@pirireis/webglobeplugins 0.9.11 → 0.9.13
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/angle-calculation.js +9 -11
- package/Math/arc.js +38 -41
- package/Math/bounds/line-bbox.js +79 -83
- package/Math/constants.js +4 -9
- package/Math/frustum/types.js +1 -2
- package/Math/juction/arc-plane.js +33 -36
- package/Math/juction/line-sphere.js +15 -18
- package/Math/juction/plane-plane.js +20 -23
- package/Math/line.js +42 -47
- package/Math/methods.js +69 -92
- package/Math/plane.js +33 -38
- package/Math/quaternion.js +48 -55
- package/Math/types.js +1 -2
- package/Math/utils.js +2 -4
- package/Math/vec3.js +46 -52
- package/algorithms/search-binary.js +5 -8
- package/altitude-locator/draw-subset-obj.js +8 -11
- package/altitude-locator/plugin.js +114 -133
- package/altitude-locator/types.js +1 -3
- package/arrowfield/adaptor.js +3 -7
- package/arrowfield/index.js +3 -10
- package/arrowfield/plugin.js +63 -69
- package/bearing-line/index.js +2 -8
- package/bearing-line/plugin.js +218 -248
- package/circle-line-chain/chain-list-map.js +82 -92
- package/circle-line-chain/plugin.js +147 -182
- package/circle-line-chain/util.js +1 -5
- package/compass-rose/compass-rose-padding-flat.js +111 -140
- package/compass-rose/compass-text-writer.js +63 -75
- package/compass-rose/index.js +3 -7
- package/compassrose/compassrose.js +50 -57
- package/compassrose/index.js +2 -8
- package/heatwave/index.js +3 -10
- package/heatwave/isobar/objectarraylabels.js +50 -56
- package/heatwave/isobar/plugin.js +111 -170
- package/heatwave/isobar/quadtreecontours.js +78 -96
- package/heatwave/plugins/heatwaveglobeshell.js +73 -94
- package/index.js +12 -58
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -70
- package/partialrings/index.js +2 -41
- package/partialrings/plugin.js +55 -98
- package/partialrings/program.js +141 -59
- package/pin/pin-object-array.js +89 -97
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
- package/point-heat-map/plugin-webworker.js +45 -53
- package/point-heat-map/point-to-heat-map-flow.js +46 -51
- package/point-tracks/key-methods.js +2 -5
- package/point-tracks/plugin.js +141 -170
- package/programs/arrowfield/index.js +2 -7
- package/programs/arrowfield/logic.js +172 -67
- package/programs/arrowfield/object.js +35 -43
- package/programs/data2legend/density-to-legend.js +47 -26
- package/programs/data2legend/point-to-density-texture.js +56 -34
- package/programs/float2legendwithratio/index.js +2 -8
- package/programs/float2legendwithratio/logic.js +88 -45
- package/programs/float2legendwithratio/object.js +45 -54
- package/programs/globe-util/is-globe-moved.js +10 -13
- package/programs/globeshell/index.js +2 -8
- package/programs/globeshell/wiggle/index.js +2 -8
- package/programs/globeshell/wiggle/logic.js +191 -101
- package/programs/globeshell/wiggle/object.js +35 -43
- package/programs/helpers/blender/program.js +36 -22
- package/programs/helpers/fadeaway/index.js +2 -7
- package/programs/helpers/fadeaway/logic.js +36 -17
- package/programs/helpers/fadeaway/object.js +11 -18
- package/programs/helpers/index.js +2 -8
- package/programs/index.js +9 -58
- package/programs/line-on-globe/angled-line.js +95 -39
- package/programs/line-on-globe/circle-accurate-3d.js +86 -39
- package/programs/line-on-globe/circle-accurate-flat.js +116 -64
- package/programs/line-on-globe/circle-accurate.js +113 -46
- package/programs/line-on-globe/circle.js +106 -44
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
- package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
- package/programs/line-on-globe/linestrip.js +126 -63
- package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
- package/programs/line-on-globe/to-the-surface.js +62 -35
- package/programs/line-on-globe/util.js +2 -5
- package/programs/picking/pickable-renderer.js +127 -46
- package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
- package/programs/point-on-globe/element-point-glow.js +112 -47
- package/programs/point-on-globe/square-pixel-point.js +80 -34
- package/programs/programcache.js +14 -19
- package/programs/rings/distancering/circleflatprogram.js +76 -70
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
- package/programs/rings/distancering/index.js +5 -14
- package/programs/rings/distancering/paddyflatprogram.js +87 -70
- package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
- package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
- package/programs/rings/index.js +1 -17
- package/programs/rings/partial-ring/piece-of-pie.js +144 -44
- package/programs/totems/camerauniformblock.js +65 -56
- package/programs/totems/canvas-webglobe-info.js +49 -45
- package/programs/totems/gpu-selection-uniform-block.js +45 -45
- package/programs/totems/index.js +2 -40
- package/programs/two-d/pixel-padding-for-compass.js +94 -36
- package/programs/util.js +7 -10
- package/programs/vectorfields/index.js +3 -23
- package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
- package/programs/vectorfields/logics/index.js +4 -12
- package/programs/vectorfields/logics/pixelbased.js +94 -41
- package/programs/vectorfields/logics/ubo.js +32 -32
- package/programs/vectorfields/pingpongbuffermanager.js +30 -37
- package/rangerings/enum.js +2 -5
- package/rangerings/index.js +5 -15
- package/rangerings/plugin.js +223 -286
- package/rangerings/rangeringangletext.js +122 -137
- package/rangerings/ring-account.js +53 -75
- package/shaders/fragment-toy/firework.js +55 -4
- package/shaders/fragment-toy/singularity.js +56 -5
- package/timetracks/adaptors-line-strip.js +27 -44
- package/timetracks/adaptors.js +48 -67
- package/timetracks/index.js +5 -19
- package/timetracks/plugin-line-strip.js +65 -79
- package/timetracks/plugin.js +71 -85
- package/timetracks/program-line-strip.js +297 -107
- package/timetracks/program.js +421 -118
- package/timetracks/programpoint-line-strip.js +98 -48
- package/timetracks/programpoint.js +91 -48
- package/util/account/bufferoffsetmanager.js +72 -98
- package/util/account/index.js +3 -23
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
- package/util/account/single-attribute-buffer-management/index.js +4 -9
- package/util/account/single-attribute-buffer-management/object-store.js +29 -34
- package/util/account/single-attribute-buffer-management/types.js +1 -2
- package/util/account/util.js +2 -8
- package/util/algorithms/search-binary.js +5 -8
- package/util/check/get.js +5 -9
- package/util/check/typecheck.js +13 -24
- package/util/geometry/index.js +10 -18
- package/util/gl-util/buffer/attribute-loader.js +10 -26
- package/util/gl-util/buffer/index.js +2 -5
- package/util/gl-util/draw-options/methods.js +10 -15
- package/util/gl-util/uniform-block/manager.js +69 -72
- package/util/heatwavedatamanager/datamanager.js +56 -119
- package/util/heatwavedatamanager/index.js +3 -10
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
- package/util/index.js +13 -57
- package/util/interpolation/timetrack/index.js +2 -5
- package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
- package/util/interpolation/timetrack/web-worker-str.js +180 -5
- package/util/interpolation/timetrack/web-worker.js +4 -6
- package/util/jshelpers/data-filler.js +8 -11
- package/util/jshelpers/equality.js +1 -3
- package/util/jshelpers/index.js +2 -37
- package/util/jshelpers/timefilters.js +8 -10
- package/util/picking/fence.js +8 -11
- package/util/picking/picker-displayer.js +49 -58
- package/util/programs/draw-texture-on-canvas.js +41 -26
- package/util/programs/index.js +1 -17
- package/util/programs/shapesonglobe.js +104 -68
- package/util/programs/supersampletotextures.js +45 -43
- package/util/programs/texturetoglobe.js +99 -52
- package/util/shaderfunctions/geometrytransformations.js +323 -35
- package/util/shaderfunctions/index.js +2 -18
- package/util/shaderfunctions/nodata.js +8 -5
- package/util/shaderfunctions/noisefunctions.js +40 -12
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/gldefaultstates.js +1 -4
- package/util/webglobe/index.js +2 -18
- package/util/webglobe/rasteroverlay.js +36 -41
- package/util/webglobjectbuilders.js +70 -93
- package/util/webglobjectbuilders1.js +63 -82
- package/waveparticles/adaptor.js +7 -10
- package/waveparticles/index.js +3 -10
- package/waveparticles/plugin.js +82 -90
- package/wind/imagetovectorfieldandmagnitude.js +16 -19
- package/wind/index.js +5 -14
- package/wind/plugin.js +454 -291
- package/wind/vectorfieldimage.js +6 -8
- package/write-text/attached-text-writer.js +48 -54
- package/write-text/context-text.js +52 -63
- package/write-text/context-text3.js +71 -80
- package/write-text/index.js +1 -5
|
@@ -1,5 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const webworkerStr = `
|
|
2
|
+
|
|
3
|
+
const WORLD_RADIUS_3D = 6378.137;
|
|
4
|
+
const WORLD_RADIUS_MERCATOR = 6378136.99911;
|
|
5
|
+
|
|
6
|
+
const dot3 = (a, b) => {
|
|
7
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const sphericalLinearInterpolation_UnitVector = (normalizedA, normalizedB, ratio) => {
|
|
11
|
+
const theta = Math.acos(dot3(normalizedA, normalizedB));
|
|
12
|
+
if (theta < 0.000001) return normalizedA; // CALIBRATE?
|
|
13
|
+
const sinTheta = Math.sin(theta);
|
|
14
|
+
const result = [
|
|
15
|
+
(Math.sin((1.0 - ratio) * theta) * normalizedA[0] + Math.sin(ratio * theta) * normalizedB[0]) / sinTheta,
|
|
16
|
+
(Math.sin((1.0 - ratio) * theta) * normalizedA[1] + Math.sin(ratio * theta) * normalizedB[1]) / sinTheta,
|
|
17
|
+
(Math.sin((1.0 - ratio) * theta) * normalizedA[2] + Math.sin(ratio * theta) * normalizedB[2]) / sinTheta
|
|
18
|
+
];
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const radianToMercator = (xy) => {
|
|
23
|
+
return [WORLD_RADIUS_MERCATOR * xy[0], WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + xy[1] / 2))];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const cartesian3dToRadian = (cartesian) => {
|
|
28
|
+
const x = cartesian[0];
|
|
29
|
+
const y = cartesian[1];
|
|
30
|
+
const z = cartesian[2];
|
|
31
|
+
// const length = Math.sqrt(x * x + y * y + z * z);
|
|
32
|
+
const long = Math.atan2(y, x);
|
|
33
|
+
const lat = Math.asin(z)// length);
|
|
34
|
+
return [long, lat];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const sphericalLinearInterpolation_Mercator = (normalizedA, normalizedB, ratio) => {
|
|
39
|
+
const unitVector = sphericalLinearInterpolation_UnitVector(normalizedA, normalizedB, ratio);
|
|
40
|
+
const angles = cartesian3dToRadian(unitVector);
|
|
41
|
+
return radianToMercator(angles);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const sphericalLinearInterpolation_Cartesian3d = (a, b, ratio) => {
|
|
45
|
+
const unitVector = sphericalLinearInterpolation_UnitVector(a, b, ratio);
|
|
46
|
+
const height = a[3] + (b[3] - a[3]) * ratio;
|
|
47
|
+
return [unitVector[0] * height, unitVector[1] * height, unitVector[2] * height];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const findFirstIndexInRange = (container, value) => {
|
|
51
|
+
let start = 0;
|
|
52
|
+
let end = container.length - 1;
|
|
53
|
+
let mid = 0;
|
|
54
|
+
while (start <= end) {
|
|
55
|
+
mid = Math.floor((start + end) / 2);
|
|
56
|
+
if (container[mid] <= value && value <= container[mid + 1]) return mid;
|
|
57
|
+
if (container[mid] < value) start = mid + 1;
|
|
58
|
+
else end = mid - 1;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const GEOMETRY = Object.freeze({
|
|
64
|
+
CARTESIAN3D: 0,
|
|
65
|
+
MERCATOR: 1,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
class TimeTrackInterpolator {
|
|
69
|
+
/**
|
|
70
|
+
* @typedef Timetrack
|
|
71
|
+
* @property {Array<vec4>}} coordinates [x,y,z, length]
|
|
72
|
+
* @property {Array<Number>} times
|
|
73
|
+
* @param {Array<Timetrack>} timeTracks
|
|
74
|
+
*/
|
|
75
|
+
constructor({ timeTracks, bbox = null, geometry = GEOMETRY.CARTESIAN3D } = {}) {
|
|
76
|
+
this.timeTracks = null;
|
|
77
|
+
this.timeTracksStartTimes = null;
|
|
78
|
+
this.geometry = geometry;
|
|
79
|
+
if (timeTracks) this.setTimetracks(timeTracks);
|
|
80
|
+
if (bbox) this.setBbox(bbox);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
setGeometry(geometry) {
|
|
85
|
+
if (geometry !== GEOMETRY.CARTESIAN3D && geometry !== GEOMETRY.MERCATOR) {
|
|
86
|
+
throw new Error('Invalid geometry');
|
|
87
|
+
}
|
|
88
|
+
this.geometry = geometry;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setTimetracks(timeTracks) {
|
|
92
|
+
this.timeTracks = timeTracks;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
interpolate(time) {
|
|
97
|
+
const { timeTracks, geometry } = this;
|
|
98
|
+
if (!timeTracks) { return null; }
|
|
99
|
+
const resultArray = [];
|
|
100
|
+
const info = {
|
|
101
|
+
outOfRange: 0,
|
|
102
|
+
processed: 0,
|
|
103
|
+
}
|
|
104
|
+
for (let i = 0; i < timeTracks.length; i++) {
|
|
105
|
+
const { times, coordinates } = timeTracks[i];
|
|
106
|
+
|
|
107
|
+
if (times[times.length - 1] < time) continue;
|
|
108
|
+
info.processed++;
|
|
109
|
+
const timeIndex = findFirstIndexInRange(times, time);
|
|
110
|
+
if (timeIndex === null) { info.outOfRange++; continue; }
|
|
111
|
+
const timeFraction = (time - times[timeIndex]) / (times[timeIndex + 1] - times[timeIndex]);
|
|
112
|
+
const interpolated = (geometry === GEOMETRY.CARTESIAN3D) ?
|
|
113
|
+
sphericalLinearInterpolation_Cartesian3d(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction) :
|
|
114
|
+
sphericalLinearInterpolation_Mercator(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction);
|
|
115
|
+
resultArray.push(...interpolated);
|
|
116
|
+
}
|
|
117
|
+
return new Float32Array(resultArray);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// implicit methods
|
|
122
|
+
|
|
123
|
+
_orderTimeTracks() {
|
|
124
|
+
this.timeTracks.sort((a, b) => a.times[0] - b.times[0]);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_setStartTimes() {
|
|
128
|
+
this.timeTracksStartTimes = this.timeTracks.map(tt => tt.times[0]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const interpolator = new TimeTrackInterpolator({ geometry: GEOMETRY.CARTESIAN3D });
|
|
133
|
+
|
|
134
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
135
|
+
self.onmessage = function (e) {
|
|
136
|
+
|
|
137
|
+
const { geometry = null, timeTracks = null, time = null } = e.data;
|
|
138
|
+
|
|
139
|
+
if (geometry !== null) {
|
|
140
|
+
try {
|
|
141
|
+
interpolator.setGeometry(geometry);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
144
|
+
self.postMessage({ error: error.message });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (timeTracks !== null) {
|
|
150
|
+
try {
|
|
151
|
+
interpolator.setTimetracks(timeTracks);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
154
|
+
self.postMessage({ error: error.message });
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (time !== null) {
|
|
160
|
+
try {
|
|
161
|
+
const result = interpolator.interpolate(time);
|
|
162
|
+
if(result === null) {
|
|
163
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
164
|
+
self.postMessage({ error: 'No TimeTracks Data' });
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
168
|
+
self.postMessage(result, [result.buffer]);
|
|
169
|
+
return;
|
|
170
|
+
} catch (error) {
|
|
171
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
172
|
+
self.postMessage({ error: error.message });
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
177
|
+
self.postMessage(true);
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
export { webworkerStr };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var timetrack_interpolator_1 = require("./timetrack-interpolator");
|
|
4
|
-
var interpolator = new timetrack_interpolator_1.TimeTrackInterpolator({ geometry: timetrack_interpolator_1.GEOMETRY.CARTESIAN3D });
|
|
1
|
+
import { TimeTrackInterpolator, GEOMETRY } from './timetrack-interpolator';
|
|
2
|
+
const interpolator = new TimeTrackInterpolator({ geometry: GEOMETRY.CARTESIAN3D });
|
|
5
3
|
/* eslint-disable-next-line no-restricted-globals */
|
|
6
4
|
self.onmessage = function (e) {
|
|
7
|
-
|
|
5
|
+
const { geometry = null, timeTracks = null, time = null } = e.data;
|
|
8
6
|
if (geometry !== null) {
|
|
9
7
|
try {
|
|
10
8
|
interpolator.setGeometry(geometry);
|
|
@@ -27,7 +25,7 @@ self.onmessage = function (e) {
|
|
|
27
25
|
}
|
|
28
26
|
if (time !== null) {
|
|
29
27
|
try {
|
|
30
|
-
|
|
28
|
+
const result = interpolator.interpolate(time);
|
|
31
29
|
if (result === null) {
|
|
32
30
|
/* eslint-disable-next-line no-restricted-globals */
|
|
33
31
|
self.postMessage({ error: 'No TimeTracks Data' });
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var populateFloat32Array = Object.freeze({
|
|
5
|
-
fillFloat32Array: function (length, data) {
|
|
6
|
-
var result = new Float32Array(length);
|
|
1
|
+
const populateFloat32Array = Object.freeze({
|
|
2
|
+
fillFloat32Array: (length, data) => {
|
|
3
|
+
const result = new Float32Array(length);
|
|
7
4
|
result.fill(data);
|
|
8
5
|
return result;
|
|
9
6
|
},
|
|
10
|
-
fillWithListData:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (
|
|
7
|
+
fillWithListData: (length, listdata) => {
|
|
8
|
+
const result = new Float32Array(length * listdata.length);
|
|
9
|
+
let offset = 0;
|
|
10
|
+
for (let i = 0; i < length; i++) {
|
|
14
11
|
result.set(listdata, offset);
|
|
15
12
|
offset += listdata.length;
|
|
16
13
|
}
|
|
17
14
|
return result;
|
|
18
15
|
}
|
|
19
16
|
});
|
|
20
|
-
|
|
17
|
+
export { populateFloat32Array };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arraysEqual = arraysEqual;
|
|
4
1
|
function arraysEqual(a, b) {
|
|
5
2
|
if (a === b)
|
|
6
3
|
return true;
|
|
@@ -18,3 +15,4 @@ function arraysEqual(a, b) {
|
|
|
18
15
|
}
|
|
19
16
|
return true;
|
|
20
17
|
}
|
|
18
|
+
export { arraysEqual };
|
package/util/jshelpers/index.js
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.timefilters = void 0;
|
|
37
|
-
exports.timefilters = __importStar(require("./timefilters"));
|
|
1
|
+
import * as timefilters_1 from './timefilters';
|
|
2
|
+
export { timefilters_1 as timefilters };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.instantDebounce = instantDebounce;
|
|
4
1
|
// TODO: fix logic error in instantDebounce
|
|
5
2
|
function instantDebounce(func, delay) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
setTimeout(
|
|
3
|
+
let timeout = null;
|
|
4
|
+
let lastArgs = null;
|
|
5
|
+
let runAtEnd = false;
|
|
6
|
+
const timeoutMethod = () => {
|
|
7
|
+
setTimeout(() => {
|
|
11
8
|
if (runAtEnd) {
|
|
12
|
-
func
|
|
9
|
+
func(...lastArgs);
|
|
13
10
|
lastArgs = null;
|
|
14
11
|
// console.log("processed with delay")
|
|
15
12
|
runAtEnd = false;
|
|
@@ -24,9 +21,10 @@ function instantDebounce(func, delay) {
|
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
23
|
else {
|
|
27
|
-
func
|
|
24
|
+
func(...args);
|
|
28
25
|
// console.log("processed instantly")
|
|
29
26
|
timeout = timeoutMethod();
|
|
30
27
|
}
|
|
31
28
|
};
|
|
32
29
|
}
|
|
30
|
+
export { instantDebounce };
|
package/util/picking/fence.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fence = void 0;
|
|
4
|
-
var fence = function (gl) { return new Promise(function (resolve, reject) {
|
|
1
|
+
const fence = (gl) => new Promise((resolve, reject) => {
|
|
5
2
|
// This will create a fence. If this follows a `readPixels()` call, then it
|
|
6
3
|
// will signal to WebGL that the read instruction should be asynchronous.
|
|
7
4
|
// This means JS can continue to work on other tasks while the read instruction
|
|
8
5
|
// completes.
|
|
9
|
-
|
|
6
|
+
const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
10
7
|
gl.flush();
|
|
11
8
|
// There are TWO possible ways to check on the status of a WebGLSync object.
|
|
12
9
|
// 1. This will check it using clientWaitSync()
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const checkStatus_v1 = () => {
|
|
11
|
+
const status = gl.clientWaitSync(sync, 0, 0);
|
|
15
12
|
// There are four possible values for status:
|
|
16
13
|
// a. ALREADY_SIGNALED and CONDITION_SATISFIED (done)
|
|
17
14
|
// b. TIMEOUT_EXPIRED (check again later)
|
|
@@ -29,8 +26,8 @@ var fence = function (gl) { return new Promise(function (resolve, reject) {
|
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
28
|
// 2. This will check with getSyncParameter(s, gl.SYNC_STATUS)
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const checkStatus_v2 = () => {
|
|
30
|
+
const status = gl.getSyncParameter(sync, gl.SYNC_STATUS);
|
|
34
31
|
// There are only two possible values for status: SIGNALED and UNSIGNALED
|
|
35
32
|
// Note that there is no `error` signal, so there is no reason to use `reject()` here
|
|
36
33
|
if (status === gl.SIGNALED) {
|
|
@@ -42,5 +39,5 @@ var fence = function (gl) { return new Promise(function (resolve, reject) {
|
|
|
42
39
|
}
|
|
43
40
|
};
|
|
44
41
|
setTimeout(checkStatus_v2, 1);
|
|
45
|
-
});
|
|
46
|
-
|
|
42
|
+
});
|
|
43
|
+
export { fence };
|
|
@@ -1,59 +1,54 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* add implicit texture display program for color
|
|
4
3
|
* add fence on query return and return id.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var PickerDisplayer = /** @class */ (function () {
|
|
12
|
-
function PickerDisplayer(globe) {
|
|
5
|
+
import { textureOnCanvasProgramCache } from "../programs/draw-texture-on-canvas";
|
|
6
|
+
import { fence } from "./fence";
|
|
7
|
+
const ESCAPE_VALUE = -1;
|
|
8
|
+
class PickerDisplayer {
|
|
9
|
+
constructor(globe) {
|
|
13
10
|
this.globe = globe;
|
|
14
11
|
this.gl = globe.gl;
|
|
15
|
-
|
|
12
|
+
const gl = this.gl;
|
|
16
13
|
this.colorTexture = gl.createTexture(); // bind to color attachment 0
|
|
17
14
|
this.indexTexture = gl.createTexture(); // bind to color attachment 1
|
|
18
15
|
this.fbo = gl.createFramebuffer();
|
|
19
16
|
this._pbo = undefined;
|
|
20
17
|
this._pboSize = 0;
|
|
21
18
|
this.resize();
|
|
22
|
-
this.displayer =
|
|
19
|
+
this.displayer = textureOnCanvasProgramCache.get(this.gl);
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
if (width === void 0) { width = null; }
|
|
26
|
-
if (height === void 0) { height = null; }
|
|
21
|
+
resize(width = null, height = null) {
|
|
27
22
|
if (width === null || height === null) {
|
|
28
23
|
width = this.globe.api_ScrW();
|
|
29
24
|
height = this.globe.api_ScrH();
|
|
30
25
|
}
|
|
31
|
-
|
|
26
|
+
const { gl, colorTexture, indexTexture } = this;
|
|
32
27
|
gl.deleteTexture(colorTexture);
|
|
33
28
|
gl.deleteTexture(indexTexture);
|
|
34
|
-
|
|
29
|
+
const colorTextureNew = gl.createTexture();
|
|
35
30
|
gl.bindTexture(gl.TEXTURE_2D, colorTextureNew);
|
|
36
31
|
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, width, height);
|
|
37
|
-
|
|
32
|
+
const indexTextureNew = gl.createTexture();
|
|
38
33
|
gl.bindTexture(gl.TEXTURE_2D, indexTextureNew);
|
|
39
34
|
// gl.texStorage2D(gl.TEXTURE_2D, 1, gl.R16I, width, height);
|
|
40
35
|
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.R32I, width, height);
|
|
41
36
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
42
37
|
this.colorTexture = colorTextureNew;
|
|
43
38
|
this.indexTexture = indexTextureNew;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
}
|
|
40
|
+
clearTextures() {
|
|
41
|
+
const { gl, colorTexture, indexTexture } = this;
|
|
47
42
|
gl.activeTexture(gl.TEXTURE1);
|
|
48
43
|
gl.bindTexture(gl.TEXTURE_2D, indexTexture);
|
|
49
44
|
gl.clearBufferiv(gl.COLOR, 1, new Int32Array([-1, -1, -1, -1]));
|
|
50
45
|
gl.activeTexture(gl.TEXTURE0);
|
|
51
46
|
gl.bindTexture(gl.TEXTURE_2D, colorTexture);
|
|
52
47
|
gl.clearBufferfv(gl.COLOR, 0, new Float32Array([0, 0, 0, 0]));
|
|
53
|
-
}
|
|
48
|
+
}
|
|
54
49
|
// call before drawing the scene with gl picker shader
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
bindFBO() {
|
|
51
|
+
const { gl, colorTexture, indexTexture, fbo } = this;
|
|
57
52
|
gl.activeTexture(gl.TEXTURE1);
|
|
58
53
|
gl.bindTexture(gl.TEXTURE_2D, indexTexture);
|
|
59
54
|
gl.activeTexture(gl.TEXTURE0);
|
|
@@ -64,30 +59,27 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
64
59
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT1, gl.TEXTURE_2D, this.indexTexture, 0);
|
|
65
60
|
gl.drawBuffers([gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]);
|
|
66
61
|
}
|
|
67
|
-
}
|
|
62
|
+
}
|
|
68
63
|
// call after drawing the scene with gl picker shader
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
drawColorTexture() {
|
|
65
|
+
const { colorTexture } = this;
|
|
71
66
|
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
|
|
72
67
|
this.displayer.draw(colorTexture);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (callback === void 0) { callback = function () { }; }
|
|
77
|
-
var size = Math.pow(1 + 2 * selectionPointFilling, 2);
|
|
68
|
+
}
|
|
69
|
+
pickXY(x, y, selectionPointFilling = 1, callback = () => { }) {
|
|
70
|
+
const size = Math.pow(1 + 2 * selectionPointFilling, 2);
|
|
78
71
|
this._pick(size, x - selectionPointFilling, y - selectionPointFilling, 1 + 2 * selectionPointFilling, 1 + 2 * selectionPointFilling, callback);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
}
|
|
73
|
+
pickBbox(left, top, right, bottom, callback) {
|
|
74
|
+
const size = (right - left) * (bottom - top) * 4;
|
|
82
75
|
this._pick(size, left, top, right - left, bottom - top, callback);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var _this = this;
|
|
76
|
+
}
|
|
77
|
+
_pick(size, startX, startY, lengthX, lengthY, callback) {
|
|
86
78
|
if (this._inProgress)
|
|
87
79
|
return false;
|
|
88
80
|
this._inProgress = true;
|
|
89
81
|
this._initHoldBuffer(size * 4);
|
|
90
|
-
|
|
82
|
+
const { gl, _pbo } = this;
|
|
91
83
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, _pbo);
|
|
92
84
|
this.bindFBO();
|
|
93
85
|
gl.readBuffer(gl.COLOR_ATTACHMENT1); // This is the attachment we want to read
|
|
@@ -95,35 +87,35 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
95
87
|
startX, startY, lengthX, lengthY, gl.RED_INTEGER, gl.INT, 0);
|
|
96
88
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
97
89
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
98
|
-
|
|
90
|
+
fence(this.gl).then(() => {
|
|
99
91
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, _pbo);
|
|
100
92
|
// const data = new Int16Array(size);
|
|
101
|
-
|
|
93
|
+
const data = new Int32Array(size);
|
|
102
94
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
|
103
95
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
104
|
-
|
|
96
|
+
const result = this._pickFromBuffer(data, size);
|
|
105
97
|
callback(result);
|
|
106
98
|
// gl.deleteBuffer(pbo);
|
|
107
|
-
|
|
99
|
+
this._inProgress = false;
|
|
108
100
|
});
|
|
109
101
|
return true;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
for (
|
|
114
|
-
|
|
102
|
+
}
|
|
103
|
+
_pickFromBuffer(array, size) {
|
|
104
|
+
const selectedObjects = new Set();
|
|
105
|
+
for (let i = 0; i < size; i += 1) {
|
|
106
|
+
const id = array[i];
|
|
115
107
|
if (id !== ESCAPE_VALUE) {
|
|
116
108
|
selectedObjects.add(id);
|
|
117
109
|
}
|
|
118
110
|
}
|
|
119
111
|
return selectedObjects;
|
|
120
|
-
}
|
|
121
|
-
|
|
112
|
+
}
|
|
113
|
+
_initHoldBuffer(size) {
|
|
122
114
|
if (this._pbo && this._pboSize >= size) {
|
|
123
115
|
return;
|
|
124
116
|
}
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
const { gl } = this;
|
|
118
|
+
const pbo = gl.createBuffer();
|
|
127
119
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pbo);
|
|
128
120
|
gl.bufferData(gl.PIXEL_PACK_BUFFER, size, gl.STREAM_READ);
|
|
129
121
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
@@ -132,14 +124,13 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
132
124
|
gl.deleteBuffer(this._pbo);
|
|
133
125
|
}
|
|
134
126
|
this._pbo = pbo;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
}
|
|
128
|
+
free() {
|
|
129
|
+
const { gl, colorTexture, indexTexture, fbo } = this;
|
|
138
130
|
gl.deleteTexture(colorTexture);
|
|
139
131
|
gl.deleteTexture(indexTexture);
|
|
140
132
|
gl.deleteFramebuffer(fbo);
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
exports.PickerDisplayer = PickerDisplayer;
|
|
133
|
+
textureOnCanvasProgramCache.release(this.gl);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export { PickerDisplayer };
|