Skip to content
Snippets Groups Projects
Commit 0b1e6100 authored by David Sehnal's avatar David Sehnal
Browse files

mol-canvas-3d: fix camera transition when adding new representations

parent 2168905c
Branches
No related tags found
No related merge requests found
......@@ -25,24 +25,30 @@ class CameraTransitionManager {
get target(): Readonly<Camera.Snapshot> { return this._target }
apply(to: Partial<Camera.Snapshot>, durationMs: number = 0, transition?: CameraTransitionManager.TransitionFunc) {
if (!this.inTransition) {
Camera.copySnapshot(this._source, this.camera.state);
Camera.copySnapshot(this._target, this.camera.state);
}
Camera.copySnapshot(this._target, to);
if (this._target.radius > this._target.radiusMax) {
this._target.radius = this._target.radiusMax
}
if (durationMs <= 0 || (typeof to.mode !== 'undefined' && to.mode !== this.camera.state.mode)) {
if (!this.inTransition && durationMs <= 0 || (typeof to.mode !== 'undefined' && to.mode !== this.camera.state.mode)) {
this.finish(this._target);
return;
}
this.inTransition = true;
this.func = transition || CameraTransitionManager.defaultTransition;
if (!this.inTransition || durationMs > 0) {
this.start = this.t;
this.durationMs = durationMs;
}
}
tick(t: number) {
this.t = t;
......
......@@ -323,6 +323,8 @@ namespace Canvas3D {
function shouldResetCamera() {
if (camera.state.radiusMax === 0) return true;
if (camera.transition.inTransition || nextCameraResetSnapshot) return false;
let cameraSphereOverlapsNone = true
Sphere3D.set(cameraSphere, camera.state.target, camera.state.radius)
......@@ -356,7 +358,7 @@ namespace Canvas3D {
}
if (oldBoundingSphereVisible.radius === 0) nextCameraResetDuration = 0;
camera.setState({ radiusMax: scene.boundingSphere.radius })
camera.setState({ radiusMax: scene.boundingSphere.radius }, 0)
reprCount.next(reprRenderObjects.size);
return true;
......
......@@ -141,8 +141,7 @@ export class StructureFocusRepresentationBehavior extends PluginBehavior.WithSub
await PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
// TODO make work with durationMs > 0
this.plugin.managers.camera.focusLoci(loci)
this.plugin.managers.camera.focusLoci(loci);
}
register(ref: string): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment