@pirireis/webglobeplugins 0.12.0-alpha → 0.14.0-alpha
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/Math/arc-cdf-points.js +20 -0
- package/Math/arc-generate-points copy.js +1 -0
- package/Math/arc.js +21 -8
- package/Math/circle-cdf-points.js +0 -2
- package/Math/circle.js +35 -16
- package/Math/templete-shapes/grid-visually-equal.js +66 -0
- package/altitude-locator/plugin.js +3 -2
- package/bearing-line/plugin.js +1 -2
- package/circle-line-chain/plugin.js +4 -7
- package/compass-rose/compass-rose-padding-flat.js +12 -0
- package/package.json +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
- package/programs/line-on-globe/linestrip/data.js +4 -0
- package/programs/line-on-globe/{linestrip.js → linestrip/linestrip.js} +37 -35
- package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
- package/programs/picking/pickable-renderer.js +1 -2
- package/programs/rings/distancering/circleflatprogram.js +116 -120
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +1 -1
- package/programs/rings/distancering/circlepaddysharedbuffer.js +368 -354
- package/programs/rings/distancering/index.js +6 -5
- package/programs/rings/distancering/paddyflatprogram.js +127 -136
- package/programs/rings/distancering/paddyflatprogram2d.js +129 -138
- package/programs/rings/distancering/paddyflatprogram3d.js +128 -136
- package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
- package/programs/rings/partial-ring/piece-of-pie.js +26 -13
- package/programs/totems/camerauniformblock.js +1 -1
- package/programs/totems/index.js +1 -1
- package/programs/vectorfields/logics/pixelbased.js +5 -21
- package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
- package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
- package/range-tools-on-terrain/bearing-line/types.js +1 -0
- package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
- package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
- package/range-tools-on-terrain/range-ring/adapters.js +25 -0
- package/range-tools-on-terrain/range-ring/plugin.js +31 -0
- package/range-tools-on-terrain/range-ring/types.js +1 -0
- package/rangerings/plugin.js +7 -11
- package/semiplugins/lightweight/line-plugin.js +195 -0
- package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
- package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
- package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +129 -68
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
- package/semiplugins/type.js +1 -0
- package/types.js +0 -11
- package/util/account/create-buffermap-orchastration.js +39 -0
- package/util/account/index.js +2 -2
- package/util/account/single-attribute-buffer-management/buffer-manager.js +2 -3
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
- package/util/build-strategy/static-dynamic.js +1 -1
- package/util/check/typecheck.js +15 -1
- package/util/geometry/index.js +3 -2
- package/util/gl-util/buffer/attribute-loader.js +2 -5
- package/util/gl-util/draw-options/methods.js +4 -5
- package/util/webglobjectbuilders.js +4 -9
- package/write-text/context-text3.js +17 -0
- package/write-text/context-text3old.js +152 -0
- package/programs/line-on-globe/circle-accurate.js +0 -175
- package/programs/line-on-globe/circle.js +0 -164
- package/programs/line-on-globe/to-the-surface.js +0 -109
- package/programs/rings/distancering/shader.js +0 -1
- package/programs/totems/canvas-webglobe-info1.js +0 -106
- package/shape-on-terrain/arc/naive/plugin.js +0 -205
- package/util/check/get.js +0 -14
- package/util/gl-util/buffer/types.js +0 -1
- package/util/gl-util/draw-options/types.js +0 -15
- package/util/webglobjectbuilders1.js +0 -219
|
@@ -1,136 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
in
|
|
19
|
-
in float
|
|
20
|
-
in
|
|
21
|
-
in
|
|
22
|
-
|
|
23
|
-
uniform int compass;
|
|
24
|
-
uniform float pad_count;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.gl.deleteProgram(this.program);
|
|
130
|
-
globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export const PaddingProgramCache = Object.freeze({
|
|
134
|
-
getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic); },
|
|
135
|
-
releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
136
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO: Delete this file if it is not needed anymore.
|
|
3
|
+
// import { createProgram, shaderfunctions } from "../../../util";
|
|
4
|
+
// import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
|
|
5
|
+
// import { globeProgramCache, noRegisterGlobeProgramCache } from "../../programcache";
|
|
6
|
+
// const vertexShader = `#version 300 es ` +
|
|
7
|
+
// shaderfunctions.PI +
|
|
8
|
+
// shaderfunctions.R +
|
|
9
|
+
// shaderfunctions.POLE +
|
|
10
|
+
// CameraUniformBlockString +
|
|
11
|
+
// shaderfunctions.mercatorXYToGLPosition +
|
|
12
|
+
// shaderfunctions.longLatRadToMercator +
|
|
13
|
+
// shaderfunctions.longLatRadToCartesian3D +
|
|
14
|
+
// shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
15
|
+
// shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
16
|
+
// shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
|
|
17
|
+
// shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
18
|
+
// in vec2 center;
|
|
19
|
+
// in float radius;
|
|
20
|
+
// in float pad_range;
|
|
21
|
+
// in vec4 color;
|
|
22
|
+
// in float flag;
|
|
23
|
+
// uniform int compass;
|
|
24
|
+
// uniform float pad_count;
|
|
25
|
+
// uniform float opacity;
|
|
26
|
+
// out vec2 v_limp;
|
|
27
|
+
// out vec4 v_color;
|
|
28
|
+
// void main() {
|
|
29
|
+
// float alpha_padding = z_level * z_level / (pad_range/ 100.0 );
|
|
30
|
+
// if( flag == 2.0 || flag == 1.0 || radius == 0.0 || alpha_padding < 0.1 || z_level < 3.0 ) return; // 1.0 is hide
|
|
31
|
+
// v_color = vec4(color.rgb, color.a * alpha_padding * opacity);
|
|
32
|
+
// gl_PointSize = 2.0;
|
|
33
|
+
// float odd = mod(float(gl_VertexID), 2.0);
|
|
34
|
+
// float index = (float(gl_VertexID)- odd ) / 2.0;
|
|
35
|
+
// float angle = 3.1415926535897932384626433832795 * 2.0 * (index / pad_count );
|
|
36
|
+
// float radius_ = radius - (pad_range * odd);
|
|
37
|
+
// if ( is3D){
|
|
38
|
+
// gl_Position = projection * view * vec4(
|
|
39
|
+
// circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
|
|
40
|
+
// v_limp = vec2(0.0, 0.0);
|
|
41
|
+
// return;
|
|
42
|
+
// }
|
|
43
|
+
// vec2 limp;
|
|
44
|
+
// if ( compass == 1 ){
|
|
45
|
+
// limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
46
|
+
// } else {
|
|
47
|
+
// // limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
|
|
48
|
+
// limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
49
|
+
// }
|
|
50
|
+
// v_limp = limp;
|
|
51
|
+
// gl_Position = mercatorXYToGLPosition(limp);
|
|
52
|
+
// }`;
|
|
53
|
+
// const fragmentShader = `#version 300 es
|
|
54
|
+
// precision highp float; `+
|
|
55
|
+
// shaderfunctions.POLE + `
|
|
56
|
+
// in vec4 v_color;
|
|
57
|
+
// in vec2 v_limp;
|
|
58
|
+
// out vec4 outColor;
|
|
59
|
+
// void main() {
|
|
60
|
+
// if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
|
|
61
|
+
// outColor = v_color;
|
|
62
|
+
// }`;
|
|
63
|
+
// class Logic {
|
|
64
|
+
// constructor(globe) {
|
|
65
|
+
// this.globe = globe;
|
|
66
|
+
// this.gl = globe.gl;
|
|
67
|
+
// this.program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
68
|
+
// { // bind positions so bufferManager can use them
|
|
69
|
+
// this.gl.bindAttribLocation(this.program, 0, "center");
|
|
70
|
+
// this.gl.bindAttribLocation(this.program, 1, "radius");
|
|
71
|
+
// this.gl.bindAttribLocation(this.program, 2, "pad_range");
|
|
72
|
+
// this.gl.bindAttribLocation(this.program, 3, "color");
|
|
73
|
+
// this.gl.bindAttribLocation(this.program, 4, "flag");
|
|
74
|
+
// }
|
|
75
|
+
// this.cameraBlockBindingPoint = 0;
|
|
76
|
+
// const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
|
|
77
|
+
// this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
78
|
+
// this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
79
|
+
// this._padCountLocation = this.gl.getUniformLocation(this.program, "pad_count");
|
|
80
|
+
// this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
|
|
81
|
+
// this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
|
|
82
|
+
// this._compassMode = 1;
|
|
83
|
+
// this._opacity = 1.0;
|
|
84
|
+
// this._padCount = 360;
|
|
85
|
+
// {
|
|
86
|
+
// const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
87
|
+
// this.gl.useProgram(this.program);
|
|
88
|
+
// this.gl.uniform1i(this._compassLocation, 1);
|
|
89
|
+
// this.gl.uniform1f(this._opacityLocation, 1.0);
|
|
90
|
+
// this.gl.uniform1f(this._padCountLocation, 360)
|
|
91
|
+
// this.gl.useProgram(currentProgram);
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// draw(attrBufferManager, padCount, compass, opacity) {
|
|
95
|
+
// const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
|
|
96
|
+
// gl.useProgram(program);
|
|
97
|
+
// attrBufferManager.bindPaddingVAO();
|
|
98
|
+
// cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
99
|
+
// // draw instanced
|
|
100
|
+
// if (padCount !== this._padCount) {
|
|
101
|
+
// this._padCount = padCount;
|
|
102
|
+
// // console.log("padCount", padCount);
|
|
103
|
+
// gl.uniform1f(_padCountLocation, padCount);
|
|
104
|
+
// }
|
|
105
|
+
// if (compass !== this._compassMode) {
|
|
106
|
+
// // console.log("compass", compass);
|
|
107
|
+
// gl.uniform1i(_compassLocation, compass);
|
|
108
|
+
// this._compassMode = compass;
|
|
109
|
+
// }
|
|
110
|
+
// if (opacity !== this._opacity) {
|
|
111
|
+
// // console.log("opacity", opacity);
|
|
112
|
+
// this._opacity = opacity;
|
|
113
|
+
// gl.uniform1f(this._opacityLocation, opacity);
|
|
114
|
+
// }
|
|
115
|
+
// gl.drawArraysInstanced(gl.LINES, 0, padCount * 2, attrBufferManager.length);
|
|
116
|
+
// gl.bindVertexArray(null);
|
|
117
|
+
// cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
118
|
+
// }
|
|
119
|
+
// free() {
|
|
120
|
+
// this.gl.deleteProgram(this.program);
|
|
121
|
+
// globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
124
|
+
// //
|
|
125
|
+
// export const PaddingProgramCache = Object.freeze({
|
|
126
|
+
// getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
|
|
127
|
+
// releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
|
|
128
|
+
// })
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { createProgram } from "../../../util/webglobjectbuilders";
|
|
2
|
+
import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems/index";
|
|
3
|
+
import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
|
|
4
|
+
import { POLE, PI, longLatRadToMercator, mercatorXYToGLPosition, longLatRadToCartesian3D, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
5
|
+
//circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
6
|
+
cartesian3DToGLPosition } from "../../../util/shaderfunctions/geometrytransformations";
|
|
7
|
+
/**
|
|
8
|
+
* TODO:
|
|
9
|
+
* 1. Triangle face looks at screen. if rotation angle is positive the last vertex must be the faintest.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const drawModeMap = Object.freeze({
|
|
13
|
+
LINE_STRIP: 0,
|
|
14
|
+
TRIANGLE_FAN: 1,
|
|
15
|
+
});
|
|
16
|
+
//${ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate }
|
|
17
|
+
const vertexShaderSource = `#version 300 es
|
|
18
|
+
|
|
19
|
+
${CameraUniformBlockString}
|
|
20
|
+
${PI}
|
|
21
|
+
${longLatRadToMercator}
|
|
22
|
+
${mercatorXYToGLPosition}
|
|
23
|
+
${longLatRadToCartesian3D}
|
|
24
|
+
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
25
|
+
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
26
|
+
${cartesian3DToGLPosition}
|
|
27
|
+
|
|
28
|
+
uniform float edge_count;
|
|
29
|
+
uniform int draw_mode; // %2 => 0: LINE_STRIP, 1: TRIANGLE_FAN
|
|
30
|
+
uniform float plugin_alpha_multiplier;
|
|
31
|
+
//, lat, startAngle, tailAngle, ...rgba, radius, rgbaMode
|
|
32
|
+
// in vec2 center; // long, lat in radian
|
|
33
|
+
in vec2 center2d;
|
|
34
|
+
in vec3 center3d;
|
|
35
|
+
in float start_angle2d;
|
|
36
|
+
in float tail_angle2d;
|
|
37
|
+
|
|
38
|
+
in float start_angle3d;
|
|
39
|
+
in float tail_angle3d;
|
|
40
|
+
|
|
41
|
+
in vec4 color;
|
|
42
|
+
in float radius; // in meter
|
|
43
|
+
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
44
|
+
// flat out int vid;
|
|
45
|
+
// flat out float v_phase;
|
|
46
|
+
out vec2 v_pos;
|
|
47
|
+
out vec4 v_color;
|
|
48
|
+
// flat out float v_angle;
|
|
49
|
+
|
|
50
|
+
void main() {
|
|
51
|
+
// vid = gl_VertexID;
|
|
52
|
+
if (filling_mode == 2.0 || radius == 0.0) { return; }
|
|
53
|
+
float start_angle, tail_angle;
|
|
54
|
+
if (is3D) {
|
|
55
|
+
start_angle = start_angle3d;
|
|
56
|
+
tail_angle = tail_angle3d;
|
|
57
|
+
} else {
|
|
58
|
+
start_angle = start_angle2d;
|
|
59
|
+
tail_angle = tail_angle2d;
|
|
60
|
+
}
|
|
61
|
+
float filling_mode_ = filling_mode;
|
|
62
|
+
if ( draw_mode == 0 && filling_mode == 1.0) {filling_mode_ = 0.0;}
|
|
63
|
+
float vertexID = float(gl_VertexID);
|
|
64
|
+
float radius_ = radius;
|
|
65
|
+
float alpha = plugin_alpha_multiplier;
|
|
66
|
+
if (draw_mode == 1) { // TRIANGLE_FAN
|
|
67
|
+
if (gl_VertexID == 0) {
|
|
68
|
+
radius_ = 0.0;
|
|
69
|
+
if ( filling_mode == 1.0 ) { alpha = 0.0; }
|
|
70
|
+
}
|
|
71
|
+
vertexID -= 1.0;
|
|
72
|
+
}
|
|
73
|
+
float phase = ( vertexID / (edge_count - 1.0) );
|
|
74
|
+
// v_angle = tail_angle;
|
|
75
|
+
|
|
76
|
+
if ( filling_mode_ == 1.0 ) {
|
|
77
|
+
if ( tail_angle < 0.0 ) {
|
|
78
|
+
v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
|
|
79
|
+
} else {
|
|
80
|
+
v_color = vec4( color.rgb , color.a * phase * alpha );
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
v_color = vec4( color.rgb , color.a * alpha );
|
|
84
|
+
}
|
|
85
|
+
if ( filling_mode == 0.0 && draw_mode == 1 ) {
|
|
86
|
+
v_color.a /= 2.0;
|
|
87
|
+
}
|
|
88
|
+
float angle;
|
|
89
|
+
if ( tail_angle > 0.0 ) {
|
|
90
|
+
angle = tail_angle * (-phase + 1.0) + start_angle;
|
|
91
|
+
} else {
|
|
92
|
+
angle = tail_angle * phase + start_angle;
|
|
93
|
+
}
|
|
94
|
+
if (is3D) {
|
|
95
|
+
vec3 pos = circleLimpFromLongLatRadCenterCartesian3D_accurate(center3d, radius_, angle);
|
|
96
|
+
v_pos = vec2(0.0, 0.0);
|
|
97
|
+
gl_Position = cartesian3DToGLPosition(pos);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
vec2 pos2 = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center2d, radius_, angle);
|
|
101
|
+
v_pos = pos2;
|
|
102
|
+
gl_Position = mercatorXYToGLPosition(pos2);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
gl_PointSize = 10.0;
|
|
106
|
+
}`;
|
|
107
|
+
const fragmentShaderSource = `#version 300 es` + POLE + PI + `
|
|
108
|
+
precision highp float;
|
|
109
|
+
// flat in int vid;
|
|
110
|
+
in vec4 v_color;
|
|
111
|
+
in vec2 v_pos;
|
|
112
|
+
// flat in float v_phase;
|
|
113
|
+
// in float v_angle;
|
|
114
|
+
out vec4 outColor;
|
|
115
|
+
void main() {
|
|
116
|
+
// if( vid % 2 == 0 ) { discard; }
|
|
117
|
+
// if ( mod(v_angle, PI / 36.0 ) < (PI / 72.0)) { discard; }
|
|
118
|
+
// if ( mod(v_angle * v_phase, PI / 90.0 ) < (PI / 180.0)) { discard; }
|
|
119
|
+
if ( v_pos.x < -POLE || v_pos.x > POLE || v_pos.y < -POLE || v_pos.y > POLE ) { discard; }
|
|
120
|
+
outColor = v_color;
|
|
121
|
+
}`;
|
|
122
|
+
export const ITEM_SIZE = 10;
|
|
123
|
+
export class Logic {
|
|
124
|
+
globe;
|
|
125
|
+
gl;
|
|
126
|
+
_lastMode;
|
|
127
|
+
_lastEdgeCount;
|
|
128
|
+
_lastAlphaMultiplier;
|
|
129
|
+
program;
|
|
130
|
+
_edgeCountLocation;
|
|
131
|
+
_draw_modeLocation;
|
|
132
|
+
_plugin_alpha_multiplierLocation;
|
|
133
|
+
cameraBlockBindingPoint;
|
|
134
|
+
cameraBlockTotem; // Type this based on your CameraUniformBlockTotem implementation
|
|
135
|
+
constructor(globe) {
|
|
136
|
+
this.globe = globe;
|
|
137
|
+
this.gl = globe.gl;
|
|
138
|
+
this._lastMode = 0;
|
|
139
|
+
this._lastEdgeCount = 64;
|
|
140
|
+
this._lastAlphaMultiplier = 1.0;
|
|
141
|
+
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
142
|
+
const { gl, program } = this;
|
|
143
|
+
{ // set attributes locations
|
|
144
|
+
gl.bindAttribLocation(program, 0, 'center2d');
|
|
145
|
+
gl.bindAttribLocation(program, 1, 'center3d');
|
|
146
|
+
gl.bindAttribLocation(program, 2, 'start_angle2d');
|
|
147
|
+
gl.bindAttribLocation(program, 3, 'tail_angle2d');
|
|
148
|
+
gl.bindAttribLocation(program, 4, 'start_angle3d');
|
|
149
|
+
gl.bindAttribLocation(program, 5, 'tail_angle3d');
|
|
150
|
+
gl.bindAttribLocation(program, 6, 'color');
|
|
151
|
+
gl.bindAttribLocation(program, 7, 'radius');
|
|
152
|
+
gl.bindAttribLocation(program, 8, 'filling_mode');
|
|
153
|
+
// vao
|
|
154
|
+
// instanced draw read 1
|
|
155
|
+
}
|
|
156
|
+
{ // Uniforms
|
|
157
|
+
this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
|
|
158
|
+
this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
|
|
159
|
+
this._plugin_alpha_multiplierLocation = gl.getUniformLocation(program, 'plugin_alpha_multiplier');
|
|
160
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
161
|
+
gl.useProgram(program);
|
|
162
|
+
gl.uniform1i(this._draw_modeLocation, this._lastMode);
|
|
163
|
+
gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
|
|
164
|
+
gl.uniform1f(this._plugin_alpha_multiplierLocation, 1.0);
|
|
165
|
+
this.cameraBlockBindingPoint = 0;
|
|
166
|
+
this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
167
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
168
|
+
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
169
|
+
gl.useProgram(currentProgram);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
draw(length, vao, edgeCount, alphaMultiplier, drawMode) {
|
|
173
|
+
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
174
|
+
// gl.disable(gl.DEPTH_TEST);
|
|
175
|
+
gl.useProgram(program);
|
|
176
|
+
if (drawModeMap[drawMode] !== this._lastMode) {
|
|
177
|
+
gl.uniform1i(this._draw_modeLocation, drawModeMap[drawMode]);
|
|
178
|
+
this._lastMode = drawModeMap[drawMode];
|
|
179
|
+
}
|
|
180
|
+
if (edgeCount !== this._lastEdgeCount) {
|
|
181
|
+
gl.uniform1f(this._edgeCountLocation, edgeCount);
|
|
182
|
+
this._lastEdgeCount = edgeCount;
|
|
183
|
+
}
|
|
184
|
+
if (alphaMultiplier !== this._lastAlphaMultiplier) {
|
|
185
|
+
gl.uniform1f(this._plugin_alpha_multiplierLocation, alphaMultiplier);
|
|
186
|
+
this._lastAlphaMultiplier = alphaMultiplier;
|
|
187
|
+
}
|
|
188
|
+
const overdraw = drawModeMap[drawMode];
|
|
189
|
+
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
190
|
+
gl.bindVertexArray(vao);
|
|
191
|
+
gl.drawArraysInstanced(gl[drawMode], 0, edgeCount + overdraw, length);
|
|
192
|
+
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
193
|
+
gl.bindVertexArray(null);
|
|
194
|
+
// gl.enable(gl.DEPTH_TEST);
|
|
195
|
+
}
|
|
196
|
+
free() {
|
|
197
|
+
noRegisterGlobeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
198
|
+
this.gl.deleteProgram(this.program);
|
|
199
|
+
this.program = null;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* in vec2 center; // long, lat in radian
|
|
203
|
+
in float start_angle; // the start of partial circle from bearing point
|
|
204
|
+
in float tail_angle; // the rotation of the partial circle
|
|
205
|
+
in vec4 color;
|
|
206
|
+
in float radius; // in meter
|
|
207
|
+
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
208
|
+
*/
|
|
209
|
+
createVAO(center2dObj, center3dObj, startAngle2DObj, tailAngle2DObj, startAngle3DObj, tailAngle3DObj, colorObj, radiusObj, colorModeObj) {
|
|
210
|
+
const { gl } = this;
|
|
211
|
+
const vao = gl.createVertexArray();
|
|
212
|
+
gl.bindVertexArray(vao);
|
|
213
|
+
{
|
|
214
|
+
const { buffer, stride, offset } = center2dObj;
|
|
215
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
216
|
+
gl.enableVertexAttribArray(0);
|
|
217
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
|
|
218
|
+
gl.vertexAttribDivisor(0, 1);
|
|
219
|
+
}
|
|
220
|
+
{
|
|
221
|
+
const { buffer, stride, offset } = center3dObj;
|
|
222
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
223
|
+
gl.enableVertexAttribArray(1);
|
|
224
|
+
gl.vertexAttribPointer(1, 3, gl.FLOAT, false, stride, offset);
|
|
225
|
+
gl.vertexAttribDivisor(1, 1);
|
|
226
|
+
}
|
|
227
|
+
{
|
|
228
|
+
const { buffer, stride, offset } = startAngle2DObj;
|
|
229
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
230
|
+
gl.enableVertexAttribArray(2);
|
|
231
|
+
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
|
|
232
|
+
gl.vertexAttribDivisor(2, 1);
|
|
233
|
+
}
|
|
234
|
+
{
|
|
235
|
+
const { buffer, stride, offset } = tailAngle2DObj;
|
|
236
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
237
|
+
gl.enableVertexAttribArray(3);
|
|
238
|
+
gl.vertexAttribPointer(3, 1, gl.FLOAT, false, stride, offset);
|
|
239
|
+
gl.vertexAttribDivisor(3, 1);
|
|
240
|
+
}
|
|
241
|
+
{
|
|
242
|
+
const { buffer, stride, offset } = startAngle3DObj;
|
|
243
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
244
|
+
gl.enableVertexAttribArray(4);
|
|
245
|
+
gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
|
|
246
|
+
gl.vertexAttribDivisor(4, 1);
|
|
247
|
+
}
|
|
248
|
+
{
|
|
249
|
+
const { buffer, stride, offset } = tailAngle3DObj;
|
|
250
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
251
|
+
gl.enableVertexAttribArray(5);
|
|
252
|
+
gl.vertexAttribPointer(5, 1, gl.FLOAT, false, stride, offset);
|
|
253
|
+
gl.vertexAttribDivisor(5, 1);
|
|
254
|
+
}
|
|
255
|
+
{
|
|
256
|
+
const { buffer, stride, offset } = colorObj;
|
|
257
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
258
|
+
gl.enableVertexAttribArray(6);
|
|
259
|
+
gl.vertexAttribPointer(6, 4, gl.FLOAT, false, stride, offset);
|
|
260
|
+
gl.vertexAttribDivisor(6, 1);
|
|
261
|
+
}
|
|
262
|
+
{
|
|
263
|
+
const { buffer, stride, offset } = radiusObj;
|
|
264
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
265
|
+
gl.enableVertexAttribArray(7);
|
|
266
|
+
gl.vertexAttribPointer(7, 1, gl.FLOAT, false, stride, offset);
|
|
267
|
+
gl.vertexAttribDivisor(7, 1);
|
|
268
|
+
}
|
|
269
|
+
{
|
|
270
|
+
const { buffer, stride, offset } = colorModeObj;
|
|
271
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
272
|
+
gl.enableVertexAttribArray(8);
|
|
273
|
+
gl.vertexAttribPointer(8, 1, gl.FLOAT, false, stride, offset);
|
|
274
|
+
gl.vertexAttribDivisor(8, 1);
|
|
275
|
+
}
|
|
276
|
+
gl.bindVertexArray(null);
|
|
277
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
278
|
+
return vao;
|
|
279
|
+
}
|
|
280
|
+
createUBO() {
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export const PieceOfPieProgramCache = Object.freeze({
|
|
284
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
285
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
286
|
+
});
|