@cesium/engine 1.0.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 (196) 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/decodeI3S.js +1 -1
  80. package/Build/Workers/package.js +25 -1
  81. package/Build/Workers/transferTypedArrayTest.js +25 -1
  82. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  83. package/Source/Core/EarthOrientationParameters.js +67 -63
  84. package/Source/Core/Ion.js +1 -1
  85. package/Source/Core/Matrix2.js +2 -1
  86. package/Source/Core/Matrix3.js +2 -1
  87. package/Source/Core/Matrix4.js +1 -0
  88. package/Source/Core/OrientedBoundingBox.js +4 -4
  89. package/Source/Core/S2Cell.js +3 -3
  90. package/Source/Core/Transforms.js +3 -7
  91. package/Source/DataSources/GpxDataSource.js +4 -6
  92. package/Source/DataSources/KmlDataSource.js +3 -5
  93. package/Source/Renderer/Context.js +27 -9
  94. package/Source/Renderer/Pass.js +3 -2
  95. package/Source/Scene/Cesium3DTileContentType.js +19 -0
  96. package/Source/Scene/Cesium3DTilesVoxelProvider.js +482 -0
  97. package/Source/Scene/Cesium3DTilesetMetadata.js +2 -2
  98. package/Source/Scene/ContentMetadata.js +2 -2
  99. package/Source/Scene/DerivedCommand.js +7 -0
  100. package/Source/Scene/Expression.js +1 -1
  101. package/Source/Scene/Globe.js +10 -0
  102. package/Source/Scene/GlobeSurfaceTileProvider.js +7 -0
  103. package/Source/Scene/GltfImageLoader.js +1 -1
  104. package/Source/Scene/GltfVertexBufferLoader.js +10 -2
  105. package/Source/Scene/GroupMetadata.js +2 -2
  106. package/Source/Scene/ImplicitMetadataView.js +2 -2
  107. package/Source/Scene/ImplicitSubtreeCache.js +127 -0
  108. package/Source/Scene/ImplicitSubtreeMetadata.js +2 -2
  109. package/Source/Scene/ImplicitTileset.js +3 -2
  110. package/Source/Scene/KeyframeNode.js +47 -0
  111. package/Source/Scene/Megatexture.js +490 -0
  112. package/Source/Scene/MetadataClass.js +60 -25
  113. package/Source/Scene/MetadataClassProperty.js +132 -68
  114. package/Source/Scene/MetadataComponentType.js +78 -57
  115. package/Source/Scene/MetadataEnum.js +59 -23
  116. package/Source/Scene/MetadataEnumValue.js +49 -15
  117. package/Source/Scene/MetadataSchema.js +53 -24
  118. package/Source/Scene/MetadataSchemaLoader.js +2 -2
  119. package/Source/Scene/MetadataTableProperty.js +2 -2
  120. package/Source/Scene/MetadataType.js +6 -14
  121. package/Source/Scene/Model/GeoJsonLoader.js +1 -1
  122. package/Source/Scene/Model/Model.js +2 -3
  123. package/Source/Scene/Model/buildDrawCommand.js +19 -11
  124. package/Source/Scene/PointCloud.js +1 -1
  125. package/Source/Scene/PropertyAttribute.js +2 -2
  126. package/Source/Scene/PropertyAttributeProperty.js +2 -2
  127. package/Source/Scene/PropertyTable.js +2 -2
  128. package/Source/Scene/PropertyTexture.js +2 -2
  129. package/Source/Scene/PropertyTextureProperty.js +2 -2
  130. package/Source/Scene/ResourceCache.js +9 -1
  131. package/Source/Scene/ResourceCacheKey.js +9 -1
  132. package/Source/Scene/Scene.js +17 -0
  133. package/Source/Scene/SpatialNode.js +375 -0
  134. package/Source/Scene/StructuralMetadata.js +2 -2
  135. package/Source/Scene/TileMetadata.js +2 -2
  136. package/Source/Scene/TilesetMetadata.js +2 -2
  137. package/Source/Scene/VoxelBoxShape.js +527 -0
  138. package/Source/Scene/VoxelContent.js +169 -0
  139. package/Source/Scene/VoxelCylinderShape.js +937 -0
  140. package/Source/Scene/VoxelEllipsoidShape.js +937 -0
  141. package/Source/Scene/VoxelPrimitive.js +1919 -0
  142. package/Source/Scene/VoxelProvider.js +255 -0
  143. package/Source/Scene/VoxelRenderResources.js +224 -0
  144. package/Source/Scene/VoxelShape.js +152 -0
  145. package/Source/Scene/VoxelShapeType.js +105 -0
  146. package/Source/Scene/VoxelTraversal.js +1144 -0
  147. package/Source/Scene/buildVoxelDrawCommands.js +116 -0
  148. package/Source/Scene/parseBatchTable.js +18 -2
  149. package/Source/Scene/preprocess3DTileContent.js +8 -0
  150. package/Source/Scene/processVoxelProperties.js +455 -0
  151. package/Source/Shaders/BillboardCollectionVS.glsl +1 -1
  152. package/Source/Shaders/BillboardCollectionVS.js +1 -1
  153. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  154. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  155. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +9 -0
  156. package/Source/Shaders/Builtin/Constants/passVoxels.js +11 -0
  157. package/Source/Shaders/Builtin/CzmBuiltins.js +17 -15
  158. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +55 -43
  159. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +55 -43
  160. package/Source/Shaders/GlobeFS.glsl +2 -1
  161. package/Source/Shaders/GlobeFS.js +2 -1
  162. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +5 -2
  163. package/Source/Shaders/PointPrimitiveCollectionVS.js +5 -2
  164. package/Source/Shaders/Voxels/IntersectBox.glsl +79 -0
  165. package/Source/Shaders/Voxels/IntersectBox.js +81 -0
  166. package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +70 -0
  167. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +72 -0
  168. package/Source/Shaders/Voxels/IntersectCylinder.glsl +273 -0
  169. package/Source/Shaders/Voxels/IntersectCylinder.js +275 -0
  170. package/Source/Shaders/Voxels/IntersectDepth.glsl +23 -0
  171. package/Source/Shaders/Voxels/IntersectDepth.js +25 -0
  172. package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +337 -0
  173. package/Source/Shaders/Voxels/IntersectEllipsoid.js +339 -0
  174. package/Source/Shaders/Voxels/Intersection.glsl +54 -0
  175. package/Source/Shaders/Voxels/Intersection.js +56 -0
  176. package/Source/Shaders/Voxels/IntersectionUtils.glsl +151 -0
  177. package/Source/Shaders/Voxels/IntersectionUtils.js +153 -0
  178. package/Source/Shaders/Voxels/Megatexture.glsl +136 -0
  179. package/Source/Shaders/Voxels/Megatexture.js +138 -0
  180. package/Source/Shaders/Voxels/Octree.glsl +221 -0
  181. package/Source/Shaders/Voxels/Octree.js +223 -0
  182. package/Source/Shaders/Voxels/VoxelFS.glsl +150 -0
  183. package/Source/Shaders/Voxels/VoxelFS.js +152 -0
  184. package/Source/Shaders/Voxels/VoxelVS.glsl +11 -0
  185. package/Source/Shaders/Voxels/VoxelVS.js +13 -0
  186. package/Source/Shaders/Voxels/convertUvToBox.glsl +16 -0
  187. package/Source/Shaders/Voxels/convertUvToBox.js +18 -0
  188. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +79 -0
  189. package/Source/Shaders/Voxels/convertUvToCylinder.js +81 -0
  190. package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +133 -0
  191. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +135 -0
  192. package/Source/ThirdParty/Workers/z-worker-pako.js +0 -0
  193. package/index.d.ts +3124 -2287
  194. package/index.js +1117 -1085
  195. package/package.json +3 -4
  196. package/Build/Workers/PolygonPipeline-774a8aaf.js +0 -1341
@@ -1,4 +1,5 @@
1
1
  import Check from "../Core/Check.js";
2
+ import clone from "../Core/clone.js";
2
3
  import defaultValue from "../Core/defaultValue.js";
3
4
  import defined from "../Core/defined.js";
4
5
  import MetadataClassProperty from "./MetadataClassProperty.js";
@@ -7,22 +8,65 @@ import MetadataClassProperty from "./MetadataClassProperty.js";
7
8
  * A metadata class.
8
9
  *
9
10
  * <p>
10
- * See the {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_metadata|3DTILES_metadata Extension} for 3D Tiles
11
+ * See the {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata|3D Metadata Specification} for 3D Tiles
11
12
  * </p>
12
13
  *
13
14
  * @param {Object} options Object with the following properties:
14
15
  * @param {String} options.id The ID of the class.
15
- * @param {Object} options.class The class JSON object.
16
- * @param {Object.<String, MetadataEnum>} [options.enums] A dictionary of enums.
16
+ * @param {String} [options.name] The name of the class.
17
+ * @param {String} [options.description] The description of the class.
18
+ * @param {Object.<String, MetadataClassProperty>} [options.properties] The class properties, where each key is the property ID.
19
+ * @param {*} [options.extras] Extra user-defined properties.
20
+ * @param {Object} [options.extensions] An object containing extensions.
17
21
  *
18
22
  * @alias MetadataClass
19
23
  * @constructor
20
- * @private
21
24
  * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
22
25
  */
23
26
  function MetadataClass(options) {
24
27
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
25
28
  const id = options.id;
29
+
30
+ //>>includeStart('debug', pragmas.debug);
31
+ Check.typeOf.string("options.id", id);
32
+ //>>includeEnd('debug');
33
+
34
+ const properties = defaultValue(options.properties, {});
35
+ const propertiesBySemantic = {};
36
+ for (const propertyId in properties) {
37
+ if (properties.hasOwnProperty(propertyId)) {
38
+ const property = properties[propertyId];
39
+ if (defined(property.semantic)) {
40
+ propertiesBySemantic[property.semantic] = property;
41
+ }
42
+ }
43
+ }
44
+
45
+ this._id = id;
46
+ this._name = options.name;
47
+ this._description = options.description;
48
+ this._properties = properties;
49
+ this._propertiesBySemantic = propertiesBySemantic;
50
+ this._extras = clone(options.extras, true);
51
+ this._extensions = clone(options.extensions, true);
52
+ }
53
+
54
+ /**
55
+ * Creates a {@link MetadataClass} from either 3D Tiles 1.1, 3DTILES_metadata, EXT_structural_metadata, or EXT_feature_metadata.
56
+ *
57
+ * @param {Object} options Object with the following properties:
58
+ * @param {String} options.id The ID of the class.
59
+ * @param {Object} options.class The class JSON object.
60
+ * @param {Object.<String, MetadataEnum>} [options.enums] A dictionary of enums.
61
+ *
62
+ * @returns {MetadataClass} The newly created metadata class.
63
+ *
64
+ * @private
65
+ * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
66
+ */
67
+ MetadataClass.fromJson = function (options) {
68
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
69
+ const id = options.id;
26
70
  const classDefinition = options.class;
27
71
 
28
72
  //>>includeStart('debug', pragmas.debug);
@@ -31,29 +75,26 @@ function MetadataClass(options) {
31
75
  //>>includeEnd('debug');
32
76
 
33
77
  const properties = {};
34
- const propertiesBySemantic = {};
35
78
  for (const propertyId in classDefinition.properties) {
36
79
  if (classDefinition.properties.hasOwnProperty(propertyId)) {
37
- const property = new MetadataClassProperty({
80
+ const property = MetadataClassProperty.fromJson({
38
81
  id: propertyId,
39
82
  property: classDefinition.properties[propertyId],
40
83
  enums: options.enums,
41
84
  });
42
85
  properties[propertyId] = property;
43
- if (defined(property.semantic)) {
44
- propertiesBySemantic[property.semantic] = property;
45
- }
46
86
  }
47
87
  }
48
88
 
49
- this._properties = properties;
50
- this._propertiesBySemantic = propertiesBySemantic;
51
- this._id = id;
52
- this._name = classDefinition.name;
53
- this._description = classDefinition.description;
54
- this._extras = classDefinition.extras;
55
- this._extensions = classDefinition.extensions;
56
- }
89
+ return new MetadataClass({
90
+ id: id,
91
+ name: classDefinition.name,
92
+ description: classDefinition.description,
93
+ properties: properties,
94
+ extras: classDefinition.extras,
95
+ extensions: classDefinition.extensions,
96
+ });
97
+ };
57
98
 
58
99
  Object.defineProperties(MetadataClass.prototype, {
59
100
  /**
@@ -62,7 +103,6 @@ Object.defineProperties(MetadataClass.prototype, {
62
103
  * @memberof MetadataClass.prototype
63
104
  * @type {Object.<String, MetadataClassProperty>}
64
105
  * @readonly
65
- * @private
66
106
  */
67
107
  properties: {
68
108
  get: function () {
@@ -91,7 +131,6 @@ Object.defineProperties(MetadataClass.prototype, {
91
131
  * @memberof MetadataClass.prototype
92
132
  * @type {String}
93
133
  * @readonly
94
- * @private
95
134
  */
96
135
  id: {
97
136
  get: function () {
@@ -105,7 +144,6 @@ Object.defineProperties(MetadataClass.prototype, {
105
144
  * @memberof MetadataClass.prototype
106
145
  * @type {String}
107
146
  * @readonly
108
- * @private
109
147
  */
110
148
  name: {
111
149
  get: function () {
@@ -119,7 +157,6 @@ Object.defineProperties(MetadataClass.prototype, {
119
157
  * @memberof MetadataClass.prototype
120
158
  * @type {String}
121
159
  * @readonly
122
- * @private
123
160
  */
124
161
  description: {
125
162
  get: function () {
@@ -128,12 +165,11 @@ Object.defineProperties(MetadataClass.prototype, {
128
165
  },
129
166
 
130
167
  /**
131
- * Extras in the JSON object.
168
+ * Extra user-defined properties.
132
169
  *
133
170
  * @memberof MetadataClass.prototype
134
171
  * @type {*}
135
172
  * @readonly
136
- * @private
137
173
  */
138
174
  extras: {
139
175
  get: function () {
@@ -142,12 +178,11 @@ Object.defineProperties(MetadataClass.prototype, {
142
178
  },
143
179
 
144
180
  /**
145
- * Extensions in the JSON object.
181
+ * An object containing extensions.
146
182
  *
147
183
  * @memberof MetadataClass.prototype
148
184
  * @type {Object}
149
185
  * @readonly
150
- * @private
151
186
  */
152
187
  extensions: {
153
188
  get: function () {
@@ -2,6 +2,7 @@ import Cartesian2 from "../Core/Cartesian2.js";
2
2
  import Cartesian3 from "../Core/Cartesian3.js";
3
3
  import Cartesian4 from "../Core/Cartesian4.js";
4
4
  import Check from "../Core/Check.js";
5
+ import clone from "../Core/clone.js";
5
6
  import defaultValue from "../Core/defaultValue.js";
6
7
  import defined from "../Core/defined.js";
7
8
  import DeveloperError from "../Core/DeveloperError.js";
@@ -12,68 +13,87 @@ import MetadataType from "./MetadataType.js";
12
13
  import MetadataComponentType from "./MetadataComponentType.js";
13
14
 
14
15
  /**
15
- * A metadata property, as part of a {@link MetadataClass}
16
+ * A metadata property, as part of a {@link MetadataClass}.
17
+ * <p>
18
+ * See the {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata|3D Metadata Specification} for 3D Tiles
19
+ * </p>
16
20
  *
17
21
  * @param {Object} options Object with the following properties:
18
22
  * @param {String} options.id The ID of the property.
19
- * @param {Object} options.property The property JSON object.
20
- * @param {Object.<String, MetadataEnum>} [options.enums] A dictionary of enums.
23
+ * @param {MetadataType} options.type The type of the property such as SCALAR, VEC2, VEC3.
24
+ * @param {MetadataComponentType} [options.componentType] The component type of the property. This includes integer (e.g. INT8 or UINT16), and floating point (FLOAT32 and FLOAT64) values.
25
+ * @param {MetadataEnum} [options.enumType] The enum type of the property. Only defined when type is ENUM.
26
+ * @param {Boolean} [options.isArray=false] True if a property is an array (either fixed length or variable length), false otherwise.
27
+ * @param {Boolean} [options.isVariableLengthArray=false] True if a property is a variable length array, false otherwise.
28
+ * @param {Number} [options.arrayLength] The number of array elements. Only defined for fixed length arrays.
29
+ * @param {Boolean} [options.normalized=false] Whether the property is normalized.
30
+ * @param {Number|Number[]|Number[][]} [options.min] A number or an array of numbers storing the minimum allowable value of this property. Only defined when type is a numeric type.
31
+ * @param {Number|Number[]|Number[][]} [options.max] A number or an array of numbers storing the maximum allowable value of this property. Only defined when type is a numeric type.
32
+ * @param {Number|Number[]|Number[][]} [options.offset] The offset to be added to property values as part of the value transform.
33
+ * @param {Number|Number[]|Number[][]} [options.scale] The scale to be multiplied to property values as part of the value transform.
34
+ * @param {Boolean|Number|String|Array} [options.noData] The no-data sentinel value that represents null values.
35
+ * @param {Boolean|Number|String|Array} [options.default] A default value to use when an entity's property value is not defined.
36
+ * @param {Boolean} [options.required=false] Whether the property is required.
37
+ * @param {String} [options.name] The name of the property.
38
+ * @param {String} [options.description] The description of the property.
39
+ * @param {String} [options.semantic] An identifier that describes how this property should be interpreted.
40
+ * @param {*} [options.extras] Extra user-defined properties.
41
+ * @param {Object} [options.extensions] An object containing extensions.
21
42
  *
22
43
  * @alias MetadataClassProperty
23
44
  * @constructor
24
- * @private
25
45
  * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
26
46
  */
27
47
  function MetadataClassProperty(options) {
28
48
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
29
49
  const id = options.id;
30
- const property = options.property;
50
+ const type = options.type;
31
51
 
32
52
  //>>includeStart('debug', pragmas.debug);
33
53
  Check.typeOf.string("options.id", id);
34
- Check.typeOf.object("options.property", property);
35
- Check.typeOf.string("options.property.type", property.type);
54
+ Check.typeOf.string("options.type", type);
36
55
  //>>includeEnd('debug');
37
56
 
38
- // Try to determine if this is the legacy extension. This is not
39
- // always possible, as there are some types that are valid in both
40
- // extensions.
41
- const isLegacyExtension = isLegacy(property);
42
- const parsedType = parseType(property, options.enums);
43
- const componentType = parsedType.componentType;
57
+ const componentType = options.componentType;
58
+ const enumType = options.enumType;
44
59
 
45
60
  const normalized =
46
61
  defined(componentType) &&
47
62
  MetadataComponentType.isIntegerType(componentType) &&
48
- defaultValue(property.normalized, false);
63
+ defaultValue(options.normalized, false);
49
64
 
50
65
  // Basic information about this property
51
66
  this._id = id;
52
- this._name = property.name;
53
- this._description = property.description;
54
- this._semantic = property.semantic;
55
- this._isLegacyExtension = isLegacyExtension;
67
+ this._name = options.name;
68
+ this._description = options.description;
69
+ this._semantic = options.semantic;
70
+
71
+ // Only for unit testing purposes, not documented in the API
72
+ this._isLegacyExtension = options.isLegacyExtension;
56
73
 
57
74
  // Details about basic types
58
- this._type = parsedType.type;
75
+ this._type = type;
59
76
  this._componentType = componentType;
60
- this._enumType = parsedType.enumType;
61
- this._valueType = parsedType.valueType;
77
+ this._enumType = enumType;
78
+ this._valueType = defined(enumType) ? enumType.valueType : componentType;
62
79
 
63
80
  // Details about arrays
64
- this._isArray = parsedType.isArray;
65
- this._isVariableLengthArray = parsedType.isVariableLengthArray;
66
- this._arrayLength = parsedType.arrayLength;
81
+ this._isArray = defaultValue(options.isArray, false);
82
+ this._isVariableLengthArray = defaultValue(
83
+ options.isVariableLengthArray,
84
+ false
85
+ );
86
+ this._arrayLength = options.arrayLength;
67
87
 
68
88
  // min and max allowed values
69
- this._min = property.min;
70
- this._max = property.max;
89
+ this._min = clone(options.min, true);
90
+ this._max = clone(options.max, true);
71
91
 
72
92
  // properties that adjust the range of metadata values
73
93
  this._normalized = normalized;
74
94
 
75
- let offset = property.offset;
76
- let scale = property.scale;
95
+ let offset = clone(options.offset, true);
96
+ let scale = clone(options.scale, true);
77
97
  const hasValueTransform = defined(offset) || defined(scale);
78
98
 
79
99
  const enableNestedArrays = true;
@@ -91,9 +111,46 @@ function MetadataClassProperty(options) {
91
111
 
92
112
  // sentinel value for missing data, and a default value to use
93
113
  // in its place if needed.
94
- this._noData = property.noData;
114
+ this._noData = clone(options.noData, true);
95
115
  // For vector and array types, this is stored as an array of values.
96
- this._default = property.default;
116
+ this._default = clone(options.default, true);
117
+
118
+ this._required = defaultValue(options.required, true);
119
+
120
+ // extras and extensions
121
+ this._extras = clone(options.extras, true);
122
+ this._extensions = clone(options.extensions, true);
123
+ }
124
+
125
+ /**
126
+ * Creates a {@link MetadataClassProperty} from either 3D Tiles 1.1, 3DTILES_metadata, EXT_structural_metadata, or EXT_feature_metadata.
127
+ *
128
+ * @param {Object} options Object with the following properties:
129
+ * @param {String} options.id The ID of the property.
130
+ * @param {Object} options.property The property JSON object.
131
+ * @param {Object.<String, MetadataEnum>} [options.enums] A dictionary of enums.
132
+ *
133
+ * @returns {MetadataClassProperty} The newly created metadata class property.
134
+ *
135
+ * @private
136
+ * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
137
+ */
138
+ MetadataClassProperty.fromJson = function (options) {
139
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
140
+ const id = options.id;
141
+ const property = options.property;
142
+
143
+ //>>includeStart('debug', pragmas.debug);
144
+ Check.typeOf.string("options.id", id);
145
+ Check.typeOf.object("options.property", property);
146
+ Check.typeOf.string("options.property.type", property.type);
147
+ //>>includeEnd('debug');
148
+
149
+ // Try to determine if this is the legacy extension. This is not
150
+ // always possible, as there are some types that are valid in both
151
+ // extensions.
152
+ const isLegacyExtension = isLegacy(property);
153
+ const parsedType = parseType(property, options.enums);
97
154
 
98
155
  // EXT_feature_metadata had an optional flag, while EXT_structural_metadata
99
156
  // has a required flag. The defaults are not the same, and there's some cases
@@ -109,12 +166,31 @@ function MetadataClassProperty(options) {
109
166
  } else {
110
167
  required = defaultValue(property.required, false);
111
168
  }
112
- this._required = required;
113
169
 
114
- // extras and extensions
115
- this._extras = property.extras;
116
- this._extensions = property.extensions;
117
- }
170
+ return new MetadataClassProperty({
171
+ id: id,
172
+ type: parsedType.type,
173
+ componentType: parsedType.componentType,
174
+ enumType: parsedType.enumType,
175
+ isArray: parsedType.isArray,
176
+ isVariableLengthArray: parsedType.isVariableLengthArray,
177
+ arrayLength: parsedType.arrayLength,
178
+ normalized: property.normalized,
179
+ min: property.min,
180
+ max: property.max,
181
+ offset: property.offset,
182
+ scale: property.scale,
183
+ noData: property.noData,
184
+ default: property.default,
185
+ required: required,
186
+ name: property.name,
187
+ description: property.description,
188
+ semantic: property.semantic,
189
+ extras: property.extras,
190
+ extensions: property.extensions,
191
+ isLegacyExtension: isLegacyExtension,
192
+ });
193
+ };
118
194
 
119
195
  Object.defineProperties(MetadataClassProperty.prototype, {
120
196
  /**
@@ -123,7 +199,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
123
199
  * @memberof MetadataClassProperty.prototype
124
200
  * @type {String}
125
201
  * @readonly
126
- * @private
127
202
  */
128
203
  id: {
129
204
  get: function () {
@@ -137,7 +212,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
137
212
  * @memberof MetadataClassProperty.prototype
138
213
  * @type {String}
139
214
  * @readonly
140
- * @private
141
215
  */
142
216
  name: {
143
217
  get: function () {
@@ -151,7 +225,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
151
225
  * @memberof MetadataClassProperty.prototype
152
226
  * @type {String}
153
227
  * @readonly
154
- * @private
155
228
  */
156
229
  description: {
157
230
  get: function () {
@@ -162,11 +235,9 @@ Object.defineProperties(MetadataClassProperty.prototype, {
162
235
  /**
163
236
  * The type of the property such as SCALAR, VEC2, VEC3
164
237
  *
165
- *
166
238
  * @memberof MetadataClassProperty.prototype
167
239
  * @type {MetadataType}
168
240
  * @readonly
169
- * @private
170
241
  */
171
242
  type: {
172
243
  get: function () {
@@ -180,7 +251,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
180
251
  * @memberof MetadataClassProperty.prototype
181
252
  * @type {MetadataEnum}
182
253
  * @readonly
183
- * @private
184
254
  */
185
255
  enumType: {
186
256
  get: function () {
@@ -195,7 +265,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
195
265
  * @memberof MetadataClassProperty.prototype
196
266
  * @type {MetadataComponentType}
197
267
  * @readonly
198
- * @private
199
268
  */
200
269
  componentType: {
201
270
  get: function () {
@@ -226,7 +295,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
226
295
  * @memberof MetadataClassProperty.prototype
227
296
  * @type {Boolean}
228
297
  * @readonly
229
- * @private
230
298
  */
231
299
  isArray: {
232
300
  get: function () {
@@ -240,7 +308,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
240
308
  * @memberof MetadataClassProperty.prototype
241
309
  * @type {Boolean}
242
310
  * @readonly
243
- * @private
244
311
  */
245
312
  isVariableLengthArray: {
246
313
  get: function () {
@@ -255,7 +322,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
255
322
  * @memberof MetadataClassProperty.prototype
256
323
  * @type {Number}
257
324
  * @readonly
258
- * @private
259
325
  */
260
326
  arrayLength: {
261
327
  get: function () {
@@ -269,7 +335,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
269
335
  * @memberof MetadataClassProperty.prototype
270
336
  * @type {Boolean}
271
337
  * @readonly
272
- * @private
273
338
  */
274
339
  normalized: {
275
340
  get: function () {
@@ -278,12 +343,11 @@ Object.defineProperties(MetadataClassProperty.prototype, {
278
343
  },
279
344
 
280
345
  /**
281
- * A number or an array of numbers storing the maximum allowable value of this property. Only defined when type or componentType is a numeric type.
346
+ * A number or an array of numbers storing the maximum allowable value of this property. Only defined when type is a numeric type.
282
347
  *
283
348
  * @memberof MetadataClassProperty.prototype
284
- * @type {Number|Number[]}
349
+ * @type {Number|Number[]|Number[][]}
285
350
  * @readonly
286
- * @private
287
351
  */
288
352
  max: {
289
353
  get: function () {
@@ -292,12 +356,11 @@ Object.defineProperties(MetadataClassProperty.prototype, {
292
356
  },
293
357
 
294
358
  /**
295
- * A number or an array of numbers storing the minimum allowable value of this property. Only defined when type or componentType is a numeric type.
359
+ * A number or an array of numbers storing the minimum allowable value of this property. Only defined when type is a numeric type.
296
360
  *
297
361
  * @memberof MetadataClassProperty.prototype
298
- * @type {Number|Number[]}
362
+ * @type {Number|Number[]|Number[][]}
299
363
  * @readonly
300
- * @private
301
364
  */
302
365
  min: {
303
366
  get: function () {
@@ -311,7 +374,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
311
374
  * @memberof MetadataClassProperty.prototype
312
375
  * @type {Boolean|Number|String|Array}
313
376
  * @readonly
314
- * @private
315
377
  */
316
378
  noData: {
317
379
  get: function () {
@@ -325,7 +387,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
325
387
  * @memberof MetadataClassProperty.prototype
326
388
  * @type {Boolean|Number|String|Array}
327
389
  * @readonly
328
- * @private
329
390
  */
330
391
  default: {
331
392
  get: function () {
@@ -339,7 +400,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
339
400
  * @memberof MetadataClassProperty.prototype
340
401
  * @type {Boolean}
341
402
  * @readonly
342
- * @private
343
403
  */
344
404
  required: {
345
405
  get: function () {
@@ -353,7 +413,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
353
413
  * @memberof MetadataClassProperty.prototype
354
414
  * @type {String}
355
415
  * @readonly
356
- * @private
357
416
  */
358
417
  semantic: {
359
418
  get: function () {
@@ -382,7 +441,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
382
441
  * @memberof MetadataClassProperty.prototype
383
442
  * @type {Number|Number[]|Number[][]}
384
443
  * @readonly
385
- * @private
386
444
  */
387
445
  offset: {
388
446
  get: function () {
@@ -396,7 +454,6 @@ Object.defineProperties(MetadataClassProperty.prototype, {
396
454
  * @memberof MetadataClassProperty.prototype
397
455
  * @type {Number|Number[]|Number[][]}
398
456
  * @readonly
399
- * @private
400
457
  */
401
458
  scale: {
402
459
  get: function () {
@@ -405,12 +462,11 @@ Object.defineProperties(MetadataClassProperty.prototype, {
405
462
  },
406
463
 
407
464
  /**
408
- * Extras in the JSON object.
465
+ * Extra user-defined properties.
409
466
  *
410
467
  * @memberof MetadataClassProperty.prototype
411
468
  * @type {*}
412
469
  * @readonly
413
- * @private
414
470
  */
415
471
  extras: {
416
472
  get: function () {
@@ -419,12 +475,11 @@ Object.defineProperties(MetadataClassProperty.prototype, {
419
475
  },
420
476
 
421
477
  /**
422
- * Extensions in the JSON object.
478
+ * An object containing extensions.
423
479
  *
424
480
  * @memberof MetadataClassProperty.prototype
425
481
  * @type {Object}
426
482
  * @readonly
427
- * @private
428
483
  */
429
484
  extensions: {
430
485
  get: function () {
@@ -450,7 +505,7 @@ function isLegacy(property) {
450
505
 
451
506
  // EXT_feature_metadata allowed numeric types as a type. Now they are
452
507
  // represented as {type: SINGLE, componentType: type}
453
- if (MetadataComponentType.isNumericType(type)) {
508
+ if (defined(MetadataComponentType[type])) {
454
509
  return true;
455
510
  }
456
511
 
@@ -585,10 +640,7 @@ function parseType(property, enums) {
585
640
 
586
641
  // Both EXT_feature_metadata and EXT_structural_metadata allow numeric types like
587
642
  // INT32 or FLOAT64 as a componentType.
588
- if (
589
- defined(componentType) &&
590
- MetadataComponentType.isNumericType(componentType)
591
- ) {
643
+ if (defined(componentType) && defined(MetadataComponentType[componentType])) {
592
644
  return {
593
645
  type: MetadataType.SCALAR,
594
646
  componentType: componentType,
@@ -602,7 +654,7 @@ function parseType(property, enums) {
602
654
 
603
655
  // EXT_feature_metadata: integer and float types were allowed as types,
604
656
  // but now these are expressed as {type: SCALAR, componentType: type}
605
- if (MetadataComponentType.isNumericType(type)) {
657
+ if (defined(MetadataComponentType[type])) {
606
658
  return {
607
659
  type: MetadataType.SCALAR,
608
660
  componentType: type,
@@ -687,6 +739,9 @@ MetadataClassProperty.prototype.unnormalize = function (value) {
687
739
  );
688
740
  };
689
741
 
742
+ /**
743
+ * @private
744
+ */
690
745
  MetadataClassProperty.prototype.applyValueTransform = function (value) {
691
746
  // variable length arrays do not have a well-defined offset/scale so this
692
747
  // is forbidden by the spec
@@ -702,6 +757,9 @@ MetadataClassProperty.prototype.applyValueTransform = function (value) {
702
757
  );
703
758
  };
704
759
 
760
+ /**
761
+ * @private
762
+ */
705
763
  MetadataClassProperty.prototype.unapplyValueTransform = function (value) {
706
764
  // variable length arrays do not have a well-defined offset/scale so this
707
765
  // is forbidden by the spec
@@ -717,6 +775,9 @@ MetadataClassProperty.prototype.unapplyValueTransform = function (value) {
717
775
  );
718
776
  };
719
777
 
778
+ /**
779
+ * @private
780
+ */
720
781
  MetadataClassProperty.prototype.expandConstant = function (
721
782
  constant,
722
783
  enableNestedArrays
@@ -1077,6 +1138,9 @@ function normalizeInPlace(values, valueType, normalizeFunction) {
1077
1138
  return values;
1078
1139
  }
1079
1140
 
1141
+ /**
1142
+ * @private
1143
+ */
1080
1144
  MetadataClassProperty.valueTransformInPlace = function (
1081
1145
  values,
1082
1146
  offsets,