@pirireis/webglobeplugins 1.1.24 → 1.2.1
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/altitude-locator/plugin.js +9 -9
- package/package.json +1 -1
- package/programs/line-on-globe/linestrip/linestrip.js +10 -13
- package/programs/line-on-globe/naive-accurate-flexible.js +14 -24
- package/programs/picking/pickable-polygon-renderer.js +9 -13
- package/programs/picking/pickable-renderer.js +11 -15
- package/programs/point-on-globe/element-globe-surface-glow.js +10 -17
- package/programs/point-on-globe/element-point-glow.js +11 -15
- package/programs/rings/partial-ring/piece-of-pie.js +16 -22
- package/semiplugins/lightweight/line-plugin.js +24 -21
- package/semiplugins/lightweight/piece-of-pie-plugin.js +7 -7
- package/semiplugins/shape-on-terrain/arc-plugin.js +13 -16
- package/semiplugins/shape-on-terrain/circle-plugin.js +9 -10
- package/semiplugins/shape-on-terrain/padding-1-degree.js +5 -6
- package/semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.js +6 -5
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +0 -1
- package/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.js +0 -1
- package/util/gl-util/buffer/attribute-loader.js +6 -17
|
@@ -7,7 +7,7 @@ import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
|
7
7
|
import { PickerDisplayer } from '../util/picking/picker-displayer';
|
|
8
8
|
import { wgs84ToCartesian3d, wgs84ToMercator } from '../Math/methods';
|
|
9
9
|
import { constraintFloat, opacityCheck } from '../util/check/typecheck';
|
|
10
|
-
import {
|
|
10
|
+
import { AttributeLoader } from '../util/gl-util/buffer/attribute-loader';
|
|
11
11
|
import { CameraUniformBlockTotemCache } from '../programs/totems/camerauniformblock';
|
|
12
12
|
/**
|
|
13
13
|
* is used with depth we can create a line from surface to the point.
|
|
@@ -76,16 +76,16 @@ class PointGlowLineToEarthPlugin {
|
|
|
76
76
|
_glowPointWrapper.program = ElementPointGlowProgramCache.get(globe);
|
|
77
77
|
_lineProgramWrapper.program = LineOnGlobeCache.get(globe);
|
|
78
78
|
this._pickerDisplayer = new PickerDisplayer(globe);
|
|
79
|
-
const obj = (key) => key === null ? null : createBufferAndReadInfo(this._bufferManagersMap.get(key).bufferManager.buffer);
|
|
80
|
-
_pickableWrapper.vao = _pickableWrapper.program.
|
|
81
|
-
_pickableWrapper.vaoLine = _pickableWrapper.program.
|
|
82
|
-
_pickableWrapper.vaoHoverPoint = _pickableWrapper.program.
|
|
83
|
-
_pickableWrapper.vaoHoverLine = _pickableWrapper.program.
|
|
84
|
-
_glowPointWrapper.vao = _glowPointWrapper.program.
|
|
85
|
-
// _lineProgramWrapper.vao = _lineProgramWrapper.program.
|
|
79
|
+
const obj = (key) => key === null ? null : AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get(key).bufferManager.buffer);
|
|
80
|
+
_pickableWrapper.vao = _pickableWrapper.program.createAttributeLoader(AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('pos3D').bufferManager.buffer, 6 * 4, 0), AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('pos2D').bufferManager.buffer), AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('rgba').bufferManager.buffer, 8 * 4, 0), AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('size').bufferManager.buffer));
|
|
81
|
+
_pickableWrapper.vaoLine = _pickableWrapper.program.createAttributeLoader(...['pos3D', 'pos2D', 'rgba', null].map(obj));
|
|
82
|
+
_pickableWrapper.vaoHoverPoint = _pickableWrapper.program.createAttributeLoader(AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('pos3D').bufferManager.buffer, 6 * 4, 0), AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('pos2D').bufferManager.buffer), null, AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('size').bufferManager.buffer));
|
|
83
|
+
_pickableWrapper.vaoHoverLine = _pickableWrapper.program.createAttributeLoader(...['pos3D', 'pos2D', null, null].map(obj));
|
|
84
|
+
_glowPointWrapper.vao = _glowPointWrapper.program.createAttributeLoader(AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('pos3D').bufferManager.buffer, 6 * 4, 0), AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('pos2D').bufferManager.buffer), null, AttributeLoader.createBufferAndReadInfo(this._bufferManagersMap.get('size').bufferManager.buffer));
|
|
85
|
+
// _lineProgramWrapper.vao = _lineProgramWrapper.program.createAttributeLoader(
|
|
86
86
|
// ...[null, 'pos3D', null, 'reverse3D', null, null, "rgba"].map(obj)
|
|
87
87
|
// );
|
|
88
|
-
// _pickableWrapper.vaoRev = _pickableWrapper.program.
|
|
88
|
+
// _pickableWrapper.vaoRev = _pickableWrapper.program.createAttributeLoader(
|
|
89
89
|
// ...['reverse3D', 'pos2D', 'rgba', 'size'].map(obj)
|
|
90
90
|
// );
|
|
91
91
|
_pickableWrapper.ubo = _pickableWrapper.program.createUBO();
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { createProgram } from "../../../util/webglobjectbuilders";
|
|
|
2
2
|
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../../totems/index";
|
|
3
3
|
import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../../util/shaderfunctions/geometrytransformations";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../../programcache";
|
|
5
|
-
import {
|
|
5
|
+
import { AttributeLoader } from "../../../util/gl-util/buffer/attribute-loader";
|
|
6
6
|
import { UniformBlockManager } from "../../../util/gl-util/uniform-block/manager";
|
|
7
7
|
import { drawArrays } from "../../../util/gl-util/draw-options/methods";
|
|
8
8
|
const ESCAPE_VALUE = -1;
|
|
@@ -100,17 +100,14 @@ export class LineProgram {
|
|
|
100
100
|
this._ubosPublished.push(ubo);
|
|
101
101
|
return ubo;
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
attributeLoader(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
|
|
110
|
-
gl.bindVertexArray(null);
|
|
111
|
-
return vao;
|
|
103
|
+
createAttributeLoader(position3D, position2D, color) {
|
|
104
|
+
return new AttributeLoader(this.gl, [
|
|
105
|
+
{ bufferAndReadInfo: position3D, index: 0, size: 3, options: { escapeValues: [NaN, NaN, NaN] } },
|
|
106
|
+
{ bufferAndReadInfo: position2D, index: 1, size: 2, options: { escapeValues: [NaN, NaN] } },
|
|
107
|
+
{ bufferAndReadInfo: color, index: 2, size: 4, options: { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] } },
|
|
108
|
+
]);
|
|
112
109
|
}
|
|
113
|
-
draw(
|
|
110
|
+
draw(attributeLoader, drawOptions, opacity = 1, flexibleUBO = null) {
|
|
114
111
|
const { gl, program, cameraBlockTotem } = this;
|
|
115
112
|
gl.useProgram(program);
|
|
116
113
|
if (opacity !== this._opacity.value) {
|
|
@@ -120,10 +117,10 @@ export class LineProgram {
|
|
|
120
117
|
const ubo = flexibleUBO || this._defaultFlexibleUBO;
|
|
121
118
|
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
122
119
|
ubo.bind();
|
|
123
|
-
|
|
120
|
+
attributeLoader.bind();
|
|
124
121
|
// drawArrays(gl, gl.POINTS, drawOptions);
|
|
125
122
|
drawArrays(gl, gl.LINE_STRIP, drawOptions);
|
|
126
|
-
|
|
123
|
+
attributeLoader.unbind();
|
|
127
124
|
ubo.unbind();
|
|
128
125
|
cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
129
126
|
}
|
|
@@ -2,7 +2,7 @@ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totem
|
|
|
2
2
|
import { slerp, POLE, R_3D, mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
|
|
3
3
|
import { createProgram } from "../../util/webglobjectbuilders";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
|
-
import {
|
|
5
|
+
import { AttributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
6
|
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
7
7
|
import { drawInstanced } from "../../util/gl-util/draw-options/methods";
|
|
8
8
|
const GLOBE_MIDPOINT_COUNT = 30;
|
|
@@ -93,7 +93,6 @@ void main() {
|
|
|
93
93
|
}
|
|
94
94
|
`;
|
|
95
95
|
class Logic {
|
|
96
|
-
vaosPublished = [];
|
|
97
96
|
isFreed = false;
|
|
98
97
|
globe;
|
|
99
98
|
gl;
|
|
@@ -135,11 +134,11 @@ class Logic {
|
|
|
135
134
|
* @param opacity - Opacity value (0-1)
|
|
136
135
|
* @param flexibleUBO - Optional flexible uniform buffer object
|
|
137
136
|
*/
|
|
138
|
-
draw(
|
|
137
|
+
draw(attributeLoader, drawOptions, opacity, flexibleUBO = null) {
|
|
139
138
|
const { gl, program, globe, cameraBlockTotem, _defaultFlexibleUBO } = this;
|
|
140
139
|
gl.useProgram(program);
|
|
141
140
|
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
142
|
-
|
|
141
|
+
attributeLoader.bind();
|
|
143
142
|
if (opacity !== this._lastOpacity) {
|
|
144
143
|
gl.uniform1f(this._opacityLocation, opacity);
|
|
145
144
|
this._lastOpacity = opacity;
|
|
@@ -149,7 +148,7 @@ class Logic {
|
|
|
149
148
|
ubo.bind();
|
|
150
149
|
drawInstanced(gl, gl.LINE_STRIP, drawOptions, vertexCount);
|
|
151
150
|
ubo.unbind();
|
|
152
|
-
|
|
151
|
+
attributeLoader.unbind();
|
|
153
152
|
cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
154
153
|
}
|
|
155
154
|
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
@@ -162,32 +161,23 @@ class Logic {
|
|
|
162
161
|
]));
|
|
163
162
|
return ubo;
|
|
164
163
|
}
|
|
165
|
-
|
|
166
|
-
const { gl } = this;
|
|
167
|
-
const vao = gl.createVertexArray();
|
|
168
|
-
if (!vao) {
|
|
169
|
-
throw new Error("Failed to create vertex array object");
|
|
170
|
-
}
|
|
171
|
-
gl.bindVertexArray(vao);
|
|
164
|
+
createAttributeLoader(startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
|
|
172
165
|
const divisor = 1;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.vaosPublished.push(vao);
|
|
183
|
-
return vao;
|
|
166
|
+
return new AttributeLoader(this.gl, [
|
|
167
|
+
{ bufferAndReadInfo: startPotision2DBufferObj, index: 0, size: 2, options: { divisor, escapeValues: [NaN, NaN] } },
|
|
168
|
+
{ bufferAndReadInfo: startPotision3DBufferObj, index: 1, size: 3, options: { divisor, escapeValues: [NaN, NaN, NaN] } },
|
|
169
|
+
{ bufferAndReadInfo: endPosition2DBufferObj, index: 2, size: 2, options: { divisor, escapeValues: [NaN, NaN] } },
|
|
170
|
+
{ bufferAndReadInfo: endPosition3DBufferObj, index: 3, size: 3, options: { divisor, escapeValues: [NaN, NaN, NaN] } },
|
|
171
|
+
{ bufferAndReadInfo: dashRatioBufferObj, index: 4, size: 1, options: { divisor, escapeValues: [escapeValue] } },
|
|
172
|
+
{ bufferAndReadInfo: dashOpacityBufferObj, index: 5, size: 1, options: { divisor, escapeValues: [escapeValue] } },
|
|
173
|
+
{ bufferAndReadInfo: colorBufferObj, index: 6, size: 4, options: { divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] } }
|
|
174
|
+
]);
|
|
184
175
|
}
|
|
185
176
|
free() {
|
|
186
177
|
if (this.isFreed)
|
|
187
178
|
return;
|
|
188
179
|
CameraUniformBlockTotemCache.release(this.globe);
|
|
189
180
|
this.gl.deleteProgram(this.program);
|
|
190
|
-
this.vaosPublished.forEach((vao) => this.gl.deleteVertexArray(vao));
|
|
191
181
|
this._ubosPublished.forEach((ubo) => ubo.free());
|
|
192
182
|
this.isFreed = true;
|
|
193
183
|
}
|
|
@@ -3,7 +3,7 @@ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totem
|
|
|
3
3
|
import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
5
|
import { drawArrays, DrawRangeIndexParams } from "../../util/gl-util/draw-options/methods";
|
|
6
|
-
import {
|
|
6
|
+
import { AttributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
7
7
|
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
8
8
|
const uniformBindingPoints = {
|
|
9
9
|
camera: 0,
|
|
@@ -139,17 +139,13 @@ class PointOnGlobeProgram {
|
|
|
139
139
|
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
140
140
|
return ubo;
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
attributeLoader(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
|
|
150
|
-
gl.bindVertexArray(null);
|
|
151
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
152
|
-
return vao;
|
|
142
|
+
createAttributeLoader(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
|
|
143
|
+
return new AttributeLoader(this.gl, [
|
|
144
|
+
{ bufferAndReadInfo: pos3DBufferObj, index: 0, size: 3 },
|
|
145
|
+
{ bufferAndReadInfo: pos2DBufferObj, index: 1, size: 2 },
|
|
146
|
+
{ bufferAndReadInfo: rgbaBufferObj, index: 2, size: 4, options: { escapeValues: [-1, -1, -1, -1] } },
|
|
147
|
+
{ bufferAndReadInfo: sizeBufferObj, index: 3, size: 1, options: { escapeValues: [-1] } }
|
|
148
|
+
]);
|
|
153
149
|
}
|
|
154
150
|
/**
|
|
155
151
|
*
|
|
@@ -181,4 +177,4 @@ const PickableRendererProgramCache = Object.freeze({
|
|
|
181
177
|
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
|
|
182
178
|
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
|
|
183
179
|
});
|
|
184
|
-
export { PickableRendererProgramCache };
|
|
180
|
+
// export { PickableRendererProgramCache };
|
|
@@ -3,7 +3,7 @@ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totem
|
|
|
3
3
|
import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
5
|
import { drawArrays } from "../../util/gl-util/draw-options/methods"; //DrawRangeIndexParams
|
|
6
|
-
import {
|
|
6
|
+
import { AttributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
7
7
|
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
8
8
|
const uniformBindingPoints = {
|
|
9
9
|
camera: 0,
|
|
@@ -139,34 +139,30 @@ class PointOnGlobeProgram {
|
|
|
139
139
|
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
140
140
|
return ubo;
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
attributeLoader(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
|
|
150
|
-
gl.bindVertexArray(null);
|
|
151
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
152
|
-
return vao;
|
|
142
|
+
createAttributeLoader(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
|
|
143
|
+
return new AttributeLoader(this.gl, [
|
|
144
|
+
{ bufferAndReadInfo: pos3DBufferObj, index: 0, size: 3 },
|
|
145
|
+
{ bufferAndReadInfo: pos2DBufferObj, index: 1, size: 2 },
|
|
146
|
+
{ bufferAndReadInfo: rgbaBufferObj, index: 2, size: 4, options: { escapeValues: [-1, -1, -1, -1] } },
|
|
147
|
+
{ bufferAndReadInfo: sizeBufferObj, index: 3, size: 1, options: { escapeValues: [-1] } }
|
|
148
|
+
]);
|
|
153
149
|
}
|
|
154
150
|
/**
|
|
155
151
|
*
|
|
156
152
|
* @param {vertexArrayObject} vao
|
|
157
153
|
* @param {DrawRangeIndexParams} drawOptions
|
|
158
154
|
*/
|
|
159
|
-
draw(
|
|
155
|
+
draw(attibuteLoader, drawOptions, ubo = null) {
|
|
160
156
|
const { gl, program } = this;
|
|
161
157
|
gl.useProgram(program);
|
|
162
|
-
|
|
158
|
+
attibuteLoader.bind();
|
|
163
159
|
this.cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
164
160
|
ubo = ubo || this._defaultUBO;
|
|
165
161
|
ubo.bind();
|
|
166
162
|
drawArrays(gl, gl.POINTS, drawOptions);
|
|
167
163
|
ubo.unbind();
|
|
168
164
|
this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
169
|
-
|
|
165
|
+
attibuteLoader.unbind();
|
|
170
166
|
}
|
|
171
167
|
free() {
|
|
172
168
|
if (this._isFreed)
|
|
@@ -9,7 +9,7 @@ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totem
|
|
|
9
9
|
import { PI, cartesian3DToGLPosition, circleLimpFromLongLatRadCenterCartesian3D_accurate } from "../../util/shaderfunctions/geometrytransformations";
|
|
10
10
|
import { createProgram } from "../../util/webglobjectbuilders";
|
|
11
11
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
12
|
-
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
12
|
+
import { AttributeLoader, attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
13
13
|
import { drawInstanced } from "../../util/gl-util/draw-options/methods";
|
|
14
14
|
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
15
15
|
const uboBlockManager = new UniformBlockManager("FlexibleBlock", [
|
|
@@ -67,7 +67,6 @@ class Logic {
|
|
|
67
67
|
constructor(globe) {
|
|
68
68
|
this.globe = globe;
|
|
69
69
|
this.gl = globe.gl;
|
|
70
|
-
this._vaoCache = [];
|
|
71
70
|
this.program = createProgram(this.gl, vs, fs);
|
|
72
71
|
const { gl, program } = this;
|
|
73
72
|
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
@@ -95,22 +94,18 @@ class Logic {
|
|
|
95
94
|
uboBlockManager.assignBindingPoint(this.gl, this.program);
|
|
96
95
|
this._defaultUBO = uboBlockManager.createUBO(this.gl);
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
const { gl } = this;
|
|
100
|
-
const vao = gl.createVertexArray();
|
|
97
|
+
createAttributeLoader(pos3DObj, radiusObj, colorObj) {
|
|
101
98
|
const divisor = 1;
|
|
102
|
-
gl
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this._vaoCache.push(vao);
|
|
108
|
-
return vao;
|
|
99
|
+
return new AttributeLoader(this.gl, [
|
|
100
|
+
{ bufferAndReadInfo: pos3DObj, index: 0, size: 3, options: { divisor } },
|
|
101
|
+
{ bufferAndReadInfo: radiusObj, index: 1, size: 1, options: { divisor, escapeValues: [-1] } },
|
|
102
|
+
{ bufferAndReadInfo: colorObj, index: 2, size: 4, options: { divisor, escapeValues: [-1, -1, -1, -1] } }
|
|
103
|
+
]);
|
|
109
104
|
}
|
|
110
|
-
draw(
|
|
105
|
+
draw(attibuteLoader, drawOptions, opacity = 1.0, ubo = null) {
|
|
111
106
|
const { gl, program } = this;
|
|
112
107
|
gl.useProgram(program);
|
|
113
|
-
|
|
108
|
+
attibuteLoader.bind();
|
|
114
109
|
if (opacity !== this._uniforms.opacity) {
|
|
115
110
|
gl.uniform1f(this._uniforms.opacity_loc, opacity);
|
|
116
111
|
this._uniforms.opacity = opacity;
|
|
@@ -119,15 +114,13 @@ class Logic {
|
|
|
119
114
|
ubo.bind();
|
|
120
115
|
drawInstanced(gl, gl.TRIANGLE_FAN, drawOptions);
|
|
121
116
|
ubo.unbind();
|
|
122
|
-
|
|
117
|
+
attibuteLoader.unbind();
|
|
123
118
|
}
|
|
124
119
|
free() {
|
|
125
120
|
if (this._isFreed)
|
|
126
121
|
return;
|
|
127
122
|
CameraUniformBlockTotemCache.release(this.globe);
|
|
128
123
|
this.gl.deleteProgram(this.program);
|
|
129
|
-
for (const vao of this._vaoCache)
|
|
130
|
-
this.gl.deleteVertexArray(vao);
|
|
131
124
|
this._isFreed = true;
|
|
132
125
|
}
|
|
133
126
|
}
|
|
@@ -2,7 +2,7 @@ import { createProgram } from "../../util/webglobjectbuilders";
|
|
|
2
2
|
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
|
|
3
3
|
import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
|
-
import {
|
|
5
|
+
import { AttributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
6
|
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
7
7
|
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
8
8
|
import { singularity } from "../../shaders/fragment-toy/singularity";
|
|
@@ -105,32 +105,28 @@ class Logic {
|
|
|
105
105
|
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
106
106
|
this._defaultUBO = uniformBlockManager.createUBO(this.gl);
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
attributeLoader(gl, sizeBuffer, 3, 1, { escapeValues: [-1] });
|
|
116
|
-
gl.bindVertexArray(null);
|
|
117
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
118
|
-
return vao;
|
|
108
|
+
createAttributeLoader(pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
|
|
109
|
+
return new AttributeLoader(this.gl, [
|
|
110
|
+
{ bufferAndReadInfo: pos3DBuffer, index: 0, size: 3 },
|
|
111
|
+
{ bufferAndReadInfo: pos2DBuffer, index: 1, size: 2 },
|
|
112
|
+
{ bufferAndReadInfo: colorBuffer, index: 2, size: 4, options: { escapeValues: [-1, -1, -1, -1] } },
|
|
113
|
+
{ bufferAndReadInfo: sizeBuffer, index: 3, size: 1, options: { escapeValues: [-1] } }
|
|
114
|
+
]);
|
|
119
115
|
}
|
|
120
116
|
createUBO() {
|
|
121
117
|
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
122
118
|
return ubo;
|
|
123
119
|
}
|
|
124
|
-
draw(
|
|
120
|
+
draw(attributeLoader, drawOptions, ubo = null) {
|
|
125
121
|
const { gl, program, cameraBlockTotem } = this;
|
|
126
122
|
gl.useProgram(program);
|
|
127
|
-
|
|
123
|
+
attributeLoader.bind();
|
|
128
124
|
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
129
125
|
ubo = ubo || this._defaultUBO;
|
|
130
126
|
ubo.bind();
|
|
131
127
|
drawArrays(gl, gl.POINTS, drawOptions);
|
|
132
128
|
ubo.unbind();
|
|
133
|
-
|
|
129
|
+
attributeLoader.unbind();
|
|
134
130
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
135
131
|
this.globe.DrawRender();
|
|
136
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createProgram } from "../../../util/webglobjectbuilders";
|
|
2
2
|
import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems/index";
|
|
3
3
|
import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
|
|
4
|
-
import {
|
|
4
|
+
import { AttributeLoader } from "../../../util/gl-util/buffer/attribute-loader";
|
|
5
5
|
import { UniformBlockManager } from "../../../util/gl-util/uniform-block/manager";
|
|
6
6
|
import { POLE, PI, longLatRadToMercator, mercatorXYToGLPosition, longLatRadToCartesian3D, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
7
7
|
//circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
@@ -131,7 +131,6 @@ export class Logic {
|
|
|
131
131
|
gl;
|
|
132
132
|
_lastMode;
|
|
133
133
|
_lastEdgeCount;
|
|
134
|
-
_lastAlphaMultiplier;
|
|
135
134
|
program;
|
|
136
135
|
_edgeCountLocation;
|
|
137
136
|
_draw_modeLocation;
|
|
@@ -144,7 +143,6 @@ export class Logic {
|
|
|
144
143
|
this.gl = globe.gl;
|
|
145
144
|
this._lastMode = 0;
|
|
146
145
|
this._lastEdgeCount = 64;
|
|
147
|
-
this._lastAlphaMultiplier = 1.0;
|
|
148
146
|
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
149
147
|
const { gl, program } = this;
|
|
150
148
|
// set attributes locations
|
|
@@ -174,7 +172,7 @@ export class Logic {
|
|
|
174
172
|
this._defaultFlexibleUBO = flexibleBlockManager.createUBO(gl);
|
|
175
173
|
gl.useProgram(currentProgram);
|
|
176
174
|
}
|
|
177
|
-
draw(length,
|
|
175
|
+
draw(length, attributeLoader, edgeCount, drawMode, ubo = null) {
|
|
178
176
|
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
179
177
|
gl.useProgram(program);
|
|
180
178
|
if (drawModeMap[drawMode] !== this._lastMode) {
|
|
@@ -193,10 +191,10 @@ export class Logic {
|
|
|
193
191
|
}
|
|
194
192
|
const overdraw = drawModeMap[drawMode];
|
|
195
193
|
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
196
|
-
|
|
194
|
+
attributeLoader.bind();
|
|
197
195
|
gl.drawArraysInstanced(gl[drawMode], 0, edgeCount + overdraw, length);
|
|
198
196
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
199
|
-
|
|
197
|
+
attributeLoader.unbind();
|
|
200
198
|
if (ubo) {
|
|
201
199
|
ubo.unbind();
|
|
202
200
|
}
|
|
@@ -219,22 +217,18 @@ export class Logic {
|
|
|
219
217
|
in float radius; // in meter
|
|
220
218
|
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
221
219
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
attributeLoader(gl, colorModeObj, 8, 1, { divisor: 1, escapeValues: [-1.0] });
|
|
235
|
-
gl.bindVertexArray(null);
|
|
236
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
237
|
-
return vao;
|
|
220
|
+
createAttributeLoader(center2dObj, center3dObj, startAngle2DObj, tailAngle2DObj, startAngle3DObj, tailAngle3DObj, colorObj, radiusObj, colorModeObj) {
|
|
221
|
+
return new AttributeLoader(this.gl, [
|
|
222
|
+
{ bufferAndReadInfo: center2dObj, index: 0, size: 2, options: { divisor: 1 } },
|
|
223
|
+
{ bufferAndReadInfo: center3dObj, index: 1, size: 3, options: { divisor: 1 } },
|
|
224
|
+
{ bufferAndReadInfo: startAngle2DObj, index: 2, size: 1, options: { divisor: 1 } },
|
|
225
|
+
{ bufferAndReadInfo: tailAngle2DObj, index: 3, size: 1, options: { divisor: 1 } },
|
|
226
|
+
{ bufferAndReadInfo: startAngle3DObj, index: 4, size: 1, options: { divisor: 1 } },
|
|
227
|
+
{ bufferAndReadInfo: tailAngle3DObj, index: 5, size: 1, options: { divisor: 1 } },
|
|
228
|
+
{ bufferAndReadInfo: colorObj, index: 6, size: 4, options: { divisor: 1, escapeValues: [-1.0, -1.0, -1.0, -1.0] } },
|
|
229
|
+
{ bufferAndReadInfo: radiusObj, index: 7, size: 1, options: { divisor: 1, escapeValues: [-1.0] } },
|
|
230
|
+
{ bufferAndReadInfo: colorModeObj, index: 8, size: 1, options: { divisor: 1, escapeValues: [-1.0] } }
|
|
231
|
+
]);
|
|
238
232
|
}
|
|
239
233
|
createUBO() {
|
|
240
234
|
const { gl } = this;
|
|
@@ -8,7 +8,7 @@ export class LinePlugin {
|
|
|
8
8
|
globe = null;
|
|
9
9
|
gl = null;
|
|
10
10
|
program = null;
|
|
11
|
-
|
|
11
|
+
attributeLoader = null;
|
|
12
12
|
_options;
|
|
13
13
|
_uboHandler = null;
|
|
14
14
|
bufferOrchestrator;
|
|
@@ -36,21 +36,24 @@ export class LinePlugin {
|
|
|
36
36
|
this._uboHandler = this.program.createUBO();
|
|
37
37
|
this.setDefaultColor(this._options.defaultColor);
|
|
38
38
|
this._fillManagerMap();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
if (this.program.createAttributeLoader) {
|
|
40
|
+
const data = this._createSelectBufferNames().map((key) => {
|
|
41
|
+
if (key === null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const bufferManagerComp = this.bufferManagersMap.get(key);
|
|
45
|
+
if (bufferManagerComp === undefined) {
|
|
46
|
+
throw new Error(`Buffer key ${key} does not exist in bufferManagersMap`);
|
|
47
|
+
}
|
|
48
|
+
const { bufferManager } = bufferManagerComp;
|
|
49
|
+
return {
|
|
50
|
+
stride: 0,
|
|
51
|
+
offset: 0,
|
|
52
|
+
buffer: bufferManager.buffer
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
this.attributeLoader = this.program.createAttributeLoader(...data);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
// PLUGIN INTERFACE METHODS
|
|
56
59
|
increaseSpace(amount) {
|
|
@@ -122,10 +125,10 @@ export class LinePlugin {
|
|
|
122
125
|
console.warn("Plugin has been freed, cannot draw.");
|
|
123
126
|
}
|
|
124
127
|
;
|
|
125
|
-
if (!this.globe || !this.gl || !this.program || !this.
|
|
128
|
+
if (!this.globe || !this.gl || !this.program || !this.attributeLoader) {
|
|
126
129
|
throw new Error("Globe, GL context or program is not initialized.");
|
|
127
130
|
}
|
|
128
|
-
const { bufferOrchestrator, _options, _uboHandler,
|
|
131
|
+
const { bufferOrchestrator, _options, _uboHandler, attributeLoader } = this;
|
|
129
132
|
if (!bufferOrchestrator || !bufferOrchestrator || !_uboHandler) {
|
|
130
133
|
throw new Error("Buffer orchestrator is not initialized.");
|
|
131
134
|
}
|
|
@@ -140,18 +143,18 @@ export class LinePlugin {
|
|
|
140
143
|
const currentGeometry = this.globe.api_GetCurrentGeometry();
|
|
141
144
|
if (currentGeometry === 0 && globeViewOn) {
|
|
142
145
|
// @ts-ignore
|
|
143
|
-
this.program.draw(
|
|
146
|
+
this.program.draw(attributeLoader, drawOptions, opacity, _uboHandler);
|
|
144
147
|
}
|
|
145
148
|
else if (currentGeometry === 1 && flatViewOn) {
|
|
146
149
|
// @ts-ignore
|
|
147
|
-
this.program.draw(
|
|
150
|
+
this.program.draw(attributeLoader, drawOptions, opacity, _uboHandler);
|
|
148
151
|
}
|
|
149
152
|
this.gl.enable(this.gl.DEPTH_TEST); // Re-enable depth test after drawing
|
|
150
153
|
}
|
|
151
154
|
free() {
|
|
152
155
|
if (this._freed)
|
|
153
156
|
return;
|
|
154
|
-
|
|
157
|
+
this.attributeLoader.free();
|
|
155
158
|
this.bufferManagersMap.forEach((manager) => {
|
|
156
159
|
manager.bufferManager.free();
|
|
157
160
|
});
|
|
@@ -11,7 +11,7 @@ export class PieceOfPiePlugin {
|
|
|
11
11
|
globe = null;
|
|
12
12
|
gl = null;
|
|
13
13
|
program = null;
|
|
14
|
-
|
|
14
|
+
attributeLoader = null;
|
|
15
15
|
bufferManagersMap = null;
|
|
16
16
|
bufferOrchestrator = new BufferOrchestrator({ capacity: INITIAL_CAPACITY });
|
|
17
17
|
drawMode = "BOTH";
|
|
@@ -144,7 +144,7 @@ export class PieceOfPiePlugin {
|
|
|
144
144
|
this.gl = gl;
|
|
145
145
|
this.program = PieceOfPieProgramCache.get(globe);
|
|
146
146
|
this._createBufferManagersMap();
|
|
147
|
-
this.
|
|
147
|
+
this.attributeLoader = this.program.createAttributeLoader(
|
|
148
148
|
//@ts-ignore
|
|
149
149
|
...['centerCoords2d',
|
|
150
150
|
'centerCoords3d',
|
|
@@ -170,18 +170,18 @@ export class PieceOfPiePlugin {
|
|
|
170
170
|
this._uboHandler.updateSingle("u_opacity", new Float32Array([this._pluginOptions.opacity ?? 1.0])); // Default opacity is 1.0
|
|
171
171
|
}
|
|
172
172
|
draw3D() {
|
|
173
|
-
if (!this.gl || !this.program || !this.
|
|
173
|
+
if (!this.gl || !this.program || !this.attributeLoader || !this.globe) {
|
|
174
174
|
console.warn("PieChartPlugin is not initialized properly Or unregistered from globe.");
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
const length = this.bufferOrchestrator.length;
|
|
178
178
|
this.gl.disable(this.gl.DEPTH_TEST);
|
|
179
179
|
if (this.drawMode === "BOTH") {
|
|
180
|
-
this.program?.draw(length, this.
|
|
181
|
-
this.program?.draw(length, this.
|
|
180
|
+
this.program?.draw(length, this.attributeLoader, EDGE_COUNT, "LINE_STRIP", this._uboHandler);
|
|
181
|
+
this.program?.draw(length, this.attributeLoader, EDGE_COUNT, "TRIANGLE_FAN", this._uboHandler);
|
|
182
182
|
}
|
|
183
183
|
else {
|
|
184
|
-
this.program?.draw(length, this.
|
|
184
|
+
this.program?.draw(length, this.attributeLoader, EDGE_COUNT, this.drawMode, this._uboHandler);
|
|
185
185
|
}
|
|
186
186
|
this.gl.enable(this.gl.DEPTH_TEST);
|
|
187
187
|
}
|
|
@@ -191,7 +191,7 @@ export class PieceOfPiePlugin {
|
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
PieceOfPieProgramCache.release(this.globe);
|
|
194
|
-
this.
|
|
194
|
+
this.attributeLoader?.free();
|
|
195
195
|
this._isFreed = true;
|
|
196
196
|
this.globe = null;
|
|
197
197
|
this.gl = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import { ArcOnTerrainPluginOptions } from "./type";
|
|
2
2
|
import { LineStripProgramCache } from "../../programs/line-on-globe/linestrip/linestrip";
|
|
3
|
-
import {
|
|
3
|
+
import { AttributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
4
4
|
import { BufferManager, BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/index";
|
|
5
5
|
import { globe3Dcoordinates, globe2Dcoordinates, RADIAN } from "../../Math/methods";
|
|
6
6
|
import { generateArcPoints, evenlySpacedArcPoints } from "../../Math/arc-cdf-points";
|
|
@@ -25,11 +25,11 @@ function createArc(start, end) {
|
|
|
25
25
|
export class ArcOnTerrainPlugin {
|
|
26
26
|
id;
|
|
27
27
|
program = null;
|
|
28
|
-
bufferManagersMap =
|
|
28
|
+
bufferManagersMap = new Map();
|
|
29
29
|
bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
|
|
30
30
|
_opacity = 1;
|
|
31
31
|
_arcUBOHandler = null;
|
|
32
|
-
|
|
32
|
+
_attributeLoader = null;
|
|
33
33
|
globe = null;
|
|
34
34
|
gl = null;
|
|
35
35
|
_arcMap;
|
|
@@ -226,11 +226,11 @@ export class ArcOnTerrainPlugin {
|
|
|
226
226
|
this.__buildDynamicArcs();
|
|
227
227
|
});
|
|
228
228
|
this.program = LineStripProgramCache.get(globe);
|
|
229
|
+
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
230
|
+
this._fillbufferManagersMap();
|
|
229
231
|
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD, () => {
|
|
230
232
|
this.__buildStaticArcs();
|
|
231
233
|
}); // Initialize static-dynamic strategy with a transition level of 8
|
|
232
|
-
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
233
|
-
this._fillbufferManagersMap();
|
|
234
234
|
this.bufferOrchestrator = new BufferOrchestrator();
|
|
235
235
|
this._arcUBOHandler = this.program.createUBO();
|
|
236
236
|
this._arcUBOHandler.update(new Map([
|
|
@@ -245,12 +245,9 @@ export class ArcOnTerrainPlugin {
|
|
|
245
245
|
}
|
|
246
246
|
const globe = this.globe;
|
|
247
247
|
this._staticDynamicStrategy?.updateState();
|
|
248
|
-
// if (globe.api_IsScreenMoving()) {
|
|
249
|
-
// this._buildArcs(); // can be async
|
|
250
|
-
// }
|
|
251
248
|
this._frameCounterTrigger?.trigger();
|
|
252
|
-
const { gl, program, bufferOrchestrator,
|
|
253
|
-
if (!gl || !program || !bufferOrchestrator || !
|
|
249
|
+
const { gl, program, bufferOrchestrator, _attributeLoader, _arcUBOHandler, } = this;
|
|
250
|
+
if (!gl || !program || !bufferOrchestrator || !_attributeLoader || !_arcUBOHandler) {
|
|
254
251
|
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
255
252
|
return;
|
|
256
253
|
}
|
|
@@ -265,7 +262,7 @@ export class ArcOnTerrainPlugin {
|
|
|
265
262
|
},
|
|
266
263
|
indexes: null
|
|
267
264
|
};
|
|
268
|
-
program.draw(
|
|
265
|
+
program.draw(_attributeLoader, drawOptions, this._opacity, _arcUBOHandler);
|
|
269
266
|
gl.enable(gl.DEPTH_TEST);
|
|
270
267
|
}
|
|
271
268
|
_buildArcs(subSetIDs = null) {
|
|
@@ -280,7 +277,7 @@ export class ArcOnTerrainPlugin {
|
|
|
280
277
|
__buildStaticArcs(subSetIDs = null) {
|
|
281
278
|
const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap, bufferOrchestrator } = this;
|
|
282
279
|
if (!globe || !_cameraUniformBlock || !bufferManagersMap || !bufferOrchestrator) {
|
|
283
|
-
console.warn(
|
|
280
|
+
console.warn(`Globe or camera uniform block is not initialized. ${globe} ${_cameraUniformBlock} ${bufferManagersMap} ${bufferOrchestrator}`);
|
|
284
281
|
return;
|
|
285
282
|
}
|
|
286
283
|
const bufferKey = [this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"];
|
|
@@ -321,7 +318,7 @@ export class ArcOnTerrainPlugin {
|
|
|
321
318
|
__buildDynamicArcs(subSetIDs = null) {
|
|
322
319
|
const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap } = this;
|
|
323
320
|
if (!globe || !_cameraUniformBlock || !bufferManagersMap) {
|
|
324
|
-
console.warn(
|
|
321
|
+
console.warn(`Globe or camera uniform block is not initialized. ${globe} ${_cameraUniformBlock} ${bufferManagersMap}`);
|
|
325
322
|
return;
|
|
326
323
|
}
|
|
327
324
|
const bufferKey = [
|
|
@@ -392,7 +389,6 @@ export class ArcOnTerrainPlugin {
|
|
|
392
389
|
}
|
|
393
390
|
const g2D = globe2Dcoordinates(globe);
|
|
394
391
|
const { flatViewOn, globeViewOn, variativeColorsOn } = this._options;
|
|
395
|
-
this.bufferManagersMap = new Map();
|
|
396
392
|
if (globeViewOn) {
|
|
397
393
|
this.bufferManagersMap.set("position3d", {
|
|
398
394
|
bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
@@ -441,10 +437,10 @@ export class ArcOnTerrainPlugin {
|
|
|
441
437
|
// @ts-ignore
|
|
442
438
|
const bufferManager = this.bufferManagersMap.get(key).bufferManager;
|
|
443
439
|
// @ts-ignore
|
|
444
|
-
return createBufferAndReadInfo(bufferManager.buffer);
|
|
440
|
+
return AttributeLoader.createBufferAndReadInfo(bufferManager.buffer);
|
|
445
441
|
});
|
|
446
442
|
// @ts-ignore
|
|
447
|
-
this.
|
|
443
|
+
this._attributeLoader = this.program?.createAttributeLoader(bufferObjects[0], // position3d
|
|
448
444
|
bufferObjects[1], // position2d
|
|
449
445
|
bufferObjects[2] // color
|
|
450
446
|
);
|
|
@@ -474,6 +470,7 @@ export class ArcOnTerrainPlugin {
|
|
|
474
470
|
CameraUniformBlockTotemCache.release(this.globe);
|
|
475
471
|
LineStripProgramCache.release(this.globe);
|
|
476
472
|
this.gl = null;
|
|
473
|
+
this.program = null;
|
|
477
474
|
this.globe = null;
|
|
478
475
|
this._arcMap.clear();
|
|
479
476
|
this._coordinaateBufferKeysForUpdate = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LineStripProgramCache } from "../../programs/line-on-globe/linestrip/linestrip";
|
|
2
2
|
import { BufferManager, BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/index";
|
|
3
3
|
import { CameraUniformBlockTotemCache } from "../../programs/totems/camerauniformblock";
|
|
4
|
-
import {
|
|
4
|
+
import { AttributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
5
5
|
import * as CircleMethods from "../../Math/circle";
|
|
6
6
|
import * as CircleCDF from "../../Math/circle-cdf-points";
|
|
7
7
|
import * as vec3 from "../../Math/vec3";
|
|
@@ -66,7 +66,7 @@ export class CircleOnTerrainPlugin {
|
|
|
66
66
|
_freed = false;
|
|
67
67
|
_circleUBOHandler = null;
|
|
68
68
|
_opacity = 1;
|
|
69
|
-
|
|
69
|
+
_attributeLoader = null;
|
|
70
70
|
_dobuild = true; // This is used to trigger the build of circles when the camera position changes.
|
|
71
71
|
_frameCounterTrigger = null;
|
|
72
72
|
_staticDynamicStrategy = null;
|
|
@@ -76,7 +76,6 @@ export class CircleOnTerrainPlugin {
|
|
|
76
76
|
defaultHeightFromGroundIn3D: 30.0,
|
|
77
77
|
isMSL: false
|
|
78
78
|
};
|
|
79
|
-
_textDataPreAdaptor = undefined;
|
|
80
79
|
constructor(id, styleOptions = null) {
|
|
81
80
|
this.id = id;
|
|
82
81
|
if (styleOptions) {
|
|
@@ -125,8 +124,8 @@ export class CircleOnTerrainPlugin {
|
|
|
125
124
|
}
|
|
126
125
|
});
|
|
127
126
|
}
|
|
128
|
-
this.
|
|
129
|
-
createBufferAndReadInfo(this.bufferManagersMap.get("color")?.bufferManager.buffer) : null);
|
|
127
|
+
this._attributeLoader = this.lineProgram.createAttributeLoader(AttributeLoader.createBufferAndReadInfo(this.bufferManagersMap.get("position3d")?.bufferManager.buffer), AttributeLoader.createBufferAndReadInfo(this.bufferManagersMap.get("position2d")?.bufferManager.buffer), this._options.variativeColorsOn ?
|
|
128
|
+
AttributeLoader.createBufferAndReadInfo(this.bufferManagersMap.get("color")?.bufferManager.buffer) : null);
|
|
130
129
|
this._circleUBOHandler = this.lineProgram.createUBO();
|
|
131
130
|
this.setDefaultColor(this._options.defaultColor);
|
|
132
131
|
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
@@ -158,7 +157,7 @@ export class CircleOnTerrainPlugin {
|
|
|
158
157
|
if (this._freed)
|
|
159
158
|
return;
|
|
160
159
|
if (!this.globe || !this.gl || !this.lineProgram || !this.bufferOrchestrator ||
|
|
161
|
-
!this.bufferManagersMap || !this.
|
|
160
|
+
!this.bufferManagersMap || !this._attributeLoader || !this._circleUBOHandler) {
|
|
162
161
|
throw new Error("Plugin not initialized properly");
|
|
163
162
|
}
|
|
164
163
|
const keys = [];
|
|
@@ -217,7 +216,7 @@ export class CircleOnTerrainPlugin {
|
|
|
217
216
|
if (this._freed)
|
|
218
217
|
return;
|
|
219
218
|
if (!this.globe || !this.gl || !this.lineProgram || !this.bufferOrchestrator ||
|
|
220
|
-
!this.bufferManagersMap || !this.
|
|
219
|
+
!this.bufferManagersMap || !this._attributeLoader || !this._circleUBOHandler) {
|
|
221
220
|
throw new Error("Plugin not initialized properly");
|
|
222
221
|
}
|
|
223
222
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
|
|
@@ -408,9 +407,9 @@ export class CircleOnTerrainPlugin {
|
|
|
408
407
|
}
|
|
409
408
|
// GLOBE API INTERFACE
|
|
410
409
|
draw3D() {
|
|
411
|
-
const { _freed, globe, gl, lineProgram, bufferOrchestrator, bufferManagersMap,
|
|
410
|
+
const { _freed, globe, gl, lineProgram, bufferOrchestrator, bufferManagersMap, _attributeLoader, _circleUBOHandler } = this;
|
|
412
411
|
if (_freed || !globe || !gl || !lineProgram || !bufferOrchestrator ||
|
|
413
|
-
!bufferManagersMap || !
|
|
412
|
+
!bufferManagersMap || !_circleUBOHandler) {
|
|
414
413
|
return;
|
|
415
414
|
}
|
|
416
415
|
// if (globe.api_IsScreenMoving())
|
|
@@ -423,7 +422,7 @@ export class CircleOnTerrainPlugin {
|
|
|
423
422
|
},
|
|
424
423
|
};
|
|
425
424
|
gl.disable(gl.DEPTH_TEST);
|
|
426
|
-
lineProgram.draw(
|
|
425
|
+
lineProgram.draw(_attributeLoader, drawOptions, this._opacity, _circleUBOHandler);
|
|
427
426
|
gl.enable(gl.DEPTH_TEST);
|
|
428
427
|
}
|
|
429
428
|
free() {
|
|
@@ -29,7 +29,7 @@ export class Padding1DegreePlugin {
|
|
|
29
29
|
_float32Array = null; // this is used to forward the data to the buffer manager
|
|
30
30
|
_uboHandler = null; // this is used to forward the data to the shader program
|
|
31
31
|
_bufferNames = ["position2d", "position3d"];
|
|
32
|
-
|
|
32
|
+
_attributeLoader = null; // this is used to store the VAO for the plugin
|
|
33
33
|
_freed = false; // this is used to check if the plugin is freed or not
|
|
34
34
|
_userOpacity = 1;
|
|
35
35
|
_adaptiveOpacityMultiplier = 1;
|
|
@@ -347,7 +347,7 @@ export class Padding1DegreePlugin {
|
|
|
347
347
|
offset: 0
|
|
348
348
|
};
|
|
349
349
|
});
|
|
350
|
-
this.
|
|
350
|
+
this._attributeLoader = this.lineProgram.createAttributeLoader(vaoInput[0], vaoInput[1], vaoInput[2]);
|
|
351
351
|
this.bufferManagerMap = bufferManagerMap;
|
|
352
352
|
this.bufferOrchestrator.resetWithCapacity(bufferManagerMap, initialCapacity);
|
|
353
353
|
this._uboHandler = this.lineProgram.createUBO("STATIC_DRAW");
|
|
@@ -358,7 +358,7 @@ export class Padding1DegreePlugin {
|
|
|
358
358
|
console.warn("Plugin is freed, cannot draw");
|
|
359
359
|
return;
|
|
360
360
|
}
|
|
361
|
-
if (this.globe === null || this.lineProgram === null || this.
|
|
361
|
+
if (this.globe === null || this.lineProgram === null || this._attributeLoader === null) {
|
|
362
362
|
console.warn("Globe or LineProgram or VAO is not initialized, cannot draw");
|
|
363
363
|
return;
|
|
364
364
|
}
|
|
@@ -372,7 +372,7 @@ export class Padding1DegreePlugin {
|
|
|
372
372
|
},
|
|
373
373
|
};
|
|
374
374
|
gl.disable(gl.DEPTH_TEST);
|
|
375
|
-
this.lineProgram.draw(this.
|
|
375
|
+
this.lineProgram.draw(this._attributeLoader, drawOptions, this._userOpacity * this._adaptiveOpacityMultiplier, this._uboHandler);
|
|
376
376
|
gl.enable(gl.DEPTH_TEST);
|
|
377
377
|
}
|
|
378
378
|
free() {
|
|
@@ -390,9 +390,8 @@ export class Padding1DegreePlugin {
|
|
|
390
390
|
this.lineProgram = null;
|
|
391
391
|
this._uboHandler?.free();
|
|
392
392
|
this._uboHandler = null;
|
|
393
|
-
this.
|
|
393
|
+
this._attributeLoader?.free();
|
|
394
394
|
this.globe = null;
|
|
395
|
-
this._vao = null;
|
|
396
395
|
this.bufferManagerMap.forEach((bufferManager) => {
|
|
397
396
|
bufferManager.bufferManager.free();
|
|
398
397
|
});
|
|
@@ -12,12 +12,13 @@ export class IndexPolygonMap {
|
|
|
12
12
|
}
|
|
13
13
|
insertBulk(polygons) {
|
|
14
14
|
for (const poly of polygons) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
15
|
+
// Upsert semantics:
|
|
16
|
+
// - if the key already exists, keep its index stable
|
|
17
|
+
// - otherwise allocate a new index
|
|
18
|
+
const existingIndex = this._polygonKeyMap.get(poly.key);
|
|
19
|
+
const index = existingIndex ?? this.newIndex();
|
|
19
20
|
// @ts-ignore
|
|
20
|
-
poly.index = index; // Assign the
|
|
21
|
+
poly.index = index; // Assign the (stable) index to the polygon
|
|
21
22
|
this._indexPolygonMap.set(index, poly);
|
|
22
23
|
this._polygonKeyMap.set(poly.key, index);
|
|
23
24
|
}
|
|
@@ -14,7 +14,6 @@ let _batchInFlight = false;
|
|
|
14
14
|
let _batchPending = 0;
|
|
15
15
|
function initWorkers() {
|
|
16
16
|
_maxWorkers = Math.max(1, ((navigator.hardwareConcurrency - 2) || 4) - 1);
|
|
17
|
-
console.log(`TerrainPolygon: initializing ${_maxWorkers} workers.`);
|
|
18
17
|
for (let i = 0; i < _maxWorkers; i++)
|
|
19
18
|
addWorker();
|
|
20
19
|
}
|
|
@@ -52,18 +52,6 @@ const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, d
|
|
|
52
52
|
gl.vertexAttribDivisor(index, divisor);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {WebGLBuffer} buffer
|
|
58
|
-
* @param {number} stride
|
|
59
|
-
* @param {number} offset
|
|
60
|
-
* @returns {BufferAndReadInfo}
|
|
61
|
-
*/
|
|
62
|
-
const createBufferAndReadInfo = (buffer, stride = 0, offset = 0) => {
|
|
63
|
-
if (buffer == null)
|
|
64
|
-
return null;
|
|
65
|
-
return { buffer, stride, offset };
|
|
66
|
-
};
|
|
67
55
|
const setConstantAttribute = (gl, index, size, values, typeInfo) => {
|
|
68
56
|
// Array should already be disabled by caller
|
|
69
57
|
if (size < 1 || size > 4) {
|
|
@@ -96,9 +84,6 @@ const setConstantAttribute = (gl, index, size, values, typeInfo) => {
|
|
|
96
84
|
function resetAttributeDefault(gl, index) {
|
|
97
85
|
gl.vertexAttrib4f(index, 0, 0, 0, 1);
|
|
98
86
|
}
|
|
99
|
-
function setDefaultAttributeValues(gl, index, size, escapeValues, typeInfo) {
|
|
100
|
-
setConstantAttribute(gl, index, size, escapeValues, DATA_TYPE_MAP[typeInfo]);
|
|
101
|
-
}
|
|
102
87
|
export class AttributeLoader {
|
|
103
88
|
gl;
|
|
104
89
|
meta;
|
|
@@ -119,7 +104,7 @@ export class AttributeLoader {
|
|
|
119
104
|
this.stickyNotes.set(index, { size, typeInfo, escapeValues: options.escapeValues });
|
|
120
105
|
}
|
|
121
106
|
else {
|
|
122
|
-
throw new Error("
|
|
107
|
+
throw new Error("Either bufferAndReadInfo or escapeValues must be provided for AttributeLoader.");
|
|
123
108
|
}
|
|
124
109
|
}
|
|
125
110
|
gl.bindVertexArray(null);
|
|
@@ -140,5 +125,9 @@ export class AttributeLoader {
|
|
|
140
125
|
free() {
|
|
141
126
|
this.gl.deleteVertexArray(this.vao);
|
|
142
127
|
}
|
|
128
|
+
static createBufferAndReadInfo(buffer, stride = 0, offset = 0) {
|
|
129
|
+
if (buffer == null)
|
|
130
|
+
return null;
|
|
131
|
+
return { buffer, stride, offset };
|
|
132
|
+
}
|
|
143
133
|
}
|
|
144
|
-
export { attributeLoader, createBufferAndReadInfo, resetAttributeDefault, setDefaultAttributeValues };
|