Skip to content

Latest commit

 

History

History
164 lines (117 loc) · 5.78 KB

NOTES.md

File metadata and controls

164 lines (117 loc) · 5.78 KB

TODO

  • top of viewport is cut off in ar mode
  • video mesh does not stay in place in ar mode
    • when camera moves, mesh moves slightly
    • when camera angle changes, mesh stays in place
  • lighting improvements - add shadows

WebXR Lighting Estimation API

XRLightEstimate provides the estimated lighting values for an XRLightProbe at the time represented by an XRFrame

XRLightProbe.getLightEstimate()

  • primaryLightDirection { x: 0.0, y: 1.0, z: 0.0, w: 0.0 } - means light is shining straight down from above
  • primaryLightIntensity { x: 0.0, y: 0.0, z: 0.0, w: 1.0 } - means no illumination

WebXR Depth API NOTES

session.depthUsage session.depthFormat

const depthInfo = frame.getDepthInformation(view); const depthInMeters = depthInfo.getDepthInMeters(x, y); // vec2 packedDepth = texture2D(depth_texture, uv_coord).ra; return dot(packedDepth, vec2(255.0, 256.0 * 255.0)) * u_RawValueToMeters;

Overview

...

Lighting

https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API/Lighting

const depthInfo = xrWebGLBinding.getDepthInformation(view); let depthValueInMeters = depthInfo.getDepthInMeters(x, y); // Where x, y - image coordinates of point a.

Math Links

Three.js

Play Canvas

playcanvas/engine#2561 CPU Path: https://playcanvas.com/project/732030/overview/ar-depth-sensing GPU Path: https://playcanvas.com/project/738358/overview/ar-depth-sensing-texture Depth Occlusion: https://playcanvas.com/project/738703/overview/ar-depth-sensing-occlusion

https://playcanvas.com/editor/code/738703?tabs=38289857

Example: Add object at camera point location

if (depthSensing.available) var depth = depthSensing.getDepth(depthSensing.width / 2, depthSensing.height / 2); this.vec3A.add(this.camera.getPosition()); var ent = this.template.resource.instantiate(); this.app.root.addChild(ent);
ent.setPosition(this.vec3A); // position it to pointer position

Example: Hand Tracking

https://forum.playcanvas.com/t/webxr-hand-tracking/14131

ARCore (Android / Java)

Holograms

LED Fan

Misc

"endOfTrackTicks": 16382

Local Development

USMORSCOBB2MB:webxr-depth-detector scobb$ http-server -S -C localhost+3.pem -K localhost+3-key.pem

Commands

  • npm run watch
  • npm run build-prod
  • http-server -S -C localhost+3.pem -K localhost+3-key.pem

https://USMORSCOBB2MB.local:8080

https://10.0.0.7:8080