-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add ability to style objects in point clouds (#2104) * feat: point cloud API for styling (#2179) * feat: Webassembly setup (#2353) * Update point cloud feature branch from master (#2416) * feat: Rust/Webassembly octree implementation for faster point-object assignment (#2327) * feat: custom classification (#2320) * docs: finalize point cloud styling docs (#2500) * refactor: move point cloud object provider to data-providers and expose object bounding boxes (#2522) * fix: point cloud custom transformation (#2550) * improvement: various fixes for point clouds (#2551) * fix: export point cloud object metadata (#2552) * Various big and small fixes Co-authored-by: Lars Moastuen <lars.moastuen@cognite.com> Co-authored-by: Christopher J. Tannum <christopher.tannum@cognite.com> Co-authored-by: Savokr <savelii.novikov@cognite.com> Co-authored-by: Pramod S <87521752+pramodcog@users.noreply.github.com>
- Loading branch information
1 parent
a0108f7
commit 50ba964
Showing
144 changed files
with
5,394 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
target | ||
**/wasm/pkg/ | ||
|
||
**/.DS_Store | ||
**/dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
id: pointcloud-styling | ||
title: Pointcloud styling | ||
description: Usage of the styling API for pointcloud models | ||
--- | ||
|
||
Cognite Data Fusion has a concept of "objects" in point clouds, represented by one or more bounding volumes for | ||
each object. The objects are backed by the [CDF Annotations API](https://docs.cognite.com/api/v1/#tag/Annotations). | ||
Reveal supports styling individual objects within a point cloud. | ||
|
||
import { DemoWrapper } from '@site/versioned_docs/version-4.x/components/DemoWrapper'; | ||
|
||
<DemoWrapper modelType="pointcloud" /> | ||
|
||
In this context, a _stylable object_ is represented by a volume in space. Styling an object results in all points that lie within the corresponding volume to attain the assigned style. | ||
|
||
Stylable objects must be supplied separately from the model itself. Upon adding a new point cloud model to the viewer, Reveal will automatically fetch data describing the point cloud objects from CDF's Annotations API, if any are available. To get the number of fetched stylable objects, use the property `model.stylableObjectCount`, where `model` is a `CognitePointCloudModel`. | ||
|
||
After the model and associated stylable objects are loaded, you may list the objects using `model.traverseStylableObjects`. This method traverses all objects as instances of `PointCloudObjectMetadata`, containing the following fields: | ||
|
||
| Field | Field type | Description | | ||
|----------------------------|---------------------------------|---------------------------------------------------------------------------------------| | ||
| `annotationId` | `number` | The ID of the CDF annotation that this stylable object corresponds to. | | ||
| `assetId` | `number?` | The ID of the CDF asset associated with the annotation, if any. | | ||
| `boundingBox` | `THREE.Box3` | The bounding box of the stylable object in Reveal space. | | ||
|
||
To visualize all bounding boxes associated with the stylable objects: | ||
|
||
```js runnable | ||
const boxGroup = new THREE.Group(); | ||
|
||
model.traverseStylableObjects(obj => boxGroup.add(new THREE.Box3Helper(obj.boundingBox))); | ||
|
||
viewer.addObject3D(boxGroup); | ||
``` | ||
|
||
Point cloud objects can be styled with a `PointCloudAppearance` object, containing the following attributes: | ||
|
||
| Field | Field type | Description | | ||
|----------------------------|---------------------------------|---------------------------------------------------------------------------------------| | ||
| `color` | `[number, number, number]?` | Override color by setting RGB values in range [0,255]. `[0, 0, 0]` means no override. | | ||
| `visible` | `boolean?` | When false, stylable object will be invisible. Default value is `true`. | | ||
|
||
To assign a style to one or more stylable objects, you must first create an instance of the abstract class `PointCloudObjectCollection`. Currently, the only implementation of this class provided by Reveal is `AnnotationIdPointCloudObjectCollection`, which is initialized with a list of annotation IDs corresponding to stylable objects. To see all available annotation IDs associated with the model, you may use the method `model.traverseStylableObjects`. | ||
|
||
To color all stylable objects green: | ||
|
||
```js runnable | ||
const annotationIds = []; | ||
|
||
model.traverseStylableObjects(objectMetadata => annotationIds.push(objectMetadata.annotationId)); | ||
|
||
const objectCollection = new AnnotationIdPointCloudObjectCollection(annotationIds); | ||
const appearance = { color: [0, 255, 0] }; | ||
|
||
model.assignStyledObjectCollection(objectCollection, appearance); | ||
``` | ||
|
||
After assigning style to an object collection, you may use the property `model.styledCollections` to get a list of all object collections and their assigned styles registered on the model. | ||
|
||
## Default appearance | ||
|
||
It is also possible to set a default appearance for the point cloud using the `model.setDefaultPointCloudAppearance`. The following example makes all annotated objects visible, while hiding everything else: | ||
|
||
```js runnable | ||
const annotationIds = []; | ||
|
||
model.traverseStylableObjects(annotationMetadata => annotationIds.push(annotationMetadata.annotationId)); | ||
|
||
const objectCollection = new AnnotationIdPointCloudObjectCollection(annotationIds); | ||
const appearance = { visible: true }; | ||
|
||
model.assignStyledObjectCollection(objectCollection, appearance); | ||
model.setDefaultPointCloudAppearance({ visible: false }); | ||
``` | ||
|
||
Like in CAD styling, stylable objects that are part of multiple styled object collections will attain the appearance of the object set whose first style assignment was last. | ||
|
||
## Unassigning styled object collections | ||
|
||
To reset style of an object collection, use `model.unassignStyledObjectCollection` with the previously styled `PointCloudObjectCollection` as argument. To reset all styled objects use `model.removeAllStyledCollections` | ||
|
||
## Reset all styled object collections | ||
|
||
To reset all styled object collections, use the method `model.removeAllStyledObjectCollections()`. | ||
|
||
This example removes all style on stylable object collections and makes sure the rest of the point cloud is visible. | ||
```js runnable | ||
model.removeAllStyledObjectCollections(); | ||
model.setDefaultPointCloudAppearance({ visible: true }); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
documentation/versioned_docs/version-3.x/examples/click-reactions-pointcloud.mdx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
documentation/versioned_docs/version-4.x/examples/pointcloud-styling.mdx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.