@cesium/engine 0.1.0 → 1.1.0

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 (217) hide show
  1. package/Build/Workers/{AttributeCompression-4589338a.js → AttributeCompression-b646d393.js} +1 -1
  2. package/Build/Workers/{AxisAlignedBoundingBox-bfb1234f.js → AxisAlignedBoundingBox-a4321399.js} +1 -1
  3. package/Build/Workers/{BoundingRectangle-7ffc2153.js → BoundingRectangle-80d8801f.js} +1 -1
  4. package/Build/Workers/{BoxGeometry-93f344a3.js → BoxGeometry-33c10a4f.js} +1 -1
  5. package/Build/Workers/{Color-0c5aaf47.js → Color-1bf9a6e0.js} +1 -1
  6. package/Build/Workers/{CoplanarPolygonGeometryLibrary-6597982a.js → CoplanarPolygonGeometryLibrary-5c5b981b.js} +1 -1
  7. package/Build/Workers/{CorridorGeometryLibrary-2119580e.js → CorridorGeometryLibrary-7cbae7a0.js} +1 -1
  8. package/Build/Workers/{CylinderGeometry-f9503c6d.js → CylinderGeometry-42740df0.js} +1 -1
  9. package/Build/Workers/{EllipseGeometry-fedf72d5.js → EllipseGeometry-49a3ac21.js} +1 -1
  10. package/Build/Workers/{EllipseGeometryLibrary-4ea68687.js → EllipseGeometryLibrary-b891b2f8.js} +1 -1
  11. package/Build/Workers/{EllipseOutlineGeometry-e2ae6a35.js → EllipseOutlineGeometry-fbd72e07.js} +1 -1
  12. package/Build/Workers/{EllipsoidGeodesic-16de63ea.js → EllipsoidGeodesic-98c62a56.js} +1 -1
  13. package/Build/Workers/{EllipsoidGeometry-95c0330e.js → EllipsoidGeometry-a351dba8.js} +1 -1
  14. package/Build/Workers/{EllipsoidOutlineGeometry-d6d2ceec.js → EllipsoidOutlineGeometry-3e8779bf.js} +1 -1
  15. package/Build/Workers/{EllipsoidRhumbLine-ae5e65e0.js → EllipsoidRhumbLine-19756602.js} +1 -1
  16. package/Build/Workers/{EllipsoidTangentPlane-bfc674bf.js → EllipsoidTangentPlane-cfb50678.js} +1 -1
  17. package/Build/Workers/{EncodedCartesian3-f473ea18.js → EncodedCartesian3-81f70735.js} +1 -1
  18. package/Build/Workers/{FrustumGeometry-3bf2e4eb.js → FrustumGeometry-c5754412.js} +1 -1
  19. package/Build/Workers/{GeometryAttribute-df5f473e.js → GeometryAttribute-0bfd05e8.js} +1 -1
  20. package/Build/Workers/{GeometryInstance-aa75b4cf.js → GeometryInstance-451dc1cd.js} +1 -1
  21. package/Build/Workers/{GeometryPipeline-f0e46c42.js → GeometryPipeline-0166905d.js} +1 -1
  22. package/Build/Workers/{IntersectionTests-9de29d51.js → IntersectionTests-a93d3de9.js} +1 -1
  23. package/Build/Workers/{Matrix2-ce637455.js → Matrix2-13178034.js} +4 -2
  24. package/Build/Workers/{Matrix3-4f4df527.js → Matrix3-315394f6.js} +2 -1
  25. package/Build/Workers/{OrientedBoundingBox-d3ff3d4d.js → OrientedBoundingBox-b450cb61.js} +5 -5
  26. package/Build/Workers/{Plane-b81241c2.js → Plane-900aa728.js} +1 -1
  27. package/Build/Workers/{PolygonGeometryLibrary-6f4937bb.js → PolygonGeometryLibrary-f918ac26.js} +1 -1
  28. package/Build/Workers/PolygonPipeline-f59a8f0a.js +1345 -0
  29. package/Build/Workers/{PolylinePipeline-2e2b015c.js → PolylinePipeline-d8e6bd9b.js} +1 -1
  30. package/Build/Workers/{PolylineVolumeGeometryLibrary-7ee1d449.js → PolylineVolumeGeometryLibrary-125d2edf.js} +1 -1
  31. package/Build/Workers/{PrimitivePipeline-a9b7aae0.js → PrimitivePipeline-0d7b5ed4.js} +1 -1
  32. package/Build/Workers/{RectangleGeometryLibrary-9aa6c8f6.js → RectangleGeometryLibrary-0768db63.js} +1 -1
  33. package/Build/Workers/{TerrainEncoding-b52dcfc5.js → TerrainEncoding-06470d7f.js} +1 -1
  34. package/Build/Workers/{Transforms-2f755df8.js → Transforms-26539bce.js} +97 -83
  35. package/Build/Workers/{WallGeometryLibrary-ab19a93d.js → WallGeometryLibrary-6167b0fc.js} +1 -1
  36. package/Build/Workers/{WebMercatorProjection-9f25de49.js → WebMercatorProjection-13a90d41.js} +1 -1
  37. package/Build/Workers/cesiumWorkerBootstrapper.js +25 -1
  38. package/Build/Workers/combineGeometry.js +1 -1
  39. package/Build/Workers/createBoxGeometry.js +1 -1
  40. package/Build/Workers/createBoxOutlineGeometry.js +1 -1
  41. package/Build/Workers/createCircleGeometry.js +1 -1
  42. package/Build/Workers/createCircleOutlineGeometry.js +1 -1
  43. package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
  44. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  45. package/Build/Workers/createCorridorGeometry.js +1 -1
  46. package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
  47. package/Build/Workers/createCylinderGeometry.js +1 -1
  48. package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
  49. package/Build/Workers/createEllipseGeometry.js +1 -1
  50. package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
  51. package/Build/Workers/createEllipsoidGeometry.js +1 -1
  52. package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
  53. package/Build/Workers/createFrustumGeometry.js +1 -1
  54. package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
  55. package/Build/Workers/createGeometry.js +1 -1
  56. package/Build/Workers/createGroundPolylineGeometry.js +1 -1
  57. package/Build/Workers/createPlaneGeometry.js +1 -1
  58. package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
  59. package/Build/Workers/createPolygonGeometry.js +1 -1
  60. package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
  61. package/Build/Workers/createPolylineGeometry.js +1 -1
  62. package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
  63. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  64. package/Build/Workers/createRectangleGeometry.js +1 -1
  65. package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
  66. package/Build/Workers/createSimplePolylineGeometry.js +1 -1
  67. package/Build/Workers/createSphereGeometry.js +1 -1
  68. package/Build/Workers/createSphereOutlineGeometry.js +1 -1
  69. package/Build/Workers/createVectorTileClampedPolylines.js +1 -1
  70. package/Build/Workers/createVectorTileGeometries.js +1 -1
  71. package/Build/Workers/createVectorTilePoints.js +1 -1
  72. package/Build/Workers/createVectorTilePolygons.js +1 -1
  73. package/Build/Workers/createVectorTilePolylines.js +1 -1
  74. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  75. package/Build/Workers/createVerticesFromHeightmap.js +7 -3
  76. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +1 -1
  77. package/Build/Workers/createWallGeometry.js +1 -1
  78. package/Build/Workers/createWallOutlineGeometry.js +1 -1
  79. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +95 -76
  80. package/Build/Workers/decodeI3S.js +1 -1
  81. package/Build/Workers/package.js +25 -1
  82. package/Build/Workers/transferTypedArrayTest.js +25 -1
  83. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  84. package/README.md +9 -9
  85. package/Source/Core/EarthOrientationParameters.js +67 -63
  86. package/Source/Core/Ion.js +1 -1
  87. package/Source/Core/Matrix2.js +2 -1
  88. package/Source/Core/Matrix3.js +2 -1
  89. package/Source/Core/Matrix4.js +1 -0
  90. package/Source/Core/OrientedBoundingBox.js +4 -4
  91. package/Source/Core/S2Cell.js +3 -3
  92. package/Source/Core/Transforms.js +3 -7
  93. package/Source/DataSources/GpxDataSource.js +4 -6
  94. package/Source/DataSources/KmlDataSource.js +3 -5
  95. package/Source/Renderer/Context.js +230 -177
  96. package/Source/Renderer/Pass.js +3 -2
  97. package/Source/Scene/Cesium3DTileContentType.js +19 -0
  98. package/Source/Scene/Cesium3DTilesVoxelProvider.js +482 -0
  99. package/Source/Scene/Cesium3DTilesetMetadata.js +2 -2
  100. package/Source/Scene/ContentMetadata.js +2 -2
  101. package/Source/Scene/DerivedCommand.js +7 -0
  102. package/Source/Scene/Expression.js +1 -1
  103. package/Source/Scene/Globe.js +10 -0
  104. package/Source/Scene/GlobeSurfaceTileProvider.js +7 -0
  105. package/Source/Scene/GltfImageLoader.js +1 -1
  106. package/Source/Scene/GltfVertexBufferLoader.js +10 -2
  107. package/Source/Scene/GroupMetadata.js +2 -2
  108. package/Source/Scene/I3SDataProvider.js +2 -1
  109. package/Source/Scene/I3SFeature.js +1 -1
  110. package/Source/Scene/I3SLayer.js +64 -2
  111. package/Source/Scene/I3SNode.js +50 -6
  112. package/Source/Scene/ImplicitMetadataView.js +2 -2
  113. package/Source/Scene/ImplicitSubtreeCache.js +127 -0
  114. package/Source/Scene/ImplicitSubtreeMetadata.js +2 -2
  115. package/Source/Scene/ImplicitTileset.js +3 -2
  116. package/Source/Scene/KeyframeNode.js +47 -0
  117. package/Source/Scene/Megatexture.js +490 -0
  118. package/Source/Scene/MetadataClass.js +60 -25
  119. package/Source/Scene/MetadataClassProperty.js +132 -68
  120. package/Source/Scene/MetadataComponentType.js +78 -57
  121. package/Source/Scene/MetadataEnum.js +59 -23
  122. package/Source/Scene/MetadataEnumValue.js +49 -15
  123. package/Source/Scene/MetadataSchema.js +53 -24
  124. package/Source/Scene/MetadataSchemaLoader.js +2 -2
  125. package/Source/Scene/MetadataTableProperty.js +2 -2
  126. package/Source/Scene/MetadataType.js +6 -14
  127. package/Source/Scene/Model/GeoJsonLoader.js +1 -1
  128. package/Source/Scene/Model/Model.js +38 -6
  129. package/Source/Scene/Model/buildDrawCommand.js +19 -11
  130. package/Source/Scene/PointCloud.js +1 -1
  131. package/Source/Scene/PropertyAttribute.js +2 -2
  132. package/Source/Scene/PropertyAttributeProperty.js +2 -2
  133. package/Source/Scene/PropertyTable.js +2 -2
  134. package/Source/Scene/PropertyTexture.js +2 -2
  135. package/Source/Scene/PropertyTextureProperty.js +2 -2
  136. package/Source/Scene/ResourceCache.js +9 -1
  137. package/Source/Scene/ResourceCacheKey.js +9 -1
  138. package/Source/Scene/Scene.js +20 -50
  139. package/Source/Scene/SpatialNode.js +375 -0
  140. package/Source/Scene/StructuralMetadata.js +2 -2
  141. package/Source/Scene/TileMetadata.js +2 -2
  142. package/Source/Scene/TilesetMetadata.js +2 -2
  143. package/Source/Scene/VoxelBoxShape.js +527 -0
  144. package/Source/Scene/VoxelContent.js +169 -0
  145. package/Source/Scene/VoxelCylinderShape.js +937 -0
  146. package/Source/Scene/VoxelEllipsoidShape.js +937 -0
  147. package/Source/Scene/VoxelPrimitive.js +1919 -0
  148. package/Source/Scene/VoxelProvider.js +255 -0
  149. package/Source/Scene/VoxelRenderResources.js +224 -0
  150. package/Source/Scene/VoxelShape.js +152 -0
  151. package/Source/Scene/VoxelShapeType.js +105 -0
  152. package/Source/Scene/VoxelTraversal.js +1144 -0
  153. package/Source/Scene/buildVoxelDrawCommands.js +116 -0
  154. package/Source/Scene/parseBatchTable.js +18 -2
  155. package/Source/Scene/preprocess3DTileContent.js +8 -0
  156. package/Source/Scene/processVoxelProperties.js +455 -0
  157. package/Source/Shaders/BillboardCollectionVS.glsl +1 -1
  158. package/Source/Shaders/BillboardCollectionVS.js +1 -1
  159. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  160. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  161. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +9 -0
  162. package/Source/Shaders/Builtin/Constants/passVoxels.js +11 -0
  163. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
  164. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +55 -43
  165. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +55 -43
  166. package/Source/Shaders/GlobeFS.glsl +2 -1
  167. package/Source/Shaders/GlobeFS.js +2 -1
  168. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +5 -2
  169. package/Source/Shaders/PointPrimitiveCollectionVS.js +5 -2
  170. package/Source/Shaders/Voxels/IntersectBox.glsl +79 -0
  171. package/Source/Shaders/Voxels/IntersectBox.js +81 -0
  172. package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +70 -0
  173. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +72 -0
  174. package/Source/Shaders/Voxels/IntersectCylinder.glsl +273 -0
  175. package/Source/Shaders/Voxels/IntersectCylinder.js +275 -0
  176. package/Source/Shaders/Voxels/IntersectDepth.glsl +23 -0
  177. package/Source/Shaders/Voxels/IntersectDepth.js +25 -0
  178. package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +337 -0
  179. package/Source/Shaders/Voxels/IntersectEllipsoid.js +339 -0
  180. package/Source/Shaders/Voxels/Intersection.glsl +54 -0
  181. package/Source/Shaders/Voxels/Intersection.js +56 -0
  182. package/Source/Shaders/Voxels/IntersectionUtils.glsl +151 -0
  183. package/Source/Shaders/Voxels/IntersectionUtils.js +153 -0
  184. package/Source/Shaders/Voxels/Megatexture.glsl +136 -0
  185. package/Source/Shaders/Voxels/Megatexture.js +138 -0
  186. package/Source/Shaders/Voxels/Octree.glsl +221 -0
  187. package/Source/Shaders/Voxels/Octree.js +223 -0
  188. package/Source/Shaders/Voxels/VoxelFS.glsl +150 -0
  189. package/Source/Shaders/Voxels/VoxelFS.js +152 -0
  190. package/Source/Shaders/Voxels/VoxelVS.glsl +11 -0
  191. package/Source/Shaders/Voxels/VoxelVS.js +13 -0
  192. package/Source/Shaders/Voxels/convertUvToBox.glsl +16 -0
  193. package/Source/Shaders/Voxels/convertUvToBox.js +18 -0
  194. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +79 -0
  195. package/Source/Shaders/Voxels/convertUvToCylinder.js +81 -0
  196. package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +133 -0
  197. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +135 -0
  198. package/Source/ThirdParty/Workers/draco_decoder_nodejs.js +100 -101
  199. package/Source/ThirdParty/Workers/pako_deflate.min.js +2 -2
  200. package/Source/ThirdParty/Workers/pako_inflate.min.js +2 -2
  201. package/Source/ThirdParty/draco_decoder.wasm +0 -0
  202. package/Source/Widget/CesiumWidget.js +1 -1
  203. package/index.d.ts +961 -56
  204. package/index.js +92 -60
  205. package/package.json +6 -4
  206. package/Build/ThirdParty/Workers/basis_transcoder.js +0 -2233
  207. package/Build/ThirdParty/Workers/draco_decoder_nodejs.js +0 -1872
  208. package/Build/ThirdParty/Workers/package.json +0 -1
  209. package/Build/ThirdParty/Workers/pako_deflate.min.js +0 -589
  210. package/Build/ThirdParty/Workers/pako_inflate.min.js +0 -798
  211. package/Build/ThirdParty/Workers/z-worker-pako.js +0 -503
  212. package/Build/ThirdParty/basis_transcoder.wasm +0 -0
  213. package/Build/ThirdParty/draco_decoder.wasm +0 -0
  214. package/Build/ThirdParty/google-earth-dbroot-parser.js +0 -8019
  215. package/Build/Widget/CesiumWidget.css +0 -120
  216. package/Build/Widget/lighter.css +0 -13
  217. package/Build/Workers/PolygonPipeline-774a8aaf.js +0 -1341
@@ -35,6 +35,11 @@ function I3SLayer(dataProvider, layerData, index) {
35
35
  .concat(`${layerData.href}`);
36
36
  }
37
37
 
38
+ this._version = layerData.store.version;
39
+ const splitVersion = this._version.split(".");
40
+ this._majorVersion = parseInt(splitVersion[0]);
41
+ this._minorVersion = splitVersion.length > 1 ? parseInt(splitVersion[1]) : 0;
42
+
38
43
  this._resource = new Resource({ url: tilesetUrl });
39
44
  this._resource.setQueryParameters(
40
45
  this._dataProvider.resource.queryParameters
@@ -98,11 +103,68 @@ Object.defineProperties(I3SLayer.prototype, {
98
103
  return this._data;
99
104
  },
100
105
  },
106
+
107
+ /**
108
+ * The version string of the loaded I3S dataset
109
+ * @memberof I3SLayer.prototype
110
+ * @type {String}
111
+ * @readonly
112
+ */
113
+ version: {
114
+ get: function () {
115
+ return this._version;
116
+ },
117
+ },
118
+
119
+ /**
120
+ * The major version number of the loaded I3S dataset
121
+ * @memberof I3SLayer.prototype
122
+ * @type {Number}
123
+ * @readonly
124
+ */
125
+ majorVersion: {
126
+ get: function () {
127
+ return this._majorVersion;
128
+ },
129
+ },
130
+
131
+ /**
132
+ * The minor version number of the loaded I3S dataset
133
+ * @memberof I3SLayer.prototype
134
+ * @type {Number}
135
+ * @readonly
136
+ */
137
+ minorVersion: {
138
+ get: function () {
139
+ return this._minorVersion;
140
+ },
141
+ },
142
+
143
+ /**
144
+ * When <code>true</code>, when the loaded I3S version is 1.6 or older
145
+ * @memberof I3SLayer.prototype
146
+ * @type {Boolean}
147
+ * @readonly
148
+ */
149
+ legacyVersion16: {
150
+ get: function () {
151
+ if (!defined(this.version)) {
152
+ return undefined;
153
+ }
154
+ if (
155
+ this.majorVersion < 1 ||
156
+ (this.majorVersion === 1 && this.minorVersion <= 6)
157
+ ) {
158
+ return true;
159
+ }
160
+ return false;
161
+ },
162
+ },
101
163
  });
102
164
 
103
165
  /**
104
166
  * Loads the content, including the root node definition and its children
105
- * @returns {Promise.<void>} A promise that is resolved when the layer data is loaded
167
+ * @returns {Promise} A promise that is resolved when the layer data is loaded
106
168
  * @private
107
169
  */
108
170
  I3SLayer.prototype.load = function () {
@@ -121,7 +183,7 @@ I3SLayer.prototype.load = function () {
121
183
  return that._tileset.readyPromise.then(function () {
122
184
  that._rootNode._tile = that._tileset._root;
123
185
  that._tileset._root._i3sNode = that._rootNode;
124
- if (that._data.store.version === "1.6") {
186
+ if (that.legacyVersion16) {
125
187
  return that._rootNode._loadChildren();
126
188
  }
127
189
  });
@@ -240,6 +240,52 @@ I3SNode.prototype.loadFields = function () {
240
240
  return Promise.all(promises);
241
241
  };
242
242
 
243
+ /**
244
+ * Returns the fields for a given picked position
245
+ * @param {Cartesian3} pickedPosition The picked position
246
+ * @returns {Object} Object containing field names and their values
247
+ */
248
+ I3SNode.prototype.getFieldsForPickedPosition = function (pickedPosition) {
249
+ const geometry = this.geometryData[0];
250
+ if (!defined(geometry.customAttributes.featureIndex)) {
251
+ return {};
252
+ }
253
+
254
+ const location = geometry.getClosestPointIndexOnTriangle(
255
+ pickedPosition.x,
256
+ pickedPosition.y,
257
+ pickedPosition.z
258
+ );
259
+
260
+ if (
261
+ location.index === -1 ||
262
+ location.index > geometry.customAttributes.featureIndex.length
263
+ ) {
264
+ return {};
265
+ }
266
+
267
+ const featureIndex = geometry.customAttributes.featureIndex[location.index];
268
+ return this.getFieldsForFeature(featureIndex);
269
+ };
270
+
271
+ /**
272
+ * Returns the fields for a given feature
273
+ * @param {Number} featureIndex Index of the feature whose attributes we want to get
274
+ * @returns {Object} Object containing field names and their values
275
+ */
276
+ I3SNode.prototype.getFieldsForFeature = function (featureIndex) {
277
+ const featureFields = {};
278
+ for (const fieldName in this.fields) {
279
+ if (this.fields.hasOwnProperty(fieldName)) {
280
+ const field = this.fields[fieldName];
281
+ if (featureIndex >= 0 && featureIndex < field.values.length) {
282
+ featureFields[field.name] = field.values[featureIndex];
283
+ }
284
+ }
285
+ }
286
+ return featureFields;
287
+ };
288
+
243
289
  /**
244
290
  * @private
245
291
  */
@@ -336,11 +382,6 @@ I3SNode.prototype._loadFeatureData = function () {
336
382
  this._featureData.push(newFeatureData);
337
383
  featurePromises.push(newFeatureData.load());
338
384
  }
339
- } else if (defined(this._data.mesh) && defined(this._data.mesh.attribute)) {
340
- const featureURI = `./features/0`;
341
- const newFeatureData = new I3SFeature(this, featureURI);
342
- this._featureData.push(newFeatureData);
343
- featurePromises.push(newFeatureData.load());
344
385
  }
345
386
 
346
387
  return Promise.all(featurePromises);
@@ -661,7 +702,10 @@ I3SNode.prototype._createContentURL = function () {
661
702
  };
662
703
 
663
704
  // Load the geometry data
664
- const dataPromises = [this._loadFeatureData(), this._loadGeometryData()];
705
+ const dataPromises = [this._loadGeometryData()];
706
+ if (this._dataProvider.legacyVersion16) {
707
+ dataPromises.push(this._loadFeatureData());
708
+ }
665
709
 
666
710
  const that = this;
667
711
  return Promise.all(dataPromises).then(function () {
@@ -56,7 +56,7 @@ Object.defineProperties(ImplicitMetadataView.prototype, {
56
56
  },
57
57
 
58
58
  /**
59
- * Extras in the JSON object.
59
+ * Extra user-defined properties.
60
60
  *
61
61
  * @memberof ImplicitMetadataView.prototype
62
62
  * @type {Object}
@@ -69,7 +69,7 @@ Object.defineProperties(ImplicitMetadataView.prototype, {
69
69
  },
70
70
 
71
71
  /**
72
- * Extensions in the JSON object.
72
+ * An object containing extensions.
73
73
  *
74
74
  * @memberof ImplicitMetadataView.prototype
75
75
  * @type {Object}
@@ -0,0 +1,127 @@
1
+ import defaultValue from "../Core/defaultValue.js";
2
+ import DeveloperError from "../Core/DeveloperError.js";
3
+ import DoubleEndedPriorityQueue from "../Core/DoubleEndedPriorityQueue.js";
4
+
5
+ /**
6
+ * @alias ImplicitSubtreeCache
7
+ * @constructor
8
+ *
9
+ * @param {Object} [options] Object with the following properties
10
+ * @param {Number} [options.maximumSubtreeCount=0] The total number of subtrees this cache can store. If adding a new subtree would exceed this limit, the lowest priority subtrees will be removed until there is room, unless the subtree that is going to be removed is the parent of the new subtree, in which case it will not be removed and the new subtree will still be added, exceeding the memory limit.
11
+ *
12
+ * @private
13
+ */
14
+ function ImplicitSubtreeCache(options) {
15
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
16
+
17
+ /**
18
+ * @type {Number}
19
+ * @private
20
+ */
21
+ this._maximumSubtreeCount = defaultValue(options.maximumSubtreeCount, 0);
22
+
23
+ /**
24
+ * A counter that goes up whenever a subtree is added. Used to sort subtrees by recency.
25
+ * @type {Number}
26
+ * @private
27
+ */
28
+ this._subtreeRequestCounter = 0;
29
+
30
+ /**
31
+ * @type {DoubleEndedPriorityQueue}
32
+ * @private
33
+ */
34
+ this._queue = new DoubleEndedPriorityQueue({
35
+ comparator: ImplicitSubtreeCache.comparator,
36
+ });
37
+ }
38
+
39
+ /**
40
+ * @param {ImplicitSubtree} subtree
41
+ */
42
+ ImplicitSubtreeCache.prototype.addSubtree = function (subtree) {
43
+ const cacheNode = new ImplicitSubtreeCacheNode(
44
+ subtree,
45
+ this._subtreeRequestCounter
46
+ );
47
+ this._subtreeRequestCounter++;
48
+ this._queue.insert(cacheNode);
49
+
50
+ // Make sure the parent subtree exists in the cache
51
+ const subtreeCoord = subtree.implicitCoordinates;
52
+ if (subtreeCoord.level > 0) {
53
+ const parentCoord = subtreeCoord.getParentSubtreeCoordinates();
54
+ const parentNode = this.find(parentCoord);
55
+
56
+ //>>includeStart('debug', pragmas.debug)
57
+ if (parentNode === undefined) {
58
+ throw new DeveloperError("parent node needs to exist");
59
+ }
60
+ //>>includeEnd('debug');
61
+ }
62
+
63
+ if (this._maximumSubtreeCount > 0) {
64
+ while (this._queue.length > this._maximumSubtreeCount) {
65
+ const lowestPriorityNode = this._queue.getMinimum();
66
+ if (lowestPriorityNode === cacheNode) {
67
+ // Don't remove itself
68
+ break;
69
+ }
70
+
71
+ this._queue.removeMinimum();
72
+ }
73
+ }
74
+ };
75
+
76
+ /**
77
+ * @param {ImplicitTileCoordinates} subtreeCoord
78
+ * @returns {ImplicitSubtree|undefined}
79
+ */
80
+ ImplicitSubtreeCache.prototype.find = function (subtreeCoord) {
81
+ const queue = this._queue;
82
+ const array = queue.internalArray;
83
+ const arrayLength = queue.length;
84
+
85
+ for (let i = 0; i < arrayLength; i++) {
86
+ const other = array[i];
87
+ const otherSubtree = other.subtree;
88
+ const otherCoord = otherSubtree.implicitCoordinates;
89
+ if (subtreeCoord.isEqual(otherCoord)) {
90
+ return other.subtree;
91
+ }
92
+ }
93
+ return undefined;
94
+ };
95
+
96
+ /**
97
+ * @param {ImplicitSubtreeCacheNode} a
98
+ * @param {ImplicitSubtreeCacheNode} b
99
+ * @returns {Number}
100
+ */
101
+ ImplicitSubtreeCache.comparator = function (a, b) {
102
+ const aCoord = a.subtree.implicitCoordinates;
103
+ const bCoord = b.subtree.implicitCoordinates;
104
+ if (aCoord.isAncestor(bCoord)) {
105
+ // Technically this shouldn't happen because the ancestor subtree was supposed to be added to the cache first.
106
+ return +1.0;
107
+ } else if (bCoord.isAncestor(aCoord)) {
108
+ return -1.0;
109
+ }
110
+ return a.stamp - b.stamp;
111
+ };
112
+
113
+ /**
114
+ * @alias ImplicitSubtreeCacheNode
115
+ * @constructor
116
+ *
117
+ * @param {ImplicitSubtree} subtree
118
+ * @param {Number} stamp
119
+ *
120
+ * @private
121
+ */
122
+ function ImplicitSubtreeCacheNode(subtree, stamp) {
123
+ this.subtree = subtree;
124
+ this.stamp = stamp;
125
+ }
126
+
127
+ export default ImplicitSubtreeCache;
@@ -54,7 +54,7 @@ Object.defineProperties(ImplicitSubtreeMetadata.prototype, {
54
54
  },
55
55
 
56
56
  /**
57
- * Extras in the JSON object.
57
+ * Extra user-defined properties.
58
58
  *
59
59
  * @memberof ImplicitSubtreeMetadata.prototype
60
60
  * @type {Object}
@@ -68,7 +68,7 @@ Object.defineProperties(ImplicitSubtreeMetadata.prototype, {
68
68
  },
69
69
 
70
70
  /**
71
- * Extensions in the JSON object.
71
+ * An object containing extensions.
72
72
  *
73
73
  * @memberof ImplicitSubtreeMetadata.prototype
74
74
  * @type {Object}
@@ -64,10 +64,11 @@ function ImplicitTileset(baseResource, tileJson, metadataSchema) {
64
64
  if (
65
65
  !defined(boundingVolume.box) &&
66
66
  !defined(boundingVolume.region) &&
67
- !hasExtension(boundingVolume, "3DTILES_bounding_volume_S2")
67
+ !hasExtension(boundingVolume, "3DTILES_bounding_volume_S2") &&
68
+ !hasExtension(boundingVolume, "3DTILES_bounding_volume_cylinder")
68
69
  ) {
69
70
  throw new RuntimeError(
70
- "Only box, region and 3DTILES_bounding_volume_S2 are supported for implicit tiling"
71
+ "Only box, region, 3DTILES_bounding_volume_S2, and 3DTILES_bounding_volume_cylinder are supported for implicit tiling"
71
72
  );
72
73
  }
73
74
 
@@ -0,0 +1,47 @@
1
+ const LoadState = Object.freeze({
2
+ UNLOADED: 0, // Has no data and is in dormant state
3
+ RECEIVING: 1, // Is waiting on data from the provider
4
+ RECEIVED: 2, // Received data from the provider
5
+ LOADED: 3, // Processed data from provider
6
+ FAILED: 4, // Failed to receive data from the provider
7
+ UNAVAILABLE: 5, // No data available for this tile
8
+ });
9
+
10
+ /**
11
+ * @alias KeyframeNode
12
+ * @constructor
13
+ *
14
+ * @param {SpatialNode} spatialNode
15
+ * @param {Number} keyframe
16
+ *
17
+ * @private
18
+ */
19
+ function KeyframeNode(spatialNode, keyframe) {
20
+ this.spatialNode = spatialNode;
21
+ this.keyframe = keyframe;
22
+ this.state = LoadState.UNLOADED;
23
+ this.metadatas = [];
24
+ this.megatextureIndex = -1;
25
+ this.priority = -Number.MAX_VALUE;
26
+ this.highPriorityFrameNumber = -1;
27
+ }
28
+
29
+ /**
30
+ * @param {KeyframeNode} a
31
+ * @param {KeyframeNode} b
32
+ */
33
+ KeyframeNode.priorityComparator = function (a, b) {
34
+ return a.priority - b.priority;
35
+ };
36
+
37
+ /**
38
+ * @param {KeyframeNode} a
39
+ * @param {KeyframeNode} b
40
+ */
41
+ KeyframeNode.searchComparator = function (a, b) {
42
+ return a.keyframe - b.keyframe;
43
+ };
44
+
45
+ KeyframeNode.LoadState = LoadState;
46
+
47
+ export default KeyframeNode;