Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow runtime plugins to extend scene meta fields #927

Open
shmishtopher opened this issue Jan 31, 2024 · 0 comments
Open

Allow runtime plugins to extend scene meta fields #927

shmishtopher opened this issue Jan 31, 2024 · 0 comments
Labels
a-core Relates to the core package b-enhancement New feature or request c-accepted The issue is ready to be worked on

Comments

@shmishtopher
Copy link
Contributor

Description
Runtime plugins should be able to configure project and scene meta fields in a similar manner to custom exporters. This would enable editor plugins to easily add new gizmos as well as allowing for state-persisting hooks similar to the existing waitUntil and useDuration functions.

Proposed solution
The API should extend makePlugin (and makeEditorPlugin) with functions for configuring both project level and scene level meta fields, similar to how custom exporters provide meta fields through meta() .

import {makePlugin} from '@motion-canvas/core';

export default makePlugin({
  name: 'motion-canvas-plugin-example',
  projectMeta() {
    return new ObjectMetaField('customProjectFields', {
      propA: new BoolMetaField('propA', true),
      propB: new BoolMetaField('propB', true),
    });
  },
  sceneMeta() {
    return new ObjectMetaField('customProjectFields', {
      propC: new BoolMetaField('propC', false),
      propD: new BoolMetaField('propD', true),
    });
  },
  player(player) {
    player.onRecalculated.subscribe(() => {
      player.requestReset();
      player.togglePlayback(true);
    });
  },
});

Considered alternatives
Currently, the best way for plugins to implement stateful interaction between the editor and animation (like useDuration) is to use the vite websocket to send messages between the editor and server, and then fetch that data in the scene whenever it is recalculated.

@shmishtopher shmishtopher added the b-enhancement New feature or request label Jan 31, 2024
@aarthificial aarthificial removed their assignment Feb 1, 2024
@aarthificial aarthificial added c-accepted The issue is ready to be worked on a-core Relates to the core package labels Feb 1, 2024
@shmishtopher shmishtopher changed the title Allow runtime plugins to extends scene meta fields Allow runtime plugins to extend scene meta fields Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-core Relates to the core package b-enhancement New feature or request c-accepted The issue is ready to be worked on
Projects
None yet
Development

No branches or pull requests

2 participants