Skip to content

Allow scaling of view matrix when constructing WebMercatorViewport #5929

@felixpalmer

Description

@felixpalmer

Target Use case

Match the Google Maps viewport (view & projection matrices)

Proposed feature

WebMercatorViewport is currently constructed with a altitude parameter which is used to construct both the view and the projection matrix:

const {fov, aspect, focalDistance, near, far} = getProjectionParameters({
width,
height,
pitch,
altitude,
nearZMultiplier,
farZMultiplier
});
// The uncentered matrix allows us two move the center addition to the
// shader (cheap) which gives a coordinate system that has its center in
// the layer's center position. This makes rotations and other modelMatrx
// transforms much more useful.
let viewMatrixUncentered = getViewMatrix({
height,
pitch,
bearing,
scale,
altitude
});

In the projection matrix it is used to calculate the field of view, while in the view matrix it is used to translate the camera in the z-direction.

While this is sufficient for matching the Mapbox style matrices (on which the deck.gl viewports are modeled), it makes it impossible to construct the matrices as used by Google Maps. This is because Google Maps positions the view matrix at an altitude of 1 (which would correspond to a field of view of 53 degrees) but then constructs a projection matrix which has a field of view of 25 degrees.

It would be good to allow configuration of these two quantities independently, as there is no inherent reason why they must be linked. One way would be to allow scaling the view matrix by a constant (scaleMultiplier), but other ways are possible (for example, explicitly passing the field of view)

To Do List

  • Coding
  • Doc update
  • What’s new update
  • Test

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions