@pirireis/webglobeplugins 0.5.3-a → 0.5.4
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 +29 -12
- package/circle-line-chain/plugin.js +20 -3
- package/package.json +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +0 -6
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +6 -7
- package/write-text/context-text2.js +0 -1
|
@@ -25,16 +25,24 @@ export class ChainListMap {
|
|
|
25
25
|
*/
|
|
26
26
|
addNode(node, chainKey, theNodeKeyFront = null) {
|
|
27
27
|
const chain = this.getChain(chainKey);
|
|
28
|
-
|
|
29
|
-
chain.push(node);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
28
|
+
let frontIndex = null;
|
|
32
29
|
for (let i = 0; i < chain.length; i++) {
|
|
33
30
|
const n_ode = chain[i];
|
|
34
|
-
if (n_ode.key
|
|
35
|
-
|
|
36
|
-
break;
|
|
31
|
+
if (n_ode.key === node.key) {
|
|
32
|
+
throw new Error("Chain node already exists");
|
|
37
33
|
}
|
|
34
|
+
if (n_ode.key === theNodeKeyFront) {
|
|
35
|
+
frontIndex = i;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (theNodeKeyFront !== null) {
|
|
39
|
+
if (frontIndex !== null) {
|
|
40
|
+
chain.splice(frontIndex, 0, node);
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error("Could not find theNodeKeyFront");
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
chain.push(node);
|
|
38
46
|
}
|
|
39
47
|
node.__identity__ = this.keyMethod(chainKey, node.key);
|
|
40
48
|
this._resetIndexChain(chainKey);
|
|
@@ -49,20 +57,20 @@ export class ChainListMap {
|
|
|
49
57
|
|
|
50
58
|
deleteNodesBelongToAChain(chainKey, nodeKeys) {
|
|
51
59
|
const chain = this._chainMap.get(chainKey);
|
|
52
|
-
const
|
|
60
|
+
const deleteKeys = [];
|
|
53
61
|
const removeSet = new Set(nodeKeys);
|
|
54
62
|
const newChain = []
|
|
55
63
|
for (const node of chain) {
|
|
56
64
|
const dKey = node.__identity__;
|
|
57
65
|
this._indexMap.delete(dKey);
|
|
58
66
|
if (removeSet.has(node.key)) {
|
|
59
|
-
|
|
67
|
+
deleteKeys.push(dKey);
|
|
60
68
|
} else {
|
|
61
69
|
newChain.push(node);
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
this._chainMap.set(chainKey, newChain);
|
|
65
|
-
return
|
|
73
|
+
return deleteKeys;
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
deleteChainAndReturnChainKeys(chainKey) {
|
|
@@ -80,11 +88,20 @@ export class ChainListMap {
|
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
updateNodeProperties(node, chainKey) {
|
|
92
|
+
const index = this.getIndexOfNode(chainKey, node.key)
|
|
93
|
+
const chainNode = this._chainMap.get(chainKey)[index];
|
|
94
|
+
if (node.circleProperties) {
|
|
95
|
+
node.circleProperties.forEach((value, key, container) => chainNode[key] = value);
|
|
96
|
+
}
|
|
97
|
+
if (node.lineProperties) {
|
|
98
|
+
node.lineProperties.forEach((value, key, container) => chainNode[key] = value);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
84
101
|
|
|
102
|
+
updateCoordsinatesOfNode(node, chainKey) {
|
|
85
103
|
const index = this.getIndexOfNode(chainKey, node.key)
|
|
86
104
|
const chain = this._chainMap.get(chainKey);
|
|
87
|
-
node.__identity__ = this.keyMethod(chainKey, node.key);
|
|
88
105
|
chain[index].long = node.long;
|
|
89
106
|
chain[index].long = node.lat;
|
|
90
107
|
|
|
@@ -2,7 +2,7 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
|
|
|
2
2
|
import { CircleCache } from '../programs/line-on-globe/circle';
|
|
3
3
|
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
4
4
|
import { ChainListMap } from "./chain-list-map";
|
|
5
|
-
import { keyMethod } from
|
|
5
|
+
import { keyMethod } from "./util";
|
|
6
6
|
// TODO: Add update buffer and update text mehods on add, delete, update methods
|
|
7
7
|
|
|
8
8
|
|
|
@@ -110,7 +110,6 @@ export class CircleLineChainPlugin {
|
|
|
110
110
|
);
|
|
111
111
|
// (startPotisionBufferObj, endPositionBufferObj, dashRatioBufferObj, colorBufferObj)
|
|
112
112
|
const obj = function (bufferManagerComp) {
|
|
113
|
-
console.log(bufferManagerComp);
|
|
114
113
|
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
|
|
115
114
|
};
|
|
116
115
|
this.lineVao = this.lineProgram.createVAO(
|
|
@@ -159,6 +158,18 @@ export class CircleLineChainPlugin {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* @param {*} chainKey
|
|
164
|
+
* @param {Array<{nodeKey, Map[propertyName ,value]}} propertyMap
|
|
165
|
+
*/
|
|
166
|
+
updateNodeProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
|
|
167
|
+
this._chainListMap.updateNodeProperties(chainKey, nodesAndPropertyMap)
|
|
168
|
+
this._reconstructChains([chainKey]);
|
|
169
|
+
this._textUpdate(chainKey, textWriterIDs);
|
|
170
|
+
this.globe.DrawRender();
|
|
171
|
+
}
|
|
172
|
+
|
|
162
173
|
/**
|
|
163
174
|
*
|
|
164
175
|
* @param {*} chainKey
|
|
@@ -199,6 +210,7 @@ export class CircleLineChainPlugin {
|
|
|
199
210
|
}
|
|
200
211
|
this._reconstructChains(chainKeysToConstruct);
|
|
201
212
|
if (textWriterIDs) this._updateTexts(chainKeysToConstruct, textWriterIDs);
|
|
213
|
+
this.globe.DrawRender();
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
/**
|
|
@@ -212,6 +224,7 @@ export class CircleLineChainPlugin {
|
|
|
212
224
|
this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
|
|
213
225
|
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
214
226
|
this._reconstructChains([chainKey]);
|
|
227
|
+
this.globe.DrawRender();
|
|
215
228
|
|
|
216
229
|
}
|
|
217
230
|
|
|
@@ -221,6 +234,7 @@ export class CircleLineChainPlugin {
|
|
|
221
234
|
this._chainListMap.updateNode(node, chainKey);
|
|
222
235
|
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
223
236
|
this._reconstructChains([chainKey]);
|
|
237
|
+
this.globe.DrawRender();
|
|
224
238
|
}
|
|
225
239
|
|
|
226
240
|
|
|
@@ -251,6 +265,7 @@ export class CircleLineChainPlugin {
|
|
|
251
265
|
this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
|
|
252
266
|
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
253
267
|
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
268
|
+
this.globe.DrawRender();
|
|
254
269
|
}
|
|
255
270
|
|
|
256
271
|
|
|
@@ -267,8 +282,10 @@ export class CircleLineChainPlugin {
|
|
|
267
282
|
});
|
|
268
283
|
this._reconstructChains(chainKeysToReconstuct);
|
|
269
284
|
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
270
|
-
if (textWriterIDs) this._updateTexts(chainKeysToReconstuct, textWriterIDs)
|
|
285
|
+
// if (textWriterIDs) this._updateTexts(chainKeysToReconstuct, textWriterIDs)
|
|
271
286
|
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
287
|
+
this.globe.DrawRender();
|
|
288
|
+
|
|
272
289
|
}
|
|
273
290
|
|
|
274
291
|
|
package/package.json
CHANGED
|
@@ -54,7 +54,6 @@ export class BufferManager {
|
|
|
54
54
|
const offsetMultiplier = itemSize * 4;
|
|
55
55
|
for (let i = 0; i < blocks.length; i++) {
|
|
56
56
|
const block = blocks[i];
|
|
57
|
-
console.log(block)
|
|
58
57
|
const offset = offsets[i] * offsetMultiplier;
|
|
59
58
|
if (offset !== undefined) gl.bufferSubData(gl.ARRAY_BUFFER, offset, block);
|
|
60
59
|
}
|
|
@@ -68,12 +67,10 @@ export class BufferManager {
|
|
|
68
67
|
|
|
69
68
|
const newArray = new Float32Array(newCapacity * itemSize);
|
|
70
69
|
const bufferData = this._getBufferData(occupiedCapacity);
|
|
71
|
-
// console.log("bufferData", bufferData);
|
|
72
70
|
let newOffset = 0;
|
|
73
71
|
for (const offset of offsetValues) {
|
|
74
72
|
const itemOffset = offset * itemSize;
|
|
75
73
|
newArray.set(bufferData.slice(itemOffset, itemOffset + itemSize), newOffset);
|
|
76
|
-
// console.log("oldOffset", itemOffset, "newOffset", newOffset);
|
|
77
74
|
newOffset += itemSize;
|
|
78
75
|
}
|
|
79
76
|
|
|
@@ -88,7 +85,6 @@ export class BufferManager {
|
|
|
88
85
|
const { gl, buffer, bufferType } = this;
|
|
89
86
|
const itemSize = this.itemSize;
|
|
90
87
|
const bufferData = this._getBufferData(occupiedCapacity);
|
|
91
|
-
// console.log("extending buffer from", occupiedCapacity, "to", newCapacity, 'item size', itemSize);
|
|
92
88
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
93
89
|
gl.bufferData(gl.ARRAY_BUFFER, newCapacity * itemSize * 4, gl[bufferType]);
|
|
94
90
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
|
@@ -97,9 +93,7 @@ export class BufferManager {
|
|
|
97
93
|
|
|
98
94
|
_getBufferData(occupiedCapacity) {
|
|
99
95
|
const { gl, buffer } = this;
|
|
100
|
-
// console.log(occupiedCapacity, this.itemSize)
|
|
101
96
|
const size = occupiedCapacity * this.itemSize;
|
|
102
|
-
// console.log("size", size);
|
|
103
97
|
const bufferData = new Float32Array(size);
|
|
104
98
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
105
99
|
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
|
@@ -129,23 +129,26 @@ export class BufferOrchestrator {
|
|
|
129
129
|
const { offsetMap } = this;
|
|
130
130
|
const offsets = [];
|
|
131
131
|
for (const item of items) {
|
|
132
|
-
|
|
132
|
+
let o = offsetMap.get(item.key);
|
|
133
|
+
const offset = o !== undefined ? o : this.nextOffset();
|
|
133
134
|
offsetMap.set(item.key, offset);
|
|
134
135
|
offsets.push(offset);
|
|
135
136
|
}
|
|
136
137
|
for (const [key, { bufferManager, adaptor }] of bufferManagersMap) {
|
|
137
138
|
bufferManager.insertBulk(items.map(adaptor), offsets);
|
|
138
139
|
}
|
|
140
|
+
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
|
|
142
|
-
//
|
|
144
|
+
// does not assign offset to the new items.
|
|
143
145
|
updateBulk(items, bufferManagersMap, bufferKeys) {
|
|
144
146
|
const { offsetMap } = this;
|
|
145
147
|
const offsets = [];
|
|
146
148
|
for (const item of items) {
|
|
147
149
|
const offset = offsetMap.get(item.key);
|
|
148
|
-
offsets.push(offset);
|
|
150
|
+
if (offset !== undefined) { offsets.push(offset); } else { throw new Error("updateBulk item Key does not exist"); }
|
|
151
|
+
|
|
149
152
|
}
|
|
150
153
|
if (bufferKeys) {
|
|
151
154
|
for (const key of bufferKeys) {
|
|
@@ -174,7 +177,6 @@ export class BufferOrchestrator {
|
|
|
174
177
|
for (const [key, { bufferManager }] of bufferManagersMap) {
|
|
175
178
|
bufferManager.deleteBulk(offsets);
|
|
176
179
|
}
|
|
177
|
-
//console.log("deleteBulk after item size", this.offsetMap.size);
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
|
|
@@ -198,9 +200,7 @@ export class BufferOrchestrator {
|
|
|
198
200
|
autoExtendBuffers(itemsLength, bufferManagersMap) {
|
|
199
201
|
if (itemsLength <= this.emptySpace) return;
|
|
200
202
|
const newCapacity = this.length + itemsLength;
|
|
201
|
-
//console.log("autoExtendBuffers", "item L", itemsLength, "E space", this.emptySpace, "cap", this.capacity, "length", this.length, 'new Cap', newCapacity);
|
|
202
203
|
for (const [key, { bufferManager }] of bufferManagersMap) {
|
|
203
|
-
//console.log("length", this.length, "newCapacity", newCapacity);
|
|
204
204
|
bufferManager.extendBuffer(this.length, newCapacity);
|
|
205
205
|
}
|
|
206
206
|
this._capacity = newCapacity;
|
|
@@ -235,7 +235,6 @@ export class BufferOrchestrator {
|
|
|
235
235
|
const newOffsetMap = new Map();
|
|
236
236
|
let newOffset = 0;
|
|
237
237
|
for (const [key, offset] of this.offsetMap) {
|
|
238
|
-
//console.log("defrag", key, offset, newOffset);
|
|
239
238
|
newOffsetMap.set(key, newOffset++);
|
|
240
239
|
}
|
|
241
240
|
this.offsetMap = newOffsetMap
|
|
@@ -134,7 +134,6 @@ export class ContextTextWriter2 {
|
|
|
134
134
|
if (text == null) return;
|
|
135
135
|
const opacity = this.opacityAdaptor(item, id, container, properties);
|
|
136
136
|
const angle = this.angleAdaptor(item, id, container, properties);
|
|
137
|
-
console.log(angle, "angle")
|
|
138
137
|
const key = this.keyAdaptor(item, id, container, properties)
|
|
139
138
|
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle });
|
|
140
139
|
}
|