@gisatcz/deckgl-geolib 1.10.1-dev.1 → 1.10.2-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,79 +1,204 @@
1
- import { CompositeLayer } from '@deck.gl/core';
2
- import { TileLayer, TerrainLayer } from '@deck.gl/geo-layers';
3
- import chroma from 'chroma-js';
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+
21
+ import {
22
+ Color,
23
+ CompositeLayer,
24
+ CompositeLayerProps,
25
+ DefaultProps,
26
+ Layer,
27
+ LayersList,
28
+ log,
29
+ Material,
30
+ TextureSource,
31
+ UpdateParameters,
32
+ COORDINATE_SYSTEM,
33
+ } from '@deck.gl/core';
34
+ import { SimpleMeshLayer } from '@deck.gl/mesh-layers';
35
+ import type { MeshAttributes } from '@loaders.gl/schema';
36
+ // import { TerrainWorkerLoader } from '@loaders.gl/terrain';
37
+ import {
38
+ TileLayer, TileLayerProps, GeoBoundingBox, _TileLoadProps as TileLoadProps,
39
+ _Tile2DHeader as Tile2DHeader, _getURLFromTemplate as getURLFromTemplate, NonGeoBoundingBox,
40
+ } from '@deck.gl/geo-layers';
41
+
42
+ import { GeoImageOptions } from '../geoimage/geoimage.ts';
4
43
 
5
- // FIXME
6
- // eslint-disable-next-line
7
- import { getTileUrl, isCogUrl, isTileServiceUrl } from '../utilities/tileurls.ts';
8
44
  import CogTiles from '../cogtiles/cogtiles.ts';
9
45
 
10
- import { GeoImageOptions, DefaultGeoImageOptions } from '../geoimage/geoimage.ts';
46
+ export type Bounds = [minX: number, minY: number, maxX: number, maxY: number];
11
47
 
12
- class CogTerrainLayer extends CompositeLayer<any> {
13
- static layerName = 'CogTerrainLayer';
48
+ export type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;
14
49
 
15
- terrainCogTiles: CogTiles;
50
+ export type ZRange = [minZ: number, maxZ: number];
16
51
 
17
- bitmapCogTiles: CogTiles;
52
+ export type URLTemplate = string | string[] | null;
18
53
 
19
- tileSize: number;
54
+ export const urlType = {
55
+ type: 'object' as const,
56
+ value: null as URLTemplate,
57
+ validate: (value, propType) => (propType.optional && value === null)
58
+ || typeof value === 'string'
59
+ || (Array.isArray(value) && value.every((url) => typeof url === 'string')),
60
+ equal: (value1, value2) => {
61
+ if (value1 === value2) {
62
+ return true;
63
+ }
64
+ if (!Array.isArray(value1) || !Array.isArray(value2)) {
65
+ return false;
66
+ }
67
+ const len = value1.length;
68
+ if (len !== value2.length) {
69
+ return false;
70
+ }
71
+ for (let i = 0; i < len; i++) {
72
+ if (value1[i] !== value2[i]) {
73
+ return false;
74
+ }
75
+ }
76
+ return true;
77
+ },
78
+ };
79
+
80
+ const DUMMY_DATA = [1];
81
+
82
+ const defaultProps: DefaultProps<TerrainLayerProps> = {
83
+ ...TileLayer.defaultProps,
84
+ // Image url that encodes height data
85
+ elevationData: urlType,
86
+ // Image url to use as texture
87
+ texture: { ...urlType, optional: true },
88
+ // Martini error tolerance in meters, smaller number -> more detailed mesh
89
+ meshMaxError: { type: 'number', value: 4.0 },
90
+ // Bounding box of the terrain image, [minX, minY, maxX, maxY] in world coordinates
91
+ bounds: {
92
+ type: 'array', value: null, optional: true, compare: true,
93
+ },
94
+ // Color to use if texture is unavailable
95
+ color: { type: 'color', value: [255, 255, 255] },
96
+ // Object to decode height data, from (r, g, b) to height in meters
97
+ elevationDecoder: {
98
+ type: 'object',
99
+ value: {
100
+ rScaler: 1,
101
+ gScaler: 0,
102
+ bScaler: 0,
103
+ offset: 0,
104
+ },
105
+ },
106
+ // Supply url to local terrain worker bundle. Only required if running offline and cannot access CDN.
107
+ workerUrl: '',
108
+ // Same as SimpleMeshLayer wireframe
109
+ wireframe: false,
110
+ material: true,
111
+
112
+ // loaders: [TerrainLoader],
113
+ };
114
+
115
+ // Turns array of templates into a single string to work around shallow change
116
+ function urlTemplateToUpdateTrigger(template: URLTemplate): string {
117
+ if (Array.isArray(template)) {
118
+ return template.join(';');
119
+ }
120
+ return template || '';
121
+ }
20
122
 
21
- minZoom: number;
123
+ type ElevationDecoder = {rScaler: number; gScaler: number; bScaler: number; offset: number};
124
+ type TerrainLoadProps = {
125
+ bounds: Bounds;
126
+ elevationData: string | null;
127
+ elevationDecoder: ElevationDecoder;
128
+ meshMaxError: number;
129
+ signal?: AbortSignal;
130
+ };
22
131
 
23
- maxZoom: number;
132
+ type MeshAndTexture = [MeshAttributes | null, TextureSource | null];
24
133
 
25
- bitmapUrl: string;
134
+ /** All properties supported by TerrainLayer */
135
+ export type TerrainLayerProps = _TerrainLayerProps &
136
+ TileLayerProps<MeshAndTexture> &
137
+ CompositeLayerProps;
26
138
 
27
- urlType: 'none' | 'tile' | 'cog' = 'none';
139
+ /** Props added by the TerrainLayer */
140
+ type _TerrainLayerProps = {
141
+ /** Image url that encodes height data. * */
142
+ elevationData: URLTemplate;
28
143
 
29
- id = '';
144
+ /** Image url to use as texture. * */
145
+ texture?: URLTemplate;
30
146
 
31
- terrainUrl: string;
147
+ /** Martini error tolerance in meters, smaller number -> more detailed mesh. * */
148
+ meshMaxError?: number;
32
149
 
33
- terrainOpacity: number;
150
+ /** Bounding box of the terrain image, [minX, minY, maxX, maxY] in world coordinates. * */
151
+ bounds?: Bounds | null;
34
152
 
35
- terrainColor: Array<number>;
153
+ /** Color to use if texture is unavailable. * */
154
+ color?: Color;
36
155
 
37
- terrainSkirtHeight: number;
156
+ /** Object to decode height data, from (r, g, b) to height in meters. * */
157
+ elevationDecoder?: ElevationDecoder;
38
158
 
39
- static displayName: string;
159
+ /** Whether to render the mesh in wireframe mode. * */
160
+ wireframe?: boolean;
40
161
 
41
- constructor(
42
- id:string,
43
- terrainUrl: string,
44
- terrainOptions: GeoImageOptions,
45
- bitmapUrl?: string,
46
- bitmapOptions?: GeoImageOptions,
47
- ) {
48
- super({});
49
- this.id = id;
50
- const mergedTerrainOptions = { ...DefaultGeoImageOptions, ...terrainOptions };
51
- this.terrainOpacity = mergedTerrainOptions.alpha / 100;
52
- this.terrainColor = chroma(mergedTerrainOptions.terrainColor.slice(0, 3)).rgb();
53
- this.terrainSkirtHeight = mergedTerrainOptions.terrainSkirtHeight;
54
-
55
- if (bitmapUrl) {
56
- if (isTileServiceUrl(bitmapUrl)) {
57
- this.bitmapUrl = bitmapUrl;
58
- this.urlType = 'tile';
59
- this.terrainColor = [0, 0, 0, 0];
60
- } else if (isCogUrl(bitmapUrl)) {
61
- this.bitmapCogTiles = new CogTiles(bitmapOptions!);
62
- this.bitmapCogTiles.initializeCog(bitmapUrl);
63
- this.urlType = 'cog';
64
- this.terrainColor = [0, 0, 0, 0];
65
- } else {
66
- console.warn('URL needs to point to a valid cog file, or needs to be in the {x}{y}{z} format.');
67
- }
68
- }
162
+ /** Material props for lighting effect. * */
163
+ material?: Material;
164
+
165
+ /**
166
+ * @deprecated Use `loadOptions.terrain.workerUrl` instead
167
+ */
168
+ workerUrl?: string;
169
+ };
170
+
171
+ /** Render mesh surfaces from height map images. */
172
+ export default class TerrainLayer<ExtraPropsT extends {} = {}> extends CompositeLayer<
173
+ ExtraPropsT & Required<_TerrainLayerProps & Required<TileLayerProps<MeshAndTexture>>>
174
+ > {
175
+ static defaultProps = defaultProps;
176
+
177
+ static layerName = 'TerrainLayer';
178
+
179
+ terrainCogTiles: CogTiles;
180
+
181
+ terrainUrl: string;
182
+
183
+ minZoom: number;
184
+
185
+ maxZoom: number;
186
+
187
+ state!: {
188
+ isTiled?: boolean;
189
+ terrain?: MeshAttributes;
190
+ zRange?: ZRange | null;
191
+ };
192
+
193
+ constructor(props: TerrainLayerProps & ExtraPropsT, terrainOptions: GeoImageOptions) {
194
+ super(props);
195
+ console.log('xxx_terrainOptions', terrainOptions);
69
196
 
70
197
  this.terrainCogTiles = new CogTiles(terrainOptions);
71
- // this.init(terrainUrl);
72
- this.terrainUrl = terrainUrl;
73
198
  }
74
199
 
75
- async initializeState() {
76
- super.initializeState();
200
+ async initializeState(context: any) {
201
+ super.initializeState(context);
77
202
  this.setState({
78
203
  initialized: false,
79
204
  });
@@ -81,118 +206,299 @@ class CogTerrainLayer extends CompositeLayer<any> {
81
206
  await this.init(this.terrainUrl);
82
207
  }
83
208
 
84
- shouldUpdateState() {
85
- if (this.internalState?.subLayers.length === 0) {
86
- return true;
87
- }
88
- return false;
89
- }
90
-
91
209
  async init(terrainUrl: string) {
92
- // console.log("LAYER INITIALIZE STATE");
210
+ console.log('xxx_LAYER INITIALIZE STATE');
93
211
 
94
- const cog = await this.terrainCogTiles.initializeCog(terrainUrl);
95
- this.tileSize = this.terrainCogTiles.getTileSize(cog);
212
+ const cog = await this.terrainCogTiles.initializeCog(this.props.elevationData);
213
+ console.log('xxx_LAYER INITIALIZE STATE', cog);
214
+ // this.tileSize = this.terrainCogTiles.getTileSize(cog);
96
215
 
97
216
  const zoomRange = this.terrainCogTiles.getZoomRange(cog);
98
- [this.props.minZoom, this.props.maxZoom] = zoomRange;
217
+ console.log('xxx_LAYER INITIALIZE STATE', zoomRange);
218
+ [this.minZoom, this.maxZoom] = zoomRange;
99
219
 
100
220
  this.setState({ initialized: true });
101
221
  }
102
222
 
103
- renderLayers() {
104
- if (this.terrainCogTiles.cog) {
105
- // console.log("LAYER RENDER");
106
-
107
- let bitmapTile: string;
108
- // let zoomOffset = 0
109
-
110
- switch (this.urlType) {
111
- case 'tile':
112
- // zoomOffset = 0
113
- break;
114
- case 'cog':
115
- // zoomOffset = -2
116
- break;
117
- default:
118
- }
119
- // console.log("is fully loaded: " + loaded);
120
- const layer = new TileLayer({
121
- id: `${this.id}-${String(performance.now())}`,
122
- zoomOffset: -1,
123
- getTileData: (tileData: any) => this.terrainCogTiles.getTile(
124
- tileData.index.x,
125
- tileData.index.y,
126
- tileData.index.z,
127
- ),
128
- minZoom: this.minZoom,
129
- maxZoom: this.maxZoom,
130
- tileSize: this.tileSize,
131
- maxRequests: 6,
132
- refinementStrategy: 'best-available',
133
- extent: this.terrainCogTiles.getBoundsAsLatLon(this.terrainCogTiles.cog),
134
-
135
- renderSubLayers: (props: any) => {
136
- if (props.data && (props.tile.index.x !== undefined)) {
137
- switch (this.urlType) {
138
- case 'tile':
139
- bitmapTile = getTileUrl(
140
- this.bitmapUrl,
141
- props.tile.index.x,
142
- props.tile.index.y,
143
- props.tile.index.z,
144
- );
145
- break;
146
- case 'cog':
147
- bitmapTile = this.bitmapCogTiles.getTile(
148
- props.tile.index.x,
149
- props.tile.index.y,
150
- props.tile.index.z,
151
- );
152
- break;
153
- default:
154
- bitmapTile = null;
155
- }
156
-
157
- return new TerrainLayer({
158
- id: (`terrain-${props.tile.index.x}-${props.tile.index.y}-${props.tile.index.z}`),
159
- pickable: true,
160
- elevationDecoder: {
161
- rScaler: 6553.6,
162
- gScaler: 25.6,
163
- bScaler: 0.1,
164
- offset: -10000,
165
- },
166
- elevationData: props.data,
167
- texture: bitmapTile,
168
- opacity: this.terrainOpacity,
169
- bounds: [props.tile.bbox.west,
170
- props.tile.bbox.south,
171
- props.tile.bbox.east,
172
- props.tile.bbox.north,
173
- ],
174
- color: this.terrainColor,
175
- operation: 'terrain+draw',
176
- minZoom: this.minZoom,
177
- maxZoom: this.maxZoom,
178
- loadOptions: {
179
- terrain: {
180
- skirtHeight: this.terrainSkirtHeight,
181
- tesselator: 'martini',
182
- },
183
- },
184
- meshMaxError: 12,
185
- });
186
- }
187
- return null;
188
- },
189
- });
190
- return [layer];
191
- }
192
- return [];
223
+ updateState({ props, oldProps }: UpdateParameters<this>): void {
224
+ const elevationDataChanged = props.elevationData !== oldProps.elevationData;
225
+ if (elevationDataChanged) {
226
+ const { elevationData } = props;
227
+ const isTiled = elevationData
228
+ && (Array.isArray(elevationData)
229
+ || (elevationData.includes('{x}') && elevationData.includes('{y}'))) || this.props.isTiled;
230
+ this.setState({ isTiled });
231
+ }
232
+
233
+ // Reloading for single terrain mesh
234
+ const shouldReload = elevationDataChanged
235
+ || props.meshMaxError !== oldProps.meshMaxError
236
+ || props.elevationDecoder !== oldProps.elevationDecoder
237
+ || props.bounds !== oldProps.bounds;
238
+
239
+ if (!this.state.isTiled && shouldReload) {
240
+ // When state.isTiled, elevationData cannot be an array
241
+ const terrain = this.loadTerrain(props as TerrainLoadProps);
242
+ this.setState({ terrain });
243
+ }
244
+
245
+ // TODO - remove in v9
246
+ // @ts-ignore
247
+ if (props.workerUrl) {
248
+ log.removed('workerUrl', 'loadOptions.terrain.workerUrl')();
249
+ }
193
250
  }
194
- }
195
251
 
196
- CogTerrainLayer.displayName = 'CogTerrainLayer';
252
+ loadTerrain({
253
+ elevationData,
254
+ bounds,
255
+ elevationDecoder,
256
+ meshMaxError,
257
+ signal,
258
+ }: TerrainLoadProps): Promise<MeshAttributes> | null {
259
+ if (!elevationData) {
260
+ return null;
261
+ }
262
+ let loadOptions = this.getLoadOptions();
263
+ loadOptions = {
264
+ ...loadOptions,
265
+ _workerType: 'test',
266
+ terrain: {
267
+ skirtHeight: this.state.isTiled ? meshMaxError * 2 : 0,
268
+ ...loadOptions?.terrain,
269
+ bounds,
270
+ meshMaxError,
271
+ elevationDecoder,
272
+ },
273
+ };
274
+ const { fetch } = this.props;
275
+ console.log('xxx_loaddata');
276
+
277
+ return fetch(elevationData, {
278
+ propName: 'elevationData', layer: this, loadOptions, signal,
279
+ });
280
+ }
281
+ // OLD version
282
+ // getTiledTerrainData(tile: TileLoadProps): Promise<MeshAndTexture> {
283
+ // const {
284
+ // elevationData, fetch, texture, elevationDecoder, meshMaxError,
285
+ // } = this.props;
286
+ // const { viewport } = this.context;
287
+ // const dataUrl = getURLFromTemplate(elevationData, tile);
288
+ // const textureUrl = texture && getURLFromTemplate(texture, tile);
289
+
290
+ // const { signal } = tile;
291
+ // let bottomLeft = [0, 0] as [number, number];
292
+ // let topRight = [0, 0] as [number, number];
293
+ // if (viewport.isGeospatial) {
294
+ // const bbox = tile.bbox as GeoBoundingBox;
295
+ // bottomLeft = viewport.projectFlat([bbox.west, bbox.south]);
296
+ // topRight = viewport.projectFlat([bbox.east, bbox.north]);
297
+ // } else {
298
+ // const bbox = tile.bbox as Exclude<TileBoundingBox, GeoBoundingBox>;
299
+ // bottomLeft = [bbox.left, bbox.bottom];
300
+ // topRight = [bbox.right, bbox.top];
301
+ // }
302
+ // const bounds: Bounds = [bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]];
303
+
304
+ // const terrain = this.loadTerrain({
305
+ // elevationData: dataUrl,
306
+ // bounds,
307
+ // elevationDecoder,
308
+ // meshMaxError,
309
+ // signal,
310
+ // });
311
+ // const surface = textureUrl
312
+ // ? // If surface image fails to load, the tile should still be displayed
313
+ // fetch(textureUrl, {
314
+ // propName: 'texture', layer: this, loaders: [], signal,
315
+ // }).catch((_) => null)
316
+ // : Promise.resolve(null);
317
+
318
+ // return Promise.all([terrain, surface]);
319
+ // }
320
+ async getTiledTerrainData(tile: TileLoadProps): Promise<MeshAndTexture> {
321
+ const {
322
+ elevationData, fetch, texture, elevationDecoder, meshMaxError,
323
+ } = this.props;
324
+ const { viewport } = this.context;
325
+ // const dataUrl = getURLFromTemplate(elevationData, tile);
326
+ // const textureUrl = texture && getURLFromTemplate(texture, tile);
327
+
328
+ const { signal } = tile;
329
+ let bottomLeft = [0, 0] as [number, number];
330
+ let topRight = [0, 0] as [number, number];
331
+ if (viewport.isGeospatial) {
332
+ const bbox = tile.bbox as GeoBoundingBox;
333
+ console.log('xxx_coords', bbox.west, bbox.south, bbox.east, bbox.north);
334
+
335
+ bottomLeft = viewport.projectFlat([bbox.west, bbox.south]);
336
+ topRight = viewport.projectFlat([bbox.east, bbox.north]);
337
+ } else {
338
+ const bbox = tile.bbox as Exclude<TileBoundingBox, GeoBoundingBox>;
339
+ bottomLeft = [bbox.left, bbox.bottom];
340
+ topRight = [bbox.right, bbox.top];
341
+ }
342
+ const bounds: Bounds = [bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]];
343
+ // const bounds: Bounds = [0, 100, 100, 100];
344
+ // const bounds: Bounds = [tile.bbox.west, tile.bbox.south, tile.bbox.east, tile.bbox.north];
345
+
346
+ const terrain = await this.terrainCogTiles.getTile(
347
+ tile.index.x,
348
+ tile.index.y,
349
+ tile.index.z,
350
+ bounds,
351
+ );
352
+ console.log(
353
+ 'xxx_TILE',
354
+ terrain,
355
+ bounds,
356
+ );
357
+
358
+ // const terrain = this.loadTerrain({
359
+ // elevationData: dataUrl,
360
+ // bounds,
361
+ // elevationDecoder,
362
+ // meshMaxError,
363
+ // signal,
364
+ // });
365
+
366
+ return Promise.all([terrain]);
367
+ }
368
+
369
+ renderSubLayers(
370
+ props: TileLayerProps<MeshAndTexture> & {
371
+ id: string;
372
+ data: MeshAndTexture;
373
+ tile: Tile2DHeader<MeshAndTexture>;
374
+ },
375
+ ) {
376
+ const SubLayerClass = this.getSubLayerClass('mesh', SimpleMeshLayer);
377
+
378
+ const { color, wireframe, material } = this.props;
379
+ const { data } = props;
380
+
381
+ if (!data) {
382
+ return null;
383
+ }
384
+
385
+ // const [mesh, texture] = data;
386
+ const [mesh] = data;
387
+
388
+ return new SubLayerClass({ ...props, tileSize: 256 }, {
389
+ data: DUMMY_DATA,
390
+ mesh,
391
+ // texture,
392
+ _instanced: false,
393
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
394
+ getPosition: (d) => [0, 0, 0],
395
+ getColor: color,
396
+ wireframe,
397
+ material,
398
+ });
399
+ }
197
400
 
198
- export default CogTerrainLayer;
401
+ // Update zRange of viewport
402
+ onViewportLoad(tiles?: Tile2DHeader<MeshAndTexture>[]): void {
403
+ if (!tiles) {
404
+ return;
405
+ }
406
+
407
+ const { zRange } = this.state;
408
+ const ranges = tiles
409
+ .map((tile) => tile.content)
410
+ .filter((x) => x && x[0])
411
+ .map((arr) => {
412
+ // @ts-ignore
413
+ const bounds = arr[0]?.header?.boundingBox;
414
+ return bounds?.map((bound) => bound[2]);
415
+ });
416
+ if (ranges.length === 0) {
417
+ return;
418
+ }
419
+ const minZ = Math.min(...ranges.map((x) => x[0]));
420
+ const maxZ = Math.max(...ranges.map((x) => x[1]));
421
+ console.log('xxx_ranges', ranges);
422
+ if (!zRange || minZ < zRange[0] || maxZ > zRange[1]) {
423
+ this.setState({ zRange: [Number.isFinite(minZ) ? minZ : 0, Number.isFinite(maxZ) ? maxZ : 0] });
424
+ }
425
+ }
426
+
427
+ renderLayers(): Layer | null | LayersList {
428
+ const {
429
+ color,
430
+ material,
431
+ elevationData,
432
+ texture,
433
+ wireframe,
434
+ meshMaxError,
435
+ elevationDecoder,
436
+ tileSize,
437
+ maxZoom,
438
+ minZoom,
439
+ extent,
440
+ maxRequests,
441
+ onTileLoad,
442
+ onTileUnload,
443
+ onTileError,
444
+ maxCacheSize,
445
+ maxCacheByteSize,
446
+ refinementStrategy,
447
+ } = this.props;
448
+ console.log('xxx_renderLayers', this.state.initialized);
449
+
450
+ if (this.state.isTiled && this.state.initialized) {
451
+ return new TileLayer<MeshAndTexture>(
452
+ this.getSubLayerProps({
453
+ id: 'tiles',
454
+ }),
455
+ {
456
+ getTileData: this.getTiledTerrainData.bind(this),
457
+ renderSubLayers: this.renderSubLayers.bind(this),
458
+ updateTriggers: {
459
+ getTileData: {
460
+ elevationData: urlTemplateToUpdateTrigger(elevationData),
461
+ // texture: urlTemplateToUpdateTrigger(texture),
462
+ meshMaxError,
463
+ elevationDecoder,
464
+ },
465
+ },
466
+ onViewportLoad: this.onViewportLoad.bind(this),
467
+ zRange: this.state.zRange || null,
468
+ tileSize,
469
+ maxZoom,
470
+ minZoom,
471
+ extent,
472
+ maxRequests,
473
+ onTileLoad,
474
+ onTileUnload,
475
+ onTileError,
476
+ maxCacheSize,
477
+ maxCacheByteSize,
478
+ refinementStrategy,
479
+ },
480
+ );
481
+ }
482
+
483
+ // if (!elevationData) {
484
+ // return null;
485
+ // }
486
+
487
+ // const SubLayerClass = this.getSubLayerClass('mesh', SimpleMeshLayer);
488
+ // return new SubLayerClass(
489
+ // this.getSubLayerProps({
490
+ // id: 'mesh',
491
+ // }),
492
+ // {
493
+ // data: DUMMY_DATA,
494
+ // mesh: this.state.terrain,
495
+ // texture,
496
+ // _instanced: false,
497
+ // getPosition: (d) => [0, 0, 0],
498
+ // getColor: color,
499
+ // material,
500
+ // wireframe,
501
+ // },
502
+ // );
503
+ }
504
+ }