Skip to content

feat: add scene.markerrender to draw scatter3d circle markers as discs - #4

Draft
katosh wants to merge 2 commits into
mainfrom
pr/disc-markers
Draft

katosh wants to merge 2 commits into
mainfrom
pr/disc-markers

Conversation

@katosh

@katosh katosh commented Dec 4, 2026 •

Copy link
Copy Markdown

Description

This adds scene.markerrender. The value disc draws a scatter3d circle marker as one vertex instead of 60 to 104. That cuts the vertex buffer from 4,160 to 36 bytes per marker. A disc also draws marker.line.width as requested, which addresses plotly#3796 for circle markers. The default is glyph, so nothing changes unless a user opts in.

Bar chart: the vertex buffers hold 4,160 bytes for each glyph marker and 36 bytes for each disc, measured in plotly.js with 1 million markers
Vertex buffer bytes per marker, glyph and disc.

Today each circle marker is a glyph mesh of 60 fill and 44 outline vertices. At 1 million markers the vertex buffers hold 4.16 GB. The outline is a GL line, and Chrome with ANGLE caps a GL line at 1 px (plotly#3796).

Nine enlarged markers. At size 60, the glyph shows polygon corners, the hard disc a stepped edge, and the soft disc a smooth edge
Glyph, hard disc and soft disc at marker sizes 3, 20 and 60, enlarged 2x at pixel ratio 2. The box shows one edge at 8x.

A disc is one gl.POINTS sprite. The fragment shader cuts out the round shape and the outline ring. Alpha-to-coverage smooths the edge on an opaque scene.bgcolor. A transparent canvas and Plotly.toImage blend a rim. Other symbols, axis projections and markers above the GPU point size limit keep the glyph path.

AnnZarro, a viewer for single-cell data, motivates the change. I am glad to rework, split or drop any part.

Addresses plotly#3796 for circle markers with scene.markerrender: 'disc'.

Closes #XXXX

Changes

  • scene.markerrender: glyph (default), disc and auto. auto is currently the same as disc.
  • stackgl_modules/package.json pins a gl-scatter3d fork commit that draws the discs, as in 58d0503 (the gl-vis pull request follows)
  • Plotly.toImage marks the scene so that exports get soft edges
  • Schema, generated types and draftlogs/XXXX_add.md

Testing

  • Ten new specs in scatter3d_test.js and gl3dlayout_test.js cover vertex counts, fallbacks, outlines, the default and hover
  • With the attribute unset or glyph, seven scenes render the same pixels as main at pixel ratios 1 and 2, and hover ids match
  • Suites scatter3d, gl3dlayout, gl3d_hover_click, gl3d_plot_interact, plot_schema and toimage fail the same four specs on main and on this branch in headless Chrome
  • npm run lint, npm run typecheck, npm run test-syntax and npm run schema-typegen-diff-check pass

Notes

  • The default glyph keeps every baseline. A default of auto moves about 52 image baselines.
  • Squares, diamonds and the other symbols keep the 1 px outline of 3D Scatter Plot marker->line->width attribute appears to be broken on some hardware plotly/plotly.js#3796
  • A disc differs from a glyph at the edge by about 1 px. At pixel ratio 2 the hover target of a disc is the visible marker, and a glyph has half that radius.
  • All traces, minified: 4,821,312 bytes on main and 4,831,937 bytes on this branch
  • This pull request and the one for scene.oit pin different gl-scatter3d commits. The second of the two to merge pins settylab/gl-scatter3d 308dcbb and takes one spec. That commit holds the two changes and a disc shader for the OIT passes. Translucent discs under scene.oit: 'auto' need that shader. The branch pr/disc-oit holds this state, built and tested.

Checklist

  • The linked issue has the ready-for-pr label, and it has no assignee or lists me as an assignee
  • I opened the pull request from a branch other than main in my fork
  • I selected "Allow edits from maintainers"
  • I did not edit files in dist/
  • I committed package-lock.json only for a dependency change
  • I added a file to draftlogs/ as draftlogs/README.md describes, or I will add one after the pull request opens

A circle marker is a vectorized glyph mesh of 60 to 104 vertices, about
4,160 bytes in the vertex buffers. With scene.markerrender set to disc or
auto, circle and circle-open markers draw as one gl.POINTS vertex with a
round cutout in the fragment shader, with an outline ring for
marker.line.width. Other symbols, projections on the axes and sprites larger
than the point size limit keep the glyph path. The default is glyph, so
rendering does not change unless the attribute is set.

gl-scatter3d is pinned to a fork commit, and stackgl_modules/index.js is
rebuilt from it.
The value disc draws a glyph where a disc cannot draw the marker, and auto
is the same as disc for now. The first description left both out.
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.

1 participant