@loaders.gl/i3s 3.2.6 → 3.3.0-alpha.2
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 +62 -55
- package/dist/es5/arcgis-webscene-loader.js +1 -1
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +19 -8
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +36 -38
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -1
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +76 -77
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +1 -1
- package/dist/esm/arcgis-webscene-loader.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +12 -4
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +8 -12
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +37 -34
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-building-scene-layer-loader.js +1 -1
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +8 -4
- package/dist/i3s-content-worker.js +56 -48
- package/dist/i3s-loader.d.ts +5 -0
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +6 -9
- 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 +36 -32
- 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/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/i3s-building-scene-layer-loader.ts +1 -1
- package/src/i3s-content-loader.ts +18 -6
- package/src/i3s-loader.ts +15 -12
- package/src/lib/parsers/parse-i3s-tile-content.ts +46 -41
- package/src/lib/parsers/parse-i3s.ts +1 -1
- package/src/types.ts +45 -0
|
@@ -8,15 +8,16 @@ import {DracoLoader, DracoMesh} from '@loaders.gl/draco';
|
|
|
8
8
|
import {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
I3STilesetHeader,
|
|
12
|
-
I3STileHeader,
|
|
13
11
|
FeatureAttribute,
|
|
14
12
|
VertexAttribute,
|
|
15
13
|
I3SMeshAttributes,
|
|
16
14
|
I3SMeshAttribute,
|
|
17
15
|
TileContentTexture,
|
|
18
16
|
HeaderAttributeProperty,
|
|
19
|
-
I3SMaterialDefinition
|
|
17
|
+
I3SMaterialDefinition,
|
|
18
|
+
I3STileContent,
|
|
19
|
+
I3STileOptions,
|
|
20
|
+
I3STilesetOptions
|
|
20
21
|
} from '../../types';
|
|
21
22
|
import {getUrlWithToken} from '../utils/url-utils';
|
|
22
23
|
|
|
@@ -40,43 +41,51 @@ function getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' |
|
|
|
40
41
|
|
|
41
42
|
const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
42
43
|
|
|
44
|
+
const defaultContent: I3STileContent = {
|
|
45
|
+
attributes: {},
|
|
46
|
+
indices: null,
|
|
47
|
+
featureIds: [],
|
|
48
|
+
vertexCount: 0,
|
|
49
|
+
modelMatrix: new Matrix4(),
|
|
50
|
+
coordinateSystem: 0,
|
|
51
|
+
byteLength: 0,
|
|
52
|
+
texture: null
|
|
53
|
+
};
|
|
54
|
+
|
|
43
55
|
export async function parseI3STileContent(
|
|
44
56
|
arrayBuffer: ArrayBuffer,
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
tileOptions: I3STileOptions,
|
|
58
|
+
tilesetOptions: I3STilesetOptions,
|
|
47
59
|
options?: LoaderOptions,
|
|
48
60
|
context?: LoaderContext
|
|
49
|
-
) {
|
|
50
|
-
|
|
51
|
-
tile.content.featureIds = tile.content.featureIds || null;
|
|
52
|
-
|
|
53
|
-
tile.content.attributes = {};
|
|
61
|
+
): Promise<I3STileContent> {
|
|
62
|
+
const content: I3STileContent = defaultContent;
|
|
54
63
|
|
|
55
|
-
if (
|
|
56
|
-
const url = getUrlWithToken(
|
|
57
|
-
const loader = getLoaderForTextureFormat(
|
|
64
|
+
if (tileOptions.textureUrl) {
|
|
65
|
+
const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);
|
|
66
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
58
67
|
const response = await fetch(url, options?.fetch as RequestInit);
|
|
59
68
|
const arrayBuffer = await response.arrayBuffer();
|
|
60
69
|
|
|
61
70
|
if (options?.i3s.decodeTextures) {
|
|
62
71
|
if (loader === ImageLoader) {
|
|
63
|
-
const options = {...
|
|
72
|
+
const options = {...tileOptions.textureLoaderOptions, image: {type: 'data'}};
|
|
64
73
|
try {
|
|
65
74
|
// @ts-ignore context must be defined
|
|
66
75
|
// Image constructor is not supported in worker thread.
|
|
67
76
|
// Do parsing image data on the main thread by using context to avoid worker issues.
|
|
68
|
-
|
|
77
|
+
content.texture = await context.parse(arrayBuffer, options);
|
|
69
78
|
} catch (e) {
|
|
70
79
|
// context object is different between worker and node.js conversion script.
|
|
71
80
|
// To prevent error we parse data in ordinary way if it is not parsed by using context.
|
|
72
|
-
|
|
81
|
+
content.texture = await parse(arrayBuffer, loader, options);
|
|
73
82
|
}
|
|
74
83
|
} else if (loader === CompressedTextureLoader || loader === BasisLoader) {
|
|
75
|
-
let texture = await load(arrayBuffer, loader,
|
|
84
|
+
let texture = await load(arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
76
85
|
if (loader === BasisLoader) {
|
|
77
86
|
texture = texture[0];
|
|
78
87
|
}
|
|
79
|
-
|
|
88
|
+
content.texture = {
|
|
80
89
|
compressed: true,
|
|
81
90
|
mipmaps: false,
|
|
82
91
|
width: texture[0].width,
|
|
@@ -85,30 +94,26 @@ export async function parseI3STileContent(
|
|
|
85
94
|
};
|
|
86
95
|
}
|
|
87
96
|
} else {
|
|
88
|
-
|
|
97
|
+
content.texture = arrayBuffer;
|
|
89
98
|
}
|
|
90
99
|
}
|
|
91
100
|
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
101
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
102
|
+
if (content.material) {
|
|
103
|
+
content.texture = null;
|
|
95
104
|
}
|
|
96
105
|
|
|
97
|
-
return await parseI3SNodeGeometry(arrayBuffer,
|
|
106
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
/* eslint-disable max-statements */
|
|
101
110
|
async function parseI3SNodeGeometry(
|
|
102
111
|
arrayBuffer: ArrayBuffer,
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
content: I3STileContent,
|
|
113
|
+
tileOptions: I3STileOptions,
|
|
114
|
+
tilesetOptions: I3STilesetOptions,
|
|
105
115
|
options?: LoaderOptions
|
|
106
|
-
) {
|
|
107
|
-
if (!tile.content) {
|
|
108
|
-
return tile;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const content = tile.content;
|
|
116
|
+
): Promise<I3STileContent> {
|
|
112
117
|
const contentByteLength = arrayBuffer.byteLength;
|
|
113
118
|
let attributes: I3SMeshAttributes;
|
|
114
119
|
let vertexCount: number;
|
|
@@ -116,7 +121,7 @@ async function parseI3SNodeGeometry(
|
|
|
116
121
|
let featureCount: number = 0;
|
|
117
122
|
let indices: TypedArray | undefined;
|
|
118
123
|
|
|
119
|
-
if (
|
|
124
|
+
if (tileOptions.isDracoGeometry) {
|
|
120
125
|
const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {
|
|
121
126
|
draco: {
|
|
122
127
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
@@ -156,9 +161,9 @@ async function parseI3SNodeGeometry(
|
|
|
156
161
|
ordering: attributesOrder,
|
|
157
162
|
featureAttributes,
|
|
158
163
|
featureAttributeOrder
|
|
159
|
-
} =
|
|
164
|
+
} = tilesetOptions.store.defaultGeometrySchema;
|
|
160
165
|
// First 8 bytes reserved for header (vertexCount and featureCount)
|
|
161
|
-
const headers = parseHeaders(
|
|
166
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
162
167
|
byteOffset = headers.byteOffset;
|
|
163
168
|
vertexCount = headers.vertexCount;
|
|
164
169
|
featureCount = headers.featureCount;
|
|
@@ -188,7 +193,7 @@ async function parseI3SNodeGeometry(
|
|
|
188
193
|
!options?.i3s?.coordinateSystem ||
|
|
189
194
|
options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS
|
|
190
195
|
) {
|
|
191
|
-
const enuMatrix = parsePositions(attributes.position,
|
|
196
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
192
197
|
content.modelMatrix = enuMatrix.invert();
|
|
193
198
|
content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;
|
|
194
199
|
} else {
|
|
@@ -206,7 +211,7 @@ async function parseI3SNodeGeometry(
|
|
|
206
211
|
content.indices = indices || null;
|
|
207
212
|
|
|
208
213
|
if (attributes.id && attributes.id.value) {
|
|
209
|
-
|
|
214
|
+
content.featureIds = attributes.id.value;
|
|
210
215
|
}
|
|
211
216
|
|
|
212
217
|
// Remove undefined attributes
|
|
@@ -219,7 +224,7 @@ async function parseI3SNodeGeometry(
|
|
|
219
224
|
content.vertexCount = vertexCount;
|
|
220
225
|
content.byteLength = contentByteLength;
|
|
221
226
|
|
|
222
|
-
return
|
|
227
|
+
return content;
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
/**
|
|
@@ -274,12 +279,12 @@ function normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {
|
|
|
274
279
|
return attribute;
|
|
275
280
|
}
|
|
276
281
|
|
|
277
|
-
function parseHeaders(
|
|
282
|
+
function parseHeaders(arrayBuffer: ArrayBuffer, options: I3STilesetOptions) {
|
|
278
283
|
let byteOffset = 0;
|
|
279
284
|
// First 8 bytes reserved for header (vertexCount and featurecount)
|
|
280
285
|
let vertexCount = 0;
|
|
281
286
|
let featureCount = 0;
|
|
282
|
-
for (const {property, type} of
|
|
287
|
+
for (const {property, type} of options.store.defaultGeometrySchema.header) {
|
|
283
288
|
const TypedArrayTypeHeader = getConstructorForDataFormat(type);
|
|
284
289
|
switch (property) {
|
|
285
290
|
case HeaderAttributeProperty.vertexCount:
|
|
@@ -394,8 +399,8 @@ function parseUint64Values(
|
|
|
394
399
|
return new Uint32Array(values);
|
|
395
400
|
}
|
|
396
401
|
|
|
397
|
-
function parsePositions(attribute: I3SMeshAttribute,
|
|
398
|
-
const mbs =
|
|
402
|
+
function parsePositions(attribute: I3SMeshAttribute, options: I3STileOptions): Matrix4 {
|
|
403
|
+
const mbs = options.mbs;
|
|
399
404
|
const value = attribute.value;
|
|
400
405
|
const metadata = attribute.metadata;
|
|
401
406
|
const enuMatrix = new Matrix4();
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '../../types';
|
|
14
14
|
import type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';
|
|
15
15
|
|
|
16
|
-
export function normalizeTileData(tile : Node3DIndexDocument,
|
|
16
|
+
export function normalizeTileData(tile : Node3DIndexDocument, context: LoaderContext): I3STileHeader {
|
|
17
17
|
const url: string = context.url || '';
|
|
18
18
|
let contentUrl: string | undefined;
|
|
19
19
|
if (tile.geometryData) {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {Matrix4, Quaternion, Vector3} from '@math.gl/core';
|
|
2
2
|
import type {TypedArray, MeshAttribute, TextureLevel} from '@loaders.gl/schema';
|
|
3
|
+
import {Tile3D, Tileset3D} from '@loaders.gl/tiles';
|
|
3
4
|
|
|
4
5
|
export enum DATA_TYPE {
|
|
5
6
|
UInt8 = 'UInt8',
|
|
@@ -80,6 +81,50 @@ export type I3STileHeader = {
|
|
|
80
81
|
lodSelection?: LodSelection[];
|
|
81
82
|
[key: string]: any;
|
|
82
83
|
};
|
|
84
|
+
|
|
85
|
+
export type I3SParseOptions = {
|
|
86
|
+
/** ArcGIS access token */
|
|
87
|
+
token?: string;
|
|
88
|
+
/** Is 3DSceneLayer json expected in response */
|
|
89
|
+
isTileset?: string;
|
|
90
|
+
/** Is 3DNodeIndexDocument json expected in response */
|
|
91
|
+
isTileHeader?: string;
|
|
92
|
+
/** Tile3D instance. This property used only to load tile content */
|
|
93
|
+
/** @deprecated */
|
|
94
|
+
tile?: Tile3D | I3STileOptions;
|
|
95
|
+
/** Tileset3D instance. This property used only to load tile content */
|
|
96
|
+
/** @deprecated */
|
|
97
|
+
tileset?: Tileset3D | I3STilesetOptions;
|
|
98
|
+
/** Tile-specific options */
|
|
99
|
+
_tileOptions?: I3STileOptions;
|
|
100
|
+
/** Tileset-specific options */
|
|
101
|
+
_tilesetOptions?: I3STilesetOptions;
|
|
102
|
+
/** Load Draco Compressed geometry if available */
|
|
103
|
+
useDracoGeometry?: boolean;
|
|
104
|
+
/** Load compressed textures if available */
|
|
105
|
+
useCompressedTextures?: boolean;
|
|
106
|
+
/** Set false if don't need to parse textures */
|
|
107
|
+
decodeTextures?: boolean;
|
|
108
|
+
/** deck.gl compatible coordinate system.
|
|
109
|
+
* https://github.com/visgl/deck.gl/blob/master/docs/developer-guide/coordinate-systems.md
|
|
110
|
+
* Supported coordinate systems: METER_OFFSETS, LNGLAT_OFFSETS
|
|
111
|
+
*/
|
|
112
|
+
coordinateSystem?: number;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type I3STileOptions = {
|
|
116
|
+
isDracoGeometry: boolean;
|
|
117
|
+
textureUrl?: string;
|
|
118
|
+
textureFormat?: I3STextureFormat;
|
|
119
|
+
textureLoaderOptions?: any;
|
|
120
|
+
materialDefinition?: I3SMaterialDefinition;
|
|
121
|
+
mbs: Mbs;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type I3STilesetOptions = {
|
|
125
|
+
store: Store;
|
|
126
|
+
};
|
|
127
|
+
|
|
83
128
|
// TODO Replace "[key: string]: any" with actual defenition
|
|
84
129
|
export type I3STileContent = {
|
|
85
130
|
attributes: I3SMeshAttributes;
|