I downloaded and brought out the object, connected the control using trackballcontrols.

It is necessary for me that, when manipulating with a mouse, an object spun only along the X axis, and all other axes, zoom, object transfer using PCM were disabled.

How to do it? Perhaps in trackballcontrols, you can somehow change the methods for this. Thank!

controls = new THREE.TrackballControls( camera ); controls.rotateSpeed = 10; controls.noZoom = true; controls.noPan = true; 
  • it is easiest to turn the hands without any libraries - ampawd
  • would be grateful if you describe the approximate logic. the object needs to be rotated with the mouse along the X axis - Oslo

1 answer 1

Found a solution that is easily customized.

https://jsfiddle.net/MadLittleMods/n6u6asza/

 var isDragging = false; 

var previousMousePosition = {x: 0, y: 0}; $ (renderer.domElement) .on ('mousedown', function (e) {isDragging = true;}) .on ('mousemove', function (e) {//console.log(e); var deltaMove = {x : e.offsetX-previousMousePosition.x, y: e.offsetY-previousMousePosition.y};

 if(isDragging) { var deltaRotationQuaternion = new three.Quaternion() .setFromEuler(new three.Euler( toRadians(deltaMove.y * 0), toRadians(deltaMove.x * 1), 0, 'XYZ' )); cube.quaternion.multiplyQuaternions(deltaRotationQuaternion, cube.quaternion); } previousMousePosition = { x: e.offsetX, y: e.offsetY };}); $(document).on('mouseup', function(e) { isDragging = false;});