From f9160a17e5236733b113aa0dd548a27d599737bb Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Thu, 15 Dec 2016 14:22:19 +0100 Subject: [PATCH 1/3] Matrix3/Matrix4: Removed .applyToVector3Array() --- docs/api/deprecated/DeprecatedList.html | 12 ++++++++-- docs/api/math/Matrix3.html | 12 +--------- docs/api/math/Matrix4.html | 13 +--------- editor/js/libs/tern-threejs/threejs.js | 12 +++++----- examples/webgl_interactive_instances_gpu.html | 14 ++++++++--- src/Three.Legacy.js | 10 ++++++++ src/core/BufferGeometry.js | 4 ++-- src/math/Matrix3.js | 24 ------------------- src/math/Matrix4.js | 24 ------------------- 9 files changed, 41 insertions(+), 84 deletions(-) diff --git a/docs/api/deprecated/DeprecatedList.html b/docs/api/deprecated/DeprecatedList.html index 3e6c711fc43b19..ecbc44698b9ed1 100644 --- a/docs/api/deprecated/DeprecatedList.html +++ b/docs/api/deprecated/DeprecatedList.html @@ -297,7 +297,11 @@

[page:Matrix3]

Matrix3.multiplyVector3 has been removed. Use vector.applyMatrix3( matrix ) instead.

- Matrix3.multiplyVector3Array has been renamed to [page:Matrix3.applyToVector3Array]( array ). + Matrix3.multiplyVector3Array has been renamed to [page:Matrix3.applyToVector3Array]( array ).

+ + Matrix3.applyToBuffer has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.

+ + Matrix3.applyToVector3Array has been removed.

[page:Matrix4]

@@ -327,7 +331,11 @@

[page:Matrix4]

Matrix4.rotateZ has been removed.

- Matrix4.rotateByAxis has been removed. + Matrix4.rotateByAxis has been removed.

+ + Matrix4.applyToBuffer has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.

+ + Matrix4.applyToVector3Array has been removed.
diff --git a/docs/api/math/Matrix3.html b/docs/api/math/Matrix3.html index 1129d6d51e3707..45a22e66e88941 100644 --- a/docs/api/math/Matrix3.html +++ b/docs/api/math/Matrix3.html @@ -78,17 +78,7 @@

[method:Array applyToBufferAttribute]( [page:BufferAttribute attribute] ) - -

[method:Array applyToVector3Array]( [page:Array array], [page:Number offset], [page:Number length] )

-
- [page:Array array] - An array of floats in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...], - that represent 3D vectors.
- [page:Number offset] - (optional) index in the array of the first vector's x component. Default is 0.
- [page:Number length] - (optional) index in the array of the last vector's z component. - Default is the last element in the array.

- - Multiplies (applies) this matrix to every 3D vector in the [page:Array array]. -
+

[method:Matrix3 clone]()

Creates a new Matrix3 and with identical elements to this one.
diff --git a/docs/api/math/Matrix4.html b/docs/api/math/Matrix4.html index fcf3a6e705649e..472b5efe91bc85 100644 --- a/docs/api/math/Matrix4.html +++ b/docs/api/math/Matrix4.html @@ -116,18 +116,7 @@

[method:Array applyToBufferAttribute]( [page:BufferAttribute attribute] ) - - -

[method:Array applyToVector3Array]( [page:Array array], [page:Number offset], [page:Number length] )

-
- [page:Array array] - An array of floats in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...], - that represent 3D vectors.
- [page:Number offset] - (optional) index in the array of the first vector's x component. Default is 0.
- [page:Number length] - (optional) index in the array of the last vector's z component. - Default is the last element in the array.

- - Multiplies (applies) the upper 3x3 matrix of this matrix to every 3D vector in the [page:Array array]. -
+

[method:Matrix4 clone]()

Creates a new Matrix4 with identical [page:.elements elements] to this one.
diff --git a/editor/js/libs/tern-threejs/threejs.js b/editor/js/libs/tern-threejs/threejs.js index 139246068ff86a..836bff234e89ec 100644 --- a/editor/js/libs/tern-threejs/threejs.js +++ b/editor/js/libs/tern-threejs/threejs.js @@ -3774,9 +3774,9 @@ "!type": "fn(scalar: number) -> +THREE.Matrix3", "!doc": "Multiply every component of the matrix by a scalar value." }, - "applyToVector3Array": { - "!type": "fn(array: []) -> []", - "!doc": "Multiply (apply) this matrix to every vector3 in the array." + "applyToBufferAttribute": { + "!type": "fn(attribute: []) -> +THREE.BufferAttribute", + "!doc": "Multiply (apply) this matrix to every vector3 in the attribute." }, "getNormalMatrix": { "!type": "fn(matrix4: +THREE.Matrix4) -> +THREE.Matrix3", @@ -3937,9 +3937,9 @@ "!type": "fn() -> +THREE.Matrix4", "!doc": "Clones this matrix." }, - "applyToVector3Array": { - "!type": "fn(a: []) -> []", - "!doc": "Multiply (apply) this matrix to every vector3 in the array." + "applyToBufferAttribute": { + "!type": "fn(attribute: []) -> +THREE.BufferAttribute", + "!doc": "Multiply (apply) this matrix to every vector3 in the attribute." }, "getMaxScaleOnAxis": { "!type": "fn() -> number", diff --git a/examples/webgl_interactive_instances_gpu.html b/examples/webgl_interactive_instances_gpu.html index 4b4ad4f8e0ab45..81d15c00842038 100644 --- a/examples/webgl_interactive_instances_gpu.html +++ b/examples/webgl_interactive_instances_gpu.html @@ -718,16 +718,24 @@ var vertices = new THREE.BufferAttribute( new Float32Array( instanceCount * posLen ), 3 ); + var vertex = new THREE.Vector3(); var matrix = new THREE.Matrix4(); for ( var i = 0, ul = instanceCount; i < ul; i ++ ) { - + var offset = i * posLen; randomizeMatrix( matrix ); var object = new THREE.Object3D(); objectCount ++; object.applyMatrix( matrix ); pickingData[ i + 1 ] = object; - vertices.set( pos.array, i * posLen ); - matrix.applyToVector3Array( vertices.array, i * posLen, posLen ) + vertices.set( pos.array, offset ); + + for ( var k = 0, l = offset; k < posLen; k += 3, l += 3 ) { + + vertex.fromArray( vertices.array, l ); + vertex.applyMatrix4( matrix ); + vertex.toArray( vertices.array, l ); + + } } mgeo.addAttribute( 'position', vertices ); diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index 2df4e514a04b38..39ab10babffb87 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -359,6 +359,11 @@ Object.assign( Matrix3.prototype, { console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' ); return this.applyToBufferAttribute( buffer ); + }, + applyToVector3Array: function( array, offset, length ) { + + console.error( 'THREE.Matrix3: .applyToVector3Array() has been removed.' ); + } } ); @@ -456,6 +461,11 @@ Object.assign( Matrix4.prototype, { console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' ); return this.applyToBufferAttribute( buffer ); + }, + applyToVector3Array: function( array, offset, length ) { + + console.error( 'THREE.Matrix4: .applyToVector3Array() has been removed.' ); + } } ); diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index bdfde71ddcc931..59b3b917de472f 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -126,7 +126,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { if ( position !== undefined ) { - matrix.applyToVector3Array( position.array ); + matrix.applyToBufferAttribute( position ); position.needsUpdate = true; } @@ -137,7 +137,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { var normalMatrix = new Matrix3().getNormalMatrix( matrix ); - normalMatrix.applyToVector3Array( normal.array ); + normalMatrix.applyToBufferAttribute( normal ); normal.needsUpdate = true; } diff --git a/src/math/Matrix3.js b/src/math/Matrix3.js index 4c1717444c50fa..066fcf7efe6cf2 100644 --- a/src/math/Matrix3.js +++ b/src/math/Matrix3.js @@ -95,30 +95,6 @@ Matrix3.prototype = { }, - applyToVector3Array: function () { - - var v1; - - return function applyToVector3Array( array, offset, length ) { - - if ( v1 === undefined ) v1 = new Vector3(); - if ( offset === undefined ) offset = 0; - if ( length === undefined ) length = array.length; - - for ( var i = 0, j = offset; i < length; i += 3, j += 3 ) { - - v1.fromArray( array, j ); - v1.applyMatrix3( this ); - v1.toArray( array, j ); - - } - - return array; - - }; - - }(), - applyToBufferAttribute: function () { var v1; diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index f00d2cfcf58990..bc2cd10d9f3ac9 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -448,30 +448,6 @@ Matrix4.prototype = { }, - applyToVector3Array: function () { - - var v1; - - return function applyToVector3Array( array, offset, length ) { - - if ( v1 === undefined ) v1 = new Vector3(); - if ( offset === undefined ) offset = 0; - if ( length === undefined ) length = array.length; - - for ( var i = 0, j = offset; i < length; i += 3, j += 3 ) { - - v1.fromArray( array, j ); - v1.applyMatrix4( this ); - v1.toArray( array, j ); - - } - - return array; - - }; - - }(), - applyToBufferAttribute: function () { var v1; From 5e65bdc15a1b5814950456ea7c5be9ecab455086 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Thu, 15 Dec 2016 14:27:03 +0100 Subject: [PATCH 2/3] tern-threejs: Correct format --- editor/js/libs/tern-threejs/threejs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/js/libs/tern-threejs/threejs.js b/editor/js/libs/tern-threejs/threejs.js index 836bff234e89ec..0beef0248cdc39 100644 --- a/editor/js/libs/tern-threejs/threejs.js +++ b/editor/js/libs/tern-threejs/threejs.js @@ -3774,7 +3774,7 @@ "!type": "fn(scalar: number) -> +THREE.Matrix3", "!doc": "Multiply every component of the matrix by a scalar value." }, - "applyToBufferAttribute": { + "applyToBufferAttribute": { "!type": "fn(attribute: []) -> +THREE.BufferAttribute", "!doc": "Multiply (apply) this matrix to every vector3 in the attribute." }, From 7b666bfd04408be5e9eab894e2a290860c31ae41 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Thu, 15 Dec 2016 14:28:34 +0100 Subject: [PATCH 3/3] tern-threejs: Correct format --- editor/js/libs/tern-threejs/threejs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/js/libs/tern-threejs/threejs.js b/editor/js/libs/tern-threejs/threejs.js index 0beef0248cdc39..1fed0b6854fe55 100644 --- a/editor/js/libs/tern-threejs/threejs.js +++ b/editor/js/libs/tern-threejs/threejs.js @@ -3774,7 +3774,7 @@ "!type": "fn(scalar: number) -> +THREE.Matrix3", "!doc": "Multiply every component of the matrix by a scalar value." }, - "applyToBufferAttribute": { + "applyToBufferAttribute": { "!type": "fn(attribute: []) -> +THREE.BufferAttribute", "!doc": "Multiply (apply) this matrix to every vector3 in the attribute." }, @@ -3937,7 +3937,7 @@ "!type": "fn() -> +THREE.Matrix4", "!doc": "Clones this matrix." }, - "applyToBufferAttribute": { + "applyToBufferAttribute": { "!type": "fn(attribute: []) -> +THREE.BufferAttribute", "!doc": "Multiply (apply) this matrix to every vector3 in the attribute." },