@mountaya/elements 0.0.0-stage → 0.1.0
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/CHANGELOG.md +235 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +1509 -2
- package/THIRD-PARTY-NOTICES.txt +103 -0
- package/dist/accentColor-GNKBD2CW.js +4 -0
- package/dist/accentColor-GNKBD2CW.js.map +1 -0
- package/dist/accentColor-VX2JSMGE.cjs +17 -0
- package/dist/accentColor-VX2JSMGE.cjs.map +1 -0
- package/dist/agent/index.cjs +1964 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +2016 -0
- package/dist/agent/index.d.ts +2016 -0
- package/dist/agent/index.js +1937 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/amenities-B3-qAjxu.d.cts +160 -0
- package/dist/amenities-B3-qAjxu.d.ts +160 -0
- package/dist/bundle-Je5zsRFg.d.cts +222 -0
- package/dist/bundle-xYrrbJTH.d.ts +222 -0
- package/dist/camera/index.cjs +3477 -0
- package/dist/camera/index.cjs.map +1 -0
- package/dist/camera/index.d.cts +1751 -0
- package/dist/camera/index.d.ts +1751 -0
- package/dist/camera/index.js +3328 -0
- package/dist/camera/index.js.map +1 -0
- package/dist/camera-BrFLU1DH.d.cts +549 -0
- package/dist/camera-C48Ykaxv.d.ts +549 -0
- package/dist/chunk-23PFRRB6.js +3 -0
- package/dist/chunk-23PFRRB6.js.map +1 -0
- package/dist/chunk-2GI5SAH2.js +71 -0
- package/dist/chunk-2GI5SAH2.js.map +1 -0
- package/dist/chunk-2MQK6A74.js +39 -0
- package/dist/chunk-2MQK6A74.js.map +1 -0
- package/dist/chunk-2RE7R4LD.js +73 -0
- package/dist/chunk-2RE7R4LD.js.map +1 -0
- package/dist/chunk-3JZQKN4O.js +6 -0
- package/dist/chunk-3JZQKN4O.js.map +1 -0
- package/dist/chunk-3NDXVUUI.js +50 -0
- package/dist/chunk-3NDXVUUI.js.map +1 -0
- package/dist/chunk-3R4GFTUM.cjs +59 -0
- package/dist/chunk-3R4GFTUM.cjs.map +1 -0
- package/dist/chunk-3RVUQ6JN.cjs +22 -0
- package/dist/chunk-3RVUQ6JN.cjs.map +1 -0
- package/dist/chunk-4F6BJMJC.cjs +49 -0
- package/dist/chunk-4F6BJMJC.cjs.map +1 -0
- package/dist/chunk-4NWQD4BX.js +132 -0
- package/dist/chunk-4NWQD4BX.js.map +1 -0
- package/dist/chunk-5K2MH3R6.js +10 -0
- package/dist/chunk-5K2MH3R6.js.map +1 -0
- package/dist/chunk-6ACRNQQQ.cjs +8 -0
- package/dist/chunk-6ACRNQQQ.cjs.map +1 -0
- package/dist/chunk-6D26E3IA.js +66 -0
- package/dist/chunk-6D26E3IA.js.map +1 -0
- package/dist/chunk-6ESAW35P.cjs +80 -0
- package/dist/chunk-6ESAW35P.cjs.map +1 -0
- package/dist/chunk-6LIW2A5M.cjs +1176 -0
- package/dist/chunk-6LIW2A5M.cjs.map +1 -0
- package/dist/chunk-6OTTWVCA.js +57 -0
- package/dist/chunk-6OTTWVCA.js.map +1 -0
- package/dist/chunk-6VROJ4UG.js +862 -0
- package/dist/chunk-6VROJ4UG.js.map +1 -0
- package/dist/chunk-6Y7FTGO4.js +23 -0
- package/dist/chunk-6Y7FTGO4.js.map +1 -0
- package/dist/chunk-75I4CG64.js +104 -0
- package/dist/chunk-75I4CG64.js.map +1 -0
- package/dist/chunk-7CUBXHAH.cjs +14 -0
- package/dist/chunk-7CUBXHAH.cjs.map +1 -0
- package/dist/chunk-7GTCURVY.js +52 -0
- package/dist/chunk-7GTCURVY.js.map +1 -0
- package/dist/chunk-7IWOL6AM.cjs +100 -0
- package/dist/chunk-7IWOL6AM.cjs.map +1 -0
- package/dist/chunk-7QN7M667.cjs +151 -0
- package/dist/chunk-7QN7M667.cjs.map +1 -0
- package/dist/chunk-A6KQDKLM.cjs +1197 -0
- package/dist/chunk-A6KQDKLM.cjs.map +1 -0
- package/dist/chunk-A77EA67G.js +354 -0
- package/dist/chunk-A77EA67G.js.map +1 -0
- package/dist/chunk-AFKOABJ4.cjs +7194 -0
- package/dist/chunk-AFKOABJ4.cjs.map +1 -0
- package/dist/chunk-AG6JV5Z2.cjs +183 -0
- package/dist/chunk-AG6JV5Z2.cjs.map +1 -0
- package/dist/chunk-APBK7NMS.js +30 -0
- package/dist/chunk-APBK7NMS.js.map +1 -0
- package/dist/chunk-AWO5YA7A.cjs +33 -0
- package/dist/chunk-AWO5YA7A.cjs.map +1 -0
- package/dist/chunk-AZATU6QW.js +108 -0
- package/dist/chunk-AZATU6QW.js.map +1 -0
- package/dist/chunk-BD2U3WST.cjs +623 -0
- package/dist/chunk-BD2U3WST.cjs.map +1 -0
- package/dist/chunk-BHBEOU6L.cjs +65 -0
- package/dist/chunk-BHBEOU6L.cjs.map +1 -0
- package/dist/chunk-CNOSNYNE.js +8 -0
- package/dist/chunk-CNOSNYNE.js.map +1 -0
- package/dist/chunk-CW3EFR4O.js +12 -0
- package/dist/chunk-CW3EFR4O.js.map +1 -0
- package/dist/chunk-DASVRNBK.js +7187 -0
- package/dist/chunk-DASVRNBK.js.map +1 -0
- package/dist/chunk-DJ6LCKYP.js +42 -0
- package/dist/chunk-DJ6LCKYP.js.map +1 -0
- package/dist/chunk-E5FHQAIO.cjs +45 -0
- package/dist/chunk-E5FHQAIO.cjs.map +1 -0
- package/dist/chunk-EOML5OTY.cjs +360 -0
- package/dist/chunk-EOML5OTY.cjs.map +1 -0
- package/dist/chunk-EP5CASHL.js +613 -0
- package/dist/chunk-EP5CASHL.js.map +1 -0
- package/dist/chunk-EP5OEEVZ.cjs +14 -0
- package/dist/chunk-EP5OEEVZ.cjs.map +1 -0
- package/dist/chunk-EUXI3FGQ.js +150 -0
- package/dist/chunk-EUXI3FGQ.js.map +1 -0
- package/dist/chunk-EWFSHCOS.js +40 -0
- package/dist/chunk-EWFSHCOS.js.map +1 -0
- package/dist/chunk-EX2C5K2T.cjs +25 -0
- package/dist/chunk-EX2C5K2T.cjs.map +1 -0
- package/dist/chunk-FEXWDQIZ.cjs +8 -0
- package/dist/chunk-FEXWDQIZ.cjs.map +1 -0
- package/dist/chunk-FEYBFY7H.cjs +358 -0
- package/dist/chunk-FEYBFY7H.cjs.map +1 -0
- package/dist/chunk-FRGAV6N6.cjs +34 -0
- package/dist/chunk-FRGAV6N6.cjs.map +1 -0
- package/dist/chunk-G5DHP5VF.js +6 -0
- package/dist/chunk-G5DHP5VF.js.map +1 -0
- package/dist/chunk-G5W2UHV2.js +99 -0
- package/dist/chunk-G5W2UHV2.js.map +1 -0
- package/dist/chunk-G7OP7O2C.cjs +39 -0
- package/dist/chunk-G7OP7O2C.cjs.map +1 -0
- package/dist/chunk-GE6CFCAM.cjs +25 -0
- package/dist/chunk-GE6CFCAM.cjs.map +1 -0
- package/dist/chunk-GIFALLHI.cjs +111 -0
- package/dist/chunk-GIFALLHI.cjs.map +1 -0
- package/dist/chunk-GLFET5GM.js +129 -0
- package/dist/chunk-GLFET5GM.js.map +1 -0
- package/dist/chunk-GQ6UFPFM.js +22 -0
- package/dist/chunk-GQ6UFPFM.js.map +1 -0
- package/dist/chunk-GQJWVMXS.js +129 -0
- package/dist/chunk-GQJWVMXS.js.map +1 -0
- package/dist/chunk-GVVJPUKC.js +80 -0
- package/dist/chunk-GVVJPUKC.js.map +1 -0
- package/dist/chunk-GZ2HOCQ2.cjs +134 -0
- package/dist/chunk-GZ2HOCQ2.cjs.map +1 -0
- package/dist/chunk-HCBOHXWP.js +37 -0
- package/dist/chunk-HCBOHXWP.js.map +1 -0
- package/dist/chunk-IBQJDVHF.cjs +281 -0
- package/dist/chunk-IBQJDVHF.cjs.map +1 -0
- package/dist/chunk-ISLB6Y5Q.cjs +106 -0
- package/dist/chunk-ISLB6Y5Q.cjs.map +1 -0
- package/dist/chunk-J55CRR4F.js +105 -0
- package/dist/chunk-J55CRR4F.js.map +1 -0
- package/dist/chunk-JBG6Z6MQ.cjs +28 -0
- package/dist/chunk-JBG6Z6MQ.cjs.map +1 -0
- package/dist/chunk-K3RQOZRU.js +61 -0
- package/dist/chunk-K3RQOZRU.js.map +1 -0
- package/dist/chunk-KDJYS4GB.cjs +703 -0
- package/dist/chunk-KDJYS4GB.cjs.map +1 -0
- package/dist/chunk-KMCAHUZM.cjs +4 -0
- package/dist/chunk-KMCAHUZM.cjs.map +1 -0
- package/dist/chunk-KUCBNPC6.js +87 -0
- package/dist/chunk-KUCBNPC6.js.map +1 -0
- package/dist/chunk-KV6UE5A4.js +50 -0
- package/dist/chunk-KV6UE5A4.js.map +1 -0
- package/dist/chunk-L6TZ2HQR.cjs +18 -0
- package/dist/chunk-L6TZ2HQR.cjs.map +1 -0
- package/dist/chunk-L7QHHGG2.cjs +141 -0
- package/dist/chunk-L7QHHGG2.cjs.map +1 -0
- package/dist/chunk-LHK3Y2AL.js +271 -0
- package/dist/chunk-LHK3Y2AL.js.map +1 -0
- package/dist/chunk-LO5RYRBH.cjs +6317 -0
- package/dist/chunk-LO5RYRBH.cjs.map +1 -0
- package/dist/chunk-LS5SJMUO.cjs +194 -0
- package/dist/chunk-LS5SJMUO.cjs.map +1 -0
- package/dist/chunk-LUGTMZFN.cjs +42 -0
- package/dist/chunk-LUGTMZFN.cjs.map +1 -0
- package/dist/chunk-LVUQU6D5.js +32 -0
- package/dist/chunk-LVUQU6D5.js.map +1 -0
- package/dist/chunk-M2QRC2GZ.js +166 -0
- package/dist/chunk-M2QRC2GZ.js.map +1 -0
- package/dist/chunk-M6QJYQIM.cjs +53 -0
- package/dist/chunk-M6QJYQIM.cjs.map +1 -0
- package/dist/chunk-MGCPH5EO.js +12 -0
- package/dist/chunk-MGCPH5EO.js.map +1 -0
- package/dist/chunk-MLVUWEZR.cjs +474 -0
- package/dist/chunk-MLVUWEZR.cjs.map +1 -0
- package/dist/chunk-MTAMJMZL.cjs +707 -0
- package/dist/chunk-MTAMJMZL.cjs.map +1 -0
- package/dist/chunk-MXL5AT3N.js +48 -0
- package/dist/chunk-MXL5AT3N.js.map +1 -0
- package/dist/chunk-MYEQSESM.cjs +75 -0
- package/dist/chunk-MYEQSESM.cjs.map +1 -0
- package/dist/chunk-N3VPF6ZD.js +427 -0
- package/dist/chunk-N3VPF6ZD.js.map +1 -0
- package/dist/chunk-N6VUAIGI.js +7 -0
- package/dist/chunk-N6VUAIGI.js.map +1 -0
- package/dist/chunk-N6XRLUN6.js +6286 -0
- package/dist/chunk-N6XRLUN6.js.map +1 -0
- package/dist/chunk-NOGDOZIT.cjs +114 -0
- package/dist/chunk-NOGDOZIT.cjs.map +1 -0
- package/dist/chunk-NUWXEISH.cjs +10 -0
- package/dist/chunk-NUWXEISH.cjs.map +1 -0
- package/dist/chunk-NZCZHXYN.cjs +161 -0
- package/dist/chunk-NZCZHXYN.cjs.map +1 -0
- package/dist/chunk-ODROSWQX.cjs +53 -0
- package/dist/chunk-ODROSWQX.cjs.map +1 -0
- package/dist/chunk-OE36AYKG.cjs +82 -0
- package/dist/chunk-OE36AYKG.cjs.map +1 -0
- package/dist/chunk-OLON7MO6.cjs +437 -0
- package/dist/chunk-OLON7MO6.cjs.map +1 -0
- package/dist/chunk-PBUOR2IT.js +277 -0
- package/dist/chunk-PBUOR2IT.js.map +1 -0
- package/dist/chunk-PC2ELXFF.cjs +225 -0
- package/dist/chunk-PC2ELXFF.cjs.map +1 -0
- package/dist/chunk-PCSGXLOC.js +71 -0
- package/dist/chunk-PCSGXLOC.js.map +1 -0
- package/dist/chunk-PFNMP6FQ.js +56 -0
- package/dist/chunk-PFNMP6FQ.js.map +1 -0
- package/dist/chunk-PIWSZTIP.js +690 -0
- package/dist/chunk-PIWSZTIP.js.map +1 -0
- package/dist/chunk-PKWHJ2GI.js +136 -0
- package/dist/chunk-PKWHJ2GI.js.map +1 -0
- package/dist/chunk-PLMVBX2A.cjs +76 -0
- package/dist/chunk-PLMVBX2A.cjs.map +1 -0
- package/dist/chunk-PM3XCD2G.cjs +113 -0
- package/dist/chunk-PM3XCD2G.cjs.map +1 -0
- package/dist/chunk-QAL4GZO7.cjs +143 -0
- package/dist/chunk-QAL4GZO7.cjs.map +1 -0
- package/dist/chunk-QDB2SEA2.js +74 -0
- package/dist/chunk-QDB2SEA2.js.map +1 -0
- package/dist/chunk-QOV7UNUN.js +25 -0
- package/dist/chunk-QOV7UNUN.js.map +1 -0
- package/dist/chunk-QQUWYLSF.cjs +50 -0
- package/dist/chunk-QQUWYLSF.cjs.map +1 -0
- package/dist/chunk-QUMBH3U4.cjs +9 -0
- package/dist/chunk-QUMBH3U4.cjs.map +1 -0
- package/dist/chunk-R4KA7OFQ.js +12 -0
- package/dist/chunk-R4KA7OFQ.js.map +1 -0
- package/dist/chunk-RBSGAZQQ.js +17 -0
- package/dist/chunk-RBSGAZQQ.js.map +1 -0
- package/dist/chunk-RM5YJWZI.js +46 -0
- package/dist/chunk-RM5YJWZI.js.map +1 -0
- package/dist/chunk-ROKNKXA4.cjs +8 -0
- package/dist/chunk-ROKNKXA4.cjs.map +1 -0
- package/dist/chunk-RQG6D546.cjs +75 -0
- package/dist/chunk-RQG6D546.cjs.map +1 -0
- package/dist/chunk-SG4YDD5L.cjs +74 -0
- package/dist/chunk-SG4YDD5L.cjs.map +1 -0
- package/dist/chunk-SNRCA7EO.js +56 -0
- package/dist/chunk-SNRCA7EO.js.map +1 -0
- package/dist/chunk-SO75R4WW.cjs +22 -0
- package/dist/chunk-SO75R4WW.cjs.map +1 -0
- package/dist/chunk-SP34NHFI.js +45 -0
- package/dist/chunk-SP34NHFI.js.map +1 -0
- package/dist/chunk-SSKSSBWJ.cjs +179 -0
- package/dist/chunk-SSKSSBWJ.cjs.map +1 -0
- package/dist/chunk-TB5663C2.js +1108 -0
- package/dist/chunk-TB5663C2.js.map +1 -0
- package/dist/chunk-TGH4NRES.js +220 -0
- package/dist/chunk-TGH4NRES.js.map +1 -0
- package/dist/chunk-TJ6ZPNID.js +189 -0
- package/dist/chunk-TJ6ZPNID.js.map +1 -0
- package/dist/chunk-U45T35N2.cjs +90 -0
- package/dist/chunk-U45T35N2.cjs.map +1 -0
- package/dist/chunk-UKVOPEZ2.js +442 -0
- package/dist/chunk-UKVOPEZ2.js.map +1 -0
- package/dist/chunk-UTB4NROA.cjs +887 -0
- package/dist/chunk-UTB4NROA.cjs.map +1 -0
- package/dist/chunk-UTW33B5V.js +6 -0
- package/dist/chunk-UTW33B5V.js.map +1 -0
- package/dist/chunk-UYUBSD2V.cjs +33 -0
- package/dist/chunk-UYUBSD2V.cjs.map +1 -0
- package/dist/chunk-V3JEP5AG.cjs +59 -0
- package/dist/chunk-V3JEP5AG.cjs.map +1 -0
- package/dist/chunk-VFAGJXHR.js +18 -0
- package/dist/chunk-VFAGJXHR.js.map +1 -0
- package/dist/chunk-VMEE57E5.cjs +58 -0
- package/dist/chunk-VMEE57E5.cjs.map +1 -0
- package/dist/chunk-VQVBEX3Y.cjs +113 -0
- package/dist/chunk-VQVBEX3Y.cjs.map +1 -0
- package/dist/chunk-VZDXX7TT.cjs +64 -0
- package/dist/chunk-VZDXX7TT.cjs.map +1 -0
- package/dist/chunk-WE5ZTI4D.js +346 -0
- package/dist/chunk-WE5ZTI4D.js.map +1 -0
- package/dist/chunk-WEFUVABP.js +19 -0
- package/dist/chunk-WEFUVABP.js.map +1 -0
- package/dist/chunk-WMU4LRKC.js +28 -0
- package/dist/chunk-WMU4LRKC.js.map +1 -0
- package/dist/chunk-WQ24RRHL.cjs +354 -0
- package/dist/chunk-WQ24RRHL.cjs.map +1 -0
- package/dist/chunk-WW4CGS7G.cjs +26 -0
- package/dist/chunk-WW4CGS7G.cjs.map +1 -0
- package/dist/chunk-WXE5WCTM.js +1144 -0
- package/dist/chunk-WXE5WCTM.js.map +1 -0
- package/dist/chunk-X23BGIYA.cjs +37 -0
- package/dist/chunk-X23BGIYA.cjs.map +1 -0
- package/dist/chunk-XEW4FTR2.js +98 -0
- package/dist/chunk-XEW4FTR2.js.map +1 -0
- package/dist/chunk-XIOI4IYW.js +167 -0
- package/dist/chunk-XIOI4IYW.js.map +1 -0
- package/dist/chunk-XLVPJ37V.cjs +44 -0
- package/dist/chunk-XLVPJ37V.cjs.map +1 -0
- package/dist/chunk-XOHAXXZA.cjs +51 -0
- package/dist/chunk-XOHAXXZA.cjs.map +1 -0
- package/dist/chunk-Y4NRIHK6.cjs +313 -0
- package/dist/chunk-Y4NRIHK6.cjs.map +1 -0
- package/dist/chunk-Y4YMMKL3.js +23 -0
- package/dist/chunk-Y4YMMKL3.js.map +1 -0
- package/dist/chunk-YJNYBVE3.cjs +14 -0
- package/dist/chunk-YJNYBVE3.cjs.map +1 -0
- package/dist/chunk-Z762QNQP.cjs +60 -0
- package/dist/chunk-Z762QNQP.cjs.map +1 -0
- package/dist/chunk-ZG5KMBOF.js +669 -0
- package/dist/chunk-ZG5KMBOF.js.map +1 -0
- package/dist/chunk-ZKONQEFA.js +344 -0
- package/dist/chunk-ZKONQEFA.js.map +1 -0
- package/dist/chunk-ZR5X7QMH.js +39 -0
- package/dist/chunk-ZR5X7QMH.js.map +1 -0
- package/dist/chunk-ZW4BJQ26.js +84 -0
- package/dist/chunk-ZW4BJQ26.js.map +1 -0
- package/dist/climbs-BhlWuu0x.d.ts +70 -0
- package/dist/climbs-DgBFwySV.d.cts +70 -0
- package/dist/collab/index.cjs +1283 -0
- package/dist/collab/index.cjs.map +1 -0
- package/dist/collab/index.d.cts +850 -0
- package/dist/collab/index.d.ts +850 -0
- package/dist/collab/index.js +1274 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/data/index.cjs +132 -0
- package/dist/data/index.cjs.map +1 -0
- package/dist/data/index.d.cts +468 -0
- package/dist/data/index.d.ts +468 -0
- package/dist/data/index.js +15 -0
- package/dist/data/index.js.map +1 -0
- package/dist/editor/index.cjs +4506 -0
- package/dist/editor/index.cjs.map +1 -0
- package/dist/editor/index.d.cts +59 -0
- package/dist/editor/index.d.ts +59 -0
- package/dist/editor/index.js +4486 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/elevationTiles-pmsb9wnU.d.cts +77 -0
- package/dist/elevationTiles-pmsb9wnU.d.ts +77 -0
- package/dist/errors/index.cjs +28 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +125 -0
- package/dist/errors/index.d.ts +125 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/geo/index.cjs +232 -0
- package/dist/geo/index.cjs.map +1 -0
- package/dist/geo/index.d.cts +821 -0
- package/dist/geo/index.d.ts +821 -0
- package/dist/geo/index.js +15 -0
- package/dist/geo/index.js.map +1 -0
- package/dist/geodesy-543qXKtI.d.cts +78 -0
- package/dist/geodesy-543qXKtI.d.ts +78 -0
- package/dist/geolocation-DDkQdWMN.d.cts +106 -0
- package/dist/geolocation-DDkQdWMN.d.ts +106 -0
- package/dist/i18n/fr/index.cjs +338 -0
- package/dist/i18n/fr/index.cjs.map +1 -0
- package/dist/i18n/fr/index.d.cts +25 -0
- package/dist/i18n/fr/index.d.ts +25 -0
- package/dist/i18n/fr/index.js +336 -0
- package/dist/i18n/fr/index.js.map +1 -0
- package/dist/i18n/index.cjs +464 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +227 -0
- package/dist/i18n/index.d.ts +227 -0
- package/dist/i18n/index.js +430 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/icons/index.cjs +116 -0
- package/dist/icons/index.cjs.map +1 -0
- package/dist/icons/index.d.cts +457 -0
- package/dist/icons/index.d.ts +457 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.cjs +1869 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +251 -0
- package/dist/index.d.ts +251 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/itinerary-Dp2ZnqgD.d.cts +178 -0
- package/dist/itinerary-Dp2ZnqgD.d.ts +178 -0
- package/dist/language-CEWQ5uYw.d.cts +69 -0
- package/dist/language-CEWQ5uYw.d.ts +69 -0
- package/dist/layers/index.cjs +318 -0
- package/dist/layers/index.cjs.map +1 -0
- package/dist/layers/index.d.cts +1555 -0
- package/dist/layers/index.d.ts +1555 -0
- package/dist/layers/index.js +17 -0
- package/dist/layers/index.js.map +1 -0
- package/dist/map-client/index.cjs +4 -0
- package/dist/map-client/index.cjs.map +1 -0
- package/dist/map-client/index.d.cts +1856 -0
- package/dist/map-client/index.d.ts +1856 -0
- package/dist/map-client/index.js +3 -0
- package/dist/map-client/index.js.map +1 -0
- package/dist/maplibre-worker.mjs +12 -0
- package/dist/markerSprite-DGBQF6PO.cjs +49 -0
- package/dist/markerSprite-DGBQF6PO.cjs.map +1 -0
- package/dist/markerSprite-DZLTR6F6.js +8 -0
- package/dist/markerSprite-DZLTR6F6.js.map +1 -0
- package/dist/mountayaMap-C9mxRFib.d.cts +3277 -0
- package/dist/mountayaMap-DgnlQ2fE.d.ts +3277 -0
- package/dist/navigation/index.cjs +699 -0
- package/dist/navigation/index.cjs.map +1 -0
- package/dist/navigation/index.d.cts +632 -0
- package/dist/navigation/index.d.ts +632 -0
- package/dist/navigation/index.js +689 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/order-BLhsGsH8.d.ts +132 -0
- package/dist/order-BZkUwMou.d.cts +132 -0
- package/dist/paint-BgUcj8l7.d.cts +118 -0
- package/dist/paint-Dx_qGNE_.d.ts +118 -0
- package/dist/profile/index.cjs +675 -0
- package/dist/profile/index.cjs.map +1 -0
- package/dist/profile/index.d.cts +2086 -0
- package/dist/profile/index.d.ts +2086 -0
- package/dist/profile/index.js +18 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/provider-DM71XnLX.d.cts +121 -0
- package/dist/provider-DM71XnLX.d.ts +121 -0
- package/dist/roadAccess-D_rOE4xW.d.cts +86 -0
- package/dist/roadAccess-D_rOE4xW.d.ts +86 -0
- package/dist/routeProfile-BKfSfxx6.d.ts +210 -0
- package/dist/routeProfile-BsSUABXv.d.cts +210 -0
- package/dist/seams/index.cjs +39 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +254 -0
- package/dist/seams/index.d.ts +254 -0
- package/dist/seams/index.js +6 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/search/index.cjs +147 -0
- package/dist/search/index.cjs.map +1 -0
- package/dist/search/index.d.cts +888 -0
- package/dist/search/index.d.ts +888 -0
- package/dist/search/index.js +14 -0
- package/dist/search/index.js.map +1 -0
- package/dist/searchHighlight-DFE7LVIL.cjs +33 -0
- package/dist/searchHighlight-DFE7LVIL.cjs.map +1 -0
- package/dist/searchHighlight-MHAQZVWG.js +12 -0
- package/dist/searchHighlight-MHAQZVWG.js.map +1 -0
- package/dist/searchLimits-j99-NTXR.d.cts +24 -0
- package/dist/searchLimits-j99-NTXR.d.ts +24 -0
- package/dist/sections-CVlc2Inr.d.cts +953 -0
- package/dist/sections-CmtaduLc.d.ts +953 -0
- package/dist/segmentRoute-C5UL_5bp.d.ts +172 -0
- package/dist/segmentRoute-CIo6dR8Y.d.cts +172 -0
- package/dist/strings-30RSdIat.d.cts +552 -0
- package/dist/strings-DPTIbzT5.d.ts +552 -0
- package/dist/stripeImage-CQUXM2YI.js +14 -0
- package/dist/stripeImage-CQUXM2YI.js.map +1 -0
- package/dist/stripeImage-R43OPA6U.cjs +39 -0
- package/dist/stripeImage-R43OPA6U.cjs.map +1 -0
- package/dist/style/index.cjs +116 -0
- package/dist/style/index.cjs.map +1 -0
- package/dist/style/index.d.cts +538 -0
- package/dist/style/index.d.ts +538 -0
- package/dist/style/index.js +11 -0
- package/dist/style/index.js.map +1 -0
- package/dist/styles.css +11 -0
- package/dist/testing/index.cjs +629 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +265 -0
- package/dist/testing/index.d.ts +265 -0
- package/dist/testing/index.js +623 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/timezone/index.cjs +759 -0
- package/dist/timezone/index.cjs.map +1 -0
- package/dist/timezone/index.d.cts +53 -0
- package/dist/timezone/index.d.ts +53 -0
- package/dist/timezone/index.js +757 -0
- package/dist/timezone/index.js.map +1 -0
- package/dist/types-B034JMjl.d.ts +973 -0
- package/dist/types-B2NDLxQA.d.cts +21 -0
- package/dist/types-B2NDLxQA.d.ts +21 -0
- package/dist/types-BEv8V_8V.d.cts +55 -0
- package/dist/types-BEv8V_8V.d.ts +55 -0
- package/dist/types-C8aX5KMU.d.cts +973 -0
- package/dist/types-CTQwbSdA.d.cts +321 -0
- package/dist/types-nO2joeRk.d.ts +321 -0
- package/dist/units/index.cjs +99 -0
- package/dist/units/index.cjs.map +1 -0
- package/dist/units/index.d.cts +75 -0
- package/dist/units/index.d.ts +75 -0
- package/dist/units/index.js +6 -0
- package/dist/units/index.js.map +1 -0
- package/dist/units-D9mBrusY.d.cts +900 -0
- package/dist/units-D9mBrusY.d.ts +900 -0
- package/dist/video/index.cjs +2198 -0
- package/dist/video/index.cjs.map +1 -0
- package/dist/video/index.d.cts +873 -0
- package/dist/video/index.d.ts +873 -0
- package/dist/video/index.js +2173 -0
- package/dist/video/index.js.map +1 -0
- package/dist/videoOverlay-Dh_D5_Zs.d.cts +44 -0
- package/dist/videoOverlay-Dh_D5_Zs.d.ts +44 -0
- package/dist/view/index.cjs +43 -0
- package/dist/view/index.cjs.map +1 -0
- package/dist/view/index.d.cts +836 -0
- package/dist/view/index.d.ts +836 -0
- package/dist/view/index.js +34 -0
- package/dist/view/index.js.map +1 -0
- package/dist/zones-B05QA8fy.d.cts +75 -0
- package/dist/zones-B05QA8fy.d.ts +75 -0
- package/package.json +433 -4
- package/src/agent/engines/session.ts +2255 -0
- package/src/agent/index.ts +109 -0
- package/src/agent/rules/agentError.ts +128 -0
- package/src/agent/rules/boundedInputJson.ts +53 -0
- package/src/agent/rules/conversation.ts +629 -0
- package/src/agent/rules/conversationFaults.ts +349 -0
- package/src/agent/rules/conversationHost.ts +390 -0
- package/src/agent/rules/dispatcher.ts +102 -0
- package/src/agent/rules/errorCodes.ts +78 -0
- package/src/agent/rules/errorStatus.ts +65 -0
- package/src/agent/rules/scriptedTransport.ts +390 -0
- package/src/agent/rules/stickToBottom.ts +38 -0
- package/src/agent/rules/toolResultPayload.ts +197 -0
- package/src/auth/rules/clientHeader.ts +22 -0
- package/src/auth/rules/sentCredential.ts +76 -0
- package/src/auth/rules/transformRequest.ts +803 -0
- package/src/camera/engines/videoFlight.ts +1758 -0
- package/src/camera/index.ts +157 -0
- package/src/camera/rules/clearance.ts +1099 -0
- package/src/camera/rules/fit.ts +132 -0
- package/src/camera/rules/modes.ts +1023 -0
- package/src/camera/rules/plan.ts +478 -0
- package/src/camera/rules/planner.ts +129 -0
- package/src/camera/rules/poseRanges.ts +38 -0
- package/src/camera/rules/presets.ts +185 -0
- package/src/camera/rules/profileSamples.ts +243 -0
- package/src/camera/rules/route.ts +596 -0
- package/src/camera/rules/routeContent.ts +104 -0
- package/src/camera/rules/spline.ts +765 -0
- package/src/camera/rules/sweptViewports.ts +39 -0
- package/src/camera/rules/track.ts +1412 -0
- package/src/camera/rules/vocabulary.ts +130 -0
- package/src/camera/rules/zoom.ts +216 -0
- package/src/collab/engines/session.ts +1902 -0
- package/src/collab/engines/trailingThrottle.ts +151 -0
- package/src/collab/index.ts +56 -0
- package/src/collab/rules/dispatch.ts +143 -0
- package/src/collab/rules/peerNames.ts +51 -0
- package/src/collab/rules/scriptedTransport.ts +244 -0
- package/src/compose/engines/baseMapSwitch.ts +1136 -0
- package/src/compose/engines/events.ts +962 -0
- package/src/compose/engines/mountayaMap.ts +5674 -0
- package/src/compose/engines/sentCredentials.ts +146 -0
- package/src/compose/engines/slotRequests.ts +413 -0
- package/src/compose/rules/accessRefusal.ts +109 -0
- package/src/compose/rules/accessStanding.ts +75 -0
- package/src/compose/rules/analysisKinds.ts +331 -0
- package/src/compose/rules/analysisLayers.ts +176 -0
- package/src/compose/rules/cameraMoves.ts +38 -0
- package/src/compose/rules/carriedLayers.ts +87 -0
- package/src/compose/rules/developmentWarnings.ts +166 -0
- package/src/compose/rules/fitCamera.ts +54 -0
- package/src/compose/rules/geoJsonSlot.ts +61 -0
- package/src/compose/rules/geometrySlots.ts +155 -0
- package/src/compose/rules/glyphNode.ts +62 -0
- package/src/compose/rules/layerKeys.ts +92 -0
- package/src/compose/rules/layerOrder.ts +85 -0
- package/src/compose/rules/layersManifest.ts +26 -0
- package/src/compose/rules/mapOptions.ts +300 -0
- package/src/compose/rules/maplibreWorkerVersion.gen.ts +8 -0
- package/src/compose/rules/markerPin.ts +122 -0
- package/src/compose/rules/markerRegistry.ts +85 -0
- package/src/compose/rules/markerSprite.ts +382 -0
- package/src/compose/rules/maxBounds.ts +120 -0
- package/src/compose/rules/overlayLookup.ts +49 -0
- package/src/compose/rules/paintDiff.ts +38 -0
- package/src/compose/rules/panLock.ts +77 -0
- package/src/compose/rules/patch.ts +124 -0
- package/src/compose/rules/queriedFeature.ts +55 -0
- package/src/compose/rules/queryLayers.ts +46 -0
- package/src/compose/rules/searchHighlight.ts +313 -0
- package/src/compose/rules/slotNames.ts +19 -0
- package/src/compose/rules/stripeImage.ts +253 -0
- package/src/compose/rules/swapMarker.ts +66 -0
- package/src/compose/rules/terrainVariant.ts +88 -0
- package/src/compose/rules/types.ts +566 -0
- package/src/compose/rules/urlHash.ts +19 -0
- package/src/compose/rules/viewOptions.ts +451 -0
- package/src/compose/rules/workerUrl.ts +96 -0
- package/src/data/engines/itineraryResource.ts +643 -0
- package/src/data/index.ts +78 -0
- package/src/data/rules/adapt.ts +473 -0
- package/src/data/rules/editModes.ts +51 -0
- package/src/data/rules/itinerary.ts +168 -0
- package/src/data/rules/nullable.ts +63 -0
- package/src/data/rules/roadAccess.ts +169 -0
- package/src/data/rules/segmentGroups.ts +309 -0
- package/src/data/rules/selectors.ts +95 -0
- package/src/data/rules/zones.ts +79 -0
- package/src/draw/engines/boundaryEngine.ts +1003 -0
- package/src/draw/engines/framedAdapter.ts +198 -0
- package/src/draw/engines/pointerCursor.ts +205 -0
- package/src/draw/engines/segmentEngine.ts +1405 -0
- package/src/draw/engines/snapIndex.ts +254 -0
- package/src/draw/engines/waypointEngine.ts +574 -0
- package/src/draw/engines/zoneEngine.ts +1137 -0
- package/src/draw/rules/drawFrame.ts +123 -0
- package/src/draw/rules/insertVertex.ts +226 -0
- package/src/draw/rules/screenSpace.ts +62 -0
- package/src/draw/rules/seeds.ts +185 -0
- package/src/draw/rules/snap.ts +115 -0
- package/src/draw/rules/snapCameraKey.ts +50 -0
- package/src/draw/rules/terraDrawShared.ts +214 -0
- package/src/draw/rules/zoneOutline.ts +213 -0
- package/src/editing/engines/cursor.ts +505 -0
- package/src/editing/engines/draftMarker.ts +149 -0
- package/src/editing/rules/accent.ts +11 -0
- package/src/editing/rules/engine.ts +286 -0
- package/src/editing/rules/placement.ts +22 -0
- package/src/editing/rules/positions.ts +89 -0
- package/src/editing/rules/sources.ts +9 -0
- package/src/editing/rules/types.ts +457 -0
- package/src/editing/rules/vocabulary.ts +10 -0
- package/src/editing/rules/waypointCursor.ts +228 -0
- package/src/editor/engines/directionArrows.ts +459 -0
- package/src/editor/engines/directions.ts +1383 -0
- package/src/editor/engines/editorClient.ts +134 -0
- package/src/editor/engines/eventScope.ts +59 -0
- package/src/editor/engines/frameLoop.ts +159 -0
- package/src/editor/engines/itineraryPreview.ts +272 -0
- package/src/editor/engines/mapLockGuard.ts +66 -0
- package/src/editor/engines/overlayRenderer.ts +2696 -0
- package/src/editor/engines/peerDraft.ts +760 -0
- package/src/editor/engines/poiPick.ts +305 -0
- package/src/editor/engines/pointPick.ts +84 -0
- package/src/editor/engines/roadAccessLine.ts +140 -0
- package/src/editor/engines/searchHighlight.ts +183 -0
- package/src/editor/engines/viewClient.ts +4083 -0
- package/src/editor/engines/zoneBadges.ts +503 -0
- package/src/editor/index.ts +97 -0
- package/src/editor/rules/accentColor.ts +116 -0
- package/src/editor/rules/camera.ts +121 -0
- package/src/editor/rules/contract.ts +125 -0
- package/src/editor/rules/icons.ts +825 -0
- package/src/editor/rules/markerElements.ts +244 -0
- package/src/editor/rules/style.ts +51 -0
- package/src/editor/rules/terrain.ts +98 -0
- package/src/editor/rules/tileWarm.ts +191 -0
- package/src/editor/rules/tilesReload.ts +158 -0
- package/src/editor/rules/zoneBadgePlacement.ts +1832 -0
- package/src/editor/rules/zoneTimeStyling.ts +119 -0
- package/src/errors/index.ts +25 -0
- package/src/errors/rules/errors.ts +157 -0
- package/src/errors/rules/print.ts +129 -0
- package/src/geo/index.ts +94 -0
- package/src/geo/rules/boundaries.ts +105 -0
- package/src/geo/rules/camera.ts +496 -0
- package/src/geo/rules/corridor.ts +242 -0
- package/src/geo/rules/elevationTiles.ts +269 -0
- package/src/geo/rules/formatLngLat.ts +63 -0
- package/src/geo/rules/geodesy.ts +125 -0
- package/src/geo/rules/geometry.ts +362 -0
- package/src/geo/rules/lineWalk.ts +77 -0
- package/src/geo/rules/longitude.ts +99 -0
- package/src/geo/rules/searchLimits.ts +22 -0
- package/src/geo/rules/segmentGeometry.ts +80 -0
- package/src/geo/rules/terrain.ts +107 -0
- package/src/geo/rules/tuples.ts +124 -0
- package/src/geo/rules/types.ts +54 -0
- package/src/geo/rules/webMercator.ts +57 -0
- package/src/i18n/fr/index.ts +17 -0
- package/src/i18n/fr/rules/fr.ts +85 -0
- package/src/i18n/fr/rules/words.gen.ts +277 -0
- package/src/i18n/index.ts +81 -0
- package/src/i18n/rules/bundle.ts +378 -0
- package/src/i18n/rules/config.ts +71 -0
- package/src/i18n/rules/endonyms.gen.ts +19 -0
- package/src/i18n/rules/language.ts +92 -0
- package/src/i18n/rules/localizedName.ts +33 -0
- package/src/i18n/rules/merge.ts +106 -0
- package/src/i18n/rules/scope.ts +127 -0
- package/src/i18n/rules/strings.ts +632 -0
- package/src/i18n/rules/videoOverlay.ts +121 -0
- package/src/i18n/rules/wordForms.ts +95 -0
- package/src/i18n/rules/words.gen.ts +277 -0
- package/src/icons/index.ts +54 -0
- package/src/icons/rules/activities.ts +40 -0
- package/src/icons/rules/amenities.ts +250 -0
- package/src/icons/rules/artwork.gen.ts +83 -0
- package/src/icons/rules/artwork.ts +47 -0
- package/src/icons/rules/fallback.ts +21 -0
- package/src/icons/rules/lucideMarkers.gen.ts +112 -0
- package/src/icons/rules/lucideUi.gen.ts +197 -0
- package/src/icons/rules/paint.ts +107 -0
- package/src/icons/rules/parse.ts +475 -0
- package/src/icons/rules/provider.ts +373 -0
- package/src/icons/rules/sprites.ts +54 -0
- package/src/icons/rules/ui.ts +348 -0
- package/src/icons/rules/waypoints.ts +215 -0
- package/src/index.ts +1012 -0
- package/src/layers/engines/layersSelection.ts +515 -0
- package/src/layers/engines/readoutEngine.ts +131 -0
- package/src/layers/index.ts +151 -0
- package/src/layers/rules/analysis.ts +135 -0
- package/src/layers/rules/enrichment.ts +30 -0
- package/src/layers/rules/geoJson.ts +270 -0
- package/src/layers/rules/hover.ts +67 -0
- package/src/layers/rules/itineraries.ts +182 -0
- package/src/layers/rules/layersPanel.ts +237 -0
- package/src/layers/rules/order.ts +194 -0
- package/src/layers/rules/overlayInstant.ts +49 -0
- package/src/layers/rules/overlays.ts +52 -0
- package/src/layers/rules/poiPanel.ts +119 -0
- package/src/layers/rules/pois.ts +114 -0
- package/src/layers/rules/readout.ts +340 -0
- package/src/layers/rules/streetView.ts +16 -0
- package/src/layers/rules/tileTimestamp.ts +146 -0
- package/src/layers/rules/timeSlider.ts +192 -0
- package/src/layers/rules/timeWindow.ts +123 -0
- package/src/layers/rules/zones.ts +43 -0
- package/src/layers/rules/zoom.ts +77 -0
- package/src/map-client/index.ts +71 -0
- package/src/map-client/rules/mapClient.ts +1943 -0
- package/src/navigation/engines/navigation.ts +493 -0
- package/src/navigation/index.ts +51 -0
- package/src/navigation/rules/followedRoute.ts +78 -0
- package/src/navigation/rules/instructions.ts +89 -0
- package/src/navigation/rules/itineraryRoute.ts +232 -0
- package/src/navigation/rules/offRoute.ts +41 -0
- package/src/navigation/rules/progress.ts +230 -0
- package/src/navigation/rules/prompts.ts +217 -0
- package/src/navigation/rules/routeRequest.ts +98 -0
- package/src/navigation/rules/status.ts +142 -0
- package/src/navigation/rules/steps.ts +234 -0
- package/src/navigation/rules/types.ts +83 -0
- package/src/profile/index.ts +307 -0
- package/src/profile/rules/amenityBadge.ts +35 -0
- package/src/profile/rules/amenityFilter.ts +74 -0
- package/src/profile/rules/amenityStacks.ts +66 -0
- package/src/profile/rules/axis.ts +89 -0
- package/src/profile/rules/axisCulling.ts +83 -0
- package/src/profile/rules/axisLookup.ts +180 -0
- package/src/profile/rules/climbs.ts +292 -0
- package/src/profile/rules/cursorMarker.ts +122 -0
- package/src/profile/rules/cursorReadout.ts +104 -0
- package/src/profile/rules/curvePlacement.ts +216 -0
- package/src/profile/rules/dock.ts +293 -0
- package/src/profile/rules/elevation.ts +1263 -0
- package/src/profile/rules/instant.ts +89 -0
- package/src/profile/rules/intl.ts +237 -0
- package/src/profile/rules/legEmphasis.ts +53 -0
- package/src/profile/rules/profileColors.ts +66 -0
- package/src/profile/rules/profileLayout.ts +59 -0
- package/src/profile/rules/profileSlices.ts +55 -0
- package/src/profile/rules/routeProfile.ts +475 -0
- package/src/profile/rules/rowMatch.ts +50 -0
- package/src/profile/rules/scale.ts +650 -0
- package/src/profile/rules/scaleFrame.ts +171 -0
- package/src/profile/rules/sectionChips.ts +83 -0
- package/src/profile/rules/sections.ts +923 -0
- package/src/profile/rules/slopeRamp.ts +160 -0
- package/src/profile/rules/statStrip.ts +103 -0
- package/src/profile/rules/steepness.ts +51 -0
- package/src/profile/rules/tableCells.ts +269 -0
- package/src/profile/rules/tableCursor.ts +87 -0
- package/src/profile/rules/unitPatterns.ts +335 -0
- package/src/profile/rules/units.ts +1025 -0
- package/src/profile/rules/waypointCard.ts +593 -0
- package/src/profile/rules/webAddress.ts +130 -0
- package/src/profile/rules/windowSpans.ts +65 -0
- package/src/rules/asciiFold.ts +17 -0
- package/src/rules/inDevelopment.ts +54 -0
- package/src/rules/listeners.ts +62 -0
- package/src/rules/timers.ts +9 -0
- package/src/rules/types.ts +22 -0
- package/src/rules/uuid.ts +87 -0
- package/src/seams/engines/geolocateControl.ts +286 -0
- package/src/seams/index.ts +50 -0
- package/src/seams/rules/clock.ts +169 -0
- package/src/seams/rules/geolocation.ts +165 -0
- package/src/seams/rules/segmentRoute.ts +187 -0
- package/src/search/engines/search.ts +1093 -0
- package/src/search/index.ts +114 -0
- package/src/search/rules/describe.ts +383 -0
- package/src/search/rules/filters.ts +195 -0
- package/src/search/rules/highlight.ts +270 -0
- package/src/search/rules/pick.ts +90 -0
- package/src/search/rules/rows.ts +258 -0
- package/src/search/rules/searchFocus.ts +27 -0
- package/src/search/rules/searchViewport.ts +44 -0
- package/src/search/rules/shown.ts +77 -0
- package/src/search/rules/types.ts +340 -0
- package/src/stream/rules/reconnectSchedule.ts +83 -0
- package/src/style/engines/organizationRead.ts +80 -0
- package/src/style/index.ts +63 -0
- package/src/style/rules/apply.ts +268 -0
- package/src/style/rules/attribution.ts +119 -0
- package/src/style/rules/itineraryLine.ts +142 -0
- package/src/style/rules/language.ts +668 -0
- package/src/style/rules/layout.gen.ts +27 -0
- package/src/style/rules/organization.ts +96 -0
- package/src/style/rules/paint.ts +143 -0
- package/src/style/rules/panelLayout.ts +51 -0
- package/src/style/rules/roadAccessColors.ts +29 -0
- package/src/style/rules/roadAccessLine.ts +267 -0
- package/src/style/rules/segmentColors.ts +207 -0
- package/src/testing/catalogs.ts +103 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/mapClient.ts +241 -0
- package/src/testing/mountayaMap.ts +741 -0
- package/src/timezone/index.ts +14 -0
- package/src/timezone/rules/viewport.ts +875 -0
- package/src/units/index.ts +55 -0
- package/src/units/rules/conversions.ts +620 -0
- package/src/units/rules/preferenceChoices.ts +124 -0
- package/src/units/rules/preferences.ts +77 -0
- package/src/units/rules/rounding.ts +69 -0
- package/src/video/engines/videoRun.ts +654 -0
- package/src/video/engines/viewClient.ts +6 -0
- package/src/video/index.ts +83 -0
- package/src/video/profileOverlay/rules/contract.ts +212 -0
- package/src/video/profileOverlay/rules/curve.ts +216 -0
- package/src/video/profileOverlay/rules/draw.ts +410 -0
- package/src/video/profileOverlay/rules/fonts.ts +54 -0
- package/src/video/profileOverlay/rules/graphDesign.ts +690 -0
- package/src/video/profileOverlay/rules/minimalDesign.ts +144 -0
- package/src/video/profileOverlay/rules/registry.ts +23 -0
- package/src/video/profileOverlay/rules/staticLayer.ts +582 -0
- package/src/video/profileOverlay/rules/stripDesign.ts +327 -0
- package/src/video/profileOverlay/rules/types.ts +78 -0
- package/src/video/rules/videoConstants.ts +250 -0
- package/src/video/rules/videoEncoder.ts +277 -0
- package/src/video/rules/videoFrames.ts +99 -0
- package/src/video/rules/videoPreview.ts +185 -0
- package/src/video/rules/videoRecorder.ts +746 -0
- package/src/video/rules/videoWatermark.ts +155 -0
- package/src/video/rules/watermarkMark.ts +40 -0
- package/src/view/engines/viewClient.ts +6 -0
- package/src/view/index.ts +20 -0
|
@@ -0,0 +1,3328 @@
|
|
|
1
|
+
import { CAMERA_FPS } from '../chunk-6Y7FTGO4.js';
|
|
2
|
+
export { CAMERA_ASPECTS, CAMERA_BEARING_MODES, CAMERA_FPS, CAMERA_MODES, CAMERA_OUTPUT_FORMATS, CAMERA_RESOLUTIONS, PROFILE_DESIGNS, QUALITY_TIERS, VIDEO_PRESETS_AVAILABLE, VIDEO_RECORDING_PHASES } from '../chunk-6Y7FTGO4.js';
|
|
3
|
+
import { detectClimbs, climbAt } from '../chunk-PKWHJ2GI.js';
|
|
4
|
+
import { CINEMATIC_EYE_HEIGHT_METERS, zoomToAltitude, altitudeToZoom, viewportGroundSpanMeters } from '../chunk-SNRCA7EO.js';
|
|
5
|
+
export { CINEMATIC_EYE_HEIGHT_METERS, DEFAULT_VIEWPORT_HEIGHT_PX, POINT_ZOOM, altitudeToZoom, viewportGroundSpanMeters, zoomControlsDisabled, zoomLimitReached, zoomToAltitude } from '../chunk-SNRCA7EO.js';
|
|
6
|
+
import { segmentsForSelection } from '../chunk-2MQK6A74.js';
|
|
7
|
+
import { nearestRoutePointIndexAt, stretchAt, bandValueAt } from '../chunk-MXL5AT3N.js';
|
|
8
|
+
export { BITRATE_MBPS_MAX, BITRATE_MBPS_MIN, aspectRatio, bitrateForOutput, estimatedVideoSizeMb, suggestVideoLengthMs, videoPresets } from '../chunk-DJ6LCKYP.js';
|
|
9
|
+
export { cameraForBounds } from '../chunk-HCBOHXWP.js';
|
|
10
|
+
import { notifyListeners } from '../chunk-Y4YMMKL3.js';
|
|
11
|
+
import { METERS_PER_DEGREE_WEB_MERCATOR, groundMetersPerPixel } from '../chunk-RBSGAZQQ.js';
|
|
12
|
+
export { groundMetersPerPixel } from '../chunk-RBSGAZQQ.js';
|
|
13
|
+
import { extractLines } from '../chunk-EUXI3FGQ.js';
|
|
14
|
+
import { namesPlace, cumulativeMeters, routeLengthMeters } from '../chunk-3NDXVUUI.js';
|
|
15
|
+
export { cumulativeMeters, routeLengthMeters } from '../chunk-3NDXVUUI.js';
|
|
16
|
+
import { longitudeDelta, wrapLongitudePastRange, LONGITUDE_LIMIT } from '../chunk-CW3EFR4O.js';
|
|
17
|
+
import { DEGREES_TO_RADIANS, RADIANS_TO_DEGREES, DEGREES_PER_TURN, convertSlope, METERS_PER_KILOMETER, MILLISECONDS_PER_SECOND } from '../chunk-M2QRC2GZ.js';
|
|
18
|
+
import { MountayaElementsError, errorFrom } from '../chunk-G5W2UHV2.js';
|
|
19
|
+
|
|
20
|
+
// src/camera/rules/plan.ts
|
|
21
|
+
var insertShotSorted = (shots, shot) => {
|
|
22
|
+
const next = [...shots];
|
|
23
|
+
let index = next.length;
|
|
24
|
+
while (index > 0) {
|
|
25
|
+
const previous = next[index - 1];
|
|
26
|
+
if (previous && previous.at <= shot.at) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
index -= 1;
|
|
30
|
+
}
|
|
31
|
+
next.splice(index, 0, shot);
|
|
32
|
+
return next;
|
|
33
|
+
};
|
|
34
|
+
var defaultCameraShot = {
|
|
35
|
+
bearingMode: "follow",
|
|
36
|
+
holdMs: 0,
|
|
37
|
+
speedScale: 1
|
|
38
|
+
};
|
|
39
|
+
var defaultCameraOutput = {
|
|
40
|
+
aspect: "9:16",
|
|
41
|
+
format: "mp4",
|
|
42
|
+
fps: 30,
|
|
43
|
+
preset: "vertical",
|
|
44
|
+
quality: "high",
|
|
45
|
+
resolution: "1080p"
|
|
46
|
+
};
|
|
47
|
+
var DEFAULT_TARGET_DURATION_MS = 2e4;
|
|
48
|
+
var refuseUnplannableShot = (shot, index, refuse) => {
|
|
49
|
+
const member = (name) => `shots[${index}].${name}`;
|
|
50
|
+
if (!Number.isFinite(shot.at)) {
|
|
51
|
+
refuse(member("at"), shot.at, "a finite progress along the route, from 0 to 1");
|
|
52
|
+
}
|
|
53
|
+
if (!Number.isFinite(shot.holdMs) || shot.holdMs < 0) {
|
|
54
|
+
refuse(member("holdMs"), shot.holdMs, "a finite number of milliseconds, 0 or more");
|
|
55
|
+
}
|
|
56
|
+
if (!Number.isFinite(shot.speedScale) || shot.speedScale <= 0) {
|
|
57
|
+
refuse(member("speedScale"), shot.speedScale, "a finite number above 0");
|
|
58
|
+
}
|
|
59
|
+
if (!Number.isFinite(shot.pitchDeg)) {
|
|
60
|
+
refuse(member("pitchDeg"), shot.pitchDeg, "a finite number of degrees");
|
|
61
|
+
}
|
|
62
|
+
if (!Number.isFinite(shot.zoom)) {
|
|
63
|
+
refuse(member("zoom"), shot.zoom, "a finite zoom level");
|
|
64
|
+
}
|
|
65
|
+
if (shot.bearingDeg !== void 0 && !Number.isFinite(shot.bearingDeg)) {
|
|
66
|
+
refuse(member("bearingDeg"), shot.bearingDeg, "a finite number of degrees, or omit it");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var refuseUnplannablePlan = (operation, plan, parameter) => {
|
|
70
|
+
const whole = plan;
|
|
71
|
+
if (typeof whole !== "object" || whole === null || Array.isArray(whole)) {
|
|
72
|
+
const shown = Array.isArray(whole) ? "a list" : String(whole);
|
|
73
|
+
throw new MountayaElementsError(
|
|
74
|
+
`${operation}: ${parameter ?? "plan"} is ${shown}; pass a plan, as createCameraPlan builds one.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const path = parameter === void 0 ? "" : `${parameter}.`;
|
|
78
|
+
const builds = parameter === void 0;
|
|
79
|
+
const refuse = (member, value, expected) => {
|
|
80
|
+
throw new MountayaElementsError(
|
|
81
|
+
`${operation}: ${path}${member} is ${String(value)}; pass ${expected}.`
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
const output = plan.output;
|
|
85
|
+
const shots = plan.shots;
|
|
86
|
+
if (typeof output !== "object" || output === null) {
|
|
87
|
+
refuse(
|
|
88
|
+
"output",
|
|
89
|
+
output,
|
|
90
|
+
builds ? "the output a plan records to as an object, or omit it for the default output" : "the output a plan records to, as createCameraPlan builds one"
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (!Array.isArray(shots)) {
|
|
94
|
+
refuse(
|
|
95
|
+
"shots",
|
|
96
|
+
shots,
|
|
97
|
+
builds ? "the plan's shots as an array, or omit it for no shots" : "the plan's shots as an array, as createCameraPlan builds one"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const version = plan.version;
|
|
101
|
+
if (version !== 1) {
|
|
102
|
+
refuse("version", version, "a version 1 plan, as createCameraPlan builds one");
|
|
103
|
+
}
|
|
104
|
+
const { targetDurationMs } = plan;
|
|
105
|
+
if (!Number.isFinite(targetDurationMs) || targetDurationMs <= 0) {
|
|
106
|
+
refuse(
|
|
107
|
+
"targetDurationMs",
|
|
108
|
+
targetDurationMs,
|
|
109
|
+
builds ? `a finite number of milliseconds above 0, or omit it for ${DEFAULT_TARGET_DURATION_MS}` : "a finite number of milliseconds above 0"
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const fps = plan.output.fps;
|
|
113
|
+
if (!CAMERA_FPS.some((rate) => rate === fps)) {
|
|
114
|
+
refuse("output.fps", fps, `one of ${CAMERA_FPS.join(", ")}`);
|
|
115
|
+
}
|
|
116
|
+
const { bitrateMbps } = plan.output;
|
|
117
|
+
if (bitrateMbps !== void 0 && (!Number.isFinite(bitrateMbps) || bitrateMbps <= 0)) {
|
|
118
|
+
refuse(
|
|
119
|
+
"output.bitrateMbps",
|
|
120
|
+
bitrateMbps,
|
|
121
|
+
"a finite number of megabits per second above 0, or omit it for the resolution's default"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
for (const [index, shot] of plan.shots.entries()) {
|
|
125
|
+
const entry = shot;
|
|
126
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
|
|
127
|
+
refuse(
|
|
128
|
+
`shots[${index}]`,
|
|
129
|
+
entry,
|
|
130
|
+
"a shot, an object that states at, pitchDeg and zoom over defaultCameraShot"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
refuseUnplannableShot(shot, index, refuse);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var refuseUnplannableRoute = (operation, route) => {
|
|
137
|
+
for (let index = 0; index < route.line.length; index += 1) {
|
|
138
|
+
const vertex = route.line[index];
|
|
139
|
+
if (vertex !== void 0 && !(Number.isFinite(vertex[0]) && Number.isFinite(vertex[1]))) {
|
|
140
|
+
throw new MountayaElementsError(
|
|
141
|
+
`${operation}: itinerary.line[${index}] is [${String(vertex[0])}, ${String(vertex[1])}]; pass a finite longitude and latitude for every vertex, or build the route with itineraryToRouteGeometry, which leaves out a vertex that names no place.`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var createCameraPlan = (plan) => {
|
|
147
|
+
const built = {
|
|
148
|
+
mode: plan.mode,
|
|
149
|
+
output: plan.output ?? { ...defaultCameraOutput },
|
|
150
|
+
shots: plan.shots ?? [],
|
|
151
|
+
targetDurationMs: plan.targetDurationMs ?? DEFAULT_TARGET_DURATION_MS,
|
|
152
|
+
version: 1
|
|
153
|
+
};
|
|
154
|
+
refuseUnplannablePlan("createCameraPlan", built);
|
|
155
|
+
return built;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/camera/rules/route.ts
|
|
159
|
+
var continuousLine = (line) => {
|
|
160
|
+
const out = [];
|
|
161
|
+
let turns = 0;
|
|
162
|
+
let previous;
|
|
163
|
+
for (const [lng, lat] of line) {
|
|
164
|
+
if (!Number.isFinite(lng)) {
|
|
165
|
+
out.push([lng, lat]);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (previous !== void 0) {
|
|
169
|
+
const step = lng - previous;
|
|
170
|
+
if (Math.abs(step) > LONGITUDE_LIMIT) {
|
|
171
|
+
turns -= Math.round(step / DEGREES_PER_TURN);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
previous = lng;
|
|
175
|
+
out.push([turns === 0 ? lng : lng + turns * DEGREES_PER_TURN, lat]);
|
|
176
|
+
}
|
|
177
|
+
return out;
|
|
178
|
+
};
|
|
179
|
+
var findVertexIndex = (cumulative, targetMeters) => {
|
|
180
|
+
const length = cumulative.length;
|
|
181
|
+
if (length === 0) {
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
184
|
+
const first = cumulative[0];
|
|
185
|
+
const last = cumulative[length - 1];
|
|
186
|
+
if (first === void 0 || last === void 0) {
|
|
187
|
+
return 0;
|
|
188
|
+
}
|
|
189
|
+
if (targetMeters <= first) {
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
if (targetMeters >= last) {
|
|
193
|
+
return length - 1;
|
|
194
|
+
}
|
|
195
|
+
let lo = 0;
|
|
196
|
+
let hi = length - 1;
|
|
197
|
+
while (lo < hi - 1) {
|
|
198
|
+
const mid = lo + hi >> 1;
|
|
199
|
+
const value = cumulative[mid];
|
|
200
|
+
if (value === void 0) {
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
if (value <= targetMeters) {
|
|
204
|
+
lo = mid;
|
|
205
|
+
} else {
|
|
206
|
+
hi = mid;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return lo;
|
|
210
|
+
};
|
|
211
|
+
var placedFrom = (line, index, step) => {
|
|
212
|
+
for (let at = index; at >= 0 && at < line.length; at += step) {
|
|
213
|
+
const vertex = line[at];
|
|
214
|
+
if (namesPlace(vertex)) {
|
|
215
|
+
return [vertex[0], vertex[1]];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return [Number.NaN, Number.NaN];
|
|
219
|
+
};
|
|
220
|
+
var pointAtMeters = (line, targetMeters, cumulative = cumulativeMeters(line)) => {
|
|
221
|
+
if (line.length === 0) {
|
|
222
|
+
return [0, 0];
|
|
223
|
+
}
|
|
224
|
+
if (Number.isNaN(targetMeters)) {
|
|
225
|
+
return [Number.NaN, Number.NaN];
|
|
226
|
+
}
|
|
227
|
+
const total = cumulative[cumulative.length - 1] ?? 0;
|
|
228
|
+
if (targetMeters <= 0 || total === 0) {
|
|
229
|
+
return placedFrom(line, 0, 1);
|
|
230
|
+
}
|
|
231
|
+
if (targetMeters >= total) {
|
|
232
|
+
return placedFrom(line, line.length - 1, -1);
|
|
233
|
+
}
|
|
234
|
+
const lo = findVertexIndex(cumulative, targetMeters);
|
|
235
|
+
const a = placedFrom(line, lo, -1);
|
|
236
|
+
const b = line[lo + 1];
|
|
237
|
+
const aMeters = cumulative[lo];
|
|
238
|
+
const bMeters = cumulative[lo + 1];
|
|
239
|
+
if (!namesPlace(a) || !namesPlace(b) || aMeters === void 0 || bMeters === void 0) {
|
|
240
|
+
return placedFrom(line, 0, 1);
|
|
241
|
+
}
|
|
242
|
+
const span = bMeters - aMeters;
|
|
243
|
+
const ratio = span === 0 ? 0 : (targetMeters - aMeters) / span;
|
|
244
|
+
return [a[0] + longitudeDelta(a[0], b[0]) * ratio, a[1] + (b[1] - a[1]) * ratio];
|
|
245
|
+
};
|
|
246
|
+
var bearingDegBetween = (a, b) => {
|
|
247
|
+
if (a[0] === b[0] && a[1] === b[1]) {
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
const lat1 = a[1] * DEGREES_TO_RADIANS;
|
|
251
|
+
const lat2 = b[1] * DEGREES_TO_RADIANS;
|
|
252
|
+
const dLng = (b[0] - a[0]) * DEGREES_TO_RADIANS;
|
|
253
|
+
const y = Math.sin(dLng) * Math.cos(lat2);
|
|
254
|
+
const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLng);
|
|
255
|
+
return (Math.atan2(y, x) * RADIANS_TO_DEGREES + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
256
|
+
};
|
|
257
|
+
var tangentBearingAtMeters = (line, targetMeters, lookaheadMeters, cumulative = cumulativeMeters(line)) => {
|
|
258
|
+
const total = cumulative[cumulative.length - 1] ?? 0;
|
|
259
|
+
const here = pointAtMeters(line, targetMeters, cumulative);
|
|
260
|
+
const aheadMeters = Math.min(targetMeters + Math.max(0, lookaheadMeters), total);
|
|
261
|
+
const ahead = pointAtMeters(line, aheadMeters, cumulative);
|
|
262
|
+
if (here[0] !== ahead[0] || here[1] !== ahead[1]) {
|
|
263
|
+
return bearingDegBetween(here, ahead);
|
|
264
|
+
}
|
|
265
|
+
const index = findVertexIndex(cumulative, targetMeters);
|
|
266
|
+
for (let start = Math.min(index, line.length - 2); start >= 0; start -= 1) {
|
|
267
|
+
const heading = legBearingDeg(line, start);
|
|
268
|
+
if (heading !== null) {
|
|
269
|
+
return heading;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
for (let start = index + 1; start < line.length - 1; start += 1) {
|
|
273
|
+
const heading = legBearingDeg(line, start);
|
|
274
|
+
if (heading !== null) {
|
|
275
|
+
return heading;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return 0;
|
|
279
|
+
};
|
|
280
|
+
var routeHeadingDeg = (line, cumulative = cumulativeMeters(line)) => tangentBearingAtMeters(line, 0, cumulative[cumulative.length - 1] ?? 0, cumulative);
|
|
281
|
+
var legBearingDeg = (line, start) => {
|
|
282
|
+
const from = line[start];
|
|
283
|
+
const to = line[start + 1];
|
|
284
|
+
if (!from || !to || from[0] === to[0] && from[1] === to[1]) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
return bearingDegBetween(from, to);
|
|
288
|
+
};
|
|
289
|
+
var cursorAtFraction = (line, fraction, lookaheadMeters, cumulative = cumulativeMeters(line)) => {
|
|
290
|
+
const total = cumulative[cumulative.length - 1] ?? 0;
|
|
291
|
+
const clamped = Math.min(1, Math.max(0, fraction));
|
|
292
|
+
const targetMeters = clamped * total;
|
|
293
|
+
return {
|
|
294
|
+
bearingDeg: tangentBearingAtMeters(line, targetMeters, lookaheadMeters, cumulative),
|
|
295
|
+
index: findVertexIndex(cumulative, targetMeters),
|
|
296
|
+
point: pointAtMeters(line, targetMeters, cumulative)
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
var itineraryToRouteGeometry = (itinerary, segmentId = null) => {
|
|
300
|
+
const segments = segmentsForSelection(itinerary, segmentId);
|
|
301
|
+
const line = [];
|
|
302
|
+
const elevations = [];
|
|
303
|
+
const jumps = [];
|
|
304
|
+
let everyVertexHasElevation = true;
|
|
305
|
+
for (const segment of segments) {
|
|
306
|
+
for (const { coordinates } of extractLines(segment.geojson)) {
|
|
307
|
+
let opensLine = true;
|
|
308
|
+
for (const coordinate of coordinates) {
|
|
309
|
+
if (!namesPlace(coordinate)) {
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (opensLine && line.length > 0) {
|
|
313
|
+
jumps.push(line.length);
|
|
314
|
+
}
|
|
315
|
+
opensLine = false;
|
|
316
|
+
const [lng = 0, lat = 0, elevation] = coordinate;
|
|
317
|
+
line.push([lng, lat]);
|
|
318
|
+
if (elevation === void 0 || !Number.isFinite(elevation)) {
|
|
319
|
+
everyVertexHasElevation = false;
|
|
320
|
+
} else {
|
|
321
|
+
elevations.push(elevation);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (line.length < 2) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
// One elevation for every vertex or none: a partial list would not line up with the line.
|
|
331
|
+
...everyVertexHasElevation && elevations.length === line.length ? { elevations } : {},
|
|
332
|
+
...jumps.length > 0 ? { jumps } : {},
|
|
333
|
+
line
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
var routeGroundMeters = (route, cumulative = cumulativeMeters(route.line)) => {
|
|
337
|
+
const jumps = new Set(route.jumps);
|
|
338
|
+
const ground = new Array(cumulative.length);
|
|
339
|
+
let jumped = 0;
|
|
340
|
+
for (let index = 0; index < cumulative.length; index += 1) {
|
|
341
|
+
const here = cumulative[index] ?? 0;
|
|
342
|
+
if (index > 0 && jumps.has(index)) {
|
|
343
|
+
jumped += here - (cumulative[index - 1] ?? here);
|
|
344
|
+
}
|
|
345
|
+
ground[index] = here - jumped;
|
|
346
|
+
}
|
|
347
|
+
return ground;
|
|
348
|
+
};
|
|
349
|
+
var groundMetersAt = (cumulative, ground, flightMeters) => {
|
|
350
|
+
const lo = findVertexIndex(cumulative, flightMeters);
|
|
351
|
+
const from = ground[lo];
|
|
352
|
+
if (from === void 0) {
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
const to = ground[lo + 1];
|
|
356
|
+
const fromMeters = cumulative[lo];
|
|
357
|
+
const toMeters = cumulative[lo + 1];
|
|
358
|
+
if (to === void 0 || fromMeters === void 0 || toMeters === void 0) {
|
|
359
|
+
return from;
|
|
360
|
+
}
|
|
361
|
+
const span = toMeters - fromMeters;
|
|
362
|
+
if (span <= 0) {
|
|
363
|
+
return from;
|
|
364
|
+
}
|
|
365
|
+
const ratio = Math.min(1, Math.max(0, (flightMeters - fromMeters) / span));
|
|
366
|
+
return from + (to - from) * ratio;
|
|
367
|
+
};
|
|
368
|
+
var elevationAtFraction = (itinerary, fraction, cumulative = cumulativeMeters(itinerary.line)) => {
|
|
369
|
+
const elevations = itinerary.elevations;
|
|
370
|
+
const line = itinerary.line;
|
|
371
|
+
if (!elevations || elevations.length !== line.length || elevations.length === 0) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
const total = cumulative[cumulative.length - 1] ?? 0;
|
|
375
|
+
const clamped = Math.min(1, Math.max(0, fraction));
|
|
376
|
+
const targetMeters = clamped * total;
|
|
377
|
+
const lo = findVertexIndex(cumulative, targetMeters);
|
|
378
|
+
const aElev = elevations[lo];
|
|
379
|
+
const bElev = elevations[lo + 1];
|
|
380
|
+
const aMeters = cumulative[lo];
|
|
381
|
+
const bMeters = cumulative[lo + 1];
|
|
382
|
+
if (aElev === void 0) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
if (bElev === void 0 || aMeters === void 0 || bMeters === void 0) {
|
|
386
|
+
return aElev;
|
|
387
|
+
}
|
|
388
|
+
const span = bMeters - aMeters;
|
|
389
|
+
if (span <= 0) {
|
|
390
|
+
return aElev;
|
|
391
|
+
}
|
|
392
|
+
const ratio = Math.min(1, Math.max(0, (targetMeters - aMeters) / span));
|
|
393
|
+
return aElev + (bElev - aElev) * ratio;
|
|
394
|
+
};
|
|
395
|
+
var slopeDegAtFraction = (itinerary, fraction, lookaheadMeters) => {
|
|
396
|
+
const cumulative = cumulativeMeters(itinerary.line);
|
|
397
|
+
if (elevationAtFraction(itinerary, fraction, cumulative) === null) {
|
|
398
|
+
return 0;
|
|
399
|
+
}
|
|
400
|
+
const total = cumulative[cumulative.length - 1] ?? 0;
|
|
401
|
+
if (!(total > 0)) {
|
|
402
|
+
return 0;
|
|
403
|
+
}
|
|
404
|
+
const window = Number.isFinite(lookaheadMeters) ? Math.max(1, lookaheadMeters) : 1;
|
|
405
|
+
const run = Math.min(window, total);
|
|
406
|
+
const startMeters = Math.min(Math.min(1, Math.max(0, fraction)) * total, total - run);
|
|
407
|
+
const here = elevationAtFraction(itinerary, startMeters / total, cumulative);
|
|
408
|
+
const ahead = elevationAtFraction(itinerary, (startMeters + run) / total, cumulative);
|
|
409
|
+
if (here === null || ahead === null) {
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
412
|
+
const slopeDeg = convertSlope((ahead - here) / run, "ratio", "degrees");
|
|
413
|
+
return Number.isFinite(slopeDeg) ? slopeDeg : 0;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// src/camera/rules/poseRanges.ts
|
|
417
|
+
var PITCH_DEG_MAX = 85;
|
|
418
|
+
var ZOOM_MAX = 22;
|
|
419
|
+
var NEUTRAL_PITCH_DEG = 60;
|
|
420
|
+
var NEUTRAL_ZOOM = 14;
|
|
421
|
+
var clampPitch = (value) => Math.max(0, Math.min(PITCH_DEG_MAX, Number.isFinite(value) ? value : NEUTRAL_PITCH_DEG));
|
|
422
|
+
var clampZoom = (value) => Math.max(0, Math.min(ZOOM_MAX, Number.isFinite(value) ? value : NEUTRAL_ZOOM));
|
|
423
|
+
|
|
424
|
+
// src/camera/rules/spline.ts
|
|
425
|
+
var modeSmoothingSigmas = {
|
|
426
|
+
chase: { bearing: 40, center: 100, pitchZoom: 70 },
|
|
427
|
+
cinematic: { bearing: 50, center: 120, pitchZoom: 80 },
|
|
428
|
+
director: { bearing: 50, center: 120, pitchZoom: 80 },
|
|
429
|
+
drone: { bearing: 220, center: 350, pitchZoom: 280 },
|
|
430
|
+
helicopter: { bearing: 200, center: 300, pitchZoom: 240 },
|
|
431
|
+
overview: { bearing: 140, center: 260, pitchZoom: 200 },
|
|
432
|
+
smart: { bearing: 110, center: 200, pitchZoom: 150 }
|
|
433
|
+
};
|
|
434
|
+
var SIGMA_FRAMES_MIN = 2;
|
|
435
|
+
var SIGMA_FRAMES_FALLBACK_DIVISOR = 3;
|
|
436
|
+
var sigmaFramesForMeters = (sigmaMeters, frameCount, routeLengthMeters2) => {
|
|
437
|
+
const ceil = Math.max(SIGMA_FRAMES_MIN, frameCount / SIGMA_FRAMES_FALLBACK_DIVISOR);
|
|
438
|
+
if (!Number.isFinite(routeLengthMeters2) || routeLengthMeters2 <= 0) {
|
|
439
|
+
return ceil;
|
|
440
|
+
}
|
|
441
|
+
const frames = sigmaMeters * frameCount / routeLengthMeters2;
|
|
442
|
+
return Math.min(ceil, Math.max(SIGMA_FRAMES_MIN, frames));
|
|
443
|
+
};
|
|
444
|
+
var uniformCatmullRom = (knots, values, target) => {
|
|
445
|
+
const n = knots.length;
|
|
446
|
+
if (n === 0) {
|
|
447
|
+
return 0;
|
|
448
|
+
}
|
|
449
|
+
if (n === 1) {
|
|
450
|
+
return values[0] ?? 0;
|
|
451
|
+
}
|
|
452
|
+
const firstKnot = knots[0] ?? 0;
|
|
453
|
+
const lastKnot = knots[n - 1] ?? 0;
|
|
454
|
+
if (target <= firstKnot) {
|
|
455
|
+
return values[0] ?? 0;
|
|
456
|
+
}
|
|
457
|
+
if (target >= lastKnot) {
|
|
458
|
+
return values[n - 1] ?? 0;
|
|
459
|
+
}
|
|
460
|
+
const i1 = segmentIndex(knots, target);
|
|
461
|
+
if (n < 4) {
|
|
462
|
+
const t02 = knots[i1] ?? 0;
|
|
463
|
+
const t12 = knots[i1 + 1] ?? t02;
|
|
464
|
+
const v0 = values[i1] ?? 0;
|
|
465
|
+
const v1 = values[i1 + 1] ?? v0;
|
|
466
|
+
const span = t12 - t02;
|
|
467
|
+
const u2 = span > 0 ? (target - t02) / span : 0;
|
|
468
|
+
return v0 + (v1 - v0) * u2;
|
|
469
|
+
}
|
|
470
|
+
const i0 = Math.max(0, i1 - 1);
|
|
471
|
+
const i2 = Math.min(n - 1, i1 + 1);
|
|
472
|
+
const i3 = Math.min(n - 1, i1 + 2);
|
|
473
|
+
const t0 = knots[i0] ?? 0;
|
|
474
|
+
const t1 = knots[i1] ?? 0;
|
|
475
|
+
const t2 = knots[i2] ?? 0;
|
|
476
|
+
const t3 = knots[i3] ?? 0;
|
|
477
|
+
const p0 = values[i0] ?? 0;
|
|
478
|
+
const p1 = values[i1] ?? 0;
|
|
479
|
+
const p2 = values[i2] ?? 0;
|
|
480
|
+
const p3 = values[i3] ?? 0;
|
|
481
|
+
const eps = 1e-6;
|
|
482
|
+
const u = target;
|
|
483
|
+
const a1 = t1 - t0 > eps ? ((t1 - u) * p0 + (u - t0) * p1) / (t1 - t0) : p1;
|
|
484
|
+
const a2 = t2 - t1 > eps ? ((t2 - u) * p1 + (u - t1) * p2) / (t2 - t1) : p1;
|
|
485
|
+
const a3 = t3 - t2 > eps ? ((t3 - u) * p2 + (u - t2) * p3) / (t3 - t2) : p2;
|
|
486
|
+
const b1 = t2 - t0 > eps ? ((t2 - u) * a1 + (u - t0) * a2) / (t2 - t0) : a2;
|
|
487
|
+
const b2 = t3 - t1 > eps ? ((t3 - u) * a2 + (u - t1) * a3) / (t3 - t1) : a2;
|
|
488
|
+
return t2 - t1 > eps ? ((t2 - u) * b1 + (u - t1) * b2) / (t2 - t1) : b1;
|
|
489
|
+
};
|
|
490
|
+
var unwrapBearings = (bearings) => {
|
|
491
|
+
const length = bearings.length;
|
|
492
|
+
if (length === 0) {
|
|
493
|
+
return [];
|
|
494
|
+
}
|
|
495
|
+
const out = new Array(length);
|
|
496
|
+
let running = bearings[0] ?? 0;
|
|
497
|
+
out[0] = running;
|
|
498
|
+
for (let i = 1; i < length; i += 1) {
|
|
499
|
+
const previous = bearings[i - 1] ?? 0;
|
|
500
|
+
const current = bearings[i] ?? previous;
|
|
501
|
+
running += shortestArcDelta(previous, current);
|
|
502
|
+
out[i] = running;
|
|
503
|
+
}
|
|
504
|
+
return out;
|
|
505
|
+
};
|
|
506
|
+
var shortestArcDelta = (from, to) => {
|
|
507
|
+
const raw = ((to - from) % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
508
|
+
return raw > DEGREES_PER_TURN / 2 ? raw - DEGREES_PER_TURN : raw;
|
|
509
|
+
};
|
|
510
|
+
var lowPass = (values, sigmaSamples, continued) => {
|
|
511
|
+
const length = values.length;
|
|
512
|
+
const lastIndex = length - 1;
|
|
513
|
+
const sigma = Math.max(1e-3, sigmaSamples);
|
|
514
|
+
const halfWidth = Math.max(1, Math.ceil(sigma * 3));
|
|
515
|
+
const denom = 2 * sigma * sigma;
|
|
516
|
+
const out = new Array(length);
|
|
517
|
+
for (let i = 0; i < length; i += 1) {
|
|
518
|
+
const from = continued === void 0 ? Math.max(0, i - halfWidth) : i - halfWidth;
|
|
519
|
+
const to = continued === void 0 ? Math.min(lastIndex, i + halfWidth) : i + halfWidth;
|
|
520
|
+
let weighted = 0;
|
|
521
|
+
let weightSum = 0;
|
|
522
|
+
for (let j = from; j <= to; j += 1) {
|
|
523
|
+
const value = j >= 0 && j <= lastIndex ? values[j] : continued?.(j);
|
|
524
|
+
if (value === void 0 || !Number.isFinite(value)) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
const d = j - i;
|
|
528
|
+
const weight = Math.exp(-(d * d) / denom);
|
|
529
|
+
weighted += value * weight;
|
|
530
|
+
weightSum += weight;
|
|
531
|
+
}
|
|
532
|
+
out[i] = weightSum > 0 ? weighted / weightSum : values[i] ?? 0;
|
|
533
|
+
}
|
|
534
|
+
return out;
|
|
535
|
+
};
|
|
536
|
+
var smoothSeries = (values, sigmaSamples) => lowPass(values, sigmaSamples);
|
|
537
|
+
var smoothPositionSeries = (values, sigmaSamples) => {
|
|
538
|
+
const length = values.length;
|
|
539
|
+
if (length < 2) {
|
|
540
|
+
return [...values];
|
|
541
|
+
}
|
|
542
|
+
const lastIndex = length - 1;
|
|
543
|
+
const first = values[0];
|
|
544
|
+
const last = values[lastIndex];
|
|
545
|
+
const turn = 2 * lastIndex;
|
|
546
|
+
const gain = first === void 0 || last === void 0 ? Number.NaN : 2 * (last - first);
|
|
547
|
+
const reflected = (index) => {
|
|
548
|
+
if (index < 0) {
|
|
549
|
+
const inside = values[-index];
|
|
550
|
+
return first === void 0 || inside === void 0 ? void 0 : 2 * first - inside;
|
|
551
|
+
}
|
|
552
|
+
if (index > lastIndex) {
|
|
553
|
+
const inside = values[turn - index];
|
|
554
|
+
return last === void 0 || inside === void 0 ? void 0 : 2 * last - inside;
|
|
555
|
+
}
|
|
556
|
+
return values[index];
|
|
557
|
+
};
|
|
558
|
+
const valueAt = (index) => {
|
|
559
|
+
if (index >= -lastIndex && index <= turn) {
|
|
560
|
+
return reflected(index);
|
|
561
|
+
}
|
|
562
|
+
const turns = Math.floor(index / turn);
|
|
563
|
+
const within = reflected(index - turns * turn);
|
|
564
|
+
return within === void 0 ? void 0 : within + turns * gain;
|
|
565
|
+
};
|
|
566
|
+
const smoothed = lowPass(values, Math.min(sigmaSamples, length), valueAt);
|
|
567
|
+
if (first !== void 0 && Number.isFinite(first)) {
|
|
568
|
+
smoothed[0] = first;
|
|
569
|
+
}
|
|
570
|
+
if (last !== void 0 && Number.isFinite(last)) {
|
|
571
|
+
smoothed[lastIndex] = last;
|
|
572
|
+
}
|
|
573
|
+
return smoothed;
|
|
574
|
+
};
|
|
575
|
+
var buildCameraSpline = (shots, itinerary, mode = "smart") => {
|
|
576
|
+
const line = continuousLine(itinerary.line);
|
|
577
|
+
const cumulative = cumulativeMeters(line);
|
|
578
|
+
const lookaheadMeters = lookaheadForMode(mode);
|
|
579
|
+
const overallHeading = routeHeadingDeg(line, cumulative);
|
|
580
|
+
const fractions = [];
|
|
581
|
+
const pitches = [];
|
|
582
|
+
const zooms = [];
|
|
583
|
+
const bearings = [];
|
|
584
|
+
const modes = [];
|
|
585
|
+
let heldHeading = overallHeading;
|
|
586
|
+
for (const shot of shots) {
|
|
587
|
+
heldHeading = resolveShotBearing(shot, line, cumulative, lookaheadMeters, heldHeading);
|
|
588
|
+
fractions.push(shot.at);
|
|
589
|
+
pitches.push(shot.pitchDeg);
|
|
590
|
+
zooms.push(shot.zoom);
|
|
591
|
+
bearings.push(heldHeading);
|
|
592
|
+
modes.push(shot.bearingMode);
|
|
593
|
+
}
|
|
594
|
+
return { bearings, cumulative, fractions, line, lookaheadMeters, modes, pitches, zooms };
|
|
595
|
+
};
|
|
596
|
+
var evalSpline = (spline, tNorm) => {
|
|
597
|
+
const clamped = Math.min(1, Math.max(0, tNorm));
|
|
598
|
+
const cursor = cursorAtFraction(spline.line, clamped, spline.lookaheadMeters, spline.cumulative);
|
|
599
|
+
if (spline.fractions.length === 0) {
|
|
600
|
+
return {
|
|
601
|
+
bearing: cursor.bearingDeg,
|
|
602
|
+
center: cursor.point,
|
|
603
|
+
followWeight: 1,
|
|
604
|
+
pitch: 60,
|
|
605
|
+
zoom: 14
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
const pitch = clampPitch(uniformCatmullRom(spline.fractions, spline.pitches, clamped));
|
|
609
|
+
const zoom = clampZoom(uniformCatmullRom(spline.fractions, spline.zooms, clamped));
|
|
610
|
+
const { bearing, followWeight } = resolveEvalBearing(spline, clamped, cursor.bearingDeg);
|
|
611
|
+
return { bearing, center: cursor.point, followWeight, pitch, zoom };
|
|
612
|
+
};
|
|
613
|
+
var resolveEvalBearing = (spline, clamped, tangentDeg) => {
|
|
614
|
+
const keyframeBearing = (uniformCatmullRom(spline.fractions, unwrapBearings(spline.bearings), clamped) % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
615
|
+
const segment = bearingSegment(spline.fractions, clamped);
|
|
616
|
+
const fromMode = spline.modes[segment.fromIndex] ?? "follow";
|
|
617
|
+
const toMode = spline.modes[segment.toIndex] ?? fromMode;
|
|
618
|
+
const fromFollows = fromMode === "follow";
|
|
619
|
+
const toFollows = toMode === "follow";
|
|
620
|
+
if (fromFollows && toFollows) {
|
|
621
|
+
return { bearing: tangentDeg, followWeight: 1 };
|
|
622
|
+
}
|
|
623
|
+
if (!fromFollows && !toFollows) {
|
|
624
|
+
return { bearing: keyframeBearing, followWeight: 0 };
|
|
625
|
+
}
|
|
626
|
+
const weight = toFollows ? smoothstep(segment.u) : smoothstep(1 - segment.u);
|
|
627
|
+
return { bearing: blendBearing(keyframeBearing, tangentDeg, weight), followWeight: weight };
|
|
628
|
+
};
|
|
629
|
+
var bearingSegment = (fractions, clamped) => {
|
|
630
|
+
const n = fractions.length;
|
|
631
|
+
const lastIndex = n - 1;
|
|
632
|
+
const first = fractions[0] ?? 0;
|
|
633
|
+
const last = fractions[lastIndex] ?? 0;
|
|
634
|
+
if (clamped <= first) {
|
|
635
|
+
return { fromIndex: 0, toIndex: 0, u: 0 };
|
|
636
|
+
}
|
|
637
|
+
if (clamped >= last) {
|
|
638
|
+
return { fromIndex: lastIndex, toIndex: lastIndex, u: 1 };
|
|
639
|
+
}
|
|
640
|
+
const fromIndex = segmentIndex(fractions, clamped);
|
|
641
|
+
const toIndex = Math.min(lastIndex, fromIndex + 1);
|
|
642
|
+
const fromFraction = fractions[fromIndex] ?? 0;
|
|
643
|
+
const toFraction = fractions[toIndex] ?? fromFraction;
|
|
644
|
+
const span = toFraction - fromFraction;
|
|
645
|
+
const u = span > 0 ? (clamped - fromFraction) / span : 0;
|
|
646
|
+
return { fromIndex, toIndex, u };
|
|
647
|
+
};
|
|
648
|
+
var blendBearing = (a, b, w) => {
|
|
649
|
+
const result = a + shortestArcDelta(a, b) * w;
|
|
650
|
+
return (result % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
651
|
+
};
|
|
652
|
+
var smoothstep = (t) => {
|
|
653
|
+
const x = Math.min(1, Math.max(0, t));
|
|
654
|
+
return x * x * (3 - 2 * x);
|
|
655
|
+
};
|
|
656
|
+
var planDurationMs = (plan) => {
|
|
657
|
+
let holds = 0;
|
|
658
|
+
for (const shot of plan.shots) {
|
|
659
|
+
holds += shot.holdMs;
|
|
660
|
+
}
|
|
661
|
+
return plan.targetDurationMs + holds;
|
|
662
|
+
};
|
|
663
|
+
var lookaheadForMode = (mode) => {
|
|
664
|
+
switch (mode) {
|
|
665
|
+
case "drone":
|
|
666
|
+
return 340;
|
|
667
|
+
case "helicopter":
|
|
668
|
+
return 200;
|
|
669
|
+
case "overview":
|
|
670
|
+
return 150;
|
|
671
|
+
case "cinematic":
|
|
672
|
+
return 70;
|
|
673
|
+
case "chase":
|
|
674
|
+
return 45;
|
|
675
|
+
default:
|
|
676
|
+
return 120;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
var resolveShotBearing = (shot, line, cumulative, lookaheadMeters, heldHeading) => {
|
|
680
|
+
if (shot.bearingMode === "value") {
|
|
681
|
+
return shot.bearingDeg ?? 0;
|
|
682
|
+
}
|
|
683
|
+
if (shot.bearingMode === "locked") {
|
|
684
|
+
return heldHeading;
|
|
685
|
+
}
|
|
686
|
+
return cursorAtFraction(line, shot.at, lookaheadMeters, cumulative).bearingDeg;
|
|
687
|
+
};
|
|
688
|
+
var segmentIndex = (knots, target) => {
|
|
689
|
+
let lo = 0;
|
|
690
|
+
let hi = knots.length - 1;
|
|
691
|
+
while (lo < hi - 1) {
|
|
692
|
+
const mid = lo + hi >> 1;
|
|
693
|
+
const value = knots[mid];
|
|
694
|
+
if (value === void 0) {
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
if (value <= target) {
|
|
698
|
+
lo = mid;
|
|
699
|
+
} else {
|
|
700
|
+
hi = mid;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return lo;
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// src/camera/rules/clearance.ts
|
|
707
|
+
var EYE_CLEARANCE_MARGIN = 120;
|
|
708
|
+
var modeEyeClearanceScale = {
|
|
709
|
+
chase: 1,
|
|
710
|
+
cinematic: 1.1,
|
|
711
|
+
director: 1,
|
|
712
|
+
drone: 1.4,
|
|
713
|
+
helicopter: 1.3,
|
|
714
|
+
overview: 1.15,
|
|
715
|
+
smart: 1
|
|
716
|
+
};
|
|
717
|
+
var RAY_CLEARANCE_MARGIN = 90;
|
|
718
|
+
var SIGHTLINE_SAMPLES = 8;
|
|
719
|
+
var FORWARD_FAN_SAMPLES = 4;
|
|
720
|
+
var FORWARD_STEP_SPAN_FRACTION = 0.4;
|
|
721
|
+
var LATERAL_OFFSET_SPAN_FRACTION = 0.25;
|
|
722
|
+
var PITCH_SEARCH_STEP_DEG = 5;
|
|
723
|
+
var ZOOM_FLOOR = 0;
|
|
724
|
+
var ZOOM_CEIL = 22;
|
|
725
|
+
var MAX_CLEARANCE_WIDEN = 5;
|
|
726
|
+
var PITCH_FLOOR = 20;
|
|
727
|
+
var PITCH_CEIL = 85;
|
|
728
|
+
var MIN_COS_PITCH = 0.05;
|
|
729
|
+
var NULL_DEM_HAZARD_MARGIN = 150;
|
|
730
|
+
var modeAnticipationMeters = {
|
|
731
|
+
chase: 200,
|
|
732
|
+
cinematic: 220,
|
|
733
|
+
director: 300,
|
|
734
|
+
drone: 480,
|
|
735
|
+
helicopter: 420,
|
|
736
|
+
overview: 380,
|
|
737
|
+
smart: 300
|
|
738
|
+
};
|
|
739
|
+
var MIN_CLEARANCE_SAMPLES_PER_WINDOW = 6;
|
|
740
|
+
var MAX_CLEARANCE_SOLVES = 300;
|
|
741
|
+
var clearanceSampleStride = (count, routeLengthMeters2, options) => {
|
|
742
|
+
const anticipationMeters = options.anticipationMeters ?? modeAnticipationMeters[options.mode ?? "smart"];
|
|
743
|
+
const windowFrames = Math.max(
|
|
744
|
+
1,
|
|
745
|
+
Math.round(sigmaFramesForMeters(anticipationMeters, count, routeLengthMeters2))
|
|
746
|
+
);
|
|
747
|
+
return Math.min(
|
|
748
|
+
windowFrames,
|
|
749
|
+
Math.max(
|
|
750
|
+
1,
|
|
751
|
+
Math.floor(windowFrames / MIN_CLEARANCE_SAMPLES_PER_WINDOW),
|
|
752
|
+
Math.ceil(count / MAX_CLEARANCE_SOLVES)
|
|
753
|
+
)
|
|
754
|
+
);
|
|
755
|
+
};
|
|
756
|
+
var resolveClearanceAdjustments = (frames, itinerary, sampler, options) => {
|
|
757
|
+
const count = frames.length;
|
|
758
|
+
if (count === 0) {
|
|
759
|
+
return { pitch: [], zoom: [] };
|
|
760
|
+
}
|
|
761
|
+
const terrain = (lngLat) => {
|
|
762
|
+
const longitude = wrapLongitudePastRange(lngLat[0]);
|
|
763
|
+
const height = sampler(longitude === lngLat[0] ? lngLat : [longitude, lngLat[1]]);
|
|
764
|
+
return height !== null && Number.isFinite(height) ? height : null;
|
|
765
|
+
};
|
|
766
|
+
const viewportHeightPx = options.viewportHeightPx;
|
|
767
|
+
const modeScale = modeEyeClearanceScale[options.mode ?? "smart"] ?? 1;
|
|
768
|
+
const cumulative = cumulativeMeters(itinerary.line);
|
|
769
|
+
const rawZoom = new Array(count);
|
|
770
|
+
const rawPitch = new Array(count);
|
|
771
|
+
let constrained = false;
|
|
772
|
+
const inputZooms = new Array(count);
|
|
773
|
+
const inputPitches = new Array(count);
|
|
774
|
+
for (let frame = 0; frame < count; frame += 1) {
|
|
775
|
+
const channel = frames[frame];
|
|
776
|
+
if (!channel) {
|
|
777
|
+
inputZooms[frame] = ZOOM_CEIL;
|
|
778
|
+
inputPitches[frame] = PITCH_CEIL;
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
inputZooms[frame] = channel.zoom;
|
|
782
|
+
inputPitches[frame] = channel.pitch;
|
|
783
|
+
}
|
|
784
|
+
const stride = Math.max(1, Math.floor(options.sampleStride ?? 1));
|
|
785
|
+
const sampleIndices = strideSampleIndices(count, stride);
|
|
786
|
+
const sampledZoom = new Array(sampleIndices.length);
|
|
787
|
+
const sampledPitch = new Array(sampleIndices.length);
|
|
788
|
+
for (let sample = 0; sample < sampleIndices.length; sample += 1) {
|
|
789
|
+
const frame = sampleIndices[sample] ?? 0;
|
|
790
|
+
const channel = frames[frame];
|
|
791
|
+
if (!channel) {
|
|
792
|
+
sampledZoom[sample] = ZOOM_CEIL;
|
|
793
|
+
sampledPitch[sample] = PITCH_CEIL;
|
|
794
|
+
continue;
|
|
795
|
+
}
|
|
796
|
+
const adjustment = frameClearanceAdjustment(
|
|
797
|
+
channel,
|
|
798
|
+
itinerary,
|
|
799
|
+
cumulative,
|
|
800
|
+
terrain,
|
|
801
|
+
viewportHeightPx,
|
|
802
|
+
modeScale
|
|
803
|
+
);
|
|
804
|
+
sampledZoom[sample] = adjustment.zoom;
|
|
805
|
+
sampledPitch[sample] = adjustment.pitch;
|
|
806
|
+
if (adjustment.zoom < channel.zoom || adjustment.pitch < channel.pitch) {
|
|
807
|
+
constrained = true;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (!constrained) {
|
|
811
|
+
return { pitch: inputPitches, zoom: inputZooms };
|
|
812
|
+
}
|
|
813
|
+
interpolateAcrossSamples(rawZoom, sampleIndices, sampledZoom);
|
|
814
|
+
interpolateAcrossSamples(rawPitch, sampleIndices, sampledPitch);
|
|
815
|
+
const anticipationMeters = options.anticipationMeters ?? modeAnticipationMeters[options.mode ?? "smart"];
|
|
816
|
+
const windowFrames = Math.max(
|
|
817
|
+
1,
|
|
818
|
+
Math.round(
|
|
819
|
+
sigmaFramesForMeters(anticipationMeters, count, cumulative[cumulative.length - 1] ?? 0)
|
|
820
|
+
)
|
|
821
|
+
);
|
|
822
|
+
const dilatedZoom = windowedMinimum(rawZoom, windowFrames);
|
|
823
|
+
const dilatedPitch = windowedMinimum(rawPitch, windowFrames);
|
|
824
|
+
return {
|
|
825
|
+
pitch: atMostInput(smoothSeries(dilatedPitch, windowFrames / 2), inputPitches),
|
|
826
|
+
zoom: atMostInput(smoothSeries(dilatedZoom, windowFrames / 2), inputZooms)
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
var atMostInput = (resolved, inputs) => resolved.map((value, frame) => Math.min(value, inputs[frame] ?? value));
|
|
830
|
+
var S_BACKSOLVE_MAX = 0.95;
|
|
831
|
+
var scaleLift = (requiredEye, centerGround, modeScale) => {
|
|
832
|
+
if (requiredEye === null) {
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
return centerGround + (requiredEye - centerGround) * modeScale;
|
|
836
|
+
};
|
|
837
|
+
var frameClearanceAdjustment = (channel, itinerary, cumulative, sampler, viewportHeightPx, modeScale) => {
|
|
838
|
+
const [, lat] = channel.center;
|
|
839
|
+
const altitude = zoomToAltitude(channel.zoom, lat, viewportHeightPx);
|
|
840
|
+
const routeFloor = elevationAtFraction(itinerary, channel.fraction, cumulative);
|
|
841
|
+
const centerSample = sampler(channel.center);
|
|
842
|
+
const centerGround = centerSample ?? routeFloor ?? 0;
|
|
843
|
+
const {
|
|
844
|
+
eye,
|
|
845
|
+
pitch: clearancePitch,
|
|
846
|
+
requiredEye
|
|
847
|
+
} = pitchClearingFrustum(
|
|
848
|
+
channel,
|
|
849
|
+
altitude,
|
|
850
|
+
centerGround,
|
|
851
|
+
routeFloor,
|
|
852
|
+
centerSample,
|
|
853
|
+
modeScale,
|
|
854
|
+
sampler,
|
|
855
|
+
viewportHeightPx
|
|
856
|
+
);
|
|
857
|
+
let clearanceZoom = channel.zoom;
|
|
858
|
+
if (requiredEye !== null && requiredEye > eye.aslHeight) {
|
|
859
|
+
clearanceZoom = Math.min(
|
|
860
|
+
clearanceZoom,
|
|
861
|
+
zoomForEyeHeight(requiredEye, centerGround, eye.cosPitch, lat, viewportHeightPx)
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
const cappedZoom = Math.max(channel.zoom - MAX_CLEARANCE_WIDEN, clearanceZoom);
|
|
865
|
+
return {
|
|
866
|
+
pitch: Math.max(PITCH_FLOOR, Math.min(PITCH_CEIL, clearancePitch)),
|
|
867
|
+
zoom: Math.max(ZOOM_FLOOR, Math.min(ZOOM_CEIL, cappedZoom))
|
|
868
|
+
};
|
|
869
|
+
};
|
|
870
|
+
var eyeGeometry = (channel, pitch, altitude, centerGround) => {
|
|
871
|
+
const pitchRad = pitch * DEGREES_TO_RADIANS;
|
|
872
|
+
const cosPitch = Math.max(MIN_COS_PITCH, Math.cos(pitchRad));
|
|
873
|
+
const sinPitch = Math.max(0, Math.sin(pitchRad));
|
|
874
|
+
return {
|
|
875
|
+
aslHeight: centerGround + altitude * cosPitch,
|
|
876
|
+
cosPitch,
|
|
877
|
+
lngLat: movePoint(channel.center, channel.bearing + 180, altitude * sinPitch)
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
var frustumSamples = (channel, eye, eyeMargin, viewportHeightPx) => {
|
|
881
|
+
const [, lat] = channel.center;
|
|
882
|
+
const span = viewportGroundSpanMeters(channel.zoom, lat, viewportHeightPx);
|
|
883
|
+
const forwardStep = FORWARD_STEP_SPAN_FRACTION * span;
|
|
884
|
+
const lateralOffset = LATERAL_OFFSET_SPAN_FRACTION * span;
|
|
885
|
+
const samples = [];
|
|
886
|
+
samples.push({ lngLat: eye.lngLat, margin: eyeMargin, s: 0 });
|
|
887
|
+
for (let step = 1; step <= SIGHTLINE_SAMPLES; step += 1) {
|
|
888
|
+
const s = step / (SIGHTLINE_SAMPLES + 1);
|
|
889
|
+
samples.push({
|
|
890
|
+
lngLat: pointAlongRay(eye.lngLat, channel.center, s),
|
|
891
|
+
margin: RAY_CLEARANCE_MARGIN,
|
|
892
|
+
s
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
const firstRayS = 1 / (SIGHTLINE_SAMPLES + 1);
|
|
896
|
+
for (const frac of [0.33, 0.66]) {
|
|
897
|
+
const s = firstRayS * frac;
|
|
898
|
+
samples.push({
|
|
899
|
+
lngLat: pointAlongRay(eye.lngLat, channel.center, s),
|
|
900
|
+
margin: RAY_CLEARANCE_MARGIN,
|
|
901
|
+
s
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
for (let step = 1; step <= FORWARD_FAN_SAMPLES; step += 1) {
|
|
905
|
+
const distance = step / 2 * forwardStep;
|
|
906
|
+
const point = movePoint(channel.center, channel.bearing, distance);
|
|
907
|
+
samples.push({
|
|
908
|
+
lngLat: point,
|
|
909
|
+
margin: RAY_CLEARANCE_MARGIN,
|
|
910
|
+
s: axisParameter(eye, channel.center, point)
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
for (const along of [1, 2 / 3]) {
|
|
914
|
+
const base = along >= 1 ? channel.center : pointAlongRay(eye.lngLat, channel.center, along);
|
|
915
|
+
for (const side of [90, -90]) {
|
|
916
|
+
const point = movePoint(base, channel.bearing + side, lateralOffset);
|
|
917
|
+
samples.push({
|
|
918
|
+
lngLat: point,
|
|
919
|
+
margin: RAY_CLEARANCE_MARGIN,
|
|
920
|
+
s: axisParameter(eye, channel.center, point)
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return samples;
|
|
925
|
+
};
|
|
926
|
+
var pointAlongRay = (from, to, s) => [
|
|
927
|
+
from[0] + (to[0] - from[0]) * s,
|
|
928
|
+
from[1] + (to[1] - from[1]) * s
|
|
929
|
+
];
|
|
930
|
+
var axisParameter = (eye, center, point) => {
|
|
931
|
+
const lat = center[1];
|
|
932
|
+
const metersPerDegLng = METERS_PER_DEGREE_WEB_MERCATOR * Math.cos(lat * DEGREES_TO_RADIANS);
|
|
933
|
+
const axisEast = (center[0] - eye.lngLat[0]) * metersPerDegLng;
|
|
934
|
+
const axisNorth = (center[1] - eye.lngLat[1]) * METERS_PER_DEGREE_WEB_MERCATOR;
|
|
935
|
+
const axisLengthSquared = axisEast * axisEast + axisNorth * axisNorth;
|
|
936
|
+
if (axisLengthSquared <= 0) {
|
|
937
|
+
return 1;
|
|
938
|
+
}
|
|
939
|
+
const pointEast = (point[0] - eye.lngLat[0]) * metersPerDegLng;
|
|
940
|
+
const pointNorth = (point[1] - eye.lngLat[1]) * METERS_PER_DEGREE_WEB_MERCATOR;
|
|
941
|
+
return (pointEast * axisEast + pointNorth * axisNorth) / axisLengthSquared;
|
|
942
|
+
};
|
|
943
|
+
var pitchClearingFrustum = (channel, altitude, centerGround, routeFloor, nearbyKnownGround, modeScale, sampler, viewportHeightPx) => {
|
|
944
|
+
const solveAt = (pitch) => {
|
|
945
|
+
const eye = eyeGeometry(channel, pitch, altitude, centerGround);
|
|
946
|
+
const samples = frustumSamples(channel, eye, EYE_CLEARANCE_MARGIN, viewportHeightPx);
|
|
947
|
+
return {
|
|
948
|
+
eye,
|
|
949
|
+
pitch,
|
|
950
|
+
requiredEye: scaleLift(
|
|
951
|
+
frustumRequiredEyeHeight(
|
|
952
|
+
samples,
|
|
953
|
+
eye,
|
|
954
|
+
centerGround,
|
|
955
|
+
routeFloor,
|
|
956
|
+
nearbyKnownGround,
|
|
957
|
+
sampler
|
|
958
|
+
),
|
|
959
|
+
centerGround,
|
|
960
|
+
modeScale
|
|
961
|
+
)
|
|
962
|
+
};
|
|
963
|
+
};
|
|
964
|
+
const startPitch = Math.min(PITCH_CEIL, Math.max(0, channel.pitch));
|
|
965
|
+
let solved = solveAt(startPitch);
|
|
966
|
+
if (startPitch <= PITCH_FLOOR) {
|
|
967
|
+
return solved;
|
|
968
|
+
}
|
|
969
|
+
const steps = Math.max(1, Math.ceil((startPitch - PITCH_FLOOR) / PITCH_SEARCH_STEP_DEG));
|
|
970
|
+
for (let step = 1; step <= steps; step += 1) {
|
|
971
|
+
if (solved.requiredEye === null || solved.requiredEye <= solved.eye.aslHeight) {
|
|
972
|
+
return solved;
|
|
973
|
+
}
|
|
974
|
+
solved = solveAt(Math.max(PITCH_FLOOR, startPitch - step * PITCH_SEARCH_STEP_DEG));
|
|
975
|
+
}
|
|
976
|
+
return solved;
|
|
977
|
+
};
|
|
978
|
+
var frustumRequiredEyeHeight = (samples, eye, centerGround, routeFloor, nearbyKnownGround, sampler) => {
|
|
979
|
+
let required = null;
|
|
980
|
+
for (const sample of samples) {
|
|
981
|
+
const ground = sampleGround(sample.lngLat, routeFloor, nearbyKnownGround, sampler);
|
|
982
|
+
if (ground === null) {
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
const s = Math.min(S_BACKSOLVE_MAX, Math.max(0, sample.s));
|
|
986
|
+
const rayHeight = eye.aslHeight + (centerGround - eye.aslHeight) * s;
|
|
987
|
+
const clearance = sample.margin * (1 - s);
|
|
988
|
+
if (ground <= rayHeight - clearance) {
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
const neededEye = (ground - centerGround * s) / (1 - s) + sample.margin;
|
|
992
|
+
required = required === null ? neededEye : Math.max(required, neededEye);
|
|
993
|
+
}
|
|
994
|
+
return required;
|
|
995
|
+
};
|
|
996
|
+
var sampleGround = (lngLat, routeFloor, nearbyKnownGround, sampler) => {
|
|
997
|
+
const sampled = sampler(lngLat);
|
|
998
|
+
if (sampled !== null) {
|
|
999
|
+
return sampled;
|
|
1000
|
+
}
|
|
1001
|
+
if (routeFloor === null && nearbyKnownGround === null) {
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
const known = Math.max(
|
|
1005
|
+
routeFloor ?? Number.NEGATIVE_INFINITY,
|
|
1006
|
+
nearbyKnownGround ?? Number.NEGATIVE_INFINITY
|
|
1007
|
+
);
|
|
1008
|
+
return known + NULL_DEM_HAZARD_MARGIN;
|
|
1009
|
+
};
|
|
1010
|
+
var zoomForEyeHeight = (eyeHeight, centerGround, cosPitch, latitude, viewportHeightPx) => {
|
|
1011
|
+
const altitude = (eyeHeight - centerGround) / cosPitch;
|
|
1012
|
+
if (!Number.isFinite(altitude) || altitude <= 0) {
|
|
1013
|
+
return ZOOM_FLOOR;
|
|
1014
|
+
}
|
|
1015
|
+
return altitudeToZoom(altitude, latitude, viewportHeightPx);
|
|
1016
|
+
};
|
|
1017
|
+
var movePoint = (origin, bearing, meters) => {
|
|
1018
|
+
if (meters === 0) {
|
|
1019
|
+
return origin;
|
|
1020
|
+
}
|
|
1021
|
+
const bearingRad = bearing * DEGREES_TO_RADIANS;
|
|
1022
|
+
const dNorth = Math.cos(bearingRad) * meters;
|
|
1023
|
+
const dEast = Math.sin(bearingRad) * meters;
|
|
1024
|
+
const metersPerDegreeLng = METERS_PER_DEGREE_WEB_MERCATOR * Math.cos(origin[1] * DEGREES_TO_RADIANS);
|
|
1025
|
+
const dLat = dNorth / METERS_PER_DEGREE_WEB_MERCATOR;
|
|
1026
|
+
const dLng = metersPerDegreeLng > 0 ? dEast / metersPerDegreeLng : 0;
|
|
1027
|
+
return [origin[0] + dLng, origin[1] + dLat];
|
|
1028
|
+
};
|
|
1029
|
+
var windowedMinimum = (values, radius) => {
|
|
1030
|
+
const length = values.length;
|
|
1031
|
+
const out = new Array(length);
|
|
1032
|
+
for (let i = 0; i < length; i += 1) {
|
|
1033
|
+
const from = Math.max(0, i - radius);
|
|
1034
|
+
const to = Math.min(length - 1, i + radius);
|
|
1035
|
+
let min = Number.POSITIVE_INFINITY;
|
|
1036
|
+
for (let j = from; j <= to; j += 1) {
|
|
1037
|
+
const value = values[j];
|
|
1038
|
+
if (value !== void 0 && value < min) {
|
|
1039
|
+
min = value;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
out[i] = Number.isFinite(min) ? min : values[i] ?? ZOOM_CEIL;
|
|
1043
|
+
}
|
|
1044
|
+
return out;
|
|
1045
|
+
};
|
|
1046
|
+
var strideSampleIndices = (count, stride) => {
|
|
1047
|
+
const indices = [];
|
|
1048
|
+
for (let frame = 0; frame < count; frame += stride) {
|
|
1049
|
+
indices.push(frame);
|
|
1050
|
+
}
|
|
1051
|
+
const last = count - 1;
|
|
1052
|
+
if (last >= 0 && indices[indices.length - 1] !== last) {
|
|
1053
|
+
indices.push(last);
|
|
1054
|
+
}
|
|
1055
|
+
return indices;
|
|
1056
|
+
};
|
|
1057
|
+
var interpolateAcrossSamples = (out, indices, values) => {
|
|
1058
|
+
for (let sample = 0; sample < indices.length; sample += 1) {
|
|
1059
|
+
out[indices[sample] ?? 0] = values[sample] ?? 0;
|
|
1060
|
+
}
|
|
1061
|
+
for (let sample = 0; sample < indices.length - 1; sample += 1) {
|
|
1062
|
+
const fromIndex = indices[sample] ?? 0;
|
|
1063
|
+
const toIndex = indices[sample + 1] ?? fromIndex;
|
|
1064
|
+
const fromValue = values[sample] ?? 0;
|
|
1065
|
+
const toValue = values[sample + 1] ?? fromValue;
|
|
1066
|
+
const span = toIndex - fromIndex;
|
|
1067
|
+
for (let frame = fromIndex + 1; frame < toIndex; frame += 1) {
|
|
1068
|
+
const t = span > 0 ? (frame - fromIndex) / span : 0;
|
|
1069
|
+
out[frame] = fromValue + (toValue - fromValue) * t;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
// src/camera/rules/track.ts
|
|
1075
|
+
var frameCountFor = (plan) => Math.max(1, Math.ceil(planDurationMs(plan) / MILLISECONDS_PER_SECOND * plan.output.fps));
|
|
1076
|
+
var modeLeadScreenFractions = {
|
|
1077
|
+
chase: 0.26,
|
|
1078
|
+
cinematic: 0.24,
|
|
1079
|
+
director: 0.16,
|
|
1080
|
+
drone: 0.08,
|
|
1081
|
+
helicopter: 0,
|
|
1082
|
+
overview: 0.12,
|
|
1083
|
+
smart: 0.16
|
|
1084
|
+
};
|
|
1085
|
+
var LEAD_MAX_METERS = 400;
|
|
1086
|
+
var MAX_MARKER_OFFCENTER_FRACTION = 0.32;
|
|
1087
|
+
var modeBearingMinSmoothSeconds = {
|
|
1088
|
+
chase: 0.3,
|
|
1089
|
+
cinematic: 0.35,
|
|
1090
|
+
director: 0.35,
|
|
1091
|
+
drone: 0.9,
|
|
1092
|
+
helicopter: 0.8,
|
|
1093
|
+
overview: 0.6,
|
|
1094
|
+
smart: 0.45
|
|
1095
|
+
};
|
|
1096
|
+
var modeHoldRevealZoom = {
|
|
1097
|
+
chase: 0.5,
|
|
1098
|
+
cinematic: 0.66,
|
|
1099
|
+
director: 0.4,
|
|
1100
|
+
drone: 0.9,
|
|
1101
|
+
helicopter: 0.8,
|
|
1102
|
+
overview: 1.1,
|
|
1103
|
+
smart: 0.42
|
|
1104
|
+
};
|
|
1105
|
+
var modeHoldSettleZoom = {
|
|
1106
|
+
chase: 0.35,
|
|
1107
|
+
cinematic: 0.42,
|
|
1108
|
+
director: 0.3,
|
|
1109
|
+
drone: 0.6,
|
|
1110
|
+
helicopter: 0.55,
|
|
1111
|
+
overview: 0.9,
|
|
1112
|
+
smart: 0.3
|
|
1113
|
+
};
|
|
1114
|
+
var BUDGET_KNEE_FRACTION = 0.8;
|
|
1115
|
+
var BUDGET_KNEE_SPAN = 0.2;
|
|
1116
|
+
var EDGE_EASE_SUBNODES = 8;
|
|
1117
|
+
var EDGE_EASE_WINDOW_FRACTION = 0.3;
|
|
1118
|
+
var REPRESENTATIVE_TRAVEL_FRACTION = 0.2;
|
|
1119
|
+
var resolveFrameProgressions = (plan) => {
|
|
1120
|
+
const shots = plan.shots.length > 0 ? plan.shots : fullRouteFollowShots(plan);
|
|
1121
|
+
const timeline = buildTimeline(shots, plan.targetDurationMs);
|
|
1122
|
+
const totalMs = planDurationMs(plan);
|
|
1123
|
+
const frameCount = frameCountFor(plan);
|
|
1124
|
+
const lastFrame = frameCount - 1;
|
|
1125
|
+
const fractions = new Array(frameCount);
|
|
1126
|
+
for (let frame = 0; frame < frameCount; frame += 1) {
|
|
1127
|
+
const timeMs = lastFrame === 0 ? 0 : frame / lastFrame * totalMs;
|
|
1128
|
+
fractions[frame] = progressAtTime(timeline, timeMs);
|
|
1129
|
+
}
|
|
1130
|
+
return fractions;
|
|
1131
|
+
};
|
|
1132
|
+
var resolveCameraTrack = (plan, itinerary, sampler, clearanceStride) => {
|
|
1133
|
+
if (sampler === void 0) {
|
|
1134
|
+
const bySignature = cameraTracks.get(itinerary) ?? /* @__PURE__ */ new Map();
|
|
1135
|
+
const signature = posePlanSignature(plan);
|
|
1136
|
+
const memoized = bySignature.get(signature);
|
|
1137
|
+
if (memoized !== void 0) {
|
|
1138
|
+
return memoized;
|
|
1139
|
+
}
|
|
1140
|
+
const resolved = walkCameraTrack(plan, itinerary, void 0, clearanceStride);
|
|
1141
|
+
bySignature.delete(signature);
|
|
1142
|
+
bySignature.set(signature, resolved);
|
|
1143
|
+
if (bySignature.size > CAMERA_TRACK_CAP) {
|
|
1144
|
+
const oldest = bySignature.keys().next().value;
|
|
1145
|
+
if (oldest !== void 0) {
|
|
1146
|
+
bySignature.delete(oldest);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
cameraTracks.set(itinerary, bySignature);
|
|
1150
|
+
return resolved;
|
|
1151
|
+
}
|
|
1152
|
+
return walkCameraTrack(plan, itinerary, sampler, clearanceStride);
|
|
1153
|
+
};
|
|
1154
|
+
var CAMERA_TRACK_CAP = 8;
|
|
1155
|
+
var cameraTracks = /* @__PURE__ */ new WeakMap();
|
|
1156
|
+
var walkCameraTrack = (plan, itinerary, sampler, clearanceStride) => {
|
|
1157
|
+
refuseUnplannableRoute("resolveCameraTrack", itinerary);
|
|
1158
|
+
const shots = plan.shots.length > 0 ? plan.shots : fullRouteFollowShots(plan);
|
|
1159
|
+
const spline = buildCameraSpline(shots, itinerary, plan.mode);
|
|
1160
|
+
const timeline = buildTimeline(shots, plan.targetDurationMs);
|
|
1161
|
+
const totalMs = planDurationMs(plan);
|
|
1162
|
+
const fps = plan.output.fps;
|
|
1163
|
+
const line = continuousLine(itinerary.line);
|
|
1164
|
+
const cumulative = cumulativeMeters(line);
|
|
1165
|
+
const routeMeters = cumulative[cumulative.length - 1] ?? 0;
|
|
1166
|
+
const fractions = resolveFrameProgressions(plan);
|
|
1167
|
+
const frameCount = fractions.length;
|
|
1168
|
+
const lastFrame = frameCount - 1;
|
|
1169
|
+
const positions = fractions.map((fraction) => fraction * lastFrame);
|
|
1170
|
+
const raw = sampleRawChannels(spline, line, cumulative, plan.mode, frameCount);
|
|
1171
|
+
const smoothed = smoothTrackChannels(raw, plan.mode, routeMeters, fps);
|
|
1172
|
+
const centerLngs = sampleSeriesAt(smoothed.centerLngs, positions);
|
|
1173
|
+
const centerLats = sampleSeriesAt(smoothed.centerLats, positions);
|
|
1174
|
+
const pitches = sampleSeriesAt(smoothed.pitches, positions);
|
|
1175
|
+
const zooms = sampleSeriesAt(smoothed.zooms, positions);
|
|
1176
|
+
const bearings = sampleCircularSeriesAt(smoothed.bearings, positions);
|
|
1177
|
+
applyHoldZoomShaping(zooms, shots, plan.mode, totalMs, lastFrame);
|
|
1178
|
+
const markers = resolveMarkerSeries(plan, itinerary);
|
|
1179
|
+
clampCenterToMarkerBudget(centerLngs, centerLats, markers, zooms);
|
|
1180
|
+
const clearance = sampler ? resolveClearanceAdjustments(
|
|
1181
|
+
buildClearanceFrames(
|
|
1182
|
+
frameCount,
|
|
1183
|
+
timeline,
|
|
1184
|
+
totalMs,
|
|
1185
|
+
centerLngs,
|
|
1186
|
+
centerLats,
|
|
1187
|
+
pitches,
|
|
1188
|
+
zooms,
|
|
1189
|
+
bearings
|
|
1190
|
+
),
|
|
1191
|
+
itinerary,
|
|
1192
|
+
sampler,
|
|
1193
|
+
{ mode: plan.mode, sampleStride: clearanceStride }
|
|
1194
|
+
) : null;
|
|
1195
|
+
const poses = new Array(frameCount);
|
|
1196
|
+
for (let frame = 0; frame < frameCount; frame += 1) {
|
|
1197
|
+
const frameZoom = clampZoom(zooms[frame] ?? raw.zooms[frame] ?? 0);
|
|
1198
|
+
const framePitch = pitches[frame] ?? raw.pitches[frame] ?? 0;
|
|
1199
|
+
const clearanceZoom = clearance?.zoom[frame];
|
|
1200
|
+
const clearancePitch = clearance?.pitch[frame];
|
|
1201
|
+
poses[frame] = {
|
|
1202
|
+
bearing: bearings[frame] ?? raw.bearings[frame] ?? 0,
|
|
1203
|
+
center: [
|
|
1204
|
+
centerLngs[frame] ?? raw.baseLngs[frame] ?? 0,
|
|
1205
|
+
centerLats[frame] ?? raw.baseLats[frame] ?? 0
|
|
1206
|
+
],
|
|
1207
|
+
pitch: clearancePitch === void 0 ? framePitch : Math.min(framePitch, clearancePitch),
|
|
1208
|
+
zoom: clearanceZoom === void 0 ? frameZoom : Math.min(frameZoom, clearanceZoom)
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
return poses;
|
|
1212
|
+
};
|
|
1213
|
+
var sampleRawChannels = (spline, line, cumulative, mode, frameCount) => {
|
|
1214
|
+
const lastFrame = frameCount - 1;
|
|
1215
|
+
const routeMeters = cumulative[cumulative.length - 1] ?? 0;
|
|
1216
|
+
const leadFraction = modeLeadScreenFractions[mode];
|
|
1217
|
+
const rawBaseLngs = new Array(frameCount);
|
|
1218
|
+
const rawBaseLats = new Array(frameCount);
|
|
1219
|
+
const rawLeadLngs = new Array(frameCount);
|
|
1220
|
+
const rawLeadLats = new Array(frameCount);
|
|
1221
|
+
const rawPitches = new Array(frameCount);
|
|
1222
|
+
const rawZooms = new Array(frameCount);
|
|
1223
|
+
const rawBearings = new Array(frameCount);
|
|
1224
|
+
for (let k = 0; k < frameCount; k += 1) {
|
|
1225
|
+
const progress = lastFrame === 0 ? 0 : k / lastFrame;
|
|
1226
|
+
const pose = evalSpline(spline, progress);
|
|
1227
|
+
const lat = pose.center[1];
|
|
1228
|
+
const metersFromStart = progress * routeMeters;
|
|
1229
|
+
const base = pointAtMeters(line, metersFromStart, cumulative);
|
|
1230
|
+
const leadM = Math.min(
|
|
1231
|
+
LEAD_MAX_METERS,
|
|
1232
|
+
metersFromStart,
|
|
1233
|
+
pose.followWeight * leadFraction * viewportGroundSpanMeters(pose.zoom, lat)
|
|
1234
|
+
);
|
|
1235
|
+
const led = pointAtMeters(line, metersFromStart + leadM, cumulative);
|
|
1236
|
+
rawBaseLngs[k] = base[0];
|
|
1237
|
+
rawBaseLats[k] = base[1];
|
|
1238
|
+
rawLeadLngs[k] = led[0] - base[0];
|
|
1239
|
+
rawLeadLats[k] = led[1] - base[1];
|
|
1240
|
+
rawPitches[k] = pose.pitch;
|
|
1241
|
+
rawZooms[k] = pose.zoom;
|
|
1242
|
+
rawBearings[k] = pose.bearing;
|
|
1243
|
+
}
|
|
1244
|
+
return {
|
|
1245
|
+
baseLats: rawBaseLats,
|
|
1246
|
+
baseLngs: rawBaseLngs,
|
|
1247
|
+
bearings: rawBearings,
|
|
1248
|
+
leadLats: rawLeadLats,
|
|
1249
|
+
leadLngs: rawLeadLngs,
|
|
1250
|
+
pitches: rawPitches,
|
|
1251
|
+
zooms: rawZooms
|
|
1252
|
+
};
|
|
1253
|
+
};
|
|
1254
|
+
var smoothTrackChannels = (raw, mode, routeMeters, fps) => {
|
|
1255
|
+
const frameCount = raw.pitches.length;
|
|
1256
|
+
const sigmas = modeSmoothingSigmas[mode];
|
|
1257
|
+
const centerSigmaFrames = sigmaFramesForMeters(sigmas.center, frameCount, routeMeters);
|
|
1258
|
+
const pitchZoomSigmaFrames = sigmaFramesForMeters(sigmas.pitchZoom, frameCount, routeMeters);
|
|
1259
|
+
const bearingSigmaFrames = bearingSigmaFramesFor(mode, frameCount, routeMeters, fps);
|
|
1260
|
+
const leadTaper = endpointTaper(frameCount, Math.ceil(centerSigmaFrames * 3));
|
|
1261
|
+
const smoothedCenterLngs = addSeries(
|
|
1262
|
+
smoothPositionSeries(raw.baseLngs, centerSigmaFrames),
|
|
1263
|
+
multiplySeries(smoothSeries(raw.leadLngs, centerSigmaFrames), leadTaper)
|
|
1264
|
+
);
|
|
1265
|
+
const smoothedCenterLats = addSeries(
|
|
1266
|
+
smoothPositionSeries(raw.baseLats, centerSigmaFrames),
|
|
1267
|
+
multiplySeries(smoothSeries(raw.leadLats, centerSigmaFrames), leadTaper)
|
|
1268
|
+
);
|
|
1269
|
+
const smoothedPitches = smoothSeries(raw.pitches, pitchZoomSigmaFrames);
|
|
1270
|
+
const smoothedZooms = smoothSeries(raw.zooms, pitchZoomSigmaFrames);
|
|
1271
|
+
const smoothedBearings = smoothSeries(unwrapBearings(raw.bearings), bearingSigmaFrames).map(
|
|
1272
|
+
(value) => (value % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN
|
|
1273
|
+
);
|
|
1274
|
+
return {
|
|
1275
|
+
bearings: smoothedBearings,
|
|
1276
|
+
centerLats: smoothedCenterLats,
|
|
1277
|
+
centerLngs: smoothedCenterLngs,
|
|
1278
|
+
pitches: smoothedPitches,
|
|
1279
|
+
zooms: smoothedZooms
|
|
1280
|
+
};
|
|
1281
|
+
};
|
|
1282
|
+
var resolveMarkerSeries = (plan, itinerary) => {
|
|
1283
|
+
const line = continuousLine(itinerary.line);
|
|
1284
|
+
const cumulative = cumulativeMeters(line);
|
|
1285
|
+
const routeMeters = cumulative[cumulative.length - 1] ?? 0;
|
|
1286
|
+
const fractions = resolveFrameProgressions(plan);
|
|
1287
|
+
const frameCount = fractions.length;
|
|
1288
|
+
const markers = new Array(frameCount);
|
|
1289
|
+
for (let frame = 0; frame < frameCount; frame += 1) {
|
|
1290
|
+
markers[frame] = pointAtMeters(line, (fractions[frame] ?? 0) * routeMeters, cumulative);
|
|
1291
|
+
}
|
|
1292
|
+
return markers;
|
|
1293
|
+
};
|
|
1294
|
+
var resolveRouteMarkers = (plan, itinerary) => {
|
|
1295
|
+
refuseUnplannableRoute("resolveRouteMarkers", itinerary);
|
|
1296
|
+
return resolveMarkerSeries(plan, itinerary);
|
|
1297
|
+
};
|
|
1298
|
+
var clearanceStrideFor = (plan, itinerary) => clearanceSampleStride(frameCountFor(plan), routeLengthMeters(itinerary.line), {
|
|
1299
|
+
mode: plan.mode
|
|
1300
|
+
});
|
|
1301
|
+
var posePlanSignature = (plan) => {
|
|
1302
|
+
const shots = plan.shots.map(
|
|
1303
|
+
(shot) => `${shot.at},${shot.bearingDeg ?? ""},${shot.bearingMode},${shot.holdMs},${shot.pitchDeg},${shot.speedScale},${shot.zoom}`
|
|
1304
|
+
).join(";");
|
|
1305
|
+
return `${plan.mode}|${plan.targetDurationMs}|${plan.output.fps}|${shots}`;
|
|
1306
|
+
};
|
|
1307
|
+
var representativeStillFraction = (plan) => {
|
|
1308
|
+
if (plan.mode === "director" || plan.shots.length === 0) {
|
|
1309
|
+
return 0;
|
|
1310
|
+
}
|
|
1311
|
+
const total = planDurationMs(plan);
|
|
1312
|
+
if (total <= 0) {
|
|
1313
|
+
return 0;
|
|
1314
|
+
}
|
|
1315
|
+
const introHoldMs = [...plan.shots].sort((a, b) => a.at - b.at)[0]?.holdMs ?? 0;
|
|
1316
|
+
const introEnd = Math.min(1, introHoldMs / total);
|
|
1317
|
+
return Math.min(1, introEnd + (1 - introEnd) * REPRESENTATIVE_TRAVEL_FRACTION);
|
|
1318
|
+
};
|
|
1319
|
+
var bearingSigmaFramesFor = (mode, frameCount, routeMeters, fps) => {
|
|
1320
|
+
const distanceFrames = sigmaFramesForMeters(
|
|
1321
|
+
modeSmoothingSigmas[mode].bearing,
|
|
1322
|
+
frameCount,
|
|
1323
|
+
routeMeters
|
|
1324
|
+
);
|
|
1325
|
+
const timeFloorFrames = modeBearingMinSmoothSeconds[mode] * fps;
|
|
1326
|
+
return Math.min(frameCount / 3, Math.max(distanceFrames, timeFloorFrames));
|
|
1327
|
+
};
|
|
1328
|
+
var sampleSeriesAt = (series, positions) => {
|
|
1329
|
+
const length = series.length;
|
|
1330
|
+
return positions.map((position) => {
|
|
1331
|
+
if (length === 0) {
|
|
1332
|
+
return 0;
|
|
1333
|
+
}
|
|
1334
|
+
const clamped = Math.min(length - 1, Math.max(0, position));
|
|
1335
|
+
const lo = Math.floor(clamped);
|
|
1336
|
+
const hi = Math.min(length - 1, lo + 1);
|
|
1337
|
+
const frac = clamped - lo;
|
|
1338
|
+
const a = series[lo] ?? 0;
|
|
1339
|
+
const b = series[hi] ?? a;
|
|
1340
|
+
return a + (b - a) * frac;
|
|
1341
|
+
});
|
|
1342
|
+
};
|
|
1343
|
+
var sampleCircularSeriesAt = (series, positions) => {
|
|
1344
|
+
const length = series.length;
|
|
1345
|
+
return positions.map((position) => {
|
|
1346
|
+
if (length === 0) {
|
|
1347
|
+
return 0;
|
|
1348
|
+
}
|
|
1349
|
+
const clamped = Math.min(length - 1, Math.max(0, position));
|
|
1350
|
+
const lo = Math.floor(clamped);
|
|
1351
|
+
const hi = Math.min(length - 1, lo + 1);
|
|
1352
|
+
const frac = clamped - lo;
|
|
1353
|
+
const a = series[lo] ?? 0;
|
|
1354
|
+
const b = series[hi] ?? a;
|
|
1355
|
+
const delta = ((b - a) % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
1356
|
+
const shortest = delta > DEGREES_PER_TURN / 2 ? delta - DEGREES_PER_TURN : delta;
|
|
1357
|
+
const result = a + shortest * frac;
|
|
1358
|
+
return (result % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
1359
|
+
});
|
|
1360
|
+
};
|
|
1361
|
+
var addSeries = (a, b) => a.map((value, index) => value + (b[index] ?? 0));
|
|
1362
|
+
var multiplySeries = (values, weights) => values.map((value, index) => value * (weights[index] ?? 1));
|
|
1363
|
+
var endpointTaper = (frameCount, rampFrames) => {
|
|
1364
|
+
const lastFrame = frameCount - 1;
|
|
1365
|
+
const ramp = Math.max(1, rampFrames);
|
|
1366
|
+
const out = new Array(frameCount);
|
|
1367
|
+
for (let i = 0; i < frameCount; i += 1) {
|
|
1368
|
+
const rise = smoothstep(i / ramp);
|
|
1369
|
+
const fall = smoothstep((lastFrame - i) / ramp);
|
|
1370
|
+
out[i] = rise * fall;
|
|
1371
|
+
}
|
|
1372
|
+
return out;
|
|
1373
|
+
};
|
|
1374
|
+
var recoverHoldWindows = (shots, targetDurationMs) => {
|
|
1375
|
+
const sorted = [...shots].sort((a, b) => a.at - b.at);
|
|
1376
|
+
const first = sorted[0];
|
|
1377
|
+
if (!first) {
|
|
1378
|
+
return [];
|
|
1379
|
+
}
|
|
1380
|
+
const lastIndex = sorted.length - 1;
|
|
1381
|
+
let weightTotal = 0;
|
|
1382
|
+
const legWeights = [];
|
|
1383
|
+
for (let index = 1; index < sorted.length; index += 1) {
|
|
1384
|
+
const from = sorted[index - 1];
|
|
1385
|
+
const to = sorted[index];
|
|
1386
|
+
if (!from || !to) {
|
|
1387
|
+
legWeights.push(0);
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
const span = Math.max(0, to.at - from.at);
|
|
1391
|
+
const weight = span / Math.max(0.1, to.speedScale);
|
|
1392
|
+
legWeights.push(weight);
|
|
1393
|
+
weightTotal += weight;
|
|
1394
|
+
}
|
|
1395
|
+
const windows = [];
|
|
1396
|
+
let timeMs = 0;
|
|
1397
|
+
if (first.holdMs > 0) {
|
|
1398
|
+
windows.push({
|
|
1399
|
+
enterMs: timeMs,
|
|
1400
|
+
exitMs: timeMs + first.holdMs,
|
|
1401
|
+
position: "intro",
|
|
1402
|
+
shot: first
|
|
1403
|
+
});
|
|
1404
|
+
timeMs += first.holdMs;
|
|
1405
|
+
}
|
|
1406
|
+
for (let index = 1; index < sorted.length; index += 1) {
|
|
1407
|
+
const to = sorted[index];
|
|
1408
|
+
if (!to) {
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
const weight = legWeights[index - 1] ?? 0;
|
|
1412
|
+
const legMs = weightTotal > 0 ? weight / weightTotal * targetDurationMs : 0;
|
|
1413
|
+
timeMs += legMs;
|
|
1414
|
+
if (to.holdMs > 0) {
|
|
1415
|
+
windows.push({
|
|
1416
|
+
enterMs: timeMs,
|
|
1417
|
+
exitMs: timeMs + to.holdMs,
|
|
1418
|
+
position: index === lastIndex ? "outro" : "mid",
|
|
1419
|
+
shot: to
|
|
1420
|
+
});
|
|
1421
|
+
timeMs += to.holdMs;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return windows;
|
|
1425
|
+
};
|
|
1426
|
+
var applyHoldZoomShaping = (zooms, shots, mode, totalMs, lastFrame) => {
|
|
1427
|
+
if (totalMs <= 0 || lastFrame <= 0) {
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
const reveal = modeHoldRevealZoom[mode];
|
|
1431
|
+
const settle = modeHoldSettleZoom[mode];
|
|
1432
|
+
for (const window of recoverHoldWindows(shots, totalMs - sumHolds(shots))) {
|
|
1433
|
+
if (mode === "director" && window.shot.bearingMode !== "follow") {
|
|
1434
|
+
continue;
|
|
1435
|
+
}
|
|
1436
|
+
const dwellMs = window.exitMs - window.enterMs;
|
|
1437
|
+
if (dwellMs <= 0) {
|
|
1438
|
+
continue;
|
|
1439
|
+
}
|
|
1440
|
+
const fromFrame = Math.max(0, Math.ceil(window.enterMs / totalMs * lastFrame));
|
|
1441
|
+
const toFrame = Math.min(lastFrame, Math.floor(window.exitMs / totalMs * lastFrame));
|
|
1442
|
+
for (let frame = fromFrame; frame <= toFrame; frame += 1) {
|
|
1443
|
+
const timeMs = frame / lastFrame * totalMs;
|
|
1444
|
+
const u = Math.min(1, Math.max(0, (timeMs - window.enterMs) / dwellMs));
|
|
1445
|
+
const offset = holdZoomOffset(window.position, u, reveal, settle);
|
|
1446
|
+
zooms[frame] = (zooms[frame] ?? 0) + offset;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
var holdZoomOffset = (position, u, reveal, settle) => {
|
|
1451
|
+
if (position === "intro") {
|
|
1452
|
+
return -reveal * (1 - easeInOutCubic(u));
|
|
1453
|
+
}
|
|
1454
|
+
if (position === "outro") {
|
|
1455
|
+
return -settle * easeInOutCubic(u);
|
|
1456
|
+
}
|
|
1457
|
+
const s = Math.sin(Math.PI * u);
|
|
1458
|
+
return -0.2 * s * s;
|
|
1459
|
+
};
|
|
1460
|
+
var clampCenterToMarkerBudget = (centerLngs, centerLats, markers, zooms) => {
|
|
1461
|
+
for (let frame = 0; frame < centerLngs.length; frame += 1) {
|
|
1462
|
+
const marker = markers[frame];
|
|
1463
|
+
const centerLng = centerLngs[frame];
|
|
1464
|
+
const centerLat = centerLats[frame];
|
|
1465
|
+
if (!marker || centerLng === void 0 || centerLat === void 0) {
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
const budget = MAX_MARKER_OFFCENTER_FRACTION * viewportGroundSpanMeters(zooms[frame] ?? 0, centerLat);
|
|
1469
|
+
if (budget <= 0) {
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
const metersPerDegLng = METERS_PER_DEGREE_WEB_MERCATOR * Math.cos(centerLat * DEGREES_TO_RADIANS);
|
|
1473
|
+
const dEast = (centerLng - marker[0]) * metersPerDegLng;
|
|
1474
|
+
const dNorth = (centerLat - marker[1]) * METERS_PER_DEGREE_WEB_MERCATOR;
|
|
1475
|
+
const offset = Math.hypot(dEast, dNorth);
|
|
1476
|
+
const knee = BUDGET_KNEE_FRACTION * budget;
|
|
1477
|
+
if (offset <= knee || offset <= 0) {
|
|
1478
|
+
continue;
|
|
1479
|
+
}
|
|
1480
|
+
const clampedOffset = budget * (BUDGET_KNEE_FRACTION + BUDGET_KNEE_SPAN * Math.tanh((offset / budget - BUDGET_KNEE_FRACTION) / BUDGET_KNEE_SPAN));
|
|
1481
|
+
const scale = clampedOffset / offset;
|
|
1482
|
+
centerLngs[frame] = marker[0] + (centerLng - marker[0]) * scale;
|
|
1483
|
+
centerLats[frame] = marker[1] + (centerLat - marker[1]) * scale;
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
var easeInOutCubic = (t) => {
|
|
1487
|
+
const x = Math.min(1, Math.max(0, t));
|
|
1488
|
+
return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
1489
|
+
};
|
|
1490
|
+
var sumHolds = (shots) => {
|
|
1491
|
+
let holds = 0;
|
|
1492
|
+
for (const shot of shots) {
|
|
1493
|
+
holds += shot.holdMs;
|
|
1494
|
+
}
|
|
1495
|
+
return holds;
|
|
1496
|
+
};
|
|
1497
|
+
var buildClearanceFrames = (frameCount, timeline, totalMs, centerLngs, centerLats, pitches, zooms, bearings) => {
|
|
1498
|
+
const lastFrame = frameCount - 1;
|
|
1499
|
+
const frames = new Array(frameCount);
|
|
1500
|
+
for (let frame = 0; frame < frameCount; frame += 1) {
|
|
1501
|
+
const timeMs = lastFrame === 0 ? 0 : frame / lastFrame * totalMs;
|
|
1502
|
+
frames[frame] = {
|
|
1503
|
+
bearing: bearings[frame] ?? 0,
|
|
1504
|
+
center: [centerLngs[frame] ?? 0, centerLats[frame] ?? 0],
|
|
1505
|
+
fraction: progressAtTime(timeline, timeMs),
|
|
1506
|
+
pitch: pitches[frame] ?? 0,
|
|
1507
|
+
zoom: zooms[frame] ?? 0
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
return frames;
|
|
1511
|
+
};
|
|
1512
|
+
var buildTimeline = (shots, targetDurationMs) => {
|
|
1513
|
+
const sorted = [...shots].sort((a, b) => a.at - b.at);
|
|
1514
|
+
const first = sorted[0];
|
|
1515
|
+
if (!first) {
|
|
1516
|
+
return [{ fraction: 0, timeMs: 0 }];
|
|
1517
|
+
}
|
|
1518
|
+
let weightTotal = 0;
|
|
1519
|
+
const legWeights = [];
|
|
1520
|
+
for (let index = 1; index < sorted.length; index += 1) {
|
|
1521
|
+
const from = sorted[index - 1];
|
|
1522
|
+
const to = sorted[index];
|
|
1523
|
+
if (!from || !to) {
|
|
1524
|
+
legWeights.push(0);
|
|
1525
|
+
continue;
|
|
1526
|
+
}
|
|
1527
|
+
const span = Math.max(0, to.at - from.at);
|
|
1528
|
+
const weight = span / Math.max(0.1, to.speedScale);
|
|
1529
|
+
legWeights.push(weight);
|
|
1530
|
+
weightTotal += weight;
|
|
1531
|
+
}
|
|
1532
|
+
const nodes = [];
|
|
1533
|
+
let timeMs = 0;
|
|
1534
|
+
nodes.push({ fraction: first.at, timeMs });
|
|
1535
|
+
if (first.holdMs > 0) {
|
|
1536
|
+
timeMs += first.holdMs;
|
|
1537
|
+
nodes.push({ fraction: first.at, timeMs });
|
|
1538
|
+
}
|
|
1539
|
+
const lastLegIndex = sorted.length - 1;
|
|
1540
|
+
for (let index = 1; index < sorted.length; index += 1) {
|
|
1541
|
+
const from = sorted[index - 1];
|
|
1542
|
+
const to = sorted[index];
|
|
1543
|
+
if (!from || !to) {
|
|
1544
|
+
continue;
|
|
1545
|
+
}
|
|
1546
|
+
const weight = legWeights[index - 1] ?? 0;
|
|
1547
|
+
const legMs = weightTotal > 0 ? weight / weightTotal * targetDurationMs : 0;
|
|
1548
|
+
const ease = edgeEaseFor(index, lastLegIndex);
|
|
1549
|
+
if (ease && legMs > 0 && to.at !== from.at) {
|
|
1550
|
+
for (let sub = 1; sub <= EDGE_EASE_SUBNODES; sub += 1) {
|
|
1551
|
+
const u = sub / (EDGE_EASE_SUBNODES + 1);
|
|
1552
|
+
nodes.push({
|
|
1553
|
+
fraction: from.at + (to.at - from.at) * ease(u),
|
|
1554
|
+
timeMs: timeMs + legMs * u
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
timeMs += legMs;
|
|
1559
|
+
nodes.push({ fraction: to.at, timeMs });
|
|
1560
|
+
if (to.holdMs > 0) {
|
|
1561
|
+
timeMs += to.holdMs;
|
|
1562
|
+
nodes.push({ fraction: to.at, timeMs });
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
return nodes;
|
|
1566
|
+
};
|
|
1567
|
+
var edgeEaseFor = (legIndex, lastLegIndex) => {
|
|
1568
|
+
const isFirst = legIndex === 1;
|
|
1569
|
+
const isLast = legIndex === lastLegIndex;
|
|
1570
|
+
if (isFirst && isLast) {
|
|
1571
|
+
return (u) => accelerateDecelerateProfile(u, EDGE_EASE_WINDOW_FRACTION);
|
|
1572
|
+
}
|
|
1573
|
+
if (isFirst) {
|
|
1574
|
+
return (u) => accelerateProfile(u, EDGE_EASE_WINDOW_FRACTION);
|
|
1575
|
+
}
|
|
1576
|
+
if (isLast) {
|
|
1577
|
+
return (u) => decelerateProfile(u, EDGE_EASE_WINDOW_FRACTION);
|
|
1578
|
+
}
|
|
1579
|
+
return null;
|
|
1580
|
+
};
|
|
1581
|
+
var accelerateProfile = (u, a) => {
|
|
1582
|
+
const cruise = 1 / (1 - a / 2);
|
|
1583
|
+
return u <= a ? cruise * u * u / (2 * a) : cruise * (u - a / 2);
|
|
1584
|
+
};
|
|
1585
|
+
var decelerateProfile = (u, a) => {
|
|
1586
|
+
const cruise = 1 / (1 - a / 2);
|
|
1587
|
+
return u >= 1 - a ? 1 - cruise * (1 - u) * (1 - u) / (2 * a) : cruise * u;
|
|
1588
|
+
};
|
|
1589
|
+
var accelerateDecelerateProfile = (u, a) => {
|
|
1590
|
+
const cruise = 1 / (1 - a);
|
|
1591
|
+
if (u <= a) {
|
|
1592
|
+
return cruise * u * u / (2 * a);
|
|
1593
|
+
}
|
|
1594
|
+
if (u >= 1 - a) {
|
|
1595
|
+
return 1 - cruise * (1 - u) * (1 - u) / (2 * a);
|
|
1596
|
+
}
|
|
1597
|
+
return cruise * (u - a / 2);
|
|
1598
|
+
};
|
|
1599
|
+
var progressAtTime = (nodes, timeMs) => {
|
|
1600
|
+
const first = nodes[0];
|
|
1601
|
+
const last = nodes[nodes.length - 1];
|
|
1602
|
+
if (!first || !last) {
|
|
1603
|
+
return 0;
|
|
1604
|
+
}
|
|
1605
|
+
if (timeMs <= first.timeMs) {
|
|
1606
|
+
return first.fraction;
|
|
1607
|
+
}
|
|
1608
|
+
if (timeMs >= last.timeMs) {
|
|
1609
|
+
return last.fraction;
|
|
1610
|
+
}
|
|
1611
|
+
for (let index = 1; index < nodes.length; index += 1) {
|
|
1612
|
+
const from = nodes[index - 1];
|
|
1613
|
+
const to = nodes[index];
|
|
1614
|
+
if (!from || !to) {
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
if (timeMs <= to.timeMs) {
|
|
1618
|
+
const span = to.timeMs - from.timeMs;
|
|
1619
|
+
if (span <= 0) {
|
|
1620
|
+
return to.fraction;
|
|
1621
|
+
}
|
|
1622
|
+
const ratio = (timeMs - from.timeMs) / span;
|
|
1623
|
+
return from.fraction + (to.fraction - from.fraction) * ratio;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return last.fraction;
|
|
1627
|
+
};
|
|
1628
|
+
var fullRouteFollowShots = (plan) => [
|
|
1629
|
+
{
|
|
1630
|
+
at: 0,
|
|
1631
|
+
bearingMode: "follow",
|
|
1632
|
+
holdMs: 0,
|
|
1633
|
+
id: `${plan.mode}-full-itinerary-start`,
|
|
1634
|
+
pitchDeg: 60,
|
|
1635
|
+
speedScale: 1,
|
|
1636
|
+
zoom: 14
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
at: 1,
|
|
1640
|
+
bearingMode: "follow",
|
|
1641
|
+
holdMs: 0,
|
|
1642
|
+
id: `${plan.mode}-full-itinerary-end`,
|
|
1643
|
+
pitchDeg: 60,
|
|
1644
|
+
speedScale: 1,
|
|
1645
|
+
zoom: 14
|
|
1646
|
+
}
|
|
1647
|
+
];
|
|
1648
|
+
|
|
1649
|
+
// src/camera/rules/profileSamples.ts
|
|
1650
|
+
var buildAscentPrefix = (points) => {
|
|
1651
|
+
const prefix = new Array(points.length);
|
|
1652
|
+
let total = 0;
|
|
1653
|
+
for (let index = 0; index < points.length; index += 1) {
|
|
1654
|
+
if (index > 0) {
|
|
1655
|
+
const delta = (points[index]?.elevation ?? 0) - (points[index - 1]?.elevation ?? 0);
|
|
1656
|
+
if (delta > 0) {
|
|
1657
|
+
total += delta;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
prefix[index] = total;
|
|
1661
|
+
}
|
|
1662
|
+
return prefix;
|
|
1663
|
+
};
|
|
1664
|
+
var resolveProfileSamples = (plan, itinerary, source) => {
|
|
1665
|
+
const bySource = profileSamples.get(itinerary) ?? /* @__PURE__ */ new WeakMap();
|
|
1666
|
+
const bySignature = bySource.get(source) ?? /* @__PURE__ */ new Map();
|
|
1667
|
+
const signature = posePlanSignature(plan);
|
|
1668
|
+
const memoized = bySignature.get(signature);
|
|
1669
|
+
if (memoized !== void 0) {
|
|
1670
|
+
return memoized;
|
|
1671
|
+
}
|
|
1672
|
+
const samples = walkProfileSamples(plan, itinerary, source);
|
|
1673
|
+
bySignature.set(signature, samples);
|
|
1674
|
+
if (bySignature.size > CAMERA_TRACK_CAP) {
|
|
1675
|
+
const oldest = bySignature.keys().next().value;
|
|
1676
|
+
if (oldest !== void 0) {
|
|
1677
|
+
bySignature.delete(oldest);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
bySource.set(source, bySignature);
|
|
1681
|
+
profileSamples.set(itinerary, bySource);
|
|
1682
|
+
return samples;
|
|
1683
|
+
};
|
|
1684
|
+
var profileSamples = /* @__PURE__ */ new WeakMap();
|
|
1685
|
+
var walkProfileSamples = (plan, itinerary, source) => {
|
|
1686
|
+
refuseUnplannableRoute("resolveProfileSamples", itinerary);
|
|
1687
|
+
const fractions = resolveFrameProgressions(plan);
|
|
1688
|
+
const cumulative = cumulativeMeters(itinerary.line);
|
|
1689
|
+
const ground = routeGroundMeters(itinerary, cumulative);
|
|
1690
|
+
const flightMeters = cumulative[cumulative.length - 1] ?? 0;
|
|
1691
|
+
const points = source.elevationPoints;
|
|
1692
|
+
const ascentPrefix = buildAscentPrefix(points);
|
|
1693
|
+
const climbs = detectClimbs(points);
|
|
1694
|
+
return fractions.map((fraction) => {
|
|
1695
|
+
const distanceKm = groundMetersAt(cumulative, ground, fraction * flightMeters) / METERS_PER_KILOMETER;
|
|
1696
|
+
const index = nearestRoutePointIndexAt(points, distanceKm);
|
|
1697
|
+
const span = stretchAt(source.segmentSpans, distanceKm);
|
|
1698
|
+
const climb = climbAt(climbs, distanceKm);
|
|
1699
|
+
return {
|
|
1700
|
+
// Elevation and ascent share the one resolved index so a frame's altitude and
|
|
1701
|
+
// its running climb are read from the same point; an itinerary with no elevation
|
|
1702
|
+
// points yields index -1, leaving both null.
|
|
1703
|
+
ascentM: index < 0 ? null : ascentPrefix[index] ?? null,
|
|
1704
|
+
climbAvgGradePercent: climb?.avgGradePercent ?? null,
|
|
1705
|
+
climbCategory: climb?.category ?? null,
|
|
1706
|
+
climbEndKm: climb?.endKm ?? null,
|
|
1707
|
+
distanceKm,
|
|
1708
|
+
elevation: index < 0 ? null : points[index]?.elevation ?? null,
|
|
1709
|
+
progress: fraction,
|
|
1710
|
+
segmentName: span?.name ?? null,
|
|
1711
|
+
slopeDeg: bandValueAt(source.slopeBands, distanceKm),
|
|
1712
|
+
speed: span?.speed ?? null,
|
|
1713
|
+
surface: bandValueAt(source.surfaceBands, distanceKm),
|
|
1714
|
+
waytype: bandValueAt(source.waytypeBands, distanceKm)
|
|
1715
|
+
};
|
|
1716
|
+
});
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1719
|
+
// src/camera/rules/planner.ts
|
|
1720
|
+
var synchronousCameraPlanner = () => ({
|
|
1721
|
+
resolveSamples: resolveProfileSamples,
|
|
1722
|
+
resolveTrack: resolveCameraTrack
|
|
1723
|
+
});
|
|
1724
|
+
var measureNames = {
|
|
1725
|
+
resolveSamples: "mountaya.camera.resolveSamples",
|
|
1726
|
+
resolveTrack: "mountaya.camera.resolveTrack"
|
|
1727
|
+
};
|
|
1728
|
+
var measuredCameraPlanner = (planner, onMeasure) => {
|
|
1729
|
+
const measure = (name, resolve) => {
|
|
1730
|
+
const started = performance.now();
|
|
1731
|
+
const result = resolve();
|
|
1732
|
+
const durationMs = performance.now() - started;
|
|
1733
|
+
performance.measure?.(name, { duration: durationMs, start: started });
|
|
1734
|
+
onMeasure?.(name, durationMs);
|
|
1735
|
+
return result;
|
|
1736
|
+
};
|
|
1737
|
+
return {
|
|
1738
|
+
resolveSamples: (plan, itinerary, source) => measure(measureNames.resolveSamples, () => planner.resolveSamples(plan, itinerary, source)),
|
|
1739
|
+
resolveTrack: (plan, itinerary, sampler, clearanceStride) => measure(
|
|
1740
|
+
measureNames.resolveTrack,
|
|
1741
|
+
() => planner.resolveTrack(plan, itinerary, sampler, clearanceStride)
|
|
1742
|
+
)
|
|
1743
|
+
};
|
|
1744
|
+
};
|
|
1745
|
+
|
|
1746
|
+
// src/camera/rules/routeContent.ts
|
|
1747
|
+
var routeContentOf = (route) => {
|
|
1748
|
+
const line = [];
|
|
1749
|
+
for (let index = 0; index < route.line.length; index += 1) {
|
|
1750
|
+
const vertex = route.line[index];
|
|
1751
|
+
line.push(vertex?.[0], vertex?.[1]);
|
|
1752
|
+
}
|
|
1753
|
+
return { elevations: [...route.elevations ?? []], jumps: [...route.jumps ?? []], line };
|
|
1754
|
+
};
|
|
1755
|
+
var holdsRouteContent = (route, content) => {
|
|
1756
|
+
const elevations = route.elevations ?? [];
|
|
1757
|
+
const jumps = route.jumps ?? [];
|
|
1758
|
+
if (route.line.length * 2 !== content.line.length || elevations.length !== content.elevations.length || jumps.length !== content.jumps.length) {
|
|
1759
|
+
return false;
|
|
1760
|
+
}
|
|
1761
|
+
for (let index = 0; index < jumps.length; index += 1) {
|
|
1762
|
+
if (!Object.is(jumps[index], content.jumps[index])) {
|
|
1763
|
+
return false;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
for (let index = 0; index < route.line.length; index += 1) {
|
|
1767
|
+
const vertex = route.line[index];
|
|
1768
|
+
if (!Object.is(vertex?.[0], content.line[index * 2]) || !Object.is(vertex?.[1], content.line[index * 2 + 1])) {
|
|
1769
|
+
return false;
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
for (let index = 0; index < elevations.length; index += 1) {
|
|
1773
|
+
if (!Object.is(elevations[index], content.elevations[index])) {
|
|
1774
|
+
return false;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return true;
|
|
1778
|
+
};
|
|
1779
|
+
var sameRouteContent = (a, b) => holdsRouteContent(a, routeContentOf(b));
|
|
1780
|
+
|
|
1781
|
+
// src/camera/rules/sweptViewports.ts
|
|
1782
|
+
var capturesSweptViewports = (swept, captured) => {
|
|
1783
|
+
if (swept.length !== captured.length) {
|
|
1784
|
+
return false;
|
|
1785
|
+
}
|
|
1786
|
+
return swept.every((pose, index) => {
|
|
1787
|
+
const frame = captured[index];
|
|
1788
|
+
return frame !== void 0 && frame.zoom === pose.zoom && frame.pitch === pose.pitch && frame.bearing === pose.bearing && frame.center[0] === pose.center[0] && frame.center[1] === pose.center[1];
|
|
1789
|
+
});
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1792
|
+
// src/camera/engines/videoFlight.ts
|
|
1793
|
+
var defaultVideoFlightProfile = {
|
|
1794
|
+
design: "graph",
|
|
1795
|
+
enabled: false,
|
|
1796
|
+
language: "en",
|
|
1797
|
+
length: "metric",
|
|
1798
|
+
pace: "per-time",
|
|
1799
|
+
slope: "degrees"
|
|
1800
|
+
};
|
|
1801
|
+
var DEFAULT_POSE_CACHE_SIZE = 4;
|
|
1802
|
+
var ROUTE_VERTICES_MIN = 2;
|
|
1803
|
+
var routeBounds = (route) => {
|
|
1804
|
+
let west = Number.POSITIVE_INFINITY;
|
|
1805
|
+
let south = Number.POSITIVE_INFINITY;
|
|
1806
|
+
let east = Number.NEGATIVE_INFINITY;
|
|
1807
|
+
let north = Number.NEGATIVE_INFINITY;
|
|
1808
|
+
for (const [lng, lat] of continuousLine(route.line)) {
|
|
1809
|
+
if (lng === void 0 || lat === void 0) {
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
west = Math.min(west, lng);
|
|
1813
|
+
south = Math.min(south, lat);
|
|
1814
|
+
east = Math.max(east, lng);
|
|
1815
|
+
north = Math.max(north, lat);
|
|
1816
|
+
}
|
|
1817
|
+
return Number.isFinite(west) ? [west, south, east, north] : null;
|
|
1818
|
+
};
|
|
1819
|
+
var flightError = (flight, cause) => errorFrom(cause, `${flight} failed.`);
|
|
1820
|
+
var poseCacheSizeFrom = (size) => {
|
|
1821
|
+
if (size === void 0) {
|
|
1822
|
+
return DEFAULT_POSE_CACHE_SIZE;
|
|
1823
|
+
}
|
|
1824
|
+
if (!Number.isInteger(size) || size < 0) {
|
|
1825
|
+
throw new MountayaElementsError(
|
|
1826
|
+
`VideoFlightEngine: poseCacheSize is ${String(size)}; pass a whole number of flights, 0 or more, or omit it for ${DEFAULT_POSE_CACHE_SIZE}.`
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
return size;
|
|
1830
|
+
};
|
|
1831
|
+
var planFrom = (plan) => {
|
|
1832
|
+
refuseUnplannablePlan("VideoFlightEngine", plan, "plan");
|
|
1833
|
+
return plan;
|
|
1834
|
+
};
|
|
1835
|
+
var couldNotStart = (result) => result.reason === "unavailable";
|
|
1836
|
+
var VideoFlightEngine = class {
|
|
1837
|
+
flight;
|
|
1838
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1839
|
+
map;
|
|
1840
|
+
planner;
|
|
1841
|
+
poseCacheSize;
|
|
1842
|
+
/**
|
|
1843
|
+
* The run in flight. One at a time: every preview and record stops the run before it as it
|
|
1844
|
+
* starts, because two flights over one map would fight for the camera.
|
|
1845
|
+
*/
|
|
1846
|
+
run = null;
|
|
1847
|
+
/**
|
|
1848
|
+
* How far through the flight a preview that {@link pause} stopped in the air had flown, which
|
|
1849
|
+
* {@link play} flies on from. Null when no flight is paused.
|
|
1850
|
+
*/
|
|
1851
|
+
pausedAt = null;
|
|
1852
|
+
/**
|
|
1853
|
+
* The memoized flights, an insertion-ordered LRU. Keyed on the pose-affecting plan fields, the
|
|
1854
|
+
* route's revision, whether this is the full-density record resolve or a decimated preview one,
|
|
1855
|
+
* and the DEM epoch, so a format-only edit collapses onto the same key and reuses the flight,
|
|
1856
|
+
* while a resolve cached against a cold DEM is dropped once the flight warm lands.
|
|
1857
|
+
*/
|
|
1858
|
+
poseCache = /* @__PURE__ */ new Map();
|
|
1859
|
+
/** Bumped when the flight terrain warms, which is what invalidates a cold-DEM resolve. */
|
|
1860
|
+
demEpoch = 0;
|
|
1861
|
+
/**
|
|
1862
|
+
* Advanced each time the route's content is read and differs from {@link routeContent}: as
|
|
1863
|
+
* {@link setRoute} is handed a route, and as a flight begins. The warm guards and the pose
|
|
1864
|
+
* cache name a route by it, so telling two routes apart costs one walk per `setRoute` and one
|
|
1865
|
+
* per flight, each ending at the first difference.
|
|
1866
|
+
*/
|
|
1867
|
+
routeRevision = 0;
|
|
1868
|
+
/** What the held route held when it was last read, or null while no route is held. */
|
|
1869
|
+
routeContent = null;
|
|
1870
|
+
/** The route revision each warm has already run for, so neither repeats. */
|
|
1871
|
+
terrainWarmedRevision = null;
|
|
1872
|
+
flightWarmedRevision = null;
|
|
1873
|
+
/** The terrain warm in progress, which a flight asked for meanwhile over the same route joins. */
|
|
1874
|
+
terrainWarm = null;
|
|
1875
|
+
/**
|
|
1876
|
+
* The flight warm in progress, shared the same way. One sweep at a time moves the camera, and
|
|
1877
|
+
* the engine holds the handle that ends it: {@link abort}, {@link dispose}, another route and
|
|
1878
|
+
* a record, which sweeps for itself, each end it.
|
|
1879
|
+
*/
|
|
1880
|
+
flightWarm = null;
|
|
1881
|
+
/**
|
|
1882
|
+
* The sweep a record makes for itself, while it is in progress. It is the flight's sweep over
|
|
1883
|
+
* that route, so a flight asked for meanwhile joins it and starts none of its own. It ends on
|
|
1884
|
+
* the record's run and on nothing else, which is why it is held apart from
|
|
1885
|
+
* {@link flightWarm}: another route set meanwhile ends a shared sweep, and leaves a record on
|
|
1886
|
+
* the route it began with.
|
|
1887
|
+
*/
|
|
1888
|
+
recordWarm = null;
|
|
1889
|
+
/**
|
|
1890
|
+
* The settling of every map call that still holds the camera: the run in flight's, and that of
|
|
1891
|
+
* each flight stopped since whose `previewPoses` or `recordPoses` has yet to settle. A seek
|
|
1892
|
+
* parks the camera once all of them have let go of it.
|
|
1893
|
+
*/
|
|
1894
|
+
landings = /* @__PURE__ */ new Set();
|
|
1895
|
+
/**
|
|
1896
|
+
* Whether a seek stopped a flight and no status has replaced the one that flight left. A
|
|
1897
|
+
* stopped flight's own exit commits nothing, so its status is settled by the seek that
|
|
1898
|
+
* stopped it or, when that seek was overtaken, by the one that parks or fails in its place.
|
|
1899
|
+
* {@link commit} clears it on every status it states.
|
|
1900
|
+
*/
|
|
1901
|
+
seekStoppedFlight = false;
|
|
1902
|
+
/** The last encoded recording, so a save does not re-encode. */
|
|
1903
|
+
lastRecording = null;
|
|
1904
|
+
/** Aborted by {@link dispose}, and the signal a seek resolves under, since it holds no run. */
|
|
1905
|
+
disposal = new AbortController();
|
|
1906
|
+
/** Whether {@link dispose} has run, read off the one signal it aborts. */
|
|
1907
|
+
get disposed() {
|
|
1908
|
+
return this.disposal.signal.aborted;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Advanced by every flight asked for, a seek included, and by {@link abort}. A seek holds no
|
|
1912
|
+
* run, so it reads this after each of its awaits to learn whether a newer preview, record or
|
|
1913
|
+
* seek was asked for since it began, or an abort, and leaves the camera alone when one was.
|
|
1914
|
+
*/
|
|
1915
|
+
flightSequence = 0;
|
|
1916
|
+
/**
|
|
1917
|
+
* @throws {MountayaElementsError} When `poseCacheSize` is not a whole number, 0 or more, when
|
|
1918
|
+
* the plan is no object, or when it holds a member no flight can be planned with.
|
|
1919
|
+
* {@link setPlan} lists them.
|
|
1920
|
+
*/
|
|
1921
|
+
constructor(options) {
|
|
1922
|
+
this.map = options.map ?? null;
|
|
1923
|
+
this.planner = options.planner ?? synchronousCameraPlanner();
|
|
1924
|
+
this.poseCacheSize = poseCacheSizeFrom(options.poseCacheSize);
|
|
1925
|
+
this.flight = {
|
|
1926
|
+
activityGlyphUrl: null,
|
|
1927
|
+
plan: planFrom(options.plan),
|
|
1928
|
+
profile: defaultVideoFlightProfile,
|
|
1929
|
+
profileSource: null,
|
|
1930
|
+
route: null,
|
|
1931
|
+
status: { kind: "idle" }
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
// -----------------------------------------------------------------------------------------
|
|
1935
|
+
// State
|
|
1936
|
+
// -----------------------------------------------------------------------------------------
|
|
1937
|
+
/**
|
|
1938
|
+
* getSnapshot returns the current flight, by reference.
|
|
1939
|
+
*
|
|
1940
|
+
* Stable between changes, deliberately: it is `useSyncExternalStore`'s second argument, and a
|
|
1941
|
+
* fresh object per call makes React's own tearing check loop forever. Every command below
|
|
1942
|
+
* replaces the object rather than mutating it, so identity IS the change signal.
|
|
1943
|
+
*/
|
|
1944
|
+
getSnapshot() {
|
|
1945
|
+
return this.flight;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* subscribe registers a listener for every change, and returns its own unsubscribe.
|
|
1949
|
+
*
|
|
1950
|
+
* A listener that throws keeps no other listener from being told and changes no command's
|
|
1951
|
+
* answer: a setter, {@link abort} and {@link reset} throw nothing, and a preview, a record or
|
|
1952
|
+
* a seek answers for the flight alone. What the listener threw is the subscribing program's
|
|
1953
|
+
* own fault, and it reaches the runtime as an uncaught error on a microtask, once per change
|
|
1954
|
+
* the listener threw at.
|
|
1955
|
+
*/
|
|
1956
|
+
subscribe(listener) {
|
|
1957
|
+
this.listeners.add(listener);
|
|
1958
|
+
return () => {
|
|
1959
|
+
this.listeners.delete(listener);
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
/** The last encoded recording, or null. Held so a save does not re-encode what was just made. */
|
|
1963
|
+
get recording() {
|
|
1964
|
+
return this.lastRecording;
|
|
1965
|
+
}
|
|
1966
|
+
// -----------------------------------------------------------------------------------------
|
|
1967
|
+
// Commands
|
|
1968
|
+
// -----------------------------------------------------------------------------------------
|
|
1969
|
+
/**
|
|
1970
|
+
* setPlan replaces the plan. Does not abort a run: a plan edit mid-preview takes on the next.
|
|
1971
|
+
*
|
|
1972
|
+
* @throws {MountayaElementsError} Naming `plan`, when it is no object. Naming the member,
|
|
1973
|
+
* when `output` is no object, `shots` no array or an entry of `shots` no object, when
|
|
1974
|
+
* `version` is not 1, when `targetDurationMs` is
|
|
1975
|
+
* not a finite number above 0, when `output.fps` is not 24, 30 or 60, when a stated
|
|
1976
|
+
* `output.bitrateMbps` is not a finite number above 0, or when a shot holds a number that is
|
|
1977
|
+
* not finite, a `holdMs` below 0 or a `speedScale` at or below 0: what `createCameraPlan`
|
|
1978
|
+
* refuses, by the same rule. The plan the engine held stands.
|
|
1979
|
+
*/
|
|
1980
|
+
setPlan(plan) {
|
|
1981
|
+
this.commit({ plan: planFrom(plan) });
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* setRoute anchors the flight to a route, and resets both warm guards when it changes.
|
|
1985
|
+
*
|
|
1986
|
+
* Reset on CONTENT, so a re-supplied identical route keeps its warms. A different route has
|
|
1987
|
+
* different terrain under it and different tiles to settle, so neither warm carries over, and
|
|
1988
|
+
* a flight warm still sweeping the route before it ends at its next stop.
|
|
1989
|
+
*
|
|
1990
|
+
* The route is held as the object it is given, never copied for a reader, and its content is
|
|
1991
|
+
* read here and again as each preview, record and seek begins. So a route edited in place (a
|
|
1992
|
+
* track that grows by a push) is flown as it stands when the next flight is asked for, with
|
|
1993
|
+
* its warms run again, whether or not it is handed over a second time.
|
|
1994
|
+
*
|
|
1995
|
+
* A line of fewer than two vertices is held as it is given and flown as no route: every run
|
|
1996
|
+
* over it answers `no-route`.
|
|
1997
|
+
*
|
|
1998
|
+
* Another route stops a preview flying the one before it, and lands a `previewing` or a
|
|
1999
|
+
* `parked` status on idle: the camera would fly, or rest on, a route the engine has let go
|
|
2000
|
+
* of, under a status that says otherwise. It forgets a paused flight as well, so the next
|
|
2001
|
+
* {@link play} flies the route that arrived from its first frame. A preview still in its
|
|
2002
|
+
* warm-up flies the route that arrived, and a record flies the route it began with.
|
|
2003
|
+
*/
|
|
2004
|
+
setRoute(route) {
|
|
2005
|
+
const content = this.routeContent;
|
|
2006
|
+
const changed = route === null || content === null ? route === null !== (content === null) : !holdsRouteContent(route, content);
|
|
2007
|
+
if (!changed) {
|
|
2008
|
+
this.commit({ route });
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
this.routeChanged(route);
|
|
2012
|
+
const status = this.flight.status.kind;
|
|
2013
|
+
if (status !== "previewing" && status !== "parked") {
|
|
2014
|
+
this.commit({ route });
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
if (status === "previewing" && this.run?.kind === "preview" && this.run.flying) {
|
|
2018
|
+
this.run.controller.abort();
|
|
2019
|
+
this.run = null;
|
|
2020
|
+
}
|
|
2021
|
+
this.commit({ route, status: { kind: "idle" } });
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* setProfile merges a partial overlay update over the current one.
|
|
2025
|
+
*
|
|
2026
|
+
* A merge rather than a replacement, because every caller changes one field (the enable flag, a
|
|
2027
|
+
* unit, the design), and a replacement would make each of those restate the others.
|
|
2028
|
+
*/
|
|
2029
|
+
setProfile(profile) {
|
|
2030
|
+
this.commit({ profile: { ...this.flight.profile, ...profile } });
|
|
2031
|
+
}
|
|
2032
|
+
/** setProfileSource sets where the overlay's per-frame readouts are resolved from. */
|
|
2033
|
+
setProfileSource(profileSource) {
|
|
2034
|
+
this.commit({ profileSource });
|
|
2035
|
+
}
|
|
2036
|
+
/** setActivityGlyph sets the silhouette the moving focus dot masks, or null for a plain disc. */
|
|
2037
|
+
setActivityGlyph(activityGlyphUrl) {
|
|
2038
|
+
this.commit({ activityGlyphUrl });
|
|
2039
|
+
}
|
|
2040
|
+
// -----------------------------------------------------------------------------------------
|
|
2041
|
+
// Running
|
|
2042
|
+
// -----------------------------------------------------------------------------------------
|
|
2043
|
+
/**
|
|
2044
|
+
* preview flies the plan live over the map from its first frame, encoding nothing, and reports
|
|
2045
|
+
* progress. It forgets a flight {@link pause} stopped.
|
|
2046
|
+
*
|
|
2047
|
+
* Paced to the plan's own wall-clock so the rehearsal runs at the speed the recording will and
|
|
2048
|
+
* dwells on holds: a preview that ran at frame rate would mislead about both.
|
|
2049
|
+
*
|
|
2050
|
+
* The run opens before the two warms rather than after them. Both warms move the camera and can
|
|
2051
|
+
* take seconds on a cold cache, which is when a caller reaches for {@link pause}: a run opened
|
|
2052
|
+
* after them would leave a pause, an abort, a dispose or a newer flight during the warm with
|
|
2053
|
+
* nothing to stop, and the fly would start anyway. A stop there answers `aborted`, starts no
|
|
2054
|
+
* further warm and flies no frame.
|
|
2055
|
+
*
|
|
2056
|
+
* The flight is of the plan and the route the engine holds once both warms have settled. A
|
|
2057
|
+
* route set during a warm is warmed in turn, the DEM over its bounds and then its viewports,
|
|
2058
|
+
* before any pose is resolved over it.
|
|
2059
|
+
*
|
|
2060
|
+
* It never rejects. A map or a planner that throws answers `failed` with the error it stopped
|
|
2061
|
+
* on. A throw that follows a stop answers `aborted`, because the caller asked the run to
|
|
2062
|
+
* stop. A subscriber that throws changes neither ({@link subscribe}). Every exit ends the run
|
|
2063
|
+
* and lands on idle unless a newer one holds it by then.
|
|
2064
|
+
*/
|
|
2065
|
+
preview() {
|
|
2066
|
+
return this.startPreview(false);
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* play flies the plan on from where a flight was stopped, as {@link preview} flies it.
|
|
2070
|
+
*
|
|
2071
|
+
* It resumes a preview {@link pause} stopped in the air, from the frame nearest where it was and
|
|
2072
|
+
* over the rest of the plan's wall-clock. Over a `parked` status it flies on from the frame
|
|
2073
|
+
* {@link seek} parked the camera on, as a player plays on from where its reader put the head.
|
|
2074
|
+
* It flies from the first frame when there is neither, and when nothing is left to fly past the
|
|
2075
|
+
* frame it would start on. A play stopped in its warm-up flies nothing, and keeps where it was
|
|
2076
|
+
* to fly on from for the next one.
|
|
2077
|
+
*/
|
|
2078
|
+
play() {
|
|
2079
|
+
return this.startPreview(true);
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* startPreview is {@link preview} and {@link play}: it opens the run, reads where the flight
|
|
2083
|
+
* flies on from, and answers what the fly settled on.
|
|
2084
|
+
*/
|
|
2085
|
+
async startPreview(resume) {
|
|
2086
|
+
const map = this.map;
|
|
2087
|
+
if (!map) {
|
|
2088
|
+
return { ok: false, reason: "no-map" };
|
|
2089
|
+
}
|
|
2090
|
+
const run = this.beginRun("preview");
|
|
2091
|
+
if (run.signal.aborted) {
|
|
2092
|
+
return { ok: false, reason: "aborted" };
|
|
2093
|
+
}
|
|
2094
|
+
this.readRoute();
|
|
2095
|
+
const status = this.flight.status;
|
|
2096
|
+
if (!resume) {
|
|
2097
|
+
this.pausedAt = null;
|
|
2098
|
+
} else if (this.pausedAt === null && status.kind === "parked") {
|
|
2099
|
+
this.pausedAt = status.fraction;
|
|
2100
|
+
}
|
|
2101
|
+
let outcome;
|
|
2102
|
+
try {
|
|
2103
|
+
outcome = await this.flyPreview(map, run);
|
|
2104
|
+
} catch (cause) {
|
|
2105
|
+
outcome = run.signal.aborted ? { ok: false, reason: "aborted" } : { error: flightError("Preview", cause), ok: false, reason: "failed" };
|
|
2106
|
+
}
|
|
2107
|
+
return this.endRun(run, outcome);
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* flyPreview is {@link preview} and {@link play} from their first warm to the end of their
|
|
2111
|
+
* fly, under the run they opened. It throws what the map or the planner threw, which they
|
|
2112
|
+
* answer.
|
|
2113
|
+
*/
|
|
2114
|
+
async flyPreview(map, run) {
|
|
2115
|
+
await this.warmRoute(() => run.signal.aborted);
|
|
2116
|
+
if (run.signal.aborted) {
|
|
2117
|
+
return { ok: false, reason: "aborted" };
|
|
2118
|
+
}
|
|
2119
|
+
const resolved = await this.resolve({ pass: "preview", signal: run.signal });
|
|
2120
|
+
if (run.signal.aborted) {
|
|
2121
|
+
return { ok: false, reason: "aborted" };
|
|
2122
|
+
}
|
|
2123
|
+
if (!resolved) {
|
|
2124
|
+
return { ok: false, reason: "no-route" };
|
|
2125
|
+
}
|
|
2126
|
+
const lastIndex = Math.max(0, resolved.poses.length - 1);
|
|
2127
|
+
const resumeAt = Math.min(lastIndex, Math.round((this.pausedAt ?? 0) * lastIndex));
|
|
2128
|
+
const from = resumeAt === lastIndex ? 0 : resumeAt;
|
|
2129
|
+
const startFraction = lastIndex === 0 ? 0 : from / lastIndex;
|
|
2130
|
+
this.pausedAt = null;
|
|
2131
|
+
run.flying = true;
|
|
2132
|
+
this.commit({ status: { fraction: startFraction, kind: "previewing" } });
|
|
2133
|
+
await this.fly(
|
|
2134
|
+
map.previewPoses(from === 0 ? resolved.poses : resolved.poses.slice(from), {
|
|
2135
|
+
...this.flight.activityGlyphUrl === null ? {} : { focusGlyphUrl: this.flight.activityGlyphUrl },
|
|
2136
|
+
markers: from === 0 ? resolved.markers : resolved.markers.slice(from),
|
|
2137
|
+
onProgress: (progress) => {
|
|
2138
|
+
if (this.run === run) {
|
|
2139
|
+
this.commit({
|
|
2140
|
+
status: {
|
|
2141
|
+
fraction: startFraction + progress.fraction * (1 - startFraction),
|
|
2142
|
+
kind: "previewing"
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
},
|
|
2147
|
+
planDurationMs: resolved.planDurationMs * (1 - startFraction),
|
|
2148
|
+
signal: run.signal
|
|
2149
|
+
})
|
|
2150
|
+
);
|
|
2151
|
+
return run.signal.aborted ? { ok: false, reason: "aborted" } : { ok: true };
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* record captures one frame per pose and encodes them, reporting progress with its phase.
|
|
2155
|
+
*
|
|
2156
|
+
* Resolved at full density (stride 1), where a preview resolves at the decimated clearance
|
|
2157
|
+
* stride, so the artifact is what the plan describes rather than what was cheap to rehearse.
|
|
2158
|
+
*
|
|
2159
|
+
* The run opens before the terrain warm, for the reason {@link preview} gives, and the flight
|
|
2160
|
+
* warm inside the resolve takes its signal: a stop, an abort or a dispose during either warm
|
|
2161
|
+
* answers `aborted`, starts no further warm and captures no frame. Over a route a flight can
|
|
2162
|
+
* follow, the status reads `recording` in its `preparing` phase from the moment the run opens,
|
|
2163
|
+
* so a reader sees the press land while the terrain warms.
|
|
2164
|
+
*
|
|
2165
|
+
* A run stopped before the recorder answers keeps nothing: it answers `aborted`, whatever the
|
|
2166
|
+
* map resolved, since a recorder a host supplies may finish a file after its signal aborted.
|
|
2167
|
+
*
|
|
2168
|
+
* It never rejects. A recorder that fails, or a map or planner that throws on the way to the
|
|
2169
|
+
* first frame, answers `failed` with the error it stopped on, and a throw that follows an abort
|
|
2170
|
+
* answers `aborted`, because the caller asked the run to stop. A subscriber that throws
|
|
2171
|
+
* changes neither ({@link subscribe}). A recording
|
|
2172
|
+
* the map could not start answers `unavailable`, which is no cancel: the result states
|
|
2173
|
+
* `reason: "unavailable"` beside its `cancelled`. Every exit ends the run and lands on idle
|
|
2174
|
+
* unless a newer run holds it by then, so a caller holding a recording state always has an
|
|
2175
|
+
* outcome to settle it on.
|
|
2176
|
+
*
|
|
2177
|
+
* The record flies the plan and the route it began with. One set while it warms takes on the
|
|
2178
|
+
* next flight, so the poses, the encoder's output and the overlay's samples stay those of one
|
|
2179
|
+
* plan. Whether its frames carry the Mountaya watermark is the map's organization's to answer,
|
|
2180
|
+
* read as the capture begins: no member of the engine takes the mark off.
|
|
2181
|
+
*/
|
|
2182
|
+
async record() {
|
|
2183
|
+
const map = this.map;
|
|
2184
|
+
if (!map) {
|
|
2185
|
+
return { ok: false, reason: "no-map" };
|
|
2186
|
+
}
|
|
2187
|
+
const run = this.beginRun("record");
|
|
2188
|
+
if (run.signal.aborted) {
|
|
2189
|
+
return { ok: false, reason: "aborted" };
|
|
2190
|
+
}
|
|
2191
|
+
this.readRoute();
|
|
2192
|
+
this.endFlightWarm();
|
|
2193
|
+
if (this.flyableRoute()) {
|
|
2194
|
+
this.commit({ status: { fraction: 0, kind: "recording", phase: "preparing" } });
|
|
2195
|
+
}
|
|
2196
|
+
let outcome;
|
|
2197
|
+
try {
|
|
2198
|
+
outcome = await this.flyRecording(map, run);
|
|
2199
|
+
} catch (cause) {
|
|
2200
|
+
outcome = run.signal.aborted ? { ok: false, reason: "aborted" } : { error: flightError("Recording", cause), ok: false, reason: "failed" };
|
|
2201
|
+
}
|
|
2202
|
+
return this.endRun(run, outcome);
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* flyRecording is {@link record} from its terrain warm to the recorder's answer, under the run
|
|
2206
|
+
* it opened. It throws what the map or the planner threw, which `record` answers.
|
|
2207
|
+
*/
|
|
2208
|
+
async flyRecording(map, run) {
|
|
2209
|
+
if (run.signal.aborted) {
|
|
2210
|
+
return { ok: false, reason: "aborted" };
|
|
2211
|
+
}
|
|
2212
|
+
await this.prewarmRoute();
|
|
2213
|
+
if (run.signal.aborted) {
|
|
2214
|
+
return { ok: false, reason: "aborted" };
|
|
2215
|
+
}
|
|
2216
|
+
let swept = false;
|
|
2217
|
+
const resolved = await this.resolve({
|
|
2218
|
+
onSwept: () => {
|
|
2219
|
+
swept = true;
|
|
2220
|
+
},
|
|
2221
|
+
pass: "record",
|
|
2222
|
+
signal: run.signal
|
|
2223
|
+
});
|
|
2224
|
+
if (run.signal.aborted) {
|
|
2225
|
+
return { ok: false, reason: "aborted" };
|
|
2226
|
+
}
|
|
2227
|
+
if (!resolved) {
|
|
2228
|
+
return { ok: false, reason: "no-route" };
|
|
2229
|
+
}
|
|
2230
|
+
const profile = this.recordProfile(resolved);
|
|
2231
|
+
const result = await this.fly(
|
|
2232
|
+
map.recordPoses(resolved.poses, resolved.plan.output, {
|
|
2233
|
+
...this.flight.activityGlyphUrl === null ? {} : { focusGlyphUrl: this.flight.activityGlyphUrl },
|
|
2234
|
+
markers: resolved.markers,
|
|
2235
|
+
onProgress: (progress) => {
|
|
2236
|
+
if (this.run === run) {
|
|
2237
|
+
this.commit({
|
|
2238
|
+
status: { fraction: progress.fraction, kind: "recording", phase: progress.phase }
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
},
|
|
2242
|
+
...profile === void 0 ? {} : { profile },
|
|
2243
|
+
signal: run.signal,
|
|
2244
|
+
...swept ? { warmed: true } : {}
|
|
2245
|
+
})
|
|
2246
|
+
);
|
|
2247
|
+
if (run.signal.aborted) {
|
|
2248
|
+
return { ok: false, reason: "aborted" };
|
|
2249
|
+
}
|
|
2250
|
+
if (result.error !== void 0) {
|
|
2251
|
+
return { error: result.error, ok: false, reason: "failed" };
|
|
2252
|
+
}
|
|
2253
|
+
if (couldNotStart(result)) {
|
|
2254
|
+
return { ok: false, reason: "unavailable" };
|
|
2255
|
+
}
|
|
2256
|
+
if (result.cancelled) {
|
|
2257
|
+
return { ok: false, reason: "aborted" };
|
|
2258
|
+
}
|
|
2259
|
+
if (!result.blob) {
|
|
2260
|
+
return { ok: false, reason: "no-frames" };
|
|
2261
|
+
}
|
|
2262
|
+
this.lastRecording = { blob: result.blob, extension: result.extension };
|
|
2263
|
+
return { blob: result.blob, extension: result.extension, ok: true };
|
|
2264
|
+
}
|
|
2265
|
+
/**
|
|
2266
|
+
* seek parks the camera on the pose the flight is at, a fraction of the way through.
|
|
2267
|
+
*
|
|
2268
|
+
* It aborts any live fly first (a seek that did not would be overwritten by the next preview
|
|
2269
|
+
* frame), resolves the flight, and jumps to the nearest frame's FULL pose. The status is left
|
|
2270
|
+
* reading `parked` at the requested fraction rather than idle, because that is what a
|
|
2271
|
+
* scrubber reads to position itself: the camera is parked mid-flight, not stopped.
|
|
2272
|
+
*
|
|
2273
|
+
* The pose is of the plan and the route the engine holds as the camera lands. One set while
|
|
2274
|
+
* the seek waits, on a warm or on a stopped flight that still holds the camera, is warmed and
|
|
2275
|
+
* resolved before the seek parks.
|
|
2276
|
+
*
|
|
2277
|
+
* The fraction is clamped rather than validated, so a scrubber dragged past its own track is a
|
|
2278
|
+
* camera at an endpoint instead of a failure a UI has to render. A fraction that is no number
|
|
2279
|
+
* (`NaN`, or a value of another type from a caller the compiler does not check) has no end to
|
|
2280
|
+
* clamp to: the seek answers `failed` and touches nothing.
|
|
2281
|
+
*
|
|
2282
|
+
* A seek waits on the warms like any flight and starts neither twice: one asked for while a
|
|
2283
|
+
* warm over the same route is in progress joins it, so a scrubber dragged on a cold route sweeps
|
|
2284
|
+
* the camera once. A {@link pause} or a {@link stop} takes no camera, so a seek in its warm-up
|
|
2285
|
+
* goes on to park, and the sweep it waits on goes on with it. A seek that parks forgets a
|
|
2286
|
+
* paused flight: the next {@link play} flies on from the frame it parked on.
|
|
2287
|
+
*
|
|
2288
|
+
* A stopped flight lets go of the camera before the seek parks it, whoever stopped it: this
|
|
2289
|
+
* seek, a seek before it, an {@link abort} or a newer flight. The seek waits for the map's
|
|
2290
|
+
* `previewPoses` or `recordPoses` to settle on the aborted signal, because a run restores the
|
|
2291
|
+
* camera it found as it settles, which for a record is once the frame in flight has ended, and
|
|
2292
|
+
* that restore would land on top of the parked pose.
|
|
2293
|
+
*
|
|
2294
|
+
* A seek after {@link dispose}, or one whose warms a dispose overtook, answers `aborted` and
|
|
2295
|
+
* leaves the camera where it is: a disposed engine does not move the map it let go of. A dispose
|
|
2296
|
+
* during the terrain warm starts no flight warm, and one during the flight warm ends its sweep
|
|
2297
|
+
* at the next stop, as an {@link abort} does. A seek a newer preview, record or seek overtook
|
|
2298
|
+
* during its warms answers `aborted` as well and leaves the camera to the newer one, so a scrub
|
|
2299
|
+
* that lands late never aborts a flight asked for after it, nor parks the camera over a later
|
|
2300
|
+
* scrub.
|
|
2301
|
+
*
|
|
2302
|
+
* It never rejects. A map or a planner that throws answers `failed` with the error it stopped
|
|
2303
|
+
* on and leaves the status as it was, or on idle when a seek had stopped a flight whose status
|
|
2304
|
+
* nothing had replaced: this seek, or one it overtook before that one parked. A seek that
|
|
2305
|
+
* answers `no-route` settles such a status the same way. A subscriber that throws changes
|
|
2306
|
+
* none of it ({@link subscribe}).
|
|
2307
|
+
*/
|
|
2308
|
+
async seek(fraction) {
|
|
2309
|
+
const map = this.map;
|
|
2310
|
+
if (!map) {
|
|
2311
|
+
return { ok: false, reason: "no-map" };
|
|
2312
|
+
}
|
|
2313
|
+
if (this.disposed) {
|
|
2314
|
+
return { ok: false, reason: "aborted" };
|
|
2315
|
+
}
|
|
2316
|
+
if (typeof fraction !== "number" || Number.isNaN(fraction)) {
|
|
2317
|
+
return {
|
|
2318
|
+
error: new MountayaElementsError(
|
|
2319
|
+
`VideoFlightEngine: seek's fraction is ${String(fraction)}; pass a number, which is held between 0 and 1.`
|
|
2320
|
+
),
|
|
2321
|
+
ok: false,
|
|
2322
|
+
reason: "failed"
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
this.readRoute();
|
|
2326
|
+
this.flightSequence += 1;
|
|
2327
|
+
const sequence = this.flightSequence;
|
|
2328
|
+
const overtaken = () => this.disposed || this.flightSequence !== sequence;
|
|
2329
|
+
let outcome;
|
|
2330
|
+
try {
|
|
2331
|
+
outcome = await this.park(map, fraction, overtaken);
|
|
2332
|
+
} catch (cause) {
|
|
2333
|
+
outcome = overtaken() ? { ok: false, reason: "aborted" } : { error: flightError("Seek", cause), ok: false, reason: "failed" };
|
|
2334
|
+
}
|
|
2335
|
+
if (outcome.ok || overtaken() || !this.seekStoppedFlight) {
|
|
2336
|
+
return outcome;
|
|
2337
|
+
}
|
|
2338
|
+
return this.land(outcome);
|
|
2339
|
+
}
|
|
2340
|
+
/**
|
|
2341
|
+
* park is {@link seek} from its first warm to the pose it lands on. `overtaken` answers
|
|
2342
|
+
* whether a dispose, an abort or a newer flight has taken the camera since the seek began. It
|
|
2343
|
+
* throws what the map or the planner threw, which `seek` answers.
|
|
2344
|
+
*/
|
|
2345
|
+
async park(map, fraction, overtaken) {
|
|
2346
|
+
for (; ; ) {
|
|
2347
|
+
await this.warmRoute(overtaken);
|
|
2348
|
+
if (overtaken()) {
|
|
2349
|
+
return { ok: false, reason: "aborted" };
|
|
2350
|
+
}
|
|
2351
|
+
const plan = this.flight.plan;
|
|
2352
|
+
const revision = this.routeRevision;
|
|
2353
|
+
const resolved = await this.resolve({ pass: "preview", signal: this.disposal.signal });
|
|
2354
|
+
if (overtaken()) {
|
|
2355
|
+
return { ok: false, reason: "aborted" };
|
|
2356
|
+
}
|
|
2357
|
+
if (!resolved) {
|
|
2358
|
+
return { ok: false, reason: "no-route" };
|
|
2359
|
+
}
|
|
2360
|
+
if (this.run) {
|
|
2361
|
+
this.run.controller.abort();
|
|
2362
|
+
this.run = null;
|
|
2363
|
+
this.seekStoppedFlight ||= this.flight.status.kind !== "idle";
|
|
2364
|
+
}
|
|
2365
|
+
this.pausedAt = null;
|
|
2366
|
+
if (this.landings.size > 0) {
|
|
2367
|
+
await Promise.all(this.landings);
|
|
2368
|
+
if (overtaken()) {
|
|
2369
|
+
return { ok: false, reason: "aborted" };
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
this.readRoute();
|
|
2373
|
+
if (plan !== this.flight.plan || revision !== this.routeRevision) {
|
|
2374
|
+
continue;
|
|
2375
|
+
}
|
|
2376
|
+
const at = Math.min(1, Math.max(0, fraction));
|
|
2377
|
+
const pose = resolved.poses[Math.round(at * Math.max(0, resolved.poses.length - 1))];
|
|
2378
|
+
if (pose) {
|
|
2379
|
+
map.jumpToPose(pose);
|
|
2380
|
+
}
|
|
2381
|
+
this.commit({ status: { fraction: at, kind: "parked" } });
|
|
2382
|
+
return { ok: true };
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* invalidatePoses drops the memoized flights without touching the terrain warms.
|
|
2387
|
+
*
|
|
2388
|
+
* What a PLAN edit needs, and the distinction from {@link reset} is the expensive half: a new
|
|
2389
|
+
* plan resolves to different poses over the same ground, so the pose cache is stale and the
|
|
2390
|
+
* warms are not. Clearing both would re-run a visible multi-second camera sweep on every shot
|
|
2391
|
+
* nudge.
|
|
2392
|
+
*/
|
|
2393
|
+
invalidatePoses() {
|
|
2394
|
+
this.poseCache.clear();
|
|
2395
|
+
}
|
|
2396
|
+
/**
|
|
2397
|
+
* reset returns the engine to the state a fresh session starts in: no run, no caches, no
|
|
2398
|
+
* warms, no recording, no paused flight, status idle. The plan and the route are left alone:
|
|
2399
|
+
* a caller that wants those changed says so.
|
|
2400
|
+
*
|
|
2401
|
+
* It throws nothing, whatever a subscriber throws as the idle is announced
|
|
2402
|
+
* ({@link subscribe}).
|
|
2403
|
+
*/
|
|
2404
|
+
reset() {
|
|
2405
|
+
this.abort();
|
|
2406
|
+
this.poseCache.clear();
|
|
2407
|
+
this.terrainWarmedRevision = null;
|
|
2408
|
+
this.flightWarmedRevision = null;
|
|
2409
|
+
this.demEpoch = 0;
|
|
2410
|
+
this.lastRecording = null;
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* pause stops the run in flight and lands on idle, remembering how far a preview in the air
|
|
2414
|
+
* had flown, which {@link play} flies on from.
|
|
2415
|
+
*
|
|
2416
|
+
* A preview stopped in its warm-up had flown nothing, so the flight paused before it stays
|
|
2417
|
+
* paused. It takes no camera: a {@link seek} in its warm-up goes on to park, and a flight warm
|
|
2418
|
+
* it waits on goes on sweeping. A sweep only stopped flights wait on ends at its next stop.
|
|
2419
|
+
* With nothing running it lands a `parked` status on idle. Idempotent.
|
|
2420
|
+
*/
|
|
2421
|
+
pause() {
|
|
2422
|
+
const status = this.flight.status;
|
|
2423
|
+
if (this.run?.kind === "preview" && this.run.flying && status.kind === "previewing" && Number.isFinite(status.fraction)) {
|
|
2424
|
+
this.pausedAt = Math.min(1, Math.max(0, status.fraction));
|
|
2425
|
+
}
|
|
2426
|
+
this.stopRun();
|
|
2427
|
+
}
|
|
2428
|
+
/**
|
|
2429
|
+
* stop stops the run in flight, forgets a paused flight and lands on idle, and answers which
|
|
2430
|
+
* run it stopped: `"preview"` for a preview or a play in the air or in its warm-up,
|
|
2431
|
+
* `"record"` for a recording, and null when nothing was running.
|
|
2432
|
+
*
|
|
2433
|
+
* Like {@link pause} it takes no camera: a {@link seek} in its warm-up goes on to park. The run
|
|
2434
|
+
* a stop ends answers `aborted`. Idempotent, and safe with nothing running.
|
|
2435
|
+
*/
|
|
2436
|
+
stop() {
|
|
2437
|
+
const stopped = this.run?.kind ?? null;
|
|
2438
|
+
this.pausedAt = null;
|
|
2439
|
+
this.stopRun();
|
|
2440
|
+
return stopped;
|
|
2441
|
+
}
|
|
2442
|
+
/**
|
|
2443
|
+
* abort stops whatever is running, a seek in its warm-up included, forgets a paused flight and
|
|
2444
|
+
* lands on idle.
|
|
2445
|
+
*
|
|
2446
|
+
* Idempotent, and safe with nothing running, which is what lets a UI wire it to a close button
|
|
2447
|
+
* and an unmount without either of them checking first.
|
|
2448
|
+
*
|
|
2449
|
+
* A seek still in its warm-up holds no run, so the abort overtakes it the way a newer flight
|
|
2450
|
+
* does: it answers `aborted` when its warm settles and parks no camera. A flight warm in
|
|
2451
|
+
* progress ends its sweep at the next stop, whichever flight began it.
|
|
2452
|
+
*/
|
|
2453
|
+
abort() {
|
|
2454
|
+
this.flightSequence += 1;
|
|
2455
|
+
this.endFlightWarm();
|
|
2456
|
+
this.pausedAt = null;
|
|
2457
|
+
if (this.run) {
|
|
2458
|
+
this.run.controller.abort();
|
|
2459
|
+
this.run = null;
|
|
2460
|
+
}
|
|
2461
|
+
if (this.flight.status.kind !== "idle") {
|
|
2462
|
+
this.commit({ status: { kind: "idle" } });
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
/**
|
|
2466
|
+
* dispose aborts the run, drops every listener and forgets the caches.
|
|
2467
|
+
*
|
|
2468
|
+
* Idempotent. It does NOT dispose the map: the engine was handed one and does not own it,
|
|
2469
|
+
* which is the same one-way dependency `VideoRunEngine` keeps. For the same reason it starts
|
|
2470
|
+
* nothing on the map after it: a warm in progress holds a signal this aborts, which ends its
|
|
2471
|
+
* sweep at the next stop, and a preview, record or seek still in its warm-up, or asked for
|
|
2472
|
+
* later, answers `aborted` without warming again, flying, capturing or parking the camera.
|
|
2473
|
+
*
|
|
2474
|
+
* A disposed engine keeps the snapshot it showed. Nothing is announced after a dispose, so a
|
|
2475
|
+
* reader that still holds the engine reads the status it last saw, a flight in progress
|
|
2476
|
+
* included, and no later command changes it.
|
|
2477
|
+
*/
|
|
2478
|
+
dispose() {
|
|
2479
|
+
if (this.disposed) {
|
|
2480
|
+
return;
|
|
2481
|
+
}
|
|
2482
|
+
this.disposal.abort();
|
|
2483
|
+
this.abort();
|
|
2484
|
+
this.listeners.clear();
|
|
2485
|
+
this.poseCache.clear();
|
|
2486
|
+
this.lastRecording = null;
|
|
2487
|
+
}
|
|
2488
|
+
// -----------------------------------------------------------------------------------------
|
|
2489
|
+
// Internals
|
|
2490
|
+
// -----------------------------------------------------------------------------------------
|
|
2491
|
+
/**
|
|
2492
|
+
* commit replaces the snapshot and announces it. A no-op after dispose.
|
|
2493
|
+
*
|
|
2494
|
+
* It never throws. Every listener is told through {@link notifyListeners}, one that throws
|
|
2495
|
+
* included, and the first thing a listener threw is surfaced once they all have been, so no
|
|
2496
|
+
* command has to decide what a listener's exception does to a flight. The snapshot is replaced
|
|
2497
|
+
* before anyone is told, so what a later reader holds is the change, whatever a listener did
|
|
2498
|
+
* with it.
|
|
2499
|
+
*/
|
|
2500
|
+
commit(patch) {
|
|
2501
|
+
if (this.disposed) {
|
|
2502
|
+
return;
|
|
2503
|
+
}
|
|
2504
|
+
this.flight = { ...this.flight, ...patch };
|
|
2505
|
+
if (patch.status !== void 0) {
|
|
2506
|
+
this.seekStoppedFlight = false;
|
|
2507
|
+
}
|
|
2508
|
+
notifyListeners(this.listeners);
|
|
2509
|
+
}
|
|
2510
|
+
/**
|
|
2511
|
+
* beginRun opens the one run a flight holds, aborting the one before it, and advances the
|
|
2512
|
+
* {@link flightSequence} a seek in its warm-up reads.
|
|
2513
|
+
*
|
|
2514
|
+
* After {@link dispose} the run is born aborted and is not held, so every entry point answers
|
|
2515
|
+
* `aborted` before it touches the map: a disposed engine was handed its map and let go of it.
|
|
2516
|
+
*/
|
|
2517
|
+
beginRun(kind) {
|
|
2518
|
+
const controller = new AbortController();
|
|
2519
|
+
const run = { controller, flying: false, kind, signal: controller.signal };
|
|
2520
|
+
if (this.disposed) {
|
|
2521
|
+
controller.abort();
|
|
2522
|
+
return run;
|
|
2523
|
+
}
|
|
2524
|
+
this.flightSequence += 1;
|
|
2525
|
+
this.run?.controller.abort();
|
|
2526
|
+
this.run = run;
|
|
2527
|
+
return run;
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* stopRun is {@link pause} and {@link stop} past what each remembers: it stops the run in
|
|
2531
|
+
* flight, ends a flight warm only stopped flights wait on, and lands on idle. It advances no
|
|
2532
|
+
* {@link flightSequence}, so a seek in its warm-up goes on to park.
|
|
2533
|
+
*/
|
|
2534
|
+
stopRun() {
|
|
2535
|
+
if (this.run) {
|
|
2536
|
+
this.run.controller.abort();
|
|
2537
|
+
this.run = null;
|
|
2538
|
+
}
|
|
2539
|
+
const warm = this.flightWarm;
|
|
2540
|
+
if (warm && [...warm.waiters].every((stopped) => stopped())) {
|
|
2541
|
+
this.endFlightWarm();
|
|
2542
|
+
}
|
|
2543
|
+
if (this.flight.status.kind !== "idle") {
|
|
2544
|
+
this.commit({ status: { kind: "idle" } });
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* endRun lands on idle unless a newer run has already replaced this one, and answers the
|
|
2549
|
+
* outcome the run settled on, as {@link land} reads it.
|
|
2550
|
+
*/
|
|
2551
|
+
endRun(run, outcome) {
|
|
2552
|
+
if (this.run !== run) {
|
|
2553
|
+
return outcome;
|
|
2554
|
+
}
|
|
2555
|
+
this.run = null;
|
|
2556
|
+
return this.land(outcome);
|
|
2557
|
+
}
|
|
2558
|
+
/** land commits idle and answers the outcome the flight settled on. */
|
|
2559
|
+
land(outcome) {
|
|
2560
|
+
this.commit({ status: { kind: "idle" } });
|
|
2561
|
+
return outcome;
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* routeChanged names a route whose content differs from the one last read: it keeps the new
|
|
2565
|
+
* content, advances the revision the warms and the pose cache are keyed on, ends a flight warm
|
|
2566
|
+
* still sweeping the content before it, and forgets a flight paused over it.
|
|
2567
|
+
*/
|
|
2568
|
+
routeChanged(route) {
|
|
2569
|
+
this.routeContent = route === null ? null : routeContentOf(route);
|
|
2570
|
+
this.routeRevision += 1;
|
|
2571
|
+
this.endFlightWarm();
|
|
2572
|
+
this.poseCache.clear();
|
|
2573
|
+
this.pausedAt = null;
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
* readRoute reads the held route against the content it held when it was last read, as a
|
|
2577
|
+
* flight begins: the route is the caller's own object, and one edited in place since is
|
|
2578
|
+
* another route. One walk that ends at the first difference, small beside a resolve.
|
|
2579
|
+
*/
|
|
2580
|
+
readRoute() {
|
|
2581
|
+
const route = this.flight.route;
|
|
2582
|
+
if (route !== null && this.routeContent !== null && !holdsRouteContent(route, this.routeContent)) {
|
|
2583
|
+
this.routeChanged(route);
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
/**
|
|
2587
|
+
* endFlightWarm ends the flight warm in progress at its next stop, and lets go of it so a flight
|
|
2588
|
+
* asked for afterwards sweeps for itself and does not wait on a sweep that is ending.
|
|
2589
|
+
*/
|
|
2590
|
+
endFlightWarm() {
|
|
2591
|
+
this.flightWarm?.controller.abort();
|
|
2592
|
+
this.flightWarm = null;
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* fly awaits a map call that holds the camera, keeping its settling among the
|
|
2596
|
+
* {@link landings} until it has settled, a stop of its run in between or not.
|
|
2597
|
+
*/
|
|
2598
|
+
async fly(flight) {
|
|
2599
|
+
const landing = flight.then(
|
|
2600
|
+
() => void 0,
|
|
2601
|
+
() => void 0
|
|
2602
|
+
);
|
|
2603
|
+
this.landings.add(landing);
|
|
2604
|
+
try {
|
|
2605
|
+
return await flight;
|
|
2606
|
+
} finally {
|
|
2607
|
+
this.landings.delete(landing);
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
/**
|
|
2611
|
+
* flyableRoute is the route a flight can follow, or null: no route, or a line of fewer than
|
|
2612
|
+
* {@link ROUTE_VERTICES_MIN} vertices, which has no direction to fly in and whose bounds frame
|
|
2613
|
+
* nothing.
|
|
2614
|
+
*/
|
|
2615
|
+
flyableRoute() {
|
|
2616
|
+
const route = this.flight.route;
|
|
2617
|
+
return route && route.line.length >= ROUTE_VERTICES_MIN ? route : null;
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* prewarmRoute settles the DEM over the route's bounds, once per route.
|
|
2621
|
+
*
|
|
2622
|
+
* Before any resolve, because the clearance pass samples terrain through the live map: without
|
|
2623
|
+
* this it reads null and the flight plans a camera straight through a ridge. Once per route
|
|
2624
|
+
* because it is a visible camera move that can take seconds on a cold cache, and repeating it on
|
|
2625
|
+
* every play would make each transport action drag.
|
|
2626
|
+
*
|
|
2627
|
+
* A flight asked for while the warm is in progress awaits the one in progress. A warm that
|
|
2628
|
+
* rejects is not recorded as done, and rejects for every flight that waited on it.
|
|
2629
|
+
*/
|
|
2630
|
+
prewarmRoute() {
|
|
2631
|
+
const map = this.map;
|
|
2632
|
+
const route = this.flyableRoute();
|
|
2633
|
+
const revision = this.routeRevision;
|
|
2634
|
+
if (!map || !route || this.terrainWarmedRevision === revision) {
|
|
2635
|
+
return Promise.resolve();
|
|
2636
|
+
}
|
|
2637
|
+
if (this.terrainWarm?.revision === revision) {
|
|
2638
|
+
return this.terrainWarm.settled;
|
|
2639
|
+
}
|
|
2640
|
+
const bounds = routeBounds(route);
|
|
2641
|
+
if (!bounds) {
|
|
2642
|
+
return Promise.resolve();
|
|
2643
|
+
}
|
|
2644
|
+
const warm = { revision, settled: Promise.resolve() };
|
|
2645
|
+
this.terrainWarm = warm;
|
|
2646
|
+
warm.settled = (async () => {
|
|
2647
|
+
try {
|
|
2648
|
+
await map.prewarmTerrain(bounds);
|
|
2649
|
+
if (this.routeRevision === revision) {
|
|
2650
|
+
this.terrainWarmedRevision = revision;
|
|
2651
|
+
}
|
|
2652
|
+
} finally {
|
|
2653
|
+
if (this.terrainWarm === warm) {
|
|
2654
|
+
this.terrainWarm = null;
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
})();
|
|
2658
|
+
return warm.settled;
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2661
|
+
* warmRoute warms the route the engine holds as a preview or a seek takes it: the DEM over its
|
|
2662
|
+
* bounds ({@link prewarmRoute}), then its flight's viewports ({@link warmFlight}), each once per
|
|
2663
|
+
* route.
|
|
2664
|
+
*
|
|
2665
|
+
* The route is read again after each warm. One set while a warm ran is the route the flight is
|
|
2666
|
+
* of, so it is warmed in turn, the DEM before the sweep, and no pose is resolved over terrain a
|
|
2667
|
+
* warm of another route settled. It settles once the route it last warmed is the one held, or
|
|
2668
|
+
* as soon as `stopped` answers true after a warm.
|
|
2669
|
+
*
|
|
2670
|
+
* @param stopped Whether the flight has let go of the camera: its run was stopped, or a newer
|
|
2671
|
+
* flight overtook it. The flight warm reads it to tell a sweep somebody still waits on from
|
|
2672
|
+
* one nobody does.
|
|
2673
|
+
*/
|
|
2674
|
+
async warmRoute(stopped) {
|
|
2675
|
+
for (; ; ) {
|
|
2676
|
+
this.readRoute();
|
|
2677
|
+
const revision = this.routeRevision;
|
|
2678
|
+
await this.prewarmRoute();
|
|
2679
|
+
this.readRoute();
|
|
2680
|
+
if (stopped()) {
|
|
2681
|
+
return;
|
|
2682
|
+
}
|
|
2683
|
+
if (revision !== this.routeRevision) {
|
|
2684
|
+
continue;
|
|
2685
|
+
}
|
|
2686
|
+
await this.warmFlight(stopped);
|
|
2687
|
+
this.readRoute();
|
|
2688
|
+
if (stopped() || revision === this.routeRevision) {
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
/**
|
|
2694
|
+
* warmFlight jumps the camera through the flight's own viewports, once per route.
|
|
2695
|
+
*
|
|
2696
|
+
* The sampler-free resolve is used for the warm pass (its centers and bearings match the final
|
|
2697
|
+
* poses, so warming against it loads exactly the tiles the flight crosses), and the DEM epoch is
|
|
2698
|
+
* bumped afterwards, which drops any resolve cached against the colder terrain.
|
|
2699
|
+
*
|
|
2700
|
+
* A flight asked for while the sweep is in progress awaits the one in progress, a record's own
|
|
2701
|
+
* sweep included ({@link sweepForRecord}): two sweeps over one route would fight for the
|
|
2702
|
+
* camera. The sweep takes a signal of its own, which {@link endFlightWarm} aborts. A warm cut
|
|
2703
|
+
* short covered part of the flight, so it is not recorded as done and the next flight warms
|
|
2704
|
+
* again.
|
|
2705
|
+
*
|
|
2706
|
+
* @param stopped Whether the waiting flight has let go of the camera, held among the sweep's
|
|
2707
|
+
* waiters while it waits.
|
|
2708
|
+
*/
|
|
2709
|
+
async warmFlight(stopped) {
|
|
2710
|
+
const map = this.map;
|
|
2711
|
+
const route = this.flyableRoute();
|
|
2712
|
+
const revision = this.routeRevision;
|
|
2713
|
+
if (!map || !route || this.flightWarmedRevision === revision) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
const recording = this.recordWarm;
|
|
2717
|
+
if (this.flightWarm?.revision !== revision && recording?.revision === revision) {
|
|
2718
|
+
if (!recording.signal.aborted) {
|
|
2719
|
+
await recording.settled;
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
let warm = this.flightWarm;
|
|
2724
|
+
if (warm?.revision !== revision) {
|
|
2725
|
+
const controller = new AbortController();
|
|
2726
|
+
const begun = {
|
|
2727
|
+
controller,
|
|
2728
|
+
revision,
|
|
2729
|
+
settled: Promise.resolve(),
|
|
2730
|
+
waiters: /* @__PURE__ */ new Set()
|
|
2731
|
+
};
|
|
2732
|
+
this.flightWarm = begun;
|
|
2733
|
+
begun.settled = (async () => {
|
|
2734
|
+
try {
|
|
2735
|
+
await map.warmPoses(
|
|
2736
|
+
this.planner.resolveTrack(this.flight.plan, route),
|
|
2737
|
+
controller.signal
|
|
2738
|
+
);
|
|
2739
|
+
if (!controller.signal.aborted) {
|
|
2740
|
+
this.flightWarmedRevision = revision;
|
|
2741
|
+
this.demEpoch += 1;
|
|
2742
|
+
}
|
|
2743
|
+
} finally {
|
|
2744
|
+
if (this.flightWarm === begun) {
|
|
2745
|
+
this.flightWarm = null;
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
})();
|
|
2749
|
+
warm = begun;
|
|
2750
|
+
}
|
|
2751
|
+
warm.waiters.add(stopped);
|
|
2752
|
+
try {
|
|
2753
|
+
await warm.settled;
|
|
2754
|
+
} finally {
|
|
2755
|
+
warm.waiters.delete(stopped);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* sweepForRecord jumps the camera through the sampler-free viewports of the flight a record is
|
|
2760
|
+
* about to capture, under the record's own run.
|
|
2761
|
+
*
|
|
2762
|
+
* It settles the DEM at flight zoom before the full-density resolve samples clearance. The
|
|
2763
|
+
* recorder skips its own warm pass only where the clearance pass moved no frame
|
|
2764
|
+
* ({@link capturesSweptViewports}): a frame it widened or tilted frames ground this sweep never
|
|
2765
|
+
* did.
|
|
2766
|
+
*
|
|
2767
|
+
* A record sweeps whenever its poses are not cached, whatever was warmed before, so the capture
|
|
2768
|
+
* never films a tile that has been let go since. The sweep is the flight's own over that
|
|
2769
|
+
* route, so it is held where {@link warmFlight} finds it: a seek asked for meanwhile waits on
|
|
2770
|
+
* it and starts no second sweep. One that runs to its end counts as the route's flight warm,
|
|
2771
|
+
* with the DEM epoch moved as `warmFlight` moves it. One its run cut short counts for nothing.
|
|
2772
|
+
*
|
|
2773
|
+
* @param track The sampler-free track of the plan and the route the record began with.
|
|
2774
|
+
* @param revision The route's revision as the record began.
|
|
2775
|
+
* @param signal The record's run.
|
|
2776
|
+
*/
|
|
2777
|
+
sweepForRecord(track, revision, signal) {
|
|
2778
|
+
const map = this.map;
|
|
2779
|
+
if (!map) {
|
|
2780
|
+
return Promise.resolve();
|
|
2781
|
+
}
|
|
2782
|
+
const warm = { revision, settled: Promise.resolve(), signal };
|
|
2783
|
+
this.recordWarm = warm;
|
|
2784
|
+
warm.settled = (async () => {
|
|
2785
|
+
try {
|
|
2786
|
+
await map.warmPoses(track, signal);
|
|
2787
|
+
if (!signal.aborted && this.routeRevision === revision) {
|
|
2788
|
+
this.flightWarmedRevision = revision;
|
|
2789
|
+
this.demEpoch += 1;
|
|
2790
|
+
}
|
|
2791
|
+
} finally {
|
|
2792
|
+
if (this.recordWarm === warm) {
|
|
2793
|
+
this.recordWarm = null;
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
})();
|
|
2797
|
+
return warm.settled;
|
|
2798
|
+
}
|
|
2799
|
+
/**
|
|
2800
|
+
* resolve turns the plan into poses, markers and a duration, memoized.
|
|
2801
|
+
*
|
|
2802
|
+
* Returns null when there is no route a flight can follow, which is the one input a flight
|
|
2803
|
+
* cannot be invented without. The record pass warms the flight-zoom tiles first so the capture
|
|
2804
|
+
* never films an unloaded tile and the clearance sampler reads real peak heights; the preview
|
|
2805
|
+
* pass skips that internal warm because `preview` already ran it once per route.
|
|
2806
|
+
*
|
|
2807
|
+
* It also returns null when `signal` aborted before or during that warm, which its caller reads
|
|
2808
|
+
* off the signal: a warm never starts on a dead signal, because the sweep moves the camera and a
|
|
2809
|
+
* map a host supplies need not honour one; and the full-density resolve after it is the costliest
|
|
2810
|
+
* step a record takes before its first frame, so poses sampled against a half-warmed DEM do not
|
|
2811
|
+
* belong in the cache.
|
|
2812
|
+
*
|
|
2813
|
+
* The plan and the route are read once, as the resolve begins, and the flight it answers names
|
|
2814
|
+
* both. A plan or a route set while the record pass warms takes on the next flight: the one in
|
|
2815
|
+
* progress is resolved, stored and recorded for what it began with.
|
|
2816
|
+
*/
|
|
2817
|
+
async resolve(options) {
|
|
2818
|
+
const route = this.flyableRoute();
|
|
2819
|
+
if (!route) {
|
|
2820
|
+
return null;
|
|
2821
|
+
}
|
|
2822
|
+
const plan = this.flight.plan;
|
|
2823
|
+
const revision = this.routeRevision;
|
|
2824
|
+
const key = () => [posePlanSignature(plan), revision, options.pass, this.demEpoch].join("|");
|
|
2825
|
+
const cached = this.poseCache.get(key());
|
|
2826
|
+
if (cached) {
|
|
2827
|
+
this.poseCache.delete(key());
|
|
2828
|
+
this.poseCache.set(key(), cached);
|
|
2829
|
+
return cached;
|
|
2830
|
+
}
|
|
2831
|
+
let swept = null;
|
|
2832
|
+
if (options.pass === "record") {
|
|
2833
|
+
if (options.signal.aborted) {
|
|
2834
|
+
return null;
|
|
2835
|
+
}
|
|
2836
|
+
swept = this.planner.resolveTrack(plan, route);
|
|
2837
|
+
await this.sweepForRecord(swept, revision, options.signal);
|
|
2838
|
+
if (options.signal.aborted) {
|
|
2839
|
+
return null;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
const resolved = {
|
|
2843
|
+
markers: resolveRouteMarkers(plan, route),
|
|
2844
|
+
plan,
|
|
2845
|
+
planDurationMs: planDurationMs(plan),
|
|
2846
|
+
// A copy, once per resolve: the planner answers a readonly track, and the map's
|
|
2847
|
+
// `previewPoses` and `recordPoses` take the array a run hands them.
|
|
2848
|
+
poses: [
|
|
2849
|
+
...this.planner.resolveTrack(
|
|
2850
|
+
plan,
|
|
2851
|
+
route,
|
|
2852
|
+
(lngLat) => this.map?.sampleTerrainElevation(lngLat) ?? null,
|
|
2853
|
+
options.pass === "record" ? 1 : clearanceStrideFor(plan, route)
|
|
2854
|
+
)
|
|
2855
|
+
],
|
|
2856
|
+
route
|
|
2857
|
+
};
|
|
2858
|
+
if (swept !== null && capturesSweptViewports(swept, resolved.poses)) {
|
|
2859
|
+
options.onSwept?.();
|
|
2860
|
+
}
|
|
2861
|
+
if (revision !== this.routeRevision) {
|
|
2862
|
+
return resolved;
|
|
2863
|
+
}
|
|
2864
|
+
this.poseCache.set(key(), resolved);
|
|
2865
|
+
if (this.poseCache.size > this.poseCacheSize) {
|
|
2866
|
+
const oldest = this.poseCache.keys().next().value;
|
|
2867
|
+
if (oldest !== void 0) {
|
|
2868
|
+
this.poseCache.delete(oldest);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
return resolved;
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* recordProfile builds the overlay's recording input for a resolved flight, or nothing.
|
|
2875
|
+
*
|
|
2876
|
+
* All three inputs or none: the overlay is composited only when a caller enabled it AND both the
|
|
2877
|
+
* route and the profile source are present. The samples are resolved through the same planner and
|
|
2878
|
+
* the same frame progression as the poses, over the plan and the route the poses were resolved
|
|
2879
|
+
* for, so the readout on frame N describes the place frame N is looking at: index alignment is
|
|
2880
|
+
* the whole correctness condition here.
|
|
2881
|
+
*/
|
|
2882
|
+
recordProfile(resolved) {
|
|
2883
|
+
const { profile, profileSource } = this.flight;
|
|
2884
|
+
if (!profile.enabled || !profileSource) {
|
|
2885
|
+
return void 0;
|
|
2886
|
+
}
|
|
2887
|
+
return {
|
|
2888
|
+
design: profile.design,
|
|
2889
|
+
format: {
|
|
2890
|
+
language: profile.language,
|
|
2891
|
+
length: profile.length,
|
|
2892
|
+
pace: profile.pace,
|
|
2893
|
+
slope: profile.slope,
|
|
2894
|
+
// The overlay states distance, elevation, grade and speed, and never a temperature,
|
|
2895
|
+
// so there is no scale here for a viewer to have chosen. Pinned rather than
|
|
2896
|
+
// carried on VideoFlightProfile, which would publish a setting with nothing to set.
|
|
2897
|
+
temperature: "celsius"
|
|
2898
|
+
},
|
|
2899
|
+
samples: this.planner.resolveSamples(resolved.plan, resolved.route, profileSource)
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
};
|
|
2903
|
+
|
|
2904
|
+
// src/camera/rules/modes.ts
|
|
2905
|
+
var KEYFRAME_COUNT = 9;
|
|
2906
|
+
var modeFramings = {
|
|
2907
|
+
chase: {
|
|
2908
|
+
basePitch: 77,
|
|
2909
|
+
introHoldMs: 1e3,
|
|
2910
|
+
introPitchDelta: -10,
|
|
2911
|
+
outroHoldMs: 1100,
|
|
2912
|
+
outroPitchDelta: -6,
|
|
2913
|
+
zoomBias: 1.7
|
|
2914
|
+
},
|
|
2915
|
+
cinematic: {
|
|
2916
|
+
basePitch: 68,
|
|
2917
|
+
introHoldMs: 1600,
|
|
2918
|
+
introPitchDelta: 8,
|
|
2919
|
+
outroHoldMs: 1400,
|
|
2920
|
+
outroPitchDelta: -4,
|
|
2921
|
+
zoomBias: 0.8
|
|
2922
|
+
},
|
|
2923
|
+
drone: {
|
|
2924
|
+
basePitch: 75,
|
|
2925
|
+
introHoldMs: 1500,
|
|
2926
|
+
introPitchDelta: 10,
|
|
2927
|
+
outroHoldMs: 1300,
|
|
2928
|
+
outroPitchDelta: 6,
|
|
2929
|
+
zoomBias: -0.6
|
|
2930
|
+
},
|
|
2931
|
+
helicopter: {
|
|
2932
|
+
basePitch: 56,
|
|
2933
|
+
introHoldMs: 1500,
|
|
2934
|
+
introPitchDelta: -8,
|
|
2935
|
+
outroHoldMs: 1400,
|
|
2936
|
+
outroPitchDelta: -6,
|
|
2937
|
+
zoomBias: -0.9
|
|
2938
|
+
},
|
|
2939
|
+
overview: {
|
|
2940
|
+
basePitch: 58,
|
|
2941
|
+
introHoldMs: 1800,
|
|
2942
|
+
outroHoldMs: 1600,
|
|
2943
|
+
zoomBias: -0.4
|
|
2944
|
+
},
|
|
2945
|
+
smart: {
|
|
2946
|
+
basePitch: 62,
|
|
2947
|
+
introHoldMs: 1100,
|
|
2948
|
+
introPitchDelta: 6,
|
|
2949
|
+
outroHoldMs: 1e3,
|
|
2950
|
+
outroPitchDelta: 3,
|
|
2951
|
+
zoomBias: 0
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
var modeEyeHeightMeters = {
|
|
2955
|
+
chase: 170,
|
|
2956
|
+
cinematic: CINEMATIC_EYE_HEIGHT_METERS,
|
|
2957
|
+
drone: 650,
|
|
2958
|
+
helicopter: 500,
|
|
2959
|
+
overview: 350,
|
|
2960
|
+
smart: 300
|
|
2961
|
+
};
|
|
2962
|
+
var SMART_MAX_SLOPE_TRIM = 28;
|
|
2963
|
+
var SMART_LOOKAHEAD_METERS = 800;
|
|
2964
|
+
var SMART_MAX_PITCH_STEP = 8;
|
|
2965
|
+
var SMART_STEEP_SLOWDOWN_MAX = 0.3;
|
|
2966
|
+
var SMART_SLOWDOWN_FULL_SLOPE_DEG = 20;
|
|
2967
|
+
var SMART_STEEP_WIDEN_ZOOM = 0.6;
|
|
2968
|
+
var CINEMATIC_HIGHLIGHT_MIN_SLOPE_DEG = 6;
|
|
2969
|
+
var CINEMATIC_HIGHLIGHT_LOOKAHEAD_METERS = 400;
|
|
2970
|
+
var CINEMATIC_HIGHLIGHT_HOLD_MS = 900;
|
|
2971
|
+
var CINEMATIC_HIGHLIGHT_APPROACH_SPEED = 0.85;
|
|
2972
|
+
var CINEMATIC_HIGHLIGHT_PITCH_TRIM = 6;
|
|
2973
|
+
var CHASE_SLOPE_LOOKAHEAD_METERS = 400;
|
|
2974
|
+
var CHASE_MAX_SLOPE_TRIM = 12;
|
|
2975
|
+
var CHASE_SLOPE_TRIM_FACTOR = 0.5;
|
|
2976
|
+
var CHASE_DESCENT_SPEEDUP_MAX = 0.5;
|
|
2977
|
+
var CHASE_DESCENT_FULL_SLOPE_DEG = 15;
|
|
2978
|
+
var HELICOPTER_TANGENT_LOOKAHEAD_METERS = 500;
|
|
2979
|
+
var HELICOPTER_SIDE_OFFSET_DEG = 90;
|
|
2980
|
+
var OVERVIEW_ENDPOINT_PITCH = 12;
|
|
2981
|
+
var OVERVIEW_FRAME_FACTOR = 1.6;
|
|
2982
|
+
var generateSmartPlan = (itinerary, params) => {
|
|
2983
|
+
refuseUnplannableRoute("generateSmartPlan", itinerary);
|
|
2984
|
+
const framing = modeFramings.smart;
|
|
2985
|
+
const line = toLine(itinerary);
|
|
2986
|
+
const cumulative = cumulativeMeters(line);
|
|
2987
|
+
const lengthMeters = routeLengthMeters(line);
|
|
2988
|
+
const fractions = keyframeFractions();
|
|
2989
|
+
const slopes = fractions.map(
|
|
2990
|
+
(fraction) => slopeDegAtFraction(itinerary, fraction, SMART_LOOKAHEAD_METERS)
|
|
2991
|
+
);
|
|
2992
|
+
const smoothedSlopes = smoothTriTap(slopes);
|
|
2993
|
+
const travelPitches = limitInteriorPitchSteps(
|
|
2994
|
+
smoothedSlopes.map((slopeDeg) => slopePitch(framing.basePitch, slopeDeg))
|
|
2995
|
+
);
|
|
2996
|
+
const fitZoom = routeFitZoom(line);
|
|
2997
|
+
const shots = fractions.map((fraction, index) => {
|
|
2998
|
+
const cursor = cursorAtFraction(line, fraction, SMART_LOOKAHEAD_METERS, cumulative);
|
|
2999
|
+
const interior = !(isIntro(index) || isOutro(index));
|
|
3000
|
+
const steepness = Math.min(
|
|
3001
|
+
1,
|
|
3002
|
+
Math.abs(smoothedSlopes[index] ?? 0) / SMART_SLOWDOWN_FULL_SLOPE_DEG
|
|
3003
|
+
);
|
|
3004
|
+
const steepWiden = interior ? SMART_STEEP_WIDEN_ZOOM * steepness : 0;
|
|
3005
|
+
return {
|
|
3006
|
+
at: fraction,
|
|
3007
|
+
bearingMode: "follow",
|
|
3008
|
+
holdMs: holdForKeyframe(framing, index),
|
|
3009
|
+
id: shotId("smart", index),
|
|
3010
|
+
pitchDeg: pitchForKeyframe(framing, index, travelPitches[index] ?? framing.basePitch),
|
|
3011
|
+
speedScale: interior ? 1 - SMART_STEEP_SLOWDOWN_MAX * steepness : 1,
|
|
3012
|
+
zoom: interior ? zoomFor(
|
|
3013
|
+
itinerary,
|
|
3014
|
+
fraction,
|
|
3015
|
+
cursor.point[1],
|
|
3016
|
+
lengthMeters,
|
|
3017
|
+
framing.zoomBias - steepWiden,
|
|
3018
|
+
modeEyeHeightMeters.smart
|
|
3019
|
+
) : fitZoom
|
|
3020
|
+
};
|
|
3021
|
+
});
|
|
3022
|
+
return parsePlan("smart", shots, params);
|
|
3023
|
+
};
|
|
3024
|
+
var slopePitch = (basePitch, slopeDeg) => clampPitch(basePitch - Math.min(SMART_MAX_SLOPE_TRIM, Math.abs(slopeDeg)));
|
|
3025
|
+
var smoothTriTap = (values) => {
|
|
3026
|
+
const length = values.length;
|
|
3027
|
+
if (length < 3) {
|
|
3028
|
+
return [...values];
|
|
3029
|
+
}
|
|
3030
|
+
const out = new Array(length);
|
|
3031
|
+
for (let i = 0; i < length; i += 1) {
|
|
3032
|
+
const previous = values[Math.max(0, i - 1)] ?? 0;
|
|
3033
|
+
const current = values[i] ?? 0;
|
|
3034
|
+
const next = values[Math.min(length - 1, i + 1)] ?? 0;
|
|
3035
|
+
out[i] = previous * 0.25 + current * 0.5 + next * 0.25;
|
|
3036
|
+
}
|
|
3037
|
+
return out;
|
|
3038
|
+
};
|
|
3039
|
+
var limitInteriorPitchSteps = (pitches) => {
|
|
3040
|
+
const out = [...pitches];
|
|
3041
|
+
for (let index = 2; index < out.length - 1; index += 1) {
|
|
3042
|
+
const previous = out[index - 1] ?? 0;
|
|
3043
|
+
const current = out[index] ?? previous;
|
|
3044
|
+
const delta = current - previous;
|
|
3045
|
+
if (delta > SMART_MAX_PITCH_STEP) {
|
|
3046
|
+
out[index] = previous + SMART_MAX_PITCH_STEP;
|
|
3047
|
+
} else if (delta < -SMART_MAX_PITCH_STEP) {
|
|
3048
|
+
out[index] = previous - SMART_MAX_PITCH_STEP;
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
return out;
|
|
3052
|
+
};
|
|
3053
|
+
var generateCinematicPlan = (itinerary, params) => {
|
|
3054
|
+
refuseUnplannableRoute("generateCinematicPlan", itinerary);
|
|
3055
|
+
const framing = modeFramings.cinematic;
|
|
3056
|
+
const line = toLine(itinerary);
|
|
3057
|
+
const lengthMeters = routeLengthMeters(line);
|
|
3058
|
+
const fractions = keyframeFractions();
|
|
3059
|
+
const fitZoom = routeFitZoom(line);
|
|
3060
|
+
const shots = fractions.map(
|
|
3061
|
+
(fraction, index) => ({
|
|
3062
|
+
at: fraction,
|
|
3063
|
+
bearingMode: "follow",
|
|
3064
|
+
holdMs: holdForKeyframe(framing, index),
|
|
3065
|
+
id: shotId("cinematic", index),
|
|
3066
|
+
pitchDeg: pitchForKeyframe(framing, index, framing.basePitch),
|
|
3067
|
+
speedScale: 1,
|
|
3068
|
+
zoom: isIntro(index) || isOutro(index) ? fitZoom : zoomFor(
|
|
3069
|
+
itinerary,
|
|
3070
|
+
fraction,
|
|
3071
|
+
latAtFraction(line, fraction),
|
|
3072
|
+
lengthMeters,
|
|
3073
|
+
framing.zoomBias,
|
|
3074
|
+
modeEyeHeightMeters.cinematic
|
|
3075
|
+
)
|
|
3076
|
+
})
|
|
3077
|
+
);
|
|
3078
|
+
let highlightIndex = -1;
|
|
3079
|
+
let highlightSlope = 0;
|
|
3080
|
+
for (let index = 2; index <= KEYFRAME_COUNT - 3; index += 1) {
|
|
3081
|
+
const slope = Math.abs(
|
|
3082
|
+
slopeDegAtFraction(itinerary, fractions[index] ?? 0, CINEMATIC_HIGHLIGHT_LOOKAHEAD_METERS)
|
|
3083
|
+
);
|
|
3084
|
+
if (slope >= CINEMATIC_HIGHLIGHT_MIN_SLOPE_DEG && slope > highlightSlope) {
|
|
3085
|
+
highlightIndex = index;
|
|
3086
|
+
highlightSlope = slope;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
const highlight = shots[highlightIndex];
|
|
3090
|
+
if (highlight) {
|
|
3091
|
+
shots[highlightIndex] = {
|
|
3092
|
+
...highlight,
|
|
3093
|
+
holdMs: CINEMATIC_HIGHLIGHT_HOLD_MS,
|
|
3094
|
+
pitchDeg: clampPitch(framing.basePitch - CINEMATIC_HIGHLIGHT_PITCH_TRIM),
|
|
3095
|
+
speedScale: CINEMATIC_HIGHLIGHT_APPROACH_SPEED
|
|
3096
|
+
};
|
|
3097
|
+
}
|
|
3098
|
+
return parsePlan("cinematic", shots, params);
|
|
3099
|
+
};
|
|
3100
|
+
var generateDronePlan = (itinerary, params) => {
|
|
3101
|
+
refuseUnplannableRoute("generateDronePlan", itinerary);
|
|
3102
|
+
const framing = modeFramings.drone;
|
|
3103
|
+
const line = toLine(itinerary);
|
|
3104
|
+
const lengthMeters = routeLengthMeters(line);
|
|
3105
|
+
const fitZoom = routeFitZoom(line);
|
|
3106
|
+
const shots = keyframeFractions().map(
|
|
3107
|
+
(fraction, index) => ({
|
|
3108
|
+
at: fraction,
|
|
3109
|
+
bearingMode: "follow",
|
|
3110
|
+
holdMs: holdForKeyframe(framing, index),
|
|
3111
|
+
id: shotId("drone", index),
|
|
3112
|
+
pitchDeg: pitchForKeyframe(framing, index, framing.basePitch),
|
|
3113
|
+
speedScale: 1,
|
|
3114
|
+
zoom: isIntro(index) || isOutro(index) ? fitZoom : zoomFor(
|
|
3115
|
+
itinerary,
|
|
3116
|
+
fraction,
|
|
3117
|
+
latAtFraction(line, fraction),
|
|
3118
|
+
lengthMeters,
|
|
3119
|
+
framing.zoomBias,
|
|
3120
|
+
modeEyeHeightMeters.drone
|
|
3121
|
+
)
|
|
3122
|
+
})
|
|
3123
|
+
);
|
|
3124
|
+
return parsePlan("drone", shots, params);
|
|
3125
|
+
};
|
|
3126
|
+
var generateHelicopterPlan = (itinerary, params) => {
|
|
3127
|
+
refuseUnplannableRoute("generateHelicopterPlan", itinerary);
|
|
3128
|
+
const framing = modeFramings.helicopter;
|
|
3129
|
+
const line = toLine(itinerary);
|
|
3130
|
+
const cumulative = cumulativeMeters(line);
|
|
3131
|
+
const lengthMeters = routeLengthMeters(line);
|
|
3132
|
+
const fitZoom = routeFitZoom(line);
|
|
3133
|
+
const shots = keyframeFractions().map((fraction, index) => {
|
|
3134
|
+
const cursor = cursorAtFraction(
|
|
3135
|
+
line,
|
|
3136
|
+
fraction,
|
|
3137
|
+
HELICOPTER_TANGENT_LOOKAHEAD_METERS,
|
|
3138
|
+
cumulative
|
|
3139
|
+
);
|
|
3140
|
+
return {
|
|
3141
|
+
at: fraction,
|
|
3142
|
+
bearingDeg: normalizeBearing(cursor.bearingDeg + HELICOPTER_SIDE_OFFSET_DEG),
|
|
3143
|
+
bearingMode: "value",
|
|
3144
|
+
holdMs: holdForKeyframe(framing, index),
|
|
3145
|
+
id: shotId("helicopter", index),
|
|
3146
|
+
pitchDeg: pitchForKeyframe(framing, index, framing.basePitch),
|
|
3147
|
+
speedScale: 1,
|
|
3148
|
+
zoom: isIntro(index) || isOutro(index) ? fitZoom : zoomFor(
|
|
3149
|
+
itinerary,
|
|
3150
|
+
fraction,
|
|
3151
|
+
cursor.point[1],
|
|
3152
|
+
lengthMeters,
|
|
3153
|
+
framing.zoomBias,
|
|
3154
|
+
modeEyeHeightMeters.helicopter
|
|
3155
|
+
)
|
|
3156
|
+
};
|
|
3157
|
+
});
|
|
3158
|
+
return parsePlan("helicopter", shots, params);
|
|
3159
|
+
};
|
|
3160
|
+
var generateChasePlan = (itinerary, params) => {
|
|
3161
|
+
refuseUnplannableRoute("generateChasePlan", itinerary);
|
|
3162
|
+
const framing = modeFramings.chase;
|
|
3163
|
+
const line = toLine(itinerary);
|
|
3164
|
+
const lengthMeters = routeLengthMeters(line);
|
|
3165
|
+
const fractions = keyframeFractions();
|
|
3166
|
+
const slopes = fractions.map(
|
|
3167
|
+
(fraction) => slopeDegAtFraction(itinerary, fraction, CHASE_SLOPE_LOOKAHEAD_METERS)
|
|
3168
|
+
);
|
|
3169
|
+
const smoothedSlopes = smoothTriTap(slopes);
|
|
3170
|
+
const travelPitches = limitInteriorPitchSteps(
|
|
3171
|
+
smoothedSlopes.map(
|
|
3172
|
+
(slopeDeg) => clampPitch(
|
|
3173
|
+
framing.basePitch - Math.min(CHASE_MAX_SLOPE_TRIM, Math.abs(slopeDeg) * CHASE_SLOPE_TRIM_FACTOR)
|
|
3174
|
+
)
|
|
3175
|
+
)
|
|
3176
|
+
);
|
|
3177
|
+
const fitZoom = routeFitZoom(line);
|
|
3178
|
+
const shots = fractions.map((fraction, index) => {
|
|
3179
|
+
const interior = !(isIntro(index) || isOutro(index));
|
|
3180
|
+
return {
|
|
3181
|
+
at: fraction,
|
|
3182
|
+
bearingMode: "follow",
|
|
3183
|
+
holdMs: holdForKeyframe(framing, index),
|
|
3184
|
+
id: shotId("chase", index),
|
|
3185
|
+
pitchDeg: pitchForKeyframe(framing, index, travelPitches[index] ?? framing.basePitch),
|
|
3186
|
+
speedScale: interior ? chaseDescentSpeedScale(smoothedSlopes[index] ?? 0) : 1,
|
|
3187
|
+
zoom: interior ? zoomFor(
|
|
3188
|
+
itinerary,
|
|
3189
|
+
fraction,
|
|
3190
|
+
latAtFraction(line, fraction),
|
|
3191
|
+
lengthMeters,
|
|
3192
|
+
framing.zoomBias,
|
|
3193
|
+
modeEyeHeightMeters.chase
|
|
3194
|
+
) : fitZoom
|
|
3195
|
+
};
|
|
3196
|
+
});
|
|
3197
|
+
return parsePlan("chase", shots, params);
|
|
3198
|
+
};
|
|
3199
|
+
var chaseDescentSpeedScale = (slopeDeg) => {
|
|
3200
|
+
const descent = Math.min(1, Math.max(0, -slopeDeg) / CHASE_DESCENT_FULL_SLOPE_DEG);
|
|
3201
|
+
return 1 + CHASE_DESCENT_SPEEDUP_MAX * descent;
|
|
3202
|
+
};
|
|
3203
|
+
var generateOverviewPlan = (itinerary, params) => {
|
|
3204
|
+
refuseUnplannableRoute("generateOverviewPlan", itinerary);
|
|
3205
|
+
const framing = modeFramings.overview;
|
|
3206
|
+
const line = toLine(itinerary);
|
|
3207
|
+
const lengthMeters = routeLengthMeters(line);
|
|
3208
|
+
const introRadiusMeters = farthestVertexMeters(line, line[0]);
|
|
3209
|
+
const outroRadiusMeters = farthestVertexMeters(line, line[line.length - 1]);
|
|
3210
|
+
const overallHeading = normalizeBearing(routeHeadingDeg(line));
|
|
3211
|
+
const shots = keyframeFractions().map((fraction, index) => {
|
|
3212
|
+
const endpoint = isIntro(index) || isOutro(index);
|
|
3213
|
+
const latitude = latAtFraction(line, fraction);
|
|
3214
|
+
return {
|
|
3215
|
+
at: fraction,
|
|
3216
|
+
...isOutro(index) ? { bearingDeg: overallHeading } : {},
|
|
3217
|
+
bearingMode: isIntro(index) ? "locked" : isOutro(index) ? "value" : "follow",
|
|
3218
|
+
holdMs: holdForKeyframe(framing, index),
|
|
3219
|
+
id: shotId("overview", index),
|
|
3220
|
+
pitchDeg: endpoint ? OVERVIEW_ENDPOINT_PITCH : clampPitch(framing.basePitch),
|
|
3221
|
+
speedScale: 1,
|
|
3222
|
+
zoom: endpoint ? distanceZoom(
|
|
3223
|
+
(isIntro(index) ? introRadiusMeters : outroRadiusMeters) * OVERVIEW_FRAME_FACTOR,
|
|
3224
|
+
latitude
|
|
3225
|
+
) : zoomFor(
|
|
3226
|
+
itinerary,
|
|
3227
|
+
fraction,
|
|
3228
|
+
latitude,
|
|
3229
|
+
lengthMeters,
|
|
3230
|
+
framing.zoomBias,
|
|
3231
|
+
modeEyeHeightMeters.overview
|
|
3232
|
+
)
|
|
3233
|
+
};
|
|
3234
|
+
});
|
|
3235
|
+
return parsePlan("overview", shots, params);
|
|
3236
|
+
};
|
|
3237
|
+
var neutralDirectorPlan = (params) => createCameraPlan({
|
|
3238
|
+
mode: "director",
|
|
3239
|
+
shots: [],
|
|
3240
|
+
targetDurationMs: params.targetDurationMs
|
|
3241
|
+
});
|
|
3242
|
+
var cameraPlanGenerators = {
|
|
3243
|
+
chase: generateChasePlan,
|
|
3244
|
+
cinematic: generateCinematicPlan,
|
|
3245
|
+
drone: generateDronePlan,
|
|
3246
|
+
helicopter: generateHelicopterPlan,
|
|
3247
|
+
overview: generateOverviewPlan,
|
|
3248
|
+
smart: generateSmartPlan
|
|
3249
|
+
};
|
|
3250
|
+
var SHORT_ROUTE_METERS = 200;
|
|
3251
|
+
var isIntro = (index) => index === 0;
|
|
3252
|
+
var isOutro = (index) => index === KEYFRAME_COUNT - 1;
|
|
3253
|
+
var keyframeFractions = () => {
|
|
3254
|
+
const last = KEYFRAME_COUNT - 1;
|
|
3255
|
+
return Array.from({ length: KEYFRAME_COUNT }, (_unused, index) => index / last);
|
|
3256
|
+
};
|
|
3257
|
+
var holdForKeyframe = (framing, index) => {
|
|
3258
|
+
if (isIntro(index)) {
|
|
3259
|
+
return framing.introHoldMs;
|
|
3260
|
+
}
|
|
3261
|
+
if (isOutro(index)) {
|
|
3262
|
+
return framing.outroHoldMs;
|
|
3263
|
+
}
|
|
3264
|
+
return 0;
|
|
3265
|
+
};
|
|
3266
|
+
var pitchForKeyframe = (framing, index, travelPitch) => {
|
|
3267
|
+
if (isIntro(index)) {
|
|
3268
|
+
return clampPitch(framing.basePitch + framing.introPitchDelta);
|
|
3269
|
+
}
|
|
3270
|
+
if (isOutro(index)) {
|
|
3271
|
+
return clampPitch(framing.basePitch + framing.outroPitchDelta);
|
|
3272
|
+
}
|
|
3273
|
+
return clampPitch(travelPitch);
|
|
3274
|
+
};
|
|
3275
|
+
var routeFitZoom = (line) => {
|
|
3276
|
+
let west = Number.POSITIVE_INFINITY;
|
|
3277
|
+
let east = Number.NEGATIVE_INFINITY;
|
|
3278
|
+
let south = Number.POSITIVE_INFINITY;
|
|
3279
|
+
let north = Number.NEGATIVE_INFINITY;
|
|
3280
|
+
for (const [lng, lat] of line) {
|
|
3281
|
+
west = Math.min(west, lng);
|
|
3282
|
+
east = Math.max(east, lng);
|
|
3283
|
+
south = Math.min(south, lat);
|
|
3284
|
+
north = Math.max(north, lat);
|
|
3285
|
+
}
|
|
3286
|
+
if (!Number.isFinite(west) || !Number.isFinite(south)) {
|
|
3287
|
+
return distanceZoom(0, 0);
|
|
3288
|
+
}
|
|
3289
|
+
const midLatitude = (south + north) / 2;
|
|
3290
|
+
const latSpanMeters = (north - south) * METERS_PER_DEGREE_WEB_MERCATOR;
|
|
3291
|
+
const lngSpanMeters = (east - west) * METERS_PER_DEGREE_WEB_MERCATOR * Math.cos(midLatitude * DEGREES_TO_RADIANS);
|
|
3292
|
+
return distanceZoom(Math.max(latSpanMeters, lngSpanMeters), midLatitude);
|
|
3293
|
+
};
|
|
3294
|
+
var farthestVertexMeters = (line, origin) => {
|
|
3295
|
+
if (!origin) {
|
|
3296
|
+
return 0;
|
|
3297
|
+
}
|
|
3298
|
+
let radius = 0;
|
|
3299
|
+
for (const [lng, lat] of line) {
|
|
3300
|
+
const midLatitude = (lat + origin[1]) / 2 * DEGREES_TO_RADIANS;
|
|
3301
|
+
const dLat = (lat - origin[1]) * METERS_PER_DEGREE_WEB_MERCATOR;
|
|
3302
|
+
const dLng = (lng - origin[0]) * METERS_PER_DEGREE_WEB_MERCATOR * Math.cos(midLatitude);
|
|
3303
|
+
radius = Math.max(radius, Math.hypot(dLat, dLng));
|
|
3304
|
+
}
|
|
3305
|
+
return radius;
|
|
3306
|
+
};
|
|
3307
|
+
var shotId = (mode, index) => `${mode}-${index}`;
|
|
3308
|
+
var toLine = (itinerary) => continuousLine(itinerary.line);
|
|
3309
|
+
var latAtFraction = (line, fraction) => cursorAtFraction(line, fraction, 0).point[1];
|
|
3310
|
+
var normalizeBearing = (bearingDeg) => (bearingDeg % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
3311
|
+
var zoomFor = (itinerary, fraction, latitude, lengthMeters, zoomBias, eyeHeightMeters) => {
|
|
3312
|
+
const surface = elevationAtFraction(itinerary, fraction);
|
|
3313
|
+
if (surface !== null && lengthMeters >= SHORT_ROUTE_METERS) {
|
|
3314
|
+
return clampZoom(altitudeToZoom(surface + eyeHeightMeters, latitude) + zoomBias);
|
|
3315
|
+
}
|
|
3316
|
+
return clampZoom(distanceZoom(lengthMeters, latitude) + zoomBias);
|
|
3317
|
+
};
|
|
3318
|
+
var ROUTE_FRAME_PX = 768;
|
|
3319
|
+
var distanceZoom = (lengthMeters, latitude) => {
|
|
3320
|
+
const span = Math.max(lengthMeters, 50);
|
|
3321
|
+
const z = Math.log2(groundMetersPerPixel(0, latitude) * ROUTE_FRAME_PX / span);
|
|
3322
|
+
return clampZoom(z);
|
|
3323
|
+
};
|
|
3324
|
+
var parsePlan = (mode, shots, params) => createCameraPlan({ mode, shots: [...shots], targetDurationMs: params.targetDurationMs });
|
|
3325
|
+
|
|
3326
|
+
export { DEFAULT_TARGET_DURATION_MS, VideoFlightEngine, bearingDegBetween, cameraPlanGenerators, capturesSweptViewports, clearanceStrideFor, createCameraPlan, cursorAtFraction, defaultCameraOutput, defaultCameraShot, defaultVideoFlightProfile, elevationAtFraction, generateChasePlan, generateCinematicPlan, generateDronePlan, generateHelicopterPlan, generateOverviewPlan, generateSmartPlan, insertShotSorted, itineraryToRouteGeometry, measuredCameraPlanner, modeEyeHeightMeters, neutralDirectorPlan, planDurationMs, pointAtMeters, posePlanSignature, representativeStillFraction, resolveCameraTrack, resolveClearanceAdjustments, resolveFrameProgressions, resolveProfileSamples, resolveRouteMarkers, sameRouteContent, slopeDegAtFraction, synchronousCameraPlanner, tangentBearingAtMeters };
|
|
3327
|
+
//# sourceMappingURL=index.js.map
|
|
3328
|
+
//# sourceMappingURL=index.js.map
|