@pirireis/webglobeplugins 0.0.9 → 0.0.10
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 +1 -1
- package/partialrings/plugin.js +1 -4
- package/partialrings/program.js +2 -3
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +3 -1
- package/programs/rings/distancering/paddyflatprogram.js +3 -1
- package/rangerings/rangerings.js +3 -10
- package/util/shaderfunctions/geometrytransformations.js +30 -1
package/package.json
CHANGED
package/partialrings/plugin.js
CHANGED
|
@@ -44,7 +44,6 @@ export default class {
|
|
|
44
44
|
this.gl = gl;
|
|
45
45
|
this.globe = globe;
|
|
46
46
|
this.program = programCache.get(globe);
|
|
47
|
-
console.log(this.program);
|
|
48
47
|
const { vao, buffer } = this.program.getVaoBuffer();
|
|
49
48
|
this.vao = vao;
|
|
50
49
|
this.buffer = buffer;
|
|
@@ -107,7 +106,6 @@ class BufferManager extends BufferOffsetManager {
|
|
|
107
106
|
|
|
108
107
|
|
|
109
108
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
110
|
-
console.log(bufferType, gl[bufferType], initialCapacity * ITEM_SIZE * 4);
|
|
111
109
|
gl.bufferData(gl.ARRAY_BUFFER, initialCapacity * ITEM_SIZE * 4, gl[bufferType]);
|
|
112
110
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
113
111
|
}
|
|
@@ -130,7 +128,6 @@ class BufferManager extends BufferOffsetManager {
|
|
|
130
128
|
}
|
|
131
129
|
const block = new Float32Array([
|
|
132
130
|
...center, startAngle, tailAngle, ...color, radius, colorMode]);
|
|
133
|
-
console.log(offset, block);
|
|
134
131
|
gl.bufferSubData(gl.ARRAY_BUFFER, offset, block);
|
|
135
132
|
// 2 1 1 1 4 1 = 10
|
|
136
133
|
}
|
|
@@ -161,7 +158,7 @@ class BufferManager extends BufferOffsetManager {
|
|
|
161
158
|
|
|
162
159
|
_autoExtendBuffer(payloadSize) {
|
|
163
160
|
const { gl, buffer, bufferType, extendRatio } = this;
|
|
164
|
-
if (payloadSize <= this.spaceLeft
|
|
161
|
+
if (payloadSize <= this.spaceLeft) return;
|
|
165
162
|
const newCapacity = Math.ceil((payloadSize + this.length) * extendRatio);
|
|
166
163
|
this.extendBuffer(gl, buffer, bufferType, newCapacity);
|
|
167
164
|
}
|
package/partialrings/program.js
CHANGED
|
@@ -72,7 +72,7 @@ void main() {
|
|
|
72
72
|
float phase = ( vertexID / edge_count);
|
|
73
73
|
|
|
74
74
|
if ( color_mode == 1.0 ) {
|
|
75
|
-
if ( tail_angle
|
|
75
|
+
if ( tail_angle < 0.0 ) {
|
|
76
76
|
v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
|
|
77
77
|
} else {
|
|
78
78
|
v_color = vec4( color.rgb , color.a * (phase ) * alpha );
|
|
@@ -82,7 +82,7 @@ void main() {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
float angle;
|
|
85
|
-
if ( tail_angle
|
|
85
|
+
if ( tail_angle > 0.0 ) {
|
|
86
86
|
angle = tail_angle * (-phase + 1.0) + start_angle;
|
|
87
87
|
} else {
|
|
88
88
|
angle = tail_angle * phase + start_angle;
|
|
@@ -163,7 +163,6 @@ export class Logic {
|
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
draw(bufferManager, vao, edgeCount, alphaMultiplier, drawMode) {
|
|
166
|
-
if (alphaMultiplier === 0) { console.log("no draw"); return };
|
|
167
166
|
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this
|
|
168
167
|
|
|
169
168
|
gl.disable(gl.DEPTH_TEST);
|
|
@@ -14,6 +14,7 @@ const vertexShader = `#version 300 es ` +
|
|
|
14
14
|
shaderfunctions.longLatRadToCartesian3D +
|
|
15
15
|
shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
16
16
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
17
|
+
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
|
|
17
18
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
18
19
|
|
|
19
20
|
in vec2 center;
|
|
@@ -49,7 +50,8 @@ void main() {
|
|
|
49
50
|
if ( compass == 1 ){
|
|
50
51
|
limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
51
52
|
} else {
|
|
52
|
-
limp =
|
|
53
|
+
limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
|
|
54
|
+
// limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
53
55
|
}
|
|
54
56
|
v_limp = limp;
|
|
55
57
|
gl_Position = mercatorXYTo2DPoint(limp);
|
|
@@ -12,6 +12,7 @@ const vertexShader = `#version 300 es ` +
|
|
|
12
12
|
shaderfunctions.longLatRadToCartesian3D +
|
|
13
13
|
shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
14
14
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
15
|
+
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
|
|
15
16
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
16
17
|
|
|
17
18
|
in vec2 center;
|
|
@@ -50,7 +51,8 @@ void main() {
|
|
|
50
51
|
if ( compass == 1 ){
|
|
51
52
|
limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
52
53
|
} else {
|
|
53
|
-
limp =
|
|
54
|
+
limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
|
|
55
|
+
// limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
54
56
|
}
|
|
55
57
|
v_limp = limp;
|
|
56
58
|
gl_Position = mercatorXYTo2DPoint(limp);
|
package/rangerings/rangerings.js
CHANGED
|
@@ -54,7 +54,7 @@ export default class {
|
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
draw3D() {
|
|
57
|
-
const { circleFlatProgram, paddyFlatProgram,
|
|
57
|
+
const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager } = this;
|
|
58
58
|
// if (globe.api_GetCurrentGeometry() === 0) return; // do not draw in 3D mode
|
|
59
59
|
if (this.bufferManager !== null && bufferManager.length > 0) {
|
|
60
60
|
gl.disable(gl.DEPTH_TEST);
|
|
@@ -68,9 +68,7 @@ export default class {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
this.padCount = padCount;
|
|
73
|
-
}
|
|
71
|
+
|
|
74
72
|
|
|
75
73
|
/**
|
|
76
74
|
* @param {RangeRingData} rangeRingData
|
|
@@ -88,11 +86,6 @@ export default class {
|
|
|
88
86
|
this.paddingBufferManager = this.paddingFreeAngleProgram.initilizeBufferManager({ bufferType: bufferDrawType, initialRingCapacity });
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
// getBufferManager() {
|
|
92
|
-
// return this.bufferManager;
|
|
93
|
-
// }
|
|
94
|
-
|
|
95
|
-
|
|
96
89
|
|
|
97
90
|
/**
|
|
98
91
|
* @typedef {Array<{ringID, radius, paddingRange}>} rings
|
|
@@ -150,7 +143,7 @@ const ringItemsToCircleBufferInsertDataAdaptor = (ringItems) => {
|
|
|
150
143
|
resultRings.push({
|
|
151
144
|
ringID,
|
|
152
145
|
radius,
|
|
153
|
-
padding: padding /
|
|
146
|
+
padding: padding / 5,
|
|
154
147
|
rgba,
|
|
155
148
|
});
|
|
156
149
|
}
|
|
@@ -95,6 +95,7 @@ vec3 longLatRadToCartesian3D( vec2 longLat) {
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
|
|
98
|
+
// TODO: Make it precise. It doesnt use haversine formula. If this changes, change the formmula which calculates text position.
|
|
98
99
|
export const circleLimpFromLongLatRadCenterCartesian3D = R + `
|
|
99
100
|
vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float angle) {
|
|
100
101
|
vec3 geoW = longLatRadToCartesian3D(center);
|
|
@@ -108,7 +109,7 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
|
|
|
108
109
|
}
|
|
109
110
|
`;
|
|
110
111
|
|
|
111
|
-
// TODO: Make it precise
|
|
112
|
+
// TODO: Make it precise.
|
|
112
113
|
export const circleLimpFromLongLatRadCenterMercatorRealDistance = `
|
|
113
114
|
vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
|
|
114
115
|
|
|
@@ -123,6 +124,34 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radiu
|
|
|
123
124
|
}
|
|
124
125
|
`;
|
|
125
126
|
|
|
127
|
+
// TODO: reconstruct this function
|
|
128
|
+
export const circleLimpFromLongLatRadCenterMercatorRealDistancePadding = `
|
|
129
|
+
vec2 circleLimpFromLongLatRadCenterMercatorRealDistancePadding(vec2 center, float radius, float angle){
|
|
130
|
+
float radius_radian = radius / R;
|
|
131
|
+
float new_angle;
|
|
132
|
+
if ( angle != - 1.5707963267948966192313216916398){
|
|
133
|
+
float section = floor(angle / ( PI / 2.0)) + 1.0;
|
|
134
|
+
float lat = center.y - radius_radian * sin(angle);
|
|
135
|
+
float scale = 1.0/abs( cos( lat ) );
|
|
136
|
+
new_angle = atan( tan(angle) * scale );
|
|
137
|
+
if ( section == 2.0 ){
|
|
138
|
+
new_angle = mod( new_angle, PI );
|
|
139
|
+
} else if ( section == 3.0 ){
|
|
140
|
+
new_angle = new_angle + PI;
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
new_angle = angle;
|
|
144
|
+
}
|
|
145
|
+
float new_lat = center.y - radius_radian * sin(new_angle);
|
|
146
|
+
float new_scale = 1.0/abs( cos( new_lat ) );
|
|
147
|
+
|
|
148
|
+
vec2 center_ = longLatRadToMercator(center);
|
|
149
|
+
float x = center_.x + new_scale * radius * cos(new_angle);
|
|
150
|
+
float y = center_.y - new_scale * radius * sin(new_angle);
|
|
151
|
+
return vec2(x, y);
|
|
152
|
+
}
|
|
153
|
+
`
|
|
154
|
+
|
|
126
155
|
|
|
127
156
|
export const circleLimpFromLongLatRadCenterMercatorCompass = `
|
|
128
157
|
vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, float angle){
|