Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WebVR API support #4177

Merged
merged 2 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 1 addition & 12 deletions src/deprecated/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ import { basisInitialize } from '../resources/basis.js';
import { EventHandler } from '../core/event-handler.js';
import { Asset } from '../asset/asset.js';

import { VrManager } from '../vr/vr-manager.js';

// CORE

export const log = {
Expand Down Expand Up @@ -1073,16 +1071,7 @@ Application.prototype.renderLines = function (position, color, options) {
};

Application.prototype.enableVr = function () {
if (!this.vr) {
this.vr = new VrManager(this);
}
};

Application.prototype.disableVr = function () {
if (this.vr) {
this.vr.destroy();
this.vr = null;
}
Debug.deprecated('pc.Application#enableVR is deprecated, and WebVR API is no longer supported.');
};

Object.defineProperty(CameraComponent.prototype, 'node', {
Expand Down
22 changes: 1 addition & 21 deletions src/framework/app-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import {
/** @typedef {import('../scene/batching/batch-manager.js').BatchManager} BatchManager */
/** @typedef {import('../framework/app-create-options.js').AppCreateOptions} AppCreateOptions */
/** @typedef {import('../xr/xr-manager.js').XrManager} XrManager */
/** @typedef {import('../vr/vr-manager.js').VrManager} VrManager */
/** @typedef {import('../sound/manager.js').SoundManager} SoundManager */

// Mini-object used to measure progress of loading sets
Expand Down Expand Up @@ -507,13 +506,6 @@ class AppBase extends EventHandler {
if (this.elementInput)
this.elementInput.app = this;

/**
* @type {VrManager|null}
* @deprecated
* @ignore
*/
this.vr = null;

/**
* The XR Manager that provides ability to start VR/AR sessions.
*
Expand Down Expand Up @@ -1175,8 +1167,6 @@ class AppBase extends EventHandler {

this.graphicsDevice.updateClientRect();

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

// #if _PROFILER
this.stats.frame.updateStart = now();
// #endif
Expand Down Expand Up @@ -2039,10 +2029,6 @@ class AppBase extends EventHandler {
this.defaultLayerDepth = null;
this.defaultLayerWorld = null;

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

this.renderer.destroy();
Expand Down Expand Up @@ -2126,9 +2112,7 @@ const makeTick = function (_app) {
application._time = currentTime;

// Submit a request to queue up a new animation frame immediately
if (application.vr && application.vr.display) {
frameRequest = application.vr.display.requestAnimationFrame(application.tick);
} else if (application.xr.session) {
if (application.xr.session) {
frameRequest = application.xr.session.requestAnimationFrame(application.tick);
} else {
frameRequest = platform.browser ? window.requestAnimationFrame(application.tick) : null;
Expand Down Expand Up @@ -2169,10 +2153,6 @@ const makeTick = function (_app) {

application.fire("frameend", _frameEndData);

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

application._inFrameUpdate = false;

if (application._destroyRequested) {
Expand Down
126 changes: 1 addition & 125 deletions src/framework/components/camera/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const properties = [
{ name: 'nearClip', readonly: false },
{ name: 'orthoHeight', readonly: false },
{ name: 'projection', readonly: false },
{ name: 'scissorRect', readonly: false },
{ name: 'vrDisplay', readonly: false }
{ name: 'scissorRect', readonly: false }
];

/**
Expand All @@ -43,13 +42,6 @@ const properties = [
* @param {number} view - Type of view. Can be {@link VIEW_CENTER}, {@link VIEW_LEFT} or {@link VIEW_RIGHT}. Left and right are only used in stereo rendering.
*/

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

/**
* The Camera Component enables an Entity to render the scene. A scene requires at least one
* enabled camera component to be rendered. Note that multiple camera components can be enabled
Expand Down Expand Up @@ -526,122 +518,6 @@ class CameraComponent extends Component {
*/
frameEnd() {}

/**
* @private
* @deprecated
* @function
* @name CameraComponent#enterVr
* @description Attempt to start presenting this camera to a {@link VrDisplay}.
* @param {VrCameraCallback} callback - Function called once to indicate success
* of failure. The callback takes one argument (err).
* On success it returns null on failure it returns the error message.
* @example
* // On an entity with a camera component
* this.entity.camera.enterVr(function (err) {
* if (err) {
* console.error(err);
* } else {
* // in VR!
* }
* });
*/
/**
* @private
* @deprecated
* @function
* @name CameraComponent#enterVr
* @variation 2
* @description Attempt to start presenting this camera to a {@link VrDisplay}.
* @param {VrDisplay} display - The VrDisplay to present. If not supplied this uses
* {@link VrManager#display} as the default.
* @param {VrCameraCallback} callback - Function called once to indicate success
* of failure. The callback takes one argument (err). On success it returns null on
* failure it returns the error message.
* @example
* // On an entity with a camera component
* this.entity.camera.enterVr(function (err) {
* if (err) {
* console.error(err);
* } else {
* // in VR!
* }
* });
*/
enterVr(display, callback) {
if ((display instanceof Function) && !callback) {
callback = display;
display = null;
}

if (!this.system.app.vr) {
callback('VrManager not created. Enable VR in project settings.');
return;
}

if (!display) {
display = this.system.app.vr.display;
}

if (display) {
const self = this;
if (display.capabilities.canPresent) {
// try and present
display.requestPresent(function (err) {
if (!err) {
self.vrDisplay = display;
// camera component uses internal 'before' event
// this means display nulled before anyone other
// code gets to update
self.vrDisplay.once('beforepresentchange', function (display) {
if (!display.presenting) {
self.vrDisplay = null;
}
});
}
callback(err);
});
} else {
// mono rendering
self.vrDisplay = display;
callback();
}
} else {
callback('No pc.VrDisplay to present');
}
}

/**
* Attempt to stop presenting this camera.
*
* @param {VrCameraCallback} callback - Function called once to indicate success of failure.
* The callback takes one argument (err). On success it returns null on failure it returns the
* error message.
* @example
* this.entity.camera.exitVr(function (err) {
* if (err) {
* console.error(err);
* } else {
* // exited successfully
* }
* });
* @private
* @deprecated
*/
exitVr(callback) {
if (this.vrDisplay) {
if (this.vrDisplay.capabilities.canPresent) {
const display = this.vrDisplay;
this.vrDisplay = null;
display.exitPresent(callback);
} else {
this.vrDisplay = null;
callback();
}
} else {
callback('Not presenting VR');
}
}

/**
* Attempt to start XR session with this camera.
*
Expand Down
23 changes: 0 additions & 23 deletions src/framework/components/camera/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,6 @@ class CameraComponentSystem extends ComponentSystem {
}

onUpdate(dt) {
if (this.app.vr) {
const components = this.store;

for (const id in components) {
const component = components[id];

if (component.data.enabled && component.entity.enabled) {
const cameraComponent = component.entity.camera;
const vrDisplay = cameraComponent.vrDisplay;
if (vrDisplay) {
// Change WebVR near/far planes based on the stereo camera
vrDisplay.setClipPlanes(cameraComponent.nearClip, cameraComponent.farClip);

// update camera node transform from VrDisplay
if (component.entity) {
component.entity.localTransform.copy(vrDisplay.combinedViewInv);
component.entity._dirtyLocal = false;
component.entity._dirtifyWorld();
}
}
}
}
}
}

onAppPrerender() {
Expand Down
4 changes: 0 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ export { ZoneComponentSystem } from './framework/components/zone/system.js';
// TEMPLATES
export { Template } from './templates/template.js';

// VR
export { VrDisplay } from './vr/vr-display.js';
export { VrManager } from './vr/vr-manager.js';

// XR
export * from './xr/constants.js';
export { XrInput } from './xr/xr-input.js';
Expand Down
13 changes: 0 additions & 13 deletions src/scene/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class Camera {
this._renderTarget = null;
this._scissorRect = new Vec4(0, 0, 1, 1);
this._scissorRectClear = false; // by default rect is used when clearing. this allows scissorRect to be used when clearing.
this._vrDisplay = null;

this._projMat = new Mat4();
this._projMatDirty = true;
Expand Down Expand Up @@ -302,17 +301,6 @@ class Camera {
return this._viewMat;
}

set vrDisplay(newValue) {
this._vrDisplay = newValue;
if (newValue) {
newValue._camera = this;
}
}

get vrDisplay() {
return this._vrDisplay;
}

/**
* Creates a duplicate of the camera.
*
Expand Down Expand Up @@ -353,7 +341,6 @@ class Camera {
this.rect = other.rect;
this.renderTarget = other.renderTarget;
this.scissorRect = other.scissorRect;
this.vrDisplay = other.vrDisplay;
return this;
}

Expand Down
Loading