@vcmap/viewshed 2.0.2 → 2.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/viewshed",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Tool to simulate a \"viewer\" and their field of vision from a certain standpoint in the map. It allows the user to see which areas and buildings can or can't be seen from a specific standpoint, regarding different viewing distances, viewers' sizes and orientations.Th",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -1,7 +1,12 @@
1
1
  <template>
2
2
  <div>
3
3
  <div v-if="viewshedMode === ViewshedPluginModes.CREATE" class="px-2 py-1">
4
- {{ $t('viewshed.createDescription') }}
4
+ <template v-if="viewshedType === ViewshedTypes.CONE">
5
+ {{ $t('viewshed.createDescription') }}
6
+ </template>
7
+ <template v-else-if="viewshedType === ViewshedTypes.THREESIXTY">
8
+ {{ $t('viewshed.createThreeSixtyDescription') }}
9
+ </template>
5
10
  </div>
6
11
  <VcsFormSection
7
12
  v-else-if="
package/src/index.js CHANGED
@@ -163,9 +163,11 @@ export default function plugin(config) {
163
163
  move: 'Move viewpoint',
164
164
  createDescription:
165
165
  'Click the map twice. First click places the origin, second defines the distance and direction of the viewshed.',
166
+ createThreeSixtyDescription:
167
+ 'Click the map twice. First click places the origin, second defines the distance of the viewshed.',
166
168
  remove: 'Remove',
167
169
  editor: {
168
- general: 'General',
170
+ general: 'General Settings',
169
171
  visibleColor: 'Visible color',
170
172
  shadowColor: 'Shadow color',
171
173
  tools: 'Tools',
@@ -197,11 +199,13 @@ export default function plugin(config) {
197
199
  move: 'Viewpoint verschieben',
198
200
  createDescription:
199
201
  'Klicke zweimal in die Karte. Der erste Klick platziert den Ursprung, der zweite die Distanz und die Richtung des Viewsheds.',
202
+ createThreeSixtyDescription:
203
+ 'Klicke zweimal in die Karte. Der erste Klick platziert den Ursprung, der zweite die Distanz des Viewsheds.',
200
204
  remove: 'Entfernen',
201
205
  editor: {
202
- general: 'Generelles',
206
+ general: 'Allgemeine Einstellungen',
203
207
  visibleColor: 'Sichtbarer Bereich',
204
- shadowColor: 'Schatten Bereich',
208
+ shadowColor: 'Nicht sichtbarer Bereich',
205
209
  tools: 'Werkzeuge',
206
210
  },
207
211
  },
package/src/viewshed.js CHANGED
@@ -267,7 +267,6 @@ export default class Viewshed extends VcsObject {
267
267
  this.position[1],
268
268
  this.position[2] + value,
269
269
  );
270
- this._updateShadowMap();
271
270
  this._updatePrimitive();
272
271
  }
273
272
  }
@@ -289,7 +288,9 @@ export default class Viewshed extends VcsObject {
289
288
  value > Viewshed.MIN_DISTANCE ? value : Viewshed.MIN_DISTANCE;
290
289
  if (this._shadowCamera) {
291
290
  this._shadowCamera.frustum.far = this._frustumOptions.far;
292
- this._updateShadowMap();
291
+ if (this._viewshedType === ViewshedTypes.THREESIXTY) {
292
+ this._updateShadowMap();
293
+ }
293
294
  if (this._viewshedType === ViewshedTypes.CONE) {
294
295
  this._updatePrimitive();
295
296
  }
@@ -314,7 +315,6 @@ export default class Viewshed extends VcsObject {
314
315
  /** @type {import("@vcmap-cesium/engine").PerspectiveFrustum} */ (
315
316
  this._shadowCamera.frustum
316
317
  ).fov = value * CesiumMath.RADIANS_PER_DEGREE;
317
- this._updateShadowMap();
318
318
  if (this._viewshedType === ViewshedTypes.CONE) {
319
319
  this._updatePrimitive();
320
320
  }
@@ -452,8 +452,10 @@ export default class Viewshed extends VcsObject {
452
452
  this._updateShadowMap();
453
453
  this._updatePrimitive();
454
454
  this._shadowMapChangedListener =
455
- this._cesiumMap.shadowMapChanged.addEventListener(() => {
456
- this.deactivate();
455
+ this._cesiumMap.shadowMapChanged.addEventListener((newShadowMap) => {
456
+ if (this._shadowMap !== newShadowMap) {
457
+ this.deactivate();
458
+ }
457
459
  });
458
460
  }
459
461
  }
@@ -471,6 +473,7 @@ export default class Viewshed extends VcsObject {
471
473
  return;
472
474
  }
473
475
 
476
+ this._shadowMap?.destroy();
474
477
  // @ts-ignore
475
478
  this._shadowMap = new ShadowMap({
476
479
  // @ts-ignore
@@ -486,7 +489,6 @@ export default class Viewshed extends VcsObject {
486
489
  size: 2048,
487
490
  });
488
491
  this._shadowMap.viewshed = this._colors;
489
- this._scene.shadowMap = this._shadowMap;
490
492
  this._cesiumMap.setShadowMap(this._shadowMap);
491
493
  }
492
494