// Generated by scripts/generate.mjs from bindings/api.mjs. Do not edit.
///|
#external
pub type AnimationLoader
///|
#module("@mizchi/three-mbt/constructors")
pub extern "js" fn AnimationLoader::AnimationLoader() -> AnimationLoader = "animationLoader"
///|
pub fn AnimationLoader::as_loader(self : AnimationLoader) -> Loader = "%identity"
///|
extern "js" fn AnimationLoader::ffi_load(
self : AnimationLoader,
url : String,
) -> @js_async.Promise[FixedArray[AnimationClip]] =
#| (self, url) => Promise.resolve().then(() => self.loadAsync(url))
///|
pub async fn AnimationLoader::load(
self : AnimationLoader,
url : String,
) -> FixedArray[AnimationClip] raise LoadError {
try {
let value = self.ffi_load(url).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}
///|
extern "js" fn AnimationLoader::ffi_parse_json(
self : AnimationLoader,
json : String,
) -> JsResult[FixedArray[AnimationClip]] =
#| (self, json) => { try { return { ok: true, value: (() => self.parse(JSON.parse(json)))() }; } catch (error) { return { ok: false, error: String(error) }; } }
///|
pub fn AnimationLoader::parse_json(
self : AnimationLoader,
json : Json,
) -> FixedArray[AnimationClip] raise LoadError {
match self.ffi_parse_json(json.stringify()).into_result() {
Ok(value) => value
Err(message) => raise LoadError(message)
}
}
///|
extern "js" fn AnimationLoader::ffi_parse_json_string(
self : AnimationLoader,
text : String,
) -> JsResult[FixedArray[AnimationClip]] =
#| (self, text) => { try { return { ok: true, value: (() => self.parse(JSON.parse(text)))() }; } catch (error) { return { ok: false, error: String(error) }; } }
///|
pub fn AnimationLoader::parse_json_string(
self : AnimationLoader,
text : String,
) -> FixedArray[AnimationClip] raise LoadError {
match self.ffi_parse_json_string(text).into_result() {
Ok(value) => value
Err(message) => raise LoadError(message)
}
}