@pirireis/webglobeplugins 0.9.9 → 0.9.11
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 +15 -0
- package/Math/arc.js +65 -0
- package/Math/bounds/line-bbox.js +190 -0
- package/Math/constants.js +9 -0
- package/Math/frustum/camera.js +24 -0
- package/Math/frustum/from-globeinfo.js +48 -0
- package/Math/frustum/types.js +2 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/index.js +1 -0
- package/Math/juction/arc-plane.js +83 -0
- package/Math/juction/line-sphere.js +25 -0
- package/Math/juction/plane-plane.js +58 -0
- package/Math/line.js +58 -0
- package/Math/matrix4.js +1 -0
- package/Math/methods.js +206 -0
- package/Math/plane.js +62 -0
- package/Math/quaternion.js +108 -0
- package/Math/types.js +2 -0
- package/Math/utils.js +4 -0
- package/Math/vec3.js +129 -0
- package/algorithms/search-binary.js +19 -0
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/draw-subset-obj.js +19 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +357 -0
- package/altitude-locator/types.js +23 -0
- package/arrowfield/adaptor.js +15 -0
- package/arrowfield/index.js +10 -0
- package/arrowfield/plugin.js +89 -0
- package/bearing-line/index.js +8 -0
- package/bearing-line/plugin.js +474 -0
- package/circle-line-chain/chain-list-map.js +211 -0
- package/circle-line-chain/init.js +1 -0
- package/circle-line-chain/plugin.js +449 -0
- package/circle-line-chain/util.js +5 -0
- package/compass-rose/compass-rose-padding-flat.js +247 -0
- package/compass-rose/compass-text-writer.js +161 -0
- package/compass-rose/index.js +7 -0
- package/compassrose/compassrose.js +300 -0
- package/compassrose/index.js +8 -0
- package/globe-types.js +1 -0
- package/heatwave/index.js +10 -0
- package/heatwave/isobar/objectarraylabels.js +206 -0
- package/heatwave/isobar/plugin.js +362 -0
- package/heatwave/isobar/quadtreecontours.js +316 -0
- package/heatwave/plugins/heatwaveglobeshell.js +224 -0
- package/index.js +11 -11
- package/jest.config.js +7 -0
- package/package.json +4 -4
- package/partialrings/buffer-manager.js +113 -0
- package/partialrings/index.js +41 -0
- package/partialrings/plugin.js +171 -0
- package/partialrings/program.js +197 -0
- package/pin/pin-object-array.js +308 -0
- package/pin/pin-point-totem.js +61 -0
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
- package/point-heat-map/index.js +1 -0
- package/point-heat-map/plugin-webworker.js +131 -0
- package/point-heat-map/point-to-heat-map-flow.js +129 -0
- package/point-tracks/key-methods.js +5 -0
- package/point-tracks/plugin.js +353 -0
- package/programs/arrowfield/index.js +7 -0
- package/programs/arrowfield/logic.js +149 -0
- package/programs/arrowfield/object.js +68 -0
- package/programs/data2legend/density-to-legend.js +77 -0
- package/programs/data2legend/point-to-density-texture.js +75 -0
- package/programs/float2legendwithratio/index.js +8 -0
- package/programs/float2legendwithratio/logic.js +125 -0
- package/programs/float2legendwithratio/object.js +113 -0
- package/programs/globe-util/is-globe-moved.js +22 -0
- package/programs/globeshell/index.js +8 -0
- package/programs/globeshell/noise/noises.js +1 -0
- package/programs/globeshell/wiggle/index.js +8 -0
- package/programs/globeshell/wiggle/logic.js +252 -0
- package/programs/globeshell/wiggle/object.js +74 -0
- package/programs/helpers/blender/index.js +1 -0
- package/programs/helpers/blender/program.js +62 -0
- package/programs/helpers/fadeaway/index.js +7 -0
- package/programs/helpers/fadeaway/logic.js +50 -0
- package/programs/helpers/fadeaway/object.js +21 -0
- package/programs/helpers/index.js +8 -0
- package/programs/index.js +58 -0
- package/programs/interface.js +1 -0
- package/programs/line-on-globe/angled-line.js +117 -0
- package/programs/line-on-globe/circle-accurate-3d.js +91 -0
- package/programs/line-on-globe/circle-accurate-flat.js +158 -0
- package/programs/line-on-globe/circle-accurate.js +108 -0
- package/programs/line-on-globe/circle.js +102 -0
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +109 -0
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +91 -0
- package/programs/line-on-globe/linestrip.js +110 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +125 -0
- package/programs/line-on-globe/to-the-surface.js +82 -0
- package/programs/line-on-globe/util.js +8 -0
- package/programs/picking/pickable-renderer.js +104 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +102 -0
- package/programs/point-on-globe/element-point-glow.js +85 -0
- package/programs/point-on-globe/square-pixel-point.js +125 -0
- package/programs/programcache.js +131 -0
- package/programs/rings/distancering/circleflatprogram.js +114 -0
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +358 -0
- package/programs/rings/distancering/circlepaddysharedbuffer.js +433 -0
- package/programs/rings/distancering/index.js +14 -0
- package/programs/rings/distancering/paddyflatprogram.js +119 -0
- package/programs/rings/distancering/paddyflatprogram2d.js +121 -0
- package/programs/rings/distancering/paddyflatprogram3d.js +119 -0
- package/programs/rings/distancering/shader.js +1 -0
- package/programs/rings/index.js +17 -0
- package/programs/rings/partial-ring/piece-of-pie.js +173 -0
- package/programs/totems/camerauniformblock.js +147 -0
- package/programs/totems/canvas-webglobe-info.js +102 -0
- package/programs/totems/gpu-selection-uniform-block.js +104 -0
- package/programs/totems/index.js +40 -0
- package/programs/two-d/pixel-circle.js +1 -0
- package/programs/two-d/pixel-padding-for-compass.js +101 -0
- package/programs/util.js +18 -0
- package/programs/vectorfields/index.js +23 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +66 -0
- package/programs/vectorfields/logics/index.js +12 -0
- package/programs/vectorfields/logics/pixelbased.js +86 -0
- package/programs/vectorfields/logics/ubo.js +57 -0
- package/programs/vectorfields/pingpongbuffermanager.js +80 -0
- package/rangerings/enum.js +5 -0
- package/rangerings/index.js +15 -0
- package/rangerings/plugin.js +610 -0
- package/rangerings/rangeringangletext.js +341 -0
- package/rangerings/ring-account.js +134 -0
- package/shaders/fragment-toy/firework.js +4 -0
- package/shaders/fragment-toy/singularity.js +5 -0
- package/shape-on-terrain/arc/naive/plugin.js +252 -0
- package/timetracks/adaptors-line-strip.js +82 -0
- package/timetracks/adaptors.js +136 -0
- package/timetracks/index.js +19 -0
- package/timetracks/plugin-line-strip.js +254 -0
- package/timetracks/plugin.js +262 -0
- package/timetracks/program-line-strip.js +418 -0
- package/timetracks/program.js +466 -0
- package/timetracks/programpoint-line-strip.js +101 -0
- package/timetracks/programpoint.js +101 -0
- package/types.js +15 -0
- package/util/account/bufferoffsetmanager.js +202 -0
- package/util/account/index.js +23 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +112 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +180 -0
- package/util/account/single-attribute-buffer-management/index.js +9 -0
- package/util/account/single-attribute-buffer-management/object-store.js +53 -0
- package/util/account/single-attribute-buffer-management/types.js +2 -0
- package/util/account/util.js +24 -0
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +28 -0
- package/util/check/get.js +18 -0
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +51 -0
- package/util/geometry/index.js +53 -0
- package/util/gl-util/buffer/attribute-loader.js +81 -0
- package/util/gl-util/buffer/index.js +6 -0
- package/util/gl-util/buffer/types.js +1 -0
- package/util/gl-util/draw-options/methods.js +38 -0
- package/util/gl-util/draw-options/types.js +15 -0
- package/util/gl-util/uniform-block/manager.js +168 -0
- package/util/gl-util/uniform-block/shader.js +1 -0
- package/util/gl-util/uniform-block/types.js +8 -0
- package/util/heatwavedatamanager/datamanager.js +212 -0
- package/util/heatwavedatamanager/index.js +10 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +125 -0
- package/util/heatwavedatamanager/pointcoordsmeta.js +21 -0
- package/util/index.js +57 -0
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +5 -0
- package/util/interpolation/timetrack/timetrack-interpolator.js +81 -0
- package/util/interpolation/timetrack/web-worker-str.js +5 -0
- package/util/interpolation/timetrack/web-worker.js +48 -0
- package/util/jshelpers/data-filler.js +20 -0
- package/util/jshelpers/equality.js +20 -0
- package/util/jshelpers/index.js +37 -0
- package/util/jshelpers/timefilters.js +32 -0
- package/util/picking/fence.js +46 -0
- package/util/picking/picker-displayer.js +145 -0
- package/util/programs/draw-texture-on-canvas.js +71 -0
- package/util/programs/index.js +17 -0
- package/util/programs/shapesonglobe.js +174 -0
- package/util/programs/supersampletotextures.js +107 -0
- package/util/programs/texturetoglobe.js +132 -0
- package/util/shaderfunctions/geometrytransformations.js +45 -0
- package/util/shaderfunctions/index.js +18 -0
- package/util/shaderfunctions/nodata.js +5 -0
- package/util/shaderfunctions/noisefunctions.js +13 -0
- package/util/surface-line-data/arc-bboxes.js +25 -0
- package/util/surface-line-data/arcs-to-cuts.js +53 -0
- package/util/surface-line-data/cut-arc.js +1 -0
- package/util/surface-line-data/flow.js +28 -0
- package/util/surface-line-data/rbush-manager.js +1 -0
- package/util/surface-line-data/types.js +1 -0
- package/util/surface-line-data/web-worker.js +1 -0
- package/util/webglobe/gldefaultstates.js +7 -0
- package/util/webglobe/index.js +18 -0
- package/util/webglobe/rasteroverlay.js +80 -0
- package/util/webglobjectbuilders.js +393 -0
- package/util/webglobjectbuilders1.js +238 -0
- package/waveparticles/adaptor.js +18 -0
- package/waveparticles/index.js +10 -0
- package/waveparticles/plugin.js +271 -0
- package/wind/imagetovectorfieldandmagnitude.js +35 -0
- package/wind/index.js +14 -0
- package/wind/plugin.js +724 -0
- package/wind/vectorfieldimage.js +25 -0
- package/write-text/attached-text-writer.js +93 -0
- package/write-text/context-text.js +105 -0
- package/write-text/context-text3.js +160 -0
- package/write-text/index.js +5 -0
- package/write-text/writer-plugin.js +8 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectStore = void 0;
|
|
4
|
+
var ObjectStore = /** @class */ (function () {
|
|
5
|
+
function ObjectStore(_a) {
|
|
6
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.initialCapcity, initialCapcity = _c === void 0 ? 10 : _c;
|
|
7
|
+
this._container = this._createEmptyList(initialCapcity);
|
|
8
|
+
}
|
|
9
|
+
ObjectStore.prototype.resetWithCapacity = function (capacity) {
|
|
10
|
+
this._container = this._createEmptyList(capacity);
|
|
11
|
+
};
|
|
12
|
+
ObjectStore.prototype.deleteBulk = function (offsets) {
|
|
13
|
+
for (var i = 0; i < offsets.length; i++) {
|
|
14
|
+
var offset = offsets[i];
|
|
15
|
+
if (offset !== undefined) {
|
|
16
|
+
this._container[offset] = null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
ObjectStore.prototype.insertBulk = function (objects, offsets) {
|
|
21
|
+
for (var i = 0; i < objects.length; i++) {
|
|
22
|
+
var object = objects[i];
|
|
23
|
+
var offset = offsets[i];
|
|
24
|
+
if (offset !== undefined) {
|
|
25
|
+
this._container[offset] = object;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
ObjectStore.prototype.defrag = function (offsetValues, occupiedCapacity, newCapacity) {
|
|
30
|
+
var hold = this._createEmptyList(newCapacity);
|
|
31
|
+
for (var i = 0; i < offsetValues.length; i++) {
|
|
32
|
+
var offset = offsetValues[i];
|
|
33
|
+
if (offset !== undefined) {
|
|
34
|
+
hold[i] = this._container[offset];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
this._container = hold;
|
|
38
|
+
};
|
|
39
|
+
ObjectStore.prototype.extendBuffer = function (occupiedCapacity, newCapacity) {
|
|
40
|
+
var oldCapacity = this._container.length;
|
|
41
|
+
this._container = this._container.concat(this._createEmptyList(newCapacity - oldCapacity));
|
|
42
|
+
};
|
|
43
|
+
ObjectStore.prototype._createEmptyList = function (size) {
|
|
44
|
+
return new Array(size).fill(null);
|
|
45
|
+
};
|
|
46
|
+
ObjectStore.prototype.get = function (index) {
|
|
47
|
+
return this._container[index];
|
|
48
|
+
};
|
|
49
|
+
ObjectStore.prototype.free = function () {
|
|
50
|
+
};
|
|
51
|
+
return ObjectStore;
|
|
52
|
+
}());
|
|
53
|
+
exports.ObjectStore = ObjectStore;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vaoAttributeLoader = void 0;
|
|
4
|
+
var vaoAttributeLoader = function (gl, buffer, index, size, stride, offset, divisor, type) {
|
|
5
|
+
if (divisor === void 0) { divisor = null; }
|
|
6
|
+
if (type === void 0) { type = null; }
|
|
7
|
+
if (!gl || !buffer) {
|
|
8
|
+
throw new Error("Invalid WebGL context or buffer");
|
|
9
|
+
}
|
|
10
|
+
if (index < 0) {
|
|
11
|
+
throw new Error("Attribute index must be non-negative");
|
|
12
|
+
}
|
|
13
|
+
if (stride < 0 || offset < 0) {
|
|
14
|
+
throw new Error("Stride and offset must be non-negative");
|
|
15
|
+
}
|
|
16
|
+
var attribType = type === null ? gl.FLOAT : type;
|
|
17
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
18
|
+
gl.enableVertexAttribArray(index);
|
|
19
|
+
gl.vertexAttribPointer(index, size, attribType, false, stride, offset);
|
|
20
|
+
if (divisor !== null) {
|
|
21
|
+
gl.vertexAttribDivisor(index, divisor);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.vaoAttributeLoader = vaoAttributeLoader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Array<number>} ListLike
|
|
4
|
+
* @typedef {number || null} Index
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.findFirstIndexInRange = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* @param {ListLike} container
|
|
10
|
+
* @param {number} value
|
|
11
|
+
* @returns {Index}
|
|
12
|
+
*/
|
|
13
|
+
var findFirstIndexInRange = function (container, value) {
|
|
14
|
+
var start = 0;
|
|
15
|
+
var end = container.length - 1;
|
|
16
|
+
var mid = 0;
|
|
17
|
+
while (start <= end) {
|
|
18
|
+
mid = Math.floor((start + end) / 2);
|
|
19
|
+
if (container[mid] <= value && value <= container[mid + 1])
|
|
20
|
+
return mid;
|
|
21
|
+
if (container[mid] < value)
|
|
22
|
+
start = mid + 1;
|
|
23
|
+
else
|
|
24
|
+
end = mid - 1;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
exports.findFirstIndexInRange = findFirstIndexInRange;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapGetOrThrow = void 0;
|
|
4
|
+
var mapGetOrThrow = function (errorNote) {
|
|
5
|
+
return function (mapInstance, ids) {
|
|
6
|
+
if (!ids)
|
|
7
|
+
throw new Error("There is no map keys to get");
|
|
8
|
+
var result = [];
|
|
9
|
+
for (var i = 0; i < ids.length; i++) {
|
|
10
|
+
var e = mapInstance.get(ids[i]);
|
|
11
|
+
if (e === undefined)
|
|
12
|
+
throw new Error(errorNote + " " + ids[i]);
|
|
13
|
+
result.push(e);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.mapGetOrThrow = mapGetOrThrow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Generic
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isBoolean = exports.constraintFloat = exports.isTextFont = exports.opacityCheck = exports.isHexColorWithOpacity = exports.isHexColor = void 0;
|
|
5
|
+
var doesOwnProperties = function (properties, errorMessage) {
|
|
6
|
+
return function (object) {
|
|
7
|
+
properties.forEach(function (element) {
|
|
8
|
+
if (!Object.hasOwn(object, element))
|
|
9
|
+
throw new TypeError(errorMessage + ':' + element);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
var isHexColor = function (hexColor) { return /^#[0-9A-F]{6}$/i.test(hexColor); };
|
|
14
|
+
exports.isHexColor = isHexColor;
|
|
15
|
+
var isHexColorWithOpacity = function (hexColor) { return /^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(hexColor); };
|
|
16
|
+
exports.isHexColorWithOpacity = isHexColorWithOpacity;
|
|
17
|
+
var opacityCheck = function (opacity) {
|
|
18
|
+
if (typeof opacity !== "number")
|
|
19
|
+
throw new TypeError("style.opacity must a number");
|
|
20
|
+
if (opacity < 0 || 1 < opacity)
|
|
21
|
+
throw new RangeError("Opacity Range Must be 0-1");
|
|
22
|
+
};
|
|
23
|
+
exports.opacityCheck = opacityCheck;
|
|
24
|
+
// Text Related
|
|
25
|
+
var fontCheckTypes = doesOwnProperties(["name", "textColor", "hollowColor", "size", "bold", "italic"], "font does not have");
|
|
26
|
+
var fontCheckColors = function (textColor, hollowColor) { return (0, exports.isHexColor)(textColor) && (0, exports.isHexColor)(hollowColor); };
|
|
27
|
+
var isTextFont = function (textFont) {
|
|
28
|
+
fontCheckTypes(textFont);
|
|
29
|
+
fontCheckColors(textFont.textColor, textFont.hollowColor);
|
|
30
|
+
if (typeof textFont.size !== "number")
|
|
31
|
+
throw new TypeError("textFont size is not a number");
|
|
32
|
+
};
|
|
33
|
+
exports.isTextFont = isTextFont;
|
|
34
|
+
var constraintFloat = function (x, lowerBound, upperBound) {
|
|
35
|
+
if (lowerBound === void 0) { lowerBound = null; }
|
|
36
|
+
if (upperBound === void 0) { upperBound = null; }
|
|
37
|
+
if (typeof x !== "number")
|
|
38
|
+
throw new Error("type must be numberic");
|
|
39
|
+
if (lowerBound === null && upperBound === null)
|
|
40
|
+
return;
|
|
41
|
+
if (lowerBound !== null && lowerBound > x)
|
|
42
|
+
throw new Error("input must be greater than ".concat(lowerBound));
|
|
43
|
+
if (upperBound !== null && x > upperBound)
|
|
44
|
+
throw new Error("input must be less than ".concat(upperBound));
|
|
45
|
+
};
|
|
46
|
+
exports.constraintFloat = constraintFloat;
|
|
47
|
+
var isBoolean = function (x) {
|
|
48
|
+
if (typeof x !== "boolean")
|
|
49
|
+
throw new TypeError("type must be boolean");
|
|
50
|
+
};
|
|
51
|
+
exports.isBoolean = isBoolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBBoxMatrix = createBBoxMatrix;
|
|
4
|
+
exports.latLongToPixelXY = latLongToPixelXY;
|
|
5
|
+
exports.latLongBboxtoPixelXYBbox = latLongBboxtoPixelXYBbox;
|
|
6
|
+
exports.sphereCoord = sphereCoord;
|
|
7
|
+
exports.normalize = normalize;
|
|
8
|
+
function latLongToPixelXY(latitude, longitude) {
|
|
9
|
+
return {
|
|
10
|
+
x: (longitude + 180) / 360,
|
|
11
|
+
y: (90 - latitude) / 180
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* createBBoxMatrix( minX, maxX, minY, maxY)
|
|
16
|
+
* use this matrix to transform a point from 0 to 1 range to the bounding box
|
|
17
|
+
* for example: Transform image coordinates to map coordinates
|
|
18
|
+
* glsl`vec3 pos = u_bbox_matrix * vec3(v_particle_pos.x, v_particle_pos.y, 1.0);`
|
|
19
|
+
*/
|
|
20
|
+
function createBBoxMatrix(minX, maxX, minY, maxY) {
|
|
21
|
+
return new Float32Array([
|
|
22
|
+
maxX - minX, 0, 0,
|
|
23
|
+
0, maxY - minY, 0,
|
|
24
|
+
minX, minY, 1
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
function latLongBboxtoPixelXYBbox(minX, minY, maxX, maxY) {
|
|
28
|
+
var minXY = latLongToPixelXY(minY, minX);
|
|
29
|
+
var maxXY = latLongToPixelXY(maxY, maxX);
|
|
30
|
+
return createBBoxMatrix(minXY.x, maxXY.x, minXY.y, maxXY.y);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {Float32List} array
|
|
35
|
+
* @returns {Float32Array}
|
|
36
|
+
*/
|
|
37
|
+
function normalize(array, newLength) {
|
|
38
|
+
if (newLength === void 0) { newLength = 1; }
|
|
39
|
+
var total = 0;
|
|
40
|
+
for (var i = 0; i < array.length; i++) {
|
|
41
|
+
total += array[i] * array[i];
|
|
42
|
+
}
|
|
43
|
+
var len = newLength / Math.sqrt(total);
|
|
44
|
+
var result = new Float32Array(array.length);
|
|
45
|
+
for (var i = 0; i < array.length; i++) {
|
|
46
|
+
result[i] = array[i] * len;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
function sphereCoord(long, lat, globe, height) {
|
|
51
|
+
if (height === void 0) { height = 0; }
|
|
52
|
+
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137 + height);
|
|
53
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createBufferAndReadInfo = exports.attributeLoader = void 0;
|
|
13
|
+
require("./types");
|
|
14
|
+
/**
|
|
15
|
+
* @typedef BufferAndReadInfo Buffers can be intertwined or interleaved.
|
|
16
|
+
* This object forces user to adapt generic convention of buffer and read information.
|
|
17
|
+
* @type {Object}
|
|
18
|
+
* @property {WebGLBuffer} buffer
|
|
19
|
+
* @property {number} stride
|
|
20
|
+
* @property {number} offset
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {WebGLBuffer} gl
|
|
25
|
+
* @param {BufferAndReadInfo} bufferAndReadInfo
|
|
26
|
+
* @param {number} index
|
|
27
|
+
* @param {number} size
|
|
28
|
+
* @param {Object} options
|
|
29
|
+
* @param {*} options.type | default gl.FLOAT, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.INT, gl.UNSIGNED_INT
|
|
30
|
+
* @param {number} options.divisor
|
|
31
|
+
* @param {Array<number>} options.escapeValues
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
var attributeLoader = function (gl, bufferAndReadInfo, index, size, _a) {
|
|
35
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.divisor, divisor = _c === void 0 ? null : _c, _d = _b.type, type = _d === void 0 ? null : _d, _e = _b.escapeValues, escapeValues = _e === void 0 ? null : _e, _f = _b.normalized, normalized = _f === void 0 ? false : _f;
|
|
36
|
+
if (size < 1 || size > 4)
|
|
37
|
+
throw new Error("Size must be between 1 and 4");
|
|
38
|
+
if (bufferAndReadInfo == null) {
|
|
39
|
+
if (escapeValues !== null)
|
|
40
|
+
constantFunction(gl, index, size, escapeValues);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var buffer = bufferAndReadInfo.buffer, stride = bufferAndReadInfo.stride, offset = bufferAndReadInfo.offset;
|
|
44
|
+
if (!gl || !buffer) {
|
|
45
|
+
throw new Error("Invalid WebGL context or buffer");
|
|
46
|
+
}
|
|
47
|
+
if (index < 0) {
|
|
48
|
+
throw new Error("Attribute index must be non-negative");
|
|
49
|
+
}
|
|
50
|
+
if (stride < 0 || offset < 0) {
|
|
51
|
+
throw new Error("Stride and offset must be non-negative");
|
|
52
|
+
}
|
|
53
|
+
var attribType = type === null ? gl.FLOAT : type;
|
|
54
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
55
|
+
gl.enableVertexAttribArray(index);
|
|
56
|
+
gl.vertexAttribPointer(index, size, attribType, normalized, stride, offset);
|
|
57
|
+
if (divisor !== null) {
|
|
58
|
+
gl.vertexAttribDivisor(index, divisor);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.attributeLoader = attributeLoader;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {WebGLBuffer} buffer
|
|
65
|
+
* @param {number} stride
|
|
66
|
+
* @param {number} offset
|
|
67
|
+
* @returns {BufferAndReadInfo}
|
|
68
|
+
*/
|
|
69
|
+
var createBufferAndReadInfo = function (buffer, stride, offset) {
|
|
70
|
+
if (stride === void 0) { stride = 0; }
|
|
71
|
+
if (offset === void 0) { offset = 0; }
|
|
72
|
+
if (buffer == null)
|
|
73
|
+
return null;
|
|
74
|
+
return { buffer: buffer, stride: stride, offset: offset };
|
|
75
|
+
};
|
|
76
|
+
exports.createBufferAndReadInfo = createBufferAndReadInfo;
|
|
77
|
+
var constantFunction = function (gl, index, size, escapeValues) {
|
|
78
|
+
var func = "vertexAttrib".concat(size, "f");
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
gl[func].apply(gl, __spreadArray([index], escapeValues, false));
|
|
81
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import './types';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.attributeLoader = void 0;
|
|
5
|
+
var attribute_loader_1 = require("./attribute-loader");
|
|
6
|
+
Object.defineProperty(exports, "attributeLoader", { enumerable: true, get: function () { return attribute_loader_1.attributeLoader; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.drawInstanced = exports.drawArrays = void 0;
|
|
4
|
+
require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Draws instanced geometry using WebGL2.
|
|
7
|
+
*/
|
|
8
|
+
var drawInstanced = function (gl, mode, drawOptions, vertexCount) {
|
|
9
|
+
var _a;
|
|
10
|
+
var drawRange = drawOptions.drawRange, _b = drawOptions.elementBufferIndexType, elementBufferIndexType = _b === void 0 ? gl.UNSIGNED_INT : _b;
|
|
11
|
+
var _c = drawRange.first, first = _c === void 0 ? 0 : _c, _d = drawRange.count, instanceCount = _d === void 0 ? 1 : _d;
|
|
12
|
+
if (first > 0 || drawOptions.elementBuffer) {
|
|
13
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, (_a = drawOptions.elementBuffer) !== null && _a !== void 0 ? _a : null);
|
|
14
|
+
gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, instanceCount);
|
|
15
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
gl.drawArraysInstanced(mode, first, vertexCount, instanceCount);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.drawInstanced = drawInstanced;
|
|
22
|
+
/**
|
|
23
|
+
* Draws geometry using WebGL2.
|
|
24
|
+
*/
|
|
25
|
+
var drawArrays = function (gl, defaultMode, drawOptions) {
|
|
26
|
+
var drawRange = drawOptions.drawRange, elementBuffer = drawOptions.elementBuffer, _a = drawOptions.elementBufferIndexType, elementBufferIndexType = _a === void 0 ? gl.UNSIGNED_INT : _a, _b = drawOptions.drawMode, drawMode = _b === void 0 ? null : _b;
|
|
27
|
+
var _c = drawRange.first, first = _c === void 0 ? 0 : _c, count = drawRange.count;
|
|
28
|
+
var mode = drawMode !== null && drawMode !== void 0 ? drawMode : defaultMode;
|
|
29
|
+
if (elementBuffer) {
|
|
30
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
|
|
31
|
+
gl.drawElements(mode, count, elementBufferIndexType, first);
|
|
32
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
gl.drawArrays(mode, first, count);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.drawArrays = drawArrays;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @typedef DrawRange
|
|
4
|
+
* @type {Object}
|
|
5
|
+
* @property {int} first
|
|
6
|
+
* @property {int} count
|
|
7
|
+
*
|
|
8
|
+
* @typedef DrawRangeIndexParams
|
|
9
|
+
* @type {Object}
|
|
10
|
+
* @property {null|DrawRange} drawRange
|
|
11
|
+
* @property {null|ElementBuffer} elementBuffer
|
|
12
|
+
* @property {null|indexType} indexType
|
|
13
|
+
* @property {null|int} drawMode
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniformBlockManager = void 0;
|
|
4
|
+
require("./types");
|
|
5
|
+
var typeSizes = {
|
|
6
|
+
'float': 4,
|
|
7
|
+
'vec2': 8,
|
|
8
|
+
'vec3': 16, // vec3 takes up same space as vec4 due to alignment
|
|
9
|
+
'vec4': 16,
|
|
10
|
+
'mat2': 32, // 2 vec4s (16 * 2)
|
|
11
|
+
'mat3': 48, // 3 vec4s (16 * 3)
|
|
12
|
+
'mat4': 64, // 4 vec4s (16 * 4)
|
|
13
|
+
'int': 4,
|
|
14
|
+
'ivec2': 8,
|
|
15
|
+
'ivec3': 16,
|
|
16
|
+
'ivec4': 16,
|
|
17
|
+
'bool': 4
|
|
18
|
+
};
|
|
19
|
+
var typeAlignments = {
|
|
20
|
+
'float': 4,
|
|
21
|
+
'vec2': 8,
|
|
22
|
+
'vec3': 16,
|
|
23
|
+
'vec4': 16,
|
|
24
|
+
'mat2': 16, // aligns to vec4 boundary
|
|
25
|
+
'mat3': 16, // aligns to vec4 boundary
|
|
26
|
+
'mat4': 16, // aligns to vec4 boundary
|
|
27
|
+
'int': 4,
|
|
28
|
+
'ivec2': 8,
|
|
29
|
+
'ivec3': 16,
|
|
30
|
+
'ivec4': 16,
|
|
31
|
+
'bool': 4
|
|
32
|
+
};
|
|
33
|
+
var typeArrayConstructors = {
|
|
34
|
+
'float': Float32Array,
|
|
35
|
+
'vec2': Float32Array,
|
|
36
|
+
'vec3': Float32Array,
|
|
37
|
+
'vec4': Float32Array,
|
|
38
|
+
'mat2': Float32Array,
|
|
39
|
+
'mat3': Float32Array,
|
|
40
|
+
'mat4': Float32Array,
|
|
41
|
+
'int': Int32Array,
|
|
42
|
+
'ivec2': Int32Array,
|
|
43
|
+
'ivec3': Int32Array,
|
|
44
|
+
'ivec4': Int32Array,
|
|
45
|
+
'bool': Float32Array
|
|
46
|
+
};
|
|
47
|
+
var UniformBlockManager = /** @class */ (function () {
|
|
48
|
+
function UniformBlockManager(blockName, blockMembers, bindingPoint, prefix) {
|
|
49
|
+
if (prefix === void 0) { prefix = ""; }
|
|
50
|
+
this.blockName = blockName;
|
|
51
|
+
this.blockMembers = blockMembers;
|
|
52
|
+
this.bindingPoint = bindingPoint;
|
|
53
|
+
this.prefix = prefix;
|
|
54
|
+
this.offsetMap = this.__create_LayoutSTD140_OffsetMap();
|
|
55
|
+
this.size = this.__calculateSize();
|
|
56
|
+
}
|
|
57
|
+
UniformBlockManager.prototype.glslCode = function () {
|
|
58
|
+
var code = "layout(std140) uniform ".concat(this.blockName, " {");
|
|
59
|
+
for (var _i = 0, _a = this.blockMembers; _i < _a.length; _i++) {
|
|
60
|
+
var member = _a[_i];
|
|
61
|
+
var name_1 = member.name, type = member.type;
|
|
62
|
+
code += "".concat(type, " ").concat(this.prefix).concat(name_1, ";");
|
|
63
|
+
}
|
|
64
|
+
if (this.prefix) {
|
|
65
|
+
code += "} ".concat(this.prefix, ";");
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
code += "};";
|
|
69
|
+
}
|
|
70
|
+
return code;
|
|
71
|
+
};
|
|
72
|
+
UniformBlockManager.prototype.createUBO = function (gl, bufferWriteType) {
|
|
73
|
+
var _this = this;
|
|
74
|
+
if (bufferWriteType === void 0) { bufferWriteType = "STATIC_DRAW"; }
|
|
75
|
+
var ubo = gl.createBuffer();
|
|
76
|
+
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
gl.bufferData(gl.UNIFORM_BUFFER, this.size, gl[bufferWriteType]);
|
|
79
|
+
gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
|
|
80
|
+
for (var _i = 0, _a = this.blockMembers; _i < _a.length; _i++) {
|
|
81
|
+
var member = _a[_i];
|
|
82
|
+
var name_2 = member.name, type = member.type, _b = member.value, value = _b === void 0 ? null : _b;
|
|
83
|
+
;
|
|
84
|
+
var offset = this.offsetMap.get(name_2);
|
|
85
|
+
var data = (value === null) ? new typeArrayConstructors[type](typeSizes[type] / 4).fill(NaN) : value;
|
|
86
|
+
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
87
|
+
}
|
|
88
|
+
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
89
|
+
return {
|
|
90
|
+
ubo: ubo,
|
|
91
|
+
update: function (nameValueMap) { return _this.updateUBO(gl, ubo, nameValueMap); },
|
|
92
|
+
bind: function () { return _this.bind(gl, ubo); },
|
|
93
|
+
unbind: function () { return _this.unbind(gl); },
|
|
94
|
+
free: function () { return gl.deleteBuffer(ubo); },
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
UniformBlockManager.prototype.updateUBO = function (gl, ubo, nameValueMap) {
|
|
98
|
+
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
99
|
+
var _loop_1 = function (name_3, value) {
|
|
100
|
+
var offset = this_1.offsetMap.get(name_3);
|
|
101
|
+
if (offset === undefined) {
|
|
102
|
+
throw new Error("Uniform block member ".concat(name_3, " not found in offset map."));
|
|
103
|
+
}
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
var type = this_1.blockMembers.find(function (member) { return member.name === name_3; }).type;
|
|
106
|
+
var data = void 0;
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
data = new typeArrayConstructors[type](value);
|
|
109
|
+
}
|
|
110
|
+
else if (typeof value === 'number') {
|
|
111
|
+
data = new typeArrayConstructors[type]([value]);
|
|
112
|
+
}
|
|
113
|
+
else if (value instanceof ArrayBuffer) {
|
|
114
|
+
data = new typeArrayConstructors[type](value);
|
|
115
|
+
}
|
|
116
|
+
else if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
117
|
+
data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
|
|
118
|
+
else {
|
|
119
|
+
throw new Error("Unsupported value type for ".concat(name_3, ": ").concat(typeof value));
|
|
120
|
+
}
|
|
121
|
+
console.log("Data to be uploaded:", data);
|
|
122
|
+
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
123
|
+
};
|
|
124
|
+
var this_1 = this;
|
|
125
|
+
for (var _i = 0, _a = nameValueMap.entries(); _i < _a.length; _i++) {
|
|
126
|
+
var _b = _a[_i], name_3 = _b[0], value = _b[1];
|
|
127
|
+
_loop_1(name_3, value);
|
|
128
|
+
}
|
|
129
|
+
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
130
|
+
};
|
|
131
|
+
// call this after linking the program
|
|
132
|
+
UniformBlockManager.prototype.assignBindingPoint = function (gl, program) {
|
|
133
|
+
var blockIndex = gl.getUniformBlockIndex(program, this.blockName);
|
|
134
|
+
gl.uniformBlockBinding(program, blockIndex, this.bindingPoint);
|
|
135
|
+
};
|
|
136
|
+
// call this before drawing
|
|
137
|
+
UniformBlockManager.prototype.bind = function (gl, ubo) {
|
|
138
|
+
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, ubo);
|
|
139
|
+
};
|
|
140
|
+
// call this right after drawing
|
|
141
|
+
UniformBlockManager.prototype.unbind = function (gl) {
|
|
142
|
+
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, null);
|
|
143
|
+
};
|
|
144
|
+
// implicit methods
|
|
145
|
+
UniformBlockManager.prototype.__create_LayoutSTD140_OffsetMap = function () {
|
|
146
|
+
var offset = 0;
|
|
147
|
+
var offsetMap = new Map();
|
|
148
|
+
for (var _i = 0, _a = this.blockMembers; _i < _a.length; _i++) {
|
|
149
|
+
var member = _a[_i];
|
|
150
|
+
var name_4 = member.name, type = member.type;
|
|
151
|
+
var size = typeSizes[type];
|
|
152
|
+
var alignment = typeAlignments[type];
|
|
153
|
+
var padding = (alignment - (offset % alignment)) % alignment;
|
|
154
|
+
offset += padding;
|
|
155
|
+
offsetMap.set(name_4, offset);
|
|
156
|
+
offset += size;
|
|
157
|
+
}
|
|
158
|
+
return offsetMap;
|
|
159
|
+
};
|
|
160
|
+
// __create_LayoutSTD140_OffsetMap() should be called before this
|
|
161
|
+
UniformBlockManager.prototype.__calculateSize = function () {
|
|
162
|
+
var lastOffset = Array.from(this.offsetMap.values()).pop() || 0;
|
|
163
|
+
var lastItemAlignment = typeAlignments[this.blockMembers[this.blockMembers.length - 1].type];
|
|
164
|
+
return lastOffset + lastItemAlignment;
|
|
165
|
+
};
|
|
166
|
+
return UniformBlockManager;
|
|
167
|
+
}());
|
|
168
|
+
exports.UniformBlockManager = UniformBlockManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|