From e921a554ae8e35fc689fc8178f101283674b021c Mon Sep 17 00:00:00 2001 From: Sebastien DUMETZ Date: Thu, 11 Apr 2024 14:56:40 +0200 Subject: [PATCH] prototype auto-start tour --- source/server/server.ts | 16 +++++++++++++++- source/server/templates/explorer.hbs | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/source/server/server.ts b/source/server/server.ts index 60835115..eea1266c 100644 --- a/source/server/server.ts +++ b/source/server/server.ts @@ -111,10 +111,22 @@ export default async function createServer(config = defaultConfig) :Promise{ 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`, @@ -122,9 +134,11 @@ export default async function createServer(config = defaultConfig) :Promise{ let {scene} = req.params; let {lang} = req.query; diff --git a/source/server/templates/explorer.hbs b/source/server/templates/explorer.hbs index ec70c32b..24c9ef37 100644 --- a/source/server/templates/explorer.hbs +++ b/source/server/templates/explorer.hbs @@ -1,3 +1,6 @@ +{{#if script }}{{/if}} \ No newline at end of file