From 8bc6da8bd0b64e8be62676666c485ad97eba9b59 Mon Sep 17 00:00:00 2001 From: Valery-a <83373303+Valery-a@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:19:24 +0300 Subject: [PATCH] added closing btn --- src/vr.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/vr.ts b/src/vr.ts index f78cdb460..25a04e4bc 100644 --- a/src/vr.ts +++ b/src/vr.ts @@ -12,8 +12,27 @@ export async function initVR () { if (!isSupported) return // VR - document.body.appendChild(VRButton.createButton(renderer)) - renderer.xr.enabled = true + const vrButton = VRButton.createButton(renderer) + document.body.appendChild(vrButton) + + const closeButton = document.createElement('button') + closeButton.textContent = 'X' + closeButton.style.position = 'absolute' + closeButton.style.bottom = '20px' + closeButton.style.left = 'calc(50% + 60px)' + closeButton.style.padding = '4px 8px' + closeButton.style.background = 'rgba(255, 0, 0, 0.7)' + closeButton.style.color = 'white' + closeButton.style.border = 'none' + closeButton.style.borderRadius = '4px' + closeButton.style.cursor = 'pointer' + closeButton.style.zIndex = '1000' + + closeButton.addEventListener('click', () => { + vrButton.remove() + closeButton.remove() + }) + document.body.appendChild(closeButton) // hack for vr camera const user = new THREE.Group()