@pirireis/webglobeplugins 0.10.13-alpha → 0.11.1-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-generate-points.js +361 -0
- package/altitude-locator/plugin.js +4 -7
- package/package.json +1 -1
- package/point-heat-map/plugin-webworker.js +3 -2
- package/programs/totems/camerauniformblock copy.js +171 -0
- package/programs/totems/camerauniformblock.js +81 -35
- package/programs/totems/camerauniformblock1.js +171 -0
- package/shape-on-terrain/arc/naive/plugin.js +110 -74
- package/types.js +1 -4
- package/Math/methods1.js +0 -183
package/Math/methods1.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { WORLD_RADIUS_3D, WORLD_RADIUS_MERCATOR } from './constants';
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {Array<number>} vec3 [x, y, z]
|
|
4
|
-
* @typedef {Array<number>} vec2 [x, y]
|
|
5
|
-
* @typedef {Array<number>} vec4 [x, y, z, w]
|
|
6
|
-
* @typedef {number} fraction a number between 0 and 1
|
|
7
|
-
* @typedef {Array<number>} wgs84 [long, lat]
|
|
8
|
-
*/
|
|
9
|
-
// *********************************************************
|
|
10
|
-
// **************** VECTOR OPERATIONS **********************
|
|
11
|
-
// *********************************************************
|
|
12
|
-
const RADIANS = Math.PI / 180;
|
|
13
|
-
/**
|
|
14
|
-
* @param {vec3} a
|
|
15
|
-
* @returns {vec3}
|
|
16
|
-
*/
|
|
17
|
-
const normalize3 = (a) => {
|
|
18
|
-
const len = length3(a);
|
|
19
|
-
return [a[0] / len, a[1] / len, a[2] / len];
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @param {vec3} a
|
|
23
|
-
* @param {vec3} b
|
|
24
|
-
* @returns {number}
|
|
25
|
-
*/
|
|
26
|
-
const dot3 = (a, b) => {
|
|
27
|
-
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* @param {vec3} a
|
|
31
|
-
* @returns {number}
|
|
32
|
-
*/
|
|
33
|
-
const length3 = (a) => {
|
|
34
|
-
return Math.sqrt(dot3(a, a));
|
|
35
|
-
};
|
|
36
|
-
// *********************************************************
|
|
37
|
-
// **************** TRANSFORMATIONS ************************
|
|
38
|
-
// *********************************************************
|
|
39
|
-
/**
|
|
40
|
-
* @param {vec3} cartesian
|
|
41
|
-
* @returns {vec2} long lat in radians
|
|
42
|
-
*/
|
|
43
|
-
const cartesian3dToRadian = (cartesian) => {
|
|
44
|
-
const x = cartesian[0];
|
|
45
|
-
const y = cartesian[1];
|
|
46
|
-
const z = cartesian[2];
|
|
47
|
-
// const length = Math.sqrt(x * x + y * y + z * z);
|
|
48
|
-
const long = Math.atan2(y, x);
|
|
49
|
-
const lat = Math.asin(z); // length);
|
|
50
|
-
return [long, lat];
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* @param {vec2} xy long lat in radians
|
|
54
|
-
* @returns {vec2} long lat in mercator meters
|
|
55
|
-
*/
|
|
56
|
-
const radianToMercator = (xy) => {
|
|
57
|
-
return [WORLD_RADIUS_MERCATOR * xy[0], WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + xy[1] / 2))];
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* @param {vec2} xy long lat radians
|
|
61
|
-
* @returns {vec3} cartesian
|
|
62
|
-
*/
|
|
63
|
-
const radianToCartesian3d = (xy) => {
|
|
64
|
-
const x = Math.cos(xy[1]) * Math.cos(xy[0]);
|
|
65
|
-
const y = Math.cos(xy[1]) * Math.sin(xy[0]);
|
|
66
|
-
const z = -Math.sin(xy[1]);
|
|
67
|
-
return [x, y, z];
|
|
68
|
-
};
|
|
69
|
-
// *********************************************************
|
|
70
|
-
// ***************** INTERPOLATIONS ************************
|
|
71
|
-
// *********************************************************
|
|
72
|
-
/**
|
|
73
|
-
* @param {vec3} normalizedA
|
|
74
|
-
* @param {vec3} normalizedB
|
|
75
|
-
* @param {fraction} ratio
|
|
76
|
-
* @returns {vec3}
|
|
77
|
-
*/
|
|
78
|
-
const sphericalLinearInterpolation_UnitVector = (normalizedA, normalizedB, ratio) => {
|
|
79
|
-
const theta = Math.acos(dot3(normalizedA, normalizedB));
|
|
80
|
-
if (theta < 0.000001)
|
|
81
|
-
return normalizedA; // CALIBRATE?
|
|
82
|
-
const sinTheta = Math.sin(theta);
|
|
83
|
-
const result = [
|
|
84
|
-
(Math.sin((1.0 - ratio) * theta) * normalizedA[0] + Math.sin(ratio * theta) * normalizedB[0]) / sinTheta,
|
|
85
|
-
(Math.sin((1.0 - ratio) * theta) * normalizedA[1] + Math.sin(ratio * theta) * normalizedB[1]) / sinTheta,
|
|
86
|
-
(Math.sin((1.0 - ratio) * theta) * normalizedA[2] + Math.sin(ratio * theta) * normalizedB[2]) / sinTheta
|
|
87
|
-
];
|
|
88
|
-
return result;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* @param {vec3} normalizedA
|
|
92
|
-
* @param {vec3} normalizedB
|
|
93
|
-
* @param {fraction} ratio
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
const sphericalLinearInterpolation_Mercator = (normalizedA, normalizedB, ratio) => {
|
|
97
|
-
const unitVector = sphericalLinearInterpolation_UnitVector(normalizedA, normalizedB, ratio);
|
|
98
|
-
const angles = cartesian3dToRadian(unitVector);
|
|
99
|
-
return radianToMercator(angles);
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* @param {vec4} a vec3 unit vector and length
|
|
103
|
-
* @param {vec4} b vec3 unit vector and length
|
|
104
|
-
* @param {fraction} ratio
|
|
105
|
-
*/
|
|
106
|
-
const sphericalLinearInterpolation_Cartesian3d = (a, b, ratio) => {
|
|
107
|
-
const unitVector = sphericalLinearInterpolation_UnitVector(a, b, ratio);
|
|
108
|
-
const height = a[3] + (b[3] - a[3]) * ratio;
|
|
109
|
-
return [unitVector[0] * height, unitVector[1] * height, unitVector[2] * height];
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
* @param {wgs84} coordinates
|
|
114
|
-
* @returns {vec3}
|
|
115
|
-
*/
|
|
116
|
-
const wgs84ToUnitVector = (coordinates) => {
|
|
117
|
-
const long = coordinates[0] * RADIANS;
|
|
118
|
-
const lat = coordinates[1] * RADIANS;
|
|
119
|
-
const x = Math.cos(lat) * Math.cos(long);
|
|
120
|
-
const y = Math.cos(lat) * Math.sin(long);
|
|
121
|
-
const z = Math.sin(lat);
|
|
122
|
-
return [x, y, z];
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* @param {number} long wgs84
|
|
126
|
-
* @param {number} lat wgs84
|
|
127
|
-
* @param {number} height
|
|
128
|
-
* @returns {vec3} cartesian3D
|
|
129
|
-
*/
|
|
130
|
-
const wgs84ToCartesian3d = (long, lat, height) => {
|
|
131
|
-
const longRad = long * RADIANS;
|
|
132
|
-
const latRad = lat * RADIANS;
|
|
133
|
-
const x = Math.cos(latRad) * Math.cos(longRad);
|
|
134
|
-
const y = Math.cos(latRad) * Math.sin(longRad);
|
|
135
|
-
const z = Math.sin(latRad);
|
|
136
|
-
const radius = WORLD_RADIUS_3D + height;
|
|
137
|
-
return [x * radius, y * radius, z * radius];
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* @param {number} long
|
|
141
|
-
* @param {number} lat
|
|
142
|
-
* @returns {vec2} mercator
|
|
143
|
-
*/
|
|
144
|
-
const wgs84ToMercator = (long, lat) => {
|
|
145
|
-
return [WORLD_RADIUS_MERCATOR * long * RADIANS, WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat * RADIANS / 2))];
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* @param {vec2} pixelXY
|
|
149
|
-
* @returns {vec2} long lat in radians
|
|
150
|
-
*/
|
|
151
|
-
const pixelXYToRadians = (pixelXY) => {
|
|
152
|
-
const long = (2.0 * pixelXY[0] - 1.0) * Math.PI;
|
|
153
|
-
const lat = (2.0 * pixelXY[1] - 1.0) * Math.PI / 2.0;
|
|
154
|
-
return [long, lat];
|
|
155
|
-
};
|
|
156
|
-
const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
|
|
157
|
-
const [long, lat] = pixelXYToRadians(pixelXYHeight);
|
|
158
|
-
const radius = WORLD_RADIUS_3D + pixelXYHeight[2];
|
|
159
|
-
return radianToCartesian3d([long, lat]).concat(radius);
|
|
160
|
-
};
|
|
161
|
-
const globe3Dcoordinates = (globe, height = 0) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
|
|
162
|
-
const len = longlats.length / 2;
|
|
163
|
-
const result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
|
|
164
|
-
for (let i = 0; i < len; i++) {
|
|
165
|
-
const long = longlats[i * 2];
|
|
166
|
-
const lat = longlats[i * 2 + 1];
|
|
167
|
-
const xyz = globe.api_GetCartesian3DPoint(long, lat, height, 0);
|
|
168
|
-
result.set(xyz, i * 3);
|
|
169
|
-
}
|
|
170
|
-
return result;
|
|
171
|
-
};
|
|
172
|
-
const globe2Dcoordinates = (globe) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
|
|
173
|
-
const len = longlats.length / 2;
|
|
174
|
-
const result = new Float32Array(len * 2 + paddingCount * 2).fill(paddingValue);
|
|
175
|
-
for (let i = 0; i < len; i++) {
|
|
176
|
-
const long = longlats[i * 2];
|
|
177
|
-
const lat = longlats[i * 2 + 1];
|
|
178
|
-
const xyz = globe.api_GetMercator2DPoint(long, lat);
|
|
179
|
-
result.set(xyz, i * 2);
|
|
180
|
-
}
|
|
181
|
-
return result;
|
|
182
|
-
};
|
|
183
|
-
export { RADIANS, normalize3, dot3, length3, cartesian3dToRadian, radianToMercator, radianToCartesian3d, sphericalLinearInterpolation_UnitVector, sphericalLinearInterpolation_Mercator, sphericalLinearInterpolation_Cartesian3d, wgs84ToUnitVector, wgs84ToCartesian3d, wgs84ToMercator, pixelXYLenghtToUnitVectorWithHeight, globe3Dcoordinates, globe2Dcoordinates, };
|