Skip to content

Commit cd27426

Browse files
committed
Shovels in some cesium wasm and uses await for assetId URL
1 parent b387079 commit cd27426

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

bundles/mapping/tiles3d/plugin/Tiles3DLayerPlugin.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,12 @@ Oskari.clazz.define('Oskari.mapframework.mapmodule.Tiles3DLayerPlugin',
180180
if (!this.getMapModule().getSupports3D()) {
181181
return;
182182
}
183-
const options = layer.getOptions() || {};
184-
const { ionAssetId, ionAssetServer, ionAccessToken } = options;
185-
186-
const url = ionAssetId
187-
? Cesium.IonResource.fromAssetId(ionAssetId, { server: ionAssetServer, accessToken: ionAccessToken })
188-
: layer.getLayerUrl();
189-
190-
this.__addTileset(layer, url, options);
183+
// moved to own func because of async/await requirement
184+
this.__addTileset(layer);
191185
},
192-
__addTileset: async function (layer, url, options = {}) {
186+
__addTileset: async function (layer) {
187+
const options = layer.getOptions() || {};
188+
const url = await this.__getURL(layer, options);
193189
// Common settings for the dynamicScreenSpaceError optimization
194190
// copied from Cesium.Cesium3DTileset api doc:
195191
// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html
@@ -208,6 +204,21 @@ Oskari.clazz.define('Oskari.mapframework.mapmodule.Tiles3DLayerPlugin',
208204
// store reference to layers
209205
this.setOLMapLayers(layer.getId(), tileset);
210206
},
207+
__getURL: async function (layer, options) {
208+
const { ionAssetId, ionAssetServer, ionAccessToken } = options;
209+
if (!ionAssetId) {
210+
return layer.getLayerUrl();
211+
}
212+
const ionResourceOpts = {};
213+
if (ionAssetServer) {
214+
// check truthy, we might have empty string defined and Cesium only checks for null/undefined for defaulting.
215+
ionResourceOpts.server = ionAssetServer;
216+
}
217+
if (ionAccessToken) {
218+
ionResourceOpts.accessToken = ionAccessToken;
219+
}
220+
return Cesium.IonResource.fromAssetId(ionAssetId, ionResourceOpts);
221+
},
211222
/**
212223
* Called when layer details are updated (for example by the admin functionality)
213224
* @param {Oskari.mapframework.domain.AbstractLayer} layer new layer details

webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ module.exports = (env, argv) => {
3737
.forEach(possibleSrcPath => {
3838
plugins.push(new CopywebpackPlugin([
3939
{ from: path.join(__dirname, possibleSrcPath, '../Source/Assets'), to: cesiumTarget + '/Assets' },
40+
// This is not available under Build folder:
41+
// - oskari-frontend/node_modules/@cesium/engine/Source/ThirdParty/draco_decoder.wasm
42+
{ from: path.join(__dirname, possibleSrcPath, '../Source/ThirdParty'), to: cesiumTarget + '/ThirdParty' },
4043
{ from: path.join(__dirname, possibleSrcPath, 'Workers'), to: cesiumTarget + '/Workers' },
4144
// { from: path.join(__dirname, possibleSrcPath, 'Widgets'), to: cesiumTarget + '/Widgets' },
4245
// copy Cesium's minified third-party scripts

0 commit comments

Comments
 (0)