772 // the inverse takes the vector into local bone space
773 // which is then transformed to the appropriate world space
774 tempVector.applyMatrix4(inverses[k]).applyMatrix4(skinMatrices[k]);
775 finalVector.add(tempVector); 776 }
777
778 output += "\t\t\tvertex " + finalVector.x + " " + finalVector.y + " " + finalVector.z + "\n";
772 // the inverse takes the vector into local bone space
773 // which is then transformed to the appropriate world space
774 tempVector.applyMatrix4(inverses[k]).applyMatrix4(skinMatrices[k]);
775 finalVector.add(tempVector); 776 }
777
778 output += "\t\t\tvertex " + finalVector.x + " " + finalVector.y + " " + finalVector.z + "\n";
771 tempVector.multiplyScalar(weights[k]);
772 // the inverse takes the vector into local bone space
773 // which is then transformed to the appropriate world space
774 tempVector.applyMatrix4(inverses[k]).applyMatrix4(skinMatrices[k]); 775 finalVector.add(tempVector);
776 }
777
771 tempVector.multiplyScalar(weights[k]);
772 // the inverse takes the vector into local bone space
773 // which is then transformed to the appropriate world space
774 tempVector.applyMatrix4(inverses[k]).applyMatrix4(skinMatrices[k]); 775 finalVector.add(tempVector);
776 }
777
768 } else {
769 var tempVector = new THREE.Vector4(vector.x, vector.y, vector.z);
770 }
771 tempVector.multiplyScalar(weights[k]); 772 // the inverse takes the vector into local bone space
773 // which is then transformed to the appropriate world space
774 tempVector.applyMatrix4(inverses[k]).applyMatrix4(skinMatrices[k]);
Variables should be used inside of their binding context.
This helps avoid difficult bugs with variable hoisting.
It is a bad practice to use var
declarations because variables declared using var
can be accessed in a function-wide scope.
They can even be accessed before declaration.
In such cases, their value would be undefined
because only declarations and not initializations are hoisted.
function doIf() {
if (cond()) {
var build = true;
}
console.log(build);
}
function doIfElse() {
if (cond()) {
var build = true;
} else {
var build = false;
}
console.log(build)
}
function doIf() {
let build;
if (cond()) {
build = true;
}
console.log(build);
}