Skip to main content

IfcLoader

The IfcLoader component is responsible of converting IFC files into Fragments. 📕 Tutorial. 📘 API.

Extends​

Implements​

Properties​

enabled​

enabled: boolean = true

Component.enabled

Overrides​

Component . enabled


onDisposed​

readonly onDisposed: Event<string>

Disposable.onDisposed

Implementation of​

Disposable . onDisposed


onIfcImporterInitialized​

readonly onIfcImporterInitialized: Event<IfcImporter>

An event triggered when the IFC importer is initialized.


onIfcStartedLoading​

readonly onIfcStartedLoading: Event<void>

An event triggered when the IFC file starts loading.


onSetup​

readonly onSetup: 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​

static readonly uuid: "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

Disposable.dispose

Returns​

void

Implementation of​

Disposable . dispose


isConfigurable()​

isConfigurable(): this is Configurable<any, any>

Whether is component is Configurable.

Returns​

this is Configurable<any, any>

Inherited from​

Component . isConfigurable


isDisposeable()​

isDisposeable(): this is Disposable

Whether is component is Disposable.

Returns​

this is Disposable

Inherited from​

Component . isDisposeable


isHideable()​

isHideable(): this is Hideable

Whether is component is Hideable.

Returns​

this is Hideable

Inherited from​

Component . isHideable


isResizeable()​

isResizeable(): this is Resizeable

Whether is component is Resizeable.

Returns​

this is Resizeable

Inherited from​

Component . isResizeable


isSerializable()​

isSerializable(): this is Serializable<any, Record<string, any>>

Whether is component is Serializable.

Returns​

this is Serializable<any, Record<string, any>>

Inherited from​

Component . isSerializable


isUpdateable()​

isUpdateable(): this is Updateable

Whether is component is Updateable.

Returns​

this is Updateable

Inherited from​

Component . isUpdateable


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​

ParameterTypeDescription
dataUint8ArrayThe Uint8Array containing the IFC file data.
coordinatebooleanBoolean indicating whether to coordinate the loaded IFC data. Default is true.
namestringName for the fragments model.
config?objectOptional 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​

ParameterTypeDescription
dataUint8ArrayThe 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​

ParameterTypeDescription
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 });