Skip to content

Commit d2215f2

Browse files
committed
Preserve navigation and projection mode between sessions #425
1 parent 37a21aa commit d2215f2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/website/website.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ export class Website
592592
this.viewer.Init (canvas);
593593
this.viewer.SetEdgeSettings (this.settings.edgeSettings);
594594
this.viewer.SetBackgroundColor (this.settings.backgroundColor);
595+
this.viewer.SetNavigationMode (this.cameraSettings.navigationMode);
596+
this.viewer.SetProjectionMode (this.cameraSettings.projectionMode);
595597
this.UpdateEnvironmentMap ();
596598
}
597599

@@ -651,6 +653,8 @@ export class Website
651653
}
652654

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

655659
AddButton (this.toolbar, 'open', 'Open from your device', [], () => {
656660
this.OpenFileBrowserDialog ();
@@ -676,7 +680,7 @@ export class Website
676680
this.viewer.FlipUpVector ();
677681
});
678682
AddSeparator (this.toolbar, ['only_full_width', 'only_on_model']);
679-
AddRadioButton (this.toolbar, ['fix_up_on', 'fix_up_off'], ['Fixed up vector', 'Free orbit'], 0, ['only_full_width', 'only_on_model'], (buttonIndex) => {
683+
AddRadioButton (this.toolbar, ['fix_up_on', 'fix_up_off'], ['Fixed up vector', 'Free orbit'], navigationModeIndex, ['only_full_width', 'only_on_model'], (buttonIndex) => {
680684
if (buttonIndex === 0) {
681685
this.cameraSettings.navigationMode = NavigationMode.FixedUpVector;
682686
} else if (buttonIndex === 1) {
@@ -686,7 +690,7 @@ export class Website
686690
this.viewer.SetNavigationMode (this.cameraSettings.navigationMode);
687691
});
688692
AddSeparator (this.toolbar, ['only_full_width', 'only_on_model']);
689-
AddRadioButton (this.toolbar, ['camera_perspective', 'camera_orthographic'], ['Perspective camera', 'Orthographic camera'], 0, ['only_full_width', 'only_on_model'], (buttonIndex) => {
693+
AddRadioButton (this.toolbar, ['camera_perspective', 'camera_orthographic'], ['Perspective camera', 'Orthographic camera'], projectionModeIndex, ['only_full_width', 'only_on_model'], (buttonIndex) => {
690694
if (buttonIndex === 0) {
691695
this.cameraSettings.projectionMode = ProjectionMode.Perspective;
692696
} else if (buttonIndex === 1) {

0 commit comments

Comments
 (0)