summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2022-10-13 10:09:24 -0400
committerMicha White <botahamec@outlook.com>2022-10-13 10:09:24 -0400
commit121dc57f0962f27ab9e5da2ec05d3a1b1d97cdb2 (patch)
treea38d541ec8f7c8c23e0324b54d18ffbfa664d762
parent0cb5bb79987ee60c49271e2905380500c75e762f (diff)
Rotate instances in the clockwise direction
-rw-r--r--shaders/sprite.wgsl3
-rw-r--r--src/camera.rs1
2 files changed, 2 insertions, 2 deletions
diff --git a/shaders/sprite.wgsl b/shaders/sprite.wgsl
index 5a00e24..43f494e 100644
--- a/shaders/sprite.wgsl
+++ b/shaders/sprite.wgsl
@@ -27,7 +27,8 @@ fn vs_main(model: VertexInput, instance: InstanceInput) -> VertexOutput {
var out: VertexOutput;
// rotate the sprite
- let a = vec2<f32>(cos(instance.rotation), sin(instance.rotation));
+ let rotation = -instance.rotation;
+ let a = vec2<f32>(cos(rotation), sin(rotation));
let b = vec2<f32>(-a[1], a[0]);
let rotation = mat2x2<f32>(a, b);
let rotated = rotation * model.position;
diff --git a/src/camera.rs b/src/camera.rs
index fb46158..edc3405 100644
--- a/src/camera.rs
+++ b/src/camera.rs
@@ -151,7 +151,6 @@ impl Camera {
#[allow(clippy::wrong_self_convention)]
fn to_matrix(&self) -> CameraUniform {
- // TODO why do the camera and instances rotate in different directions?
let cos = self.rotation.cos();
let sin = self.rotation.sin();