Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | 1535x 1535x 1535x 1535x 1533x 1532x 1532x 1532x 1521x 920x 920x 920x 920x 1532x 1532x 1532x 1532x 1x 23x 1764x 1100x 1x 263x 1x 1753x 1x 20x 1x 2662x 2660x 2660x 2414x 246x 2656x 1x 67x 65x 65x 36x 30x 29x 1x 5712x 5710x 5710x 5708x 5710x 1938x 3772x 1x 23x 21x 21x 20x 21x 15x 6x 1x 10x 9x 9x 5x 4x 1x 5x 4x 4x 4x 4x 2x 2x 246x 246x 1x 245x 245x 9x 9x 1x 9x 9x | import Check from "../Core/Check.js";
import clone from "../Core/clone.js";
import Frozen from "../Core/Frozen.js";
import defined from "../Core/defined.js";
import MetadataEntity from "./MetadataEntity.js";
import MetadataTableProperty from "./MetadataTableProperty.js";
/**
* A table containing binary metadata for a collection of entities. This is
* used for representing binary properties of a batch table, as well as binary
* metadata in 3D Tiles next extensions.
* <p>
* For 3D Tiles Next details, see the {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_metadata|3DTILES_metadata Extension} for 3D Tiles, as well as the {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata|EXT_feature_metadata Extension} for glTF.
* </p>
*
* @param {object} options Object with the following properties:
* @param {number} options.count The number of entities in the table.
* @param {object} [options.properties] A dictionary containing properties.
* @param {MetadataClass} options.class The class that properties conform to.
* @param {Object<string, Uint8Array>} [options.bufferViews] An object mapping bufferView IDs to Uint8Array objects.
*
* @alias MetadataTable
* @constructor
*
* @private
* @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.
*/
function MetadataTable(options) {
options = options ?? Frozen.EMPTY_OBJECT;
const count = options.count;
const metadataClass = options.class;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThan("options.count", count, 0);
Check.typeOf.object("options.class", metadataClass);
//>>includeEnd('debug');
let byteLength = 0;
const properties = {};
if (defined(options.properties)) {
for (const propertyId in options.properties) {
Eif (options.properties.hasOwnProperty(propertyId)) {
const property = new MetadataTableProperty({
count: count,
property: options.properties[propertyId],
classProperty: metadataClass.properties[propertyId],
bufferViews: options.bufferViews,
});
properties[propertyId] = property;
byteLength += property.byteLength;
}
}
}
this._count = count;
this._class = metadataClass;
this._properties = properties;
this._byteLength = byteLength;
}
Object.defineProperties(MetadataTable.prototype, {
/**
* The number of entities in the table.
*
* @memberof MetadataTable.prototype
* @type {number}
* @readonly
* @private
*/
count: {
get: function () {
return this._count;
},
},
/**
* The class that properties conform to.
*
* @memberof MetadataTable.prototype
* @type {MetadataClass}
* @readonly
* @private
*/
class: {
get: function () {
return this._class;
},
},
/**
* The size of all typed arrays used in this table.
*
* @memberof MetadataTable.prototype
* @type {number}
* @readonly
* @private
*/
byteLength: {
get: function () {
return this._byteLength;
},
},
});
/**
* Returns whether the table has this property.
*
* @param {string} propertyId The case-sensitive ID of the property.
* @returns {boolean} Whether the table has this property.
* @private
*/
MetadataTable.prototype.hasProperty = function (propertyId) {
return MetadataEntity.hasProperty(propertyId, this._properties, this._class);
};
/**
* Returns whether the table has a property with the given semantic.
*
* @param {string} semantic The case-sensitive semantic of the property.
* @returns {boolean} Whether the table has a property with the given semantic.
* @private
*/
MetadataTable.prototype.hasPropertyBySemantic = function (semantic) {
return MetadataEntity.hasPropertyBySemantic(
semantic,
this._properties,
this._class,
);
};
/**
* Returns an array of property IDs.
*
* @param {string[]} [results] An array into which to store the results.
* @returns {string[]} The property IDs.
* @private
*/
MetadataTable.prototype.getPropertyIds = function (results) {
return MetadataEntity.getPropertyIds(this._properties, this._class, results);
};
/**
* Returns a copy of the value of the property with the given ID.
* <p>
* If the property is an enum the name of the enum is returned.
* </p>
* <p>
* If the property is normalized the normalized value is returned. The value is
* in the range [-1.0, 1.0] for signed integer types and [0.0, 1.0] for unsigned
* integer types.
* </p>
* <p>
* If the property is not normalized and type or componentType is INT64 or
* UINT64 a BigInt will be returned. On platforms that don't support BigInt a
* number will be returned instead. Note that numbers only support up to 52 bits
* of integer precision. Values greater than 2^53 - 1 or less than -(2^53 - 1)
* may lose precision when read.
* </p>
*
* @param {number} index The index of the entity.
* @param {string} propertyId The case-sensitive ID of the property.
* @returns {*} The value of the property or <code>undefined</code> if the entity does not have this property.
*
* @exception {DeveloperError} index is required and between zero and count - 1
* @private
*/
MetadataTable.prototype.getProperty = function (index, propertyId) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("propertyId", propertyId);
//>>includeEnd('debug');
const property = this._properties[propertyId];
let value;
if (defined(property)) {
value = property.get(index);
} else {
value = getDefault(this._class, propertyId);
}
return value;
};
/**
* Sets the value of the property with the given ID.
* <p>
* If the property is an enum the name of the enum must be provided, not the
* integer value.
* </p>
* <p>
* If the property is normalized a normalized value must be provided to this
* function. The value must be in the range [-1.0, 1.0] for signed integer
* types and [0.0, 1.0] for unsigned integer types.
* </p>
* <p>
* If the property is not normalized and type or componentType is INT64 or
* UINT64 a BigInt may be provided. On platforms that don't support BigInt a
* number may be provided instead. Note that numbers only support up to 52 bits
* of integer precision. Values greater than 2^53 - 1 or less than -(2^53 - 1)
* may lose precision when set."
* </p>
*
* @param {number} index The index of the entity.
* @param {string} propertyId The case-sensitive ID of the property.
* @param {*} value The value of the property that will be copied.
* @returns {boolean} <code>true</code> if the property was set, <code>false</code> otherwise.
*
* @exception {DeveloperError} index is required and between zero and count - 1
* @exception {DeveloperError} value does not match type
* @exception {DeveloperError} value is out of range for type
* @exception {DeveloperError} Array length does not match componentCount
* @private
*/
MetadataTable.prototype.setProperty = function (index, propertyId, value) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("propertyId", propertyId);
//>>includeEnd('debug');
const property = this._properties[propertyId];
if (defined(property)) {
property.set(index, value);
return true;
}
return false;
};
/**
* Returns a copy of the value of the property with the given semantic.
*
* @param {number} index The index of the entity.
* @param {string} semantic The case-sensitive semantic of the property.
* @returns {*} The value of the property or <code>undefined</code> if the entity does not have this semantic.
*
* @exception {DeveloperError} index is required and between zero and count - 1
* @private
*/
MetadataTable.prototype.getPropertyBySemantic = function (index, semantic) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("semantic", semantic);
//>>includeEnd('debug');
let property;
const propertiesBySemantic = this._class.propertiesBySemantic;
if (defined(propertiesBySemantic)) {
property = propertiesBySemantic[semantic];
}
if (defined(property)) {
return this.getProperty(index, property.id);
}
return undefined;
};
/**
* Sets the value of the property with the given semantic.
*
* @param {number} index The index of the entity.
* @param {string} semantic The case-sensitive semantic of the property.
* @param {*} value The value of the property that will be copied.
* @returns {boolean} <code>true</code> if the property was set, <code>false</code> otherwise.
*
* @exception {DeveloperError} index is required and between zero and count - 1
* @exception {DeveloperError} value does not match type
* @exception {DeveloperError} value is out of range for type
* @exception {DeveloperError} Array length does not match componentCount
* @private
*/
MetadataTable.prototype.setPropertyBySemantic = function (
index,
semantic,
value,
) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("semantic", semantic);
//>>includeEnd('debug');
let property;
const propertiesBySemantic = this._class.propertiesBySemantic;
if (defined(propertiesBySemantic)) {
property = propertiesBySemantic[semantic];
}
if (defined(property)) {
return this.setProperty(index, property.id, value);
}
return false;
};
/**
* Returns a typed array containing the property values for a given propertyId.
*
* @param {string} propertyId The case-sensitive ID of the property.
* @returns {*} The typed array containing the property values or <code>undefined</code> if the property values are not stored in a typed array.
*
* @private
*/
MetadataTable.prototype.getPropertyTypedArray = function (propertyId) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("propertyId", propertyId);
//>>includeEnd('debug');
const property = this._properties[propertyId];
if (defined(property)) {
return property.getTypedArray();
}
return undefined;
};
/**
* Returns a typed array containing the property values for the property with the given semantic.
*
* @param {string} semantic The case-sensitive semantic of the property.
* @returns {*} The typed array containing the property values or <code>undefined</code> if the property values are not stored in a typed array.
*
* @private
*/
MetadataTable.prototype.getPropertyTypedArrayBySemantic = function (semantic) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("semantic", semantic);
//>>includeEnd('debug');
let property;
const propertiesBySemantic = this._class.propertiesBySemantic;
Eif (defined(propertiesBySemantic)) {
property = propertiesBySemantic[semantic];
}
if (defined(property)) {
return this.getPropertyTypedArray(property.id);
}
return undefined;
};
function getDefault(classDefinition, propertyId) {
const classProperties = classDefinition.properties;
if (!defined(classProperties)) {
return undefined;
}
const classProperty = classProperties[propertyId];
if (defined(classProperty) && defined(classProperty.default)) {
let value = classProperty.default;
if (classProperty.isArray) {
value = clone(value, true);
}
value = classProperty.normalize(value);
return classProperty.unpackVectorAndMatrixTypes(value);
}
}
export default MetadataTable;
|