engine_components
engine_components copied to clipboard
IfcFragmentLoader creates transformations with shear, causing problems down the line
Describe the bug 📝
When I import certain models with IfcFragmentLoader, the loading process introduces shearing to the matrices. Shearing is not supported well by some engines. See this issue for example.
There's no clear way to detect shearing in matrices, which means that the only way to make geometries generated by IfcFragmentLoader to work outside is to duplicate them and apply the corresponding instance matrices to them. This wastes memory and / or increases file sizes (if for example I decide to export the model in glTF format). And figuring out the problem can be very difficult in the first place.
Reproduction ▶️
https://shear-problem.netlify.app/
Steps to reproduce 🔢
- Open reproduction
- Wait until it has loaded the pre-configured IFC file
- Save the exported GLB file wherever you want
- Open the GLB in Blender or any other glTF-capable viewer
- Observe how every component has been misplaced.
The problem is that the matrix cannot be decomposed cleanly into position, rotation and scale as has been established in this issue this issue.
The code is unoptimized so it can be read. And it's based on IfcFragmentLoader example with some extras removed (and IfcSite is added to the excluded categories).
System Info 💻
System:
OS: Linux 6.8 Pop!_OS 22.04 LTS
CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF
Memory: 18.33 GB / 31.19 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 20.12.2 - /usr/bin/node
npm: 10.5.0 - /usr/bin/npm
Browsers:
Chromium: 123.0.6312.105
npmPackages:
openbim-components: 1.5.0 => 1.5.0
Used Package Manager 📦
npm
Error Trace/Logs 📃
No response
Validations ✅
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a repository issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
- [X] Check that this is a concrete bug. For Q&A join our Community.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Hi @wlinna!
Have you tried to apply the FragmentsGroup.coordinationMatrix to the elements right before exporting the model to GLB?
EDIT: Hi there, thanks for the response!
When I apply coordinationMatrix to the model, I do it on the root of the model. However, whether I apply it or not, this problem remains the same. I have indeed tried.
Hi @wlinna this might happen due to 2 reasons:
1 - You are probably using the web-ifc option OPTIMIZE_PROFILES: true. This is something that we set as true by default because it helped with performance, but now that we have streaming we are removing that option for simplicity's sake. Basically, this deduplicates all circular and rectangular extrusions. This shouldn't be an issue in future versions, and if you are using a past version, you can already disable that by setting that option to false when reading an IFC.
2 - Because the shear comes from the IFC itself.
If the cause is 1, is solved. If the cause is 2, there's nothing we can do, because we are just reading the transformations present in the IFC and using them to create the geometry. Either way, this issue is either solved, or has no solution. Let us know!
Thank you, OPTIMIZE_PROFILES was the cause. The problem disappears once I disable it