@loaders.gl/tiles 3.3.0-alpha.5 → 3.3.0-alpha.6

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 (95) hide show
  1. package/dist/dist.min.js +823 -1298
  2. package/dist/es5/bundle.js +0 -1
  3. package/dist/es5/bundle.js.map +1 -1
  4. package/dist/es5/constants.js +2 -1
  5. package/dist/es5/constants.js.map +1 -1
  6. package/dist/es5/index.js +26 -36
  7. package/dist/es5/index.js.map +1 -1
  8. package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -1
  9. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -1
  10. package/dist/es5/tileset/helpers/bounding-volume.js +7 -26
  11. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
  12. package/dist/es5/tileset/helpers/frame-state.js +22 -42
  13. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  14. package/dist/es5/tileset/helpers/i3s-lod.js +0 -13
  15. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  16. package/dist/es5/tileset/helpers/tiles-3d-lod.js +7 -16
  17. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
  18. package/dist/es5/tileset/helpers/transform-utils.js +2 -11
  19. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
  20. package/dist/es5/tileset/helpers/zoom.js +6 -16
  21. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  22. package/dist/es5/tileset/tile-3d.js +95 -96
  23. package/dist/es5/tileset/tile-3d.js.map +1 -1
  24. package/dist/es5/tileset/tileset-3d.js +78 -185
  25. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  26. package/dist/es5/tileset/tileset-cache.js +1 -14
  27. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  28. package/dist/es5/tileset/traversers/i3s-pending-tiles-register.js +8 -13
  29. package/dist/es5/tileset/traversers/i3s-pending-tiles-register.js.map +1 -1
  30. package/dist/es5/tileset/traversers/i3s-tile-manager.js +20 -24
  31. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
  32. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +7 -48
  33. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  34. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +0 -22
  35. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
  36. package/dist/es5/tileset/traversers/tileset-traverser.js +53 -76
  37. package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
  38. package/dist/es5/types.js.map +1 -1
  39. package/dist/es5/utils/doubly-linked-list-node.js +3 -7
  40. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  41. package/dist/es5/utils/doubly-linked-list.js +9 -17
  42. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  43. package/dist/es5/utils/managed-array.js +29 -30
  44. package/dist/es5/utils/managed-array.js.map +1 -1
  45. package/dist/esm/bundle.js +1 -1
  46. package/dist/esm/bundle.js.map +1 -1
  47. package/dist/esm/constants.js +3 -0
  48. package/dist/esm/constants.js.map +1 -1
  49. package/dist/esm/index.js.map +1 -1
  50. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -1
  51. package/dist/esm/tileset/helpers/bounding-volume.js +4 -10
  52. package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -1
  53. package/dist/esm/tileset/helpers/frame-state.js +16 -16
  54. package/dist/esm/tileset/helpers/frame-state.js.map +1 -1
  55. package/dist/esm/tileset/helpers/i3s-lod.js +4 -4
  56. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
  57. package/dist/esm/tileset/helpers/tiles-3d-lod.js +11 -8
  58. package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +1 -1
  59. package/dist/esm/tileset/helpers/transform-utils.js +1 -3
  60. package/dist/esm/tileset/helpers/transform-utils.js.map +1 -1
  61. package/dist/esm/tileset/helpers/zoom.js +3 -2
  62. package/dist/esm/tileset/helpers/zoom.js.map +1 -1
  63. package/dist/esm/tileset/tile-3d.js +31 -107
  64. package/dist/esm/tileset/tile-3d.js.map +1 -1
  65. package/dist/esm/tileset/tileset-3d.js +21 -155
  66. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  67. package/dist/esm/tileset/tileset-cache.js +2 -18
  68. package/dist/esm/tileset/tileset-cache.js.map +1 -1
  69. package/dist/esm/tileset/traversers/i3s-pending-tiles-register.js +0 -5
  70. package/dist/esm/tileset/traversers/i3s-pending-tiles-register.js.map +1 -1
  71. package/dist/esm/tileset/traversers/i3s-tile-manager.js +2 -4
  72. package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +1 -1
  73. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +4 -17
  74. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  75. package/dist/esm/tileset/traversers/tileset-3d-traverser.js +2 -9
  76. package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +1 -1
  77. package/dist/esm/tileset/traversers/tileset-traverser.js +18 -57
  78. package/dist/esm/tileset/traversers/tileset-traverser.js.map +1 -1
  79. package/dist/esm/types.js.map +1 -1
  80. package/dist/esm/utils/doubly-linked-list-node.js +1 -4
  81. package/dist/esm/utils/doubly-linked-list-node.js.map +1 -1
  82. package/dist/esm/utils/doubly-linked-list.js +2 -11
  83. package/dist/esm/utils/doubly-linked-list.js.map +1 -1
  84. package/dist/esm/utils/managed-array.js +4 -22
  85. package/dist/esm/utils/managed-array.js.map +1 -1
  86. package/dist/tileset/helpers/frame-state.d.ts +4 -4
  87. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  88. package/dist/tileset/helpers/frame-state.js +1 -0
  89. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  90. package/dist/types.d.ts +18 -10
  91. package/dist/types.d.ts.map +1 -1
  92. package/package.json +4 -4
  93. package/src/tileset/helpers/frame-state.ts +6 -5
  94. package/src/tileset/tileset-3d.ts +2 -2
  95. package/src/types.ts +19 -10
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var moduleExports = require('./index');
4
-
5
4
  globalThis.loaders = globalThis.loaders || {};
6
5
  module.exports = Object.assign(globalThis.loaders, moduleExports);
7
6
  //# sourceMappingURL=bundle.js.map
@@ -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,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TILE3D_OPTIMIZATION_HINT = exports.LOD_METRIC_TYPE = exports.TILESET_TYPE = exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = void 0;
6
+ exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = exports.TILESET_TYPE = exports.TILE3D_OPTIMIZATION_HINT = exports.LOD_METRIC_TYPE = void 0;
7
7
  var TILE_CONTENT_STATE = {
8
8
  UNLOADED: 0,
9
9
  LOADING: 1,
@@ -34,6 +34,7 @@ var LOD_METRIC_TYPE = {
34
34
  GEOMETRIC_ERROR: 'geometricError',
35
35
  MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'
36
36
  };
37
+
37
38
  exports.LOD_METRIC_TYPE = LOD_METRIC_TYPE;
38
39
  var TILE3D_OPTIMIZATION_HINT = {
39
40
  NOT_COMPUTED: -1,
@@ -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,"file":"constants.js","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"],"sources":["../../src/constants.ts"],"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"],"mappings":";;;;;;AAAO,IAAMA,kBAAkB,GAAG;EAChCC,QAAQ,EAAE,CAAC;EACXC,OAAO,EAAE,CAAC;EACVC,UAAU,EAAE,CAAC;EACbC,KAAK,EAAE,CAAC;EACRC,OAAO,EAAE,CAAC;EACVC,MAAM,EAAE;AACV,CAAC;AAAC;AAEK,IAAMC,eAAe,GAAG;EAC7BC,GAAG,EAAE,CAAC;EACNC,OAAO,EAAE;AACX,CAAC;AAAC;AAEK,IAAMC,SAAS,GAAG;EACvBC,KAAK,EAAE,OAAO;EACdC,UAAU,EAAE,YAAY;EACxBC,UAAU,EAAE,YAAY;EACxBC,IAAI,EAAE;AACR,CAAC;AAAC;AAEK,IAAMC,YAAY,GAAG;EAC1BC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE;AACX,CAAC;AAAC;AAEK,IAAMC,eAAe,GAAG;EAC7BC,eAAe,EAAE,gBAAgB;EACjCC,oBAAoB,EAAE;AACxB,CAAC;;AAAC;AAGK,IAAMC,wBAAwB,GAAG;EACtCC,YAAY,EAAE,CAAC,CAAC;EAChBC,gBAAgB,EAAE,CAAC;EACnBC,iBAAiB,EAAE;AACrB,CAAC;AAAC"}
package/dist/es5/index.js CHANGED
@@ -1,104 +1,94 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- Object.defineProperty(exports, "Tileset3D", {
7
+ Object.defineProperty(exports, "LOD_METRIC_TYPE", {
9
8
  enumerable: true,
10
9
  get: function get() {
11
- return _tileset3d.default;
10
+ return _constants.LOD_METRIC_TYPE;
12
11
  }
13
12
  });
14
- Object.defineProperty(exports, "Tile3D", {
13
+ Object.defineProperty(exports, "TILESET_TYPE", {
15
14
  enumerable: true,
16
15
  get: function get() {
17
- return _tile3d.default;
16
+ return _constants.TILESET_TYPE;
18
17
  }
19
18
  });
20
- Object.defineProperty(exports, "TilesetTraverser", {
19
+ Object.defineProperty(exports, "TILE_CONTENT_STATE", {
21
20
  enumerable: true,
22
21
  get: function get() {
23
- return _tilesetTraverser.default;
22
+ return _constants.TILE_CONTENT_STATE;
24
23
  }
25
24
  });
26
- Object.defineProperty(exports, "TilesetCache", {
25
+ Object.defineProperty(exports, "TILE_REFINEMENT", {
27
26
  enumerable: true,
28
27
  get: function get() {
29
- return _tilesetCache.default;
28
+ return _constants.TILE_REFINEMENT;
30
29
  }
31
30
  });
32
- Object.defineProperty(exports, "createBoundingVolume", {
31
+ Object.defineProperty(exports, "TILE_TYPE", {
33
32
  enumerable: true,
34
33
  get: function get() {
35
- return _boundingVolume.createBoundingVolume;
34
+ return _constants.TILE_TYPE;
36
35
  }
37
36
  });
38
- Object.defineProperty(exports, "calculateTransformProps", {
37
+ Object.defineProperty(exports, "Tile3D", {
39
38
  enumerable: true,
40
39
  get: function get() {
41
- return _transformUtils.calculateTransformProps;
40
+ return _tile3d.default;
42
41
  }
43
42
  });
44
- Object.defineProperty(exports, "getFrameState", {
43
+ Object.defineProperty(exports, "Tileset3D", {
45
44
  enumerable: true,
46
45
  get: function get() {
47
- return _frameState.getFrameState;
46
+ return _tileset3d.default;
48
47
  }
49
48
  });
50
- Object.defineProperty(exports, "getLodStatus", {
49
+ Object.defineProperty(exports, "TilesetCache", {
51
50
  enumerable: true,
52
51
  get: function get() {
53
- return _i3sLod.getLodStatus;
52
+ return _tilesetCache.default;
54
53
  }
55
54
  });
56
- Object.defineProperty(exports, "TILE_CONTENT_STATE", {
55
+ Object.defineProperty(exports, "TilesetTraverser", {
57
56
  enumerable: true,
58
57
  get: function get() {
59
- return _constants.TILE_CONTENT_STATE;
58
+ return _tilesetTraverser.default;
60
59
  }
61
60
  });
62
- Object.defineProperty(exports, "TILE_REFINEMENT", {
61
+ Object.defineProperty(exports, "calculateTransformProps", {
63
62
  enumerable: true,
64
63
  get: function get() {
65
- return _constants.TILE_REFINEMENT;
64
+ return _transformUtils.calculateTransformProps;
66
65
  }
67
66
  });
68
- Object.defineProperty(exports, "TILE_TYPE", {
67
+ Object.defineProperty(exports, "createBoundingVolume", {
69
68
  enumerable: true,
70
69
  get: function get() {
71
- return _constants.TILE_TYPE;
70
+ return _boundingVolume.createBoundingVolume;
72
71
  }
73
72
  });
74
- Object.defineProperty(exports, "TILESET_TYPE", {
73
+ Object.defineProperty(exports, "getFrameState", {
75
74
  enumerable: true,
76
75
  get: function get() {
77
- return _constants.TILESET_TYPE;
76
+ return _frameState.getFrameState;
78
77
  }
79
78
  });
80
- Object.defineProperty(exports, "LOD_METRIC_TYPE", {
79
+ Object.defineProperty(exports, "getLodStatus", {
81
80
  enumerable: true,
82
81
  get: function get() {
83
- return _constants.LOD_METRIC_TYPE;
82
+ return _i3sLod.getLodStatus;
84
83
  }
85
84
  });
86
-
87
85
  var _tileset3d = _interopRequireDefault(require("./tileset/tileset-3d"));
88
-
89
86
  var _tile3d = _interopRequireDefault(require("./tileset/tile-3d"));
90
-
91
87
  var _tilesetTraverser = _interopRequireDefault(require("./tileset/traversers/tileset-traverser"));
92
-
93
88
  var _tilesetCache = _interopRequireDefault(require("./tileset/tileset-cache"));
94
-
95
89
  var _boundingVolume = require("./tileset/helpers/bounding-volume");
96
-
97
90
  var _transformUtils = require("./tileset/helpers/transform-utils");
98
-
99
91
  var _frameState = require("./tileset/helpers/frame-state");
100
-
101
92
  var _i3sLod = require("./tileset/helpers/i3s-lod");
102
-
103
93
  var _constants = require("./constants");
104
94
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AAEA"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.get3dTilesOptions = get3dTilesOptions;
7
-
8
7
  function get3dTilesOptions(tileset) {
9
8
  return {
10
9
  assetGltfUpAxis: tileset.asset && tileset.asset.gltfUpAxis || 'Y'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/3d-tiles-options.ts"],"names":["get3dTilesOptions","tileset","assetGltfUpAxis","asset","gltfUpAxis"],"mappings":";;;;;;;AAAO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoC;AACzC,SAAO;AACLC,IAAAA,eAAe,EAAGD,OAAO,CAACE,KAAR,IAAiBF,OAAO,CAACE,KAAR,CAAcC,UAAhC,IAA+C;AAD3D,GAAP;AAGD","sourcesContent":["export function get3dTilesOptions(tileset) {\n return {\n assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'\n };\n}\n"],"file":"3d-tiles-options.js"}
1
+ {"version":3,"file":"3d-tiles-options.js","names":["get3dTilesOptions","tileset","assetGltfUpAxis","asset","gltfUpAxis"],"sources":["../../../../src/tileset/helpers/3d-tiles-options.ts"],"sourcesContent":["export function get3dTilesOptions(tileset) {\n return {\n assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'\n };\n}\n"],"mappings":";;;;;;AAAO,SAASA,iBAAiB,CAACC,OAAO,EAAE;EACzC,OAAO;IACLC,eAAe,EAAGD,OAAO,CAACE,KAAK,IAAIF,OAAO,CAACE,KAAK,CAACC,UAAU,IAAK;EAClE,CAAC;AACH"}
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createBoundingVolume = createBoundingVolume;
9
-
10
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
10
  var _core = require("@math.gl/core");
15
-
16
11
  var _culling = require("@math.gl/culling");
17
-
18
12
  var _geospatial = require("@math.gl/geospatial");
19
-
20
13
  var _loaderUtils = require("@loaders.gl/loader-utils");
21
14
 
22
15
  function defined(x) {
@@ -33,37 +26,30 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
33
26
  if (boundingVolumeHeader.box) {
34
27
  return createBox(boundingVolumeHeader.box, transform, result);
35
28
  }
36
-
37
29
  if (boundingVolumeHeader.region) {
38
30
  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];
45
-
31
+ west = _boundingVolumeHeader[0],
32
+ south = _boundingVolumeHeader[1],
33
+ east = _boundingVolumeHeader[2],
34
+ north = _boundingVolumeHeader[3],
35
+ minHeight = _boundingVolumeHeader[4],
36
+ maxHeight = _boundingVolumeHeader[5];
46
37
  var northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
47
-
48
38
  var southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
49
-
50
39
  var centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
51
40
  var radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
41
+
52
42
  return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
53
43
  }
54
-
55
44
  if (boundingVolumeHeader.sphere) {
56
45
  return createSphere(boundingVolumeHeader.sphere, transform, result);
57
46
  }
58
-
59
47
  throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
60
48
  }
61
-
62
49
  function createBox(box, transform, result) {
63
50
  var center = new _core.Vector3(box[0], box[1], box[2]);
64
51
  transform.transform(center, center);
65
52
  var origin = [];
66
-
67
53
  if (box.length === 10) {
68
54
  var halfSize = box.slice(3, 6);
69
55
  var quaternion = new _core.Quaternion();
@@ -81,18 +67,15 @@ function createBox(box, transform, result) {
81
67
  } else {
82
68
  origin = [].concat((0, _toConsumableArray2.default)(box.slice(3, 6)), (0, _toConsumableArray2.default)(box.slice(6, 9)), (0, _toConsumableArray2.default)(box.slice(9, 12)));
83
69
  }
84
-
85
70
  var xAxis = transform.transformAsVector(origin.slice(0, 3));
86
71
  var yAxis = transform.transformAsVector(origin.slice(3, 6));
87
72
  var zAxis = transform.transformAsVector(origin.slice(6, 9));
88
73
  var halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
89
-
90
74
  if (defined(result)) {
91
75
  result.center = center;
92
76
  result.halfAxes = halfAxes;
93
77
  return result;
94
78
  }
95
-
96
79
  return new _culling.OrientedBoundingBox(center, halfAxes);
97
80
  }
98
81
 
@@ -102,13 +85,11 @@ function createSphere(sphere, transform, result) {
102
85
  var scale = transform.getScale(scratchScale);
103
86
  var uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
104
87
  var radius = sphere[3] * uniformScale;
105
-
106
88
  if (defined(result)) {
107
89
  result.center = center;
108
90
  result.radius = radius;
109
91
  return result;
110
92
  }
111
-
112
93
  return new _culling.BoundingSphere(center, radius);
113
94
  }
114
95
  //# sourceMappingURL=bounding-volume.js.map
@@ -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","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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CAACyB,MAAP,GAAgBA,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"}
1
+ {"version":3,"file":"bounding-volume.js","names":["defined","x","undefined","scratchScale","Vector3","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","assert","box","createBox","region","west","south","east","north","minHeight","maxHeight","northWest","Ellipsoid","WGS84","cartographicToCartesian","degrees","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"],"sources":["../../../../src/tileset/helpers/bounding-volume.ts"],"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"],"mappings":";;;;;;;;;AAIA;AACA;AACA;AACA;;AAIA,SAASA,OAAO,CAACC,CAAC,EAAE;EAClB,OAAOA,CAAC,KAAKC,SAAS,IAAID,CAAC,KAAK,IAAI;AACtC;;AAGA,IAAME,YAAY,GAAG,IAAIC,aAAO,EAAE;AAClC,IAAMC,gBAAgB,GAAG,IAAID,aAAO,EAAE;AACtC,IAAME,gBAAgB,GAAG,IAAIF,aAAO,EAAE;;AAY/B,SAASG,oBAAoB,CAACC,oBAAoB,EAAEC,SAAS,EAAEC,MAAM,EAAE;EAC5E,IAAAC,mBAAM,EAACH,oBAAoB,EAAE,yCAAyC,CAAC;;EAIvE,IAAIA,oBAAoB,CAACI,GAAG,EAAE;IAC5B,OAAOC,SAAS,CAACL,oBAAoB,CAACI,GAAG,EAAEH,SAAS,EAAEC,MAA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,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,CAAC,CAAC;EAC3D1B,SAAS,CAACA,SAAS,CAAC4B,MAAM,EAAEA,MAAM,CAAC;EACnC,IAAMW,KAAK,GAAGvC,SAAS,CAACgD,QAAQ,CAACtD,YAAY,CAAC;EAE9C,IAAMuD,YAAY,GAAGC,IAAI,CAACC,GAAG,CAACD,IAAI,CAACC,GAAG,CAACZ,KAAK,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,CAAC;EACrE,IAAMlB,MAAM,GAAGK,MAAM,CAAC,CAAC,CAAC,GAAGuB,YAAY;EAEvC,IAAI1D,OAAO,CAACU,MAAM,CAAC,EAAE;IACnBA,MAAM,CAAC2B,MAAM,GAAGA,MAAM;IACtB3B,MAAM,CAACoB,MAAM,GAAGA,MAAM;IACtB,OAAOpB,MAAM;EACf;EAEA,OAAO,IAAImD,uBAAc,CAACxB,MAAM,EAAEP,MAAM,CAAC;AAC3C"}
@@ -1,53 +1,44 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getFrameState = getFrameState;
9
8
  exports.limitSelectedTiles = limitSelectedTiles;
10
-
11
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
-
13
10
  var _core = require("@math.gl/core");
14
-
15
11
  var _culling = require("@math.gl/culling");
16
-
17
12
  var _geospatial = require("@math.gl/geospatial");
18
-
19
13
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
20
-
21
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
-
23
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
-
25
16
  var scratchVector = new _core.Vector3();
26
17
  var scratchPosition = new _core.Vector3();
27
18
  var cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
28
19
 
29
20
  function getFrameState(viewport, frameNumber) {
30
21
  var cameraDirection = viewport.cameraDirection,
31
- cameraUp = viewport.cameraUp,
32
- height = viewport.height;
22
+ cameraUp = viewport.cameraUp,
23
+ height = viewport.height;
33
24
  var metersPerUnit = viewport.distanceScales.metersPerUnit;
34
- var viewportCenterCartesian = worldToCartesian(viewport, viewport.center);
35
25
 
26
+ var viewportCenterCartesian = worldToCartesian(viewport, viewport.center);
36
27
  var enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
37
-
38
28
  var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
39
-
40
29
  var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
41
30
 
42
- var cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
43
- var cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
31
+ var cameraDirectionCartesian = new _core.Vector3(
32
+ enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
33
+ var cameraUpCartesian = new _core.Vector3(
34
+ enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
44
35
  commonSpacePlanesToWGS84(viewport);
45
36
  var ViewportClass = viewport.constructor;
46
37
  var longitude = viewport.longitude,
47
- latitude = viewport.latitude,
48
- width = viewport.width,
49
- bearing = viewport.bearing,
50
- zoom = viewport.zoom;
38
+ latitude = viewport.latitude,
39
+ width = viewport.width,
40
+ bearing = viewport.bearing,
41
+ zoom = viewport.zoom;
51
42
  var topDownViewport = new ViewportClass({
52
43
  longitude: longitude,
53
44
  latitude: latitude,
@@ -57,6 +48,7 @@ function getFrameState(viewport, frameNumber) {
57
48
  zoom: zoom,
58
49
  pitch: 0
59
50
  });
51
+
60
52
  return {
61
53
  camera: {
62
54
  position: cameraPositionCartesian,
@@ -76,25 +68,20 @@ function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
76
68
  if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {
77
69
  return [tiles, []];
78
70
  }
79
-
80
71
  var tuples = [];
81
72
  var _frameState$viewport = frameState.viewport,
82
- viewportLongitude = _frameState$viewport.longitude,
83
- viewportLatitude = _frameState$viewport.latitude;
84
-
73
+ viewportLongitude = _frameState$viewport.longitude,
74
+ viewportLatitude = _frameState$viewport.latitude;
85
75
  var _iterator = _createForOfIteratorHelper(tiles.entries()),
86
- _step;
87
-
76
+ _step;
88
77
  try {
89
78
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
90
79
  var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
91
- index = _step$value[0],
92
- tile = _step$value[1];
93
-
80
+ index = _step$value[0],
81
+ tile = _step$value[1];
94
82
  var _tile$header$mbs = (0, _slicedToArray2.default)(tile.header.mbs, 2),
95
- longitude = _tile$header$mbs[0],
96
- latitude = _tile$header$mbs[1];
97
-
83
+ longitude = _tile$header$mbs[0],
84
+ latitude = _tile$header$mbs[1];
98
85
  var deltaLon = Math.abs(viewportLongitude - longitude);
99
86
  var deltaLat = Math.abs(viewportLatitude - latitude);
100
87
  var distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);
@@ -105,33 +92,27 @@ function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
105
92
  } finally {
106
93
  _iterator.f();
107
94
  }
108
-
109
95
  var tuplesSorted = tuples.sort(function (a, b) {
110
96
  return a[1] - b[1];
111
97
  });
112
98
  var selectedTiles = [];
113
-
114
99
  for (var i = 0; i < maximumTilesSelected; i++) {
115
100
  selectedTiles.push(tiles[tuplesSorted[i][0]]);
116
101
  }
117
-
118
102
  var unselectedTiles = [];
119
-
120
103
  for (var _i = maximumTilesSelected; _i < tuplesSorted.length; _i++) {
121
104
  unselectedTiles.push(tiles[tuplesSorted[_i][0]]);
122
105
  }
123
-
124
106
  return [selectedTiles, unselectedTiles];
125
107
  }
126
-
127
108
  function commonSpacePlanesToWGS84(viewport) {
128
109
  var frustumPlanes = viewport.getFrustumPlanes();
110
+
129
111
  var nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);
130
112
  var nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);
131
113
  var cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);
132
114
  var i = 0;
133
115
  cullingVolume.planes[i++].fromPointNormal(nearCenterCartesian, scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian));
134
-
135
116
  for (var dir in frustumPlanes) {
136
117
  if (dir === 'near') {
137
118
  continue;
@@ -140,17 +121,16 @@ function commonSpacePlanesToWGS84(viewport) {
140
121
  var plane = frustumPlanes[dir];
141
122
  var posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);
142
123
  var cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);
143
- cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(nearCenterCartesian).subtract(cartesianPos));
124
+ cullingVolume.planes[i++].fromPointNormal(cartesianPos,
125
+ scratchVector.copy(nearCenterCartesian).subtract(cartesianPos));
144
126
  }
145
127
  }
146
-
147
128
  function closestPointOnPlane(plane, refPoint) {
148
129
  var out = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _core.Vector3();
149
130
  var distanceToRef = plane.normal.dot(refPoint);
150
131
  out.copy(plane.normal).scale(plane.distance - distanceToRef).add(refPoint);
151
132
  return out;
152
133
  }
153
-
154
134
  function worldToCartesian(viewport, point) {
155
135
  var out = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _core.Vector3();
156
136
  var cartographicPos = viewport.unprojectPosition(point);
@@ -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","viewportCenterCartesian","worldToCartesian","center","enuToFixedTransform","Ellipsoid","WGS84","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cartographicToCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","ViewportClass","constructor","longitude","latitude","width","bearing","zoom","topDownViewport","pitch","camera","position","direction","up","sseDenominator","limitSelectedTiles","tiles","frameState","maximumTilesSelected","length","tuples","viewportLongitude","viewportLatitude","entries","index","tile","header","mbs","deltaLon","Math","abs","deltaLat","distance","sqrt","push","tuplesSorted","sort","a","b","selectedTiles","i","unselectedTiles","frustumPlanes","getFrustumPlanes","nearCenterCommon","closestPointOnPlane","near","nearCenterCartesian","cameraCartesian","planes","fromPointNormal","copy","subtract","dir","plane","posCommon","cartesianPos","refPoint","out","distanceToRef","normal","dot","add","point","cartographicPos"],"mappings":";;;;;;;;;;;;AACA;;AACA;;AACA;;;;;;;;AAiBA,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,EAA2CC,WAA3C,EAA4E;AAEjF,MAAOC,eAAP,GAA4CF,QAA5C,CAAOE,eAAP;AAAA,MAAwBC,QAAxB,GAA4CH,QAA5C,CAAwBG,QAAxB;AAAA,MAAkCC,MAAlC,GAA4CJ,QAA5C,CAAkCI,MAAlC;AACA,MAAOC,aAAP,GAAwBL,QAAQ,CAACM,cAAjC,CAAOD,aAAP;AAIA,MAAME,uBAAuB,GAAGC,gBAAgB,CAACR,QAAD,EAAWA,QAAQ,CAACS,MAApB,CAAhD;;AACA,MAAMC,mBAAmB,GAAGC,sBAAUC,KAAV,CAAgBC,uBAAhB,CAAwCN,uBAAxC,CAA5B;;AAEA,MAAMO,0BAA0B,GAAGd,QAAQ,CAACe,iBAAT,CAA2Bf,QAAQ,CAACgB,cAApC,CAAnC;;AACA,MAAMC,uBAAuB,GAAGN,sBAAUC,KAAV,CAAgBM,uBAAhB,CAC9BJ,0BAD8B,EAE9B,IAAIpB,aAAJ,EAF8B,CAAhC;;AAMA,MAAMyB,wBAAwB,GAAG,IAAI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D;;AACD,QAAMC,KAAK,GAAGZ,aAAa,CAACW,GAAD,CAA3B;AACA,QAAME,SAAS,GAAGV,mBAAmB,CAACS,KAAD,EAAQV,gBAAR,EAA0BzE,eAA1B,CAArC;AACA,QAAMqF,YAAY,GAAGxE,gBAAgB,CAACR,QAAD,EAAW+E,SAAX,EAAsBpF,eAAtB,CAArC;AAEAC,IAAAA,aAAa,CAAC6E,MAAd,CAAqBT,CAAC,EAAtB,EAA0BU,eAA1B,CACEM,YADF,EAGEvF,aAAa,CAACkF,IAAd,CAAmBJ,mBAAnB,EAAwCK,QAAxC,CAAiDI,YAAjD,CAHF;AAKD;AACF;;AAED,SAASX,mBAAT,CACES,KADF,EAEEG,QAFF,EAIW;AAAA,MADTC,GACS,uEADM,IAAIxF,aAAJ,EACN;AACT,MAAMyF,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAaC,GAAb,CAAiBJ,QAAjB,CAAtB;AACAC,EAAAA,GAAG,CACAP,IADH,CACQG,KAAK,CAACM,MADd,EAEG/D,KAFH,CAESyD,KAAK,CAACtB,QAAN,GAAiB2B,aAF1B,EAGGG,GAHH,CAGOL,QAHP;AAIA,SAAOC,GAAP;AACD;;AAED,SAAS1E,gBAAT,CACER,QADF,EAEEuF,KAFF,EAIW;AAAA,MADTL,GACS,uEADM,IAAIxF,aAAJ,EACN;AACT,MAAM8F,eAAe,GAAGxF,QAAQ,CAACe,iBAAT,CAA2BwE,KAA3B,CAAxB;AACA,SAAO5E,sBAAUC,KAAV,CAAgBM,uBAAhB,CAAwCsE,eAAxC,EAAyDN,GAAzD,CAAP;AACD","sourcesContent":["import {Tile3D} from '@loaders.gl/tiles';\nimport {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Viewport} from '../../types';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: Viewport;\n topDownViewport: Viewport; // Use it to calculate projected radius for a tile\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: 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 // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);\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);\n\n const ViewportClass = viewport.constructor;\n const {longitude, latitude, width, bearing, zoom} = viewport;\n // @ts-ignore\n const topDownViewport = new ViewportClass({\n longitude,\n latitude,\n height,\n width,\n bearing,\n zoom,\n pitch: 0\n });\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 topDownViewport,\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\n/**\n * Limit `tiles` array length with `maximumTilesSelected` number.\n * The criteria for this filtering is distance of a tile center\n * to the `frameState.viewport`'s longitude and latitude\n * @param tiles - tiles array to filter\n * @param frameState - frameState to calculate distances\n * @param maximumTilesSelected - maximal amount of tiles in the output array\n * @returns new tiles array\n */\nexport function limitSelectedTiles(\n tiles: Tile3D[],\n frameState: FrameState,\n maximumTilesSelected: number\n): [Tile3D[], Tile3D[]] {\n if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {\n return [tiles, []];\n }\n // Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]\n const tuples: [number, number][] = [];\n const {longitude: viewportLongitude, latitude: viewportLatitude} = frameState.viewport;\n for (const [index, tile] of tiles.entries()) {\n const [longitude, latitude] = tile.header.mbs;\n const deltaLon = Math.abs(viewportLongitude - longitude);\n const deltaLat = Math.abs(viewportLatitude - latitude);\n const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);\n tuples.push([index, distance]);\n }\n const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);\n const selectedTiles: Tile3D[] = [];\n for (let i = 0; i < maximumTilesSelected; i++) {\n selectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n const unselectedTiles: Tile3D[] = [];\n for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {\n unselectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n\n return [selectedTiles, unselectedTiles];\n}\n\nfunction commonSpacePlanesToWGS84(viewport) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n\n // Get the near/far plane centers\n const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);\n const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);\n const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);\n\n let i = 0;\n cullingVolume.planes[i++].fromPointNormal(\n nearCenterCartesian,\n scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian)\n );\n\n for (const dir in frustumPlanes) {\n if (dir === 'near') {\n continue; // eslint-disable-line no-continue\n }\n const plane = frustumPlanes[dir];\n const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);\n const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);\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(nearCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n\nfunction closestPointOnPlane(\n plane: {distance: number; normal: Vector3},\n refPoint: [number, number, number] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const distanceToRef = plane.normal.dot(refPoint);\n out\n .copy(plane.normal)\n .scale(plane.distance - distanceToRef)\n .add(refPoint);\n return out;\n}\n\nfunction worldToCartesian(\n viewport: Viewport,\n point: [number, number, number] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const cartographicPos = viewport.unprojectPosition(point);\n return Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);\n}\n"],"file":"frame-state.js"}
1
+ {"version":3,"file":"frame-state.js","names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartesian","worldToCartesian","center","enuToFixedTransform","Ellipsoid","WGS84","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cartographicToCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","ViewportClass","constructor","longitude","latitude","width","bearing","zoom","topDownViewport","pitch","camera","position","direction","up","sseDenominator","limitSelectedTiles","tiles","frameState","maximumTilesSelected","length","tuples","viewportLongitude","viewportLatitude","entries","index","tile","header","mbs","deltaLon","Math","abs","deltaLat","distance","sqrt","push","tuplesSorted","sort","a","b","selectedTiles","i","unselectedTiles","frustumPlanes","getFrustumPlanes","nearCenterCommon","closestPointOnPlane","near","nearCenterCartesian","cameraCartesian","planes","fromPointNormal","copy","subtract","dir","plane","posCommon","cartesianPos","refPoint","out","distanceToRef","normal","dot","add","point","cartographicPos"],"sources":["../../../../src/tileset/helpers/frame-state.ts"],"sourcesContent":["import {Tile3D} from '@loaders.gl/tiles';\nimport {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {GeospatialViewport, Viewport} from '../../types';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: GeospatialViewport;\n topDownViewport: GeospatialViewport; // Use it to calculate projected radius for a tile\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: GeospatialViewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\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 // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);\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);\n\n const ViewportClass = viewport.constructor;\n const {longitude, latitude, width, bearing, zoom} = viewport;\n // @ts-ignore\n const topDownViewport = new ViewportClass({\n longitude,\n latitude,\n height,\n width,\n bearing,\n zoom,\n pitch: 0\n });\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 topDownViewport,\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\n/**\n * Limit `tiles` array length with `maximumTilesSelected` number.\n * The criteria for this filtering is distance of a tile center\n * to the `frameState.viewport`'s longitude and latitude\n * @param tiles - tiles array to filter\n * @param frameState - frameState to calculate distances\n * @param maximumTilesSelected - maximal amount of tiles in the output array\n * @returns new tiles array\n */\nexport function limitSelectedTiles(\n tiles: Tile3D[],\n frameState: FrameState,\n maximumTilesSelected: number\n): [Tile3D[], Tile3D[]] {\n if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {\n return [tiles, []];\n }\n // Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]\n const tuples: [number, number][] = [];\n const {longitude: viewportLongitude, latitude: viewportLatitude} = frameState.viewport;\n for (const [index, tile] of tiles.entries()) {\n const [longitude, latitude] = tile.header.mbs;\n const deltaLon = Math.abs(viewportLongitude - longitude);\n const deltaLat = Math.abs(viewportLatitude - latitude);\n const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);\n tuples.push([index, distance]);\n }\n const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);\n const selectedTiles: Tile3D[] = [];\n for (let i = 0; i < maximumTilesSelected; i++) {\n selectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n const unselectedTiles: Tile3D[] = [];\n for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {\n unselectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n\n return [selectedTiles, unselectedTiles];\n}\n\nfunction commonSpacePlanesToWGS84(viewport) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n\n // Get the near/far plane centers\n const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);\n const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);\n const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);\n\n let i = 0;\n cullingVolume.planes[i++].fromPointNormal(\n nearCenterCartesian,\n scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian)\n );\n\n for (const dir in frustumPlanes) {\n if (dir === 'near') {\n continue; // eslint-disable-line no-continue\n }\n const plane = frustumPlanes[dir];\n const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);\n const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);\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(nearCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n\nfunction closestPointOnPlane(\n plane: {distance: number; normal: Vector3},\n refPoint: [number, number, number] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const distanceToRef = plane.normal.dot(refPoint);\n out\n .copy(plane.normal)\n .scale(plane.distance - distanceToRef)\n .add(refPoint);\n return out;\n}\n\nfunction worldToCartesian(\n viewport: Viewport,\n point: number[] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const cartographicPos = viewport.unprojectPosition(point);\n return Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);\n}\n"],"mappings":";;;;;;;;;AACA;AACA;AACA;AAA8C;AAAA;AAAA;AAiB9C,IAAMA,aAAa,GAAG,IAAIC,aAAO,EAAE;AACnC,IAAMC,eAAe,GAAG,IAAID,aAAO,EAAE;AACrC,IAAME,aAAa,GAAG,IAAIC,sBAAa,CAAC,CACtC,IAAIC,cAAK,EAAE,EACX,IAAIA,cAAK,EAAE,EACX,IAAIA,cAAK,EAAE,EACX,IAAIA,cAAK,EAAE,EACX,IAAIA,cAAK,EAAE,EACX,IAAIA,cAAK,EAAE,CACZ,CAAC;;AAIK,SAASC,aAAa,CAACC,QAA4B,EAAEC,WAAmB,EAAc;EAG3F,IAAOC,eAAe,GAAsBF,QAAQ,CAA7CE,eAAe;IAAEC,QAAQ,GAAYH,QAAQ,CAA5BG,QAAQ;IAAEC,MAAM,GAAIJ,QAAQ,CAAlBI,MAAM;EACxC,IAAOC,aAAa,GAAIL,QAAQ,CAACM,cAAc,CAAxCD,aAAa;;EAIpB,IAAME,uBAAuB,GAAGC,gBAAgB,CAACR,QAAQ,EAAEA,QAAQ,CAACS,MAAM,CAAC;EAC3E,IAAMC,mBAAmB,GAAGC,qBAAS,CAACC,KAAK,CAACC,uBAAuB,CAACN,uBAAuB,CAAC;EAE5F,IAAMO,0BAA0B,GAAGd,QAAQ,CAACe,iBAAiB,CAACf,QAAQ,CAACgB,cAAc,CAAC;EACtF,IAAMC,uBAAuB,GAAGN,qBAAS,CAACC,KAAK,CAACM,uBAAuB,CACrEJ,0BAA0B,EAC1B,IAAIpB,aAAO,EAAE,CACd;;EAGD,IAAMyB,wBAAwB,GAAG,IAAIzB,aAAO;EAE1CgB,mBAAmB,CAACU,iBAAiB,CAAC,IAAI1B,aAAO,CAACQ,eAAe,CAAC,C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