未验证 提交 96422181 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #12520 from maccesch/dev

fixed line precision raycasting outside the bounding sphere of Line
......@@ -101,7 +101,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
return function raycast( raycaster, intersects ) {
var precision = raycaster.linePrecision;
var precisionSq = precision * precision;
var geometry = this.geometry;
var matrixWorld = this.matrixWorld;
......@@ -112,6 +111,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
sphere.copy( geometry.boundingSphere );
sphere.applyMatrix4( matrixWorld );
sphere.radius += precision;
if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
......@@ -120,6 +120,9 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
inverseMatrix.getInverse( matrixWorld );
ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
var localPrecision = precision / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
var localPrecisionSq = localPrecision * localPrecision;
var vStart = new Vector3();
var vEnd = new Vector3();
var interSegment = new Vector3();
......@@ -146,7 +149,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
if ( distSq > precisionSq ) continue;
if ( distSq > localPrecisionSq ) continue;
interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
......@@ -178,7 +181,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
if ( distSq > precisionSq ) continue;
if ( distSq > localPrecisionSq ) continue;
interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
......@@ -212,7 +215,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
var distSq = ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
if ( distSq > precisionSq ) continue;
if ( distSq > localPrecisionSq ) continue;
interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册