ol 10.0.1-dev.1723624515788 → 10.0.1-dev.1723833631932
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/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/expr/expression.d.ts +3 -0
- package/expr/expression.d.ts.map +1 -1
- package/expr/expression.js +5 -0
- package/expr/gpu.js +1 -0
- package/geom/flat/transform.d.ts +2 -1
- package/geom/flat/transform.d.ts.map +1 -1
- package/geom/flat/transform.js +8 -0
- package/package.json +1 -1
- package/render/webgl/MixedGeometryBatch.d.ts +1 -0
- package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
- package/render/webgl/MixedGeometryBatch.js +37 -3
- package/render/webgl/VectorStyleRenderer.d.ts +2 -0
- package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
- package/render/webgl/VectorStyleRenderer.js +12 -0
- package/render/webgl/renderinstructions.d.ts.map +1 -1
- package/render/webgl/renderinstructions.js +7 -5
- package/render/webgl/utils.d.ts.map +1 -1
- package/render/webgl/utils.js +12 -1
- package/util.js +1 -1
- package/webgl/ShaderBuilder.d.ts +1 -1
- package/webgl/ShaderBuilder.d.ts.map +1 -1
- package/webgl/ShaderBuilder.js +16 -4
- package/worker/webgl.js +1 -1
package/expr/expression.d.ts
CHANGED
|
@@ -139,6 +139,9 @@ export type ArgValidator = (arg0: Array<EncodedExpression>, arg1: number, arg2:
|
|
|
139
139
|
* * `['time']` The time in seconds since the creation of the layer (WebGL only).
|
|
140
140
|
* * `['var', 'varName']` fetches a value from the style variables; will throw an error if that variable is undefined
|
|
141
141
|
* * `['zoom']` The current zoom level (WebGL only).
|
|
142
|
+
* * `['line-metric']` returns the M component of the current point on a line (WebGL only); in case where the geometry layout of the line
|
|
143
|
+
* does not contain an M component (e.g. XY or XYZ), 0 is returned; 0 is also returned for geometries other than lines.
|
|
144
|
+
* Please note that the M component will be linearly interpolated between the two points composing a segment.
|
|
142
145
|
*
|
|
143
146
|
* * Math operators:
|
|
144
147
|
* * `['*', value1, value2, ...]` multiplies the values (either numbers or colors)
|
package/expr/expression.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["expression.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["expression.js"],"names":[],"mappings":"AAoKA;;;;GAIG;AACH,+BAHW,MAAM,GACL,MAAM,CAgBjB;AAED;;;;GAIG;AACH,oCAJW,MAAM,YACN,MAAM,GACL,OAAO,CAIlB;AAED;;;;GAIG;AACH,sCAJW,MAAM,aACN,MAAM,GACL,OAAO,CAIlB;AAED;;;;GAIG;AACH,6BAJW,MAAM,YACN,MAAM,GACL,OAAO,CAIlB;AAmCD;;GAEG;AAEH;;;;;;GAMG;AAEH;;GAEG;AACH,qCAFY,cAAc,CASzB;AAED;;GAEG;AAEH;;;;;GAKG;AACH,+BALW,iBAAiB,gBACjB,MAAM,WACN,cAAc,GACb,UAAU,CA6FrB;AAuoBD;;;;GAIG;AACH,8CAHW,OAAO,qBAAqB,EAAE,OAAO,GAAC,OAAO,sBAAsB,EAAE,OAAO,GAC3E,OAAO,GAAC,YAAY,GAAC,SAAS,GAAC,EAAE,CA2B5C;AA/4BD,yBAA0B;AAC1B,iCAA2C;AAC3C,gCAA0C;AAC1C,gCAA0C;AAC1C,+BAAyC;AACzC,qCAA+C;AAC/C,8BAAwC;AACxC,6BAAiD;AAqEjD;;GAEG;AAEH;IACE;;;OAGG;IACH,kBAHW,MAAM,SACN,YAAY,EAUtB;IAFC,aAAgB;IAChB,oBAAkB;CAErB;AAED;IACE;;;;OAIG;IACH,kBAJW,MAAM,YACN,MAAM,WACH,UAAU,EAAA,EAMvB;IAHC,aAAgB;IAChB,iBAAwB;IACxB,mBAAgB;CAEnB;AAiID;;GAEG;AACH,kBAFU;QAAO,MAAM,GAAE,MAAM;CAAC,CAkD9B;yBAjLW,iBAAiB,GAAC,cAAc;;;;;eAK/B,GAAG,CAAC,MAAM,CAAC;;;;gBACX,GAAG,CAAC,MAAM,CAAC;;;;eACX,OAAO;;;;kBACP,OAAO;;gCAgBR,YAAY,QAAM;;;;;2BAyUlB,CAAS,IAAwB,EAAxB,KAAK,CAAC,iBAAiB,CAAC,EAAE,IAAM,EAAN,MAAM,EAAE,IAAc,EAAd,cAAc,KAAE,KAAK,CAAC,UAAU,CAAC,GAAC,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BApdjF,KAAK,CAAC,GAAC,CAAC,GAAC,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,GAAC,MAAM,GAAC,OAAO;2BAkF1D,OAAO,GAAC,MAAM,GAAC,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC;;;;qBAqNnC,CAAS,IAAK,SAAE,IAAM,EAAN,MAAM,EAAE,IAAc,EAAd,cAAc,KAAE,UAAU"}
|
package/expr/expression.js
CHANGED
|
@@ -37,6 +37,9 @@ import {toSize} from '../size.js';
|
|
|
37
37
|
* * `['time']` The time in seconds since the creation of the layer (WebGL only).
|
|
38
38
|
* * `['var', 'varName']` fetches a value from the style variables; will throw an error if that variable is undefined
|
|
39
39
|
* * `['zoom']` The current zoom level (WebGL only).
|
|
40
|
+
* * `['line-metric']` returns the M component of the current point on a line (WebGL only); in case where the geometry layout of the line
|
|
41
|
+
* does not contain an M component (e.g. XY or XYZ), 0 is returned; 0 is also returned for geometries other than lines.
|
|
42
|
+
* Please note that the M component will be linearly interpolated between the two points composing a segment.
|
|
40
43
|
*
|
|
41
44
|
* * Math operators:
|
|
42
45
|
* * `['*', value1, value2, ...]` multiplies the values (either numbers or colors)
|
|
@@ -375,6 +378,7 @@ export const Ops = {
|
|
|
375
378
|
Var: 'var',
|
|
376
379
|
Concat: 'concat',
|
|
377
380
|
GeometryType: 'geometry-type',
|
|
381
|
+
LineMetric: 'line-metric',
|
|
378
382
|
Any: 'any',
|
|
379
383
|
All: 'all',
|
|
380
384
|
Not: '!',
|
|
@@ -438,6 +442,7 @@ const parsers = {
|
|
|
438
442
|
withArgsOfType(StringType),
|
|
439
443
|
),
|
|
440
444
|
[Ops.GeometryType]: createCallExpressionParser(usesGeometryType, withNoArgs),
|
|
445
|
+
[Ops.LineMetric]: createCallExpressionParser(withNoArgs),
|
|
441
446
|
[Ops.Resolution]: createCallExpressionParser(withNoArgs),
|
|
442
447
|
[Ops.Zoom]: createCallExpressionParser(withNoArgs),
|
|
443
448
|
[Ops.Time]: createCallExpressionParser(withNoArgs),
|
package/expr/gpu.js
CHANGED
|
@@ -239,6 +239,7 @@ const compilers = {
|
|
|
239
239
|
const prefix = context.inFragmentShader ? 'v_prop_' : 'a_prop_';
|
|
240
240
|
return prefix + propName;
|
|
241
241
|
},
|
|
242
|
+
[Ops.LineMetric]: () => 'currentLineMetric', // this variable is assumed to always be present in shaders, default is 0.
|
|
242
243
|
[Ops.Var]: (context, expression) => {
|
|
243
244
|
const firstArg = /** @type {LiteralExpression} */ (expression.args[0]);
|
|
244
245
|
const varName = /** @type {string} */ (firstArg.value);
|
package/geom/flat/transform.d.ts
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* @param {number} stride Stride.
|
|
9
9
|
* @param {import("../../transform.js").Transform} transform Transform.
|
|
10
10
|
* @param {Array<number>} [dest] Destination.
|
|
11
|
+
* @param {number} [destinationStride] Stride of destination coordinates; if unspecified, assumed to be 2.
|
|
11
12
|
* @return {Array<number>} Transformed coordinates.
|
|
12
13
|
*/
|
|
13
|
-
export function transform2D(flatCoordinates: Array<number>, offset: number, end: number, stride: number, transform: import("../../transform.js").Transform, dest?: number[] | undefined): Array<number>;
|
|
14
|
+
export function transform2D(flatCoordinates: Array<number>, offset: number, end: number, stride: number, transform: import("../../transform.js").Transform, dest?: number[] | undefined, destinationStride?: number | undefined): Array<number>;
|
|
14
15
|
/**
|
|
15
16
|
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
16
17
|
* @param {number} offset Offset.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["transform.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["transform.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;GASG;AACH,6CATW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,OACN,MAAM,UACN,MAAM,aACN,OAAO,oBAAoB,EAAE,SAAS,wEAGrC,KAAK,CAAC,MAAM,CAAC,CA6BxB;AAED;;;;;;;;;GASG;AACH,wCATW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,OACN,MAAM,UACN,MAAM,SACN,MAAM,UACN,KAAK,CAAC,MAAM,CAAC,gCAEZ,KAAK,CAAC,MAAM,CAAC,CA8BxB;AAED;;;;;;;;;;;GAWG;AACH,uCAVW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,OACN,MAAM,UACN,MAAM,MACN,MAAM,MACN,MAAM,UACN,KAAK,CAAC,MAAM,CAAC,gCAEZ,KAAK,CAAC,MAAM,CAAC,CA6BxB;AAED;;;;;;;;;GASG;AACH,2CATW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,OACN,MAAM,UACN,MAAM,UACN,MAAM,UACN,MAAM,gCAEL,KAAK,CAAC,MAAM,CAAC,CAwBxB"}
|
package/geom/flat/transform.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @param {number} stride Stride.
|
|
10
10
|
* @param {import("../../transform.js").Transform} transform Transform.
|
|
11
11
|
* @param {Array<number>} [dest] Destination.
|
|
12
|
+
* @param {number} [destinationStride] Stride of destination coordinates; if unspecified, assumed to be 2.
|
|
12
13
|
* @return {Array<number>} Transformed coordinates.
|
|
13
14
|
*/
|
|
14
15
|
export function transform2D(
|
|
@@ -18,15 +19,22 @@ export function transform2D(
|
|
|
18
19
|
stride,
|
|
19
20
|
transform,
|
|
20
21
|
dest,
|
|
22
|
+
destinationStride,
|
|
21
23
|
) {
|
|
22
24
|
dest = dest ? dest : [];
|
|
25
|
+
destinationStride = destinationStride ? destinationStride : 2;
|
|
23
26
|
let i = 0;
|
|
24
27
|
for (let j = offset; j < end; j += stride) {
|
|
25
28
|
const x = flatCoordinates[j];
|
|
26
29
|
const y = flatCoordinates[j + 1];
|
|
27
30
|
dest[i++] = transform[0] * x + transform[2] * y + transform[4];
|
|
28
31
|
dest[i++] = transform[1] * x + transform[3] * y + transform[5];
|
|
32
|
+
|
|
33
|
+
for (let k = 2; k < destinationStride; k++) {
|
|
34
|
+
dest[i++] = flatCoordinates[j + k];
|
|
35
|
+
}
|
|
29
36
|
}
|
|
37
|
+
|
|
30
38
|
if (dest && dest.length != i) {
|
|
31
39
|
dest.length = i;
|
|
32
40
|
}
|
package/package.json
CHANGED
|
@@ -226,6 +226,7 @@ declare class MixedGeometryBatch {
|
|
|
226
226
|
* @param {Feature|RenderFeature} feature Feature
|
|
227
227
|
* @param {string} featureUid Feature uid
|
|
228
228
|
* @param {number} stride Stride
|
|
229
|
+
* @param {import('../../geom/Geometry.js').GeometryLayout} [layout] Layout
|
|
229
230
|
* @private
|
|
230
231
|
*/
|
|
231
232
|
private addCoordinates_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixedGeometryBatch.d.ts","sourceRoot":"","sources":["MixedGeometryBatch.js"],"names":[],"mappings":";sBAQa,OAAO,kBAAkB,EAAE,OAAO;2BAGlC,OAAO,wBAAwB,EAAE,IAAI;;;;;;;;aAKpC,OAAO,GAAC,aAAa;;;;iBACrB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;;;;;;;;;;;;;;;;;;4BAQrB,kBAAkB,GAAC,uBAAuB,GAAC,oBAAoB;;;;;;;;;aAK9D;YAAO,MAAM,GAAE,iBAAiB;KAAC;;;;qBAEjC,MAAM;;;;mBACN,MAAM;;;;gBACN,MAAM;;;;;;;;;;aAKN;YAAO,MAAM,GAAE,iBAAiB;KAAC;;;;qBAEjC,MAAM;;;;mBACN,MAAM;;;;;;;;;;aAKN;YAAO,MAAM,GAAE,iBAAiB;KAAC;;;;qBAEjC,MAAM;;AA1CpB;;GAEG;AACH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAEI;;OAEG;IACH,uBAAuB;IAEvB;;;;OAIG;IACH,sBAA8B;IAE9B;;;;OAIG;IACH,kBAA0B;IAE1B;;;;;OAKG;IACH,uBAAwB;IAExB;;OAEG;IACH,cAFU,oBAAoB,CAO7B;IAED;;OAEG;IACH,YAFU,kBAAkB,CAK3B;IAED;;OAEG;IACH,iBAFU,uBAAuB,CAMhC;IAGH;;;OAGG;IACH,sBAHW,KAAK,CAAC,OAAO,GAAC,aAAa,CAAC,qFAOtC;IAED;;;OAGG;IACH,oBAHW,OAAO,GAAC,aAAa,qFAa/B;IAED;;;;OAIG;IACH,uCAQC;IAED;;;;OAIG;IACH,4CASC;IAED;;;;OAIG;IACH,yCAUC;IAED;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"MixedGeometryBatch.d.ts","sourceRoot":"","sources":["MixedGeometryBatch.js"],"names":[],"mappings":";sBAQa,OAAO,kBAAkB,EAAE,OAAO;2BAGlC,OAAO,wBAAwB,EAAE,IAAI;;;;;;;;aAKpC,OAAO,GAAC,aAAa;;;;iBACrB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;;;;;;;;;;;;;;;;;;4BAQrB,kBAAkB,GAAC,uBAAuB,GAAC,oBAAoB;;;;;;;;;aAK9D;YAAO,MAAM,GAAE,iBAAiB;KAAC;;;;qBAEjC,MAAM;;;;mBACN,MAAM;;;;gBACN,MAAM;;;;;;;;;;aAKN;YAAO,MAAM,GAAE,iBAAiB;KAAC;;;;qBAEjC,MAAM;;;;mBACN,MAAM;;;;;;;;;;aAKN;YAAO,MAAM,GAAE,iBAAiB;KAAC;;;;qBAEjC,MAAM;;AA1CpB;;GAEG;AACH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAEI;;OAEG;IACH,uBAAuB;IAEvB;;;;OAIG;IACH,sBAA8B;IAE9B;;;;OAIG;IACH,kBAA0B;IAE1B;;;;;OAKG;IACH,uBAAwB;IAExB;;OAEG;IACH,cAFU,oBAAoB,CAO7B;IAED;;OAEG;IACH,YAFU,kBAAkB,CAK3B;IAED;;OAEG;IACH,iBAFU,uBAAuB,CAMhC;IAGH;;;OAGG;IACH,sBAHW,KAAK,CAAC,OAAO,GAAC,aAAa,CAAC,qFAOtC;IAED;;;OAGG;IACH,oBAHW,OAAO,GAAC,aAAa,qFAa/B;IAED;;;;OAIG;IACH,uCAQC;IAED;;;;OAIG;IACH,4CASC;IAED;;;;OAIG;IACH,yCAUC;IAED;;;;OAIG;IACH,qBA2GC;IAED;;;;;;;;;OASG;IACH,wBAyJC;IAED;;;;;OAKG;IACH,uBAYC;IAED;;;;;OAKG;IACH,mBAOC;IAED;;OAEG;IACH,uBAFW,OAAO,GAAC,aAAa,QAS/B;IAED;;OAEG;IACH,uBAFW,OAAO,GAAC,aAAa,QAU/B;IAED,cAcC;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,GAAC,aAAa,CAIhC;CACF;0BAljByB,yBAAyB"}
|
|
@@ -295,13 +295,17 @@ class MixedGeometryBatch {
|
|
|
295
295
|
const lineGeom = /** @type {import("../../geom.js").LineString} */ (
|
|
296
296
|
geometry
|
|
297
297
|
);
|
|
298
|
+
|
|
299
|
+
const stride = lineGeom.getStride();
|
|
300
|
+
|
|
298
301
|
this.addCoordinates_(
|
|
299
302
|
type,
|
|
300
303
|
lineGeom.getFlatCoordinates(),
|
|
301
304
|
null,
|
|
302
305
|
feature,
|
|
303
306
|
getUid(feature),
|
|
304
|
-
|
|
307
|
+
stride,
|
|
308
|
+
lineGeom.getLayout?.(),
|
|
305
309
|
);
|
|
306
310
|
break;
|
|
307
311
|
}
|
|
@@ -317,9 +321,10 @@ class MixedGeometryBatch {
|
|
|
317
321
|
* @param {Feature|RenderFeature} feature Feature
|
|
318
322
|
* @param {string} featureUid Feature uid
|
|
319
323
|
* @param {number} stride Stride
|
|
324
|
+
* @param {import('../../geom/Geometry.js').GeometryLayout} [layout] Layout
|
|
320
325
|
* @private
|
|
321
326
|
*/
|
|
322
|
-
addCoordinates_(type, flatCoords, ends, feature, featureUid, stride) {
|
|
327
|
+
addCoordinates_(type, flatCoords, ends, feature, featureUid, stride, layout) {
|
|
323
328
|
/** @type {number} */
|
|
324
329
|
let verticesCount;
|
|
325
330
|
switch (type) {
|
|
@@ -343,6 +348,7 @@ class MixedGeometryBatch {
|
|
|
343
348
|
feature,
|
|
344
349
|
featureUid,
|
|
345
350
|
stride,
|
|
351
|
+
layout,
|
|
346
352
|
);
|
|
347
353
|
}
|
|
348
354
|
break;
|
|
@@ -358,6 +364,7 @@ class MixedGeometryBatch {
|
|
|
358
364
|
feature,
|
|
359
365
|
featureUid,
|
|
360
366
|
stride,
|
|
367
|
+
layout,
|
|
361
368
|
);
|
|
362
369
|
}
|
|
363
370
|
break;
|
|
@@ -371,6 +378,7 @@ class MixedGeometryBatch {
|
|
|
371
378
|
feature,
|
|
372
379
|
featureUid,
|
|
373
380
|
null,
|
|
381
|
+
null,
|
|
374
382
|
);
|
|
375
383
|
}
|
|
376
384
|
break;
|
|
@@ -386,6 +394,7 @@ class MixedGeometryBatch {
|
|
|
386
394
|
feature,
|
|
387
395
|
featureUid,
|
|
388
396
|
stride,
|
|
397
|
+
layout,
|
|
389
398
|
);
|
|
390
399
|
return;
|
|
391
400
|
}
|
|
@@ -427,6 +436,7 @@ class MixedGeometryBatch {
|
|
|
427
436
|
feature,
|
|
428
437
|
featureUid,
|
|
429
438
|
stride,
|
|
439
|
+
layout,
|
|
430
440
|
);
|
|
431
441
|
}
|
|
432
442
|
break;
|
|
@@ -460,7 +470,7 @@ class MixedGeometryBatch {
|
|
|
460
470
|
this.lineStringBatch.verticesCount += verticesCount;
|
|
461
471
|
this.lineStringBatch.geometriesCount++;
|
|
462
472
|
this.lineStringBatch.entries[featureUid].flatCoordss.push(
|
|
463
|
-
|
|
473
|
+
getFlatCoordinatesXYM(flatCoords, stride, layout),
|
|
464
474
|
);
|
|
465
475
|
this.lineStringBatch.entries[featureUid].verticesCount += verticesCount;
|
|
466
476
|
break;
|
|
@@ -567,4 +577,28 @@ function getFlatCoordinatesXY(flatCoords, stride) {
|
|
|
567
577
|
return flatCoords.filter((v, i) => i % stride < 2);
|
|
568
578
|
}
|
|
569
579
|
|
|
580
|
+
/**
|
|
581
|
+
* @param {Array<number>} flatCoords Flat coords
|
|
582
|
+
* @param {number} stride Stride
|
|
583
|
+
* @param {string} layout Layout
|
|
584
|
+
* @return {Array<number>} Flat coords with only XY components
|
|
585
|
+
*/
|
|
586
|
+
function getFlatCoordinatesXYM(flatCoords, stride, layout) {
|
|
587
|
+
if (stride === 3 && layout === 'XYM') {
|
|
588
|
+
return flatCoords;
|
|
589
|
+
}
|
|
590
|
+
// this is XYZM layout
|
|
591
|
+
if (stride === 4) {
|
|
592
|
+
return flatCoords.filter((v, i) => i % stride !== 2);
|
|
593
|
+
}
|
|
594
|
+
// this is XYZ layout
|
|
595
|
+
if (stride === 3) {
|
|
596
|
+
return flatCoords.map((v, i) => (i % stride !== 2 ? v : 0));
|
|
597
|
+
}
|
|
598
|
+
// this is XY layout
|
|
599
|
+
return new Array(flatCoords.length * 1.5)
|
|
600
|
+
.fill(0)
|
|
601
|
+
.map((v, i) => (i % 3 === 2 ? 0 : flatCoords[Math.round(i / 1.5)]));
|
|
602
|
+
}
|
|
603
|
+
|
|
570
604
|
export default MixedGeometryBatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VectorStyleRenderer.d.ts","sourceRoot":"","sources":["VectorStyleRenderer.js"],"names":[],"mappings":";;;;yBA4BU,MAAM
|
|
1
|
+
{"version":3,"file":"VectorStyleRenderer.d.ts","sourceRoot":"","sources":["VectorStyleRenderer.js"],"names":[],"mappings":";;;;yBA4BU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmBF,CAAS,IAAwD,EAAnD,OAAO,yBAAyB,EAAE,iBAAiB,EAAE,IAAmC,EAAnC,OAAO,eAAe,EAAE,WAAW,KAAE,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC;;mCAK7H;QAAO,MAAM,GAAE,mBAAmB;CAAC;iCACnC;QAAO,MAAM,GAAE,OAAO,oBAAoB,EAAE,YAAY;CAAC;;;;;oBAKxD,KAAK,CAAC,gBAAgB,CAAC;;;;uBACvB,KAAK,CAAC,gBAAgB,CAAC;;;;kBACvB,KAAK,CAAC,gBAAgB,CAAC;;;;6BACvB,OAAO,oBAAoB,EAAE,SAAS;;;;;;yBAKtC,YAAY,GAAC,IAAI;;;;4BACjB,YAAY,GAAC,IAAI;;;;uBACjB,YAAY,GAAC,IAAI;;;;;;;;;YAKjB,MAAM;;;;cACN,MAAM;;;;;;aAKN,OAAO,8BAA8B,EAAE,aAAa;;;;;;;;;;;;;;;0BAOrD,OAAO,sBAAsB,EAAE,UAAU,GAAC,YAAY;AA5CnE;;;;;;;GAOG;AAEH;;;GAGG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;GAaG;AACH;IACE;;;;OAIG;IACH,4BAJW,WAAW,UACX,OAAO,uBAAuB,EAAE,OAAO,sBACvC,OAAO,EA0MjB;IAvMC;;OAEG;IACH,gBAAqB;IAErB;;OAEG;IACH,6BAA8C;IAgB9C;;;OAGG;IACH,iBAAuD;IAErD;;OAEG;IACH,0BAA8D;IAC9D;;OAEG;IACH,4BAAkE;IAClE;;OAEG;IACH,qBAGC;IAGH;;;OAGG;IACH,mBAA2D;IAEzD;;OAEG;IACH,4BAAkE;IAClE;;OAEG;IACH,8BAAsE;IACtE;;OAEG;IACH,uBAGC;IAGH;;;OAGG;IACH,mBAA2D;IAEzD;;OAEG;IACH,4BAAkE;IAClE;;OAEG;IACH,8BAAsE;IACtE;;OAEG;IACH,uBAGC;IAcH;;OAEG;IACH,0BAIC;IACD;;OAEG;IACH,kBAAiC;IASjC;;;OAGG;IACH,+BAOC;IACD;;;OAGG;IACH,kCAqCC;IACD;;;OAGG;IACH,6BAYC;IAOH;;;;OAIG;IACH,+BAJW,OAAO,yBAAyB,EAAE,OAAO,aACzC,OAAO,oBAAoB,EAAE,SAAS,GACrC,OAAO,CAAC,YAAY,CAAC,CAqChC;IAED;;;;;OAKG;IACH,oCA+BC;IAED;;;;;;OAMG;IACH,gCAuEC;IAED;;;;;OAKG;IACH,gBAJW,YAAY,cACZ,OAAO,cAAc,EAAE,UAAU,qBACjC,MAAY,IAAI,QA8B1B;IAED;;;;;;;;OAQG;IACH,wBAkBC;CACF;6BArhB4B,uBAAuB"}
|
|
@@ -33,6 +33,8 @@ export const Attributes = {
|
|
|
33
33
|
INDEX: 'a_index',
|
|
34
34
|
SEGMENT_START: 'a_segmentStart',
|
|
35
35
|
SEGMENT_END: 'a_segmentEnd',
|
|
36
|
+
MEASURE_START: 'a_measureStart',
|
|
37
|
+
MEASURE_END: 'a_measureEnd',
|
|
36
38
|
PARAMETERS: 'a_parameters',
|
|
37
39
|
JOIN_ANGLES: 'a_joinAngles',
|
|
38
40
|
DISTANCE: 'a_distance',
|
|
@@ -252,11 +254,21 @@ class VectorStyleRenderer {
|
|
|
252
254
|
size: 2,
|
|
253
255
|
type: AttributeType.FLOAT,
|
|
254
256
|
},
|
|
257
|
+
{
|
|
258
|
+
name: Attributes.MEASURE_START,
|
|
259
|
+
size: 1,
|
|
260
|
+
type: AttributeType.FLOAT,
|
|
261
|
+
},
|
|
255
262
|
{
|
|
256
263
|
name: Attributes.SEGMENT_END,
|
|
257
264
|
size: 2,
|
|
258
265
|
type: AttributeType.FLOAT,
|
|
259
266
|
},
|
|
267
|
+
{
|
|
268
|
+
name: Attributes.MEASURE_END,
|
|
269
|
+
size: 1,
|
|
270
|
+
type: AttributeType.FLOAT,
|
|
271
|
+
},
|
|
260
272
|
{
|
|
261
273
|
name: Attributes.JOIN_ANGLES,
|
|
262
274
|
size: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderinstructions.d.ts","sourceRoot":"","sources":["renderinstructions.js"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,0DAHW,OAAO,0BAA0B,EAAE,oBAAoB,GACtD,MAAM,CAOjB;AAED;;;;;;;;GAQG;AACH,uDANW,OAAO,yBAAyB,EAAE,kBAAkB,sBACpD,YAAY,oBACZ,OAAO,0BAA0B,EAAE,oBAAoB,aACvD,OAAO,oBAAoB,EAAE,SAAS,GACrC,YAAY,CAyCvB;AAED;;;;;;;;GAQG;AACH,4DANW,OAAO,yBAAyB,EAAE,uBAAuB,sBACzD,YAAY,oBACZ,OAAO,0BAA0B,EAAE,oBAAoB,aACvD,OAAO,oBAAoB,EAAE,SAAS,GACrC,YAAY,
|
|
1
|
+
{"version":3,"file":"renderinstructions.d.ts","sourceRoot":"","sources":["renderinstructions.js"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,0DAHW,OAAO,0BAA0B,EAAE,oBAAoB,GACtD,MAAM,CAOjB;AAED;;;;;;;;GAQG;AACH,uDANW,OAAO,yBAAyB,EAAE,kBAAkB,sBACpD,YAAY,oBACZ,OAAO,0BAA0B,EAAE,oBAAoB,aACvD,OAAO,oBAAoB,EAAE,SAAS,GACrC,YAAY,CAyCvB;AAED;;;;;;;;GAQG;AACH,4DANW,OAAO,yBAAyB,EAAE,uBAAuB,sBACzD,YAAY,oBACZ,OAAO,0BAA0B,EAAE,oBAAoB,aACvD,OAAO,oBAAoB,EAAE,SAAS,GACrC,YAAY,CAyDvB;AAED;;;;;;;;GAQG;AACH,yDANW,OAAO,yBAAyB,EAAE,oBAAoB,sBACtD,YAAY,oBACZ,OAAO,0BAA0B,EAAE,oBAAoB,aACvD,OAAO,oBAAoB,EAAE,SAAS,GACrC,YAAY,CAoEvB"}
|
|
@@ -115,11 +115,11 @@ export function generateLineStringRenderInstructions(
|
|
|
115
115
|
transform,
|
|
116
116
|
) {
|
|
117
117
|
// here we anticipate the amount of render instructions for lines:
|
|
118
|
-
//
|
|
118
|
+
// 3 instructions per vertex for position (x, y and m)
|
|
119
119
|
// + 1 instruction per line per custom attributes
|
|
120
120
|
// + 1 instruction per line (for vertices count)
|
|
121
121
|
const totalInstructionsCount =
|
|
122
|
-
|
|
122
|
+
3 * batch.verticesCount +
|
|
123
123
|
(1 + getCustomAttributesSize(customAttributes)) * batch.geometriesCount;
|
|
124
124
|
if (
|
|
125
125
|
!renderInstructions ||
|
|
@@ -139,9 +139,10 @@ export function generateLineStringRenderInstructions(
|
|
|
139
139
|
batchEntry.flatCoordss[i],
|
|
140
140
|
0,
|
|
141
141
|
flatCoords.length,
|
|
142
|
-
|
|
142
|
+
3,
|
|
143
143
|
transform,
|
|
144
144
|
flatCoords,
|
|
145
|
+
3,
|
|
145
146
|
);
|
|
146
147
|
renderIndex += pushCustomAttributesInRenderInstructions(
|
|
147
148
|
renderInstructions,
|
|
@@ -151,12 +152,13 @@ export function generateLineStringRenderInstructions(
|
|
|
151
152
|
);
|
|
152
153
|
|
|
153
154
|
// vertices count
|
|
154
|
-
renderInstructions[renderIndex++] = flatCoords.length /
|
|
155
|
+
renderInstructions[renderIndex++] = flatCoords.length / 3;
|
|
155
156
|
|
|
156
157
|
// looping on points for positions
|
|
157
|
-
for (let j = 0, jj = flatCoords.length; j < jj; j +=
|
|
158
|
+
for (let j = 0, jj = flatCoords.length; j < jj; j += 3) {
|
|
158
159
|
renderInstructions[renderIndex++] = flatCoords[j];
|
|
159
160
|
renderInstructions[renderIndex++] = flatCoords[j + 1];
|
|
161
|
+
renderInstructions[renderIndex++] = flatCoords[j + 2];
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAiCA;;;;;;;;;;;;GAYG;AACH,yDAXW,YAAY,gBACZ,MAAM,gBACN,YAAY,eACZ,WAAW,wBACX,MAAM,kDAEL,eAAe,CAgE1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wDAdW,YAAY,qBACZ,MAAM,mBACN,MAAM,sBACN,MAAM,GAAC,IAAI,qBACX,MAAM,GAAC,IAAI,eACX,KAAK,CAAC,MAAM,CAAC,cACb,KAAK,CAAC,MAAM,CAAC,oBACb,KAAK,CAAC,MAAM,CAAC,oBACb,OAAO,oBAAoB,EAAE,SAAS,iBACtC,MAAM,0BACN,MAAM,GACL;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAiCA;;;;;;;;;;;;GAYG;AACH,yDAXW,YAAY,gBACZ,MAAM,gBACN,YAAY,eACZ,WAAW,wBACX,MAAM,kDAEL,eAAe,CAgE1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wDAdW,YAAY,qBACZ,MAAM,mBACN,MAAM,sBACN,MAAM,GAAC,IAAI,qBACX,MAAM,GAAC,IAAI,eACX,KAAK,CAAC,MAAM,CAAC,cACb,KAAK,CAAC,MAAM,CAAC,oBACb,KAAK,CAAC,MAAM,CAAC,oBACb,OAAO,oBAAoB,EAAE,SAAS,iBACtC,MAAM,0BACN,MAAM,GACL;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAgM1C;AAED;;;;;;;;;GASG;AACH,6DARW,YAAY,qBACZ,MAAM,eACN,KAAK,CAAC,MAAM,CAAC,cACb,KAAK,CAAC,MAAM,CAAC,wBACb,MAAM,GACL,MAAM,CA0CjB;AAED;;;;GAIG;AACH,qCAFY,SAAS,CAUpB;AAED;;;;;;GAMG;AACH,kCAJW,MAAM,iCAEL,KAAK,CAAC,MAAM,CAAC,CAWxB;AAED;;;;;GAKG;AACH,qCAHW,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CAWjB;AAxaD,mDAAoD;;;;;;;;oBAQtC,MAAM;;;;mBACN,MAAM"}
|
package/render/webgl/utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function writeLineSegmentToBuffers(
|
|
|
153
153
|
currentAngleTangentSum,
|
|
154
154
|
) {
|
|
155
155
|
// compute the stride to determine how many vertices were already pushed
|
|
156
|
-
const baseVertexAttrsCount =
|
|
156
|
+
const baseVertexAttrsCount = 10; // base attributes: x0, y0, m0, x1, y1, m1, angle0, angle1, distance, params
|
|
157
157
|
const stride = baseVertexAttrsCount + customAttributes.length;
|
|
158
158
|
const baseIndex = vertexArray.length / stride;
|
|
159
159
|
|
|
@@ -166,6 +166,9 @@ export function writeLineSegmentToBuffers(
|
|
|
166
166
|
];
|
|
167
167
|
const p1 = [instructions[segmentEndIndex], instructions[segmentEndIndex + 1]];
|
|
168
168
|
|
|
169
|
+
const m0 = instructions[segmentStartIndex + 2];
|
|
170
|
+
const m1 = instructions[segmentEndIndex + 2];
|
|
171
|
+
|
|
169
172
|
// to compute join angles we need to reproject coordinates back in world units
|
|
170
173
|
const p0world = applyTransform(toWorldTransform, [...p0]);
|
|
171
174
|
const p1world = applyTransform(toWorldTransform, [...p1]);
|
|
@@ -254,8 +257,10 @@ export function writeLineSegmentToBuffers(
|
|
|
254
257
|
vertexArray.push(
|
|
255
258
|
p0[0],
|
|
256
259
|
p0[1],
|
|
260
|
+
m0,
|
|
257
261
|
p1[0],
|
|
258
262
|
p1[1],
|
|
263
|
+
m1,
|
|
259
264
|
angle0,
|
|
260
265
|
angle1,
|
|
261
266
|
currentLength,
|
|
@@ -266,8 +271,10 @@ export function writeLineSegmentToBuffers(
|
|
|
266
271
|
vertexArray.push(
|
|
267
272
|
p0[0],
|
|
268
273
|
p0[1],
|
|
274
|
+
m0,
|
|
269
275
|
p1[0],
|
|
270
276
|
p1[1],
|
|
277
|
+
m1,
|
|
271
278
|
angle0,
|
|
272
279
|
angle1,
|
|
273
280
|
currentLength,
|
|
@@ -278,8 +285,10 @@ export function writeLineSegmentToBuffers(
|
|
|
278
285
|
vertexArray.push(
|
|
279
286
|
p0[0],
|
|
280
287
|
p0[1],
|
|
288
|
+
m0,
|
|
281
289
|
p1[0],
|
|
282
290
|
p1[1],
|
|
291
|
+
m1,
|
|
283
292
|
angle0,
|
|
284
293
|
angle1,
|
|
285
294
|
currentLength,
|
|
@@ -290,8 +299,10 @@ export function writeLineSegmentToBuffers(
|
|
|
290
299
|
vertexArray.push(
|
|
291
300
|
p0[0],
|
|
292
301
|
p0[1],
|
|
302
|
+
m0,
|
|
293
303
|
p1[0],
|
|
294
304
|
p1[1],
|
|
305
|
+
m1,
|
|
295
306
|
angle0,
|
|
296
307
|
angle1,
|
|
297
308
|
currentLength,
|
package/util.js
CHANGED
package/webgl/ShaderBuilder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\n";
|
|
1
|
+
export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n";
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {Object} VaryingDescription
|
|
4
4
|
* @property {string} name Varying name, as will be declared in the header.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"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"}
|
package/webgl/ShaderBuilder.js
CHANGED
|
@@ -27,6 +27,7 @@ uniform mediump int u_hitDetection;
|
|
|
27
27
|
|
|
28
28
|
const float PI = 3.141592653589793238;
|
|
29
29
|
const float TWO_PI = 2.0 * PI;
|
|
30
|
+
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
|
|
30
31
|
`;
|
|
31
32
|
|
|
32
33
|
const DEFAULT_STYLE = createDefaultStyle();
|
|
@@ -601,10 +602,10 @@ ${this.uniforms_
|
|
|
601
602
|
return 'uniform ' + uniform + ';';
|
|
602
603
|
})
|
|
603
604
|
.join('\n')}
|
|
604
|
-
attribute vec2 a_position;
|
|
605
|
-
attribute float a_index;
|
|
606
605
|
attribute vec2 a_segmentStart;
|
|
607
606
|
attribute vec2 a_segmentEnd;
|
|
607
|
+
attribute float a_measureStart;
|
|
608
|
+
attribute float a_measureEnd;
|
|
608
609
|
attribute float a_parameters;
|
|
609
610
|
attribute float a_distance;
|
|
610
611
|
attribute vec2 a_joinAngles;
|
|
@@ -621,6 +622,8 @@ varying float v_angleEnd;
|
|
|
621
622
|
varying float v_width;
|
|
622
623
|
varying vec4 v_prop_hitColor;
|
|
623
624
|
varying float v_distanceOffsetPx;
|
|
625
|
+
varying float v_measureStart;
|
|
626
|
+
varying float v_measureEnd;
|
|
624
627
|
${this.varyings_
|
|
625
628
|
.map(function (varying) {
|
|
626
629
|
return 'varying ' + varying.type + ' ' + varying.name + ';';
|
|
@@ -663,6 +666,7 @@ void main(void) {
|
|
|
663
666
|
v_angleStart = a_joinAngles.x;
|
|
664
667
|
v_angleEnd = a_joinAngles.y;
|
|
665
668
|
float vertexNumber = floor(abs(a_parameters) / 10000. + 0.5);
|
|
669
|
+
currentLineMetric = vertexNumber < 1.5 ? a_measureStart : a_measureEnd;
|
|
666
670
|
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
|
|
667
671
|
float angleTangentSum = fract(abs(a_parameters) / 10000.) * 10000. * sign(a_parameters);
|
|
668
672
|
|
|
@@ -697,6 +701,8 @@ void main(void) {
|
|
|
697
701
|
v_width = lineWidth;
|
|
698
702
|
v_prop_hitColor = a_prop_hitColor;
|
|
699
703
|
v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * angleTangentSum);
|
|
704
|
+
v_measureStart = a_measureStart;
|
|
705
|
+
v_measureEnd = a_measureEnd;
|
|
700
706
|
${this.varyings_
|
|
701
707
|
.map(function (varying) {
|
|
702
708
|
return ' ' + varying.name + ' = ' + varying.expression + ';';
|
|
@@ -728,6 +734,8 @@ varying float v_angleEnd;
|
|
|
728
734
|
varying float v_width;
|
|
729
735
|
varying vec4 v_prop_hitColor;
|
|
730
736
|
varying float v_distanceOffsetPx;
|
|
737
|
+
varying float v_measureStart;
|
|
738
|
+
varying float v_measureEnd;
|
|
731
739
|
${this.varyings_
|
|
732
740
|
.map(function (varying) {
|
|
733
741
|
return 'varying ' + varying.type + ' ' + varying.name + ';';
|
|
@@ -833,15 +841,19 @@ void main(void) {
|
|
|
833
841
|
discard;
|
|
834
842
|
}
|
|
835
843
|
#endif
|
|
836
|
-
if (${this.discardExpression_}) { discard; }
|
|
837
844
|
|
|
838
845
|
float segmentLength = length(v_segmentEnd - v_segmentStart);
|
|
839
846
|
vec2 segmentTangent = (v_segmentEnd - v_segmentStart) / segmentLength;
|
|
840
847
|
vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
|
|
841
848
|
vec2 startToPoint = currentPoint - v_segmentStart;
|
|
842
|
-
float
|
|
849
|
+
float lengthToPoint = max(0., min(dot(segmentTangent, startToPoint), segmentLength));
|
|
850
|
+
float currentLengthPx = lengthToPoint + v_distanceOffsetPx;
|
|
843
851
|
float currentRadiusPx = abs(dot(segmentNormal, startToPoint));
|
|
844
852
|
float currentRadiusRatio = dot(segmentNormal, startToPoint) * 2. / v_width;
|
|
853
|
+
currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPoint / segmentLength);
|
|
854
|
+
|
|
855
|
+
if (${this.discardExpression_}) { discard; }
|
|
856
|
+
|
|
845
857
|
vec4 color = ${this.strokeColorExpression_};
|
|
846
858
|
float capType = ${this.strokeCapExpression_};
|
|
847
859
|
float joinType = ${this.strokeJoinExpression_};
|
package/worker/webgl.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
export function create() {
|
|
3
|
-
const source = "const t=\"GENERATE_POLYGON_BUFFERS\",e=\"GENERATE_POINT_BUFFERS\",n=\"GENERATE_LINE_STRING_BUFFERS\";function r(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function x(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,\"Transformation matrix cannot be inverted\");const x=e[0],o=e[1],u=e[2],i=e[3],f=e[4],s=e[5];return t[0]=i/n,t[1]=-o/n,t[2]=-u/n,t[3]=x/n,t[4]=(u*s-i*f)/n,t[5]=-(x*s-o*f)/n,t}function o(t,e,n=2){const r=e&&e.length,x=r?e[0]*n:t.length;let o=u(t,0,x,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(r&&(o=function(t,e,n,r){const x=[];for(let n=0,o=e.length;n<o;n++){const i=u(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1);i===i.next&&(i.steiner=!0),x.push(g(i))}x.sort(y);for(let t=0;t<x.length;t++)n=h(x[t],n);return n}(t,e,o,n)),t.length>80*n){s=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=n;o<x;o+=n){const n=t[o],x=t[o+1];n<s&&(s=n),x<l&&(l=x),n>e&&(e=n),x>r&&(r=x)}c=Math.max(e-s,r-l),c=0!==c?32767/c:0}return f(o,i,n,s,l,c,0),i}function u(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,u=n-r;o<n;o+=r)x+=(t[u]-t[o])*(t[o+1]+t[u+1]),u=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=z(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=z(x/r|0,t[x],t[x+1],o);return o&&M(o,o.next)&&(F(o),o=o.next),o}function i(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!M(r,r.next)&&0!==d(r.prev,r,r.next))r=r.next;else{if(F(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function f(t,e,n,r,x,o,u){if(!t)return;!u&&o&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=v(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let u=x,i=0;for(let t=0;t<n&&(i++,u=u.nextZ,u);t++);let f=n;for(;i>0||f>0&&u;)0!==i&&(0===f||!u||x.z<=u.z)?(r=x,x=x.nextZ,i--):(r=u,u=u.nextZ,f--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=u}o.nextZ=null,n*=2}while(e>1)}(x)}(t,r,x,o);let y=t;for(;t.prev!==t.next;){const h=t.prev,p=t.next;if(o?l(t,r,x,o):s(t))e.push(h.i,t.i,p.i),F(t),t=p.next,y=p.next;else if((t=p)===y){u?1===u?f(t=c(i(t),e),e,n,r,x,o,2):2===u&&a(t,e,n,r,x,o):f(i(t),e,n,r,x,o,1);break}}}function s(t){const e=t.prev,n=t,r=t.next;if(d(e,n,r)>=0)return!1;const x=e.x,o=n.x,u=r.x,i=e.y,f=n.y,s=r.y,l=x<o?x<u?x:u:o<u?o:u,c=i<f?i<s?i:s:f<s?f:s,a=x>o?x>u?x:u:o>u?o:u,y=i>f?i>s?i:s:f>s?f:s;let h=r.next;for(;h!==e;){if(h.x>=l&&h.x<=a&&h.y>=c&&h.y<=y&&b(x,i,o,f,u,s,h.x,h.y)&&d(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function l(t,e,n,r){const x=t.prev,o=t,u=t.next;if(d(x,o,u)>=0)return!1;const i=x.x,f=o.x,s=u.x,l=x.y,c=o.y,a=u.y,y=i<f?i<s?i:s:f<s?f:s,h=l<c?l<a?l:a:c<a?c:a,p=i>f?i>s?i:s:f>s?f:s,g=l>c?l>a?l:a:c>a?c:a,Z=v(y,h,e,n,r),M=v(p,g,e,n,r);let w=t.prevZ,m=t.nextZ;for(;w&&w.z>=Z&&m&&m.z<=M;){if(w.x>=y&&w.x<=p&&w.y>=h&&w.y<=g&&w!==x&&w!==u&&b(i,l,f,c,s,a,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,m.x>=y&&m.x<=p&&m.y>=h&&m.y<=g&&m!==x&&m!==u&&b(i,l,f,c,s,a,m.x,m.y)&&d(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;w&&w.z>=Z;){if(w.x>=y&&w.x<=p&&w.y>=h&&w.y<=g&&w!==x&&w!==u&&b(i,l,f,c,s,a,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;m&&m.z<=M;){if(m.x>=y&&m.x<=p&&m.y>=h&&m.y<=g&&m!==x&&m!==u&&b(i,l,f,c,s,a,m.x,m.y)&&d(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function c(t,e){let n=t;do{const r=n.prev,x=n.next.next;!M(r,x)&&w(r,n,n.next,x)&&E(r,x)&&E(x,r)&&(e.push(r.i,n.i,x.i),F(n),F(n.next),n=t=x),n=n.next}while(n!==t);return i(n)}function a(t,e,n,r,x,o){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&Z(u,t)){let s=I(u,t);return u=i(u,u.next),s=i(s,s.next),f(u,e,n,r,x,o,0),void f(s,e,n,r,x,o,0)}t=t.next}u=u.next}while(u!==t)}function y(t,e){return t.x-e.x}function h(t,e){const n=function(t,e){let n=e;const r=t.x,x=t.y;let o,u=-1/0;do{if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>u&&(u=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const i=o,f=o.x,s=o.y;let l=1/0;n=o;do{if(r>=n.x&&n.x>=f&&r!==n.x&&b(x<s?r:u,x,f,s,x<s?u:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);E(n,t)&&(e<l||e===l&&(n.x>o.x||n.x===o.x&&p(o,n)))&&(o=n,l=e)}n=n.next}while(n!==i);return o}(t,e);if(!n)return e;const r=I(n,t);return i(r,r.next),i(n,n.next)}function p(t,e){return d(t.prev,t,e.prev)<0&&d(e.next,t,t.next)<0}function v(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function g(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function b(t,e,n,r,x,o,u,i){return(x-u)*(e-i)>=(t-u)*(o-i)&&(t-u)*(r-i)>=(n-u)*(e-i)&&(n-u)*(o-i)>=(x-u)*(r-i)}function Z(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&w(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(E(t,e)&&E(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(d(t.prev,t,e.prev)||d(t,e.prev,e))||M(t,e)&&d(t.prev,t,t.next)>0&&d(e.prev,e,e.next)>0)}function d(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function M(t,e){return t.x===e.x&&t.y===e.y}function w(t,e,n,r){const x=A(d(t,e,n)),o=A(d(t,e,r)),u=A(d(n,r,t)),i=A(d(n,r,e));return x!==o&&u!==i||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==u||!m(n,t,r))||!(0!==i||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function E(t,e){return d(t.prev,t,t.next)<0?d(t,e,t.next)>=0&&d(t,t.prev,e)>=0:d(t,e,t.prev)<0||d(t,t.next,e)<0}function I(t,e){const n=P(t.i,t.x,t.y),r=P(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function z(t,e,n,r){const x=P(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function F(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function P(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}new Array(6);const B=[],N={vertexPosition:0,indexPosition:0};function R(t,e,n,r,x){t[e+0]=n,t[e+1]=r,t[e+2]=x}function S(t,e,n,r,x,o){const u=3+x,i=t[e+0],f=t[e+1],s=B;s.length=x;for(let n=0;n<s.length;n++)s[n]=t[e+2+n];let l=o?o.vertexPosition:0,c=o?o.indexPosition:0;const a=l/u;return R(n,l,i,f,0),s.length&&n.set(s,l+3),l+=u,R(n,l,i,f,1),s.length&&n.set(s,l+3),l+=u,R(n,l,i,f,2),s.length&&n.set(s,l+3),l+=u,R(n,l,i,f,3),s.length&&n.set(s,l+3),l+=u,r[c++]=a,r[c++]=a+1,r[c++]=a+3,r[c++]=a+1,r[c++]=a+2,r[c++]=a+3,N.vertexPosition=l,N.indexPosition=c,N}function T(t,e,n,x,o,u,i,f,s,l,c){const a=
|
|
3
|
+
const source = "const t=\"GENERATE_POLYGON_BUFFERS\",e=\"GENERATE_POINT_BUFFERS\",n=\"GENERATE_LINE_STRING_BUFFERS\";function r(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function x(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,\"Transformation matrix cannot be inverted\");const x=e[0],o=e[1],u=e[2],i=e[3],f=e[4],s=e[5];return t[0]=i/n,t[1]=-o/n,t[2]=-u/n,t[3]=x/n,t[4]=(u*s-i*f)/n,t[5]=-(x*s-o*f)/n,t}function o(t,e,n=2){const r=e&&e.length,x=r?e[0]*n:t.length;let o=u(t,0,x,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(r&&(o=function(t,e,n,r){const x=[];for(let n=0,o=e.length;n<o;n++){const i=u(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1);i===i.next&&(i.steiner=!0),x.push(g(i))}x.sort(y);for(let t=0;t<x.length;t++)n=h(x[t],n);return n}(t,e,o,n)),t.length>80*n){s=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=n;o<x;o+=n){const n=t[o],x=t[o+1];n<s&&(s=n),x<l&&(l=x),n>e&&(e=n),x>r&&(r=x)}c=Math.max(e-s,r-l),c=0!==c?32767/c:0}return f(o,i,n,s,l,c,0),i}function u(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,u=n-r;o<n;o+=r)x+=(t[u]-t[o])*(t[o+1]+t[u+1]),u=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=z(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=z(x/r|0,t[x],t[x+1],o);return o&&M(o,o.next)&&(F(o),o=o.next),o}function i(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!M(r,r.next)&&0!==d(r.prev,r,r.next))r=r.next;else{if(F(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function f(t,e,n,r,x,o,u){if(!t)return;!u&&o&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=v(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let u=x,i=0;for(let t=0;t<n&&(i++,u=u.nextZ,u);t++);let f=n;for(;i>0||f>0&&u;)0!==i&&(0===f||!u||x.z<=u.z)?(r=x,x=x.nextZ,i--):(r=u,u=u.nextZ,f--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=u}o.nextZ=null,n*=2}while(e>1)}(x)}(t,r,x,o);let y=t;for(;t.prev!==t.next;){const h=t.prev,p=t.next;if(o?l(t,r,x,o):s(t))e.push(h.i,t.i,p.i),F(t),t=p.next,y=p.next;else if((t=p)===y){u?1===u?f(t=c(i(t),e),e,n,r,x,o,2):2===u&&a(t,e,n,r,x,o):f(i(t),e,n,r,x,o,1);break}}}function s(t){const e=t.prev,n=t,r=t.next;if(d(e,n,r)>=0)return!1;const x=e.x,o=n.x,u=r.x,i=e.y,f=n.y,s=r.y,l=x<o?x<u?x:u:o<u?o:u,c=i<f?i<s?i:s:f<s?f:s,a=x>o?x>u?x:u:o>u?o:u,y=i>f?i>s?i:s:f>s?f:s;let h=r.next;for(;h!==e;){if(h.x>=l&&h.x<=a&&h.y>=c&&h.y<=y&&b(x,i,o,f,u,s,h.x,h.y)&&d(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function l(t,e,n,r){const x=t.prev,o=t,u=t.next;if(d(x,o,u)>=0)return!1;const i=x.x,f=o.x,s=u.x,l=x.y,c=o.y,a=u.y,y=i<f?i<s?i:s:f<s?f:s,h=l<c?l<a?l:a:c<a?c:a,p=i>f?i>s?i:s:f>s?f:s,g=l>c?l>a?l:a:c>a?c:a,Z=v(y,h,e,n,r),M=v(p,g,e,n,r);let w=t.prevZ,m=t.nextZ;for(;w&&w.z>=Z&&m&&m.z<=M;){if(w.x>=y&&w.x<=p&&w.y>=h&&w.y<=g&&w!==x&&w!==u&&b(i,l,f,c,s,a,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,m.x>=y&&m.x<=p&&m.y>=h&&m.y<=g&&m!==x&&m!==u&&b(i,l,f,c,s,a,m.x,m.y)&&d(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;w&&w.z>=Z;){if(w.x>=y&&w.x<=p&&w.y>=h&&w.y<=g&&w!==x&&w!==u&&b(i,l,f,c,s,a,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;m&&m.z<=M;){if(m.x>=y&&m.x<=p&&m.y>=h&&m.y<=g&&m!==x&&m!==u&&b(i,l,f,c,s,a,m.x,m.y)&&d(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function c(t,e){let n=t;do{const r=n.prev,x=n.next.next;!M(r,x)&&w(r,n,n.next,x)&&E(r,x)&&E(x,r)&&(e.push(r.i,n.i,x.i),F(n),F(n.next),n=t=x),n=n.next}while(n!==t);return i(n)}function a(t,e,n,r,x,o){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&Z(u,t)){let s=I(u,t);return u=i(u,u.next),s=i(s,s.next),f(u,e,n,r,x,o,0),void f(s,e,n,r,x,o,0)}t=t.next}u=u.next}while(u!==t)}function y(t,e){return t.x-e.x}function h(t,e){const n=function(t,e){let n=e;const r=t.x,x=t.y;let o,u=-1/0;do{if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>u&&(u=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const i=o,f=o.x,s=o.y;let l=1/0;n=o;do{if(r>=n.x&&n.x>=f&&r!==n.x&&b(x<s?r:u,x,f,s,x<s?u:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);E(n,t)&&(e<l||e===l&&(n.x>o.x||n.x===o.x&&p(o,n)))&&(o=n,l=e)}n=n.next}while(n!==i);return o}(t,e);if(!n)return e;const r=I(n,t);return i(r,r.next),i(n,n.next)}function p(t,e){return d(t.prev,t,e.prev)<0&&d(e.next,t,t.next)<0}function v(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function g(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function b(t,e,n,r,x,o,u,i){return(x-u)*(e-i)>=(t-u)*(o-i)&&(t-u)*(r-i)>=(n-u)*(e-i)&&(n-u)*(o-i)>=(x-u)*(r-i)}function Z(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&w(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(E(t,e)&&E(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(d(t.prev,t,e.prev)||d(t,e.prev,e))||M(t,e)&&d(t.prev,t,t.next)>0&&d(e.prev,e,e.next)>0)}function d(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function M(t,e){return t.x===e.x&&t.y===e.y}function w(t,e,n,r){const x=A(d(t,e,n)),o=A(d(t,e,r)),u=A(d(n,r,t)),i=A(d(n,r,e));return x!==o&&u!==i||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==u||!m(n,t,r))||!(0!==i||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function E(t,e){return d(t.prev,t,t.next)<0?d(t,e,t.next)>=0&&d(t,t.prev,e)>=0:d(t,e,t.prev)<0||d(t,t.next,e)<0}function I(t,e){const n=P(t.i,t.x,t.y),r=P(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function z(t,e,n,r){const x=P(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function F(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function P(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}new Array(6);const B=[],N={vertexPosition:0,indexPosition:0};function R(t,e,n,r,x){t[e+0]=n,t[e+1]=r,t[e+2]=x}function S(t,e,n,r,x,o){const u=3+x,i=t[e+0],f=t[e+1],s=B;s.length=x;for(let n=0;n<s.length;n++)s[n]=t[e+2+n];let l=o?o.vertexPosition:0,c=o?o.indexPosition:0;const a=l/u;return R(n,l,i,f,0),s.length&&n.set(s,l+3),l+=u,R(n,l,i,f,1),s.length&&n.set(s,l+3),l+=u,R(n,l,i,f,2),s.length&&n.set(s,l+3),l+=u,R(n,l,i,f,3),s.length&&n.set(s,l+3),l+=u,r[c++]=a,r[c++]=a+1,r[c++]=a+3,r[c++]=a+1,r[c++]=a+2,r[c++]=a+3,N.vertexPosition=l,N.indexPosition=c,N}function T(t,e,n,x,o,u,i,f,s,l,c){const a=10+f.length,y=u.length/a,h=[t[e+0],t[e+1]],p=[t[n],t[n+1]],v=t[e+2],g=t[n+2],b=r(s,[...h]),Z=r(s,[...p]);function d(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],u=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),i=[(n[0]-t[0])/u,(n[1]-t[1])/u],f=0===r||0===u?0:Math.acos((s=i[0]*x[0]+i[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;return i[0]*o[0]+i[1]*o[1]>0?f:2*Math.PI-f}let M=-1,w=-1,m=c;const A=null!==o;if(null!==x){M=d(b,Z,r(s,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((M-Math.PI)/2))}if(A){w=d(Z,b,r(s,[...[t[o],t[o+1]]])),Math.cos(w)<=.985&&(m+=Math.tan((Math.PI-w)/2))}function E(t,e){return 0===e?1e4*t:Math.sign(e)*(1e4*t+Math.abs(e))}return u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(0,c)),u.push(...f),u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(1,c)),u.push(...f),u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(2,c)),u.push(...f),u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(3,c)),u.push(...f),i.push(y,y+1,y+2,y+1,y+3,y+2),{length:l+Math.sqrt((Z[0]-b[0])*(Z[0]-b[0])+(Z[1]-b[1])*(Z[1]-b[1])),angle:m}}function _(t,e,n,r,x){const u=2+x;let i=e;const f=t.slice(i,i+x);i+=x;const s=t[i++];let l=0;const c=new Array(s-1);for(let e=0;e<s;e++)l+=t[i++],e<s-1&&(c[e]=l);const a=t.slice(i,i+2*l),y=o(a,c,2);for(let t=0;t<y.length;t++)r.push(y[t]+n.length/u);for(let t=0;t<a.length;t+=2)n.push(a[t],a[t+1],...f);return i+2*l}const O=self;O.onmessage=r=>{const o=r.data;switch(o.type){case e:{const t=3,e=2,n=o.customAttributesSize,r=e+n,x=new Float32Array(o.renderInstructions),u=x.length/r,i=4*u*(n+t),f=new Uint32Array(6*u),s=new Float32Array(i);let l;for(let t=0;t<x.length;t+=r)l=S(x,t,s,f,n,l);const c=Object.assign({vertexBuffer:s.buffer,indexBuffer:f.buffer,renderInstructions:x.buffer},o);O.postMessage(c,[s.buffer,f.buffer,x.buffer]);break}case n:{const t=[],e=[],n=o.customAttributesSize,r=3,u=new Float32Array(o.renderInstructions);let i=0;const f=[1,0,0,1,0,0];let s,l;for(x(f,o.renderInstructionsTransform);i<u.length;){l=Array.from(u.slice(i,i+n)),i+=n,s=u[i++];const x=i,o=i+(s-1)*r,c=u[x]===u[o]&&u[x+1]===u[o+1];let a=0,y=0;for(let n=0;n<s-1;n++){let h=null;n>0?h=i+(n-1)*r:c&&(h=o-r);let p=null;n<s-2?p=i+(n+2)*r:c&&(p=x+r);const v=T(u,i+n*r,i+(n+1)*r,h,p,t,e,l,f,a,y);a=v.length,y=v.angle}i+=s*r}const c=Uint32Array.from(e),a=Float32Array.from(t),y=Object.assign({vertexBuffer:a.buffer,indexBuffer:c.buffer,renderInstructions:u.buffer},o);O.postMessage(y,[a.buffer,c.buffer,u.buffer]);break}case t:{const t=[],e=[],n=o.customAttributesSize,r=new Float32Array(o.renderInstructions);let x=0;for(;x<r.length;)x=_(r,x,t,e,n);const u=Uint32Array.from(e),i=Float32Array.from(t),f=Object.assign({vertexBuffer:i.buffer,indexBuffer:u.buffer,renderInstructions:r.buffer},o);O.postMessage(f,[i.buffer,u.buffer,r.buffer]);break}}};";
|
|
4
4
|
return new Worker(typeof Blob === 'undefined'
|
|
5
5
|
? 'data:application/javascript;base64,' + Buffer.from(source, 'binary').toString('base64')
|
|
6
6
|
: URL.createObjectURL(new Blob([source], {type: 'application/javascript'})));
|