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

makeScene2D anywhere #2

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/2d/src/lib/scenes/makeScene2D.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import {
createSceneMetadata,
DescriptionOf,
FullSceneDescription,
ThreadGeneratorFactory,
} from '@revideo/core';
import type {View2D} from '../components';
import {Scene2D} from './Scene2D';

export function makeScene2D(
runner: ThreadGeneratorFactory<View2D>,
): DescriptionOf<Scene2D> {
export function makeScene2D(runner: ThreadGeneratorFactory<View2D>) {
return {
klass: Scene2D,
config: runner,
stack: new Error().stack,
meta: createSceneMetadata(),
plugins: ['@revideo/2d/editor'],
};

/**
* We need to cast this to `FullSceneDescription` because all makeScene2D calls
* are transformed into `FullSceneDescription` by one of the vite plugins.
*
* This transformation happens inside of `/packages/vite-plugin/src/partials/scenes.ts`.
*/
} as unknown as FullSceneDescription;
}
5 changes: 0 additions & 5 deletions packages/core/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@ declare module '*.glsl' {
export = value;
}

declare module '*?scene' {
const value: import('./lib/scenes/Scene').FullSceneDescription;
export = value;
}

declare type Callback = (...args: any[]) => void;
6 changes: 1 addition & 5 deletions packages/core/src/app/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ export interface ProjectSettings {
/**
* A list of scene descriptions that make up the project.
*
* @remarks
* A full scene description can be obtained by loading a scene module with a
* `?scene` query parameter.
*
* @example
* ```ts
* import exampleScene from './example?scene';
* import exampleScene from './example';
*
* export default makeProject({
* scenes: [exampleScene],
Expand Down
2 changes: 1 addition & 1 deletion packages/create/template-2d-js/src/project.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import example from './scenes/example?scene';
import example from './scenes/example';

export default makeProject({
scenes: [example],
Expand Down
2 changes: 1 addition & 1 deletion packages/create/template-2d-ts/src/project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import example from './scenes/example?scene';
import example from './scenes/example';

export default makeProject({
scenes: [example],
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/docs/advanced/custom-font.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Then, in `project.ts`, import the css file.
```ts
import {makeProject} from '@revideo/core';

import example from './scenes/example?scene';
import example from './scenes/example';

import './global.css'; // <- import the css

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/docs/getting-started/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ our example, this configuration is declared in `src/project.ts`:
```ts title="src/project.ts"
import {makeProject} from '@revideo/core';

import example from './scenes/example?scene';
import example from './scenes/example';

export default makeProject({
scenes: [example],
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e/tests/project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {makeProject} from '@revideo/core';

import circle from './scenes/circle?scene';
import rect from './scenes/rect?scene';
import circle from './scenes/circle';
import rect from './scenes/rect';

export default makeProject({
scenes: [circle, rect],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/code-block.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/code-block?scene';
import scene from './scenes/code-block';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/components?scene';
import scene from './scenes/components';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/layout-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/layout-group?scene';
import scene from './scenes/layout-group';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/layout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import layout from './scenes/layout?scene';
import layout from './scenes/layout';

export default makeProject({
scenes: [layout],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/logging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/logging?scene';
import scene from './scenes/logging';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/media-image.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/media-image?scene';
import scene from './scenes/media-image';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/media-video.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/media-video?scene';
import scene from './scenes/media-video';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/node-signal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/node-signal?scene';
import scene from './scenes/node-signal';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/positioning.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import node from './scenes/positioning?scene';
import node from './scenes/positioning';

export default makeProject({
scenes: [node],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/presentation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/presentation?scene';
import scene from './scenes/presentation';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/quickstart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/quickstart?scene';
import scene from './scenes/quickstart';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/random.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/random?scene';
import scene from './scenes/random';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tex?scene';
import scene from './scenes/tex';

export default makeProject({
scenes: [scene],
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/src/transitions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {makeProject} from '@revideo/core';

import first from './scenes/transitions-first?scene';
import second from './scenes/transitions-second?scene';
import first from './scenes/transitions-first';
import second from './scenes/transitions-second';

export default makeProject({
scenes: [first, second],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-color.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-color?scene';
import scene from './scenes/tweening-color';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-cubic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-cubic?scene';
import scene from './scenes/tweening-cubic';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-linear.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-linear?scene';
import scene from './scenes/tweening-linear';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-save-restore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-save-restore?scene';
import scene from './scenes/tweening-save-restore';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-spring.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-spring?scene';
import scene from './scenes/tweening-spring';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-vector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-vector?scene';
import scene from './scenes/tweening-vector';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/tweening-visualiser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeProject} from '@revideo/core';

import scene from './scenes/tweening-visualiser?scene';
import scene from './scenes/tweening-visualiser';

export default makeProject({
scenes: [scene],
Expand Down
2 changes: 1 addition & 1 deletion packages/template/src/project.meta
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"resolutionScale": 1,
"colorSpace": "srgb",
"exporter": {
"name": "@motion-canvas/ffmpeg",
"name": "@revideo/ffmpeg",
"options": {
"fastStart": true,
"includeAudio": true
Expand Down
5 changes: 2 additions & 3 deletions packages/template/src/project.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {makeProject} from '@revideo/core';

import example from './scenes/example?scene';
import {scene, scene2} from './scene';

export default makeProject({
experimentalFeatures: true,
scenes: [example],
scenes: [scene, scene2],
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"timeEvents": [
{
"name": "rect",
"targetTime": 0.6792665726375177
"targetTime": 0.9156612868172298
}
],
"seed": 3073416149
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ import {
waitUntil,
} from '@revideo/core';

export default makeScene2D(function* (view) {
export const scene = makeScene2D(function* (view) {
const rect = createRef<Rect>();

view.add(
<Rect ref={rect} size={320} radius={80} smoothCorners fill={'#f3303f'} />,
);

yield* waitUntil('rect');
yield* rect().scale(2, 1, easeInOutExpo).to(1, 0.6, easeInExpo);
rect().fill('#ffa56d');
yield* all(rect().ripple(1));
yield* waitFor(0.3);
});

/* meta=./scene2.meta */
export const scene2 = makeScene2D(function* (view) {
const rect = createRef<Rect>();

view.add(
Expand Down
10 changes: 10 additions & 0 deletions packages/template/src/scene2.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": 1,
"timeEvents": [
{
"name": "rect",
"targetTime": 0.9792357585408316
}
],
"seed": 3073416149
}
Loading
Loading