Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IFCLoader #22113

Merged
merged 1 commit into from
Jul 12, 2021
Merged

Update IFCLoader #22113

merged 1 commit into from
Jul 12, 2021

Conversation

agviegas
Copy link
Contributor

Latest updates from IFC.js, which are a lot. Some of them are:

  • Faster query of spatial tree for the scene.
  • Faster property fetch.
  • More geometry support.
  • Bigger files support (improved WASM memory allocation).
  • Faster picking. We have made three-mesh-bvh completely optional. The users can select and get all the information of all the objects without that library, although for bigger models they can optionally use it to enhance the selection speed. Users can use it with just one line.

@mrdoob mrdoob added this to the r131 milestone Jul 12, 2021
@mrdoob mrdoob merged commit 4ebe96f into mrdoob:dev Jul 12, 2021
@mrdoob
Copy link
Owner

mrdoob commented Jul 12, 2021

Thanks!

ifcLoader.load( 'models/ifc/rac_advanced_sample_project.ifc', function ( model ) {

scene.add( model );
scene.add( model.mesh );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IFCLoader returns a single Mesh now then?

Copy link
Contributor Author

@agviegas agviegas Jul 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be precise, it retuns a single mesh and an API to work with that mesh.

In the beginning we were generating an object3d containing one mesh per item in the IFC file, but we found that this was already too laggy in medium sized files. The solution we came up with was generating only one single mesh (with one group per material), which dramatically increased the performance. That's the reason why we provide an API; to be able to access the individual elements, highlight them, get their properties, etc. That way, users can both have big models at 60 fps and still be able to work with individual items, as if they were separate meshes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see...

How about making IFCLoader return a IFCModel that extends Mesh then?

Then we can just do:

scene.add( model );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't mind, but we would like a firm decision before changing the API and documentation again 😅 We have already made the API accessible from the IfcModel instances, not only from the IfcLoader. If we make the IfcLoader return an IfcMesh, should we provide each IfcMesh with all the methods of the API? For example: IfcMesh.getExpressID() .

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry...

When I suggested returning a Group instead of a Scene I was not aware that the the Scene had only one child.

We could follow GLTFLoader approach which returns an object:

loader.load( 'foo.ifc', function ( ifc /* { manager : IFCManager, mesh : Mesh } */ ) {

    const mesh = ifc.mesh;
    scene.add( ifc.mesh );

    const manager = ifc.manager;
    const id = manager.getExpressId( mesh.geometry );

} );

This approach would also be backwards compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! Sounds good, we'll do that 👌

Copy link
Contributor Author

@agviegas agviegas Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look correct?

export class IFCModel extends Mesh {
    modelID = modelIdCounter++;
    mesh = this;

    constructor(geometry: BufferGeometry, materials: Material | Material[], public ifcManager: IFCManager) {
        super(geometry, materials);
    }
}

You can add IFCModels directly to the scene, and also call the IFC methods directly from them through their ifcManager property. The mesh property is to maintain the back/compatibility until we release the next major version.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems safer?

export class IFCModel extends Mesh {
    modelID = modelIdCounter++;
    mesh = this;
    manager = null;

    setIFCManager( manager ) {
        this.manager = manager;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants