@loaders.gl/tile-converter 3.4.0-alpha.2 → 3.4.0-alpha.4
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-attributes-worker.js +2 -2
- package/dist/3d-tiles-attributes-worker.js.map +3 -3
- package/dist/converter.min.js +90 -2875
- package/dist/dist.min.js +1823 -19725
- package/dist/es5/3d-tiles-attributes-worker.js +1 -2
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +264 -287
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +89 -113
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -2
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +67 -81
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +64 -69
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -2
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +0 -8
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +0 -5
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +14 -16
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +1 -11
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +3 -10
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +427 -457
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +0 -2
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +3 -13
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +293 -318
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +279 -319
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +964 -1030
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +28 -30
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +15 -18
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +198 -218
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +118 -128
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +0 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +81 -85
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +84 -92
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +7 -10
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +7 -9
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +10 -12
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -3
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +1 -15
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +0 -12
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +0 -3
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/converter-cli.js +0 -11
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -4
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -3
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +0 -8
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +0 -5
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +0 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +0 -11
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +0 -7
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +30 -56
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +0 -3
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js +3 -13
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +0 -14
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +0 -18
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +4 -42
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/controllers/index-controller.js +0 -2
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/i3s-server/routes/index.js +0 -1
- package/dist/esm/i3s-server/routes/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +1 -17
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +0 -7
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js +0 -2
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js.map +1 -1
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +0 -2
- package/dist/esm/lib/utils/write-queue.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -3
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -2
- package/dist/i3s-attributes-worker.js.map +3 -3
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +44 -6
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-debug.js +10 -4
- package/dist/i3s-converter/helpers/node-pages.js +1 -1
- package/dist/i3s-converter/types.d.ts +1 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/package.json +15 -16
- package/src/i3s-converter/helpers/geometry-converter.ts +59 -14
- package/src/i3s-converter/helpers/node-debug.ts +11 -5
- package/src/i3s-converter/types.ts +10 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAsBxE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,+DAA+D;AAC/D,OAAO,EAAC,kBAAkB,EAAsC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAsBxE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,+DAA+D;AAC/D,OAAO,EAAC,kBAAkB,EAAsC,MAAM,6BAA6B,CAAC;AAsCpG;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,YAAY,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GACpC,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CA0DzC;AA6ID;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAgD3C;AAkoCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAoBlF"}
|
|
@@ -39,6 +39,7 @@ const coordinate_converter_1 = require("./coordinate-converter");
|
|
|
39
39
|
const gltf_attributes_1 = require("./gltf-attributes");
|
|
40
40
|
const batch_ids_extensions_1 = require("./batch-ids-extensions");
|
|
41
41
|
const feature_attributes_1 = require("./feature-attributes");
|
|
42
|
+
const math_1 = require("@loaders.gl/math");
|
|
42
43
|
// Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/pbrMetallicRoughness.cmn.md
|
|
43
44
|
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
44
45
|
const DEFAULT_METALLIC_FACTOR = 1;
|
|
@@ -334,12 +335,13 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
334
335
|
if (!outputAttributes) {
|
|
335
336
|
continue;
|
|
336
337
|
}
|
|
338
|
+
const indices = getIndices(primitive);
|
|
337
339
|
outputAttributes.positions = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
|
|
338
340
|
vertices: attributes.POSITION.value,
|
|
339
341
|
cartographicOrigin,
|
|
340
342
|
cartesianModelMatrix,
|
|
341
343
|
nodeMatrix: matrix,
|
|
342
|
-
indices
|
|
344
|
+
indices,
|
|
343
345
|
attributeSpecificTransformation: transformVertexPositions,
|
|
344
346
|
useCartesianPositions
|
|
345
347
|
}));
|
|
@@ -348,19 +350,55 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
348
350
|
cartographicOrigin,
|
|
349
351
|
cartesianModelMatrix,
|
|
350
352
|
nodeMatrix: matrix,
|
|
351
|
-
indices
|
|
353
|
+
indices,
|
|
352
354
|
attributeSpecificTransformation: transformVertexNormals,
|
|
353
355
|
useCartesianPositions: false
|
|
354
356
|
}));
|
|
355
|
-
outputAttributes.texCoords = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value,
|
|
356
|
-
outputAttributes.colors = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0,
|
|
357
|
+
outputAttributes.texCoords = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices));
|
|
358
|
+
outputAttributes.colors = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, indices));
|
|
357
359
|
if (materialUvRegion) {
|
|
358
|
-
outputAttributes.uvRegions = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion,
|
|
360
|
+
outputAttributes.uvRegions = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
|
|
359
361
|
}
|
|
360
362
|
outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
|
|
361
|
-
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images),
|
|
363
|
+
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
|
|
362
364
|
}
|
|
363
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Converts TRIANGLE-STRIPS to independent TRIANGLES
|
|
368
|
+
* @param {MeshPrimitive} primitive - the primitive to get the indices from
|
|
369
|
+
* @returns indices of vertices of the independent triangles
|
|
370
|
+
*/
|
|
371
|
+
function getIndices(primitive) {
|
|
372
|
+
let indices = primitive.indices?.value;
|
|
373
|
+
if (indices && primitive.mode === math_1.GL.TRIANGLE_STRIP) {
|
|
374
|
+
/*
|
|
375
|
+
TRIANGLE_STRIP geometry contains n+2 vertices for n triangles;
|
|
376
|
+
TRIANGLE geometry contains n*3 vertices for n triangles.
|
|
377
|
+
The conversion from TRIANGLE_STRIP to TRIANGLE implies duplicating adjacent vertices.
|
|
378
|
+
*/
|
|
379
|
+
const TypedArrayConstructor = indices.constructor;
|
|
380
|
+
const newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
|
|
381
|
+
// Copy the first triangle indices with no modification like [i0, i1, i2, ...] -> [i0, i1, i2, ...]
|
|
382
|
+
let triangleIndex = 0;
|
|
383
|
+
let currentTriangle = indices.slice(0, 3);
|
|
384
|
+
newIndices.set(currentTriangle, 0);
|
|
385
|
+
// The rest triangle indices are being taken from strips using the following logic:
|
|
386
|
+
// [i1, i2, i3, i4, i5, i6, ...] -> [i3, i2, i1, i2, i3, i4, i5, i4, i3, i4, i5, i6, ...]
|
|
387
|
+
for (let i = 1; i + 2 < indices.length; i++) {
|
|
388
|
+
triangleIndex += 3;
|
|
389
|
+
currentTriangle = indices.slice(i, i + 3);
|
|
390
|
+
if (i % 2 === 0) {
|
|
391
|
+
newIndices.set(currentTriangle, triangleIndex);
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
// The following "reverce" is necessary to calculate normals correctly
|
|
395
|
+
newIndices.set(currentTriangle.reverse(), triangleIndex);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
indices = newIndices;
|
|
399
|
+
}
|
|
400
|
+
return indices;
|
|
401
|
+
}
|
|
364
402
|
/**
|
|
365
403
|
* Convert vertices attributes (POSITIONS or NORMALS) to i3s compatible format
|
|
366
404
|
* @param args
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-debug.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAM,mBAAmB,EAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"node-debug.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAM,mBAAmB,EAAM,MAAM,iBAAiB,CAAC;AAiBnE;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAW/E"}
|
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateNodeBoundingVolumes = void 0;
|
|
4
4
|
const culling_1 = require("@math.gl/culling");
|
|
5
|
-
const engine_1 = require("@luma.gl/engine");
|
|
6
5
|
const core_1 = require("@math.gl/core");
|
|
7
6
|
const geospatial_1 = require("@math.gl/geospatial");
|
|
7
|
+
// prettier-ignore
|
|
8
|
+
const CUBE_POSITIONS = new Float32Array([
|
|
9
|
+
-1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1,
|
|
10
|
+
-1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1,
|
|
11
|
+
-1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1,
|
|
12
|
+
-1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1,
|
|
13
|
+
1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1,
|
|
14
|
+
-1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1
|
|
15
|
+
]);
|
|
8
16
|
// TODO Unite Tile validation logic in i3s-17-and-debug with this code.
|
|
9
17
|
/**
|
|
10
18
|
* Do validation of bounding volumes for particular node.
|
|
@@ -75,11 +83,9 @@ function createBoundingBoxFromTileObb(obb) {
|
|
|
75
83
|
* @param node
|
|
76
84
|
*/
|
|
77
85
|
function getTileObbVertices(node) {
|
|
78
|
-
const geometry = new engine_1.CubeGeometry();
|
|
79
86
|
// @ts-expect-error
|
|
80
87
|
const halfSize = node.obb.halfSize;
|
|
81
|
-
const
|
|
82
|
-
const positions = new Float32Array(attributes.POSITION.value);
|
|
88
|
+
const positions = CUBE_POSITIONS;
|
|
83
89
|
// @ts-expect-error
|
|
84
90
|
const obbCenterCartesian = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(node.obb.center);
|
|
85
91
|
let vertices = [];
|
|
@@ -11,7 +11,7 @@ const file_utils_1 = require("../../lib/utils/file-utils");
|
|
|
11
11
|
* class NodePages - wrapper of nodePages array
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
|
-
* import {writeFile} from './helpers/write-file';
|
|
14
|
+
* import {writeFile} from './helpers/write-file.js';
|
|
15
15
|
*
|
|
16
16
|
* // create an instance of the class
|
|
17
17
|
* const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
@@ -141,4 +141,5 @@ export type MergedMaterial = {
|
|
|
141
141
|
/** Uint16Array of 4 elements https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md */
|
|
142
142
|
uvRegion?: Uint16Array;
|
|
143
143
|
};
|
|
144
|
+
export type TypedArrayConstructor = Uint8ArrayConstructor | Int8ArrayConstructor | Uint16ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
|
144
145
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,4CAA4C;AAC5C,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,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,qBAAqB,EAAE,CAAC;IACjD,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG;IACnC,2GAA2G;IAC3G,QAAQ,EAAE,qBAAqB,CAAC;IAChC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,uCAAuC;IACvC,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,qBAAqB,GACrB,oBAAoB,GACpB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "3.4.0-alpha.
|
|
3
|
+
"version": "3.4.0-alpha.4",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -44,20 +44,19 @@
|
|
|
44
44
|
"build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node14 --external:join-images --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@loaders.gl/3d-tiles": "3.4.0-alpha.
|
|
48
|
-
"@loaders.gl/crypto": "3.4.0-alpha.
|
|
49
|
-
"@loaders.gl/draco": "3.4.0-alpha.
|
|
50
|
-
"@loaders.gl/gltf": "3.4.0-alpha.
|
|
51
|
-
"@loaders.gl/i3s": "3.4.0-alpha.
|
|
52
|
-
"@loaders.gl/images": "3.4.0-alpha.
|
|
53
|
-
"@loaders.gl/loader-utils": "3.4.0-alpha.
|
|
54
|
-
"@loaders.gl/polyfills": "3.4.0-alpha.
|
|
55
|
-
"@loaders.gl/schema": "3.4.0-alpha.
|
|
56
|
-
"@loaders.gl/textures": "3.4.0-alpha.
|
|
57
|
-
"@loaders.gl/tiles": "3.4.0-alpha.
|
|
58
|
-
"@loaders.gl/worker-utils": "3.4.0-alpha.
|
|
59
|
-
"@loaders.gl/zip": "3.4.0-alpha.
|
|
60
|
-
"@luma.gl/engine": "^8.5.4",
|
|
47
|
+
"@loaders.gl/3d-tiles": "3.4.0-alpha.4",
|
|
48
|
+
"@loaders.gl/crypto": "3.4.0-alpha.4",
|
|
49
|
+
"@loaders.gl/draco": "3.4.0-alpha.4",
|
|
50
|
+
"@loaders.gl/gltf": "3.4.0-alpha.4",
|
|
51
|
+
"@loaders.gl/i3s": "3.4.0-alpha.4",
|
|
52
|
+
"@loaders.gl/images": "3.4.0-alpha.4",
|
|
53
|
+
"@loaders.gl/loader-utils": "3.4.0-alpha.4",
|
|
54
|
+
"@loaders.gl/polyfills": "3.4.0-alpha.4",
|
|
55
|
+
"@loaders.gl/schema": "3.4.0-alpha.4",
|
|
56
|
+
"@loaders.gl/textures": "3.4.0-alpha.4",
|
|
57
|
+
"@loaders.gl/tiles": "3.4.0-alpha.4",
|
|
58
|
+
"@loaders.gl/worker-utils": "3.4.0-alpha.4",
|
|
59
|
+
"@loaders.gl/zip": "3.4.0-alpha.4",
|
|
61
60
|
"@math.gl/core": "^3.5.1",
|
|
62
61
|
"@math.gl/culling": "^3.5.1",
|
|
63
62
|
"@math.gl/geoid": "^3.5.1",
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
"join-images": "^1.1.3",
|
|
81
80
|
"sharp": "^0.31.3"
|
|
82
81
|
},
|
|
83
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "f039a523df8b908a91f26c5ba8c4cfc1924b6140"
|
|
84
83
|
}
|
|
@@ -40,6 +40,15 @@ import {B3DMAttributesData /*, transformI3SAttributesOnWorker*/} from '../../i3s
|
|
|
40
40
|
import {prepareDataForAttributesConversion} from './gltf-attributes';
|
|
41
41
|
import {handleBatchIdsExtensions} from './batch-ids-extensions';
|
|
42
42
|
import {checkPropertiesLength, flattenPropertyTableByFeatureIds} from './feature-attributes';
|
|
43
|
+
import {MeshPrimitive} from 'modules/gltf/src/lib/types/gltf-postprocessed-schema';
|
|
44
|
+
import {GL} from '@loaders.gl/math';
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
At the moment of writing the type TypedArrayConstructor is not exported in '@math.gl/types'.
|
|
48
|
+
So the following import is replaced with the local import
|
|
49
|
+
import type {TypedArrayConstructor} from '@math.gl/types';
|
|
50
|
+
*/
|
|
51
|
+
import type {TypedArrayConstructor} from '../types';
|
|
43
52
|
|
|
44
53
|
// Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/pbrMetallicRoughness.cmn.md
|
|
45
54
|
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
@@ -507,6 +516,8 @@ function convertMesh(
|
|
|
507
516
|
if (!outputAttributes) {
|
|
508
517
|
continue;
|
|
509
518
|
}
|
|
519
|
+
|
|
520
|
+
const indices = getIndices(primitive);
|
|
510
521
|
outputAttributes.positions = concatenateTypedArrays(
|
|
511
522
|
outputAttributes.positions,
|
|
512
523
|
transformVertexArray({
|
|
@@ -514,7 +525,7 @@ function convertMesh(
|
|
|
514
525
|
cartographicOrigin,
|
|
515
526
|
cartesianModelMatrix,
|
|
516
527
|
nodeMatrix: matrix,
|
|
517
|
-
indices
|
|
528
|
+
indices,
|
|
518
529
|
attributeSpecificTransformation: transformVertexPositions,
|
|
519
530
|
useCartesianPositions
|
|
520
531
|
})
|
|
@@ -526,37 +537,71 @@ function convertMesh(
|
|
|
526
537
|
cartographicOrigin,
|
|
527
538
|
cartesianModelMatrix,
|
|
528
539
|
nodeMatrix: matrix,
|
|
529
|
-
indices
|
|
540
|
+
indices,
|
|
530
541
|
attributeSpecificTransformation: transformVertexNormals,
|
|
531
542
|
useCartesianPositions: false
|
|
532
543
|
})
|
|
533
544
|
);
|
|
534
545
|
outputAttributes.texCoords = concatenateTypedArrays(
|
|
535
546
|
outputAttributes.texCoords,
|
|
536
|
-
flattenTexCoords(
|
|
537
|
-
attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value,
|
|
538
|
-
primitive.indices?.value
|
|
539
|
-
)
|
|
547
|
+
flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices)
|
|
540
548
|
);
|
|
541
549
|
|
|
542
550
|
outputAttributes.colors = concatenateTypedArrays(
|
|
543
551
|
outputAttributes.colors,
|
|
544
|
-
flattenColors(attributes.COLOR_0,
|
|
552
|
+
flattenColors(attributes.COLOR_0, indices)
|
|
545
553
|
);
|
|
546
554
|
|
|
547
555
|
if (materialUvRegion) {
|
|
548
556
|
outputAttributes.uvRegions = concatenateTypedArrays(
|
|
549
557
|
outputAttributes.uvRegions,
|
|
550
|
-
createUvRegion(materialUvRegion,
|
|
558
|
+
createUvRegion(materialUvRegion, indices)
|
|
551
559
|
);
|
|
552
560
|
}
|
|
553
561
|
|
|
554
562
|
outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
|
|
555
563
|
outputAttributes.featureIndicesGroups.push(
|
|
556
|
-
flattenBatchIds(getBatchIds(attributes, primitive, images),
|
|
564
|
+
flattenBatchIds(getBatchIds(attributes, primitive, images), indices)
|
|
557
565
|
);
|
|
558
566
|
}
|
|
559
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* Converts TRIANGLE-STRIPS to independent TRIANGLES
|
|
570
|
+
* @param {MeshPrimitive} primitive - the primitive to get the indices from
|
|
571
|
+
* @returns indices of vertices of the independent triangles
|
|
572
|
+
*/
|
|
573
|
+
function getIndices(primitive: MeshPrimitive): TypedArray {
|
|
574
|
+
let indices: TypedArray = primitive.indices?.value;
|
|
575
|
+
if (indices && primitive.mode === GL.TRIANGLE_STRIP) {
|
|
576
|
+
/*
|
|
577
|
+
TRIANGLE_STRIP geometry contains n+2 vertices for n triangles;
|
|
578
|
+
TRIANGLE geometry contains n*3 vertices for n triangles.
|
|
579
|
+
The conversion from TRIANGLE_STRIP to TRIANGLE implies duplicating adjacent vertices.
|
|
580
|
+
*/
|
|
581
|
+
const TypedArrayConstructor = indices.constructor as TypedArrayConstructor;
|
|
582
|
+
const newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
|
|
583
|
+
|
|
584
|
+
// Copy the first triangle indices with no modification like [i0, i1, i2, ...] -> [i0, i1, i2, ...]
|
|
585
|
+
let triangleIndex = 0;
|
|
586
|
+
let currentTriangle = indices.slice(0, 3);
|
|
587
|
+
newIndices.set(currentTriangle, 0);
|
|
588
|
+
|
|
589
|
+
// The rest triangle indices are being taken from strips using the following logic:
|
|
590
|
+
// [i1, i2, i3, i4, i5, i6, ...] -> [i3, i2, i1, i2, i3, i4, i5, i4, i3, i4, i5, i6, ...]
|
|
591
|
+
for (let i = 1; i + 2 < indices.length; i++) {
|
|
592
|
+
triangleIndex += 3;
|
|
593
|
+
currentTriangle = indices.slice(i, i + 3);
|
|
594
|
+
if (i % 2 === 0) {
|
|
595
|
+
newIndices.set(currentTriangle, triangleIndex);
|
|
596
|
+
} else {
|
|
597
|
+
// The following "reverce" is necessary to calculate normals correctly
|
|
598
|
+
newIndices.set(currentTriangle.reverse(), triangleIndex);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
indices = newIndices;
|
|
602
|
+
}
|
|
603
|
+
return indices;
|
|
604
|
+
}
|
|
560
605
|
|
|
561
606
|
/**
|
|
562
607
|
* Convert vertices attributes (POSITIONS or NORMALS) to i3s compatible format
|
|
@@ -575,7 +620,7 @@ function transformVertexArray(args: {
|
|
|
575
620
|
cartographicOrigin: number[];
|
|
576
621
|
cartesianModelMatrix: number[];
|
|
577
622
|
nodeMatrix: Matrix4;
|
|
578
|
-
indices:
|
|
623
|
+
indices: TypedArray;
|
|
579
624
|
attributeSpecificTransformation: Function;
|
|
580
625
|
useCartesianPositions: boolean;
|
|
581
626
|
}) {
|
|
@@ -654,7 +699,7 @@ function transformVertexNormals(vertexVector, calleeArgs): number[] {
|
|
|
654
699
|
* @param indices - gltf primitive indices
|
|
655
700
|
* @returns flattened texture coordinates
|
|
656
701
|
*/
|
|
657
|
-
function flattenTexCoords(texCoords: Float32Array, indices:
|
|
702
|
+
function flattenTexCoords(texCoords: Float32Array, indices: TypedArray): Float32Array {
|
|
658
703
|
const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
|
|
659
704
|
if (!texCoords) {
|
|
660
705
|
// We need dummy UV0s because it is required in 1.6
|
|
@@ -679,7 +724,7 @@ function flattenTexCoords(texCoords: Float32Array, indices: Uint8Array): Float32
|
|
|
679
724
|
*/
|
|
680
725
|
function flattenColors(
|
|
681
726
|
colorsAttribute: GLTFAccessorPostprocessed,
|
|
682
|
-
indices:
|
|
727
|
+
indices: TypedArray
|
|
683
728
|
): Uint8Array {
|
|
684
729
|
const components = colorsAttribute?.components || VALUES_PER_COLOR_ELEMENT;
|
|
685
730
|
const newColors = new Uint8Array(indices.length * components);
|
|
@@ -707,7 +752,7 @@ function flattenColors(
|
|
|
707
752
|
* @param indices - geometry indices data
|
|
708
753
|
* @returns - uv-region array
|
|
709
754
|
*/
|
|
710
|
-
function createUvRegion(materialUvRegion: Uint16Array, indices:
|
|
755
|
+
function createUvRegion(materialUvRegion: Uint16Array, indices: TypedArray): Uint16Array {
|
|
711
756
|
const result = new Uint16Array(indices.length * 4);
|
|
712
757
|
for (let i = 0; i < result.length; i += 4) {
|
|
713
758
|
result.set(materialUvRegion, i);
|
|
@@ -721,7 +766,7 @@ function createUvRegion(materialUvRegion: Uint16Array, indices: Uint8Array): Uin
|
|
|
721
766
|
* @param indices - gltf primitive indices
|
|
722
767
|
* @returns flattened batch ids
|
|
723
768
|
*/
|
|
724
|
-
function flattenBatchIds(batchedIds: number[], indices:
|
|
769
|
+
function flattenBatchIds(batchedIds: number[], indices: TypedArray): number[] {
|
|
725
770
|
if (!batchedIds.length || !indices.length) {
|
|
726
771
|
return [];
|
|
727
772
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type {Mbs, Node3DIndexDocument, Obb} from '@loaders.gl/i3s';
|
|
2
|
-
|
|
3
2
|
import {OrientedBoundingBox, BoundingSphere} from '@math.gl/culling';
|
|
4
|
-
import {CubeGeometry} from '@luma.gl/engine';
|
|
5
3
|
import {Vector3} from '@math.gl/core';
|
|
6
4
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
7
5
|
|
|
6
|
+
// prettier-ignore
|
|
7
|
+
const CUBE_POSITIONS = new Float32Array([
|
|
8
|
+
-1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1,
|
|
9
|
+
-1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1,
|
|
10
|
+
-1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1,
|
|
11
|
+
-1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1,
|
|
12
|
+
1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1,
|
|
13
|
+
-1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1
|
|
14
|
+
]);
|
|
15
|
+
|
|
8
16
|
// TODO Unite Tile validation logic in i3s-17-and-debug with this code.
|
|
9
17
|
|
|
10
18
|
/**
|
|
@@ -86,11 +94,9 @@ function createBoundingBoxFromTileObb(obb: Obb): OrientedBoundingBox {
|
|
|
86
94
|
* @param node
|
|
87
95
|
*/
|
|
88
96
|
function getTileObbVertices(node: Node3DIndexDocument): number[] {
|
|
89
|
-
const geometry = new CubeGeometry();
|
|
90
97
|
// @ts-expect-error
|
|
91
98
|
const halfSize = node.obb.halfSize;
|
|
92
|
-
const
|
|
93
|
-
const positions = new Float32Array(attributes.POSITION.value);
|
|
99
|
+
const positions = CUBE_POSITIONS;
|
|
94
100
|
// @ts-expect-error
|
|
95
101
|
const obbCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(node.obb.center);
|
|
96
102
|
|
|
@@ -153,3 +153,13 @@ export type MergedMaterial = {
|
|
|
153
153
|
/** Uint16Array of 4 elements https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md */
|
|
154
154
|
uvRegion?: Uint16Array;
|
|
155
155
|
};
|
|
156
|
+
|
|
157
|
+
export type TypedArrayConstructor =
|
|
158
|
+
| Uint8ArrayConstructor
|
|
159
|
+
| Int8ArrayConstructor
|
|
160
|
+
| Uint16ArrayConstructor
|
|
161
|
+
| Int16ArrayConstructor
|
|
162
|
+
| Int32ArrayConstructor
|
|
163
|
+
| Uint32ArrayConstructor
|
|
164
|
+
| Float32ArrayConstructor
|
|
165
|
+
| Float64ArrayConstructor;
|