UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

2 lines (1 loc) 3.61 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=require("./common.js"),r={create:function(){var r=new t.GLMAT_ARRAY_TYPE(9);return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},fromMat4:function(t,r){return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[4],t[4]=r[5],t[5]=r[6],t[6]=r[8],t[7]=r[9],t[8]=r[10],t},clone:function(r){var n=new t.GLMAT_ARRAY_TYPE(9);return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n},copy:function(t,r){return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},transpose:function(t,r){if(t===r){var n=r[1],e=r[2],o=r[5];t[1]=r[3],t[2]=r[6],t[3]=n,t[5]=r[7],t[6]=e,t[7]=o}else t[0]=r[0],t[1]=r[3],t[2]=r[6],t[3]=r[1],t[4]=r[4],t[5]=r[7],t[6]=r[2],t[7]=r[5],t[8]=r[8];return t},invert:function(t,r){var n=r[0],e=r[1],o=r[2],u=r[3],a=r[4],i=r[5],c=r[6],f=r[7],l=r[8],M=l*a-i*f,v=-l*u+i*c,p=f*u-a*c,s=n*M+e*v+o*p;return s?(s=1/s,t[0]=M*s,t[1]=(-l*e+o*f)*s,t[2]=(i*e-o*a)*s,t[3]=v*s,t[4]=(l*n-o*c)*s,t[5]=(-i*n+o*u)*s,t[6]=p*s,t[7]=(-f*n+e*c)*s,t[8]=(a*n-e*u)*s,t):null},adjoint:function(t,r){var n=r[0],e=r[1],o=r[2],u=r[3],a=r[4],i=r[5],c=r[6],f=r[7],l=r[8];return t[0]=a*l-i*f,t[1]=o*f-e*l,t[2]=e*i-o*a,t[3]=i*c-u*l,t[4]=n*l-o*c,t[5]=o*u-n*i,t[6]=u*f-a*c,t[7]=e*c-n*f,t[8]=n*a-e*u,t},determinant:function(t){var r=t[0],n=t[1],e=t[2],o=t[3],u=t[4],a=t[5],i=t[6],c=t[7],f=t[8];return r*(f*u-a*c)+n*(-f*o+a*i)+e*(c*o-u*i)},multiply:function(t,r,n){var e=r[0],o=r[1],u=r[2],a=r[3],i=r[4],c=r[5],f=r[6],l=r[7],M=r[8],v=n[0],p=n[1],s=n[2],h=n[3],m=n[4],w=n[5],d=n[6],A=n[7],_=n[8];return t[0]=v*e+p*a+s*f,t[1]=v*o+p*i+s*l,t[2]=v*u+p*c+s*M,t[3]=h*e+m*a+w*f,t[4]=h*o+m*i+w*l,t[5]=h*u+m*c+w*M,t[6]=d*e+A*a+_*f,t[7]=d*o+A*i+_*l,t[8]=d*u+A*c+_*M,t}};r.mul=r.multiply,r.translate=function(t,r,n){var e=r[0],o=r[1],u=r[2],a=r[3],i=r[4],c=r[5],f=r[6],l=r[7],M=r[8],v=n[0],p=n[1];return t[0]=e,t[1]=o,t[2]=u,t[3]=a,t[4]=i,t[5]=c,t[6]=v*e+p*a+f,t[7]=v*o+p*i+l,t[8]=v*u+p*c+M,t},r.rotate=function(t,r,n){var e=r[0],o=r[1],u=r[2],a=r[3],i=r[4],c=r[5],f=r[6],l=r[7],M=r[8],v=Math.sin(n),p=Math.cos(n);return t[0]=p*e+v*a,t[1]=p*o+v*i,t[2]=p*u+v*c,t[3]=p*a-v*e,t[4]=p*i-v*o,t[5]=p*c-v*u,t[6]=f,t[7]=l,t[8]=M,t},r.scale=function(t,r,n){var e=n[0],o=n[1];return t[0]=e*r[0],t[1]=e*r[1],t[2]=e*r[2],t[3]=o*r[3],t[4]=o*r[4],t[5]=o*r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t},r.fromMat2d=function(t,r){return t[0]=r[0],t[1]=r[1],t[2]=0,t[3]=r[2],t[4]=r[3],t[5]=0,t[6]=r[4],t[7]=r[5],t[8]=1,t},r.fromQuat=function(t,r){var n=r[0],e=r[1],o=r[2],u=r[3],a=n+n,i=e+e,c=o+o,f=n*a,l=e*a,M=e*i,v=o*a,p=o*i,s=o*c,h=u*a,m=u*i,w=u*c;return t[0]=1-M-s,t[3]=l-w,t[6]=v+m,t[1]=l+w,t[4]=1-f-s,t[7]=p-h,t[2]=v-m,t[5]=p+h,t[8]=1-f-M,t},r.normalFromMat4=function(t,r){var n=r[0],e=r[1],o=r[2],u=r[3],a=r[4],i=r[5],c=r[6],f=r[7],l=r[8],M=r[9],v=r[10],p=r[11],s=r[12],h=r[13],m=r[14],w=r[15],d=n*i-e*a,A=n*c-o*a,_=n*f-u*a,y=e*c-o*i,T=e*f-u*i,R=o*f-u*c,Y=l*h-M*s,b=l*m-v*s,j=l*w-p*s,P=M*m-v*h,g=M*w-p*h,q=v*w-p*m,x=d*q-A*g+_*P+y*j-T*b+R*Y;return x?(x=1/x,t[0]=(i*q-c*g+f*P)*x,t[1]=(c*j-a*q-f*b)*x,t[2]=(a*g-i*j+f*Y)*x,t[3]=(o*g-e*q-u*P)*x,t[4]=(n*q-o*j+u*b)*x,t[5]=(e*j-n*g-u*Y)*x,t[6]=(h*R-m*T+w*y)*x,t[7]=(m*_-s*R-w*A)*x,t[8]=(s*T-h*_+w*d)*x,t):null},r.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))};var n=r;exports.default=n;