@vertexvis/geometry
Advanced tools
Comparing version 0.21.1-testing.0 to 0.21.1-testing.1
@@ -1,2 +0,2 @@ | ||
function t(t,n,r){return Math.max(n,Math.min(r,t))}function n(n,r,e){return(e=t(e,0,1))*(r-n)+n}function r(t,n){return void 0===t&&(t=0),void 0===n&&(n=0),{x:t,y:n}}function e(t,n){return{x:t.x-n.x,y:t.y-n.y}}function a(t,n){return{x:t.x+n.x,y:t.y+n.y}}function i(t,n){return t.x===n.x&&t.y===n.y}function o(t,n){return{x:t.x*n,y:t.y*n}}function u(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function c(t){var n=u(t);return 0===n?r(0,0):o(t,1/n)}function h(t,n){return c(e(n,t))}var f=Object.freeze({__proto__:null,create:r,polar:function(t,n){return r(Math.cos(n)*t,Math.sin(n)*t)},distance:function(t,n){var r=e(t,n);return Math.sqrt(r.x*r.x+r.y*r.y)},subtract:e,add:a,isEqual:i,lerp:function(t,r,e){return{x:n(t.x,r.x,e),y:n(t.y,r.y,e)}},negate:function(t){return r(-t.x,-t.y)},scale:function(t,n,r){return{x:t.x*n,y:t.y*r}},scaleProportional:o,magnitude:u,normalizeVector:c,normalDirectionVector:h,orthogonalVector:function(t,n){var e=h(t,n);return 0===e.x||0===e.y?r(-1*e.y,e.x):Math.abs(e.x)>Math.abs(e.y)?c(r(1-Math.pow(e.x,2),-1*e.x*e.y)):c(r(-1*e.x*e.y,1-Math.pow(e.y,2)))},fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?r(n[0],n[1]):r(n.x,n.y)}});function y(t){return(t+3600)%360}function x(t){return t*(180/Math.PI)}function m(t){return t*(Math.PI/180)}var s=Object.freeze({__proto__:null,fromPoints:function(t,n){var r=e(n,t);return Math.atan2(r.y,r.x)},fromPointsInDegrees:function(t,n){var r=e(n,t);return y(x(Math.atan2(r.y,r.x))-270)},normalize:y,normalizeRadians:function(t){return m(y(x(t)))},toDegrees:x,toRadians:m}),d=function(){return d=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a]);return t},d.apply(this,arguments)}; | ||
function t(t,n,r){return Math.max(n,Math.min(r,t))}function n(n,r,e){return(e=t(e,0,1))*(r-n)+n}function r(t,n){return void 0===t&&(t=0),void 0===n&&(n=0),{x:t,y:n}}function e(t,n){return{x:t.x-n.x,y:t.y-n.y}}function a(t,n){return{x:t.x+n.x,y:t.y+n.y}}function i(t,n){return t.x===n.x&&t.y===n.y}function o(t,n){return{x:t.x*n,y:t.y*n}}function u(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function c(t){var n=u(t);return 0===n?r(0,0):o(t,1/n)}function h(t,n){return c(e(n,t))}var f=Object.freeze({__proto__:null,create:r,polar:function(t,n){return r(Math.cos(n)*t,Math.sin(n)*t)},distance:function(t,n){var r=e(t,n);return Math.sqrt(r.x*r.x+r.y*r.y)},subtract:e,add:a,isEqual:i,lerp:function(t,r,e){return{x:n(t.x,r.x,e),y:n(t.y,r.y,e)}},negate:function(t){return r(-t.x,-t.y)},scale:function(t,n,r){return{x:t.x*n,y:t.y*r}},scaleProportional:o,magnitude:u,normalizeVector:c,normalDirectionVector:h,orthogonalVector:function(t,n){var e=h(t,n);return 0===e.x||0===e.y?r(-1*e.y,e.x):Math.abs(e.x)>Math.abs(e.y)?c(r(1-Math.pow(e.x,2),-1*e.x*e.y)):c(r(-1*e.x*e.y,1-Math.pow(e.y,2)))},fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?r(n[0],n[1]):r(n.x,n.y)}});function y(t){return(t+3600)%360}function m(t){return t*(180/Math.PI)}function x(t){return t*(Math.PI/180)}var s=Object.freeze({__proto__:null,fromPoints:function(t,n){var r=e(n,t);return Math.atan2(r.y,r.x)},fromPointsInDegrees:function(t,n){var r=e(n,t);return y(m(Math.atan2(r.y,r.x))-270)},normalize:y,normalizeRadians:function(t){return x(y(m(t)))},toDegrees:m,toRadians:x}),d=function(){return d=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a]);return t},d.apply(this,arguments)}; | ||
/*! ***************************************************************************** | ||
@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function l(t,n,r){if(r||2===arguments.length)for(var e,a=0,i=n.length;a<i;a++)!e&&a in n||(e||(e=Array.prototype.slice.call(n,0,a)),e[a]=n[a]);return t.concat(e||Array.prototype.slice.call(n))}function z(t,n,r,e,a,i,o,u,c,h,f,y,x,m,s,d){return[t,a,c,x,n,i,h,m,r,o,f,s,e,u,y,d]}function v(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function M(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}function g(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1]}function w(t){var n=t.x,r=t.y,e=t.z,a=t.w,i=n+n,o=r+r,u=e+e,c=n*i,h=n*o,f=n*u,y=r*o,x=r*u,m=e*u,s=a*i,d=a*o,l=a*u;return[1-(y+m),h+l,f-d,0,h-l,1-(c+m),x+s,0,f+d,x-s,1-(c+y),0,0,0,0,1]}function p(t){return[t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1]}function _(t,n,r,e,a,i){return[2*a/(n-t),0,0,0,0,2*a/(r-e),0,0,(n+t)/(n-t),(r+e)/(r-e),-(i+a)/(i-a),-1,0,0,-2*i*a/(i-a),0]}function b(t,n){var r=t,e=n,a=r[0],i=r[4],o=r[8],u=r[12],c=r[1],h=r[5],f=r[9],y=r[13],x=r[2],m=r[6],s=r[10],d=r[14],l=r[3],z=r[7],v=r[11],M=r[15],g=e[0],w=e[4],p=e[8],_=e[12],b=e[1],O=e[5],P=e[9],A=e[13],k=e[2],j=e[6],q=e[10],S=e[14],R=e[3],T=e[7],J=e[11],N=e[15],F=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return F[0]=a*g+i*b+o*k+u*R,F[4]=a*w+i*O+o*j+u*T,F[8]=a*p+i*P+o*q+u*J,F[12]=a*_+i*A+o*S+u*N,F[1]=c*g+h*b+f*k+y*R,F[5]=c*w+h*O+f*j+y*T,F[9]=c*p+h*P+f*q+y*J,F[13]=c*_+h*A+f*S+y*N,F[2]=x*g+m*b+s*k+d*R,F[6]=x*w+m*O+s*j+d*T,F[10]=x*p+m*P+s*q+d*J,F[14]=x*_+m*A+s*S+d*N,F[3]=l*g+z*b+v*k+M*R,F[7]=l*w+z*O+v*j+M*T,F[11]=l*p+z*P+v*q+M*J,F[15]=l*_+z*A+v*S+M*N,F}function O(t){return{m11:t[0],m12:t[4],m13:t[8],m14:t[12],m21:t[1],m22:t[5],m23:t[9],m24:t[13],m31:t[2],m32:t[6],m33:t[10],m34:t[14],m41:t[3],m42:t[7],m43:t[11],m44:t[15]}}var P=Object.freeze({__proto__:null,fromValues:z,fromObject:function(t){return z(t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44)},makeIdentity:v,makeZero:M,makeTranslation:g,makeRotation:w,makeScale:p,makeTRS:function(t,n,r){var e=g(t),a=w(n),i=p(r);return b(b(e,a),i)},makeBasis:function(t,n,r){return[t.x,t.y,t.z,0,n.x,n.y,n.z,0,r.x,r.y,r.z,0,0,0,0,1]},makeRotationAxis:function(t,n){var r=Math.cos(n),e=Math.sin(n),a=1-r,i=t.x,o=t.y,u=t.z,c=a*i,h=a*o;return[c*i+r,c*o+e*u,c*u-e*o,0,c*o-e*u,h*o+r,h*u+e*i,0,c*u+e*o,h*u-e*i,a*u*u+r,0,0,0,0,1]},makeFrustum:_,makePerspective:function(t,n,r,e){var a=t*Math.tan(m(r/2)),i=a*e;return _(-i,i,a,-a,t,n)},makeOrthographic:function(t,n,r,e,a,i){var o=1/(n-t),u=1/(e-r),c=1/(i-a);return[2*o,0,0,-((n+t)*o),0,2*u,0,-((e+r)*u),0,0,-2*c,-((i+a)*c),0,0,0,1]},makeLookAtView:function(t,n,r){var e=E(Q(t,n)),a=E(B(r,e)),i=B(e,a),o=-Z(a,t),u=-Z(i,t),c=-Z(e,t);return[a.x,i.x,e.x,0,a.y,i.y,e.y,0,a.z,i.z,e.z,0,o,u,c,1]},makeLookAt:function(t,n,r){var e=E(Q(t,n)),a=E(B(r,e)),i=B(e,a);return[a.x,a.y,a.z,0,i.x,i.y,i.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,1]},invert:function(t){var n=t[0],r=t[1],e=t[2],a=t[3],i=t[4],o=t[5],u=t[6],c=t[7],h=t[8],f=t[9],y=t[10],x=t[11],m=t[12],s=t[13],d=t[14],l=t[15],z=n*o-r*i,v=n*u-e*i,M=n*c-a*i,g=r*u-e*o,w=r*c-a*o,p=e*c-a*u,_=h*s-f*m,b=h*d-y*m,O=h*l-x*m,P=f*d-y*s,A=f*l-x*s,k=y*l-x*d,j=z*k-v*A+M*P+g*O-w*b+p*_;return j?[(o*k-u*A+c*P)*(j=1/j),(e*A-r*k-a*P)*j,(s*p-d*w+l*g)*j,(y*w-f*p-x*g)*j,(u*O-i*k-c*b)*j,(n*k-e*O+a*b)*j,(d*M-m*p-l*v)*j,(h*p-y*M+x*v)*j,(i*A-o*O+c*_)*j,(r*O-n*A-a*_)*j,(m*w-s*M+l*z)*j,(f*M-h*w-x*z)*j,(o*b-i*P-u*_)*j,(n*P-r*b+e*_)*j,(s*v-m*g-d*z)*j,(h*g-f*v+y*z)*j]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},lookAt:function(t,n,r,e){var a=Q(n,r);0===L(a)&&(a=d(d({},a),{z:1}));var i=B(e,a=E(a));0===L(i)&&(i=B(e,a=E(a=1===Math.abs(e.z)?d(d({},a),{x:a.x+1e-4}):d(d({},a),{z:a.z+1e-4}))));var o=B(a,i=E(i)),u=l([],t,!0);return u[0]=i.x,u[4]=o.x,u[8]=a.x,u[1]=i.y,u[5]=o.y,u[9]=a.y,u[2]=i.z,u[6]=o.z,u[10]=a.z,u},multiply:b,transpose:function(t){return[t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]]},scale:function(t,n){var r=n.x,e=n.y,a=n.z,i=l([],t,!0);return i[0]*=r,i[4]*=e,i[8]*=a,i[1]*=r,i[5]*=e,i[9]*=a,i[2]*=r,i[6]*=e,i[10]*=a,i[3]*=r,i[7]*=e,i[11]*=a,i},position:function(t,n){var r=l([],t,!0);return r[12]=n[12],r[13]=n[13],r[14]=n[14],r},isIdentity:function(t){var n=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return t.every((function(t,r){return t===n[r]}))},toObject:O,isType:function(t){return Array.isArray(t)&&16===t.length}});function A(t){var n,r,e,a;return void 0===t&&(t={}),{x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(r=t.y)&&void 0!==r?r:0,z:null!==(e=t.z)&&void 0!==e?e:0,order:null!==(a=t.order)&&void 0!==a?a:"xyz"}}function k(n,r){void 0===r&&(r="xyz");var e=O(n),a=0,i=0,o=0;return"xyz"===r?(i=Math.asin(t(e.m13,-1,1)),Math.abs(e.m13)<.9999999?(a=Math.atan2(-e.m23,e.m33),o=Math.atan2(-e.m12,e.m11)):(a=Math.atan2(e.m32,e.m22),o=0)):"yxz"===r?(a=Math.asin(-t(e.m23,-1,1)),Math.abs(e.m23)<.9999999?(i=Math.atan2(e.m13,e.m33),o=Math.atan2(e.m21,e.m22)):(i=Math.atan2(-e.m31,e.m11),o=0)):"zxy"===r?(a=Math.asin(t(e.m32,-1,1)),Math.abs(e.m32)<.9999999?(i=Math.atan2(-e.m31,e.m33),o=Math.atan2(-e.m12,e.m22)):(i=0,o=Math.atan2(e.m21,e.m11))):"zyx"===r?(i=Math.asin(-t(e.m31,-1,1)),Math.abs(e.m31)<.9999999?(a=Math.atan2(e.m32,e.m33),o=Math.atan2(e.m21,e.m11)):(a=0,o=Math.atan2(-e.m12,e.m22))):"yzx"===r?(o=Math.asin(t(e.m21,-1,1)),Math.abs(e.m21)<.9999999?(a=Math.atan2(-e.m23,e.m22),i=Math.atan2(-e.m31,e.m11)):(a=0,i=Math.atan2(e.m13,e.m33))):"xzy"===r&&(o=Math.asin(-t(e.m12,-1,1)),Math.abs(e.m12)<.9999999?(a=Math.atan2(e.m32,e.m22),i=Math.atan2(e.m13,e.m11)):(a=Math.atan2(-e.m23,e.m33),i=0)),{x:a,y:i,z:o,order:r}}var j=Object.freeze({__proto__:null,create:A,fromDegrees:function(t){void 0===t&&(t={});var n=t.x,r=void 0===n?0:n,e=t.y,a=void 0===e?0:e,i=t.z,o=void 0===i?0:i,u=t.order;return A({x:m(r),y:m(a),z:m(o),order:u})},fromRotationMatrix:k,fromJson:function(t){var n=JSON.parse(t);if(Array.isArray(n)){var r=n[0],e=n[1],a=n[2],i=n[3];return{x:r,y:e,z:a,order:void 0===i?"xyz":i}}r=n.x,e=n.y,a=n.z;var o=n.order;return{x:r,y:e,z:a,order:void 0===o?"xyz":o}},isType:function(t){var n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("order")}});function q(t){return void 0===t&&(t={}),d({x:0,y:0,z:0,w:1},t)}function S(t){return T(1/R(t),t)}function R(t){return Math.sqrt(t.w*t.w+t.x*t.x+t.y*t.y+t.z*t.z)}function T(t,n){return q({w:n.w*t,x:n.x*t,y:n.y*t,z:n.z*t})}var J=Object.freeze({__proto__:null,create:q,fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?q({x:n[0],y:n[1],z:n[2],w:n[3]}):q(n)},normalize:S,magnitude:R,scale:T,fromAxisAngle:function(t,n){var r=n/2,e=Math.sin(r);return{x:t.x*e,y:t.y*e,z:t.z*e,w:Math.cos(r)}},fromMatrixRotation:function(t){var n,r=O(t),e=F(t),a=1/e.x,i=1/e.y,o=1/e.z,u=r.m11*a,c=r.m21*i,h=r.m31*o,f=r.m12*a,y=r.m22*i,x=r.m32*o,m=r.m13*a,s=r.m23*i,d=r.m33*o,l=u+y+d;return l>0?{x:(x-s)/(n=2*Math.sqrt(l+1)),y:(m-h)/n,z:(c-f)/n,w:.25*n}:u>y&&u>d?{x:.25*(n=2*Math.sqrt(1+u-y-d)),y:(c+f)/n,z:(m+h)/n,w:(x-s)/n}:y>d?{x:(c+f)/(n=2*Math.sqrt(1+y-u-d)),y:.25*n,z:(x+s)/n,w:(m-h)/n}:{x:(m+h)/(n=2*Math.sqrt(1+d-u-y)),y:(x+s)/n,z:.25*n,w:(c-f)/n}},fromEuler:function(t){var n=t.x,r=t.y,e=t.z,a=t.order,i=Math.cos(n/2),o=Math.cos(r/2),u=Math.cos(e/2),c=Math.sin(n/2),h=Math.sin(r/2),f=Math.sin(e/2),y=0,x=0,m=0,s=0;switch(a){case"xyz":y=c*o*u+i*h*f,x=i*h*u-c*o*f,m=i*o*f+c*h*u,s=i*o*u-c*h*f;break;case"yxz":y=c*o*u+i*h*f,x=i*h*u-c*o*f,m=i*o*f-c*h*u,s=i*o*u+c*h*f;break;case"zxy":y=c*o*u-i*h*f,x=i*h*u+c*o*f,m=i*o*f+c*h*u,s=i*o*u-c*h*f;break;case"zyx":y=c*o*u-i*h*f,x=i*h*u+c*o*f,m=i*o*f-c*h*u,s=i*o*u+c*h*f;break;case"yzx":y=c*o*u+i*h*f,x=i*h*u+c*o*f,m=i*o*f-c*h*u,s=i*o*u-c*h*f;break;case"xzy":y=c*o*u-i*h*f,x=i*h*u-c*o*f,m=i*o*f+c*h*u,s=i*o*u+c*h*f}return{x:y,y:x,z:m,w:s}},multiply:function(t,n){return{x:t.x*n.w+t.w*n.x+t.y*n.z-t.z*n.y,y:t.y*n.w+t.w*n.y+t.z*n.x-t.x*n.z,z:t.z*n.w+t.w*n.z+t.x*n.y-t.y*n.x,w:t.w*n.w-t.x*n.x-t.y*n.y-t.z*n.z}},isType:function(t){var n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("w")}});function N(){for(var t,n,r,e,a,i,o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];return 1===o.length?{x:null!==(t=o[0].x)&&void 0!==t?t:0,y:null!==(n=o[0].y)&&void 0!==n?n:0,z:null!==(r=o[0].z)&&void 0!==r?r:0}:3===o.length?{x:null!==(e=o[0])&&void 0!==e?e:0,y:null!==(a=o[1])&&void 0!==a?a:0,z:null!==(i=o[2])&&void 0!==i?i:0}:{x:0,y:0,z:0}}function F(t){var n=O(t);return{x:Math.hypot(n.m11,n.m21,n.m31),y:Math.hypot(n.m12,n.m22,n.m32),z:Math.hypot(n.m13,n.m23,n.m33)}}function V(){return N(0,0,-1)}function D(){return N(0,0,0)}function E(t){var n=I(t);return{x:t.x/n,y:t.y/n,z:t.z/n}}function I(t){return Math.sqrt(L(t))}function L(t){return t.x*t.x+t.y*t.y+t.z*t.z}function B(t,n){return{x:t.y*n.z-t.z*n.y,y:t.z*n.x-t.x*n.z,z:t.x*n.y-t.y*n.x}}function C(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return{x:t.x+n.x,y:t.y+n.y,z:t.z+n.z}}),t)}function Q(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return{x:t.x-n.x,y:t.y-n.y,z:t.z-n.z}}),t)}function W(t,n){return{x:n.x*t,y:n.y*t,z:n.z*t}}function Z(t,n){return t.x*n.x+t.y*n.y+t.z*n.z}function G(t,n){var r=t.x,e=t.y,a=t.z,i=1/(n[3]*r+n[7]*e+n[11]*a+n[15]);return{x:(n[0]*r+n[4]*e+n[8]*a+n[12])*i,y:(n[1]*r+n[5]*e+n[9]*a+n[13])*i,z:(n[2]*r+n[6]*e+n[10]*a+n[14])*i}}function H(t,n){return Math.sqrt(K(t,n))}function K(t,n){var r=Q(t,n),e=r.x,a=r.y,i=r.z;return e*e+a*a+i*i}function U(t,n){return N(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))}function X(t,n){return N(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z))}function Y(t,r,e){return{x:n(t.x,r.x,e),y:n(t.y,r.y,e),z:n(t.z,r.z,e)}}var $=Object.freeze({__proto__:null,create:N,isValid:function(t){return[t.x,t.y,t.z].every((function(t){return isFinite(t)&&!isNaN(t)}))},fromMatrixScale:F,fromMatrixPosition:function(t){var n=O(t);return{x:n.m14,y:n.m24,z:n.m34}},fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?N(n[0],n[1],n[2]):N(n.x,n.y,n.z)},fromArray:function(t,n){return void 0===n&&(n=0),N(t[n],t[n+1],t[n+2])},toArray:function(t){return[t.x,t.y,t.z]},right:function(){return N(1,0,0)},up:function(){return N(0,1,0)},forward:V,left:function(){return N(-1,0,0)},down:function(){return N(0,-1,0)},back:function(){return N(0,0,1)},origin:D,normalize:E,magnitude:I,magnitudeSquared:L,cross:B,add:C,subtract:Q,multiply:function(t,n){return{x:t.x*n.x,y:t.y*n.y,z:t.z*n.z}},scale:W,dot:Z,angleTo:function(t,n){var r=Z(t,n)/(I(t)*I(n));return Math.acos(r)},eulerTo:function(t,n){var r=E(t),e=E(n),a=Math.cos(m(1)),i=Z(r,e);return Math.abs(i)>a?i>.999999?A():A({x:Math.PI}):k(w(S(q(d({w:1+i},B(r,e))))))},project:function(t,n){return W(Z(n,t)/I(n),n)},rotateAboutAxis:function(t,n,r,e){if(0!==t){var a=n.x,i=n.y,o=n.z,u=e.x,c=e.y,h=e.z,f=r.x,y=r.y,x=r.z;return{x:(u*(y*y+x*x)-f*(c*y+h*x-f*a-y*i-x*o))*(1-Math.cos(t))+a*Math.cos(t)+(-h*y+c*x-x*i+y*o)*Math.sin(t),y:(c*(f*f+x*x)-y*(u*f+h*x-f*a-y*i-x*o))*(1-Math.cos(t))+i*Math.cos(t)+(h*f-u*x+x*a-f*o)*Math.sin(t),z:(h*(f*f+y*y)-x*(u*f+c*y-f*a-y*i-x*o))*(1-Math.cos(t))+o*Math.cos(t)+(-c*f+u*y-y*a+f*i)*Math.sin(t)}}return n},transformMatrix:G,distance:H,distanceSquared:K,isEqual:function(t,n){return t.x===n.x&&t.y===n.y&&t.z===n.z},max:U,min:X,negate:function(t){return{x:-t.x,y:-t.y,z:-t.z}},lerp:Y,transformNdcToWorldSpace:function(t,n,r){return G(G(t,r),n)}}),tt=function(t,n){return{min:t,max:n}},nt=function(t){return W(.5,C(t.min,t.max))},rt=function(t){return Q(t.max,t.min)};function et(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var e=l([t],n,!0);return e.reduce((function(t,n){return tt(X(t.min,n.min),U(t.max,n.max))}))}var at=Object.freeze({__proto__:null,create:tt,fromVectors:function(t){return et.apply(void 0,t.map((function(t){return tt(t,t)})))},center:nt,diagonal:rt,epsilon:function(t){return 1e-6*Math.max(Math.max(I(t.max),I(t.min)),I(rt(t)))},union:et,lengths:function(t){return N(t.max.x-t.min.x,t.max.y-t.min.y,t.max.z-t.min.z)}}),it=Object.freeze({__proto__:null,create:function(t){var n=nt(t),r=I(Q(t.max,n)),e=Math.max(r,I(n));return{center:n,radius:r,epsilon:0===e?1:1e-6*e}}});function ot(t,n,r,e){return{x:t,y:n,width:r,height:e}}function ut(t,n){return ot(t.x,t.y,n.width,n.height)}function ct(t,n){var r=Math.min(t.width/n.width,t.height/n.height),a=vt(r,n);return ut(e(xt(t),gt(a)),a)}function ht(t,n){var r=Math.max(t.width/n.width,t.height/n.height),a=vt(r,n);return ut(e(xt(t),gt(a)),a)}function ft(t,n){var r=Math.min(Math.sqrt(t/yt(n)),1),a=Mt(vt(r,n));return ut(e(xt(n),gt(a)),a)}function yt(t){return t.width*t.height}function xt(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function mt(t){return r(t.x,t.y)}var st=Object.freeze({__proto__:null,create:ot,fromDimensions:function(t){return ot(0,0,t.width,t.height)},fromPointAndDimensions:ut,fromPoints:function(t,n){var r=Math.min(t.x,n.x),e=Math.min(t.y,n.y);return ot(r,e,Math.max(t.x,n.x)-r,Math.max(t.y,n.y)-e)},containFit:ct,cropFit:ht,scaleFit:ft,scale:function t(n,r,e){return null==e?t(n,r,r):ot(n.x*r,n.y*e,n.width*r,n.height*e)},isEqual:function(t,n){return i(t,n)&<(t,n)},offset:function(t,n){return ut(a(mt(n),t),n)},area:yt,center:xt,topLeft:mt,bottomRight:function(t){return r(t.x+t.width,t.y+t.height)},isPortrait:function(t){return t.width<t.height},isLandscape:function(t){return t.width>t.height},isSquare:function(t){return t.width===t.height},pad:function(t,n){return ot(t.x-n,t.y-n,t.width+2*n,t.height+2*n)},containsPoints:function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.every((function(n){return t.x<=n.x&&t.x+t.width>=n.x&&t.y<=n.y&&t.y+t.height>=n.y}))},fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?ot(n[0],n[1],n[2],n[3]):ot(n.x,n.y,n.width,n.height)}}),dt=function(t,n){return{width:t,height:n}},lt=function(t,n){return t.width===n.width&&t.height===n.height},zt=function(t,n,r){return{width:r.width*t,height:r.height*n}},vt=function(t,n){return zt(t,t,n)},Mt=function(t){return{width:Math.floor(t.width),height:Math.floor(t.height)}},gt=function(t){return{x:t.width/2,y:t.height/2}};function wt(t,n){return void 0===n&&(n=r()),ut(n,t)}var pt=Object.freeze({__proto__:null,create:dt,square:function(t){return dt(t,t)},isEqual:lt,scale:zt,proportionalScale:vt,trim:function(t,n){return{width:Math.min(t.width,n.width),height:Math.min(t.height,n.height)}},containFit:function(t,n){var r=ct(wt(t),wt(n));return{width:r.width,height:r.height}},cropFit:function(t,n){var r=ht(wt(t),wt(n));return{width:r.width,height:r.height}},scaleFit:function(t,n){var r=ft(t,wt(n));return{width:r.width,height:r.height}},round:function(t){return{width:Math.round(t.width),height:Math.round(t.height)}},floor:Mt,center:gt,aspectRatio:function(t){return t.width/t.height},area:function(t){return t.width*t.height},fitToRatio:function(t,n){return n.width>=n.height*t?dt(n.height*t,n.height):dt(n.width,n.width/t)},toRectangle:wt});function _t(t){return Q(t.end,t.start)}var bt=Object.freeze({__proto__:null,create:function(t){var n,r;return void 0===t&&(t={}),{start:null!==(n=t.start)&&void 0!==n?n:D(),end:null!==(r=t.end)&&void 0!==r?r:D()}},center:function(t){return Y(t.start,t.end,.5)},transformMatrix:function(t,n){return{start:G(t.start,n),end:G(t.end,n)}},distance:function(t){return H(t.start,t.end)},distanceSquared:function(t){return K(t.start,t.end)},direction:_t}),Ot=function(t,n,r,e,a,i){return void 0===t&&(t=1),void 0===n&&(n=0),void 0===r&&(r=0),void 0===e&&(e=1),void 0===a&&(a=0),void 0===i&&(i=0),{a:t,b:n,c:r,d:e,tx:a,ty:i}},Pt=function(){return Ot()},At=function(t,n){var r=m(t),e=Math.cos(r),a=Math.sin(r),i=n.a*e+n.c*a,o=n.b*e+n.d*a,u=n.a*-a+n.c*e,c=n.b*-a+n.d*e;return Ot(i,o,u,c,n.tx,n.ty)},kt=function(t,n,r){var e=r.a*t+r.c*n+r.tx,a=r.b*t+r.d*n+r.ty;return Ot(r.a,r.b,r.c,r.d,e,a)},jt=Object.freeze({__proto__:null,create:Ot,identity:Pt,translation:function(t,n){return kt(t,n,Pt())},rotation:function(t){return At(t,Pt())},rotate:At,translate:kt,transformPoint:function(t,n){return r(t.a*n.x+t.c*n.y+t.tx,t.b*n.x+t.d*n.y+t.ty)}});var qt=Object.freeze({__proto__:null,create:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return 2===t.length?{a:t[0].x,b:t[0].y,c:t[1].x,d:t[1].y}:4===t.length?{a:t[0],b:t[1],c:t[2],d:t[3]}:{a:0,b:0,c:0,d:0}},determinant:function(t){return t.a*t.d-t.b*t.c},dot:function(t){return t.a*t.c+t.b*t.d}});function St(t){return void 0===t&&(t={}),d({normal:D(),constant:0},t)}function Rt(t,n){return Z(t.normal,n)+t.constant}var Tt=Object.freeze({__proto__:null,create:St,fromNormalAndCoplanarPoint:function(t,n){return St({normal:t,constant:-Z(n,t)})},distanceToPoint:Rt,intersectLine:function(t,n){var r=_t(n),e=Z(t.normal,r);if(0===e)return 0===Rt(t,n.start)?n.start:void 0;var a=-(Z(n.start,t.normal)+t.constant)/e;return a<0||a>1?void 0:C(W(a,r),n.start)},projectPoint:function(t,n){return C(n,W(-Rt(t,n),t.normal))}});function Jt(t,n){return C(W(n,t.direction),t.origin)}function Nt(t,n){var r=Z(n.normal,t.direction);if(0===r)return 0===Rt(n,t.origin)?0:void 0;var e=-(Z(t.origin,n.normal)+n.constant)/r;return e>=0?e:void 0}var Ft=Object.freeze({__proto__:null,create:function(t){var n,r;return void 0===t&&(t={}),{origin:null!==(n=t.origin)&&void 0!==n?n:D(),direction:null!==(r=t.direction)&&void 0!==r?r:V()}},at:Jt,distanceToPlane:Nt,intersectPlane:function(t,n){var r=Nt(t,n);return null!=r?Jt(t,r):void 0}});export{s as Angle,at as BoundingBox,it as BoundingSphere,pt as Dimensions,j as Euler,bt as Line3,jt as Matrix,qt as Matrix2,P as Matrix4,Tt as Plane,f as Point,J as Quaternion,Ft as Ray,st as Rectangle,$ as Vector3,t as clamp,n as lerp}; | ||
***************************************************************************** */function l(t,n,r){if(r||2===arguments.length)for(var e,a=0,i=n.length;a<i;a++)!e&&a in n||(e||(e=Array.prototype.slice.call(n,0,a)),e[a]=n[a]);return t.concat(e||Array.prototype.slice.call(n))}function z(t,n,r,e,a,i,o,u,c,h,f,y,m,x,s,d){return[t,a,c,m,n,i,h,x,r,o,f,s,e,u,y,d]}function v(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function M(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}function g(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1]}function w(t){var n=t.x,r=t.y,e=t.z,a=t.w,i=n+n,o=r+r,u=e+e,c=n*i,h=n*o,f=n*u,y=r*o,m=r*u,x=e*u,s=a*i,d=a*o,l=a*u;return[1-(y+x),h+l,f-d,0,h-l,1-(c+x),m+s,0,f+d,m-s,1-(c+y),0,0,0,0,1]}function p(t){return[t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1]}function _(t,n,r,e,a,i){return[2*a/(n-t),0,0,0,0,2*a/(r-e),0,0,(n+t)/(n-t),(r+e)/(r-e),-(i+a)/(i-a),-1,0,0,-2*i*a/(i-a),0]}function b(t,n){var r=t,e=n,a=r[0],i=r[4],o=r[8],u=r[12],c=r[1],h=r[5],f=r[9],y=r[13],m=r[2],x=r[6],s=r[10],d=r[14],l=r[3],z=r[7],v=r[11],M=r[15],g=e[0],w=e[4],p=e[8],_=e[12],b=e[1],O=e[5],P=e[9],A=e[13],j=e[2],k=e[6],q=e[10],S=e[14],R=e[3],T=e[7],J=e[11],N=e[15],F=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return F[0]=a*g+i*b+o*j+u*R,F[4]=a*w+i*O+o*k+u*T,F[8]=a*p+i*P+o*q+u*J,F[12]=a*_+i*A+o*S+u*N,F[1]=c*g+h*b+f*j+y*R,F[5]=c*w+h*O+f*k+y*T,F[9]=c*p+h*P+f*q+y*J,F[13]=c*_+h*A+f*S+y*N,F[2]=m*g+x*b+s*j+d*R,F[6]=m*w+x*O+s*k+d*T,F[10]=m*p+x*P+s*q+d*J,F[14]=m*_+x*A+s*S+d*N,F[3]=l*g+z*b+v*j+M*R,F[7]=l*w+z*O+v*k+M*T,F[11]=l*p+z*P+v*q+M*J,F[15]=l*_+z*A+v*S+M*N,F}function O(t){return{m11:t[0],m12:t[4],m13:t[8],m14:t[12],m21:t[1],m22:t[5],m23:t[9],m24:t[13],m31:t[2],m32:t[6],m33:t[10],m34:t[14],m41:t[3],m42:t[7],m43:t[11],m44:t[15]}}var P=Object.freeze({__proto__:null,fromValues:z,fromObject:function(t){return z(t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44)},makeIdentity:v,makeZero:M,makeTranslation:g,makeRotation:w,makeScale:p,makeTRS:function(t,n,r){var e=g(t),a=w(n),i=p(r);return b(b(e,a),i)},makeBasis:function(t,n,r){return[t.x,t.y,t.z,0,n.x,n.y,n.z,0,r.x,r.y,r.z,0,0,0,0,1]},makeRotationAxis:function(t,n){var r=Math.cos(n),e=Math.sin(n),a=1-r,i=t.x,o=t.y,u=t.z,c=a*i,h=a*o;return[c*i+r,c*o+e*u,c*u-e*o,0,c*o-e*u,h*o+r,h*u+e*i,0,c*u+e*o,h*u-e*i,a*u*u+r,0,0,0,0,1]},makeFrustum:_,makePerspective:function(t,n,r,e){var a=t*Math.tan(x(r/2)),i=a*e;return _(-i,i,a,-a,t,n)},makeOrthographic:function(t,n,r,e,a,i){var o=1/(n-t),u=1/(e-r),c=1/(i-a);return[2*o,0,0,-((n+t)*o),0,2*u,0,-((e+r)*u),0,0,-2*c,-((i+a)*c),0,0,0,1]},makeLookAtView:function(t,n,r){var e=E(Q(t,n)),a=E(B(r,e)),i=B(e,a),o=-Z(a,t),u=-Z(i,t),c=-Z(e,t);return[a.x,i.x,e.x,0,a.y,i.y,e.y,0,a.z,i.z,e.z,0,o,u,c,1]},invert:function(t){var n=t[0],r=t[1],e=t[2],a=t[3],i=t[4],o=t[5],u=t[6],c=t[7],h=t[8],f=t[9],y=t[10],m=t[11],x=t[12],s=t[13],d=t[14],l=t[15],z=n*o-r*i,v=n*u-e*i,M=n*c-a*i,g=r*u-e*o,w=r*c-a*o,p=e*c-a*u,_=h*s-f*x,b=h*d-y*x,O=h*l-m*x,P=f*d-y*s,A=f*l-m*s,j=y*l-m*d,k=z*j-v*A+M*P+g*O-w*b+p*_;return k?[(o*j-u*A+c*P)*(k=1/k),(e*A-r*j-a*P)*k,(s*p-d*w+l*g)*k,(y*w-f*p-m*g)*k,(u*O-i*j-c*b)*k,(n*j-e*O+a*b)*k,(d*M-x*p-l*v)*k,(h*p-y*M+m*v)*k,(i*A-o*O+c*_)*k,(r*O-n*A-a*_)*k,(x*w-s*M+l*z)*k,(f*M-h*w-m*z)*k,(o*b-i*P-u*_)*k,(n*P-r*b+e*_)*k,(s*v-x*g-d*z)*k,(h*g-f*v+y*z)*k]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},lookAt:function(t,n,r,e){var a=Q(n,r);0===L(a)&&(a=d(d({},a),{z:1}));var i=B(e,a=E(a));0===L(i)&&(i=B(e,a=E(a=1===Math.abs(e.z)?d(d({},a),{x:a.x+1e-4}):d(d({},a),{z:a.z+1e-4}))));var o=B(a,i=E(i)),u=l([],t,!0);return u[0]=i.x,u[4]=o.x,u[8]=a.x,u[1]=i.y,u[5]=o.y,u[9]=a.y,u[2]=i.z,u[6]=o.z,u[10]=a.z,u},multiply:b,transpose:function(t){return[t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]]},scale:function(t,n){var r=n.x,e=n.y,a=n.z,i=l([],t,!0);return i[0]*=r,i[4]*=e,i[8]*=a,i[1]*=r,i[5]*=e,i[9]*=a,i[2]*=r,i[6]*=e,i[10]*=a,i[3]*=r,i[7]*=e,i[11]*=a,i},position:function(t,n){var r=l([],t,!0);return r[12]=n[12],r[13]=n[13],r[14]=n[14],r},isIdentity:function(t){var n=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return t.every((function(t,r){return t===n[r]}))},toObject:O,isType:function(t){return Array.isArray(t)&&16===t.length}});function A(t){var n,r,e,a;return void 0===t&&(t={}),{x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(r=t.y)&&void 0!==r?r:0,z:null!==(e=t.z)&&void 0!==e?e:0,order:null!==(a=t.order)&&void 0!==a?a:"xyz"}}function j(n,r){void 0===r&&(r="xyz");var e=O(n),a=0,i=0,o=0;return"xyz"===r?(i=Math.asin(t(e.m13,-1,1)),Math.abs(e.m13)<.9999999?(a=Math.atan2(-e.m23,e.m33),o=Math.atan2(-e.m12,e.m11)):(a=Math.atan2(e.m32,e.m22),o=0)):"yxz"===r?(a=Math.asin(-t(e.m23,-1,1)),Math.abs(e.m23)<.9999999?(i=Math.atan2(e.m13,e.m33),o=Math.atan2(e.m21,e.m22)):(i=Math.atan2(-e.m31,e.m11),o=0)):"zxy"===r?(a=Math.asin(t(e.m32,-1,1)),Math.abs(e.m32)<.9999999?(i=Math.atan2(-e.m31,e.m33),o=Math.atan2(-e.m12,e.m22)):(i=0,o=Math.atan2(e.m21,e.m11))):"zyx"===r?(i=Math.asin(-t(e.m31,-1,1)),Math.abs(e.m31)<.9999999?(a=Math.atan2(e.m32,e.m33),o=Math.atan2(e.m21,e.m11)):(a=0,o=Math.atan2(-e.m12,e.m22))):"yzx"===r?(o=Math.asin(t(e.m21,-1,1)),Math.abs(e.m21)<.9999999?(a=Math.atan2(-e.m23,e.m22),i=Math.atan2(-e.m31,e.m11)):(a=0,i=Math.atan2(e.m13,e.m33))):"xzy"===r&&(o=Math.asin(-t(e.m12,-1,1)),Math.abs(e.m12)<.9999999?(a=Math.atan2(e.m32,e.m22),i=Math.atan2(e.m13,e.m11)):(a=Math.atan2(-e.m23,e.m33),i=0)),{x:a,y:i,z:o,order:r}}var k=Object.freeze({__proto__:null,create:A,fromDegrees:function(t){void 0===t&&(t={});var n=t.x,r=void 0===n?0:n,e=t.y,a=void 0===e?0:e,i=t.z,o=void 0===i?0:i,u=t.order;return A({x:x(r),y:x(a),z:x(o),order:u})},fromRotationMatrix:j,fromJson:function(t){var n=JSON.parse(t);if(Array.isArray(n)){var r=n[0],e=n[1],a=n[2],i=n[3];return{x:r,y:e,z:a,order:void 0===i?"xyz":i}}r=n.x,e=n.y,a=n.z;var o=n.order;return{x:r,y:e,z:a,order:void 0===o?"xyz":o}},isType:function(t){var n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("order")}});function q(t){return void 0===t&&(t={}),d({x:0,y:0,z:0,w:1},t)}function S(t){return T(1/R(t),t)}function R(t){return Math.sqrt(t.w*t.w+t.x*t.x+t.y*t.y+t.z*t.z)}function T(t,n){return q({w:n.w*t,x:n.x*t,y:n.y*t,z:n.z*t})}var J=Object.freeze({__proto__:null,create:q,fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?q({x:n[0],y:n[1],z:n[2],w:n[3]}):q(n)},normalize:S,magnitude:R,scale:T,fromAxisAngle:function(t,n){var r=n/2,e=Math.sin(r);return{x:t.x*e,y:t.y*e,z:t.z*e,w:Math.cos(r)}},fromMatrixRotation:function(t){var n,r=O(t),e=F(t),a=1/e.x,i=1/e.y,o=1/e.z,u=r.m11*a,c=r.m21*i,h=r.m31*o,f=r.m12*a,y=r.m22*i,m=r.m32*o,x=r.m13*a,s=r.m23*i,d=r.m33*o,l=u+y+d;return l>0?{x:(m-s)/(n=2*Math.sqrt(l+1)),y:(x-h)/n,z:(c-f)/n,w:.25*n}:u>y&&u>d?{x:.25*(n=2*Math.sqrt(1+u-y-d)),y:(c+f)/n,z:(x+h)/n,w:(m-s)/n}:y>d?{x:(c+f)/(n=2*Math.sqrt(1+y-u-d)),y:.25*n,z:(m+s)/n,w:(x-h)/n}:{x:(x+h)/(n=2*Math.sqrt(1+d-u-y)),y:(m+s)/n,z:.25*n,w:(c-f)/n}},fromEuler:function(t){var n=t.x,r=t.y,e=t.z,a=t.order,i=Math.cos(n/2),o=Math.cos(r/2),u=Math.cos(e/2),c=Math.sin(n/2),h=Math.sin(r/2),f=Math.sin(e/2),y=0,m=0,x=0,s=0;switch(a){case"xyz":y=c*o*u+i*h*f,m=i*h*u-c*o*f,x=i*o*f+c*h*u,s=i*o*u-c*h*f;break;case"yxz":y=c*o*u+i*h*f,m=i*h*u-c*o*f,x=i*o*f-c*h*u,s=i*o*u+c*h*f;break;case"zxy":y=c*o*u-i*h*f,m=i*h*u+c*o*f,x=i*o*f+c*h*u,s=i*o*u-c*h*f;break;case"zyx":y=c*o*u-i*h*f,m=i*h*u+c*o*f,x=i*o*f-c*h*u,s=i*o*u+c*h*f;break;case"yzx":y=c*o*u+i*h*f,m=i*h*u+c*o*f,x=i*o*f-c*h*u,s=i*o*u-c*h*f;break;case"xzy":y=c*o*u-i*h*f,m=i*h*u-c*o*f,x=i*o*f+c*h*u,s=i*o*u+c*h*f}return{x:y,y:m,z:x,w:s}},multiply:function(t,n){return{x:t.x*n.w+t.w*n.x+t.y*n.z-t.z*n.y,y:t.y*n.w+t.w*n.y+t.z*n.x-t.x*n.z,z:t.z*n.w+t.w*n.z+t.x*n.y-t.y*n.x,w:t.w*n.w-t.x*n.x-t.y*n.y-t.z*n.z}},isType:function(t){var n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("w")}});function N(){for(var t,n,r,e,a,i,o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];return 1===o.length?{x:null!==(t=o[0].x)&&void 0!==t?t:0,y:null!==(n=o[0].y)&&void 0!==n?n:0,z:null!==(r=o[0].z)&&void 0!==r?r:0}:3===o.length?{x:null!==(e=o[0])&&void 0!==e?e:0,y:null!==(a=o[1])&&void 0!==a?a:0,z:null!==(i=o[2])&&void 0!==i?i:0}:{x:0,y:0,z:0}}function F(t){var n=O(t);return{x:Math.hypot(n.m11,n.m21,n.m31),y:Math.hypot(n.m12,n.m22,n.m32),z:Math.hypot(n.m13,n.m23,n.m33)}}function V(){return N(0,0,-1)}function D(){return N(0,0,0)}function E(t){var n=I(t);return{x:t.x/n,y:t.y/n,z:t.z/n}}function I(t){return Math.sqrt(L(t))}function L(t){return t.x*t.x+t.y*t.y+t.z*t.z}function B(t,n){return{x:t.y*n.z-t.z*n.y,y:t.z*n.x-t.x*n.z,z:t.x*n.y-t.y*n.x}}function C(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return{x:t.x+n.x,y:t.y+n.y,z:t.z+n.z}}),t)}function Q(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return{x:t.x-n.x,y:t.y-n.y,z:t.z-n.z}}),t)}function W(t,n){return{x:n.x*t,y:n.y*t,z:n.z*t}}function Z(t,n){return t.x*n.x+t.y*n.y+t.z*n.z}function G(t,n){var r=t.x,e=t.y,a=t.z,i=1/(n[3]*r+n[7]*e+n[11]*a+n[15]);return{x:(n[0]*r+n[4]*e+n[8]*a+n[12])*i,y:(n[1]*r+n[5]*e+n[9]*a+n[13])*i,z:(n[2]*r+n[6]*e+n[10]*a+n[14])*i}}function H(t,n){return Math.sqrt(K(t,n))}function K(t,n){var r=Q(t,n),e=r.x,a=r.y,i=r.z;return e*e+a*a+i*i}function U(t,n){return N(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))}function X(t,n){return N(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z))}function Y(t,r,e){return{x:n(t.x,r.x,e),y:n(t.y,r.y,e),z:n(t.z,r.z,e)}}var $=Object.freeze({__proto__:null,create:N,isValid:function(t){return[t.x,t.y,t.z].every((function(t){return isFinite(t)&&!isNaN(t)}))},fromMatrixScale:F,fromMatrixPosition:function(t){var n=O(t);return{x:n.m14,y:n.m24,z:n.m34}},fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?N(n[0],n[1],n[2]):N(n.x,n.y,n.z)},fromArray:function(t,n){return void 0===n&&(n=0),N(t[n],t[n+1],t[n+2])},toArray:function(t){return[t.x,t.y,t.z]},right:function(){return N(1,0,0)},up:function(){return N(0,1,0)},forward:V,left:function(){return N(-1,0,0)},down:function(){return N(0,-1,0)},back:function(){return N(0,0,1)},origin:D,normalize:E,magnitude:I,magnitudeSquared:L,cross:B,add:C,subtract:Q,multiply:function(t,n){return{x:t.x*n.x,y:t.y*n.y,z:t.z*n.z}},scale:W,dot:Z,angleTo:function(t,n){var r=Z(t,n)/(I(t)*I(n));return Math.acos(r)},eulerTo:function(t,n){var r=E(t),e=E(n),a=Math.cos(x(1)),i=Z(r,e);return Math.abs(i)>a?i>.999999?A():A({x:Math.PI}):j(w(S(q(d({w:1+i},B(r,e))))))},project:function(t,n){return W(Z(n,t)/I(n),n)},rotateAboutAxis:function(t,n,r,e){if(0!==t){var a=n.x,i=n.y,o=n.z,u=e.x,c=e.y,h=e.z,f=r.x,y=r.y,m=r.z;return{x:(u*(y*y+m*m)-f*(c*y+h*m-f*a-y*i-m*o))*(1-Math.cos(t))+a*Math.cos(t)+(-h*y+c*m-m*i+y*o)*Math.sin(t),y:(c*(f*f+m*m)-y*(u*f+h*m-f*a-y*i-m*o))*(1-Math.cos(t))+i*Math.cos(t)+(h*f-u*m+m*a-f*o)*Math.sin(t),z:(h*(f*f+y*y)-m*(u*f+c*y-f*a-y*i-m*o))*(1-Math.cos(t))+o*Math.cos(t)+(-c*f+u*y-y*a+f*i)*Math.sin(t)}}return n},transformMatrix:G,distance:H,distanceSquared:K,isEqual:function(t,n){return t.x===n.x&&t.y===n.y&&t.z===n.z},max:U,min:X,negate:function(t){return{x:-t.x,y:-t.y,z:-t.z}},lerp:Y,transformNdcToWorldSpace:function(t,n,r){return G(G(t,r),n)}}),tt=function(t,n){return{min:t,max:n}},nt=function(t){return W(.5,C(t.min,t.max))},rt=function(t){return Q(t.max,t.min)};function et(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var e=l([t],n,!0);return e.reduce((function(t,n){return tt(X(t.min,n.min),U(t.max,n.max))}))}var at=Object.freeze({__proto__:null,create:tt,fromVectors:function(t){return et.apply(void 0,t.map((function(t){return tt(t,t)})))},center:nt,diagonal:rt,epsilon:function(t){return 1e-6*Math.max(Math.max(I(t.max),I(t.min)),I(rt(t)))},union:et,lengths:function(t){return N(t.max.x-t.min.x,t.max.y-t.min.y,t.max.z-t.min.z)}}),it=Object.freeze({__proto__:null,create:function(t){var n=nt(t),r=I(Q(t.max,n)),e=Math.max(r,I(n));return{center:n,radius:r,epsilon:0===e?1:1e-6*e}}});function ot(t,n,r,e){return{x:t,y:n,width:r,height:e}}function ut(t,n){return ot(t.x,t.y,n.width,n.height)}function ct(t,n){var r=Math.min(t.width/n.width,t.height/n.height),a=vt(r,n);return ut(e(mt(t),gt(a)),a)}function ht(t,n){var r=Math.max(t.width/n.width,t.height/n.height),a=vt(r,n);return ut(e(mt(t),gt(a)),a)}function ft(t,n){var r=Math.min(Math.sqrt(t/yt(n)),1),a=Mt(vt(r,n));return ut(e(mt(n),gt(a)),a)}function yt(t){return t.width*t.height}function mt(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function xt(t){return r(t.x,t.y)}var st=Object.freeze({__proto__:null,create:ot,fromDimensions:function(t){return ot(0,0,t.width,t.height)},fromPointAndDimensions:ut,fromPoints:function(t,n){var r=Math.min(t.x,n.x),e=Math.min(t.y,n.y);return ot(r,e,Math.max(t.x,n.x)-r,Math.max(t.y,n.y)-e)},containFit:ct,cropFit:ht,scaleFit:ft,scale:function t(n,r,e){return null==e?t(n,r,r):ot(n.x*r,n.y*e,n.width*r,n.height*e)},isEqual:function(t,n){return i(t,n)&<(t,n)},offset:function(t,n){return ut(a(xt(n),t),n)},area:yt,center:mt,topLeft:xt,bottomRight:function(t){return r(t.x+t.width,t.y+t.height)},isPortrait:function(t){return t.width<t.height},isLandscape:function(t){return t.width>t.height},isSquare:function(t){return t.width===t.height},pad:function(t,n){return ot(t.x-n,t.y-n,t.width+2*n,t.height+2*n)},containsPoints:function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.every((function(n){return t.x<=n.x&&t.x+t.width>=n.x&&t.y<=n.y&&t.y+t.height>=n.y}))},fromJson:function(t){var n=JSON.parse(t);return Array.isArray(n)?ot(n[0],n[1],n[2],n[3]):ot(n.x,n.y,n.width,n.height)}}),dt=function(t,n){return{width:t,height:n}},lt=function(t,n){return t.width===n.width&&t.height===n.height},zt=function(t,n,r){return{width:r.width*t,height:r.height*n}},vt=function(t,n){return zt(t,t,n)},Mt=function(t){return{width:Math.floor(t.width),height:Math.floor(t.height)}},gt=function(t){return{x:t.width/2,y:t.height/2}};function wt(t,n){return void 0===n&&(n=r()),ut(n,t)}var pt=Object.freeze({__proto__:null,create:dt,square:function(t){return dt(t,t)},isEqual:lt,scale:zt,proportionalScale:vt,trim:function(t,n){return{width:Math.min(t.width,n.width),height:Math.min(t.height,n.height)}},containFit:function(t,n){var r=ct(wt(t),wt(n));return{width:r.width,height:r.height}},cropFit:function(t,n){var r=ht(wt(t),wt(n));return{width:r.width,height:r.height}},scaleFit:function(t,n){var r=ft(t,wt(n));return{width:r.width,height:r.height}},round:function(t){return{width:Math.round(t.width),height:Math.round(t.height)}},floor:Mt,center:gt,aspectRatio:function(t){return t.width/t.height},area:function(t){return t.width*t.height},fitToRatio:function(t,n){return n.width>=n.height*t?dt(n.height*t,n.height):dt(n.width,n.width/t)},toRectangle:wt});function _t(t){return Q(t.end,t.start)}var bt=Object.freeze({__proto__:null,create:function(t){var n,r;return void 0===t&&(t={}),{start:null!==(n=t.start)&&void 0!==n?n:D(),end:null!==(r=t.end)&&void 0!==r?r:D()}},center:function(t){return Y(t.start,t.end,.5)},transformMatrix:function(t,n){return{start:G(t.start,n),end:G(t.end,n)}},distance:function(t){return H(t.start,t.end)},distanceSquared:function(t){return K(t.start,t.end)},direction:_t}),Ot=function(t,n,r,e,a,i){return void 0===t&&(t=1),void 0===n&&(n=0),void 0===r&&(r=0),void 0===e&&(e=1),void 0===a&&(a=0),void 0===i&&(i=0),{a:t,b:n,c:r,d:e,tx:a,ty:i}},Pt=function(){return Ot()},At=function(t,n){var r=x(t),e=Math.cos(r),a=Math.sin(r),i=n.a*e+n.c*a,o=n.b*e+n.d*a,u=n.a*-a+n.c*e,c=n.b*-a+n.d*e;return Ot(i,o,u,c,n.tx,n.ty)},jt=function(t,n,r){var e=r.a*t+r.c*n+r.tx,a=r.b*t+r.d*n+r.ty;return Ot(r.a,r.b,r.c,r.d,e,a)},kt=Object.freeze({__proto__:null,create:Ot,identity:Pt,translation:function(t,n){return jt(t,n,Pt())},rotation:function(t){return At(t,Pt())},rotate:At,translate:jt,transformPoint:function(t,n){return r(t.a*n.x+t.c*n.y+t.tx,t.b*n.x+t.d*n.y+t.ty)}});var qt=Object.freeze({__proto__:null,create:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return 2===t.length?{a:t[0].x,b:t[0].y,c:t[1].x,d:t[1].y}:4===t.length?{a:t[0],b:t[1],c:t[2],d:t[3]}:{a:0,b:0,c:0,d:0}},determinant:function(t){return t.a*t.d-t.b*t.c},dot:function(t){return t.a*t.c+t.b*t.d}});function St(t){return void 0===t&&(t={}),d({normal:D(),constant:0},t)}function Rt(t,n){return Z(t.normal,n)+t.constant}var Tt=Object.freeze({__proto__:null,create:St,fromNormalAndCoplanarPoint:function(t,n){return St({normal:t,constant:-Z(n,t)})},distanceToPoint:Rt,intersectLine:function(t,n){var r=_t(n),e=Z(t.normal,r);if(0===e)return 0===Rt(t,n.start)?n.start:void 0;var a=-(Z(n.start,t.normal)+t.constant)/e;return a<0||a>1?void 0:C(W(a,r),n.start)},projectPoint:function(t,n){return C(n,W(-Rt(t,n),t.normal))}});function Jt(t,n){return C(W(n,t.direction),t.origin)}function Nt(t,n){var r=Z(n.normal,t.direction);if(0===r)return 0===Rt(n,t.origin)?0:void 0;var e=-(Z(t.origin,n.normal)+n.constant)/r;return e>=0?e:void 0}var Ft=Object.freeze({__proto__:null,create:function(t){var n,r;return void 0===t&&(t={}),{origin:null!==(n=t.origin)&&void 0!==n?n:D(),direction:null!==(r=t.direction)&&void 0!==r?r:V()}},at:Jt,distanceToPlane:Nt,intersectPlane:function(t,n){var r=Nt(t,n);return null!=r?Jt(t,r):void 0}});export{s as Angle,at as BoundingBox,it as BoundingSphere,pt as Dimensions,k as Euler,bt as Line3,kt as Matrix,qt as Matrix2,P as Matrix4,Tt as Plane,f as Point,J as Quaternion,Ft as Ray,st as Rectangle,$ as Vector3,t as clamp,n as lerp}; | ||
//# sourceMappingURL=bundle.esm.min.js.map |
@@ -231,16 +231,2 @@ import * as Quaternion from './quaternion'; | ||
/** | ||
* Matrix becomes a combination of translation and rotation. | ||
* | ||
* Matrix becomes a combination of a translation to the position of 'eye' and a | ||
* rotation matrix which orients an object to point towards 'center' along its | ||
* z-axis. Use this function if you want an object to look at a point from | ||
* another point in space. | ||
* | ||
* @param position The position of the object. | ||
* @param lookAt The point which the object is looking at. | ||
* @param up The direction which the object considers up. | ||
* @returns A matrix. | ||
*/ | ||
export declare function makeLookAt(position: Vector3.Vector3, lookAt: Vector3.Vector3, up: Vector3.Vector3): Matrix4; | ||
/** | ||
* Returns the inverse of the given matrix. If the determinate of the matrix is | ||
@@ -247,0 +233,0 @@ * zero, then a zero matrix is returned. |
@@ -181,2 +181,3 @@ import * as Euler from './euler'; | ||
* Returns a vector that is multiplied with a matrix. | ||
* Is it v*m or m*v? | ||
*/ | ||
@@ -183,0 +184,0 @@ export declare function transformMatrix(vector: Vector3, m: Matrix4.Matrix4): Vector3; |
@@ -231,16 +231,2 @@ import * as Quaternion from './quaternion'; | ||
/** | ||
* Matrix becomes a combination of translation and rotation. | ||
* | ||
* Matrix becomes a combination of a translation to the position of 'eye' and a | ||
* rotation matrix which orients an object to point towards 'center' along its | ||
* z-axis. Use this function if you want an object to look at a point from | ||
* another point in space. | ||
* | ||
* @param position The position of the object. | ||
* @param lookAt The point which the object is looking at. | ||
* @param up The direction which the object considers up. | ||
* @returns A matrix. | ||
*/ | ||
export declare function makeLookAt(position: Vector3.Vector3, lookAt: Vector3.Vector3, up: Vector3.Vector3): Matrix4; | ||
/** | ||
* Returns the inverse of the given matrix. If the determinate of the matrix is | ||
@@ -247,0 +233,0 @@ * zero, then a zero matrix is returned. |
@@ -181,2 +181,3 @@ import * as Euler from './euler'; | ||
* Returns a vector that is multiplied with a matrix. | ||
* Is it v*m or m*v? | ||
*/ | ||
@@ -183,0 +184,0 @@ export declare function transformMatrix(vector: Vector3, m: Matrix4.Matrix4): Vector3; |
{ | ||
"name": "@vertexvis/geometry", | ||
"version": "0.21.1-testing.0", | ||
"version": "0.21.1-testing.1", | ||
"description": "Library for 2D and 3D geometric types.", | ||
@@ -43,3 +43,3 @@ "license": "MIT", | ||
"@vertexvis/jest-config-vertexvis": "^0.5.4", | ||
"@vertexwebsdk/build": "0.21.1-testing.0", | ||
"@vertexwebsdk/build": "0.21.1-testing.1", | ||
"eslint": "^8.17.0", | ||
@@ -55,3 +55,3 @@ "jest": "^27.5.1", | ||
}, | ||
"gitHead": "a957648337b12fe35224c5c968c5a8bdd76c5529" | ||
"gitHead": "c33e770f1bea977f35225e049a5d182446a82c5f" | ||
} |
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
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 not supported yet
923788
9699