threlte logo
@threlte/xr

useTeleport

Provides a function to teleport the player to a reference frame.

<script>
  import { useTeleport } from '@threlte/xr'

  const teleport = useTeleport()
  const vec3 = new THREE.Vector3()

  vec3.set(5, 0, 5)

  teleport(vec3)
</script>

This function can be used within useTask for smooth movement.

useTask((delta) => {
  vec3.z += delta
  teleport(vec3)
})