@powsybl/network-map-layers 2.0.0 → 3.0.0
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.d.cts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/powsybl-network-map-layers.cjs +176 -163
- package/dist/powsybl-network-map-layers.js +170 -157
- package/package.json +7 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { GL } from "@luma.gl/constants";
|
|
2
|
+
import { Model, Geometry } from "@luma.gl/engine";
|
|
1
3
|
import { Layer, project32, picking, CompositeLayer } from "@deck.gl/core";
|
|
2
|
-
import GL from "@luma.gl/constants";
|
|
3
|
-
import { hasFeatures, FEATURES, isWebGL2, Texture2D, Model, Geometry } from "@luma.gl/core";
|
|
4
4
|
import { PathStyleExtension } from "@deck.gl/extensions";
|
|
5
5
|
import { LineLayer as LineLayer$1, PathLayer, TextLayer, IconLayer, ScatterplotLayer } from "@deck.gl/layers";
|
|
6
6
|
var EQUIPMENT_TYPES = /* @__PURE__ */ ((EQUIPMENT_TYPES2) => {
|
|
@@ -23,6 +23,8 @@ var EQUIPMENT_TYPES = /* @__PURE__ */ ((EQUIPMENT_TYPES2) => {
|
|
|
23
23
|
EQUIPMENT_TYPES2["SWITCH"] = "SWITCH";
|
|
24
24
|
return EQUIPMENT_TYPES2;
|
|
25
25
|
})(EQUIPMENT_TYPES || {});
|
|
26
|
+
const isMapSubstation = (object) => "voltageLevels" in object;
|
|
27
|
+
const isMapLine = (object) => "id" in object && "voltageLevelId1" in object && "voltageLevelId2" in object;
|
|
26
28
|
const factors = {
|
|
27
29
|
kilometers: 1,
|
|
28
30
|
miles: 1e3 / 1609.344,
|
|
@@ -1665,82 +1667,71 @@ wktToPolygon$1.default = _default;
|
|
|
1665
1667
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
1666
1668
|
}
|
|
1667
1669
|
})(es);
|
|
1668
|
-
const vs =
|
|
1670
|
+
const vs = `#version 300 es
|
|
1671
|
+
#define SHADER_NAME "arrow-layer-vertex-shader"
|
|
1672
|
+
|
|
1673
|
+
/**
|
|
1669
1674
|
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
1670
1675
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
1671
1676
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
1672
1677
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
1673
1678
|
*/
|
|
1674
1679
|
|
|
1675
|
-
#define SHADER_NAME "arrow-layer-vertex-shader"
|
|
1676
|
-
|
|
1677
1680
|
precision highp float;
|
|
1678
1681
|
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1682
|
+
in vec3 positions;
|
|
1683
|
+
in float instanceSize;
|
|
1684
|
+
in vec4 instanceColor;
|
|
1685
|
+
in float instanceSpeedFactor;
|
|
1686
|
+
in float instanceArrowDistance;
|
|
1687
|
+
in float instanceArrowDirection;
|
|
1688
|
+
in float instanceLineDistance;
|
|
1689
|
+
in int instanceLinePositionsTextureOffset;
|
|
1690
|
+
in int instanceLineDistancesTextureOffset;
|
|
1691
|
+
in int instanceLinePointCount;
|
|
1692
|
+
in float instanceLineParallelIndex;
|
|
1693
|
+
in vec3 instanceLineAngles;
|
|
1694
|
+
in vec2 instanceProximityFactors;
|
|
1695
|
+
in float instanceDistanceBetweenLines;
|
|
1693
1696
|
|
|
1694
1697
|
uniform float sizeMinPixels;
|
|
1695
1698
|
uniform float sizeMaxPixels;
|
|
1696
1699
|
uniform float timestamp;
|
|
1697
1700
|
uniform sampler2D linePositionsTexture;
|
|
1698
1701
|
uniform sampler2D lineDistancesTexture;
|
|
1699
|
-
uniform ivec2 linePositionsTextureSize;
|
|
1700
|
-
uniform ivec2 lineDistancesTextureSize;
|
|
1701
|
-
uniform float webgl2;
|
|
1702
|
-
uniform float distanceBetweenLines;
|
|
1703
1702
|
uniform float maxParallelOffset;
|
|
1704
1703
|
uniform float minParallelOffset;
|
|
1705
1704
|
uniform float opacity;
|
|
1705
|
+
uniform ivec2 linePositionsTextureSize;
|
|
1706
1706
|
|
|
1707
|
-
|
|
1708
|
-
varying float shouldDiscard;
|
|
1707
|
+
uniform ivec2 lineDistancesTextureSize;
|
|
1709
1708
|
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
float y = (2.0 * float(index.y) + 1.0) / (2.0 * float(size.y));
|
|
1713
|
-
return texture2D(sampler, vec2(x, y));
|
|
1714
|
-
}
|
|
1709
|
+
flat out vec4 vFillColor;
|
|
1710
|
+
flat out float shouldDiscard;
|
|
1715
1711
|
|
|
1716
1712
|
/**
|
|
1717
1713
|
* Calculate 2 dimensions texture index from flat index.
|
|
1718
1714
|
*/
|
|
1719
1715
|
ivec2 calculateTextureIndex(int flatIndex, ivec2 textureSize) {
|
|
1720
|
-
|
|
1721
|
-
int y = flatIndex / textureSize.y;
|
|
1722
|
-
return ivec2(x, y);
|
|
1716
|
+
return ivec2(flatIndex % textureSize.x, flatIndex / textureSize.x);
|
|
1723
1717
|
}
|
|
1724
1718
|
|
|
1725
1719
|
/**
|
|
1726
1720
|
* Fetch WGS84 position from texture for a given point of the line.
|
|
1727
1721
|
*/
|
|
1728
1722
|
vec3 fetchLinePosition(int point) {
|
|
1729
|
-
int flatIndex =
|
|
1723
|
+
int flatIndex = instanceLinePositionsTextureOffset + point;
|
|
1730
1724
|
ivec2 textureIndex = calculateTextureIndex(flatIndex, linePositionsTextureSize);
|
|
1731
|
-
|
|
1732
|
-
float x = color.r;
|
|
1733
|
-
float y = webgl2 > 0.5 ? color.g : color.a;
|
|
1734
|
-
return vec3(x, y, 0);
|
|
1725
|
+
return vec3(texelFetch(linePositionsTexture, textureIndex, 0).xy, 0);
|
|
1735
1726
|
}
|
|
1736
1727
|
|
|
1737
1728
|
/**
|
|
1738
1729
|
* Fetch distance (in meters from the start of the line) from texture for a point of the line.
|
|
1739
1730
|
*/
|
|
1740
1731
|
float fetchLineDistance(int point) {
|
|
1741
|
-
int flatIndex =
|
|
1732
|
+
int flatIndex = instanceLineDistancesTextureOffset + point;
|
|
1742
1733
|
ivec2 textureIndex = calculateTextureIndex(flatIndex, lineDistancesTextureSize);
|
|
1743
|
-
return texelFetch(lineDistancesTexture, textureIndex,
|
|
1734
|
+
return texelFetch(lineDistancesTexture, textureIndex, 0).x;
|
|
1744
1735
|
}
|
|
1745
1736
|
|
|
1746
1737
|
/**
|
|
@@ -1760,25 +1751,21 @@ float fetchLineDistance(int point) {
|
|
|
1760
1751
|
*/
|
|
1761
1752
|
int findFirstLinePointAfterDistance(float distance) {
|
|
1762
1753
|
int firstPoint = 0;
|
|
1763
|
-
int lastPoint =
|
|
1754
|
+
int lastPoint = instanceLinePointCount - 1;
|
|
1764
1755
|
|
|
1765
|
-
// variable length loops are
|
|
1766
|
-
//
|
|
1767
|
-
//
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
if (
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
firstPoint = middlePoint;
|
|
1779
|
-
} else {
|
|
1780
|
-
lastPoint = middlePoint;
|
|
1781
|
-
}
|
|
1756
|
+
// variable length loops are now supported in GLSL with OpenGL ES 3.0+,
|
|
1757
|
+
// instanceLinePointCount is an upper bound that
|
|
1758
|
+
// will never be reached as binary search complexity is in O(log(instanceLinePointCount))
|
|
1759
|
+
for (int i = 0; i < instanceLinePointCount; i++) {
|
|
1760
|
+
if (firstPoint + 1 == lastPoint) {
|
|
1761
|
+
return lastPoint;
|
|
1762
|
+
}
|
|
1763
|
+
int middlePoint = (firstPoint + lastPoint) / 2;
|
|
1764
|
+
float middlePointDistance = fetchLineDistance(middlePoint);
|
|
1765
|
+
if (middlePointDistance <= distance) {
|
|
1766
|
+
firstPoint = middlePoint;
|
|
1767
|
+
} else {
|
|
1768
|
+
lastPoint = middlePoint;
|
|
1782
1769
|
}
|
|
1783
1770
|
}
|
|
1784
1771
|
return lastPoint;
|
|
@@ -1789,7 +1776,7 @@ mat3 calculateRotation(vec3 commonPosition1, vec3 commonPosition2) {
|
|
|
1789
1776
|
if (instanceArrowDirection < 2.0) {
|
|
1790
1777
|
angle += radians(180.0);
|
|
1791
1778
|
}
|
|
1792
|
-
return mat3(cos(angle), sin(angle), 0, -sin(angle), cos(angle), 0, 0, 0, 0);
|
|
1779
|
+
return mat3(cos(angle), sin(angle), 0.0, -sin(angle), cos(angle), 0.0, 0.0, 0.0, 1.0);
|
|
1793
1780
|
}
|
|
1794
1781
|
|
|
1795
1782
|
/**
|
|
@@ -1821,16 +1808,18 @@ float project_size_all_zoom_levels(float meters, float lat) {
|
|
|
1821
1808
|
|
|
1822
1809
|
void main(void ) {
|
|
1823
1810
|
if (instanceArrowDirection < 1.0) {
|
|
1824
|
-
vFillColor = vec4(0
|
|
1811
|
+
vFillColor = vec4(0.0);
|
|
1825
1812
|
shouldDiscard = 1.0;
|
|
1826
1813
|
} else {
|
|
1827
1814
|
// arrow distance from the line start shifted with current timestamp
|
|
1828
1815
|
// instanceArrowDistance: a float in interval [0,1] describing the initial position of the arrow along the full path between two substations (0: begin, 1.0 end)
|
|
1829
|
-
float
|
|
1816
|
+
float distanceAlong =
|
|
1830
1817
|
instanceLineDistance * instanceArrowDistance +
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
)
|
|
1818
|
+
(instanceArrowDirection < 2.0 ? 1.0 : -1.0) * timestamp * instanceSpeedFactor;
|
|
1819
|
+
float arrowDistance = mod(distanceAlong, instanceLineDistance);
|
|
1820
|
+
if (arrowDistance < 0.0) {
|
|
1821
|
+
arrowDistance += instanceLineDistance;
|
|
1822
|
+
}
|
|
1834
1823
|
|
|
1835
1824
|
// look for first line point that is after arrow distance
|
|
1836
1825
|
int linePoint = findFirstLinePointAfterDistance(arrowDistance);
|
|
@@ -1838,7 +1827,8 @@ void main(void ) {
|
|
|
1838
1827
|
// Interpolate the 2 line points position
|
|
1839
1828
|
float lineDistance1 = fetchLineDistance(linePoint - 1);
|
|
1840
1829
|
float lineDistance2 = fetchLineDistance(linePoint);
|
|
1841
|
-
float
|
|
1830
|
+
float denom = max(1e-6, lineDistance2 - lineDistance1);
|
|
1831
|
+
float interpolationValue = clamp((arrowDistance - lineDistance1) / denom, 0.0, 1.0);
|
|
1842
1832
|
|
|
1843
1833
|
// position for the line point just before the arrow
|
|
1844
1834
|
vec3 linePosition1 = fetchLinePosition(linePoint - 1);
|
|
@@ -1859,7 +1849,7 @@ void main(void ) {
|
|
|
1859
1849
|
// This hack does not seem necessary for parallel-path or fork-line layers.
|
|
1860
1850
|
vec3 arrowPositionWorldSpace = mix(linePosition1, linePosition2, interpolationValue);
|
|
1861
1851
|
float offsetCommonSpace = clamp(
|
|
1862
|
-
project_size_all_zoom_levels(
|
|
1852
|
+
project_size_all_zoom_levels(instanceDistanceBetweenLines, arrowPositionWorldSpace.y),
|
|
1863
1853
|
project_pixel_size(minParallelOffset),
|
|
1864
1854
|
project_pixel_size(maxParallelOffset)
|
|
1865
1855
|
);
|
|
@@ -1907,7 +1897,7 @@ void main(void ) {
|
|
|
1907
1897
|
}
|
|
1908
1898
|
}
|
|
1909
1899
|
`;
|
|
1910
|
-
const fs = '/**\n * Copyright (c) 2022, RTE (http://www.rte-france.com)\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n\
|
|
1900
|
+
const fs = '#version 300 es\n#define SHADER_NAME "arrow-layer-fragment-shader"\nprecision highp float;\n\n/**\n * Copyright (c) 2022, RTE (http://www.rte-france.com)\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n\nflat in vec4 vFillColor;\nflat in float shouldDiscard;\nout vec4 fragmentColor;\n\nvoid main(void) {\n if (shouldDiscard > 0.0) {\n discard;\n }\n fragmentColor = vFillColor;\n}\n';
|
|
1911
1901
|
const DEFAULT_COLOR = [0, 0, 0, 255];
|
|
1912
1902
|
const MAX_LINE_POINT_COUNT = 2 ** 15;
|
|
1913
1903
|
var ArrowDirection = /* @__PURE__ */ ((ArrowDirection2) => {
|
|
@@ -1935,11 +1925,9 @@ const defaultProps$3 = {
|
|
|
1935
1925
|
animated: { type: "boolean", value: true },
|
|
1936
1926
|
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
1937
1927
|
getLineAngles: { type: "accessor", value: [0, 0, 0] },
|
|
1938
|
-
// @ts-expect-error TODO TS2322: distanceBetweenLines does not exist in type DefaultProps<ArrowLayerProps>. Did you mean to write getDistanceBetweenLines?
|
|
1939
|
-
distanceBetweenLines: { type: "number", value: 1e3 },
|
|
1940
1928
|
maxParallelOffset: { type: "number", value: 100 },
|
|
1941
|
-
minParallelOffset: { type: "number", value: 3 }
|
|
1942
|
-
opacity
|
|
1929
|
+
minParallelOffset: { type: "number", value: 3 }
|
|
1930
|
+
// opacity prop is handled at the layer level for visually proportional perception https://deck.gl/docs/api-reference/core/layer#opacity
|
|
1943
1931
|
};
|
|
1944
1932
|
const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
1945
1933
|
getShaders() {
|
|
@@ -1957,20 +1945,16 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
1957
1945
|
}
|
|
1958
1946
|
return attributes;
|
|
1959
1947
|
}
|
|
1960
|
-
initializeState() {
|
|
1948
|
+
initializeState({ device }) {
|
|
1961
1949
|
var _a;
|
|
1962
|
-
const
|
|
1963
|
-
if (!hasFeatures(gl, [FEATURES.TEXTURE_FLOAT])) {
|
|
1964
|
-
throw new Error("Arrow layer not supported on this browser");
|
|
1965
|
-
}
|
|
1966
|
-
const maxTextureSize = gl.getParameter(GL.MAX_TEXTURE_SIZE);
|
|
1950
|
+
const maxTextureSize = device.limits.maxTextureDimension2D;
|
|
1967
1951
|
this.state = {
|
|
1968
|
-
maxTextureSize
|
|
1969
|
-
webgl2: isWebGL2(gl)
|
|
1952
|
+
maxTextureSize
|
|
1970
1953
|
};
|
|
1971
1954
|
(_a = this.getAttributeManager()) == null ? void 0 : _a.addInstanced({
|
|
1972
1955
|
instanceSize: {
|
|
1973
1956
|
size: 1,
|
|
1957
|
+
type: "float32",
|
|
1974
1958
|
transition: true,
|
|
1975
1959
|
accessor: "getSize",
|
|
1976
1960
|
defaultValue: 1
|
|
@@ -1978,13 +1962,14 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
1978
1962
|
instanceColor: {
|
|
1979
1963
|
size: this.props.colorFormat.length,
|
|
1980
1964
|
transition: true,
|
|
1981
|
-
|
|
1982
|
-
|
|
1965
|
+
type: "unorm8",
|
|
1966
|
+
// normalized: true,
|
|
1983
1967
|
accessor: "getColor",
|
|
1984
1968
|
defaultValue: [0, 0, 0, 255]
|
|
1985
1969
|
},
|
|
1986
1970
|
instanceSpeedFactor: {
|
|
1987
1971
|
size: 1,
|
|
1972
|
+
type: "float32",
|
|
1988
1973
|
transition: true,
|
|
1989
1974
|
accessor: "getSpeedFactor",
|
|
1990
1975
|
defaultValue: 1
|
|
@@ -1993,11 +1978,12 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
1993
1978
|
size: 1,
|
|
1994
1979
|
transition: true,
|
|
1995
1980
|
accessor: "getDistance",
|
|
1996
|
-
type:
|
|
1981
|
+
type: "float32",
|
|
1997
1982
|
defaultValue: 0
|
|
1998
1983
|
},
|
|
1999
1984
|
instanceArrowDirection: {
|
|
2000
1985
|
size: 1,
|
|
1986
|
+
type: "float32",
|
|
2001
1987
|
transition: true,
|
|
2002
1988
|
accessor: "getDirection",
|
|
2003
1989
|
transform: (direction) => {
|
|
@@ -2017,41 +2003,48 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
2017
2003
|
instanceLineDistance: {
|
|
2018
2004
|
size: 1,
|
|
2019
2005
|
transition: true,
|
|
2020
|
-
type:
|
|
2006
|
+
type: "float32",
|
|
2021
2007
|
accessor: (arrow) => this.getArrowLineAttributes(arrow).distance
|
|
2022
2008
|
},
|
|
2023
2009
|
instanceLinePositionsTextureOffset: {
|
|
2024
2010
|
size: 1,
|
|
2025
2011
|
transition: true,
|
|
2026
|
-
type:
|
|
2012
|
+
type: "sint32",
|
|
2027
2013
|
accessor: (arrow) => this.getArrowLineAttributes(arrow).positionsTextureOffset
|
|
2028
2014
|
},
|
|
2029
2015
|
instanceLineDistancesTextureOffset: {
|
|
2030
2016
|
size: 1,
|
|
2031
2017
|
transition: true,
|
|
2032
|
-
type:
|
|
2018
|
+
type: "sint32",
|
|
2033
2019
|
accessor: (arrow) => this.getArrowLineAttributes(arrow).distancesTextureOffset
|
|
2034
2020
|
},
|
|
2035
2021
|
instanceLinePointCount: {
|
|
2036
2022
|
size: 1,
|
|
2037
2023
|
transition: true,
|
|
2038
|
-
type:
|
|
2024
|
+
type: "sint32",
|
|
2039
2025
|
accessor: (arrow) => this.getArrowLineAttributes(arrow).pointCount
|
|
2040
2026
|
},
|
|
2041
2027
|
instanceLineParallelIndex: {
|
|
2042
2028
|
size: 1,
|
|
2043
2029
|
accessor: "getLineParallelIndex",
|
|
2044
|
-
type:
|
|
2030
|
+
type: "float32"
|
|
2045
2031
|
},
|
|
2046
2032
|
instanceLineAngles: {
|
|
2047
2033
|
size: 3,
|
|
2048
2034
|
accessor: "getLineAngles",
|
|
2049
|
-
type:
|
|
2035
|
+
type: "float32"
|
|
2050
2036
|
},
|
|
2051
2037
|
instanceProximityFactors: {
|
|
2052
2038
|
size: 2,
|
|
2053
2039
|
accessor: "getProximityFactors",
|
|
2054
|
-
type:
|
|
2040
|
+
type: "float32"
|
|
2041
|
+
},
|
|
2042
|
+
instanceDistanceBetweenLines: {
|
|
2043
|
+
size: 1,
|
|
2044
|
+
transition: true,
|
|
2045
|
+
accessor: "getDistanceBetweenLines",
|
|
2046
|
+
type: "float32",
|
|
2047
|
+
defaultValue: 1e3
|
|
2055
2048
|
}
|
|
2056
2049
|
});
|
|
2057
2050
|
}
|
|
@@ -2059,25 +2052,28 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
2059
2052
|
super.finalizeState(context);
|
|
2060
2053
|
this.state.stop = true;
|
|
2061
2054
|
}
|
|
2062
|
-
createTexture2D(
|
|
2055
|
+
createTexture2D(device, data, elementSize, format) {
|
|
2063
2056
|
const start = performance.now();
|
|
2064
|
-
const elementCount = data.length / elementSize;
|
|
2065
|
-
const n = Math.ceil(Math.log2(elementCount) / 2);
|
|
2066
|
-
const textureSize = 2 ** n;
|
|
2067
2057
|
const { maxTextureSize } = this.state;
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2058
|
+
const elementCount = data.length / elementSize;
|
|
2059
|
+
const expSum = Math.ceil(Math.log2(elementCount));
|
|
2060
|
+
const widthExp = Math.ceil(expSum / 2);
|
|
2061
|
+
const heightExp = expSum - widthExp;
|
|
2062
|
+
const width = 2 ** widthExp;
|
|
2063
|
+
const height = 2 ** heightExp;
|
|
2064
|
+
if (height > maxTextureSize || width > maxTextureSize) {
|
|
2065
|
+
throw new Error(`Texture size ${width}*${height} cannot be greater than ${maxTextureSize}`);
|
|
2066
|
+
}
|
|
2067
|
+
const newLength = width * height * elementSize;
|
|
2068
|
+
const oldLength = data.length;
|
|
2069
|
+
if (data.length < newLength) {
|
|
2070
|
+
data.length = newLength;
|
|
2071
|
+
data.fill(0, oldLength, newLength);
|
|
2072
|
+
}
|
|
2073
|
+
const texture2d = device.createTexture({
|
|
2074
|
+
width,
|
|
2075
|
+
height,
|
|
2079
2076
|
format,
|
|
2080
|
-
dataFormat,
|
|
2081
2077
|
type: GL.FLOAT,
|
|
2082
2078
|
data: new Float32Array(data),
|
|
2083
2079
|
parameters: {
|
|
@@ -2090,7 +2086,7 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
2090
2086
|
});
|
|
2091
2087
|
const stop = performance.now();
|
|
2092
2088
|
console.info(
|
|
2093
|
-
`Texture of ${elementCount} elements (${
|
|
2089
|
+
`Texture of ${elementCount} elements of size ${elementSize} (${width} * ${height}) created in ${stop - start} ms`
|
|
2094
2090
|
);
|
|
2095
2091
|
return texture2d;
|
|
2096
2092
|
}
|
|
@@ -2140,21 +2136,21 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
2140
2136
|
var _a;
|
|
2141
2137
|
const geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getLinePositions);
|
|
2142
2138
|
if (geometryChanged) {
|
|
2143
|
-
const {
|
|
2139
|
+
const { device } = this.context;
|
|
2144
2140
|
const { linePositionsTextureData, lineDistancesTextureData, lineAttributes } = this.createTexturesStructure(props);
|
|
2145
2141
|
const linePositionsTexture = this.createTexture2D(
|
|
2146
|
-
|
|
2142
|
+
device,
|
|
2147
2143
|
linePositionsTextureData,
|
|
2148
2144
|
2,
|
|
2149
|
-
|
|
2150
|
-
|
|
2145
|
+
"rg32float"
|
|
2146
|
+
//GL.RG32F,
|
|
2151
2147
|
);
|
|
2152
2148
|
const lineDistancesTexture = this.createTexture2D(
|
|
2153
|
-
|
|
2149
|
+
device,
|
|
2154
2150
|
lineDistancesTextureData,
|
|
2155
2151
|
1,
|
|
2156
|
-
|
|
2157
|
-
|
|
2152
|
+
"r32float"
|
|
2153
|
+
//GL.R32F,
|
|
2158
2154
|
);
|
|
2159
2155
|
this.setState({
|
|
2160
2156
|
linePositionsTexture,
|
|
@@ -2168,14 +2164,14 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
2168
2164
|
}
|
|
2169
2165
|
updateModel({ changeFlags }) {
|
|
2170
2166
|
var _a;
|
|
2171
|
-
if (changeFlags.
|
|
2172
|
-
const {
|
|
2167
|
+
if (changeFlags.somethingChanged) {
|
|
2168
|
+
const { device } = this.context;
|
|
2173
2169
|
const { model } = this.state;
|
|
2174
2170
|
if (model) {
|
|
2175
|
-
model.
|
|
2171
|
+
model.destroy();
|
|
2176
2172
|
}
|
|
2177
2173
|
this.setState({
|
|
2178
|
-
model: this._getModel(
|
|
2174
|
+
model: this._getModel(device)
|
|
2179
2175
|
});
|
|
2180
2176
|
(_a = this.getAttributeManager()) == null ? void 0 : _a.invalidateAll();
|
|
2181
2177
|
}
|
|
@@ -2207,41 +2203,51 @@ const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
|
2207
2203
|
startAnimation() {
|
|
2208
2204
|
window.requestAnimationFrame((timestamp) => this.animate(timestamp));
|
|
2209
2205
|
}
|
|
2210
|
-
|
|
2211
|
-
draw({ uniforms }) {
|
|
2212
|
-
var _a;
|
|
2206
|
+
draw({ uniforms, renderPass }) {
|
|
2213
2207
|
const { sizeMinPixels, sizeMaxPixels } = this.props;
|
|
2214
|
-
const {
|
|
2215
|
-
|
|
2216
|
-
sizeMinPixels,
|
|
2217
|
-
sizeMaxPixels,
|
|
2208
|
+
const {
|
|
2209
|
+
model,
|
|
2218
2210
|
linePositionsTexture,
|
|
2219
2211
|
lineDistancesTexture,
|
|
2220
|
-
|
|
2212
|
+
timestamp
|
|
2213
|
+
// maxTextureSize,
|
|
2214
|
+
} = this.state;
|
|
2215
|
+
model.setBindings({
|
|
2221
2216
|
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2222
|
-
|
|
2217
|
+
linePositionsTexture,
|
|
2218
|
+
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2219
|
+
lineDistancesTexture
|
|
2220
|
+
});
|
|
2221
|
+
model.setUniforms({
|
|
2222
|
+
...uniforms,
|
|
2223
|
+
sizeMinPixels,
|
|
2224
|
+
sizeMaxPixels,
|
|
2225
|
+
// maxTextureSize,
|
|
2226
|
+
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2227
|
+
linePositionsTextureSize: [linePositionsTexture.width, linePositionsTexture.height],
|
|
2228
|
+
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2229
|
+
lineDistancesTextureSize: [lineDistancesTexture.width, lineDistancesTexture.height],
|
|
2223
2230
|
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2224
|
-
lineDistancesTextureSize: [lineDistancesTexture == null ? void 0 : lineDistancesTexture.width, lineDistancesTexture == null ? void 0 : lineDistancesTexture.height],
|
|
2225
2231
|
timestamp,
|
|
2226
|
-
webgl2,
|
|
2227
|
-
distanceBetweenLines: this.props.getDistanceBetweenLines,
|
|
2228
2232
|
maxParallelOffset: this.props.maxParallelOffset,
|
|
2229
2233
|
minParallelOffset: this.props.minParallelOffset
|
|
2230
|
-
})
|
|
2234
|
+
});
|
|
2235
|
+
model.draw(renderPass);
|
|
2231
2236
|
}
|
|
2232
|
-
|
|
2233
|
-
|
|
2237
|
+
_getModel(device) {
|
|
2238
|
+
const positions = [-1, -1, 0, 0, 1, 0, 0, -0.6, 0, 1, -1, 0, 0, 1, 0, 0, -0.6, 0];
|
|
2234
2239
|
return new Model(
|
|
2235
|
-
|
|
2240
|
+
device,
|
|
2236
2241
|
Object.assign(this.getShaders(), {
|
|
2237
2242
|
id: this.props.id,
|
|
2243
|
+
bufferLayout: this.getAttributeManager().getBufferLayouts(),
|
|
2238
2244
|
geometry: new Geometry({
|
|
2239
|
-
|
|
2245
|
+
topology: "triangle-list",
|
|
2240
2246
|
vertexCount: 6,
|
|
2241
2247
|
attributes: {
|
|
2242
2248
|
positions: {
|
|
2243
2249
|
size: 3,
|
|
2244
|
-
value: new Float32Array(
|
|
2250
|
+
value: new Float32Array(positions)
|
|
2245
2251
|
}
|
|
2246
2252
|
}
|
|
2247
2253
|
}),
|
|
@@ -2496,10 +2502,10 @@ const _ForkLineLayer = class _ForkLineLayer extends LineLayer$1 {
|
|
|
2496
2502
|
const shaders = super.getShaders();
|
|
2497
2503
|
shaders.inject = {
|
|
2498
2504
|
"vs:#decl": `
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2505
|
+
in float instanceLineParallelIndex;
|
|
2506
|
+
in float instanceLineAngle;
|
|
2507
|
+
in float instanceOffsetStart;
|
|
2508
|
+
in float instanceProximityFactor;
|
|
2503
2509
|
uniform float distanceBetweenLines;
|
|
2504
2510
|
uniform float maxParallelOffset;
|
|
2505
2511
|
uniform float minParallelOffset;
|
|
@@ -2530,27 +2536,27 @@ uniform float minSubstationRadiusPixel;
|
|
|
2530
2536
|
return shaders;
|
|
2531
2537
|
}
|
|
2532
2538
|
initializeState() {
|
|
2539
|
+
var _a;
|
|
2533
2540
|
super.initializeState();
|
|
2534
|
-
|
|
2535
|
-
attributeManager == null ? void 0 : attributeManager.addInstanced({
|
|
2541
|
+
(_a = this.getAttributeManager()) == null ? void 0 : _a.addInstanced({
|
|
2536
2542
|
instanceLineParallelIndex: {
|
|
2537
2543
|
size: 1,
|
|
2538
|
-
type:
|
|
2544
|
+
type: "float32",
|
|
2539
2545
|
accessor: "getLineParallelIndex"
|
|
2540
2546
|
},
|
|
2541
2547
|
instanceLineAngle: {
|
|
2542
2548
|
size: 1,
|
|
2543
|
-
type:
|
|
2549
|
+
type: "float32",
|
|
2544
2550
|
accessor: "getLineAngle"
|
|
2545
2551
|
},
|
|
2546
2552
|
instanceOffsetStart: {
|
|
2547
2553
|
size: 1,
|
|
2548
|
-
type:
|
|
2554
|
+
type: "float32",
|
|
2549
2555
|
accessor: "getSubstationOffset"
|
|
2550
2556
|
},
|
|
2551
2557
|
instanceProximityFactor: {
|
|
2552
2558
|
size: 1,
|
|
2553
|
-
type:
|
|
2559
|
+
type: "float32",
|
|
2554
2560
|
accessor: "getProximityFactor"
|
|
2555
2561
|
}
|
|
2556
2562
|
});
|
|
@@ -2606,7 +2612,7 @@ const _ParallelPathLayer = class _ParallelPathLayer extends PathLayer {
|
|
|
2606
2612
|
// also has the downside that you can't update one attribute and reconstruct
|
|
2607
2613
|
// only its buffer, so it hurts performance a bit in this case.
|
|
2608
2614
|
// But this is a rare case for us (changing parameters) so it doesn't matter much.
|
|
2609
|
-
|
|
2615
|
+
in vec4 instanceExtraAttributes;
|
|
2610
2616
|
uniform float distanceBetweenLines;
|
|
2611
2617
|
uniform float maxParallelOffset;
|
|
2612
2618
|
uniform float minParallelOffset;
|
|
@@ -2654,12 +2660,11 @@ gl_Position += project_common_position_to_clipspace(trans) - project_uCenter;
|
|
|
2654
2660
|
// too much instances variables need to compact some...
|
|
2655
2661
|
instanceExtraAttributes: {
|
|
2656
2662
|
size: 4,
|
|
2657
|
-
type:
|
|
2663
|
+
type: "float32",
|
|
2658
2664
|
accessor: "getExtraAttributes"
|
|
2659
2665
|
}
|
|
2660
2666
|
});
|
|
2661
2667
|
}
|
|
2662
|
-
// TODO find the full type for record values
|
|
2663
2668
|
draw({ uniforms }) {
|
|
2664
2669
|
super.draw({
|
|
2665
2670
|
uniforms: {
|
|
@@ -3031,7 +3036,7 @@ const _LineLayer = class _LineLayer extends CompositeLayer {
|
|
|
3031
3036
|
}
|
|
3032
3037
|
);
|
|
3033
3038
|
const arrowCount = Math.ceil(directLineDistance / DISTANCE_BETWEEN_ARROWS);
|
|
3034
|
-
return
|
|
3039
|
+
return Array.from({ length: arrowCount }, (_, index) => {
|
|
3035
3040
|
return {
|
|
3036
3041
|
distance: index / arrowCount,
|
|
3037
3042
|
line
|
|
@@ -3244,10 +3249,13 @@ const _LineLayer = class _LineLayer extends CompositeLayer {
|
|
|
3244
3249
|
const startFork = new ForkLineLayer(
|
|
3245
3250
|
this.getSubLayerProps({
|
|
3246
3251
|
id: "LineForkStart" + compositeData.nominalV,
|
|
3252
|
+
data: compositeData.lines,
|
|
3253
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3247
3254
|
getSourcePosition: (line) => line.origin,
|
|
3255
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3248
3256
|
getTargetPosition: (line) => line.end,
|
|
3257
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3249
3258
|
getSubstationOffset: (line) => line.substationIndexStart,
|
|
3250
|
-
data: compositeData.lines,
|
|
3251
3259
|
widthScale: 20,
|
|
3252
3260
|
widthMinPixels: 1,
|
|
3253
3261
|
widthMaxPixels: 2,
|
|
@@ -3257,6 +3265,7 @@ const _LineLayer = class _LineLayer extends CompositeLayer {
|
|
|
3257
3265
|
getLineColor(line, nominalVoltageColor, this.props, this.state.linesConnection.get(line.id))
|
|
3258
3266
|
),
|
|
3259
3267
|
getWidth: 2,
|
|
3268
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3260
3269
|
getProximityFactor: (line) => line.proximityFactorStart,
|
|
3261
3270
|
// @ts-expect-error TODO: manage undefined case
|
|
3262
3271
|
getLineParallelIndex: (line) => line.parallelIndex,
|
|
@@ -3288,10 +3297,13 @@ const _LineLayer = class _LineLayer extends CompositeLayer {
|
|
|
3288
3297
|
const endFork = new ForkLineLayer(
|
|
3289
3298
|
this.getSubLayerProps({
|
|
3290
3299
|
id: "LineForkEnd" + compositeData.nominalV,
|
|
3300
|
+
data: compositeData.lines,
|
|
3301
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3291
3302
|
getSourcePosition: (line) => line.end,
|
|
3303
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3292
3304
|
getTargetPosition: (line) => line.origin,
|
|
3305
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3293
3306
|
getSubstationOffset: (line) => line.substationIndexEnd,
|
|
3294
|
-
data: compositeData.lines,
|
|
3295
3307
|
widthScale: 20,
|
|
3296
3308
|
widthMinPixels: 1,
|
|
3297
3309
|
widthMaxPixels: 2,
|
|
@@ -3301,6 +3313,7 @@ const _LineLayer = class _LineLayer extends CompositeLayer {
|
|
|
3301
3313
|
getLineColor(line, nominalVoltageColor, this.props, this.state.linesConnection.get(line.id))
|
|
3302
3314
|
),
|
|
3303
3315
|
getWidth: 2,
|
|
3316
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3304
3317
|
getProximityFactor: (line) => line.proximityFactorEnd,
|
|
3305
3318
|
// @ts-expect-error TODO: manage undefined case
|
|
3306
3319
|
getLineParallelIndex: (line) => -line.parallelIndex,
|
|
@@ -3628,7 +3641,7 @@ const _ScatterplotLayerExt = class _ScatterplotLayerExt extends ScatterplotLayer
|
|
|
3628
3641
|
vs: shaders.vs.replace(", radiusMaxPixels", ", instanceRadiusMaxPixels"),
|
|
3629
3642
|
// hack to replace the uniform variable to corresponding attribute
|
|
3630
3643
|
inject: {
|
|
3631
|
-
"vs:#decl": `
|
|
3644
|
+
"vs:#decl": `in float instanceRadiusMaxPixels;
|
|
3632
3645
|
`
|
|
3633
3646
|
}
|
|
3634
3647
|
});
|
|
@@ -3641,7 +3654,7 @@ const _ScatterplotLayerExt = class _ScatterplotLayerExt extends ScatterplotLayer
|
|
|
3641
3654
|
size: 1,
|
|
3642
3655
|
transition: true,
|
|
3643
3656
|
accessor: "getRadiusMaxPixels",
|
|
3644
|
-
type:
|
|
3657
|
+
type: "float32",
|
|
3645
3658
|
defaultValue: 0
|
|
3646
3659
|
}
|
|
3647
3660
|
});
|
|
@@ -3682,9 +3695,7 @@ const _SubstationLayer = class _SubstationLayer extends CompositeLayer {
|
|
|
3682
3695
|
substation.voltageLevels.map((voltageLevel) => voltageLevel.nominalV).sort((nominalVoltage1, nominalVoltage2) => nominalVoltage1 - nominalVoltage2)
|
|
3683
3696
|
)
|
|
3684
3697
|
];
|
|
3685
|
-
Array.from(voltageLevelsByNominalVoltage.entries()).forEach((
|
|
3686
|
-
const nominalV = e[0];
|
|
3687
|
-
const voltageLevels = e[1];
|
|
3698
|
+
Array.from(voltageLevelsByNominalVoltage.entries()).forEach(([nominalV, voltageLevels]) => {
|
|
3688
3699
|
let metaVoltageLevels = metaVoltageLevelsByNominalVoltage.get(nominalV);
|
|
3689
3700
|
if (!metaVoltageLevels) {
|
|
3690
3701
|
metaVoltageLevels = [];
|
|
@@ -4030,5 +4041,7 @@ export {
|
|
|
4030
4041
|
LineLayer,
|
|
4031
4042
|
MapEquipments,
|
|
4032
4043
|
SubstationLayer,
|
|
4033
|
-
getNominalVoltageColor
|
|
4044
|
+
getNominalVoltageColor,
|
|
4045
|
+
isMapLine,
|
|
4046
|
+
isMapSubstation
|
|
4034
4047
|
};
|