@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
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
// handoff.js — one scene handing over to the next, one call each, as plain
|
|
2
|
+
// functions of film time t: give it t and when, read back each side as CSS
|
|
3
|
+
// (transform, opacity, visibility) and where the thing carried across is.
|
|
4
|
+
// No state: a frame drawn twice or out of order comes out the same. Built on
|
|
5
|
+
// the kit's measured seams and moves — kit/seams.js's whip, kit/motion.js's
|
|
6
|
+
// morphRect and rectClip — with what a launch film's scene change does
|
|
7
|
+
// round them: one thing staying on screen and travelling to its place in the
|
|
8
|
+
// next scene, a panel rising in, a push through what was clicked into the view
|
|
9
|
+
// it opens.
|
|
10
|
+
//
|
|
11
|
+
// Nothing here blurs: the master's shutter (`film render`) smears whatever
|
|
12
|
+
// moves fast, so a whip or a panel's first frames come out blurred and its
|
|
13
|
+
// landing sharp. A draft has no shutter — `film still --at` shows a handoff as
|
|
14
|
+
// the master will.
|
|
15
|
+
//
|
|
16
|
+
// import { whip, carry, carryAlong, panel, through, apply } from "./lib/handoff.js";
|
|
17
|
+
// // this scene whips out to the left, the next arrives from the right on the
|
|
18
|
+
// // same strip, and the avatar travels from its place here to its place there
|
|
19
|
+
// const h = whip(t, 6.0, { dir: "left", carry: { from: avatarHere, to: avatarThere } });
|
|
20
|
+
// apply(sceneA, h.a); apply(sceneB, h.b); apply(avatar, h.carry);
|
|
21
|
+
//
|
|
22
|
+
// whip(t, at, o) the scene leaves along `dir`, the next arriving behind it on one
|
|
23
|
+
// strip (dir "up": the next comes up from below as this one leaves
|
|
24
|
+
// upward); `carry` travels one thing across meanwhile
|
|
25
|
+
// carry(t, start, end, from, to, o) one thing between two places: in an arc, its size in log space
|
|
26
|
+
// carryAlong(t, places, o) one thing through a list of places over the film, each of them
|
|
27
|
+
// still or moving, travelling to the next when its time comes
|
|
28
|
+
// panel(t, at, o) a panel rising in from below, fastest at once and settling
|
|
29
|
+
// through(t, start, end, rect, o) a push through what was clicked: it opens into the view it leads
|
|
30
|
+
// to, the scene growing with it
|
|
31
|
+
// apply(el, side) writes one of them onto an element
|
|
32
|
+
//
|
|
33
|
+
// Rects are { x, y, w, h, r? } in frame px. A device's `at(pose).toFrame(x, y)`
|
|
34
|
+
// (lib/devices.js) gives a point of its screen in the frame, so a row on a
|
|
35
|
+
// laptop's screen can be the rect a push goes through.
|
|
36
|
+
// What each side is laid out as: a scene at its place at rest (the whole
|
|
37
|
+
// frame, usually); the thing carried at its place in the next scene (`to`),
|
|
38
|
+
// so it lands sharp; the view a push opens at the whole frame.
|
|
39
|
+
|
|
40
|
+
import { morphRect, rectClip } from "../kit/motion.js";
|
|
41
|
+
import { apply as applySide, ease, side, whip as stripWhip } from "../kit/seams.js";
|
|
42
|
+
|
|
43
|
+
/** @typedef {{ x: number, y: number, w: number, h: number, r?: number }} Rect in frame px */
|
|
44
|
+
/** @typedef {{ width: number, height: number }} View */
|
|
45
|
+
/** @typedef {import("../kit/seams.js").Side & { origin?: string, radius?: string, clip?: string }} Side
|
|
46
|
+
* one side at t: kit/seams.js's, and the transform-origin, border-radius and clip it needs, if any */
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {object} Carried the thing carried, at t
|
|
49
|
+
* @property {number} x @property {number} y @property {number} w @property {number} h where it is (frame px)
|
|
50
|
+
* @property {number} scale its size against its place in the next scene
|
|
51
|
+
* @property {number} p 0 → 1 along the way
|
|
52
|
+
* @property {boolean} visible
|
|
53
|
+
* @property {number} opacity
|
|
54
|
+
* @property {string} transform for an element laid out at `to`, transform-origin 0 0 ("none" once there)
|
|
55
|
+
* @property {string} filter
|
|
56
|
+
* @property {string} origin "0 0"
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
const FRAME = { width: 1920, height: 1080 };
|
|
60
|
+
|
|
61
|
+
/** @param {number} x */
|
|
62
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
63
|
+
/** @param {number} a @param {number} b @param {number} p */
|
|
64
|
+
const lerp = (a, b, p) => a + (b - a) * p;
|
|
65
|
+
/** @param {number} v */
|
|
66
|
+
const f3 = (v) => +v.toFixed(3);
|
|
67
|
+
/** @param {unknown} r @param {string} who @returns {Rect} */
|
|
68
|
+
function rectOf(r, who) {
|
|
69
|
+
const o = /** @type {Record<string, number> | null} */ (r && typeof r === "object" ? r : null);
|
|
70
|
+
const w = o ? (o.w ?? o.width) : undefined;
|
|
71
|
+
const h = o ? (o.h ?? o.height) : undefined;
|
|
72
|
+
if (!o || !Number.isFinite(o.x) || !Number.isFinite(o.y) || !(Number(w) > 0) || !(Number(h) > 0))
|
|
73
|
+
throw new Error(
|
|
74
|
+
`handoff: ${who} is a rect { x, y, w, h } in frame px (got ${JSON.stringify(r)})`,
|
|
75
|
+
);
|
|
76
|
+
return { x: Number(o.x), y: Number(o.y), w: Number(w), h: Number(h), r: Number(o.r ?? 0) };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* One thing travelling from one place to another between `start` and `end`:
|
|
81
|
+
* its middle on a straight line bowed upward by `arc` px at halfway (a thrown
|
|
82
|
+
* thing's path; default a sixth of the distance), its width changing in log
|
|
83
|
+
* space so a growth reads steady (its height follows its width). Before
|
|
84
|
+
* `start` it is at `from`; from `end` on at `to`, untransformed.
|
|
85
|
+
* `const c = carry(t, 4.2, 4.9, avatarOnLaptop, avatarOnPhone); apply(avatar, c);`
|
|
86
|
+
* @param {number} t
|
|
87
|
+
* @param {number} start
|
|
88
|
+
* @param {number} end
|
|
89
|
+
* @param {Rect} from
|
|
90
|
+
* @param {Rect} to where it is laid out
|
|
91
|
+
* @param {{ ease?: (p: number) => number, arc?: number }} [o] ease default in-out (cubic)
|
|
92
|
+
* @returns {Carried}
|
|
93
|
+
*/
|
|
94
|
+
export function carry(t, start, end, from, to, o = {}) {
|
|
95
|
+
const a = rectOf(from, "carry's from");
|
|
96
|
+
const b = rectOf(to, "carry's to");
|
|
97
|
+
const curve = o.ease ?? ease.inOut(3);
|
|
98
|
+
const p = end > start ? curve(clamp01((t - start) / (end - start))) : t >= end ? 1 : 0;
|
|
99
|
+
const ca = { x: a.x + a.w / 2, y: a.y + a.h / 2 };
|
|
100
|
+
const cb = { x: b.x + b.w / 2, y: b.y + b.h / 2 };
|
|
101
|
+
const arc = o.arc ?? Math.hypot(cb.x - ca.x, cb.y - ca.y) / 6;
|
|
102
|
+
const w = a.w * (b.w / a.w) ** p;
|
|
103
|
+
const s = w / b.w;
|
|
104
|
+
const h = b.h * s;
|
|
105
|
+
const cx = lerp(ca.x, cb.x, p);
|
|
106
|
+
const cy = lerp(ca.y, cb.y, p) - 4 * arc * p * (1 - p);
|
|
107
|
+
const x = cx - w / 2;
|
|
108
|
+
const y = cy - h / 2;
|
|
109
|
+
const there = p >= 1 - 1e-9;
|
|
110
|
+
return {
|
|
111
|
+
x,
|
|
112
|
+
y,
|
|
113
|
+
w,
|
|
114
|
+
h,
|
|
115
|
+
scale: s,
|
|
116
|
+
p,
|
|
117
|
+
visible: true,
|
|
118
|
+
opacity: 1,
|
|
119
|
+
transform: there
|
|
120
|
+
? "none"
|
|
121
|
+
: `translate(${f3(x - b.x)}px, ${f3(y - b.y)}px) scale(${+s.toFixed(5)})`,
|
|
122
|
+
filter: "none",
|
|
123
|
+
origin: "0 0",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @typedef {object} Place one place the thing sits, and how it gets there
|
|
129
|
+
* @property {Rect | ((t: number) => Rect | null)} at where: a rect, or one read at t (an element's box, a
|
|
130
|
+
* device's `toFrame`, a 3D point seen by the lens) — null while it cannot be seen
|
|
131
|
+
* @property {number} [from] when it leaves the place before for this one (not read on the first place)
|
|
132
|
+
* @property {number} [to] when it lands (default 0.6 s after `from`)
|
|
133
|
+
* @property {number} [arc] the bow of that trip (px; default a sixth of the distance)
|
|
134
|
+
* @property {(p: number) => number} [ease]
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* One thing through many places — the face, the file, the card a film
|
|
139
|
+
* follows from its first scene to its last. `places` in time order: it sits
|
|
140
|
+
* on the first until the second's `from`, travels to the second by its `to`
|
|
141
|
+
* (carry's path: an arc, its width in log space), sits there, and so on.
|
|
142
|
+
* A place may be a function of t — where an element is now
|
|
143
|
+
* (`() => box(el)`), a point on a device's screen, a point in 3D — and is
|
|
144
|
+
* read at every t, during the trip too, so the thing leaves a place that is
|
|
145
|
+
* moving and lands on one that is moving, and rides it after. Between trips
|
|
146
|
+
* it is at its place, to the pixel.
|
|
147
|
+
* Lay the element out once, anywhere, and say where with `laid` (default: at
|
|
148
|
+
* 0, 0, the size of the first place): `transform` is for that layout, origin
|
|
149
|
+
* 0 0, so the same element serves every place. `place` is the place it is
|
|
150
|
+
* on or travelling to, `moving` whether it is between two.
|
|
151
|
+
* A place that cannot be read (null) hides the thing while it is on it or
|
|
152
|
+
* bound for it; one it is leaving is read where it last could be.
|
|
153
|
+
* `const c = carryAlong(t, [{ at: () => box(replyFace) }, { from: 5.3, to: 6.5, at: () => box(cloudSlot) },
|
|
154
|
+
* { from: 9.5, to: 11, at: () => box(paneFace) }], { laid: { x: 0, y: 0, w: 160, h: 160 } }); apply(face, c);`
|
|
155
|
+
* @param {number} t
|
|
156
|
+
* @param {Place[]} places in time order
|
|
157
|
+
* @param {{ laid?: Rect, ease?: (p: number) => number, arc?: number }} [o] ease and arc: for every trip
|
|
158
|
+
* that does not say its own
|
|
159
|
+
* @returns {Carried & { place: number, moving: boolean }}
|
|
160
|
+
*/
|
|
161
|
+
export function carryAlong(t, places, o = {}) {
|
|
162
|
+
if (!places.length) throw new Error("handoff: carryAlong needs places [{ at }, { from, to, at }, …]");
|
|
163
|
+
let i = 0;
|
|
164
|
+
for (let k = 1; k < places.length; k++) {
|
|
165
|
+
const at = /** @type {Place} */ (places[k]).from;
|
|
166
|
+
if (!Number.isFinite(at)) throw new Error(`handoff: carryAlong's place ${k} needs \`from\`, when the thing leaves for it`);
|
|
167
|
+
if (t >= /** @type {number} */ (at)) i = k;
|
|
168
|
+
}
|
|
169
|
+
const read = (/** @type {number} */ k) => {
|
|
170
|
+
const pl = /** @type {Place} */ (places[k]);
|
|
171
|
+
const r = typeof pl.at === "function" ? pl.at(t) : pl.at;
|
|
172
|
+
return r == null ? null : rectOf(r, `carryAlong's place ${k}`);
|
|
173
|
+
};
|
|
174
|
+
const cur = /** @type {Place} */ (places[i]);
|
|
175
|
+
const here = read(i);
|
|
176
|
+
// the place it left: the nearest one before that can be read
|
|
177
|
+
let prev = null;
|
|
178
|
+
for (let k = i - 1; k >= 0 && !prev; k--) prev = read(k);
|
|
179
|
+
const first = read(0);
|
|
180
|
+
const laid = o.laid ? rectOf(o.laid, "carryAlong's laid") : { x: 0, y: 0, w: first?.w ?? here?.w ?? 1, h: first?.h ?? here?.h ?? 1 };
|
|
181
|
+
const start = cur.from ?? -Infinity;
|
|
182
|
+
const end = cur.to ?? start + 0.6;
|
|
183
|
+
const moving = i > 0 && t < end;
|
|
184
|
+
if (!here) {
|
|
185
|
+
return {
|
|
186
|
+
x: 0, y: 0, w: laid.w, h: laid.h, scale: 1, p: moving ? 0 : 1, visible: false, opacity: 0,
|
|
187
|
+
transform: "none", filter: "none", origin: "0 0", place: i, moving,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const ease = cur.ease ?? o.ease;
|
|
191
|
+
const arc = cur.arc ?? o.arc;
|
|
192
|
+
const c =
|
|
193
|
+
i === 0 || !prev
|
|
194
|
+
? { x: here.x, y: here.y, w: here.w, h: here.h, p: 1 }
|
|
195
|
+
: carry(t, start, end, prev, here, { ...(ease ? { ease } : {}), ...(arc != null ? { arc } : {}) });
|
|
196
|
+
const s = c.w / laid.w;
|
|
197
|
+
return {
|
|
198
|
+
x: c.x,
|
|
199
|
+
y: c.y,
|
|
200
|
+
w: c.w,
|
|
201
|
+
h: c.h,
|
|
202
|
+
scale: s,
|
|
203
|
+
p: c.p,
|
|
204
|
+
visible: true,
|
|
205
|
+
opacity: 1,
|
|
206
|
+
transform: `translate(${f3(c.x - laid.x * s)}px, ${f3(c.y - laid.y * s)}px) scale(${+s.toFixed(5)})`,
|
|
207
|
+
filter: "none",
|
|
208
|
+
origin: "0 0",
|
|
209
|
+
place: i,
|
|
210
|
+
moving,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The box of an element in the frame, now: for a place of carryAlong's, or
|
|
216
|
+
* a rect of `through`'s. It reads the page's layout when called, so draw the
|
|
217
|
+
* scene for t first. `host`: the element the frame is measured from
|
|
218
|
+
* (default the page's top-left).
|
|
219
|
+
* `{ from: 9.5, to: 11, at: () => box(paneFace) }`
|
|
220
|
+
* @param {Element} el @param {{ host?: Element | null }} [o] @returns {Rect | null} null when it has no box (hidden by display)
|
|
221
|
+
*/
|
|
222
|
+
export function box(el, o = {}) {
|
|
223
|
+
const r = el.getBoundingClientRect();
|
|
224
|
+
if (r.width === 0 && r.height === 0) return null;
|
|
225
|
+
const h = o.host?.getBoundingClientRect() ?? { left: 0, top: 0 };
|
|
226
|
+
return { x: r.left - h.left, y: r.top - h.top, w: r.width, h: r.height };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A whip: this scene and the next ride one strip one frame long, the next
|
|
231
|
+
* docked beyond this one, and the strip moves a frame's width (or height) on
|
|
232
|
+
* one ease-in-out — kit/seams.js's whip, whose speed across the seam is the
|
|
233
|
+
* same on both sides by construction. `at` is the middle, its fastest moment.
|
|
234
|
+
* With `carry`, one thing stays on screen above both and travels from its
|
|
235
|
+
* place in this scene to its place in the next, leaving as the whip starts
|
|
236
|
+
* and landing `settle` s after it ends — the thing the film follows, moving
|
|
237
|
+
* on while the world round it changes. Default 0.5 s (the launch film these
|
|
238
|
+
* notes came from changed scene in 0.4–0.5 s).
|
|
239
|
+
* `const h = whip(t, 6, { dir: "up", carry: { from: here, to: there } })`
|
|
240
|
+
* @param {number} t
|
|
241
|
+
* @param {number} at
|
|
242
|
+
* @param {{ dir?: "left" | "right" | "up" | "down", dur?: number, power?: number, view?: View, carry?: { from: Rect, to: Rect, arc?: number, settle?: number } }} [o]
|
|
243
|
+
* @returns {{ a: Side, b: Side, carry: Carried | null, p: number, edge: number | null }}
|
|
244
|
+
* a: this scene, b: the next (each at its place at rest); edge: where they meet, along the strip (frame px)
|
|
245
|
+
*/
|
|
246
|
+
export function whip(t, at, o = {}) {
|
|
247
|
+
const { dir = "left", dur = 0.5, power = 3, view = FRAME } = o;
|
|
248
|
+
const s = stripWhip(t, at, view, { dir, dur, power });
|
|
249
|
+
const c = o.carry;
|
|
250
|
+
return {
|
|
251
|
+
a: s.a,
|
|
252
|
+
b: s.b,
|
|
253
|
+
carry: c
|
|
254
|
+
? carry(t, at - dur / 2, at + dur / 2 + (c.settle ?? 0.2), c.from, c.to, {
|
|
255
|
+
...(c.arc != null ? { arc: c.arc } : {}),
|
|
256
|
+
})
|
|
257
|
+
: null,
|
|
258
|
+
p: s.p,
|
|
259
|
+
edge: s.edge,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* A panel rising in over the scene from `dy` px below its place: fastest at
|
|
265
|
+
* once, closing on its place exponentially (the reference's fling, τ 22 % of
|
|
266
|
+
* the move), so the master's shutter smears its first frames and it lands
|
|
267
|
+
* sharp; seen from its first frame (opacity over the first 0.08 s). With
|
|
268
|
+
* `recede` and `dim`, the scene under it steps back a little meanwhile and
|
|
269
|
+
* stays so.
|
|
270
|
+
* `const r = panel(t, 7.4, { dy: 260 }); apply(card, r.panel); apply(scene, r.under);`
|
|
271
|
+
* @param {number} t
|
|
272
|
+
* @param {number} at
|
|
273
|
+
* @param {{ dy?: number, dur?: number, tau?: number, from?: number, recede?: number, dim?: number }} [o]
|
|
274
|
+
* dy (default 240 px), dur (default 0.6 s), tau (share of dur, default 0.22), from: its first
|
|
275
|
+
* scale (default 0.97); recede: the scene under it ends at this scale (default 1: unmoved),
|
|
276
|
+
* dim: its brightness (default 1)
|
|
277
|
+
* @returns {{ panel: Side, under: Side, p: number }}
|
|
278
|
+
*/
|
|
279
|
+
export function panel(t, at, o = {}) {
|
|
280
|
+
const { dy = 240, dur = 0.6, tau = 0.22, from = 0.97, recede = 1, dim = 1 } = o;
|
|
281
|
+
if (t < at)
|
|
282
|
+
return { panel: side({ visible: false, opacity: 0 }), under: side({ visible: true }), p: 0 };
|
|
283
|
+
const u = clamp01((t - at) / dur);
|
|
284
|
+
const e = (1 - Math.exp(-u / tau)) / (1 - Math.exp(-1 / tau));
|
|
285
|
+
return {
|
|
286
|
+
panel: {
|
|
287
|
+
...side({
|
|
288
|
+
visible: true,
|
|
289
|
+
y: dy * (1 - e),
|
|
290
|
+
scale: lerp(from, 1, e),
|
|
291
|
+
opacity: clamp01((t - at) / 0.08),
|
|
292
|
+
}),
|
|
293
|
+
origin: "50% 100%",
|
|
294
|
+
},
|
|
295
|
+
under: {
|
|
296
|
+
...side({ visible: true, scale: lerp(1, recede, e), brightness: lerp(1, dim, e) }),
|
|
297
|
+
origin: "50% 50%",
|
|
298
|
+
},
|
|
299
|
+
p: e,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* A push through what was clicked: `rect` opens into the view it leads to.
|
|
305
|
+
* A window grows from `rect` to the whole frame (kit/motion.js's morphRect:
|
|
306
|
+
* its size in log space, its corners going square); the view, built at the
|
|
307
|
+
* frame's size, is scaled to cover the window and shown through it (a clip,
|
|
308
|
+
* no stretch), fading in over the first `fade` of the move; the scene under
|
|
309
|
+
* it grows with the window, so what was clicked stays under it, and is hidden
|
|
310
|
+
* once the window fills the frame. One ease for all of it (default in-out,
|
|
311
|
+
* cubic). Put both on elements the size of the frame: `apply` sets their
|
|
312
|
+
* transform-origin (0 0) and the view's clip.
|
|
313
|
+
* The push goes through what can be seen: the part of `rect` inside the
|
|
314
|
+
* frame is used (a row running off the right edge opens from its visible
|
|
315
|
+
* part; taken whole, a rect wider than the frame would shrink the scene and
|
|
316
|
+
* show the ground round it), and a rect wholly outside the frame is an
|
|
317
|
+
* error. The scene is never drawn short of the frame's edges: where the
|
|
318
|
+
* window travels faster than the scene grows (a rect near an edge), the
|
|
319
|
+
* scene is held to the edge and what was clicked slips a little under the
|
|
320
|
+
* window, which the view is covering by then.
|
|
321
|
+
* Over a live 3D canvas (lib/space.js): `a` goes on the element that holds
|
|
322
|
+
* the canvas, the size of the frame, and scales it as a flat picture — so
|
|
323
|
+
* give the rect as the lens sees it when the push starts
|
|
324
|
+
* (`st.toFrame(p, start)` for two corners, not at t: the push holds the
|
|
325
|
+
* picture it began on), keep the lens from travelling on during the push
|
|
326
|
+
* (its move would slide what was clicked out from under the window; a slow
|
|
327
|
+
* drift is fine), and keep drawing the canvas each frame until `a` is
|
|
328
|
+
* hidden. The canvas's pixels are enlarged with it, up to frame ÷ rect
|
|
329
|
+
* (3.7× for a 520 px row); the view has faded in over them by the first
|
|
330
|
+
* `fade` of the move, when the push has barely begun (1.15× for that row).
|
|
331
|
+
* `const g = through(t, 8.1, 8.75, rowRect); apply(list, g.a); apply(detail, g.b);`
|
|
332
|
+
* @param {number} t
|
|
333
|
+
* @param {number} start
|
|
334
|
+
* @param {number} end 0.5–0.8 s after start reads as a push; longer, as a zoom
|
|
335
|
+
* @param {Rect} rect what was clicked, in frame px
|
|
336
|
+
* @param {{ view?: View, ease?: (p: number) => number, fade?: number }} [o] fade: share of the move (default 0.3)
|
|
337
|
+
* @returns {{ a: Side, b: Side & { clip: string }, window: Rect, p: number }}
|
|
338
|
+
* window: where the view shows through, frame px
|
|
339
|
+
*/
|
|
340
|
+
export function through(t, start, end, rect, o = {}) {
|
|
341
|
+
const asked = rectOf(rect, "through's rect");
|
|
342
|
+
const { view = FRAME, fade = 0.3 } = o;
|
|
343
|
+
// the part of it inside the frame
|
|
344
|
+
const x0 = Math.max(0, asked.x), y0 = Math.max(0, asked.y);
|
|
345
|
+
const x1 = Math.min(view.width, asked.x + asked.w), y1 = Math.min(view.height, asked.y + asked.h);
|
|
346
|
+
if (!(x1 > x0 && y1 > y0))
|
|
347
|
+
throw new Error(
|
|
348
|
+
`handoff: through's rect is outside the ${view.width} × ${view.height} frame (got ${JSON.stringify(rect)}): it is what was clicked, in frame px`,
|
|
349
|
+
);
|
|
350
|
+
const r = { x: x0, y: y0, w: x1 - x0, h: y1 - y0, r: Math.min(asked.r ?? 0, (x1 - x0) / 2, (y1 - y0) / 2) };
|
|
351
|
+
const curve = o.ease ?? ease.inOut(3);
|
|
352
|
+
const q = end > start ? clamp01((t - start) / (end - start)) : t >= end ? 1 : 0;
|
|
353
|
+
const whole = { x: 0, y: 0, w: view.width, h: view.height, r: 0 };
|
|
354
|
+
if (t < start)
|
|
355
|
+
return {
|
|
356
|
+
a: { ...side({ visible: true }), origin: "0 0" },
|
|
357
|
+
b: { ...side({ visible: false, opacity: 0 }), origin: "0 0", clip: "" },
|
|
358
|
+
window: r,
|
|
359
|
+
p: 0,
|
|
360
|
+
};
|
|
361
|
+
const win = morphRect(t, start, end, r, whole, { ease: curve });
|
|
362
|
+
const done = q >= 1;
|
|
363
|
+
// the scene: what was clicked kept under the window — its width (or its
|
|
364
|
+
// height, for something taller than the frame's shape) grown to the window's
|
|
365
|
+
const wide = r.w / r.h >= view.width / view.height;
|
|
366
|
+
const sa = wide ? win.w / r.w : win.h / r.h;
|
|
367
|
+
// …and never short of the frame's edges (sa is 1 or more: the rect is inside the frame)
|
|
368
|
+
const ax = Math.min(0, Math.max(view.width * (1 - sa), win.x + win.w / 2 - sa * (r.x + r.w / 2)));
|
|
369
|
+
const ay = Math.min(0, Math.max(view.height * (1 - sa), win.y + win.h / 2 - sa * (r.y + r.h / 2)));
|
|
370
|
+
// the view: covering the window, centred on it
|
|
371
|
+
const sb = Math.max(win.w / view.width, win.h / view.height);
|
|
372
|
+
const bx = win.x + win.w / 2 - (sb * view.width) / 2;
|
|
373
|
+
const by = win.y + win.h / 2 - (sb * view.height) / 2;
|
|
374
|
+
// the window in the view's own px, for its clip
|
|
375
|
+
const local = {
|
|
376
|
+
x: (win.x - bx) / sb,
|
|
377
|
+
y: (win.y - by) / sb,
|
|
378
|
+
w: win.w / sb,
|
|
379
|
+
h: win.h / sb,
|
|
380
|
+
r: win.r / sb,
|
|
381
|
+
};
|
|
382
|
+
return {
|
|
383
|
+
a: { ...side({ visible: !done, x: ax, y: ay, scale: sa }), origin: "0 0" },
|
|
384
|
+
b: {
|
|
385
|
+
...side({
|
|
386
|
+
visible: true,
|
|
387
|
+
x: done ? 0 : bx,
|
|
388
|
+
y: done ? 0 : by,
|
|
389
|
+
scale: done ? 1 : sb,
|
|
390
|
+
opacity: clamp01(q / Math.max(1e-9, fade)),
|
|
391
|
+
}),
|
|
392
|
+
origin: "0 0",
|
|
393
|
+
clip: done ? "" : rectClip(local, view),
|
|
394
|
+
},
|
|
395
|
+
window: { x: win.x, y: win.y, w: win.w, h: win.h, r: win.r },
|
|
396
|
+
p: win.p,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Write a side (or a carried thing) onto an element: visibility, opacity,
|
|
402
|
+
* transform, filter (kit/seams.js's apply), and the transform-origin,
|
|
403
|
+
* border-radius and clip it names. A side at rest is left with no transform or filter.
|
|
404
|
+
* @param {Element} el
|
|
405
|
+
* @param {Side | Carried} s
|
|
406
|
+
*/
|
|
407
|
+
export function apply(el, s) {
|
|
408
|
+
applySide(
|
|
409
|
+
el,
|
|
410
|
+
/** @type {import("../kit/seams.js").Side} */ ({
|
|
411
|
+
blur: 0,
|
|
412
|
+
blurAxis: null,
|
|
413
|
+
brightness: 1,
|
|
414
|
+
...s,
|
|
415
|
+
}),
|
|
416
|
+
);
|
|
417
|
+
const st = /** @type {HTMLElement} */ (el).style;
|
|
418
|
+
if (s.origin) st.transformOrigin = s.origin;
|
|
419
|
+
if ("radius" in s && s.radius != null) st.borderRadius = s.radius;
|
|
420
|
+
if ("clip" in s && typeof s.clip === "string") st.clipPath = s.clip;
|
|
421
|
+
}
|