@pirireis/webglobeplugins 0.5.11 → 0.6.0
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/circle-line-chain/chain-list-map.js +2 -2
- package/compass-rose/compass-rose-padding-flat.js +182 -0
- package/compass-rose/compass-text-writer.js +120 -0
- package/package.json +1 -1
- package/programs/totems/camerauniformblock.js +19 -4
- package/programs/two-d/pixel-padding-for-compass.js +47 -25
- package/util/account/bufferoffsetmanager.js +1 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -2
- package/compass-rose/compass-rose-flat.js +0 -76
|
@@ -101,11 +101,11 @@ export class ChainListMap {
|
|
|
101
101
|
const index = this.getIndexOfNode(chainKey, node.key)
|
|
102
102
|
const chainNode = this._chainMap.get(chainKey)[index];
|
|
103
103
|
if (node.circleProperties) {
|
|
104
|
-
if (chainNode.circleProperties
|
|
104
|
+
if (typeof chainNode.circleProperties !== 'object') chainNode.circleProperties = {}
|
|
105
105
|
node.circleProperties.forEach((value, key, container) => chainNode.circleProperties[key] = value);
|
|
106
106
|
}
|
|
107
107
|
if (node.lineProperties) {
|
|
108
|
-
if (chainNode.lineProperties
|
|
108
|
+
if (typeof chainNode.lineProperties !== 'object') chainNode.lineProperties = {}
|
|
109
109
|
node.lineProperties.forEach((value, key, container) => chainNode.lineProperties[key] = value);
|
|
110
110
|
}
|
|
111
111
|
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { PixelPaddingForFlatCompassCache } from "../programs/two-d/pixel-padding-for-compass";
|
|
2
|
+
import { BufferManager, BufferOrchestrator } from "../util/account";
|
|
3
|
+
// import { ContextTextWriter2 } from "../write-text/context-text2";
|
|
4
|
+
import { ContextTextWriter2Offsets } from "./compass-text-writer"
|
|
5
|
+
|
|
6
|
+
const PaddingAngle = 30;
|
|
7
|
+
|
|
8
|
+
export class PixelPaddingCompassPlugin {
|
|
9
|
+
constructor(id, {
|
|
10
|
+
opacity = 1,
|
|
11
|
+
textAngle = true,
|
|
12
|
+
defaultProperties = {
|
|
13
|
+
rgba: [1, 1, 1, 1],
|
|
14
|
+
pixelRadiusBig: 350,
|
|
15
|
+
pixelRadiusSmall: 270
|
|
16
|
+
}
|
|
17
|
+
} = {}) {
|
|
18
|
+
this.id = id;
|
|
19
|
+
this.textWriters = null
|
|
20
|
+
this.textAngle = textAngle
|
|
21
|
+
this.defaultProperties = defaultProperties
|
|
22
|
+
this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
|
|
23
|
+
|
|
24
|
+
this.compassMap = new CompassMap(this);
|
|
25
|
+
this._opacity = opacity;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
init(globe, gl) {
|
|
29
|
+
this.globe = globe;
|
|
30
|
+
this.gl = gl;
|
|
31
|
+
if (this.textAngle) {
|
|
32
|
+
this._createTextWriter();
|
|
33
|
+
}
|
|
34
|
+
this._initOrchestrations()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
insert(key, long, lat, properties = null) {
|
|
38
|
+
this.__insertText(key, null, null, properties);
|
|
39
|
+
this.compassMap.insert(key, long, lat, properties);
|
|
40
|
+
this.globe.DrawRender();
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
delete(key) {
|
|
46
|
+
this.compassMap.delete(key);
|
|
47
|
+
this.globe.DrawRender();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
setTextStyle(textStyle) {
|
|
53
|
+
this.writer.setStyle(textStyle);
|
|
54
|
+
this.globe.DrawRender();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setOpacity(opacity) {
|
|
58
|
+
this._opacity = opacity;
|
|
59
|
+
this.globe.DrawRender();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_initOrchestrations() {
|
|
63
|
+
const { gl, globe } = this;
|
|
64
|
+
this.paddingProgram = PixelPaddingForFlatCompassCache.get(globe);
|
|
65
|
+
{
|
|
66
|
+
// createBuffers
|
|
67
|
+
const bufferType = "DYNAMIC_DRAW";
|
|
68
|
+
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
69
|
+
this.bufferManagersCompMap = new Map(
|
|
70
|
+
[
|
|
71
|
+
["screenCoordinates", {
|
|
72
|
+
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
73
|
+
'adaptor': (item) => new Float32Array([item.x, item.y])
|
|
74
|
+
}],
|
|
75
|
+
["pixelRadiusSmall", {
|
|
76
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
77
|
+
'adaptor': (item) => new Float32Array([item.properties.pixelRadiusSmall])
|
|
78
|
+
}],
|
|
79
|
+
["pixelRadiusBig", {
|
|
80
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
81
|
+
'adaptor': (item) => new Float32Array([item.properties.pixelRadiusBig])
|
|
82
|
+
}],
|
|
83
|
+
["rgba", {
|
|
84
|
+
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
85
|
+
'adaptor': (item) => new Float32Array(item.properties.rgba)
|
|
86
|
+
}],
|
|
87
|
+
]
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const obj = function (bufferManagerComp) {
|
|
91
|
+
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
|
|
92
|
+
};
|
|
93
|
+
this.paddingVao = this.paddingProgram.createVAO(
|
|
94
|
+
...['screenCoordinates', 'pixelRadiusSmall', 'pixelRadiusBig', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_createTextWriter() {
|
|
99
|
+
this.writer = new ContextTextWriter2Offsets(this.globe, { angle: PaddingAngle });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
__insertText(key, x, y, properties) {
|
|
103
|
+
if (!this.writer) return;
|
|
104
|
+
let radius;
|
|
105
|
+
if (properties != null && properties.pixelRadiusBig) {
|
|
106
|
+
radius = properties.pixelRadiusBig
|
|
107
|
+
} else {
|
|
108
|
+
radius = this.defaultProperties.pixelRadiusBig;
|
|
109
|
+
}
|
|
110
|
+
this.writer.insertTextItem(key, x, y, radius);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Globe API interface methods
|
|
114
|
+
|
|
115
|
+
draw2D() {
|
|
116
|
+
const { gl, globe, paddingProgram, paddingVao, bufferOrchestrator, bufferManagersCompMap } = this;
|
|
117
|
+
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
118
|
+
if (is3D) return;
|
|
119
|
+
const items = this.compassMap.query(globe, this.writer);
|
|
120
|
+
if (items.length === 0) return;
|
|
121
|
+
bufferOrchestrator.flush();
|
|
122
|
+
bufferOrchestrator.insertBulk(items, bufferManagersCompMap);
|
|
123
|
+
items.forEach((v) => {
|
|
124
|
+
this.__insertText(v.key, v.x, v.y)
|
|
125
|
+
});
|
|
126
|
+
gl.disable(gl.DEPTH_TEST);
|
|
127
|
+
paddingProgram.draw(paddingVao, bufferOrchestrator.length, this._opacity)
|
|
128
|
+
gl.enable(gl.DEPTH_TEST);
|
|
129
|
+
this.writer?.draw();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
free() {
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class CompassMap {
|
|
141
|
+
constructor(parent) {
|
|
142
|
+
this.coordsMemory = new Map();
|
|
143
|
+
this.propertyMemory = new Map();
|
|
144
|
+
this.parent = parent;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
insert(key, long, lat, properties = null) {
|
|
148
|
+
this.coordsMemory.set(key, [long, lat]);
|
|
149
|
+
if (properties) this.propertyMemory.set(key, properties);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
delete(key) {
|
|
153
|
+
this.coordsMemory.delete(key);
|
|
154
|
+
this.propertyMemory.delete(key);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
query(globe, writer) {
|
|
158
|
+
const { coordsMemory, propertyMemory } = this;
|
|
159
|
+
const defaultProperties = this.parent.defaultProperties;
|
|
160
|
+
const result = [];
|
|
161
|
+
coordsMemory.forEach((v, k, c) => {
|
|
162
|
+
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
163
|
+
{
|
|
164
|
+
long: v[0],
|
|
165
|
+
lat: v[1],
|
|
166
|
+
z: 0,
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
);
|
|
170
|
+
writer?.insertTextItem(k, x, y);
|
|
171
|
+
|
|
172
|
+
if (x !== null) {
|
|
173
|
+
const properties = { ...defaultProperties, ...propertyMemory.get(k) };
|
|
174
|
+
result.push({ key: k, x, y, properties })
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function isOnTheScreen(globe, points) { }
|
|
182
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { CSZMode } from "@pirireis/webglobe";
|
|
2
|
+
|
|
3
|
+
const defaultStyle = {
|
|
4
|
+
textFont: {
|
|
5
|
+
name: 'Arial',
|
|
6
|
+
textColor: '#FFFFFF', // beyaz
|
|
7
|
+
hollowColor: '#000000', // siyah
|
|
8
|
+
size: 12, // piksel
|
|
9
|
+
hollow: true,
|
|
10
|
+
bold: true,
|
|
11
|
+
italic: false,
|
|
12
|
+
},
|
|
13
|
+
opacity: 1.0,
|
|
14
|
+
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* TODOs:
|
|
19
|
+
* 1) update all if initials change (propably need a context and a callback to iterate over data)
|
|
20
|
+
* 2) expose a mechanic to update text on zoom change
|
|
21
|
+
* 3) extend the mechanic on 2 to other events
|
|
22
|
+
*/
|
|
23
|
+
export class ContextTextWriter2Offsets {
|
|
24
|
+
constructor(globe, { style = null, doDraw = true, angle = 30, } = {}) {
|
|
25
|
+
this.globe = globe;
|
|
26
|
+
this.itemMap = new Map();
|
|
27
|
+
this.style = style || defaultStyle;
|
|
28
|
+
this.doDraw = doDraw;
|
|
29
|
+
this.angle = angle;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setKeyAdaptor(adaptor) {
|
|
35
|
+
this.keyAdaptor = adaptor;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setDoDraw(bool) {
|
|
39
|
+
this.doDraw = bool;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setStyle(style) {
|
|
43
|
+
this.style = style;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setOpacity(opacity) {
|
|
47
|
+
this.style.opacity = opacity;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
draw() {
|
|
53
|
+
if (!this.doDraw) return;
|
|
54
|
+
const { globe, style, itemMap } = this;
|
|
55
|
+
const { textFont, opacity: opacity_ } = style;
|
|
56
|
+
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
57
|
+
if (is3D) return;
|
|
58
|
+
const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn)
|
|
59
|
+
for (const [key, { center, offsets, texts, opacity = null, angles }] of itemMap) {
|
|
60
|
+
const o = opacity === null ? opacity_ : opacity * opacity_;
|
|
61
|
+
if (center.x !== null && center.y !== null) {
|
|
62
|
+
offsets.forEach(({ offsetX, offsetY }, i) => {
|
|
63
|
+
const text = texts[i];
|
|
64
|
+
const angle = angles[i];
|
|
65
|
+
console.log("asdfadsf", text, angle, center, offsetX, offsetY);
|
|
66
|
+
globe.api_DrawContextTextMultiLine(text, textFont, o, { x: center.x + offsetX, y: center.y + offsetY }, angleIsOn, angle);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
insertTextItem(key, x, y, radius) {
|
|
75
|
+
const item = this.getItem(key);
|
|
76
|
+
item.center = { x, y };
|
|
77
|
+
if (item.radius != undefined && item.radius === radius) return;
|
|
78
|
+
item.radius = radius;
|
|
79
|
+
const { offsets, angles, texts } = this.__offsetAngleText(radius);
|
|
80
|
+
item.offsets = offsets;
|
|
81
|
+
item.angles = angles;
|
|
82
|
+
item.texts = texts;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getItem(key) {
|
|
86
|
+
if (!this.itemMap.has(key)) this.itemMap.set(key, {});
|
|
87
|
+
return this.itemMap.get(key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
__calculateOffset(radius, angle) {
|
|
91
|
+
const rAngle = (angle - 90) * (Math.PI / 180);
|
|
92
|
+
return { offsetX: Math.cos(rAngle) * radius, offsetY: Math.sin(rAngle) * radius };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
__offsetAngleText(radius) {
|
|
96
|
+
const angle = this.angle;
|
|
97
|
+
const offsets = []
|
|
98
|
+
const angles = []
|
|
99
|
+
const texts = []
|
|
100
|
+
let currentAngle = 0;
|
|
101
|
+
while (currentAngle < 360) {
|
|
102
|
+
offsets.push(this.__calculateOffset(radius + 10, currentAngle));
|
|
103
|
+
angles.push(currentAngle);
|
|
104
|
+
if (currentAngle == 0) {
|
|
105
|
+
texts.push("K");
|
|
106
|
+
} else {
|
|
107
|
+
texts.push(currentAngle.toString());
|
|
108
|
+
}
|
|
109
|
+
currentAngle += angle;
|
|
110
|
+
}
|
|
111
|
+
return { offsets, angles, texts };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
clear() {
|
|
116
|
+
this.itemMap.clear();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
package/package.json
CHANGED
|
@@ -10,10 +10,14 @@ layout(std140) uniform CameraUniformBlock {
|
|
|
10
10
|
vec2 mapWH; // 8 bytes 144
|
|
11
11
|
vec2 screenWH; // 8 bytes 152
|
|
12
12
|
float z_level; // 4 bytes 160 | 164
|
|
13
|
-
|
|
13
|
+
float world_distance; // 4 bytes 164
|
|
14
|
+
float world_tilt; // 4 bytes 168
|
|
15
|
+
float world_north_angle; // 4 bytes 172
|
|
16
|
+
vec2 world_center_radian; // 8 bytes 176 | 184
|
|
17
|
+
}; // 14 lines
|
|
14
18
|
`;
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
const Radian = Math.PI / 180.0;
|
|
17
21
|
|
|
18
22
|
export default class
|
|
19
23
|
|
|
@@ -44,7 +48,7 @@ export default class
|
|
|
44
48
|
const { gl } = this;
|
|
45
49
|
const ubo = gl.createBuffer();
|
|
46
50
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
47
|
-
gl.bufferData(gl.UNIFORM_BUFFER,
|
|
51
|
+
gl.bufferData(gl.UNIFORM_BUFFER, 184, gl.STREAM_DRAW);
|
|
48
52
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
|
|
49
53
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
50
54
|
return ubo;
|
|
@@ -87,9 +91,20 @@ export default class
|
|
|
87
91
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 144, mapWHFloat32);
|
|
88
92
|
}
|
|
89
93
|
}
|
|
94
|
+
{
|
|
95
|
+
// float world_distance; // 4 bytes 164
|
|
96
|
+
// float world_tilt; // 4 bytes 168
|
|
97
|
+
// float world_north_angle; // 4 bytes 172
|
|
98
|
+
// vec2 world_center_radian; // 8 bytes 180
|
|
99
|
+
const { CenterLong, CenterLat, Distance, Tilt, NorthAng } = globe.api_GetCurrentLookInfo();
|
|
100
|
+
gl.bufferSubData(gl.UNIFORM_BUFFER, 164, new Float32Array([
|
|
101
|
+
Distance, Radian * Tilt, Radian * NorthAng, Radian * CenterLong, Radian * CenterLat
|
|
102
|
+
]));
|
|
103
|
+
|
|
104
|
+
}
|
|
90
105
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
91
|
-
}
|
|
92
106
|
|
|
107
|
+
}
|
|
93
108
|
|
|
94
109
|
getUBO() {
|
|
95
110
|
return this.ubo;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createProgram } from "../../util";
|
|
2
2
|
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
|
|
3
|
-
import {
|
|
3
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
4
|
const vertexCount = 720;
|
|
5
5
|
const vertexShaderSource = `#version 300 es
|
|
6
6
|
${CameraUniformBlockString}
|
|
7
|
+
|
|
7
8
|
in vec2 screen_coordinate;
|
|
8
9
|
in float pixel_radius_small;
|
|
9
10
|
in float pixel_radius_big;
|
|
@@ -11,34 +12,53 @@ in vec4 rgba;
|
|
|
11
12
|
|
|
12
13
|
out vec4 v_rgba;
|
|
13
14
|
|
|
14
|
-
uniform float world_angle_radiance;
|
|
15
15
|
uniform float plugin_opacity;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
vec3 coord_opacity(){
|
|
18
18
|
float radius;
|
|
19
19
|
float angle;
|
|
20
20
|
if( gl_VertexID % 2 == 0){
|
|
21
21
|
if ( gl_VertexID % 60 == 0){
|
|
22
22
|
radius = pixel_radius_small;
|
|
23
|
+
} else if( gl_VertexID % 10 == 0) {
|
|
24
|
+
float gap = (pixel_radius_big - pixel_radius_small) / 4.0;
|
|
25
|
+
radius = pixel_radius_small + gap;
|
|
23
26
|
} else {
|
|
24
|
-
|
|
27
|
+
float gap = (pixel_radius_big - pixel_radius_small) * 0.75;
|
|
28
|
+
radius = pixel_radius_small + gap;
|
|
25
29
|
}
|
|
26
30
|
angle = (float(gl_VertexID) / (${vertexCount}.0));
|
|
27
|
-
|
|
28
31
|
} else {
|
|
29
|
-
|
|
32
|
+
if ( gl_VertexID % 60 == 1){
|
|
33
|
+
radius = pixel_radius_big + 10.0;
|
|
34
|
+
|
|
35
|
+
} else {
|
|
36
|
+
radius = pixel_radius_big;
|
|
37
|
+
}
|
|
30
38
|
angle = (float(gl_VertexID - 1) / (${vertexCount}.0));
|
|
31
39
|
}
|
|
32
|
-
angle
|
|
33
|
-
|
|
40
|
+
float opacity = fract(angle + 0.2475) / 1.5 + 0.33;
|
|
41
|
+
angle = angle * ${Math.PI * 2.0} + world_north_angle;
|
|
42
|
+
|
|
43
|
+
return vec3( screen_coordinate + vec2( cos(angle), sin(angle)) * radius, opacity);
|
|
34
44
|
}
|
|
35
45
|
|
|
46
|
+
vec2 adjust_pos(vec2 pos) {
|
|
47
|
+
return vec2(
|
|
48
|
+
(pos.x / screenWH.x - 0.5) * 2.0,
|
|
49
|
+
(0.5 - pos.y / screenWH.y) * 2.0
|
|
50
|
+
);
|
|
51
|
+
}
|
|
36
52
|
|
|
37
53
|
void main(){
|
|
38
|
-
|
|
39
|
-
gl_Position = vec4(
|
|
54
|
+
vec3 c = coord_opacity();
|
|
55
|
+
gl_Position = vec4( adjust_pos(c.xy), 0.0, 1.0);
|
|
56
|
+
// gl_Position = vec4( 0.0, 0.0, 0.0, 1.0);
|
|
40
57
|
v_rgba = rgba;
|
|
41
58
|
v_rgba.a *= plugin_opacity;
|
|
59
|
+
// float opacity = (float((gl_VertexID + 179) % 720 ) / (${vertexCount}.0)) / 1.5 + 0.5;
|
|
60
|
+
v_rgba.a *= c.z;
|
|
61
|
+
gl_PointSize = 10.0;
|
|
42
62
|
}
|
|
43
63
|
`
|
|
44
64
|
|
|
@@ -60,10 +80,15 @@ class Logic {
|
|
|
60
80
|
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
61
81
|
const { gl, program } = this;
|
|
62
82
|
{ // assign attribute locations
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
// in vec2 screen_coordinate;
|
|
84
|
+
// in float pixel_radius_small;
|
|
85
|
+
// in float pixel_radius_big;
|
|
86
|
+
// in vec4 rgba;
|
|
87
|
+
|
|
88
|
+
gl.bindAttribLocation(program, 0, "screen_coordinate");
|
|
89
|
+
gl.bindAttribLocation(program, 1, "pixel_radius_small");
|
|
90
|
+
gl.bindAttribLocation(program, 2, "pixel_radius_big");
|
|
91
|
+
gl.bindAttribLocation(program, 3, "rgba");
|
|
67
92
|
}
|
|
68
93
|
{
|
|
69
94
|
this._opacityLocation = gl.getUniformLocation(program, "plugin_opacity");
|
|
@@ -86,11 +111,11 @@ class Logic {
|
|
|
86
111
|
if (globe.api_GetCurrentGeometry() === 0) return;
|
|
87
112
|
gl.useProgram(program);
|
|
88
113
|
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
89
|
-
gl.bindVertexArray(vao);
|
|
90
114
|
if (opacity !== this._lastOpacity) {
|
|
91
115
|
this._lastOpacity = opacity;
|
|
92
116
|
gl.uniform1f(_opacityLocation, opacity);
|
|
93
117
|
}
|
|
118
|
+
gl.bindVertexArray(vao);
|
|
94
119
|
gl.drawArraysInstanced(gl.LINES, 0, vertexCount, length);
|
|
95
120
|
gl.bindVertexArray(null);
|
|
96
121
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
@@ -98,7 +123,6 @@ class Logic {
|
|
|
98
123
|
|
|
99
124
|
createVAO(screenCoordsBufferObj, pixelRadiusSmallBufferObj, pixelRadiusBigBufferObj, rgbaBufferObj) {
|
|
100
125
|
const { gl } = this;
|
|
101
|
-
|
|
102
126
|
const vao = gl.createVertexArray();
|
|
103
127
|
gl.bindVertexArray(vao);
|
|
104
128
|
{
|
|
@@ -111,26 +135,27 @@ class Logic {
|
|
|
111
135
|
{
|
|
112
136
|
const { buffer, stride = 0, offset = 0 } = pixelRadiusSmallBufferObj;
|
|
113
137
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
114
|
-
gl.enableVertexAttribArray(
|
|
138
|
+
gl.enableVertexAttribArray(1);
|
|
115
139
|
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
|
|
116
140
|
gl.vertexAttribDivisor(1, 1);
|
|
117
141
|
}
|
|
118
142
|
{
|
|
119
143
|
const { buffer, stride = 0, offset = 0 } = pixelRadiusBigBufferObj;
|
|
120
144
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
121
|
-
gl.enableVertexAttribArray(
|
|
145
|
+
gl.enableVertexAttribArray(2);
|
|
122
146
|
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
|
|
123
147
|
gl.vertexAttribDivisor(2, 1);
|
|
124
148
|
}
|
|
125
149
|
{
|
|
126
150
|
const { buffer, stride = 0, offset = 0 } = rgbaBufferObj;
|
|
127
151
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
128
|
-
gl.enableVertexAttribArray(
|
|
152
|
+
gl.enableVertexAttribArray(3);
|
|
129
153
|
gl.vertexAttribPointer(3, 4, gl.FLOAT, false, stride, offset);
|
|
130
154
|
gl.vertexAttribDivisor(3, 1);
|
|
131
155
|
}
|
|
132
156
|
|
|
133
157
|
gl.bindVertexArray(null);
|
|
158
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
134
159
|
return vao;
|
|
135
160
|
|
|
136
161
|
}
|
|
@@ -139,6 +164,7 @@ class Logic {
|
|
|
139
164
|
|
|
140
165
|
|
|
141
166
|
free() {
|
|
167
|
+
const { globe } = this;
|
|
142
168
|
CameraUniformBlockTotemCache.release(globe);
|
|
143
169
|
}
|
|
144
170
|
}
|
|
@@ -146,10 +172,6 @@ class Logic {
|
|
|
146
172
|
|
|
147
173
|
|
|
148
174
|
export const PixelPaddingForFlatCompassCache = Object.freeze({
|
|
149
|
-
get: (globe) =>
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
release: (globe) => {
|
|
153
|
-
globeProgramCache.releaseProgram(globe, Logic)
|
|
154
|
-
}
|
|
175
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
176
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
155
177
|
})
|
|
@@ -147,8 +147,11 @@ export class BufferOrchestrator {
|
|
|
147
147
|
const offsets = [];
|
|
148
148
|
for (const item of items) {
|
|
149
149
|
const offset = offsetMap.get(item.key);
|
|
150
|
-
if (offset !== undefined) {
|
|
151
|
-
|
|
150
|
+
if (offset !== undefined) {
|
|
151
|
+
offsets.push(offset);
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error("updateBulk item Key does not exist");
|
|
154
|
+
}
|
|
152
155
|
}
|
|
153
156
|
if (bufferKeys) {
|
|
154
157
|
for (const key of bufferKeys) {
|
|
@@ -230,6 +233,15 @@ export class BufferOrchestrator {
|
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Flushes metadata and sets length to 0 without actualize change on buffers
|
|
238
|
+
* This method created for cases in which data is loaded on each frame
|
|
239
|
+
*/
|
|
240
|
+
flush() {
|
|
241
|
+
this._length = 0;
|
|
242
|
+
this.tombstoneOffSet = []
|
|
243
|
+
this.offsetMap.clear();
|
|
244
|
+
}
|
|
233
245
|
|
|
234
246
|
_defrag() {
|
|
235
247
|
const newOffsetMap = new Map();
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { PixelPaddingForFlatCompassCache } from "../programs/two-d/pixel-padding-for-compass";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export class PixelPaddingCompassPlugin {
|
|
6
|
-
constructor(id, { } = {}) {
|
|
7
|
-
this.id = id;
|
|
8
|
-
this.memory = new Map();
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
init(globe, gl) {
|
|
13
|
-
this.globe = globe;
|
|
14
|
-
this.gl = gl;
|
|
15
|
-
|
|
16
|
-
this._initOrchestrations()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_initOrchestrations() {
|
|
22
|
-
const { gl, globe } = this;
|
|
23
|
-
this.paddingProgram = PixelPaddingForFlatCompassCache.get(globe);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
// createBuffers
|
|
28
|
-
const bufferType = "DYNAMIC_DRAW";
|
|
29
|
-
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
30
|
-
this.bufferManagersCompMap = new Map(
|
|
31
|
-
[
|
|
32
|
-
["screenCoordinates", {
|
|
33
|
-
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
34
|
-
'adaptor': (item) => {
|
|
35
|
-
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
36
|
-
{
|
|
37
|
-
long: item.long,
|
|
38
|
-
lat: item.lat,
|
|
39
|
-
z: 0,
|
|
40
|
-
});
|
|
41
|
-
return new Float32Array([x, y]);
|
|
42
|
-
}
|
|
43
|
-
}],
|
|
44
|
-
["pixelRadiusSmall", {
|
|
45
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
46
|
-
'adaptor': (item) => new Float32Array([item.pixelRadiusSmall])
|
|
47
|
-
}],
|
|
48
|
-
["pixelRadiusBig", {
|
|
49
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
50
|
-
'adaptor': (item) => new Float32Array([item.pixelRadiusBig])
|
|
51
|
-
}],
|
|
52
|
-
["rgba", {
|
|
53
|
-
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
54
|
-
'adaptor': (item) => {
|
|
55
|
-
if (item.lineProperties?.rgba) return new Float32Array(item.lineProperties.rgba);
|
|
56
|
-
return new Float32Array(item.rgba);
|
|
57
|
-
}
|
|
58
|
-
}],
|
|
59
|
-
|
|
60
|
-
]
|
|
61
|
-
);
|
|
62
|
-
const obj = function (bufferManagerComp) {
|
|
63
|
-
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
|
|
64
|
-
};
|
|
65
|
-
this.paddingVao = this.paddingProgram.createVAO(
|
|
66
|
-
...['screenCoordinates', 'pixelRadiusSmall', 'pixelRadiusBig', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
function isOnTheScreen(globe, points) { }
|
|
76
|
-
|