Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
enable embedded viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Apr 20, 2024
1 parent 8cf1980 commit a05c380
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
5 changes: 4 additions & 1 deletion web/src/routes/(assets)/[...path]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export async function load({ params }) {
if (_path.endsWith("/")) _path = _path.substring(0, _path.length - 1);

const currentDir = dirs?.find(child => child.path === _path || child.path === _path + "/");
const currentItem = items?.find(item => item.path === _path || item.path + "/" === _path);
let currentItem = items?.find(item => item.path === _path || item.path + "/" === _path);

// fall back to first item if we have a directory with only one item
currentItem = currentItem || (currentDir?.items.length == 1 ? currentDir.items[0] : undefined);

// console.log("Loading page: " + path + ", currentDir: " + currentDir + ", currentItem: " + currentItem);

Expand Down
3 changes: 1 addition & 2 deletions web/src/routes/(assets)/[...path]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export let data;
function getViewerUrl(abs: string) {
const encoded = encodeURIComponent(abs);
return base + "/viewer/view?file=" + encoded;
return "http://localhost:3003/?file=" + encoded;
return "https://usd-viewer.glitch.me/?file=" + encoded;
// return "https://usd-viewer.glitch.me/?file=" + encoded;
}
$: absoluteGithubUrl = item ? "https://github.com/usd-wg/assets/blob/main/" + item.path + item.ext : "";
Expand Down
4 changes: 4 additions & 0 deletions web/src/routes/viewer/view/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export const prerender = true;
export const ssr = true;
export const trailingSlash = 'always';
10 changes: 2 additions & 8 deletions web/src/routes/viewer/view/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { base } from '$app/paths';
let container: HTMLDivElement;
function goFullscreen(event: MouseEvent & { currentTarget: EventTarget & HTMLDivElement; }) {
function goFullscreen(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement; }) {
console.log("goFullscreen");
const elem = document.body;
if (elem.requestFullscreen) {
Expand Down Expand Up @@ -36,7 +36,7 @@ function goFullscreen(event: MouseEvent & { currentTarget: EventTarget & HTMLDiv
{#if false}
<a class="file" href="?file=">Clear<br/><span>Drop USDZ to load</span></a>

<a class="filename"></a>
<a href="." class="filename">Filename.usd</a>
{/if}

<p id="message-log">
Expand All @@ -50,12 +50,6 @@ function goFullscreen(event: MouseEvent & { currentTarget: EventTarget & HTMLDiv

</div>

{#if false}
<div class="footer">
<a id="quick-look-link" rel="ar" href="#"><img width="128" height="128" src="ARKit_Glyph.svg" title="ARKit Glyph" style="max-width:100%; height:auto;"></a>
</div>
{/if}

<style>
Expand Down

0 comments on commit a05c380

Please sign in to comment.