xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
728 stars 287 forks source link

Less performances when loading from XKT instead of glTF (FPS) #143

Closed Amoki closed 5 years ago

Amoki commented 5 years ago

I have less FPS when I load a model from XKT than glTF. All tests has been made with the latest commit (7e58c886519dcc19987f77da4281008339797471)

Unfortunately, I can't share the model but I can give some information: The glTF weights 58,7MB and the XKT 42,4MB. The model is the plumbing of a big building.

glTF loads in 1 minute and 30 secondes (between gltfLoader.load() and model.once("loaded") XKT loads in 1 minute and 25 secondes (Not much faster).

After that, the glTF is very smooth (I've never seen this model runs that smoothly). The XKT runs at ~10 FPS (by rule of thumb). According to Chrome debug tool, the V8 engine takes 1.8 GB of RAM with glTF and 1.6BG with XKT.

I can give more information (debug, memory snapshot and more) but I don't know what to do and how to do it.

Do you have any clues?

xeolabs commented 5 years ago

I think the best thing would be for me to play around with a model that has similar performance - would you be able to generate a similar-performing glTF?

Have you tried the model with one of the earlier xeokit releases?

tmarti commented 5 years ago

One thing that could be done, is to instrument the batchingLayer.js and the ArrayBuf.js class.

The 1st could provide an additional parameter to the 2nd to tell which type of buffer is being loaded ("positions", "indices", ...).

The goal is dumping how many total positions and indices are loaded into GPU-buffers for each case (glTF vs XKT), and start the analysis from there.

@xeolabs: do you agree that the small difference in load times could point to having a heavy case of geometry instancing?

I checked the code for the glTF->XKT conversor, and code is slightly different from the prototype I did, so I'm not sure on how to instrument the conversor to measure the % of instanced objects, but a high % of instanced geometries would confirm the hypotesis of having hit an instancing-intensive model.

That would also explain the similarities in file sizes (glTF vs XKT), because the advantages XKT format v1 degrade as higher is the instancing % (for v1, each instanced geometry in the gltf expands to duplicated positions/indices data on the XKT file). This by no way means the XKT format is useless (in our cases it reduces the file size to about 15% and boosts load times about x6), just that it needs to explicitly support geometry instancing 😉

tmarti commented 5 years ago

@Amoki: grab your popcorn 🍿 and await for the next week 😉

xeolabs commented 5 years ago

@Amoki I've just added @tmarti's support for geometry reuse in XKT. Could you try again using the latest updates to xeokit and xeokit-gltf-to-xkt?

Amoki commented 5 years ago

It's awesome! It's really fast! Loading the model is now faster than building the DOM for the structure! :p

tmarti commented 5 years ago

@Amoki, I'm just curious about the new size for the v2-XKT file you converted (just the size) 👀

Amoki commented 5 years ago

6,21 MB!!