Skip to content

Commit 0949e59

Browse files
committed
r94
1 parent a645c2d commit 0949e59

File tree

6 files changed

+582
-405
lines changed

6 files changed

+582
-405
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Please also include a live example if possible. You can start from these templat
1919
##### Three.js version
2020

2121
- [ ] Dev
22-
- [ ] r93
22+
- [ ] r94
2323
- [ ] ...
2424

2525
##### Browser

build/three.js

Lines changed: 102 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185

186186
} );
187187

188-
var REVISION = '94dev';
188+
var REVISION = '94';
189189
var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
190190
var CullFaceNone = 0;
191191
var CullFaceBack = 1;
@@ -2436,19 +2436,21 @@
24362436

24372437
}
24382438

2439-
var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta );
2439+
var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
24402440

2441-
if ( Math.abs( sinHalfTheta ) < 0.001 ) {
2441+
if ( sqrSinHalfTheta <= Number.EPSILON ) {
24422442

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;
24472448

2448-
return this;
2449+
return this.normalize();
24492450

24502451
}
24512452

2453+
var sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
24522454
var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
24532455
var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
24542456
ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
@@ -24781,18 +24783,80 @@
2478124783
raycast: ( function () {
2478224784

2478324785
var intersectPoint = new Vector3();
24784-
var worldPosition = new Vector3();
2478524786
var worldScale = new Vector3();
24787+
var mvPosition = new Vector3();
2478624788

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 ) {
2478824798

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 ) {
2479124825

2479224826
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 );
2479424844

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+
}
2479624860

2479724861
var distance = raycaster.ray.origin.distanceTo( intersectPoint );
2479824862

@@ -39436,6 +39500,8 @@
3943639500

3943739501
}
3943839502

39503+
return this;
39504+
3943939505
},
3944039506

3944139507
getFilter: function () {
@@ -39461,6 +39527,8 @@
3946139527
this.gain.connect( this.filter );
3946239528
this.filter.connect( this.context.destination );
3946339529

39530+
return this;
39531+
3946439532
},
3946539533

3946639534
getMasterVolume: function () {
@@ -39473,6 +39541,8 @@
3947339541

3947439542
this.gain.gain.setTargetAtTime( value, this.context.currentTime, 0.01 );
3947539543

39544+
return this;
39545+
3947639546
},
3947739547

3947839548
updateMatrixWorld: ( function () {
@@ -39866,6 +39936,8 @@
3986639936

3986739937
this.panner.refDistance = value;
3986839938

39939+
return this;
39940+
3986939941
},
3987039942

3987139943
getRolloffFactor: function () {
@@ -39878,6 +39950,8 @@
3987839950

3987939951
this.panner.rolloffFactor = value;
3988039952

39953+
return this;
39954+
3988139955
},
3988239956

3988339957
getDistanceModel: function () {
@@ -39890,6 +39964,8 @@
3989039964

3989139965
this.panner.distanceModel = value;
3989239966

39967+
return this;
39968+
3989339969
},
3989439970

3989539971
getMaxDistance: function () {
@@ -39902,6 +39978,18 @@
3990239978

3990339979
this.panner.maxDistance = value;
3990439980

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+
3990539993
},
3990639994

3990739995
updateMatrixWorld: ( function () {

0 commit comments

Comments
 (0)