@pirireis/webglobeplugins 1.0.3 → 1.0.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/package.json +2 -2
- package/plugins/alarms/alarmFadeInFadeOutPlugin/AlarmTimeLineFadeInFadeOutPlugin.js +399 -0
- package/{Math → webglobeplugins/Math}/tessellation/triangle-tessellation.js +82 -4
- package/{heatwave → webglobeplugins/heatwave}/isobar.js +3 -0
- package/{programs → webglobeplugins/programs}/polygon-on-globe/texture-dem-triangles.js +17 -4
- package/webglobeplugins/programs/totems/attachments/adaptive-opacity.js +131 -0
- package/{programs/totems → webglobeplugins/programs/totems/attachments}/dem-textures-manager.js +11 -5
- package/{programs → webglobeplugins/programs}/vectorfields/logics/drawrectangleparticles.js +34 -28
- package/{programs → webglobeplugins/programs}/vectorfields/logics/particle-ubo.js +7 -4
- package/{programs → webglobeplugins/programs}/vectorfields/logics/pixelbased.js +3 -7
- package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/cache.js +10 -8
- package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/master-worker.js +104 -40
- package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.js +76 -0
- package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/worker-contact.js +3 -2
- package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +162 -0
- package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/terrain-polygon.js +66 -3
- package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/test-records.js +14 -0
- package/{semiplugins → webglobeplugins/semiplugins}/shell/bbox-renderer/object.js +5 -2
- package/{tracks → webglobeplugins/tracks}/timetracks/program-line-strip.js +2 -0
- package/{util → webglobeplugins/util}/gl-util/buffer/attribute-loader.js +18 -6
- package/{util → webglobeplugins/util}/gl-util/uniform-block/manager.js +13 -4
- package/{vectorfield → webglobeplugins/vectorfield}/waveparticles/plugin.js +77 -37
- package/{vectorfield → webglobeplugins/vectorfield}/wind/adapters/image-to-fields.js +46 -15
- package/{vectorfield → webglobeplugins/vectorfield}/wind/plugin-persistant.js +32 -17
- package/{vectorfield → webglobeplugins/vectorfield}/wind/plugin.js +4 -4
- package/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.js +0 -100
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +0 -125
- package/vectorfield/wind/plugin-persistant copy.js +0 -364
- package/{Math → webglobeplugins/Math}/angle-calculation.js +0 -0
- package/{Math → webglobeplugins/Math}/arc-cdf-points.js +0 -0
- package/{Math → webglobeplugins/Math}/arc-generate-points-exponantial.js +0 -0
- package/{Math → webglobeplugins/Math}/arc.js +0 -0
- package/{Math → webglobeplugins/Math}/bounds/line-bbox.js +0 -0
- package/{Math → webglobeplugins/Math}/circle-cdf-points.js +0 -0
- package/{Math → webglobeplugins/Math}/circle.js +0 -0
- package/{Math → webglobeplugins/Math}/constants.js +0 -0
- package/{Math → webglobeplugins/Math}/contour/quadtreecontours.js +0 -0
- package/{Math → webglobeplugins/Math}/contour/quadtreecontours1.js +0 -0
- package/{Math → webglobeplugins/Math}/finite-line-2d.js +0 -0
- package/{Math → webglobeplugins/Math}/haversine.js +0 -0
- package/{Math → webglobeplugins/Math}/index.js +0 -0
- package/{Math → webglobeplugins/Math}/juction/arc-plane.js +0 -0
- package/{Math → webglobeplugins/Math}/juction/line-sphere.js +0 -0
- package/{Math → webglobeplugins/Math}/juction/plane-plane.js +0 -0
- package/{Math → webglobeplugins/Math}/line.js +0 -0
- package/{Math → webglobeplugins/Math}/matrix4.js +0 -0
- package/{Math → webglobeplugins/Math}/methods.js +0 -0
- package/{Math → webglobeplugins/Math}/plane.js +0 -0
- package/{Math → webglobeplugins/Math}/quaternion.js +0 -0
- package/{Math → webglobeplugins/Math}/templete-shapes/grid-visually-equal.js +0 -0
- package/{Math → webglobeplugins/Math}/tessellation/constants.js +0 -0
- package/{Math → webglobeplugins/Math}/tessellation/methods.js +0 -0
- package/{Math → webglobeplugins/Math}/tessellation/nearest-value-padding.js +0 -0
- package/{Math → webglobeplugins/Math}/tessellation/spherical-triangle-area.js +0 -0
- package/{Math → webglobeplugins/Math}/tessellation/tile-merger.js +0 -0
- package/{Math → webglobeplugins/Math}/tessellation/types.js +0 -0
- package/{Math → webglobeplugins/Math}/types.js +0 -0
- package/{Math → webglobeplugins/Math}/utils.js +0 -0
- package/{Math → webglobeplugins/Math}/vec3.js +0 -0
- package/{Math → webglobeplugins/Math}/xyz-tile.js +0 -0
- package/{algorithms → webglobeplugins/algorithms}/search-binary.js +0 -0
- package/{altitude-locator → webglobeplugins/altitude-locator}/adaptors.js +0 -0
- package/{altitude-locator → webglobeplugins/altitude-locator}/keymethod.js +0 -0
- package/{altitude-locator → webglobeplugins/altitude-locator}/plugin.js +0 -0
- package/{altitude-locator → webglobeplugins/altitude-locator}/types.js +0 -0
- package/{compass-rose → webglobeplugins/compass-rose}/compass-rose-padding-flat.js +0 -0
- package/{compass-rose → webglobeplugins/compass-rose}/compass-text-writer.js +0 -0
- package/{compass-rose → webglobeplugins/compass-rose}/index.js +0 -0
- package/{constants.js → webglobeplugins/constants.js} +0 -0
- package/{heatwave → webglobeplugins/heatwave}/datamanager.js +0 -0
- package/{heatwave → webglobeplugins/heatwave}/heatwave.js +0 -0
- package/{heatwave → webglobeplugins/heatwave}/index.js +0 -0
- package/{heatwave → webglobeplugins/heatwave}/texture-point-sampler.js +0 -0
- package/{investigation-tools → webglobeplugins/investigation-tools}/draw/tiles/adapters.js +0 -0
- package/{investigation-tools → webglobeplugins/investigation-tools}/draw/tiles/tiles.js +0 -0
- package/{jest.config.js → webglobeplugins/jest.config.js} +0 -0
- package/{pin → webglobeplugins/pin}/pin-object-array1.js +0 -0
- package/{pin → webglobeplugins/pin}/pin-point-totem1.js +0 -0
- package/{programs → webglobeplugins/programs}/arrowfield/arrow-field.js +0 -0
- package/{programs → webglobeplugins/programs}/arrowfield/logic.js +0 -0
- package/{programs → webglobeplugins/programs}/data2legend/density-to-legend.js +0 -0
- package/{programs → webglobeplugins/programs}/data2legend/point-to-density-texture.js +0 -0
- package/{programs → webglobeplugins/programs}/float2legendwithratio/index.js +0 -0
- package/{programs → webglobeplugins/programs}/float2legendwithratio/logic.js +0 -0
- package/{programs → webglobeplugins/programs}/float2legendwithratio/object.js +0 -0
- package/{programs → webglobeplugins/programs}/helpers/blender.js +0 -0
- package/{programs → webglobeplugins/programs}/helpers/fadeaway.js +0 -0
- package/{programs → webglobeplugins/programs}/index.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/circle-accurate-3d.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/circle-accurate-flat.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/degree-padding-around-circle-3d.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/index.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/lines-color-instanced-flat.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/linestrip/data.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/linestrip/linestrip.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/naive-accurate-flexible.js +0 -0
- package/{programs → webglobeplugins/programs}/line-on-globe/util.js +0 -0
- package/{programs → webglobeplugins/programs}/picking/pickable-polygon-renderer.js +0 -0
- package/{programs → webglobeplugins/programs}/picking/pickable-renderer.js +0 -0
- package/{programs → webglobeplugins/programs}/point-on-globe/element-globe-surface-glow.js +0 -0
- package/{programs → webglobeplugins/programs}/point-on-globe/element-point-glow.js +0 -0
- package/{programs → webglobeplugins/programs}/point-on-globe/square-pixel-point.js +0 -0
- package/{programs → webglobeplugins/programs}/programcache.js +0 -0
- package/{programs → webglobeplugins/programs}/rings/index.js +0 -0
- package/{programs → webglobeplugins/programs}/rings/partial-ring/piece-of-pie.js +0 -0
- package/{programs → webglobeplugins/programs}/totems/camera-totem-attactment-interface.js +0 -0
- package/{programs → webglobeplugins/programs}/totems/camerauniformblock.js +0 -0
- package/{programs → webglobeplugins/programs}/totems/canvas-webglobe-info.js +0 -0
- package/{programs → webglobeplugins/programs}/totems/globe-changes.js +0 -0
- package/{programs → webglobeplugins/programs}/totems/gpu-selection-uniform-block.js +0 -0
- package/{programs → webglobeplugins/programs}/totems/index.js +0 -0
- package/{programs → webglobeplugins/programs}/two-d/pixel-padding-for-compass.js +0 -0
- package/{programs → webglobeplugins/programs}/util.js +0 -0
- package/{programs → webglobeplugins/programs}/vectorfields/logics/constants.js +0 -0
- package/{programs → webglobeplugins/programs}/vectorfields/logics/index.js +0 -0
- package/{programs → webglobeplugins/programs}/vectorfields/logics/ubo.js +0 -0
- package/{programs → webglobeplugins/programs}/vectorfields/pingpongbuffermanager.js +0 -0
- package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/bearing-line/adapters.js +0 -0
- package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/bearing-line/plugin.js +1 -1
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/bearing-line/types.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/circle-line-chain/adapters.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/circle-line-chain/chain-list-map.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/circle-line-chain/plugin.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/circle-line-chain/types.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/range-ring/adapters.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/range-ring/enum.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/range-ring/plugin.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/range-ring/rangeringangletext.js +0 -0
- /package/{range-tools-on-terrain → webglobeplugins/range-tools-on-terrain}/range-ring/types.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/interface.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/lightweight/line-plugin.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/lightweight/piece-of-pie-plugin.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/arc-plugin.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/circle-plugin.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/padding-1-degree.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/adapters.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/index-polygon-map.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/manager.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/random.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/data/types.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shape-on-terrain/terrain-polygon/types.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shell/bbox-renderer/index.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/shell/bbox-renderer/logic.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/type.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/utility/container-plugin.js +0 -0
- /package/{semiplugins → webglobeplugins/semiplugins}/utility/object-pass-container-plugin.js +0 -0
- /package/{shaders → webglobeplugins/shaders}/fragment-toy/firework.js +0 -0
- /package/{shaders → webglobeplugins/shaders}/fragment-toy/singularity.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/point-heat-map/index.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/point-heat-map/plugin-webworker.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/point-heat-map/point-to-heat-map-flow.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/point-tracks/key-methods.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/point-tracks/plugin.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/timetracks/adaptors-line-strip.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/timetracks/plugin-line-strip.js +0 -0
- /package/{tracks → webglobeplugins/tracks}/timetracks/programpoint-line-strip.js +0 -0
- /package/{types.js → webglobeplugins/types.js} +0 -0
- /package/{util → webglobeplugins/util}/account/bufferoffsetmanager.js +0 -0
- /package/{util → webglobeplugins/util}/account/create-buffermap-orchastration.js +0 -0
- /package/{util → webglobeplugins/util}/account/index.js +0 -0
- /package/{util → webglobeplugins/util}/account/single-attribute-buffer-management/buffer-manager.js +0 -0
- /package/{util → webglobeplugins/util}/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -0
- /package/{util → webglobeplugins/util}/account/single-attribute-buffer-management/buffer-orchestrator1.js +0 -0
- /package/{util → webglobeplugins/util}/account/single-attribute-buffer-management/index.js +0 -0
- /package/{util → webglobeplugins/util}/account/single-attribute-buffer-management/object-store.js +0 -0
- /package/{util → webglobeplugins/util}/account/single-attribute-buffer-management/types.js +0 -0
- /package/{util → webglobeplugins/util}/account/util.js +0 -0
- /package/{util → webglobeplugins/util}/algorithms/index.js +0 -0
- /package/{util → webglobeplugins/util}/algorithms/search-binary.js +0 -0
- /package/{util → webglobeplugins/util}/build-strategy/static-dynamic.js +0 -0
- /package/{util → webglobeplugins/util}/check/index.js +0 -0
- /package/{util → webglobeplugins/util}/check/typecheck.js +0 -0
- /package/{util → webglobeplugins/util}/frame-counter-trigger.js +0 -0
- /package/{util → webglobeplugins/util}/geometry/index.js +0 -0
- /package/{util → webglobeplugins/util}/gl-util/buffer/index.js +0 -0
- /package/{util → webglobeplugins/util}/gl-util/draw-options/methods.js +0 -0
- /package/{util → webglobeplugins/util}/globe-default-gl-states.js +0 -0
- /package/{util → webglobeplugins/util}/helper-methods.js +0 -0
- /package/{util → webglobeplugins/util}/index.js +0 -0
- /package/{util → webglobeplugins/util}/interpolation/index.js +0 -0
- /package/{util → webglobeplugins/util}/interpolation/timetrack/index.js +0 -0
- /package/{util → webglobeplugins/util}/interpolation/timetrack/timetrack-interpolator.js +0 -0
- /package/{util → webglobeplugins/util}/interpolation/timetrack/web-worker.js +0 -0
- /package/{util → webglobeplugins/util}/picking/fence.js +0 -0
- /package/{util → webglobeplugins/util}/picking/picker-displayer.js +0 -0
- /package/{util → webglobeplugins/util}/programs/draw-from-pixel-coords.js +0 -0
- /package/{util → webglobeplugins/util}/programs/draw-texture-on-canvas.js +0 -0
- /package/{util → webglobeplugins/util}/programs/supersampletotextures.js +0 -0
- /package/{util/programs/texturetoglobe.js → webglobeplugins/util/programs/texturetoglobe_delete.js} +0 -0
- /package/{util → webglobeplugins/util}/shaderfunctions/geometrytransformations.js +0 -0
- /package/{util → webglobeplugins/util}/shaderfunctions/index.js +0 -0
- /package/{util → webglobeplugins/util}/shaderfunctions/nodata.js +0 -0
- /package/{util → webglobeplugins/util}/shaderfunctions/noisefunctions.js +0 -0
- /package/{util → webglobeplugins/util}/webglobjectbuilders.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/arrowfield/adaptor.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/arrowfield/index.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/arrowfield/plugin.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/waveparticles/adaptor.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/waveparticles/index.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/wind/adapters/types.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/wind/imagetovectorfieldandmagnitude.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/wind/index.js +0 -0
- /package/{vectorfield → webglobeplugins/vectorfield}/wind/vectorfieldimage.js +0 -0
- /package/{write-text → webglobeplugins/write-text}/context-text-bulk.js +0 -0
- /package/{write-text → webglobeplugins/write-text}/context-text3.js +0 -0
- /package/{write-text → webglobeplugins/write-text}/context-text4.js +0 -0
- /package/{write-text → webglobeplugins/write-text}/context-textDELETE.js +0 -0
- /package/{write-text → webglobeplugins/write-text}/objectarraylabels/index.js +0 -0
- /package/{write-text → webglobeplugins/write-text}/objectarraylabels/objectarraylabels.js +0 -0
package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Purpose
|
|
3
|
+
* Divide long edges of polygons into smaller segments
|
|
4
|
+
*
|
|
5
|
+
* This algorithm should be called after earcutting / triangulation.
|
|
6
|
+
* Then earcut should run second time to further divide long edges.
|
|
7
|
+
*
|
|
8
|
+
* populate points on a arc between two given points on a sphere
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
import earcut from "earcut";
|
|
12
|
+
function _isReal(a, b, len) {
|
|
13
|
+
return (Math.abs(a - b) === 1 || Math.abs(a - b) === len);
|
|
14
|
+
}
|
|
15
|
+
function edgeKey(a, b) {
|
|
16
|
+
// undirected edge key
|
|
17
|
+
return a < b ? `${a},${b}` : `${b},${a}`;
|
|
18
|
+
}
|
|
19
|
+
export function calculateRealEdges(geom, indeces) {
|
|
20
|
+
const realEdges = [];
|
|
21
|
+
const boundaryEdges = new Set();
|
|
22
|
+
// Build boundary edges for all geometries, using a running vertex offset
|
|
23
|
+
// (must match how triangulation() concatenates vertices and offsets indices).
|
|
24
|
+
let vertexIndexOffset = 0;
|
|
25
|
+
for (const g of geom) {
|
|
26
|
+
const vertexCount = g.vertices.length / 2;
|
|
27
|
+
if (!Number.isInteger(vertexCount) || vertexCount <= 1) {
|
|
28
|
+
vertexIndexOffset += vertexCount; // still advance consistently
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// Build rings: [0..holes[0]), [holes[0]..holes[1]), ... , [holes[last]..vertexCount)
|
|
32
|
+
const ringStarts = [0, ...(g.holes ?? [])];
|
|
33
|
+
const ringEnds = [...(g.holes ?? []), vertexCount];
|
|
34
|
+
for (let r = 0; r < ringStarts.length; r++) {
|
|
35
|
+
const start = ringStarts[r];
|
|
36
|
+
const end = ringEnds[r];
|
|
37
|
+
if (end - start < 2)
|
|
38
|
+
continue;
|
|
39
|
+
for (let i = start; i < end - 1; i++) {
|
|
40
|
+
boundaryEdges.add(edgeKey(vertexIndexOffset + i, vertexIndexOffset + i + 1));
|
|
41
|
+
}
|
|
42
|
+
// close the ring
|
|
43
|
+
boundaryEdges.add(edgeKey(vertexIndexOffset + (end - 1), vertexIndexOffset + start));
|
|
44
|
+
}
|
|
45
|
+
vertexIndexOffset += vertexCount;
|
|
46
|
+
}
|
|
47
|
+
// Mark each triangle edge as "real" iff it belongs to any boundary ring edge
|
|
48
|
+
for (let i = 0; i < indeces.length; i += 3) {
|
|
49
|
+
const a = indeces[i];
|
|
50
|
+
const b = indeces[i + 1];
|
|
51
|
+
const c = indeces[i + 2];
|
|
52
|
+
realEdges.push(boundaryEdges.has(edgeKey(a, b)));
|
|
53
|
+
realEdges.push(boundaryEdges.has(edgeKey(b, c)));
|
|
54
|
+
realEdges.push(boundaryEdges.has(edgeKey(c, a)));
|
|
55
|
+
}
|
|
56
|
+
return realEdges;
|
|
57
|
+
}
|
|
58
|
+
function triangulation(polygon) {
|
|
59
|
+
const finalVertices = [];
|
|
60
|
+
const finalIndices = [];
|
|
61
|
+
let vertexIndexOffset = 0;
|
|
62
|
+
for (const geom of polygon.geometry) {
|
|
63
|
+
const indices = earcut(geom.vertices, geom.holes, 2);
|
|
64
|
+
finalVertices.push(...geom.vertices);
|
|
65
|
+
for (const index of indices) {
|
|
66
|
+
finalIndices.push(index + vertexIndexOffset);
|
|
67
|
+
}
|
|
68
|
+
vertexIndexOffset += geom.vertices.length / 2;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
key: polygon.key,
|
|
72
|
+
vertices: finalVertices,
|
|
73
|
+
indices: finalIndices,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export { triangulation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DemTextureManagerCache } from "../../../../programs/totems/dem-textures-manager";
|
|
1
|
+
import { DemTextureManagerCache } from "../../../../programs/totems/attachments/dem-textures-manager";
|
|
2
2
|
import { RADIAN } from "../../../../Math/methods";
|
|
3
3
|
export class WorkerContact {
|
|
4
4
|
_masterWorker;
|
|
@@ -10,12 +10,13 @@ export class WorkerContact {
|
|
|
10
10
|
this.onResult = onResult;
|
|
11
11
|
// Initialize the Master Worker
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
this._masterWorker = new Worker(new URL("./master-worker.
|
|
13
|
+
this._masterWorker = new Worker(new URL("./master-worker.ts", import.meta.url), { type: 'module' });
|
|
14
14
|
this._masterWorker.onmessage = (event) => {
|
|
15
15
|
this.onResult(event.data);
|
|
16
16
|
};
|
|
17
17
|
// Initialize Master Worker state
|
|
18
18
|
this._masterWorker.postMessage({
|
|
19
|
+
arcState: this._options.drawEdges,
|
|
19
20
|
pickableState: this._options.pickable,
|
|
20
21
|
variativeColorsOn: this._options.variativeColorsOn,
|
|
21
22
|
insertDeleteQueue: [],
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
2
|
+
/* eslint-disable no-restricted-globals */
|
|
3
|
+
import { Cache } from "./cache";
|
|
4
|
+
import { partialTessellation, uint32Escape, zoomLevelShowThreshold } from "../../../../Math/tessellation/triangle-tessellation";
|
|
5
|
+
const cache = new Cache();
|
|
6
|
+
let _pickableState = false;
|
|
7
|
+
let _arcState = false;
|
|
8
|
+
let _variativeColorsOnState = false;
|
|
9
|
+
let showThreshold = 0;
|
|
10
|
+
const NO_COLOR_ALPHA = 255;
|
|
11
|
+
const MAX_ALPHA_VALUE = 254;
|
|
12
|
+
function clamp01(value) {
|
|
13
|
+
if (!Number.isFinite(value))
|
|
14
|
+
return 0;
|
|
15
|
+
return Math.max(0, Math.min(1, value));
|
|
16
|
+
}
|
|
17
|
+
function colorToBytes(color) {
|
|
18
|
+
if (!color)
|
|
19
|
+
return [0, 0, 0, NO_COLOR_ALPHA];
|
|
20
|
+
const r = Math.round(clamp01(color[0]) * 255);
|
|
21
|
+
const g = Math.round(clamp01(color[1]) * 255);
|
|
22
|
+
const b = Math.round(clamp01(color[2]) * 255);
|
|
23
|
+
// Reserve 255 for "no color" sentinel.
|
|
24
|
+
const a = Math.round(clamp01(color[3]) * MAX_ALPHA_VALUE);
|
|
25
|
+
return [r, g, b, a];
|
|
26
|
+
}
|
|
27
|
+
self.onmessage = (event) => {
|
|
28
|
+
try {
|
|
29
|
+
const { bboxes, insertDeleteQueue, pickableState, variativeColorsOn, arcState } = event.data;
|
|
30
|
+
if (variativeColorsOn !== undefined) {
|
|
31
|
+
_variativeColorsOnState = variativeColorsOn;
|
|
32
|
+
}
|
|
33
|
+
if (pickableState !== undefined) {
|
|
34
|
+
_pickableState = pickableState;
|
|
35
|
+
}
|
|
36
|
+
if (arcState !== undefined) {
|
|
37
|
+
_arcState = arcState;
|
|
38
|
+
}
|
|
39
|
+
// Process insert/delete queue
|
|
40
|
+
if (insertDeleteQueue && insertDeleteQueue.length > 0) {
|
|
41
|
+
if (insertDeleteQueue[0] === "__CLEAR_ALL_ITEMS__") {
|
|
42
|
+
insertDeleteQueue.shift();
|
|
43
|
+
cache.clear();
|
|
44
|
+
}
|
|
45
|
+
for (const item of insertDeleteQueue) {
|
|
46
|
+
if (typeof item === "string") {
|
|
47
|
+
cache.remove(item);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
cache.insert(item.key, item);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Update bboxes if provided
|
|
55
|
+
if (bboxes) {
|
|
56
|
+
cache.setBBOXes(bboxes);
|
|
57
|
+
if (bboxes.length > 0) {
|
|
58
|
+
showThreshold = zoomLevelShowThreshold(bboxes[0].zoom, 0.05);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const trianglesInView = cache.search();
|
|
62
|
+
const results = [];
|
|
63
|
+
// Convert bbox to BBoxZoom format for partialTessellation
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
const bboxZooms = bboxes
|
|
66
|
+
? bboxes.map((b) => ({
|
|
67
|
+
bbox: {
|
|
68
|
+
min: [b.minX, b.minY],
|
|
69
|
+
max: [b.maxX, b.maxY],
|
|
70
|
+
},
|
|
71
|
+
zoom: b.zoom,
|
|
72
|
+
}))
|
|
73
|
+
: [];
|
|
74
|
+
let counter = 0;
|
|
75
|
+
let indexCounter = 0;
|
|
76
|
+
let arcCounter = 0;
|
|
77
|
+
for (const triangle of trianglesInView) {
|
|
78
|
+
if (triangle.tessellationMeta.showThreshold * 0.075 > showThreshold) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const tessResult = triangle.tessellationMeta.showThreshold < showThreshold
|
|
82
|
+
? partialTessellation(triangle.tessellationMeta, bboxZooms, 5, _arcState)
|
|
83
|
+
: triangle.tessellationMeta.shortCut;
|
|
84
|
+
const result = {
|
|
85
|
+
vec3s: tessResult.vec3s,
|
|
86
|
+
indices: tessResult.indices,
|
|
87
|
+
longLats: tessResult.longLats,
|
|
88
|
+
realEdgeArcIndices: _arcState ? tessResult.realEdgeArcIndices : null,
|
|
89
|
+
};
|
|
90
|
+
counter += result.vec3s.length;
|
|
91
|
+
indexCounter += result.indices.length;
|
|
92
|
+
if (_pickableState) {
|
|
93
|
+
result.pickIndex = triangle.polygon.index;
|
|
94
|
+
}
|
|
95
|
+
if (_arcState) {
|
|
96
|
+
arcCounter += result.realEdgeArcIndices ? result.realEdgeArcIndices.length : 0;
|
|
97
|
+
}
|
|
98
|
+
if (_variativeColorsOnState) {
|
|
99
|
+
result.variativeColors = colorToBytes(triangle.polygon.color);
|
|
100
|
+
}
|
|
101
|
+
results.push(result);
|
|
102
|
+
}
|
|
103
|
+
const totalArcCount = arcCounter;
|
|
104
|
+
const output = {
|
|
105
|
+
vec3s: new Float32Array(counter),
|
|
106
|
+
longLats: new Float32Array((counter / 3) * 2),
|
|
107
|
+
indices: new Uint32Array(indexCounter),
|
|
108
|
+
realEdgeArcIndices: _arcState ? new Uint32Array(totalArcCount) : null,
|
|
109
|
+
pickIndices: _pickableState ? new Float32Array(counter / 3) : null,
|
|
110
|
+
variativeColors: _variativeColorsOnState ? new Uint8Array((counter / 3) * 4) : null,
|
|
111
|
+
};
|
|
112
|
+
let currentVertexOffset = 0;
|
|
113
|
+
let indexOffset = 0;
|
|
114
|
+
let arcOffset = 0;
|
|
115
|
+
for (const result of results) {
|
|
116
|
+
output.vec3s.set(result.vec3s, currentVertexOffset);
|
|
117
|
+
output.longLats.set(result.longLats, (currentVertexOffset / 3) * 2);
|
|
118
|
+
const startVertex = currentVertexOffset / 3;
|
|
119
|
+
for (let i = 0; i < result.indices.length; i++) {
|
|
120
|
+
output.indices[indexOffset + i] = result.indices[i] + startVertex;
|
|
121
|
+
}
|
|
122
|
+
const vertexCount = result.vec3s.length / 3;
|
|
123
|
+
currentVertexOffset += result.vec3s.length;
|
|
124
|
+
indexOffset += result.indices.length;
|
|
125
|
+
if (_pickableState && output.pickIndices && result.pickIndex !== undefined) {
|
|
126
|
+
output.pickIndices.fill(result.pickIndex, startVertex, startVertex + vertexCount);
|
|
127
|
+
}
|
|
128
|
+
if (_variativeColorsOnState && output.variativeColors && result.variativeColors) {
|
|
129
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
130
|
+
const o = (startVertex + i) * 4;
|
|
131
|
+
output.variativeColors[o + 0] = result.variativeColors[0];
|
|
132
|
+
output.variativeColors[o + 1] = result.variativeColors[1];
|
|
133
|
+
output.variativeColors[o + 2] = result.variativeColors[2];
|
|
134
|
+
output.variativeColors[o + 3] = result.variativeColors[3];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (_arcState && output.realEdgeArcIndices && result.realEdgeArcIndices) {
|
|
138
|
+
for (let i = 0; i < result.realEdgeArcIndices.length; i++) {
|
|
139
|
+
const value = result.realEdgeArcIndices[i];
|
|
140
|
+
if (value === uint32Escape) {
|
|
141
|
+
output.realEdgeArcIndices[arcOffset + i] = uint32Escape;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
output.realEdgeArcIndices[arcOffset + i] = value + startVertex;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
arcOffset += result.realEdgeArcIndices.length;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const buffers = [output.vec3s.buffer, output.indices.buffer, output.longLats.buffer];
|
|
151
|
+
if (_arcState && output.realEdgeArcIndices)
|
|
152
|
+
buffers.push(output.realEdgeArcIndices.buffer);
|
|
153
|
+
if (_pickableState && output.pickIndices)
|
|
154
|
+
buffers.push(output.pickIndices.buffer);
|
|
155
|
+
if (_variativeColorsOnState && output.variativeColors)
|
|
156
|
+
buffers.push(output.variativeColors.buffer);
|
|
157
|
+
self.postMessage(output, buffers);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error("Error in worker:", error);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
@@ -3,10 +3,12 @@ import { TextureDemTriangles } from "../../../programs/polygon-on-globe/texture-
|
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../../../programs/programcache";
|
|
4
4
|
import { PickerDisplayer } from "../../../util/picking/picker-displayer";
|
|
5
5
|
import { IndexPolygonMap } from "./data/index-polygon-map";
|
|
6
|
+
import { TestRecords } from "./test-records";
|
|
6
7
|
export class TerrainPolygonSemiPlugin {
|
|
7
8
|
id;
|
|
8
9
|
globe = null;
|
|
9
10
|
_options = {
|
|
11
|
+
drawEdges: true,
|
|
10
12
|
pickable: false,
|
|
11
13
|
variativeColorsOn: false,
|
|
12
14
|
defaultColor: [0.5, 0.5, 1, 1],
|
|
@@ -26,6 +28,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
26
28
|
_mercatorXYBuffer = null;
|
|
27
29
|
_vao = null;
|
|
28
30
|
_uboHandler = null;
|
|
31
|
+
_uboForRealEdgeArcs = null;
|
|
29
32
|
_drawPointsRangeIndexParams = {
|
|
30
33
|
drawRange: {
|
|
31
34
|
first: 0,
|
|
@@ -35,6 +38,15 @@ export class TerrainPolygonSemiPlugin {
|
|
|
35
38
|
elementBufferIndexType: WebGL2RenderingContext.UNSIGNED_INT,
|
|
36
39
|
elementBuffer: WebGLBuffer = null,
|
|
37
40
|
};
|
|
41
|
+
_drawRealEdgeArcs = {
|
|
42
|
+
drawRange: {
|
|
43
|
+
first: 0,
|
|
44
|
+
count: 0,
|
|
45
|
+
},
|
|
46
|
+
drawMode: WebGL2RenderingContext.LINE_STRIP,
|
|
47
|
+
elementBufferIndexType: WebGL2RenderingContext.UNSIGNED_INT,
|
|
48
|
+
elementBuffer: WebGLBuffer = null,
|
|
49
|
+
};
|
|
38
50
|
_drawRangeIndexParams = {
|
|
39
51
|
drawRange: {
|
|
40
52
|
first: 0,
|
|
@@ -47,6 +59,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
47
59
|
constructor(id, options = {}) {
|
|
48
60
|
this.id = id;
|
|
49
61
|
this._options = { ...this._options, ...options };
|
|
62
|
+
console.log("TerrainPolygonSemiPlugin options:", this._options);
|
|
50
63
|
}
|
|
51
64
|
;
|
|
52
65
|
init(globe, gl) {
|
|
@@ -66,6 +79,12 @@ export class TerrainPolygonSemiPlugin {
|
|
|
66
79
|
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
|
|
67
80
|
this._uboHandler.updateSingle("pickedColor", new Float32Array(this._options.pickedColor));
|
|
68
81
|
}
|
|
82
|
+
if (this._options.drawEdges) {
|
|
83
|
+
this._uboForRealEdgeArcs = this._program.createUBO();
|
|
84
|
+
this._uboForRealEdgeArcs.updateSingle("defaultColor", new Float32Array([1, 1, 0, 1]));
|
|
85
|
+
this._uboForRealEdgeArcs.updateSingle("dontUseColor", new Float32Array([1]));
|
|
86
|
+
this._drawRealEdgeArcs.elementBuffer = gl.createBuffer();
|
|
87
|
+
}
|
|
69
88
|
if (this._options.variativeColorsOn) {
|
|
70
89
|
this._variativeColorBuffer = gl.createBuffer();
|
|
71
90
|
}
|
|
@@ -96,9 +115,10 @@ export class TerrainPolygonSemiPlugin {
|
|
|
96
115
|
}
|
|
97
116
|
insertBulk(polygons) {
|
|
98
117
|
// if (this._indexPolygonMap) {
|
|
99
|
-
|
|
118
|
+
let filteredPolygons = polygons.filter(inputCheck);
|
|
119
|
+
filteredPolygons = this._indexPolygonMap.insertBulk(filteredPolygons);
|
|
100
120
|
// }
|
|
101
|
-
this._workerContact.insertBulk(
|
|
121
|
+
this._workerContact.insertBulk(filteredPolygons);
|
|
102
122
|
}
|
|
103
123
|
deleteBulk(keys) {
|
|
104
124
|
this._workerContact.deleteBulk(keys);
|
|
@@ -122,11 +142,11 @@ export class TerrainPolygonSemiPlugin {
|
|
|
122
142
|
if (this._options.opacity !== opacity) {
|
|
123
143
|
this._options.opacity = opacity;
|
|
124
144
|
this._uboHandler.updateSingle("opacity", new Float32Array([opacity]));
|
|
145
|
+
this._uboForRealEdgeArcs?.updateSingle("opacity", new Float32Array([opacity]));
|
|
125
146
|
this.globe.DrawRender();
|
|
126
147
|
}
|
|
127
148
|
}
|
|
128
149
|
setBuffers(data) {
|
|
129
|
-
console.log("TerrainPolygonSemiPlugin updating buffers", data.indices.length / 3, "triangles");
|
|
130
150
|
const gl = this.globe.gl;
|
|
131
151
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._elementArrayBuffer);
|
|
132
152
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data.indices, gl.STREAM_DRAW);
|
|
@@ -142,6 +162,14 @@ export class TerrainPolygonSemiPlugin {
|
|
|
142
162
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._variativeColorBuffer);
|
|
143
163
|
gl.bufferData(gl.ARRAY_BUFFER, data.variativeColors, gl.STREAM_DRAW);
|
|
144
164
|
}
|
|
165
|
+
if (this._options.drawEdges && data.realEdgeArcIndices) {
|
|
166
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._drawRealEdgeArcs.elementBuffer);
|
|
167
|
+
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data.realEdgeArcIndices, gl.STREAM_DRAW);
|
|
168
|
+
this._drawRealEdgeArcs.drawRange.count = data.realEdgeArcIndices.length;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this._drawRealEdgeArcs.drawRange.count = 0;
|
|
172
|
+
}
|
|
145
173
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
146
174
|
this._drawRangeIndexParams.drawRange.count = data.indices.length;
|
|
147
175
|
this._drawPointsRangeIndexParams.drawRange.count = data.indices.length;
|
|
@@ -210,10 +238,45 @@ export class TerrainPolygonSemiPlugin {
|
|
|
210
238
|
this._pickerDisplayer.drawColorTexture();
|
|
211
239
|
this._selfSelect();
|
|
212
240
|
}
|
|
241
|
+
if (this._options.drawEdges) {
|
|
242
|
+
gl.disable(gl.DEPTH_TEST);
|
|
243
|
+
// gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
244
|
+
// gl.polygonOffset(-3.0, -3.0);
|
|
245
|
+
this._program.draw(this._vao, this._drawRealEdgeArcs, this._uboForRealEdgeArcs);
|
|
246
|
+
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
247
|
+
}
|
|
213
248
|
gl.enable(gl.DEPTH_TEST);
|
|
214
249
|
}
|
|
215
250
|
free() {
|
|
216
251
|
this._workerContact.free();
|
|
217
252
|
noRegisterGlobeProgramCache.releaseProgram(this.globe, TextureDemTriangles);
|
|
218
253
|
}
|
|
254
|
+
loadTest(recordName) {
|
|
255
|
+
if (!TestRecords.has(recordName)) {
|
|
256
|
+
console.warn(`Test record ${recordName} not found.`);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
this.insertBulk(TestRecords.get(recordName));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function inputCheck(input) {
|
|
265
|
+
if (!input.geometry || !Array.isArray(input.geometry) || input.geometry.length === 0) {
|
|
266
|
+
console.warn("Invalid polygon input: geometry is required and must be a non-empty array.");
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
// lat and long should be in range
|
|
270
|
+
for (const geom of input.geometry) {
|
|
271
|
+
const vertices = geom.vertices;
|
|
272
|
+
for (let i = 0; i < vertices.length / 2; i++) {
|
|
273
|
+
const lon = vertices[i * 2];
|
|
274
|
+
const lat = vertices[i * 2 + 1];
|
|
275
|
+
if (lon < -180 || lon > 180 || lat < -90 || lat > 90) {
|
|
276
|
+
console.warn(`Invalid polygon input: longitude ${lon} or latitude ${lat} out of range.`);
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return true;
|
|
219
282
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const rect2 = {
|
|
2
|
+
key: "2 rectangles",
|
|
3
|
+
geometry: [
|
|
4
|
+
{
|
|
5
|
+
vertices: [-5, -5, -5, 0, 0, 0, 0, -5],
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
vertices: [-15, -15, -15, -10, -10, -10, -10, -15],
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
export const TestRecords = new Map([
|
|
13
|
+
["2 rectangles", [rect2]],
|
|
14
|
+
]);
|
|
@@ -4,7 +4,6 @@ export class BBOXGlobeShell {
|
|
|
4
4
|
globe;
|
|
5
5
|
program;
|
|
6
6
|
shellBlockManager;
|
|
7
|
-
update;
|
|
8
7
|
innerTime;
|
|
9
8
|
texture;
|
|
10
9
|
bbox;
|
|
@@ -15,7 +14,6 @@ export class BBOXGlobeShell {
|
|
|
15
14
|
this.globe = globe;
|
|
16
15
|
this.program = BBOXGlobeShellProgramCache.get(globe);
|
|
17
16
|
this.shellBlockManager = this.program.getShellBlockBufferManager();
|
|
18
|
-
this.update = this.shellBlockManager.update.bind(this.shellBlockManager);
|
|
19
17
|
this.innerTime = 0;
|
|
20
18
|
this.wiggleInKM = wiggleInKM;
|
|
21
19
|
this.wiggleSpeed = wiggleSpeed;
|
|
@@ -32,6 +30,11 @@ export class BBOXGlobeShell {
|
|
|
32
30
|
this.shellBlockManager.update({ height });
|
|
33
31
|
this.globe.DrawRender();
|
|
34
32
|
}
|
|
33
|
+
// public update(data: any): void {
|
|
34
|
+
// console.log("BBOXGlobeShell update", data);
|
|
35
|
+
// this.shellBlockManager.update(data);
|
|
36
|
+
// this.globe.DrawRender();
|
|
37
|
+
// }
|
|
35
38
|
setOpacity(opacity) {
|
|
36
39
|
this.shellBlockManager.update({ opacity });
|
|
37
40
|
this.globe.DrawRender();
|
|
@@ -538,6 +538,7 @@ void main() {
|
|
|
538
538
|
this._resetTexture();
|
|
539
539
|
gl.enable(gl.BLEND);
|
|
540
540
|
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
541
|
+
// if (this.sample_alpha_to_covarage) gl.enable(gl.SAMPLE_ALPHA_TO_COVERAGE);
|
|
541
542
|
// draw lines
|
|
542
543
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
543
544
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._middleTexture, 0);
|
|
@@ -585,6 +586,7 @@ void main() {
|
|
|
585
586
|
gl.bindTexture(gl.TEXTURE_2D, this._middleTexture);
|
|
586
587
|
gl.uniform1i(this._combineProgram.u_main_texture, 0);
|
|
587
588
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
589
|
+
// if (this.sample_alpha_to_covarage) gl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE);
|
|
588
590
|
gl.bindVertexArray(null);
|
|
589
591
|
defaultblendfunction(gl);
|
|
590
592
|
}
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* @param {Array<number>} options.escapeValues
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, type = null, escapeValues = null, normalized = false } = {}) => {
|
|
21
|
+
const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, type = null, escapeValues = null, normalized = false, integer = false, integerUnsigned = true, } = {}) => {
|
|
22
22
|
if (bufferAndReadInfo == null || bufferAndReadInfo.buffer == null) {
|
|
23
23
|
if (escapeValues)
|
|
24
|
-
constantFunction(gl, index, size, escapeValues);
|
|
24
|
+
constantFunction(gl, index, size, escapeValues, integer, integerUnsigned);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
const { buffer, stride, offset } = bufferAndReadInfo;
|
|
@@ -37,7 +37,12 @@ const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, t
|
|
|
37
37
|
const attribType = type === null ? gl.FLOAT : type;
|
|
38
38
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
39
39
|
gl.enableVertexAttribArray(index);
|
|
40
|
-
|
|
40
|
+
if (integer) {
|
|
41
|
+
gl.vertexAttribIPointer(index, size, attribType, stride, offset);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
gl.vertexAttribPointer(index, size, attribType, normalized, stride, offset);
|
|
45
|
+
}
|
|
41
46
|
if (divisor !== null) {
|
|
42
47
|
gl.vertexAttribDivisor(index, divisor);
|
|
43
48
|
}
|
|
@@ -54,9 +59,16 @@ const createBufferAndReadInfo = (buffer, stride = 0, offset = 0) => {
|
|
|
54
59
|
return null;
|
|
55
60
|
return { buffer, stride, offset };
|
|
56
61
|
};
|
|
57
|
-
const constantFunction = (gl, index, size, escapeValues) => {
|
|
58
|
-
|
|
62
|
+
const constantFunction = (gl, index, size, escapeValues, integer, integerUnsigned) => {
|
|
63
|
+
if (!integer) {
|
|
64
|
+
const func = `vertexAttrib${size}f`;
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
gl[func](index, ...escapeValues);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const values = escapeValues.map((v) => Math.trunc(v));
|
|
70
|
+
const func = integerUnsigned ? `vertexAttribI${size}ui` : `vertexAttribI${size}i`;
|
|
59
71
|
// @ts-ignore
|
|
60
|
-
gl[func](index, ...
|
|
72
|
+
gl[func](index, ...values);
|
|
61
73
|
};
|
|
62
74
|
export { attributeLoader, createBufferAndReadInfo };
|
|
@@ -92,7 +92,8 @@ export class UniformBlockManager {
|
|
|
92
92
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
93
93
|
// @ts-ignore
|
|
94
94
|
gl.bufferData(gl.UNIFORM_BUFFER, this.size, gl[bufferWriteType]);
|
|
95
|
-
|
|
95
|
+
// bind to the configured binding point, not zero
|
|
96
|
+
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, ubo);
|
|
96
97
|
for (const member of this.blockMembers) {
|
|
97
98
|
const { name, type, value = null } = member;
|
|
98
99
|
;
|
|
@@ -193,8 +194,16 @@ export class UniformBlockManager {
|
|
|
193
194
|
}
|
|
194
195
|
// __create_LayoutSTD140_OffsetMap() should be called before this
|
|
195
196
|
__calculateSize() {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
// compute size as last member's offset + its actual std140 size,
|
|
198
|
+
// then round the total block size up to a 16-byte multiple per std140.
|
|
199
|
+
if (this.blockMembers.length === 0)
|
|
200
|
+
return 0;
|
|
201
|
+
const names = Array.from(this.offsetMap.keys());
|
|
202
|
+
const lastName = names[names.length - 1];
|
|
203
|
+
const lastOffset = this.offsetMap.get(lastName);
|
|
204
|
+
const lastType = this.blockMembers[this.blockMembers.length - 1].type;
|
|
205
|
+
const rawSize = lastOffset + typeSizes[lastType];
|
|
206
|
+
const paddedSize = (rawSize + 15) & ~15; // round up to multiple of 16
|
|
207
|
+
return paddedSize;
|
|
199
208
|
}
|
|
200
209
|
}
|