@loaders.gl/tile-converter 4.4.0-alpha.1 → 4.4.0-alpha.9
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/converter.min.cjs +89 -98
- package/dist/i3s-server/bin/i3s-server.min.cjs +78 -78
- package/package.json +17 -17
- package/src/3d-tiles-converter/3d-tiles-converter.ts +11 -7
- package/src/3d-tiles-converter/helpers/load-i3s.ts +5 -5
- package/src/converter-cli.ts +2 -2
- package/src/i3s-converter/helpers/geometry-converter.ts +17 -1
- package/src/i3s-converter/helpers/load-3d-tiles.ts +24 -9
- package/src/i3s-converter/i3s-converter.ts +25 -9
- package/src/i3s-server/controllers/slpk-controller.ts +2 -2
- package/src/lib/utils/compress-util.ts +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +0 -115
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -388
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts +0 -88
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js +0 -380
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -13
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -19
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +0 -37
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -98
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +0 -10
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -50
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +0 -15
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -39
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -2
- package/dist/converter-cli.d.ts +0 -2
- package/dist/converter-cli.d.ts.map +0 -1
- package/dist/converter-cli.js +0 -290
- package/dist/deps-installer/deps-installer.d.ts +0 -19
- package/dist/deps-installer/deps-installer.d.ts.map +0 -1
- package/dist/deps-installer/deps-installer.js +0 -95
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +0 -84
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +0 -219
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +0 -26
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -165
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +0 -39
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -118
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +0 -9
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -21
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +0 -54
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -193
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +0 -8
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -226
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +0 -60
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1309
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +0 -28
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -122
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +0 -33
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -121
- package/dist/i3s-converter/helpers/node-debug.d.ts +0 -8
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js +0 -116
- package/dist/i3s-converter/helpers/node-index-document.d.ts +0 -111
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-index-document.js +0 -269
- package/dist/i3s-converter/helpers/node-pages.d.ts +0 -156
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js +0 -285
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +0 -22
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -104
- package/dist/i3s-converter/helpers/progress.d.ts +0 -90
- package/dist/i3s-converter/helpers/progress.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/progress.js +0 -148
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +0 -32
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -34
- package/dist/i3s-converter/i3s-converter.d.ts +0 -312
- package/dist/i3s-converter/i3s-converter.d.ts.map +0 -1
- package/dist/i3s-converter/i3s-converter.js +0 -1191
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +0 -7
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -80
- package/dist/i3s-converter/json-templates/layers.d.ts +0 -70
- package/dist/i3s-converter/json-templates/layers.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js +0 -132
- package/dist/i3s-converter/json-templates/metadata.d.ts +0 -22
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js +0 -21
- package/dist/i3s-converter/json-templates/node.d.ts +0 -61
- package/dist/i3s-converter/json-templates/node.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/node.js +0 -82
- package/dist/i3s-converter/json-templates/scene-server.d.ts +0 -28
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js +0 -27
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +0 -14
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -122
- package/dist/i3s-converter/json-templates/store.d.ts +0 -95
- package/dist/i3s-converter/json-templates/store.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/store.js +0 -100
- package/dist/i3s-converter/types.d.ts +0 -226
- package/dist/i3s-converter/types.d.ts.map +0 -1
- package/dist/i3s-converter/types.js +0 -37
- package/dist/i3s-server/app.d.ts +0 -3
- package/dist/i3s-server/app.d.ts.map +0 -1
- package/dist/i3s-server/app.js +0 -31
- package/dist/i3s-server/bin/www.d.ts +0 -3
- package/dist/i3s-server/bin/www.d.ts.map +0 -1
- package/dist/i3s-server/bin/www.js +0 -46
- package/dist/i3s-server/controllers/slpk-controller.d.ts +0 -13
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +0 -1
- package/dist/i3s-server/controllers/slpk-controller.js +0 -32
- package/dist/i3s-server/routes/slpk-router.d.ts +0 -3
- package/dist/i3s-server/routes/slpk-router.d.ts.map +0 -1
- package/dist/i3s-server/routes/slpk-router.js +0 -40
- package/dist/i3s-server/utils/create-scene-server.d.ts +0 -17
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +0 -1
- package/dist/i3s-server/utils/create-scene-server.js +0 -18
- package/dist/i3s-server/utils/server-utils.d.ts +0 -21
- package/dist/i3s-server/utils/server-utils.d.ts.map +0 -1
- package/dist/i3s-server/utils/server-utils.js +0 -60
- package/dist/index.cjs +0 -6228
- package/dist/index.cjs.map +0 -7
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts +0 -463
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts.map +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +0 -285
- package/dist/lib/utils/cli-utils.d.ts +0 -34
- package/dist/lib/utils/cli-utils.d.ts.map +0 -1
- package/dist/lib/utils/cli-utils.js +0 -76
- package/dist/lib/utils/compress-util.d.ts +0 -8
- package/dist/lib/utils/compress-util.d.ts.map +0 -1
- package/dist/lib/utils/compress-util.js +0 -25
- package/dist/lib/utils/conversion-dump.d.ts +0 -147
- package/dist/lib/utils/conversion-dump.d.ts.map +0 -1
- package/dist/lib/utils/conversion-dump.js +0 -257
- package/dist/lib/utils/file-utils.d.ts +0 -57
- package/dist/lib/utils/file-utils.d.ts.map +0 -1
- package/dist/lib/utils/file-utils.js +0 -140
- package/dist/lib/utils/geometry-utils.d.ts +0 -9
- package/dist/lib/utils/geometry-utils.d.ts.map +0 -1
- package/dist/lib/utils/geometry-utils.js +0 -14
- package/dist/lib/utils/lod-conversion-utils.d.ts +0 -42
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js +0 -71
- package/dist/lib/utils/queue.d.ts +0 -7
- package/dist/lib/utils/queue.d.ts.map +0 -1
- package/dist/lib/utils/queue.js +0 -14
- package/dist/lib/utils/statistic-utils.d.ts +0 -20
- package/dist/lib/utils/statistic-utils.d.ts.map +0 -1
- package/dist/lib/utils/statistic-utils.js +0 -88
- package/dist/lib/utils/write-queue.d.ts +0 -44
- package/dist/lib/utils/write-queue.d.ts.map +0 -1
- package/dist/lib/utils/write-queue.js +0 -82
- package/dist/pgm-loader.d.ts +0 -28
- package/dist/pgm-loader.d.ts.map +0 -1
- package/dist/pgm-loader.js +0 -24
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
import { encodeSync } from '@loaders.gl/core';
|
|
2
|
-
import { GLTFScenegraph, GLTFWriter, createExtStructuralMetadata, createExtMeshFeatures } from '@loaders.gl/gltf';
|
|
3
|
-
import { Tile3DWriter, TILE3D_TYPE } from '@loaders.gl/3d-tiles';
|
|
4
|
-
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
5
|
-
import { isTypedArray } from '@math.gl/types';
|
|
6
|
-
import { Ellipsoid } from '@math.gl/geospatial';
|
|
7
|
-
import { convertTextureAtlas } from "./texture-atlas.js";
|
|
8
|
-
import { generateSyntheticIndices } from "../../lib/utils/geometry-utils.js";
|
|
9
|
-
const Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
|
|
10
|
-
const scratchVector = new Vector3();
|
|
11
|
-
const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';
|
|
12
|
-
const METALLIC_FACTOR_DEFAULT = 1.0;
|
|
13
|
-
const ROUGHNESS_FACTOR_DEFAULT = 1.0;
|
|
14
|
-
/**
|
|
15
|
-
* Converts content of an I3S node to 3D Tiles file content
|
|
16
|
-
*/
|
|
17
|
-
export class Tiles3DContentConverter {
|
|
18
|
-
// @ts-expect-error
|
|
19
|
-
rtcCenter;
|
|
20
|
-
i3sTile;
|
|
21
|
-
tileType;
|
|
22
|
-
constructor(options = { outputVersion: '1.1' }) {
|
|
23
|
-
this.tileType =
|
|
24
|
-
options.outputVersion === '1.0' ? TILE3D_TYPE.BATCHED_3D_MODEL : TILE3D_TYPE.GLTF;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The starter of content conversion
|
|
28
|
-
* @param i3sTile - Tile3D instance for I3S node
|
|
29
|
-
* @returns - encoded content
|
|
30
|
-
*/
|
|
31
|
-
async convert(i3sAttributesData, featureAttributes = null, attributeStorageInfo) {
|
|
32
|
-
const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes, attributeStorageInfo);
|
|
33
|
-
if (this.tileType === TILE3D_TYPE.BATCHED_3D_MODEL) {
|
|
34
|
-
const b3dm = encodeSync({
|
|
35
|
-
gltfEncoded: new Uint8Array(gltf),
|
|
36
|
-
type: 'b3dm',
|
|
37
|
-
featuresLength: this._getFeaturesLength(featureAttributes),
|
|
38
|
-
batchTable: featureAttributes
|
|
39
|
-
}, Tile3DWriter);
|
|
40
|
-
return b3dm;
|
|
41
|
-
}
|
|
42
|
-
return gltf;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Build and encode gltf
|
|
46
|
-
* @param i3sTile - Tile3D instance for I3S node
|
|
47
|
-
* @returns - encoded glb content
|
|
48
|
-
*/
|
|
49
|
-
// eslint-disable-next-line complexity, max-statements
|
|
50
|
-
async buildGLTF(i3sAttributesData, featureAttributes, attributeStorageInfo) {
|
|
51
|
-
const { tileContent, textureFormat, box } = i3sAttributesData;
|
|
52
|
-
const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
|
|
53
|
-
const gltfBuilder = new GLTFScenegraph();
|
|
54
|
-
const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);
|
|
55
|
-
// Add KHR_MATERIALS_UNLIT extension in the following cases:
|
|
56
|
-
// - metallicFactor or roughnessFactor are set to default values
|
|
57
|
-
// - metallicFactor or roughnessFactor are not set
|
|
58
|
-
const pbrMetallicRoughness = material?.pbrMetallicRoughness;
|
|
59
|
-
if (pbrMetallicRoughness &&
|
|
60
|
-
(pbrMetallicRoughness.metallicFactor === undefined ||
|
|
61
|
-
pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) &&
|
|
62
|
-
(pbrMetallicRoughness.roughnessFactor === undefined ||
|
|
63
|
-
pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)) {
|
|
64
|
-
gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
|
|
65
|
-
gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);
|
|
66
|
-
}
|
|
67
|
-
const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);
|
|
68
|
-
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
69
|
-
const positions = attributes.positions;
|
|
70
|
-
const positionsValue = positions.value;
|
|
71
|
-
if (attributes.uvRegions && attributes.texCoords) {
|
|
72
|
-
attributes.texCoords.value = convertTextureAtlas(attributes.texCoords.value, attributes.uvRegions.value);
|
|
73
|
-
}
|
|
74
|
-
const cartesianOrigin = new Vector3(box);
|
|
75
|
-
const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());
|
|
76
|
-
attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
|
|
77
|
-
this._createBatchIds(tileContent, featureAttributes);
|
|
78
|
-
if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
|
|
79
|
-
delete attributes.normals;
|
|
80
|
-
}
|
|
81
|
-
const indices = originalIndices || generateSyntheticIndices(positionsValue.length / positions.size);
|
|
82
|
-
const meshIndex = gltfBuilder.addMesh({
|
|
83
|
-
attributes,
|
|
84
|
-
indices,
|
|
85
|
-
material: materialIndex,
|
|
86
|
-
mode: 4
|
|
87
|
-
});
|
|
88
|
-
if (this.tileType === TILE3D_TYPE.GLTF) {
|
|
89
|
-
this._createMetadataExtensions(gltfBuilder, meshIndex, featureAttributes, attributeStorageInfo, tileContent);
|
|
90
|
-
}
|
|
91
|
-
const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
|
|
92
|
-
const nodeIndex = gltfBuilder.addNode({ meshIndex, matrix: transformMatrix });
|
|
93
|
-
const sceneIndex = gltfBuilder.addScene({ nodeIndices: [nodeIndex] });
|
|
94
|
-
gltfBuilder.setDefaultScene(sceneIndex);
|
|
95
|
-
gltfBuilder.createBinaryChunk();
|
|
96
|
-
return encodeSync(gltfBuilder.gltf, GLTFWriter, { gltfBuilder });
|
|
97
|
-
}
|
|
98
|
-
_createMetadataExtensions(gltfBuilder, meshIndex, featureAttributes, attributeStorageInfo, tileContent) {
|
|
99
|
-
const propertyAttributes = this._createPropertyAttibutes(featureAttributes, attributeStorageInfo);
|
|
100
|
-
const tableIndex = createExtStructuralMetadata(gltfBuilder, propertyAttributes);
|
|
101
|
-
const mesh = gltfBuilder.getMesh(meshIndex);
|
|
102
|
-
for (const primitive of mesh.primitives) {
|
|
103
|
-
if (tileContent.attributes._BATCHID?.value) {
|
|
104
|
-
createExtMeshFeatures(gltfBuilder, primitive, tileContent.attributes._BATCHID.value, tableIndex);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
_createPropertyAttibutes(featureAttributes, attributeStorageInfo) {
|
|
109
|
-
if (!featureAttributes || !attributeStorageInfo) {
|
|
110
|
-
return [];
|
|
111
|
-
}
|
|
112
|
-
const propertyAttributeArray = [];
|
|
113
|
-
for (const attributeName in featureAttributes) {
|
|
114
|
-
const propertyAttribute = this._convertAttributeStorageInfoToPropertyAttribute(attributeName, attributeStorageInfo, featureAttributes);
|
|
115
|
-
if (propertyAttribute) {
|
|
116
|
-
propertyAttributeArray.push(propertyAttribute);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return propertyAttributeArray;
|
|
120
|
-
}
|
|
121
|
-
// eslint-disable-next-line complexity
|
|
122
|
-
_convertAttributeStorageInfoToPropertyAttribute(attributeName, attributeStorageInfo, featureAttributes) {
|
|
123
|
-
const attributeValues = featureAttributes[attributeName];
|
|
124
|
-
const info = attributeStorageInfo.find((e) => e.name === attributeName);
|
|
125
|
-
if (!info) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
const attributeMetadata = info.attributeValues;
|
|
129
|
-
if (!attributeMetadata?.valueType) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
let elementType;
|
|
133
|
-
let componentType;
|
|
134
|
-
switch (attributeMetadata.valueType.toLowerCase()) {
|
|
135
|
-
case 'oid32':
|
|
136
|
-
elementType = 'SCALAR';
|
|
137
|
-
componentType = 'UINT32';
|
|
138
|
-
break;
|
|
139
|
-
case 'int32':
|
|
140
|
-
elementType = 'SCALAR';
|
|
141
|
-
componentType = 'INT32';
|
|
142
|
-
break;
|
|
143
|
-
case 'uint32':
|
|
144
|
-
elementType = 'SCALAR';
|
|
145
|
-
componentType = 'UINT32';
|
|
146
|
-
break;
|
|
147
|
-
case 'int16':
|
|
148
|
-
elementType = 'SCALAR';
|
|
149
|
-
componentType = 'INT16';
|
|
150
|
-
break;
|
|
151
|
-
case 'uint16':
|
|
152
|
-
elementType = 'SCALAR';
|
|
153
|
-
componentType = 'UINT16';
|
|
154
|
-
break;
|
|
155
|
-
case 'float64':
|
|
156
|
-
elementType = 'SCALAR';
|
|
157
|
-
componentType = 'FLOAT64';
|
|
158
|
-
break;
|
|
159
|
-
case 'string':
|
|
160
|
-
elementType = 'STRING';
|
|
161
|
-
break;
|
|
162
|
-
default:
|
|
163
|
-
elementType = '';
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
const propertyAttribute = {
|
|
167
|
-
name: attributeName,
|
|
168
|
-
elementType,
|
|
169
|
-
componentType,
|
|
170
|
-
values: []
|
|
171
|
-
};
|
|
172
|
-
if (isTypedArray(attributeValues)) {
|
|
173
|
-
propertyAttribute.values = Array.from(attributeValues);
|
|
174
|
-
}
|
|
175
|
-
else if (attributeValues !== null) {
|
|
176
|
-
propertyAttribute.values = attributeValues;
|
|
177
|
-
}
|
|
178
|
-
return propertyAttribute;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Update gltfBuilder with texture from I3S tile
|
|
182
|
-
* @param {object} i3sTile - Tile3D object
|
|
183
|
-
* @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
|
|
184
|
-
* @returns {Promise<number | null>} - GLTF texture index
|
|
185
|
-
*/
|
|
186
|
-
async _addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder) {
|
|
187
|
-
const { texture, material, attributes } = tileContent;
|
|
188
|
-
let textureIndex = null;
|
|
189
|
-
let selectedTexture = texture;
|
|
190
|
-
if (!texture && material) {
|
|
191
|
-
selectedTexture =
|
|
192
|
-
material.pbrMetallicRoughness &&
|
|
193
|
-
material.pbrMetallicRoughness.baseColorTexture &&
|
|
194
|
-
material.pbrMetallicRoughness.baseColorTexture.texture.source.image;
|
|
195
|
-
}
|
|
196
|
-
if (selectedTexture) {
|
|
197
|
-
const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
|
|
198
|
-
const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
|
|
199
|
-
textureIndex = gltfBuilder.addTexture({ imageIndex });
|
|
200
|
-
delete attributes.colors;
|
|
201
|
-
}
|
|
202
|
-
return textureIndex;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Generate a positions array which is correct for 3DTiles/GLTF format
|
|
206
|
-
* @param {Float64Array} positionsValue - the input geometry positions array
|
|
207
|
-
* @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
|
|
208
|
-
* @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
|
|
209
|
-
* @param {number[]} modelMatrix - the model matrix of geometry
|
|
210
|
-
* @returns {Float32Array} - the output geometry positions array
|
|
211
|
-
*/
|
|
212
|
-
_normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {
|
|
213
|
-
const newPositionsValue = new Float32Array(positionsValue.length);
|
|
214
|
-
for (let index = 0; index < positionsValue.length; index += 3) {
|
|
215
|
-
const vertex = positionsValue.subarray(index, index + 3);
|
|
216
|
-
const cartesianOriginVector = new Vector3(cartesianOrigin);
|
|
217
|
-
let vertexVector = new Vector3(Array.from(vertex))
|
|
218
|
-
.transform(modelMatrix)
|
|
219
|
-
.add(cartographicOrigin);
|
|
220
|
-
Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);
|
|
221
|
-
vertexVector = scratchVector.subtract(cartesianOriginVector);
|
|
222
|
-
newPositionsValue.set(vertexVector, index);
|
|
223
|
-
}
|
|
224
|
-
return newPositionsValue;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Generate the transformation matrix for GLTF node:
|
|
228
|
-
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node
|
|
229
|
-
* 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)
|
|
230
|
-
* 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)
|
|
231
|
-
* @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
|
|
232
|
-
* @returns {Matrix4} - an array of 16 numbers (4x4 matrix)
|
|
233
|
-
*/
|
|
234
|
-
_generateTransformMatrix(cartesianOrigin) {
|
|
235
|
-
const translateOriginMatrix = new Matrix4().translate(cartesianOrigin);
|
|
236
|
-
const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);
|
|
237
|
-
return result;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Create _BATCHID attribute
|
|
241
|
-
* @param {Object} i3sContent - the source object
|
|
242
|
-
* @returns {void}
|
|
243
|
-
*/
|
|
244
|
-
_createBatchIds(i3sContent, featureAttributes) {
|
|
245
|
-
const { featureIds } = i3sContent;
|
|
246
|
-
const { OBJECTID: objectIds } = featureAttributes || {};
|
|
247
|
-
if (!featureIds || !objectIds) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
for (let i = 0; i < featureIds.length; i++) {
|
|
251
|
-
const featureId = featureIds[i];
|
|
252
|
-
const batchId = objectIds.indexOf(featureId);
|
|
253
|
-
featureIds[i] = batchId;
|
|
254
|
-
}
|
|
255
|
-
i3sContent.attributes._BATCHID = {
|
|
256
|
-
size: 1,
|
|
257
|
-
byteOffset: 0,
|
|
258
|
-
value: featureIds
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Deduce mime type by format from `textureSetDefinition.formats[0].format`
|
|
263
|
-
* https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
|
|
264
|
-
* @param {string} format - format name
|
|
265
|
-
* @returns {string} mime type.
|
|
266
|
-
*/
|
|
267
|
-
_deduceMimeTypeFromFormat(format) {
|
|
268
|
-
switch (format) {
|
|
269
|
-
case 'jpg':
|
|
270
|
-
return 'image/jpeg';
|
|
271
|
-
case 'png':
|
|
272
|
-
return 'image/png';
|
|
273
|
-
case 'ktx2':
|
|
274
|
-
return 'image/ktx2';
|
|
275
|
-
default:
|
|
276
|
-
console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef
|
|
277
|
-
return 'image/jpeg';
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Convert i3s material to GLTF compatible material
|
|
282
|
-
* @param {object} material - i3s material definition
|
|
283
|
-
* @param {number | null} textureIndex - texture index in GLTF
|
|
284
|
-
* @returns {object} GLTF material
|
|
285
|
-
*/
|
|
286
|
-
_convertI3sMaterialToGLTFMaterial(material, textureIndex) {
|
|
287
|
-
const isTextureIndexExists = textureIndex !== null;
|
|
288
|
-
if (!material) {
|
|
289
|
-
material = {
|
|
290
|
-
alphaMode: 'OPAQUE',
|
|
291
|
-
doubleSided: false,
|
|
292
|
-
pbrMetallicRoughness: {
|
|
293
|
-
metallicFactor: 0,
|
|
294
|
-
roughnessFactor: 1
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
if (isTextureIndexExists) {
|
|
298
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
299
|
-
index: textureIndex,
|
|
300
|
-
texCoord: 0
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];
|
|
305
|
-
}
|
|
306
|
-
return material;
|
|
307
|
-
}
|
|
308
|
-
if (textureIndex !== null) {
|
|
309
|
-
material = this._setGLTFTexture(material, textureIndex);
|
|
310
|
-
}
|
|
311
|
-
return material;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Set texture properties in material with GLTF textureIndex
|
|
315
|
-
* @param {object} materialDefinition - i3s material definition
|
|
316
|
-
* @param {number} textureIndex - texture index in GLTF
|
|
317
|
-
* @returns {void}
|
|
318
|
-
*/
|
|
319
|
-
_setGLTFTexture(materialDefinition, textureIndex) {
|
|
320
|
-
const material = {
|
|
321
|
-
...materialDefinition,
|
|
322
|
-
pbrMetallicRoughness: { ...materialDefinition.pbrMetallicRoughness }
|
|
323
|
-
};
|
|
324
|
-
// I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of
|
|
325
|
-
// properties defined in materialDefinition
|
|
326
|
-
if (materialDefinition.pbrMetallicRoughness &&
|
|
327
|
-
materialDefinition.pbrMetallicRoughness.baseColorTexture) {
|
|
328
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
329
|
-
index: textureIndex,
|
|
330
|
-
texCoord: 0
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
else if (materialDefinition.emissiveTexture) {
|
|
334
|
-
material.emissiveTexture = {
|
|
335
|
-
index: textureIndex,
|
|
336
|
-
texCoord: 0
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
else if (materialDefinition.pbrMetallicRoughness &&
|
|
340
|
-
materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
341
|
-
material.pbrMetallicRoughness.metallicRoughnessTexture = {
|
|
342
|
-
index: textureIndex,
|
|
343
|
-
texCoord: 0
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
else if (materialDefinition.normalTexture) {
|
|
347
|
-
material.normalTexture = {
|
|
348
|
-
index: textureIndex,
|
|
349
|
-
texCoord: 0
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
else if (materialDefinition.occlusionTexture) {
|
|
353
|
-
material.occlusionTexture = {
|
|
354
|
-
index: textureIndex,
|
|
355
|
-
texCoord: 0
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
return material;
|
|
359
|
-
}
|
|
360
|
-
/*
|
|
361
|
-
* Returns Features length based on attribute array in attribute object.
|
|
362
|
-
* @param {Object} attributes
|
|
363
|
-
* @returns {Number} Features length .
|
|
364
|
-
*/
|
|
365
|
-
_getFeaturesLength(attributes) {
|
|
366
|
-
if (!attributes) {
|
|
367
|
-
return 0;
|
|
368
|
-
}
|
|
369
|
-
const firstKey = Object.keys(attributes)[0];
|
|
370
|
-
return firstKey ? attributes[firstKey].length : 0;
|
|
371
|
-
}
|
|
372
|
-
/* Checks that normals buffer is correct
|
|
373
|
-
* @param {TypedArray} normals
|
|
374
|
-
* @returns {boolean} true - normals are correct; false - normals are incorrect
|
|
375
|
-
*/
|
|
376
|
-
_checkNormals(normals) {
|
|
377
|
-
// If all normals === 0, the resulting tileset is all in black colors on Cesium
|
|
378
|
-
return normals.find((value) => value);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GeoidHeightModel } from '@loaders.gl/tile-converter/lib/geoid-height-model';
|
|
2
|
-
/**
|
|
3
|
-
* Convert quaternion-based OBB to half-axes-based OBB
|
|
4
|
-
* @param i3SObb quaternion based OBB
|
|
5
|
-
* @param geoidHeightModel the Earth Gravity Model instance
|
|
6
|
-
* @returns number[12] 3DTiles OBB https://github.com/CesiumGS/3d-tiles/tree/master/specification#box
|
|
7
|
-
*/
|
|
8
|
-
export declare function i3sObbTo3dTilesObb(i3SObb: {
|
|
9
|
-
center: number[];
|
|
10
|
-
halfSize: number[];
|
|
11
|
-
quaternion: number[];
|
|
12
|
-
}, geoidHeightModel: GeoidHeightModel): number[];
|
|
13
|
-
//# sourceMappingURL=i3s-obb-to-3d-tiles-obb.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-obb-to-3d-tiles-obb.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mDAAmD,CAAC;AAEnF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE;IACN,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,EACD,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,EAAE,CAaV"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from '@math.gl/core';
|
|
2
|
-
import { Ellipsoid } from '@math.gl/geospatial';
|
|
3
|
-
import { OrientedBoundingBox } from '@math.gl/culling';
|
|
4
|
-
/**
|
|
5
|
-
* Convert quaternion-based OBB to half-axes-based OBB
|
|
6
|
-
* @param i3SObb quaternion based OBB
|
|
7
|
-
* @param geoidHeightModel the Earth Gravity Model instance
|
|
8
|
-
* @returns number[12] 3DTiles OBB https://github.com/CesiumGS/3d-tiles/tree/master/specification#box
|
|
9
|
-
*/
|
|
10
|
-
export function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
|
|
11
|
-
const tiles3DCenter = [
|
|
12
|
-
i3SObb.center[0],
|
|
13
|
-
i3SObb.center[1],
|
|
14
|
-
i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])
|
|
15
|
-
];
|
|
16
|
-
const cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new Vector3());
|
|
17
|
-
const tiles3DObb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(cartesianCenter, i3SObb.halfSize, i3SObb.quaternion);
|
|
18
|
-
return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];
|
|
19
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { LoaderWithParser } from '@loaders.gl/core';
|
|
2
|
-
import { I3STileContent, I3STileHeader, I3STilesetHeader, I3SLoaderOptions } from '@loaders.gl/i3s';
|
|
3
|
-
import { ZipFileSystem } from '@loaders.gl/zip';
|
|
4
|
-
export type SLPKUrlParts = {
|
|
5
|
-
slpkFileName: string;
|
|
6
|
-
internalFileName: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Load I3S node content
|
|
10
|
-
* @param sourceTileset - source layer JSON
|
|
11
|
-
* @param sourceTile - source I3S node metadata
|
|
12
|
-
* @param tilesetLoadOptions - load options for Tiles3DLoader
|
|
13
|
-
* @param slpkFilesystem - loaded instance of ZipFileSystem for local convertion from SLPK file
|
|
14
|
-
* @returns - 3DTiles tile content or null
|
|
15
|
-
*/
|
|
16
|
-
export declare const loadI3SContent: (sourceTileset: I3STilesetHeader | null, sourceTile: I3STileHeader, tilesetLoadOptions: I3SLoaderOptions, slpkFilesystem: ZipFileSystem | null) => Promise<I3STileContent | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Load local SLPK file to ZipFileSystem instance
|
|
19
|
-
* @param url - path to SLPK file
|
|
20
|
-
* @returns instance of ZipFileSystem or null if url is not an SLPK file
|
|
21
|
-
*/
|
|
22
|
-
export declare function openSLPK(url: string): Promise<ZipFileSystem | null>;
|
|
23
|
-
/**
|
|
24
|
-
* Load a resource with load options and .3tz format support
|
|
25
|
-
* @param url - resource URL
|
|
26
|
-
* @param loader - loader to parse data (Tiles3DLoader / CesiumIonLoader)
|
|
27
|
-
* @param loadOptions - i3s loader options
|
|
28
|
-
* @returns i3s resource
|
|
29
|
-
*/
|
|
30
|
-
export declare function loadFromArchive(url: string, loader: LoaderWithParser, loadOptions: I3SLoaderOptions, fileSystem: ZipFileSystem | null): Promise<any>;
|
|
31
|
-
/**
|
|
32
|
-
* Get nodes count inside SLPK
|
|
33
|
-
* @param fileSystem - file system of SLPK
|
|
34
|
-
* @returns number of nodes
|
|
35
|
-
*/
|
|
36
|
-
export declare function getNodeCount(fileSystem: ZipFileSystem | null): Promise<number>;
|
|
37
|
-
//# sourceMappingURL=load-i3s.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-i3s.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/load-i3s.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAO,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAEhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAC,CAAC;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,kBACV,gBAAgB,GAAG,IAAI,cAC1B,aAAa,sBACL,gBAAgB,kBACpB,aAAa,GAAG,IAAI,KACnC,OAAO,CAAC,cAAc,GAAG,IAAI,CAuC/B,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAUzE;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,gBAAgB,EAC7B,UAAU,EAAE,aAAa,GAAG,IAAI,gBAUjC;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAcpF"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { load } from '@loaders.gl/core';
|
|
2
|
-
import { I3SLoader, parseSLPKArchive } from '@loaders.gl/i3s';
|
|
3
|
-
import { FileHandleFile } from '@loaders.gl/loader-utils';
|
|
4
|
-
import { ZipFileSystem, makeZipCDHeaderIterator } from '@loaders.gl/zip';
|
|
5
|
-
/**
|
|
6
|
-
* Load I3S node content
|
|
7
|
-
* @param sourceTileset - source layer JSON
|
|
8
|
-
* @param sourceTile - source I3S node metadata
|
|
9
|
-
* @param tilesetLoadOptions - load options for Tiles3DLoader
|
|
10
|
-
* @param slpkFilesystem - loaded instance of ZipFileSystem for local convertion from SLPK file
|
|
11
|
-
* @returns - 3DTiles tile content or null
|
|
12
|
-
*/
|
|
13
|
-
export const loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions, slpkFilesystem) => {
|
|
14
|
-
if (!sourceTileset || !sourceTile.contentUrl) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
const loadOptions = {
|
|
18
|
-
...tilesetLoadOptions,
|
|
19
|
-
i3s: {
|
|
20
|
-
...tilesetLoadOptions.i3s,
|
|
21
|
-
// @ts-expect-error
|
|
22
|
-
isTileset: false,
|
|
23
|
-
// @ts-expect-error
|
|
24
|
-
isTileHeader: false,
|
|
25
|
-
_tileOptions: {
|
|
26
|
-
attributeUrls: sourceTile.attributeUrls || [],
|
|
27
|
-
textureUrl: sourceTile.textureUrl,
|
|
28
|
-
textureFormat: sourceTile.textureFormat,
|
|
29
|
-
textureLoaderOptions: sourceTile.textureLoaderOptions,
|
|
30
|
-
materialDefinition: sourceTile.materialDefinition,
|
|
31
|
-
isDracoGeometry: sourceTile.isDracoGeometry,
|
|
32
|
-
mbs: sourceTile.mbs
|
|
33
|
-
},
|
|
34
|
-
_tilesetOptions: {
|
|
35
|
-
store: sourceTileset.store,
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
attributeStorageInfo: sourceTileset.attributeStorageInfo,
|
|
38
|
-
// @ts-expect-error
|
|
39
|
-
fields: sourceTileset.fields
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const tileContent = await loadFromArchive(sourceTile.contentUrl, I3SLoader, loadOptions, slpkFilesystem);
|
|
44
|
-
return tileContent;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Load local SLPK file to ZipFileSystem instance
|
|
48
|
-
* @param url - path to SLPK file
|
|
49
|
-
* @returns instance of ZipFileSystem or null if url is not an SLPK file
|
|
50
|
-
*/
|
|
51
|
-
export async function openSLPK(url) {
|
|
52
|
-
const slpkUrlParts = url.split('.slpk');
|
|
53
|
-
if (slpkUrlParts.length === 2) {
|
|
54
|
-
const slpkFileName = `${slpkUrlParts[0]}.slpk`;
|
|
55
|
-
const fileProvider = new FileHandleFile(slpkFileName);
|
|
56
|
-
const archive = await parseSLPKArchive(fileProvider, undefined, slpkFileName);
|
|
57
|
-
const fileSystem = new ZipFileSystem(archive);
|
|
58
|
-
return fileSystem;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Load a resource with load options and .3tz format support
|
|
64
|
-
* @param url - resource URL
|
|
65
|
-
* @param loader - loader to parse data (Tiles3DLoader / CesiumIonLoader)
|
|
66
|
-
* @param loadOptions - i3s loader options
|
|
67
|
-
* @returns i3s resource
|
|
68
|
-
*/
|
|
69
|
-
export async function loadFromArchive(url, loader, loadOptions, fileSystem) {
|
|
70
|
-
if (fileSystem !== null) {
|
|
71
|
-
const content = await load(url, loader, {
|
|
72
|
-
...loadOptions,
|
|
73
|
-
fetch: fileSystem.fetch.bind(fileSystem)
|
|
74
|
-
});
|
|
75
|
-
return content;
|
|
76
|
-
}
|
|
77
|
-
return await load(url, loader, loadOptions);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get nodes count inside SLPK
|
|
81
|
-
* @param fileSystem - file system of SLPK
|
|
82
|
-
* @returns number of nodes
|
|
83
|
-
*/
|
|
84
|
-
export async function getNodeCount(fileSystem) {
|
|
85
|
-
if (!fileSystem?.fileProvider) {
|
|
86
|
-
return 0;
|
|
87
|
-
}
|
|
88
|
-
const nodeSet = new Set();
|
|
89
|
-
const filesIterator = makeZipCDHeaderIterator(fileSystem.fileProvider);
|
|
90
|
-
for await (const file of filesIterator) {
|
|
91
|
-
const filename = file.fileName;
|
|
92
|
-
const nodeNumberSearchResult = /^nodes\/(\d+)\//.exec(filename);
|
|
93
|
-
if (nodeNumberSearchResult) {
|
|
94
|
-
nodeSet.add(nodeNumberSearchResult[1]);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return nodeSet.size;
|
|
98
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TypedArray } from '@loaders.gl/loader-utils';
|
|
2
|
-
/**
|
|
3
|
-
* Apply uvRegions to texture coordinates.
|
|
4
|
-
* Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md
|
|
5
|
-
* Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
|
|
6
|
-
* @param texCoords
|
|
7
|
-
* @param uvRegions
|
|
8
|
-
*/
|
|
9
|
-
export declare function convertTextureAtlas(texCoords: TypedArray, uvRegions: TypedArray): Float32Array;
|
|
10
|
-
//# sourceMappingURL=texture-atlas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"texture-atlas.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/texture-atlas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,YAAY,CAwB9F"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apply uvRegions to texture coordinates.
|
|
3
|
-
* Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md
|
|
4
|
-
* Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
|
|
5
|
-
* @param texCoords
|
|
6
|
-
* @param uvRegions
|
|
7
|
-
*/
|
|
8
|
-
export function convertTextureAtlas(texCoords, uvRegions) {
|
|
9
|
-
const convertedTexCoords = new Float32Array(texCoords.length);
|
|
10
|
-
const normalisedRegions = normalizeRegions(uvRegions);
|
|
11
|
-
for (let index = 0; index < texCoords.length; index += 2) {
|
|
12
|
-
const uv = texCoords.subarray(index, index + 2);
|
|
13
|
-
const regions = normalisedRegions.slice(index * 2, index * 2 + 4);
|
|
14
|
-
// fract(texCoords)
|
|
15
|
-
const fractatedUV = fract([uv[0], uv[1]]);
|
|
16
|
-
// (uvRegions.zw - uvRegions.xy)
|
|
17
|
-
const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];
|
|
18
|
-
// fract(texCoords) * (uvRegions.zw - uvRegions.xy)
|
|
19
|
-
const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];
|
|
20
|
-
// fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
|
|
21
|
-
const convertedUV = [
|
|
22
|
-
multiplicationResult[0] + regions[0],
|
|
23
|
-
multiplicationResult[1] + regions[1]
|
|
24
|
-
];
|
|
25
|
-
convertedTexCoords[index] = convertedUV[0];
|
|
26
|
-
convertedTexCoords[index + 1] = convertedUV[1];
|
|
27
|
-
}
|
|
28
|
-
return convertedTexCoords;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Do fractation of UV array.
|
|
32
|
-
* @param uv
|
|
33
|
-
*/
|
|
34
|
-
function fract(uv) {
|
|
35
|
-
return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Normalize uvRegions by dividing by the maximum Uint16 value
|
|
39
|
-
* @param regions
|
|
40
|
-
*/
|
|
41
|
-
function normalizeRegions(regions) {
|
|
42
|
-
// The code is for Uint16Array because it is the spec requirement
|
|
43
|
-
// https://github.com/Esri/i3s-spec/blob/master/docs/1.8/geometryUVRegion.cmn.md
|
|
44
|
-
const MAX_UINT_16_VALUE = 65535;
|
|
45
|
-
const normalizedRegions = [];
|
|
46
|
-
for (let index = 0; index < regions.length; index++) {
|
|
47
|
-
normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;
|
|
48
|
-
}
|
|
49
|
-
return normalizedRegions;
|
|
50
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const TILESET: () => {
|
|
2
|
-
asset: {
|
|
3
|
-
path: string;
|
|
4
|
-
transform: (val: any) => any;
|
|
5
|
-
};
|
|
6
|
-
geometricError: {
|
|
7
|
-
path: string;
|
|
8
|
-
transform: (val: any) => any;
|
|
9
|
-
};
|
|
10
|
-
root: {
|
|
11
|
-
path: string;
|
|
12
|
-
transform: (val: any) => any;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=tileset.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tileset.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/json-templates/tileset.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAalB,CAAC"}
|