From 4fe509db8dd76aa926f3109bc74d222bccd4579f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20H=C3=A4rtl?= Date: Fri, 18 Oct 2024 16:59:55 +0200 Subject: [PATCH] Add URL query params for hiding UI and camera settings --- index.html | 2 +- src/logic/uimodel.js | 5 +++++ src/main.js | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 23c59b54..8249413e 100644 --- a/index.html +++ b/index.html @@ -101,7 +101,7 @@
diff --git a/src/logic/uimodel.js b/src/logic/uimodel.js index df736140..bf26d62f 100644 --- a/src/logic/uimodel.js +++ b/src/logic/uimodel.js @@ -18,6 +18,11 @@ class UIModel const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const modelURL = urlParams.get("model"); + const noUI = urlParams.get("noUI"); + if (noUI !== null) { + this.app.uiVisible = false; + this.app.noUI = true; + } this.scene = app.sceneChanged.pipe(); this.camera = app.cameraChanged.pipe(); diff --git a/src/main.js b/src/main.js index 8d2cd05a..69259177 100644 --- a/src/main.js +++ b/src/main.js @@ -135,6 +135,16 @@ export default async () => { state.userCamera.perspective.aspectRatio = canvas.width / canvas.height; state.userCamera.resetView(state.gltf, state.sceneIndex); + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + let yaw = urlParams.get("yaw") ?? 0; + yaw = yaw * (Math.PI / 180) / state.userCamera.orbitSpeed; + let pitch = urlParams.get("pitch") ?? 0; + pitch = pitch * (Math.PI / 180) / state.userCamera.orbitSpeed; + const distance = urlParams.get("distance") ?? 0; + state.userCamera.orbit(yaw, pitch); + state.userCamera.zoomBy(distance); + // Try to start as many animations as possible without generating conficts. state.animationIndices = []; for (let i = 0; i < gltf.animations.length; i++) {