@loaders.gl/tiles 3.1.0-beta.7 → 3.1.3

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.
Files changed (50) hide show
  1. package/dist/bundle.js +5 -8136
  2. package/dist/dist.min.js +8423 -0
  3. package/dist/es5/bundle.js +1 -1
  4. package/dist/es5/bundle.js.map +1 -1
  5. package/dist/es5/constants.js +6 -6
  6. package/dist/es5/constants.js.map +1 -1
  7. package/dist/es5/index.js +13 -13
  8. package/dist/es5/tileset/helpers/bounding-volume.js +37 -25
  9. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
  10. package/dist/es5/tileset/helpers/frame-state.js +25 -29
  11. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  12. package/dist/es5/tileset/helpers/i3s-lod.js +44 -42
  13. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  14. package/dist/es5/tileset/helpers/tiles-3d-lod.js +47 -51
  15. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
  16. package/dist/es5/tileset/helpers/transform-utils.js +11 -17
  17. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
  18. package/dist/es5/tileset/helpers/zoom.js +15 -17
  19. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  20. package/dist/es5/tileset/tile-3d.js +423 -328
  21. package/dist/es5/tileset/tile-3d.js.map +1 -1
  22. package/dist/es5/tileset/tileset-3d.js +563 -381
  23. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  24. package/dist/es5/tileset/tileset-cache.js +63 -50
  25. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  26. package/dist/es5/tileset/traversers/i3s-tile-manager.js +44 -32
  27. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
  28. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +143 -53
  29. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  30. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +62 -34
  31. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
  32. package/dist/es5/tileset/traversers/tileset-traverser.js +282 -209
  33. package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
  34. package/dist/es5/utils/doubly-linked-list-node.js +11 -11
  35. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  36. package/dist/es5/utils/doubly-linked-list.js +76 -64
  37. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  38. package/dist/es5/utils/managed-array.js +106 -86
  39. package/dist/es5/utils/managed-array.js.map +1 -1
  40. package/dist/esm/tileset/helpers/frame-state.js +1 -1
  41. package/dist/esm/tileset/helpers/frame-state.js.map +1 -1
  42. package/dist/esm/tileset/tile-3d.js +3 -0
  43. package/dist/esm/tileset/tile-3d.js.map +1 -1
  44. package/dist/tileset/helpers/frame-state.js +1 -1
  45. package/dist/tileset/tile-3d.d.ts +1 -0
  46. package/dist/tileset/tile-3d.d.ts.map +1 -1
  47. package/dist/tileset/tile-3d.js +1 -0
  48. package/package.json +7 -7
  49. package/src/tileset/helpers/frame-state.ts +1 -1
  50. package/src/tileset/tile-3d.ts +2 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const moduleExports = require('./index');
3
+ var moduleExports = require('./index');
4
4
 
5
5
  globalThis.loaders = globalThis.loaders || {};
6
6
  module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,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"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TILE3D_OPTIMIZATION_HINT = exports.LOD_METRIC_TYPE = exports.TILESET_TYPE = exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = void 0;
7
- const TILE_CONTENT_STATE = {
7
+ var TILE_CONTENT_STATE = {
8
8
  UNLOADED: 0,
9
9
  LOADING: 1,
10
10
  PROCESSING: 2,
@@ -13,29 +13,29 @@ const TILE_CONTENT_STATE = {
13
13
  FAILED: 5
14
14
  };
15
15
  exports.TILE_CONTENT_STATE = TILE_CONTENT_STATE;
16
- const TILE_REFINEMENT = {
16
+ var TILE_REFINEMENT = {
17
17
  ADD: 1,
18
18
  REPLACE: 2
19
19
  };
20
20
  exports.TILE_REFINEMENT = TILE_REFINEMENT;
21
- const TILE_TYPE = {
21
+ var TILE_TYPE = {
22
22
  EMPTY: 'empty',
23
23
  SCENEGRAPH: 'scenegraph',
24
24
  POINTCLOUD: 'pointcloud',
25
25
  MESH: 'mesh'
26
26
  };
27
27
  exports.TILE_TYPE = TILE_TYPE;
28
- const TILESET_TYPE = {
28
+ var TILESET_TYPE = {
29
29
  I3S: 'I3S',
30
30
  TILES3D: 'TILES3D'
31
31
  };
32
32
  exports.TILESET_TYPE = TILESET_TYPE;
33
- const LOD_METRIC_TYPE = {
33
+ var LOD_METRIC_TYPE = {
34
34
  GEOMETRIC_ERROR: 'geometricError',
35
35
  MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'
36
36
  };
37
37
  exports.LOD_METRIC_TYPE = LOD_METRIC_TYPE;
38
- const TILE3D_OPTIMIZATION_HINT = {
38
+ var TILE3D_OPTIMIZATION_HINT = {
39
39
  NOT_COMPUTED: -1,
40
40
  USE_OPTIMIZATION: 1,
41
41
  SKIP_OPTIMIZATION: 0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants.ts"],"names":["TILE_CONTENT_STATE","UNLOADED","LOADING","PROCESSING","READY","EXPIRED","FAILED","TILE_REFINEMENT","ADD","REPLACE","TILE_TYPE","EMPTY","SCENEGRAPH","POINTCLOUD","MESH","TILESET_TYPE","I3S","TILES3D","LOD_METRIC_TYPE","GEOMETRIC_ERROR","MAX_SCREEN_THRESHOLD","TILE3D_OPTIMIZATION_HINT","NOT_COMPUTED","USE_OPTIMIZATION","SKIP_OPTIMIZATION"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAG;AAChCC,EAAAA,QAAQ,EAAE,CADsB;AAEhCC,EAAAA,OAAO,EAAE,CAFuB;AAGhCC,EAAAA,UAAU,EAAE,CAHoB;AAIhCC,EAAAA,KAAK,EAAE,CAJyB;AAKhCC,EAAAA,OAAO,EAAE,CALuB;AAMhCC,EAAAA,MAAM,EAAE;AANwB,CAA3B;;AASA,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,GAAG,EAAE,CADwB;AAE7BC,EAAAA,OAAO,EAAE;AAFoB,CAAxB;;AAKA,MAAMC,SAAS,GAAG;AACvBC,EAAAA,KAAK,EAAE,OADgB;AAEvBC,EAAAA,UAAU,EAAE,YAFW;AAGvBC,EAAAA,UAAU,EAAE,YAHW;AAIvBC,EAAAA,IAAI,EAAE;AAJiB,CAAlB;;AAOA,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,GAAG,EAAE,KADqB;AAE1BC,EAAAA,OAAO,EAAE;AAFiB,CAArB;;AAKA,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,eAAe,EAAE,gBADY;AAE7BC,EAAAA,oBAAoB,EAAE;AAFO,CAAxB;;AAMA,MAAMC,wBAAwB,GAAG;AACtCC,EAAAA,YAAY,EAAE,CAAC,CADuB;AAEtCC,EAAAA,gBAAgB,EAAE,CAFoB;AAGtCC,EAAAA,iBAAiB,EAAE;AAHmB,CAAjC","sourcesContent":["export const TILE_CONTENT_STATE = {\n UNLOADED: 0, // Has never been requested\n LOADING: 1, // Is waiting on a pending request\n PROCESSING: 2, // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.\n READY: 3, // Ready to render.\n EXPIRED: 4, // Is expired and will be unloaded once new content is loaded.\n FAILED: 5 // Request failed.\n};\n\nexport const TILE_REFINEMENT = {\n ADD: 1, // Render tile and, if screen space error exceeded, also refine to its children.\n REPLACE: 2 // Render tile or, if screen space error exceeded, refine to its descendants instead.\n};\n\nexport const TILE_TYPE = {\n EMPTY: 'empty',\n SCENEGRAPH: 'scenegraph',\n POINTCLOUD: 'pointcloud',\n MESH: 'mesh'\n};\n\nexport const TILESET_TYPE = {\n I3S: 'I3S',\n TILES3D: 'TILES3D'\n};\n\nexport const LOD_METRIC_TYPE = {\n GEOMETRIC_ERROR: 'geometricError',\n MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'\n};\n\n// Cesium 3D Tiles Specific\nexport const TILE3D_OPTIMIZATION_HINT = {\n NOT_COMPUTED: -1,\n USE_OPTIMIZATION: 1,\n SKIP_OPTIMIZATION: 0\n};\n"],"file":"constants.js"}
1
+ {"version":3,"sources":["../../src/constants.ts"],"names":["TILE_CONTENT_STATE","UNLOADED","LOADING","PROCESSING","READY","EXPIRED","FAILED","TILE_REFINEMENT","ADD","REPLACE","TILE_TYPE","EMPTY","SCENEGRAPH","POINTCLOUD","MESH","TILESET_TYPE","I3S","TILES3D","LOD_METRIC_TYPE","GEOMETRIC_ERROR","MAX_SCREEN_THRESHOLD","TILE3D_OPTIMIZATION_HINT","NOT_COMPUTED","USE_OPTIMIZATION","SKIP_OPTIMIZATION"],"mappings":";;;;;;AAAO,IAAMA,kBAAkB,GAAG;AAChCC,EAAAA,QAAQ,EAAE,CADsB;AAEhCC,EAAAA,OAAO,EAAE,CAFuB;AAGhCC,EAAAA,UAAU,EAAE,CAHoB;AAIhCC,EAAAA,KAAK,EAAE,CAJyB;AAKhCC,EAAAA,OAAO,EAAE,CALuB;AAMhCC,EAAAA,MAAM,EAAE;AANwB,CAA3B;;AASA,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,GAAG,EAAE,CADwB;AAE7BC,EAAAA,OAAO,EAAE;AAFoB,CAAxB;;AAKA,IAAMC,SAAS,GAAG;AACvBC,EAAAA,KAAK,EAAE,OADgB;AAEvBC,EAAAA,UAAU,EAAE,YAFW;AAGvBC,EAAAA,UAAU,EAAE,YAHW;AAIvBC,EAAAA,IAAI,EAAE;AAJiB,CAAlB;;AAOA,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,GAAG,EAAE,KADqB;AAE1BC,EAAAA,OAAO,EAAE;AAFiB,CAArB;;AAKA,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,eAAe,EAAE,gBADY;AAE7BC,EAAAA,oBAAoB,EAAE;AAFO,CAAxB;;AAMA,IAAMC,wBAAwB,GAAG;AACtCC,EAAAA,YAAY,EAAE,CAAC,CADuB;AAEtCC,EAAAA,gBAAgB,EAAE,CAFoB;AAGtCC,EAAAA,iBAAiB,EAAE;AAHmB,CAAjC","sourcesContent":["export const TILE_CONTENT_STATE = {\n UNLOADED: 0, // Has never been requested\n LOADING: 1, // Is waiting on a pending request\n PROCESSING: 2, // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.\n READY: 3, // Ready to render.\n EXPIRED: 4, // Is expired and will be unloaded once new content is loaded.\n FAILED: 5 // Request failed.\n};\n\nexport const TILE_REFINEMENT = {\n ADD: 1, // Render tile and, if screen space error exceeded, also refine to its children.\n REPLACE: 2 // Render tile or, if screen space error exceeded, refine to its descendants instead.\n};\n\nexport const TILE_TYPE = {\n EMPTY: 'empty',\n SCENEGRAPH: 'scenegraph',\n POINTCLOUD: 'pointcloud',\n MESH: 'mesh'\n};\n\nexport const TILESET_TYPE = {\n I3S: 'I3S',\n TILES3D: 'TILES3D'\n};\n\nexport const LOD_METRIC_TYPE = {\n GEOMETRIC_ERROR: 'geometricError',\n MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'\n};\n\n// Cesium 3D Tiles Specific\nexport const TILE3D_OPTIMIZATION_HINT = {\n NOT_COMPUTED: -1,\n USE_OPTIMIZATION: 1,\n SKIP_OPTIMIZATION: 0\n};\n"],"file":"constants.js"}
package/dist/es5/index.js CHANGED
@@ -7,79 +7,79 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "Tileset3D", {
9
9
  enumerable: true,
10
- get: function () {
10
+ get: function get() {
11
11
  return _tileset3d.default;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "Tile3D", {
15
15
  enumerable: true,
16
- get: function () {
16
+ get: function get() {
17
17
  return _tile3d.default;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "TilesetTraverser", {
21
21
  enumerable: true,
22
- get: function () {
22
+ get: function get() {
23
23
  return _tilesetTraverser.default;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "TilesetCache", {
27
27
  enumerable: true,
28
- get: function () {
28
+ get: function get() {
29
29
  return _tilesetCache.default;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "createBoundingVolume", {
33
33
  enumerable: true,
34
- get: function () {
34
+ get: function get() {
35
35
  return _boundingVolume.createBoundingVolume;
36
36
  }
37
37
  });
38
38
  Object.defineProperty(exports, "calculateTransformProps", {
39
39
  enumerable: true,
40
- get: function () {
40
+ get: function get() {
41
41
  return _transformUtils.calculateTransformProps;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "getFrameState", {
45
45
  enumerable: true,
46
- get: function () {
46
+ get: function get() {
47
47
  return _frameState.getFrameState;
48
48
  }
49
49
  });
50
50
  Object.defineProperty(exports, "getLodStatus", {
51
51
  enumerable: true,
52
- get: function () {
52
+ get: function get() {
53
53
  return _i3sLod.getLodStatus;
54
54
  }
55
55
  });
56
56
  Object.defineProperty(exports, "TILE_CONTENT_STATE", {
57
57
  enumerable: true,
58
- get: function () {
58
+ get: function get() {
59
59
  return _constants.TILE_CONTENT_STATE;
60
60
  }
61
61
  });
62
62
  Object.defineProperty(exports, "TILE_REFINEMENT", {
63
63
  enumerable: true,
64
- get: function () {
64
+ get: function get() {
65
65
  return _constants.TILE_REFINEMENT;
66
66
  }
67
67
  });
68
68
  Object.defineProperty(exports, "TILE_TYPE", {
69
69
  enumerable: true,
70
- get: function () {
70
+ get: function get() {
71
71
  return _constants.TILE_TYPE;
72
72
  }
73
73
  });
74
74
  Object.defineProperty(exports, "TILESET_TYPE", {
75
75
  enumerable: true,
76
- get: function () {
76
+ get: function get() {
77
77
  return _constants.TILESET_TYPE;
78
78
  }
79
79
  });
80
80
  Object.defineProperty(exports, "LOD_METRIC_TYPE", {
81
81
  enumerable: true,
82
- get: function () {
82
+ get: function get() {
83
83
  return _constants.LOD_METRIC_TYPE;
84
84
  }
85
85
  });
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.createBoundingVolume = createBoundingVolume;
7
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
8
14
  var _core = require("@math.gl/core");
9
15
 
10
16
  var _culling = require("@math.gl/culling");
@@ -17,9 +23,9 @@ function defined(x) {
17
23
  return x !== undefined && x !== null;
18
24
  }
19
25
 
20
- const scratchScale = new _core.Vector3();
21
- const scratchNorthWest = new _core.Vector3();
22
- const scratchSouthEast = new _core.Vector3();
26
+ var scratchScale = new _core.Vector3();
27
+ var scratchNorthWest = new _core.Vector3();
28
+ var scratchSouthEast = new _core.Vector3();
23
29
 
24
30
  function createBoundingVolume(boundingVolumeHeader, transform, result) {
25
31
  (0, _loaderUtils.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
@@ -29,14 +35,20 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
29
35
  }
30
36
 
31
37
  if (boundingVolumeHeader.region) {
32
- const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
38
+ var _boundingVolumeHeader = (0, _slicedToArray2.default)(boundingVolumeHeader.region, 6),
39
+ west = _boundingVolumeHeader[0],
40
+ south = _boundingVolumeHeader[1],
41
+ east = _boundingVolumeHeader[2],
42
+ north = _boundingVolumeHeader[3],
43
+ minHeight = _boundingVolumeHeader[4],
44
+ maxHeight = _boundingVolumeHeader[5];
33
45
 
34
- const northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
46
+ var northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
35
47
 
36
- const southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
48
+ var southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
37
49
 
38
- const centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
39
- const radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
50
+ var centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
51
+ var radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
40
52
  return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
41
53
  }
42
54
 
@@ -48,32 +60,32 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
48
60
  }
49
61
 
50
62
  function createBox(box, transform, result) {
51
- const center = new _core.Vector3(box[0], box[1], box[2]);
63
+ var center = new _core.Vector3(box[0], box[1], box[2]);
52
64
  transform.transform(center, center);
53
- let origin = [];
65
+ var origin = [];
54
66
 
55
67
  if (box.length === 10) {
56
- const halfSize = box.slice(3, 6);
57
- const quaternion = new _core.Quaternion();
68
+ var halfSize = box.slice(3, 6);
69
+ var quaternion = new _core.Quaternion();
58
70
  quaternion.fromArray(box, 6);
59
- const x = new _core.Vector3([1, 0, 0]);
60
- const y = new _core.Vector3([0, 1, 0]);
61
- const z = new _core.Vector3([0, 0, 1]);
71
+ var x = new _core.Vector3([1, 0, 0]);
72
+ var y = new _core.Vector3([0, 1, 0]);
73
+ var z = new _core.Vector3([0, 0, 1]);
62
74
  x.transformByQuaternion(quaternion);
63
75
  x.scale(halfSize[0]);
64
76
  y.transformByQuaternion(quaternion);
65
77
  y.scale(halfSize[1]);
66
78
  z.transformByQuaternion(quaternion);
67
79
  z.scale(halfSize[2]);
68
- origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];
80
+ origin = [].concat((0, _toConsumableArray2.default)(x.toArray()), (0, _toConsumableArray2.default)(y.toArray()), (0, _toConsumableArray2.default)(z.toArray()));
69
81
  } else {
70
- origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];
82
+ origin = [].concat((0, _toConsumableArray2.default)(box.slice(3, 6)), (0, _toConsumableArray2.default)(box.slice(6, 9)), (0, _toConsumableArray2.default)(box.slice(9, 12)));
71
83
  }
72
84
 
73
- const xAxis = transform.transformAsVector(origin.slice(0, 3));
74
- const yAxis = transform.transformAsVector(origin.slice(3, 6));
75
- const zAxis = transform.transformAsVector(origin.slice(6, 9));
76
- const halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
85
+ var xAxis = transform.transformAsVector(origin.slice(0, 3));
86
+ var yAxis = transform.transformAsVector(origin.slice(3, 6));
87
+ var zAxis = transform.transformAsVector(origin.slice(6, 9));
88
+ var halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
77
89
 
78
90
  if (defined(result)) {
79
91
  result.center = center;
@@ -85,11 +97,11 @@ function createBox(box, transform, result) {
85
97
  }
86
98
 
87
99
  function createSphere(sphere, transform, result) {
88
- const center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
100
+ var center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
89
101
  transform.transform(center, center);
90
- const scale = transform.getScale(scratchScale);
91
- const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
92
- const radius = sphere[3] * uniformScale;
102
+ var scale = transform.getScale(scratchScale);
103
+ var uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
104
+ var radius = sphere[3] * uniformScale;
93
105
 
94
106
  if (defined(result)) {
95
107
  result.center = center;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/bounding-volume.ts"],"names":["defined","x","undefined","scratchScale","Vector3","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","box","createBox","region","west","south","east","north","minHeight","maxHeight","northWest","Ellipsoid","WGS84","cartographicToCartesian","southEast","centerInCartesian","addVectors","multiplyScalar","radius","subVectors","len","createSphere","Matrix4","sphere","Error","center","origin","length","halfSize","slice","quaternion","Quaternion","fromArray","y","z","transformByQuaternion","scale","toArray","xAxis","transformAs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CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACyB,MAAP,GAAgBA,MAAhB;AACAzB,IAAAA,MAAM,CAACkB,MAAP,GAAgBA,MAAhB;AACA,WAAOlB,MAAP;AACD;;AAED,SAAO,IAAIiD,uBAAJ,CAAmBxB,MAAnB,EAA2BP,MAA3B,CAAP;AACD","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {assert} from '@loaders.gl/loader-utils';\n\n// const scratchProjectedBoundingSphere = new BoundingSphere();\n\nfunction defined(x) {\n return x !== undefined && x !== null;\n}\n\n// const scratchMatrix = new Matrix3();\nconst scratchScale = new Vector3();\nconst scratchNorthWest = new Vector3();\nconst scratchSouthEast = new Vector3();\n// const scratchRectangle = new Rectangle();\n// const scratchOrientedBoundingBox = new OrientedBoundingBox();\n// const scratchTransform = new Matrix4();\n\n/**\n * Create a bounding volume from the tile's bounding volume header.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {Matrix4} transform The transform to apply to the bounding volume.\n * @param [result] The object onto which to store the result.\n * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.\n */\nexport function createBoundingVolume(boundingVolumeHeader, transform, result) {\n assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');\n\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return createBox(boundingVolumeHeader.box, transform, result);\n }\n if (boundingVolumeHeader.region) {\n // [west, south, east, north, minimum height, maximum height]\n // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n // Heights are in meters above (or below) the WGS 84 ellipsoid.\n const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;\n\n const northWest = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(west), degrees(north), minHeight],\n scratchNorthWest\n );\n const southEast = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(east), degrees(south), maxHeight],\n scratchSouthEast\n );\n const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);\n const radius = new Vector3().subVectors(northWest, southEast).len() / 2.0;\n\n // TODO improve region boundingVolume\n // for now, create a sphere as the boundingVolume instead of box\n return createSphere(\n [centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius],\n new Matrix4()\n );\n }\n\n if (boundingVolumeHeader.sphere) {\n return createSphere(boundingVolumeHeader.sphere, transform, result);\n }\n\n throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\n}\n\nfunction createBox(box, transform, result) {\n // https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box\n // 1. A half-axes based representation.\n // box: An array of 12 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box.\n // The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.\n // The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.\n // The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.\n // 2. A half-size-quaternion based representation.\n // box: An array of 10 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.\n // The next three elements (with indices 3, 4, and 5) define the halfSize.\n // The last four elements (indices 6, 7, 8 and 10) define the quaternion.\n const center = new Vector3(box[0], box[1], box[2]);\n transform.transform(center, center);\n let origin: number[] = [];\n if (box.length === 10) {\n const halfSize = box.slice(3, 6);\n const quaternion = new Quaternion();\n quaternion.fromArray(box, 6);\n const x = new Vector3([1, 0, 0]);\n const y = new Vector3([0, 1, 0]);\n const z = new Vector3([0, 0, 1]);\n x.transformByQuaternion(quaternion);\n x.scale(halfSize[0]);\n y.transformByQuaternion(quaternion);\n y.scale(halfSize[1]);\n z.transformByQuaternion(quaternion);\n z.scale(halfSize[2]);\n origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];\n } else {\n origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];\n }\n const xAxis = transform.transformAsVector(origin.slice(0, 3));\n const yAxis = transform.transformAsVector(origin.slice(3, 6));\n const zAxis = transform.transformAsVector(origin.slice(6, 9));\n const halfAxes = new Matrix3([\n xAxis[0],\n xAxis[1],\n xAxis[2],\n yAxis[0],\n yAxis[1],\n yAxis[2],\n zAxis[0],\n zAxis[1],\n zAxis[2]\n ]);\n\n if (defined(result)) {\n result.center = center;\n result.halfAxes = halfAxes;\n return result;\n }\n\n return new OrientedBoundingBox(center, halfAxes);\n}\n\n/*\nfunction createBoxFromTransformedRegion(region, transform, initialTransform, result) {\n const rectangle = Rectangle.unpack(region, 0, scratchRectangle);\n const minimumHeight = region[4];\n const maximumHeight = region[5];\n\n const orientedBoundingBox = OrientedBoundingBox.fromRectangle(\n rectangle,\n minimumHeight,\n maximumHeight,\n Ellipsoid.WGS84,\n scratchOrientedBoundingBox\n );\n const center = orientedBoundingBox.center;\n const halfAxes = orientedBoundingBox.halfAxes;\n\n // A region bounding volume is not transformed by the transform in the tileset JSON,\n // but may be transformed by additional transforms applied in Cesium.\n // This is why the transform is calculated as the difference between the initial transform and the current transform.\n transform = Matrix4.multiplyTransformation(\n transform,\n Matrix4.inverseTransformation(initialTransform, scratchTransform),\n scratchTransform\n );\n center = Matrix4.multiplyByPoint(transform, center, center);\n const rotationScale = Matrix4.getRotation(transform, scratchMatrix);\n halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);\n\n if (defined(result) && result instanceof TileOrientedBoundingBox) {\n result.update(center, halfAxes);\n return result;\n }\n\n return new TileOrientedBoundingBox(center, halfAxes);\n}\n\nfunction createRegion(region, transform, initialTransform, result) {\n if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {\n return createBoxFromTransformedRegion(region, transform, initialTransform, result);\n }\n\n if (defined(result)) {\n return result;\n }\n\n const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);\n\n return new TileBoundingRegion({\n rectangle: rectangleRegion,\n minimumHeight: region[4],\n maximumHeight: region[5]\n });\n}\n*/\n\nfunction createSphere(sphere, transform, result?) {\n // Find the transformed center\n const center = new Vector3(sphere[0], sphere[1], sphere[2]);\n transform.transform(center, center);\n const scale = transform.getScale(scratchScale);\n\n const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n const radius = sphere[3] * uniformScale;\n\n if (defined(result)) {\n result.center = center;\n result.radius = radius;\n return result;\n }\n\n return new BoundingSphere(center, radius);\n}\n"],"file":"bounding-volume.js"}
1
+ {"version":3,"sources":["../../../../src/tileset/helpers/bounding-volume.ts"],"names":["defined","x","undefined","scratchScale","Vector3","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","box","createBox","region","west","south","east","north","minHeight","maxHeight","northWest","Ellipsoid","WGS84","cartographicToCartesian","southEast","centerInCartesian","addVectors","multiplyScalar","radius","subVectors","len","createSphere","Matrix4","sphere","Error","center","origin","length","halfSize","slice","quaternion","Quaternion","fromArray","y","z","transformByQuaternion","scale","toArray","xAxis","transformAsVector","yAxis","zAxis","halfAxes","Matrix3","OrientedBoundingBox","getScale","uniformScale","Math","max","BoundingSphere"],"mappings":";;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AAIA,SAASA,OAAT,CAAiBC,CAAjB,EAAoB;AAClB,SAAOA,CAAC,KAAKC,SAAN,IAAmBD,CAAC,KAAK,IAAhC;AACD;;AAGD,IAAME,YAAY,GAAG,IAAIC,aAAJ,EAArB;AACA,IAAMC,gBAAgB,GAAG,IAAID,aAAJ,EAAzB;AACA,IAAME,gBAAgB,GAAG,IAAIF,aAAJ,EAAzB;;AAYO,SAASG,oBAAT,CAA8BC,oBAA9B,EAAoDC,SAApD,EAA+DC,MAA/D,EAA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,MAAhB;AACAzB,IAAAA,MAAM,CAAC0C,QAAP,GAAkBA,QAAlB;AACA,WAAO1C,MAAP;AACD;;AAED,SAAO,IAAI4C,4BAAJ,CAAwBnB,MAAxB,EAAgCiB,QAAhC,CAAP;AACD;;AAyDD,SAASrB,YAAT,CAAsBE,MAAtB,EAA8BxB,SAA9B,EAAyCC,MAAzC,EAAkD;AAEhD,MAAMyB,MAAM,GAAG,IAAI/B,aAAJ,CAAY6B,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAf;AACAxB,EAAAA,SAAS,CAACA,SAAV,CAAoB0B,MAApB,EAA4BA,MAA5B;AACA,MAAMW,KAAK,GAAGrC,SAAS,CAAC8C,QAAV,CAAmBpD,YAAnB,CAAd;AAEA,MAAMqD,YAAY,GAAGC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACC,GAAL,CAASZ,KAAK,CAAC,CAAD,CAAd,EAAmBA,KAAK,CAAC,CAAD,CAAxB,CAAT,EAAuCA,KAAK,CAAC,CAAD,CAA5C,CAArB;AACA,MAAMlB,MAAM,GAAGK,MAAM,CAAC,CAAD,CAAN,GAAYuB,YAA3B;;AAEA,MAAIxD,OAAO,CAACU,MAAD,CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACyB,MAAP,GAAgBA,MAAhB;AACAzB,IAAAA,MAAM,CAACkB,MAAP,GAAgBA,MAAhB;AACA,WAAOlB,MAAP;AACD;;AAED,SAAO,IAAIiD,uBAAJ,CAAmBxB,MAAnB,EAA2BP,MAA3B,CAAP;AACD","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {assert} from '@loaders.gl/loader-utils';\n\n// const scratchProjectedBoundingSphere = new BoundingSphere();\n\nfunction defined(x) {\n return x !== undefined && x !== null;\n}\n\n// const scratchMatrix = new Matrix3();\nconst scratchScale = new Vector3();\nconst scratchNorthWest = new Vector3();\nconst scratchSouthEast = new Vector3();\n// const scratchRectangle = new Rectangle();\n// const scratchOrientedBoundingBox = new OrientedBoundingBox();\n// const scratchTransform = new Matrix4();\n\n/**\n * Create a bounding volume from the tile's bounding volume header.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {Matrix4} transform The transform to apply to the bounding volume.\n * @param [result] The object onto which to store the result.\n * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.\n */\nexport function createBoundingVolume(boundingVolumeHeader, transform, result) {\n assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');\n\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return createBox(boundingVolumeHeader.box, transform, result);\n }\n if (boundingVolumeHeader.region) {\n // [west, south, east, north, minimum height, maximum height]\n // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n // Heights are in meters above (or below) the WGS 84 ellipsoid.\n const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;\n\n const northWest = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(west), degrees(north), minHeight],\n scratchNorthWest\n );\n const southEast = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(east), degrees(south), maxHeight],\n scratchSouthEast\n );\n const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);\n const radius = new Vector3().subVectors(northWest, southEast).len() / 2.0;\n\n // TODO improve region boundingVolume\n // for now, create a sphere as the boundingVolume instead of box\n return createSphere(\n [centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius],\n new Matrix4()\n );\n }\n\n if (boundingVolumeHeader.sphere) {\n return createSphere(boundingVolumeHeader.sphere, transform, result);\n }\n\n throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\n}\n\nfunction createBox(box, transform, result) {\n // https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box\n // 1. A half-axes based representation.\n // box: An array of 12 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box.\n // The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.\n // The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.\n // The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.\n // 2. A half-size-quaternion based representation.\n // box: An array of 10 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.\n // The next three elements (with indices 3, 4, and 5) define the halfSize.\n // The last four elements (indices 6, 7, 8 and 10) define the quaternion.\n const center = new Vector3(box[0], box[1], box[2]);\n transform.transform(center, center);\n let origin: number[] = [];\n if (box.length === 10) {\n const halfSize = box.slice(3, 6);\n const quaternion = new Quaternion();\n quaternion.fromArray(box, 6);\n const x = new Vector3([1, 0, 0]);\n const y = new Vector3([0, 1, 0]);\n const z = new Vector3([0, 0, 1]);\n x.transformByQuaternion(quaternion);\n x.scale(halfSize[0]);\n y.transformByQuaternion(quaternion);\n y.scale(halfSize[1]);\n z.transformByQuaternion(quaternion);\n z.scale(halfSize[2]);\n origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];\n } else {\n origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];\n }\n const xAxis = transform.transformAsVector(origin.slice(0, 3));\n const yAxis = transform.transformAsVector(origin.slice(3, 6));\n const zAxis = transform.transformAsVector(origin.slice(6, 9));\n const halfAxes = new Matrix3([\n xAxis[0],\n xAxis[1],\n xAxis[2],\n yAxis[0],\n yAxis[1],\n yAxis[2],\n zAxis[0],\n zAxis[1],\n zAxis[2]\n ]);\n\n if (defined(result)) {\n result.center = center;\n result.halfAxes = halfAxes;\n return result;\n }\n\n return new OrientedBoundingBox(center, halfAxes);\n}\n\n/*\nfunction createBoxFromTransformedRegion(region, transform, initialTransform, result) {\n const rectangle = Rectangle.unpack(region, 0, scratchRectangle);\n const minimumHeight = region[4];\n const maximumHeight = region[5];\n\n const orientedBoundingBox = OrientedBoundingBox.fromRectangle(\n rectangle,\n minimumHeight,\n maximumHeight,\n Ellipsoid.WGS84,\n scratchOrientedBoundingBox\n );\n const center = orientedBoundingBox.center;\n const halfAxes = orientedBoundingBox.halfAxes;\n\n // A region bounding volume is not transformed by the transform in the tileset JSON,\n // but may be transformed by additional transforms applied in Cesium.\n // This is why the transform is calculated as the difference between the initial transform and the current transform.\n transform = Matrix4.multiplyTransformation(\n transform,\n Matrix4.inverseTransformation(initialTransform, scratchTransform),\n scratchTransform\n );\n center = Matrix4.multiplyByPoint(transform, center, center);\n const rotationScale = Matrix4.getRotation(transform, scratchMatrix);\n halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);\n\n if (defined(result) && result instanceof TileOrientedBoundingBox) {\n result.update(center, halfAxes);\n return result;\n }\n\n return new TileOrientedBoundingBox(center, halfAxes);\n}\n\nfunction createRegion(region, transform, initialTransform, result) {\n if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {\n return createBoxFromTransformedRegion(region, transform, initialTransform, result);\n }\n\n if (defined(result)) {\n return result;\n }\n\n const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);\n\n return new TileBoundingRegion({\n rectangle: rectangleRegion,\n minimumHeight: region[4],\n maximumHeight: region[5]\n });\n}\n*/\n\nfunction createSphere(sphere, transform, result?) {\n // Find the transformed center\n const center = new Vector3(sphere[0], sphere[1], sphere[2]);\n transform.transform(center, center);\n const scale = transform.getScale(scratchScale);\n\n const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n const radius = sphere[3] * uniformScale;\n\n if (defined(result)) {\n result.center = center;\n result.radius = radius;\n return result;\n }\n\n return new BoundingSphere(center, radius);\n}\n"],"file":"bounding-volume.js"}
@@ -11,31 +11,27 @@ var _culling = require("@math.gl/culling");
11
11
 
12
12
  var _geospatial = require("@math.gl/geospatial");
13
13
 
14
- const scratchVector = new _core.Vector3();
15
- const scratchPosition = new _core.Vector3();
16
- const cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
14
+ var scratchVector = new _core.Vector3();
15
+ var scratchPosition = new _core.Vector3();
16
+ var cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
17
17
 
18
18
  function getFrameState(viewport, frameNumber) {
19
- const {
20
- cameraDirection,
21
- cameraUp,
22
- height
23
- } = viewport;
24
- const {
25
- metersPerUnit
26
- } = viewport.distanceScales;
27
- const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
19
+ var cameraDirection = viewport.cameraDirection,
20
+ cameraUp = viewport.cameraUp,
21
+ height = viewport.height;
22
+ var metersPerUnit = viewport.distanceScales.metersPerUnit;
23
+ var viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
28
24
 
29
- const viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
25
+ var viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
30
26
 
31
- const enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
27
+ var enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
32
28
 
33
- const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
29
+ var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
34
30
 
35
- const cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
31
+ var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
36
32
 
37
- const cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
38
- const cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
33
+ var cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
34
+ var cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
39
35
  commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
40
36
  return {
41
37
  camera: {
@@ -43,25 +39,25 @@ function getFrameState(viewport, frameNumber) {
43
39
  direction: cameraDirectionCartesian,
44
40
  up: cameraUpCartesian
45
41
  },
46
- viewport,
47
- height,
48
- cullingVolume,
49
- frameNumber,
42
+ viewport: viewport,
43
+ height: height,
44
+ cullingVolume: cullingVolume,
45
+ frameNumber: frameNumber,
50
46
  sseDenominator: 1.15
51
47
  };
52
48
  }
53
49
 
54
50
  function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
55
- const frustumPlanes = viewport.getFrustumPlanes();
56
- let i = 0;
51
+ var frustumPlanes = viewport.getFrustumPlanes();
52
+ var i = 0;
57
53
 
58
- for (const dir in frustumPlanes) {
59
- const plane = frustumPlanes[dir];
60
- const distanceToCenter = plane.normal.dot(viewport.center);
54
+ for (var dir in frustumPlanes) {
55
+ var plane = frustumPlanes[dir];
56
+ var distanceToCenter = plane.normal.dot(viewport.center);
61
57
  scratchPosition.copy(plane.normal).scale(plane.distance - distanceToCenter).add(viewport.center);
62
- const cartographicPos = viewport.unprojectPosition(scratchPosition);
58
+ var cartographicPos = viewport.unprojectPosition(scratchPosition);
63
59
 
64
- const cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
60
+ var cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
65
61
 
66
62
  cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos));
67
63
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","longitude","latitude","viewportCenterCartesian","Ellipsoid","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","center","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAeA,MAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,MAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,MAAME,aAAa,GAAG,IAAIC,sBAAJ,CAAkB,CACtC,IAAIC,cAAJ,EADsC,EAEtC,IAAIA,cAAJ,EAFsC,EAGtC,IAAIA,cAAJ,EAHsC,EAItC,IAAIA,cAAJ,EAJsC,EAKtC,IAAIA,cAAJ,EALsC,EAMtC,IAAIA,cAAJ,EANsC,CAAlB,CAAtB;;AAWO,SAASC,aAAT,CAAuBC,QAAvB,EAAiCC,WAAjC,EAAkE;AAEvE,QAAM;AAACC,IAAAA,eAAD;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAsCJ,QAA5C;AACA,QAAM;AAACK,IAAAA;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;AAYD;;AAED,SAASL,wBAAT,CAAkCzB,QAAlC,EAA4CU,uBAA5C,EAAqE;AAEnE,QAAMqB,aAAa,GAAG/B,QAAQ,CAACgC,gBAAT,EAAtB;AACA,MAAIC,CAAC,GAAG,CAAR;;AACA,OAAK,MAAMC,GAAX,IAAkBH,aAAlB,EAAiC;AAC/B,UAAMI,KAAK,GAAGJ,aAAa,CAACG,GAAD,CAA3B;AACA,UAAME,gBAAgB,GAAGD,KAAK,CAACE,MAAN,CAAaC,GAAb,CAAiBtC,QAAQ,CAACuC,MAA1B,CAAzB;AACA5C,IAAAA,eAAe,CACZ6C,IADH,CACQL,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACM,QAAN,GAAiBL,gBAF1B,EAGGM,GAHH,CAGO1C,QAAQ,CAACuC,MAHhB;AAIA,UAAMI,eAAe,GAAG3C,QAAQ,CAACiB,iBAAT,CAA2BtB,eAA3B,CAAxB;;AAEA,UAAMiD,YAAY,GAAGjC,sBAAUC,KAAV,CAAgBC,uBAAhB,CAAwC8B,eAAxC,EAAyD,IAAIjD,aAAJ,EAAzD,CAArB;;AAEAE,IAAAA,aAAa,CAACiD,MAAd,CAAqBZ,CAAC,EAAtB,EAA0Ba,eAA1B,CACEF,YADF,EAGEnD,aAAa,CAAC+C,IAAd,CAAmB9B,uBAAnB,EAA4CqC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
1
+ {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","unprojectPosition","center","viewportCenterCartesian","Ellipsoid","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAeA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,IAAME,aAAa,GAAG,IAAIC,sBAAJ,CAAkB,CACtC,IAAIC,cAAJ,EADsC,EAEtC,IAAIA,cAAJ,EAFsC,EAGtC,IAAIA,cAAJ,EAHsC,EAItC,IAAIA,cAAJ,EAJsC,EAKtC,IAAIA,cAAJ,EALsC,EAMtC,IAAIA,cAAJ,EANsC,CAAlB,CAAtB;;AAWO,SAASC,aAAT,CAAuBC,QAAvB,EAAiCC,WAAjC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AER,wBAFL;AAGNS,MAAAA,EAAE,EAAEL;AAHE,KADH;AAMLvB,IAAAA,QAAQ,EAARA,QANK;AAOLI,IAAAA,MAAM,EAANA,MAPK;AAQLR,IAAAA,aAAa,EAAbA,aARK;AASLK,IAAAA,WAAW,EAAXA,WATK;AAUL4B,IAAAA,cAAc,EAAE;AAVX,GAAP;AAYD;;AAED,SAASL,wBAAT,CAAkCxB,QAAlC,EAA4CU,uBAA5C,EAAqE;AAEnE,MAAMoB,aAAa,GAAG9B,QAAQ,CAAC+B,gBAAT,EAAtB;AACA,MAAIC,CAAC,GAAG,CAAR;;AACA,OAAK,IAAMC,GAAX,IAAkBH,aAAlB,EAAiC;AAC/B,QAAMI,KAAK,GAAGJ,aAAa,CAACG,GAAD,CAA3B;AACA,QAAME,gBAAgB,GAAGD,KAAK,CAACE,MAAN,CAAaC,GAAb,CAAiBrC,QAAQ,CAACS,MAA1B,CAAzB;AACAd,IAAAA,eAAe,CACZ2C,IADH,CACQJ,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACK,QAAN,GAAiBJ,gBAF1B,EAGGK,GAHH,CAGOxC,QAAQ,CAACS,MAHhB;AAIA,QAAMgC,eAAe,GAAGzC,QAAQ,CAACQ,iBAAT,CAA2Bb,eAA3B,CAAxB;;AAEA,QAAM+C,YAAY,GAAG/B,sBAAUC,KAAV,CAAgBC,uBAAhB,CAAwC4B,eAAxC,EAAyD,IAAI/C,aAAJ,EAAzD,CAArB;;AAEAE,IAAAA,aAAa,CAAC+C,MAAd,CAAqBX,CAAC,EAAtB,EAA0BY,eAA1B,CACEF,YADF,EAGEjD,aAAa,CAAC6C,IAAd,CAAmB5B,uBAAnB,EAA4CmC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.getLodStatus = getLodStatus;
7
9
  exports.getProjectedRadius = getProjectedRadius;
8
10
 
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+
9
13
  var _core = require("@math.gl/core");
10
14
 
11
15
  var _geospatial = require("@math.gl/geospatial");
@@ -15,7 +19,7 @@ function getLodStatus(tile, frameState) {
15
19
  return 'DIG';
16
20
  }
17
21
 
18
- const screenSize = 2 * getProjectedRadius(tile, frameState);
22
+ var screenSize = 2 * getProjectedRadius(tile, frameState);
19
23
 
20
24
  if (screenSize < 2) {
21
25
  return 'OUT';
@@ -31,54 +35,52 @@ function getLodStatus(tile, frameState) {
31
35
  }
32
36
 
33
37
  function getProjectedRadius(tile, frameState) {
34
- const originalViewport = frameState.viewport;
35
- const ViewportClass = originalViewport.constructor;
36
- const {
37
- longitude,
38
- latitude,
39
- height,
40
- width,
41
- bearing,
42
- zoom
43
- } = originalViewport;
44
- const viewport = new ViewportClass({
45
- longitude,
46
- latitude,
47
- height,
48
- width,
49
- bearing,
50
- zoom,
38
+ var originalViewport = frameState.viewport;
39
+ var ViewportClass = originalViewport.constructor;
40
+ var longitude = originalViewport.longitude,
41
+ latitude = originalViewport.latitude,
42
+ height = originalViewport.height,
43
+ width = originalViewport.width,
44
+ bearing = originalViewport.bearing,
45
+ zoom = originalViewport.zoom;
46
+ var viewport = new ViewportClass({
47
+ longitude: longitude,
48
+ latitude: latitude,
49
+ height: height,
50
+ width: width,
51
+ bearing: bearing,
52
+ zoom: zoom,
51
53
  pitch: 0
52
54
  });
53
- const mbsLat = tile.header.mbs[1];
54
- const mbsLon = tile.header.mbs[0];
55
- const mbsZ = tile.header.mbs[2];
56
- const mbsR = tile.header.mbs[3];
57
- const mbsCenterCartesian = [...tile.boundingVolume.center];
58
- const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
55
+ var mbsLat = tile.header.mbs[1];
56
+ var mbsLon = tile.header.mbs[0];
57
+ var mbsZ = tile.header.mbs[2];
58
+ var mbsR = tile.header.mbs[3];
59
+ var mbsCenterCartesian = (0, _toConsumableArray2.default)(tile.boundingVolume.center);
60
+ var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
59
61
 
60
- const cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
62
+ var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
61
63
 
62
- const toEye = new _core.Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
63
- const enuToCartesianMatrix = new _core.Matrix4();
64
+ var toEye = new _core.Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
65
+ var enuToCartesianMatrix = new _core.Matrix4();
64
66
 
65
67
  _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
66
68
 
67
- const cartesianToEnuMatrix = new _core.Matrix4(enuToCartesianMatrix).invert();
68
- const cameraPositionEnu = new _core.Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
69
- const projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
70
- const extraZ = projection * projection / cameraPositionEnu[2];
71
- const extraVertexEnu = new _core.Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
72
- const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
73
- const extraVectorCartesian = new _core.Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
74
- const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
75
- const sphereMbsBorderVertexCartesian = new _core.Vector3(mbsCenterCartesian).add(radiusVector);
76
-
77
- const sphereMbsBorderVertexCartographic = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
78
-
79
- const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
80
- const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
81
- const projectedRadius = new _core.Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
69
+ var cartesianToEnuMatrix = new _core.Matrix4(enuToCartesianMatrix).invert();
70
+ var cameraPositionEnu = new _core.Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
71
+ var projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
72
+ var extraZ = projection * projection / cameraPositionEnu[2];
73
+ var extraVertexEnu = new _core.Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
74
+ var extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
75
+ var extraVectorCartesian = new _core.Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
76
+ var radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
77
+ var sphereMbsBorderVertexCartesian = new _core.Vector3(mbsCenterCartesian).add(radiusVector);
78
+
79
+ var sphereMbsBorderVertexCartographic = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
80
+
81
+ var projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
82
+ var projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
83
+ var projectedRadius = new _core.Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
82
84
  return projectedRadius;
83
85
  }
84
86
  //# sourceMappingURL=i3s-lod.js.map