Skip to content

Commit

Permalink
tweak the camera
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Dec 27, 2024
1 parent eac5c36 commit 1852ff1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions webgpu/lessons/webgpu-scene-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ And let's tweak the camera code
+ const cameraMatrix = mat4.identity();
+ mat4.translate(cameraMatrix, [120, 100, 0], cameraMatrix);
+ mat4.rotateY(cameraMatrix, settings.cameraRotation, cameraMatrix);
+ mat4.translate(cameraMatrix, [0, 0, 300], cameraMatrix);
+ mat4.translate(cameraMatrix, [60, 0, 300], cameraMatrix);
+
+ // Compute a view matrix
+ const viewMatrix = mat4.inverse(cameraMatrix);
Expand Down Expand Up @@ -935,9 +935,10 @@ Finally, ket's adjust the camera slightly.
// Compute a camera matrix.
const cameraMatrix = mat4.identity();
- mat4.translate(cameraMatrix, [120, 100, 0], cameraMatrix);
+ mat4.translate(cameraMatrix, [40, 100, 0], cameraMatrix);
+ mat4.translate(cameraMatrix, [100, 100, 0], cameraMatrix);
mat4.rotateY(cameraMatrix, settings.cameraRotation, cameraMatrix);
mat4.translate(cameraMatrix, [0, 0, 300], cameraMatrix);
- mat4.translate(cameraMatrix, [60, 0, 300], cameraMatrix);
+ mat4.translate(cameraMatrix, [100, 0, 300], cameraMatrix);
```
{{{example url="../webgpu-scene-graphs-hand.html"}}}
Expand Down
2 changes: 1 addition & 1 deletion webgpu/webgpu-scene-graphs-file-cabinets-w-animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@
const cameraMatrix = mat4.identity();
mat4.translate(cameraMatrix, [120, 100, 0], cameraMatrix);
mat4.rotateY(cameraMatrix, settings.cameraRotation, cameraMatrix);
mat4.translate(cameraMatrix, [0, 0, 300], cameraMatrix);
mat4.translate(cameraMatrix, [60, 0, 300], cameraMatrix);

// Compute a view matrix
const viewMatrix = mat4.inverse(cameraMatrix);
Expand Down
2 changes: 1 addition & 1 deletion webgpu/webgpu-scene-graphs-file-cabinets-w-gui.html
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@
const cameraMatrix = mat4.identity();
mat4.translate(cameraMatrix, [120, 100, 0], cameraMatrix);
mat4.rotateY(cameraMatrix, settings.cameraRotation, cameraMatrix);
mat4.translate(cameraMatrix, [0, 0, 300], cameraMatrix);
mat4.translate(cameraMatrix, [60, 0, 300], cameraMatrix);

// Compute a view matrix
const viewMatrix = mat4.inverse(cameraMatrix);
Expand Down
4 changes: 2 additions & 2 deletions webgpu/webgpu-scene-graphs-hand-shoot.html
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,9 @@

// Compute a camera matrix.
const cameraMatrix = mat4.identity();
mat4.translate(cameraMatrix, [40, 100, 0], cameraMatrix);
mat4.translate(cameraMatrix, [0, 100, 0], cameraMatrix);
mat4.rotateY(cameraMatrix, settings.cameraRotation, cameraMatrix);
mat4.translate(cameraMatrix, [0, 0, 300], cameraMatrix);
mat4.translate(cameraMatrix, [100, 0, 300], cameraMatrix);

// Compute a view matrix
const viewMatrix = mat4.inverse(cameraMatrix);
Expand Down
4 changes: 2 additions & 2 deletions webgpu/webgpu-scene-graphs-hand.html
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@

// Compute a camera matrix.
const cameraMatrix = mat4.identity();
mat4.translate(cameraMatrix, [40, 100, 0], cameraMatrix);
mat4.translate(cameraMatrix, [0, 100, 0], cameraMatrix);
mat4.rotateY(cameraMatrix, settings.cameraRotation, cameraMatrix);
mat4.translate(cameraMatrix, [0, 0, 300], cameraMatrix);
mat4.translate(cameraMatrix, [100, 0, 300], cameraMatrix);

// Compute a view matrix
const viewMatrix = mat4.inverse(cameraMatrix);
Expand Down

0 comments on commit 1852ff1

Please sign in to comment.