Skip to content

Commit e0ac064

Browse files
committed
Disable orthographic menu if fov is set to any value
1 parent a5ba02c commit e0ac064

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

Viewer/Camera.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ extension Camera {
7474
settings?.hasScale ?? false
7575
}
7676

77-
var fov: Angle {
78-
settings?.fov ?? .degrees(60)
77+
var fov: Angle? {
78+
settings?.fov
7979
}
8080

81-
var isOrthographic: Bool {
82-
fov <= .zero
81+
var isOrthographic: Bool? {
82+
fov.map { $0 <= .zero }
8383
}
8484

8585
private var settings: ShapeScript.Camera? {

Viewer/Document.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ class Document: NSDocument, EvaluationDelegate {
480480
case #selector(showAxes(_:)):
481481
menuItem.state = showAxes ? .on : .off
482482
case #selector(setOrthographic(_:)):
483-
menuItem.state = camera.isOrthographic || isOrthographic ? .on : .off
484-
return camera.fov > .zero
483+
menuItem.state = camera.isOrthographic ?? isOrthographic ? .on : .off
484+
return camera.isOrthographic == nil
485485
case #selector(selectCamera(_:)) where menuItem.tag < cameras.count:
486486
menuItem.state = (camera == cameras[menuItem.tag]) ? .on : .off
487487
case #selector(selectCameras(_:)):

Viewer/SceneViewController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SceneViewController: NSViewController {
3030
cameraNode.position = SCNVector3(0, 0, 1)
3131
cameraNode.camera?.zNear = 0.01
3232
cameraNode.camera?.automaticallyAdjustsZRange = true
33-
cameraNode.camera?.usesOrthographicProjection = camera.isOrthographic || isOrthographic
33+
cameraNode.camera?.usesOrthographicProjection = camera.isOrthographic ?? isOrthographic
3434
cameraNode.eulerAngles = SCNVector3(0, 0, 0)
3535
return cameraNode
3636
}()
@@ -148,7 +148,8 @@ class SceneViewController: NSViewController {
148148
guard isOrthographic != oldValue else {
149149
return
150150
}
151-
cameraNode.camera?.usesOrthographicProjection = camera.isOrthographic || isOrthographic
151+
cameraNode.camera?.usesOrthographicProjection =
152+
camera.isOrthographic ?? isOrthographic
152153
resetCamera(nil)
153154
}
154155
}
@@ -321,8 +322,8 @@ class SceneViewController: NSViewController {
321322
if !camera.hasOrientation {
322323
cameraNode.look(at: SCNVector3(viewCenter))
323324
}
324-
cameraNode.camera?.fieldOfView = camera.fov.degrees
325-
cameraNode.camera?.usesOrthographicProjection = camera.isOrthographic || isOrthographic
325+
cameraNode.camera?.fieldOfView = CGFloat(camera.fov?.degrees ?? 60)
326+
cameraNode.camera?.usesOrthographicProjection = camera.isOrthographic ?? isOrthographic
326327
resetCamera(nil)
327328
}
328329

0 commit comments

Comments
 (0)