Skip to content

Commit

Permalink
fix uv morph y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
noname0310 committed Mar 18, 2024
1 parent e59793c commit e184286
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- support Babylon.js 6.46.0

- add missing uv morph y axis inversion

## 0.37.2

- wasm runtime stabilization
Expand Down
2 changes: 1 addition & 1 deletion docs/static/pmx_converter/main.bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Loader/pmLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ export abstract class PmLoader extends MmdModelLoader<PmLoadState, PmxObject, Pm

const elementIndex = indexToSubMeshIndexMap[morphIndices[j]];
uvs[elementIndex * 2 + 0] += uvOffsets[j * 4 + 0];
uvs[elementIndex * 2 + 1] += uvOffsets[j * 4 + 1];
uvs[elementIndex * 2 + 1] -= uvOffsets[j * 4 + 1]; // flip y axis
indexCount += 1;
}

Expand All @@ -719,7 +719,7 @@ export abstract class PmLoader extends MmdModelLoader<PmLoadState, PmxObject, Pm
const elementIndex = indexToSubMeshIndexMap[morphIndices[j]];
indices[k] = elementIndex;
offsets[k * 4 + 0] = uvOffsets[j * 4 + 0];
offsets[k * 4 + 1] = uvOffsets[j * 4 + 1];
offsets[k * 4 + 1] = -uvOffsets[j * 4 + 1]; // flip y axis
offsets[k * 4 + 2] = uvOffsets[j * 4 + 2];
offsets[k * 4 + 3] = uvOffsets[j * 4 + 3];
k += 1;
Expand All @@ -735,7 +735,7 @@ export abstract class PmLoader extends MmdModelLoader<PmLoadState, PmxObject, Pm

const elementIndex = indexToSubMeshIndexMap[morphIndices[j]];
uvs[elementIndex * 2 + 0] += uvOffsets[j * 4 + 0];
uvs[elementIndex * 2 + 1] += uvOffsets[j * 4 + 1];
uvs[elementIndex * 2 + 1] -= uvOffsets[j * 4 + 1]; // flip y axis
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Test/Scene/shadingTestScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export class SceneBuilder implements ISceneBuilder {
createDefaultGround(scene);
const mmdMesh = await SceneLoader.ImportMeshAsync(
undefined,
"res/private_test/model/Sour式初音ミクVer.1.02/",
"Black.pmx",
"res/private_test/model/YYB Delta_M Miku_2.1/",
"delta_M2.0.pmx",
scene
).then(result => result.meshes[0]) as Mesh;
shadowGenerator.addShadowCaster(mmdMesh);
Expand Down

0 comments on commit e184286

Please sign in to comment.