6.6.17 â€ĸ Published 7 months ago

@pmndrs/xr v6.6.17

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
7 months ago
npm install three @pmndrs/xr

What does it look like?

A simple scene with a mesh that toggles its material color between "red" and "blue" when clicked through touching or pointing.recording of interacting with the code below
import { createXRStore } from '@pmndrs/xr'
import { BoxGeometry, Mesh, MeshBasicMaterial, PerspectiveCamera, Scene, WebGLRenderer } from 'three'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'

const camera = new PerspectiveCamera(70, 1, 0.01, 100)
const scene = new Scene()
const canvas = document.getElementById('root') as HTMLCanvasElement
const renderer = new WebGLRenderer({ antialias: true, canvas, alpha: true })

const boxMaterial = new MeshBasicMaterial({ color: 'red' })
const box = new Mesh(new BoxGeometry(), boxMaterial)
box.pointerEventsType = { deny: 'grab' }
let red = false
box.addEventListener('click', () => {
  red = !red
  boxMaterial.color.set(red ? 'red' : 'blue')
})
scene.add(box)

const store = createXRStore(canvas, scene, camera, renderer.xr)
document.getElementById('enter-ar')?.addEventListener('click', () => store.enterAR())

let prevTime: undefined | number

renderer.setAnimationLoop((time, frame) => {
  const delta = prevTime == null ? 0 : time - prevTime
  prevTime = time
  store.update(frame, delta)
  renderer.render(scene, camera)
})

function updateSize() {
  renderer.setSize(window.innerWidth, window.innerHeight)
  renderer.setPixelRatio(window.devicePixelRatio)
  camera.aspect = window.innerWidth / window.innerHeight
  camera.updateProjectionMatrix()
}

updateSize()
window.addEventListener('resize', updateSize)

How to enable XR for your threejs app?

  1. const store = createXRStore(canvas, scene, camera, renderer.xr) create a xr store
  2. store.enterAR() call enter AR when clicking on a button

Tutorials

The following tutorials contain code for react-three/fiber but all informations are also applicable for @pmndrs/xr.

Roadmap

  • đŸ¤ŗ XR Gestures
  • ➕ Multimodal
  • âš“ī¸ Anchors
  • đŸ“ē Layers
  • 📱 Dom Overlays
  • đŸ•ē Tracked Body
  • đŸŽ¯ Hit Test
  • ↕ pmndrs/controls

Sponsors

This project is supported by a few companies and individuals building cutting-edge 3D Web & XR experiences. Check them out!

Sponsors Overview

6.5.1-alpha.2

11 months ago

6.5.0

11 months ago

6.4.12-alpha.36

11 months ago

6.4.12-alpha.33

11 months ago

6.4.12-alpha.31

11 months ago

6.6.11

9 months ago

6.6.12

8 months ago

6.6.13

8 months ago

6.6.14

8 months ago

6.6.15

7 months ago

6.6.16

7 months ago

6.6.17

7 months ago

6.6.1

10 months ago

6.6.0

10 months ago

6.6.3

10 months ago

6.4.5

1 year ago

6.6.2

10 months ago

6.4.4

1 year ago

6.6.5

10 months ago

6.4.7

1 year ago

6.6.4

10 months ago

6.4.6

1 year ago

6.6.7

10 months ago

6.4.9

1 year ago

6.6.10

9 months ago

6.6.6

10 months ago

6.4.8

1 year ago

6.6.9

9 months ago

6.6.8

10 months ago

6.4.12-alpha.54

11 months ago

6.4.10

1 year ago

6.4.12

1 year ago

6.4.11

1 year ago

6.5.2

11 months ago

6.5.1

11 months ago

6.5.4

11 months ago

6.5.3

11 months ago

6.5.6

10 months ago

6.5.5

10 months ago

6.4.12-alpha.48

11 months ago

6.4.12-alpha.46

11 months ago

6.4.1

1 year ago

6.4.3

1 year ago

6.4.2

1 year ago

6.3.0

1 year ago

6.4.0

1 year ago

6.2.17

1 year ago

6.2.18

1 year ago

6.2.16

1 year ago

6.2.19

1 year ago

6.2.15

1 year ago

6.2.14

1 year ago

6.2.13

1 year ago

6.2.11

1 year ago

6.2.12

1 year ago

6.2.10

1 year ago

6.2.9

1 year ago

6.2.8

1 year ago

6.2.7

1 year ago

6.2.5

1 year ago

6.2.4

1 year ago

6.2.6

1 year ago

6.2.3

1 year ago

6.2.2

1 year ago

6.2.1

1 year ago

6.2.0

1 year ago

6.1.1

1 year ago

6.1.0

1 year ago

6.0.0

1 year ago