Allow for textures that aren't 16x16
This commit is contained in:
@@ -396,13 +396,15 @@ function push_quad(
|
||||
buffer.count += 1;
|
||||
}
|
||||
|
||||
// pixels of a sprite to atlas coordinates, kept off the sprite's edge
|
||||
// model uvs (0 to TEXTURE_SIZE across the sprite, whatever its size) to atlas coordinates, kept off the sprite's edge
|
||||
function atlas_u(sprite: SpriteRegion, u: number) {
|
||||
return (sprite.x * TEXTURE_SIZE + Math.min(Math.max(u, UV_PAD), TEXTURE_SIZE - UV_PAD)) / image.width;
|
||||
const px = u * sprite.width / TEXTURE_SIZE;
|
||||
return (sprite.x + Math.min(Math.max(px, UV_PAD), sprite.width - UV_PAD)) / image.width;
|
||||
}
|
||||
|
||||
function atlas_v(sprite: SpriteRegion, v: number) {
|
||||
return (sprite.y * TEXTURE_SIZE + Math.min(Math.max(v, UV_PAD), TEXTURE_SIZE - UV_PAD)) / image.height;
|
||||
const px = v * sprite.height / TEXTURE_SIZE;
|
||||
return (sprite.y + Math.min(Math.max(px, UV_PAD), sprite.height - UV_PAD)) / image.height;
|
||||
}
|
||||
|
||||
// the model quads for a block value, baked the first time it's seen
|
||||
|
||||
Reference in New Issue
Block a user