@loaders.gl/tiles 3.1.0-alpha.4 → 3.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +8136 -0
  4. package/dist/constants.d.ts +32 -0
  5. package/dist/constants.d.ts.map +1 -0
  6. package/dist/constants.js +35 -0
  7. package/dist/es5/bundle.js +1 -1
  8. package/dist/es5/bundle.js.map +1 -1
  9. package/dist/es5/constants.js +6 -6
  10. package/dist/es5/constants.js.map +1 -1
  11. package/dist/es5/index.js +20 -12
  12. package/dist/es5/index.js.map +1 -1
  13. package/dist/es5/tileset/helpers/bounding-volume.js +25 -37
  14. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
  15. package/dist/es5/tileset/helpers/frame-state.js +29 -25
  16. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  17. package/dist/es5/tileset/helpers/i3s-lod.js +57 -106
  18. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  19. package/dist/es5/tileset/helpers/tiles-3d-lod.js +51 -47
  20. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
  21. package/dist/es5/tileset/helpers/transform-utils.js +21 -12
  22. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
  23. package/dist/es5/tileset/helpers/zoom.js +17 -15
  24. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  25. package/dist/es5/tileset/tile-3d.js +328 -421
  26. package/dist/es5/tileset/tile-3d.js.map +1 -1
  27. package/dist/es5/tileset/tileset-3d.js +381 -563
  28. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  29. package/dist/es5/tileset/tileset-cache.js +50 -63
  30. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  31. package/dist/es5/tileset/traversers/i3s-tile-manager.js +32 -44
  32. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
  33. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +53 -143
  34. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  35. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +34 -62
  36. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
  37. package/dist/es5/tileset/traversers/tileset-traverser.js +209 -282
  38. package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
  39. package/dist/es5/utils/doubly-linked-list-node.js +12 -7
  40. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  41. package/dist/es5/utils/doubly-linked-list.js +68 -78
  42. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  43. package/dist/es5/utils/managed-array.js +90 -106
  44. package/dist/es5/utils/managed-array.js.map +1 -1
  45. package/dist/esm/index.js +1 -0
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/tileset/helpers/i3s-lod.js +45 -86
  48. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
  49. package/dist/esm/tileset/helpers/transform-utils.js +4 -1
  50. package/dist/esm/tileset/helpers/transform-utils.js.map +1 -1
  51. package/dist/esm/tileset/tile-3d.js +3 -3
  52. package/dist/esm/tileset/tile-3d.js.map +1 -1
  53. package/dist/esm/tileset/tileset-3d.js +5 -5
  54. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  55. package/dist/esm/tileset/tileset-cache.js.map +1 -1
  56. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +4 -4
  57. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  58. package/dist/esm/utils/doubly-linked-list-node.js +7 -0
  59. package/dist/esm/utils/doubly-linked-list-node.js.map +1 -1
  60. package/dist/esm/utils/doubly-linked-list.js +6 -3
  61. package/dist/esm/utils/doubly-linked-list.js.map +1 -1
  62. package/dist/esm/utils/managed-array.js +7 -1
  63. package/dist/esm/utils/managed-array.js.map +1 -1
  64. package/dist/index.d.ts +11 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +28 -0
  67. package/dist/tileset/helpers/3d-tiles-options.d.ts +4 -0
  68. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -0
  69. package/dist/tileset/helpers/3d-tiles-options.js +9 -0
  70. package/dist/tileset/helpers/bounding-volume.d.ts +9 -0
  71. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -0
  72. package/dist/tileset/helpers/bounding-volume.js +177 -0
  73. package/dist/tileset/helpers/frame-state.d.ts +17 -0
  74. package/dist/tileset/helpers/frame-state.d.ts.map +1 -0
  75. package/dist/tileset/helpers/frame-state.js +70 -0
  76. package/dist/tileset/helpers/i3s-lod.d.ts +20 -0
  77. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -0
  78. package/dist/tileset/helpers/i3s-lod.js +83 -0
  79. package/dist/tileset/helpers/tiles-3d-lod.d.ts +8 -0
  80. package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -0
  81. package/dist/tileset/helpers/tiles-3d-lod.js +116 -0
  82. package/dist/tileset/helpers/transform-utils.d.ts +2 -0
  83. package/dist/tileset/helpers/transform-utils.d.ts.map +1 -0
  84. package/dist/tileset/helpers/transform-utils.js +52 -0
  85. package/dist/tileset/helpers/zoom.d.ts +7 -0
  86. package/dist/tileset/helpers/zoom.d.ts.map +1 -0
  87. package/dist/tileset/helpers/zoom.js +42 -0
  88. package/dist/tileset/tile-3d.d.ts +174 -0
  89. package/dist/tileset/tile-3d.d.ts.map +1 -0
  90. package/dist/tileset/tile-3d.js +554 -0
  91. package/dist/tileset/tileset-3d.d.ts +172 -0
  92. package/dist/tileset/tileset-3d.d.ts.map +1 -0
  93. package/dist/tileset/tileset-3d.js +601 -0
  94. package/dist/tileset/tileset-cache.d.ts +18 -0
  95. package/dist/tileset/tileset-cache.d.ts.map +1 -0
  96. package/dist/tileset/tileset-cache.js +79 -0
  97. package/dist/tileset/traversers/i3s-tile-manager.d.ts +8 -0
  98. package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +1 -0
  99. package/dist/tileset/traversers/i3s-tile-manager.js +36 -0
  100. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +18 -0
  101. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +1 -0
  102. package/dist/tileset/traversers/i3s-tileset-traverser.js +85 -0
  103. package/dist/tileset/traversers/tileset-3d-traverser.d.ts +7 -0
  104. package/dist/tileset/traversers/tileset-3d-traverser.d.ts.map +1 -0
  105. package/dist/tileset/traversers/tileset-3d-traverser.js +55 -0
  106. package/dist/tileset/traversers/tileset-traverser.d.ts +52 -0
  107. package/dist/tileset/traversers/tileset-traverser.d.ts.map +1 -0
  108. package/dist/tileset/traversers/tileset-traverser.js +294 -0
  109. package/dist/utils/doubly-linked-list-node.d.ts +12 -0
  110. package/dist/utils/doubly-linked-list-node.d.ts.map +1 -0
  111. package/dist/utils/doubly-linked-list-node.js +17 -0
  112. package/dist/utils/doubly-linked-list.d.ts +31 -0
  113. package/dist/utils/doubly-linked-list.d.ts.map +1 -0
  114. package/dist/utils/doubly-linked-list.js +100 -0
  115. package/dist/utils/managed-array.d.ts +85 -0
  116. package/dist/utils/managed-array.d.ts.map +1 -0
  117. package/dist/utils/managed-array.js +151 -0
  118. package/package.json +9 -7
  119. package/src/index.ts +1 -0
  120. package/src/tileset/helpers/i3s-lod.ts +72 -96
  121. package/src/tileset/helpers/transform-utils.ts +3 -1
  122. package/src/tileset/tile-3d.ts +2 -2
  123. package/src/tileset/tileset-cache.ts +2 -0
  124. package/src/tileset/traversers/i3s-tileset-traverser.ts +2 -3
  125. package/src/utils/{doubly-linked-list-node.js → doubly-linked-list-node.ts} +4 -0
  126. package/src/utils/{doubly-linked-list.js → doubly-linked-list.ts} +3 -5
  127. package/src/utils/{managed-array.js → managed-array.ts} +4 -1
  128. package/dist/dist.min.js +0 -2
  129. package/dist/dist.min.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doubly-linked-list-node.d.ts","sourceRoot":"","sources":["../../src/utils/doubly-linked-list-node.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,IAAI,MAAC;IACL,QAAQ,MAAC;IACT,IAAI,MAAC;gBAEO,IAAI,KAAA,EAAE,QAAQ,KAAA,EAAE,IAAI,KAAA;CAKjC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ /**
6
+ * Doubly linked list node
7
+ *
8
+ * @private
9
+ */
10
+ class DoublyLinkedListNode {
11
+ constructor(item, previous, next) {
12
+ this.item = item;
13
+ this.previous = previous;
14
+ this.next = next;
15
+ }
16
+ }
17
+ exports.default = DoublyLinkedListNode;
@@ -0,0 +1,31 @@
1
+ import DoublyLinkedListNode from '../utils/doubly-linked-list-node';
2
+ /**
3
+ * Doubly linked list
4
+ *
5
+ * @private
6
+ */
7
+ export default class DoublyLinkedList {
8
+ head: DoublyLinkedListNode | null;
9
+ tail: DoublyLinkedListNode | null;
10
+ _length: number;
11
+ get length(): number;
12
+ /**
13
+ * Adds the item to the end of the list
14
+ * @param {*} [item]
15
+ * @return {DoublyLinkedListNode}
16
+ */
17
+ add(item: any): DoublyLinkedListNode;
18
+ /**
19
+ * Removes the given node from the list
20
+ * @param {DoublyLinkedListNode} node
21
+ */
22
+ remove(node: any): void;
23
+ /**
24
+ * Moves nextNode after node
25
+ * @param {DoublyLinkedListNode} node
26
+ * @param {DoublyLinkedListNode} nextNode
27
+ */
28
+ splice(node: any, nextNode: any): void;
29
+ _insert(node: any, nextNode: any): void;
30
+ }
31
+ //# sourceMappingURL=doubly-linked-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doubly-linked-list.d.ts","sourceRoot":"","sources":["../../src/utils/doubly-linked-list.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IACzC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IACzC,OAAO,SAAK;IAEZ,IAAI,MAAM,WAET;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAI,KAAA;IAgBR;;;OAGG;IACH,MAAM,CAAC,IAAI,KAAA;IA4BX;;;;OAIG;IACH,MAAM,CAAC,IAAI,KAAA,EAAE,QAAQ,KAAA;IAUrB,OAAO,CAAC,IAAI,KAAA,EAAE,QAAQ,KAAA;CAgBvB"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const doubly_linked_list_node_1 = __importDefault(require("../utils/doubly-linked-list-node"));
9
+ /**
10
+ * Doubly linked list
11
+ *
12
+ * @private
13
+ */
14
+ class DoublyLinkedList {
15
+ constructor() {
16
+ this.head = null;
17
+ this.tail = null;
18
+ this._length = 0;
19
+ }
20
+ get length() {
21
+ return this._length;
22
+ }
23
+ /**
24
+ * Adds the item to the end of the list
25
+ * @param {*} [item]
26
+ * @return {DoublyLinkedListNode}
27
+ */
28
+ add(item) {
29
+ const node = new doubly_linked_list_node_1.default(item, this.tail, null);
30
+ if (this.tail) {
31
+ this.tail.next = node;
32
+ this.tail = node;
33
+ }
34
+ else {
35
+ this.head = node;
36
+ this.tail = node;
37
+ }
38
+ ++this._length;
39
+ return node;
40
+ }
41
+ /**
42
+ * Removes the given node from the list
43
+ * @param {DoublyLinkedListNode} node
44
+ */
45
+ remove(node) {
46
+ if (!node) {
47
+ return;
48
+ }
49
+ if (node.previous && node.next) {
50
+ node.previous.next = node.next;
51
+ node.next.previous = node.previous;
52
+ }
53
+ else if (node.previous) {
54
+ // Remove last node
55
+ node.previous.next = null;
56
+ this.tail = node.previous;
57
+ }
58
+ else if (node.next) {
59
+ // Remove first node
60
+ node.next.previous = null;
61
+ this.head = node.next;
62
+ }
63
+ else {
64
+ // Remove last node in the linked list
65
+ this.head = null;
66
+ this.tail = null;
67
+ }
68
+ node.next = null;
69
+ node.previous = null;
70
+ --this._length;
71
+ }
72
+ /**
73
+ * Moves nextNode after node
74
+ * @param {DoublyLinkedListNode} node
75
+ * @param {DoublyLinkedListNode} nextNode
76
+ */
77
+ splice(node, nextNode) {
78
+ if (node === nextNode) {
79
+ return;
80
+ }
81
+ // Remove nextNode, then insert after node
82
+ this.remove(nextNode);
83
+ this._insert(node, nextNode);
84
+ }
85
+ _insert(node, nextNode) {
86
+ const oldNodeNext = node.next;
87
+ node.next = nextNode;
88
+ // nextNode is the new tail
89
+ if (this.tail === node) {
90
+ this.tail = nextNode;
91
+ }
92
+ else {
93
+ oldNodeNext.previous = nextNode;
94
+ }
95
+ nextNode.next = oldNodeNext;
96
+ nextNode.previous = node;
97
+ ++this._length;
98
+ }
99
+ }
100
+ exports.default = DoublyLinkedList;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * A wrapper around arrays so that the internal length of the array can be manually managed.
3
+ *
4
+ * @alias ManagedArray
5
+ * @constructor
6
+ * @private
7
+ *
8
+ * @param {Number} [length=0] The initial length of the array.
9
+ */
10
+ export default class ManagedArray {
11
+ _map: Map<any, any>;
12
+ _array: any[];
13
+ _length: number;
14
+ constructor(length?: number);
15
+ /**
16
+ * Gets or sets the length of the array.
17
+ * If the set length is greater than the length of the internal array, the internal array is resized.
18
+ *
19
+ * @memberof ManagedArray.prototype
20
+ * @type Number
21
+ */
22
+ get length(): number;
23
+ set length(length: number);
24
+ /**
25
+ * Gets the internal array.
26
+ *
27
+ * @memberof ManagedArray.prototype
28
+ * @type Array
29
+ * @readonly
30
+ */
31
+ get values(): any[];
32
+ /**
33
+ * Gets the element at an index.
34
+ *
35
+ * @param {Number} index The index to get.
36
+ */
37
+ get(index: any): any;
38
+ /**
39
+ * Sets the element at an index. Resizes the array if index is greater than the length of the array.
40
+ *
41
+ * @param {Number} index The index to set.
42
+ * @param {*} element The element to set at index.
43
+ */
44
+ set(index: any, element: any): void;
45
+ delete(element: any): void;
46
+ /**
47
+ * Returns the last element in the array without modifying the array.
48
+ *
49
+ * @returns {*} The last element in the array.
50
+ */
51
+ peek(): any;
52
+ /**
53
+ * Push an element into the array.
54
+ *
55
+ * @param {*} element The element to push.
56
+ */
57
+ push(element: any): void;
58
+ /**
59
+ * Pop an element from the array.
60
+ *
61
+ * @returns {*} The last element in the array.
62
+ */
63
+ pop(): any;
64
+ /**
65
+ * Resize the internal array if length > _array.length.
66
+ *
67
+ * @param {Number} length The length.
68
+ */
69
+ reserve(length: any): void;
70
+ /**
71
+ * Resize the array.
72
+ *
73
+ * @param {Number} length The length.
74
+ */
75
+ resize(length: any): void;
76
+ /**
77
+ * Trim the internal array to the specified length. Defaults to the current length.
78
+ *
79
+ * @param {Number} [length] The length.
80
+ */
81
+ trim(length: any): void;
82
+ reset(): void;
83
+ find(target: any): boolean;
84
+ }
85
+ //# sourceMappingURL=managed-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-array.d.ts","sourceRoot":"","sources":["../../src/utils/managed-array.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,IAAI,gBAAa;IACjB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;gBAEJ,MAAM,SAAI;IAKtB;;;;;;OAMG;IACH,IAAI,MAAM,WAET;IAED,IAAI,MAAM,CAAC,MAAM,QAAA,EAKhB;IAED;;;;;;OAMG;IACH,IAAI,MAAM,UAET;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAK,KAAA;IAKT;;;;;OAKG;IACH,GAAG,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAelB,MAAM,CAAC,OAAO,KAAA;IASd;;;;OAIG;IACH,IAAI;IAIJ;;;;OAIG;IACH,IAAI,CAAC,OAAO,KAAA;IAQZ;;;;OAIG;IACH,GAAG;IAMH;;;;OAIG;IACH,OAAO,CAAC,MAAM,KAAA;IAQd;;;;OAIG;IACH,MAAM,CAAC,MAAM,KAAA;IAMb;;;;OAIG;IACH,IAAI,CAAC,MAAM,KAAA;IAOX,KAAK;IAML,IAAI,CAAC,MAAM,KAAA;CAGZ"}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
6
+ /**
7
+ * A wrapper around arrays so that the internal length of the array can be manually managed.
8
+ *
9
+ * @alias ManagedArray
10
+ * @constructor
11
+ * @private
12
+ *
13
+ * @param {Number} [length=0] The initial length of the array.
14
+ */
15
+ class ManagedArray {
16
+ constructor(length = 0) {
17
+ this._map = new Map();
18
+ this._array = new Array(length);
19
+ this._length = length;
20
+ }
21
+ /**
22
+ * Gets or sets the length of the array.
23
+ * If the set length is greater than the length of the internal array, the internal array is resized.
24
+ *
25
+ * @memberof ManagedArray.prototype
26
+ * @type Number
27
+ */
28
+ get length() {
29
+ return this._length;
30
+ }
31
+ set length(length) {
32
+ this._length = length;
33
+ if (length > this._array.length) {
34
+ this._array.length = length;
35
+ }
36
+ }
37
+ /**
38
+ * Gets the internal array.
39
+ *
40
+ * @memberof ManagedArray.prototype
41
+ * @type Array
42
+ * @readonly
43
+ */
44
+ get values() {
45
+ return this._array;
46
+ }
47
+ /**
48
+ * Gets the element at an index.
49
+ *
50
+ * @param {Number} index The index to get.
51
+ */
52
+ get(index) {
53
+ (0, loader_utils_1.assert)(index < this._array.length);
54
+ return this._array[index];
55
+ }
56
+ /**
57
+ * Sets the element at an index. Resizes the array if index is greater than the length of the array.
58
+ *
59
+ * @param {Number} index The index to set.
60
+ * @param {*} element The element to set at index.
61
+ */
62
+ set(index, element) {
63
+ (0, loader_utils_1.assert)(index >= 0);
64
+ if (index >= this.length) {
65
+ this.length = index + 1;
66
+ }
67
+ if (this._map.has(this._array[index])) {
68
+ this._map.delete(this._array[index]);
69
+ }
70
+ this._array[index] = element;
71
+ this._map.set(element, index);
72
+ }
73
+ delete(element) {
74
+ const index = this._map.get(element);
75
+ if (index >= 0) {
76
+ this._array.splice(index, 1);
77
+ this._map.delete(element);
78
+ this.length--;
79
+ }
80
+ }
81
+ /**
82
+ * Returns the last element in the array without modifying the array.
83
+ *
84
+ * @returns {*} The last element in the array.
85
+ */
86
+ peek() {
87
+ return this._array[this._length - 1];
88
+ }
89
+ /**
90
+ * Push an element into the array.
91
+ *
92
+ * @param {*} element The element to push.
93
+ */
94
+ push(element) {
95
+ if (!this._map.has(element)) {
96
+ const index = this.length++;
97
+ this._array[index] = element;
98
+ this._map.set(element, index);
99
+ }
100
+ }
101
+ /**
102
+ * Pop an element from the array.
103
+ *
104
+ * @returns {*} The last element in the array.
105
+ */
106
+ pop() {
107
+ const element = this._array[--this.length];
108
+ this._map.delete(element);
109
+ return element;
110
+ }
111
+ /**
112
+ * Resize the internal array if length > _array.length.
113
+ *
114
+ * @param {Number} length The length.
115
+ */
116
+ reserve(length) {
117
+ (0, loader_utils_1.assert)(length >= 0);
118
+ if (length > this._array.length) {
119
+ this._array.length = length;
120
+ }
121
+ }
122
+ /**
123
+ * Resize the array.
124
+ *
125
+ * @param {Number} length The length.
126
+ */
127
+ resize(length) {
128
+ (0, loader_utils_1.assert)(length >= 0);
129
+ this.length = length;
130
+ }
131
+ /**
132
+ * Trim the internal array to the specified length. Defaults to the current length.
133
+ *
134
+ * @param {Number} [length] The length.
135
+ */
136
+ trim(length) {
137
+ if (length === null || length === undefined) {
138
+ length = this.length;
139
+ }
140
+ this._array.length = length;
141
+ }
142
+ reset() {
143
+ this._array = [];
144
+ this._map = new Map();
145
+ this._length = 0;
146
+ }
147
+ find(target) {
148
+ return this._map.has(target);
149
+ }
150
+ }
151
+ exports.default = ManagedArray;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tiles",
3
- "version": "3.1.0-alpha.4",
3
+ "version": "3.1.0-beta.3",
4
4
  "description": "Common components for different tiles loaders.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -19,7 +19,7 @@
19
19
  "point cloud",
20
20
  "pointcloud"
21
21
  ],
22
- "types": "src/index.ts",
22
+ "types": "dist/index.d.ts",
23
23
  "main": "dist/es5/index.js",
24
24
  "module": "dist/esm/index.js",
25
25
  "sideEffects": false,
@@ -30,17 +30,19 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "pre-build": "npm run build-bundle",
33
- "build-bundle": "webpack --display=minimal --config ../../scripts/webpack/bundle.js"
33
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js"
34
34
  },
35
35
  "dependencies": {
36
- "@loaders.gl/core": "3.1.0-alpha.4",
37
- "@loaders.gl/loader-utils": "3.1.0-alpha.4",
38
- "@loaders.gl/math": "3.1.0-alpha.4",
36
+ "@loaders.gl/loader-utils": "3.1.0-beta.3",
37
+ "@loaders.gl/math": "3.1.0-beta.3",
39
38
  "@math.gl/core": "^3.5.1",
40
39
  "@math.gl/culling": "^3.5.1",
41
40
  "@math.gl/geospatial": "^3.5.1",
42
41
  "@math.gl/web-mercator": "^3.5.1",
43
42
  "@probe.gl/stats": "^3.4.0"
44
43
  },
45
- "gitHead": "e309784af37ef9f3640c7733c7851124c72e1fa3"
44
+ "peerDependencies": {
45
+ "@loaders.gl/core": "3.1.0-beta.1"
46
+ },
47
+ "gitHead": "3537c382b3ea4e092b24b6f94c3edee72076039c"
46
48
  }
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export {createBoundingVolume} from './tileset/helpers/bounding-volume';
9
9
  export {calculateTransformProps} from './tileset/helpers/transform-utils';
10
10
 
11
11
  export {getFrameState} from './tileset/helpers/frame-state';
12
+ export {getLodStatus} from './tileset/helpers/i3s-lod';
12
13
 
13
14
  export {
14
15
  TILE_CONTENT_STATE,
@@ -1,52 +1,23 @@
1
- import {toRadians} from '@math.gl/core';
2
-
3
- const WGS84_RADIUS_X = 6378137.0;
4
- // use this to bias the lod switching (1+ results in increasing the LOD quality)
5
- const qualityFactor = Math.PI / 2; // empirical derived bias factor
6
- /* eslint-disable max-statements */
7
- export function lodJudge(tile, frameState) {
8
- const viewport = frameState.viewport;
9
- const metersPerPixel = viewport.metersPerPixel;
10
-
11
- const mbsLat = tile.header.mbs[1];
12
- const mbsLon = tile.header.mbs[0];
13
- const mbsZ = tile.header.mbs[2];
14
- const mbsR = tile.header.mbs[3];
15
-
16
- const {height, width, latitude, longitude} = viewport;
17
-
18
- const viewportCenter = [longitude, latitude];
19
- const mbsCenter = [mbsLon, mbsLat, mbsZ];
20
- const mbsLatProjected = [longitude, mbsLat];
21
- const mbsLonProjected = [mbsLon, latitude];
22
-
23
- const diagonalInMeters = Math.sqrt(height * height + width * width) * metersPerPixel[0];
24
- const distanceInMeters = getDistanceFromLatLon(viewportCenter, mbsCenter);
25
-
26
- const visibleHeight = height * 0.5 + mbsR / WGS84_RADIUS_X;
27
- const visibleWidth = width * 0.5 + mbsR / WGS84_RADIUS_X;
28
-
29
- if (distanceInMeters > diagonalInMeters + mbsR / WGS84_RADIUS_X) {
30
- return 'OUT';
31
- }
32
- if (getDistanceFromLatLon(viewportCenter, mbsLatProjected) > visibleHeight) {
33
- return 'OUT';
34
- }
35
- if (getDistanceFromLatLon(viewportCenter, mbsLonProjected) > visibleWidth) {
36
- return 'OUT';
37
- }
38
-
39
- if (tile.lodMetricValue === 0) {
1
+ import {Matrix4, Vector3} from '@math.gl/core';
2
+ import {Ellipsoid} from '@math.gl/geospatial';
3
+ import Tile3D from '../tile-3d';
4
+ import {FrameState} from './frame-state';
5
+
6
+ /**
7
+ * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children
8
+ as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.
9
+ In this sense a value of 0 means you should always load it's children,
10
+ or if it's a leaf node, you should always display it.
11
+ * @param tile
12
+ * @param frameState
13
+ * @returns
14
+ */
15
+ export function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {
16
+ if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {
40
17
  return 'DIG';
41
18
  }
42
-
43
- // For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children
44
- // as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.
45
- // In this sense a value of 0 means you should always load it's children,
46
- // or if it's a leaf node, you should always display it.
47
- let screenSize = getI3ScreenSize(tile, frameState); // in pixels
48
- screenSize *= qualityFactor;
49
- if (screenSize < 0.5) {
19
+ const screenSize = 2 * getProjectedRadius(tile, frameState);
20
+ if (screenSize < 2) {
50
21
  return 'OUT';
51
22
  }
52
23
  if (!tile.header.children || screenSize <= tile.lodMetricValue) {
@@ -57,58 +28,63 @@ export function lodJudge(tile, frameState) {
57
28
  return 'OUT';
58
29
  }
59
30
 
60
- /* eslint-enable max-statements */
61
-
62
- function projectVertexToSphere([x, y, z]) {
63
- const azim = toRadians(x);
64
- const incl = toRadians(y);
65
- const radius = 1.0 + z / WGS84_RADIUS_X;
66
- const radCosInc = radius * Math.cos(incl);
67
- x = radCosInc * Math.cos(azim);
68
- y = radCosInc * Math.sin(azim);
69
- z = radius * Math.sin(incl);
70
- return [x, y, z];
71
- }
72
-
73
- function getDistanceFromLatLon(observer: number[], center: number[]) {
74
- const [observerLon, observerLat, observerZ = 0.0] = observer;
75
- const [centerLon, centerLat, centerZ = 0.0] = center;
76
-
77
- const projectedCenter = projectVertexToSphere([centerLon, centerLat, centerZ]);
78
- const projectedObserver = projectVertexToSphere([observerLon, observerLat, observerZ]);
79
- const dx = projectedObserver[0] - projectedCenter[0];
80
- const dy = projectedObserver[1] - projectedCenter[1];
81
- const dz = projectedObserver[2] - projectedCenter[2];
82
- return dx * dx + dy * dy + dz * dz;
83
- }
84
-
85
- export function getI3ScreenSize(tile, frameState) {
86
- const viewport = frameState.viewport;
31
+ /**
32
+ * Calculate size of MBS radius projected on the screen plane
33
+ * @param tile
34
+ * @param frameState
35
+ * @returns
36
+ */
37
+ // eslint-disable-next-line max-statements
38
+ export function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {
39
+ const originalViewport = frameState.viewport;
40
+ const ViewportClass = originalViewport.constructor;
41
+ const {longitude, latitude, height, width, bearing, zoom} = originalViewport;
42
+ // @ts-ignore
43
+ const viewport = new ViewportClass({longitude, latitude, height, width, bearing, zoom, pitch: 0});
87
44
  const mbsLat = tile.header.mbs[1];
88
45
  const mbsLon = tile.header.mbs[0];
89
46
  const mbsZ = tile.header.mbs[2];
90
47
  const mbsR = tile.header.mbs[3];
91
-
92
- const mbsCenter = [mbsLon, mbsLat, mbsZ];
48
+ const mbsCenterCartesian = [...tile.boundingVolume.center];
93
49
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
94
- const dSquared = getDistanceFromLatLon(cameraPositionCartographic, mbsCenter);
95
- const mbsRNormalized = mbsR / WGS84_RADIUS_X;
96
- const d = dSquared - mbsRNormalized * mbsRNormalized;
97
- const fltMax = 3.4028235e38; // convert from 0x7f7fffff which is the maximum
98
- if (d <= 0.0) {
99
- return 0.5 * fltMax;
100
- }
101
- // https://stackoverflow.com/questions/21648630/radius-of-projected-sphere-in-screen-space
102
- // There is a formula there to calculate projected radius:
103
- // return 1.0 / Math.tan(fov) * r / Math.sqrt(d * d - r * r); // Right
104
- // Hack: 300 is a Magic number to get the correct LoD. Possibly, d and r are calculated in a wrong way.
105
- const screenSizeFactor =
106
- ((getTanOfHalfVFAngle(frameState) * mbsRNormalized) / Math.sqrt(d)) * 300;
107
- return screenSizeFactor;
108
- }
109
-
110
- function getTanOfHalfVFAngle(frameState) {
111
- const {projectionMatrix} = frameState.viewport;
112
- const t = projectionMatrix[5];
113
- return t;
50
+ const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(
51
+ cameraPositionCartographic,
52
+ new Vector3()
53
+ );
54
+
55
+ // ---------------------------
56
+ // Calculate mbs border vertex
57
+ // ---------------------------
58
+ const toEye = new Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
59
+ // Add extra vector to form plane
60
+ const enuToCartesianMatrix = new Matrix4();
61
+ Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
62
+ const cartesianToEnuMatrix = new Matrix4(enuToCartesianMatrix).invert();
63
+ const cameraPositionEnu = new Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
64
+ // Mean Proportionals in Right Triangles - Altitude rule
65
+ // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html
66
+ const projection = Math.sqrt(
67
+ cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]
68
+ );
69
+ const extraZ = (projection * projection) / cameraPositionEnu[2];
70
+ const extraVertexEnu = new Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
71
+ const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
72
+ const extraVectorCartesian = new Vector3(extraVertexCartesian)
73
+ .subtract(mbsCenterCartesian)
74
+ .normalize();
75
+ // We need radius vector orthogonal to toEye vector
76
+ const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
77
+ const sphereMbsBorderVertexCartesian = new Vector3(mbsCenterCartesian).add(radiusVector);
78
+ const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(
79
+ sphereMbsBorderVertexCartesian
80
+ );
81
+ // ---------------------------
82
+
83
+ // Project center vertex and border vertex and calculate projected radius of MBS
84
+ const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
85
+ const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
86
+ const projectedRadius = new Vector3(projectedOrigin)
87
+ .subtract(projectedMbsBorderVertex)
88
+ .magnitude();
89
+ return projectedRadius;
114
90
  }
@@ -59,5 +59,7 @@ export function calculateTransformProps(tileHeader, tile) {
59
59
  tile.cartographicOrigin = cartographicOrigin;
60
60
 
61
61
  // Deprecated, drop
62
- tile.modelMatrix = tile.cartographicModelMatrix;
62
+ if (!tile.coordinateSystem) {
63
+ tile.modelMatrix = tile.cartographicModelMatrix;
64
+ }
63
65
  }
@@ -9,7 +9,7 @@ import {TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE} from '../constants';
9
9
  import {FrameState} from './helpers/frame-state';
10
10
  import {createBoundingVolume} from './helpers/bounding-volume';
11
11
  import {getTiles3DScreenSpaceError} from './helpers/tiles-3d-lod';
12
- import {getI3ScreenSize} from './helpers/i3s-lod';
12
+ import {getProjectedRadius} from './helpers/i3s-lod';
13
13
  import {get3dTilesOptions} from './helpers/3d-tiles-options';
14
14
  import TilesetTraverser from './traversers/tileset-traverser';
15
15
 
@@ -287,7 +287,7 @@ export default class TileHeader {
287
287
  getScreenSpaceError(frameState, useParentLodMetric) {
288
288
  switch (this.tileset.type) {
289
289
  case TILESET_TYPE.I3S:
290
- return getI3ScreenSize(this, frameState);
290
+ return getProjectedRadius(this, frameState);
291
291
  case TILESET_TYPE.TILES3D:
292
292
  return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);
293
293
  default:
@@ -80,7 +80,9 @@ export default class TilesetCache {
80
80
  node !== sentinel &&
81
81
  (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)
82
82
  ) {
83
+ // @ts-expect-error
83
84
  const tile = node.item;
85
+ // @ts-expect-error
84
86
  node = node.next;
85
87
  this.unloadTile(tileset, tile, unloadCallback);
86
88
  }