Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d6abbea
origin/webxr
Maksims Jan 19, 2020
e14f9b9
lint fixes
Maksims Jan 19, 2020
5b8d0d9
respect parent transform, fix start/end session rendering
Maksims Jan 20, 2020
31054d6
resize graphics device to respect XR session framebuffer
Maksims Jan 25, 2020
5f8ff76
provide multiple XR session types; AR
Maksims Jan 25, 2020
f9d8568
better API, tidy up, lint clean
Maksims Jan 30, 2020
70d339a
merge
Maksims Jan 30, 2020
45903ba
jsdocs fixes
Maksims Jan 30, 2020
95c3fff
fix tests
Maksims Jan 30, 2020
d8b9599
add backwards compatibility warnings for VR
Maksims Jan 30, 2020
5d0c342
remove deprecated VR camera logic
Maksims Jan 30, 2020
77ba3ae
Merge branch 'master' into webxr
Maksims Jan 30, 2020
4f70715
Merge branch 'master' of github.com:playcanvas/engine into webxr
Maksims Jan 30, 2020
92fb7e6
remove VR examples and add XR examples
Maksims Jan 30, 2020
d21a68c
Merge branch 'webxr' of github.com:Maksims/engine-1 into webxr
Maksims Jan 30, 2020
2deb5f5
lint errors
Maksims Jan 30, 2020
1d001fb
Merge branch 'master' into webxr
willeastcott Jan 31, 2020
407c0e6
Merge branch 'master' of github.com:playcanvas/engine into webxr
Maksims Feb 4, 2020
52304f9
Merge branch 'webxr' of github.com:Maksims/engine-1 into webxr
Maksims Feb 4, 2020
1ebcd83
address PR comments
Maksims Feb 4, 2020
9aedc74
calculate camera XR frustum based on XR view
Maksims Feb 4, 2020
462d537
fix XR normals bug, and change position/rotation calculation
Maksims Feb 4, 2020
2616d31
API renaming/simplification
Maksims Feb 5, 2020
8b84b9d
undepricate WebVR
Maksims Feb 5, 2020
f500fb2
fixes
Maksims Feb 5, 2020
c6dd516
rename pc.XR_TYPE_* to simplified version
Maksims Feb 6, 2020
b0c78bf
remove CameraComponent.isXr property
Maksims Feb 6, 2020
be08fb2
Merge branch 'master' into webxr
Maksims Feb 8, 2020
2639133
Merge branch 'master' of github.com:playcanvas/engine into webxr
Maksims Feb 8, 2020
40272a7
Merge branch 'webxr' of github.com:Maksims/engine-1 into webxr
Maksims Feb 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@
../src/input/touch.js
../src/input/controller.js
../src/input/element-input.js
../src/vr/vr-manager.js
../src/vr/vr-display.js
../src/xr/xr-manager.js
../src/net/http.js
../src/script/script-registry.js
../src/script/script.js
Expand Down
17 changes: 3 additions & 14 deletions src/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@
* @param {pc.Vec3} cameraForward - The forward vector of the camera.
*/

/**
* @callback pc.callbacks.VrCamera
* @description Callback used by {@link pc.CameraComponent#enterVr} and {@link pc.CameraComponent#exitVr}.
* @param {string|null} err - On success it is null on failure it is the error message.
*/

/**
* @private
* @callback pc.callbacks.CreateScript
Expand Down Expand Up @@ -162,12 +156,7 @@
*/

/**
* @callback pc.callbacks.VrDisplay
* @description Callback used by {@link pc.VrDisplay#requestPresent} and {@link pc.VrDisplay#exitPresent}.
* @param {string|null} err - The error message if presenting fails, or null if the call succeeds.
*/

/**
* @callback pc.callbacks.VrFrame
* @description Callback used by {@link pc.VrDisplay#requestAnimationFrame}.
* @callback pc.callbacks.XrError
* @description Callback used by {@link pc.XrManager#endXr} and {@link pc.XrManager#startXr}.
* @param {Error|null} err The Error object or null if operation was successfull.
*/
83 changes: 39 additions & 44 deletions src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ Object.assign(pc, function () {
* this.app.systems.sound.volume = 0.5;
*/

/**
* @name pc.Application#xr
* @type {pc.XrManager}
* @description The XR Manager that provides ability to start VR/AR sessions.
* @example
* // check if VR is available
* if (app.xr.isAvailable(pc.XR_TYPE_IMMERSIVE_VR)) {
* // VR is available
* }
*/

/**
* @name pc.Application#loader
* @type {pc.ResourceLoader}
Expand Down Expand Up @@ -255,11 +266,12 @@ Object.assign(pc, function () {
this._librariesLoaded = false;
this._fillMode = pc.FILLMODE_KEEP_ASPECT;
this._resolutionMode = pc.RESOLUTION_FIXED;
this._allowResize = true;

// for compatibility
this.context = this;

options.graphicsDeviceOptions.xrCompatible = true;

this.graphicsDevice = new pc.GraphicsDevice(canvas, options.graphicsDeviceOptions);
this.stats = new pc.ApplicationStats(this.graphicsDevice);
this._audioManager = new pc.SoundManager(options);
Expand Down Expand Up @@ -535,7 +547,7 @@ Object.assign(pc, function () {
if (this.elementInput)
this.elementInput.app = this;

this.vr = null;
this.xr = new pc.XrManager(this);

this._inTools = false;

Expand Down Expand Up @@ -1163,8 +1175,6 @@ Object.assign(pc, function () {

this.graphicsDevice.updateClientRect();

if (this.vr) this.vr.poll();

// #ifdef PROFILER
this.stats.frame.updateStart = pc.now();
// #endif
Expand Down Expand Up @@ -1379,7 +1389,9 @@ Object.assign(pc, function () {
* @returns {object} A object containing the values calculated to use as width and height.
*/
resizeCanvas: function (width, height) {
if (!this._allowResize) return; // prevent resizing (e.g. if presenting in VR HMD)
// prevent resizing when in XR session
if (this.xr && this.xr.session)
return;

var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
Expand Down Expand Up @@ -1565,29 +1577,6 @@ Object.assign(pc, function () {
}
},

/**
* @function
* @name pc.Application#enableVr
* @description Create and assign a {@link pc.VrManager} object to allow this application render in VR.
*/
enableVr: function () {
if (!this.vr) {
this.vr = new pc.VrManager(this);
}
},

/**
* @function
* @name pc.Application#disableVr
* @description Destroy the {@link pc.VrManager}.
*/
disableVr: function () {
if (this.vr) {
this.vr.destroy();
this.vr = null;
}
},

_onSkyboxChange: function (asset) {
this.scene.setSkybox(asset.resources);
},
Expand Down Expand Up @@ -1740,10 +1729,7 @@ Object.assign(pc, function () {

pc.destroyPostEffectQuad();

if (this.vr) {
this.vr.destroy();
this.vr = null;
}
this.xr.sessionEnd();

this.graphicsDevice.destroy();
this.graphicsDevice = null;
Expand Down Expand Up @@ -1789,13 +1775,19 @@ Object.assign(pc, function () {
// create tick function to be wrapped in closure
var makeTick = function (_app) {
var app = _app;
return function (timestamp) {
if (!app.graphicsDevice) {
var frameRequest;

return function (timestamp, frame) {
if (!app.graphicsDevice)
return;
}

Application._currentApplication = app;

if (frameRequest) {
cancelAnimationFrame(frameRequest);
frameRequest = null;
}

// have current application pointer in pc
pc.app = app;

Expand All @@ -1808,20 +1800,27 @@ Object.assign(pc, function () {
app._time = now;

// Submit a request to queue up a new animation frame immediately
if (app.vr && app.vr.display) {
app.vr.display.requestAnimationFrame(app.tick);
if (app.xr.session) {
frameRequest = app.xr.session.requestAnimationFrame(app.tick);
} else {
requestAnimationFrame(app.tick);
frameRequest = requestAnimationFrame(app.tick);
}

if (app.graphicsDevice.contextLost) {
if (app.graphicsDevice.contextLost)
return;
}

// #ifdef PROFILER
app._fillFrameStats(now, dt, ms);
// #endif

if (frame) app.xr.calculateViews(frame);

if (frame) {
app.graphicsDevice.defaultFramebuffer = frame.session.renderState.baseLayer.framebuffer;
} else {
app.graphicsDevice.defaultFramebuffer = null;
}

app.update(dt);

if (app.autoRender || app.renderNextFrame) {
Expand All @@ -1835,10 +1834,6 @@ Object.assign(pc, function () {

app.fire("frameend", _frameEndData);
app.fire("frameEnd", _frameEndData);// deprecated old event, remove when editor updated

if (app.vr && app.vr.display && app.vr.display.presenting) {
app.vr.display.submitFrame();
}
};
};

Expand Down
Loading