@loaders.gl/tile-converter 4.3.0-alpha.3 → 4.3.0-alpha.4

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.
@@ -23,7 +23,13 @@ router.get('*', (req, res, next) => {
23
23
  async function routerCallback(req, res, next) {
24
24
  const file = await getFileByUrl(req.path.replace(/\/+$/, ''));
25
25
  if (file) {
26
- res.send(Buffer.from(file));
26
+ try {
27
+ const json = JSON.parse(textDecoder.decode(file));
28
+ res.send(json);
29
+ }
30
+ catch (e) {
31
+ res.send(Buffer.from(file));
32
+ }
27
33
  }
28
34
  else {
29
35
  res.status(404);
package/dist/index.cjs CHANGED
@@ -960,7 +960,9 @@ function createBoundingVolumes(sourceBoundingVolume, geoidHeightModel) {
960
960
  let halfSize;
961
961
  let quaternion;
962
962
  const cartographicCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(sourceBoundingVolume.center, new import_core2.Vector3());
963
- cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
963
+ if (geoidHeightModel) {
964
+ cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
965
+ }
964
966
  if (sourceBoundingVolume instanceof import_culling.OrientedBoundingBox) {
965
967
  halfSize = sourceBoundingVolume.halfSize;
966
968
  radius = new import_core2.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
@@ -985,8 +987,10 @@ function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel)
985
987
  const geometryMbs = (0, import_culling.makeBoundingSphereFromPoints)(positionVectors);
986
988
  const mbsCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core2.Vector3());
987
989
  const obbCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core2.Vector3());
988
- mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
989
- obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
990
+ if (geoidHeightModel) {
991
+ mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
992
+ obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
993
+ }
990
994
  return {
991
995
  mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],
992
996
  obb: {
@@ -1447,7 +1451,9 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
1447
1451
  for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX2) {
1448
1452
  const vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX2);
1449
1453
  import_geospatial3.Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
1450
- scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
1454
+ if (geoidHeightModel) {
1455
+ scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
1456
+ }
1451
1457
  scratchVector = scratchVector.subtract(cartographicOrigin);
1452
1458
  attributes.positions.set(scratchVector, index);
1453
1459
  }
@@ -2342,7 +2348,7 @@ function convertScreenThresholdToGeometricError(node) {
2342
2348
 
2343
2349
  // dist/pgm-loader.js
2344
2350
  var import_geoid = require("@math.gl/geoid");
2345
- var VERSION = true ? "4.3.0-alpha.2" : "latest";
2351
+ var VERSION = true ? "4.3.0-alpha.3" : "latest";
2346
2352
  var PGMLoader = {
2347
2353
  dataType: null,
2348
2354
  batchType: null,
@@ -4378,7 +4384,7 @@ var I3SConverter = class {
4378
4384
  return BROWSER_ERROR_MESSAGE;
4379
4385
  }
4380
4386
  this.conversionStartTime = import_process4.default.hrtime();
4381
- const { tilesetName, slpk, egmFilePath, inputUrl, validate, outputPath, draco = true, sevenZipExe, maxDepth, token, generateTextures, generateBoundingVolumes, instantNodeWriting = false, mergeMaterials: mergeMaterials2 = true, inquirer, metadataClass, analyze = false } = options;
4387
+ const { tilesetName, slpk, egmFilePath, inputUrl, validate, outputPath, draco = true, sevenZipExe, maxDepth, token, generateTextures, generateBoundingVolumes, instantNodeWriting = false, mergeMaterials: mergeMaterials2 = true, inquirer, metadataClass, analyze = false, noEgm = false } = options;
4382
4388
  this.options = {
4383
4389
  outputPath,
4384
4390
  tilesetName,
@@ -4402,9 +4408,13 @@ var I3SConverter = class {
4402
4408
  this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
4403
4409
  this.writeQueue = new WriteQueue(this.conversionDump);
4404
4410
  this.writeQueue.startListening();
4405
- console.log("Loading egm file...");
4406
- this.geoidHeightModel = await (0, import_core9.load)(egmFilePath, PGMLoader);
4407
- console.log("Loading egm file completed!");
4411
+ if (!noEgm) {
4412
+ console.log("--no-egm option selected, skip loading egm file");
4413
+ } else {
4414
+ console.log("Loading egm file...");
4415
+ this.geoidHeightModel = await (0, import_core9.load)(egmFilePath, PGMLoader);
4416
+ console.log("Loading egm file completed!");
4417
+ }
4408
4418
  if (slpk) {
4409
4419
  this.nodePages.useWriteFunction(writeFileForSlpk);
4410
4420
  }