|
@@ -5389,33 +5389,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 ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
|
|
|
- result.copy( point );
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 ) {
|
|
|
|
|
|
- box.set( this.center, this.center );
|
|
|
- box.expandByScalar( this.radius );
|
|
|
+ console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
|
|
|
+ target = new Box3();
|
|
|
|
|
|
- return box;
|
|
|
+ }
|
|
|
+
|
|
|
+ target.set( this.center, this.center );
|
|
|
+ target.expandByScalar( this.radius );
|
|
|
+
|
|
|
+ return target;
|
|
|
|
|
|
},
|
|
|
|
|
@@ -5553,11 +5563,16 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- projectPoint: function ( point, optionalTarget ) {
|
|
|
+ projectPoint: function ( point, target ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
+ if ( target === undefined ) {
|
|
|
|
|
|
- return result.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
|
|
|
+ console.warn( 'THREE.Plane: .projectPoint() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -5565,9 +5580,14 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
var v1 = new Vector3();
|
|
|
|
|
|
- return function intersectLine( line, optionalTarget ) {
|
|
|
+ return function intersectLine( line, target ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
+ if ( target === undefined ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Plane: .intersectLine() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
var direction = line.delta( v1 );
|
|
|
|
|
@@ -5578,7 +5598,7 @@ Object.assign( Plane.prototype, {
|
|
|
// line is coplanar, return origin
|
|
|
if ( this.distanceToPoint( line.start ) === 0 ) {
|
|
|
|
|
|
- return result.copy( line.start );
|
|
|
+ return target.copy( line.start );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -5595,7 +5615,7 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
- return result.copy( direction ).multiplyScalar( t ).add( line.start );
|
|
|
+ return target.copy( direction ).multiplyScalar( t ).add( line.start );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -5624,11 +5644,16 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- coplanarPoint: function ( optionalTarget ) {
|
|
|
+ coplanarPoint: function ( target ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
+ if ( target === undefined ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Plane: .coplanarPoint() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
|
|
|
- return result.copy( this.normal ).multiplyScalar( - this.constant );
|
|
|
+ }
|
|
|
+
|
|
|
+ return target.copy( this.normal ).multiplyScalar( - this.constant );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13028,11 +13053,16 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- at: function ( t, optionalTarget ) {
|
|
|
+ at: function ( t, target ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
+ if ( target === undefined ) {
|
|
|
|
|
|
- return result.copy( this.direction ).multiplyScalar( t ).add( this.origin );
|
|
|
+ console.warn( 'THREE.Ray: .at() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return target.copy( this.direction ).multiplyScalar( t ).add( this.origin );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13058,19 +13088,26 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
}(),
|
|
|
|
|
|
- closestPointToPoint: function ( point, optionalTarget ) {
|
|
|
+ closestPointToPoint: function ( point, target ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
- result.subVectors( point, this.origin );
|
|
|
- var directionDistance = result.dot( this.direction );
|
|
|
+ if ( target === undefined ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ target.subVectors( point, this.origin );
|
|
|
+
|
|
|
+ var directionDistance = target.dot( this.direction );
|
|
|
|
|
|
if ( directionDistance < 0 ) {
|
|
|
|
|
|
- return result.copy( this.origin );
|
|
|
+ return target.copy( this.origin );
|
|
|
|
|
|
}
|
|
|
|
|
|
- return result.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
|
|
|
+ return target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13235,7 +13272,7 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
var v1 = new Vector3();
|
|
|
|
|
|
- return function intersectSphere( sphere, optionalTarget ) {
|
|
|
+ return function intersectSphere( sphere, target ) {
|
|
|
|
|
|
v1.subVectors( sphere.center, this.origin );
|
|
|
var tca = v1.dot( this.direction );
|
|
@@ -13258,10 +13295,10 @@ Object.assign( Ray.prototype, {
|
|
|
// test to see if t0 is behind the ray:
|
|
|
// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,
|
|
|
// in order to always return an intersect point that is in front of the ray.
|
|
|
- if ( t0 < 0 ) return this.at( t1, optionalTarget );
|
|
|
+ if ( t0 < 0 ) return this.at( t1, target );
|
|
|
|
|
|
// else t0 is in front of the ray, so return the first collision point scaled by t0
|
|
|
- return this.at( t0, optionalTarget );
|
|
|
+ return this.at( t0, target );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -13300,7 +13337,7 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- intersectPlane: function ( plane, optionalTarget ) {
|
|
|
+ intersectPlane: function ( plane, target ) {
|
|
|
|
|
|
var t = this.distanceToPlane( plane );
|
|
|
|
|
@@ -13310,7 +13347,7 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
- return this.at( t, optionalTarget );
|
|
|
+ return this.at( t, target );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13340,7 +13377,7 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- intersectBox: function ( box, optionalTarget ) {
|
|
|
+ intersectBox: function ( box, target ) {
|
|
|
|
|
|
var tmin, tmax, tymin, tymax, tzmin, tzmax;
|
|
|
|
|
@@ -13405,7 +13442,7 @@ Object.assign( Ray.prototype, {
|
|
|
|
|
|
if ( tmax < 0 ) return null;
|
|
|
|
|
|
- return this.at( tmin >= 0 ? tmin : tmax, optionalTarget );
|
|
|
+ return this.at( tmin >= 0 ? tmin : tmax, target );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13429,7 +13466,7 @@ Object.assign( Ray.prototype, {
|
|
|
var edge2 = new Vector3();
|
|
|
var normal = new Vector3();
|
|
|
|
|
|
- return function intersectTriangle( a, b, c, backfaceCulling, optionalTarget ) {
|
|
|
+ return function intersectTriangle( a, b, c, backfaceCulling, target ) {
|
|
|
|
|
|
// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
|
|
|
|
|
@@ -13498,7 +13535,7 @@ Object.assign( Ray.prototype, {
|
|
|
}
|
|
|
|
|
|
// Ray intersects triangle.
|
|
|
- return this.at( QdN / DdN, optionalTarget );
|
|
|
+ return this.at( QdN / DdN, target );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -13558,17 +13595,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 ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
- return result.subVectors( this.end, this.start );
|
|
|
+ if ( target === undefined ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Line3: .delta() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return target.subVectors( this.end, this.start );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13584,11 +13633,16 @@ Object.assign( Line3.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- at: function ( t, optionalTarget ) {
|
|
|
+ at: function ( t, target ) {
|
|
|
|
|
|
- var result = optionalTarget || new Vector3();
|
|
|
+ if ( target === undefined ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Line3: .at() 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 );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -13619,13 +13673,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 ) {
|
|
|
|
|
|
- return this.delta( result ).multiplyScalar( t ).add( this.start );
|
|
|
+ console.warn( 'THREE.Line3: .closestPointToPoint() target is now required' );
|
|
|
+ target = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.delta( target ).multiplyScalar( t ).add( this.start );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -19604,9 +19663,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
_gl.generateMipmap( target );
|
|
|
|
|
|
+ // We assume images for cube map have the same size.
|
|
|
var image = Array.isArray( texture.image ) ? texture.image[ 0 ] : texture.image;
|
|
|
var textureProperties = properties.get( texture );
|
|
|
- textureProperties.__maxMipLevel = Math.max( Math.log2( Math.max( image.width, image.height ) ), textureProperties.__maxMipLevel );
|
|
|
+ textureProperties.__maxMipLevel = Math.log2( Math.max( image.width, image.height ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -37213,6 +37273,9 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
object = new OrthographicCamera( data.left, data.right, data.top, data.bottom, data.near, data.far );
|
|
|
|
|
|
+ if ( data.zoom !== undefined ) object.zoom = data.zoom;
|
|
|
+ if ( data.view !== undefined ) object.view = Object.assign( {}, data.view );
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case 'AmbientLight':
|