diff options
-rw-r--r-- | starling/node-2d.scm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm index 6fd80ba..095c5ca 100644 --- a/starling/node-2d.scm +++ b/starling/node-2d.scm @@ -155,19 +155,19 @@ ;; This method can be overridden by subclasses to create custom camera ;; movement. (define-method (follow-target (camera <camera-2d>)) - (let ((p (position camera))) - (set-vec2! p 0.0 0.0) - (transform! (world-matrix (target camera)) p) + (let ((p (position camera)) + (m (view-matrix camera)) + (w (world-matrix (target camera)))) + (set-vec2! p (matrix4-x w) (matrix4-y w)) (vec2-mult! p -1.0) - (vec2-add! p (offset camera)))) + (vec2-add! p (offset camera)) + (matrix4-translate! m (position camera)) + (matrix4-mult! m m (projection-matrix camera)))) (define-syntax-rule (with-camera camera body ...) (begin (when (target camera) - (follow-target camera) - (let ((m (view-matrix camera))) - (matrix4-translate! m (position camera)) - (matrix4-mult! m m (projection-matrix camera)))) + (follow-target camera)) (with-viewport (viewport camera) (with-projection (if (target camera) (view-matrix camera) |