Commit 13d9fa49 authored by yannick legoc's avatar yannick legoc
Browse files

Do not zoom when changing the displayed root component

parent eb0e89f4
......@@ -421,7 +421,7 @@ public class Nomad3DEditor extends Application {
buildEventHandlers(axesGroup);
// Initialize the camera position
resetCamera(this.model.getRoot());
resetCamera(this.model.getRoot(), true);
return scene;
}
......@@ -430,12 +430,16 @@ public class Nomad3DEditor extends Application {
* Sets the camera center and zoom according to the component.
* @param component
*/
private void resetCamera(Component component) {
private void resetCamera(Component component, boolean init) {
Bounds rootBounds = component.getSceneNode().localToScene(component.getSceneNode().getBoundsInLocal());
Point3D rootCenter = new Point3D(rootBounds.getMinX(), rootBounds.getMinY(), rootBounds.getMinZ());
rootCenter = rootCenter.add(rootBounds.getWidth() / 2.0, rootBounds.getHeight() / 2.0, rootBounds.getDepth() / 2.0);
this.controls.setCenter(rootCenter);
this.controls.zoom(-1.0 * ((new Point3D(rootBounds.getWidth(), rootBounds.getHeight(), rootBounds.getDepth())).magnitude()), false, false);
// Zoom only for the first time.
if (init) {
this.controls.zoom(-1.0 * ((new Point3D(rootBounds.getWidth(), rootBounds.getHeight(), rootBounds.getDepth())).magnitude()), false, false);
}
}
/**
......@@ -686,7 +690,7 @@ public class Nomad3DEditor extends Application {
menuBar.setDisplayedRootComponent(component);
// Change the center of the camera.
resetCamera(component);
resetCamera(component, false);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment