diff --git a/viewer/package.json b/viewer/package.json index 7bafba3d271..8b79e429314 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -1,6 +1,6 @@ { "name": "@cognite/reveal", - "version": "4.14.1", + "version": "4.14.2", "description": "WebGL based 3D viewer for CAD and point clouds processed in Cognite Data Fusion.", "homepage": "https://github.com/cognitedata/reveal/tree/master/viewer", "repository": { diff --git a/viewer/packages/api/src/api-helpers/Image360ApiHelper.ts b/viewer/packages/api/src/api-helpers/Image360ApiHelper.ts index 93da768ed04..1a4eae7d069 100644 --- a/viewer/packages/api/src/api-helpers/Image360ApiHelper.ts +++ b/viewer/packages/api/src/api-helpers/Image360ApiHelper.ts @@ -482,8 +482,7 @@ export class Image360ApiHelper { public dispose(): void { this._onBeforeSceneRenderedEvent.unsubscribe(this._eventHandlers.updateHoverStateOnRender); this._domElement.removeEventListener('mousemove', this._eventHandlers.setHoverIconEventHandler); - this._domElement.addEventListener('pointerup', this._eventHandlers.enter360Image); - this._domElement.addEventListener('keydown', this._eventHandlers.exit360ImageOnEscapeKey); + this._domElement.removeEventListener('keydown', this._eventHandlers.exit360ImageOnEscapeKey); if (this._stationaryCameraManager && this._cachedCameraManager) { if (this._activeCameraManager.innerCameraManager === this._stationaryCameraManager) { diff --git a/viewer/packages/api/src/public/RevealManager.ts b/viewer/packages/api/src/public/RevealManager.ts index 24dbcb3df64..a8fd899d76e 100644 --- a/viewer/packages/api/src/public/RevealManager.ts +++ b/viewer/packages/api/src/public/RevealManager.ts @@ -100,6 +100,8 @@ export class RevealManager { this._pointCloudManager.dispose(); this._pipelineExecutor.dispose(); this._renderPipeline.dispose(); + this._resizeHandler.dispose(); + this._updateSubject.unsubscribe(); this._subscriptions.unsubscribe(); this._isDisposed = true; diff --git a/viewer/packages/api/src/public/migration/Cognite3DViewer.ts b/viewer/packages/api/src/public/migration/Cognite3DViewer.ts index 6feb0033f27..01c93bf4571 100644 --- a/viewer/packages/api/src/public/migration/Cognite3DViewer.ts +++ b/viewer/packages/api/src/public/migration/Cognite3DViewer.ts @@ -298,7 +298,8 @@ export class Cognite3DViewer { (useFlexibleCameraManager ? new FlexibleCameraManager( this._domElement, - this.modelIntersectionCallback.bind(this), + (offsetX: number, offsetY: number, pickBoundingBox: boolean) => + this.modelIntersectionCallback(offsetX, offsetY, pickBoundingBox), undefined, this._sceneHandler.scene, options.hasEventListeners @@ -306,7 +307,8 @@ export class Cognite3DViewer { : new DefaultCameraManager( this._domElement, this._mouseHandler, - this.modelIntersectionCallback.bind(this), + (offsetX: number, offsetY: number, pickBoundingBox: boolean) => + this.modelIntersectionCallback(offsetX, offsetY, pickBoundingBox), undefined )); diff --git a/viewer/packages/camera-manager/src/ComboControls.ts b/viewer/packages/camera-manager/src/ComboControls.ts index 99edb65a04a..057afcb19dc 100644 --- a/viewer/packages/camera-manager/src/ComboControls.ts +++ b/viewer/packages/camera-manager/src/ComboControls.ts @@ -385,7 +385,7 @@ export class ComboControls extends EventDispatcher { private addEventListeners() { this._keyboard.addEventListeners(this._domElement); this._domElement.addEventListener('pointerdown', this.onPointerDown); - this._domElement.addEventListener('wheel', event => this.onMouseWheel(event)); + this._domElement.addEventListener('wheel', this.onMouseWheel); this._domElement.addEventListener('contextmenu', this.onContextMenu); // canvas has focus by default, but it's possible to set tabindex on it, diff --git a/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts b/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts index 7d497d33b23..99001b33eaa 100644 --- a/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts +++ b/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts @@ -173,6 +173,7 @@ export class FlexibleCameraManager extends PointerEvents implements IFlexibleCam public dispose(): void { this._isDisposed = true; this.removeEventListeners(); + this._markers?.dispose(); } //================================================ diff --git a/viewer/packages/camera-manager/src/Flexible/FlexibleCameraMarkers.ts b/viewer/packages/camera-manager/src/Flexible/FlexibleCameraMarkers.ts index caaf9b320ce..ba188a21a6d 100644 --- a/viewer/packages/camera-manager/src/Flexible/FlexibleCameraMarkers.ts +++ b/viewer/packages/camera-manager/src/Flexible/FlexibleCameraMarkers.ts @@ -8,7 +8,7 @@ import { FlexibleControlsType } from './FlexibleControlsType'; export class FlexibleCameraMarkers { private readonly _scene: Scene; - private _targetMarker: Object3D | undefined; + private _targetMarker: Sprite | undefined; //================================================ // CONSTRUCTOR @@ -39,6 +39,16 @@ export class FlexibleCameraMarkers { } } + public dispose(): void { + if (this._targetMarker) { + this._scene.remove(this._targetMarker); + this._targetMarker.material.map?.dispose(); + this._targetMarker.material.dispose(); + this._targetMarker.geometry.dispose(); + this._targetMarker = undefined; + } + } + private isVisible(manager: FlexibleCameraManager): boolean { if (!manager.options.showTarget) { return false; diff --git a/viewer/packages/rendering/src/ResizeHandler.ts b/viewer/packages/rendering/src/ResizeHandler.ts index a7f092f84b0..e102a87a58b 100644 --- a/viewer/packages/rendering/src/ResizeHandler.ts +++ b/viewer/packages/rendering/src/ResizeHandler.ts @@ -23,7 +23,7 @@ export class ResizeHandler { private readonly _onCameraChangeCallback: () => void; private readonly _onCameraStopCallback: () => void; - private readonly _resizeObserver: ResizeObserver | undefined; + private _resizeObserver: ResizeObserver | undefined; private _shouldResize: boolean = false; @@ -141,7 +141,9 @@ export class ResizeHandler { } dispose(): void { + this._resizeObserver?.unobserve(this._renderer.domElement.parentElement!); this._resizeObserver?.disconnect(); + this._resizeObserver = undefined; } }