Autodesk Forge Viewer. Selecting large number of elements (updating question) - autodesk-forge

Following this discussion Autodesk Forge Viewer - Selecting large number of elements (performance). Today is November 2022, maybe something has changed in the situation with the selection of a large number of elements? For example, in my case, I may need to select one million elements in the model (a model of a large building)

In case you're not using this feature yet, consider looking at the "selection type" that can now be passed to selection methods such as toggleSelect. The selection type can be one of the following:
Autodesk.Viewing.SelectionType.OVERLAYED
Nodes are tinted with the selection color and shown on top of the not selected geometry.
This does not scale for larger number of selected elements as they are rendered twice - once using their original shader, and then again using the highlight shader
Autodesk.Viewing.SelectionType.REGULAR
Nodes are tinted with the selection color.
This is better for performance reason - selected objects are only rendered once, with a color tint applied to their shader
Autodesk.Viewing.SelectionType.MIXED
Leaf nodes are selected using the overlayed selection type, and inner nodes are selected using regular selection type.

Related

Models created with `SceneBuilder` in `AggregatedView` disappear/reappear on rotate/zoom when loaded in combination with larger models

Custom objects disappear on every orbit zoom or rotation for about one second, then reappear again when added to a aggregated view in combination with a large model. While the objects are hidden, I can see that there is some reloading/rerendering of the other unrelated model going on.
Overlays (meshes rendered directly into threejs) obviously don't show this behavior.
I'm using viewer version 7.85 and the sample code from here: https://aps.autodesk.com/blog/custom-models-forge-viewer
modelBuilder.addFragment(sphereGeometry, sphereMaterial, sphereTransform);
Is there any way I can prioritize rendering of my custom model or disconnect the rendering from other loaded models?

How do I get element in Forge Viewer by lvid/rvid or loid/roid from Clash Test Report from Forge?

I am trying to extract data from the clashing elements from Model Coordination in BIM 360. The clash report gives me lvid's and rvid's (left and right visual id's of the clashing elements) as well as the loid's and the roid's (left and right object id's).
However, the viewer only gives me the dbId for each element and it doesn't match the lvid/rvid's or the loid/roid's.
Here is a video on the problem I am bumping up against. Does anyone know how to tie these two, seemingly differnt, id's together?
https://youtu.be/aRxR_nuhyvk
The dbId for the element in question is 1697376, but the only lvid and loid values available don't match it at all. How do I tie these together?
Image of possible lvid's or loid's per the clash report

Apply custom appearance to individual model fragments in forge viewer

In the viewable, the model has three leaf nodes that are named “Solid1” but have a parent name of “Tread”, how do I search by parent name to get the dbId?
Following the answer from Default material for model in Forge Viewer I can see that we can set a color. Is it possible to instead apply a texture?
Thanks!
The Viewer has a search() function so you can search for any component based on its properties. You can then go up and down the instance tree to go from Thread to Solid1 or vice versa. See e.g.
https://forge.autodesk.com/blog/selection-override
Yes, you can also use texture for materials. See e.g. https://github.com/Autodesk-Forge/library-javascript-viewer-extensions/blob/master/src/Autodesk.ADN.Viewing.Extension.Material/Autodesk.ADN.Viewing.Extension.Material.js#L273
That code is used in this sample https://forge-rcdb.autodesk.io/configurator?id=58c7ae474c6d400bfa5aaf37
Just enable the "Material" extension by clicking on it, then you will be able to assign textured materials to faces.

Highlighting only the geometry of a parent object in autodesk's online viewer

We have revit model in which a parent element has both children and its own geometry. In the online viewer it is possible to select the parent through clicking the respective geometry, in which case only the geometry for the parent is highlighted. (selected through a click)
If I select the element through the tree the whole model gets highlighted.
(selected through the model browser)
In our web application, we are unable to get the former behavior. When passing the dbId of the parent to viewer.select, the parent plus all the children get highlighted. Same happens when we click the parent element's geometry. How can we select only the parent object programmatically?
We have tried passing different selection modes (overlayed, regular, mixed) to viewer.select but that didn't help and all objects got selected regardless of that parameter.
In this question it is mentioned by autodesk staff that only leaf nodes have geometries. That doesn't seem to be the case here:
Determine if node is an assembly or part in viewer
Thanks for the sample file. I did the following: open the model, select manually and, via console, typed .getSelection(), which returns me the dbId of the selected element. Now unselect everything. Then run .select(2890) and the result is as expected: only the top element is selected (as shown in the image below). I'm using Viewer 3.3.
You can try my sample live here, it uses the Basic Application tutorial.

How to make selection work for 2D multi-models in Autodesk-Forge Viewer

I have a couple of DWG drawings which I have converted into F2D files for offline viewing.
There is a base model which I load on the viewer initialization. Other drawings are loaded using viewer.loadModel as in when required.
These drawings get loaded fine. The problem is that it messes up the selection. Only one of the loaded models gets selected (and gets highlighted) on mouse down.
When I check the selection on the event received in AggregateSelectionChangedEvent, the selection has only the first model. So, I cannot even distinguish the model which has been selected.
Since some of the drawings can be loaded multiple times, (Consider a car drawing where one can load same wheel drawing and place at 4 positions) the dbId of the selected entity is same for multiple models. So, dbId can not be used as the only parameter. What I need is dbId + model.id combination to tell the selected object apart.
As per the suggestion received from elsewhere, I was setting
renderer.settings.numIdTargets = 2.
This made the selection work for multi-model pretty much as normal selection.
It worked a while, then suddenly stopped working. I am not able to figure out why.
Can anyone suggest a lasting solution to this problem?