@openglobus/og 0.13.4 → 0.13.7

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.
Files changed (55) hide show
  1. package/css/og.css +66 -25
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/og/Events.js +188 -188
  9. package/src/og/Extent.js +1 -9
  10. package/src/og/Globe.js +1 -0
  11. package/src/og/control/DebugInfo.js +15 -4
  12. package/src/og/control/EarthCoordinates.js +151 -160
  13. package/src/og/control/KeyboardNavigation.js +48 -2
  14. package/src/og/control/TouchNavigation.js +13 -13
  15. package/src/og/control/ZoomControl.js +1 -1
  16. package/src/og/ellipsoid/Ellipsoid.js +1 -1
  17. package/src/og/entity/Billboard.js +165 -165
  18. package/src/og/entity/BillboardHandler.js +1 -1
  19. package/src/og/entity/Geometry.js +319 -319
  20. package/src/og/entity/Label.js +348 -346
  21. package/src/og/entity/LabelHandler.js +44 -37
  22. package/src/og/input/input.js +7 -1
  23. package/src/og/layer/CanvasTiles.js +8 -8
  24. package/src/og/layer/KML.js +181 -12
  25. package/src/og/layer/Layer.js +4 -2
  26. package/src/og/layer/XYZ.js +4 -2
  27. package/src/og/quadTree/Node.js +1 -0
  28. package/src/og/renderer/RendererEvents.js +17 -3
  29. package/src/og/scene/Planet.js +89 -30
  30. package/src/og/segment/Segment.js +1 -0
  31. package/src/og/shaders/label.js +56 -13
  32. package/src/og/terrain/EmptyTerrain.js +164 -146
  33. package/src/og/terrain/Geoid.js +246 -241
  34. package/src/og/terrain/GlobusTerrain.js +23 -24
  35. package/src/og/terrain/MapboxTerrain.js +292 -294
  36. package/src/og/utils/FontAtlas.js +25 -15
  37. package/src/og/utils/Loader.js +53 -12
  38. package/src/og/utils/PlainSegmentWorker.js +38 -26
  39. package/src/og/utils/TextureAtlas.js +291 -280
  40. package/src/og/utils/units.js +78 -0
  41. package/types/control/EarthCoordinates.d.ts +27 -30
  42. package/types/control/KeyboardNavigation.d.ts +3 -0
  43. package/types/entity/Label.d.ts +1 -0
  44. package/types/entity/LabelHandler.d.ts +1 -1
  45. package/types/input/input.d.ts +6 -0
  46. package/types/layer/KML.d.ts +26 -1
  47. package/types/renderer/RendererEvents.d.ts +2 -0
  48. package/types/scene/Planet.d.ts +10 -1
  49. package/types/terrain/EmptyTerrain.d.ts +4 -1
  50. package/types/terrain/Geoid.d.ts +1 -10
  51. package/types/terrain/GlobusTerrain.d.ts +0 -2
  52. package/types/terrain/MapboxTerrain.d.ts +1 -1
  53. package/types/utils/Loader.d.ts +3 -0
  54. package/types/utils/TextureAtlas.d.ts +2 -0
  55. package/types/utils/units.d.ts +20 -0
@@ -1,294 +1,292 @@
1
- import { getTileExtent } from "../mercator.js";
2
- import { Layer } from "../layer/Layer.js";
3
- import { GlobusTerrain } from "./GlobusTerrain.js";
4
- import { isPowerOfTwo } from "../math.js";
5
-
6
- const KEY =
7
- "pk.eyJ1IjoiZm94bXVsZGVyODMiLCJhIjoiY2pqYmR3dG5oM2Z1bzNrczJqYm5pODhuNSJ9.Y4DRmEPhb-XSlCR9CAXACQ";
8
-
9
- class MapboxTerrain extends GlobusTerrain {
10
- constructor(name, options) {
11
- super(name, options);
12
-
13
- options = options || {};
14
-
15
- this.equalizeVertices =
16
- options.equalizeVertices != undefined ? options.equalizeVertices : true;
17
-
18
- this.equalizeNormals = options.equalizeNormals || false;
19
-
20
- this.minZoom = options.minZoom != undefined ? options.minZoom : 2;
21
-
22
- this.maxZoom = options.maxZoom != undefined ? options.maxZoom : 17;
23
-
24
- this.gridSizeByZoom = options.gridSizeByZoom || [
25
- 64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
26
- ];
27
-
28
- this.url =
29
- options.url != undefined
30
- ? options.url
31
- : `//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${
32
- options.key || KEY
33
- }`;
34
-
35
- this.noDataValues = options.noDataValues || [-65537, -10000];
36
-
37
- this.plainGridSize = options.plainGridSize || 128;
38
-
39
- this._dataType = "imageBitmap";
40
-
41
- this._imageSize = options.imageSize || 256;
42
-
43
- this._ctx = this._createTemporalCanvas(this._imageSize);
44
- }
45
-
46
- isBlur(segment) {
47
- if (segment.tileZoom >= 13) {
48
- return true;
49
- }
50
- return false;
51
- }
52
-
53
- _createTemporalCanvas(size) {
54
- let canvas = document.createElement("canvas");
55
- canvas.width = size;
56
- canvas.height = size;
57
- return canvas.getContext("2d");
58
- }
59
-
60
- _createHeights(data, segment) {
61
- const SIZE = data.width;
62
-
63
- this._ctx.clearRect(0, 0, SIZE, SIZE);
64
- this._ctx.drawImage(data, 0, 0);
65
- let rgbaData = this._ctx.getImageData(0, 0, SIZE, SIZE).data;
66
-
67
- //
68
- //Non power of two images
69
- //
70
- if (!isPowerOfTwo(this._imageSize) && SIZE === this._imageSize) {
71
- let outCurrenElevations = new Float32Array(SIZE * SIZE);
72
- extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations);
73
- return outCurrenElevations;
74
- }
75
-
76
- // TODO:
77
- //if (this._imageSize === this.plainGridSize) {
78
- // let elevationsSize = (this.plainGridSize + 1) * (this.plainGridSize + 1);
79
- // let d = SIZE / this.plainGridSize;
80
-
81
- // let outCurrenElevations = new Float32Array(elevationsSize);
82
-
83
- // for (let i = 0, len = outCurrenElevations.length; i < len; i++) {
84
- // let i4 = i * 4;
85
- // outCurrenElevations[i] = -10000 + 0.1 * (rgbaData[i4] * 256 * 256 + rgbaData[i4 + 1] * 256 + rgbaData[i4 + 2]);
86
- // }
87
-
88
- // return outCurrenElevations;
89
- //}
90
-
91
- //
92
- // Power of two images
93
- //
94
- let elevationsSize = (this.plainGridSize + 1) * (this.plainGridSize + 1);
95
- let d = SIZE / this.plainGridSize;
96
-
97
- let outCurrenElevations = new Float32Array(elevationsSize);
98
- let outChildrenElevations = new Array(d);
99
-
100
- for (let i = 0; i < d; i++) {
101
- outChildrenElevations[i] = [];
102
- for (let j = 0; j < d; j++) {
103
- outChildrenElevations[i][j] = new Float32Array(elevationsSize);
104
- }
105
- }
106
-
107
- extractElevationTilesMapbox(
108
- rgbaData,
109
- this.noDataValues,
110
- outCurrenElevations,
111
- outChildrenElevations
112
- );
113
-
114
- this._elevationCache[segment.tileIndex] = {
115
- heights: outCurrenElevations,
116
- extent: segment.getExtent()
117
- };
118
-
119
- for (let i = 0; i < d; i++) {
120
- for (let j = 0; j < d; j++) {
121
- let x = segment.tileX * 2 + j,
122
- y = segment.tileY * 2 + i,
123
- z = segment.tileZoom + 1;
124
- let tileIndex = Layer.getTileIndex(x, y, z);
125
- this._elevationCache[tileIndex] = {
126
- heights: outChildrenElevations[i][j],
127
- extent: getTileExtent(x, y, z)
128
- };
129
- }
130
- }
131
-
132
- return outCurrenElevations;
133
- }
134
- }
135
-
136
- function extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations) {
137
- for (let i = 0, len = outCurrenElevations.length; i < len; i++) {
138
- let i4 = i * 4;
139
- outCurrenElevations[i] =
140
- -10000 + 0.1 * (rgbaData[i4] * 256 * 256 + rgbaData[i4 + 1] * 256 + rgbaData[i4 + 2]);
141
- }
142
- }
143
-
144
- function extractElevationTilesMapbox(
145
- rgbaData,
146
- noDataValues,
147
- outCurrenElevations,
148
- outChildrenElevations
149
- ) {
150
- let destSize = Math.sqrt(outCurrenElevations.length) - 1;
151
- let destSizeOne = destSize + 1;
152
- let sourceSize = Math.sqrt(rgbaData.length / 4);
153
- let dt = sourceSize / destSize;
154
-
155
- let rightHeight = 0,
156
- bottomHeight = 0,
157
- sourceSize4 = 0;
158
-
159
- for (
160
- let k = 0, currIndex = 0, sourceDataLength = rgbaData.length / 4;
161
- k < sourceDataLength;
162
- k++
163
- ) {
164
- let k4 = k * 4;
165
-
166
- let height =
167
- -10000 + 0.1 * (rgbaData[k4] * 256 * 256 + rgbaData[k4 + 1] * 256 + rgbaData[k4 + 2]);
168
-
169
- let isNoDataCurrent = MapboxTerrain.checkNoDataValue(noDataValues, height),
170
- isNoDataRight = false,
171
- isNoDataBottom = false;
172
-
173
- let i = Math.floor(k / sourceSize),
174
- j = k % sourceSize;
175
-
176
- let tileX = Math.floor(j / destSize),
177
- tileY = Math.floor(i / destSize);
178
-
179
- let destArr = outChildrenElevations[tileY][tileX];
180
-
181
- let ii = i % destSize,
182
- jj = j % destSize;
183
-
184
- let destIndex = (ii + tileY) * destSizeOne + jj + tileX;
185
-
186
- destArr[destIndex] = height;
187
-
188
- if ((i + tileY) % dt === 0 && (j + tileX) % dt === 0) {
189
- outCurrenElevations[currIndex++] = height;
190
- }
191
-
192
- if ((j + 1) % destSize === 0 && j !== sourceSize - 1) {
193
- //current tile
194
- rightHeight =
195
- -10000 +
196
- 0.1 * (rgbaData[k4 + 4] * 256 * 256 + rgbaData[k4 + 5] * 256 + rgbaData[k4 + 6]);
197
-
198
- isNoDataRight = MapboxTerrain.checkNoDataValue(noDataValues, rightHeight);
199
-
200
- let middleHeight = height;
201
-
202
- if (!(isNoDataCurrent || isNoDataRight)) {
203
- middleHeight = (height + rightHeight) * 0.5;
204
- }
205
-
206
- destIndex = (ii + tileY) * destSizeOne + jj + 1;
207
- destArr[destIndex] = middleHeight;
208
-
209
- if ((i + tileY) % dt === 0) {
210
- outCurrenElevations[currIndex++] = middleHeight;
211
- }
212
-
213
- //next right tile
214
- let rightindex = (ii + tileY) * destSizeOne + ((jj + 1) % destSize);
215
- outChildrenElevations[tileY][tileX + 1][rightindex] = middleHeight;
216
- }
217
-
218
- if ((i + 1) % destSize === 0 && i !== sourceSize - 1) {
219
- //current tile
220
- sourceSize4 = sourceSize * 4;
221
-
222
- bottomHeight =
223
- -10000 +
224
- 0.1 *
225
- (rgbaData[k4 + sourceSize4] * 256 * 256 +
226
- rgbaData[k4 + sourceSize4 + 1] * 256 +
227
- rgbaData[k4 + sourceSize4 + 2]);
228
-
229
- isNoDataBottom = MapboxTerrain.checkNoDataValue(noDataValues, bottomHeight);
230
-
231
- let middleHeight = (height + bottomHeight) * 0.5;
232
-
233
- if (!(isNoDataCurrent || isNoDataBottom)) {
234
- middleHeight = (height + bottomHeight) * 0.5;
235
- }
236
-
237
- destIndex = (ii + 1) * destSizeOne + jj + tileX;
238
- destArr[destIndex] = middleHeight;
239
-
240
- if ((j + tileX) % dt === 0) {
241
- outCurrenElevations[currIndex++] = middleHeight;
242
- }
243
-
244
- //next bottom tile
245
- let bottomindex = ((ii + 1) % destSize) * destSizeOne + jj + tileX;
246
- outChildrenElevations[tileY + 1][tileX][bottomindex] = middleHeight;
247
- }
248
-
249
- if (
250
- (j + 1) % destSize === 0 &&
251
- j !== sourceSize - 1 &&
252
- (i + 1) % destSize === 0 &&
253
- i !== sourceSize - 1
254
- ) {
255
- //current tile
256
- let rightBottomHeight =
257
- -10000 +
258
- 0.1 *
259
- (rgbaData[k4 + sourceSize4 + 4] * 256 * 256 +
260
- rgbaData[k4 + sourceSize4 + 5] * 256 +
261
- rgbaData[k4 + sourceSize4 + 6]);
262
-
263
- let isNoDataRightBottom = MapboxTerrain.checkNoDataValue(
264
- noDataValues,
265
- rightBottomHeight
266
- );
267
-
268
- let middleHeight = height;
269
-
270
- if (!(isNoDataCurrent || isNoDataRight || isNoDataBottom || isNoDataRightBottom)) {
271
- middleHeight = (height + rightHeight + bottomHeight + rightBottomHeight) * 0.25;
272
- }
273
-
274
- destIndex = (ii + 1) * destSizeOne + (jj + 1);
275
- destArr[destIndex] = middleHeight;
276
-
277
- outCurrenElevations[currIndex++] = middleHeight;
278
-
279
- //next right tile
280
- let rightindex = (ii + 1) * destSizeOne;
281
- outChildrenElevations[tileY][tileX + 1][rightindex] = middleHeight;
282
-
283
- //next bottom tile
284
- let bottomindex = destSize;
285
- outChildrenElevations[tileY + 1][tileX][bottomindex] = middleHeight;
286
-
287
- //next right bottom tile
288
- let rightBottomindex = 0;
289
- outChildrenElevations[tileY + 1][tileX + 1][rightBottomindex] = middleHeight;
290
- }
291
- }
292
- }
293
-
294
- export { MapboxTerrain };
1
+ import { getTileExtent } from "../mercator.js";
2
+ import { Layer } from "../layer/Layer.js";
3
+ import { GlobusTerrain } from "./GlobusTerrain.js";
4
+ import { isPowerOfTwo } from "../math.js";
5
+
6
+ const KEY =
7
+ "pk.eyJ1IjoiZm94bXVsZGVyODMiLCJhIjoiY2pqYmR3dG5oM2Z1bzNrczJqYm5pODhuNSJ9.Y4DRmEPhb-XSlCR9CAXACQ";
8
+
9
+ class MapboxTerrain extends GlobusTerrain {
10
+ constructor(name, options = {}) {
11
+ super(name, options);
12
+
13
+ this.equalizeVertices =
14
+ options.equalizeVertices != undefined ? options.equalizeVertices : true;
15
+
16
+ this.equalizeNormals = options.equalizeNormals || false;
17
+
18
+ this.minZoom = options.minZoom != undefined ? options.minZoom : 2;
19
+
20
+ this.maxZoom = options.maxZoom != undefined ? options.maxZoom : 17;
21
+
22
+ this.gridSizeByZoom = options.gridSizeByZoom || [
23
+ 64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
24
+ ];
25
+
26
+ this.url =
27
+ options.url != undefined
28
+ ? options.url
29
+ : `//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${
30
+ options.key || KEY
31
+ }`;
32
+
33
+ this.noDataValues = options.noDataValues || [-65537, -10000];
34
+
35
+ this.plainGridSize = options.plainGridSize || 128;
36
+
37
+ this._dataType = "imageBitmap";
38
+
39
+ this._imageSize = options.imageSize || 256;
40
+
41
+ this._ctx = this._createTemporalCanvas(this._imageSize);
42
+ }
43
+
44
+ isBlur(segment) {
45
+ if (segment.tileZoom >= 13) {
46
+ return true;
47
+ }
48
+ return false;
49
+ }
50
+
51
+ _createTemporalCanvas(size) {
52
+ let canvas = document.createElement("canvas");
53
+ canvas.width = size;
54
+ canvas.height = size;
55
+ return canvas.getContext("2d");
56
+ }
57
+
58
+ _createHeights(data, tileIndex, tileX, tileY, tileZoom, extent) {
59
+ const SIZE = data.width;
60
+
61
+ this._ctx.clearRect(0, 0, SIZE, SIZE);
62
+ this._ctx.drawImage(data, 0, 0);
63
+ let rgbaData = this._ctx.getImageData(0, 0, SIZE, SIZE).data;
64
+
65
+ //
66
+ //Non power of two images
67
+ //
68
+ if (!isPowerOfTwo(this._imageSize) && SIZE === this._imageSize) {
69
+ let outCurrenElevations = new Float32Array(SIZE * SIZE);
70
+ extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations);
71
+ return outCurrenElevations;
72
+ }
73
+
74
+ // TODO:
75
+ //if (this._imageSize === this.plainGridSize) {
76
+ // let elevationsSize = (this.plainGridSize + 1) * (this.plainGridSize + 1);
77
+ // let d = SIZE / this.plainGridSize;
78
+
79
+ // let outCurrenElevations = new Float32Array(elevationsSize);
80
+
81
+ // for (let i = 0, len = outCurrenElevations.length; i < len; i++) {
82
+ // let i4 = i * 4;
83
+ // outCurrenElevations[i] = -10000 + 0.1 * (rgbaData[i4] * 256 * 256 + rgbaData[i4 + 1] * 256 + rgbaData[i4 + 2]);
84
+ // }
85
+
86
+ // return outCurrenElevations;
87
+ //}
88
+
89
+ //
90
+ // Power of two images
91
+ //
92
+ let elevationsSize = (this.plainGridSize + 1) * (this.plainGridSize + 1);
93
+ let d = SIZE / this.plainGridSize;
94
+
95
+ let outCurrenElevations = new Float32Array(elevationsSize);
96
+ let outChildrenElevations = new Array(d);
97
+
98
+ for (let i = 0; i < d; i++) {
99
+ outChildrenElevations[i] = [];
100
+ for (let j = 0; j < d; j++) {
101
+ outChildrenElevations[i][j] = new Float32Array(elevationsSize);
102
+ }
103
+ }
104
+
105
+ extractElevationTilesMapbox(
106
+ rgbaData,
107
+ this.noDataValues,
108
+ outCurrenElevations,
109
+ outChildrenElevations
110
+ );
111
+
112
+ this._elevationCache[tileIndex] = {
113
+ heights: outCurrenElevations,
114
+ extent: extent//segment.getExtent()
115
+ };
116
+
117
+ for (let i = 0; i < d; i++) {
118
+ for (let j = 0; j < d; j++) {
119
+ let x = tileX * 2 + j,
120
+ y = tileY * 2 + i,
121
+ z = tileZoom + 1;
122
+ let tileIndex = Layer.getTileIndex(x, y, z);
123
+ this._elevationCache[tileIndex] = {
124
+ heights: outChildrenElevations[i][j],
125
+ extent: getTileExtent(x, y, z)
126
+ };
127
+ }
128
+ }
129
+
130
+ return outCurrenElevations;
131
+ }
132
+ }
133
+
134
+ function extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations) {
135
+ for (let i = 0, len = outCurrenElevations.length; i < len; i++) {
136
+ let i4 = i * 4;
137
+ outCurrenElevations[i] =
138
+ -10000 + 0.1 * (rgbaData[i4] * 256 * 256 + rgbaData[i4 + 1] * 256 + rgbaData[i4 + 2]);
139
+ }
140
+ }
141
+
142
+ function extractElevationTilesMapbox(
143
+ rgbaData,
144
+ noDataValues,
145
+ outCurrenElevations,
146
+ outChildrenElevations
147
+ ) {
148
+ let destSize = Math.sqrt(outCurrenElevations.length) - 1;
149
+ let destSizeOne = destSize + 1;
150
+ let sourceSize = Math.sqrt(rgbaData.length / 4);
151
+ let dt = sourceSize / destSize;
152
+
153
+ let rightHeight = 0,
154
+ bottomHeight = 0,
155
+ sourceSize4 = 0;
156
+
157
+ for (
158
+ let k = 0, currIndex = 0, sourceDataLength = rgbaData.length / 4;
159
+ k < sourceDataLength;
160
+ k++
161
+ ) {
162
+ let k4 = k * 4;
163
+
164
+ let height =
165
+ -10000 + 0.1 * (rgbaData[k4] * 256 * 256 + rgbaData[k4 + 1] * 256 + rgbaData[k4 + 2]);
166
+
167
+ let isNoDataCurrent = MapboxTerrain.checkNoDataValue(noDataValues, height),
168
+ isNoDataRight = false,
169
+ isNoDataBottom = false;
170
+
171
+ let i = Math.floor(k / sourceSize),
172
+ j = k % sourceSize;
173
+
174
+ let tileX = Math.floor(j / destSize),
175
+ tileY = Math.floor(i / destSize);
176
+
177
+ let destArr = outChildrenElevations[tileY][tileX];
178
+
179
+ let ii = i % destSize,
180
+ jj = j % destSize;
181
+
182
+ let destIndex = (ii + tileY) * destSizeOne + jj + tileX;
183
+
184
+ destArr[destIndex] = height;
185
+
186
+ if ((i + tileY) % dt === 0 && (j + tileX) % dt === 0) {
187
+ outCurrenElevations[currIndex++] = height;
188
+ }
189
+
190
+ if ((j + 1) % destSize === 0 && j !== sourceSize - 1) {
191
+ //current tile
192
+ rightHeight =
193
+ -10000 +
194
+ 0.1 * (rgbaData[k4 + 4] * 256 * 256 + rgbaData[k4 + 5] * 256 + rgbaData[k4 + 6]);
195
+
196
+ isNoDataRight = MapboxTerrain.checkNoDataValue(noDataValues, rightHeight);
197
+
198
+ let middleHeight = height;
199
+
200
+ if (!(isNoDataCurrent || isNoDataRight)) {
201
+ middleHeight = (height + rightHeight) * 0.5;
202
+ }
203
+
204
+ destIndex = (ii + tileY) * destSizeOne + jj + 1;
205
+ destArr[destIndex] = middleHeight;
206
+
207
+ if ((i + tileY) % dt === 0) {
208
+ outCurrenElevations[currIndex++] = middleHeight;
209
+ }
210
+
211
+ //next right tile
212
+ let rightindex = (ii + tileY) * destSizeOne + ((jj + 1) % destSize);
213
+ outChildrenElevations[tileY][tileX + 1][rightindex] = middleHeight;
214
+ }
215
+
216
+ if ((i + 1) % destSize === 0 && i !== sourceSize - 1) {
217
+ //current tile
218
+ sourceSize4 = sourceSize * 4;
219
+
220
+ bottomHeight =
221
+ -10000 +
222
+ 0.1 *
223
+ (rgbaData[k4 + sourceSize4] * 256 * 256 +
224
+ rgbaData[k4 + sourceSize4 + 1] * 256 +
225
+ rgbaData[k4 + sourceSize4 + 2]);
226
+
227
+ isNoDataBottom = MapboxTerrain.checkNoDataValue(noDataValues, bottomHeight);
228
+
229
+ let middleHeight = (height + bottomHeight) * 0.5;
230
+
231
+ if (!(isNoDataCurrent || isNoDataBottom)) {
232
+ middleHeight = (height + bottomHeight) * 0.5;
233
+ }
234
+
235
+ destIndex = (ii + 1) * destSizeOne + jj + tileX;
236
+ destArr[destIndex] = middleHeight;
237
+
238
+ if ((j + tileX) % dt === 0) {
239
+ outCurrenElevations[currIndex++] = middleHeight;
240
+ }
241
+
242
+ //next bottom tile
243
+ let bottomindex = ((ii + 1) % destSize) * destSizeOne + jj + tileX;
244
+ outChildrenElevations[tileY + 1][tileX][bottomindex] = middleHeight;
245
+ }
246
+
247
+ if (
248
+ (j + 1) % destSize === 0 &&
249
+ j !== sourceSize - 1 &&
250
+ (i + 1) % destSize === 0 &&
251
+ i !== sourceSize - 1
252
+ ) {
253
+ //current tile
254
+ let rightBottomHeight =
255
+ -10000 +
256
+ 0.1 *
257
+ (rgbaData[k4 + sourceSize4 + 4] * 256 * 256 +
258
+ rgbaData[k4 + sourceSize4 + 5] * 256 +
259
+ rgbaData[k4 + sourceSize4 + 6]);
260
+
261
+ let isNoDataRightBottom = MapboxTerrain.checkNoDataValue(
262
+ noDataValues,
263
+ rightBottomHeight
264
+ );
265
+
266
+ let middleHeight = height;
267
+
268
+ if (!(isNoDataCurrent || isNoDataRight || isNoDataBottom || isNoDataRightBottom)) {
269
+ middleHeight = (height + rightHeight + bottomHeight + rightBottomHeight) * 0.25;
270
+ }
271
+
272
+ destIndex = (ii + 1) * destSizeOne + (jj + 1);
273
+ destArr[destIndex] = middleHeight;
274
+
275
+ outCurrenElevations[currIndex++] = middleHeight;
276
+
277
+ //next right tile
278
+ let rightindex = (ii + 1) * destSizeOne;
279
+ outChildrenElevations[tileY][tileX + 1][rightindex] = middleHeight;
280
+
281
+ //next bottom tile
282
+ let bottomindex = destSize;
283
+ outChildrenElevations[tileY + 1][tileX][bottomindex] = middleHeight;
284
+
285
+ //next right bottom tile
286
+ let rightBottomindex = 0;
287
+ outChildrenElevations[tileY + 1][tileX + 1][rightBottomindex] = middleHeight;
288
+ }
289
+ }
290
+ }
291
+
292
+ export { MapboxTerrain };
@@ -86,16 +86,20 @@ class FontAtlas {
86
86
  tc[10] = r.left / w;
87
87
  tc[11] = r.top / h;
88
88
 
89
- atlas.nodes[ti] = new TextureAtlasNode(r, tc);
90
- atlas.nodes[ti].metrics = ci;
91
-
92
- atlas.nodes[ti].metrics.nWidth = atlas.nodes[ti].metrics.width / s;
93
- atlas.nodes[ti].metrics.nHeight = atlas.nodes[ti].metrics.height / s;
94
- atlas.nodes[ti].metrics.nAdvance = atlas.nodes[ti].metrics.xadvance / s;
95
- atlas.nodes[ti].metrics.nXOffset = atlas.nodes[ti].metrics.xoffset / s;
96
- atlas.nodes[ti].metrics.nYOffset = 1.0 - atlas.nodes[ti].metrics.yoffset / s;
97
-
98
- atlas.nodes[ti].emptySize = 1;
89
+ let taNode = new TextureAtlasNode(r, tc);
90
+ let ciNorm = ci.char.normalize('NFKC');
91
+ let ciCode = ciNorm.charCodeAt();
92
+ taNode.metrics = ci;
93
+ taNode.metrics.nChar = ciNorm;
94
+ taNode.metrics.nCode = ciCode;
95
+ taNode.metrics.nWidth = taNode.metrics.width / s;
96
+ taNode.metrics.nHeight = taNode.metrics.height / s;
97
+ taNode.metrics.nAdvance = taNode.metrics.xadvance / s;
98
+ taNode.metrics.nXOffset = taNode.metrics.xoffset / s;
99
+ taNode.metrics.nYOffset = 1.0 - taNode.metrics.yoffset / s;
100
+ taNode.emptySize = 1;
101
+
102
+ atlas.nodes.set(ciNorm.charCodeAt(), taNode);
99
103
  }
100
104
 
101
105
  atlas.kernings = {};
@@ -106,14 +110,20 @@ class FontAtlas {
106
110
  let first = ki.first,
107
111
  second = ki.second;
108
112
 
109
- let charFirst = idToChar[first],
110
- charSecond = idToChar[second];
113
+ //let charFirst = idToChar[first],
114
+ // charSecond = idToChar[second];
115
+
116
+ // if (!atlas.kernings[charFirst]) {
117
+ // atlas.kernings[charFirst] = {};
118
+ // }
119
+ //
120
+ // atlas.kernings[charFirst][charSecond] = ki.amount / s;
111
121
 
112
- if (!atlas.kernings[charFirst]) {
113
- atlas.kernings[charFirst] = {};
122
+ if (!atlas.kernings[first]) {
123
+ atlas.kernings[first] = {};
114
124
  }
115
125
 
116
- atlas.kernings[charFirst][charSecond] = ki.amount / s;
126
+ atlas.kernings[first][second] = ki.amount / s;
117
127
  }
118
128
  }
119
129