@thatopen/fragments
Enumerations
| Enumeration | Description |
|---|---|
| CurrentLod | Enum representing the current level of detail (LOD) for a mesh. |
| EditRequestType | Types of edit requests. |
| ItemConfigClass | Enum representing the configuration class for an item in a Fragments model. |
| LodMode | Enum representing the mode of the LOD / culling system. |
| SnappingClass | Enum representing the snapping class for a raycast operation. |
Classes
| Class | Description |
|---|---|
| Editor | The Editor class provides functionality for editing and managing Fragments models. It handles operations like editing model elements, saving changes and managing edit history. |
| FragmentsModel | The 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. |
| FragmentsModels | The 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. |
| GeometryEngine | The 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 | - |
| IfcImporter | An objet to convert IFC files into fragments. |
| IfcParserStream | Parses 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. | |
| LoadAbortedError | Error thrown when a model load is aborted via FragmentsModels.abort(). |
| SingleThreadedFragmentsModel | The 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
| Interface | Description |
|---|---|
| AggregateMap | Parent-child aggregation relationships between building elements (e.g. roof to slabs). |
| Attributes | Interface representing the attributes of a model item. |
| BaseCreateRequest | Base interface for all create edit requests. |
| BaseEditRequest | Base interface for all edit requests. |
| BaseUpdateRequest | Base interface for all update edit requests. |
| CRSData | Interface representing the Coordinate Reference System (CRS) data extracted from an IFC model's IFCPROJECTEDCRS and IFCMAPCONVERSION entities. |
| CreateGlobalTransformRequest | Interface for create global transform edit requests. |
| CreateIndexRequest | Interface 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. | |
| CreateItemRequest | Interface for create item edit requests. |
| CreateLocalTransformRequest | Interface for create local transform edit requests. |
| CreateMaterialRequest | Interface for create material edit requests. |
| CreateRelationRequest | Interface for create relation edit requests. |
| CreateRepresentationRequest | Interface for create representation edit requests. |
| CreateSampleRequest | Interface for create sample edit requests. |
| DeleteGlobalTransformRequest | Interface for delete global transform edit requests. |
| DeleteIndexRequest | Interface for delete index edit requests. No-op if the named index |
| doesn't exist. | |
| DeleteItemRequest | Interface for delete item edit requests. |
| DeleteLocalTransformRequest | Interface for delete local transform edit requests. |
| DeleteMaterialRequest | Interface for delete material edit requests. |
| DeleteRelationRequest | Interface for delete relation edit requests. |
| DeleteRepresentationRequest | Interface for delete representation edit requests. |
| DeleteSampleRequest | Interface for delete sample edit requests. |
| GroupData | Per-group output data: the set of IFC entity IDs to include and any rewritten relationship lines. |
| IndexInfo | Snapshot of an index's shape. Returned by getIndexInfo so callers can |
| branch on the mode without re-inspecting the underlying buffer. | |
| ItemAttribute | Interface representing the attributes of an item in a Fragments model. |
| ItemData | Interface representing the data of an item in a Fragments model. |
| ItemsDataConfig | Interface representing the configuration for item data in a Fragments model. |
| MappedInformationResult | Interface representing the result of an information query for a specific item type. |
| MappedResultInput | Interface representing the input for a result query in a Fragments model. |
| MappedSelectionInput | Interface representing the input for a selection query in a Fragments model. |
| ModelIdMap | Interface representing a map of model IDs to their corresponding local IDs. |
| RawIndexData | Payload 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: onlykeys.oneToOne:keys+values, nostart/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 alias | Description |
|---|---|
| AttributeData | Represents attribute data for a model item. |
| AttrsChange | Union type representing all possible attribute change types. |
| BIMMaterial | Union type representing all possible material types. |
| BIMMesh | Union type representing all possible mesh types. |
| CreateRequest | Type for create edit requests. |
| DataBuffer | Union type representing all possible data buffer types. |
| DeleteRequest | Type for delete edit requests. |
| EditRequest | Type for all edit requests. |
| ElementData | Container of all the data of an element of a fragments model. |
| Identifier | Type representing a unique identifier for a model item. This can be either a string or a number. |
| IndexEntry | Forward-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 viahasIndexEntry/ iterated viagetIndexKeys.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-levelEditRequesttype alongside the others. | | IndexValueType | Value type of a user-defined model index.nonefor 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 directionkey -> value, the inverse mapsvalue -> set of keys. Keys come back asUint32Arrayfor number-keyed indexes andstring[]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
| Variable | Description |
|---|---|
| ELEMENT_TYPES | The default IfcSplitterConfig.elementTypes. |
| Exported so it can be extended rather than replaced. | |
| EditRequestTypeNames | Names of the edit request types (e.g. to display in a history UI). |
| FRAGMENTS_GENERATOR | The name of this package, used to identify it as the generator of the |
| models it creates. | |
| FRAGMENTS_VERSION | The 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_TYPES | The default IfcSplitterConfig.spatialTypes. |
| Exported so it can be extended rather than replaced. | |
| geometryTypes | A Set of unique numbers representing different types of IFC geometries. |
| ifcCategoryMap | A 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. |
| limitOf2Bytes | The maximum value for a 2-byte unsigned integer. |
Functions
| Function | Description |
|---|---|
| decodeStepString | Decode a raw STEP string body: '', \\, \S\c, \X\hh, \X2\…\X0. |
| getObject | Recursively 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. |
| getProvenanceMetadata | Provenance 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). | |
| isIndexRequest | Discriminator for index edit requests. Use to skip them in code paths that |
assume every request carries a localId. | |
| isRawBuffer | Returns 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. |