Skip to content

[Bug] Normalize Canvas renderer aliases and define constructor-prop updates #32

Description

@jonobr1

Summary

Make every renderer value accepted by the Canvas TypeScript API work at runtime, and define what happens when Two.js constructor options change after mount.

Current behavior

The React prop types accept both short aliases and Two.js renderer names:

  • canvas / CanvasRenderer
  • svg / SVGRenderer
  • webgl / WebGLRenderer

The short aliases are currently passed directly to new Two(...). Two.js expects renderer class names (or values from Two.Types), so a value such as type="canvas" fails with Two[this.type] is not a constructor. The README currently demonstrates type="webgl".

Additionally, the Two.js instance is constructed once. Later changes to type, ratio, overdraw, smoothing, or autostart are not applied and do not warn.

This issue does not propose restoring the removed container prop; the current styling API is intentional.

Acceptance criteria

  • Normalize canvas, svg, and webgl to their Two.Types values before construction, or remove unsupported aliases from the public type and documentation.
  • Test every documented renderer spelling.
  • Decide which constructor props are mutable, which recreate the Two.js instance, and which require a React key remount.
  • Apply mutable changes such as play/pause behavior when appropriate.
  • Warn in development when an immutable constructor prop changes without a remount.
  • Preserve children and clean up the old renderer when recreation is supported.
  • Update the README renderer examples to use tested values.
  • Add coverage for renderer selection and post-mount option changes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions