Skip to content

Commit d1a5fbc

Browse files
committed
refactor(PlanarLayer): homogeneisation with GlobeLayer in args
1 parent c609e23 commit d1a5fbc

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

examples/view_multi_25d.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
obj.updateMatrixWorld(true);
137137

138138
const tileLayer = new itowns.PlanarLayer('planar' + wms.name + index,
139-
extent, obj, { disableSkirt: true });
139+
obj, { disableSkirt: true, extent });
140140

141141
view.addLayer(tileLayer);
142142

src/Core/Prefab/Planar/PlanarLayer.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class PlanarLayer extends TiledGeometryLayer {
2121
* @param {string} id - The id of the layer, that should be unique. It is
2222
* not mandatory, but an error will be emitted if this layer is added a
2323
* {@link View} that already has a layer going by that id.
24-
* @param {Extent} extent - The extent to define the layer within.
2524
* @param {THREE.Object3d} [object3d=THREE.Group] - The object3d used to
2625
* contain the geometry of the TiledGeometryLayer. It is usually a
2726
* `THREE.Group`, but it can be anything inheriting from a `THREE.Object3d`.
@@ -30,14 +29,23 @@ class PlanarLayer extends TiledGeometryLayer {
3029
* contains three elements `name, protocol, extent`, these elements will be
3130
* available using `layer.name` or something else depending on the property
3231
* name.
32+
* @param {Extent} config.extent - The extent to define the layer within.
3333
* @param {number} [config.maxSubdivisionLevel=5] - Maximum subdivision
3434
* level for this tiled layer.
3535
* @param {number} [config.maxDeltaElevationLevel=4] - Maximum delta between
3636
* two elevations tile.
3737
*
3838
* @throws {Error} `object3d` must be a valid `THREE.Object3d`.
3939
*/
40-
constructor(id, extent, object3d, config = {}) {
40+
constructor(id, object3d, config = {}) {
41+
if (arguments.length > 3 || object3d?.isExtent) {
42+
console.warn("Deprecated: change in arguments, 'extent' should be set in config");
43+
// eslint-disable-next-line prefer-rest-params
44+
const [, ext,, conf = {}] = arguments;
45+
conf.extent = ext;
46+
config = conf;
47+
}
48+
const extent = config.extent;
4149
const tms = CRS.formatToTms(extent.crs);
4250

4351
const scheme = schemeTiles.get(tms);

src/Core/Prefab/PlanarView.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import View from 'Core/View';
44
import CameraUtils from 'Utils/CameraUtils';
55

66
import PlanarControls from 'Controls/PlanarControls';
7-
import PlanarLayer from './Planar/PlanarLayer';
7+
import PlanarLayer from 'Core/Prefab/Planar/PlanarLayer';
8+
import { ellipsoidSizes } from 'Core/Math/Ellipsoid';
89

910
class PlanarView extends View {
1011
/**
@@ -29,7 +30,6 @@ class PlanarView extends View {
2930
*/
3031
constructor(viewerDiv, options = {}) {
3132
THREE.Object3D.DEFAULT_UP.set(0, 0, 1);
32-
3333
if (arguments.length > 2 || options.isExtent) {
3434
console.warn("Deprecated: change in arguments, 'extent' should be set in options");
3535
// eslint-disable-next-line prefer-rest-params
@@ -43,7 +43,7 @@ class PlanarView extends View {
4343
super(extent.crs, viewerDiv, options);
4444
this.isPlanarView = true;
4545

46-
const tileLayer = new PlanarLayer('planar', extent, options.object3d, options);
46+
const tileLayer = new PlanarLayer('planar', options.object3d, options);
4747
this.mainLoop.gfxEngine.label2dRenderer.infoTileLayer = tileLayer.info;
4848

4949
this.addLayer(tileLayer);
@@ -52,8 +52,10 @@ class PlanarView extends View {
5252
// Configure camera
5353
const dim = extent.planarDimensions();
5454
const max = Math.max(dim.x, dim.y);
55-
this.camera3D.near = 0.1;
56-
this.camera3D.far = this.camera3D.isOrthographicCamera ? 2000 : 2 * max;
55+
// this.camera3D.near = 0.1;
56+
// this.camera3D.far = this.camera3D.isOrthographicCamera ? 2000 : 2 * max;
57+
this.camera3D.near = Math.max(15.0, 0.000002352 * ellipsoidSizes.x);
58+
this.camera3D.far = ellipsoidSizes.x * 10;
5759
this.camera3D.updateProjectionMatrix();
5860

5961
const placement = options.placement || {};

test/unit/dataSourceProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('Provide in Sources', function () {
6767
stubFetcherTexture = sinon.stub(Fetcher, 'texture')
6868
.callsFake(() => Promise.resolve(new THREE.Texture()));
6969

70-
planarlayer = new PlanarLayer('globe', globalExtent, new THREE.Group());
70+
planarlayer = new PlanarLayer('globe', new THREE.Group(), { extent: globalExtent });
7171
colorlayer = new ColorLayer('color', { crs: 'EPSG:3857', source: false });
7272
elevationlayer = new ElevationLayer('elevation', { crs: 'EPSG:3857', source: false });
7373

test/unit/tilemesh.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('TileMesh', function () {
4343
const globalExtent = globalExtentTMS.get('EPSG:3857');
4444
// const view = new PlanarView(viewerDiv, globalExtent, { maxSubdivisionLevel: 20 });
4545

46-
const planarlayer = new PlanarLayer('globe', globalExtent, new THREE.Group());
46+
const planarlayer = new PlanarLayer('globe', new THREE.Group(), { extent: globalExtent });
4747

4848
// Mock scheduler
4949
const context = {

0 commit comments

Comments
 (0)