Tileset3DTileContent.js 4.1 KB

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