Skip to content

feat: add alwaysontop to scatter3d traces to keep a highlight visible - #6

Draft
katosh wants to merge 2 commits into
pr/oitfrom
pr/alwaysontop
Draft

katosh wants to merge 2 commits into
pr/oitfrom
pr/alwaysontop

Conversation

@katosh

@katosh katosh commented Dec 5, 2026 •

Copy link
Copy Markdown

Stacked on #5 (scene.oit); the base is pr/oit.

Description

alwaysontop: true on a scatter3d trace draws its markers last, over everything else, with no depth test. The default is false and changes no pixel. The markers stay pickable.

AnnZarro, a viewer for single-cell data, motivates the change. It marks the focused cell with a ring. We will rework, split or drop any part. Related: a plotly.js issue follows. Overview: #11.

Points in front hide a highlight inside a dense cloud. On a translucent cloud, they also tint it.

With scene.oit: 'auto' (#5, plotly#1267), translucent markers blend by depth, so the order of the traces no longer puts a highlight on top. alwaysontop gives that control back as an explicit attribute.

Four renders in one camera loop: markers cut or hide a black ring on the left, and the full ring shows on the right

One camera loop. On upstream main, the markers in front cut the ring, and the cut changes with the camera. In the dense cloud, the ring has 0 visible pixels in all 72 frames. With alwaysontop: true, the full ring shows in each frame.

Four renders with scene.oit in one camera loop: the ring is cut or hidden on the left and shows in full on the right

The two sides use scene.oit: 'auto', and the highlight is the last trace. Without alwaysontop, depth decides, and the last trace no longer shows on top. The ring is cut in the sparse cloud and has 0 near-black pixels in the dense one.

The depth, opaque and transparent passes skip flagged markers. The render loop then draws them after the composite, in trace order. It works with scene.oit set to 'off' or 'auto'. In the spec, pixels outside the marker stay identical.

Changes

Testing

  • 4 specs in scatter3d_test.js
  • With the flag unset, seven scenes render byte-identical to main

Notes

  • The pick pass still uses depth. If other pickable points hide a flagged marker, the scene picks the nearest point.
  • Flagged markers also draw over axes, spikes and meshes

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/ (XXXX_add_alwaysontop.md, to rename with the PR number)

The fork skips objects with alwaysOnTop in the depth, opaque and transparent passes and draws them after the composite.
Rebuild stackgl_modules/index.js with npm run bundle-stackgl.
Points in front hide a highlighted marker inside a dense cloud.
The markers of a trace with alwaysontop true draw last, over everything else, with no depth test.
The default is false and changes no pixel. The markers stay pickable.
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