@loaders.gl/tile-converter 4.0.0-alpha.22 → 4.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/converter.min.js +106 -106
- package/dist/dist.min.js +1883 -1241
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/es5/constants.js +1 -5
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +26 -11
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +7 -17
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -44
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +70 -17
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +3 -2
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +36 -26
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +2 -2
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/pgm-loader.js +11 -3
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/esm/constants.js +0 -2
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +21 -6
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +9 -7
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +76 -34
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +66 -13
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +2 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +20 -17
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
- package/dist/esm/i3s-server/controllers/slpk-controller.js +1 -1
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/pgm-loader.js +7 -4
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/esm/slpk-extractor/slpk-extractor.js +2 -1
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +6 -6
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/types.d.ts +7 -4
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/pgm-loader.d.ts +9 -2
- package/dist/pgm-loader.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor.min.js +38 -38
- package/package.json +14 -14
- package/src/3d-tiles-converter/helpers/load-i3s.ts +1 -0
- package/src/constants.ts +0 -3
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +53 -14
- package/src/i3s-converter/helpers/feature-attributes.ts +20 -15
- package/src/i3s-converter/helpers/geometry-attributes.ts +80 -50
- package/src/i3s-converter/helpers/geometry-converter.ts +153 -21
- package/src/i3s-converter/helpers/node-index-document.ts +5 -1
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -1
- package/src/i3s-converter/i3s-converter.ts +42 -17
- package/src/i3s-converter/types.ts +8 -4
- package/src/i3s-server/controllers/slpk-controller.ts +1 -1
- package/src/pgm-loader.ts +15 -7
- package/src/slpk-extractor/slpk-extractor.ts +2 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -279
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -271
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -42
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -54
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
- package/dist/bundle.js +0 -5
- package/dist/constants.js +0 -6
- package/dist/converter-cli.js +0 -222
- package/dist/deps-installer/deps-installer.js +0 -89
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -158
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -122
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -203
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1240
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -129
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -99
- package/dist/i3s-converter/helpers/node-debug.js +0 -120
- package/dist/i3s-converter/helpers/node-index-document.js +0 -268
- package/dist/i3s-converter/helpers/node-pages.js +0 -316
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -100
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
- package/dist/i3s-converter/i3s-converter.js +0 -945
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
- package/dist/i3s-converter/json-templates/layers.js +0 -139
- package/dist/i3s-converter/json-templates/metadata.js +0 -25
- package/dist/i3s-converter/json-templates/node.js +0 -89
- package/dist/i3s-converter/json-templates/scene-server.js +0 -31
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
- package/dist/i3s-converter/json-templates/store.js +0 -103
- package/dist/i3s-converter/types.js +0 -17
- package/dist/i3s-server/app.js +0 -29
- package/dist/i3s-server/bin/www.js +0 -37
- package/dist/i3s-server/controllers/index-controller.js +0 -31
- package/dist/i3s-server/controllers/slpk-controller.js +0 -33
- package/dist/i3s-server/routes/index.js +0 -20
- package/dist/i3s-server/routes/slpk-router.js +0 -34
- package/dist/i3s-server/utils/create-scene-server.js +0 -22
- package/dist/i3s-server/utils/server-utils.js +0 -66
- package/dist/index.js +0 -10
- package/dist/lib/utils/cli-utils.js +0 -82
- package/dist/lib/utils/compress-util.js +0 -257
- package/dist/lib/utils/file-utils.js +0 -139
- package/dist/lib/utils/geometry-utils.js +0 -18
- package/dist/lib/utils/lod-conversion-utils.js +0 -76
- package/dist/lib/utils/queue.js +0 -18
- package/dist/lib/utils/statistic-utills.js +0 -64
- package/dist/lib/utils/write-queue.js +0 -80
- package/dist/pgm-loader.js +0 -24
- package/dist/slpk-extractor/slpk-extractor.js +0 -74
- package/dist/slpk-extractor-cli.js +0 -102
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-controller.js","names":["require","_i3s","
|
|
1
|
+
{"version":3,"file":"slpk-controller.js","names":["require","_i3s","_loaderUtils","slpkArchive","loadArchive","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","fullLayerPath","wrap","_callee$","_context","prev","next","t0","parseSLPK","FileHandleFile","from","t1","sent","t2","msg","console","log","stop","_x","apply","arguments","exports","getFileByUrl","_x2","_getFileByUrl","_callee2","url","trimmedPath","uncompressedFile","_callee2$","_context2","exec","Buffer","getFile","call","abrupt"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.ts"],"sourcesContent":["import '@loaders.gl/polyfills';\nimport {parseSLPK} from '@loaders.gl/i3s';\nimport {FileHandleFile} from '@loaders.gl/loader-utils';\n\nlet slpkArchive;\n\n/**\n * Open SLPK file for reading and load HASH file\n * @param fullLayerPath - full path to SLPK file\n */\nexport const loadArchive = async (fullLayerPath: string): Promise<void> => {\n slpkArchive = await parseSLPK(await FileHandleFile.from(fullLayerPath), (msg) =>\n console.log(msg)\n );\n console.log('The server is ready to use');\n};\n\n/**\n * Get a file from SLPK\n * @param url - I3S HTTP URL\n * @returns - file content\n */\nexport async function getFileByUrl(url: string) {\n const trimmedPath = /^\\/?(.*)\\/?$/.exec(url);\n let uncompressedFile: Buffer | null = null;\n if (trimmedPath) {\n try {\n uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));\n } catch (e) {}\n }\n return uncompressedFile;\n}\n"],"mappings":";;;;;;;;;;AAAAA,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAIG,WAAW;AAMR,IAAMC,WAAW;EAAA,IAAAC,IAAA,OAAAC,kBAAA,CAAAC,OAA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AA;MAAA,kBAAAA,SAAA,CAAAzB,IAAA,GAAAyB,SAAA,CAAAxB,IAAA;QAAA;UACtCqB,WAAW,GAAG,cAAc,CAACI,IAAI,CAACL,GAAG,CAAC;UACxCE,gBAA+B,GAAG,IAAI;UAAA,KACtCD,WAAW;YAAAG,SAAA,CAAAxB,IAAA;YAAA;UAAA;UAAAwB,SAAA,CAAAzB,IAAA;UAAAyB,SAAA,CAAAvB,EAAA,GAEQyB,MAAM;UAAAF,SAAA,CAAAxB,IAAA;UAAA,OAAYb,WAAW,CAACwC,OAAO,CAACN,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAA;UAAAG,SAAA,CAAAnB,EAAA,GAAAmB,SAAA,CAAAlB,IAAA;UAAhFgB,gBAAgB,GAAAE,SAAA,CAAAvB,EAAA,CAAUG,IAAI,CAAAwB,IAAA,CAAAJ,SAAA,CAAAvB,EAAA,EAAAuB,SAAA,CAAAnB,EAAA;UAAAmB,SAAA,CAAAxB,IAAA;UAAA;QAAA;UAAAwB,SAAA,CAAAzB,IAAA;UAAAyB,SAAA,CAAAjB,EAAA,GAAAiB,SAAA;QAAA;UAAA,OAAAA,SAAA,CAAAK,MAAA,WAG3BP,gBAAgB;QAAA;QAAA;UAAA,OAAAE,SAAA,CAAAb,IAAA;MAAA;IAAA,GAAAQ,QAAA;EAAA,CACxB;EAAA,OAAAD,aAAA,CAAAL,KAAA,OAAAC,SAAA;AAAA"}
|
package/dist/es5/pgm-loader.js
CHANGED
|
@@ -4,11 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "Geoid", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _geoid.Geoid;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
exports.PGMLoader = void 0;
|
|
8
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
16
|
var _geoid = require("@math.gl/geoid");
|
|
11
|
-
var VERSION = typeof "4.0.0-alpha.
|
|
17
|
+
var VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : 'latest';
|
|
12
18
|
var PGMLoader = {
|
|
13
19
|
name: 'PGM - Netpbm grayscale image format',
|
|
14
20
|
id: 'pgm',
|
|
@@ -20,7 +26,7 @@ var PGMLoader = {
|
|
|
20
26
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
21
27
|
while (1) switch (_context.prev = _context.next) {
|
|
22
28
|
case 0:
|
|
23
|
-
return _context.abrupt("return", (0, _geoid.parsePGM)(new Uint8Array(arrayBuffer), options));
|
|
29
|
+
return _context.abrupt("return", (0, _geoid.parsePGM)(new Uint8Array(arrayBuffer), (options === null || options === void 0 ? void 0 : options.pgm) || {}));
|
|
24
30
|
case 1:
|
|
25
31
|
case "end":
|
|
26
32
|
return _context.stop();
|
|
@@ -34,7 +40,9 @@ var PGMLoader = {
|
|
|
34
40
|
}(),
|
|
35
41
|
extensions: ['pgm'],
|
|
36
42
|
options: {
|
|
37
|
-
|
|
43
|
+
pgm: {
|
|
44
|
+
cubic: false
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
};
|
|
40
48
|
exports.PGMLoader = PGMLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pgm-loader.js","names":["_geoid","require","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parsePGM","Uint8Array","stop","_x","_x2","apply","arguments","extensions","cubic","exports"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {parsePGM} from '@math.gl/geoid';\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\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
|
|
1
|
+
{"version":3,"file":"pgm-loader.js","names":["_geoid","require","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parsePGM","Uint8Array","pgm","stop","_x","_x2","apply","arguments","extensions","cubic","exports"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Geoid, parsePGM} from '@math.gl/geoid';\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 {Geoid};\n\nexport type PGMLoaderOptions = LoaderOptions & {\n pgm?: {\n cubic?: boolean;\n };\n};\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser<Geoid, never, PGMLoaderOptions> = {\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?.pgm || {}),\n extensions: ['pgm'],\n options: {\n pgm: {\n cubic: false\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAMC,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAapE,IAAMC,SAA2D,GAAG;EACzEC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,KAAK;IAAA,IAAAC,MAAA,OAAAC,kBAAA,CAAAC,OAAA,EAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAE,SAAAC,QAAOC,WAAW,EAAEC,OAAO;MAAA,OAAAJ,YAAA,CAAAD,OAAA,CAAAM,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,OAAAF,QAAA,CAAAG,MAAA,WAAK,IAAAC,eAAQ,EAAC,IAAIC,UAAU,CAACT,WAAW,CAAC,EAAE,CAAAC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAES,GAAG,KAAI,CAAC,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAN,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAZ,OAAA;IAAA;IAAA,SAAAN,MAAAmB,EAAA,EAAAC,GAAA;MAAA,OAAAnB,MAAA,CAAAoB,KAAA,OAAAC,SAAA;IAAA;IAAA,OAAAtB,KAAA;EAAA;EAChGuB,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBf,OAAO,EAAE;IACPS,GAAG,EAAE;MACHO,KAAK,EAAE;IACT;EACF;AACF,CAAC;AAACC,OAAA,CAAA/B,SAAA,GAAAA,SAAA"}
|
|
@@ -37,7 +37,7 @@ var SLPKExtractor = function () {
|
|
|
37
37
|
case 3:
|
|
38
38
|
inputUrl = options.inputUrl;
|
|
39
39
|
_context.next = 6;
|
|
40
|
-
return
|
|
40
|
+
return _loaderUtils.FileHandleFile.from(inputUrl);
|
|
41
41
|
case 6:
|
|
42
42
|
provider = _context.sent;
|
|
43
43
|
_context.next = 9;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-extractor.js","names":["_core","require","_constants","_loaderUtils","_zip","_compression","_fileUtils","indexNames","SLPKExtractor","_classCallCheck2","default","_createClass2","key","value","_extract","_asyncToGenerator2","_regenerator","mark","_callee","options","inputUrl","provider","localHeader","_localHeader","wrap","_callee$","_context","prev","next","isBrowser","console","log","BROWSER_ERROR_MESSAGE","abrupt","FileHandleFile","from","sent","parseZipLocalFileHeader","t0","t1","t2","correctIndexNames","fileName","slice","fileDataOffset","compressedSize","t3","t4","name","data","unGzip","call","t5","t6","outputPath","writeFile","stop","extract","_x","apply","arguments","includes","path","filename","join","dirname","parts","exec","concat","at","_unGzip","_callee2","file","_file$name","_file$name2","compression","decompressedData","_callee2$","_context2","test","GZipCompression","decompress","Promise","resolve","_x2","_writeFile2","_callee3","finalPath","dirName","_callee3$","_context3","_x3","_x4","exports"],"sources":["../../../src/slpk-extractor/slpk-extractor.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/core';\n\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {path} from '@loaders.gl/loader-utils';\nimport {FileHandleFile
|
|
1
|
+
{"version":3,"file":"slpk-extractor.js","names":["_core","require","_constants","_loaderUtils","_zip","_compression","_fileUtils","indexNames","SLPKExtractor","_classCallCheck2","default","_createClass2","key","value","_extract","_asyncToGenerator2","_regenerator","mark","_callee","options","inputUrl","provider","localHeader","_localHeader","wrap","_callee$","_context","prev","next","isBrowser","console","log","BROWSER_ERROR_MESSAGE","abrupt","FileHandleFile","from","sent","parseZipLocalFileHeader","t0","t1","t2","correctIndexNames","fileName","slice","fileDataOffset","compressedSize","t3","t4","name","data","unGzip","call","t5","t6","outputPath","writeFile","stop","extract","_x","apply","arguments","includes","path","filename","join","dirname","parts","exec","concat","at","_unGzip","_callee2","file","_file$name","_file$name2","compression","decompressedData","_callee2$","_context2","test","GZipCompression","decompress","Promise","resolve","_x2","_writeFile2","_callee3","finalPath","dirName","_callee3$","_context3","_x3","_x4","exports"],"sources":["../../../src/slpk-extractor/slpk-extractor.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/core';\n\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {path} from '@loaders.gl/loader-utils';\nimport {FileHandleFile} from '@loaders.gl/loader-utils';\nimport {parseZipLocalFileHeader} from '@loaders.gl/zip';\nimport {GZipCompression} from '@loaders.gl/compression';\nimport {writeFile} from '../lib/utils/file-utils';\n\nconst indexNames = [\n '3dSceneLayer.json.gz',\n '3dNodeIndexDocument.json.gz',\n 'sharedResource.json.gz'\n];\n\n/**\n * Description of the file in the SLPK\n */\ntype File = {\n name: string | null;\n data: ArrayBuffer;\n};\n\n/**\n * Converter from slpk to i3s\n */\nexport default class SLPKExtractor {\n /**\n * Extract slpk to i3s\n * @param options\n * @param options.inputUrl the url to read SLPK file\n * @param options.outputPath the output filename\n */\n public async extract(options: {inputUrl: string; outputPath: string}): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl} = options;\n\n const provider = await FileHandleFile.from(inputUrl);\n\n let localHeader = await parseZipLocalFileHeader(0n, provider);\n while (localHeader) {\n await this.writeFile(\n await this.unGzip({\n name: this.correctIndexNames(localHeader.fileName),\n data: await provider.slice(\n localHeader.fileDataOffset,\n localHeader.fileDataOffset + localHeader.compressedSize\n )\n }),\n options.outputPath\n );\n localHeader = await parseZipLocalFileHeader(\n localHeader.fileDataOffset + localHeader?.compressedSize,\n provider\n );\n }\n\n return 'success';\n }\n\n /**\n * Defines file name and path for i3s format\n * @param fileName initial file name and path\n */\n\n private correctIndexNames(fileName: string): string | null {\n if (indexNames.includes(path.filename(path.join('/', fileName)))) {\n return path.join(path.dirname(fileName), 'index.json.gz');\n }\n // finds path with name part and extention part\n let parts = /^(.*\\/[^\\/\\.]*)(\\..+)$/.exec(fileName);\n if (!parts) {\n return null;\n }\n return `${parts?.at(1)}/index${parts?.at(2)}`;\n }\n\n private async unGzip(file: File): Promise<File> {\n if (/\\.gz$/.test(file.name ?? '')) {\n const compression = new GZipCompression();\n\n const decompressedData = await compression.decompress(file.data);\n\n return {data: decompressedData, name: (file.name ?? '').slice(0, -3)};\n }\n return Promise.resolve(file);\n }\n\n private async writeFile(options: File, outputPath: string): Promise<void> {\n if (!options.name) {\n return;\n }\n const finalPath = path.join(outputPath, options.name);\n const dirName = path.dirname(finalPath);\n const fileName = path.filename(finalPath);\n await writeFile(dirName, options.data, fileName);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAEA,IAAMM,UAAU,GAAG,CACjB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,CACzB;AAAC,IAamBC,aAAa;EAAA,SAAAA,cAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAF,aAAA;EAAA;EAAA,IAAAG,aAAA,CAAAD,OAAA,EAAAF,aAAA;IAAAI,GAAA;IAAAC,KAAA;MAAA,IAAAC,QAAA,OAAAC,kBAAA,CAAAL,OAAA,EAAAM,YAAA,CAAAN,OAAA,CAAAO,IAAA,CAOhC,SAAAC,QAAqBC,OAA+C;QAAA,IAAAC,QAAA,EAAAC,QAAA,EAAAC,WAAA,EAAAC,YAAA;QAAA,OAAAP,YAAA,CAAAN,OAAA,CAAAc,IAAA,UAAAC,SAAAC,QAAA;UAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;YAAA;cAAA,KAC9DC,eAAS;gBAAAH,QAAA,CAAAE,IAAA;gBAAA;cAAA;cACXE,OAAO,CAACC,GAAG,CAACC,gCAAqB,CAAC;cAAC,OAAAN,QAAA,CAAAO,MAAA,WAC5BD,gCAAqB;YAAA;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AA,CAAAN,OAAA,CAAAO,IAAA,CAED,SAAAqE,SAAwBnE,OAAa,EAAEmC,UAAkB;QAAA,IAAAiC,SAAA,EAAAC,OAAA,EAAA9C,QAAA;QAAA,OAAA1B,YAAA,CAAAN,OAAA,CAAAc,IAAA,UAAAiE,UAAAC,SAAA;UAAA,kBAAAA,SAAA,CAAA/D,IAAA,GAAA+D,SAAA,CAAA9D,IAAA;YAAA;cAAA,IAClDT,OAAO,CAAC6B,IAAI;gBAAA0C,SAAA,CAAA9D,IAAA;gBAAA;cAAA;cAAA,OAAA8D,SAAA,CAAAzD,MAAA;YAAA;cAGXsD,SAAS,GAAGzB,iBAAI,CAACE,IAAI,CAACV,UAAU,EAAEnC,OAAO,CAAC6B,IAAI,CAAC;cAC/CwC,OAAO,GAAG1B,iBAAI,CAACG,OAAO,CAACsB,SAAS,CAAC;cACjC7C,QAAQ,GAAGoB,iBAAI,CAACC,QAAQ,CAACwB,SAAS,CAAC;cAAAG,SAAA,CAAA9D,IAAA;cAAA,OACnC,IAAA2B,oBAAS,EAACiC,OAAO,EAAErE,OAAO,CAAC8B,IAAI,EAAEP,QAAQ,CAAC;YAAA;YAAA;cAAA,OAAAgD,SAAA,CAAAlC,IAAA;UAAA;QAAA,GAAA8B,QAAA;MAAA,CACjD;MAAA,SAAA/B,UAAAoC,GAAA,EAAAC,GAAA;QAAA,OAAAP,WAAA,CAAA1B,KAAA,OAAAC,SAAA;MAAA;MAAA,OAAAL,SAAA;IAAA;EAAA;EAAA,OAAA/C,aAAA;AAAA;AAAAqF,OAAA,CAAAnF,OAAA,GAAAF,aAAA"}
|
|
@@ -1 +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;
|
|
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 // @ts-expect-error\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;EAG7E,OAAOgB,WAAW;AACpB,CAAC"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["BROWSER_ERROR_MESSAGE"
|
|
1
|
+
{"version":3,"file":"constants.js","names":["BROWSER_ERROR_MESSAGE"],"sources":["../../src/constants.ts"],"sourcesContent":["export const BROWSER_ERROR_MESSAGE =\n 'Tile converter does not work in browser, only in node js environment';\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAChC,sEAAsE"}
|
|
@@ -5,7 +5,7 @@ import { join } from 'path';
|
|
|
5
5
|
import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
6
6
|
import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
|
|
7
7
|
import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
|
|
8
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
8
|
+
const VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : 'beta';
|
|
9
9
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
10
10
|
export class DepsInstaller {
|
|
11
11
|
async install() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { emod } from '@loaders.gl/math';
|
|
2
|
+
import { EXT_STRUCTURAL_METADATA, EXT_MESH_FEATURES, EXT_FEATURE_METADATA } from '@loaders.gl/gltf';
|
|
2
3
|
export function getTextureByMetadataClass(tileContent, metadataClass) {
|
|
3
4
|
var _tileContent$gltf, _tileContent$gltf$ext;
|
|
4
5
|
const extFeatureMetadata = (_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : (_tileContent$gltf$ext = _tileContent$gltf.extensions) === null || _tileContent$gltf$ext === void 0 ? void 0 : _tileContent$gltf$ext[EXT_FEATURE_METADATA];
|
|
@@ -23,14 +24,31 @@ export function handleBatchIdsExtensions(attributes, primitive, images, featureT
|
|
|
23
24
|
case EXT_FEATURE_METADATA:
|
|
24
25
|
return handleExtFeatureMetadataExtension(attributes, extensionData, images, featureTexture);
|
|
25
26
|
case EXT_MESH_FEATURES:
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
return handleExtMeshFeaturesExtension(attributes, extensionData);
|
|
28
|
+
case EXT_STRUCTURAL_METADATA:
|
|
29
|
+
return handleExtStructuralMetadataExtension(attributes, extensionData);
|
|
28
30
|
default:
|
|
29
31
|
return [];
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
return [];
|
|
33
35
|
}
|
|
36
|
+
function handleExtStructuralMetadataExtension(attributes, extStructuralMetadata) {
|
|
37
|
+
const dataAttributeNames = extStructuralMetadata === null || extStructuralMetadata === void 0 ? void 0 : extStructuralMetadata.dataAttributeNames;
|
|
38
|
+
if (dataAttributeNames !== null && dataAttributeNames !== void 0 && dataAttributeNames.length) {
|
|
39
|
+
const batchIdsAttribute = attributes[dataAttributeNames[0]];
|
|
40
|
+
return batchIdsAttribute.value;
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
function handleExtMeshFeaturesExtension(attributes, extMeshFeatures) {
|
|
45
|
+
const dataAttributeNames = extMeshFeatures === null || extMeshFeatures === void 0 ? void 0 : extMeshFeatures.dataAttributeNames;
|
|
46
|
+
if (dataAttributeNames !== null && dataAttributeNames !== void 0 && dataAttributeNames.length) {
|
|
47
|
+
const batchIdsAttribute = attributes[dataAttributeNames[0]];
|
|
48
|
+
return batchIdsAttribute.value;
|
|
49
|
+
}
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
34
52
|
function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images, featureTexture) {
|
|
35
53
|
var _extFeatureMetadata$f, _featureIdAttribute$f, _featureIdAttribute$f2, _featureIdAttribute$f3;
|
|
36
54
|
const featureIdAttribute = extFeatureMetadata === null || extFeatureMetadata === void 0 ? void 0 : (_extFeatureMetadata$f = extFeatureMetadata.featureIdAttributes) === null || _extFeatureMetadata$f === void 0 ? void 0 : _extFeatureMetadata$f[0];
|
|
@@ -111,7 +129,4 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
|
|
|
111
129
|
}
|
|
112
130
|
return batchIds;
|
|
113
131
|
}
|
|
114
|
-
function emod(n) {
|
|
115
|
-
return (n % 1 + 1) % 1;
|
|
116
|
-
}
|
|
117
132
|
//# sourceMappingURL=batch-ids-extensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-ids-extensions.js","names":["EXT_FEATURE_METADATA","EXT_MESH_FEATURES","getTextureByMetadataClass","tileContent","metadataClass","_tileContent$gltf","_tileContent$gltf$ext","extFeatureMetadata","gltf","extensions","featureTextures","textureKey","texture","class","handleBatchIdsExtensions","attributes","primitive","images","featureTexture","extensionName","extensionData","Object","entries","handleExtFeatureMetadataExtension","console","warn","_extFeatureMetadata$f","_featureIdAttribute$f","_featureIdAttribute$f2","_featureIdAttribute$f3","featureIdAttribute","featureIdAttributes","featureIds","attribute","batchIdsAttribute","value","hasOwnProperty","_attributes$POSITIONS","featuresCount","POSITIONS","length","generateImplicitFeatureIds","constant","divisor","featureIdTexture","featureIdTextures","_featureIdTexture$fea","_featureIdTexture$fea2","textureAttributeIndex","texCoord","textCoordAttribute","concat","textureCoordinates","generateBatchIdsFromTexture","arguments","undefined","currentValue","devisorCounter","index","push","Array","fill","_featureIdTexture$fea3","_featureIdTexture$fea4","_featureIdTexture$fea5","CHANNELS_MAP","r","g","b","a","textureIndex","featureChannel","channels","image","batchIds","width","height","components","u","v","tx","Math","min","emod","ty","offset","batchId","Uint8Array","data","mimeType","n"],"sources":["../../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"sourcesContent":["import {GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed} from '@loaders.gl/gltf';\nimport type {NumericArray} from '@loaders.gl/loader-utils';\nimport type {\n GLTF_EXT_feature_metadata_FeatureIdTexture,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_Primitive\n} from '@loaders.gl/gltf';\nimport {TypedArray} from '@math.gl/core';\nimport {TextureImageProperties} from '../types';\nimport {EXT_FEATURE_METADATA, EXT_MESH_FEATURES} from '../../constants';\nimport {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\n\n/**\n * Get featureTexture by metadataClass\n * @param tileContent - 3d tile content\n * @param metadataClass - user selected feature metadata class name\n * @returns featureTexture key\n */\nexport function getTextureByMetadataClass(\n tileContent: Tiles3DTileContent,\n metadataClass?: string\n): string | null {\n const extFeatureMetadata = tileContent.gltf?.extensions?.[\n EXT_FEATURE_METADATA\n ] as GLTF_EXT_feature_metadata_GLTF;\n if (!extFeatureMetadata?.featureTextures) {\n return null;\n }\n for (const textureKey in extFeatureMetadata.featureTextures) {\n const texture = extFeatureMetadata.featureTextures[textureKey];\n if (texture.class === metadataClass) {\n return textureKey;\n }\n }\n return null;\n}\n\n/**\n * Getting batchIds from 3DTilesNext extensions.\n * @param attributes - gltf accessors\n * @param primitive - gltf primitive data\n * @param images - gltf texture images\n * @param featureTexture - feature texture key\n * @return array of batch IDs\n */\nexport function handleBatchIdsExtensions(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n primitive: GLTFMeshPrimitivePostprocessed,\n images: (TextureImageProperties | null)[],\n featureTexture: string | null\n): NumericArray {\n const extensions = primitive?.extensions;\n\n if (!extensions) {\n return [];\n }\n\n for (const [extensionName, extensionData] of Object.entries(extensions || {})) {\n switch (extensionName) {\n case EXT_FEATURE_METADATA:\n return handleExtFeatureMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_feature_metadata_Primitive,\n images,\n featureTexture\n );\n case EXT_MESH_FEATURES:\n console.warn('EXT_mesh_features extension is not supported yet');\n return [];\n default:\n return [];\n }\n }\n\n return [];\n}\n\n/**\n * Get batchIds from EXT_feature_metadata extension.\n * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n * @param attributes - glTF attributes\n * @param extFeatureMetadata - primitive-level EXT_FEATURE_METADATA extension data\n * @param textures - texture images\n * @param featureTexture - feature texture key\n */\nfunction handleExtFeatureMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extFeatureMetadata: GLTF_EXT_feature_metadata_Primitive,\n images: (TextureImageProperties | null)[],\n featureTexture: string | null\n): NumericArray {\n // Take only first extension object to get batchIds attribute name.\n const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];\n\n if (featureIdAttribute?.featureIds?.attribute) {\n const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];\n return batchIdsAttribute.value;\n }\n\n if (\n featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&\n featureIdAttribute?.featureIds?.hasOwnProperty('divisor')\n ) {\n const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;\n return generateImplicitFeatureIds(\n featuresCount,\n featureIdAttribute.featureIds.constant,\n featureIdAttribute.featureIds.divisor\n );\n }\n\n // Take only first extension object to get batchIds attribute name.\n const featureIdTexture =\n extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];\n\n if (featureIdTexture) {\n const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;\n const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;\n const textureCoordinates = attributes[textCoordAttribute].value;\n return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);\n }\n\n if (featureTexture) {\n const batchIdsAttribute = attributes[featureTexture];\n return batchIdsAttribute.value;\n }\n\n return [];\n}\n\n/**\n * Generates implicit feature ids\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids\n * @param featuresCount\n * @param constant\n * @param devisor\n */\nfunction generateImplicitFeatureIds(\n featuresCount: number,\n constant: number = 0,\n divisor: number = 0\n): number[] {\n let featureIds: number[] = [];\n\n if (divisor > 0) {\n let currentValue = constant;\n let devisorCounter = divisor;\n\n for (let index = 0; index < featuresCount; index++) {\n featureIds.push(currentValue);\n\n devisorCounter -= 1;\n\n if (devisorCounter === 0) {\n currentValue++;\n devisorCounter = divisor;\n }\n }\n } else {\n featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);\n }\n\n return featureIds;\n}\n\n/**\n * Get batchIds from texture.\n * @param primitive\n * @param featureIdTextures\n */\nfunction generateBatchIdsFromTexture(\n featureIdTexture: GLTF_EXT_feature_metadata_FeatureIdTexture,\n textureCoordinates: TypedArray,\n images: (TextureImageProperties | null)[]\n) {\n if (!images?.length) {\n return [];\n }\n\n const CHANNELS_MAP = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n };\n\n const textureIndex = featureIdTexture?.featureIds?.texture?.index;\n const featureChannel = featureIdTexture?.featureIds?.channels;\n\n if (!featureChannel || textureIndex === undefined) {\n return [];\n }\n\n const image = images[textureIndex];\n const batchIds: number[] = [];\n const channels = CHANNELS_MAP[featureChannel];\n\n if (image && image?.width && image?.height && image?.components) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);\n const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);\n\n const offset = (ty * image.width + tx) * image.components + channels;\n const batchId = new Uint8Array(image.data)[offset];\n\n batchIds.push(batchId);\n }\n } else {\n console.warn(`Can't get batch Ids from ${image?.mimeType || ''} compressed texture`);\n }\n\n return batchIds;\n}\n\n/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n * @param m\n */\nfunction emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":"AASA,SAAQA,oBAAoB,EAAEC,iBAAiB,QAAO,iBAAiB;AASvE,OAAO,SAASC,yBAAyBA,CACvCC,WAA+B,EAC/BC,aAAsB,EACP;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EACf,MAAMC,kBAAkB,IAAAF,iBAAA,GAAGF,WAAW,CAACK,IAAI,cAAAH,iBAAA,wBAAAC,qBAAA,GAAhBD,iBAAA,CAAkBI,UAAU,cAAAH,qBAAA,uBAA5BA,qBAAA,CACzBN,oBAAoB,CACa;EACnC,IAAI,EAACO,kBAAkB,aAAlBA,kBAAkB,eAAlBA,kBAAkB,CAAEG,eAAe,GAAE;IACxC,OAAO,IAAI;EACb;EACA,KAAK,MAAMC,UAAU,IAAIJ,kBAAkB,CAACG,eAAe,EAAE;IAC3D,MAAME,OAAO,GAAGL,kBAAkB,CAACG,eAAe,CAACC,UAAU,CAAC;IAC9D,IAAIC,OAAO,CAACC,KAAK,KAAKT,aAAa,EAAE;MACnC,OAAOO,UAAU;IACnB;EACF;EACA,OAAO,IAAI;AACb;AAUA,OAAO,SAASG,wBAAwBA,CACtCC,UAEC,EACDC,SAAyC,EACzCC,MAAyC,EACzCC,cAA6B,EACf;EACd,MAAMT,UAAU,GAAGO,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEP,UAAU;EAExC,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,EAAE;EACX;EAEA,KAAK,MAAM,CAACU,aAAa,EAAEC,aAAa,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACb,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;IAC7E,QAAQU,aAAa;MACnB,KAAKnB,oBAAoB;QACvB,OAAOuB,iCAAiC,CACtCR,UAAU,EACVK,aAAa,EACbH,MAAM,EACNC,cACF,CAAC;MACH,KAAKjB,iBAAiB;QACpBuB,OAA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K,CAAEgB,QAAQ,KAAI,EAAE,wBAAqB,CAAC;EACtF;EAEA,OAAOf,QAAQ;AACjB;AAOA,SAASS,IAAIA,CAACO,CAAS,EAAU;EAC/B,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
|
|
1
|
+
{"version":3,"file":"batch-ids-extensions.js","names":["emod","EXT_STRUCTURAL_METADATA","EXT_MESH_FEATURES","EXT_FEATURE_METADATA","getTextureByMetadataClass","tileContent","metadataClass","_tileContent$gltf","_tileContent$gltf$ext","extFeatureMetadata","gltf","extensions","featureTextures","textureKey","texture","class","handleBatchIdsExtensions","attributes","primitive","images","featureTexture","extensionName","extensionData","Object","entries","handleExtFeatureMetadataExtension","handleExtMeshFeaturesExtension","handleExtStructuralMetadataExtension","extStructuralMetadata","dataAttributeNames","length","batchIdsAttribute","value","extMeshFeatures","_extFeatureMetadata$f","_featureIdAttribute$f","_featureIdAttribute$f2","_featureIdAttribute$f3","featureIdAttribute","featureIdAttributes","featureIds","attribute","hasOwnProperty","_attributes$POSITIONS","featuresCount","POSITIONS","generateImplicitFeatureIds","constant","divisor","featureIdTexture","featureIdTextures","_featureIdTexture$fea","_featureIdTexture$fea2","textureAttributeIndex","texCoord","textCoordAttribute","concat","textureCoordinates","generateBatchIdsFromTexture","arguments","undefined","currentValue","devisorCounter","index","push","Array","fill","_featureIdTexture$fea3","_featureIdTexture$fea4","_featureIdTexture$fea5","CHANNELS_MAP","r","g","b","a","textureIndex","featureChannel","channels","image","batchIds","width","height","components","u","v","tx","Math","min","ty","offset","batchId","Uint8Array","data","console","warn","mimeType"],"sources":["../../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"sourcesContent":["import {GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed} from '@loaders.gl/gltf';\nimport type {NumericArray} from '@loaders.gl/loader-utils';\nimport type {\n GLTF_EXT_feature_metadata_FeatureIdTexture,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_Primitive,\n GLTF_EXT_structural_metadata\n} from '@loaders.gl/gltf';\n\nimport type {GLTF_EXT_mesh_features} from '@loaders.gl/gltf';\n\nimport {TypedArray} from '@math.gl/core';\nimport {TextureImageProperties} from '../types';\nimport {emod} from '@loaders.gl/math';\nimport {EXT_STRUCTURAL_METADATA, EXT_MESH_FEATURES, EXT_FEATURE_METADATA} from '@loaders.gl/gltf';\nimport {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\n\n/**\n * Get featureTexture by metadataClass\n * @param tileContent - 3d tile content\n * @param metadataClass - user selected feature metadata class name\n * @returns featureTexture key\n */\nexport function getTextureByMetadataClass(\n tileContent: Tiles3DTileContent,\n metadataClass?: string\n): string | null {\n const extFeatureMetadata = tileContent.gltf?.extensions?.[\n EXT_FEATURE_METADATA\n ] as GLTF_EXT_feature_metadata_GLTF;\n if (!extFeatureMetadata?.featureTextures) {\n return null;\n }\n for (const textureKey in extFeatureMetadata.featureTextures) {\n const texture = extFeatureMetadata.featureTextures[textureKey];\n if (texture.class === metadataClass) {\n return textureKey;\n }\n }\n return null;\n}\n\n/**\n * Getting batchIds from 3DTilesNext extensions.\n * @param attributes - gltf accessors\n * @param primitive - gltf primitive data\n * @param images - gltf texture images\n * @param featureTexture - feature texture key\n * @return array of batch IDs\n */\nexport function handleBatchIdsExtensions(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n primitive: GLTFMeshPrimitivePostprocessed,\n images: (TextureImageProperties | null)[],\n featureTexture: string | null\n): NumericArray {\n const extensions = primitive?.extensions;\n if (!extensions) {\n return [];\n }\n\n for (const [extensionName, extensionData] of Object.entries(extensions || {})) {\n switch (extensionName) {\n case EXT_FEATURE_METADATA:\n return handleExtFeatureMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_feature_metadata_Primitive,\n images,\n featureTexture\n );\n case EXT_MESH_FEATURES:\n return handleExtMeshFeaturesExtension(attributes, extensionData as GLTF_EXT_mesh_features);\n case EXT_STRUCTURAL_METADATA:\n return handleExtStructuralMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_structural_metadata\n );\n\n default:\n return [];\n }\n }\n\n return [];\n}\n\nfunction handleExtStructuralMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extStructuralMetadata: GLTF_EXT_structural_metadata\n): NumericArray {\n // Take only first extension object to get batchIds attribute name.\n const dataAttributeNames = extStructuralMetadata?.dataAttributeNames;\n if (dataAttributeNames?.length) {\n // Let's use the first element of the array\n // TODO: What to do with others if any?\n const batchIdsAttribute = attributes[dataAttributeNames[0]];\n return batchIdsAttribute.value;\n }\n return [];\n}\n\n/**\n * Getting batchIds from EXT_mesh_features extensions.\n * @param attributes - gltf accessors\n * @param extMeshFeatures - EXT_mesh_features extension\n * @returns an array of attribute values\n */\nfunction handleExtMeshFeaturesExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extMeshFeatures: GLTF_EXT_mesh_features\n): NumericArray {\n const dataAttributeNames = extMeshFeatures?.dataAttributeNames;\n if (dataAttributeNames?.length) {\n // Let's use the first element of the array\n // TODO: What to do with others if any?\n const batchIdsAttribute = attributes[dataAttributeNames[0]];\n return batchIdsAttribute.value;\n }\n return [];\n}\n\n/**\n * Get batchIds from EXT_feature_metadata extension.\n * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n * @param attributes - glTF attributes\n * @param extFeatureMetadata - primitive-level EXT_FEATURE_METADATA extension data\n * @param textures - texture images\n * @param featureTexture - feature texture key\n */\nfunction handleExtFeatureMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extFeatureMetadata: GLTF_EXT_feature_metadata_Primitive,\n images: (TextureImageProperties | null)[],\n featureTexture: string | null\n): NumericArray {\n // Take only first extension object to get batchIds attribute name.\n const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];\n\n if (featureIdAttribute?.featureIds?.attribute) {\n const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];\n return batchIdsAttribute.value;\n }\n\n if (\n featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&\n featureIdAttribute?.featureIds?.hasOwnProperty('divisor')\n ) {\n const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;\n return generateImplicitFeatureIds(\n featuresCount,\n featureIdAttribute.featureIds.constant,\n featureIdAttribute.featureIds.divisor\n );\n }\n\n // Take only first extension object to get batchIds attribute name.\n const featureIdTexture =\n extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];\n\n if (featureIdTexture) {\n const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;\n const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;\n const textureCoordinates = attributes[textCoordAttribute].value;\n return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);\n }\n\n if (featureTexture) {\n const batchIdsAttribute = attributes[featureTexture];\n return batchIdsAttribute.value;\n }\n\n return [];\n}\n\n/**\n * Generates implicit feature ids\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids\n * @param featuresCount\n * @param constant\n * @param devisor\n */\nfunction generateImplicitFeatureIds(\n featuresCount: number,\n constant: number = 0,\n divisor: number = 0\n): number[] {\n let featureIds: number[] = [];\n\n if (divisor > 0) {\n let currentValue = constant;\n let devisorCounter = divisor;\n\n for (let index = 0; index < featuresCount; index++) {\n featureIds.push(currentValue);\n\n devisorCounter -= 1;\n\n if (devisorCounter === 0) {\n currentValue++;\n devisorCounter = divisor;\n }\n }\n } else {\n featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);\n }\n\n return featureIds;\n}\n\n/**\n * Get batchIds from texture.\n * @param primitive\n * @param featureIdTextures\n */\nfunction generateBatchIdsFromTexture(\n featureIdTexture: GLTF_EXT_feature_metadata_FeatureIdTexture,\n textureCoordinates: TypedArray,\n images: (TextureImageProperties | null)[]\n) {\n if (!images?.length) {\n return [];\n }\n\n const CHANNELS_MAP = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n };\n\n const textureIndex = featureIdTexture?.featureIds?.texture?.index;\n const featureChannel = featureIdTexture?.featureIds?.channels;\n\n if (!featureChannel || textureIndex === undefined) {\n return [];\n }\n\n const image = images[textureIndex];\n const batchIds: number[] = [];\n const channels = CHANNELS_MAP[featureChannel];\n\n if (image && image?.width && image?.height && image?.components) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);\n const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);\n\n const offset = (ty * image.width + tx) * image.components + channels;\n const batchId = new Uint8Array(image.data)[offset];\n\n batchIds.push(batchId);\n }\n } else {\n console.warn(`Can't get batch Ids from ${image?.mimeType || ''} compressed texture`);\n }\n\n return batchIds;\n}\n"],"mappings":"AAaA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAAQC,uBAAuB,EAAEC,iBAAiB,EAAEC,oBAAoB,QAAO,kBAAkB;AASjG,OAAO,SAASC,yBAAyBA,CACvCC,WAA+B,EAC/BC,aAAsB,EACP;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EACf,MAAMC,kBAAkB,IAAAF,iBAAA,GAAGF,WAAW,CAACK,IAAI,cAAAH,iBAAA,wBAAAC,qBAAA,GAAhBD,iBAAA,CAAkBI,UAAU,cAAAH,qBAAA,uBAA5BA,qBAAA,CACzBL,oBAAoB,CACa;EACnC,IAAI,EAACM,kBAAkB,aAAlBA,kBAAkB,eAAlBA,kBAAkB,CAAEG,eAAe,GAAE;IACxC,OAAO,IAAI;EACb;EACA,KAAK,MAAMC,UAAU,IAAIJ,kBAAkB,CAACG,eAAe,EAAE;IAC3D,MAAME,OAAO,GAAGL,kBAAkB,CAACG,eAAe,CAACC,UAAU,CAAC;IAC9D,IAAIC,OAAO,CAACC,KAAK,KAAKT,aAAa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G,OAAO,CAACC,IAAI,6BAAAtC,MAAA,CAA6B,CAAAsB,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEiB,QAAQ,KAAI,EAAE,wBAAqB,CAAC;EACtF;EAEA,OAAOhB,QAAQ;AACjB"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
export function flattenPropertyTableByFeatureIds(
|
|
1
|
+
export function flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) {
|
|
2
2
|
const resultPropertyTable = {};
|
|
3
3
|
for (const propertyName in propertyTable) {
|
|
4
4
|
const properties = propertyTable[propertyName];
|
|
5
|
-
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties,
|
|
5
|
+
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);
|
|
6
6
|
}
|
|
7
7
|
return resultPropertyTable;
|
|
8
8
|
}
|
|
9
|
-
function getPropertiesByFeatureIds(properties,
|
|
9
|
+
function getPropertiesByFeatureIds(properties, featureIdsMap) {
|
|
10
10
|
const resultProperties = [];
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
if (properties) {
|
|
12
|
+
for (const featureIdKey in featureIdsMap) {
|
|
13
|
+
const property = properties[featureIdKey] || null;
|
|
14
|
+
resultProperties.push(property);
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
17
|
return resultProperties;
|
|
16
18
|
}
|
|
17
19
|
export function checkPropertiesLength(featureIds, propertyTable) {
|
|
18
20
|
let needFlatten = false;
|
|
19
21
|
for (const attribute of Object.values(propertyTable)) {
|
|
20
|
-
if (featureIds.length !== attribute.length) {
|
|
22
|
+
if (!featureIds || !attribute || featureIds.length !== attribute.length) {
|
|
21
23
|
needFlatten = true;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-attributes.js","names":["flattenPropertyTableByFeatureIds","featureIds","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureId","property","push","checkPropertiesLength","needFlatten","attribute","Object","values","length","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","getAttributeType","key","Number","isInteger","createdStorageAttribute","attributeIndex","attributeType","storageAttribute","concat","name","ordering","header","valueType","attributeValues","valuesPerElement","setupIdAttribute","setupStringAttribute","setupDoubleAttribute","getFieldAttributeType","createFieldAttribute","fieldAttributeType","type","alias","createPopupInfo","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","unshift","encoding","attributeByteCounts"],"sources":["../../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\n/**\n * Takes attributes from property table based on featureIds.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'null']\n * @param featureIds\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): FeatureTableJson {\n const resultPropertyTable: FeatureTableJson = {};\n for (const propertyName in propertyTable) {\n const properties = propertyTable[propertyName];\n resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIds);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIds\n */\nfunction getPropertiesByFeatureIds(properties: any[], featureIds: number[]): any[] {\n const resultProperties: any = [];\n\n for (const featureId of featureIds) {\n const property = properties[featureId] || null;\n resultProperties.push(property);\n }\n\n return resultProperties;\n}\n\n/**\n * Check that all attributes in propertyTable have the same length as FeatureIds.\n * If there are differencies between lengths we should flatten property table based on exiesting featureIds.\n * @param featureIds\n * @param propertyTable\n * @returns\n */\nexport function checkPropertiesLength(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): boolean {\n let needFlatten = false;\n\n for (const attribute of Object.values(propertyTable)) {\n if (featureIds.length !== attribute.length) {\n needFlatten = true;\n }\n }\n\n return needFlatten;\n}\n\n/** String data type name for feature attributes */\nconst STRING_TYPE = 'string';\n/** Integer data type name for feature attributes */\nconst SHORT_INT_TYPE = 'Int32';\n/** Double data type name for feature attributes */\nconst DOUBLE_TYPE = 'double';\n/** Type of attribute that is linked with feature ids */\nconst OBJECT_ID_TYPE = 'OBJECTID';\n/**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in propertyTable\n */\nexport function getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n}\n\n/**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\nexport function createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n}\n\n/**\n * Find and return attribute type based on key form propertyTable.\n * @param attributeType\n */\nexport function getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n}\n\n/**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\nexport function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n}\n\n/**\n * Generate popup info to show metadata on the map.\n * @param propertyTable - table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\nexport function createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in propertyTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n}\n\n/**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\nfunction setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n}\n"],"mappings":"AAuBA,OAAO,SAASA,gCAAgCA,CAC9CC,UAAoB,EACpBC,aAA+B,EACb;EAClB,MAAMC,mBAAqC,GAAG,CAAC,CAAC;EAChD,KAAK,MAAMC,YAAY,IAAIF,aAAa,EAAE;IACxC,MAAMG,UAAU,GAAGH,aAAa,CAACE,YAAY,CAAC;IAC9CD,mBAAmB,CAACC,YAAY,CAAC,GAAGE,yBAAyB,CAACD,UAAU,EAAEJ,UAAU,CAAC;EACvF;EAEA,OAAOE,mBAAmB;AAC5B;AAOA,SAASG,yBAAyBA,CAACD,UAAiB,EAAEJ,UAAoB,EAAS;EACjF,MAAMM,gBAAqB,GAAG,EAAE;EAEhC,KAAK,MAAMC,SAAS,IAAIP,UAAU,EAAE;IAClC,MAAMQ,QAAQ,GAAGJ,UAAU,CAACG,SAAS,CAAC,IAAI,IAAI;IAC9CD,gBAAgB,CAACG,IAAI,CAACD,QAAQ,CAAC;EACjC;EAEA,OAAOF,gBAAgB;AACzB;AASA,OAAO,SAASI,qBAAqBA,CACnCV,UAAoB,EACpBC,aAA+B,EACtB;EACT,IAAIU,WAAW,GAAG,KAAK;EAEvB,KAAK,MAAMC,SAAS,IAAIC,MAAM,CAACC,MAAM,CAACb,aAAa,CAAC,EAAE;IACpD,IAAID,UAAU,CAACe,MAAM,KAAKH,SAAS,CAACG,MAAM,EAAE;MAC1CJ,WAAW,GAAG,IAAI;IACpB;EACF;EAEA,OAAOA,WAAW;AACpB;AAGA,MAAMK,WAAW,GAAG,QAAQ;AAE5B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AgB,EAAE;EACpB,CAAC;EACDP,gBAAgB,CAAC4B,mBAAmB,GAAG;IACrCvB,SAAS,EAAE,QAAQ;IACnBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASC,gBAAgBA,CAACR,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASG,oBAAoBA,CAACV,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"feature-attributes.js","names":["flattenPropertyTableByFeatureIds","featureIdsMap","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureIdKey","property","push","checkPropertiesLength","featureIds","needFlatten","attribute","Object","values","length","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","getAttributeType","key","Number","isInteger","createdStorageAttribute","attributeIndex","attributeType","storageAttribute","concat","name","ordering","header","valueType","attributeValues","valuesPerElement","setupIdAttribute","setupStringAttribute","setupDoubleAttribute","getFieldAttributeType","createFieldAttribute","fieldAttributeType","type","alias","createPopupInfo","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","unshift","encoding","attributeByteCounts"],"sources":["../../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\n/**\n * Takes attributes from property table based on featureIdsMap.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: {0: 0, 3: 33, 4: 333}\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 33, 333]\n * component: ['Windows', 'Roof', 'Skylight']\n * @param featureIdsMap\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIdsMap: Record<string, number>,\n propertyTable: FeatureTableJson\n): FeatureTableJson {\n const resultPropertyTable: FeatureTableJson = {};\n for (const propertyName in propertyTable) {\n const properties = propertyTable[propertyName];\n resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIdsMap\n */\nfunction getPropertiesByFeatureIds(\n properties: unknown[],\n featureIdsMap: Record<string, number>\n): unknown[] {\n const resultProperties: unknown[] = [];\n\n if (properties) {\n for (const featureIdKey in featureIdsMap) {\n const property = properties[featureIdKey] || null;\n resultProperties.push(property);\n }\n }\n\n return resultProperties;\n}\n\n/**\n * Check that all attributes in propertyTable have the same length as FeatureIds.\n * If there are differencies between lengths we should flatten property table based on exiesting featureIds.\n * @param featureIds\n * @param propertyTable\n * @returns\n */\nexport function checkPropertiesLength(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): boolean {\n let needFlatten = false;\n\n for (const attribute of Object.values(propertyTable)) {\n if (!featureIds || !attribute || featureIds.length !== attribute.length) {\n needFlatten = true;\n }\n }\n\n return needFlatten;\n}\n\n/** String data type name for feature attributes */\nconst STRING_TYPE = 'string';\n/** Integer data type name for feature attributes */\nconst SHORT_INT_TYPE = 'Int32';\n/** Double data type name for feature attributes */\nconst DOUBLE_TYPE = 'double';\n/** Type of attribute that is linked with feature ids */\nconst OBJECT_ID_TYPE = 'OBJECTID';\n/**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in propertyTable\n */\nexport function getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n}\n\n/**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\nexport function createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n}\n\n/**\n * Find and return attribute type based on key form propertyTable.\n * @param attributeType\n */\nexport function getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n}\n\n/**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\nexport function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n}\n\n/**\n * Generate popup info to show metadata on the map.\n * @param propertyTable - table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\nexport function createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in propertyTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n}\n\n/**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\nfunction setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n}\n"],"mappings":"AAuBA,OAAO,SAASA,gCAAgCA,CAC9CC,aAAqC,EACrCC,aAA+B,EACb;EAClB,MAAMC,mBAAqC,GAAG,CAAC,CAAC;EAChD,KAAK,MAAMC,YAAY,IAAIF,aAAa,EAAE;IACxC,MAAMG,UAAU,GAAGH,aAAa,CAACE,YAAY,CAAC;IAC9CD,mBAAmB,CAACC,YAAY,CAAC,GAAGE,yBAAyB,CAACD,UAAU,EAAEJ,aAAa,CAAC;EAC1F;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AAe,GAAG,EAAE;EAE1B,KAAK,MAAM3B,GAAG,IAAIrB,aAAa,EAAE;IAC/B8C,UAAU,CAACtC,IAAI,CAAC;MACdyC,SAAS,EAAE5B,GAAG;MACd6B,OAAO,EAAE,IAAI;MACbC,UAAU,EAAE,KAAK;MACjBC,KAAK,EAAE/B;IACT,CAAC,CAAC;EACJ;EACA0B,aAAa,CAACvC,IAAI,CAAC;IACjBsC,UAAU;IACVL,IAAI,EAAE;EACR,CAAC,CAAC;EAEF,OAAO;IACLG,KAAK;IACLC,UAAU;IACVE,aAAa;IACbD,UAAU;IACVE;EACF,CAAC;AACH;AAMA,SAASZ,oBAAoBA,CAACT,gBAAsC,EAAQ;EAE1EA,gBAAgB,CAACG,QAAQ,CAACuB,OAAO,CAAC,qBAAqB,CAAC;EACxD1B,gBAAgB,CAACI,MAAM,CAACvB,IAAI,CAAC;IAACD,QAAQ,EAAE,0BAA0B;IAAEyB,SAAS,EAAE;EAAQ,CAAC,CAAC;EACzFL,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,QAAQ;IACnBsB,QAAQ,EAAE,OAAO;IACjBpB,gBAAgB,EAAE;EACpB,CAAC;EACDP,gBAAgB,CAAC4B,mBAAmB,GAAG;IACrCvB,SAAS,EAAE,QAAQ;IACnBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASC,gBAAgBA,CAACR,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASG,oBAAoBA,CAACV,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
|
|
@@ -91,6 +91,11 @@ function makeAttributeObjects(attributes) {
|
|
|
91
91
|
let colorsList = new Uint8Array(colors);
|
|
92
92
|
let texCoordsList = new Float32Array(texCoords);
|
|
93
93
|
let uvRegionsList = new Uint16Array(uvRegions);
|
|
94
|
+
let positionsOffset = 0;
|
|
95
|
+
let normalsOffset = 0;
|
|
96
|
+
let colorsOffset = 0;
|
|
97
|
+
let uvRegionsOffset = 0;
|
|
98
|
+
let texCoordsOffset = 0;
|
|
94
99
|
for (let index = 0; index < featureIds.length; index++) {
|
|
95
100
|
const startIndex = faceRange[index * 2];
|
|
96
101
|
const endIndex = faceRange[index * 2 + 1];
|
|
@@ -101,19 +106,19 @@ function makeAttributeObjects(attributes) {
|
|
|
101
106
|
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
102
107
|
groupedData.push({
|
|
103
108
|
featureId: featureIds[index],
|
|
104
|
-
positions: positionsList.
|
|
105
|
-
normals: normalsList.
|
|
106
|
-
colors: colorsList.
|
|
107
|
-
uvRegions: uvRegionsList.
|
|
108
|
-
texCoords: texCoordsList.
|
|
109
|
+
positions: positionsList.subarray(positionsOffset, positionsOffset + positionsCount),
|
|
110
|
+
normals: normalsList.subarray(normalsOffset, normalsOffset + normalsCount),
|
|
111
|
+
colors: colorsList.subarray(colorsOffset, colorsOffset + colorsCount),
|
|
112
|
+
uvRegions: uvRegionsList.subarray(uvRegionsOffset, uvRegionsOffset + uvRegionsCount),
|
|
113
|
+
texCoords: texCoordsList.subarray(texCoordsOffset, texCoordsOffset + texCoordsCount)
|
|
109
114
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
positionsOffset += positionsCount;
|
|
116
|
+
normalsOffset += normalsCount;
|
|
117
|
+
colorsOffset += colorsCount;
|
|
118
|
+
uvRegionsOffset += uvRegionsCount;
|
|
119
|
+
texCoordsOffset += texCoordsCount;
|
|
115
120
|
}
|
|
116
|
-
return groupedData
|
|
121
|
+
return groupedData;
|
|
117
122
|
}
|
|
118
123
|
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
119
124
|
const itemsPerVertex4 = 4;
|
|
@@ -134,58 +139,95 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
function unifyObjectsByFeatureId(sortedData) {
|
|
137
|
-
const
|
|
138
|
-
for (
|
|
139
|
-
const
|
|
140
|
-
const existingObject = uniqueObjects.find(obj => obj.featureId === currentObject.featureId);
|
|
142
|
+
const groupedMetadata = [];
|
|
143
|
+
for (const data of sortedData) {
|
|
144
|
+
const existingObject = groupedMetadata.find(obj => obj.featureId === data.featureId);
|
|
141
145
|
if (existingObject) {
|
|
142
|
-
existingObject.
|
|
143
|
-
existingObject.normals = concatenateTypedArrays(existingObject.normals, currentObject.normals);
|
|
144
|
-
existingObject.colors = concatenateTypedArrays(existingObject.colors, currentObject.colors);
|
|
145
|
-
existingObject.texCoords = concatenateTypedArrays(existingObject.texCoords, currentObject.texCoords);
|
|
146
|
-
existingObject.uvRegions = concatenateTypedArrays(existingObject.uvRegions, currentObject.uvRegions);
|
|
146
|
+
existingObject.attributes.push(data);
|
|
147
147
|
} else {
|
|
148
|
-
|
|
148
|
+
groupedMetadata.push({
|
|
149
|
+
featureId: data.featureId,
|
|
150
|
+
attributes: [data]
|
|
151
|
+
});
|
|
149
152
|
}
|
|
150
153
|
}
|
|
154
|
+
const uniqueObjects = [];
|
|
155
|
+
for (const metatada of groupedMetadata) {
|
|
156
|
+
const attributes = concatenateAttributes(metatada.attributes);
|
|
157
|
+
uniqueObjects.push({
|
|
158
|
+
featureId: metatada.featureId,
|
|
159
|
+
...attributes
|
|
160
|
+
});
|
|
161
|
+
}
|
|
151
162
|
return uniqueObjects;
|
|
152
163
|
}
|
|
153
164
|
function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
154
165
|
const firstAttributeObject = unifiedObjects[0];
|
|
155
166
|
const featureIds = [firstAttributeObject.featureId || 0];
|
|
156
|
-
let positions = new Float32Array(firstAttributeObject.positions);
|
|
157
|
-
let normals = new Float32Array(firstAttributeObject.normals);
|
|
158
|
-
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
159
|
-
let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
|
|
160
|
-
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
161
167
|
const range = [0];
|
|
162
168
|
let objIndex = 0;
|
|
163
169
|
let sum = 0;
|
|
164
170
|
for (let index = 1; index < unifiedObjects.length; index++) {
|
|
165
171
|
const currentAttributesObject = unifiedObjects[index];
|
|
166
172
|
featureIds.push(currentAttributesObject.featureId || 0);
|
|
167
|
-
positions = concatenateTypedArrays(positions, currentAttributesObject.positions);
|
|
168
|
-
normals = concatenateTypedArrays(normals, currentAttributesObject.normals);
|
|
169
|
-
colors = concatenateTypedArrays(colors, currentAttributesObject.colors);
|
|
170
|
-
uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);
|
|
171
|
-
texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);
|
|
172
173
|
const groupedObject = unifiedObjects[objIndex];
|
|
173
174
|
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
174
175
|
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
|
|
175
176
|
sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
176
177
|
objIndex += 1;
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
+
const attributes = concatenateAttributes(unifiedObjects);
|
|
180
|
+
range.push(attributes.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
179
181
|
const faceRange = new Uint32Array(range);
|
|
180
182
|
return {
|
|
181
183
|
faceRange,
|
|
182
184
|
featureIds,
|
|
185
|
+
featureCount,
|
|
186
|
+
...attributes
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function concatenateAttributes(attributes) {
|
|
190
|
+
const positionGroups = attributes.map(_ref => {
|
|
191
|
+
let {
|
|
192
|
+
positions
|
|
193
|
+
} = _ref;
|
|
194
|
+
return positions;
|
|
195
|
+
});
|
|
196
|
+
const positions = positionGroups.length > 1 ? concatenateTypedArrays(...positionGroups) : positionGroups[0];
|
|
197
|
+
const normalGroups = attributes.map(_ref2 => {
|
|
198
|
+
let {
|
|
199
|
+
normals
|
|
200
|
+
} = _ref2;
|
|
201
|
+
return normals;
|
|
202
|
+
});
|
|
203
|
+
const normals = normalGroups.length > 1 ? concatenateTypedArrays(...normalGroups) : normalGroups[0];
|
|
204
|
+
const colorGroups = attributes.map(_ref3 => {
|
|
205
|
+
let {
|
|
206
|
+
colors
|
|
207
|
+
} = _ref3;
|
|
208
|
+
return colors;
|
|
209
|
+
});
|
|
210
|
+
const colors = colorGroups.length > 1 ? concatenateTypedArrays(...colorGroups) : colorGroups[0];
|
|
211
|
+
const texCoordGroups = attributes.map(_ref4 => {
|
|
212
|
+
let {
|
|
213
|
+
texCoords
|
|
214
|
+
} = _ref4;
|
|
215
|
+
return texCoords;
|
|
216
|
+
});
|
|
217
|
+
const texCoords = texCoordGroups.length > 1 ? concatenateTypedArrays(...texCoordGroups) : texCoordGroups[0];
|
|
218
|
+
const uvRegionGroups = attributes.map(_ref5 => {
|
|
219
|
+
let {
|
|
220
|
+
uvRegions
|
|
221
|
+
} = _ref5;
|
|
222
|
+
return uvRegions;
|
|
223
|
+
});
|
|
224
|
+
const uvRegions = uvRegionGroups.length > 1 ? concatenateTypedArrays(...uvRegionGroups) : uvRegionGroups[0];
|
|
225
|
+
return {
|
|
183
226
|
positions,
|
|
184
227
|
normals,
|
|
185
228
|
colors,
|
|
186
|
-
uvRegions,
|
|
187
229
|
texCoords,
|
|
188
|
-
|
|
230
|
+
uvRegions
|
|
189
231
|
};
|
|
190
232
|
}
|
|
191
233
|
//# sourceMappingURL=geometry-attributes.js.map
|