@vcmap/core 5.0.0-rc.30 → 5.0.0-rc.32
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/index.d.ts +9 -7
- package/package.json +3 -3
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +25 -24
- package/src/layer/cesium/terrainCesiumImpl.js +2 -3
- package/src/layer/cesium/vectorTileImageryProvider.js +5 -22
- package/src/layer/cesiumTilesetLayer.js +0 -4
- package/src/layer/terrainHelpers.js +9 -12
- package/src/layer/terrainLayer.js +2 -3
- package/src/map/cameraLimiter.js +8 -24
- package/src/map/cesiumMap.js +13 -14
- package/src/oblique/obliqueCollection.js +6 -1
- package/src/oblique/obliqueDataSet.js +21 -20
- package/src/util/clipping/clippingObject.js +4 -6
- package/tests/unit/helpers/obliqueHelpers.js +7 -7
- package/tests/unit/helpers/terrain/terrainData.js +3 -5
package/index.d.ts
CHANGED
|
@@ -685,7 +685,7 @@ export const cesiumTilesetLastUpdated: unique symbol;
|
|
|
685
685
|
/**
|
|
686
686
|
* @returns in mercator
|
|
687
687
|
*/
|
|
688
|
-
export function getExtentFromTileset(cesium3DTileset: import("@vcmap-cesium/engine").Cesium3DTileset): import("ol/extent").Extent;
|
|
688
|
+
export function getExtentFromTileset(cesium3DTileset: import("@vcmap-cesium/engine").Cesium3DTileset | undefined): import("ol/extent").Extent;
|
|
689
689
|
|
|
690
690
|
|
|
691
691
|
|
|
@@ -959,8 +959,8 @@ export class VectorTileImageryProvider {
|
|
|
959
959
|
minLevel: number;
|
|
960
960
|
maxLevel: number;
|
|
961
961
|
|
|
962
|
+
|
|
962
963
|
ready: any;
|
|
963
|
-
readyPromise: any;
|
|
964
964
|
rectangle: any;
|
|
965
965
|
tileWidth: any;
|
|
966
966
|
tileHeight: any;
|
|
@@ -3237,12 +3237,11 @@ export class SingleImageLayer extends RasterLayer {
|
|
|
3237
3237
|
}
|
|
3238
3238
|
|
|
3239
3239
|
export interface TerrainProviderOptions {
|
|
3240
|
-
url: string;
|
|
3241
3240
|
requestVertexNormals?: boolean | undefined;
|
|
3242
3241
|
requestWaterMask?: boolean | undefined;
|
|
3243
3242
|
}
|
|
3244
3243
|
|
|
3245
|
-
export function getTerrainProviderForUrl(options: TerrainProviderOptions): import("@vcmap-cesium/engine").CesiumTerrainProvider
|
|
3244
|
+
export function getTerrainProviderForUrl(url: string, options: TerrainProviderOptions): Promise<import("@vcmap-cesium/engine").CesiumTerrainProvider>;
|
|
3246
3245
|
|
|
3247
3246
|
/**
|
|
3248
3247
|
* changes input coordinate Array in place, new height can also be accessed by coordinates[x][2]
|
|
@@ -5789,10 +5788,14 @@ export interface ObliqueVersion {
|
|
|
5789
5788
|
buildNumber: number;
|
|
5790
5789
|
}
|
|
5791
5790
|
|
|
5791
|
+
export interface ObliqueDataSetTerrainProviderOptions extends TerrainProviderOptions {
|
|
5792
|
+
url: string;
|
|
5793
|
+
}
|
|
5794
|
+
|
|
5792
5795
|
export interface ObliqueDataSetOptions {
|
|
5793
5796
|
url: string;
|
|
5794
5797
|
projection?: ProjectionOptions;
|
|
5795
|
-
terrainProvider?:
|
|
5798
|
+
terrainProvider?: ObliqueDataSetTerrainProviderOptions;
|
|
5796
5799
|
}
|
|
5797
5800
|
|
|
5798
5801
|
export interface ObliqueCollectionOptions extends VcsObjectOptions {
|
|
@@ -5937,7 +5940,7 @@ export enum DataState {
|
|
|
5937
5940
|
export function getStateFromStatesArray(states: DataState[]): DataState;
|
|
5938
5941
|
|
|
5939
5942
|
export class ObliqueDataSet {
|
|
5940
|
-
constructor(url: string, projection: Projection | ProjectionOptions, terrainProviderOptions?:
|
|
5943
|
+
constructor(url: string, projection: Projection | ProjectionOptions, terrainProviderOptions?: ObliqueDataSetTerrainProviderOptions);
|
|
5941
5944
|
url: string;
|
|
5942
5945
|
baseUrl: string;
|
|
5943
5946
|
projection: Projection;
|
|
@@ -5958,7 +5961,6 @@ export class ObliqueDataSet {
|
|
|
5958
5961
|
* reflect the state of loaded tiles.
|
|
5959
5962
|
*/
|
|
5960
5963
|
readonly state: DataState;
|
|
5961
|
-
readonly terrainProvider: import("@vcmap-cesium/engine").CesiumTerrainProvider | undefined;
|
|
5962
5964
|
/**
|
|
5963
5965
|
* Loads the data set.
|
|
5964
5966
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/core",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.32",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"typescript": "^4.9.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@vcmap-cesium/engine": "~
|
|
65
|
-
"ol": "~7.
|
|
64
|
+
"@vcmap-cesium/engine": "~2.3.2",
|
|
65
|
+
"ol": "~7.3.0"
|
|
66
66
|
},
|
|
67
67
|
"eslintConfig": {
|
|
68
68
|
"extends": [
|
|
@@ -21,11 +21,11 @@ import { circleFromCenterRadius } from '../../util/geometryHelpers.js';
|
|
|
21
21
|
export const cesiumTilesetLastUpdated = Symbol('cesiumTilesetLastUpdated');
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @param {import("@vcmap-cesium/engine").Cesium3DTileset} cesium3DTileset
|
|
24
|
+
* @param {import("@vcmap-cesium/engine").Cesium3DTileset|undefined} cesium3DTileset
|
|
25
25
|
* @returns {import("ol/extent").Extent} in mercator
|
|
26
26
|
*/
|
|
27
27
|
export function getExtentFromTileset(cesium3DTileset) {
|
|
28
|
-
if (!cesium3DTileset
|
|
28
|
+
if (!cesium3DTileset) {
|
|
29
29
|
return createEmpty();
|
|
30
30
|
}
|
|
31
31
|
const { rectangle } = cesium3DTileset.root.boundingVolume;
|
|
@@ -121,8 +121,12 @@ class CesiumTilesetCesiumImpl extends LayerImplementation {
|
|
|
121
121
|
*/
|
|
122
122
|
async initialize() {
|
|
123
123
|
if (!this._initializedPromise) {
|
|
124
|
+
this._initializedPromise = Cesium3DTileset.fromUrl(
|
|
125
|
+
this.url,
|
|
126
|
+
this.tilesetOptions,
|
|
127
|
+
);
|
|
124
128
|
/** @type {import("@vcmap-cesium/engine").Cesium3DTileset} */
|
|
125
|
-
this.cesium3DTileset =
|
|
129
|
+
this.cesium3DTileset = await this._initializedPromise;
|
|
126
130
|
if (this.tilesetProperties) {
|
|
127
131
|
this.tilesetProperties.forEach(({ key, value }) => {
|
|
128
132
|
this.cesium3DTileset[key] = value;
|
|
@@ -136,9 +140,6 @@ class CesiumTilesetCesiumImpl extends LayerImplementation {
|
|
|
136
140
|
delete tile[cesiumTilesetLastUpdated];
|
|
137
141
|
});
|
|
138
142
|
|
|
139
|
-
this._initializedPromise = this.cesium3DTileset.readyPromise;
|
|
140
|
-
|
|
141
|
-
await this._initializedPromise;
|
|
142
143
|
this._originalOrigin = Cartesian3.clone(
|
|
143
144
|
this.cesium3DTileset.boundingSphere.center,
|
|
144
145
|
);
|
|
@@ -249,24 +250,22 @@ class CesiumTilesetCesiumImpl extends LayerImplementation {
|
|
|
249
250
|
},
|
|
250
251
|
);
|
|
251
252
|
this._styleLastUpdated = Date.now();
|
|
252
|
-
this.cesium3DTileset.
|
|
253
|
-
if
|
|
254
|
-
|
|
253
|
+
if (this.cesium3DTileset.colorBlendMode !== this.style.colorBlendMode) {
|
|
254
|
+
// we only support replace and mix mode if the _3DTILESDIFFUSE Flag is set in the tileset
|
|
255
|
+
if (
|
|
256
|
+
this.style.colorBlendMode !== Cesium3DTileColorBlendMode.HIGHLIGHT
|
|
257
|
+
) {
|
|
255
258
|
if (
|
|
256
|
-
this.
|
|
259
|
+
this.cesium3DTileset.extras &&
|
|
260
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
261
|
+
this.cesium3DTileset.extras._3DTILESDIFFUSE
|
|
257
262
|
) {
|
|
258
|
-
if (
|
|
259
|
-
this.cesium3DTileset.extras &&
|
|
260
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
261
|
-
this.cesium3DTileset.extras._3DTILESDIFFUSE
|
|
262
|
-
) {
|
|
263
|
-
this.cesium3DTileset.colorBlendMode = this.style.colorBlendMode;
|
|
264
|
-
}
|
|
265
|
-
} else {
|
|
266
263
|
this.cesium3DTileset.colorBlendMode = this.style.colorBlendMode;
|
|
267
264
|
}
|
|
265
|
+
} else {
|
|
266
|
+
this.cesium3DTileset.colorBlendMode = this.style.colorBlendMode;
|
|
268
267
|
}
|
|
269
|
-
}
|
|
268
|
+
}
|
|
270
269
|
}
|
|
271
270
|
}
|
|
272
271
|
|
|
@@ -284,12 +283,14 @@ class CesiumTilesetCesiumImpl extends LayerImplementation {
|
|
|
284
283
|
* @param {import("@vcmap-cesium/engine").Cesium3DTile} tile
|
|
285
284
|
*/
|
|
286
285
|
applyStyle(tile) {
|
|
287
|
-
if (tile.
|
|
288
|
-
|
|
289
|
-
|
|
286
|
+
if (tile.contentReady) {
|
|
287
|
+
if (tile.content instanceof Composite3DTileContent) {
|
|
288
|
+
for (let i = 0; i < tile.content.innerContents.length; i++) {
|
|
289
|
+
this.styleContent(tile.content.innerContents[i]);
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
this.styleContent(tile.content);
|
|
290
293
|
}
|
|
291
|
-
} else {
|
|
292
|
-
this.styleContent(tile.content);
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
296
|
|
|
@@ -35,10 +35,9 @@ class TerrainCesiumImpl extends LayerImplementation {
|
|
|
35
35
|
* @inheritDoc
|
|
36
36
|
* @returns {Promise<void>}
|
|
37
37
|
*/
|
|
38
|
-
initialize() {
|
|
38
|
+
async initialize() {
|
|
39
39
|
if (!this.initialized) {
|
|
40
|
-
this.terrainProvider = getTerrainProviderForUrl({
|
|
41
|
-
url: this.url,
|
|
40
|
+
this.terrainProvider = await getTerrainProviderForUrl(this.url, {
|
|
42
41
|
requestVertexNormals: this.requestVertexNormals,
|
|
43
42
|
requestWaterMask: this.requestWaterMask,
|
|
44
43
|
});
|
|
@@ -128,12 +128,6 @@ class VectorTileImageryProvider {
|
|
|
128
128
|
*/
|
|
129
129
|
this._errorEvent = new CesiumEvent();
|
|
130
130
|
|
|
131
|
-
/**
|
|
132
|
-
* @type {Promise<boolean>}
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
this._readyPromise = Promise.resolve(true);
|
|
136
|
-
|
|
137
131
|
/**
|
|
138
132
|
* @type {HTMLCanvasElement}
|
|
139
133
|
*/
|
|
@@ -154,33 +148,22 @@ class VectorTileImageryProvider {
|
|
|
154
148
|
* @type {Function}
|
|
155
149
|
*/
|
|
156
150
|
this._reload = undefined;
|
|
157
|
-
|
|
158
|
-
// Necessary to satisfy Cesium ImageryProvider Interface
|
|
159
|
-
this.defaultAlpha = undefined;
|
|
160
|
-
this.defaultNightAlpha = undefined;
|
|
161
|
-
this.defaultDayAlpha = undefined;
|
|
162
|
-
this.defaultBrightness = undefined;
|
|
163
|
-
this.defaultContrast = undefined;
|
|
164
|
-
this.defaultHue = undefined;
|
|
165
|
-
this.defaultSaturation = undefined;
|
|
166
|
-
this.defaultGamma = undefined;
|
|
167
|
-
this.defaultMinificationFilter = undefined;
|
|
168
|
-
this.defaultMagnificationFilter = undefined;
|
|
169
151
|
}
|
|
170
152
|
|
|
171
153
|
/**
|
|
172
154
|
* @returns {boolean}
|
|
173
155
|
*/
|
|
174
156
|
// eslint-disable-next-line class-methods-use-this
|
|
175
|
-
get
|
|
157
|
+
get _ready() {
|
|
176
158
|
return true;
|
|
177
159
|
}
|
|
178
160
|
|
|
179
161
|
/**
|
|
180
|
-
* @returns {
|
|
162
|
+
* @returns {boolean}
|
|
181
163
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
164
|
+
// eslint-disable-next-line class-methods-use-this
|
|
165
|
+
get ready() {
|
|
166
|
+
return true;
|
|
184
167
|
}
|
|
185
168
|
|
|
186
169
|
/**
|
|
@@ -113,7 +113,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
113
113
|
|
|
114
114
|
/** @type {!Object} */
|
|
115
115
|
this.tilesetOptions = {
|
|
116
|
-
url: this.url,
|
|
117
116
|
maximumScreenSpaceError: isMobile()
|
|
118
117
|
? this.screenSpaceErrorMobile
|
|
119
118
|
: this.screenSpaceError,
|
|
@@ -297,9 +296,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
297
296
|
}
|
|
298
297
|
|
|
299
298
|
const tilesetOptions = { ...this.tilesetOptions };
|
|
300
|
-
if (tilesetOptions.url === this.url) {
|
|
301
|
-
delete tilesetOptions.url;
|
|
302
|
-
}
|
|
303
299
|
|
|
304
300
|
const usedScreenSpaceError = isMobile()
|
|
305
301
|
? this.screenSpaceErrorMobile
|
|
@@ -9,7 +9,6 @@ import { wgs84Projection } from '../util/projection.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {Object} TerrainProviderOptions
|
|
12
|
-
* @property {!string} url
|
|
13
12
|
* @property {boolean|undefined} requestVertexNormals
|
|
14
13
|
* @property {boolean|undefined} requestWaterMask
|
|
15
14
|
* @api
|
|
@@ -21,23 +20,24 @@ import { wgs84Projection } from '../util/projection.js';
|
|
|
21
20
|
const terrainProviders = {};
|
|
22
21
|
|
|
23
22
|
/**
|
|
23
|
+
* @param {string} url
|
|
24
24
|
* @param {TerrainProviderOptions} options
|
|
25
|
-
* @returns {import("@vcmap-cesium/engine").CesiumTerrainProvider}
|
|
25
|
+
* @returns {Promise<import("@vcmap-cesium/engine").CesiumTerrainProvider>}
|
|
26
26
|
*/
|
|
27
|
-
export function getTerrainProviderForUrl(options) {
|
|
28
|
-
if (!terrainProviders[
|
|
29
|
-
terrainProviders[
|
|
30
|
-
return terrainProviders[
|
|
27
|
+
export async function getTerrainProviderForUrl(url, options) {
|
|
28
|
+
if (!terrainProviders[url]) {
|
|
29
|
+
terrainProviders[url] = await CesiumTerrainProvider.fromUrl(url, options);
|
|
30
|
+
return terrainProviders[url];
|
|
31
31
|
}
|
|
32
|
-
let terrainProvider = terrainProviders[
|
|
32
|
+
let terrainProvider = terrainProviders[url];
|
|
33
33
|
if (
|
|
34
34
|
(options.requestVertexNormals !== undefined &&
|
|
35
35
|
terrainProvider.requestVertexNormals !== options.requestVertexNormals) ||
|
|
36
36
|
(options.requestWaterMask !== undefined &&
|
|
37
37
|
terrainProvider.requestWaterMask !== options.requestWaterMask)
|
|
38
38
|
) {
|
|
39
|
-
terrainProviders[
|
|
40
|
-
terrainProvider = terrainProviders[
|
|
39
|
+
terrainProviders[url] = await CesiumTerrainProvider.fromUrl(url, options);
|
|
40
|
+
terrainProvider = terrainProviders[url];
|
|
41
41
|
}
|
|
42
42
|
return terrainProvider;
|
|
43
43
|
}
|
|
@@ -86,9 +86,6 @@ export function getHeightFromTerrainProvider(
|
|
|
86
86
|
* @returns {boolean}
|
|
87
87
|
*/
|
|
88
88
|
export function isTerrainTileAvailable(terrainProvider, level, position) {
|
|
89
|
-
if (!terrainProvider.ready) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
89
|
const tileXY = terrainProvider.tilingScheme.positionToTileXY(
|
|
93
90
|
position,
|
|
94
91
|
level,
|
|
@@ -100,9 +100,8 @@ class TerrainLayer extends Layer {
|
|
|
100
100
|
* @returns {Promise<Array<import("ol/coordinate").Coordinate>>}
|
|
101
101
|
* @api stable
|
|
102
102
|
*/
|
|
103
|
-
getHeightForWGS84Coordinates(coords) {
|
|
104
|
-
const terrainProvider = getTerrainProviderForUrl({
|
|
105
|
-
url: this.url,
|
|
103
|
+
async getHeightForWGS84Coordinates(coords) {
|
|
104
|
+
const terrainProvider = await getTerrainProviderForUrl(this.url, {
|
|
106
105
|
requestVertexNormals: this.requestVertexNormals,
|
|
107
106
|
requestWaterMask: this.requestWaterMask,
|
|
108
107
|
});
|
package/src/map/cameraLimiter.js
CHANGED
|
@@ -74,13 +74,6 @@ class CameraLimiter {
|
|
|
74
74
|
* @private
|
|
75
75
|
*/
|
|
76
76
|
this._terrainUrl = options.terrainUrl || defaultOptions.terrainUrl;
|
|
77
|
-
/**
|
|
78
|
-
* @type {import("@vcmap-cesium/engine").CesiumTerrainProvider|null}
|
|
79
|
-
* @private
|
|
80
|
-
*/
|
|
81
|
-
this._terrainProvider = this._terrainUrl
|
|
82
|
-
? getTerrainProviderForUrl({ url: this._terrainUrl })
|
|
83
|
-
: null;
|
|
84
77
|
/**
|
|
85
78
|
* The minimum height/distance to the terrain the camera must maintain
|
|
86
79
|
* @type {number}
|
|
@@ -131,9 +124,6 @@ class CameraLimiter {
|
|
|
131
124
|
|
|
132
125
|
if (this._terrainUrl !== url) {
|
|
133
126
|
this._terrainUrl = url;
|
|
134
|
-
this._terrainProvider = this._terrainUrl
|
|
135
|
-
? getTerrainProviderForUrl({ url: this._terrainUrl })
|
|
136
|
-
: null;
|
|
137
127
|
}
|
|
138
128
|
}
|
|
139
129
|
|
|
@@ -142,17 +132,12 @@ class CameraLimiter {
|
|
|
142
132
|
* @returns {Promise<Array<import("@vcmap-cesium/engine").Cartographic>>}
|
|
143
133
|
* @private
|
|
144
134
|
*/
|
|
145
|
-
_limitWithLevel(cameraCartographic) {
|
|
135
|
+
async _limitWithLevel(cameraCartographic) {
|
|
136
|
+
const terrainProvider = await getTerrainProviderForUrl(this.terrainUrl, {});
|
|
146
137
|
if (
|
|
147
|
-
isTerrainTileAvailable(
|
|
148
|
-
this._terrainProvider,
|
|
149
|
-
this.level,
|
|
150
|
-
cameraCartographic,
|
|
151
|
-
)
|
|
138
|
+
isTerrainTileAvailable(terrainProvider, this.level, cameraCartographic)
|
|
152
139
|
) {
|
|
153
|
-
return sampleTerrain(
|
|
154
|
-
cameraCartographic,
|
|
155
|
-
]);
|
|
140
|
+
return sampleTerrain(terrainProvider, this.level, [cameraCartographic]);
|
|
156
141
|
}
|
|
157
142
|
return this._limitMostDetailed(cameraCartographic);
|
|
158
143
|
}
|
|
@@ -162,10 +147,9 @@ class CameraLimiter {
|
|
|
162
147
|
* @returns {Promise<Array<import("@vcmap-cesium/engine").Cartographic>>}
|
|
163
148
|
* @private
|
|
164
149
|
*/
|
|
165
|
-
_limitMostDetailed(cameraCartographic) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]);
|
|
150
|
+
async _limitMostDetailed(cameraCartographic) {
|
|
151
|
+
const terrainProvider = await getTerrainProviderForUrl(this.terrainUrl, {});
|
|
152
|
+
return sampleTerrainMostDetailed(terrainProvider, [cameraCartographic]);
|
|
169
153
|
}
|
|
170
154
|
|
|
171
155
|
/**
|
|
@@ -202,7 +186,7 @@ class CameraLimiter {
|
|
|
202
186
|
let promise = Promise.resolve();
|
|
203
187
|
const cameraCartographic = Cartographic.fromCartesian(camera.position);
|
|
204
188
|
if (cameraCartographic) {
|
|
205
|
-
if (this.mode === CameraLimiterMode.DISTANCE && this.
|
|
189
|
+
if (this.mode === CameraLimiterMode.DISTANCE && this.terrainUrl) {
|
|
206
190
|
promise = this._updateTerrainHeight(cameraCartographic);
|
|
207
191
|
if (
|
|
208
192
|
this._terrainHeight &&
|
package/src/map/cesiumMap.js
CHANGED
|
@@ -552,7 +552,8 @@ class CesiumMap extends VcsMap {
|
|
|
552
552
|
this._cesiumWidget = new CesiumWidget(this.mapElement, {
|
|
553
553
|
requestRenderMode: false,
|
|
554
554
|
scene3DOnly: true,
|
|
555
|
-
|
|
555
|
+
// @ts-ignore // error in Cesium, recheck on next cesium update
|
|
556
|
+
baseLayer: false,
|
|
556
557
|
shadows: false,
|
|
557
558
|
terrainShadows: ShadowMode.ENABLED,
|
|
558
559
|
contextOptions: {
|
|
@@ -675,19 +676,17 @@ class CesiumMap extends VcsMap {
|
|
|
675
676
|
*/
|
|
676
677
|
getHeightFromTerrain(positions) {
|
|
677
678
|
const { terrainProvider } = this._cesiumWidget.scene;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
return Promise.resolve(positions);
|
|
690
|
-
});
|
|
679
|
+
if (terrainProvider.availability) {
|
|
680
|
+
return getHeightFromTerrainProvider(
|
|
681
|
+
/** @type {import("@vcmap-cesium/engine").CesiumTerrainProvider} */ (
|
|
682
|
+
terrainProvider
|
|
683
|
+
),
|
|
684
|
+
positions,
|
|
685
|
+
mercatorProjection,
|
|
686
|
+
positions,
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
return Promise.resolve(positions);
|
|
691
690
|
}
|
|
692
691
|
|
|
693
692
|
/**
|
|
@@ -61,11 +61,16 @@ import VcsObject from '../vcsObject.js';
|
|
|
61
61
|
* @api
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {TerrainProviderOptions} ObliqueDataSetTerrainProviderOptions
|
|
66
|
+
* @property {string} url
|
|
67
|
+
*/
|
|
68
|
+
|
|
64
69
|
/**
|
|
65
70
|
* @typedef {Object} ObliqueDataSetOptions
|
|
66
71
|
* @property {string} url
|
|
67
72
|
* @property {ProjectionOptions} [projection]
|
|
68
|
-
* @property {
|
|
73
|
+
* @property {ObliqueDataSetTerrainProviderOptions} [terrainProvider]
|
|
69
74
|
*/
|
|
70
75
|
|
|
71
76
|
/**
|
|
@@ -54,7 +54,7 @@ class ObliqueDataSet {
|
|
|
54
54
|
/**
|
|
55
55
|
* @param {string} url
|
|
56
56
|
* @param {import("@vcmap/core").Projection|ProjectionOptions=} projection
|
|
57
|
-
* @param {
|
|
57
|
+
* @param {ObliqueDataSetTerrainProviderOptions=} terrainProviderOptions
|
|
58
58
|
*/
|
|
59
59
|
constructor(url, projection, terrainProviderOptions) {
|
|
60
60
|
/** @type {string} */
|
|
@@ -75,7 +75,7 @@ class ObliqueDataSet {
|
|
|
75
75
|
projectionObject
|
|
76
76
|
);
|
|
77
77
|
/**
|
|
78
|
-
* @type {
|
|
78
|
+
* @type {ObliqueDataSetTerrainProviderOptions|undefined}
|
|
79
79
|
* @private
|
|
80
80
|
*/
|
|
81
81
|
this._terrainProviderOptions = terrainProviderOptions
|
|
@@ -85,9 +85,7 @@ class ObliqueDataSet {
|
|
|
85
85
|
* @type {import("@vcmap-cesium/engine").CesiumTerrainProvider|undefined}
|
|
86
86
|
* @private
|
|
87
87
|
*/
|
|
88
|
-
this._terrainProvider =
|
|
89
|
-
? getTerrainProviderForUrl(this._terrainProviderOptions)
|
|
90
|
-
: undefined;
|
|
88
|
+
this._terrainProvider = undefined;
|
|
91
89
|
/**
|
|
92
90
|
* @type {Array<import("@vcmap/core").ObliqueImageMeta>}
|
|
93
91
|
* @private
|
|
@@ -146,25 +144,18 @@ class ObliqueDataSet {
|
|
|
146
144
|
return this._state;
|
|
147
145
|
}
|
|
148
146
|
|
|
149
|
-
/**
|
|
150
|
-
* @type {import("@vcmap-cesium/engine").CesiumTerrainProvider|undefined}
|
|
151
|
-
* @readonly
|
|
152
|
-
*/
|
|
153
|
-
get terrainProvider() {
|
|
154
|
-
return this._terrainProvider;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
147
|
/**
|
|
158
148
|
* Loads the data set.
|
|
159
149
|
* @returns {Promise<void>}
|
|
160
150
|
* @api
|
|
161
151
|
*/
|
|
162
|
-
load() {
|
|
152
|
+
async load() {
|
|
163
153
|
if (!this._loadingPromise) {
|
|
164
154
|
this._state = DataState.LOADING;
|
|
165
|
-
|
|
166
155
|
this._loadingPromise = requestJson(this.url)
|
|
167
|
-
.then((data) =>
|
|
156
|
+
.then((data) => {
|
|
157
|
+
return this._initialize(data);
|
|
158
|
+
})
|
|
168
159
|
.catch((err) => {
|
|
169
160
|
return Promise.reject(err);
|
|
170
161
|
});
|
|
@@ -192,19 +183,29 @@ class ObliqueDataSet {
|
|
|
192
183
|
* @param {ObliqueImageJson} json
|
|
193
184
|
* @api
|
|
194
185
|
*/
|
|
195
|
-
initialize(json) {
|
|
186
|
+
async initialize(json) {
|
|
196
187
|
if (this._state !== DataState.PENDING) {
|
|
197
188
|
throw new Error('DataSet has already been loaded');
|
|
198
189
|
}
|
|
199
190
|
this._loadingPromise = Promise.resolve();
|
|
200
|
-
this._initialize(json);
|
|
191
|
+
await this._initialize(json);
|
|
201
192
|
}
|
|
202
193
|
|
|
203
194
|
/**
|
|
204
195
|
* @param {ObliqueImageJson} json
|
|
205
196
|
* @private
|
|
206
197
|
*/
|
|
207
|
-
_initialize(json) {
|
|
198
|
+
async _initialize(json) {
|
|
199
|
+
if (this._terrainProviderOptions?.url) {
|
|
200
|
+
const terrainProviderOptions = {
|
|
201
|
+
requestVertexNormals: this._terrainProviderOptions.requestVertexNormals,
|
|
202
|
+
requestWaterMask: this._terrainProviderOptions.requestWaterMask,
|
|
203
|
+
};
|
|
204
|
+
this._terrainProvider = await getTerrainProviderForUrl(
|
|
205
|
+
this._terrainProviderOptions.url,
|
|
206
|
+
terrainProviderOptions,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
208
209
|
this._parseMetaData(json);
|
|
209
210
|
this._state = DataState.READY;
|
|
210
211
|
}
|
|
@@ -218,7 +219,7 @@ class ObliqueDataSet {
|
|
|
218
219
|
json,
|
|
219
220
|
this.baseUrl,
|
|
220
221
|
this.projection,
|
|
221
|
-
this.
|
|
222
|
+
this._terrainProvider,
|
|
222
223
|
);
|
|
223
224
|
const { version, buildNumber } = getVersionFromImageJson(json);
|
|
224
225
|
|
|
@@ -215,12 +215,10 @@ class ClippingObject {
|
|
|
215
215
|
/** @param {import("@vcmap-cesium/engine").Cesium3DTileset} tileset */ (
|
|
216
216
|
tileset,
|
|
217
217
|
) => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
});
|
|
218
|
+
if (this.layerNames.includes(layer.name) && layer.active) {
|
|
219
|
+
this.targets.set(layer.name, tileset);
|
|
220
|
+
this.targetsUpdated.raiseEvent();
|
|
221
|
+
}
|
|
224
222
|
},
|
|
225
223
|
);
|
|
226
224
|
} else {
|
|
@@ -47,7 +47,7 @@ function getStartingViewpoint() {
|
|
|
47
47
|
* @param {Scope=} scope if provided the dataset is initialized with a terrainProvider
|
|
48
48
|
* @returns {vcs-oblique/ObliqueDataSet}
|
|
49
49
|
*/
|
|
50
|
-
export function getObliqueDataSet(scope) {
|
|
50
|
+
export async function getObliqueDataSet(scope) {
|
|
51
51
|
if (!obliqueProjection) {
|
|
52
52
|
obliqueProjection = new Projection({
|
|
53
53
|
epsg: 'EPSG:25833',
|
|
@@ -56,7 +56,7 @@ export function getObliqueDataSet(scope) {
|
|
|
56
56
|
}
|
|
57
57
|
let terrainProvider;
|
|
58
58
|
if (scope) {
|
|
59
|
-
getTerrainProvider(scope);
|
|
59
|
+
await getTerrainProvider(scope);
|
|
60
60
|
terrainProvider = {
|
|
61
61
|
url: 'http://localhost/terrain/',
|
|
62
62
|
};
|
|
@@ -66,7 +66,7 @@ export function getObliqueDataSet(scope) {
|
|
|
66
66
|
obliqueProjection,
|
|
67
67
|
terrainProvider,
|
|
68
68
|
);
|
|
69
|
-
obliqueDataSet.initialize(imageJson);
|
|
69
|
+
await obliqueDataSet.initialize(imageJson);
|
|
70
70
|
return obliqueDataSet;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -74,8 +74,8 @@ export function getObliqueDataSet(scope) {
|
|
|
74
74
|
* @param {Array<ObliqueDataSet>=} obliqueDataSets
|
|
75
75
|
* @returns {ObliqueCollection}
|
|
76
76
|
*/
|
|
77
|
-
export function getObliqueCollection(obliqueDataSets) {
|
|
78
|
-
const dataSets = obliqueDataSets || [getObliqueDataSet()];
|
|
77
|
+
export async function getObliqueCollection(obliqueDataSets) {
|
|
78
|
+
const dataSets = obliqueDataSets || [await getObliqueDataSet()];
|
|
79
79
|
const obliqueCollection = new ObliqueCollection({
|
|
80
80
|
name: 'obliqueCollection',
|
|
81
81
|
dataSets,
|
|
@@ -89,8 +89,8 @@ export function getObliqueCollection(obliqueDataSets) {
|
|
|
89
89
|
* @returns {Promise<ObliqueMap>}
|
|
90
90
|
*/
|
|
91
91
|
export async function getObliqueMap(mapOptions = {}, scope = undefined) {
|
|
92
|
-
const obliqueDataSet = getObliqueDataSet(scope);
|
|
93
|
-
const obliqueCollection = getObliqueCollection([obliqueDataSet]);
|
|
92
|
+
const obliqueDataSet = await getObliqueDataSet(scope);
|
|
93
|
+
const obliqueCollection = await getObliqueCollection([obliqueDataSet]);
|
|
94
94
|
const map = new ObliqueMap(mapOptions);
|
|
95
95
|
await map.initialize();
|
|
96
96
|
await map.setCollection(obliqueCollection);
|
|
@@ -37,11 +37,9 @@ export function setTerrainServer(scope) {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @param {Scope} scope
|
|
40
|
-
* @returns {cesium/CesiumTerrainProvider}
|
|
40
|
+
* @returns {Promise<cesium/CesiumTerrainProvider>}
|
|
41
41
|
*/
|
|
42
|
-
export function getTerrainProvider(scope) {
|
|
42
|
+
export async function getTerrainProvider(scope) {
|
|
43
43
|
setTerrainServer(scope);
|
|
44
|
-
return
|
|
45
|
-
url: 'http://localhost/terrain/',
|
|
46
|
-
});
|
|
44
|
+
return CesiumTerrainProvider.fromUrl('http://localhost/terrain/', {});
|
|
47
45
|
}
|