-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-components): Add tool and domain obect for making Image360…
…Annotation (#4864) * Add annotations polygons * Renaming * Fixes * Fix render on top of 360 Image * Connect annotations to their respective 360 images * Export image360Annotation objects * Increase cylinder radius and change pipe render order to render on top of image360 * Cleanup and export Image360Annotations button in Revealbuttons * Adding point count * Implement fast hover * Add transformation on the points * Tuning * Update Image360AnnotationDomainObject.ts * Update DomainObjectPanelUpdater.ts * Update DomainObjectPanelUpdater.ts * Update Image360AnnotationDomainObject.ts * Update Image360AnnotationDomainObject.ts * Update RevealButtons.tsx * Make it easier to read * Update LineDomainObject.ts * Update package.json * Fixes * Changing key strings --------- Co-authored-by: anders-hopland <[email protected]>
- Loading branch information
1 parent
151f3d7
commit 12035d6
Showing
44 changed files
with
788 additions
and
410 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
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
48 changes: 0 additions & 48 deletions
48
react-components/src/architecture/base/utilities/geometry/Points.ts
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
react-components/src/architecture/base/utilities/geometry/Polyline.ts
This file was deleted.
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
51 changes: 51 additions & 0 deletions
51
...onents/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.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,51 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { InstanceCommand } from '../../base/commands/InstanceCommand'; | ||
import { type DomainObject } from '../../base/domainObjects/DomainObject'; | ||
import { Changes } from '../../base/domainObjectsHelpers/Changes'; | ||
import { FocusType } from '../../base/domainObjectsHelpers/FocusType'; | ||
import { type IconName } from '../../base/utilities/IconName'; | ||
import { type TranslateKey } from '../../base/utilities/TranslateKey'; | ||
import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; | ||
|
||
export class DeleteSelectedImage360AnnotationCommand extends InstanceCommand { | ||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'Remove selected polygon' }; | ||
} | ||
|
||
public override get icon(): IconName { | ||
return 'Delete'; | ||
} | ||
|
||
public override get buttonType(): string { | ||
return 'ghost-destructive'; | ||
} | ||
|
||
public override get shortCutKey(): string { | ||
return 'DEL'; | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this.getFirstInstance() !== undefined; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
const array = Array.from(this.getInstances()); | ||
array.reverse(); | ||
for (const domainObject of array) { | ||
this.addTransaction(domainObject.createTransaction(Changes.deleted)); | ||
domainObject.removeInteractive(); | ||
} | ||
return true; | ||
} | ||
|
||
protected override isInstance(domainObject: DomainObject): boolean { | ||
return ( | ||
domainObject instanceof Image360AnnotationDomainObject && | ||
domainObject.isSelected && | ||
domainObject.focusType !== FocusType.Pending | ||
); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.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,56 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type Ray, type Vector3 } from 'three'; | ||
import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; | ||
import { type BaseTool } from '../../base/commands/BaseTool'; | ||
import { LineCreator } from '../primitives/line/LineCreator'; | ||
import assert from 'assert'; | ||
|
||
export class Image360AnnotationCreator extends LineCreator { | ||
// ================================================== | ||
// CONSTRUCTOR | ||
// ================================================== | ||
|
||
public constructor(tool: BaseTool) { | ||
const image360Id = tool.renderTarget.viewer.getActive360ImageInfo()?.image360.id; | ||
assert(image360Id !== undefined, 'Image360AnnotationCreator: image360Id is undefined'); | ||
|
||
// Get the camera position in CDF coordinates | ||
const { position } = tool.renderTarget.cameraManager.getCameraState(); | ||
assert(position !== undefined, 'Camera position unknown'); | ||
|
||
const center = position.clone(); | ||
center.applyMatrix4(tool.renderTarget.fromViewerMatrix); | ||
|
||
const domainObject = new Image360AnnotationDomainObject(image360Id); | ||
domainObject.center.copy(center); | ||
|
||
super(tool, domainObject); | ||
} | ||
|
||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get preferIntersection(): boolean { | ||
return false; | ||
} | ||
|
||
public override get minimumPointCount(): number { | ||
return 3; | ||
} | ||
|
||
public override get maximumPointCount(): number { | ||
return Number.MAX_SAFE_INTEGER; | ||
} | ||
|
||
protected override transformInputPoint( | ||
ray: Ray, | ||
_point: Vector3 | undefined, | ||
_isPending: boolean | ||
): Vector3 | undefined { | ||
return ray.direction.clone(); | ||
} | ||
} |
Oops, something went wrong.