|
cesium-native 0.53.0
|
An abstract class that allows modifying a tile's glTF model after it has been loaded. More...
#include <Cesium3DTilesSelection/GltfModifier.h>
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 |
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.
|
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.
| input | The input to the glTF modification. |
std::nullopt if the model does not need to be modified. | 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.
| 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.
| bool Cesium3DTilesSelection::GltfModifier::needsMainThreadModification | ( | const Tile & | tile | ) | const |
Checks if the given tile needs to be processed by this GltfModifier in the main thread.
| tile | The tile to check. |
true if the tile needs to be processed by the GltfModifier in the main thread, or false otherwise. | bool Cesium3DTilesSelection::GltfModifier::needsWorkerThreadModification | ( | const Tile & | tile | ) | const |
Checks if the given tile needs to be processed by this GltfModifier in a worker thread.
| tile | The tile to check. |
true if the tile needs to be processed by the GltfModifier in a worker thread, or false otherwise.
|
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.
| asyncSystem | The async system with which to do background work. |
| pAssetAccessor | The asset accessor to use to retrieve any additional assets. |
| pLogger | The logger to which to log errors and warnings that occur during preparation of the GltfModifier. |
| tilesetMetadata | The metadata associated with the tileset. |
| rootTile | The root tile of the tileset. |
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. | 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.
|
friend |
Definition at line 270 of file GltfModifier.h.
|
friend |
Definition at line 269 of file GltfModifier.h.