未验证 提交 46485726 编写于 作者: M Michael Herzog 提交者: GitHub

Core: Remove checks for mandatory target parameter. (#21990)

上级 2272eaec
import { Matrix4 } from '../math/Matrix4.js';
import { Object3D } from '../core/Object3D.js';
import { Vector3 } from '../math/Vector3.js';
class Camera extends Object3D {
......@@ -32,13 +31,6 @@ class Camera extends Object3D {
getWorldDirection( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Camera: .getWorldDirection() target is now required' );
target = new Vector3();
}
this.updateWorldMatrix( true, false );
const e = this.matrixWorld.elements;
......
......@@ -461,13 +461,6 @@ class Object3D extends EventDispatcher {
getWorldPosition( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Object3D: .getWorldPosition() target is now required' );
target = new Vector3();
}
this.updateWorldMatrix( true, false );
return target.setFromMatrixPosition( this.matrixWorld );
......@@ -476,13 +469,6 @@ class Object3D extends EventDispatcher {
getWorldQuaternion( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
target = new Quaternion();
}
this.updateWorldMatrix( true, false );
this.matrixWorld.decompose( _position, target, _scale );
......@@ -493,13 +479,6 @@ class Object3D extends EventDispatcher {
getWorldScale( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Object3D: .getWorldScale() target is now required' );
target = new Vector3();
}
this.updateWorldMatrix( true, false );
this.matrixWorld.decompose( _position, _quaternion, target );
......@@ -510,13 +489,6 @@ class Object3D extends EventDispatcher {
getWorldDirection( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Object3D: .getWorldDirection() target is now required' );
target = new Vector3();
}
this.updateWorldMatrix( true, false );
const e = this.matrixWorld.elements;
......
......@@ -78,26 +78,12 @@ class Box2 {
getCenter( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Box2: .getCenter() target is now required' );
target = new Vector2();
}
return this.isEmpty() ? target.set( 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
}
getSize( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Box2: .getSize() target is now required' );
target = new Vector2();
}
return this.isEmpty() ? target.set( 0, 0 ) : target.subVectors( this.max, this.min );
}
......@@ -148,13 +134,6 @@ class Box2 {
// This can potentially have a divide by zero if the box
// has a size dimension of 0.
if ( target === undefined ) {
console.warn( 'THREE.Box2: .getParameter() target is now required' );
target = new Vector2();
}
return target.set(
( point.x - this.min.x ) / ( this.max.x - this.min.x ),
( point.y - this.min.y ) / ( this.max.y - this.min.y )
......@@ -173,13 +152,6 @@ class Box2 {
clampPoint( point, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Box2: .clampPoint() target is now required' );
target = new Vector2();
}
return target.copy( point ).clamp( this.min, this.max );
}
......
......@@ -151,26 +151,12 @@ class Box3 {
getCenter( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Box3: .getCenter() target is now required' );
target = new Vector3();
}
return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
}
getSize( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Box3: .getSize() target is now required' );
target = new Vector3();
}
return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
}
......@@ -259,13 +245,6 @@ class Box3 {
// This can potentially have a divide by zero if the box
// has a size dimension of 0.
if ( target === undefined ) {
console.warn( 'THREE.Box3: .getParameter() target is now required' );
target = new Vector3();
}
return target.set(
( point.x - this.min.x ) / ( this.max.x - this.min.x ),
( point.y - this.min.y ) / ( this.max.y - this.min.y ),
......@@ -395,13 +374,6 @@ class Box3 {
clampPoint( point, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Box3: .clampPoint() target is now required' );
target = new Vector3();
}
return target.copy( point ).clamp( this.min, this.max );
}
......@@ -416,13 +388,6 @@ class Box3 {
getBoundingSphere( target ) {
if ( target === undefined ) {
console.error( 'THREE.Box3: .getBoundingSphere() target is now required' );
//target = new Sphere(); // removed to avoid cyclic dependency
}
this.getCenter( target.center );
target.radius = this.getSize( _vector ).length() * 0.5;
......
......@@ -388,13 +388,6 @@ class Color {
// h,s,l ranges are in 0.0 - 1.0
if ( target === undefined ) {
console.warn( 'THREE.Color: .getHSL() target is now required' );
target = { h: 0, s: 0, l: 0 };
}
const r = this.r, g = this.g, b = this.b;
const max = Math.max( r, g, b );
......
......@@ -33,26 +33,12 @@ class Line3 {
getCenter( target ) {
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( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Line3: .delta() target is now required' );
target = new Vector3();
}
return target.subVectors( this.end, this.start );
}
......@@ -71,13 +57,6 @@ class Line3 {
at( t, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Line3: .at() target is now required' );
target = new Vector3();
}
return this.delta( target ).multiplyScalar( t ).add( this.start );
}
......@@ -106,13 +85,6 @@ class Line3 {
const t = this.closestPointToPointParameter( point, clampToLine );
if ( target === undefined ) {
console.warn( 'THREE.Line3: .closestPointToPoint() target is now required' );
target = new Vector3();
}
return this.delta( target ).multiplyScalar( t ).add( this.start );
}
......
......@@ -99,26 +99,12 @@ class Plane {
projectPoint( point, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Plane: .projectPoint() target is now required' );
target = new Vector3();
}
return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
}
intersectLine( line, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Plane: .intersectLine() target is now required' );
target = new Vector3();
}
const direction = line.delta( _vector1 );
const denominator = this.normal.dot( direction );
......@@ -174,13 +160,6 @@ class Plane {
coplanarPoint( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Plane: .coplanarPoint() target is now required' );
target = new Vector3();
}
return target.copy( this.normal ).multiplyScalar( - this.constant );
}
......
......@@ -38,13 +38,6 @@ class Ray {
at( t, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Ray: .at() target is now required' );
target = new Vector3();
}
return target.copy( this.direction ).multiplyScalar( t ).add( this.origin );
}
......@@ -67,13 +60,6 @@ class Ray {
closestPointToPoint( point, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );
target = new Vector3();
}
target.subVectors( point, this.origin );
const directionDistance = target.dot( this.direction );
......
......@@ -112,13 +112,6 @@ class Sphere {
const deltaLengthSq = this.center.distanceToSquared( point );
if ( target === undefined ) {
console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
target = new Vector3();
}
target.copy( point );
if ( deltaLengthSq > ( this.radius * this.radius ) ) {
......@@ -134,13 +127,6 @@ class Sphere {
getBoundingBox( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
target = new Box3();
}
if ( this.isEmpty() ) {
// Empty sphere produces empty bounding box
......
import { Vector3 } from './Vector3.js';
import { Plane } from './Plane.js';
const _v0 = /*@__PURE__*/ new Vector3();
const _v1 = /*@__PURE__*/ new Vector3();
......@@ -25,13 +24,6 @@ class Triangle {
static getNormal( a, b, c, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Triangle: .getNormal() target is now required' );
target = new Vector3();
}
target.subVectors( c, b );
_v0.subVectors( a, b );
target.cross( _v0 );
......@@ -63,13 +55,6 @@ class Triangle {
const denom = ( dot00 * dot11 - dot01 * dot01 );
if ( target === undefined ) {
console.warn( 'THREE.Triangle: .getBarycoord() target is now required' );
target = new Vector3();
}
// collinear or singular triangle
if ( denom === 0 ) {
......@@ -166,13 +151,6 @@ class Triangle {
getMidpoint( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Triangle: .getMidpoint() target is now required' );
target = new Vector3();
}
return target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );
}
......@@ -185,13 +163,6 @@ class Triangle {
getPlane( target ) {
if ( target === undefined ) {
console.warn( 'THREE.Triangle: .getPlane() target is now required' );
target = new Plane();
}
return target.setFromCoplanarPoints( this.a, this.b, this.c );
}
......@@ -228,13 +199,6 @@ class Triangle {
closestPointToPoint( p, target ) {
if ( target === undefined ) {
console.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );
target = new Vector3();
}
const a = this.a, b = this.b, c = this.c;
let v, w;
......
......@@ -14,10 +14,8 @@ import {
} from '../constants.js';
import { Frustum } from '../math/Frustum.js';
import { Matrix4 } from '../math/Matrix4.js';
import { Vector2 } from '../math/Vector2.js';
import { Vector3 } from '../math/Vector3.js';
import { Vector4 } from '../math/Vector4.js';
import { Color } from '../math/Color.js';
import { WebGLAnimation } from './webgl/WebGLAnimation.js';
import { WebGLAttributes } from './webgl/WebGLAttributes.js';
import { WebGLBackground } from './webgl/WebGLBackground.js';
......@@ -375,14 +373,6 @@ function WebGLRenderer( parameters = {} ) {
this.getSize = function ( target ) {
if ( target === undefined ) {
console.warn( 'WebGLRenderer: .getsize() now requires a Vector2 as an argument' );
target = new Vector2();
}
return target.set( _width, _height );
};
......@@ -415,14 +405,6 @@ function WebGLRenderer( parameters = {} ) {
this.getDrawingBufferSize = function ( target ) {
if ( target === undefined ) {
console.warn( 'WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument' );
target = new Vector2();
}
return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
};
......@@ -443,14 +425,6 @@ function WebGLRenderer( parameters = {} ) {
this.getCurrentViewport = function ( target ) {
if ( target === undefined ) {
console.warn( 'WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument' );
target = new Vector4();
}
return target.copy( _currentViewport );
};
......@@ -527,14 +501,6 @@ function WebGLRenderer( parameters = {} ) {
this.getClearColor = function ( target ) {
if ( target === undefined ) {
console.warn( 'WebGLRenderer: .getClearColor() now requires a Color as an argument' );
target = new Color();
}
return target.copy( background.getClearColor() );
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册