Skip to content

Commit

Permalink
Add transpose functionality for matrices and improve copy methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yzrmn committed Apr 11, 2024
1 parent 42d11f7 commit 52f6ef1
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 147 deletions.
10 changes: 4 additions & 6 deletions packages/redgeometry-app/src/ecs/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ export function cameraSystem(world: World): void {
continue;
}

const mat = camera.viewProjection;

const computedTransform = world.getComponent<ComputedTransformComponent>(entity, "computed-transform");

if (computedTransform !== undefined) {
const e = computedTransform.global.getInverse().elements;
mat.set(e[0], e[1], e[2], 0, e[3], e[4], e[5], 0, e[6], e[7], e[8], 0, e[9], e[10], e[11], 1);
mat.mulSet(camera.projection, mat);
const matView = computedTransform.global.inverse();
camera.viewProjection.copyFrom(matView);
camera.viewProjection.mulSet(camera.projection, camera.viewProjection);
} else {
mat.copyFrom(camera.projection);
camera.viewProjection.copyFrom(camera.projection);
}
}
}
Loading

0 comments on commit 52f6ef1

Please sign in to comment.