Skip to content

Commit

Permalink
Allow user to spin camera a little further before hitting limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Retera committed Jan 6, 2023
1 parent d72f7d7 commit 919ba35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public abstract class CameraManager {
protected Vector3f position;
public Vector3f target;
protected Vector3f worldUp;
protected Vector3f worldDown;
protected Vector3f vecHeap;
protected Vector4f vec4Heap;
protected Quaternion quatHeap;
Expand All @@ -51,6 +52,7 @@ public void setupCamera(final ViewerCamera camera/* final Scene scene */) {
this.position = new Vector3f();
this.target = new Vector3f(0, 0, 0);
this.worldUp = new Vector3f(0, 0, 1);
this.worldDown = new Vector3f(0, 0, -1);
this.vecHeap = new Vector3f();
this.vec4Heap = new Vector4f();
this.quatHeap = new Quaternion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ public void updateCamera() {
}
this.camera.perspective(fieldOfView, this.camera.getAspect(), nearClip, farClip);

this.camera.moveToAndFace(this.position, this.target, this.worldUp);
this.camera.moveToAndFace(this.position, this.target,
(this.horizontalAngle < 0) || (this.horizontalAngle > Math.PI) ? this.worldDown : this.worldUp);
}

public void setModelInstance(final RenderModel modelInstance, final Camera camera) {
this.modelInstance = modelInstance;
if (modelInstance == null) {
this.modelCamera = null;
reset();
} else if (camera != null) {
}
else if (camera != null) {
this.modelCamera = camera;
fieldOfView = (float) this.modelCamera.getFieldOfView() * 0.75f;
nearClip = (float) this.modelCamera.getNearClip();
Expand Down

0 comments on commit 919ba35

Please sign in to comment.