Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 api = {}; | 5 var api = {}; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Enumeration of scene update commands. | 8 * Enumeration of scene update commands. |
| 9 * @enum {number} | 9 * @enum {number} |
| 10 * @const | 10 * @const |
| 11 */ | 11 */ |
| 12 api.Command = { | 12 api.Command = { |
| 13 'ADD_ELEMENT': 0, | 13 'ADD_ELEMENT': 0, |
| 14 'UPDATE_ELEMENT': 1, | 14 'UPDATE_ELEMENT': 1, |
| 15 'REMOVE_ELEMENT': 2, | 15 'REMOVE_ELEMENT': 2, |
| 16 'ADD_ANIMATION': 3, | 16 'ADD_ANIMATION': 3, |
| 17 'REMOVE_ANIMATION': 4, | 17 'REMOVE_ANIMATION': 4, |
| 18 'UPDATE_BACKGROUND': 5 | 18 'CONFIGURE_SCENE': 5 |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Sends one or more commands to native scene management. Commands are used | 22 * Sends one or more commands to native scene management. Commands are used |
| 23 * to add, modify or remove elements and animations. For examples of how to | 23 * to add, modify or remove elements and animations. For examples of how to |
| 24 * format command parameters, refer to examples in scene.js. | 24 * format command parameters, refer to examples in scene.js. |
| 25 * @param {Array<Object>} commands | 25 * @param {Array<Object>} commands |
| 26 */ | 26 */ |
| 27 api.sendCommands = function(commands) { | 27 api.sendCommands = function(commands) { |
| 28 if (commands.length > 0) { | 28 if (commands.length > 0) { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 /** | 533 /** |
| 534 * Set the animation's easing. | 534 * Set the animation's easing. |
| 535 * @param {api.Easing} easing | 535 * @param {api.Easing} easing |
| 536 */ | 536 */ |
| 537 setEasing(easing) { | 537 setEasing(easing) { |
| 538 this.easing = easing; | 538 this.easing = easing; |
| 539 } | 539 } |
| 540 }; | 540 }; |
| 541 | 541 |
| 542 /** | 542 /** |
| 543 * Scene configuration class. Use this object to generate the payload of a | |
| 544 * CONFIGURE_SCENE command. | |
| 545 * @struct | |
| 546 */ | |
| 547 api.SceneConfiguration = class { | |
| 548 constructor() { | |
| 549 /** @private {!Object} */ | |
| 550 this.properties = {}; | |
| 551 } | |
| 552 | |
| 553 getCommandPayload() { | |
| 554 return this.properties; | |
| 555 } | |
| 556 | |
| 557 /** | |
| 558 * Set the background color of the scene. | |
| 559 * @param {{r: number, b: number, g: number, a: number}} color | |
| 560 */ | |
| 561 setBackgroundColor(color) { | |
| 562 this.properties.backgroundColor = color; | |
| 563 } | |
| 564 | |
| 565 /** | |
| 566 * Set the radius of the background-bounding sphere. | |
| 567 * @param {number} distance | |
| 568 */ | |
| 569 setBackgroundDistance(distance) { | |
| 570 this.properties.backgroundDistance = distance; | |
| 571 } | |
| 572 | |
| 573 /** | |
| 574 * Enable or disable rendering of the laser and reticle. | |
| 575 * @param {boolean} enabled | |
| 576 */ | |
| 577 setCursorEnabled(enabled) { | |
| 578 this.properties.drawCursor = enabled; | |
| 579 } | |
| 580 | |
| 581 /** | |
| 582 * Enable or disable rendering of WebVR content in the foreground. Rendering | |
| 583 * defaults to enable when on a WebVR page. This property allows rendering to | |
| 584 * be disabled, for purposes of showing an alternate UI (such as a menu). | |
| 585 * @param {boolean} enabled | |
| 586 */ | |
| 587 setWebVrRenderingEnabled(enabled) { | |
|
tiborg
2017/03/16 19:40:23
Maybe call it setShowWebVrPresentation or so? Sinc
cjgrant
2017/03/20 15:34:57
Now that this controls rendering of WebVR vs UI an
tiborg
2017/03/20 15:56:08
setWebVrRenderingModeEnabled() sounds good to me.
cjgrant
2017/03/20 17:57:22
Done.
| |
| 588 this.properties.drawWebVr = enabled; | |
| 589 } | |
| 590 }; | |
| 591 | |
| 592 /** | |
| 543 * Abstract class handling webui command calls from native. The UI must | 593 * Abstract class handling webui command calls from native. The UI must |
| 544 * subclass this and override the handlers. | 594 * subclass this and override the handlers. |
| 545 * @abstract | 595 * @abstract |
| 546 */ | 596 */ |
| 547 api.NativeCommandHandler = class { | 597 api.NativeCommandHandler = class { |
| 548 /** | 598 /** |
| 549 * @param {api.Mode} mode | 599 * @param {api.Mode} mode |
| 550 */ | 600 */ |
| 551 onSetMode(mode) {} | 601 onSetMode(mode) {} |
| 552 | 602 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 if ('removeTab' in dict) { | 730 if ('removeTab' in dict) { |
| 681 this.onRemoveTab(dict['removeTab']); | 731 this.onRemoveTab(dict['removeTab']); |
| 682 } | 732 } |
| 683 if ('canGoBack' in dict) { | 733 if ('canGoBack' in dict) { |
| 684 this.onSetHistoryButtonsEnabled(dict['canGoBack'], dict['canGoForward']); | 734 this.onSetHistoryButtonsEnabled(dict['canGoBack'], dict['canGoForward']); |
| 685 } | 735 } |
| 686 | 736 |
| 687 this.onCommandHandlerFinished() | 737 this.onCommandHandlerFinished() |
| 688 } | 738 } |
| 689 }; | 739 }; |
| OLD | NEW |