@openglobus/og 0.10.2 → 0.10.5

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.
@@ -32,8 +32,7 @@ import {
32
32
 
33
33
  import { MAX_NORMAL_ZOOM } from "../segment/Segment.js";
34
34
 
35
- const DOT_VIS = 0.3;
36
- const VISIBLE_HEIGHT = 3000000.0;
35
+ const VISIBLE_HEIGHT = 1400000.0;
37
36
 
38
37
  let _tempHigh = new Vec3(),
39
38
  _tempLow = new Vec3();
@@ -255,7 +254,7 @@ Node.prototype.renderTree = function (cam, maxZoom, terrainReadySegment, stopLoa
255
254
  }
256
255
  }
257
256
  } else {
258
- let commonFrustumFlag = 1 << (numFrustums - 1 - 1); //Math.pow(2, numFrustums - 1) - 1;
257
+ let commonFrustumFlag = 1 << (numFrustums - 1 - 1);
259
258
  for (let i = 0; commonFrustumFlag && i < numFrustums; i++) {
260
259
  if (seg.terrainReady) {
261
260
  if (frustums[i].containsBox(seg.bbox)) {
@@ -332,12 +331,13 @@ Node.prototype.prepareForRendering = function (
332
331
  } else {
333
332
  if (seg.tileZoom < 2) {
334
333
  this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
334
+ } else if (seg.tileZoom > MAX_NORMAL_ZOOM) {
335
+ this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
335
336
  } else if (
336
- seg.tileZoom < MAX_NORMAL_ZOOM &&
337
- (seg._swNorm.dot(cam.eyeNorm) > DOT_VIS ||
338
- seg._nwNorm.dot(cam.eyeNorm) > DOT_VIS ||
339
- seg._neNorm.dot(cam.eyeNorm) > DOT_VIS ||
340
- seg._seNorm.dot(cam.eyeNorm) > DOT_VIS)
337
+ seg._swNorm.dot(cam._n) > 0.0 ||
338
+ seg._nwNorm.dot(cam._n) > 0.0 ||
339
+ seg._neNorm.dot(cam._n) > 0.0 ||
340
+ seg._seNorm.dot(cam._n) > 0.0
341
341
  ) {
342
342
  this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
343
343
  } else {
@@ -1,7 +1,7 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  export const VISIBLE_DISTANCE = 3570.0;
4
- export const MAX_RENDERED_NODES = 500;
4
+ export const MAX_RENDERED_NODES = 700;
5
5
 
6
6
  export const NW = 0;
7
7
  export const NE = 1;
@@ -25,40 +25,44 @@ export const OPSIDE = [S, W, N, E];
25
25
  /**
26
26
  * First index is {N,E,S,W} and second is {NW,NE,SW,SE}
27
27
  */
28
- export const NEIGHBOUR =
29
- [[-1, -1, NW, NE],
28
+ export const NEIGHBOUR = [
29
+ [-1, -1, NW, NE],
30
30
  [NE, -1, SE, -1],
31
31
  [SW, SE, -1, -1],
32
- [-1, NW, -1, SW]];
32
+ [-1, NW, -1, SW]
33
+ ];
33
34
 
34
35
  /**
35
36
  * Neighbor's oposite part. For example oposite side
36
37
  * on the east neighbor side is: [S][SE] = NE
37
38
  */
38
- export const OPPART =
39
- [[SW, SE, NW, NE],
39
+ export const OPPART = [
40
+ [SW, SE, NW, NE],
40
41
  [NE, NW, SE, SW],
41
42
  [SW, SE, NW, NE],
42
- [NE, NW, SE, SW]];
43
+ [NE, NW, SE, SW]
44
+ ];
43
45
 
44
46
  /**
45
47
  * Neighbos's opside array order. For example NW node
46
48
  * by E side array index is 0, SE node by S side is 1.
47
49
  */
48
- export const NOPSORD =
49
- [[0, 1, 0, 1],
50
+ export const NOPSORD = [
51
+ [0, 1, 0, 1],
50
52
  [0, 0, 1, 1],
51
53
  [0, 1, 0, 1],
52
- [0, 0, 1, 1]];
54
+ [0, 0, 1, 1]
55
+ ];
53
56
 
54
57
  /**
55
58
  * First index is {NW,NE,SW,SE}, another one is {N,E,S,W}
56
59
  */
57
- export const COMSIDE =
58
- [[true, false, false, true],
60
+ export const COMSIDE = [
61
+ [true, false, false, true],
59
62
  [true, true, false, false],
60
63
  [false, false, true, true],
61
- [false, true, true, false]];
64
+ [false, true, true, false]
65
+ ];
62
66
 
63
67
  /**
64
68
  * Gets segment part left to right or up to downo ffset against neighbour side.
@@ -66,8 +70,8 @@ export const COMSIDE =
66
70
  */
67
71
  export const PARTOFFSET = [
68
72
  /* N E S W */
69
- /*NW*/[0, 1, 0, 0],
70
- /*NE*/[1, 0, 0, 0],
71
- /*SW*/[0, 1, 0, 1],
72
- /*SE*/[1, 1, 1, 1]
73
+ /*NW*/ [0, 1, 0, 0],
74
+ /*NE*/ [1, 0, 0, 0],
75
+ /*SW*/ [0, 1, 0, 1],
76
+ /*SE*/ [1, 1, 1, 1]
73
77
  ];
@@ -301,33 +301,38 @@ class RendererEvents extends Events {
301
301
  }
302
302
 
303
303
  /**
304
- * @private
304
+ * @protected
305
305
  */
306
- onMouseMove(event, sys) {
307
- let b = sys.buttons;
308
-
309
- if (b & LB_M) {
310
- this.mouseState.leftButtonDown = true;
306
+ updateButtonsStates(buttons) {
307
+ var ms = this.mouseState;
308
+ if (buttons & LB_M) {
309
+ ms.leftButtonDown = true;
311
310
  } else {
312
- this.mouseState.leftButtonHold = false;
313
- this.mouseState.leftButtonDown = false;
311
+ ms.leftButtonHold = false;
312
+ ms.leftButtonDown = false;
314
313
  }
315
314
 
316
- if (b & RB_M) {
317
- this.mouseState.rightButtonDown = true;
315
+ if (buttons & RB_M) {
316
+ ms.rightButtonDown = true;
318
317
  } else {
319
- this.mouseState.rightButtonHold = false;
320
- this.mouseState.rightButtonDown = false;
318
+ ms.rightButtonHold = false;
319
+ ms.rightButtonDown = false;
321
320
  }
322
321
 
323
- if (b & MB_M) {
324
- this.mouseState.middleButtonDown = true;
322
+ if (buttons & MB_M) {
323
+ ms.middleButtonDown = true;
325
324
  } else {
326
- this.mouseState.middleButtonHold = false;
327
- this.mouseState.middleButtonDown = false;
325
+ ms.middleButtonHold = false;
326
+ ms.middleButtonDown = false;
328
327
  }
328
+ }
329
329
 
330
+ /**
331
+ * @private
332
+ */
333
+ onMouseMove(event, sys) {
330
334
  var ms = this.mouseState;
335
+ this.updateButtonsStates(sys.buttons)
331
336
  ms.sys = event;
332
337
 
333
338
  let ex = event.clientX,
@@ -24,7 +24,7 @@ import { PlanetCamera } from "../camera/PlanetCamera.js";
24
24
  import { RenderNode } from "./RenderNode.js";
25
25
  import { Segment } from "../segment/Segment.js";
26
26
  import { SegmentLonLat } from "../segment/SegmentLonLat.js";
27
- import { PlainSegmentWorker } from "../segment/PlainSegmentWorker.js";
27
+ import { PlainSegmentWorker } from "../utils/PlainSegmentWorker.js";
28
28
  import { TerrainWorker } from "../utils/TerrainWorker.js";
29
29
  import { VectorTileCreator } from "../utils/VectorTileCreator.js";
30
30
  import { wgs84 } from "../ellipsoid/wgs84.js";
@@ -174,6 +174,9 @@ class Planet extends RenderNode {
174
174
  */
175
175
  this.camera = null;
176
176
 
177
+ this._minAltitude = options.minAltitude;
178
+ this._maxAltitude = options.maxAltitude;
179
+
177
180
  /**
178
181
  * Screen mouse pointer projected to planet cartesian position.
179
182
  * @public
@@ -699,7 +702,9 @@ class Planet extends RenderNode {
699
702
  this.camera = this.renderer.activeCamera = new PlanetCamera(this, {
700
703
  eye: new Vec3(0, 0, 28000000),
701
704
  look: new Vec3(0, 0, 0),
702
- up: new Vec3(0, 1, 0)
705
+ up: new Vec3(0, 1, 0),
706
+ minAltitude: this._minAltitude,
707
+ maxAltitude: this._maxAltitude
703
708
  });
704
709
 
705
710
  this.camera.update();
@@ -800,11 +805,11 @@ class Planet extends RenderNode {
800
805
  this._quadTree.renderNode();
801
806
  this._normalMapCreator.drawSingle(this._quadTree.segment);
802
807
 
803
- for (var i = 0; i < this._quadTree.nodes.length; i++) {
804
- this._quadTree.nodes[i].segment.createPlainSegment();
805
- this._quadTree.nodes[i].renderNode(true);
806
- this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment);
807
- }
808
+ //for (var i = 0; i < this._quadTree.nodes.length; i++) {
809
+ // this._quadTree.nodes[i].segment.createPlainSegment();
810
+ // this._quadTree.nodes[i].renderNode(true);
811
+ // this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment);
812
+ //}
808
813
 
809
814
  this._quadTreeNorth.createChildrenNodes();
810
815
  this._quadTreeNorth.segment.createPlainSegment();
@@ -31,8 +31,6 @@ var _RenderingSlice = function (p) {
31
31
  };
32
32
  };
33
33
 
34
- //const BSPHERERADIUSEXT = 2;
35
-
36
34
  /**
37
35
  * Planet segment Web Mercator tile class that stored and rendered with quad tree.
38
36
  * @class
@@ -1002,7 +1000,7 @@ Segment.prototype.createBoundsByExtent = function () {
1002
1000
  var coord_ne = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.northEast.lat);
1003
1001
 
1004
1002
  // check for zoom
1005
- if (this.tileZoom < MAX_NORMAL_ZOOM) {
1003
+ if (this.tileZoom <= MAX_NORMAL_ZOOM) {
1006
1004
  var coord_nw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.northEast.lat);
1007
1005
  var coord_se = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.southWest.lat);
1008
1006
 
@@ -1039,7 +1037,7 @@ Segment.prototype.createBoundsByParent = function () {
1039
1037
  this.bsphere.center.z = pn.segment.bsphere.center.z;
1040
1038
  this.bsphere.radius = pn.segment.bsphere.radius;
1041
1039
 
1042
- if (this.tileZoom < MAX_NORMAL_ZOOM) {
1040
+ if (this.tileZoom <= MAX_NORMAL_ZOOM) {
1043
1041
  let i0 = gridSize * offsetY;
1044
1042
  let j0 = gridSize * offsetX;
1045
1043
 
@@ -188,6 +188,7 @@ class FontAtlas {
188
188
  };
189
189
 
190
190
  img.src = `${srcDir}/${data.pages[0]}`;
191
+ img.crossOrigin = "Anonymous";
191
192
  })
192
193
  .catch(err => {
193
194
  def.reject();