@pirireis/webglobeplugins 0.6.9 → 0.6.11
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.js
CHANGED
|
@@ -293,7 +293,7 @@ export default class Plugin {
|
|
|
293
293
|
updatePartial(items, propertyIDs = [], textWriterInjectionSubSetIDs = []) { // textWriterInjectionSubSetIDs = []
|
|
294
294
|
if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
|
|
295
295
|
const { _textContextInjectionMap, bufferOrchestrator, bufferManagersCompMap } = this;
|
|
296
|
-
const writers = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);
|
|
296
|
+
const writers = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);
|
|
297
297
|
for (let item of items) { this._insertTexts(item, writers) }
|
|
298
298
|
bufferOrchestrator.updateBulk(items, bufferManagersCompMap, propertyIDs);
|
|
299
299
|
// patch to update text opacity
|
package/package.json
CHANGED
|
@@ -54,7 +54,12 @@ void main() {
|
|
|
54
54
|
gl_Position = cartesian3DToGLPosition(position);
|
|
55
55
|
v_limp = vec2(0.0, 0.0);
|
|
56
56
|
} else {
|
|
57
|
-
vec2 position
|
|
57
|
+
vec2 position;
|
|
58
|
+
if (radius < 1200.0) {
|
|
59
|
+
position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius/ cos(center_position.y), angle);
|
|
60
|
+
} else {
|
|
61
|
+
position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_position, radius, angle);
|
|
62
|
+
}
|
|
58
63
|
v_limp = position;
|
|
59
64
|
gl_Position = mercatorXYToGLPosition( position);
|
|
60
65
|
|
package/util/check/typecheck.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
// Generic
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const doesOwnProperties = (properties, errorMessage) => {
|
|
4
|
+
return (object) => {
|
|
5
|
+
properties.forEach(element => {
|
|
6
|
+
if (!Object.hasOwn(object, element)) throw new TypeError(errorMessage + ':' + element);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export const isHexColor = (hexColor) => /^#[0-9A-F]{6}$/i.test(hexColor);
|
|
10
12
|
export const isHexColorWithOpacity = (hexColor) => /^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(hexColor);
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
export const opacityCheck = (opacity) => {
|
|
15
|
+
if (typeof opacity !== "number") throw new TypeError("style.opacity must a number");
|
|
16
|
+
if (opacity < 0 || 1 < opacity) throw new RangeError("Opacity Range Must be 0-1");
|
|
17
|
+
}
|
|
13
18
|
// Text Related
|
|
14
19
|
|
|
15
20
|
const fontCheckTypes = doesOwnProperties(["name", "textColor", "hollowColor", "size", "bold", "italic"], "font does not have");
|
|
@@ -17,7 +22,7 @@ const fontCheckColors = (textColor, hollowColor) => isHexColor(textColor) && isH
|
|
|
17
22
|
export const isTextFont = (textFont) => {
|
|
18
23
|
fontCheckTypes(textFont);
|
|
19
24
|
fontCheckColors(textFont.textColor, textFont.hollowColor);
|
|
20
|
-
if (
|
|
25
|
+
if (typeof textFont.size !== "number") throw new TypeError("textFont size is not a number");
|
|
21
26
|
|
|
22
27
|
}
|
|
23
28
|
|
|
@@ -17,7 +17,7 @@ export const R = `
|
|
|
17
17
|
|
|
18
18
|
export const PI = `
|
|
19
19
|
#ifndef PI
|
|
20
|
-
#define PI 3.
|
|
20
|
+
#define PI 3.141592653589793
|
|
21
21
|
#endif
|
|
22
22
|
`;
|
|
23
23
|
|
|
@@ -111,12 +111,32 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
|
|
|
111
111
|
// TODO: Make it precise. Y axis is not correct.
|
|
112
112
|
|
|
113
113
|
export const circleLimpFromLongLatRadCenterMercatorRealDistance = PI + `
|
|
114
|
+
vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle) {
|
|
115
|
+
float ang = angle + PI / 2.0; // Shift angle to align with +x axis
|
|
116
|
+
float r = radius / R;
|
|
117
|
+
float cos_r = cos(r);
|
|
118
|
+
float sin_r = sin(r);
|
|
119
|
+
|
|
120
|
+
float sin_lat = sin(center.y) * cos_r + cos(center.y) * sin_r * cos(ang);
|
|
121
|
+
float lat = asin(sin_lat);
|
|
122
|
+
|
|
123
|
+
float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
|
|
124
|
+
float longi = center.x + delta_long;
|
|
125
|
+
|
|
126
|
+
return vec2(
|
|
127
|
+
R * longi,
|
|
128
|
+
R * log(tan(PI / 4.0 + lat / 2.0))
|
|
129
|
+
);
|
|
130
|
+
}`;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
export const circleLimpFromLongLatRadCenterMercatorRealDistanceOLD = PI + `
|
|
114
134
|
vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
|
|
115
135
|
float ang = angle + PI / 2.0; // this is there because the other methods are implemented in, angle 0 is +x axis orientatation
|
|
116
|
-
float r =
|
|
117
|
-
float sin_lat =
|
|
136
|
+
float r = radius / R;
|
|
137
|
+
float sin_lat = sin(center.y) * cos(r) + cos(center.y) * sin(r) * cos(ang);
|
|
118
138
|
float lat = asin(sin_lat);
|
|
119
|
-
float longi = center.x + atan(
|
|
139
|
+
float longi = center.x + atan(sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
|
|
120
140
|
return longLatRadToMercator(vec2(longi, lat));
|
|
121
141
|
}
|
|
122
142
|
`;
|
|
@@ -124,23 +144,23 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radiu
|
|
|
124
144
|
// TODO: reconstruct this function
|
|
125
145
|
export const circleLimpFromLongLatRadCenterMercatorRealDistancePadding = `
|
|
126
146
|
vec2 circleLimpFromLongLatRadCenterMercatorRealDistancePadding(vec2 center, float radius, float angle){
|
|
127
|
-
float radius_radian =
|
|
147
|
+
float radius_radian = radius / R;
|
|
128
148
|
float new_angle;
|
|
129
|
-
if (
|
|
130
|
-
float section = floor(angle / (
|
|
149
|
+
if (angle != - 1.5707963267948966192313216916398) {
|
|
150
|
+
float section = floor(angle / (PI / 2.0)) + 1.0;
|
|
131
151
|
float lat = center.y - radius_radian * sin(angle);
|
|
132
|
-
float scale = 1.0/abs(
|
|
133
|
-
new_angle = atan(
|
|
134
|
-
if (
|
|
135
|
-
new_angle = mod(
|
|
136
|
-
} else if (
|
|
137
|
-
new_angle = new_angle + PI;
|
|
152
|
+
float scale = 1.0 / abs(cos(lat));
|
|
153
|
+
new_angle = atan(tan(angle) * scale);
|
|
154
|
+
if (section == 2.0) {
|
|
155
|
+
new_angle = mod(new_angle, PI);
|
|
156
|
+
} else if (section == 3.0) {
|
|
157
|
+
new_angle = new_angle + PI;
|
|
138
158
|
}
|
|
139
159
|
} else {
|
|
140
|
-
new_angle = angle;
|
|
160
|
+
new_angle = angle;
|
|
141
161
|
}
|
|
142
162
|
float new_lat = center.y - radius_radian * sin(new_angle);
|
|
143
|
-
float new_scale = 1.0/abs(
|
|
163
|
+
float new_scale = 1.0 / abs(cos(new_lat));
|
|
144
164
|
|
|
145
165
|
vec2 center_ = longLatRadToMercator(center);
|
|
146
166
|
float x = center_.x + new_scale * radius * cos(new_angle);
|
|
@@ -156,7 +176,7 @@ vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, fl
|
|
|
156
176
|
float y = -sin(angle) * radius + center_.y;
|
|
157
177
|
float x = cos(angle) * radius + center_.x;
|
|
158
178
|
return vec2(x, y);
|
|
159
|
-
}`;
|
|
179
|
+
} `;
|
|
160
180
|
|
|
161
181
|
|
|
162
182
|
// Function to interpolate between two Cartesian points using spherical interpolation (slerp)
|
|
@@ -186,7 +206,7 @@ vec2 cartesianToSpherical(vec3 point) {
|
|
|
186
206
|
float lon = degrees(atan(point.y, point.x)); // Longitude
|
|
187
207
|
|
|
188
208
|
return vec2(lat, lon);
|
|
189
|
-
}`;
|
|
209
|
+
} `;
|
|
190
210
|
|
|
191
211
|
// Main function to calculate an intermediate point
|
|
192
212
|
|
|
@@ -204,10 +224,10 @@ vec3 interpolateGeographicPoint(vec2 start, vec2 end, float t) {
|
|
|
204
224
|
|
|
205
225
|
export const angleBetweenTwoPointsRadian = `
|
|
206
226
|
float angleBetweenTwoPointsRadian(vec2 start_, vec2 end_) {
|
|
207
|
-
float start_lat = log(
|
|
208
|
-
float end_lat = log(
|
|
209
|
-
float angle = atan(
|
|
210
|
-
return angle;
|
|
227
|
+
float start_lat = log(tan((1.0 - start_.y) * PI / 2.0));
|
|
228
|
+
float end_lat = log(tan((1.0 - end_.y) * PI / 2.0));
|
|
229
|
+
float angle = atan((end_lat - start_lat) / (end_.x - start_.x));
|
|
230
|
+
return angle;
|
|
211
231
|
}
|
|
212
232
|
`
|
|
213
233
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSZMode } from "@pirireis/webglobe";
|
|
2
|
+
import { isTextFont, opacityCheck } from "../util/check/typecheck";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* TODOs:
|
|
@@ -39,9 +40,8 @@ export class ContextTextWriter3 {
|
|
|
39
40
|
} = {}) {
|
|
40
41
|
this.globe = globe;
|
|
41
42
|
this.itemMap = new Map();
|
|
42
|
-
this.style
|
|
43
|
+
this.setStyle(style);
|
|
43
44
|
this.doDraw = doDraw;
|
|
44
|
-
|
|
45
45
|
this._checkParameterTypes(textAdaptor, coordinatesAdaptor, keyAdaptor, opacityAdaptor, angleAdaptor, xOffset, yOffset);
|
|
46
46
|
|
|
47
47
|
this.textAdaptor = textAdaptor;
|
|
@@ -83,6 +83,8 @@ export class ContextTextWriter3 {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
setStyle(style) {
|
|
86
|
+
isTextFont(style.textFont);
|
|
87
|
+
opacityCheck(style.opacity);
|
|
86
88
|
this.style = style;
|
|
87
89
|
}
|
|
88
90
|
|
package/write-text/util.js
DELETED