diff --git a/.all-contributorsrc b/.all-contributorsrc index 2c39b59d9..2acbc2ea8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -754,6 +754,15 @@ "doc", "maintenance" ] + }, + { + "login": "Yonet", + "name": "Yönet", + "avatar_url": "https://avatars.githubusercontent.com/u/3523671?v=4", + "profile": "https://github.com/Yonet", + "contributions": [ + "code" + ] } ], "skipCi": true, diff --git a/README.md b/README.md index e93fcb549..a3488da68 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Mikael Pettersson
Mikael Pettersson

💻 Tom Harley
Tom Harley

💻 Ondřej Španěl
Ondřej Španěl

🐛 💻 📖 🚧 + Yönet
Yönet

💻 diff --git a/types/three/examples/jsm/webxr/XRButton.d.ts b/types/three/examples/jsm/webxr/XRButton.d.ts new file mode 100644 index 000000000..8d93b5c35 --- /dev/null +++ b/types/three/examples/jsm/webxr/XRButton.d.ts @@ -0,0 +1,6 @@ +import { WebGLRenderer } from '../../../src/Three'; + +// tslint:disable-next-line:no-unnecessary-class +export class XRButton { + static createButton(renderer: WebGLRenderer): HTMLElement; +} diff --git a/types/three/test/integration/webxr-vr-cube.ts b/types/three/test/integration/webxr-cube.ts similarity index 71% rename from types/three/test/integration/webxr-vr-cube.ts rename to types/three/test/integration/webxr-cube.ts index 60116996a..efcc0b442 100644 --- a/types/three/test/integration/webxr-vr-cube.ts +++ b/types/three/test/integration/webxr-cube.ts @@ -1,6 +1,7 @@ // A simple WebXR VR example that just shows a cube. import * as THREE from 'three'; +import { XRButton } from 'three/examples/jsm/webxr/XRButton'; const container = document.createElement('div'); @@ -8,7 +9,6 @@ const renderer = new THREE.WebGLRenderer({ antialias: true }); const camera = new THREE.PerspectiveCamera(50, 2, 0.1, 10); const scene = new THREE.Scene(); -const vrButton = document.createElement('button'); let currentSession: XRSession | null = null; let mesh: THREE.Mesh; @@ -18,8 +18,6 @@ async function onSessionStarted(session: XRSession): Promise { session.addEventListener('end', onSessionEnded); await renderer.xr.setSession(session); - vrButton.innerText = 'Exit VR'; - currentSession = session; } @@ -27,11 +25,8 @@ async function onSessionEnded(): Promise { if (currentSession == null) { return; } - currentSession.removeEventListener('end', onSessionEnded); await renderer.xr.setSession(null); - vrButton.innerText = 'Enter VR'; - currentSession = null; } @@ -53,7 +48,6 @@ function init(): void { renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(300, 150); - renderer.outputEncoding = THREE.sRGBEncoding; renderer.xr.enabled = true; container.appendChild(renderer.domElement); @@ -70,24 +64,6 @@ function init(): void { directionalLight.position.set(1, 1, 1).normalize(); scene.add(directionalLight); - checkVRSupport().then(xr => { - if (xr) { - vrButton.innerText = 'Enter VR'; - - vrButton.addEventListener('click', async () => { - if (currentSession == null) { - const sessionInit = { optionalFeatures: ['local-floor', 'bounded-floor'] }; - const session = await xr.requestSession('immersive-vr', sessionInit); - await onSessionStarted(session); - } - }); - } else { - vrButton.innerText = 'VR Not Supported'; - } - - container.appendChild(vrButton); - }); - renderer.setAnimationLoop(() => { mesh.rotation.x += 0.005; mesh.rotation.y += 0.01; diff --git a/types/three/tsconfig.json b/types/three/tsconfig.json index 60d973d16..79bff73ff 100644 --- a/types/three/tsconfig.json +++ b/types/three/tsconfig.json @@ -78,7 +78,7 @@ "test/integration/three-examples/webgl_shadowmap_vsm.ts", "test/integration/three-examples/webxr_ar_lighting.ts", "test/integration/three-examples/webxr_vr_handinput_cubes.ts", - "test/integration/webxr-vr-cube.ts", + "test/integration/webxr-cube.ts", "test/unit/examples/jsm/exporters/PLYExporter.ts", "test/unit/examples/jsm/exporters/STLExporter.ts", "test/unit/examples/jsm/helpers/ViewHelper.ts",