@openglobus/og 0.19.0 → 0.19.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.
@@ -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
  }
@@ -720,7 +720,7 @@ class Renderer {
720
720
  this.enableBlendDefault();
721
721
  e.dispatch(e.draw, this);
722
722
  let frustums = this.activeCamera.frustums;
723
- let pointerEvent = e.pointerEvent() || this.activeCamera.isMoving;
723
+ let pointerEvent = !(e.mouseState.leftButtonDown || e.mouseState.rightButtonDown || this.activeCamera.isMoving) && (e.pointerEvent() /* || this.activeCamera!.isMoving*/);
724
724
  // Rendering scene nodes and entityCollections
725
725
  let rn = this._renderNodesArr;
726
726
  let k = frustums.length;
@@ -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,20 +50,31 @@ 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;
54
+ varying float useLighting;
56
55
 
57
56
  const float PI = 3.141592653589793;
58
57
 
59
58
  const float RADIANS = PI / 180.0;
60
59
 
61
60
  void main(void) {
62
-
61
+
63
62
  if (aDispose == 0.0) {
64
63
  return;
65
64
  }
65
+
66
+ vec3 position = aPositionHigh + aPositionLow;
67
+ cameraPosition = eyePositionHigh + eyePositionLow;
68
+
69
+ vec3 look = cameraPosition - position;
70
+ float lookLength = length(look);
71
+
72
+ useLighting = 1.0;
73
+ if(lookLength > 2000000.0){
74
+ useLighting = 0.0;
75
+ }
76
+
66
77
 
67
- vUseTexture = uUseTexture;
68
78
  vColor = aColor;
69
79
  vTexCoords = aTexCoord;
70
80
 
@@ -86,8 +96,6 @@ export const geo_object = () => new Program("geo_object", {
86
96
  vec3(0.0, -sin_pitch, cos_pitch)
87
97
  );
88
98
 
89
- vec3 position = aPositionHigh + aPositionLow;
90
- cameraPosition = eyePositionHigh + eyePositionLow;
91
99
  vec3 r = cross(normalize(-position), aDirection);
92
100
  mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ;
93
101
 
@@ -97,8 +105,6 @@ export const geo_object = () => new Program("geo_object", {
97
105
  vec3 highDiff = aPositionHigh - eyePositionHigh;
98
106
  vec3 lowDiff = aPositionLow - eyePositionLow;
99
107
 
100
- vec3 look = cameraPosition - position;
101
- float lookLength = length(look);
102
108
  vNormal = modelMatrix * aVertexNormal;
103
109
 
104
110
  // if(lookLength > uScaleByDistance[1])
@@ -127,28 +133,34 @@ export const geo_object = () => new Program("geo_object", {
127
133
 
128
134
  uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
129
135
  uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
130
- uniform float lightsParamsf[MAX_POINT_LIGHTS];
136
+ uniform float lightsParamsf[MAX_POINT_LIGHTS];
131
137
  uniform sampler2D uTexture;
132
-
138
+ uniform float uUseTexture;
139
+
133
140
  varying vec3 cameraPosition;
134
141
  varying vec3 v_vertex;
135
142
  varying vec4 vColor;
136
143
  varying vec3 vNormal;
137
144
  varying vec2 vTexCoords;
138
- varying float vUseTexture;
145
+ varying float useLighting;
139
146
 
140
- void main(void) {
141
- vec3 normal = normalize(vNormal);
147
+ void main(void) {
148
+
149
+ vec3 lightWeighting = vec3(1.0);
142
150
 
143
- vec3 lightDir = normalize(lightsPositions[0]);
144
- vec3 viewDir = normalize(cameraPosition - v_vertex);
145
- vec3 reflectionDirection = reflect(-lightDir, normal);
146
- float reflection = max( dot(reflectionDirection, viewDir), 0.0);
147
- float specularLightWeighting = pow( reflection, lightsParamsf[0]);
148
- float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
149
- vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
150
- vec4 tColor = texture2D(uTexture, vTexCoords);
151
- if(vUseTexture > 0.0){
151
+ if(useLighting != 0.0){
152
+ vec3 normal = normalize(vNormal);
153
+ vec3 lightDir = normalize(lightsPositions[0]);
154
+ vec3 viewDir = normalize(cameraPosition - v_vertex);
155
+ vec3 reflectionDirection = reflect(-lightDir, normal);
156
+ float reflection = max( dot(reflectionDirection, viewDir), 0.0);
157
+ float specularLightWeighting = pow( reflection, lightsParamsf[0]);
158
+ float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
159
+ lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
160
+ }
161
+
162
+ if(uUseTexture > 0.0) {
163
+ vec4 tColor = texture2D(uTexture, vTexCoords);
152
164
  gl_FragColor = vec4(tColor.rgb * lightWeighting, tColor.a);
153
165
  } else {
154
166
  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.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"