Skip to main content

@thatopen/fragments

Enumerations​

EnumerationDescription
CurrentLodEnum representing the current level of detail (LOD) for a mesh.
EditRequestTypeTypes of edit requests.
ItemConfigClassEnum representing the configuration class for an item in a Fragments model.
LodModeEnum representing the mode of the LOD / culling system.
SnappingClassEnum representing the snapping class for a raycast operation.

Classes​

ClassDescription
EditorThe Editor class provides functionality for editing and managing Fragments models. It handles operations like editing model elements, saving changes and managing edit history.
FragmentsModelThe main class for managing a 3D model loaded from a fragments file. Handles geometry, materials, visibility, highlighting, sections, and more. This class orchestrates multiple specialized managers to handle different aspects of the model like mesh management, item data, raycasting, etc. It maintains the overall state and provides the main interface for interacting with the model. The model data is loaded and processed asynchronously across multiple threads.
FragmentsModelsThe main class for managing multiple 3D models loaded from fragments files. Handles loading, disposing, updating, raycasting, highlighting and coordinating multiple FragmentsModel instances. This class acts as the main entry point for working with fragments models. A FragmentsModels instance needs a worker to process fragments off the main thread. The recommended way to obtain the worker URL is via the static FragmentsModels.getWorker method, which fetches the version-matched worker from unpkg. Check the method docs for more info.
GeometryEngineThe geometry engine is responsible for generating geometry using web-ifc. It provides a high-level API to generate common BIM shapes like extrusions, sweeps, walls, and profiles.
IfcDecoderStream-
IfcImporterAn objet to convert IFC files into fragments.
IfcParserStreamParses the ISO 10303-21 statements of an IFC file into web-ifc entities,
matching the shape IfcAPI.GetLine returns (attributes hold typed value
wrappers, refs are { type: 5, value } handles, omitted attributes are
null). Statements may span physical lines, share a line, or be
interleaved with /* ... */ comments and blank lines. Entity types
outside the file's declared schema are skipped, like web-ifc does.
The stream errors on corrupted statements and on input that ends before
END-ISO-10303-21;, so truncated files are not mistaken for complete ones.
LoadAbortedErrorError thrown when a model load is aborted via FragmentsModels.abort().
SingleThreadedFragmentsModelThe main class for managing a 3D model loaded from a fragments file in a single thread. It's designed for easy data querying in the backend, so all the 3D visualization logic is not present.

Interfaces​

InterfaceDescription
AggregateMapParent-child aggregation relationships between building elements (e.g. roof to slabs).
AttributesInterface representing the attributes of a model item.
BaseCreateRequestBase interface for all create edit requests.
BaseEditRequestBase interface for all edit requests.
BaseUpdateRequestBase interface for all update edit requests.
CRSDataInterface representing the Coordinate Reference System (CRS) data extracted from an IFC model's IFCPROJECTEDCRS and IFCMAPCONVERSION entities.
CreateGlobalTransformRequestInterface for create global transform edit requests.
CreateIndexRequestInterface for create index edit requests. Indexes are name-keyed, so
data.name identifies the index. Fails silently if an index with the
same name already exists; use UPDATE_INDEX to replace.
CreateItemRequestInterface for create item edit requests.
CreateLocalTransformRequestInterface for create local transform edit requests.
CreateMaterialRequestInterface for create material edit requests.
CreateRelationRequestInterface for create relation edit requests.
CreateRepresentationRequestInterface for create representation edit requests.
CreateSampleRequestInterface for create sample edit requests.
DeleteGlobalTransformRequestInterface for delete global transform edit requests.
DeleteIndexRequestInterface for delete index edit requests. No-op if the named index
doesn't exist.
DeleteItemRequestInterface for delete item edit requests.
DeleteLocalTransformRequestInterface for delete local transform edit requests.
DeleteMaterialRequestInterface for delete material edit requests.
DeleteRelationRequestInterface for delete relation edit requests.
DeleteRepresentationRequestInterface for delete representation edit requests.
DeleteSampleRequestInterface for delete sample edit requests.
GroupDataPer-group output data: the set of IFC entity IDs to include and any rewritten relationship lines.
IndexInfoSnapshot of an index's shape. Returned by getIndexInfo so callers can
branch on the mode without re-inspecting the underlying buffer.
ItemAttributeInterface representing the attributes of an item in a Fragments model.
ItemDataInterface representing the data of an item in a Fragments model.
ItemsDataConfigInterface representing the configuration for item data in a Fragments model.
MappedInformationResultInterface representing the result of an information query for a specific item type.
MappedResultInputInterface representing the input for a result query in a Fragments model.
MappedSelectionInputInterface representing the input for a selection query in a Fragments model.
ModelIdMapInterface representing a map of model IDs to their corresponding local IDs.
RawIndexDataPayload describing a user-defined model index. Maps directly to the
ModelIndex schema's flat key/value vectors with optional slicing.

Mode is inferred from which fields are populated:

  • keysOnly: only keys.
  • oneToOne: keys + values, no start/end.
  • oneToNLinear: keys + values + end.
  • oneToNNonLinear: keys + values + start + end.

Keys must be homogeneous (number[] or string[]). Values, if present, must also be homogeneous. | | RaycastData | Interface representing the data for a raycast operation. | | RaycastResult | Interface representing the result of a raycast operation. | | RectangleRaycastData | Interface representing the data for a rectangle raycast operation. | | RectangleRaycastResult | Interface representing the result of a rectangle raycast operation. | | RelsModifyChange | Interface representing a change event when relations are modified in a model item. | | SpatialTreeItem | Interface representing an item in a spatial tree. | | StyleMaps | Reverse indices for IFCSTYLEDITEM and IFCMATERIALDEFINITIONREPRESENTATION backward pointers. | | UpdateGlobalTransformRequest | Interface for update global transform edit requests. | | UpdateIndexRequest | Interface for update index edit requests. Replaces the entire index identified by data.name. Use DELETE_INDEX + CREATE_INDEX if you want to rename. | | UpdateItemRequest | Interface for update item edit requests. | | UpdateLocalTransformRequest | Interface for update local transform edit requests. | | UpdateMaterialRequest | Interface for update material edit requests. | | UpdateMaxLocalIdRequest | Interface for update max local id edit requests. | | UpdateMetadataRequest | Interface for update metadata edit requests. | | UpdateRelationRequest | Interface for update relation edit requests. | | UpdateRepresentationRequest | Interface for update representation edit requests. | | UpdateSampleRequest | Interface for update sample edit requests. | | UpdateSpatialStructureRequest | Interface for update spatial structure edit requests. | | VirtualModelConfig | Interface representing the configuration for a virtual model. | | VirtualMultithreadingConfig | Interface representing multithreading timing configuration for virtual models. | | VirtualPropertiesConfig | Interface representing the configuration for virtual properties in a Fragments model. | | VoidFillMap | Mapping of void/fill relationships between walls, openings, and fillers (doors/windows). |

Type Aliases​

Type aliasDescription
AttributeDataRepresents attribute data for a model item.
AttrsChangeUnion type representing all possible attribute change types.
BIMMaterialUnion type representing all possible material types.
BIMMeshUnion type representing all possible mesh types.
CreateRequestType for create edit requests.
DataBufferUnion type representing all possible data buffer types.
DeleteRequestType for delete edit requests.
EditRequestType for all edit requests.
ElementDataContainer of all the data of an element of a fragments model.
IdentifierType representing a unique identifier for a model item. This can be either a string or a number.
IndexEntryForward-lookup result for a single key in a IndexInfo.

Shape depends on the index mode: null for keys-only, the scalar value for oneToOne, or a Uint32Array view (number values) / string[] (string values) for the 1:N modes. The Uint32Array is a zero-copy view over the underlying buffer; do not mutate it. | | IndexKeyType | Key type of a user-defined model index. | | IndexMode | Storage shape of a user-defined model index. Detected once per index from the populated vectors and exposed via IndexInfo.

  • keysOnly: only keys are stored. The index acts as a sorted set; values are queried via hasIndexEntry / iterated via getIndexKeys.
  • oneToOne: each key maps to exactly one value.
  • oneToNLinear: each key maps to a contiguous slice of values.
  • oneToNNonLinear: each key maps to an arbitrary slice (slices may overlap or reorder, e.g. flattened descendant trees). | | IndexRequest | Type for index edit requests. Indexes are name-keyed (no localId), so they live in their own union and are merged into the top-level EditRequest type alongside the others. | | IndexValueType | Value type of a user-defined model index. none for keys-only indexes. | | InformationResultType | Type representing the result of an information query for a specific item type. | | InverseIndexEntry | Inverse-lookup result. For an index with forward direction key -> value, the inverse maps value -> set of keys. Keys come back as Uint32Array for number-keyed indexes and string[] for string-keyed ones. | | ItemInformationType | Union type representing all possible item information types. | | ItemSelectionType | Union type representing all possible item selection types. | | LoadProgressEvent | Progress event emitted during model loading. | | MaterialDefinition | Interface representing the definition of a material. | | MeshData | Interface representing the data of a mesh. | | NewElementData | Data defining a new element of a fragments model. | | RawCircleExtrusion | Data defining a circle extrusion geometry (e.g. reinforcement bars). | | RawGlobalTransformData | Data defining a global transform of a mesh. | | RawItemData | Data defining a fragments item. It can be anything, from a property to property set or a physical element like a wall or a beam. | | RawMaterial | Data defining a fragments material. | | RawMetadataData | Data defining metadata of the fragments model. | | RawRelationData | Data defining a fragments relation. | | RawRepresentation | Data defining a representation of a geometry. | | RawSample | Data defining a sample (instance) of a mesh. | | RawShell | Data defining a shell geometry (e.g. a brep). | | RawTransformData | Data defining a transform (local or global) of a mesh. | | RelsChange | Union type representing all possible relation change types. | | ResultInputType | Union type representing all possible result input types. | | SelectionInputType | Union type representing all possible selection input types. | | UpdateRequest | Type for update edit requests. |

Variables​

VariableDescription
ELEMENT_TYPESThe default IfcSplitterConfig.elementTypes.
Exported so it can be extended rather than replaced.
EditRequestTypeNamesNames of the edit request types (e.g. to display in a history UI).
FRAGMENTS_GENERATORThe name of this package, used to identify it as the generator of the
models it creates.
FRAGMENTS_VERSIONThe version of this package. It's injected at build time from package.json
(see the define option in vite.config.ts), so it's always in sync with
the published version. When the code runs unbundled and the define is not
applied (e.g. tsx scripts), it falls back to "unknown".
SPATIAL_TYPESThe default IfcSplitterConfig.spatialTypes.
Exported so it can be extended rather than replaced.
geometryTypesA Set of unique numbers representing different types of IFC geometries.
ifcCategoryMapA map that associates each unique integer identifier (IFC Entity ID) with its corresponding category name. This map is used to map IFC entities to their respective categories for easier identification and processing.
limitOf2BytesThe maximum value for a 2-byte unsigned integer.

Functions​

FunctionDescription
decodeStepStringDecode a raw STEP string body: '', \\, \S\c, \X\hh, \X2\…\X0.
getObjectRecursively converts a Flatbuffers object into a plain JavaScript object. This function traverses the prototype chain of the Flatbuffers object and extracts all properties and their values, handling both primitive values and nested objects/arrays.
getProvenanceMetadataProvenance data stamped into the metadata of every model this library
creates, so any fragments file records which package and version generated
it (see ThatOpen/engine_fragment#273).
isIndexRequestDiscriminator for index edit requests. Use to skip them in code paths that
assume every request carries a localId.
isRawBufferReturns whether bytes is a raw (uncompressed) fragments buffer rather than
a pako/zlib-deflated one, by inspecting the first two bytes.

A deflated fragments buffer is a zlib stream: byte 0's low nibble is the deflate compression method (8) and (byte0 << 8 | byte1) is a multiple of 31 (the zlib header check). A raw fragments buffer is a flatbuffer, whose leading 32-bit root offset does not satisfy that. This lets load and the model constructors accept either form without the caller tracking which it is.

In the extremely unlikely case a raw buffer's first two bytes happen to look like a zlib header, pass raw explicitly to override the detection.

Performance note: a raw (uncompressed) model is the fastest to load. Only deflate a fragments buffer when you persist it to disk or send it over the network. Inflating and deflating on every load, with no transport in between, just wastes CPU. | | listIdxByType | Returns the argument index at which a given IFC type stores its list of "related objects". Getting this wrong causes the rewriter to read the wrong field, end up with an empty list, and skip the line entirely — dropping all its transitive dependencies (property sets, materials, styles, etc.) from the split output.

The default IfcSplitterConfig.listArgIndex. Exported so an override can delegate to it for the types it doesn't care about. | | parseStepArguments | Parse the argument list of a STEP data statement (#ID=TYPENAME(args);) into web-ifc's raw tape shape, suitable for webIfc.FromRawLineData. Throws on malformed arguments. | | streamAsyncIterator | Backward compatible stream async iterator

for await (const line of streamAsyncIterator(readableStream)) {
await callback(line);
}

Modern environments support stream async iterator out of the box:

for await (const line of readableStream) {
await callback(line);
}
``` |
| [toClassicWorker](functions/toClassicWorker.md) | Fetches a worker script and returns a blob URL with the ES module `export` stripped, so it can be used as a classic (non-module) worker. |