Add reorientation component: face the direction of travel#640
Open
borismasis wants to merge 1 commit into
Open
Add reorientation component: face the direction of travel#640borismasis wants to merge 1 commit into
borismasis wants to merge 1 commit into
Conversation
Reorients each spherical (360) image to face the direction of travel (the
great-circle bearing toward the next image in the sequence) as the user
navigates, instead of facing off to the side or behind. Can be disabled with component: { reorientation: false }.
ReorientationEngine (pure, unit-tested): GPS-speed motion detection with a
low-speed-turn allowance, GPS-outlier rejection, and last-confirmed-bearing
fallback. Results cached and prefetched ahead.
ReorientationComponent: feeds the engine from the viewer's graph and steers
via a new eased state op (rotateToBasicSmooth); a manual look-around offset
is preserved across the sequence.
82d4117 to
e5904b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add reorientation component: face the direction of travel
Summary
Adds a
reorientationcomponent that, as the user navigates a sequence,reorients each spherical image to face the direction of travel (the
great-circle bearing toward the next image) instead of preserving the previous
look direction.
Active by default, opt-out like other default components:
Why
When stepping through a sequence the stock viewer keeps the previous look
direction, so a user looking forward ends up looking sideways/backward after a
turn. Facing the travel direction matches user intent for "driving down the
street" navigation. Because it lives in mapillary-js, every client that embeds
the viewer benefits.
How
ReorientationEngine(pure, unit-tested): from an image's position, thenext image's position, and the compass angle, computes the basic-x that frames
the travel direction. Motion is detected from GPS speed with a low-speed-turn
allowance; GPS outliers are rejected against recent bearings; stationary images
fall back to the last confirmed moving bearing so the view is preserved rather
than spun by noise. Results are cached and prefetched ahead so a step lands on
an already-resolved bearing.
ReorientationComponent: subscribes tocurrentImage$, feeds the enginefrom the viewer's graph (
cacheImage$/cacheSequence$), and steers the view:reconstruction) eases to the travel direction via
rotateToBasicSmooth;a mesh-less image (no smooth transition is possible) snaps via
rotateToBasic, so the reorientation doesn't pan over what is already aninstant cut. The decision is per-image, independent of how you arrived
(deep link, in-sequence step, or jump).
less than ~15° is skipped, so near-straight steps don't jitter; it re-faces
only on real turns.
carried pitch are reset on a sequence change — a new sequence starts at the
travel direction, nothing carries over from the previous one.
(
mouseDragEnd$), the horizontal offset from the computed forward isremembered and re-applied to subsequent images in the same sequence,
instead of re-facing forward on every step.
Eased state operation
rotateToBasicSmooth([basicX, y])(the eased siblingof the existing snap
rotateToBasic): sets the state's_desiredLookat, which_updateLookatlerps the current camera toward each frame — so an easedreorientation stays smooth whether it lands within the running image transition
or after the transition has already settled.
Flash-free hard cuts (state hint). On a motionless/instant transition the
new image would render one frame at the carried view before the component's
reactive snap lands, a visible flash. To avoid it, the component registers a
per-image reorientation hint with the state (
setReorientation); thetraversing state applies it to the image's camera as it becomes current —
before that frame is rendered — but only on instant transitions (a smooth
transition still eases). Hints are cleared on a sequence change.
Files
New:
src/component/reorientation/ReorientationEngine.ts— pure, testable math +motion engine
src/component/reorientation/ReorientationComponent.tssrc/component/interfaces/ReorientationConfiguration.tstest/component/reorientation/ReorientationEngine.test.tsEased state operation (
rotateToBasicSmooth, internal service API):src/state/state/InteractiveStateBase.ts(implementation)src/state/state/StateBase.ts(noop default)src/state/StateContext.ts,src/state/interfaces/IStateContext.ts,src/state/StateService.tsPer-image reorientation hint (flash-free hard cuts):
src/state/interfaces/IStateBase.ts(reorientationsmap, shared across statetransitions)
src/state/state/StateBase.ts(setReorientation/clearReorientations)src/state/state/TraversingState.ts(apply the hint when an image becomescurrent on a motionless transition, before render)
src/state/StateContext.ts,src/state/interfaces/IStateContext.ts,src/state/StateService.ts(plumbing)Wiring (default-on, opt-out + public export + registration):
src/component/ComponentName.tssrc/viewer/options/ComponentOptions.tssrc/viewer/ComponentController.ts(_uTrue(options.reorientation, ...))src/mapillary.ts(register)src/external/component.ts(export component + config)Test plan
yarn test— full suite green: 95 suites, 1357 tests pass (includes newReorientationEngineunit tests: bearing/haversine/basic-x + wrap-delta math,moving detection, low-speed-turn, end-of-sequence + non-spherical
invalidation, cache reuse; and the
ComponentControllertest updated for thenew default component).
yarn lintclean;yarn buildclean (tsc + rollup).travel direction (smoothly, including on cold jumps to an unprefetched image);
mesh-less sequences hard-cut without a flash; near-straight steps hold steady
and re-face only on turns; dragging to look around is preserved across the
sequence and reset between sequences. Validated against production imagery in a
downstream web client running the same engine + steering across ~30 cities.