Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Voyager 3D betatest previewer #78

Merged
merged 8 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions 6.1curlcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1753,5 +1753,39 @@ curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin
]
}'
```
### Smithsonian Voyager 3D model Previewer (beta)

__Note:__ Voyager supports multiple formats. Only *.glb (model/gltf-binary) is currently supported by the Previewer.
Also note that with current styling the Voyager app fills the window when launched as a separate page, so the usual
preview header/footer information doesn't show (and therefore isn't even requested from Dataverse).

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"View 3D model",
"description":"Explore the 3D model file using Voyager.",
"toolName":"voyagerPreviewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/VoyagerPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/gltf-binary",
"allowedApiCalls": [
{
"name": "retrieveFileContents",
"httpMethod": "GET",
"urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=true",
"timeOut": 3600
}
]
}'
```

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ The image previewer only works with image/tiff files on some browsers (as of ~Ja

The original tools were developed through the [Qualitative Data Repository](https://qdr.syr.edu) but are being offered to the Dataverse community at large.

[qqmyers](https://github.com/qqmyers) - developer of the original previewer framework, contributions to the Rich Html Previewer
[qqmyers](https://github.com/qqmyers) - developer of the original previewer framework, contributions to the Rich Html Previewer, Voyager Previewer, updating to use signed URLs

The Spreadsheet Previewer was contributed by [anncie-pcss](https://github.com/anncie-pcss).

[pdurbin](https://github.com/pdurbin) updated the retriever.js script to allow previewers to be embedded directly in the Dataverse file pages.
Expand Down
40 changes: 40 additions & 0 deletions previewers/betatest/VoyagerPreview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>

<head>
<meta charset="utf-8">
<title class="voyagerPreviewText">Voyager 3D Preview</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="css/preview.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://3d-api.si.edu/resources/fonts/fonts.css" rel="stylesheet">
<script type="text/javascript" src="js/voyager.js"></script>
<style>
body { background: #303030; }
</style>
</head>

<body class="container">
<main>
<img id='logo' alt='Site Logo'>
<h1 class="page-title voyoagerPreviewText">Voyager 3D Preview</h1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview' width='1200'>
<voyager-explorer resourceRoot="https://3d-api.si.edu/resources/" ></voyager-explorer>
</div>
</div>
</main>
</body>

</html>
21 changes: 21 additions & 0 deletions previewers/betatest/js/voyager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$(document).ready(function() {
startPreview(false);
});

function translateBaseHtmlPage() {
var videoPreviewText = $.i18n("videoPreviewText");
$('.videoPreviewText').text(videoPreviewText);
}

function writeContent(fileUrl, file, title, authors) {
// Currently the styling of Voyager hides this info anyway.
// addStandardPreviewHeader(file, title, authors);
const lastIndexOfChar = fileUrl.lastIndexOf("/");
const rootUrl = fileUrl.substring(0, lastIndexOfChar + 1);
const fileName = fileUrl.substring(lastIndexOfChar + 1);
console.log(fileUrl);
$("voyager-explorer").attr("root", rootUrl).attr("model", fileName);
//For Dataverse 6.4+, this can use the standard script:
//$.getScript("https://3d-api.si.edu/resources/js/v0.42.1/voyager-explorer.min.js");
$.getScript("lib/voyager-explorer.v0.42.1.gdcc.min.js");
}
381 changes: 381 additions & 0 deletions previewers/betatest/lib/voyager-explorer.v0.42.1.gdcc.min.js

Large diffs are not rendered by default.

Loading