-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Update IFCLoader #22113
Conversation
Thanks! |
ifcLoader.load( 'models/ifc/rac_advanced_sample_project.ifc', function ( model ) { | ||
|
||
scene.add( model ); | ||
scene.add( model.mesh ); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 );
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👌
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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;
}
}
Latest updates from IFC.js, which are a lot. Some of them are: