Repository: motion-canvas/motion-canvas
File: packages/core/src/Project.ts (TypeScript)

Code before:
      this.previousBuffer.height =
        this.size.y * this._resolutionScale;

    this.render();
  }

  public setCanvas(value: HTMLCanvasElement | null = null) {
    this.canvas = value;
    this.updateCanvas();
  }

  public setSize(size: PossibleVector2): void {
    this.size = new Vector2(size);
    this.updateCanvas();
    this.reloadAll();
  }

  public getSize(): Vector2 {
    return this.size;
  }

  public setVariables(variables: object) {
    this.variables = variables;
    if (this.scenes.current[0]) {
      this.scenes.current[0].variables.updateSignals();
    }
  }

  public getVariables(): {[key: string]: any} {
    return this.variables;
  }

  public readonly name: string;
  public readonly audio = new AudioManager();
  public readonly logger = new Logger();
  public readonly background: string | false;
  public readonly creationStack: string;
  public playbackState = createSignal(PlaybackState.Paused);
  private readonly renderLookup: Record<number, Callback> = {};
  private _resolutionScale = 1;
  private _colorSpace: CanvasColorSpace = 'srgb';
  private _fileType: CanvasOutputMimeType = 'image/png';
  private _quality = 1;
  private _speed = 1;
  private framesPerSeconds = 30;
  private previousScene: Scene | null = null;
  private canvas: HTMLCanvasElement | null = null;
  private context: CanvasRenderingContext2D | null = null;
  private buffer = document.createElement('canvas');
  private bufferContext: CanvasRenderingContext2D | null = null;
  private previousBuffer = document.createElement('canvas');

Review comment (suggestion):
It should be:
```suggestion
    this.currentScene.current?.variables.updateSignals();
```
There can be more than one scene in a project. We're interested in updating the current one, not the first one.

Code after:
      this.previousBuffer.height =
        this.size.y * this._resolutionScale;

    this.render();
  }

  public setCanvas(value: HTMLCanvasElement | null = null) {
    this.canvas = value;
    this.updateCanvas();
  }

  public setSize(size: PossibleVector2): void {
    this.size = new Vector2(size);
    this.updateCanvas();
    this.reloadAll();
  }

  public getSize(): Vector2 {
    return this.size;
  }

  public setVariables(variables: Record<string, unknown>) {
    this.variables = variables;
    this.currentScene.current?.variables.updateSignals();
  }

  public getVariables(): {[key: string]: any} {
    return this.variables;
  }

  public readonly name: string;
  public readonly audio = new AudioManager();
  public readonly logger = new Logger();
  public readonly background: string | false;
  public readonly creationStack: string;
  public playbackState = createSignal(PlaybackState.Paused);
  private readonly renderLookup: Record<number, Callback> = {};
  private _resolutionScale = 1;
  private _colorSpace: CanvasColorSpace = 'srgb';
  private _fileType: CanvasOutputMimeType = 'image/png';
  private _quality = 1;
  private _speed = 1;
  private framesPerSeconds = 30;
  private previousScene: Scene | null = null;
  private canvas: HTMLCanvasElement | null = null;
  private context: CanvasRenderingContext2D | null = null;
  private buffer = document.createElement('canvas');
  private bufferContext: CanvasRenderingContext2D | null = null;
  private previousBuffer = document.createElement('canvas');
  private previousBufferContext: CanvasRenderingContext2D | null = null;
  private exportCounter = 0;