MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / captureMotionPathShot

Function captureMotionPathShot

packages/cli/src/commands/motionShot.ts:606–663  ·  view source on GitHub ↗
(
  projectDir: string,
  requestsIn: ShotRequest[],
  outPath: string,
  opts: ShotOptions = {},
)

Source from the content-addressed store, hash-verified

604/** Render `projectDir`'s index headless, sample each element's motion as a 3D
605 * onion-skin, screenshot to `outPath` (PNG). Returns the saved path. */
606export async function captureMotionPathShot(
607 projectDir: string,
608 requestsIn: ShotRequest[],
609 outPath: string,
610 opts: ShotOptions = {},
611): Promise<string> {
612 let requests = requestsIn;
613 const samples = Math.max(1, Math.min(60, opts.samples ?? 9));
614 const layout = opts.layout ?? "path";
615 const fit = opts.fit ?? true;
616 const camera = parseAngle(opts.angle);
617
618 const { ensureBrowser } = await import("../browser/manager.js");
619 const { serveStaticProjectHtml } = await import("../utils/staticProjectServer.js");
620 const { bundleToSingleHtml } = await import("@hyperframes/core/compiler");
621
622 const html = await bundleToSingleHtml(projectDir);
623 const server = await serveStaticProjectHtml(
624 projectDir,
625 html,
626 "Failed to bind motion shot server",
627 );
628 let browserInstance: import("puppeteer-core").Browser | undefined;
629 try {
630 const browser = await ensureBrowser();
631 const opened = await openCompositionPage(server.url, browser.executablePath);
632 browserInstance = opened.browser;
633 const { page, size } = opened;
634
635 if (opts.scopeSelector && !opts.ghost) {
636 requests = await resolveScopedRequests(page, requests, opts.scopeSelector);
637 }
638
639 const times = sampleTimes(
640 await timelineDuration(page),
641 samples,
642 opts.from ?? null,
643 opts.to ?? null,
644 );
645
646 if (opts.ghost) {
647 return await captureGhostOnionSkin(page, requests, times, size, camera, outPath);
648 }
649
650 return await captureMarkerOnionSkin(
651 page,
652 requests,
653 times,
654 size,
655 camera,
656 { layout, fit, hasWindow: opts.from != null || opts.to != null },
657 outPath,
658 );
659 } finally {
660 await browserInstance?.close().catch(() => {});
661 await server.close().catch(() => {});
662 }
663}

Callers 1

runOnionShotFunction · 0.85

Calls 11

parseAngleFunction · 0.85
bundleToSingleHtmlFunction · 0.85
serveStaticProjectHtmlFunction · 0.85
ensureBrowserFunction · 0.85
openCompositionPageFunction · 0.85
resolveScopedRequestsFunction · 0.85
sampleTimesFunction · 0.85
timelineDurationFunction · 0.85
captureGhostOnionSkinFunction · 0.85
captureMarkerOnionSkinFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected