cesium-native 0.53.0
Loading...
Searching...
No Matches
Cesium3DTilesSelection::GltfModifier Class Referenceabstract

An abstract class that allows modifying a tile's glTF model after it has been loaded. More...

#include <Cesium3DTilesSelection/GltfModifier.h>

Inheritance diagram for Cesium3DTilesSelection::GltfModifier:
Cesium3DTilesSelection::TileLoadRequester

Public Member Functions

std::optional< int64_t > getCurrentVersion () const
 Gets the current version number, or std::nullopt if the GltfModifier is currently inactive.
 
bool isActive () const
 Checks if this GltfModifier is active.
 
void trigger ()
 Call this the first time to activate this GltfModifier after it has been constructed in its default nilpotent state and set the getCurrentVersion to 0. Call it successive times to increment getCurrentVersion and reapply modification to all previously-modified models without unloading them.
 
virtual CesiumAsync::Future< std::optional< GltfModifierOutput > > apply (GltfModifierInput &&input)=0
 Implement this method to apply custom modification to a glTF model. It is called by the Tileset from within a worker thread.
 
bool needsWorkerThreadModification (const Tile &tile) const
 Checks if the given tile needs to be processed by this GltfModifier in a worker thread.
 
bool needsMainThreadModification (const Tile &tile) const
 Checks if the given tile needs to be processed by this GltfModifier in the main thread.
 

Protected Member Functions

virtual CesiumAsync::Future< void > onRegister (const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::shared_ptr< spdlog::logger > &pLogger, const TilesetMetadata &tilesetMetadata, const Tile &rootTile)
 Notifies this instance that it has been registered with a Tileset.
 

Friends

class TilesetContentManager
 
class MockTilesetContentManagerForGltfModifier
 

Detailed Description

An abstract class that allows modifying a tile's glTF model after it has been loaded.

An example modification is merging or splitting the primitives in the glTF. Merging primitives can lead to improved rendering performance. Splitting primitives allows different materials to be assigned to parts that were initially in the same primitive.

The GltfModifier can be applied several times during the lifetime of the model, depending on current needs. For this reason, the GltfModifer has a getCurrentVersion, which can be incremented by calling trigger. When the version is incremented, the GltfModifier will be re-applied to all previously-modified models.

The version number of a modified glTF is stored in the GltfModifierVersionExtension extension.

A just-constructed modifier is considered nilpotent, meaning nothing will happen until trigger has been called at least once.

The apply function is called from a worker thread. All other methods must only be called from the main thread.

Definition at line 101 of file GltfModifier.h.

Member Function Documentation

◆ apply()

virtual CesiumAsync::Future< std::optional< GltfModifierOutput > > Cesium3DTilesSelection::GltfModifier::apply ( GltfModifierInput && input)
pure virtual

Implement this method to apply custom modification to a glTF model. It is called by the Tileset from within a worker thread.

This method will be called for each Tile during the content load process if trigger has been called at least once. It will also be called again for already-loaded tiles for successive calls to trigger.

Parameters
inputThe input to the glTF modification.
Returns
A future that resolves to a GltfModifierOutput with the new model, or to std::nullopt if the model does not need to be modified.

◆ getCurrentVersion()

std::optional< int64_t > Cesium3DTilesSelection::GltfModifier::getCurrentVersion ( ) const

Gets the current version number, or std::nullopt if the GltfModifier is currently inactive.

Returns std::nullopt when in the default nilpotent state where glTFs will not be modified at all. Calling trigger once will set the version number to 0 and activate the GltfModifier. Calling it successive times will increment the version number and re-apply modification to all previously-modified models.

◆ isActive()

bool Cesium3DTilesSelection::GltfModifier::isActive ( ) const

Checks if this GltfModifier is active.

This method returns true if the current version is greater than or equal to 0, indicating that trigger has been called at least once.

◆ needsMainThreadModification()

bool Cesium3DTilesSelection::GltfModifier::needsMainThreadModification ( const Tile & tile) const

Checks if the given tile needs to be processed by this GltfModifier in the main thread.

Parameters
tileThe tile to check.
Returns
true if the tile needs to be processed by the GltfModifier in the main thread, or false otherwise.

◆ needsWorkerThreadModification()

bool Cesium3DTilesSelection::GltfModifier::needsWorkerThreadModification ( const Tile & tile) const

Checks if the given tile needs to be processed by this GltfModifier in a worker thread.

Parameters
tileThe tile to check.
Returns
true if the tile needs to be processed by the GltfModifier in a worker thread, or false otherwise.

◆ onRegister()

virtual CesiumAsync::Future< void > Cesium3DTilesSelection::GltfModifier::onRegister ( const CesiumAsync::AsyncSystem & asyncSystem,
const std::shared_ptr< CesiumAsync::IAssetAccessor > & pAssetAccessor,
const std::shared_ptr< spdlog::logger > & pLogger,
const TilesetMetadata & tilesetMetadata,
const Tile & rootTile )
protectedvirtual

Notifies this instance that it has been registered with a Tileset.

This method is called after the tileset's root tile is known but before Tileset::getRootTileAvailableEvent has been raised.

This method is called from the main thread. Override this method to respond to this event.

Parameters
asyncSystemThe async system with which to do background work.
pAssetAccessorThe asset accessor to use to retrieve any additional assets.
pLoggerThe logger to which to log errors and warnings that occur during preparation of the GltfModifier.
tilesetMetadataThe metadata associated with the tileset.
rootTileThe root tile of the tileset.
Returns
A future that resolves when the GltfModifier is ready to modify glTF instances for this tileset. Tileset loading will not proceed until this future resolves. If the future rejects, tileset load will proceed but the GltfModifier will not be used.

◆ trigger()

void Cesium3DTilesSelection::GltfModifier::trigger ( )

Call this the first time to activate this GltfModifier after it has been constructed in its default nilpotent state and set the getCurrentVersion to 0. Call it successive times to increment getCurrentVersion and reapply modification to all previously-modified models without unloading them.

While the GltfModifier is being reapplied for a new version, the display may show a mix of tiles with the old and new versions.

Friends And Related Symbol Documentation

◆ MockTilesetContentManagerForGltfModifier

friend class MockTilesetContentManagerForGltfModifier
friend

Definition at line 270 of file GltfModifier.h.

◆ TilesetContentManager

friend class TilesetContentManager
friend

Definition at line 269 of file GltfModifier.h.


The documentation for this class was generated from the following file: