• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iTowns / itowns / 5691913681

pending completion
5691913681

push

github

mgermerie
chore: update three to r154

3933 of 5864 branches covered (67.07%)

Branch coverage included in aggregate %.

7778 of 9456 relevant lines covered (82.25%)

1619.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.45
/src/Source/C3DTilesIonSource.js
1
import Fetcher from 'Provider/Fetcher';
1✔
2
import C3DTilesSource from './C3DTilesSource';
6✔
3

4
/**
5
 * @classdesc
6
 * An object defining the source connection to a 3DTiles asset of a [Cesium ion server](https://cesium.com/learn/ion/).
7
 *
8
 * @extends Source
9
 *
10
 * @property {boolean} isC3DTilesIonSource - Used to checkout whether this source is a C3DTilesIonSource. Default is
11
 * true. You should not change this, as it is used internally for optimisation.
12
 * @property {string} url - The URL of the tileset json.
13
 * @property {string} baseUrl - The base URL to access tiles.
14
 * @property {string} accessToken - The Cesium ion access token used to retrieve the resource.
15
 * @property {string} assetId - The id of the asset on Cesium ion.
16
 */
17
class C3DTilesIonSource extends C3DTilesSource {
2✔
18
    /**
19
     * Create a new Source for 3D Tiles data from Cesium ion.
20
     *
21
     * @constructor
22
     * @extends Source
23
     *
24
     * @param {Object} source An object that can contain all properties of a C3DTilesIonSource and {@link Source}.
25
     * Only `accessToken` and `assetId` are mandatory.
26
     */
27
    constructor(source) {
3✔
28
        if (!source.accessToken) {
3✔
29
            throw new Error('New 3D Tiles Ion Source: access token is required');
2✔
30
        }
31
        if (!source.assetId) {
1!
32
            throw new Error('New 3D Tiles Ion Source: asset id is required');
1✔
33
        }
34

35
        // Url to query cesium ion the first time to retrieve metadata of the asset with assetId
36
        source.url = `https://api.cesium.com/v1/assets/${source.assetId}/endpoint?access_token=${source.accessToken}`;
×
37
        super(source);
×
38

39
        this.isC3DTilesIonSource = true;
×
40
        this.accessToken = source.accessToken;
×
41
        this.assetId = source.assetId;
×
42

43
        // get asset metadata
44
        this.whenReady = Fetcher.json(source.url, this.networkOptions)
×
45
            .then((json) => {
46
                if (json.type !== '3DTILES') {
×
47
                    throw new Error(`${json.type} datasets from Cesium ion are not supported with C3DTilesIonSource. ` +
×
48
                    'Only 3D Tiles datasets are supported.');
49
                }
50
                this.url = json.url; // Store url to the tileset.json
×
51
                this.baseUrl = json.url.slice(0, json.url.lastIndexOf('/') + 1); // baseUrl for tiles queries
×
52
                this.networkOptions.headers = {};
×
53
                this.networkOptions.headers.Authorization = `Bearer ${json.accessToken}`;
×
54
                this.attribution = json.attributions;
×
55
                return Fetcher.json(this.url, this.networkOptions);
×
56
            });
×
57
    }
1✔
58
}
59

60
export default C3DTilesIonSource;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc