@pirireis/webglobeplugins 0.9.9 → 0.9.10
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 +15 -0
- package/Math/arc.js +65 -0
- package/Math/bounds/line-bbox.js +188 -0
- package/Math/constants.js +9 -0
- package/Math/frustum/camera.js +24 -0
- package/Math/frustum/from-globeinfo.js +48 -0
- package/Math/frustum/types.js +2 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/index.js +1 -0
- package/Math/juction/arc-plane.js +83 -0
- package/Math/juction/line-sphere.js +25 -0
- package/Math/juction/plane-plane.js +58 -0
- package/Math/line.js +56 -0
- package/Math/matrix4.js +1 -0
- package/Math/methods.js +201 -0
- package/Math/plane.js +60 -0
- package/Math/quaternion.js +104 -0
- package/Math/types.js +2 -0
- package/Math/utils.js +4 -0
- package/Math/vec3.js +126 -0
- package/algorithms/search-binary.js +19 -0
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/draw-subset-obj.js +18 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +341 -0
- package/altitude-locator/types.js +23 -0
- package/arrowfield/adaptor.js +14 -0
- package/arrowfield/index.js +10 -0
- package/arrowfield/plugin.js +86 -0
- package/bearing-line/index.js +8 -0
- package/bearing-line/plugin.js +449 -0
- package/circle-line-chain/chain-list-map.js +205 -0
- package/circle-line-chain/init.js +1 -0
- package/circle-line-chain/plugin.js +424 -0
- package/circle-line-chain/util.js +5 -0
- package/compass-rose/compass-rose-padding-flat.js +225 -0
- package/compass-rose/compass-text-writer.js +153 -0
- package/compass-rose/index.js +7 -0
- package/compassrose/compassrose.js +296 -0
- package/compassrose/index.js +8 -0
- package/globe-types.js +1 -0
- package/heatwave/index.js +10 -0
- package/heatwave/isobar/objectarraylabels.js +202 -0
- package/heatwave/isobar/plugin.js +343 -0
- package/heatwave/isobar/quadtreecontours.js +300 -0
- package/heatwave/plugins/heatwaveglobeshell.js +206 -0
- package/jest.config.js +7 -0
- package/package.json +4 -4
- package/partialrings/buffer-manager.js +81 -0
- package/partialrings/index.js +41 -0
- package/partialrings/plugin.js +135 -0
- package/partialrings/program.js +286 -0
- package/pin/pin-object-array.js +305 -0
- package/pin/pin-point-totem.js +60 -0
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
- package/point-heat-map/index.js +1 -0
- package/point-heat-map/plugin-webworker.js +126 -0
- package/point-heat-map/point-to-heat-map-flow.js +127 -0
- package/point-tracks/key-methods.js +5 -0
- package/point-tracks/plugin.js +338 -0
- package/programs/arrowfield/index.js +7 -0
- package/programs/arrowfield/logic.js +257 -0
- package/programs/arrowfield/object.js +66 -0
- package/programs/data2legend/density-to-legend.js +101 -0
- package/programs/data2legend/point-to-density-texture.js +100 -0
- package/programs/float2legendwithratio/index.js +8 -0
- package/programs/float2legendwithratio/logic.js +171 -0
- package/programs/float2legendwithratio/object.js +110 -0
- package/programs/globe-util/is-globe-moved.js +21 -0
- package/programs/globeshell/index.js +8 -0
- package/programs/globeshell/noise/noises.js +1 -0
- package/programs/globeshell/wiggle/index.js +8 -0
- package/programs/globeshell/wiggle/logic.js +345 -0
- package/programs/globeshell/wiggle/object.js +72 -0
- package/programs/helpers/blender/index.js +1 -0
- package/programs/helpers/blender/program.js +79 -0
- package/programs/helpers/fadeaway/index.js +7 -0
- package/programs/helpers/fadeaway/logic.js +72 -0
- package/programs/helpers/fadeaway/object.js +20 -0
- package/programs/helpers/index.js +8 -0
- package/programs/index.js +58 -0
- package/programs/interface.js +1 -0
- package/programs/line-on-globe/angled-line.js +176 -0
- package/programs/line-on-globe/circle-accurate-3d.js +141 -0
- package/programs/line-on-globe/circle-accurate-flat.js +216 -0
- package/programs/line-on-globe/circle-accurate.js +178 -0
- package/programs/line-on-globe/circle.js +167 -0
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
- package/programs/line-on-globe/linestrip.js +171 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +195 -0
- package/programs/line-on-globe/to-the-surface.js +111 -0
- package/programs/line-on-globe/util.js +8 -0
- package/programs/picking/pickable-renderer.js +188 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +142 -0
- package/programs/point-on-globe/element-point-glow.js +153 -0
- package/programs/point-on-globe/square-pixel-point.js +174 -0
- package/programs/programcache.js +131 -0
- package/programs/rings/distancering/circleflatprogram.js +156 -0
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
- package/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
- package/programs/rings/distancering/index.js +14 -0
- package/programs/rings/distancering/paddyflatprogram.js +172 -0
- package/programs/rings/distancering/paddyflatprogram2d.js +174 -0
- package/programs/rings/distancering/paddyflatprogram3d.js +172 -0
- package/programs/rings/distancering/shader.js +1 -0
- package/programs/rings/index.js +17 -0
- package/programs/rings/partial-ring/piece-of-pie.js +275 -0
- package/programs/totems/camerauniformblock.js +160 -0
- package/programs/totems/canvas-webglobe-info.js +110 -0
- package/programs/totems/gpu-selection-uniform-block.js +108 -0
- package/programs/totems/index.js +40 -0
- package/programs/two-d/pixel-circle.js +1 -0
- package/programs/two-d/pixel-padding-for-compass.js +162 -0
- package/programs/util.js +17 -0
- package/programs/vectorfields/index.js +23 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
- package/programs/vectorfields/logics/index.js +12 -0
- package/programs/vectorfields/logics/pixelbased.js +142 -0
- package/programs/vectorfields/logics/ubo.js +63 -0
- package/programs/vectorfields/pingpongbuffermanager.js +76 -0
- package/rangerings/enum.js +5 -0
- package/rangerings/index.js +15 -0
- package/rangerings/plugin.js +560 -0
- package/rangerings/rangeringangletext.js +329 -0
- package/rangerings/ring-account.js +117 -0
- package/shaders/fragment-toy/firework.js +58 -0
- package/shaders/fragment-toy/singularity.js +59 -0
- package/shape-on-terrain/arc/naive/plugin.js +252 -0
- package/timetracks/adaptors-line-strip.js +71 -0
- package/timetracks/adaptors.js +122 -0
- package/timetracks/index.js +19 -0
- package/timetracks/plugin-line-strip.js +250 -0
- package/timetracks/plugin.js +258 -0
- package/timetracks/program-line-strip.js +611 -0
- package/timetracks/program.js +772 -0
- package/timetracks/programpoint-line-strip.js +154 -0
- package/timetracks/programpoint.js +147 -0
- package/types.js +15 -0
- package/util/account/bufferoffsetmanager.js +179 -0
- package/util/account/index.js +23 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
- package/util/account/single-attribute-buffer-management/index.js +9 -0
- package/util/account/single-attribute-buffer-management/object-store.js +51 -0
- package/util/account/single-attribute-buffer-management/types.js +2 -0
- package/util/account/util.js +22 -0
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +28 -0
- package/util/check/get.js +18 -0
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +49 -0
- package/util/geometry/index.js +51 -0
- package/util/gl-util/buffer/attribute-loader.js +69 -0
- package/util/gl-util/buffer/index.js +6 -0
- package/util/gl-util/buffer/types.js +1 -0
- package/util/gl-util/draw-options/methods.js +38 -0
- package/util/gl-util/draw-options/types.js +15 -0
- package/util/gl-util/uniform-block/manager.js +156 -0
- package/util/gl-util/uniform-block/shader.js +1 -0
- package/util/gl-util/uniform-block/types.js +8 -0
- package/util/heatwavedatamanager/datamanager.js +152 -0
- package/util/heatwavedatamanager/index.js +10 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
- package/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
- package/util/index.js +57 -0
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +5 -0
- package/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
- package/util/interpolation/timetrack/web-worker-str.js +183 -0
- package/util/interpolation/timetrack/web-worker.js +48 -0
- package/util/jshelpers/data-filler.js +20 -0
- package/util/jshelpers/equality.js +20 -0
- package/util/jshelpers/index.js +37 -0
- package/util/jshelpers/timefilters.js +32 -0
- package/util/picking/fence.js +46 -0
- package/util/picking/picker-displayer.js +139 -0
- package/util/programs/draw-texture-on-canvas.js +89 -0
- package/util/programs/index.js +17 -0
- package/util/programs/shapesonglobe.js +214 -0
- package/util/programs/supersampletotextures.js +113 -0
- package/util/programs/texturetoglobe.js +182 -0
- package/util/shaderfunctions/geometrytransformations.js +340 -0
- package/util/shaderfunctions/index.js +18 -0
- package/util/shaderfunctions/nodata.js +11 -0
- package/util/shaderfunctions/noisefunctions.js +43 -0
- package/util/surface-line-data/arc-bboxes.js +25 -0
- package/util/surface-line-data/arcs-to-cuts.js +50 -0
- package/util/surface-line-data/cut-arc.js +1 -0
- package/util/surface-line-data/flow.js +28 -0
- package/util/surface-line-data/rbush-manager.js +1 -0
- package/util/surface-line-data/types.js +1 -0
- package/util/surface-line-data/web-worker.js +1 -0
- package/util/webglobe/gldefaultstates.js +7 -0
- package/util/webglobe/index.js +18 -0
- package/util/webglobe/rasteroverlay.js +78 -0
- package/util/webglobjectbuilders.js +388 -0
- package/util/webglobjectbuilders1.js +237 -0
- package/waveparticles/adaptor.js +17 -0
- package/waveparticles/index.js +10 -0
- package/waveparticles/plugin.js +266 -0
- package/wind/imagetovectorfieldandmagnitude.js +35 -0
- package/wind/index.js +14 -0
- package/wind/plugin.js +926 -0
- package/wind/vectorfieldimage.js +25 -0
- package/write-text/attached-text-writer.js +91 -0
- package/write-text/context-text.js +98 -0
- package/write-text/context-text3.js +155 -0
- package/write-text/index.js +5 -0
- package/write-text/writer-plugin.js +8 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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.BufferManager = exports.PaddingFreeAngleCache = void 0;
|
|
37
|
+
const util_1 = require("../../../util");
|
|
38
|
+
const account_1 = require("../../../util/account");
|
|
39
|
+
const camerauniformblock_1 = __importStar(require("../../totems/camerauniformblock"));
|
|
40
|
+
const programcache_1 = require("../../programcache");
|
|
41
|
+
const vertexShader = `#version 300 es ` +
|
|
42
|
+
util_1.shaderfunctions.PI +
|
|
43
|
+
util_1.shaderfunctions.R +
|
|
44
|
+
util_1.shaderfunctions.POLE +
|
|
45
|
+
camerauniformblock_1.CameraUniformBlockString +
|
|
46
|
+
util_1.shaderfunctions.mercatorXYToGLPosition +
|
|
47
|
+
util_1.shaderfunctions.longLatRadToMercator +
|
|
48
|
+
util_1.shaderfunctions.longLatRadToCartesian3D +
|
|
49
|
+
util_1.shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
50
|
+
util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
51
|
+
util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
52
|
+
|
|
53
|
+
in vec2 center;
|
|
54
|
+
in float radius;
|
|
55
|
+
in float pad_range;
|
|
56
|
+
in vec4 color;
|
|
57
|
+
in float flag;
|
|
58
|
+
in float pad_angle;
|
|
59
|
+
|
|
60
|
+
uniform int compass;
|
|
61
|
+
|
|
62
|
+
uniform float opacity;
|
|
63
|
+
|
|
64
|
+
out vec2 v_limp;
|
|
65
|
+
out vec4 v_color;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
void main() {
|
|
69
|
+
if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide
|
|
70
|
+
v_color = vec4(color.rgb, color.a * opacity);
|
|
71
|
+
|
|
72
|
+
if ( pad_angle == 0.0 ) v_color.rgb -= 0.2;
|
|
73
|
+
gl_PointSize = 2.0;
|
|
74
|
+
|
|
75
|
+
float odd = mod(float(gl_VertexID), 2.0);
|
|
76
|
+
float index = (float(gl_VertexID)- odd ) / 2.0;
|
|
77
|
+
float angle = pad_angle - 1.5707963267948966192313216916398;
|
|
78
|
+
float radius_ = radius - (pad_range * odd);
|
|
79
|
+
|
|
80
|
+
if (is3D){
|
|
81
|
+
gl_Position = projection * view * vec4(
|
|
82
|
+
circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
|
|
83
|
+
v_limp = vec2(0.0, 0.0);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
vec2 limp;
|
|
87
|
+
if ( compass == 1 ){
|
|
88
|
+
limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
89
|
+
} else {
|
|
90
|
+
limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
91
|
+
}
|
|
92
|
+
v_limp = limp;
|
|
93
|
+
gl_Position = mercatorXYToGLPosition(limp);
|
|
94
|
+
}`;
|
|
95
|
+
const fragmentShader = `#version 300 es
|
|
96
|
+
precision highp float; ` +
|
|
97
|
+
util_1.shaderfunctions.POLE + `
|
|
98
|
+
in vec4 v_color;
|
|
99
|
+
in vec2 v_limp;
|
|
100
|
+
out vec4 outColor;
|
|
101
|
+
void main() {
|
|
102
|
+
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
|
|
103
|
+
outColor = v_color;
|
|
104
|
+
}`;
|
|
105
|
+
class Logic {
|
|
106
|
+
constructor(globe) {
|
|
107
|
+
this.globe = globe;
|
|
108
|
+
this.gl = globe.gl;
|
|
109
|
+
this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
|
|
110
|
+
{
|
|
111
|
+
const gl = this.gl;
|
|
112
|
+
// assign attribute locations
|
|
113
|
+
gl.bindAttribLocation(this.program, 0, "center");
|
|
114
|
+
gl.bindAttribLocation(this.program, 1, "radius");
|
|
115
|
+
gl.bindAttribLocation(this.program, 2, "pad_range");
|
|
116
|
+
gl.bindAttribLocation(this.program, 3, "color");
|
|
117
|
+
gl.bindAttribLocation(this.program, 4, "flag");
|
|
118
|
+
gl.bindAttribLocation(this.program, 5, "pad_angle");
|
|
119
|
+
}
|
|
120
|
+
this.cameraBlockBindingPoint = 0;
|
|
121
|
+
const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
|
|
122
|
+
this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
123
|
+
this.cameraBlockTotem = programcache_1.globeProgramCache.getProgram(globe, camerauniformblock_1.default);
|
|
124
|
+
this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
|
|
125
|
+
this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
|
|
126
|
+
this._opacity = 1.0;
|
|
127
|
+
{
|
|
128
|
+
const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
129
|
+
this.gl.useProgram(this.program);
|
|
130
|
+
this.gl.uniform1i(this._compassLocation, 1);
|
|
131
|
+
this.gl.uniform1f(this._opacityLocation, 1.0);
|
|
132
|
+
this._lastCompass = 1;
|
|
133
|
+
this.gl.useProgram(currentProgram);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
draw(attrBufferManager, compass, opacity) {
|
|
137
|
+
const { gl, program, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
|
|
138
|
+
gl.useProgram(program);
|
|
139
|
+
attrBufferManager.bindPaddingVAO();
|
|
140
|
+
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
141
|
+
if (compass !== this._lastCompass) {
|
|
142
|
+
gl.uniform1i(_compassLocation, compass);
|
|
143
|
+
this._lastCompass = compass;
|
|
144
|
+
}
|
|
145
|
+
if (opacity !== this._opacity) {
|
|
146
|
+
gl.uniform1f(this._opacityLocation, opacity);
|
|
147
|
+
this._opacity = opacity;
|
|
148
|
+
}
|
|
149
|
+
gl.disable(gl.DEPTH_TEST);
|
|
150
|
+
gl.drawArraysInstanced(gl.LINES, 0, 2, attrBufferManager.length);
|
|
151
|
+
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
152
|
+
gl.enable(gl.DEPTH_TEST);
|
|
153
|
+
gl.bindVertexArray(null);
|
|
154
|
+
}
|
|
155
|
+
createBuffer({ bufferType = "DYNAMIC_DRAW", initialRingCapacity = 10 } = {}) {
|
|
156
|
+
return new BufferManager(this.gl, bufferType, initialRingCapacity);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.PaddingFreeAngleCache = Object.freeze({
|
|
160
|
+
getProgram: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
161
|
+
releaseProgram: (globe) => programcache_1.globeProgramCache.releaseProgram(globe, Logic)
|
|
162
|
+
});
|
|
163
|
+
class BufferManager extends account_1.BufferOffsetManager {
|
|
164
|
+
constructor(gl, bufferType, initialRingCapacity = 10) {
|
|
165
|
+
super(10, { capacity: initialRingCapacity, bufferType });
|
|
166
|
+
this.gl = gl;
|
|
167
|
+
this.bufferType = bufferType;
|
|
168
|
+
this.buffer = gl.createBuffer();
|
|
169
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
170
|
+
gl.bufferData(gl.ARRAY_BUFFER, this.capacity * this.itemSize * 4, gl[bufferType]);
|
|
171
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
172
|
+
this._centerMaps = new Map();
|
|
173
|
+
this.vao = gl.createVertexArray();
|
|
174
|
+
{
|
|
175
|
+
gl.bindVertexArray(this.vao);
|
|
176
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
177
|
+
gl.enableVertexAttribArray(0);
|
|
178
|
+
gl.enableVertexAttribArray(1);
|
|
179
|
+
gl.enableVertexAttribArray(2);
|
|
180
|
+
gl.enableVertexAttribArray(3);
|
|
181
|
+
gl.enableVertexAttribArray(4);
|
|
182
|
+
gl.enableVertexAttribArray(5);
|
|
183
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 40, 0);
|
|
184
|
+
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, 40, 8);
|
|
185
|
+
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, 40, 12);
|
|
186
|
+
gl.vertexAttribPointer(3, 4, gl.FLOAT, false, 40, 16);
|
|
187
|
+
gl.vertexAttribPointer(4, 1, gl.FLOAT, false, 40, 32);
|
|
188
|
+
gl.vertexAttribPointer(5, 1, gl.FLOAT, false, 40, 36);
|
|
189
|
+
// divisor
|
|
190
|
+
gl.vertexAttribDivisor(0, 1);
|
|
191
|
+
gl.vertexAttribDivisor(1, 1);
|
|
192
|
+
gl.vertexAttribDivisor(2, 1);
|
|
193
|
+
gl.vertexAttribDivisor(3, 1);
|
|
194
|
+
gl.vertexAttribDivisor(4, 1);
|
|
195
|
+
gl.vertexAttribDivisor(5, 1);
|
|
196
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
197
|
+
gl.bindVertexArray(null);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
__centerMapMethod(rings, paddingAngles) {
|
|
201
|
+
return new Map([
|
|
202
|
+
["rings", rings],
|
|
203
|
+
["paddingAngles", paddingAngles]
|
|
204
|
+
]);
|
|
205
|
+
}
|
|
206
|
+
bindPaddingVAO() {
|
|
207
|
+
this.gl.bindVertexArray(this.vao);
|
|
208
|
+
}
|
|
209
|
+
//TODO: implement this
|
|
210
|
+
// insertBulk is gone. no update feature
|
|
211
|
+
// addBulk is added.
|
|
212
|
+
// deletes old centers given
|
|
213
|
+
insertBulk(data) {
|
|
214
|
+
const { gl, buffer } = this;
|
|
215
|
+
const deleteCentersList = [];
|
|
216
|
+
for (const { centerID } of data) {
|
|
217
|
+
if (this._centerMaps.has(centerID)) {
|
|
218
|
+
deleteCentersList.push(centerID);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (deleteCentersList.length > 0) {
|
|
222
|
+
this.removeCenters(deleteCentersList);
|
|
223
|
+
}
|
|
224
|
+
const requiredSpace = this.__requiredSpaceForBulk(data);
|
|
225
|
+
const spaceLeft = this.spaceLeft;
|
|
226
|
+
// console.log("space left:", spaceLeft, "required space:", requiredSpace);
|
|
227
|
+
if (requiredSpace > spaceLeft) {
|
|
228
|
+
// console.log("new capacity:", this.capacity + requiredSpace - spaceLeft)
|
|
229
|
+
this.extendBuffer(this.capacity + requiredSpace - spaceLeft);
|
|
230
|
+
}
|
|
231
|
+
const items = [];
|
|
232
|
+
for (const { centerID, x, y, rgba, paddingAngles, hide = 0, rings } of data) {
|
|
233
|
+
this._centerMaps.set(centerID, this.__centerMapMethod(rings, paddingAngles)); // x,y, rgba, hide prograbably not needed
|
|
234
|
+
for (const { ringID, radius, padding } of rings) {
|
|
235
|
+
for (const paddingAngle of paddingAngles) {
|
|
236
|
+
const _offsetMapKey = `${centerID}_${ringID}_${paddingAngle}`;
|
|
237
|
+
const offset = this.getOffset(_offsetMapKey) | this.nextOffset();
|
|
238
|
+
items.push({
|
|
239
|
+
offset: offset,
|
|
240
|
+
payload: new Float32Array([x, y, radius, padding, rgba[0], rgba[1], rgba[2], rgba[3], hide, paddingAngle])
|
|
241
|
+
});
|
|
242
|
+
this.offSetMap.set(_offsetMapKey, offset);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
247
|
+
for (let { offset, payload } of items) {
|
|
248
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
updateCentersXY(data) {
|
|
252
|
+
const { gl, buffer } = this;
|
|
253
|
+
const items = [];
|
|
254
|
+
for (const { centerID, x, y } of data) {
|
|
255
|
+
const center = this._centerMaps.get(centerID);
|
|
256
|
+
const payload = new Float32Array([x, y]);
|
|
257
|
+
const paddingAngles = center.get("paddingAngles");
|
|
258
|
+
const rings = center.get("rings");
|
|
259
|
+
for (const { ringID } of rings) {
|
|
260
|
+
for (const paddingAngle of paddingAngles) {
|
|
261
|
+
const offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
|
|
262
|
+
items.push({ offset: this.getOffset(offsetKey), payload });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
267
|
+
for (let { offset, payload } of items) {
|
|
268
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
|
|
269
|
+
}
|
|
270
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
271
|
+
}
|
|
272
|
+
//TODO: test
|
|
273
|
+
updateCentersHide(data) {
|
|
274
|
+
const { gl, buffer } = this;
|
|
275
|
+
const items = [];
|
|
276
|
+
for (const { centerID, hide = null } of data) {
|
|
277
|
+
if (hide === null)
|
|
278
|
+
continue;
|
|
279
|
+
const block = new Float32Array([hide]);
|
|
280
|
+
const center = this._centerMaps.get(centerID);
|
|
281
|
+
if (!center)
|
|
282
|
+
continue;
|
|
283
|
+
const paddingAngles = center.get("paddingAngles");
|
|
284
|
+
const rings = center.get("rings");
|
|
285
|
+
for (const { ringID } of rings) {
|
|
286
|
+
for (const paddingAngle of paddingAngles) {
|
|
287
|
+
const offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
|
|
288
|
+
items.push({ key: offsetKey, payload: block });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
this._updatePartial(items, 8, gl, buffer);
|
|
293
|
+
}
|
|
294
|
+
updateCentersColor(data) {
|
|
295
|
+
const { gl, buffer } = this;
|
|
296
|
+
const items = [];
|
|
297
|
+
for (const { centerID, rgba } of data) {
|
|
298
|
+
const center = this._centerMaps.get(centerID);
|
|
299
|
+
if (!center)
|
|
300
|
+
continue;
|
|
301
|
+
center.set("rgba", rgba);
|
|
302
|
+
const paddingAngles = center.get("paddingAngles");
|
|
303
|
+
const rings = center.get("rings");
|
|
304
|
+
const payload = new Float32Array(rgba);
|
|
305
|
+
for (const { ringID } of rings) {
|
|
306
|
+
for (const paddingAngle of paddingAngles) {
|
|
307
|
+
const offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
|
|
308
|
+
items.push({ key: offsetKey, payload });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
this._updatePartial(items, 4, gl, buffer);
|
|
313
|
+
}
|
|
314
|
+
__requiredSpaceForBulk(data) {
|
|
315
|
+
let space = 0;
|
|
316
|
+
for (const { paddingAngles, rings } of data) {
|
|
317
|
+
space += paddingAngles.length * rings.length;
|
|
318
|
+
}
|
|
319
|
+
return space;
|
|
320
|
+
}
|
|
321
|
+
// TODO: TEST IT WITH INSERT
|
|
322
|
+
removeCenters(centerIDs) {
|
|
323
|
+
const keys = [];
|
|
324
|
+
for (const centerID of centerIDs) {
|
|
325
|
+
const center = this._centerMaps.get(centerID);
|
|
326
|
+
if (!center)
|
|
327
|
+
continue;
|
|
328
|
+
const rings = center.get("rings");
|
|
329
|
+
const paddingAngles = center.get("paddingAngles");
|
|
330
|
+
for (const { ringID } of rings) {
|
|
331
|
+
for (const paddingAngle of paddingAngles) {
|
|
332
|
+
keys.push(offsetMapKey(centerID, ringID, paddingAngle));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
this._centerMaps.delete(centerID);
|
|
336
|
+
}
|
|
337
|
+
this._removeFromBuffer(keys);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
exports.BufferManager = BufferManager;
|
|
341
|
+
const offsetMapKey = (centerID, ringID, paddingAngle) => `${centerID}_${ringID}_${paddingAngle}`;
|
|
342
|
+
/**
|
|
343
|
+
* {center has x,y, color, paddingAngles, rings} key: centerID
|
|
344
|
+
* {ring has ranges, paddings} key: ringKey
|
|
345
|
+
* _offSetMap => | key: centerID_ringKey_paddingAngle | value: offset |
|
|
346
|
+
*
|
|
347
|
+
* insertCenter
|
|
348
|
+
*
|
|
349
|
+
* insertRing
|
|
350
|
+
*
|
|
351
|
+
* updateCenter ---> updatesRings ---> updatesPaddings
|
|
352
|
+
* centerMap ringMap
|
|
353
|
+
* keeps keeps
|
|
354
|
+
* list of Rings list of Paddings
|
|
355
|
+
*
|
|
356
|
+
*
|
|
357
|
+
* needs an adaptor to convert currently implemented data into this format.
|
|
358
|
+
* current format:
|
|
359
|
+
* center = {
|
|
360
|
+
* centerID,
|
|
361
|
+
* x,
|
|
362
|
+
* y,
|
|
363
|
+
* rings: [
|
|
364
|
+
* radius,
|
|
365
|
+
* paddingRadius,
|
|
366
|
+
* rgba,
|
|
367
|
+
* ]
|
|
368
|
+
* }
|
|
369
|
+
*/
|