pub struct AssetManager {
pub path_to_uuid: HashMap<String, Uuid>,
pub uuid_to_path: HashMap<Uuid, String>,
pub embedded_assets: HashMap<String, Cow<'static, [u8]>>,
/* private fields */
}Fields§
§path_to_uuid: HashMap<String, Uuid>§uuid_to_path: HashMap<Uuid, String>§embedded_assets: HashMap<String, Cow<'static, [u8]>>Assets whose bytes are baked into the binary (e.g. via include_bytes!).
Implementations§
Source§impl AssetManager
impl AssetManager
Sourcepub fn install_obj_mesh(
&mut self,
device: &Device,
file_path: &str,
vertices: Vec<Vertex>,
_aabb: Aabb,
) -> Mesh
pub fn install_obj_mesh( &mut self, device: &Device, file_path: &str, vertices: Vec<Vertex>, _aabb: Aabb, ) -> Mesh
Upload an already-decoded OBJ vertex buffer to the GPU and cache it.
Called by AsyncAssetLoader
after decoding completes on a worker thread.
Sourcepub fn load_obj(&mut self, device: &Device, file_path_or_uuid: &str) -> Mesh
pub fn load_obj(&mut self, device: &Device, file_path_or_uuid: &str) -> Mesh
Load an OBJ file from disk (or return the cached copy).
Sourcepub fn load_gltf_scene(
&mut self,
device: &Device,
queue: &Queue,
texture_bind_group_layout: &BindGroupLayout,
default_tbind: Arc<BindGroup>,
path_or_uuid: &str,
) -> Result<GltfSceneAsset, String>
pub fn load_gltf_scene( &mut self, device: &Device, queue: &Queue, texture_bind_group_layout: &BindGroupLayout, default_tbind: Arc<BindGroup>, path_or_uuid: &str, ) -> Result<GltfSceneAsset, String>
Load a glTF scene from disk (or embedded data) and upload it to the GPU.
The returned GltfSceneAsset is pure CPU/ECS data; a separate scene
builder is responsible for spawning ECS entities from it.
Sourcepub fn load_gltf_from_import(
&mut self,
device: &Device,
queue: &Queue,
texture_bind_group_layout: &BindGroupLayout,
default_tbind: Arc<BindGroup>,
file_path: &str,
document: Document,
buffers: Vec<Data>,
images: Vec<Data>,
) -> Result<GltfSceneAsset, String>
pub fn load_gltf_from_import( &mut self, device: &Device, queue: &Queue, texture_bind_group_layout: &BindGroupLayout, default_tbind: Arc<BindGroup>, file_path: &str, document: Document, buffers: Vec<Data>, images: Vec<Data>, ) -> Result<GltfSceneAsset, String>
Upload a pre-parsed glTF import to the GPU.
Split from load_gltf_scene so that gltf::import (which is
CPU-bound and blocks) can be called off the main thread while GPU
upload happens here on the main thread.
Source§impl AssetManager
impl AssetManager
Sourcepub fn create_inverted_cube(device: &Device) -> Mesh
pub fn create_inverted_cube(device: &Device) -> Mesh
İçi boş ters yüzlü küp (Skybox) mesh üretir. Normaller içe bakar, böylece kamera küpün merkezinden dışarıya baktığında yüzeyler görünür.
Sourcepub fn create_cube(device: &Device) -> Mesh
pub fn create_cube(device: &Device) -> Mesh
Düzenli Küp mesh üretir (Dışa bakan normaller, PBR ışıklandırma ve gölgelendirme için doğru)
pub fn create_gizmo_arrow(device: &Device) -> Mesh
Sourcepub fn create_plane(device: &Device, size: f32) -> Mesh
pub fn create_plane(device: &Device, size: f32) -> Mesh
Basit, yatay bir düzlem (Plane) üretir.
Sourcepub fn create_circle(device: &Device, radius: f32, segments: u32) -> Mesh
pub fn create_circle(device: &Device, radius: f32, segments: u32) -> Mesh
Yuvarlak bir disk (Çember tabanı) üretir. Bevy’nin Circle::new(radius) karşılığıdır.
Sourcepub fn create_editor_grid_mesh(device: &Device, extents: f32) -> Mesh
pub fn create_editor_grid_mesh(device: &Device, extents: f32) -> Mesh
Editör sahneleri için GPU’da çizilen sonsuz grid mesh (tek bir quad). Shader içinde matematiksel olarak çizilir.
Sourcepub fn create_sprite_quad(device: &Device, width: f32, height: f32) -> Mesh
pub fn create_sprite_quad(device: &Device, width: f32, height: f32) -> Mesh
2D Sprite dörtgeni oluşturur (XY düzleminde, kameraya paralel). Ortografik projeksiyon ile kullanıldığında 2D oyun desteği sağlar.
Sourcepub fn create_sphere(
device: &Device,
radius: f32,
stacks: u32,
slices: u32,
) -> Mesh
pub fn create_sphere( device: &Device, radius: f32, stacks: u32, slices: u32, ) -> Mesh
Programatik UV Küre (Sphere) üretir.
pub fn create_cylinder( device: &Device, radius: f32, height: f32, radial_segments: u32, ) -> Mesh
pub fn create_cone( device: &Device, radius: f32, height: f32, radial_segments: u32, ) -> Mesh
pub fn create_torus( device: &Device, radius: f32, tube_radius: f32, radial_segments: u32, tubular_segments: u32, ) -> Mesh
pub fn create_capsule( device: &Device, radius: f32, depth: f32, latitudes: u32, longitudes: u32, ) -> Mesh
pub fn create_terrain( device: &Device, heightmap_path: &str, width: f32, depth: f32, max_height: f32, ) -> Result<(Mesh, Vec<f32>, u32, u32), String>
Source§impl AssetManager
impl AssetManager
pub fn create_tetrahedron(device: &Device, size: f32) -> Mesh
pub fn create_conical_frustum( device: &Device, radius_bottom: f32, radius_top: f32, height: f32, radial_segments: u32, ) -> Mesh
pub fn create_convex_extrusion( device: &Device, points_2d: &[[f32; 2]], depth: f32, ) -> Mesh
pub fn create_ring_extrusion( device: &Device, inner_points: &[[f32; 2]], outer_points: &[[f32; 2]], depth: f32, ) -> Mesh
Source§impl AssetManager
impl AssetManager
Sourcepub fn install_decoded_material_texture(
&mut self,
device: &Device,
queue: &Queue,
layout: &BindGroupLayout,
cache_key: &str,
rgba: &[u8],
width: u32,
height: u32,
) -> Result<Arc<BindGroup>, String>
pub fn install_decoded_material_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, cache_key: &str, rgba: &[u8], width: u32, height: u32, ) -> Result<Arc<BindGroup>, String>
Upload a single RGBA8 pixel buffer to the GPU, cache the bind group, and return it.
Called by async loaders after decoding completes on a worker thread, and by the procedural texture helpers below.
§Errors
Returns an error when:
widthorheightis zero (wgpu would panic on a zero-sized texture).rgba.len()does not equalwidth * height * 4.
Sourcepub fn load_material_texture(
&mut self,
device: &Device,
queue: &Queue,
layout: &BindGroupLayout,
path_or_uuid: &str,
) -> Result<Arc<BindGroup>, String>
pub fn load_material_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, path_or_uuid: &str, ) -> Result<Arc<BindGroup>, String>
Load a texture from path_or_uuid, uploading it to the GPU on first
access and returning the cached bind group on subsequent calls.
Supports both filesystem paths and UUID strings registered by the asset
scanner. Embedded assets (registered with [AssetManager::embed_asset])
take priority over filesystem reads.
Sourcepub fn reload_material_texture(
&mut self,
device: &Device,
queue: &Queue,
layout: &BindGroupLayout,
path_or_uuid: &str,
) -> Result<Arc<BindGroup>, String>
pub fn reload_material_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, path_or_uuid: &str, ) -> Result<Arc<BindGroup>, String>
Evict path_or_uuid from the texture cache and reload it from disk.
Useful for hot-reload workflows where an asset file changes at runtime.
Sourcepub fn create_white_texture(
&mut self,
device: &Device,
queue: &Queue,
layout: &BindGroupLayout,
) -> Arc<BindGroup>
pub fn create_white_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, ) -> Arc<BindGroup>
Return (creating once) a 1×1 opaque-white texture.
Used as the default albedo map for materials that specify no texture.
Sourcepub fn create_checkerboard_texture(
&mut self,
device: &Device,
queue: &Queue,
layout: &BindGroupLayout,
) -> Arc<BindGroup>
pub fn create_checkerboard_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, ) -> Arc<BindGroup>
Return (creating once) a 256×256 grey checkerboard texture.
Used for geometry whose material has no texture assigned — makes UVs immediately visible in the editor.
pub fn create_uv_debug_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, ) -> Arc<BindGroup>
Source§impl AssetManager
impl AssetManager
pub fn new() -> AssetManager
Sourcepub fn garbage_collect(&mut self) -> usize
pub fn garbage_collect(&mut self) -> usize
Serbest bırakılmış GPU kaynaklarını (mesh/texture) cache’ten siler. Sadece referans sayısı 1’e düşmüş (yani ECS’te kullanılmayan ve sadece AssetManager’ın bildiği) varlıklar silinir.
Sourcepub fn normalize_path(path: &str) -> String
pub fn normalize_path(path: &str) -> String
Normalise a file-system path to forward-slash form for use as a map key.
Uses Path to avoid platform-specific separator assumptions.
Sourcepub fn get_uuid(&self, path: &str) -> Option<Uuid>
pub fn get_uuid(&self, path: &str) -> Option<Uuid>
Return the UUID registered for path, if any.
Sourcepub fn get_path(&self, uuid: &Uuid) -> Option<String>
pub fn get_path(&self, uuid: &Uuid) -> Option<String>
Return the filesystem path registered for uuid, if any.
Sourcepub fn resolve_path_from_meta_source(
&self,
source: &str,
) -> Result<String, String>
pub fn resolve_path_from_meta_source( &self, source: &str, ) -> Result<String, String>
Resolve a load source to a filesystem path.
If source parses as a UUID, the registered path is returned.
Otherwise source is normalised and returned as-is.
Sourcepub fn get_cached_mesh(&self, source_id: &str) -> Option<Mesh>
pub fn get_cached_mesh(&self, source_id: &str) -> Option<Mesh>
Return a cached mesh by its source ID without triggering a load.
Sourcepub fn embed_asset(&mut self, path: &str, data: impl Into<Cow<'static, [u8]>>)
pub fn embed_asset(&mut self, path: &str, data: impl Into<Cow<'static, [u8]>>)
Embed a raw asset byte slice under path so it can be loaded without
a filesystem read.
Sourcepub fn scan_assets_directory(&mut self, dir: &Path)
pub fn scan_assets_directory(&mut self, dir: &Path)
Recursively scan dir for known asset extensions, creating or
reading .meta sidecar files to assign stable UUIDs.
Safe to call multiple times — existing entries are updated, not duplicated.
Sourcepub fn loading_placeholder_mesh(&mut self, device: &Device) -> Mesh
pub fn loading_placeholder_mesh(&mut self, device: &Device) -> Mesh
Return (creating if needed) a small magenta octahedron used as a stand-in while an async asset load is in flight.
Trait Implementations§
Source§impl Default for AssetManager
impl Default for AssetManager
Source§fn default() -> AssetManager
fn default() -> AssetManager
Auto Trait Implementations§
impl Freeze for AssetManager
impl !RefUnwindSafe for AssetManager
impl Send for AssetManager
impl Sync for AssetManager
impl Unpin for AssetManager
impl UnsafeUnpin for AssetManager
impl !UnwindSafe for AssetManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().