3D Performance issue fixed: Multiple selection the same object or null (#5411)

Related #3438
main
Boris Sekachev 3 years ago committed by GitHub
parent c49fe70083
commit 8b13a2c485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -85,6 +85,7 @@ non-ascii paths while adding files from "Connected file share" (issue #4428)
- Added force logout on CVAT app start if token is missing (<https://github.com/opencv/cvat/pull/5331>) - Added force logout on CVAT app start if token is missing (<https://github.com/opencv/cvat/pull/5331>)
- Drawing issues on 3D canvas (<https://github.com/opencv/cvat/pull/5410>) - Drawing issues on 3D canvas (<https://github.com/opencv/cvat/pull/5410>)
- Missed token with using social account authentication (<https://github.com/opencv/cvat/pull/5344>) - Missed token with using social account authentication (<https://github.com/opencv/cvat/pull/5344>)
- The same object on 3D scene or `null` selected each click (PERFORMANCE) (<https://github.com/opencv/cvat/pull/5411>)
- An exception when run export for an empty task (<https://github.com/opencv/cvat/pull/5396>) - An exception when run export for an empty task (<https://github.com/opencv/cvat/pull/5396>)
- Fixed FBRS serverless function runtime error on images with alpha channel (<https://github.com/opencv/cvat/pull/5384>) - Fixed FBRS serverless function runtime error on images with alpha channel (<https://github.com/opencv/cvat/pull/5384>)
- Attaching manifest with custom name (<https://github.com/opencv/cvat/pull/5377>) - Attaching manifest with custom name (<https://github.com/opencv/cvat/pull/5377>)

@ -1,6 +1,6 @@
{ {
"name": "cvat-canvas3d", "name": "cvat-canvas3d",
"version": "0.0.4", "version": "0.0.5",
"description": "Part of Computer Vision Annotation Tool which presents its canvas3D library", "description": "Part of Computer Vision Annotation Tool which presents its canvas3D library",
"main": "src/canvas3d.ts", "main": "src/canvas3d.ts",
"scripts": { "scripts": {

@ -4,14 +4,13 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import { import {
Canvas3dModel, Mode, DrawData, ActiveElement, FocusData, GroupData, Configuration, Canvas3dModel, Mode, DrawData, ActiveElement, GroupData, Configuration,
} from './canvas3dModel'; } from './canvas3dModel';
export interface Canvas3dController { export interface Canvas3dController {
readonly drawData: DrawData; readonly drawData: DrawData;
readonly activeElement: ActiveElement; readonly activeElement: ActiveElement;
readonly selected: any; readonly selected: any;
readonly focused: FocusData;
readonly groupData: GroupData; readonly groupData: GroupData;
readonly configuration: Configuration; readonly configuration: Configuration;
readonly imageIsDeleted: boolean; readonly imageIsDeleted: boolean;
@ -46,10 +45,6 @@ export class Canvas3dControllerImpl implements Canvas3dController {
return this.model.data.selected; return this.model.data.selected;
} }
public get focused(): any {
return this.model.data.focusData;
}
public get imageIsDeleted(): any { public get imageIsDeleted(): any {
return this.model.imageIsDeleted; return this.model.imageIsDeleted;
} }

@ -62,10 +62,6 @@ export enum MouseInteraction {
HOVER = 'hover', HOVER = 'hover',
} }
export interface FocusData {
clientID: string | null;
}
export interface ShapeProperties { export interface ShapeProperties {
opacity: number; opacity: number;
outlined: boolean; outlined: boolean;
@ -113,7 +109,6 @@ export interface Canvas3dDataModel {
exception: Error | null; exception: Error | null;
objects: any[]; objects: any[];
groupedObjects: any[]; groupedObjects: any[];
focusData: FocusData;
selected: any; selected: any;
shapeProperties: ShapeProperties; shapeProperties: ShapeProperties;
groupData: GroupData; groupData: GroupData;
@ -169,9 +164,6 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
}, },
mode: Mode.IDLE, mode: Mode.IDLE,
exception: null, exception: null,
focusData: {
clientID: null,
},
groupData: { groupData: {
enabled: false, enabled: false,
grouped: [], grouped: [],

@ -225,13 +225,13 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
const canvasFrontView = this.views.front.renderer.domElement; const canvasFrontView = this.views.front.renderer.domElement;
canvasPerspectiveView.addEventListener('contextmenu', (e: MouseEvent): void => { canvasPerspectiveView.addEventListener('contextmenu', (e: MouseEvent): void => {
if (this.controller.focused.clientID !== null) { if (this.model.data.activeElement.clientID !== null) {
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('canvas.contextmenu', { new CustomEvent('canvas.contextmenu', {
bubbles: false, bubbles: false,
cancelable: true, cancelable: true,
detail: { detail: {
clientID: Number(this.controller.focused.clientID), clientID: Number(this.model.data.activeElement.clientID),
clientX: e.clientX, clientX: e.clientX,
clientY: e.clientY, clientY: e.clientY,
}, },
@ -335,15 +335,18 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
if (intersects.length === 0) { if (intersects.length === 0) {
this.setHelperVisibility(false); this.setHelperVisibility(false);
} }
this.dispatchEvent( const intersectedClientID = intersects[0]?.object?.name || null;
new CustomEvent('canvas.selected', { if (this.model.data.activeElement.clientID !== intersectedClientID) {
bubbles: false, this.dispatchEvent(
cancelable: true, new CustomEvent('canvas.selected', {
detail: { bubbles: false,
clientID: intersects.length !== 0 ? Number(intersects[0].object.name) : null, cancelable: true,
}, detail: {
}), clientID: typeof intersectedClientID === 'string' ? +intersectedClientID : null,
); },
}),
);
}
} }
}); });
@ -356,7 +359,7 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
this.views.perspective.scene.children[0].children, this.views.perspective.scene.children[0].children,
false, false,
); );
if (intersects.length !== 0 || this.controller.focused.clientID !== null) { if (intersects.length !== 0 || this.model.data.activeElement.clientID !== null) {
this.setDefaultZoom(); this.setDefaultZoom();
} else { } else {
const { x, y, z } = this.action.frameCoordinates; const { x, y, z } = this.action.frameCoordinates;
@ -1261,14 +1264,12 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
const intersects = renderer.intersectObjects(children, false); const intersects = renderer.intersectObjects(children, false);
if (intersects.length !== 0) { if (intersects.length !== 0) {
const clientID = intersects[0].object.name; const clientID = intersects[0].object.name;
if (clientID === undefined || clientID === '' || this.model.data.focusData.clientID === clientID) { if (clientID === undefined || clientID === '' || this.model.data.activeElement.clientID === clientID) {
return; return;
} }
if (!this.action.selectable) return; if (!this.action.selectable) return;
this.resetColor();
const object = this.views.perspective.scene.getObjectByName(clientID); const object = this.views.perspective.scene.getObjectByName(clientID);
if (object === undefined) return; if (object === undefined) return;
this.model.data.focusData.clientID = clientID;
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('canvas.selected', { new CustomEvent('canvas.selected', {
bubbles: false, bubbles: false,
@ -1278,23 +1279,10 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
}, },
}), }),
); );
} else if (this.model.data.focusData.clientID !== null) {
this.resetColor();
this.model.data.focusData.clientID = null;
} }
} }
}; };
private resetColor(): void {
this.model.data.objects.forEach((object: any): void => {
const { clientID } = object;
const target = this.views.perspective.scene.getObjectByName(String(clientID));
if (target) {
((target as THREE.Mesh).material as THREE.MeshBasicMaterial).color.set((target as any).originalColor);
}
});
}
public render(): void { public render(): void {
Object.keys(this.views).forEach((view: string): void => { Object.keys(this.views).forEach((view: string): void => {
const viewType = this.views[view as keyof Views]; const viewType = this.views[view as keyof Views];

Loading…
Cancel
Save