Official WebXR implementation for Looking Glass Holographic Displays.
npm install @lookingglass/webxrv141+)
v5.0+)
LookingGlassWebXRPolyfill implements the WebXR override and allows you to target Looking Glass displays.
Enter Looking Glass button. This will open up a small pop-up window.
sh
npm install @lookingglass/webxr
`
or, if you use the yarn package manager.
`sh
yarn install @lookingglass/webxr
`
$3
To get started import LookingGlassWebXRPolyfill
`ts
import { LookingGlassWebXRPolyfill } from "@lookingglass/webxr"
`
or you can also use a
Initialize LookingGlassWebXRPolyfill
After you have the library properly installed and imported into your project, all you have to do is is instantiate LookingGlassWebXRPolyfill and you're done!
`ts
import { LookingGlassWebXRPolyfill } from "@lookingglass/webxr"
new LookingGlassWebXRPolyfill()
`
You should now see an "Enter Looking Glass" button in your scene. You can optionally pass in your own defaults for all the view controls:
`ts
new LookingGlassWebXRPolyfill({
tileHeight: 512,
numViews: 45,
targetY: 0,
targetZ: 0,
targetDiam: 3,
fovy: (14 * Math.PI) / 180
})
`
Since Looking Glass WebXR is engine agnostic there are a few settings that will be the same regardless of what 3D engine you're working with. Here are all the possible properties you can pass into LookingGlassWebXRPolyfill:
- tileHeight - defines the height of the individual quilt view, the width is then set based on the aspect ratio of the connected device.
- numViews - defines the number of views to be rendered
- targetX - defines the position of the camera on the X-axis
- targetY - defines the position of the camera on the Y-axis
- targetZ - defines the position of the camera on the Z-axis
- trackballX - defines the rotation of the camera on the X-axis
- trackballY - defines the rotation of the camera on the Y-axis
- targetDiam - defines the size of the camera, this makes your scene bigger or smaller without changing the focus.
- fovy - defines the vertical FOV of your camera (defined in radians)
- depthiness - modifies to the view frustum to increase or decrease the perceived depth of the scene.
- inlineView - changes how the original canvas on your main web page is displayed, can show the encoded subpixel matrix, a single centered view, or a quilt view.
Updating the view
In some cases you may need to update the view controls after instatiating:
`ts
const lookingGlassWebXR = new LookingGlassWebXRPolyfill({
tileHeight: 512,
numViews: 45,
targetY: 0,
targetZ: 0,
targetDiam: 3,
fovy: (14 * Math.PI) / 180
})
// ...
// Use the update() method
lookingGlassWebXR.update({
numViews: 80
})
`
You can also update the config values by importing LookingGlassConfig and declaring it as follows, this can be handy if you want to modify the camera from a separate file where you're declaring the polyfill in.
`ts
let config = LookingGlassConfig
config.trackballX = Math.PI / 2
``