IfcLoader
The IfcLoader component is responsible of converting IFC files into Fragments. 📕 Tutorial. 📘 API.
Extends
Implements
Properties
enabled
enabled:
boolean=true
Overrides
onDisposed
readonlyonDisposed:Event<string>
Implementation of
onIfcImporterInitialized
readonlyonIfcImporterInitialized:Event<IfcImporter>
An event triggered when the IFC importer is initialized.
onIfcStartedLoading
readonlyonIfcStartedLoading:Event<void>
An event triggered when the IFC file starts loading.
onSetup
readonlyonSetup:Event<void>
An event triggered when the setup process is completed.
settings
settings:
IfcFragmentSettings
The settings for the IfcLoader. It includes options for excluding categories, setting WASM paths, and more.
webIfc
webIfc:
IfcAPI
The instance of the Web-IFC library used for handling IFC data.
uuid
staticreadonlyuuid:"a659add7-1418-4771-a0d6-7d4d438e4624"
A unique identifier for the component. This UUID is used to register the component within the Components system.
Methods
cleanUp()
cleanUp():
void
Cleans up the IfcLoader component by resetting the Web-IFC library, clearing the visited fragments and fragment instances maps, and creating a new instance of the Web-IFC library.
Returns
void
Remarks
This method is called automatically after using the .load() method, so usually you don't need to use it manually.
Example
const ifcLoader = components.get(IfcLoader);
ifcLoader.cleanUp();
dispose()
dispose():
void
Returns
void
Implementation of
isConfigurable()
isConfigurable():
this is Configurable<any, any>
Whether is component is Configurable.
Returns
this is Configurable<any, any>
Inherited from
isDisposeable()
isDisposeable():
this is Disposable
Whether is component is Disposable.
Returns
this is Disposable
Inherited from
isHideable()
isHideable():
this is Hideable
Whether is component is Hideable.
Returns
this is Hideable
Inherited from
isResizeable()
isResizeable():
this is Resizeable
Whether is component is Resizeable.
Returns
this is Resizeable
Inherited from
isSerializable()
isSerializable():
this is Serializable<any, Record<string, any>>
Whether is component is Serializable.
Returns
this is Serializable<any, Record<string, any>>
Inherited from
isUpdateable()
isUpdateable():
this is Updateable
Whether is component is Updateable.
Returns
this is Updateable
Inherited from
load()
load(
data,coordinate,name,config?):Promise<FragmentsModel>
Loads an IFC file and processes it for 3D visualization.
By default, the loader imports a minimal set of attributes and relations needed for typical visualization workflows.
Default attributes
- Base entities: Project, Site, Building, BuildingStorey
- Materials: IFC material definitions and layers
- Properties: Property Sets, quantities (area, volume, length, etc.)
Default relations
- DefinesByProperties (IsDefinedBy / DefinesOccurrence)
- AssociatesMaterial (HasAssociations / AssociatedTo)
- Aggregates (IsDecomposedBy / Decomposes)
- ContainedInSpatialStructure (ContainsElements / ContainedInStructure)
If you need all attributes or relations to be loaded, you can enable them
via the instanceCallback.
The callback provides direct access to the underlying IfcImporter,
allowing advanced configuration before processing begins.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | Uint8Array | The Uint8Array containing the IFC file data. |
coordinate | boolean | Boolean indicating whether to coordinate the loaded IFC data. Default is true. |
name | string | Name for the fragments model. |
config? | object | Optional extra data for loading the IFC. |
config.instanceCallback? | (importer) => void | - |
config.processData? | Omit<ProcessData, "bytes"> | - |
config.userData? | Record<string, any> | - |
Returns
Promise<FragmentsModel>
A Promise that resolves to the FragmentsModel containing the loaded and processed IFC data.
Examples
// Load all attributes and relations using the instanceCallback
const model = await ifcLoader.load(ifcData, true, "modelName", {
instanceCallback: (importer) => {
importer.addAllAttributes();
importer.addAllRelations();
},
});
// Default loading (built-in attributes and relations only)
const ifcLoader = components.get(IfcLoader);
const model = await ifcLoader.load(ifcData);
readIfcFile()
readIfcFile(
data):Promise<number>
Reads an IFC file and initializes the Web-IFC library.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | Uint8Array | The Uint8Array containing the IFC file data. |
Returns
Promise<number>
A Promise that resolves when the IFC file is opened and initialized.
Remarks
This method sets the WASM path and initializes the Web-IFC library based on the provided settings. It also opens the IFC model using the provided data and settings.
Example
const ifcLoader = components.get(IfcLoader);
await ifcLoader.readIfcFile(ifcData);
setup()
setup(
config?):Promise<void>
Sets up the IfcLoader component with the provided configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
config? | Partial <IfcFragmentSettings> | Optional configuration settings for the IfcLoader. |
| If not provided, the existing settings will be used. |
Returns
Promise<void>
A Promise that resolves when the setup process is completed.
Remarks
If the autoSetWasm option is enabled in the configuration,
the method will automatically set the WASM paths for the Web-IFC library.
Example
const ifcLoader = new IfcLoader(components);
await ifcLoader.setup({ autoSetWasm: true });