Skip to content
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

Globe custom layer fixes #5150

Merged

Conversation

kubapelc
Copy link
Collaborator

@kubapelc kubapelc commented Dec 3, 2024

Fixes #5117

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 88.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 91.81%. Comparing base (ea4f31a) to head (48dee24).
Report is 1 commits behind head on projection-expression.

Files with missing lines Patch % Lines
src/geo/transform_helper.ts 73.91% 6 Missing ⚠️
src/geo/projection/globe_transform.ts 91.66% 2 Missing ⚠️
src/geo/projection/mercator_transform.ts 94.11% 2 Missing ⚠️
...c/geo/projection/vertical_perspective_transform.ts 89.47% 2 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           projection-expression    #5150      +/-   ##
=========================================================
- Coverage                  91.82%   91.81%   -0.01%     
=========================================================
  Files                        281      281              
  Lines                      38712    38751      +39     
  Branches                    6745     6757      +12     
=========================================================
+ Hits                       35548    35581      +33     
- Misses                      3036     3042       +6     
  Partials                     128      128              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Dec 3, 2024

I've added some comments. Thanks!

@HarelM
Copy link
Collaborator

HarelM commented Dec 8, 2024

I think the following PR:

Will cause this PR to not exactly match the changes I've made.
I can easily incorporate some of the fixes here, but I'm still having an issue with the API around setting far and near Z, I would prefer to make the near/farZ either auto calculated or allow setting them from the outside - i.e. only add a flag to disable their calculations, what do you think?

@kubapelc
Copy link
Collaborator Author

I can help with merge conflicts with #5164 if there are any. The changes don't seem to overlap too much.

…bapelc/globe-custom-layer-fix2

# Conflicts:
#	CHANGELOG.md
#	src/geo/projection/globe_transform.ts
#	src/geo/projection/mercator_transform.ts
#	src/geo/projection/vertical_perspective_transform.ts
#	src/geo/transform_interface.ts
@HarelM
Copy link
Collaborator

HarelM commented Dec 11, 2024

I've added a few comments.
Also there's a need to resolve conflicts on this branch.
Let me know when those can be fixed and I'll merge this to the upstream branch and merge that branch into main.

// seems to solve z-fighting issues in deck.gl while not clipping buildings too close to the camera.
this._nearZ = this._helper._height / 50;

if (this._helper.autoCalculateNearFarZ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression other variables are used later on, since this is not the case I would consider moving this to an internal method, it will be a lot more readable.

}

public get cameraPosition(): vec3 { return this._cameraPosition; }
public get projectionMatrix(): mat4 { return this._projectionMatrix; }
public get modelViewProjectionMatrix(): mat4 { return this._viewProjMatrix; }
public get inverseProjectionMatrix(): mat4 { return this._invProjMatrix; }
public get nearZ(): number { return this._nearZ; }
public get farZ(): number { return this._farZ; }
public get nearZ(): number { return this._helper.nearZ; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these methods to be with the other helper methods in the file

@HarelM
Copy link
Collaborator

HarelM commented Dec 11, 2024

I'll merge this and fix what's left in the other branch, THANKS!!!

@HarelM HarelM merged commit 49802fb into maplibre:projection-expression Dec 11, 2024
13 of 15 checks passed
HarelM added a commit that referenced this pull request Dec 12, 2024
* Initial commit to move the logic of transition out to a new file

* Remove one line method

* Fix build test

* Fix projection data bad refactoring

* Fix render and size tests

* Fix failing unit test

* Uncomment unit tests

* Fix typo, remove unneeded details provider initialization. Added current transfrom getter

* Fix typo

* Add back error correction for latitude.

* Refactors the `Projection` classed only (#5163)

* This refactors the projection class only, without touching other parts of the code.

* remove mercator from the code, revert more changes

* Refactor camera helper to split the logic for vertical-perspective and mercator (#5162)

* Refactor camera helper

* Use the helper in the factory.

* Fix build test

* Fix according to code review

* Use `Transitionalable` infrastructure for transfrom globeness changes. (#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>

* Globe custom layer fixes (#5150)

* 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>

* Final removal of TODOs and some minor clean up

* Update CHANGELOG.md

---------

Co-authored-by: Isaac Besora Vilardaga <isaac.besora@gmail.com>
Co-authored-by: Jakub Pelc <57600346+kubapelc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants