Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wgpu-matrix

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wgpu-matrix - npm Package Compare versions

Comparing version 2.8.3 to 2.9.0

40

dist/2.x/mat4-impl.d.ts

@@ -246,2 +246,23 @@ import { Mat3 } from './mat3';

/**
* Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height
* of the frustum, the aspect ratio, and the near and far clipping planes. The
* arguments define a frustum extending in the negative z direction. The given
* angle is the vertical angle of the frustum, and the horizontal angle is
* determined to produce the given aspect ratio. The arguments near and far are
* the distances to the near and far clipping planes. Note that near and far
* are not z coordinates, but rather they are distances along the negative
* z-axis. The matrix generated sends the viewing frustum to the unit box.
* We assume a unit box extending from -1 to 1 in the x and y dimensions and
* from 1 (at -zNear) to 0 (at -zFar) in the z dimension.
*
* @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).
* @param aspect - The aspect ratio width / height.
* @param zNear - The depth (negative z coordinate)
* of the near clipping plane.
* @param zFar - The depth (negative z coordinate)
* of the far clipping plane. (default = Infinity)
* @param dst - matrix to hold result. If not passed a new one is created.
* @returns The perspective matrix.
*/ export declare function perspectiveReverseZ(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar?: number, dst?: Mat4): Mat4;
/**
* Computes a 4-by-4 orthogonal transformation matrix that transforms from

@@ -282,2 +303,21 @@ * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y

/**
* Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right,
* top, bottom, near and far clipping planes. The arguments define a frustum
* extending in the negative z direction. The arguments near and far are the
* distances to the near and far clipping planes. Note that near and far are not
* z coordinates, but rather they are distances along the negative z-axis. The
* matrix generated sends the viewing frustum to the unit box. We assume a unit
* box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z
* dimension.
* @param left - The x coordinate of the left plane of the box.
* @param right - The x coordinate of the right plane of the box.
* @param bottom - The y coordinate of the bottom plane of the box.
* @param top - The y coordinate of the right plane of the box.
* @param near - The negative z coordinate of the near plane of the box.
* @param far - The negative z coordinate of the far plane of the box.
* @param dst - Output matrix. If not passed a new one is created.
* @returns The perspective projection matrix.
*/
export declare function frustumReverseZ(left: number, right: number, bottom: number, top: number, near: number, far?: number, dst?: Mat4): Mat4;
/**
* Computes a 4-by-4 aim transformation.

@@ -284,0 +324,0 @@ *

31

dist/2.x/wgpu-matrix.min.js

@@ -1,2 +0,2 @@

/* wgpu-matrix@2.8.3, license MIT */
/* wgpu-matrix@2.9.0, license MIT */
(function(M,aa){"object"===typeof exports&&"undefined"!==typeof module?aa(exports):"function"===typeof define&&define.amd?define(["exports"],aa):(M="undefined"!==typeof globalThis?globalThis:M||self,aa(M.wgpuMatrix={}))})(this,function(M){function aa(a){const b=y;y=a;return b}function ba(a=0,b=0){const c=new y(2);void 0!==a&&(c[0]=a,void 0!==b&&(c[1]=b));return c}function Da(a){const b=u;u=a;return b}function H(a,b,c){const d=new u(3);void 0!==a&&(d[0]=a,void 0!==b&&(d[1]=b,void 0!==c&&(d[2]=c)));

@@ -40,16 +40,17 @@ return d}function Ea(a,b,c){c=c||new y(2);c[0]=a[0]-b[0];c[1]=a[1]-b[1];return c}function Fa(a,b,c,d){d=d||new y(2);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);return d}function qa(a,b,c){c=c||new y(2);c[0]=a[0]*b;c[1]=a[1]*b;return c}function Ga(a,b){b=b||new y(2);b[0]=1/a[0];b[1]=1/a[1];return b}function Ha(a,b){return a[0]*b[0]+a[1]*b[1]}function ra(a){const b=a[0];a=a[1];return Math.sqrt(b*b+a*a)}function Ia(a){const b=a[0];a=a[1];return b*b+a*a}function Ja(a,b){const c=a[0]-b[0];a=a[1]-b[1];

b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},fromQuat:function(a,b){b=b||new x(16);var c=a[0],d=a[1],e=a[2];a=a[3];var f=c+c,g=d+d;const h=e+e;c*=f;const l=d*f;d*=g;const k=e*f,m=e*g;e*=h;f*=a;g*=a;a*=h;b[0]=1-d-e;b[1]=l+a;b[2]=k-g;b[3]=0;b[4]=l-a;b[5]=1-c-e;b[6]=m+f;b[7]=0;b[8]=k+g;b[9]=m-f;b[10]=1-c-d;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},frustum:function(a,b,c,d,e,f,g){g=g||new x(16);const h=b-a,l=d-c,k=e-f;g[0]=2*e/h;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2*e/l;g[6]=0;g[7]=0;g[8]=(a+
b)/h;g[9]=(d+c)/l;g[10]=f/k;g[11]=-1;g[12]=0;g[13]=0;g[14]=e*f/k;g[15]=0;return g},getAxis:function(a,b,c){c=c||H();b*=4;c[0]=a[b+0];c[1]=a[b+1];c[2]=a[b+2];return c},getScaling:function(a,b){b=b||H();const c=a[0],d=a[1],e=a[2],f=a[4],g=a[5],h=a[6],l=a[8],k=a[9];a=a[10];b[0]=Math.sqrt(c*c+d*d+e*e);b[1]=Math.sqrt(f*f+g*g+h*h);b[2]=Math.sqrt(l*l+k*k+a*a);return b},getTranslation:function(a,b){b=b||H();b[0]=a[12];b[1]=a[13];b[2]=a[14];return b},identity:db,inverse:eb,invert:eb,lookAt:function(a,b,c,
d){d=d||new x(16);B=B||H();D=D||H();z=z||H();N(ca(a,b,z),z);N(P(c,z,B),B);N(P(z,B,D),D);d[0]=B[0];d[1]=D[0];d[2]=z[0];d[3]=0;d[4]=B[1];d[5]=D[1];d[6]=z[1];d[7]=0;d[8]=B[2];d[9]=D[2];d[10]=z[2];d[11]=0;d[12]=-(B[0]*a[0]+B[1]*a[1]+B[2]*a[2]);d[13]=-(D[0]*a[0]+D[1]*a[1]+D[2]*a[2]);d[14]=-(z[0]*a[0]+z[1]*a[1]+z[2]*a[2]);d[15]=1;return d},mul:hb,multiply:hb,negate:function(a,b){b=b||new x(16);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=-a[3];b[4]=-a[4];b[5]=-a[5];b[6]=-a[6];b[7]=-a[7];b[8]=-a[8];b[9]=-a[9];
b[10]=-a[10];b[11]=-a[11];b[12]=-a[12];b[13]=-a[13];b[14]=-a[14];b[15]=-a[15];return b},ortho:function(a,b,c,d,e,f,g){g=g||new x(16);g[0]=2/(b-a);g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2/(d-c);g[6]=0;g[7]=0;g[8]=0;g[9]=0;g[10]=1/(e-f);g[11]=0;g[12]=(b+a)/(a-b);g[13]=(d+c)/(c-d);g[14]=e/(e-f);g[15]=1;return g},perspective:function(a,b,c,d,e){e=e||new x(16);a=Math.tan(.5*Math.PI-.5*a);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[11]=-1;e[12]=0;e[13]=0;e[15]=0;Infinity===d?(e[10]=
-1,e[14]=-c):(b=1/(c-d),e[10]=d*b,e[14]=d*c*b);return e},rotate:jb,rotateX:function(a,b,c){c=c||new x(16);const d=a[4],e=a[5],f=a[6],g=a[7],h=a[8],l=a[9],k=a[10],m=a[11],n=Math.cos(b);b=Math.sin(b);c[4]=n*d+b*h;c[5]=n*e+b*l;c[6]=n*f+b*k;c[7]=n*g+b*m;c[8]=n*h-b*d;c[9]=n*l-b*e;c[10]=n*k-b*f;c[11]=n*m-b*g;a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},rotateY:function(a,b,c){c=c||new x(16);const d=a[0],e=a[1],f=a[2],g=a[3],h=a[8],l=a[9],k=a[10],
m=a[11],n=Math.cos(b);b=Math.sin(b);c[0]=n*d-b*h;c[1]=n*e-b*l;c[2]=n*f-b*k;c[3]=n*g-b*m;c[8]=n*h+b*d;c[9]=n*l+b*e;c[10]=n*k+b*f;c[11]=n*m+b*g;a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},rotateZ:function(a,b,c){c=c||new x(16);const d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],l=a[5],k=a[6],m=a[7],n=Math.cos(b);b=Math.sin(b);c[0]=n*d+b*h;c[1]=n*e+b*l;c[2]=n*f+b*k;c[3]=n*g+b*m;c[4]=n*h-b*d;c[5]=n*l-b*e;c[6]=n*k-b*f;c[7]=n*m-b*g;a!==c&&(c[8]=a[8],c[9]=
a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},rotation:ib,rotationX:function(a,b){b=b||new x(16);const c=Math.cos(a);a=Math.sin(a);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=c;b[6]=a;b[7]=0;b[8]=0;b[9]=-a;b[10]=c;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},rotationY:function(a,b){b=b||new x(16);const c=Math.cos(a);a=Math.sin(a);b[0]=c;b[1]=0;b[2]=-a;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=a;b[9]=0;b[10]=c;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},
rotationZ:function(a,b){b=b||new x(16);const c=Math.cos(a);a=Math.sin(a);b[0]=c;b[1]=a;b[2]=0;b[3]=0;b[4]=-a;b[5]=c;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},scale:function(a,b,c){c=c||new x(16);const d=b[0],e=b[1];b=b[2];c[0]=d*a[0];c[1]=d*a[1];c[2]=d*a[2];c[3]=d*a[3];c[4]=e*a[4];c[5]=e*a[5];c[6]=e*a[6];c[7]=e*a[7];c[8]=b*a[8];c[9]=b*a[9];c[10]=b*a[10];c[11]=b*a[11];a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},scaling:function(a,b){b=
b||new x(16);b[0]=a[0];b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=a[1];b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=a[2];b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},set:function(a,b,c,d,e,f,g,h,l,k,m,n,q,r,w,v,p){p=p||new x(16);p[0]=a;p[1]=b;p[2]=c;p[3]=d;p[4]=e;p[5]=f;p[6]=g;p[7]=h;p[8]=l;p[9]=k;p[10]=m;p[11]=n;p[12]=q;p[13]=r;p[14]=w;p[15]=v;return p},setAxis:function(a,b,c,d){d!==a&&(d=xa(a,d));a=4*c;d[a+0]=b[0];d[a+1]=b[1];d[a+2]=b[2];return d},setDefaultType:cb,setTranslation:function(a,b,c){c=c||db();a!==
c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11]);c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c},translate:function(a,b,c){c=c||new x(16);const d=b[0],e=b[1];b=b[2];const f=a[0],g=a[1],h=a[2],l=a[3],k=a[4],m=a[5],n=a[6],q=a[7],r=a[8],w=a[9],v=a[10],p=a[11],E=a[12],F=a[13],I=a[14],J=a[15];a!==c&&(c[0]=f,c[1]=g,c[2]=h,c[3]=l,c[4]=k,c[5]=m,c[6]=n,c[7]=q,c[8]=r,c[9]=w,c[10]=v,c[11]=p);c[12]=f*d+k*e+r*b+E;c[13]=g*d+m*e+
w*b+F;c[14]=h*d+n*e+v*b+I;c[15]=l*d+q*e+p*b+J;return c},translation:function(a,b){b=b||new x(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=a[0];b[13]=a[1];b[14]=a[2];b[15]=1;return b},transpose:function(a,b){b=b||new x(16);if(b===a){var c=a[1];a[1]=a[4];a[4]=c;c=a[2];a[2]=a[8];a[8]=c;c=a[3];a[3]=a[12];a[12]=c;c=a[6];a[6]=a[9];a[9]=c;c=a[7];a[7]=a[13];a[13]=c;c=a[11];a[11]=a[14];a[14]=c;return b}c=a[1];const d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],
k=a[8],m=a[9],n=a[10],q=a[11],r=a[12],w=a[13],v=a[14],p=a[15];b[0]=a[0];b[1]=f;b[2]=k;b[3]=r;b[4]=c;b[5]=g;b[6]=m;b[7]=w;b[8]=d;b[9]=h;b[10]=n;b[11]=v;b[12]=e;b[13]=l;b[14]=q;b[15]=p;return b},uniformScale:function(a,b,c){c=c||new x(16);c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];c[3]=b*a[3];c[4]=b*a[4];c[5]=b*a[5];c[6]=b*a[6];c[7]=b*a[7];c[8]=b*a[8];c[9]=b*a[9];c[10]=b*a[10];c[11]=b*a[11];a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},uniformScaling:function(a,b){b=b||new x(16);b[0]=
a;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=a;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=a;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b}};let C=Float32Array,O,Ba,Ca,oa,pa;var Kb={__proto__:null,add:function(a,b,c){c=c||new C(4);c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];return c},angle:function(a,b){a=rb(a,b);return Math.acos(2*a*a-1)},clone:ob,conjugate:function(a,b){b=b||new C(4);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b},copy:ob,create:lb,divScalar:function(a,b,c){c=c||new C(4);c[0]=
a[0]/b;c[1]=a[1]/b;c[2]=a[2]/b;c[3]=a[3]/b;return c},dot:rb,equals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]},equalsApproximately:function(a,b){return Math.abs(a[0]-b[0])<t&&Math.abs(a[1]-b[1])<t&&Math.abs(a[2]-b[2])<t&&Math.abs(a[3]-b[3])<t},fromAxisAngle:mb,fromEuler:function(a,b,c,d,e){e=e||new C(4);a*=.5;var f=.5*b;b=.5*c;c=Math.sin(a);a=Math.cos(a);const g=Math.sin(f);f=Math.cos(f);const h=Math.sin(b);b=Math.cos(b);switch(d){case "xyz":e[0]=c*f*b+a*g*h;e[1]=a*g*
b-c*f*h;e[2]=a*f*h+c*g*b;e[3]=a*f*b-c*g*h;break;case "xzy":e[0]=c*f*b-a*g*h;e[1]=a*g*b-c*f*h;e[2]=a*f*h+c*g*b;e[3]=a*f*b+c*g*h;break;case "yxz":e[0]=c*f*b+a*g*h;e[1]=a*g*b-c*f*h;e[2]=a*f*h-c*g*b;e[3]=a*f*b+c*g*h;break;case "yzx":e[0]=c*f*b+a*g*h;e[1]=a*g*b+c*f*h;e[2]=a*f*h-c*g*b;e[3]=a*f*b-c*g*h;break;case "zxy":e[0]=c*f*b-a*g*h;e[1]=a*g*b+c*f*h;e[2]=a*f*h+c*g*b;e[3]=a*f*b-c*g*h;break;case "zyx":e[0]=c*f*b-a*g*h;e[1]=a*g*b+c*f*h;e[2]=a*f*h-c*g*b;e[3]=a*f*b+c*g*h;break;default:throw Error(`Unknown rotation order: ${d}`);
b)/h;g[9]=(d+c)/l;g[10]=f/k;g[11]=-1;g[12]=0;g[13]=0;g[14]=e*f/k;g[15]=0;return g},frustumReverseZ:function(a,b,c,d,e,f=Infinity,g){g=g||new x(16);const h=b-a,l=d-c;g[0]=2*e/h;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2*e/l;g[6]=0;g[7]=0;g[8]=(a+b)/h;g[9]=(d+c)/l;g[11]=-1;g[12]=0;g[13]=0;g[15]=0;Infinity===f?(g[10]=0,g[14]=e):(a=1/(f-e),g[10]=e*a,g[14]=f*e*a);return g},getAxis:function(a,b,c){c=c||H();b*=4;c[0]=a[b+0];c[1]=a[b+1];c[2]=a[b+2];return c},getScaling:function(a,b){b=b||H();const c=a[0],d=a[1],
e=a[2],f=a[4],g=a[5],h=a[6],l=a[8],k=a[9];a=a[10];b[0]=Math.sqrt(c*c+d*d+e*e);b[1]=Math.sqrt(f*f+g*g+h*h);b[2]=Math.sqrt(l*l+k*k+a*a);return b},getTranslation:function(a,b){b=b||H();b[0]=a[12];b[1]=a[13];b[2]=a[14];return b},identity:db,inverse:eb,invert:eb,lookAt:function(a,b,c,d){d=d||new x(16);B=B||H();D=D||H();z=z||H();N(ca(a,b,z),z);N(P(c,z,B),B);N(P(z,B,D),D);d[0]=B[0];d[1]=D[0];d[2]=z[0];d[3]=0;d[4]=B[1];d[5]=D[1];d[6]=z[1];d[7]=0;d[8]=B[2];d[9]=D[2];d[10]=z[2];d[11]=0;d[12]=-(B[0]*a[0]+B[1]*
a[1]+B[2]*a[2]);d[13]=-(D[0]*a[0]+D[1]*a[1]+D[2]*a[2]);d[14]=-(z[0]*a[0]+z[1]*a[1]+z[2]*a[2]);d[15]=1;return d},mul:hb,multiply:hb,negate:function(a,b){b=b||new x(16);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=-a[3];b[4]=-a[4];b[5]=-a[5];b[6]=-a[6];b[7]=-a[7];b[8]=-a[8];b[9]=-a[9];b[10]=-a[10];b[11]=-a[11];b[12]=-a[12];b[13]=-a[13];b[14]=-a[14];b[15]=-a[15];return b},ortho:function(a,b,c,d,e,f,g){g=g||new x(16);g[0]=2/(b-a);g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2/(d-c);g[6]=0;g[7]=0;g[8]=0;g[9]=0;g[10]=1/(e-
f);g[11]=0;g[12]=(b+a)/(a-b);g[13]=(d+c)/(c-d);g[14]=e/(e-f);g[15]=1;return g},perspective:function(a,b,c,d,e){e=e||new x(16);a=Math.tan(.5*Math.PI-.5*a);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[11]=-1;e[12]=0;e[13]=0;e[15]=0;Number.isFinite(d)?(b=1/(c-d),e[10]=d*b,e[14]=d*c*b):(e[10]=-1,e[14]=-c);return e},perspectiveReverseZ:function(a,b,c,d=Infinity,e){e=e||new x(16);a=1/Math.tan(.5*a);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[11]=
-1;e[12]=0;e[13]=0;e[15]=0;Infinity===d?(e[10]=0,e[14]=c):(b=1/(d-c),e[10]=c*b,e[14]=d*c*b);return e},rotate:jb,rotateX:function(a,b,c){c=c||new x(16);const d=a[4],e=a[5],f=a[6],g=a[7],h=a[8],l=a[9],k=a[10],m=a[11],n=Math.cos(b);b=Math.sin(b);c[4]=n*d+b*h;c[5]=n*e+b*l;c[6]=n*f+b*k;c[7]=n*g+b*m;c[8]=n*h-b*d;c[9]=n*l-b*e;c[10]=n*k-b*f;c[11]=n*m-b*g;a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},rotateY:function(a,b,c){c=c||new x(16);const d=
a[0],e=a[1],f=a[2],g=a[3],h=a[8],l=a[9],k=a[10],m=a[11],n=Math.cos(b);b=Math.sin(b);c[0]=n*d-b*h;c[1]=n*e-b*l;c[2]=n*f-b*k;c[3]=n*g-b*m;c[8]=n*h+b*d;c[9]=n*l+b*e;c[10]=n*k+b*f;c[11]=n*m+b*g;a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},rotateZ:function(a,b,c){c=c||new x(16);const d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],l=a[5],k=a[6],m=a[7],n=Math.cos(b);b=Math.sin(b);c[0]=n*d+b*h;c[1]=n*e+b*l;c[2]=n*f+b*k;c[3]=n*g+b*m;c[4]=n*h-b*d;c[5]=n*l-b*
e;c[6]=n*k-b*f;c[7]=n*m-b*g;a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},rotation:ib,rotationX:function(a,b){b=b||new x(16);const c=Math.cos(a);a=Math.sin(a);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=c;b[6]=a;b[7]=0;b[8]=0;b[9]=-a;b[10]=c;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},rotationY:function(a,b){b=b||new x(16);const c=Math.cos(a);a=Math.sin(a);b[0]=c;b[1]=0;b[2]=-a;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=a;b[9]=0;b[10]=
c;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},rotationZ:function(a,b){b=b||new x(16);const c=Math.cos(a);a=Math.sin(a);b[0]=c;b[1]=a;b[2]=0;b[3]=0;b[4]=-a;b[5]=c;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},scale:function(a,b,c){c=c||new x(16);const d=b[0],e=b[1];b=b[2];c[0]=d*a[0];c[1]=d*a[1];c[2]=d*a[2];c[3]=d*a[3];c[4]=e*a[4];c[5]=e*a[5];c[6]=e*a[6];c[7]=e*a[7];c[8]=b*a[8];c[9]=b*a[9];c[10]=b*a[10];c[11]=b*a[11];a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=
a[14],c[15]=a[15]);return c},scaling:function(a,b){b=b||new x(16);b[0]=a[0];b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=a[1];b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=a[2];b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},set:function(a,b,c,d,e,f,g,h,l,k,m,n,q,r,w,v,p){p=p||new x(16);p[0]=a;p[1]=b;p[2]=c;p[3]=d;p[4]=e;p[5]=f;p[6]=g;p[7]=h;p[8]=l;p[9]=k;p[10]=m;p[11]=n;p[12]=q;p[13]=r;p[14]=w;p[15]=v;return p},setAxis:function(a,b,c,d){d!==a&&(d=xa(a,d));a=4*c;d[a+0]=b[0];d[a+1]=b[1];d[a+2]=b[2];return d},setDefaultType:cb,
setTranslation:function(a,b,c){c=c||db();a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11]);c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c},translate:function(a,b,c){c=c||new x(16);const d=b[0],e=b[1];b=b[2];const f=a[0],g=a[1],h=a[2],l=a[3],k=a[4],m=a[5],n=a[6],q=a[7],r=a[8],w=a[9],v=a[10],p=a[11],E=a[12],F=a[13],I=a[14],J=a[15];a!==c&&(c[0]=f,c[1]=g,c[2]=h,c[3]=l,c[4]=k,c[5]=m,c[6]=n,c[7]=q,c[8]=r,c[9]=w,c[10]=
v,c[11]=p);c[12]=f*d+k*e+r*b+E;c[13]=g*d+m*e+w*b+F;c[14]=h*d+n*e+v*b+I;c[15]=l*d+q*e+p*b+J;return c},translation:function(a,b){b=b||new x(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=a[0];b[13]=a[1];b[14]=a[2];b[15]=1;return b},transpose:function(a,b){b=b||new x(16);if(b===a){var c=a[1];a[1]=a[4];a[4]=c;c=a[2];a[2]=a[8];a[8]=c;c=a[3];a[3]=a[12];a[12]=c;c=a[6];a[6]=a[9];a[9]=c;c=a[7];a[7]=a[13];a[13]=c;c=a[11];a[11]=a[14];a[14]=c;return b}c=a[1];const d=
a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],q=a[11],r=a[12],w=a[13],v=a[14],p=a[15];b[0]=a[0];b[1]=f;b[2]=k;b[3]=r;b[4]=c;b[5]=g;b[6]=m;b[7]=w;b[8]=d;b[9]=h;b[10]=n;b[11]=v;b[12]=e;b[13]=l;b[14]=q;b[15]=p;return b},uniformScale:function(a,b,c){c=c||new x(16);c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];c[3]=b*a[3];c[4]=b*a[4];c[5]=b*a[5];c[6]=b*a[6];c[7]=b*a[7];c[8]=b*a[8];c[9]=b*a[9];c[10]=b*a[10];c[11]=b*a[11];a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c},uniformScaling:function(a,
b){b=b||new x(16);b[0]=a;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=a;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=a;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b}};let C=Float32Array,O,Ba,Ca,oa,pa;var Kb={__proto__:null,add:function(a,b,c){c=c||new C(4);c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];return c},angle:function(a,b){a=rb(a,b);return Math.acos(2*a*a-1)},clone:ob,conjugate:function(a,b){b=b||new C(4);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b},copy:ob,create:lb,divScalar:function(a,
b,c){c=c||new C(4);c[0]=a[0]/b;c[1]=a[1]/b;c[2]=a[2]/b;c[3]=a[3]/b;return c},dot:rb,equals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]},equalsApproximately:function(a,b){return Math.abs(a[0]-b[0])<t&&Math.abs(a[1]-b[1])<t&&Math.abs(a[2]-b[2])<t&&Math.abs(a[3]-b[3])<t},fromAxisAngle:mb,fromEuler:function(a,b,c,d,e){e=e||new C(4);a*=.5;var f=.5*b;b=.5*c;c=Math.sin(a);a=Math.cos(a);const g=Math.sin(f);f=Math.cos(f);const h=Math.sin(b);b=Math.cos(b);switch(d){case "xyz":e[0]=
c*f*b+a*g*h;e[1]=a*g*b-c*f*h;e[2]=a*f*h+c*g*b;e[3]=a*f*b-c*g*h;break;case "xzy":e[0]=c*f*b-a*g*h;e[1]=a*g*b-c*f*h;e[2]=a*f*h+c*g*b;e[3]=a*f*b+c*g*h;break;case "yxz":e[0]=c*f*b+a*g*h;e[1]=a*g*b-c*f*h;e[2]=a*f*h-c*g*b;e[3]=a*f*b+c*g*h;break;case "yzx":e[0]=c*f*b+a*g*h;e[1]=a*g*b+c*f*h;e[2]=a*f*h-c*g*b;e[3]=a*f*b-c*g*h;break;case "zxy":e[0]=c*f*b-a*g*h;e[1]=a*g*b+c*f*h;e[2]=a*f*h+c*g*b;e[3]=a*f*b-c*g*h;break;case "zyx":e[0]=c*f*b-a*g*h;e[1]=a*g*b+c*f*h;e[2]=a*f*h-c*g*b;e[3]=a*f*b+c*g*h;break;default:throw Error(`Unknown rotation order: ${d}`);
}return e},fromMat:function(a,b){b=b||new C(4);var c=a[0]+a[5]+a[10];if(0<c)c=Math.sqrt(c+1),b[3]=.5*c,c=.5/c,b[0]=(a[6]-a[9])*c,b[1]=(a[8]-a[2])*c,b[2]=(a[1]-a[4])*c;else{c=0;a[5]>a[0]&&(c=1);a[10]>a[4*c+c]&&(c=2);const e=(c+1)%3,f=(c+2)%3;var d=Math.sqrt(a[4*c+c]-a[4*e+e]-a[4*f+f]+1);b[c]=.5*d;d=.5/d;b[3]=(a[4*e+f]-a[4*f+e])*d;b[e]=(a[4*e+c]+a[4*c+e])*d;b[f]=(a[4*f+c]+a[4*c+f])*d}return b},fromValues:lb,identity:function(a){a=a||new C(4);a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a},inverse:function(a,

@@ -56,0 +57,0 @@ b){b=b||new C(4);const c=a[0],d=a[1],e=a[2];a=a[3];var f=c*c+d*d+e*e+a*a;f=f?1/f:0;b[0]=-c*f;b[1]=-d*f;b[2]=-e*f;b[3]=a*f;return b},len:sb,lenSq:tb,length:sb,lengthSq:tb,lerp:function(a,b,c,d){d=d||new C(4);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);d[2]=a[2]+c*(b[2]-a[2]);d[3]=a[3]+c*(b[3]-a[3]);return d},mul:nb,mulScalar:qb,multiply:nb,normalize:ub,rotateX:function(a,b,c){c=c||new C(4);var d=.5*b;b=a[0];const e=a[1],f=a[2];a=a[3];const g=Math.sin(d);d=Math.cos(d);c[0]=b*d+a*g;c[1]=e*d+f*g;

{
"name": "wgpu-matrix",
"version": "2.8.3",
"version": "2.9.0",
"description": "fast matrix math library for WebGPU",

@@ -5,0 +5,0 @@ "main": "dist/2.x/wgpu-matrix.module.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc