Utilities

Utility APIs for inspecting IFC entities and working with colors.

Interfaces

AttributeEntry

Defined in: ifcopenshell-js/src/util/inspect.ts:4

Properties

name

name: string

Defined in: ifcopenshell-js/src/util/inspect.ts:4

value

value: string

Defined in: ifcopenshell-js/src/util/inspect.ts:4


EntityInspection

Defined in: ifcopenshell-js/src/util/inspect.ts:5

Properties

attributes

attributes: AttributeEntry[]

Defined in: ifcopenshell-js/src/util/inspect.ts:9

guid

guid: string | null

Defined in: ifcopenshell-js/src/util/inspect.ts:8

id

id: number

Defined in: ifcopenshell-js/src/util/inspect.ts:6

type

type: string

Defined in: ifcopenshell-js/src/util/inspect.ts:7

Type Aliases

RGB

RGB = [number, number, number]

Defined in: ifcopenshell-js/src/util/color.ts:3

RGB triplet with components normalized to the [0, 1] range.

Functions

formatAttributeValue()

formatAttributeValue(value): string

Defined in: ifcopenshell-js/src/util/inspect.ts:12

Parameters

value

AttributeValueType

Returns

string


hashColor()

hashColor(input): RGB

Defined in: ifcopenshell-js/src/util/color.ts:23

Generate a deterministic RGB color from a string hash.

Uses an FNV-1a style hash so that the same input always maps to the same color — handy for assigning consistent display colors to IFC entity types (e.g. hashColor('IfcWall')).

Components are returned in the [0, 1] range and deliberately biased away from pure black / pure white so they remain visible on both light and dark backgrounds.

Parameters

input

string

Arbitrary string to hash.

Returns

RGB

A deterministic [r, g, b] triplet in [0, 1].


inspectEntity()

inspectEntity(file, id): Promise<EntityInspection | null>

Defined in: ifcopenshell-js/src/util/inspect.ts:19

Parameters

file

File

id

number

Returns

Promise<EntityInspection | null>


meshColor()

meshColor(type, materialIds, colors): RGB

Defined in: ifcopenshell-js/src/util/color.ts:50

Resolve the display color for a mesh, preferring material colors defined on the IFC representation over a type-based hash color.

The colors buffer follows the IfcOpenShell convention: each material contributes four consecutive floats ([r, g, b, a]), and materialIds maps each face item to a material index. When a material color is available it is used directly; otherwise the entity type is hashed to produce a stable fallback color.

Parameters

type

string

IFC entity type name (e.g. 'IfcWall').

materialIds

ArrayLike<number>

Per-face material indices (may be empty).

colors

ArrayLike<number>

Flat RGBA material color buffer (may be empty).

Returns

RGB

A [r, g, b] triplet in [0, 1].