Browse Source

fix camera reset when loading stored state

David Sehnal 5 years ago
parent
commit
b4c70ab14a

+ 1 - 0
src/mol-canvas3d/canvas3d.ts

@@ -310,6 +310,7 @@ namespace Canvas3D {
             if (!scene.commit(isSynchronous ? void 0 : sceneCommitTimeoutMs)) return false;
 
             if (debugHelper.isEnabled) debugHelper.update();
+            if (reprCount.value === 0) cameraResetRequested = true;
             reprCount.next(reprRenderObjects.size);
             return true;
         }

+ 0 - 9
src/mol-plugin/behavior/static/representation.ts

@@ -16,15 +16,6 @@ export function registerDefault(ctx: PluginContext) {
 }
 
 export function SyncRepresentationToCanvas(ctx: PluginContext) {
-    let reprCount = 0;
-
-    ctx.events.canvas3d.initialized.subscribe(() => {
-        ctx.canvas3d?.reprCount.subscribe(v => {
-            if (reprCount === 0) ctx.canvas3d?.requestCameraReset();
-            reprCount = v;
-        });
-    })
-
     const events = ctx.state.dataState.events;
     events.object.created.subscribe(e => {
         if (!SO.isRepresentation3D(e.obj)) return;

+ 1 - 1
src/mol-plugin/state.ts

@@ -79,7 +79,7 @@ class PluginState {
             this.animation.setSnapshot(snapshot.animation);
         }
         if (snapshot.camera) {
-            PluginCommands.Camera.SetSnapshot(this.plugin, {
+            PluginCommands.Camera.Reset(this.plugin, {
                 snapshot: snapshot.camera.current,
                 durationMs: snapshot.camera.transitionStyle === 'animate'
                     ? snapshot.camera.transitionDurationInMs