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

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

Issue 2775003002: Assign names to VR UI elements for debugging and test. (Closed)
Patch Set: Restore use of UiElementUpdate when adding non-sprite UI elements. Created 3 years, 9 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.48; 50 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.48;
51 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = -0.125; 51 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = -0.125;
52 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414; 52 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414;
53 /** @const */ this.DOM_INTERCEPTOR_SELECTOR = '#content-interceptor'; 53 /** @const */ this.DOM_INTERCEPTOR_SELECTOR = '#content-interceptor';
54 /** @const */ this.DOM_INTERCEPTOR_ELEVATION = 0.01; 54 /** @const */ this.DOM_INTERCEPTOR_ELEVATION = 0.01;
55 55
56 this.menuMode = false; 56 this.menuMode = false;
57 this.fullscreen = false; 57 this.fullscreen = false;
58 58
59 let element = new api.UiElement(0, 0, 0, 0); 59 let element = new api.UiElement(0, 0, 0, 0);
60 element.setName('Content');
60 element.setFill(new api.Content()); 61 element.setFill(new api.Content());
61 element.setVisible(false); 62 element.setVisible(false);
62 element.setSize( 63 element.setSize(
63 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); 64 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT);
64 element.setTranslation( 65 element.setTranslation(
65 0, this.BROWSING_SCREEN_ELEVATION, -this.BROWSING_SCREEN_DISTANCE); 66 0, this.BROWSING_SCREEN_ELEVATION, -this.BROWSING_SCREEN_DISTANCE);
66 this.elementId = ui.addElement(element); 67 this.elementId = ui.addElement(element);
67 68
68 // Place an invisible (fill none) but hittable plane behind the content 69 // Place an invisible (fill none) but hittable plane behind the content
69 // quad, to keep the reticle roughly planar with the content if near 70 // quad, to keep the reticle roughly planar with the content if near
70 // content. 71 // content.
71 let backPlane = new api.UiElement(0, 0, 0, 0); 72 let backPlane = new api.UiElement(0, 0, 0, 0);
73 backPlane.setName('Content backing');
72 backPlane.setSize(1000, 1000); 74 backPlane.setSize(1000, 1000);
73 backPlane.setTranslation(0, 0, -0.01); 75 backPlane.setTranslation(0, 0, -0.01);
74 backPlane.setParentId(this.elementId); 76 backPlane.setParentId(this.elementId);
75 backPlane.setFill(new api.NoFill()); 77 backPlane.setFill(new api.NoFill());
76 ui.addElement(backPlane); 78 ui.addElement(backPlane);
77 79
78 // Place invisible plane on top of content quad, to intercept the clicks 80 // Place invisible plane on top of content quad, to intercept the clicks
79 // while on menu mode. 81 // while on menu mode.
80 this.interceptor = new DomUiElement(this.DOM_INTERCEPTOR_SELECTOR); 82 this.interceptor = new DomUiElement(this.DOM_INTERCEPTOR_SELECTOR);
81 let update = new api.UiElementUpdate(); 83 let update = new api.UiElementUpdate();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 199 }
198 200
199 this.rotationX = getStyleFloat(style, '--rotX', 0); 201 this.rotationX = getStyleFloat(style, '--rotX', 0);
200 this.rotationY = getStyleFloat(style, '--rotY', 0); 202 this.rotationY = getStyleFloat(style, '--rotY', 0);
201 this.rotationZ = getStyleFloat(style, '--rotZ', 0); 203 this.rotationZ = getStyleFloat(style, '--rotZ', 0);
202 if (this.rotationX != 0 || this.rotationY != 0 || this.rotationZ != 0) { 204 if (this.rotationX != 0 || this.rotationY != 0 || this.rotationZ != 0) {
203 element.setRotation( 205 element.setRotation(
204 this.rotationX, this.rotationY, this.rotationZ, 2 * Math.PI); 206 this.rotationX, this.rotationY, this.rotationZ, 2 * Math.PI);
205 } 207 }
206 208
209 element.setName(domId);
207 this.id = ui.addElement(element); 210 this.id = ui.addElement(element);
208 this.domElement = domElement; 211 this.domElement = domElement;
209 } 212 }
210 }; 213 };
211 214
212 class Button { 215 class Button {
213 constructor(domId, callback, parentId) { 216 constructor(domId, callback, parentId) {
214 let captionId = domId + '-caption'; 217 let captionId = domId + '-caption';
215 this.button = document.querySelector(domId); 218 this.button = document.querySelector(domId);
216 this.caption = document.querySelector(captionId); 219 this.caption = document.querySelector(captionId);
217 this.callback = callback; 220 this.callback = callback;
218 this.enabled = true; 221 this.enabled = true;
219 222
220 // Create an invisible parent, from which the button will hover. 223 // Create an invisible parent, from which the button will hover.
221 let backing = new api.UiElement(0, 0, 0, 0); 224 let backing = new api.UiElement(0, 0, 0, 0);
225 backing.setName(domId + '-backing');
222 backing.setParentId(parentId); 226 backing.setParentId(parentId);
223 backing.setVisible(false); 227 backing.setVisible(false);
224 this.backingElementId = ui.addElement(backing); 228 this.backingElementId = ui.addElement(backing);
225 229
226 this.buttonElement = new DomUiElement(domId); 230 this.buttonElement = new DomUiElement(domId);
227 let update = new api.UiElementUpdate(); 231 let update = new api.UiElementUpdate();
228 update.setParentId(this.backingElementId); 232 update.setParentId(this.backingElementId);
229 ui.updateElement(this.buttonElement.id, update); 233 ui.updateElement(this.buttonElement.id, update);
230 234
231 this.captionElement = new DomUiElement(captionId); 235 this.captionElement = new DomUiElement(captionId);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 291 }
288 }; 292 };
289 293
290 class GestureHandlers { 294 class GestureHandlers {
291 constructor() { 295 constructor() {
292 /** @const */ var BACKING_DISTANCE = 0.8; 296 /** @const */ var BACKING_DISTANCE = 0.8;
293 /** @const */ var INDICATOR_DISTANCE = 0.15; 297 /** @const */ var INDICATOR_DISTANCE = 0.15;
294 this.enabled = false; 298 this.enabled = false;
295 299
296 let backing = new api.UiElement(0, 0, 0, 0); 300 let backing = new api.UiElement(0, 0, 0, 0);
301 backing.setName('Navigation indicator backing');
297 backing.setVisible(false); 302 backing.setVisible(false);
298 backing.setTranslation(0, 0, -BACKING_DISTANCE); 303 backing.setTranslation(0, 0, -BACKING_DISTANCE);
299 backing.setLockToFieldOfView(true); 304 backing.setLockToFieldOfView(true);
300 this.backingElementId = ui.addElement(backing); 305 this.backingElementId = ui.addElement(backing);
301 306
302 this.indicators = {}; 307 this.indicators = {};
303 this.indicators[api.Direction.LEFT] = 308 this.indicators[api.Direction.LEFT] =
304 new GestureHandler( 309 new GestureHandler(
305 '#back-indicator', 310 '#back-indicator',
306 function() { 311 function() {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 api.doAction(api.Action.HISTORY_FORWARD, {}); 416 api.doAction(api.Action.HISTORY_FORWARD, {});
412 } 417 }
413 ], 418 ],
414 ]; 419 ];
415 420
416 /** @const */ var BUTTON_Y = -0.53; 421 /** @const */ var BUTTON_Y = -0.53;
417 /** @const */ var BUTTON_Z = -2; 422 /** @const */ var BUTTON_Z = -2;
418 /** @const */ var BUTTON_SPACING = 0.14; 423 /** @const */ var BUTTON_SPACING = 0.14;
419 424
420 let controls = new api.UiElement(0, 0, 0, 0); 425 let controls = new api.UiElement(0, 0, 0, 0);
426 controls.setName('Controls');
421 controls.setVisible(false); 427 controls.setVisible(false);
422 controls.setTranslation(0, BUTTON_Y, BUTTON_Z); 428 controls.setTranslation(0, BUTTON_Y, BUTTON_Z);
423 this.controlsId = ui.addElement(controls); 429 this.controlsId = ui.addElement(controls);
424 430
425 let startPosition = -BUTTON_SPACING * (descriptors.length / 2.0 - 0.5); 431 let startPosition = -BUTTON_SPACING * (descriptors.length / 2.0 - 0.5);
426 432
427 for (let i = 0; i < descriptors.length; i++) { 433 for (let i = 0; i < descriptors.length; i++) {
428 let name = descriptors[i][0]; 434 let name = descriptors[i][0];
429 let domId = descriptors[i][1]; 435 let domId = descriptors[i][1];
430 let callback = descriptors[i][2]; 436 let callback = descriptors[i][2];
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 /** @const */ this.SCENE_GROUND_SIZE = 25.0; 735 /** @const */ this.SCENE_GROUND_SIZE = 25.0;
730 /** @const */ this.SCENE_HEIGHT = 4.0; 736 /** @const */ this.SCENE_HEIGHT = 4.0;
731 /** @const */ this.GRIDLINE_COUNT = 40; 737 /** @const */ this.GRIDLINE_COUNT = 40;
732 /** @const */ this.HORIZON_COLOR = {r: 0.57, g: 0.57, b: 0.57, a: 1.0}; 738 /** @const */ this.HORIZON_COLOR = {r: 0.57, g: 0.57, b: 0.57, a: 1.0};
733 /** @const */ this.CENTER_COLOR = {r: 0.48, g: 0.48, b: 0.48, a: 1.0}; 739 /** @const */ this.CENTER_COLOR = {r: 0.48, g: 0.48, b: 0.48, a: 1.0};
734 /** @const */ this.FULLSCREEN_BACKGROUND_COLOR = 740 /** @const */ this.FULLSCREEN_BACKGROUND_COLOR =
735 {r: 0.1, g: 0.1, b: 0.1, a: 1.0}; 741 {r: 0.1, g: 0.1, b: 0.1, a: 1.0};
736 742
737 // Make ground plane. 743 // Make ground plane.
738 let groundPlane = new api.UiElementUpdate(); 744 let groundPlane = new api.UiElementUpdate();
745 groundPlane.setName('Ground plane');
739 groundPlane.setVisible(true); 746 groundPlane.setVisible(true);
740 groundPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); 747 groundPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE);
741 groundPlane.setFill( 748 groundPlane.setFill(
742 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR)); 749 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR));
743 groundPlane.setTranslation(0, -this.SCENE_HEIGHT / 2, 0); 750 groundPlane.setTranslation(0, -this.SCENE_HEIGHT / 2, 0);
744 groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); 751 groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI / 2);
745 groundPlane.setDrawPhase(0); 752 groundPlane.setDrawPhase(0);
746 this.groundPlaneId = ui.addElement(groundPlane); 753 this.groundPlaneId = ui.addElement(groundPlane);
747 754
748 // Make ceiling plane. 755 // Make ceiling plane.
749 let ceilingPlane = new api.UiElementUpdate(); 756 let ceilingPlane = new api.UiElementUpdate();
757 ceilingPlane.setName('Ceiling');
750 ceilingPlane.setVisible(true); 758 ceilingPlane.setVisible(true);
751 ceilingPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); 759 ceilingPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE);
752 ceilingPlane.setFill( 760 ceilingPlane.setFill(
753 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR)); 761 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR));
754 ceilingPlane.setTranslation(0, this.SCENE_HEIGHT * 2, 0); 762 ceilingPlane.setTranslation(0, this.SCENE_HEIGHT * 2, 0);
755 ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI / 2); 763 ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI / 2);
756 ceilingPlane.setDrawPhase(0); 764 ceilingPlane.setDrawPhase(0);
757 this.ceilingPlaneId = ui.addElement(ceilingPlane); 765 this.ceilingPlaneId = ui.addElement(ceilingPlane);
758 766
759 // Ground grid. 767 // Ground grid.
760 let groundGrid = new api.UiElementUpdate(); 768 let groundGrid = new api.UiElementUpdate();
769 groundGrid.setName('Ground grid');
761 groundGrid.setVisible(true); 770 groundGrid.setVisible(true);
762 groundGrid.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); 771 groundGrid.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE);
763 let transparentHorizonColor = { 772 let transparentHorizonColor = {
764 r: this.HORIZON_COLOR.r, 773 r: this.HORIZON_COLOR.r,
765 g: this.HORIZON_COLOR.g, 774 g: this.HORIZON_COLOR.g,
766 b: this.HORIZON_COLOR.b, 775 b: this.HORIZON_COLOR.b,
767 a: 0 776 a: 0
768 }; 777 };
769 groundGrid.setFill(new api.GridGradient( 778 groundGrid.setFill(new api.GridGradient(
770 transparentHorizonColor, this.HORIZON_COLOR, this.GRIDLINE_COUNT)); 779 transparentHorizonColor, this.HORIZON_COLOR, this.GRIDLINE_COUNT));
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 nativeCommandHandler.handleCommand(dict); 1345 nativeCommandHandler.handleCommand(dict);
1337 } 1346 }
1338 1347
1339 return { 1348 return {
1340 initialize: initialize, 1349 initialize: initialize,
1341 command: command, 1350 command: command,
1342 }; 1351 };
1343 })(); 1352 })();
1344 1353
1345 window.addEventListener('load', vrShellUi.initialize); 1354 window.addEventListener('load', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_unittest.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