How to obtain meshLevel during model transformation?

I set generate_LODs parameters to true during model conversion.
However, setting LOD through the setMeshLevel method does not take effect.Except for generate_LODs What else parameters need to be set?


We have a sample that comes with the HOOPS Communicator package that walks through changing level of detail for selected notes in the scene. You access the JavaScript sample code for that sample by going viewing the following file:


One thing that stands out to me is we check to see if the selected node is a body, and if so we traverse up the model tree to grab the parent and then apply the new mesh level. You can see that code:

LevelOfDetailExample.prototype._onSelection = function (selectionEvent) {
            var selection = selectionEvent.getSelection();
            if (selection.isNodeSelection()) {
                this._selectedNodeId = selection.getNodeId();
                var model = this._viewer.model;
                if (model.isNodeLoaded(this._selectedNodeId)) {
                    // If we selected a body, then get the assembly node that holds it (loadSubtreeFromXXX() works on assembly nodes)
                    if (model.getNodeType(this._selectedNodeId) ===
                        Communicator.NodeType.BodyInstance) {
                        var parent_1 = model.getNodeParent(this._selectedNodeId);
                        if (parent_1 !== null) {
                            this._selectedNodeId = parent_1;

I’m not sure how you are selecting the nodes to apply the different level of detail, but maybe you need to check the node type first.

If you want to show me the code you are using to change the mesh level, that could help diagnose the issue.

Thanks, and hope that helps!

1 Like

Yes,I’m sure the selected node is a body.I use the following code to apply the new mesh level:

hwv.model.setMeshLevel([0, 65], 2)

What can be determined is that the nodes used as parameters above are the body.This has been tested and verified through the getNodeType method, and it is indeed a body.
I am considering whether the parameter settings during the model conversion process may be incorrect.
So I would like to ask which parameters need to be set during conversion?

Hi again,

Can you share the full command line that you are using with Converter to create your stream cache file?

Also, is there a chance you can share your input file with me so I can try and generate the LODs and see about setting the desired mesh level? If so, let me know and I can DM you a link to upload.

It is also important to note that HOOPS Communicator can only generate LOD’s via converter if the original CAD model has brep geometry, as the LOD’s are generated from the breps surface/curve data. That means that for example for tessellated formats like gltf or fbx no lod’s will be available. See here:

Most of the models I use are in ifc and rvt formats.Here are some of the models I used. (4.9 MB) (463.6 KB)

1 Like

Ifc and Revit models generally don’t contain brep geometry so enabling LOD generation via converter will not do anything. Try converting the landinggear model from our package (in authoring/converter/example/_data) for an example of correct LOD generation. After converting this model with the --generate_LODs setting, you will notice that when you click on the part, there is an option in the right click menu to switch to the different lod levels.

Hope this helps.

1 Like

Good point about there needing to be BREP in the input model @guido . I forgot about that detail until you mentioned it. The description for the option does mention that LODs will be generated for every brep body, but I submitted a feature request to our learning team to add a bit more the description discussing how the option will not do anything for formats that do not contain BREP or where Exchange/Converter does not read the BREP.


I used the step format model and saw the effects in different lod levels.

1 Like

It is also worth noting that improvements to our lod functionality are on the roadmap so stay tuned for more information on this topic.

Also, if your goal is to limit the triangle count for your models in the webviewer, then in particular for AEC models, you can always turn off the visibility for certain less relevant categories of entities (e.g. furnishing elements) or selectively decide to not request them from the server via our onDemand streaming mode.

1 Like