Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1574)

Unified Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2668093002: VrShell background implemented in JS. (Closed)
Patch Set: Removed superfluous tests from previous patch set Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/vr_shell/vr_shell_ui.js
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui.js b/chrome/browser/resources/vr_shell/vr_shell_ui.js
index ce1b792f877b67956a79ee4fe46c0b9198421eb4..3e0dc82ba13827cde3d6faf9b2e2d8f4807a51d3 100644
--- a/chrome/browser/resources/vr_shell/vr_shell_ui.js
+++ b/chrome/browser/resources/vr_shell/vr_shell_ui.js
@@ -33,7 +33,7 @@ var vrShellUi = (function() {
/** @const */ this.FULLSCREEN_DISTANCE = 3.0;
let element = new api.UiElement(0, 0, 0, 0);
- element.setIsContentQuad();
+ element.setFill(new api.Content());
element.setVisible(false);
element.setSize(
this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT);
@@ -454,12 +454,67 @@ var vrShellUi = (function() {
}
};
+ class Background {
+ constructor() {
+ /** @const */ var GRADIENT_LIGHER_GRAY =
+ {r: 0.57, g: 0.57, b: 0.57, a: 1.0};
+ /** @const */ var GRADIENT_DARKER_GRAY =
+ {r: 0.48, g: 0.48, b: 0.48, a: 1.0};
+ /** @const */ var SCENE_GROUND_SIZE = 25.0;
+ /** @const */ var SCENE_HEIGHT = 4.0;
+ /** @const */ var TILE_NUMBER = 10;
+
+ // Make ground plane.
+ let groundPlane = new api.UiElementUpdate();
+ groundPlane.setVisible(true);
+ groundPlane.setSize(SCENE_GROUND_SIZE, SCENE_GROUND_SIZE);
+ groundPlane.setFill(
+ new api.OpaqueGradient(GRADIENT_LIGHER_GRAY, GRADIENT_DARKER_GRAY));
+ groundPlane.setTranslation(0, -SCENE_HEIGHT / 2, 0);
+ groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI / 2);
+ this.groundPlaneId = ui.addElement(groundPlane);
+
+ // Make ceiling plane.
+ let ceilingPlane = new api.UiElementUpdate();
+ ceilingPlane.setVisible(true);
+ ceilingPlane.setSize(SCENE_GROUND_SIZE, SCENE_GROUND_SIZE);
+ ceilingPlane.setFill(
+ new api.OpaqueGradient(GRADIENT_LIGHER_GRAY, GRADIENT_DARKER_GRAY));
+ ceilingPlane.setTranslation(0, SCENE_HEIGHT / 2, 0);
+ ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI / 2);
+ this.ceilingPlaneId = ui.addElement(ceilingPlane);
+
+ // Ground grid.
+ let groundGrid = new api.UiElementUpdate();
+ groundGrid.setVisible(true);
+ groundGrid.setSize(SCENE_GROUND_SIZE, SCENE_GROUND_SIZE);
+ groundGrid.setFill(new api.GridGradient(
+ GRADIENT_LIGHER_GRAY, GRADIENT_LIGHER_GRAY, TILE_NUMBER));
+ groundGrid.setTranslation(0, -SCENE_HEIGHT / 2 + 0.01, 0);
+ groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI / 2);
+ this.groundGridId = ui.addElement(groundGrid);
+ }
+
+ setEnabled(enabled) {
+ let groundPlaneUpdate = new api.UiElementUpdate();
+ groundPlaneUpdate.setVisible(enabled);
+ ui.updateElement(this.groundPlaneId, groundPlaneUpdate);
+ let ceilingPlaneUpdate = new api.UiElementUpdate();
+ ceilingPlaneUpdate.setVisible(enabled);
+ ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate);
+ let groundGridUpdate = new api.UiElementUpdate();
+ groundGridUpdate.setVisible(enabled);
+ ui.updateElement(this.groundGridId, groundGridUpdate);
+ }
+ };
+
class UiManager {
constructor() {
this.mode = api.Mode.UNKNOWN;
this.menuMode = false;
this.fullscreen = false;
+ this.background = new Background();
this.contentQuad = new ContentQuad();
let contentId = this.contentQuad.getElementId();
@@ -487,6 +542,7 @@ var vrShellUi = (function() {
0 :
URL_INDICATOR_VISIBILITY_TIMEOUT_MS);
this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR);
+ this.background.setEnabled(mode == api.Mode.STANDARD && !menuMode);
api.setUiCssSize(
uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR);

Powered by Google App Engine
This is Rietveld 408576698