@loaders.gl/tiles 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (201) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/constants.d.ts +6 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +29 -26
  5. package/dist/dist.min.js +1994 -1035
  6. package/dist/es5/bundle.js +6 -0
  7. package/dist/es5/bundle.js.map +1 -0
  8. package/dist/es5/constants.js +44 -0
  9. package/dist/es5/constants.js.map +1 -0
  10. package/dist/es5/index.js +93 -0
  11. package/dist/es5/index.js.map +1 -0
  12. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +70 -0
  13. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  14. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +45 -0
  15. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  16. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +84 -0
  17. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  18. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +143 -0
  19. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  20. package/dist/es5/tileset/helpers/3d-tiles-options.js +12 -0
  21. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -0
  22. package/dist/es5/tileset/helpers/bounding-volume.js +176 -0
  23. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -0
  24. package/dist/es5/tileset/helpers/frame-state.js +129 -0
  25. package/dist/es5/tileset/helpers/frame-state.js.map +1 -0
  26. package/dist/es5/tileset/helpers/i3s-lod.js +60 -0
  27. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -0
  28. package/dist/es5/tileset/helpers/tiles-3d-lod.js +103 -0
  29. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -0
  30. package/dist/es5/tileset/helpers/transform-utils.js +50 -0
  31. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -0
  32. package/dist/es5/tileset/helpers/zoom.js +63 -0
  33. package/dist/es5/tileset/helpers/zoom.js.map +1 -0
  34. package/dist/es5/tileset/tile-3d.js +536 -0
  35. package/dist/es5/tileset/tile-3d.js.map +1 -0
  36. package/dist/es5/tileset/tileset-3d.js +855 -0
  37. package/dist/es5/tileset/tileset-3d.js.map +1 -0
  38. package/dist/es5/tileset/tileset-cache.js +82 -0
  39. package/dist/es5/tileset/tileset-cache.js.map +1 -0
  40. package/dist/es5/tileset/tileset-traverser.js +321 -0
  41. package/dist/es5/tileset/tileset-traverser.js.map +1 -0
  42. package/dist/es5/types.js +2 -0
  43. package/dist/es5/types.js.map +1 -0
  44. package/dist/es5/utils/doubly-linked-list-node.js +21 -0
  45. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -0
  46. package/dist/es5/utils/doubly-linked-list.js +88 -0
  47. package/dist/es5/utils/doubly-linked-list.js.map +1 -0
  48. package/dist/es5/utils/managed-array.js +126 -0
  49. package/dist/es5/utils/managed-array.js.map +1 -0
  50. package/dist/esm/bundle.js +4 -0
  51. package/dist/esm/bundle.js.map +1 -0
  52. package/dist/esm/constants.js +32 -0
  53. package/dist/esm/constants.js.map +1 -0
  54. package/dist/esm/index.js +10 -0
  55. package/dist/esm/index.js.map +1 -0
  56. package/dist/{tileset/traversers → esm/tileset/format-3d-tiles}/tileset-3d-traverser.js +2 -13
  57. package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  58. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js +26 -0
  59. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  60. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js +79 -0
  61. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  62. package/dist/{tileset/traversers → esm/tileset/format-i3s}/i3s-tileset-traverser.js +14 -26
  63. package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  64. package/dist/esm/tileset/helpers/3d-tiles-options.js +6 -0
  65. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -0
  66. package/dist/esm/tileset/helpers/bounding-volume.js +155 -0
  67. package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -0
  68. package/dist/esm/tileset/helpers/frame-state.js +109 -0
  69. package/dist/esm/tileset/helpers/frame-state.js.map +1 -0
  70. package/dist/esm/tileset/helpers/i3s-lod.js +53 -0
  71. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -0
  72. package/dist/esm/tileset/helpers/tiles-3d-lod.js +100 -0
  73. package/dist/{tileset → esm/tileset}/helpers/tiles-3d-lod.js.map +1 -1
  74. package/dist/esm/tileset/helpers/transform-utils.js +50 -0
  75. package/dist/esm/tileset/helpers/transform-utils.js.map +1 -0
  76. package/dist/esm/tileset/helpers/zoom.js +55 -0
  77. package/dist/esm/tileset/helpers/zoom.js.map +1 -0
  78. package/dist/esm/tileset/tile-3d.js +414 -0
  79. package/dist/esm/tileset/tile-3d.js.map +1 -0
  80. package/dist/esm/tileset/tileset-3d.js +606 -0
  81. package/dist/esm/tileset/tileset-3d.js.map +1 -0
  82. package/dist/esm/tileset/tileset-cache.js +57 -0
  83. package/dist/esm/tileset/tileset-cache.js.map +1 -0
  84. package/dist/{tileset/traversers → esm/tileset}/tileset-traverser.js +29 -88
  85. package/dist/esm/tileset/tileset-traverser.js.map +1 -0
  86. package/dist/esm/types.js +2 -0
  87. package/dist/esm/types.js.map +1 -0
  88. package/dist/esm/utils/doubly-linked-list-node.js +12 -0
  89. package/dist/esm/utils/doubly-linked-list-node.js.map +1 -0
  90. package/dist/esm/utils/doubly-linked-list.js +65 -0
  91. package/dist/esm/utils/doubly-linked-list.js.map +1 -0
  92. package/dist/esm/utils/managed-array.js +87 -0
  93. package/dist/esm/utils/managed-array.js.map +1 -0
  94. package/dist/index.d.ts +4 -4
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +26 -10
  97. package/dist/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.d.ts +2 -2
  98. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -0
  99. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +54 -0
  100. package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts +27 -0
  101. package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts.map +1 -0
  102. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +47 -0
  103. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts +34 -0
  104. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts.map +1 -0
  105. package/dist/tileset/format-i3s/i3s-tile-manager.js +80 -0
  106. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts +25 -0
  107. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts.map +1 -0
  108. package/dist/tileset/format-i3s/i3s-tileset-traverser.js +92 -0
  109. package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -2
  110. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
  111. package/dist/tileset/helpers/3d-tiles-options.js +8 -5
  112. package/dist/tileset/helpers/bounding-volume.d.ts +10 -0
  113. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
  114. package/dist/tileset/helpers/bounding-volume.js +274 -69
  115. package/dist/tileset/helpers/frame-state.d.ts +16 -5
  116. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  117. package/dist/tileset/helpers/frame-state.js +131 -49
  118. package/dist/tileset/helpers/i3s-lod.d.ts +1 -1
  119. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
  120. package/dist/tileset/helpers/i3s-lod.js +82 -64
  121. package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -1
  122. package/dist/tileset/helpers/tiles-3d-lod.js +112 -100
  123. package/dist/tileset/helpers/transform-utils.d.ts.map +1 -1
  124. package/dist/tileset/helpers/transform-utils.js +51 -56
  125. package/dist/tileset/helpers/zoom.d.ts +41 -2
  126. package/dist/tileset/helpers/zoom.d.ts.map +1 -1
  127. package/dist/tileset/helpers/zoom.js +83 -30
  128. package/dist/tileset/tile-3d.d.ts +82 -35
  129. package/dist/tileset/tile-3d.d.ts.map +1 -1
  130. package/dist/tileset/tile-3d.js +607 -534
  131. package/dist/tileset/tileset-3d.d.ts +140 -48
  132. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  133. package/dist/tileset/tileset-3d.js +693 -652
  134. package/dist/tileset/tileset-cache.d.ts +6 -5
  135. package/dist/tileset/tileset-cache.d.ts.map +1 -1
  136. package/dist/tileset/tileset-cache.js +66 -73
  137. package/dist/tileset/tileset-traverser.d.ts +57 -0
  138. package/dist/tileset/tileset-traverser.d.ts.map +1 -0
  139. package/dist/tileset/tileset-traverser.js +300 -0
  140. package/dist/types.d.ts +34 -0
  141. package/dist/types.d.ts.map +1 -0
  142. package/dist/types.js +2 -0
  143. package/dist/utils/doubly-linked-list-node.d.ts +1 -2
  144. package/dist/utils/doubly-linked-list-node.d.ts.map +1 -1
  145. package/dist/utils/doubly-linked-list-node.js +17 -15
  146. package/dist/utils/doubly-linked-list.d.ts +2 -3
  147. package/dist/utils/doubly-linked-list.d.ts.map +1 -1
  148. package/dist/utils/doubly-linked-list.js +91 -75
  149. package/dist/utils/managed-array.d.ts +1 -1
  150. package/dist/utils/managed-array.d.ts.map +1 -1
  151. package/dist/utils/managed-array.js +144 -109
  152. package/package.json +11 -8
  153. package/src/constants.ts +20 -0
  154. package/src/index.ts +6 -4
  155. package/src/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.ts +4 -2
  156. package/src/tileset/format-i3s/i3s-pending-tiles-register.ts +44 -0
  157. package/src/tileset/format-i3s/i3s-tile-manager.ts +101 -0
  158. package/src/tileset/{traversers → format-i3s}/i3s-tileset-traverser.ts +25 -12
  159. package/src/tileset/helpers/3d-tiles-options.ts +3 -1
  160. package/src/tileset/helpers/bounding-volume.ts +136 -0
  161. package/src/tileset/helpers/frame-state.ts +102 -18
  162. package/src/tileset/helpers/i3s-lod.ts +24 -21
  163. package/src/tileset/helpers/tiles-3d-lod.ts +2 -0
  164. package/src/tileset/helpers/transform-utils.ts +2 -0
  165. package/src/tileset/helpers/zoom.ts +84 -9
  166. package/src/tileset/tile-3d.ts +137 -123
  167. package/src/tileset/tileset-3d.ts +378 -251
  168. package/src/tileset/tileset-cache.ts +24 -17
  169. package/src/tileset/{traversers/tileset-traverser.ts → tileset-traverser.ts} +71 -72
  170. package/src/types.ts +36 -0
  171. package/src/utils/doubly-linked-list-node.ts +3 -2
  172. package/src/utils/doubly-linked-list.ts +2 -3
  173. package/src/utils/managed-array.ts +1 -1
  174. package/dist/bundle.js.map +0 -1
  175. package/dist/constants.js.map +0 -1
  176. package/dist/index.js.map +0 -1
  177. package/dist/tileset/helpers/3d-tiles-options.js.map +0 -1
  178. package/dist/tileset/helpers/bounding-volume.js.map +0 -1
  179. package/dist/tileset/helpers/frame-state.js.map +0 -1
  180. package/dist/tileset/helpers/i3s-lod.js.map +0 -1
  181. package/dist/tileset/helpers/transform-utils.js.map +0 -1
  182. package/dist/tileset/helpers/zoom.js.map +0 -1
  183. package/dist/tileset/tile-3d.js.map +0 -1
  184. package/dist/tileset/tileset-3d.js.map +0 -1
  185. package/dist/tileset/tileset-cache.js.map +0 -1
  186. package/dist/tileset/traversers/i3s-tile-manager.d.ts +0 -8
  187. package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +0 -1
  188. package/dist/tileset/traversers/i3s-tile-manager.js +0 -45
  189. package/dist/tileset/traversers/i3s-tile-manager.js.map +0 -1
  190. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +0 -18
  191. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +0 -1
  192. package/dist/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  193. package/dist/tileset/traversers/tileset-3d-traverser.d.ts.map +0 -1
  194. package/dist/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  195. package/dist/tileset/traversers/tileset-traverser.d.ts +0 -52
  196. package/dist/tileset/traversers/tileset-traverser.d.ts.map +0 -1
  197. package/dist/tileset/traversers/tileset-traverser.js.map +0 -1
  198. package/dist/utils/doubly-linked-list-node.js.map +0 -1
  199. package/dist/utils/doubly-linked-list.js.map +0 -1
  200. package/dist/utils/managed-array.js.map +0 -1
  201. package/src/tileset/traversers/i3s-tile-manager.ts +0 -39
@@ -1,18 +1,17 @@
1
+ // loaders.gl, MIT license
2
+
1
3
  // This file is derived from the Cesium code base under Apache 2 license
2
4
  // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
5
 
4
- import DoublyLinkedList from '../utils/doubly-linked-list';
5
-
6
- function defined(x) {
7
- return x !== undefined && x !== null;
8
- }
6
+ import type {Tileset3D} from './tileset-3d';
7
+ import type {Tile3D} from './tile-3d';
8
+ import {DoublyLinkedList} from '../utils/doubly-linked-list';
9
9
 
10
10
  /**
11
11
  * Stores tiles with content loaded.
12
- *
13
12
  * @private
14
13
  */
15
- export default class TilesetCache {
14
+ export class TilesetCache {
16
15
  private _list: DoublyLinkedList;
17
16
  private _sentinel: any;
18
17
  private _trimTiles: boolean;
@@ -25,22 +24,26 @@ export default class TilesetCache {
25
24
  this._trimTiles = false;
26
25
  }
27
26
 
28
- reset() {
27
+ reset(): void {
29
28
  // Move sentinel node to the tail so, at the start of the frame, all tiles
30
29
  // may be potentially replaced. Tiles are moved to the right of the sentinel
31
30
  // when they are selected so they will not be replaced.
32
31
  this._list.splice(this._list.tail, this._sentinel);
33
32
  }
34
33
 
35
- touch(tile) {
34
+ touch(tile: Tile3D): void {
36
35
  const node = tile._cacheNode;
37
- if (defined(node)) {
36
+ if (node) {
38
37
  this._list.splice(this._sentinel, node);
39
38
  }
40
39
  }
41
40
 
42
- add(tileset, tile, addCallback) {
43
- if (!defined(tile._cacheNode)) {
41
+ add(
42
+ tileset: Tileset3D,
43
+ tile: Tile3D,
44
+ addCallback?: (tileset: Tileset3D, tile: Tile3D) => void
45
+ ): void {
46
+ if (!tile._cacheNode) {
44
47
  tile._cacheNode = this._list.add(tile);
45
48
 
46
49
  if (addCallback) {
@@ -49,20 +52,24 @@ export default class TilesetCache {
49
52
  }
50
53
  }
51
54
 
52
- unloadTile(tileset, tile, unloadCallback?) {
55
+ unloadTile(
56
+ tileset: Tileset3D,
57
+ tile: Tile3D,
58
+ unloadCallback?: (tileset: Tileset3D, tile: Tile3D) => void
59
+ ): void {
53
60
  const node = tile._cacheNode;
54
- if (!defined(node)) {
61
+ if (!node) {
55
62
  return;
56
63
  }
57
64
 
58
65
  this._list.remove(node);
59
- tile._cacheNode = undefined;
66
+ tile._cacheNode = null;
60
67
  if (unloadCallback) {
61
68
  unloadCallback(tileset, tile);
62
69
  }
63
70
  }
64
71
 
65
- unloadTiles(tileset, unloadCallback) {
72
+ unloadTiles(tileset, unloadCallback): void {
66
73
  const trimTiles = this._trimTiles;
67
74
  this._trimTiles = false;
68
75
 
@@ -88,7 +95,7 @@ export default class TilesetCache {
88
95
  }
89
96
  }
90
97
 
91
- trim() {
98
+ trim(): void {
92
99
  this._trimTiles = true;
93
100
  }
94
101
  }
@@ -1,26 +1,21 @@
1
- import ManagedArray from '../../utils/managed-array';
2
- import {TILE_REFINEMENT} from '../../constants';
1
+ // loaders.gl, MIT license
2
+
3
+ import type {Tile3D} from './tile-3d';
4
+ import {ManagedArray} from '../utils/managed-array';
5
+ import {TILE_REFINEMENT} from '../constants';
6
+ import {FrameState} from './helpers/frame-state';
3
7
 
4
8
  export type TilesetTraverserProps = {
5
9
  loadSiblings?: boolean;
6
10
  skipLevelOfDetail?: boolean;
11
+ updateTransforms?: boolean;
7
12
  maximumScreenSpaceError?: number;
8
13
  onTraversalEnd?: (frameState) => any;
9
- viewportTraversersMap?: {[key: string]: any};
14
+ viewportTraversersMap?: Record<string, any>;
10
15
  basePath?: string;
11
16
  };
12
17
 
13
- export type Props = {
14
- loadSiblings: boolean;
15
- skipLevelOfDetail: boolean;
16
- updateTransforms: boolean;
17
- maximumScreenSpaceError: number;
18
- onTraversalEnd: (frameState) => any;
19
- viewportTraversersMap: {[key: string]: any};
20
- basePath: string;
21
- };
22
-
23
- export const DEFAULT_PROPS: Props = {
18
+ export const DEFAULT_PROPS: Required<TilesetTraverserProps> = {
24
19
  loadSiblings: false,
25
20
  skipLevelOfDetail: false,
26
21
  maximumScreenSpaceError: 2,
@@ -30,39 +25,35 @@ export const DEFAULT_PROPS: Props = {
30
25
  basePath: ''
31
26
  };
32
27
 
33
- export default class TilesetTraverser {
34
- options: Props;
35
-
36
- root: any;
37
- requestedTiles: object;
38
- selectedTiles: object;
39
- emptyTiles: object;
40
-
41
- protected _traversalStack: ManagedArray;
42
- protected _emptyTraversalStack: ManagedArray;
43
- protected _frameNumber: number | null;
28
+ export class TilesetTraverser {
29
+ options: Required<TilesetTraverserProps>;
30
+
31
+ // fulfill in traverse call
32
+ root: any = null;
33
+
34
+ // tiles should be rendered
35
+ selectedTiles: Record<string, Tile3D> = {};
36
+ // tiles should be loaded from server
37
+ requestedTiles: Record<string, Tile3D> = {};
38
+ // tiles does not have render content
39
+ emptyTiles: Record<string, Tile3D> = {};
40
+
41
+ protected lastUpdate: number = new Date().getTime();
42
+ protected readonly updateDebounceTime = 1000;
43
+ /** temporary storage to hold the traversed tiles during a traversal */
44
+ protected _traversalStack = new ManagedArray();
45
+ protected _emptyTraversalStack = new ManagedArray();
46
+ /** set in every traverse cycle */
47
+ protected _frameNumber: number | null = null;
48
+
49
+ // RESULT
50
+ protected traversalFinished(frameState: FrameState): boolean {
51
+ return true;
52
+ }
44
53
 
45
54
  // TODO nested props
46
55
  constructor(options: TilesetTraverserProps) {
47
56
  this.options = {...DEFAULT_PROPS, ...options};
48
- // TRAVERSAL
49
- // temporary storage to hold the traversed tiles during a traversal
50
- this._traversalStack = new ManagedArray();
51
- this._emptyTraversalStack = new ManagedArray();
52
-
53
- // set in every traverse cycle
54
- this._frameNumber = null;
55
-
56
- // fulfill in traverse call
57
- this.root = null;
58
-
59
- // RESULT
60
- // tiles should be rendered
61
- this.selectedTiles = {};
62
- // tiles should be loaded from server
63
- this.requestedTiles = {};
64
- // tiles does not have render content
65
- this.emptyTiles = {};
66
57
  }
67
58
 
68
59
  // tiles should be visible
@@ -88,15 +79,17 @@ export default class TilesetTraverser {
88
79
  this._emptyTraversalStack.reset();
89
80
  }
90
81
 
91
- // execute traverse
92
- // Depth-first traversal that traverses all visible tiles and marks tiles for selection.
93
- // If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
94
- // This is the traditional replacement refinement approach and is called the base traversal.
95
- // Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
96
- // all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
97
- // and rendering children and parent tiles simultaneously.
82
+ /**
83
+ * Execute traverse
84
+ * Depth-first traversal that traverses all visible tiles and marks tiles for selection.
85
+ * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
86
+ * This is the traditional replacement refinement approach and is called the base traversal.
87
+ * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
88
+ * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
89
+ * and rendering children and parent tiles simultaneously.
90
+ */
98
91
  /* eslint-disable-next-line complexity, max-statements */
99
- executeTraversal(root, frameState) {
92
+ executeTraversal(root, frameState: FrameState): void {
100
93
  // stack to store traversed tiles, only visible tiles should be added to stack
101
94
  // visible: visible in the current view frustum
102
95
  const stack = this._traversalStack;
@@ -156,19 +149,22 @@ export default class TilesetTraverser {
156
149
  tile._shouldRefine = shouldRefine && parentRefines;
157
150
  }
158
151
 
159
- this.options.onTraversalEnd(frameState);
152
+ const newTime = new Date().getTime();
153
+ if (this.traversalFinished(frameState) || newTime - this.lastUpdate > this.updateDebounceTime) {
154
+ this.lastUpdate = newTime;
155
+ this.options.onTraversalEnd(frameState);
156
+ }
160
157
  }
161
158
 
162
- updateChildTiles(tile, frameState) {
159
+ updateChildTiles(tile: Tile3D, frameState: FrameState): void {
163
160
  const children = tile.children;
164
161
  for (const child of children) {
165
162
  this.updateTile(child, frameState);
166
163
  }
167
- return true;
168
164
  }
169
165
 
170
166
  /* eslint-disable complexity, max-statements */
171
- updateAndPushChildren(tile, frameState, stack, depth) {
167
+ updateAndPushChildren(tile: Tile3D, frameState: FrameState, stack, depth): boolean {
172
168
  const {loadSiblings, skipLevelOfDetail} = this.options;
173
169
 
174
170
  const children = tile.children;
@@ -223,12 +219,12 @@ export default class TilesetTraverser {
223
219
  }
224
220
  /* eslint-enable complexity, max-statements */
225
221
 
226
- updateTile(tile, frameState) {
222
+ updateTile(tile: Tile3D, frameState: FrameState): void {
227
223
  this.updateTileVisibility(tile, frameState);
228
224
  }
229
225
 
230
226
  // tile to render in the browser
231
- selectTile(tile, frameState) {
227
+ selectTile(tile: Tile3D, frameState: FrameState): void {
232
228
  if (this.shouldSelectTile(tile)) {
233
229
  // The tile can be selected right away and does not require traverseAndSelect
234
230
  tile._selectedFrame = frameState.frameNumber;
@@ -237,7 +233,7 @@ export default class TilesetTraverser {
237
233
  }
238
234
 
239
235
  // tile to load from server
240
- loadTile(tile, frameState) {
236
+ loadTile(tile: Tile3D, frameState: FrameState): void {
241
237
  if (this.shouldLoadTile(tile)) {
242
238
  tile._requestedFrame = frameState.frameNumber;
243
239
  tile._priority = tile._getPriority();
@@ -246,7 +242,7 @@ export default class TilesetTraverser {
246
242
  }
247
243
 
248
244
  // cache tile
249
- touchTile(tile, frameState) {
245
+ touchTile(tile: Tile3D, frameState: FrameState): void {
250
246
  tile.tileset._cache.touch(tile);
251
247
  tile._touchedFrame = frameState.frameNumber;
252
248
  }
@@ -254,7 +250,12 @@ export default class TilesetTraverser {
254
250
  // tile should be visible
255
251
  // tile should have children
256
252
  // tile LoD (level of detail) is not sufficient under current viewport
257
- canTraverse(tile, frameState, useParentMetric = false, ignoreVisibility = false) {
253
+ canTraverse(
254
+ tile: Tile3D,
255
+ frameState: FrameState,
256
+ useParentMetric: boolean = false,
257
+ ignoreVisibility: boolean = false
258
+ ): boolean {
258
259
  if (!tile.hasChildren) {
259
260
  return false;
260
261
  }
@@ -273,20 +274,20 @@ export default class TilesetTraverser {
273
274
  return this.shouldRefine(tile, frameState, useParentMetric);
274
275
  }
275
276
 
276
- shouldLoadTile(tile) {
277
+ shouldLoadTile(tile: Tile3D): boolean {
277
278
  // if request tile is in current frame
278
279
  // and has unexpired render content
279
280
  return tile.hasUnloadedContent || tile.contentExpired;
280
281
  }
281
282
 
282
- shouldSelectTile(tile) {
283
+ shouldSelectTile(tile: Tile3D): boolean {
283
284
  // if select tile is in current frame
284
285
  // and content available
285
286
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
286
287
  }
287
288
 
288
- // Decide if tile LoD (level of detail) is not sufficient under current viewport
289
- shouldRefine(tile, frameState, useParentMetric) {
289
+ /** Decide if tile LoD (level of detail) is not sufficient under current viewport */
290
+ shouldRefine(tile: Tile3D, frameState: FrameState, useParentMetric: boolean = false): boolean {
290
291
  let screenSpaceError = tile._screenSpaceError;
291
292
  if (useParentMetric) {
292
293
  screenSpaceError = tile.getScreenSpaceError(frameState, true);
@@ -295,7 +296,7 @@ export default class TilesetTraverser {
295
296
  return screenSpaceError > this.options.maximumScreenSpaceError;
296
297
  }
297
298
 
298
- updateTileVisibility(tile, frameState) {
299
+ updateTileVisibility(tile: Tile3D, frameState: FrameState): void {
299
300
  const viewportIds: string[] = [];
300
301
  if (this.options.viewportTraversersMap) {
301
302
  for (const key in this.options.viewportTraversersMap) {
@@ -312,14 +313,16 @@ export default class TilesetTraverser {
312
313
 
313
314
  // UTILITIES
314
315
 
315
- compareDistanceToCamera(b, a) {
316
+ compareDistanceToCamera(b: Tile3D, a: Tile3D): number {
316
317
  return b._distanceToCamera - a._distanceToCamera;
317
318
  }
318
319
 
319
- anyChildrenVisible(tile, frameState) {
320
+ anyChildrenVisible(tile: Tile3D, frameState: FrameState): boolean {
320
321
  let anyVisible = false;
321
322
  for (const child of tile.children) {
323
+ // @ts-expect-error
322
324
  child.updateVisibility(frameState);
325
+ // @ts-expect-error
323
326
  anyVisible = anyVisible || child.isVisibleAndInRequestVolume;
324
327
  }
325
328
  return anyVisible;
@@ -327,7 +330,7 @@ export default class TilesetTraverser {
327
330
 
328
331
  // Depth-first traversal that checks if all nearest descendants with content are loaded.
329
332
  // Ignores visibility.
330
- executeEmptyTraversal(root, frameState) {
333
+ executeEmptyTraversal(root: Tile3D, frameState: FrameState): boolean {
331
334
  let allDescendantsLoaded = true;
332
335
  const stack = this._emptyTraversalStack;
333
336
 
@@ -365,7 +368,3 @@ export default class TilesetTraverser {
365
368
  return allDescendantsLoaded;
366
369
  }
367
370
  }
368
-
369
- // TODO
370
- // enable expiration
371
- // enable optimization hint
package/src/types.ts ADDED
@@ -0,0 +1,36 @@
1
+ import {Vector3} from '@math.gl/core';
2
+
3
+ export type BoundingRectangle = {
4
+ width: number;
5
+ height: number;
6
+ };
7
+
8
+ /** Deck.gl Viewport instance type.
9
+ * We can't import it from Deck.gl to avoid circular reference */
10
+ export type Viewport = {
11
+ id: string;
12
+ cameraPosition: number[] | Vector3;
13
+ height: number;
14
+ width: number;
15
+ zoom: number;
16
+ distanceScales: {
17
+ unitsPerMeter: number[];
18
+ metersPerUnit: number[];
19
+ };
20
+ center: number[] | Vector3;
21
+ unprojectPosition: (position: number[] | Vector3) => [number, number, number];
22
+ project: (coorinates: number[] | Vector3) => number[];
23
+ };
24
+
25
+ /**
26
+ * Contain extra fields from WebMercatorViewport and FirstPersonViewport
27
+ */
28
+ export type GeospatialViewport = Viewport & {
29
+ /** @todo This field is not represented in Deck.gl viewports. Can be removed in the next version */
30
+ cameraDirection: [number, number, number];
31
+ /** @todo This field is not represented in Deck.gl viewports. Can be removed in the next version */
32
+ cameraUp: [number, number, number];
33
+ longitude: number;
34
+ latitude: number;
35
+ bearing: number;
36
+ };
@@ -1,12 +1,13 @@
1
+ // loaders.gl, MIT license
2
+
1
3
  // This file is derived from the Cesium code base under Apache 2 license
2
4
  // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
5
 
4
6
  /**
5
7
  * Doubly linked list node
6
- *
7
8
  * @private
8
9
  */
9
- export default class DoublyLinkedListNode {
10
+ export class DoublyLinkedListNode {
10
11
  item;
11
12
  previous;
12
13
  next;
@@ -1,14 +1,13 @@
1
1
  // This file is derived from the Cesium code base under Apache 2 license
2
2
  // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
3
 
4
- import DoublyLinkedListNode from '../utils/doubly-linked-list-node';
4
+ import {DoublyLinkedListNode} from './doubly-linked-list-node';
5
5
 
6
6
  /**
7
7
  * Doubly linked list
8
- *
9
8
  * @private
10
9
  */
11
- export default class DoublyLinkedList {
10
+ export class DoublyLinkedList {
12
11
  head: DoublyLinkedListNode | null = null;
13
12
  tail: DoublyLinkedListNode | null = null;
14
13
  _length = 0;
@@ -12,7 +12,7 @@ import {assert} from '@loaders.gl/loader-utils';
12
12
  *
13
13
  * @param {Number} [length=0] The initial length of the array.
14
14
  */
15
- export default class ManagedArray {
15
+ export class ManagedArray {
16
16
  _map = new Map();
17
17
  _array: any[];
18
18
  _length: number;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -1 +0,0 @@
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":"AAAA,OAAO,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;AASP,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,GAAG,EAAE,CADwB;AAE7BC,EAAAA,OAAO,EAAE;AAFoB,CAAxB;AAKP,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,KAAK,EAAE,OADgB;AAEvBC,EAAAA,UAAU,EAAE,YAFW;AAGvBC,EAAAA,UAAU,EAAE,YAHW;AAIvBC,EAAAA,IAAI,EAAE;AAJiB,CAAlB;AAOP,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,GAAG,EAAE,KADqB;AAE1BC,EAAAA,OAAO,EAAE;AAFiB,CAArB;AAKP,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,eAAe,EAAE,gBADY;AAE7BC,EAAAA,oBAAoB,EAAE;AAFO,CAAxB;AAMP,OAAO,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/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["default","Tileset3D","Tile3D","TilesetTraverser","TilesetCache","createBoundingVolume","calculateTransformProps","getFrameState","getLodStatus","TILE_CONTENT_STATE","TILE_REFINEMENT","TILE_TYPE","TILESET_TYPE","LOD_METRIC_TYPE"],"mappings":"AACA,SAAQA,OAAO,IAAIC,SAAnB,QAAmC,sBAAnC;AACA,SAAQD,OAAO,IAAIE,MAAnB,QAAgC,mBAAhC;AAEA,SAAQF,OAAO,IAAIG,gBAAnB,QAA0C,wCAA1C;AACA,SAAQH,OAAO,IAAII,YAAnB,QAAsC,yBAAtC;AAEA,SAAQC,oBAAR,QAAmC,mCAAnC;AACA,SAAQC,uBAAR,QAAsC,mCAAtC;AAEA,SAAQC,aAAR,QAA4B,+BAA5B;AACA,SAAQC,YAAR,QAA2B,2BAA3B;AAEA,SACEC,kBADF,EAEEC,eAFF,EAGEC,SAHF,EAIEC,YAJF,EAKEC,eALF,QAMO,aANP","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 +0,0 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/3d-tiles-options.ts"],"names":["get3dTilesOptions","tileset","assetGltfUpAxis","asset","gltfUpAxis"],"mappings":"AAAA,OAAO,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 +0,0 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/bounding-volume.ts"],"names":["Quaternion","Vector3","Matrix3","Matrix4","degrees","BoundingSphere","OrientedBoundingBox","Ellipsoid","assert","defined","x","undefined","scratchScale","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","box","createBox","region","west","south","east","north","minHeight","maxHeight","northWest","WGS84","cartographicToCartesian","southEast","centerInCartesian","addVectors","multiplyScalar","radius","subVectors","len","createSphere","sphere","Error","center","origin","length","halfSize","slice","quaternion","fromArray","y","z","transformByQuaternion","scale","toArray","xAxis","transformAsVector","yAxis","zAxis","halfAxes","getScale","uniformScale","Math","max"],"mappings":"AAIA,SAAQA,UAAR,EAAoBC,OAApB,EAA6BC,OAA7B,EAAsCC,OAAtC,EAA+CC,OAA/C,QAA6D,eAA7D;AACA,SAAQC,cAAR,EAAwBC,mBAAxB,QAAkD,kBAAlD;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AACA,SAAQC,MAAR,QAAqB,0BAArB;;AAIA,SAASC,OAAT,CAAiBC,CAAjB,EAAoB;AAClB,SAAOA,CAAC,KAAKC,SAAN,IAAmBD,CAAC,KAAK,IAAhC;AACD;;AAGD,MAAME,YAAY,GAAG,IAAIX,OAAJ,EAArB;AACA,MAAMY,gBAAgB,GAAG,IAAIZ,OAAJ,EAAzB;AACA,MAAMa,gBAAgB,GAAG,IAAIb,OAAJ,EAAzB;AAYA,OAAO,SAASc,oBAAT,CAA8BC,oBAA9B,EAAoDC,SAApD,EAA+DC,MAA/D,EAAuE;AAC5EV,EAAAA,MAAM,CAACQ,oBAAD,EAAuB,yCAAvB,CAAN;;AAIA,MAAIA,oBAAoB,CAACG,GAAzB,EAA8B;AAC5B,WAAOC,SAAS,CAACJ,oBAAoB,CAACG,GAAtB,EAA2BF,SAA3B,EAAsCC,MAAtC,CAAhB;AACD;;AACD,MAAIF,oBAAoB,CAACK,MAAzB,EAAiC;AAI/B,UAAM,CAACC,IAAD,EAAOC,KAAP,EAAcC,IAAd,EAAoBC,KAApB,EAA2BC,SAA3B,EAAsCC,SAAtC,IAAmDX,oBAAoB,CAACK,MAA9E;AAEA,UAAMO,SAAS,GAAGrB,SAAS,CAACsB,KAAV,CAAgBC,uBAAhB,CAChB,CAAC1B,OAAO,CAACkB,IAAD,CAAR,EAAgBlB,OAAO,CAACqB,KAAD,CAAvB,EAAgCC,SAAhC,CADgB,EAEhB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GAAGlC,SAAS,CAACyC,QAAV,CAAmB9C,YAAnB,CAAd;AAEA,QAAM+C,YAAY,GAAGC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACC,GAAL,CAASV,KAAK,CAAC,CAAD,CAAd,EAAmBA,KAAK,CAAC,CAAD,CAAxB,CAAT,EAAuCA,KAAK,CAAC,CAAD,CAA5C,CAArB;AACA,QAAMhB,MAAM,GAAGI,MAAM,CAAC,CAAD,CAAN,GAAYoB,YAA3B;;AAEA,MAAIlD,OAAO,CAACS,MAAD,CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACuB,MAAP,GAAgBA,MAAhB;AACAvB,IAAAA,MAAM,CAACiB,MAAP,GAAgBA,MAAhB;AACA,WAAOjB,MAAP;AACD;;AAED,SAAO,IAAIb,cAAJ,CAAmBoC,MAAnB,EAA2BN,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 +0,0 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/frame-state.ts"],"names":["Vector3","CullingVolume","Plane","Ellipsoid","scratchVector","scratchPosition","cullingVolume","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","unprojectPosition","center","viewportCenterCartesian","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","copy","distance","add","cartographic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A,UAAM4C,YAAY,GAAG9C,SAAS,CAACgB,KAAV,CAAgBC,uBAAhB,CAAwC4B,eAAxC,EAAyD,IAAIhD,OAAJ,EAAzD,CAArB;AAEAM,IAAAA,aAAa,CAAC4C,MAAd,CAAqBX,CAAC,EAAtB,EAA0BY,eAA1B,CACEF,YADF,EAGE7C,aAAa,CAACyC,IAAd,CAAmB3B,uBAAnB,EAA4CkC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/i3s-lod.ts"],"names":["Matrix4","Vector3","Ellipsoid","getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","originalViewport","viewport","ViewportClass","constructor","longitude","latitude","height","width","bearing","zoom","pitch","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","WGS84","cartographicToCartesian","toEye","subtract","normalize","enuToCartesianMatrix","eastNorthUpToFixedFrame","cartesianToEnuMatrix","invert","cameraPositionEnu","transform","projection","Math","sqrt","extraZ","extraVertexEnu","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,OAAjB,QAA+B,eAA/B;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAaA,OAAO,SAASC,YAAT,CAAsBC,IAAtB,EAAoCC,UAApC,EAAoF;AACzF,MAAID,IAAI,CAACE,cAAL,KAAwB,CAAxB,IAA6BC,KAAK,CAACH,IAAI,CAACE,cAAN,CAAtC,EAA6D;AAC3D,WAAO,KAAP;AACD;;AACD,QAAME,UAAU,GAAG,IAAIC,kBAAkB,CAACL,IAAD,EAAOC,UAAP,CAAzC;;AACA,MAAIG,UAAU,GAAG,CAAjB,EAAoB;AAClB,WAAO,KAAP;AACD;;AACD,MAAI,CAACJ,IAAI,CAACM,MAAL,CAAYC,QAAb,IAAyBH,UAAU,IAAIJ,IAAI,CAACE,cAAhD,EAAgE;AAC9D,WAAO,MAAP;AACD,GAFD,MAEO,IAAIF,IAAI,CAACM,MAAL,CAAYC,QAAhB,EAA0B;AAC/B,WAAO,KAAP;AACD;;AACD,SAAO,KAAP;AACD;AASD,OAAO,SAASF,kBAAT,CAA4BL,IAA5B,EAA0CC,UAA1C,EAA0E;AAC/E,QAAMO,gBAAgB,GAAGP,UAAU,CAACQ,QAApC;AACA,QAAMC,aAAa,GAAGF,gBAAgB,CAACG,WAAvC;AACA,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,MAAtB;AAA8BC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AAJ,CAAY2D,eAAZ,EACrBtB,QADqB,CACZwB,wBADY,EAErBE,SAFqB,EAAxB;AAGA,SAAOD,eAAP;AACD","sourcesContent":["import {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport Tile3D from '../tile-3d';\nimport {FrameState} from './frame-state';\n\n/**\n * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children\n as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.\n In this sense a value of 0 means you should always load it's children,\n or if it's a leaf node, you should always display it.\n * @param tile \n * @param frameState \n * @returns \n */\nexport function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {\n if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {\n return 'DIG';\n }\n const screenSize = 2 * getProjectedRadius(tile, frameState);\n if (screenSize < 2) {\n return 'OUT';\n }\n if (!tile.header.children || screenSize <= tile.lodMetricValue) {\n return 'DRAW';\n } else if (tile.header.children) {\n return 'DIG';\n }\n return 'OUT';\n}\n\n/**\n * Calculate size of MBS radius projected on the screen plane\n * @param tile\n * @param frameState\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {\n const originalViewport = frameState.viewport;\n const ViewportClass = originalViewport.constructor;\n const {longitude, latitude, height, width, bearing, zoom} = originalViewport;\n // @ts-ignore\n const viewport = new ViewportClass({longitude, latitude, height, width, bearing, zoom, pitch: 0});\n const mbsLat = tile.header.mbs[1];\n const mbsLon = tile.header.mbs[0];\n const mbsZ = tile.header.mbs[2];\n const mbsR = tile.header.mbs[3];\n const mbsCenterCartesian = [...tile.boundingVolume.center];\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // ---------------------------\n // Calculate mbs border vertex\n // ---------------------------\n const toEye = new Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n // Add extra vector to form plane\n const enuToCartesianMatrix = new Matrix4();\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n const cartesianToEnuMatrix = new Matrix4(enuToCartesianMatrix).invert();\n const cameraPositionEnu = new Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);\n // Mean Proportionals in Right Triangles - Altitude rule\n // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html\n const projection = Math.sqrt(\n cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]\n );\n const extraZ = (projection * projection) / cameraPositionEnu[2];\n const extraVertexEnu = new Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n const extraVectorCartesian = new Vector3(extraVertexCartesian)\n .subtract(mbsCenterCartesian)\n .normalize();\n // We need radius vector orthogonal to toEye vector\n const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n const sphereMbsBorderVertexCartesian = new Vector3(mbsCenterCartesian).add(radiusVector);\n const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(\n sphereMbsBorderVertexCartesian\n );\n // ---------------------------\n\n // Project center vertex and border vertex and calculate projected radius of MBS\n const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);\n const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);\n const projectedRadius = new Vector3(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n"],"file":"i3s-lod.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/transform-utils.ts"],"names":["Ellipsoid","Matrix4","Vector3","assert","calculateTransformProps","tileHeader","tile","rtcCenter","gltfUpAxis","computedTransform","boundingVolume","center","modelMatrix","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","isQuantized","quantizedVolumeOffset","scale","quantizedVolumeScale","cartesianOrigin","cartesianModelMatrix","cartographicOrigin","WGS84","cartesianToCartographic","fromFixedFrameMatrix","eastNorthUpToFixedFrame","toFixedFrameMatrix","invert","cartographicModelMatrix","coordinateSystem"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,qBAAxB;AACA,SAAQC,OAAR,EAAiBC,OAAjB,QAA+B,eAA/B;AACA,SAAQC,MAAR,QAAqB,0BAArB;AAEA,OAAO,SAASC,uBAAT,CAAiCC,UAAjC,EAA6CC,IAA7C,EAAmD;AACxDH,EAAAA,MAAM,CAACE,UAAD,CAAN;AACAF,EAAAA,MAAM,CAACG,IAAD,CAAN;AAEA,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA;AAAZ,MAA0BF,IAAhC;AACA,QAAM;AACJG,IAAAA,iBADI;AAEJC,IAAAA,cAAc,EAAE;AAACC,MAAAA;AAAD;AAFZ,MAGFN,UAHJ;AAKA,MAAIO,WAAW,GAAG,IAAIX,OAAJ,CAAYQ,iBAAZ,CAAlB;;AAGA,MAAIF,SAAJ,EAAe;AACbK,IAAAA,WAAW,CAACC,SAAZ,CAAsBN,SAAtB;AACD;;AAID,UAAQC,UAAR;AACE,SAAK,GAAL;AACE;;AACF,SAAK,GAAL;AACE,YAAMM,SAAS,GAAG,IAAIb,OAAJ,GAAcc,OAAd,CAAsBC,IAAI,CAACC,EAAL,GAAU,CAAhC,CAAlB;AACAL,MAAAA,WAAW,GAAGA,WAAW,CAACM,aAAZ,CAA0BJ,SAA1B,CAAd;AACA;;AACF,SAAK,GAAL;AACE,YAAMK,SAAS,GAAG,IAAIlB,OAAJ,GAAcmB,OAAd,CAAsB,CAACJ,IAAI,CAACC,EAAN,GAAW,CAAjC,CAAlB;AACAL,MAAAA,WAAW,GAAGA,WAAW,CAACM,aAAZ,CAA0BC,SAA1B,CAAd;AACA;;AACF;AACE;AAZJ;;AAgBA,MAAIb,IAAI,CAACe,WAAT,EAAsB;AACpBT,IAAAA,WAAW,CAACC,SAAZ,CAAsBP,IAAI,CAACgB,qBAA3B,EAAkDC,KAAlD,CAAwDjB,IAAI,CAACkB,oBAA7D;AACD;;AAGD,QAAMC,eAAe,GAAG,IAAIvB,OAAJ,CAAYS,MAAZ,CAAxB;AAEAL,EAAAA,IAAI,CAACoB,oBAAL,GAA4Bd,WAA5B;AACAN,EAAAA,IAAI,CAACmB,eAAL,GAAuBA,eAAvB;AAGA,QAAME,kBAAkB,GAAG3B,SAAS,CAAC4B,KAAV,CAAgBC,uBAAhB,CACzBJ,eADyB,EAEzB,IAAIvB,OAAJ,EAFyB,CAA3B;AAIA,QAAM4B,oBAAoB,GAAG9B,SAAS,CAAC4B,KAAV,CAAgBG,uBAAhB,CAAwCN,eAAxC,CAA7B;AACA,QAAMO,kBAAkB,GAAGF,oBAAoB,CAACG,MAArB,EAA3B;AAEA3B,EAAAA,IAAI,CAAC4B,uBAAL,GAA+BF,kBAAkB,CAACd,aAAnB,CAAiCN,WAAjC,CAA/B;AACAN,EAAAA,IAAI,CAACqB,kBAAL,GAA0BA,kBAA1B;;AAGA,MAAI,CAACrB,IAAI,CAAC6B,gBAAV,EAA4B;AAC1B7B,IAAAA,IAAI,CAACM,WAAL,GAAmBN,IAAI,CAAC4B,uBAAxB;AACD;AACF","sourcesContent":["import {Ellipsoid} from '@math.gl/geospatial';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {assert} from '@loaders.gl/loader-utils';\n\nexport function calculateTransformProps(tileHeader, tile) {\n assert(tileHeader);\n assert(tile);\n\n const {rtcCenter, gltfUpAxis} = tile;\n const {\n computedTransform,\n boundingVolume: {center}\n } = tileHeader;\n\n let modelMatrix = new Matrix4(computedTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n // Scale/offset positions if normalized integers\n if (tile.isQuantized) {\n modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);\n }\n\n // Option 1: Cartesian matrix and origin\n const cartesianOrigin = new Vector3(center);\n\n tile.cartesianModelMatrix = modelMatrix;\n tile.cartesianOrigin = cartesianOrigin;\n\n // Option 2: Cartographic matrix and origin\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);\n const toFixedFrameMatrix = fromFixedFrameMatrix.invert();\n\n tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);\n tile.cartographicOrigin = cartographicOrigin;\n\n // Deprecated, drop\n if (!tile.coordinateSystem) {\n tile.modelMatrix = tile.cartographicModelMatrix;\n }\n}\n"],"file":"transform-utils.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/zoom.ts"],"names":["Vector3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","getZoomFromBoundingVolume","boundingVolume","halfAxes","radius","width","height","obbSize","getObbSize","Math","log2","zoomX","zoomY","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"mappings":"AAAA,SAAQA,OAAR,QAAsB,eAAtB;AAEA,MAAMC,cAAc,GAAG,SAAvB;AACA,MAAMC,cAAc,GAAG,SAAvB;AACA,MAAMC,cAAc,GAAG,kBAAvB;AAEA,MAAMC,aAAa,GAAG,IAAIJ,OAAJ,EAAtB;AAOA,OAAO,SAASK,yBAAT,CAAmCC,cAAnC,EAAmD;AACxD,QAAM;AAACC,IAAAA,QAAD;AAAWC,IAAAA,MAAX;AAAmBC,IAAAA,KAAnB;AAA0BC,IAAAA;AAA1B,MAAoCJ,cAA1C;;AAEA,MAAIC,QAAJ,EAAc;AAEZ,UAAMI,OAAO,GAAGC,UAAU,CAACL,QAAD,CAA1B;AAEA,WAAOM,IAAI,CAACC,IAAL,CAAUX,cAAc,GAAGQ,OAA3B,CAAP;AACD,GALD,MAKO,IAAIH,MAAJ,EAAY;AAEjB,WAAOK,IAAI,CAACC,IAAL,CAAUX,cAAc,GAAGK,MAA3B,CAAP;AACD,GAHM,MAGA,IAAIE,MAAM,IAAID,KAAd,EAAqB;AAE1B,UAAMM,KAAK,GAAGF,IAAI,CAACC,IAAL,CAAUb,cAAc,GAAGQ,KAA3B,CAAd;AACA,UAAMO,KAAK,GAAGH,IAAI,CAACC,IAAL,CAAUZ,cAAc,GAAGQ,MAA3B,CAAd;AAEA,WAAO,CAACK,KAAK,GAAGC,KAAT,IAAkB,CAAzB;AACD;;AAED,SAAO,CAAP;AACD;;AAED,SAASJ,UAAT,CAAoBL,QAApB,EAA8B;AAC5BA,EAAAA,QAAQ,CAACU,SAAT,CAAmB,CAAnB,EAAsBb,aAAtB;AACA,QAAMc,IAAI,GAAGX,QAAQ,CAACU,SAAT,CAAmB,CAAnB,CAAb;AACA,QAAME,IAAI,GAAGZ,QAAQ,CAACU,SAAT,CAAmB,CAAnB,CAAb;AACA,QAAMG,cAAc,GAAGhB,aAAa,CAACiB,GAAd,CAAkBH,IAAlB,EAAwBG,GAAxB,CAA4BF,IAA5B,CAAvB;AACA,QAAMG,IAAI,GAAGF,cAAc,CAACG,GAAf,EAAb;AACA,SAAOD,IAAP;AACD","sourcesContent":["import {Vector3} from '@math.gl/core';\n\nconst WGS84_RADIUS_X = 6378137.0;\nconst WGS84_RADIUS_Y = 6378137.0;\nconst WGS84_RADIUS_Z = 6356752.3142451793;\n\nconst scratchVector = new Vector3();\n\n/**\n * Calculate appropriate zoom value for a particular boundingVolume\n * @param {BoundingSphere, OrientedBoundingBox} boundingVolume - the instance of bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(boundingVolume) {\n const {halfAxes, radius, width, height} = boundingVolume;\n\n if (halfAxes) {\n // OrientedBoundingBox\n const obbSize = getObbSize(halfAxes);\n // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n return Math.log2(WGS84_RADIUS_Z / obbSize);\n } else if (radius) {\n // BoundingSphere\n return Math.log2(WGS84_RADIUS_Z / radius);\n } else if (height && width) {\n // BoundingRectangle\n const zoomX = Math.log2(WGS84_RADIUS_X / width);\n const zoomY = Math.log2(WGS84_RADIUS_Y / height);\n\n return (zoomX + zoomY) / 2;\n }\n\n return 1;\n}\n\nfunction getObbSize(halfAxes) {\n halfAxes.getColumn(0, scratchVector);\n const axeY = halfAxes.getColumn(1);\n const axeZ = halfAxes.getColumn(2);\n const farthestVertex = scratchVector.add(axeY).add(axeZ);\n const size = farthestVertex.len();\n return size;\n}\n"],"file":"zoom.js"}