1 Star 0 Fork 0

轻飘yyf/WireframeSuperellipsoid_Javascript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MV.js 21.75 KB
一键复制 编辑 原始数据 按行查看 历史
mill5488 提交于 2019-09-12 14:33 . Add files via upload
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
//////////////////////////////////////////////////////////////////////////////
//
// Angel.js
//
//////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Helper functions
//
function _argumentsToArray( args )
{
return [].concat.apply( [], Array.prototype.slice.apply(args) );
}
//----------------------------------------------------------------------------
function radians( degrees ) {
return degrees * Math.PI / 180.0;
}
//----------------------------------------------------------------------------
//
// Vector Constructors
//
function vec2()
{
var result = _argumentsToArray( arguments );
switch ( result.length ) {
case 0: result.push( 0.0 );
case 1: result.push( 0.0 );
}
return result.splice( 0, 2 );
}
function vec3()
{
var result = _argumentsToArray( arguments );
switch ( result.length ) {
case 0: result.push( 0.0 );
case 1: result.push( 0.0 );
case 2: result.push( 0.0 );
}
return result.splice( 0, 3 );
}
function vec4()
{
var result = _argumentsToArray( arguments );
switch ( result.length ) {
case 0: result.push( 0.0 );
case 1: result.push( 0.0 );
case 2: result.push( 0.0 );
case 3: result.push( 1.0 );
}
return result.splice( 0, 4 );
}
//----------------------------------------------------------------------------
//
// Matrix Constructors
//
function mat2()
{
var v = _argumentsToArray( arguments );
var m = [];
switch ( v.length ) {
case 0:
v[0] = 1;
case 1:
m = [
vec2( v[0], 0.0 ),
vec2( 0.0, v[0] )
];
break;
default:
m.push( vec2(v) ); v.splice( 0, 2 );
m.push( vec2(v) );
break;
}
m.matrix = true;
return m;
}
//----------------------------------------------------------------------------
function mat3()
{
var v = _argumentsToArray( arguments );
var m = [];
switch ( v.length ) {
case 0:
v[0] = 1;
case 1:
m = [
vec3( v[0], 0.0, 0.0 ),
vec3( 0.0, v[0], 0.0 ),
vec3( 0.0, 0.0, v[0] )
];
break;
default:
m.push( vec3(v) ); v.splice( 0, 3 );
m.push( vec3(v) ); v.splice( 0, 3 );
m.push( vec3(v) );
break;
}
m.matrix = true;
return m;
}
//----------------------------------------------------------------------------
function mat4()
{
var v = _argumentsToArray( arguments );
var m = [];
switch ( v.length ) {
case 0:
v[0] = 1;
case 1:
m = [
vec4( v[0], 0.0, 0.0, 0.0 ),
vec4( 0.0, v[0], 0.0, 0.0 ),
vec4( 0.0, 0.0, v[0], 0.0 ),
vec4( 0.0, 0.0, 0.0, v[0] )
];
break;
default:
m.push( vec4(v) ); v.splice( 0, 4 );
m.push( vec4(v) ); v.splice( 0, 4 );
m.push( vec4(v) ); v.splice( 0, 4 );
m.push( vec4(v) );
break;
}
m.matrix = true;
return m;
}
//----------------------------------------------------------------------------
//
// Generic Mathematical Operations for Vectors and Matrices
//
function equal( u, v )
{
if ( u.length != v.length ) { return false; }
if ( u.matrix && v.matrix ) {
for ( var i = 0; i < u.length; ++i ) {
if ( u[i].length != v[i].length ) { return false; }
for ( var j = 0; j < u[i].length; ++j ) {
if ( u[i][j] !== v[i][j] ) { return false; }
}
}
}
else if ( u.matrix && !v.matrix || !u.matrix && v.matrix ) {
return false;
}
else {
for ( var i = 0; i < u.length; ++i ) {
if ( u[i] !== v[i] ) { return false; }
}
}
return true;
}
//----------------------------------------------------------------------------
function add( u, v )
{
var result = [];
if ( u.matrix && v.matrix ) {
if ( u.length != v.length ) {
throw "add(): trying to add matrices of different dimensions";
}
for ( var i = 0; i < u.length; ++i ) {
if ( u[i].length != v[i].length ) {
throw "add(): trying to add matrices of different dimensions";
}
result.push( [] );
for ( var j = 0; j < u[i].length; ++j ) {
result[i].push( u[i][j] + v[i][j] );
}
}
result.matrix = true;
return result;
}
else if ( u.matrix && !v.matrix || !u.matrix && v.matrix ) {
throw "add(): trying to add matrix and non-matrix variables";
}
else {
if ( u.length != v.length ) {
throw "add(): vectors are not the same dimension";
}
for ( var i = 0; i < u.length; ++i ) {
result.push( u[i] + v[i] );
}
return result;
}
}
//----------------------------------------------------------------------------
function subtract( u, v )
{
var result = [];
if ( u.matrix && v.matrix ) {
if ( u.length != v.length ) {
throw "subtract(): trying to subtract matrices" +
" of different dimensions";
}
for ( var i = 0; i < u.length; ++i ) {
if ( u[i].length != v[i].length ) {
throw "subtract(): trying to subtact matrices" +
" of different dimensions";
}
result.push( [] );
for ( var j = 0; j < u[i].length; ++j ) {
result[i].push( u[i][j] - v[i][j] );
}
}
result.matrix = true;
return result;
}
else if ( u.matrix && !v.matrix || !u.matrix && v.matrix ) {
throw "subtact(): trying to subtact matrix and non-matrix variables";
}
else {
if ( u.length != v.length ) {
throw "subtract(): vectors are not the same length";
}
for ( var i = 0; i < u.length; ++i ) {
result.push( u[i] - v[i] );
}
return result;
}
}
//----------------------------------------------------------------------------
//Adjustments made to the original file: added Matrix*Vector/Vector*Matrix math
//Nathan Taylor 9/25/2017
function mult( u, v )
{
var result = [];
if ( u.matrix && v.matrix ) {
if ( u.length != v.length ) {
throw "mult(): trying to multiply matrices of different dimensions";
}
for ( var i = 0; i < u.length; ++i ) {
if ( u[i].length != v[i].length ) {
throw "mult(): trying to multiply matrices of different dimensions";
}
}
for ( var i = 0; i < u.length; ++i ) {
result.push( [] );
for ( var j = 0; j < v.length; ++j ) {
var sum = 0.0;
for ( var k = 0; k < u.length; ++k ) {
sum += u[i][k] * v[k][j];
}
result[i].push( sum );
}
}
result.matrix = true;
return result;
}
else if ( u.matrix && !v.matrix ) {
if ( u[0].length != v.length ) {
throw "mult(): trying to multiply matrices of different dimensions";
}
for ( var j = 0; j < u.length; ++j ) {
var sum = 0.0;
for ( var k = 0; k < v.length; ++k ) {
sum += u[j][k] * v[k];
}
result.push( sum );
}
//result.matrix = false;
return result;
}
else if ( !u.matrix && v.matrix ) {
if ( u.length != v.length ) {
throw "mult(): trying to multiply matrices of different dimensions";
}
for ( var j = 0; j < v.length; ++j ) {
var sum = 0.0;
for ( var k = 0; k < u.length; ++k ) {
sum += u[k] * v[k][j];
}
result.push( sum );
}
//result.matrix = false;
return result;
}
else {
if ( u.length != v.length ) {
throw "mult(): vectors are not the same dimension";
}
for ( var i = 0; i < u.length; ++i ) {
result.push( u[i] * v[i] );
}
return result;
}
}
//----------------------------------------------------------------------------
//
// Basic Transformation Matrix Generators
//
function translate( x, y, z )
{
if ( Array.isArray(x) && x.length == 3 ) {
z = x[2];
y = x[1];
x = x[0];
}
var result = mat4();
result[0][3] = x;
result[1][3] = y;
result[2][3] = z;
return result;
}
//----------------------------------------------------------------------------
function rotate( angle, axis )
{
if ( !Array.isArray(axis) ) {
axis = [ arguments[1], arguments[2], arguments[3] ];
}
var v = normalize( axis );
var x = v[0];
var y = v[1];
var z = v[2];
var c = Math.cos( radians(angle) );
var omc = 1.0 - c;
var s = Math.sin( radians(angle) );
var result = mat4(
vec4( x*x*omc + c, x*y*omc - z*s, x*z*omc + y*s, 0.0 ),
vec4( x*y*omc + z*s, y*y*omc + c, y*z*omc - x*s, 0.0 ),
vec4( x*z*omc - y*s, y*z*omc + x*s, z*z*omc + c, 0.0 ),
vec4()
);
return result;
}
//----------------------------------------------------------------------------
function scalem( x, y, z )
{
if ( Array.isArray(x) && x.length == 3 ) {
z = x[2];
y = x[1];
x = x[0];
}
var result = mat4();
result[0][0] = x;
result[1][1] = y;
result[2][2] = z;
return result;
}
//----------------------------------------------------------------------------
//
// ModelView Matrix Generators
//
function lookAt( eye, at, up )
{
if ( !Array.isArray(eye) || eye.length != 3) {
throw "lookAt(): first parameter [eye] must be an a vec3";
}
if ( !Array.isArray(at) || at.length != 3) {
throw "lookAt(): first parameter [at] must be an a vec3";
}
if ( !Array.isArray(up) || up.length != 3) {
throw "lookAt(): first parameter [up] must be an a vec3";
}
if ( equal(eye, at) ) {
return mat4();
}
var v = normalize( subtract(at, eye) ); // view direction vector
var n = normalize( cross(v, up) ); // perpendicular vector
var u = normalize( cross(n, v) ); // "new" up vector
v = negate( v );
var result = mat4(
vec4( n, -dot(n, eye) ),
vec4( u, -dot(u, eye) ),
vec4( v, -dot(v, eye) ),
vec4()
);
return result;
}
//----------------------------------------------------------------------------
//
// Projection Matrix Generators
//
function ortho( left, right, bottom, top, near, far )
{
if ( left == right ) { throw "ortho(): left and right are equal"; }
if ( bottom == top ) { throw "ortho(): bottom and top are equal"; }
if ( near == far ) { throw "ortho(): near and far are equal"; }
var w = right - left;
var h = top - bottom;
var d = far - near;
var result = mat4();
result[0][0] = 2.0 / w;
result[1][1] = 2.0 / h;
result[2][2] = -2.0 / d;
result[0][3] = -1*((left + right) / w);
result[1][3] = -1*((top + bottom) / h);
result[2][3] = -1*((near + far) / d);
return result;
}
//----------------------------------------------------------------------------
function perspective( fovy, aspect, near, far )
{
var f = 1.0 / Math.tan( radians(fovy) / 2 );
var d = far - near;
var result = mat4();
result[0][0] = f / aspect;
result[1][1] = f;
result[2][2] = -(near + far) / d;
result[2][3] = -2 * near * far / d;
result[3][2] = -1;
result[3][3] = 0.0;
return result;
}
//----------------------------------------------------------------------------
//
// Matrix Functions
//
function transpose( m )
{
if ( !m.matrix ) {
return "transpose(): trying to transpose a non-matrix";
}
var result = [];
for ( var i = 0; i < m.length; ++i ) {
result.push( [] );
for ( var j = 0; j < m[i].length; ++j ) {
result[i].push( m[j][i] );
}
}
result.matrix = true;
return result;
}
//----------------------------------------------------------------------------
//
// Vector Functions
//
function dot( u, v )
{
if ( u.length != v.length ) {
throw "dot(): vectors are not the same dimension";
}
var sum = 0.0;
for ( var i = 0; i < u.length; ++i ) {
sum += u[i] * v[i];
}
return sum;
}
//----------------------------------------------------------------------------
function negate( u )
{
var result = [];
for ( var i = 0; i < u.length; ++i ) {
result.push( -u[i] );
}
return result;
}
//----------------------------------------------------------------------------
function cross( u, v )
{
if ( !Array.isArray(u) || u.length < 3 ) {
throw "cross(): first argument is not a vector of at least 3";
}
if ( !Array.isArray(v) || v.length < 3 ) {
throw "cross(): second argument is not a vector of at least 3";
}
var result = [
u[1]*v[2] - u[2]*v[1],
u[2]*v[0] - u[0]*v[2],
u[0]*v[1] - u[1]*v[0]
];
return result;
}
//----------------------------------------------------------------------------
function length( u )
{
return Math.sqrt( dot(u, u) );
}
//----------------------------------------------------------------------------
function normalize( u, excludeLastComponent )
{
if ( excludeLastComponent ) {
var last = u.pop();
}
var len = length( u );
if ( !isFinite(len) ) {
throw "normalize: vector " + u + " has zero length";
}
for ( var i = 0; i < u.length; ++i ) {
u[i] /= len;
}
if ( excludeLastComponent ) {
u.push( last );
}
return u;
}
//----------------------------------------------------------------------------
function mix( u, v, s )
{
if ( typeof s !== "number" ) {
throw "mix: the last paramter " + s + " must be a number";
}
if ( u.length != v.length ) {
throw "vector dimension mismatch";
}
var result = [];
for ( var i = 0; i < u.length; ++i ) {
result.push( (1.0 - s) * u[i] + s * v[i] );
}
return result;
}
//----------------------------------------------------------------------------
//
// Vector and Matrix functions
//
function scale( s, u )
{
if ( !Array.isArray(u) ) {
throw "scale: second parameter " + u + " is not a vector";
}
var result = [];
for ( var i = 0; i < u.length; ++i ) {
result.push( s * u[i] );
}
return result;
}
//----------------------------------------------------------------------------
//
//
//
function flatten( v )
{
if ( v.matrix === true ) {
v = transpose( v );
}
var n = v.length;
var elemsAreArrays = false;
if ( Array.isArray(v[0]) ) {
elemsAreArrays = true;
n *= v[0].length;
}
var floats = new Float32Array( n );
if ( elemsAreArrays ) {
var idx = 0;
for ( var i = 0; i < v.length; ++i ) {
for ( var j = 0; j < v[i].length; ++j ) {
floats[idx++] = v[i][j];
}
}
}
else {
for ( var i = 0; i < v.length; ++i ) {
floats[i] = v[i];
}
}
return floats;
}
//----------------------------------------------------------------------------
var sizeof = {
'vec2' : new Float32Array( flatten(vec2()) ).byteLength,
'vec3' : new Float32Array( flatten(vec3()) ).byteLength,
'vec4' : new Float32Array( flatten(vec4()) ).byteLength,
'mat2' : new Float32Array( flatten(mat2()) ).byteLength,
'mat3' : new Float32Array( flatten(mat3()) ).byteLength,
'mat4' : new Float32Array( flatten(mat4()) ).byteLength
};
// new functions 5/2/2015
// printing
function printm(m)
{
if(m.length == 2)
for(var i=0; i<m.length; i++)
console.log(m[i][0], m[i][1]);
else if(m.length == 3)
for(var i=0; i<m.length; i++)
console.log(m[i][0], m[i][1], m[i][2]);
else if(m.length == 4)
for(var i=0; i<m.length; i++)
console.log(m[i][0], m[i][1], m[i][2], m[i][3]);
}
// determinants
function det2(m)
{
return m[0][0]*m[1][1]-m[0][1]*m[1][0];
}
function det3(m)
{
var d = m[0][0]*m[1][1]*m[2][2]
+ m[0][1]*m[1][2]*m[2][0]
+ m[0][2]*m[2][1]*m[1][0]
- m[2][0]*m[1][1]*m[0][2]
- m[1][0]*m[0][1]*m[2][2]
- m[0][0]*m[1][2]*m[2][1]
;
return d;
}
function det4(m)
{
var m0 = [
vec3(m[1][1], m[1][2], m[1][3]),
vec3(m[2][1], m[2][2], m[2][3]),
vec3(m[3][1], m[3][2], m[3][3])
];
var m1 = [
vec3(m[1][0], m[1][2], m[1][3]),
vec3(m[2][0], m[2][2], m[2][3]),
vec3(m[3][0], m[3][2], m[3][3])
];
var m2 = [
vec3(m[1][0], m[1][1], m[1][3]),
vec3(m[2][0], m[2][1], m[2][3]),
vec3(m[3][0], m[3][1], m[3][3])
];
var m3 = [
vec3(m[1][0], m[1][1], m[1][2]),
vec3(m[2][0], m[2][1], m[2][2]),
vec3(m[3][0], m[3][1], m[3][2])
];
return m[0][0]*det3(m0) - m[0][1]*det3(m1)
+ m[0][2]*det3(m2) - m[0][3]*det3(m3);
}
function det(m)
{
if(m.matrix != true) console.log("not a matrix");
if(m.length == 2) return det2(m);
if(m.length == 3) return det3(m);
if(m.length == 4) return det4(m);
}
//---------------------------------------------------------
// inverses
function inverse2(m)
{
var a = mat2();
var d = det2(m);
a[0][0] = m[1][1]/d;
a[0][1] = -m[0][1]/d;
a[1][0] = -m[1][0]/d;
a[1][1] = m[0][0]/d;
a.matrix = true;
return a;
}
function inverse3(m)
{
var a = mat3();
var d = det3(m);
var a00 = [
vec2(m[1][1], m[1][2]),
vec2(m[2][1], m[2][2])
];
var a01 = [
vec2(m[1][0], m[1][2]),
vec2(m[2][0], m[2][2])
];
var a02 = [
vec2(m[1][0], m[1][1]),
vec2(m[2][0], m[2][1])
];
var a10 = [
vec2(m[0][1], m[0][2]),
vec2(m[2][1], m[2][2])
];
var a11 = [
vec2(m[0][0], m[0][2]),
vec2(m[2][0], m[2][2])
];
var a12 = [
vec2(m[0][0], m[0][1]),
vec2(m[2][0], m[2][1])
];
var a20 = [
vec2(m[0][1], m[0][2]),
vec2(m[1][1], m[1][2])
];
var a21 = [
vec2(m[0][0], m[0][2]),
vec2(m[1][0], m[1][2])
];
var a22 = [
vec2(m[0][0], m[0][1]),
vec2(m[1][0], m[1][1])
];
a[0][0] = det2(a00)/d;
a[0][1] = -det2(a10)/d;
a[0][2] = det2(a20)/d;
a[1][0] = -det2(a01)/d;
a[1][1] = det2(a11)/d;
a[1][2] = -det2(a21)/d;
a[2][0] = det2(a02)/d;
a[2][1] = -det2(a12)/d;
a[2][2] = det2(a22)/d;
return a;
}
function inverse4(m)
{
var a = mat4();
var d = det4(m);
var a00 = [
vec3(m[1][1], m[1][2], m[1][3]),
vec3(m[2][1], m[2][2], m[2][3]),
vec3(m[3][1], m[3][2], m[3][3])
];
var a01 = [
vec3(m[1][0], m[1][2], m[1][3]),
vec3(m[2][0], m[2][2], m[2][3]),
vec3(m[3][0], m[3][2], m[3][3])
];
var a02 = [
vec3(m[1][0], m[1][1], m[1][3]),
vec3(m[2][0], m[2][1], m[2][3]),
vec3(m[3][0], m[3][1], m[3][3])
];
var a03 = [
vec3(m[1][0], m[1][1], m[1][2]),
vec3(m[2][0], m[2][1], m[2][2]),
vec3(m[3][0], m[3][1], m[3][2])
];
var a10 = [
vec3(m[0][1], m[0][2], m[0][3]),
vec3(m[2][1], m[2][2], m[2][3]),
vec3(m[3][1], m[3][2], m[3][3])
];
var a11 = [
vec3(m[0][0], m[0][2], m[0][3]),
vec3(m[2][0], m[2][2], m[2][3]),
vec3(m[3][0], m[3][2], m[3][3])
];
var a12 = [
vec3(m[0][0], m[0][1], m[0][3]),
vec3(m[2][0], m[2][1], m[2][3]),
vec3(m[3][0], m[3][1], m[3][3])
];
var a13 = [
vec3(m[0][0], m[0][1], m[0][2]),
vec3(m[2][0], m[2][1], m[2][2]),
vec3(m[3][0], m[3][1], m[3][2])
];
var a20 = [
vec3(m[0][1], m[0][2], m[0][3]),
vec3(m[1][1], m[1][2], m[1][3]),
vec3(m[3][1], m[3][2], m[3][3])
];
var a21 = [
vec3(m[0][0], m[0][2], m[0][3]),
vec3(m[1][0], m[1][2], m[1][3]),
vec3(m[3][0], m[3][2], m[3][3])
];
var a22 = [
vec3(m[0][0], m[0][1], m[0][3]),
vec3(m[1][0], m[1][1], m[1][3]),
vec3(m[3][0], m[3][1], m[3][3])
];
var a23 = [
vec3(m[0][0], m[0][1], m[0][2]),
vec3(m[1][0], m[1][1], m[1][2]),
vec3(m[3][0], m[3][1], m[3][2])
];
var a30 = [
vec3(m[0][1], m[0][2], m[0][3]),
vec3(m[1][1], m[1][2], m[1][3]),
vec3(m[2][1], m[2][2], m[2][3])
];
var a31 = [
vec3(m[0][0], m[0][2], m[0][3]),
vec3(m[1][0], m[1][2], m[1][3]),
vec3(m[2][0], m[2][2], m[2][3])
];
var a32 = [
vec3(m[0][0], m[0][1], m[0][3]),
vec3(m[1][0], m[1][1], m[1][3]),
vec3(m[2][0], m[2][1], m[2][3])
];
var a33 = [
vec3(m[0][0], m[0][1], m[0][2]),
vec3(m[1][0], m[1][1], m[1][2]),
vec3(m[2][0], m[2][1], m[2][2])
];
a[0][0] = det3(a00)/d;
a[0][1] = -det3(a10)/d;
a[0][2] = det3(a20)/d;
a[0][3] = -det3(a30)/d;
a[1][0] = -det3(a01)/d;
a[1][1] = det3(a11)/d;
a[1][2] = -det3(a21)/d;
a[1][3] = det3(a31)/d;
a[2][0] = det3(a02)/d;
a[2][1] = -det3(a12)/d;
a[2][2] = det3(a22)/d;
a[2][3] = -det3(a32)/d;
a[3][0] = -det3(a03)/d;
a[3][1] = det3(a13)/d;
a[3][2] = -det3(a23)/d;
a[3][3] = det3(a33)/d;
return a;
}
function inverse(m)
{
if(m.matrix != true) console.log("not a matrix");
if(m.length == 2) return inverse2(m);
if(m.length == 3) return inverse3(m);
if(m.length == 4) return inverse4(m);
}
function normalMatrix(m, flag)
{
var a = mat4();
a = inverse(transpose(m));
if(flag != true) return a;
else {
var b = mat3();
for(var i=0;i<3;i++) for(var j=0; j<3; j++) b[i][j] = a[i][j];
return b;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yyf994/WireframeSuperellipsoid_Javascript.git
git@gitee.com:yyf994/WireframeSuperellipsoid_Javascript.git
yyf994
WireframeSuperellipsoid_Javascript
WireframeSuperellipsoid_Javascript
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385