Tileset3DTileContent.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import defaultValue from "../Core/defaultValue.js";
  2. import destroyObject from "../Core/destroyObject.js";
  3. import getStringFromTypedArray from "../Core/getStringFromTypedArray.js";
  4. import RuntimeError from "../Core/RuntimeError.js";
  5. import when from "../ThirdParty/when.js";
  6. /**
  7. * Represents content for a tile in a
  8. * {@link https://github.com/CesiumGS/3d-tiles/tree/master/specification|3D Tiles} tileset whose
  9. * content points to another 3D Tiles tileset.
  10. * <p>
  11. * Implements the {@link Cesium3DTileContent} interface.
  12. * </p>
  13. *
  14. * @alias Tileset3DTileContent
  15. * @constructor
  16. *
  17. * @private
  18. */
  19. function Tileset3DTileContent(
  20. tileset,
  21. tile,
  22. resource,
  23. arrayBuffer,
  24. byteOffset
  25. ) {
  26. this._tileset = tileset;
  27. this._tile = tile;
  28. this._resource = resource;
  29. this._readyPromise = when.defer();
  30. this.featurePropertiesDirty = false;
  31. initialize(this, arrayBuffer, byteOffset);
  32. }
  33. Object.defineProperties(Tileset3DTileContent.prototype, {
  34. featuresLength: {
  35. get: function () {
  36. return 0;
  37. },
  38. },
  39. pointsLength: {
  40. get: function () {
  41. return 0;
  42. },
  43. },
  44. trianglesLength: {
  45. get: function () {
  46. return 0;
  47. },
  48. },
  49. geometryByteLength: {
  50. get: function () {
  51. return 0;
  52. },
  53. },
  54. texturesByteLength: {
  55. get: function () {
  56. return 0;
  57. },
  58. },
  59. batchTableByteLength: {
  60. get: function () {
  61. return 0;
  62. },
  63. },
  64. innerContents: {
  65. get: function () {
  66. return undefined;
  67. },
  68. },
  69. readyPromise: {
  70. get: function () {
  71. return this._readyPromise.promise;
  72. },
  73. },
  74. tileset: {
  75. get: function () {
  76. return this._tileset;
  77. },
  78. },
  79. tile: {
  80. get: function () {
  81. return this._tile;
  82. },
  83. },
  84. url: {
  85. get: function () {
  86. return this._resource.getUrlComponent(true);
  87. },
  88. },
  89. batchTable: {
  90. get: function () {
  91. return undefined;
  92. },
  93. },
  94. });
  95. function initialize(content, arrayBuffer, byteOffset) {
  96. byteOffset = defaultValue(byteOffset, 0);
  97. var uint8Array = new Uint8Array(arrayBuffer);
  98. var jsonString = getStringFromTypedArray(uint8Array, byteOffset);
  99. var tilesetJson;
  100. try {
  101. tilesetJson = JSON.parse(jsonString);
  102. } catch (error) {
  103. content._readyPromise.reject(new RuntimeError("Invalid tile content."));
  104. return;
  105. }
  106. content._tileset.loadTileset(content._resource, tilesetJson, content._tile);
  107. content._readyPromise.resolve(content);
  108. }
  109. /**
  110. * Part of the {@link Cesium3DTileContent} interface. <code>Tileset3DTileContent</code>
  111. * always returns <code>false</code> since a tile of this type does not have any features.
  112. */
  113. Tileset3DTileContent.prototype.hasProperty = function (batchId, name) {
  114. return false;
  115. };
  116. /**
  117. * Part of the {@link Cesium3DTileContent} interface. <code>Tileset3DTileContent</code>
  118. * always returns <code>undefined</code> since a tile of this type does not have any features.
  119. */
  120. Tileset3DTileContent.prototype.getFeature = function (batchId) {
  121. return undefined;
  122. };
  123. Tileset3DTileContent.prototype.applyDebugSettings = function (
  124. enabled,
  125. color
  126. ) {};
  127. Tileset3DTileContent.prototype.applyStyle = function (style) {};
  128. Tileset3DTileContent.prototype.update = function (tileset, frameState) {};
  129. Tileset3DTileContent.prototype.isDestroyed = function () {
  130. return false;
  131. };
  132. Tileset3DTileContent.prototype.destroy = function () {
  133. return destroyObject(this);
  134. };
  135. export default Tileset3DTileContent;