Skip to content

Commit 2827dd8

Browse files
committed
feat: make ifc importer accessible in ifc loader
1 parent a423e8f commit 2827dd8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/core/src/fragments/IfcLoader/example.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ components.get(OBC.Grids).create(world);
6060

6161
const ifcLoader = components.get(OBC.IfcLoader);
6262

63+
/* MD
64+
:::warning What elements of IFC get converted to Fragments?
65+
66+
For memory efficiency reasons, we don't convert each an every element to fragments by default. You can see the list in IfcImporter.classes and check out the full list [here](https://github.com/ThatOpen/engine_fragment/blob/main/packages/fragments/src/Importers/IfcImporter/src/classes.ts). If you convert an IFC to fragments and miss some elements, you probably need to add their IFC classes to the list. You can access the importer instance in the onIfcImporterInitialized event.
67+
:::
68+
*/
69+
70+
ifcLoader.onIfcImporterInitialized.add((importer) => {
71+
console.log(importer.classes);
72+
});
73+
6374
/* MD
6475
With the loader in place, it needs to be properly configured. This involves setting up web-ifc (the core library responsible for reading IFC files) to ensure it is ready to convert IFC files into Fragments:
6576
*/

packages/core/src/fragments/IfcLoader/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ export class IfcLoader extends Component implements Disposable {
2525
*/
2626
readonly onIfcStartedLoading = new Event<void>();
2727

28+
/**
29+
* An event triggered when the IFC importer is initialized.
30+
*/
31+
readonly onIfcImporterInitialized = new Event<FRAGS.IfcImporter>();
32+
2833
/**
2934
* An event triggered when the setup process is completed.
3035
*/
@@ -124,6 +129,8 @@ export class IfcLoader extends Component implements Disposable {
124129
serializer.wasm.absolute = this.settings.wasm.absolute;
125130
serializer.webIfcSettings = this.settings.webIfc;
126131

132+
this.onIfcImporterInitialized.trigger(serializer);
133+
127134
if (config?.instanceCallback) config.instanceCallback(serializer);
128135

129136
const bytes = await serializer.process({

0 commit comments

Comments
 (0)