@openglobus/og 0.18.2 → 0.18.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.
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/control/Atmosphere.js +7 -10
- package/lib/js/entity/LabelWorker.js +7 -7
- package/lib/js/input/KeyboardHandler.js +2 -0
- package/lib/js/input/input.js +8 -3
- package/lib/js/scene/Planet.js +1 -1
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ export class Atmosphere extends Control {
|
|
|
30
30
|
this.planet && this.planet.events.off("draw", this._drawBackground);
|
|
31
31
|
}
|
|
32
32
|
_drawAtmosphereTextures() {
|
|
33
|
-
let width =
|
|
33
|
+
let width = 1024, height = 1024;
|
|
34
34
|
this._transmittanceBuffer = new Framebuffer(this.renderer.handler, {
|
|
35
35
|
width: width,
|
|
36
36
|
height: height,
|
|
@@ -142,7 +142,7 @@ function atmosphereBackgroundShader() {
|
|
|
142
142
|
gl_Position = vec4(corners, 0.0, 1.0);
|
|
143
143
|
}`,
|
|
144
144
|
fragmentShader: `
|
|
145
|
-
precision
|
|
145
|
+
precision lowp float;
|
|
146
146
|
|
|
147
147
|
${atmos.COMMON}
|
|
148
148
|
|
|
@@ -242,7 +242,7 @@ function atmosphereBackgroundShader() {
|
|
|
242
242
|
if (offset > 0.0) {
|
|
243
243
|
// intersection of camera ray with atmosphere
|
|
244
244
|
rayOrigin = cameraPosition + rayDirection * offset;
|
|
245
|
-
}
|
|
245
|
+
}
|
|
246
246
|
|
|
247
247
|
float height = length(rayOrigin) - BOTTOM_RADIUS;
|
|
248
248
|
float rayAngle = dot(rayOrigin, rayDirection) / length(rayOrigin);
|
|
@@ -258,12 +258,13 @@ function atmosphereBackgroundShader() {
|
|
|
258
258
|
|
|
259
259
|
bool hitGround = intersectSphere(cameraPosition, rayDirection, BOTTOM_RADIUS, distanceToGround) && distanceToGround > 0.0;
|
|
260
260
|
|
|
261
|
-
if(intersectSphere(cameraPosition, rayDirection, BOTTOM_RADIUS - 15000.0, distanceToGround) && hitGround)
|
|
261
|
+
if(intersectSphere(cameraPosition, rayDirection, BOTTOM_RADIUS - 15000.0, distanceToGround) && hitGround)
|
|
262
|
+
{
|
|
262
263
|
discard;
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
float segmentLength = ((hitGround ? distanceToGround : distanceToSpace) - max(offset, 0.0)) / float(SAMPLE_COUNT);
|
|
266
|
-
|
|
267
|
+
|
|
267
268
|
float t = segmentLength * 0.5;
|
|
268
269
|
|
|
269
270
|
vec3 transmittanceCamera;
|
|
@@ -276,17 +277,13 @@ function atmosphereBackgroundShader() {
|
|
|
276
277
|
vec3 up = position / length(position);
|
|
277
278
|
float rayAngle = dot(up, rayDirection);
|
|
278
279
|
float lightAngle = dot(up, lightDirection);
|
|
279
|
-
// shadow is ommitted because it can create banding artifacts with low sample counts
|
|
280
|
-
// float distanceToGround;
|
|
281
|
-
// float shadow = intersectSphere(position, lightDirection, BOTTOM_RADIUS, distanceToGround) && distanceToGround >= 0.0 ? 0.0 : 1.0;
|
|
282
|
-
float shadow = 1.0;
|
|
283
280
|
vec3 transmittanceToSpace = transmittanceFromTexture(height, cameraBelow ? -rayAngle : rayAngle);
|
|
284
281
|
transmittanceCamera = cameraBelow ? (transmittanceToSpace / transmittanceFromCameraToSpace) : (transmittanceFromCameraToSpace / transmittanceToSpace);
|
|
285
282
|
transmittanceLight = transmittanceFromTexture(height, lightAngle);
|
|
286
283
|
vec2 opticalDensity = exp(-height / rayleighMieHeights);
|
|
287
284
|
vec3 scatteredLight = transmittanceLight * (rayleighScatteringCoefficient * opticalDensity.x * rayleighPhase + mieScatteringCoefficient * opticalDensity.y * miePhase);
|
|
288
285
|
scatteredLight += multipleScatteringContributionFromTexture(height, lightAngle) * (rayleighScatteringCoefficient * opticalDensity.x + mieScatteringCoefficient * opticalDensity.y);
|
|
289
|
-
light +=
|
|
286
|
+
light += transmittanceCamera * scatteredLight * segmentLength;
|
|
290
287
|
t += segmentLength;
|
|
291
288
|
}
|
|
292
289
|
|
|
@@ -20,10 +20,10 @@ class LabelWorker extends BaseWorker {
|
|
|
20
20
|
make(data) {
|
|
21
21
|
let label = data.label, handler = data.handler;
|
|
22
22
|
if (handler._entityCollection) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
let labelData = label.serializeWorkerData(this._sourceId);
|
|
24
|
+
if (labelData) {
|
|
25
|
+
if (this._workerQueue.length) {
|
|
26
|
+
let w = this._workerQueue.pop();
|
|
27
27
|
this._source.set(this._sourceId, data);
|
|
28
28
|
label._lockId = this._sourceId;
|
|
29
29
|
this._sourceId++;
|
|
@@ -33,9 +33,9 @@ class LabelWorker extends BaseWorker {
|
|
|
33
33
|
labelData.buffer,
|
|
34
34
|
]);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
else {
|
|
37
|
+
this._pendingQueue.push(data);
|
|
38
|
+
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -116,6 +116,8 @@ class KeyboardHandler {
|
|
|
116
116
|
return this._currentlyPressedKeys[keyCode];
|
|
117
117
|
}
|
|
118
118
|
handleKeyDown() {
|
|
119
|
+
// If you want to get a key code just uncomment and check console
|
|
120
|
+
//console.log(this._event!.keyCode);
|
|
119
121
|
this._anykeyCallback && this._anykeyCallback.callback.call(this._anykeyCallback.sender, this._event);
|
|
120
122
|
this._currentlyPressedKeys[this._event.keyCode] = true;
|
|
121
123
|
for (let ch in this._charkeysCallbacks) {
|
package/lib/js/input/input.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export const input = {
|
|
2
|
+
MB_LEFT: 0,
|
|
3
|
+
MB_RIGHT: 2,
|
|
4
|
+
MB_MIDDLE: 1,
|
|
2
5
|
KEY_CTRL: 17,
|
|
3
6
|
KEY_ALT: 18,
|
|
4
7
|
KEY_SHIFT: 16,
|
|
@@ -34,9 +37,11 @@ export const input = {
|
|
|
34
37
|
KEY_F1: 112,
|
|
35
38
|
KEY_MINUS: 173,
|
|
36
39
|
KEY_APOSTROPHE: 192,
|
|
37
|
-
MB_LEFT: 0,
|
|
38
|
-
MB_RIGHT: 2,
|
|
39
|
-
MB_MIDDLE: 1,
|
|
40
40
|
KEY_BACK_SLASH: 220,
|
|
41
|
+
KEY_MORE: 190,
|
|
42
|
+
KEY_SLASH: 191,
|
|
43
|
+
KEY_LESS: 188,
|
|
44
|
+
KEY_LEFT_SQUARE_BRACKET: 219,
|
|
45
|
+
KEY_RIGHT_SQUARE_BRACKET: 221,
|
|
41
46
|
KEY_SINGLE_QUOTE: 222
|
|
42
47
|
};
|
package/lib/js/scene/Planet.js
CHANGED
|
@@ -112,7 +112,7 @@ export class Planet extends RenderNode {
|
|
|
112
112
|
this._ambient = new Float32Array([a.x, a.y, a.z]);
|
|
113
113
|
this._diffuse = new Float32Array([d.x, d.y, d.z]);
|
|
114
114
|
this._specular = new Float32Array([s.x, s.y, s.z, shininess]);
|
|
115
|
-
this._maxGridSize = Math.log2(options.maxGridSize ||
|
|
115
|
+
this._maxGridSize = Math.log2(options.maxGridSize || 256);
|
|
116
116
|
this.SLICE_SIZE = 4;
|
|
117
117
|
this.SLICE_SIZE_4 = this.SLICE_SIZE * 4;
|
|
118
118
|
this.SLICE_SIZE_3 = this.SLICE_SIZE * 3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.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"
|