@pirireis/webglobeplugins 0.6.28-c → 0.6.30-c
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/bearing-line/plugin copy.js +542 -0
- package/bearing-line/plugin.js +59 -67
- package/package.json +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +20 -13
- package/programs/line-on-globe/lines-color-instanced-flat.js +7 -8
- package/programs/line-on-globe/util.js +8 -0
- package/programs/util.js +4 -1
- package/rangerings/plugin.js +228 -234
- package/util/check/get.js +1 -0
- package/write-text/context-text3.js +8 -0
package/bearing-line/plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ import { CircleCache, EDGE_COUNT as flatCircleEdgeCount, centerCoords2dflatDataC
|
|
|
5
5
|
import { BufferOrchestrator, BufferManager } from '../util/account';
|
|
6
6
|
import { mapGetOrThrow } from "../util/check/get";
|
|
7
7
|
import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
8
|
-
import {
|
|
8
|
+
import { ContextTextWriter3 } from '../write-text/context-text3'
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
@@ -29,7 +29,7 @@ const constraintFloat = (x, lowerBound, upperBound) => {
|
|
|
29
29
|
* @property {string} id
|
|
30
30
|
* @property {function} coordsAdaptor
|
|
31
31
|
* @property {function} textAdaptor
|
|
32
|
-
* @property {
|
|
32
|
+
* @property {ContextTextWriter3} writer
|
|
33
33
|
*
|
|
34
34
|
*/
|
|
35
35
|
|
|
@@ -40,7 +40,7 @@ export default class Plugin {
|
|
|
40
40
|
/**
|
|
41
41
|
*
|
|
42
42
|
* @param {*} id
|
|
43
|
-
* @param {Map<[
|
|
43
|
+
* @param {Map<[key, ContextTextWriter3]>} textContextInjectionMap
|
|
44
44
|
*
|
|
45
45
|
*/
|
|
46
46
|
|
|
@@ -48,6 +48,7 @@ export default class Plugin {
|
|
|
48
48
|
{
|
|
49
49
|
opacity = 1,
|
|
50
50
|
textContextInjectionMap = new Map(),
|
|
51
|
+
textDataPreAdaptor = null,
|
|
51
52
|
drawVRM = true,
|
|
52
53
|
drawBearingLine = true,
|
|
53
54
|
drawAngleRing = true,
|
|
@@ -57,12 +58,15 @@ export default class Plugin {
|
|
|
57
58
|
this.id = id;
|
|
58
59
|
this._opacity = opacity;
|
|
59
60
|
this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
|
|
60
|
-
this.
|
|
61
|
+
this._checkTextContextWriterInjectionMap(textContextInjectionMap);
|
|
61
62
|
this._textContextInjectionMap = textContextInjectionMap;
|
|
63
|
+
this._textContextInjectionMap.forEach((writer) => writer.keyAdaptor = (item) => item.key);
|
|
62
64
|
this.drawVRM = drawVRM;
|
|
63
65
|
this.drawBearingLine = drawBearingLine;
|
|
64
66
|
this.drawAngleRing = drawAngleRing;
|
|
65
67
|
|
|
68
|
+
this._textDataPreAdaptor = textDataPreAdaptor;
|
|
69
|
+
this._memoryForText = new Map();
|
|
66
70
|
|
|
67
71
|
this.drawText = drawText;
|
|
68
72
|
|
|
@@ -87,15 +91,8 @@ export default class Plugin {
|
|
|
87
91
|
this.globe.DrawRender();
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
textContextInjectionMap.forEach((v) => {
|
|
93
|
-
if (typeof v !== 'object') throw new TypeError("textContextInjectionMap format is wrong");
|
|
94
|
-
if (typeof v.coordsAdaptor !== 'function') throw new TypeError("textContextInjectionMap coordsAdaptor format is wrong");
|
|
95
|
-
if (typeof v.textAdaptor !== 'function') throw new TypeError("textContextInjectionMap textAdaptor format is wrong");
|
|
96
|
-
if (!(v.writer instanceof ContextTextWriter)) throw new TypeError("textContextInjectionMap writer is not instance of ContextTextWriter");
|
|
97
|
-
})
|
|
98
|
-
}
|
|
94
|
+
|
|
95
|
+
|
|
99
96
|
|
|
100
97
|
setDoDrawAngleRing(bool) {
|
|
101
98
|
if (bool === this.drawAngleRing) return;
|
|
@@ -104,21 +101,13 @@ export default class Plugin {
|
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
|
|
107
|
-
|
|
108
|
-
this._textContextInjectionMap = textContextInjectionMap;
|
|
109
|
-
this._textContextInjectionMap.forEach(({ writer }) => writer.clear());
|
|
110
|
-
if (data) {
|
|
111
|
-
for (const item of data) {
|
|
112
|
-
this._insertTexts(item);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
104
|
+
|
|
116
105
|
|
|
117
106
|
|
|
118
107
|
setOpacity(opacity) {
|
|
119
108
|
constraintFloat(opacity, 0, 1);
|
|
120
109
|
this._opacity = opacity;
|
|
121
|
-
this._textContextInjectionMap.forEach((
|
|
110
|
+
this._textContextInjectionMap.forEach((writer) => writer.setOpacity(opacity));
|
|
122
111
|
this.globe.DrawRender();
|
|
123
112
|
}
|
|
124
113
|
|
|
@@ -277,6 +266,7 @@ export default class Plugin {
|
|
|
277
266
|
...["centerCoords3d", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
278
267
|
);
|
|
279
268
|
|
|
269
|
+
|
|
280
270
|
}
|
|
281
271
|
|
|
282
272
|
|
|
@@ -301,7 +291,7 @@ export default class Plugin {
|
|
|
301
291
|
}
|
|
302
292
|
}
|
|
303
293
|
if (this.drawText) {
|
|
304
|
-
this._textContextInjectionMap.forEach((
|
|
294
|
+
this._textContextInjectionMap.forEach((writer) => writer.draw());
|
|
305
295
|
}
|
|
306
296
|
gl.enable(gl.DEPTH_TEST);
|
|
307
297
|
}
|
|
@@ -323,29 +313,34 @@ export default class Plugin {
|
|
|
323
313
|
* @property {number} dashOpacity 0-1
|
|
324
314
|
* @property {number} circleDashAngle 0-360
|
|
325
315
|
* @param {Array<item>} items
|
|
326
|
-
* @param {Array<string>}
|
|
316
|
+
* @param {Array<string>} textWriterIDs | textContextInjectionMap keys to be used for writing text.
|
|
327
317
|
*/
|
|
328
|
-
insertBulk(items,
|
|
318
|
+
insertBulk(items, textWriterIDs = []) {
|
|
329
319
|
const { globe, bufferOrchestrator, bufferManagersCompMap } = this;// angleTextContext, distanceTextContext,
|
|
330
|
-
const textWriterInjectionSubSets = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);
|
|
331
320
|
const data = []
|
|
332
321
|
for (let item of items) {
|
|
333
|
-
this._insertTexts(item, textWriterInjectionSubSets);
|
|
334
322
|
data.push(this.__insertAdaptor(item));
|
|
335
323
|
}
|
|
336
324
|
bufferOrchestrator.insertBulk(data, bufferManagersCompMap);
|
|
337
|
-
this.
|
|
338
|
-
|
|
339
|
-
writer.updateOpacityBulk(items, (e) => e.key, (e) => e.rgba[3]);
|
|
340
|
-
})
|
|
325
|
+
this.__insertTexts(items, textWriterIDs);
|
|
326
|
+
|
|
341
327
|
globe.DrawRender();
|
|
342
328
|
}
|
|
343
329
|
|
|
344
330
|
|
|
345
|
-
|
|
331
|
+
updateText(textWriterIDs) {
|
|
332
|
+
const textContextInjectionMap = textWriterGetOrThrow(this._textContextInjectionMap, textWriterIDs);
|
|
333
|
+
this._memoryForText.forEach((item) => {
|
|
334
|
+
textContextInjectionMap.forEach((writer) => writer.insertText(item));
|
|
335
|
+
});
|
|
336
|
+
this.globe.DrawRender();
|
|
337
|
+
}
|
|
346
338
|
|
|
347
339
|
deleteBulk(keys) {
|
|
348
340
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersCompMap);
|
|
341
|
+
for (const key of keys) {
|
|
342
|
+
this._memoryForText.delete(key);
|
|
343
|
+
}
|
|
349
344
|
this._deleteTexts(keys);
|
|
350
345
|
this.globe.DrawRender();
|
|
351
346
|
}
|
|
@@ -355,20 +350,18 @@ export default class Plugin {
|
|
|
355
350
|
this.bufferOrchestrator.defrag(this.bufferManagersCompMap);
|
|
356
351
|
}
|
|
357
352
|
|
|
353
|
+
|
|
358
354
|
/**
|
|
359
|
-
*
|
|
360
355
|
* @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
|
|
361
|
-
* @param {Array<string>}
|
|
356
|
+
* @param {Array<string>} textWriterIDs | textContextInjectionMap keys to be used for writing text.
|
|
362
357
|
*/
|
|
363
|
-
updateCoordinatesBulk(items,
|
|
364
|
-
const injectionsSubSet = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);;
|
|
358
|
+
updateCoordinatesBulk(items, textWriterIDs = []) {
|
|
365
359
|
const { globe, bufferOrchestrator, bufferManagersCompMap, } = this;
|
|
366
360
|
const data = []
|
|
367
361
|
for (let item of items) {
|
|
368
|
-
this._insertTexts(item, injectionsSubSet);
|
|
369
362
|
data.push(this.__updateCoordsAdaptor(item));
|
|
370
363
|
}
|
|
371
|
-
|
|
364
|
+
this.__insertTexts(items, textWriterIDs);
|
|
372
365
|
bufferOrchestrator.updateBulk(data, bufferManagersCompMap, ["centerCoords2d", "centerCoords3d", "targetCoords2d", "targetCoords3d", "startAngle", "tailAngle",
|
|
373
366
|
"startAngle2d", "tailAngle2d", "startAngle3d", "tailAngle3d", "bearingTargetCoords2d", "bearingTargetCoords3d", "centerCoords2dflat",
|
|
374
367
|
"bearingAngle", "bigRadius", "radius"]);
|
|
@@ -380,37 +373,46 @@ export default class Plugin {
|
|
|
380
373
|
*
|
|
381
374
|
* @param {*} items some colums EXCEPT positional ones
|
|
382
375
|
* @param {string} propertyIDs
|
|
383
|
-
* @param {string}
|
|
376
|
+
* @param {string} textWriterIDs
|
|
384
377
|
* Do NOT send empty data if property ID of this data is entered or NaN is loaded to the buffer, resulting in an unwanted behaviour.
|
|
378
|
+
* textWriterIDs = []
|
|
385
379
|
*/
|
|
386
|
-
updatePartial(items, propertyIDs = [],
|
|
380
|
+
updatePartial(items, propertyIDs = [], textWriterIDs = []) {
|
|
387
381
|
if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
|
|
388
382
|
const fixedPropertyIDs = this.__fixPartialProperties(propertyIDs)
|
|
389
|
-
const {
|
|
390
|
-
const writers = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);
|
|
391
|
-
for (let item of items) { this._insertTexts(item, writers) }
|
|
383
|
+
const { bufferOrchestrator, bufferManagersCompMap } = this;
|
|
392
384
|
bufferOrchestrator.updateBulk(items, bufferManagersCompMap, fixedPropertyIDs);
|
|
393
385
|
// patch to update text opacity
|
|
394
|
-
|
|
395
|
-
if (property === "rgba") {
|
|
396
|
-
_textContextInjectionMap.forEach((v) => {
|
|
397
|
-
const { writer } = v;
|
|
398
|
-
writer.updateOpacityBulk(items, (e) => e.key, (e) => e.rgba[3]);
|
|
399
|
-
})
|
|
400
|
-
}
|
|
401
|
-
}
|
|
386
|
+
this.__insertTexts(items, textWriterIDs);
|
|
402
387
|
this.globe.DrawRender();
|
|
403
388
|
}
|
|
404
389
|
|
|
405
390
|
|
|
406
|
-
|
|
391
|
+
_checkTextContextWriterInjectionMap(textContextWriterInjectionMap) {
|
|
392
|
+
if (!(textContextWriterInjectionMap instanceof Map)) throw new Error("textContextWriterInjectionMap is not an instance of Map");
|
|
393
|
+
textContextWriterInjectionMap.forEach((v) => {
|
|
394
|
+
if (!(v instanceof ContextTextWriter3)) throw new Error("textContextWriterInjectionMap element is not an instance of ContextTextWriter3");
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
407
398
|
|
|
399
|
+
__insertTexts(items, textWriterIDs) {
|
|
400
|
+
const textContextInjectionMap = textWriterGetOrThrow(this._textContextInjectionMap, textWriterIDs);
|
|
401
|
+
for (const item of items) {
|
|
402
|
+
const oldItem = this._memoryForText.get(item.key);
|
|
403
|
+
let _item = oldItem !== undefined ? { ...oldItem, ...item } : item;
|
|
404
|
+
if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
|
|
405
|
+
this._memoryForText.set(item.key, _item);
|
|
406
|
+
textContextInjectionMap.forEach((writer) => writer.insertText(_item));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
__insertAdaptor(item) {
|
|
408
411
|
const rgba = item.rgba !== undefined ? item.rgba : [0, 0, 0, 0];
|
|
409
412
|
const rgbaMode = item.rgbaMode !== undefined ? item.rgbaMode : 0;
|
|
410
413
|
const dashRatio = item.dashRatio !== undefined ? item.dashRatio : 1.0;
|
|
411
414
|
const dashOpacity = item.dashOpacity !== undefined ? item.dashOpacity : 0.9;
|
|
412
415
|
const circleDashAngle = item.circleDashAngle !== undefined ? item.circleDashAngle : 360;
|
|
413
|
-
|
|
414
416
|
const coordsData = this.__updateCoordsAdaptor(item);
|
|
415
417
|
|
|
416
418
|
return {
|
|
@@ -502,24 +504,14 @@ export default class Plugin {
|
|
|
502
504
|
|
|
503
505
|
|
|
504
506
|
|
|
505
|
-
_insertTexts(item, textWriterInjectionSubSet) {
|
|
506
|
-
//TODO This method can be more performant if it works horizontally, tabular
|
|
507
|
-
textWriterInjectionSubSet.forEach((v) => {
|
|
508
|
-
const { coordsAdaptor, textAdaptor, writer } = v
|
|
509
|
-
const { lat, long } = coordsAdaptor(item);
|
|
510
|
-
const text = textAdaptor(item);
|
|
511
|
-
writer.insertText(item.key, lat, long, text);
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
|
|
516
507
|
_deleteTexts(keys) {
|
|
517
|
-
this._textContextInjectionMap.forEach((
|
|
518
|
-
|
|
508
|
+
this._textContextInjectionMap.forEach((writer) => {
|
|
509
|
+
writer.deleteTextBulk(keys);
|
|
519
510
|
});
|
|
520
511
|
}
|
|
521
512
|
|
|
522
513
|
|
|
514
|
+
|
|
523
515
|
}
|
|
524
516
|
|
|
525
517
|
|
package/package.json
CHANGED
|
@@ -2,12 +2,11 @@ import { createProgram } from "../../util/webglobjectbuilders";
|
|
|
2
2
|
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
4
|
import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
+
import { Z_ALPHA_MODE } from "./util";
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
+
cartesian3DToGLPosition,
|
|
7
8
|
circleLimpFromLongLatRadCenterCartesian3D_accurate,
|
|
8
|
-
|
|
9
|
-
circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
10
|
-
POLE
|
|
9
|
+
POLE,
|
|
11
10
|
} from "../../util/shaderfunctions/geometrytransformations";
|
|
12
11
|
|
|
13
12
|
|
|
@@ -25,14 +24,8 @@ const INITIAL_EDGE_COUNT = 360;
|
|
|
25
24
|
const vertexShaderSource = `#version 300 es
|
|
26
25
|
precision highp float;
|
|
27
26
|
${CameraUniformBlockString}
|
|
28
|
-
${longLatRadToMercator}
|
|
29
|
-
${longLatRadToCartesian3D}
|
|
30
27
|
${cartesian3DToGLPosition}
|
|
31
|
-
${mercatorXYToGLPosition}
|
|
32
|
-
${realDistanceOnSphereR1}
|
|
33
28
|
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
34
|
-
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
35
|
-
${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
|
|
36
29
|
|
|
37
30
|
|
|
38
31
|
in vec3 center_position3d;
|
|
@@ -42,6 +35,7 @@ in vec4 color;
|
|
|
42
35
|
|
|
43
36
|
uniform float edge_count;
|
|
44
37
|
uniform float step_angle;
|
|
38
|
+
uniform int z_alpha_on;
|
|
45
39
|
|
|
46
40
|
out float interpolation;
|
|
47
41
|
out vec4 v_color;
|
|
@@ -49,6 +43,12 @@ void main() {
|
|
|
49
43
|
if( !is3D) {
|
|
50
44
|
return;
|
|
51
45
|
}
|
|
46
|
+
v_color = color;
|
|
47
|
+
if ( z_alpha_on == 1 ){
|
|
48
|
+
float z_alpha = pow(z_level * 0.75, 3.0) * distance(big_radius, small_radius) / (R * 2.0);
|
|
49
|
+
if ( z_alpha < 0.1 ) { return; }
|
|
50
|
+
v_color.a *= z_alpha;
|
|
51
|
+
}
|
|
52
52
|
int pad_phase = gl_VertexID % 2; // 0 or 1
|
|
53
53
|
interpolation = float( gl_VertexID - pad_phase) / edge_count;
|
|
54
54
|
float angle = float( gl_VertexID - pad_phase) * step_angle;
|
|
@@ -59,7 +59,7 @@ void main() {
|
|
|
59
59
|
position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, small_radius, angle);
|
|
60
60
|
}
|
|
61
61
|
gl_Position = cartesian3DToGLPosition(position);
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
gl_PointSize = 5.0;
|
|
64
64
|
}`
|
|
65
65
|
|
|
@@ -87,13 +87,15 @@ class Logic {
|
|
|
87
87
|
this._lastOpacity = 1.0;
|
|
88
88
|
this._lastEdgeCount = INITIAL_EDGE_COUNT;
|
|
89
89
|
this._lastStepAngle = 360 / INITIAL_EDGE_COUNT;
|
|
90
|
+
this._lastZAlphaMode = Z_ALPHA_MODE.ON;
|
|
90
91
|
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
91
92
|
|
|
92
93
|
const { gl, program } = this;
|
|
93
94
|
this.program.uniforms = {
|
|
94
95
|
opacity: gl.getUniformLocation(program, "opacity"),
|
|
95
96
|
edgeCount: gl.getUniformLocation(program, "edge_count"),
|
|
96
|
-
stepAngle: gl.getUniformLocation(program, "step_angle")
|
|
97
|
+
stepAngle: gl.getUniformLocation(program, "step_angle"),
|
|
98
|
+
zAlphaMode: gl.getUniformLocation(program, "z_alpha_on")
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
{ // initial uniform values
|
|
@@ -102,6 +104,7 @@ class Logic {
|
|
|
102
104
|
gl.uniform1f(program.uniforms.opacity, 1.0);
|
|
103
105
|
gl.uniform1f(program.uniforms.edgeCount, INITIAL_EDGE_COUNT * 2);
|
|
104
106
|
gl.uniform1f(program.uniforms.stepAngle, this._lastStepAngle * Math.PI / 180);
|
|
107
|
+
gl.uniform1i(program.uniforms.zAlphaMode, Z_ALPHA_MODE.ON);
|
|
105
108
|
gl.useProgram(currentProgram);
|
|
106
109
|
}
|
|
107
110
|
|
|
@@ -147,7 +150,7 @@ class Logic {
|
|
|
147
150
|
return vao;
|
|
148
151
|
}
|
|
149
152
|
|
|
150
|
-
draw(vao, length, edgeCount, stepAngle, opacity) {
|
|
153
|
+
draw(vao, length, edgeCount, stepAngle, opacity, zAlphaMode = Z_ALPHA_MODE.ON) {
|
|
151
154
|
const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
|
|
152
155
|
gl.useProgram(program);
|
|
153
156
|
|
|
@@ -163,6 +166,10 @@ class Logic {
|
|
|
163
166
|
gl.uniform1f(program.uniforms.stepAngle, stepAngle * Math.PI / 180);
|
|
164
167
|
this._lastStepAngle = stepAngle;
|
|
165
168
|
}
|
|
169
|
+
if (this._lastZAlphaMode !== zAlphaMode) {
|
|
170
|
+
gl.uniform1i(program.uniforms.zAlphaMode, zAlphaMode);
|
|
171
|
+
this._lastZAlphaMode = zAlphaMode;
|
|
172
|
+
}
|
|
166
173
|
gl.bindVertexArray(vao);
|
|
167
174
|
cameraBlockTotem.bind(cameraBindingPoint);
|
|
168
175
|
gl.drawArraysInstanced(gl.LINES, 0, edgeCount * 2, length);
|
|
@@ -3,17 +3,15 @@ import { mercatorXYToGLPosition, POLE } from "../../util/shaderfunctions/geometr
|
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
4
|
import { createProgram } from "../../util";
|
|
5
5
|
import { vaoAttributeLoader } from "../../util/account/util";
|
|
6
|
+
import { Z_ALPHA_MODE } from "./util";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This program draws line between points provided from the first and second buffer.
|
|
9
10
|
* draw method gl.drawArraysInstanced( gl.POINTS, 0,2, lineCount);
|
|
10
11
|
* */
|
|
11
12
|
|
|
12
|
-
const Z_ALPHA_MODE = Object.freeze({
|
|
13
|
-
ON: 1,
|
|
14
|
-
OFF: 0
|
|
15
|
-
});
|
|
16
13
|
|
|
14
|
+
// TODO: find better way to eleminate edge case distance(posA, posB) > 37000000.0
|
|
17
15
|
const vertexShaderSource = `#version 300 es
|
|
18
16
|
precision highp float;
|
|
19
17
|
${CameraUniformBlockString}
|
|
@@ -32,10 +30,11 @@ void main() {
|
|
|
32
30
|
if ( is3D ) {
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
|
-
float gap =
|
|
33
|
+
float gap = max( distance(posA.x, posB.x), distance(posA.y,posB.y)); //
|
|
34
|
+
if ( gap > 37000000.0) { return; }
|
|
36
35
|
float z_alpha;
|
|
37
|
-
if ( z_alpha_on == 1
|
|
38
|
-
z_alpha = z_level
|
|
36
|
+
if ( z_alpha_on == 1 ){
|
|
37
|
+
z_alpha = pow(z_level,3.0) / ( 37000000.0 / gap);
|
|
39
38
|
if( z_alpha < 0.1 ) {return;}
|
|
40
39
|
if( z_alpha > 1.0 ) {z_alpha = 1.0;}
|
|
41
40
|
} else {
|
|
@@ -115,7 +114,7 @@ class Logic {
|
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
|
|
118
|
-
draw(vao, lineCount, opacity = 1.0, zAlphaOn = Z_ALPHA_MODE.
|
|
117
|
+
draw(vao, lineCount, opacity = 1.0, zAlphaOn = Z_ALPHA_MODE.ON) {
|
|
119
118
|
const { gl, program, _cameraBindingPoint, _cameraUniformBlock } = this;
|
|
120
119
|
gl.useProgram(program);
|
|
121
120
|
_cameraUniformBlock.bind(_cameraBindingPoint);
|
package/programs/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function longlatbbox2normalbbox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
|
|
4
4
|
// x
|
|
5
5
|
const horOffset = (minLon) * Math.PI / 180;
|
|
6
6
|
const horSize = (maxLon - minLon) * Math.PI / 180;
|
|
@@ -15,3 +15,6 @@ export function longlatbbox2normalbbox({ minLon = -180, maxLon = 180, minLat = -
|
|
|
15
15
|
console.log("longlatbbox2normalbbox", result);
|
|
16
16
|
return result;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export { longlatbbox2normalbbox }
|