From 101d4ab665c5ea7a09f87b6c6b988b177bb5eb9f Mon Sep 17 00:00:00 2001 From: Kayh Date: Tue, 10 Sep 2024 13:37:40 -0400 Subject: [PATCH] add ellipse and circle shape --- wasm/example-unavi-layout/src/bindings.rs | 564 +++++++++++-- wasm/example-unavi-scene/src/bindings.rs | 518 +++++++++++- wasm/example-unavi-shapes/src/bindings.rs | 518 +++++++++++- wasm/example-unavi-shapes/src/lib.rs | 20 +- wasm/example-unavi-ui/src/bindings.rs | 526 ++++++++++-- wasm/example-unavi-vscreen/src/bindings.rs | 554 +++++++++++-- wasm/example-wired-input/src/bindings.rs | 526 ++++++++++-- wasm/example-wired-physics/src/bindings.rs | 526 ++++++++++-- wasm/example-wired-player/src/bindings.rs | 526 ++++++++++-- wasm/example-wired-scene/src/bindings.rs | 680 +++++++++++++--- wasm/unavi-shapes/src/bindings.rs | 879 ++++++++++++++++++--- wasm/unavi-shapes/src/lib.rs | 7 +- wasm/unavi-shapes/src/shapes/circle.rs | 60 ++ wasm/unavi-shapes/src/shapes/cylinder.rs | 1 - wasm/unavi-shapes/src/shapes/ellipse.rs | 94 +++ wasm/unavi-shapes/src/shapes/mod.rs | 2 + wasm/unavi-shapes/src/shapes/rectangle.rs | 7 +- wasm/unavi-shapes/wit/world.wit | 38 +- wasm/unavi-ui/src/bindings.rs | 554 +++++++++++-- wasm/unavi-vscreen/src/bindings.rs | 554 +++++++++++-- 20 files changed, 6403 insertions(+), 751 deletions(-) create mode 100644 wasm/unavi-shapes/src/shapes/circle.rs create mode 100644 wasm/unavi-shapes/src/shapes/ellipse.rs diff --git a/wasm/example-unavi-layout/src/bindings.rs b/wasm/example-unavi-layout/src/bindings.rs index e3f821efd..4151da5f2 100644 --- a/wasm/example-unavi-layout/src/bindings.rs +++ b/wasm/example-unavi-layout/src/bindings.rs @@ -1198,7 +1198,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -1244,7 +1243,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -1552,6 +1637,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -5620,8 +6040,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6978] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc55\x01A\x02\x01A$\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 7689] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8c;\x01A\x02\x01A$\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -5713,69 +6133,83 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B#\x02\ -\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\x02\ -\x01m\x03\x06center\x03end\x05start\x04\0\x09alignment\x03\0\x04\x04\0\x09contai\ -ner\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\0\x16[constructor]container\x01\ -\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15[method]container.ref\x01\x0a\x01\ -i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[method]container.root\x01\x0c\x04\0\x17\ -[method]container.inner\x01\x0c\x01p\x07\x01@\x01\x04self\x09\0\x0d\x04\0\x1f[me\ -thod]container.list-children\x01\x0e\x01@\x02\x04self\x09\x05child\x09\x01\0\x04\ -\0\x1b[method]container.add-child\x01\x0f\x04\0\x1e[method]container.remove-chil\ -d\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\0\x16[method]container.size\x01\x10\x01\ -@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1a[method]container.set-size\x01\x11\ -\x01@\x01\x04self\x09\0\x05\x04\0\x19[method]container.align-x\x01\x12\x04\0\x19\ -[method]container.align-y\x01\x12\x04\0\x19[method]container.align-z\x01\x12\x01\ -@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d[method]container.set-align-x\x01\x13\ -\x04\0\x1d[method]container.set-align-y\x01\x13\x04\0\x1d[method]container.set-a\ -lign-z\x01\x13\x03\x01\x16unavi:layout/container\x05\x14\x02\x03\0\x09\x09contai\ -ner\x01B\x16\x02\x03\x02\x01\x15\x04\0\x09container\x03\0\0\x02\x03\x02\x01\x04\x04\ -\0\x04vec3\x03\0\x02\x04\0\x04grid\x03\x01\x01i\x04\x01@\x02\x04size\x03\x04rows\ -\x03\0\x05\x04\0\x11[constructor]grid\x01\x06\x01h\x04\x01i\x01\x01@\x01\x04self\ -\x07\0\x08\x04\0\x11[method]grid.root\x01\x09\x01p\x08\x01@\x01\x04self\x07\0\x0a\ -\x04\0\x12[method]grid.cells\x01\x0b\x01k\x08\x01@\x04\x04self\x07\x01xy\x01yy\x01\ -zy\0\x0c\x04\0\x11[method]grid.cell\x01\x0d\x01@\x01\x04self\x07\0\x03\x04\0\x11\ -[method]grid.rows\x01\x0e\x01@\x02\x04self\x07\x05value\x03\x01\0\x04\0\x15[meth\ -od]grid.set-rows\x01\x0f\x03\x01\x11unavi:layout/grid\x05\x16\x01B\x07\x04\0\x06\ -script\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]script\x01\x02\x01h\0\x01\ -@\x02\x04self\x03\x05deltav\x01\0\x04\0\x15[method]script.update\x01\x04\x04\x01\ -\x12wired:script/types\x05\x17\x04\x01\x1bexample:unavi-layout/script\x04\0\x0b\x0c\ -\x01\0\x06script\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-componen\ -t\x070.208.1\x10wit-bindgen-rust\x060.25.0"; +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\x01\x10\x04\0\x04node\x03\ +\0\x02\x01m\x03\x06center\x03end\x05start\x04\0\x09alignment\x03\0\x04\x04\0\x09\ +container\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\0\x16[constructor]cont\ +ainer\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15[method]container.ref\ +\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[method]container.root\x01\ +\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\x07\x01@\x01\x04self\x09\0\x0d\ +\x04\0\x1f[method]container.list-children\x01\x0e\x01@\x02\x04self\x09\x05child\x09\ +\x01\0\x04\0\x1b[method]container.add-child\x01\x0f\x04\0\x1e[method]container.r\ +emove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\0\x16[method]container.size\x01\ +\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1a[method]container.set-size\ +\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[method]container.align-x\x01\x12\x04\ +\0\x19[method]container.align-y\x01\x12\x04\0\x19[method]container.align-z\x01\x12\ +\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d[method]container.set-align-x\x01\ +\x13\x04\0\x1d[method]container.set-align-y\x01\x13\x04\0\x1d[method]container.s\ +et-align-z\x01\x13\x03\x01\x16unavi:layout/container\x05\x14\x02\x03\0\x09\x09co\ +ntainer\x01B\x16\x02\x03\x02\x01\x15\x04\0\x09container\x03\0\0\x02\x03\x02\x01\x04\ +\x04\0\x04vec3\x03\0\x02\x04\0\x04grid\x03\x01\x01i\x04\x01@\x02\x04size\x03\x04\ +rows\x03\0\x05\x04\0\x11[constructor]grid\x01\x06\x01h\x04\x01i\x01\x01@\x01\x04\ +self\x07\0\x08\x04\0\x11[method]grid.root\x01\x09\x01p\x08\x01@\x01\x04self\x07\0\ +\x0a\x04\0\x12[method]grid.cells\x01\x0b\x01k\x08\x01@\x04\x04self\x07\x01xy\x01\ +yy\x01zy\0\x0c\x04\0\x11[method]grid.cell\x01\x0d\x01@\x01\x04self\x07\0\x03\x04\ +\0\x11[method]grid.rows\x01\x0e\x01@\x02\x04self\x07\x05value\x03\x01\0\x04\0\x15\ +[method]grid.set-rows\x01\x0f\x03\x01\x11unavi:layout/grid\x05\x16\x01B\x07\x04\0\ +\x06script\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]script\x01\x02\x01h\ +\0\x01@\x02\x04self\x03\x05deltav\x01\0\x04\0\x15[method]script.update\x01\x04\x04\ +\x01\x12wired:script/types\x05\x17\x04\x01\x1bexample:unavi-layout/script\x04\0\x0b\ +\x0c\x01\0\x06script\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-comp\ +onent\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] diff --git a/wasm/example-unavi-scene/src/bindings.rs b/wasm/example-unavi-scene/src/bindings.rs index 91aab33a8..116a88fad 100644 --- a/wasm/example-unavi-scene/src/bindings.rs +++ b/wasm/example-unavi-scene/src/bindings.rs @@ -494,7 +494,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -540,7 +539,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -848,6 +933,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -4916,8 +5336,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 5952] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc3-\x01A\x02\x01A\x1f\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6663] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8a3\x01A\x02\x01A\x1f\ \x01B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\ \0\x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01\ r\x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -5009,46 +5429,60 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B\x07\ -\x04\0\x06script\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]script\x01\x02\ -\x01h\0\x01@\x02\x04self\x03\x05deltav\x01\0\x04\0\x15[method]script.update\x01\x04\ -\x04\x01\x12wired:script/types\x05\x14\x04\x01\x1aexample:unavi-scene/script\x04\ -\0\x0b\x0c\x01\0\x06script\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwi\ -t-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +\x07\x04\0\x06script\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]script\x01\ +\x02\x01h\0\x01@\x02\x04self\x03\x05deltav\x01\0\x04\0\x15[method]script.update\x01\ +\x04\x04\x01\x12wired:script/types\x05\x14\x04\x01\x1aexample:unavi-scene/script\ +\x04\0\x0b\x0c\x01\0\x06script\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] diff --git a/wasm/example-unavi-shapes/src/bindings.rs b/wasm/example-unavi-shapes/src/bindings.rs index ae55736f4..8f99697c1 100644 --- a/wasm/example-unavi-shapes/src/bindings.rs +++ b/wasm/example-unavi-shapes/src/bindings.rs @@ -494,7 +494,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -540,7 +539,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -848,6 +933,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -4916,8 +5336,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 5953] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc4-\x01A\x02\x01A\x1f\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6664] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8b3\x01A\x02\x01A\x1f\ \x01B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\ \0\x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01\ r\x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -5009,46 +5429,60 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B\x07\ -\x04\0\x06script\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]script\x01\x02\ -\x01h\0\x01@\x02\x04self\x03\x05deltav\x01\0\x04\0\x15[method]script.update\x01\x04\ -\x04\x01\x12wired:script/types\x05\x14\x04\x01\x1bexample:unavi-shapes/script\x04\ -\0\x0b\x0c\x01\0\x06script\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwi\ -t-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +\x07\x04\0\x06script\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]script\x01\ +\x02\x01h\0\x01@\x02\x04self\x03\x05deltav\x01\0\x04\0\x15[method]script.update\x01\ +\x04\x04\x01\x12wired:script/types\x05\x14\x04\x01\x1bexample:unavi-shapes/scrip\ +t\x04\0\x0b\x0c\x01\0\x06script\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] diff --git a/wasm/example-unavi-shapes/src/lib.rs b/wasm/example-unavi-shapes/src/lib.rs index dfad71493..d91d31336 100644 --- a/wasm/example-unavi-shapes/src/lib.rs +++ b/wasm/example-unavi-shapes/src/lib.rs @@ -4,7 +4,7 @@ use bindings::{ exports::wired::script::types::{Guest, GuestScript}, unavi::{ scene::api::{Root, Scene}, - shapes::api::{Cuboid, Cylinder, Rectangle, Sphere}, + shapes::api::{Circle, Cuboid, Cylinder, Ellipse, Rectangle, Sphere}, }, wired::{ math::types::{Quat, Transform, Vec2, Vec3}, @@ -69,6 +69,24 @@ impl GuestScript for Script { scene.add_node(&rectangle); } + { + let translation = Vec3::new(-3.0, 0.0, 0.0); + spawn_axis(translation); + + let circle = Circle::new(0.5).to_physics_node(); + circle.set_transform(Transform::from_translation(translation)); + scene.add_node(&circle); + } + + { + let translation = Vec3::new(-4.5, 0.0, 0.0); + spawn_axis(translation); + + let ellipse = Ellipse::new(Vec2::new(0.5, 0.75)).to_node(); + ellipse.set_transform(Transform::from_translation(translation)); + scene.add_node(&ellipse); + } + Root::add_scene(&scene); Script diff --git a/wasm/example-unavi-ui/src/bindings.rs b/wasm/example-unavi-ui/src/bindings.rs index 19a9fe93f..78bdc7e25 100644 --- a/wasm/example-unavi-ui/src/bindings.rs +++ b/wasm/example-unavi-ui/src/bindings.rs @@ -934,7 +934,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -980,7 +979,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -1288,6 +1373,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -5986,8 +6406,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 7615] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc2:\x01A\x02\x01A*\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8326] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x89@\x01A\x02\x01A*\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -6079,50 +6499,64 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B\x04\ -\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\x05\ -level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\x14\ -\x01B\x02\x01@\x01\x05deltav\x01\0\x04\0\x09update-ui\x01\0\x03\x01\x0cunavi:ui/\ -api\x05\x15\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\x01\x10\x04\ -\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\0\x09alignment\x03\0\ -\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\0\x16[co\ -nstructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15[method\ -]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[method]cont\ -ainer.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\x07\x01@\x01\x04\ +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +\x04\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\ +\x05level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\ +\x14\x01B\x02\x01@\x01\x05deltav\x01\0\x04\0\x09update-ui\x01\0\x03\x01\x0cunavi\ +:ui/api\x05\x15\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\x01\x10\ +\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\0\x09alignment\x03\ +\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\0\x16[\ +constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15[meth\ +od]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[method]co\ +ntainer.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\x07\x01@\x01\x04\ self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\x01@\x02\x04self\ \x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\x0f\x04\0\x1e[m\ ethod]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\0\x16[method\ diff --git a/wasm/example-unavi-vscreen/src/bindings.rs b/wasm/example-unavi-vscreen/src/bindings.rs index b20f6616f..adc5f63c8 100644 --- a/wasm/example-unavi-vscreen/src/bindings.rs +++ b/wasm/example-unavi-vscreen/src/bindings.rs @@ -456,7 +456,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -502,7 +501,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -810,6 +895,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -5232,17 +5652,6 @@ mod _rt { let layout = alloc::Layout::from_size_align_unchecked(size, align); alloc::dealloc(ptr as *mut u8, layout); } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - } - } else { - val != 0 - } - } pub fn as_i32(t: T) -> i32 { t.as_i32() @@ -5313,6 +5722,17 @@ mod _rt { self as i32 } } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } pub use alloc_crate::boxed::Box; #[cfg(target_arch = "wasm32")] @@ -5354,8 +5774,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6768] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf33\x01A\x02\x01A\"\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 7479] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xba9\x01A\x02\x01A\"\ \x01B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\ \0\x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01\ r\x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -5435,53 +5855,67 @@ y\x01'\x01h\x09\x01k(\x01@\x02\x04self\x0d\x05value)\x01\0\x04\0\x1b[method]node .set-rigid-body\x01*\x01i\x03\x01k+\x01@\x01\x04self\x0d\0,\x04\0\x1a[method]nod\ e.input-handler\x01-\x01h\x03\x01k.\x01@\x02\x04self\x0d\x05value/\x01\0\x04\0\x1e\ [method]node.set-input-handler\x010\x03\x01\x10wired:scene/node\x05\x0f\x02\x03\0\ -\0\x04vec2\x02\x03\0\x06\x04node\x01BY\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ +\0\x04vec2\x02\x03\0\x06\x04node\x01B}\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ \x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\ \0\x04\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x06\x04\0\x09rectangle\x03\x01\x04\ -\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0a\ -sphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0d\ -\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\0\x0bsphere-kind\x03\0\x0f\x04\0\x06\ -sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x12\x04\0\x16[constructor]rectang\ -le\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\x04\0\x16[method]rectangle.size\x01\ -\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\x04\0\x1a[method]rectangle.set-size\ -\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\x04\0\x19[method]rectangle.to-mesh\x01\ -\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\0\x19[method]rectangle.to-node\x01\x1a\ -\x04\0![method]rectangle.to-physics-node\x01\x1a\x01i\x09\x01@\x02\x06radiusv\x06\ -heightv\0\x1b\x04\0\x15[constructor]cylinder\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\ -\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\x01@\x02\x04self\x1d\x05value\x7f\x01\ -\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\x01@\x01\x04self\x1d\0v\x04\0\x17[m\ -ethod]cylinder.height\x01\x20\x01@\x02\x04self\x1d\x05valuev\x01\0\x04\0\x1b[met\ -hod]cylinder.set-height\x01!\x04\0\x17[method]cylinder.radius\x01\x20\x04\0\x1b[\ -method]cylinder.set-radius\x01!\x01@\x01\x04self\x1d\0}\x04\0\x1b[method]cylinde\ -r.resolution\x01\"\x01@\x02\x04self\x1d\x05value}\x01\0\x04\0\x1f[method]cylinde\ -r.set-resolution\x01#\x04\0\x19[method]cylinder.segments\x01\"\x04\0\x1d[method]\ -cylinder.set-segments\x01#\x01@\x01\x04self\x1d\0\x17\x04\0\x18[method]cylinder.\ -to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18[method]cylinder.to-node\x01%\x04\ -\0\x20[method]cylinder.to-physics-node\x01%\x01i\x0a\x01@\x01\x04size\x03\0&\x04\ -\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\x04self(\0\x03\x04\0\x13[method\ -]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\x01\0\x04\0\x17[method]cuboid.s\ -et-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[method]cuboid.to-mesh\x01+\x01@\x01\ -\x04self(\0\x19\x04\0\x16[method]cuboid.to-node\x01,\x04\0\x1e[method]cuboid.to-\ -physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\0-\x04\0\x16[static]sphere.new-ic\ -o\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01h\x11\x01@\x01\x04self/\0v\x04\0\x15\ -[method]sphere.radius\x010\x01@\x02\x04self/\x05valuev\x01\0\x04\0\x19[method]sp\ -here.set-radius\x011\x01@\x01\x04self/\0\x10\x04\0\x13[method]sphere.kind\x012\x01\ -@\x02\x04self/\x05value\x10\x01\0\x04\0\x17[method]sphere.set-kind\x013\x01@\x01\ -\x04self/\0\x17\x04\0\x16[method]sphere.to-mesh\x014\x01@\x01\x04self/\0\x19\x04\ -\0\x16[method]sphere.to-node\x015\x04\0\x1e[method]sphere.to-physics-node\x015\x03\ -\x01\x10unavi:shapes/api\x05\x12\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\ -\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\ -\0\x09alignment\x03\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\ -\0\x07\x04\0\x16[constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\ -\x04\0\x15[method]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\ -\x16[method]container.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\ -\x07\x01@\x01\x04self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\ -\x01@\x02\x04self\x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\ -\x0f\x04\0\x1e[method]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\ -\0\x16[method]container.size\x01\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\ -\0\x1a[method]container.set-size\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[me\ -thod]container.align-x\x01\x12\x04\0\x19[method]container.align-y\x01\x12\x04\0\x19\ -[method]container.align-z\x01\x12\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d\ +\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06\ +cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07\ +sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\ +\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\ +\x04size\x01\0\x14\x04\0\x16[constructor]rectangle\x01\x15\x01h\x08\x01@\x01\x04\ +self\x16\0\x01\x04\0\x16[method]rectangle.size\x01\x17\x01@\x02\x04self\x16\x05v\ +alue\x01\x01\0\x04\0\x1a[method]rectangle.set-size\x01\x18\x01i\x05\x01@\x01\x04\ +self\x16\0\x19\x04\0\x19[method]rectangle.to-mesh\x01\x1a\x01i\x07\x01@\x01\x04s\ +elf\x16\0\x1b\x04\0\x19[method]rectangle.to-node\x01\x1c\x04\0![method]rectangle\ +.to-physics-node\x01\x1c\x01i\x09\x01@\x01\x06radiusv\0\x1d\x04\0\x13[constructo\ +r]circle\x01\x1e\x01h\x09\x01@\x01\x04self\x1f\0v\x04\0\x15[method]circle.radius\ +\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\0\x04\0\x19[method]circle.set-radius\ +\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[method]circle.resolution\x01\"\x01@\x02\x04\ +self\x1f\x05value{\x01\0\x04\0\x1d[method]circle.set-resolution\x01#\x01@\x01\x04\ +self\x1f\0\x19\x04\0\x16[method]circle.to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\ +\0\x16[method]circle.to-node\x01%\x04\0\x1e[method]circle.to-physics-node\x01%\x01\ +i\x0a\x01@\x01\x09half-size\x01\0&\x04\0\x14[constructor]ellipse\x01'\x01h\x0a\x01\ +@\x01\x04self(\0\x01\x04\0\x19[method]ellipse.half-size\x01)\x01@\x02\x04self(\x05\ +value\x01\x01\0\x04\0\x1d[method]ellipse.set-half-size\x01*\x01@\x01\x04self(\0{\ +\x04\0\x1a[method]ellipse.resolution\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\ +\x1e[method]ellipse.set-resolution\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method\ +]ellipse.to-mesh\x01-\x01@\x01\x04self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01\ +.\x04\0\x1f[method]ellipse.to-physics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06\ +heightv\0/\x04\0\x15[constructor]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\ +\0\x14[method]cylinder.cap\x012\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[m\ +ethod]cylinder.set-cap\x013\x01@\x01\x04self1\0v\x04\0\x17[method]cylinder.heigh\ +t\x014\x01@\x02\x04self1\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01\ +5\x04\0\x17[method]cylinder.radius\x014\x04\0\x1b[method]cylinder.set-radius\x01\ +5\x01@\x01\x04self1\0}\x04\0\x1b[method]cylinder.resolution\x016\x01@\x02\x04sel\ +f1\x05value}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x017\x04\0\x19[metho\ +d]cylinder.segments\x016\x04\0\x1d[method]cylinder.set-segments\x017\x01@\x01\x04\ +self1\0\x19\x04\0\x18[method]cylinder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\ +\x18[method]cylinder.to-node\x019\x04\0\x20[method]cylinder.to-physics-node\x019\ +\x01i\x0c\x01@\x01\x04size\x03\0:\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01\ +@\x01\x04self<\0\x03\x04\0\x13[method]cuboid.size\x01=\x01@\x02\x04self<\x05valu\ +e\x03\x01\0\x04\0\x17[method]cuboid.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16\ +[method]cuboid.to-mesh\x01?\x01@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-n\ +ode\x01@\x04\0\x1e[method]cuboid.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiu\ +sv\0\xc1\0\x04\0\x16[static]sphere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01\ +B\x01h\x13\x01@\x01\x04self\xc3\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\ +\x04self\xc3\0\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04\ +self\xc3\0\0\x12\x04\0\x13[method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05val\ +ue\x12\x01\0\x04\0\x17[method]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\ +\0\x16[method]sphere.to-mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]\ +sphere.to-node\x01I\x04\0\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unav\ +i:shapes/api\x05\x12\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\ +\x01\x11\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\0\x09ali\ +gnment\x03\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\ +\0\x16[constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15\ +[method]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[meth\ +od]container.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\x07\x01@\ +\x01\x04self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\x01@\x02\ +\x04self\x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\x0f\x04\ +\0\x1e[method]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\0\x16\ +[method]container.size\x01\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1a\ +[method]container.set-size\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[method]c\ +ontainer.align-x\x01\x12\x04\0\x19[method]container.align-y\x01\x12\x04\0\x19[me\ +thod]container.align-z\x01\x12\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d\ [method]container.set-align-x\x01\x13\x04\0\x1d[method]container.set-align-y\x01\ \x13\x04\0\x1d[method]container.set-align-z\x01\x13\x03\x01\x16unavi:layout/cont\ ainer\x05\x13\x02\x03\0\x08\x09container\x01B&\x02\x03\x02\x01\x14\x04\0\x09cont\ diff --git a/wasm/example-wired-input/src/bindings.rs b/wasm/example-wired-input/src/bindings.rs index 36730c927..63374ff8f 100644 --- a/wasm/example-wired-input/src/bindings.rs +++ b/wasm/example-wired-input/src/bindings.rs @@ -494,7 +494,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -540,7 +539,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -848,6 +933,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -7565,8 +7985,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9625] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9cJ\x01A\x02\x01A+\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 10336] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe3O\x01A\x02\x01A+\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -7658,50 +8078,64 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B\x04\ -\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\x05\ -level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\x14\ -\x01B\x11\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hips\x02\ -\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dleft-sh\ -oulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0eright\ --shoulder\x02\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\x0e\ -left-upper-leg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\x02\ -\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06p\ -layer\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\ +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +\x04\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\ +\x05level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\ +\x14\x01B\x11\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hip\ +s\x02\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dle\ +ft-shoulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0e\ +right-shoulder\x02\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\ +\x0eleft-upper-leg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\ +\x02\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06\ +player\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\ \x07\x01@\x01\x04self\x06\0\x04\x04\0\x17[method]player.skeleton\x01\x08\x01i\x05\ \x01p\x09\x01@\0\0\x0a\x04\0\x0clist-players\x01\x0b\x01@\0\0\x09\x04\0\x0clocal\ -player\x01\x0c\x03\x01\x10wired:player/api\x05\x15\x01B\x15\x02\x03\x02\x01\x10\ diff --git a/wasm/example-wired-physics/src/bindings.rs b/wasm/example-wired-physics/src/bindings.rs index 7c9b93cae..65e389cef 100644 --- a/wasm/example-wired-physics/src/bindings.rs +++ b/wasm/example-wired-physics/src/bindings.rs @@ -494,7 +494,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -540,7 +539,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -848,6 +933,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -7565,8 +7985,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9627] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9eJ\x01A\x02\x01A+\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 10338] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe5O\x01A\x02\x01A+\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -7658,50 +8078,64 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B\x04\ -\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\x05\ -level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\x14\ -\x01B\x11\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hips\x02\ -\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dleft-sh\ -oulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0eright\ --shoulder\x02\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\x0e\ -left-upper-leg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\x02\ -\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06p\ -layer\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\ +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +\x04\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\ +\x05level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\ +\x14\x01B\x11\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hip\ +s\x02\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dle\ +ft-shoulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0e\ +right-shoulder\x02\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\ +\x0eleft-upper-leg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\ +\x02\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06\ +player\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\ \x07\x01@\x01\x04self\x06\0\x04\x04\0\x17[method]player.skeleton\x01\x08\x01i\x05\ \x01p\x09\x01@\0\0\x0a\x04\0\x0clist-players\x01\x0b\x01@\0\0\x09\x04\0\x0clocal\ -player\x01\x0c\x03\x01\x10wired:player/api\x05\x15\x01B\x15\x02\x03\x02\x01\x10\ diff --git a/wasm/example-wired-player/src/bindings.rs b/wasm/example-wired-player/src/bindings.rs index f38e4a80e..6e1840c26 100644 --- a/wasm/example-wired-player/src/bindings.rs +++ b/wasm/example-wired-player/src/bindings.rs @@ -494,7 +494,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -540,7 +539,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -848,6 +933,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -7565,8 +7985,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9626] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9dJ\x01A\x02\x01A+\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 10337] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe4O\x01A\x02\x01A+\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -7658,50 +8078,64 @@ t.remove-scene\x01\x0a\x01@\0\0\x06\x04\0\x12[constructor]scene\x01\x0b\x01i\x03 d]scene.transform\x01\x12\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1b[meth\ od]scene.set-transform\x01\x13\x01@\x01\x04self\x09\0\x7f\x04\0\x14[method]scene\ .active\x01\x14\x01@\x02\x04self\x09\x05value\x7f\x01\0\x04\0\x18[method]scene.s\ -et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01BY\x02\ +et-active\x01\x15\x03\x01\x0funavi:scene/api\x05\x11\x02\x03\0\0\x04vec2\x01B}\x02\ \x03\x02\x01\x12\x04\0\x04vec2\x03\0\0\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\ \x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x04\x02\x03\x02\x01\x10\x04\0\x04node\x03\ -\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\ -\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06\ -stacks}\x04\0\x09sphere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\ -\0\x0bsphere-kind\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\ -\0\x12\x04\0\x16[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\ -\x04\0\x16[method]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\ -\x04\0\x1a[method]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\ -\x04\0\x19[method]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\ -\0\x19[method]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\ -\x1a\x01i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinde\ -r\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\ -\x01@\x02\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\ -\x01@\x01\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04se\ -lf\x1d\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[metho\ -d]cylinder.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04\ -self\x1d\0}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05v\ -alue}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylin\ -der.segments\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\ -\0\x17\x04\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18\ -[method]cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01\ -i\x0a\x01@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\ -\x04self(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\ -\x01\0\x04\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[m\ -ethod]cuboid.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-nod\ -e\x01,\x04\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\ -\0-\x04\0\x16[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01\ -h\x11\x01@\x01\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\ -\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\ -\x04\0\x13[method]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17\ -[method]sphere.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-\ -mesh\x014\x01@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e\ -[method]sphere.to-physics-node\x015\x03\x01\x10unavi:shapes/api\x05\x13\x01B\x04\ -\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\x05\ -level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\x14\ -\x01B\x11\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hips\x02\ -\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dleft-sh\ -oulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0eright\ --shoulder\x02\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\x0e\ -left-upper-leg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\x02\ -\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06p\ -layer\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\ +\0\x06\x04\0\x09rectangle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\ +\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\ +\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\ +\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\ +\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]r\ +ectangle\x01\x15\x01h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.\ +size\x01\x17\x01@\x02\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.\ +set-size\x01\x18\x01i\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.\ +to-mesh\x01\x1a\x01i\x07\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.t\ +o-node\x01\x1c\x04\0![method]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\ +\x06radiusv\0\x1d\x04\0\x13[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\ +\x1f\0v\x04\0\x15[method]circle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\ +\0\x04\0\x19[method]circle.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[met\ +hod]circle.resolution\x01\"\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[metho\ +d]circle.set-resolution\x01#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.\ +to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\ +\0\x1e[method]circle.to-physics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\ +\0\x14[constructor]ellipse\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[metho\ +d]ellipse.half-size\x01)\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]e\ +llipse.set-half-size\x01*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resoluti\ +on\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolutio\ +n\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04\ +self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-ph\ +ysics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor\ +]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x01\ +2\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01\ +@\x01\x04self1\0v\x04\0\x17[method]cylinder.height\x014\x01@\x02\x04self1\x05val\ +uev\x01\0\x04\0\x1b[method]cylinder.set-height\x015\x04\0\x17[method]cylinder.ra\ +dius\x014\x04\0\x1b[method]cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b\ +[method]cylinder.resolution\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[met\ +hod]cylinder.set-resolution\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d\ +[method]cylinder.set-segments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cyli\ +nder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\ +\x04\0\x20[method]cylinder.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\ +\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[me\ +thod]cuboid.size\x01=\x01@\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cubo\ +id.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01\ +@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboi\ +d.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sph\ +ere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\ +\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\ +\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[\ +method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[meth\ +od]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-\ +mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\ +\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unavi:shapes/api\x05\x13\x01B\ +\x04\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\ +\x05level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\ +\x14\x01B\x11\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hip\ +s\x02\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dle\ +ft-shoulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0e\ +right-shoulder\x02\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\ +\x0eleft-upper-leg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\ +\x02\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06\ +player\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\ \x07\x01@\x01\x04self\x06\0\x04\x04\0\x17[method]player.skeleton\x01\x08\x01i\x05\ \x01p\x09\x01@\0\0\x0a\x04\0\x0clist-players\x01\x0b\x01@\0\0\x09\x04\0\x0clocal\ -player\x01\x0c\x03\x01\x10wired:player/api\x05\x15\x01B\x15\x02\x03\x02\x01\x10\ diff --git a/wasm/example-wired-scene/src/bindings.rs b/wasm/example-wired-scene/src/bindings.rs index ea06d0c42..ad5be032a 100644 --- a/wasm/example-wired-scene/src/bindings.rs +++ b/wasm/example-wired-scene/src/bindings.rs @@ -16,7 +16,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -62,7 +61,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -370,6 +455,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -6965,17 +7385,6 @@ mod _rt { let layout = alloc::Layout::from_size_align_unchecked(size, align); alloc::dealloc(ptr as *mut u8, layout); } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - } - } else { - val != 0 - } - } pub fn as_i32(t: T) -> i32 { t.as_i32() @@ -7046,6 +7455,17 @@ mod _rt { self as i32 } } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } pub use alloc_crate::alloc; pub use alloc_crate::boxed::Box; @@ -7087,8 +7507,8 @@ pub(crate) use __export_script_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9071] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf2E\x01A\x02\x01A)\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9782] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb9K\x01A\x02\x01A)\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -7168,116 +7588,130 @@ y\x01'\x01h\x09\x01k(\x01@\x02\x04self\x0d\x05value)\x01\0\x04\0\x1b[method]node .set-rigid-body\x01*\x01i\x03\x01k+\x01@\x01\x04self\x0d\0,\x04\0\x1a[method]nod\ e.input-handler\x01-\x01h\x03\x01k.\x01@\x02\x04self\x0d\x05value/\x01\0\x04\0\x1e\ [method]node.set-input-handler\x010\x03\x01\x10wired:scene/node\x05\x0f\x02\x03\0\ -\0\x04vec2\x02\x03\0\x06\x04node\x01BY\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ +\0\x04vec2\x02\x03\0\x06\x04node\x01B}\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ \x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\ \0\x04\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x06\x04\0\x09rectangle\x03\x01\x04\ -\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0a\ -sphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0d\ -\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\0\x0bsphere-kind\x03\0\x0f\x04\0\x06\ -sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x12\x04\0\x16[constructor]rectang\ -le\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\x04\0\x16[method]rectangle.size\x01\ -\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\x04\0\x1a[method]rectangle.set-size\ -\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\x04\0\x19[method]rectangle.to-mesh\x01\ -\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\0\x19[method]rectangle.to-node\x01\x1a\ -\x04\0![method]rectangle.to-physics-node\x01\x1a\x01i\x09\x01@\x02\x06radiusv\x06\ -heightv\0\x1b\x04\0\x15[constructor]cylinder\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\ -\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\x01@\x02\x04self\x1d\x05value\x7f\x01\ -\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\x01@\x01\x04self\x1d\0v\x04\0\x17[m\ -ethod]cylinder.height\x01\x20\x01@\x02\x04self\x1d\x05valuev\x01\0\x04\0\x1b[met\ -hod]cylinder.set-height\x01!\x04\0\x17[method]cylinder.radius\x01\x20\x04\0\x1b[\ -method]cylinder.set-radius\x01!\x01@\x01\x04self\x1d\0}\x04\0\x1b[method]cylinde\ -r.resolution\x01\"\x01@\x02\x04self\x1d\x05value}\x01\0\x04\0\x1f[method]cylinde\ -r.set-resolution\x01#\x04\0\x19[method]cylinder.segments\x01\"\x04\0\x1d[method]\ -cylinder.set-segments\x01#\x01@\x01\x04self\x1d\0\x17\x04\0\x18[method]cylinder.\ -to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18[method]cylinder.to-node\x01%\x04\ -\0\x20[method]cylinder.to-physics-node\x01%\x01i\x0a\x01@\x01\x04size\x03\0&\x04\ -\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\x04self(\0\x03\x04\0\x13[method\ -]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\x01\0\x04\0\x17[method]cuboid.s\ -et-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[method]cuboid.to-mesh\x01+\x01@\x01\ -\x04self(\0\x19\x04\0\x16[method]cuboid.to-node\x01,\x04\0\x1e[method]cuboid.to-\ -physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\0-\x04\0\x16[static]sphere.new-ic\ -o\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01h\x11\x01@\x01\x04self/\0v\x04\0\x15\ -[method]sphere.radius\x010\x01@\x02\x04self/\x05valuev\x01\0\x04\0\x19[method]sp\ -here.set-radius\x011\x01@\x01\x04self/\0\x10\x04\0\x13[method]sphere.kind\x012\x01\ -@\x02\x04self/\x05value\x10\x01\0\x04\0\x17[method]sphere.set-kind\x013\x01@\x01\ -\x04self/\0\x17\x04\0\x16[method]sphere.to-mesh\x014\x01@\x01\x04self/\0\x19\x04\ -\0\x16[method]sphere.to-node\x015\x04\0\x1e[method]sphere.to-physics-node\x015\x03\ -\x01\x10unavi:shapes/api\x05\x12\x01B\x04\x01m\x04\x05debug\x04info\x04warn\x05e\ -rror\x04\0\x09log-level\x03\0\0\x01@\x02\x05level\x01\x07messages\x01\0\x04\0\x03\ -log\x01\x02\x03\x01\x0dwired:log/api\x05\x13\x01B\x11\x02\x03\x02\x01\x11\x04\0\x04\ -node\x03\0\0\x01i\x01\x01r\x14\x04hips\x02\x05spine\x02\x05chest\x02\x0bupper-ch\ -est\x02\x04neck\x02\x04head\x02\x0dleft-shoulder\x02\x0eleft-upper-arm\x02\x0ele\ -ft-lower-arm\x02\x09left-hand\x02\x0eright-shoulder\x02\x0fright-upper-arm\x02\x0f\ -right-lower-arm\x02\x0aright-hand\x02\x0eleft-upper-leg\x02\x0eleft-lower-leg\x02\ -\x09left-foot\x02\x0fright-upper-leg\x02\x0fright-lower-leg\x02\x0aright-foot\x02\ -\x04\0\x08skeleton\x03\0\x03\x04\0\x06player\x03\x01\x01h\x05\x01@\x01\x04self\x06\ -\0\x02\x04\0\x13[method]player.root\x01\x07\x01@\x01\x04self\x06\0\x04\x04\0\x17\ -[method]player.skeleton\x01\x08\x01i\x05\x01p\x09\x01@\0\0\x0a\x04\0\x0clist-pla\ -yers\x01\x0b\x01@\0\0\x09\x04\0\x0clocal-player\x01\x0c\x03\x01\x10wired:player/\ -api\x05\x14\x01B\x15\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\0\x04\0\x05scene\x03\ -\x01\x01i\x02\x01@\0\0\x03\x04\0\x12[constructor]scene\x01\x04\x01h\x02\x01@\x01\ -\x04self\x05\0y\x04\0\x10[method]scene.id\x01\x06\x01@\x01\x04self\x05\0s\x04\0\x12\ -[method]scene.name\x01\x07\x01@\x02\x04self\x05\x05values\x01\0\x04\0\x16[method\ -]scene.set-name\x01\x08\x01i\x01\x01p\x09\x01@\x01\x04self\x05\0\x0a\x04\0\x13[m\ -ethod]scene.nodes\x01\x0b\x01h\x01\x01@\x02\x04self\x05\x05value\x0c\x01\0\x04\0\ -\x16[method]scene.add-node\x01\x0d\x04\0\x19[method]scene.remove-node\x01\x0d\x03\ -\x01\x11wired:scene/scene\x05\x15\x02\x03\0\x0a\x05scene\x01B5\x02\x03\x02\x01\x02\ -\x04\0\x08material\x03\0\0\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x02\x02\x03\x02\ -\x01\x11\x04\0\x04node\x03\0\x04\x02\x03\x02\x01\x16\x04\0\x05scene\x03\0\x06\x04\ -\0\x04gltf\x03\x01\x01i\x08\x01@\0\0\x09\x04\0\x11[constructor]gltf\x01\x0a\x01h\ -\x08\x01i\x01\x01p\x0c\x01@\x01\x04self\x0b\0\x0d\x04\0\x1b[method]gltf.list-mat\ -erials\x01\x0e\x01h\x01\x01@\x02\x04self\x0b\x05value\x0f\x01\0\x04\0\x19[method\ -]gltf.add-material\x01\x10\x04\0\x1c[method]gltf.remove-material\x01\x10\x01i\x03\ -\x01p\x11\x01@\x01\x04self\x0b\0\x12\x04\0\x18[method]gltf.list-meshes\x01\x13\x01\ -h\x03\x01@\x02\x04self\x0b\x05value\x14\x01\0\x04\0\x15[method]gltf.add-mesh\x01\ -\x15\x04\0\x18[method]gltf.remove-mesh\x01\x15\x01i\x05\x01p\x16\x01@\x01\x04sel\ -f\x0b\0\x17\x04\0\x17[method]gltf.list-nodes\x01\x18\x01h\x05\x01@\x02\x04self\x0b\ -\x05value\x19\x01\0\x04\0\x15[method]gltf.add-node\x01\x1a\x04\0\x18[method]gltf\ -.remove-node\x01\x1a\x01i\x07\x01p\x1b\x01@\x01\x04self\x0b\0\x1c\x04\0\x18[meth\ -od]gltf.list-scenes\x01\x1d\x01h\x07\x01@\x02\x04self\x0b\x05value\x1e\x01\0\x04\ -\0\x16[method]gltf.add-scene\x01\x1f\x04\0\x19[method]gltf.remove-scene\x01\x1f\x01\ -k\x1b\x01@\x01\x04self\x0b\0\x20\x04\0\x19[method]gltf.active-scene\x01!\x01k\x1e\ -\x01@\x02\x04self\x0b\x05value\"\x01\0\x04\0\x1d[method]gltf.set-active-scene\x01\ -#\x04\0\x1a[method]gltf.default-scene\x01!\x04\0\x1e[method]gltf.set-default-sce\ -ne\x01\x1f\x03\x01\x10wired:scene/gltf\x05\x17\x02\x03\0\x0b\x04gltf\x01Bt\x02\x03\ -\x02\x01\x18\x04\0\x04gltf\x03\0\0\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x02\x02\ -\x03\x02\x01\x0c\x04\0\x09transform\x03\0\x04\x04\0\x04glxf\x03\x01\x04\0\x0aass\ -et-gltf\x03\x01\x04\0\x0aasset-glxf\x03\x01\x01i\x07\x01i\x08\x01q\x02\x04gltf\x01\ -\x09\0\x04glxf\x01\x0a\0\x04\0\x05asset\x03\0\x0b\x01h\x07\x01h\x08\x01q\x02\x04\ -gltf\x01\x0d\0\x04glxf\x01\x0e\0\x04\0\x0casset-borrow\x03\0\x0f\x04\0\x09glxf-n\ -ode\x03\x01\x01i\x11\x01p\x12\x01q\x02\x05asset\x01\x0c\0\x05nodes\x01\x13\0\x04\ -\0\x08children\x03\0\x14\x01h\x11\x01p\x16\x01q\x02\x05asset\x01\x10\0\x05nodes\x01\ -\x17\0\x04\0\x0fchildren-borrow\x03\0\x18\x04\0\x0aglxf-scene\x03\x01\x01i\x06\x01\ -@\0\0\x1b\x04\0\x11[constructor]glxf\x01\x1c\x01h\x06\x01p\x0c\x01@\x01\x04self\x1d\ -\0\x1e\x04\0\x18[method]glxf.list-assets\x01\x1f\x01@\x02\x04self\x1d\x05value\x10\ -\x01\0\x04\0\x16[method]glxf.add-asset\x01\x20\x04\0\x19[method]glxf.remove-asse\ -t\x01\x20\x01@\x01\x04self\x1d\0\x13\x04\0\x17[method]glxf.list-nodes\x01!\x01@\x02\ -\x04self\x1d\x05value\x16\x01\0\x04\0\x15[method]glxf.add-node\x01\"\x04\0\x18[m\ -ethod]glxf.remove-node\x01\"\x01i\x1a\x01p#\x01@\x01\x04self\x1d\0$\x04\0\x18[me\ -thod]glxf.list-scenes\x01%\x01h\x1a\x01@\x02\x04self\x1d\x05value&\x01\0\x04\0\x16\ -[method]glxf.add-scene\x01'\x04\0\x19[method]glxf.remove-scene\x01'\x01k#\x01@\x01\ -\x04self\x1d\0(\x04\0\x19[method]glxf.active-scene\x01)\x01k&\x01@\x02\x04self\x1d\ -\x05value*\x01\0\x04\0\x1d[method]glxf.set-active-scene\x01+\x04\0\x1a[method]gl\ -xf.default-scene\x01)\x04\0\x1e[method]glxf.set-default-scene\x01'\x01h\x01\x01@\ -\x01\x08document,\0\x09\x04\0\x17[constructor]asset-gltf\x01-\x01i\x01\x01@\x01\x04\ -self\x0d\0.\x04\0\x1b[method]asset-gltf.document\x01/\x01i\x03\x01p0\x01@\x01\x04\ -self\x0d\01\x04\0\x1d[method]asset-gltf.list-nodes\x012\x01h\x03\x01@\x02\x04sel\ -f\x0d\x05value3\x01\0\x04\0\x1b[method]asset-gltf.add-node\x014\x04\0\x1e[method\ -]asset-gltf.remove-node\x014\x01@\x01\x08document\x1d\0\x0a\x04\0\x17[constructo\ -r]asset-glxf\x015\x01@\x01\x04self\x0e\0\x1b\x04\0\x1b[method]asset-glxf.documen\ -t\x016\x01@\x01\x04self\x0e\0\x13\x04\0\x1d[method]asset-glxf.list-nodes\x017\x01\ -@\x02\x04self\x0e\x05value\x16\x01\0\x04\0\x1b[method]asset-glxf.add-node\x018\x04\ -\0\x1e[method]asset-glxf.remove-node\x018\x01@\0\0\x12\x04\0\x16[constructor]glx\ -f-node\x019\x01@\x01\x04self\x16\0y\x04\0\x14[method]glxf-node.id\x01:\x01@\x01\x04\ -self\x16\0s\x04\0\x16[method]glxf-node.name\x01;\x01@\x02\x04self\x16\x05values\x01\ -\0\x04\0\x1a[method]glxf-node.set-name\x01<\x01@\x01\x04self\x16\0\x05\x04\0\x1b\ -[method]glxf-node.transform\x01=\x01@\x02\x04self\x16\x05value\x05\x01\0\x04\0\x1f\ -[method]glxf-node.set-transform\x01>\x01k\x12\x01@\x01\x04self\x16\0?\x04\0\x18[\ -method]glxf-node.parent\x01@\x01k\x15\x01@\x01\x04self\x16\0\xc1\0\x04\0\x1a[met\ -hod]glxf-node.children\x01B\x01k\x19\x01@\x02\x04self\x16\x05value\xc3\0\x01\0\x04\ -\0\x1e[method]glxf-node.set-children\x01D\x01@\0\0#\x04\0\x17[constructor]glxf-s\ -cene\x01E\x01@\x01\x04self&\0y\x04\0\x15[method]glxf-scene.id\x01F\x01@\x01\x04s\ -elf&\0s\x04\0\x17[method]glxf-scene.name\x01G\x01@\x02\x04self&\x05values\x01\0\x04\ +\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06\ +cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07\ +sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\ +\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\ +\x04size\x01\0\x14\x04\0\x16[constructor]rectangle\x01\x15\x01h\x08\x01@\x01\x04\ +self\x16\0\x01\x04\0\x16[method]rectangle.size\x01\x17\x01@\x02\x04self\x16\x05v\ +alue\x01\x01\0\x04\0\x1a[method]rectangle.set-size\x01\x18\x01i\x05\x01@\x01\x04\ +self\x16\0\x19\x04\0\x19[method]rectangle.to-mesh\x01\x1a\x01i\x07\x01@\x01\x04s\ +elf\x16\0\x1b\x04\0\x19[method]rectangle.to-node\x01\x1c\x04\0![method]rectangle\ +.to-physics-node\x01\x1c\x01i\x09\x01@\x01\x06radiusv\0\x1d\x04\0\x13[constructo\ +r]circle\x01\x1e\x01h\x09\x01@\x01\x04self\x1f\0v\x04\0\x15[method]circle.radius\ +\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\0\x04\0\x19[method]circle.set-radius\ +\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[method]circle.resolution\x01\"\x01@\x02\x04\ +self\x1f\x05value{\x01\0\x04\0\x1d[method]circle.set-resolution\x01#\x01@\x01\x04\ +self\x1f\0\x19\x04\0\x16[method]circle.to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\ +\0\x16[method]circle.to-node\x01%\x04\0\x1e[method]circle.to-physics-node\x01%\x01\ +i\x0a\x01@\x01\x09half-size\x01\0&\x04\0\x14[constructor]ellipse\x01'\x01h\x0a\x01\ +@\x01\x04self(\0\x01\x04\0\x19[method]ellipse.half-size\x01)\x01@\x02\x04self(\x05\ +value\x01\x01\0\x04\0\x1d[method]ellipse.set-half-size\x01*\x01@\x01\x04self(\0{\ +\x04\0\x1a[method]ellipse.resolution\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\ +\x1e[method]ellipse.set-resolution\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method\ +]ellipse.to-mesh\x01-\x01@\x01\x04self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01\ +.\x04\0\x1f[method]ellipse.to-physics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06\ +heightv\0/\x04\0\x15[constructor]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\ +\0\x14[method]cylinder.cap\x012\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[m\ +ethod]cylinder.set-cap\x013\x01@\x01\x04self1\0v\x04\0\x17[method]cylinder.heigh\ +t\x014\x01@\x02\x04self1\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01\ +5\x04\0\x17[method]cylinder.radius\x014\x04\0\x1b[method]cylinder.set-radius\x01\ +5\x01@\x01\x04self1\0}\x04\0\x1b[method]cylinder.resolution\x016\x01@\x02\x04sel\ +f1\x05value}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x017\x04\0\x19[metho\ +d]cylinder.segments\x016\x04\0\x1d[method]cylinder.set-segments\x017\x01@\x01\x04\ +self1\0\x19\x04\0\x18[method]cylinder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\ +\x18[method]cylinder.to-node\x019\x04\0\x20[method]cylinder.to-physics-node\x019\ +\x01i\x0c\x01@\x01\x04size\x03\0:\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01\ +@\x01\x04self<\0\x03\x04\0\x13[method]cuboid.size\x01=\x01@\x02\x04self<\x05valu\ +e\x03\x01\0\x04\0\x17[method]cuboid.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16\ +[method]cuboid.to-mesh\x01?\x01@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-n\ +ode\x01@\x04\0\x1e[method]cuboid.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiu\ +sv\0\xc1\0\x04\0\x16[static]sphere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01\ +B\x01h\x13\x01@\x01\x04self\xc3\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\ +\x04self\xc3\0\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04\ +self\xc3\0\0\x12\x04\0\x13[method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05val\ +ue\x12\x01\0\x04\0\x17[method]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\ +\0\x16[method]sphere.to-mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]\ +sphere.to-node\x01I\x04\0\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unav\ +i:shapes/api\x05\x12\x01B\x04\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09\ +log-level\x03\0\0\x01@\x02\x05level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\ +\x01\x0dwired:log/api\x05\x13\x01B\x11\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\0\ +\x01i\x01\x01r\x14\x04hips\x02\x05spine\x02\x05chest\x02\x0bupper-chest\x02\x04n\ +eck\x02\x04head\x02\x0dleft-shoulder\x02\x0eleft-upper-arm\x02\x0eleft-lower-arm\ +\x02\x09left-hand\x02\x0eright-shoulder\x02\x0fright-upper-arm\x02\x0fright-lowe\ +r-arm\x02\x0aright-hand\x02\x0eleft-upper-leg\x02\x0eleft-lower-leg\x02\x09left-\ +foot\x02\x0fright-upper-leg\x02\x0fright-lower-leg\x02\x0aright-foot\x02\x04\0\x08\ +skeleton\x03\0\x03\x04\0\x06player\x03\x01\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\ +\0\x13[method]player.root\x01\x07\x01@\x01\x04self\x06\0\x04\x04\0\x17[method]pl\ +ayer.skeleton\x01\x08\x01i\x05\x01p\x09\x01@\0\0\x0a\x04\0\x0clist-players\x01\x0b\ +\x01@\0\0\x09\x04\0\x0clocal-player\x01\x0c\x03\x01\x10wired:player/api\x05\x14\x01\ +B\x15\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\0\x04\0\x05scene\x03\x01\x01i\x02\x01\ +@\0\0\x03\x04\0\x12[constructor]scene\x01\x04\x01h\x02\x01@\x01\x04self\x05\0y\x04\ +\0\x10[method]scene.id\x01\x06\x01@\x01\x04self\x05\0s\x04\0\x12[method]scene.na\ +me\x01\x07\x01@\x02\x04self\x05\x05values\x01\0\x04\0\x16[method]scene.set-name\x01\ +\x08\x01i\x01\x01p\x09\x01@\x01\x04self\x05\0\x0a\x04\0\x13[method]scene.nodes\x01\ +\x0b\x01h\x01\x01@\x02\x04self\x05\x05value\x0c\x01\0\x04\0\x16[method]scene.add\ +-node\x01\x0d\x04\0\x19[method]scene.remove-node\x01\x0d\x03\x01\x11wired:scene/\ +scene\x05\x15\x02\x03\0\x0a\x05scene\x01B5\x02\x03\x02\x01\x02\x04\0\x08material\ +\x03\0\0\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x02\x02\x03\x02\x01\x11\x04\0\x04\ +node\x03\0\x04\x02\x03\x02\x01\x16\x04\0\x05scene\x03\0\x06\x04\0\x04gltf\x03\x01\ +\x01i\x08\x01@\0\0\x09\x04\0\x11[constructor]gltf\x01\x0a\x01h\x08\x01i\x01\x01p\ +\x0c\x01@\x01\x04self\x0b\0\x0d\x04\0\x1b[method]gltf.list-materials\x01\x0e\x01\ +h\x01\x01@\x02\x04self\x0b\x05value\x0f\x01\0\x04\0\x19[method]gltf.add-material\ +\x01\x10\x04\0\x1c[method]gltf.remove-material\x01\x10\x01i\x03\x01p\x11\x01@\x01\ +\x04self\x0b\0\x12\x04\0\x18[method]gltf.list-meshes\x01\x13\x01h\x03\x01@\x02\x04\ +self\x0b\x05value\x14\x01\0\x04\0\x15[method]gltf.add-mesh\x01\x15\x04\0\x18[met\ +hod]gltf.remove-mesh\x01\x15\x01i\x05\x01p\x16\x01@\x01\x04self\x0b\0\x17\x04\0\x17\ +[method]gltf.list-nodes\x01\x18\x01h\x05\x01@\x02\x04self\x0b\x05value\x19\x01\0\ +\x04\0\x15[method]gltf.add-node\x01\x1a\x04\0\x18[method]gltf.remove-node\x01\x1a\ +\x01i\x07\x01p\x1b\x01@\x01\x04self\x0b\0\x1c\x04\0\x18[method]gltf.list-scenes\x01\ +\x1d\x01h\x07\x01@\x02\x04self\x0b\x05value\x1e\x01\0\x04\0\x16[method]gltf.add-\ +scene\x01\x1f\x04\0\x19[method]gltf.remove-scene\x01\x1f\x01k\x1b\x01@\x01\x04se\ +lf\x0b\0\x20\x04\0\x19[method]gltf.active-scene\x01!\x01k\x1e\x01@\x02\x04self\x0b\ +\x05value\"\x01\0\x04\0\x1d[method]gltf.set-active-scene\x01#\x04\0\x1a[method]g\ +ltf.default-scene\x01!\x04\0\x1e[method]gltf.set-default-scene\x01\x1f\x03\x01\x10\ +wired:scene/gltf\x05\x17\x02\x03\0\x0b\x04gltf\x01Bt\x02\x03\x02\x01\x18\x04\0\x04\ +gltf\x03\0\0\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x02\x02\x03\x02\x01\x0c\x04\ +\0\x09transform\x03\0\x04\x04\0\x04glxf\x03\x01\x04\0\x0aasset-gltf\x03\x01\x04\0\ +\x0aasset-glxf\x03\x01\x01i\x07\x01i\x08\x01q\x02\x04gltf\x01\x09\0\x04glxf\x01\x0a\ +\0\x04\0\x05asset\x03\0\x0b\x01h\x07\x01h\x08\x01q\x02\x04gltf\x01\x0d\0\x04glxf\ +\x01\x0e\0\x04\0\x0casset-borrow\x03\0\x0f\x04\0\x09glxf-node\x03\x01\x01i\x11\x01\ +p\x12\x01q\x02\x05asset\x01\x0c\0\x05nodes\x01\x13\0\x04\0\x08children\x03\0\x14\ +\x01h\x11\x01p\x16\x01q\x02\x05asset\x01\x10\0\x05nodes\x01\x17\0\x04\0\x0fchild\ +ren-borrow\x03\0\x18\x04\0\x0aglxf-scene\x03\x01\x01i\x06\x01@\0\0\x1b\x04\0\x11\ +[constructor]glxf\x01\x1c\x01h\x06\x01p\x0c\x01@\x01\x04self\x1d\0\x1e\x04\0\x18\ +[method]glxf.list-assets\x01\x1f\x01@\x02\x04self\x1d\x05value\x10\x01\0\x04\0\x16\ +[method]glxf.add-asset\x01\x20\x04\0\x19[method]glxf.remove-asset\x01\x20\x01@\x01\ +\x04self\x1d\0\x13\x04\0\x17[method]glxf.list-nodes\x01!\x01@\x02\x04self\x1d\x05\ +value\x16\x01\0\x04\0\x15[method]glxf.add-node\x01\"\x04\0\x18[method]glxf.remov\ +e-node\x01\"\x01i\x1a\x01p#\x01@\x01\x04self\x1d\0$\x04\0\x18[method]glxf.list-s\ +cenes\x01%\x01h\x1a\x01@\x02\x04self\x1d\x05value&\x01\0\x04\0\x16[method]glxf.a\ +dd-scene\x01'\x04\0\x19[method]glxf.remove-scene\x01'\x01k#\x01@\x01\x04self\x1d\ +\0(\x04\0\x19[method]glxf.active-scene\x01)\x01k&\x01@\x02\x04self\x1d\x05value*\ +\x01\0\x04\0\x1d[method]glxf.set-active-scene\x01+\x04\0\x1a[method]glxf.default\ +-scene\x01)\x04\0\x1e[method]glxf.set-default-scene\x01'\x01h\x01\x01@\x01\x08do\ +cument,\0\x09\x04\0\x17[constructor]asset-gltf\x01-\x01i\x01\x01@\x01\x04self\x0d\ +\0.\x04\0\x1b[method]asset-gltf.document\x01/\x01i\x03\x01p0\x01@\x01\x04self\x0d\ +\01\x04\0\x1d[method]asset-gltf.list-nodes\x012\x01h\x03\x01@\x02\x04self\x0d\x05\ +value3\x01\0\x04\0\x1b[method]asset-gltf.add-node\x014\x04\0\x1e[method]asset-gl\ +tf.remove-node\x014\x01@\x01\x08document\x1d\0\x0a\x04\0\x17[constructor]asset-g\ +lxf\x015\x01@\x01\x04self\x0e\0\x1b\x04\0\x1b[method]asset-glxf.document\x016\x01\ +@\x01\x04self\x0e\0\x13\x04\0\x1d[method]asset-glxf.list-nodes\x017\x01@\x02\x04\ +self\x0e\x05value\x16\x01\0\x04\0\x1b[method]asset-glxf.add-node\x018\x04\0\x1e[\ +method]asset-glxf.remove-node\x018\x01@\0\0\x12\x04\0\x16[constructor]glxf-node\x01\ +9\x01@\x01\x04self\x16\0y\x04\0\x14[method]glxf-node.id\x01:\x01@\x01\x04self\x16\ +\0s\x04\0\x16[method]glxf-node.name\x01;\x01@\x02\x04self\x16\x05values\x01\0\x04\ +\0\x1a[method]glxf-node.set-name\x01<\x01@\x01\x04self\x16\0\x05\x04\0\x1b[metho\ +d]glxf-node.transform\x01=\x01@\x02\x04self\x16\x05value\x05\x01\0\x04\0\x1f[met\ +hod]glxf-node.set-transform\x01>\x01k\x12\x01@\x01\x04self\x16\0?\x04\0\x18[meth\ +od]glxf-node.parent\x01@\x01k\x15\x01@\x01\x04self\x16\0\xc1\0\x04\0\x1a[method]\ +glxf-node.children\x01B\x01k\x19\x01@\x02\x04self\x16\x05value\xc3\0\x01\0\x04\0\ +\x1e[method]glxf-node.set-children\x01D\x01@\0\0#\x04\0\x17[constructor]glxf-sce\ +ne\x01E\x01@\x01\x04self&\0y\x04\0\x15[method]glxf-scene.id\x01F\x01@\x01\x04sel\ +f&\0s\x04\0\x17[method]glxf-scene.name\x01G\x01@\x02\x04self&\x05values\x01\0\x04\ \0\x1b[method]glxf-scene.set-name\x01H\x01@\x01\x04self&\0\x13\x04\0\x18[method]\ glxf-scene.nodes\x01I\x01@\x02\x04self&\x04node\x16\x01\0\x04\0\x1b[method]glxf-\ scene.add-node\x01J\x04\0\x1e[method]glxf-scene.remove-node\x01J\x04\0\x08get-ro\ diff --git a/wasm/unavi-shapes/src/bindings.rs b/wasm/unavi-shapes/src/bindings.rs index b72229a3c..34346c0d0 100644 --- a/wasm/unavi-shapes/src/bindings.rs +++ b/wasm/unavi-shapes/src/bindings.rs @@ -2966,7 +2966,6 @@ pub mod exports { pub type Vec3 = super::super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -3108,7 +3107,285 @@ pub mod exports { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + type _CircleRep = Option; + + impl Circle { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Circle`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CircleRep = Some(val); + let ptr: *mut _CircleRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCircle` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CircleRep); + } + + fn as_ptr(&self) -> *mut _CircleRep { + Circle::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Circle`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CircleBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Circle>, + } + + impl<'a> CircleBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CircleRep { + Circle::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + type _EllipseRep = Option; + + impl Ellipse { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Ellipse`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _EllipseRep = Some(val); + let ptr: *mut _EllipseRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestEllipse` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _EllipseRep); + } + + fn as_ptr(&self) -> *mut _EllipseRep { + Ellipse::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Ellipse`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct EllipseBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Ellipse>, + } + + impl<'a> EllipseBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _EllipseRep { + Ellipse::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -3530,71 +3807,223 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Sphere>, } - - impl<'a> SphereBorrow<'a> { - #[doc(hidden)] - pub unsafe fn lift(rep: usize) -> Self { - Self { - rep: rep as *mut u8, - _marker: core::marker::PhantomData, - } - } - - /// Gets access to the underlying `T` in this resource. - pub fn get(&self) -> &T { - let ptr = unsafe { &mut *self.as_ptr::() }; - ptr.as_ref().unwrap() - } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - - fn as_ptr(&self) -> *mut _SphereRep { - Sphere::type_guard::(); - self.rep.cast() - } + + impl<'a> SphereBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _SphereRep { + Sphere::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Sphere { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]sphere"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_rectangle_cabi( + arg0: f32, + arg1: f32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = Rectangle::new(T::new( + super::super::super::super::wired::math::types::Vec2 { x: arg0, y: arg1 }, + )); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_rectangle_size_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::size(RectangleBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let super::super::super::super::wired::math::types::Vec2 { x: x2, y: y2 } = + result0; + *ptr1.add(0).cast::() = _rt::as_f32(x2); + *ptr1.add(4).cast::() = _rt::as_f32(y2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_rectangle_set_size_cabi( + arg0: *mut u8, + arg1: f32, + arg2: f32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::set_size( + RectangleBorrow::lift(arg0 as u32 as usize).get(), + super::super::super::super::wired::math::types::Vec2 { x: arg1, y: arg2 }, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_rectangle_to_mesh_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::to_mesh(RectangleBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_rectangle_to_node_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::to_node(RectangleBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_rectangle_to_physics_node_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::to_physics_node(RectangleBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_circle_cabi(arg0: f32) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = Circle::new(T::new(arg0)); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_circle_radius_cabi( + arg0: *mut u8, + ) -> f32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::radius(CircleBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_f32(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_circle_set_radius_cabi( + arg0: *mut u8, + arg1: f32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::set_radius(CircleBorrow::lift(arg0 as u32 as usize).get(), arg1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_circle_resolution_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::resolution(CircleBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i32(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_circle_set_resolution_cabi( + arg0: *mut u8, + arg1: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::set_resolution(CircleBorrow::lift(arg0 as u32 as usize).get(), arg1 as u16); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_circle_to_mesh_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::to_mesh(CircleBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 } - - unsafe impl _rt::WasmResource for Sphere { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]unavi:shapes/api")] - extern "C" { - #[link_name = "[resource-drop]sphere"] - fn drop(_: u32); - } - - drop(_handle); - } - } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_circle_to_node_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::to_node(CircleBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 } - #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_constructor_rectangle_cabi( + pub unsafe fn _export_method_circle_to_physics_node_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::to_physics_node(CircleBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_ellipse_cabi( arg0: f32, arg1: f32, ) -> i32 { #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - let result0 = Rectangle::new(T::new( + let result0 = Ellipse::new(T::new( super::super::super::super::wired::math::types::Vec2 { x: arg0, y: arg1 }, )); (result0).take_handle() as i32 } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_rectangle_size_cabi( + pub unsafe fn _export_method_ellipse_half_size_cabi( arg0: *mut u8, ) -> *mut u8 { #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - let result0 = T::size(RectangleBorrow::lift(arg0 as u32 as usize).get()); + let result0 = T::half_size(EllipseBorrow::lift(arg0 as u32 as usize).get()); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let super::super::super::super::wired::math::types::Vec2 { x: x2, y: y2 } = result0; @@ -3604,47 +4033,67 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_rectangle_set_size_cabi( + pub unsafe fn _export_method_ellipse_set_half_size_cabi( arg0: *mut u8, arg1: f32, arg2: f32, ) { #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - T::set_size( - RectangleBorrow::lift(arg0 as u32 as usize).get(), + T::set_half_size( + EllipseBorrow::lift(arg0 as u32 as usize).get(), super::super::super::super::wired::math::types::Vec2 { x: arg1, y: arg2 }, ); } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_rectangle_to_mesh_cabi( + pub unsafe fn _export_method_ellipse_resolution_cabi( arg0: *mut u8, ) -> i32 { #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - let result0 = T::to_mesh(RectangleBorrow::lift(arg0 as u32 as usize).get()); + let result0 = T::resolution(EllipseBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i32(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_ellipse_set_resolution_cabi( + arg0: *mut u8, + arg1: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::set_resolution(EllipseBorrow::lift(arg0 as u32 as usize).get(), arg1 as u16); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_ellipse_to_mesh_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::to_mesh(EllipseBorrow::lift(arg0 as u32 as usize).get()); (result0).take_handle() as i32 } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_rectangle_to_node_cabi( + pub unsafe fn _export_method_ellipse_to_node_cabi( arg0: *mut u8, ) -> i32 { #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - let result0 = T::to_node(RectangleBorrow::lift(arg0 as u32 as usize).get()); + let result0 = T::to_node(EllipseBorrow::lift(arg0 as u32 as usize).get()); (result0).take_handle() as i32 } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_rectangle_to_physics_node_cabi( + pub unsafe fn _export_method_ellipse_to_physics_node_cabi( arg0: *mut u8, ) -> i32 { #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = - T::to_physics_node(RectangleBorrow::lift(arg0 as u32 as usize).get()); + T::to_physics_node(EllipseBorrow::lift(arg0 as u32 as usize).get()); (result0).take_handle() as i32 } #[doc(hidden)] @@ -4008,6 +4457,8 @@ pub mod exports { } pub trait Guest { type Rectangle: GuestRectangle; + type Circle: GuestCircle; + type Ellipse: GuestEllipse; type Cylinder: GuestCylinder; type Cuboid: GuestCuboid; type Sphere: GuestSphere; @@ -4067,6 +4518,122 @@ pub mod exports { /// Creates a node with a mesh and physics collider of this shape. fn to_physics_node(&self) -> Node; } + pub trait GuestCircle: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-new]circle"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-rep]circle"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(radius: f32) -> Self; + fn radius(&self) -> f32; + fn set_radius(&self, value: f32); + /// The number of vertices used for the mesh. + fn resolution(&self) -> u16; + fn set_resolution(&self, value: u16); + /// Creates a mesh of this shape. + fn to_mesh(&self) -> Mesh; + /// Creates a node with a mesh of this shape. + fn to_node(&self) -> Node; + /// Creates a node with a mesh and physics collider of this shape. + fn to_physics_node(&self) -> Node; + } + pub trait GuestEllipse: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-new]ellipse"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-rep]ellipse"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(half_size: Vec2) -> Self; + fn half_size(&self) -> Vec2; + fn set_half_size(&self, value: Vec2); + /// The number of vertices used for the mesh. + fn resolution(&self) -> u16; + fn set_resolution(&self, value: u16); + /// Creates a mesh of this shape. + fn to_mesh(&self) -> Mesh; + /// Creates a node with a mesh of this shape. + fn to_node(&self) -> Node; + /// Creates a node with a mesh and physics collider of this shape. + fn to_physics_node(&self) -> Node; + } pub trait GuestCylinder: 'static { #[doc(hidden)] unsafe fn _resource_new(val: *mut u8) -> u32 @@ -4275,6 +4842,70 @@ pub mod exports { unsafe extern "C" fn export_method_rectangle_to_physics_node(arg0: *mut u8,) -> i32 { $($path_to_types)*::_export_method_rectangle_to_physics_node_cabi::<<$ty as $($path_to_types)*::Guest>::Rectangle>(arg0) } + #[export_name = "unavi:shapes/api#[constructor]circle"] + unsafe extern "C" fn export_constructor_circle(arg0: f32,) -> i32 { + $($path_to_types)*::_export_constructor_circle_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0) + } + #[export_name = "unavi:shapes/api#[method]circle.radius"] + unsafe extern "C" fn export_method_circle_radius(arg0: *mut u8,) -> f32 { + $($path_to_types)*::_export_method_circle_radius_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0) + } + #[export_name = "unavi:shapes/api#[method]circle.set-radius"] + unsafe extern "C" fn export_method_circle_set_radius(arg0: *mut u8,arg1: f32,) { + $($path_to_types)*::_export_method_circle_set_radius_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0, arg1) + } + #[export_name = "unavi:shapes/api#[method]circle.resolution"] + unsafe extern "C" fn export_method_circle_resolution(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_circle_resolution_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0) + } + #[export_name = "unavi:shapes/api#[method]circle.set-resolution"] + unsafe extern "C" fn export_method_circle_set_resolution(arg0: *mut u8,arg1: i32,) { + $($path_to_types)*::_export_method_circle_set_resolution_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0, arg1) + } + #[export_name = "unavi:shapes/api#[method]circle.to-mesh"] + unsafe extern "C" fn export_method_circle_to_mesh(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_circle_to_mesh_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0) + } + #[export_name = "unavi:shapes/api#[method]circle.to-node"] + unsafe extern "C" fn export_method_circle_to_node(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_circle_to_node_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0) + } + #[export_name = "unavi:shapes/api#[method]circle.to-physics-node"] + unsafe extern "C" fn export_method_circle_to_physics_node(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_circle_to_physics_node_cabi::<<$ty as $($path_to_types)*::Guest>::Circle>(arg0) + } + #[export_name = "unavi:shapes/api#[constructor]ellipse"] + unsafe extern "C" fn export_constructor_ellipse(arg0: f32,arg1: f32,) -> i32 { + $($path_to_types)*::_export_constructor_ellipse_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0, arg1) + } + #[export_name = "unavi:shapes/api#[method]ellipse.half-size"] + unsafe extern "C" fn export_method_ellipse_half_size(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_ellipse_half_size_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0) + } + #[export_name = "unavi:shapes/api#[method]ellipse.set-half-size"] + unsafe extern "C" fn export_method_ellipse_set_half_size(arg0: *mut u8,arg1: f32,arg2: f32,) { + $($path_to_types)*::_export_method_ellipse_set_half_size_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0, arg1, arg2) + } + #[export_name = "unavi:shapes/api#[method]ellipse.resolution"] + unsafe extern "C" fn export_method_ellipse_resolution(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_ellipse_resolution_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0) + } + #[export_name = "unavi:shapes/api#[method]ellipse.set-resolution"] + unsafe extern "C" fn export_method_ellipse_set_resolution(arg0: *mut u8,arg1: i32,) { + $($path_to_types)*::_export_method_ellipse_set_resolution_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0, arg1) + } + #[export_name = "unavi:shapes/api#[method]ellipse.to-mesh"] + unsafe extern "C" fn export_method_ellipse_to_mesh(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_ellipse_to_mesh_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0) + } + #[export_name = "unavi:shapes/api#[method]ellipse.to-node"] + unsafe extern "C" fn export_method_ellipse_to_node(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_ellipse_to_node_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0) + } + #[export_name = "unavi:shapes/api#[method]ellipse.to-physics-node"] + unsafe extern "C" fn export_method_ellipse_to_physics_node(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_ellipse_to_physics_node_cabi::<<$ty as $($path_to_types)*::Guest>::Ellipse>(arg0) + } #[export_name = "unavi:shapes/api#[constructor]cylinder"] unsafe extern "C" fn export_constructor_cylinder(arg0: f32,arg1: f32,) -> i32 { $($path_to_types)*::_export_constructor_cylinder_cabi::<<$ty as $($path_to_types)*::Guest>::Cylinder>(arg0, arg1) @@ -4404,6 +5035,30 @@ pub mod exports { }; + const _: () = { + #[doc(hidden)] + #[export_name = "unavi:shapes/api#[dtor]circle"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Circle::dtor::< + <$ty as $($path_to_types)*::Guest>::Circle + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "unavi:shapes/api#[dtor]ellipse"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Ellipse::dtor::< + <$ty as $($path_to_types)*::Guest>::Ellipse + >(rep) + } + }; + + const _: () = { #[doc(hidden)] #[export_name = "unavi:shapes/api#[dtor]cylinder"] @@ -4596,17 +5251,6 @@ mod _rt { pub fn run_ctors_once() { wit_bindgen_rt::run_ctors_once(); } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - } - } else { - val != 0 - } - } pub fn as_i32(t: T) -> i32 { t.as_i32() @@ -4677,6 +5321,17 @@ mod _rt { self as i32 } } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } extern crate alloc as alloc_crate; pub use alloc_crate::alloc; } @@ -4712,8 +5367,8 @@ pub(crate) use __export_guest_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:guest:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 5363] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf7(\x01A\x02\x01A\x1d\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6074] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xbe.\x01A\x02\x01A\x1d\ \x01B\x04\x01m\x04\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01\ @\x02\x05level\x01\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/a\ pi\x05\0\x01B\x13\x01r\x04\x01rv\x01gv\x01bv\x01av\x04\0\x05color\x03\0\0\x04\0\x08\ @@ -4795,43 +5450,57 @@ rigid-body\x01'\x01h\x09\x01k(\x01@\x02\x04self\x0d\x05value)\x01\0\x04\0\x1b[me thod]node.set-rigid-body\x01*\x01i\x03\x01k+\x01@\x01\x04self\x0d\0,\x04\0\x1a[m\ ethod]node.input-handler\x01-\x01h\x03\x01k.\x01@\x02\x04self\x0d\x05value/\x01\0\ \x04\0\x1e[method]node.set-input-handler\x010\x03\x01\x10wired:scene/node\x05\x10\ -\x02\x03\0\x03\x04vec2\x02\x03\0\x07\x04node\x01BY\x02\x03\x02\x01\x11\x04\0\x04\ +\x02\x03\0\x03\x04vec2\x02\x03\0\x07\x04node\x01B}\x02\x03\x02\x01\x11\x04\0\x04\ vec2\x03\0\0\x02\x03\x02\x01\x05\x04\0\x04vec3\x03\0\x02\x02\x03\x02\x01\x0b\x04\ \0\x04mesh\x03\0\x04\x02\x03\x02\x01\x12\x04\0\x04node\x03\0\x06\x04\0\x09rectan\ -gle\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdiv\ -isions}\x04\0\x0asphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06stacks}\x04\0\x09s\ -phere-uv\x03\0\x0d\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\0\x0bsphere-kin\ -d\x03\0\x0f\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x12\x04\0\x16\ -[constructor]rectangle\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\x04\0\x16[met\ -hod]rectangle.size\x01\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\x04\0\x1a[met\ -hod]rectangle.set-size\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\x04\0\x19[met\ -hod]rectangle.to-mesh\x01\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\0\x19[meth\ -od]rectangle.to-node\x01\x1a\x04\0![method]rectangle.to-physics-node\x01\x1a\x01\ -i\x09\x01@\x02\x06radiusv\x06heightv\0\x1b\x04\0\x15[constructor]cylinder\x01\x1c\ -\x01h\x09\x01@\x01\x04self\x1d\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\x01@\x02\ -\x04self\x1d\x05value\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\x01@\x01\ -\x04self\x1d\0v\x04\0\x17[method]cylinder.height\x01\x20\x01@\x02\x04self\x1d\x05\ -valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01!\x04\0\x17[method]cylinder\ -.radius\x01\x20\x04\0\x1b[method]cylinder.set-radius\x01!\x01@\x01\x04self\x1d\0\ -}\x04\0\x1b[method]cylinder.resolution\x01\"\x01@\x02\x04self\x1d\x05value}\x01\0\ -\x04\0\x1f[method]cylinder.set-resolution\x01#\x04\0\x19[method]cylinder.segment\ -s\x01\"\x04\0\x1d[method]cylinder.set-segments\x01#\x01@\x01\x04self\x1d\0\x17\x04\ -\0\x18[method]cylinder.to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18[method]\ -cylinder.to-node\x01%\x04\0\x20[method]cylinder.to-physics-node\x01%\x01i\x0a\x01\ -@\x01\x04size\x03\0&\x04\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\x04self\ -(\0\x03\x04\0\x13[method]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\x01\0\x04\ -\0\x17[method]cuboid.set-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[method]cubo\ -id.to-mesh\x01+\x01@\x01\x04self(\0\x19\x04\0\x16[method]cuboid.to-node\x01,\x04\ -\0\x1e[method]cuboid.to-physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\0-\x04\0\x16\ -[static]sphere.new-ico\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01h\x11\x01@\x01\ -\x04self/\0v\x04\0\x15[method]sphere.radius\x010\x01@\x02\x04self/\x05valuev\x01\ -\0\x04\0\x19[method]sphere.set-radius\x011\x01@\x01\x04self/\0\x10\x04\0\x13[met\ -hod]sphere.kind\x012\x01@\x02\x04self/\x05value\x10\x01\0\x04\0\x17[method]spher\ -e.set-kind\x013\x01@\x01\x04self/\0\x17\x04\0\x16[method]sphere.to-mesh\x014\x01\ -@\x01\x04self/\0\x19\x04\0\x16[method]sphere.to-node\x015\x04\0\x1e[method]spher\ -e.to-physics-node\x015\x04\x01\x10unavi:shapes/api\x05\x13\x04\x01\x12unavi:shap\ -es/guest\x04\0\x0b\x0b\x01\0\x05guest\x03\0\0\0G\x09producers\x01\x0cprocessed-b\ -y\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; +gle\x03\x01\x04\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\x04\0\x08cylinder\x03\ +\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\ +\x0d\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0f\x01q\x02\x03ic\ +o\x01\x0e\0\x02uv\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\0\x06sphere\x03\x01\ +\x01i\x08\x01@\x01\x04size\x01\0\x14\x04\0\x16[constructor]rectangle\x01\x15\x01\ +h\x08\x01@\x01\x04self\x16\0\x01\x04\0\x16[method]rectangle.size\x01\x17\x01@\x02\ +\x04self\x16\x05value\x01\x01\0\x04\0\x1a[method]rectangle.set-size\x01\x18\x01i\ +\x05\x01@\x01\x04self\x16\0\x19\x04\0\x19[method]rectangle.to-mesh\x01\x1a\x01i\x07\ +\x01@\x01\x04self\x16\0\x1b\x04\0\x19[method]rectangle.to-node\x01\x1c\x04\0![me\ +thod]rectangle.to-physics-node\x01\x1c\x01i\x09\x01@\x01\x06radiusv\0\x1d\x04\0\x13\ +[constructor]circle\x01\x1e\x01h\x09\x01@\x01\x04self\x1f\0v\x04\0\x15[method]ci\ +rcle.radius\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\0\x04\0\x19[method]circle\ +.set-radius\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[method]circle.resolution\x01\"\ +\x01@\x02\x04self\x1f\x05value{\x01\0\x04\0\x1d[method]circle.set-resolution\x01\ +#\x01@\x01\x04self\x1f\0\x19\x04\0\x16[method]circle.to-mesh\x01$\x01@\x01\x04se\ +lf\x1f\0\x1b\x04\0\x16[method]circle.to-node\x01%\x04\0\x1e[method]circle.to-phy\ +sics-node\x01%\x01i\x0a\x01@\x01\x09half-size\x01\0&\x04\0\x14[constructor]ellip\ +se\x01'\x01h\x0a\x01@\x01\x04self(\0\x01\x04\0\x19[method]ellipse.half-size\x01)\ +\x01@\x02\x04self(\x05value\x01\x01\0\x04\0\x1d[method]ellipse.set-half-size\x01\ +*\x01@\x01\x04self(\0{\x04\0\x1a[method]ellipse.resolution\x01+\x01@\x02\x04self\ +(\x05value{\x01\0\x04\0\x1e[method]ellipse.set-resolution\x01,\x01@\x01\x04self(\ +\0\x19\x04\0\x17[method]ellipse.to-mesh\x01-\x01@\x01\x04self(\0\x1b\x04\0\x17[m\ +ethod]ellipse.to-node\x01.\x04\0\x1f[method]ellipse.to-physics-node\x01.\x01i\x0b\ +\x01@\x02\x06radiusv\x06heightv\0/\x04\0\x15[constructor]cylinder\x010\x01h\x0b\x01\ +@\x01\x04self1\0\x7f\x04\0\x14[method]cylinder.cap\x012\x01@\x02\x04self1\x05val\ +ue\x7f\x01\0\x04\0\x18[method]cylinder.set-cap\x013\x01@\x01\x04self1\0v\x04\0\x17\ +[method]cylinder.height\x014\x01@\x02\x04self1\x05valuev\x01\0\x04\0\x1b[method]\ +cylinder.set-height\x015\x04\0\x17[method]cylinder.radius\x014\x04\0\x1b[method]\ +cylinder.set-radius\x015\x01@\x01\x04self1\0}\x04\0\x1b[method]cylinder.resoluti\ +on\x016\x01@\x02\x04self1\x05value}\x01\0\x04\0\x1f[method]cylinder.set-resoluti\ +on\x017\x04\0\x19[method]cylinder.segments\x016\x04\0\x1d[method]cylinder.set-se\ +gments\x017\x01@\x01\x04self1\0\x19\x04\0\x18[method]cylinder.to-mesh\x018\x01@\x01\ +\x04self1\0\x1b\x04\0\x18[method]cylinder.to-node\x019\x04\0\x20[method]cylinder\ +.to-physics-node\x019\x01i\x0c\x01@\x01\x04size\x03\0:\x04\0\x13[constructor]cub\ +oid\x01;\x01h\x0c\x01@\x01\x04self<\0\x03\x04\0\x13[method]cuboid.size\x01=\x01@\ +\x02\x04self<\x05value\x03\x01\0\x04\0\x17[method]cuboid.set-size\x01>\x01@\x01\x04\ +self<\0\x19\x04\0\x16[method]cuboid.to-mesh\x01?\x01@\x01\x04self<\0\x1b\x04\0\x16\ +[method]cuboid.to-node\x01@\x04\0\x1e[method]cuboid.to-physics-node\x01@\x01i\x13\ +\x01@\x01\x06radiusv\0\xc1\0\x04\0\x16[static]sphere.new-ico\x01B\x04\0\x15[stat\ +ic]sphere.new-uv\x01B\x01h\x13\x01@\x01\x04self\xc3\0\0v\x04\0\x15[method]sphere\ +.radius\x01D\x01@\x02\x04self\xc3\0\x05valuev\x01\0\x04\0\x19[method]sphere.set-\ +radius\x01E\x01@\x01\x04self\xc3\0\0\x12\x04\0\x13[method]sphere.kind\x01F\x01@\x02\ +\x04self\xc3\0\x05value\x12\x01\0\x04\0\x17[method]sphere.set-kind\x01G\x01@\x01\ +\x04self\xc3\0\0\x19\x04\0\x16[method]sphere.to-mesh\x01H\x01@\x01\x04self\xc3\0\ +\0\x1b\x04\0\x16[method]sphere.to-node\x01I\x04\0\x1e[method]sphere.to-physics-n\ +ode\x01I\x04\x01\x10unavi:shapes/api\x05\x13\x04\x01\x12unavi:shapes/guest\x04\0\ +\x0b\x0b\x01\0\x05guest\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-c\ +omponent\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] diff --git a/wasm/unavi-shapes/src/lib.rs b/wasm/unavi-shapes/src/lib.rs index 0f2008e28..4040b56d0 100644 --- a/wasm/unavi-shapes/src/lib.rs +++ b/wasm/unavi-shapes/src/lib.rs @@ -1,5 +1,8 @@ use bindings::exports::unavi::shapes::api::Guest; -use shapes::{cuboid::Cuboid, cylinder::Cylinder, rectangle::Rectangle, sphere::Sphere}; +use shapes::{ + circle::Circle, cuboid::Cuboid, cylinder::Cylinder, ellipse::Ellipse, rectangle::Rectangle, + sphere::Sphere, +}; mod attributes; #[allow(warnings)] @@ -10,8 +13,10 @@ mod wired_math_impls; struct GuestImpl; impl Guest for GuestImpl { + type Circle = Circle; type Cuboid = Cuboid; type Cylinder = Cylinder; + type Ellipse = Ellipse; type Rectangle = Rectangle; type Sphere = Sphere; } diff --git a/wasm/unavi-shapes/src/shapes/circle.rs b/wasm/unavi-shapes/src/shapes/circle.rs new file mode 100644 index 000000000..a759b38df --- /dev/null +++ b/wasm/unavi-shapes/src/shapes/circle.rs @@ -0,0 +1,60 @@ +use std::cell::Cell; + +use crate::bindings::{ + exports::unavi::shapes::api::GuestCircle, + wired::{ + math::types::Vec2, + physics::types::{Collider, Shape, ShapeCylinder}, + scene::{mesh::Mesh, node::Node}, + }, +}; + +use super::ellipse::create_ellipse_mesh; + +pub struct Circle { + radius: Cell, + resolution: Cell, +} + +impl GuestCircle for Circle { + fn new(radius: f32) -> Self { + Self { + radius: Cell::new(radius), + resolution: Cell::new(32), + } + } + + fn radius(&self) -> f32 { + self.radius.get() + } + fn set_radius(&self, value: f32) { + self.radius.set(value); + } + + fn resolution(&self) -> u16 { + self.resolution.get() + } + fn set_resolution(&self, value: u16) { + self.resolution.set(value); + } + + fn to_mesh(&self) -> Mesh { + let radius = self.radius.get(); + let resolution = self.resolution.get(); + create_ellipse_mesh(Vec2::splat(radius), resolution) + } + fn to_node(&self) -> crate::bindings::exports::unavi::shapes::api::Node { + let node = Node::new(); + node.set_mesh(Some(&self.to_mesh())); + node + } + fn to_physics_node(&self) -> Node { + let node = self.to_node(); + let radius = self.radius.get(); + node.set_collider(Some(&Collider::new(Shape::Cylinder(ShapeCylinder { + radius, + height: 0.0001, + })))); + node + } +} diff --git a/wasm/unavi-shapes/src/shapes/cylinder.rs b/wasm/unavi-shapes/src/shapes/cylinder.rs index d83e3382c..1388cf679 100644 --- a/wasm/unavi-shapes/src/shapes/cylinder.rs +++ b/wasm/unavi-shapes/src/shapes/cylinder.rs @@ -112,7 +112,6 @@ fn create_cylinder_mesh( let step_y = 2.0 * half_height / segments as f32; // rings - for ring in 0..num_rings { let y = -half_height + ring as f32 * step_y; diff --git a/wasm/unavi-shapes/src/shapes/ellipse.rs b/wasm/unavi-shapes/src/shapes/ellipse.rs new file mode 100644 index 000000000..539769d6b --- /dev/null +++ b/wasm/unavi-shapes/src/shapes/ellipse.rs @@ -0,0 +1,94 @@ +use std::cell::Cell; + +use crate::bindings::{ + exports::unavi::shapes::api::GuestEllipse, + wired::{ + math::types::Vec2, + scene::{mesh::Mesh, node::Node}, + }, +}; + +pub struct Ellipse { + half_size: Cell, + resolution: Cell, +} + +impl GuestEllipse for Ellipse { + fn new(half_size: Vec2) -> Self { + Self { + half_size: Cell::new(half_size), + resolution: Cell::new(32), + } + } + + fn half_size(&self) -> Vec2 { + self.half_size.get() + } + fn set_half_size(&self, value: Vec2) { + self.half_size.set(value); + } + + fn resolution(&self) -> u16 { + self.resolution.get() + } + fn set_resolution(&self, value: u16) { + self.resolution.set(value); + } + + fn to_mesh(&self) -> Mesh { + let half_size = self.half_size.get(); + let resolution = self.resolution.get(); + create_ellipse_mesh(half_size, resolution) + } + fn to_node(&self) -> Node { + let node = Node::new(); + node.set_mesh(Some(&self.to_mesh())); + node + } + fn to_physics_node(&self) -> Node { + // TODO: use mesh collider + todo!() + } +} + +pub fn create_ellipse_mesh(half_size: Vec2, resolution: u16) -> Mesh { + let resolution = resolution as usize; + + let mut indices = Vec::with_capacity((resolution - 2) * 3); + let mut positions = Vec::with_capacity(resolution); + let normals = vec![[0.0, 0.0, -1.0]; resolution]; + let mut uvs = Vec::with_capacity(resolution); + + // Add pi/2 so that there is a vertex at the top (sin is 1.0 and cos is 0.0) + let start_angle = std::f32::consts::FRAC_PI_2; + let step = std::f32::consts::TAU / resolution as f32; + + for i in 0..resolution { + // Compute vertex position at angle theta + let theta = start_angle + i as f32 * step; + let (sin, cos) = theta.sin_cos(); + let x = cos * half_size.x; + let y = sin * half_size.y; + + positions.push([x, 0.0, -y]); + uvs.push([0.5 * (cos + 1.0), 1.0 - 0.5 * (sin + 1.0)]); + } + + for i in 1..(resolution as u32 - 1) { + indices.extend_from_slice(&[0, i, i + 1]); + } + + let normals = normals.into_iter().flatten().collect::>(); + let positions = positions.into_iter().flatten().collect::>(); + let uvs = uvs.into_iter().flatten().collect::>(); + + let mesh = Mesh::new(); + let primitive = mesh.create_primitive(); + + primitive.set_indices(&indices); + primitive.set_normals(&normals); + primitive.set_positions(&positions); + primitive.set_uvs(&uvs); + + mesh +} diff --git a/wasm/unavi-shapes/src/shapes/mod.rs b/wasm/unavi-shapes/src/shapes/mod.rs index e3e31224f..9f7600e21 100644 --- a/wasm/unavi-shapes/src/shapes/mod.rs +++ b/wasm/unavi-shapes/src/shapes/mod.rs @@ -1,4 +1,6 @@ +pub mod circle; pub mod cuboid; pub mod cylinder; +pub mod ellipse; pub mod rectangle; pub mod sphere; diff --git a/wasm/unavi-shapes/src/shapes/rectangle.rs b/wasm/unavi-shapes/src/shapes/rectangle.rs index 42f225346..90422ff73 100644 --- a/wasm/unavi-shapes/src/shapes/rectangle.rs +++ b/wasm/unavi-shapes/src/shapes/rectangle.rs @@ -39,7 +39,7 @@ impl GuestRectangle for Rectangle { let node = self.to_node(); let size = self.size(); node.set_collider(Some(&Collider::new(Shape::Cuboid(Vec3::new( - size.x, size.y, 0.0, + size.x, 0.0, size.y, ))))); node } @@ -59,13 +59,11 @@ fn create_rectangle_mesh(size: Vec2) -> Mesh { let mut uvs: Vec<[f32; 2]> = Vec::with_capacity(num_vertices); let mut indices: Vec = Vec::with_capacity(num_indices); - let rotation = glam::Quat::from_rotation_arc(glam::Vec3::Y, normal); - for z in 0..z_vertex_count { for x in 0..x_vertex_count { let tx = x as f32 / (x_vertex_count - 1) as f32; let tz = z as f32 / (z_vertex_count - 1) as f32; - let pos = rotation * glam::Vec3::new((-0.5 + tx) * size.x, 0.0, (-0.5 + tz) * size.y); + let pos = glam::Vec3::new((-0.5 + tx) * size.x, 0.0, (-0.5 + tz) * size.y); positions.push(pos); normals.push(normal.to_array()); uvs.push([tx, tz]); @@ -93,7 +91,6 @@ fn create_rectangle_mesh(size: Vec2) -> Mesh { let mesh = Mesh::new(); let primitive = mesh.create_primitive(); - primitive.set_indices(&indices); primitive.set_normals(&normals); primitive.set_positions(&positions); diff --git a/wasm/unavi-shapes/wit/world.wit b/wasm/unavi-shapes/wit/world.wit index 8fce90a4b..1bd963dbe 100644 --- a/wasm/unavi-shapes/wit/world.wit +++ b/wasm/unavi-shapes/wit/world.wit @@ -12,7 +12,6 @@ interface api { use wired:scene/mesh.{mesh}; use wired:scene/node.{node}; - /// 2D resource rectangle { constructor(size: vec2); @@ -27,7 +26,42 @@ interface api { to-physics-node: func() -> node; } - /// 3D + resource circle { + constructor(radius: f32); + + radius: func() -> f32; + set-radius: func(value: f32); + + /// The number of vertices used for the mesh. + resolution: func() -> u16; + set-resolution: func(value: u16); + + /// Creates a mesh of this shape. + to-mesh: func() -> mesh; + /// Creates a node with a mesh of this shape. + to-node: func() -> node; + /// Creates a node with a mesh and physics collider of this shape. + to-physics-node: func() -> node; + } + + resource ellipse { + constructor(half-size: vec2); + + half-size: func() -> vec2; + set-half-size: func(value: vec2); + + /// The number of vertices used for the mesh. + resolution: func() -> u16; + set-resolution: func(value: u16); + + /// Creates a mesh of this shape. + to-mesh: func() -> mesh; + /// Creates a node with a mesh of this shape. + to-node: func() -> node; + /// Creates a node with a mesh and physics collider of this shape. + to-physics-node: func() -> node; + } + resource cylinder { constructor(radius: f32, height: f32); diff --git a/wasm/unavi-ui/src/bindings.rs b/wasm/unavi-ui/src/bindings.rs index 30db34678..418bad280 100644 --- a/wasm/unavi-ui/src/bindings.rs +++ b/wasm/unavi-ui/src/bindings.rs @@ -456,7 +456,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -502,7 +501,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -810,6 +895,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -5493,17 +5913,6 @@ mod _rt { let layout = alloc::Layout::from_size_align_unchecked(size, align); alloc::dealloc(ptr as *mut u8, layout); } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - } - } else { - val != 0 - } - } pub fn as_i32(t: T) -> i32 { t.as_i32() @@ -5574,6 +5983,17 @@ mod _rt { self as i32 } } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } #[cfg(target_arch = "wasm32")] pub fn run_ctors_once() { @@ -5617,8 +6037,8 @@ pub(crate) use __export_guest_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:guest:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6845] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc14\x01A\x02\x01A$\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 7556] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x88:\x01A\x02\x01A$\x01\ B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\ \x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\ \x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -5698,53 +6118,67 @@ y\x01'\x01h\x09\x01k(\x01@\x02\x04self\x0d\x05value)\x01\0\x04\0\x1b[method]node .set-rigid-body\x01*\x01i\x03\x01k+\x01@\x01\x04self\x0d\0,\x04\0\x1a[method]nod\ e.input-handler\x01-\x01h\x03\x01k.\x01@\x02\x04self\x0d\x05value/\x01\0\x04\0\x1e\ [method]node.set-input-handler\x010\x03\x01\x10wired:scene/node\x05\x0f\x02\x03\0\ -\0\x04vec2\x02\x03\0\x06\x04node\x01BY\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ +\0\x04vec2\x02\x03\0\x06\x04node\x01B}\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ \x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\ \0\x04\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x06\x04\0\x09rectangle\x03\x01\x04\ -\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0a\ -sphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0d\ -\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\0\x0bsphere-kind\x03\0\x0f\x04\0\x06\ -sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x12\x04\0\x16[constructor]rectang\ -le\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\x04\0\x16[method]rectangle.size\x01\ -\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\x04\0\x1a[method]rectangle.set-size\ -\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\x04\0\x19[method]rectangle.to-mesh\x01\ -\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\0\x19[method]rectangle.to-node\x01\x1a\ -\x04\0![method]rectangle.to-physics-node\x01\x1a\x01i\x09\x01@\x02\x06radiusv\x06\ -heightv\0\x1b\x04\0\x15[constructor]cylinder\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\ -\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\x01@\x02\x04self\x1d\x05value\x7f\x01\ -\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\x01@\x01\x04self\x1d\0v\x04\0\x17[m\ -ethod]cylinder.height\x01\x20\x01@\x02\x04self\x1d\x05valuev\x01\0\x04\0\x1b[met\ -hod]cylinder.set-height\x01!\x04\0\x17[method]cylinder.radius\x01\x20\x04\0\x1b[\ -method]cylinder.set-radius\x01!\x01@\x01\x04self\x1d\0}\x04\0\x1b[method]cylinde\ -r.resolution\x01\"\x01@\x02\x04self\x1d\x05value}\x01\0\x04\0\x1f[method]cylinde\ -r.set-resolution\x01#\x04\0\x19[method]cylinder.segments\x01\"\x04\0\x1d[method]\ -cylinder.set-segments\x01#\x01@\x01\x04self\x1d\0\x17\x04\0\x18[method]cylinder.\ -to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18[method]cylinder.to-node\x01%\x04\ -\0\x20[method]cylinder.to-physics-node\x01%\x01i\x0a\x01@\x01\x04size\x03\0&\x04\ -\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\x04self(\0\x03\x04\0\x13[method\ -]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\x01\0\x04\0\x17[method]cuboid.s\ -et-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[method]cuboid.to-mesh\x01+\x01@\x01\ -\x04self(\0\x19\x04\0\x16[method]cuboid.to-node\x01,\x04\0\x1e[method]cuboid.to-\ -physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\0-\x04\0\x16[static]sphere.new-ic\ -o\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01h\x11\x01@\x01\x04self/\0v\x04\0\x15\ -[method]sphere.radius\x010\x01@\x02\x04self/\x05valuev\x01\0\x04\0\x19[method]sp\ -here.set-radius\x011\x01@\x01\x04self/\0\x10\x04\0\x13[method]sphere.kind\x012\x01\ -@\x02\x04self/\x05value\x10\x01\0\x04\0\x17[method]sphere.set-kind\x013\x01@\x01\ -\x04self/\0\x17\x04\0\x16[method]sphere.to-mesh\x014\x01@\x01\x04self/\0\x19\x04\ -\0\x16[method]sphere.to-node\x015\x04\0\x1e[method]sphere.to-physics-node\x015\x03\ -\x01\x10unavi:shapes/api\x05\x12\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\ -\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\ -\0\x09alignment\x03\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\ -\0\x07\x04\0\x16[constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\ -\x04\0\x15[method]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\ -\x16[method]container.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\ -\x07\x01@\x01\x04self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\ -\x01@\x02\x04self\x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\ -\x0f\x04\0\x1e[method]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\ -\0\x16[method]container.size\x01\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\ -\0\x1a[method]container.set-size\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[me\ -thod]container.align-x\x01\x12\x04\0\x19[method]container.align-y\x01\x12\x04\0\x19\ -[method]container.align-z\x01\x12\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d\ +\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06\ +cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07\ +sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\ +\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\ +\x04size\x01\0\x14\x04\0\x16[constructor]rectangle\x01\x15\x01h\x08\x01@\x01\x04\ +self\x16\0\x01\x04\0\x16[method]rectangle.size\x01\x17\x01@\x02\x04self\x16\x05v\ +alue\x01\x01\0\x04\0\x1a[method]rectangle.set-size\x01\x18\x01i\x05\x01@\x01\x04\ +self\x16\0\x19\x04\0\x19[method]rectangle.to-mesh\x01\x1a\x01i\x07\x01@\x01\x04s\ +elf\x16\0\x1b\x04\0\x19[method]rectangle.to-node\x01\x1c\x04\0![method]rectangle\ +.to-physics-node\x01\x1c\x01i\x09\x01@\x01\x06radiusv\0\x1d\x04\0\x13[constructo\ +r]circle\x01\x1e\x01h\x09\x01@\x01\x04self\x1f\0v\x04\0\x15[method]circle.radius\ +\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\0\x04\0\x19[method]circle.set-radius\ +\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[method]circle.resolution\x01\"\x01@\x02\x04\ +self\x1f\x05value{\x01\0\x04\0\x1d[method]circle.set-resolution\x01#\x01@\x01\x04\ +self\x1f\0\x19\x04\0\x16[method]circle.to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\ +\0\x16[method]circle.to-node\x01%\x04\0\x1e[method]circle.to-physics-node\x01%\x01\ +i\x0a\x01@\x01\x09half-size\x01\0&\x04\0\x14[constructor]ellipse\x01'\x01h\x0a\x01\ +@\x01\x04self(\0\x01\x04\0\x19[method]ellipse.half-size\x01)\x01@\x02\x04self(\x05\ +value\x01\x01\0\x04\0\x1d[method]ellipse.set-half-size\x01*\x01@\x01\x04self(\0{\ +\x04\0\x1a[method]ellipse.resolution\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\ +\x1e[method]ellipse.set-resolution\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method\ +]ellipse.to-mesh\x01-\x01@\x01\x04self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01\ +.\x04\0\x1f[method]ellipse.to-physics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06\ +heightv\0/\x04\0\x15[constructor]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\ +\0\x14[method]cylinder.cap\x012\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[m\ +ethod]cylinder.set-cap\x013\x01@\x01\x04self1\0v\x04\0\x17[method]cylinder.heigh\ +t\x014\x01@\x02\x04self1\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01\ +5\x04\0\x17[method]cylinder.radius\x014\x04\0\x1b[method]cylinder.set-radius\x01\ +5\x01@\x01\x04self1\0}\x04\0\x1b[method]cylinder.resolution\x016\x01@\x02\x04sel\ +f1\x05value}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x017\x04\0\x19[metho\ +d]cylinder.segments\x016\x04\0\x1d[method]cylinder.set-segments\x017\x01@\x01\x04\ +self1\0\x19\x04\0\x18[method]cylinder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\ +\x18[method]cylinder.to-node\x019\x04\0\x20[method]cylinder.to-physics-node\x019\ +\x01i\x0c\x01@\x01\x04size\x03\0:\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01\ +@\x01\x04self<\0\x03\x04\0\x13[method]cuboid.size\x01=\x01@\x02\x04self<\x05valu\ +e\x03\x01\0\x04\0\x17[method]cuboid.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16\ +[method]cuboid.to-mesh\x01?\x01@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-n\ +ode\x01@\x04\0\x1e[method]cuboid.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiu\ +sv\0\xc1\0\x04\0\x16[static]sphere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01\ +B\x01h\x13\x01@\x01\x04self\xc3\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\ +\x04self\xc3\0\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04\ +self\xc3\0\0\x12\x04\0\x13[method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05val\ +ue\x12\x01\0\x04\0\x17[method]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\ +\0\x16[method]sphere.to-mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]\ +sphere.to-node\x01I\x04\0\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unav\ +i:shapes/api\x05\x12\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\ +\x01\x11\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\0\x09ali\ +gnment\x03\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\ +\0\x16[constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15\ +[method]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[meth\ +od]container.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\x07\x01@\ +\x01\x04self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\x01@\x02\ +\x04self\x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\x0f\x04\ +\0\x1e[method]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\0\x16\ +[method]container.size\x01\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1a\ +[method]container.set-size\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[method]c\ +ontainer.align-x\x01\x12\x04\0\x19[method]container.align-y\x01\x12\x04\0\x19[me\ +thod]container.align-z\x01\x12\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d\ [method]container.set-align-x\x01\x13\x04\0\x1d[method]container.set-align-y\x01\ \x13\x04\0\x1d[method]container.set-align-z\x01\x13\x03\x01\x16unavi:layout/cont\ ainer\x05\x13\x01B\x02\x01@\x01\x05deltav\x01\0\x04\0\x09update-ui\x01\0\x04\x01\ diff --git a/wasm/unavi-vscreen/src/bindings.rs b/wasm/unavi-vscreen/src/bindings.rs index 8ccae8c14..62bc37383 100644 --- a/wasm/unavi-vscreen/src/bindings.rs +++ b/wasm/unavi-vscreen/src/bindings.rs @@ -456,7 +456,6 @@ pub mod unavi { pub type Vec3 = super::super::super::wired::math::types::Vec3; pub type Mesh = super::super::super::wired::scene::mesh::Mesh; pub type Node = super::super::super::wired::scene::node::Node; - /// 2D #[derive(Debug)] #[repr(transparent)] @@ -502,7 +501,93 @@ pub mod unavi { } } - /// 3D + #[derive(Debug)] + #[repr(transparent)] + pub struct Circle { + handle: _rt::Resource, + } + + impl Circle { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Circle { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]circle"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Ellipse { + handle: _rt::Resource, + } + + impl Ellipse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Ellipse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[resource-drop]ellipse"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } #[derive(Debug)] #[repr(transparent)] @@ -810,6 +895,341 @@ pub mod unavi { } } } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn new(radius: f32) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]circle"] + fn wit_import(_: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(&radius)); + Circle::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn radius(&self) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.radius"] + fn wit_import(_: i32) -> f32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_radius(&self, value: f32) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-radius"] + fn wit_import(_: i32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Circle { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]circle.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn new(half_size: Vec2) -> Self { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = + half_size; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[constructor]ellipse"] + fn wit_import(_: f32, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: f32, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_f32(x0), _rt::as_f32(y0)); + Ellipse::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn half_size(&self) -> Vec2 { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.half-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(4).cast::(); + super::super::super::wired::math::types::Vec2 { x: l1, y: l2 } + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_half_size(&self, value: Vec2) { + unsafe { + let super::super::super::wired::math::types::Vec2 { x: x0, y: y0 } = value; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-half-size"] + fn wit_import(_: i32, _: f32, _: f32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: f32, _: f32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_f32(x0), _rt::as_f32(y0)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// The number of vertices used for the mesh. + pub fn resolution(&self) -> u16 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.resolution"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + pub fn set_resolution(&self, value: u16) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.set-resolution"] + fn wit_import(_: i32, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i32(&value)); + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a mesh of this shape. + pub fn to_mesh(&self) -> Mesh { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-mesh"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::mesh::Mesh::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh of this shape. + pub fn to_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } + impl Ellipse { + #[allow(unused_unsafe, clippy::all)] + /// Creates a node with a mesh and physics collider of this shape. + pub fn to_physics_node(&self) -> Node { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "unavi:shapes/api")] + extern "C" { + #[link_name = "[method]ellipse.to-physics-node"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wired::scene::node::Node::from_handle(ret as u32) + } + } + } impl Cylinder { #[allow(unused_unsafe, clippy::all)] pub fn new(radius: f32, height: f32) -> Self { @@ -5069,17 +5489,6 @@ mod _rt { let layout = alloc::Layout::from_size_align_unchecked(size, align); alloc::dealloc(ptr as *mut u8, layout); } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - } - } else { - val != 0 - } - } pub fn as_i32(t: T) -> i32 { t.as_i32() @@ -5150,6 +5559,17 @@ mod _rt { self as i32 } } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } pub use alloc_crate::boxed::Box; #[cfg(target_arch = "wasm32")] @@ -5191,8 +5611,8 @@ pub(crate) use __export_guest_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:guest:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6642] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf62\x01A\x02\x01A\x20\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 7353] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xbd8\x01A\x02\x01A\x20\ \x01B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\ \0\x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01\ r\x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\ @@ -5272,53 +5692,67 @@ y\x01'\x01h\x09\x01k(\x01@\x02\x04self\x0d\x05value)\x01\0\x04\0\x1b[method]node .set-rigid-body\x01*\x01i\x03\x01k+\x01@\x01\x04self\x0d\0,\x04\0\x1a[method]nod\ e.input-handler\x01-\x01h\x03\x01k.\x01@\x02\x04self\x0d\x05value/\x01\0\x04\0\x1e\ [method]node.set-input-handler\x010\x03\x01\x10wired:scene/node\x05\x0f\x02\x03\0\ -\0\x04vec2\x02\x03\0\x06\x04node\x01BY\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ +\0\x04vec2\x02\x03\0\x06\x04node\x01B}\x02\x03\x02\x01\x10\x04\0\x04vec2\x03\0\0\ \x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\x02\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\ \0\x04\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x06\x04\0\x09rectangle\x03\x01\x04\ -\0\x08cylinder\x03\x01\x04\0\x06cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0a\ -sphere-ico\x03\0\x0b\x01r\x02\x07sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0d\ -\x01q\x02\x03ico\x01\x0c\0\x02uv\x01\x0e\0\x04\0\x0bsphere-kind\x03\0\x0f\x04\0\x06\ -sphere\x03\x01\x01i\x08\x01@\x01\x04size\x01\0\x12\x04\0\x16[constructor]rectang\ -le\x01\x13\x01h\x08\x01@\x01\x04self\x14\0\x01\x04\0\x16[method]rectangle.size\x01\ -\x15\x01@\x02\x04self\x14\x05value\x01\x01\0\x04\0\x1a[method]rectangle.set-size\ -\x01\x16\x01i\x05\x01@\x01\x04self\x14\0\x17\x04\0\x19[method]rectangle.to-mesh\x01\ -\x18\x01i\x07\x01@\x01\x04self\x14\0\x19\x04\0\x19[method]rectangle.to-node\x01\x1a\ -\x04\0![method]rectangle.to-physics-node\x01\x1a\x01i\x09\x01@\x02\x06radiusv\x06\ -heightv\0\x1b\x04\0\x15[constructor]cylinder\x01\x1c\x01h\x09\x01@\x01\x04self\x1d\ -\0\x7f\x04\0\x14[method]cylinder.cap\x01\x1e\x01@\x02\x04self\x1d\x05value\x7f\x01\ -\0\x04\0\x18[method]cylinder.set-cap\x01\x1f\x01@\x01\x04self\x1d\0v\x04\0\x17[m\ -ethod]cylinder.height\x01\x20\x01@\x02\x04self\x1d\x05valuev\x01\0\x04\0\x1b[met\ -hod]cylinder.set-height\x01!\x04\0\x17[method]cylinder.radius\x01\x20\x04\0\x1b[\ -method]cylinder.set-radius\x01!\x01@\x01\x04self\x1d\0}\x04\0\x1b[method]cylinde\ -r.resolution\x01\"\x01@\x02\x04self\x1d\x05value}\x01\0\x04\0\x1f[method]cylinde\ -r.set-resolution\x01#\x04\0\x19[method]cylinder.segments\x01\"\x04\0\x1d[method]\ -cylinder.set-segments\x01#\x01@\x01\x04self\x1d\0\x17\x04\0\x18[method]cylinder.\ -to-mesh\x01$\x01@\x01\x04self\x1d\0\x19\x04\0\x18[method]cylinder.to-node\x01%\x04\ -\0\x20[method]cylinder.to-physics-node\x01%\x01i\x0a\x01@\x01\x04size\x03\0&\x04\ -\0\x13[constructor]cuboid\x01'\x01h\x0a\x01@\x01\x04self(\0\x03\x04\0\x13[method\ -]cuboid.size\x01)\x01@\x02\x04self(\x05value\x03\x01\0\x04\0\x17[method]cuboid.s\ -et-size\x01*\x01@\x01\x04self(\0\x17\x04\0\x16[method]cuboid.to-mesh\x01+\x01@\x01\ -\x04self(\0\x19\x04\0\x16[method]cuboid.to-node\x01,\x04\0\x1e[method]cuboid.to-\ -physics-node\x01,\x01i\x11\x01@\x01\x06radiusv\0-\x04\0\x16[static]sphere.new-ic\ -o\x01.\x04\0\x15[static]sphere.new-uv\x01.\x01h\x11\x01@\x01\x04self/\0v\x04\0\x15\ -[method]sphere.radius\x010\x01@\x02\x04self/\x05valuev\x01\0\x04\0\x19[method]sp\ -here.set-radius\x011\x01@\x01\x04self/\0\x10\x04\0\x13[method]sphere.kind\x012\x01\ -@\x02\x04self/\x05value\x10\x01\0\x04\0\x17[method]sphere.set-kind\x013\x01@\x01\ -\x04self/\0\x17\x04\0\x16[method]sphere.to-mesh\x014\x01@\x01\x04self/\0\x19\x04\ -\0\x16[method]sphere.to-node\x015\x04\0\x1e[method]sphere.to-physics-node\x015\x03\ -\x01\x10unavi:shapes/api\x05\x12\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\ -\x02\x03\x02\x01\x11\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\ -\0\x09alignment\x03\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\ -\0\x07\x04\0\x16[constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\ -\x04\0\x15[method]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\ -\x16[method]container.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\ -\x07\x01@\x01\x04self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\ -\x01@\x02\x04self\x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\ -\x0f\x04\0\x1e[method]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\ -\0\x16[method]container.size\x01\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\ -\0\x1a[method]container.set-size\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[me\ -thod]container.align-x\x01\x12\x04\0\x19[method]container.align-y\x01\x12\x04\0\x19\ -[method]container.align-z\x01\x12\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d\ +\0\x06circle\x03\x01\x04\0\x07ellipse\x03\x01\x04\0\x08cylinder\x03\x01\x04\0\x06\ +cuboid\x03\x01\x01r\x01\x0csubdivisions}\x04\0\x0asphere-ico\x03\0\x0d\x01r\x02\x07\ +sectors}\x06stacks}\x04\0\x09sphere-uv\x03\0\x0f\x01q\x02\x03ico\x01\x0e\0\x02uv\ +\x01\x10\0\x04\0\x0bsphere-kind\x03\0\x11\x04\0\x06sphere\x03\x01\x01i\x08\x01@\x01\ +\x04size\x01\0\x14\x04\0\x16[constructor]rectangle\x01\x15\x01h\x08\x01@\x01\x04\ +self\x16\0\x01\x04\0\x16[method]rectangle.size\x01\x17\x01@\x02\x04self\x16\x05v\ +alue\x01\x01\0\x04\0\x1a[method]rectangle.set-size\x01\x18\x01i\x05\x01@\x01\x04\ +self\x16\0\x19\x04\0\x19[method]rectangle.to-mesh\x01\x1a\x01i\x07\x01@\x01\x04s\ +elf\x16\0\x1b\x04\0\x19[method]rectangle.to-node\x01\x1c\x04\0![method]rectangle\ +.to-physics-node\x01\x1c\x01i\x09\x01@\x01\x06radiusv\0\x1d\x04\0\x13[constructo\ +r]circle\x01\x1e\x01h\x09\x01@\x01\x04self\x1f\0v\x04\0\x15[method]circle.radius\ +\x01\x20\x01@\x02\x04self\x1f\x05valuev\x01\0\x04\0\x19[method]circle.set-radius\ +\x01!\x01@\x01\x04self\x1f\0{\x04\0\x19[method]circle.resolution\x01\"\x01@\x02\x04\ +self\x1f\x05value{\x01\0\x04\0\x1d[method]circle.set-resolution\x01#\x01@\x01\x04\ +self\x1f\0\x19\x04\0\x16[method]circle.to-mesh\x01$\x01@\x01\x04self\x1f\0\x1b\x04\ +\0\x16[method]circle.to-node\x01%\x04\0\x1e[method]circle.to-physics-node\x01%\x01\ +i\x0a\x01@\x01\x09half-size\x01\0&\x04\0\x14[constructor]ellipse\x01'\x01h\x0a\x01\ +@\x01\x04self(\0\x01\x04\0\x19[method]ellipse.half-size\x01)\x01@\x02\x04self(\x05\ +value\x01\x01\0\x04\0\x1d[method]ellipse.set-half-size\x01*\x01@\x01\x04self(\0{\ +\x04\0\x1a[method]ellipse.resolution\x01+\x01@\x02\x04self(\x05value{\x01\0\x04\0\ +\x1e[method]ellipse.set-resolution\x01,\x01@\x01\x04self(\0\x19\x04\0\x17[method\ +]ellipse.to-mesh\x01-\x01@\x01\x04self(\0\x1b\x04\0\x17[method]ellipse.to-node\x01\ +.\x04\0\x1f[method]ellipse.to-physics-node\x01.\x01i\x0b\x01@\x02\x06radiusv\x06\ +heightv\0/\x04\0\x15[constructor]cylinder\x010\x01h\x0b\x01@\x01\x04self1\0\x7f\x04\ +\0\x14[method]cylinder.cap\x012\x01@\x02\x04self1\x05value\x7f\x01\0\x04\0\x18[m\ +ethod]cylinder.set-cap\x013\x01@\x01\x04self1\0v\x04\0\x17[method]cylinder.heigh\ +t\x014\x01@\x02\x04self1\x05valuev\x01\0\x04\0\x1b[method]cylinder.set-height\x01\ +5\x04\0\x17[method]cylinder.radius\x014\x04\0\x1b[method]cylinder.set-radius\x01\ +5\x01@\x01\x04self1\0}\x04\0\x1b[method]cylinder.resolution\x016\x01@\x02\x04sel\ +f1\x05value}\x01\0\x04\0\x1f[method]cylinder.set-resolution\x017\x04\0\x19[metho\ +d]cylinder.segments\x016\x04\0\x1d[method]cylinder.set-segments\x017\x01@\x01\x04\ +self1\0\x19\x04\0\x18[method]cylinder.to-mesh\x018\x01@\x01\x04self1\0\x1b\x04\0\ +\x18[method]cylinder.to-node\x019\x04\0\x20[method]cylinder.to-physics-node\x019\ +\x01i\x0c\x01@\x01\x04size\x03\0:\x04\0\x13[constructor]cuboid\x01;\x01h\x0c\x01\ +@\x01\x04self<\0\x03\x04\0\x13[method]cuboid.size\x01=\x01@\x02\x04self<\x05valu\ +e\x03\x01\0\x04\0\x17[method]cuboid.set-size\x01>\x01@\x01\x04self<\0\x19\x04\0\x16\ +[method]cuboid.to-mesh\x01?\x01@\x01\x04self<\0\x1b\x04\0\x16[method]cuboid.to-n\ +ode\x01@\x04\0\x1e[method]cuboid.to-physics-node\x01@\x01i\x13\x01@\x01\x06radiu\ +sv\0\xc1\0\x04\0\x16[static]sphere.new-ico\x01B\x04\0\x15[static]sphere.new-uv\x01\ +B\x01h\x13\x01@\x01\x04self\xc3\0\0v\x04\0\x15[method]sphere.radius\x01D\x01@\x02\ +\x04self\xc3\0\x05valuev\x01\0\x04\0\x19[method]sphere.set-radius\x01E\x01@\x01\x04\ +self\xc3\0\0\x12\x04\0\x13[method]sphere.kind\x01F\x01@\x02\x04self\xc3\0\x05val\ +ue\x12\x01\0\x04\0\x17[method]sphere.set-kind\x01G\x01@\x01\x04self\xc3\0\0\x19\x04\ +\0\x16[method]sphere.to-mesh\x01H\x01@\x01\x04self\xc3\0\0\x1b\x04\0\x16[method]\ +sphere.to-node\x01I\x04\0\x1e[method]sphere.to-physics-node\x01I\x03\x01\x10unav\ +i:shapes/api\x05\x12\x01B#\x02\x03\x02\x01\x04\x04\0\x04vec3\x03\0\0\x02\x03\x02\ +\x01\x11\x04\0\x04node\x03\0\x02\x01m\x03\x06center\x03end\x05start\x04\0\x09ali\ +gnment\x03\0\x04\x04\0\x09container\x03\x01\x01i\x06\x01@\x01\x04size\x01\0\x07\x04\ +\0\x16[constructor]container\x01\x08\x01h\x06\x01@\x01\x04self\x09\0\x07\x04\0\x15\ +[method]container.ref\x01\x0a\x01i\x03\x01@\x01\x04self\x09\0\x0b\x04\0\x16[meth\ +od]container.root\x01\x0c\x04\0\x17[method]container.inner\x01\x0c\x01p\x07\x01@\ +\x01\x04self\x09\0\x0d\x04\0\x1f[method]container.list-children\x01\x0e\x01@\x02\ +\x04self\x09\x05child\x09\x01\0\x04\0\x1b[method]container.add-child\x01\x0f\x04\ +\0\x1e[method]container.remove-child\x01\x0f\x01@\x01\x04self\x09\0\x01\x04\0\x16\ +[method]container.size\x01\x10\x01@\x02\x04self\x09\x05value\x01\x01\0\x04\0\x1a\ +[method]container.set-size\x01\x11\x01@\x01\x04self\x09\0\x05\x04\0\x19[method]c\ +ontainer.align-x\x01\x12\x04\0\x19[method]container.align-y\x01\x12\x04\0\x19[me\ +thod]container.align-z\x01\x12\x01@\x02\x04self\x09\x05value\x05\x01\0\x04\0\x1d\ [method]container.set-align-x\x01\x13\x04\0\x1d[method]container.set-align-y\x01\ \x13\x04\0\x1d[method]container.set-align-z\x01\x13\x03\x01\x16unavi:layout/cont\ ainer\x05\x13\x02\x03\0\x08\x09container\x01B&\x02\x03\x02\x01\x14\x04\0\x09cont\