@loaders.gl/i3s 3.3.0-alpha.1 → 3.3.0-alpha.10
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/dist.min.js +1215 -1478
- package/dist/es5/arcgis-webscene-loader.js +2 -8
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +19 -59
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -10
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +18 -18
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +48 -80
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -12
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/index.js +12 -18
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +18 -78
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +3 -19
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +128 -30
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +1 -23
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +8 -25
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +90 -199
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +6 -37
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +0 -7
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/customizeColors.js +164 -0
- package/dist/es5/lib/utils/customizeColors.js.map +1 -0
- package/dist/es5/lib/utils/url-utils.js +3 -8
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +0 -3
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/workers/i3s-content-nodejs-worker.js +7 -0
- package/dist/es5/workers/i3s-content-nodejs-worker.js.map +1 -0
- package/dist/es5/workers/i3s-content-worker.js +0 -2
- package/dist/es5/workers/i3s-content-worker.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +3 -1
- package/dist/esm/arcgis-webscene-loader.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +9 -26
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +2 -3
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +13 -6
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +16 -24
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -2
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +2 -45
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +2 -11
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js +50 -11
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +1 -8
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +1 -4
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +60 -104
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +16 -18
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/esm/lib/utils/customizeColors.js +96 -0
- package/dist/esm/lib/utils/customizeColors.js.map +1 -0
- package/dist/esm/lib/utils/url-utils.js +5 -5
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +0 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/i3s-content-nodejs-worker.js +5 -0
- package/dist/esm/workers/i3s-content-nodejs-worker.js.map +1 -0
- package/dist/esm/workers/i3s-content-worker.js.map +1 -1
- package/dist/i3s-attribute-loader.d.ts +6 -0
- package/dist/i3s-attribute-loader.d.ts.map +1 -1
- package/dist/i3s-attribute-loader.js +2 -1
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +9 -4
- package/dist/i3s-content-nodejs-worker.js +201 -0
- package/dist/i3s-content-nodejs-worker.js.map +7 -0
- package/dist/i3s-content-worker.js +672 -1045
- package/dist/i3s-loader.d.ts +5 -0
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +12 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parsers/constants.js +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.js +49 -7
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +2 -2
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +38 -33
- 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 +1 -1
- package/dist/lib/utils/customizeColors.d.ts +14 -0
- package/dist/lib/utils/customizeColors.d.ts.map +1 -0
- package/dist/lib/utils/customizeColors.js +89 -0
- package/dist/types.d.ts +265 -85
- package/dist/types.d.ts.map +1 -1
- package/dist/workers/i3s-content-nodejs-worker.d.ts +2 -0
- package/dist/workers/i3s-content-nodejs-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-nodejs-worker.js +6 -0
- package/package.json +12 -12
- package/src/i3s-attribute-loader.ts +1 -1
- package/src/i3s-content-loader.ts +19 -6
- package/src/i3s-loader.ts +22 -13
- package/src/index.ts +8 -1
- package/src/lib/parsers/constants.ts +1 -1
- package/src/lib/parsers/parse-arcgis-webscene.ts +57 -7
- package/src/lib/parsers/parse-i3s-tile-content.ts +56 -43
- package/src/lib/parsers/parse-i3s.ts +1 -1
- package/src/lib/utils/customizeColors.ts +129 -0
- package/src/types.ts +198 -3
- package/src/workers/i3s-content-nodejs-worker.ts +5 -0
|
@@ -7,59 +7,58 @@ import { BasisLoader, CompressedTextureLoader } from '@loaders.gl/textures';
|
|
|
7
7
|
import { HeaderAttributeProperty } from '../../types';
|
|
8
8
|
import { getUrlWithToken } from '../utils/url-utils';
|
|
9
9
|
import { GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM } from './constants';
|
|
10
|
+
import { customizeColors } from '../utils/customizeColors';
|
|
10
11
|
const scratchVector = new Vector3([0, 0, 0]);
|
|
11
|
-
|
|
12
12
|
function getLoaderForTextureFormat(textureFormat) {
|
|
13
13
|
switch (textureFormat) {
|
|
14
14
|
case 'ktx-etc2':
|
|
15
15
|
case 'dds':
|
|
16
16
|
return CompressedTextureLoader;
|
|
17
|
-
|
|
18
17
|
case 'ktx2':
|
|
19
18
|
return BasisLoader;
|
|
20
|
-
|
|
21
19
|
case 'jpg':
|
|
22
20
|
case 'png':
|
|
23
21
|
default:
|
|
24
22
|
return ImageLoader;
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
29
|
-
export async function parseI3STileContent(arrayBuffer,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
export async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
27
|
+
const content = {
|
|
28
|
+
attributes: {},
|
|
29
|
+
indices: null,
|
|
30
|
+
featureIds: [],
|
|
31
|
+
vertexCount: 0,
|
|
32
|
+
modelMatrix: new Matrix4(),
|
|
33
|
+
coordinateSystem: 0,
|
|
34
|
+
byteLength: 0,
|
|
35
|
+
texture: null
|
|
36
|
+
};
|
|
37
|
+
if (tileOptions.textureUrl) {
|
|
35
38
|
var _options$i3s;
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const loader = getLoaderForTextureFormat(tile.textureFormat);
|
|
39
|
+
const url = getUrlWithToken(tileOptions.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
40
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
39
41
|
const response = await fetch(url, options === null || options === void 0 ? void 0 : options.fetch);
|
|
40
42
|
const arrayBuffer = await response.arrayBuffer();
|
|
41
|
-
|
|
42
43
|
if (options !== null && options !== void 0 && options.i3s.decodeTextures) {
|
|
43
44
|
if (loader === ImageLoader) {
|
|
44
|
-
const options = {
|
|
45
|
+
const options = {
|
|
46
|
+
...tileOptions.textureLoaderOptions,
|
|
45
47
|
image: {
|
|
46
48
|
type: 'data'
|
|
47
49
|
}
|
|
48
50
|
};
|
|
49
|
-
|
|
50
51
|
try {
|
|
51
|
-
|
|
52
|
+
content.texture = await context.parse(arrayBuffer, options);
|
|
52
53
|
} catch (e) {
|
|
53
|
-
|
|
54
|
+
content.texture = await parse(arrayBuffer, loader, options);
|
|
54
55
|
}
|
|
55
56
|
} else if (loader === CompressedTextureLoader || loader === BasisLoader) {
|
|
56
|
-
let texture = await load(arrayBuffer, loader,
|
|
57
|
-
|
|
57
|
+
let texture = await load(arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
58
58
|
if (loader === BasisLoader) {
|
|
59
59
|
texture = texture[0];
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
tile.content.texture = {
|
|
61
|
+
content.texture = {
|
|
63
62
|
compressed: true,
|
|
64
63
|
mipmaps: false,
|
|
65
64
|
width: texture[0].width,
|
|
@@ -68,37 +67,26 @@ export async function parseI3STileContent(arrayBuffer, tile, tileset, options, c
|
|
|
68
67
|
};
|
|
69
68
|
}
|
|
70
69
|
} else {
|
|
71
|
-
|
|
70
|
+
content.texture = arrayBuffer;
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (tile.content.material) {
|
|
78
|
-
tile.content.texture = null;
|
|
73
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
74
|
+
if (content.material) {
|
|
75
|
+
content.texture = null;
|
|
79
76
|
}
|
|
80
|
-
|
|
81
|
-
return await parseI3SNodeGeometry(arrayBuffer, tile, tileset, options);
|
|
77
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
async function parseI3SNodeGeometry(arrayBuffer,
|
|
80
|
+
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
85
81
|
var _options$i3s2;
|
|
86
|
-
|
|
87
|
-
if (!tile.content) {
|
|
88
|
-
return tile;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const content = tile.content;
|
|
92
82
|
const contentByteLength = arrayBuffer.byteLength;
|
|
93
83
|
let attributes;
|
|
94
84
|
let vertexCount;
|
|
95
85
|
let byteOffset = 0;
|
|
96
86
|
let featureCount = 0;
|
|
97
87
|
let indices;
|
|
98
|
-
|
|
99
|
-
if (tile.isDracoGeometry) {
|
|
88
|
+
if (tileOptions.isDracoGeometry) {
|
|
100
89
|
var _decompressedGeometry;
|
|
101
|
-
|
|
102
90
|
const decompressedGeometry = await parse(arrayBuffer, DracoLoader, {
|
|
103
91
|
draco: {
|
|
104
92
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
@@ -124,7 +112,6 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
124
112
|
};
|
|
125
113
|
updateAttributesMetadata(attributes, decompressedGeometry);
|
|
126
114
|
const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
|
|
127
|
-
|
|
128
115
|
if (featureIds) {
|
|
129
116
|
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
130
117
|
}
|
|
@@ -134,8 +121,8 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
134
121
|
ordering: attributesOrder,
|
|
135
122
|
featureAttributes,
|
|
136
123
|
featureAttributeOrder
|
|
137
|
-
} =
|
|
138
|
-
const headers = parseHeaders(
|
|
124
|
+
} = tilesetOptions.store.defaultGeometrySchema;
|
|
125
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
139
126
|
byteOffset = headers.byteOffset;
|
|
140
127
|
vertexCount = headers.vertexCount;
|
|
141
128
|
featureCount = headers.featureCount;
|
|
@@ -143,33 +130,33 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
143
130
|
attributes: normalizedVertexAttributes,
|
|
144
131
|
byteOffset: offset
|
|
145
132
|
} = normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder);
|
|
133
|
+
|
|
146
134
|
const {
|
|
147
135
|
attributes: normalizedFeatureAttributes
|
|
148
136
|
} = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder);
|
|
149
137
|
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
150
138
|
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
151
139
|
}
|
|
152
|
-
|
|
153
140
|
if (!(options !== null && options !== void 0 && (_options$i3s2 = options.i3s) !== null && _options$i3s2 !== void 0 && _options$i3s2.coordinateSystem) || options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
154
|
-
const enuMatrix = parsePositions(attributes.position,
|
|
141
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
155
142
|
content.modelMatrix = enuMatrix.invert();
|
|
156
143
|
content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;
|
|
157
144
|
} else {
|
|
158
145
|
content.modelMatrix = getModelMatrix(attributes.position);
|
|
159
146
|
content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;
|
|
160
147
|
}
|
|
161
|
-
|
|
148
|
+
attributes.color = await customizeColors(attributes.color, attributes.id, tileOptions, tilesetOptions, options);
|
|
162
149
|
content.attributes = {
|
|
163
150
|
positions: attributes.position,
|
|
164
151
|
normals: attributes.normal,
|
|
165
152
|
colors: normalizeAttribute(attributes.color),
|
|
166
153
|
texCoords: attributes.uv0,
|
|
167
|
-
uvRegions: normalizeAttribute(attributes.uvRegion)
|
|
154
|
+
uvRegions: normalizeAttribute(attributes.uvRegion || attributes.region)
|
|
168
155
|
};
|
|
169
|
-
content.indices = indices || null;
|
|
170
156
|
|
|
157
|
+
content.indices = indices || null;
|
|
171
158
|
if (attributes.id && attributes.id.value) {
|
|
172
|
-
|
|
159
|
+
content.featureIds = attributes.id.value;
|
|
173
160
|
}
|
|
174
161
|
|
|
175
162
|
for (const attributeIndex in content.attributes) {
|
|
@@ -177,25 +164,21 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
177
164
|
delete content.attributes[attributeIndex];
|
|
178
165
|
}
|
|
179
166
|
}
|
|
180
|
-
|
|
181
167
|
content.vertexCount = vertexCount;
|
|
182
168
|
content.byteLength = contentByteLength;
|
|
183
|
-
return
|
|
169
|
+
return content;
|
|
184
170
|
}
|
|
185
171
|
|
|
186
172
|
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
187
173
|
for (const key in decompressedGeometry.loaderData.attributes) {
|
|
188
174
|
const dracoAttribute = decompressedGeometry.loaderData.attributes[key];
|
|
189
|
-
|
|
190
175
|
switch (dracoAttribute.name) {
|
|
191
176
|
case 'POSITION':
|
|
192
177
|
attributes.position.metadata = dracoAttribute.metadata;
|
|
193
178
|
break;
|
|
194
|
-
|
|
195
179
|
case 'feature-index':
|
|
196
180
|
attributes.id.metadata = dracoAttribute.metadata;
|
|
197
181
|
break;
|
|
198
|
-
|
|
199
182
|
default:
|
|
200
183
|
break;
|
|
201
184
|
}
|
|
@@ -203,7 +186,8 @@ function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
|
203
186
|
}
|
|
204
187
|
|
|
205
188
|
function concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes) {
|
|
206
|
-
return {
|
|
189
|
+
return {
|
|
190
|
+
...normalizedVertexAttributes,
|
|
207
191
|
...normalizedFeatureAttributes
|
|
208
192
|
};
|
|
209
193
|
}
|
|
@@ -212,38 +196,31 @@ function normalizeAttribute(attribute) {
|
|
|
212
196
|
if (!attribute) {
|
|
213
197
|
return attribute;
|
|
214
198
|
}
|
|
215
|
-
|
|
216
199
|
attribute.normalized = true;
|
|
217
200
|
return attribute;
|
|
218
201
|
}
|
|
219
|
-
|
|
220
|
-
function parseHeaders(tileset, arrayBuffer) {
|
|
202
|
+
function parseHeaders(arrayBuffer, options) {
|
|
221
203
|
let byteOffset = 0;
|
|
222
204
|
let vertexCount = 0;
|
|
223
205
|
let featureCount = 0;
|
|
224
|
-
|
|
225
206
|
for (const {
|
|
226
207
|
property,
|
|
227
208
|
type
|
|
228
|
-
} of
|
|
209
|
+
} of options.store.defaultGeometrySchema.header) {
|
|
229
210
|
const TypedArrayTypeHeader = getConstructorForDataFormat(type);
|
|
230
|
-
|
|
231
211
|
switch (property) {
|
|
232
212
|
case HeaderAttributeProperty.vertexCount:
|
|
233
213
|
vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
|
|
234
214
|
byteOffset += sizeOf(type);
|
|
235
215
|
break;
|
|
236
|
-
|
|
237
216
|
case HeaderAttributeProperty.featureCount:
|
|
238
217
|
featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
|
|
239
218
|
byteOffset += sizeOf(type);
|
|
240
219
|
break;
|
|
241
|
-
|
|
242
220
|
default:
|
|
243
221
|
break;
|
|
244
222
|
}
|
|
245
223
|
}
|
|
246
|
-
|
|
247
224
|
return {
|
|
248
225
|
vertexCount,
|
|
249
226
|
featureCount,
|
|
@@ -260,42 +237,35 @@ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attribut
|
|
|
260
237
|
valueType,
|
|
261
238
|
valuesPerElement
|
|
262
239
|
} = vertexAttributes[attribute];
|
|
263
|
-
|
|
264
240
|
if (byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <= arrayBuffer.byteLength) {
|
|
265
241
|
const buffer = arrayBuffer.slice(byteOffset);
|
|
266
242
|
let value;
|
|
267
|
-
|
|
268
243
|
if (valueType === 'UInt64') {
|
|
269
244
|
value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));
|
|
270
245
|
} else {
|
|
271
246
|
const TypedArrayType = getConstructorForDataFormat(valueType);
|
|
272
247
|
value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
|
|
273
248
|
}
|
|
274
|
-
|
|
275
249
|
attributes[attribute] = {
|
|
276
250
|
value,
|
|
277
251
|
type: GL_TYPE_MAP[valueType],
|
|
278
252
|
size: valuesPerElement
|
|
279
253
|
};
|
|
280
|
-
|
|
281
254
|
switch (attribute) {
|
|
282
255
|
case 'color':
|
|
283
256
|
attributes.color.normalized = true;
|
|
284
257
|
break;
|
|
285
|
-
|
|
286
258
|
case 'position':
|
|
287
259
|
case 'region':
|
|
288
260
|
case 'normal':
|
|
289
261
|
default:
|
|
290
262
|
}
|
|
291
|
-
|
|
292
263
|
byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);
|
|
293
264
|
} else if (attribute !== 'uv0') {
|
|
294
265
|
break;
|
|
295
266
|
}
|
|
296
267
|
}
|
|
297
268
|
}
|
|
298
|
-
|
|
299
269
|
return {
|
|
300
270
|
attributes,
|
|
301
271
|
byteOffset
|
|
@@ -306,7 +276,6 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
306
276
|
const values = [];
|
|
307
277
|
const dataView = new DataView(buffer);
|
|
308
278
|
let offset = 0;
|
|
309
|
-
|
|
310
279
|
for (let index = 0; index < elementsCount; index++) {
|
|
311
280
|
const left = dataView.getUint32(offset, true);
|
|
312
281
|
const right = dataView.getUint32(offset + 4, true);
|
|
@@ -314,12 +283,10 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
314
283
|
values.push(value);
|
|
315
284
|
offset += attributeSize;
|
|
316
285
|
}
|
|
317
|
-
|
|
318
286
|
return new Uint32Array(values);
|
|
319
287
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const mbs = tile.mbs;
|
|
288
|
+
function parsePositions(attribute, options) {
|
|
289
|
+
const mbs = options.mbs;
|
|
323
290
|
const value = attribute.value;
|
|
324
291
|
const metadata = attribute.metadata;
|
|
325
292
|
const enuMatrix = new Matrix4();
|
|
@@ -331,30 +298,28 @@ function parsePositions(attribute, tile) {
|
|
|
331
298
|
return enuMatrix;
|
|
332
299
|
}
|
|
333
300
|
|
|
334
|
-
function offsetsToCartesians(vertices
|
|
301
|
+
function offsetsToCartesians(vertices) {
|
|
302
|
+
let metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
303
|
+
let cartographicOrigin = arguments.length > 2 ? arguments[2] : undefined;
|
|
335
304
|
const positions = new Float64Array(vertices.length);
|
|
336
305
|
const scaleX = metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double || 1;
|
|
337
306
|
const scaleY = metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double || 1;
|
|
338
|
-
|
|
339
307
|
for (let i = 0; i < positions.length; i += 3) {
|
|
340
308
|
positions[i] = vertices[i] * scaleX + cartographicOrigin.x;
|
|
341
309
|
positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;
|
|
342
310
|
positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;
|
|
343
311
|
}
|
|
344
|
-
|
|
345
312
|
for (let i = 0; i < positions.length; i += 3) {
|
|
346
313
|
Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);
|
|
347
314
|
positions[i] = scratchVector.x;
|
|
348
315
|
positions[i + 1] = scratchVector.y;
|
|
349
316
|
positions[i + 2] = scratchVector.z;
|
|
350
317
|
}
|
|
351
|
-
|
|
352
318
|
return positions;
|
|
353
319
|
}
|
|
354
320
|
|
|
355
321
|
function getModelMatrix(positions) {
|
|
356
322
|
var _metadata$i3sScale_x, _metadata$i3sScale_y;
|
|
357
|
-
|
|
358
323
|
const metadata = positions.metadata;
|
|
359
324
|
const scaleX = (metadata === null || metadata === void 0 ? void 0 : (_metadata$i3sScale_x = metadata['i3s-scale_x']) === null || _metadata$i3sScale_x === void 0 ? void 0 : _metadata$i3sScale_x.double) || 1;
|
|
360
325
|
const scaleY = (metadata === null || metadata === void 0 ? void 0 : (_metadata$i3sScale_y = metadata['i3s-scale_y']) === null || _metadata$i3sScale_y === void 0 ? void 0 : _metadata$i3sScale_y.double) || 1;
|
|
@@ -366,10 +331,11 @@ function getModelMatrix(positions) {
|
|
|
366
331
|
|
|
367
332
|
function makePbrMaterial(materialDefinition, texture) {
|
|
368
333
|
let pbrMaterial;
|
|
369
|
-
|
|
370
334
|
if (materialDefinition) {
|
|
371
|
-
pbrMaterial = {
|
|
372
|
-
|
|
335
|
+
pbrMaterial = {
|
|
336
|
+
...materialDefinition,
|
|
337
|
+
pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ? {
|
|
338
|
+
...materialDefinition.pbrMetallicRoughness
|
|
373
339
|
} : {
|
|
374
340
|
baseColorFactor: [255, 255, 255, 255]
|
|
375
341
|
}
|
|
@@ -378,7 +344,6 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
378
344
|
pbrMaterial = {
|
|
379
345
|
pbrMetallicRoughness: {}
|
|
380
346
|
};
|
|
381
|
-
|
|
382
347
|
if (texture) {
|
|
383
348
|
pbrMaterial.pbrMetallicRoughness.baseColorTexture = {
|
|
384
349
|
texCoord: 0
|
|
@@ -389,7 +354,6 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
389
354
|
}
|
|
390
355
|
|
|
391
356
|
pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;
|
|
392
|
-
|
|
393
357
|
if (pbrMaterial.alphaMode) {
|
|
394
358
|
pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();
|
|
395
359
|
}
|
|
@@ -397,25 +361,20 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
397
361
|
if (pbrMaterial.emissiveFactor) {
|
|
398
362
|
pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);
|
|
399
363
|
}
|
|
400
|
-
|
|
401
364
|
if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {
|
|
402
365
|
pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(pbrMaterial.pbrMetallicRoughness.baseColorFactor);
|
|
403
366
|
}
|
|
404
|
-
|
|
405
367
|
if (texture) {
|
|
406
368
|
setMaterialTexture(pbrMaterial, texture);
|
|
407
369
|
}
|
|
408
|
-
|
|
409
370
|
return pbrMaterial;
|
|
410
371
|
}
|
|
411
372
|
|
|
412
373
|
function convertColorFormat(colorFactor) {
|
|
413
374
|
const normalizedColor = [...colorFactor];
|
|
414
|
-
|
|
415
375
|
for (let index = 0; index < colorFactor.length; index++) {
|
|
416
376
|
normalizedColor[index] = colorFactor[index] / 255;
|
|
417
377
|
}
|
|
418
|
-
|
|
419
378
|
return normalizedColor;
|
|
420
379
|
}
|
|
421
380
|
|
|
@@ -425,25 +384,29 @@ function setMaterialTexture(material, image) {
|
|
|
425
384
|
image
|
|
426
385
|
}
|
|
427
386
|
};
|
|
428
|
-
|
|
429
387
|
if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {
|
|
430
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
388
|
+
material.pbrMetallicRoughness.baseColorTexture = {
|
|
389
|
+
...material.pbrMetallicRoughness.baseColorTexture,
|
|
431
390
|
texture
|
|
432
391
|
};
|
|
433
392
|
} else if (material.emissiveTexture) {
|
|
434
|
-
material.emissiveTexture = {
|
|
393
|
+
material.emissiveTexture = {
|
|
394
|
+
...material.emissiveTexture,
|
|
435
395
|
texture
|
|
436
396
|
};
|
|
437
397
|
} else if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
438
|
-
material.pbrMetallicRoughness.metallicRoughnessTexture = {
|
|
398
|
+
material.pbrMetallicRoughness.metallicRoughnessTexture = {
|
|
399
|
+
...material.pbrMetallicRoughness.metallicRoughnessTexture,
|
|
439
400
|
texture
|
|
440
401
|
};
|
|
441
402
|
} else if (material.normalTexture) {
|
|
442
|
-
material.normalTexture = {
|
|
403
|
+
material.normalTexture = {
|
|
404
|
+
...material.normalTexture,
|
|
443
405
|
texture
|
|
444
406
|
};
|
|
445
407
|
} else if (material.occlusionTexture) {
|
|
446
|
-
material.occlusionTexture = {
|
|
408
|
+
material.occlusionTexture = {
|
|
409
|
+
...material.occlusionTexture,
|
|
447
410
|
texture
|
|
448
411
|
};
|
|
449
412
|
}
|
|
@@ -454,18 +417,15 @@ function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
|
454
417
|
id,
|
|
455
418
|
faceRange
|
|
456
419
|
} = normalizedFeatureAttributes;
|
|
457
|
-
|
|
458
420
|
if (!id || !faceRange) {
|
|
459
421
|
return;
|
|
460
422
|
}
|
|
461
|
-
|
|
462
423
|
const featureIds = id.value;
|
|
463
424
|
const range = faceRange.value;
|
|
464
425
|
const featureIdsLength = range[range.length - 1] + 1;
|
|
465
426
|
const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
|
|
466
427
|
let featureIndex = 0;
|
|
467
428
|
let startIndex = 0;
|
|
468
|
-
|
|
469
429
|
for (let index = 1; index < range.length; index += 2) {
|
|
470
430
|
const fillId = Number(featureIds[featureIndex]);
|
|
471
431
|
const endValue = range[index];
|
|
@@ -476,24 +436,20 @@ function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
|
476
436
|
featureIndex++;
|
|
477
437
|
startIndex = endIndex;
|
|
478
438
|
}
|
|
479
|
-
|
|
480
439
|
normalizedFeatureAttributes.id.value = orderedFeatureIndices;
|
|
481
440
|
}
|
|
482
441
|
|
|
483
442
|
function flattenFeatureIdsByFeatureIndices(attributes, featureIds) {
|
|
484
443
|
const featureIndices = attributes.id.value;
|
|
485
444
|
const result = new Float32Array(featureIndices.length);
|
|
486
|
-
|
|
487
445
|
for (let index = 0; index < featureIndices.length; index++) {
|
|
488
446
|
result[index] = featureIds[featureIndices[index]];
|
|
489
447
|
}
|
|
490
|
-
|
|
491
448
|
attributes.id.value = result;
|
|
492
449
|
}
|
|
493
450
|
|
|
494
451
|
function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
|
|
495
452
|
var _featureIndex$metadat, _featureIndex$metadat2;
|
|
496
|
-
|
|
497
453
|
return featureIndex === null || featureIndex === void 0 ? void 0 : (_featureIndex$metadat = featureIndex.metadata) === null || _featureIndex$metadat === void 0 ? void 0 : (_featureIndex$metadat2 = _featureIndex$metadat['i3s-feature-ids']) === null || _featureIndex$metadat2 === void 0 ? void 0 : _featureIndex$metadat2.intArray;
|
|
498
454
|
}
|
|
499
455
|
//# sourceMappingURL=parse-i3s-tile-content.js.map
|