Forge elements missing in some direction - autodesk-forge

My model is a pipe line and this is the screenshot from IFC viewer
and this is the screenshot from forge viewer
You can see in the forge I can't see the full pipe line. When I zoom in or change the direction some parts will missing. It only happens when close to model.

This seems to be one of the pathological cases where, due to the extremely large extent of the 3D design, the viewer heuristic (which tries to optimize the near/far clipping planes to avoid precision issues) fails. What's the bounding box of your model (you can retrieve it using viewer.model.getBoundingBox())?
To work around this, you could try the following:
switch the camera from perspective mode to orthogonal
set the near radius to 1 (viewer.impl.setNearRadius(1)) as suggested in this Stack Overflow discussion: Autodesk Forge Viewer - Near and Far clipping issues

Related

How to show/hide part of an element in Autodesk Viewer v7

We currently use the model derivatives API to upload 3D models and later visualize them in a browser with the Autodesk Viewer v7 (previously Forge Viewer).
For different reasons we have been trying to hide and show parts of the model, but to do so in some cases we need to be able to hide geometric pieces of some elements while still being able to see the rest. For example if we had an element in gray (see image below) we would like to make the part of the element in red transparent.
I have looked into the Viewer API docs and there are functions that allow showing and hiding complete elements, but not cutting elements along a custom path.
While the docs mention the overlay functionality which enables us to add custom geometries by interacting with the THREE library that the Viewer runs on, drawing a copy of the whole model seems inefficient and prone to giving bad results.
Searching in SO I found that the THREE v71 library (which is the version the Viewer uses) has the possibility of occluding elements with the colorWrite option. See these links for reference:
three.js transparent object occlusion
Occlusion of real-world objects using three.js
I tried implementing something similar by using the colorWrite key when creating a new Three Material in an overlay, but nothing happens. This makes me think that either the Autodesk Viewer overwrites the render order (which makes sense) or openly ignores the colorWrite option. Does anyone know why and if there is a workaround for this? Or does anyone know if there is another way to cut an element that I'm not considering?
Please note that we have to do this with multiple elements at the same time and that reuploading the model periodically is not an option for us.
I got the following feedback:
The approach linked in the SO thread doesn't work, because we ignore both the colorWrite material property and the renderOrder mesh property. I also think that the approach would not work as expected in general, because using an invisible object to occlude a part of another object would always be view-dependent, and also occlude other objects in the background (so it wouldn't just 'cut out' a part of a single object).
Generally, this is not really a use-case for LMV, because it's a viewing tool, not a solid modelling tool.
Cut planes might help to get some of what you want, but they also have limitations:
It's possible to define multiple section planes to construct a 'shape' (that's also what the section box does internally). But since they are infinite, you wouldn't be able to cut away parts of one object, but not other objects (or other parts of the same object that intersect the cutplane). They're also designed to be 'outward' facing. The section box, for example, can only be used to narrow the scene down to some elements of interest. It's not possible to do the opposite, i.e. cut out some inner part of the design and keep everything around it.
This is what the section box could offer:

Forge IFC model weird "shadow lines"

When an IFC model is uploaded and translated by Autodesk Forge, some weird "shadow lines" are generated and appear in the Forge viewer. These lines mostly are IFC wall elements and correspond to real walls in the model, but they are drawn under the actual model. Here is an example of such lines:
Now, if I try to add another model, which should align with the first one and I set both Global Offset Zs to 0, the added model fits into the shadow lines at the bottom and not the actual model. Thus, it seems that the shadow lines are the considered to be a part of the model. Here is a visualisation of the problem:
When I load the model with other IFC viewers, these shadow lines don't appear:
Thus, I guess these lines are generated during the Forge translation process. Where are these lines coming from and how can I get rid of these? And even more important, how can I align the models correctly?
Thanks for any kind of help!
EDIT:
When I use legacy conversion, the alignment works! Here is an image:
The problem is, that I need to have spaces and opening elements, thus I need to use the modern conversion.
The "shadow lines" probably are 2D representations of your building elements, and they are located on z=0.
The 3D representations seem to be located at a higher level, maybe the origin of this model isn't set correctly.
So what you see is basically a plan of your model at the correct z value, while the 3D elements are at a wrong z value.
This also explains why other models are places at the z level of the 2D representations.
The IFC files would be helpful to take a closer look.
The lines shown are actual geometries. Some viewers draw them, others don't. Unfortunately, our customer generates the data and isn't able to remove these line geometries.
The main problem of aligning the models was fixed by manipulating the IFC file. We figured out, that one model has a geographic reference point defined in the IfcSite and the other doesn't. When we replaced the longitude, latitude and elevation attribues by '$', the alignment worked again. According to iFC definition, the geographic reference point is only given for informational purposes, but still, it affects the global offset, at least when using 'modern' conversion.

Forge viewer slows down when added SVG on it

I am using Autodesk Forge's Markups core extension to draw some shapes on a forge viewer, which is rendering 2D sheet(rvt). Once I draw a shape I save its SVG in my DB to redraw it later. To redraw the shape I use markupExtension.loadMarkups(svgData, LayerName).
Somehow my forge viewer's performance slows when I redraw some shapes on the sheet. The zooming and selection of elements slows down.
Can someone please help me solve this issue?
Using markupExt.loadMarkups() is the correct way to recreate the <svg> element with all your markups. It should provide the exact same performance as the markups you created earlier by hand.
Make sure that you're not accidentally calling the function multiple times, creating many copies of the same SVF markup. And if you're still having issues with the performance, please share your code here so we can have a look.
You have more than one SVG element tag in your markup which is slowing your viewer down. Try to move all the markup elements in one svg.
Or
Are you trying to invalidate the viewer, if so then don't do it because your webGL canvas will be redrawn again and again
I was doing the same thing then I remove the line
NOP_VIEWER.impl.invalidate(true);

viewer v7 performance regression

Did anyone else notice graphic regression in the new v7 of the autodesk forge viewer? The new features like ambient shadows look nice, but the basic viewer has worse output in terms of navigation. I have some samples here comparing v6 to v7 with most graphic features turned off and progressive display and smooth navigation turned on.
v6, only distant objects disappear
v7, almost all models disappear, this even happens without smooth navigation
v6, orbiting doesn't turn models inside out
v7, orbiting does turn models inside out
v7, the disappearing models makes it the easing of the zoom pretty annoying, since it only shows objects if the camera has completely stopped moving
I can see the progressive display hiding as a potential feature, but I wonder is there a treshold or depth where progressive display will hide meshes that is can configurable? The flipping of mesh normals seems more like a bug.
The progressive display can only be turned on/off. There's no granular level of control, unfortunately.
The progressive rendering is driven by a hard-coded "frame budget", where the viewer tries to render as much content as possible within the given number of milliseconds. It's possible that v7 introduces shader/rendering changes that affect the amount of geometry that can be rendered within the same budget. And as far as the inverted normals, that does look like a bug. Let me report your observations to the dev team to get more details on that.

Change size of cutplanes tool in Forge Viewer

I'm using ForgeViewer to display both IFC models and custom geometry (point clouds and meshes using THREE.js directly), and I'm using the Section tool to cut away parts of the model.
Is there anyway I can set the size of the planes in the UI. I want the arrows and planes to be centered around specific models making them easier to use. Also, it would be nice to be able to set the default size and position of the cutting box.
The size of the cutting plane/box as well as the position of the manipulating gizmo are estimated by the section tool based on the bounding box of all visible objects. There's no UI to change that behavior, but you might be able to reverse engineer the official Section tool and perhaps modify it to your needs.
Edit: alternatively, you could retrieve the THREE.js geometry representing the cutting plane after it's been created by the Section tool (and placed into viewer.impl.sceneAfter) and customize it as needed.
Adding to Petr's answer...
Use the 'box section' tool (see screenshot) and manually adjust the box size by clicking on each of the box faces to adjust.
Then use Augusto's blog post (below) to programmatically capture (using viewer.getState();) and replay your box section (viewer.setCutPlanes(planes);).
https://forge.autodesk.com/blog/viewer-setcutplanes