@loaders.gl/tile-converter 4.0.0-alpha.16 → 4.0.0-alpha.18
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/bin/converter.js +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -4
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +39 -37
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +3 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +4 -2
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +10 -0
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/load-i3s.js +42 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +2 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +2 -0
- package/dist/converter.min.js +79 -79
- package/dist/dist.min.js +753 -3022
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +94 -81
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +6 -4
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js +63 -0
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +10 -4
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +46 -43
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +4 -3
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js +32 -0
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +72 -72
- package/dist/esm/lib/utils/lod-conversion-utils.js +6 -4
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/lib/utils/lod-conversion-utils.d.ts +2 -2
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
- package/dist/lib/utils/lod-conversion-utils.js +4 -4
- package/dist/slpk-extractor.min.js +38 -38
- package/package.json +14 -14
- package/src/3d-tiles-converter/3d-tiles-converter.ts +60 -46
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +11 -10
- package/src/3d-tiles-converter/helpers/load-i3s.ts +51 -0
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +6 -2
- package/src/lib/utils/lod-conversion-utils.ts +10 -6
|
@@ -27,14 +27,13 @@ export default class B3dmConverter {
|
|
|
27
27
|
async buildGltf(i3sAttributesData, featureAttributes) {
|
|
28
28
|
const {
|
|
29
29
|
tileContent,
|
|
30
|
-
textureFormat
|
|
30
|
+
textureFormat,
|
|
31
|
+
box
|
|
31
32
|
} = i3sAttributesData;
|
|
32
33
|
const {
|
|
33
34
|
material,
|
|
34
35
|
attributes,
|
|
35
36
|
indices: originalIndices,
|
|
36
|
-
cartesianOrigin,
|
|
37
|
-
cartographicOrigin,
|
|
38
37
|
modelMatrix
|
|
39
38
|
} = tileContent;
|
|
40
39
|
const gltfBuilder = new GLTFScenegraph();
|
|
@@ -46,6 +45,8 @@ export default class B3dmConverter {
|
|
|
46
45
|
if (attributes.uvRegions && attributes.texCoords) {
|
|
47
46
|
attributes.texCoords.value = convertTextureAtlas(attributes.texCoords.value, attributes.uvRegions.value);
|
|
48
47
|
}
|
|
48
|
+
const cartesianOrigin = new Vector3(box);
|
|
49
|
+
const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());
|
|
49
50
|
attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
|
|
50
51
|
this._createBatchIds(tileContent, featureAttributes);
|
|
51
52
|
if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
|
|
@@ -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","_defineProperty","convert","i3sAttributesData","featureAttributes","arguments","length","undefined","gltf","buildGltf","b3dm","gltfEncoded","Uint8Array","type","featuresLength","_getFeaturesLength","batchTable","tileContent","textureFormat","material","attributes","indices","originalIndices","cartesianOrigin","cartographicOrigin","modelMatrix","gltfBuilder","textureIndex","_addI3sTextureToGltf","pbrMaterialInfo","_convertI3sMaterialToGltfMaterial","materialIndex","addMaterial","positions","positionsValue","value","uvRegions","texCoords","_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","WGS84","cartographicToCartesian","subtract","set","translateOriginMatrix","translate","result","multiplyLeft","i3sContent","featureIds","OBJECTID","objectIds","i","featureId","batchId","indexOf","_BATCHID","byteOffset","format","console","warn","concat","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 {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: any;\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} = i3sAttributesData;\n const {\n material,\n attributes,\n indices: originalIndices,\n cartesianOrigin,\n cartographicOrigin,\n modelMatrix\n } = 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 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":";AAAA,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;AAC7C,SAAQC,mBAAmB,QAAO,iBAAiB;AACnD,SAAQC,wBAAwB,QAAO,gCAAgC;AAEvE,MAAMC,mBAAmB,GAAG,IAAIL,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAA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,CAAC7G,MAAM,GAAG,CAAC;EACnD;EAMAmC,aAAaA,CAACD,OAAO,EAAE;IAErB,OAAOA,OAAO,CAAC8E,IAAI,CAAEnF,KAAK,IAAKA,KAAK,CAAC;EACvC;AACF"}
|
|
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","_defineProperty","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","concat","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;AAC7C,SAAQC,mBAAmB,QAAO,iBAAiB;AACnD,SAAQC,wBAAwB,QAAO,gCAAgC;AAEvE,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;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AQ,CAAC,CAAC/G,MAAM,GAAG,CAAC;EACnD;EAMAsC,aAAaA,CAACD,OAAO,EAAE;IAErB,OAAOA,OAAO,CAAC6E,IAAI,CAAEtF,KAAK,IAAKA,KAAK,CAAC;EACvC;AACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { load } from '@loaders.gl/core';
|
|
2
|
+
import { I3SLoader } from '@loaders.gl/i3s';
|
|
3
|
+
export const loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions) => {
|
|
4
|
+
if (!sourceTileset || !sourceTile.contentUrl) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const loadOptions = {
|
|
8
|
+
...tilesetLoadOptions,
|
|
9
|
+
i3s: {
|
|
10
|
+
...tilesetLoadOptions.i3s,
|
|
11
|
+
isTileset: false,
|
|
12
|
+
isTileHeader: false,
|
|
13
|
+
_tileOptions: {
|
|
14
|
+
attributeUrls: sourceTile.attributeUrls,
|
|
15
|
+
textureUrl: sourceTile.textureUrl,
|
|
16
|
+
textureFormat: sourceTile.textureFormat,
|
|
17
|
+
textureLoaderOptions: sourceTile.textureLoaderOptions,
|
|
18
|
+
materialDefinition: sourceTile.materialDefinition,
|
|
19
|
+
isDracoGeometry: sourceTile.isDracoGeometry,
|
|
20
|
+
mbs: sourceTile.mbs
|
|
21
|
+
},
|
|
22
|
+
_tilesetOptions: {
|
|
23
|
+
store: sourceTileset.store,
|
|
24
|
+
attributeStorageInfo: sourceTileset.attributeStorageInfo,
|
|
25
|
+
fields: sourceTileset.fields
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const tileContent = await load(sourceTile.contentUrl, I3SLoader, loadOptions);
|
|
30
|
+
return tileContent;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=load-i3s.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-i3s.js","names":["load","I3SLoader","loadI3SContent","sourceTileset","sourceTile","tilesetLoadOptions","contentUrl","loadOptions","i3s","isTileset","isTileHeader","_tileOptions","attributeUrls","textureUrl","textureFormat","textureLoaderOptions","materialDefinition","isDracoGeometry","mbs","_tilesetOptions","store","attributeStorageInfo","fields","tileContent"],"sources":["../../../../src/3d-tiles-converter/helpers/load-i3s.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {\n I3STileContent,\n I3STileHeader,\n I3STilesetHeader,\n I3SLoader,\n I3SLoaderOptions\n} from '@loaders.gl/i3s';\n\n/**\n * Load I3S node content\n * @param sourceTileset - source layer JSON\n * @param sourceTile - source I3S node metadata\n * @param tilesetLoadOptions - load options for Tiles3DLoader\n * @returns - 3DTiles tile content or null\n */\nexport const loadI3SContent = async (\n sourceTileset: I3STilesetHeader | null,\n sourceTile: I3STileHeader,\n tilesetLoadOptions: I3SLoaderOptions\n): Promise<I3STileContent | null> => {\n if (!sourceTileset || !sourceTile.contentUrl) {\n return null;\n }\n\n const loadOptions = {\n ...tilesetLoadOptions,\n i3s: {\n ...tilesetLoadOptions.i3s,\n isTileset: false,\n isTileHeader: false,\n _tileOptions: {\n attributeUrls: sourceTile.attributeUrls,\n textureUrl: sourceTile.textureUrl,\n textureFormat: sourceTile.textureFormat,\n textureLoaderOptions: sourceTile.textureLoaderOptions,\n materialDefinition: sourceTile.materialDefinition,\n isDracoGeometry: sourceTile.isDracoGeometry,\n mbs: sourceTile.mbs\n },\n _tilesetOptions: {\n store: sourceTileset.store,\n attributeStorageInfo: sourceTileset.attributeStorageInfo,\n fields: sourceTileset.fields\n }\n }\n };\n const tileContent = await load(sourceTile.contentUrl, I3SLoader, loadOptions);\n\n return tileContent;\n};\n"],"mappings":"AAAA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAIEC,SAAS,QAEJ,iBAAiB;AASxB,OAAO,MAAMC,cAAc,GAAG,MAAAA,CAC5BC,aAAsC,EACtCC,UAAyB,EACzBC,kBAAoC,KACD;EACnC,IAAI,CAACF,aAAa,IAAI,CAACC,UAAU,CAACE,UAAU,EAAE;IAC5C,OAAO,IAAI;EACb;EAEA,MAAMC,WAAW,GAAG;IAClB,GAAGF,kBAAkB;IACrBG,GAAG,EAAE;MACH,GAAGH,kBAAkB,CAACG,GAAG;MACzBC,SAAS,EAAE,KAAK;MAChBC,YAAY,EAAE,KAAK;MACnBC,YAAY,EAAE;QACZC,aAAa,EAAER,UAAU,CAACQ,aAAa;QACvCC,UAAU,EAAET,UAAU,CAACS,UAAU;QACjCC,aAAa,EAAEV,UAAU,CAACU,aAAa;QACvCC,oBAAoB,EAAEX,UAAU,CAACW,oBAAoB;QACrDC,kBAAkB,EAAEZ,UAAU,CAACY,kBAAkB;QACjDC,eAAe,EAAEb,UAAU,CAACa,eAAe;QAC3CC,GAAG,EAAEd,UAAU,CAACc;MAClB,CAAC;MACDC,eAAe,EAAE;QACfC,KAAK,EAAEjB,aAAa,CAACiB,KAAK;QAC1BC,oBAAoB,EAAElB,aAAa,CAACkB,oBAAoB;QACxDC,MAAM,EAAEnB,aAAa,CAACmB;MACxB;IACF;EACF,CAAC;EACD,MAAMC,WAAW,GAAG,MAAMvB,IAAI,CAACI,UAAU,CAACE,UAAU,EAAEL,SAAS,EAAEM,WAAW,CAAC;EAE7E,OAAOgB,WAAW;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture-atlas.js","names":["convertTextureAtlas","texCoords","uvRegions","convertedTexCoords","Float32Array","length","normalisedRegions","normalizeRegions","index","uv","subarray","regions","slice","fractatedUV","fract","subtracted","multiplicationResult","convertedUV","Math","floor","MAX_UINT_16_VALUE","normalizedRegions"],"sources":["../../../../src/3d-tiles-converter/helpers/texture-atlas.ts"],"sourcesContent":["/**\n * Apply uvRegions to texture coordinates.\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md\n * Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n * @param texCoords\n * @param uvRegions\n */\nexport function convertTextureAtlas(texCoords:
|
|
1
|
+
{"version":3,"file":"texture-atlas.js","names":["convertTextureAtlas","texCoords","uvRegions","convertedTexCoords","Float32Array","length","normalisedRegions","normalizeRegions","index","uv","subarray","regions","slice","fractatedUV","fract","subtracted","multiplicationResult","convertedUV","Math","floor","MAX_UINT_16_VALUE","normalizedRegions"],"sources":["../../../../src/3d-tiles-converter/helpers/texture-atlas.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/loader-utils';\n\n/**\n * Apply uvRegions to texture coordinates.\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md\n * Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n * @param texCoords\n * @param uvRegions\n */\nexport function convertTextureAtlas(texCoords: TypedArray, uvRegions: TypedArray): Float32Array {\n const convertedTexCoords = new Float32Array(texCoords.length);\n const normalisedRegions = normalizeRegions(uvRegions);\n\n for (let index = 0; index < texCoords.length; index += 2) {\n const uv = texCoords.subarray(index, index + 2);\n const regions = normalisedRegions.slice(index * 2, index * 2 + 4);\n // fract(texCoords)\n const fractatedUV = fract([uv[0], uv[1]]);\n // (uvRegions.zw - uvRegions.xy)\n const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];\n // fract(texCoords) * (uvRegions.zw - uvRegions.xy)\n const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];\n // fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n const convertedUV = [\n multiplicationResult[0] + regions[0],\n multiplicationResult[1] + regions[1]\n ];\n\n convertedTexCoords[index] = convertedUV[0];\n convertedTexCoords[index + 1] = convertedUV[1];\n }\n\n return convertedTexCoords;\n}\n\n/**\n * Do fractation of UV array.\n * @param uv\n */\nfunction fract(uv: [number, number]): [number, number] {\n return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];\n}\n\n/**\n * Normalize uvRegions by dividing by the maximum Uint16 value\n * @param regions\n */\nfunction normalizeRegions(regions: TypedArray): number[] {\n // The code is for Uint16Array because it is the spec requirement\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.8/geometryUVRegion.cmn.md\n const MAX_UINT_16_VALUE = 65535;\n const normalizedRegions: number[] = [];\n\n for (let index = 0; index < regions.length; index++) {\n normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;\n }\n\n return normalizedRegions;\n}\n"],"mappings":"AASA,OAAO,SAASA,mBAAmBA,CAACC,SAAqB,EAAEC,SAAqB,EAAgB;EAC9F,MAAMC,kBAAkB,GAAG,IAAIC,YAAY,CAACH,SAAS,CAACI,MAAM,CAAC;EAC7D,MAAMC,iBAAiB,GAAGC,gBAAgB,CAACL,SAAS,CAAC;EAErD,KAAK,IAAIM,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,SAAS,CAACI,MAAM,EAAEG,KAAK,IAAI,CAAC,EAAE;IACxD,MAAMC,EAAE,GAAGR,SAAS,CAACS,QAAQ,CAACF,KAAK,EAAEA,KAAK,GAAG,CAAC,CAAC;IAC/C,MAAMG,OAAO,GAAGL,iBAAiB,CAACM,KAAK,CAACJ,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;IAEjE,MAAMK,WAAW,GAAGC,KAAK,CAAC,CAACL,EAAE,CAAC,CAAC,CAAC,EAAEA,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzC,MAAMM,UAAU,GAAG,CAACJ,OAAO,CAAC,CAAC,CAAC,GAAGA,OAAO,CAAC,CAAC,CAAC,EAAEA,OAAO,CAAC,CAAC,CAAC,GAAGA,OAAO,CAAC,CAAC,CAAC,CAAC;IAErE,MAAMK,oBAAoB,GAAG,CAACH,WAAW,CAAC,CAAC,CAAC,GAAGE,UAAU,CAAC,CAAC,CAAC,EAAEF,WAAW,CAAC,CAAC,CAAC,GAAGE,UAAU,CAAC,CAAC,CAAC,CAAC;IAE7F,MAAME,WAAW,GAAG,CAClBD,oBAAoB,CAAC,CAAC,CAAC,GAAGL,OAAO,CAAC,CAAC,CAAC,EACpCK,oBAAoB,CAAC,CAAC,CAAC,GAAGL,OAAO,CAAC,CAAC,CAAC,CACrC;IAEDR,kBAAkB,CAACK,KAAK,CAAC,GAAGS,WAAW,CAAC,CAAC,CAAC;IAC1Cd,kBAAkB,CAACK,KAAK,GAAG,CAAC,CAAC,GAAGS,WAAW,CAAC,CAAC,CAAC;EAChD;EAEA,OAAOd,kBAAkB;AAC3B;AAMA,SAASW,KAAKA,CAACL,EAAoB,EAAoB;EACrD,OAAO,CAACA,EAAE,CAAC,CAAC,CAAC,GAAGS,IAAI,CAACC,KAAK,CAACV,EAAE,CAAC,CAAC,CAAC,CAAC,EAAEA,EAAE,CAAC,CAAC,CAAC,GAAGS,IAAI,CAACC,KAAK,CAACV,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D;AAMA,SAASF,gBAAgBA,CAACI,OAAmB,EAAY;EAGvD,MAAMS,iBAAiB,GAAG,KAAK;EAC/B,MAAMC,iBAA2B,GAAG,EAAE;EAEtC,KAAK,IAAIb,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGG,OAAO,CAACN,MAAM,EAAEG,KAAK,EAAE,EAAE;IACnDa,iBAAiB,CAACb,KAAK,CAAC,GAAGG,OAAO,CAACH,KAAK,CAAC,GAAGY,iBAAiB;EAC/D;EAEA,OAAOC,iBAAiB;AAC1B"}
|
|
@@ -3,7 +3,7 @@ import { ZipLoader } from '@loaders.gl/zip';
|
|
|
3
3
|
import { writeFile } from '../lib/utils/file-utils';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
6
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
6
|
+
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'beta';
|
|
7
7
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
8
8
|
export class DepsInstaller {
|
|
9
9
|
async install() {
|