FX Graph & Vision Puppeteer

FX Graph (PipelineMermaidPanel) is PinePaper’s executable Mermaid pipeline editor. It connects live media inputs (camera, uploaded video, canvas video, or a built-in sample clip) through MediaPipe landmark tracking (Pose33, Hands21, Face52) to rigged characters (Character:CelSkeleton, Character:ActiveRig), signal mappers (Map:*), GPU shaders (Shader:*), and live canvas items (Output:Canvas).

Launching FX Graph

  • UI trigger: Click FX Graph (#fxGraphBtn) in the editor header bar, which lazy-loads js/ui/PipelineMermaidPanel.js via openPipelineMermaidPanel(app).
  • Before starting: The panel automatically calls await app.ensureHeavyModules() before compiling or starting VisionPuppeteer, ensuring RiggingSystem and VisionPuppeteer are ready before media acquisition begins.

Media Input Sources

VisionPuppeteer (js/VisionPuppeteer.js) and PipelineMermaidPanel (#pmMediaSourceSelect) support four uniform media sources via vp.setMediaSource(spec) or options.mediaSource in vp.start(skeletonId, options):

Source Value Description
Live Camera 'camera' Calls navigator.mediaDevices.getUserMedia(...). Requires Permissions-Policy: camera=(self) on /editor, /editor.html, and /editor/*.
Uploaded Video File 'file' Reads a user-selected .webm, .mp4, .ogg, or .mov file via URL.createObjectURL(file). Rejects empty or unsupported files before spawning skeletons.
Canvas Video (MediaPipeline) 'canvas-video' Attaches to an existing VideoRaster / MediaPipeline video item on the canvas (itemId).
Built-in Sample Clip 'sample' Generates an offline procedural 33-landmark stick-figure stream (captureStream(30) + deterministic pose frames) requiring neither camera hardware nor network access.

Preview, Overlay & Deferred Spawn Contract

  • Mounted preview & overlay: Call vp.setPreviewElement(videoEl) (#pmPreviewVideo) and vp.setOverlayCanvas(canvasEl) (#pmOverlayCanvas) before vp.start(...) so live frames and MediaPipe landmark overlays render visibly inside the panel.
  • Deferred cel_skeleton spawn: vp.start() registers options.onStatus first and completes media acquisition before invoking autoSpawnPreset (cel_skeleton). If camera permission is denied (NotAllowedError) or a media file fails validation, vp.start() returns false, reports the error through onStatus, leaves #pmStatus in the error state (never "Pipeline running"), and avoids leaving orphaned skeletons on the canvas.
  • Close cleanup: Closing the modal ([data-pm-close] or backdrop click) stops the active bridge runtime, stops VisionPuppeteer, and releases all active media stream tracks.

Mermaid Pipeline Nodes (MermaidPipelineBridge)

MermaidPipelineBridge (js/diagram/MermaidPipelineBridge.js) parses flowchart LR / flowchart TD graphs, validates DAG acyclicity, and executes nodes in topological order:

Category Node Types Behavior
Input MediaPipe:Pose33, MediaPipe:Hands21, MediaPipe:Face52 Extracts 33-point body pose, 21-point hand landmarks, and 52 facial blendshape weights.
Mapping Map:Clamp, Map:Smooth, Map:Threshold Shapes and smooths derived scalar signals (pinchL, pinchR, handOpenR, energy).
Character Character:CelSkeleton, Character:ActiveRig Drives targetApp.riggingSystem pose updates (applyExternalPose / setBoneAngle + solveFK / loadShapeKey) and refreshes view.update().
Shaders & Output Shader:SelectiveBloom, Shader:Relighting3D, Shader:DOF, Shader:CustomGLSL, Output:Canvas Binds live uniforms to a shaderGraph canvas item (data.renderAs === 'shaderGraph', data.fxGraphManaged === true) via ShaderGraphItem / shaderGraphUI.

Starter Recipes & Telemetry

Six starter recipes are available in PIPELINE_MERMAID_PRESETS (#pmRecipeSelect): cel_skeleton_puppet, pinch_bloom_relight, face_dof_portrait, energy_aura_rig, custom_glsl_hand_fx, and motion_capture_record. While running, #pmTelemetry streams live JSON frames containing fps, source, poseActive, poseJoints, hands, faceBlendshapes, derived, activeShaders, and outputs.

Permissions Policy

In _headers, /* enforces camera=() by default, while /editor, /editor.html, and /editor/* detach Permissions-Policy (! Permissions-Policy) and re-declare Permissions-Policy: camera=(self), microphone=(), geolocation=(), payment=(), display-capture=(self). Video frames are processed locally on-device and never uploaded.