RPE Chart Utils
    Preparing search index...

    Class ExtraBuilder

    Fluent builder for PhiraExtra.

    Wraps a PhiraExtra object and provides ergonomic methods for creating shader effects (with fluent per-uniform configuration via EffectBuilder) and videos.

    // From scratch:
    const extra = new ExtraBuilder(120);

    // Wrap an existing parsed extra.json:
    const extra = ExtraBuilder.from(existingExtra);
    import { readFileSync } from 'fs';

    const glsl = readFileSync('shaders/camera.glsl', 'utf8');

    new ExtraBuilder(120)
    .addShader('/camera.glsl', glsl, 0, 32) // auto-populates defaults from GLSL
    .animate('posZ', 5, 0.5, { easing: 'cubicOut' })
    .animate('rotX', 0, Math.PI * 6, { easing: 'cubicOut' })
    .setRange(100, 101)
    .toExtra()
    .serialize();
    Index

    Constructors

    Accessors

    Methods

    • Add a shader effect and return a fluent EffectBuilder for configuring its uniform variables inline.

      Parameters

      • shader: string

        Built-in name ('chromatic') or custom path ('/myshader.glsl').

      • startBeat: number

        Effect start beat.

      • endBeat: number

        Effect end beat.

      • vars: Record<string, Variable> = {}

        Initial variable overrides (static or animated).

      • options: Omit<CreateEffectOptions, "vars"> = {}

        Additional options (global, targetRange).

      Returns EffectBuilder

      extra.addEffect('chromatic', 0, 8)
      .animate('power', 0, 0.05, { easing: 'sineInOut' })
      .set('sampleCount', 5);
    • Add a custom shader effect whose default uniform values are auto-parsed from the provided GLSL source code.

      Uniforms annotated with // %default% comments in the shader become the initial variable values. You can then override or animate specific uniforms via the returned EffectBuilder.

      Parameters

      • shaderPath: string

        Custom shader path (e.g. '/camera_ssaa.glsl'). A leading / is added automatically if missing.

      • glslSource: string

        Full GLSL shader source text.

      • startBeat: number

        Effect start beat.

      • endBeat: number

        Effect end beat.

      • options: Omit<CreateEffectOptions, "vars"> = {}

        Additional options.

      Returns EffectBuilder

      import { readFileSync } from 'fs';
      const glsl = readFileSync('shaders/camera.glsl', 'utf8');

      extra.addShader('/camera.glsl', glsl, 0, 32, {
      targetRange: { minZIndex: 100, maxZIndex: 101 },
      })
      .animate('posZ', 5, 0.5, { easing: 'cubicOut' })
      .animate('rotX', 0, Math.PI * 6, { easing: 'cubicOut' });
    • Remove a shader effect by index. Returns this for chaining.

      Parameters

      • index: number

      Returns this

    • Add a video background.

      Parameters

      Returns this

      extra.addVideo('bg.mp4', 0, { scale: 'cropCenter', dim: 0.3 });
      
    • Remove a video by index. Returns this for chaining.

      Parameters

      • index: number

      Returns this

    • Offset all effects and videos by beatOffset beats.

      Parameters

      • beatOffset: number

      Returns this

    • Sort effects by start beat.

      Returns this

    • Serialize to a JSON string.

      Parameters

      • pretty: boolean = true

      Returns string