deeptwins-engine-3d 0.1.64 → 0.1.66
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/esm/constant.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.d.ts +1 -0
- package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
- package/dist/esm/drawer/common.d.ts +62 -0
- package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
- package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +1 -0
- package/dist/esm/drawer/index.d.ts +11 -18
- package/dist/esm/drawer/index.js +329 -80
- package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
- package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
- package/dist/esm/drawer/shape/Assemble.js +415 -0
- package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/AttackArrow.js +442 -0
- package/dist/esm/drawer/shape/BaseShape.d.ts +15 -4
- package/dist/esm/drawer/shape/BaseShape.js +175 -20
- package/dist/esm/drawer/shape/Bow.d.ts +31 -0
- package/dist/esm/drawer/shape/Bow.js +375 -0
- package/dist/esm/drawer/shape/Circle.d.ts +37 -0
- package/dist/esm/drawer/shape/Circle.js +461 -0
- package/dist/esm/drawer/shape/Curve.d.ts +29 -0
- package/dist/esm/drawer/shape/Curve.js +386 -0
- package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
- package/dist/esm/drawer/shape/DragPoint.js +211 -0
- package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
- package/dist/esm/drawer/shape/Elliptic.js +491 -0
- package/dist/esm/drawer/shape/Formation.d.ts +33 -0
- package/dist/esm/drawer/shape/Formation.js +395 -0
- package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/PincerArrow.js +445 -0
- package/dist/esm/drawer/shape/Point.d.ts +2 -31
- package/dist/esm/drawer/shape/Point.js +7 -201
- package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
- package/dist/esm/drawer/shape/Polygon.js +10 -81
- package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
- package/dist/esm/drawer/shape/Polyline.js +10 -81
- package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
- package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
- package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
- package/dist/esm/drawer/shape/Sector.d.ts +37 -0
- package/dist/esm/drawer/shape/Sector.js +568 -0
- package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/StraightArrow.js +422 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
- package/dist/esm/drawer/types.d.ts +23 -0
- package/dist/esm/drawer/types.js +11 -0
- package/dist/esm/drawer/utils.d.ts +14 -0
- package/dist/esm/drawer/utils.js +320 -2
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/map/Map.d.ts +9 -0
- package/dist/esm/map/Map.js +115 -2
- package/dist/esm/material/AtmosphericDispersion.d.ts +71 -0
- package/dist/esm/material/AtmosphericDispersion.js +485 -33
- package/dist/esm/material/GlobalVolumetricCloud.d.ts +117 -0
- package/dist/esm/material/GlobalVolumetricCloud.js +219 -223
- package/dist/esm/material/entity/ImageMaterialProperty.d.ts +1 -0
- package/dist/esm/material/shader/AtmosphericShader.glsl +244 -0
- package/dist/esm/measure/Area.d.ts +17 -17
- package/dist/esm/measure/Area.js +95 -63
- package/dist/esm/measure/BaseDraw.d.ts +10 -4
- package/dist/esm/measure/BaseDraw.js +37 -2
- package/dist/esm/measure/Distance.d.ts +9 -9
- package/dist/esm/measure/Distance.js +52 -68
- package/dist/esm/measure/index.d.ts +16 -26
- package/dist/esm/measure/index.js +72 -84
- package/dist/esm/measure/types.d.ts +95 -0
- package/dist/esm/measure/types.js +17 -0
- package/dist/esm/measure/utils.d.ts +8 -7
- package/dist/esm/measure/utils.js +43 -24
- package/dist/esm/sceneFusion/Airway.d.ts +0 -0
- package/dist/esm/sceneFusion/Airway.js +692 -0
- package/dist/esm/tileLayer/ArcGisLayer.d.ts +1 -0
- package/dist/esm/tileLayer/ImageryLayer.d.ts +1 -0
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +1 -0
- package/dist/esm/tool/common.d.ts +1 -0
- package/dist/esm/tool/utils.d.ts +1 -0
- package/dist/esm/tool/utils.js +1 -1
- package/dist/esm/typings.d.ts +8 -0
- package/dist/esm/visualization/BaseHeatmap.d.ts +5 -0
- package/dist/esm/visualization/BaseHeatmap.js +54 -12
- package/dist/esm/visualization/Heatmap2d.d.ts +1 -0
- package/dist/esm/visualization/Heatmap2d.js +17 -26
- package/dist/esm/visualization/Heatmap3d.d.ts +8 -2
- package/dist/esm/visualization/Heatmap3d.js +195 -59
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
- package/dist/esm/plot/create/CreateAssemble.js +0 -63
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
- package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
- package/dist/esm/plot/create/CreateBillboard.js +0 -47
- package/dist/esm/plot/create/CreateBow.d.ts +0 -2
- package/dist/esm/plot/create/CreateBow.js +0 -63
- package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
- package/dist/esm/plot/create/CreateCircle.js +0 -68
- package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
- package/dist/esm/plot/create/CreateCurve.js +0 -76
- package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
- package/dist/esm/plot/create/CreateElliptic.js +0 -69
- package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
- package/dist/esm/plot/create/CreateFlag.js +0 -80
- package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
- package/dist/esm/plot/create/CreateFormation.js +0 -65
- package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreeLine.js +0 -69
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
- package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
- package/dist/esm/plot/create/CreateLabel.js +0 -55
- package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
- package/dist/esm/plot/create/CreateLineArrow.js +0 -79
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
- package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
- package/dist/esm/plot/create/CreatePoint.js +0 -47
- package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolygon.js +0 -80
- package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolyline.js +0 -70
- package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRectangle.js +0 -60
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
- package/dist/esm/plot/create/CreateSector.d.ts +0 -2
- package/dist/esm/plot/create/CreateSector.js +0 -65
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
- package/dist/esm/plot/create/index.d.ts +0 -25
- package/dist/esm/plot/create/index.js +0 -25
- package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
- package/dist/esm/plot/edit/EditAssemble.js +0 -120
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
- package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
- package/dist/esm/plot/edit/EditBillboard.js +0 -70
- package/dist/esm/plot/edit/EditBow.d.ts +0 -8
- package/dist/esm/plot/edit/EditBow.js +0 -119
- package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
- package/dist/esm/plot/edit/EditCircle.js +0 -133
- package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
- package/dist/esm/plot/edit/EditCurve.js +0 -180
- package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
- package/dist/esm/plot/edit/EditElliptic.js +0 -144
- package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
- package/dist/esm/plot/edit/EditFlag.js +0 -121
- package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
- package/dist/esm/plot/edit/EditFormation.js +0 -120
- package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
- package/dist/esm/plot/edit/EditLabel.js +0 -100
- package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditLineArrow.js +0 -180
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
- package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
- package/dist/esm/plot/edit/EditPoint.js +0 -70
- package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolygon.js +0 -181
- package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolyline.js +0 -179
- package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRectangle.js +0 -119
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
- package/dist/esm/plot/edit/EditSector.d.ts +0 -8
- package/dist/esm/plot/edit/EditSector.js +0 -120
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
- package/dist/esm/plot/edit/index.d.ts +0 -23
- package/dist/esm/plot/edit/index.js +0 -23
- package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
- package/dist/esm/plot/utils/DomUtil.js +0 -100
- package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
- package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
- package/dist/esm/plot/utils/ReminderTip.js +0 -67
- package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
- package/dist/esm/plot/utils/Tooltip.js +0 -97
- /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
precision highp float;
|
|
2
|
+
uniform sampler2D colorTexture;
|
|
3
|
+
uniform sampler2D depthTexture;
|
|
4
|
+
uniform float u_threshold;
|
|
5
|
+
uniform float u_blendFactor;
|
|
6
|
+
uniform float u_lightIntensity;
|
|
7
|
+
uniform float u_scatterStrength;
|
|
8
|
+
uniform float u_tonemapExposure;
|
|
9
|
+
uniform float u_mieExtinctionStrength;
|
|
10
|
+
uniform float u_fogOpacity;
|
|
11
|
+
uniform float u_fogPower;
|
|
12
|
+
uniform float u_clearMixBias;
|
|
13
|
+
in vec2 v_textureCoordinates;
|
|
14
|
+
const float PI = 3.14159265359;
|
|
15
|
+
const float TWO_PI = PI * 2.0;
|
|
16
|
+
const float FOUR_PI = PI * 4.0;
|
|
17
|
+
const float SCATTER_VISIBILITY_SCALE = 30000.0;
|
|
18
|
+
const float MAX_EXPOSURE_RESPONSE = 1.8;
|
|
19
|
+
const float MAX_LIGHT_RESPONSE = 3.0;
|
|
20
|
+
|
|
21
|
+
const vec3 betaR = vec3(5.5e-6, 13.0e-6, 22.4e-6);
|
|
22
|
+
|
|
23
|
+
const vec3 betaM = vec3(21e-6);
|
|
24
|
+
|
|
25
|
+
const float hR = 10e3;
|
|
26
|
+
const float hM = 3.8e3;
|
|
27
|
+
const int num_samples = 16;
|
|
28
|
+
const int num_samples_light = 4;
|
|
29
|
+
#ifdef GL_ES
|
|
30
|
+
#define _in(T) const in T
|
|
31
|
+
#define _inout(T) inout T
|
|
32
|
+
#define _out(T) out T
|
|
33
|
+
#define _begin(type) type (
|
|
34
|
+
#define _end )
|
|
35
|
+
#define mul(a, b) (a) * (b)
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
struct ray_t {
|
|
39
|
+
vec3 origin;
|
|
40
|
+
vec3 direction;
|
|
41
|
+
};
|
|
42
|
+
struct sphere_t {
|
|
43
|
+
vec3 origin;
|
|
44
|
+
float radius;
|
|
45
|
+
int material;
|
|
46
|
+
};
|
|
47
|
+
struct plane_t {
|
|
48
|
+
vec3 direction;
|
|
49
|
+
float distance;
|
|
50
|
+
int material;
|
|
51
|
+
};
|
|
52
|
+
plane_t plane;
|
|
53
|
+
mat3 rotate_around_x(_in(float) angle_degrees) {
|
|
54
|
+
float angle = radians(angle_degrees);
|
|
55
|
+
float _sin = sin(angle);
|
|
56
|
+
float _cos = cos(angle);
|
|
57
|
+
return mat3(1, 0, 0, 0, _cos, -_sin, 0, _sin, _cos);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bool isect_sphere(_in(ray_t) ray, _in(sphere_t) sphere, _inout(float) t0, _inout(float) t1) {
|
|
61
|
+
vec3 rc = sphere.origin - ray.origin;
|
|
62
|
+
float radius2 = sphere.radius * sphere.radius;
|
|
63
|
+
float tca = dot(rc, ray.direction);
|
|
64
|
+
float d2 = dot(rc, rc) - tca * tca;
|
|
65
|
+
if (d2 > radius2) return false;
|
|
66
|
+
float thc = sqrt(radius2 - d2);
|
|
67
|
+
t0 = tca - thc;
|
|
68
|
+
t1 = tca + thc;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
float rayleigh_phase_func(float mu) {
|
|
72
|
+
return
|
|
73
|
+
3. * (1. + mu * mu)
|
|
74
|
+
/
|
|
75
|
+
(16. * PI);
|
|
76
|
+
}
|
|
77
|
+
const float g = 0.76;
|
|
78
|
+
float henyey_greenstein_phase_func(float mu) {
|
|
79
|
+
return
|
|
80
|
+
(1. - g * g)
|
|
81
|
+
/
|
|
82
|
+
((4. * PI) * pow(1. + g * g - 2. * g * mu, 1.5));
|
|
83
|
+
}
|
|
84
|
+
const float k = 1.55 * g - 0.55 * (g * g * g);
|
|
85
|
+
float schlick_phase_func(float mu) {
|
|
86
|
+
return
|
|
87
|
+
(1. - k * k)
|
|
88
|
+
/
|
|
89
|
+
(4. * PI * (1. + k * mu) * (1. + k * mu));
|
|
90
|
+
}
|
|
91
|
+
const sphere_t atmosphere = _begin(sphere_t)
|
|
92
|
+
vec3(0, 0, 0), 6420e3, 0
|
|
93
|
+
_end;
|
|
94
|
+
|
|
95
|
+
bool get_sun_light(
|
|
96
|
+
_in(ray_t) ray, _inout(float) optical_depthR, _inout(float) optical_depthM
|
|
97
|
+
) {
|
|
98
|
+
float t0, t1;
|
|
99
|
+
isect_sphere(ray, atmosphere, t0, t1);
|
|
100
|
+
float march_pos = 0.;
|
|
101
|
+
float march_step = t1 / float(num_samples_light);
|
|
102
|
+
for (int i = 0; i < num_samples_light; i++) {
|
|
103
|
+
vec3 s = ray.origin +
|
|
104
|
+
ray.direction * (march_pos + 0.5 * march_step);
|
|
105
|
+
float height = length(s) - 6360e3;
|
|
106
|
+
if (height < 0.)
|
|
107
|
+
return false;
|
|
108
|
+
optical_depthR += exp(-height / hR) * march_step;
|
|
109
|
+
optical_depthM += exp(-height / hM) * march_step;
|
|
110
|
+
march_pos += march_step;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
vec4 get_incident_light(_in(ray_t) ray) {
|
|
115
|
+
vec3 dir = ray.direction;
|
|
116
|
+
vec3 start = ray.origin;
|
|
117
|
+
float a = dot(dir, dir);
|
|
118
|
+
float b = 2.0 * dot(dir, start);
|
|
119
|
+
float radius2 = atmosphere.radius * atmosphere.radius;
|
|
120
|
+
float c = dot(start, start) - radius2;
|
|
121
|
+
float d = (b * b) - 4.0 * a * c;
|
|
122
|
+
if (d < 0.0) return vec4(0.0);
|
|
123
|
+
float squaredD = sqrt(d);
|
|
124
|
+
vec2 ray_length = vec2(
|
|
125
|
+
max((-b - squaredD) / (2.0 * a), 0.0), min((-b + squaredD) / (2.0 * a), plane.distance)
|
|
126
|
+
);
|
|
127
|
+
if (ray_length.x > ray_length.y) return vec4(0.0);
|
|
128
|
+
float march_step = (ray_length.y - ray_length.x) / float(num_samples);
|
|
129
|
+
float mu = dot(ray.direction, normalize(czm_sunPositionWC));
|
|
130
|
+
float phaseR = rayleigh_phase_func(mu);
|
|
131
|
+
float phaseM =
|
|
132
|
+
#if 1
|
|
133
|
+
henyey_greenstein_phase_func(mu);
|
|
134
|
+
#else
|
|
135
|
+
schlick_phase_func(mu);
|
|
136
|
+
#endif
|
|
137
|
+
|
|
138
|
+
float optical_depthR = 0.;
|
|
139
|
+
float optical_depthM = 0.;
|
|
140
|
+
vec3 sumR = vec3(0);
|
|
141
|
+
vec3 sumM = vec3(0);
|
|
142
|
+
float march_pos = 0.;
|
|
143
|
+
for (int i = 0; i < num_samples; i++) {
|
|
144
|
+
vec3 s = ray.origin +
|
|
145
|
+
ray.direction * (march_pos + 0.5 * march_step);
|
|
146
|
+
float height = length(s) - 6360e3;
|
|
147
|
+
|
|
148
|
+
float hr = exp(-height / hR) * march_step;
|
|
149
|
+
float hm = exp(-height / hM) * march_step;
|
|
150
|
+
optical_depthR += hr;
|
|
151
|
+
optical_depthM += hm;
|
|
152
|
+
|
|
153
|
+
ray_t light_ray = _begin(ray_t)
|
|
154
|
+
s, normalize(czm_sunPositionWC)
|
|
155
|
+
_end;
|
|
156
|
+
float optical_depth_lightR = 0.;
|
|
157
|
+
float optical_depth_lightM = 0.;
|
|
158
|
+
bool overground = get_sun_light(
|
|
159
|
+
light_ray,
|
|
160
|
+
optical_depth_lightR,
|
|
161
|
+
optical_depth_lightM);
|
|
162
|
+
|
|
163
|
+
if (overground) {
|
|
164
|
+
|
|
165
|
+
vec3 tau =
|
|
166
|
+
betaR * (optical_depthR + optical_depth_lightR) +
|
|
167
|
+
betaM * u_mieExtinctionStrength * (optical_depthM + optical_depth_lightM);
|
|
168
|
+
vec3 attenuation = exp(-tau);
|
|
169
|
+
sumR += hr * attenuation;
|
|
170
|
+
sumM += hm * attenuation;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
march_pos += march_step;
|
|
174
|
+
}
|
|
175
|
+
vec3 transmittance = exp(-((betaM * optical_depthM * u_mieExtinctionStrength)
|
|
176
|
+
+ (betaR * optical_depthR)) * 4.);
|
|
177
|
+
float attenuation = clamp(dot(transmittance, vec3(0.3333333)), 0.0, 1.0);
|
|
178
|
+
|
|
179
|
+
return vec4(
|
|
180
|
+
u_scatterStrength *
|
|
181
|
+
(sumR * phaseR * betaR +
|
|
182
|
+
sumM * phaseM * betaM), 1.0 - attenuation);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
void main() {
|
|
186
|
+
vec4 rawColor = texture(colorTexture, v_textureCoordinates);
|
|
187
|
+
float depth = czm_unpackDepth(texture(depthTexture, v_textureCoordinates));
|
|
188
|
+
|
|
189
|
+
vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);
|
|
190
|
+
vec4 positionWC = czm_inverseView * positionEC;
|
|
191
|
+
positionWC.xyz = positionWC.xyz / positionWC.w;
|
|
192
|
+
|
|
193
|
+
vec3 lVector = positionWC.xyz - czm_viewerPositionWC;
|
|
194
|
+
ray_t ray;
|
|
195
|
+
ray.origin = czm_viewerPositionWC;
|
|
196
|
+
ray.direction = normalize(lVector);
|
|
197
|
+
plane.distance = length(lVector);
|
|
198
|
+
|
|
199
|
+
vec4 atmosphereColor = get_incident_light(ray);
|
|
200
|
+
float lightControl = clamp(u_lightIntensity / 4.0, 0.0, 1.0);
|
|
201
|
+
float lightStrength = MAX_LIGHT_RESPONSE * (
|
|
202
|
+
1.0 - exp(-2.6 * pow(lightControl, 1.6))
|
|
203
|
+
);
|
|
204
|
+
vec3 scatterColor = atmosphereColor.rgb * lightStrength;
|
|
205
|
+
float exposureControl = clamp(u_tonemapExposure / 3.0, 0.0, 1.0);
|
|
206
|
+
float exposureStrength = pow(exposureControl, 1.25) * MAX_EXPOSURE_RESPONSE;
|
|
207
|
+
float mieVisualFactor = mix(
|
|
208
|
+
0.6,
|
|
209
|
+
1.8,
|
|
210
|
+
clamp(u_mieExtinctionStrength / 2.0, 0.0, 1.0)
|
|
211
|
+
);
|
|
212
|
+
vec3 visibleScatter = 1.0 - exp(
|
|
213
|
+
-max(scatterColor * SCATTER_VISIBILITY_SCALE, 0.0) * exposureStrength
|
|
214
|
+
);
|
|
215
|
+
visibleScatter *= mieVisualFactor;
|
|
216
|
+
float brightness = dot(visibleScatter, vec3(0.299, 0.587, 0.114));
|
|
217
|
+
float thresholdMask = u_threshold > 0.0
|
|
218
|
+
? smoothstep(0.0, u_threshold, brightness)
|
|
219
|
+
: 1.0;
|
|
220
|
+
visibleScatter *= thresholdMask;
|
|
221
|
+
float fogSignal = clamp(atmosphereColor.a * 2.5, 0.0, 1.0);
|
|
222
|
+
float fogAlpha = clamp(
|
|
223
|
+
pow(fogSignal, u_fogPower) * u_fogOpacity * mieVisualFactor,
|
|
224
|
+
0.0,
|
|
225
|
+
1.0
|
|
226
|
+
);
|
|
227
|
+
float clearPreserve = clamp(1.0 - u_clearMixBias, 0.0, 1.0);
|
|
228
|
+
float fogMix = fogAlpha * clearPreserve * 0.85;
|
|
229
|
+
vec3 foggedBase = mix(
|
|
230
|
+
rawColor.rgb,
|
|
231
|
+
rawColor.rgb * (1.0 - fogAlpha * 0.35),
|
|
232
|
+
fogMix
|
|
233
|
+
);
|
|
234
|
+
vec3 overlayColor = visibleScatter *
|
|
235
|
+
(0.55 + fogAlpha * 1.25) *
|
|
236
|
+
mix(1.0, 0.6, u_clearMixBias);
|
|
237
|
+
vec3 finalColor = mix(
|
|
238
|
+
rawColor.rgb,
|
|
239
|
+
foggedBase + overlayColor,
|
|
240
|
+
u_blendFactor
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
out_FragColor = vec4(clamp(finalColor, 0.0, 1.0), rawColor.a);
|
|
244
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import BaseDraw from './BaseDraw';
|
|
2
|
-
import { MeasureContext } from './
|
|
3
|
-
declare class Area extends BaseDraw {
|
|
4
|
-
private readonly _type;
|
|
2
|
+
import { AreaMeasureResult, MeasureContext, MeasureDrawConfig, MeasureLayer, MeasurePosition, MeasureShapeLayer } from './types';
|
|
3
|
+
declare class Area extends BaseDraw implements MeasureLayer {
|
|
5
4
|
private _config;
|
|
6
|
-
private
|
|
5
|
+
private readonly _shapeType;
|
|
6
|
+
_instance: MeasureShapeLayer | null;
|
|
7
7
|
private _area;
|
|
8
8
|
private _areaLayer;
|
|
9
|
-
constructor(measureContext: MeasureContext, config
|
|
9
|
+
constructor(measureContext: MeasureContext, config?: MeasureDrawConfig);
|
|
10
10
|
private _init;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
pointsChange(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
area: any;
|
|
19
|
-
} | undefined;
|
|
11
|
+
private _resolveShapeType;
|
|
12
|
+
private _getDrawerConfig;
|
|
13
|
+
drawing(positions: MeasurePosition[]): AreaMeasureResult | undefined;
|
|
14
|
+
pointsChange(_layer: MeasureShapeLayer, positions: MeasurePosition[]): AreaMeasureResult;
|
|
15
|
+
drawEnd(positions?: MeasurePosition[]): {
|
|
16
|
+
area: number;
|
|
17
|
+
};
|
|
20
18
|
startEdit(): void;
|
|
21
|
-
endEdit(positions
|
|
22
|
-
area:
|
|
23
|
-
}
|
|
19
|
+
endEdit(positions?: MeasurePosition[]): {
|
|
20
|
+
area: number;
|
|
21
|
+
};
|
|
24
22
|
private _calculateArea;
|
|
25
23
|
private _createAreaLabel;
|
|
26
24
|
private _destroyAreaLabel;
|
|
25
|
+
private _updateArea;
|
|
26
|
+
private _toPolygonPositions;
|
|
27
27
|
destroy(): void;
|
|
28
28
|
}
|
|
29
29
|
export default Area;
|
package/dist/esm/measure/Area.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
9
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
15
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -23,33 +27,45 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
23
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
24
28
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
29
|
import { centerOfMass, point, polygon } from '@turf/turf';
|
|
26
|
-
import { SceneTransforms } from 'deeptwins-cesium';
|
|
27
|
-
import { STATUS } from "../drawer";
|
|
28
|
-
import { lngLatAltToCartesian3 } from "../tool/utils";
|
|
29
30
|
import BaseDraw from "./BaseDraw";
|
|
31
|
+
import { AREA_SHAPE_TYPE, STATUS } from "./types";
|
|
30
32
|
import * as utils from "./utils";
|
|
31
33
|
var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
32
34
|
_inherits(Area, _BaseDraw);
|
|
33
35
|
var _super = _createSuper(Area);
|
|
34
|
-
function Area(measureContext
|
|
36
|
+
function Area(measureContext) {
|
|
35
37
|
var _this;
|
|
38
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
39
|
_classCallCheck(this, Area);
|
|
37
40
|
_this = _super.call(this, measureContext);
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "_type", 'area');
|
|
39
41
|
_defineProperty(_assertThisInitialized(_this), "_config", void 0);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "_shapeType", void 0);
|
|
43
|
+
// 图形图层
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "_instance", null);
|
|
42
45
|
_defineProperty(_assertThisInitialized(_this), "_area", 0);
|
|
43
46
|
// 鼠标移动的label
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "_areaLayer",
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "_areaLayer", null);
|
|
45
48
|
_this._config = config;
|
|
49
|
+
_this._shapeType = _this._resolveShapeType(config.shapeType);
|
|
46
50
|
_this._init();
|
|
47
51
|
return _this;
|
|
48
52
|
}
|
|
49
53
|
_createClass(Area, [{
|
|
50
54
|
key: "_init",
|
|
51
55
|
value: function _init() {
|
|
52
|
-
this._instance = this._drawer.startDraw(
|
|
56
|
+
this._instance = this._drawer.startDraw(this._shapeType, this._getDrawerConfig());
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "_resolveShapeType",
|
|
60
|
+
value: function _resolveShapeType(shapeType) {
|
|
61
|
+
return Object.values(AREA_SHAPE_TYPE).includes(shapeType) ? shapeType : AREA_SHAPE_TYPE.POLYGON;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "_getDrawerConfig",
|
|
65
|
+
value: function _getDrawerConfig() {
|
|
66
|
+
var drawerConfig = _objectSpread({}, this._config);
|
|
67
|
+
delete drawerConfig.shapeType;
|
|
68
|
+
return drawerConfig;
|
|
53
69
|
}
|
|
54
70
|
|
|
55
71
|
// 绘制
|
|
@@ -58,48 +74,30 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
58
74
|
value: function drawing(positions) {
|
|
59
75
|
if (!this._canOperate()) return;
|
|
60
76
|
this._measureContext._changeStatus(STATUS.DRAWING);
|
|
61
|
-
|
|
62
|
-
this._destroyAreaLabel();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
var polygonPositions = [].concat(_toConsumableArray(positions), [positions[0]]);
|
|
66
|
-
this._area = this._calculateArea(polygonPositions);
|
|
67
|
-
var center = centerOfMass(polygon([polygonPositions]));
|
|
68
|
-
this._createAreaLabel(center.geometry.coordinates, "\u9762\u79EF".concat(utils.formatArea(this._area)));
|
|
69
|
-
return {
|
|
70
|
-
area: this._area
|
|
71
|
-
};
|
|
77
|
+
return this._updateArea(positions);
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
// 点位修改
|
|
75
81
|
}, {
|
|
76
82
|
key: "pointsChange",
|
|
77
|
-
value: function pointsChange(
|
|
78
|
-
if (!this._canOperate()) return
|
|
79
|
-
|
|
80
|
-
this._destroyAreaLabel();
|
|
81
|
-
return {
|
|
82
|
-
area: 0
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
var polygonPositions = [].concat(_toConsumableArray(positions), [positions[0]]);
|
|
86
|
-
this._area = this._calculateArea(polygonPositions);
|
|
87
|
-
var center = centerOfMass(polygon([polygonPositions]));
|
|
88
|
-
this._createAreaLabel(center.geometry.coordinates, "\u9762\u79EF".concat(utils.formatArea(this._area)));
|
|
89
|
-
return {
|
|
90
|
-
area: this._area
|
|
83
|
+
value: function pointsChange(_layer, positions) {
|
|
84
|
+
if (!this._canOperate()) return {
|
|
85
|
+
area: 0
|
|
91
86
|
};
|
|
87
|
+
return this._updateArea(positions);
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
// 结束绘制
|
|
95
91
|
}, {
|
|
96
92
|
key: "drawEnd",
|
|
97
|
-
value: function drawEnd(
|
|
98
|
-
|
|
93
|
+
value: function drawEnd() {
|
|
94
|
+
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
95
|
+
if (!this._canOperate()) return {
|
|
96
|
+
area: 0
|
|
97
|
+
};
|
|
99
98
|
this._measureContext._changeStatus(STATUS.END_DRAW);
|
|
100
99
|
this._measureContext.setDrawerLayer(this.id, this);
|
|
101
|
-
|
|
102
|
-
this._area = this._calculateArea(polygonPositions);
|
|
100
|
+
this._area = this._calculateArea(this._toPolygonPositions(positions));
|
|
103
101
|
this.startEdit();
|
|
104
102
|
return {
|
|
105
103
|
area: this._area
|
|
@@ -117,10 +115,12 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
117
115
|
// 结束编辑
|
|
118
116
|
}, {
|
|
119
117
|
key: "endEdit",
|
|
120
|
-
value: function endEdit(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
value: function endEdit() {
|
|
119
|
+
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
120
|
+
if (!this._canOperate()) return {
|
|
121
|
+
area: 0
|
|
122
|
+
};
|
|
123
|
+
this._area = this._calculateArea(this._toPolygonPositions(positions));
|
|
124
124
|
return {
|
|
125
125
|
area: this._area
|
|
126
126
|
};
|
|
@@ -131,21 +131,25 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
131
131
|
key: "_calculateArea",
|
|
132
132
|
value: function _calculateArea(positions) {
|
|
133
133
|
var _this2 = this;
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var config =
|
|
138
|
-
var positionsC3 = positions.map(function (
|
|
139
|
-
return
|
|
134
|
+
if (positions.length < 4) {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
var config = this.getMeasureConfig(this._config);
|
|
138
|
+
var positionsC3 = positions.map(function (item) {
|
|
139
|
+
return _this2.toCartesian3(item);
|
|
140
140
|
});
|
|
141
141
|
if (config.clampToGround) {
|
|
142
|
-
|
|
143
|
-
return
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
var windowPositions = positions.map(function (item) {
|
|
143
|
+
return _this2.toWindowPosition(item);
|
|
144
|
+
});
|
|
145
|
+
if (windowPositions.some(function (item) {
|
|
146
|
+
return !item;
|
|
147
|
+
})) {
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
return utils.calculateSurfaceArea(this.getMap(), windowPositions, config.splitNum);
|
|
147
151
|
}
|
|
148
|
-
return
|
|
152
|
+
return utils.getArea(this.getMap(), positionsC3);
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
// 绘制area label
|
|
@@ -167,8 +171,36 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
167
171
|
}, {
|
|
168
172
|
key: "_destroyAreaLabel",
|
|
169
173
|
value: function _destroyAreaLabel() {
|
|
170
|
-
this._areaLayer
|
|
171
|
-
|
|
174
|
+
this._areaLayer = this.destroyLabelLayer(this._areaLayer);
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "_updateArea",
|
|
178
|
+
value: function _updateArea(positions) {
|
|
179
|
+
if (positions.length < 3) {
|
|
180
|
+
this._area = 0;
|
|
181
|
+
this._destroyAreaLabel();
|
|
182
|
+
return {
|
|
183
|
+
area: 0
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
var polygonPositions = this._toPolygonPositions(positions);
|
|
187
|
+
this._area = this._calculateArea(polygonPositions);
|
|
188
|
+
var center = centerOfMass(polygon([polygonPositions]));
|
|
189
|
+
var _center$geometry$coor = _slicedToArray(center.geometry.coordinates, 2),
|
|
190
|
+
lng = _center$geometry$coor[0],
|
|
191
|
+
lat = _center$geometry$coor[1];
|
|
192
|
+
this._createAreaLabel([lng, lat, 0], "\u9762\u79EF".concat(utils.formatArea(this._area)));
|
|
193
|
+
return {
|
|
194
|
+
area: this._area
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "_toPolygonPositions",
|
|
199
|
+
value: function _toPolygonPositions(positions) {
|
|
200
|
+
if (positions.length < 3) {
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
return [].concat(_toConsumableArray(positions), [positions[0]]);
|
|
172
204
|
}
|
|
173
205
|
|
|
174
206
|
// 销毁
|
|
@@ -176,11 +208,11 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
176
208
|
key: "destroy",
|
|
177
209
|
value: function destroy() {
|
|
178
210
|
if (!this._canOperate()) return;
|
|
179
|
-
|
|
180
|
-
this.
|
|
211
|
+
var layer = this._instance;
|
|
212
|
+
this._destroyAreaLabel();
|
|
181
213
|
this._instance = null;
|
|
182
|
-
|
|
183
|
-
this.
|
|
214
|
+
_get(_getPrototypeOf(Area.prototype), "destroy", this).call(this);
|
|
215
|
+
layer && this._drawer.removeDrawerLayer(layer);
|
|
184
216
|
}
|
|
185
217
|
}]);
|
|
186
218
|
return Area;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="../typings.d.ts" />
|
|
2
|
+
import { type Cartesian2, type Cartesian3 } from 'deeptwins-cesium';
|
|
3
|
+
import { MeasureContext, MeasureDrawConfig, MeasureLabelLayer, MeasureMap, MeasurePosition, ResolvedMeasureConfig } from './types';
|
|
2
4
|
declare class BaseDraw {
|
|
3
5
|
_measureContext: MeasureContext;
|
|
4
6
|
id: string;
|
|
5
|
-
_drawer:
|
|
7
|
+
_drawer: MeasureContext['drawer'];
|
|
6
8
|
isDestroyed: boolean;
|
|
7
9
|
constructor(measureContext: MeasureContext);
|
|
8
10
|
_canOperate(): boolean;
|
|
9
|
-
getMap():
|
|
10
|
-
createLabelLayer(position:
|
|
11
|
+
getMap(): MeasureMap;
|
|
12
|
+
createLabelLayer(position: MeasurePosition, text: string, style?: Record<string, any>): MeasureLabelLayer;
|
|
13
|
+
protected getMeasureConfig(config?: MeasureDrawConfig): ResolvedMeasureConfig;
|
|
14
|
+
protected toCartesian3(position: MeasurePosition): Cartesian3;
|
|
15
|
+
protected toWindowPosition(position: MeasurePosition): Cartesian2 | undefined;
|
|
16
|
+
protected destroyLabelLayer<T extends MeasureLabelLayer | null | undefined>(layer: T): null;
|
|
11
17
|
destroy(): void;
|
|
12
18
|
}
|
|
13
19
|
export default BaseDraw;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -9,9 +15,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
9
15
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
16
|
import { point } from '@turf/turf';
|
|
11
17
|
import * as Cesium from 'deeptwins-cesium';
|
|
18
|
+
import { SceneTransforms } from 'deeptwins-cesium';
|
|
12
19
|
import { v4 as uuidV4 } from 'uuid';
|
|
13
20
|
import PositionProperty from "../property/PositionProperty";
|
|
14
|
-
import { error } from "../tool/utils";
|
|
21
|
+
import { error, lngLatAltToCartesian3 } from "../tool/utils";
|
|
15
22
|
var BaseDraw = /*#__PURE__*/function () {
|
|
16
23
|
function BaseDraw(measureContext) {
|
|
17
24
|
_classCallCheck(this, BaseDraw);
|
|
@@ -37,7 +44,7 @@ var BaseDraw = /*#__PURE__*/function () {
|
|
|
37
44
|
}, {
|
|
38
45
|
key: "getMap",
|
|
39
46
|
value: function getMap() {
|
|
40
|
-
return this._measureContext
|
|
47
|
+
return this._measureContext.getMap();
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
// 创建label图层
|
|
@@ -58,6 +65,34 @@ var BaseDraw = /*#__PURE__*/function () {
|
|
|
58
65
|
positionProperty: new PositionProperty()
|
|
59
66
|
});
|
|
60
67
|
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "getMeasureConfig",
|
|
70
|
+
value: function getMeasureConfig() {
|
|
71
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
72
|
+
return _objectSpread(_objectSpread({}, this._measureContext.options), config);
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "toCartesian3",
|
|
76
|
+
value: function toCartesian3(position) {
|
|
77
|
+
var _position = _slicedToArray(position, 3),
|
|
78
|
+
lng = _position[0],
|
|
79
|
+
lat = _position[1],
|
|
80
|
+
_position$ = _position[2],
|
|
81
|
+
alt = _position$ === void 0 ? 0 : _position$;
|
|
82
|
+
return lngLatAltToCartesian3(lng, lat, alt);
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "toWindowPosition",
|
|
86
|
+
value: function toWindowPosition(position) {
|
|
87
|
+
var _SceneTransforms$worl;
|
|
88
|
+
return (_SceneTransforms$worl = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, this.toCartesian3(position))) !== null && _SceneTransforms$worl !== void 0 ? _SceneTransforms$worl : undefined;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "destroyLabelLayer",
|
|
92
|
+
value: function destroyLabelLayer(layer) {
|
|
93
|
+
layer === null || layer === void 0 || layer.destroy();
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
61
96
|
}, {
|
|
62
97
|
key: "destroy",
|
|
63
98
|
value: function destroy() {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import BaseDraw from './BaseDraw';
|
|
2
|
-
import { MeasureContext } from './
|
|
3
|
-
declare class Distance extends BaseDraw {
|
|
4
|
-
private readonly _type;
|
|
2
|
+
import { DistanceMeasureResult, MeasureContext, MeasureDrawConfig, MeasureLayer, MeasurePosition, MeasureShapeLayer } from './types';
|
|
3
|
+
declare class Distance extends BaseDraw implements MeasureLayer {
|
|
5
4
|
private _config;
|
|
6
|
-
|
|
5
|
+
_instance: MeasureShapeLayer | null;
|
|
7
6
|
private _measureCache;
|
|
8
7
|
private _mouseLabelLayer;
|
|
9
|
-
constructor(measureContext: MeasureContext, config
|
|
8
|
+
constructor(measureContext: MeasureContext, config?: MeasureDrawConfig);
|
|
10
9
|
private _init;
|
|
11
|
-
drawing(positions:
|
|
12
|
-
pointsChange(layer:
|
|
13
|
-
drawEnd():
|
|
10
|
+
drawing(positions: MeasurePosition[]): {} | undefined;
|
|
11
|
+
pointsChange(layer: MeasureShapeLayer, positions: MeasurePosition[]): DistanceMeasureResult;
|
|
12
|
+
drawEnd(): DistanceMeasureResult;
|
|
14
13
|
startEdit(): void;
|
|
15
|
-
endEdit():
|
|
14
|
+
endEdit(): DistanceMeasureResult;
|
|
16
15
|
private _createMouseMoveLabel;
|
|
17
16
|
private _destroyMouseMoveLabel;
|
|
18
17
|
private _calculateDistance;
|
|
19
18
|
private _calculateMouseDistance;
|
|
19
|
+
private _calculateSegmentDistance;
|
|
20
20
|
private _createMeasureCacheText;
|
|
21
21
|
destroy(): void;
|
|
22
22
|
}
|