From e27ecd42fbc81f359d4ef23066d11ad203a2102e Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:13:48 +0100 Subject: [PATCH] Update version to 4.20.0 (#4831) * Update package.json * Update Image360History.ts * Update Image360History.ts --- viewer/package.json | 5 +++-- .../360-images/src/Image360History.ts | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/viewer/package.json b/viewer/package.json index dcc90714a92..fdd6c46866a 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -1,6 +1,6 @@ { "name": "@cognite/reveal", - "version": "4.19.1", + "version": "4.20.0", "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": { @@ -15,7 +15,8 @@ "Håkon Flatval ", "Savelii Novikov ", "Pramod S ", - "Astrid Kløve-Graue " + "Astrid Kløve-Graue ", + "Nils Petter Fremming " ], "sideEffects": false, "main": "dist/index.js", diff --git a/viewer/packages/360-images/src/Image360History.ts b/viewer/packages/360-images/src/Image360History.ts index bd15f08f968..6a839545f9a 100644 --- a/viewer/packages/360-images/src/Image360History.ts +++ b/viewer/packages/360-images/src/Image360History.ts @@ -6,31 +6,34 @@ import { Image360 } from './entity/Image360'; import { Image360Action } from './Image360Action'; export class Image360History { - private readonly _history: Image360[] = []; + private readonly _images: Image360[] = []; private _currentIndex: number = -1; // Negative mean no current index (avoid empty because of harder logic) - public start(history: Image360): void { + public start(image: Image360): void { if (this.isLegalIndex(this._currentIndex + 1)) { - this._history.slice(this._currentIndex + 1); + this._images.slice(this._currentIndex + 1); } - this._history.push(history); - this._currentIndex = this._history.length - 1; + if (this.current() === image) { + return; // No need to add the same image twice to the end + } + this._images.push(image); + this._currentIndex = this._images.length - 1; } private current(): Image360 | undefined { if (!this.isLegalIndex(this._currentIndex)) { return undefined; } - return this._history[this._currentIndex]; + return this._images[this._currentIndex]; } public clear(): void { - this._history.splice(0, this._history.length); + this._images.splice(0, this._images.length); this._currentIndex = -1; } private isLegalIndex(index: number): boolean { - return index >= 0 && index < this._history.length; + return index >= 0 && index < this._images.length; } public canDoAction(action: Image360Action): boolean {