ThreePipe
    Preparing search index...

    Class CanvasRecorderPlugin

    Canvas Recorder Plugin

    Records the viewer canvas to a video (MP4 with ffmpeg.js, or the browser's MediaRecorder) or to an image sequence. In converge mode, each video frame is captured only after the ProgressivePlugin has converged, and the animations step by 1 / videoFrameRate per captured frame (see ProgressivePlugin.postFrameConvergedRecordingDelta).

    The MP4 recorder loads ffmpeg.js from FFMPEGRecorder.LIBRARY_PATH when it is created.

    Hierarchy (View Summary)

    Implements

    Index
    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    convergeMode: boolean = true
    enabled: boolean = true
    endPaddingMs: number = 500
    frameSink: CanvasFrameSink | undefined = undefined

    Where the frames of an image sequence go. Default: a folder the user picks (DirectoryFrameSink) in a browser that can (Chromium), and one zip download (ZipFrameSink) in the others (Safari, Firefox). A zip works in every browser, and holds the frames in memory until the end; a function or your own ICanvasFrameSink can send them to a server or memory. In converge mode the next frame waits for the sink. A failure is reported when the recording stops. Not saved with the plugin's settings.

    isViewerPluginSync: true = ...
    mimeType: string = 'video/mp4'
    toastErrors: boolean = true

    A failed recording shows why in a toast (viewer.dialog.toast, where the viewer's dialog has toasts), like a browser that can't save to a folder or a write that failed. Cancelling the folder picker shows none. The error event and a rejected record report it in code either way.

    uiConfig: UiObjectConfig = ...
    videoFrameRate: number = 30
    OldPluginType?: string
    PluginType: "CanvasRecorder" = 'CanvasRecorder'
    • Prompts for duration if not specified

      Parameters

      • duration: number | null = null
      • ccw: boolean = false
      • angle: number = 360
      • Optionalease: Easing
      • OptionalonStart: () => void

      Returns Promise<void>

    • Parameters

      • action: () => Promise<any>
      • OptionalonStart: () => void

      Returns Promise<Blob | undefined>

    • Parameters

      • durationNum: number
      • ccw: boolean = false
      • angle: number = 360
      • Optionalease: Easing
      • OptionalonStart: () => void

      Returns Promise<Blob | undefined>

    • Adds a recorder, for a new output with no change to this plugin. It's used when mimeType matches, and over the built-in ones. The last one registered for a format wins. Not while a recording runs.

      Parameters

      • name: string

        unique; registering a name again replaces that recorder

      • factory: CanvasRecorderFactory

        makes the recorder from the viewer's canvas, once, when it's first needed

      • match: (mimeType: string) => boolean = ...

        which values of mimeType it records. Default: the one equal to name

      • Optionalui: { label: string; mimeType: string }

        an entry in the format list of the plugin's UI: its label and the mimeType it sets

      Returns boolean

      false when a recording runs, and nothing changed

    • Stops the recording and resolves with the recording (no blob for an image sequence). A second call while the recording stops gets the same promise.

      Returns Promise<Blob | undefined>

    • Waits for a time of the video: in a converge-mode recording, for the steps of the recording (one frame each, as the animations step), so a pause has its length in the video; else for the wall time. A scene that does not converge (no step in maxFrameCount frames, e.g. a plugin that stays dirty) waits the rest on the wall clock. The frames in which a browser recorder still records a frame (canRecordFrame) do not count as such for two frame times of the video. It ends early when the recording ends.

      Parameters

      • ms: number

        the time in milliseconds

      Returns Promise<void>