JavaScript
语言:
JaveScriptBabelCoffeeScript
确定
/* Referrer links:
1. http://graphic-sim.com/23_body_axis_rotation.php
2. http://rwoodley.org/?p=1073
3. http://stackoverflow.com/questions/25199173/how-to-find-rotation-matrix-between-two-vectors-in-three-js */
function fixMatrix(mesh) {
bakeRotation(mesh);
rotate180(mesh);
bakeRotation(mesh);
}
function rotate180(mesh) {
var m = new THREE.Matrix4();
m.makeRotationY(Math.PI);
mesh.matrix.multiplyMatrices(mesh.matrix, m);
mesh.matrix.decompose(mesh.position, mesh.quaternion, mesh.scale);
}
function bakeRotation(mesh) {
mesh.updateMatrixWorld();
var geom = mesh.geometry;
var rotMatrix = mesh.matrix.clone();
rotMatrix.setPosition(new THREE.Vector3(0, 0, 0));<