@cesium/engine 13.1.0 → 15.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 (183) hide show
  1. package/Build/Workers/{chunk-APCS5YJI.js → chunk-25TOENEE.js} +7 -7
  2. package/Build/Workers/{chunk-FNCXBBCF.js → chunk-2AVIUB5H.js} +2 -2
  3. package/Build/Workers/{chunk-OZTFRHA2.js → chunk-3JZGPJMZ.js} +6 -6
  4. package/Build/Workers/{chunk-5JY4LYO3.js → chunk-3LHBH4TC.js} +7 -7
  5. package/Build/Workers/{chunk-MGABCOOH.js → chunk-3LZF23RY.js} +6 -6
  6. package/Build/Workers/{chunk-AXYZUG4N.js → chunk-5S2B46UQ.js} +1 -1
  7. package/Build/Workers/{chunk-2SRHVCFD.js → chunk-67ONR44K.js} +6 -6
  8. package/Build/Workers/{chunk-PBJQFLKS.js → chunk-6EDBC234.js} +11 -11
  9. package/Build/Workers/{chunk-GSLKQJM2.js → chunk-6EV4VOET.js} +10 -10
  10. package/Build/Workers/{chunk-OGRXNUR2.js → chunk-7ITUZTFH.js} +1 -1
  11. package/Build/Workers/{chunk-IP7F2MVW.js → chunk-ARVZCY6X.js} +7 -7
  12. package/Build/Workers/{chunk-EYZFEJX3.js → chunk-B2UQN3DH.js} +6 -6
  13. package/Build/Workers/{chunk-WE4KF4AM.js → chunk-B2Y4ZS6X.js} +9 -9
  14. package/Build/Workers/{chunk-DWIKWWEE.js → chunk-BD2TPFGC.js} +5 -5
  15. package/Build/Workers/{chunk-5ICYLS6B.js → chunk-CHX2K5AC.js} +10 -10
  16. package/Build/Workers/{chunk-NQDKNE7V.js → chunk-CJGVEABL.js} +13 -13
  17. package/Build/Workers/{chunk-B34JXFHF.js → chunk-DYJHEP3B.js} +5 -5
  18. package/Build/Workers/{chunk-J7BMSSY7.js → chunk-E3H7AVMK.js} +13 -13
  19. package/Build/Workers/{chunk-TOHDFUJM.js → chunk-EZNAJPP5.js} +4 -4
  20. package/Build/Workers/{chunk-K62EHZFT.js → chunk-F7ZI463G.js} +15 -15
  21. package/Build/Workers/{chunk-EJ5DT5BP.js → chunk-FMZ5CX6V.js} +1 -1
  22. package/Build/Workers/{chunk-OARMSJUU.js → chunk-FRAWHNSR.js} +2 -2
  23. package/Build/Workers/{chunk-S3UM4OKP.js → chunk-GGV2XJHE.js} +7 -7
  24. package/Build/Workers/{chunk-SAKQO5NX.js → chunk-GK4QU6QI.js} +2 -2
  25. package/Build/Workers/{chunk-LFUFGHL3.js → chunk-HYPB7FAV.js} +10 -10
  26. package/Build/Workers/{chunk-3SCCWLZS.js → chunk-I4HO2ED2.js} +9 -9
  27. package/Build/Workers/{chunk-K6SQV4IS.js → chunk-IGINOLDX.js} +6 -6
  28. package/Build/Workers/{chunk-IXNXKVOB.js → chunk-ISQSYLZY.js} +4 -4
  29. package/Build/Workers/{chunk-PM76TX2X.js → chunk-JZAMRL5I.js} +6 -6
  30. package/Build/Workers/{chunk-CBE4HRBH.js → chunk-K5G2WELR.js} +7 -7
  31. package/Build/Workers/{chunk-EHGQQA7C.js → chunk-L5SO4Y5V.js} +1 -1
  32. package/Build/Workers/{chunk-M2AA2ARJ.js → chunk-LCMJQVIF.js} +11 -11
  33. package/Build/Workers/{chunk-HI73PIPQ.js → chunk-MWJW37I7.js} +2 -2
  34. package/Build/Workers/{chunk-WAJNX74N.js → chunk-NAGMYRDW.js} +27 -20
  35. package/Build/Workers/{chunk-WUIDEXAN.js → chunk-OYO6TKMU.js} +7 -7
  36. package/Build/Workers/{chunk-YVGU235V.js → chunk-PUTA3AE2.js} +4 -4
  37. package/Build/Workers/{chunk-ZWSWJYJP.js → chunk-Q5BHMNKU.js} +13 -13
  38. package/Build/Workers/{chunk-LQT2ZK7D.js → chunk-QTEX3Y4V.js} +17 -17
  39. package/Build/Workers/{chunk-UBAHTE4Q.js → chunk-QZKN2RXM.js} +1 -1
  40. package/Build/Workers/{chunk-T34EOLFR.js → chunk-RO2Z3LCR.js} +14 -14
  41. package/Build/Workers/{chunk-PTFIVVLX.js → chunk-RRN6LRDX.js} +12 -12
  42. package/Build/Workers/{chunk-B6IJY6AN.js → chunk-SLIA3GQP.js} +7 -7
  43. package/Build/Workers/{chunk-GIOZHX7U.js → chunk-TFCOEX3W.js} +2 -2
  44. package/Build/Workers/{chunk-KRVALCCI.js → chunk-TU6ZXHVU.js} +5 -5
  45. package/Build/Workers/{chunk-54I6VSRP.js → chunk-VJ2PDF64.js} +6 -6
  46. package/Build/Workers/{chunk-BMFWWTD7.js → chunk-VMVPONIV.js} +5 -5
  47. package/Build/Workers/{chunk-CNPP6TQ2.js → chunk-WPXU45PH.js} +4 -4
  48. package/Build/Workers/{chunk-2ONAV62A.js → chunk-XDHM4G3P.js} +7 -7
  49. package/Build/Workers/{chunk-KO232FLP.js → chunk-XED3RXKO.js} +2 -2
  50. package/Build/Workers/{chunk-5I3LPAS7.js → chunk-YNYCGTQH.js} +5 -5
  51. package/Build/Workers/{chunk-THDHWSEJ.js → chunk-Z4SI54EB.js} +4 -4
  52. package/Build/Workers/{chunk-R2KGFZBA.js → chunk-ZVDLC3T4.js} +13 -13
  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 +50 -43
  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/EllipsoidRhumbLine.js +1 -1
  105. package/Source/Core/Ion.js +1 -1
  106. package/Source/Core/OrientedBoundingBox.js +2 -2
  107. package/Source/Core/PolygonGeometryLibrary.js +26 -4
  108. package/Source/Core/Spherical.js +3 -3
  109. package/Source/Core/TexturePacker.js +166 -0
  110. package/Source/Core/writeTextToCanvas.js +0 -1
  111. package/Source/DataSources/BillboardVisualizer.js +3 -3
  112. package/Source/DataSources/BoundingSphereState.js +3 -3
  113. package/Source/DataSources/DataSourceClock.js +1 -1
  114. package/Source/DataSources/DataSourceDisplay.js +5 -2
  115. package/Source/DataSources/EntityCluster.js +44 -19
  116. package/Source/Renderer/AutomaticUniforms.js +2 -2
  117. package/Source/Renderer/Context.js +0 -4
  118. package/Source/Renderer/Texture.js +6 -5
  119. package/Source/Renderer/TextureAtlas.js +802 -0
  120. package/Source/Scene/ArcGisMapService.js +1 -1
  121. package/Source/Scene/Billboard.js +87 -142
  122. package/Source/Scene/BillboardCollection.js +132 -202
  123. package/Source/Scene/BillboardLoadState.js +44 -0
  124. package/Source/Scene/BillboardTexture.js +348 -0
  125. package/Source/Scene/Camera.js +2 -2
  126. package/Source/Scene/Cesium3DTile.js +56 -28
  127. package/Source/Scene/Cesium3DTilesVoxelProvider.js +403 -132
  128. package/Source/Scene/Cesium3DTilesetStatistics.js +0 -1
  129. package/Source/Scene/ClippingPolygon.js +2 -2
  130. package/Source/Scene/Expression.js +1 -0
  131. package/Source/Scene/GltfDracoLoader.js +45 -0
  132. package/Source/Scene/GltfIndexBufferLoader.js +5 -0
  133. package/Source/Scene/GltfLoader.js +22 -9
  134. package/Source/Scene/GltfVertexBufferLoader.js +13 -0
  135. package/Source/Scene/ITwinData.js +47 -1
  136. package/Source/Scene/ImageryLayer.js +1 -1
  137. package/Source/Scene/ImplicitSubtree.js +2 -0
  138. package/Source/Scene/KeyframeNode.js +16 -2
  139. package/Source/Scene/Label.js +1 -1
  140. package/Source/Scene/LabelCollection.js +212 -193
  141. package/Source/Scene/Megatexture.js +145 -81
  142. package/Source/Scene/Model/CustomShader.js +0 -2
  143. package/Source/Scene/Model/Model.js +1 -1
  144. package/Source/Scene/Model/ModelUtility.js +5 -1
  145. package/Source/Scene/Multiple3DTileContent.js +21 -8
  146. package/Source/Scene/PointPrimitive.js +1 -1
  147. package/Source/Scene/ResourceCache.js +17 -1
  148. package/Source/Scene/Scene.js +39 -15
  149. package/Source/Scene/ScreenSpaceCameraController.js +0 -8
  150. package/Source/Scene/SpatialNode.js +4 -11
  151. package/Source/Scene/Vector3DTilePoints.js +2 -5
  152. package/Source/Scene/VoxelBoxShape.js +12 -5
  153. package/Source/Scene/VoxelCell.js +6 -5
  154. package/Source/Scene/VoxelContent.js +171 -107
  155. package/Source/Scene/VoxelCylinderShape.js +65 -58
  156. package/Source/Scene/VoxelEllipsoidShape.js +15 -5
  157. package/Source/Scene/VoxelMetadataOrder.js +12 -0
  158. package/Source/Scene/VoxelPrimitive.js +245 -53
  159. package/Source/Scene/VoxelProvider.js +44 -29
  160. package/Source/Scene/VoxelRenderResources.js +30 -7
  161. package/Source/Scene/VoxelShape.js +10 -3
  162. package/Source/Scene/VoxelTraversal.js +326 -166
  163. package/Source/Scene/WebMapTileServiceImageryProvider.js +2 -2
  164. package/Source/Scene/createGooglePhotorealistic3DTileset.js +5 -8
  165. package/Source/Scene/processVoxelProperties.js +3 -0
  166. package/Source/Shaders/GlobeFS.glsl +10 -1
  167. package/Source/Shaders/GlobeFS.js +10 -1
  168. package/Source/Shaders/PolylineCommon.glsl +1 -1
  169. package/Source/Shaders/PolylineCommon.js +1 -1
  170. package/Source/Shaders/Voxels/Megatexture.glsl +4 -16
  171. package/Source/Shaders/Voxels/Megatexture.js +4 -16
  172. package/Source/Shaders/Voxels/Octree.glsl +44 -7
  173. package/Source/Shaders/Voxels/Octree.js +44 -7
  174. package/Source/Shaders/Voxels/VoxelFS.glsl +9 -15
  175. package/Source/Shaders/Voxels/VoxelFS.js +9 -15
  176. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +15 -15
  177. package/Source/Shaders/Voxels/convertUvToCylinder.js +15 -15
  178. package/Source/Widget/CesiumWidget.js +16 -10
  179. package/Source/Workers/decodeDraco.js +4 -4
  180. package/index.d.ts +321 -110
  181. package/index.js +209 -205
  182. package/package.json +2 -2
  183. package/Source/Scene/TextureAtlas.js +0 -558
@@ -1,27 +1,50 @@
1
1
  import Cartesian3 from "../Core/Cartesian3.js";
2
+ import Cesium3DTilesetMetadata from "./Cesium3DTilesetMetadata.js";
2
3
  import Check from "../Core/Check.js";
3
4
  import defaultValue from "../Core/defaultValue.js";
4
5
  import defined from "../Core/defined.js";
5
6
  import Ellipsoid from "../Core/Ellipsoid.js";
6
- import Matrix4 from "../Core/Matrix4.js";
7
- import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
8
- import Resource from "../Core/Resource.js";
9
- import RuntimeError from "../Core/RuntimeError.js";
10
- import Cesium3DTilesetMetadata from "./Cesium3DTilesetMetadata.js";
11
7
  import hasExtension from "./hasExtension.js";
12
8
  import ImplicitSubtree from "./ImplicitSubtree.js";
13
9
  import ImplicitSubtreeCache from "./ImplicitSubtreeCache.js";
14
10
  import ImplicitTileCoordinates from "./ImplicitTileCoordinates.js";
15
11
  import ImplicitTileset from "./ImplicitTileset.js";
12
+ import Matrix4 from "../Core/Matrix4.js";
16
13
  import MetadataSemantic from "./MetadataSemantic.js";
17
14
  import MetadataType from "./MetadataType.js";
15
+ import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
18
16
  import preprocess3DTileContent from "./preprocess3DTileContent.js";
17
+ import Resource from "../Core/Resource.js";
19
18
  import ResourceCache from "./ResourceCache.js";
19
+ import RuntimeError from "../Core/RuntimeError.js";
20
20
  import VoxelBoxShape from "./VoxelBoxShape.js";
21
21
  import VoxelContent from "./VoxelContent.js";
22
22
  import VoxelCylinderShape from "./VoxelCylinderShape.js";
23
+ import VoxelMetadataOrder from "./VoxelMetadataOrder.js";
23
24
  import VoxelShapeType from "./VoxelShapeType.js";
24
25
 
26
+ /**
27
+ * @typedef {Object} Cesium3DTilesVoxelProvider.ConstructorOptions
28
+ *
29
+ * Initialization options for the Cesium3DTilesVoxelProvider constructor
30
+ *
31
+ * @property {string} className The class in the tileset schema describing voxel metadata.
32
+ * @property {string[]} names The metadata names.
33
+ * @property {MetadataType[]} types The metadata types.
34
+ * @property {MetadataComponentType[]} componentTypes The metadata component types.
35
+ * @property {VoxelShapeType} shape The {@link VoxelShapeType}.
36
+ * @property {Cartesian3} dimensions The number of voxels per dimension of a tile. This is the same for all tiles in the dataset.
37
+ * @property {Cartesian3} [paddingBefore=Cartesian3.ZERO] The number of padding voxels before the tile. This improves rendering quality when sampling the edge of a tile, but it increases memory usage.
38
+ * @property {Cartesian3} [paddingAfter=Cartesian3.ZERO] The number of padding voxels after the tile. This improves rendering quality when sampling the edge of a tile, but it increases memory usage.
39
+ * @property {Matrix4} [globalTransform=Matrix4.IDENTITY] A transform from local space to global space.
40
+ * @property {Matrix4} [shapeTransform=Matrix4.IDENTITY] A transform from shape space to local space.
41
+ * @property {Cartesian3} [minBounds] The minimum bounds.
42
+ * @property {Cartesian3} [maxBounds] The maximum bounds.
43
+ * @property {number[][]} [minimumValues] The metadata minimum values.
44
+ * @property {number[][]} [maximumValues] The metadata maximum values.
45
+ * @property {number} [maximumTileCount] The maximum number of tiles that exist for this provider. This value is used as a hint to the voxel renderer to allocate an appropriate amount of GPU memory. If this value is not known it can be undefined.
46
+ */
47
+
25
48
  /**
26
49
  * A {@link VoxelProvider} that fetches voxel data from a 3D Tiles tileset.
27
50
  * <p>
@@ -35,7 +58,7 @@ import VoxelShapeType from "./VoxelShapeType.js";
35
58
  * @constructor
36
59
  * @augments VoxelProvider
37
60
  *
38
- * @param {object} options Object with the following properties:
61
+ * @param {Cesium3DTilesVoxelProvider.ConstructorOptions} options An object describing initialization options
39
62
  *
40
63
  * @see Cesium3DTilesVoxelProvider.fromUrl
41
64
  * @see VoxelProvider
@@ -47,54 +70,287 @@ import VoxelShapeType from "./VoxelShapeType.js";
47
70
  function Cesium3DTilesVoxelProvider(options) {
48
71
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
49
72
 
50
- /** @inheritdoc */
51
- this.shapeTransform = undefined;
52
-
53
- /** @inheritdoc */
54
- this.globalTransform = undefined;
55
-
56
- /** @inheritdoc */
57
- this.shape = undefined;
58
-
59
- /** @inheritdoc */
60
- this.minBounds = undefined;
61
-
62
- /** @inheritdoc */
63
- this.maxBounds = undefined;
64
-
65
- /** @inheritdoc */
66
- this.dimensions = undefined;
67
-
68
- /** @inheritdoc */
69
- this.paddingBefore = undefined;
70
-
71
- /** @inheritdoc */
72
- this.paddingAfter = undefined;
73
+ const {
74
+ className,
75
+ names,
76
+ types,
77
+ componentTypes,
78
+ shape,
79
+ dimensions,
80
+ paddingBefore = Cartesian3.ZERO.clone(),
81
+ paddingAfter = Cartesian3.ZERO.clone(),
82
+ globalTransform = Matrix4.IDENTITY.clone(),
83
+ shapeTransform = Matrix4.IDENTITY.clone(),
84
+ minBounds,
85
+ maxBounds,
86
+ minimumValues,
87
+ maximumValues,
88
+ maximumTileCount,
89
+ } = options;
73
90
 
74
- /** @inheritdoc */
75
- this.names = undefined;
76
-
77
- /** @inheritdoc */
78
- this.types = undefined;
79
-
80
- /** @inheritdoc */
81
- this.componentTypes = undefined;
82
-
83
- /** @inheritdoc */
84
- this.minimumValues = undefined;
85
-
86
- /** @inheritdoc */
87
- this.maximumValues = undefined;
88
-
89
- /** @inheritdoc */
90
- this.maximumTileCount = undefined;
91
+ //>>includeStart('debug', pragmas.debug);
92
+ Check.typeOf.string("className", className);
93
+ Check.typeOf.object("names", names);
94
+ Check.typeOf.object("types", types);
95
+ Check.typeOf.object("componentTypes", componentTypes);
96
+ Check.typeOf.string("shape", shape);
97
+ Check.typeOf.object("dimensions", dimensions);
98
+ //>>includeEnd('debug');
91
99
 
100
+ this._shapeTransform = shapeTransform;
101
+ this._globalTransform = globalTransform;
102
+ this._shape = shape;
103
+ this._minBounds = minBounds;
104
+ this._maxBounds = maxBounds;
105
+ this._dimensions = dimensions;
106
+ this._paddingBefore = paddingBefore;
107
+ this._paddingAfter = paddingAfter;
108
+ this._className = className;
109
+ this._names = names;
110
+ this._types = types;
111
+ this._componentTypes = componentTypes;
112
+ this._metadataOrder = VoxelMetadataOrder.GLTF;
113
+ this._minimumValues = minimumValues;
114
+ this._maximumValues = maximumValues;
115
+ this._maximumTileCount = maximumTileCount;
116
+ this._availableLevels = undefined;
92
117
  this._implicitTileset = undefined;
93
118
  this._subtreeCache = new ImplicitSubtreeCache();
94
119
  }
95
120
 
121
+ Object.defineProperties(Cesium3DTilesVoxelProvider.prototype, {
122
+ /**
123
+ * A transform from local space to global space.
124
+ *
125
+ * @memberof Cesium3DTilesVoxelProvider.prototype
126
+ * @type {Matrix4}
127
+ * @default Matrix4.IDENTITY
128
+ * @readonly
129
+ */
130
+ globalTransform: {
131
+ get: function () {
132
+ return this._globalTransform;
133
+ },
134
+ },
135
+
136
+ /**
137
+ * A transform from shape space to local space.
138
+ *
139
+ * @memberof Cesium3DTilesVoxelProvider.prototype
140
+ * @type {Matrix4}
141
+ * @default Matrix4.IDENTITY
142
+ * @readonly
143
+ */
144
+ shapeTransform: {
145
+ get: function () {
146
+ return this._shapeTransform;
147
+ },
148
+ },
149
+
150
+ /**
151
+ * Gets the {@link VoxelShapeType}
152
+ *
153
+ * @memberof Cesium3DTilesVoxelProvider.prototype
154
+ * @type {VoxelShapeType}
155
+ * @readonly
156
+ */
157
+ shape: {
158
+ get: function () {
159
+ return this._shape;
160
+ },
161
+ },
162
+
163
+ /**
164
+ * Gets the minimum bounds.
165
+ * If undefined, the shape's default minimum bounds will be used instead.
166
+ *
167
+ * @memberof Cesium3DTilesVoxelProvider.prototype
168
+ * @type {Cartesian3|undefined}
169
+ * @readonly
170
+ */
171
+ minBounds: {
172
+ get: function () {
173
+ return this._minBounds;
174
+ },
175
+ },
176
+
177
+ /**
178
+ * Gets the maximum bounds.
179
+ * If undefined, the shape's default maximum bounds will be used instead.
180
+ *
181
+ * @memberof Cesium3DTilesVoxelProvider.prototype
182
+ * @type {Cartesian3|undefined}
183
+ * @readonly
184
+ */
185
+ maxBounds: {
186
+ get: function () {
187
+ return this._maxBounds;
188
+ },
189
+ },
190
+
191
+ /**
192
+ * Gets the number of voxels per dimension of a tile. This is the same for all tiles in the dataset.
193
+ *
194
+ * @memberof Cesium3DTilesVoxelProvider.prototype
195
+ * @type {Cartesian3}
196
+ * @readonly
197
+ */
198
+ dimensions: {
199
+ get: function () {
200
+ return this._dimensions;
201
+ },
202
+ },
203
+
204
+ /**
205
+ * Gets the number of padding voxels before the tile. This improves rendering quality when sampling the edge of a tile, but it increases memory usage.
206
+ *
207
+ * @memberof Cesium3DTilesVoxelProvider.prototype
208
+ * @type {Cartesian3}
209
+ * @default Cartesian3.ZERO
210
+ * @readonly
211
+ */
212
+ paddingBefore: {
213
+ get: function () {
214
+ return this._paddingBefore;
215
+ },
216
+ },
217
+
218
+ /**
219
+ * Gets the number of padding voxels after the tile. This improves rendering quality when sampling the edge of a tile, but it increases memory usage.
220
+ *
221
+ * @memberof Cesium3DTilesVoxelProvider.prototype
222
+ * @type {Cartesian3}
223
+ * @default Cartesian3.ZERO
224
+ * @readonly
225
+ */
226
+ paddingAfter: {
227
+ get: function () {
228
+ return this._paddingAfter;
229
+ },
230
+ },
231
+
232
+ /**
233
+ * The metadata class for this tileset.
234
+ *
235
+ * @memberof Cesium3DTilesVoxelProvider.prototype
236
+ * @type {string}
237
+ * @readonly
238
+ */
239
+ className: {
240
+ get: function () {
241
+ return this._className;
242
+ },
243
+ },
244
+
245
+ /**
246
+ * Gets the metadata names.
247
+ *
248
+ * @memberof Cesium3DTilesVoxelProvider.prototype
249
+ * @type {string[]}
250
+ * @readonly
251
+ */
252
+ names: {
253
+ get: function () {
254
+ return this._names;
255
+ },
256
+ },
257
+
258
+ /**
259
+ * Gets the metadata types.
260
+ *
261
+ * @memberof Cesium3DTilesVoxelProvider.prototype
262
+ * @type {MetadataType[]}
263
+ * @readonly
264
+ */
265
+ types: {
266
+ get: function () {
267
+ return this._types;
268
+ },
269
+ },
270
+
271
+ /**
272
+ * Gets the metadata component types.
273
+ *
274
+ * @memberof Cesium3DTilesVoxelProvider.prototype
275
+ * @type {MetadataComponentType[]}
276
+ * @readonly
277
+ */
278
+ componentTypes: {
279
+ get: function () {
280
+ return this._componentTypes;
281
+ },
282
+ },
283
+
284
+ /**
285
+ * Gets the ordering of the metadata in the buffers.
286
+ *
287
+ * @memberof Cesium3DTilesVoxelProvider.prototype
288
+ * @type {VoxelMetadataOrder}
289
+ * @readonly
290
+ */
291
+ metadataOrder: {
292
+ get: function () {
293
+ return this._metadataOrder;
294
+ },
295
+ },
296
+
297
+ /**
298
+ * Gets the metadata minimum values.
299
+ *
300
+ * @memberof Cesium3DTilesVoxelProvider.prototype
301
+ * @type {number[][]|undefined}
302
+ * @readonly
303
+ */
304
+ minimumValues: {
305
+ get: function () {
306
+ return this._minimumValues;
307
+ },
308
+ },
309
+
310
+ /**
311
+ * Gets the metadata maximum values.
312
+ *
313
+ * @memberof Cesium3DTilesVoxelProvider.prototype
314
+ * @type {number[][]|undefined}
315
+ * @readonly
316
+ */
317
+ maximumValues: {
318
+ get: function () {
319
+ return this._maximumValues;
320
+ },
321
+ },
322
+
323
+ /**
324
+ * The maximum number of tiles that exist for this provider.
325
+ * This value is used as a hint to the voxel renderer to allocate an appropriate amount of GPU memory.
326
+ * If this value is not known it can be undefined.
327
+ *
328
+ * @memberof Cesium3DTilesVoxelProvider.prototype
329
+ * @type {number|undefined}
330
+ * @readonly
331
+ */
332
+ maximumTileCount: {
333
+ get: function () {
334
+ return this._maximumTileCount;
335
+ },
336
+ },
337
+
338
+ /**
339
+ * The number of levels of detail containing available tiles in the tileset.
340
+ *
341
+ * @memberof Cesium3DTilesVoxelProvider.prototype
342
+ * @type {number|undefined}
343
+ * @readonly
344
+ */
345
+ availableLevels: {
346
+ get: function () {
347
+ return this._availableLevels;
348
+ },
349
+ },
350
+ });
351
+
96
352
  /**
97
- * Creates a {@link VoxelProvider} that fetches voxel data from a 3D Tiles tileset.
353
+ * Creates a {@link Cesium3DTilesVoxelProvider} that fetches voxel data from a 3D Tiles tileset.
98
354
  *
99
355
  * @param {Resource|string} url The URL to a tileset JSON file
100
356
  * @returns {Promise<Cesium3DTilesVoxelProvider>} The created provider
@@ -104,6 +360,22 @@ function Cesium3DTilesVoxelProvider(options) {
104
360
  * @exception {RuntimeException} Root tile must have implicit tiling
105
361
  * @exception {RuntimeException} Tileset must have a metadata schema
106
362
  * @exception {RuntimeException} Only box, region and 3DTILES_bounding_volume_cylinder are supported in Cesium3DTilesVoxelProvider
363
+ *
364
+ * @example
365
+ * try {
366
+ * const voxelProvider = await Cesium3DTilesVoxelProvider.fromUrl(
367
+ * "http://localhost:8002/tilesets/voxel/tileset.json"
368
+ * );
369
+ * const voxelPrimitive = new VoxelPrimitive({
370
+ * provider: voxelProvider,
371
+ * customShader: customShader,
372
+ * });
373
+ * scene.primitives.add(voxelPrimitive);
374
+ * } catch (error) {
375
+ * console.error(`Error creating voxel primitive: ${error}`);
376
+ * }
377
+ *
378
+ * @see {@link VoxelPrimitive}
107
379
  */
108
380
  Cesium3DTilesVoxelProvider.fromUrl = async function (url) {
109
381
  //>>includeStart('debug', pragmas.debug);
@@ -118,49 +390,40 @@ Cesium3DTilesVoxelProvider.fromUrl = async function (url) {
118
390
  const schemaLoader = getMetadataSchemaLoader(tilesetJson, resource);
119
391
  await schemaLoader.load();
120
392
 
121
- const root = tilesetJson.root;
122
- const voxel = root.content.extensions["3DTILES_content_voxels"];
123
- const className = voxel.class;
393
+ const { root } = tilesetJson;
124
394
 
125
395
  const metadataJson = hasExtension(tilesetJson, "3DTILES_metadata")
126
396
  ? tilesetJson.extensions["3DTILES_metadata"]
127
397
  : tilesetJson;
128
398
 
129
- const metadataSchema = schemaLoader.schema;
130
- const metadata = new Cesium3DTilesetMetadata({
399
+ const tilesetMetadata = new Cesium3DTilesetMetadata({
131
400
  metadataJson: metadataJson,
132
- schema: metadataSchema,
401
+ schema: schemaLoader.schema,
133
402
  });
134
403
 
135
- const provider = new Cesium3DTilesVoxelProvider();
136
-
137
- addAttributeInfo(provider, metadata, className);
138
-
139
- const implicitTileset = new ImplicitTileset(resource, root, metadataSchema);
140
-
141
- const { shape, minBounds, maxBounds, shapeTransform, globalTransform } =
142
- getShape(root);
404
+ const voxel = root.content.extensions["3DTILES_content_voxels"];
405
+ const className = voxel.class;
143
406
 
144
- provider.shape = shape;
145
- provider.minBounds = minBounds;
146
- provider.maxBounds = maxBounds;
147
- provider.dimensions = Cartesian3.unpack(voxel.dimensions);
148
- provider.shapeTransform = shapeTransform;
149
- provider.globalTransform = globalTransform;
150
- provider.maximumTileCount = getTileCount(metadata);
407
+ const providerOptions = getAttributeInfo(tilesetMetadata, className);
408
+ Object.assign(providerOptions, getShape(root));
151
409
 
152
- let paddingBefore;
153
- let paddingAfter;
410
+ providerOptions.dimensions = Cartesian3.unpack(voxel.dimensions);
411
+ providerOptions.maximumTileCount = getTileCount(tilesetMetadata);
154
412
 
155
413
  if (defined(voxel.padding)) {
156
- paddingBefore = Cartesian3.unpack(voxel.padding.before);
157
- paddingAfter = Cartesian3.unpack(voxel.padding.after);
414
+ providerOptions.paddingBefore = Cartesian3.unpack(voxel.padding.before);
415
+ providerOptions.paddingAfter = Cartesian3.unpack(voxel.padding.after);
158
416
  }
159
417
 
160
- provider.paddingBefore = paddingBefore;
161
- provider.paddingAfter = paddingAfter;
418
+ const provider = new Cesium3DTilesVoxelProvider(providerOptions);
162
419
 
420
+ const implicitTileset = new ImplicitTileset(
421
+ resource,
422
+ root,
423
+ schemaLoader.schema,
424
+ );
163
425
  provider._implicitTileset = implicitTileset;
426
+ provider._availableLevels = implicitTileset.availableLevels;
164
427
 
165
428
  ResourceCache.unload(schemaLoader);
166
429
 
@@ -298,7 +561,7 @@ function getMetadataSchemaLoader(tilesetJson, resource) {
298
561
  });
299
562
  }
300
563
 
301
- function addAttributeInfo(provider, metadata, className) {
564
+ function getAttributeInfo(metadata, className) {
302
565
  const { schema, statistics } = metadata;
303
566
  const classStatistics = statistics?.classes[className];
304
567
  const properties = schema.classes[className].properties;
@@ -314,16 +577,22 @@ function addAttributeInfo(provider, metadata, className) {
314
577
  return { id, type, componentType, minValue, maxValue };
315
578
  });
316
579
 
317
- provider.names = propertyInfo.map((info) => info.id);
318
- provider.types = propertyInfo.map((info) => info.type);
319
- provider.componentTypes = propertyInfo.map((info) => info.componentType);
580
+ const names = propertyInfo.map((info) => info.id);
581
+ const types = propertyInfo.map((info) => info.type);
582
+ const componentTypes = propertyInfo.map((info) => info.componentType);
320
583
 
321
584
  const minimumValues = propertyInfo.map((info) => info.minValue);
322
585
  const maximumValues = propertyInfo.map((info) => info.maxValue);
323
586
  const hasMinimumValues = minimumValues.some(defined);
324
587
 
325
- provider.minimumValues = hasMinimumValues ? minimumValues : undefined;
326
- provider.maximumValues = hasMinimumValues ? maximumValues : undefined;
588
+ return {
589
+ className,
590
+ names,
591
+ types,
592
+ componentTypes,
593
+ minimumValues: hasMinimumValues ? minimumValues : undefined,
594
+ maximumValues: hasMinimumValues ? maximumValues : undefined,
595
+ };
327
596
  }
328
597
 
329
598
  function copyArray(values, length) {
@@ -339,29 +608,14 @@ function copyArray(values, length) {
339
608
  return Array.from({ length }, (v, i) => valuesArray[i]);
340
609
  }
341
610
 
342
- async function getVoxelContent(implicitTileset, tileCoordinates) {
343
- const voxelRelative =
344
- implicitTileset.contentUriTemplates[0].getDerivedResource({
345
- templateValues: tileCoordinates.getTemplateValues(),
346
- });
347
- const voxelResource = implicitTileset.baseResource.getDerivedResource({
348
- url: voxelRelative.url,
349
- });
350
-
351
- const arrayBuffer = await voxelResource.fetchArrayBuffer();
352
- const preprocessed = preprocess3DTileContent(arrayBuffer);
353
-
354
- const voxelContent = await VoxelContent.fromJson(
355
- voxelResource,
356
- preprocessed.jsonPayload,
357
- preprocessed.binaryPayload,
358
- implicitTileset.metadataSchema,
359
- );
360
-
361
- return voxelContent;
362
- }
363
-
364
- async function getSubtreePromise(provider, subtreeCoord) {
611
+ /**
612
+ * Get the subtree at a given subtree coordinate
613
+ * @param {VoxelProvider} provider The voxel provider
614
+ * @param {ImplicitTileCoordinates} subtreeCoord The coordinate at which to retrieve the subtree
615
+ * @returns {Promise<ImplicitSubtree>} The subtree at the given coordinate
616
+ * @private
617
+ */
618
+ async function getSubtree(provider, subtreeCoord) {
365
619
  const implicitTileset = provider._implicitTileset;
366
620
  const subtreeCache = provider._subtreeCache;
367
621
 
@@ -402,27 +656,38 @@ async function getSubtreePromise(provider, subtreeCoord) {
402
656
  return subtree;
403
657
  }
404
658
 
405
- /** @inheritdoc */
406
- Cesium3DTilesVoxelProvider.prototype.requestData = function (options) {
659
+ /**
660
+ * Requests the data for a given tile.
661
+ *
662
+ * @param {object} [options] Object with the following properties:
663
+ * @param {number} [options.tileLevel=0] The tile's level.
664
+ * @param {number} [options.tileX=0] The tile's X coordinate.
665
+ * @param {number} [options.tileY=0] The tile's Y coordinate.
666
+ * @param {number} [options.tileZ=0] The tile's Z coordinate.
667
+ * @privateparam {number} [options.keyframe=0] The requested keyframe.
668
+ * @returns {Promise<VoxelContent>|undefined} A promise resolving to a VoxelContent containing the data for the tile, or undefined if the request could not be scheduled this frame.
669
+ */
670
+ Cesium3DTilesVoxelProvider.prototype.requestData = async function (options) {
407
671
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
408
- const tileLevel = defaultValue(options.tileLevel, 0);
409
- const tileX = defaultValue(options.tileX, 0);
410
- const tileY = defaultValue(options.tileY, 0);
411
- const tileZ = defaultValue(options.tileZ, 0);
412
- const keyframe = defaultValue(options.keyframe, 0);
672
+ const {
673
+ tileLevel = 0,
674
+ tileX = 0,
675
+ tileY = 0,
676
+ tileZ = 0,
677
+ keyframe = 0,
678
+ } = options;
413
679
 
414
- // 3D Tiles currently doesn't support time-dynamic data.
415
680
  if (keyframe !== 0) {
416
- return undefined;
681
+ return Promise.reject(
682
+ `3D Tiles currently doesn't support time-dynamic data.`,
683
+ );
417
684
  }
418
685
 
419
686
  // 1. Load the subtree that the tile belongs to (possibly from the subtree cache)
420
687
  // 2. Load the voxel content if available
421
688
 
422
- const implicitTileset = this._implicitTileset;
423
- const names = this.names;
424
-
425
689
  // Can't use a scratch variable here because the object is used inside the promise chain.
690
+ const implicitTileset = this._implicitTileset;
426
691
  const tileCoordinates = new ImplicitTileCoordinates({
427
692
  subdivisionScheme: implicitTileset.subdivisionScheme,
428
693
  subtreeLevels: implicitTileset.subtreeLevels,
@@ -444,23 +709,29 @@ Cesium3DTilesVoxelProvider.prototype.requestData = function (options) {
444
709
 
445
710
  const that = this;
446
711
 
447
- return getSubtreePromise(that, subtreeCoord)
448
- .then(function (subtree) {
449
- const available = isSubtreeRoot
450
- ? subtree.childSubtreeIsAvailableAtCoordinates(tileCoordinates)
451
- : subtree.tileIsAvailableAtCoordinates(tileCoordinates);
452
-
453
- if (!available) {
454
- return Promise.reject("Tile is not available");
455
- }
456
-
457
- return getVoxelContent(implicitTileset, tileCoordinates);
458
- })
459
- .then(function (voxelContent) {
460
- return names.map(function (name) {
461
- return voxelContent.metadataTable.getPropertyTypedArray(name);
462
- });
463
- });
712
+ const subtree = await getSubtree(that, subtreeCoord);
713
+ // NOTE: these two subtree methods are ONLY used by voxels!
714
+ const isAvailable = isSubtreeRoot
715
+ ? subtree.childSubtreeIsAvailableAtCoordinates
716
+ : subtree.tileIsAvailableAtCoordinates;
717
+
718
+ const available = isAvailable.call(subtree, tileCoordinates);
719
+
720
+ if (!available) {
721
+ return Promise.reject(
722
+ `Tile is not available at level ${tileLevel}, x ${tileX}, y ${tileY}, z ${tileZ}.`,
723
+ );
724
+ }
725
+
726
+ const { contentUriTemplates, baseResource } = implicitTileset;
727
+ const gltfRelative = contentUriTemplates[0].getDerivedResource({
728
+ templateValues: tileCoordinates.getTemplateValues(),
729
+ });
730
+ const gltfResource = baseResource.getDerivedResource({
731
+ url: gltfRelative.url,
732
+ });
733
+
734
+ return VoxelContent.fromGltf(gltfResource);
464
735
  };
465
736
 
466
737
  export default Cesium3DTilesVoxelProvider;
@@ -170,7 +170,6 @@ Cesium3DTilesetStatistics.clone = function (statistics, result) {
170
170
  result.selected = statistics.selected;
171
171
  result.visited = statistics.visited;
172
172
  result.numberOfCommands = statistics.numberOfCommands;
173
- result.selected = statistics.selected;
174
173
  result.numberOfAttemptedRequests = statistics.numberOfAttemptedRequests;
175
174
  result.numberOfPendingRequests = statistics.numberOfPendingRequests;
176
175
  result.numberOfTilesProcessing = statistics.numberOfTilesProcessing;
@@ -117,8 +117,8 @@ ClippingPolygon.clone = function (polygon, result) {
117
117
  * Compares the provided ClippingPolygons and returns
118
118
  * <code>true</code> if they are equal, <code>false</code> otherwise.
119
119
  *
120
- * @param {Plane} left The first polygon.
121
- * @param {Plane} right The second polygon.
120
+ * @param {ClippingPolygon} left The first polygon.
121
+ * @param {ClippingPolygon} right The second polygon.
122
122
  * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
123
123
  */
124
124
  ClippingPolygon.equals = function (left, right) {
@@ -1225,6 +1225,7 @@ Node.prototype._evaluateVariableString = function (feature) {
1225
1225
  property = "";
1226
1226
  }
1227
1227
  result = result.replace(placeholder, property);
1228
+ variableRegex.lastIndex += property.length - placeholder.length;
1228
1229
  match = variableRegex.exec(result);
1229
1230
  }
1230
1231
  return result;