Skip to content

Commit 5d5fb3b

Browse files
committed
Updadte look at
1 parent 1220e4a commit 5d5fb3b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/NeuralGraphicsGL.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,18 @@ const SVec4f0 = SVector{4, Float32}
8585
const SMat3f0 = SMatrix{3, 3, Float32}
8686
const SMat4f0 = SMatrix{4, 4, Float32}
8787

88-
function look_at(position, target, up)
89-
Z = normalize(position - target)
90-
X = normalize(normalize(up) × Z)
91-
Y = Z × X
88+
function look_at(position, target, up; left_handed::Bool = true)
89+
Z = left_handed ? # front
90+
normalize(position - target) :
91+
normalize(target - position)
92+
X = normalize(normalize(up) × Z) # right
93+
Y = Z × X # up
9294

9395
SMatrix{4, 4, Float32, 16}(
9496
X[1], Y[1], Z[1], 0f0,
9597
X[2], Y[2], Z[2], 0f0,
9698
X[3], Y[3], Z[3], 0f0,
97-
X -position, Y -position, Z -position, 1f0)
99+
-(X position), -(Y position), -(Z position), 1f0)
98100
end
99101

100102
function _frustum(left, right, bottom, top, znear, zfar; zsign::Float32 = -1f0)

0 commit comments

Comments
 (0)