itowns 2.42.1-next.12 → 2.42.1-next.14
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/debug.js +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/lib/Core/Style.js +3 -4
- package/lib/Layer/C3DTilesLayer.js +4 -4
- package/lib/Main.js +18 -5
- package/lib/Parser/B3dmParser.js +70 -113
- package/lib/Parser/GLTFParser.js +103 -0
- package/lib/Provider/3dTilesProvider.js +18 -4
- package/lib/Source/C3DTilesGoogleSource.js +84 -0
- package/package.json +3 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _Fetcher = _interopRequireDefault(require("../Provider/Fetcher"));
|
|
9
|
+
var _C3DTilesSource = _interopRequireDefault(require("./C3DTilesSource"));
|
|
10
|
+
function findSessionId(tile) {
|
|
11
|
+
if (!tile) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (tile.content && tile.content.uri) {
|
|
15
|
+
const searchParams = new URLSearchParams(tile.content.uri.slice(tile.content.uri.indexOf('?') + 1));
|
|
16
|
+
return searchParams.get('session');
|
|
17
|
+
} else if (tile.children && tile.children.length > 0) {
|
|
18
|
+
for (const c of tile.children) {
|
|
19
|
+
const sessionId = findSessionId(c);
|
|
20
|
+
if (sessionId) {
|
|
21
|
+
return sessionId;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @classdesc
|
|
30
|
+
* An object defining the source connection to a 3DTiles asset from a [Google api](https://tile.googleapis.com).
|
|
31
|
+
*
|
|
32
|
+
* @extends C3DTilesSource
|
|
33
|
+
*
|
|
34
|
+
* @property {boolean} isC3DTilesGoogleSource - Used to checkout whether this source is a C3DTilesGoogleSource. Default is
|
|
35
|
+
* true. You should not change this, as it is used internally for optimisation.
|
|
36
|
+
* @property {string} url - The URL to the tileset json.
|
|
37
|
+
* @property {string} baseUrl - The base URL to access tiles.
|
|
38
|
+
*/
|
|
39
|
+
class C3DTilesGoogleSource extends _C3DTilesSource.default {
|
|
40
|
+
/**
|
|
41
|
+
* Create a new Source for 3D Tiles data from Google api (experimental).
|
|
42
|
+
*
|
|
43
|
+
* @constructor
|
|
44
|
+
* @extends C3DTilesSource
|
|
45
|
+
*
|
|
46
|
+
* @property {boolean} isC3DTilesGoogleSource - Used to checkout whether this source is a C3DTilesGoogleSource. Default is
|
|
47
|
+
* true. You should not change this, as it is used internally for optimisation.
|
|
48
|
+
* @param {Object} source An object that can contain all properties of a C3DTilesGoogleSource and {@link Source}.
|
|
49
|
+
* @param {String} source.key Your google tiles map API access key
|
|
50
|
+
*/
|
|
51
|
+
constructor(source) {
|
|
52
|
+
if (!source.key) {
|
|
53
|
+
throw new Error('[C3DTilesGoogleSource]: A API key for the google map tiles API is required');
|
|
54
|
+
}
|
|
55
|
+
// URL to the root tileset
|
|
56
|
+
source.url = `https://tile.googleapis.com/v1/3dtiles/root.json?key=${source.key}`;
|
|
57
|
+
super(source);
|
|
58
|
+
this.isC3DTilesGoogleSource = true;
|
|
59
|
+
this.baseUrl = 'https://tile.googleapis.com';
|
|
60
|
+
this.key = source.key;
|
|
61
|
+
this.whenReady = _Fetcher.default.json(source.url, this.networkOptions).then(json => {
|
|
62
|
+
if (json && json.root) {
|
|
63
|
+
this.sessionId = findSessionId(json.root);
|
|
64
|
+
if (this.sessionId === null) {
|
|
65
|
+
throw new Error('[C3DTilesGoogleSource]: Cannot find sessionId from the tileset while it is mandatory to request tiles.');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return json;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Adds the key and session to the tile url (non-standard behaviour, that is specific to Google 3D tiles),
|
|
74
|
+
* see https://github.com/CesiumGS/3d-tiles/issues/746
|
|
75
|
+
* @param {String} url the tile url
|
|
76
|
+
* @returns {String} the tile url with Google map tiles api key and session parameters added at the end of the url
|
|
77
|
+
*/
|
|
78
|
+
getTileUrl(url) {
|
|
79
|
+
const extraParameters = `key=${this.key}&session=${this.sessionId}`;
|
|
80
|
+
return /\?/.test(url) ? `${url}&${extraParameters}` : `${url}?${extraParameters}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
var _default = C3DTilesGoogleSource;
|
|
84
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itowns",
|
|
3
|
-
"version": "2.42.1-next.
|
|
3
|
+
"version": "2.42.1-next.14",
|
|
4
4
|
"description": "A JS/WebGL framework for 3D geospatial data visualization",
|
|
5
5
|
"main": "lib/Main.js",
|
|
6
6
|
"exports": {
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"@babel/preset-env": "^7.22.5",
|
|
77
77
|
"@babel/register": "^7.22.5",
|
|
78
78
|
"@types/three": "^0.159.0",
|
|
79
|
+
"@xmldom/xmldom": "^0.8.10",
|
|
79
80
|
"babel-inline-import-loader": "^1.0.1",
|
|
80
81
|
"babel-loader": "^9.1.3",
|
|
81
82
|
"babel-plugin-inline-import": "^3.0.0",
|
|
@@ -107,6 +108,7 @@
|
|
|
107
108
|
"puppeteer": "^21.6.0",
|
|
108
109
|
"q": "^1.5.1",
|
|
109
110
|
"replace-in-file": "^7.0.2",
|
|
111
|
+
"sinon": "^17.0.1",
|
|
110
112
|
"three": "^0.159.0",
|
|
111
113
|
"typescript": "^5.3.3",
|
|
112
114
|
"webpack": "^5.89.0",
|