Skip to content

Commit

Permalink
Merge pull request #18264 from WestLangley/dev_deprecate
Browse files Browse the repository at this point in the history
Deprecate Matrix*.applyToBufferAttribute() methods
  • Loading branch information
mrdoob committed Dec 30, 2019
2 parents 3ba0553 + efd9928 commit 87e4279
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 139 deletions.
14 changes: 7 additions & 7 deletions docs/api/en/deprecated/DeprecatedList.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ <h3>[page:XHRLoader]</h3>
<h3>[page:JSONLoader]</h3>
<p>JSONLoader has been removed from core.</p>

<h2>Maths</h2>
<h2>Math</h2>

<h3>[page:Box2]</h3>
<p>
Expand Down Expand Up @@ -293,15 +293,15 @@ <h3>[page:Math]</h3>

<h3>[page:Matrix3]</h3>
<p>
Matrix3.flattenToArrayOffset is deprecated. Use [page:Matrix3.toArray]() instead.<br /><br />
Matrix3.flattenToArrayOffset() is deprecated. Use [page:Matrix3.toArray]() instead.<br /><br />

Matrix3.multiplyVector3 has been removed. Use vector.applyMatrix3( matrix ) instead.<br /><br />
Matrix3.multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.<br /><br />

Matrix3.multiplyVector3Array has been renamed to [page:Matrix3.applyToVector3Array]( array ).<br /><br />
Matrix3.multiplyVector3Array() has been renamed to [page:Matrix3.applyToVector3Array]( array ).<br /><br />

Matrix3.applyToBuffer has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.<br /><br />
Matrix3.applyToBufferAttribute() has been removed. Use [page:BufferAttribute.applyMatrix3]( matrix ) instead.<br /><br />

Matrix3.applyToVector3Array has been removed.
Matrix3.applyToVector3Array() has been removed.
<p>

<h3>[page:Matrix4]</h3>
Expand Down Expand Up @@ -332,7 +332,7 @@ <h3>[page:Matrix4]</h3>

Matrix4.rotateByAxis() has been removed.<br /><br />

Matrix4.applyToBuffer() has been removed. Use matrix.applyToBufferAttribute() instead.<br /><br />
Matrix4.applyToBufferAttribute() has been removed. Use [page:BufferAttribute.applyMatrix4]( matrix ) instead.<br /><br />

Matrix4.applyToVector3Array() has been removed.<br /><br />

Expand Down
8 changes: 0 additions & 8 deletions docs/api/en/math/Matrix3.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ <h3>[property:Array elements]</h3>

<h2>Methods</h2>

<h3>[method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )</h3>
<p>
[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br /><br />

Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].
</p>


<h3>[method:Matrix3 clone]()</h3>
<p>Creates a new Matrix3 and with identical elements to this one.</p>

Expand Down
8 changes: 0 additions & 8 deletions docs/api/en/math/Matrix4.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ <h3>[property:Array elements]</h3>

<h2>Methods</h2>

<h3>[method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )</h3>
<p>
[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br /><br />

Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].
</p>


<h3>[method:Matrix4 clone]()</h3>
<p>Creates a new Matrix4 with identical [page:.elements elements] to this one.</p>

Expand Down
8 changes: 0 additions & 8 deletions docs/api/zh/math/Matrix3.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ <h3>[property:Array elements]</h3>

<h2>方法(Methods)</h2>

<h3>[method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )</h3>
<p>
[page:BufferAttribute attribute] - 表示三维向量缓存属性。<br /><br />

用这个矩阵乘以缓存属性[page:BufferAttribute attribute]里的所有3d向量。
</p>


<h3>[method:Matrix3 clone]()</h3>
<p>创建一个新的矩阵,元素 [page:.elements elements] 与该矩阵相同。</p>

Expand Down
8 changes: 0 additions & 8 deletions docs/api/zh/math/Matrix4.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ <h3>[property:Array elements]</h3>

<h2>方法(Methods)</h2>

<h3>[method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )</h3>
<p>
[page:BufferAttribute attribute] - 表示三维向量缓存属性。<br /><br />

用这个矩阵乘以缓存属性[page:BufferAttribute attribute]里的所有3d向量。
</p>


<h3>[method:Matrix4 clone]()</h3>
<p>创建一个新的矩阵,元素[page:.elements elements]与该矩阵相同。</p>

Expand Down
12 changes: 6 additions & 6 deletions src/Three.Legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,10 @@ Object.assign( Matrix3.prototype, {
console.error( 'THREE.Matrix3: .multiplyVector3Array() has been removed.' );

},
applyToBuffer: function ( buffer /*, offset, length */ ) {
applyToBufferAttribute: function ( attribute ) {

console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );
return this.applyToBufferAttribute( buffer );
console.warn( 'THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.' );
return attribute.applyMatrix3( this );

},
applyToVector3Array: function ( /* array, offset, length */ ) {
Expand Down Expand Up @@ -687,10 +687,10 @@ Object.assign( Matrix4.prototype, {
console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' );

},
applyToBuffer: function ( buffer /*, offset, length */ ) {
applyToBufferAttribute: function ( attribute ) {

console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );
return this.applyToBufferAttribute( buffer );
console.warn( 'THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.' );
return attribute.applyMatrix4( this );

},
applyToVector3Array: function ( /* array, offset, length */ ) {
Expand Down
12 changes: 0 additions & 12 deletions src/math/Matrix3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ export class Matrix3 implements Matrix {
clone(): this;
copy( m: Matrix3 ): this;
setFromMatrix4( m: Matrix4 ): Matrix3;

/**
* @deprecated Use {@link Matrix3#applyToBufferAttribute matrix3.applyToBufferAttribute( attribute )} instead.
*/
applyToBuffer(
buffer: BufferAttribute,
offset?: number,
length?: number
): BufferAttribute;

applyToBufferAttribute( attribute: BufferAttribute ): BufferAttribute;

multiplyScalar( s: number ): Matrix3;
determinant(): number;
getInverse( matrix: Matrix3, throwOnDegenerate?: boolean ): Matrix3;
Expand Down
18 changes: 0 additions & 18 deletions src/math/Matrix3.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,6 @@ Object.assign( Matrix3.prototype, {

},

applyToBufferAttribute: function ( attribute ) {

for ( var i = 0, l = attribute.count; i < l; i ++ ) {

_vector.x = attribute.getX( i );
_vector.y = attribute.getY( i );
_vector.z = attribute.getZ( i );

_vector.applyMatrix3( this );

attribute.setXYZ( i, _vector.x, _vector.y, _vector.z );

}

return attribute;

},

multiply: function ( m ) {

return this.multiplyMatrices( this, m );
Expand Down
11 changes: 0 additions & 11 deletions src/math/Matrix4.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ export class Matrix4 implements Matrix {
*/
multiplyScalar( s: number ): Matrix4;

/**
* @deprecated Use {@link Matrix4#applyToBufferAttribute matrix4.applyToBufferAttribute( attribute )} instead.
*/
applyToBuffer(
buffer: BufferAttribute,
offset?: number,
length?: number
): BufferAttribute;

applyToBufferAttribute( attribute: BufferAttribute ): BufferAttribute;

/**
* Computes determinant of this matrix.
* Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
Expand Down
18 changes: 0 additions & 18 deletions src/math/Matrix4.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,6 @@ Object.assign( Matrix4.prototype, {

},

applyToBufferAttribute: function ( attribute ) {

for ( var i = 0, l = attribute.count; i < l; i ++ ) {

_v1.x = attribute.getX( i );
_v1.y = attribute.getY( i );
_v1.z = attribute.getZ( i );

_v1.applyMatrix4( this );

attribute.setXYZ( i, _v1.x, _v1.y, _v1.z );

}

return attribute;

},

determinant: function () {

var te = this.elements;
Expand Down
12 changes: 0 additions & 12 deletions test/unit/src/math/Matrix3.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,6 @@ export default QUnit.module( 'Maths', () => {

} );

QUnit.test( "applyToBufferAttribute", ( assert ) => {

var a = new Matrix3().set( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
var attr = new Float32BufferAttribute( [ 1, 2, 1, 3, 0, 3 ], 3 );
var expected = new Float32Array( [ 8, 20, 32, 12, 30, 48 ] );

var applied = a.applyToBufferAttribute( attr );

assert.deepEqual( applied.array, expected, "Check resulting buffer" );

} );

QUnit.test( "multiply/premultiply", ( assert ) => {

// both simply just wrap multiplyMatrices
Expand Down
23 changes: 0 additions & 23 deletions test/unit/src/math/Matrix4.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,29 +418,6 @@ export default QUnit.module( 'Maths', () => {

} );

QUnit.test( "applyToBufferAttribute", ( assert ) => {

var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
var attr = new Float32BufferAttribute( [ 1, 2, 1, 3, 0, 3 ], 3 );
var expected = new Float32BufferAttribute( [
0.1666666716337204, 0.4444444477558136, 0.7222222089767456,
0.1599999964237213, 0.4399999976158142, 0.7200000286102295
], 3 );

var applied = a.applyToBufferAttribute( attr );

assert.strictEqual( expected.count, applied.count, "Applied buffer and expected buffer have the same number of entries" );

for ( var i = 0, l = expected.count; i < l; i ++ ) {

assert.ok( Math.abs( applied.getX( i ) - expected.getX( i ) ) <= eps, "Check x" );
assert.ok( Math.abs( applied.getY( i ) - expected.getY( i ) ) <= eps, "Check y" );
assert.ok( Math.abs( applied.getZ( i ) - expected.getZ( i ) ) <= eps, "Check z" );

}

} );

QUnit.test( "determinant", ( assert ) => {

var a = new Matrix4();
Expand Down

0 comments on commit 87e4279

Please sign in to comment.