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 scene = {}; | 5 var scene = {}; |
6 | 6 |
7 /** | 7 /** |
8 * The scene class assists in managing element and animations in the UI. It | 8 * The scene class assists in managing element and animations in the UI. It |
9 * allows UI update API commands to be queued in batches, and manages allocation | 9 * allows UI update API commands to be queued in batches, and manages allocation |
10 * of element and animation IDs. | 10 * of element and animation IDs. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 removeAnimation(id) { | 123 removeAnimation(id) { |
124 // To-do: Make sure ID exists. | 124 // To-do: Make sure ID exists. |
125 this.commands.push({ | 125 this.commands.push({ |
126 'type': api.Command.REMOVE_ANIMATION, | 126 'type': api.Command.REMOVE_ANIMATION, |
127 'data': {'id': id, 'meshId': this.animations[id]} | 127 'data': {'id': id, 'meshId': this.animations[id]} |
128 }); | 128 }); |
129 delete this.animations[id]; | 129 delete this.animations[id]; |
130 } | 130 } |
131 | 131 |
132 /** | 132 /** |
133 * Set the background color of the scene. | 133 * Configure scene parameters. |
cjgrant
2017/03/16 15:44:37
Dropping comments as these are direct wrappers on
tiborg
2017/03/16 19:40:23
Acknowledged.
| |
134 * @param {{r: number, b: number, g: number, a: number}} color | 134 * @param {api.SceneConfiguration} configuration |
135 */ | 135 */ |
136 setBackgroundColor(color) { | 136 configureScene(configuration) { |
137 this.commands.push( | |
138 {'type': api.Command.UPDATE_BACKGROUND, 'data': {'color': color}}); | |
139 } | |
140 | |
141 /** | |
142 * Set the radius of background-bounding sphere. | |
143 * @param {number} distance | |
144 */ | |
145 setBackgroundDistance(distance) { | |
146 this.commands.push({ | 137 this.commands.push({ |
147 'type': api.Command.UPDATE_BACKGROUND, | 138 'type': api.Command.CONFIGURE_SCENE, |
148 'data': {'distance': distance} | 139 'data': configuration.getCommandPayload(), |
149 }); | 140 }); |
150 } | 141 } |
151 | 142 |
152 /** | 143 /** |
144 * @param {{r: number, b: number, g: number, a: number}} color | |
145 */ | |
146 setBackgroundColor(color) { | |
147 let configuration = new api.SceneConfiguration(); | |
148 configuration.setBackgroundColor(color); | |
149 this.configureScene(configuration); | |
150 } | |
151 | |
152 /** | |
153 * @param {number} distance | |
154 */ | |
155 setBackgroundDistance(distance) { | |
156 let configuration = new api.SceneConfiguration(); | |
157 configuration.setBackgroundDistance(distance); | |
158 this.configureScene(configuration); | |
159 } | |
160 | |
161 /** | |
162 * @param {boolean} enabled | |
163 */ | |
164 setCursorEnabled(enabled) { | |
165 let configuration = new api.SceneConfiguration(); | |
166 configuration.setCursorEnabled(enabled); | |
167 this.configureScene(configuration); | |
168 } | |
169 | |
170 /** | |
171 * @param {boolean} enabled | |
172 */ | |
173 setWebVrRenderingEnabled(enabled) { | |
174 let configuration = new api.SceneConfiguration(); | |
175 configuration.setWebVrRenderingEnabled(enabled); | |
176 this.configureScene(configuration); | |
177 } | |
178 | |
179 /** | |
153 * Purge all elements in the scene. | 180 * Purge all elements in the scene. |
154 */ | 181 */ |
155 purge() { | 182 purge() { |
156 var ids = Object.keys(this.animations); | 183 var ids = Object.keys(this.animations); |
157 for (let id_key of ids) { | 184 for (let id_key of ids) { |
158 var id = parseInt(id_key, 10); | 185 var id = parseInt(id_key, 10); |
159 this.removeAnimation(id); | 186 this.removeAnimation(id); |
160 } | 187 } |
161 var ids = this.elements.values(); | 188 var ids = this.elements.values(); |
162 for (let id of ids) { | 189 for (let id of ids) { |
163 this.removeElement(id); | 190 this.removeElement(id); |
164 } | 191 } |
165 this.flush(); | 192 this.flush(); |
166 } | 193 } |
167 }; | 194 }; |
OLD | NEW |