I am in Gothenburg supporting the Forge accelerator.
My project here is ForgeFader, implementing the same end user functionality as the RvtFader Revit C# .NET API add-in that I implemented last week.
I have not quite finished it yet, but the existing functionality looks as if it already ought to be very useful indeed to anyone working with geometry in the Forge viewer.
Inspired by Kean Walmsley's note on enabling Visual Studio Code’s integrated web debugging, I am using Visual Studio Code to develop ForgeFader and very happy with it indeed.
I have not actually enabled the integration with Chrome debugging that is the main point of Kean's article, but just using this as an editor is a good start.
ForgeFader implements a Forge viewer extension to calculate and display signal attenuation caused by distance and obstacles in a building model with a floor plan containing walls.
It implements a functionality similar to RvtFader:
Given a source point, calculate the attenuation in a widening circle around it and display that as a heat map.
Two signal attenuation values in decibels are defined in the application settings:
This app is based on Philippe Leefsma's Forge React boilerplate sample.
Please refer to that for more details on the underlying architecture and components used.
The ForgeFader implementation lives in Viewing.Extension.Fader.js.
On loading, in onGeometryLoaded
, it determines the Revit BIM wall fragments for subsequent ray tracing.
On picking a point on a floor in the model, in onSelection
, it launches the attenuationCalculator
function to do the work.
That fiddles around a bit to determine the picked floor top faces and add a new mesh to the model on which to draw the attenuation map.
Once the mesh has been added, it in turn calls rayTraceToFindWalls
to create a bitmap representing the signal attenuation to be displayed by a custom shader.
When debugging any kind of geometrical programming task, it is of utmost importance to be able to comfortably visualise the situation.
In this app, I add three different kinds of geometry dynamically to the model displayed by the Forge viewer:
Three example screen snapshots illustrate what I mean.
Display points and lines for debugging using drawVertex
and drawLine
:
Create a mesh to represent the floor top face and offset it up slightly above the floor surface:
A debug helper displaying lines in the model representing the ray tracing rays:
(u.v)
values to the desired colour value.I made the following notes during the research and implementation steps.
urn
: models.autodesk.io.dXJuOm...ydnQ
forge-rcdb.nodejs
sample Viewing.Extension.Configurator.Predix.js
onSelection
; it relies on EventTool
and EventsEmitter
.Viewer.Toolkit/Viewer.Toolkit.js
getLeafNodes
.library-javascript-viewer-extensions
Viewing.Extension.Transform/Viewing.Tool.Rotate.js
onPointerDown
and pointerToRaycaster
.scene.add
and pass a mesh.drawFace
in Snapper.js.I want to attach a fragment shader to the picked floor face. My shader should draw an image or texture directly, i.e., the desired 'heat map'. Here are som more complex pixel shader samples. I need to implement a fragment shader script and equip it with an id.