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
impl MeshDataJs
Sourcepub fn express_id(&self) -> u32
pub fn express_id(&self) -> u32
Get express ID
Sourcepub fn positions(&self) -> Float32Array
pub fn positions(&self) -> Float32Array
Get positions as Float32Array (copy to JS)
Sourcepub fn normals(&self) -> Float32Array
pub fn normals(&self) -> Float32Array
Get normals as Float32Array (copy to JS)
Sourcepub fn indices(&self) -> Uint32Array
pub fn indices(&self) -> Uint32Array
Get indices as Uint32Array (copy to JS)
Sourcepub fn shading_color(&self) -> Option<Vec<f32>>
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).
Sourcepub fn metallic(&self) -> Option<f32>
pub fn metallic(&self) -> Option<f32>
IFC-authored metallic/roughness (#5582). undefined when unauthored.
pub fn roughness(&self) -> Option<f32>
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Get vertex count
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Get triangle count
Sourcepub fn has_texture(&self) -> bool
pub fn has_texture(&self) -> bool
True when this mesh carries a surface texture (#961).
Sourcepub fn uvs(&self) -> Float32Array
pub fn uvs(&self) -> Float32Array
Per-vertex texture coordinates as Float32Array (u, v pairs). Empty when the mesh is untextured.
Sourcepub fn texture_rgba(&self) -> Uint8Array
pub fn texture_rgba(&self) -> Uint8Array
Decoded RGBA8 texture bytes (width*height*4). Empty when untextured.
pub fn texture_width(&self) -> u32
pub fn texture_height(&self) -> u32
Sourcepub fn texture_repeat_s(&self) -> bool
pub fn texture_repeat_s(&self) -> bool
Sampler wrap for the S axis (IfcSurfaceTexture.RepeatS): true = repeat.
Sourcepub fn texture_repeat_t(&self) -> bool
pub fn texture_repeat_t(&self) -> bool
Sampler wrap for the T axis (IfcSurfaceTexture.RepeatT): true = repeat.
Sourcepub fn texture_id(&self) -> u32
pub fn texture_id(&self) -> u32
Stable texture dedup key (IfcSurfaceTexture express id, #1781).
0 when the mesh is untextured.
Sourcepub fn texture_url(&self) -> Option<String>
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.
Sourcepub fn geometry_class(&self) -> u8
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).
Sourcepub fn geometry_item_id(&self) -> Option<u32>
pub fn geometry_item_id(&self) -> Option<u32>
Source IfcRepresentationItem, or undefined where identity is merged
away. Never set alongside materialId (#3199).
Sourcepub fn material_id(&self) -> Option<u32>
pub fn material_id(&self) -> Option<u32>
IfcMaterial layer sliced, or undefined (#3199).
Sourcepub fn origin(&self) -> Float64Array
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).
Sourcepub fn local_bounds(&self) -> Option<Vec<f32>>
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).
Sourcepub fn local_to_world(&self) -> Option<Vec<f64>>
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
impl MeshDataJs
Sourcepub fn new(
express_id: u32,
ifc_type: String,
mesh: Mesh,
color: [f32; 4],
) -> Self
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).
Sourcepub fn set_geometry_class(&mut self, class: u8)
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.
Sourcepub fn set_source_ids(
&mut self,
geometry_item_id: Option<u32>,
material_id: Option<u32>,
)
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).
Sourcepub fn set_shading_color(&mut self, shading: Option<[f32; 4]>)
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.
Sourcepub fn set_material(&mut self, metallic: Option<f32>, roughness: Option<f32>)
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).
Sourcepub fn set_texture(
&mut self,
uvs: Vec<f32>,
rgba: Vec<u8>,
width: u32,
height: u32,
repeat_s: bool,
repeat_t: bool,
texture_id: u32,
)
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.
Sourcepub fn set_texture_ref(
&mut self,
uvs: Vec<f32>,
url: String,
repeat_s: bool,
repeat_t: bool,
texture_id: u32,
)
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.
Sourcepub fn from_mesh_data(m: MeshData) -> Self
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
impl Clone for MeshDataJs
Source§fn clone(&self) -> MeshDataJs
fn clone(&self) -> MeshDataJs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for MeshDataJs
Hand-written rather than derived, and it must keep agreeing with new.
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§impl From<MeshDataJs> for JsValue
impl From<MeshDataJs> for JsValue
Source§fn from(value: MeshDataJs) -> Self
fn from(value: MeshDataJs) -> Self
Source§impl FromWasmAbi for MeshDataJs
impl FromWasmAbi for MeshDataJs
Source§impl IntoWasmAbi for MeshDataJs
impl IntoWasmAbi for MeshDataJs
Source§impl LongRefFromWasmAbi for MeshDataJs
impl LongRefFromWasmAbi for MeshDataJs
Source§type Abi = WasmPtr<WasmRefCell<MeshDataJs>>
type Abi = WasmPtr<WasmRefCell<MeshDataJs>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<MeshDataJs>
type Anchor = RcRef<MeshDataJs>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for MeshDataJs
impl OptionFromWasmAbi for MeshDataJs
Source§impl OptionIntoWasmAbi for MeshDataJs
impl OptionIntoWasmAbi for MeshDataJs
Source§impl RefFromWasmAbi for MeshDataJs
impl RefFromWasmAbi for MeshDataJs
Source§type Abi = WasmPtr<WasmRefCell<MeshDataJs>>
type Abi = WasmPtr<WasmRefCell<MeshDataJs>>
Self are recovered from.Source§type Anchor = RcRef<MeshDataJs>
type Anchor = RcRef<MeshDataJs>
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§impl RefMutFromWasmAbi for MeshDataJs
impl RefMutFromWasmAbi for MeshDataJs
Source§type Abi = WasmPtr<WasmRefCell<MeshDataJs>>
type Abi = WasmPtr<WasmRefCell<MeshDataJs>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<MeshDataJs>
type Anchor = RcRefMut<MeshDataJs>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl TryFromJsValue for MeshDataJs
impl TryFromJsValue for MeshDataJs
Source§impl VectorFromWasmAbi for MeshDataJs
impl VectorFromWasmAbi for MeshDataJs
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[MeshDataJs]>
Source§impl VectorIntoWasmAbi for MeshDataJs
impl VectorIntoWasmAbi for MeshDataJs
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[MeshDataJs]>) -> Self::Abi
Source§impl WasmDescribeVector for MeshDataJs
impl WasmDescribeVector for MeshDataJs
impl SupportsConstructor for MeshDataJs
impl SupportsInstanceProperty for MeshDataJs
impl SupportsStaticProperty for MeshDataJs
Auto Trait Implementations§
impl Freeze for MeshDataJs
impl RefUnwindSafe for MeshDataJs
impl Send for MeshDataJs
impl Sync for MeshDataJs
impl Unpin for MeshDataJs
impl UnwindSafe for MeshDataJs
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
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 moreSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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
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
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.