|
185 | 185 |
|
186 | 186 | } ); |
187 | 187 |
|
188 | | - var REVISION = '94dev'; |
| 188 | + var REVISION = '94'; |
189 | 189 | var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 }; |
190 | 190 | var CullFaceNone = 0; |
191 | 191 | var CullFaceBack = 1; |
|
2436 | 2436 |
|
2437 | 2437 | } |
2438 | 2438 |
|
2439 | | - var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta ); |
| 2439 | + var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; |
2440 | 2440 |
|
2441 | | - if ( Math.abs( sinHalfTheta ) < 0.001 ) { |
| 2441 | + if ( sqrSinHalfTheta <= Number.EPSILON ) { |
2442 | 2442 |
|
2443 | | - this._w = 0.5 * ( w + this._w ); |
2444 | | - this._x = 0.5 * ( x + this._x ); |
2445 | | - this._y = 0.5 * ( y + this._y ); |
2446 | | - this._z = 0.5 * ( z + this._z ); |
| 2443 | + var s = 1 - t; |
| 2444 | + this._w = s * w + t * this._w; |
| 2445 | + this._x = s * x + t * this._x; |
| 2446 | + this._y = s * y + t * this._y; |
| 2447 | + this._z = s * z + t * this._z; |
2447 | 2448 |
|
2448 | | - return this; |
| 2449 | + return this.normalize(); |
2449 | 2450 |
|
2450 | 2451 | } |
2451 | 2452 |
|
| 2453 | + var sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); |
2452 | 2454 | var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); |
2453 | 2455 | var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, |
2454 | 2456 | ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; |
@@ -24781,18 +24783,80 @@ |
24781 | 24783 | raycast: ( function () { |
24782 | 24784 |
|
24783 | 24785 | var intersectPoint = new Vector3(); |
24784 | | - var worldPosition = new Vector3(); |
24785 | 24786 | var worldScale = new Vector3(); |
| 24787 | + var mvPosition = new Vector3(); |
24786 | 24788 |
|
24787 | | - return function raycast( raycaster, intersects ) { |
| 24789 | + var alignedPosition = new Vector2(); |
| 24790 | + var rotatedPosition = new Vector2(); |
| 24791 | + var viewWorldMatrix = new Matrix4(); |
| 24792 | + |
| 24793 | + var vA = new Vector3(); |
| 24794 | + var vB = new Vector3(); |
| 24795 | + var vC = new Vector3(); |
| 24796 | + |
| 24797 | + function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) { |
24788 | 24798 |
|
24789 | | - worldPosition.setFromMatrixPosition( this.matrixWorld ); |
24790 | | - raycaster.ray.closestPointToPoint( worldPosition, intersectPoint ); |
| 24799 | + // compute position in camera space |
| 24800 | + alignedPosition.subVectors( vertexPosition, center ).addScalar( 0.5 ).multiply( scale ); |
| 24801 | + |
| 24802 | + // to check if rotation is not zero |
| 24803 | + if ( sin !== undefined ) { |
| 24804 | + |
| 24805 | + rotatedPosition.x = ( cos * alignedPosition.x ) - ( sin * alignedPosition.y ); |
| 24806 | + rotatedPosition.y = ( sin * alignedPosition.x ) + ( cos * alignedPosition.y ); |
| 24807 | + |
| 24808 | + } else { |
| 24809 | + |
| 24810 | + rotatedPosition.copy( alignedPosition ); |
| 24811 | + |
| 24812 | + } |
| 24813 | + |
| 24814 | + |
| 24815 | + vertexPosition.copy( mvPosition ); |
| 24816 | + vertexPosition.x += rotatedPosition.x; |
| 24817 | + vertexPosition.y += rotatedPosition.y; |
| 24818 | + |
| 24819 | + // transform to world space |
| 24820 | + vertexPosition.applyMatrix4( viewWorldMatrix ); |
| 24821 | + |
| 24822 | + } |
| 24823 | + |
| 24824 | + return function raycast( raycaster, intersects ) { |
24791 | 24825 |
|
24792 | 24826 | worldScale.setFromMatrixScale( this.matrixWorld ); |
24793 | | - var guessSizeSq = worldScale.x * worldScale.y / 4; |
| 24827 | + viewWorldMatrix.getInverse( this.modelViewMatrix ).premultiply( this.matrixWorld ); |
| 24828 | + mvPosition.setFromMatrixPosition( this.modelViewMatrix ); |
| 24829 | + |
| 24830 | + var rotation = this.material.rotation; |
| 24831 | + var sin, cos; |
| 24832 | + if ( rotation !== 0 ) { |
| 24833 | + |
| 24834 | + cos = Math.cos( rotation ); |
| 24835 | + sin = Math.sin( rotation ); |
| 24836 | + |
| 24837 | + } |
| 24838 | + |
| 24839 | + var center = this.center; |
| 24840 | + |
| 24841 | + transformVertex( vA.set( - 0.5, - 0.5, 0 ), mvPosition, center, worldScale, sin, cos ); |
| 24842 | + transformVertex( vB.set( 0.5, - 0.5, 0 ), mvPosition, center, worldScale, sin, cos ); |
| 24843 | + transformVertex( vC.set( 0.5, 0.5, 0 ), mvPosition, center, worldScale, sin, cos ); |
24794 | 24844 |
|
24795 | | - if ( worldPosition.distanceToSquared( intersectPoint ) > guessSizeSq ) return; |
| 24845 | + // check first triangle |
| 24846 | + var intersect = raycaster.ray.intersectTriangle( vA, vB, vC, false, intersectPoint ); |
| 24847 | + |
| 24848 | + if ( intersect === null ) { |
| 24849 | + |
| 24850 | + // check second triangle |
| 24851 | + transformVertex( vB.set( - 0.5, 0.5, 0 ), mvPosition, center, worldScale, sin, cos ); |
| 24852 | + intersect = raycaster.ray.intersectTriangle( vA, vC, vB, false, intersectPoint ); |
| 24853 | + if ( intersect === null ) { |
| 24854 | + |
| 24855 | + return; |
| 24856 | + |
| 24857 | + } |
| 24858 | + |
| 24859 | + } |
24796 | 24860 |
|
24797 | 24861 | var distance = raycaster.ray.origin.distanceTo( intersectPoint ); |
24798 | 24862 |
|
|
39436 | 39500 |
|
39437 | 39501 | } |
39438 | 39502 |
|
| 39503 | + return this; |
| 39504 | + |
39439 | 39505 | }, |
39440 | 39506 |
|
39441 | 39507 | getFilter: function () { |
|
39461 | 39527 | this.gain.connect( this.filter ); |
39462 | 39528 | this.filter.connect( this.context.destination ); |
39463 | 39529 |
|
| 39530 | + return this; |
| 39531 | + |
39464 | 39532 | }, |
39465 | 39533 |
|
39466 | 39534 | getMasterVolume: function () { |
|
39473 | 39541 |
|
39474 | 39542 | this.gain.gain.setTargetAtTime( value, this.context.currentTime, 0.01 ); |
39475 | 39543 |
|
| 39544 | + return this; |
| 39545 | + |
39476 | 39546 | }, |
39477 | 39547 |
|
39478 | 39548 | updateMatrixWorld: ( function () { |
|
39866 | 39936 |
|
39867 | 39937 | this.panner.refDistance = value; |
39868 | 39938 |
|
| 39939 | + return this; |
| 39940 | + |
39869 | 39941 | }, |
39870 | 39942 |
|
39871 | 39943 | getRolloffFactor: function () { |
|
39878 | 39950 |
|
39879 | 39951 | this.panner.rolloffFactor = value; |
39880 | 39952 |
|
| 39953 | + return this; |
| 39954 | + |
39881 | 39955 | }, |
39882 | 39956 |
|
39883 | 39957 | getDistanceModel: function () { |
|
39890 | 39964 |
|
39891 | 39965 | this.panner.distanceModel = value; |
39892 | 39966 |
|
| 39967 | + return this; |
| 39968 | + |
39893 | 39969 | }, |
39894 | 39970 |
|
39895 | 39971 | getMaxDistance: function () { |
|
39902 | 39978 |
|
39903 | 39979 | this.panner.maxDistance = value; |
39904 | 39980 |
|
| 39981 | + return this; |
| 39982 | + |
| 39983 | + }, |
| 39984 | + |
| 39985 | + setDirectionalCone: function ( coneInnerAngle, coneOuterAngle, coneOuterGain ) { |
| 39986 | + |
| 39987 | + this.panner.coneInnerAngle = coneInnerAngle; |
| 39988 | + this.panner.coneOuterAngle = coneOuterAngle; |
| 39989 | + this.panner.coneOuterGain = coneOuterGain; |
| 39990 | + |
| 39991 | + return this; |
| 39992 | + |
39905 | 39993 | }, |
39906 | 39994 |
|
39907 | 39995 | updateMatrixWorld: ( function () { |
|
0 commit comments