Skip to main content

AssetManager

Struct AssetManager 

Source
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

Source

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.

Source

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).

Source

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.

Source

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

Source

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.

Source

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)

Source

pub fn create_gizmo_arrow(device: &Device) -> Mesh

Source

pub fn create_plane(device: &Device, size: f32) -> Mesh

Basit, yatay bir düzlem (Plane) üretir.

Source

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.

Source

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.

Source

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.

Source

pub fn create_sphere( device: &Device, radius: f32, stacks: u32, slices: u32, ) -> Mesh

Programatik UV Küre (Sphere) üretir.

Source

pub fn create_cylinder( device: &Device, radius: f32, height: f32, radial_segments: u32, ) -> Mesh

Source

pub fn create_cone( device: &Device, radius: f32, height: f32, radial_segments: u32, ) -> Mesh

Source

pub fn create_torus( device: &Device, radius: f32, tube_radius: f32, radial_segments: u32, tubular_segments: u32, ) -> Mesh

Source

pub fn create_capsule( device: &Device, radius: f32, depth: f32, latitudes: u32, longitudes: u32, ) -> Mesh

Source

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

Source

pub fn create_tetrahedron(device: &Device, size: f32) -> Mesh

Source

pub fn create_conical_frustum( device: &Device, radius_bottom: f32, radius_top: f32, height: f32, radial_segments: u32, ) -> Mesh

Source

pub fn create_convex_extrusion( device: &Device, points_2d: &[[f32; 2]], depth: f32, ) -> Mesh

Source

pub fn create_ring_extrusion( device: &Device, inner_points: &[[f32; 2]], outer_points: &[[f32; 2]], depth: f32, ) -> Mesh

Source§

impl AssetManager

Source

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:

  • width or height is zero (wgpu would panic on a zero-sized texture).
  • rgba.len() does not equal width * height * 4.
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn create_uv_debug_texture( &mut self, device: &Device, queue: &Queue, layout: &BindGroupLayout, ) -> Arc<BindGroup>

Source§

impl AssetManager

Source

pub fn new() -> AssetManager

Source

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.

Source

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.

Source

pub fn get_uuid(&self, path: &str) -> Option<Uuid>

Return the UUID registered for path, if any.

Source

pub fn get_path(&self, uuid: &Uuid) -> Option<String>

Return the filesystem path registered for uuid, if any.

Source

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.

Source

pub fn get_cached_mesh(&self, source_id: &str) -> Option<Mesh>

Return a cached mesh by its source ID without triggering a load.

Source

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.

Source

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.

Source

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

Source§

fn default() -> AssetManager

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,