@openglobus/og 0.19.1 → 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.
@@ -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;
@@ -51,16 +51,29 @@ 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
55
 
55
56
  const float PI = 3.141592653589793;
56
57
 
57
58
  const float RADIANS = PI / 180.0;
58
59
 
59
60
  void main(void) {
60
-
61
+
61
62
  if (aDispose == 0.0) {
62
63
  return;
63
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
+
64
77
 
65
78
  vColor = aColor;
66
79
  vTexCoords = aTexCoord;
@@ -83,8 +96,6 @@ export const geo_object = () => new Program("geo_object", {
83
96
  vec3(0.0, -sin_pitch, cos_pitch)
84
97
  );
85
98
 
86
- vec3 position = aPositionHigh + aPositionLow;
87
- cameraPosition = eyePositionHigh + eyePositionLow;
88
99
  vec3 r = cross(normalize(-position), aDirection);
89
100
  mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ;
90
101
 
@@ -94,8 +105,6 @@ export const geo_object = () => new Program("geo_object", {
94
105
  vec3 highDiff = aPositionHigh - eyePositionHigh;
95
106
  vec3 lowDiff = aPositionLow - eyePositionLow;
96
107
 
97
- vec3 look = cameraPosition - position;
98
- float lookLength = length(look);
99
108
  vNormal = modelMatrix * aVertexNormal;
100
109
 
101
110
  // if(lookLength > uScaleByDistance[1])
@@ -124,7 +133,7 @@ export const geo_object = () => new Program("geo_object", {
124
133
 
125
134
  uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
126
135
  uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
127
- uniform float lightsParamsf[MAX_POINT_LIGHTS];
136
+ uniform float lightsParamsf[MAX_POINT_LIGHTS];
128
137
  uniform sampler2D uTexture;
129
138
  uniform float uUseTexture;
130
139
 
@@ -133,20 +142,25 @@ export const geo_object = () => new Program("geo_object", {
133
142
  varying vec4 vColor;
134
143
  varying vec3 vNormal;
135
144
  varying vec2 vTexCoords;
145
+ varying float useLighting;
136
146
 
137
- void main(void) {
138
- vec3 normal = normalize(vNormal);
147
+ void main(void) {
148
+
149
+ vec3 lightWeighting = vec3(1.0);
139
150
 
140
- vec3 lightDir = normalize(lightsPositions[0]);
141
- vec3 viewDir = normalize(cameraPosition - v_vertex);
142
- vec3 reflectionDirection = reflect(-lightDir, normal);
143
- float reflection = max( dot(reflectionDirection, viewDir), 0.0);
144
- float specularLightWeighting = pow( reflection, lightsParamsf[0]);
145
- float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
146
- vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
147
- vec4 tColor = texture2D(uTexture, vTexCoords);
148
-
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
+
149
162
  if(uUseTexture > 0.0) {
163
+ vec4 tColor = texture2D(uTexture, vTexCoords);
150
164
  gl_FragColor = vec4(tColor.rgb * lightWeighting, tColor.a);
151
165
  } else {
152
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.1",
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"