-
-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera Roll #4780
Camera Roll #4780
Conversation
…ibre#3783) * Port changes from main globe branch - basics Fix minor issues so that it compiles. * Fix PI redefinitions * Fix stencil shader * Port adaptation of raster layer for globe from main globe branch * Add globe.html example from pheonor's repo Minor changes (remove terrain, set initial zoom 0, change title and description) * Better map projection parameter doc comment, warn when using unknown projection * Mercator projectionData handles negative zoom correctly * Comment clarification * Fix spelling of "granularity" * Add missing docs * Convert ProjectionBase to an interface * Do not leak GL object in globe projection error measurement, add a destroy method to projection * Fix chrome performance warning, refactor error measurement Warning fixed by changing ring buffer size to 1, making ring buffer pointless, so I removed it. * Fix granularity capitalization * Fix capitalization * Fix typo * Fix stencil mask triangle index order (this was causing failing render tests) * Cleanup vertex shader projection interface * Move projection creation function into its own file * Remove getProjectionName * Added comment for deduplicateWrapped * Remove unused vertex-buffer-related code from image source * Add globe raster layer render test * More render tests - test transition to mercator * Remove pointless test, add test descriptions * Render test for rendering poles on globe * SubdivisionGranularitySetting constructor takes an object * Remove "defines" parameter from useProgram * Refactor useProgram and Program constructor * Properly format translatePosMatrix comment * Refactor globe-specific code outside projection classes, remove stencil-specific granularity settings * Refactor granularity settings to be more readable * Minor refactor of ProjectionErrorMeasurement * Refactor draw_raster.ts * Move globe utility functions to utils.ts, use easeCubicInOut instead of smoothStep * Simplify imports in globe.ts * globe.ts refactor * Move ProjectionErrorMeasurement to a separate file * Refactor ProjectionErrorMeasurement Change parseRGBA8float to a private static function, use isWebGL2 function instead of instanceof * Refactor draw_raster.ts * Refactor globe projection error measurement to not use Painter * Painter.clearStencil creates custom ProjectionData instead of calling getProjectionData(null, null) * Remove "deduplicateWrapped" functionality from source_cache.ts * Globe projection no longer requires a map instance * Painter doesn't pass `this` to `updateGPUdependent` * isRenderingDirty is now a function * Rename ProjectionBase to Projection * Replace globeView property with setGlobeViewAllowed * Add mercator and globe projection unit tests * Remove tests that test for exact clipping planes * Update build test with new bundle size * isRenderingDirty is now a function
* Port changes from main globe branch - basics Fix minor issues so that it compiles. * Fix PI redefinitions * Fix stencil shader * Port adaptation of raster layer for globe from main globe branch * Add globe.html example from pheonor's repo Minor changes (remove terrain, set initial zoom 0, change title and description) * Better map projection parameter doc comment, warn when using unknown projection * Mercator projectionData handles negative zoom correctly * Comment clarification * Fix spelling of "granularity" * Add missing docs * Convert ProjectionBase to an interface * Do not leak GL object in globe projection error measurement, add a destroy method to projection * Fix chrome performance warning, refactor error measurement Warning fixed by changing ring buffer size to 1, making ring buffer pointless, so I removed it. * Fix granularity capitalization * Fix capitalization * Fix typo * Fix stencil mask triangle index order (this was causing failing render tests) * Cleanup vertex shader projection interface * Move projection creation function into its own file * Remove getProjectionName * Added comment for deduplicateWrapped * Remove unused vertex-buffer-related code from image source * Add globe raster layer render test * More render tests - test transition to mercator * Remove pointless test, add test descriptions * Render test for rendering poles on globe * SubdivisionGranularitySetting constructor takes an object * Remove "defines" parameter from useProgram * Refactor useProgram and Program constructor * Properly format translatePosMatrix comment * Refactor globe-specific code outside projection classes, remove stencil-specific granularity settings * Refactor granularity settings to be more readable * Minor refactor of ProjectionErrorMeasurement * Refactor draw_raster.ts * Move globe utility functions to utils.ts, use easeCubicInOut instead of smoothStep * Simplify imports in globe.ts * globe.ts refactor * Move ProjectionErrorMeasurement to a separate file * Refactor ProjectionErrorMeasurement Change parseRGBA8float to a private static function, use isWebGL2 function instead of instanceof * Refactor draw_raster.ts * Refactor globe projection error measurement to not use Painter * Painter.clearStencil creates custom ProjectionData instead of calling getProjectionData(null, null) * Remove "deduplicateWrapped" functionality from source_cache.ts * Globe projection no longer requires a map instance * Painter doesn't pass `this` to `updateGPUdependent` * isRenderingDirty is now a function * Rename ProjectionBase to Projection * Replace globeView property with setGlobeViewAllowed * Add mercator and globe projection unit tests * Remove tests that test for exact clipping planes * Update build test with new bundle size * isRenderingDirty is now a function * Fill, fill-extrusion, line layers, subdivision: Import changes from kubapelc/globe-vector branch * Fix unit tests * Subdivision: ensure consistent triangle winding order, fix unit tests * Fix terrain * Fix fill extrusion not working with terrain * Fix typos * Fix line gradient bug * Subdivision: fix line ring handling * Subdivision: fix unit test expecting an invalid line segment * Fix fill-extrusion ring handling * Fill-extrusion refactor and fix failing test * Update terrain fill extrusion test expected image * Render tests for fill, line and fill-extrusion for globe * Move fillArrays function into a separate file * Add vector globe example * Remove changes for line and fill-extrusion layers to make the PR smaller * Add unit tests for fillArrays() * fillArrays unit test has better segment size limits * Update build test build size * Fix html example description * Fix missing docs for granularity settings * Rename globe fill render test tile source layer to "vector_tiles" * Fix classifyRings comment format * Move subdivisionGranularitySettingsNoSubdivision constant to a static readonly field, shorten the name * Use `import type` for SubdivisionGranularitySetting where possible * Fix typo * Revert fill_attributes back to default exports * Improve comment for scanline subdivision * Subdivision: break up scanline subdivision function into more functions * Move SubdivisionGranularitySetting into its own file * Unit tests: use mock of MercatorProjection instead of the full class * Add SegmentVector unit tests * Subdivision: unit tests for poles, ring triangulation, fix bug in ring triangulation * Subdivision: more pole unit tests * Subdivision: fix wireframe generation, add unit test for wireframe * Rename subdivisionGranularitySettings.ts to subdivision_granularity_settings.ts * Move granularity settings registration to subdivision * Update build size * Rename `fillArrays` to `fillLargeMeshArrays` * Move virtual buffers to a test util file * Better warning for segments.ts vertex overflow * Better comment for projection subdivision granularity * Clarify mesh comparison in fill_large_mesh_arrays.test.ts * Move mesh creating functions into a separate file, add tests for mesh comparison and grid creation * Refactor and add better doc comment for `fillLargeMeshArrays` * Refactor fill_large_mesh_arrays by removing duplicated code * Move debug functions to mesh_utils.ts * Unit tests: use StructArrays instead of VirtualVertexBuffer, etc. * Subdivision: refactor * Subdivision: rename subdivideFill to subdividePolygon, remove wireframe function * Subdivision: throw when a vertex is outside int16 range * Subdivision: refactor generatePoleQuad into a proper function * Subdivision: add subdivision benchmark * Subdivision: split scanline subdivision into smaller functions * Remove wireframe generation function * Subdivision: better doc comments for scanline subdivision * Fix 'as any' in segment.ts * Reuse condition in fill_large_arrays * Deduplicate code in fill_large_arrays * Subdivision: remove redundant function in tests * Subdivision: improve scanline subdivision comments * Subdivision: benchmark is not async * Rename SegmentVector's invalidateLast to forceNewSegmentOnTextPrepare * More tests for segment.ts * Fix typo in forceNewSegmentOnNextPrepare * Subdivision: more tests for fillLargeMeshArrays * Subdivision: better comment in fillLargeMeshArrays
* Fix merge * Import line layer changes from kubapelc/globe-vector * Lines: shorten line_bucket.test.ts subdivision settings * Lines: minor refactor * Lines: update build size * Lines: minor refactor
* Import changes for fill-extrusion from main vector globe branch * Fill extrusion: refactor * Fill extrusion: indent shader ifdefs * Fill extrusion: add example * Fill extrusion: update build size * Move globe specific projection methods to projection interface * Fix failing unit test * Use vec3.clone() instead of manually copying vector components
* Import background layer changes from main vector globe branch * Import hillshade layer changes from main vector globe branch * Subdivision: explicit types * Fix single-pixel seams in the oceans * Add render test for background pattern on globe * Refactor drawBackground * Refactor drawHillshade * Update build size * Update globe background-pattern render test with results from CI * Hillshade: refactor prepareHillshade * Add a render test for fill layer seams fix
* Import changes for circle and heatmap layers from the main vector globe branch * Minor refactors * Update build size * Use "/ 8.0" in shader instead of "* 0.125" * Update shader comments * Use a thin type instead of full Transform in projection * Only import types in projection.ts * getPixelScale and getCircleRadiusCorrection only need map center as argument * Only import types where possible in projection classes * Smaller refactors * Fix failing unit test * Add heatmap render test * More explicit types in projection interface * Globe plane equation is a vec4 * Fix wrong args in projection functions
* Import changes from main vector globe branch * Fix import * Remove unused code * Remove unused imports * Update build size test * Remove unused function * Add render test results for Debian * Add another Debian render test variant * Add more render test variants * Hide collision boxes on the backfacing side of the globe * Fix pitch-aligned texts getting hidden when their anchor is beyond horizon * Update build size * Fix merge * Better comment in draw_collision_debug * Update build size The 10 kb size increase seems to come from the main branch * Minor refactor * Use explicit types, even for unused parameters * Refactor screenspace path projection * Refactor imports for projection.ts and collision_index.ts * Fix import in collision_index.ts
* Add example images * Add "-" into example name * Remove basic globe example
* HiSilicon fix: enable face culling whereever possible (cherry picked from commit fe439a5) * Improve circle layer performance by discarding empty pixels (cherry picked from commit 266897d) * HiSilicon fix: software clipping of polygon outlines (cherry picked from commit 98167ba) * HiSilicon fix: software clipping for line layer (cherry picked from commit d521e95) * HiSilicon fix: circle software clipping (cherry picked from commit f2ed744) * HiSilicon fix: enable backface culling for symbols (cherry picked from commit 54e3632) * Update build test * Fix terrain using a mirrored projection matrix * Fix typos * Fix terrain coord textures being flipped vertically * Update build size * Fix rendering of images with face culling, fix image rendering near pole regions * Add render test for images on a globe * Update comment in circle.vertex.glsl
Another thing I just thought about is a dedicated control for this. Otherwise, after adding the roll to the spec, updating the spec package here and addressing the above, I think this can be merged. |
@HarelM Is the NavigationControl update required to merge this? I don't intend to ever use the NavigationControl. |
I believe so, also an example page with this new functionality, preferably with a control the users can interact with. |
…f roll using Ctrl + right click.
OK, Here's a demo of the updated NavigationControl. https://nathanmolson.github.io/camera_roll
@HarelM if this is acceptable I will add unit tests and an example page. Or I can extend an existing example (maybe |
return new DragHandler<DragRollResult, MouseEvent>({ | ||
clickTolerance, | ||
move: (lastPoint: Point, point: Point) => | ||
({rollDelta: (point.x - lastPoint.x) * rollDegreesPerPixelMoved}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to what I tested, I think this needs to be in the opposite direction - i.e. when moving the mouse right I expect the right part to be "lowered".
Not sure if it's exactly here or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think the behavior should change. As currently implemented, at pitch = 0, roll and bearing are the same, and roll control behaves the same as bearing control. Your proposed change would cause identical mouse movements to move bearing and roll in opposite directions, which seems unexpected and confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean about mouse movement for bearing.
If you are looking at the map from the top then dragging above the center of the map behaves "opposite", as if the gesture is expecting to be done below the center of the map to feel intuitive.
This is not the case for mobile as you have two fingers which defines the rotation better.
I believe both roll and bearing mouse gestures needs to be changed to be "better".
Something like taking into consideration the point where the gesture started and calculating the angle from the map center or view center for the rotation.
Here's a movie I made, I was not aware that this is the case, it doesn't make any sense...
Screen.Recording.2024-10-17.at.1.24.36.mov
I don't know if this is out of scope for this PR, but I wouldn't like to pile up on the "bad" behavior.
Since we are still in 5.x pre-release, this can be a breaking change that can be introduced at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's out of scope for this PR.
I think the demo looks good! |
Please also see if you can update the style-spec package that was just released and remove the |
@@ -711,7 +724,8 @@ export class Map extends Camera { | |||
|
|||
this.on('style.load', () => { | |||
if (this.transform.unmodified) { | |||
this.jumpTo(this.style.stylesheet as any); | |||
const coercedOptions = pick(this.style.stylesheet, ['center', 'zoom', 'bearing', 'pitch', 'roll']) as CameraOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make this a bit more strict somehow?
Maybe by creating an object of type CameraOptions
?
Something like:
const coercedOptions: CameraOptions = {
center: this.style.stylesheet.center,
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I tried at first. I got a ton of unit test failures and I don't understand how they are related, so I copied a working example from camera.ts
.
Here's an example of what happens using your approach (there are other failed test suites as well):
const coercedOptions: CameraOptions = {
center: new LngLat(this.style.stylesheet.center[0], this.style.stylesheet.center[1]),
zoom: this.style.stylesheet.zoom,
bearing: this.style.stylesheet.bearing,
pitch: this.style.stylesheet.pitch,
roll: this.style.stylesheet.roll
};
=>
npx jest src/ui/map_tests/map_layer.test.ts --reporters=default
FAIL unit src/ui/map_tests/map_layer.test.ts (75.728 s)
✕ #moveLayer (5003 ms)
✕ #getLayer (5001 ms)
✕ #removeLayer restores Map#loaded() to true (5003 ms)
#getLayersOrder
✕ returns ids of layers in the correct order (5003 ms)
#setLayoutProperty
✕ sets property (5001 ms)
✓ throw before loaded (8 ms)
✕ fires an error if layer not found (5002 ms)
✕ fires a data event (5002 ms)
✕ sets visibility on background layer (5002 ms)
✕ sets visibility on raster layer (5004 ms)
✕ sets visibility on video layer (5004 ms)
✕ sets visibility on image layer (5004 ms)
#getLayoutProperty
✕ fires an error if layer not found (5003 ms)
#setPaintProperty
✕ sets property (5002 ms)
✕ #3373 paint property should be synchronized with an update (5001 ms)
✓ throw before loaded (5 ms)
✕ fires an error if layer not found (5002 ms)
● #moveLayer
thrown: "Exceeded timeout of 5000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."
17 | });
18 |
> 19 | test('#moveLayer', async () => {
| ^
20 | const map = createMap({
21 | style: extend(createStyle(), {
22 | sources: {
at Object.<anonymous> (src/ui/map_tests/map_layer.test.ts:19:1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HarelM this works:
let coercedOptions: CameraOptions = {}
if (this.style.stylesheet.center != undefined) {
coercedOptions.center = new LngLat(this.style.stylesheet.center[0], this.style.stylesheet.center[1]);
}
if (this.style.stylesheet.zoom != undefined) {
coercedOptions.zoom = this.style.stylesheet.zoom;
}
if (this.style.stylesheet.bearing != undefined) {
coercedOptions.bearing = this.style.stylesheet.bearing;
}
if (this.style.stylesheet.pitch != undefined) {
coercedOptions.pitch = this.style.stylesheet.pitch;
}
if (this.style.stylesheet.roll != undefined) {
coercedOptions.roll = this.style.stylesheet.roll;
}
Do you like this better than the current pick()
? Or do you have any idea how to turn this into something prettier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked into it.
I think pick is doing these if in a shorter why and is typesafe enough.
I would like the CameraOptions
to be defined before the pick
but I see the Stylespec's center
is defined as a number[]
and the CameraOptions
is expecting center
to be [number, number]
.
I think this might be solvable by adjusting the style-spec package exported types.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, this is not a showstopper for this PR, this is nit picking in the nice-to-have realm.
If you feel like improving this bit feel free to open a PR etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably figure out what to do about center-point elevation before changing the style-spec package exported types. maplibre/maplibre-style-spec#851
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These doesn't have to be tied together, we can improve the style spec typings to supports current implementation and change that when needed in the future.
Last two comments hopefully before this can get merged. |
Reopening accidentally closed PR: #4771
This is the first part of #4717: adding camera roll.
In this PR, roll is defined as rotation about the camera boresight. Rotation order is bearing, pitch, roll.
easeTo()
andflyTo()
are implemented usinglinear interpolation of Euler anglesspherical linear interpolation.You can play with this feature here, using the controls in the top right corner: https://nathanmolson.github.io/camera_roll
There is some weirdness near +/- 90 degrees roll, but I'd like to get #4750 merged before attempting to address it. Near 90 degrees, it appears that tiles are being selected with a much lower zoom level than they should be.
You can also play with camera roll on the globe projection here: https://nathanmolson.github.io/globe_roll/