@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.
- package/README.md +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- 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,
|
|
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 =
|
|
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(
|
|
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,
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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(
|
|
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 [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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 [
|
|
161
|
-
|
|
162
|
-
|
|
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 [
|
|
175
|
-
|
|
176
|
-
|
|
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(
|
|
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(
|
|
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 =>
|
|
267
|
-
|
|
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(
|
|
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,
|
|
5
|
+
Cartographic,
|
|
6
|
+
Color,
|
|
7
|
+
ColorGeometryInstanceAttribute,
|
|
6
8
|
CylinderGeometry,
|
|
7
9
|
CylinderOutlineGeometry,
|
|
8
10
|
EllipsoidGeometry,
|
|
9
|
-
EllipsoidOutlineGeometry,
|
|
10
|
-
|
|
11
|
+
EllipsoidOutlineGeometry,
|
|
12
|
+
GeometryInstance,
|
|
13
|
+
HeadingPitchRoll,
|
|
14
|
+
Material,
|
|
15
|
+
MaterialAppearance,
|
|
11
16
|
Matrix4,
|
|
12
17
|
Model,
|
|
13
|
-
ModelAnimationLoop,
|
|
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() {
|
|
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() {
|
|
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} */ (
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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) {
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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 = (
|
|
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
|
-
.
|
|
293
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
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
|
-
(
|
|
330
|
-
|
|
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;
|