Skip to content

Commit

Permalink
fix: render Minecraft skin texture in 3d correctly (#136)
Browse files Browse the repository at this point in the history
All textures were rendered flipped on the X axis.
This is especially noticeable if a logo or text is present and mirrored.

closes #136

Co-authored-by: Katharina Heidenreich <katharina.heidenreich02@gmail.com>
  • Loading branch information
SpraxDev and NudelErde committed Aug 29, 2024
1 parent 3c76c5e commit 5f15374
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/minecraft/skin/renderer/legacy-3d/modelRender.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from 'node:fs';
import Gl from 'gl';
import { readFileSync } from 'node:fs';

const gl = Gl(64, 64, {preserveDrawingBuffer: true});

Expand Down Expand Up @@ -312,12 +312,14 @@ export class Camera {
0, 0, 1, 0,
this.postPosition.x, this.postPosition.y, 0, 1
];
const mvpMatrix = multiplyMatrices(scale,
multiplyMatrices(postTranslate,
multiplyMatrices(projection,
multiplyMatrices(rotateZ,
multiplyMatrices(rotateX,
multiplyMatrices(rotateY, translate))))));
const flipX = [
-1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
];

const mvpMatrix = [scale, postTranslate, projection, rotateZ, rotateX, rotateY, translate, flipX].reduce((acc, cur) => multiplyMatrices(acc, cur));
return new Float32Array(mvpMatrix);
}

Expand Down

0 comments on commit 5f15374

Please sign in to comment.