Commit 263f03d1 authored by MatusT's avatar MatusT
Browse files

Switch to Orbit camera, because it has smaller amount of issues. Fix one last...

Switch to Orbit camera, because it has smaller amount of issues. Fix one last performance bug: distance viewport starts drawing at LOD 0 causing gpu hang
parent 46c66a18
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ function App(): JSX.Element {
      clearBrowser() //not awaiting on purpouse
      throw "The workspace you are trying to load was created in a version of ChromoSkein that is no longer supported. Your saved workspace has been deleted. Sorry, hopefully it was nothing important ^_^;)"
    }
    console.time('Set STATE from file.');
    if (state.data)
      dispatchData({
        type: DataActionKind.SET,
@@ -151,6 +152,7 @@ function App(): JSX.Element {
        type: SelectionActionKind.SET,
        state: state.selections
      });
      console.timeEnd('Set STATE from file.');
  }

  function getCurrentState(): ApplicationState {
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ export async function saveToFile(states: ApplicationState): Promise<void> {
export type TextFile = { name: string, content: string };

export function loadFromJson(json: string): ApplicationState {
    console.time('loadFromJson');
    const parsed: ApplicationState = JSON.parse(json);

    // Fix TypedArray conversion to Object
@@ -24,6 +25,9 @@ export function loadFromJson(json: string): ApplicationState {
            selection.bins = new Uint16Array(Array.from(Object.values(selection.bins)));
        }       
    }

    console.timeEnd('loadFromJson');

    return parsed;
}

+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ const PI = Math.PI;
export class OrbitCamera extends Camera {
    private _rotX = 0.0;
    private _rotY = 0.0;
    private _distance = 1.0;
    private _distance = 1.5;
    private _lookAtPosition: vec3 = vec3.fromValues(0.0, 0.0, 0.0);
    private _upVector: vec3;

+2 −2
Original line number Diff line number Diff line
@@ -109,8 +109,8 @@ export class Viewport3D {
    }

    if (this._canvas != null && this._context != null) {
      // this._camera = camera ?? new OrbitCamera(this.graphicsLibrary.device, this.width, this.height);
      this._camera = camera ?? new SmoothCamera(this.graphicsLibrary.device, this.width, this.height);
      this._camera = camera ?? new OrbitCamera(this.graphicsLibrary.device, this.width, this.height);
      // this._camera = camera ?? new SmoothCamera(this.graphicsLibrary.device, this.width, this.height);
      this._canvas.addEventListener('mousedown', this.onMouseDown.bind(this));
      this._canvas.addEventListener('mouseup', this.onMouseUp.bind(this));
      this._canvas.addEventListener('mousemove', this.onMouseMove.bind(this));
+3 −1
Original line number Diff line number Diff line
@@ -444,6 +444,7 @@ export class DistanceViewport {
    public setPositions(positions: Array<vec4>): void {
        console.time('distanceMap::setPositions');
        const device = this.graphicsLibrary.device;
        this.globals = globalsNew();

        const worker = new Worker(new URL('./maximum_distance.worker.ts', import.meta.url));
        worker.onmessage = (result) => {
@@ -484,8 +485,9 @@ export class DistanceViewport {
                colorsCPU.buffer, 0,
                colorsCPU.buffer.byteLength,
            );

            this.recalculateLoD();
        };
        this.globals = globalsNew();
        worker.postMessage({
            globals: this.globals,
            positions,