@open-take/compositor 0.5.3 → 0.6.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/dist/cdp-CzT5BKNY.js +3 -0
- package/dist/cdp-QXbQfXna.js +373 -0
- package/dist/cdp-QXbQfXna.js.map +1 -0
- package/dist/index.d.ts +4327 -195
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26282 -160
- package/dist/index.js.map +1 -1
- package/dist/server-841PMF2H.js +163 -0
- package/dist/server-841PMF2H.js.map +1 -0
- package/dist/server-C2aVv4-t.js +3 -0
- package/kit/audio.mjs +2366 -0
- package/kit/camera.js +587 -0
- package/kit/cursor.js +264 -0
- package/kit/cut.js +427 -0
- package/kit/draw.js +346 -0
- package/kit/look.js +589 -0
- package/kit/map.js +170 -0
- package/kit/media.js +3568 -0
- package/kit/motion.js +1115 -0
- package/kit/seams.js +1006 -0
- package/kit/stage.js +923 -0
- package/kit/time.js +812 -0
- package/kit/world.js +1072 -0
- package/package.json +7 -3
- package/src/ffmpeg.ts +63 -0
- package/src/film/beats.ts +1285 -0
- package/src/film/carry.ts +221 -0
- package/src/film/changes.ts +330 -0
- package/src/film/check.ts +996 -0
- package/src/film/clock.ts +2530 -0
- package/src/film/components-probe.ts +809 -0
- package/src/film/components.ts +1566 -0
- package/src/film/frames.ts +389 -0
- package/src/film/gallery.ts +3276 -0
- package/src/film/kit.ts +515 -0
- package/src/film/layout.ts +701 -0
- package/src/film/listen.ts +1979 -0
- package/src/film/look.ts +3829 -0
- package/src/film/materials.ts +976 -0
- package/src/film/moving.ts +248 -0
- package/src/film/part-files.ts +729 -0
- package/src/film/picture.ts +74 -0
- package/src/film/probe-text.ts +843 -0
- package/src/film/probe.ts +3456 -0
- package/src/film/provenance.ts +596 -0
- package/src/film/render.ts +2447 -0
- package/src/film/report.ts +1631 -0
- package/src/film/sheet.ts +156 -0
- package/src/film/study-declared.ts +123 -0
- package/src/film/study-picture.ts +791 -0
- package/src/film/study-sound.ts +416 -0
- package/src/film/study.ts +864 -0
- package/src/film/tuning.ts +155 -0
- package/src/film/viewer.ts +174 -0
- package/src/html/cdp.ts +575 -0
- package/src/html/server.ts +208 -0
- package/src/index.ts +202 -0
- package/src/launch-render.ts +3 -2
- package/src/math.ts +3 -3
- package/src/mjpeg-matroska.ts +228 -0
- package/src/render.ts +6 -4
- package/src/state-diff.ts +215 -0
- package/src/state-index.ts +99 -0
- package/src/types.ts +59 -1
- package/starter/PLAN.md +84 -0
- package/starter/START.md +460 -0
- package/starter/lib/anim.js +760 -0
- package/starter/lib/devices.js +1402 -0
- package/starter/lib/handoff.js +421 -0
- package/starter/lib/hud.js +1879 -0
- package/starter/lib/measure.mjs +154 -0
- package/starter/lib/moves.js +1095 -0
- package/starter/lib/palette.mjs +803 -0
- package/starter/lib/physics-seeds.mjs +198 -0
- package/starter/lib/physics.js +738 -0
- package/starter/lib/sampler.mjs +242 -0
- package/starter/lib/solid.js +727 -0
- package/starter/lib/space.js +1227 -0
- package/starter/lib/swarm.js +1398 -0
- package/starter/reference/motion.md +276 -0
- package/starter/reference/structure.md +466 -0
- package/starter/reference/travel/motion.md +433 -0
- package/starter/reference/travel/sound.md +241 -0
- package/starter/reference/travel/structure.md +518 -0
- package/starter/samples/NOTICE.txt +55 -0
- package/starter/samples/celli/celli_24_1.opus +0 -0
- package/starter/samples/celli/celli_24_3.opus +0 -0
- package/starter/samples/celli/celli_28_1.opus +0 -0
- package/starter/samples/celli/celli_28_3.opus +0 -0
- package/starter/samples/celli/celli_31_1.opus +0 -0
- package/starter/samples/celli/celli_31_3.opus +0 -0
- package/starter/samples/celli/celli_35_1.opus +0 -0
- package/starter/samples/celli/celli_35_3.opus +0 -0
- package/starter/samples/celli/celli_38_1.opus +0 -0
- package/starter/samples/celli/celli_38_3.opus +0 -0
- package/starter/samples/celli/celli_41_1.opus +0 -0
- package/starter/samples/celli/celli_41_3.opus +0 -0
- package/starter/samples/celli/celli_45_1.opus +0 -0
- package/starter/samples/celli/celli_45_3.opus +0 -0
- package/starter/samples/celli/celli_48_1.opus +0 -0
- package/starter/samples/celli/celli_48_3.opus +0 -0
- package/starter/samples/celli/celli_52_1.opus +0 -0
- package/starter/samples/celli/celli_52_3.opus +0 -0
- package/starter/samples/celli/celli_55_1.opus +0 -0
- package/starter/samples/celli/celli_55_3.opus +0 -0
- package/starter/samples/celli/celli_59_1.opus +0 -0
- package/starter/samples/celli/celli_59_3.opus +0 -0
- package/starter/samples/celli/celli_62_1.opus +0 -0
- package/starter/samples/celli/celli_62_3.opus +0 -0
- package/starter/samples/celli/celli_65_1.opus +0 -0
- package/starter/samples/celli/celli_65_3.opus +0 -0
- package/starter/samples/crash/crash_f_1.flac +0 -0
- package/starter/samples/crash/crash_fff_1.flac +0 -0
- package/starter/samples/ebass/ebass_0_x.flac +0 -0
- package/starter/samples/ebass/ebass_10_x.flac +0 -0
- package/starter/samples/ebass/ebass_11_x.flac +0 -0
- package/starter/samples/ebass/ebass_1_x.flac +0 -0
- package/starter/samples/ebass/ebass_2_x.flac +0 -0
- package/starter/samples/ebass/ebass_3_x.flac +0 -0
- package/starter/samples/ebass/ebass_4_x.flac +0 -0
- package/starter/samples/ebass/ebass_5_x.flac +0 -0
- package/starter/samples/ebass/ebass_6_x.flac +0 -0
- package/starter/samples/ebass/ebass_7_x.flac +0 -0
- package/starter/samples/ebass/ebass_8_x.flac +0 -0
- package/starter/samples/ebass/ebass_9_x.flac +0 -0
- package/starter/samples/ek_clap/ek_clap_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_2.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_1.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_2.flac +0 -0
- package/starter/samples/glock/glock_67_x.flac +0 -0
- package/starter/samples/glock/glock_72_x.flac +0 -0
- package/starter/samples/glock/glock_79_x.flac +0 -0
- package/starter/samples/glock/glock_84_x.flac +0 -0
- package/starter/samples/glock/glock_91_x.flac +0 -0
- package/starter/samples/glock/glock_96_x.flac +0 -0
- package/starter/samples/harp/harp_101_f.opus +0 -0
- package/starter/samples/harp/harp_28_f.opus +0 -0
- package/starter/samples/harp/harp_31_mp.opus +0 -0
- package/starter/samples/harp/harp_35_mf.opus +0 -0
- package/starter/samples/harp/harp_38_mf.opus +0 -0
- package/starter/samples/harp/harp_41_mf.opus +0 -0
- package/starter/samples/harp/harp_45_mf.opus +0 -0
- package/starter/samples/harp/harp_48_mf.opus +0 -0
- package/starter/samples/harp/harp_52_mf.opus +0 -0
- package/starter/samples/harp/harp_55_mf.opus +0 -0
- package/starter/samples/harp/harp_59_mf.opus +0 -0
- package/starter/samples/harp/harp_62_mf.opus +0 -0
- package/starter/samples/harp/harp_65_mf.opus +0 -0
- package/starter/samples/harp/harp_69_mf.opus +0 -0
- package/starter/samples/harp/harp_72_mf.opus +0 -0
- package/starter/samples/harp/harp_76_mf.opus +0 -0
- package/starter/samples/harp/harp_79_mf.opus +0 -0
- package/starter/samples/harp/harp_83_mf.opus +0 -0
- package/starter/samples/harp/harp_86_mf.opus +0 -0
- package/starter/samples/harp/harp_89_mf.opus +0 -0
- package/starter/samples/harp/harp_93_mf.opus +0 -0
- package/starter/samples/harp/harp_95_mf.opus +0 -0
- package/starter/samples/harp/harp_98_f.opus +0 -0
- package/starter/samples/manifest.json +2951 -0
- package/starter/samples/marimba/marimba_29_x.flac +0 -0
- package/starter/samples/marimba/marimba_36_x.flac +0 -0
- package/starter/samples/marimba/marimba_43_x.flac +0 -0
- package/starter/samples/marimba/marimba_47_x.flac +0 -0
- package/starter/samples/marimba/marimba_53_x.flac +0 -0
- package/starter/samples/marimba/marimba_60_x.flac +0 -0
- package/starter/samples/marimba/marimba_67_x.flac +0 -0
- package/starter/samples/marimba/marimba_71_x.flac +0 -0
- package/starter/samples/marimba/marimba_77_x.flac +0 -0
- package/starter/samples/marimba/marimba_84_x.flac +0 -0
- package/starter/samples/piano/piano_102_12.opus +0 -0
- package/starter/samples/piano/piano_102_16.opus +0 -0
- package/starter/samples/piano/piano_102_4.opus +0 -0
- package/starter/samples/piano/piano_102_8.opus +0 -0
- package/starter/samples/piano/piano_105_12.opus +0 -0
- package/starter/samples/piano/piano_105_16.opus +0 -0
- package/starter/samples/piano/piano_105_4.opus +0 -0
- package/starter/samples/piano/piano_105_8.opus +0 -0
- package/starter/samples/piano/piano_108_12.opus +0 -0
- package/starter/samples/piano/piano_108_16.opus +0 -0
- package/starter/samples/piano/piano_108_4.opus +0 -0
- package/starter/samples/piano/piano_108_8.opus +0 -0
- package/starter/samples/piano/piano_21_12.opus +0 -0
- package/starter/samples/piano/piano_21_16.opus +0 -0
- package/starter/samples/piano/piano_21_4.opus +0 -0
- package/starter/samples/piano/piano_21_8.opus +0 -0
- package/starter/samples/piano/piano_24_12.opus +0 -0
- package/starter/samples/piano/piano_24_16.opus +0 -0
- package/starter/samples/piano/piano_24_4.opus +0 -0
- package/starter/samples/piano/piano_24_8.opus +0 -0
- package/starter/samples/piano/piano_27_12.opus +0 -0
- package/starter/samples/piano/piano_27_16.opus +0 -0
- package/starter/samples/piano/piano_27_4.opus +0 -0
- package/starter/samples/piano/piano_27_8.opus +0 -0
- package/starter/samples/piano/piano_30_12.opus +0 -0
- package/starter/samples/piano/piano_30_16.opus +0 -0
- package/starter/samples/piano/piano_30_4.opus +0 -0
- package/starter/samples/piano/piano_30_8.opus +0 -0
- package/starter/samples/piano/piano_33_12.opus +0 -0
- package/starter/samples/piano/piano_33_16.opus +0 -0
- package/starter/samples/piano/piano_33_4.opus +0 -0
- package/starter/samples/piano/piano_33_8.opus +0 -0
- package/starter/samples/piano/piano_36_12.opus +0 -0
- package/starter/samples/piano/piano_36_16.opus +0 -0
- package/starter/samples/piano/piano_36_4.opus +0 -0
- package/starter/samples/piano/piano_36_8.opus +0 -0
- package/starter/samples/piano/piano_39_12.opus +0 -0
- package/starter/samples/piano/piano_39_16.opus +0 -0
- package/starter/samples/piano/piano_39_4.opus +0 -0
- package/starter/samples/piano/piano_39_8.opus +0 -0
- package/starter/samples/piano/piano_42_12.opus +0 -0
- package/starter/samples/piano/piano_42_16.opus +0 -0
- package/starter/samples/piano/piano_42_4.opus +0 -0
- package/starter/samples/piano/piano_42_8.opus +0 -0
- package/starter/samples/piano/piano_45_12.opus +0 -0
- package/starter/samples/piano/piano_45_16.opus +0 -0
- package/starter/samples/piano/piano_45_4.opus +0 -0
- package/starter/samples/piano/piano_45_8.opus +0 -0
- package/starter/samples/piano/piano_48_12.opus +0 -0
- package/starter/samples/piano/piano_48_16.opus +0 -0
- package/starter/samples/piano/piano_48_4.opus +0 -0
- package/starter/samples/piano/piano_48_8.opus +0 -0
- package/starter/samples/piano/piano_51_12.opus +0 -0
- package/starter/samples/piano/piano_51_16.opus +0 -0
- package/starter/samples/piano/piano_51_4.opus +0 -0
- package/starter/samples/piano/piano_51_8.opus +0 -0
- package/starter/samples/piano/piano_54_12.opus +0 -0
- package/starter/samples/piano/piano_54_16.opus +0 -0
- package/starter/samples/piano/piano_54_4.opus +0 -0
- package/starter/samples/piano/piano_54_8.opus +0 -0
- package/starter/samples/piano/piano_57_12.opus +0 -0
- package/starter/samples/piano/piano_57_16.opus +0 -0
- package/starter/samples/piano/piano_57_4.opus +0 -0
- package/starter/samples/piano/piano_57_8.opus +0 -0
- package/starter/samples/piano/piano_60_12.opus +0 -0
- package/starter/samples/piano/piano_60_16.opus +0 -0
- package/starter/samples/piano/piano_60_4.opus +0 -0
- package/starter/samples/piano/piano_60_8.opus +0 -0
- package/starter/samples/piano/piano_63_12.opus +0 -0
- package/starter/samples/piano/piano_63_16.opus +0 -0
- package/starter/samples/piano/piano_63_4.opus +0 -0
- package/starter/samples/piano/piano_63_8.opus +0 -0
- package/starter/samples/piano/piano_66_12.opus +0 -0
- package/starter/samples/piano/piano_66_16.opus +0 -0
- package/starter/samples/piano/piano_66_4.opus +0 -0
- package/starter/samples/piano/piano_66_8.opus +0 -0
- package/starter/samples/piano/piano_69_12.opus +0 -0
- package/starter/samples/piano/piano_69_16.opus +0 -0
- package/starter/samples/piano/piano_69_4.opus +0 -0
- package/starter/samples/piano/piano_69_8.opus +0 -0
- package/starter/samples/piano/piano_72_12.opus +0 -0
- package/starter/samples/piano/piano_72_16.opus +0 -0
- package/starter/samples/piano/piano_72_4.opus +0 -0
- package/starter/samples/piano/piano_72_8.opus +0 -0
- package/starter/samples/piano/piano_75_12.opus +0 -0
- package/starter/samples/piano/piano_75_16.opus +0 -0
- package/starter/samples/piano/piano_75_4.opus +0 -0
- package/starter/samples/piano/piano_75_8.opus +0 -0
- package/starter/samples/piano/piano_78_12.opus +0 -0
- package/starter/samples/piano/piano_78_16.opus +0 -0
- package/starter/samples/piano/piano_78_4.opus +0 -0
- package/starter/samples/piano/piano_78_8.opus +0 -0
- package/starter/samples/piano/piano_81_12.opus +0 -0
- package/starter/samples/piano/piano_81_16.opus +0 -0
- package/starter/samples/piano/piano_81_4.opus +0 -0
- package/starter/samples/piano/piano_81_8.opus +0 -0
- package/starter/samples/piano/piano_84_12.opus +0 -0
- package/starter/samples/piano/piano_84_16.opus +0 -0
- package/starter/samples/piano/piano_84_4.opus +0 -0
- package/starter/samples/piano/piano_84_8.opus +0 -0
- package/starter/samples/piano/piano_87_12.opus +0 -0
- package/starter/samples/piano/piano_87_16.opus +0 -0
- package/starter/samples/piano/piano_87_4.opus +0 -0
- package/starter/samples/piano/piano_87_8.opus +0 -0
- package/starter/samples/piano/piano_90_12.opus +0 -0
- package/starter/samples/piano/piano_90_16.opus +0 -0
- package/starter/samples/piano/piano_90_4.opus +0 -0
- package/starter/samples/piano/piano_90_8.opus +0 -0
- package/starter/samples/piano/piano_93_12.opus +0 -0
- package/starter/samples/piano/piano_93_16.opus +0 -0
- package/starter/samples/piano/piano_93_4.opus +0 -0
- package/starter/samples/piano/piano_93_8.opus +0 -0
- package/starter/samples/piano/piano_96_12.opus +0 -0
- package/starter/samples/piano/piano_96_16.opus +0 -0
- package/starter/samples/piano/piano_96_4.opus +0 -0
- package/starter/samples/piano/piano_96_8.opus +0 -0
- package/starter/samples/piano/piano_99_12.opus +0 -0
- package/starter/samples/piano/piano_99_16.opus +0 -0
- package/starter/samples/piano/piano_99_4.opus +0 -0
- package/starter/samples/piano/piano_99_8.opus +0 -0
- package/starter/samples/piano/piano_rel_102_x.opus +0 -0
- package/starter/samples/piano/piano_rel_105_x.opus +0 -0
- package/starter/samples/piano/piano_rel_108_x.opus +0 -0
- package/starter/samples/piano/piano_rel_21_x.opus +0 -0
- package/starter/samples/piano/piano_rel_24_x.opus +0 -0
- package/starter/samples/piano/piano_rel_27_x.opus +0 -0
- package/starter/samples/piano/piano_rel_30_x.opus +0 -0
- package/starter/samples/piano/piano_rel_33_x.opus +0 -0
- package/starter/samples/piano/piano_rel_36_x.opus +0 -0
- package/starter/samples/piano/piano_rel_39_x.opus +0 -0
- package/starter/samples/piano/piano_rel_42_x.opus +0 -0
- package/starter/samples/piano/piano_rel_45_x.opus +0 -0
- package/starter/samples/piano/piano_rel_48_x.opus +0 -0
- package/starter/samples/piano/piano_rel_51_x.opus +0 -0
- package/starter/samples/piano/piano_rel_54_x.opus +0 -0
- package/starter/samples/piano/piano_rel_57_x.opus +0 -0
- package/starter/samples/piano/piano_rel_60_x.opus +0 -0
- package/starter/samples/piano/piano_rel_63_x.opus +0 -0
- package/starter/samples/piano/piano_rel_66_x.opus +0 -0
- package/starter/samples/piano/piano_rel_69_x.opus +0 -0
- package/starter/samples/piano/piano_rel_72_x.opus +0 -0
- package/starter/samples/piano/piano_rel_75_x.opus +0 -0
- package/starter/samples/piano/piano_rel_78_x.opus +0 -0
- package/starter/samples/piano/piano_rel_81_x.opus +0 -0
- package/starter/samples/piano/piano_rel_84_x.opus +0 -0
- package/starter/samples/piano/piano_rel_87_x.opus +0 -0
- package/starter/samples/piano/piano_rel_90_x.opus +0 -0
- package/starter/samples/piano/piano_rel_93_x.opus +0 -0
- package/starter/samples/piano/piano_rel_96_x.opus +0 -0
- package/starter/samples/piano/piano_rel_99_x.opus +0 -0
- package/starter/samples/pizz/pizz_24_2.flac +0 -0
- package/starter/samples/pizz/pizz_28_2.flac +0 -0
- package/starter/samples/pizz/pizz_31_2.flac +0 -0
- package/starter/samples/pizz/pizz_35_2.flac +0 -0
- package/starter/samples/pizz/pizz_38_2.flac +0 -0
- package/starter/samples/pizz/pizz_41_2.flac +0 -0
- package/starter/samples/pizz/pizz_45_2.flac +0 -0
- package/starter/samples/pizz/pizz_48_2.flac +0 -0
- package/starter/samples/pizz/pizz_52_2.flac +0 -0
- package/starter/samples/pizz/pizz_57_2.flac +0 -0
- package/starter/samples/pizz/pizz_60_2.flac +0 -0
- package/starter/samples/pizz/pizz_64_2.flac +0 -0
- package/starter/samples/pizz/pizz_67_2.flac +0 -0
- package/starter/samples/pizz/pizz_71_2.flac +0 -0
- package/starter/samples/pizz/pizz_74_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_2.flac +0 -0
- package/starter/samples/shaker/shaker_1_1.flac +0 -0
- package/starter/samples/shaker/shaker_2_1.flac +0 -0
- package/starter/samples/snap/snap_r_1.flac +0 -0
- package/starter/samples/snap/snap_r_2.flac +0 -0
- package/starter/samples/snap/snap_r_3.flac +0 -0
- package/starter/samples/snap/snap_r_4.flac +0 -0
- package/starter/samples/snap/snap_r_5.flac +0 -0
- package/starter/samples/snap/snap_r_6.flac +0 -0
- package/starter/samples/tom/tom_3_1.flac +0 -0
- package/starter/samples/tom/tom_3_2.flac +0 -0
- package/starter/samples/tom/tom_4_1.flac +0 -0
- package/starter/samples/tom/tom_4_2.flac +0 -0
- package/starter/samples/vibes/vibes_41_1.opus +0 -0
- package/starter/samples/vibes/vibes_41_2.opus +0 -0
- package/starter/samples/vibes/vibes_45_1.opus +0 -0
- package/starter/samples/vibes/vibes_45_2.opus +0 -0
- package/starter/samples/vibes/vibes_48_1.opus +0 -0
- package/starter/samples/vibes/vibes_48_2.opus +0 -0
- package/starter/samples/vibes/vibes_52_1.opus +0 -0
- package/starter/samples/vibes/vibes_52_2.opus +0 -0
- package/starter/samples/vibes/vibes_55_1.opus +0 -0
- package/starter/samples/vibes/vibes_55_2.opus +0 -0
- package/starter/samples/vibes/vibes_59_1.opus +0 -0
- package/starter/samples/vibes/vibes_59_2.opus +0 -0
- package/starter/samples/vibes/vibes_62_1.opus +0 -0
- package/starter/samples/vibes/vibes_62_2.opus +0 -0
- package/starter/samples/vibes/vibes_65_1.opus +0 -0
- package/starter/samples/vibes/vibes_65_2.opus +0 -0
- package/starter/samples/vibes/vibes_69_1.opus +0 -0
- package/starter/samples/vibes/vibes_69_2.opus +0 -0
- package/starter/samples/vibes/vibes_72_1.opus +0 -0
- package/starter/samples/vibes/vibes_72_2.opus +0 -0
- package/starter/samples/vibes/vibes_76_1.opus +0 -0
- package/starter/samples/vibes/vibes_76_2.opus +0 -0
- package/starter/samples/violas/violas_36_1.opus +0 -0
- package/starter/samples/violas/violas_36_2.opus +0 -0
- package/starter/samples/violas/violas_38_1.opus +0 -0
- package/starter/samples/violas/violas_38_2.opus +0 -0
- package/starter/samples/violas/violas_40_1.opus +0 -0
- package/starter/samples/violas/violas_40_2.opus +0 -0
- package/starter/samples/violas/violas_43_1.opus +0 -0
- package/starter/samples/violas/violas_43_2.opus +0 -0
- package/starter/samples/violas/violas_47_1.opus +0 -0
- package/starter/samples/violas/violas_47_2.opus +0 -0
- package/starter/samples/violas/violas_50_1.opus +0 -0
- package/starter/samples/violas/violas_50_2.opus +0 -0
- package/starter/samples/violas/violas_53_1.opus +0 -0
- package/starter/samples/violas/violas_53_2.opus +0 -0
- package/starter/samples/violas/violas_57_1.opus +0 -0
- package/starter/samples/violas/violas_57_2.opus +0 -0
- package/starter/samples/violas/violas_60_1.opus +0 -0
- package/starter/samples/violas/violas_60_2.opus +0 -0
- package/starter/samples/violas/violas_64_1.opus +0 -0
- package/starter/samples/violas/violas_64_2.opus +0 -0
- package/starter/samples/violas/violas_67_1.opus +0 -0
- package/starter/samples/violas/violas_67_2.opus +0 -0
- package/starter/samples/violas/violas_71_1.opus +0 -0
- package/starter/samples/violas/violas_71_2.opus +0 -0
- package/starter/samples/violas/violas_74_1.opus +0 -0
- package/starter/samples/violas/violas_74_2.opus +0 -0
- package/starter/samples/violins/violins_43_1.opus +0 -0
- package/starter/samples/violins/violins_43_2.opus +0 -0
- package/starter/samples/violins/violins_45_1.opus +0 -0
- package/starter/samples/violins/violins_45_2.opus +0 -0
- package/starter/samples/violins/violins_47_1.opus +0 -0
- package/starter/samples/violins/violins_47_2.opus +0 -0
- package/starter/samples/violins/violins_50_1.opus +0 -0
- package/starter/samples/violins/violins_50_2.opus +0 -0
- package/starter/samples/violins/violins_54_1.opus +0 -0
- package/starter/samples/violins/violins_54_2.opus +0 -0
- package/starter/samples/violins/violins_57_1.opus +0 -0
- package/starter/samples/violins/violins_57_2.opus +0 -0
- package/starter/samples/violins/violins_60_1.opus +0 -0
- package/starter/samples/violins/violins_60_2.opus +0 -0
- package/starter/samples/violins/violins_64_1.opus +0 -0
- package/starter/samples/violins/violins_64_2.opus +0 -0
- package/starter/samples/violins/violins_67_1.opus +0 -0
- package/starter/samples/violins/violins_67_2.opus +0 -0
- package/starter/samples/violins/violins_71_1.opus +0 -0
- package/starter/samples/violins/violins_71_2.opus +0 -0
- package/starter/samples/violins/violins_74_1.opus +0 -0
- package/starter/samples/violins/violins_74_2.opus +0 -0
- package/starter/samples/woodblock/woodblock_f_1.flac +0 -0
- package/starter/samples/woodblock/woodblock_f_2.flac +0 -0
package/kit/seams.js
ADDED
|
@@ -0,0 +1,1006 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Seams for a film page — open-take's film kit. How one scene hands over to
|
|
3
|
+
// the next, as plain functions of time: give one the film's time t and the
|
|
4
|
+
// moment of the cut, read back where each side is, how big, how faint, how
|
|
5
|
+
// blurred — numbers and the CSS for them. Nothing here owns an element or
|
|
6
|
+
// keeps state, so a frame rendered twice or out of order comes out the same
|
|
7
|
+
// (`apply` at the bottom writes one side onto an element, for a page that
|
|
8
|
+
// wants it written).
|
|
9
|
+
//
|
|
10
|
+
// - a cut on the curve: the outgoing scene leaves on an accelerating curve,
|
|
11
|
+
// the cut falls at its fastest frame, the incoming one arrives at the
|
|
12
|
+
// same speed in the same direction and brakes — whole scenes (`curve`) or
|
|
13
|
+
// word by word (`waterfall`);
|
|
14
|
+
// - one strip: both scenes on one mover a frame apart, whipped past
|
|
15
|
+
// (`whip`) — the speed across the seam is the same by construction;
|
|
16
|
+
// - a swap in depth: the scene flies at the lens into blur, the next comes
|
|
17
|
+
// out of the same blur (`depth`, and `inverse` for a payoff); one line of
|
|
18
|
+
// text becoming another on one curve, split at its fastest point
|
|
19
|
+
// (`matchText`);
|
|
20
|
+
// - a card that grows into its panel while the parts both share move to
|
|
21
|
+
// their new places at their own size, not stretched (`morph`);
|
|
22
|
+
// - one card out of a grid becomes the scene while the rest fly outward
|
|
23
|
+
// (`parallax`), or the scene shrinks back into its tile (`reverse`);
|
|
24
|
+
// - a hard cut on purpose: a small push on both sides and a flash
|
|
25
|
+
// (`pushCut`), or the outgoing frame darkened for three frames (`dipCut`).
|
|
26
|
+
//
|
|
27
|
+
// `seams(tl, list)` names the seam at each boundary between scenes and
|
|
28
|
+
// declares each as a cut on the timeline. A boundary that names none gets a
|
|
29
|
+
// cut on the curve; one that says "cut" is a hard cut, on purpose.
|
|
30
|
+
//
|
|
31
|
+
// The numbers come from launch films measured frame by frame: HyperFrames'
|
|
32
|
+
// cut catalog and its registry components (github.com/heygen-com/hyperframes,
|
|
33
|
+
// Apache-2.0) and the saas-motion-kit transition atlas
|
|
34
|
+
// (github.com/Sylla431/saas-motion-kit, MIT), each re-derived here, none
|
|
35
|
+
// copied; where a default comes from is said beside it. None of them is a
|
|
36
|
+
// style: change any per call.
|
|
37
|
+
//
|
|
38
|
+
// Text stays sharp: a side at rest gets `transform: none` and `filter: none`
|
|
39
|
+
// (a layer left scaled or filtered is rastered once and stays soft); a scene
|
|
40
|
+
// that has to grow is laid out at its full size and scaled down into the
|
|
41
|
+
// move, never a small copy scaled up; blur peaks where the swap happens, the
|
|
42
|
+
// same on both sides of it. The master's shutter (film render) already
|
|
43
|
+
// smears what moves fast, so the blur here is only what a move needs at rest
|
|
44
|
+
// speed: a whip is left to the shutter unless asked.
|
|
45
|
+
//
|
|
46
|
+
// import { curve, seams, apply } from "./kit/seams.js";
|
|
47
|
+
// const c = curve(t, 6.0, { dir: "left" }); // { a, b, speed }
|
|
48
|
+
// apply(sceneA, c.a); apply(sceneB, c.b);
|
|
49
|
+
// // or name every boundary once:
|
|
50
|
+
// const s = seams(tl, [
|
|
51
|
+
// { at: 6.0, from: "#intro", to: "#map" }, // nothing named: on the curve
|
|
52
|
+
// { at: 12.4, from: "#map", to: "#table", kind: "whip", dir: "up" },
|
|
53
|
+
// { at: 18.0, from: "#table", to: "#end", kind: "cut" },
|
|
54
|
+
// ], { view: { width: 1920, height: 1080 } });
|
|
55
|
+
// window.__render = (t) => { s.apply(t); };
|
|
56
|
+
|
|
57
|
+
/** @typedef {{ x: number, y: number }} Pt a point, in CSS px */
|
|
58
|
+
/** @typedef {{ x: number, y: number, w?: number, h?: number, width?: number, height?: number, r?: number }} RectLike a Rect ({ x, y, w, h, r }) or a kit Box ({ x, y, width, height }) */
|
|
59
|
+
/** @typedef {{ width: number, height: number }} View the picture's size */
|
|
60
|
+
/**
|
|
61
|
+
* One side of a seam at one instant.
|
|
62
|
+
* @typedef {object} Side
|
|
63
|
+
* @property {boolean} visible whether it is on screen at all
|
|
64
|
+
* @property {number} x offset from its place (px)
|
|
65
|
+
* @property {number} y
|
|
66
|
+
* @property {number} scale about `origin` (1: its own size)
|
|
67
|
+
* @property {number} opacity
|
|
68
|
+
* @property {number} blur Gaussian blur (px); 0 at rest
|
|
69
|
+
* @property {"x" | "y" | null} blurAxis blur along one axis only (a whip), or both
|
|
70
|
+
* @property {number} brightness 1: as it is
|
|
71
|
+
* @property {string} transform CSS; "none" when it is at rest
|
|
72
|
+
* @property {string} filter CSS; "none" when nothing is blurred or dimmed
|
|
73
|
+
* (an axis blur needs an SVG filter: `apply` makes one; see there)
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
// --- small helpers ----------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
/** @param {number} x */
|
|
79
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
80
|
+
/** @param {number} a @param {number} b @param {number} p */
|
|
81
|
+
const lerp = (a, b, p) => a + (b - a) * p;
|
|
82
|
+
/** progress through [start, start + dur], 0 before, 1 after @param {number} t @param {number} start @param {number} dur */
|
|
83
|
+
const prog = (t, start, dur) => (dur > 0 ? clamp01((t - start) / dur) : t >= start ? 1 : 0);
|
|
84
|
+
/** a number for CSS @param {number} v @param {number} [d] */
|
|
85
|
+
const f = (v, d = 3) => +v.toFixed(d);
|
|
86
|
+
|
|
87
|
+
/** eases by name: `in(n)` is pⁿ (GSAP's power3.in is in(4)), `out(n)` and
|
|
88
|
+
* `inOut(n)` its mirror and its two halves, an exponential ease-out,
|
|
89
|
+
* GSAP's back.out, a CSS cubic-bezier */
|
|
90
|
+
export const ease = {
|
|
91
|
+
/** @param {number} n the exponent @returns {(p: number) => number} */
|
|
92
|
+
in: (n) => (p) => clamp01(p) ** n,
|
|
93
|
+
/** @param {number} n @returns {(p: number) => number} */
|
|
94
|
+
out: (n) => (p) => 1 - (1 - clamp01(p)) ** n,
|
|
95
|
+
/** @param {number} n @returns {(p: number) => number} */
|
|
96
|
+
inOut: (n) => (p) => {
|
|
97
|
+
const x = clamp01(p);
|
|
98
|
+
return x < 0.5 ? 2 ** (n - 1) * x ** n : 1 - (-2 * x + 2) ** n / 2;
|
|
99
|
+
},
|
|
100
|
+
/** 1 − 2^(−10p), set to land exactly on 1 @param {number} p */
|
|
101
|
+
expoOut: (p) => {
|
|
102
|
+
const x = clamp01(p);
|
|
103
|
+
return x >= 1 ? 1 : (1 - 2 ** (-10 * x)) / (1 - 2 ** -10);
|
|
104
|
+
},
|
|
105
|
+
/** GSAP's back.out(c): past 1 and back; c 0.7 peaks at ≈ 1.0177 of the travel
|
|
106
|
+
* @param {number} [c] @returns {(p: number) => number} */
|
|
107
|
+
backOut:
|
|
108
|
+
(c = 0.7) =>
|
|
109
|
+
(p) => {
|
|
110
|
+
const x = clamp01(p) - 1;
|
|
111
|
+
return 1 + (c + 1) * x * x * x + c * x * x;
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* A CSS cubic-bezier(x1, y1, x2, y2), solved for x by Newton's method then
|
|
115
|
+
* bisection — what a browser does.
|
|
116
|
+
* @param {number} x1 @param {number} y1 @param {number} x2 @param {number} y2
|
|
117
|
+
* @returns {(p: number) => number}
|
|
118
|
+
*/
|
|
119
|
+
bezier: (x1, y1, x2, y2) => {
|
|
120
|
+
/** @param {number} u @param {number} a @param {number} b */
|
|
121
|
+
const at = (u, a, b) => 3 * a * u * (1 - u) ** 2 + 3 * b * u * u * (1 - u) + u ** 3;
|
|
122
|
+
/** @param {number} u @param {number} a @param {number} b */
|
|
123
|
+
const slope = (u, a, b) =>
|
|
124
|
+
3 * a * (1 - u) ** 2 + 6 * (b - a) * u * (1 - u) + 3 * (1 - b) * u * u;
|
|
125
|
+
return (p) => {
|
|
126
|
+
const x = clamp01(p);
|
|
127
|
+
if (x === 0 || x === 1) return x;
|
|
128
|
+
let u = x;
|
|
129
|
+
for (let i = 0; i < 8; i++) {
|
|
130
|
+
const d = slope(u, x1, x2);
|
|
131
|
+
if (Math.abs(d) < 1e-7) break;
|
|
132
|
+
u -= (at(u, x1, x2) - x) / d;
|
|
133
|
+
}
|
|
134
|
+
if (!(u >= 0 && u <= 1) || Math.abs(at(u, x1, x2) - x) > 1e-7) {
|
|
135
|
+
let lo = 0;
|
|
136
|
+
let hi = 1;
|
|
137
|
+
u = x;
|
|
138
|
+
for (let i = 0; i < 60; i++) {
|
|
139
|
+
if (at(u, x1, x2) < x) lo = u;
|
|
140
|
+
else hi = u;
|
|
141
|
+
u = (lo + hi) / 2;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return at(u, y1, y2);
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** a direction word or a vector, as a unit vector: where the outgoing scene goes */
|
|
150
|
+
/** @param {"left" | "right" | "up" | "down" | Pt} dir @returns {Pt} */
|
|
151
|
+
function unit(dir) {
|
|
152
|
+
if (dir === "left") return { x: -1, y: 0 };
|
|
153
|
+
if (dir === "right") return { x: 1, y: 0 };
|
|
154
|
+
if (dir === "up") return { x: 0, y: -1 };
|
|
155
|
+
if (dir === "down") return { x: 0, y: 1 };
|
|
156
|
+
if (dir && Number.isFinite(dir.x) && Number.isFinite(dir.y)) {
|
|
157
|
+
const l = Math.hypot(dir.x, dir.y);
|
|
158
|
+
if (l > 0) return { x: dir.x / l, y: dir.y / l };
|
|
159
|
+
}
|
|
160
|
+
throw new Error(
|
|
161
|
+
`seams: dir is "left", "right", "up", "down" or { x, y } (got ${JSON.stringify(dir)})`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** a Rect from a Rect or a kit Box */
|
|
166
|
+
/** @param {RectLike} b */
|
|
167
|
+
function rectOf(b) {
|
|
168
|
+
return { x: b.x, y: b.y, w: b.w ?? b.width ?? 0, h: b.h ?? b.height ?? 0, r: b.r ?? 0 };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A side from its numbers: the CSS strings follow, and a side that has come
|
|
173
|
+
* to rest gets "none" for both, so the browser draws it from its own layout.
|
|
174
|
+
* @param {Partial<Side> & { visible: boolean }} s
|
|
175
|
+
* @returns {Side}
|
|
176
|
+
*/
|
|
177
|
+
export function side(s) {
|
|
178
|
+
const x = s.x ?? 0;
|
|
179
|
+
const y = s.y ?? 0;
|
|
180
|
+
const scale = s.scale ?? 1;
|
|
181
|
+
const blur = Math.max(0, s.blur ?? 0);
|
|
182
|
+
const brightness = s.brightness ?? 1;
|
|
183
|
+
const moved = Math.abs(x) > 1e-3 || Math.abs(y) > 1e-3 || Math.abs(scale - 1) > 1e-5;
|
|
184
|
+
const transform = moved ? `translate(${f(x)}px, ${f(y)}px) scale(${f(scale, 5)})` : "none";
|
|
185
|
+
/** @type {string[]} */
|
|
186
|
+
const parts = [];
|
|
187
|
+
if (blur >= 0.05 && !s.blurAxis) parts.push(`blur(${f(blur, 2)}px)`);
|
|
188
|
+
if (Math.abs(brightness - 1) > 1e-3) parts.push(`brightness(${f(brightness)})`);
|
|
189
|
+
return {
|
|
190
|
+
visible: s.visible,
|
|
191
|
+
x,
|
|
192
|
+
y,
|
|
193
|
+
scale,
|
|
194
|
+
opacity: clamp01(s.opacity ?? 1),
|
|
195
|
+
blur: blur >= 0.05 ? blur : 0,
|
|
196
|
+
blurAxis: blur >= 0.05 ? (s.blurAxis ?? null) : null,
|
|
197
|
+
brightness,
|
|
198
|
+
transform,
|
|
199
|
+
filter: parts.length ? parts.join(" ") : "none",
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** a side that is off screen */
|
|
204
|
+
const gone = () => side({ visible: false, opacity: 0 });
|
|
205
|
+
/** a side at rest, on screen */
|
|
206
|
+
const still = () => side({ visible: true });
|
|
207
|
+
|
|
208
|
+
// --- a cut on the curve -------------------------------------------------------
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A cut on the curve: the outgoing scene accelerates away (ease-in, p⁴) and
|
|
212
|
+
* the cut falls on its fastest frame; the incoming one arrives from the far
|
|
213
|
+
* side moving the same way at the same speed and brakes (ease-out, the same
|
|
214
|
+
* curve mirrored). Both speeds at the cut are 4·dist/dur, so the eye reads
|
|
215
|
+
* one move with the picture changing inside it. The outgoing scene is gone by
|
|
216
|
+
* the cut while it is still plainly accelerating — nothing has to reach the
|
|
217
|
+
* edge of the frame — and the incoming one starts at `enter` opacity.
|
|
218
|
+
* Defaults: 230 px (12 % of 1920) over 0.30 s each side, a 0.18 s fade, the
|
|
219
|
+
* incoming at 0.35 — HyperFrames' cut catalog, "cut-the-curve", measured on
|
|
220
|
+
* its launch films: ≈ 3070 px/s at the cut.
|
|
221
|
+
* Translate only, no blur: what is on either side is sharp the moment it stops.
|
|
222
|
+
* @param {number} t
|
|
223
|
+
* @param {number} at the cut: the outgoing side's last frame is before it
|
|
224
|
+
* @param {{ dir?: "left" | "right" | "up" | "down" | Pt, dist?: number, dur?: number, fade?: number, enter?: number }} [o]
|
|
225
|
+
* dir: the way both travel (default "left"); dist (px), dur (s each side),
|
|
226
|
+
* fade (s the outgoing takes to go, ending at the cut), enter (the incoming
|
|
227
|
+
* side's first opacity)
|
|
228
|
+
* @returns {{ a: Side, b: Side, speed: number, p: number }} speed: px/s at the cut
|
|
229
|
+
*/
|
|
230
|
+
export function curve(t, at, o = {}) {
|
|
231
|
+
const { dir = "left", dist = 230, dur = 0.3, fade = 0.18, enter = 0.35 } = o;
|
|
232
|
+
const u = unit(dir);
|
|
233
|
+
const speed = dur > 0 ? (4 * dist) / dur : Number.POSITIVE_INFINITY;
|
|
234
|
+
if (t < at) {
|
|
235
|
+
const e = ease.in(4)(prog(t, at - dur, dur));
|
|
236
|
+
const q = prog(t, at - fade, fade);
|
|
237
|
+
return {
|
|
238
|
+
a: side({ visible: true, x: u.x * dist * e, y: u.y * dist * e, opacity: 1 - q }),
|
|
239
|
+
b: gone(),
|
|
240
|
+
speed,
|
|
241
|
+
p: e,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const q = prog(t, at, dur);
|
|
245
|
+
if (q >= 1) return { a: gone(), b: still(), speed, p: 1 };
|
|
246
|
+
const e = ease.out(4)(q);
|
|
247
|
+
return {
|
|
248
|
+
a: gone(),
|
|
249
|
+
b: side({
|
|
250
|
+
visible: true,
|
|
251
|
+
x: -u.x * dist * (1 - e),
|
|
252
|
+
y: -u.y * dist * (1 - e),
|
|
253
|
+
opacity: lerp(enter, 1, prog(t, at, fade)),
|
|
254
|
+
}),
|
|
255
|
+
speed,
|
|
256
|
+
p: e,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The cut on the curve word by word: the outgoing line's words leave one
|
|
262
|
+
* after another in reading order, each on its own ease-in, the last of them
|
|
263
|
+
* gone exactly at the cut; the incoming words cascade in from the far side,
|
|
264
|
+
* each on an ease-out, the gaps between them shrinking (a waterfall).
|
|
265
|
+
* Defaults (HyperFrames' cut catalog, "waterfall"): out 0.34 s a word, a
|
|
266
|
+
* 0.18 s fade, 0.022 s apart; in 0.30 s a word, the first gap 0.05 s, each
|
|
267
|
+
* next ×0.84; 230 px.
|
|
268
|
+
* @param {number} t
|
|
269
|
+
* @param {number} at the cut
|
|
270
|
+
* @param {number} nOut how many words leave
|
|
271
|
+
* @param {number} nIn how many arrive
|
|
272
|
+
* @param {{ dir?: "left" | "right" | "up" | "down" | Pt, dist?: number, outDur?: number, inDur?: number, fade?: number, stagger?: number, gap?: number, shrink?: number }} [o]
|
|
273
|
+
* @returns {{ out: Side[], in: Side[], end: number }} end: when the last word has landed
|
|
274
|
+
*/
|
|
275
|
+
export function waterfall(t, at, nOut, nIn, o = {}) {
|
|
276
|
+
const {
|
|
277
|
+
dir = "left",
|
|
278
|
+
dist = 230,
|
|
279
|
+
outDur = 0.34,
|
|
280
|
+
inDur = 0.3,
|
|
281
|
+
fade = 0.18,
|
|
282
|
+
stagger = 0.022,
|
|
283
|
+
gap = 0.05,
|
|
284
|
+
shrink = 0.84,
|
|
285
|
+
} = o;
|
|
286
|
+
const u = unit(dir);
|
|
287
|
+
const out = [];
|
|
288
|
+
for (let i = 0; i < nOut; i++) {
|
|
289
|
+
const start = at - outDur - (nOut - 1 - i) * stagger;
|
|
290
|
+
if (t >= start + outDur) {
|
|
291
|
+
out.push(gone());
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const e = ease.in(4)(prog(t, start, outDur));
|
|
295
|
+
const q = prog(t, start + outDur - fade, fade);
|
|
296
|
+
out.push(side({ visible: true, x: u.x * dist * e, y: u.y * dist * e, opacity: 1 - q }));
|
|
297
|
+
}
|
|
298
|
+
const inn = [];
|
|
299
|
+
let start = at;
|
|
300
|
+
let g = gap;
|
|
301
|
+
for (let i = 0; i < nIn; i++) {
|
|
302
|
+
if (t < start) inn.push(gone());
|
|
303
|
+
else {
|
|
304
|
+
const e = ease.out(4)(prog(t, start, inDur));
|
|
305
|
+
inn.push(
|
|
306
|
+
side({
|
|
307
|
+
visible: true,
|
|
308
|
+
x: -u.x * dist * (1 - e),
|
|
309
|
+
y: -u.y * dist * (1 - e),
|
|
310
|
+
opacity: prog(t, start, fade),
|
|
311
|
+
}),
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
if (i < nIn - 1) {
|
|
315
|
+
start += g;
|
|
316
|
+
g *= shrink;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return { out, in: inn, end: start + inDur };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// --- one strip ----------------------------------------------------------------
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* A whip: both scenes ride one strip, the incoming docked a frame's width
|
|
326
|
+
* (or height) beyond the outgoing, and the strip moves one frame on one
|
|
327
|
+
* ease-in-out — so the speed across the seam is the same on both sides by
|
|
328
|
+
* construction, and there is no swap at all. The cut is the strip's middle,
|
|
329
|
+
* its fastest moment: 3·width/dur (≈ 10 500 px/s at 1920 px over 0.55 s, the
|
|
330
|
+
* HyperFrames whip-pan component's default; its films measured 0.13–0.3 s of
|
|
331
|
+
* smear). The master's shutter smears it along its path already; `blur`
|
|
332
|
+
* adds a blur along that axis only, peaking with the speed — for a draft,
|
|
333
|
+
* or a heavier smear. `edge` is where the two scenes meet, along the axis,
|
|
334
|
+
* in frame px: a hairline there is the seam drawn.
|
|
335
|
+
* @param {number} t
|
|
336
|
+
* @param {number} at the middle of the whip
|
|
337
|
+
* @param {View} view
|
|
338
|
+
* @param {{ dir?: "left" | "right" | "up" | "down", dur?: number, blur?: number, power?: number }} [o]
|
|
339
|
+
* dir: the way the strip moves (default "left": the next scene comes in
|
|
340
|
+
* from the right); dur (default 0.55 s); blur (px at the fastest point,
|
|
341
|
+
* default 0); power: the in-out's exponent (default 3)
|
|
342
|
+
* @returns {{ a: Side, b: Side, speed: number, edge: number | null, p: number }}
|
|
343
|
+
*/
|
|
344
|
+
export function whip(t, at, view, o = {}) {
|
|
345
|
+
const { dir = "left", dur = 0.55, blur = 0, power = 3 } = o;
|
|
346
|
+
const u = unit(dir);
|
|
347
|
+
const horiz = u.x !== 0;
|
|
348
|
+
const W = horiz ? view.width : view.height;
|
|
349
|
+
const s = horiz ? u.x : u.y;
|
|
350
|
+
const start = at - dur / 2;
|
|
351
|
+
const speed = dur > 0 ? (power * W) / dur : Number.POSITIVE_INFINITY;
|
|
352
|
+
if (t < start) return { a: still(), b: gone(), speed, edge: null, p: 0 };
|
|
353
|
+
const p = prog(t, start, dur);
|
|
354
|
+
if (p >= 1) return { a: gone(), b: still(), speed, edge: null, p: 1 };
|
|
355
|
+
const e = ease.inOut(power)(p);
|
|
356
|
+
// the in-out's speed against its fastest, 0 → 1 → 0
|
|
357
|
+
const h = 1e-4;
|
|
358
|
+
const v =
|
|
359
|
+
(ease.inOut(power)(Math.min(1, p + h)) - ease.inOut(power)(Math.max(0, p - h))) /
|
|
360
|
+
(Math.min(1, p + h) - Math.max(0, p - h));
|
|
361
|
+
const sigma = blur * clamp01(v / power);
|
|
362
|
+
const axis = horiz ? "x" : "y";
|
|
363
|
+
const along = /** @param {number} d */ (d) => (horiz ? { x: d, y: 0 } : { x: 0, y: d });
|
|
364
|
+
const da = s * W * e;
|
|
365
|
+
const db = s * W * e - s * W;
|
|
366
|
+
return {
|
|
367
|
+
a: side({ visible: Math.abs(da) < W, ...along(da), blur: sigma, blurAxis: axis }),
|
|
368
|
+
b: side({ visible: Math.abs(db) < W, ...along(db), blur: sigma, blurAxis: axis }),
|
|
369
|
+
speed,
|
|
370
|
+
edge: s < 0 ? W + da : da,
|
|
371
|
+
p: e,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// --- a swap in depth ------------------------------------------------------------
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* A swap in depth: the outgoing scene flies at the lens — grows, blurs,
|
|
379
|
+
* fades — and on the cut the incoming one comes out of the same blur from
|
|
380
|
+
* smaller and settles (a zoom-through); `inverse` runs it the other way for
|
|
381
|
+
* a payoff — the old recedes, the new arrives oversized and retracts. The
|
|
382
|
+
* blur at the cut is the same on both sides, so the eye does not see the
|
|
383
|
+
* swap. Defaults (HyperFrames' cut catalog, "zoom-through"): out 0.2 s to
|
|
384
|
+
* ×1.2 with blur to 10 px on an ease-in (p⁴), opacity to 0.15 on a straight
|
|
385
|
+
* line; in 0.5 s from ×0.75, blur 10, opacity 0.15 on an exponential ease-out.
|
|
386
|
+
* 10 px is for text-sized subjects ("at 20 px text smears"); 18–20 for a full
|
|
387
|
+
* frame. Put it on the scene's wrapper, transform-origin at its centre (or
|
|
388
|
+
* where `origin` says); the incoming scene is laid out at its full size and
|
|
389
|
+
* grows into it from smaller (inverse: from larger, briefly, in blur).
|
|
390
|
+
* @param {number} t
|
|
391
|
+
* @param {number} at the cut
|
|
392
|
+
* @param {{ inverse?: boolean, outDur?: number, inDur?: number, outScale?: number, inScale?: number, blur?: number, dim?: number }} [o]
|
|
393
|
+
* @returns {{ a: Side, b: Side, p: number }}
|
|
394
|
+
*/
|
|
395
|
+
export function depth(t, at, o = {}) {
|
|
396
|
+
const { inverse = false, outDur = 0.2, inDur = 0.5, blur = 10, dim = 0.15 } = o;
|
|
397
|
+
const outScale = o.outScale ?? (inverse ? 0.8 : 1.2);
|
|
398
|
+
const inScale = o.inScale ?? (inverse ? 1.25 : 0.75);
|
|
399
|
+
if (t < at) {
|
|
400
|
+
const q = prog(t, at - outDur, outDur);
|
|
401
|
+
const e = ease.in(4)(q);
|
|
402
|
+
return {
|
|
403
|
+
a: side({
|
|
404
|
+
visible: true,
|
|
405
|
+
scale: lerp(1, outScale, e),
|
|
406
|
+
blur: blur * e,
|
|
407
|
+
opacity: lerp(1, dim, q),
|
|
408
|
+
}),
|
|
409
|
+
b: gone(),
|
|
410
|
+
p: e,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
const q = prog(t, at, inDur);
|
|
414
|
+
if (q >= 1) return { a: gone(), b: still(), p: 1 };
|
|
415
|
+
const e = ease.expoOut(q);
|
|
416
|
+
return {
|
|
417
|
+
a: gone(),
|
|
418
|
+
b: side({
|
|
419
|
+
visible: true,
|
|
420
|
+
scale: lerp(inScale, 1, e),
|
|
421
|
+
blur: blur * (1 - e),
|
|
422
|
+
opacity: lerp(dim, 1, e),
|
|
423
|
+
}),
|
|
424
|
+
p: e,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** the one curve of a text match cut: cubic-bezier(.85, 0, .15, 1) — slow out,
|
|
429
|
+
* very fast through the middle, slow in (HyperFrames' text-match-cut,
|
|
430
|
+
* measured at 60 fps on the tutorial it credits) */
|
|
431
|
+
const MATCH_EASE = ease.bezier(0.85, 0, 0.15, 1);
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* One line of text becomes another on one curve: the whole move is one ease,
|
|
435
|
+
* split at its middle — its fastest point — where the outgoing line is
|
|
436
|
+
* swapped for the incoming on the same frame, no crossfade. The outgoing line
|
|
437
|
+
* rides the first half, the incoming the second, so the motion runs on
|
|
438
|
+
* across the swap.
|
|
439
|
+
* "zoom": the outgoing grows from 1 to `k`, the incoming grows from 1/k to
|
|
440
|
+
* 1 — one push in, in log space (k < 1: one pull back); defaults k 1.7:
|
|
441
|
+
* the incoming starts at ≈ 0.59, built at its full size;
|
|
442
|
+
* "slide": the outgoing moves `dist` px, the incoming arrives from `dist`
|
|
443
|
+
* px the other side of its place and moves the same way;
|
|
444
|
+
* "track": letter-spacing runs from `from` to `to` em on the one curve, the
|
|
445
|
+
* incoming taking over at the middle — read `spacing` (defaults +0.22 →
|
|
446
|
+
* −0.05 em, the values it was measured at).
|
|
447
|
+
* Default 2.0 s for the whole move.
|
|
448
|
+
* @param {number} t
|
|
449
|
+
* @param {number} start
|
|
450
|
+
* @param {number} end
|
|
451
|
+
* @param {{ mode?: "zoom" | "slide" | "track", k?: number, dir?: "left" | "right" | "up" | "down" | Pt, dist?: number, from?: number, to?: number, ease?: (p: number) => number }} [o]
|
|
452
|
+
* @returns {{ a: Side, b: Side, cut: number, spacing: number | null, p: number }}
|
|
453
|
+
* cut: the time of the swap; spacing: letter-spacing in em ("track")
|
|
454
|
+
*/
|
|
455
|
+
export function matchText(t, start, end, o = {}) {
|
|
456
|
+
const { mode = "zoom", k = 1.7, dir = "left", dist = 160, from = 0.22, to = -0.05 } = o;
|
|
457
|
+
const curveOf = o.ease ?? MATCH_EASE;
|
|
458
|
+
const cut = start + (end - start) / 2;
|
|
459
|
+
const e = end > start ? curveOf(clamp01((t - start) / (end - start))) : t >= end ? 1 : 0;
|
|
460
|
+
const first = t < cut;
|
|
461
|
+
/** @param {Partial<Side>} s */
|
|
462
|
+
const on = (s) => side({ visible: true, ...s });
|
|
463
|
+
if (mode === "zoom") {
|
|
464
|
+
if (!(k > 0)) throw new Error(`matchText: k is a scale above 0 (got ${k})`);
|
|
465
|
+
// log scale runs 0 → 2·ln k over the move; each side shows it about its own rest
|
|
466
|
+
const L = 2 * Math.log(k) * e;
|
|
467
|
+
return first
|
|
468
|
+
? { a: on({ scale: Math.exp(L) }), b: gone(), cut, spacing: null, p: e }
|
|
469
|
+
: { a: gone(), b: on({ scale: Math.exp(L - 2 * Math.log(k)) }), cut, spacing: null, p: e };
|
|
470
|
+
}
|
|
471
|
+
if (mode === "slide") {
|
|
472
|
+
const u = unit(dir);
|
|
473
|
+
const d = 2 * dist * e;
|
|
474
|
+
return first
|
|
475
|
+
? { a: on({ x: u.x * d, y: u.y * d }), b: gone(), cut, spacing: null, p: e }
|
|
476
|
+
: {
|
|
477
|
+
a: gone(),
|
|
478
|
+
b: on({ x: u.x * (d - 2 * dist), y: u.y * (d - 2 * dist) }),
|
|
479
|
+
cut,
|
|
480
|
+
spacing: null,
|
|
481
|
+
p: e,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
if (mode === "track") {
|
|
485
|
+
const spacing = lerp(from, to, e);
|
|
486
|
+
return first
|
|
487
|
+
? { a: on({}), b: gone(), cut, spacing, p: e }
|
|
488
|
+
: { a: gone(), b: on({}), cut, spacing, p: e };
|
|
489
|
+
}
|
|
490
|
+
throw new Error(`matchText: mode is "zoom", "slide" or "track" (got ${mode})`);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// --- a card that becomes its panel ------------------------------------------------
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* A card grows into the panel it opens, and the parts both of them hold move
|
|
497
|
+
* from their place in the card to their place in the panel at their own
|
|
498
|
+
* size — the text re-flows, it does not stretch. The panel is laid out at its
|
|
499
|
+
* full size (its own element, transform-origin 0 0) and `container.transform`
|
|
500
|
+
* shrinks it onto the card and grows it back: a box interpolated in log
|
|
501
|
+
* space for the size, its corner radius with it (`container.radius`, already
|
|
502
|
+
* divided by the scale, for the element's own border-radius). For each part
|
|
503
|
+
* the two share, `part(inCard, inPanel)` gives the transform for the part's
|
|
504
|
+
* element inside the panel: it sits where it would between its two places,
|
|
505
|
+
* uniformly scaled, the panel's own scale undone. The card's own content
|
|
506
|
+
* leaves over the first `aOut` of the move, the panel's own arrives over the
|
|
507
|
+
* last `bIn`. Defaults (HyperFrames' modal-morph and card-morph-anchor): a
|
|
508
|
+
* smooth in-out, the card's content gone by 30 %, the panel's from 60 %;
|
|
509
|
+
* `snappy` lands on GSAP back.out(0.7), overshooting ≈ 1.8 % of the travel.
|
|
510
|
+
* At the end the transform is "none": the panel is its own DOM, unscaled.
|
|
511
|
+
* @param {number} t
|
|
512
|
+
* @param {number} start
|
|
513
|
+
* @param {number} end 0.6–1.2 s after start was what the films used; under 0.5 s
|
|
514
|
+
* both contents' fades do not fit
|
|
515
|
+
* @param {RectLike} from the card, in frame px
|
|
516
|
+
* @param {RectLike} to the panel, in frame px
|
|
517
|
+
* @param {{ snappy?: boolean, ease?: (p: number) => number, aOut?: number, bIn?: number }} [o]
|
|
518
|
+
*/
|
|
519
|
+
export function morph(t, start, end, from, to, o = {}) {
|
|
520
|
+
const { snappy = false, aOut = 0.3, bIn = 0.4 } = o;
|
|
521
|
+
const curveOf = o.ease ?? (snappy ? ease.backOut(0.7) : ease.inOut(3));
|
|
522
|
+
const a = rectOf(from);
|
|
523
|
+
const b = rectOf(to);
|
|
524
|
+
const q = end > start ? clamp01((t - start) / (end - start)) : t >= end ? 1 : 0;
|
|
525
|
+
const e = curveOf(q);
|
|
526
|
+
/** sizes in log space: a ten-times growth looks steady @param {number} u @param {number} v */
|
|
527
|
+
const size = (u, v) => (u > 0 && v > 0 ? u * (v / u) ** e : lerp(u, v, e));
|
|
528
|
+
const w = size(a.w, b.w);
|
|
529
|
+
const h = size(a.h, b.h);
|
|
530
|
+
const cx = lerp(a.x + a.w / 2, b.x + b.w / 2, e);
|
|
531
|
+
const cy = lerp(a.y + a.h / 2, b.y + b.h / 2, e);
|
|
532
|
+
const box = { x: cx - w / 2, y: cy - h / 2, w, h, r: lerp(a.r, b.r, e) };
|
|
533
|
+
const sx = b.w > 0 ? w / b.w : 1;
|
|
534
|
+
const sy = b.h > 0 ? h / b.h : 1;
|
|
535
|
+
const done = q >= 1;
|
|
536
|
+
const container = {
|
|
537
|
+
box,
|
|
538
|
+
sx,
|
|
539
|
+
sy,
|
|
540
|
+
transform: done
|
|
541
|
+
? "none"
|
|
542
|
+
: `translate(${f(box.x - b.x)}px, ${f(box.y - b.y)}px) scale(${f(sx, 5)}, ${f(sy, 5)})`,
|
|
543
|
+
radius: done
|
|
544
|
+
? `${f(b.r)}px`
|
|
545
|
+
: `${f(box.r / Math.max(1e-9, sx))}px / ${f(box.r / Math.max(1e-9, sy))}px`,
|
|
546
|
+
};
|
|
547
|
+
return {
|
|
548
|
+
container,
|
|
549
|
+
/** the card's own content (what the panel does not have) */
|
|
550
|
+
a: { opacity: 1 - clamp01(q / Math.max(1e-9, aOut)) },
|
|
551
|
+
/** the panel's own content (what the card did not have) */
|
|
552
|
+
b: { opacity: clamp01((q - (1 - bIn)) / Math.max(1e-9, bIn)) },
|
|
553
|
+
/**
|
|
554
|
+
* A part both hold: its box in the card and in the panel, frame px. The
|
|
555
|
+
* transform goes on the part's element inside the panel (transform-origin 0 0).
|
|
556
|
+
* @param {RectLike} inCard
|
|
557
|
+
* @param {RectLike} inPanel
|
|
558
|
+
*/
|
|
559
|
+
part(inCard, inPanel) {
|
|
560
|
+
const pa = rectOf(inCard);
|
|
561
|
+
const pb = rectOf(inPanel);
|
|
562
|
+
const want = { x: lerp(pa.x, pb.x, e), y: lerp(pa.y, pb.y, e), w: size(pa.w, pb.w) };
|
|
563
|
+
if (done) return { transform: "none", scale: 1 };
|
|
564
|
+
const g = pb.w > 0 ? want.w / pb.w : 1;
|
|
565
|
+
const kx = g / Math.max(1e-9, sx);
|
|
566
|
+
const ky = g / Math.max(1e-9, sy);
|
|
567
|
+
// its place in the panel's own (unscaled) coordinates, then moved to
|
|
568
|
+
// where it should show: frame = box + s·(local)
|
|
569
|
+
const dx = (want.x - box.x) / Math.max(1e-9, sx) - (pb.x - b.x);
|
|
570
|
+
const dy = (want.y - box.y) / Math.max(1e-9, sy) - (pb.y - b.y);
|
|
571
|
+
return {
|
|
572
|
+
transform: `translate(${f(dx)}px, ${f(dy)}px) scale(${f(kx, 5)}, ${f(ky, 5)})`,
|
|
573
|
+
scale: g,
|
|
574
|
+
};
|
|
575
|
+
},
|
|
576
|
+
p: e,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// --- one card out of a grid --------------------------------------------------------
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* One card of a grid becomes the scene: it grows until it fills the view —
|
|
584
|
+
* one scale about a fixed point, in log space, as `zoomThrough` flies — while
|
|
585
|
+
* every other card flies outward from it, shrinks and fades. `reverse` runs
|
|
586
|
+
* it back: the scene shrinks into its tile while the grid forms round it (a
|
|
587
|
+
* dolly-out). The next scene is meant to be laid out at the view's full size
|
|
588
|
+
* (`scene.transform`, transform-origin 0 0, on an element that fills the
|
|
589
|
+
* view): it is scaled down onto the tile and grows to "none" — sharp — rather
|
|
590
|
+
* than a small card scaled up; `focal.transform` is for the card's own
|
|
591
|
+
* element, if it has to be the one that grows. `radius` is the tile's corner
|
|
592
|
+
* radius on screen (it goes to 0 as it fills); `scene.radius` is that divided
|
|
593
|
+
* by the scene's scale, for its border-radius.
|
|
594
|
+
* Defaults (HyperFrames' parallax-zoom, after eBay Playbook's hero; the
|
|
595
|
+
* dolly-out from the saas-motion-kit atlas): siblings pushed 900 px per tile
|
|
596
|
+
* of distance from the card, shrunk to 0.6 and faded out by the end; a smooth
|
|
597
|
+
* in-out (2.4 s was its length; the dolly-out 1.2 s); a 16 px tile radius.
|
|
598
|
+
* @param {number} t
|
|
599
|
+
* @param {number} start
|
|
600
|
+
* @param {number} end
|
|
601
|
+
* @param {RectLike} card the card that becomes the scene, frame px
|
|
602
|
+
* @param {RectLike[]} others the rest of the grid
|
|
603
|
+
* @param {View} view
|
|
604
|
+
* @param {{ reverse?: boolean, push?: number, shrink?: number, radius?: number, ease?: (p: number) => number }} [o]
|
|
605
|
+
*/
|
|
606
|
+
export function parallax(t, start, end, card, others, view, o = {}) {
|
|
607
|
+
const { reverse = false, push = 900, shrink = 0.4, radius = 16 } = o;
|
|
608
|
+
const curveOf = o.ease ?? ease.inOut(3);
|
|
609
|
+
const c = rectOf(card);
|
|
610
|
+
const q0 = end > start ? clamp01((t - start) / (end - start)) : t >= end ? 1 : 0;
|
|
611
|
+
const e = curveOf(reverse ? 1 - q0 : q0);
|
|
612
|
+
// the scale that makes the card cover the view, and the point it grows about
|
|
613
|
+
// so its centre lands on the view's: f = (S·c − v) / (S − 1)
|
|
614
|
+
const S = Math.max(view.width / Math.max(1e-9, c.w), view.height / Math.max(1e-9, c.h));
|
|
615
|
+
const cc = { x: c.x + c.w / 2, y: c.y + c.h / 2 };
|
|
616
|
+
const v = { x: view.width / 2, y: view.height / 2 };
|
|
617
|
+
const fx = Math.abs(S - 1) < 1e-9 ? cc.x : (S * cc.x - v.x) / (S - 1);
|
|
618
|
+
const fy = Math.abs(S - 1) < 1e-9 ? cc.y : (S * cc.y - v.y) / (S - 1);
|
|
619
|
+
const s = S ** e;
|
|
620
|
+
const done = e >= 1 - 1e-9;
|
|
621
|
+
const scene = s / S;
|
|
622
|
+
const r = radius * (1 - e);
|
|
623
|
+
return {
|
|
624
|
+
focal: {
|
|
625
|
+
scale: s,
|
|
626
|
+
// for the card's own element, transform-origin 0 0: about f, in its own box
|
|
627
|
+
transform:
|
|
628
|
+
e <= 1e-9
|
|
629
|
+
? "none"
|
|
630
|
+
: `translate(${f((1 - s) * (fx - c.x))}px, ${f((1 - s) * (fy - c.y))}px) scale(${f(s, 5)})`,
|
|
631
|
+
},
|
|
632
|
+
scene: {
|
|
633
|
+
scale: scene,
|
|
634
|
+
transform: done
|
|
635
|
+
? "none"
|
|
636
|
+
: `translate(${f(fx * (1 - scene))}px, ${f(fy * (1 - scene))}px) scale(${f(scene, 5)})`,
|
|
637
|
+
radius: `${f(r / Math.max(1e-9, scene))}px`,
|
|
638
|
+
},
|
|
639
|
+
others: others.map((b) => {
|
|
640
|
+
const r2 = rectOf(b);
|
|
641
|
+
const dCol = c.w > 0 ? (r2.x + r2.w / 2 - cc.x) / c.w : 0;
|
|
642
|
+
const dRow = c.h > 0 ? (r2.y + r2.h / 2 - cc.y) / c.h : 0;
|
|
643
|
+
return side({
|
|
644
|
+
visible: e < 1 - 1e-9,
|
|
645
|
+
x: e * push * dCol,
|
|
646
|
+
y: e * push * dRow,
|
|
647
|
+
scale: 1 - shrink * e,
|
|
648
|
+
opacity: 1 - e,
|
|
649
|
+
});
|
|
650
|
+
}),
|
|
651
|
+
radius: r,
|
|
652
|
+
p: e,
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// --- a hard cut on purpose -------------------------------------------------------------
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* A hard cut that reads as meant: both sides keep pushing in — the outgoing
|
|
660
|
+
* from 1 to 1.04 on an ease-in, the incoming from 1.04/1.07 (≈ 0.972) to 1 on
|
|
661
|
+
* an ease-out, so the push runs on at the same rate across the cut and the
|
|
662
|
+
* incoming lands on its own size — and a pale flash rises in the frame
|
|
663
|
+
* before the cut and dies over two frames after it. The cut sits 5/11 of the
|
|
664
|
+
* way through the window. Defaults: Remotion's pushCut (its numbers: 1.04,
|
|
665
|
+
* 1.07, a 0.2 flash of #f5f2ed; the incoming here ends at 1, built at full
|
|
666
|
+
* size, instead of held at 1.07) over 0.36 s.
|
|
667
|
+
* @param {number} t
|
|
668
|
+
* @param {number} at the cut
|
|
669
|
+
* @param {{ dur?: number, push?: number, flash?: number, colour?: string, fps?: number }} [o]
|
|
670
|
+
* @returns {{ a: Side, b: Side, flash: { colour: string, opacity: number }, p: number }}
|
|
671
|
+
*/
|
|
672
|
+
export function pushCut(t, at, o = {}) {
|
|
673
|
+
const { dur = 0.36, push = 1.04, flash = 0.2, colour = "#f5f2ed", fps = filmFps() } = o;
|
|
674
|
+
const pre = (dur * 5) / 11;
|
|
675
|
+
const post = dur - pre;
|
|
676
|
+
const fr = 1 / fps;
|
|
677
|
+
const fl =
|
|
678
|
+
t >= at - fr && t < at
|
|
679
|
+
? flash * ((t - (at - fr)) / fr)
|
|
680
|
+
: t >= at && t < at + 2 * fr
|
|
681
|
+
? flash * (1 - (t - at) / (2 * fr))
|
|
682
|
+
: 0;
|
|
683
|
+
const fo = { colour, opacity: clamp01(fl) };
|
|
684
|
+
if (t < at) {
|
|
685
|
+
const e = ease.in(2)(prog(t, at - pre, pre));
|
|
686
|
+
return { a: side({ visible: true, scale: lerp(1, push, e) }), b: gone(), flash: fo, p: e };
|
|
687
|
+
}
|
|
688
|
+
const e = ease.out(2)(prog(t, at, post));
|
|
689
|
+
// the outgoing's push carried on as Remotion's second stage (1.04 → 1.07):
|
|
690
|
+
// the same ratio, ending on 1 instead of above it
|
|
691
|
+
const from = push / (1 + (push - 1) * 1.75);
|
|
692
|
+
return {
|
|
693
|
+
a: gone(),
|
|
694
|
+
b: side({ visible: true, scale: lerp(from, 1, e) }),
|
|
695
|
+
flash: fo,
|
|
696
|
+
p: e,
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/** the rate the film is drawn at: what `film render` tells the page
|
|
701
|
+
* (window.__filmFps; a draft is 30), else 60 */
|
|
702
|
+
const filmFps = () => {
|
|
703
|
+
const f = /** @type {{ __filmFps?: number }} */ (globalThis).__filmFps;
|
|
704
|
+
return typeof f === "number" && f > 0 ? f : 60;
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* A dip cut: the outgoing frame darkens to `level` for its last frames before
|
|
709
|
+
* a hard cut (≈ 40 % darker for 3 frames, as HyperFrames' motion notes
|
|
710
|
+
* measured), so the cut reads as meant; with `settle`, the incoming arrives a
|
|
711
|
+
* little large and settles on an ease-out (a cut on a click's rebound).
|
|
712
|
+
* @param {number} t
|
|
713
|
+
* @param {number} at the cut
|
|
714
|
+
* @param {{ frames?: number, level?: number, settle?: number, settleDur?: number, fps?: number }} [o]
|
|
715
|
+
* settle: the incoming's first scale (default 1: none; 1.03 is a light one)
|
|
716
|
+
* @returns {{ a: Side, b: Side, p: number }}
|
|
717
|
+
*/
|
|
718
|
+
export function dipCut(t, at, o = {}) {
|
|
719
|
+
const { frames = 3, level = 0.6, settle = 1, settleDur = 0.25, fps = filmFps() } = o;
|
|
720
|
+
if (t < at) {
|
|
721
|
+
const dark = t >= at - frames / fps;
|
|
722
|
+
return { a: side({ visible: true, brightness: dark ? level : 1 }), b: gone(), p: 0 };
|
|
723
|
+
}
|
|
724
|
+
const e = ease.out(3)(prog(t, at, settleDur));
|
|
725
|
+
return { a: gone(), b: side({ visible: true, scale: lerp(settle, 1, e) }), p: e };
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// --- every boundary, named once -----------------------------------------------------------
|
|
729
|
+
|
|
730
|
+
/** the kinds `seams` knows by name */
|
|
731
|
+
export const KINDS = Object.freeze(["curve", "whip", "depth", "inverse", "push", "dip", "cut"]);
|
|
732
|
+
|
|
733
|
+
/** other names a kind goes by: the functions' own names, and the words a
|
|
734
|
+
* beat sheet tends to use for the same seam */
|
|
735
|
+
export const ALIASES = Object.freeze({
|
|
736
|
+
pushCut: "push",
|
|
737
|
+
dipCut: "dip",
|
|
738
|
+
"cut on the curve": "curve",
|
|
739
|
+
"whip pan": "whip",
|
|
740
|
+
"whip-pan": "whip",
|
|
741
|
+
"into the lens": "depth",
|
|
742
|
+
"hard cut": "cut",
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
/** seams that need more than two scenes and a time — each is a call of its
|
|
746
|
+
* own, with what it carries across */
|
|
747
|
+
const CALLS = Object.freeze({
|
|
748
|
+
waterfall: "waterfall(t, at, nOut, nIn) — word by word, with how many words each side has",
|
|
749
|
+
matchText: "matchText(t, start, end) — one line becoming another",
|
|
750
|
+
morph: "morph(t, start, end, from, to) — a card growing into its panel, with both rects",
|
|
751
|
+
parallax: "parallax(t, start, end, card, others, view) — one card of a grid becoming the scene",
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* The kind a name means: one of KINDS, by its own name or one it goes by
|
|
756
|
+
* ("pushCut" is "push", "into the lens" is "depth"), any case; null for any
|
|
757
|
+
* other words. A seam that is a call of its own (`morph`, `waterfall`,
|
|
758
|
+
* `matchText`, `parallax`) is null too — `seamCall(name)` says how to call it.
|
|
759
|
+
* @param {unknown} name
|
|
760
|
+
* @returns {string | null}
|
|
761
|
+
*/
|
|
762
|
+
export function kindOf(name) {
|
|
763
|
+
if (typeof name !== "string") return null;
|
|
764
|
+
const n = name.trim();
|
|
765
|
+
if (KINDS.includes(n)) return n;
|
|
766
|
+
const low = n.toLowerCase();
|
|
767
|
+
for (const k of KINDS) if (k === low) return k;
|
|
768
|
+
for (const [a, k] of Object.entries(ALIASES)) if (a.toLowerCase() === low) return k;
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/** how to call a seam that is not a kind but a call of its own, or null
|
|
773
|
+
* @param {unknown} name @returns {string | null} */
|
|
774
|
+
export function seamCall(name) {
|
|
775
|
+
if (typeof name !== "string") return null;
|
|
776
|
+
const low = name.trim().toLowerCase();
|
|
777
|
+
for (const [k, how] of Object.entries(CALLS)) if (k.toLowerCase() === low) return how;
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* The seam at every boundary between two scenes, named once. Each entry:
|
|
783
|
+
* `at` (a time, or a moment's name on the timeline), `from` and `to` (the two
|
|
784
|
+
* scenes' elements, or their ids or selectors), `kind` — "curve" (also when
|
|
785
|
+
* left out), "whip", "depth", "inverse", "push", "dip", "cut" (a plain hard
|
|
786
|
+
* cut, on purpose) — or a name they go by, as `kindOf` reads it ("pushCut",
|
|
787
|
+
* "into the lens") — or a function (t, at) → { a, b } of your own — and that
|
|
788
|
+
* seam's options beside them (`dir`, `dur`, …; `span: [before, after]` (s) is
|
|
789
|
+
* how long round `at` an own function's seam is open, default 1 s each side).
|
|
790
|
+
* Each is declared on the
|
|
791
|
+
* timeline as a cut at `at`, labelled with its kind, so `film render` lists
|
|
792
|
+
* it and the score and `film probe` see it. `apply(t)` writes both sides of
|
|
793
|
+
* every seam whose window is open at t onto its elements (see `apply`);
|
|
794
|
+
* `at(t)` gives the same as numbers. Outside every window nothing is touched:
|
|
795
|
+
* which scene shows then is the page's (or `scenes`', kit/time.js).
|
|
796
|
+
* @param {{ event: (at: number | string, kind: string, o?: { label?: string }) => number } | null} tl
|
|
797
|
+
* @param {{ at: number | string, from: unknown, to: unknown, kind?: string | ((t: number, at: number) => { a: Side, b: Side }), [k: string]: unknown }[]} list
|
|
798
|
+
* @param {{ view?: View, el?: (name: unknown) => Element | null }} [o]
|
|
799
|
+
*/
|
|
800
|
+
export function seams(tl, list, o = {}) {
|
|
801
|
+
const view = o.view ?? { width: 1920, height: 1080 };
|
|
802
|
+
if (!Array.isArray(list)) throw new Error("seams: give it a list of boundaries");
|
|
803
|
+
const items = list.map((s, i) => {
|
|
804
|
+
const named = s.kind ?? "curve";
|
|
805
|
+
const kind = typeof named === "function" ? named : kindOf(named);
|
|
806
|
+
if (kind == null) {
|
|
807
|
+
const call = seamCall(named);
|
|
808
|
+
throw new Error(
|
|
809
|
+
call
|
|
810
|
+
? `seams: boundary ${i}: "${named}" is a call of its own, not a kind: ${call}`
|
|
811
|
+
: `seams: boundary ${i}: kind "${named}" is not one of ${KINDS.join(", ")} — or give a function`,
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
const label = typeof kind === "function" ? kind.name || "own" : kind;
|
|
815
|
+
const at = tl
|
|
816
|
+
? tl.event(s.at, "cut", { label: `seam: ${label}` })
|
|
817
|
+
: typeof s.at === "number"
|
|
818
|
+
? s.at
|
|
819
|
+
: Number.NaN;
|
|
820
|
+
if (!Number.isFinite(at)) throw new Error(`seams: boundary ${i} is not at a time (${s.at})`);
|
|
821
|
+
const { at: _a, from, to, kind: _k, ...opts } = s;
|
|
822
|
+
return { at, from, to, kind, label, opts };
|
|
823
|
+
});
|
|
824
|
+
/** the window a seam touches its scenes in, [a, b]
|
|
825
|
+
* @param {(typeof items)[number]} s @returns {[number, number]} */
|
|
826
|
+
const span = (s) => {
|
|
827
|
+
const own = s.opts.span;
|
|
828
|
+
if (Array.isArray(own)) return [s.at - Number(own[0]), s.at + Number(own[1])];
|
|
829
|
+
/** an option's number, or its default @param {string} k @param {number} d */
|
|
830
|
+
const n = (k, d) => (typeof s.opts[k] === "number" ? /** @type {number} */ (s.opts[k]) : d);
|
|
831
|
+
switch (s.kind) {
|
|
832
|
+
case "curve":
|
|
833
|
+
return [s.at - n("dur", 0.3), s.at + n("dur", 0.3)];
|
|
834
|
+
case "whip":
|
|
835
|
+
return [s.at - n("dur", 0.55) / 2, s.at + n("dur", 0.55) / 2];
|
|
836
|
+
case "depth":
|
|
837
|
+
case "inverse":
|
|
838
|
+
return [s.at - n("outDur", 0.2), s.at + n("inDur", 0.5)];
|
|
839
|
+
case "push":
|
|
840
|
+
return [s.at - (n("dur", 0.36) * 5) / 11, s.at + (n("dur", 0.36) * 6) / 11];
|
|
841
|
+
case "dip":
|
|
842
|
+
// its dark frames, and one more, before the cut
|
|
843
|
+
return [
|
|
844
|
+
s.at - Math.max(0.1, (n("frames", 3) + 1) / n("fps", filmFps())),
|
|
845
|
+
s.at + n("settleDur", 0.25),
|
|
846
|
+
];
|
|
847
|
+
case "cut":
|
|
848
|
+
return [s.at - 1 / 120, s.at + 1 / 120];
|
|
849
|
+
default:
|
|
850
|
+
return [s.at - 1, s.at + 1];
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
/** @param {(typeof items)[number]} s @param {number} t */
|
|
854
|
+
const sidesAt = (s, t) => {
|
|
855
|
+
const k = s.kind;
|
|
856
|
+
const opts = /** @type {Record<string, any>} */ (s.opts);
|
|
857
|
+
if (typeof k === "function") return k(t, s.at);
|
|
858
|
+
if (k === "curve") return curve(t, s.at, opts);
|
|
859
|
+
if (k === "whip") return whip(t, s.at, view, opts);
|
|
860
|
+
if (k === "depth") return depth(t, s.at, opts);
|
|
861
|
+
if (k === "inverse") return depth(t, s.at, { ...opts, inverse: true });
|
|
862
|
+
if (k === "push") return pushCut(t, s.at, opts);
|
|
863
|
+
if (k === "dip") return dipCut(t, s.at, opts);
|
|
864
|
+
return t < s.at ? { a: still(), b: gone() } : { a: gone(), b: still() };
|
|
865
|
+
};
|
|
866
|
+
/** @type {Map<unknown, Element>} */
|
|
867
|
+
const found = new Map();
|
|
868
|
+
/** @param {unknown} name */
|
|
869
|
+
const elOf = (name) => {
|
|
870
|
+
if (name && typeof name === "object") return /** @type {Element} */ (name);
|
|
871
|
+
const had = found.get(name);
|
|
872
|
+
if (had) return had;
|
|
873
|
+
const n = String(name);
|
|
874
|
+
const el = o.el
|
|
875
|
+
? o.el(name)
|
|
876
|
+
: (document.getElementById(n) ??
|
|
877
|
+
(/^[#.[]|[\s>:]/.test(n) ? document.querySelector(n) : null));
|
|
878
|
+
if (!el) throw new Error(`seams: no element for "${n}" (an element, an id or a selector)`);
|
|
879
|
+
found.set(name, el);
|
|
880
|
+
return el;
|
|
881
|
+
};
|
|
882
|
+
return {
|
|
883
|
+
/** every boundary: its time, its kind, its window */
|
|
884
|
+
list: () =>
|
|
885
|
+
items.map((s) => ({ at: s.at, kind: s.label, from: s.from, to: s.to, span: span(s) })),
|
|
886
|
+
/** the seams open at t, with both sides as numbers @param {number} t */
|
|
887
|
+
at(t) {
|
|
888
|
+
return items
|
|
889
|
+
.filter((s) => {
|
|
890
|
+
const [a, b] = span(s);
|
|
891
|
+
return t >= a && t <= b;
|
|
892
|
+
})
|
|
893
|
+
.map((s) => ({ at: s.at, kind: s.label, ...sidesAt(s, t) }));
|
|
894
|
+
},
|
|
895
|
+
/**
|
|
896
|
+
* Write both sides of every open seam onto its scenes. The scenes of every
|
|
897
|
+
* closed seam are first set back to rest (no transform, filter or opacity
|
|
898
|
+
* of a seam's), so a frame drawn out of order comes out the same; which
|
|
899
|
+
* of them shows outside a seam is left alone — call `scenes`' show(t)
|
|
900
|
+
* (kit/time.js) first, then this.
|
|
901
|
+
* @param {number} t
|
|
902
|
+
*/
|
|
903
|
+
apply(t) {
|
|
904
|
+
const open = items.filter((s) => {
|
|
905
|
+
const [a, b] = span(s);
|
|
906
|
+
return t >= a && t <= b;
|
|
907
|
+
});
|
|
908
|
+
for (const s of items) {
|
|
909
|
+
if (open.includes(s)) continue;
|
|
910
|
+
for (const name of [s.from, s.to]) rest(elOf(name));
|
|
911
|
+
}
|
|
912
|
+
let fl = 0;
|
|
913
|
+
let colour = "#fff";
|
|
914
|
+
for (const s of open) {
|
|
915
|
+
const r = sidesAt(s, t);
|
|
916
|
+
apply(elOf(s.from), r.a);
|
|
917
|
+
apply(elOf(s.to), r.b);
|
|
918
|
+
if ("flash" in r && r.flash) {
|
|
919
|
+
const x = /** @type {{ colour: string, opacity: number }} */ (r.flash);
|
|
920
|
+
if (x.opacity > fl) {
|
|
921
|
+
fl = x.opacity;
|
|
922
|
+
colour = x.colour;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
if (fl > 0 || flashLayer) flashOn({ colour, opacity: fl });
|
|
927
|
+
},
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// --- writing a side onto an element ---------------------------------------------------------
|
|
932
|
+
|
|
933
|
+
/** @type {WeakMap<Element, SVGFEGaussianBlurElement>} */
|
|
934
|
+
const axisBlurs = new WeakMap();
|
|
935
|
+
let blurIds = 0;
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Write one side onto an element: visibility (never display, so what is in
|
|
939
|
+
* it keeps its layout; `inherit` when shown, so a scene hidden above it
|
|
940
|
+
* still hides it — and for the same reason a child that sets `visibility:
|
|
941
|
+
* visible` itself shows through a hidden side: write `inherit` on it, or
|
|
942
|
+
* nothing), opacity, transform (transform-origin is the page's:
|
|
943
|
+
* the centre, unless it set another), filter. A blur along one axis is an SVG
|
|
944
|
+
* filter (feGaussianBlur with "σ 0"), made once per element and removed from
|
|
945
|
+
* the element's style the moment the blur is 0 — a filter left on keeps the
|
|
946
|
+
* layer soft.
|
|
947
|
+
* @param {Element} el
|
|
948
|
+
* @param {Side} s
|
|
949
|
+
*/
|
|
950
|
+
export function apply(el, s) {
|
|
951
|
+
const st = /** @type {HTMLElement} */ (el).style;
|
|
952
|
+
st.visibility = s.visible ? "inherit" : "hidden";
|
|
953
|
+
st.opacity = s.opacity >= 1 ? "" : String(f(s.opacity, 4));
|
|
954
|
+
st.transform = s.transform === "none" ? "" : s.transform;
|
|
955
|
+
if (s.blurAxis && s.blur > 0) {
|
|
956
|
+
let fe = axisBlurs.get(el);
|
|
957
|
+
if (!fe) {
|
|
958
|
+
const ns = "http://www.w3.org/2000/svg";
|
|
959
|
+
const svg = document.createElementNS(ns, "svg");
|
|
960
|
+
svg.setAttribute("width", "0");
|
|
961
|
+
svg.setAttribute("height", "0");
|
|
962
|
+
svg.style.position = "absolute";
|
|
963
|
+
const filter = document.createElementNS(ns, "filter");
|
|
964
|
+
const id = `ot-seam-blur-${++blurIds}`;
|
|
965
|
+
filter.setAttribute("id", id);
|
|
966
|
+
filter.setAttribute("x", "-20%");
|
|
967
|
+
filter.setAttribute("width", "140%");
|
|
968
|
+
filter.setAttribute("y", "-20%");
|
|
969
|
+
filter.setAttribute("height", "140%");
|
|
970
|
+
fe = /** @type {SVGFEGaussianBlurElement} */ (document.createElementNS(ns, "feGaussianBlur"));
|
|
971
|
+
filter.append(fe);
|
|
972
|
+
svg.append(filter);
|
|
973
|
+
document.body.append(svg);
|
|
974
|
+
axisBlurs.set(el, fe);
|
|
975
|
+
fe.dataset.id = id;
|
|
976
|
+
}
|
|
977
|
+
fe.setAttribute("stdDeviation", s.blurAxis === "x" ? `${f(s.blur, 2)} 0` : `0 ${f(s.blur, 2)}`);
|
|
978
|
+
const rest = s.filter === "none" ? "" : ` ${s.filter}`;
|
|
979
|
+
st.filter = `url(#${fe.dataset.id})${rest}`;
|
|
980
|
+
} else st.filter = s.filter === "none" ? "" : s.filter;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/** a seam's own styles off an element: at rest @param {Element} el */
|
|
984
|
+
function rest(el) {
|
|
985
|
+
const st = /** @type {HTMLElement} */ (el).style;
|
|
986
|
+
st.opacity = "";
|
|
987
|
+
st.transform = "";
|
|
988
|
+
st.filter = "";
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** a flash over the whole frame: one layer, made once, above everything */
|
|
992
|
+
/** @type {HTMLElement | null} */
|
|
993
|
+
let flashLayer = null;
|
|
994
|
+
/** @param {{ colour: string, opacity: number }} fl */
|
|
995
|
+
function flashOn(fl) {
|
|
996
|
+
let d = flashLayer;
|
|
997
|
+
if (!d) {
|
|
998
|
+
d = document.createElement("div");
|
|
999
|
+
d.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:2147483647";
|
|
1000
|
+
document.body.append(d);
|
|
1001
|
+
flashLayer = d;
|
|
1002
|
+
}
|
|
1003
|
+
d.style.background = fl.colour;
|
|
1004
|
+
d.style.opacity = String(f(fl.opacity, 4));
|
|
1005
|
+
d.style.visibility = fl.opacity > 0 ? "inherit" : "hidden";
|
|
1006
|
+
}
|