@openglobus/og 0.15.2 → 0.15.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "[OpenGlobus](https://www.openglobus.org/) is a javascript 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"
|
|
@@ -494,8 +494,6 @@ class Renderer {
|
|
|
494
494
|
|
|
495
495
|
this.handler.addPrograms([depth()]);
|
|
496
496
|
|
|
497
|
-
this.handler.addProgram(pickingMask());
|
|
498
|
-
|
|
499
497
|
this.sceneFramebuffer = new Multisample(this.handler, {
|
|
500
498
|
size: 1,
|
|
501
499
|
msaa: this._msaa,
|
|
@@ -527,6 +525,8 @@ class Renderer {
|
|
|
527
525
|
};
|
|
528
526
|
}
|
|
529
527
|
|
|
528
|
+
this.handler.addProgram(pickingMask());
|
|
529
|
+
|
|
530
530
|
this.handler.ONCANVASRESIZE = () => {
|
|
531
531
|
this._resizeStart();
|
|
532
532
|
this.events.dispatch(this.events.resize, this.handler.canvas);
|
|
@@ -6,6 +6,188 @@
|
|
|
6
6
|
|
|
7
7
|
import { Program } from '../webgl/Program.js';
|
|
8
8
|
|
|
9
|
+
export function polyline_screen() {
|
|
10
|
+
return new Program("polyline_screen", {
|
|
11
|
+
uniforms: {
|
|
12
|
+
viewport: "vec2",
|
|
13
|
+
proj: "mat4",
|
|
14
|
+
view: "mat4",
|
|
15
|
+
eyePositionHigh: "vec3",
|
|
16
|
+
eyePositionLow: "vec3",
|
|
17
|
+
uFloatParams: "vec2",
|
|
18
|
+
thickness: "float",
|
|
19
|
+
opacity: "float",
|
|
20
|
+
depthOffset: "float"
|
|
21
|
+
},
|
|
22
|
+
attributes: {
|
|
23
|
+
prevHigh: "vec3",
|
|
24
|
+
currentHigh: "vec3",
|
|
25
|
+
nextHigh: "vec3",
|
|
26
|
+
|
|
27
|
+
prevLow: "vec3",
|
|
28
|
+
currentLow: "vec3",
|
|
29
|
+
nextLow: "vec3",
|
|
30
|
+
|
|
31
|
+
order: "float",
|
|
32
|
+
|
|
33
|
+
color: "vec4"
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
vertexShader:
|
|
37
|
+
`precision highp float;
|
|
38
|
+
|
|
39
|
+
attribute vec3 prevHigh;
|
|
40
|
+
attribute vec3 currentHigh;
|
|
41
|
+
attribute vec3 nextHigh;
|
|
42
|
+
|
|
43
|
+
attribute vec3 prevLow;
|
|
44
|
+
attribute vec3 currentLow;
|
|
45
|
+
attribute vec3 nextLow;
|
|
46
|
+
|
|
47
|
+
attribute float order;
|
|
48
|
+
|
|
49
|
+
attribute vec4 color;
|
|
50
|
+
|
|
51
|
+
uniform float thickness;
|
|
52
|
+
uniform mat4 proj;
|
|
53
|
+
uniform mat4 view;
|
|
54
|
+
uniform vec2 viewport;
|
|
55
|
+
uniform vec3 eyePositionHigh;
|
|
56
|
+
uniform vec3 eyePositionLow;
|
|
57
|
+
uniform float opacity;
|
|
58
|
+
uniform float depthOffset;
|
|
59
|
+
|
|
60
|
+
varying vec4 vColor;
|
|
61
|
+
varying vec3 vPos;
|
|
62
|
+
varying vec3 uCamPos;
|
|
63
|
+
|
|
64
|
+
const float NEAR = -1.0;
|
|
65
|
+
|
|
66
|
+
vec2 getIntersection(vec2 start1, vec2 end1, vec2 start2, vec2 end2){
|
|
67
|
+
vec2 dir = end2 - start2;
|
|
68
|
+
vec2 perp = vec2(-dir.y, dir.x);
|
|
69
|
+
float d2 = dot(perp, start2);
|
|
70
|
+
float seg = dot(perp, start1) - d2;
|
|
71
|
+
float prl = seg - dot(perp, end1) + d2;
|
|
72
|
+
if(prl > -1.0 && prl < 1.0){
|
|
73
|
+
return start1;
|
|
74
|
+
}
|
|
75
|
+
float u = seg / prl;
|
|
76
|
+
return start1 + u * (end1 - start1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
vec2 project(vec4 p){
|
|
80
|
+
return (0.5 * p.xyz / p.w + 0.5).xy * viewport;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void main(){
|
|
84
|
+
|
|
85
|
+
uCamPos = eyePositionHigh + eyePositionLow;
|
|
86
|
+
|
|
87
|
+
vColor = vec4(color.rgb, color.a * opacity);
|
|
88
|
+
|
|
89
|
+
vec3 current = currentHigh + currentLow;
|
|
90
|
+
|
|
91
|
+
vPos = current;
|
|
92
|
+
|
|
93
|
+
mat4 viewMatrixRTE = view;
|
|
94
|
+
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
95
|
+
|
|
96
|
+
vec3 highDiff, lowDiff;
|
|
97
|
+
|
|
98
|
+
highDiff = currentHigh - eyePositionHigh;
|
|
99
|
+
lowDiff = currentLow - eyePositionLow;
|
|
100
|
+
vec4 vCurrent = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
101
|
+
|
|
102
|
+
highDiff = prevHigh - eyePositionHigh;
|
|
103
|
+
lowDiff = prevLow - eyePositionLow;
|
|
104
|
+
vec4 vPrev = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
105
|
+
|
|
106
|
+
highDiff = nextHigh - eyePositionHigh;
|
|
107
|
+
lowDiff = nextLow - eyePositionLow;
|
|
108
|
+
vec4 vNext = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
109
|
+
|
|
110
|
+
/*Clip near plane, the point behind view plane*/
|
|
111
|
+
if(vCurrent.z > NEAR) {
|
|
112
|
+
if(vPrev.z < NEAR && abs(order) == 1.0){
|
|
113
|
+
vCurrent = vPrev + (vCurrent - vPrev) * (NEAR - vPrev.z) / (vCurrent.z - vPrev.z);
|
|
114
|
+
} else if(vNext.z < NEAR && abs(order) == 2.0){
|
|
115
|
+
vCurrent = vNext + (vCurrent - vNext) * (NEAR - vNext.z) / (vCurrent.z - vNext.z);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
vec4 dCurrent = proj * vCurrent;
|
|
120
|
+
vec2 _next = project(proj * vNext);
|
|
121
|
+
vec2 _prev = project(proj * vPrev);
|
|
122
|
+
vec2 _current = project(dCurrent);
|
|
123
|
+
|
|
124
|
+
if(_prev == _current){
|
|
125
|
+
if(_next == _current){
|
|
126
|
+
_next = _current + vec2(1.0, 0.0);
|
|
127
|
+
_prev = _current - _next;
|
|
128
|
+
}else{
|
|
129
|
+
_prev = _current + normalize(_current - _next);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if(_next == _current){
|
|
134
|
+
_next = _current + normalize(_current - _prev);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
vec2 sNext = _next,
|
|
138
|
+
sCurrent = _current,
|
|
139
|
+
sPrev = _prev;
|
|
140
|
+
|
|
141
|
+
vec2 dirNext = normalize(sNext - sCurrent);
|
|
142
|
+
vec2 dirPrev = normalize(sPrev - sCurrent);
|
|
143
|
+
float dotNP = dot(dirNext, dirPrev);
|
|
144
|
+
|
|
145
|
+
vec2 normalNext = normalize(vec2(-dirNext.y, dirNext.x));
|
|
146
|
+
vec2 normalPrev = normalize(vec2(dirPrev.y, -dirPrev.x));
|
|
147
|
+
|
|
148
|
+
float d = thickness * sign(order);
|
|
149
|
+
|
|
150
|
+
vec2 m;
|
|
151
|
+
if(dotNP >= 0.99991){
|
|
152
|
+
m = sCurrent - normalPrev * d;
|
|
153
|
+
}else{
|
|
154
|
+
m = getIntersection( sCurrent + normalPrev * d, sPrev + normalPrev * d,
|
|
155
|
+
sCurrent + normalNext * d, sNext + normalNext * d );
|
|
156
|
+
|
|
157
|
+
if( dotNP > 0.5 && dot(dirNext + dirPrev, m - sCurrent) < 0.0 ){
|
|
158
|
+
float occw = order * sign(dirNext.x * dirPrev.y - dirNext.y * dirPrev.x);
|
|
159
|
+
if(occw == -1.0){
|
|
160
|
+
m = sCurrent + normalPrev * d;
|
|
161
|
+
}else if(occw == 1.0){
|
|
162
|
+
m = sCurrent + normalNext * d;
|
|
163
|
+
}else if(occw == -2.0){
|
|
164
|
+
m = sCurrent + normalNext * d;
|
|
165
|
+
}else if(occw == 2.0){
|
|
166
|
+
m = sCurrent + normalPrev * d;
|
|
167
|
+
}
|
|
168
|
+
}else if(distance(sCurrent, m) > min(distance(sCurrent, sNext), distance(sCurrent, sPrev))){
|
|
169
|
+
m = sCurrent + normalNext * d;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
gl_Position = vec4((2.0 * m / viewport - 1.0) * dCurrent.w, dCurrent.z + depthOffset, dCurrent.w);
|
|
174
|
+
}`,
|
|
175
|
+
|
|
176
|
+
fragmentShader:
|
|
177
|
+
`precision highp float;
|
|
178
|
+
uniform vec2 uFloatParams;
|
|
179
|
+
varying vec3 uCamPos;
|
|
180
|
+
varying vec4 vColor;
|
|
181
|
+
varying vec3 vPos;
|
|
182
|
+
void main() {
|
|
183
|
+
vec3 look = vPos - uCamPos;
|
|
184
|
+
float lookLength = length(look);
|
|
185
|
+
float a = vColor.a * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(vPos,vPos) - uFloatParams[0]));
|
|
186
|
+
gl_FragColor = vec4(vColor.rgb, a);
|
|
187
|
+
}`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
9
191
|
// export function polyline_screen() {
|
|
10
192
|
// return new Program("polyline_screen", {
|
|
11
193
|
// uniforms: {
|
|
@@ -34,19 +216,21 @@ import { Program } from '../webgl/Program.js';
|
|
|
34
216
|
// },
|
|
35
217
|
//
|
|
36
218
|
// vertexShader:
|
|
37
|
-
//
|
|
219
|
+
// `#version 300 es
|
|
38
220
|
//
|
|
39
|
-
//
|
|
40
|
-
// attribute vec3 currentHigh;
|
|
41
|
-
// attribute vec3 nextHigh;
|
|
221
|
+
// precision highp float;
|
|
42
222
|
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
223
|
+
// in vec3 prevHigh;
|
|
224
|
+
// in vec3 currentHigh;
|
|
225
|
+
// in vec3 nextHigh;
|
|
46
226
|
//
|
|
47
|
-
//
|
|
227
|
+
// in vec3 prevLow;
|
|
228
|
+
// in vec3 currentLow;
|
|
229
|
+
// in vec3 nextLow;
|
|
48
230
|
//
|
|
49
|
-
//
|
|
231
|
+
// in float order;
|
|
232
|
+
//
|
|
233
|
+
// in vec4 color;
|
|
50
234
|
//
|
|
51
235
|
// uniform float thickness;
|
|
52
236
|
// uniform mat4 proj;
|
|
@@ -57,9 +241,9 @@ import { Program } from '../webgl/Program.js';
|
|
|
57
241
|
// uniform float opacity;
|
|
58
242
|
// uniform float depthOffset;
|
|
59
243
|
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
244
|
+
// out vec4 vColor;
|
|
245
|
+
// out vec3 vPos;
|
|
246
|
+
// out vec3 uCamPos;
|
|
63
247
|
//
|
|
64
248
|
// const float NEAR = -1.0;
|
|
65
249
|
//
|
|
@@ -174,215 +358,31 @@ import { Program } from '../webgl/Program.js';
|
|
|
174
358
|
// }`,
|
|
175
359
|
//
|
|
176
360
|
// fragmentShader:
|
|
177
|
-
//
|
|
361
|
+
// `#version 300 es
|
|
362
|
+
//
|
|
363
|
+
// precision highp float;
|
|
364
|
+
//
|
|
178
365
|
// uniform vec2 uFloatParams;
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
//
|
|
366
|
+
//
|
|
367
|
+
// layout(location = 0) out vec4 diffuseColor;
|
|
368
|
+
// layout(location = 1) out vec4 normalColor;
|
|
369
|
+
// layout(location = 2) out vec4 distanceColor;
|
|
370
|
+
//
|
|
371
|
+
// in vec3 uCamPos;
|
|
372
|
+
// in vec4 vColor;
|
|
373
|
+
// in vec3 vPos;
|
|
374
|
+
//
|
|
182
375
|
// void main() {
|
|
183
376
|
// vec3 look = vPos - uCamPos;
|
|
184
377
|
// float lookLength = length(look);
|
|
185
378
|
// float a = vColor.a * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(vPos,vPos) - uFloatParams[0]));
|
|
186
|
-
//
|
|
379
|
+
// diffuseColor = vec4(vColor.rgb, a);
|
|
380
|
+
// normalColor = vec4(1.0);
|
|
381
|
+
// distanceColor = vec4(1.0);
|
|
187
382
|
// }`
|
|
188
383
|
// });
|
|
189
384
|
// }
|
|
190
385
|
|
|
191
|
-
export function polyline_screen() {
|
|
192
|
-
return new Program("polyline_screen", {
|
|
193
|
-
uniforms: {
|
|
194
|
-
viewport: "vec2",
|
|
195
|
-
proj: "mat4",
|
|
196
|
-
view: "mat4",
|
|
197
|
-
eyePositionHigh: "vec3",
|
|
198
|
-
eyePositionLow: "vec3",
|
|
199
|
-
uFloatParams: "vec2",
|
|
200
|
-
thickness: "float",
|
|
201
|
-
opacity: "float",
|
|
202
|
-
depthOffset: "float"
|
|
203
|
-
},
|
|
204
|
-
attributes: {
|
|
205
|
-
prevHigh: "vec3",
|
|
206
|
-
currentHigh: "vec3",
|
|
207
|
-
nextHigh: "vec3",
|
|
208
|
-
|
|
209
|
-
prevLow: "vec3",
|
|
210
|
-
currentLow: "vec3",
|
|
211
|
-
nextLow: "vec3",
|
|
212
|
-
|
|
213
|
-
order: "float",
|
|
214
|
-
|
|
215
|
-
color: "vec4"
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
vertexShader:
|
|
219
|
-
`#version 300 es
|
|
220
|
-
|
|
221
|
-
precision highp float;
|
|
222
|
-
|
|
223
|
-
in vec3 prevHigh;
|
|
224
|
-
in vec3 currentHigh;
|
|
225
|
-
in vec3 nextHigh;
|
|
226
|
-
|
|
227
|
-
in vec3 prevLow;
|
|
228
|
-
in vec3 currentLow;
|
|
229
|
-
in vec3 nextLow;
|
|
230
|
-
|
|
231
|
-
in float order;
|
|
232
|
-
|
|
233
|
-
in vec4 color;
|
|
234
|
-
|
|
235
|
-
uniform float thickness;
|
|
236
|
-
uniform mat4 proj;
|
|
237
|
-
uniform mat4 view;
|
|
238
|
-
uniform vec2 viewport;
|
|
239
|
-
uniform vec3 eyePositionHigh;
|
|
240
|
-
uniform vec3 eyePositionLow;
|
|
241
|
-
uniform float opacity;
|
|
242
|
-
uniform float depthOffset;
|
|
243
|
-
|
|
244
|
-
out vec4 vColor;
|
|
245
|
-
out vec3 vPos;
|
|
246
|
-
out vec3 uCamPos;
|
|
247
|
-
|
|
248
|
-
const float NEAR = -1.0;
|
|
249
|
-
|
|
250
|
-
vec2 getIntersection(vec2 start1, vec2 end1, vec2 start2, vec2 end2){
|
|
251
|
-
vec2 dir = end2 - start2;
|
|
252
|
-
vec2 perp = vec2(-dir.y, dir.x);
|
|
253
|
-
float d2 = dot(perp, start2);
|
|
254
|
-
float seg = dot(perp, start1) - d2;
|
|
255
|
-
float prl = seg - dot(perp, end1) + d2;
|
|
256
|
-
if(prl > -1.0 && prl < 1.0){
|
|
257
|
-
return start1;
|
|
258
|
-
}
|
|
259
|
-
float u = seg / prl;
|
|
260
|
-
return start1 + u * (end1 - start1);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
vec2 project(vec4 p){
|
|
264
|
-
return (0.5 * p.xyz / p.w + 0.5).xy * viewport;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
void main(){
|
|
268
|
-
|
|
269
|
-
uCamPos = eyePositionHigh + eyePositionLow;
|
|
270
|
-
|
|
271
|
-
vColor = vec4(color.rgb, color.a * opacity);
|
|
272
|
-
|
|
273
|
-
vec3 current = currentHigh + currentLow;
|
|
274
|
-
|
|
275
|
-
vPos = current;
|
|
276
|
-
|
|
277
|
-
mat4 viewMatrixRTE = view;
|
|
278
|
-
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
279
|
-
|
|
280
|
-
vec3 highDiff, lowDiff;
|
|
281
|
-
|
|
282
|
-
highDiff = currentHigh - eyePositionHigh;
|
|
283
|
-
lowDiff = currentLow - eyePositionLow;
|
|
284
|
-
vec4 vCurrent = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
285
|
-
|
|
286
|
-
highDiff = prevHigh - eyePositionHigh;
|
|
287
|
-
lowDiff = prevLow - eyePositionLow;
|
|
288
|
-
vec4 vPrev = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
289
|
-
|
|
290
|
-
highDiff = nextHigh - eyePositionHigh;
|
|
291
|
-
lowDiff = nextLow - eyePositionLow;
|
|
292
|
-
vec4 vNext = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
293
|
-
|
|
294
|
-
/*Clip near plane, the point behind view plane*/
|
|
295
|
-
if(vCurrent.z > NEAR) {
|
|
296
|
-
if(vPrev.z < NEAR && abs(order) == 1.0){
|
|
297
|
-
vCurrent = vPrev + (vCurrent - vPrev) * (NEAR - vPrev.z) / (vCurrent.z - vPrev.z);
|
|
298
|
-
} else if(vNext.z < NEAR && abs(order) == 2.0){
|
|
299
|
-
vCurrent = vNext + (vCurrent - vNext) * (NEAR - vNext.z) / (vCurrent.z - vNext.z);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
vec4 dCurrent = proj * vCurrent;
|
|
304
|
-
vec2 _next = project(proj * vNext);
|
|
305
|
-
vec2 _prev = project(proj * vPrev);
|
|
306
|
-
vec2 _current = project(dCurrent);
|
|
307
|
-
|
|
308
|
-
if(_prev == _current){
|
|
309
|
-
if(_next == _current){
|
|
310
|
-
_next = _current + vec2(1.0, 0.0);
|
|
311
|
-
_prev = _current - _next;
|
|
312
|
-
}else{
|
|
313
|
-
_prev = _current + normalize(_current - _next);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if(_next == _current){
|
|
318
|
-
_next = _current + normalize(_current - _prev);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
vec2 sNext = _next,
|
|
322
|
-
sCurrent = _current,
|
|
323
|
-
sPrev = _prev;
|
|
324
|
-
|
|
325
|
-
vec2 dirNext = normalize(sNext - sCurrent);
|
|
326
|
-
vec2 dirPrev = normalize(sPrev - sCurrent);
|
|
327
|
-
float dotNP = dot(dirNext, dirPrev);
|
|
328
|
-
|
|
329
|
-
vec2 normalNext = normalize(vec2(-dirNext.y, dirNext.x));
|
|
330
|
-
vec2 normalPrev = normalize(vec2(dirPrev.y, -dirPrev.x));
|
|
331
|
-
|
|
332
|
-
float d = thickness * sign(order);
|
|
333
|
-
|
|
334
|
-
vec2 m;
|
|
335
|
-
if(dotNP >= 0.99991){
|
|
336
|
-
m = sCurrent - normalPrev * d;
|
|
337
|
-
}else{
|
|
338
|
-
m = getIntersection( sCurrent + normalPrev * d, sPrev + normalPrev * d,
|
|
339
|
-
sCurrent + normalNext * d, sNext + normalNext * d );
|
|
340
|
-
|
|
341
|
-
if( dotNP > 0.5 && dot(dirNext + dirPrev, m - sCurrent) < 0.0 ){
|
|
342
|
-
float occw = order * sign(dirNext.x * dirPrev.y - dirNext.y * dirPrev.x);
|
|
343
|
-
if(occw == -1.0){
|
|
344
|
-
m = sCurrent + normalPrev * d;
|
|
345
|
-
}else if(occw == 1.0){
|
|
346
|
-
m = sCurrent + normalNext * d;
|
|
347
|
-
}else if(occw == -2.0){
|
|
348
|
-
m = sCurrent + normalNext * d;
|
|
349
|
-
}else if(occw == 2.0){
|
|
350
|
-
m = sCurrent + normalPrev * d;
|
|
351
|
-
}
|
|
352
|
-
}else if(distance(sCurrent, m) > min(distance(sCurrent, sNext), distance(sCurrent, sPrev))){
|
|
353
|
-
m = sCurrent + normalNext * d;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
gl_Position = vec4((2.0 * m / viewport - 1.0) * dCurrent.w, dCurrent.z + depthOffset, dCurrent.w);
|
|
358
|
-
}`,
|
|
359
|
-
|
|
360
|
-
fragmentShader:
|
|
361
|
-
`#version 300 es
|
|
362
|
-
|
|
363
|
-
precision highp float;
|
|
364
|
-
|
|
365
|
-
uniform vec2 uFloatParams;
|
|
366
|
-
|
|
367
|
-
layout(location = 0) out vec4 diffuseColor;
|
|
368
|
-
layout(location = 1) out vec4 normalColor;
|
|
369
|
-
layout(location = 2) out vec4 distanceColor;
|
|
370
|
-
|
|
371
|
-
in vec3 uCamPos;
|
|
372
|
-
in vec4 vColor;
|
|
373
|
-
in vec3 vPos;
|
|
374
|
-
|
|
375
|
-
void main() {
|
|
376
|
-
vec3 look = vPos - uCamPos;
|
|
377
|
-
float lookLength = length(look);
|
|
378
|
-
float a = vColor.a * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(vPos,vPos) - uFloatParams[0]));
|
|
379
|
-
diffuseColor = vec4(vColor.rgb, a);
|
|
380
|
-
normalColor = vec4(1.0);
|
|
381
|
-
distanceColor = vec4(1.0);
|
|
382
|
-
}`
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
386
|
export function polyline_picking() {
|
|
387
387
|
return new Program("polyline_picking", {
|
|
388
388
|
uniforms: {
|