Skip to content

Commit

Permalink
Preserve navigation and projection mode between sessions #425
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Oct 14, 2023
1 parent 37a21aa commit d2215f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/website/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ export class Website
this.viewer.Init (canvas);
this.viewer.SetEdgeSettings (this.settings.edgeSettings);
this.viewer.SetBackgroundColor (this.settings.backgroundColor);
this.viewer.SetNavigationMode (this.cameraSettings.navigationMode);
this.viewer.SetProjectionMode (this.cameraSettings.projectionMode);
this.UpdateEnvironmentMap ();
}

Expand Down Expand Up @@ -651,6 +653,8 @@ export class Website
}

let importer = this.modelLoaderUI.GetImporter ();
let navigationModeIndex = (this.cameraSettings.navigationMode === NavigationMode.FixedUpVector ? 0 : 1);
let projectionModeIndex = (this.cameraSettings.projectionMode === ProjectionMode.Perspective ? 0 : 1);

AddButton (this.toolbar, 'open', 'Open from your device', [], () => {
this.OpenFileBrowserDialog ();
Expand All @@ -676,7 +680,7 @@ export class Website
this.viewer.FlipUpVector ();
});
AddSeparator (this.toolbar, ['only_full_width', 'only_on_model']);
AddRadioButton (this.toolbar, ['fix_up_on', 'fix_up_off'], ['Fixed up vector', 'Free orbit'], 0, ['only_full_width', 'only_on_model'], (buttonIndex) => {
AddRadioButton (this.toolbar, ['fix_up_on', 'fix_up_off'], ['Fixed up vector', 'Free orbit'], navigationModeIndex, ['only_full_width', 'only_on_model'], (buttonIndex) => {
if (buttonIndex === 0) {
this.cameraSettings.navigationMode = NavigationMode.FixedUpVector;
} else if (buttonIndex === 1) {
Expand All @@ -686,7 +690,7 @@ export class Website
this.viewer.SetNavigationMode (this.cameraSettings.navigationMode);
});
AddSeparator (this.toolbar, ['only_full_width', 'only_on_model']);
AddRadioButton (this.toolbar, ['camera_perspective', 'camera_orthographic'], ['Perspective camera', 'Orthographic camera'], 0, ['only_full_width', 'only_on_model'], (buttonIndex) => {
AddRadioButton (this.toolbar, ['camera_perspective', 'camera_orthographic'], ['Perspective camera', 'Orthographic camera'], projectionModeIndex, ['only_full_width', 'only_on_model'], (buttonIndex) => {
if (buttonIndex === 0) {
this.cameraSettings.projectionMode = ProjectionMode.Perspective;
} else if (buttonIndex === 1) {
Expand Down

0 comments on commit d2215f2

Please # to comment.