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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/constants.js +26 -29
  4. package/dist/constants.js.map +1 -0
  5. package/dist/dist.min.js +45 -264
  6. package/dist/index.js +10 -28
  7. package/dist/index.js.map +1 -0
  8. package/dist/tileset/helpers/3d-tiles-options.js +5 -8
  9. package/dist/tileset/helpers/3d-tiles-options.js.map +1 -0
  10. package/dist/tileset/helpers/bounding-volume.js +70 -159
  11. package/dist/tileset/helpers/bounding-volume.js.map +1 -0
  12. package/dist/tileset/helpers/frame-state.js +48 -67
  13. package/dist/tileset/helpers/frame-state.js.map +1 -0
  14. package/dist/tileset/helpers/i3s-lod.js +64 -80
  15. package/dist/tileset/helpers/i3s-lod.js.map +1 -0
  16. package/dist/tileset/helpers/tiles-3d-lod.js +100 -111
  17. package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -0
  18. package/dist/tileset/helpers/transform-utils.js +56 -50
  19. package/dist/tileset/helpers/transform-utils.js.map +1 -0
  20. package/dist/tileset/helpers/zoom.js +30 -36
  21. package/dist/tileset/helpers/zoom.js.map +1 -0
  22. package/dist/tileset/tile-3d.js +533 -551
  23. package/dist/tileset/tile-3d.js.map +1 -0
  24. package/dist/tileset/tileset-3d.js +649 -576
  25. package/dist/tileset/tileset-3d.js.map +1 -0
  26. package/dist/tileset/tileset-cache.js +71 -71
  27. package/dist/tileset/tileset-cache.js.map +1 -0
  28. package/dist/tileset/traversers/i3s-tile-manager.js +40 -31
  29. package/dist/tileset/traversers/i3s-tile-manager.js.map +1 -0
  30. package/dist/tileset/traversers/i3s-tileset-traverser.js +76 -81
  31. package/dist/tileset/traversers/i3s-tileset-traverser.js.map +1 -0
  32. package/dist/tileset/traversers/tileset-3d-traverser.js +49 -51
  33. package/dist/tileset/traversers/tileset-3d-traverser.js.map +1 -0
  34. package/dist/tileset/traversers/tileset-traverser.js +276 -274
  35. package/dist/tileset/traversers/tileset-traverser.js.map +1 -0
  36. package/dist/utils/doubly-linked-list-node.js +15 -16
  37. package/dist/utils/doubly-linked-list-node.js.map +1 -0
  38. package/dist/utils/doubly-linked-list.js +75 -94
  39. package/dist/utils/doubly-linked-list.js.map +1 -0
  40. package/dist/utils/managed-array.js +109 -143
  41. package/dist/utils/managed-array.js.map +1 -0
  42. package/package.json +7 -7
  43. package/dist/es5/bundle.js +0 -7
  44. package/dist/es5/bundle.js.map +0 -1
  45. package/dist/es5/constants.js +0 -44
  46. package/dist/es5/constants.js.map +0 -1
  47. package/dist/es5/index.js +0 -104
  48. package/dist/es5/index.js.map +0 -1
  49. package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -13
  50. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +0 -1
  51. package/dist/es5/tileset/helpers/bounding-volume.js +0 -114
  52. package/dist/es5/tileset/helpers/bounding-volume.js.map +0 -1
  53. package/dist/es5/tileset/helpers/frame-state.js +0 -65
  54. package/dist/es5/tileset/helpers/frame-state.js.map +0 -1
  55. package/dist/es5/tileset/helpers/i3s-lod.js +0 -86
  56. package/dist/es5/tileset/helpers/i3s-lod.js.map +0 -1
  57. package/dist/es5/tileset/helpers/tiles-3d-lod.js +0 -119
  58. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +0 -1
  59. package/dist/es5/tileset/helpers/transform-utils.js +0 -65
  60. package/dist/es5/tileset/helpers/transform-utils.js.map +0 -1
  61. package/dist/es5/tileset/helpers/zoom.js +0 -43
  62. package/dist/es5/tileset/helpers/zoom.js.map +0 -1
  63. package/dist/es5/tileset/tile-3d.js +0 -605
  64. package/dist/es5/tileset/tile-3d.js.map +0 -1
  65. package/dist/es5/tileset/tileset-3d.js +0 -838
  66. package/dist/es5/tileset/tileset-3d.js.map +0 -1
  67. package/dist/es5/tileset/tileset-cache.js +0 -101
  68. package/dist/es5/tileset/tileset-cache.js.map +0 -1
  69. package/dist/es5/tileset/traversers/i3s-tile-manager.js +0 -69
  70. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +0 -1
  71. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +0 -185
  72. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  73. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +0 -94
  74. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  75. package/dist/es5/tileset/traversers/tileset-traverser.js +0 -377
  76. package/dist/es5/tileset/traversers/tileset-traverser.js.map +0 -1
  77. package/dist/es5/utils/doubly-linked-list-node.js +0 -25
  78. package/dist/es5/utils/doubly-linked-list-node.js.map +0 -1
  79. package/dist/es5/utils/doubly-linked-list.js +0 -104
  80. package/dist/es5/utils/doubly-linked-list.js.map +0 -1
  81. package/dist/es5/utils/managed-array.js +0 -147
  82. package/dist/es5/utils/managed-array.js.map +0 -1
  83. package/dist/esm/bundle.js +0 -5
  84. package/dist/esm/bundle.js.map +0 -1
  85. package/dist/esm/constants.js +0 -32
  86. package/dist/esm/constants.js.map +0 -1
  87. package/dist/esm/index.js +0 -10
  88. package/dist/esm/index.js.map +0 -1
  89. package/dist/esm/tileset/helpers/3d-tiles-options.js +0 -6
  90. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +0 -1
  91. package/dist/esm/tileset/helpers/bounding-volume.js +0 -88
  92. package/dist/esm/tileset/helpers/bounding-volume.js.map +0 -1
  93. package/dist/esm/tileset/helpers/frame-state.js +0 -51
  94. package/dist/esm/tileset/helpers/frame-state.js.map +0 -1
  95. package/dist/esm/tileset/helpers/i3s-lod.js +0 -67
  96. package/dist/esm/tileset/helpers/i3s-lod.js.map +0 -1
  97. package/dist/esm/tileset/helpers/tiles-3d-lod.js +0 -105
  98. package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +0 -1
  99. package/dist/esm/tileset/helpers/transform-utils.js +0 -58
  100. package/dist/esm/tileset/helpers/transform-utils.js.map +0 -1
  101. package/dist/esm/tileset/helpers/zoom.js +0 -36
  102. package/dist/esm/tileset/helpers/zoom.js.map +0 -1
  103. package/dist/esm/tileset/tile-3d.js +0 -537
  104. package/dist/esm/tileset/tile-3d.js.map +0 -1
  105. package/dist/esm/tileset/tileset-3d.js +0 -674
  106. package/dist/esm/tileset/tileset-3d.js.map +0 -1
  107. package/dist/esm/tileset/tileset-cache.js +0 -79
  108. package/dist/esm/tileset/tileset-cache.js.map +0 -1
  109. package/dist/esm/tileset/traversers/i3s-tile-manager.js +0 -45
  110. package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +0 -1
  111. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +0 -80
  112. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  113. package/dist/esm/tileset/traversers/tileset-3d-traverser.js +0 -53
  114. package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  115. package/dist/esm/tileset/traversers/tileset-traverser.js +0 -296
  116. package/dist/esm/tileset/traversers/tileset-traverser.js.map +0 -1
  117. package/dist/esm/utils/doubly-linked-list-node.js +0 -16
  118. package/dist/esm/utils/doubly-linked-list-node.js.map +0 -1
  119. package/dist/esm/utils/doubly-linked-list.js +0 -81
  120. package/dist/esm/utils/doubly-linked-list.js.map +0 -1
  121. package/dist/esm/utils/managed-array.js +0 -117
  122. package/dist/esm/utils/managed-array.js.map +0 -1
package/dist/es5/index.js DELETED
@@ -1,104 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "Tileset3D", {
9
- enumerable: true,
10
- get: function get() {
11
- return _tileset3d.default;
12
- }
13
- });
14
- Object.defineProperty(exports, "Tile3D", {
15
- enumerable: true,
16
- get: function get() {
17
- return _tile3d.default;
18
- }
19
- });
20
- Object.defineProperty(exports, "TilesetTraverser", {
21
- enumerable: true,
22
- get: function get() {
23
- return _tilesetTraverser.default;
24
- }
25
- });
26
- Object.defineProperty(exports, "TilesetCache", {
27
- enumerable: true,
28
- get: function get() {
29
- return _tilesetCache.default;
30
- }
31
- });
32
- Object.defineProperty(exports, "createBoundingVolume", {
33
- enumerable: true,
34
- get: function get() {
35
- return _boundingVolume.createBoundingVolume;
36
- }
37
- });
38
- Object.defineProperty(exports, "calculateTransformProps", {
39
- enumerable: true,
40
- get: function get() {
41
- return _transformUtils.calculateTransformProps;
42
- }
43
- });
44
- Object.defineProperty(exports, "getFrameState", {
45
- enumerable: true,
46
- get: function get() {
47
- return _frameState.getFrameState;
48
- }
49
- });
50
- Object.defineProperty(exports, "getLodStatus", {
51
- enumerable: true,
52
- get: function get() {
53
- return _i3sLod.getLodStatus;
54
- }
55
- });
56
- Object.defineProperty(exports, "TILE_CONTENT_STATE", {
57
- enumerable: true,
58
- get: function get() {
59
- return _constants.TILE_CONTENT_STATE;
60
- }
61
- });
62
- Object.defineProperty(exports, "TILE_REFINEMENT", {
63
- enumerable: true,
64
- get: function get() {
65
- return _constants.TILE_REFINEMENT;
66
- }
67
- });
68
- Object.defineProperty(exports, "TILE_TYPE", {
69
- enumerable: true,
70
- get: function get() {
71
- return _constants.TILE_TYPE;
72
- }
73
- });
74
- Object.defineProperty(exports, "TILESET_TYPE", {
75
- enumerable: true,
76
- get: function get() {
77
- return _constants.TILESET_TYPE;
78
- }
79
- });
80
- Object.defineProperty(exports, "LOD_METRIC_TYPE", {
81
- enumerable: true,
82
- get: function get() {
83
- return _constants.LOD_METRIC_TYPE;
84
- }
85
- });
86
-
87
- var _tileset3d = _interopRequireDefault(require("./tileset/tileset-3d"));
88
-
89
- var _tile3d = _interopRequireDefault(require("./tileset/tile-3d"));
90
-
91
- var _tilesetTraverser = _interopRequireDefault(require("./tileset/traversers/tileset-traverser"));
92
-
93
- var _tilesetCache = _interopRequireDefault(require("./tileset/tileset-cache"));
94
-
95
- var _boundingVolume = require("./tileset/helpers/bounding-volume");
96
-
97
- var _transformUtils = require("./tileset/helpers/transform-utils");
98
-
99
- var _frameState = require("./tileset/helpers/frame-state");
100
-
101
- var _i3sLod = require("./tileset/helpers/i3s-lod");
102
-
103
- var _constants = require("./constants");
104
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA","sourcesContent":["export type {Tileset3DProps} from './tileset/tileset-3d';\nexport {default as Tileset3D} from './tileset/tileset-3d';\nexport {default as Tile3D} from './tileset/tile-3d';\n\nexport {default as TilesetTraverser} from './tileset/traversers/tileset-traverser';\nexport {default as TilesetCache} from './tileset/tileset-cache';\n\nexport {createBoundingVolume} from './tileset/helpers/bounding-volume';\nexport {calculateTransformProps} from './tileset/helpers/transform-utils';\n\nexport {getFrameState} from './tileset/helpers/frame-state';\nexport {getLodStatus} from './tileset/helpers/i3s-lod';\n\nexport {\n TILE_CONTENT_STATE,\n TILE_REFINEMENT,\n TILE_TYPE,\n TILESET_TYPE,\n LOD_METRIC_TYPE\n} from './constants';\n"],"file":"index.js"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.get3dTilesOptions = get3dTilesOptions;
7
-
8
- function get3dTilesOptions(tileset) {
9
- return {
10
- assetGltfUpAxis: tileset.asset && tileset.asset.gltfUpAxis || 'Y'
11
- };
12
- }
13
- //# sourceMappingURL=3d-tiles-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/3d-tiles-options.ts"],"names":["get3dTilesOptions","tileset","assetGltfUpAxis","asset","gltfUpAxis"],"mappings":";;;;;;;AAAO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoC;AACzC,SAAO;AACLC,IAAAA,eAAe,EAAGD,OAAO,CAACE,KAAR,IAAiBF,OAAO,CAACE,KAAR,CAAcC,UAAhC,IAA+C;AAD3D,GAAP;AAGD","sourcesContent":["export function get3dTilesOptions(tileset) {\n return {\n assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'\n };\n}\n"],"file":"3d-tiles-options.js"}
@@ -1,114 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createBoundingVolume = createBoundingVolume;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _core = require("@math.gl/core");
15
-
16
- var _culling = require("@math.gl/culling");
17
-
18
- var _geospatial = require("@math.gl/geospatial");
19
-
20
- var _loaderUtils = require("@loaders.gl/loader-utils");
21
-
22
- function defined(x) {
23
- return x !== undefined && x !== null;
24
- }
25
-
26
- var scratchScale = new _core.Vector3();
27
- var scratchNorthWest = new _core.Vector3();
28
- var scratchSouthEast = new _core.Vector3();
29
-
30
- function createBoundingVolume(boundingVolumeHeader, transform, result) {
31
- (0, _loaderUtils.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
32
-
33
- if (boundingVolumeHeader.box) {
34
- return createBox(boundingVolumeHeader.box, transform, result);
35
- }
36
-
37
- if (boundingVolumeHeader.region) {
38
- var _boundingVolumeHeader = (0, _slicedToArray2.default)(boundingVolumeHeader.region, 6),
39
- west = _boundingVolumeHeader[0],
40
- south = _boundingVolumeHeader[1],
41
- east = _boundingVolumeHeader[2],
42
- north = _boundingVolumeHeader[3],
43
- minHeight = _boundingVolumeHeader[4],
44
- maxHeight = _boundingVolumeHeader[5];
45
-
46
- var northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
47
-
48
- var southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
49
-
50
- var centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
51
- var radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
52
- return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
53
- }
54
-
55
- if (boundingVolumeHeader.sphere) {
56
- return createSphere(boundingVolumeHeader.sphere, transform, result);
57
- }
58
-
59
- throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
60
- }
61
-
62
- function createBox(box, transform, result) {
63
- var center = new _core.Vector3(box[0], box[1], box[2]);
64
- transform.transform(center, center);
65
- var origin = [];
66
-
67
- if (box.length === 10) {
68
- var halfSize = box.slice(3, 6);
69
- var quaternion = new _core.Quaternion();
70
- quaternion.fromArray(box, 6);
71
- var x = new _core.Vector3([1, 0, 0]);
72
- var y = new _core.Vector3([0, 1, 0]);
73
- var z = new _core.Vector3([0, 0, 1]);
74
- x.transformByQuaternion(quaternion);
75
- x.scale(halfSize[0]);
76
- y.transformByQuaternion(quaternion);
77
- y.scale(halfSize[1]);
78
- z.transformByQuaternion(quaternion);
79
- z.scale(halfSize[2]);
80
- origin = [].concat((0, _toConsumableArray2.default)(x.toArray()), (0, _toConsumableArray2.default)(y.toArray()), (0, _toConsumableArray2.default)(z.toArray()));
81
- } else {
82
- origin = [].concat((0, _toConsumableArray2.default)(box.slice(3, 6)), (0, _toConsumableArray2.default)(box.slice(6, 9)), (0, _toConsumableArray2.default)(box.slice(9, 12)));
83
- }
84
-
85
- var xAxis = transform.transformAsVector(origin.slice(0, 3));
86
- var yAxis = transform.transformAsVector(origin.slice(3, 6));
87
- var zAxis = transform.transformAsVector(origin.slice(6, 9));
88
- var halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
89
-
90
- if (defined(result)) {
91
- result.center = center;
92
- result.halfAxes = halfAxes;
93
- return result;
94
- }
95
-
96
- return new _culling.OrientedBoundingBox(center, halfAxes);
97
- }
98
-
99
- function createSphere(sphere, transform, result) {
100
- var center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
101
- transform.transform(center, center);
102
- var scale = transform.getScale(scratchScale);
103
- var uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
104
- var radius = sphere[3] * uniformScale;
105
-
106
- if (defined(result)) {
107
- result.center = center;
108
- result.radius = radius;
109
- return result;
110
- }
111
-
112
- return new _culling.BoundingSphere(center, radius);
113
- }
114
- //# sourceMappingURL=bounding-volume.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/bounding-volume.ts"],"names":["defined","x","undefined","scratchScale","Vector3","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","box","createBox","region","west","south","east","north","minHeight","maxHeight","northWest","Ellipsoid","WGS84","cartographicToCartesian","southEast","centerInCartesian","addVectors","multiplyScalar","radius","subVectors","len","createSphere","Matrix4","sphere","Error","center","origin","length","halfSize","slice","quaternion","Quaternion","fromArray","y","z","transformByQuaternion","scale","toArray","xAxis","transformAsVector","yAxis","zAxis","halfAxes","Matrix3","OrientedBoundingBox","getScale","uniformScale","Math","max","BoundingSphere"],"mappings":";;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AAIA,SAASA,OAAT,CAAiBC,CAAjB,EAAoB;AAClB,SAAOA,CAAC,KAAKC,SAAN,IAAmBD,CAAC,KAAK,IAAhC;AACD;;AAGD,IAAME,YAAY,GAAG,IAAIC,aAAJ,EAArB;AACA,IAAMC,gBAAgB,GAAG,IAAID,aAAJ,EAAzB;AACA,IAAME,gBAAgB,GAAG,IAAIF,a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AYA,MAAInD,OAAO,CAACU,MAAD,CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACyB,MAAP,GAAgBA,MAAhB;AACAzB,IAAAA,MAAM,CAAC0C,QAAP,GAAkBA,QAAlB;AACA,WAAO1C,MAAP;AACD;;AAED,SAAO,IAAI4C,4BAAJ,CAAwBnB,MAAxB,EAAgCiB,QAAhC,CAAP;AACD;;AAyDD,SAASrB,YAAT,CAAsBE,MAAtB,EAA8BxB,SAA9B,EAAyCC,MAAzC,EAAkD;AAEhD,MAAMyB,MAAM,GAAG,IAAI/B,aAAJ,CAAY6B,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAf;AACAxB,EAAAA,SAAS,CAACA,SAAV,CAAoB0B,MAApB,EAA4BA,MAA5B;AACA,MAAMW,KAAK,GAAGrC,SAAS,CAAC8C,QAAV,CAAmBpD,YAAnB,CAAd;AAEA,MAAMqD,YAAY,GAAGC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACC,GAAL,CAASZ,KAAK,CAAC,CAAD,CAAd,EAAmBA,KAAK,CAAC,CAAD,CAAxB,CAAT,EAAuCA,KAAK,CAAC,CAAD,CAA5C,CAArB;AACA,MAAMlB,MAAM,GAAGK,MAAM,CAAC,CAAD,CAAN,GAAYuB,YAA3B;;AAEA,MAAIxD,OAAO,CAACU,MAAD,CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACyB,MAAP,GAAgBA,MAAhB;AACAzB,IAAAA,MAAM,CAACkB,MAAP,GAAgBA,MAAhB;AACA,WAAOlB,MAAP;AACD;;AAED,SAAO,IAAIiD,uBAAJ,CAAmBxB,MAAnB,EAA2BP,MAA3B,CAAP;AACD","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {assert} from '@loaders.gl/loader-utils';\n\n// const scratchProjectedBoundingSphere = new BoundingSphere();\n\nfunction defined(x) {\n return x !== undefined && x !== null;\n}\n\n// const scratchMatrix = new Matrix3();\nconst scratchScale = new Vector3();\nconst scratchNorthWest = new Vector3();\nconst scratchSouthEast = new Vector3();\n// const scratchRectangle = new Rectangle();\n// const scratchOrientedBoundingBox = new OrientedBoundingBox();\n// const scratchTransform = new Matrix4();\n\n/**\n * Create a bounding volume from the tile's bounding volume header.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {Matrix4} transform The transform to apply to the bounding volume.\n * @param [result] The object onto which to store the result.\n * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.\n */\nexport function createBoundingVolume(boundingVolumeHeader, transform, result) {\n assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');\n\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return createBox(boundingVolumeHeader.box, transform, result);\n }\n if (boundingVolumeHeader.region) {\n // [west, south, east, north, minimum height, maximum height]\n // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n // Heights are in meters above (or below) the WGS 84 ellipsoid.\n const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;\n\n const northWest = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(west), degrees(north), minHeight],\n scratchNorthWest\n );\n const southEast = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(east), degrees(south), maxHeight],\n scratchSouthEast\n );\n const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);\n const radius = new Vector3().subVectors(northWest, southEast).len() / 2.0;\n\n // TODO improve region boundingVolume\n // for now, create a sphere as the boundingVolume instead of box\n return createSphere(\n [centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius],\n new Matrix4()\n );\n }\n\n if (boundingVolumeHeader.sphere) {\n return createSphere(boundingVolumeHeader.sphere, transform, result);\n }\n\n throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\n}\n\nfunction createBox(box, transform, result) {\n // https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box\n // 1. A half-axes based representation.\n // box: An array of 12 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box.\n // The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.\n // The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.\n // The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.\n // 2. A half-size-quaternion based representation.\n // box: An array of 10 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.\n // The next three elements (with indices 3, 4, and 5) define the halfSize.\n // The last four elements (indices 6, 7, 8 and 10) define the quaternion.\n const center = new Vector3(box[0], box[1], box[2]);\n transform.transform(center, center);\n let origin: number[] = [];\n if (box.length === 10) {\n const halfSize = box.slice(3, 6);\n const quaternion = new Quaternion();\n quaternion.fromArray(box, 6);\n const x = new Vector3([1, 0, 0]);\n const y = new Vector3([0, 1, 0]);\n const z = new Vector3([0, 0, 1]);\n x.transformByQuaternion(quaternion);\n x.scale(halfSize[0]);\n y.transformByQuaternion(quaternion);\n y.scale(halfSize[1]);\n z.transformByQuaternion(quaternion);\n z.scale(halfSize[2]);\n origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];\n } else {\n origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];\n }\n const xAxis = transform.transformAsVector(origin.slice(0, 3));\n const yAxis = transform.transformAsVector(origin.slice(3, 6));\n const zAxis = transform.transformAsVector(origin.slice(6, 9));\n const halfAxes = new Matrix3([\n xAxis[0],\n xAxis[1],\n xAxis[2],\n yAxis[0],\n yAxis[1],\n yAxis[2],\n zAxis[0],\n zAxis[1],\n zAxis[2]\n ]);\n\n if (defined(result)) {\n result.center = center;\n result.halfAxes = halfAxes;\n return result;\n }\n\n return new OrientedBoundingBox(center, halfAxes);\n}\n\n/*\nfunction createBoxFromTransformedRegion(region, transform, initialTransform, result) {\n const rectangle = Rectangle.unpack(region, 0, scratchRectangle);\n const minimumHeight = region[4];\n const maximumHeight = region[5];\n\n const orientedBoundingBox = OrientedBoundingBox.fromRectangle(\n rectangle,\n minimumHeight,\n maximumHeight,\n Ellipsoid.WGS84,\n scratchOrientedBoundingBox\n );\n const center = orientedBoundingBox.center;\n const halfAxes = orientedBoundingBox.halfAxes;\n\n // A region bounding volume is not transformed by the transform in the tileset JSON,\n // but may be transformed by additional transforms applied in Cesium.\n // This is why the transform is calculated as the difference between the initial transform and the current transform.\n transform = Matrix4.multiplyTransformation(\n transform,\n Matrix4.inverseTransformation(initialTransform, scratchTransform),\n scratchTransform\n );\n center = Matrix4.multiplyByPoint(transform, center, center);\n const rotationScale = Matrix4.getRotation(transform, scratchMatrix);\n halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);\n\n if (defined(result) && result instanceof TileOrientedBoundingBox) {\n result.update(center, halfAxes);\n return result;\n }\n\n return new TileOrientedBoundingBox(center, halfAxes);\n}\n\nfunction createRegion(region, transform, initialTransform, result) {\n if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {\n return createBoxFromTransformedRegion(region, transform, initialTransform, result);\n }\n\n if (defined(result)) {\n return result;\n }\n\n const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);\n\n return new TileBoundingRegion({\n rectangle: rectangleRegion,\n minimumHeight: region[4],\n maximumHeight: region[5]\n });\n}\n*/\n\nfunction createSphere(sphere, transform, result?) {\n // Find the transformed center\n const center = new Vector3(sphere[0], sphere[1], sphere[2]);\n transform.transform(center, center);\n const scale = transform.getScale(scratchScale);\n\n const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n const radius = sphere[3] * uniformScale;\n\n if (defined(result)) {\n result.center = center;\n result.radius = radius;\n return result;\n }\n\n return new BoundingSphere(center, radius);\n}\n"],"file":"bounding-volume.js"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFrameState = getFrameState;
7
-
8
- var _core = require("@math.gl/core");
9
-
10
- var _culling = require("@math.gl/culling");
11
-
12
- var _geospatial = require("@math.gl/geospatial");
13
-
14
- var scratchVector = new _core.Vector3();
15
- var scratchPosition = new _core.Vector3();
16
- var cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
17
-
18
- function getFrameState(viewport, frameNumber) {
19
- var cameraDirection = viewport.cameraDirection,
20
- cameraUp = viewport.cameraUp,
21
- height = viewport.height;
22
- var metersPerUnit = viewport.distanceScales.metersPerUnit;
23
- var viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
24
-
25
- var viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
26
-
27
- var enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
28
-
29
- var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
30
-
31
- var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
32
-
33
- var cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
34
- var cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
35
- commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
36
- return {
37
- camera: {
38
- position: cameraPositionCartesian,
39
- direction: cameraDirectionCartesian,
40
- up: cameraUpCartesian
41
- },
42
- viewport: viewport,
43
- height: height,
44
- cullingVolume: cullingVolume,
45
- frameNumber: frameNumber,
46
- sseDenominator: 1.15
47
- };
48
- }
49
-
50
- function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
51
- var frustumPlanes = viewport.getFrustumPlanes();
52
- var i = 0;
53
-
54
- for (var dir in frustumPlanes) {
55
- var plane = frustumPlanes[dir];
56
- var distanceToCenter = plane.normal.dot(viewport.center);
57
- scratchPosition.copy(plane.normal).scale(plane.distance - distanceToCenter).add(viewport.center);
58
- var cartographicPos = viewport.unprojectPosition(scratchPosition);
59
-
60
- var cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
61
-
62
- cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos));
63
- }
64
- }
65
- //# sourceMappingURL=frame-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","unprojectPosition","center","viewportCenterCartesian","Ellipsoid","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAeA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,IAAME,aAAa,GAAG,IAAIC,sBAAJ,CAAkB,CACtC,IAAIC,cAAJ,EADsC,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,CAAmB5B,uBAAnB,EAA4CmC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.getLodStatus = getLodStatus;
9
- exports.getProjectedRadius = getProjectedRadius;
10
-
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
-
13
- var _core = require("@math.gl/core");
14
-
15
- var _geospatial = require("@math.gl/geospatial");
16
-
17
- function getLodStatus(tile, frameState) {
18
- if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {
19
- return 'DIG';
20
- }
21
-
22
- var screenSize = 2 * getProjectedRadius(tile, frameState);
23
-
24
- if (screenSize < 2) {
25
- return 'OUT';
26
- }
27
-
28
- if (!tile.header.children || screenSize <= tile.lodMetricValue) {
29
- return 'DRAW';
30
- } else if (tile.header.children) {
31
- return 'DIG';
32
- }
33
-
34
- return 'OUT';
35
- }
36
-
37
- function getProjectedRadius(tile, frameState) {
38
- var originalViewport = frameState.viewport;
39
- var ViewportClass = originalViewport.constructor;
40
- var longitude = originalViewport.longitude,
41
- latitude = originalViewport.latitude,
42
- height = originalViewport.height,
43
- width = originalViewport.width,
44
- bearing = originalViewport.bearing,
45
- zoom = originalViewport.zoom;
46
- var viewport = new ViewportClass({
47
- longitude: longitude,
48
- latitude: latitude,
49
- height: height,
50
- width: width,
51
- bearing: bearing,
52
- zoom: zoom,
53
- pitch: 0
54
- });
55
- var mbsLat = tile.header.mbs[1];
56
- var mbsLon = tile.header.mbs[0];
57
- var mbsZ = tile.header.mbs[2];
58
- var mbsR = tile.header.mbs[3];
59
- var mbsCenterCartesian = (0, _toConsumableArray2.default)(tile.boundingVolume.center);
60
- var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
61
-
62
- var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
63
-
64
- var toEye = new _core.Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
65
- var enuToCartesianMatrix = new _core.Matrix4();
66
-
67
- _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
68
-
69
- var cartesianToEnuMatrix = new _core.Matrix4(enuToCartesianMatrix).invert();
70
- var cameraPositionEnu = new _core.Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
71
- var projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
72
- var extraZ = projection * projection / cameraPositionEnu[2];
73
- var extraVertexEnu = new _core.Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
74
- var extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
75
- var extraVectorCartesian = new _core.Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
76
- var radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
77
- var sphereMbsBorderVertexCartesian = new _core.Vector3(mbsCenterCartesian).add(radiusVector);
78
-
79
- var sphereMbsBorderVertexCartographic = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
80
-
81
- var projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
82
- var projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
83
- var projectedRadius = new _core.Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
84
- return projectedRadius;
85
- }
86
- //# sourceMappingURL=i3s-lod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/i3s-lod.ts"],"names":["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","Ellipsoid","WGS84","cartographicToCartesian","Vector3","toEye","subtract","normalize","enuToCartesianMatrix","Matrix4","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;;AACA;;AAaO,SAASA,YAAT,CAAsBC,IAAtB,EAAoCC,UAApC,EAAoF;AACzF,MAAID,IAAI,CAACE,cAAL,KAAwB,CAAxB,I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,iBAAiB,CAAC,CAAD,CAA5D;AACA,MAAMM,cAAc,GAAG,IAAIf,aAAJ,CAAY,CAACS,iBAAiB,CAAC,CAAD,CAAlB,EAAuBA,iBAAiB,CAAC,CAAD,CAAxC,EAA6CK,MAA7C,CAAZ,CAAvB;AACA,MAAME,oBAAoB,GAAGD,cAAc,CAACL,SAAf,CAAyBN,oBAAzB,CAA7B;AACA,MAAMa,oBAAoB,GAAG,IAAIjB,aAAJ,CAAYgB,oBAAZ,EAC1Bd,QAD0B,CACjBZ,kBADiB,EAE1Ba,SAF0B,EAA7B;AAIA,MAAMe,YAAY,GAAGjB,KAAK,CAACkB,KAAN,CAAYF,oBAAZ,EAAkCd,SAAlC,GAA8CiB,KAA9C,CAAoD/B,IAApD,CAArB;AACA,MAAMgC,8BAA8B,GAAG,IAAIrB,aAAJ,CAAYV,kBAAZ,EAAgCgC,GAAhC,CAAoCJ,YAApC,CAAvC;;AACA,MAAMK,iCAAiC,GAAG1B,sBAAUC,KAAV,CAAgB0B,uBAAhB,CACxCH,8BADwC,CAA1C;;AAMA,MAAMI,eAAe,GAAGlD,QAAQ,CAACmD,OAAT,CAAiB,CAACvC,MAAD,EAASF,MAAT,EAAiBG,IAAjB,CAAjB,CAAxB;AACA,MAAMuC,wBAAwB,GAAGpD,QAAQ,CAACmD,OAAT,CAAiBH,iCAAjB,CAAjC;AACA,MAAMK,eAAe,GAAG,IAAI5B,aAAJ,CAAYyB,eAAZ,EACrBvB,QADqB,CACZyB,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,119 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.calculateDynamicScreenSpaceError = calculateDynamicScreenSpaceError;
7
- exports.fog = fog;
8
- exports.getDynamicScreenSpaceError = getDynamicScreenSpaceError;
9
- exports.getTiles3DScreenSpaceError = getTiles3DScreenSpaceError;
10
-
11
- var _core = require("@math.gl/core");
12
-
13
- var scratchPositionNormal = new _core.Vector3();
14
- var scratchCartographic = new _core.Vector3();
15
- var scratchMatrix = new _core.Matrix4();
16
- var scratchCenter = new _core.Vector3();
17
- var scratchPosition = new _core.Vector3();
18
- var scratchDirection = new _core.Vector3();
19
-
20
- function calculateDynamicScreenSpaceError(root, _ref) {
21
- var camera = _ref.camera,
22
- mapProjection = _ref.mapProjection;
23
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24
- var _options$dynamicScree = options.dynamicScreenSpaceErrorHeightFalloff,
25
- dynamicScreenSpaceErrorHeightFalloff = _options$dynamicScree === void 0 ? 0.25 : _options$dynamicScree,
26
- _options$dynamicScree2 = options.dynamicScreenSpaceErrorDensity,
27
- dynamicScreenSpaceErrorDensity = _options$dynamicScree2 === void 0 ? 0.00278 : _options$dynamicScree2;
28
- var up;
29
- var direction;
30
- var height;
31
- var minimumHeight;
32
- var maximumHeight;
33
- var tileBoundingVolume = root.contentBoundingVolume;
34
-
35
- if (tileBoundingVolume instanceof TileBoundingRegion) {
36
- up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
37
- direction = camera.directionWC;
38
- height = camera.positionCartographic.height;
39
- minimumHeight = tileBoundingVolume.minimumHeight;
40
- maximumHeight = tileBoundingVolume.maximumHeight;
41
- } else {
42
- var transformLocal = _core.Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);
43
-
44
- var ellipsoid = mapProjection.ellipsoid;
45
- var boundingVolume = tileBoundingVolume.boundingVolume;
46
-
47
- var centerLocal = _core.Matrix4.multiplyByPoint(transformLocal, boundingVolume.center, scratchCenter);
48
-
49
- if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
50
- var centerCartographic = Cartographic.fromCartesian(centerLocal, ellipsoid, scratchCartographic);
51
- up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
52
- direction = camera.directionWC;
53
- height = camera.positionCartographic.height;
54
- minimumHeight = 0.0;
55
- maximumHeight = centerCartographic.height * 2.0;
56
- } else {
57
- var positionLocal = _core.Matrix4.multiplyByPoint(transformLocal, camera.positionWC, scratchPosition);
58
-
59
- up = Cartesian3.UNIT_Z;
60
- direction = _core.Matrix4.multiplyByPointAsVector(transformLocal, camera.directionWC, scratchDirection);
61
- direction = Cartesian3.normalize(direction, direction);
62
- height = positionLocal.z;
63
-
64
- if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
65
- var boxHeight = root._header.boundingVolume.box[11];
66
- minimumHeight = centerLocal.z - boxHeight;
67
- maximumHeight = centerLocal.z + boxHeight;
68
- } else if (tileBoundingVolume instanceof TileBoundingSphere) {
69
- var radius = boundingVolume.radius;
70
- minimumHeight = centerLocal.z - radius;
71
- maximumHeight = centerLocal.z + radius;
72
- }
73
- }
74
- }
75
-
76
- var heightFalloff = dynamicScreenSpaceErrorHeightFalloff;
77
- var heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
78
- var heightFar = maximumHeight;
79
- var t = (0, _core.clamp)((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);
80
- var dot = Math.abs(Cartesian3.dot(direction, up));
81
- var horizonFactor = 1.0 - dot;
82
- horizonFactor = horizonFactor * (1.0 - t);
83
- return dynamicScreenSpaceErrorDensity * horizonFactor;
84
- }
85
-
86
- function fog(distanceToCamera, density) {
87
- var scalar = distanceToCamera * density;
88
- return 1.0 - Math.exp(-(scalar * scalar));
89
- }
90
-
91
- function getDynamicScreenSpaceError(tileset, distanceToCamera) {
92
- if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {
93
- var density = tileset.dynamicScreenSpaceErrorComputedDensity;
94
- var factor = tileset.dynamicScreenSpaceErrorFactor;
95
- var dynamicError = fog(distanceToCamera, density) * factor;
96
- return dynamicError;
97
- }
98
-
99
- return 0;
100
- }
101
-
102
- function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {
103
- var tileset = tile.tileset;
104
- var parentLodMetricValue = tile.parent && tile.parent.lodMetricValue || tile.lodMetricValue;
105
- var lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;
106
-
107
- if (lodMetricValue === 0.0) {
108
- return 0.0;
109
- }
110
-
111
- var distance = Math.max(tile._distanceToCamera, 1e-7);
112
- var height = frameState.height,
113
- sseDenominator = frameState.sseDenominator;
114
- var viewDistanceScale = tileset.options.viewDistanceScale;
115
- var error = lodMetricValue * height * (viewDistanceScale || 1.0) / (distance * sseDenominator);
116
- error -= getDynamicScreenSpaceError(tileset, distance);
117
- return error;
118
- }
119
- //# sourceMappingURL=tiles-3d-lod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/tiles-3d-lod.ts"],"names":["scratchPositionNormal","Vector3","scratchCartographic","scratchMatrix","Matrix4","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","camera","mapProjection","options","dynamicScreenSpaceErrorHeightFalloff","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"mappings":";;;;;;;;;;AAQA;;AAEA,IAAMA,qBAAqB,GAAG,IAAIC,aAAJ,EAA9B;AACA,IAAMC,mBAAmB,GAAG,IAAID,aAAJ,EAA5B;AACA,IAAME,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,aAAa,GAAG,IAAIJ,aAAJ,EAAtB;AACA,IAAMK,eAAe,GAAG,IAAIL,aAAJ,EAAxB;AACA,IAAMM,gBAAgB,GAAG,IAAIN,aAAJ,EAAzB;;AAGO,SAASO,gCAAT,CAA0CC,IAA1C,QAAuF;AAAA,MAAtCC,MAAsC,QAAtCA,MAAsC;AAAA,MAA9BC,aAA8B,QAA9BA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AA5B,IAA+CL,IAAI,CAACK,cAAjF;AACA,MAAMA,cAAc,GAAGH,kBAAkB,GAAGC,oBAAH,GAA0BH,IAAI,CAACK,cAAxE;;AAGA,MAAIA,cAAc,KAAK,GAAvB,EAA4B;AAC1B,WAAO,GAAP;AACD;;AAMD,MAAMC,QAAQ,GAAGtB,IAAI,CAACuB,GAAL,CAASP,IAAI,CAACQ,iBAAd,EAAiC,IAAjC,CAAjB;AACA,MAAO/D,MAAP,GAAiCwD,UAAjC,CAAOxD,MAAP;AAAA,MAAegE,cAAf,GAAiCR,UAAjC,CAAeQ,cAAf;AACA,MAAOC,iBAAP,GAA4BjB,OAAO,CAACrD,OAApC,CAAOsE,iBAAP;AACA,MAAIC,KAAK,GAAIN,cAAc,GAAG5D,MAAjB,IAA2BiE,iBAAiB,IAAI,GAAhD,CAAD,IAA0DJ,QAAQ,GAAGG,cAArE,CAAZ;AAEAE,EAAAA,KAAK,IAAInB,0BAA0B,CAACC,OAAD,EAAUa,QAAV,CAAnC;AAEA,SAAOK,KAAP;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// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(tileset, distance);\n\n return error;\n}\n"],"file":"tiles-3d-lod.js"}