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