Cognite3DViewer is a component that eases the migration from @cognite/3d-viewer.
It has mostly the same API and could be used when you don't need to control the scene or render loop,
i.e., just want to view some 3d models from CDF.
CogniteClient version 6 and later requires a
getToken function for authentication.
For this documentation we have made a class called
LoginManager that handles this. To
publicdata project used in the examples in this documentation, you may use the
LoginManager class yourself. Note that
accessing data in other projects may require different authentication flows not supported by the LoginManager.
You can read more about different types of authentication flows in the CogniteClient documentation.
Models can be temporarily hidden using
Cognite3DModel.visible. Note that
the viewer must be explicitly re-rendered after setting the visibility flag:
Hiding models doesn't free any memory occupied by the model and should only be used to temporarily hide a model when it's expected that it will shortly be shown again.
To also reclaim memory and permanently unloading the model, use
Only loading a part of the model
In some cases, it might be useful to restrict the area for which geometry is loaded to only show a partial
view. This can be done using a
geometryFilter which allows only loading geometry within a provided box:
By default, the bounds provided must be in "CDF coordinates". This is e.g. suitable if you are retrieving coordinates
directly from the Nodes API to for instance show the area
around a given node. If the coordinates are in "Reveal coordinates" (i.e. in
the WebGL coordinate system) the
geometryFilter can be
set up using