Trying to render 2d image inside the forge viewer with 3d model - autodesk-forge

My current use case is to align a 2d image to a 3d model inside the forge viewer allowing zoom as well as panning functionalities. I have tried the following implementations -
Adding the 2d image as an overlay scene on the forge viewer but the problem there is that I can't position the model on the image precisely even though i have tried translating, rotating and scaling the model programatically.
Loading two different viewers on top of each other and then using viewer.getState() and viewer.restoreState() to sync the state between the two viewers on Autodesk.Viewing.CAMERA_CHANGE_EVENT.
Placing the image inside the HTML beneath the forge viewer and then disabling the pointer events on the viewer and using Javascript to zoom both the viewer and the image in sync. But the problem there is that the measure tool doesn't seem to work right.
What am i missing?

I assume that you simply want to insert a 2D raster image into the viewer scene. That can certainly be done using the 1st approach you suggested. Use an overlay scene or the SceneBuilder extension to add a custom three.js mesh into the scene, and then apply your image as a texture to the mesh.
Regarding the placement of the mesh in the viewer scene, that really depends on your use case and the type of models you're working with. For example, if you wanted to place the image under the 3D model (perhaps the picture contains some satellite imagery), you could find the bounding box of the model using the viewer APIs (viewer.model.getBoundingBox()), and place the three.js object with your image at the bottom side of it.

Related

How can I get the x,y,z axes in forge viewer which is similar to HUD in Navisworks?

I want to show X,Y,Z axes in forge viewer at the bottom-left corner like Navisworks. I can create the axes lines (described here) in a certain position of the viewer. But, as expected, whenever I navigate to somewhere the axes also moves. I want it to be placed at the bottom-left corner every time and syncing with the viewer X,Y,Z axes. The Navisworks axes in HUD is like below -
Please share some good idea!
Forge Viewer doesn't offer this feature out-of-the-box but it should be pretty straightforward to implement something similar yourself.
I'd recommend using the approach used by the viewer's "view cube" (in the top-right corner). That cube is actually rendered in its own <canvas> element, and overlaid on top of the viewer canvas. You could create your own <canvas> element in the bottom-right corner, use standard three.js (specifically version 71 that's included in Forge Viewer) to render your axes there, and update their orientation based on the viewer's Autodesk.Viewing.CAMERA_CHANGE_EVENT.

Forge viewer displays elements blurry in 2D views and the Measure extension does not work on them

For some of our Revit models, in Forge viewer, 2D views are display blurry, no element can be selected and the Measure extension does not work on elements and only works on the dimensions and the titleblock.
Like this example:
here and here
But it should be like this
I have tested it with our viewer, A360 viewer and Autodesk Forge Tools vscode extension.
This is because 2D drawings or PDFs can contain both vector graphics and raster graphics (this article explains the difference between the two). The measure extension needs vector graphics in order to work properly.
Thanks to Petr Broz and his hint, by changing the Model Display Style in Revit side to Hidden Line instead of Shaded the problem was solved.
Like this.
Update:
The Shadows in Graphic Display Options, also should be unchecked.

Exporting markup data in RVT/CAD format

I am using Autodesk Markupscore Extension to draw markups on 2D view. I want to create a separate rvt or CAD file for the drawn markup, which can further be used/opened in Revit soft. So the newly created 2D view(rvt/CAD) will contain only that part of 2D view which is inside the drawn markup, How can I achieve this?
I can't comment on the Revit specific piece (for that I would suggest that you check out the Revit discussion forums) but if we're talking about where Forge can help, I see two options:
you could have a Revit plugin running in the Forge Design Automation service, accepting a Revit document and some coordinates of 2D markups on the input, removing design elements that are outside of the 2D markups via Revit APIs, and generating a new Revit document on the output.
you could customize Forge Viewer to hide or occlude the parts of the 2D drawings you don't want to be visible, for example, by "hiding" them (making them semi-transparent), by changing their color, or by overlaying them with another content such as a blank SVG rectangle.

Load a 360 panorama image in forge viewer

How do I load a 360 image viewer using forge viewer. One approach I tried was by creating a sphere with image as texture and add it to the overlay scene. Using this, I was able to load a 360 image but I'm getting rendering issues (in some specific views sphere is getting culled).
Check out the skybox sample here and see that fits the bill for you ...

Viewing Multiple .DWG files in viewer using Forge API

I need to see multiple .DWG in the Forge viewer in 3D format. There are some buttons on the viewer screen using which we can toggle between 2D and 3D views. On using those toggle buttons, currently we are able to see only one file at a time in the 3D view. Is there any option to view multiple files in 3D format?
You can use three ways to see multiple views of the same model.
Split the screen into multiple screens (SplitScreenExtension): https://forge.autodesk.com/en/docs/viewer/v7/reference/Extensions/SplitScreenExtension/
Place a view inside a div: https://github.com/Autodesk-Forge/viewer-navigation.sample/blob/master/www/scripts/model.js
Creating a div that renders a view within a DockingPanel.
I may have already answered this in your other Stackoverflow question, but, it is the same answer here. Try loading multiple models into a scene, using this blog post as your guide:
https://forge.autodesk.com/blog/loading-multiple-models-forge-viewer-v7
One neat trick with Forge Viewer, is the ability to load a 2D sheet inside the 3D world. The 2D sheet, if it comes from DWG, it will be vector lines, and if it's an old PDF, it will be image tiles.
Here's a video of combining 2D sheets into a 3D scene, into something more useful to your user...