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