-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: types ARButton and VRButton #28
Conversation
ARButton.js -> ARButton.ts removes ARButton.js adds return types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few discussion points, nothing major imo
src/webxr/ARButton.ts
Outdated
@@ -1,28 +1,37 @@ | |||
import { WebGLRenderer, XRSession, XRSessionInit } from 'three' | |||
|
|||
interface ARButtonSessionInit extends XRSessionInit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets export this type, even if no one uses it, we might aswell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do!
@@ -79,7 +88,8 @@ class ARButton { | |||
|
|||
button.onclick = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could use addEventListener
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I'll convert it the morning 😃
src/webxr/ARButton.ts
Outdated
@@ -79,7 +88,8 @@ class ARButton { | |||
|
|||
button.onclick = function () { | |||
if (currentSession === null) { | |||
navigator.xr.requestSession('immersive-ar', sessionInit).then(onSessionStarted) | |||
const xr: THREE.XR = (navigator as any).xr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unconventional, but i think i'd prefer a @ts-expect-error
here instead, small description afterwards explaining that we need to add webxr types which might be an open issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me, will update
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pmndrs/three-stdlib/7Y5z8x3YrQqzzG4zL48E1EDpSNds [Deployment for 3b1517f failed] |
Continuing in #241. three.js has broken a lot of stuff around WebXR and its renderers since. |
What
ARButton.js
->ARButton.ts
VRButton.js
->VRButton.ts
Why
Types XRButtons. Didn't see an issue tracking these in any of the typing milestones so no worries if it's too early to merge this. Just wanted to fix something inbetween working on typing the loaders as they're taking a while.
Checklist