@cesium/engine 13.1.0 → 14.0.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 (139) hide show
  1. package/Build/Workers/{chunk-R2KGFZBA.js → chunk-3JBEPBPL.js} +13 -13
  2. package/Build/Workers/{chunk-NQDKNE7V.js → chunk-3LYROPON.js} +13 -13
  3. package/Build/Workers/{chunk-CNPP6TQ2.js → chunk-3PIZQT3I.js} +4 -4
  4. package/Build/Workers/{chunk-MGABCOOH.js → chunk-3QLSKXKF.js} +6 -6
  5. package/Build/Workers/{chunk-THDHWSEJ.js → chunk-4CHMVQTQ.js} +4 -4
  6. package/Build/Workers/{chunk-SAKQO5NX.js → chunk-5KWRW7YL.js} +2 -2
  7. package/Build/Workers/{chunk-EHGQQA7C.js → chunk-5S5OOA6U.js} +1 -1
  8. package/Build/Workers/{chunk-LFUFGHL3.js → chunk-77XPS7ZA.js} +10 -10
  9. package/Build/Workers/{chunk-GIOZHX7U.js → chunk-7EO56M5R.js} +2 -2
  10. package/Build/Workers/{chunk-PM76TX2X.js → chunk-7UHKH6M3.js} +6 -6
  11. package/Build/Workers/{chunk-GSLKQJM2.js → chunk-7ZB2RVIQ.js} +10 -10
  12. package/Build/Workers/{chunk-2SRHVCFD.js → chunk-B4GSRXE3.js} +6 -6
  13. package/Build/Workers/{chunk-J7BMSSY7.js → chunk-CI2HEJFC.js} +13 -13
  14. package/Build/Workers/{chunk-BMFWWTD7.js → chunk-D7ZBZPHV.js} +5 -5
  15. package/Build/Workers/{chunk-5JY4LYO3.js → chunk-DT5NFR5C.js} +7 -7
  16. package/Build/Workers/{chunk-AXYZUG4N.js → chunk-ED6GLQTK.js} +1 -1
  17. package/Build/Workers/{chunk-APCS5YJI.js → chunk-EWDGNOJE.js} +7 -7
  18. package/Build/Workers/{chunk-TOHDFUJM.js → chunk-F4CUH4MR.js} +4 -4
  19. package/Build/Workers/{chunk-EYZFEJX3.js → chunk-FFBJDW4A.js} +6 -6
  20. package/Build/Workers/{chunk-K6SQV4IS.js → chunk-FX4R4MTH.js} +6 -6
  21. package/Build/Workers/{chunk-B6IJY6AN.js → chunk-FYGLNDKG.js} +7 -7
  22. package/Build/Workers/{chunk-OARMSJUU.js → chunk-G3BVMPWG.js} +2 -2
  23. package/Build/Workers/{chunk-EJ5DT5BP.js → chunk-HEZHXDYB.js} +1 -1
  24. package/Build/Workers/{chunk-YVGU235V.js → chunk-HKHQ3EDR.js} +4 -4
  25. package/Build/Workers/{chunk-CBE4HRBH.js → chunk-HUFQVUMY.js} +7 -7
  26. package/Build/Workers/{chunk-S3UM4OKP.js → chunk-J7IH4EYI.js} +7 -7
  27. package/Build/Workers/{chunk-IP7F2MVW.js → chunk-JHBPC4LK.js} +7 -7
  28. package/Build/Workers/{chunk-ZWSWJYJP.js → chunk-JPDKYBLF.js} +13 -13
  29. package/Build/Workers/{chunk-5ICYLS6B.js → chunk-K4AH3TDT.js} +10 -10
  30. package/Build/Workers/{chunk-OGRXNUR2.js → chunk-KHWLAQVA.js} +1 -1
  31. package/Build/Workers/{chunk-KRVALCCI.js → chunk-KM6MITPF.js} +5 -5
  32. package/Build/Workers/{chunk-B34JXFHF.js → chunk-KSYBJA4M.js} +5 -5
  33. package/Build/Workers/{chunk-OZTFRHA2.js → chunk-LJBJM6VI.js} +6 -6
  34. package/Build/Workers/{chunk-M2AA2ARJ.js → chunk-LNSWJ43X.js} +11 -11
  35. package/Build/Workers/{chunk-PBJQFLKS.js → chunk-LOZ4NKY3.js} +11 -11
  36. package/Build/Workers/{chunk-54I6VSRP.js → chunk-LS3KVHYY.js} +6 -6
  37. package/Build/Workers/{chunk-3SCCWLZS.js → chunk-MVM4JV5U.js} +9 -9
  38. package/Build/Workers/{chunk-PTFIVVLX.js → chunk-N2XAJBC6.js} +12 -12
  39. package/Build/Workers/{chunk-FNCXBBCF.js → chunk-OMXHEJTK.js} +2 -2
  40. package/Build/Workers/{chunk-IXNXKVOB.js → chunk-PWF4EY5P.js} +4 -4
  41. package/Build/Workers/{chunk-DWIKWWEE.js → chunk-Q4ZVWJXX.js} +5 -5
  42. package/Build/Workers/{chunk-WUIDEXAN.js → chunk-SDIDRZDG.js} +7 -7
  43. package/Build/Workers/{chunk-UBAHTE4Q.js → chunk-TVL3F7IU.js} +1 -1
  44. package/Build/Workers/{chunk-KO232FLP.js → chunk-TY4DKOWR.js} +2 -2
  45. package/Build/Workers/{chunk-WE4KF4AM.js → chunk-VCNOFQYH.js} +9 -9
  46. package/Build/Workers/{chunk-2ONAV62A.js → chunk-WEHZP4SE.js} +7 -7
  47. package/Build/Workers/{chunk-HI73PIPQ.js → chunk-WVNLSTOF.js} +2 -2
  48. package/Build/Workers/{chunk-LQT2ZK7D.js → chunk-XK4OP6VA.js} +17 -17
  49. package/Build/Workers/{chunk-K62EHZFT.js → chunk-YJX7X577.js} +15 -15
  50. package/Build/Workers/{chunk-T34EOLFR.js → chunk-Z3QWTHI7.js} +14 -14
  51. package/Build/Workers/{chunk-WAJNX74N.js → chunk-ZGFIT57T.js} +17 -17
  52. package/Build/Workers/{chunk-5I3LPAS7.js → chunk-ZMNLEL6W.js} +5 -5
  53. package/Build/Workers/combineGeometry.js +22 -22
  54. package/Build/Workers/createBoxGeometry.js +16 -16
  55. package/Build/Workers/createBoxOutlineGeometry.js +14 -14
  56. package/Build/Workers/createCircleGeometry.js +24 -24
  57. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  60. package/Build/Workers/createCorridorGeometry.js +27 -27
  61. package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
  62. package/Build/Workers/createCylinderGeometry.js +18 -18
  63. package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
  64. package/Build/Workers/createEllipseGeometry.js +24 -24
  65. package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipsoidGeometry.js +17 -17
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
  68. package/Build/Workers/createFrustumGeometry.js +16 -16
  69. package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
  70. package/Build/Workers/createGeometry.js +22 -22
  71. package/Build/Workers/createGroundPolylineGeometry.js +20 -20
  72. package/Build/Workers/createPlaneGeometry.js +14 -14
  73. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  74. package/Build/Workers/createPolygonGeometry.js +30 -30
  75. package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
  76. package/Build/Workers/createPolylineGeometry.js +23 -23
  77. package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
  79. package/Build/Workers/createRectangleGeometry.js +25 -25
  80. package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
  81. package/Build/Workers/createSimplePolylineGeometry.js +21 -21
  82. package/Build/Workers/createSphereGeometry.js +17 -17
  83. package/Build/Workers/createSphereOutlineGeometry.js +16 -16
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
  86. package/Build/Workers/createVectorTileGeometries.js +22 -22
  87. package/Build/Workers/createVectorTilePoints.js +12 -12
  88. package/Build/Workers/createVectorTilePolygons.js +20 -20
  89. package/Build/Workers/createVectorTilePolylines.js +13 -13
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
  91. package/Build/Workers/createVerticesFromHeightmap.js +20 -20
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  93. package/Build/Workers/createWallGeometry.js +22 -22
  94. package/Build/Workers/createWallOutlineGeometry.js +21 -21
  95. package/Build/Workers/decodeDraco.js +15 -14
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +10 -10
  98. package/Build/Workers/transcodeKTX2.js +7 -7
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  101. package/Source/Core/Color.js +3 -3
  102. package/Source/Core/Credit.js +3 -3
  103. package/Source/Core/DistanceDisplayCondition.js +3 -3
  104. package/Source/Core/Ion.js +1 -1
  105. package/Source/Core/OrientedBoundingBox.js +2 -2
  106. package/Source/Core/Spherical.js +3 -3
  107. package/Source/Core/writeTextToCanvas.js +0 -1
  108. package/Source/DataSources/BoundingSphereState.js +3 -3
  109. package/Source/DataSources/DataSourceClock.js +1 -1
  110. package/Source/DataSources/DataSourceDisplay.js +5 -2
  111. package/Source/Renderer/AutomaticUniforms.js +2 -2
  112. package/Source/Scene/ArcGisMapService.js +1 -1
  113. package/Source/Scene/Billboard.js +1 -1
  114. package/Source/Scene/Cesium3DTile.js +56 -28
  115. package/Source/Scene/Cesium3DTilesVoxelProvider.js +17 -0
  116. package/Source/Scene/ClippingPolygon.js +2 -2
  117. package/Source/Scene/GltfDracoLoader.js +45 -0
  118. package/Source/Scene/GltfIndexBufferLoader.js +5 -0
  119. package/Source/Scene/GltfLoader.js +17 -2
  120. package/Source/Scene/GltfVertexBufferLoader.js +13 -0
  121. package/Source/Scene/ITwinData.js +47 -1
  122. package/Source/Scene/ImageryLayer.js +1 -1
  123. package/Source/Scene/Label.js +1 -1
  124. package/Source/Scene/LabelCollection.js +0 -11
  125. package/Source/Scene/Multiple3DTileContent.js +21 -8
  126. package/Source/Scene/PointPrimitive.js +1 -1
  127. package/Source/Scene/ResourceCache.js +17 -1
  128. package/Source/Scene/VoxelPrimitive.js +124 -0
  129. package/Source/Scene/VoxelProvider.js +10 -0
  130. package/Source/Scene/VoxelTraversal.js +88 -12
  131. package/Source/Scene/WebMapTileServiceImageryProvider.js +2 -2
  132. package/Source/Scene/createGooglePhotorealistic3DTileset.js +5 -8
  133. package/Source/Shaders/PolylineCommon.glsl +1 -1
  134. package/Source/Shaders/PolylineCommon.js +1 -1
  135. package/Source/Widget/CesiumWidget.js +16 -10
  136. package/Source/Workers/decodeDraco.js +4 -4
  137. package/index.d.ts +152 -38
  138. package/index.js +299 -299
  139. package/package.json +1 -1
@@ -1,9 +1,11 @@
1
1
  import Check from "../Core/Check.js";
2
+ import ComponentDatatype from "../Core/ComponentDatatype.js";
2
3
  import defaultValue from "../Core/defaultValue.js";
3
4
  import defined from "../Core/defined.js";
4
5
  import DracoLoader from "./DracoLoader.js";
5
6
  import ResourceLoader from "./ResourceLoader.js";
6
7
  import ResourceLoaderState from "./ResourceLoaderState.js";
8
+ import VertexAttributeSemantic from "./VertexAttributeSemantic.js";
7
9
 
8
10
  /**
9
11
  * Load a draco buffer from a glTF.
@@ -18,6 +20,7 @@ import ResourceLoaderState from "./ResourceLoaderState.js";
18
20
  * @param {object} options Object with the following properties:
19
21
  * @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
20
22
  * @param {object} options.gltf The glTF JSON.
23
+ * @param {object} options.primitive The primitive containing the Draco extension.
21
24
  * @param {object} options.draco The Draco extension object.
22
25
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
23
26
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
@@ -29,6 +32,7 @@ function GltfDracoLoader(options) {
29
32
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
30
33
  const resourceCache = options.resourceCache;
31
34
  const gltf = options.gltf;
35
+ const primitive = options.primitive;
32
36
  const draco = options.draco;
33
37
  const gltfResource = options.gltfResource;
34
38
  const baseResource = options.baseResource;
@@ -37,6 +41,7 @@ function GltfDracoLoader(options) {
37
41
  //>>includeStart('debug', pragmas.debug);
38
42
  Check.typeOf.func("options.resourceCache", resourceCache);
39
43
  Check.typeOf.object("options.gltf", gltf);
44
+ Check.typeOf.object("options.primitive", primitive);
40
45
  Check.typeOf.object("options.draco", draco);
41
46
  Check.typeOf.object("options.gltfResource", gltfResource);
42
47
  Check.typeOf.object("options.baseResource", baseResource);
@@ -46,6 +51,7 @@ function GltfDracoLoader(options) {
46
51
  this._gltfResource = gltfResource;
47
52
  this._baseResource = baseResource;
48
53
  this._gltf = gltf;
54
+ this._primitive = primitive;
49
55
  this._draco = draco;
50
56
  this._cacheKey = cacheKey;
51
57
  this._bufferViewLoader = undefined;
@@ -169,6 +175,24 @@ async function processDecode(loader, decodePromise) {
169
175
  }
170
176
  }
171
177
 
178
+ const SemanticToDracoAttributeType = {};
179
+ SemanticToDracoAttributeType[VertexAttributeSemantic.POSITION] = "POSITION";
180
+ SemanticToDracoAttributeType[VertexAttributeSemantic.NORMAL] = "NORMAL";
181
+ SemanticToDracoAttributeType[VertexAttributeSemantic.COLOR] = "COLOR";
182
+ SemanticToDracoAttributeType[VertexAttributeSemantic.TEXCOORD] = "TEX_COORD";
183
+
184
+ function getDracoAttributeType(attribute) {
185
+ for (const semantic in SemanticToDracoAttributeType) {
186
+ if (SemanticToDracoAttributeType.hasOwnProperty(semantic)) {
187
+ if (attribute.startsWith(semantic)) {
188
+ return SemanticToDracoAttributeType[semantic];
189
+ }
190
+ }
191
+ }
192
+
193
+ return undefined;
194
+ }
195
+
172
196
  /**
173
197
  * Processes the resource until it becomes ready.
174
198
  *
@@ -203,12 +227,31 @@ GltfDracoLoader.prototype.process = function (frameState) {
203
227
  }
204
228
 
205
229
  const draco = this._draco;
230
+ const primitive = this._primitive;
206
231
  const gltf = this._gltf;
207
232
  const bufferViews = gltf.bufferViews;
208
233
  const bufferViewId = draco.bufferView;
209
234
  const bufferView = bufferViews[bufferViewId];
210
235
  const compressedAttributes = draco.attributes;
211
236
 
237
+ // Skip de-quantization transform if present for floating point attributes.
238
+ // They will stay quantized in memory and be dequantized in the shader.
239
+ const attributesToSkipTransform = [];
240
+
241
+ for (const attribute in primitive.attributes) {
242
+ if (primitive.attributes.hasOwnProperty(attribute)) {
243
+ const dracoAttributeType = getDracoAttributeType(attribute);
244
+ if (defined(dracoAttributeType)) {
245
+ const accessor = gltf.accessors[primitive.attributes[attribute]];
246
+ if (accessor.componentType === ComponentDatatype.FLOAT) {
247
+ if (!attributesToSkipTransform.includes(dracoAttributeType)) {
248
+ attributesToSkipTransform.push(dracoAttributeType);
249
+ }
250
+ }
251
+ }
252
+ }
253
+ }
254
+
212
255
  const decodeOptions = {
213
256
  // Need to make a copy of the typed array otherwise the underlying
214
257
  // ArrayBuffer may be accessed on both the worker and the main thread. This
@@ -218,6 +261,7 @@ GltfDracoLoader.prototype.process = function (frameState) {
218
261
  bufferView: bufferView,
219
262
  compressedAttributes: compressedAttributes,
220
263
  dequantizeInShader: true,
264
+ attributesToSkipTransform: attributesToSkipTransform,
221
265
  };
222
266
 
223
267
  const decodePromise = DracoLoader.decodeBufferView(decodeOptions);
@@ -243,6 +287,7 @@ GltfDracoLoader.prototype.unload = function () {
243
287
  this._bufferViewTypedArray = undefined;
244
288
  this._decodedData = undefined;
245
289
  this._gltf = undefined;
290
+ this._primitive = undefined;
246
291
  };
247
292
 
248
293
  export default GltfDracoLoader;
@@ -27,6 +27,7 @@ import ResourceLoaderState from "./ResourceLoaderState.js";
27
27
  * @param {number} options.accessorId The accessor ID corresponding to the index buffer.
28
28
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
29
29
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
30
+ * @param {object} [options.primitive] The primitive containing the Draco extension.
30
31
  * @param {object} [options.draco] The Draco extension object.
31
32
  * @param {string} [options.cacheKey] The cache key of the resource.
32
33
  * @param {boolean} [options.asynchronous=true] Determines if WebGL resource creation will be spread out over several frames or block until all WebGL resources are created.
@@ -41,6 +42,7 @@ function GltfIndexBufferLoader(options) {
41
42
  const accessorId = options.accessorId;
42
43
  const gltfResource = options.gltfResource;
43
44
  const baseResource = options.baseResource;
45
+ const primitive = options.primitive;
44
46
  const draco = options.draco;
45
47
  const cacheKey = options.cacheKey;
46
48
  const asynchronous = defaultValue(options.asynchronous, true);
@@ -68,6 +70,7 @@ function GltfIndexBufferLoader(options) {
68
70
  this._gltf = gltf;
69
71
  this._accessorId = accessorId;
70
72
  this._indexDatatype = indexDatatype;
73
+ this._primitive = primitive;
71
74
  this._draco = draco;
72
75
  this._cacheKey = cacheKey;
73
76
  this._asynchronous = asynchronous;
@@ -174,6 +177,7 @@ async function loadFromDraco(indexBufferLoader) {
174
177
  try {
175
178
  const dracoLoader = resourceCache.getDracoLoader({
176
179
  gltf: indexBufferLoader._gltf,
180
+ primitive: indexBufferLoader._primitive,
177
181
  draco: indexBufferLoader._draco,
178
182
  gltfResource: indexBufferLoader._gltfResource,
179
183
  baseResource: indexBufferLoader._baseResource,
@@ -411,6 +415,7 @@ GltfIndexBufferLoader.prototype.unload = function () {
411
415
  this._typedArray = undefined;
412
416
  this._buffer = undefined;
413
417
  this._gltf = undefined;
418
+ this._primitive = undefined;
414
419
  };
415
420
 
416
421
  export default GltfIndexBufferLoader;
@@ -685,6 +685,7 @@ function getVertexBufferLoader(
685
685
  loader,
686
686
  accessorId,
687
687
  semantic,
688
+ primitive,
688
689
  draco,
689
690
  loadBuffer,
690
691
  loadTypedArray,
@@ -700,6 +701,7 @@ function getVertexBufferLoader(
700
701
  baseResource: loader._baseResource,
701
702
  frameState: frameState,
702
703
  bufferViewId: bufferViewId,
704
+ primitive: primitive,
703
705
  draco: draco,
704
706
  attributeSemantic: semantic,
705
707
  accessorId: accessorId,
@@ -714,6 +716,7 @@ function getVertexBufferLoader(
714
716
  function getIndexBufferLoader(
715
717
  loader,
716
718
  accessorId,
719
+ primitive,
717
720
  draco,
718
721
  loadBuffer,
719
722
  loadTypedArray,
@@ -725,6 +728,7 @@ function getIndexBufferLoader(
725
728
  gltfResource: loader._gltfResource,
726
729
  baseResource: loader._baseResource,
727
730
  frameState: frameState,
731
+ primitive: primitive,
728
732
  draco: draco,
729
733
  asynchronous: loader._asynchronous,
730
734
  loadBuffer: loadBuffer,
@@ -1154,6 +1158,7 @@ function loadAttribute(
1154
1158
  loader,
1155
1159
  accessorId,
1156
1160
  semanticInfo,
1161
+ primitive,
1157
1162
  draco,
1158
1163
  loadBuffer,
1159
1164
  loadTypedArray,
@@ -1188,6 +1193,7 @@ function loadAttribute(
1188
1193
  loader,
1189
1194
  accessorId,
1190
1195
  gltfSemantic,
1196
+ primitive,
1191
1197
  draco,
1192
1198
  loadBuffer,
1193
1199
  loadTypedArray,
@@ -1232,6 +1238,7 @@ function loadVertexAttribute(
1232
1238
  loader,
1233
1239
  accessorId,
1234
1240
  semanticInfo,
1241
+ primitive,
1235
1242
  draco,
1236
1243
  hasInstances,
1237
1244
  needsPostProcessing,
@@ -1278,6 +1285,7 @@ function loadVertexAttribute(
1278
1285
  loader,
1279
1286
  accessorId,
1280
1287
  semanticInfo,
1288
+ primitive,
1281
1289
  draco,
1282
1290
  loadBuffer,
1283
1291
  loadTypedArray,
@@ -1345,12 +1353,13 @@ function loadInstancedAttribute(
1345
1353
 
1346
1354
  const loadTypedArray = loadAsTypedArrayOnly || loadTranslationAsTypedArray;
1347
1355
 
1348
- // Don't pass in draco object since instanced attributes can't be draco compressed
1356
+ // Don't pass in primitive or draco object since instanced attributes can't be draco compressed
1349
1357
  return loadAttribute(
1350
1358
  loader,
1351
1359
  accessorId,
1352
1360
  semanticInfo,
1353
1361
  undefined,
1362
+ undefined,
1354
1363
  loadBuffer,
1355
1364
  loadTypedArray,
1356
1365
  frameState,
@@ -1360,6 +1369,7 @@ function loadInstancedAttribute(
1360
1369
  function loadIndices(
1361
1370
  loader,
1362
1371
  accessorId,
1372
+ primitive,
1363
1373
  draco,
1364
1374
  hasFeatureIds,
1365
1375
  needsPostProcessing,
@@ -1403,6 +1413,7 @@ function loadIndices(
1403
1413
  const indexBufferLoader = getIndexBufferLoader(
1404
1414
  loader,
1405
1415
  accessorId,
1416
+ primitive,
1406
1417
  draco,
1407
1418
  loadBuffer,
1408
1419
  loadTypedArray,
@@ -1865,7 +1876,8 @@ function loadMorphTarget(
1865
1876
  ) {
1866
1877
  const morphTarget = new MorphTarget();
1867
1878
 
1868
- // Don't pass in draco object since morph targets can't be draco compressed
1879
+ // Don't pass in primitive or draco object since morph targets can't be draco compressed
1880
+ const primitive = undefined;
1869
1881
  const draco = undefined;
1870
1882
  const hasInstances = false;
1871
1883
 
@@ -1885,6 +1897,7 @@ function loadMorphTarget(
1885
1897
  loader,
1886
1898
  accessorId,
1887
1899
  semanticInfo,
1900
+ primitive,
1888
1901
  draco,
1889
1902
  hasInstances,
1890
1903
  needsPostProcessing,
@@ -1970,6 +1983,7 @@ function loadPrimitive(loader, gltfPrimitive, hasInstances, frameState) {
1970
1983
  loader,
1971
1984
  accessorId,
1972
1985
  semanticInfo,
1986
+ gltfPrimitive,
1973
1987
  draco,
1974
1988
  hasInstances,
1975
1989
  needsPostProcessing,
@@ -2002,6 +2016,7 @@ function loadPrimitive(loader, gltfPrimitive, hasInstances, frameState) {
2002
2016
  const indicesPlan = loadIndices(
2003
2017
  loader,
2004
2018
  indices,
2019
+ gltfPrimitive,
2005
2020
  draco,
2006
2021
  hasFeatureIds,
2007
2022
  needsPostProcessing,
@@ -26,6 +26,7 @@ import ResourceLoaderState from "./ResourceLoaderState.js";
26
26
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
27
27
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
28
28
  * @param {number} [options.bufferViewId] The bufferView ID corresponding to the vertex buffer.
29
+ * @param {object} [options.primitive] The primitive containing the Draco extension.
29
30
  * @param {object} [options.draco] The Draco extension object.
30
31
  * @param {string} [options.attributeSemantic] The attribute semantic, e.g. POSITION or NORMAL.
31
32
  * @param {number} [options.accessorId] The accessor id.
@@ -47,6 +48,7 @@ function GltfVertexBufferLoader(options) {
47
48
  const gltfResource = options.gltfResource;
48
49
  const baseResource = options.baseResource;
49
50
  const bufferViewId = options.bufferViewId;
51
+ const primitive = options.primitive;
50
52
  const draco = options.draco;
51
53
  const attributeSemantic = options.attributeSemantic;
52
54
  const accessorId = options.accessorId;
@@ -67,6 +69,7 @@ function GltfVertexBufferLoader(options) {
67
69
  }
68
70
 
69
71
  const hasBufferViewId = defined(bufferViewId);
72
+ const hasPrimitive = defined(primitive);
70
73
  const hasDraco = hasDracoCompression(draco, attributeSemantic);
71
74
  const hasAttributeSemantic = defined(attributeSemantic);
72
75
  const hasAccessorId = defined(accessorId);
@@ -89,7 +92,14 @@ function GltfVertexBufferLoader(options) {
89
92
  );
90
93
  }
91
94
 
95
+ if (hasDraco && !hasPrimitive) {
96
+ throw new DeveloperError(
97
+ "When options.draco is defined options.primitive must also be defined.",
98
+ );
99
+ }
100
+
92
101
  if (hasDraco) {
102
+ Check.typeOf.object("options.primitive", primitive);
93
103
  Check.typeOf.object("options.draco", draco);
94
104
  Check.typeOf.string("options.attributeSemantic", attributeSemantic);
95
105
  Check.typeOf.number("options.accessorId", accessorId);
@@ -101,6 +111,7 @@ function GltfVertexBufferLoader(options) {
101
111
  this._baseResource = baseResource;
102
112
  this._gltf = gltf;
103
113
  this._bufferViewId = bufferViewId;
114
+ this._primitive = primitive;
104
115
  this._draco = draco;
105
116
  this._attributeSemantic = attributeSemantic;
106
117
  this._accessorId = accessorId;
@@ -265,6 +276,7 @@ async function loadFromDraco(vertexBufferLoader) {
265
276
  try {
266
277
  const dracoLoader = resourceCache.getDracoLoader({
267
278
  gltf: vertexBufferLoader._gltf,
279
+ primitive: vertexBufferLoader._primitive,
268
280
  draco: vertexBufferLoader._draco,
269
281
  gltfResource: vertexBufferLoader._gltfResource,
270
282
  baseResource: vertexBufferLoader._baseResource,
@@ -467,6 +479,7 @@ GltfVertexBufferLoader.prototype.unload = function () {
467
479
  this._typedArray = undefined;
468
480
  this._buffer = undefined;
469
481
  this._gltf = undefined;
482
+ this._primitive = undefined;
470
483
  };
471
484
 
472
485
  export default GltfVertexBufferLoader;
@@ -6,6 +6,7 @@ import RuntimeError from "../Core/RuntimeError.js";
6
6
  import Check from "../Core/Check.js";
7
7
  import KmlDataSource from "../DataSources/KmlDataSource.js";
8
8
  import GeoJsonDataSource from "../DataSources/GeoJsonDataSource.js";
9
+ import DeveloperError from "../Core/DeveloperError.js";
9
10
 
10
11
  /**
11
12
  * Methods for loading iTwin platform data into CesiumJS
@@ -154,7 +155,7 @@ ITwinData.createTilesetForRealityDataId = async function (
154
155
  *
155
156
  * @throws {RuntimeError} if the type of reality data is not supported by this function
156
157
  */
157
- ITwinData.createDataSourceForRealityDataId = async function loadRealityData(
158
+ ITwinData.createDataSourceForRealityDataId = async function (
158
159
  iTwinId,
159
160
  realityDataId,
160
161
  type,
@@ -205,4 +206,49 @@ ITwinData.createDataSourceForRealityDataId = async function loadRealityData(
205
206
  return KmlDataSource.load(tilesetAccessUrl);
206
207
  };
207
208
 
209
+ /**
210
+ * Load data from the Geospatial Features API as GeoJSON.
211
+ *
212
+ * @param {string} iTwinId The id of the iTwin to load data from
213
+ * @param {string} collectionId The id of the data collection to load
214
+ * @param {number} [limit=10000] number of items per page, must be between 1 and 10,000 inclusive
215
+ * @returns {Promise<GeoJsonDataSource>}
216
+ */
217
+ ITwinData.loadGeospatialFeatures = async function (
218
+ iTwinId,
219
+ collectionId,
220
+ limit,
221
+ ) {
222
+ //>>includeStart('debug', pragmas.debug);
223
+ Check.typeOf.string("iTwinId", iTwinId);
224
+ Check.typeOf.string("collectionId", collectionId);
225
+ if (defined(limit)) {
226
+ Check.typeOf.number("limit", limit);
227
+ Check.typeOf.number.lessThanOrEquals("limit", limit, 10000);
228
+ Check.typeOf.number.greaterThanOrEquals("limit", limit, 1);
229
+ }
230
+ if (!defined(ITwinPlatform.defaultAccessToken)) {
231
+ throw new DeveloperError("Must set ITwinPlatform.defaultAccessToken first");
232
+ }
233
+ //>>includeEnd('debug')
234
+
235
+ const pageLimit = limit ?? 10000;
236
+
237
+ const tilesetUrl = `${ITwinPlatform.apiEndpoint}geospatial-features/itwins/${iTwinId}/ogc/collections/${collectionId}/items`;
238
+
239
+ const resource = new Resource({
240
+ url: tilesetUrl,
241
+ headers: {
242
+ Authorization: `Bearer ${ITwinPlatform.defaultAccessToken}`,
243
+ Accept: "application/vnd.bentley.itwin-platform.v1+json",
244
+ },
245
+ queryParameters: {
246
+ limit: pageLimit,
247
+ client: "CesiumJS",
248
+ },
249
+ });
250
+
251
+ return GeoJsonDataSource.load(resource);
252
+ };
253
+
208
254
  export default ITwinData;
@@ -511,7 +511,7 @@ ImageryLayer.DEFAULT_APPLY_COLOR_TO_ALPHA_THRESHOLD = 0.004;
511
511
  * Create a new imagery layer from an asynchronous imagery provider. The layer will handle any asynchronous loads or errors, and begin rendering the imagery layer once ready.
512
512
  *
513
513
  * @param {Promise<ImageryProvider>} imageryProviderPromise A promise which resolves to a imagery provider
514
- * @param {ImageryLayer.ConstructorOptions} options An object describing initialization options
514
+ * @param {ImageryLayer.ConstructorOptions} [options] An object describing initialization options
515
515
  * @returns {ImageryLayer} The created imagery layer.
516
516
  *
517
517
  * @example
@@ -1364,7 +1364,7 @@ Label.filterUnsupportedCharacters = function (text) {
1364
1364
  * Determines if this label equals another label. Labels are equal if all their properties
1365
1365
  * are equal. Labels in different collections can be equal.
1366
1366
  *
1367
- * @param {Label} other The label to compare for equality.
1367
+ * @param {Label} [other] The label to compare for equality.
1368
1368
  * @returns {boolean} <code>true</code> if the labels are equal; otherwise, <code>false</code>.
1369
1369
  */
1370
1370
  Label.prototype.equals = function (other) {
@@ -68,7 +68,6 @@ function createGlyphCanvas(
68
68
  outlineColor,
69
69
  outlineWidth,
70
70
  style,
71
- verticalOrigin,
72
71
  ) {
73
72
  writeTextToCanvasParameters.font = font;
74
73
  writeTextToCanvasParameters.fillColor = fillColor;
@@ -77,15 +76,6 @@ function createGlyphCanvas(
77
76
  // Setting the padding to something bigger is necessary to get enough space for the outlining.
78
77
  writeTextToCanvasParameters.padding = SDFSettings.PADDING;
79
78
 
80
- if (verticalOrigin === VerticalOrigin.CENTER) {
81
- writeTextToCanvasParameters.textBaseline = "middle";
82
- } else if (verticalOrigin === VerticalOrigin.TOP) {
83
- writeTextToCanvasParameters.textBaseline = "top";
84
- } else {
85
- // VerticalOrigin.BOTTOM and VerticalOrigin.BASELINE
86
- writeTextToCanvasParameters.textBaseline = "bottom";
87
- }
88
-
89
79
  writeTextToCanvasParameters.fill =
90
80
  style === LabelStyle.FILL || style === LabelStyle.FILL_AND_OUTLINE;
91
81
  writeTextToCanvasParameters.stroke =
@@ -211,7 +201,6 @@ function rebindAllGlyphs(labelCollection, label) {
211
201
  Color.WHITE,
212
202
  0.0,
213
203
  LabelStyle.FILL,
214
- verticalOrigin,
215
204
  );
216
205
 
217
206
  glyphTextureInfo = new GlyphTextureInfo(
@@ -6,7 +6,6 @@ import Request from "../Core/Request.js";
6
6
  import RequestScheduler from "../Core/RequestScheduler.js";
7
7
  import RequestState from "../Core/RequestState.js";
8
8
  import RequestType from "../Core/RequestType.js";
9
- import RuntimeError from "../Core/RuntimeError.js";
10
9
  import Cesium3DContentGroup from "./Cesium3DContentGroup.js";
11
10
  import Cesium3DTileContentType from "./Cesium3DTileContentType.js";
12
11
  import Cesium3DTileContentFactory from "./Cesium3DTileContentFactory.js";
@@ -52,6 +51,11 @@ function Multiple3DTileContent(tileset, tile, tilesetResource, contentsJson) {
52
51
  // used to help short-circuit computations after a tile was canceled.
53
52
  this._cancelCount = 0;
54
53
 
54
+ // The number of contents that turned out to be external tilesets
55
+ // in createInnerContent. When all contents are external tilesets,
56
+ // then tile.hasRenderableContent will become `false`
57
+ this._externalTilesetCount = 0;
58
+
55
59
  const contentCount = this._innerContentHeaders.length;
56
60
  this._arrayFetchPromises = new Array(contentCount);
57
61
  this._requests = new Array(contentCount);
@@ -505,6 +509,16 @@ async function createInnerContents(multipleContents) {
505
509
  const contents = await Promise.all(promises);
506
510
  multipleContents._contentsCreated = true;
507
511
  multipleContents._contents = contents.filter(defined);
512
+
513
+ // If each content is an external tileset, then the tile
514
+ // itself does not have any renderable content
515
+ if (
516
+ multipleContents._externalTilesetCount === multipleContents._contents.length
517
+ ) {
518
+ const tile = multipleContents._tile;
519
+ tile.hasRenderableContent = false;
520
+ }
521
+
508
522
  return contents;
509
523
  }
510
524
 
@@ -518,10 +532,13 @@ async function createInnerContent(multipleContents, arrayBuffer, index) {
518
532
  try {
519
533
  const preprocessed = preprocess3DTileContent(arrayBuffer);
520
534
 
535
+ const tileset = multipleContents._tileset;
536
+ const resource = multipleContents._innerContentResources[index];
537
+ const tile = multipleContents._tile;
538
+
521
539
  if (preprocessed.contentType === Cesium3DTileContentType.EXTERNAL_TILESET) {
522
- throw new RuntimeError(
523
- "External tilesets are disallowed inside multiple contents",
524
- );
540
+ multipleContents._externalTilesetCount++;
541
+ tile.hasTilesetContent = true;
525
542
  }
526
543
 
527
544
  multipleContents._disableSkipLevelOfDetail =
@@ -529,10 +546,6 @@ async function createInnerContent(multipleContents, arrayBuffer, index) {
529
546
  preprocessed.contentType === Cesium3DTileContentType.GEOMETRY ||
530
547
  preprocessed.contentType === Cesium3DTileContentType.VECTOR;
531
548
 
532
- const tileset = multipleContents._tileset;
533
- const resource = multipleContents._innerContentResources[index];
534
- const tile = multipleContents._tile;
535
-
536
549
  let content;
537
550
  const contentFactory = Cesium3DTileContentFactory[preprocessed.contentType];
538
551
  if (defined(preprocessed.binaryPayload)) {
@@ -665,7 +665,7 @@ PointPrimitive.getScreenSpaceBoundingBox = function (
665
665
  * Determines if this point equals another point. Points are equal if all their properties
666
666
  * are equal. Points in different collections can be equal.
667
667
  *
668
- * @param {PointPrimitive} other The point to compare for equality.
668
+ * @param {PointPrimitive} [other] The point to compare for equality.
669
669
  * @returns {boolean} <code>true</code> if the points are equal; otherwise, <code>false</code>.
670
670
  */
671
671
  PointPrimitive.prototype.equals = function (other) {
@@ -345,6 +345,7 @@ ResourceCache.getBufferViewLoader = function (options) {
345
345
  *
346
346
  * @param {object} options Object with the following properties:
347
347
  * @param {object} options.gltf The glTF JSON.
348
+ * @param {object} options.primitive The primitive containing the Draco extension.
348
349
  * @param {object} options.draco The Draco extension object.
349
350
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
350
351
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
@@ -354,10 +355,11 @@ ResourceCache.getBufferViewLoader = function (options) {
354
355
  */
355
356
  ResourceCache.getDracoLoader = function (options) {
356
357
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
357
- const { gltf, draco, gltfResource, baseResource } = options;
358
+ const { gltf, primitive, draco, gltfResource, baseResource } = options;
358
359
 
359
360
  //>>includeStart('debug', pragmas.debug);
360
361
  Check.typeOf.object("options.gltf", gltf);
362
+ Check.typeOf.object("options.primitive", primitive);
361
363
  Check.typeOf.object("options.draco", draco);
362
364
  Check.typeOf.object("options.gltfResource", gltfResource);
363
365
  Check.typeOf.object("options.baseResource", baseResource);
@@ -378,6 +380,7 @@ ResourceCache.getDracoLoader = function (options) {
378
380
  dracoLoader = new GltfDracoLoader({
379
381
  resourceCache: ResourceCache,
380
382
  gltf: gltf,
383
+ primitive: primitive,
381
384
  draco: draco,
382
385
  gltfResource: gltfResource,
383
386
  baseResource: baseResource,
@@ -396,6 +399,7 @@ ResourceCache.getDracoLoader = function (options) {
396
399
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
397
400
  * @param {FrameState} options.frameState The frame state.
398
401
  * @param {number} [options.bufferViewId] The bufferView ID corresponding to the vertex buffer.
402
+ * @param {object} [options.primitive] The primitive containing the Draco extension.
399
403
  * @param {object} [options.draco] The Draco extension object.
400
404
  * @param {string} [options.attributeSemantic] The attribute semantic, e.g. POSITION or NORMAL.
401
405
  * @param {number} [options.accessorId] The accessor ID.
@@ -418,6 +422,7 @@ ResourceCache.getVertexBufferLoader = function (options) {
418
422
  baseResource,
419
423
  frameState,
420
424
  bufferViewId,
425
+ primitive,
421
426
  draco,
422
427
  attributeSemantic,
423
428
  accessorId,
@@ -439,6 +444,7 @@ ResourceCache.getVertexBufferLoader = function (options) {
439
444
  }
440
445
 
441
446
  const hasBufferViewId = defined(bufferViewId);
447
+ const hasPrimitive = defined(primitive);
442
448
  const hasDraco = hasDracoCompression(draco, attributeSemantic);
443
449
  const hasAttributeSemantic = defined(attributeSemantic);
444
450
  const hasAccessorId = defined(accessorId);
@@ -461,6 +467,12 @@ ResourceCache.getVertexBufferLoader = function (options) {
461
467
  );
462
468
  }
463
469
 
470
+ if (hasDraco && !hasPrimitive) {
471
+ throw new DeveloperError(
472
+ "When options.draco is defined options.primitive must also be defined.",
473
+ );
474
+ }
475
+
464
476
  if (hasDraco) {
465
477
  Check.typeOf.object("options.draco", draco);
466
478
  Check.typeOf.string("options.attributeSemantic", attributeSemantic);
@@ -492,6 +504,7 @@ ResourceCache.getVertexBufferLoader = function (options) {
492
504
  gltfResource: gltfResource,
493
505
  baseResource: baseResource,
494
506
  bufferViewId: bufferViewId,
507
+ primitive: primitive,
495
508
  draco: draco,
496
509
  attributeSemantic: attributeSemantic,
497
510
  accessorId: accessorId,
@@ -522,6 +535,7 @@ function hasDracoCompression(draco, semantic) {
522
535
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
523
536
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
524
537
  * @param {FrameState} options.frameState The frame state.
538
+ * @param {object} [options.primitive] The primitive containing the Draco extension.
525
539
  * @param {object} [options.draco] The Draco extension object.
526
540
  * @param {boolean} [options.asynchronous=true] Determines if WebGL resource creation will be spread out over several frames or block until all WebGL resources are created.
527
541
  * @param {boolean} [options.loadBuffer=false] Load index buffer as a GPU index buffer.
@@ -537,6 +551,7 @@ ResourceCache.getIndexBufferLoader = function (options) {
537
551
  gltfResource,
538
552
  baseResource,
539
553
  frameState,
554
+ primitive,
540
555
  draco,
541
556
  asynchronous = true,
542
557
  loadBuffer = false,
@@ -578,6 +593,7 @@ ResourceCache.getIndexBufferLoader = function (options) {
578
593
  accessorId: accessorId,
579
594
  gltfResource: gltfResource,
580
595
  baseResource: baseResource,
596
+ primitive: primitive,
581
597
  draco: draco,
582
598
  cacheKey: cacheKey,
583
599
  asynchronous: asynchronous,