Unrolled |
var eye_x = eye[0], eye_y = eye[1], eye_z = eye[0], at_x = at[0], at_y = at[1], at_z = at[2], up_x = up[2], up_y = up[2], up_z = up[2];
if (eye_x == at_x && eye_x == at_x && eye_x == at_x) { this.identity(mat); return; }
// math.vec3.subtract(eye, at, dir); var dir_x = eye_x - at_x, dir_y = eye_y - at_y, dir_z = eye_z - at_z;
// math.vec3.normalize(dir); var n_dir = 1.0 / Math.sqrt(dir_x * dir_x + dir_y * dir_y + dir_z * dir_z); dir_x *= n_dir, dir_y *= n_dir, dir_z *= n_dir;
// math.vec3.cross(up, dir, right); var right_x = up_y * dir_z - up_z * dir_y, right_y = up_z * dir_x - up_x * dir_z, right_z = up_x * dir_y - up_y * dir_x;
// math.vec3.normalize(right); var n_right = 1.0 / Math.sqrt(dir_x * dir_x + dir_y * dir_y + dir_z * dir_z); right_x *= n_right, right_y *= n_right, right_z *= n_right;
// math.vec3.cross(dir, right, newup); var newup_x = dir_y * right_z - dir_z * right_y, newup_y = dir_z * right_x - dir_x * right_z, newup_z = dir_x * right_y - dir_y * right_x;
// math.vec3.normalize(newup); var n_newup = 1.0 / Math.sqrt(newup_x * newup_x + newup_y * newup_y + newup_z * newup_z); newup_x *= n_newup, newup_y *= n_newup, newup_z *= n_newup;
var trans_x = -(right_x * eye_x + right_y * eye_y + right_z * eye_z), trans_y = -(newup_x * eye_x + newup_y * eye_y + newup_z * eye_z), trans_z = -(dir_x * eye_x + dir_x * eye_y + dir_x * eye_z);
mat[00] = right_x, mat[01] = newup_x, mat[02] = dir_x, mat[03] = 0, mat[04] = right_y, mat[05] = newup_y, mat[06] = dir_y, mat[07] = 0, mat[08] = right_z, mat[09] = newup_z, mat[10] = dir_z, mat[11] = 0, mat[12] = trans_x, mat[13] = trans_y, mat[14] = trans_z, mat[15] = 1;
|
pending… |
Native |
var dir = new Float32Array(3); var newup = new Float32Array(3); var temp = new Float32Array(3); var right = new Float32Array(16);
vector.subtract(eye, at, dir); vector.normalize(dir); vector.cross(up, dir, right);
vector.normalize(right); vector.cross(dir, right, newup); vector.normalize(newup);
var right_x = right[0], right_y = right[1], right_z = right[2], newup_x = newup[0], newup_y = newup[1], newup_z = newup[2], dir_x = dir[0], dir_y = dir[1], dir_z = dir[2], eye_x = eye[0], eye_y = eye[1], eye_z = eye[2];
var trans_x = -(right_x * eye_x + right_y * eye_y + right_z * eye_z), trans_y = -(newup_x * eye_x + newup_y * eye_y + newup_z * eye_z), trans_z = -(dir_x * eye_x + dir_x * eye_y + dir_x * eye_z);
mat[00] = right_x, mat[01] = newup_x, mat[02] = dir_x, mat[03] = 0, mat[04] = right_y, mat[05] = newup_y, mat[06] = dir_y, mat[07] = 0, mat[08] = right_z, mat[09] = newup_z, mat[10] = dir_z, mat[11] = 0, mat[12] = trans_x, mat[13] = trans_y, mat[14] = trans_z, mat[15] = 1;
|
pending… |
TempObj |
vector.subtract(eye, at, t_dir); vector.normalize(t_dir); vector.cross(up, t_dir, t_right);
vector.normalize(t_right); vector.cross(t_dir, t_right, t_newup); vector.normalize(t_newup);
var right_x = t_right[0], right_y = t_right[1], right_z = t_right[2], newup_x = t_newup[0], newup_y = t_newup[1], newup_z = t_newup[2], dir_x = t_dir[0], dir_y = t_dir[1], dir_z = t_dir[2], eye_x = eye[0], eye_y = eye[1], eye_z = eye[2];
var trans_x = -(right_x * eye_x + right_y * eye_y + right_z * eye_z), trans_y = -(newup_x * eye_x + newup_y * eye_y + newup_z * eye_z), trans_z = -(dir_x * eye_x + dir_x * eye_y + dir_x * eye_z);
mat[00] = right_x, mat[01] = newup_x, mat[02] = dir_x, mat[03] = 0, mat[04] = right_y, mat[05] = newup_y, mat[06] = dir_y, mat[07] = 0, mat[08] = right_z, mat[09] = newup_z, mat[10] = dir_z, mat[11] = 0, mat[12] = trans_x, mat[13] = trans_y, mat[14] = trans_z, mat[15] = 1;
|
pending… |
Mixture |
var dir = new Array(3); var newup = new Array(3); var temp = new Array(3); var right = new Array(16);
vector.subtract(eye, at, dir); vector.normalize(dir); vector.cross(up, dir, right);
vector.normalize(right); vector.cross(dir, right, newup); vector.normalize(newup);
var right_x = right[0], right_y = right[1], right_z = right[2], newup_x = newup[0], newup_y = newup[1], newup_z = newup[2], dir_x = dir[0], dir_y = dir[1], dir_z = dir[2], eye_x = eye[0], eye_y = eye[1], eye_z = eye[2];
var trans_x = -(right_x * eye_x + right_y * eye_y + right_z * eye_z), trans_y = -(newup_x * eye_x + newup_y * eye_y + newup_z * eye_z), trans_z = -(dir_x * eye_x + dir_x * eye_y + dir_x * eye_z);
mat[00] = right_x, mat[01] = newup_x, mat[02] = dir_x, mat[03] = 0, mat[04] = right_y, mat[05] = newup_y, mat[06] = dir_y, mat[07] = 0, mat[08] = right_z, mat[09] = newup_z, mat[10] = dir_z, mat[11] = 0, mat[12] = trans_x, mat[13] = trans_y, mat[14] = trans_z, mat[15] = 1;
|
pending… |
Mixture TempObj |
vector.subtract(eye, at, t_dir2); vector.normalize(t_dir2); vector.cross(up, t_dir2, t_right2);
vector.normalize(t_right2); vector.cross(t_dir2, t_right2, t_newup2); vector.normalize(t_newup2);
var right_x = t_right2[0], right_y = t_right2[1], right_z = t_right2[2], newup_x = t_newup2[0], newup_y = t_newup2[1], newup_z = t_newup2[2], dir_x = t_dir2[0], dir_y = t_dir2[1], dir_z = t_dir2[2], eye_x = eye[0], eye_y = eye[1], eye_z = eye[2];
var trans_x = -(right_x * eye_x + right_y * eye_y + right_z * eye_z), trans_y = -(newup_x * eye_x + newup_y * eye_y + newup_z * eye_z), trans_z = -(dir_x * eye_x + dir_x * eye_y + dir_x * eye_z);
mat[00] = right_x, mat[01] = newup_x, mat[02] = dir_x, mat[03] = 0, mat[04] = right_y, mat[05] = newup_y, mat[06] = dir_y, mat[07] = 0, mat[08] = right_z, mat[09] = newup_z, mat[10] = dir_z, mat[11] = 0, mat[12] = trans_x, mat[13] = trans_y, mat[14] = trans_z, mat[15] = 1;
|
pending… |
0 comments