webaverse / xrpackage

XR (VR+AR) web object packaging core API
https://xrpackage.org/
24 stars 10 forks source link

renderer.xr.getControllerGrip() is broken in XRPKs #92

Open michaelybecker opened 4 years ago

michaelybecker commented 4 years ago

Any call to getting controller grip, in any part of the app lifecycle, throws:

three.module.js:4855 Uncaught TypeError: Cannot read property '0' of undefined
    at Matrix4.fromArray (three.module.js:4855)
    at _applyXrOffsetToPose (XR.js:391)
    at XRFrame.getPose (XR.js:422)
    at _r.update (1.bundle.js:1)
    at 1.bundle.js:1
    at r (1.bundle.js:1)
    at XR.js:211
    at EventTarget.draw (xrpackage.js:1345)
    at EventTarget.tick (xrpackage.js:1293)
    at animate (xrpackage.js:1049)

This functionality is standardized in webxr apps (you can see it for example in the threejs ballshooter, among others).

avaer commented 4 years ago

The bug is that these properties aren't absorbed: https://github.com/webaverse/xrpackage/blob/97c66f9217d6c5ca54d71ebcc2dd81116e21ae2e/xrpackage/XR.js#L541

avaer commented 4 years ago

They would need to be declared in the xrState and read in from the XR device.