Skip to content

Commit

Permalink
Update version to 4.20.0 (#4831)
Browse files Browse the repository at this point in the history
* Update package.json

* Update Image360History.ts

* Update Image360History.ts
  • Loading branch information
nilscognite authored Oct 29, 2024
1 parent 1cdd5c5 commit e27ecd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions viewer/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -15,7 +15,8 @@
"Håkon Flatval <[email protected]>",
"Savelii Novikov <[email protected]>",
"Pramod S <[email protected]>",
"Astrid Kløve-Graue <[email protected]>"
"Astrid Kløve-Graue <[email protected]>",
"Nils Petter Fremming <[email protected]>"
],
"sideEffects": false,
"main": "dist/index.js",
Expand Down
19 changes: 11 additions & 8 deletions viewer/packages/360-images/src/Image360History.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e27ecd4

Please sign in to comment.