// Generated by scripts/generate.mjs from bindings/api.mjs. Do not edit.
///|
#external
pub type GLTFParser
///|
extern "js" fn GLTFParser::ffi_json(self : GLTFParser) -> JsResult[String] =
#| (self) => { try { return { ok: true, value: (() => JSON.stringify(self.json))() }; } catch (error) { return { ok: false, error: String(error) }; } }
///|
pub fn GLTFParser::json(self : GLTFParser) -> Json raise SerializationError {
match self.ffi_json().into_result() {
Ok(value) =>
@json.parse(value) catch {
error => raise SerializationError((error : Error).to_string())
}
Err(message) => raise SerializationError(message)
}
}
///|
extern "js" fn GLTFParser::ffi_node_definition(
self : GLTFParser,
index : Int,
) -> Nullable[GLTFDefinition] =
#| (self, index) => self.json.nodes?.[index]
///|
pub fn GLTFParser::node_definition(
self : GLTFParser,
index : Int,
) -> GLTFDefinition? {
self.ffi_node_definition(index).to_option()
}
///|
extern "js" fn GLTFParser::ffi_mesh_definition(
self : GLTFParser,
index : Int,
) -> Nullable[GLTFDefinition] =
#| (self, index) => self.json.meshes?.[index]
///|
pub fn GLTFParser::mesh_definition(
self : GLTFParser,
index : Int,
) -> GLTFDefinition? {
self.ffi_mesh_definition(index).to_option()
}
///|
extern "js" fn GLTFParser::ffi_material_definition(
self : GLTFParser,
index : Int,
) -> Nullable[GLTFDefinition] =
#| (self, index) => self.json.materials?.[index]
///|
pub fn GLTFParser::material_definition(
self : GLTFParser,
index : Int,
) -> GLTFDefinition? {
self.ffi_material_definition(index).to_option()
}
///|
extern "js" fn GLTFParser::ffi_texture_definition(
self : GLTFParser,
index : Int,
) -> Nullable[GLTFDefinition] =
#| (self, index) => self.json.textures?.[index]
///|
pub fn GLTFParser::texture_definition(
self : GLTFParser,
index : Int,
) -> GLTFDefinition? {
self.ffi_texture_definition(index).to_option()
}
///|
extern "js" fn GLTFParser::ffi_get_node(
self : GLTFParser,
index : Int,
) -> @js_async.Promise[Object3D] =
#| (self, index) => Promise.resolve().then(() => self.getDependency("node",index))
///|
pub async fn GLTFParser::get_node(
self : GLTFParser,
index : Int,
) -> Object3D raise LoadError {
try {
let value = self.ffi_get_node(index).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}
///|
extern "js" fn GLTFParser::ffi_get_mesh(
self : GLTFParser,
index : Int,
) -> @js_async.Promise[Object3D] =
#| (self, index) => Promise.resolve().then(() => self.getDependency("mesh",index))
///|
pub async fn GLTFParser::get_mesh(
self : GLTFParser,
index : Int,
) -> Object3D raise LoadError {
try {
let value = self.ffi_get_mesh(index).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}
///|
extern "js" fn GLTFParser::ffi_get_material(
self : GLTFParser,
index : Int,
) -> @js_async.Promise[Material] =
#| (self, index) => Promise.resolve().then(() => self.getDependency("material",index))
///|
pub async fn GLTFParser::get_material(
self : GLTFParser,
index : Int,
) -> Material raise LoadError {
try {
let value = self.ffi_get_material(index).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}
///|
extern "js" fn GLTFParser::ffi_get_texture(
self : GLTFParser,
index : Int,
) -> @js_async.Promise[Texture] =
#| (self, index) => Promise.resolve().then(() => self.getDependency("texture",index))
///|
pub async fn GLTFParser::get_texture(
self : GLTFParser,
index : Int,
) -> Texture raise LoadError {
try {
let value = self.ffi_get_texture(index).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}
///|
extern "js" fn GLTFParser::ffi_get_accessor(
self : GLTFParser,
index : Int,
) -> @js_async.Promise[BufferAttribute] =
#| (self, index) => Promise.resolve().then(() => self.getDependency("accessor",index))
///|
pub async fn GLTFParser::get_accessor(
self : GLTFParser,
index : Int,
) -> BufferAttribute raise LoadError {
try {
let value = self.ffi_get_accessor(index).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}
///|
extern "js" fn GLTFParser::ffi_get_buffer_view(
self : GLTFParser,
index : Int,
) -> @js_async.Promise[Bytes] =
#| (self, index) => Promise.resolve().then(() => self.getDependency("bufferView",index).then(data=>new Uint8Array(data).slice()))
///|
pub async fn GLTFParser::get_buffer_view(
self : GLTFParser,
index : Int,
) -> Bytes raise LoadError {
try {
let value = self.ffi_get_buffer_view(index).wait()
value
} catch {
error => raise LoadError((error : Error).to_string())
}
}