pub struct JsMesh { /* private fields */ }Expand description
A triangle mesh exposed to JavaScript.
Positions and normals are flattened to [x, y, z, x, y, z, ...] format
for efficient WASM transfer and direct use as GPU vertex buffers.
Implementations§
Source§impl JsMesh
impl JsMesh
Sourcepub fn vertex_count(&self) -> u32
pub fn vertex_count(&self) -> u32
Number of vertices in the mesh.
Sourcepub fn triangle_count(&self) -> u32
pub fn triangle_count(&self) -> u32
Number of triangles in the mesh.
Sourcepub fn packed_buffer(&self) -> Vec<u8> ⓘ
pub fn packed_buffer(&self) -> Vec<u8> ⓘ
Return all mesh data in a single packed buffer for efficient FFI transfer.
Layout: [pos_bytes: u32 LE, norm_bytes: u32 LE, idx_bytes: u32 LE, positions: f64 LE..., normals: f64 LE..., indices: u32 LE...]
This avoids three separate .clone() + FFI copies that the individual
getters (positions, normals, indices) would incur.
Trait Implementations§
Source§impl From<TriangleMesh> for JsMesh
impl From<TriangleMesh> for JsMesh
Source§fn from(mesh: TriangleMesh) -> Self
fn from(mesh: TriangleMesh) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for JsMesh
impl FromWasmAbi for JsMesh
Source§impl IntoWasmAbi for JsMesh
impl IntoWasmAbi for JsMesh
Source§impl LongRefFromWasmAbi for JsMesh
impl LongRefFromWasmAbi for JsMesh
Source§impl OptionFromWasmAbi for JsMesh
impl OptionFromWasmAbi for JsMesh
Source§impl OptionIntoWasmAbi for JsMesh
impl OptionIntoWasmAbi for JsMesh
Source§impl RefFromWasmAbi for JsMesh
impl RefFromWasmAbi for JsMesh
Source§type Abi = WasmPtr<WasmRefCell<JsMesh>>
type Abi = WasmPtr<WasmRefCell<JsMesh>>
The Wasm ABI type references to
Self are recovered from.Source§impl RefMutFromWasmAbi for JsMesh
impl RefMutFromWasmAbi for JsMesh
impl SupportsConstructor for JsMesh
impl SupportsInstanceProperty for JsMesh
impl SupportsStaticProperty for JsMesh
Source§impl TryFromJsValue for JsMesh
impl TryFromJsValue for JsMesh
Source§impl VectorFromWasmAbi for JsMesh
impl VectorFromWasmAbi for JsMesh
Source§impl VectorIntoWasmAbi for JsMesh
impl VectorIntoWasmAbi for JsMesh
Auto Trait Implementations§
impl Freeze for JsMesh
impl RefUnwindSafe for JsMesh
impl Send for JsMesh
impl Sync for JsMesh
impl Unpin for JsMesh
impl UnsafeUnpin for JsMesh
impl UnwindSafe for JsMesh
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.