@pirireis/webglobeplugins 0.17.0 → 1.0.2
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/{angle-calculation.js → angle-calculation.ts} +18 -14
- package/Math/{arc-cdf-points.js → arc-cdf-points.ts} +329 -272
- package/Math/{arc-generate-points-exponantial.js → arc-generate-points-exponantial.ts} +299 -254
- package/Math/{arc.js → arc.ts} +421 -292
- package/Math/bounds/line-bbox.js +225 -186
- package/Math/{circle-cdf-points.js → circle-cdf-points.ts} +143 -78
- package/Math/{circle.js → circle.ts} +49 -33
- package/Math/{constants.js → constants.ts} +12 -4
- package/Math/contour/{quadtreecontours.js → quadtreecontours.ts} +371 -300
- package/Math/contour/quadtreecontours1.js +336 -298
- package/Math/{finite-line-2d.js → finite-line-2d.ts} +68 -58
- package/Math/haversine.ts +33 -0
- package/Math/index.js +0 -1
- package/Math/juction/{arc-plane.js → arc-plane.ts} +203 -143
- package/Math/juction/{line-sphere.js → line-sphere.ts} +32 -22
- package/Math/juction/{plane-plane.js → plane-plane.ts} +62 -53
- package/Math/{line.js → line.ts} +84 -52
- package/Math/matrix4.ts +0 -0
- package/Math/mesh/mapbox-delaunay.d.ts +74 -0
- package/Math/{methods.js → methods.ts} +182 -107
- package/Math/{plane.js → plane.ts} +92 -56
- package/Math/{quaternion.js → quaternion.ts} +128 -106
- package/Math/roadmap.md +10 -0
- package/Math/templete-shapes/{grid-visually-equal.js → grid-visually-equal.ts} +118 -65
- package/Math/tessellation/constants.ts +1 -0
- package/Math/tessellation/methods.ts +79 -0
- package/Math/tessellation/nearest-value-padding.ts +147 -0
- package/Math/tessellation/roadmap.md +48 -0
- package/Math/tessellation/spherical-triangle-area.ts +127 -0
- package/Math/tessellation/tile-merger.ts +578 -0
- package/Math/tessellation/triangle-tessellation.ts +533 -0
- package/Math/tessellation/types.ts +1 -0
- package/Math/types.ts +68 -0
- package/Math/utils.js +3 -2
- package/Math/{vec3.js → vec3.ts} +227 -151
- package/Math/xyz-tile.ts +26 -0
- package/algorithms/search-binary.js +14 -16
- package/altitude-locator/adaptors.js +0 -1
- package/altitude-locator/keymethod.js +0 -1
- package/altitude-locator/plugin.js +445 -345
- package/altitude-locator/types.js +26 -21
- package/compass-rose/compass-rose-padding-flat.js +274 -230
- package/compass-rose/{compass-text-writer.js → compass-text-writer.ts} +210 -155
- package/compass-rose/index.js +3 -3
- package/{constants.js → constants.ts} +8 -6
- package/heatwave/datamanager.js +168 -149
- package/heatwave/heatwave.js +261 -206
- package/heatwave/index.js +5 -5
- package/heatwave/isobar.js +340 -303
- package/heatwave/{texture-point-sampler.js → texture-point-sampler.ts} +220 -187
- package/investigation-tools/draw/tiles/adapters.ts +133 -0
- package/investigation-tools/draw/tiles/tiles.ts +162 -0
- package/jest.config.js +6 -7
- package/package.json +1 -1
- package/pin/pin-object-array1.js +381 -300
- package/pin/pin-point-totem1.js +77 -60
- package/programs/arrowfield/arrow-field.js +89 -60
- package/programs/arrowfield/logic.js +173 -141
- package/programs/data2legend/density-to-legend.js +86 -68
- package/programs/data2legend/point-to-density-texture.js +84 -67
- package/programs/float2legendwithratio/index.js +3 -2
- package/programs/float2legendwithratio/logic.js +144 -118
- package/programs/float2legendwithratio/object.js +141 -104
- package/programs/helpers/blender.js +73 -58
- package/programs/helpers/{fadeaway.js → fadeaway.ts} +73 -55
- package/programs/index.js +19 -20
- package/programs/line-on-globe/circle-accurate-3d.js +112 -85
- package/programs/line-on-globe/circle-accurate-flat.js +200 -148
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +134 -102
- package/programs/line-on-globe/index.js +0 -1
- package/programs/line-on-globe/lines-color-instanced-flat.js +99 -80
- package/programs/line-on-globe/linestrip/data.ts +29 -0
- package/programs/line-on-globe/linestrip/{linestrip.js → linestrip.ts} +152 -93
- package/programs/line-on-globe/{naive-accurate-flexible.js → naive-accurate-flexible.ts} +175 -126
- package/programs/line-on-globe/util.js +8 -5
- package/programs/picking/pickable-polygon-renderer.js +129 -98
- package/programs/picking/pickable-renderer.js +130 -98
- package/programs/point-on-globe/element-globe-surface-glow.js +122 -93
- package/programs/point-on-globe/element-point-glow.js +114 -80
- package/programs/point-on-globe/square-pixel-point.js +139 -120
- package/programs/polygon-on-globe/roadmap.md +8 -0
- package/programs/polygon-on-globe/texture-dem-triangles.ts +290 -0
- package/programs/{programcache.js → programcache.ts} +134 -126
- package/programs/rings/index.js +1 -1
- package/programs/rings/partial-ring/{piece-of-pie.js → piece-of-pie.ts} +222 -152
- package/programs/totems/camera-totem-attactment-interface.ts +4 -0
- package/programs/totems/{camerauniformblock.js → camerauniformblock.ts} +326 -230
- package/programs/totems/{canvas-webglobe-info.js → canvas-webglobe-info.ts} +147 -132
- package/programs/totems/dem-textures-manager.ts +368 -0
- package/programs/totems/{globe-changes.js → globe-changes.ts} +79 -59
- package/programs/totems/gpu-selection-uniform-block.js +127 -99
- package/programs/totems/{index.js → index.ts} +2 -2
- package/programs/two-d/pixel-padding-for-compass.js +101 -87
- package/programs/util.js +19 -14
- package/programs/vectorfields/logics/{constants.js → constants.ts} +5 -4
- package/programs/vectorfields/logics/drawrectangleparticles.ts +182 -0
- package/programs/vectorfields/logics/index.js +4 -2
- package/programs/vectorfields/logics/particle-ubo.ts +23 -0
- package/programs/vectorfields/logics/{pixelbased.js → pixelbased.ts} +119 -84
- package/programs/vectorfields/logics/ubo.js +57 -51
- package/programs/vectorfields/{pingpongbuffermanager.js → pingpongbuffermanager.ts} +113 -73
- package/publish.bat +62 -0
- package/range-tools-on-terrain/bearing-line/{adapters.js → adapters.ts} +154 -114
- package/range-tools-on-terrain/bearing-line/{plugin.js → plugin.ts} +569 -457
- package/range-tools-on-terrain/bearing-line/types.ts +65 -0
- package/range-tools-on-terrain/circle-line-chain/{adapters.js → adapters.ts} +104 -85
- package/range-tools-on-terrain/circle-line-chain/{chain-list-map.js → chain-list-map.ts} +446 -382
- package/range-tools-on-terrain/circle-line-chain/{plugin.js → plugin.ts} +607 -464
- package/range-tools-on-terrain/circle-line-chain/types.ts +43 -0
- package/range-tools-on-terrain/range-ring/{adapters.js → adapters.ts} +114 -93
- package/range-tools-on-terrain/range-ring/{enum.js → enum.ts} +2 -2
- package/range-tools-on-terrain/range-ring/{plugin.js → plugin.ts} +444 -377
- package/range-tools-on-terrain/range-ring/rangeringangletext.ts +396 -0
- package/range-tools-on-terrain/range-ring/types.ts +30 -0
- package/semiplugins/interface.ts +14 -0
- package/semiplugins/lightweight/{line-plugin.js → line-plugin.ts} +342 -221
- package/semiplugins/lightweight/{piece-of-pie-plugin.js → piece-of-pie-plugin.ts} +275 -200
- package/semiplugins/shape-on-terrain/{arc-plugin.js → arc-plugin.ts} +616 -472
- package/semiplugins/shape-on-terrain/{circle-plugin.js → circle-plugin.ts} +588 -444
- package/semiplugins/shape-on-terrain/goal.md +12 -0
- package/semiplugins/shape-on-terrain/{padding-1-degree.js → padding-1-degree.ts} +713 -539
- package/semiplugins/shape-on-terrain/terrain-polygon/adapters.ts +69 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache-shortcuts.md +20 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache.ts +149 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.ts +58 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/manager.ts +4 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +196 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.ts +209 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.ts +144 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/random.ts +165 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/readme.md +5 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.ts +37 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker-contact.ts +81 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +146 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/notes.md +90 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.ts +265 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/types.ts +69 -0
- package/semiplugins/shell/bbox-renderer/index.ts +2 -0
- package/semiplugins/shell/bbox-renderer/{logic.js → logic.ts} +273 -249
- package/semiplugins/shell/bbox-renderer/object.ts +129 -0
- package/semiplugins/type.ts +8 -0
- package/semiplugins/utility/{container-plugin.js → container-plugin.ts} +126 -94
- package/semiplugins/utility/{object-pass-container-plugin.js → object-pass-container-plugin.ts} +101 -80
- package/shaders/fragment-toy/firework.js +1 -1
- package/shaders/fragment-toy/singularity.js +5 -2
- package/terrain-plugin.mmd +83 -0
- package/tests/Math/arc-sampling-test.js +367 -0
- package/tests/Math/arc-sampling-test.ts +429 -0
- package/tests/Math/arc.test.ts +77 -0
- package/tests/Math/junction/arc-limit.test.ts +7 -0
- package/tests/Math/junction/arc-plane-points.test.ts +196 -0
- package/tests/Math/junction/arc-plane.test.ts +172 -0
- package/tests/Math/junction/line-sphere.test.ts +127 -0
- package/tests/Math/junction/plane-plane.test.ts +91 -0
- package/tests/Math/plane-test.ts +17 -0
- package/tests/Math/plane.test.ts +43 -0
- package/tests/Math/vec3.test.ts +33 -0
- package/tracks/point-heat-map/adaptors/timetracksplugin-format-to-this.js +78 -63
- package/tracks/point-heat-map/index.js +0 -1
- package/tracks/point-heat-map/plugin-webworker.js +148 -121
- package/tracks/point-heat-map/point-to-heat-map-flow.js +150 -121
- package/tracks/point-heat-map/readme.md +15 -0
- package/tracks/point-tracks/key-methods.js +3 -2
- package/tracks/point-tracks/plugin.js +487 -393
- package/tracks/timetracks/adaptors-line-strip.js +79 -65
- package/tracks/timetracks/plugin-line-strip.js +295 -240
- package/tracks/timetracks/program-line-strip.js +495 -411
- package/tracks/timetracks/programpoint-line-strip.js +137 -109
- package/tracks/timetracks/readme.md +1 -0
- package/tsconfig.json +22 -0
- package/types/@pirireis/webglobe.d.ts +102 -0
- package/types/delaunator.d.ts +40 -0
- package/types/earcut.d.ts +11 -0
- package/types/rbush.d.ts +57 -0
- package/types.ts +319 -0
- package/util/account/bufferoffsetmanager.js +209 -176
- package/util/account/create-buffermap-orchastration.ts +85 -0
- package/util/account/index.js +6 -3
- package/util/account/single-attribute-buffer-management/{buffer-manager.js → buffer-manager.ts} +151 -117
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator.js → buffer-orchestrator.ts} +238 -212
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator1.js → buffer-orchestrator1.ts} +184 -159
- package/util/account/single-attribute-buffer-management/{index.js → index.ts} +11 -4
- package/util/account/single-attribute-buffer-management/{object-store.js → object-store.ts} +76 -55
- package/util/account/single-attribute-buffer-management/types.ts +43 -0
- package/util/account/util.js +22 -18
- package/util/algorithms/index.js +0 -1
- package/util/algorithms/search-binary.js +26 -25
- package/util/build-strategy/{static-dynamic.js → static-dynamic.ts} +50 -41
- package/util/check/index.js +0 -1
- package/util/check/typecheck.ts +74 -0
- package/util/{frame-counter-trigger.js → frame-counter-trigger.ts} +99 -84
- package/util/geometry/{index.js → index.ts} +155 -121
- package/util/gl-util/buffer/{attribute-loader.js → attribute-loader.ts} +84 -62
- package/util/gl-util/buffer/{index.js → index.ts} +6 -3
- package/util/gl-util/draw-options/{methods.js → methods.ts} +47 -32
- package/util/gl-util/uniform-block/{manager.js → manager.ts} +232 -190
- package/util/{webglobe/gldefaultstates.js → globe-default-gl-states.ts} +5 -4
- package/util/helper-methods.ts +9 -0
- package/util/index.js +9 -10
- package/util/interpolation/index.js +0 -1
- package/util/interpolation/timetrack/index.js +9 -2
- package/util/interpolation/timetrack/timetrack-interpolator.js +94 -79
- package/util/interpolation/timetrack/web-worker.js +51 -46
- package/util/picking/{fence.js → fence.ts} +47 -41
- package/util/picking/picker-displayer.ts +226 -0
- package/util/programs/draw-from-pixel-coords.js +201 -164
- package/util/programs/{draw-texture-on-canvas.js → draw-texture-on-canvas.ts} +92 -67
- package/util/programs/supersampletotextures.js +130 -97
- package/util/programs/texturetoglobe.js +153 -128
- package/util/shaderfunctions/{geometrytransformations.js → geometrytransformations.ts} +169 -41
- package/util/shaderfunctions/index.js +2 -2
- package/util/shaderfunctions/nodata.js +4 -2
- package/util/shaderfunctions/noisefunctions.js +10 -7
- package/util/{webglobjectbuilders.js → webglobjectbuilders.ts} +446 -358
- package/vectorfield/arrowfield/adaptor.js +11 -11
- package/vectorfield/arrowfield/index.js +3 -3
- package/vectorfield/arrowfield/plugin.js +128 -83
- package/vectorfield/waveparticles/adaptor.js +16 -15
- package/vectorfield/waveparticles/index.js +3 -3
- package/vectorfield/waveparticles/plugin.ts +506 -0
- package/vectorfield/wind/adapters/image-to-fields.ts +74 -0
- package/vectorfield/wind/adapters/types.ts +12 -0
- package/vectorfield/wind/{imagetovectorfieldandmagnitude.js → imagetovectorfieldandmagnitude.ts} +78 -56
- package/vectorfield/wind/index.js +5 -5
- package/vectorfield/wind/plugin-persistant copy.ts +461 -0
- package/vectorfield/wind/plugin-persistant.ts +483 -0
- package/vectorfield/wind/plugin.js +883 -671
- package/vectorfield/wind/vectorfieldimage.js +27 -23
- package/write-text/{context-text-bulk.js → context-text-bulk.ts} +285 -200
- package/write-text/context-text3.ts +252 -0
- package/write-text/{context-text4.js → context-text4.ts} +231 -145
- package/write-text/context-textDELETE.js +125 -94
- package/write-text/objectarraylabels/{index.js → index.ts} +2 -2
- package/write-text/objectarraylabels/objectarraylabels.d.ts +72 -0
- package/write-text/objectarraylabels/objectarraylabels.js +247 -200
- package/Math/matrix4.js +0 -1
- package/Math/tessellation/earcut/adapters.js +0 -37
- package/Math/tessellation/hybrid-triangle-tessellation-meta.js +0 -123
- package/Math/tessellation/methods.js +0 -46
- package/Math/tessellation/shred-input.js +0 -18
- package/Math/tessellation/tile-merger.js +0 -56
- package/Math/tessellation/tiler.js +0 -50
- package/Math/tessellation/triangle-tessellation-meta.js +0 -516
- package/Math/tessellation/triangle-tessellation.js +0 -14
- package/Math/tessellation/types.js +0 -1
- package/Math/tessellation/zoom-catch.js +0 -1
- package/Math/types.js +0 -1
- package/programs/line-on-globe/linestrip/data.js +0 -4
- package/programs/polygon-on-globe/partial-tesselation.js +0 -1
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +0 -204
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +0 -118
- package/programs/polygon-on-globe/texture-dem-triangles.js +0 -236
- package/programs/vectorfields/logics/drawrectangleparticles.js +0 -112
- package/programs/vectorfields/logics/ubo-new.js +0 -25
- package/range-tools-on-terrain/bearing-line/types.js +0 -1
- package/range-tools-on-terrain/circle-line-chain/types.js +0 -1
- package/range-tools-on-terrain/range-ring/rangeringangletext.js +0 -331
- package/range-tools-on-terrain/range-ring/types.js +0 -9
- package/semiplugins/interface.js +0 -1
- package/semiplugins/shape-on-terrain/terrain-cover/texture-dem-cover.js +0 -1
- package/semiplugins/shell/bbox-renderer/index.js +0 -2
- package/semiplugins/shell/bbox-renderer/object.js +0 -65
- package/semiplugins/type.js +0 -1
- package/types.js +0 -19
- package/util/account/create-buffermap-orchastration.js +0 -39
- package/util/account/single-attribute-buffer-management/types.js +0 -1
- package/util/check/typecheck.js +0 -66
- package/util/gl-util/uniform-block/types.js +0 -1
- package/util/picking/picker-displayer.js +0 -134
- package/util/webglobe/index.js +0 -2
- package/util/webglobe/rasteroverlay.js +0 -76
- package/vectorfield/waveparticles/plugin.js +0 -290
- package/write-text/attached-text-writer.js +0 -95
- package/write-text/context-text3.js +0 -167
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { TextureDemTriangles } from "./texture-dem-triangles";
|
|
2
|
-
import { partialTest } from "../../Math/tessellation/triangle-tessellation";
|
|
3
|
-
/**
|
|
4
|
-
* Loads a plugin with test data for TextureDemTriangles
|
|
5
|
-
*/
|
|
6
|
-
const createTestBBOXES = () => {
|
|
7
|
-
const bboxes = [];
|
|
8
|
-
for (let i = 0; i < 6; i++) {
|
|
9
|
-
const north = Math.random() * Math.PI / 2 / 1.4; // random latitude
|
|
10
|
-
const west = Math.random() * -1 * Math.PI / 10; // random longitude
|
|
11
|
-
const south = north - Math.PI / 30; // random latitude
|
|
12
|
-
const east = west + Math.PI / 30; // random longitude
|
|
13
|
-
const nw = [west, north]; // random northWest
|
|
14
|
-
const se = [east, south]; // random southEast
|
|
15
|
-
bboxes.push({ northWest: nw, southEast: se });
|
|
16
|
-
}
|
|
17
|
-
return bboxes;
|
|
18
|
-
};
|
|
19
|
-
const demTextureBBOX = createTestBBOXES();
|
|
20
|
-
function showTextureBBoxes(bboxes, demData = []) {
|
|
21
|
-
for (let i = 0; i < bboxes.length; i++) {
|
|
22
|
-
const bbox = bboxes[i];
|
|
23
|
-
console.log(`Texture BBOX ${i}: NW(${(bbox.northWest[0] * 180 / Math.PI).toFixed(2)}, ${(bbox.northWest[1] * 180 / Math.PI).toFixed(2)}) SE(${(bbox.southEast[0] * 180 / Math.PI).toFixed(2)}, ${(bbox.southEast[1] * 180 / Math.PI).toFixed(2)})`);
|
|
24
|
-
if (demData.length > i) {
|
|
25
|
-
const dem = demData[i];
|
|
26
|
-
let demStr = "DEM: \n";
|
|
27
|
-
for (let j = 0; j < dem.length; j++) {
|
|
28
|
-
demStr += dem[j].toFixed(1) + " ";
|
|
29
|
-
if ((j + 1) % 5 === 0) {
|
|
30
|
-
demStr += "\n";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
console.log(demStr);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const createTestDemTextures = () => {
|
|
38
|
-
const textures = [];
|
|
39
|
-
for (let i = 0; i < 6; i++) {
|
|
40
|
-
const texture = [];
|
|
41
|
-
for (let j = 0; j < 5 * 5; j++) {
|
|
42
|
-
const value = 100 * Math.random(); // random elevation value
|
|
43
|
-
texture.push(value);
|
|
44
|
-
}
|
|
45
|
-
textures.push(texture);
|
|
46
|
-
}
|
|
47
|
-
return textures;
|
|
48
|
-
};
|
|
49
|
-
// TODO: NAME IT longlat degree or radian
|
|
50
|
-
export function createBuffersAndFill(gl, vec3s, longLats, indices) {
|
|
51
|
-
const positionBuffer = gl.createBuffer();
|
|
52
|
-
const longLatBuffer = gl.createBuffer();
|
|
53
|
-
const indexBuffer = gl.createBuffer();
|
|
54
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
55
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vec3s), gl.STATIC_DRAW);
|
|
56
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, longLatBuffer);
|
|
57
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(longLats), gl.STATIC_DRAW);
|
|
58
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
59
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW);
|
|
60
|
-
return {
|
|
61
|
-
buffers: {
|
|
62
|
-
positionBuffer,
|
|
63
|
-
longLatBuffer,
|
|
64
|
-
indexBuffer
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export class TextureDemTrianglesTestPlugin {
|
|
69
|
-
globe = null;
|
|
70
|
-
textureDemTriangles = null;
|
|
71
|
-
vao = null;
|
|
72
|
-
drawOptions = null;
|
|
73
|
-
bufferInfo = null;
|
|
74
|
-
id;
|
|
75
|
-
uboTriangleStyle = null;
|
|
76
|
-
uboStringStyle = null;
|
|
77
|
-
showDemPoints = false;
|
|
78
|
-
bboxZooms = [];
|
|
79
|
-
constructor(id) {
|
|
80
|
-
this.id = id;
|
|
81
|
-
this.bboxZooms = [];
|
|
82
|
-
}
|
|
83
|
-
init(globe) {
|
|
84
|
-
this.globe = globe;
|
|
85
|
-
this.textureDemTriangles = new TextureDemTriangles(globe);
|
|
86
|
-
// set bboxes and dem textures
|
|
87
|
-
const demTextures = createTestDemTextures();
|
|
88
|
-
// const demTextureBBOX = createTestBBOXES();
|
|
89
|
-
this.textureDemTriangles.setDemTextures(demTextures, demTextureBBOX);
|
|
90
|
-
//
|
|
91
|
-
// const baseZoom = 5;
|
|
92
|
-
showTextureBBoxes(demTextureBBOX, demTextures);
|
|
93
|
-
this.uboTriangleStyle = this.textureDemTriangles.createUBO();
|
|
94
|
-
this.uboStringStyle = this.textureDemTriangles.createUBO();
|
|
95
|
-
this.uboTriangleStyle.updateSingle("u_color", new Float32Array([1.0, 0.0, 0.0, 0.0]));
|
|
96
|
-
this.uboStringStyle.updateSingle("u_color", new Float32Array([.3, .3, .0, 1.0]));
|
|
97
|
-
const elementBuffer = globe.gl.createBuffer();
|
|
98
|
-
const bufferInfo = {
|
|
99
|
-
pos3dBufferInfo: {
|
|
100
|
-
buffer: globe.gl.createBuffer(),
|
|
101
|
-
stride: 0,
|
|
102
|
-
offset: 0,
|
|
103
|
-
},
|
|
104
|
-
longLatBufferInfo: {
|
|
105
|
-
buffer: globe.gl.createBuffer(),
|
|
106
|
-
stride: 0,
|
|
107
|
-
offset: 0,
|
|
108
|
-
},
|
|
109
|
-
elementBufferInfo: {
|
|
110
|
-
buffer: elementBuffer,
|
|
111
|
-
stride: 0,
|
|
112
|
-
offset: 0,
|
|
113
|
-
},
|
|
114
|
-
drawOptions: {
|
|
115
|
-
drawRange: { count: 0, first: 0 },
|
|
116
|
-
drawMode: globe.gl.TRIANGLES,
|
|
117
|
-
elementBuffer: elementBuffer,
|
|
118
|
-
elementBufferIndexType: globe.gl.UNSIGNED_INT
|
|
119
|
-
},
|
|
120
|
-
drawOptionsPoint: {
|
|
121
|
-
drawRange: { count: 0, first: 0 },
|
|
122
|
-
drawMode: globe.gl.POINTS,
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
this.vao = this.textureDemTriangles.createVAO(bufferInfo.pos3dBufferInfo, bufferInfo.longLatBufferInfo);
|
|
126
|
-
this.bufferInfo = bufferInfo;
|
|
127
|
-
this.setZoom(5);
|
|
128
|
-
}
|
|
129
|
-
setUniform(key, value) {
|
|
130
|
-
if (this.uboTriangleStyle) {
|
|
131
|
-
this.uboTriangleStyle.updateSingle(key, value);
|
|
132
|
-
}
|
|
133
|
-
if (this.uboStringStyle) {
|
|
134
|
-
this.uboStringStyle.updateSingle(key, value);
|
|
135
|
-
}
|
|
136
|
-
this.globe?.DrawRender();
|
|
137
|
-
}
|
|
138
|
-
setZoom(zoomLevel) {
|
|
139
|
-
this.bboxZooms = demTextureBBOX.map((bbox, index) => {
|
|
140
|
-
return {
|
|
141
|
-
bbox: {
|
|
142
|
-
min: [bbox.northWest[0], bbox.southEast[1]], max: [bbox.southEast[0], bbox.northWest[1]]
|
|
143
|
-
}, zoom: index + zoomLevel + 1
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
// all world
|
|
147
|
-
this.bboxZooms.push({
|
|
148
|
-
bbox: {
|
|
149
|
-
min: [-180, -90],
|
|
150
|
-
max: [180, 90]
|
|
151
|
-
},
|
|
152
|
-
zoom: zoomLevel
|
|
153
|
-
});
|
|
154
|
-
if (!this.globe || !this.textureDemTriangles || !this.bufferInfo)
|
|
155
|
-
return;
|
|
156
|
-
// const p1: LongLatRadian = [-20 * Math.PI / 180, 50 * Math.PI / 180];
|
|
157
|
-
// const p2: LongLatRadian = [20 * Math.PI / 180, 50 * Math.PI / 180];
|
|
158
|
-
// const p3: LongLatRadian = [0, -10 * Math.PI / 180];
|
|
159
|
-
const p1 = [-60 * Math.PI / 180, 60 * Math.PI / 180];
|
|
160
|
-
const p2 = [60 * Math.PI / 180, 60 * Math.PI / 180];
|
|
161
|
-
const p3 = [0, -60 * Math.PI / 180];
|
|
162
|
-
// const p1_1: LongLatRadian = [-20 * Math.PI / 180, 30 * Math.PI / 180];
|
|
163
|
-
// const p2_2: LongLatRadian = [20 * Math.PI / 180, 20 * Math.PI / 180];
|
|
164
|
-
// const p3_3: LongLatRadian = [5, -20 * Math.PI / 180];
|
|
165
|
-
// const { vec3s, longLats, indices } = test1(zoomLevel, p1, p2, p3);
|
|
166
|
-
// const {vec3s, longLats, indices} = test1(5, p1_1, p2_2, p3_3);
|
|
167
|
-
const { vec3s, longLats, indices } = partialTest(this.bboxZooms, p1, p2, p3);
|
|
168
|
-
const bufferInfo = this.bufferInfo;
|
|
169
|
-
bufferInfo.drawOptions.drawRange.first = 0;
|
|
170
|
-
bufferInfo.drawOptions.drawRange.count = indices.length;
|
|
171
|
-
bufferInfo.drawOptionsPoint.drawRange.first = 0;
|
|
172
|
-
bufferInfo.drawOptionsPoint.drawRange.count = longLats.length / 2;
|
|
173
|
-
const gl = this.globe.gl;
|
|
174
|
-
// const longLatArray = createTestLongLatArray();
|
|
175
|
-
// const pos3dArray = createTestPos3dArray(longLatArray);
|
|
176
|
-
// @ts-ignore
|
|
177
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, bufferInfo.pos3dBufferInfo.buffer);
|
|
178
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vec3s), gl.STATIC_DRAW);
|
|
179
|
-
// @ts-ignore
|
|
180
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, bufferInfo.longLatBufferInfo.buffer);
|
|
181
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(longLats), gl.STATIC_DRAW);
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferInfo.elementBufferInfo.buffer);
|
|
184
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(indices), gl.STATIC_DRAW);
|
|
185
|
-
this.globe.DrawRender();
|
|
186
|
-
console.log("DrawIInfo", this.bufferInfo);
|
|
187
|
-
}
|
|
188
|
-
setShowDemPoints(show) {
|
|
189
|
-
this.showDemPoints = show;
|
|
190
|
-
}
|
|
191
|
-
draw3D() {
|
|
192
|
-
if (!this.globe || !this.textureDemTriangles || !this.vao || !this.bufferInfo)
|
|
193
|
-
return;
|
|
194
|
-
const gl = this.globe.gl;
|
|
195
|
-
gl.frontFace(gl.CW);
|
|
196
|
-
// @ts-ignore
|
|
197
|
-
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptions, this.uboTriangleStyle);
|
|
198
|
-
if (this.showDemPoints) {
|
|
199
|
-
// @ts-ignore
|
|
200
|
-
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptionsPoint, this.uboStringStyle);
|
|
201
|
-
}
|
|
202
|
-
gl.frontFace(gl.CCW);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { TextureDemTriangles } from "./texture-dem-triangles";
|
|
2
|
-
/**
|
|
3
|
-
* Loads a plugin with test data for TextureDemTriangles
|
|
4
|
-
*/
|
|
5
|
-
const TEST_ITEM_COUNT = 1000000;
|
|
6
|
-
function createTestLongLatArray() {
|
|
7
|
-
const arr = new Float32Array(TEST_ITEM_COUNT * 2);
|
|
8
|
-
for (let i = 0; i < TEST_ITEM_COUNT; i++) {
|
|
9
|
-
arr[i * 2 + 0] = (Math.random() - 0.5) * Math.PI * 2; // longitude
|
|
10
|
-
arr[i * 2 + 1] = (Math.random() - 0.5) * Math.PI; // latitude
|
|
11
|
-
}
|
|
12
|
-
return arr;
|
|
13
|
-
}
|
|
14
|
-
function createTestPos3dArray(longLatArray) {
|
|
15
|
-
const arr = new Float32Array(TEST_ITEM_COUNT * 3);
|
|
16
|
-
for (let i = 0; i < TEST_ITEM_COUNT; i++) {
|
|
17
|
-
const long = longLatArray[i * 2 + 0];
|
|
18
|
-
const lat = longLatArray[i * 2 + 1];
|
|
19
|
-
// Convert long/lat to 3D position (simplified)
|
|
20
|
-
arr[i * 3 + 0] = Math.cos(lat) * Math.cos(long);
|
|
21
|
-
arr[i * 3 + 1] = Math.cos(lat) * Math.sin(long);
|
|
22
|
-
arr[i * 3 + 2] = Math.sin(lat);
|
|
23
|
-
}
|
|
24
|
-
return arr;
|
|
25
|
-
}
|
|
26
|
-
const createTestBBOXES = () => {
|
|
27
|
-
const bboxes = [];
|
|
28
|
-
for (let i = 0; i < 6; i++) {
|
|
29
|
-
const north = Math.random(); // random latitude
|
|
30
|
-
const west = Math.random() * -1; // random longitude
|
|
31
|
-
const south = north - Math.PI / 6; // random latitude
|
|
32
|
-
const east = west + Math.PI / 6; // random longitude
|
|
33
|
-
const nw = [west, north]; // random northWest
|
|
34
|
-
const se = [east, south]; // random southEast
|
|
35
|
-
bboxes.push({ northWest: nw, southEast: se });
|
|
36
|
-
}
|
|
37
|
-
return bboxes;
|
|
38
|
-
};
|
|
39
|
-
const createTestDemTextures = () => {
|
|
40
|
-
const textures = [];
|
|
41
|
-
for (let i = 0; i < 6; i++) {
|
|
42
|
-
const texture = [];
|
|
43
|
-
for (let j = 0; j < 5 * 5; j++) {
|
|
44
|
-
const value = 1000 * Math.random(); // random elevation value
|
|
45
|
-
texture.push(value);
|
|
46
|
-
}
|
|
47
|
-
textures.push(texture);
|
|
48
|
-
}
|
|
49
|
-
return textures;
|
|
50
|
-
};
|
|
51
|
-
export function createBuffersAndFill(gl, vec3s, longLats, indices) {
|
|
52
|
-
const positionBuffer = gl.createBuffer();
|
|
53
|
-
const longLatBuffer = gl.createBuffer();
|
|
54
|
-
const indexBuffer = gl.createBuffer();
|
|
55
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
56
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vec3s), gl.STATIC_DRAW);
|
|
57
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, longLatBuffer);
|
|
58
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(longLats), gl.STATIC_DRAW);
|
|
59
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
60
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW);
|
|
61
|
-
return {
|
|
62
|
-
buffers: {
|
|
63
|
-
positionBuffer,
|
|
64
|
-
longLatBuffer,
|
|
65
|
-
indexBuffer
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
export class TextureDemTrianglesTestPlugin {
|
|
70
|
-
globe = null;
|
|
71
|
-
textureDemTriangles = null;
|
|
72
|
-
vao = null;
|
|
73
|
-
drawOptions = null;
|
|
74
|
-
bufferInfo = null;
|
|
75
|
-
ubo = null;
|
|
76
|
-
id;
|
|
77
|
-
constructor(id) {
|
|
78
|
-
this.id = id;
|
|
79
|
-
}
|
|
80
|
-
init(globe) {
|
|
81
|
-
this.globe = globe;
|
|
82
|
-
this.textureDemTriangles = new TextureDemTriangles(globe);
|
|
83
|
-
// set bboxes and dem textures
|
|
84
|
-
const demTextures = createTestDemTextures();
|
|
85
|
-
const demTextureBBOX = createTestBBOXES();
|
|
86
|
-
this.textureDemTriangles.setDemTextures(demTextures, demTextureBBOX);
|
|
87
|
-
//
|
|
88
|
-
this.ubo = this.textureDemTriangles.createUBO();
|
|
89
|
-
this.ubo.updateSingle("u_color", new Float32Array([1.0, 0.0, 0.0, 0.0]));
|
|
90
|
-
const bufferInfo = {
|
|
91
|
-
pos3dBufferInfo: {
|
|
92
|
-
buffer: globe.gl.createBuffer(),
|
|
93
|
-
stride: 0,
|
|
94
|
-
offset: 0,
|
|
95
|
-
},
|
|
96
|
-
longLatBufferInfo: {
|
|
97
|
-
buffer: globe.gl.createBuffer(),
|
|
98
|
-
stride: 0,
|
|
99
|
-
offset: 0,
|
|
100
|
-
},
|
|
101
|
-
drawOptions: { drawRange: { count: TEST_ITEM_COUNT, first: 0 } }
|
|
102
|
-
};
|
|
103
|
-
this.vao = this.textureDemTriangles.createVAO(bufferInfo.pos3dBufferInfo, bufferInfo.longLatBufferInfo);
|
|
104
|
-
const gl = globe.gl;
|
|
105
|
-
const longLatArray = createTestLongLatArray();
|
|
106
|
-
const pos3dArray = createTestPos3dArray(longLatArray);
|
|
107
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, bufferInfo.pos3dBufferInfo.buffer);
|
|
108
|
-
gl.bufferData(gl.ARRAY_BUFFER, pos3dArray, gl.STATIC_DRAW);
|
|
109
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, bufferInfo.longLatBufferInfo.buffer);
|
|
110
|
-
gl.bufferData(gl.ARRAY_BUFFER, longLatArray, gl.STATIC_DRAW);
|
|
111
|
-
this.bufferInfo = bufferInfo;
|
|
112
|
-
}
|
|
113
|
-
draw3D() {
|
|
114
|
-
if (!this.globe || !this.textureDemTriangles || !this.vao || !this.bufferInfo || !this.ubo)
|
|
115
|
-
return;
|
|
116
|
-
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptions, this.ubo);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
|
-
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems/camerauniformblock";
|
|
3
|
-
import { cartesian3DToGLPosition, } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
|
-
import { isPointInBBox } from "../../util/shaderfunctions/geometrytransformations";
|
|
5
|
-
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
6
|
-
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
7
|
-
import { WORLD_RADIUS_3D } from "../../Math/constants";
|
|
8
|
-
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
9
|
-
const uniformBindingPoints = {
|
|
10
|
-
camera: 0,
|
|
11
|
-
style: 1,
|
|
12
|
-
};
|
|
13
|
-
const styleBlockManager = new UniformBlockManager('Style', [
|
|
14
|
-
{ name: "u_color", type: "vec4", value: new Float32Array([0.0, 0.0, 0.0, 0.0]) },
|
|
15
|
-
{ name: "u_pointSize", type: "float", value: new Float32Array([1.0]) },
|
|
16
|
-
{ name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
|
|
17
|
-
], uniformBindingPoints.style);
|
|
18
|
-
const vertexShaderSource = `#version 300 es
|
|
19
|
-
#pragma vscode_glsllint_stage : vert
|
|
20
|
-
|
|
21
|
-
precision highp float;
|
|
22
|
-
precision highp sampler2DArray;
|
|
23
|
-
|
|
24
|
-
${CameraUniformBlockString}
|
|
25
|
-
|
|
26
|
-
${cartesian3DToGLPosition}
|
|
27
|
-
in vec3 a_position;
|
|
28
|
-
in vec2 a_longLat;
|
|
29
|
-
uniform sampler2DArray u_demTexture; // <-- changed from array to single
|
|
30
|
-
uniform vec4 u_demTextureBBOX[6];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
${styleBlockManager.glslCode()}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// TODO: light directioni
|
|
37
|
-
// out vec3 v_position;
|
|
38
|
-
// out vec3 v_normal;
|
|
39
|
-
// out vec2 v_textureCoord;
|
|
40
|
-
|
|
41
|
-
out vec4 v_color;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
${isPointInBBox}
|
|
45
|
-
|
|
46
|
-
void main() {
|
|
47
|
-
|
|
48
|
-
float elevation = ${WORLD_RADIUS_3D}; // default elevation at sea level
|
|
49
|
-
v_color = vec4(1.0, 1.0, 1.0, 1.0); // default color white
|
|
50
|
-
for (int i = 0; i < 6; i++) {
|
|
51
|
-
if (isPointInBBox(a_longLat, u_demTextureBBOX[i])) {
|
|
52
|
-
vec2 uv = (a_longLat - u_demTextureBBOX[i].xy) / (u_demTextureBBOX[i].zw - u_demTextureBBOX[i].xy);
|
|
53
|
-
float altitude = texture(u_demTexture, vec3(uv, float(i))).r;
|
|
54
|
-
elevation += altitude;
|
|
55
|
-
v_color = mix(vec4(0.0, 0.0, 1.0, 1.0), vec4(1.0, 0.0, 0.0, 1.0), altitude / 100.0); // color from blue to red based on altitude
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (u_color.a > 0.0) {
|
|
60
|
-
v_color = u_color;
|
|
61
|
-
}
|
|
62
|
-
v_color.a *= u_opacity;
|
|
63
|
-
vec3 position = a_position * elevation;
|
|
64
|
-
gl_Position = cartesian3DToGLPosition(position);
|
|
65
|
-
gl_PointSize = 5.0; //u_pointSize;
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
const fragmentShaderSource = `#version 300 es
|
|
69
|
-
#pragma vscode_glsllint_stage : frag
|
|
70
|
-
|
|
71
|
-
precision highp float;
|
|
72
|
-
in vec4 v_color;
|
|
73
|
-
out vec4 outColor;
|
|
74
|
-
void main() {
|
|
75
|
-
outColor = v_color;
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
export class TextureDemTriangles {
|
|
79
|
-
globe;
|
|
80
|
-
gl;
|
|
81
|
-
program;
|
|
82
|
-
// Later an injection will handle demTextures and demTextureBBOX
|
|
83
|
-
texture;
|
|
84
|
-
// demTextures: WebGLTexture[] = [];
|
|
85
|
-
// demTextureBBOX: Float32Array = new Float32Array(6 * 4); // 6 bounding boxes
|
|
86
|
-
cameraUniformBlock;
|
|
87
|
-
_publishedUBOs = [];
|
|
88
|
-
locations = {
|
|
89
|
-
attributes: {
|
|
90
|
-
a_position: -1,
|
|
91
|
-
a_longLat: -1,
|
|
92
|
-
},
|
|
93
|
-
uniforms: {
|
|
94
|
-
u_demTexture: -1,
|
|
95
|
-
u_demTextureBBOX: -1,
|
|
96
|
-
u_style: -1,
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
constructor(globe) {
|
|
100
|
-
this.globe = globe;
|
|
101
|
-
this.gl = globe.gl;
|
|
102
|
-
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
103
|
-
this.cameraUniformBlock = CameraUniformBlockTotemCache.get(this.globe);
|
|
104
|
-
this.cameraUniformBlock.assignBindingPoint(this.program, uniformBindingPoints.camera);
|
|
105
|
-
// get attribute locations
|
|
106
|
-
this.locations.attributes.a_position = this.gl.getAttribLocation(this.program, 'a_position');
|
|
107
|
-
this.locations.attributes.a_longLat = this.gl.getAttribLocation(this.program, 'a_longLat');
|
|
108
|
-
// get uniform locations
|
|
109
|
-
this.locations.uniforms.u_demTexture = this.gl.getUniformLocation(this.program, 'u_demTexture');
|
|
110
|
-
this.locations.uniforms.u_demTextureBBOX = this.gl.getUniformLocation(this.program, 'u_demTextureBBOX');
|
|
111
|
-
this.locations.uniforms.u_style = this.gl.getUniformBlockIndex(this.program, 'Style');
|
|
112
|
-
this.gl.uniformBlockBinding(this.program, this.locations.uniforms.u_style, uniformBindingPoints.style);
|
|
113
|
-
// create 3d texture
|
|
114
|
-
const texture = this.gl.createTexture();
|
|
115
|
-
this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, texture);
|
|
116
|
-
// this.gl.texImage3D(this.gl.TEXTURE_2D_ARRAY, 0, this.gl.R32F, 25, 25, 6, 0, this.gl.RED, this.gl.FLOAT, null);
|
|
117
|
-
this.gl.texStorage3D(this.gl.TEXTURE_2D_ARRAY, 1, this.gl.R32F, 5, 5, 6);
|
|
118
|
-
// set texture parameters
|
|
119
|
-
const ext = this.gl.getExtension('OES_texture_float_linear');
|
|
120
|
-
console.log('OES_texture_float_linear extension:', ext);
|
|
121
|
-
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
|
|
122
|
-
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
|
|
123
|
-
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
124
|
-
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
125
|
-
this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, null);
|
|
126
|
-
this.texture = texture;
|
|
127
|
-
}
|
|
128
|
-
createVAO(pos3dBufferInfo, longLatBufferInfo) {
|
|
129
|
-
const vao = this.gl.createVertexArray();
|
|
130
|
-
this.gl.bindVertexArray(vao);
|
|
131
|
-
attributeLoader(this.gl, pos3dBufferInfo, this.locations.attributes.a_position, 3);
|
|
132
|
-
attributeLoader(this.gl, longLatBufferInfo, this.locations.attributes.a_longLat, 2);
|
|
133
|
-
this.gl.bindVertexArray(null);
|
|
134
|
-
return vao;
|
|
135
|
-
}
|
|
136
|
-
setDemTextures(demTexturesData, demTextureBBOX) {
|
|
137
|
-
// bind textures to texture units
|
|
138
|
-
const gl = this.gl;
|
|
139
|
-
gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.texture);
|
|
140
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
141
|
-
// turn off premultiply alpha
|
|
142
|
-
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
143
|
-
// bind and upload each texture to the 3D texture array
|
|
144
|
-
for (let i = 0; i < demTexturesData.length; i++) {
|
|
145
|
-
const data = demTexturesData[i];
|
|
146
|
-
if (data.length === 5 * 5) { // <-- FIXED
|
|
147
|
-
gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, i, 5, 5, 1, gl.RED, gl.FLOAT, new Float32Array(data));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// set uniform for texture units
|
|
151
|
-
const bboxVec4Array = new Float32Array(6 * 4);
|
|
152
|
-
for (let i = 0; i < demTextureBBOX.length; i++) {
|
|
153
|
-
const bbox = demTextureBBOX[i];
|
|
154
|
-
bboxVec4Array[i * 4 + 0] = bbox.northWest[0];
|
|
155
|
-
bboxVec4Array[i * 4 + 1] = bbox.southEast[1];
|
|
156
|
-
bboxVec4Array[i * 4 + 2] = bbox.southEast[0];
|
|
157
|
-
bboxVec4Array[i * 4 + 3] = bbox.northWest[1];
|
|
158
|
-
}
|
|
159
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
160
|
-
gl.useProgram(this.program);
|
|
161
|
-
gl.uniform4fv(this.locations.uniforms.u_demTextureBBOX, bboxVec4Array);
|
|
162
|
-
gl.bindTexture(gl.TEXTURE_2D_ARRAY, null);
|
|
163
|
-
gl.useProgram(currentProgram);
|
|
164
|
-
}
|
|
165
|
-
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
166
|
-
const ubo = styleBlockManager.createUBO(this.gl, bufferReadType);
|
|
167
|
-
this._publishedUBOs.push(ubo);
|
|
168
|
-
return ubo;
|
|
169
|
-
}
|
|
170
|
-
free() {
|
|
171
|
-
this.gl.deleteProgram(this.program);
|
|
172
|
-
this.gl.deleteTexture(this.texture);
|
|
173
|
-
this._publishedUBOs.forEach(ubo => ubo.free());
|
|
174
|
-
this._publishedUBOs = [];
|
|
175
|
-
CameraUniformBlockTotemCache.release(this.globe);
|
|
176
|
-
}
|
|
177
|
-
draw(vao, drawOptions, ubo) {
|
|
178
|
-
const gl = this.gl;
|
|
179
|
-
gl.useProgram(this.program);
|
|
180
|
-
this.cameraUniformBlock.bind(uniformBindingPoints.camera);
|
|
181
|
-
// TURN OFF flip y for texture
|
|
182
|
-
// gl.disable(gl.DEPTH_TEST);
|
|
183
|
-
// gl.depthMask(false);
|
|
184
|
-
// gl.depthRange(0.0, 0.01); // Use near 1% of depth range
|
|
185
|
-
// Step 3: Optionally: Set depth func to ALWAYS (to ignore previous depth)
|
|
186
|
-
// This ensures your new geometry passes depth test regardless of prior depth values
|
|
187
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
188
|
-
gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.texture);
|
|
189
|
-
gl.uniform1i(this.locations.uniforms.u_demTexture, 0); // texture unit 0
|
|
190
|
-
// bind VAO and draw
|
|
191
|
-
gl.bindVertexArray(vao);
|
|
192
|
-
// bind UBO for style
|
|
193
|
-
ubo.bind();
|
|
194
|
-
drawOnTopBegin(gl);
|
|
195
|
-
drawArrays(gl, gl.POINTS, drawOptions);
|
|
196
|
-
drawOnTopEnd(gl);
|
|
197
|
-
gl.bindVertexArray(null);
|
|
198
|
-
gl.bindTexture(gl.TEXTURE_2D_ARRAY, null);
|
|
199
|
-
gl.useProgram(null);
|
|
200
|
-
ubo.unbind();
|
|
201
|
-
this.cameraUniformBlock.unbind(uniformBindingPoints.camera);
|
|
202
|
-
}
|
|
203
|
-
_getUniformBlockOffset(name) {
|
|
204
|
-
// hardcoded offsets based on std140 layout rules
|
|
205
|
-
const offsets = {
|
|
206
|
-
'u_color': 0,
|
|
207
|
-
};
|
|
208
|
-
const result = offsets[name];
|
|
209
|
-
if (result === undefined) {
|
|
210
|
-
throw new Error(`Unknown uniform block member: ${name}, names are: ${Object.keys(offsets).join(", ")}`);
|
|
211
|
-
}
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function drawOnTopBegin(gl) {
|
|
216
|
-
// gl.disable(gl.DEPTH_TEST);
|
|
217
|
-
// gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
218
|
-
// // Use an offset to "nudge" the depth value slightly closer or farther.
|
|
219
|
-
// // Common values are gl.polygonOffset(1.0, 1.0) or gl.polygonOffset(0.5, 0.5)
|
|
220
|
-
// gl.polygonOffset(1.0, 1.0);
|
|
221
|
-
// gl.depthRange(0.0, 0.0001); // Use near 0.01% of depth range
|
|
222
|
-
// gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
223
|
-
// You will need to experiment with these values!
|
|
224
|
-
// A good starting point is -1.0, -1.0.
|
|
225
|
-
// Negative values "pull" the fragments closer to the camera.
|
|
226
|
-
// gl.polygonOffset(-1.0, -1.0);
|
|
227
|
-
gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
228
|
-
gl.polygonOffset(-1.0, -2.0);
|
|
229
|
-
}
|
|
230
|
-
function drawOnTopEnd(gl) {
|
|
231
|
-
// gl.enable(gl.DEPTH_TEST);
|
|
232
|
-
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
233
|
-
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
234
|
-
// gl.depthRange(0.0, 1.0); // Restore full depth range
|
|
235
|
-
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
236
|
-
}
|
|
@@ -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
|
-
});
|