-
-
Notifications
You must be signed in to change notification settings - Fork 748
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
Facilitate for globe transition expression refactoring #5139
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #5139 +/- ##
==========================================
- Coverage 91.84% 91.82% -0.03%
==========================================
Files 278 281 +3
Lines 38336 38776 +440
Branches 6714 6756 +42
==========================================
+ Hits 35211 35605 +394
- Misses 2996 3043 +47
+ Partials 129 128 -1 ☔ View full report in Codecov by Sentry. |
I think this looks like the right direction, with the globe transform (being a mercator<->verticalPerspective lerp) to contain a mercatorTransform and now also a verticalPerspectiveTransform, and call into those, instead of having too much logic of it's own. |
This comment was marked as outdated.
This comment was marked as outdated.
Surprisingly I think I managed to find what created the issues in the branch after trying to recreate it in another branch... |
The new |
I think you can simply fix it by opening a PR to this branch, it would be better to avoid the need for me to resolve conflicts. |
I think it makes sense to query mercator transfrom to get the fallback matrix. since it is the exact matrix which is used when mercator is active. Globe mostly needs it to do the projection transition.
I think I'll go over all the mercator transform usages.
Sounds good! |
I went over all mercator transform usages in the current globe_transform.ts, everything looks good, I only added a comment about the removed double interpolation. |
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 like where this is going, nice work!
Added some comments but feel free to ignore them (except for the typo ones!)
@kubapelc I'm looking into leveraging the following code to calculate the current globeness: type ProjectionProps = {
type: DataConstantProperty<ProjectionDefinition>;
}
type ProjectionPossiblyEvaluated = {
type: ProjectionDefinitionSpecification;
}
const properties: Properties<ProjectionProps> = new Properties({
'type': new DataConstantProperty(styleSpec.projection.type as StylePropertySpecification)
});
export class ProjectionTransition extends Evented {
properties: PossiblyEvaluated<ProjectionProps, ProjectionPossiblyEvaluated>;
_transitionable: Transitionable<ProjectionProps>;
_transitioning: Transitioning<ProjectionProps>;
constructor(projection?: ProjectionSpecification) {
super();
this._transitionable = new Transitionable(properties);
this.setProjection(projection);
this._transitioning = this._transitionable.untransitioned();
this.recalculate(new EvaluationParameters(0));
}
setProjection(projection?: ProjectionSpecification) {
this._transitionable.setValue('type', projection.type);
}
updateTransitions(parameters: TransitionParameters) {
this._transitioning = this._transitionable.transitioned(parameters, this._transitioning);
}
hasTransition() {
return this._transitioning.hasTransition();
}
recalculate(parameters: EvaluationParameters) {
this.properties = this._transitioning.possiblyEvaluate(parameters);
}
}
//... usage:
new ProjectionTransition({
type: ["interpolate", ["linear"], ["zoom"],
10, "vertical-perspective", 12, "mercator"]
}); This leverages maplibre's expression evaluation capabilities and it looks like it is working as expected, and also removes the code related to animation and time tracking. I do see code related to updating the zoom and center when the globeness is not equal, can you elaborate on what it does? |
See #5139 (comment) We need to somehow smoothly move globe's map center to match mercator, it is not clear how now that the transition is controlled by an arbitrary expression. Maybe we can interpolate the center towards mercator every time that globeness decresases compared to the last update, and do nothing if it increases? This would make zooming in smoothly interpolate the center, and zooming out would not affect it. |
I'll create a PR against this branch with the changes related to the globeness calculations outside the transform class so we can discuss the changes. |
* This refactors the projection class only, without touching other parts of the code. * remove mercator from the code, revert more changes
…d mercator (#5162) * Refactor camera helper * Use the helper in the factory. * Fix build test * Fix according to code review
#5164) * Remove duplicate code * Fix lint, add some methods for original branch * Add projection definition in factory * Add has transition to projection * Fix transition value * Remove isRenderingDirty and use hasTransition when needed * Remove the last part of the animation handling in the transform class * More clean-up * Remove some "TODO"s. * Remove reference to globe projection in globe transform * Rename newFrame with recalculateCache * Remove unneeded ifs * Add support for arbitrary projection definitions * Uses mercator matrix when globe is using mercator transform * Improve handling of fog martix in globe transform --------- Co-authored-by: Isaac Besora Vilardaga <isaac.besora@gmail.com>
This is now ready for review and afterwards merged to main branch. |
* Simplify custom layer ProjectionData code in mercator transform * Fix globe tiles example * Fix globe projection shader * Add custom layer 3D model after globe->mercator transition render test * Fix custom layer 3D models not rendering when globe transitions to mercator * Move camera to center distance to helper # Conflicts: # src/geo/projection/globe_transform.ts # src/geo/projection/mercator_transform.ts # src/geo/transform_helper.ts # src/geo/transform_interface.ts * Synchronize globe+mercator near and far Z to prevent 3D model disappearing during projection transition * Expose getProjectionData and getMatrixForModel for custom layers, don't use internal API in examples * VerticalPerspectiveTransform should have a valid getProjectionDataForCustomLayer implementation * Add changelog entry * Fix missing docs * Fix docs again * Review feedback * Move nearZfarZoverride to transform helper * Update build size * Review feedback * Change near/far Z override API * Custom layers use internal API * Fix globe custom tiles example * Update build size * Fix typo --------- Co-authored-by: HarelM <harel.mazor@gmail.com>
@Pessimistress I was about to completely remove the event of projection change here as the only place after these code change that this event is fired is when setting the projection, which is a programmatic operation, and raising an event for something you called seems weird to me... |
Launch Checklist
vertical-perspective
toglobe
projection #5114args.defaultProjectionData.mainMatrix
value using globe projection with high zoom level #5117This is a draft PR at this point to see what still need to be fixed and for others to see.
CC: @birkskyum @ibesora @kubapelc
The idea behind this refactoring: