forked from radiantearth/stac-browser
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCesium.js
More file actions
43 lines (37 loc) · 1.24 KB
/
Cesium.js
File metadata and controls
43 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import LinkActionPlugin from "../LinkActionPlugin";
import URI from 'urijs';
import i18n from "../../i18n";
export default class Cesium extends LinkActionPlugin {
get show() {
return this.link.rel === '3d-tiles';
}
get uri() {
// https://sandcastle.cesium.com/standalone.html vs https://sandcastle.cesium.com/index.html
let uri = new URI("https://sandcastle.cesium.com/standalone.html");
const tileset_url = this.link.href;
const code_payload = {
html: `
<style> @import url(../templates/bucket.css); </style>
<div id="cesiumContainer" class="fullSize"></div>
`,
code: `
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldTerrain(),
});
try {
const tileset = await Cesium.Cesium3DTileset.fromUrl('${tileset_url}');
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset);
} catch (error) {
console.log('Error loading tileset');
}
`.replaceAll(' ', '')
};
const code_str = btoa(JSON.stringify(code_payload));
uri.addQuery('code', code_str);
return uri;
}
get text() {
return i18n.t('actions.openIn', {service: 'Cesium Sandcastle'});
}
}