MeshDataJs

Struct MeshDataJs 

Source
pub struct MeshDataJs { /* private fields */ }
Expand description

Individual mesh data with express ID and color (matches MeshData interface)

Clone is derived so the three sites that used to enumerate all 21 fields by hand – get, takeMesh and MeshCollection’s own Clone – reduce to .cloned(), mem::take and .clone(). Adding a field to #3199 meant editing three literals in lockstep; the allowlist row for this file records exactly that cost.

To be precise about what this does and does not buy, because the obvious claim is wrong: an exhaustive struct literal that OMITS a field is a compile error, so those literals were never silently lossy. What they were is three places to edit for one field, and ..Default::default() is the shortcut a hurried author reaches for when the compiler complains – which WOULD be silently lossy. Default is what makes takeMesh a one-liner, so the rule is: TWO literals remain, new and Default below (both spelled Self { .. }, which is why a grep for MeshDataJs { finds neither). Both must stay exhaustive AND must agree on every field new does not take as an argument. The compiler catches an omitted field in either; it cannot catch the two DISAGREEING, which is the failure the pair exists to prevent, so default_agrees_with_new_on_the_fields_new_does_not_take covers that. Never spread Default into new – new is the only place a field’s initial value is decided, so a field defaulted there is inert everywhere.

Implementations§

Source§

impl MeshDataJs

Source

pub fn express_id(&self) -> u32

Get express ID

Source

pub fn ifc_type(&self) -> String

Get IFC type name (e.g., “IfcWall”, “IfcSpace”)

Source

pub fn positions(&self) -> Float32Array

Get positions as Float32Array (copy to JS)

Source

pub fn normals(&self) -> Float32Array

Get normals as Float32Array (copy to JS)

Source

pub fn indices(&self) -> Uint32Array

Get indices as Uint32Array (copy to JS)

Source

pub fn color(&self) -> Vec<f32>

Get color as [r, g, b, a] array

Source

pub fn shading_color(&self) -> Option<Vec<f32>>

Optional SurfaceColour for the “Shading” GLB-export choice — only present when the file authored a distinct DiffuseColour. JS sees undefined when absent (most files).

Source

pub fn metallic(&self) -> Option<f32>

IFC-authored metallic/roughness (#5582). undefined when unauthored.

Source

pub fn roughness(&self) -> Option<f32>

Source

pub fn vertex_count(&self) -> usize

Get vertex count

Source

pub fn triangle_count(&self) -> usize

Get triangle count

Source

pub fn has_texture(&self) -> bool

True when this mesh carries a surface texture (#961).

Source

pub fn uvs(&self) -> Float32Array

Per-vertex texture coordinates as Float32Array (u, v pairs). Empty when the mesh is untextured.

Source

pub fn texture_rgba(&self) -> Uint8Array

Decoded RGBA8 texture bytes (width*height*4). Empty when untextured.

Source

pub fn texture_width(&self) -> u32

Source

pub fn texture_height(&self) -> u32

Source

pub fn texture_repeat_s(&self) -> bool

Sampler wrap for the S axis (IfcSurfaceTexture.RepeatS): true = repeat.

Source

pub fn texture_repeat_t(&self) -> bool

Sampler wrap for the T axis (IfcSurfaceTexture.RepeatT): true = repeat.

Source

pub fn texture_id(&self) -> u32

Stable texture dedup key (IfcSurfaceTexture express id, #1781). 0 when the mesh is untextured.

Source

pub fn texture_url(&self) -> Option<String>

External image reference (IfcImageTexture.URLReference, #1781) for the host to resolve — e.g. a sibling image inside the .ifcZIP. undefined for untextured meshes and Rust-decoded blob/pixel textures.

Source

pub fn geometry_class(&self) -> u8

Geometry provenance for the viewer’s Model/Types switch (#957 follow-up): 0 = occurrence, 1 = orphan type geometry (no occurrence), 2 = instanced type geometry (hidden in Model mode, shown in Types mode).

Source

pub fn geometry_item_id(&self) -> Option<u32>

Source IfcRepresentationItem, or undefined where identity is merged away. Never set alongside materialId (#3199).

Source

pub fn material_id(&self) -> Option<u32>

IfcMaterial layer sliced, or undefined (#3199).

Source

pub fn origin(&self) -> Float64Array

Per-element local-frame origin (Float64Array[3], WebGL Y-up, metres): world position of vertex i = origin + positions[3i..3i+3]. Returns [0,0,0] when positions are absolute (legacy / local frame off).

Source

pub fn local_bounds(&self) -> Option<Vec<f32>>

Local (pre-placement, object-space) AABB (issue #1474), WebGL Y-up, [minX,minY,minZ,maxX,maxY,maxZ]. undefined when not captured (wasm-bindgen maps Option::None to undefined, not null).

Source

pub fn local_to_world(&self) -> Option<Vec<f64>>

The resolved IfcLocalPlacement chain for this mesh (issue #1474), row-major 4×4, WebGL Y-up. undefined when not captured (see local_bounds above).

Source§

impl MeshDataJs

Source

pub fn new( express_id: u32, ifc_type: String, mesh: Mesh, color: [f32; 4], ) -> Self

Create new mesh data with IFC Z-up to WebGL Y-up conversion.

Performs coordinate conversion in Rust to avoid expensive per-vertex JS iteration (63.5M vertices for large files). IFC Z-up → WebGL Y-up: swap Y/Z, negate new Z for right-handedness. This rotation has determinant +1, so triangle winding is preserved (#4056).

Source

pub fn set_geometry_class(&mut self, class: u8)

Tag this mesh’s geometry provenance for the Model/Types view switch (0 = occurrence, 1 = orphan type, 2 = instanced type). Call after new.

Source

pub fn set_source_ids( &mut self, geometry_item_id: Option<u32>, material_id: Option<u32>, )

Both DISJOINT ids at once, so a caller cannot set one without considering the other (#3199).

Source

pub fn set_shading_color(&mut self, shading: Option<[f32; 4]>)

Attach an optional SurfaceColour for the GLB exporter’s “Shading” colour source. Callers that have a geometry_shading_styles entry for the mesh’s source geometry id should invoke this after new.

Source

pub fn set_material(&mut self, metallic: Option<f32>, roughness: Option<f32>)

Attach the IFC-authored metallic/roughness (#5582); the wasm batch stamps it from setStyleFinishes by geometry_item_id (MeshData carries none).

Source

pub fn set_texture( &mut self, uvs: Vec<f32>, rgba: Vec<u8>, width: u32, height: u32, repeat_s: bool, repeat_t: bool, texture_id: u32, )

Attach per-vertex UVs + a decoded RGBA8 texture (#961). UVs are 1:1 with positions and need no coordinate flip (they are 2D). The rotation in new preserves vertex and index order, so per-vertex UVs stay aligned. Call after new.

Source

pub fn set_texture_ref( &mut self, uvs: Vec<f32>, url: String, repeat_s: bool, repeat_t: bool, texture_id: u32, )

Attach per-vertex UVs + an EXTERNAL image reference (#1781): the host resolves url (e.g. against the .ifcZIP siblings), decodes it once per texture_id, and shares the GPU texture. Call after new.

Source

pub fn from_mesh_data(m: MeshData) -> Self

Build from the canonical per-element producer’s [MeshData] (ifc_lite_processing::element): wraps MeshDataJs::new (IFC Z-up → WebGL Y-up rotation with preserved winding), copies the geometry_class tag and the optional texture/UVs. Element metadata the browser doesn’t carry (global_id / name / presentation layer / material name / properties) is dropped — the viewer gets it from the parser worker instead.

Trait Implementations§

Source§

impl Clone for MeshDataJs

Source§

fn clone(&self) -> MeshDataJs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for MeshDataJs

Hand-written rather than derived, and it must keep agreeing with new.

The derive gives false for the texture repeat flags while new sets them true, so a MeshDataJs::default() plus setters would report textureRepeatS === false and clamp a texture that should tile. Inert while every texture path goes through set_texture, but that was enforced by prose alone; this makes the two constructors agree structurally.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<MeshDataJs> for JsValue

Source§

fn from(value: MeshDataJs) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for MeshDataJs

Source§

type Abi = WasmPtr<WasmRefCell<MeshDataJs>>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for MeshDataJs

Source§

type Abi = WasmPtr<WasmRefCell<MeshDataJs>>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for MeshDataJs

Source§

type Abi = WasmPtr<WasmRefCell<MeshDataJs>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<MeshDataJs>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for MeshDataJs

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for MeshDataJs

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for MeshDataJs

Source§

type Abi = WasmPtr<WasmRefCell<MeshDataJs>>

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<MeshDataJs>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for MeshDataJs

Source§

type Abi = WasmPtr<WasmRefCell<MeshDataJs>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<MeshDataJs>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for MeshDataJs

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for MeshDataJs

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[MeshDataJs]>

Source§

impl VectorIntoWasmAbi for MeshDataJs

Source§

impl WasmDescribe for MeshDataJs

Source§

impl WasmDescribeVector for MeshDataJs

Source§

impl SupportsConstructor for MeshDataJs

Source§

impl SupportsInstanceProperty for MeshDataJs

Source§

impl SupportsStaticProperty for MeshDataJs

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

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.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more