@openglobus/og 0.22.0 → 0.22.2

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/lib/js/Globe.js CHANGED
@@ -123,7 +123,8 @@ class Globe {
123
123
  context: {
124
124
  //alpha: false,
125
125
  antialias: false,
126
- premultipliedAlpha: false
126
+ premultipliedAlpha: false,
127
+ preserveDrawingBuffer: false
127
128
  }
128
129
  }), {
129
130
  autoActivate: false,
@@ -143,8 +144,8 @@ class Globe {
143
144
  frustums: options.frustums,
144
145
  ellipsoid: options.ellipsoid,
145
146
  maxGridSize: options.maxGridSize,
146
- nightTextureSrc: options.nightTextureSrc === null ? null : `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_NIGHT_SRC}`,
147
- specularTextureSrc: options.specularTextureSrc === null ? null : `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_SPEC_SRC}`,
147
+ nightTextureSrc: options.nightTextureSrc === null ? null : options.nightTextureSrc || `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_NIGHT_SRC}`,
148
+ specularTextureSrc: options.specularTextureSrc === null ? null : options.specularTextureSrc || `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_SPEC_SRC}`,
148
149
  minAltitude: options.minAltitude,
149
150
  maxAltitude: options.maxAltitude || 15000000,
150
151
  maxEqualZoomAltitude: options.maxEqualZoomAltitude,
@@ -189,5 +189,6 @@ declare class Ellipsoid {
189
189
  */
190
190
  static getIntermediatePointOnGreatCircle(lonLat1: LonLat, lonLat2: LonLat, fraction: number): LonLat;
191
191
  static getRhumbBearing(lonLat1: LonLat, lonLat2: LonLat): number;
192
+ getLonLatVisibilitySimple(eye: Vec3, lonLat: LonLat, forward?: Vec3): boolean;
192
193
  }
193
194
  export { Ellipsoid };
@@ -439,5 +439,21 @@ class Ellipsoid {
439
439
  }
440
440
  return (Math.atan2(dLon, dPhi) * DEGREES + 360) % 360;
441
441
  }
442
+ getLonLatVisibilitySimple(eye, lonLat, forward) {
443
+ const cart = this.lonLatToCartesian(lonLat);
444
+ const height = lonLat.height;
445
+ const f = this.polarSize + height;
446
+ const g = Math.max(eye.length() - this.polarSize, 0);
447
+ const look = cart.sub(eye);
448
+ let maxVisibleDistance;
449
+ if (g > 0) {
450
+ maxVisibleDistance = Math.sqrt((f + g) ** 2 - f ** 2);
451
+ }
452
+ else {
453
+ maxVisibleDistance = f;
454
+ }
455
+ return maxVisibleDistance > look.length() &&
456
+ (!forward || forward.dot(look.normalize()) > 0.0);
457
+ }
442
458
  }
443
459
  export { Ellipsoid };
@@ -67,16 +67,6 @@ class CanvasTiles extends Layer {
67
67
  * @public
68
68
  */
69
69
  abortLoading() {
70
- //const q = this._pendingsQueue;
71
- // for (let i = q._shiftIndex + 1; i < q._popIndex + 1; i++) {
72
- // if (q._array[i]) {
73
- // this.abortMaterialLoading(q._array[i]);
74
- // }
75
- // }
76
- // this._pendingsQueue.clear();
77
- // for (let i = 0; i < q.length; i++) {
78
- // this.abortMaterialLoading(q[i]);
79
- // }
80
70
  this._pendingsQueue.forEach((qi) => {
81
71
  this.abortMaterialLoading(qi);
82
72
  });
@@ -104,7 +94,7 @@ class CanvasTiles extends Layer {
104
94
  loadMaterial(material) {
105
95
  let seg = material.segment;
106
96
  if (this._isBaseLayer) {
107
- material.texture = seg._isNorth ? seg.planet.solidTextureOne : seg.planet.solidTextureTwo;
97
+ material.texture = seg.getDefaultTexture();
108
98
  }
109
99
  else {
110
100
  material.texture = seg.planet.transparentTexture;
@@ -75,7 +75,7 @@ class Layer {
75
75
  this._fading = options.fading || false;
76
76
  this._fadingFactor = this._opacity / FADING_RATIO;
77
77
  if (this._fading) {
78
- this._fadingOpacity = this._visibility ? this._opacity : 0.0;
78
+ this._fadingOpacity = 0;
79
79
  }
80
80
  else {
81
81
  this._fadingOpacity = this._opacity;
@@ -581,29 +581,7 @@ class Layer {
581
581
  return new Material(segment, this);
582
582
  }
583
583
  redraw() {
584
- if (this._planet) {
585
- this._planet.quadTreeStrategy.clearLayerMaterial(this);
586
- // this._planet._quadTree.traverseTree((n: Node) => {
587
- // if (n.segment.materials[this.__id]) {
588
- // n.segment.materials[this.__id].clear();
589
- // }
590
- // }
591
- // );
592
- //
593
- // this._planet._quadTreeNorth.traverseTree((n: Node) => {
594
- // if (n.segment.materials[this.__id]) {
595
- // n.segment.materials[this.__id].clear();
596
- // }
597
- // }
598
- // );
599
- //
600
- // this._planet._quadTreeSouth.traverseTree((n: Node) => {
601
- // if (n.segment.materials[this.__id]) {
602
- // n.segment.materials[this.__id].clear();
603
- // }
604
- // }
605
- // );
606
- }
584
+ this._planet?.quadTreeStrategy.clearLayerMaterial(this);
607
585
  }
608
586
  abortMaterialLoading(material) {
609
587
  }
@@ -4,6 +4,7 @@ import { EntityCollection } from "../entity/EntityCollection";
4
4
  import { GeometryHandler } from "../entity/GeometryHandler";
5
5
  import { Layer } from "./Layer";
6
6
  import { Vec3 } from "../math/Vec3";
7
+ import * as mercator from "../mercator";
7
8
  /**
8
9
  * Creates entity instance array.
9
10
  * @param {Entity[] | IEntityParams[]} entities - Entity array.
@@ -216,6 +217,13 @@ class Vector extends Layer {
216
217
  }
217
218
  else {
218
219
  entity._lonLat = this._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
220
+ // IT's important event for degrees proj strategies
221
+ if (Math.abs(entity._lonLat.lat) < mercator.MAX_LAT) {
222
+ entity._lonLatMerc = entity._lonLat.forwardMercator();
223
+ }
224
+ else {
225
+ entity._lonLatMerc.lon = entity._lonLatMerc.lat = entity._lonLatMerc.height = 0;
226
+ }
219
227
  }
220
228
  }
221
229
  if (entity.billboard || entity.label) {
@@ -612,7 +620,9 @@ class Vector extends Layer {
612
620
  this._collectStripCollectionPASS(outArr);
613
621
  this._collectPolylineCollectionPASS(outArr);
614
622
  this._collectGeoObjectCollectionPASS(outArr);
615
- this._entityCollectionsTreeStrategy.collectVisibleEntityCollections(outArr);
623
+ if (this._entityCollectionsTreeStrategy) {
624
+ this._entityCollectionsTreeStrategy.collectVisibleEntityCollections(outArr);
625
+ }
616
626
  }
617
627
  }
618
628
  /**
@@ -142,9 +142,7 @@ export class XYZ extends Layer {
142
142
  material.textureNotExists();
143
143
  }
144
144
  }
145
- }
146
- //,this.__id
147
- );
145
+ });
148
146
  }
149
147
  else {
150
148
  material.textureNotExists();
@@ -277,12 +275,14 @@ export class XYZ extends Layer {
277
275
  if (e.southWest.lon === -180.0) {
278
276
  em.southWest.lon = -ENLARGE_MERCATOR_LON;
279
277
  }
280
- if (e.northEast.lat >= mercator.MAX_LAT) {
281
- e.northEast.lat = mercator.MAX_LAT;
282
- }
283
- if (e.northEast.lat <= mercator.MIN_LAT) {
284
- e.northEast.lat = mercator.MIN_LAT;
285
- }
278
+ // WHY!???
279
+ // if (e.northEast.lat >= mercator.MAX_LAT) {
280
+ // e.northEast.lat = mercator.MAX_LAT;
281
+ // }
282
+ //
283
+ // if (e.northEast.lat <= mercator.MIN_LAT) {
284
+ // e.northEast.lat = mercator.MIN_LAT;
285
+ // }
286
286
  }
287
287
  }
288
288
  const XYZ_EVENTS = [
@@ -292,6 +292,7 @@ declare class Renderer {
292
292
  * @public
293
293
  */
294
294
  draw(): void;
295
+ getImageDataURL(type?: string, quality?: number): string;
295
296
  protected _screenFrameMSAA(): void;
296
297
  protected _screenFrameNoMSAA(): void;
297
298
  /**
@@ -764,6 +764,10 @@ class Renderer {
764
764
  e.mouseState.moving = false;
765
765
  e.touchState.moving = false;
766
766
  }
767
+ getImageDataURL(type = "image/png", quality = 1.0) {
768
+ this.draw();
769
+ return this.handler.canvas ? this.handler.canvas.toDataURL(type, quality) : "";
770
+ }
767
771
  _screenFrameMSAA() {
768
772
  let h = this.handler;
769
773
  let sh = h.programs.toneMapping, p = sh._program, gl = h.gl;
@@ -2,9 +2,12 @@ import { Extent } from "../Extent";
2
2
  import { Node } from "../quadTree/Node";
3
3
  import { Planet } from "../scene/Planet";
4
4
  import { SegmentLonLat } from "./SegmentLonLat";
5
+ import { WebGLTextureExt } from "../webgl/Handler";
6
+ export declare const POLE_PIECE_SIZE: number;
5
7
  export declare class SegmentLonLatEqui extends SegmentLonLat {
6
8
  constructor(node: Node, planet: Planet, tileZoom: number, extent: Extent);
7
9
  protected _getMaxZoom(): number;
8
10
  protected _assignTileYIndexes(extent: Extent): void;
9
11
  protected _assignTileXIndexes(extent: Extent): void;
12
+ getDefaultTexture(): WebGLTextureExt | null;
10
13
  }
@@ -1,6 +1,8 @@
1
1
  import { SegmentLonLat } from "./SegmentLonLat";
2
2
  import { getTileCellIndex, TILEGROUP_COMMON } from "./Segment";
3
3
  import { equi } from "../proj/equi";
4
+ const MAX_POLE_ZOOM = 5;
5
+ export const POLE_PIECE_SIZE = 5 / Math.pow(2, MAX_POLE_ZOOM);
4
6
  export class SegmentLonLatEqui extends SegmentLonLat {
5
7
  constructor(node, planet, tileZoom, extent) {
6
8
  super(node, planet, tileZoom, extent);
@@ -9,7 +11,21 @@ export class SegmentLonLatEqui extends SegmentLonLat {
9
11
  this._tileGroup = TILEGROUP_COMMON;
10
12
  }
11
13
  _getMaxZoom() {
12
- return 150;
14
+ let maxPoleZoom = 0;
15
+ if (this._extent.northEast.lat > 85) {
16
+ //north pole limits
17
+ let Yz = Math.floor((90.0 - this._extent.northEast.lat) / POLE_PIECE_SIZE);
18
+ maxPoleZoom = Math.floor(Yz / 16) + MAX_POLE_ZOOM;
19
+ }
20
+ else if (this._extent.southWest.lat < -85) {
21
+ //south pole limits
22
+ let Yz = Math.floor((90 + this._extent.southWest.lat) / POLE_PIECE_SIZE);
23
+ maxPoleZoom = Math.floor(Yz / 16) + MAX_POLE_ZOOM;
24
+ }
25
+ else {
26
+ maxPoleZoom = 50;
27
+ }
28
+ return maxPoleZoom;
13
29
  }
14
30
  _assignTileYIndexes(extent) {
15
31
  const lat = extent.getCenter().lat;
@@ -24,4 +40,7 @@ export class SegmentLonLatEqui extends SegmentLonLat {
24
40
  this.tileXE = (this.tileX + 1) % p2;
25
41
  this.tileXW = (p2 + this.tileX - 1) % p2;
26
42
  }
43
+ getDefaultTexture() {
44
+ return this.planet.solidTextureOne;
45
+ }
27
46
  }
@@ -28,6 +28,7 @@ export interface IHandlerParameters {
28
28
  alpha?: boolean;
29
29
  antialias?: boolean;
30
30
  premultipliedAlpha?: boolean;
31
+ preserveDrawingBuffer?: boolean;
31
32
  };
32
33
  extensions?: string[];
33
34
  autoActivate?: boolean;
@@ -120,6 +121,7 @@ declare class Handler {
120
121
  alpha?: boolean;
121
122
  antialias?: boolean;
122
123
  premultipliedAlpha?: boolean;
124
+ preserveDrawingBuffer?: boolean;
123
125
  };
124
126
  extensions: string[];
125
127
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.22.0",
3
+ "version": "0.22.2",
4
4
  "description": "[openglobus](https://www.openglobus.org/) is a javascript/typescript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers, and 3D objects. It uses the WebGL technology, open source, and completely free.",
5
5
  "directories": {
6
6
  "example": "./sandbox"
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "docs": "jsdoc -r ./src/ -c ./jsdoc.conf.json -d ./docs",
13
13
  "serve_docs": "cd docs; ws -p 8088",
14
- "serve": "ws -p 8080",
14
+ "serve": "ws -p 3000",
15
15
  "build": "rollup -c --bundleConfigAsCjs",
16
16
  "clean": "rm -rf ./lib ./docs",
17
17
  "prepublishOnly": "npm run build; npm run gen_js",
@@ -57,7 +57,7 @@
57
57
  "local-web-server": "^5.4.0",
58
58
  "postcss": "^8.4.45",
59
59
  "prettier": "^3.3.3",
60
- "rollup": "^4.21.2",
60
+ "rollup": "^4.22.4",
61
61
  "rollup-plugin-copy": "^3.5.0",
62
62
  "rollup-plugin-postcss": "^4.0.2",
63
63
  "ts-jest": "^29.2.5",