-
Notifications
You must be signed in to change notification settings - Fork 11
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
Creating one mesh for the ThreeJS scene using the WASM #9
Comments
Well, I think it's important to separate some things regarding performance.
Instead of hacking this into three js I'd rather work with https://github.com/opensourceBIM/BIMsurfer/ While not very actively maintained, it is designed from scratch with large bim models in mind. Which isn't so hard when using some of the modern webgl2 api calls. It also has a couple of nice features such as section planes, measurement and cad-friendly orbit. You can try it online at https://view.ifcopenshell.org/ when you toggle rendering engine. |
Hi @aothms and thanks for taking the time to reply in such detail, it has helped me make my thoughts clearer. Of the three things you mentioned, the main one I would like to target is the second: Loading time. Right now, with the Wasm-preview demo, it takes 45 seconds to load a 10Mb IFC file (I profiled it using the Chrome dev tools). The same model takes 15s to load in IFCjs (but with more errors...). How do you think this parsing and geometry generation step can be sped up to similar speeds to IfcJS? Based on the code and the profiler, it seems to me like we are doing a lot of back-and-forth calls from JS/Pyodide to Wasm and back over and over again: So, in my mind: if the IfcOpenShell WASM was able to, with one function call, output/return an entire model/object of the complete IFC file in a format compatible with ThreeJS (doing this in much faster compiled code), then we would have a "drop-in" replacement (or compatible library...) for IFC.js. |
Cool insights from profiling. I'd be tempted to think the problem is not so much the per-mesh creation, but the way we go in C++ from (a) native array (b) sequence of python floats (c) sequence of javascript floats (d) javascript typed array. It looks trivial in code [0], but there is a lot of unnecessary back and forth. Also creating submeshes based on the material idxs doesn't help [1] of course. [0] https://github.com/IfcOpenShell/wasm-preview/blob/master/index.html#L172 So we need to look into [2] and [3] to seemlessly get the C++ buffers accessible in JS wasm as typed arrays. [2] https://pyodide.org/en/0.16.1/type_conversions.html#typed-arrays It seems that is a prerequisite anyway. If after that it is still obviously slow, we can (optionally) concatenate these buffers on the C++ side. Thoughts? |
To be honest I don't understand this callstack very well. It would be cool if we can annotate this profiling run with the various "events" that occur during page load, such as parsed ifc model, geometric tesselation computed, webgl representation created. So that we have a better understanding of the spacing between these events. |
I've attached the trace created using Google Chrome Dev Tools in case you want to load it and explore: The trace starts after all the WASMs are loaded and just before I click on "load" which starts loading the model: I'm not familiar enough with the lower-level function calls to tell where the transition from parsing to geometry creation happens. |
Hello @aothms,
I have a question that's been bouncing around in my head for a while: is it currently possible (or how much work would it be...) to have the IfcOpenShell WASM generate one single mesh (or multiple) without having to iterate in javascript over the entire model and create unique meshes (which is very slow)?
If I understand correctly, this would be a similar approach to how IFC.js loads the model into ThreeJs. They have the heavy lifting of generating the mesh done by the WASM which spits out one mesh that is then loaded into the ThreeJs scene and then use subsets to turn things on and off.
I think this would be an interesting direction to take the IfcOpenShell WASM in the short term since it would make it into a possible alternative IFC loader for ThreeJs. I like the work IFC.js is doing but IfcOpenShell is a more mature API in my opinion and it's always good to have options 😃
Thanks for your time!
The text was updated successfully, but these errors were encountered: