Skip to content

Instantly share code, notes, and snippets.

@ajlyons

ajlyons/app.R Secret

Last active Jun 1, 2021
Embed
What would you like to do?
A fully functioning basic 360 viewer for Shiny (R). See
library(shiny)
## Create a vector of the JPG files in the 'www' directory.
## We do this *outside* of ui() and server() because this only needs to be done once and only once
imgs_fn <- list.files("www", pattern = "JPG$|JPEG$", ignore.case = TRUE)
## Define the UI
ui <- fluidPage(
titlePanel("Simple 360 Photo Viewer"),
sidebarLayout(
sidebarPanel(
selectInput("img_fn", "Image", choices = imgs_fn, selected = NULL),
width = 2
),
mainPanel(
uiOutput("pano_iframe")
)
)
)
server <- function(input, output) {
output$pano_iframe <- renderUI({
## Construct the iframe URL
src_url <- paste0("pannellum.htm#panorama=",
input$img_fn,
"&autoLoad=true&autoRotate=-2")
tags$iframe(src = URLencode(src_url), width = "1200px", height = "600px")
})
}
# Run the application
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment