@vcmap/core 6.0.0-rc.4 → 6.0.0-rc.6
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/cesium.d.ts +11 -0
- package/dist/index.d.ts +23 -16
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +15 -2
- package/dist/src/layer/cesium/clusterContext.d.ts +8 -14
- package/dist/src/layer/cesium/clusterContext.js +62 -41
- package/dist/src/layer/cesium/clusterContext.js.map +1 -1
- package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +2 -3
- package/dist/src/layer/cesium/vectorCesiumImpl.js +16 -10
- package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorContext.d.ts +10 -53
- package/dist/src/layer/cesium/vectorContext.js +88 -172
- package/dist/src/layer/cesium/vectorContext.js.map +1 -1
- package/dist/src/layer/geojsonHelpers.d.ts +1 -1
- package/dist/src/layer/geojsonHelpers.js +5 -10
- package/dist/src/layer/geojsonHelpers.js.map +1 -1
- package/dist/src/layer/oblique/obliqueHelpers.js +6 -6
- package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +0 -37
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.d.ts +8 -3
- package/dist/src/layer/vectorProperties.js +30 -5
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/map/baseOLMap.js +1 -1
- package/dist/src/map/baseOLMap.js.map +1 -1
- package/dist/src/map/obliqueMap.d.ts +3 -0
- package/dist/src/map/obliqueMap.js +27 -6
- package/dist/src/map/obliqueMap.js.map +1 -1
- package/dist/src/map/vcsMap.d.ts +8 -0
- package/dist/src/map/vcsMap.js +11 -0
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/oblique/helpers.js +5 -5
- package/dist/src/oblique/helpers.js.map +1 -1
- package/dist/src/oblique/obliqueDataSet.js +4 -4
- package/dist/src/oblique/obliqueDataSet.js.map +1 -1
- package/dist/src/ol/geom/geometryCollection.js +19 -2
- package/dist/src/ol/geom/geometryCollection.js.map +1 -1
- package/dist/src/style/arcStyle.js +1 -0
- package/dist/src/style/arcStyle.js.map +1 -1
- package/dist/src/util/editor/createFeatureSession.d.ts +5 -1
- package/dist/src/util/editor/createFeatureSession.js +48 -4
- package/dist/src/util/editor/createFeatureSession.js.map +1 -1
- package/dist/src/util/editor/editFeaturesSession.d.ts +10 -4
- package/dist/src/util/editor/editFeaturesSession.js +74 -37
- package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
- package/dist/src/util/editor/editGeometrySession.d.ts +5 -1
- package/dist/src/util/editor/editGeometrySession.js +77 -55
- package/dist/src/util/editor/editGeometrySession.js.map +1 -1
- package/dist/src/util/editor/editorHelpers.d.ts +12 -6
- package/dist/src/util/editor/editorHelpers.js +47 -20
- package/dist/src/util/editor/editorHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSessionHelpers.d.ts +5 -0
- package/dist/src/util/editor/editorSessionHelpers.js +1 -0
- package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSymbols.d.ts +1 -1
- package/dist/src/util/editor/editorSymbols.js +1 -1
- package/dist/src/util/editor/editorSymbols.js.map +1 -1
- package/dist/src/util/editor/interactions/createBBoxInteraction.d.ts +1 -0
- package/dist/src/util/editor/interactions/createBBoxInteraction.js +20 -16
- package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createLineStringInteraction.js +3 -3
- package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPolygonInteraction.d.ts +4 -0
- package/dist/src/util/editor/interactions/createPolygonInteraction.js +9 -3
- package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/creationSnapping.d.ts +26 -0
- package/dist/src/util/editor/interactions/creationSnapping.js +139 -0
- package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +3 -2
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.d.ts +3 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.js +14 -6
- package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/layerSnapping.d.ts +19 -0
- package/dist/src/util/editor/interactions/layerSnapping.js +87 -0
- package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/translateVertexInteraction.js +2 -2
- package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/translationSnapping.d.ts +25 -0
- package/dist/src/util/editor/interactions/translationSnapping.js +179 -0
- package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -0
- package/dist/src/util/editor/snappingHelpers.d.ts +44 -0
- package/dist/src/util/editor/snappingHelpers.js +329 -0
- package/dist/src/util/editor/snappingHelpers.js.map +1 -0
- package/dist/src/util/editor/transformation/create2DHandlers.js +26 -26
- package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/create3DHandlers.js +65 -14
- package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/scaleInteraction.js +27 -5
- package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationHandler.js +56 -38
- package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationTypes.d.ts +2 -0
- package/dist/src/util/editor/transformation/transformationTypes.js +4 -0
- package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
- package/dist/src/util/featureconverter/arcToCesium.d.ts +5 -19
- package/dist/src/util/featureconverter/arcToCesium.js +15 -42
- package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/circleToCesium.d.ts +2 -27
- package/dist/src/util/featureconverter/circleToCesium.js +84 -63
- package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/clampedPrimitive.d.ts +2 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js +29 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -0
- package/dist/src/util/featureconverter/convert.d.ts +26 -7
- package/dist/src/util/featureconverter/convert.js +221 -44
- package/dist/src/util/featureconverter/convert.js.map +1 -1
- package/dist/src/util/featureconverter/extent3D.d.ts +4 -3
- package/dist/src/util/featureconverter/extent3D.js +4 -3
- package/dist/src/util/featureconverter/extent3D.js.map +1 -1
- package/dist/src/util/featureconverter/lineStringToCesium.d.ts +12 -27
- package/dist/src/util/featureconverter/lineStringToCesium.js +85 -107
- package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/pointHelpers.d.ts +8 -11
- package/dist/src/util/featureconverter/pointHelpers.js +134 -120
- package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
- package/dist/src/util/featureconverter/pointToCesium.d.ts +14 -17
- package/dist/src/util/featureconverter/pointToCesium.js +47 -96
- package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/polygonToCesium.d.ts +2 -26
- package/dist/src/util/featureconverter/polygonToCesium.js +62 -72
- package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/storeyHelpers.d.ts +17 -0
- package/dist/src/util/featureconverter/storeyHelpers.js +78 -0
- package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.d.ts +54 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js +278 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.d.ts +86 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js +242 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -0
- package/dist/src/util/geometryHelpers.d.ts +22 -1
- package/dist/src/util/geometryHelpers.js +65 -2
- package/dist/src/util/geometryHelpers.js.map +1 -1
- package/dist/src/util/mapCollection.js +8 -0
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/math.d.ts +6 -2
- package/dist/src/util/math.js +34 -12
- package/dist/src/util/math.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js +3 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/helpers.d.ts +2 -9
- package/dist/tests/unit/helpers/helpers.js +2 -8
- package/dist/tests/unit/helpers/helpers.js.map +1 -1
- package/index.ts +74 -35
- package/package.json +3 -3
- package/src/cesium/cesium.d.ts +11 -0
- package/src/layer/cesium/clusterContext.ts +82 -91
- package/src/layer/cesium/vectorCesiumImpl.ts +17 -11
- package/src/layer/cesium/vectorContext.ts +120 -348
- package/src/layer/geojsonHelpers.ts +9 -12
- package/src/layer/oblique/obliqueHelpers.ts +6 -6
- package/src/layer/vectorLayer.ts +0 -71
- package/src/layer/vectorProperties.ts +46 -9
- package/src/map/baseOLMap.ts +1 -1
- package/src/map/obliqueMap.ts +46 -6
- package/src/map/vcsMap.ts +20 -2
- package/src/oblique/helpers.ts +11 -5
- package/src/oblique/obliqueDataSet.ts +4 -4
- package/src/ol/geom/geometryCollection.js +21 -2
- package/src/ol/ol.d.ts +15 -2
- package/src/style/arcStyle.ts +1 -0
- package/src/util/editor/createFeatureSession.ts +64 -6
- package/src/util/editor/editFeaturesSession.ts +105 -39
- package/src/util/editor/editGeometrySession.ts +118 -75
- package/src/util/editor/editorHelpers.ts +78 -30
- package/src/util/editor/editorSessionHelpers.ts +7 -0
- package/src/util/editor/editorSymbols.ts +1 -1
- package/src/util/editor/interactions/createBBoxInteraction.ts +25 -16
- package/src/util/editor/interactions/createCircleInteraction.ts +1 -1
- package/src/util/editor/interactions/createLineStringInteraction.ts +9 -3
- package/src/util/editor/interactions/createPointInteraction.ts +1 -1
- package/src/util/editor/interactions/createPolygonInteraction.ts +16 -3
- package/src/util/editor/interactions/creationSnapping.ts +226 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +3 -2
- package/src/util/editor/interactions/insertVertexInteraction.ts +27 -7
- package/src/util/editor/interactions/layerSnapping.ts +136 -0
- package/src/util/editor/interactions/translateVertexInteraction.ts +8 -2
- package/src/util/editor/interactions/translationSnapping.ts +302 -0
- package/src/util/editor/snappingHelpers.ts +490 -0
- package/src/util/editor/transformation/create2DHandlers.ts +38 -26
- package/src/util/editor/transformation/create3DHandlers.ts +84 -22
- package/src/util/editor/transformation/scaleInteraction.ts +28 -5
- package/src/util/editor/transformation/transformationHandler.ts +72 -41
- package/src/util/editor/transformation/transformationTypes.ts +5 -0
- package/src/util/featureconverter/arcToCesium.ts +25 -95
- package/src/util/featureconverter/circleToCesium.ts +127 -113
- package/src/util/featureconverter/clampedPrimitive.ts +70 -0
- package/src/util/featureconverter/convert.ts +446 -114
- package/src/util/featureconverter/extent3D.ts +13 -6
- package/src/util/featureconverter/lineStringToCesium.ts +132 -179
- package/src/util/featureconverter/pointHelpers.ts +271 -214
- package/src/util/featureconverter/pointToCesium.ts +111 -175
- package/src/util/featureconverter/polygonToCesium.ts +98 -117
- package/src/util/featureconverter/storeyHelpers.ts +104 -0
- package/src/util/featureconverter/vectorGeometryFactory.ts +601 -0
- package/src/util/featureconverter/vectorHeightInfo.ts +393 -0
- package/src/util/geometryHelpers.ts +79 -5
- package/src/util/mapCollection.ts +8 -0
- package/src/util/math.ts +59 -12
- package/dist/src/util/featureconverter/featureconverterHelper.d.ts +0 -35
- package/dist/src/util/featureconverter/featureconverterHelper.js +0 -404
- package/dist/src/util/featureconverter/featureconverterHelper.js.map +0 -1
- package/src/util/featureconverter/featureconverterHelper.ts +0 -672
|
@@ -19,27 +19,31 @@ import {
|
|
|
19
19
|
ModelAnimationLoop,
|
|
20
20
|
PerInstanceColorAppearance,
|
|
21
21
|
Primitive,
|
|
22
|
-
sampleTerrainMostDetailed,
|
|
23
22
|
type Scene,
|
|
24
23
|
SphereGeometry,
|
|
25
24
|
SphereOutlineGeometry,
|
|
26
25
|
Transforms,
|
|
27
26
|
} from '@vcmap-cesium/engine';
|
|
28
27
|
import type { Feature } from 'ol/index.js';
|
|
29
|
-
import type { Coordinate } from 'ol/coordinate.js';
|
|
30
28
|
import { RegularShape, type Style } from 'ol/style.js';
|
|
31
29
|
import { asColorLike } from 'ol/colorlike.js';
|
|
30
|
+
import { Coordinate } from 'ol/coordinate.js';
|
|
32
31
|
import { createSync } from '../../layer/vectorSymbols.js';
|
|
33
32
|
import VectorProperties, {
|
|
34
33
|
PrimitiveOptionsType,
|
|
35
|
-
VectorPropertiesModelOptions,
|
|
36
34
|
vectorPropertiesOfType,
|
|
37
|
-
VectorPropertiesPrimitive,
|
|
38
35
|
VectorPropertiesPrimitiveOptions,
|
|
39
36
|
} from '../../layer/vectorProperties.js';
|
|
40
37
|
import { getCesiumColor } from '../../style/styleHelpers.js';
|
|
41
38
|
import ModelFill from '../../style/modelFill.js';
|
|
42
39
|
import { ColorType } from '../../style/vectorStyleItem.js';
|
|
40
|
+
import { wgs84ToCartographic } from '../math.js';
|
|
41
|
+
import { ConvertedItem } from './convert.js';
|
|
42
|
+
import {
|
|
43
|
+
isRelativeHeightReference,
|
|
44
|
+
RelativeHeightReference,
|
|
45
|
+
VectorHeightInfo,
|
|
46
|
+
} from './vectorHeightInfo.js';
|
|
43
47
|
|
|
44
48
|
function makeOffsetAutoScalePrimitive(
|
|
45
49
|
primitive: Primitive | Model,
|
|
@@ -91,47 +95,75 @@ function makeScaledAutoScalePrimitive(
|
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
const scratchUpdateHeightCartesian = new Cartesian3();
|
|
99
|
+
|
|
100
|
+
function makeClampedPrimitive(
|
|
95
101
|
primitive: Primitive | Model,
|
|
96
|
-
|
|
102
|
+
scale: Cartesian3,
|
|
103
|
+
headingPitchRoll: HeadingPitchRoll,
|
|
104
|
+
heightReference: HeightReference,
|
|
97
105
|
scene: Scene,
|
|
106
|
+
wgs84Coords: Coordinate,
|
|
98
107
|
offset?: Cartesian3,
|
|
99
|
-
):
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
): void {
|
|
109
|
+
const originCartographic = wgs84ToCartographic(wgs84Coords);
|
|
110
|
+
const updatePrimitiveHeight = (clampedPosition: Cartographic): void => {
|
|
111
|
+
clampedPosition.height += wgs84Coords[2];
|
|
112
|
+
Cartographic.toCartesian(
|
|
113
|
+
clampedPosition,
|
|
114
|
+
undefined,
|
|
115
|
+
scratchUpdateHeightCartesian,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const geometryModelMatrix = Matrix4.fromScale(scale);
|
|
119
|
+
if (offset) {
|
|
120
|
+
Matrix4.setTranslation(
|
|
121
|
+
geometryModelMatrix,
|
|
122
|
+
Cartesian3.multiplyComponents(offset, scale, new Cartesian3()),
|
|
123
|
+
geometryModelMatrix,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const transform = Transforms.headingPitchRollToFixedFrame(
|
|
127
|
+
scratchUpdateHeightCartesian,
|
|
128
|
+
headingPitchRoll,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
primitive.modelMatrix = Matrix4.multiply(
|
|
132
|
+
transform,
|
|
133
|
+
geometryModelMatrix,
|
|
134
|
+
new Matrix4(),
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const callbackHandler = scene.updateHeight(
|
|
139
|
+
originCartographic,
|
|
140
|
+
updatePrimitiveHeight,
|
|
141
|
+
heightReference,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const height = scene.getHeight(originCartographic, heightReference);
|
|
145
|
+
if (height) {
|
|
146
|
+
const updatedHeightCarto = originCartographic.clone();
|
|
147
|
+
updatedHeightCarto.height = height;
|
|
148
|
+
updatePrimitiveHeight(updatedHeightCarto);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const destroy = primitive.destroy.bind(primitive);
|
|
152
|
+
primitive.destroy = (): void => {
|
|
153
|
+
callbackHandler();
|
|
154
|
+
destroy();
|
|
155
|
+
};
|
|
122
156
|
}
|
|
123
157
|
|
|
124
158
|
export async function getModelOptions(
|
|
125
159
|
feature: Feature,
|
|
126
|
-
|
|
127
|
-
|
|
160
|
+
position: Cartesian3,
|
|
161
|
+
wgs84Coords: Coordinate,
|
|
128
162
|
vectorProperties: VectorProperties,
|
|
129
163
|
scene: Scene,
|
|
164
|
+
heightInfo: VectorHeightInfo,
|
|
130
165
|
style?: Style,
|
|
131
|
-
): Promise<null | {
|
|
132
|
-
primitives: Model[];
|
|
133
|
-
options: VectorPropertiesModelOptions;
|
|
134
|
-
}> {
|
|
166
|
+
): Promise<null | ConvertedItem<'primitive'>> {
|
|
135
167
|
const options = vectorProperties.getModel(feature);
|
|
136
168
|
if (!options) {
|
|
137
169
|
return null;
|
|
@@ -152,57 +184,59 @@ export async function getModelOptions(
|
|
|
152
184
|
}
|
|
153
185
|
}
|
|
154
186
|
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
new Matrix4(),
|
|
161
|
-
);
|
|
187
|
+
const modelMatrix = Matrix4.multiply(
|
|
188
|
+
Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll),
|
|
189
|
+
Matrix4.fromScale(scale),
|
|
190
|
+
new Matrix4(),
|
|
191
|
+
);
|
|
162
192
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
wgs84Positions[index][2] == null ||
|
|
176
|
-
heightReference === HeightReference.CLAMP_TO_GROUND
|
|
177
|
-
) {
|
|
178
|
-
await placePrimitiveOnTerrain(model, position, scene);
|
|
179
|
-
}
|
|
193
|
+
const additionalModelOptions = vectorProperties.getModelOptions(feature);
|
|
194
|
+
const model = await Model.fromGltfAsync({
|
|
195
|
+
asynchronous: !feature[createSync],
|
|
196
|
+
url: options.url,
|
|
197
|
+
modelMatrix,
|
|
198
|
+
allowPicking,
|
|
199
|
+
color,
|
|
200
|
+
...additionalModelOptions,
|
|
201
|
+
});
|
|
180
202
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (model.ready) {
|
|
188
|
-
activateAnimations();
|
|
189
|
-
} else {
|
|
190
|
-
const listener = model.readyEvent.addEventListener(() => {
|
|
191
|
-
listener();
|
|
192
|
-
activateAnimations();
|
|
193
|
-
});
|
|
194
|
-
}
|
|
203
|
+
const activateAnimations = (): void => {
|
|
204
|
+
model.activeAnimations.addAll({
|
|
205
|
+
loop: ModelAnimationLoop.REPEAT,
|
|
206
|
+
});
|
|
207
|
+
};
|
|
195
208
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
209
|
+
if (model.ready) {
|
|
210
|
+
activateAnimations();
|
|
211
|
+
} else {
|
|
212
|
+
const listener = model.readyEvent.addEventListener(() => {
|
|
213
|
+
listener();
|
|
214
|
+
activateAnimations();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (options.autoScale && !Cartesian3.ONE.equals(scale)) {
|
|
219
|
+
makeScaledAutoScalePrimitive(model, scale);
|
|
220
|
+
}
|
|
221
|
+
if (
|
|
222
|
+
isRelativeHeightReference(heightInfo.heightReference) &&
|
|
223
|
+
(heightInfo as VectorHeightInfo<RelativeHeightReference>).groundLevel ==
|
|
224
|
+
null
|
|
225
|
+
) {
|
|
226
|
+
makeClampedPrimitive(
|
|
227
|
+
model,
|
|
228
|
+
scale,
|
|
229
|
+
headingPitchRoll,
|
|
230
|
+
heightInfo.heightReference,
|
|
231
|
+
scene,
|
|
232
|
+
wgs84Coords,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
202
235
|
|
|
203
236
|
return {
|
|
204
|
-
|
|
205
|
-
|
|
237
|
+
type: 'primitive',
|
|
238
|
+
item: model,
|
|
239
|
+
autoScale: options.autoScale,
|
|
206
240
|
};
|
|
207
241
|
}
|
|
208
242
|
|
|
@@ -263,20 +297,18 @@ function getGeometryInstanceFromOptions(
|
|
|
263
297
|
return null;
|
|
264
298
|
}
|
|
265
299
|
|
|
266
|
-
export
|
|
300
|
+
export function getPrimitiveOptions(
|
|
267
301
|
feature: Feature,
|
|
268
302
|
style: Style,
|
|
269
|
-
|
|
270
|
-
|
|
303
|
+
position: Cartesian3,
|
|
304
|
+
wgs84Coords: Coordinate,
|
|
271
305
|
vectorProperties: VectorProperties,
|
|
272
306
|
scene: Scene,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
options: VectorPropertiesPrimitive;
|
|
276
|
-
}> {
|
|
307
|
+
heightInfo: VectorHeightInfo,
|
|
308
|
+
): ConvertedItem<'primitive'>[] {
|
|
277
309
|
const options = vectorProperties.getPrimitive(feature);
|
|
278
310
|
if (!options) {
|
|
279
|
-
return
|
|
311
|
+
return [];
|
|
280
312
|
}
|
|
281
313
|
|
|
282
314
|
const imageStyle = style.getImage();
|
|
@@ -292,7 +324,7 @@ export async function getPrimitiveOptions(
|
|
|
292
324
|
}
|
|
293
325
|
|
|
294
326
|
if (!fill && !stroke) {
|
|
295
|
-
return
|
|
327
|
+
return [];
|
|
296
328
|
}
|
|
297
329
|
let fillColor: Color | undefined;
|
|
298
330
|
if (fill) {
|
|
@@ -313,134 +345,159 @@ export async function getPrimitiveOptions(
|
|
|
313
345
|
options.roll,
|
|
314
346
|
);
|
|
315
347
|
const allowPicking = vectorProperties.getAllowPicking(feature);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
348
|
+
|
|
349
|
+
const geometryModelMatrix = Matrix4.fromScale(scale);
|
|
350
|
+
let offset: Cartesian3 | undefined;
|
|
351
|
+
if (options.primitiveOptions.offset?.length === 3) {
|
|
352
|
+
offset = Cartesian3.fromArray(options.primitiveOptions.offset);
|
|
353
|
+
Matrix4.setTranslation(
|
|
354
|
+
geometryModelMatrix,
|
|
355
|
+
Cartesian3.multiplyComponents(offset, scale, new Cartesian3()),
|
|
356
|
+
geometryModelMatrix,
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
const transform = Transforms.headingPitchRollToFixedFrame(
|
|
360
|
+
position,
|
|
361
|
+
headingPitchRoll,
|
|
362
|
+
);
|
|
363
|
+
const modelMatrix = Matrix4.multiply(
|
|
364
|
+
transform,
|
|
365
|
+
geometryModelMatrix,
|
|
366
|
+
new Matrix4(),
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
let depthFail;
|
|
370
|
+
if (options.primitiveOptions.depthFailColor) {
|
|
371
|
+
const depthFailColor = getCesiumColor(
|
|
372
|
+
options.primitiveOptions.depthFailColor,
|
|
373
|
+
[255, 255, 255, 0.4],
|
|
374
|
+
);
|
|
375
|
+
depthFail = new MaterialAppearance({
|
|
376
|
+
translucent: depthFailColor.alpha < 1,
|
|
377
|
+
material: Material.fromType('Color', {
|
|
378
|
+
color: depthFailColor,
|
|
379
|
+
}),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const createPrimitive = (
|
|
384
|
+
translucent: boolean,
|
|
385
|
+
geometryInstances: (GeometryInstance | null)[],
|
|
386
|
+
depthFailAppearance?: MaterialAppearance,
|
|
387
|
+
): Primitive => {
|
|
388
|
+
const primitive = new Primitive({
|
|
389
|
+
asynchronous: !feature[createSync],
|
|
390
|
+
geometryInstances: geometryInstances.filter(
|
|
391
|
+
(g) => g,
|
|
392
|
+
) as GeometryInstance[],
|
|
393
|
+
modelMatrix,
|
|
394
|
+
appearance: new PerInstanceColorAppearance({
|
|
395
|
+
translucent,
|
|
396
|
+
flat: true,
|
|
397
|
+
}),
|
|
398
|
+
depthFailAppearance,
|
|
399
|
+
allowPicking,
|
|
400
|
+
...options.primitiveOptions.additionalOptions,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
if (options.autoScale) {
|
|
404
|
+
if (offset) {
|
|
405
|
+
makeOffsetAutoScalePrimitive(primitive, transform, scale, offset);
|
|
406
|
+
} else if (!Cartesian3.ONE.equals(scale)) {
|
|
407
|
+
makeScaledAutoScalePrimitive(primitive, scale);
|
|
329
408
|
}
|
|
330
|
-
|
|
331
|
-
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (
|
|
412
|
+
isRelativeHeightReference(heightInfo.heightReference) &&
|
|
413
|
+
(heightInfo as VectorHeightInfo<RelativeHeightReference>).groundLevel ==
|
|
414
|
+
null
|
|
415
|
+
) {
|
|
416
|
+
makeClampedPrimitive(
|
|
417
|
+
primitive,
|
|
418
|
+
scale,
|
|
332
419
|
headingPitchRoll,
|
|
420
|
+
heightInfo.heightReference,
|
|
421
|
+
scene,
|
|
422
|
+
wgs84Coords,
|
|
423
|
+
offset,
|
|
333
424
|
);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
new Matrix4(),
|
|
338
|
-
);
|
|
425
|
+
}
|
|
426
|
+
return primitive;
|
|
427
|
+
};
|
|
339
428
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
)
|
|
346
|
-
depthFail
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
429
|
+
const fillAndOutline = [];
|
|
430
|
+
if (fillColor) {
|
|
431
|
+
fillAndOutline.push(
|
|
432
|
+
createPrimitive(
|
|
433
|
+
fillColor.alpha < 1 || !!depthFail,
|
|
434
|
+
[getGeometryInstanceFromOptions(options.primitiveOptions, fillColor)],
|
|
435
|
+
depthFail,
|
|
436
|
+
),
|
|
437
|
+
);
|
|
438
|
+
} else if (depthFail) {
|
|
439
|
+
const transparent = Color.TRANSPARENT;
|
|
440
|
+
fillAndOutline.push(
|
|
441
|
+
createPrimitive(
|
|
442
|
+
true,
|
|
443
|
+
[getGeometryInstanceFromOptions(options.primitiveOptions, transparent)],
|
|
444
|
+
depthFail,
|
|
445
|
+
),
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
if (strokeColor) {
|
|
449
|
+
fillAndOutline.push(
|
|
450
|
+
createPrimitive(strokeColor.alpha < 1 || !!depthFail, [
|
|
451
|
+
getGeometryInstanceFromOptions(
|
|
452
|
+
options.primitiveOptions,
|
|
453
|
+
strokeColor,
|
|
454
|
+
true,
|
|
455
|
+
),
|
|
456
|
+
]),
|
|
457
|
+
);
|
|
458
|
+
}
|
|
353
459
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
asynchronous: !feature[createSync],
|
|
361
|
-
geometryInstances: geometryInstances.filter(
|
|
362
|
-
(g) => g,
|
|
363
|
-
) as GeometryInstance[],
|
|
364
|
-
modelMatrix,
|
|
365
|
-
appearance: new PerInstanceColorAppearance({
|
|
366
|
-
translucent,
|
|
367
|
-
flat: true,
|
|
368
|
-
}),
|
|
369
|
-
depthFailAppearance,
|
|
370
|
-
allowPicking,
|
|
371
|
-
...options.primitiveOptions.additionalOptions,
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
if (
|
|
375
|
-
wgs84Positions[index][2] == null ||
|
|
376
|
-
heightReference === HeightReference.CLAMP_TO_GROUND
|
|
377
|
-
) {
|
|
378
|
-
await placePrimitiveOnTerrain(primitive, position, scene, offset);
|
|
379
|
-
Transforms.headingPitchRollToFixedFrame(
|
|
380
|
-
position,
|
|
381
|
-
headingPitchRoll,
|
|
382
|
-
undefined,
|
|
383
|
-
undefined,
|
|
384
|
-
transform,
|
|
385
|
-
); // update transform for usage in offset auto scale
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (options.autoScale) {
|
|
389
|
-
if (offset) {
|
|
390
|
-
makeOffsetAutoScalePrimitive(primitive, transform, scale, offset);
|
|
391
|
-
} else if (!Cartesian3.ONE.equals(scale)) {
|
|
392
|
-
makeScaledAutoScalePrimitive(primitive, scale);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return primitive;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
const fillAndOutline = [];
|
|
399
|
-
if (fillColor) {
|
|
400
|
-
fillAndOutline.push(
|
|
401
|
-
createPrimitive(
|
|
402
|
-
fillColor.alpha < 1 || !!depthFail,
|
|
403
|
-
[
|
|
404
|
-
getGeometryInstanceFromOptions(
|
|
405
|
-
options.primitiveOptions,
|
|
406
|
-
fillColor,
|
|
407
|
-
),
|
|
408
|
-
],
|
|
409
|
-
depthFail,
|
|
410
|
-
),
|
|
411
|
-
);
|
|
412
|
-
} else if (depthFail) {
|
|
413
|
-
const transparent = Color.TRANSPARENT;
|
|
414
|
-
fillAndOutline.push(
|
|
415
|
-
createPrimitive(
|
|
416
|
-
true,
|
|
417
|
-
[
|
|
418
|
-
getGeometryInstanceFromOptions(
|
|
419
|
-
options.primitiveOptions,
|
|
420
|
-
transparent,
|
|
421
|
-
),
|
|
422
|
-
],
|
|
423
|
-
depthFail,
|
|
424
|
-
),
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
if (strokeColor) {
|
|
428
|
-
fillAndOutline.push(
|
|
429
|
-
createPrimitive(strokeColor.alpha < 1 || !!depthFail, [
|
|
430
|
-
getGeometryInstanceFromOptions(
|
|
431
|
-
options.primitiveOptions,
|
|
432
|
-
strokeColor,
|
|
433
|
-
true,
|
|
434
|
-
),
|
|
435
|
-
]),
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
return Promise.all(fillAndOutline);
|
|
439
|
-
}),
|
|
440
|
-
);
|
|
460
|
+
return fillAndOutline.map((item) => ({
|
|
461
|
+
type: 'primitive',
|
|
462
|
+
item,
|
|
463
|
+
autoScale: options.autoScale,
|
|
464
|
+
}));
|
|
465
|
+
}
|
|
441
466
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
467
|
+
export async function getModelOrPointPrimitiveOptions(
|
|
468
|
+
feature: Feature,
|
|
469
|
+
style: Style,
|
|
470
|
+
position: Cartesian3,
|
|
471
|
+
wgs84Coords: Coordinate,
|
|
472
|
+
vectorProperties: VectorProperties,
|
|
473
|
+
heightInfo: VectorHeightInfo,
|
|
474
|
+
scene: Scene,
|
|
475
|
+
): Promise<ConvertedItem<'primitive'>[]> {
|
|
476
|
+
const renderAs = vectorProperties.renderAs(feature);
|
|
477
|
+
if (renderAs === 'model') {
|
|
478
|
+
const modelOptions = await getModelOptions(
|
|
479
|
+
feature,
|
|
480
|
+
position,
|
|
481
|
+
wgs84Coords,
|
|
482
|
+
vectorProperties,
|
|
483
|
+
scene,
|
|
484
|
+
heightInfo,
|
|
485
|
+
style,
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
return modelOptions ? [modelOptions] : [];
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (renderAs === 'primitive') {
|
|
492
|
+
return getPrimitiveOptions(
|
|
493
|
+
feature,
|
|
494
|
+
style,
|
|
495
|
+
position,
|
|
496
|
+
wgs84Coords,
|
|
497
|
+
vectorProperties,
|
|
498
|
+
scene,
|
|
499
|
+
heightInfo,
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
return [];
|
|
446
503
|
}
|