@pirireis/webglobeplugins 0.8.26 → 0.9.2
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.ts +74 -245
- package/Math/constants.ts +4 -1
- package/Math/frustum/camera.ts +32 -0
- package/Math/frustum/from-globeinfo.ts +63 -0
- package/Math/frustum/types.ts +11 -0
- package/Math/globe-util/horizon-plane.ts +137 -0
- package/Math/juction/arc-plane.ts +90 -0
- package/Math/juction/line-sphere.ts +30 -0
- package/Math/juction/plane-plane.ts +66 -0
- package/Math/line.ts +70 -0
- package/Math/methods.js +29 -1
- package/Math/plane.ts +57 -138
- package/Math/quaternion.ts +108 -144
- package/Math/types.ts +39 -30
- package/Math/vec3.ts +155 -0
- package/altitude-locator/plugin.js +1 -1
- package/bearing-line/plugin.js +1 -1
- package/circle-line-chain/plugin.js +1 -1
- package/globe-types.ts +13 -0
- package/heatwave/plugins/heatwaveglobeshell.js +5 -9
- package/index.js +3 -0
- package/package.json +1 -1
- package/programs/interface.ts +7 -0
- package/programs/line-on-globe/circle-accurate-3d.js +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
- package/programs/line-on-globe/lines-color-instanced-flat.js +1 -1
- package/programs/line-on-globe/linestrip.ts +228 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +1 -1
- package/programs/line-on-globe/to-the-surface.js +1 -1
- package/programs/picking/pickable-renderer.js +1 -1
- package/programs/point-on-globe/element-globe-surface-glow.js +1 -1
- package/programs/point-on-globe/element-point-glow.js +1 -1
- package/programs/totems/camerauniformblock.js +24 -1
- package/shape-on-terrain/arc/naive/plugin.ts +304 -0
- package/tests/Math/junction/arc-plane.test.ts +129 -0
- package/tests/Math/junction/plane-plane.test.ts +82 -0
- package/tests/Math/plane.test.ts +30 -32
- package/tests/Math/vec3.test.ts +14 -0
- package/timetracks/plugin-line-strip.js +3 -1
- package/{types.js → types.ts} +2 -1
- package/util/account/{index.js → index.ts} +1 -2
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -31
- package/util/account/single-attribute-buffer-management/index.ts +13 -0
- package/util/gl-util/buffer/{integrate-buffer.js → attribute-loader.ts} +17 -6
- package/util/gl-util/buffer/index.ts +6 -0
- package/util/gl-util/buffer/types.ts +13 -0
- package/util/gl-util/draw-options/methods.js +4 -4
- package/util/gl-util/draw-options/{types.js → types.ts} +10 -0
- package/util/gl-util/uniform-block/{manager.js → manager.ts} +24 -13
- package/util/gl-util/uniform-block/types.ts +27 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +17 -17
- package/waveparticles/plugin.js +3 -0
- package/wind/plugin.js +39 -52
- package/Math/methodology/arc-part-on-screen.ts +0 -47
- package/Math/ray.ts +0 -101
- package/Math/vector3d.ts +0 -241
- package/shape-on-terrain/tree-search.js +0 -0
- package/surface-cover-shapes/arc/naive/data-manager.ts +0 -0
- package/surface-cover-shapes/arc/naive/plugin.ts +0 -0
- package/tests/Math/arc.test.ts +0 -112
- package/tests/Math/quaternion.test.ts +0 -98
- package/tests/Math/ray-plane.test.ts +0 -176
- package/tests/Math/vector3d.test.ts +0 -104
- package/util/account/single-attribute-buffer-management/index.js +0 -4
- package/util/gl-util/uniform-block/types.js +0 -7
- /package/{shape-on-terrain/intersection.js → Math/matrix4.ts} +0 -0
package/Math/quaternion.ts
CHANGED
|
@@ -1,159 +1,123 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
y:
|
|
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
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
import { Vec3, Quaternion } from './types';
|
|
2
|
+
import { vec3 } from './vec3';
|
|
3
|
+
import { EPSILON } from './constants';
|
|
4
|
+
|
|
5
|
+
export const quaternion = Object.freeze({
|
|
6
|
+
create(x = 0, y = 0, z = 0, w = 1): Quaternion {
|
|
7
|
+
return [x, y, z, w];
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
set(out: Quaternion, x: number, y: number, z: number, w: number) {
|
|
11
|
+
out[0] = x;
|
|
12
|
+
out[1] = y;
|
|
13
|
+
out[2] = z;
|
|
14
|
+
out[3] = w;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
copy(out: Quaternion, a: Quaternion) {
|
|
18
|
+
out[0] = a[0];
|
|
19
|
+
out[1] = a[1];
|
|
20
|
+
out[2] = a[2];
|
|
21
|
+
out[3] = a[3];
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
clone(a: Quaternion): Quaternion {
|
|
25
|
+
return [a[0], a[1], a[2], a[3]];
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
multiply(out: Quaternion, a: Quaternion, b: Quaternion): Quaternion {
|
|
30
|
+
const x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
|
|
31
|
+
const y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
|
|
32
|
+
const z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
|
|
33
|
+
const w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
|
|
34
|
+
this.set(out, x, y, z, w);
|
|
35
|
+
return out;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
randomUnit(out: Quaternion): Quaternion {
|
|
39
|
+
const u1 = Math.random();
|
|
40
|
+
const u2 = Math.random();
|
|
41
|
+
const u3 = Math.random();
|
|
42
|
+
const sqrt1MinusU1 = Math.sqrt(1 - u1);
|
|
43
|
+
const sqrtU1 = Math.sqrt(u1);
|
|
44
|
+
const x = sqrt1MinusU1 * Math.sin(2 * Math.PI * u2);
|
|
45
|
+
const y = sqrt1MinusU1 * Math.cos(2 * Math.PI * u2);
|
|
46
|
+
const z = sqrtU1 * Math.sin(2 * Math.PI * u3);
|
|
47
|
+
const w = sqrtU1 * Math.cos(2 * Math.PI * u3);
|
|
48
|
+
this.set(out, x, y, z, w);
|
|
49
|
+
this.normalize(out, out);
|
|
50
|
+
return out;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
rotateQuaternion(out: Quaternion, a: Quaternion, b: Quaternion) {
|
|
54
|
+
const x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
|
|
55
|
+
const y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
|
|
56
|
+
const z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
|
|
57
|
+
const w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
|
|
58
|
+
this.set(out, x, y, z, w);
|
|
59
|
+
this.normalize(out);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
lengthSquared(a: Quaternion): number {
|
|
63
|
+
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3];
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
length(a: Quaternion): number {
|
|
67
|
+
return Math.sqrt(this.lengthSquared(a));
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
normalize(out: Quaternion) {
|
|
71
|
+
const len = Math.sqrt(this.lengthSquared(out));
|
|
72
|
+
if (len < EPSILON) {
|
|
73
|
+
this.set(out, 0, 0, 0, 1);
|
|
54
74
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.z = other.z;
|
|
64
|
-
this.w = other.w;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
clone(): Quaternion {
|
|
71
|
-
return new Quaternion(this.x, this.y, this.z, this.w);
|
|
72
|
-
}
|
|
73
|
-
|
|
75
|
+
else {
|
|
76
|
+
const invLen = 1 / len;
|
|
77
|
+
out[0] *= invLen;
|
|
78
|
+
out[1] *= invLen;
|
|
79
|
+
out[2] *= invLen;
|
|
80
|
+
out[3] *= invLen;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
74
83
|
|
|
84
|
+
fromUnitVectors(out: Quaternion, from: Vec3, to: Vec3) {
|
|
75
85
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.set(-vFrom.y, vFrom.x, 0, 0);
|
|
86
|
+
const d = vec3.dot(from, to) + 1;
|
|
87
|
+
if (d < EPSILON) {
|
|
88
|
+
if (Math.abs(from[0]) > Math.abs(from[2])) {
|
|
89
|
+
this.set(out, -from[1], from[0], 0, 0);
|
|
81
90
|
} else {
|
|
82
|
-
this.set(0, -
|
|
91
|
+
this.set(out, 0, -from[2], from[1], 0);
|
|
83
92
|
}
|
|
93
|
+
} else {
|
|
94
|
+
const x = from[1] * to[2] - from[2] * to[1];
|
|
95
|
+
const y = from[2] * to[0] - from[0] * to[2];
|
|
96
|
+
const z = from[0] * to[1] - from[1] * to[0];
|
|
97
|
+
this.set(out, x, y, z, d);
|
|
84
98
|
}
|
|
85
|
-
|
|
86
|
-
this.set(
|
|
87
|
-
vFrom.y * vTo.z - vFrom.z * vTo.y,
|
|
88
|
-
vFrom.z * vTo.x - vFrom.x * vTo.z,
|
|
89
|
-
vFrom.x * vTo.y - vFrom.y * vTo.x,
|
|
90
|
-
d
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
},
|
|
97
100
|
|
|
98
|
-
static fromUnitVectors(vFrom: Vector3D, vTo: Vector3D): Quaternion {
|
|
99
|
-
return new Quaternion().setFromUnitVectors(vFrom, vTo);
|
|
100
|
-
}
|
|
101
101
|
|
|
102
|
+
fromTwoQuaternions(out: Quaternion, from: Quaternion, to: Quaternion) {
|
|
103
|
+
const x = from[0] * to[3] + from[3] * to[0] + from[1] * to[2] - from[2] * to[1];
|
|
104
|
+
const y = from[1] * to[3] + from[3] * to[1] + from[2] * to[0] - from[0] * to[2];
|
|
105
|
+
const z = from[2] * to[3] + from[3] * to[2] + from[0] * to[1] - from[1] * to[0];
|
|
106
|
+
const w = from[3] * to[3] - from[0] * to[0] - from[1] * to[1] - from[2] * to[2];
|
|
107
|
+
this.set(out, x, y, z, w);
|
|
108
|
+
this.normalize(out);
|
|
109
|
+
},
|
|
102
110
|
|
|
111
|
+
conjugate(out: Quaternion, a: Quaternion) {
|
|
112
|
+
this.set(out, -a[0], -a[1], -a[2], a[3]);
|
|
113
|
+
},
|
|
103
114
|
|
|
104
|
-
|
|
115
|
+
fromAxisAngle(out: Quaternion, axis: Vec3, angle: number) {
|
|
105
116
|
const halfAngle = angle / 2;
|
|
106
117
|
const s = Math.sin(halfAngle);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.y = axis.y * s / len;
|
|
110
|
-
this.z = axis.z * s / len;
|
|
111
|
-
this.w = Math.cos(halfAngle);
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
static fromAxisAngle(axis: Vector3D, angle: Radians): Quaternion {
|
|
118
|
-
return new Quaternion().setFromAxisAngle(axis, angle);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
rotatePoint(point: Vector3D, out: Vector3D) {
|
|
124
|
-
const x = point.x;
|
|
125
|
-
const y = point.y;
|
|
126
|
-
const z = point.z;
|
|
127
|
-
|
|
128
|
-
const qx = this.x;
|
|
129
|
-
const qy = this.y;
|
|
130
|
-
const qz = this.z;
|
|
131
|
-
const qw = this.w;
|
|
132
|
-
|
|
133
|
-
const ix = qw * x + qy * z - qz * y;
|
|
134
|
-
const iy = qw * y + qz * x - qx * z;
|
|
135
|
-
const iz = qw * z + qx * y - qy * x;
|
|
136
|
-
const iw = -qx * x - qy * y - qz * z;
|
|
137
|
-
|
|
138
|
-
out.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
139
|
-
out.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
140
|
-
out.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
141
|
-
|
|
142
|
-
return out;
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
118
|
+
this.set(out, axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(halfAngle));
|
|
119
|
+
},
|
|
146
120
|
|
|
147
|
-
toMatrix4x4(): number[] {
|
|
148
|
-
const x = this.x, y = this.y, z = this.z, w = this.w;
|
|
149
|
-
const xx = x * x, yy = y * y, zz = z * z, xy = x * y, xz = x * z, yz = y * z, wx = w * x, wy = w * y, wz = w * z;
|
|
150
|
-
return [
|
|
151
|
-
1 - 2 * (yy + zz), 2 * (xy - wz), 2 * (xz + wy), 0,
|
|
152
|
-
2 * (xy + wz), 1 - 2 * (xx + zz), 2 * (yz - wx), 0,
|
|
153
|
-
2 * (xz - wy), 2 * (yz + wx), 1 - 2 * (xx + yy), 0,
|
|
154
|
-
0, 0, 0, 1
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
121
|
|
|
122
|
+
});
|
|
158
123
|
|
|
159
|
-
}
|
package/Math/types.ts
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
type Radians = number;
|
|
2
|
+
type Degrees = number;
|
|
3
|
+
type Meter = number;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type Vec3 = [number, number, number];
|
|
7
|
+
|
|
8
|
+
type Line = {
|
|
9
|
+
origin: Vec3;
|
|
10
|
+
direction: Vec3;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Plane = {
|
|
14
|
+
normal: Vec3;
|
|
15
|
+
distance: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type LongLat = [number, number]; // [longitude, latitude]
|
|
19
|
+
|
|
20
|
+
type Quaternion = [number, number, number, number];
|
|
21
|
+
|
|
22
|
+
type Arc = {
|
|
23
|
+
p0: Vec3;
|
|
24
|
+
p1: Vec3;
|
|
25
|
+
normal: Vec3;
|
|
26
|
+
coverPlane: Plane;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
z: number;
|
|
30
|
-
w: number;
|
|
29
|
+
type Sphere = {
|
|
30
|
+
center: Vec3;
|
|
31
|
+
radius: number;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
Vec3,
|
|
36
|
+
Line,
|
|
37
|
+
Plane,
|
|
38
|
+
Quaternion,
|
|
39
|
+
Arc,
|
|
40
|
+
Sphere,
|
|
41
|
+
Radians,
|
|
42
|
+
Degrees,
|
|
43
|
+
Meter,
|
|
44
|
+
LongLat,
|
|
36
45
|
}
|
package/Math/vec3.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Vec3, LongLat, Quaternion } from './types';
|
|
2
|
+
import { EPSILON } from './constants';
|
|
3
|
+
|
|
4
|
+
export const vec3 = Object.freeze({
|
|
5
|
+
create(x = 0, y = 0, z = 1): Vec3 {
|
|
6
|
+
return [x, y, z];
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
set(out: Vec3, x: number, y: number, z: number) {
|
|
10
|
+
out[0] = x;
|
|
11
|
+
out[1] = y;
|
|
12
|
+
out[2] = z;
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
clone(a: Vec3): Vec3 {
|
|
16
|
+
return [a[0], a[1], a[2]];
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
copy(out: Vec3, a: Vec3): Vec3 {
|
|
20
|
+
out[0] = a[0];
|
|
21
|
+
out[1] = a[1];
|
|
22
|
+
out[2] = a[2];
|
|
23
|
+
return out;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
add(out: Vec3, a: Vec3, b: Vec3): Vec3 {
|
|
27
|
+
out[0] = a[0] + b[0];
|
|
28
|
+
out[1] = a[1] + b[1];
|
|
29
|
+
out[2] = a[2] + b[2];
|
|
30
|
+
return out;
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
subtract(out: Vec3, a: Vec3, b: Vec3) {
|
|
34
|
+
out[0] = a[0] - b[0];
|
|
35
|
+
out[1] = a[1] - b[1];
|
|
36
|
+
out[2] = a[2] - b[2];
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
dot(a: Vec3, b: Vec3): number {
|
|
40
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
cross(out: Vec3, a: Vec3, b: Vec3) {
|
|
44
|
+
const x = a[1] * b[2] - a[2] * b[1];
|
|
45
|
+
const y = a[2] * b[0] - a[0] * b[2];
|
|
46
|
+
const z = a[0] * b[1] - a[1] * b[0];
|
|
47
|
+
out[0] = x;
|
|
48
|
+
out[1] = y;
|
|
49
|
+
out[2] = z;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
multiplyScalar(out: Vec3, a: Vec3, b: number) {
|
|
54
|
+
out[0] = a[0] * b;
|
|
55
|
+
out[1] = a[1] * b;
|
|
56
|
+
out[2] = a[2] * b;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
divideScalar(out: Vec3, a: Vec3, b: number) {
|
|
60
|
+
if (b === 0) {
|
|
61
|
+
throw new Error('Division by zero');
|
|
62
|
+
}
|
|
63
|
+
out[0] = a[0] / b;
|
|
64
|
+
out[1] = a[1] / b;
|
|
65
|
+
out[2] = a[2] / b;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
lengthSquared(a: Vec3): number {
|
|
69
|
+
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
length(a: Vec3): number {
|
|
73
|
+
return Math.sqrt(this.lengthSquared(a));
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
normalize(outVec: Vec3, inVec: Vec3) {
|
|
77
|
+
const len = this.length(inVec);
|
|
78
|
+
if (len === 0) {
|
|
79
|
+
throw new Error('Cannot normalize a zero vector');
|
|
80
|
+
}
|
|
81
|
+
outVec[0] = inVec[0] / len;
|
|
82
|
+
outVec[1] = inVec[1] / len;
|
|
83
|
+
outVec[2] = inVec[2] / len;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
distanceSquared(a: Vec3, b: Vec3): number {
|
|
88
|
+
const dx = a[0] - b[0];
|
|
89
|
+
const dy = a[1] - b[1];
|
|
90
|
+
const dz = a[2] - b[2];
|
|
91
|
+
return dx * dx + dy * dy + dz * dz;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
distance(a: Vec3, b: Vec3): number {
|
|
96
|
+
return Math.sqrt(this.distanceSquared(a, b));
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
equals(a: Vec3, b: Vec3): boolean {
|
|
100
|
+
return (
|
|
101
|
+
Math.abs(a[0] - b[0]) < EPSILON &&
|
|
102
|
+
Math.abs(a[1] - b[1]) < EPSILON &&
|
|
103
|
+
Math.abs(a[2] - b[2]) < EPSILON
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
toUnitVectorLongLat(out: LongLat, a: Vec3) {
|
|
109
|
+
const len = this.length(a); // TODO Might drop length check
|
|
110
|
+
if (len === 0) {
|
|
111
|
+
throw new Error('Cannot convert a zero vector to unit vector');
|
|
112
|
+
}
|
|
113
|
+
out[0] = Math.atan2(a[1], a[0]); // Longitude
|
|
114
|
+
out[1] = Math.asin(a[2] / len); // Latitude
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
fromUnitVectorLongLat(out: Vec3, longLat: LongLat) {
|
|
118
|
+
const longitude = longLat[0];
|
|
119
|
+
const latitude = longLat[1];
|
|
120
|
+
const cosLat = Math.cos(latitude);
|
|
121
|
+
out[0] = cosLat * Math.cos(longitude);
|
|
122
|
+
out[1] = cosLat * Math.sin(longitude);
|
|
123
|
+
out[2] = Math.sin(latitude);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
applyQuaternion(out: Vec3, a: Vec3, q: Quaternion) {
|
|
127
|
+
const x = a[0], y = a[1], z = a[2];
|
|
128
|
+
const qx = q[0], qy = q[1], qz = q[2], qw = q[3];
|
|
129
|
+
// Calculate the quaternion multiplication
|
|
130
|
+
const ix = qw * x + qy * z - qz * y;
|
|
131
|
+
const iy = qw * y + qz * x - qx * z;
|
|
132
|
+
const iz = qw * z + qx * y - qy * x;
|
|
133
|
+
const iw = -qx * x - qy * y - qz * z;
|
|
134
|
+
// Apply the quaternion to the vector
|
|
135
|
+
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
136
|
+
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
137
|
+
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
randomUnit(out: Vec3) {
|
|
142
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
143
|
+
const phi = Math.acos(2 * Math.random() - 1);
|
|
144
|
+
out[0] = Math.sin(phi) * Math.cos(theta);
|
|
145
|
+
out[1] = Math.sin(phi) * Math.sin(theta);
|
|
146
|
+
out[2] = Math.cos(phi);
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
str(a: Vec3): string {
|
|
151
|
+
return `Vec3(${a[0].toFixed(2)}, ${a[1].toFixed(2)}, ${a[2].toFixed(2)})`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
});
|
|
@@ -11,7 +11,7 @@ import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
|
11
11
|
import { PickerDisplayer } from '../util/picking/picker-displayer.js';
|
|
12
12
|
import { wgs84ToCartesian3d, wgs84ToMercator } from '../Math/methods.js';
|
|
13
13
|
import { constraintFloat, opacityCheck } from '../util/check/typecheck.js';
|
|
14
|
-
import { createBufferAndReadInfo } from '../util/gl-util/buffer/
|
|
14
|
+
import { createBufferAndReadInfo } from '../util/gl-util/buffer/attribute-loader';
|
|
15
15
|
import { CameraUniformBlockTotemCache } from '../programs/totems/camerauniformblock.js';
|
|
16
16
|
|
|
17
17
|
/**
|
package/bearing-line/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
|
8
8
|
import { ContextTextWriter3 } from '../write-text/context-text3'
|
|
9
9
|
import { constraintFloat, isBoolean } from '../util/check/typecheck';
|
|
10
10
|
import { sphereCoord } from '../util/geometry';
|
|
11
|
-
import { createBufferAndReadInfo } from '../util/gl-util/buffer/
|
|
11
|
+
import { createBufferAndReadInfo } from '../util/gl-util/buffer/attribute-loader';
|
|
12
12
|
|
|
13
13
|
export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
14
14
|
LINE_STRIP: "LINE_STRIP",
|
|
@@ -8,7 +8,7 @@ import { keyMethod } from "./util";
|
|
|
8
8
|
import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
9
9
|
import { ContextTextWriter3 } from '../write-text/context-text3';
|
|
10
10
|
import { isBoolean, constraintFloat, opacityCheck } from '../util/check/typecheck';
|
|
11
|
-
import { createBufferAndReadInfo } from '../util/gl-util/buffer/
|
|
11
|
+
import { createBufferAndReadInfo } from '../util/gl-util/buffer/attribute-loader';
|
|
12
12
|
import { sphereCoord } from '../util/geometry/index';
|
|
13
13
|
/**
|
|
14
14
|
* Insert info to chain list map (nodes and properties)
|
package/globe-types.ts
ADDED
|
@@ -38,7 +38,7 @@ export default class HeatWaveGlobeShellPlugin {
|
|
|
38
38
|
// output of heatProgram is written to ._coloredHeatTexture
|
|
39
39
|
this._frameBuffer = null
|
|
40
40
|
this._coloredHeatTexture = null;
|
|
41
|
-
|
|
41
|
+
this.enabled = false;
|
|
42
42
|
this.isAble = false;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -185,14 +185,10 @@ export default class HeatWaveGlobeShellPlugin {
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
_setAfterInit() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
{
|
|
193
|
-
this.setColorRamp(this._colorRampData.values, this._colorRampData.thresholds, this._colorRampData.mode);
|
|
194
|
-
delete this._colorRampData;
|
|
195
|
-
}
|
|
188
|
+
const [minLon, minLat, maxLon, maxLat] = this._bbox;
|
|
189
|
+
this.globeShell.setBBox({ minLon, minLat, maxLon, maxLat });
|
|
190
|
+
this.setColorRamp(this._colorRampData.values, this._colorRampData.thresholds, this._colorRampData.mode);
|
|
191
|
+
delete this._colorRampData;
|
|
196
192
|
this.setMinMaxEdges(this._minMaxEdges.min, this._minMaxEdges.max);
|
|
197
193
|
this.setEscapeValue(this._escapeValue);
|
|
198
194
|
}
|
package/index.js
CHANGED
|
@@ -9,4 +9,7 @@ import * as heatwave from "./heatwave";
|
|
|
9
9
|
import * as util from "./util";
|
|
10
10
|
import * as programs from "./programs";
|
|
11
11
|
import * as pointheatmap from "./point-heat-map";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
12
15
|
export { wind, waveparticles, timetracks, rangerings, compassrose, heatwave, util, programs, arrowfield, partialring, pointheatmap };
|
package/package.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
interface ProgramInterface {
|
|
3
|
+
draw(vao: WebGLVertexArrayObject, drawOptions: DrawRangeIndexParams, opacity: number, flexibleUBO: UBOHandler | null): void;
|
|
4
|
+
createUBO(bufferReadType?: "STATIC_DRAW" | "DYNAMIC_DRAW" | "STREAM_DRAW"): UBOHandler;
|
|
5
|
+
createVAO(...inputs: BufferAndReadInfo[]): WebGLVertexArrayObject;
|
|
6
|
+
free(): void;
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import { createProgram } from "../../util/webglobjectbuilders";
|
|
|
2
2
|
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
4
|
// import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
-
import { attributeLoader } from "../../util/gl-util/buffer/
|
|
5
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
6
|
import {
|
|
7
7
|
cartesian3DToGLPosition,
|
|
8
8
|
circleLimpFromLongLatRadCenterCartesian3D_accurate,
|
|
@@ -2,7 +2,7 @@ import { createProgram } from "../../util/webglobjectbuilders";
|
|
|
2
2
|
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
4
|
// import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
-
import { attributeLoader } from "../../util/gl-util/buffer/
|
|
5
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
6
|
import { Z_ALPHA_MODE } from "./util";
|
|
7
7
|
import {
|
|
8
8
|
cartesian3DToGLPosition,
|
|
@@ -3,7 +3,7 @@ import { mercatorXYToGLPosition, POLE } from "../../util/shaderfunctions/geometr
|
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
4
|
import { createProgram } from "../../util";
|
|
5
5
|
import { Z_ALPHA_MODE } from "./util";
|
|
6
|
-
import { attributeLoader } from "../../util/gl-util/buffer/
|
|
6
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This program draws line between points provided from the first and second buffer.
|