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

Merge pull request #13510 from WestLangley/dev-optTgt_3

Remove optionalTarget - part 3
......@@ -42,11 +42,10 @@
<h3>[method:Line3 applyMatrix4]( [param:Matrix4 matrix] )</h3>
<div>Applies a matrix transform to the line segment.</div>
<h3>[method:Vector3 at]( [param:Float t], [param:Vector3 optionalTarget] )</h3>
<h3>[method:Vector3 at]( [param:Float t], [param:Vector3 target] )</h3>
<div>
[page:Float t] - Use values 0-1 to return a position along the line segment. <br />
[page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
otherwise a new [page:Vector3] will be created.<br /><br />
[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
Returns a vector at a certain position along the line. When [page:Float t] = 0, it returns the start vector,
and when [page:Float t] = 1 it returns the end vector.<br />
......@@ -55,12 +54,11 @@
<h3>[method:Line3 clone]()</h3>
<div>Returns a new [page:Line3] with the same [page:.start start] and [page:.end end] vectors as this one.</div>
<h3>[method:Vector3 closestPointToPoint]( [param:Vector3 point], [param:Boolean clampToLine], [param:Vector3 optionalTarget] )</h3>
<h3>[method:Vector3 closestPointToPoint]( [param:Vector3 point], [param:Boolean clampToLine], [param:Vector3 target] )</h3>
<div>
[page:Vector3 point] - return the closest point on the line to this point.<br />
[page:Boolean clampToLine] - whether to clamp the returned value to the line segment.<br />
[page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
otherwise a new [page:Vector3] will be created.<br /><br />
[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
Returns the closets point on the line. If [page:Boolean clampToLine] is true, then the returned value will be
clamped to the line segment.
......@@ -78,10 +76,9 @@
<h3>[method:Line3 copy]( [param:Line3 line] )</h3>
<div>Copies the passed line's [page:.start start] and [page:.end end] vectors to this line.</div>
<h3>[method:Vector3 delta]( [param:Vector3 optionalTarget] )</h3>
<h3>[method:Vector3 delta]( [param:Vector3 target] )</h3>
<div>
[page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
otherwise a new [page:Vector3] will be created.<br /><br />
[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
Returns the delta vector of the line segment ( [page:.end end] vector minus the [page:.start start] vector).
</div>
......@@ -104,10 +101,9 @@
Returns true if both line's [page:.start start] and [page:.end en] points are equal.
</div>
<h3>[method:Vector3 getCenter]( [param:Vector3 optionalTarget] )</h3>
<h3>[method:Vector3 getCenter]( [param:Vector3 target] )</h3>
<div>
[page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
otherwise a new [page:Vector3] will be created.<br /><br />
[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
Returns the center of the line segment.
</div>
......
......@@ -41,11 +41,10 @@
Transforms this sphere with the provided [page:Matrix4].
</div>
<h3>[method:Vector3 clampPoint]( [param:Vector3 point], [param:Vector3 optionalTarget] )</h3>
<h3>[method:Vector3 clampPoint]( [param:Vector3 point], [param:Vector3 target] )</h3>
<div>
[page:Vector3 point] - [page:Vector3] The point to clamp.<br />
[page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
otherwise a new [page:Vector3] will be created.<br /><br />
[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
Clamps a point within the sphere. If the point is is outside the sphere, it will clamp it to the
closets point on the edge of the sphere. Points already inside the sphere will not be affected.
......@@ -82,11 +81,11 @@
Checks to see if the two spheres' centers and radii are equal.
</div>
<h3>[method:Box3 getBoundingBox]( [param:Box3 optionalTarget] )</h3>
<h3>[method:Box3 getBoundingBox]( [param:Box3 target] )</h3>
<div>
[page:Box3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Box3], otherwise a new [page:Box3] will be created.<br /><br />
[page:Box3 target] — the result will be copied into this Box3.<br /><br />
Returns a[link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Box] for the sphere.
Returns a[link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Box] for the sphere.
</div>
<h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
......
......@@ -38,17 +38,29 @@ Object.assign( Line3.prototype, {
},
getCenter: function ( optionalTarget ) {
getCenter: function ( target ) {
var result = optionalTarget || new Vector3();
return result.addVectors( this.start, this.end ).multiplyScalar( 0.5 );
if ( target === undefined ) {
console.warn( 'THREE.Line3: .getCenter() target is now required' );
target = new Vector3();
}
return target.addVectors( this.start, this.end ).multiplyScalar( 0.5 );
},
delta: function ( optionalTarget ) {
delta: function ( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Line3: .delta() target is now required' );
target = new Vector3();
var result = optionalTarget || new Vector3();
return result.subVectors( this.end, this.start );
}
return target.subVectors( this.end, this.start );
},
......@@ -64,11 +76,16 @@ Object.assign( Line3.prototype, {
},
at: function ( t, optionalTarget ) {
at: function ( t, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Line3: .at() target is now required' );
target = new Vector3();
var result = optionalTarget || new Vector3();
}
return this.delta( result ).multiplyScalar( t ).add( this.start );
return this.delta( target ).multiplyScalar( t ).add( this.start );
},
......@@ -99,13 +116,18 @@ Object.assign( Line3.prototype, {
}(),
closestPointToPoint: function ( point, clampToLine, optionalTarget ) {
closestPointToPoint: function ( point, clampToLine, target ) {
var t = this.closestPointToPointParameter( point, clampToLine );
var result = optionalTarget || new Vector3();
if ( target === undefined ) {
console.warn( 'THREE.Line3: .closestPointToPoint() target is now required' );
target = new Vector3();
}
return this.delta( result ).multiplyScalar( t ).add( this.start );
return this.delta( target ).multiplyScalar( t ).add( this.start );
},
......
......@@ -111,33 +111,43 @@ Object.assign( Sphere.prototype, {
},
clampPoint: function ( point, optionalTarget ) {
clampPoint: function ( point, target ) {
var deltaLengthSq = this.center.distanceToSquared( point );
var result = optionalTarget || new Vector3();
if ( target === undefined ) {
result.copy( point );
console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
target = new Vector3();
}
target.copy( point );
if ( deltaLengthSq > ( this.radius * this.radius ) ) {
result.sub( this.center ).normalize();
result.multiplyScalar( this.radius ).add( this.center );
target.sub( this.center ).normalize();
target.multiplyScalar( this.radius ).add( this.center );
}
return result;
return target;
},
getBoundingBox: function ( optionalTarget ) {
getBoundingBox: function ( target ) {
var box = optionalTarget || new Box3();
if ( target === undefined ) {
console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
target = new Box3();
}
box.set( this.center, this.center );
box.expandByScalar( this.radius );
target.set( this.center, this.center );
target.expandByScalar( this.radius );
return box;
return target;
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册