cesium-native 0.61.0
Loading...
Searching...
No Matches
Tileset.h
1#pragma once
2
3#include <Cesium3DTilesSelection/Library.h>
4#include <Cesium3DTilesSelection/LoadedTileEnumerator.h>
5#include <Cesium3DTilesSelection/RasterOverlayCollection.h>
6#include <Cesium3DTilesSelection/SampleHeightResult.h>
7#include <Cesium3DTilesSelection/Tile.h>
8#include <Cesium3DTilesSelection/TilesetContentLoader.h>
9#include <Cesium3DTilesSelection/TilesetContentLoaderFactory.h>
10#include <Cesium3DTilesSelection/TilesetExternals.h>
11#include <Cesium3DTilesSelection/TilesetLoadFailureDetails.h>
12#include <Cesium3DTilesSelection/TilesetOptions.h>
13#include <Cesium3DTilesSelection/TilesetSelection.h>
14#include <Cesium3DTilesSelection/TilesetViewGroup.h>
15#include <Cesium3DTilesSelection/ViewState.h>
16#include <Cesium3DTilesSelection/ViewUpdateResult.h>
17#include <CesiumAsync/AsyncSystem.h>
18#include <CesiumUtility/IntrusivePointer.h>
19
20#include <rapidjson/fwd.h>
21
22#include <list>
23#include <memory>
24#include <string>
25#include <vector>
26
27namespace Cesium3DTilesSelection {
28
29class TilesetContentManager;
30class TilesetMetadata;
31class TilesetHeightQuery;
32struct TilesetHeightRequest;
36
43class CESIUM3DTILESSELECTION_API Tileset final {
44public:
54 const TilesetExternals& externals,
55 std::unique_ptr<TilesetContentLoader>&& pCustomLoader,
56 std::unique_ptr<Tile>&& pRootTile,
57 const TilesetOptions& options = TilesetOptions());
58
66 const TilesetExternals& externals,
67 const std::string& url,
68 const TilesetOptions& options = TilesetOptions());
69
82 const TilesetExternals& externals,
83 int64_t ionAssetID,
84 const std::string& ionAccessToken,
85 const TilesetOptions& options = TilesetOptions(),
86 const std::string& ionAssetEndpointUrl = "https://api.cesium.com/");
87
98 const TilesetExternals& externals,
99 TilesetContentLoaderFactory&& loaderFactory,
100 const TilesetOptions& options = TilesetOptions());
101
112 ~Tileset() noexcept;
113
120
130
135 std::optional<CesiumUtility::Credit> getUserCredit() const noexcept;
136
140 const std::vector<CesiumUtility::Credit>& getTilesetCredits() const noexcept;
141
146 void setShowCreditsOnScreen(bool showCreditsOnScreen) noexcept;
147
152 const CesiumUtility::CreditSource& getCreditSource() const noexcept;
153
158 TilesetExternals& getExternals() noexcept { return this->_externals; }
159
164 const TilesetExternals& getExternals() const noexcept {
165 return this->_externals;
166 }
167
173 return this->_asyncSystem;
174 }
175
177 const CesiumAsync::AsyncSystem& getAsyncSystem() const noexcept {
178 return this->_asyncSystem;
179 }
180
182 const TilesetOptions& getOptions() const noexcept { return this->_options; }
183
187 TilesetOptions& getOptions() noexcept { return this->_options; }
188
193 return this->_options.ellipsoid;
194 }
195
198 return this->_options.ellipsoid;
199 }
200
206 const Tile* getRootTile() const noexcept;
207
213 Tile* getRootTile() noexcept;
214
219
221 const RasterOverlayCollection& getOverlays() const noexcept;
222
227
230
241 [[deprecated("Instead of `tileset.updateViewOffline(...)`, call "
242 "`tileset.updateViewGroupOffline(tileset.getDefaultViewGroup(), "
243 "...)`.")]] const ViewUpdateResult&
244 updateViewOffline(const std::vector<ViewState>& frustums);
245
261 [[deprecated("Instead of `tileset.updateView(...)`, call "
262 "`tileset.updateViewGroup(tileset.getDefaultViewGroup(), ...)` "
263 "followed by `tileset.loadTiles()`.")]] const ViewUpdateResult&
264 updateView(const std::vector<ViewState>& frustums, float deltaTime = 0.0f);
265
269 int32_t getNumberOfTilesLoaded() const;
270
278 float computeLoadProgress() noexcept;
279
297
304 const std::function<void(const Tile& tile)>& callback) const;
305
310 int64_t getTotalDataBytes() const noexcept;
311
336 const TilesetMetadata* getMetadata(const Tile* pTile = nullptr) const;
337
354
374 const std::vector<CesiumGeospatial::Cartographic>& positions);
375
383
386
411 TilesetViewGroup& viewGroup,
412 const std::vector<ViewState>& frustums,
413 float deltaTime = 0.0f);
414
435 TilesetViewGroup& viewGroup,
436 const std::vector<ViewState>& frustums);
437
446 void loadTiles();
447
462
476
488 bool waitForAllLoadsToComplete(double maximumWaitTimeInMilliseconds);
489
490 Tileset(const Tileset& rhs) = delete;
491 Tileset& operator=(const Tileset& rhs) = delete;
492
493private:
494 void _unloadCachedTiles(double timeBudget) noexcept;
495
496 void _updateLodTransitions(
497 const TilesetFrameState& frameState,
498 float deltaTime,
499 ViewUpdateResult& result) const noexcept;
500
501 TilesetExternals _externals;
502 CesiumAsync::AsyncSystem _asyncSystem;
503
504 TilesetOptions _options;
505
506 // Holds computed distances, to avoid allocating them on the heap during tile
507 // selection.
508 std::vector<double> _distances;
509
510 // Holds the occlusion proxies of the children of a tile, to avoid
511 // per-frame allocation.
512 std::vector<const TileOcclusionRendererProxy*> _childOcclusionProxies;
513
514 CesiumUtility::IntrusivePointer<TilesetContentManager>
515 _pTilesetContentManager;
516
517 std::list<TilesetHeightRequest> _heightRequests;
518
519 TilesetViewGroup _defaultViewGroup;
520};
521
522} // namespace Cesium3DTilesSelection
A "virtual collection" that allows enumeration through the loaded tiles in a subtree rooted at a give...
A collection of CesiumRasterOverlays::RasterOverlay instances that are associated with a Tileset.
The base class for something that requests loading of specific tiles from a 3D Tiles Tileset.
An interface for client renderers to use to represent tile bounding volumes that should be occlusion ...
A tile in a Tileset.
Definition Tile.h:123
External interfaces used by a Tileset.
Captures information about the current frame during a call to Tileset::updateViewGroup.
Holds the metadata associated with a Tileset or an external tileset. This holds all of the fields of ...
Contains assets that are potentially shared across multiple Tilesets.
Represents a group of views that collectively select tiles from a particular Tileset.
Tileset(const TilesetExternals &externals, TilesetContentLoaderFactory &&loaderFactory, const TilesetOptions &options=TilesetOptions())
Constructs a new instance with the given TilesetContentLoaderFactory.
void setShowCreditsOnScreen(bool showCreditsOnScreen) noexcept
Sets whether or not the tileset's credits should be shown on screen.
CesiumGeospatial::Ellipsoid & getEllipsoid() noexcept
Gets the CesiumGeospatial::Ellipsoid used by this tileset.
Definition Tileset.h:197
LoadedConstTileEnumerator loadedTiles() const
Gets an object that can be used to enumerate the loaded tiles of this tileset.
Tileset(const TilesetExternals &externals, int64_t ionAssetID, const std::string &ionAccessToken, const TilesetOptions &options=TilesetOptions(), const std::string &ionAssetEndpointUrl="https://api.cesium.com/")
Constructs a new instance with the given asset ID on Cesium ion.
Tileset(const TilesetExternals &externals, const std::string &url, const TilesetOptions &options=TilesetOptions())
Constructs a new instance with a given tileset.json URL.
CesiumAsync::AsyncSystem & getAsyncSystem() noexcept
Returns the CesiumAsync::AsyncSystem that is used for dispatching asynchronous tasks.
Definition Tileset.h:172
CesiumAsync::Future< SampleHeightResult > sampleHeightMostDetailed(const std::vector< CesiumGeospatial::Cartographic > &positions)
Initiates an asynchronous query for the height of this tileset at a list of cartographic positions (l...
const TilesetOptions & getOptions() const noexcept
Gets the TilesetOptions of this tileset.
Definition Tileset.h:182
const TilesetExternals & getExternals() const noexcept
Gets the TilesetExternals that summarize the external interfaces used by this tileset.
Definition Tileset.h:164
const CesiumUtility::CreditSource & getCreditSource() const noexcept
Gets the CesiumUtility::CreditSource that identifies this tileset's credits with the CesiumUtility::C...
const CesiumAsync::AsyncSystem & getAsyncSystem() const noexcept
Returns the CesiumAsync::AsyncSystem that is used for dispatching asynchronous tasks.
Definition Tileset.h:177
void loadTiles()
Loads the tiles that are currently deemed the most important, across all height queries and TilesetVi...
int32_t getNumberOfTilesLoaded() const
Gets the total number of tiles that are currently loaded.
CesiumAsync::SharedFuture< void > & getAsyncDestructionCompleteEvent()
A future that resolves when this Tileset has been destroyed (i.e. its destructor has been called) and...
CesiumAsync::SharedFuture< void > & getRootTileAvailableEvent()
A future that resolves when the details of the root tile of this tileset are available....
void registerLoadRequester(TileLoadRequester &requester)
Registers a tile load requester with this Tileset. Registered tile load requesters get to influence w...
TilesetViewGroup & getDefaultViewGroup()
Gets the default view group that is used when calling updateView.
float computeLoadProgress() noexcept
Gets the percentage of tiles that had been loaded for the default view group as of the last time it w...
const ViewUpdateResult & updateViewOffline(const std::vector< ViewState > &frustums)
Updates this view but waits for all tiles that meet sse to finish loading and ready to be rendered be...
int64_t getTotalDataBytes() const noexcept
Gets the total number of bytes of tile and raster overlay data that are currently loaded.
TilesetOptions & getOptions() noexcept
Gets the TilesetOptions of this tileset.
Definition Tileset.h:187
std::optional< CesiumUtility::Credit > getUserCredit() const noexcept
Gets the CesiumUtility::Credit created from TilesetOptions::credit, if any.
void forEachLoadedTile(const std::function< void(const Tile &tile)> &callback) const
Invokes a function for each tile that is currently loaded.
const TilesetMetadata * getMetadata(const Tile *pTile=nullptr) const
Gets the TilesetMetadata associated with the main or external tileset.json that contains a given tile...
const ViewUpdateResult & updateView(const std::vector< ViewState > &frustums, float deltaTime=0.0f)
Updates this view, returning the set of tiles to render in this view.
const ViewUpdateResult & updateViewGroup(TilesetViewGroup &viewGroup, const std::vector< ViewState > &frustums, float deltaTime=0.0f)
Updates a view group, returning the set of tiles to render in this view.
const CesiumGeospatial::Ellipsoid & getEllipsoid() const
Gets the CesiumGeospatial::Ellipsoid used by this tileset.
Definition Tileset.h:192
void updateTileContent(Tile &tile)
Updates the content of the given tile based on its current state.
~Tileset() noexcept
Destroys this tileset.
Tileset(const TilesetExternals &externals, std::unique_ptr< TilesetContentLoader > &&pCustomLoader, std::unique_ptr< Tile > &&pRootTile, const TilesetOptions &options=TilesetOptions())
Constructs a new instance with a given custom tileset loader.
bool waitForAllLoadsToComplete(double maximumWaitTimeInMilliseconds)
Waits until no tile loads are in progress. This function must be called from the main thread,...
const Tile * getRootTile() const noexcept
Gets the root tile of this tileset.
const std::vector< CesiumUtility::Credit > & getTilesetCredits() const noexcept
Get tileset credits.
RasterOverlayCollection & getOverlays() noexcept
Returns the RasterOverlayCollection of this tileset.
CesiumAsync::Future< const TilesetMetadata * > loadMetadata()
Asynchronously loads the metadata associated with the main tileset.json.
const ViewUpdateResult & updateViewGroupOffline(TilesetViewGroup &viewGroup, const std::vector< ViewState > &frustums)
Updates a view group, returning the set of tiles to render in this view. Unlike updateViewGroup,...
TilesetExternals & getExternals() noexcept
Gets the TilesetExternals that summarize the external interfaces used by this tileset.
Definition Tileset.h:158
TilesetSharedAssetSystem & getSharedAssetSystem() noexcept
Returns the TilesetSharedAssetSystem of this tileset.
The state of the view that is used during the traversal of a tileset.
Definition ViewState.h:25
Reports the results of Tileset::updateViewGroup.
A system for managing asynchronous requests and tasks.
Definition AsyncSystem.h:37
A quadratic surface defined in Cartesian coordinates.
Definition Ellipsoid.h:39
Classes that implement the 3D Tiles standard.
Classes that support asynchronous operations.
Classes for geospatial computations in Cesium.
Utility classes for Cesium.
STL namespace.
The result of sampling heights with Tileset::sampleHeightMostDetailed.
Additional options for configuring a Tileset.