google-ar / codelab-webxr

Building an augmented reality application with the WebXR Device API
https://codelabs.developers.google.com/codelabs/ar-with-webxr/
Apache License 2.0
171 stars 85 forks source link

Code not matching tutorial #30

Open LostEchoDX opened 2 years ago

LostEchoDX commented 2 years ago

Hello, I've done extensive testing and found the following: on step 4, part 4 of Add a reticle the following code is on the tutorial:

async onSessionStarted() {
  // ...

  // Setup an XRReferenceSpace using the "local" coordinate system.
  this.localReferenceSpace = await **_session_**.requestReferenceSpace("local");

  // Add these lines:
  // Create another XRReferenceSpace that has the viewer as the origin.
  this.viewerSpace = await this.**_session_**.requestReferenceSpace("viewer");
  // Perform hit testing using the viewer as origin.
  this.hitTestSource = await this.**_session_**.requestHitTestSource({ space: this.viewerSpace });

  // ...
}

and it doesn't work, it throws the onNoXRDevice exception.

The functional code, found in step-04 folder is the following:

// Setup an XRReferenceSpace using the "local" coordinate system.
this.localReferenceSpace = await this.**_xrSession_**.requestReferenceSpace('local');

// Create another XRReferenceSpace that has the viewer as the origin.
this.viewerSpace = await this.**_xrSession_**.requestReferenceSpace('viewer');
// Perform hit testing using the viewer as origin.
this.hitTestSource = await this.**_xrSession_**.requestHitTestSource({ space: this.viewerSpace });
devbridie commented 2 years ago

Thanks for the catch! I can't immediately update the website at the moment (colleagues are in a far-off timezone), but the patch is waiting for submission. Thanks for bringing this up!