diff --git a/polyfill/XRPresentationFrame.js b/polyfill/XRPresentationFrame.js index 481b1ed..43f9ad9 100644 --- a/polyfill/XRPresentationFrame.js +++ b/polyfill/XRPresentationFrame.js @@ -5,9 +5,9 @@ import MatrixMath from './fill/MatrixMath.js' XRPresentationFrame provides all of the values needed to render a single frame of an XR scene to the XRDisplay. */ export default class XRPresentationFrame { - constructor(session){ + constructor(session, timestamp){ this._session = session - this._timestamp = this._session.reality._getTimeStamp(); + this._timestamp = this._session.reality._getTimeStamp(timestamp); } get session(){ return this._session } diff --git a/polyfill/XRSession.js b/polyfill/XRSession.js index e3e8a62..9f2ad6f 100644 --- a/polyfill/XRSession.js +++ b/polyfill/XRSession.js @@ -59,13 +59,13 @@ export default class XRSession extends EventHandlerBase { } _handleRequestFrame(callback) { - return this._display._requestAnimationFrame(() => { + return this._display._requestAnimationFrame((timestamp) => { if (this._skip) { this._skip = false; return this._handleRequestFrame(callback) } //this._skip = true; // try skipping every second raf - const frame = this._createPresentationFrame() + const frame = this._createPresentationFrame(timestamp) this._updateCameraAnchor(frame) this._display._reality._handleNewFrame(frame) @@ -177,8 +177,8 @@ export default class XRSession extends EventHandlerBase { this._display._startVideoFrames(); } - _createPresentationFrame(){ - return new XRPresentationFrame(this) + _createPresentationFrame(timestamp){ + return new XRPresentationFrame(this, timestamp) } _getCoordinateSystem(...types){ diff --git a/polyfill/reality/CameraReality.js b/polyfill/reality/CameraReality.js index 2d3ce38..86e380a 100644 --- a/polyfill/reality/CameraReality.js +++ b/polyfill/reality/CameraReality.js @@ -607,12 +607,13 @@ export default class CameraReality extends Reality { } } - _getTimeStamp() { + _getTimeStamp(timestamp) { if(this._arKitWrapper !== null){ return this._arKitWrapper.timestamp; }else{ // use performance.now() - return ( performance || Date ).now(); + //return ( performance || Date ).now(); + return timestamp } } /* diff --git a/polyfill/reality/VirtualReality.js b/polyfill/reality/VirtualReality.js index 7d5d0c3..c623f82 100644 --- a/polyfill/reality/VirtualReality.js +++ b/polyfill/reality/VirtualReality.js @@ -73,6 +73,9 @@ export default class VirtualReality extends Reality { }) } + _getTimeStamp(timestamp) { + return timestamp + } } \ No newline at end of file