提交 faab3b03 编写于 作者: A apendua

Fixed weights normalization in `SkinnedMesh.js`. Added `lengthManhattan` method to `Vector4`.

上级 9acd1deb
......@@ -142,6 +142,12 @@ THREE.Vector4.prototype = {
return Math.sqrt( this.lengthSq() );
},
lengthManhattan: function () {
return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
},
normalize: function () {
......
......@@ -218,8 +218,24 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function ( force ) {
THREE.SkinnedMesh.prototype.pose = function() {
this.updateMatrixWorld( true );
// TODO: decide if we need to normalize weights here; for now it's
// done automatically by shader (as a byproduct of using vec4 arithmetic)
for ( var i = 0; i < this.geometry.skinIndices.length; i ++ ) {
// normalize weights
var sw = this.geometry.skinWeights[ i ];
var scale = 1.0 / sw.lengthManhattan();
if ( scale != Infinity ) {
sw.multiplyScalar( scale );
} else {
sw.set( 1 ); // this will be normalized by the shader anyway
}
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册