Преглед изворни кода

Change formatting for TransformControl zoom fix

Vladimir Jigouline пре 5 година
родитељ
комит
7757590f3c
2 измењених фајлова са 4 додато и 10 уклоњено
  1. 2 5
      examples/js/controls/TransformControls.js
  2. 2 5
      examples/jsm/controls/TransformControls.js

+ 2 - 5
examples/js/controls/TransformControls.js

@@ -1165,11 +1165,8 @@ THREE.TransformControlsGizmo = function () {
 			handle.rotation.set( 0, 0, 0 );
 			handle.rotation.set( 0, 0, 0 );
 			handle.position.copy( this.worldPosition );
 			handle.position.copy( this.worldPosition );
 
 
-			var eyeDistance = this.worldPosition.distanceTo( this.cameraPosition );
-			// Orthographic camera zoom doesn't depend on eyeDistance, but on camera zoom factor.
-			if (this.camera.type == "OrthographicCamera") {
-				eyeDistance = 1000 / this.camera.zoom;
-			}
+			var eyeDistance = this.camera.isOrthographicCamera ? 1000 / this.camera.zoom : 
+				this.worldPosition.distanceTo( this.cameraPosition );			
 			handle.scale.set( 1, 1, 1 ).multiplyScalar( eyeDistance * this.size / 7 );
 			handle.scale.set( 1, 1, 1 ).multiplyScalar( eyeDistance * this.size / 7 );
 
 
 			// TODO: simplify helpers and consider decoupling from gizmo
 			// TODO: simplify helpers and consider decoupling from gizmo

+ 2 - 5
examples/jsm/controls/TransformControls.js

@@ -1188,11 +1188,8 @@ var TransformControlsGizmo = function () {
 			handle.rotation.set( 0, 0, 0 );
 			handle.rotation.set( 0, 0, 0 );
 			handle.position.copy( this.worldPosition );
 			handle.position.copy( this.worldPosition );
 
 
-			var eyeDistance = this.worldPosition.distanceTo( this.cameraPosition );
-			// Orthographic camera zoom doesn't depend on eyeDistance, but on camera zoom factor.
-			if (this.camera.type == "OrthographicCamera") {
-				eyeDistance = 1000 / this.camera.zoom;
-			}
+			var eyeDistance = this.camera.isOrthographicCamera ? 1000 / this.camera.zoom : 
+				this.worldPosition.distanceTo( this.cameraPosition );			
 			handle.scale.set( 1, 1, 1 ).multiplyScalar( eyeDistance * this.size / 7 );
 			handle.scale.set( 1, 1, 1 ).multiplyScalar( eyeDistance * this.size / 7 );
 
 
 			// TODO: simplify helpers and consider decoupling from gizmo
 			// TODO: simplify helpers and consider decoupling from gizmo