MotionScript

@motion-script/core


@motion-script/core / serializeScenePrecomp

Function: serializeScenePrecomp()

serializeScenePrecomp(precomp): SerializedScenePrecomp | null

Defined in: runtime/precomp-cache.ts:84

Reduce a scene's pass to JSON-safe values, or return null if it holds something that cannot survive the round trip.

Returning null rather than a lossy entry is the whole safety story here: a cache that silently drops an asset reference or an audio automation curve would produce a subtly wrong timeline on the next run, which is far worse than simply measuring the scene again. Callers treat null as "this scene is not cacheable" and fall back to a real pass.

Two things trigger it:

  • A loader record. LoaderRecord.load is a live closure owned by the requesting package, and a function cannot be revived from JSON. (No built-in path produces one today — the sole caller is gated behind a View3D resource loader that nothing registers — so this is a guard against a future regression, not a common case.)
  • A curve-valued audio filter param. Curve is a class whose segments carry EasingFunctions; reviving one would need an easing registry keyed by name. Detected via filtersKey, which already has to enumerate every param of every filter type for playback identity — so this check cannot drift out of sync as filter types are added.

Parameters

precomp

ScenePrecomp

Returns

SerializedScenePrecomp | null