@pirireis/webglobeplugins 0.10.10-alpha → 0.10.11-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/package.json +1 -1
- package/point-heat-map/plugin-webworker.js +0 -3
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +13 -19
- package/timetracks/index.js +0 -2
- package/util/heatwavedatamanager/index.js +1 -2
- package/programs/globeshell/noise/noises.js +0 -1
- package/programs/line-on-globe/angled-line.js +0 -173
- package/timetracks/adaptors.js +0 -117
- package/timetracks/plugin.js +0 -248
- package/timetracks/program.js +0 -769
- package/timetracks/programpoint.js +0 -144
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator1.js +0 -116
- package/util/interpolation/timetrack/web-worker-str.js +0 -180
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { createProgram, shaderfunctions } from "../util";
|
|
2
|
-
import { CameraUniformBlockTotem, globeProgramCache } from "../programs";
|
|
3
|
-
const vertexShader = `#version 300 es
|
|
4
|
-
|
|
5
|
-
layout(std140) uniform GlobeCamera {
|
|
6
|
-
mat4 view; // 64 bytes 0
|
|
7
|
-
mat4 projection; // 64 bytes 64
|
|
8
|
-
vec3 translate; // 12 bytes 128
|
|
9
|
-
bool is3D; // 4 bytes 140
|
|
10
|
-
vec2 mapWH; // 8 bytes 144
|
|
11
|
-
vec2 screenWH; // 8 bytes 152
|
|
12
|
-
float z_level; // 4 bytes 160
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
layout(std140) uniform Globals {
|
|
16
|
-
float head_time;
|
|
17
|
-
float final_opacity;
|
|
18
|
-
float point_size;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
in vec3 start_position;
|
|
22
|
-
in float start_time;
|
|
23
|
-
in vec3 start_color;
|
|
24
|
-
in vec3 end_position;
|
|
25
|
-
in float end_time;
|
|
26
|
-
in vec3 end_color;
|
|
27
|
-
out vec4 v_color;
|
|
28
|
-
|
|
29
|
-
` + shaderfunctions.pixelXYToCartesian3DPoint + shaderfunctions.pixelXYToCartesian2DPoint + `
|
|
30
|
-
|
|
31
|
-
void main() {
|
|
32
|
-
if (head_time < start_time || head_time > end_time) { return; }
|
|
33
|
-
float t = (head_time - start_time) / (end_time - start_time);
|
|
34
|
-
vec3 position = mix(start_position, end_position, t);
|
|
35
|
-
if (is3D){
|
|
36
|
-
vec3 pos = pixelXYToCartesian3DPoint(position);
|
|
37
|
-
gl_Position = projection * view * vec4(pos - translate, 1.0);
|
|
38
|
-
} else {
|
|
39
|
-
vec2 xy = pixelXYToCartesian2DPoint(position.xy, translate.xy, mapWH, screenWH);
|
|
40
|
-
gl_Position = projection * vec4(xy.x, xy.y, 0.0, 1.0);
|
|
41
|
-
}
|
|
42
|
-
v_color = vec4(mix(start_color, end_color, t), final_opacity);
|
|
43
|
-
gl_PointSize = point_size;
|
|
44
|
-
}`;
|
|
45
|
-
const fragmentShader = `#version 300 es
|
|
46
|
-
precision highp float;
|
|
47
|
-
in vec4 v_color;
|
|
48
|
-
out vec4 outColor;
|
|
49
|
-
void main() {
|
|
50
|
-
outColor = v_color;
|
|
51
|
-
}`;
|
|
52
|
-
export default class {
|
|
53
|
-
constructor(gl, globe, attrBuffer, options) {
|
|
54
|
-
this.gl = gl;
|
|
55
|
-
this._cameraBlockBindingPoint = 0;
|
|
56
|
-
this._globalsBlockBindingPoint = 1;
|
|
57
|
-
this.cameraUniformBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
58
|
-
this._vao = gl.createVertexArray();
|
|
59
|
-
this._attbuffer = attrBuffer;
|
|
60
|
-
this.program = this._createProgram();
|
|
61
|
-
this._drawCount = 0;
|
|
62
|
-
this._globalsbuffer = gl.createBuffer();
|
|
63
|
-
{
|
|
64
|
-
const { gl, _globalsbuffer } = this;
|
|
65
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, _globalsbuffer);
|
|
66
|
-
gl.bufferData(gl.UNIFORM_BUFFER, 12, gl.STREAM_DRAW);
|
|
67
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array([0, options.opacity, options.pointSize]));
|
|
68
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this._globalsBlockBindingPoint, _globalsbuffer);
|
|
69
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
_createProgram() {
|
|
73
|
-
const gl = this.gl;
|
|
74
|
-
const program = createProgram(gl, vertexShader, fragmentShader);
|
|
75
|
-
const ubo = this.cameraUniformBlockTotem.getUBO(); // ubo bl
|
|
76
|
-
const cameraBlockIndex = gl.getUniformBlockIndex(program, "GlobeCamera");
|
|
77
|
-
gl.uniformBlockBinding(program, cameraBlockIndex, this._cameraBlockBindingPoint);
|
|
78
|
-
const globalsBlockIndex = gl.getUniformBlockIndex(program, "Globals");
|
|
79
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this._cameraBlockBindingPoint, ubo);
|
|
80
|
-
gl.uniformBlockBinding(program, globalsBlockIndex, this._globalsBlockBindingPoint);
|
|
81
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this._globalsBlockBindingPoint, this._globalsbuffer);
|
|
82
|
-
// numaralarda yanlışlık olabilir
|
|
83
|
-
const start_position = gl.getAttribLocation(program, "start_position");
|
|
84
|
-
const start_time = gl.getAttribLocation(program, "start_time");
|
|
85
|
-
const start_color = gl.getAttribLocation(program, "start_color");
|
|
86
|
-
const end_position = gl.getAttribLocation(program, "end_position");
|
|
87
|
-
const end_time = gl.getAttribLocation(program, "end_time");
|
|
88
|
-
const end_color = gl.getAttribLocation(program, "end_color");
|
|
89
|
-
gl.bindVertexArray(this._vao);
|
|
90
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._attbuffer);
|
|
91
|
-
gl.enableVertexAttribArray(start_position);
|
|
92
|
-
gl.vertexAttribPointer(start_position, 3, gl.FLOAT, false, 72, 0);
|
|
93
|
-
gl.enableVertexAttribArray(start_time);
|
|
94
|
-
gl.vertexAttribPointer(start_time, 1, gl.FLOAT, false, 72, 12);
|
|
95
|
-
gl.enableVertexAttribArray(start_color);
|
|
96
|
-
gl.vertexAttribPointer(start_color, 3, gl.FLOAT, false, 72, 16);
|
|
97
|
-
gl.enableVertexAttribArray(end_position);
|
|
98
|
-
gl.vertexAttribPointer(end_position, 3, gl.FLOAT, false, 72, 36);
|
|
99
|
-
gl.enableVertexAttribArray(end_time);
|
|
100
|
-
gl.vertexAttribPointer(end_time, 1, gl.FLOAT, false, 72, 48);
|
|
101
|
-
gl.enableVertexAttribArray(end_color);
|
|
102
|
-
gl.vertexAttribPointer(end_color, 3, gl.FLOAT, false, 72, 52);
|
|
103
|
-
gl.bindVertexArray(null);
|
|
104
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
105
|
-
return program;
|
|
106
|
-
}
|
|
107
|
-
setOpacity(opacity) {
|
|
108
|
-
const { gl, _globalsbuffer } = this;
|
|
109
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, _globalsbuffer);
|
|
110
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 4, new Float32Array([opacity]));
|
|
111
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
112
|
-
}
|
|
113
|
-
setDrawCount(count) {
|
|
114
|
-
this._drawCount = count;
|
|
115
|
-
}
|
|
116
|
-
setPointSize(size) {
|
|
117
|
-
const { gl, _globalsbuffer } = this;
|
|
118
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, _globalsbuffer);
|
|
119
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 8, new Float32Array([size]));
|
|
120
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
121
|
-
}
|
|
122
|
-
setHeadTime(time) {
|
|
123
|
-
const { gl, _globalsbuffer } = this;
|
|
124
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, _globalsbuffer);
|
|
125
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array([time]));
|
|
126
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
127
|
-
}
|
|
128
|
-
draw() {
|
|
129
|
-
const { gl, program, _vao, _drawCount } = this;
|
|
130
|
-
gl.useProgram(program);
|
|
131
|
-
gl.bindVertexArray(_vao);
|
|
132
|
-
gl.disable(gl.DEPTH_TEST);
|
|
133
|
-
gl.drawArrays(gl.POINTS, 0, _drawCount);
|
|
134
|
-
gl.enable(gl.DEPTH_TEST);
|
|
135
|
-
gl.bindVertexArray(null);
|
|
136
|
-
}
|
|
137
|
-
free() {
|
|
138
|
-
const { gl, _vao, _globalsbuffer, program } = this;
|
|
139
|
-
gl.deleteVertexArray(_vao);
|
|
140
|
-
// gl.deleteBuffer(_attbuffer);
|
|
141
|
-
gl.deleteBuffer(_globalsbuffer);
|
|
142
|
-
gl.deleteProgram(program);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import PointCoordsMeta from "./pointcoordsmeta";
|
|
2
|
-
const pointObject = (long, lat, posIndex, callback) => {
|
|
3
|
-
return { long, lat, posIndex, callback };
|
|
4
|
-
};
|
|
5
|
-
export default class PointCoordinatesDataCalculator {
|
|
6
|
-
constructor(bbox, width, height) {
|
|
7
|
-
this._pointObjects = {};
|
|
8
|
-
this._ratio = 0.0;
|
|
9
|
-
this._bbox = bbox;
|
|
10
|
-
this._width = width;
|
|
11
|
-
this._height = height;
|
|
12
|
-
this._metaCalculater = new PointCoordsMeta(bbox, width, height);
|
|
13
|
-
this._texture0 = null;
|
|
14
|
-
this._texture1 = null;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {*} key
|
|
19
|
-
* @param {*} lat
|
|
20
|
-
* @param {*} long
|
|
21
|
-
* @param {*} callback | callback(data0, data1, interpolated)
|
|
22
|
-
*/
|
|
23
|
-
registerPoint(key, long, lat, callback) {
|
|
24
|
-
if (key in this._pointObjects) {
|
|
25
|
-
console.warn("key already registered, old one is unregistered");
|
|
26
|
-
this.unregisterPoint(key);
|
|
27
|
-
}
|
|
28
|
-
if (!this._isInBBox(long, lat))
|
|
29
|
-
return false;
|
|
30
|
-
const index = this._metaCalculater.getFlooredIndex(long, lat);
|
|
31
|
-
this._pointObjects[key] = pointObject(long, lat, index, callback);
|
|
32
|
-
if (this._texture0 && this._texture1) {
|
|
33
|
-
const { data0, data1, interpolated } = this._findAPoint(index);
|
|
34
|
-
callback(data0, data1, interpolated);
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
_isInBBox(long, lat) {
|
|
39
|
-
return lat >= this._bbox[1] && lat <= this._bbox[3] && long >= this._bbox[0] && long <= this._bbox[2];
|
|
40
|
-
}
|
|
41
|
-
unregisterPoint(key) {
|
|
42
|
-
if (!(key in this._pointObjects))
|
|
43
|
-
return false;
|
|
44
|
-
delete this._pointObjects[key];
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
updatePoint(key, long, lat) {
|
|
48
|
-
if (!(key in this._pointObjects))
|
|
49
|
-
return false;
|
|
50
|
-
if (!this._isInBBox(long, lat))
|
|
51
|
-
return false;
|
|
52
|
-
this._pointObjects[key].long = long;
|
|
53
|
-
this._pointObjects[key].lat = lat;
|
|
54
|
-
const index = this._metaCalculater.getFlooredIndex(long, lat);
|
|
55
|
-
this._pointObjects[key].posIndex = index;
|
|
56
|
-
const { data0, data1, interpolated } = this._findAPoint(index);
|
|
57
|
-
this._pointObjects[key].callback(data0, data1, interpolated);
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @param {Number} ratio 0-1
|
|
62
|
-
* @param {} textureData0
|
|
63
|
-
* @param {*} textureData1
|
|
64
|
-
*/
|
|
65
|
-
updateData(ratio, textureData0 = null, textureData1 = null) {
|
|
66
|
-
if (!textureData0 && !textureData1) {
|
|
67
|
-
this._pushPointCallBackEmpty();
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (textureData0 && textureData1) {
|
|
71
|
-
this._texture0 = textureData0;
|
|
72
|
-
this._texture1 = textureData1;
|
|
73
|
-
}
|
|
74
|
-
this._ratio = ratio;
|
|
75
|
-
this._pushPointCallbackAll();
|
|
76
|
-
}
|
|
77
|
-
_findAPoint(posIndex) {
|
|
78
|
-
const data0 = this._texture0[posIndex];
|
|
79
|
-
const data1 = this._texture1[posIndex];
|
|
80
|
-
const interpolated = data0 * (1 - this._ratio) + data1 * this._ratio;
|
|
81
|
-
return { data0, data1, interpolated };
|
|
82
|
-
}
|
|
83
|
-
_pushPointCallbackAll() {
|
|
84
|
-
for (const key in this._pointObjects) {
|
|
85
|
-
const { posIndex, callback } = this._pointObjects[key];
|
|
86
|
-
const { data0, data1, interpolated } = this._findAPoint(posIndex);
|
|
87
|
-
callback(data0, data1, interpolated);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
_pushPointCallBackEmpty() {
|
|
91
|
-
for (const key in this._pointObjects) {
|
|
92
|
-
const { callback } = this._pointObjects[key];
|
|
93
|
-
callback(null, null, null);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
flush() {
|
|
97
|
-
this._pointObjects = {};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// function test() {
|
|
101
|
-
// const cp = window.plugin.getTexturePointSampler();
|
|
102
|
-
// const bbox = [-15, 25, 70, 60];
|
|
103
|
-
// cp.registerPoint("left up", -15, 60, (data0, data1, interpolated) => {
|
|
104
|
-
// console.log("left up", data0, data1, interpolated);
|
|
105
|
-
// });
|
|
106
|
-
// cp.registerPoint("right up", 70, 60, (data0, data1, interpolated) => {
|
|
107
|
-
// console.log("right up", data0, data1, interpolated);
|
|
108
|
-
// });
|
|
109
|
-
// cp.registerPoint("left down", -15, 25, (data0, data1, interpolated) => {
|
|
110
|
-
// console.log("right down", data0, data1, interpolated);
|
|
111
|
-
// });
|
|
112
|
-
// cp.registerPoint("right down", 70, 25, (data0, data1, interpolated) => {
|
|
113
|
-
// console.log("right down", data0, data1, interpolated);
|
|
114
|
-
// });
|
|
115
|
-
// return cp;
|
|
116
|
-
// }
|
|
@@ -1,180 +0,0 @@
|
|
|
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 };
|