Module presentation

Source
Expand description

Visibility, colour, opacity, and glTF PBR materials (ifcx_alpha).

NodePresentation::from_attributes decodes one node’s own presentation attributes. The functions is_visible, resolve_basic_material, and resolve_mesh_material apply the precedence of the upstream reference viewer (src/viewer/render.ts at buildingSMART/IFC5-development 1a63082) to a node and its ancestors. crate::scene applies them while walking a composed tree, dropping invisible subtrees.

AttributeValue
usd::usdgeom::visibility{"visibility": "inherited" | "invisible"}
bsi::ifc::presentation::diffuseColor[r, g, b], linear, 0..=1
bsi::ifc::presentation::opacitynumber, 0..=1
gltf::materialglTF 2.0 material subset, see GltfMaterial

§Material bindings

In ifcx_alpha a node binds a material by inheriting from the material node ("inherits": {"material": "<path>"}); composition then gives the node the material’s bsi::ifc::presentation::* and gltf::material attributes. The pre-alpha usd::usdshade::material::outputs::surface connections were converted to that form upstream: no upstream example uses them, and the reference viewer only lists the name for an outline icon. They are therefore not read here.

§Precedence

Given a node followed by its ancestors, nearest first:

  1. A node is drawn only if neither it nor any ancestor is invisible.
  2. A mesh uses the gltf::material of the nearest node that has one, with glTF defaults for missing factors, and ignores the bsi::ifc::presentation attributes.
  3. Otherwise, and always for curves, colour comes from the nearest node with diffuseColor, and opacity from that same node only. Without any diffuseColor the colour is BasicMaterial::DEFAULT, grey 0.6 and opaque.

Point clouds use neither; they carry their own per-point colours.

Three choices differ from the reference viewer where its behaviour follows from JavaScript truthiness or branch order rather than intent:

  • Opacity 0 is fully transparent; the viewer skips falsy opacity values and draws such objects opaque.
  • visibility: "inherited" hides nothing; the viewer also skips the geometry of any node that merely has the attribute.
  • A gltf::material whose members are all false or 0 still selects PBR; the viewer skips it.

Structs§

BasicMaterial
Colour and opacity from bsi::ifc::presentation.
GltfMaterial
A gltf::material value with glTF 2.0 defaults filled in.
NodePresentation
One node’s own presentation attributes, before any inheritance.
NormalTexture
A normal map reference. The texture is recorded, not loaded.
OcclusionTexture
An occlusion map reference. The texture is recorded, not loaded.

Enums§

AlphaMode
glTF alphaMode.
Material
The material a mesh is drawn with.
Visibility
USD visibility token of one node.

Constants§

DIFFUSE_COLOR
Attribute id of the IFC diffuse colour.
GLTF_MATERIAL
Attribute id of a glTF PBR material.
OPACITY
Attribute id of the IFC opacity.
VISIBILITY
Attribute id of USD visibility.

Functions§

is_visible
Whether a node is drawn, given whether its parent is (true for a root) and the node’s own visibility. An invisible node hides its subtree; a descendant cannot become visible again.
resolve_basic_material
Colour and opacity for a node, from the node and its ancestors given nearest first. The nearest diffuseColor wins, and opacity comes from that same node (default 1); an opacity on a node without diffuseColor is not used. Used for curves, and for meshes without a glTF material.
resolve_mesh_material
The material for a mesh node, from the node and its ancestors given nearest first. The nearest gltf::material wins over any bsi::ifc::presentation attribute; without one, see resolve_basic_material.