@loaders.gl/i3s 4.2.0-alpha.4 → 4.2.0-alpha.5
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/arcgis-webscene-loader.d.ts +1 -1
- package/dist/arcgis-webscene-loader.d.ts.map +1 -1
- package/dist/arcgis-webscene-loader.js +19 -10
- package/dist/dist.dev.js +1244 -731
- package/dist/dist.min.js +9 -0
- package/dist/i3s-attribute-loader.d.ts +2 -2
- package/dist/i3s-attribute-loader.d.ts.map +1 -1
- package/dist/i3s-attribute-loader.js +145 -94
- package/dist/i3s-building-scene-layer-loader.d.ts +2 -2
- package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -1
- package/dist/i3s-building-scene-layer-loader.js +17 -13
- package/dist/i3s-content-loader.d.ts +2 -2
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +23 -24
- package/dist/i3s-content-worker-node.js +1 -1
- package/dist/i3s-content-worker-node.js.map +2 -2
- package/dist/i3s-content-worker.js +3 -1
- package/dist/i3s-loader.d.ts +2 -2
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +76 -65
- package/dist/i3s-node-page-loader.d.ts +2 -2
- package/dist/i3s-node-page-loader.d.ts.map +1 -1
- package/dist/i3s-node-page-loader.js +16 -12
- package/dist/i3s-slpk-loader.js +18 -14
- package/dist/index.cjs +73 -138
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +1 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js +226 -184
- package/dist/lib/parsers/constants.js +72 -45
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.js +79 -59
- package/dist/lib/parsers/parse-i3s-attribute.js +83 -46
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js +36 -33
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +460 -394
- package/dist/lib/parsers/parse-i3s.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s.js +84 -81
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +1 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.js +23 -16
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js +132 -97
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js +12 -5
- package/dist/lib/utils/customize-colors.d.ts +1 -1
- package/dist/lib/utils/customize-colors.d.ts.map +1 -1
- package/dist/lib/utils/customize-colors.js +95 -81
- package/dist/lib/utils/url-utils.d.ts +1 -1
- package/dist/lib/utils/url-utils.d.ts.map +1 -1
- package/dist/lib/utils/url-utils.js +48 -28
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -6
- package/dist/workers/i3s-content-worker-node.js +1 -1
- package/dist/workers/i3s-content-worker.js +0 -1
- package/package.json +13 -12
- package/dist/arcgis-webscene-loader.js.map +0 -1
- package/dist/i3s-attribute-loader.js.map +0 -1
- package/dist/i3s-building-scene-layer-loader.js.map +0 -1
- package/dist/i3s-content-loader.js.map +0 -1
- package/dist/i3s-loader.js.map +0 -1
- package/dist/i3s-node-page-loader.js.map +0 -1
- package/dist/i3s-slpk-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
- package/dist/lib/parsers/constants.js.map +0 -1
- package/dist/lib/parsers/parse-arcgis-webscene.js.map +0 -1
- package/dist/lib/parsers/parse-i3s-attribute.js.map +0 -1
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js.map +0 -1
- package/dist/lib/parsers/parse-i3s.js.map +0 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.js.map +0 -1
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js.map +0 -1
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
- package/dist/lib/utils/customize-colors.js.map +0 -1
- package/dist/lib/utils/url-utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/workers/i3s-content-worker-node.js.map +0 -1
- package/dist/workers/i3s-content-worker.js.map +0 -1
|
@@ -3,199 +3,241 @@ import { getSupportedGPUTextureFormats, selectSupportedBasisFormat } from '@load
|
|
|
3
3
|
import { I3SNodePageLoader } from "../../i3s-node-page-loader.js";
|
|
4
4
|
import { normalizeTileNonUrlData } from "../parsers/parse-i3s.js";
|
|
5
5
|
import { getUrlWithToken, generateTilesetAttributeUrls } from "../utils/url-utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* class I3SNodePagesTiles - loads nodePages and form i3s tiles from them
|
|
8
|
+
*/
|
|
6
9
|
export default class I3SNodePagesTiles {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.lodSelectionMetricType = (_tileset$nodePages2 = tileset.nodePages) === null || _tileset$nodePages2 === void 0 ? void 0 : _tileset$nodePages2.lodSelectionMetricType;
|
|
27
|
-
this.options = options;
|
|
28
|
-
this.nodesInNodePages = 0;
|
|
29
|
-
this.initSelectedFormatsForTextureDefinitions(tileset);
|
|
30
|
-
}
|
|
31
|
-
async getNodeById(id) {
|
|
32
|
-
const pageIndex = Math.floor(id / this.nodesPerPage);
|
|
33
|
-
if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
|
|
34
|
-
var _this$options$i3s;
|
|
35
|
-
const nodePageUrl = getUrlWithToken(this.url.indexOf('.slpk') !== -1 ? `nodepages/${pageIndex}` : `${this.url}/nodepages/${pageIndex}`, (_this$options$i3s = this.options.i3s) === null || _this$options$i3s === void 0 ? void 0 : _this$options$i3s.token);
|
|
36
|
-
this.pendingNodePages[pageIndex] = {
|
|
37
|
-
status: 'Pending',
|
|
38
|
-
promise: load(nodePageUrl, I3SNodePageLoader, this.options)
|
|
39
|
-
};
|
|
40
|
-
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
41
|
-
this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
|
|
42
|
-
this.pendingNodePages[pageIndex].status = 'Done';
|
|
10
|
+
/**
|
|
11
|
+
* @constructs
|
|
12
|
+
* Create a I3SNodePagesTiles instance.
|
|
13
|
+
* @param tileset - i3s tileset header ('layers/0')
|
|
14
|
+
* @param url - tileset url
|
|
15
|
+
* @param options - i3s loader options
|
|
16
|
+
*/
|
|
17
|
+
constructor(tileset, url = '', options) {
|
|
18
|
+
this.nodePages = [];
|
|
19
|
+
this.pendingNodePages = [];
|
|
20
|
+
this.textureDefinitionsSelectedFormats = [];
|
|
21
|
+
this.textureLoaderOptions = {};
|
|
22
|
+
this.tileset = { ...tileset }; // spread the tileset to avoid circular reference
|
|
23
|
+
this.url = url;
|
|
24
|
+
this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;
|
|
25
|
+
this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.nodesInNodePages = 0;
|
|
28
|
+
this.initSelectedFormatsForTextureDefinitions(tileset);
|
|
43
29
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
let isDracoGeometry = false;
|
|
70
|
-
if (node && node.mesh) {
|
|
71
|
-
const {
|
|
72
|
-
url,
|
|
73
|
-
isDracoGeometry: isDracoGeometryResult
|
|
74
|
-
} = node.mesh.geometry && this.getContentUrl(node.mesh.geometry) || {
|
|
75
|
-
isDracoGeometry: false
|
|
76
|
-
};
|
|
77
|
-
contentUrl = url;
|
|
78
|
-
isDracoGeometry = isDracoGeometryResult;
|
|
79
|
-
const {
|
|
80
|
-
textureData,
|
|
81
|
-
materialDefinition: nodeMaterialDefinition
|
|
82
|
-
} = this.getInformationFromMaterial(node.mesh.material);
|
|
83
|
-
materialDefinition = nodeMaterialDefinition;
|
|
84
|
-
textureFormat = textureData.format || textureFormat;
|
|
85
|
-
if (textureData.name) {
|
|
86
|
-
textureUrl = `${this.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;
|
|
87
|
-
}
|
|
88
|
-
if (this.tileset.attributeStorageInfo) {
|
|
89
|
-
attributeUrls = generateTilesetAttributeUrls(this.tileset, this.url, node.mesh.attribute.resource);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const lodSelection = this.getLodSelection(node);
|
|
93
|
-
return normalizeTileNonUrlData({
|
|
94
|
-
id: id.toString(),
|
|
95
|
-
lodSelection,
|
|
96
|
-
obb: node.obb,
|
|
97
|
-
contentUrl,
|
|
98
|
-
textureUrl,
|
|
99
|
-
attributeUrls,
|
|
100
|
-
materialDefinition,
|
|
101
|
-
textureFormat,
|
|
102
|
-
textureLoaderOptions: this.textureLoaderOptions,
|
|
103
|
-
children,
|
|
104
|
-
isDracoGeometry
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
getContentUrl(meshGeometryData) {
|
|
108
|
-
let result = null;
|
|
109
|
-
const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
|
|
110
|
-
let geometryIndex = -1;
|
|
111
|
-
if (this.options.i3s && this.options.i3s.useDracoGeometry) {
|
|
112
|
-
geometryIndex = geometryDefinition.geometryBuffers.findIndex(buffer => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco');
|
|
30
|
+
/**
|
|
31
|
+
* Loads some nodePage and return a particular node from it
|
|
32
|
+
* @param id - id of node through all node pages
|
|
33
|
+
*/
|
|
34
|
+
async getNodeById(id) {
|
|
35
|
+
const pageIndex = Math.floor(id / this.nodesPerPage);
|
|
36
|
+
if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
|
|
37
|
+
const nodePageUrl = getUrlWithToken(this.url.indexOf('.slpk') !== -1
|
|
38
|
+
? `nodepages/${pageIndex}`
|
|
39
|
+
: `${this.url}/nodepages/${pageIndex}`,
|
|
40
|
+
// @ts-expect-error this.options is not properly typed
|
|
41
|
+
this.options.i3s?.token);
|
|
42
|
+
this.pendingNodePages[pageIndex] = {
|
|
43
|
+
status: 'Pending',
|
|
44
|
+
promise: load(nodePageUrl, I3SNodePageLoader, this.options)
|
|
45
|
+
};
|
|
46
|
+
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
47
|
+
this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
|
|
48
|
+
this.pendingNodePages[pageIndex].status = 'Done';
|
|
49
|
+
}
|
|
50
|
+
if (this.pendingNodePages[pageIndex].status === 'Pending') {
|
|
51
|
+
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
52
|
+
}
|
|
53
|
+
const nodeIndex = id % this.nodesPerPage;
|
|
54
|
+
return this.nodePages[pageIndex].nodes[nodeIndex];
|
|
113
55
|
}
|
|
114
|
-
|
|
115
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Forms tile header using node and tileset data
|
|
58
|
+
* @param id - id of node through all node pages
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line complexity, max-statements
|
|
61
|
+
async formTileFromNodePages(id) {
|
|
62
|
+
const node = await this.getNodeById(id);
|
|
63
|
+
const children = [];
|
|
64
|
+
const childNodesPromises = [];
|
|
65
|
+
for (const child of node.children || []) {
|
|
66
|
+
childNodesPromises.push(this.getNodeById(child));
|
|
67
|
+
}
|
|
68
|
+
const childNodes = await Promise.all(childNodesPromises);
|
|
69
|
+
for (const childNode of childNodes) {
|
|
70
|
+
children.push({
|
|
71
|
+
id: childNode.index.toString(),
|
|
72
|
+
obb: childNode.obb
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
let contentUrl;
|
|
76
|
+
let textureUrl;
|
|
77
|
+
let materialDefinition;
|
|
78
|
+
let textureFormat = 'jpg';
|
|
79
|
+
let attributeUrls = [];
|
|
80
|
+
let isDracoGeometry = false;
|
|
81
|
+
if (node && node.mesh) {
|
|
82
|
+
// Get geometry resource URL and type (compressed / non-compressed)
|
|
83
|
+
const { url, isDracoGeometry: isDracoGeometryResult } = (node.mesh.geometry &&
|
|
84
|
+
this.getContentUrl(node.mesh.geometry)) || { isDracoGeometry: false };
|
|
85
|
+
contentUrl = url;
|
|
86
|
+
isDracoGeometry = isDracoGeometryResult;
|
|
87
|
+
const { textureData, materialDefinition: nodeMaterialDefinition } = this.getInformationFromMaterial(node.mesh.material);
|
|
88
|
+
materialDefinition = nodeMaterialDefinition;
|
|
89
|
+
textureFormat = textureData.format || textureFormat;
|
|
90
|
+
if (textureData.name) {
|
|
91
|
+
textureUrl = `${this.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;
|
|
92
|
+
}
|
|
93
|
+
if (this.tileset.attributeStorageInfo) {
|
|
94
|
+
attributeUrls = generateTilesetAttributeUrls(this.tileset, this.url, node.mesh.attribute.resource);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const lodSelection = this.getLodSelection(node);
|
|
98
|
+
return normalizeTileNonUrlData({
|
|
99
|
+
id: id.toString(),
|
|
100
|
+
lodSelection,
|
|
101
|
+
obb: node.obb,
|
|
102
|
+
contentUrl,
|
|
103
|
+
textureUrl,
|
|
104
|
+
attributeUrls,
|
|
105
|
+
materialDefinition,
|
|
106
|
+
textureFormat,
|
|
107
|
+
textureLoaderOptions: this.textureLoaderOptions,
|
|
108
|
+
children,
|
|
109
|
+
isDracoGeometry
|
|
110
|
+
});
|
|
116
111
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset
|
|
114
|
+
* @param - data about the node's mesh from the nodepage
|
|
115
|
+
* @returns -
|
|
116
|
+
* {string} url - url to the geometry resource
|
|
117
|
+
* {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry
|
|
118
|
+
*/
|
|
119
|
+
getContentUrl(meshGeometryData) {
|
|
120
|
+
let result = null;
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
|
|
123
|
+
let geometryIndex = -1;
|
|
124
|
+
// Try to find DRACO geometryDefinition of `useDracoGeometry` option is set
|
|
125
|
+
// @ts-expect-error this.options is not properly typed
|
|
126
|
+
if (this.options.i3s && this.options.i3s.useDracoGeometry) {
|
|
127
|
+
geometryIndex = geometryDefinition.geometryBuffers.findIndex((buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco');
|
|
128
|
+
}
|
|
129
|
+
// If DRACO geometry is not applicable try to select non-compressed geometry
|
|
130
|
+
if (geometryIndex === -1) {
|
|
131
|
+
geometryIndex = geometryDefinition.geometryBuffers.findIndex((buffer) => !buffer.compressedAttributes);
|
|
132
|
+
}
|
|
133
|
+
if (geometryIndex !== -1) {
|
|
134
|
+
const isDracoGeometry = Boolean(geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes);
|
|
135
|
+
result = {
|
|
136
|
+
url: `${this.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,
|
|
137
|
+
isDracoGeometry
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
123
141
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Forms 1.6 compatible LOD selection object from a nodepage's node data
|
|
144
|
+
* @param node - a node from nodepage
|
|
145
|
+
* @returns- Array of LodSelection
|
|
146
|
+
*/
|
|
147
|
+
getLodSelection(node) {
|
|
148
|
+
const lodSelection = [];
|
|
149
|
+
if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {
|
|
150
|
+
lodSelection.push({
|
|
151
|
+
metricType: 'maxScreenThreshold',
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
lodSelection.push({
|
|
157
|
+
metricType: this.lodSelectionMetricType,
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
maxError: node.lodThreshold
|
|
160
|
+
});
|
|
161
|
+
return lodSelection;
|
|
133
162
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
name: null
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Returns information about texture and material from `materialDefinitions`
|
|
165
|
+
* @param material - material data from nodepage
|
|
166
|
+
* @returns - Couple {textureData, materialDefinition}
|
|
167
|
+
* {string} textureData.name - path name of the texture
|
|
168
|
+
* {string} textureData.format - format of the texture
|
|
169
|
+
* materialDefinition - PBR-like material definition from `materialDefinitions`
|
|
170
|
+
*/
|
|
171
|
+
getInformationFromMaterial(material) {
|
|
172
|
+
const informationFromMaterial = { textureData: { name: null } };
|
|
173
|
+
if (material) {
|
|
174
|
+
const materialDefinition = this.tileset.materialDefinitions?.[material.definition];
|
|
175
|
+
if (materialDefinition) {
|
|
176
|
+
informationFromMaterial.materialDefinition = materialDefinition;
|
|
177
|
+
const textureSetDefinitionIndex = materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;
|
|
178
|
+
if (typeof textureSetDefinitionIndex === 'number') {
|
|
179
|
+
informationFromMaterial.textureData =
|
|
180
|
+
this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||
|
|
181
|
+
informationFromMaterial.textureData;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
155
184
|
}
|
|
156
|
-
|
|
185
|
+
return informationFromMaterial;
|
|
157
186
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
187
|
+
/**
|
|
188
|
+
* Sets preferable and supported format for each textureDefinition of the tileset
|
|
189
|
+
* @param tileset - I3S layer data
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
initSelectedFormatsForTextureDefinitions(tileset) {
|
|
193
|
+
this.textureDefinitionsSelectedFormats = [];
|
|
194
|
+
const possibleI3sFormats = this.getSupportedTextureFormats();
|
|
195
|
+
const textureSetDefinitions = tileset.textureSetDefinitions || [];
|
|
196
|
+
for (const textureSetDefinition of textureSetDefinitions) {
|
|
197
|
+
const formats = (textureSetDefinition && textureSetDefinition.formats) || [];
|
|
198
|
+
let selectedFormat = null;
|
|
199
|
+
for (const i3sFormat of possibleI3sFormats) {
|
|
200
|
+
const format = formats.find((value) => value.format === i3sFormat);
|
|
201
|
+
if (format) {
|
|
202
|
+
selectedFormat = format;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// For I3S 1.8 need to define basis target format to decode
|
|
207
|
+
if (selectedFormat && selectedFormat.format === 'ktx2') {
|
|
208
|
+
this.textureLoaderOptions.basis = {
|
|
209
|
+
format: selectSupportedBasisFormat(),
|
|
210
|
+
containerFormat: 'ktx2',
|
|
211
|
+
module: 'encoder'
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
this.textureDefinitionsSelectedFormats.push(selectedFormat);
|
|
172
215
|
}
|
|
173
|
-
}
|
|
174
|
-
if (selectedFormat && selectedFormat.format === 'ktx2') {
|
|
175
|
-
this.textureLoaderOptions.basis = {
|
|
176
|
-
format: selectSupportedBasisFormat(),
|
|
177
|
-
containerFormat: 'ktx2',
|
|
178
|
-
module: 'encoder'
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
this.textureDefinitionsSelectedFormats.push(selectedFormat);
|
|
182
216
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Returns the array of supported texture format
|
|
219
|
+
* @returns list of format strings
|
|
220
|
+
*/
|
|
221
|
+
getSupportedTextureFormats() {
|
|
222
|
+
const formats = [];
|
|
223
|
+
// @ts-expect-error this.options is not properly typed
|
|
224
|
+
if (!this.options.i3s || this.options.i3s.useCompressedTextures) {
|
|
225
|
+
// I3S 1.7 selection
|
|
226
|
+
const supportedCompressedFormats = getSupportedGPUTextureFormats();
|
|
227
|
+
// List of possible in i3s formats:
|
|
228
|
+
// https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
|
|
229
|
+
if (supportedCompressedFormats.has('etc2')) {
|
|
230
|
+
formats.push('ktx-etc2');
|
|
231
|
+
}
|
|
232
|
+
if (supportedCompressedFormats.has('dxt')) {
|
|
233
|
+
formats.push('dds');
|
|
234
|
+
}
|
|
235
|
+
// I3S 1.8 selection
|
|
236
|
+
// ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image
|
|
237
|
+
formats.push('ktx2');
|
|
238
|
+
}
|
|
239
|
+
formats.push('jpg');
|
|
240
|
+
formats.push('png');
|
|
241
|
+
return formats;
|
|
195
242
|
}
|
|
196
|
-
formats.push('jpg');
|
|
197
|
-
formats.push('png');
|
|
198
|
-
return formats;
|
|
199
|
-
}
|
|
200
243
|
}
|
|
201
|
-
//# sourceMappingURL=i3s-nodepages-tiles.js.map
|
|
@@ -1,56 +1,83 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { GL } from '@loaders.gl/math';
|
|
2
5
|
export function getConstructorForDataFormat(dataType) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
switch (dataType) {
|
|
7
|
+
case 'UInt8':
|
|
8
|
+
return Uint8Array;
|
|
9
|
+
case 'UInt16':
|
|
10
|
+
return Uint16Array;
|
|
11
|
+
case 'UInt32':
|
|
12
|
+
return Uint32Array;
|
|
13
|
+
case 'Float32':
|
|
14
|
+
return Float32Array;
|
|
15
|
+
case 'UInt64':
|
|
16
|
+
return Float64Array;
|
|
17
|
+
default:
|
|
18
|
+
throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
export const GL_TYPE_MAP = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
UInt8: GL.UNSIGNED_BYTE,
|
|
23
|
+
UInt16: GL.UNSIGNED_SHORT,
|
|
24
|
+
Float32: GL.FLOAT,
|
|
25
|
+
UInt32: GL.UNSIGNED_INT,
|
|
26
|
+
UInt64: GL.DOUBLE
|
|
24
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Returns how many bytes a type occupies
|
|
30
|
+
* @param dataType
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
25
33
|
export function sizeOf(dataType) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
switch (dataType) {
|
|
35
|
+
case 'UInt8':
|
|
36
|
+
return 1;
|
|
37
|
+
case 'UInt16':
|
|
38
|
+
case 'Int16':
|
|
39
|
+
return 2;
|
|
40
|
+
case 'UInt32':
|
|
41
|
+
case 'Int32':
|
|
42
|
+
case 'Float32':
|
|
43
|
+
return 4;
|
|
44
|
+
case 'UInt64':
|
|
45
|
+
case 'Int64':
|
|
46
|
+
case 'Float64':
|
|
47
|
+
return 8;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
52
|
export const STRING_ATTRIBUTE_TYPE = 'String';
|
|
45
53
|
export const OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';
|
|
46
54
|
export const FLOAT_64_TYPE = 'Float64';
|
|
47
55
|
export const INT_16_ATTRIBUTE_TYPE = 'Int16';
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
// https://github.com/visgl/deck.gl/blob/9548f43cba2234a1f4877b6b17f6c88eb35b2e08/modules/core/src/lib/constants.js#L27
|
|
57
|
+
// Describes the format of positions
|
|
58
|
+
export var COORDINATE_SYSTEM;
|
|
59
|
+
(function (COORDINATE_SYSTEM) {
|
|
60
|
+
/**
|
|
61
|
+
* `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
|
|
62
|
+
*/
|
|
63
|
+
COORDINATE_SYSTEM[COORDINATE_SYSTEM["DEFAULT"] = -1] = "DEFAULT";
|
|
64
|
+
/**
|
|
65
|
+
* Positions are interpreted as [lng, lat, elevation]
|
|
66
|
+
* lng lat are degrees, elevation is meters. distances as meters.
|
|
67
|
+
*/
|
|
68
|
+
COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT"] = 1] = "LNGLAT";
|
|
69
|
+
/**
|
|
70
|
+
* Positions are interpreted as meter offsets, distances as meters
|
|
71
|
+
*/
|
|
72
|
+
COORDINATE_SYSTEM[COORDINATE_SYSTEM["METER_OFFSETS"] = 2] = "METER_OFFSETS";
|
|
73
|
+
/**
|
|
74
|
+
* Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]
|
|
75
|
+
* deltaLng, deltaLat are delta degrees, elevation is meters.
|
|
76
|
+
* distances as meters.
|
|
77
|
+
*/
|
|
78
|
+
COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
|
|
79
|
+
/**
|
|
80
|
+
* Non-geospatial
|
|
81
|
+
*/
|
|
82
|
+
COORDINATE_SYSTEM[COORDINATE_SYSTEM["CARTESIAN"] = 0] = "CARTESIAN";
|
|
83
|
+
})(COORDINATE_SYSTEM || (COORDINATE_SYSTEM = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-arcgis-webscene.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-arcgis-webscene.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAmB,
|
|
1
|
+
{"version":3,"file":"parse-arcgis-webscene.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-arcgis-webscene.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAmB,uBAAoB;AA2BtE;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAG1B,OAAO,EAAE,OAAO;gBADvB,OAAO,EAAE,MAAM,EACR,OAAO,EAAE,OAAO;CAK1B;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAclF"}
|