-
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)
* chore(deps): update dependency @cognite/sdk to v7.4.0 (#2160) Co-authored-by: Renovate Bot <bot@renovateapp.com> * improvement: remove unused 'headers' for custom data sources and update docs (#2164) * fix: clearing wrong render target (#2166) * example: add UI for setting point size type (#2157) * improvement: Make typescript strict (#2163) * fix: fix all strict typechecking errors * improvement: don't return primitive collections if empty * chore: lint fix * improvement: make byteOffset 0 if undefined * improvement: unhackify helper function * fix: fix that byteOffset fix * fix: fix type errors for tests * fix: correct BinaryHeap bevaviour Co-authored-by: Christopher J. Tannum <christopher.tannum@cognite.com> Co-authored-by: cognite-bulldozer[bot] <51074376+cognite-bulldozer[bot]@users.noreply.github.com> * chore(deps): update dependency @cognite/sdk to v7.5.0 (#2165) Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: cognite-bulldozer[bot] <51074376+cognite-bulldozer[bot]@users.noreply.github.com> * feat: simple styling in the works * feat: working visualization of pipe system Pipe data not included * feat: add simple styling interface for point clouds Also temporarily add data.ts to allow for testing for people who are not me * refac: make object style LUT 2D * refactor: let EPT loader take non-hardcoded object list * feat: automatically fetch annotations from server on point cloud load * chore: update Migration example for annotation fetching * fix: remove unused import * fix: remove not-yet-available feature * feat: add arbitrarily oriented boxes as stylable objects * refactor: some cleanup among stylable shapes * fix: don't import anything externally to worker * chore: lint fix * feat: blend style color with original RGB * chore: lint fix * chore: fix LGTM warnings * chore: update yarn lock * test: fix constructor in test * chore: remove unused member variable * chore: remove unused import Fixes LGTM error * fix: make @cognite/sdk-playground a peer dependency * fix: fix that pesky visual test error * refactor: factor out default EPT metadata file name * improvement: make "then" into an "await" * refactor: refactor annotation translation * chore: make public variable private-gettable * fix: correct import path * fix: refer to private field, not public getter * refactor: rewrite point cloud buffer parsing * improvement: be stricter in specifying optional types * improvement: make use of color constants * improvement: rewrite 0-vector check * fix: correct paratheses in shader * improvement: mappify array transformation * improvement: make ShapeType an enum * improvement: remove out-commented import * chore: lint fix * fix: make CogniteClientPlayground optionality annotation stricter * test: add trivial test for CognitePointCloudModel * fix: add missing creation function file * refactor: move some responsibility from PointCloudManager to -Factory * improvement: then -> await * fix: make indices be of type Uint32 * feat: add fromThreeVector3 utility function * refactor: parser-worker logic * improvement: make parse(data) actually return parsed data * improvement: improve readability * refactor: simplify primitive translation * improvement: renamed/simplify objectId assignment * refactor: change terminology from "StyledObject" to "StylableObject" * refactor: simplify Box constructor * chore: minor cleanup * improvement: simplify composite bounding box computation * fix: correct Box constructor call * fix: repair, please type checker, and lint after merge * improvement: remove computeBoundingBox for shapes for now They'll be back for the acceleration structure * chore: another lint fix * chore: add warning regarding point-object matching * refactor: remove "StylableObjectInfo" abstraction * chore: lint fix Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Lars Moastuen <lars.moastuen@cognite.com> Co-authored-by: Christopher J. Tannum <christopher.tannum@cognite.com> Co-authored-by: cognite-bulldozer[bot] <51074376+cognite-bulldozer[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a94dac6
commit 02b9439
Showing
49 changed files
with
1,421 additions
and
385 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
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,40 @@ | ||
/*! | ||
* Copyright 2022 Cognite AS | ||
*/ | ||
|
||
import { CognitePointCloudModel } from '@cognite/reveal'; | ||
import * as THREE from 'three'; | ||
|
||
export class PointCloudObjectStylingUI { | ||
|
||
static readonly MAX_OBJECTS = 10; | ||
|
||
private readonly _model: CognitePointCloudModel; | ||
|
||
constructor(uiFolder: dat.GUI, model: CognitePointCloudModel) { | ||
this._model = model; | ||
|
||
const objects = model.stylableObjects; | ||
|
||
objects.slice(0, PointCloudObjectStylingUI.MAX_OBJECTS).map(obj => this.createObjectUi(uiFolder.addFolder('Object #' + obj.objectId), obj.objectId)); | ||
} | ||
|
||
createObjectUi(uiFolder: dat.GUI, objectId: number): void { | ||
const state = { | ||
color: '#ffffff', | ||
}; | ||
|
||
uiFolder.addColor(state, 'color').name('Color').onFinishChange(color => { | ||
this._model.setObjectStyle(objectId, { color: hexStringToColor(color) }); | ||
}); | ||
} | ||
}; | ||
|
||
|
||
function hexStringToColor(hexColor: string): [number, number, number] { | ||
const threeColor = new THREE.Color(hexColor); | ||
return [ | ||
Math.floor(threeColor.r * 255), | ||
Math.floor(threeColor.g * 255), | ||
Math.floor(threeColor.b * 255)]; | ||
} |
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
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
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
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
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
18 changes: 18 additions & 0 deletions
18
viewer/packages/pointclouds/src/CognitePointCloudModel.test.ts
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,18 @@ | ||
/*! | ||
* Copyright 2022 Cognite AS | ||
*/ | ||
|
||
import { createPointCloudModel } from '../../../test-utilities/src/createPointCloudModel'; | ||
import { CognitePointCloudModel } from './CognitePointCloudModel'; | ||
|
||
describe(CognitePointCloudModel.name, () => { | ||
let model: CognitePointCloudModel; | ||
|
||
beforeEach(() => { | ||
model = createPointCloudModel(1, 2); | ||
}); | ||
|
||
test('Default CognitePointCloudModel does not contain annotations', () => { | ||
expect(model.stylableObjects).toHaveLength(0); | ||
}); | ||
}); |
Oops, something went wrong.