Skip to content

Commit

Permalink
fix demo texture uv
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsjo committed Apr 22, 2024
1 parent aae0448 commit 96b49ac
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions demo/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ Promise.all([
const atlasCtx = atlasCanvas.getContext('2d')!
atlasCtx.drawImage(atlas, 0, 0)
const atlasData = atlasCtx.getImageData(0, 0, atlasSize, atlasSize)
const part = 16 / atlasData.width
const idMap = {}
Object.keys(uvMap).forEach(id => {
const u = uvMap[id][0] / atlasSize
const v = uvMap[id][1] / atlasSize
idMap['minecraft:' + id] = [u, v, u + part, v + part]
const [u, v, du, dv] = uvMap[id]
const dv2 = (du !== dv && id.startsWith('block/')) ? du : dv
idMap[Identifier.create(id).toString()] = [u / atlasSize, v / atlasSize, (u + du) / atlasSize, (v + dv2) / atlasSize]
})
const textureAtlas = new TextureAtlas(atlasData, idMap)

Expand Down

0 comments on commit 96b49ac

Please sign in to comment.