resp <- getToken(
id = Sys.getenv("client_id"),
secret = Sys.getenv("client_secret"),
scope = "data:read"
)
myToken <- resp$content$access_token
myEncodedUrn <- jsonlite::base64_enc(Sys.getenv("urn"))
# Full viewer — great for exploration
viewer3D(urn = myEncodedUrn, token = myToken)
# Headless — embed in a dashboard without the toolbar chrome
viewer3D(urn = myEncodedUrn, token = myToken, viewerType = "headless")
# VR mode for a phone or headset
viewer3D(urn = myEncodedUrn, token = myToken, viewerType = "vr")6 Viewer
The AutoDesk Viewer is a WebGL-based 3D model browser that runs entirely in the browser. With AutoDeskR, you can embed it in a Shiny app with a single function call — no JavaScript required. Rotate, zoom, and inspect your models without leaving R.
Before launching the viewer, you need a file translated to SVF format and its encoded URN — the Model Derivative chapter covers both steps.
6.1 Launch the Viewer
viewer3D() opens a Shiny app with the viewer pre-loaded. The viewerType parameter controls the UI chrome:
viewerType |
What you get |
|---|---|
"header" |
Full toolbar, navigation panels, and settings (default) |
"headless" |
Viewer canvas only — clean embed for dashboards |
"vr" |
WebVR mode, optimised for mobile |
When you run viewer3D() in RStudio or a browser, a WebGL viewport opens and you can rotate, zoom, and click elements to inspect their properties. The viewer renders whatever SVF translation produced: layer geometry for DWG files, full BIM elements for Revit.
6.2 Embed in a Shiny App
viewerUI() drops the viewer into any Shiny layout as a module. The id parameter namespaces the module so multiple viewers can live on the same page without stepping on each other.
library(shiny)
library(AutoDeskR)
ui <- fluidPage(
viewerUI("viewer1", urn = myEncodedUrn, token = myToken)
)
server <- function(input, output, session) {}
shinyApp(ui, server)6.2.1 Viewer in a Tab Panel
Headless mode is perfect for a multi-tab layout — the viewer sits in one tab and data tables or charts in another:
ui <- fluidPage(
tabsetPanel(
tabPanel("Model",
viewerUI("viewer1", myEncodedUrn, myToken, viewerType = "headless")
),
tabPanel("Metadata",
verbatimTextOutput("meta")
),
tabPanel("Layer Chart",
plotOutput("layer_plot")
)
)
)
server <- function(input, output, session) {
output$meta <- renderPrint({
# getData() results displayed alongside the viewer
})
}
shinyApp(ui, server)6.2.2 Viewer + Sensor Dashboard
Pair the headless viewer with a dygraphs time-series panel for a live digital twin layout — see the Live Dashboards chapter for the full implementation:
library(dygraphs)
ui <- fluidPage(
fluidRow(
column(7, viewerUI("twin_viewer", myEncodedUrn, myToken, viewerType = "headless")),
column(5, dygraphOutput("sensor_plot", height = "500px"))
)
)6.3 What’s Displayed
The viewer renders whatever the SVF translation produced. For a DWG file, that’s the full drawing geometry organised by layer. For a Revit file, it’s the full BIM model with element properties accessible in the side panel. Click any element in the viewer to inspect its properties — the same data that getData() returns programmatically.