提交 7441b1de 编写于 作者: M Mr.doob

Implemented gero3's Matrix4.transformVector3 optimisation (...

Implemented gero3's Matrix4.transformVector3 optimisation ( http://jsperf.com/diff-in-speed-for-three-js ).
上级 6a257e81
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -133,7 +133,7 @@
objects = [];
geometry = new Sphere( 100, 16, 8 );
material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg', THREE.ReflectionMapping ) } );
material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/uvgrid.png', THREE.ReflectionMapping ) } );
for ( var i = 0; i < 10; i ++ ) {
......
http://www.flickr.com/photos/seeminglee/1791052516/
......@@ -52,13 +52,12 @@ THREE.Matrix4.prototype = {
transformVector3: function ( v ) {
var vx = v.x, vy = v.y, vz = v.z;
var vx = v.x, vy = v.y, vz = v.z,
d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 );
v.x = this.n11 * vx + this.n12 * vy + this.n13 * vz + this.n14;
v.y = this.n21 * vx + this.n22 * vy + this.n23 * vz + this.n24;
v.z = this.n31 * vx + this.n32 * vy + this.n33 * vz + this.n34;
v.multiplyScalar( 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 ) );
v.x = ( this.n11 * vx + this.n12 * vy + this.n13 * vz + this.n14 ) * d;
v.y = ( this.n21 * vx + this.n22 * vy + this.n23 * vz + this.n24 ) * d;
v.z = ( this.n31 * vx + this.n32 * vy + this.n33 * vz + this.n34 ) * d;
return v;
......
......@@ -482,11 +482,11 @@ THREE.CanvasRenderer = function () {
texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.env_map.image, element.vertexNormalsWorld[ 0 ].x * 0.5 + 0.5, element.vertexNormalsWorld[ 0 ].y * 0.5 + 0.5, element.vertexNormalsWorld[ 1 ].x * 0.5 + 0.5, element.vertexNormalsWorld[ 1 ].y * 0.5 + 0.5, element.vertexNormalsWorld[ 2 ].x * 0.5 + 0.5, element.vertexNormalsWorld[ 2 ].y * 0.5 + 0.5 );
} else if ( material.env_map.mapping == THREE.RefractionMapping ) {
}/* else if ( material.env_map.mapping == THREE.RefractionMapping ) {
}
}*/
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册