Skip to content

Commit

Permalink
Allow adjusting camera clipbounds.
Browse files Browse the repository at this point in the history
This was motivated by wanting to set the near and far clip values.  This
can be done by `map.camera().clipbounds = {near: <near value>, far: <far
value>}`.

This simplifies some of the camera code.  Before, we were generating a
display matrix but separately calculating the transform in a series of
steps, and similarly we were doing the inverse via a set of steps
instead of a matrix multiplication.  This uses the `display` and `world`
matrices explicitly in the transforms.

The `css` transform property was ambiguous about the transform origin.
We now explicitly expect a transform-origin of `0 0`, as we use that
elsewhere in the project.  This adjusts several tests.

Some of the tests have be rewritten for clarity.

Some of the camera helper functions have been eliminated as they were
simple wrappers around matrix functions.

There are now distinct clipbounds for perspective and parallel
projections.

The css transform format was rewritten to be more compact and not lose
precision in some instances.

Note that the webgl use of the perspective camera projection will need
additional refactoring to handle any clipbounds.
  • Loading branch information
manthey committed Aug 16, 2018
1 parent d4f29fa commit 3075e87
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 367 deletions.
2 changes: 1 addition & 1 deletion examples/tiles/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ block append mainContent

.form-group(title="The camera can use a parallel or perspective projection. The difference is subtly unless the data has non-zero z-values.")
label(for="camera-projection") Camera Projection
select#camera-projection.cameraparam(param-name="projection", placeholder="parallel")
select#camera-projection.cameraparam(param-name="projection", placeholder="parallel", reload="true")
option(value="parallel") Parallel
option(value="perspective") Perspective

Expand Down
2 changes: 1 addition & 1 deletion examples/tiles/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ $(function () {
}
break;
}
if (ctl.is('.layerparam') && ctl.attr('reload') === 'true') {
if (ctl.is('.layerparam,.cameraparam') && ctl.attr('reload') === 'true') {
map.deleteLayer(osmLayer);
osmLayer = map.createLayer('osm', layerParams);
tileDebug.osmLayer = osmLayer;
Expand Down
Loading

0 comments on commit 3075e87

Please sign in to comment.