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 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | 1265x 1265x 1265x 1265x 1265x 1265x 1265x 1x 6373x 6373x 6373x 6373x 5508x 865x 6223x 4903x 1340x 16x 1333x 1333x 6224x 5299x 31435x 298x 294x 294x 294x 294x 294x 118x 1268x 71x 49x 1x 1324x 1x 23x 1x 1x 39x 39x 39x 2x 37x 37x 37x 37x 3x 34x 1x 3x 3x 3x 1x 2x 2x 1x 29x 29x 11x 18x 18x 1x 113x 1x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 9938x 21x 9938x 9938x 9938x 9938x 2x 2x 9938x 9938x 9938x 9938x 9934x 1257x 1257x 1x 1x 1x 1251x 1251x 1x 181x 181x 181x 181x 181x 181x 181x 181x 1x 948x 948x 948x 948x 948x 948x 947x 947x 1x 77x 77x 77x 77x 76x 76x 1x 43x 43x 43x 43x 43x 43x 1x 16x 16x 16x 16x 16x 16x 1x 7x 7x 7x 7x 1265x 1265x | import Color from "../../Core/Color.js";
import combine from "../../Core/combine.js";
import defined from "../../Core/defined.js";
import destroyObject from "../../Core/destroyObject.js";
import DeveloperError from "../../Core/DeveloperError.js";
import Ellipsoid from "../../Core/Ellipsoid.js";
import Pass from "../../Renderer/Pass.js";
import ModelAnimationLoop from "../ModelAnimationLoop.js";
import Model from "./Model.js";
/**
* Represents the contents of a glTF, glb or
* {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Batched3DModel|Batched 3D Model}
* tile in a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles} tileset.
* <p>
* Implements the {@link Cesium3DTileContent} interface.
* </p>
* This object is normally not instantiated directly, use {@link Model3DTileContent.fromGltf}, {@link Model3DTileContent.fromB3dm}, {@link Model3DTileContent.fromI3dm}, {@link Model3DTileContent.fromPnts}, or {@link Model3DTileContent.fromGeoJson}.
*
* @alias Model3DTileContent
* @constructor
* @private
*/
function Model3DTileContent(tileset, tile, resource) {
this._tileset = tileset;
this._tile = tile;
this._resource = resource;
this._model = undefined;
this._metadata = undefined;
this._group = undefined;
this._ready = false;
}
Object.defineProperties(Model3DTileContent.prototype, {
featuresLength: {
get: function () {
const model = this._model;
const featureTables = model.featureTables;
const featureTableId = model.featureTableId;
if (defined(featureTables) && defined(featureTables[featureTableId])) {
return featureTables[featureTableId].featuresLength;
}
return 0;
},
},
pointsLength: {
get: function () {
return this._model.statistics.pointsLength;
},
},
trianglesLength: {
get: function () {
return this._model.statistics.trianglesLength;
},
},
geometryByteLength: {
get: function () {
return this._model.statistics.geometryByteLength;
},
},
texturesByteLength: {
get: function () {
return this._model.statistics.texturesByteLength;
},
},
batchTableByteLength: {
get: function () {
const statistics = this._model.statistics;
return (
statistics.propertyTablesByteLength + statistics.batchTexturesByteLength
);
},
},
innerContents: {
get: function () {
return undefined;
},
},
/**
* Returns true when the tile's content is ready to render; otherwise false
*
* @memberof Model3DTileContent.prototype
*
* @type {boolean}
* @readonly
* @private
*/
ready: {
get: function () {
return this._ready;
},
},
tileset: {
get: function () {
return this._tileset;
},
},
tile: {
get: function () {
return this._tile;
},
},
url: {
get: function () {
return this._resource.getUrlComponent(true);
},
},
batchTable: {
get: function () {
const model = this._model;
const featureTables = model.featureTables;
const featureTableId = model.featureTableId;
Eif (defined(featureTables) && defined(featureTables[featureTableId])) {
return featureTables[featureTableId];
}
return undefined;
},
},
metadata: {
get: function () {
return this._metadata;
},
set: function (value) {
this._metadata = value;
},
},
group: {
get: function () {
return this._group;
},
set: function (value) {
this._group = value;
},
},
});
/**
* Returns an array containing the `texture.id` values for all textures
* that are part of this content.
*
* @returns {string[]} The texture IDs
*/
Model3DTileContent.prototype.getTextureIds = function () {
return this._model.statistics.getTextureIds();
};
/**
* Returns the length, in bytes, of the texture data for the texture with
* the given ID that is part of this content, or `undefined` if this
* content does not contain the texture with the given ID.
*
* @param {string} textureId The texture ID
* @returns {number|undefined} The texture byte length
*/
Model3DTileContent.prototype.getTextureByteLengthById = function (textureId) {
return this._model.statistics.getTextureByteLengthById(textureId);
};
/**
* Returns the object that was created for the given extension.
*
* The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
* If the specified extension was present in the root of the underlying glTF asset,
* and a loader for the specified extension has processed the extension data, then
* this will return the model representation of the extension.
*
* @param {string} extensionName The name of the extension
* @returns {object|undefined} The object, or `undefined`
*
* @private
*/
Model3DTileContent.prototype.getExtension = function (extensionName) {
const model = this._model;
const extension = model.getExtension(extensionName);
return extension;
};
Model3DTileContent.prototype.getFeature = function (featureId) {
const model = this._model;
const featureTableId = model.featureTableId;
//>>includeStart('debug', pragmas.debug);
if (!defined(featureTableId)) {
throw new DeveloperError(
"No feature ID set is selected. Make sure Cesium3DTileset.featureIdLabel or Cesium3DTileset.instanceFeatureIdLabel is defined",
);
}
//>>includeEnd('debug');
const featureTable = model.featureTables[featureTableId];
//>>includeStart('debug', pragmas.debug);
Iif (!defined(featureTable)) {
throw new DeveloperError(
"No feature table found for the selected feature ID set",
);
}
//>>includeEnd('debug');
//>>includeStart('debug', pragmas.debug);
const featuresLength = featureTable.featuresLength;
if (!defined(featureId) || featureId < 0 || featureId >= featuresLength) {
throw new DeveloperError(
`featureId is required and must be between 0 and featuresLength - 1 (${
featuresLength - 1
}).`,
);
}
//>>includeEnd('debug');
return featureTable.getFeature(featureId);
};
Model3DTileContent.prototype.hasProperty = function (featureId, name) {
const model = this._model;
const featureTableId = model.featureTableId;
if (!defined(featureTableId)) {
return false;
}
const featureTable = model.featureTables[featureTableId];
return featureTable.hasProperty(featureId, name);
};
Model3DTileContent.prototype.applyDebugSettings = function (enabled, color) {
color = enabled ? color : Color.WHITE;
if (this.featuresLength === 0) {
this._model.color = color;
} else Eif (defined(this.batchTable)) {
this.batchTable.setAllColor(color);
}
};
Model3DTileContent.prototype.applyStyle = function (style) {
// the setter will call model.applyStyle()
this._model.style = style;
};
Model3DTileContent.prototype.update = function (tileset, frameState) {
const model = this._model;
const tile = this._tile;
model.colorBlendAmount = tileset.colorBlendAmount;
model.colorBlendMode = tileset.colorBlendMode;
model.modelMatrix = tile.computedTransform;
model.customShader = tileset.customShader;
model.featureIdLabel = tileset.featureIdLabel;
model.instanceFeatureIdLabel = tileset.instanceFeatureIdLabel;
model.lightColor = tileset.lightColor;
model.imageBasedLighting = tileset.imageBasedLighting;
model.backFaceCulling = tileset.backFaceCulling;
model.shadows = tileset.shadows;
model.showCreditsOnScreen = tileset.showCreditsOnScreen;
model.splitDirection = tileset.splitDirection;
model.debugWireframe = tileset.debugWireframe;
model.showOutline = tileset.showOutline;
model.outlineColor = tileset.outlineColor;
model.pointCloudShading = tileset.pointCloudShading;
// Updating clipping planes requires more effort because of ownership checks
const tilesetClippingPlanes = tileset.clippingPlanes;
model.referenceMatrix = tileset.clippingPlanesOriginMatrix;
if (defined(tilesetClippingPlanes) && tile.clippingPlanesDirty) {
// Dereference the clipping planes from the model if they are irrelevant.
model._clippingPlanes =
tilesetClippingPlanes.enabled && tile._isClipped
? tilesetClippingPlanes
: undefined;
}
const tilesetEnvironmentMapManager = tileset.environmentMapManager;
Eif (model.environmentMapManager !== tilesetClippingPlanes) {
model._environmentMapManager = tilesetEnvironmentMapManager;
}
// If the model references a different ClippingPlaneCollection from the tileset,
// update the model to use the new ClippingPlaneCollection.
if (
defined(tilesetClippingPlanes) &&
defined(model._clippingPlanes) &&
model._clippingPlanes !== tilesetClippingPlanes
) {
model._clippingPlanes = tilesetClippingPlanes;
model._clippingPlanesState = 0;
}
// Updating clipping polygons requires more effort because of ownership checks
const tilesetClippingPolygons = tileset.clippingPolygons;
Iif (defined(tilesetClippingPolygons) && tile.clippingPolygonsDirty) {
// Dereference the clipping polygons from the model if they are irrelevant.
model._clippingPolygons =
tilesetClippingPolygons.enabled && tile._isClippedByPolygon
? tilesetClippingPolygons
: undefined;
}
// If the model references a different ClippingPolygonCollection from the tileset,
// update the model to use the new ClippingPolygonCollection.
Iif (
defined(tilesetClippingPolygons) &&
defined(model._clippingPolygons) &&
model._clippingPolygons !== tilesetClippingPolygons
) {
model._clippingPolygons = tilesetClippingPolygons;
model._clippingPolygonsState = 0;
}
model.update(frameState);
if (!this._ready && model.ready) {
// Animation can only be added once the model is ready
model.activeAnimations.addAll({
loop: ModelAnimationLoop.REPEAT,
});
this._ready = true;
}
};
Model3DTileContent.prototype.isDestroyed = function () {
return false;
};
Model3DTileContent.prototype.destroy = function () {
this._model = this._model && this._model.destroy();
return destroyObject(this);
};
Model3DTileContent.fromGltf = async function (tileset, tile, resource, gltf) {
const content = new Model3DTileContent(tileset, tile, resource);
const additionalOptions = {
gltf: gltf,
basePath: resource,
};
const modelOptions = makeModelOptions(
tileset,
tile,
content,
additionalOptions,
);
const classificationType = tileset.vectorClassificationOnly
? undefined
: tileset.classificationType;
modelOptions.classificationType = classificationType;
const model = await Model.fromGltfAsync(modelOptions);
content._model = model;
return content;
};
Model3DTileContent.fromB3dm = async function (
tileset,
tile,
resource,
arrayBuffer,
byteOffset,
) {
const content = new Model3DTileContent(tileset, tile, resource);
const additionalOptions = {
arrayBuffer: arrayBuffer,
byteOffset: byteOffset,
resource: resource,
};
const modelOptions = makeModelOptions(
tileset,
tile,
content,
additionalOptions,
);
const classificationType = tileset.vectorClassificationOnly
? undefined
: tileset.classificationType;
modelOptions.classificationType = classificationType;
const model = await Model.fromB3dm(modelOptions);
content._model = model;
return content;
};
Model3DTileContent.fromI3dm = async function (
tileset,
tile,
resource,
arrayBuffer,
byteOffset,
) {
const content = new Model3DTileContent(tileset, tile, resource);
const additionalOptions = {
arrayBuffer: arrayBuffer,
byteOffset: byteOffset,
resource: resource,
};
const modelOptions = makeModelOptions(
tileset,
tile,
content,
additionalOptions,
);
const model = await Model.fromI3dm(modelOptions);
content._model = model;
return content;
};
Model3DTileContent.fromPnts = async function (
tileset,
tile,
resource,
arrayBuffer,
byteOffset,
) {
const content = new Model3DTileContent(tileset, tile, resource);
const additionalOptions = {
arrayBuffer: arrayBuffer,
byteOffset: byteOffset,
resource: resource,
};
const modelOptions = makeModelOptions(
tileset,
tile,
content,
additionalOptions,
);
const model = await Model.fromPnts(modelOptions);
content._model = model;
return content;
};
Model3DTileContent.fromGeoJson = async function (
tileset,
tile,
resource,
geoJson,
) {
const content = new Model3DTileContent(tileset, tile, resource);
const additionalOptions = {
geoJson: geoJson,
resource: resource,
};
const modelOptions = makeModelOptions(
tileset,
tile,
content,
additionalOptions,
);
const model = await Model.fromGeoJson(modelOptions);
content._model = model;
return content;
};
/**
* Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
*
* @param {Ray} ray The ray to test for intersection.
* @param {FrameState} frameState The frame state.
* @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
* @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
*
* @private
*/
Model3DTileContent.prototype.pick = function (ray, frameState, result) {
Iif (!defined(this._model) || !this._ready) {
return undefined;
}
const verticalExaggeration = frameState.verticalExaggeration;
const relativeHeight = frameState.verticalExaggerationRelativeHeight;
// All tilesets assume a WGS84 ellipsoid
return this._model.pick(
ray,
frameState,
verticalExaggeration,
relativeHeight,
Ellipsoid.WGS84,
result,
);
};
function makeModelOptions(tileset, tile, content, additionalOptions) {
const mainOptions = {
cull: false, // The model is already culled by 3D Tiles
releaseGltfJson: true, // Models are unique and will not benefit from caching so save memory
opaquePass: Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
modelMatrix: tile.computedTransform,
upAxis: tileset._modelUpAxis,
forwardAxis: tileset._modelForwardAxis,
incrementallyLoadTextures: false,
customShader: tileset.customShader,
content: content,
colorBlendMode: tileset.colorBlendMode,
colorBlendAmount: tileset.colorBlendAmount,
lightColor: tileset.lightColor,
imageBasedLighting: tileset.imageBasedLighting,
featureIdLabel: tileset.featureIdLabel,
instanceFeatureIdLabel: tileset.instanceFeatureIdLabel,
pointCloudShading: tileset.pointCloudShading,
clippingPlanes: tileset.clippingPlanes,
backFaceCulling: tileset.backFaceCulling,
shadows: tileset.shadows,
showCreditsOnScreen: tileset.showCreditsOnScreen,
splitDirection: tileset.splitDirection,
enableDebugWireframe: tileset._enableDebugWireframe,
debugWireframe: tileset.debugWireframe,
projectTo2D: tileset._projectTo2D,
enablePick: tileset._enablePick,
enableShowOutline: tileset._enableShowOutline,
showOutline: tileset.showOutline,
outlineColor: tileset.outlineColor,
};
return combine(additionalOptions, mainOptions);
}
export default Model3DTileContent;
|