@@ -28,6 +28,7 @@ import {XYZTerra} from './XYZTerra';
2828import { TerrainTileLoaderOptions } from './TerrainWorkerLoader' ;
2929import { StyleZoomRange } from '../../styles/LayerStyle' ;
3030import { GeoJSONFeature } from '../../features/GeoJSON' ;
31+ import webMercator from '../../projection/webMercator' ;
3132
3233declare const self : Worker ;
3334
@@ -54,7 +55,7 @@ export const createTerrainTile = (
5455 if ( normals ) {
5556 feature . properties . normals = normals ;
5657 }
57- return prepareFeature ( feature , null , null , quantizeOptions ) ;
58+ return prepareFeature ( feature , z , null , null , quantizeOptions ) ;
5859} ;
5960const createTerrainFeature = (
6061 x : number , y : number , z : number ,
@@ -72,7 +73,8 @@ const createTerrainFeature = (
7273 properties : {
7374 isTerrain : true ,
7475 source : {
75- type : sourceFormat
76+ type : sourceFormat ,
77+ tile : [ x , y , z ]
7678 } ,
7779 indices,
7880 vertices
@@ -137,6 +139,7 @@ function createHeightmapTerrainFeature(x: number, y: number, z: number, mesh: RT
137139}
138140
139141function prepareFeature ( feature ,
142+ zoom : number ,
140143 heightMap ?: Float32Array ,
141144 skirtToMainVertexMap ?: Map < number , number > ,
142145 quantizeOptions ?: QuantizeOptions
@@ -179,7 +182,7 @@ function prepareFeature(feature,
179182 const maxLat = feature . geometry . coordinates [ 0 ] [ 4 ] [ 1 ] ;
180183 const centerLat = minLat + ( maxLat - minLat ) / 2 ;
181184 const worldSize = Math . pow ( 2 , feature . id . length ) * 256 ;
182- const meterPerPixel = earthCircumference ( centerLat ) / worldSize ;
185+ const meterPerPixel = webMercator . earthCircumference ( centerLat ) / worldSize ;
183186
184187 properties . normals ||= computeMeshNormals ( {
185188 vertex : properties . vertices ,
@@ -277,7 +280,7 @@ class TerrainWorker extends HTTPWorker {
277280 }
278281
279282 if ( feature ) {
280- prepareFeature ( feature , heightMap , skirtToMainVertexMap ) ;
283+ prepareFeature ( feature , z , heightMap , skirtToMainVertexMap ) ;
281284
282285 // properties.uv = (function createUVs(
283286 // vertices: Float64Array | Float32Array | Uint16Array | Int16Array | number[],
0 commit comments