@loaders.gl/tile-converter 3.1.6 → 3.2.0-alpha.1
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/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js +242 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +83 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +278 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +23 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +52 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js +43 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -0
- package/dist/converter.min.js +21 -21
- package/dist/deps-installer/deps-installer.d.ts +4 -0
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/deps-installer/deps-installer.js +21 -0
- package/dist/dist.min.js +1913 -908
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +2 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +14 -21
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +78 -35
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +35 -25
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +2 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +7 -5
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +2 -7
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +10 -0
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js +118 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js +176 -0
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +12 -0
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-converter.js +791 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-debug.js +114 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +116 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.js +203 -0
- package/dist/i3s-converter/i3s-converter.d.ts +321 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/i3s-converter/i3s-converter.js +994 -0
- package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/layers.js +199 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/metadata.js +25 -0
- package/dist/i3s-converter/json-templates/node.d.ts +61 -0
- package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/node.js +89 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/scene-server.js +31 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
- package/dist/i3s-converter/json-templates/store.d.ts +95 -0
- package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/store.js +103 -0
- package/dist/i3s-converter/types.d.ts +39 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/i3s-converter/types.js +2 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/i3s-server/app.js +14 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.js +23 -0
- package/dist/i3s-server/routes/index.d.ts +3 -0
- package/dist/i3s-server/routes/index.d.ts.map +1 -0
- package/dist/i3s-server/routes/index.js +16 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/lib/utils/compress-util.d.ts +6 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/lib/utils/compress-util.js +190 -0
- package/dist/lib/utils/file-utils.d.ts +6 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.js +42 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts +20 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/lib/utils/lod-conversion-utils.js +57 -0
- package/dist/lib/utils/statistic-utills.d.ts +3 -0
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/lib/utils/statistic-utills.js +64 -0
- package/dist/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/pgm-loader.js +23 -0
- package/package.json +16 -17
- package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -1
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +6 -5
- package/src/i3s-converter/helpers/node-pages.ts +6 -6
- package/src/i3s-converter/i3s-converter.ts +12 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GeometryAttributes, AttributesData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate geometry attributes with faceRange and featureCount
|
|
4
|
+
* @param attributes
|
|
5
|
+
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateAttributes(attributes: AttributesData): GeometryAttributes;
|
|
8
|
+
//# sourceMappingURL=geometry-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,cAAc,EAA+B,MAAM,UAAU,CAAC;AAM/F;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,GAAG,kBAAkB,CAuBjF"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAttributes = void 0;
|
|
4
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
5
|
+
const VALUES_PER_VERTEX = 3;
|
|
6
|
+
const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
7
|
+
/**
|
|
8
|
+
* Generate geometry attributes with faceRange and featureCount
|
|
9
|
+
* @param attributes
|
|
10
|
+
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
11
|
+
*/
|
|
12
|
+
function generateAttributes(attributes) {
|
|
13
|
+
const { positions, normals, texCoords, colors, featureIndices, triangleCount } = attributes;
|
|
14
|
+
if (!featureIndices.length) {
|
|
15
|
+
return {
|
|
16
|
+
faceRange: new Uint32Array([0, triangleCount - 1]),
|
|
17
|
+
featureIds: [0],
|
|
18
|
+
featureCount: 1,
|
|
19
|
+
positions,
|
|
20
|
+
normals,
|
|
21
|
+
texCoords,
|
|
22
|
+
colors
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const data = calculateFaceRangesAndFeaturesCount(featureIndices);
|
|
26
|
+
const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
|
|
27
|
+
const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
|
|
28
|
+
const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
|
|
29
|
+
return groupedAttributes;
|
|
30
|
+
}
|
|
31
|
+
exports.generateAttributes = generateAttributes;
|
|
32
|
+
/**
|
|
33
|
+
* Calculates face Ranges and feature count based on featureIndices.
|
|
34
|
+
* @param featureIndices
|
|
35
|
+
* @returns Object with featureCount, reordered attributes and changed faceRange.
|
|
36
|
+
*/
|
|
37
|
+
function calculateFaceRangesAndFeaturesCount(featureIndices) {
|
|
38
|
+
let rangeIndex = 1;
|
|
39
|
+
let featureIndex = 1;
|
|
40
|
+
let currentFeatureId = featureIndices[0];
|
|
41
|
+
const faceRangeList = [];
|
|
42
|
+
const featureIds = [];
|
|
43
|
+
const uniqueFeatureIds = [currentFeatureId];
|
|
44
|
+
faceRangeList[0] = 0;
|
|
45
|
+
featureIds[0] = currentFeatureId;
|
|
46
|
+
for (let index = 1; index < featureIndices.length; index++) {
|
|
47
|
+
if (currentFeatureId !== featureIndices[index]) {
|
|
48
|
+
faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
|
|
49
|
+
faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
|
|
50
|
+
featureIds[featureIndex] = featureIndices[index];
|
|
51
|
+
if (!uniqueFeatureIds.includes(featureIndices[index])) {
|
|
52
|
+
uniqueFeatureIds.push(featureIndices[index]);
|
|
53
|
+
}
|
|
54
|
+
rangeIndex += 2;
|
|
55
|
+
featureIndex += 1;
|
|
56
|
+
}
|
|
57
|
+
currentFeatureId = featureIndices[index];
|
|
58
|
+
}
|
|
59
|
+
faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
|
|
60
|
+
const faceRange = new Uint32Array(faceRangeList);
|
|
61
|
+
const featureCount = uniqueFeatureIds.length;
|
|
62
|
+
return { faceRange, featureCount, featureIds };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate list of attribute object grouped by feature ids.
|
|
66
|
+
* @param attributes
|
|
67
|
+
* @returns sorted list of attribute objects.
|
|
68
|
+
*/
|
|
69
|
+
function makeAttributeObjects(attributes) {
|
|
70
|
+
const { featureIds, positions, normals, colors, texCoords, faceRange = new Uint32Array(0) } = attributes;
|
|
71
|
+
const groupedData = [];
|
|
72
|
+
let positionsList = new Float32Array(positions);
|
|
73
|
+
let normalsList = new Float32Array(normals);
|
|
74
|
+
let colorsList = new Uint8Array(colors);
|
|
75
|
+
let texCoordsList = new Float32Array(texCoords);
|
|
76
|
+
let faceRangeIndex = 0;
|
|
77
|
+
for (let index = 0; index < featureIds.length; index++) {
|
|
78
|
+
const startIndex = faceRange[index + faceRangeIndex];
|
|
79
|
+
const endIndex = faceRange[index + faceRangeIndex + 1];
|
|
80
|
+
const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
|
|
81
|
+
const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
|
|
82
|
+
const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
|
|
83
|
+
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
84
|
+
groupedData.push({
|
|
85
|
+
featureId: featureIds[index],
|
|
86
|
+
positions: positionsList.slice(0, positionsCount),
|
|
87
|
+
normals: normalsList.slice(0, normalsCount),
|
|
88
|
+
colors: colorsList.slice(0, colorsCount),
|
|
89
|
+
texCoords: texCoordsList.slice(0, texCoordsCount)
|
|
90
|
+
});
|
|
91
|
+
positionsList = positionsList.slice(positionsCount);
|
|
92
|
+
normalsList = normalsList.slice(normalsCount);
|
|
93
|
+
colorsList = colorsList.slice(colorsCount);
|
|
94
|
+
texCoordsList = texCoordsList.slice(texCoordsCount);
|
|
95
|
+
faceRangeIndex += 1;
|
|
96
|
+
}
|
|
97
|
+
return groupedData.sort((first, second) => first.featureId - second.featureId);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generate sliced count for generating attribute objects depends on attribute name and range.
|
|
101
|
+
* @param attributeName
|
|
102
|
+
* @param startIndex
|
|
103
|
+
* @param endIndex
|
|
104
|
+
* @returns sliced count
|
|
105
|
+
*/
|
|
106
|
+
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
107
|
+
const colorsPerVertex = 4;
|
|
108
|
+
const texCoordsPerVertex = 2;
|
|
109
|
+
const trianglesCount = endIndex - startIndex + 1;
|
|
110
|
+
const vertexCount = trianglesCount * 3;
|
|
111
|
+
switch (attributeName) {
|
|
112
|
+
case 'positions':
|
|
113
|
+
case 'normals':
|
|
114
|
+
return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
115
|
+
case 'colors':
|
|
116
|
+
return vertexCount * colorsPerVertex;
|
|
117
|
+
case 'texCoords':
|
|
118
|
+
return vertexCount * texCoordsPerVertex;
|
|
119
|
+
default:
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Generates unique object list depends on feature ids and concantenate their attributes.
|
|
125
|
+
* @param sortedData
|
|
126
|
+
* @returns unique list of objects
|
|
127
|
+
*/
|
|
128
|
+
function unifyObjectsByFeatureId(sortedData) {
|
|
129
|
+
const uniqueObjects = [];
|
|
130
|
+
for (let index = 0; index < sortedData.length; index++) {
|
|
131
|
+
const currentObject = sortedData[index];
|
|
132
|
+
const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
|
|
133
|
+
if (existedObject) {
|
|
134
|
+
existedObject.positions = (0, loader_utils_1.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
|
|
135
|
+
existedObject.normals = (0, loader_utils_1.concatenateTypedArrays)(existedObject.normals, currentObject.normals);
|
|
136
|
+
existedObject.colors = (0, loader_utils_1.concatenateTypedArrays)(existedObject.colors, currentObject.colors);
|
|
137
|
+
existedObject.texCoords = (0, loader_utils_1.concatenateTypedArrays)(existedObject.texCoords, currentObject.texCoords);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
uniqueObjects.push(currentObject);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return uniqueObjects;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Generates attribute objects with new faceRange and reordered attributes.
|
|
147
|
+
* @param unifiedObjects
|
|
148
|
+
* @returns generated attributes with new faceRange.
|
|
149
|
+
*/
|
|
150
|
+
function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
151
|
+
const firstAttributeObject = unifiedObjects[0];
|
|
152
|
+
const featureIds = [firstAttributeObject.featureId || 0];
|
|
153
|
+
let positions = new Float32Array(firstAttributeObject.positions);
|
|
154
|
+
let normals = new Float32Array(firstAttributeObject.normals);
|
|
155
|
+
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
156
|
+
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
157
|
+
const range = [0];
|
|
158
|
+
let objIndex = 0;
|
|
159
|
+
let sum = 0;
|
|
160
|
+
for (let index = 1; index < unifiedObjects.length; index++) {
|
|
161
|
+
const currentAttributesObject = unifiedObjects[index];
|
|
162
|
+
featureIds.push(currentAttributesObject.featureId || 0);
|
|
163
|
+
positions = (0, loader_utils_1.concatenateTypedArrays)(positions, currentAttributesObject.positions);
|
|
164
|
+
normals = (0, loader_utils_1.concatenateTypedArrays)(normals, currentAttributesObject.normals);
|
|
165
|
+
colors = (0, loader_utils_1.concatenateTypedArrays)(colors, currentAttributesObject.colors);
|
|
166
|
+
texCoords = (0, loader_utils_1.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
|
|
167
|
+
const groupedObject = unifiedObjects[objIndex];
|
|
168
|
+
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
169
|
+
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
|
|
170
|
+
sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
171
|
+
objIndex += 1;
|
|
172
|
+
}
|
|
173
|
+
range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
174
|
+
const faceRange = new Uint32Array(range);
|
|
175
|
+
return { faceRange, featureIds, positions, normals, colors, texCoords, featureCount };
|
|
176
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function convertB3dmToI3sGeometry(tileContent: any, nodeId: any, featuresHashArray: any, attributeStorageInfo: any, draco: any, generateBoundingVolumes: any, geoidHeightModel: any): Promise<{
|
|
2
|
+
geometry: Uint8Array;
|
|
3
|
+
compressedGeometry: any;
|
|
4
|
+
texture: any;
|
|
5
|
+
sharedResources: any;
|
|
6
|
+
meshMaterial: any;
|
|
7
|
+
vertexCount: number;
|
|
8
|
+
attributes: any[];
|
|
9
|
+
featureCount: number;
|
|
10
|
+
boundingVolumes: any;
|
|
11
|
+
}[] | null>;
|
|
12
|
+
//# sourceMappingURL=geometry-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;YAuDC"}
|