@deck.gl-community/layers 9.0.0-alpha.1 → 9.0.3
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/index.cjs +605 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -5
- package/dist/path-marker-layer/arrow-2d-geometry.d.ts +5 -0
- package/dist/path-marker-layer/arrow-2d-geometry.d.ts.map +1 -0
- package/dist/path-marker-layer/arrow-2d-geometry.js +58 -0
- package/dist/path-marker-layer/create-path-markers.d.ts +19 -0
- package/dist/path-marker-layer/create-path-markers.d.ts.map +1 -0
- package/dist/path-marker-layer/create-path-markers.js +78 -0
- package/dist/path-marker-layer/path-marker-layer.d.ts +41 -0
- package/dist/path-marker-layer/path-marker-layer.d.ts.map +1 -0
- package/dist/path-marker-layer/path-marker-layer.js +124 -0
- package/dist/path-marker-layer/polyline.d.ts +19 -0
- package/dist/path-marker-layer/polyline.d.ts.map +1 -0
- package/dist/path-marker-layer/polyline.js +40 -0
- package/dist/path-outline-layer/outline.d.ts +9 -0
- package/dist/path-outline-layer/outline.d.ts.map +1 -0
- package/dist/path-outline-layer/outline.js +100 -0
- package/dist/path-outline-layer/path-outline-layer.d.ts +35 -0
- package/dist/path-outline-layer/path-outline-layer.d.ts.map +1 -0
- package/dist/path-outline-layer/path-outline-layer.js +116 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts +44 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts.map +1 -0
- package/dist/tile-source-layer/tile-source-layer.js +109 -0
- package/package.json +27 -13
- package/src/index.ts +7 -4
- package/src/path-marker-layer/arrow-2d-geometry.ts +65 -0
- package/src/path-marker-layer/create-path-markers.ts +122 -0
- package/src/path-marker-layer/path-marker-layer.ts +183 -0
- package/src/path-marker-layer/polyline.ts +44 -0
- package/src/path-outline-layer/outline.ts +107 -0
- package/src/path-outline-layer/path-outline-layer.ts +159 -0
- package/src/{tile-source-layer.ts → tile-source-layer/tile-source-layer.ts} +30 -22
- package/dist/data-driven-tile-3d-layer/data-driven-tile-3d-layer.js +0 -193
- package/dist/data-driven-tile-3d-layer/data-driven-tile-3d-layer.js.map +0 -1
- package/dist/data-driven-tile-3d-layer/utils/colorize-tile.js +0 -31
- package/dist/data-driven-tile-3d-layer/utils/colorize-tile.js.map +0 -1
- package/dist/data-driven-tile-3d-layer/utils/filter-tile.js +0 -146
- package/dist/data-driven-tile-3d-layer/utils/filter-tile.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tile-source-layer.js +0 -112
- package/dist/tile-source-layer.js.map +0 -1
- package/src/data-driven-tile-3d-layer/data-driven-tile-3d-layer.ts +0 -261
- package/src/data-driven-tile-3d-layer/utils/colorize-tile.ts +0 -53
- package/src/data-driven-tile-3d-layer/utils/filter-tile.ts +0 -179
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { TileSourceLayerProps } from "./tile-source-layer/tile-source-layer.js";
|
|
2
|
+
export { TileSourceLayer } from "./tile-source-layer/tile-source-layer.js";
|
|
3
|
+
export type { PathOutlineLayerProps } from "./path-outline-layer/path-outline-layer.js";
|
|
4
|
+
export { PathOutlineLayer } from "./path-outline-layer/path-outline-layer.js";
|
|
5
|
+
export type { PathMarkerLayerProps } from "./path-marker-layer/path-marker-layer.js";
|
|
6
|
+
export { PathMarkerLayer } from "./path-marker-layer/path-marker-layer.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,oBAAoB,EAAC,iDAA8C;AAChF,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,YAAY,EAAC,qBAAqB,EAAC,mDAAgD;AACnF,OAAO,EAAC,gBAAgB,EAAC,mDAAgD;AAEzE,YAAY,EAAC,oBAAoB,EAAC,iDAA8C;AAChF,OAAO,EAAC,eAAe,EAAC,iDAA8C"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export { TileSourceLayer } from "./tile-source-layer/tile-source-layer.js";
|
|
5
|
+
export { PathOutlineLayer } from "./path-outline-layer/path-outline-layer.js";
|
|
6
|
+
export { PathMarkerLayer } from "./path-marker-layer/path-marker-layer.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-2d-geometry.d.ts","sourceRoot":"","sources":["../../src/path-marker-layer/arrow-2d-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAEzC,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,IAAI,KAAK;CAQtB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Geometry } from '@luma.gl/engine';
|
|
5
|
+
export class Arrow2DGeometry extends Geometry {
|
|
6
|
+
constructor(opts = {}) {
|
|
7
|
+
super(Object.assign({}, opts, {
|
|
8
|
+
attributes: getArrowAttributes(opts),
|
|
9
|
+
topology: 'triangle-list'
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function getArrowAttributes({ length = 1, headSize = 0.2, tailWidth = 0.05, tailStart = 0.05 }) {
|
|
14
|
+
const texCoords = [
|
|
15
|
+
// HEAD
|
|
16
|
+
0.5,
|
|
17
|
+
1.0,
|
|
18
|
+
0,
|
|
19
|
+
0.5 - headSize / 2,
|
|
20
|
+
1.0 - headSize,
|
|
21
|
+
0,
|
|
22
|
+
0.5 + headSize / 2,
|
|
23
|
+
1.0 - headSize,
|
|
24
|
+
0,
|
|
25
|
+
0.5 - tailWidth / 2,
|
|
26
|
+
tailStart,
|
|
27
|
+
0,
|
|
28
|
+
0.5 + tailWidth / 2,
|
|
29
|
+
1.0 - headSize,
|
|
30
|
+
0,
|
|
31
|
+
0.5 + tailWidth / 2,
|
|
32
|
+
tailStart,
|
|
33
|
+
0,
|
|
34
|
+
0.5 - tailWidth / 2,
|
|
35
|
+
tailStart,
|
|
36
|
+
0,
|
|
37
|
+
0.5 - tailWidth / 2,
|
|
38
|
+
1.0 - headSize,
|
|
39
|
+
0,
|
|
40
|
+
0.5 + tailWidth / 2,
|
|
41
|
+
1.0 - headSize,
|
|
42
|
+
0
|
|
43
|
+
];
|
|
44
|
+
const normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1];
|
|
45
|
+
// Center and scale
|
|
46
|
+
const positions = new Array(texCoords.length);
|
|
47
|
+
for (let i = 0; i < texCoords.length / 3; i++) {
|
|
48
|
+
const i3 = i * 3;
|
|
49
|
+
positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length;
|
|
50
|
+
positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length;
|
|
51
|
+
positions[i3 + 2] = 0;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
positions: { size: 3, value: new Float32Array(positions) },
|
|
55
|
+
normals: { size: 3, value: new Float32Array(normals) },
|
|
56
|
+
texCoords: { size: 2, value: new Float32Array(texCoords) }
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** GeoJSON style position coordinate vector */
|
|
2
|
+
export type Position = [number, number] | [number, number, number];
|
|
3
|
+
/** [red, green, blue, alpha] in premultiplied alpha format */
|
|
4
|
+
export type Color = [number, number, number, number];
|
|
5
|
+
export interface PathMarker {
|
|
6
|
+
position: Position;
|
|
7
|
+
angle: number;
|
|
8
|
+
color: Color;
|
|
9
|
+
object: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare function createPathMarkers({ data, getPath, getDirection, getColor, getMarkerPercentages, projectFlat }: {
|
|
12
|
+
data: any;
|
|
13
|
+
getPath?: (x: any, context: any) => any;
|
|
14
|
+
getDirection?: (x: any) => any;
|
|
15
|
+
getColor?: (x: any) => number[];
|
|
16
|
+
getMarkerPercentages?: (x: any, info: any) => number[];
|
|
17
|
+
projectFlat: any;
|
|
18
|
+
}): PathMarker[];
|
|
19
|
+
//# sourceMappingURL=create-path-markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-path-markers.d.ts","sourceRoot":"","sources":["../../src/path-marker-layer/create-path-markers.ts"],"names":[],"mappings":"AAMA,+CAA+C;AAC/C,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnE,8DAA8D;AAC9D,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAcD,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,OAAgC,EAChC,YAAiC,EACjC,QAA+B,EAC/B,oBAAyC,EACzC,WAAW,EACZ;;;;;;;CAAA,GAAG,UAAU,EAAE,CA8Cf"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Vector2 } from '@math.gl/core';
|
|
5
|
+
function getLineLength(vPoints) {
|
|
6
|
+
// calculate total length
|
|
7
|
+
let lineLength = 0;
|
|
8
|
+
for (let i = 0; i < vPoints.length - 1; i++) {
|
|
9
|
+
lineLength += vPoints[i].distance(vPoints[i + 1]);
|
|
10
|
+
}
|
|
11
|
+
return lineLength;
|
|
12
|
+
}
|
|
13
|
+
const DEFAULT_COLOR = [0, 0, 0, 255];
|
|
14
|
+
const DEFAULT_DIRECTION = { forward: true, backward: false };
|
|
15
|
+
export function createPathMarkers({ data, getPath = (x, context) => x.path, getDirection = (x) => x.direction, getColor = (x) => DEFAULT_COLOR, getMarkerPercentages = (x, info) => [0.5], projectFlat }) {
|
|
16
|
+
const markers = [];
|
|
17
|
+
for (const object of data) {
|
|
18
|
+
const path = getPath(object, null);
|
|
19
|
+
const direction = getDirection(object) || DEFAULT_DIRECTION;
|
|
20
|
+
const color = getColor(object);
|
|
21
|
+
const vPoints = path.map((p) => new Vector2(p));
|
|
22
|
+
const vPointsReverse = vPoints.slice(0).reverse();
|
|
23
|
+
// calculate total length
|
|
24
|
+
const lineLength = getLineLength(vPoints);
|
|
25
|
+
// Ask for where to put markers
|
|
26
|
+
const percentages = getMarkerPercentages(object, { lineLength });
|
|
27
|
+
// Create the markers
|
|
28
|
+
for (const percentage of percentages) {
|
|
29
|
+
if (direction.forward) {
|
|
30
|
+
const marker = createMarkerAlongPath({
|
|
31
|
+
path: vPoints,
|
|
32
|
+
percentage,
|
|
33
|
+
lineLength,
|
|
34
|
+
color,
|
|
35
|
+
object,
|
|
36
|
+
projectFlat
|
|
37
|
+
});
|
|
38
|
+
markers.push(marker);
|
|
39
|
+
}
|
|
40
|
+
if (direction.backward) {
|
|
41
|
+
const marker = createMarkerAlongPath({
|
|
42
|
+
path: vPointsReverse,
|
|
43
|
+
percentage,
|
|
44
|
+
lineLength,
|
|
45
|
+
color,
|
|
46
|
+
object,
|
|
47
|
+
projectFlat
|
|
48
|
+
});
|
|
49
|
+
markers.push(marker);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return markers;
|
|
54
|
+
}
|
|
55
|
+
function createMarkerAlongPath({ path, percentage, lineLength, color, object, projectFlat }) {
|
|
56
|
+
const distanceAlong = lineLength * percentage;
|
|
57
|
+
let currentDistance = 0;
|
|
58
|
+
let previousDistance = 0;
|
|
59
|
+
let i = 0;
|
|
60
|
+
for (i = 0; i < path.length - 1; i++) {
|
|
61
|
+
currentDistance += path[i].distance(path[i + 1]);
|
|
62
|
+
if (currentDistance > distanceAlong) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
previousDistance = currentDistance;
|
|
66
|
+
}
|
|
67
|
+
// If reached the end of the loop without exiting early,
|
|
68
|
+
// undo the final increment to avoid a null-pointer exception
|
|
69
|
+
if (i === path.length - 1) {
|
|
70
|
+
i -= 1;
|
|
71
|
+
}
|
|
72
|
+
const vDirection = path[i + 1].clone().subtract(path[i]).normalize();
|
|
73
|
+
const along = distanceAlong - previousDistance;
|
|
74
|
+
const vCenter = vDirection.clone().multiply(new Vector2(along, along)).add(path[i]);
|
|
75
|
+
const vDirection2 = new Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i]));
|
|
76
|
+
const angle = (vDirection2.verticalAngle() * 180) / Math.PI;
|
|
77
|
+
return { position: [vCenter.x, vCenter.y, 0], angle, color, object };
|
|
78
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CompositeLayer, DefaultProps } from '@deck.gl/core';
|
|
2
|
+
import { PathOutlineLayerProps } from "../path-outline-layer/path-outline-layer.js";
|
|
3
|
+
import { Arrow2DGeometry } from "./arrow-2d-geometry.js";
|
|
4
|
+
import { Vector3 } from '@math.gl/core';
|
|
5
|
+
export type PathMarkerLayerProps<DataT> = PathOutlineLayerProps<DataT> & {
|
|
6
|
+
getDirection?: (x: any) => any;
|
|
7
|
+
getMarkerColor?: (x: any) => number[];
|
|
8
|
+
getMarkerPercentages?: (x: any, info: any) => number[];
|
|
9
|
+
highlightPoint?: any;
|
|
10
|
+
highlightIndex?: number;
|
|
11
|
+
MarkerLayer?: any;
|
|
12
|
+
markerLayerProps?: any;
|
|
13
|
+
sizeScale?: number;
|
|
14
|
+
fp64?: boolean;
|
|
15
|
+
nebulaLayer?: any;
|
|
16
|
+
};
|
|
17
|
+
export declare class PathMarkerLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends CompositeLayer<ExtraPropsT & Required<PathMarkerLayerProps<DataT>>> {
|
|
18
|
+
static layerName: string;
|
|
19
|
+
static defaultProps: DefaultProps<PathMarkerLayerProps<any>>;
|
|
20
|
+
state: {
|
|
21
|
+
closestPoint: Vector3 | null;
|
|
22
|
+
closestPoints?: {
|
|
23
|
+
position: Vector3;
|
|
24
|
+
}[];
|
|
25
|
+
markers: any[];
|
|
26
|
+
mesh: Arrow2DGeometry;
|
|
27
|
+
};
|
|
28
|
+
initializeState(): void;
|
|
29
|
+
projectFlat(xyz: any, viewport: any, coordinateSystem: any, coordinateOrigin: any): any;
|
|
30
|
+
updateState({ props, oldProps, changeFlags }: {
|
|
31
|
+
props: any;
|
|
32
|
+
oldProps: any;
|
|
33
|
+
changeFlags: any;
|
|
34
|
+
}): void;
|
|
35
|
+
_recalculateClosestPoint(): void;
|
|
36
|
+
getPickingInfo({ info }: {
|
|
37
|
+
info: any;
|
|
38
|
+
}): any;
|
|
39
|
+
renderLayers(): any[];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=path-marker-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-marker-layer.d.ts","sourceRoot":"","sources":["../../src/path-marker-layer/path-marker-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAqB,YAAY,EAAC,MAAM,eAAe,CAAC;AAG9E,OAAO,EAAmB,qBAAqB,EAAC,oDAAiD;AACjG,OAAO,EAAC,eAAe,EAAC,+BAA4B;AAIpD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAStC,MAAM,MAAM,oBAAoB,CAAC,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAAG;IACvE,YAAY,CAAC,EAAE,CAAC,CAAC,KAAA,KAAK,GAAG,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,CAAC,KAAA,KAAK,MAAM,EAAE,CAAC;IACjC,oBAAoB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,MAAM,EAAE,CAAC;IACvD,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,gBAAgB,CAAC,EAAE,GAAG,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB,CAAC;AA4BF,qBAAa,eAAe,CAC1B,KAAK,GAAG,GAAG,EACX,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACrC,SAAQ,cAAc,CAAC,WAAW,GAAG,QAAQ,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,MAAM,CAAC,SAAS,SAAqB;IACrC,MAAM,CAAC,YAAY,0CAAgB;IAEnC,KAAK,EAAE;QACL,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;QAC7B,aAAa,CAAC,EAAE;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAC,EAAE,CAAC;QACtC,OAAO,EAAE,GAAG,EAAE,CAAC;QACf,IAAI,EAAE,eAAe,CAAC;KACvB,CAAc;IAEf,eAAe;IASf,WAAW,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA,EAAE,gBAAgB,KAAA,EAAE,gBAAgB,KAAA;IAc7D,WAAW,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAC;;;;KAAA;IA+B1C,wBAAwB;IAYxB,cAAc,CAAC,EAAC,IAAI,EAAC;;KAAA;IAOrB,YAAY;CAmCb"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { CompositeLayer, COORDINATE_SYSTEM } from '@deck.gl/core';
|
|
5
|
+
import { ScatterplotLayer } from '@deck.gl/layers';
|
|
6
|
+
import { SimpleMeshLayer } from '@deck.gl/mesh-layers';
|
|
7
|
+
import { PathOutlineLayer } from "../path-outline-layer/path-outline-layer.js";
|
|
8
|
+
import { Arrow2DGeometry } from "./arrow-2d-geometry.js";
|
|
9
|
+
import { createPathMarkers } from "./create-path-markers.js";
|
|
10
|
+
import { getClosestPointOnPolyline } from "./polyline.js";
|
|
11
|
+
const DISTANCE_FOR_MULTI_ARROWS = 0.1;
|
|
12
|
+
const ARROW_HEAD_SIZE = 0.2;
|
|
13
|
+
const ARROW_TAIL_WIDTH = 0.05;
|
|
14
|
+
// const ARROW_CENTER_ADJUST = -0.8;
|
|
15
|
+
const DEFAULT_MARKER_LAYER = SimpleMeshLayer;
|
|
16
|
+
const DEFAULT_MARKER_LAYER_PROPS = {
|
|
17
|
+
mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH })
|
|
18
|
+
};
|
|
19
|
+
const defaultProps = Object.assign({}, PathOutlineLayer.defaultProps, {
|
|
20
|
+
MarkerLayer: DEFAULT_MARKER_LAYER,
|
|
21
|
+
markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,
|
|
22
|
+
sizeScale: 100,
|
|
23
|
+
fp64: false,
|
|
24
|
+
highlightIndex: -1,
|
|
25
|
+
highlightPoint: null,
|
|
26
|
+
getPath: (x) => x.path,
|
|
27
|
+
getColor: (x) => x.color,
|
|
28
|
+
getMarkerColor: (x) => [0, 0, 0, 255],
|
|
29
|
+
getDirection: (x) => x.direction,
|
|
30
|
+
getMarkerPercentages: (object, { lineLength }) => lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]
|
|
31
|
+
});
|
|
32
|
+
export class PathMarkerLayer extends CompositeLayer {
|
|
33
|
+
static layerName = 'PathMarkerLayer';
|
|
34
|
+
static defaultProps = defaultProps;
|
|
35
|
+
state = undefined;
|
|
36
|
+
initializeState() {
|
|
37
|
+
this.state = {
|
|
38
|
+
markers: [],
|
|
39
|
+
mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH }),
|
|
40
|
+
closestPoint: null,
|
|
41
|
+
closestPoints: []
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {
|
|
45
|
+
if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
46
|
+
const [dx, dy] = viewport.metersToLngLatDelta(xyz);
|
|
47
|
+
const [x, y] = coordinateOrigin;
|
|
48
|
+
return viewport.projectFlat([x + dx, dy + y]);
|
|
49
|
+
}
|
|
50
|
+
else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) {
|
|
51
|
+
const [dx, dy] = xyz;
|
|
52
|
+
const [x, y] = coordinateOrigin;
|
|
53
|
+
return viewport.projectFlat([x + dx, dy + y]);
|
|
54
|
+
}
|
|
55
|
+
return viewport.projectFlat(xyz);
|
|
56
|
+
}
|
|
57
|
+
updateState({ props, oldProps, changeFlags }) {
|
|
58
|
+
if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {
|
|
59
|
+
const { data, getPath, getDirection, getMarkerColor, getMarkerPercentages, coordinateSystem, coordinateOrigin } = this.props;
|
|
60
|
+
const { viewport } = this.context;
|
|
61
|
+
const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);
|
|
62
|
+
this.state.markers = createPathMarkers({
|
|
63
|
+
data,
|
|
64
|
+
getPath,
|
|
65
|
+
getDirection,
|
|
66
|
+
getColor: getMarkerColor,
|
|
67
|
+
getMarkerPercentages,
|
|
68
|
+
projectFlat
|
|
69
|
+
});
|
|
70
|
+
this._recalculateClosestPoint();
|
|
71
|
+
}
|
|
72
|
+
if (changeFlags.propsChanged) {
|
|
73
|
+
if (props.point !== oldProps.point) {
|
|
74
|
+
this._recalculateClosestPoint();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_recalculateClosestPoint() {
|
|
79
|
+
const { highlightPoint, highlightIndex } = this.props;
|
|
80
|
+
if (highlightPoint && highlightIndex >= 0) {
|
|
81
|
+
const object = this.props.data[highlightIndex];
|
|
82
|
+
const points = this.props.getPath(object, null);
|
|
83
|
+
const { point } = getClosestPointOnPolyline({ points, p: highlightPoint });
|
|
84
|
+
this.state.closestPoints = [{ position: point }];
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.state.closestPoints = [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
getPickingInfo({ info }) {
|
|
91
|
+
return Object.assign(info, {
|
|
92
|
+
// override object with picked feature
|
|
93
|
+
object: (info.object && info.object.path) || info.object
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
renderLayers() {
|
|
97
|
+
return [
|
|
98
|
+
new PathOutlineLayer(this.props, this.getSubLayerProps({
|
|
99
|
+
id: 'paths',
|
|
100
|
+
// Note: data has to be passed explicitly like this to avoid being empty
|
|
101
|
+
data: this.props.data
|
|
102
|
+
})),
|
|
103
|
+
new this.props.MarkerLayer(this.getSubLayerProps(Object.assign({}, this.props.markerLayerProps, {
|
|
104
|
+
id: 'markers',
|
|
105
|
+
data: this.state.markers,
|
|
106
|
+
getOrientation: (x) => [0, -x.angle, 0],
|
|
107
|
+
getColor: (x) => x.color,
|
|
108
|
+
sizeScale: this.props.sizeScale,
|
|
109
|
+
fp64: this.props.fp64,
|
|
110
|
+
pickable: false,
|
|
111
|
+
parameters: {
|
|
112
|
+
blend: false,
|
|
113
|
+
depthTest: false
|
|
114
|
+
}
|
|
115
|
+
}))),
|
|
116
|
+
this.state.closestPoints &&
|
|
117
|
+
new ScatterplotLayer({
|
|
118
|
+
id: `${this.props.id}-highlight`,
|
|
119
|
+
data: this.state.closestPoints,
|
|
120
|
+
fp64: this.props.fp64
|
|
121
|
+
})
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Vector3 } from '@math.gl/core';
|
|
2
|
+
export declare function getClosestPointOnLine({ p, p1, p2, clampToLine }: {
|
|
3
|
+
p: any;
|
|
4
|
+
p1: any;
|
|
5
|
+
p2: any;
|
|
6
|
+
clampToLine?: boolean;
|
|
7
|
+
}): Vector3;
|
|
8
|
+
export declare function getClosestPointOnPolyline({ p, points }: {
|
|
9
|
+
p: any;
|
|
10
|
+
points: any;
|
|
11
|
+
}): {
|
|
12
|
+
point: Vector3;
|
|
13
|
+
index: number;
|
|
14
|
+
p1: any;
|
|
15
|
+
p2: any;
|
|
16
|
+
distanceSquared: number;
|
|
17
|
+
distance: number;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=polyline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyline.d.ts","sourceRoot":"","sources":["../../src/path-marker-layer/polyline.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAQ,MAAM,eAAe,CAAC;AAG7C,wBAAgB,qBAAqB,CAAC,EAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,WAAkB,EAAC;;;;;CAAA,WASpE;AAGD,wBAAgB,yBAAyB,CAAC,EAAC,CAAC,EAAE,MAAM,EAAC;;;CAAA;;;;;;;EAwBpD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Vector3, clamp } from '@math.gl/core';
|
|
5
|
+
// Return the closest point on a line segment
|
|
6
|
+
export function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
|
|
7
|
+
const lineVector = new Vector3(p2).subtract(p1);
|
|
8
|
+
const pointVector = new Vector3(p).subtract(p1);
|
|
9
|
+
let dotProduct = lineVector.dot(pointVector);
|
|
10
|
+
if (clampToLine) {
|
|
11
|
+
dotProduct = clamp(dotProduct, 0, 1);
|
|
12
|
+
}
|
|
13
|
+
return lineVector.lerp(p1, p2, dotProduct);
|
|
14
|
+
}
|
|
15
|
+
// Return the closest point on a line segment
|
|
16
|
+
export function getClosestPointOnPolyline({ p, points }) {
|
|
17
|
+
p = new Vector3(p);
|
|
18
|
+
let pClosest = null;
|
|
19
|
+
let distanceSquared = Infinity;
|
|
20
|
+
let index = -1;
|
|
21
|
+
for (let i = 0; i < points.length - 1; ++i) {
|
|
22
|
+
const p1 = points[i];
|
|
23
|
+
const p2 = points[i + 1];
|
|
24
|
+
const pClosestOnLine = getClosestPointOnLine({ p, p1, p2 });
|
|
25
|
+
const distanceToLineSquared = p.distanceSquared(pClosestOnLine);
|
|
26
|
+
if (distanceToLineSquared < distanceSquared) {
|
|
27
|
+
distanceSquared = distanceToLineSquared;
|
|
28
|
+
pClosest = pClosestOnLine;
|
|
29
|
+
index = i;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
point: pClosest,
|
|
34
|
+
index,
|
|
35
|
+
p1: points[index],
|
|
36
|
+
p2: points[index + 1],
|
|
37
|
+
distanceSquared,
|
|
38
|
+
distance: Math.sqrt(distanceSquared)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare function getUniforms({ outlineEnabled, outlineRenderShadowmap, outlineShadowmap }?: Record<string, any>): Record<string, any>;
|
|
2
|
+
export declare const outline: {
|
|
3
|
+
readonly name: "outline";
|
|
4
|
+
readonly vs: "#version 300 es\nin float instanceZLevel;\nout float outline_vzLevel;\nout vec4 outline_vPosition;\n\n// Set the z level for the outline shadowmap rendering\nvoid outline_setZLevel(float zLevel) {\n outline_vzLevel = zLevel;\n}\n\n// Store an adjusted position for texture2DProj\nvoid outline_setUV(vec4 position) {\n // mat4(\n // 0.5, 0.0, 0.0, 0.0,\n // 0.0, 0.5, 0.0, 0.0,\n // 0.0, 0.0, 0.5, 0.0,\n // 0.5, 0.5, 0.5, 1.0\n // ) * position;\n outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);\n}\n";
|
|
5
|
+
readonly fs: "uniform bool outline_uEnabled;\nuniform bool outline_uRenderOutlines;\nuniform sampler2D outline_uShadowmap;\n\nin float outline_vzLevel;\n// in vec2 outline_vUV;\nin vec4 outline_vPosition;\n\nout vec4 fragColor;\n\nconst float OUTLINE_Z_LEVEL_ERROR = 0.01;\n\n// Return a darker color in shadowmap\nvec4 outline_filterShadowColor(vec4 color) {\n return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);\n}\n\n// Return a darker color if in shadowmap\nvec4 outline_filterDarkenColor(vec4 color) {\n if (outline_uEnabled) {\n float maxZLevel;\n if (outline_vPosition.q > 0.0) {\n maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;\n } else {\n discard;\n }\n if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {\n vec4(color.rgb * 0.5, color.a);\n } else {\n discard;\n }\n }\n return color;\n}\n\n// if enabled and rendering outlines - Render depth to shadowmap\n// if enabled and rendering colors - Return a darker color if in shadowmap\n// if disabled, just return color\nvec4 outline_filterColor(vec4 color) {\n if (outline_uEnabled) {\n return outline_uRenderOutlines ?\n outline_filterShadowColor(color) :\n outline_filterDarkenColor(color);\n }\n return color;\n}\n";
|
|
6
|
+
readonly getUniforms: typeof getUniforms;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=outline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/path-outline-layer/outline.ts"],"names":[],"mappings":"AAaA,iBAAS,WAAW,CAAC,EAAC,cAAc,EAAE,sBAAsB,EAAE,gBAAgB,EAAC,sBAAgB,uBAc9F;AA0ED,eAAO,MAAM,OAAO;;;;;CAKa,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/* eslint-disable camelcase */
|
|
5
|
+
const INITIAL_STATE = {
|
|
6
|
+
outlineEnabled: false,
|
|
7
|
+
outlineRenderShadowmap: false,
|
|
8
|
+
outlineShadowmap: null
|
|
9
|
+
};
|
|
10
|
+
function getUniforms({ outlineEnabled, outlineRenderShadowmap, outlineShadowmap } = INITIAL_STATE) {
|
|
11
|
+
const uniforms = {};
|
|
12
|
+
if (outlineEnabled !== undefined) {
|
|
13
|
+
// ? 1.0 : 0.0;
|
|
14
|
+
uniforms.outline_uEnabled = outlineEnabled;
|
|
15
|
+
}
|
|
16
|
+
if (outlineRenderShadowmap !== undefined) {
|
|
17
|
+
// ? 1.0 : 0.0;
|
|
18
|
+
uniforms.outline_uRenderOutlines = outlineRenderShadowmap;
|
|
19
|
+
}
|
|
20
|
+
if (outlineShadowmap !== undefined) {
|
|
21
|
+
uniforms.outline_uShadowmap = outlineShadowmap;
|
|
22
|
+
}
|
|
23
|
+
return uniforms;
|
|
24
|
+
}
|
|
25
|
+
const vs = `\
|
|
26
|
+
#version 300 es
|
|
27
|
+
in float instanceZLevel;
|
|
28
|
+
out float outline_vzLevel;
|
|
29
|
+
out vec4 outline_vPosition;
|
|
30
|
+
|
|
31
|
+
// Set the z level for the outline shadowmap rendering
|
|
32
|
+
void outline_setZLevel(float zLevel) {
|
|
33
|
+
outline_vzLevel = zLevel;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Store an adjusted position for texture2DProj
|
|
37
|
+
void outline_setUV(vec4 position) {
|
|
38
|
+
// mat4(
|
|
39
|
+
// 0.5, 0.0, 0.0, 0.0,
|
|
40
|
+
// 0.0, 0.5, 0.0, 0.0,
|
|
41
|
+
// 0.0, 0.0, 0.5, 0.0,
|
|
42
|
+
// 0.5, 0.5, 0.5, 1.0
|
|
43
|
+
// ) * position;
|
|
44
|
+
outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
const fs = `\
|
|
48
|
+
uniform bool outline_uEnabled;
|
|
49
|
+
uniform bool outline_uRenderOutlines;
|
|
50
|
+
uniform sampler2D outline_uShadowmap;
|
|
51
|
+
|
|
52
|
+
in float outline_vzLevel;
|
|
53
|
+
// in vec2 outline_vUV;
|
|
54
|
+
in vec4 outline_vPosition;
|
|
55
|
+
|
|
56
|
+
out vec4 fragColor;
|
|
57
|
+
|
|
58
|
+
const float OUTLINE_Z_LEVEL_ERROR = 0.01;
|
|
59
|
+
|
|
60
|
+
// Return a darker color in shadowmap
|
|
61
|
+
vec4 outline_filterShadowColor(vec4 color) {
|
|
62
|
+
return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Return a darker color if in shadowmap
|
|
66
|
+
vec4 outline_filterDarkenColor(vec4 color) {
|
|
67
|
+
if (outline_uEnabled) {
|
|
68
|
+
float maxZLevel;
|
|
69
|
+
if (outline_vPosition.q > 0.0) {
|
|
70
|
+
maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;
|
|
71
|
+
} else {
|
|
72
|
+
discard;
|
|
73
|
+
}
|
|
74
|
+
if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {
|
|
75
|
+
vec4(color.rgb * 0.5, color.a);
|
|
76
|
+
} else {
|
|
77
|
+
discard;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return color;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// if enabled and rendering outlines - Render depth to shadowmap
|
|
84
|
+
// if enabled and rendering colors - Return a darker color if in shadowmap
|
|
85
|
+
// if disabled, just return color
|
|
86
|
+
vec4 outline_filterColor(vec4 color) {
|
|
87
|
+
if (outline_uEnabled) {
|
|
88
|
+
return outline_uRenderOutlines ?
|
|
89
|
+
outline_filterShadowColor(color) :
|
|
90
|
+
outline_filterDarkenColor(color);
|
|
91
|
+
}
|
|
92
|
+
return color;
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
export const outline = {
|
|
96
|
+
name: 'outline',
|
|
97
|
+
vs,
|
|
98
|
+
fs,
|
|
99
|
+
getUniforms
|
|
100
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PathLayer, PathLayerProps } from '@deck.gl/layers';
|
|
2
|
+
import type { DefaultProps, LayerContext } from '@deck.gl/core';
|
|
3
|
+
import { Framebuffer, Texture } from '@luma.gl/core';
|
|
4
|
+
/**
|
|
5
|
+
* Unit literal to shader unit number conversion.
|
|
6
|
+
*/
|
|
7
|
+
export declare const UNIT: {
|
|
8
|
+
common: number;
|
|
9
|
+
meters: number;
|
|
10
|
+
pixels: number;
|
|
11
|
+
};
|
|
12
|
+
export type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {
|
|
13
|
+
dashJustified?: boolean;
|
|
14
|
+
getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);
|
|
15
|
+
getZLevel?: (d: DataT, index: number) => number;
|
|
16
|
+
};
|
|
17
|
+
export declare class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends PathLayer<DataT, ExtraPropsT & Required<PathOutlineLayerProps<DataT>>> {
|
|
18
|
+
static layerName: string;
|
|
19
|
+
static defaultProps: DefaultProps<PathOutlineLayerProps<any>>;
|
|
20
|
+
state: {
|
|
21
|
+
model?: any;
|
|
22
|
+
pathTesselator: any;
|
|
23
|
+
outlineFramebuffer: Framebuffer;
|
|
24
|
+
dummyTexture: Texture;
|
|
25
|
+
};
|
|
26
|
+
getShaders(): any;
|
|
27
|
+
initializeState(context: LayerContext): void;
|
|
28
|
+
draw({ moduleParameters, parameters, uniforms, context }: {
|
|
29
|
+
moduleParameters?: {};
|
|
30
|
+
parameters: any;
|
|
31
|
+
uniforms: any;
|
|
32
|
+
context: any;
|
|
33
|
+
}): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=path-outline-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-outline-layer.d.ts","sourceRoot":"","sources":["../../src/path-outline-layer/path-outline-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGnD;;GAEG;AACH,eAAO,MAAM,IAAI;;;;CAIhB,CAAC;AAiBF,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG;IACjE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1E,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACjD,CAAC;AAMF,qBAAa,gBAAgB,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAE,SAAQ,SAAS,CACjG,KAAK,EACL,WAAW,GAAG,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CACrD;IACC,MAAM,CAAC,SAAS,SAAsB;IACtC,MAAM,CAAC,YAAY,2CAAgB;IAEnC,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,cAAc,EAAE,GAAG,CAAC;QACpB,kBAAkB,EAAE,WAAW,CAAC;QAChC,YAAY,EAAE,OAAO,CAAC;KACvB,CAAc;IAGf,UAAU;IAUV,eAAe,CAAC,OAAO,EAAE,YAAY;IAsBrC,IAAI,CAAC,EAAC,gBAAqB,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAC;;;;;KAAA;CAmE5D"}
|