Skip to content

Instantly share code, notes, and snippets.

@ajlyons

ajlyons/app.R Secret

Last active June 1, 2021 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajlyons/58233833b4b5ccde08fd47810802f6f5 to your computer and use it in GitHub Desktop.
Save ajlyons/58233833b4b5ccde08fd47810802f6f5 to your computer and use it in GitHub Desktop.
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