@ifc-lite/lens
Rule-based 3D filtering and colorization for IFC models. A pure, framework-agnostic evaluation engine: you define lenses whose rules match entities by IFC class, property value, material, or classification, and apply visual actions (colorize, hide, make transparent). The engine has zero dependencies and reads model data through a small LensDataProvider interface, so it works with any data store.
Install
npm install @ifc-lite/lens
Usage
import { evaluateLens, BUILTIN_LENSES } from '@ifc-lite/lens';
import type { LensDataProvider } from '@ifc-lite/lens';
const provider: LensDataProvider = createMyProvider(myData);
const result = evaluateLens(BUILTIN_LENSES[0], provider);
// result.colorMap - Map<globalId, RGBAColor>
// result.hiddenIds - Set<globalId>
// result.ruleCounts - Map<ruleId, count>
Features
evaluateLens/evaluateAutoColorLens: turn aLensdefinition into color and visibility maps- Auto-color mode: assign distinct colors per IFC class, property value, or material automatically, with a generated legend
matchesCriteriafor standalone rule matchingBUILTIN_LENSESpresets (for example "By IFC Class")discoverClasses/discoverDataSourcesto populate lens editors from model data- Color helpers:
hexToRgba,rgbaToHex,uniqueColor,GHOST_COLOR,LENS_PALETTE - Fully typed:
Lens,LensRule,LensCriteria,LensEvaluationResult,RGBAColor
Links
License
MPL-2.0