@loaders.gl/tile-converter 4.1.0-alpha.10 → 4.1.0-alpha.11
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/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +8 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/converter-cli.js +2 -2
- package/dist/converter-cli.js.map +1 -1
- package/dist/converter.min.cjs +131 -220
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +6 -6
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
- package/dist/index.cjs +69 -106
- package/dist/lib/utils/compress-util.d.ts +0 -37
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +1 -149
- package/dist/lib/utils/compress-util.js.map +1 -1
- package/dist/lib/utils/conversion-dump.d.ts +2 -1
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +14 -10
- package/dist/lib/utils/conversion-dump.js.map +1 -1
- package/dist/pgm-loader.js +1 -1
- package/package.json +14 -14
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
- package/src/converter-cli.ts +2 -2
- package/src/i3s-converter/i3s-converter.ts +8 -36
- package/src/lib/utils/compress-util.ts +1 -264
- package/src/lib/utils/conversion-dump.ts +16 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"b3dm-converter.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;
|
|
1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AC,OAAO,KAAA;CAItB"}
|
|
@@ -7,6 +7,9 @@ import { convertTextureAtlas } from "./texture-atlas.js";
|
|
|
7
7
|
import { generateSyntheticIndices } from "../../lib/utils/geometry-utils.js";
|
|
8
8
|
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]);
|
|
9
9
|
const scratchVector = new Vector3();
|
|
10
|
+
const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';
|
|
11
|
+
const METALLIC_FACTOR_DEFAULT = 1.0;
|
|
12
|
+
const ROUGHNESS_FACTOR_DEFAULT = 1.0;
|
|
10
13
|
export default class B3dmConverter {
|
|
11
14
|
constructor() {
|
|
12
15
|
this.rtcCenter = void 0;
|
|
@@ -37,6 +40,11 @@ export default class B3dmConverter {
|
|
|
37
40
|
} = tileContent;
|
|
38
41
|
const gltfBuilder = new GLTFScenegraph();
|
|
39
42
|
const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);
|
|
43
|
+
const pbrMetallicRoughness = material === null || material === void 0 ? void 0 : material.pbrMetallicRoughness;
|
|
44
|
+
if (pbrMetallicRoughness && (pbrMetallicRoughness.metallicFactor === undefined || pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) && (pbrMetallicRoughness.roughnessFactor === undefined || pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)) {
|
|
45
|
+
gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
|
|
46
|
+
gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);
|
|
47
|
+
}
|
|
40
48
|
const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);
|
|
41
49
|
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
42
50
|
const positions = attributes.positions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"b3dm-converter.js","names":["encodeSync","GLTFScenegraph","GLTFWriter","Tile3DWriter","Matrix4","Vector3","Ellipsoid","convertTextureAtlas","generateSyntheticIndices","Z_UP_TO_Y_UP_MATRIX","scratchVector","B3dmConverter","constructor","rtcCenter","i3sTile","convert","i3sAttributesData","featureAttributes","arguments","length","undefined","gltf","buildGLTF","b3dm","gltfEncoded","Uint8Array","type","featuresLength","_getFeaturesLength","batchTable","tileContent","textureFormat","box","material","attributes","indices","originalIndices","modelMatrix","gltfBuilder","textureIndex","_addI3sTextureToGLTF","pbrMaterialInfo","_convertI3sMaterialToGLTFMaterial","materialIndex","addMaterial","positions","positionsValue","value","uvRegions","texCoords","cartesianOrigin","cartographicOrigin","WGS84","cartesianToCartographic","_normalizePositions","_createBatchIds","normals","_checkNormals","size","meshIndex","addMesh","mode","transformMatrix","_generateTransformMatrix","nodeIndex","addNode","matrix","sceneIndex","addScene","nodeIndices","setDefaultScene","createBinaryChunk","gltfBuffer","texture","selectedTexture","pbrMetallicRoughness","baseColorTexture","source","image","mimeType","_deduceMimeTypeFromFormat","imageIndex","addImage","addTexture","colors","newPositionsValue","Float32Array","index","vertex","subarray","cartesianOriginVector","vertexVector","Array","from","transform","add","cartographicToCartesian","subtract","set","translateOriginMatrix","translate","result","multiplyLeft","i3sContent","featureIds","OBJECTID","objectIds","i","featureId","batchId","indexOf","_BATCHID","byteOffset","format","console","warn","isTextureIndexExists","alphaMode","doubleSided","metallicFactor","roughnessFactor","texCoord","baseColorFactor","_setGLTFTexture","materialDefinition","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","firstKey","Object","keys","find"],"sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"sourcesContent":["import type {I3STileContent} from '@loaders.gl/i3s';\nimport {encodeSync} from '@loaders.gl/core';\nimport {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';\nimport {Tile3DWriter} from '@loaders.gl/3d-tiles';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {convertTextureAtlas} from './texture-atlas';\nimport {generateSyntheticIndices} from '../../lib/utils/geometry-utils';\n\nconst Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);\nconst scratchVector = new Vector3();\n\nexport type I3SAttributesData = {\n tileContent: I3STileContent;\n box: number[];\n textureFormat: string;\n};\n\n/**\n * Converts content of an I3S node to *.b3dm's file content\n */\nexport default class B3dmConverter {\n // @ts-expect-error\n rtcCenter: Float32Array;\n i3sTile: any;\n\n /**\n * The starter of content conversion\n * @param i3sTile - Tile3D instance for I3S node\n * @returns - encoded content\n */\n async convert(\n i3sAttributesData: I3SAttributesData,\n featureAttributes: any = null\n ): Promise<ArrayBuffer> {\n const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes);\n const b3dm = encodeSync(\n {\n gltfEncoded: new Uint8Array(gltf),\n type: 'b3dm',\n featuresLength: this._getFeaturesLength(featureAttributes),\n batchTable: featureAttributes\n },\n Tile3DWriter\n );\n return b3dm;\n }\n\n /**\n * Build and encode gltf\n * @param i3sTile - Tile3D instance for I3S node\n * @returns - encoded glb content\n */\n async buildGLTF(\n i3sAttributesData: I3SAttributesData,\n featureAttributes: any\n ): Promise<ArrayBuffer> {\n const {tileContent, textureFormat, box} = i3sAttributesData;\n const {material, attributes, indices: originalIndices, modelMatrix} = tileContent;\n const gltfBuilder = new GLTFScenegraph();\n\n const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);\n const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);\n const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);\n\n const positions = attributes.positions;\n const positionsValue = positions.value;\n\n if (attributes.uvRegions && attributes.texCoords) {\n attributes.texCoords.value = convertTextureAtlas(\n attributes.texCoords.value,\n attributes.uvRegions.value\n );\n }\n\n const cartesianOrigin = new Vector3(box);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n\n attributes.positions.value = this._normalizePositions(\n positionsValue,\n cartesianOrigin,\n cartographicOrigin,\n modelMatrix\n );\n this._createBatchIds(tileContent, featureAttributes);\n if (attributes.normals && !this._checkNormals(attributes.normals.value)) {\n delete attributes.normals;\n }\n const indices =\n originalIndices || generateSyntheticIndices(positionsValue.length / positions.size);\n const meshIndex = gltfBuilder.addMesh({\n attributes,\n indices,\n material: materialIndex,\n mode: 4\n });\n const transformMatrix = this._generateTransformMatrix(cartesianOrigin);\n const nodeIndex = gltfBuilder.addNode({meshIndex, matrix: transformMatrix});\n const sceneIndex = gltfBuilder.addScene({nodeIndices: [nodeIndex]});\n gltfBuilder.setDefaultScene(sceneIndex);\n\n gltfBuilder.createBinaryChunk();\n\n const gltfBuffer = encodeSync(gltfBuilder.gltf, GLTFWriter);\n\n return gltfBuffer;\n }\n\n /**\n * Update gltfBuilder with texture from I3S tile\n * @param {object} i3sTile - Tile3D object\n * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF\n * @returns {Promise<number | null>} - GLTF texture index\n */\n async _addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder) {\n const {texture, material, attributes} = tileContent;\n let textureIndex = null;\n let selectedTexture = texture;\n if (!texture && material) {\n selectedTexture =\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.baseColorTexture &&\n material.pbrMetallicRoughness.baseColorTexture.texture.source.image;\n }\n if (selectedTexture) {\n const mimeType = this._deduceMimeTypeFromFormat(textureFormat);\n const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);\n textureIndex = gltfBuilder.addTexture({imageIndex});\n delete attributes.colors;\n }\n return textureIndex;\n }\n\n /**\n * Generate a positions array which is correct for 3DTiles/GLTF format\n * @param {Float64Array} positionsValue - the input geometry positions array\n * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system\n * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system\n * @param {number[]} modelMatrix - the model matrix of geometry\n * @returns {Float32Array} - the output geometry positions array\n */\n _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {\n const newPositionsValue = new Float32Array(positionsValue.length);\n for (let index = 0; index < positionsValue.length; index += 3) {\n const vertex = positionsValue.subarray(index, index + 3);\n const cartesianOriginVector = new Vector3(cartesianOrigin);\n let vertexVector = new Vector3(Array.from(vertex))\n .transform(modelMatrix)\n .add(cartographicOrigin);\n Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);\n vertexVector = scratchVector.subtract(cartesianOriginVector);\n newPositionsValue.set(vertexVector, index);\n }\n return newPositionsValue;\n }\n\n /**\n * Generate the transformation matrix for GLTF node:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node\n * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)\n * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)\n * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system\n * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)\n */\n _generateTransformMatrix(cartesianOrigin) {\n const translateOriginMatrix = new Matrix4().translate(cartesianOrigin);\n const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);\n return result;\n }\n\n /**\n * Create _BATCHID attribute\n * @param {Object} i3sContent - the source object\n * @returns {void}\n */\n _createBatchIds(i3sContent, featureAttributes) {\n const {featureIds} = i3sContent;\n const {OBJECTID: objectIds} = featureAttributes || {};\n if (!featureIds || !objectIds) {\n return;\n }\n\n for (let i = 0; i < featureIds.length; i++) {\n const featureId = featureIds[i];\n const batchId = objectIds.indexOf(featureId);\n featureIds[i] = batchId;\n }\n\n i3sContent.attributes._BATCHID = {\n size: 1,\n byteOffset: 0,\n value: featureIds\n };\n }\n\n /**\n * Deduce mime type by format from `textureSetDefinition.formats[0].format`\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n * @param {string} format - format name\n * @returns {string} mime type.\n */\n _deduceMimeTypeFromFormat(format) {\n switch (format) {\n case 'jpg':\n return 'image/jpeg';\n case 'png':\n return 'image/png';\n case 'ktx2':\n return 'image/ktx2';\n default:\n console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef\n return 'image/jpeg';\n }\n }\n\n /**\n * Convert i3s material to GLTF compatible material\n * @param {object} material - i3s material definition\n * @param {number | null} textureIndex - texture index in GLTF\n * @returns {object} GLTF material\n */\n _convertI3sMaterialToGLTFMaterial(material, textureIndex) {\n const isTextureIndexExists = textureIndex !== null;\n\n if (!material) {\n material = {\n alphaMode: 'OPAQUE',\n doubleSided: false,\n pbrMetallicRoughness: {\n metallicFactor: 0,\n roughnessFactor: 1\n }\n };\n\n if (isTextureIndexExists) {\n material.pbrMetallicRoughness.baseColorTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else {\n material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];\n }\n\n return material;\n }\n\n if (textureIndex !== null) {\n material = this._setGLTFTexture(material, textureIndex);\n }\n\n return material;\n }\n\n /**\n * Set texture properties in material with GLTF textureIndex\n * @param {object} materialDefinition - i3s material definition\n * @param {number} textureIndex - texture index in GLTF\n * @returns {void}\n */\n _setGLTFTexture(materialDefinition, textureIndex) {\n const material = {\n ...materialDefinition,\n pbrMetallicRoughness: {...materialDefinition.pbrMetallicRoughness}\n };\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture\n ) {\n material.pbrMetallicRoughness.baseColorTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.emissiveTexture) {\n material.emissiveTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.normalTexture) {\n material.normalTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.occlusionTexture) {\n material.occlusionTexture = {\n index: textureIndex,\n texCoord: 0\n };\n }\n return material;\n }\n\n /*\n * Returns Features length based on attribute array in attribute object.\n * @param {Object} attributes\n * @returns {Number} Features length .\n */\n _getFeaturesLength(attributes) {\n if (!attributes) {\n return 0;\n }\n const firstKey = Object.keys(attributes)[0];\n return firstKey ? attributes[firstKey].length : 0;\n }\n\n /* Checks that normals buffer is correct\n * @param {TypedArray} normals\n * @returns {boolean} true - normals are correct; false - normals are incorrect\n */\n _checkNormals(normals) {\n // If all normals === 0, the resulting tileset is all in black colors on Cesium\n return normals.find((value) => value);\n }\n}\n"],"mappings":"AACA,SAAQA,UAAU,QAAO,kBAAkB;AAC3C,SAAQC,cAAc,EAAEC,UAAU,QAAO,kBAAkB;AAC3D,SAAQC,YAAY,QAAO,sBAAsB;AACjD,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,SAAS,QAAO,qBAAqB;AAAC,SACtCC,mBAAmB;AAAA,SACnBC,wBAAwB;AAEhC,MAAMC,mBAAmB,GAAG,IAAIL,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1F,MAAMM,aAAa,GAAG,IAAIL,OAAO,CAAC,CAAC;AAWnC,eAAe,MAAMM,aAAa,CAAC;EAAAC,YAAA;IAAA,KAEjCC,SAAS;IAAA,KACTC,OAAO;EAAA;EAOP,MAAMC,OAAOA,CACXC,iBAAoC,EAEd;IAAA,IADtBC,iBAAsB,GAA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LTFScenegraph","GLTFWriter","Tile3DWriter","Matrix4","Vector3","Ellipsoid","convertTextureAtlas","generateSyntheticIndices","Z_UP_TO_Y_UP_MATRIX","scratchVector","KHR_MATERIALS_UNLIT","METALLIC_FACTOR_DEFAULT","ROUGHNESS_FACTOR_DEFAULT","B3dmConverter","constructor","rtcCenter","i3sTile","convert","i3sAttributesData","featureAttributes","arguments","length","undefined","gltf","buildGLTF","b3dm","gltfEncoded","Uint8Array","type","featuresLength","_getFeaturesLength","batchTable","tileContent","textureFormat","box","material","attributes","indices","originalIndices","modelMatrix","gltfBuilder","textureIndex","_addI3sTextureToGLTF","pbrMetallicRoughness","metallicFactor","roughnessFactor","addObjectExtension","addExtension","pbrMaterialInfo","_convertI3sMaterialToGLTFMaterial","materialIndex","addMaterial","positions","positionsValue","value","uvRegions","texCoords","cartesianOrigin","cartographicOrigin","WGS84","cartesianToCartographic","_normalizePositions","_createBatchIds","normals","_checkNormals","size","meshIndex","addMesh","mode","transformMatrix","_generateTransformMatrix","nodeIndex","addNode","matrix","sceneIndex","addScene","nodeIndices","setDefaultScene","createBinaryChunk","gltfBuffer","texture","selectedTexture","baseColorTexture","source","image","mimeType","_deduceMimeTypeFromFormat","imageIndex","addImage","addTexture","colors","newPositionsValue","Float32Array","index","vertex","subarray","cartesianOriginVector","vertexVector","Array","from","transform","add","cartographicToCartesian","subtract","set","translateOriginMatrix","translate","result","multiplyLeft","i3sContent","featureIds","OBJECTID","objectIds","i","featureId","batchId","indexOf","_BATCHID","byteOffset","format","console","warn","isTextureIndexExists","alphaMode","doubleSided","texCoord","baseColorFactor","_setGLTFTexture","materialDefinition","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","firstKey","Object","keys","find"],"sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"sourcesContent":["import type {I3STileContent} from '@loaders.gl/i3s';\nimport {encodeSync} from '@loaders.gl/core';\nimport {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';\nimport {Tile3DWriter} from '@loaders.gl/3d-tiles';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {convertTextureAtlas} from './texture-atlas';\nimport {generateSyntheticIndices} from '../../lib/utils/geometry-utils';\n\nconst Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);\nconst scratchVector = new Vector3();\nconst KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';\nconst METALLIC_FACTOR_DEFAULT = 1.0;\nconst ROUGHNESS_FACTOR_DEFAULT = 1.0;\n\nexport type I3SAttributesData = {\n tileContent: I3STileContent;\n box: number[];\n textureFormat: string;\n};\n\n/**\n * Converts content of an I3S node to *.b3dm's file content\n */\nexport default class B3dmConverter {\n // @ts-expect-error\n rtcCenter: Float32Array;\n i3sTile: any;\n\n /**\n * The starter of content conversion\n * @param i3sTile - Tile3D instance for I3S node\n * @returns - encoded content\n */\n async convert(\n i3sAttributesData: I3SAttributesData,\n featureAttributes: any = null\n ): Promise<ArrayBuffer> {\n const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes);\n const b3dm = encodeSync(\n {\n gltfEncoded: new Uint8Array(gltf),\n type: 'b3dm',\n featuresLength: this._getFeaturesLength(featureAttributes),\n batchTable: featureAttributes\n },\n Tile3DWriter\n );\n return b3dm;\n }\n\n /**\n * Build and encode gltf\n * @param i3sTile - Tile3D instance for I3S node\n * @returns - encoded glb content\n */\n async buildGLTF(\n i3sAttributesData: I3SAttributesData,\n featureAttributes: any\n ): Promise<ArrayBuffer> {\n const {tileContent, textureFormat, box} = i3sAttributesData;\n const {material, attributes, indices: originalIndices, modelMatrix} = tileContent;\n const gltfBuilder = new GLTFScenegraph();\n\n const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);\n\n // Add KHR_MATERIALS_UNLIT extension in the following cases:\n // - metallicFactor or roughnessFactor are set to default values\n // - metallicFactor or roughnessFactor are not set\n const pbrMetallicRoughness = material?.pbrMetallicRoughness;\n if (\n pbrMetallicRoughness &&\n (pbrMetallicRoughness.metallicFactor === undefined ||\n pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) &&\n (pbrMetallicRoughness.roughnessFactor === undefined ||\n pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)\n ) {\n gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});\n gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);\n }\n\n const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);\n const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);\n\n const positions = attributes.positions;\n const positionsValue = positions.value;\n\n if (attributes.uvRegions && attributes.texCoords) {\n attributes.texCoords.value = convertTextureAtlas(\n attributes.texCoords.value,\n attributes.uvRegions.value\n );\n }\n\n const cartesianOrigin = new Vector3(box);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n\n attributes.positions.value = this._normalizePositions(\n positionsValue,\n cartesianOrigin,\n cartographicOrigin,\n modelMatrix\n );\n this._createBatchIds(tileContent, featureAttributes);\n if (attributes.normals && !this._checkNormals(attributes.normals.value)) {\n delete attributes.normals;\n }\n const indices =\n originalIndices || generateSyntheticIndices(positionsValue.length / positions.size);\n const meshIndex = gltfBuilder.addMesh({\n attributes,\n indices,\n material: materialIndex,\n mode: 4\n });\n const transformMatrix = this._generateTransformMatrix(cartesianOrigin);\n const nodeIndex = gltfBuilder.addNode({meshIndex, matrix: transformMatrix});\n const sceneIndex = gltfBuilder.addScene({nodeIndices: [nodeIndex]});\n gltfBuilder.setDefaultScene(sceneIndex);\n\n gltfBuilder.createBinaryChunk();\n\n const gltfBuffer = encodeSync(gltfBuilder.gltf, GLTFWriter);\n\n return gltfBuffer;\n }\n\n /**\n * Update gltfBuilder with texture from I3S tile\n * @param {object} i3sTile - Tile3D object\n * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF\n * @returns {Promise<number | null>} - GLTF texture index\n */\n async _addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder) {\n const {texture, material, attributes} = tileContent;\n let textureIndex = null;\n let selectedTexture = texture;\n if (!texture && material) {\n selectedTexture =\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.baseColorTexture &&\n material.pbrMetallicRoughness.baseColorTexture.texture.source.image;\n }\n if (selectedTexture) {\n const mimeType = this._deduceMimeTypeFromFormat(textureFormat);\n const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);\n textureIndex = gltfBuilder.addTexture({imageIndex});\n delete attributes.colors;\n }\n return textureIndex;\n }\n\n /**\n * Generate a positions array which is correct for 3DTiles/GLTF format\n * @param {Float64Array} positionsValue - the input geometry positions array\n * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system\n * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system\n * @param {number[]} modelMatrix - the model matrix of geometry\n * @returns {Float32Array} - the output geometry positions array\n */\n _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {\n const newPositionsValue = new Float32Array(positionsValue.length);\n for (let index = 0; index < positionsValue.length; index += 3) {\n const vertex = positionsValue.subarray(index, index + 3);\n const cartesianOriginVector = new Vector3(cartesianOrigin);\n let vertexVector = new Vector3(Array.from(vertex))\n .transform(modelMatrix)\n .add(cartographicOrigin);\n Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);\n vertexVector = scratchVector.subtract(cartesianOriginVector);\n newPositionsValue.set(vertexVector, index);\n }\n return newPositionsValue;\n }\n\n /**\n * Generate the transformation matrix for GLTF node:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node\n * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)\n * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)\n * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system\n * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)\n */\n _generateTransformMatrix(cartesianOrigin) {\n const translateOriginMatrix = new Matrix4().translate(cartesianOrigin);\n const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);\n return result;\n }\n\n /**\n * Create _BATCHID attribute\n * @param {Object} i3sContent - the source object\n * @returns {void}\n */\n _createBatchIds(i3sContent, featureAttributes) {\n const {featureIds} = i3sContent;\n const {OBJECTID: objectIds} = featureAttributes || {};\n if (!featureIds || !objectIds) {\n return;\n }\n\n for (let i = 0; i < featureIds.length; i++) {\n const featureId = featureIds[i];\n const batchId = objectIds.indexOf(featureId);\n featureIds[i] = batchId;\n }\n\n i3sContent.attributes._BATCHID = {\n size: 1,\n byteOffset: 0,\n value: featureIds\n };\n }\n\n /**\n * Deduce mime type by format from `textureSetDefinition.formats[0].format`\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n * @param {string} format - format name\n * @returns {string} mime type.\n */\n _deduceMimeTypeFromFormat(format) {\n switch (format) {\n case 'jpg':\n return 'image/jpeg';\n case 'png':\n return 'image/png';\n case 'ktx2':\n return 'image/ktx2';\n default:\n console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef\n return 'image/jpeg';\n }\n }\n\n /**\n * Convert i3s material to GLTF compatible material\n * @param {object} material - i3s material definition\n * @param {number | null} textureIndex - texture index in GLTF\n * @returns {object} GLTF material\n */\n _convertI3sMaterialToGLTFMaterial(material, textureIndex) {\n const isTextureIndexExists = textureIndex !== null;\n\n if (!material) {\n material = {\n alphaMode: 'OPAQUE',\n doubleSided: false,\n pbrMetallicRoughness: {\n metallicFactor: 0,\n roughnessFactor: 1\n }\n };\n\n if (isTextureIndexExists) {\n material.pbrMetallicRoughness.baseColorTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else {\n material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];\n }\n\n return material;\n }\n\n if (textureIndex !== null) {\n material = this._setGLTFTexture(material, textureIndex);\n }\n\n return material;\n }\n\n /**\n * Set texture properties in material with GLTF textureIndex\n * @param {object} materialDefinition - i3s material definition\n * @param {number} textureIndex - texture index in GLTF\n * @returns {void}\n */\n _setGLTFTexture(materialDefinition, textureIndex) {\n const material = {\n ...materialDefinition,\n pbrMetallicRoughness: {...materialDefinition.pbrMetallicRoughness}\n };\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture\n ) {\n material.pbrMetallicRoughness.baseColorTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.emissiveTexture) {\n material.emissiveTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.normalTexture) {\n material.normalTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.occlusionTexture) {\n material.occlusionTexture = {\n index: textureIndex,\n texCoord: 0\n };\n }\n return material;\n }\n\n /*\n * Returns Features length based on attribute array in attribute object.\n * @param {Object} attributes\n * @returns {Number} Features length .\n */\n _getFeaturesLength(attributes) {\n if (!attributes) {\n return 0;\n }\n const firstKey = Object.keys(attributes)[0];\n return firstKey ? attributes[firstKey].length : 0;\n }\n\n /* Checks that normals buffer is correct\n * @param {TypedArray} normals\n * @returns {boolean} true - normals are correct; false - normals are incorrect\n */\n _checkNormals(normals) {\n // If all normals === 0, the resulting tileset is all in black colors on Cesium\n return normals.find((value) => value);\n }\n}\n"],"mappings":"AACA,SAAQA,UAAU,QAAO,kBAAkB;AAC3C,SAAQC,cAAc,EAAEC,UAAU,QAAO,kBAAkB;AAC3D,SAAQ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converter';
|
|
5
5
|
import { DepsInstaller } from "./deps-installer/deps-installer.js";
|
|
6
6
|
import { getBooleanValue, getIntegerValue, getStringValue, getURLValue, validateOptionsWithEqual } from "./lib/utils/cli-utils.js";
|
|
7
|
-
import { addOneFile, composeHashFile } from '@loaders.gl/zip';
|
|
7
|
+
import { addOneFile, composeHashFile, makeZipCDHeaderIterator } from '@loaders.gl/zip';
|
|
8
8
|
import { FileHandleFile } from '@loaders.gl/loader-utils';
|
|
9
9
|
import { copyFile } from 'node:fs/promises';
|
|
10
10
|
const TILESET_TYPE = {
|
|
@@ -49,7 +49,7 @@ async function main() {
|
|
|
49
49
|
if (finalPath !== validatedOptions.tileset) {
|
|
50
50
|
await copyFile(validatedOptions.tileset, finalPath);
|
|
51
51
|
}
|
|
52
|
-
const hashTable = await composeHashFile(new FileHandleFile(finalPath));
|
|
52
|
+
const hashTable = await composeHashFile(makeZipCDHeaderIterator(new FileHandleFile(finalPath)));
|
|
53
53
|
await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter-cli.js","names":["join","inquirer","I3SConverter","Tiles3DConverter","DepsInstaller","getBooleanValue","getIntegerValue","getStringValue","getURLValue","validateOptionsWithEqual","addOneFile","composeHashFile","FileHandleFile","copyFile","TILESET_TYPE","I3S","_3DTILES","main","args","process","argv","length","printHelp","validatedOptionsArr","options","parseOptions","installDependencies","depthInstaller","install","addHash","validatedOptions","validateOptions","finalPath","tileset","output","nameWithoutExt","substring","result","prompt","name","type","message","choices","value","isNewFileRequired","hashTable","convert","catch","error","console","log","exit","inputType","toUpperCase","tiles3DConverter","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","mergeMaterials","generateTextures","generateBoundingVolumes","validate","instantNodeWriting","metadataClass","analyze","mandatoryOptionsWithExceptions","getMessage","condition","Boolean","Object","values","includes","exceptions","mandatoryOption","optionValue","conditionFunc","testValue","push","forEach","exeption","opts","cwd","arg","index","indexOf","warn"],"sources":["../src/converter-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport {join} from 'path';\nimport inquirer from 'inquirer';\nimport {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';\nimport {DepsInstaller} from './deps-installer/deps-installer';\nimport {\n getBooleanValue,\n getIntegerValue,\n getStringValue,\n getURLValue,\n validateOptionsWithEqual\n} from './lib/utils/cli-utils';\nimport {addOneFile, composeHashFile} from '@loaders.gl/zip';\nimport {FileHandleFile} from '@loaders.gl/loader-utils';\nimport {copyFile} from 'node:fs/promises';\n\ntype TileConversionOptions = {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType?: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n /** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */\n instantNodeWriting: boolean;\n /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */\n mergeMaterials: boolean;\n /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: \"C:\\Program Files\\7-Zip\\7z.exe\" */\n sevenZipExe: string;\n /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,\n * default: \"./deps/egm2008-5.pgm\". A model file can be loaded from GeographicLib\n * https://geographiclib.sourceforge.io/html/geoid.html */\n egm: string;\n /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */\n token?: string;\n /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */\n draco: boolean;\n /** Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is\n * implemented */\n installDependencies: boolean;\n /** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture\n * if only KTX2 is provided */\n generateTextures: boolean;\n /** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */\n generateBoundingVolumes: boolean;\n /** Validate the dataset during conversion. Validation messages will be posted in the console output */\n validate: boolean;\n /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */\n maxDepth?: number;\n /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */\n slpk: boolean;\n /** adds hash file to the slpk if there's no one */\n addHash: boolean;\n /** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */\n metadataClass?: string;\n /** With this options the tileset content will be analyzed without conversion */\n analyze?: boolean;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\ntype ValidatedTileConversionOptions = TileConversionOptions & {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name: string;\n};\n\nconst TILESET_TYPE = {\n I3S: 'I3S',\n _3DTILES: '3DTILES'\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: TileConversionOptions = parseOptions(validatedOptionsArr);\n\n if (options.installDependencies) {\n const depthInstaller = new DepsInstaller();\n depthInstaller.install('deps');\n return;\n }\n\n if (options.addHash) {\n const validatedOptions = validateOptions(options, true);\n let finalPath = validatedOptions.tileset;\n if (validatedOptions.output === 'data') {\n const nameWithoutExt = validatedOptions.tileset.substring(\n 0,\n validatedOptions.tileset.length - 5\n );\n\n const result = await inquirer.prompt<{isNewFileRequired: boolean}>([\n {\n name: 'isNewFileRequired',\n type: 'list',\n message: 'What would you like to do?',\n choices: [\n {\n name: 'Add hash file to the current SLPK file',\n value: false\n },\n {\n name: `Create a new file ${nameWithoutExt}-hash.slpk with hash file inside`,\n value: true\n }\n ]\n }\n ]);\n\n if (result.isNewFileRequired) {\n finalPath = `${nameWithoutExt}-hash.slpk`;\n }\n } else {\n finalPath = validatedOptions.output;\n }\n if (finalPath !== validatedOptions.tileset) {\n await copyFile(validatedOptions.tileset, finalPath);\n }\n const hashTable = await composeHashFile(new FileHandleFile(finalPath));\n await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');\n\n return;\n }\n\n const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx tile-converter --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');\n console.log(\n '--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is implemented]'\n );\n console.log(\n '--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'\n );\n console.log('--name [Tileset name]');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log(\n '--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'\n );\n console.log(\n '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'\n );\n console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');\n console.log(\n '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'\n );\n console.log('--input-type [tileset input type: I3S or 3DTILES]');\n console.log(\n '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\"]'\n );\n console.log(\n '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: \"./deps/egm2008-5.zip\"'\n );\n console.log('--token [Token for Cesium ION tilesets authentication]');\n console.log('--no-draco [Disable draco compression for geometry]');\n console.log(\n '--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'\n );\n console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');\n console.log('--analyze [Analyze the input tileset content without conversion, default: false]');\n console.log(\n '--metadata-class [One of the list of feature metadata classes, detected by converter on \"analyze\" stage, default: not set]'\n );\n console.log('--validate [Enable validation]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run conversion process\n * @param options validated tile-converter options\n */\nasync function convert(options: ValidatedTileConversionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const inputType = options.inputType.toUpperCase();\n switch (inputType) {\n case TILESET_TYPE.I3S:\n const tiles3DConverter = new Tiles3DConverter();\n tiles3DConverter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n egmFilePath: options.egm\n });\n break;\n case TILESET_TYPE._3DTILES:\n const converter = new I3SConverter();\n await converter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n slpk: options.slpk,\n sevenZipExe: options.sevenZipExe,\n egmFilePath: options.egm,\n token: options.token,\n draco: options.draco,\n mergeMaterials: options.mergeMaterials,\n generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate,\n instantNodeWriting: options.instantNodeWriting,\n metadataClass: options.metadataClass,\n analyze: options.analyze,\n inquirer\n });\n break;\n default:\n printHelp();\n }\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(\n options: TileConversionOptions,\n addHash?: boolean\n): ValidatedTileConversionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: {\n getMessage: () => void;\n condition?: (optionValue: any) => boolean;\n };\n } = {\n name: {\n getMessage: () => console.log('Missed: --name [Tileset name]'),\n condition: (value: any) => addHash || Boolean(value) || Boolean(options.analyze)\n },\n output: {getMessage: () => console.log('Missed: --output [Output path name]')},\n sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},\n egm: {getMessage: () => console.log('Missed: --egm [*.pgm earth gravity model file path]')},\n tileset: {getMessage: () => console.log('Missed: --tileset [tileset.json file]')},\n inputType: {\n getMessage: () =>\n console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]'),\n condition: (value) =>\n addHash || (Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase()))\n }\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n\n const conditionFunc = mandatoryOptionsWithExceptions[mandatoryOption].condition;\n const testValue = conditionFunc ? conditionFunc(optionValue) : optionValue;\n\n if (!testValue) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption].getMessage);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedTileConversionOptions>options;\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): TileConversionOptions {\n const opts: TileConversionOptions = {\n output: 'data',\n instantNodeWriting: false,\n mergeMaterials: true,\n sevenZipExe: 'C:\\\\Program Files\\\\7-Zip\\\\7z.exe',\n egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),\n draco: true,\n installDependencies: false,\n generateTextures: false,\n generateBoundingVolumes: false,\n validate: false,\n slpk: false,\n addHash: false\n };\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--input-type':\n opts.inputType = getStringValue(index, args);\n break;\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--name':\n opts.name = getStringValue(index, args);\n break;\n case '--output':\n opts.output = getStringValue(index, args);\n break;\n case '--instant-node-writing':\n opts.instantNodeWriting = getBooleanValue(index, args);\n break;\n case '--split-nodes':\n opts.mergeMaterials = getBooleanValue(index, args);\n break;\n case '--max-depth':\n opts.maxDepth = getIntegerValue(index, args);\n break;\n case '--slpk':\n opts.slpk = getBooleanValue(index, args);\n break;\n case '--add-hash':\n opts.addHash = getBooleanValue(index, args);\n break;\n case '--7zExe':\n opts.sevenZipExe = getStringValue(index, args);\n break;\n case '--egm':\n opts.egm = getStringValue(index, args);\n break;\n case '--token':\n opts.token = getStringValue(index, args);\n break;\n case '--no-draco':\n opts.draco = getBooleanValue(index, args);\n break;\n case '--validate':\n opts.validate = getBooleanValue(index, args);\n break;\n case '--install-dependencies':\n opts.installDependencies = getBooleanValue(index, args);\n break;\n case '--generate-textures':\n opts.generateTextures = getBooleanValue(index, args);\n break;\n case '--generate-bounding-volumes':\n opts.generateBoundingVolumes = getBooleanValue(index, args);\n break;\n case '--analyze':\n opts.analyze = getBooleanValue(index, args);\n break;\n case '--metadata-class':\n opts.metadataClass = getStringValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SAAQC,YAAY,EAAEC,gBAAgB,QAAO,4BAA4B;AAAC,SAClEC,aAAa;AAAA,SAEnBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,wBAAwB;AAE1B,SAAQC,UAAU,EAAEC,eAAe,QAAO,iBAAiB;AAC3D,SAAQC,cAAc,QAAO,0BAA0B;AACvD,SAAQC,QAAQ,QAAO,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AC;EACF,OAAOqC,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"converter-cli.js","names":["join","inquirer","I3SConverter","Tiles3DConverter","DepsInstaller","getBooleanValue","getIntegerValue","getStringValue","getURLValue","validateOptionsWithEqual","addOneFile","composeHashFile","makeZipCDHeaderIterator","FileHandleFile","copyFile","TILESET_TYPE","I3S","_3DTILES","main","args","process","argv","length","printHelp","validatedOptionsArr","options","parseOptions","installDependencies","depthInstaller","install","addHash","validatedOptions","validateOptions","finalPath","tileset","output","nameWithoutExt","substring","result","prompt","name","type","message","choices","value","isNewFileRequired","hashTable","convert","catch","error","console","log","exit","inputType","toUpperCase","tiles3DConverter","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","mergeMaterials","generateTextures","generateBoundingVolumes","validate","instantNodeWriting","metadataClass","analyze","mandatoryOptionsWithExceptions","getMessage","condition","Boolean","Object","values","includes","exceptions","mandatoryOption","optionValue","conditionFunc","testValue","push","forEach","exeption","opts","cwd","arg","index","indexOf","warn"],"sources":["../src/converter-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport {join} from 'path';\nimport inquirer from 'inquirer';\nimport {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';\nimport {DepsInstaller} from './deps-installer/deps-installer';\nimport {\n getBooleanValue,\n getIntegerValue,\n getStringValue,\n getURLValue,\n validateOptionsWithEqual\n} from './lib/utils/cli-utils';\nimport {addOneFile, composeHashFile, makeZipCDHeaderIterator} from '@loaders.gl/zip';\nimport {FileHandleFile} from '@loaders.gl/loader-utils';\nimport {copyFile} from 'node:fs/promises';\n\ntype TileConversionOptions = {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType?: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n /** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */\n instantNodeWriting: boolean;\n /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */\n mergeMaterials: boolean;\n /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: \"C:\\Program Files\\7-Zip\\7z.exe\" */\n sevenZipExe: string;\n /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,\n * default: \"./deps/egm2008-5.pgm\". A model file can be loaded from GeographicLib\n * https://geographiclib.sourceforge.io/html/geoid.html */\n egm: string;\n /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */\n token?: string;\n /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */\n draco: boolean;\n /** Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is\n * implemented */\n installDependencies: boolean;\n /** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture\n * if only KTX2 is provided */\n generateTextures: boolean;\n /** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */\n generateBoundingVolumes: boolean;\n /** Validate the dataset during conversion. Validation messages will be posted in the console output */\n validate: boolean;\n /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */\n maxDepth?: number;\n /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */\n slpk: boolean;\n /** adds hash file to the slpk if there's no one */\n addHash: boolean;\n /** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */\n metadataClass?: string;\n /** With this options the tileset content will be analyzed without conversion */\n analyze?: boolean;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\ntype ValidatedTileConversionOptions = TileConversionOptions & {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name: string;\n};\n\nconst TILESET_TYPE = {\n I3S: 'I3S',\n _3DTILES: '3DTILES'\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: TileConversionOptions = parseOptions(validatedOptionsArr);\n\n if (options.installDependencies) {\n const depthInstaller = new DepsInstaller();\n depthInstaller.install('deps');\n return;\n }\n\n if (options.addHash) {\n const validatedOptions = validateOptions(options, true);\n let finalPath = validatedOptions.tileset;\n if (validatedOptions.output === 'data') {\n const nameWithoutExt = validatedOptions.tileset.substring(\n 0,\n validatedOptions.tileset.length - 5\n );\n\n const result = await inquirer.prompt<{isNewFileRequired: boolean}>([\n {\n name: 'isNewFileRequired',\n type: 'list',\n message: 'What would you like to do?',\n choices: [\n {\n name: 'Add hash file to the current SLPK file',\n value: false\n },\n {\n name: `Create a new file ${nameWithoutExt}-hash.slpk with hash file inside`,\n value: true\n }\n ]\n }\n ]);\n\n if (result.isNewFileRequired) {\n finalPath = `${nameWithoutExt}-hash.slpk`;\n }\n } else {\n finalPath = validatedOptions.output;\n }\n if (finalPath !== validatedOptions.tileset) {\n await copyFile(validatedOptions.tileset, finalPath);\n }\n const hashTable = await composeHashFile(makeZipCDHeaderIterator(new FileHandleFile(finalPath)));\n await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');\n\n return;\n }\n\n const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx tile-converter --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');\n console.log(\n '--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is implemented]'\n );\n console.log(\n '--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'\n );\n console.log('--name [Tileset name]');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log(\n '--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'\n );\n console.log(\n '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'\n );\n console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');\n console.log(\n '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'\n );\n console.log('--input-type [tileset input type: I3S or 3DTILES]');\n console.log(\n '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\"]'\n );\n console.log(\n '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: \"./deps/egm2008-5.zip\"'\n );\n console.log('--token [Token for Cesium ION tilesets authentication]');\n console.log('--no-draco [Disable draco compression for geometry]');\n console.log(\n '--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'\n );\n console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');\n console.log('--analyze [Analyze the input tileset content without conversion, default: false]');\n console.log(\n '--metadata-class [One of the list of feature metadata classes, detected by converter on \"analyze\" stage, default: not set]'\n );\n console.log('--validate [Enable validation]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run conversion process\n * @param options validated tile-converter options\n */\nasync function convert(options: ValidatedTileConversionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const inputType = options.inputType.toUpperCase();\n switch (inputType) {\n case TILESET_TYPE.I3S:\n const tiles3DConverter = new Tiles3DConverter();\n tiles3DConverter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n egmFilePath: options.egm\n });\n break;\n case TILESET_TYPE._3DTILES:\n const converter = new I3SConverter();\n await converter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n slpk: options.slpk,\n sevenZipExe: options.sevenZipExe,\n egmFilePath: options.egm,\n token: options.token,\n draco: options.draco,\n mergeMaterials: options.mergeMaterials,\n generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate,\n instantNodeWriting: options.instantNodeWriting,\n metadataClass: options.metadataClass,\n analyze: options.analyze,\n inquirer\n });\n break;\n default:\n printHelp();\n }\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(\n options: TileConversionOptions,\n addHash?: boolean\n): ValidatedTileConversionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: {\n getMessage: () => void;\n condition?: (optionValue: any) => boolean;\n };\n } = {\n name: {\n getMessage: () => console.log('Missed: --name [Tileset name]'),\n condition: (value: any) => addHash || Boolean(value) || Boolean(options.analyze)\n },\n output: {getMessage: () => console.log('Missed: --output [Output path name]')},\n sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},\n egm: {getMessage: () => console.log('Missed: --egm [*.pgm earth gravity model file path]')},\n tileset: {getMessage: () => console.log('Missed: --tileset [tileset.json file]')},\n inputType: {\n getMessage: () =>\n console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]'),\n condition: (value) =>\n addHash || (Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase()))\n }\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n\n const conditionFunc = mandatoryOptionsWithExceptions[mandatoryOption].condition;\n const testValue = conditionFunc ? conditionFunc(optionValue) : optionValue;\n\n if (!testValue) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption].getMessage);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedTileConversionOptions>options;\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): TileConversionOptions {\n const opts: TileConversionOptions = {\n output: 'data',\n instantNodeWriting: false,\n mergeMaterials: true,\n sevenZipExe: 'C:\\\\Program Files\\\\7-Zip\\\\7z.exe',\n egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),\n draco: true,\n installDependencies: false,\n generateTextures: false,\n generateBoundingVolumes: false,\n validate: false,\n slpk: false,\n addHash: false\n };\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--input-type':\n opts.inputType = getStringValue(index, args);\n break;\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--name':\n opts.name = getStringValue(index, args);\n break;\n case '--output':\n opts.output = getStringValue(index, args);\n break;\n case '--instant-node-writing':\n opts.instantNodeWriting = getBooleanValue(index, args);\n break;\n case '--split-nodes':\n opts.mergeMaterials = getBooleanValue(index, args);\n break;\n case '--max-depth':\n opts.maxDepth = getIntegerValue(index, args);\n break;\n case '--slpk':\n opts.slpk = getBooleanValue(index, args);\n break;\n case '--add-hash':\n opts.addHash = getBooleanValue(index, args);\n break;\n case '--7zExe':\n opts.sevenZipExe = getStringValue(index, args);\n break;\n case '--egm':\n opts.egm = getStringValue(index, args);\n break;\n case '--token':\n opts.token = getStringValue(index, args);\n break;\n case '--no-draco':\n opts.draco = getBooleanValue(index, args);\n break;\n case '--validate':\n opts.validate = getBooleanValue(index, args);\n break;\n case '--install-dependencies':\n opts.installDependencies = getBooleanValue(index, args);\n break;\n case '--generate-textures':\n opts.generateTextures = getBooleanValue(index, args);\n break;\n case '--generate-bounding-volumes':\n opts.generateBoundingVolumes = getBooleanValue(index, args);\n break;\n case '--analyze':\n opts.analyze = getBooleanValue(index, args);\n break;\n case '--metadata-class':\n opts.metadataClass = getStringValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SAAQC,YAAY,EAAEC,gBAAgB,QAAO,4BAA4B;AAAC,SAClEC,aAAa;AAAA,SAEnBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,wBAAwB;AAE1B,SAAQC,UAAU,EAAEC,eAAe,EAAEC,uBAAuB,QAAO,iBAAiB;AACpF,SAAQC,cAAc,QAAO,0BAA0B;AACvD,SAAQC,QAAQ,QAAO,kBAAkB;AA0DzC,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE;AACZ,CAAC;AAMD,eAAeC,IAAIA,CAAA,EAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC,IAAIF,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IACrBC,SAAS,CAAC,CAAC;EACb;EAEA,MAAMC,mBAAmB,GAAGf,wBAAwB,CAACU,IAAI,CAAC;EAE1D,MAAMM,OAA8B,GAAGC,YAAY,CAACF,mBAAmB,CAAC;EAExE,IAAIC,OAAO,CAACE,mBAAmB,EAAE;IAC/B,MAAMC,cAAc,GAAG,IAAIxB,aAAa,CAAC,CAAC;IAC1CwB,cAAc,CAACC,OAAO,CAAC,MAAM,CAAC;IAC9B;EACF;EAEA,IAAIJ,OAAO,CAACK,OAAO,EAAE;IACnB,MAAMC,gBAAgB,GAAGC,e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