@openglobus/og 0.11.8 → 0.12.0
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/css/og.css +2 -0
- package/package.json +1 -1
- package/src/og/Globe.js +18 -6
- package/src/og/camera/Camera.js +70 -79
- package/src/og/camera/PlanetCamera.js +25 -30
- package/src/og/control/DebugInfo.js +2 -2
- package/src/og/control/EarthNavigation.js +26 -17
- package/src/og/control/MouseNavigation.js +11 -13
- package/src/og/control/MouseWheelZoomControl.js +5 -5
- package/src/og/control/Sun.js +3 -3
- package/src/og/entity/Entity.js +742 -742
- package/src/og/entity/GeoObjectHandler.js +102 -117
- package/src/og/entity/LabelHandler.js +2 -1
- package/src/og/layer/XYZ.js +20 -21
- package/src/og/math/Vec3.js +18 -2
- package/src/og/quadTree/Node.js +48 -93
- package/src/og/quadTree/quadTree.js +1 -1
- package/src/og/renderer/Renderer.js +3 -5
- package/src/og/scene/Planet.js +105 -118
- package/src/og/segment/Segment.js +57 -136
- package/src/og/shaders/drawnode.js +132 -221
- package/src/og/terrain/EmptyTerrain.js +3 -2
- package/src/og/terrain/GlobusTerrain.js +2 -0
- package/src/og/utils/Loader.js +1 -1
- package/src/og/utils/PlainSegmentWorker.js +0 -13
- package/src/og/webgl/Handler.js +13 -9
|
@@ -5,39 +5,31 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
import { Program } from "../webgl/Program.js";
|
|
8
|
-
|
|
9
|
-
// REMEMBER!
|
|
8
|
+
|
|
9
|
+
// REMEMBER!
|
|
10
10
|
// src*(1)+dest*(1-src.alpha)
|
|
11
11
|
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
12
12
|
// src*(src.alpha)+dest*(1-src.alpha)
|
|
13
13
|
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const NIGHT = `const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);`;
|
|
14
17
|
|
|
18
|
+
const DEF_BLEND = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
|
|
19
|
+
src = texture( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw ); \
|
|
20
|
+
DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
|
|
15
21
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
void blend(
|
|
20
|
-
out vec4 dest,
|
|
21
|
-
in sampler2D sampler,
|
|
22
|
-
in vec4 tileOffset,
|
|
23
|
-
in float opacity)
|
|
24
|
-
{
|
|
25
|
-
vec4 src = texture( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
26
|
-
//dest = dest * (1.0 - src.a * opacity) + src * opacity;
|
|
27
|
-
dest = vec4(mix(dest.rgb, src.rgb, src.a * opacity), 1.0);
|
|
28
|
-
}`;
|
|
22
|
+
const DEF_BLEND_WEBGL1 = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
|
|
23
|
+
src = texture2D( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw ); \
|
|
24
|
+
DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
|
|
29
25
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
in float opacity)
|
|
36
|
-
{
|
|
37
|
-
vec4 src = texture2D(sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw);
|
|
38
|
-
dest = vec4(mix(dest.rgb, src.rgb, src.a * opacity), 1.0);
|
|
39
|
-
}`
|
|
26
|
+
const DEF_BLEND_PICKING = `#define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) \
|
|
27
|
+
tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; \
|
|
28
|
+
t = texture2D(SAMPLER, tc); \
|
|
29
|
+
p = texture2D(MASK, tc); \
|
|
30
|
+
DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0 : 1.0) * COLOR.a);`
|
|
40
31
|
|
|
32
|
+
|
|
41
33
|
const SLICE_SIZE = 4;
|
|
42
34
|
|
|
43
35
|
export function drawnode_screen_nl() {
|
|
@@ -48,7 +40,7 @@ export function drawnode_screen_nl() {
|
|
|
48
40
|
eyePositionHigh: "vec3",
|
|
49
41
|
eyePositionLow: "vec3",
|
|
50
42
|
samplerCount: "int",
|
|
51
|
-
tileOffsetArr: "vec4",
|
|
43
|
+
tileOffsetArr: "vec4",
|
|
52
44
|
layerOpacityArr: "float",
|
|
53
45
|
samplerArr: "sampler2darray",
|
|
54
46
|
defaultTexture: "sampler2d",
|
|
@@ -85,33 +77,35 @@ export function drawnode_screen_nl() {
|
|
|
85
77
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
86
78
|
}`,
|
|
87
79
|
|
|
88
|
-
fragmentShader: `precision highp float;
|
|
80
|
+
fragmentShader: `precision highp float;
|
|
89
81
|
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
90
|
-
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
82
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
91
83
|
uniform float layerOpacityArr[SLICE_SIZE];
|
|
92
84
|
uniform sampler2D defaultTexture;
|
|
93
85
|
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
94
86
|
uniform int samplerCount;
|
|
95
|
-
varying vec2 vTextureCoord;
|
|
96
|
-
|
|
97
|
-
${
|
|
87
|
+
varying vec2 vTextureCoord;
|
|
88
|
+
|
|
89
|
+
${DEF_BLEND_WEBGL1}
|
|
98
90
|
|
|
99
91
|
void main(void) {
|
|
100
92
|
gl_FragColor = texture2D( defaultTexture, vTextureCoord );
|
|
101
93
|
if( samplerCount == 0 ) return;
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
95
|
+
vec4 src;
|
|
96
|
+
|
|
97
|
+
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
98
|
+
if( samplerCount == 1 ) return;
|
|
99
|
+
|
|
100
|
+
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
101
|
+
if( samplerCount == 2 ) return;
|
|
102
|
+
|
|
103
|
+
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
104
|
+
if( samplerCount == 3 ) return;
|
|
105
|
+
|
|
106
|
+
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
107
|
+
if( samplerCount == 4 ) return;
|
|
108
|
+
|
|
115
109
|
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
116
110
|
}`
|
|
117
111
|
});
|
|
@@ -130,7 +124,7 @@ export function drawnode_screen_wl() {
|
|
|
130
124
|
uNormalMapBias: "vec3",
|
|
131
125
|
|
|
132
126
|
samplerCount: "int",
|
|
133
|
-
tileOffsetArr: "vec4",
|
|
127
|
+
tileOffsetArr: "vec4",
|
|
134
128
|
layerOpacityArr: "float",
|
|
135
129
|
samplerArr: "sampler2darray",
|
|
136
130
|
defaultTexture: "sampler2d",
|
|
@@ -199,7 +193,7 @@ export function drawnode_screen_wl() {
|
|
|
199
193
|
uniform sampler2D nightTexture;
|
|
200
194
|
uniform sampler2D specularTexture;
|
|
201
195
|
|
|
202
|
-
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
196
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
203
197
|
uniform float layerOpacityArr[SLICE_SIZE];
|
|
204
198
|
|
|
205
199
|
uniform sampler2D defaultTexture;
|
|
@@ -210,10 +204,10 @@ export function drawnode_screen_wl() {
|
|
|
210
204
|
varying vec2 vGlobalTextureCoord;
|
|
211
205
|
varying vec4 v_vertex;
|
|
212
206
|
varying float v_height;
|
|
213
|
-
|
|
207
|
+
|
|
214
208
|
${NIGHT}
|
|
215
|
-
|
|
216
|
-
${
|
|
209
|
+
|
|
210
|
+
${DEF_BLEND}
|
|
217
211
|
|
|
218
212
|
|
|
219
213
|
void main(void) {
|
|
@@ -234,36 +228,38 @@ export function drawnode_screen_wl() {
|
|
|
234
228
|
vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting + spec + night;
|
|
235
229
|
|
|
236
230
|
gl_FragColor = texture2D( defaultTexture, vTextureCoord.xy );
|
|
237
|
-
if( samplerCount == 0 ) {
|
|
238
|
-
gl_FragColor *= lightWeighting;
|
|
239
|
-
return;
|
|
231
|
+
if( samplerCount == 0 ) {
|
|
232
|
+
gl_FragColor *= lightWeighting;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
vec4 src;
|
|
237
|
+
|
|
238
|
+
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
239
|
+
if( samplerCount == 1 ) {
|
|
240
|
+
gl_FragColor *= lightWeighting;
|
|
241
|
+
return;
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
blend(gl_FragColor, samplerArr[
|
|
243
|
-
if( samplerCount ==
|
|
244
|
-
gl_FragColor *= lightWeighting;
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
blend(gl_FragColor, samplerArr[
|
|
249
|
-
if( samplerCount ==
|
|
250
|
-
gl_FragColor *= lightWeighting;
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
blend(gl_FragColor, samplerArr[
|
|
255
|
-
if( samplerCount ==
|
|
256
|
-
gl_FragColor *= lightWeighting;
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
blend(gl_FragColor, samplerArr[
|
|
261
|
-
if( samplerCount == 4 ) {
|
|
262
|
-
gl_FragColor *= lightWeighting;
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
244
|
+
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
245
|
+
if( samplerCount == 2 ) {
|
|
246
|
+
gl_FragColor *= lightWeighting;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
251
|
+
if( samplerCount == 3 ) {
|
|
252
|
+
gl_FragColor *= lightWeighting;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
257
|
+
if( samplerCount == 4 ) {
|
|
258
|
+
gl_FragColor *= lightWeighting;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
267
263
|
gl_FragColor *= lightWeighting;
|
|
268
264
|
}`
|
|
269
265
|
});
|
|
@@ -282,7 +278,7 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
282
278
|
uNormalMapBias: "vec3",
|
|
283
279
|
|
|
284
280
|
samplerCount: "int",
|
|
285
|
-
tileOffsetArr: "vec4",
|
|
281
|
+
tileOffsetArr: "vec4",
|
|
286
282
|
layerOpacityArr: "float",
|
|
287
283
|
samplerArr: "sampler2darray",
|
|
288
284
|
defaultTexture: "sampler2d",
|
|
@@ -301,7 +297,7 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
301
297
|
aTextureCoord: "vec2"
|
|
302
298
|
},
|
|
303
299
|
|
|
304
|
-
vertexShader: `#version 300 es
|
|
300
|
+
vertexShader: `#version 300 es
|
|
305
301
|
|
|
306
302
|
in vec3 aVertexPositionHigh;
|
|
307
303
|
in vec3 aVertexPositionLow;
|
|
@@ -355,7 +351,7 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
355
351
|
uniform sampler2D nightTexture;
|
|
356
352
|
uniform sampler2D specularTexture;
|
|
357
353
|
|
|
358
|
-
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
354
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
359
355
|
uniform float layerOpacityArr[SLICE_SIZE];
|
|
360
356
|
|
|
361
357
|
uniform sampler2D defaultTexture;
|
|
@@ -365,7 +361,7 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
365
361
|
in vec4 vTextureCoord;
|
|
366
362
|
in vec2 vGlobalTextureCoord;
|
|
367
363
|
in vec4 v_vertex;
|
|
368
|
-
in float v_height;
|
|
364
|
+
in float v_height;
|
|
369
365
|
|
|
370
366
|
float shininess;
|
|
371
367
|
float reflection;
|
|
@@ -374,60 +370,62 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
374
370
|
|
|
375
371
|
layout(location = 0) out vec4 fragColor;
|
|
376
372
|
|
|
377
|
-
${NIGHT}
|
|
378
|
-
|
|
379
|
-
${BLEND}
|
|
373
|
+
${NIGHT}
|
|
380
374
|
|
|
381
|
-
|
|
375
|
+
${DEF_BLEND}
|
|
376
|
+
|
|
377
|
+
void main(void) {
|
|
382
378
|
|
|
383
379
|
float overGround = 1.0 - step(0.1, v_height);
|
|
384
380
|
vec3 normal = normalize(normalMatrix * ((texture(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
|
|
385
381
|
vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
|
|
386
382
|
vec3 eyeDirection = normalize(-v_vertex.xyz);
|
|
387
383
|
vec3 reflectionDirection = reflect(-lightDirection, normal);
|
|
388
|
-
vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
|
|
384
|
+
vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
|
|
389
385
|
|
|
390
386
|
shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
391
387
|
reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
|
|
392
388
|
diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
|
|
393
389
|
night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
|
|
394
390
|
night *= overGround * step(0.0, night);
|
|
395
|
-
|
|
391
|
+
|
|
396
392
|
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
397
|
-
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
|
|
393
|
+
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
|
|
398
394
|
|
|
399
395
|
fragColor = texture( defaultTexture, vTextureCoord.xy );
|
|
400
|
-
if( samplerCount == 0 ) {
|
|
401
|
-
fragColor *= lightWeighting;
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
blend(fragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
406
|
-
if( samplerCount == 1 ) {
|
|
407
|
-
fragColor *= lightWeighting;
|
|
408
|
-
return;
|
|
396
|
+
if( samplerCount == 0 ) {
|
|
397
|
+
fragColor *= lightWeighting;
|
|
398
|
+
return;
|
|
409
399
|
}
|
|
410
400
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
401
|
+
vec4 src;
|
|
402
|
+
|
|
403
|
+
blend(fragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
404
|
+
if( samplerCount == 1 ) {
|
|
405
|
+
fragColor *= lightWeighting;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
blend(fragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
410
|
+
if( samplerCount == 2 ) {
|
|
411
|
+
fragColor *= lightWeighting;
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
blend(fragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
416
|
+
if( samplerCount == 3 ) {
|
|
417
|
+
fragColor *= lightWeighting;
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
blend(fragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
422
|
+
if( samplerCount == 4 ) {
|
|
423
|
+
fragColor *= lightWeighting;
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
blend(fragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
428
|
+
fragColor *= lightWeighting;
|
|
431
429
|
}`
|
|
432
430
|
});
|
|
433
431
|
}
|
|
@@ -477,32 +475,24 @@ export function drawnode_colorPicking() {
|
|
|
477
475
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
478
476
|
}`,
|
|
479
477
|
|
|
480
|
-
fragmentShader: `precision highp float;
|
|
478
|
+
fragmentShader: `precision highp float;
|
|
481
479
|
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
482
480
|
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
483
481
|
uniform vec4 pickingColorArr[SLICE_SIZE];
|
|
484
482
|
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
485
483
|
uniform sampler2D pickingMaskArr[SLICE_SIZE];
|
|
486
484
|
uniform int samplerCount;
|
|
487
|
-
varying vec2 vTextureCoord;
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
out vec4 dest,
|
|
491
|
-
in vec4 tileOffset,
|
|
492
|
-
in sampler2D sampler,
|
|
493
|
-
in sampler2D pickingMask,
|
|
494
|
-
in vec4 pickingColor,
|
|
495
|
-
in float opacity)
|
|
496
|
-
{
|
|
497
|
-
vec2 tc = tileOffset.xy + vTextureCoord.xy * tileOffset.zw;
|
|
498
|
-
vec4 t = texture2D( sampler, tc );
|
|
499
|
-
vec4 p = texture2D( pickingMask, tc );
|
|
500
|
-
dest = mix( dest, vec4(max(pickingColor.rgb, p.rgb), opacity), (t.a == 0.0 ? 0.0 : 1.0) * pickingColor.a);
|
|
501
|
-
}
|
|
485
|
+
varying vec2 vTextureCoord;
|
|
486
|
+
|
|
487
|
+
${DEF_BLEND_PICKING}
|
|
502
488
|
|
|
503
489
|
void main(void) {
|
|
504
490
|
gl_FragColor = vec4(0.0);
|
|
505
491
|
if( samplerCount == 0 ) return;
|
|
492
|
+
|
|
493
|
+
vec2 tc;
|
|
494
|
+
vec4 t;
|
|
495
|
+
vec4 p;
|
|
506
496
|
|
|
507
497
|
blendPicking(gl_FragColor, tileOffsetArr[0], samplerArr[0], pickingMaskArr[0], pickingColorArr[0], 1.0);
|
|
508
498
|
if( samplerCount == 1 ) return;
|
|
@@ -526,23 +516,17 @@ export function drawnode_heightPicking() {
|
|
|
526
516
|
uniforms: {
|
|
527
517
|
projectionMatrix: "mat4",
|
|
528
518
|
viewMatrix: "mat4",
|
|
529
|
-
samplerCount: "int",
|
|
530
|
-
tileOffsetArr: "vec4",
|
|
531
|
-
samplerArr: "sampler2darray",
|
|
532
|
-
defaultTexture: "sampler2d",
|
|
533
519
|
height: "float",
|
|
534
520
|
eyePositionHigh: "vec3",
|
|
535
521
|
eyePositionLow: "vec3"
|
|
536
522
|
},
|
|
537
523
|
attributes: {
|
|
538
524
|
aVertexPositionHigh: "vec3",
|
|
539
|
-
aVertexPositionLow: "vec3"
|
|
540
|
-
aTextureCoord: "vec2"
|
|
525
|
+
aVertexPositionLow: "vec3"
|
|
541
526
|
},
|
|
542
527
|
|
|
543
528
|
vertexShader: `attribute vec3 aVertexPositionHigh;
|
|
544
529
|
attribute vec3 aVertexPositionLow;
|
|
545
|
-
attribute vec2 aTextureCoord;
|
|
546
530
|
|
|
547
531
|
uniform mat4 projectionMatrix;
|
|
548
532
|
uniform mat4 viewMatrix;
|
|
@@ -550,7 +534,6 @@ export function drawnode_heightPicking() {
|
|
|
550
534
|
uniform vec3 eyePositionHigh;
|
|
551
535
|
uniform vec3 eyePositionLow;
|
|
552
536
|
|
|
553
|
-
varying vec2 vTextureCoord;
|
|
554
537
|
varying float range;
|
|
555
538
|
|
|
556
539
|
void main(void) {
|
|
@@ -565,17 +548,11 @@ export function drawnode_heightPicking() {
|
|
|
565
548
|
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
566
549
|
|
|
567
550
|
range = distance(cameraPosition, aVertexPosition + normalize(aVertexPosition) * height);
|
|
568
|
-
vTextureCoord = aTextureCoord;
|
|
569
551
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
570
552
|
}`,
|
|
571
553
|
|
|
572
|
-
fragmentShader: `precision highp float;
|
|
573
|
-
|
|
574
|
-
uniform sampler2D defaultTexture;
|
|
575
|
-
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
576
|
-
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
577
|
-
uniform int samplerCount;
|
|
578
|
-
varying vec2 vTextureCoord;
|
|
554
|
+
fragmentShader: `precision highp float;
|
|
555
|
+
|
|
579
556
|
varying float range;
|
|
580
557
|
|
|
581
558
|
vec3 encode24(highp float f) {
|
|
@@ -591,29 +568,7 @@ export function drawnode_heightPicking() {
|
|
|
591
568
|
}
|
|
592
569
|
|
|
593
570
|
void main(void) {
|
|
594
|
-
gl_FragColor = vec4(encode24(range),
|
|
595
|
-
if( samplerCount == 0 ) return;
|
|
596
|
-
|
|
597
|
-
vec4 t = texture2D( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw );
|
|
598
|
-
gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
599
|
-
//
|
|
600
|
-
// TODO: Seems to be it is not necessary
|
|
601
|
-
//if( samplerCount == 1 ) return;
|
|
602
|
-
|
|
603
|
-
//t = texture2D( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw );
|
|
604
|
-
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
605
|
-
//if( samplerCount == 2 ) return;
|
|
606
|
-
|
|
607
|
-
//t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw );
|
|
608
|
-
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
609
|
-
//if( samplerCount == 3 ) return;
|
|
610
|
-
|
|
611
|
-
//t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw );
|
|
612
|
-
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
613
|
-
//if( samplerCount == 4 ) return;
|
|
614
|
-
|
|
615
|
-
//t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw );
|
|
616
|
-
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
571
|
+
gl_FragColor = vec4(encode24(range), 1.0);
|
|
617
572
|
}`
|
|
618
573
|
});
|
|
619
574
|
}
|
|
@@ -623,10 +578,6 @@ export function drawnode_depth() {
|
|
|
623
578
|
uniforms: {
|
|
624
579
|
projectionMatrix: "mat4",
|
|
625
580
|
viewMatrix: "mat4",
|
|
626
|
-
samplerCount: "int",
|
|
627
|
-
tileOffsetArr: "vec4",
|
|
628
|
-
samplerArr: "sampler2darray",
|
|
629
|
-
defaultTexture: "sampler2d",
|
|
630
581
|
height: "float",
|
|
631
582
|
eyePositionHigh: "vec3",
|
|
632
583
|
eyePositionLow: "vec3",
|
|
@@ -634,14 +585,11 @@ export function drawnode_depth() {
|
|
|
634
585
|
},
|
|
635
586
|
attributes: {
|
|
636
587
|
aVertexPositionHigh: "vec3",
|
|
637
|
-
aVertexPositionLow: "vec3"
|
|
638
|
-
aTextureCoord: "vec2"
|
|
588
|
+
aVertexPositionLow: "vec3"
|
|
639
589
|
},
|
|
640
590
|
|
|
641
|
-
vertexShader:
|
|
642
|
-
|
|
643
|
-
in vec3 aVertexPositionLow;
|
|
644
|
-
in vec2 aTextureCoord;
|
|
591
|
+
vertexShader: `attribute vec3 aVertexPositionHigh;
|
|
592
|
+
attribute vec3 aVertexPositionLow;
|
|
645
593
|
|
|
646
594
|
uniform mat4 projectionMatrix;
|
|
647
595
|
uniform mat4 viewMatrix;
|
|
@@ -649,8 +597,6 @@ export function drawnode_depth() {
|
|
|
649
597
|
uniform vec3 eyePositionHigh;
|
|
650
598
|
uniform vec3 eyePositionLow;
|
|
651
599
|
|
|
652
|
-
out vec2 vTextureCoord;
|
|
653
|
-
|
|
654
600
|
void main(void) {
|
|
655
601
|
|
|
656
602
|
vec3 cameraPosition = eyePositionHigh + eyePositionLow;
|
|
@@ -662,49 +608,14 @@ export function drawnode_depth() {
|
|
|
662
608
|
mat4 viewMatrixRTE = viewMatrix;
|
|
663
609
|
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
664
610
|
|
|
665
|
-
vTextureCoord = aTextureCoord;
|
|
666
611
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
667
612
|
}`,
|
|
668
613
|
|
|
669
|
-
fragmentShader:
|
|
670
|
-
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
671
|
-
precision highp float;
|
|
672
|
-
uniform sampler2D defaultTexture;
|
|
673
|
-
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
674
|
-
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
675
|
-
uniform int samplerCount;
|
|
614
|
+
fragmentShader: `precision highp float;
|
|
676
615
|
uniform vec3 frustumPickingColor;
|
|
677
616
|
|
|
678
|
-
in vec2 vTextureCoord;
|
|
679
|
-
|
|
680
|
-
layout(location = 0) out vec4 frustumColor;
|
|
681
|
-
|
|
682
617
|
void main(void) {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
if(samplerCount == 0) return;
|
|
686
|
-
|
|
687
|
-
vec4 t = texture(samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw);
|
|
688
|
-
frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
689
|
-
|
|
690
|
-
//
|
|
691
|
-
// TODO: Seems to be it is not necessary
|
|
692
|
-
//if (samplerCount == 1) return;
|
|
693
|
-
|
|
694
|
-
//t = texture(samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw);
|
|
695
|
-
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
696
|
-
//if (samplerCount == 2) return;
|
|
697
|
-
|
|
698
|
-
//t = texture(samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw);
|
|
699
|
-
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
700
|
-
//if (samplerCount == 3) return;
|
|
701
|
-
|
|
702
|
-
//t = texture(samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw);
|
|
703
|
-
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
704
|
-
//if (samplerCount == 4) return;
|
|
705
|
-
|
|
706
|
-
//t = texture(samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw);
|
|
707
|
-
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
708
|
-
} `
|
|
618
|
+
gl_FragColor = vec4(frustumPickingColor, 1.0);
|
|
619
|
+
} `
|
|
709
620
|
});
|
|
710
621
|
}
|
|
@@ -14,7 +14,9 @@ class EmptyTerrain {
|
|
|
14
14
|
constructor(options = {}) {
|
|
15
15
|
this.equalizeVertices = false;
|
|
16
16
|
|
|
17
|
-
this.equalizeNormals = false;
|
|
17
|
+
this.equalizeNormals = false;
|
|
18
|
+
|
|
19
|
+
this.isEmpty = true;
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Provider name is "empty"
|
|
@@ -106,7 +108,6 @@ class EmptyTerrain {
|
|
|
106
108
|
|
|
107
109
|
set geoid(geoid) {
|
|
108
110
|
this._geoid = geoid;
|
|
109
|
-
//...this._planet
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
get geoid() {
|
package/src/og/utils/Loader.js
CHANGED
|
@@ -222,19 +222,6 @@ const _programm = `
|
|
|
222
222
|
res.x = nc * Math.sin(lonrad);
|
|
223
223
|
res.y = (N * (1.0 - E2) + h) * slt;
|
|
224
224
|
res.z = nc * Math.cos(lonrad);
|
|
225
|
-
|
|
226
|
-
//let cosLat = Math.cos(lat * RADIANS)
|
|
227
|
-
//let sinLat = Math.sin(lat * RADIANS)
|
|
228
|
-
|
|
229
|
-
//let cosLong = Math.cos(lon * RADIANS)
|
|
230
|
-
//let sinLong = Math.sin(lon * RADIANS)
|
|
231
|
-
|
|
232
|
-
//let c = 1.0 / Math.sqrt(cosLat * cosLat + (1 - f) * (1 - f) * sinLat * sinLat)
|
|
233
|
-
//s = (1 - f) * (1 - f) * c
|
|
234
|
-
|
|
235
|
-
//x = (R*c + altitude) * cosLat * cosLong
|
|
236
|
-
//y = (R*c + altitude) * cosLat * sinLong
|
|
237
|
-
//z = (R*s + altitude) * sinLat
|
|
238
225
|
};
|
|
239
226
|
|
|
240
227
|
var lonLatToCartesianInverse = function (lon, lat, heightFactor, res){
|
package/src/og/webgl/Handler.js
CHANGED
|
@@ -646,13 +646,17 @@ class Handler {
|
|
|
646
646
|
this.initializeExtension(this._params.extensions[i], true);
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
649
|
+
if (this.gl.type === "webgl") {
|
|
650
|
+
this.createTexture_n = this.createTexture_n_webgl1.bind(this);
|
|
651
|
+
this.createTexture_l = this.createTexture_l_webgl1.bind(this);
|
|
652
|
+
this.createTexture_mm = this.createTexture_mm_webgl1.bind(this);
|
|
653
|
+
this.createTexture_a = this.createTexture_a_webgl1.bind(this);
|
|
654
|
+
} else {
|
|
655
|
+
this.createTexture_n = this.createTexture_n_webgl2.bind(this);
|
|
656
|
+
this.createTexture_l = this.createTexture_l_webgl2.bind(this);
|
|
657
|
+
this.createTexture_mm = this.createTexture_mm_webgl2.bind(this);
|
|
658
|
+
this.createTexture_a = this.createTexture_a_webgl2.bind(this);
|
|
659
|
+
}
|
|
656
660
|
|
|
657
661
|
this.createTexture["NEAREST"] = this.createTexture_n;
|
|
658
662
|
this.createTexture["LINEAR"] = this.createTexture_l;
|
|
@@ -979,7 +983,7 @@ class Handler {
|
|
|
979
983
|
if (params && params.color) {
|
|
980
984
|
imgCnv = new ImageCanvas(2, 2);
|
|
981
985
|
imgCnv.fillColor(params.color);
|
|
982
|
-
texture = this.createTexture_n_webgl2(imgCnv._canvas
|
|
986
|
+
texture = this.createTexture_n_webgl2(imgCnv._canvas);
|
|
983
987
|
texture.default = true;
|
|
984
988
|
success(texture);
|
|
985
989
|
} else if (params && params.url) {
|
|
@@ -994,7 +998,7 @@ class Handler {
|
|
|
994
998
|
} else {
|
|
995
999
|
imgCnv = new ImageCanvas(2, 2);
|
|
996
1000
|
imgCnv.fillColor("#C5C5C5");
|
|
997
|
-
texture = this.createTexture_n_webgl2(imgCnv._canvas
|
|
1001
|
+
texture = this.createTexture_n_webgl2(imgCnv._canvas);
|
|
998
1002
|
texture.default = true;
|
|
999
1003
|
success(texture);
|
|
1000
1004
|
}
|