fix texture atlas image creation

This commit is contained in:
Elias Stepanik 2025-06-14 00:54:01 +02:00
parent 440fd4a717
commit 430a933e8b

View File

@ -1,3 +1,4 @@
use bevy::asset::RenderAssetUsages;
use bevy::prelude::*;
use bevy::render::texture::{Extent3d, TextureDimension, TextureFormat};
@ -37,13 +38,22 @@ impl VoxelTextureAtlas {
}
}
let image = Image::new_fill(
Extent3d { width, height, depth_or_array_layers: 1 },
Extent3d {
width,
height,
depth_or_array_layers: 1,
},
TextureDimension::D2,
&data,
TextureFormat::Rgba8UnormSrgb,
RenderAssetUsages::default(),
);
let handle = images.add(image);
Self { handle, columns, rows }
Self {
handle,
columns,
rows,
}
}
/// Compute UV coordinates for the given atlas index.
@ -56,11 +66,6 @@ impl VoxelTextureAtlas {
let v0 = row as f32 / rows;
let u1 = (col + 1) as f32 / cols;
let v1 = (row + 1) as f32 / rows;
[
[u0, v1],
[u1, v1],
[u1, v0],
[u0, v0],
]
[[u0, v1], [u1, v1], [u1, v0], [u0, v0]]
}
}