Skip to content

[Bug] Align pointer events with Two.js coordinates and scene order #34

Description

@jonobr1

Summary

Follow up on the event system introduced in #16 and align pointer coordinates, hit ordering, bubbling, and missed-event behavior with the actual Two.js scene graph.

Known correctness gaps

  • Hit testing uses top-left Two.js world coordinates, while TwoEvent.point subtracts half the canvas width and height and reports a different coordinate space.
  • Shapes under different parent groups fall back to event-registration order rather than complete scene-graph draw order.
  • A Group with handlers but no registered interactive child is tested through the Group bounding rectangle, which can report hits in empty areas.
  • onPointerMissed currently fires on a missed pointer-up; its relationship to click, pointer-down, and pointer-capture semantics is not defined.
  • Pointer capture is inferred from the renderer DOM element, but the synthetic Two.js event does not expose a clear capture API.

Two.js now has contains(...) and Group.getShapesAtPoint(...); the React event layer should use the upstream traversal where possible rather than maintain a competing partial ordering model.

Acceptance criteria

  • Define and document whether event points are renderer, world, parent-local, or target-local coordinates.
  • Return coordinates consistently for click, wheel, pointer, bubbling, and captured events.
  • Resolve topmost targets from the complete current Two.js scene order, including nested and reordered groups.
  • Define and test Group hit behavior for sparse, nested, transparent, invisible, clipped, and masked content.
  • Define onPointerMissed semantics and test down/up/click/cancel sequences.
  • Provide a supported pointer-capture pattern for shape dragging.
  • Keep bubbling and stopPropagation() behavior deterministic.
  • Add renderer coverage for SVG, Canvas, and WebGL where behavior differs.
  • Add tests that assert handler calls and event payloads, not only that the renderer element exists.

Related work

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