@openglobus/og 0.15.4 → 0.16.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.
- package/README.md +4 -8
- package/css/og.css +1 -1
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +13 -14
- package/src/og/Globe.js +5 -2
- package/src/og/LonLat.js +224 -193
- package/src/og/Object3d.js +21 -2
- package/src/og/bv/index.js +2 -2
- package/src/og/camera/Camera.js +4 -16
- package/src/og/camera/PlanetCamera.js +15 -15
- package/src/og/control/KeyboardNavigation.js +153 -169
- package/src/og/control/MouseNavigation.js +0 -20
- package/src/og/control/RulerSwitcher.js +2 -2
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/ZoomControl.js +2 -2
- package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
- package/src/og/control/index.js +5 -2
- package/src/og/control/ruler/RulerScene.js +11 -8
- package/src/og/control/timeline/TimelineControl.js +5 -3
- package/src/og/control/timeline/TimelineModel.js +4 -0
- package/src/og/control/timeline/TimelineView.js +10 -3
- package/src/og/control/visibleExtent/Segment.js +36 -42
- package/src/og/ellipsoid/Ellipsoid.js +41 -11
- package/src/og/entity/Entity.js +3 -3
- package/src/og/entity/EntityCollection.js +2 -2
- package/src/og/entity/Label.js +1 -1
- package/src/og/entity/Polyline.js +4 -2
- package/src/og/index.js +4 -7
- package/src/og/layer/CanvasTiles.js +70 -23
- package/src/og/layer/GeoImage.js +40 -18
- package/src/og/layer/Vector.js +21 -17
- package/src/og/layer/WMS.js +2 -2
- package/src/og/layer/XYZ.js +2 -2
- package/src/og/math.js +2 -1
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
- package/src/og/quadTree/EntityCollectionNode.js +8 -2
- package/src/og/quadTree/Node.js +44 -50
- package/src/og/quadTree/index.js +2 -0
- package/src/og/renderer/Renderer.js +14 -1
- package/src/og/scene/Planet.js +12 -8
- package/src/og/scene/index.js +3 -3
- package/src/og/segment/Segment.js +125 -120
- package/src/og/terrain/EmptyTerrain.js +19 -7
- package/src/og/terrain/GlobusTerrain.js +23 -18
- package/src/og/terrain/MapboxTerrain.js +7 -8
- package/src/og/terrain/index.js +4 -4
- package/src/og/utils/objParser.js +227 -0
- package/src/og/utils/shared.js +9 -0
- package/src/og/webgl/Handler.js +1 -3
- package/types/Globe.d.ts +2 -0
- package/types/LonLat.d.ts +20 -1
- package/types/Object3d.d.ts +2 -0
- package/types/Popup.d.ts +1 -1
- package/types/bv/index.d.ts +2 -2
- package/types/camera/PlanetCamera.d.ts +1 -8
- package/types/camera/index.d.ts +2 -2
- package/types/control/GeoImageDragControl.d.ts +1 -1
- package/types/control/LayerAnimation.d.ts +1 -1
- package/types/control/Lighting.d.ts +2 -2
- package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
- package/types/control/index.d.ts +3 -2
- package/types/control/ruler/RulerScene.d.ts +5 -4
- package/types/control/selection/SelectionScene.d.ts +3 -3
- package/types/control/timeline/TimelineControl.d.ts +10 -0
- package/types/control/timeline/TimelineModel.d.ts +33 -0
- package/types/control/timeline/TimelineView.d.ts +57 -0
- package/types/control/timeline/timelineUtils.d.ts +9 -0
- package/types/ellipsoid/Ellipsoid.d.ts +27 -8
- package/types/ellipsoid/index.d.ts +2 -2
- package/types/entity/Entity.d.ts +3 -3
- package/types/entity/EntityCollection.d.ts +2 -2
- package/types/entity/Label.d.ts +1 -1
- package/types/entity/Polyline.d.ts +1 -0
- package/types/index.d.ts +45 -46
- package/types/layer/CanvasTiles.d.ts +2 -1
- package/types/layer/GeoImage.d.ts +7 -1
- package/types/layer/GeoTexture2d.d.ts +1 -1
- package/types/layer/Vector.d.ts +3 -3
- package/types/layer/XYZ.d.ts +1 -1
- package/types/layer/index.d.ts +9 -9
- package/types/math/Line2.d.ts +1 -1
- package/types/math/Line3.d.ts +1 -1
- package/types/math/index.d.ts +10 -10
- package/types/mercator.d.ts +1 -1
- package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/EntityCollectionNode.d.ts +1 -1
- package/types/quadTree/index.d.ts +2 -0
- package/types/renderer/Renderer.d.ts +2 -2
- package/types/scene/Axes.d.ts +1 -1
- package/types/scene/SkyBox.d.ts +1 -1
- package/types/scene/index.d.ts +3 -3
- package/types/segment/Segment.d.ts +11 -14
- package/types/shaders/atmos.d.ts +1 -1
- package/types/shaders/billboard.d.ts +1 -1
- package/types/shaders/depth.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/shaders/pickingMask.d.ts +1 -1
- package/types/shaders/pointCloud.d.ts +1 -1
- package/types/shaders/polyline.d.ts +1 -1
- package/types/shaders/ray.d.ts +1 -1
- package/types/shaders/screenFrame.d.ts +1 -1
- package/types/shaders/skybox.d.ts +1 -1
- package/types/shaders/toneMapping.d.ts +1 -1
- package/types/terrain/BilTerrain.d.ts +1 -0
- package/types/terrain/EmptyTerrain.d.ts +13 -2
- package/types/terrain/GlobusTerrain.d.ts +2 -1
- package/types/terrain/MapboxTerrain.d.ts +1 -3
- package/types/terrain/index.d.ts +4 -4
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/ButtonGroup.d.ts +12 -0
- package/types/ui/Dialog.d.ts +2 -2
- package/types/ui/Slider.d.ts +1 -1
- package/types/ui/ToggleButton.d.ts +1 -1
- package/types/ui/View.d.ts +1 -1
- package/types/utils/GeoImageCreator.d.ts +2 -2
- package/types/utils/ImagesCacheManager.d.ts +1 -1
- package/types/utils/Loader.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +1 -1
- package/types/utils/objParser.d.ts +8 -0
- package/types/utils/shared.d.ts +6 -0
- package/types/webgl/Handler.d.ts +2 -2
- package/src/og/index.core.js +0 -116
- package/src/og/index.webgl.js +0 -17
- package/types/index.core.d.ts +0 -65
- package/types/index.webgl.d.ts +0 -7
|
@@ -174,12 +174,6 @@ class Segment {
|
|
|
174
174
|
*/
|
|
175
175
|
this.normalMapReady = false;
|
|
176
176
|
|
|
177
|
-
/**
|
|
178
|
-
* Parent normal map is made allready(optimization parameter).
|
|
179
|
-
* @type {boolean}
|
|
180
|
-
*/
|
|
181
|
-
this.parentNormalMapReady = false;
|
|
182
|
-
|
|
183
177
|
/**
|
|
184
178
|
* Terrain is allready applied flag.
|
|
185
179
|
* @type {boolean}
|
|
@@ -254,11 +248,10 @@ class Segment {
|
|
|
254
248
|
* @public
|
|
255
249
|
* @param {Entity} entity - Entity.
|
|
256
250
|
* @param {Vec3} res - Point coordinates.
|
|
257
|
-
* @param {Vec3} [normal] - Terrain point normal.
|
|
258
251
|
* @returns {Vec3} -
|
|
259
252
|
*/
|
|
260
|
-
getEntityTerrainPoint(entity, res
|
|
261
|
-
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res
|
|
253
|
+
getEntityTerrainPoint(entity, res) {
|
|
254
|
+
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res);
|
|
262
255
|
}
|
|
263
256
|
|
|
264
257
|
isEntityInside(e) {
|
|
@@ -274,80 +267,74 @@ class Segment {
|
|
|
274
267
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
275
268
|
* @returns {number} -
|
|
276
269
|
*/
|
|
277
|
-
getTerrainPoint(xyz, insideSegmentPosition, res
|
|
278
|
-
|
|
270
|
+
getTerrainPoint(xyz, insideSegmentPosition, res) {
|
|
271
|
+
let verts = this.tempVertices;
|
|
279
272
|
|
|
280
|
-
|
|
273
|
+
if (verts && verts.length) {
|
|
274
|
+
let norm = this.planet.ellipsoid.getSurfaceNormal3v(xyz);
|
|
275
|
+
_ray.set(xyz, norm.negateTo());
|
|
281
276
|
|
|
282
|
-
|
|
283
|
-
var ne = this._extent.northEast,
|
|
277
|
+
let ne = this._extent.northEast,
|
|
284
278
|
sw = this._extent.southWest,
|
|
285
279
|
size = Math.sqrt(verts.length / 3) - 1;
|
|
286
280
|
|
|
287
|
-
|
|
281
|
+
let xmax = ne.lon,
|
|
288
282
|
ymax = ne.lat,
|
|
289
283
|
xmin = sw.lon,
|
|
290
284
|
ymin = sw.lat,
|
|
291
285
|
x = insideSegmentPosition.lon,
|
|
292
286
|
y = insideSegmentPosition.lat;
|
|
293
287
|
|
|
294
|
-
|
|
288
|
+
let sxn = xmax - xmin,
|
|
295
289
|
syn = ymax - ymin;
|
|
296
290
|
|
|
297
|
-
|
|
291
|
+
let qx = sxn / size,
|
|
298
292
|
qy = syn / size;
|
|
299
293
|
|
|
300
|
-
|
|
294
|
+
let xn = x - xmin,
|
|
301
295
|
yn = y - ymin;
|
|
302
296
|
|
|
303
|
-
|
|
297
|
+
let indX = Math.floor(xn / qx),
|
|
304
298
|
indY = Math.floor(size - yn / qy);
|
|
305
299
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
300
|
+
let ind_v0 = ((size + 1) * indY + indX) * 3;
|
|
301
|
+
let ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
309
302
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
303
|
+
_v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
|
|
304
|
+
_v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
|
|
305
|
+
_v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
|
|
313
306
|
|
|
314
|
-
|
|
307
|
+
let d = _ray.hitTriangle(_v0, _v1, _v2, res);
|
|
315
308
|
|
|
309
|
+
if (d === Ray.INSIDE) {
|
|
310
|
+
return xyz.distance(res);
|
|
311
|
+
} else if (d === Ray.AWAY) {
|
|
312
|
+
_rayEx.set(xyz, norm);
|
|
313
|
+
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res);
|
|
316
314
|
if (d === Ray.INSIDE) {
|
|
317
|
-
return xyz.distance(res);
|
|
318
|
-
} else if (d === Ray.AWAY) {
|
|
319
|
-
_rayEx.set(xyz, this.planet.ellipsoid.getSurfaceNormal3v(xyz));
|
|
320
|
-
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res, normal);
|
|
321
|
-
if (d === Ray.INSIDE) {
|
|
322
|
-
return -xyz.distance(res);
|
|
323
|
-
}
|
|
315
|
+
return -xyz.distance(res);
|
|
324
316
|
}
|
|
317
|
+
}
|
|
325
318
|
|
|
326
|
-
|
|
319
|
+
_v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
|
|
327
320
|
|
|
328
|
-
|
|
321
|
+
d = _ray.hitTriangle(_v1, _v3, _v2, res);
|
|
322
|
+
if (d === Ray.INSIDE) {
|
|
323
|
+
return xyz.distance(res);
|
|
324
|
+
} else if (d === Ray.AWAY) {
|
|
325
|
+
_rayEx.set(xyz, norm);
|
|
326
|
+
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res);
|
|
329
327
|
if (d === Ray.INSIDE) {
|
|
330
|
-
return xyz.distance(res);
|
|
331
|
-
} else if (d === Ray.AWAY) {
|
|
332
|
-
_rayEx.set(xyz, this.planet.ellipsoid.getSurfaceNormal3v(xyz));
|
|
333
|
-
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res, normal);
|
|
334
|
-
if (d === Ray.INSIDE) {
|
|
335
|
-
return -xyz.distance(res);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (d === Ray.AWAY) {
|
|
340
328
|
return -xyz.distance(res);
|
|
341
329
|
}
|
|
330
|
+
}
|
|
342
331
|
|
|
343
|
-
|
|
332
|
+
if (d === Ray.AWAY) {
|
|
333
|
+
return -xyz.distance(res);
|
|
344
334
|
}
|
|
345
335
|
|
|
346
|
-
res.copy(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
347
|
-
normal && normal.copy(xyz.normal());
|
|
348
336
|
return xyz.distance(res);
|
|
349
337
|
} else {
|
|
350
|
-
normal && normal.copy(xyz.normal());
|
|
351
338
|
return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
352
339
|
}
|
|
353
340
|
}
|
|
@@ -367,7 +354,7 @@ class Segment {
|
|
|
367
354
|
* @param {boolean} forceLoading
|
|
368
355
|
*/
|
|
369
356
|
loadTerrain(forceLoading) {
|
|
370
|
-
if (this.tileZoom < this.planet.terrain.minZoom) {
|
|
357
|
+
if (this.tileZoom < this.planet.terrain.minZoom || this.planet.terrain.isEmpty) {
|
|
371
358
|
this.terrainIsLoading = true;
|
|
372
359
|
|
|
373
360
|
this.elevationsNotExists();
|
|
@@ -381,6 +368,9 @@ class Segment {
|
|
|
381
368
|
} else if (!this.terrainIsLoading && !this.terrainReady) {
|
|
382
369
|
this.planet.terrain.loadTerrain(this, forceLoading);
|
|
383
370
|
}
|
|
371
|
+
// if (!this.terrainIsLoading && !this.terrainReady) {
|
|
372
|
+
// this.planet.terrain.loadTerrain(this, forceLoading);
|
|
373
|
+
// }
|
|
384
374
|
}
|
|
385
375
|
}
|
|
386
376
|
|
|
@@ -389,9 +379,8 @@ class Segment {
|
|
|
389
379
|
* @param {Float32Array} elevations - Elevation data.
|
|
390
380
|
*/
|
|
391
381
|
elevationsExists(elevations) {
|
|
392
|
-
const segment = this;
|
|
393
382
|
if (this.plainReady && this.terrainIsLoading) {
|
|
394
|
-
this.planet._terrainWorker.make(
|
|
383
|
+
this.planet._terrainWorker.make(this, elevations);
|
|
395
384
|
|
|
396
385
|
this.plainVerticesHigh = null;
|
|
397
386
|
this.plainVerticesLow = null;
|
|
@@ -406,6 +395,63 @@ class Segment {
|
|
|
406
395
|
}
|
|
407
396
|
}
|
|
408
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Keep plain elevation segment for rendering
|
|
400
|
+
*
|
|
401
|
+
* 'this.tileZoom <= this.planet.terrain.maxZoom' it means, that the segment is plain
|
|
402
|
+
*
|
|
403
|
+
*/
|
|
404
|
+
elevationsNotExists() {
|
|
405
|
+
if (this.planet && this.tileZoom <= this.planet.terrain.maxNativeZoom) {
|
|
406
|
+
if (this.plainReady && this.terrainIsLoading) {
|
|
407
|
+
this.terrainIsLoading = false;
|
|
408
|
+
|
|
409
|
+
let n = this.node;
|
|
410
|
+
n.appliedTerrainNodeId = this.node.nodeId;
|
|
411
|
+
n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
|
|
412
|
+
n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
|
|
413
|
+
|
|
414
|
+
if (this.planet.lightEnabled && !this._inTheQueue) {
|
|
415
|
+
this.planet._normalMapCreator.queue(this);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
this.readyToEngage = true;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// plain terrain only
|
|
422
|
+
this.terrainVertices = this.plainVertices;
|
|
423
|
+
this.terrainVerticesHigh = this.plainVerticesHigh;
|
|
424
|
+
this.terrainVerticesLow = this.plainVerticesLow;
|
|
425
|
+
|
|
426
|
+
this.tempVertices = this.terrainVertices;
|
|
427
|
+
this.tempVerticesHigh = this.terrainVerticesHigh;
|
|
428
|
+
this.tempVerticesLow = this.terrainVerticesLow;
|
|
429
|
+
|
|
430
|
+
this.noDataVertices = null;
|
|
431
|
+
|
|
432
|
+
this.fileGridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
|
|
433
|
+
this.gridSize = this.fileGridSize;
|
|
434
|
+
this.terrainReady = true;
|
|
435
|
+
this.terrainExists = false;
|
|
436
|
+
} else {
|
|
437
|
+
|
|
438
|
+
if (this.plainReady && this.terrainIsLoading) {
|
|
439
|
+
this.terrainIsLoading = false;
|
|
440
|
+
|
|
441
|
+
let n = this.node;
|
|
442
|
+
n.appliedTerrainNodeId = this.node.nodeId;
|
|
443
|
+
n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
|
|
444
|
+
n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
|
|
445
|
+
|
|
446
|
+
this.readyToEngage = true;
|
|
447
|
+
this.terrainReady = true;
|
|
448
|
+
this.passReady = true;
|
|
449
|
+
|
|
450
|
+
this.terrainExists = false;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
409
455
|
_checkEqualization(neighborSide, neigborNode) {
|
|
410
456
|
return neigborNode && this.tileZoom >= neigborNode.segment.tileZoom &&
|
|
411
457
|
this.node.equalizedSideWithNodeId[neighborSide] !== neigborNode.equalizedSideWithNodeId[OPSIDE[neighborSide]];
|
|
@@ -589,33 +635,6 @@ class Segment {
|
|
|
589
635
|
this.createCoordsBuffers(this.tempVerticesHigh, this.tempVerticesLow, this.gridSize);
|
|
590
636
|
}
|
|
591
637
|
|
|
592
|
-
_plainSegmentWorkerCallback(data) {
|
|
593
|
-
this.plainProcessing = false;
|
|
594
|
-
|
|
595
|
-
if (this.initialized && !this.terrainReady) {
|
|
596
|
-
this.plainVertices = data.plainVertices;
|
|
597
|
-
this.plainVerticesHigh = data.plainVerticesHigh;
|
|
598
|
-
this.plainVerticesLow = data.plainVerticesLow;
|
|
599
|
-
|
|
600
|
-
this.plainNormals = data.plainNormals;
|
|
601
|
-
|
|
602
|
-
this.normalMapNormals = data.normalMapNormals;
|
|
603
|
-
this.normalMapVertices = data.normalMapVertices;
|
|
604
|
-
this.normalMapVerticesHigh = data.normalMapVerticesHigh;
|
|
605
|
-
this.normalMapVerticesLow = data.normalMapVerticesLow;
|
|
606
|
-
|
|
607
|
-
this.terrainVertices = this.plainVertices;
|
|
608
|
-
this.terrainVerticesHigh = this.plainVerticesHigh;
|
|
609
|
-
this.terrainVerticesLow = this.plainVerticesLow;
|
|
610
|
-
|
|
611
|
-
this.fileGridSize = Math.sqrt(data.normalMapVertices.length / 3) - 1;
|
|
612
|
-
|
|
613
|
-
this._plainRadius = data.plainRadius;
|
|
614
|
-
|
|
615
|
-
this.plainReady = true;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
638
|
_terrainWorkerCallback(data) {
|
|
620
639
|
if (this.plainReady) {
|
|
621
640
|
this.readyToEngage = true;
|
|
@@ -661,7 +680,6 @@ class Segment {
|
|
|
661
680
|
|
|
662
681
|
this.terrainReady = true;
|
|
663
682
|
this.terrainIsLoading = false;
|
|
664
|
-
this.parentNormalMapReady = true;
|
|
665
683
|
this.terrainExists = true;
|
|
666
684
|
|
|
667
685
|
if (!this.normalMapTexturePtr) {
|
|
@@ -678,43 +696,6 @@ class Segment {
|
|
|
678
696
|
}
|
|
679
697
|
}
|
|
680
698
|
|
|
681
|
-
/**
|
|
682
|
-
* Terrain is not obtained or not exists on the server.
|
|
683
|
-
*/
|
|
684
|
-
elevationsNotExists() {
|
|
685
|
-
if (this.planet && this.tileZoom <= this.planet.terrain.maxZoom) {
|
|
686
|
-
if (this.plainReady && this.terrainIsLoading) {
|
|
687
|
-
this.terrainIsLoading = false;
|
|
688
|
-
|
|
689
|
-
let n = this.node;
|
|
690
|
-
n.appliedTerrainNodeId = this.node.nodeId;
|
|
691
|
-
n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
|
|
692
|
-
n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
|
|
693
|
-
|
|
694
|
-
if (this.planet.lightEnabled && !this._inTheQueue) {
|
|
695
|
-
this.planet._normalMapCreator.queue(this);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
this.readyToEngage = true;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
this.terrainVertices = this.plainVertices;
|
|
702
|
-
this.terrainVerticesHigh = this.plainVerticesHigh;
|
|
703
|
-
this.terrainVerticesLow = this.plainVerticesLow;
|
|
704
|
-
|
|
705
|
-
this.tempVertices = this.terrainVertices;
|
|
706
|
-
this.tempVerticesHigh = this.terrainVerticesHigh;
|
|
707
|
-
this.tempVerticesLow = this.terrainVerticesLow;
|
|
708
|
-
|
|
709
|
-
this.noDataVertices = null;
|
|
710
|
-
|
|
711
|
-
this.fileGridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
|
|
712
|
-
this.gridSize = this.fileGridSize;
|
|
713
|
-
this.terrainReady = true;
|
|
714
|
-
this.terrainExists = false;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
699
|
_normalMapEdgeEqualize(side) {
|
|
719
700
|
let nn = this.node.neighbors;
|
|
720
701
|
let n = nn[side][0];
|
|
@@ -874,7 +855,6 @@ class Segment {
|
|
|
874
855
|
this.handler.gl.deleteTexture(this.normalMapTexture);
|
|
875
856
|
}
|
|
876
857
|
this.normalMapReady = false;
|
|
877
|
-
this.parentNormalMapReady = false;
|
|
878
858
|
this._appliedNeighborsZoom = [0, 0, 0, 0];
|
|
879
859
|
this.normalMapTextureBias[0] = 0;
|
|
880
860
|
this.normalMapTextureBias[1] = 0;
|
|
@@ -1263,12 +1243,37 @@ class Segment {
|
|
|
1263
1243
|
let p = this.planet,
|
|
1264
1244
|
t = p.terrain;
|
|
1265
1245
|
|
|
1266
|
-
if (t.isReady() && this.tileZoom <= t.maxZoom
|
|
1246
|
+
if (t.isReady() && !this.plainReady && this.tileZoom <= t.maxZoom) {
|
|
1267
1247
|
this.plainProcessing = true;
|
|
1268
1248
|
p._plainSegmentWorker.make(this);
|
|
1269
1249
|
}
|
|
1270
1250
|
}
|
|
1271
1251
|
|
|
1252
|
+
_plainSegmentWorkerCallback(data) {
|
|
1253
|
+
this.plainProcessing = false;
|
|
1254
|
+
|
|
1255
|
+
if (this.initialized && !this.terrainReady) {
|
|
1256
|
+
this.plainReady = true;
|
|
1257
|
+
|
|
1258
|
+
this.plainVertices = data.plainVertices;
|
|
1259
|
+
this.plainVerticesHigh = data.plainVerticesHigh;
|
|
1260
|
+
this.plainVerticesLow = data.plainVerticesLow;
|
|
1261
|
+
this.plainNormals = data.plainNormals;
|
|
1262
|
+
this._plainRadius = data.plainRadius;
|
|
1263
|
+
|
|
1264
|
+
this.normalMapNormals = data.normalMapNormals;
|
|
1265
|
+
this.normalMapVertices = data.normalMapVertices;
|
|
1266
|
+
this.normalMapVerticesHigh = data.normalMapVerticesHigh;
|
|
1267
|
+
this.normalMapVerticesLow = data.normalMapVerticesLow;
|
|
1268
|
+
|
|
1269
|
+
//this.terrainVertices = this.plainVertices;
|
|
1270
|
+
//this.terrainVerticesHigh = this.plainVerticesHigh;
|
|
1271
|
+
//this.terrainVerticesLow = this.plainVerticesLow;
|
|
1272
|
+
|
|
1273
|
+
this.fileGridSize = Math.sqrt(data.normalMapVertices.length / 3) - 1;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1272
1277
|
createPlainSegment() {
|
|
1273
1278
|
this.initialize();
|
|
1274
1279
|
this._createPlainVertices();
|
|
@@ -1597,7 +1602,7 @@ class Segment {
|
|
|
1597
1602
|
shu = sh.uniforms;
|
|
1598
1603
|
|
|
1599
1604
|
var currHeight;
|
|
1600
|
-
if (layerSlice.length) {
|
|
1605
|
+
if (layerSlice && layerSlice.length) {
|
|
1601
1606
|
currHeight = layerSlice[0]._height;
|
|
1602
1607
|
} else {
|
|
1603
1608
|
currHeight = 0;
|
|
@@ -9,11 +9,18 @@ import { Geoid } from "./Geoid.js";
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Class represents terrain provider without elevation data.
|
|
12
|
-
* @
|
|
12
|
+
* @param {Object} [options] - Provider options:
|
|
13
|
+
* @param {string} [options.name="empty"] - Provider name.
|
|
14
|
+
* @param {number} [options.minZoom=2] - Minimal visible zoom index when terrain handler works.
|
|
15
|
+
* @param {number} [options.minZoom=50] - Maximal visible zoom index when terrain handler works.
|
|
16
|
+
* @param {number} [options.minNativeZoom=50] - Maximal available terrain zoom level.
|
|
17
|
+
* @param {Array.<number>} [options.gridSizeByZoom] - Array of segment triangulation grid sizes where array index agreed to the segment zoom index.
|
|
18
|
+
* @param {Array.<number>} [gridSizeByZoom] - Array of values, where each value corresponds to the size of a tile(or segment) on the globe. Each value must be power of two.
|
|
13
19
|
*/
|
|
14
20
|
class EmptyTerrain {
|
|
15
21
|
constructor(options = {}) {
|
|
16
|
-
|
|
22
|
+
|
|
23
|
+
this.equalizeVertices = options.equalizeVertices || false;
|
|
17
24
|
|
|
18
25
|
this.equalizeNormals = false;
|
|
19
26
|
|
|
@@ -24,30 +31,35 @@ class EmptyTerrain {
|
|
|
24
31
|
* @public
|
|
25
32
|
* @type {string}
|
|
26
33
|
*/
|
|
27
|
-
this.name = "empty";
|
|
34
|
+
this.name = options.name || "empty";
|
|
28
35
|
|
|
29
36
|
/**
|
|
30
37
|
* Minimal z-index value for segment elevation data handling.
|
|
31
38
|
* @public
|
|
32
39
|
* @type {number}
|
|
33
40
|
*/
|
|
34
|
-
this.minZoom =
|
|
41
|
+
this.minZoom = options.minZoom || 2;
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
44
|
* Maximal z-index value for segment elevation data handling.
|
|
38
45
|
* @public
|
|
39
46
|
* @type {number}
|
|
40
47
|
*/
|
|
41
|
-
this.maxZoom =
|
|
48
|
+
this.maxZoom = options.maxZoom || 50;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Maximal existent available zoom
|
|
52
|
+
* @type {number}
|
|
53
|
+
*/
|
|
54
|
+
this.maxNativeZoom = options.maxNativeZoom || this.maxZoom;
|
|
42
55
|
|
|
43
56
|
/**
|
|
44
57
|
* @public
|
|
45
58
|
* @type {Array.<number>}
|
|
46
59
|
*/
|
|
47
60
|
this.gridSizeByZoom = options.gridSizeByZoom || [
|
|
48
|
-
|
|
61
|
+
64, 32, 16, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
|
|
49
62
|
];
|
|
50
|
-
//this.gridSizeByZoom = options.gridSizeByZoom || [32, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2];
|
|
51
63
|
|
|
52
64
|
this._maxNodeZoom = this.gridSizeByZoom.length - 1;
|
|
53
65
|
|
|
@@ -39,6 +39,7 @@ const EVENT_NAMES = [
|
|
|
39
39
|
* @param {Object} [options] - Provider options:
|
|
40
40
|
* @param {number} [options.minZoom=3] - Minimal visible zoom index when terrain handler works.
|
|
41
41
|
* @param {number} [options.minZoom=14] - Maximal visible zoom index when terrain handler works.
|
|
42
|
+
* @param {number} [options.minNativeZoom=14] - Maximal available terrain zoom level.
|
|
42
43
|
* @param {string} [options.url="//openglobus.org/heights/srtm3/{z}/{y}/{x}.ddm"] - Terrain source path url template. Default is openglobus ddm elevation file.
|
|
43
44
|
* @param {Array.<number>} [options.gridSizeByZoom] - Array of segment triangulation grid sizes where array index agreed to the segment zoom index.
|
|
44
45
|
* @param {number} [options.plainGridSize=32] - Elevation grid size. Default is 32x32. Must be power of two.
|
|
@@ -54,8 +55,14 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
54
55
|
* @param {*} [options]
|
|
55
56
|
*/
|
|
56
57
|
constructor(name, options = {}) {
|
|
57
|
-
super({
|
|
58
|
+
super({
|
|
59
|
+
geoidSrc: "//openglobus.org/geoid/egm84-30.pgm",
|
|
60
|
+
maxNativeZoom: options.maxNativeZoom || 14,
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
|
|
58
64
|
this._s = options.subdomains || ["a", "b", "c"];
|
|
65
|
+
|
|
59
66
|
/**
|
|
60
67
|
* Events handler.
|
|
61
68
|
* @public
|
|
@@ -78,20 +85,6 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
78
85
|
*/
|
|
79
86
|
this.name = name || "openglobus";
|
|
80
87
|
|
|
81
|
-
/**
|
|
82
|
-
* Minimal visible zoom index when terrain handler works.
|
|
83
|
-
* @public
|
|
84
|
-
* @type {number}
|
|
85
|
-
*/
|
|
86
|
-
this.minZoom = options.minZoom || 2;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Maximal visible zoom index when terrain handler works.
|
|
90
|
-
* @public
|
|
91
|
-
* @type {number}
|
|
92
|
-
*/
|
|
93
|
-
this.maxZoom = options.maxZoom || 14;
|
|
94
|
-
|
|
95
88
|
/**
|
|
96
89
|
* Terrain source path url template.
|
|
97
90
|
* @public
|
|
@@ -169,13 +162,15 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
169
162
|
return false;
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
getHeightAsync(lonLat, callback, zoom) {
|
|
165
|
+
getHeightAsync(lonLat, callback, zoom, firstAttempt) {
|
|
173
166
|
if (!lonLat || lonLat.lat > mercator.MAX_LAT || lonLat.lat < mercator.MIN_LAT) {
|
|
174
167
|
callback(0);
|
|
175
168
|
return true;
|
|
176
169
|
}
|
|
177
170
|
|
|
178
|
-
|
|
171
|
+
firstAttempt = firstAttempt != undefined ? firstAttempt : true;
|
|
172
|
+
|
|
173
|
+
let z = zoom || this.maxNativeZoom,
|
|
179
174
|
z2 = Math.pow(2, z),
|
|
180
175
|
size = mercator.POLE2 / z2,
|
|
181
176
|
merc = mercator.forward(lonLat),
|
|
@@ -214,12 +209,22 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
214
209
|
this._elevationCache[tileIndex] = cache;
|
|
215
210
|
callback(this._getGroundHeightMerc(merc, cache));
|
|
216
211
|
} else if (response.status === "error") {
|
|
212
|
+
|
|
213
|
+
if (firstAttempt && z > this.maxZoom) {
|
|
214
|
+
firstAttempt = false;
|
|
215
|
+
this.getHeightAsync(lonLat, callback, this.maxZoom, false);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
217
219
|
let cache = {
|
|
218
220
|
heights: null,
|
|
219
221
|
extent: extent
|
|
220
222
|
};
|
|
223
|
+
|
|
221
224
|
this._elevationCache[tileIndex] = cache;
|
|
225
|
+
|
|
222
226
|
callback(0);
|
|
227
|
+
|
|
223
228
|
} else {
|
|
224
229
|
this._fetchCache[tileIndex] = null;
|
|
225
230
|
delete this._fetchCache[tileIndex];
|
|
@@ -475,4 +480,4 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
475
480
|
}
|
|
476
481
|
}
|
|
477
482
|
|
|
478
|
-
export { GlobusTerrain };
|
|
483
|
+
export { GlobusTerrain };
|
|
@@ -13,21 +13,20 @@ const rgb2Height = (r, g, b) => {
|
|
|
13
13
|
|
|
14
14
|
class MapboxTerrain extends GlobusTerrain {
|
|
15
15
|
constructor(name, options = {}) {
|
|
16
|
-
super(name || "mapbox",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options
|
|
16
|
+
super(name || "mapbox", {
|
|
17
|
+
equalizeVertices: options.equalizeVertices != undefined ? options.equalizeVertices : true,
|
|
18
|
+
maxZoom: options.maxZoom || 17,
|
|
19
|
+
...options
|
|
20
|
+
});
|
|
20
21
|
|
|
21
22
|
this.equalizeNormals = options.equalizeNormals || false;
|
|
22
23
|
|
|
23
|
-
this.minZoom = options.minZoom != undefined ? options.minZoom : 2;
|
|
24
|
-
|
|
25
|
-
this.maxZoom = options.maxZoom != undefined ? options.maxZoom : 17;
|
|
26
|
-
|
|
27
24
|
this.gridSizeByZoom = options.gridSizeByZoom || [
|
|
28
25
|
64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
|
|
29
26
|
];
|
|
30
27
|
|
|
28
|
+
"//{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm";
|
|
29
|
+
|
|
31
30
|
this.url =
|
|
32
31
|
options.url != undefined
|
|
33
32
|
? options.url
|
package/src/og/terrain/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BilTerrain } from './BilTerrain';
|
|
2
|
-
import { EmptyTerrain } from './EmptyTerrain';
|
|
3
|
-
import { GlobusTerrain } from './GlobusTerrain';
|
|
4
|
-
import { MapboxTerrain } from './MapboxTerrain';
|
|
1
|
+
import { BilTerrain } from './BilTerrain.js';
|
|
2
|
+
import { EmptyTerrain } from './EmptyTerrain.js';
|
|
3
|
+
import { GlobusTerrain } from './GlobusTerrain.js';
|
|
4
|
+
import { MapboxTerrain } from './MapboxTerrain.js';
|
|
5
5
|
|
|
6
6
|
export { EmptyTerrain, GlobusTerrain, MapboxTerrain, BilTerrain };
|