@openglobus/og 0.19.0 → 0.19.1

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.
@@ -155,9 +155,9 @@ class Node {
155
155
  }
156
156
  this.state = WALKTHROUGH;
157
157
  this.clearNeighbors();
158
- for (let i = 0; i < this._fadingNodes.length; i++) {
159
- this._fadingNodes[i].neighbors && this._fadingNodes[i].clearNeighbors();
160
- }
158
+ // for (let i = 0; i < this._fadingNodes.length; i++) {
159
+ // this._fadingNodes[i].neighbors && this._fadingNodes[i].clearNeighbors();
160
+ // }
161
161
  let seg = this.segment, planet = this.planet;
162
162
  this._cameraInside = false;
163
163
  // Search a node which the camera is flying over.
@@ -352,22 +352,10 @@ class Node {
352
352
  else {
353
353
  if (this._fadingNodes.length === 4 && !this.childrenPrevStateEquals(RENDERING)) {
354
354
  this.segment._transitionOpacity = 1.0;
355
+ this._fadingNodes = [];
355
356
  }
356
357
  else {
357
358
  this.segment.increaseTransitionOpacity();
358
- for (let i = 0; i < this._fadingNodes.length; i++) {
359
- let n = this._fadingNodes[i];
360
- if (n.segment) {
361
- if (n.segment._transitionOpacity > 0 && !this.planet._fadingNodes.has(n.nodeId)) {
362
- this.planet._fadingNodes.set(n.nodeId, n);
363
- n.segment.fadingTransitionOpacity();
364
- }
365
- }
366
- else {
367
- this.segment._transitionOpacity = 1.0;
368
- break;
369
- }
370
- }
371
359
  }
372
360
  }
373
361
  }
@@ -1059,28 +1059,36 @@ export class Planet extends RenderNode {
1059
1059
  let transparentSegments = [];
1060
1060
  let isEq = this.terrain.equalizeVertices;
1061
1061
  let i = renderedNodes.length;
1062
- let _renderingFadingNodes = this._renderingFadingNodes;
1063
- if (cam.slope > 0.78 || cam.getAltitude() > 10000) {
1064
- _renderingFadingNodes = this._renderingFadingNodesNoDepth;
1065
- }
1066
- while (i--) {
1067
- let ri = renderedNodes[i];
1068
- let s = ri.segment;
1069
- _renderingFadingNodes(nodes, sh, ri, sl[0], 0, transparentSegments);
1070
- if (s._transitionOpacity < 1) {
1071
- transparentSegments.push(s);
1072
- }
1073
- else {
1062
+ if (cam.slope > 0.8 /*|| cam.getAltitude() > 10000*/) {
1063
+ while (i--) {
1064
+ let ri = renderedNodes[i];
1065
+ let s = ri.segment;
1066
+ this._renderingFadingNodesNoDepth(nodes, sh, ri, sl[0], 0);
1074
1067
  isEq && s.equalize();
1075
1068
  s.readyToEngage && s.engage();
1076
1069
  s.screenRendering(sh, sl[0], 0);
1077
1070
  }
1078
1071
  }
1079
- for (let j = 0; j < transparentSegments.length; j++) {
1080
- let tj = transparentSegments[j];
1081
- isEq && tj.equalize();
1082
- tj.readyToEngage && tj.engage();
1083
- tj.screenRendering(sh, sl[0], 0);
1072
+ else {
1073
+ while (i--) {
1074
+ let ri = renderedNodes[i];
1075
+ let s = ri.segment;
1076
+ this._renderingFadingNodes(nodes, sh, ri, sl[0], 0, transparentSegments);
1077
+ if (s._transitionOpacity < 1) {
1078
+ transparentSegments.push(s);
1079
+ }
1080
+ else {
1081
+ isEq && s.equalize();
1082
+ s.readyToEngage && s.engage();
1083
+ s.screenRendering(sh, sl[0], 0);
1084
+ }
1085
+ }
1086
+ for (let j = 0; j < transparentSegments.length; j++) {
1087
+ let tj = transparentSegments[j];
1088
+ isEq && tj.equalize();
1089
+ tj.readyToEngage && tj.engage();
1090
+ tj.screenRendering(sh, sl[0], 0);
1091
+ }
1084
1092
  }
1085
1093
  }
1086
1094
  _renderingScreenNodesWithHeight(sh, cam, renderedNodes) {
@@ -1028,13 +1028,30 @@ class Segment {
1028
1028
  //this._transitionOpacity += 0.01;
1029
1029
  this._transitionOpacity += (window.performance.now() - this._transitionTimestamp) / this.planet.transitionTime;
1030
1030
  this._transitionTimestamp = window.performance.now();
1031
- if (this._transitionOpacity > 1.0) {
1032
- this._transitionOpacity = 1.0;
1031
+ if (this._transitionOpacity > 2.0) {
1032
+ this._transitionOpacity = 2.0;
1033
+ }
1034
+ let i = this.node._fadingNodes.length;
1035
+ while (i--) {
1036
+ let n = this.node._fadingNodes[i];
1037
+ if (n.segment) {
1038
+ if (n.segment._transitionOpacity > 0 && !this.planet._fadingNodes.has(n.nodeId)) {
1039
+ this.planet._fadingNodes.set(n.nodeId, n);
1040
+ n.segment._transitionOpacity = 2.0 - this._transitionOpacity;
1041
+ if (n.segment._transitionOpacity === 0) {
1042
+ this.node._fadingNodes.splice(i, 1);
1043
+ }
1044
+ }
1045
+ }
1046
+ else {
1047
+ this._transitionOpacity = 1.0;
1048
+ break;
1049
+ }
1033
1050
  }
1034
1051
  }
1035
1052
  fadingTransitionOpacity() {
1036
- //this._transitionOpacity -= 0.01;
1037
- this._transitionOpacity -= (window.performance.now() - this._transitionTimestamp) / this.planet.transitionTime;
1053
+ this._transitionOpacity -= 0.01;
1054
+ // this._transitionOpacity -= (window.performance.now() - this._transitionTimestamp) / this.planet.transitionTime;
1038
1055
  this._transitionTimestamp = window.performance.now();
1039
1056
  if (this._transitionOpacity < 0.0) {
1040
1057
  this._transitionOpacity = 0;
@@ -38,7 +38,6 @@ export const geo_object = () => new Program("geo_object", {
38
38
  attribute float aUseTexture;
39
39
  attribute vec2 aTexCoord;
40
40
 
41
- uniform float uUseTexture;
42
41
  uniform vec3 uScaleByDistance;
43
42
  uniform mat4 projectionMatrix;
44
43
  uniform mat4 viewMatrix;
@@ -51,7 +50,6 @@ export const geo_object = () => new Program("geo_object", {
51
50
  varying vec3 v_vertex;
52
51
  varying vec4 vColor;
53
52
  varying float vDispose;
54
- varying float vUseTexture;
55
53
  varying vec2 vTexCoords;
56
54
 
57
55
  const float PI = 3.141592653589793;
@@ -64,7 +62,6 @@ export const geo_object = () => new Program("geo_object", {
64
62
  return;
65
63
  }
66
64
 
67
- vUseTexture = uUseTexture;
68
65
  vColor = aColor;
69
66
  vTexCoords = aTexCoord;
70
67
 
@@ -129,13 +126,13 @@ export const geo_object = () => new Program("geo_object", {
129
126
  uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
130
127
  uniform float lightsParamsf[MAX_POINT_LIGHTS];
131
128
  uniform sampler2D uTexture;
132
-
129
+ uniform float uUseTexture;
130
+
133
131
  varying vec3 cameraPosition;
134
132
  varying vec3 v_vertex;
135
133
  varying vec4 vColor;
136
134
  varying vec3 vNormal;
137
135
  varying vec2 vTexCoords;
138
- varying float vUseTexture;
139
136
 
140
137
  void main(void) {
141
138
  vec3 normal = normalize(vNormal);
@@ -148,7 +145,8 @@ export const geo_object = () => new Program("geo_object", {
148
145
  float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
149
146
  vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
150
147
  vec4 tColor = texture2D(uTexture, vTexCoords);
151
- if(vUseTexture > 0.0){
148
+
149
+ if(uUseTexture > 0.0) {
152
150
  gl_FragColor = vec4(tColor.rgb * lightWeighting, tColor.a);
153
151
  } else {
154
152
  gl_FragColor = vec4(vColor.rgb * lightWeighting, vColor.a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
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"