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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 /** | 553 /** |
554 * Set the animation's easing. | 554 * Set the animation's easing. |
555 * @param {api.Easing} easing | 555 * @param {api.Easing} easing |
556 */ | 556 */ |
557 setEasing(easing) { | 557 setEasing(easing) { |
558 this.easing = easing; | 558 this.easing = easing; |
559 } | 559 } |
560 }; | 560 }; |
561 | 561 |
562 /** | 562 /** |
| 563 * Scene configuration class. Use this object to generate the payload of a |
| 564 * CONFIGURE_SCENE command. |
| 565 * @struct |
| 566 */ |
| 567 api.SceneConfiguration = class { |
| 568 constructor() { |
| 569 /** @private {!Object} */ |
| 570 this.properties = {}; |
| 571 } |
| 572 |
| 573 getCommandPayload() { |
| 574 return this.properties; |
| 575 } |
| 576 |
| 577 /** |
| 578 * Set the background color of the scene. |
| 579 * @param {{r: number, b: number, g: number, a: number}} color |
| 580 */ |
| 581 setBackgroundColor(color) { |
| 582 this.properties.backgroundColor = color; |
| 583 } |
| 584 |
| 585 /** |
| 586 * Set the radius of the background-bounding sphere. |
| 587 * @param {number} distance |
| 588 */ |
| 589 setBackgroundDistance(distance) { |
| 590 this.properties.backgroundDistance = distance; |
| 591 } |
| 592 |
| 593 /** |
| 594 * Enable or disable rendering of WebVR content in the foreground. Rendering |
| 595 * defaults to enabled when on a WebVR page. This property allows rendering to |
| 596 * be disabled, for purposes of showing an alternate UI (such as a menu). When |
| 597 * disabled, the cursor is rendered. |
| 598 * @param {boolean} enabled |
| 599 */ |
| 600 setWebVrRenderingModeEnabled(enabled) { |
| 601 this.properties.drawWebVr = enabled; |
| 602 } |
| 603 }; |
| 604 |
| 605 /** |
563 * Abstract class handling webui command calls from native. The UI must | 606 * Abstract class handling webui command calls from native. The UI must |
564 * subclass this and override the handlers. | 607 * subclass this and override the handlers. |
565 * @abstract | 608 * @abstract |
566 */ | 609 */ |
567 api.NativeCommandHandler = class { | 610 api.NativeCommandHandler = class { |
568 /** | 611 /** |
569 * @param {api.Mode} mode | 612 * @param {api.Mode} mode |
570 */ | 613 */ |
571 onSetMode(mode) {} | 614 onSetMode(mode) {} |
572 | 615 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 if ('removeTab' in dict) { | 752 if ('removeTab' in dict) { |
710 this.onRemoveTab(dict['removeTab']); | 753 this.onRemoveTab(dict['removeTab']); |
711 } | 754 } |
712 if ('canGoBack' in dict) { | 755 if ('canGoBack' in dict) { |
713 this.onSetHistoryButtonsEnabled(dict['canGoBack'], dict['canGoForward']); | 756 this.onSetHistoryButtonsEnabled(dict['canGoBack'], dict['canGoForward']); |
714 } | 757 } |
715 | 758 |
716 this.onCommandHandlerFinished() | 759 this.onCommandHandlerFinished() |
717 } | 760 } |
718 }; | 761 }; |
OLD | NEW |