@pirireis/webglobeplugins 0.17.1 → 1.0.3
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/Math/haversine.js +22 -0
- package/Math/methods.js +15 -2
- package/Math/tessellation/methods.js +4 -1
- package/Math/tessellation/nearest-value-padding.js +112 -0
- package/Math/tessellation/spherical-triangle-area.js +99 -0
- package/Math/tessellation/tile-merger.js +346 -215
- package/Math/tessellation/triangle-tessellation.js +381 -9
- package/Math/vec3.js +4 -0
- package/Math/xyz-tile.js +18 -0
- package/altitude-locator/plugin.js +1 -2
- package/investigation-tools/draw/tiles/adapters.js +2 -2
- package/investigation-tools/draw/tiles/tiles.js +2 -2
- package/package.json +1 -1
- package/programs/helpers/fadeaway.js +6 -1
- package/programs/point-on-globe/square-pixel-point.js +1 -0
- package/programs/polygon-on-globe/texture-dem-triangles.js +94 -116
- package/programs/totems/camera-totem-attactment-interface.js +1 -0
- package/programs/totems/camerauniformblock.js +33 -22
- package/programs/totems/dem-textures-manager.js +265 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +51 -18
- package/programs/vectorfields/logics/{ubo-new.js → particle-ubo.js} +5 -14
- package/programs/vectorfields/logics/pixelbased.js +42 -36
- package/programs/vectorfields/pingpongbuffermanager.js +34 -8
- package/semiplugins/shape-on-terrain/terrain-polygon/adapters.js +55 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache.js +102 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.js +45 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/manager.js +4 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +177 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.js +100 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/random.js +121 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.js +1 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker-contact.js +63 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +125 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.js +219 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/types.js +8 -0
- package/semiplugins/shell/bbox-renderer/logic.js +18 -58
- package/semiplugins/shell/bbox-renderer/object.js +19 -9
- package/tracks/point-heat-map/point-to-heat-map-flow.js +1 -1
- package/tracks/point-tracks/plugin.js +13 -6
- package/tracks/timetracks/program-line-strip.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +5 -3
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +2 -2
- package/util/gl-util/uniform-block/manager.js +20 -10
- package/util/helper-methods.js +8 -0
- package/util/picking/fence.js +4 -2
- package/util/picking/picker-displayer.js +51 -9
- package/util/programs/draw-texture-on-canvas.js +18 -15
- package/util/shaderfunctions/geometrytransformations.js +67 -1
- package/vectorfield/waveparticles/plugin.js +241 -116
- package/vectorfield/wind/adapters/image-to-fields.js +61 -0
- package/vectorfield/wind/adapters/types.js +1 -0
- package/vectorfield/wind/imagetovectorfieldandmagnitude.js +6 -9
- package/vectorfield/wind/plugin-persistant copy.js +364 -0
- package/vectorfield/wind/plugin-persistant.js +375 -0
- package/vectorfield/wind/plugin.js +1 -1
- package/Math/tessellation/earcut/adapters.js +0 -37
- package/Math/tessellation/hybrid-triangle-tessellation-meta.js +0 -123
- package/Math/tessellation/shred-input.js +0 -18
- package/Math/tessellation/tiler.js +0 -50
- package/Math/tessellation/triangle-tessellation-meta.js +0 -523
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +0 -328
- package/programs/vectorfields/logics/drawrectangleparticles1.js +0 -112
- package/semiplugins/shape-on-terrain/terrain-cover/texture-dem-cover.js +0 -1
- package/util/gl-util/uniform-block/types.js +0 -1
- package/util/webglobe/index.js +0 -2
- /package/Math/tessellation/{zoom-catch.js → constants.js} +0 -0
- /package/util/{webglobe/gldefaultstates.js → globe-default-gl-states.js} +0 -0
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { TextureDemTriangles } from "./texture-dem-triangles";
|
|
2
|
-
import { RADIAN, radianToMercatorXY } from "../../Math/methods";
|
|
3
|
-
import { mergeMeshes } from "../../Math/tessellation/tile-merger";
|
|
4
|
-
import { createTriangleTessellationMeta, getAllPoints, partialTessellation } from "../../Math/tessellation/triangle-tessellation-meta";
|
|
5
|
-
/**
|
|
6
|
-
* Loads a plugin with test data for TextureDemTriangles
|
|
7
|
-
*/
|
|
8
|
-
function test1(zoomLevel, p1, p2, p3) {
|
|
9
|
-
const triangleMeta = createTriangleTessellationMeta(p1, p2, p3);
|
|
10
|
-
const { vec3s, longLats, indices } = getAllPoints(triangleMeta, zoomLevel);
|
|
11
|
-
return { vec3s, longLats, indices };
|
|
12
|
-
}
|
|
13
|
-
function partialTest(bboxZooms, p1, p2, p3) {
|
|
14
|
-
const triangleMeta = createTriangleTessellationMeta(p1, p2, p3);
|
|
15
|
-
return partialTessellation(triangleMeta, bboxZooms, 5);
|
|
16
|
-
}
|
|
17
|
-
function antalyaTestTriangle() {
|
|
18
|
-
const p1 = [30.5391 * RADIAN, 36.9083 * RADIAN];
|
|
19
|
-
const p2 = [32.9271 * RADIAN, 36.9083 * RADIAN];
|
|
20
|
-
const p3 = [31.7331 * RADIAN, 35.8145 * RADIAN];
|
|
21
|
-
const bboxZooms = [
|
|
22
|
-
// 12 zoom level
|
|
23
|
-
{
|
|
24
|
-
bbox: {
|
|
25
|
-
min: [30.5391 * RADIAN, 35.8145 * RADIAN],
|
|
26
|
-
max: [32.9271 * RADIAN, 36.9083 * RADIAN]
|
|
27
|
-
}, zoom: 15
|
|
28
|
-
},
|
|
29
|
-
// 11 zoom level
|
|
30
|
-
// {
|
|
31
|
-
// bbox: {
|
|
32
|
-
// min: [30.5391 * RADIAN, 35.8145 * RADIAN],
|
|
33
|
-
// max: [32.9271 * RADIAN, 36.9083 * RADIAN]
|
|
34
|
-
// }, zoom: 11
|
|
35
|
-
// },
|
|
36
|
-
];
|
|
37
|
-
return partialTest(bboxZooms, p1, p2, p3);
|
|
38
|
-
}
|
|
39
|
-
function loadVec3sLongLatsIndices(gl, bufferInfo, data) {
|
|
40
|
-
// Calculate total sizes
|
|
41
|
-
let totalVec3s = 0;
|
|
42
|
-
let totalLongLats = 0;
|
|
43
|
-
let totalIndices = 0;
|
|
44
|
-
for (const item of data) {
|
|
45
|
-
totalVec3s += item.vec3s.length;
|
|
46
|
-
totalLongLats += item.longLats.length;
|
|
47
|
-
totalIndices += item.indices.length;
|
|
48
|
-
}
|
|
49
|
-
// Pre-allocate arrays
|
|
50
|
-
const vec3s = new Float32Array(totalVec3s);
|
|
51
|
-
const longLats = new Float32Array(totalLongLats);
|
|
52
|
-
const indices = new Uint32Array(totalIndices);
|
|
53
|
-
let vec3Offset = 0;
|
|
54
|
-
let longLatOffset = 0;
|
|
55
|
-
let indexOffset = 0;
|
|
56
|
-
let vertexOffset = 0;
|
|
57
|
-
for (const item of data) {
|
|
58
|
-
// Copy vec3s
|
|
59
|
-
vec3s.set(item.vec3s, vec3Offset);
|
|
60
|
-
vec3Offset += item.vec3s.length;
|
|
61
|
-
// Copy longLats
|
|
62
|
-
longLats.set(item.longLats, longLatOffset);
|
|
63
|
-
longLatOffset += item.longLats.length;
|
|
64
|
-
// Copy and adjust indices
|
|
65
|
-
for (let i = 0; i < item.indices.length; i++) {
|
|
66
|
-
indices[indexOffset + i] = item.indices[i] + vertexOffset;
|
|
67
|
-
}
|
|
68
|
-
indexOffset += item.indices.length;
|
|
69
|
-
vertexOffset += item.vec3s.length / 3; // Each vertex has 3 components
|
|
70
|
-
}
|
|
71
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, bufferInfo.pos3dBufferInfo.buffer);
|
|
72
|
-
gl.bufferData(gl.ARRAY_BUFFER, vec3s, gl.STATIC_DRAW);
|
|
73
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, bufferInfo.longLatBufferInfo.buffer);
|
|
74
|
-
gl.bufferData(gl.ARRAY_BUFFER, longLats, gl.STATIC_DRAW);
|
|
75
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferInfo.elementBufferInfo.buffer);
|
|
76
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
|
|
77
|
-
}
|
|
78
|
-
const createTestBBOXES = () => {
|
|
79
|
-
const bboxes = [];
|
|
80
|
-
for (let i = 0; i < 6; i++) {
|
|
81
|
-
const north = Math.random() * Math.PI / 2 / 1.4; // random latitude
|
|
82
|
-
const west = Math.random() * -1 * Math.PI / 10; // random longitude
|
|
83
|
-
const south = north - Math.PI / 30; // random latitude
|
|
84
|
-
const east = west + Math.PI / 30; // random longitude
|
|
85
|
-
const ll = [west, north]; // random northWest
|
|
86
|
-
const ur = [east, south]; // random southEast
|
|
87
|
-
//
|
|
88
|
-
bboxes.push({ ll, ur });
|
|
89
|
-
}
|
|
90
|
-
return bboxes;
|
|
91
|
-
};
|
|
92
|
-
const demTextureBBOX = createTestBBOXES();
|
|
93
|
-
function showTextureBBoxes(bboxes, demData = []) {
|
|
94
|
-
for (let i = 0; i < bboxes.length; i++) {
|
|
95
|
-
const bbox = bboxes[i];
|
|
96
|
-
console.log(`Texture BBOX ${i}: LL(${(bbox.ll[0] * 180 / Math.PI).toFixed(2)}, ${(bbox.ll[1] * 180 / Math.PI).toFixed(2)}) UR(${(bbox.ur[0] * 180 / Math.PI).toFixed(2)}, ${(bbox.ur[1] * 180 / Math.PI).toFixed(2)})`);
|
|
97
|
-
if (demData.length > i) {
|
|
98
|
-
const dem = demData[i];
|
|
99
|
-
let demStr = "DEM: \n";
|
|
100
|
-
for (let j = 0; j < dem.length; j++) {
|
|
101
|
-
demStr += dem[j].toFixed(1) + " ";
|
|
102
|
-
if ((j + 1) % 5 === 0) {
|
|
103
|
-
demStr += "\n";
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
console.log(demStr);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const createTestDemTextures = () => {
|
|
111
|
-
const textures = [];
|
|
112
|
-
for (let i = 0; i < 6; i++) {
|
|
113
|
-
const texture = [];
|
|
114
|
-
for (let j = 0; j < 5 * 5; j++) {
|
|
115
|
-
const value = 100 * Math.random(); // random elevation value
|
|
116
|
-
texture.push(value);
|
|
117
|
-
}
|
|
118
|
-
textures.push(texture);
|
|
119
|
-
}
|
|
120
|
-
return textures;
|
|
121
|
-
};
|
|
122
|
-
// TODO: NAME IT longlat degree or radian
|
|
123
|
-
export function createBuffersAndFill(gl, vec3s, longLats, indices) {
|
|
124
|
-
const positionBuffer = gl.createBuffer();
|
|
125
|
-
const longLatBuffer = gl.createBuffer();
|
|
126
|
-
const indexBuffer = gl.createBuffer();
|
|
127
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
128
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vec3s), gl.STATIC_DRAW);
|
|
129
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, longLatBuffer);
|
|
130
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(longLats), gl.STATIC_DRAW);
|
|
131
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
132
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW);
|
|
133
|
-
return {
|
|
134
|
-
buffers: {
|
|
135
|
-
positionBuffer,
|
|
136
|
-
longLatBuffer,
|
|
137
|
-
indexBuffer
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
export class TextureDemTrianglesTestPlugin {
|
|
142
|
-
globe = null;
|
|
143
|
-
textureDemTriangles = null;
|
|
144
|
-
vao = null;
|
|
145
|
-
drawOptions = null;
|
|
146
|
-
_lastTilesUniqueIdentifier = "";
|
|
147
|
-
bufferInfo = null;
|
|
148
|
-
id;
|
|
149
|
-
uboTriangleStyle = null;
|
|
150
|
-
uboStringStyle = null;
|
|
151
|
-
showDemPoints = false;
|
|
152
|
-
bboxZooms = [];
|
|
153
|
-
constructor(id) {
|
|
154
|
-
this.id = id;
|
|
155
|
-
this.bboxZooms = [];
|
|
156
|
-
}
|
|
157
|
-
init(globe) {
|
|
158
|
-
this.globe = globe;
|
|
159
|
-
this.textureDemTriangles = new TextureDemTriangles(globe);
|
|
160
|
-
// set bboxes and dem textures
|
|
161
|
-
const demTextures = createTestDemTextures();
|
|
162
|
-
// const demTextureBBOX = createTestBBOXES();
|
|
163
|
-
this.textureDemTriangles.setDemTextures(demTextures, demTextureBBOX);
|
|
164
|
-
//
|
|
165
|
-
// const baseZoom = 5;
|
|
166
|
-
showTextureBBoxes(demTextureBBOX, demTextures);
|
|
167
|
-
this.uboTriangleStyle = this.textureDemTriangles.createUBO();
|
|
168
|
-
this.uboStringStyle = this.textureDemTriangles.createUBO();
|
|
169
|
-
this.uboTriangleStyle.updateSingle("u_color", new Float32Array([1.0, 0.0, 0.0, 0.0]));
|
|
170
|
-
this.uboStringStyle.updateSingle("u_color", new Float32Array([.3, .3, .0, 1.0]));
|
|
171
|
-
const elementBuffer = globe.gl.createBuffer();
|
|
172
|
-
const bufferInfo = {
|
|
173
|
-
pos3dBufferInfo: {
|
|
174
|
-
buffer: globe.gl.createBuffer(),
|
|
175
|
-
stride: 0,
|
|
176
|
-
offset: 0,
|
|
177
|
-
},
|
|
178
|
-
longLatBufferInfo: {
|
|
179
|
-
buffer: globe.gl.createBuffer(),
|
|
180
|
-
stride: 0,
|
|
181
|
-
offset: 0,
|
|
182
|
-
},
|
|
183
|
-
elementBufferInfo: {
|
|
184
|
-
buffer: elementBuffer,
|
|
185
|
-
stride: 0,
|
|
186
|
-
offset: 0,
|
|
187
|
-
},
|
|
188
|
-
drawOptions: {
|
|
189
|
-
drawRange: { count: 0, first: 0 },
|
|
190
|
-
drawMode: globe.gl.TRIANGLES,
|
|
191
|
-
elementBuffer: elementBuffer,
|
|
192
|
-
elementBufferIndexType: globe.gl.UNSIGNED_INT
|
|
193
|
-
},
|
|
194
|
-
drawOptionsPoint: {
|
|
195
|
-
drawRange: { count: 0, first: 0 },
|
|
196
|
-
drawMode: globe.gl.POINTS,
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
this.vao = this.textureDemTriangles.createVAO(bufferInfo.pos3dBufferInfo, bufferInfo.longLatBufferInfo);
|
|
200
|
-
this.bufferInfo = bufferInfo;
|
|
201
|
-
this.setZoom(5);
|
|
202
|
-
}
|
|
203
|
-
setUniform(key, value) {
|
|
204
|
-
if (this.uboTriangleStyle) {
|
|
205
|
-
this.uboTriangleStyle.updateSingle(key, value);
|
|
206
|
-
}
|
|
207
|
-
if (this.uboStringStyle) {
|
|
208
|
-
this.uboStringStyle.updateSingle(key, value);
|
|
209
|
-
}
|
|
210
|
-
this.globe?.DrawRender();
|
|
211
|
-
}
|
|
212
|
-
setZoom(zoomLevel) {
|
|
213
|
-
this.bboxZooms = demTextureBBOX.map((bbox, index) => {
|
|
214
|
-
return {
|
|
215
|
-
bbox: {
|
|
216
|
-
min: bbox.ll,
|
|
217
|
-
max: bbox.ur,
|
|
218
|
-
}, zoom: index + zoomLevel + 1
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
// all world - FIX: Convert to radians
|
|
222
|
-
this.bboxZooms.push({
|
|
223
|
-
bbox: {
|
|
224
|
-
min: [-180 * RADIAN, -90 * RADIAN], // ✓ Now radians
|
|
225
|
-
max: [180 * RADIAN, 90 * RADIAN] // ✓ Now radians
|
|
226
|
-
},
|
|
227
|
-
zoom: zoomLevel
|
|
228
|
-
});
|
|
229
|
-
if (!this.globe || !this.textureDemTriangles || !this.bufferInfo)
|
|
230
|
-
return;
|
|
231
|
-
// const p1: LongLatRadian = [-20 * Math.PI / 180, 50 * Math.PI / 180];
|
|
232
|
-
// const p2: LongLatRadian = [20 * Math.PI / 180, 50 * Math.PI / 180];
|
|
233
|
-
// const p3: LongLatRadian = [0, -10 * Math.PI / 180];
|
|
234
|
-
const p1 = [-60 * Math.PI / 180, 60 * Math.PI / 180];
|
|
235
|
-
const p2 = [60 * Math.PI / 180, 60 * Math.PI / 180];
|
|
236
|
-
const p3 = [0, -60 * Math.PI / 180];
|
|
237
|
-
const bigTriangle = partialTest(this.bboxZooms, p1, p2, p3);
|
|
238
|
-
const bufferInfo = this.bufferInfo;
|
|
239
|
-
const antalya = antalyaTestTriangle();
|
|
240
|
-
loadVec3sLongLatsIndices(this.globe.gl, bufferInfo, [
|
|
241
|
-
bigTriangle,
|
|
242
|
-
antalya
|
|
243
|
-
]);
|
|
244
|
-
bufferInfo.drawOptions.drawRange.first = 0;
|
|
245
|
-
bufferInfo.drawOptions.drawRange.count = antalya.indices.length + bigTriangle.indices.length;
|
|
246
|
-
bufferInfo.drawOptionsPoint.drawRange.first = 0;
|
|
247
|
-
bufferInfo.drawOptionsPoint.drawRange.count = (antalya.longLats.length + bigTriangle.longLats.length) / 2;
|
|
248
|
-
}
|
|
249
|
-
setShowDemPoints(show) {
|
|
250
|
-
this.showDemPoints = show;
|
|
251
|
-
}
|
|
252
|
-
draw3D() {
|
|
253
|
-
if (!this.globe || !this.textureDemTriangles || !this.vao || !this.bufferInfo)
|
|
254
|
-
return;
|
|
255
|
-
const gl = this.globe.gl;
|
|
256
|
-
this._prepareDem();
|
|
257
|
-
gl.frontFace(gl.CW);
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptions, this.uboTriangleStyle);
|
|
260
|
-
if (this.showDemPoints) {
|
|
261
|
-
// @ts-ignore
|
|
262
|
-
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptionsPoint, this.uboStringStyle);
|
|
263
|
-
}
|
|
264
|
-
gl.frontFace(gl.CCW);
|
|
265
|
-
}
|
|
266
|
-
_prepareDem() {
|
|
267
|
-
if (!this.globe || !this.textureDemTriangles)
|
|
268
|
-
return;
|
|
269
|
-
const drawnTiles = this.globe.api_GetDrawedTilesInfo();
|
|
270
|
-
if (this._checkTileChange(drawnTiles))
|
|
271
|
-
return;
|
|
272
|
-
const mergedTiles = mergeMeshes(drawnTiles, 12, 5, 4);
|
|
273
|
-
// let I = 6;
|
|
274
|
-
for (const tile of mergedTiles) {
|
|
275
|
-
const bbox = globeBBoxToXYBBOX(tile.bbox);
|
|
276
|
-
// Validation: Check if values are in expected radian range
|
|
277
|
-
// if (Math.abs(bbox.northWest[0]) > Math.PI * 2 || Math.abs(bbox.northWest[1]) > Math.PI) {
|
|
278
|
-
// console.error(`⚠️ BBOX out of radian range! Raw bbox:`, tile.bbox);
|
|
279
|
-
// }
|
|
280
|
-
if (bbox.ll[0] > bbox.ur[0]) {
|
|
281
|
-
console.warn(`⚠️ BBOX longitudes seem incorrect! ll longitude is greater than ur longitude. Raw bbox:`, bbox);
|
|
282
|
-
}
|
|
283
|
-
if (bbox.ll[1] > bbox.ur[1]) {
|
|
284
|
-
console.warn(`⚠️ BBOX latitudes seem incorrect! ll latitude is greater than ur latitude. Raw bbox:`, bbox);
|
|
285
|
-
}
|
|
286
|
-
// console.log(` BBox LL (${(bbox.ll[0]).toFixed(2)}°, ${(bbox.ll[1]).toFixed(2)}°) UR (${(bbox.ur[0]).toFixed(2)}°, ${(bbox.ur[1]).toFixed(2)}°), Cover: ${tile.coverRatio.x.toFixed(2)}x${tile.coverRatio.y.toFixed(2)}`);
|
|
287
|
-
// console.log(`${I} Cover: ${tile.coverRatio.x.toFixed(2)} ${tile.coverRatio.y.toFixed(2)}`);
|
|
288
|
-
// I--;
|
|
289
|
-
}
|
|
290
|
-
// console.log("...............................")
|
|
291
|
-
this.textureDemTriangles.setDemTextures(mergedTiles.map(t => Array.from(t.mesh)), mergedTiles.map(t => globeBBoxToXYBBOX(t.bbox)), mergedTiles.map(t => ({ x: t.coverRatio.x, y: t.coverRatio.y })));
|
|
292
|
-
}
|
|
293
|
-
_checkTileChange(drawnTiles) {
|
|
294
|
-
let maxLevel = 0;
|
|
295
|
-
let minLevel = Number.MAX_VALUE;
|
|
296
|
-
const tileMap = new Map();
|
|
297
|
-
for (const tile of drawnTiles) {
|
|
298
|
-
if (tile.level > maxLevel) {
|
|
299
|
-
maxLevel = tile.level;
|
|
300
|
-
}
|
|
301
|
-
if (tile.level < minLevel) {
|
|
302
|
-
minLevel = tile.level;
|
|
303
|
-
}
|
|
304
|
-
if (!tileMap.has(tile.level)) {
|
|
305
|
-
tileMap.set(tile.level, []);
|
|
306
|
-
}
|
|
307
|
-
tileMap.get(tile.level).push(tile);
|
|
308
|
-
}
|
|
309
|
-
let tilesUniqueId = "";
|
|
310
|
-
for (let level = minLevel; level <= maxLevel; level++) {
|
|
311
|
-
const tiles = tileMap.get(level);
|
|
312
|
-
if (!tiles)
|
|
313
|
-
continue;
|
|
314
|
-
tilesUniqueId += `L${level}_C${tiles.length}_`;
|
|
315
|
-
}
|
|
316
|
-
if (tilesUniqueId === this._lastTilesUniqueIdentifier)
|
|
317
|
-
return true;
|
|
318
|
-
this._lastTilesUniqueIdentifier = tilesUniqueId;
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
function globeBBoxToXYBBOX(t) {
|
|
323
|
-
// this code scales Y to linear integration
|
|
324
|
-
return {
|
|
325
|
-
ll: radianToMercatorXY([t.ll.x * RADIAN, t.ll.y * RADIAN]), // west longitude, north latitude
|
|
326
|
-
ur: radianToMercatorXY([t.ur.x * RADIAN, t.ur.y * RADIAN]) // east longitude, south latitude
|
|
327
|
-
};
|
|
328
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { createProgram } from "../../../util/webglobjectbuilders";
|
|
2
|
-
import { glProgramCache } from "../../programcache";
|
|
3
|
-
import { SeaWaveUbo } from "./ubo-new";
|
|
4
|
-
/**
|
|
5
|
-
* [+] ubo
|
|
6
|
-
*/
|
|
7
|
-
const vertexShaderSource = `#version 300 es
|
|
8
|
-
precision highp float;
|
|
9
|
-
` + SeaWaveUbo.glslCode() + `
|
|
10
|
-
uniform sampler2D u_vector_field;
|
|
11
|
-
in vec2 in_position;
|
|
12
|
-
out vec3 base_color;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
vec2 read_value(const vec2 uv) {
|
|
16
|
-
vec2 value = texture(u_vector_field, uv).rg;
|
|
17
|
-
if ( value.x == escape_value || value.y == escape_value) {
|
|
18
|
-
return vec2(0.0);
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
vec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu ayni isi yapiyor
|
|
25
|
-
// return texture(u_vector_field, uv).rg; // lower-res hardware filtering
|
|
26
|
-
vec2 res = vec2(textureSize(u_vector_field, 0));
|
|
27
|
-
vec2 px = 1.0 / res;
|
|
28
|
-
vec2 vc = (floor(uv * res)) * px;
|
|
29
|
-
vec2 f = fract(uv * res);
|
|
30
|
-
vec2 tl = read_value(vc).rg;
|
|
31
|
-
vec2 tr = read_value(vc + vec2(px.x, 0)).rg;
|
|
32
|
-
vec2 bl = read_value(vc + vec2(0, px.y)).rg;
|
|
33
|
-
vec2 br = read_value(vc + px).rg;
|
|
34
|
-
|
|
35
|
-
return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
void main(){
|
|
40
|
-
vec2 direction_vector = lookup_wind(in_position);
|
|
41
|
-
if (direction_vector.r == 0.0 && direction_vector.g == 0.0) return;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
vec2 limp;
|
|
45
|
-
if ( 0 == gl_VertexID) { limp = -tail_wing_base_limp; }
|
|
46
|
-
else if ( 1 == gl_VertexID) { limp = vec2( tail_wing_base_limp.x, -tail_wing_base_limp.y); }
|
|
47
|
-
else if ( 2 == gl_VertexID) { limp = tail_wing_base_limp; }
|
|
48
|
-
else { limp = vec2(-tail_wing_base_limp.x, tail_wing_base_limp.y); } // if ( 3 == gl_VertexID)
|
|
49
|
-
|
|
50
|
-
limp = (limp * mat2(
|
|
51
|
-
direction_vector.x, -direction_vector.y,
|
|
52
|
-
direction_vector.y, direction_vector.x)) / draw_texture_size;
|
|
53
|
-
|
|
54
|
-
vec2 pos = in_position * 2.0 - 1.0;
|
|
55
|
-
gl_Position = vec4(pos + limp, 0.0, 1.0);
|
|
56
|
-
base_color = color;
|
|
57
|
-
}`;
|
|
58
|
-
const fragmentShaderSource = `#version 300 es
|
|
59
|
-
precision highp float;
|
|
60
|
-
out vec4 outColor;
|
|
61
|
-
in vec3 base_color;
|
|
62
|
-
void main(){
|
|
63
|
-
outColor = vec4(base_color, 1.0);
|
|
64
|
-
}`;
|
|
65
|
-
class Logic {
|
|
66
|
-
constructor(gl) {
|
|
67
|
-
this.gl = gl;
|
|
68
|
-
[this.program,
|
|
69
|
-
this._vector_field_location] = this._createProgram();
|
|
70
|
-
// this.decoyBuffer = new DecoyBufferManager(gl);
|
|
71
|
-
}
|
|
72
|
-
_createProgram() {
|
|
73
|
-
const gl = this.gl;
|
|
74
|
-
const program = createProgram(gl, vertexShaderSource, fragmentShaderSource);
|
|
75
|
-
// ubo point
|
|
76
|
-
// const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
|
|
77
|
-
// gl.uniformBlockBinding(program, ubo_location, UBO_BINDING_POINT);
|
|
78
|
-
SeaWaveUbo.assignBindingPoint(gl, program, 0);
|
|
79
|
-
return [program, gl.getUniformLocation(program, 'u_vector_field')];
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @param {*} bufferManager | PingPongBufferManager
|
|
83
|
-
* @param {*} vectorTexture | RG32F texture R: x, G: y
|
|
84
|
-
* @param {*} uboManager | WaveParticalUboManager under ubo.js
|
|
85
|
-
*/
|
|
86
|
-
draw(bufferManager, vectorTexture, uboManager) {
|
|
87
|
-
const { gl, program } = this;
|
|
88
|
-
gl.useProgram(program);
|
|
89
|
-
gl.bindVertexArray(bufferManager.getSourceVao());
|
|
90
|
-
// gl.bindVertexArray(this.decoyBuffer.getSourceVao());
|
|
91
|
-
uboManager.bind();
|
|
92
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
93
|
-
gl.uniform1i(this._vector_field_location, 0);
|
|
94
|
-
gl.bindTexture(gl.TEXTURE_2D, vectorTexture);
|
|
95
|
-
gl.drawArraysInstanced(gl.TRIANGLE_FAN, 0, 4, bufferManager.length);
|
|
96
|
-
gl.drawArraysInstanced(gl.POINTS, 0, 4, bufferManager.length);
|
|
97
|
-
gl.bindVertexArray(null);
|
|
98
|
-
uboManager.unbind();
|
|
99
|
-
}
|
|
100
|
-
free() {
|
|
101
|
-
this.gl.deleteProgram(this.program);
|
|
102
|
-
this.program = null;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
export const drawRectangleParticlesProgramCache = Object.freeze({
|
|
106
|
-
getProgram: (gl) => {
|
|
107
|
-
return glProgramCache.getProgram(gl, Logic);
|
|
108
|
-
},
|
|
109
|
-
releaseProgram: (gl) => {
|
|
110
|
-
glProgramCache.releaseProgram(gl, Logic);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/util/webglobe/index.js
DELETED
|
File without changes
|
|
File without changes
|