提交 64851129 编写于 作者: G Garrett Johnson

Add setFromMatrix3 function

Add test
上级 6e6bb25c
......@@ -368,6 +368,9 @@ x, y, 1, 0,
[page:Float n12], ... [page:Float n44].
</p>
<h3>[method:this setFromMatrix3]( [param:Matrix3 m] )</h3>
<p>Set the upper 3x3 elements of this matrix to the values of the Matrix3 [page:Matrix3 m].</p>
<h3>[method:this setPosition]( [param:Vector3 v] )</h3>
<h3>[method:this setPosition]( [param:Float x], [param:Float y], [param:Float z] ) // optional API</h3>
<p>
......
......@@ -351,6 +351,9 @@ x, y, 1, 0,
以行优先的格式将传入的数值设置给该矩阵中的元素[page:.elements elements]。
</p>
<h3>[method:this setFromMatrix3]( [param:Matrix3 m] )</h3>
<p>Set the upper 3x3 elements of this matrix to the values of the Matrix3 [page:Matrix3 m].</p>
<h3>[method:this setPosition]( [param:Vector3 v] )</h3>
<h3>[method:this setPosition]( [param:Float x], [param:Float y], [param:Float z] ) // optional API</h3>
<p>
......
......@@ -83,6 +83,23 @@ class Matrix4 {
}
setFromMatrix3( m ) {
const me = m.elements;
this.set(
me[ 0 ], me[ 3 ], me[ 6 ], 0,
me[ 1 ], me[ 4 ], me[ 7 ], 0,
me[ 2 ], me[ 5 ], me[ 8 ], 0,
0, 0, 0, 1
);
return this;
}
extractBasis( xAxis, yAxis, zAxis ) {
xAxis.setFromMatrixColumn( this, 0 );
......
/* global QUnit */
import { Matrix3 } from '../../../../src/math/Matrix3';
import { Matrix4 } from '../../../../src/math/Matrix4';
import { Vector3 } from '../../../../src/math/Vector3';
import { Euler } from '../../../../src/math/Euler';
......@@ -163,6 +164,25 @@ export default QUnit.module( 'Maths', () => {
} );
QUnit.test( "setFromMatrix4", ( assert ) => {
var a = new Matrix3().set(
0, 1, 2,
3, 4, 5,
6, 7, 8
);
var b = new Matrix4();
var c = new Matrix4().set(
0, 1, 2, 0,
3, 4, 5, 0,
6, 7, 8, 0,
0, 0, 0, 1
);
b.setFromMatrix3( a );
assert.ok( b.equals( c ) );
} );
QUnit.test( "copyPosition", ( assert ) => {
var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册