@openglobus/og 0.13.10 → 0.14.10

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 (39) hide show
  1. package/README.md +1 -4
  2. package/dist/@openglobus/og.esm.js +2 -2
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +2 -2
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/package.json +2 -2
  7. package/src/og/Globe.js +14 -6
  8. package/src/og/control/Sun.js +3 -2
  9. package/src/og/entity/GeometryHandler.js +3 -3
  10. package/src/og/entity/LabelHandler.js +1 -4
  11. package/src/og/entity/LabelWorker.js +10 -13
  12. package/src/og/index.js +106 -95
  13. package/src/og/layer/GeoVideo.js +1 -0
  14. package/src/og/layer/Layer.js +13 -12
  15. package/src/og/layer/XYZ.js +4 -3
  16. package/src/og/quadTree/EarthQuadTreeStrategy.js +29 -0
  17. package/src/og/quadTree/MarsQuadTreeStrategy.js +27 -0
  18. package/src/og/quadTree/Node.js +53 -216
  19. package/src/og/quadTree/QuadTreeStrategy.js +93 -0
  20. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +26 -0
  21. package/src/og/scene/Planet.js +20 -156
  22. package/src/og/segment/Segment.js +18 -25
  23. package/src/og/segment/SegmentLonLat.js +34 -31
  24. package/src/og/segment/SegmentLonLatWgs84.js +41 -0
  25. package/src/og/utils/quadTreeType.js +11 -0
  26. package/types/Globe.d.ts +7 -0
  27. package/types/control/Sun.d.ts +2 -1
  28. package/types/entity/LabelWorker.d.ts +1 -1
  29. package/types/index.d.ts +6 -1
  30. package/types/quadTree/EarthQuadTreeStrategy.d.ts +3 -0
  31. package/types/quadTree/MarsQuadTreeStrategy.d.ts +3 -0
  32. package/types/quadTree/Node.d.ts +0 -1
  33. package/types/quadTree/QuadTreeStrategy.d.ts +21 -0
  34. package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +3 -0
  35. package/types/scene/Planet.d.ts +2 -24
  36. package/types/segment/Segment.d.ts +4 -4
  37. package/types/segment/SegmentLonLat.d.ts +6 -2
  38. package/types/segment/SegmentLonLatWgs84.d.ts +4 -0
  39. package/types/utils/quadTreeType.d.ts +8 -0
@@ -29,24 +29,15 @@ import {
29
29
  WALKTHROUGH
30
30
  } from "./quadTree.js";
31
31
 
32
- let _tempHigh = new Vec3(),
33
- _tempLow = new Vec3();
34
-
35
- const _vertOrder = [
36
- { x: 0, y: 0 },
37
- { x: 1, y: 0 },
38
- { x: 0, y: 1 },
39
- { x: 1, y: 1 }
40
- ];
32
+ import { TILEGROUP_COMMON, TILEGROUP_NORTH, TILEGROUP_SOUTH } from "../segment/Segment.js";
33
+
34
+ let _tempHigh = new Vec3(), _tempLow = new Vec3();
35
+
36
+ const _vertOrder = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }, { x: 1, y: 1 }];
41
37
  const _neGridSize = Math.sqrt(_vertOrder.length) - 1;
42
38
 
43
39
  let BOUNDS = {
44
- xmin: 0.0,
45
- ymin: 0.0,
46
- zmin: 0.0,
47
- xmax: 0.0,
48
- ymax: 0.0,
49
- zmax: 0.0
40
+ xmin: 0.0, ymin: 0.0, zmin: 0.0, xmax: 0.0, ymax: 0.0, zmax: 0.0
50
41
  };
51
42
 
52
43
  /**
@@ -71,7 +62,6 @@ class Node {
71
62
  this.nodeId = partId + id;
72
63
  this.state = null;
73
64
  this.appliedTerrainNodeId = -1;
74
- this.sideSize = [1, 1, 1, 1];
75
65
  this.sideSizeLog2 = [0, 0, 0, 0];
76
66
  this.ready = false;
77
67
  this.neighbors = [[], [], [], []];
@@ -91,8 +81,7 @@ class Node {
91
81
  var ext = ps._extent;
92
82
  var size_x = ext.getWidth() * 0.5;
93
83
  var size_y = ext.getHeight() * 0.5;
94
- var ne = ext.northEast,
95
- sw = ext.southWest;
84
+ var ne = ext.northEast, sw = ext.southWest;
96
85
  var z = ps.tileZoom + 1;
97
86
  var id = this.nodeId * 4 + 1;
98
87
  var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
@@ -115,9 +104,7 @@ class Node {
115
104
  seg.createBoundsByParent();
116
105
  }
117
106
 
118
- let x = seg.bsphere.center.x,
119
- y = seg.bsphere.center.y,
120
- z = seg.bsphere.center.z;
107
+ let x = seg.bsphere.center.x, y = seg.bsphere.center.y, z = seg.bsphere.center.z;
121
108
 
122
109
  let length = 1.0 / Math.sqrt(x * x + y * y + z * z);
123
110
  seg.centerNormal.x = x * length;
@@ -190,8 +177,7 @@ class Node {
190
177
  this.neighbors[2] = [];
191
178
  this.neighbors[3] = [];
192
179
 
193
- let seg = this.segment,
194
- planet = this.planet;
180
+ let seg = this.segment, planet = this.planet;
195
181
 
196
182
  this._cameraInside = false;
197
183
 
@@ -218,8 +204,7 @@ class Node {
218
204
 
219
205
  this.inFrustum = 0;
220
206
 
221
- let frustums = cam.frustums,
222
- numFrustums = frustums.length;
207
+ let frustums = cam.frustums, numFrustums = frustums.length;
223
208
 
224
209
  if (seg.tileZoom < 6) {
225
210
  for (let i = 0; i < numFrustums; i++) {
@@ -250,15 +235,10 @@ class Node {
250
235
  let eye = cam.eye;
251
236
  let horizonDist = eye.length2() - this.planet.ellipsoid._b2;
252
237
 
253
- let altVis = seg.tileZoom > 19 ||
254
- (seg.tileZoom < 4 && !seg.terrainReady) ||
255
- seg.tileZoom < 2;
238
+ let altVis = seg.tileZoom > 19 || (seg.tileZoom < 4 && !seg.terrainReady) || seg.tileZoom < 2;
256
239
 
257
240
  if (h > 21000) {
258
- altVis = altVis || eye.distance2(seg._sw) < horizonDist
259
- || eye.distance2(seg._nw) < horizonDist
260
- || eye.distance2(seg._ne) < horizonDist
261
- || eye.distance2(seg._se) < horizonDist;
241
+ altVis = altVis || eye.distance2(seg._sw) < horizonDist || eye.distance2(seg._nw) < horizonDist || eye.distance2(seg._ne) < horizonDist || eye.distance2(seg._se) < horizonDist;
262
242
  } else {
263
243
  altVis = altVis || cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius < VISIBLE_DISTANCE * Math.sqrt(h);
264
244
  }
@@ -269,9 +249,7 @@ class Node {
269
249
 
270
250
  if (seg.tileZoom < 2 && seg.normalMapReady) {
271
251
  this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
272
- } else if (seg.terrainReady && (
273
- !maxZoom && cam.projectedSize(seg.bsphere.center, seg._plainRadius) < planet._lodSize ||
274
- maxZoom && ((seg.tileZoom === maxZoom) || !altVis))) {
252
+ } else if (seg.terrainReady && (!maxZoom && cam.projectedSize(seg.bsphere.center, seg._plainRadius) < planet._lodSize || maxZoom && ((seg.tileZoom === maxZoom) || !altVis))) {
275
253
 
276
254
  if (altVis) {
277
255
  seg.passReady = true;
@@ -280,10 +258,7 @@ class Node {
280
258
  this.state = NOTRENDERING;
281
259
  }
282
260
 
283
- } else if (
284
- seg.terrainReady &&
285
- seg.tileZoom < planet.terrain._maxNodeZoom &&
286
- (!maxZoom || cam.projectedSize(seg.bsphere.center, seg.bsphere.radius) > this.planet._maxLodSize)) {
261
+ } else if (seg.terrainReady && seg.checkZoom() && (!maxZoom || cam.projectedSize(seg.bsphere.center, seg.bsphere.radius) > this.planet._maxLodSize)) {
287
262
  this.traverseNodes(cam, maxZoom, seg, stopLoading);
288
263
  } else if (altVis) {
289
264
  seg.passReady = maxZoom ? seg.terrainReady : false;
@@ -376,8 +351,7 @@ class Node {
376
351
  var bp = ni.segment;
377
352
  var ld = ap.gridSize / (bp.gridSize * Math.pow(2, bp.tileZoom - ap.tileZoom));
378
353
 
379
- let cs_size = ap.gridSize,
380
- opcs_size = bp.gridSize;
354
+ let cs_size = ap.gridSize, opcs_size = bp.gridSize;
381
355
 
382
356
  if (ld > 1) {
383
357
  cs_size = Math.ceil(ap.gridSize / ld);
@@ -387,9 +361,6 @@ class Node {
387
361
  opcs_size = Math.ceil(bp.gridSize * ld);
388
362
  }
389
363
 
390
- this.sideSize[cs] = cs_size;
391
- ni.sideSize[opcs] = opcs_size;
392
-
393
364
  this.sideSizeLog2[cs] = Math.log2(cs_size);
394
365
  ni.sideSizeLog2[opcs] = Math.log2(opcs_size);
395
366
  }
@@ -406,8 +377,7 @@ class Node {
406
377
  this.planet._terrainCompleted = false;
407
378
  }
408
379
 
409
- let k = 0,
410
- rf = this.planet._renderedNodesInFrustum;
380
+ let k = 0, rf = this.planet._renderedNodesInFrustum;
411
381
  while (inFrustum) {
412
382
  if (inFrustum & 1) {
413
383
  rf[k].push(this);
@@ -418,106 +388,41 @@ class Node {
418
388
  }
419
389
 
420
390
  getCommonSide(node) {
421
- var as = this.segment,
422
- bs = node.segment;
391
+ var as = this.segment, bs = node.segment;
423
392
 
424
393
  if (as.tileZoom === bs.tileZoom && as._tileGroup === bs._tileGroup) {
425
394
  return as.getNeighborSide(bs);
426
395
  } else {
427
- var a = as._extentLonLat,
428
- b = bs._extentLonLat;
429
-
430
- var a_ne = a.northEast,
431
- a_sw = a.southWest,
432
- b_ne = b.northEast,
433
- b_sw = b.southWest;
434
-
435
- var a_ne_lon = a_ne.lon,
436
- a_ne_lat = a_ne.lat,
437
- a_sw_lon = a_sw.lon,
438
- a_sw_lat = a_sw.lat,
439
- b_ne_lon = b_ne.lon,
440
- b_ne_lat = b_ne.lat,
441
- b_sw_lon = b_sw.lon,
442
- b_sw_lat = b_sw.lat;
396
+ var a = as._extentLonLat, b = bs._extentLonLat;
397
+
398
+ var a_ne = a.northEast, a_sw = a.southWest, b_ne = b.northEast, b_sw = b.southWest;
399
+
400
+ var a_ne_lon = a_ne.lon, a_ne_lat = a_ne.lat, a_sw_lon = a_sw.lon, a_sw_lat = a_sw.lat, b_ne_lon = b_ne.lon,
401
+ b_ne_lat = b_ne.lat, b_sw_lon = b_sw.lon, b_sw_lat = b_sw.lat;
443
402
 
444
403
  if (as._tileGroup === bs._tileGroup) {
445
- if (
446
- a_ne_lon === b_sw_lon &&
447
- ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) ||
448
- (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))
449
- ) {
404
+ if (a_ne_lon === b_sw_lon && ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) || (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))) {
450
405
  return E;
451
- } else if (
452
- a_sw_lon === b_ne_lon &&
453
- ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) ||
454
- (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))
455
- ) {
406
+ } else if (a_sw_lon === b_ne_lon && ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) || (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))) {
456
407
  return W;
457
- } else if (
458
- a_ne_lat === b_sw_lat &&
459
- ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) ||
460
- (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))
461
- ) {
408
+ } else if (a_ne_lat === b_sw_lat && ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) || (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))) {
462
409
  return N;
463
- } else if (
464
- a_sw_lat === b_ne_lat &&
465
- ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) ||
466
- (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))
467
- ) {
410
+ } else if (a_sw_lat === b_ne_lat && ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) || (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))) {
468
411
  return S;
469
- } else if (
470
- bs.tileX === 0 &&
471
- as.tileX === Math.pow(2, as.tileZoom) - 1 &&
472
- ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) ||
473
- (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))
474
- ) {
412
+ } else if (bs.tileX === 0 && as.tileX === Math.pow(2, as.tileZoom) - 1 && ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) || (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))) {
475
413
  return E;
476
- } else if (
477
- as.tileX === 0 &&
478
- bs.tileX === Math.pow(2, bs.tileZoom) - 1 &&
479
- ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) ||
480
- (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))
481
- ) {
414
+ } else if (as.tileX === 0 && bs.tileX === Math.pow(2, bs.tileZoom) - 1 && ((a_ne_lat <= b_ne_lat && a_sw_lat >= b_sw_lat) || (a_ne_lat >= b_ne_lat && a_sw_lat <= b_sw_lat))) {
482
415
  return W;
483
416
  }
484
417
  }
485
418
 
486
- if (
487
- as._tileGroup === 0 &&
488
- bs._tileGroup === 1 &&
489
- as.tileY === 0 &&
490
- bs.tileY === Math.pow(2, bs.tileZoom) - 1 &&
491
- ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) ||
492
- (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))
493
- ) {
419
+ if (as._tileGroup === TILEGROUP_COMMON && bs._tileGroup === TILEGROUP_NORTH && as.tileY === 0 && bs.tileY === Math.pow(2, bs.tileZoom) - 1 && ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) || (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))) {
494
420
  return N;
495
- } else if (
496
- as._tileGroup === 2 &&
497
- bs._tileGroup === 0 &&
498
- as.tileY === 0 &&
499
- bs.tileY === Math.pow(2, bs.tileZoom) - 1 &&
500
- ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) ||
501
- (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))
502
- ) {
421
+ } else if (as._tileGroup === TILEGROUP_SOUTH && bs._tileGroup === TILEGROUP_COMMON && as.tileY === 0 && bs.tileY === Math.pow(2, bs.tileZoom) - 1 && ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) || (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))) {
503
422
  return N;
504
- } else if (
505
- bs._tileGroup === 1 &&
506
- as._tileGroup === 0 &&
507
- as.tileY === Math.pow(2, as.tileZoom) - 1 &&
508
- bs.tileY === 0 &&
509
- ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) ||
510
- (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))
511
- ) {
423
+ } else if (bs._tileGroup === TILEGROUP_NORTH && as._tileGroup === TILEGROUP_COMMON && as.tileY === Math.pow(2, as.tileZoom) - 1 && bs.tileY === 0 && ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) || (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))) {
512
424
  return S;
513
- } else if (
514
- as._tileGroup === 1 &&
515
- bs._tileGroup === 0 &&
516
- as.tileY === Math.pow(2, as.tileZoom) - 1 &&
517
- bs.tileY === 0 &&
518
- ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) ||
519
- (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))
520
- ) {
425
+ } else if (as._tileGroup === TILEGROUP_NORTH && bs._tileGroup === TILEGROUP_COMMON && as.tileY === Math.pow(2, as.tileZoom) - 1 && bs.tileY === 0 && ((a_sw_lon >= b_sw_lon && a_ne_lon <= b_ne_lon) || (a_sw_lon <= b_sw_lon && a_ne_lon >= b_ne_lon))) {
521
426
  return S;
522
427
  }
523
428
  }
@@ -527,16 +432,12 @@ class Node {
527
432
 
528
433
  // TODO: test test test
529
434
  ___getCommonSide___(b) {
530
- var a = this,
531
- as = a.segment,
532
- bs = b.segment;
435
+ var a = this, as = a.segment, bs = b.segment;
533
436
 
534
437
  if (as.tileZoom === bs.tileZoom) {
535
438
  return as.getNeighborSide(bs);
536
439
  } else if (as.tileZoom > bs.tileZoom) {
537
- let dz = as.tileZoom - bs.tileZoom,
538
- i = dz,
539
- p = this;
440
+ let dz = as.tileZoom - bs.tileZoom, i = dz, p = this;
540
441
 
541
442
  while (i--) {
542
443
  p = p.parentNode;
@@ -558,9 +459,7 @@ class Node {
558
459
  }
559
460
  }
560
461
  } else {
561
- let dz = bs.tileZoom - as.tileZoom,
562
- i = dz,
563
- p = b;
462
+ let dz = bs.tileZoom - as.tileZoom, i = dz, p = b;
564
463
 
565
464
  while (i--) {
566
465
  p = p.parentNode;
@@ -629,8 +528,7 @@ class Node {
629
528
  }
630
529
 
631
530
  if (pn.segment.terrainReady && this.appliedTerrainNodeId !== pn.nodeId) {
632
- let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1),
633
- offsetX = seg.tileX - pn.segment.tileX * dZ2,
531
+ let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1), offsetX = seg.tileX - pn.segment.tileX * dZ2,
634
532
  offsetY = seg.tileY - pn.segment.tileY * dZ2;
635
533
 
636
534
  let pseg = pn.segment;
@@ -638,12 +536,10 @@ class Node {
638
536
  let tempVertices, tempVerticesHigh, tempVerticesLow, noDataVertices;
639
537
 
640
538
  this.appliedTerrainNodeId = pn.nodeId;
641
- this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] =
642
- this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
539
+ this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] = this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
643
540
 
644
541
 
645
- let gridSize = pn.segment.gridSize / dZ2,
646
- gridSizeExt = pn.segment.fileGridSize / dZ2;
542
+ let gridSize = pn.segment.gridSize / dZ2, gridSizeExt = pn.segment.fileGridSize / dZ2;
647
543
 
648
544
  BOUNDS.xmin = MAX;
649
545
  BOUNDS.xmax = MIN;
@@ -664,21 +560,7 @@ class Node {
664
560
  noDataVertices = new Uint8Array(len / 3);
665
561
  }
666
562
 
667
- getMatrixSubArrayBoundsExt(
668
- pseg.terrainVertices,
669
- pseg.terrainVerticesHigh,
670
- pseg.terrainVerticesLow,
671
- pseg.noDataVertices,
672
- pseg.gridSize,
673
- gridSize * offsetY,
674
- gridSize * offsetX,
675
- gridSize,
676
- tempVertices,
677
- tempVerticesHigh,
678
- tempVerticesLow,
679
- BOUNDS,
680
- noDataVertices
681
- );
563
+ getMatrixSubArrayBoundsExt(pseg.terrainVertices, pseg.terrainVerticesHigh, pseg.terrainVerticesLow, pseg.noDataVertices, pseg.gridSize, gridSize * offsetY, gridSize * offsetX, gridSize, tempVertices, tempVerticesHigh, tempVerticesLow, BOUNDS, noDataVertices);
682
564
  } else if (gridSizeExt >= 1) {
683
565
  seg.gridSize = gridSizeExt;
684
566
 
@@ -691,26 +573,11 @@ class Node {
691
573
  noDataVertices = new Uint8Array(len / 3);
692
574
  }
693
575
 
694
- getMatrixSubArrayBoundsExt(
695
- pseg.normalMapVertices,
696
- pseg.normalMapVerticesHigh,
697
- pseg.normalMapVerticesLow,
698
- pseg.noDataVertices,
699
- pn.segment.fileGridSize,
700
- gridSizeExt * offsetY,
701
- gridSizeExt * offsetX,
702
- gridSizeExt,
703
- tempVertices,
704
- tempVerticesHigh,
705
- tempVerticesLow,
706
- BOUNDS,
707
- noDataVertices
708
- );
576
+ getMatrixSubArrayBoundsExt(pseg.normalMapVertices, pseg.normalMapVerticesHigh, pseg.normalMapVerticesLow, pseg.noDataVertices, pn.segment.fileGridSize, gridSizeExt * offsetY, gridSizeExt * offsetX, gridSizeExt, tempVertices, tempVerticesHigh, tempVerticesLow, BOUNDS, noDataVertices);
709
577
  } else {
710
578
  seg.gridSize = _neGridSize;
711
579
 
712
- let i0 = Math.floor(gridSize * offsetY),
713
- j0 = Math.floor(gridSize * offsetX);
580
+ let i0 = Math.floor(gridSize * offsetY), j0 = Math.floor(gridSize * offsetX);
714
581
 
715
582
  let bigOne;
716
583
  if (pseg.gridSize === 1) {
@@ -721,24 +588,15 @@ class Node {
721
588
 
722
589
  let insideSize = 1.0 / gridSize;
723
590
 
724
- let t_i0 = offsetY - insideSize * i0,
725
- t_j0 = offsetX - insideSize * j0;
591
+ let t_i0 = offsetY - insideSize * i0, t_j0 = offsetX - insideSize * j0;
726
592
 
727
593
  let v_lt = new Vec3(bigOne[0], bigOne[1], bigOne[2]),
728
594
  v_rb = new Vec3(bigOne[9], bigOne[10], bigOne[11]);
729
595
 
730
596
  let vn = new Vec3(bigOne[3] - bigOne[0], bigOne[4] - bigOne[1], bigOne[5] - bigOne[2]),
731
597
  vw = new Vec3(bigOne[6] - bigOne[0], bigOne[7] - bigOne[1], bigOne[8] - bigOne[2]),
732
- ve = new Vec3(
733
- bigOne[3] - bigOne[9],
734
- bigOne[4] - bigOne[10],
735
- bigOne[5] - bigOne[11]
736
- ),
737
- vs = new Vec3(
738
- bigOne[6] - bigOne[9],
739
- bigOne[7] - bigOne[10],
740
- bigOne[8] - bigOne[11]
741
- );
598
+ ve = new Vec3(bigOne[3] - bigOne[9], bigOne[4] - bigOne[10], bigOne[5] - bigOne[11]),
599
+ vs = new Vec3(bigOne[6] - bigOne[9], bigOne[7] - bigOne[10], bigOne[8] - bigOne[11]);
742
600
 
743
601
  let coords = new Vec3();
744
602
 
@@ -747,11 +605,9 @@ class Node {
747
605
  tempVerticesLow = new Float32Array(3 * _vertOrder.length);
748
606
 
749
607
  for (var i = 0; i < _vertOrder.length; i++) {
750
- let vi_y = _vertOrder[i].y + t_i0,
751
- vi_x = _vertOrder[i].x + t_j0;
608
+ let vi_y = _vertOrder[i].y + t_i0, vi_x = _vertOrder[i].x + t_j0;
752
609
 
753
- let vi_x_is = vi_x * gridSize,
754
- vi_y_is = vi_y * gridSize;
610
+ let vi_x_is = vi_x * gridSize, vi_y_is = vi_y * gridSize;
755
611
 
756
612
  if (vi_y + vi_x < insideSize) {
757
613
  coords = vn.scaleTo(vi_x_is).addA(vw.scaleTo(vi_y_is)).addA(v_lt);
@@ -799,14 +655,7 @@ class Node {
799
655
 
800
656
  seg.noDataVertices = noDataVertices;
801
657
 
802
- seg.setBoundingVolume(
803
- BOUNDS.xmin,
804
- BOUNDS.ymin,
805
- BOUNDS.zmin,
806
- BOUNDS.xmax,
807
- BOUNDS.ymax,
808
- BOUNDS.zmax
809
- );
658
+ seg.setBoundingVolume(BOUNDS.xmin, BOUNDS.ymin, BOUNDS.zmin, BOUNDS.xmax, BOUNDS.ymax, BOUNDS.zmax);
810
659
 
811
660
  if (seg.tileZoom > terrain.maxZoom) {
812
661
  if (pn.segment.tileZoom >= terrain.maxZoom) {
@@ -821,25 +670,17 @@ class Node {
821
670
  seg.terrainVerticesLow = tempVerticesLow;
822
671
 
823
672
  this.appliedTerrainNodeId = this.nodeId;
824
- this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] =
825
- this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
673
+ this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] = this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
826
674
 
827
675
  if (pn.segment.terrainExists) {
828
676
  seg.terrainExists = true;
829
677
  seg.normalMapVertices = tempVertices;
830
678
  seg.fileGridSize = Math.sqrt(tempVertices.length / 3) - 1;
831
679
 
832
- let fgs = Math.sqrt(pseg.normalMapNormals.length / 3) - 1,
833
- fgsZ = fgs / dZ2;
680
+ let fgs = Math.sqrt(pseg.normalMapNormals.length / 3) - 1, fgsZ = fgs / dZ2;
834
681
 
835
682
  if (fgs > 1) {
836
- seg.normalMapNormals = getMatrixSubArray(
837
- pseg.normalMapNormals,
838
- fgs,
839
- fgsZ * offsetY,
840
- fgsZ * offsetX,
841
- fgsZ
842
- );
683
+ seg.normalMapNormals = getMatrixSubArray(pseg.normalMapNormals, fgs, fgsZ * offsetY, fgsZ * offsetX, fgsZ);
843
684
  } else {
844
685
  // TODO: interpolation
845
686
  seg.normalMapNormals = pseg.normalMapNormals;
@@ -879,7 +720,6 @@ class Node {
879
720
  n[W] && n[W].neighbors && (n[W].neighbors[E] = []);
880
721
  this.neighbors = null;
881
722
  this.parentNode = null;
882
- this.sideSize = null;
883
723
  this.sideSizeLog2 = null;
884
724
  this.segment = null;
885
725
  }
@@ -905,8 +745,7 @@ class Node {
905
745
 
906
746
  destroyBranches() {
907
747
  if (this.ready) {
908
- var nodesToRemove = [],
909
- i;
748
+ var nodesToRemove = [], i;
910
749
 
911
750
  for (i = 0; i < this.nodes.length; i++) {
912
751
  nodesToRemove[i] = this.nodes[i];
@@ -936,9 +775,7 @@ class Node {
936
775
  }
937
776
 
938
777
  getOffsetOppositeNeighbourSide(neighbourNode, side) {
939
- let pNode = this,
940
- neighbourZoom = neighbourNode.segment.tileZoom,
941
- offset = 0;
778
+ let pNode = this, neighbourZoom = neighbourNode.segment.tileZoom, offset = 0;
942
779
 
943
780
  while (pNode.segment.tileZoom > neighbourZoom) {
944
781
  offset += PARTOFFSET[pNode.partId][side] / (1 << (pNode.segment.tileZoom - neighbourZoom));
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ import { EPSG3857 } from "../proj/EPSG3857.js";
3
+
4
+ export class QuadTreeStrategy {
5
+ constructor(options = {}) {
6
+ this.name = "";
7
+ this._planet = options.planet;
8
+ this.projection = EPSG3857;
9
+
10
+ /**
11
+ * grid tree list.
12
+ * @protected
13
+ * @type {quadTree.Node[]}
14
+ */
15
+ this._quadTreeList = [];
16
+ }
17
+
18
+ destroyBranches() {
19
+ for (let i = 0, len = this._quadTreeList.length; i < len; i++) {
20
+ this._quadTreeList[i].destroyBranches();
21
+ }
22
+ }
23
+
24
+ clearLayerMaterial(layer) {
25
+ let lid = layer._id;
26
+ for (let i = 0, len = this._quadTreeList.length; i < len; i++) {
27
+ this._quadTreeList[i].traverseTree(function (node) {
28
+ let mats = node.segment.materials;
29
+ if (mats[lid]) {
30
+ mats[lid].clear();
31
+ mats[lid] = null;
32
+ delete mats[lid];
33
+ }
34
+ });
35
+ }
36
+ }
37
+
38
+ get planet() {
39
+ return this._planet;
40
+ }
41
+
42
+ init() {
43
+
44
+ }
45
+
46
+ preRender() {
47
+ for (let i = 0; i < this._quadTreeList.length; i++) {
48
+
49
+ let quadTree = this._quadTreeList[i];
50
+ quadTree.createChildrenNodes();
51
+ quadTree.segment.createPlainSegment();
52
+
53
+ for (let j = 0; j < quadTree.nodes.length; j++) {
54
+ quadTree.nodes[j].segment.createPlainSegment();
55
+ }
56
+ }
57
+
58
+ }
59
+
60
+ preLoad() {
61
+
62
+ for (let i = 0; i < this._quadTreeList.length; i++) {
63
+
64
+ let quadTree = this._quadTreeList[i];
65
+ quadTree.segment.passReady = true;
66
+ quadTree.renderNode(true);
67
+ this._planet.normalMapCreator.drawSingle(quadTree.segment);
68
+
69
+ for (let j = 0; j < quadTree.nodes.length; j++) {
70
+ quadTree.nodes[j].segment.passReady = true;
71
+ quadTree.nodes[j].renderNode(true);
72
+ this._planet._normalMapCreator.drawSingle(quadTree.nodes[j].segment);
73
+ }
74
+ }
75
+ }
76
+
77
+ collectRenderNodes() {
78
+ for (let i = 0; i < this._quadTreeList.length; i++) {
79
+ this._quadTreeList[i].renderTree(this._planet.camera, 0, null);
80
+ }
81
+ }
82
+
83
+ clear() {
84
+ for (let i = 0; i < this._quadTreeList.length; i++) {
85
+ this._quadTreeList[i].clearTree();
86
+ }
87
+ }
88
+
89
+ get quadTreeList() {
90
+ return this._quadTreeList;
91
+ }
92
+
93
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ import { QuadTreeStrategy } from "./QuadTreeStrategy.js"
3
+ import { SegmentLonLatWgs84 } from "../segment/SegmentLonLatWgs84.js";
4
+ import * as quadTree from "../quadTree/quadTree.js";
5
+ import { Extent } from "../Extent.js";
6
+ import { Node } from "../quadTree/Node.js";
7
+ import { EPSG4326 } from "../proj/EPSG4326.js";
8
+
9
+ export class Wgs84QuadTreeStrategy extends QuadTreeStrategy {
10
+ constructor(options = {}) {
11
+ super(options);
12
+ this.name = "wgs84";
13
+ this.projection = EPSG4326;
14
+ }
15
+
16
+ init() {
17
+
18
+ let wgs84QuadTree = new Node(SegmentLonLatWgs84, this.planet, quadTree.NW, null, 0, 0,
19
+ Extent.createFromArray([-180, -90, 180, 90])
20
+ );
21
+
22
+
23
+
24
+ this._quadTreeList.push(wgs84QuadTree);
25
+ }
26
+ }