Skip to content

Commit 4a99ecd

Browse files
authored
Xyz imagesource cleanup (#1449)
* Add a configurable "projection" field * Add support for list of levels * Update types, pass projection in
1 parent fceaea9 commit 4a99ecd

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

src/three/plugins/images/EPSGTilesPlugin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export class XYZTilesPlugin {
44

55
constructor( options: {
66
center?: boolean,
7-
levels?: number,
7+
levels?: number|Array<object>,
88
tileDimension?: number,
99
shape?: 'ellipsoid' | 'planar',
1010
useRecommendedSettings?: boolean,

src/three/plugins/images/EPSGTilesPlugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ export class XYZTilesPlugin extends EllipsoidProjectionTilesPlugin {
1515
const {
1616
levels,
1717
tileDimension,
18+
projection,
1819
url,
1920
...rest
2021
} = options;
2122

2223
super( rest );
2324

2425
this.name = 'XYZ_TILES_PLUGIN';
25-
this.imageSource = new XYZImageSource( { url, levels, tileDimension } );
26+
this.imageSource = new XYZImageSource( { url, levels, tileDimension, projection } );
2627

2728
}
2829

src/three/plugins/images/ImageOverlayPlugin.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class XYZTilesOverlay extends ImageOverlay {
3333
constructor( options: {
3434
levels: number,
3535
dimension: number,
36+
projection: string;
3637
url: string,
3738

3839
color: number | Color,

src/three/plugins/images/sources/XYZImageSource.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class XYZImageSource extends TiledImageSource {
88
const {
99
levels = 20,
1010
tileDimension = 256,
11+
projection = 'EPSG:4326',
1112
url = null,
1213
...rest
1314
} = options;
@@ -16,6 +17,7 @@ export class XYZImageSource extends TiledImageSource {
1617

1718
this.tileDimension = tileDimension;
1819
this.levels = levels;
20+
this.projection = projection;
1921
this.url = url;
2022

2123
}
@@ -32,15 +34,34 @@ export class XYZImageSource extends TiledImageSource {
3234
init() {
3335

3436
// transform the url
35-
const { tiling, tileDimension, levels, url } = this;
36-
37+
const { tiling, tileDimension, levels, url, projection } = this;
3738
tiling.flipY = ! /{\s*reverseY|-\s*y\s*}/g.test( url );
38-
tiling.setProjection( new ProjectionScheme( 'EPSG:3857' ) );
39+
tiling.setProjection( new ProjectionScheme( projection ) );
3940
tiling.setContentBounds( ...tiling.projection.getBounds() );
40-
tiling.generateLevels( levels, tiling.projection.tileCountX, tiling.projection.tileCountY, {
41-
tilePixelWidth: tileDimension,
42-
tilePixelHeight: tileDimension,
43-
} );
41+
if ( Array.isArray( levels ) ) {
42+
43+
levels.forEach( ( info, level ) => {
44+
45+
if ( info !== null ) {
46+
47+
tiling.setLevel( level, {
48+
tilePixelWidth: tileDimension,
49+
tilePixelHeight: tileDimension,
50+
...info
51+
} );
52+
53+
}
54+
55+
} );
56+
57+
} else {
58+
59+
tiling.generateLevels( levels, tiling.projection.tileCountX, tiling.projection.tileCountY, {
60+
tilePixelWidth: tileDimension,
61+
tilePixelHeight: tileDimension,
62+
} );
63+
64+
}
4465

4566
this.url = url;
4667

src/three/renderer/controls/PivotPointMesh.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class PivotMaterial extends ShaderMaterial {
5252

5353
vertexShader: /* glsl */`
5454
55-
uniform float pixelRatio;
5655
uniform float size;
5756
uniform float thickness;
5857
uniform vec2 resolution;

0 commit comments

Comments
 (0)