Skip to content

Commit

Permalink
isAppleVisionPro fn and make editor work with hand tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
bbohlender committed Jan 14, 2025
1 parent 182c8fc commit 4a38278
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/editor/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const useSceneStore = create(() => ({

const cameraStore = createScreenCameraStore({ rotationY: Math.PI, distance: 0.5 })

const store = createXRStore({ handTracking: false })
const store = createXRStore()

const buttonStyles: CSSProperties = {
background: 'white',
Expand Down
2 changes: 2 additions & 0 deletions packages/react/xr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export * from './events.js'

//react-three/xr v5 compatibility layer
export * from './deprecated/index.js'

export { isAppleVisionPro } from '@pmndrs/xr'
4 changes: 3 additions & 1 deletion packages/xr/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isAppleVisionPro } from './misc.js'

export type XRSessionFeatureRequest = 'required' | true | false

export type XRSessionInitOptions = {
Expand Down Expand Up @@ -54,7 +56,7 @@ export function buildXRSessionInit(
domOverlayRoot: Element | undefined,
{
anchors = true,
handTracking = true,
handTracking = isAppleVisionPro() ? false : true,
layers = true,
meshDetection = true,
planeDetection = true,
Expand Down
1 change: 1 addition & 0 deletions packages/xr/src/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export * from './hit-test.js'
export * from './anchor.js'
export * from './layer.js'
export * from './controller-locomotion.js'
export * from './misc.js'
4 changes: 4 additions & 0 deletions packages/xr/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ export function isFacingCamera(camera: Camera, object: Object3D, direction: Vect
//compute the angle between guardToCamera and object world direction
return vectorHelper.angleTo(directionHelper) < angle / 2
}

export function isAppleVisionPro() {
return navigator.userAgent.includes('Macintosh') && navigator.xr != null
}

0 comments on commit 4a38278

Please sign in to comment.