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

Side by Side Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2698623007: Change how the VR reticle distance is determined. (Closed)
Patch Set: Change background distance multplier to 1.414; move Reload UI button out of the floor. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var vrShellUi = (function() { 5 var vrShellUi = (function() {
6 'use strict'; 6 'use strict';
7 7
8 let ui = new scene.Scene(); 8 let ui = new scene.Scene();
9 let uiManager; 9 let uiManager;
10 let nativeCommandHandler; 10 let nativeCommandHandler;
(...skipping 20 matching lines...) Expand all
31 /** @const */ this.SCREEN_HEIGHT = 1.6; 31 /** @const */ this.SCREEN_HEIGHT = 1.6;
32 /** @const */ this.SCREEN_RATIO = 16 / 9; 32 /** @const */ this.SCREEN_RATIO = 16 / 9;
33 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; 33 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0;
34 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; 34 /** @const */ this.FULLSCREEN_DISTANCE = 3.0;
35 /** @const */ this.CSS_WIDTH_PIXELS = 960.0; 35 /** @const */ this.CSS_WIDTH_PIXELS = 960.0;
36 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0; 36 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0;
37 /** @const */ this.DPR = 1.2; 37 /** @const */ this.DPR = 1.2;
38 /** @const */ this.MENU_MODE_SCREEN_DISTANCE = 1.2; 38 /** @const */ this.MENU_MODE_SCREEN_DISTANCE = 1.2;
39 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.5; 39 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.5;
40 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = 0.1; 40 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = 0.1;
41 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414;
41 42
42 this.menuMode = false; 43 this.menuMode = false;
43 this.fullscreen = false; 44 this.fullscreen = false;
44 45
45 let element = new api.UiElement(0, 0, 0, 0); 46 let element = new api.UiElement(0, 0, 0, 0);
46 element.setFill(new api.Content()); 47 element.setFill(new api.Content());
47 element.setVisible(false); 48 element.setVisible(false);
48 element.setSize( 49 element.setSize(
49 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); 50 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT);
50 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE); 51 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE);
51 this.elementId = ui.addElement(element); 52 this.elementId = ui.addElement(element);
53
54 // Place an invisible but hittable plane behind the content quad, to keep
55 // the reticle roughly planar with the content if near content.
56 let backPlane = new api.UiElement(0, 0, 0, 0);
57 backPlane.setVisible(false);
58 backPlane.setHitTestable(true);
59 backPlane.setSize(1000, 1000);
60 backPlane.setTranslation(0, 0, -0.01);
61 backPlane.setParentId(this.elementId);
62 ui.addElement(backPlane);
63
64 this.updateState();
52 } 65 }
53 66
54 setEnabled(enabled) { 67 setEnabled(enabled) {
55 let update = new api.UiElementUpdate(); 68 let update = new api.UiElementUpdate();
56 update.setVisible(enabled); 69 update.setVisible(enabled);
57 ui.updateElement(this.elementId, update); 70 ui.updateElement(this.elementId, update);
58 if (enabled) { 71 if (enabled) {
59 api.setContentCssSize( 72 api.setContentCssSize(
60 this.CSS_WIDTH_PIXELS, this.CSS_HEIGHT_PIXELS, this.DPR); 73 this.CSS_WIDTH_PIXELS, this.CSS_HEIGHT_PIXELS, this.DPR);
61 } else { 74 } else {
(...skipping 12 matching lines...) Expand all
74 setFullscreen(enabled) { 87 setFullscreen(enabled) {
75 if (this.fullscreen == enabled) 88 if (this.fullscreen == enabled)
76 return; 89 return;
77 this.fullscreen = enabled; 90 this.fullscreen = enabled;
78 this.updateState() 91 this.updateState()
79 } 92 }
80 93
81 updateState() { 94 updateState() {
82 // Defaults content quad parameters. 95 // Defaults content quad parameters.
83 let y = 0; 96 let y = 0;
84 let z = -this.BROWSING_SCREEN_DISTANCE; 97 let distance = this.BROWSING_SCREEN_DISTANCE;
85 let height = this.SCREEN_HEIGHT; 98 let height = this.SCREEN_HEIGHT;
86 99
87 // Mode-specific overrides. 100 // Mode-specific overrides.
88 if (this.menuMode) { 101 if (this.menuMode) {
89 y = this.MENU_MODE_SCREEN_ELEVATION; 102 y = this.MENU_MODE_SCREEN_ELEVATION;
90 z = -this.MENU_MODE_SCREEN_DISTANCE; 103 distance = this.MENU_MODE_SCREEN_DISTANCE;
91 height = this.MENU_MODE_SCREEN_HEIGHT; 104 height = this.MENU_MODE_SCREEN_HEIGHT;
92 } else if (this.fullscreen) { 105 } else if (this.fullscreen) {
93 z = -this.FULLSCREEN_DISTANCE; 106 distance = this.FULLSCREEN_DISTANCE;
94 } 107 }
95 108
96 let anim; 109 let anim;
97 anim = new api.Animation(this.elementId, ANIM_DURATION); 110 anim = new api.Animation(this.elementId, ANIM_DURATION);
98 anim.setTranslation(0, y, z); 111 anim.setTranslation(0, y, -distance);
99 ui.addAnimation(anim); 112 ui.addAnimation(anim);
100 anim = new api.Animation(this.elementId, ANIM_DURATION); 113 anim = new api.Animation(this.elementId, ANIM_DURATION);
101 anim.setSize(height * this.SCREEN_RATIO, height); 114 anim.setSize(height * this.SCREEN_RATIO, height);
102 ui.addAnimation(anim); 115 ui.addAnimation(anim);
116
117 ui.setBackgroundDistance(distance * this.BACKGROUND_DISTANCE_MULTIPLIER);
103 } 118 }
104 119
105 // TODO(crbug/643815): Add a method setting aspect ratio (and possible 120 // TODO(crbug/643815): Add a method setting aspect ratio (and possible
106 // animation of changing it). 121 // animation of changing it).
107 122
108 getElementId() { 123 getElementId() {
109 return this.elementId; 124 return this.elementId;
110 } 125 }
111 }; 126 };
112 127
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 this.devMode = false; 260 this.devMode = false;
246 261
247 this.uiElement = new DomUiElement('#reload-ui-button'); 262 this.uiElement = new DomUiElement('#reload-ui-button');
248 this.uiElement.domElement.addEventListener('click', function() { 263 this.uiElement.domElement.addEventListener('click', function() {
249 ui.purge(); 264 ui.purge();
250 api.doAction(api.Action.RELOAD_UI, {}); 265 api.doAction(api.Action.RELOAD_UI, {});
251 }); 266 });
252 267
253 let update = new api.UiElementUpdate(); 268 let update = new api.UiElementUpdate();
254 update.setVisible(false); 269 update.setVisible(false);
255 update.setSize(0.5, 0.2); 270 update.setSize(0.25, 0.1);
256 update.setTranslation(0, -2, -1); 271 update.setTranslation(0, -1.5, -1.5);
257 update.setRotation(1, 0, 0, -0.8); 272 update.setRotation(1, 0, 0, -0.8);
258 ui.updateElement(this.uiElement.uiElementId, update); 273 ui.updateElement(this.uiElement.uiElementId, update);
259 } 274 }
260 275
261 setEnabled(enabled) { 276 setEnabled(enabled) {
262 this.enabled = enabled; 277 this.enabled = enabled;
263 this.updateState(); 278 this.updateState();
264 } 279 }
265 280
266 setDevMode(enabled) { 281 setDevMode(enabled) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 g: this.HORIZON_COLOR.g, 574 g: this.HORIZON_COLOR.g,
560 b: this.HORIZON_COLOR.b, 575 b: this.HORIZON_COLOR.b,
561 a: 0 576 a: 0
562 }; 577 };
563 groundGrid.setFill(new api.GridGradient( 578 groundGrid.setFill(new api.GridGradient(
564 transparentHorizonColor, this.HORIZON_COLOR, this.GRIDLINE_COUNT)); 579 transparentHorizonColor, this.HORIZON_COLOR, this.GRIDLINE_COUNT));
565 groundGrid.setTranslation(0, -this.SCENE_HEIGHT / 2 + 0.01, 0); 580 groundGrid.setTranslation(0, -this.SCENE_HEIGHT / 2 + 0.01, 0);
566 groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); 581 groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI / 2);
567 groundGrid.setDrawPhase(0); 582 groundGrid.setDrawPhase(0);
568 this.groundGridId = ui.addElement(groundGrid); 583 this.groundGridId = ui.addElement(groundGrid);
584
585 ui.setBackgroundColor(this.HORIZON_COLOR);
569 } 586 }
570 587
571 setEnabled(enabled) { 588 setEnabled(enabled) {
572 let groundPlaneUpdate = new api.UiElementUpdate(); 589 let groundPlaneUpdate = new api.UiElementUpdate();
573 groundPlaneUpdate.setVisible(enabled); 590 groundPlaneUpdate.setVisible(enabled);
574 ui.updateElement(this.groundPlaneId, groundPlaneUpdate); 591 ui.updateElement(this.groundPlaneId, groundPlaneUpdate);
575 let ceilingPlaneUpdate = new api.UiElementUpdate(); 592 let ceilingPlaneUpdate = new api.UiElementUpdate();
576 ceilingPlaneUpdate.setVisible(enabled); 593 ceilingPlaneUpdate.setVisible(enabled);
577 ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate); 594 ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate);
578 let groundGridUpdate = new api.UiElementUpdate(); 595 let groundGridUpdate = new api.UiElementUpdate();
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 nativeCommandHandler.handleCommand(dict); 973 nativeCommandHandler.handleCommand(dict);
957 } 974 }
958 975
959 return { 976 return {
960 initialize: initialize, 977 initialize: initialize,
961 command: command, 978 command: command,
962 }; 979 };
963 })(); 980 })();
964 981
965 window.addEventListener('load', vrShellUi.initialize); 982 window.addEventListener('load', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.cc ('k') | chrome/browser/resources/vr_shell/vr_shell_ui_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698