Skip to content

Commit

Permalink
prototype auto-start tour
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Apr 11, 2024
1 parent 3309025 commit e921a55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion source/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,34 @@ export default async function createServer(config = defaultConfig) :Promise<expr

app.get("/ui/scenes/:scene/view", (req, res)=>{
let {scene} = req.params;
let {lang} = req.query;
let {lang, tour} = req.query;
let host = getHost(req);
let referrer = new URL(req.get("Referrer")||`/ui/scenes/`, host);
let thumb = new URL(`/scenes/${encodeURIComponent(scene)}/scene-image-thumb.jpg`, host);

let script = undefined;
if(tour && !Number.isNaN(parseInt(tour as any))){
script = `
const v = document.querySelector("voyager-explorer");
v?.on("model-load",()=>{
v?.toggleTours();
v?.setTourStep(${parseInt(tour as any)}, 0, true);
})
`;
}


res.render("explorer", {
title: `${scene}: Explorer`,
scene,
thumb: thumb.toString(),
referrer: referrer.toString(),
lang: ((typeof lang === "string")?lang.toUpperCase():"FR"),
script
});
});


app.get("/ui/scenes/:scene/edit", canWrite, (req, res)=>{
let {scene} = req.params;
let {lang} = req.query;
Expand Down
3 changes: 3 additions & 0 deletions source/server/templates/explorer.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

<voyager-explorer resourceroot="/dist/" dracoRoot="/dist/js/draco/" root="/scenes/{{scene}}/" referrer="{{referrer}}" lang="{{lang}}"></voyager-explorer>
<script type="text/javascript" src="/dist/js/voyager-explorer.js"></script>
{{#if script }}<script type="text/javascript">
{{{script}}}
</script>{{/if}}

0 comments on commit e921a55

Please sign in to comment.