Skip to content

Commit fed6eea

Browse files
authored
OrbitControls: Added target distance check in change condition. (#26063)
1 parent 6c94900 commit fed6eea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/jsm/controls/OrbitControls.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class OrbitControls extends EventDispatcher {
165165

166166
const lastPosition = new Vector3();
167167
const lastQuaternion = new Quaternion();
168+
const lastTargetPosition = new Vector3();
168169

169170
const twoPI = 2 * Math.PI;
170171

@@ -278,12 +279,15 @@ class OrbitControls extends EventDispatcher {
278279

279280
if ( zoomChanged ||
280281
lastPosition.distanceToSquared( scope.object.position ) > EPS ||
281-
8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
282+
8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ||
283+
lastTargetPosition.distanceToSquared( scope.target ) > 0 ) {
282284

283285
scope.dispatchEvent( _changeEvent );
284286

285287
lastPosition.copy( scope.object.position );
286288
lastQuaternion.copy( scope.object.quaternion );
289+
lastTargetPosition.copy( scope.target );
290+
287291
zoomChanged = false;
288292

289293
return true;

0 commit comments

Comments
 (0)