Files
engine/packages/xr-webxr
GuoLei1990 cc16941c50 "v1.3.3"
2024-08-07 12:01:41 +08:00
..
2024-07-19 19:48:05 +08:00
2024-08-07 12:01:41 +08:00
2023-12-12 15:20:40 +08:00
2023-12-12 15:20:40 +08:00

Installation

@galacean/engine-xr-webxr is one of the implementation backends of xr. If your XR application interface is WebXR standard, please introduce this package.

To install, use:

npm install @galacean/engine-xr-webxr

This will allow you to import engine entirely using:

import { WebXRDevice } from "@galacean/engine-xr-webxr";
import { XRHitTest, XRSessionMode } from "@galacean/engine-xr";

Usage

import { WebXRDevice } from "@galacean/engine-xr-webxr";
import { XRHitTest, XRSessionMode } from "@galacean/engine-xr";

// Create engine by passing in the HTMLCanvasElement
WebGLEngine.create({
  canvas: "canvas",
  xrDevice: new WebXRDevice(),
}).then((engine) => {
  // Users need to actively click the button to enter XR
  XRButton.onClick = function () {
    this.engine.xrManager.enterXR(XRSessionMode.AR).then(
      () => {
        console.log("Enter AR");
      },
      (error) => {
        console.log("Not supported AR", error);
      }
    );
  };
});
......