@pirireis/webglobeplugins 0.9.14 → 0.10.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.js +188 -60
- package/Math/juction/arc-plane.js +38 -30
- package/Math/juction/line-sphere.js +14 -14
- package/Math/juction/plane-plane.js +9 -9
- package/Math/line.js +51 -52
- package/Math/plane.js +55 -56
- package/Math/quaternion.js +102 -97
- package/Math/vec3.js +120 -121
- package/heatwave/plugins/heatwaveglobeshell.js +7 -6
- package/package.json +1 -1
- package/programs/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +7 -13
- package/programs/vectorfields/logics/index.js +1 -3
- package/programs/vectorfields/logics/pixelbased.js +7 -16
- package/shape-on-terrain/arc/naive/plugin.js +22 -21
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +6 -6
- package/util/heatwavedatamanager/pointcoordsmeta.js +7 -2
- package/util/heatwavedatamanager/texture-point-sampler.js +160 -0
- package/util/webglobjectbuilders.js +13 -20
- package/waveparticles/plugin.js +14 -9
package/Math/plane.js
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
import { EPSILON } from "./constants";
|
|
2
|
-
import {
|
|
3
|
-
const _0vector = /*@__PURE__*/
|
|
4
|
-
const _1vector = /*@__PURE__*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
});
|
|
2
|
+
import { copy as vec3copy, create as vec3create, clone as vec3clone, set as vec3set, dot, subtract, multiplyScalar, cross, normalize, equals as vec3equals } from "./vec3";
|
|
3
|
+
const _0vector = /*@__PURE__*/ vec3create(0, 0, 0);
|
|
4
|
+
const _1vector = /*@__PURE__*/ vec3create(1, 1, 1);
|
|
5
|
+
function create(normal = vec3create(), distance = 0) {
|
|
6
|
+
return {
|
|
7
|
+
normal: vec3clone(normal),
|
|
8
|
+
distance: distance
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function set(out, normal, distance) {
|
|
12
|
+
vec3copy(out.normal, normal);
|
|
13
|
+
out.distance = distance;
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
function fromValues(out, nx, ny, nz, distance) {
|
|
17
|
+
vec3set(out.normal, nx, ny, nz);
|
|
18
|
+
out.distance = distance;
|
|
19
|
+
}
|
|
20
|
+
function copy(out, a) {
|
|
21
|
+
vec3copy(out.normal, a.normal);
|
|
22
|
+
out.distance = a.distance;
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
function clone(a) {
|
|
26
|
+
return {
|
|
27
|
+
normal: vec3clone(a.normal),
|
|
28
|
+
distance: a.distance
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function distanceToPoint(plane, point) {
|
|
32
|
+
return dot(plane.normal, point) - plane.distance;
|
|
33
|
+
}
|
|
34
|
+
function projectPoint(out, plane, point) {
|
|
35
|
+
const distance = distanceToPoint(plane, point);
|
|
36
|
+
multiplyScalar(out, plane.normal, distance);
|
|
37
|
+
subtract(out, point, out);
|
|
38
|
+
}
|
|
39
|
+
function equals(plane, other) {
|
|
40
|
+
return vec3equals(plane.normal, other.normal) && Math.abs(plane.distance - other.distance) < EPSILON;
|
|
41
|
+
}
|
|
42
|
+
function fromNormalAndCoplanarPoint(out, normal, point) {
|
|
43
|
+
vec3copy(out.normal, normal);
|
|
44
|
+
out.distance = dot(point, normal);
|
|
45
|
+
}
|
|
46
|
+
function fromPoints(out, a, b, c) {
|
|
47
|
+
subtract(_0vector, b, a);
|
|
48
|
+
subtract(_1vector, c, a);
|
|
49
|
+
cross(out.normal, _0vector, _1vector);
|
|
50
|
+
normalize(out.normal, out.normal);
|
|
51
|
+
out.distance = dot(out.normal, a);
|
|
52
|
+
}
|
|
53
|
+
function getUnitSphereRadiusAngle(plane) {
|
|
54
|
+
return Math.acos(Math.max(Math.min(plane.distance, 1), -1));
|
|
55
|
+
}
|
|
56
|
+
export { create, set, fromValues, copy, clone, distanceToPoint, projectPoint, equals, fromNormalAndCoplanarPoint, fromPoints, getUnitSphereRadiusAngle };
|
package/Math/quaternion.js
CHANGED
|
@@ -1,101 +1,106 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dot } from './vec3';
|
|
2
2
|
import { EPSILON } from './constants';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
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
|
-
|
|
3
|
+
function create(x = 0, y = 0, z = 0, w = 1) {
|
|
4
|
+
return [x, y, z, w];
|
|
5
|
+
}
|
|
6
|
+
function set(out, x, y, z, w) {
|
|
7
|
+
out[0] = x;
|
|
8
|
+
out[1] = y;
|
|
9
|
+
out[2] = z;
|
|
10
|
+
out[3] = w;
|
|
11
|
+
}
|
|
12
|
+
function copy(out, a) {
|
|
13
|
+
out[0] = a[0];
|
|
14
|
+
out[1] = a[1];
|
|
15
|
+
out[2] = a[2];
|
|
16
|
+
out[3] = a[3];
|
|
17
|
+
}
|
|
18
|
+
function clone(a) {
|
|
19
|
+
return [a[0], a[1], a[2], a[3]];
|
|
20
|
+
}
|
|
21
|
+
function lengthSquared(a) {
|
|
22
|
+
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3];
|
|
23
|
+
}
|
|
24
|
+
function length(a) {
|
|
25
|
+
return Math.sqrt(lengthSquared(a));
|
|
26
|
+
}
|
|
27
|
+
function normalize(out, input) {
|
|
28
|
+
const len = Math.sqrt(lengthSquared(input));
|
|
29
|
+
if (len < EPSILON) {
|
|
30
|
+
set(out, 0, 0, 0, 1);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const invLen = 1 / len;
|
|
34
|
+
set(out, input[0] * invLen, input[1] * invLen, input[2] * invLen, input[3] * invLen);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function multiply(out, a, b) {
|
|
38
|
+
const x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
|
|
39
|
+
const y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
|
|
40
|
+
const z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
|
|
41
|
+
const w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
|
|
42
|
+
set(out, x, y, z, w);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
function randomUnit(out) {
|
|
46
|
+
const u1 = Math.random();
|
|
47
|
+
const u2 = Math.random();
|
|
48
|
+
const u3 = Math.random();
|
|
49
|
+
const sqrt1MinusU1 = Math.sqrt(1 - u1);
|
|
50
|
+
const sqrtU1 = Math.sqrt(u1);
|
|
51
|
+
const x = sqrt1MinusU1 * Math.sin(2 * Math.PI * u2);
|
|
52
|
+
const y = sqrt1MinusU1 * Math.cos(2 * Math.PI * u2);
|
|
53
|
+
const z = sqrtU1 * Math.sin(2 * Math.PI * u3);
|
|
54
|
+
const w = sqrtU1 * Math.cos(2 * Math.PI * u3);
|
|
55
|
+
set(out, x, y, z, w);
|
|
56
|
+
normalize(out, out);
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
function rotateQuaternion(out, a, b) {
|
|
60
|
+
const x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
|
|
61
|
+
const y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
|
|
62
|
+
const z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
|
|
63
|
+
const w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
|
|
64
|
+
set(out, x, y, z, w);
|
|
65
|
+
normalize(out, out);
|
|
66
|
+
}
|
|
67
|
+
function fromUnitVectors(out, from, to) {
|
|
68
|
+
const d = dot(from, to) + 1;
|
|
69
|
+
if (d < EPSILON) {
|
|
70
|
+
if (Math.abs(from[0]) > Math.abs(from[2])) {
|
|
71
|
+
set(out, -from[1], from[0], 0, 0);
|
|
62
72
|
}
|
|
63
73
|
else {
|
|
64
|
-
|
|
65
|
-
this.set(out, input[0] * invLen, input[1] * invLen, input[2] * invLen, input[3] * invLen);
|
|
74
|
+
set(out, 0, -from[2], from[1], 0);
|
|
66
75
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const
|
|
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
|
-
const s = Math.sin(halfAngle);
|
|
99
|
-
this.set(out, axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(halfAngle));
|
|
100
|
-
},
|
|
101
|
-
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const x = from[1] * to[2] - from[2] * to[1];
|
|
79
|
+
const y = from[2] * to[0] - from[0] * to[2];
|
|
80
|
+
const z = from[0] * to[1] - from[1] * to[0];
|
|
81
|
+
set(out, x, y, z, d);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function fromTwoQuaternions(out, from, to) {
|
|
85
|
+
const x = from[0] * to[3] + from[3] * to[0] + from[1] * to[2] - from[2] * to[1];
|
|
86
|
+
const y = from[1] * to[3] + from[3] * to[1] + from[2] * to[0] - from[0] * to[2];
|
|
87
|
+
const z = from[2] * to[3] + from[3] * to[2] + from[0] * to[1] - from[1] * to[0];
|
|
88
|
+
const w = from[3] * to[3] - from[0] * to[0] - from[1] * to[1] - from[2] * to[2];
|
|
89
|
+
set(out, x, y, z, w);
|
|
90
|
+
normalize(out, out);
|
|
91
|
+
}
|
|
92
|
+
function conjugate(out, a) {
|
|
93
|
+
set(out, -a[0], -a[1], -a[2], a[3]);
|
|
94
|
+
}
|
|
95
|
+
function fromAxisAngle(out, axis, angle) {
|
|
96
|
+
const halfAngle = angle / 2;
|
|
97
|
+
const s = Math.sin(halfAngle);
|
|
98
|
+
set(out, axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(halfAngle));
|
|
99
|
+
}
|
|
100
|
+
function reverse(out, a) {
|
|
101
|
+
out[0] = -a[0];
|
|
102
|
+
out[1] = -a[1];
|
|
103
|
+
out[2] = -a[2];
|
|
104
|
+
out[3] = a[3];
|
|
105
|
+
}
|
|
106
|
+
export { create, set, copy, clone, length, lengthSquared, normalize, multiply, randomUnit, rotateQuaternion, fromUnitVectors, fromTwoQuaternions, conjugate, fromAxisAngle, reverse };
|
package/Math/vec3.js
CHANGED
|
@@ -1,123 +1,122 @@
|
|
|
1
1
|
import { EPSILON } from './constants';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
throw new Error('Division by zero');
|
|
50
|
-
}
|
|
51
|
-
out[0] = a[0] / b;
|
|
52
|
-
out[1] = a[1] / b;
|
|
53
|
-
out[2] = a[2] / b;
|
|
54
|
-
},
|
|
55
|
-
lengthSquared(a) {
|
|
56
|
-
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
|
|
57
|
-
},
|
|
58
|
-
length(a) {
|
|
59
|
-
return Math.sqrt(this.lengthSquared(a));
|
|
60
|
-
},
|
|
61
|
-
normalize(outVec, inVec) {
|
|
62
|
-
const len = this.length(inVec);
|
|
63
|
-
if (len === 0) {
|
|
64
|
-
throw new Error('Cannot normalize a zero vector');
|
|
65
|
-
}
|
|
66
|
-
outVec[0] = inVec[0] / len;
|
|
67
|
-
outVec[1] = inVec[1] / len;
|
|
68
|
-
outVec[2] = inVec[2] / len;
|
|
69
|
-
},
|
|
70
|
-
distanceSquared(a, b) {
|
|
71
|
-
const dx = a[0] - b[0];
|
|
72
|
-
const dy = a[1] - b[1];
|
|
73
|
-
const dz = a[2] - b[2];
|
|
74
|
-
return dx * dx + dy * dy + dz * dz;
|
|
75
|
-
},
|
|
76
|
-
distance(a, b) {
|
|
77
|
-
return Math.sqrt(this.distanceSquared(a, b));
|
|
78
|
-
},
|
|
79
|
-
equals(a, b) {
|
|
80
|
-
return (Math.abs(a[0] - b[0]) < EPSILON &&
|
|
81
|
-
Math.abs(a[1] - b[1]) < EPSILON &&
|
|
82
|
-
Math.abs(a[2] - b[2]) < EPSILON);
|
|
83
|
-
},
|
|
84
|
-
toUnitVectorLongLat(out, a) {
|
|
85
|
-
const len = this.length(a); // TODO Might drop length check
|
|
86
|
-
if (len === 0) {
|
|
87
|
-
throw new Error('Cannot convert a zero vector to unit vector');
|
|
88
|
-
}
|
|
89
|
-
out[0] = Math.atan2(a[1], a[0]); // Longitude
|
|
90
|
-
out[1] = Math.asin(a[2] / len); // Latitude
|
|
91
|
-
},
|
|
92
|
-
fromUnitVectorLongLat(out, longLat) {
|
|
93
|
-
const longitude = longLat[0];
|
|
94
|
-
const latitude = longLat[1];
|
|
95
|
-
const cosLat = Math.cos(latitude);
|
|
96
|
-
out[0] = cosLat * Math.cos(longitude);
|
|
97
|
-
out[1] = cosLat * Math.sin(longitude);
|
|
98
|
-
out[2] = Math.sin(latitude);
|
|
99
|
-
},
|
|
100
|
-
applyQuaternion(out, a, q) {
|
|
101
|
-
const x = a[0], y = a[1], z = a[2];
|
|
102
|
-
const qx = q[0], qy = q[1], qz = q[2], qw = q[3];
|
|
103
|
-
// Calculate the quaternion multiplication
|
|
104
|
-
const ix = qw * x + qy * z - qz * y;
|
|
105
|
-
const iy = qw * y + qz * x - qx * z;
|
|
106
|
-
const iz = qw * z + qx * y - qy * x;
|
|
107
|
-
const iw = -qx * x - qy * y - qz * z;
|
|
108
|
-
// Apply the quaternion to the vector
|
|
109
|
-
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
110
|
-
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
111
|
-
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
112
|
-
},
|
|
113
|
-
randomUnit(out) {
|
|
114
|
-
const theta = Math.random() * 2 * Math.PI;
|
|
115
|
-
const phi = Math.acos(2 * Math.random() - 1);
|
|
116
|
-
out[0] = Math.sin(phi) * Math.cos(theta);
|
|
117
|
-
out[1] = Math.sin(phi) * Math.sin(theta);
|
|
118
|
-
out[2] = Math.cos(phi);
|
|
119
|
-
},
|
|
120
|
-
str(a) {
|
|
121
|
-
return `Vec3(${a[0].toFixed(2)}, ${a[1].toFixed(2)}, ${a[2].toFixed(2)})`;
|
|
2
|
+
function create(x = 0, y = 0, z = 1) {
|
|
3
|
+
return [x, y, z];
|
|
4
|
+
}
|
|
5
|
+
function set(out, x, y, z) {
|
|
6
|
+
out[0] = x;
|
|
7
|
+
out[1] = y;
|
|
8
|
+
out[2] = z;
|
|
9
|
+
}
|
|
10
|
+
function clone(a) {
|
|
11
|
+
return [a[0], a[1], a[2]];
|
|
12
|
+
}
|
|
13
|
+
function copy(out, a) {
|
|
14
|
+
out[0] = a[0];
|
|
15
|
+
out[1] = a[1];
|
|
16
|
+
out[2] = a[2];
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
function add(out, a, b) {
|
|
20
|
+
out[0] = a[0] + b[0];
|
|
21
|
+
out[1] = a[1] + b[1];
|
|
22
|
+
out[2] = a[2] + b[2];
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
function subtract(out, a, b) {
|
|
26
|
+
out[0] = a[0] - b[0];
|
|
27
|
+
out[1] = a[1] - b[1];
|
|
28
|
+
out[2] = a[2] - b[2];
|
|
29
|
+
}
|
|
30
|
+
function dot(a, b) {
|
|
31
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
32
|
+
}
|
|
33
|
+
function cross(out, a, b) {
|
|
34
|
+
const x = a[1] * b[2] - a[2] * b[1];
|
|
35
|
+
const y = a[2] * b[0] - a[0] * b[2];
|
|
36
|
+
const z = a[0] * b[1] - a[1] * b[0];
|
|
37
|
+
out[0] = x;
|
|
38
|
+
out[1] = y;
|
|
39
|
+
out[2] = z;
|
|
40
|
+
}
|
|
41
|
+
function multiplyScalar(out, a, b) {
|
|
42
|
+
out[0] = a[0] * b;
|
|
43
|
+
out[1] = a[1] * b;
|
|
44
|
+
out[2] = a[2] * b;
|
|
45
|
+
}
|
|
46
|
+
function divideScalar(out, a, b) {
|
|
47
|
+
if (b === 0) {
|
|
48
|
+
throw new Error('Division by zero');
|
|
122
49
|
}
|
|
123
|
-
|
|
50
|
+
out[0] = a[0] / b;
|
|
51
|
+
out[1] = a[1] / b;
|
|
52
|
+
out[2] = a[2] / b;
|
|
53
|
+
}
|
|
54
|
+
function lengthSquared(a) {
|
|
55
|
+
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
|
|
56
|
+
}
|
|
57
|
+
function length(a) {
|
|
58
|
+
return Math.sqrt(lengthSquared(a));
|
|
59
|
+
}
|
|
60
|
+
function normalize(outVec, inVec) {
|
|
61
|
+
const len = length(inVec);
|
|
62
|
+
if (len === 0) {
|
|
63
|
+
throw new Error('Cannot normalize a zero vector');
|
|
64
|
+
}
|
|
65
|
+
outVec[0] = inVec[0] / len;
|
|
66
|
+
outVec[1] = inVec[1] / len;
|
|
67
|
+
outVec[2] = inVec[2] / len;
|
|
68
|
+
}
|
|
69
|
+
function distanceSquared(a, b) {
|
|
70
|
+
const dx = a[0] - b[0];
|
|
71
|
+
const dy = a[1] - b[1];
|
|
72
|
+
const dz = a[2] - b[2];
|
|
73
|
+
return dx * dx + dy * dy + dz * dz;
|
|
74
|
+
}
|
|
75
|
+
function distance(a, b) {
|
|
76
|
+
return Math.sqrt(distanceSquared(a, b));
|
|
77
|
+
}
|
|
78
|
+
function equals(a, b) {
|
|
79
|
+
return (Math.abs(a[0] - b[0]) < EPSILON &&
|
|
80
|
+
Math.abs(a[1] - b[1]) < EPSILON &&
|
|
81
|
+
Math.abs(a[2] - b[2]) < EPSILON);
|
|
82
|
+
}
|
|
83
|
+
function toUnitVectorLongLat(out, a) {
|
|
84
|
+
const len = length(a); // TODO Might drop length check
|
|
85
|
+
if (len === 0) {
|
|
86
|
+
throw new Error('Cannot convert a zero vector to unit vector');
|
|
87
|
+
}
|
|
88
|
+
out[0] = Math.atan2(a[1], a[0]); // Longitude
|
|
89
|
+
out[1] = Math.asin(a[2] / len); // Latitude
|
|
90
|
+
}
|
|
91
|
+
function fromUnitVectorLongLat(out, longLat) {
|
|
92
|
+
const longitude = longLat[0];
|
|
93
|
+
const latitude = longLat[1];
|
|
94
|
+
const cosLat = Math.cos(latitude);
|
|
95
|
+
out[0] = cosLat * Math.cos(longitude);
|
|
96
|
+
out[1] = cosLat * Math.sin(longitude);
|
|
97
|
+
out[2] = Math.sin(latitude);
|
|
98
|
+
}
|
|
99
|
+
function applyQuaternion(out, a, q) {
|
|
100
|
+
const x = a[0], y = a[1], z = a[2];
|
|
101
|
+
const qx = q[0], qy = q[1], qz = q[2], qw = q[3];
|
|
102
|
+
// Calculate the quaternion multiplication
|
|
103
|
+
const ix = qw * x + qy * z - qz * y;
|
|
104
|
+
const iy = qw * y + qz * x - qx * z;
|
|
105
|
+
const iz = qw * z + qx * y - qy * x;
|
|
106
|
+
const iw = -qx * x - qy * y - qz * z;
|
|
107
|
+
// Apply the quaternion to the vector
|
|
108
|
+
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
109
|
+
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
110
|
+
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
111
|
+
}
|
|
112
|
+
function randomUnit(out) {
|
|
113
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
114
|
+
const phi = Math.acos(2 * Math.random() - 1);
|
|
115
|
+
out[0] = Math.sin(phi) * Math.cos(theta);
|
|
116
|
+
out[1] = Math.sin(phi) * Math.sin(theta);
|
|
117
|
+
out[2] = Math.cos(phi);
|
|
118
|
+
}
|
|
119
|
+
function str(a) {
|
|
120
|
+
return `Vec3(${a[0].toFixed(2)}, ${a[1].toFixed(2)}, ${a[2].toFixed(2)})`;
|
|
121
|
+
}
|
|
122
|
+
export { create, set, clone, copy, add, subtract, dot, cross, multiplyScalar, divideScalar, lengthSquared, length, normalize, distanceSquared, distance, equals, toUnitVectorLongLat, fromUnitVectorLongLat, applyQuaternion, randomUnit, str };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getColorRampModed, DataManager,
|
|
1
|
+
import { getColorRampModed, DataManager, } from "../../util/index";
|
|
2
|
+
import { TexturePointSampler } from "../../util/heatwavedatamanager/texture-point-sampler";
|
|
2
3
|
import { GlobeShellWiggle, Float2LegendWithRatio } from "../../programs";
|
|
3
4
|
import { opacityCheck } from "../../util/check/typecheck";
|
|
4
5
|
/**
|
|
@@ -50,9 +51,9 @@ export default class HeatWaveGlobeShellPlugin {
|
|
|
50
51
|
this._escapeValue = escapeValue;
|
|
51
52
|
this.heatProgram.setEscapeValue(escapeValue);
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
this.coordinatesDataCalculator = new
|
|
55
|
-
this.dataManager.register(this._coordinatesDataCalculatorID(), this.coordinatesDataCalculator.
|
|
54
|
+
_createTexturePointSampler() {
|
|
55
|
+
this.coordinatesDataCalculator = new TexturePointSampler(this._bbox, this._dataWidthHeight.width, this._dataWidthHeight.height);
|
|
56
|
+
this.dataManager.register(this._coordinatesDataCalculatorID(), this.coordinatesDataCalculator.updateTextureData.bind(this.coordinatesDataCalculator));
|
|
56
57
|
}
|
|
57
58
|
_coordinatesDataCalculatorID() {
|
|
58
59
|
return this.id + "_coordinatesDataCalculator";
|
|
@@ -77,9 +78,9 @@ export default class HeatWaveGlobeShellPlugin {
|
|
|
77
78
|
this.globeShell.setBBox({ minLon, minLat, maxLon, maxLat });
|
|
78
79
|
this.drawHeat();
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
getTexturePointSampler() {
|
|
81
82
|
if (!this.coordinatesDataCalculator)
|
|
82
|
-
this.
|
|
83
|
+
this._createTexturePointSampler();
|
|
83
84
|
return this.coordinatesDataCalculator;
|
|
84
85
|
}
|
|
85
86
|
/**
|
package/package.json
CHANGED
package/programs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { GlobeShellWiggle } from "./globeshell/wiggle";
|
|
|
3
3
|
import { CameraUniformBlockTotem, CameraUniformBlockString } from "./totems/index";
|
|
4
4
|
import ArrowField from "./arrowfield";
|
|
5
5
|
import { glProgramCache, globeProgramCache, noRegisterGlobeProgramCache } from "./programcache";
|
|
6
|
-
import * as vectorfield from "./vectorfields";
|
|
6
|
+
import * as vectorfield from "./vectorfields/index";
|
|
7
7
|
import { FadeAway } from "./helpers";
|
|
8
8
|
import * as rings from "./rings";
|
|
9
9
|
export { Float2LegendWithRatio, GlobeShellWiggle, ArrowField, CameraUniformBlockTotem, CameraUniformBlockString, glProgramCache, globeProgramCache, noRegisterGlobeProgramCache, vectorfield, FadeAway, rings };
|
|
@@ -88,17 +88,11 @@ class Logic {
|
|
|
88
88
|
this.program = null;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.logic.draw(bufferManager, vectorTexture, uboManager);
|
|
91
|
+
export const drawRectangleParticlesProgramCache = Object.freeze({
|
|
92
|
+
getProgram: (gl) => {
|
|
93
|
+
return glProgramCache.getProgram(gl, Logic);
|
|
94
|
+
},
|
|
95
|
+
releaseProgram: (gl) => {
|
|
96
|
+
glProgramCache.releaseProgram(gl, Logic);
|
|
98
97
|
}
|
|
99
|
-
|
|
100
|
-
glProgramCache.releaseProgram(this.gl, Logic);
|
|
101
|
-
this.logic = null;
|
|
102
|
-
this.gl = null;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
98
|
+
});
|