@pirireis/webglobeplugins 0.16.4 → 0.16.7
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/arc.js +92 -2
- package/Math/circle-cdf-points.js +2 -2
- package/Math/circle.js +2 -2
- package/Math/juction/arc-plane.js +67 -12
- package/Math/juction/line-sphere.js +6 -6
- package/Math/juction/plane-plane.js +4 -6
- package/Math/methods.js +5 -5
- package/Math/templete-shapes/grid-visually-equal.js +0 -1
- package/Math/tessellation/earcut/adapters.js +37 -0
- package/Math/tessellation/methods.js +46 -0
- package/Math/tessellation/shred-input.js +18 -0
- package/Math/tessellation/tessellation-algorithm.js +67 -0
- package/Math/tessellation/tiler.js +50 -0
- package/Math/tessellation/triangle-tessellation-meta.js +370 -0
- package/Math/tessellation/triangle-tessellation.js +10 -0
- package/Math/tessellation/types.js +1 -0
- package/Math/tessellation/zoom-catch.js +1 -0
- package/Math/vec3.js +26 -1
- package/package.json +4 -2
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +178 -0
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +31 -10
- package/programs/polygon-on-globe/texture-dem-triangles.js +53 -11
- package/programs/totems/camerauniformblock.js +3 -3
- package/semiplugins/shape-on-terrain/arc-plugin.js +5 -5
- package/semiplugins/shape-on-terrain/padding-1-degree.js +0 -1
- package/util/gl-util/uniform-block/manager.js +4 -4
- package/util/shaderfunctions/geometrytransformations.js +6 -0
- package/Math/mesh/mapbox-delaunay.js +0 -544
|
@@ -6,16 +6,16 @@ const TEST_ITEM_COUNT = 1000000;
|
|
|
6
6
|
function createTestLongLatArray() {
|
|
7
7
|
const arr = new Float32Array(TEST_ITEM_COUNT * 2);
|
|
8
8
|
for (let i = 0; i < TEST_ITEM_COUNT; i++) {
|
|
9
|
-
arr[i * 2 + 0] = Math.random() *
|
|
10
|
-
arr[i * 2 + 1] = Math.random()
|
|
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
11
|
}
|
|
12
12
|
return arr;
|
|
13
13
|
}
|
|
14
14
|
function createTestPos3dArray(longLatArray) {
|
|
15
15
|
const arr = new Float32Array(TEST_ITEM_COUNT * 3);
|
|
16
16
|
for (let i = 0; i < TEST_ITEM_COUNT; i++) {
|
|
17
|
-
const long = longLatArray[i * 2 + 0]
|
|
18
|
-
const lat = longLatArray[i * 2 + 1]
|
|
17
|
+
const long = longLatArray[i * 2 + 0];
|
|
18
|
+
const lat = longLatArray[i * 2 + 1];
|
|
19
19
|
// Convert long/lat to 3D position (simplified)
|
|
20
20
|
arr[i * 3 + 0] = Math.cos(lat) * Math.cos(long);
|
|
21
21
|
arr[i * 3 + 1] = Math.cos(lat) * Math.sin(long);
|
|
@@ -26,10 +26,10 @@ function createTestPos3dArray(longLatArray) {
|
|
|
26
26
|
const createTestBBOXES = () => {
|
|
27
27
|
const bboxes = [];
|
|
28
28
|
for (let i = 0; i < 6; i++) {
|
|
29
|
-
const north = Math.random()
|
|
30
|
-
const west = Math.random() * -
|
|
31
|
-
const south = north -
|
|
32
|
-
const east = west +
|
|
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
33
|
const nw = [west, north]; // random northWest
|
|
34
34
|
const se = [east, south]; // random southEast
|
|
35
35
|
bboxes.push({ northWest: nw, southEast: se });
|
|
@@ -48,12 +48,31 @@ const createTestDemTextures = () => {
|
|
|
48
48
|
}
|
|
49
49
|
return textures;
|
|
50
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
|
+
}
|
|
51
69
|
export class TextureDemTrianglesTestPlugin {
|
|
52
70
|
globe = null;
|
|
53
71
|
textureDemTriangles = null;
|
|
54
72
|
vao = null;
|
|
55
73
|
drawOptions = null;
|
|
56
74
|
bufferInfo = null;
|
|
75
|
+
ubo = null;
|
|
57
76
|
id;
|
|
58
77
|
constructor(id) {
|
|
59
78
|
this.id = id;
|
|
@@ -66,6 +85,8 @@ export class TextureDemTrianglesTestPlugin {
|
|
|
66
85
|
const demTextureBBOX = createTestBBOXES();
|
|
67
86
|
this.textureDemTriangles.setDemTextures(demTextures, demTextureBBOX);
|
|
68
87
|
//
|
|
88
|
+
this.ubo = this.textureDemTriangles.createUBO();
|
|
89
|
+
this.ubo.updateSingle("u_color", new Float32Array([1.0, 0.0, 0.0, 0.0]));
|
|
69
90
|
const bufferInfo = {
|
|
70
91
|
pos3dBufferInfo: {
|
|
71
92
|
buffer: globe.gl.createBuffer(),
|
|
@@ -90,8 +111,8 @@ export class TextureDemTrianglesTestPlugin {
|
|
|
90
111
|
this.bufferInfo = bufferInfo;
|
|
91
112
|
}
|
|
92
113
|
draw3D() {
|
|
93
|
-
if (!this.globe || !this.textureDemTriangles || !this.vao || !this.bufferInfo)
|
|
114
|
+
if (!this.globe || !this.textureDemTriangles || !this.vao || !this.bufferInfo || !this.ubo)
|
|
94
115
|
return;
|
|
95
|
-
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptions);
|
|
116
|
+
this.textureDemTriangles.draw(this.vao, this.bufferInfo.drawOptions, this.ubo);
|
|
96
117
|
}
|
|
97
118
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
2
|
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems/camerauniformblock";
|
|
3
3
|
import { cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
|
+
import { isPointInBBox } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
5
|
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
5
6
|
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
7
|
import { WORLD_RADIUS_3D } from "../../Math/constants";
|
|
8
|
+
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
7
9
|
const uniformBindingPoints = {
|
|
8
10
|
camera: 0,
|
|
11
|
+
style: 1,
|
|
9
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);
|
|
10
18
|
const vertexShaderSource = `#version 300 es
|
|
11
19
|
#pragma vscode_glsllint_stage : vert
|
|
12
20
|
|
|
@@ -22,6 +30,8 @@ uniform sampler2DArray u_demTexture; // <-- changed from array to single
|
|
|
22
30
|
uniform vec4 u_demTextureBBOX[6];
|
|
23
31
|
|
|
24
32
|
|
|
33
|
+
${styleBlockManager.glslCode()}
|
|
34
|
+
|
|
25
35
|
|
|
26
36
|
// TODO: light directioni
|
|
27
37
|
// out vec3 v_position;
|
|
@@ -30,9 +40,8 @@ uniform vec4 u_demTextureBBOX[6];
|
|
|
30
40
|
|
|
31
41
|
out vec4 v_color;
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
43
|
+
|
|
44
|
+
${isPointInBBox}
|
|
36
45
|
|
|
37
46
|
void main() {
|
|
38
47
|
|
|
@@ -43,16 +52,17 @@ void main() {
|
|
|
43
52
|
vec2 uv = (a_longLat - u_demTextureBBOX[i].xy) / (u_demTextureBBOX[i].zw - u_demTextureBBOX[i].xy);
|
|
44
53
|
float altitude = texture(u_demTexture, vec3(uv, float(i))).r;
|
|
45
54
|
elevation += altitude;
|
|
46
|
-
v_color = mix(vec4(0.0, 0.0, 1.0, 1.0), vec4(1.0, 0.0, 0.0, 1.0), altitude /
|
|
47
|
-
// elevation += 1000.0 * float(i); // temporary for testing
|
|
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
|
|
48
56
|
break;
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
if (u_color.a > 0.0) {
|
|
60
|
+
v_color = u_color;
|
|
61
|
+
}
|
|
62
|
+
v_color.a *= u_opacity;
|
|
53
63
|
vec3 position = a_position * elevation;
|
|
54
64
|
gl_Position = cartesian3DToGLPosition(position);
|
|
55
|
-
gl_PointSize =
|
|
65
|
+
gl_PointSize = u_pointSize;
|
|
56
66
|
}
|
|
57
67
|
`;
|
|
58
68
|
const fragmentShaderSource = `#version 300 es
|
|
@@ -62,7 +72,7 @@ precision highp float;
|
|
|
62
72
|
in vec4 v_color;
|
|
63
73
|
out vec4 outColor;
|
|
64
74
|
void main() {
|
|
65
|
-
outColor = v_color;
|
|
75
|
+
outColor = v_color;
|
|
66
76
|
}
|
|
67
77
|
`;
|
|
68
78
|
export class TextureDemTriangles {
|
|
@@ -74,6 +84,7 @@ export class TextureDemTriangles {
|
|
|
74
84
|
// demTextures: WebGLTexture[] = [];
|
|
75
85
|
// demTextureBBOX: Float32Array = new Float32Array(6 * 4); // 6 bounding boxes
|
|
76
86
|
cameraUniformBlock;
|
|
87
|
+
_publishedUBOs = [];
|
|
77
88
|
locations = {
|
|
78
89
|
attributes: {
|
|
79
90
|
a_position: -1,
|
|
@@ -82,6 +93,7 @@ export class TextureDemTriangles {
|
|
|
82
93
|
uniforms: {
|
|
83
94
|
u_demTexture: -1,
|
|
84
95
|
u_demTextureBBOX: -1,
|
|
96
|
+
u_style: -1,
|
|
85
97
|
}
|
|
86
98
|
};
|
|
87
99
|
constructor(globe) {
|
|
@@ -96,6 +108,8 @@ export class TextureDemTriangles {
|
|
|
96
108
|
// get uniform locations
|
|
97
109
|
this.locations.uniforms.u_demTexture = this.gl.getUniformLocation(this.program, 'u_demTexture');
|
|
98
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);
|
|
99
113
|
// create 3d texture
|
|
100
114
|
const texture = this.gl.createTexture();
|
|
101
115
|
this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, texture);
|
|
@@ -147,21 +161,49 @@ export class TextureDemTriangles {
|
|
|
147
161
|
gl.bindTexture(gl.TEXTURE_2D_ARRAY, null);
|
|
148
162
|
gl.useProgram(currentProgram);
|
|
149
163
|
}
|
|
150
|
-
|
|
164
|
+
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
165
|
+
const ubo = styleBlockManager.createUBO(this.gl, bufferReadType);
|
|
166
|
+
this._publishedUBOs.push(ubo);
|
|
167
|
+
return ubo;
|
|
168
|
+
}
|
|
169
|
+
free() {
|
|
170
|
+
this.gl.deleteProgram(this.program);
|
|
171
|
+
this.gl.deleteTexture(this.texture);
|
|
172
|
+
this._publishedUBOs.forEach(ubo => ubo.free());
|
|
173
|
+
this._publishedUBOs = [];
|
|
174
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
175
|
+
}
|
|
176
|
+
draw(vao, drawOptions, ubo) {
|
|
151
177
|
const gl = this.gl;
|
|
152
|
-
console.log('Drawing TextureDemTriangles drawOptions:', drawOptions);
|
|
153
178
|
gl.useProgram(this.program);
|
|
154
179
|
this.cameraUniformBlock.bind(uniformBindingPoints.camera);
|
|
155
180
|
// TURN OFF flip y for texture
|
|
181
|
+
gl.disable(gl.DEPTH_TEST);
|
|
156
182
|
gl.activeTexture(gl.TEXTURE0);
|
|
157
183
|
gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.texture);
|
|
158
184
|
gl.uniform1i(this.locations.uniforms.u_demTexture, 0); // texture unit 0
|
|
159
185
|
// bind VAO and draw
|
|
160
186
|
gl.bindVertexArray(vao);
|
|
187
|
+
// bind UBO for style
|
|
188
|
+
ubo.bind();
|
|
161
189
|
drawArrays(gl, gl.POINTS, drawOptions);
|
|
190
|
+
gl.enable(gl.DEPTH_TEST);
|
|
191
|
+
// unbind everything
|
|
162
192
|
gl.bindVertexArray(null);
|
|
163
193
|
gl.bindTexture(gl.TEXTURE_2D_ARRAY, null);
|
|
164
194
|
gl.useProgram(null);
|
|
195
|
+
ubo.unbind();
|
|
165
196
|
this.cameraUniformBlock.unbind(uniformBindingPoints.camera);
|
|
166
197
|
}
|
|
198
|
+
_getUniformBlockOffset(name) {
|
|
199
|
+
// hardcoded offsets based on std140 layout rules
|
|
200
|
+
const offsets = {
|
|
201
|
+
'u_color': 0,
|
|
202
|
+
};
|
|
203
|
+
const result = offsets[name];
|
|
204
|
+
if (result === undefined) {
|
|
205
|
+
throw new Error(`Unknown uniform block member: ${name}, names are: ${Object.keys(offsets).join(", ")}`);
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
167
209
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { globeProgramCache } from "../programcache";
|
|
2
2
|
import { fromLongLatToUnitVector } from "../../Math/vec3";
|
|
3
|
-
import {
|
|
3
|
+
import { RADIAN } from "../../Math/methods";
|
|
4
4
|
import { GlobeChangeObserver } from "./globe-changes";
|
|
5
5
|
// import { approximatedZoomLevel } from "../../util/geometry/index";
|
|
6
6
|
export const CameraUniformBlockString = `
|
|
@@ -155,7 +155,7 @@ export class CameraUniformBlockTotem {
|
|
|
155
155
|
}
|
|
156
156
|
else if (currentGeom === 1) {
|
|
157
157
|
const { CenterLong, CenterLat } = globe.api_GetCurrentLookInfo();
|
|
158
|
-
fromLongLatToUnitVector(_0vec3, [CenterLong *
|
|
158
|
+
fromLongLatToUnitVector(_0vec3, [CenterLong * RADIAN, CenterLat * RADIAN]);
|
|
159
159
|
this._normalizedCameraVector[0] = _0vec3[0];
|
|
160
160
|
this._normalizedCameraVector[1] = _0vec3[1];
|
|
161
161
|
this._normalizedCameraVector[2] = _0vec3[2];
|
|
@@ -197,7 +197,7 @@ export class CameraUniformBlockTotem {
|
|
|
197
197
|
const globe = this.globe;
|
|
198
198
|
const { CenterLong, CenterLat } = globe.api_GetCurrentLookInfo();
|
|
199
199
|
const result = [0, 0, 0];
|
|
200
|
-
fromLongLatToUnitVector(result, [CenterLong *
|
|
200
|
+
fromLongLatToUnitVector(result, [CenterLong * RADIAN, CenterLat * RADIAN]);
|
|
201
201
|
return result;
|
|
202
202
|
}
|
|
203
203
|
getGlobeChanges() {
|
|
@@ -3,7 +3,7 @@ import { LineStripProgramCache } from "../../programs/line-on-globe/linestrip/li
|
|
|
3
3
|
import { createBufferAndReadInfo } from "../../util/gl-util/buffer/attribute-loader";
|
|
4
4
|
// import { populateFloat32Array } from "../../util/jshelpers/data-filler";
|
|
5
5
|
import { BufferManager, BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/index";
|
|
6
|
-
import { globe3Dcoordinates, globe2Dcoordinates,
|
|
6
|
+
import { globe3Dcoordinates, globe2Dcoordinates, RADIAN } from "../../Math/methods";
|
|
7
7
|
import { generateArcPoints, evenlySpacedArcPoints } from "../../Math/arc-cdf-points";
|
|
8
8
|
import { StaticDynamicState, StaticDynamicStrategy } from "../../util/build-strategy/static-dynamic";
|
|
9
9
|
import { opacityCheck } from "../../util/check/typecheck";
|
|
@@ -19,8 +19,8 @@ const _start = [0, 0, 0];
|
|
|
19
19
|
const _end = [0, 0, 0];
|
|
20
20
|
const _0arc = arc.create([1, 0, 0], [0, 1, 0]); // zero arc for intersection tests
|
|
21
21
|
function createArc(start, end) {
|
|
22
|
-
vec3.fromLongLatToUnitVector(_start, [start[0] *
|
|
23
|
-
vec3.fromLongLatToUnitVector(_end, [end[0] *
|
|
22
|
+
vec3.fromLongLatToUnitVector(_start, [start[0] * RADIAN, start[1] * RADIAN]);
|
|
23
|
+
vec3.fromLongLatToUnitVector(_end, [end[0] * RADIAN, end[1] * RADIAN]);
|
|
24
24
|
return arc.create(_start, _end);
|
|
25
25
|
}
|
|
26
26
|
export class ArcOnTerrainPlugin {
|
|
@@ -302,7 +302,7 @@ export class ArcOnTerrainPlugin {
|
|
|
302
302
|
for (let i = 0; i < generatedPoints.length; i++) {
|
|
303
303
|
const point = generatedPoints[i];
|
|
304
304
|
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
305
|
-
longLatArr.set([longLat[0] /
|
|
305
|
+
longLatArr.set([longLat[0] / RADIAN, longLat[1] / RADIAN], i * 2);
|
|
306
306
|
}
|
|
307
307
|
data[0].key = key;
|
|
308
308
|
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
@@ -365,7 +365,7 @@ export class ArcOnTerrainPlugin {
|
|
|
365
365
|
for (let i = 0; i < generatedPoints.length; i++) {
|
|
366
366
|
const point = generatedPoints[i];
|
|
367
367
|
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
368
|
-
longLatArr.set([longLat[0] /
|
|
368
|
+
longLatArr.set([longLat[0] / RADIAN, longLat[1] / RADIAN], i * 2);
|
|
369
369
|
}
|
|
370
370
|
result.push({
|
|
371
371
|
key: key,
|
|
@@ -103,7 +103,7 @@ export class UniformBlockManager {
|
|
|
103
103
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
104
104
|
const offset = this.offsetMap.get(key);
|
|
105
105
|
if (offset === undefined) {
|
|
106
|
-
throw new Error(`Uniform block member ${key} not found in offset map
|
|
106
|
+
throw new Error(`Uniform block member ${key} not found in offset map.\nPossible members: ${Array.from(this.offsetMap.keys()).join(", ")}`);
|
|
107
107
|
}
|
|
108
108
|
// @ts-ignore
|
|
109
109
|
const type = this.blockMembers.find(member => member.name === key).type;
|
|
@@ -121,7 +121,7 @@ export class UniformBlockManager {
|
|
|
121
121
|
data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
|
-
throw new Error(`Unsupported value type for ${key}: ${typeof value}
|
|
124
|
+
throw new Error(`Unsupported value type for ${key}: ${typeof value}.\n Supported types are: number, Array, ArrayBuffer, TypedArray.`);
|
|
125
125
|
}
|
|
126
126
|
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
127
127
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
@@ -131,7 +131,7 @@ export class UniformBlockManager {
|
|
|
131
131
|
for (const [name, value] of nameValueMap.entries()) {
|
|
132
132
|
const offset = this.offsetMap.get(name);
|
|
133
133
|
if (offset === undefined) {
|
|
134
|
-
throw new Error(`Uniform block member ${name} not found in offset map
|
|
134
|
+
throw new Error(`Uniform block member ${name} not found in offset map.\nPossible members: ${Array.from(this.offsetMap.keys()).join(", ")}`);
|
|
135
135
|
}
|
|
136
136
|
// @ts-ignore
|
|
137
137
|
const type = this.blockMembers.find(member => member.name === name).type;
|
|
@@ -148,7 +148,7 @@ export class UniformBlockManager {
|
|
|
148
148
|
else if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
149
149
|
data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
|
|
150
150
|
else {
|
|
151
|
-
throw new Error(`Unsupported value type for ${name}: ${typeof value}
|
|
151
|
+
throw new Error(`Unsupported value type for ${name}: ${typeof value}.\n Supported types are: number, Array, ArrayBuffer, TypedArray.`);
|
|
152
152
|
}
|
|
153
153
|
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
154
154
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Z in kolometers
|
|
2
2
|
//
|
|
3
|
+
const EPSILON = 0.00001;
|
|
3
4
|
export const POLE = `
|
|
4
5
|
#ifndef POLE
|
|
5
6
|
#define POLE 20037508.34
|
|
@@ -197,6 +198,11 @@ float realDistanceOnSphereR1(vec2 longLat1, vec2 longLat2) {
|
|
|
197
198
|
return c;
|
|
198
199
|
}
|
|
199
200
|
`;
|
|
201
|
+
export const isPointInBBox = `
|
|
202
|
+
bool isPointInBBox(vec2 point, vec4 bbox) {
|
|
203
|
+
return point.x + ${EPSILON} >= bbox.x && point.x <= bbox.z + ${EPSILON} && point.y + ${EPSILON} >= bbox.y && point.y <= bbox.w + ${EPSILON};
|
|
204
|
+
}
|
|
205
|
+
`;
|
|
200
206
|
const pointsOnSphereBetween = `
|
|
201
207
|
vec3 pointsOnSphereBetween(vec3 a, vec3 b, float ratio) {
|
|
202
208
|
// Normalize the input points to ensure they are on the unit sphere
|