@vcmap/viewshed 2.0.1
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/CHANGELOG.md +4 -0
- package/LICENSE.md +13 -0
- package/README.md +4 -0
- package/dist/index.js +1423 -0
- package/package.json +75 -0
- package/src/ViewshedConfigEditor.vue +121 -0
- package/src/ViewshedWindow.vue +477 -0
- package/src/index.js +211 -0
- package/src/util/toolboxHelper.js +133 -0
- package/src/util/windowHelper.js +128 -0
- package/src/viewshed.js +578 -0
- package/src/viewshedCategory.js +216 -0
- package/src/viewshedInteraction.js +57 -0
- package/src/viewshedManager.js +416 -0
- package/src/viewshedPrimitive.js +101 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
ColorGeometryInstanceAttribute,
|
|
4
|
+
GeometryInstance,
|
|
5
|
+
Matrix4,
|
|
6
|
+
PerInstanceColorAppearance,
|
|
7
|
+
Primitive,
|
|
8
|
+
SphereGeometry,
|
|
9
|
+
SphereOutlineGeometry,
|
|
10
|
+
Transforms,
|
|
11
|
+
} from '@vcmap-cesium/engine';
|
|
12
|
+
import { VcsCameraPrimitive } from '@vcmap/core';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {import("@vcmap-cesium/engine").Color}
|
|
16
|
+
*/
|
|
17
|
+
const scratchColor = new Color();
|
|
18
|
+
/**
|
|
19
|
+
* @type {import("@vcmap-cesium/engine").Matrix4}
|
|
20
|
+
*/
|
|
21
|
+
const scratchMatrix = new Matrix4();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @class
|
|
25
|
+
* @extends VcsCameraPrimitive
|
|
26
|
+
*/
|
|
27
|
+
class ViewshedCameraPrimitive extends VcsCameraPrimitive {
|
|
28
|
+
constructor(options) {
|
|
29
|
+
super(options);
|
|
30
|
+
/** @type {boolean} */
|
|
31
|
+
this.spot = options.spot;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Updates the camera primitive.
|
|
36
|
+
* @param {unknown} frameState
|
|
37
|
+
*/
|
|
38
|
+
update(frameState) {
|
|
39
|
+
if (!this.show) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!this.spot) {
|
|
43
|
+
const planesPrimitives = this._planesPrimitives;
|
|
44
|
+
const outlinePrimitives = this._outlinePrimitives;
|
|
45
|
+
|
|
46
|
+
if (planesPrimitives.length === 0) {
|
|
47
|
+
Transforms.eastNorthUpToFixedFrame(
|
|
48
|
+
this._camera.positionWC,
|
|
49
|
+
undefined,
|
|
50
|
+
scratchMatrix,
|
|
51
|
+
);
|
|
52
|
+
planesPrimitives[0] = new Primitive({
|
|
53
|
+
allowPicking: this.allowPicking,
|
|
54
|
+
geometryInstances: new GeometryInstance({
|
|
55
|
+
geometry: new SphereGeometry({
|
|
56
|
+
radius: 2,
|
|
57
|
+
}),
|
|
58
|
+
attributes: {
|
|
59
|
+
color: ColorGeometryInstanceAttribute.fromColor(
|
|
60
|
+
Color.fromAlpha(this._color, 0.1, scratchColor),
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
modelMatrix: scratchMatrix,
|
|
64
|
+
}),
|
|
65
|
+
appearance: new PerInstanceColorAppearance({
|
|
66
|
+
translucent: true,
|
|
67
|
+
flat: true,
|
|
68
|
+
}),
|
|
69
|
+
asynchronous: false,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
outlinePrimitives[0] = new Primitive({
|
|
73
|
+
allowPicking: this.allowPicking,
|
|
74
|
+
geometryInstances: new GeometryInstance({
|
|
75
|
+
geometry: new SphereOutlineGeometry({
|
|
76
|
+
radius: 2,
|
|
77
|
+
}),
|
|
78
|
+
attributes: {
|
|
79
|
+
color: ColorGeometryInstanceAttribute.fromColor(this._color),
|
|
80
|
+
},
|
|
81
|
+
modelMatrix: scratchMatrix,
|
|
82
|
+
}),
|
|
83
|
+
appearance: new PerInstanceColorAppearance({
|
|
84
|
+
translucent: false,
|
|
85
|
+
flat: true,
|
|
86
|
+
}),
|
|
87
|
+
asynchronous: false,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const { length } = planesPrimitives;
|
|
91
|
+
for (let i = 0; i < length; ++i) {
|
|
92
|
+
outlinePrimitives[i].update(frameState);
|
|
93
|
+
planesPrimitives[i].update(frameState);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
super.update(frameState);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default ViewshedCameraPrimitive;
|