Three.js: fix rotate and pan on HiDPI devices.
parent
26c8cdcb37
commit
6f9358ae95
|
@ -155,8 +155,8 @@ SolvespaceControls = function(object, domElement) {
|
|||
|
||||
switch (event.button) {
|
||||
case 0:
|
||||
_rotateCur.set(event.screenX / window.devicePixelRatio,
|
||||
event.screenY / window.devicePixelRatio);
|
||||
_rotateCur.set(event.screenX,
|
||||
event.screenY);
|
||||
_rotatePrev.copy(_rotateCur);
|
||||
document.addEventListener('mousemove', mousemove_rotate, false);
|
||||
document.addEventListener('mouseup', mouseup, false);
|
||||
|
@ -184,8 +184,8 @@ SolvespaceControls = function(object, domElement) {
|
|||
}
|
||||
|
||||
function mousemove_rotate(event) {
|
||||
_rotateCur.set(event.screenX / window.devicePixelRatio,
|
||||
event.screenY / window.devicePixelRatio);
|
||||
_rotateCur.set(event.screenX,
|
||||
event.screenY);
|
||||
var diff = new THREE.Vector2().subVectors(_rotateCur, _rotatePrev)
|
||||
.multiplyScalar(1 / object.zoomScale);
|
||||
object.rotate(-0.3 * Math.PI / 180 * diff.x * object.zoomScale,
|
||||
|
@ -199,7 +199,7 @@ SolvespaceControls = function(object, domElement) {
|
|||
_offsetCur.set(event.screenX / window.devicePixelRatio,
|
||||
event.screenY / window.devicePixelRatio);
|
||||
var diff = new THREE.Vector2().subVectors(_offsetCur, _offsetPrev)
|
||||
.multiplyScalar(1 / object.zoomScale);
|
||||
.multiplyScalar(window.devicePixelRatio / object.zoomScale);
|
||||
object.offsetProj(diff.x, -diff.y);
|
||||
_changed = true;
|
||||
_offsetPrev.copy(_offsetCur);
|
||||
|
@ -507,3 +507,4 @@ solvespace = function(obj, params) {
|
|||
return new THREE.LineSegments(geometry, material);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue