未验证 提交 02cf0df1 编写于 作者: W WestLangley 提交者: GitHub

Added Vector3.setFromEuler(); removed Euler.toVector3() (#23494)

上级 7e1c525d
......@@ -143,15 +143,6 @@
Returns an array of the form [[page:.x x], [page:.y y], [page:.z z], [page:.order order ]].
</p>
<h3>[method:Vector3 toVector3]( [param:Vector3 optionalResult] )</h3>
<p>
[page:Vector3 optionalResult] — (optional) If specified, the result will be copied into this Vector,
otherwise a new one will be created. <br /><br />
Returns the Euler's [page:.x x], [page:.y y] and [page:.z z] properties as a [page:Vector3].
</p>
<h2>Source</h2>
<p>
......
......@@ -357,6 +357,11 @@
<h3>[method:this setFromCylindricalCoords]( [param:Float radius], [param:Float theta], [param:Float y] )</h3>
<p>Sets this vector from the cylindrical coordinates [page:Cylindrical radius], [page:Cylindrical theta] and [page:Cylindrical y].</p>
<h3>[method:this setFromEuler]( [param:Euler euler] )</h3>
<p>
Sets this vector's [page:.x x], [page:.y y] and [page:.z z] components from the x, y, and z components of the specified [page:Euler Euler Angle].
</p>
<h3>[method:this setFromMatrixColumn]( [param:Matrix4 matrix], [param:Integer index] )</h3>
<p>
Sets this vector's [page:.x x], [page:.y y] and [page:.z z] components from [page:Integer index] column of [page:Matrix4 matrix].
......
......@@ -403,7 +403,7 @@ function SidebarObject( editor ) {
}
const newRotation = new THREE.Euler( objectRotationX.getValue() * THREE.MathUtils.DEG2RAD, objectRotationY.getValue() * THREE.MathUtils.DEG2RAD, objectRotationZ.getValue() * THREE.MathUtils.DEG2RAD );
if ( object.rotation.toVector3().distanceTo( newRotation.toVector3() ) >= 0.01 ) {
if ( new THREE.Vector3().setFromEuler( object.rotation ).distanceTo( new THREE.Vector3().setFromEuler( newRotation ) ) >= 0.01 ) {
editor.execute( new SetRotationCommand( editor, object, newRotation ) );
......
......@@ -186,19 +186,13 @@ class CCDIKSolver {
if ( rotationMin !== undefined ) {
link.rotation.setFromVector3(
link.rotation
.toVector3( _vector )
.max( rotationMin ) );
link.rotation.setFromVector3( _vector.setFromEuler( link.rotation ).max( rotationMin ) );
}
if ( rotationMax !== undefined ) {
link.rotation.setFromVector3(
link.rotation
.toVector3( _vector )
.min( rotationMax ) );
link.rotation.setFromVector3( _vector.setFromEuler( link.rotation ).min( rotationMax ) );
}
......
......@@ -49,6 +49,7 @@ import { PointsMaterial } from './materials/PointsMaterial.js';
import { ShaderMaterial } from './materials/ShaderMaterial.js';
import { Box2 } from './math/Box2.js';
import { Box3 } from './math/Box3.js';
import { Euler } from './math/Euler.js';
import { Sphere } from './math/Sphere.js';
import { Color } from './math/Color.js';
import { Frustum } from './math/Frustum.js';
......@@ -399,6 +400,15 @@ Box3.prototype.size = function ( optionalTarget ) {
};
//
Euler.prototype.toVector3 = function () {
console.error( 'THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead' );
};
//
Sphere.prototype.empty = function () {
......
import { Quaternion } from './Quaternion.js';
import { Vector3 } from './Vector3.js';
import { Matrix4 } from './Matrix4.js';
import { clamp } from './MathUtils.js';
......@@ -288,20 +287,6 @@ class Euler {
}
toVector3( optionalResult ) {
if ( optionalResult ) {
return optionalResult.set( this._x, this._y, this._z );
} else {
return new Vector3( this._x, this._y, this._z );
}
}
_onChange( callback ) {
this._onChangeCallback = callback;
......
......@@ -659,6 +659,16 @@ class Vector3 {
}
setFromEuler( e ) {
this.x = e._x;
this.y = e._y;
this.z = e._z;
return this;
}
equals( v ) {
return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
......
......@@ -200,25 +200,6 @@ export default QUnit.module( 'Maths', () => {
} );
QUnit.test( 'set/setFromVector3/toVector3', ( assert ) => {
var a = new Euler();
a.set( 0, 1, 0, 'ZYX' );
assert.ok( a.equals( eulerAzyx ), 'Passed!' );
assert.ok( ! a.equals( eulerAxyz ), 'Passed!' );
assert.ok( ! a.equals( eulerZero ), 'Passed!' );
var vec = new Vector3( 0, 1, 0 );
var b = new Euler().setFromVector3( vec, 'ZYX' );
assert.ok( a.equals( b ), 'Passed!' );
var c = b.toVector3();
assert.ok( c.equals( vec ), 'Passed!' );
} );
QUnit.test( 'clone/copy/equals', ( assert ) => {
var a = eulerAxyz.clone();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册