Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing code in deferredRendering #327

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/sample/deferredRendering/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,6 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
2000.0
);

const viewMatrix = mat4.inverse(mat4.lookAt(eyePosition, origin, upVector));

const viewProjMatrix = mat4.multiply(projectionMatrix, viewMatrix);

// Move the model so it's centered.
const modelMatrix = mat4.translation([0, -45, 0]);

Expand All @@ -515,17 +511,13 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {

// Rotates the camera around the origin based on time.
function getCameraViewProjMatrix() {
const eyePosition = vec3.fromValues(0, 50, -100);

const rad = Math.PI * (Date.now() / 5000);
const rotation = mat4.rotateY(mat4.translation(origin), rad);
vec3.transformMat4(eyePosition, rotation, eyePosition);
const rotatedEyePosition = vec3.transformMat4(eyePosition, rotation);

const viewMatrix = mat4.lookAt(rotatedEyePosition, origin, upVector);

mat4.multiply(projectionMatrix, viewMatrix, viewProjMatrix);
return viewProjMatrix as Float32Array;
return mat4.multiply(projectionMatrix, viewMatrix) as Float32Array;
}

function frame() {
Expand Down
Loading