Controls always set _change flag to true


the code below in TrackBallControls or OrthgraphicTrackBallControls may lead to endless rendering in some project. Is this a bug?

this.panCamera = ( function () {

		var mouseChange = new THREE.Vector2(),
			objectUp = new THREE.Vector3(),
			pan = new THREE.Vector3();

		return function panCamera() {

			mouseChange.copy( _panEnd ).sub( _panStart );

             // here, this value may never be zero.  why not use a numerical small value? like:
             // if( mouseChange.lengthSq() < 1e-9)
			if ( mouseChange.lengthSq() ) { 

				// Scale movement to keep clicked/dragged position under cursor
				var scale_x = ( _this.object.right - _this.object.left ) / _this.object.zoom;
				var scale_y = ( - _this.object.bottom ) / _this.object.zoom;
				mouseChange.x *= scale_x;
				mouseChange.y *= scale_y;

What exactly do you mean with “endless rendering”? TrackballControls already uses a check to avoid firing change events if the displacement (distance between last and new position) is very small, see:

Besides, I’m afraid “some projects” is too vague for a useful information. Please share a live example that demonstrates the issue.

1 Like

This is my fault . I changed some original code in TrackballControls.js by accident. sorry for my stupid question…:wink: