@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29

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.
Files changed (191) hide show
  1. package/README.md +9 -3
  2. package/build/postinstall.js +13 -2
  3. package/index.d.ts +155 -106
  4. package/package.json +9 -4
  5. package/src/category/category.js +71 -32
  6. package/src/category/categoryCollection.js +27 -18
  7. package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
  8. package/src/cesium/entity.js +3 -1
  9. package/src/cesium/wallpaperMaterial.js +4 -2
  10. package/src/classRegistry.js +11 -4
  11. package/src/featureProvider/abstractFeatureProvider.js +43 -22
  12. package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
  13. package/src/featureProvider/wmsFeatureProvider.js +37 -15
  14. package/src/interaction/abstractInteraction.js +5 -1
  15. package/src/interaction/coordinateAtPixel.js +34 -12
  16. package/src/interaction/eventHandler.js +63 -23
  17. package/src/interaction/featureAtPixelInteraction.js +96 -32
  18. package/src/interaction/featureProviderInteraction.js +23 -8
  19. package/src/interaction/interactionChain.js +19 -9
  20. package/src/interaction/interactionType.js +23 -26
  21. package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
  22. package/src/layer/cesium/clusterContext.js +10 -3
  23. package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
  24. package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
  25. package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
  26. package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
  27. package/src/layer/cesium/terrainCesiumImpl.js +3 -2
  28. package/src/layer/cesium/tmsCesiumImpl.js +15 -3
  29. package/src/layer/cesium/vectorCesiumImpl.js +69 -25
  30. package/src/layer/cesium/vectorContext.js +25 -5
  31. package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
  32. package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
  33. package/src/layer/cesium/wmsCesiumImpl.js +15 -3
  34. package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
  35. package/src/layer/cesium/x3dmHelper.js +4 -1
  36. package/src/layer/cesiumTilesetLayer.js +55 -26
  37. package/src/layer/czmlLayer.js +11 -5
  38. package/src/layer/dataSourceLayer.js +25 -17
  39. package/src/layer/featureLayer.js +33 -18
  40. package/src/layer/featureStoreLayer.js +161 -99
  41. package/src/layer/featureStoreLayerChanges.js +57 -17
  42. package/src/layer/featureVisibility.js +89 -59
  43. package/src/layer/geojsonHelpers.js +70 -29
  44. package/src/layer/geojsonLayer.js +17 -11
  45. package/src/layer/globalHider.js +14 -4
  46. package/src/layer/layer.js +77 -44
  47. package/src/layer/layerImplementation.js +12 -4
  48. package/src/layer/oblique/layerObliqueImpl.js +3 -1
  49. package/src/layer/oblique/obliqueHelpers.js +75 -30
  50. package/src/layer/oblique/vectorObliqueImpl.js +175 -69
  51. package/src/layer/openStreetMapLayer.js +34 -20
  52. package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
  53. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
  54. package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
  55. package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
  56. package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
  57. package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
  58. package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
  59. package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
  60. package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
  61. package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
  62. package/src/layer/pointCloudLayer.js +21 -10
  63. package/src/layer/rasterLayer.js +73 -22
  64. package/src/layer/singleImageLayer.js +10 -7
  65. package/src/layer/terrainHelpers.js +30 -19
  66. package/src/layer/terrainLayer.js +16 -7
  67. package/src/layer/tileLoadedHelper.js +9 -4
  68. package/src/layer/tileProvider/mvtTileProvider.js +10 -4
  69. package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
  70. package/src/layer/tileProvider/tileProvider.js +163 -87
  71. package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
  72. package/src/layer/tmsLayer.js +7 -6
  73. package/src/layer/vectorHelpers.js +34 -25
  74. package/src/layer/vectorLayer.js +77 -36
  75. package/src/layer/vectorProperties.js +245 -74
  76. package/src/layer/vectorSymbols.js +3 -1
  77. package/src/layer/vectorTileLayer.js +121 -70
  78. package/src/layer/wfsLayer.js +19 -8
  79. package/src/layer/wmsHelpers.js +11 -6
  80. package/src/layer/wmsLayer.js +36 -14
  81. package/src/layer/wmtsLayer.js +35 -20
  82. package/src/map/baseOLMap.js +57 -31
  83. package/src/map/cameraLimiter.js +67 -18
  84. package/src/map/cesiumMap.js +307 -95
  85. package/src/map/obliqueMap.js +84 -34
  86. package/src/map/openlayersMap.js +40 -19
  87. package/src/map/vcsMap.js +21 -8
  88. package/src/oblique/helpers.js +212 -64
  89. package/src/oblique/obliqueCollection.js +111 -48
  90. package/src/oblique/obliqueDataSet.js +53 -21
  91. package/src/oblique/obliqueImage.js +50 -17
  92. package/src/oblique/obliqueImageMeta.js +7 -6
  93. package/src/oblique/obliqueProvider.js +75 -27
  94. package/src/oblique/obliqueView.js +18 -7
  95. package/src/oblique/obliqueViewDirection.js +3 -2
  96. package/src/oblique/parseImageJson.js +57 -23
  97. package/src/ol/feature.js +8 -3
  98. package/src/ol/geom/circle.js +12 -3
  99. package/src/ol/geom/geometryCollection.js +11 -4
  100. package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
  101. package/src/overrideClassRegistry.js +13 -3
  102. package/src/style/arcStyle.js +129 -36
  103. package/src/style/arrowStyle.js +57 -22
  104. package/src/style/declarativeStyleItem.js +107 -62
  105. package/src/style/shapesCategory.js +8 -6
  106. package/src/style/styleFactory.js +4 -1
  107. package/src/style/styleHelpers.js +17 -8
  108. package/src/style/styleItem.js +28 -10
  109. package/src/style/vectorStyleItem.js +160 -74
  110. package/src/style/writeStyle.js +5 -7
  111. package/src/util/clipping/clippingObject.js +72 -38
  112. package/src/util/clipping/clippingObjectManager.js +53 -19
  113. package/src/util/clipping/clippingPlaneHelper.js +120 -53
  114. package/src/util/collection.js +12 -6
  115. package/src/util/editor/createFeatureSession.js +21 -6
  116. package/src/util/editor/editFeaturesSession.js +41 -15
  117. package/src/util/editor/editGeometrySession.js +55 -30
  118. package/src/util/editor/editorHelpers.js +114 -29
  119. package/src/util/editor/editorSessionHelpers.js +8 -3
  120. package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
  121. package/src/util/editor/interactions/createCircleInteraction.js +7 -2
  122. package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
  123. package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
  124. package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
  125. package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
  126. package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
  127. package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
  128. package/src/util/editor/interactions/mapInteractionController.js +31 -14
  129. package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
  130. package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
  131. package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
  132. package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
  133. package/src/util/editor/selectFeaturesSession.js +37 -21
  134. package/src/util/editor/transformation/create2DHandlers.js +82 -37
  135. package/src/util/editor/transformation/create3DHandlers.js +187 -84
  136. package/src/util/editor/transformation/extrudeInteraction.js +20 -5
  137. package/src/util/editor/transformation/rotateInteraction.js +29 -16
  138. package/src/util/editor/transformation/scaleInteraction.js +31 -15
  139. package/src/util/editor/transformation/transformationHandler.js +23 -8
  140. package/src/util/editor/transformation/transformationTypes.js +8 -4
  141. package/src/util/editor/transformation/translateInteraction.js +86 -32
  142. package/src/util/editor/validateGeoemetry.js +3 -1
  143. package/src/util/exclusiveManager.js +6 -3
  144. package/src/util/extent.js +20 -10
  145. package/src/util/featureconverter/arcToCesium.js +46 -12
  146. package/src/util/featureconverter/circleToCesium.js +61 -27
  147. package/src/util/featureconverter/convert.js +85 -13
  148. package/src/util/featureconverter/extent3D.js +69 -28
  149. package/src/util/featureconverter/featureconverterHelper.js +232 -79
  150. package/src/util/featureconverter/lineStringToCesium.js +107 -35
  151. package/src/util/featureconverter/pointHelpers.js +117 -45
  152. package/src/util/featureconverter/pointToCesium.js +128 -31
  153. package/src/util/featureconverter/polygonToCesium.js +50 -16
  154. package/src/util/fetch.js +3 -1
  155. package/src/util/geometryHelpers.js +15 -10
  156. package/src/util/indexedCollection.js +7 -3
  157. package/src/util/isMobile.js +8 -2
  158. package/src/util/layerCollection.js +28 -12
  159. package/src/util/mapCollection.js +37 -18
  160. package/src/util/math.js +35 -19
  161. package/src/util/overrideCollection.js +57 -32
  162. package/src/util/projection.js +21 -5
  163. package/src/util/urlHelpers.js +5 -3
  164. package/src/util/viewpoint.js +66 -33
  165. package/src/vcsApp.js +133 -69
  166. package/src/vcsModule.js +3 -2
  167. package/src/vcsModuleHelpers.js +24 -9
  168. package/src/vcsObject.js +3 -2
  169. package/tests/data/dynamicPointCzml.json +24 -35
  170. package/tests/data/oblique/imageData/imagev34.json +56 -272
  171. package/tests/data/oblique/imageData/imagev35.json +272 -19
  172. package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
  173. package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
  174. package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
  175. package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
  176. package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
  177. package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
  178. package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
  179. package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
  180. package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
  181. package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
  182. package/tests/data/oblique/tiledImageData/image.json +70 -1
  183. package/tests/data/terrain/layer.json +121 -130
  184. package/tests/data/testGeoJSON.json +4 -16
  185. package/tests/unit/helpers/cesiumHelpers.js +58 -33
  186. package/tests/unit/helpers/helpers.js +10 -2
  187. package/tests/unit/helpers/imageHelpers.js +8 -4
  188. package/tests/unit/helpers/obliqueData.js +39 -13
  189. package/tests/unit/helpers/obliqueHelpers.js +12 -9
  190. package/tests/unit/helpers/openlayersHelpers.js +4 -1
  191. package/tests/unit/helpers/terrain/terrainData.js +8 -7
@@ -4,7 +4,8 @@ import {
4
4
  WallOutlineGeometry,
5
5
  GroundPolylineGeometry,
6
6
  PolylineGeometry,
7
- Math as CesiumMath, HeightReference,
7
+ Math as CesiumMath,
8
+ HeightReference,
8
9
  } from '@vcmap-cesium/engine';
9
10
  import { Feature } from 'ol';
10
11
  import { Point } from 'ol/geom.js';
@@ -31,12 +32,15 @@ import { getPrimitiveOptions } from './pointHelpers.js';
31
32
  * @returns {ArrowOptions}
32
33
  */
33
34
  function getArrowOptions(from, to, heightReference) {
34
- let pitch = heightReference === HeightReference.NONE ? getCartesianPitch(to, from) : 0;
35
+ let pitch =
36
+ heightReference === HeightReference.NONE ? getCartesianPitch(to, from) : 0;
35
37
  pitch += 90;
36
38
  return {
37
39
  location: to,
38
40
  pitch,
39
- heading: CesiumMath.toDegrees(getCartesianBearing(from, to) + CesiumMath.PI_OVER_TWO),
41
+ heading: CesiumMath.toDegrees(
42
+ getCartesianBearing(from, to) + CesiumMath.PI_OVER_TWO,
43
+ ),
40
44
  };
41
45
  }
42
46
 
@@ -50,7 +54,13 @@ function getArrowOptions(from, to, heightReference) {
50
54
  * @param {import("@vcmap/core").VectorContext|import("@vcmap/core").ClusterContext} context
51
55
  */
52
56
  export function addArrowsToContext(
53
- feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context,
57
+ feature,
58
+ style,
59
+ validGeometries,
60
+ vectorProperties,
61
+ scene,
62
+ lineGeometryFactory,
63
+ context,
54
64
  ) {
55
65
  if (style.end === ArrowEnd.NONE || !style.primitiveOptions?.geometryOptions) {
56
66
  return;
@@ -60,11 +70,19 @@ export function addArrowsToContext(
60
70
  validGeometries.forEach((geom) => {
61
71
  const coordinates = lineGeometryFactory.getCoordinates([geom]);
62
72
  if (style.end === ArrowEnd.START || style.end === ArrowEnd.BOTH) {
63
- arrowOptions.push(getArrowOptions(coordinates[1], coordinates[0], heightReference));
73
+ arrowOptions.push(
74
+ getArrowOptions(coordinates[1], coordinates[0], heightReference),
75
+ );
64
76
  }
65
77
 
66
78
  if (style.end === ArrowEnd.END || style.end === ArrowEnd.BOTH) {
67
- arrowOptions.push(getArrowOptions(coordinates.at(-2), coordinates.at(-1), heightReference));
79
+ arrowOptions.push(
80
+ getArrowOptions(
81
+ coordinates.at(-2),
82
+ coordinates.at(-1),
83
+ heightReference,
84
+ ),
85
+ );
68
86
  }
69
87
  });
70
88
 
@@ -86,7 +104,11 @@ export function addArrowsToContext(
86
104
  });
87
105
 
88
106
  const wgs84Position = Projection.mercatorToWgs84(arrowOption.location);
89
- const cartesianLocation = Cartesian3.fromDegrees(wgs84Position[0], wgs84Position[1], wgs84Position[2]);
107
+ const cartesianLocation = Cartesian3.fromDegrees(
108
+ wgs84Position[0],
109
+ wgs84Position[1],
110
+ wgs84Position[2],
111
+ );
90
112
  const primitiveOptions = getPrimitiveOptions(
91
113
  arrowFeature,
92
114
  usedStyle,
@@ -97,7 +119,11 @@ export function addArrowsToContext(
97
119
  );
98
120
 
99
121
  if (primitiveOptions.primitives) {
100
- context.addScaledPrimitives(primitiveOptions.primitives, feature, allowPicking);
122
+ context.addScaledPrimitives(
123
+ primitiveOptions.primitives,
124
+ feature,
125
+ allowPicking,
126
+ );
101
127
  }
102
128
  });
103
129
  }
@@ -110,12 +136,19 @@ export function addArrowsToContext(
110
136
  * @returns {Array<import("@vcmap-cesium/engine").WallGeometry>}
111
137
  * @private
112
138
  */
113
- export function createSolidGeometries(options, height, perPositionHeight, extrudedHeight) {
114
- return [WallGeometry.fromConstantHeights({
115
- ...options,
116
- maximumHeight: !perPositionHeight ? height : undefined,
117
- minimumHeight: extrudedHeight,
118
- })];
139
+ export function createSolidGeometries(
140
+ options,
141
+ height,
142
+ perPositionHeight,
143
+ extrudedHeight,
144
+ ) {
145
+ return [
146
+ WallGeometry.fromConstantHeights({
147
+ ...options,
148
+ maximumHeight: !perPositionHeight ? height : undefined,
149
+ minimumHeight: extrudedHeight,
150
+ }),
151
+ ];
119
152
  }
120
153
 
121
154
  /**
@@ -126,14 +159,21 @@ export function createSolidGeometries(options, height, perPositionHeight, extrud
126
159
  * @returns {Array<import("@vcmap-cesium/engine").WallOutlineGeometry>}
127
160
  * @private
128
161
  */
129
- export function createOutlineGeometries(options, height, perPositionHeight, extrudedHeight) {
162
+ export function createOutlineGeometries(
163
+ options,
164
+ height,
165
+ perPositionHeight,
166
+ extrudedHeight,
167
+ ) {
130
168
  // maxium and minimum are flipped, to create the same perPositionHeight behaviour as in polygons
131
169
  // WallGeometries extrudes down instead of up, so we switch the behaviour and extrude in the other direction
132
- return [WallOutlineGeometry.fromConstantHeights({
133
- ...options,
134
- maximumHeight: !perPositionHeight ? height : undefined,
135
- minimumHeight: extrudedHeight,
136
- })];
170
+ return [
171
+ WallOutlineGeometry.fromConstantHeights({
172
+ ...options,
173
+ maximumHeight: !perPositionHeight ? height : undefined,
174
+ minimumHeight: extrudedHeight,
175
+ }),
176
+ ];
137
177
  }
138
178
 
139
179
  /**
@@ -148,7 +188,6 @@ export function createFillGeometries(options, height, perPositionHeight) {
148
188
  return [];
149
189
  }
150
190
 
151
-
152
191
  /**
153
192
  * @param {Object} options
154
193
  * @param {import("ol/style/Style").default} style
@@ -157,10 +196,12 @@ export function createFillGeometries(options, height, perPositionHeight) {
157
196
  */
158
197
  export function createGroundLineGeometries(options, style) {
159
198
  const width = parseNumber(style.getStroke().getWidth(), 1.0);
160
- return [new GroundPolylineGeometry({
161
- ...options,
162
- width,
163
- })];
199
+ return [
200
+ new GroundPolylineGeometry({
201
+ ...options,
202
+ width,
203
+ }),
204
+ ];
164
205
  }
165
206
 
166
207
  /**
@@ -171,10 +212,12 @@ export function createGroundLineGeometries(options, style) {
171
212
  */
172
213
  export function createLineGeometries(options, style) {
173
214
  const width = parseNumber(style.getStroke().getWidth(), 1.0);
174
- return [new PolylineGeometry({
175
- ...options,
176
- width,
177
- })];
215
+ return [
216
+ new PolylineGeometry({
217
+ ...options,
218
+ width,
219
+ }),
220
+ ];
178
221
  }
179
222
 
180
223
  /**
@@ -191,7 +234,11 @@ export function getGeometryOptions(geometry, positionHeightAdjustment) {
191
234
  if (wgs84Coords[2] != null) {
192
235
  wgs84Coords[2] += positionHeightAdjustment;
193
236
  }
194
- return Cartesian3.fromDegrees(wgs84Coords[0], wgs84Coords[1], wgs84Coords[2]);
237
+ return Cartesian3.fromDegrees(
238
+ wgs84Coords[0],
239
+ wgs84Coords[1],
240
+ wgs84Coords[2],
241
+ );
195
242
  });
196
243
  return { positions };
197
244
  }
@@ -244,7 +291,7 @@ export function validateLineString(lineString) {
244
291
  const flatCoordinates = lineString.getFlatCoordinates();
245
292
  const minimumValues = lineString.getStride() * 2;
246
293
  if (flatCoordinates && flatCoordinates.length >= minimumValues) {
247
- return flatCoordinates.every(value => Number.isFinite(value));
294
+ return flatCoordinates.every((value) => Number.isFinite(value));
248
295
  }
249
296
  return false;
250
297
  }
@@ -258,14 +305,39 @@ export function validateLineString(lineString) {
258
305
  * @param {import("@vcmap-cesium/engine").Scene} scene
259
306
  * @param {import("@vcmap/core").VectorContext|import("@vcmap/core").ClusterContext} context
260
307
  */
261
- export default function lineStringToCesium(feature, style, geometries, vectorProperties, scene, context) {
308
+ export default function lineStringToCesium(
309
+ feature,
310
+ style,
311
+ geometries,
312
+ vectorProperties,
313
+ scene,
314
+ context,
315
+ ) {
262
316
  if (!style.getFill() && !style.getStroke()) {
263
317
  return;
264
318
  }
265
319
  const lineGeometryFactory = getGeometryFactory();
266
- const validGeometries = geometries.filter(lineString => validateLineString(lineString));
267
- addPrimitivesToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context);
320
+ const validGeometries = geometries.filter((lineString) =>
321
+ validateLineString(lineString),
322
+ );
323
+ addPrimitivesToContext(
324
+ feature,
325
+ style,
326
+ validGeometries,
327
+ vectorProperties,
328
+ scene,
329
+ lineGeometryFactory,
330
+ context,
331
+ );
268
332
  if (style instanceof ArrowStyle) {
269
- addArrowsToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context);
333
+ addArrowsToContext(
334
+ feature,
335
+ style,
336
+ validGeometries,
337
+ vectorProperties,
338
+ scene,
339
+ lineGeometryFactory,
340
+ context,
341
+ );
270
342
  }
271
343
  }
@@ -2,15 +2,22 @@ import {
2
2
  BoxGeometry,
3
3
  BoxOutlineGeometry,
4
4
  Cartesian3,
5
- Cartographic, Color, ColorGeometryInstanceAttribute,
5
+ Cartographic,
6
+ Color,
7
+ ColorGeometryInstanceAttribute,
6
8
  CylinderGeometry,
7
9
  CylinderOutlineGeometry,
8
10
  EllipsoidGeometry,
9
- EllipsoidOutlineGeometry, GeometryInstance,
10
- HeadingPitchRoll, Material, MaterialAppearance,
11
+ EllipsoidOutlineGeometry,
12
+ GeometryInstance,
13
+ HeadingPitchRoll,
14
+ Material,
15
+ MaterialAppearance,
11
16
  Matrix4,
12
17
  Model,
13
- ModelAnimationLoop, PerInstanceColorAppearance, Primitive,
18
+ ModelAnimationLoop,
19
+ PerInstanceColorAppearance,
20
+ Primitive,
14
21
  sampleTerrainMostDetailed,
15
22
  SphereGeometry,
16
23
  SphereOutlineGeometry,
@@ -33,7 +40,9 @@ function makeOffsetAutoScalePrimitive(primitive, transform, scale, offset) {
33
40
  const currentOffset = offset.clone();
34
41
 
35
42
  Object.defineProperty(primitive, 'modelMatrix', {
36
- get() { return modelMatrix; },
43
+ get() {
44
+ return modelMatrix;
45
+ },
37
46
  set(newModelMatrix) {
38
47
  const newScale = Matrix4.getScale(newModelMatrix, new Cartesian3());
39
48
  if (!newScale.equals(currentScale)) {
@@ -57,7 +66,9 @@ function makeScaledAutoScalePrimitive(primitive, scale) {
57
66
  let currentScale = scale.clone();
58
67
 
59
68
  Object.defineProperty(primitive, 'modelMatrix', {
60
- get() { return modelMatrix; },
69
+ get() {
70
+ return modelMatrix;
71
+ },
61
72
  set(newModelMatrix) {
62
73
  const newScale = Matrix4.getScale(newModelMatrix, new Cartesian3());
63
74
  if (!newScale.equals(currentScale)) {
@@ -78,18 +89,27 @@ function makeScaledAutoScalePrimitive(primitive, scale) {
78
89
  */
79
90
  async function placePrimitiveOnTerrain(primitive, position, scene, offset) {
80
91
  await sampleTerrainMostDetailed(
81
- /** @type {import("@vcmap-cesium/engine").CesiumTerrainProvider} */ (scene.globe.terrainProvider),
92
+ /** @type {import("@vcmap-cesium/engine").CesiumTerrainProvider} */ (
93
+ scene.globe.terrainProvider
94
+ ),
82
95
  [Cartographic.fromCartesian(position)],
83
96
  )
84
97
  .then(([cartoWithNewHeight]) => {
85
98
  if (!primitive.isDestroyed()) {
86
99
  const { modelMatrix } = primitive;
87
- const newPosition = Cartographic.toCartesian(cartoWithNewHeight, undefined, position);
100
+ const newPosition = Cartographic.toCartesian(
101
+ cartoWithNewHeight,
102
+ undefined,
103
+ position,
104
+ );
88
105
  if (offset) {
89
106
  Cartesian3.add(newPosition, offset, newPosition);
90
107
  }
91
- primitive.modelMatrix = Matrix4
92
- .setTranslation(modelMatrix, newPosition, modelMatrix);
108
+ primitive.modelMatrix = Matrix4.setTranslation(
109
+ modelMatrix,
110
+ newPosition,
111
+ modelMatrix,
112
+ );
93
113
  }
94
114
  })
95
115
  .catch(() => {});
@@ -103,13 +123,23 @@ async function placePrimitiveOnTerrain(primitive, position, scene, offset) {
103
123
  * @param {import("@vcmap-cesium/engine").Scene} scene
104
124
  * @returns {null|{ primitives: Array<import("@vcmap-cesium/engine").Model>, options: VectorPropertiesModelOptions }}
105
125
  */
106
- export function getModelOptions(feature, wgs84Positions, positions, vectorProperties, scene) {
126
+ export function getModelOptions(
127
+ feature,
128
+ wgs84Positions,
129
+ positions,
130
+ vectorProperties,
131
+ scene,
132
+ ) {
107
133
  const options = vectorProperties.getModel(feature);
108
134
  if (!options) {
109
135
  return null;
110
136
  }
111
137
  const scale = Cartesian3.fromArray(options.scale);
112
- const headingPitchRoll = HeadingPitchRoll.fromDegrees(options.heading, options.pitch, options.roll);
138
+ const headingPitchRoll = HeadingPitchRoll.fromDegrees(
139
+ options.heading,
140
+ options.pitch,
141
+ options.roll,
142
+ );
113
143
  const allowPicking = vectorProperties.getAllowPicking(feature);
114
144
  const primitives = positions.map((position, index) => {
115
145
  const modelMatrix = Matrix4.multiply(
@@ -159,35 +189,43 @@ function getGeometryInstanceFromOptions(options, color, outline) {
159
189
  const { type } = options;
160
190
  let geometry;
161
191
  if (type === PrimitiveOptionsType.CYLINDER) {
162
- geometry = outline ?
163
- new CylinderOutlineGeometry(options.geometryOptions) :
164
- new CylinderGeometry(options.geometryOptions);
192
+ geometry = outline
193
+ ? new CylinderOutlineGeometry(options.geometryOptions)
194
+ : new CylinderGeometry(options.geometryOptions);
165
195
  } else if (type === PrimitiveOptionsType.ELLIPSOID) {
166
196
  if (Array.isArray(options.geometryOptions.radii)) {
167
- options.geometryOptions.radii = Cartesian3.fromArray(options.geometryOptions.radii);
197
+ options.geometryOptions.radii = Cartesian3.fromArray(
198
+ options.geometryOptions.radii,
199
+ );
168
200
  }
169
201
  if (Array.isArray(options.geometryOptions.innerRadii)) {
170
- options.geometryOptions.innerRadii = Cartesian3.fromArray(options.geometryOptions.innerRadii);
202
+ options.geometryOptions.innerRadii = Cartesian3.fromArray(
203
+ options.geometryOptions.innerRadii,
204
+ );
171
205
  }
172
- geometry = outline ?
173
- new EllipsoidOutlineGeometry(options.geometryOptions) :
174
- new EllipsoidGeometry(options.geometryOptions);
206
+ geometry = outline
207
+ ? new EllipsoidOutlineGeometry(options.geometryOptions)
208
+ : new EllipsoidGeometry(options.geometryOptions);
175
209
  }
176
210
  if (type === PrimitiveOptionsType.SPHERE) {
177
- geometry = outline ?
178
- new SphereOutlineGeometry(options.geometryOptions) :
179
- new SphereGeometry(options.geometryOptions);
211
+ geometry = outline
212
+ ? new SphereOutlineGeometry(options.geometryOptions)
213
+ : new SphereGeometry(options.geometryOptions);
180
214
  }
181
215
  if (type === PrimitiveOptionsType.BOX) {
182
216
  if (Array.isArray(options.geometryOptions.minimum)) {
183
- options.geometryOptions.minimum = Cartesian3.fromArray(options.geometryOptions.minimum);
217
+ options.geometryOptions.minimum = Cartesian3.fromArray(
218
+ options.geometryOptions.minimum,
219
+ );
184
220
  }
185
221
  if (Array.isArray(options.geometryOptions.maximum)) {
186
- options.geometryOptions.maximum = Cartesian3.fromArray(options.geometryOptions.maximum);
222
+ options.geometryOptions.maximum = Cartesian3.fromArray(
223
+ options.geometryOptions.maximum,
224
+ );
187
225
  }
188
- geometry = outline ?
189
- new BoxOutlineGeometry(options.geometryOptions) :
190
- new BoxGeometry(options.geometryOptions);
226
+ geometry = outline
227
+ ? new BoxOutlineGeometry(options.geometryOptions)
228
+ : new BoxGeometry(options.geometryOptions);
191
229
  }
192
230
 
193
231
  if (geometry) {
@@ -210,7 +248,14 @@ function getGeometryInstanceFromOptions(options, color, outline) {
210
248
  * @param {import("@vcmap-cesium/engine").Scene} scene
211
249
  * @returns {null|{ primitives: Array<import("@vcmap-cesium/engine").Primitive>, options: VectorPropertiesPrimitive}}
212
250
  */
213
- export function getPrimitiveOptions(feature, style, wgs84Positions, positions, vectorProperties, scene) {
251
+ export function getPrimitiveOptions(
252
+ feature,
253
+ style,
254
+ wgs84Positions,
255
+ positions,
256
+ vectorProperties,
257
+ scene,
258
+ ) {
214
259
  const options = vectorProperties.getPrimitive(feature);
215
260
  if (!options) {
216
261
  return null;
@@ -222,7 +267,8 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
222
267
  if (imageStyle instanceof RegularShape) {
223
268
  fill = imageStyle.getFill();
224
269
  stroke = imageStyle.getStroke();
225
- } else if (imageStyle) { // XXX or should we only allow primitives with regular shapes defined as image?
270
+ } else if (imageStyle) {
271
+ // XXX or should we only allow primitives with regular shapes defined as image?
226
272
  fill = style.getFill();
227
273
  stroke = style.getStroke(); // XXX this makes it impossible to create an extruded un-stroked primitive with an icon in 2D or we add a new primitive option
228
274
  }
@@ -240,8 +286,11 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
240
286
  }
241
287
 
242
288
  const scale = Cartesian3.fromArray(options.scale);
243
- const headingPitchRoll = HeadingPitchRoll
244
- .fromDegrees(options.heading, options.pitch, options.roll);
289
+ const headingPitchRoll = HeadingPitchRoll.fromDegrees(
290
+ options.heading,
291
+ options.pitch,
292
+ options.roll,
293
+ );
245
294
  const allowPicking = vectorProperties.getAllowPicking(feature);
246
295
 
247
296
  const primitives = positions.flatMap((position, index) => {
@@ -255,7 +304,10 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
255
304
  geometryModelMatrix,
256
305
  );
257
306
  }
258
- const transform = Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll);
307
+ const transform = Transforms.headingPitchRollToFixedFrame(
308
+ position,
309
+ headingPitchRoll,
310
+ );
259
311
  const modelMatrix = Matrix4.multiply(
260
312
  transform,
261
313
  geometryModelMatrix,
@@ -264,7 +316,10 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
264
316
 
265
317
  let deptFail;
266
318
  if (options.primitiveOptions.depthFailColor) {
267
- const depthFailColor = getCesiumColor(options.primitiveOptions.depthFailColor, [255, 255, 255, 0.4]);
319
+ const depthFailColor = getCesiumColor(
320
+ options.primitiveOptions.depthFailColor,
321
+ [255, 255, 255, 0.4],
322
+ );
268
323
  deptFail = new MaterialAppearance({
269
324
  translucent: depthFailColor.alpha < 1,
270
325
  material: Material.fromType('Color', {
@@ -273,7 +328,11 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
273
328
  });
274
329
  }
275
330
 
276
- const createPrimitive = (translucent, geometryInstances, depthFailAppearance) => {
331
+ const createPrimitive = (
332
+ translucent,
333
+ geometryInstances,
334
+ depthFailAppearance,
335
+ ) => {
277
336
  const primitive = new Primitive({
278
337
  asynchronous: !feature[createSync],
279
338
  geometryInstances,
@@ -288,10 +347,15 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
288
347
  });
289
348
 
290
349
  if (!wgs84Positions[index][2]) {
291
- placePrimitiveOnTerrain(primitive, position, scene, offset)
292
- .then(() => {
293
- Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll, undefined, undefined, transform); // update transform for usage in offset auto scale
294
- });
350
+ placePrimitiveOnTerrain(primitive, position, scene, offset).then(() => {
351
+ Transforms.headingPitchRollToFixedFrame(
352
+ position,
353
+ headingPitchRoll,
354
+ undefined,
355
+ undefined,
356
+ transform,
357
+ ); // update transform for usage in offset auto scale
358
+ });
295
359
  }
296
360
 
297
361
  if (options.autoScale) {
@@ -308,7 +372,7 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
308
372
  if (fillColor) {
309
373
  fillAndOutline.push(
310
374
  createPrimitive(
311
- (fillColor.alpha < 1) || !!deptFail,
375
+ fillColor.alpha < 1 || !!deptFail,
312
376
  [getGeometryInstanceFromOptions(options.primitiveOptions, fillColor)],
313
377
  deptFail,
314
378
  ),
@@ -318,17 +382,25 @@ export function getPrimitiveOptions(feature, style, wgs84Positions, positions, v
318
382
  fillAndOutline.push(
319
383
  createPrimitive(
320
384
  true,
321
- [getGeometryInstanceFromOptions(options.primitiveOptions, transparent)],
385
+ [
386
+ getGeometryInstanceFromOptions(
387
+ options.primitiveOptions,
388
+ transparent,
389
+ ),
390
+ ],
322
391
  deptFail,
323
392
  ),
324
393
  );
325
394
  }
326
395
  if (strokeColor) {
327
396
  fillAndOutline.push(
328
- createPrimitive(
329
- (strokeColor.alpha < 1) || !!deptFail,
330
- [getGeometryInstanceFromOptions(options.primitiveOptions, strokeColor, true)],
331
- ),
397
+ createPrimitive(strokeColor.alpha < 1 || !!deptFail, [
398
+ getGeometryInstanceFromOptions(
399
+ options.primitiveOptions,
400
+ strokeColor,
401
+ true,
402
+ ),
403
+ ]),
332
404
  );
333
405
  }
334
406
  return fillAndOutline;