@pirireis/webglobeplugins 0.9.5 → 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 +8 -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 -21
- 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,420 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ring data model
|
|
3
|
-
* [centerX, centerY, range, padding, r, g, b, a, hide]
|
|
4
|
-
*
|
|
5
|
-
* Buffer is initialized with ring capacity and buffer is created with that capacity. It might be called buffer orphaning.
|
|
6
|
-
*
|
|
7
|
-
* */
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* TODO
|
|
12
|
-
* delete registerCenter
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
const RING_SIZE = 9;
|
|
17
|
-
|
|
18
|
-
export default class {
|
|
19
|
-
/**
|
|
20
|
-
* @param {WebGL2RenderingContext} gl
|
|
21
|
-
* @param {Object} options
|
|
22
|
-
* @param {Number} options.initialRingCapacity
|
|
23
|
-
* @param {String} options.bufferType - "static" or "dynamic"
|
|
24
|
-
* */
|
|
25
|
-
constructor(gl, globe, { initialRingCapacity = 20, bufferType = "STATIC_DRAW", implicitExtentionRate = 1.2 } = {}) {
|
|
26
|
-
this.gl = gl;
|
|
27
|
-
this.globe = globe;
|
|
28
|
-
this._capacity = initialRingCapacity;
|
|
29
|
-
this._ringCounter = 0;
|
|
30
|
-
this._length = 0;
|
|
31
|
-
|
|
32
|
-
this._centerMap = new Map(); // key, new MAP(x,y, rings:[])
|
|
33
|
-
this._ringOffsets = new Map();
|
|
34
|
-
this._removedRingsOffsetStack = [];
|
|
35
|
-
|
|
36
|
-
this._bufferType = gl[bufferType.toUpperCase()];
|
|
37
|
-
this.implicitExtentionRate = implicitExtentionRate;
|
|
38
|
-
this.buffer = gl.createBuffer();
|
|
39
|
-
|
|
40
|
-
{ // initilize data
|
|
41
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
42
|
-
gl.bufferData(gl.ARRAY_BUFFER, initialRingCapacity * 4 * RING_SIZE, this._bufferType);
|
|
43
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
this._circleVAO = gl.createVertexArray();
|
|
48
|
-
gl.bindVertexArray(this._circleVAO);
|
|
49
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
50
|
-
gl.enableVertexAttribArray(0);
|
|
51
|
-
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, RING_SIZE * 4, 0);
|
|
52
|
-
gl.enableVertexAttribArray(1);
|
|
53
|
-
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, RING_SIZE * 4, 2 * 4);
|
|
54
|
-
gl.enableVertexAttribArray(2);
|
|
55
|
-
gl.vertexAttribPointer(2, 4, gl.FLOAT, false, RING_SIZE * 4, 4 * 4);
|
|
56
|
-
gl.enableVertexAttribArray(3);
|
|
57
|
-
gl.vertexAttribPointer(3, 3, gl.FLOAT, false, RING_SIZE * 4, 8 * 4);
|
|
58
|
-
|
|
59
|
-
// set divisors to 1
|
|
60
|
-
gl.vertexAttribDivisor(0, 1);
|
|
61
|
-
gl.vertexAttribDivisor(1, 1);
|
|
62
|
-
gl.vertexAttribDivisor(2, 1);
|
|
63
|
-
gl.vertexAttribDivisor(3, 1);
|
|
64
|
-
gl.bindVertexArray(null);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
this._paddingVAO = gl.createVertexArray();
|
|
69
|
-
gl.bindVertexArray(this._paddingVAO);
|
|
70
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
71
|
-
gl.enableVertexAttribArray(0);
|
|
72
|
-
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, RING_SIZE * 4, 0);
|
|
73
|
-
gl.enableVertexAttribArray(1);
|
|
74
|
-
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, RING_SIZE * 4, 2 * 4);
|
|
75
|
-
gl.enableVertexAttribArray(2);
|
|
76
|
-
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, RING_SIZE * 4, 3 * 4);
|
|
77
|
-
gl.enableVertexAttribArray(3);
|
|
78
|
-
gl.vertexAttribPointer(3, 4, gl.FLOAT, false, RING_SIZE * 4, 4 * 4);
|
|
79
|
-
gl.enableVertexAttribArray(4);
|
|
80
|
-
gl.vertexAttribPointer(4, 3, gl.FLOAT, false, RING_SIZE * 4, 8 * 4);
|
|
81
|
-
gl.vertexAttribDivisor(0, 1);
|
|
82
|
-
gl.vertexAttribDivisor(1, 1);
|
|
83
|
-
gl.vertexAttribDivisor(2, 1);
|
|
84
|
-
gl.vertexAttribDivisor(3, 1);
|
|
85
|
-
gl.vertexAttribDivisor(4, 1);
|
|
86
|
-
gl.bindVertexArray(null);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @param {String} centerID
|
|
92
|
-
* @param {Object} options
|
|
93
|
-
* @param {Number} options.x
|
|
94
|
-
* @param {Number} options.y
|
|
95
|
-
* */
|
|
96
|
-
registerCenter(centerID, { x = 0, y = 0 } = {}) {
|
|
97
|
-
this._centerMap.set(centerID, new Map(
|
|
98
|
-
[
|
|
99
|
-
["x", x],
|
|
100
|
-
["y", y],
|
|
101
|
-
["rings", []] // ring keys
|
|
102
|
-
]
|
|
103
|
-
));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* @param {null | number} newCapacity if null, vacuum defragmentation is applied -> capacity is set to the current ring count
|
|
109
|
-
*/
|
|
110
|
-
defrag(newCapacity = null) {
|
|
111
|
-
const { _removedRingsOffsetStack, _ringOffsets } = this;
|
|
112
|
-
_removedRingsOffsetStack.sort();
|
|
113
|
-
this._capacity = newCapacity || this._ringCounter;
|
|
114
|
-
const arrayToLoad = new Float32Array(this._capacity * RING_SIZE);
|
|
115
|
-
const bufferData = this._getBufferData();
|
|
116
|
-
let arrayOffset = 0;
|
|
117
|
-
const newRingOffsets = new Map();
|
|
118
|
-
for (const [key, offset] of _ringOffsets) {
|
|
119
|
-
const ringOffset = offset / 4
|
|
120
|
-
const ringData = bufferData.slice(ringOffset, ringOffset + RING_SIZE);
|
|
121
|
-
arrayToLoad.set(ringData, arrayOffset);
|
|
122
|
-
newRingOffsets.set(key, arrayOffset * 4);
|
|
123
|
-
arrayOffset += RING_SIZE;
|
|
124
|
-
}
|
|
125
|
-
const { gl, buffer } = this;
|
|
126
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
127
|
-
gl.bufferData(gl.ARRAY_BUFFER, arrayToLoad, this._bufferType);
|
|
128
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
129
|
-
this._ringOffsets = newRingOffsets;
|
|
130
|
-
this._removedRingsOffsetStack = [];
|
|
131
|
-
this._length = this._ringCounter;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
extendBuffer(newCapacity) {
|
|
135
|
-
if (this._capacity >= newCapacity) {
|
|
136
|
-
console.warn("New capacity is smaller than the current capacity");
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
this._capacity = newCapacity;
|
|
140
|
-
const { gl, buffer } = this;
|
|
141
|
-
const bufferData = this._getBufferData();
|
|
142
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
143
|
-
gl.bufferData(gl.ARRAY_BUFFER, newCapacity * RING_SIZE * 4, this._bufferType);
|
|
144
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
|
145
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
checkCapacity(sizeLeft = 1) {
|
|
149
|
-
return sizeLeft <= this._capacity - this._ringCounter;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
capacityLeft() {
|
|
153
|
-
return this._capacity - this._ringCounter;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
get capacity() {
|
|
157
|
-
return this._capacity;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
get length() {
|
|
161
|
-
return this._length;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
get ringCount() {
|
|
165
|
-
return this._ringCounter;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @param {Array<string>} centerIDs
|
|
173
|
-
* */
|
|
174
|
-
removeCenters(centerIDs) {
|
|
175
|
-
const { gl, buffer } = this;
|
|
176
|
-
const zero = new Float32Array([0]);
|
|
177
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
178
|
-
for (let centerID of centerIDs) {
|
|
179
|
-
if (!this._centerMap.has(centerID)) {
|
|
180
|
-
// console.warn("Center is not registered yet");
|
|
181
|
-
// return;
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const center = this._centerMap.get(centerID);
|
|
185
|
-
const rings = center.get("rings");
|
|
186
|
-
for (let i = 0; i < rings.length; i++) {
|
|
187
|
-
// set range to 0, 3rd index of float32array
|
|
188
|
-
const offset = this._ringOffsets.get(rings[i]);
|
|
189
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset + 8, zero);
|
|
190
|
-
this._removedRingsOffsetStack.push(offset);
|
|
191
|
-
this._ringOffsets.delete(rings[i]);
|
|
192
|
-
}
|
|
193
|
-
this._ringCounter -= rings.length;
|
|
194
|
-
this._centerMap.delete(centerID);
|
|
195
|
-
}
|
|
196
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
197
|
-
this.globe.DrawRender();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
*
|
|
203
|
-
* @property {String} centerID
|
|
204
|
-
* @property {Number} x radians x
|
|
205
|
-
* @property {Number} y radians y
|
|
206
|
-
* @param {*} centerIDxyList
|
|
207
|
-
*/
|
|
208
|
-
updateCentersXY(centerIDxyList) {
|
|
209
|
-
const { gl, buffer } = this;
|
|
210
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
211
|
-
for (let { centerID, x, y } of centerIDxyList) {
|
|
212
|
-
const center = this._centerMap.get(centerID);
|
|
213
|
-
center.set("x", x);
|
|
214
|
-
center.set("y", y);
|
|
215
|
-
const xyBlock = new Float32Array([x, y]);
|
|
216
|
-
const rings = center.get("rings");
|
|
217
|
-
for (let i = 0; i < rings.length; i++) {
|
|
218
|
-
const offset = this._ringOffsets.get(rings[i]);
|
|
219
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset, xyBlock);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
223
|
-
this.globe.DrawRender();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
updateCentersHide(data) {
|
|
228
|
-
const { gl, buffer } = this;
|
|
229
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
230
|
-
for (let { centerID, hide = null } of data) {
|
|
231
|
-
if (hide === null) continue;
|
|
232
|
-
const rings = this._centerMap.get(centerID).get("rings");
|
|
233
|
-
for (let i = 0; i < rings.length; i++) {
|
|
234
|
-
const offset = this._ringOffsets.get(rings[i]);
|
|
235
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset + 32, new Float32Array([hide]));
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
239
|
-
this.globe.DrawRender();
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
insertBulk(rangeRingDatas) {
|
|
244
|
-
const { gl, buffer } = this;
|
|
245
|
-
|
|
246
|
-
{// remove existring centers
|
|
247
|
-
const existingCenterIDs = [];
|
|
248
|
-
for (let { centerID } of rangeRingDatas) {
|
|
249
|
-
if (this._centerMap.has(centerID)) {
|
|
250
|
-
existingCenterIDs.push(centerID);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
this.removeCenters(existingCenterIDs);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
{ // capacity check
|
|
257
|
-
let incomingRingSize = 0;
|
|
258
|
-
for (let { rings } of rangeRingDatas) {
|
|
259
|
-
incomingRingSize += rings.length;
|
|
260
|
-
// It should check if ring is already registered but for now it is not implemented.
|
|
261
|
-
// Reasons: increase in complexity and performance
|
|
262
|
-
}
|
|
263
|
-
this._implicitExtendBufferInNeed(incomingRingSize);
|
|
264
|
-
}
|
|
265
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
266
|
-
for (const { centerID, x, y, rings, hide = 0 } of rangeRingDatas) {
|
|
267
|
-
this.registerCenter(centerID, { x, y })
|
|
268
|
-
for (const { ringID, radius, padding, rgba } of rings) {
|
|
269
|
-
const key = this._ringKey(centerID, ringID);
|
|
270
|
-
const bufferData = new Float32Array([x, y, radius, padding, ...rgba, hide]);
|
|
271
|
-
const offset = this._nextBufferOffset();
|
|
272
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
|
|
273
|
-
this._ringOffsets.set(key, offset);
|
|
274
|
-
this._centerMap.get(centerID).get("rings").push(key);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
278
|
-
this.globe.DrawRender();
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
*
|
|
285
|
-
* @param {Array<{centerID, rgba}} centersColors
|
|
286
|
-
*/
|
|
287
|
-
updateCentersColor(centersColors) {
|
|
288
|
-
const { gl, buffer } = this;
|
|
289
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
290
|
-
for (let { centerID, rgba } of centersColors) {
|
|
291
|
-
if (!this._centerMap.has(centerID)) {
|
|
292
|
-
console.warn("Center is not registered yet");
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
const rings = this._centerMap.get(centerID).get("rings");
|
|
296
|
-
const block = new Float32Array(rgba);
|
|
297
|
-
for (let i = 0; i < rings.length; i++) {
|
|
298
|
-
const offset = this._ringOffsets.get(rings[i]);
|
|
299
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset + 16, block);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
303
|
-
this.globe.DrawRender();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ----------------- INTERNAL METHODS ----------------- //
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
bindCircleVAO() {
|
|
310
|
-
this.gl.bindVertexArray(this._circleVAO);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
bindPaddingVAO() {
|
|
314
|
-
this.gl.bindVertexArray(this._paddingVAO);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
free() {
|
|
319
|
-
this.gl.deleteBuffer(this.buffer);
|
|
320
|
-
this.gl.deleteVertexArray(this._circleVAO);
|
|
321
|
-
this.gl.deleteVertexArray(this._paddingVAO);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// ----------------- PRIVATE METHODS ----------------- //
|
|
325
|
-
|
|
326
|
-
_getBufferData() {
|
|
327
|
-
const { gl, buffer } = this;
|
|
328
|
-
const size = new Float32Array(this._length * RING_SIZE);
|
|
329
|
-
const bufferData = new Float32Array(size);
|
|
330
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
331
|
-
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
|
332
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
333
|
-
return bufferData;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
_ringKey(centerID, ringID) {
|
|
337
|
-
return `C=${centerID},R=${ringID}`;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
_nextBufferOffset() {
|
|
343
|
-
if (!this.checkCapacity()) {
|
|
344
|
-
throw new Error("Buffer is full");
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
let offset;
|
|
348
|
-
if (this._removedRingsOffsetStack.length > 0) {
|
|
349
|
-
offset = this._removedRingsOffsetStack.pop();
|
|
350
|
-
} else {
|
|
351
|
-
offset = this._ringCounter * RING_SIZE * 4;
|
|
352
|
-
this._length++;
|
|
353
|
-
}
|
|
354
|
-
this._ringCounter++;
|
|
355
|
-
return offset;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
_implicitExtendBufferInNeed(incomingRingSize) {
|
|
360
|
-
const overCapacity = incomingRingSize - this.capacityLeft();
|
|
361
|
-
if (overCapacity <= 0) return;
|
|
362
|
-
const newCapacity = Math.ceil((this._capacity + overCapacity) * this.implicitExtentionRate);
|
|
363
|
-
this.extendBuffer(newCapacity);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
async readRing(centerID, ringID) {
|
|
368
|
-
const key = this._ringKey(centerID, ringID);
|
|
369
|
-
if (!this._ringOffsets.has(key)) {
|
|
370
|
-
console.warn("Ring is not registered yet");
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const offset = this._ringOffsets.get(key);
|
|
374
|
-
const { gl, buffer } = this;
|
|
375
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
376
|
-
const bufferData = new Float32Array(9);
|
|
377
|
-
gl.getBufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
|
|
378
|
-
return {
|
|
379
|
-
centerX: bufferData[0],
|
|
380
|
-
centerY: bufferData[1],
|
|
381
|
-
range: bufferData[2],
|
|
382
|
-
padding: bufferData[3],
|
|
383
|
-
rgba: [bufferData[4], bufferData[5], bufferData[6], bufferData[7]],
|
|
384
|
-
hide: bufferData[8]
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* TODOS:
|
|
392
|
-
* - bulk ring registration. This must be managed here to avoid binding and unbinding buffer multiple times
|
|
393
|
-
* - bulk centers and rings registration
|
|
394
|
-
*
|
|
395
|
-
* - Check capacity on extend buffer and collect garbage
|
|
396
|
-
* - set length to the filled part of the buffer. used for draw calls
|
|
397
|
-
* */
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* collectGarbage with Defragmantation
|
|
401
|
-
* Basic idea: on unregistration the last ring is moved to the removed ring's place. length is decreased by 1
|
|
402
|
-
* Optimization: Reading buffer is expensive. So bulk defragmentation is needed to work with this approach
|
|
403
|
-
* */
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Documentation
|
|
409
|
-
*
|
|
410
|
-
* Methods:
|
|
411
|
-
* - insertRings(centerIdringIdRadiusPaddingRgbaHide)
|
|
412
|
-
* - removeRings(centerIDringIDs)
|
|
413
|
-
* - removeCenters(centerIDs)
|
|
414
|
-
* - updateCentersXY(centerIDxyList)
|
|
415
|
-
* - updateCenters(centerDatas)
|
|
416
|
-
* - insertBulk(rangeRingDatas)
|
|
417
|
-
* - updateRing(centerID, ringID, { radius, padding, rgba, hide })
|
|
418
|
-
* - readRing(centerID, ringID)
|
|
419
|
-
*
|
|
420
|
-
*/
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { programCache as circleProgramCache } from './circleflatprogram';
|
|
2
|
-
import { PaddingProgramCache } from './paddyflatprogram';
|
|
3
|
-
import CirclePaddySharedBuffer from './circlepaddysharedbuffer';
|
|
4
|
-
import { PaddingFreeAngleCache } from './circlepaddingfreeangleprogram';
|
|
5
|
-
export { circleProgramCache, PaddingProgramCache, CirclePaddySharedBuffer, PaddingFreeAngleCache };
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { createProgram, shaderfunctions } from "../../../util";
|
|
2
|
-
import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
|
|
3
|
-
import { globeProgramCache, noRegisterGlobeProgramCache } from "../../programcache";
|
|
4
|
-
|
|
5
|
-
const vertexShader = `#version 300 es ` +
|
|
6
|
-
shaderfunctions.PI +
|
|
7
|
-
shaderfunctions.R +
|
|
8
|
-
shaderfunctions.POLE +
|
|
9
|
-
CameraUniformBlockString +
|
|
10
|
-
shaderfunctions.mercatorXYToGLPosition +
|
|
11
|
-
shaderfunctions.longLatRadToMercator +
|
|
12
|
-
shaderfunctions.longLatRadToCartesian3D +
|
|
13
|
-
shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
14
|
-
shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
15
|
-
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
|
|
16
|
-
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
17
|
-
|
|
18
|
-
in vec2 center;
|
|
19
|
-
in float radius;
|
|
20
|
-
in float pad_range;
|
|
21
|
-
in vec4 color;
|
|
22
|
-
in float flag;
|
|
23
|
-
|
|
24
|
-
uniform int compass;
|
|
25
|
-
uniform float pad_count;
|
|
26
|
-
|
|
27
|
-
uniform float opacity;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
out vec2 v_limp;
|
|
31
|
-
out vec4 v_color;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
void main() {
|
|
35
|
-
|
|
36
|
-
float alpha_padding = z_level * z_level / (pad_range/ 100.0 );
|
|
37
|
-
if( flag == 2.0 || flag == 1.0 || radius == 0.0 || alpha_padding < 0.1 || z_level < 3.0 ) return; // 1.0 is hide
|
|
38
|
-
v_color = vec4(color.rgb, color.a * alpha_padding * opacity);
|
|
39
|
-
|
|
40
|
-
gl_PointSize = 2.0;
|
|
41
|
-
|
|
42
|
-
float odd = mod(float(gl_VertexID), 2.0);
|
|
43
|
-
float index = (float(gl_VertexID)- odd ) / 2.0;
|
|
44
|
-
float angle = 3.1415926535897932384626433832795 * 2.0 * (index / pad_count );
|
|
45
|
-
float radius_ = radius - (pad_range * odd);
|
|
46
|
-
|
|
47
|
-
if ( is3D){
|
|
48
|
-
gl_Position = projection * view * vec4(
|
|
49
|
-
circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
|
|
50
|
-
v_limp = vec2(0.0, 0.0);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
vec2 limp;
|
|
54
|
-
if ( compass == 1 ){
|
|
55
|
-
limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
56
|
-
} else {
|
|
57
|
-
// limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
|
|
58
|
-
limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
59
|
-
}
|
|
60
|
-
v_limp = limp;
|
|
61
|
-
gl_Position = mercatorXYToGLPosition(limp);
|
|
62
|
-
}`;
|
|
63
|
-
|
|
64
|
-
const fragmentShader = `#version 300 es
|
|
65
|
-
precision highp float; `+
|
|
66
|
-
shaderfunctions.POLE + `
|
|
67
|
-
in vec4 v_color;
|
|
68
|
-
in vec2 v_limp;
|
|
69
|
-
out vec4 outColor;
|
|
70
|
-
void main() {
|
|
71
|
-
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
|
|
72
|
-
outColor = v_color;
|
|
73
|
-
}`;
|
|
74
|
-
|
|
75
|
-
class Logic {
|
|
76
|
-
constructor(globe) {
|
|
77
|
-
this.globe = globe;
|
|
78
|
-
this.gl = globe.gl;
|
|
79
|
-
this.program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
80
|
-
{ // bind positions so bufferManager can use them
|
|
81
|
-
this.gl.bindAttribLocation(this.program, 0, "center");
|
|
82
|
-
this.gl.bindAttribLocation(this.program, 1, "radius");
|
|
83
|
-
this.gl.bindAttribLocation(this.program, 2, "pad_range");
|
|
84
|
-
this.gl.bindAttribLocation(this.program, 3, "color");
|
|
85
|
-
this.gl.bindAttribLocation(this.program, 4, "flag");
|
|
86
|
-
}
|
|
87
|
-
this.cameraBlockBindingPoint = 0;
|
|
88
|
-
const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
|
|
89
|
-
this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
90
|
-
this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
91
|
-
this._padCountLocation = this.gl.getUniformLocation(this.program, "pad_count");
|
|
92
|
-
this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
|
|
93
|
-
this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
|
|
94
|
-
this._compassMode = 1;
|
|
95
|
-
this._opacity = 1.0;
|
|
96
|
-
this._padCount = 360;
|
|
97
|
-
{
|
|
98
|
-
const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
99
|
-
this.gl.useProgram(this.program);
|
|
100
|
-
this.gl.uniform1i(this._compassLocation, 1);
|
|
101
|
-
this.gl.uniform1f(this._opacityLocation, 1.0);
|
|
102
|
-
this.gl.uniform1f(this._padCountLocation, 360)
|
|
103
|
-
this.gl.useProgram(currentProgram);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
draw(attrBufferManager, padCount, compass, opacity) {
|
|
110
|
-
const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
|
|
111
|
-
gl.useProgram(program);
|
|
112
|
-
attrBufferManager.bindPaddingVAO();
|
|
113
|
-
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
114
|
-
// draw instanced
|
|
115
|
-
if (padCount !== this._padCount) {
|
|
116
|
-
this._padCount = padCount;
|
|
117
|
-
// console.log("padCount", padCount);
|
|
118
|
-
gl.uniform1f(_padCountLocation, padCount);
|
|
119
|
-
}
|
|
120
|
-
if (compass !== this._compassMode) {
|
|
121
|
-
// console.log("compass", compass);
|
|
122
|
-
gl.uniform1i(_compassLocation, compass);
|
|
123
|
-
this._compassMode = compass;
|
|
124
|
-
}
|
|
125
|
-
if (opacity !== this._opacity) {
|
|
126
|
-
// console.log("opacity", opacity);
|
|
127
|
-
this._opacity = opacity;
|
|
128
|
-
gl.uniform1f(this._opacityLocation, opacity);
|
|
129
|
-
}
|
|
130
|
-
gl.drawArraysInstanced(gl.LINES, 0, padCount * 2, attrBufferManager.length);
|
|
131
|
-
gl.bindVertexArray(null);
|
|
132
|
-
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
free() {
|
|
136
|
-
this.gl.deleteProgram(this.program);
|
|
137
|
-
globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export const PaddingProgramCache = Object.freeze({
|
|
144
|
-
getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
|
|
145
|
-
releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
|
|
146
|
-
})
|