My understanding is that we can add custom skyboxes to the viewer. As of now I am also aware the feature that changes background color and gradient. However, is it possible to add a custom background image? This would've been really helpful in our scenario.
As I know, if your models are translated from Inventor, and you had set custom background up before uploading, then you can see the user-defined background shows up in the Forge Viewer. In contrast, your models are from another software, I have to say sorry there is no APIs or existing feature for that without adding the skybox.
However, I have logged a similar case in our internal case system a few months ago to make our engineering team allocate time to take a look, its' id is DERI-4307. You can track updates of this request by sending this id to forge.help#autodesk.com in the further.
P.S. As I know, viewer requires some extra textures for changing the viewer background with custom images. Unfortunately, there is no way to generate this on none Inventor models currently. You can refer some information about the DERI-4307 here :
How to add custom environment map for background in autodesk forge?
Related
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:
Im working with NWC models translated into SVG and i need to change the materials/textures from it. I created my own custom materiales with textures with MeshPhongMaterial but the result isnt the same because the quality is bad, i just need to replace the img texture of that material. Could you tell me what is the correct way of doing this? Thank you.
Is there any example of changing materials/textures in autodesk-forge that you con provide me?
Materials coming from SVF can be quite complex, with varying schemas. For example, the carbon fiber material in the screenshot below is loaded as a THREE.ShaderMaterial with many custom properties such as layered_anisotropy, layered_bottom_f0, layered_bottom_f0_map, or layered_diffuse.
Because of that, customization of textures of SVF materials would be very difficult unfortunately.
If the quality of the custom THREE.MeshPhongMaterial is not sufficient, I'd suggest tweaking some of its parameters, for example, adding an environment map (see an example).
Is it possible to export a view as more than 1 image? in any kind of split.
When exporting the view as an Image I want to keep the scaling consistent and Revit will not allow export an image with more than 15000 pixels. So on big Models I want to split the image to keep the meter per pixel consistent.
Any other suggestions are welcome.
I am not aware of any such possibility.
Please be aware of the following rule of thumb:
In general, if a feature is not available in the Revit product manually through the user interface, then the Revit API will not provide it either.
You should therefore research the optimal workflow and best practices to address your task at hand manually through the Revit user interface first.
To do so, please discuss and analyse it with an experienced application engineer, product usage expert, or product support.
Once you have got that part sorted out, it is time to step up into the programming environment.
I hope this clarifies.
I was able to do it by cropping different parts of the view and hiding everything outside the crop before the export. As the image export only export the visible elements.
I've encountered a different issue now, there are different visible objects outside of the actual model that interfere with the image export, sometimes those are elevation markers, site internal origin, other hidden annotations and many more.
Is there a way to hide absolutely everything outside the crop? do I need to go over every instance of a list of possible visible objects and hide them?
Thank you for sharing your solution to the original question on exporting several images displaying different elements by toggling their visibilities.
Regarding your second, new, question, on interfering elements such as 'elevation markers, site internal origin, other hidden annotations and many more':
Yes, indeed, I would suggest hiding those as well, just as you successfully handled the other 'standard' BIM elements, e.g., using the HideElements method, HideElementsTemporary, or, maybe better still for such special element types, hiding their entire categories using HideCategoriesTemporary.
I am brand new to Forge and making my way through some documentation but it seems quite hard to get some of the older examples working (pages don't load correctly etc) and I am currently using version 6, which seems newer than many examples too.
Is it possible in client-side code to take in some user data and generate a heatmap (overlayed ontop of the floor of a house) based on that data (i.e. different blocks of colour, it can be quite rudimentary).
This is using a Revvitt model uploaded to Forge and shown in the Viewer.
I have no experience with Three.JS but if anyone could point me in the right direction, show me a working example, or at least tell me if its possible I would greatly appreciate it!
There are a couple of options, with different levels of complexity:
You could use the official viewer APIs such as setThemingColor and clearThemingColors to add a semi-transparent color tint to selected objects.
If you need to overlay scene elements with anything more sophisticated, you could replace their original material with a custom THREE.ShaderMaterial. Just be sure to follow the documentation of three.js version 71 which is used by Forge Viewer. The process of adding new materials to Forge Viewer, and assigning them to specific objects is explained in https://forge.autodesk.com/blog/forge-viewer-custom-shaders-part-1. The article is a bit old, but I think the relevant parts of it (mainly the createShaderMaterial and selectionHandler functions) can be reused.
It came to my knowledge that custom background images can't be uploaded with the model to the Forge viewer (or added from any code) - but - by using Inventor there is a workaround. Or should be if I am correct?
I've added my custom background image to my model in Inventor using these steps, however the changes doesn't reflect in the viewer (still displaying the environments)
Would anyone kindly share the correct steps with me. Thanks a lot.
After reviewing the mentioned answer and checked with a few colleagues working on it: this still under research and we don't have the proper steps to make it work. It is logged as a feature request.