Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update engine to include ProjectConfig in world initialization and modify disposal logic

konstantin-paulusa2ef63a9ebfa
diff --git a/apps/web/src/engine/create-engine.ts b/apps/web/src/engine/create-engine.ts
index becbee92..f15e77e8 100644
--- a/apps/web/src/engine/create-engine.ts
+++ b/apps/web/src/engine/create-engine.ts
@@ -5,7 +5,7 @@
import { renderSystem, transformSystem, playbackSystem, motionSystem, AudioEngine, createRuntimeWorld, RenderSurface, Time, ChildOf, syncInteractiveState } from '@diffusionstudio/runtime';
import { hudSystem } from './hud';
import { createSignal, type Accessor, type Setter } from 'solid-js';
-import { AssetSelection, Hud, Keys, Pointer, PointerEvents, SnapLines } from './traits';
+import { AssetSelection, Hud, Keys, Pointer, PointerEvents, ProjectConfig, SnapLines } from './traits';
import { inputSystem } from './input/input-system';
import { shortcutSystem } from './input/shortcuts';
@@ -47,7 +47,7 @@ class Engine {
public constructor(projectId: string, options: EngineOptions = {}) {
this.world = createRuntimeWorld(projectId);
- this.world.add(Pointer, Keys, SnapLines, Hud, PointerEvents, AssetSelection);
+ this.world.add(Pointer, Keys, SnapLines, Hud, PointerEvents, AssetSelection, ProjectConfig);
this.unsubscribe.push(
this.world.onAdd(ChildOf('*'), () => (this.interactiveDirty = true)),
diff --git a/apps/web/src/engine/project-config.ts b/apps/web/src/engine/project-config.ts
index dc025326..ee4b344f 100644
--- a/apps/web/src/engine/project-config.ts
+++ b/apps/web/src/engine/project-config.ts
@@ -163,7 +163,9 @@ export class ProjectConfig {
/** Detaches the config from the world. */
public dispose(): void {
this.disposed = true;
- if (this.world.get(ProjectConfigTrait) === this) this.world.remove(ProjectConfigTrait);
+ if (this.world.get(ProjectConfigTrait) === this) {
+ this.world.set(ProjectConfigTrait, null);
+ }
}
}