@loaders.gl/tiles 3.1.0-alpha.4 → 3.1.0-alpha.5

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 (78) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/constants.d.ts +31 -0
  3. package/dist/dist.min.js +1 -1
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/bundle.js +1 -1
  6. package/dist/es5/bundle.js.map +1 -1
  7. package/dist/es5/constants.js +6 -6
  8. package/dist/es5/constants.js.map +1 -1
  9. package/dist/es5/index.js +20 -12
  10. package/dist/es5/index.js.map +1 -1
  11. package/dist/es5/tileset/helpers/bounding-volume.js +25 -37
  12. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
  13. package/dist/es5/tileset/helpers/frame-state.js +29 -25
  14. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  15. package/dist/es5/tileset/helpers/i3s-lod.js +57 -106
  16. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  17. package/dist/es5/tileset/helpers/tiles-3d-lod.js +51 -47
  18. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
  19. package/dist/es5/tileset/helpers/transform-utils.js +21 -12
  20. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
  21. package/dist/es5/tileset/helpers/zoom.js +17 -15
  22. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  23. package/dist/es5/tileset/tile-3d.js +328 -421
  24. package/dist/es5/tileset/tile-3d.js.map +1 -1
  25. package/dist/es5/tileset/tileset-3d.js +381 -563
  26. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  27. package/dist/es5/tileset/tileset-cache.js +50 -63
  28. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  29. package/dist/es5/tileset/traversers/i3s-tile-manager.js +32 -44
  30. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
  31. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +53 -143
  32. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  33. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +34 -62
  34. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
  35. package/dist/es5/tileset/traversers/tileset-traverser.js +209 -282
  36. package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
  37. package/dist/es5/utils/doubly-linked-list-node.js +7 -9
  38. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  39. package/dist/es5/utils/doubly-linked-list.js +64 -76
  40. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  41. package/dist/es5/utils/managed-array.js +86 -108
  42. package/dist/es5/utils/managed-array.js.map +1 -1
  43. package/dist/esm/index.js +1 -0
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/tileset/helpers/i3s-lod.js +45 -86
  46. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
  47. package/dist/esm/tileset/helpers/transform-utils.js +4 -1
  48. package/dist/esm/tileset/helpers/transform-utils.js.map +1 -1
  49. package/dist/esm/tileset/tile-3d.js +3 -3
  50. package/dist/esm/tileset/tile-3d.js.map +1 -1
  51. package/dist/esm/tileset/tileset-3d.js +5 -5
  52. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  53. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +4 -4
  54. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  55. package/dist/index.d.ts +10 -0
  56. package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -0
  57. package/dist/tileset/helpers/bounding-volume.d.ts +8 -0
  58. package/dist/tileset/helpers/frame-state.d.ts +16 -0
  59. package/dist/tileset/helpers/i3s-lod.d.ts +19 -0
  60. package/dist/tileset/helpers/tiles-3d-lod.d.ts +7 -0
  61. package/dist/tileset/helpers/transform-utils.d.ts +1 -0
  62. package/dist/tileset/helpers/zoom.d.ts +6 -0
  63. package/dist/tileset/tile-3d.d.ts +173 -0
  64. package/dist/tileset/tileset-3d.d.ts +171 -0
  65. package/dist/tileset/tileset-cache.d.ts +17 -0
  66. package/dist/tileset/traversers/i3s-tile-manager.d.ts +7 -0
  67. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +17 -0
  68. package/dist/tileset/traversers/tileset-3d-traverser.d.ts +6 -0
  69. package/dist/tileset/traversers/tileset-traverser.d.ts +51 -0
  70. package/dist/utils/doubly-linked-list-node.d.ts +11 -0
  71. package/dist/utils/doubly-linked-list.d.ts +30 -0
  72. package/dist/utils/managed-array.d.ts +84 -0
  73. package/package.json +9 -6
  74. package/src/index.ts +1 -0
  75. package/src/tileset/helpers/i3s-lod.ts +72 -96
  76. package/src/tileset/helpers/transform-utils.ts +3 -1
  77. package/src/tileset/tile-3d.ts +2 -2
  78. package/src/tileset/traversers/i3s-tileset-traverser.ts +2 -3
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var moduleExports = require('./index');
3
+ const 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,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"}
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"}
@@ -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
- var TILE_CONTENT_STATE = {
7
+ const TILE_CONTENT_STATE = {
8
8
  UNLOADED: 0,
9
9
  LOADING: 1,
10
10
  PROCESSING: 2,
@@ -13,29 +13,29 @@ var TILE_CONTENT_STATE = {
13
13
  FAILED: 5
14
14
  };
15
15
  exports.TILE_CONTENT_STATE = TILE_CONTENT_STATE;
16
- var TILE_REFINEMENT = {
16
+ const TILE_REFINEMENT = {
17
17
  ADD: 1,
18
18
  REPLACE: 2
19
19
  };
20
20
  exports.TILE_REFINEMENT = TILE_REFINEMENT;
21
- var TILE_TYPE = {
21
+ const 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
- var TILESET_TYPE = {
28
+ const TILESET_TYPE = {
29
29
  I3S: 'I3S',
30
30
  TILES3D: 'TILES3D'
31
31
  };
32
32
  exports.TILESET_TYPE = TILESET_TYPE;
33
- var LOD_METRIC_TYPE = {
33
+ const 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
- var TILE3D_OPTIMIZATION_HINT = {
38
+ const 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,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"}
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"}
package/dist/es5/index.js CHANGED
@@ -7,73 +7,79 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "Tileset3D", {
9
9
  enumerable: true,
10
- get: function get() {
10
+ get: function () {
11
11
  return _tileset3d.default;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "Tile3D", {
15
15
  enumerable: true,
16
- get: function get() {
16
+ get: function () {
17
17
  return _tile3d.default;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "TilesetTraverser", {
21
21
  enumerable: true,
22
- get: function get() {
22
+ get: function () {
23
23
  return _tilesetTraverser.default;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "TilesetCache", {
27
27
  enumerable: true,
28
- get: function get() {
28
+ get: function () {
29
29
  return _tilesetCache.default;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "createBoundingVolume", {
33
33
  enumerable: true,
34
- get: function get() {
34
+ get: function () {
35
35
  return _boundingVolume.createBoundingVolume;
36
36
  }
37
37
  });
38
38
  Object.defineProperty(exports, "calculateTransformProps", {
39
39
  enumerable: true,
40
- get: function get() {
40
+ get: function () {
41
41
  return _transformUtils.calculateTransformProps;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "getFrameState", {
45
45
  enumerable: true,
46
- get: function get() {
46
+ get: function () {
47
47
  return _frameState.getFrameState;
48
48
  }
49
49
  });
50
+ Object.defineProperty(exports, "getLodStatus", {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _i3sLod.getLodStatus;
54
+ }
55
+ });
50
56
  Object.defineProperty(exports, "TILE_CONTENT_STATE", {
51
57
  enumerable: true,
52
- get: function get() {
58
+ get: function () {
53
59
  return _constants.TILE_CONTENT_STATE;
54
60
  }
55
61
  });
56
62
  Object.defineProperty(exports, "TILE_REFINEMENT", {
57
63
  enumerable: true,
58
- get: function get() {
64
+ get: function () {
59
65
  return _constants.TILE_REFINEMENT;
60
66
  }
61
67
  });
62
68
  Object.defineProperty(exports, "TILE_TYPE", {
63
69
  enumerable: true,
64
- get: function get() {
70
+ get: function () {
65
71
  return _constants.TILE_TYPE;
66
72
  }
67
73
  });
68
74
  Object.defineProperty(exports, "TILESET_TYPE", {
69
75
  enumerable: true,
70
- get: function get() {
76
+ get: function () {
71
77
  return _constants.TILESET_TYPE;
72
78
  }
73
79
  });
74
80
  Object.defineProperty(exports, "LOD_METRIC_TYPE", {
75
81
  enumerable: true,
76
- get: function get() {
82
+ get: function () {
77
83
  return _constants.LOD_METRIC_TYPE;
78
84
  }
79
85
  });
@@ -92,5 +98,7 @@ var _transformUtils = require("./tileset/helpers/transform-utils");
92
98
 
93
99
  var _frameState = require("./tileset/helpers/frame-state");
94
100
 
101
+ var _i3sLod = require("./tileset/helpers/i3s-lod");
102
+
95
103
  var _constants = require("./constants");
96
104
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AAEA","sourcesContent":["export type {Tileset3DProps} from './tileset/tileset-3d';\nexport {default as Tileset3D} from './tileset/tileset-3d';\nexport {default as Tile3D} from './tileset/tile-3d';\n\nexport {default as TilesetTraverser} from './tileset/traversers/tileset-traverser';\nexport {default as TilesetCache} from './tileset/tileset-cache';\n\nexport {createBoundingVolume} from './tileset/helpers/bounding-volume';\nexport {calculateTransformProps} from './tileset/helpers/transform-utils';\n\nexport {getFrameState} from './tileset/helpers/frame-state';\n\nexport {\n TILE_CONTENT_STATE,\n TILE_REFINEMENT,\n TILE_TYPE,\n TILESET_TYPE,\n LOD_METRIC_TYPE\n} from './constants';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA","sourcesContent":["export type {Tileset3DProps} from './tileset/tileset-3d';\nexport {default as Tileset3D} from './tileset/tileset-3d';\nexport {default as Tile3D} from './tileset/tile-3d';\n\nexport {default as TilesetTraverser} from './tileset/traversers/tileset-traverser';\nexport {default as TilesetCache} from './tileset/tileset-cache';\n\nexport {createBoundingVolume} from './tileset/helpers/bounding-volume';\nexport {calculateTransformProps} from './tileset/helpers/transform-utils';\n\nexport {getFrameState} from './tileset/helpers/frame-state';\nexport {getLodStatus} from './tileset/helpers/i3s-lod';\n\nexport {\n TILE_CONTENT_STATE,\n TILE_REFINEMENT,\n TILE_TYPE,\n TILESET_TYPE,\n LOD_METRIC_TYPE\n} from './constants';\n"],"file":"index.js"}
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.createBoundingVolume = createBoundingVolume;
9
7
 
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
8
  var _core = require("@math.gl/core");
15
9
 
16
10
  var _culling = require("@math.gl/culling");
@@ -23,9 +17,9 @@ function defined(x) {
23
17
  return x !== undefined && x !== null;
24
18
  }
25
19
 
26
- var scratchScale = new _core.Vector3();
27
- var scratchNorthWest = new _core.Vector3();
28
- var scratchSouthEast = new _core.Vector3();
20
+ const scratchScale = new _core.Vector3();
21
+ const scratchNorthWest = new _core.Vector3();
22
+ const scratchSouthEast = new _core.Vector3();
29
23
 
30
24
  function createBoundingVolume(boundingVolumeHeader, transform, result) {
31
25
  (0, _loaderUtils.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
@@ -35,20 +29,14 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
35
29
  }
36
30
 
37
31
  if (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];
32
+ const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
45
33
 
46
- var northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
34
+ const northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
47
35
 
48
- var southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
36
+ const southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
49
37
 
50
- var centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
51
- var radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
38
+ const centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
39
+ const radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
52
40
  return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
53
41
  }
54
42
 
@@ -60,32 +48,32 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
60
48
  }
61
49
 
62
50
  function createBox(box, transform, result) {
63
- var center = new _core.Vector3(box[0], box[1], box[2]);
51
+ const center = new _core.Vector3(box[0], box[1], box[2]);
64
52
  transform.transform(center, center);
65
- var origin = [];
53
+ let origin = [];
66
54
 
67
55
  if (box.length === 10) {
68
- var halfSize = box.slice(3, 6);
69
- var quaternion = new _core.Quaternion();
56
+ const halfSize = box.slice(3, 6);
57
+ const quaternion = new _core.Quaternion();
70
58
  quaternion.fromArray(box, 6);
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]);
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]);
74
62
  x.transformByQuaternion(quaternion);
75
63
  x.scale(halfSize[0]);
76
64
  y.transformByQuaternion(quaternion);
77
65
  y.scale(halfSize[1]);
78
66
  z.transformByQuaternion(quaternion);
79
67
  z.scale(halfSize[2]);
80
- origin = [].concat((0, _toConsumableArray2.default)(x.toArray()), (0, _toConsumableArray2.default)(y.toArray()), (0, _toConsumableArray2.default)(z.toArray()));
68
+ origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];
81
69
  } else {
82
- origin = [].concat((0, _toConsumableArray2.default)(box.slice(3, 6)), (0, _toConsumableArray2.default)(box.slice(6, 9)), (0, _toConsumableArray2.default)(box.slice(9, 12)));
70
+ origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];
83
71
  }
84
72
 
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]]);
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]]);
89
77
 
90
78
  if (defined(result)) {
91
79
  result.center = center;
@@ -97,11 +85,11 @@ function createBox(box, transform, result) {
97
85
  }
98
86
 
99
87
  function createSphere(sphere, transform, result) {
100
- var center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
88
+ const center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
101
89
  transform.transform(center, center);
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;
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;
105
93
 
106
94
  if (defined(result)) {
107
95
  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","transformAsVector","yAxis","zAxis","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ACnBA,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,MAAME,YAAY,GAAG,IAAIC,aAAJ,EAArB;AACA,MAAMC,gBAAgB,GAAG,IAAID,aAAJ,EAAzB;AACA,MAAME,gBAAgB,GAAG,IAAIF,aAAJ,EAAzB;;AAYO,SAASG,oBAAT,CAA8BC,oBAA9B,EAAoDC,SAApD,EAA+DC,MAA/D,EAAuE;AAC5E,2BAAOF,oB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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,QAAMyB,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,QAAMW,KAAK,GAAGrC,SAAS,CAAC8C,QAAV,CAAmBpD,YAAnB,CAAd;AAEA,QAAMqD,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,QAAMlB,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,27 +11,31 @@ var _culling = require("@math.gl/culling");
11
11
 
12
12
  var _geospatial = require("@math.gl/geospatial");
13
13
 
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()]);
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()]);
17
17
 
18
18
  function getFrameState(viewport, frameNumber) {
19
- var cameraDirection = viewport.cameraDirection,
20
- cameraUp = viewport.cameraUp,
21
- height = viewport.height;
22
- var metersPerUnit = viewport.distanceScales.metersPerUnit;
23
- var viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
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];
24
28
 
25
- var viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
29
+ const viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
26
30
 
27
- var enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
31
+ const enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
28
32
 
29
- var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
33
+ const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
30
34
 
31
- var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
35
+ const cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
32
36
 
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();
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();
35
39
  commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
36
40
  return {
37
41
  camera: {
@@ -39,25 +43,25 @@ function getFrameState(viewport, frameNumber) {
39
43
  direction: cameraDirectionCartesian,
40
44
  up: cameraUpCartesian
41
45
  },
42
- viewport: viewport,
43
- height: height,
44
- cullingVolume: cullingVolume,
45
- frameNumber: frameNumber,
46
+ viewport,
47
+ height,
48
+ cullingVolume,
49
+ frameNumber,
46
50
  sseDenominator: 1.15
47
51
  };
48
52
  }
49
53
 
50
54
  function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
51
- var frustumPlanes = viewport.getFrustumPlanes();
52
- var i = 0;
55
+ const frustumPlanes = viewport.getFrustumPlanes();
56
+ let i = 0;
53
57
 
54
- for (var dir in frustumPlanes) {
55
- var plane = frustumPlanes[dir];
56
- var distanceToCenter = plane.normal.dot(viewport.center);
58
+ for (const dir in frustumPlanes) {
59
+ const plane = frustumPlanes[dir];
60
+ const distanceToCenter = plane.normal.dot(viewport.center);
57
61
  scratchPosition.copy(plane.normal).scale(plane.distance - distanceToCenter).add(viewport.center);
58
- var cartographicPos = viewport.unprojectPosition(scratchPosition);
62
+ const cartographicPos = viewport.unprojectPosition(scratchPosition);
59
63
 
60
- var cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
64
+ const cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
61
65
 
62
66
  cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos));
63
67
  }
@@ -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,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,EAAkE;AAEvE,MAAOC,eAAP,GAA4CF,QAA5C,CAAOE,eAAP;AAAA,MAAwBC,QAAxB,GAA4CH,QAA5C,CAAwBG,QAAxB;AAAA,MAAkCC,MAAlC,GAA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K;AAQLR,IAAAA,aAAa,EAAbA,aARK;AASLK,IAAAA,WAAW,EAAXA,WATK;AAUL6B,IAAAA,cAAc,EAAE;AAVX,GAAP;AAYD;;AAED,SAASL,wBAAT,CAAkCzB,QAAlC,EAA4CU,uBAA5C,EAAqE;AAEnE,MAAMqB,aAAa,GAAG/B,QAAQ,CAACgC,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,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,QAAMI,eAAe,GAAG3C,QAAQ,CAACiB,iBAAT,CAA2BtB,eAA3B,CAAxB;;AAEA,QAAMiD,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","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,EAKt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,IAAAA,MAAM,EAAE;AACNC,MAAAA,QAAQ,EAAER,uBADJ;AAENS,MAAAA,SAAS,EAAER,wBAFL;AAGNS,MAAAA,EAAE,EAAEL;AAHE,KADH;AAMLxB,IAAAA,QANK;AAOLI,IAAAA,MAPK;AAQLR,IAAAA,aARK;AASLK,IAAAA,WATK;AAUL6B,IAAAA,cAAc,EAAE;AAVX,GAAP;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"}