| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 */ | 8 */ |
| 9 WebInspector.SensorsView = function() | 9 WebInspector.SensorsView = function() |
| 10 { | 10 { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 { | 246 { |
| 247 if (!deviceOrientation) | 247 if (!deviceOrientation) |
| 248 return; | 248 return; |
| 249 | 249 |
| 250 /** | 250 /** |
| 251 * @param {number} angle | 251 * @param {number} angle |
| 252 * @return {number} | 252 * @return {number} |
| 253 */ | 253 */ |
| 254 function roundAngle(angle) | 254 function roundAngle(angle) |
| 255 { | 255 { |
| 256 return Math.round(angle*10000)/10000; | 256 return Math.round(angle * 10000) / 10000; |
| 257 } | 257 } |
| 258 | 258 |
| 259 if (modificationSource != WebInspector.SensorsView.DeviceOrientationModi
ficationSource.UserInput) { | 259 if (modificationSource != WebInspector.SensorsView.DeviceOrientationModi
ficationSource.UserInput) { |
| 260 this._alphaSetter(roundAngle(deviceOrientation.alpha)); | 260 this._alphaSetter(roundAngle(deviceOrientation.alpha)); |
| 261 this._betaSetter(roundAngle(deviceOrientation.beta)); | 261 this._betaSetter(roundAngle(deviceOrientation.beta)); |
| 262 this._gammaSetter(roundAngle(deviceOrientation.gamma)); | 262 this._gammaSetter(roundAngle(deviceOrientation.gamma)); |
| 263 } | 263 } |
| 264 | 264 |
| 265 var animate = modificationSource !== WebInspector.SensorsView.DeviceOrie
ntationModificationSource.UserDrag; | 265 var animate = modificationSource !== WebInspector.SensorsView.DeviceOrie
ntationModificationSource.UserDrag; |
| 266 this._setBoxOrientation(deviceOrientation, animate); | 266 this._setBoxOrientation(deviceOrientation, animate); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 * @param {!WebInspector.DeviceOrientation} deviceOrientation | 314 * @param {!WebInspector.DeviceOrientation} deviceOrientation |
| 315 * @param {boolean} animate | 315 * @param {boolean} animate |
| 316 */ | 316 */ |
| 317 _setBoxOrientation: function(deviceOrientation, animate) | 317 _setBoxOrientation: function(deviceOrientation, animate) |
| 318 { | 318 { |
| 319 if (animate) | 319 if (animate) |
| 320 this._stageElement.classList.add("is-animating"); | 320 this._stageElement.classList.add("is-animating"); |
| 321 else | 321 else |
| 322 this._stageElement.classList.remove("is-animating"); | 322 this._stageElement.classList.remove("is-animating"); |
| 323 | 323 |
| 324 // The CSS transform should not depend on matrix3d, which does not inter
polate well. |
| 324 var matrix = new WebKitCSSMatrix(); | 325 var matrix = new WebKitCSSMatrix(); |
| 325 this._boxMatrix = matrix.rotate(-deviceOrientation.beta, deviceOrientati
on.gamma, -deviceOrientation.alpha); | 326 this._boxMatrix = matrix.rotate(-deviceOrientation.beta, deviceOrientati
on.gamma, -deviceOrientation.alpha); |
| 326 var eulerAngles = WebInspector.Geometry.EulerAngles.fromRotationMatrix(t
his._boxMatrix); | 327 var eulerAngles = new WebInspector.Geometry.EulerAngles(deviceOrientatio
n.alpha, deviceOrientation.beta, deviceOrientation.gamma); |
| 327 this._orientationLayer.style.transform = eulerAngles.toRotate3DString(); | 328 this._orientationLayer.style.transform = eulerAngles.toRotate3DString(); |
| 328 }, | 329 }, |
| 329 | 330 |
| 330 /** | 331 /** |
| 331 * @param {!MouseEvent} event | 332 * @param {!MouseEvent} event |
| 332 * @return {boolean} | 333 * @return {boolean} |
| 333 */ | 334 */ |
| 334 _onBoxDrag: function(event) | 335 _onBoxDrag: function(event) |
| 335 { | 336 { |
| 336 var mouseMoveVector = this._calculateRadiusVector(event.x, event.y); | 337 var mouseMoveVector = this._calculateRadiusVector(event.x, event.y); |
| 337 if (!mouseMoveVector) | 338 if (!mouseMoveVector) |
| 338 return true; | 339 return true; |
| 339 | 340 |
| 340 event.consume(true); | 341 event.consume(true); |
| 341 var axis, angle; | 342 var axis, angle; |
| 342 if (event.shiftKey) { | 343 if (event.shiftKey) { |
| 343 axis = new WebInspector.Geometry.Vector(0, 0, -1); | 344 axis = new WebInspector.Geometry.Vector(0, 0, -1); |
| 344 angle = (this._mouseDownVector.x - mouseMoveVector.x)*WebInspector.S
ensorsView.ShiftDragOrientationSpeed; | 345 angle = (this._mouseDownVector.x - mouseMoveVector.x) * WebInspector
.SensorsView.ShiftDragOrientationSpeed; |
| 345 } else { | 346 } else { |
| 346 axis = WebInspector.Geometry.crossProduct(this._mouseDownVector, mou
seMoveVector); | 347 axis = WebInspector.Geometry.crossProduct(this._mouseDownVector, mou
seMoveVector); |
| 347 angle = WebInspector.Geometry.calculateAngle(this._mouseDownVector,
mouseMoveVector); | 348 angle = WebInspector.Geometry.calculateAngle(this._mouseDownVector,
mouseMoveVector); |
| 348 } | 349 } |
| 349 | 350 |
| 350 // The mouse movement vectors occur in the screen space, which is offset
by 90 degrees from | 351 // The mouse movement vectors occur in the screen space, which is offset
by 90 degrees from |
| 351 // the actual device orientation. | 352 // the actual device orientation. |
| 352 var currentMatrix = new WebKitCSSMatrix(); | 353 var currentMatrix = new WebKitCSSMatrix(); |
| 353 currentMatrix = currentMatrix | 354 currentMatrix = currentMatrix |
| 354 .rotate(-90, 0, 0) | 355 .rotate(-90, 0, 0) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 * @return {boolean} | 502 * @return {boolean} |
| 502 */ | 503 */ |
| 503 handleAction: function(context, actionId) | 504 handleAction: function(context, actionId) |
| 504 { | 505 { |
| 505 WebInspector.inspectorView.showViewInDrawer("sensors"); | 506 WebInspector.inspectorView.showViewInDrawer("sensors"); |
| 506 return true; | 507 return true; |
| 507 } | 508 } |
| 508 } | 509 } |
| 509 | 510 |
| 510 WebInspector.SensorsView.ShiftDragOrientationSpeed = 16; | 511 WebInspector.SensorsView.ShiftDragOrientationSpeed = 16; |
| OLD | NEW |