@motion-script/core / createScene
Function: createScene()
createScene(
generator):Scene
Defined in: nodes/scene/scene-node.ts:458
Create a scene from a generator body. This is the only way to author a scene:
// scenes/intro.tsx import { createScene, Rect } from '@motion-script/core';
export default createScene(function* (stage) { stage.set({ fill: 'bg' }); stage.add(); yield* …; });
For a parameterized scene, write a function that returns a generator and
call it per ?scene file (one instance per file keeps the hot-reload boundary
intact):
// scenes/card.ts (shared factory — not a ?scene file) export const card = (opts: { color: string }): SceneGenerator => function* (stage) { stage.add(); yield* …; };
// scenes/blue-card.tsx (a ?scene file → one instance) export default createScene(card({ color: 'royalblue' }));