@openglobus/og 0.19.2 → 0.19.4

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.
@@ -43,13 +43,13 @@ class Axes extends RenderNode {
43
43
  }
44
44
  createAxesBuffer(gridSize) {
45
45
  const vertices = [
46
- 0.0, 0.0, 0.0, gridSize - 1, 0.0, 0.0,
47
- 0.0, 0.0, 0.0, 0.0, gridSize - 1, 0.0,
46
+ 0.0, 0.0, 0.0, gridSize - 1, 0.0, 0.0, // x - R
47
+ 0.0, 0.0, 0.0, 0.0, gridSize - 1, 0.0, // y - B
48
48
  0.0, 0.0, 0.0, 0.0, 0.0, gridSize - 1 // z - G
49
49
  ];
50
50
  const colors = [
51
- 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0,
52
- 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0,
51
+ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, // x - R
52
+ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, // y - B
53
53
  0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 // z - G
54
54
  ];
55
55
  this.axesBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(vertices), 3, 6);
@@ -228,6 +228,7 @@ declare class Segment {
228
228
  * @todo: looks like it could be simplified in Segment contructor
229
229
  */
230
230
  _setExtentLonLat(): void;
231
+ protected _createExtentNormals(): void;
231
232
  createBoundsByExtent(): void;
232
233
  createBoundsByParent(): void;
233
234
  setBoundingSphere(x: number, y: number, z: number, v: Vec3): void;
@@ -283,7 +283,8 @@ class Segment {
283
283
  this.node.equalizedSideWithNodeId[neighborSide] !== neigborNode.equalizedSideWithNodeId[OPSIDE[neighborSide]];
284
284
  }
285
285
  equalize() {
286
- if (this.tileZoom < 8 || this.gridSize < 2) {
286
+ // Equalization doesnt work correctly for gridSize equals 2
287
+ if (this.gridSize < 2) {
287
288
  return;
288
289
  }
289
290
  this.readyToEngage = true;
@@ -621,7 +622,7 @@ class Segment {
621
622
  _setExtentLonLat() {
622
623
  this._extentLonLat = this._extent.inverseMercator();
623
624
  }
624
- createBoundsByExtent() {
625
+ _createExtentNormals() {
625
626
  const ellipsoid = this.planet.ellipsoid;
626
627
  const extent = this._extentLonLat;
627
628
  const coord_sw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.southWest.lat);
@@ -632,7 +633,10 @@ class Segment {
632
633
  this._nw.copy(coord_nw);
633
634
  this._ne.copy(coord_ne);
634
635
  this._se.copy(coord_se);
635
- this.setBoundingVolume3v(coord_sw, coord_ne);
636
+ }
637
+ createBoundsByExtent() {
638
+ this._createExtentNormals();
639
+ this.setBoundingVolume3v(this._sw, this._ne);
636
640
  }
637
641
  createBoundsByParent() {
638
642
  let pn = this.node;
@@ -694,6 +698,7 @@ class Segment {
694
698
  else {
695
699
  coords_rb = Vec3.add(vs.scaleTo(1 - vi_x / insideSize), ve.scaleTo(1 - vi_y / insideSize)).addA(v_rb);
696
700
  }
701
+ this._createExtentNormals();
697
702
  this.setBoundingVolume3v(coords_lt, coords_rb);
698
703
  }
699
704
  }
@@ -219,10 +219,10 @@ export function drawnode_screen_wl_webgl1NoAtmos() {
219
219
  float maxH = minH * 3.0;
220
220
  float nightCoef = getLerpValue(minH, maxH, camHeight) * nightTextureCoefficient;
221
221
 
222
- if(camHeight > 6000000.0)
223
- {
224
- normal = normalize(v_vertex);
225
- }
222
+ // if(camHeight > 6000000.0)
223
+ // {
224
+ // normal = normalize(v_vertex);
225
+ // }
226
226
 
227
227
  vec3 lightDir = normalize(sunPos);
228
228
  vec3 viewDir = normalize(cameraPosition - v_vertex);
@@ -406,10 +406,10 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
406
406
  float maxH = minH * 3.0;
407
407
  float nightCoef = getLerpValue(minH, maxH, camHeight) * nightTextureCoefficient;
408
408
 
409
- if(camHeight > 6000000.0)
410
- {
411
- normal = normalize(v_vertex);
412
- }
409
+ // if(camHeight > 6000000.0)
410
+ // {
411
+ // normal = normalize(v_vertex);
412
+ // }
413
413
 
414
414
  vec3 lightDir = normalize(sunPos);
415
415
  vec3 viewDir = normalize(cameraPosition - v_vertex);
@@ -661,8 +661,12 @@ export function drawnode_screen_wl_webgl2Atmos() {
661
661
  bool hitGround = intersectSphere(camPos, rayDirection, BOTTOM_RADIUS, distanceToGround) && distanceToGround > 0.0;
662
662
 
663
663
  // Fix black dots on the edge of atmosphere
664
- if(camHeight < 700000.0 || !hitGround)
665
- {
664
+ // if(camHeight < 700000.0 || !hitGround)
665
+ // {
666
+ // distanceToGround = distance(camPos, v_vertex * SPHERE_TO_ELLIPSOID_SCALE);
667
+ // }
668
+
669
+ if(length(v_vertex * SPHERE_TO_ELLIPSOID_SCALE) > BOTTOM_RADIUS){
666
670
  distanceToGround = distance(camPos, v_vertex * SPHERE_TO_ELLIPSOID_SCALE);
667
671
  }
668
672
 
@@ -725,10 +729,10 @@ export function drawnode_screen_wl_webgl2Atmos() {
725
729
  float maxH = minH * 3.0;
726
730
  float nightCoef = getLerpValue(minH, maxH, camHeight) * nightTextureCoefficient;
727
731
 
728
- if(camHeight > 6000000.0)
729
- {
730
- normal = normalize(v_vertex);
731
- }
732
+ // if(camHeight > 6000000.0)
733
+ // {
734
+ // normal = normalize(v_vertex);
735
+ // }
732
736
 
733
737
  vec3 lightDir = normalize(sunPos);
734
738
  vec3 viewDir = normalize(cameraPosition - v_vertex);
@@ -21,7 +21,7 @@ export const geo_object = () => new Program("geo_object", {
21
21
  aDirection: { type: "vec3", divisor: 1 },
22
22
  aPitchRoll: { type: "vec2", divisor: 1 },
23
23
  aColor: { type: "vec4", divisor: 1 },
24
- aScale: { type: "float", divisor: 1 },
24
+ aScale: { type: "vec3", divisor: 1 },
25
25
  aDispose: { type: "float", divisor: 1 }
26
26
  },
27
27
  vertexShader: `precision highp float;
@@ -33,7 +33,7 @@ export const geo_object = () => new Program("geo_object", {
33
33
  attribute vec3 aDirection;
34
34
  attribute vec2 aPitchRoll;
35
35
  attribute vec4 aColor;
36
- attribute float aScale;
36
+ attribute vec3 aScale;
37
37
  attribute float aDispose;
38
38
  attribute float aUseTexture;
39
39
  attribute vec2 aTexCoord;
@@ -51,7 +51,7 @@ export const geo_object = () => new Program("geo_object", {
51
51
  varying vec4 vColor;
52
52
  varying float vDispose;
53
53
  varying vec2 vTexCoords;
54
- varying float useLighting;
54
+ //varying float useLighting;
55
55
 
56
56
  const float PI = 3.141592653589793;
57
57
 
@@ -69,10 +69,10 @@ export const geo_object = () => new Program("geo_object", {
69
69
  vec3 look = cameraPosition - position;
70
70
  float lookLength = length(look);
71
71
 
72
- useLighting = 1.0;
73
- if(lookLength > 2000000.0){
74
- useLighting = 0.0;
75
- }
72
+ // useLighting = 1.0;
73
+ // if(lookLength > 2000000.0){
74
+ // useLighting = 0.0;
75
+ // }
76
76
 
77
77
 
78
78
  vColor = aColor;
@@ -118,7 +118,7 @@ export const geo_object = () => new Program("geo_object", {
118
118
  // ... is the same math
119
119
  float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
120
120
 
121
- vec3 vert = modelMatrix * aVertexPosition * aScale * scd;
121
+ vec3 vert = modelMatrix * (aVertexPosition * aScale) * scd;
122
122
  v_vertex = position + vert;
123
123
 
124
124
  // @hack
@@ -142,13 +142,13 @@ export const geo_object = () => new Program("geo_object", {
142
142
  varying vec4 vColor;
143
143
  varying vec3 vNormal;
144
144
  varying vec2 vTexCoords;
145
- varying float useLighting;
145
+ //varying float useLighting;
146
146
 
147
147
  void main(void) {
148
148
 
149
149
  vec3 lightWeighting = vec3(1.0);
150
150
 
151
- if(useLighting != 0.0){
151
+ //if(useLighting != 0.0){
152
152
  vec3 normal = normalize(vNormal);
153
153
  vec3 lightDir = normalize(lightsPositions[0]);
154
154
  vec3 viewDir = normalize(cameraPosition - v_vertex);
@@ -157,7 +157,7 @@ export const geo_object = () => new Program("geo_object", {
157
157
  float specularLightWeighting = pow( reflection, lightsParamsf[0]);
158
158
  float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
159
159
  lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
160
- }
160
+ //}
161
161
 
162
162
  if(uUseTexture > 0.0) {
163
163
  vec4 tColor = texture2D(uTexture, vTexCoords);
@@ -183,7 +183,7 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
183
183
  aDirection: { type: "vec3", divisor: 1 },
184
184
  aPitchRoll: { type: "vec2", divisor: 1 },
185
185
  aPickingColor: { type: "vec3", divisor: 1 },
186
- aScale: { type: "float", divisor: 1 },
186
+ aScale: { type: "vec3", divisor: 1 },
187
187
  aDispose: { type: "float", divisor: 1 }
188
188
  },
189
189
  vertexShader: `precision highp float;
@@ -194,7 +194,7 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
194
194
  attribute vec3 aDirection;
195
195
  attribute vec3 aPickingColor;
196
196
  attribute vec2 aPitchRoll;
197
- attribute float aScale;
197
+ attribute vec3 aScale;
198
198
  attribute float aDispose;
199
199
 
200
200
  uniform vec3 eyePositionHigh;
@@ -262,7 +262,7 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
262
262
  // tays in the vert above it affects on Mac Safari jitter
263
263
  float scd = pickingScale * uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
264
264
 
265
- vec3 vert = modelMatrix * aVertexPosition * aScale * scd;
265
+ vec3 vert = modelMatrix * (aVertexPosition * aScale) * scd;
266
266
 
267
267
  vert += lowDiff;
268
268
 
@@ -13,6 +13,7 @@ declare class MapboxTerrain extends GlobusTerrain {
13
13
  protected _ctx: CanvasRenderingContext2D;
14
14
  protected _imageDataCache: Record<string, Uint8ClampedArray>;
15
15
  constructor(name: string | null, options?: IMapboxTerrainParams);
16
+ static checkNoDataValue(noDataValues: number[] | TypedArray, value: number): boolean;
16
17
  isBlur(segment: Segment): boolean;
17
18
  protected _createTemporalCanvas(size: number): CanvasRenderingContext2D;
18
19
  protected _createHeights(data: HTMLImageElement | ImageBitmap, tileIndex: string, tileX: number, tileY: number, tileZoom: number, extent: Extent, preventChildren: boolean): TypedArray | number[];
@@ -3,6 +3,7 @@ import { getTileExtent } from "../mercator";
3
3
  import { GlobusTerrain } from "./GlobusTerrain";
4
4
  import { isPowerOfTwo } from "../math";
5
5
  import { Layer } from "../layer/Layer";
6
+ import { binarySearchFast } from "../utils/shared";
6
7
  /**
7
8
  * The key doesn't work; just an example!
8
9
  */
@@ -31,6 +32,12 @@ class MapboxTerrain extends GlobusTerrain {
31
32
  this._ctx = this._createTemporalCanvas(this._imageSize);
32
33
  this._imageDataCache = {};
33
34
  }
35
+ static checkNoDataValue(noDataValues, value) {
36
+ if (value > 50000) {
37
+ return true;
38
+ }
39
+ return binarySearchFast(noDataValues, value) !== -1;
40
+ }
34
41
  isBlur(segment) {
35
42
  return segment.tileZoom >= 16;
36
43
  }
@@ -10,8 +10,8 @@ export function objParser(text) {
10
10
  ];
11
11
  // same order as `f` indices
12
12
  let vertexData = [
13
- [],
14
- [],
13
+ [], // positions
14
+ [], // texcoords
15
15
  [], // normals
16
16
  ];
17
17
  const materialLibs = [];
@@ -82,7 +82,7 @@ export function objParser(text) {
82
82
  }
83
83
  },
84
84
  s: () => {
85
- },
85
+ }, // smoothing group
86
86
  mtllib(parts, unparsedArgs) {
87
87
  // the spec says there can be multiple filenames here
88
88
  // but many exist with spaces in a single filename
@@ -52,8 +52,9 @@ export declare function stringTemplate(template: string, params?: any): string;
52
52
  export declare function getHTML(template: string, params?: any): string;
53
53
  export declare function parseHTML(htmlStr: string): HTMLElement[];
54
54
  export declare function print2d(id: string, text: string, x: number, y: number): void;
55
+ export declare function isNumber(value: any): boolean;
55
56
  export declare function defaultString(str?: string, def?: string): string;
56
- export declare function createVector3(v?: Vec3 | Vec2 | NumberArray3 | NumberArray2 | null, def?: Vec3): Vec3;
57
+ export declare function createVector3(v?: number | Vec3 | Vec2 | NumberArray3 | NumberArray2 | null, def?: Vec3): Vec3;
57
58
  export declare function createVector4(v?: Vec4 | NumberArray4 | null, def?: Vec4): Vec4;
58
59
  export declare function createColorRGBA(c?: string | NumberArray4 | Vec4 | null, def?: Vec4): Vec4;
59
60
  export declare function createColorRGB(c?: string | NumberArray3 | Vec3 | null, def?: Vec3): Vec3;
@@ -145,12 +145,18 @@ export function print2d(id, text, x, y) {
145
145
  el.style.left = `${x}px`;
146
146
  el.style.top = `${y}px`;
147
147
  }
148
+ export function isNumber(value) {
149
+ return typeof value === 'number';
150
+ }
148
151
  export function defaultString(str, def = "") {
149
152
  return str ? str.trim() : def;
150
153
  }
151
154
  export function createVector3(v, def) {
152
155
  if (v) {
153
- if (v instanceof Vec3) {
156
+ if (isNumber(v)) {
157
+ return new Vec3(v, v, v);
158
+ }
159
+ else if (v instanceof Vec3) {
154
160
  return v.clone();
155
161
  }
156
162
  else if (v instanceof Array) {
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
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"
7
7
  },
8
8
  "main": "./lib/js/index.js",
9
+ "types": "./lib/js/index.d.ts",
9
10
  "style": "./css/og.css",
10
11
  "scripts": {
11
12
  "docs": "jsdoc -r ./src/ -c ./jsdoc.conf.json -d ./docs",
@@ -32,28 +33,34 @@
32
33
  },
33
34
  "homepage": "https://www.openglobus.org",
34
35
  "devDependencies": {
35
- "@babel/preset-env": "^7.22.20",
36
- "@rollup/plugin-json": "^6.0.0",
37
- "@rollup/plugin-terser": "^0.4.3",
38
- "@rollup/plugin-typescript": "^11.1.3",
39
- "@types/jest": "^29.5.5",
40
- "@typescript-eslint/eslint-plugin": "^6.7.2",
41
- "@typescript-eslint/parser": "^6.7.2",
42
- "clean-jsdoc-theme": "^4.2.10",
43
- "eslint": "^8.49.0",
36
+ "@babel/cli": "^7.24.7",
37
+ "@babel/core": "^7.24.7",
38
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
39
+ "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
40
+ "@babel/preset-env": "^7.24.7",
41
+ "@babel/preset-typescript": "^7.24.7",
42
+ "@rollup/plugin-json": "^6.1.0",
43
+ "@rollup/plugin-terser": "^0.4.4",
44
+ "@rollup/plugin-typescript": "^11.1.6",
45
+ "@types/jest": "^29.5.12",
46
+ "@typescript-eslint/eslint-plugin": "^7.10.0",
47
+ "@typescript-eslint/parser": "^7.10.0",
48
+ "clean-jsdoc-theme": "^4.3.0",
49
+ "eslint": "^8.57.0",
44
50
  "jest": "^29.7.0",
45
51
  "jest-canvas-mock": "^2.5.2",
46
52
  "jest-environment-jsdom": "^29.7.0",
47
- "jsdoc": "^4.0.2",
48
- "lint-staged": "^14.0.1",
49
- "local-web-server": "^5.3.0",
50
- "postcss": "^8.4.31",
51
- "prettier": "^3.0.3",
52
- "rollup": "^3.29.2",
53
+ "jsdoc": "^4.0.3",
54
+ "jsdoc-babel": "^0.5.0",
55
+ "lint-staged": "^15.2.4",
56
+ "local-web-server": "^5.3.3",
57
+ "postcss": "^8.4.38",
58
+ "prettier": "^3.2.5",
59
+ "rollup": "^4.18.0",
53
60
  "rollup-plugin-copy": "^3.5.0",
54
61
  "rollup-plugin-postcss": "^4.0.2",
55
- "ts-jest": "^29.1.1",
56
- "typescript": "^5.2.2"
62
+ "ts-jest": "^29.1.3",
63
+ "typescript": "^5.4.5"
57
64
  },
58
65
  "lint-staged": {
59
66
  "*.{js,ts}": [