@loaders.gl/tiles 4.0.0-beta.2 → 4.0.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 (126) hide show
  1. package/dist/constants.js.map +1 -0
  2. package/dist/dist.dev.js +8162 -0
  3. package/dist/index.cjs +2537 -0
  4. package/dist/index.js +10 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/{esm/tileset → tileset}/format-3d-tiles/tileset-3d-traverser.js +2 -2
  7. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  8. package/dist/{esm/tileset → tileset}/format-i3s/i3s-pending-tiles-register.js +1 -2
  9. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  10. package/dist/{esm/tileset → tileset}/format-i3s/i3s-tile-manager.js +3 -4
  11. package/dist/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  12. package/dist/{esm/tileset → tileset}/format-i3s/i3s-tileset-traverser.js +7 -8
  13. package/dist/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  14. package/dist/tileset/helpers/3d-tiles-options.js.map +1 -0
  15. package/dist/tileset/helpers/bounding-volume.d.ts +1 -1
  16. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
  17. package/dist/{esm/tileset → tileset}/helpers/bounding-volume.js +16 -6
  18. package/dist/tileset/helpers/bounding-volume.js.map +1 -0
  19. package/dist/tileset/helpers/frame-state.js.map +1 -0
  20. package/dist/tileset/helpers/i3s-lod.js.map +1 -0
  21. package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -0
  22. package/dist/tileset/helpers/transform-utils.js.map +1 -0
  23. package/dist/{esm/tileset → tileset}/helpers/zoom.js +2 -2
  24. package/dist/tileset/helpers/zoom.js.map +1 -0
  25. package/dist/tileset/tile-3d.d.ts.map +1 -1
  26. package/dist/{esm/tileset → tileset}/tile-3d.js +55 -56
  27. package/dist/tileset/tile-3d.js.map +1 -0
  28. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  29. package/dist/{esm/tileset → tileset}/tileset-3d.js +64 -62
  30. package/dist/tileset/tileset-3d.js.map +1 -0
  31. package/dist/{esm/tileset → tileset}/tileset-cache.js +4 -5
  32. package/dist/tileset/tileset-cache.js.map +1 -0
  33. package/dist/{esm/tileset → tileset}/tileset-traverser.js +12 -13
  34. package/dist/tileset/tileset-traverser.js.map +1 -0
  35. package/dist/types.js.map +1 -0
  36. package/dist/utils/doubly-linked-list-node.js +11 -0
  37. package/dist/utils/doubly-linked-list-node.js.map +1 -0
  38. package/dist/{esm/utils → utils}/doubly-linked-list.js +4 -5
  39. package/dist/utils/doubly-linked-list.js.map +1 -0
  40. package/dist/{esm/utils → utils}/managed-array.js +3 -4
  41. package/dist/utils/managed-array.js.map +1 -0
  42. package/package.json +20 -12
  43. package/src/tileset/helpers/bounding-volume.ts +53 -24
  44. package/src/tileset/helpers/zoom.ts +5 -5
  45. package/src/tileset/tile-3d.ts +1 -1
  46. package/src/tileset/tileset-3d.ts +6 -9
  47. package/dist/bundle.d.ts +0 -2
  48. package/dist/bundle.d.ts.map +0 -1
  49. package/dist/dist.min.js +0 -9231
  50. package/dist/es5/bundle.js +0 -6
  51. package/dist/es5/bundle.js.map +0 -1
  52. package/dist/es5/constants.js +0 -48
  53. package/dist/es5/constants.js.map +0 -1
  54. package/dist/es5/index.js +0 -93
  55. package/dist/es5/index.js.map +0 -1
  56. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +0 -70
  57. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
  58. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +0 -45
  59. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
  60. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +0 -84
  61. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
  62. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +0 -143
  63. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
  64. package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -12
  65. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +0 -1
  66. package/dist/es5/tileset/helpers/bounding-volume.js +0 -176
  67. package/dist/es5/tileset/helpers/bounding-volume.js.map +0 -1
  68. package/dist/es5/tileset/helpers/frame-state.js +0 -129
  69. package/dist/es5/tileset/helpers/frame-state.js.map +0 -1
  70. package/dist/es5/tileset/helpers/i3s-lod.js +0 -60
  71. package/dist/es5/tileset/helpers/i3s-lod.js.map +0 -1
  72. package/dist/es5/tileset/helpers/tiles-3d-lod.js +0 -103
  73. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +0 -1
  74. package/dist/es5/tileset/helpers/transform-utils.js +0 -50
  75. package/dist/es5/tileset/helpers/transform-utils.js.map +0 -1
  76. package/dist/es5/tileset/helpers/zoom.js +0 -63
  77. package/dist/es5/tileset/helpers/zoom.js.map +0 -1
  78. package/dist/es5/tileset/tile-3d.js +0 -536
  79. package/dist/es5/tileset/tile-3d.js.map +0 -1
  80. package/dist/es5/tileset/tileset-3d.js +0 -859
  81. package/dist/es5/tileset/tileset-3d.js.map +0 -1
  82. package/dist/es5/tileset/tileset-cache.js +0 -82
  83. package/dist/es5/tileset/tileset-cache.js.map +0 -1
  84. package/dist/es5/tileset/tileset-traverser.js +0 -321
  85. package/dist/es5/tileset/tileset-traverser.js.map +0 -1
  86. package/dist/es5/types.js +0 -2
  87. package/dist/es5/types.js.map +0 -1
  88. package/dist/es5/utils/doubly-linked-list-node.js +0 -21
  89. package/dist/es5/utils/doubly-linked-list-node.js.map +0 -1
  90. package/dist/es5/utils/doubly-linked-list.js +0 -88
  91. package/dist/es5/utils/doubly-linked-list.js.map +0 -1
  92. package/dist/es5/utils/managed-array.js +0 -126
  93. package/dist/es5/utils/managed-array.js.map +0 -1
  94. package/dist/esm/bundle.js +0 -4
  95. package/dist/esm/bundle.js.map +0 -1
  96. package/dist/esm/constants.js.map +0 -1
  97. package/dist/esm/index.js +0 -10
  98. package/dist/esm/index.js.map +0 -1
  99. package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
  100. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
  101. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
  102. package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
  103. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +0 -1
  104. package/dist/esm/tileset/helpers/bounding-volume.js.map +0 -1
  105. package/dist/esm/tileset/helpers/frame-state.js.map +0 -1
  106. package/dist/esm/tileset/helpers/i3s-lod.js.map +0 -1
  107. package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +0 -1
  108. package/dist/esm/tileset/helpers/transform-utils.js.map +0 -1
  109. package/dist/esm/tileset/helpers/zoom.js.map +0 -1
  110. package/dist/esm/tileset/tile-3d.js.map +0 -1
  111. package/dist/esm/tileset/tileset-3d.js.map +0 -1
  112. package/dist/esm/tileset/tileset-cache.js.map +0 -1
  113. package/dist/esm/tileset/tileset-traverser.js.map +0 -1
  114. package/dist/esm/types.js.map +0 -1
  115. package/dist/esm/utils/doubly-linked-list-node.js +0 -12
  116. package/dist/esm/utils/doubly-linked-list-node.js.map +0 -1
  117. package/dist/esm/utils/doubly-linked-list.js.map +0 -1
  118. package/dist/esm/utils/managed-array.js.map +0 -1
  119. package/src/bundle.ts +0 -4
  120. /package/dist/{esm/constants.js → constants.js} +0 -0
  121. /package/dist/{esm/tileset → tileset}/helpers/3d-tiles-options.js +0 -0
  122. /package/dist/{esm/tileset → tileset}/helpers/frame-state.js +0 -0
  123. /package/dist/{esm/tileset → tileset}/helpers/i3s-lod.js +0 -0
  124. /package/dist/{esm/tileset → tileset}/helpers/tiles-3d-lod.js +0 -0
  125. /package/dist/{esm/tileset → tileset}/helpers/transform-utils.js +0 -0
  126. /package/dist/{esm/types.js → types.js} +0 -0
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.calculateTransformProps = calculateTransformProps;
7
- var _geospatial = require("@math.gl/geospatial");
8
- var _core = require("@math.gl/core");
9
- var _loaderUtils = require("@loaders.gl/loader-utils");
10
- function calculateTransformProps(tileHeader, tile) {
11
- (0, _loaderUtils.assert)(tileHeader);
12
- (0, _loaderUtils.assert)(tile);
13
- var rtcCenter = tile.rtcCenter,
14
- gltfUpAxis = tile.gltfUpAxis;
15
- var computedTransform = tileHeader.computedTransform,
16
- center = tileHeader.boundingVolume.center;
17
- var modelMatrix = new _core.Matrix4(computedTransform);
18
- if (rtcCenter) {
19
- modelMatrix.translate(rtcCenter);
20
- }
21
- switch (gltfUpAxis) {
22
- case 'Z':
23
- break;
24
- case 'Y':
25
- var rotationY = new _core.Matrix4().rotateX(Math.PI / 2);
26
- modelMatrix = modelMatrix.multiplyRight(rotationY);
27
- break;
28
- case 'X':
29
- var rotationX = new _core.Matrix4().rotateY(-Math.PI / 2);
30
- modelMatrix = modelMatrix.multiplyRight(rotationX);
31
- break;
32
- default:
33
- break;
34
- }
35
- if (tile.isQuantized) {
36
- modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);
37
- }
38
- var cartesianOrigin = new _core.Vector3(center);
39
- tile.cartesianModelMatrix = modelMatrix;
40
- tile.cartesianOrigin = cartesianOrigin;
41
- var cartographicOrigin = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new _core.Vector3());
42
- var fromFixedFrameMatrix = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);
43
- var toFixedFrameMatrix = fromFixedFrameMatrix.invert();
44
- tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);
45
- tile.cartographicOrigin = cartographicOrigin;
46
- if (!tile.coordinateSystem) {
47
- tile.modelMatrix = tile.cartographicModelMatrix;
48
- }
49
- }
50
- //# sourceMappingURL=transform-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-utils.js","names":["_geospatial","require","_core","_loaderUtils","calculateTransformProps","tileHeader","tile","assert","rtcCenter","gltfUpAxis","computedTransform","center","boundingVolume","modelMatrix","Matrix4","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","isQuantized","quantizedVolumeOffset","scale","quantizedVolumeScale","cartesianOrigin","Vector3","cartesianModelMatrix","cartographicOrigin","Ellipsoid","WGS84","cartesianToCartographic","fromFixedFrameMatrix","eastNorthUpToFixedFrame","toFixedFrameMatrix","invert","cartographicModelMatrix","coordinateSystem"],"sources":["../../../../src/tileset/helpers/transform-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {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"],"mappings":";;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,SAASG,uBAAuBA,CAACC,UAAU,EAAEC,IAAI,EAAE;EACxD,IAAAC,mBAAM,EAACF,UAAU,CAAC;EAClB,IAAAE,mBAAM,EAACD,IAAI,CAAC;EAEZ,IAAOE,SAAS,GAAgBF,IAAI,CAA7BE,SAAS;IAAEC,UAAU,GAAIH,IAAI,CAAlBG,UAAU;EAC5B,IACEC,iBAAiB,GAEfL,UAAU,CAFZK,iBAAiB;IACAC,MAAM,GACrBN,UAAU,CADZO,cAAc,CAAGD,MAAM;EAGzB,IAAIE,WAAW,GAAG,IAAIC,aAAO,CAACJ,iBAAiB,CAAC;EAGhD,IAAIF,SAAS,EAAE;IACbK,WAAW,CAACE,SAAS,CAACP,SAAS,CAAC;EAClC;EAIA,QAAQC,UAAU;IAChB,KAAK,GAAG;MACN;IACF,KAAK,GAAG;MACN,IAAMO,SAAS,GAAG,IAAIF,aAAO,CAAC,CAAC,CAACG,OAAO,CAACC,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;MACpDN,WAAW,GAAGA,WAAW,CAACO,aAAa,CAACJ,SAAS,CAAC;MAClD;IACF,KAAK,GAAG;MACN,IAAMK,SAAS,GAAG,IAAIP,aAAO,CAAC,CAAC,CAACQ,OAAO,CAAC,CAACJ,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;MACrDN,WAAW,GAAGA,WAAW,CAACO,aAAa,CAACC,SAAS,CAAC;MAClD;IACF;MACE;EACJ;EAGA,IAAIf,IAAI,CAACiB,WAAW,EAAE;IACpBV,WAAW,CAACE,SAAS,CAACT,IAAI,CAACkB,qBAAqB,CAAC,CAACC,KAAK,CAACnB,IAAI,CAACoB,oBAAoB,CAAC;EACpF;EAGA,IAAMC,eAAe,GAAG,IAAIC,aAAO,CAACjB,MAAM,CAAC;EAE3CL,IAAI,CAACuB,oBAAoB,GAAGhB,WAAW;EACvCP,IAAI,CAACqB,eAAe,GAAGA,eAAe;EAGtC,IAAMG,kBAAkB,GAAGC,qBAAS,CAACC,KAAK,CAACC,uBAAuB,CAChEN,eAAe,EACf,IAAIC,aAAO,CAAC,CACd,CAAC;EACD,IAAMM,oBAAoB,GAAGH,qBAAS,CAACC,KAAK,CAACG,uBAAuB,CAACR,eAAe,CAAC;EACrF,IAAMS,kBAAkB,GAAGF,oBAAoB,CAACG,MAAM,CAAC,CAAC;EAExD/B,IAAI,CAACgC,uBAAuB,GAAGF,kBAAkB,CAAChB,aAAa,CAACP,WAAW,CAAC;EAC5EP,IAAI,CAACwB,kBAAkB,GAAGA,kBAAkB;EAG5C,IAAI,CAACxB,IAAI,CAACiC,gBAAgB,EAAE;IAC1BjC,IAAI,CAACO,WAAW,GAAGP,IAAI,CAACgC,uBAAuB;EACjD;AACF"}
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getZoomFromBoundingVolume = getZoomFromBoundingVolume;
8
- exports.getZoomFromExtent = getZoomFromExtent;
9
- exports.getZoomFromFullExtent = getZoomFromFullExtent;
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _core = require("@math.gl/core");
12
- var _culling = require("@math.gl/culling");
13
- var _geospatial = require("@math.gl/geospatial");
14
- var WGS84_RADIUS_X = 6378137.0;
15
- var WGS84_RADIUS_Y = 6378137.0;
16
- var WGS84_RADIUS_Z = 6356752.3142451793;
17
- var scratchVector = new _core.Vector3();
18
- function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
19
- if (boundingVolume instanceof _culling.OrientedBoundingBox) {
20
- var halfAxes = boundingVolume.halfAxes;
21
- var obbSize = getObbSize(halfAxes);
22
- return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));
23
- } else if (boundingVolume instanceof _culling.BoundingSphere) {
24
- var radius = boundingVolume.radius;
25
- return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));
26
- } else if (boundingVolume.width && boundingVolume.height) {
27
- var width = boundingVolume.width,
28
- height = boundingVolume.height;
29
- var zoomX = Math.log2(WGS84_RADIUS_X / width);
30
- var zoomY = Math.log2(WGS84_RADIUS_Y / height);
31
- return (zoomX + zoomY) / 2;
32
- }
33
- return 1;
34
- }
35
- function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
36
- var extentVertex = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new _core.Vector3());
37
- var extentSize = Math.sqrt(Math.pow(extentVertex[0] - cartesianCenter[0], 2) + Math.pow(extentVertex[1] - cartesianCenter[1], 2) + Math.pow(extentVertex[2] - cartesianCenter[2], 2));
38
- return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));
39
- }
40
- function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
41
- var _extent = (0, _slicedToArray2.default)(extent, 4),
42
- xmin = _extent[0],
43
- ymin = _extent[1],
44
- xmax = _extent[2],
45
- ymax = _extent[3];
46
- return getZoomFromFullExtent({
47
- xmin: xmin,
48
- xmax: xmax,
49
- ymin: ymin,
50
- ymax: ymax,
51
- zmin: 0,
52
- zmax: 0
53
- }, cartorgraphicCenter, cartesianCenter);
54
- }
55
- function getObbSize(halfAxes) {
56
- halfAxes.getColumn(0, scratchVector);
57
- var axeY = halfAxes.getColumn(1);
58
- var axeZ = halfAxes.getColumn(2);
59
- var farthestVertex = scratchVector.add(axeY).add(axeZ);
60
- var size = farthestVertex.len();
61
- return size;
62
- }
63
- //# sourceMappingURL=zoom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zoom.js","names":["_core","require","_culling","_geospatial","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","Vector3","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","OrientedBoundingBox","halfAxes","obbSize","getObbSize","Math","log2","BoundingSphere","radius","width","height","zoomX","zoomY","getZoomFromFullExtent","fullExtent","cartesianCenter","extentVertex","Ellipsoid","WGS84","cartographicToCartesian","xmax","ymax","zmax","extentSize","sqrt","pow","getZoomFromExtent","extent","_extent","_slicedToArray2","default","xmin","ymin","zmin","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"sources":["../../../../src/tileset/helpers/zoom.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {BoundingRectangle} from '../../types';\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 boundingVolume - the instance of bounding volume\n * @param cartorgraphicCenter - cartographic center of the bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(\n boundingVolume: BoundingSphere | OrientedBoundingBox | BoundingRectangle,\n cartorgraphicCenter: Vector3\n) {\n if (boundingVolume instanceof OrientedBoundingBox) {\n // OrientedBoundingBox\n const {halfAxes} = boundingVolume;\n const obbSize = getObbSize(halfAxes);\n // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));\n } else if (boundingVolume instanceof BoundingSphere) {\n // BoundingSphere\n const {radius} = boundingVolume;\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));\n } else if (boundingVolume.width && boundingVolume.height) {\n // BoundingRectangle\n const {width, height} = boundingVolume;\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\n/**\n * Calculate initial zoom for the tileset from 3D `fullExtent` defined in\n * the tileset metadata\n * @param fullExtent - 3D extent of the tileset\n * @param fullExtent.xmin - minimal longitude in decimal degrees\n * @param fullExtent.xmax - maximal longitude in decimal degrees\n * @param fullExtent.ymin - minimal latitude in decimal degrees\n * @param fullExtent.ymax - maximal latitude in decimal degrees\n * @param fullExtent.zmin - minimal elevation in meters\n * @param fullExtent.zmax - maximal elevation in meters\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromFullExtent(\n fullExtent: {\n xmin: number;\n xmax: number;\n ymin: number;\n ymax: number;\n zmin: number;\n zmax: number;\n },\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const extentVertex = Ellipsoid.WGS84.cartographicToCartesian(\n [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n new Vector3()\n );\n const extentSize = Math.sqrt(\n Math.pow(extentVertex[0] - cartesianCenter[0], 2) +\n Math.pow(extentVertex[1] - cartesianCenter[1], 2) +\n Math.pow(extentVertex[2] - cartesianCenter[2], 2)\n );\n return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));\n}\n\n/**\n * Calculate initial zoom for the tileset from 2D `extent` defined in\n * the tileset metadata\n * @param extent - 2D extent of the tileset. It is array of 4 elements [xmin, ymin, xmax, ymax]\n * @param extent[0] - minimal longitude in decimal degrees\n * @param extent[1] - minimal latitude in decimal degrees\n * @param extent[2] - maximal longitude in decimal degrees\n * @param extent[3] - maximal latitude in decimal degrees\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromExtent(\n extent: [number, number, number, number],\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const [xmin, ymin, xmax, ymax] = extent;\n return getZoomFromFullExtent(\n {xmin, xmax, ymin, ymax, zmin: 0, zmax: 0},\n cartorgraphicCenter,\n cartesianCenter\n );\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"],"mappings":"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"}
@@ -1,536 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Tile3D = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _core = require("@math.gl/core");
14
- var _culling = require("@math.gl/culling");
15
- var _core2 = require("@loaders.gl/core");
16
- var _constants = require("../constants");
17
- var _boundingVolume = require("./helpers/bounding-volume");
18
- var _tiles3dLod = require("./helpers/tiles-3d-lod");
19
- var _i3sLod = require("./helpers/i3s-lod");
20
- var _dTilesOptions = require("./helpers/3d-tiles-options");
21
- var _tilesetTraverser = require("./tileset-traverser");
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
- var scratchVector = new _core.Vector3();
25
- function defined(x) {
26
- return x !== undefined && x !== null;
27
- }
28
- var Tile3D = function () {
29
- function Tile3D(tileset, header, parentHeader) {
30
- var extendedId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
31
- (0, _classCallCheck2.default)(this, Tile3D);
32
- (0, _defineProperty2.default)(this, "tileset", void 0);
33
- (0, _defineProperty2.default)(this, "header", void 0);
34
- (0, _defineProperty2.default)(this, "id", void 0);
35
- (0, _defineProperty2.default)(this, "url", void 0);
36
- (0, _defineProperty2.default)(this, "parent", void 0);
37
- (0, _defineProperty2.default)(this, "refine", void 0);
38
- (0, _defineProperty2.default)(this, "type", void 0);
39
- (0, _defineProperty2.default)(this, "contentUrl", void 0);
40
- (0, _defineProperty2.default)(this, "lodMetricType", 'geometricError');
41
- (0, _defineProperty2.default)(this, "lodMetricValue", 0);
42
- (0, _defineProperty2.default)(this, "boundingVolume", null);
43
- (0, _defineProperty2.default)(this, "content", null);
44
- (0, _defineProperty2.default)(this, "contentState", _constants.TILE_CONTENT_STATE.UNLOADED);
45
- (0, _defineProperty2.default)(this, "gpuMemoryUsageInBytes", 0);
46
- (0, _defineProperty2.default)(this, "children", []);
47
- (0, _defineProperty2.default)(this, "depth", 0);
48
- (0, _defineProperty2.default)(this, "viewportIds", []);
49
- (0, _defineProperty2.default)(this, "transform", new _core.Matrix4());
50
- (0, _defineProperty2.default)(this, "extensions", null);
51
- (0, _defineProperty2.default)(this, "implicitTiling", null);
52
- (0, _defineProperty2.default)(this, "userData", {});
53
- (0, _defineProperty2.default)(this, "computedTransform", void 0);
54
- (0, _defineProperty2.default)(this, "hasEmptyContent", false);
55
- (0, _defineProperty2.default)(this, "hasTilesetContent", false);
56
- (0, _defineProperty2.default)(this, "traverser", new _tilesetTraverser.TilesetTraverser({}));
57
- (0, _defineProperty2.default)(this, "_cacheNode", null);
58
- (0, _defineProperty2.default)(this, "_frameNumber", null);
59
- (0, _defineProperty2.default)(this, "_expireDate", null);
60
- (0, _defineProperty2.default)(this, "_expiredContent", null);
61
- (0, _defineProperty2.default)(this, "_boundingBox", void 0);
62
- (0, _defineProperty2.default)(this, "_distanceToCamera", 0);
63
- (0, _defineProperty2.default)(this, "_screenSpaceError", 0);
64
- (0, _defineProperty2.default)(this, "_visibilityPlaneMask", void 0);
65
- (0, _defineProperty2.default)(this, "_visible", undefined);
66
- (0, _defineProperty2.default)(this, "_contentBoundingVolume", void 0);
67
- (0, _defineProperty2.default)(this, "_viewerRequestVolume", void 0);
68
- (0, _defineProperty2.default)(this, "_initialTransform", new _core.Matrix4());
69
- (0, _defineProperty2.default)(this, "_priority", 0);
70
- (0, _defineProperty2.default)(this, "_selectedFrame", 0);
71
- (0, _defineProperty2.default)(this, "_requestedFrame", 0);
72
- (0, _defineProperty2.default)(this, "_selectionDepth", 0);
73
- (0, _defineProperty2.default)(this, "_touchedFrame", 0);
74
- (0, _defineProperty2.default)(this, "_centerZDepth", 0);
75
- (0, _defineProperty2.default)(this, "_shouldRefine", false);
76
- (0, _defineProperty2.default)(this, "_stackLength", 0);
77
- (0, _defineProperty2.default)(this, "_visitedFrame", 0);
78
- (0, _defineProperty2.default)(this, "_inRequestVolume", false);
79
- (0, _defineProperty2.default)(this, "_lodJudge", null);
80
- this.header = header;
81
- this.tileset = tileset;
82
- this.id = extendedId || header.id;
83
- this.url = header.url;
84
- this.parent = parentHeader;
85
- this.refine = this._getRefine(header.refine);
86
- this.type = header.type;
87
- this.contentUrl = header.contentUrl;
88
- this._initializeLodMetric(header);
89
- this._initializeTransforms(header);
90
- this._initializeBoundingVolumes(header);
91
- this._initializeContent(header);
92
- this._initializeRenderingState(header);
93
- Object.seal(this);
94
- }
95
- (0, _createClass2.default)(Tile3D, [{
96
- key: "destroy",
97
- value: function destroy() {
98
- this.header = null;
99
- }
100
- }, {
101
- key: "isDestroyed",
102
- value: function isDestroyed() {
103
- return this.header === null;
104
- }
105
- }, {
106
- key: "selected",
107
- get: function get() {
108
- return this._selectedFrame === this.tileset._frameNumber;
109
- }
110
- }, {
111
- key: "isVisible",
112
- get: function get() {
113
- return this._visible;
114
- }
115
- }, {
116
- key: "isVisibleAndInRequestVolume",
117
- get: function get() {
118
- return this._visible && this._inRequestVolume;
119
- }
120
- }, {
121
- key: "hasRenderContent",
122
- get: function get() {
123
- return !this.hasEmptyContent && !this.hasTilesetContent;
124
- }
125
- }, {
126
- key: "hasChildren",
127
- get: function get() {
128
- return this.children.length > 0 || this.header.children && this.header.children.length > 0;
129
- }
130
- }, {
131
- key: "contentReady",
132
- get: function get() {
133
- return this.contentState === _constants.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
134
- }
135
- }, {
136
- key: "contentAvailable",
137
- get: function get() {
138
- return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
139
- }
140
- }, {
141
- key: "hasUnloadedContent",
142
- get: function get() {
143
- return this.hasRenderContent && this.contentUnloaded;
144
- }
145
- }, {
146
- key: "contentUnloaded",
147
- get: function get() {
148
- return this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED;
149
- }
150
- }, {
151
- key: "contentExpired",
152
- get: function get() {
153
- return this.contentState === _constants.TILE_CONTENT_STATE.EXPIRED;
154
- }
155
- }, {
156
- key: "contentFailed",
157
- get: function get() {
158
- return this.contentState === _constants.TILE_CONTENT_STATE.FAILED;
159
- }
160
- }, {
161
- key: "distanceToCamera",
162
- get: function get() {
163
- return this._distanceToCamera;
164
- }
165
- }, {
166
- key: "screenSpaceError",
167
- get: function get() {
168
- return this._screenSpaceError;
169
- }
170
- }, {
171
- key: "boundingBox",
172
- get: function get() {
173
- if (!this._boundingBox) {
174
- this._boundingBox = (0, _boundingVolume.getCartographicBounds)(this.header.boundingVolume, this.boundingVolume);
175
- }
176
- return this._boundingBox;
177
- }
178
- }, {
179
- key: "getScreenSpaceError",
180
- value: function getScreenSpaceError(frameState, useParentLodMetric) {
181
- switch (this.tileset.type) {
182
- case _constants.TILESET_TYPE.I3S:
183
- return (0, _i3sLod.getProjectedRadius)(this, frameState);
184
- case _constants.TILESET_TYPE.TILES3D:
185
- return (0, _tiles3dLod.getTiles3DScreenSpaceError)(this, frameState, useParentLodMetric);
186
- default:
187
- throw new Error('Unsupported tileset type');
188
- }
189
- }
190
- }, {
191
- key: "unselect",
192
- value: function unselect() {
193
- this._selectedFrame = 0;
194
- }
195
- }, {
196
- key: "_getGpuMemoryUsageInBytes",
197
- value: function _getGpuMemoryUsageInBytes() {
198
- return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
199
- }
200
- }, {
201
- key: "_getPriority",
202
- value: function _getPriority() {
203
- var traverser = this.tileset._traverser;
204
- var skipLevelOfDetail = traverser.options.skipLevelOfDetail;
205
- var maySkipTile = this.refine === _constants.TILE_REFINEMENT.ADD || skipLevelOfDetail;
206
- if (maySkipTile && !this.isVisible && this._visible !== undefined) {
207
- return -1;
208
- }
209
- if (this.tileset._frameNumber - this._touchedFrame >= 1) {
210
- return -1;
211
- }
212
- if (this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED) {
213
- return -1;
214
- }
215
- var parent = this.parent;
216
- var useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
217
- var screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
218
- var rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
219
- return Math.max(rootScreenSpaceError - screenSpaceError, 0);
220
- }
221
- }, {
222
- key: "loadContent",
223
- value: function () {
224
- var _loadContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
225
- var expired, requestToken, contentUrl, loader, options;
226
- return _regenerator.default.wrap(function _callee$(_context) {
227
- while (1) switch (_context.prev = _context.next) {
228
- case 0:
229
- if (!this.hasEmptyContent) {
230
- _context.next = 2;
231
- break;
232
- }
233
- return _context.abrupt("return", false);
234
- case 2:
235
- if (!this.content) {
236
- _context.next = 4;
237
- break;
238
- }
239
- return _context.abrupt("return", true);
240
- case 4:
241
- expired = this.contentExpired;
242
- if (expired) {
243
- this._expireDate = null;
244
- }
245
- this.contentState = _constants.TILE_CONTENT_STATE.LOADING;
246
- _context.next = 9;
247
- return this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
248
- case 9:
249
- requestToken = _context.sent;
250
- if (requestToken) {
251
- _context.next = 13;
252
- break;
253
- }
254
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
255
- return _context.abrupt("return", false);
256
- case 13:
257
- _context.prev = 13;
258
- contentUrl = this.tileset.getTileUrl(this.contentUrl);
259
- loader = this.tileset.loader;
260
- options = _objectSpread(_objectSpread({}, this.tileset.loadOptions), {}, (0, _defineProperty2.default)({}, loader.id, _objectSpread(_objectSpread({}, this.tileset.loadOptions[loader.id]), {}, {
261
- isTileset: this.type === 'json'
262
- }, this._getLoaderSpecificOptions(loader.id))));
263
- _context.next = 19;
264
- return (0, _core2.load)(contentUrl, loader, options);
265
- case 19:
266
- this.content = _context.sent;
267
- if (!this.tileset.options.contentLoader) {
268
- _context.next = 23;
269
- break;
270
- }
271
- _context.next = 23;
272
- return this.tileset.options.contentLoader(this);
273
- case 23:
274
- if (this._isTileset()) {
275
- this.tileset._initializeTileHeaders(this.content, this);
276
- }
277
- this.contentState = _constants.TILE_CONTENT_STATE.READY;
278
- this._onContentLoaded();
279
- return _context.abrupt("return", true);
280
- case 29:
281
- _context.prev = 29;
282
- _context.t0 = _context["catch"](13);
283
- this.contentState = _constants.TILE_CONTENT_STATE.FAILED;
284
- throw _context.t0;
285
- case 33:
286
- _context.prev = 33;
287
- requestToken.done();
288
- return _context.finish(33);
289
- case 36:
290
- case "end":
291
- return _context.stop();
292
- }
293
- }, _callee, this, [[13, 29, 33, 36]]);
294
- }));
295
- function loadContent() {
296
- return _loadContent.apply(this, arguments);
297
- }
298
- return loadContent;
299
- }()
300
- }, {
301
- key: "unloadContent",
302
- value: function unloadContent() {
303
- if (this.content && this.content.destroy) {
304
- this.content.destroy();
305
- }
306
- this.content = null;
307
- if (this.header.content && this.header.content.destroy) {
308
- this.header.content.destroy();
309
- }
310
- this.header.content = null;
311
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
312
- return true;
313
- }
314
- }, {
315
- key: "updateVisibility",
316
- value: function updateVisibility(frameState, viewportIds) {
317
- if (this._frameNumber === frameState.frameNumber) {
318
- return;
319
- }
320
- var parent = this.parent;
321
- var parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : _culling.CullingVolume.MASK_INDETERMINATE;
322
- if (this.tileset._traverser.options.updateTransforms) {
323
- var parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
324
- this._updateTransform(parentTransform);
325
- }
326
- this._distanceToCamera = this.distanceToTile(frameState);
327
- this._screenSpaceError = this.getScreenSpaceError(frameState, false);
328
- this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
329
- this._visible = this._visibilityPlaneMask !== _culling.CullingVolume.MASK_OUTSIDE;
330
- this._inRequestVolume = this.insideViewerRequestVolume(frameState);
331
- this._frameNumber = frameState.frameNumber;
332
- this.viewportIds = viewportIds;
333
- }
334
- }, {
335
- key: "visibility",
336
- value: function visibility(frameState, parentVisibilityPlaneMask) {
337
- var cullingVolume = frameState.cullingVolume;
338
- var boundingVolume = this.boundingVolume;
339
- return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
340
- }
341
- }, {
342
- key: "contentVisibility",
343
- value: function contentVisibility() {
344
- return true;
345
- }
346
- }, {
347
- key: "distanceToTile",
348
- value: function distanceToTile(frameState) {
349
- var boundingVolume = this.boundingVolume;
350
- return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
351
- }
352
- }, {
353
- key: "cameraSpaceZDepth",
354
- value: function cameraSpaceZDepth(_ref) {
355
- var camera = _ref.camera;
356
- var boundingVolume = this.boundingVolume;
357
- scratchVector.subVectors(boundingVolume.center, camera.position);
358
- return camera.direction.dot(scratchVector);
359
- }
360
- }, {
361
- key: "insideViewerRequestVolume",
362
- value: function insideViewerRequestVolume(frameState) {
363
- var viewerRequestVolume = this._viewerRequestVolume;
364
- return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
365
- }
366
- }, {
367
- key: "updateExpiration",
368
- value: function updateExpiration() {
369
- if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
370
- var now = Date.now();
371
- if (Date.lessThan(this._expireDate, now)) {
372
- this.contentState = _constants.TILE_CONTENT_STATE.EXPIRED;
373
- this._expiredContent = this.content;
374
- }
375
- }
376
- }
377
- }, {
378
- key: "extras",
379
- get: function get() {
380
- return this.header.extras;
381
- }
382
- }, {
383
- key: "_initializeLodMetric",
384
- value: function _initializeLodMetric(header) {
385
- if ('lodMetricType' in header) {
386
- this.lodMetricType = header.lodMetricType;
387
- } else {
388
- this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
389
- console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
390
- }
391
- if ('lodMetricValue' in header) {
392
- this.lodMetricValue = header.lodMetricValue;
393
- } else {
394
- this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
395
- console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
396
- }
397
- }
398
- }, {
399
- key: "_initializeTransforms",
400
- value: function _initializeTransforms(tileHeader) {
401
- this.transform = tileHeader.transform ? new _core.Matrix4(tileHeader.transform) : new _core.Matrix4();
402
- var parent = this.parent;
403
- var tileset = this.tileset;
404
- var parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
405
- this.computedTransform = new _core.Matrix4(parentTransform).multiplyRight(this.transform);
406
- var parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new _core.Matrix4();
407
- this._initialTransform = new _core.Matrix4(parentInitialTransform).multiplyRight(this.transform);
408
- }
409
- }, {
410
- key: "_initializeBoundingVolumes",
411
- value: function _initializeBoundingVolumes(tileHeader) {
412
- this._contentBoundingVolume = null;
413
- this._viewerRequestVolume = null;
414
- this._updateBoundingVolume(tileHeader);
415
- }
416
- }, {
417
- key: "_initializeContent",
418
- value: function _initializeContent(tileHeader) {
419
- this.content = {
420
- _tileset: this.tileset,
421
- _tile: this
422
- };
423
- this.hasEmptyContent = true;
424
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
425
- this.hasTilesetContent = false;
426
- if (tileHeader.contentUrl) {
427
- this.content = null;
428
- this.hasEmptyContent = false;
429
- }
430
- }
431
- }, {
432
- key: "_initializeRenderingState",
433
- value: function _initializeRenderingState(header) {
434
- this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
435
- this._shouldRefine = false;
436
- this._distanceToCamera = 0;
437
- this._centerZDepth = 0;
438
- this._screenSpaceError = 0;
439
- this._visibilityPlaneMask = _culling.CullingVolume.MASK_INDETERMINATE;
440
- this._visible = undefined;
441
- this._inRequestVolume = false;
442
- this._stackLength = 0;
443
- this._selectionDepth = 0;
444
- this._frameNumber = 0;
445
- this._touchedFrame = 0;
446
- this._visitedFrame = 0;
447
- this._selectedFrame = 0;
448
- this._requestedFrame = 0;
449
- this._priority = 0.0;
450
- }
451
- }, {
452
- key: "_getRefine",
453
- value: function _getRefine(refine) {
454
- return refine || this.parent && this.parent.refine || _constants.TILE_REFINEMENT.REPLACE;
455
- }
456
- }, {
457
- key: "_isTileset",
458
- value: function _isTileset() {
459
- return this.contentUrl.indexOf('.json') !== -1;
460
- }
461
- }, {
462
- key: "_onContentLoaded",
463
- value: function _onContentLoaded() {
464
- switch (this.content && this.content.type) {
465
- case 'vctr':
466
- case 'geom':
467
- this.tileset._traverser.disableSkipLevelOfDetail = true;
468
- break;
469
- default:
470
- }
471
- if (this._isTileset()) {
472
- this.hasTilesetContent = true;
473
- } else {
474
- this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
475
- }
476
- }
477
- }, {
478
- key: "_updateBoundingVolume",
479
- value: function _updateBoundingVolume(header) {
480
- this.boundingVolume = (0, _boundingVolume.createBoundingVolume)(header.boundingVolume, this.computedTransform, this.boundingVolume);
481
- var content = header.content;
482
- if (!content) {
483
- return;
484
- }
485
- if (content.boundingVolume) {
486
- this._contentBoundingVolume = (0, _boundingVolume.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
487
- }
488
- if (header.viewerRequestVolume) {
489
- this._viewerRequestVolume = (0, _boundingVolume.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
490
- }
491
- }
492
- }, {
493
- key: "_updateTransform",
494
- value: function _updateTransform() {
495
- var parentTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _core.Matrix4();
496
- var computedTransform = parentTransform.clone().multiplyRight(this.transform);
497
- var didTransformChange = !computedTransform.equals(this.computedTransform);
498
- if (!didTransformChange) {
499
- return;
500
- }
501
- this.computedTransform = computedTransform;
502
- this._updateBoundingVolume(this.header);
503
- }
504
- }, {
505
- key: "_getLoaderSpecificOptions",
506
- value: function _getLoaderSpecificOptions(loaderId) {
507
- switch (loaderId) {
508
- case 'i3s':
509
- return _objectSpread(_objectSpread({}, this.tileset.options.i3s), {}, {
510
- _tileOptions: {
511
- attributeUrls: this.header.attributeUrls,
512
- textureUrl: this.header.textureUrl,
513
- textureFormat: this.header.textureFormat,
514
- textureLoaderOptions: this.header.textureLoaderOptions,
515
- materialDefinition: this.header.materialDefinition,
516
- isDracoGeometry: this.header.isDracoGeometry,
517
- mbs: this.header.mbs
518
- },
519
- _tilesetOptions: {
520
- store: this.tileset.tileset.store,
521
- attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,
522
- fields: this.tileset.tileset.fields
523
- },
524
- isTileHeader: false
525
- });
526
- case '3d-tiles':
527
- case 'cesium-ion':
528
- default:
529
- return (0, _dTilesOptions.get3dTilesOptions)(this.tileset.tileset);
530
- }
531
- }
532
- }]);
533
- return Tile3D;
534
- }();
535
- exports.Tile3D = Tile3D;
536
- //# sourceMappingURL=tile-3d.js.map