Skip to content

Commit

Permalink
TransformControls: Simplified intersectObjectWithRay.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Apr 25, 2020
1 parent 22749d1 commit 327b63a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions examples/js/controls/TransformControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,23 @@ THREE.TransformControls = function ( camera, domElement ) {

var raycaster = new THREE.Raycaster();

var intersectObjectWithRay = function ( object, raycaster, includeInvisible ) {
function intersectObjectWithRay( object, raycaster, includeInvisible ) {

var allIntersections = raycaster.intersectObject( object, true );

var intersection = false;

for ( var i = allIntersections.length; i --; ) {

if ( allIntersections[ i ].object.visible || includeInvisible ) {

intersection = allIntersections[ i ];

continue;
return allIntersections[ i ];

}

}

return intersection;
return false;

};
}

var _tempVector = new THREE.Vector3();
var _tempVector2 = new THREE.Vector3();
Expand Down
12 changes: 4 additions & 8 deletions examples/jsm/controls/TransformControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,23 @@ var TransformControls = function ( camera, domElement ) {

var raycaster = new Raycaster();

var intersectObjectWithRay = function ( object, raycaster, includeInvisible ) {
function intersectObjectWithRay( object, raycaster, includeInvisible ) {

var allIntersections = raycaster.intersectObject( object, true );

var intersection = false;

for ( var i = allIntersections.length; i --; ) {

if ( allIntersections[ i ].object.visible || includeInvisible ) {

intersection = allIntersections[ i ];

continue;
return allIntersections[ i ];

}

}

return intersection;
return false;

};
}

var _tempVector = new Vector3();
var _tempVector2 = new Vector3();
Expand Down

0 comments on commit 327b63a

Please sign in to comment.