vanilladocs
vanillapunch.com
API / resource/assetloader

resource/assetloader

애셋 함께 받기. (원본 resource/assetloader.js)

  • 그림, JSON, 글, 바이너리, 소리, 글꼴을 목록에 넣고 동시에 받는 수(set_concurrency)만큼씩 받는다. 실패한 것도 끝난 것으로 쳐서 멈추지 않는다.
  • 원본은 await load() 로 기다린다. 러스트 판도 load(engine) 가 원본처럼 await 할 수 있는 손잡이(AssetLoaderLoadHandle)를 돌려주고, await 하면 다 받을 때까지 기다려 실패 목록이 나온다. (기다리는 동안 프레임마다 update 를 불러 준다, wait_for_load().await 도 같다) await 없이 쓰는 꼴은 엔진의 "요청 → 나중에 다 읽힘" 꼴을 따른다: add_image 같은 함수가 아직 비어 있는 읽기 손잡이를 단 애셋을 바로 돌려주고, load(engine) 가 첫 몫을 요청한다. 그 뒤로는 update(engine) 를 프레임마다 불러야 앞의 것이 끝난 만큼 다음 것을 요청한다. (데스크탑은 그 자리에서 읽혀 load 에서 다 끝난다) 씬은 get_completion_handle() 을 scene_base.track_load_handle 로 맡겨 다 받을 때까지 initialize 를 미룬다. GameSceneBase 는 track_asset_loader 하나로 맡기고, draw_on_load 가 update 를 부르고 진행률을 로딩 화면에 넘긴다.
  • 손잡이를 나눠 드는 값싼 복제 꼴이다. (Clone 하면 같은 목록을 가리킨다)
  • 진행률은 끝난 수 / 전체 수. 실패는 get_failed_list() 에 AssetLoadFailure 로 남는다. 바뀌면 set_progress_handler, 다 끝나면 set_complete_handler 의 함수를 부른다.
  • 원본과 다른 점: 글꼴은 FontAsset 대신 읽기 손잡이를 돌려준다. (러스트 판 글꼴은 엔진이 이름으로 등록하고, FontAsset 은 손잡이를 든 껍데기라서) 원본 descriptors(굵기, 기울기, 글자 범위)는 FontFaceDescriptors 로 받아 엔진의 register_font_face_when_loaded 에 넘긴다. (없으면 FontFaceDescriptors::new()) JSON 은 원본처럼 받은 뒤 풀지 못하면 실패다. (원본 isLoaded() 가 거짓이면 실패) 소리는 Rc<AudioAsset> 을 돌려주고, 바이트를 받은 뒤 디코딩까지 끝나야 끝난 것으로 친다. 원본 addTask(직접 만든 받기) 자리는 add_load_handle 이다. 직접 요청한 읽기 손잡이를 넣으면 진행률에 같이 센다. 원본 일꾼이 addTask 를 집어 끝날 때까지 한 자리를 쓰듯, 끝나기 전까지 받는 중인 수(get_in_flight_count)와 동시 수에 든다. 손잡이는 넣기 전에 이미 요청된 것이라 원본처럼 차례가 올 때까지 미루지는 못하고, 넣은 때부터 받는 중이다. 받는 중인 수는 원본처럼 집어 받기 시작했고 아직 끝나지 않은 것이다. (그림은 풀어 보기까지, 소리는 디코딩까지. 원본 일꾼이 그것까지 기다린다) 동시 수도 이것으로 센다. 그림은 원본 img.onload 처럼 다 받았을 때 풀어 본다. 풀지 못하는 것(깨진 PNG)은 실패 목록에 들고, 푼 그림은 손잡이에 담아 ImageAsset 이 다시 풀지 않는다. 받는 동안 더한 것은 원본처럼 빈 자리만큼 함께 받는다. (원본은 넣을 때 일꾼을 더 띄우고, 러스트 판은 update 마다 빈 자리를 채운다)

Loads assets together. (the original resource/assetloader.js)

  • Puts images, JSON, text, binaries, sounds and fonts in a list and receives them as many at a time as the concurrency (set_concurrency). Failed ones also count as finished, so it does not stall.
  • The original waits with await load(). In the Rust version too, load(engine) returns a handle (AssetLoaderLoadHandle) that can be awaited as in the original, and awaiting it waits until everything arrives and yields the failure list. (calls update every frame while waiting, wait_for_load().await is the same) Usage without await follows the engine's "request → fully read later" pattern: Functions like add_image return an asset with a still-empty load handle right away, and load(engine) requests the first batch. After that, update(engine) must be called every frame to request the next ones as earlier ones finish. (on desktop they are read on the spot and all finish in load) A scene hands get_completion_handle() to scene_base.track_load_handle to defer initialize until everything arrives. GameSceneBase hands it off with a single track_asset_loader, and draw_on_load calls update and passes the progress to the loading screen.
  • A cheap-clone form that shares handles. (cloning points to the same list)
  • Progress is finished count / total count. Failures stay in get_failed_list() as AssetLoadFailure. Calls the set_progress_handler function on change and the set_complete_handler function when all finish.
  • Differences from the original: Fonts return a load handle instead of a FontAsset. (fonts in the Rust version are registered by name by the engine, and FontAsset is a shell holding a handle) The original descriptors (weight, style, character range) are taken as FontFaceDescriptors and passed to the engine's register_font_face_when_loaded. (FontFaceDescriptors::new() if none) JSON is a failure if it cannot be parsed after receiving, as in the original. (a failure if the original isLoaded() is false) Sounds return Rc<AudioAsset>, and count as finished only once decoding finishes after the bytes arrive. The original addTask (a hand-made fetch) corresponds to add_load_handle. A load handle requested directly and added is counted in the progress too. Just as an original worker picks up an addTask and uses one slot until it finishes, it counts toward the in-flight count (get_in_flight_count) and concurrency until it finishes. The handle was already requested before being added, so it cannot be deferred until its turn as in the original, and it is in flight from when it is added. The in-flight count is, as in the original, those picked up and started but not yet finished. (images until decoded, sounds until decoded. The original worker waits for that too) Concurrency is counted with this too. Images are decoded once fully received, like the original img.onload. Ones that cannot be decoded (broken PNG) go into the failure list, and decoded images are kept on the handle so ImageAsset does not decode them again. Items added while receiving are received together as free slots allow, as in the original. (the original spins up more workers when adding, the Rust version fills free slots on each update)

AssetLoadFailurestruct traits Clone, Debug, PartialEq, Eq

소스source

받지 못한 것 하나. (원본 { path, error })

One item that could not be received. (the original { path, error })

예제Example없는 파일은 실패 목록에 남는다A missing file stays in the failure list
use vanilla::{AssetLoader, Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
asset_loader.add_text("examples/assets/missing.txt");
asset_loader.load(&engine);
let failed_list = asset_loader.get_failed_list();
assert_eq!(failed_list.len(), 1);
assert_eq!(failed_list[0].path, "examples/assets/missing.txt");
assert!(!failed_list[0].error_message.is_empty());
필드fieldpub path: String#0.4.0 부터since 0.4.0소스source

넣을 때 준 경로. (바깥 손잡이는 그 손잡이의 경로)

Path given when added. (for an external handle, that handle's path)

반환ReturnsString

필드fieldpub error_message: String#0.4.0 부터since 0.4.0소스source

실패 까닭. (받지 못함, 그림이나 JSON 을 풀지 못함, 소리 디코딩 실패)

Failure reason. (could not fetch, could not decode the image or parse the JSON, sound decoding failed)

반환ReturnsString

AssetLoaderProgressHandlertype

소스source

진행 알림 함수. (진행률, 끝난 수, 전체 수)

Progress notification function. (progress, finished count, total count)

pub type AssetLoaderProgressHandler = Box<dyn FnMut(f64, usize, usize)>

AssetLoaderCompleteHandlertype

소스source

다 받음 알림 함수. (실패 목록)

All-received notification function. (failure list)

pub type AssetLoaderCompleteHandler = Box<dyn FnMut(&[AssetLoadFailure])>

AssetLoaderLoadHandlestruct traits Clone, IntoFuture

소스source

함께 받기 손잡이. (AssetLoader::load 가 돌려준다. 원본 load 의 Promise 자리, 받기 목록을 나눠 든다)

  • await 하면 다 받을 때까지 기다려 실패 목록으로 끝난다.

Load-together handle. (returned by AssetLoader::load. Stands in for the Promise of the original load, shares the receive list)

  • Awaiting it waits until everything arrives and finishes with the failure list.
예제Example엔진 작업 안에서 다 받기를 기다려 실패 목록 보기Wait for everything to load inside an engine task and check the failure list
use vanilla::{Asset, AssetLoader, Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
let json_asset = asset_loader.add_json("examples/assets/atlas/icons.json");
asset_loader.add_text("examples/assets/missing.txt");
let loader_load_handle = asset_loader.load(&engine);
let task_handle = engine.spawn_task(|_engine_context| async move {
	let failed_list = loader_load_handle.await;
	assert_eq!(failed_list.len(), 1);
	assert_eq!(failed_list[0].path, "examples/assets/missing.txt");
});
assert!(task_handle.is_finished());
assert!(json_asset.is_loaded());

AssetLoaderLoadFuturestruct traits Clone, Future

소스source

다 받기를 기다리는 퓨처. (손잡이를 await 하거나 wait_for_load 가 돌려준다. 실패 목록으로 끝난다)

  • 폴링할 때마다 update 를 불러 다음 것을 요청한다.

Future that waits for everything to arrive. (made by awaiting the handle or returned by wait_for_load. Finishes with the failure list)

  • Calls update on every poll to request the next ones.
예제Exampleload 를 부른 뒤 wait_for_load 로 기다리기Call load and then wait with wait_for_load
use vanilla::{AssetLoader, Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
let mut image_asset = asset_loader.add_image("examples/assets/atlas/icons.png");
asset_loader.load(&engine);
let loader_load_future = asset_loader.wait_for_load();
let task_handle = engine.spawn_task(|_engine_context| async move {
	assert!(loader_load_future.await.is_empty());
});
assert!(task_handle.is_finished());
assert_eq!(image_asset.get_image_size().x, 128.0);

AssetLoaderstruct traits Clone, Default

짝Counterpart: vanilla.js AssetLoader소스source

애셋 함께 받기.

  • add_image 같은 함수가 비어 있는 읽기 손잡이를 단 애셋을 바로 돌려주고, load 가 동시 수만큼 요청한다. 그 뒤로는 update 를 프레임마다 부른다.
  • Clone 하면 같은 목록을 가리킨다.

Loads assets together.

  • Functions like add_image immediately return an asset with an empty load handle, and load requests as many as the concurrency allows. After that, call update every frame.
  • A Clone points to the same list.
예제Example넣고 받기 시작하고 씬에 맡기기 (데스크탑은 load 에서 다 끝난다)Add, start loading, and hand it to the scene (on desktop everything finishes in load)
use vanilla::{AssetLoader, Engine, EngineConfiguration, SceneBase};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
let mut image_asset = asset_loader.add_image("examples/assets/atlas/icons.png");
let json_asset = asset_loader.add_json("examples/assets/atlas/icons.json");
let mut text_asset = asset_loader.add_text("examples/assets/scenedocument.scene.json");
assert_eq!(asset_loader.get_total_count(), 3);
assert_eq!(asset_loader.get_progress(), 0.0);
let mut scene_base = SceneBase::new();
scene_base.track_load_handle(&asset_loader.get_completion_handle());
assert!(!scene_base.are_tracked_assets_finished());

asset_loader.load(&engine);
asset_loader.update(&engine);
assert!(asset_loader.is_finished());
assert_eq!(asset_loader.get_progress(), 1.0);
assert_eq!(asset_loader.get_loaded_count(), 3);
assert!(asset_loader.get_failed_list().is_empty());
assert!(scene_base.are_tracked_assets_finished());
assert_eq!(image_asset.get_image_size().x, 128.0);
assert_eq!(json_asset.get_data().expect("json")["meta"]["width"], 128);
assert!(text_asset.get_text().is_some());
생성자constructorpub fn new() -> AssetLoader#0.4.0 부터since 0.4.0소스source

생성. (동시에 받는 수 6)

Creates one. (concurrency 6)

반환ReturnsAssetLoader 빈 목록의 받기. (load 전)A loader with an empty list. (before load)

짝Counterpart: vanilla.js AssetLoader.constructor

메서드methodpub fn set_concurrency(&self, concurrency: usize)#0.4.0 부터since 0.4.0소스source

동시에 받는 수 설정. (1 이상)

Sets the concurrency. (1 or more)

concurrencyusize
동시에 받는 수. (0 이면 1 로 친다)Number of concurrent loads. (0 counts as 1)

짝Counterpart: vanilla.js AssetLoader.setConcurrency

메서드methodpub fn get_concurrency(&self) -> usize#0.4.0 부터since 0.4.0소스source

동시에 받는 수 반환.

Returns the number of concurrent loads.

반환Returnsusize 동시에 받는 수. (기본 6)Number fetched at the same time. (default 6)

짝Counterpart: vanilla.js AssetLoader.getConcurrency

메서드methodpub fn add_image(&self, path: &str) -> ImageAsset#0.4.0 부터since 0.4.0소스source

그림 넣기. (받으면 바이트가 차는 애셋, 처음 get_image 할 때 푼다)

Adds an image. (an asset whose bytes fill in once received, decoded on the first get_image)

path&str
애셋 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준, data: 주소도 된다)Asset path. (relative to the asset folder on desktop, to asset_base_url on the web; data: URLs also work)

반환ReturnsImageAsset 아직 비어 있는 읽기 손잡이를 단 이미지 애셋. (차례가 오면 받고, 다 받으면 풀어 본다. 풀지 못하면 실패 목록에 든다)Image asset with a load handle that is still empty. (fetched when its turn comes and decoded once fetched. Goes into the failure list if it cannot be decoded)

짝Counterpart: vanilla.js AssetLoader.addImage

메서드methodpub fn add_json(&self, path: &str) -> JsonAsset#0.4.0 부터since 0.4.0소스source

JSON 넣기.

Adds JSON.

path&str
애셋 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준, data: 주소도 된다)Asset path. (relative to the asset folder on desktop, to asset_base_url on the web; data: URLs also work)

반환ReturnsJsonAsset 아직 비어 있는 읽기 손잡이를 단 JSON 애셋. (받은 뒤 풀지 못하면 실패 목록에 든다, 푼 자료는 이 애셋과 나눠 든다)JSON asset with a load handle that is still empty. (goes into the failure list if it cannot be parsed after fetching, the parsed data is shared with this asset)

짝Counterpart: vanilla.js AssetLoader.addJson

메서드methodpub fn add_text(&self, path: &str) -> TextAsset#0.4.0 부터since 0.4.0소스source

글 넣기.

Adds text.

path&str
애셋 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준, data: 주소도 된다)Asset path. (relative to the asset folder on desktop, to asset_base_url on the web; data: URLs also work)

반환ReturnsTextAsset 아직 비어 있는 읽기 손잡이를 단 글 애셋.Text asset with a load handle that is still empty.

짝Counterpart: vanilla.js AssetLoader.addText

메서드methodpub fn add_blob(&self, path: &str) -> BlobAsset#0.4.0 부터since 0.4.0소스source

바이너리 넣기.

Adds binary.

path&str
애셋 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준, data: 주소도 된다)Asset path. (relative to the asset folder on desktop, to asset_base_url on the web; data: URLs also work)

반환ReturnsBlobAsset 아직 비어 있는 읽기 손잡이를 단 바이너리 애셋.Binary asset with a load handle that is still empty.

짝Counterpart: vanilla.js AssetLoader.addBlob

메서드methodpub fn add_font(&self, engine: &Engine, family: &str, path: &str, font_face_descriptors: FontFaceDescriptors) -> AssetLoadHandle#0.4.0 부터since 0.4.0소스source

글꼴 넣기. (받으면 엔진이 다음 프레임 시작에 family 이름 아래 서술자(굵기, 기울기, 글자 범위)대로 올린다. 읽기 손잡이를 돌려준다)

  • 원본 addFont(family, path, descriptors). 서술자를 주지 않던 원본 쓰임은 FontFaceDescriptors::new() 다.

Adds a font. (once received, the engine registers it under the family name with the descriptor (weight, style, character range) at the start of the next frame. Returns a load handle)

  • The original addFont(family, path, descriptors). Original uses that gave no descriptor correspond to FontFaceDescriptors::new().
engine&Engine
글꼴을 올릴 엔진. (지금 올리기를 맡겨 둔다)Engine to register the font with. (the registration is handed to it now)
family&str
글꼴 이름.Font name.
path&str
글꼴 파일 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준)Font file path. (relative to the asset folder on desktop, relative to asset_base_url on web)
font_face_descriptorsFontFaceDescriptors
굵기, 기울기, 글자 범위, 얼굴 열쇠. (열쇠가 비면 path)Weight, italic, character range, face key. (path if the key is empty)

반환ReturnsAssetLoadHandle 글꼴 바이트의 읽기 손잡이. (차례가 오면 받는다, 못 받으면 실패로 끝난다)Load handle for the font bytes. (fetched when its turn comes, finishes as a failure if it cannot be fetched)

짝Counterpart: vanilla.js AssetLoader.addFont

메서드methodpub fn add_audio(&self, path: &str) -> Rc<AudioAsset>#0.4.0 부터since 0.4.0소스source

소리 넣기. (바이트를 받으면 디코딩한다. 데스크탑은 그 자리에서, 웹은 뒤에서)

Adds a sound. (decodes once the bytes are received. On the spot on desktop, in the background on web)

path&str
소리 파일 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준, data: 주소도 된다)Sound file path. (relative to the asset folder on desktop, relative to asset_base_url on the web, data: URLs also work)

반환ReturnsRc<AudioAsset> 아직 비어 있는 오디오 애셋. (디코딩까지 끝나야 끝난 것으로 친다, 플레이어에 미리 실어 둬도 된다)Audio asset that is still empty. (counts as finished only once decoding is done, can be loaded into a player in advance)

짝Counterpart: vanilla.js AssetLoader.addAudio

예제Example소리를 넣고 받기 (데스크탑은 load 에서 디코딩까지 끝난다)Add a sound and load it (on desktop decoding also finishes in load)
use vanilla::{AssetLoader, Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
let audio_asset = asset_loader.add_audio("tests/assets/audio/wav_s16_stereo.wav");
assert!(!audio_asset.is_loaded());
asset_loader.load(&engine);
assert!(audio_asset.is_loaded());
assert!(asset_loader.is_finished());
메서드methodpub fn add_load_handle(&self, load_handle: &AssetLoadHandle)#0.4.0 부터since 0.4.0소스source

바깥에서 요청한 읽기 손잡이 넣기. (원본 addTask 자리, 진행률에 같이 센다)

  • 넣은 때부터 받는 중으로 치고, 끝나기 전까지 동시 수의 한 자리를 쓴다. 실패로 끝나면 실패 목록에 든다.

Adds a load handle requested from outside. (in place of the original addTask, counted in the progress too)

  • It counts as loading from the moment it is added, and takes one concurrency slot until it finishes. If it finishes as a failure it goes into the failure list.
load_handle&AssetLoadHandle
바깥에서 요청했거나 직접 끝낼 읽기 손잡이. (나눠 든다)Load handle requested from outside or to be finished directly. (shared)
예제Example직접 만든 일을 진행률에 넣고 끝내기Add a custom task to the progress and finish it
use vanilla::{AssetLoadHandle, AssetLoader, Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
let generate_handle = AssetLoadHandle::create_pending("level.generate");
asset_loader.add_load_handle(&generate_handle);
asset_loader.load(&engine);
assert_eq!(asset_loader.get_in_flight_count(), 1);
assert!(!asset_loader.is_finished());
generate_handle.finish(Ok(Vec::new()));
asset_loader.update(&engine);
assert_eq!(asset_loader.get_in_flight_count(), 0);
assert!(asset_loader.is_finished());
assert_eq!(asset_loader.get_loaded_count(), 1);
메서드methodpub fn load(&self, engine: &Engine) -> AssetLoaderLoadHandle#0.4.0 부터since 0.4.0소스source

받기 시작. (첫 몫을 요청한다. 데스크탑은 여기서 다 끝난다. 그 뒤로는 update 를 프레임마다 부른다)

  • 원본처럼 await 할 수 있는 손잡이를 돌려준다. await 하면 다 받을 때까지 기다려 실패 목록이 나온다.
  • 넣은 것이 없으면 여기서 바로 다 받음이 된다.

Starts receiving. (requests the first batch. On desktop everything finishes here. After that, call update every frame)

  • Returns a handle that can be awaited as in the original. Awaiting it waits until everything arrives and yields the failure list.
  • If nothing was added, it becomes fully loaded right here.
engine&Engine
바이트를 부탁할 엔진.Engine to ask for the bytes.

반환ReturnsAssetLoaderLoadHandle 다 받으면 실패 목록으로 끝나는 손잡이. (받기 목록을 나눠 든다)Handle that finishes with the failure list once everything arrives. (shares the receive list)

짝Counterpart: vanilla.js AssetLoader.load

메서드methodpub fn update(&self, engine: &Engine)#0.4.0 부터since 0.4.0소스source

갱신. (끝난 소리 바이트를 디코딩에 넘기고, 빈 자리만큼 다음 것을 요청하고, 진행과 다 받음을 알린다. load 전이면 아무것도 하지 않는다)

  • 다 받은 그림은 여기서 풀어 본다. 새로 끝난 것이 있을 때만 진행 알림을, 처음 다 끝났을 때 한 번 다 받음 알림을 부른다.

Update. (passes finished sound bytes to decoding, requests the next ones as free slots allow, and reports progress and completion. Does nothing before load)

  • Fetched images are decoded here. Calls the progress notification only when something newly finished, and the completion notification once when everything first finishes.
engine&Engine
바이트를 부탁할 엔진.Engine to ask for the bytes.
메서드methodpub fn set_progress_handler(&self, progress_handler: Option<AssetLoaderProgressHandler>)#0.4.0 부터since 0.4.0소스source

진행 알림 함수 설정. (진행률, 끝난 수, 전체 수. None 이면 끔)

  • 알림 함수 안에서 이 받기를 불러도 된다. (부르는 동안 꺼내 둔다)

Sets the progress notification function. (progress, finished count, total count. Off if None)

  • This loader may be called from inside the notification function. (it is taken out while being called)
progress_handlerOption<AssetLoaderProgressHandler>
새로 끝난 것이 있을 때 부를 함수. (진행률 0 ~ 1, 끝난 수, 전체 수) None 이면 끈다.Function to call when something newly finishes. (progress 0 ~ 1, finished count, total count) None turns it off.

짝Counterpart: vanilla.js AssetLoader.setProgressHandler

예제Example진행과 다 받음 알림 받기Receive progress and completion notifications
use std::cell::RefCell;
use std::rc::Rc;
use vanilla::{AssetLoadFailure, AssetLoader, Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
let asset_loader = AssetLoader::new();
asset_loader.add_text("examples/assets/atlas/icons.json");
asset_loader.add_blob("examples/assets/missing.bin");
let progress_list: Rc<RefCell<Vec<(f64, usize, usize)>>> = Rc::new(RefCell::new(Vec::new()));
let progress_list_for_handler = progress_list.clone();
asset_loader.set_progress_handler(Some(Box::new(move |progress: f64, finished_count: usize, total_count: usize| {
	progress_list_for_handler.borrow_mut().push((progress, finished_count, total_count));
})));
let failed_path_list: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::new(Vec::new()));
let failed_path_list_for_handler = failed_path_list.clone();
asset_loader.set_complete_handler(Some(Box::new(move |failed_list: &[AssetLoadFailure]| {
	for failure in failed_list {
		failed_path_list_for_handler.borrow_mut().push(failure.path.clone());
	}
})));
asset_loader.load(&engine);
assert_eq!(*progress_list.borrow(), vec![(1.0, 2, 2)]);
assert_eq!(*failed_path_list.borrow(), vec![String::from("examples/assets/missing.bin")]);
메서드methodpub fn set_complete_handler(&self, complete_handler: Option<AssetLoaderCompleteHandler>)#0.4.0 부터since 0.4.0소스source

다 받음 알림 함수 설정. (실패 목록. None 이면 끔)

Sets the all-received notification function. (failure list. Off if None)

complete_handlerOption<AssetLoaderCompleteHandler>
처음 다 끝났을 때 한 번 부를 함수. (실패 목록, 없으면 빈 목록) None 이면 끈다.Function to call once when everything first finishes. (the failure list, an empty list if none) None turns it off.

짝Counterpart: vanilla.js AssetLoader.setCompleteHandler

메서드methodpub fn get_completion_handle(&self) -> AssetLoadHandle#0.4.0 부터since 0.4.0소스source

다 받음 손잡이. (다 끝나면 끝나는 손잡이, 씬이 track_load_handle 로 맡긴다. 다 끝난 뒤 더 넣은 것은 기다리지 않는다)

Completion handle. (a handle that finishes when everything finishes, handed off by a scene with track_load_handle. Items added after everything finished are not waited for)

반환ReturnsAssetLoadHandle 넣은 것이 모두 끝나면(실패 포함) 빈 바이트로 끝나는 읽기 손잡이.Load handle that finishes with empty bytes once everything added has finished (failures included).

메서드methodpub fn get_progress(&self) -> f64#0.4.0 부터since 0.4.0소스source

진행률. (끝난 수 / 전체 수, 넣은 것이 없으면 1)

Progress. (Finished count / total count, 1 if nothing was added)

반환Returnsf64 진행률. (0 ~ 1, 실패도 끝난 것으로 센다)Progress. (0 ~ 1, failures count as finished)

짝Counterpart: vanilla.js AssetLoader.getProgress

메서드methodpub fn get_total_count(&self) -> usize#0.4.0 부터since 0.4.0소스source

전체 수.

Total count.

반환Returnsusize 넣은 것의 수. (바깥 손잡이 포함)Number of items added. (external handles included)

짝Counterpart: vanilla.js AssetLoader.getTotalCount

메서드methodpub fn get_finished_count(&self) -> usize#0.4.0 부터since 0.4.0소스source

끝난 수. (받은 것과 실패한 것)

Finished count. (Loaded and failed)

반환Returnsusize 끝난 것의 수.Number of finished items.

짝Counterpart: vanilla.js AssetLoader.getFinishedCount

메서드methodpub fn get_loaded_count(&self) -> usize#0.4.0 부터since 0.4.0소스source

받은 수. (실패한 것은 빼고)

Loaded count. (Excluding failed)

반환Returnsusize 실패 없이 끝난 것의 수.Number of items finished without failure.

짝Counterpart: vanilla.js AssetLoader.getLoadedCount

메서드methodpub fn get_failed_list(&self) -> Vec<AssetLoadFailure>#0.4.0 부터since 0.4.0소스source

실패 목록. (복사본)

Failure list. (a copy)

반환ReturnsVec<AssetLoadFailure> 지금까지 실패한 것의 목록. (끝난 차례)List of items that have failed so far. (in finishing order)

짝Counterpart: vanilla.js AssetLoader.getFailedList

메서드methodpub fn wait_for_load(&self) -> AssetLoaderLoadFuture#0.4.0 부터since 0.4.0소스source

다 받기를 기다리는 퓨처. (원본 await load() 의 await 자리, load 를 부른 뒤 엔진 작업 안에서 await 한다. 실패 목록이 나온다)

  • 기다리는 동안 프레임마다 update 를 불러 다음 것을 요청한다. 손잡이를 나눠 들어 빌리지 않는다.

Future that waits for everything to arrive. (the await of the original await load(), awaited inside an engine task after calling load. Yields the failure list)

  • Calls update every frame while waiting to request the next ones. Shares the handle instead of borrowing it.

반환ReturnsAssetLoaderLoadFuture 다 받으면 실패 목록으로 끝나는 퓨처.Future that finishes with the failure list once everything arrives.

메서드methodpub fn is_finished(&self) -> bool#0.4.0 부터since 0.4.0소스source

넣은 것을 모두 받았는지. (실패 포함, 넣은 것이 없으면 true)

Whether everything added has been loaded. (Including failures, true if nothing was added)

반환Returnsbool 끝난 수가 전체 수에 닿았으면 true.true if the finished count has reached the total count.

짝Counterpart: vanilla.js AssetLoader.isFinished

메서드methodpub fn get_in_flight_count(&self) -> usize#0.4.0 부터since 0.4.0소스source

지금 받는 중인 수. (원본 getInFlightCount, 집어 받기 시작했고 아직 끝나지 않은 것. 넣은 바깥 손잡이도 끝나기 전까지 센다)

Number currently in flight. (the original getInFlightCount, those picked up and started but not yet finished. Added outside handles are also counted until they finish)

반환Returnsusize 받는 중인 것의 수.Number of items being loaded.

짝Counterpart: vanilla.js AssetLoader.getInFlightCount