@loaders.gl/tile-converter 3.1.0-alpha.3 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/converter.js +1 -1
- package/dist/bundle.js +85947 -4
- package/dist/converter.min.js +292 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +267 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
- package/dist/{3d-tiles-converter → es5/3d-tiles-converter}/helpers/b3dm-converter.d.ts +0 -0
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +269 -0
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
- package/dist/{3d-tiles-converter → es5/3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -0
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +22 -0
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +40 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +48 -0
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -0
- package/dist/es5/bundle.js +7 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/{deps-installer → es5/deps-installer}/deps-installer.d.ts +0 -0
- package/dist/es5/deps-installer/deps-installer.js +39 -0
- package/dist/es5/deps-installer/deps-installer.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +65 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +30 -0
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +208 -0
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -0
- package/dist/{i3s-converter → es5/i3s-converter}/helpers/geometry-converter.d.ts +0 -0
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +700 -0
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-debug.js +103 -0
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -0
- package/dist/{i3s-converter → es5/i3s-converter}/helpers/node-pages.d.ts +0 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +150 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -0
- package/dist/es5/i3s-converter/i3s-converter.js +915 -0
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/layers.js +203 -0
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/metadata.js +29 -0
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/node.js +91 -0
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/scene-server.js +35 -0
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +141 -0
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/store.js +105 -0
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -0
- package/dist/es5/i3s-server/app.js +23 -0
- package/dist/es5/i3s-server/app.js.map +1 -0
- package/dist/{i3s-server → es5/i3s-server}/bin/www +0 -0
- package/dist/{i3s-server → es5/i3s-server}/certs/cert.pem +0 -0
- package/dist/{i3s-server → es5/i3s-server}/certs/key.pem +0 -0
- package/dist/es5/i3s-server/controllers/index-controller.js +33 -0
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -0
- package/dist/es5/i3s-server/routes/index.js +22 -0
- package/dist/es5/i3s-server/routes/index.js.map +1 -0
- package/dist/es5/index.js +40 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/{lib → es5/lib}/geoid-height-model.d.ts +0 -0
- package/dist/es5/lib/geoid-height-model.js +149 -0
- package/dist/es5/lib/geoid-height-model.js.map +1 -0
- package/dist/{lib → es5/lib}/pgm-parser.d.ts +0 -0
- package/dist/es5/lib/pgm-parser.js +192 -0
- package/dist/es5/lib/pgm-parser.js.map +1 -0
- package/dist/es5/lib/utils/compress-util.js +202 -0
- package/dist/es5/lib/utils/compress-util.js.map +1 -0
- package/dist/{lib → es5/lib}/utils/compress-utils.d.ts +0 -0
- package/dist/{lib → es5/lib}/utils/file-utils.d.ts +0 -0
- package/dist/es5/lib/utils/file-utils.js +59 -0
- package/dist/es5/lib/utils/file-utils.js.map +1 -0
- package/dist/{lib → es5/lib}/utils/lod-conversion-utils.d.ts +0 -0
- package/dist/es5/lib/utils/lod-conversion-utils.js +52 -0
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -0
- package/dist/{lib → es5/lib}/utils/statistic-utills.d.ts +0 -0
- package/dist/es5/lib/utils/statistic-utills.js +85 -0
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -0
- package/dist/es5/pgm-loader.js +24 -0
- package/dist/es5/pgm-loader.js.map +1 -0
- package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/3d-tiles-converter.js +19 -13
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.d.ts +23 -0
- package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/helpers/b3dm-converter.js +19 -8
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +16 -0
- package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.js +0 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +33 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/json-templates/tileset.js +0 -0
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -0
- package/dist/esm/bundle.js +5 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/deps-installer/deps-installer.d.ts +10 -0
- package/dist/{deps-installer → esm/deps-installer}/deps-installer.js +0 -0
- package/dist/esm/deps-installer/deps-installer.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/helpers/coordinate-converter.js +0 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/helpers/create-scene-server-path.js +0 -0
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/helpers/geometry-attributes.js +0 -0
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +40 -0
- package/dist/{i3s-converter → esm/i3s-converter}/helpers/geometry-converter.js +29 -31
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/helpers/node-debug.js +2 -2
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.d.ts +144 -0
- package/dist/{i3s-converter → esm/i3s-converter}/helpers/node-pages.js +2 -2
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/i3s-converter.js +50 -31
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/json-templates/layers.js +0 -0
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/json-templates/metadata.js +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/json-templates/node.js +0 -0
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/json-templates/scene-server.js +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/json-templates/shared-resources.js +2 -2
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -0
- package/dist/{i3s-converter → esm/i3s-converter}/json-templates/store.js +2 -2
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -0
- package/dist/{i3s-server → esm/i3s-server}/app.js +0 -0
- package/dist/esm/i3s-server/app.js.map +1 -0
- package/dist/esm/i3s-server/bin/www +102 -0
- package/dist/esm/i3s-server/certs/cert.pem +19 -0
- package/dist/esm/i3s-server/certs/key.pem +27 -0
- package/dist/{i3s-server → esm/i3s-server}/controllers/index-controller.js +2 -2
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -0
- package/dist/{i3s-server → esm/i3s-server}/routes/index.js +0 -0
- package/dist/esm/i3s-server/routes/index.js.map +1 -0
- package/dist/{index.js → esm/index.js} +0 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/geoid-height-model.d.ts +41 -0
- package/dist/{lib → esm/lib}/geoid-height-model.js +0 -0
- package/dist/esm/lib/geoid-height-model.js.map +1 -0
- package/dist/esm/lib/pgm-parser.d.ts +14 -0
- package/dist/{lib → esm/lib}/pgm-parser.js +0 -0
- package/dist/esm/lib/pgm-parser.js.map +1 -0
- package/dist/{lib → esm/lib}/utils/compress-util.js +13 -13
- package/dist/esm/lib/utils/compress-util.js.map +1 -0
- package/dist/esm/lib/utils/compress-utils.d.ts +53 -0
- package/dist/esm/lib/utils/file-utils.d.ts +43 -0
- package/dist/{lib → esm/lib}/utils/file-utils.js +1 -1
- package/dist/esm/lib/utils/file-utils.js.map +1 -0
- package/dist/esm/lib/utils/lod-conversion-utils.d.ts +32 -0
- package/dist/{lib → esm/lib}/utils/lod-conversion-utils.js +0 -0
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -0
- package/dist/esm/lib/utils/statistic-utills.d.ts +25 -0
- package/dist/{lib → esm/lib}/utils/statistic-utills.js +5 -5
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -0
- package/dist/{pgm-loader.js → esm/pgm-loader.js} +1 -1
- package/dist/esm/pgm-loader.js.map +1 -0
- package/package.json +24 -21
- package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -2
- package/src/3d-tiles-converter/helpers/b3dm-converter.js +35 -7
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +55 -0
- package/src/i3s-converter/helpers/geometry-converter.js +21 -22
- package/src/i3s-converter/i3s-converter.ts +32 -7
- package/src/i3s-converter/json-templates/metadata.js +1 -1
- package/src/i3s-converter/json-templates/scene-server.js +1 -1
- package/src/i3s-converter/json-templates/store.js +2 -2
- package/src/i3s-server/controllers/index-controller.js +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
- package/dist/bundle.js.map +0 -1
- package/dist/deps-installer/deps-installer.js.map +0 -1
- package/dist/dist.min.js +0 -94
- package/dist/dist.min.js.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
- package/dist/i3s-converter/i3s-converter.js.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
- package/dist/i3s-converter/json-templates/node.js.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
- package/dist/i3s-converter/json-templates/store.js.map +0 -1
- package/dist/i3s-server/app.js.map +0 -1
- package/dist/i3s-server/controllers/index-controller.js.map +0 -1
- package/dist/i3s-server/routes/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/geoid-height-model.js.map +0 -1
- package/dist/lib/pgm-parser.js.map +0 -1
- package/dist/lib/utils/compress-util.js.map +0 -1
- package/dist/lib/utils/file-utils.js.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
- package/dist/lib/utils/statistic-utills.js.map +0 -1
- package/dist/pgm-loader.js.map +0 -1
- package/dist/scripts/converter.js +0 -274
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertTextureAtlas = convertTextureAtlas;
|
|
7
|
+
|
|
8
|
+
function convertTextureAtlas(texCoords, uvRegions) {
|
|
9
|
+
const convertedTexCoords = new Float32Array(texCoords.length);
|
|
10
|
+
const normalisedRegions = normalizeRegions(uvRegions);
|
|
11
|
+
|
|
12
|
+
for (let index = 0; index < texCoords.length; index += 2) {
|
|
13
|
+
const uv = texCoords.subarray(index, index + 2);
|
|
14
|
+
const regions = normalisedRegions.slice(index * 2, index * 2 + 4);
|
|
15
|
+
const fractatedUV = fract(uv);
|
|
16
|
+
const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];
|
|
17
|
+
const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];
|
|
18
|
+
const convertedUV = [multiplicationResult[0] + regions[0], multiplicationResult[1] + regions[1]];
|
|
19
|
+
convertedTexCoords[index] = convertedUV[0];
|
|
20
|
+
convertedTexCoords[index + 1] = convertedUV[1];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return convertedTexCoords;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function fract(uv) {
|
|
27
|
+
return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function normalizeRegions(regions) {
|
|
31
|
+
const MAX_UINT_16_VALUE = 65535;
|
|
32
|
+
const normalizedRegions = [];
|
|
33
|
+
|
|
34
|
+
for (let index = 0; index < regions.length; index++) {
|
|
35
|
+
normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return normalizedRegions;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=texture-atlas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/3d-tiles-converter/helpers/texture-atlas.ts"],"names":["convertTextureAtlas","texCoords","uvRegions","convertedTexCoords","Float32Array","length","normalisedRegions","normalizeRegions","index","uv","subarray","regions","slice","fractatedUV","fract","subtracted","multiplicationResult","convertedUV","Math","floor","MAX_UINT_16_VALUE","normalizedRegions"],"mappings":";;;;;;;AAOO,SAASA,mBAAT,CAA6BC,SAA7B,EAAsDC,SAAtD,EAA4F;AACjG,QAAMC,kBAAkB,GAAG,IAAIC,YAAJ,CAAiBH,SAAS,CAACI,MAA3B,CAA3B;AACA,QAAMC,iBAAiB,GAAGC,gBAAgB,CAACL,SAAD,CAA1C;;AAEA,OAAK,IAAIM,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGP,SAAS,CAACI,MAAtC,EAA8CG,KAAK,IAAI,CAAvD,EAA0D;AACxD,UAAMC,EAAE,GAAGR,SAAS,CAACS,QAAV,CAAmBF,KAAnB,EAA0BA,KAAK,GAAG,CAAlC,CAAX;AACA,UAAMG,OAAO,GA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B,EAAoBA,KAAK,GAAGG,OAAO,CAACN,MAApC,EAA4CG,KAAK,EAAjD,EAAqD;AACnDa,IAAAA,iBAAiB,CAACb,KAAD,CAAjB,GAA2BG,OAAO,CAACH,KAAD,CAAP,GAAiBY,iBAA5C;AACD;;AAED,SAAOC,iBAAP;AACD","sourcesContent":["/**\n * Apply uvRegions to texture coordinates.\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md\n * Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n * @param texCoords\n * @param uvRegions\n */\nexport function convertTextureAtlas(texCoords: Float32Array, uvRegions: Uint16Array): Float32Array {\n const convertedTexCoords = new Float32Array(texCoords.length);\n const normalisedRegions = normalizeRegions(uvRegions);\n\n for (let index = 0; index < texCoords.length; index += 2) {\n const uv = texCoords.subarray(index, index + 2);\n const regions = normalisedRegions.slice(index * 2, index * 2 + 4);\n // fract(texCoords)\n const fractatedUV = fract(uv);\n // (uvRegions.zw - uvRegions.xy)\n const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];\n // fract(texCoords) * (uvRegions.zw - uvRegions.xy)\n const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];\n // fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n const convertedUV = [\n multiplicationResult[0] + regions[0],\n multiplicationResult[1] + regions[1]\n ];\n\n convertedTexCoords[index] = convertedUV[0];\n convertedTexCoords[index + 1] = convertedUV[1];\n }\n\n return convertedTexCoords;\n}\n\n/**\n * Do fractation of UV array.\n * @param uv\n */\nfunction fract(uv: number[2]): number[2] {\n return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];\n}\n\n/**\n * Normalize uvRegions by dividing by the maximum Uint16 value\n * @param regions\n */\nfunction normalizeRegions(regions: Uint16Array): number[4] {\n const MAX_UINT_16_VALUE = 65535;\n const normalizedRegions = [];\n\n for (let index = 0; index < regions.length; index++) {\n normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;\n }\n\n return normalizedRegions;\n}\n"],"file":"texture-atlas.js"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.TILESET = void 0;
|
|
9
|
+
|
|
10
|
+
var _jsonMapTransform = _interopRequireDefault(require("json-map-transform"));
|
|
11
|
+
|
|
12
|
+
const ASSET = {
|
|
13
|
+
version: {
|
|
14
|
+
path: 'version',
|
|
15
|
+
default: '1.0'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const TILE = {
|
|
19
|
+
boundingVolume: {
|
|
20
|
+
path: 'boundingVolume'
|
|
21
|
+
},
|
|
22
|
+
geometricError: {
|
|
23
|
+
path: 'geometricError'
|
|
24
|
+
},
|
|
25
|
+
content: {
|
|
26
|
+
path: 'content'
|
|
27
|
+
},
|
|
28
|
+
children: {
|
|
29
|
+
path: 'children',
|
|
30
|
+
transform: val => val.map(tile => (0, _jsonMapTransform.default)(tile, TILE))
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const TILESET = {
|
|
34
|
+
asset: {
|
|
35
|
+
path: 'asset',
|
|
36
|
+
transform: val => (0, _jsonMapTransform.default)(val, ASSET)
|
|
37
|
+
},
|
|
38
|
+
geometricError: {
|
|
39
|
+
path: 'root',
|
|
40
|
+
transform: val => val.geometricError
|
|
41
|
+
},
|
|
42
|
+
root: {
|
|
43
|
+
path: 'root',
|
|
44
|
+
transform: val => (0, _jsonMapTransform.default)(val, TILE)
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.TILESET = TILESET;
|
|
48
|
+
//# sourceMappingURL=tileset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/3d-tiles-converter/json-templates/tileset.js"],"names":["ASSET","version","path","default","TILE","boundingVolume","geometricError","content","children","transform","val","map","tile","TILESET","asset","root"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAMA,KAAK,GAAG;AACZC,EAAAA,OAAO,EAAE;AACPC,IAAAA,IAAI,EAAE,SADC;AAEPC,IAAAA,OAAO,EAAE;AAFF;AADG,CAAd;AAOA,MAAMC,IAAI,GAAG;AACXC,EAAAA,cAAc,EAAE;AACdH,IAAAA,IAAI,EAAE;AADQ,GADL;AAIXI,EAAAA,cAAc,EAAE;AACdJ,IAAAA,IAAI,EAAE;AADQ,GAJL;AAOXK,EAAAA,OAAO,EAAE;AACPL,IAAAA,IAAI,EAAE;AADC,GAPE;AAUXM,EAAAA,QAAQ,EAAE;AACRN,IAAAA,IAAI,EAAE,UADE;AAERO,IAAAA,SAAS,EAAGC,GAAD,IAASA,GAAG,CAACC,GAAJ,CAASC,IAAD,IAAU,+BAAUA,IAAV,EAAgBR,IAAhB,CAAlB;AAFZ;AAVC,CAAb;AAgBO,MAAMS,OAAO,GAAG;AACrBC,EAAAA,KAAK,EAAE;AACLZ,IAAAA,IAAI,EAAE,OADD;AAELO,IAAAA,SAAS,EAAGC,GAAD,IAAS,+BAAUA,GAAV,EAAeV,KAAf;AAFf,GADc;AAKrBM,EAAAA,cAAc,EAAE;AACdJ,IAAAA,IAAI,EAAE,MADQ;AAEdO,IAAAA,SAAS,EAAGC,GAAD,IAASA,GAAG,CAACJ;AAFV,GALK;AASrBS,EAAAA,IAAI,EAAE;AACJb,IAAAA,IAAI,EAAE,MADF;AAEJO,IAAAA,SAAS,EAAGC,GAAD,IAAS,+BAAUA,GAAV,EAAeN,IAAf;AAFhB;AATe,CAAhB","sourcesContent":["import transform from 'json-map-transform';\n\nconst ASSET = {\n version: {\n path: 'version',\n default: '1.0'\n }\n};\n\nconst TILE = {\n boundingVolume: {\n path: 'boundingVolume'\n },\n geometricError: {\n path: 'geometricError'\n },\n content: {\n path: 'content'\n },\n children: {\n path: 'children',\n transform: (val) => val.map((tile) => transform(tile, TILE))\n }\n};\n\nexport const TILESET = {\n asset: {\n path: 'asset',\n transform: (val) => transform(val, ASSET)\n },\n geometricError: {\n path: 'root',\n transform: (val) => val.geometricError\n },\n root: {\n path: 'root',\n transform: (val) => transform(val, TILE)\n }\n};\n"],"file":"tileset.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DepsInstaller = void 0;
|
|
7
|
+
|
|
8
|
+
var _core = require("@loaders.gl/core");
|
|
9
|
+
|
|
10
|
+
var _zip = require("@loaders.gl/zip");
|
|
11
|
+
|
|
12
|
+
var _fileUtils = require("../lib/utils/file-utils");
|
|
13
|
+
|
|
14
|
+
var _path = require("path");
|
|
15
|
+
|
|
16
|
+
const PGM_LINK = 'https://github.com/visgl/deck.gl-data/raw/master/egm/egm2008-5.zip';
|
|
17
|
+
|
|
18
|
+
class DepsInstaller {
|
|
19
|
+
async install(path = '') {
|
|
20
|
+
console.log('Installing "EGM2008-5" model...');
|
|
21
|
+
const fileMap = await (0, _core.load)(PGM_LINK, _zip.ZipLoader, {
|
|
22
|
+
fetch: {
|
|
23
|
+
followRedirect: true
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
let depsPath = process.cwd();
|
|
27
|
+
|
|
28
|
+
if (path) {
|
|
29
|
+
depsPath = (0, _path.join)(depsPath, path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await (0, _fileUtils.writeFile)(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
|
|
33
|
+
console.log('All dependencies were installed succesfully.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.DepsInstaller = DepsInstaller;
|
|
39
|
+
//# sourceMappingURL=deps-installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/deps-installer/deps-installer.js"],"names":["PGM_LINK","DepsInstaller","install","path","console","log","fileMap","ZipLoader","fetch","followRedirect","depsPath","process","cwd","Uint8Array"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,oEAAjB;;AAEO,MAAMC,aAAN,CAAoB;AACZ,QAAPC,OAAO,CAACC,IAAI,GAAG,EAAR,EAAY;AACvBC,IAAAA,OAAO,CAACC,GAAR,CAAY,iCAAZ;AACA,UAAMC,OAAO,GAAG,MAAM,gBAAKN,QAAL,EAAeO,cAAf,EAA0B;AAACC,MAAAA,KAAK,EAAE;AAACC,QAAAA,cAAc,EAAE;AAAjB;AAAR,KAA1B,CAAtB;AAEA,QAAIC,QAAQ,GAAGC,OAAO,CAACC,GAAR,EAAf;;AACA,QAAIT,IAAJ,EAAU;AACRO,MAAAA,QAAQ,GAAG,gBAAKA,QAAL,EAAeP,IAAf,CAAX;AACD;;AAED,UAAM,0BAAUO,QAAV,EAAoB,IAAIG,UAAJ,CAAeP,OAAO,CAAC,sBAAD,CAAtB,CAApB,EAAqE,eAArE,CAAN;AAEAF,IAAAA,OAAO,CAACC,GAAR,CAAY,8CAAZ;AACD;;AAbwB","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {ZipLoader} from '@loaders.gl/zip';\nimport {writeFile} from '../lib/utils/file-utils';\nimport {join} from 'path';\n\nconst PGM_LINK = 'https://github.com/visgl/deck.gl-data/raw/master/egm/egm2008-5.zip';\n\nexport class DepsInstaller {\n async install(path = '') {\n console.log('Installing \"EGM2008-5\" model...'); // eslint-disable-line no-console\n const fileMap = await load(PGM_LINK, ZipLoader, {fetch: {followRedirect: true}});\n\n let depsPath = process.cwd();\n if (path) {\n depsPath = join(depsPath, path);\n }\n\n await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n}\n"],"file":"deps-installer.js"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBoundingVolumes = createBoundingVolumes;
|
|
7
|
+
exports.convertCommonToI3SExtentCoordinate = convertCommonToI3SExtentCoordinate;
|
|
8
|
+
exports.createObbFromMbs = createObbFromMbs;
|
|
9
|
+
|
|
10
|
+
var _core = require("@math.gl/core");
|
|
11
|
+
|
|
12
|
+
var _geospatial = require("@math.gl/geospatial");
|
|
13
|
+
|
|
14
|
+
var _culling = require("@math.gl/culling");
|
|
15
|
+
|
|
16
|
+
function createBoundingVolumes(tile, geoidHeightModel) {
|
|
17
|
+
let radius;
|
|
18
|
+
let halfSize;
|
|
19
|
+
let quaternion;
|
|
20
|
+
const boundingVolume = tile.boundingVolume;
|
|
21
|
+
|
|
22
|
+
const cartographicCenter = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new _core.Vector3());
|
|
23
|
+
|
|
24
|
+
cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
|
|
25
|
+
|
|
26
|
+
if (boundingVolume instanceof _culling.OrientedBoundingBox) {
|
|
27
|
+
halfSize = boundingVolume.halfSize;
|
|
28
|
+
radius = new _core.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
|
|
29
|
+
quaternion = boundingVolume.quaternion;
|
|
30
|
+
} else {
|
|
31
|
+
radius = tile.boundingVolume.radius;
|
|
32
|
+
halfSize = [radius, radius, radius];
|
|
33
|
+
quaternion = new _core.Quaternion().fromMatrix3(new _core.Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]])).normalize();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],
|
|
38
|
+
obb: {
|
|
39
|
+
center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],
|
|
40
|
+
halfSize,
|
|
41
|
+
quaternion
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function convertCommonToI3SExtentCoordinate(tileset) {
|
|
47
|
+
const cartesianCenter = tileset.cartesianCenter;
|
|
48
|
+
const radius = tileset.lodMetricValue;
|
|
49
|
+
|
|
50
|
+
const rightTop = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(new _core.Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]), new _core.Vector3());
|
|
51
|
+
|
|
52
|
+
const leftBottom = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(new _core.Vector3(cartesianCenter[0] - radius, cartesianCenter[1] - radius, cartesianCenter[2]), new _core.Vector3());
|
|
53
|
+
|
|
54
|
+
const isFirstRight = rightTop[0] < leftBottom[0];
|
|
55
|
+
const isFirstTop = rightTop[1] < leftBottom[1];
|
|
56
|
+
return [isFirstRight ? rightTop[0] : leftBottom[0], isFirstTop ? rightTop[1] : leftBottom[1], isFirstRight ? leftBottom[0] : rightTop[0], isFirstTop ? leftBottom[1] : rightTop[1]];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function createObbFromMbs(mbs) {
|
|
60
|
+
const radius = mbs[3];
|
|
61
|
+
const center = new _core.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
62
|
+
const halfAxex = new _core.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
|
|
63
|
+
return new _culling.OrientedBoundingBox(center, halfAxex);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=coordinate-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":["createBoundingVolumes","tile","geoidHeightModel","radius","halfSize","quaternion","boundingVolume","cartographicCenter","Ellipsoid","WGS84","cartesianToCartographic","center","Vector3","getHeight","OrientedBoundingBox","len","Quaternion","fromMatrix3","Matrix3","normalize","mbs","obb","convertCommonToI3SExtentCoordinate","tileset","cartesianCenter","lodMetricValue","rightTop","leftBottom","isFirstRight","isFirstTop","createObbFromMbs","halfAxex"],"mappings":";;;;;;;;;AAEA;;AACA;;AACA;;AAWO,SAASA,qBAAT,CACLC,IADK,EAELC,gBAFK,EAGY;AACjB,MAAIC,MAAJ;AACA,MAAIC,QAAJ;AACA,MAAIC,UAAJ;AAEA,QAAMC,cAAc,GAAGL,IAAI,CAACK,cAA5B;;AACA,QAAMC,kBAAkB,GAAGC,sBAAUC,KAAV,CAAgBC,uBAAhB,CACzBJ,cAAc,CAACK,MADU,EAEzB,IAAIC,aAAJ,EAFyB,CAA3B;;AAIAL,EAAAA,kBAAkB,CAAC,CAAD,CAAlB,GACEA,kBAAkB,CAAC,CAAD,CAAlB,GACAL,gBAAgB,CAACW,SAAjB,CAA2BN,kBAAkB,CAAC,CAAD,CAA7C,EAAkDA,kBAAkB,CAAC,CAAD,CAApE,CAFF;;AAGA,MAAID,cAAc,YAAYQ,4BAA9B,E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,CAAC,CAAD,CAA/B,CAAf;AACA,QAAMW,QAAQ,GAAG,IAAIb,aAAJ,CAAY,CAACf,MAAD,EAAS,CAAT,EAAY,CAAZ,EAAe,CAAf,EAAkBA,MAAlB,EAA0B,CAA1B,EAA6B,CAA7B,EAAgC,CAAhC,EAAmCA,MAAnC,CAAZ,CAAjB;AACA,SAAO,IAAIW,4BAAJ,CAAwBH,MAAxB,EAAgCoB,QAAhC,CAAP;AACD","sourcesContent":["import type {BoundingVolumes, Extent, Mbs, Obb} from '@loaders.gl/i3s';\n\nimport {Matrix3, Quaternion, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {OrientedBoundingBox} from '@math.gl/culling';\nimport TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';\nimport {GeoidHeightModel} from '../../lib/geoid-height-model';\nimport {Tileset3D} from '@loaders.gl/tiles';\n\n/**\n * Create bounding volumes object from tile and geoid height model.\n * @param tile\n * @param geoidHeightModel\n * @returns - Bounding volumes object\n */\nexport function createBoundingVolumes(\n tile: TileHeader,\n geoidHeightModel: GeoidHeightModel\n): BoundingVolumes {\n let radius;\n let halfSize;\n let quaternion;\n\n const boundingVolume = tile.boundingVolume;\n const cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(\n boundingVolume.center,\n new Vector3()\n );\n cartographicCenter[2] =\n cartographicCenter[2] -\n geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);\n if (boundingVolume instanceof OrientedBoundingBox) {\n halfSize = boundingVolume.halfSize;\n radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();\n quaternion = boundingVolume.quaternion;\n } else {\n radius = tile.boundingVolume.radius;\n halfSize = [radius, radius, radius];\n quaternion = new Quaternion()\n .fromMatrix3(new Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))\n .normalize();\n }\n\n return {\n mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],\n obb: {\n center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],\n halfSize,\n quaternion\n }\n };\n}\n\n/**\n * Convert common coordinate to extent coordinate\n * @param tileset\n * @returns - Extent\n */\nexport function convertCommonToI3SExtentCoordinate(tileset: Tileset3D): Extent {\n const cartesianCenter = tileset.cartesianCenter;\n const radius = tileset.lodMetricValue;\n const rightTop = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]),\n new Vector3()\n );\n const leftBottom = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(cartesianCenter[0] - radius, cartesianCenter[1] - radius, cartesianCenter[2]),\n new Vector3()\n );\n const isFirstRight = rightTop[0] < leftBottom[0];\n const isFirstTop = rightTop[1] < leftBottom[1];\n\n return [\n isFirstRight ? rightTop[0] : leftBottom[0],\n isFirstTop ? rightTop[1] : leftBottom[1],\n isFirstRight ? leftBottom[0] : rightTop[0],\n isFirstTop ? leftBottom[1] : rightTop[1]\n ];\n}\n\n/**\n * Creates oriented boundinb box from mbs.\n * @param mbs - Minimum Bounding Sphere\n * @returns - Oriented BOunding Box\n */\nexport function createObbFromMbs(mbs: Mbs): Obb {\n const radius = mbs[3];\n const center = new Vector3(mbs[0], mbs[1], mbs[2]);\n const halfAxex = new Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);\n return new OrientedBoundingBox(center, halfAxex);\n}\n"],"file":"coordinate-converter.js"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createSceneServerPath = createSceneServerPath;
|
|
9
|
+
|
|
10
|
+
var _uuid = require("uuid");
|
|
11
|
+
|
|
12
|
+
var _jsonMapTransform = _interopRequireDefault(require("json-map-transform"));
|
|
13
|
+
|
|
14
|
+
var _path = require("path");
|
|
15
|
+
|
|
16
|
+
var _sceneServer = require("../json-templates/scene-server");
|
|
17
|
+
|
|
18
|
+
var _fileUtils = require("../../lib/utils/file-utils");
|
|
19
|
+
|
|
20
|
+
async function createSceneServerPath(layerName, layers0, rootPath) {
|
|
21
|
+
const sceneServerData = {
|
|
22
|
+
serviceItemId: (0, _uuid.v4)().replace(/-/gi, ''),
|
|
23
|
+
layerName,
|
|
24
|
+
layers0
|
|
25
|
+
};
|
|
26
|
+
const sceneServer = (0, _jsonMapTransform.default)(sceneServerData, _sceneServer.SCENE_SERVER_TEMPLATE);
|
|
27
|
+
const nodePagePath = (0, _path.join)(rootPath, 'SceneServer');
|
|
28
|
+
await (0, _fileUtils.writeFile)(nodePagePath, JSON.stringify(sceneServer));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=create-scene-server-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.js"],"names":["createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","SCENE_SERVER_TEMPLATE","nodePagePath","JSON","stringify"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AASO,eAAeA,qBAAf,CAAqCC,SAArC,EAAgDC,OAAhD,EAAyDC,QAAzD,EAAmE;AACxE,QAAMC,eAAe,GAAG;AACtBC,IAAAA,aAAa,EAAE,gBAASC,OAAT,CAAiB,KAAjB,EAAwB,EAAxB,CADO;AAEtBL,IAAAA,SAFsB;AAGtBC,IAAAA;AAHsB,GAAxB;AAMA,QAAMK,WAAW,GAAG,+BAAUH,eAAV,EAA2BI,kCAA3B,CAApB;AACA,QAAMC,YAAY,GAAG,gBAAKN,QAAL,EAAe,aAAf,CAArB;AACA,QAAM,0BAAUM,YAAV,EAAwBC,IAAI,CAACC,SAAL,CAAeJ,WAAf,CAAxB,CAAN;AACD","sourcesContent":["import {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER_TEMPLATE} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param {string} layerName - layer name to display\n * @param {object} layers0 - layer object embedded into sceneServer meta data\n * @param {string} rootPath - root path of new converted tileset\n * @return {promise}\n */\nexport async function createSceneServerPath(layerName, layers0, rootPath) {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, SCENE_SERVER_TEMPLATE);\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"file":"create-scene-server-path.js"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateAttributes = generateAttributes;
|
|
7
|
+
|
|
8
|
+
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
9
|
+
|
|
10
|
+
const VALUES_PER_VERTEX = 3;
|
|
11
|
+
const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
12
|
+
|
|
13
|
+
function generateAttributes(attributes) {
|
|
14
|
+
const {
|
|
15
|
+
positions,
|
|
16
|
+
normals,
|
|
17
|
+
texCoords,
|
|
18
|
+
colors,
|
|
19
|
+
featureIndices,
|
|
20
|
+
triangleCount
|
|
21
|
+
} = attributes;
|
|
22
|
+
|
|
23
|
+
if (!featureIndices.length) {
|
|
24
|
+
return {
|
|
25
|
+
faceRange: new Uint32Array([0, triangleCount - 1]),
|
|
26
|
+
featureIds: [0],
|
|
27
|
+
featureCount: 1,
|
|
28
|
+
positions,
|
|
29
|
+
normals,
|
|
30
|
+
texCoords,
|
|
31
|
+
colors
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
faceRange,
|
|
37
|
+
featureCount,
|
|
38
|
+
featureIds
|
|
39
|
+
} = calculateFaceRangesAndFeaturesCount(featureIndices);
|
|
40
|
+
const attributeObjects = makeAttributeObjects({
|
|
41
|
+
faceRange,
|
|
42
|
+
featureIds,
|
|
43
|
+
...attributes
|
|
44
|
+
});
|
|
45
|
+
const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
|
|
46
|
+
const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds);
|
|
47
|
+
return {
|
|
48
|
+
featureCount,
|
|
49
|
+
...groupedAttributes
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function calculateFaceRangesAndFeaturesCount(featureIndices) {
|
|
54
|
+
let rangeIndex = 1;
|
|
55
|
+
let featureIndex = 1;
|
|
56
|
+
let currentFeatureId = featureIndices[0];
|
|
57
|
+
const faceRangeList = [];
|
|
58
|
+
const featureIds = [];
|
|
59
|
+
const uniqueFeatureIds = [currentFeatureId];
|
|
60
|
+
faceRangeList[0] = 0;
|
|
61
|
+
featureIds[0] = currentFeatureId;
|
|
62
|
+
|
|
63
|
+
for (let index = 1; index < featureIndices.length; index++) {
|
|
64
|
+
if (currentFeatureId !== featureIndices[index]) {
|
|
65
|
+
faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
|
|
66
|
+
faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
|
|
67
|
+
featureIds[featureIndex] = featureIndices[index];
|
|
68
|
+
|
|
69
|
+
if (!uniqueFeatureIds.includes(featureIndices[index])) {
|
|
70
|
+
uniqueFeatureIds.push(featureIndices[index]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
rangeIndex += 2;
|
|
74
|
+
featureIndex += 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
currentFeatureId = featureIndices[index];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
|
|
81
|
+
const faceRange = new Uint32Array(faceRangeList);
|
|
82
|
+
const featureCount = uniqueFeatureIds.length;
|
|
83
|
+
return {
|
|
84
|
+
faceRange,
|
|
85
|
+
featureCount,
|
|
86
|
+
featureIds
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function makeAttributeObjects(attributes) {
|
|
91
|
+
const {
|
|
92
|
+
featureIds,
|
|
93
|
+
positions,
|
|
94
|
+
normals,
|
|
95
|
+
colors,
|
|
96
|
+
texCoords,
|
|
97
|
+
faceRange
|
|
98
|
+
} = attributes;
|
|
99
|
+
const groupedData = [];
|
|
100
|
+
let positionsList = new Float32Array(positions);
|
|
101
|
+
let normalsList = new Float32Array(normals);
|
|
102
|
+
let colorsList = new Uint8Array(colors);
|
|
103
|
+
let texCoordsList = new Float32Array(texCoords);
|
|
104
|
+
let faceRangeIndex = 0;
|
|
105
|
+
|
|
106
|
+
for (let index = 0; index < featureIds.length; index++) {
|
|
107
|
+
const startIndex = faceRange[index + faceRangeIndex];
|
|
108
|
+
const endIndex = faceRange[index + faceRangeIndex + 1];
|
|
109
|
+
const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
|
|
110
|
+
const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
|
|
111
|
+
const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
|
|
112
|
+
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
113
|
+
groupedData.push({
|
|
114
|
+
featureId: featureIds[index],
|
|
115
|
+
positions: positionsList.slice(0, positionsCount),
|
|
116
|
+
normals: normalsList.slice(0, normalsCount),
|
|
117
|
+
colors: colorsList.slice(0, colorsCount),
|
|
118
|
+
texCoords: texCoordsList.slice(0, texCoordsCount)
|
|
119
|
+
});
|
|
120
|
+
positionsList = positionsList.slice(positionsCount);
|
|
121
|
+
normalsList = normalsList.slice(normalsCount);
|
|
122
|
+
colorsList = colorsList.slice(colorsCount);
|
|
123
|
+
texCoordsList = texCoordsList.slice(texCoordsCount);
|
|
124
|
+
faceRangeIndex += 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return groupedData.sort((first, second) => first.featureId - second.featureId);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
131
|
+
const colorsPerVertex = 4;
|
|
132
|
+
const texCoordsPerVertex = 2;
|
|
133
|
+
const trianglesCount = endIndex - startIndex + 1;
|
|
134
|
+
const vertexCount = trianglesCount * 3;
|
|
135
|
+
|
|
136
|
+
switch (attributeName) {
|
|
137
|
+
case 'positions':
|
|
138
|
+
case 'normals':
|
|
139
|
+
return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
140
|
+
|
|
141
|
+
case 'colors':
|
|
142
|
+
return vertexCount * colorsPerVertex;
|
|
143
|
+
|
|
144
|
+
case 'texCoords':
|
|
145
|
+
return vertexCount * texCoordsPerVertex;
|
|
146
|
+
|
|
147
|
+
default:
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function unifyObjectsByFeatureId(sortedData) {
|
|
153
|
+
const uniqueObjects = [];
|
|
154
|
+
|
|
155
|
+
for (let index = 0; index < sortedData.length; index++) {
|
|
156
|
+
const currentObject = sortedData[index];
|
|
157
|
+
const existedObject = uniqueObjects.find(obj => obj.featureId === currentObject.featureId);
|
|
158
|
+
|
|
159
|
+
if (existedObject) {
|
|
160
|
+
existedObject.positions = (0, _loaderUtils.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
|
|
161
|
+
existedObject.normals = (0, _loaderUtils.concatenateTypedArrays)(existedObject.normals, currentObject.normals);
|
|
162
|
+
existedObject.colors = (0, _loaderUtils.concatenateTypedArrays)(existedObject.colors, currentObject.colors);
|
|
163
|
+
existedObject.texCoords = (0, _loaderUtils.concatenateTypedArrays)(existedObject.texCoords, currentObject.texCoords);
|
|
164
|
+
} else {
|
|
165
|
+
uniqueObjects.push(currentObject);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return uniqueObjects;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function groupAttributesAndRangesByFeatureId(unifiedObjects) {
|
|
173
|
+
const firstAttributeObject = unifiedObjects[0];
|
|
174
|
+
const featureIds = [firstAttributeObject.featureId];
|
|
175
|
+
let positions = new Float32Array(firstAttributeObject.positions);
|
|
176
|
+
let normals = new Float32Array(firstAttributeObject.normals);
|
|
177
|
+
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
178
|
+
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
179
|
+
const range = [0];
|
|
180
|
+
let objIndex = 0;
|
|
181
|
+
let sum = 0;
|
|
182
|
+
|
|
183
|
+
for (let index = 1; index < unifiedObjects.length; index++) {
|
|
184
|
+
const currentAttributesObject = unifiedObjects[index];
|
|
185
|
+
featureIds.push(currentAttributesObject.featureId);
|
|
186
|
+
positions = (0, _loaderUtils.concatenateTypedArrays)(positions, currentAttributesObject.positions);
|
|
187
|
+
normals = (0, _loaderUtils.concatenateTypedArrays)(normals, currentAttributesObject.normals);
|
|
188
|
+
colors = (0, _loaderUtils.concatenateTypedArrays)(colors, currentAttributesObject.colors);
|
|
189
|
+
texCoords = (0, _loaderUtils.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
|
|
190
|
+
const groupedObject = unifiedObjects[objIndex];
|
|
191
|
+
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
192
|
+
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
|
|
193
|
+
sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
194
|
+
objIndex += 1;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
198
|
+
const faceRange = new Uint32Array(range);
|
|
199
|
+
return {
|
|
200
|
+
faceRange,
|
|
201
|
+
featureIds,
|
|
202
|
+
positions,
|
|
203
|
+
normals,
|
|
204
|
+
colors,
|
|
205
|
+
texCoords
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=geometry-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.js"],"names":["VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","faceRangeList","uniqueFeatureIds","index","includes","push","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","slice","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"mappings":";;;;;;;AAAA;;AAEA,MAAMA,iBAAiB,GAAG,CAA1B;AACA,MAAMC,kCAAkC,GAAG,CAA3C;;AAOO,SAASC,kBAAT,CAA4BC,UAA5B,EAAwC;AAC7C,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,OAAZ;AAAqBC,IAAAA,SAArB;AAAgCC,IAAAA,MAAhC;AAAwCC,IAAAA,cAAxC;AAAwDC,IAAAA;AAAxD,MAAyEN,UAA/E;;AAEA,MAAI,CAACK,cAA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const VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param {Object} attributes\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nexport function generateAttributes(attributes) {\n const {positions, normals, texCoords, colors, featureIndices, triangleCount} = attributes;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const {faceRange, featureCount, featureIds} = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({faceRange, featureIds, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds\n );\n return {featureCount, ...groupedAttributes};\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param {Object} featureIndices\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices) {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = featureIndices[0];\n const faceRangeList = [];\n const featureIds = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = 1; index < featureIndices.length; index++) {\n if (currentFeatureId !== featureIndices[index]) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = featureIndices[index];\n\n if (!uniqueFeatureIds.includes(featureIndices[index])) {\n uniqueFeatureIds.push(featureIndices[index]);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = featureIndices[index];\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param {Object} attributes\n * @returns {Array} sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes) {\n const {featureIds, positions, normals, colors, texCoords, faceRange} = attributes;\n const groupedData = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param {String} attributeName\n * @param {Number} startIndex\n * @param {Number} endIndex\n * @returns {Number} - sliced count\n */\nfunction getSliceAttributeCount(attributeName, startIndex, endIndex) {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param {Array} sortedData\n * @returns {Array} - unique list of objects\n */\nfunction unifyObjectsByFeatureId(sortedData) {\n const uniqueObjects = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param {Array} unifiedObjects\n * @returns {Object} - ugenerated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(unifiedObjects) {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords};\n}\n"],"file":"geometry-attributes.js"}
|
|
File without changes
|