Skip to content

Conversation

@mikeharv
Copy link
Contributor

@mikeharv mikeharv commented Sep 10, 2025

Summary

Introduce a pluggable “external dancer” rendering layer that Dance Party can composite between sprites and foreground effects. This allows the main code-dot-org repo to supply its own renderer (e.g., a Lottie-based dancer preview) without adding that dependency to Dance Party.

The external renderer layer is shown below as bull dancer that is provided by a Lottie renderer introduced with code-dot-org/code-dot-org#68250

2025-09-09.15-37-31.2025-09-09.15_38_01.mp4

We have multiple surfaces that need to render the same generated dancer JSON (Dance Party canvas, a Dancer Editor, and a Music Lab view). Centralizing the rendering logic in the main repo keeps Dance Party lean and lets other surfaces reuse the same renderer.

What changed

  • New adapter: ExternalDancerLayer (p5 adapter that owns a p5.Graphics buffer and hands its 2D context to an external renderer).
  • New injection point: DanceParty now accepts an optional externalRendererFactory (constructor option). If provided, setup() creates an ExternalDancerLayer.
  • New helper: setExternalLayerSource(danceMove) informs the render which dancer animation source JSON to use.
  • Reset/teardown: Resets clear or dispose the external layer cleanly.

Behavioral notes

  • If no externalRendererFactory is provided, no behavior change: sprites and effects render as before.
  • Timing for the external layer is driven by the current song measure, so it stays in sync with sprites.
  • This code does not change any behavior for the standalone DanceParty package, unless a compatible external renderer is provided.

Deployment strategy

Pairs with code-dot-org/code-dot-org#68250 (adds the concrete Lottie renderer and passes the factory into DanceParty).

Testing story

  • Verified dancer renders inside the Dance Party canvas and respects layout (fit/center/scale).
  • Confirmed sprite split rendering shows “in front of”/“behind” correctly.
  • Verified sync with song beat and sprite timing.
  • Resizing and disposal don’t leak canvases.

@mikeharv mikeharv marked this pull request as ready for review September 10, 2025 18:43
Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! a few minor things/questions

Copy link
Member

@breville breville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving so you're not blocked on me. Fantastic work! Thanks for addressing all of my comments.

@sanchitmalhotra126 should approve separately, because he had a lot of other good feedback, before this is merged.

Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mikeharv mikeharv merged commit 3dc76d1 into main Oct 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants