Add orientation axes inset overlay to Scene#6026
Conversation
`Scene.set_axes_inset` and `set_axes_labels` overlay Three.js'
`ViewHelper` in a configurable corner — a small XYZ gizmo that
indicates camera orientation and snap-animates the camera to look
down an axis when clicked.
Position is wired through r184's `viewHelper.location` field
(`{top|bottom: my, left|right: mx}`); on-click forwards pointerdown
to `viewHelper.handleClick(event)` and stops propagation when an
axis sprite is hit so OrbitControls doesn't start a drag-rotate on
what was meant to be an inset click.
Both methods cache their opts on the Python side and replay them in
`_handle_init`, so a fresh client connect re-applies the inset
without the host having to re-call them.
Bumps the scene-bundle's `three` pin from `^0.180.0` to `^0.184.0`
because `viewHelper.location` was added in r184. As a result this
change targets nicegui v4 — earlier versions can't merge it without
backporting the location math by hand.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pre-commit's end-of-file-fixer hook flagged this on CI; rebuilt maps from rollup don't emit a trailing newline by default. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@evnchn @falkoschindler Not sure whats the process for PR that require package upgrades (and therefore next nicegui v4 release). Let me know if this should be switched back to a draft or if there is a v4 branch this should target instead. |
|
Hi @Jepson2k, there's no separate v4 branch — we keep development on |
|
Posted by Claude Code on @evnchn's behalf. Reinforcing the v4 gate so this doesn't get accidentally swept onto a 3.x bump in a triage pass —
|
ViewHelper.render() implicitly clears the framebuffer; without this guard the main scene gets wiped every frame after the helper renders, leaving an empty canvas. The original feature/additional_scene_features branch had this guard; it was lost in the simplification that split this PR out of zauberzeug#5993.
Motivation
Three.js ships with a
ViewHelper— a small XYZ orientation gizmo that indicates the camera's view direction and snap-animates the camera to look down an axis when an axis sprite is clicked. This PR exposes it throughSceneso users can drop a small inset into a corner of the canvas without writing JS.This was originally part of #5993 (scene-clipping-axes), but supporting it on the current
^0.180.0three.js pin required a manual scissor + viewport block in the render loop and a fake-clientX/clientY synthesis aroundViewHelper.handleClickto compensate for r180's hardcoded bottom-right/dim=128 assumptions — both fragile workarounds. r184 added aviewHelper.locationfield that handles positioning natively, so I split this out as a follow-up that targets nicegui v4 (where the three.js pin can move to r184).Implementation
Two new methods on
Scene:set_axes_inset(*, enabled, margin, margin_x, margin_y, anchor)— toggles the inset on a configurable corner. Position is wired throughviewHelper.location({top|bottom: my, left|right: mx}). The inset is fixed at 128 px (a hardcoded constant inside three.js'ViewHelper).set_axes_labels(*, enabled, labels, font, color, radius)— replaces the defaultX/Y/Zlabels and customizes their typography. Forwards toviewHelper.setLabelsandsetLabelStyle.Click-to-snap is wired via a single capture-phase
pointerdownlistener that callsviewHelper.handleClick(event)and stops propagation when an axis sprite is hit, so OrbitControls doesn't start a drag-rotate on what was meant to be an inset click.Both methods cache their opts on the Python side and replay them in
_handle_init, so a fresh client connect (e.g. after a reload) re-applies the inset without the host having to re-call them.The scene-bundle's
threepin is bumped from^0.180.0to^0.184.0becauseviewHelper.locationwas added in r184. As a result this change can only land in nicegui v4 — earlier versions can't merge it without backporting the location math by hand.Progress
Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com