@loaders.gl/tile-converter 3.2.0-alpha.3 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +5 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +4 -0
- package/dist/converter.min.js +21 -21
- package/dist/dist.min.js +64 -19
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +33 -22
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/constants.js +9 -0
- package/dist/es5/constants.js.map +1 -0
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +37 -23
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +29 -0
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +7 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +13 -3
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/layers.js +25 -0
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +8 -2
- package/dist/i3s-converter/json-templates/layers.d.ts +4 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
- package/dist/i3s-converter/json-templates/layers.js +24 -0
- package/package.json +20 -17
- package/src/3d-tiles-converter/3d-tiles-converter.ts +6 -1
- package/src/constants.ts +2 -0
- package/src/i3s-converter/i3s-converter.ts +9 -4
- package/src/i3s-converter/json-templates/layers.ts +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/i3s-converter/json-templates/layers.ts"],"names":["PLAIN_GEOMETRY_DEFINITION","offset","position","type","component","normal","uv0","color","featureId","binding","faceRange","PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0","COMPRESSED_GEOMETRY_DEFINITION","compressedAttributes","encoding","attributes","COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0","SPATIAL_REFERENCE","wkid","path","default","latestWkid","vcsWkid","latestVcsWkid","HEIGHT_MODEL_INFO","heightModel","vertCRS","heightUnit","NODE_PAGES","nodesPerPage","lodSelectionMetricType","LAYERS","version","transform","val","toUpperCase","id","name","href","layerType","spatialReference","capabilities","store","STORE","heightModelInfo","nodePages","materialDefinitions","textureSetDefinitions","geometryDefinitions","result","geometryBuffers","push","attributeStorageInfo","fields","popupInfo"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B;AAAA,SAAO;AACvCC,IAAAA,MAAM,EAAE,CAD+B;AAEvCC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,IAAI,EAAE,SADE;AAERC,MAAAA,SAAS,EAAE;AAFH,KAF6B;AAMvCC,IAAAA,MAAM,EA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C,CAAD,CAAN,CAAUC,eAAV,CAA0BC,IAA1B,CAA+BnC,0CAA0C,EAAzE;AACD;;AACD,eAAOiC,MAAP;AACD,OAhBkB;AAiBnB7B,MAAAA,OAAO,EAAE,CACP;AACE8B,QAAAA,eAAe,EAAE,CAAClD,yBAAyB,EAA1B,EAA8BW,qCAAqC,EAAnE;AADnB,OADO;AAjBU,KAhDM;AAuE3ByC,IAAAA,oBAAoB,EAAE;AACpBjC,MAAAA,IAAI,EAAE,sBADc;AAEpBC,MAAAA,OAAO,EAAE;AAFW,KAvEK;AA2E3BiC,IAAAA,MAAM,EAAE;AACNlC,MAAAA,IAAI,EAAE,QADA;AAENC,MAAAA,OAAO,EAAE;AAFH,KA3EmB;AA+E3BkC,IAAAA,SAAS,EAAE;AACTnC,MAAAA,IAAI,EAAE,WADG;AAETC,MAAAA,OAAO,EAAE;AAFA;AA/EgB,GAAP;AAAA,CAAf","sourcesContent":["import transform from 'json-map-transform';\nimport {STORE} from './store';\n\nconst PLAIN_GEOMETRY_DEFINITION = () => ({\n offset: 8,\n position: {\n type: 'Float32',\n component: 3\n },\n normal: {\n type: 'Float32',\n component: 3\n },\n uv0: {\n type: 'Float32',\n component: 2\n },\n color: {\n type: 'UInt8',\n component: 4\n },\n featureId: {\n binding: 'per-feature',\n type: 'UInt64',\n component: 1\n },\n faceRange: {\n binding: 'per-feature',\n type: 'UInt32',\n component: 2\n }\n});\n\nconst PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({\n offset: 8,\n position: {\n type: 'Float32',\n component: 3\n },\n normal: {\n type: 'Float32',\n component: 3\n },\n color: {\n type: 'UInt8',\n component: 4\n },\n featureId: {\n binding: 'per-feature',\n type: 'UInt64',\n component: 1\n },\n faceRange: {\n binding: 'per-feature',\n type: 'UInt32',\n component: 2\n }\n});\n\nconst COMPRESSED_GEOMETRY_DEFINITION = () => ({\n compressedAttributes: {\n encoding: 'draco',\n attributes: ['position', 'normal', 'uv0', 'color', 'feature-index']\n }\n});\n\nconst COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({\n compressedAttributes: {\n encoding: 'draco',\n attributes: ['position', 'normal', 'color', 'feature-index']\n }\n});\n\nconst SPATIAL_REFERENCE = () => ({\n wkid: {\n path: 'wkid',\n default: 4326\n },\n latestWkid: {\n path: 'latestWkid',\n default: 4326\n },\n vcsWkid: {\n path: 'vcsWkid',\n default: 5773\n },\n latestVcsWkid: {\n path: 'latestVcsWkid',\n default: 5773\n }\n});\n\nconst HEIGHT_MODEL_INFO = () => ({\n heightModel: {\n path: 'heightModel',\n default: 'gravity_related_height'\n },\n vertCRS: {\n path: 'vertCRS',\n default: 'EGM96_Geoid'\n },\n heightUnit: {\n path: 'heightUnit',\n default: 'meter'\n }\n});\n\nconst NODE_PAGES = () => ({\n nodesPerPage: {\n path: 'nodesPerPage'\n },\n lodSelectionMetricType: {\n path: 'lodSelectionMetricType',\n default: 'maxScreenThresholdSQ'\n }\n});\n\nexport const LAYERS = () => ({\n version: {\n path: 'version',\n transform: (val) => val.toUpperCase()\n },\n id: {\n path: 'id',\n default: 0\n },\n name: {\n path: 'name'\n },\n href: {\n path: 'href',\n default: './layers/0'\n },\n layerType: {\n path: 'layerType',\n default: 'IntegratedMesh'\n },\n spatialReference: {\n path: 'spatialReference',\n transform: (val) => transform(val, SPATIAL_REFERENCE())\n },\n capabilities: {\n path: 'capabilities',\n default: ['View', 'Query']\n },\n store: {\n path: 'store',\n transform: (val) => transform(val, STORE)\n },\n heightModelInfo: {\n path: 'heightModelInfo',\n transform: (val) => transform(val, HEIGHT_MODEL_INFO())\n },\n nodePages: {\n path: 'nodePages',\n transform: (val) => transform(val, NODE_PAGES())\n },\n materialDefinitions: {\n path: 'materialDefinitions',\n default: []\n },\n textureSetDefinitions: {\n path: 'textureSetDefinitions',\n default: []\n },\n geometryDefinitions: {\n path: 'compressGeometry',\n transform: (val) => {\n const result = [{geometryBuffers: []}, {geometryBuffers: []}];\n\n // @ts-expect-error\n result[0].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION());\n // @ts-expect-error\n result[1].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0());\n if (val) {\n // @ts-expect-error\n result[0].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION());\n // @ts-expect-error\n result[1].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0());\n }\n return result;\n },\n default: [\n {\n geometryBuffers: [PLAIN_GEOMETRY_DEFINITION(), PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0()]\n }\n ]\n },\n attributeStorageInfo: {\n path: 'attributeStorageInfo',\n default: []\n },\n fields: {\n path: 'fields',\n default: []\n },\n popupInfo: {\n path: 'popupInfo',\n default: null\n }\n});\n"],"file":"layers.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/i3s-converter/json-templates/layers.ts"],"names":["PLAIN_GEOMETRY_DEFINITION","offset","position","type","component","normal","uv0","color","featureId","binding","faceRange","PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0","COMPRESSED_GEOMETRY_DEFINITION","compressedAttributes","encoding","attributes","COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0","SPATIAL_REFERENCE","wkid","path","default","latestWkid","vcsWkid","latestVcsWkid","HEIGHT_MODEL_INFO","heightModel","vertCRS","heightUnit","NODE_PAGES","nodesPerPage","lodSelectionMetricType","FULL_EXTENT","xmin","ymin","xmax","ymax","zmin","zmax","LAYERS","version","transform","val","toUpperCase","id","name","href","layerType","spatialReference","capabilities","store","STORE","fullExtent","heightModelInfo","nodePages","materialDefinitions","textureSetDefinitions","geometryDefinitions","result","geometryBuffers","push","attributeStorageInfo","fields","popupInfo"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B;AAAA,SAAO;AACvCC,IAAAA,MAAM,EAAE,CAD+B;AAEvCC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,IAAI,EA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WADG;AAETC,MAAAA,OAAO,EAAE;AAFA;AAnFgB,GAAP;AAAA,CAAf","sourcesContent":["import transform from 'json-map-transform';\nimport {STORE} from './store';\n\nconst PLAIN_GEOMETRY_DEFINITION = () => ({\n offset: 8,\n position: {\n type: 'Float32',\n component: 3\n },\n normal: {\n type: 'Float32',\n component: 3\n },\n uv0: {\n type: 'Float32',\n component: 2\n },\n color: {\n type: 'UInt8',\n component: 4\n },\n featureId: {\n binding: 'per-feature',\n type: 'UInt64',\n component: 1\n },\n faceRange: {\n binding: 'per-feature',\n type: 'UInt32',\n component: 2\n }\n});\n\nconst PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({\n offset: 8,\n position: {\n type: 'Float32',\n component: 3\n },\n normal: {\n type: 'Float32',\n component: 3\n },\n color: {\n type: 'UInt8',\n component: 4\n },\n featureId: {\n binding: 'per-feature',\n type: 'UInt64',\n component: 1\n },\n faceRange: {\n binding: 'per-feature',\n type: 'UInt32',\n component: 2\n }\n});\n\nconst COMPRESSED_GEOMETRY_DEFINITION = () => ({\n compressedAttributes: {\n encoding: 'draco',\n attributes: ['position', 'normal', 'uv0', 'color', 'feature-index']\n }\n});\n\nconst COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({\n compressedAttributes: {\n encoding: 'draco',\n attributes: ['position', 'normal', 'color', 'feature-index']\n }\n});\n\nconst SPATIAL_REFERENCE = () => ({\n wkid: {\n path: 'wkid',\n default: 4326\n },\n latestWkid: {\n path: 'latestWkid',\n default: 4326\n },\n vcsWkid: {\n path: 'vcsWkid',\n default: 5773\n },\n latestVcsWkid: {\n path: 'latestVcsWkid',\n default: 5773\n }\n});\n\nconst HEIGHT_MODEL_INFO = () => ({\n heightModel: {\n path: 'heightModel',\n default: 'gravity_related_height'\n },\n vertCRS: {\n path: 'vertCRS',\n default: 'EGM96_Geoid'\n },\n heightUnit: {\n path: 'heightUnit',\n default: 'meter'\n }\n});\n\nconst NODE_PAGES = () => ({\n nodesPerPage: {\n path: 'nodesPerPage'\n },\n lodSelectionMetricType: {\n path: 'lodSelectionMetricType',\n default: 'maxScreenThresholdSQ'\n }\n});\n\nconst FULL_EXTENT = () => ({\n xmin: {\n path: 'xmin'\n },\n ymin: {\n path: 'ymin'\n },\n xmax: {\n path: 'xmax'\n },\n ymax: {\n path: 'ymax'\n },\n zmin: {\n path: 'zmin'\n },\n zmax: {\n path: 'zmax'\n }\n});\n\nexport const LAYERS = () => ({\n version: {\n path: 'version',\n transform: (val) => val.toUpperCase()\n },\n id: {\n path: 'id',\n default: 0\n },\n name: {\n path: 'name'\n },\n href: {\n path: 'href',\n default: './layers/0'\n },\n layerType: {\n path: 'layerType',\n default: 'IntegratedMesh'\n },\n spatialReference: {\n path: 'spatialReference',\n transform: (val) => transform(val, SPATIAL_REFERENCE())\n },\n capabilities: {\n path: 'capabilities',\n default: ['View', 'Query']\n },\n store: {\n path: 'store',\n transform: (val) => transform(val, STORE)\n },\n fullExtent: {\n path: 'fullExtent',\n transform: (val) => transform(val, FULL_EXTENT())\n },\n heightModelInfo: {\n path: 'heightModelInfo',\n transform: (val) => transform(val, HEIGHT_MODEL_INFO())\n },\n nodePages: {\n path: 'nodePages',\n transform: (val) => transform(val, NODE_PAGES())\n },\n materialDefinitions: {\n path: 'materialDefinitions',\n default: []\n },\n textureSetDefinitions: {\n path: 'textureSetDefinitions',\n default: []\n },\n geometryDefinitions: {\n path: 'compressGeometry',\n transform: (val) => {\n const result = [{geometryBuffers: []}, {geometryBuffers: []}];\n\n // @ts-expect-error\n result[0].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION());\n // @ts-expect-error\n result[1].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0());\n if (val) {\n // @ts-expect-error\n result[0].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION());\n // @ts-expect-error\n result[1].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0());\n }\n return result;\n },\n default: [\n {\n geometryBuffers: [PLAIN_GEOMETRY_DEFINITION(), PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0()]\n }\n ]\n },\n attributeStorageInfo: {\n path: 'attributeStorageInfo',\n default: []\n },\n fields: {\n path: 'fields',\n default: []\n },\n popupInfo: {\n path: 'popupInfo',\n default: null\n }\n});\n"],"file":"layers.js"}
|
package/dist/es5/pgm-loader.js
CHANGED
|
@@ -13,7 +13,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
13
13
|
|
|
14
14
|
var _geoid = require("@math.gl/geoid");
|
|
15
15
|
|
|
16
|
-
var VERSION = typeof "3.2.
|
|
16
|
+
var VERSION = typeof "3.2.1" !== 'undefined' ? "3.2.1" : 'latest';
|
|
17
17
|
var PGMLoader = {
|
|
18
18
|
name: 'PGM - Netpbm grayscale image format',
|
|
19
19
|
id: 'pgm',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pgm-loader.ts"],"names":["VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"mappings":";;;;;;;;;;;;;AAMA;;AAFA,IAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../src/pgm-loader.ts"],"names":["VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"mappings":";;;;;;;;;;;;;AAMA;;AAFA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAOO,IAAMC,SAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,qCADmC;AAEzCC,EAAAA,EAAE,EAAE,KAFqC;AAGzCC,EAAAA,MAAM,EAAE,gBAHiC;AAIzCC,EAAAA,OAAO,EAAEL,OAJgC;AAKzCM,EAAAA,SAAS,EAAE,CAAC,0BAAD,CAL8B;AAMzCC,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP,EAAoBC,OAApB;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAgC,qBAAS,IAAIC,UAAJ,CAAeF,WAAf,CAAT,EAAsCC,OAAtC,CAAhC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KANoC;AAOzCE,EAAAA,UAAU,EAAE,CAAC,KAAD,CAP6B;AAQzCF,EAAAA,OAAO,EAAE;AAEPG,IAAAA,KAAK,EAAE;AAFA;AARgC,CAApC","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nimport {parsePGM} from '@math.gl/geoid';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"file":"pgm-loader.js"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
2
|
-
const VERSION = typeof "3.2.
|
|
2
|
+
const VERSION = typeof "3.2.1" !== 'undefined' ? "3.2.1" : 'latest';
|
|
3
3
|
export const Tile3dAttributesWorker = {
|
|
4
4
|
id: '3d-tiles-attributes',
|
|
5
5
|
name: '3DTiles Attributes Worker',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/3d-tiles-attributes-worker.ts"],"names":["processOnWorker","VERSION","Tile3dAttributesWorker","id","name","module","version","options","attributes","transform3DTilesAttributesOnWorker","i3sAttributesData","_typecheckI3SAttributesWorker"],"mappings":"AAGA,SAAQA,eAAR,QAA8B,0BAA9B;AAIA,MAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../src/3d-tiles-attributes-worker.ts"],"names":["processOnWorker","VERSION","Tile3dAttributesWorker","id","name","module","version","options","attributes","transform3DTilesAttributesOnWorker","i3sAttributesData","_typecheckI3SAttributesWorker"],"mappings":"AAGA,SAAQA,eAAR,QAA8B,0BAA9B;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAeA,OAAO,MAAMC,sBAAsB,GAAG;AACpCC,EAAAA,EAAE,EAAE,qBADgC;AAEpCC,EAAAA,IAAI,EAAE,2BAF8B;AAGpCC,EAAAA,MAAM,EAAE,gBAH4B;AAIpCC,EAAAA,OAAO,EAAEL,OAJ2B;AAKpCM,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE;AADL;AAL2B,CAA/B;AAaP,OAAO,SAASC,kCAAT,CACLC,iBADK,EAELH,OAFK,EAGiB;AACtB,SAAOP,eAAe,CAACE,sBAAD,EAAyBQ,iBAAzB,EAA4CH,OAA5C,CAAtB;AACD;AAED,OAAO,MAAMI,6BAA2C,GAAGT,sBAApD","sourcesContent":["import type {WorkerObject} from '@loaders.gl/worker-utils';\nimport type {FeatureAttribute} from '@loaders.gl/i3s';\n\nimport {processOnWorker} from '@loaders.gl/worker-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type Tile3DAttributesWorkerOptions = {\n featureAttributes: FeatureAttribute | null;\n source: string;\n};\n\nexport type I3SAttributesData = {\n tileContent: any;\n textureFormat: string;\n};\n\n/**\n * I3S Attributes Worker to handle B3DM object\n */\nexport const Tile3dAttributesWorker = {\n id: '3d-tiles-attributes',\n name: '3DTiles Attributes Worker',\n module: 'tile-converter',\n version: VERSION,\n options: {\n attributes: null\n }\n};\n\n/**\n * Performs I3S attributes transformation\n */\nexport function transform3DTilesAttributesOnWorker(\n i3sAttributesData: I3SAttributesData,\n options: Tile3DAttributesWorkerOptions\n): Promise<ArrayBuffer> {\n return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);\n}\n\nexport const _typecheckI3SAttributesWorker: WorkerObject = Tile3dAttributesWorker;\n"],"file":"3d-tiles-attributes-worker.js"}
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import process from 'process';
|
|
4
4
|
import transform from 'json-map-transform';
|
|
5
|
-
import { fetchFile, getLoaderOptions, load } from '@loaders.gl/core';
|
|
5
|
+
import { fetchFile, getLoaderOptions, load, isBrowser } from '@loaders.gl/core';
|
|
6
6
|
import { I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM } from '@loaders.gl/i3s';
|
|
7
7
|
import { Tileset3D, Tile3D } from '@loaders.gl/tiles';
|
|
8
8
|
import { PGMLoader } from '../pgm-loader';
|
|
@@ -15,6 +15,7 @@ import B3dmConverter from './helpers/b3dm-converter';
|
|
|
15
15
|
import { createObbFromMbs } from '../i3s-converter/helpers/coordinate-converter';
|
|
16
16
|
import { Tile3dAttributesWorker } from '../3d-tiles-attributes-worker';
|
|
17
17
|
import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
|
|
18
|
+
import { BROWSER_ERROR_MESSAGE } from '../constants';
|
|
18
19
|
const I3S = 'I3S';
|
|
19
20
|
export default class Tiles3DConverter {
|
|
20
21
|
constructor() {
|
|
@@ -45,6 +46,11 @@ export default class Tiles3DConverter {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
async convert(options) {
|
|
49
|
+
if (isBrowser) {
|
|
50
|
+
console.log(BROWSER_ERROR_MESSAGE);
|
|
51
|
+
return BROWSER_ERROR_MESSAGE;
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
const {
|
|
49
55
|
inputUrl,
|
|
50
56
|
outputPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":["join","process","transform","fetchFile","getLoaderOptions","load","I3SLoader","I3SAttributeLoader","COORDINATE_SYSTEM","Tileset3D","Tile3D","PGMLoader","i3sObbTo3dTilesObb","convertScreenThresholdToGeometricError","writeFile","removeDir","calculateFilesSize","timeConverter","TILESET","tilesetTemplate","B3dmConverter","createObbFromMbs","Tile3dAttributesWorker","getWorkerURL","WorkerFarm","I3S","Tiles3DConverter","constructor","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","convert","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","hrtime","console","log","loadWorkers","sourceTilesetJson","loadOptions","i3s","coordinateSystem","LNGLAT_OFFSETS","decodeTextures","tilesetInitializationPromise","rootNode","root","header","obb","mbs","e","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","workerFarm","getWorkerFarm","destroy","parentSourceNode","parentNode","level","childNodeInfo","sourceChild","_loadChildNode","push","contentUrl","_loadTile","content","vertexCount","featureAttributes","_loadChildAttributes","child","i3sAttributesData","tileContent","textureFormat","b3dm","uri","id","Uint8Array","unloadContent","nodePages","nodePagesTile","formTileFromNodePages","loader","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","baseUrl","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","promises","attributeUrls","index","length","attribute","attributeName","name","attributeType","_getAttributeType","attributesList","Promise","all","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime","tile3dAttributesWorkerUrl","sourceResponse","source","text","tile3dWorkerSource"],"mappings":";AAGA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,OAAP,MAAoB,SAApB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,SAAR,EAAmBC,gBAAnB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AR;AACA,UAAM8F,yBAAyB,GAAGnH,YAAY,CAACD,sBAAD,EAAyB,EAAC,GAAGlB,gBAAgB;AAApB,KAAzB,CAA9C;AACA,UAAMuI,cAAc,GAAG,MAAMxI,SAAS,CAACuI,yBAAD,CAAtC;AACA,UAAME,MAAM,GAAG,MAAMD,cAAc,CAACE,IAAf,EAArB;AAEA,SAAK1G,YAAL,CAAkB2G,kBAAlB,GAAuCF,MAAvC;AACAjG,IAAAA,OAAO,CAACC,GAAR;AACD;;AA5SmC","sourcesContent":["import type {AttributeStorageInfo, FeatureAttribute, NodeReference} from '@loaders.gl/i3s';\nimport type {Node3D} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {fetchFile, getLoaderOptions, load} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Tileset3D, Tile3D} from '@loaders.gl/tiles';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport B3dmConverter from './helpers/b3dm-converter';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {\n I3SAttributesData,\n Tile3dAttributesWorker\n /*transform3DTilesAttributesOnWorker*/\n} from '../3d-tiles-attributes-worker';\nimport {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: Tileset3D | null;\n attributeStorageInfo: AttributeStorageInfo | null;\n workerSource: {[key: string]: string} = {};\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n }\n\n /**\n * Convert i3s format data to 3dTiles\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth?: number;\n egmFilePath: string;\n }): Promise<any> {\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n await this.loadWorkers();\n\n const sourceTilesetJson = await load(inputUrl, I3SLoader, {});\n\n this.sourceTileset = new Tileset3D(sourceTilesetJson, {\n loadOptions: {\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}\n }\n });\n\n await this.sourceTileset.tilesetInitializationPromise;\n const rootNode = this.sourceTileset.root!;\n if (!rootNode.header.obb) {\n rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Node3D = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.header.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: []\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: Tile3D,\n parentNode: Node3D,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.header.children || []) {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n parentSourceNode.children.push(sourceChild);\n if (sourceChild.contentUrl) {\n await this.sourceTileset!._loadTile(sourceChild);\n this.vertexCounter += sourceChild.content.vertexCount;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(\n sourceChild,\n this.attributeStorageInfo\n );\n }\n\n if (!sourceChild.header.obb) {\n sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)\n };\n const child: Node3D = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: sourceChild.content,\n textureFormat: sourceChild?.header?.textureFormat\n };\n\n // TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.\n // const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {\n // source: this.workerSource.tile3dWorkerSource,\n // featureAttributes\n // });\n\n const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);\n\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n sourceChild.unloadContent();\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(parentNode: Tile3D, childNodeInfo: NodeReference): Promise<Tile3D> {\n let header;\n if (this.sourceTileset!.tileset.nodePages) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset!.tileset.nodePagesTile.formTileFromNodePages(\n childNodeInfo.id\n );\n } else {\n const {loader} = this.sourceTileset!;\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options = {\n i3s: {\n ...this.sourceTileset!.loadOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, loader, options);\n }\n return new Tile3D(this.sourceTileset!, header, parentNode);\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string, relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: Tile3D,\n attributeStorageInfo: AttributeStorageInfo\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls} = sourceChild.header;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n\n private async loadWorkers(): Promise<void> {\n console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console\n const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);\n const source = await sourceResponse.text();\n\n this.workerSource.tile3dWorkerSource = source;\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"file":"3d-tiles-converter.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":["join","process","transform","fetchFile","getLoaderOptions","load","isBrowser","I3SLoader","I3SAttributeLoader","COORDINATE_SYSTEM","Tileset3D","Tile3D","PGMLoader","i3sObbTo3dTilesObb","convertScreenThresholdToGeometricError","writeFile","removeDir","calculateFilesSize","timeConverter","TILESET","tilesetTemplate","B3dmConverter","createObbFromMbs","Tile3dAttributesWorker","getWorkerURL","WorkerFarm","BROWSER_ERROR_MESSAGE","I3S","Tiles3DConverter","constructor","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","convert","console","log","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","hrtime","loadWorkers","sourceTilesetJson","loadOptions","i3s","coordinateSystem","LNGLAT_OFFSETS","decodeTextures","tilesetInitializationPromise","rootNode","root","header","obb","mbs","e","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","workerFarm","getWorkerFarm","destroy","parentSourceNode","parentNode","level","childNodeInfo","sourceChild","_loadChildNode","push","contentUrl","_loadTile","content","vertexCount","featureAttributes","_loadChildAttributes","child","i3sAttributesData","tileContent","textureFormat","b3dm","uri","id","Uint8Array","unloadContent","nodePages","nodePagesTile","formTileFromNodePages","loader","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","baseUrl","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","promises","attributeUrls","index","length","attribute","attributeName","name","attributeType","_getAttributeType","attributesList","Promise","all","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime","tile3dAttributesWorkerUrl","sourceResponse","source","text","tile3dWorkerSource"],"mappings":";AAGA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,OAAP,MAAoB,SAApB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,SAAR,EAAmBC,gBAAnB,EAAqCC,IAArC,EAA2CC,SAA3C,QAA2D,kBAA3D;AACA,SAAQC,SAAR,EAAmBC,kBAAnB,EAAuCC,iBAAvC,QAA+D,iBAA/D;AACA,SAAQC,SAAR,EAAmBC,MAAnB,QAAgC,mBAAhC;AAGA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,kBAAR,QAAiC,mCAAjC;AACA,SAAQC,sCAAR,QAAqD,mCAArD;AACA,SAAQC,SAAR,EAAmBC,SAAnB,QAAmC,yBAAnC;AACA,SAAQC,kBAAR,EAA4BC,aAA5B,QAAgD,+BAAhD;AACA,SAAQC,OAAO,IAAIC,eAAnB,QAAyC,0BAAzC;AACA,OAAOC,aAAP,MAA0B,0BAA1B;AACA,SAAQC,gBAAR,QAA+B,+CAA/B;AACA,SAEEC,sBAFF,QAIO,+BAJP;AAKA,SAAQC,YAAR,EAAsBC,UAAtB,QAAuC,0BAAvC;AACA,SAAQC,qBAAR,QAAoC,cAApC;AAEA,MAAMC,GAAG,GAAG,KAAZ;AAKA,eAAe,MAAMC,gBAAN,CAAuB;AAUpCC,EAAAA,WAAW,GAAG;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,0CAF0B,EAE1B;;AACZ,SAAKC,OAAL,GAAe,EAAf;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,aAAL,GAAqB,CAArB;AACA,SAAKC,mBAAL,GAA2B,CAAC,CAAD,EAAI,CAAJ,CAA3B;AACA,SAAKC,gBAAL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AAC6C,MAAR,CAAe,KAAKb,mBAApB,CAAb;AACA,UAAM0G,cAAc,GAAGzH,aAAa,CAACwH,IAAD,CAApC;AAEAnG,IAAAA,OAAO,CAACC,GAAR;AACAD,IAAAA,OAAO,CAACC,GAAR,gCAAoCb,GAApC;AACAY,IAAAA,OAAO,CAACC,GAAR,kCAAsCmG,cAAtC;AACApG,IAAAA,OAAO,CAACC,GAAR,mBAA8B,KAAKR,aAAnC;AACAO,IAAAA,OAAO,CAACC,GAAR,mBAA8BiG,SAA9B,EAAyC,QAAzC;AACAlG,IAAAA,OAAO,CAACC,GAAR;AACD;;AAEwB,QAAXO,WAAW,GAAkB;AACzCR,IAAAA,OAAO,CAACC,GAAR;AACA,UAAMoG,yBAAyB,GAAGpH,YAAY,CAACD,sBAAD,EAAyB,EAAC,GAAGnB,gBAAgB;AAApB,KAAzB,CAA9C;AACA,UAAMyI,cAAc,GAAG,MAAM1I,SAAS,CAACyI,yBAAD,CAAtC;AACA,UAAME,MAAM,GAAG,MAAMD,cAAc,CAACE,IAAf,EAArB;AAEA,SAAK1G,YAAL,CAAkB2G,kBAAlB,GAAuCF,MAAvC;AACAvG,IAAAA,OAAO,CAACC,GAAR;AACD;;AAhTmC","sourcesContent":["import type {AttributeStorageInfo, FeatureAttribute, NodeReference} from '@loaders.gl/i3s';\nimport type {Node3D} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {fetchFile, getLoaderOptions, load, isBrowser} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Tileset3D, Tile3D} from '@loaders.gl/tiles';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport B3dmConverter from './helpers/b3dm-converter';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {\n I3SAttributesData,\n Tile3dAttributesWorker\n /*transform3DTilesAttributesOnWorker*/\n} from '../3d-tiles-attributes-worker';\nimport {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: Tileset3D | null;\n attributeStorageInfo: AttributeStorageInfo | null;\n workerSource: {[key: string]: string} = {};\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n }\n\n /**\n * Convert i3s format data to 3dTiles\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth?: number;\n egmFilePath: string;\n }): Promise<any> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n await this.loadWorkers();\n\n const sourceTilesetJson = await load(inputUrl, I3SLoader, {});\n\n this.sourceTileset = new Tileset3D(sourceTilesetJson, {\n loadOptions: {\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}\n }\n });\n\n await this.sourceTileset.tilesetInitializationPromise;\n const rootNode = this.sourceTileset.root!;\n if (!rootNode.header.obb) {\n rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Node3D = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.header.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: []\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: Tile3D,\n parentNode: Node3D,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.header.children || []) {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n parentSourceNode.children.push(sourceChild);\n if (sourceChild.contentUrl) {\n await this.sourceTileset!._loadTile(sourceChild);\n this.vertexCounter += sourceChild.content.vertexCount;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(\n sourceChild,\n this.attributeStorageInfo\n );\n }\n\n if (!sourceChild.header.obb) {\n sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)\n };\n const child: Node3D = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: sourceChild.content,\n textureFormat: sourceChild?.header?.textureFormat\n };\n\n // TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.\n // const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {\n // source: this.workerSource.tile3dWorkerSource,\n // featureAttributes\n // });\n\n const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);\n\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n sourceChild.unloadContent();\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(parentNode: Tile3D, childNodeInfo: NodeReference): Promise<Tile3D> {\n let header;\n if (this.sourceTileset!.tileset.nodePages) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset!.tileset.nodePagesTile.formTileFromNodePages(\n childNodeInfo.id\n );\n } else {\n const {loader} = this.sourceTileset!;\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options = {\n i3s: {\n ...this.sourceTileset!.loadOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, loader, options);\n }\n return new Tile3D(this.sourceTileset!, header, parentNode);\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string, relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: Tile3D,\n attributeStorageInfo: AttributeStorageInfo\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls} = sourceChild.header;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n\n private async loadWorkers(): Promise<void> {\n console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console\n const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);\n const source = await sourceResponse.text();\n\n this.workerSource.tile3dWorkerSource = source;\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"file":"3d-tiles-converter.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants.ts"],"names":["BROWSER_ERROR_MESSAGE"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAChC,sEADK","sourcesContent":["export const BROWSER_ERROR_MESSAGE =\n 'Tile converter does not work in browser, only in node js environment';\n"],"file":"constants.js"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
2
|
-
const VERSION = typeof "3.2.
|
|
2
|
+
const VERSION = typeof "3.2.1" !== 'undefined' ? "3.2.1" : 'latest';
|
|
3
3
|
export const I3SAttributesWorker = {
|
|
4
4
|
id: 'i3s-attributes',
|
|
5
5
|
name: 'I3S Attributes Worker',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i3s-attributes-worker.ts"],"names":["processOnWorker","VERSION","I3SAttributesWorker","id","name","module","version","options","useCartesianPositions","transformI3SAttributesOnWorker","attributesData","_typecheckI3SAttributesWorker"],"mappings":"AAIA,SAAQA,eAAR,QAA8B,0BAA9B;AAIA,MAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../src/i3s-attributes-worker.ts"],"names":["processOnWorker","VERSION","I3SAttributesWorker","id","name","module","version","options","useCartesianPositions","transformI3SAttributesOnWorker","attributesData","_typecheckI3SAttributesWorker"],"mappings":"AAIA,SAAQA,eAAR,QAA8B,0BAA9B;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAiBA,OAAO,MAAMC,mBAAmB,GAAG;AACjCC,EAAAA,EAAE,EAAE,gBAD6B;AAEjCC,EAAAA,IAAI,EAAE,uBAF2B;AAGjCC,EAAAA,MAAM,EAAE,gBAHyB;AAIjCC,EAAAA,OAAO,EAAEL,OAJwB;AAKjCM,EAAAA,OAAO,EAAE;AACPC,IAAAA,qBAAqB,EAAE;AADhB;AALwB,CAA5B;AAaP,OAAO,SAASC,8BAAT,CACLC,cADK,EAELH,OAFK,EAGsC;AAC3C,SAAOP,eAAe,CAACE,mBAAD,EAAsBQ,cAAtB,EAAsCH,OAAtC,CAAtB;AACD;AAED,OAAO,MAAMI,6BAA2C,GAAGT,mBAApD","sourcesContent":["import type {WorkerObject} from '@loaders.gl/worker-utils';\nimport type {ConvertedAttributes} from './i3s-converter/types';\nimport type {Matrix4, Vector3} from '@math.gl/core';\n\nimport {processOnWorker} from '@loaders.gl/worker-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type I3SAttributesWorkerOptions = {\n useCartesianPositions: boolean;\n source: string;\n};\n\nexport type B3DMAttributesData = {\n gltfMaterials?: {id: string}[];\n nodes: any;\n cartographicOrigin: Vector3;\n cartesianModelMatrix: Matrix4;\n};\n\n/**\n * I3S Attributes Worker to handle B3DM object\n */\nexport const I3SAttributesWorker = {\n id: 'i3s-attributes',\n name: 'I3S Attributes Worker',\n module: 'tile-converter',\n version: VERSION,\n options: {\n useCartesianPositions: false\n }\n};\n\n/**\n * Performs I3S attributes transformation\n */\nexport function transformI3SAttributesOnWorker(\n attributesData: B3DMAttributesData,\n options: I3SAttributesWorkerOptions\n): Promise<Map<string, ConvertedAttributes>> {\n return processOnWorker(I3SAttributesWorker, attributesData, options);\n}\n\nexport const _typecheckI3SAttributesWorker: WorkerObject = I3SAttributesWorker;\n"],"file":"i3s-attributes-worker.js"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
var _process$env;
|
|
4
|
+
|
|
5
|
+
import { load, encode, fetchFile, getLoaderOptions, isBrowser } from '@loaders.gl/core';
|
|
3
6
|
import { Tileset3D } from '@loaders.gl/tiles';
|
|
4
7
|
import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
|
|
5
8
|
import { join } from 'path';
|
|
@@ -26,7 +29,8 @@ import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
|
|
|
26
29
|
import { DracoWriterWorker } from '@loaders.gl/draco';
|
|
27
30
|
import WriteQueue from '../lib/utils/write-queue';
|
|
28
31
|
import { I3SAttributesWorker } from '../i3s-attributes-worker';
|
|
29
|
-
|
|
32
|
+
import { BROWSER_ERROR_MESSAGE } from '../constants';
|
|
33
|
+
const ION_DEFAULT_TOKEN = ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken) || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
30
34
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
31
35
|
const _3D_TILES = '3DTILES';
|
|
32
36
|
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
@@ -99,6 +103,11 @@ export default class I3SConverter {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
async convert(options) {
|
|
106
|
+
if (isBrowser) {
|
|
107
|
+
console.log(BROWSER_ERROR_MESSAGE);
|
|
108
|
+
return BROWSER_ERROR_MESSAGE;
|
|
109
|
+
}
|
|
110
|
+
|
|
102
111
|
this.conversionStartTime = process.hrtime();
|
|
103
112
|
const {
|
|
104
113
|
tilesetName,
|
|
@@ -230,7 +239,8 @@ export default class I3SConverter {
|
|
|
230
239
|
nodePages: {
|
|
231
240
|
nodesPerPage: HARDCODED_NODES_PER_PAGE
|
|
232
241
|
},
|
|
233
|
-
compressGeometry: this.options.draco
|
|
242
|
+
compressGeometry: this.options.draco,
|
|
243
|
+
fullExtent
|
|
234
244
|
};
|
|
235
245
|
this.layers0 = transform(layers0data, layersTemplate());
|
|
236
246
|
}
|