Invalid position of the viewport visualization in navigator
See original GitHub issueI was trying to implement viewport tracking, and noticed my tracked positions are off. Further inspection led me to realize the OSD’s implementation does not display the viewport correctly.
I shouldn’t have modified the navigator in any way that would cause this, but I am not 100% sure.
What I am doing:
const size = 250;
this.record = document.createElement("canvas");
const homeBounds = VIEWER.viewport.getHomeBounds();
homeBounds.width += 2*homeBounds.x; //consider setting 1 since it is computed to be 1 anyway
homeBounds.height += 2*homeBounds.y;
homeBounds.x = 0;
homeBounds.y = 0;
const w = size * homeBounds.width, h = size * homeBounds.height;
this.record.width = w;
this.record.height = h;
this.recordCtx = this.record.getContext('2d');
this.recordCtx.globalCompositeOperation = "lighten";
....
VIEWER.addHandler("update-viewport", e => {
const viewport = e.eventSource.viewport;
....
const bounds = viewport.getBoundsNoRotate(true);
_this.recordCtx.fillRect(size*bounds.x, size*bounds.y, size*bounds.width, size*bounds.height);
});
(tissue blurred) If you look closer you can see that while the whole bottom part of the tissue is visible, the viewport position indicator is off. Note that the display is cut and the OSD renders behind the menu too, the reason the rectangle is so wide.
I tried loading just a single TiledImage with the same result.
What OSD is doing (for reference):
bounds = viewport.getBoundsNoRotate(true);
topleft = this.viewport.pixelFromPointNoRotate(bounds.getTopLeft(), false);
bottomright = this.viewport.pixelFromPointNoRotate(bounds.getBottomRight(), false)
.minus( this.totalBorderWidths );
//update style for navigator-box
var style = this.displayRegion.style;
style.display = this.world.getItemCount() ? 'block' : 'none';
style.top = Math.round( topleft.y ) + 'px';
style.left = Math.round( topleft.x ) + 'px';
var width = Math.abs( topleft.x - bottomright.x );
var height = Math.abs( topleft.y - bottomright.y );
// make sure width and height are non-negative so IE doesn't throw
style.width = Math.round( Math.max( width, 0 ) ) + 'px';
style.height = Math.round( Math.max( height, 0 ) ) + 'px';
Any ideas? Thanks.
Issue Analytics
- State:
- Created 9 months ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Position center of viewport · Issue #164 · davidfig/pixi ... - GitHub
I draw a network visualization; I set the zoom to fit it in the screen with .setZoom(.5); I don't understand how to center...
Read more >Troubleshoot Viewport 2.0 | Maya 2022
The viewport is not updating the contents of the scene or incorrect materials or instances are displaying. For example, textures, geometry, or ...
Read more >Positioning errors - Pozyx Knowledge Center
Positioning result is considered invalid. The system was able to calculate a position but this calculated position was considered invalid.
Read more >Why did my test fail? - Testim overview
This error occurs when the target element exists on the page but is not visible. Common Causes: The target element is currently not...
Read more >UGameViewportClient - Unreal Engine Documentation
Name Description
FString ConsoleCommand. ( const FString& Command ) Process Console Co...
FSceneViewpo... CreateGameViewport. ( TSharedPtr< SViewport > In... Create the game vie...
void DrawTransition. (...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aha! In your example, I disabled
box-sizing: border-box
in the CSS for the navigator panel (can be found with selector#panel-navigator-displayregion.displayregion
(among others) ) and the bottom right positioning seems much better.I feel like it might be worth considering how to make the indicator rectangle robust to external CSS like this. I can’t imagine why it would be beneficial for a user to intentionally apply a different
box-sizing
model that makes it inaccurate, and it is highly likely to happen by accident like it did to you.@iangilman Thoughts? Perhaps inline CSS defined on the element itself could be used to override any such changes made by an external stylesheet…