@vertexvis/geometry 1.1.1-testing.0 → 1.1.1-testing.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs +3 -4
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.js +3 -4
- package/dist/bundle.js.map +1 -1
- package/dist/cdn/bundle.js +3 -4
- package/dist/cdn/bundle.js.map +1 -1
- package/dist/cdn/bundle.min.js +1 -1
- package/dist/cdn/bundle.min.js.map +1 -1
- package/package.json +11 -11
package/dist/cdn/bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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=0,n=0){return{x:t,y:n}}function e(t,n){return{x:t.x-n.x,y:t.y-n.y}}function o(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 a(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){const n=u(t);return 0===n?r(0,0):a(t,1/n)}function s(t,n){return c(e(n,t))}var m=Object.freeze({__proto__:null,add:o,create:r,distance:function(t,n){const r=e(t,n);return Math.sqrt(r.x*r.x+r.y*r.y)},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,e]=n;return r(t,e)}{const{x:t,y:e}=n;return r(t,e)}},isEqual:i,lerp:function(t,r,e){return{x:n(t.x,r.x,e),y:n(t.y,r.y,e)}},magnitude:u,negate:function(t){return r(-t.x,-t.y)},normalDirectionVector:s,normalizeVector:c,orthogonalVector:function(t,n){const e=s(t,n);if(0===e.x||0===e.y)return r(-1*e.y,e.x);if(Math.abs(e.x)>Math.abs(e.y)){return c(r(1-Math.pow(e.x,2),-1*e.x*e.y))}return c(r(-1*e.x*e.y,1-Math.pow(e.y,2)))},polar:function(t,n){return r(Math.cos(n)*t,Math.sin(n)*t)},scale:function(t,n,r){return{x:t.x*n,y:t.y*r}},scaleProportional:a,subtract:e});function h(t){return(t+3600)%360}function y(t){return t*(180/Math.PI)}function x(t){return t*(Math.PI/180)}var f=Object.freeze({__proto__:null,fromPoints:function(t,n){const r=e(n,t);return Math.atan2(r.y,r.x)},fromPointsInDegrees:function(t,n){const r=e(n,t);return h(y(Math.atan2(r.y,r.x))-270)},normalize:h,normalizeRadians:function(t){return x(h(y(t)))},toDegrees:y,toRadians:x});function l(t,n,r,e,o,i,a,u,c,s,m,h,y,x,f,l){return[t,n,r,e,o,i,a,u,c,s,m,h,y,x,f,l]}function z(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function d(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}function M(t){const{x:n,y:r,z:e}=t;return[1,0,0,0,0,1,0,0,0,0,1,0,n,r,e,1]}function w(t){const{x:n,y:r,z:e,w:o}=t,i=n+n,a=r+r,u=e+e,c=n*i,s=n*a,m=n*u,h=r*a,y=r*u,x=e*u,f=o*i,l=o*a,z=o*u;return[1-(h+x),s-z,m+l,0,s+z,1-(c+x),y-f,0,m-l,y+f,1-(c+h),0,0,0,0,1]}function g(t){const{x:n,y:r,z:e}=t;return[n,0,0,0,0,r,0,0,0,0,e,0,0,0,0,1]}function p(t,n,r,e,o,i){return[2*o/(n-t),0,0,0,0,2*o/(r-e),0,0,(n+t)/(n-t),(r+e)/(r-e),-(i+o)/(i-o),-1,0,0,-2*i*o/(i-o),0]}function _(t,n){const r=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];for(let e=0;e<4;e++)for(let o=0;o<4;o++){let i=0;for(let r=0;r<4;r++)i+=t[4*e+r]*n[4*r+o];r[4*e+o]=i}return r}function b(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]]}function v(t,n){const{x:r,y:e,z:o}=n,i=[...t];return i[0]*=r,i[1]*=r,i[2]*=r,i[3]*=r,i[4]*=e,i[5]*=e,i[6]*=e,i[7]*=e,i[8]*=o,i[9]*=o,i[10]*=o,i[11]*=o,i}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]}}function P(t){return{m11:t[0],m12:t[1],m13:t[2],m14:t[3],m21:t[4],m22:t[5],m23:t[6],m24:t[7],m31:t[8],m32:t[9],m33:t[10],m34:t[11],m41:t[12],m42:t[13],m43:t[14],m44:t[15]}}var j=Object.freeze({__proto__:null,fromObject:function(t){return l(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)},fromValues:l,invert:function(t){const n=t[0],r=t[1],e=t[2],o=t[3],i=t[4],a=t[5],u=t[6],c=t[7],s=t[8],m=t[9],h=t[10],y=t[11],x=t[12],f=t[13],l=t[14],z=t[15],d=n*a-r*i,M=n*u-e*i,w=n*c-o*i,g=r*u-e*a,p=r*c-o*a,_=e*c-o*u,b=s*f-m*x,v=s*l-h*x,O=s*z-y*x,P=m*l-h*f,j=m*z-y*f,A=h*z-y*l,k=d*A-M*j+w*P+g*O-p*v+_*b;if(!k)return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];const q=1/k;return[(a*A-u*j+c*P)*q,(e*j-r*A-o*P)*q,(f*_-l*p+z*g)*q,(h*p-m*_-y*g)*q,(u*O-i*A-c*v)*q,(n*A-e*O+o*v)*q,(l*w-x*_-z*M)*q,(s*_-h*w+y*M)*q,(i*j-a*O+c*b)*q,(r*O-n*j-o*b)*q,(x*p-f*w+z*d)*q,(m*w-s*p-y*d)*q,(a*v-i*P-u*b)*q,(n*P-r*v+e*b)*q,(f*M-x*g-l*d)*q,(s*g-m*M+h*d)*q]},isIdentity:function(t){const n=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return t.every((t,r)=>t===n[r])},isType:function(t){return Array.isArray(t)&&16===t.length},lookAt:function(t,n,r,e){let o=W(n,r);0===C(o)&&(o={...o,z:1}),o=I(o);let i=Z(e,o);0===C(i)&&(o=1===Math.abs(e.z)?{...o,x:o.x+1e-4}:{...o,z:o.z+1e-4},o=I(o),i=Z(e,o)),i=I(i);const a=Z(o,i),u=[...t];return u[0]=i.x,u[1]=i.y,u[2]=i.z,u[4]=a.x,u[5]=a.y,u[6]=a.z,u[8]=o.x,u[9]=o.y,u[10]=o.z,u},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]},makeFrustum:p,makeIdentity:z,makeLookAt:function(t,n,r){const e=I(W(t,n)),o=I(Z(r,e)),i=Z(e,o);return[o.x,o.y,o.z,0,i.x,i.y,i.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,1]},makeLookAtView:function(t,n,r){const e=I(W(t,n)),o=I(Z(r,e)),i=Z(e,o),a=-H(o,t),u=-H(i,t),c=-H(e,t);return[o.x,i.x,e.x,0,o.y,i.y,e.y,0,o.z,i.z,e.z,0,a,u,c,1]},makeOrthographic:function(t,n,r,e,o,i){const a=1/(n-t),u=1/(e-r),c=1/(i-o);return[2*a,0,0,-((n+t)*a),0,2*u,0,-((e+r)*u),0,0,-2*c,-((i+o)*c),0,0,0,1]},makePerspective:function(t,n,r,e){const o=t*Math.tan(x(r/2)),i=o*e;return p(-i,i,o,-o,t,n)},makeRotation:w,makeScale:g,makeTRS:function(t,n,r){const e=M(t),o=b(w(n));return _(g(r),_(o,e))},makeTranslation:M,makeZero:d,multiply:_,position:function(t,n){const r=[...t];return r[12]=n[12],r[13]=n[13],r[14]=n[14],r},scale:v,toObject:function(t){return O(t)},toObjectColumnMajor:O,toObjectRowMajor:P,transpose:b});function A(t={}){var n,r,e,o;return{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!==(o=t.order)&&void 0!==o?o:"xyz"}}function k(n,r="xyz",e=!0){const o=e?O(n):P(n);let i=0,a=0,u=0;return"xyz"===r?(a=Math.asin(t(o.m13,-1,1)),Math.abs(o.m13)<.9999999?(i=Math.atan2(-o.m23,o.m33),u=Math.atan2(-o.m12,o.m11)):(i=Math.atan2(o.m32,o.m22),u=0)):"yxz"===r?(i=Math.asin(-t(o.m23,-1,1)),Math.abs(o.m23)<.9999999?(a=Math.atan2(o.m13,o.m33),u=Math.atan2(o.m21,o.m22)):(a=Math.atan2(-o.m31,o.m11),u=0)):"zxy"===r?(i=Math.asin(t(o.m32,-1,1)),Math.abs(o.m32)<.9999999?(a=Math.atan2(-o.m31,o.m33),u=Math.atan2(-o.m12,o.m22)):(a=0,u=Math.atan2(o.m21,o.m11))):"zyx"===r?(a=Math.asin(-t(o.m31,-1,1)),Math.abs(o.m31)<.9999999?(i=Math.atan2(o.m32,o.m33),u=Math.atan2(o.m21,o.m11)):(i=0,u=Math.atan2(-o.m12,o.m22))):"yzx"===r?(u=Math.asin(t(o.m21,-1,1)),Math.abs(o.m21)<.9999999?(i=Math.atan2(-o.m23,o.m22),a=Math.atan2(-o.m31,o.m11)):(i=0,a=Math.atan2(o.m13,o.m33))):"xzy"===r&&(u=Math.asin(-t(o.m12,-1,1)),Math.abs(o.m12)<.9999999?(i=Math.atan2(o.m32,o.m22),a=Math.atan2(o.m13,o.m11)):(i=Math.atan2(-o.m23,o.m33),a=0)),{x:i,y:a,z:u,order:r}}var q=Object.freeze({__proto__:null,create:A,fromDegrees:function(t={}){const{x:n=0,y:r=0,z:e=0,order:o}=t;return A({x:x(n),y:x(r),z:x(e),order:o})},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o="xyz"]=n;return{x:t,y:r,z:e,order:o}}{const{x:t,y:r,z:e,order:o="xyz"}=n;return{x:t,y:r,z:e,order:o}}},fromRotationMatrix:k,isType:function(t){const n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("order")}});function S(t={}){return{x:0,y:0,z:0,w:1,...t}}function R(t){return J(1/T(t),t)}function T(t){return Math.sqrt(t.w*t.w+t.x*t.x+t.y*t.y+t.z*t.z)}function J(t,n){return S({w:n.w*t,x:n.x*t,y:n.y*t,z:n.z*t})}var V=Object.freeze({__proto__:null,create:S,fromAxisAngle:function(t,n){const r=n/2,e=Math.sin(r);return{x:t.x*e,y:t.y*e,z:t.z*e,w:Math.cos(r)}},fromEuler:function(t){const{x:n,y:r,z:e,order:o}=t,i=Math.cos(n/2),a=Math.cos(r/2),u=Math.cos(e/2),c=Math.sin(n/2),s=Math.sin(r/2),m=Math.sin(e/2);let h=0,y=0,x=0,f=0;switch(o){case"xyz":h=c*a*u+i*s*m,y=i*s*u-c*a*m,x=i*a*m+c*s*u,f=i*a*u-c*s*m;break;case"yxz":h=c*a*u+i*s*m,y=i*s*u-c*a*m,x=i*a*m-c*s*u,f=i*a*u+c*s*m;break;case"zxy":h=c*a*u-i*s*m,y=i*s*u+c*a*m,x=i*a*m+c*s*u,f=i*a*u-c*s*m;break;case"zyx":h=c*a*u-i*s*m,y=i*s*u+c*a*m,x=i*a*m-c*s*u,f=i*a*u+c*s*m;break;case"yzx":h=c*a*u+i*s*m,y=i*s*u+c*a*m,x=i*a*m-c*s*u,f=i*a*u-c*s*m;break;case"xzy":h=c*a*u-i*s*m,y=i*s*u-c*a*m,x=i*a*m+c*s*u,f=i*a*u+c*s*m}return{x:h,y:y,z:x,w:f}},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o]=n;return S({x:t,y:r,z:e,w:o})}return S(n)},fromMatrixRotation:function(t){const n=D(t),r=P(v(t,N(1/n.x,1/n.y,1/n.z))),e=r.m11+r.m22+r.m33;if(e>0){const t=2*Math.sqrt(e+1);return{x:(r.m23-r.m32)/t,y:(r.m31-r.m13)/t,z:(r.m12-r.m21)/t,w:.25*t}}if(r.m11>r.m22&&r.m11>r.m33){const t=2*Math.sqrt(1+r.m11-r.m22-r.m33);return{x:.25*t,y:(r.m12+r.m21)/t,z:(r.m31+r.m13)/t,w:(r.m23-r.m32)/t}}if(r.m22>r.m33){const t=2*Math.sqrt(1+r.m22-r.m11-r.m33);return{x:(r.m12+r.m21)/t,y:.25*t,z:(r.m23+r.m32)/t,w:(r.m31-r.m13)/t}}{const t=2*Math.sqrt(1+r.m33-r.m11-r.m22);return{x:(r.m31+r.m13)/t,y:(r.m23+r.m32)/t,z:.25*t,w:(r.m12-r.m21)/t}}},isType:function(t){const n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("w")},magnitude:T,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}},normalize:R,scale:J});function N(...t){var n,r,e,o,i,a;return 1===t.length?{x:null!==(n=t[0].x)&&void 0!==n?n:0,y:null!==(r=t[0].y)&&void 0!==r?r:0,z:null!==(e=t[0].z)&&void 0!==e?e:0}:3===t.length?{x:null!==(o=t[0])&&void 0!==o?o:0,y:null!==(i=t[1])&&void 0!==i?i:0,z:null!==(a=t[2])&&void 0!==a?a:0}:{x:0,y:0,z:0}}function F({x:t,y:n,z:r}){return[t,n,r].every(t=>isFinite(t)&&!isNaN(t))}function D(t){const n=P(t);return{x:Math.hypot(n.m11,n.m12,n.m13),y:Math.hypot(n.m21,n.m22,n.m23),z:Math.hypot(n.m31,n.m32,n.m33)}}function B(){return N(0,0,-1)}function E(){return N(0,0,0)}function I(t){const n=L(t);return{x:t.x/n,y:t.y/n,z:t.z/n}}function L(t){return Math.sqrt(C(t))}function C(t){return t.x*t.x+t.y*t.y+t.z*t.z}function Z(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 Q(t,...n){return n.reduce((t,n)=>({x:t.x+n.x,y:t.y+n.y,z:t.z+n.z}),t)}function W(t,...n){return n.reduce((t,n)=>({x:t.x-n.x,y:t.y-n.y,z:t.z-n.z}),t)}function G(t,n){return{x:n.x*t,y:n.y*t,z:n.z*t}}function H(t,n){return t.x*n.x+t.y*n.y+t.z*n.z}function K(t,n){const{x:r,y:e,z:o}=t,i=1/(n[3]*r+n[7]*e+n[11]*o+n[15]);return{x:(n[0]*r+n[4]*e+n[8]*o+n[12])*i,y:(n[1]*r+n[5]*e+n[9]*o+n[13])*i,z:(n[2]*r+n[6]*e+n[10]*o+n[14])*i}}function U(t,n){return Math.sqrt(X(t,n))}function X(t,n){const{x:r,y:e,z:o}=W(t,n);return r*r+e*e+o*o}function Y(t,n){return N(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))}function $(t,n){return N(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z))}function tt(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 nt=Object.freeze({__proto__:null,add:Q,angleTo:function(t,n){const r=H(t,n)/(L(t)*L(n));return Math.acos(r)},back:function(){return N(0,0,1)},create:N,cross:Z,distance:U,distanceSquared:X,dot:H,down:function(){return N(0,-1,0)},eulerTo:function(t,n){const r=I(t),e=I(n),o=Math.cos(x(1)),i=H(r,e);return Math.abs(i)>o?i>.999999?A():A({x:Math.PI}):k(w(R(S({w:1+i,...Z(r,e)}))),"xyz",!1)},forward:B,fromArray:function(t,n=0){return N(t[n],t[n+1],t[n+2])},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e]=n;return N(t,r,e)}{const{x:t,y:r,z:e}=n;return N(t,r,e)}},fromMatrixPosition:function(t){const n=P(t);return{x:n.m41,y:n.m42,z:n.m43}},fromMatrixScale:D,isEqual:function(t,n){return t.x===n.x&&t.y===n.y&&t.z===n.z},isValid:F,isZeroVector:function({x:t,y:n,z:r}){return[t,n,r].every(t=>0===t)},left:function(){return N(-1,0,0)},lerp:tt,magnitude:L,magnitudeSquared:C,max:Y,min:$,multiply:function(t,n){return{x:t.x*n.x,y:t.y*n.y,z:t.z*n.z}},multiplyByTransformMatrixColumnMajor:K,multiplyByTransformMatrixRowMajor:function(t,n){const{x:r,y:e,z:o}=t,i=1/(n[12]*r+n[13]*e+n[14]*o+n[15]);return{x:(n[0]*r+n[1]*e+n[2]*o+n[3])*i,y:(n[4]*r+n[5]*e+n[6]*o+n[7])*i,z:(n[8]*r+n[9]*e+n[10]*o+n[11])*i}},negate:function(t){return{x:-t.x,y:-t.y,z:-t.z}},normalize:I,origin:E,project:function(t,n){return G(H(n,t)/L(n),n)},right:function(){return N(1,0,0)},rotateAboutAxis:function(t,n,r,e){if(0!==t){const{x:o,y:i,z:a}=n,{x:u,y:c,z:s}=e,{x:m,y:h,z:y}=r;return{x:(u*(h*h+y*y)-m*(c*h+s*y-m*o-h*i-y*a))*(1-Math.cos(t))+o*Math.cos(t)+(-s*h+c*y-y*i+h*a)*Math.sin(t),y:(c*(m*m+y*y)-h*(u*m+s*y-m*o-h*i-y*a))*(1-Math.cos(t))+i*Math.cos(t)+(s*m-u*y+y*o-m*a)*Math.sin(t),z:(s*(m*m+h*h)-y*(u*m+c*h-m*o-h*i-y*a))*(1-Math.cos(t))+a*Math.cos(t)+(-c*m+u*h-h*o+m*i)*Math.sin(t)}}return n},scale:G,subtract:W,toArray:function({x:t,y:n,z:r}){return[t,n,r]},transformMatrix:function(t,n){return K(t,n)},transformNdcToWorldSpace:function(t,n,r){return K(K(t,r),n)},up:function(){return N(0,1,0)}});const rt=(t,n)=>({min:t,max:n}),et=t=>G(.5,Q(t.min,t.max)),ot=t=>W(t.max,t.min);function it(t,...n){return[t,...n].reduce((t,n)=>rt($(t.min,n.min),Y(t.max,n.max)))}var at=Object.freeze({__proto__:null,center:et,create:rt,diagonal:ot,epsilon:t=>1e-6*Math.max(Math.max(L(t.max),L(t.min)),L(ot(t))),fromVectors:t=>it(...t.map(t=>rt(t,t))),isValid:function(t){const n=F(t.max),r=F(t.min);return n&&r},lengths:t=>N(t.max.x-t.min.x,t.max.y-t.min.y,t.max.z-t.min.z),union:it});var ut=Object.freeze({__proto__:null,create:t=>{const n=et(t),r=L(W(t.max,n)),e=Math.max(r,L(n));return{center:n,radius:r,epsilon:0===e?1:1e-6*e}}});function ct(t,n,r,e){return{x:t,y:n,width:r,height:e}}function st(t,n){return ct(t.x,t.y,n.width,n.height)}function mt(t,n){const r=Math.min(t.width/n.width,t.height/n.height),o=gt(r,n);return st(e(ft(t),_t(o)),o)}function ht(t,n){const r=Math.max(t.width/n.width,t.height/n.height),o=gt(r,n);return st(e(ft(t),_t(o)),o)}function yt(t,n){const r=Math.min(Math.sqrt(t/xt(n)),1),o=pt(gt(r,n));return st(e(ft(n),_t(o)),o)}function xt(t){return t.width*t.height}function ft(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function lt(t){return r(t.x,t.y)}var zt=Object.freeze({__proto__:null,area:xt,bottomRight:function(t){return r(t.x+t.width,t.y+t.height)},center:ft,containFit:mt,containsPoints:function(t,...n){return n.every(n=>t.x<=n.x&&t.x+t.width>=n.x&&t.y<=n.y&&t.y+t.height>=n.y)},create:ct,cropFit:ht,fromDimensions:function(t){return ct(0,0,t.width,t.height)},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o]=n;return ct(t,r,e,o)}{const{x:t,y:r,width:e,height:o}=n;return ct(t,r,e,o)}},fromPointAndDimensions:st,fromPoints:function(t,n){const r=Math.min(t.x,n.x),e=Math.min(t.y,n.y);return ct(r,e,Math.max(t.x,n.x)-r,Math.max(t.y,n.y)-e)},isEqual:function(t,n){return i(t,n)&&Mt(t,n)},isLandscape:function(t){return t.width>t.height},isPortrait:function(t){return t.width<t.height},isSquare:function(t){return t.width===t.height},offset:function(t,n){return st(o(lt(n),t),n)},pad:function(t,n){return ct(t.x-n,t.y-n,t.width+2*n,t.height+2*n)},scale:function t(n,r,e){if(null==e)return t(n,r,r);{const{x:t,y:o,width:i,height:a}=n;return ct(t*r,o*e,i*r,a*e)}},scaleFit:yt,topLeft:lt});const dt=(t,n)=>({width:t,height:n}),Mt=(t,n)=>t.width===n.width&&t.height===n.height,wt=(t,n,r)=>({width:r.width*t,height:r.height*n}),gt=(t,n)=>wt(t,t,n),pt=t=>({width:Math.floor(t.width),height:Math.floor(t.height)}),_t=t=>({x:t.width/2,y:t.height/2});function bt(t,n=r()){return st(n,t)}var vt=Object.freeze({__proto__:null,area:({width:t,height:n})=>t*n,aspectRatio:({width:t,height:n})=>t/n,center:_t,containFit:(t,n)=>{const{width:r,height:e}=mt(bt(t),bt(n));return{width:r,height:e}},create:dt,cropFit:(t,n)=>{const{width:r,height:e}=ht(bt(t),bt(n));return{width:r,height:e}},fitToRatio:(t,n)=>n.width>=n.height*t?dt(n.height*t,n.height):dt(n.width,n.width/t),floor:pt,isEqual:Mt,proportionalScale:gt,round:t=>({width:Math.round(t.width),height:Math.round(t.height)}),scale:wt,scaleFit:(t,n)=>{const{width:r,height:e}=yt(t,bt(n));return{width:r,height:e}},square:t=>dt(t,t),toRectangle:bt,trim:(t,n)=>({width:Math.min(t.width,n.width),height:Math.min(t.height,n.height)})});function Ot(t){return W(t.end,t.start)}var Pt=Object.freeze({__proto__:null,center:function(t){return tt(t.start,t.end,.5)},create:function(t={}){var n,r;return{start:null!==(n=t.start)&&void 0!==n?n:E(),end:null!==(r=t.end)&&void 0!==r?r:E()}},direction:Ot,distance:function(t){return U(t.start,t.end)},distanceSquared:function(t){return X(t.start,t.end)},transformMatrix:function(t,n){return{start:K(t.start,n),end:K(t.end,n)}}});const jt=(t=1,n=0,r=0,e=1,o=0,i=0)=>({a:t,b:n,c:r,d:e,tx:o,ty:i}),At=()=>jt(),kt=(t,n)=>{const r=x(t),e=Math.cos(r),o=Math.sin(r),i=n.a*e+n.c*o,a=n.b*e+n.d*o,u=n.a*-o+n.c*e,c=n.b*-o+n.d*e;return jt(i,a,u,c,n.tx,n.ty)},qt=(t,n,r)=>{const e=r.a*t+r.c*n+r.tx,o=r.b*t+r.d*n+r.ty;return jt(r.a,r.b,r.c,r.d,e,o)};var St=Object.freeze({__proto__:null,create:jt,identity:At,rotate:kt,rotation:t=>kt(t,At()),transformPoint:(t,n)=>r(t.a*n.x+t.c*n.y+t.tx,t.b*n.x+t.d*n.y+t.ty),translate:qt,translation:(t,n)=>qt(t,n,At())});var Rt=Object.freeze({__proto__:null,create:function(...t){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 Tt(t={}){return{normal:E(),constant:0,...t}}function Jt(t,n){return H(t.normal,n)+t.constant}var Vt=Object.freeze({__proto__:null,create:Tt,distanceToPoint:Jt,fromNormalAndCoplanarPoint:function(t,n){return Tt({normal:t,constant:-H(n,t)})},intersectLine:function(t,n){const r=Ot(n),e=H(t.normal,r);if(0===e)return 0===Jt(t,n.start)?n.start:void 0;const o=-(H(n.start,t.normal)+t.constant)/e;return o<0||o>1?void 0:Q(G(o,r),n.start)},projectPoint:function(t,n){return Q(n,G(-Jt(t,n),t.normal))}});function Nt(t,n){return Q(G(n,t.direction),t.origin)}function Ft(t,n){const r=H(n.normal,t.direction);if(0===r)return 0===Jt(n,t.origin)?0:void 0;{const e=-(H(t.origin,n.normal)+n.constant)/r;return e>=0?e:void 0}}var Dt=Object.freeze({__proto__:null,at:Nt,create:function(t={}){var n,r;return{origin:null!==(n=t.origin)&&void 0!==n?n:E(),direction:null!==(r=t.direction)&&void 0!==r?r:B()}},distanceToPlane:Ft,intersectPlane:function(t,n){const r=Ft(t,n);return null!=r?Nt(t,r):void 0}});function Bt(t={}){return{x:0,y:0,z:0,w:0,...t}}var Et=Object.freeze({__proto__:null,create:Bt,fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o]=n;return Bt({x:t,y:r,z:e,w:o})}return Bt(n)}});export{f as Angle,at as BoundingBox,ut as BoundingSphere,vt as Dimensions,q as Euler,Pt as Line3,St as Matrix,Rt as Matrix2,j as Matrix4,Vt as Plane,m as Point,V as Quaternion,Dt as Ray,zt as Rectangle,nt as Vector3,Et as Vector4,t as clamp,n as lerp};
|
|
1
|
+
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=0,n=0){return{x:t,y:n}}function e(t,n){return{x:t.x-n.x,y:t.y-n.y}}function o(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 a(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){const n=u(t);return 0===n?r(0,0):a(t,1/n)}function s(t,n){return c(e(n,t))}var m=Object.freeze({__proto__:null,add:o,create:r,distance:function(t,n){const r=e(t,n);return Math.sqrt(r.x*r.x+r.y*r.y)},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,e]=n;return r(t,e)}{const{x:t,y:e}=n;return r(t,e)}},isEqual:i,lerp:function(t,r,e){return{x:n(t.x,r.x,e),y:n(t.y,r.y,e)}},magnitude:u,negate:function(t){return r(-t.x,-t.y)},normalDirectionVector:s,normalizeVector:c,orthogonalVector:function(t,n){const e=s(t,n);if(0===e.x||0===e.y)return r(-1*e.y,e.x);if(Math.abs(e.x)>Math.abs(e.y)){return c(r(1-Math.pow(e.x,2),-1*e.x*e.y))}return c(r(-1*e.x*e.y,1-Math.pow(e.y,2)))},polar:function(t,n){return r(Math.cos(n)*t,Math.sin(n)*t)},scale:function(t,n,r){return{x:t.x*n,y:t.y*r}},scaleProportional:a,subtract:e});function h(t){return(t+3600)%360}function y(t){return t*(180/Math.PI)}function x(t){return t*(Math.PI/180)}var f=Object.freeze({__proto__:null,fromPoints:function(t,n){const r=e(n,t);return Math.atan2(r.y,r.x)},fromPointsInDegrees:function(t,n){const r=e(n,t);return h(y(Math.atan2(r.y,r.x))-270)},normalize:h,normalizeRadians:function(t){return x(h(y(t)))},toDegrees:y,toRadians:x});function l(t,n,r,e,o,i,a,u,c,s,m,h,y,x,f,l){return[t,n,r,e,o,i,a,u,c,s,m,h,y,x,f,l]}function z(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function d(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}function M(t){const{x:n,y:r,z:e}=t;return[1,0,0,0,0,1,0,0,0,0,1,0,n,r,e,1]}function w(t){const{x:n,y:r,z:e,w:o}=t,i=n+n,a=r+r,u=e+e,c=n*i,s=n*a,m=n*u,h=r*a,y=r*u,x=e*u,f=o*i,l=o*a,z=o*u;return[1-(h+x),s-z,m+l,0,s+z,1-(c+x),y-f,0,m-l,y+f,1-(c+h),0,0,0,0,1]}function g(t){const{x:n,y:r,z:e}=t;return[n,0,0,0,0,r,0,0,0,0,e,0,0,0,0,1]}function p(t,n,r,e,o,i){return[2*o/(n-t),0,0,0,0,2*o/(r-e),0,0,(n+t)/(n-t),(r+e)/(r-e),-(i+o)/(i-o),-1,0,0,-2*i*o/(i-o),0]}function _(t,n){const r=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];for(let e=0;e<4;e++)for(let o=0;o<4;o++){let i=0;for(let r=0;r<4;r++)i+=t[4*e+r]*n[4*r+o];r[4*e+o]=i}return r}function b(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]]}function v(t,n){const{x:r,y:e,z:o}=n,i=[...t];return i[0]*=r,i[1]*=r,i[2]*=r,i[3]*=r,i[4]*=e,i[5]*=e,i[6]*=e,i[7]*=e,i[8]*=o,i[9]*=o,i[10]*=o,i[11]*=o,i}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]}}function P(t){return{m11:t[0],m12:t[1],m13:t[2],m14:t[3],m21:t[4],m22:t[5],m23:t[6],m24:t[7],m31:t[8],m32:t[9],m33:t[10],m34:t[11],m41:t[12],m42:t[13],m43:t[14],m44:t[15]}}var j=Object.freeze({__proto__:null,fromObject:function(t){return l(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)},fromValues:l,invert:function(t){const n=t[0],r=t[1],e=t[2],o=t[3],i=t[4],a=t[5],u=t[6],c=t[7],s=t[8],m=t[9],h=t[10],y=t[11],x=t[12],f=t[13],l=t[14],z=t[15],d=n*a-r*i,M=n*u-e*i,w=n*c-o*i,g=r*u-e*a,p=r*c-o*a,_=e*c-o*u,b=s*f-m*x,v=s*l-h*x,O=s*z-y*x,P=m*l-h*f,j=m*z-y*f,A=h*z-y*l,k=d*A-M*j+w*P+g*O-p*v+_*b;if(!k)return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];const q=1/k;return[(a*A-u*j+c*P)*q,(e*j-r*A-o*P)*q,(f*_-l*p+z*g)*q,(h*p-m*_-y*g)*q,(u*O-i*A-c*v)*q,(n*A-e*O+o*v)*q,(l*w-x*_-z*M)*q,(s*_-h*w+y*M)*q,(i*j-a*O+c*b)*q,(r*O-n*j-o*b)*q,(x*p-f*w+z*d)*q,(m*w-s*p-y*d)*q,(a*v-i*P-u*b)*q,(n*P-r*v+e*b)*q,(f*M-x*g-l*d)*q,(s*g-m*M+h*d)*q]},isIdentity:function(t){const n=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return t.every((t,r)=>t===n[r])},isType:function(t){return Array.isArray(t)&&16===t.length},lookAt:function(t,n,r,e){let o=W(n,r);0===C(o)&&(o={...o,z:1}),o=I(o);let i=Z(e,o);0===C(i)&&(o=1===Math.abs(e.z)?{...o,x:o.x+1e-4}:{...o,z:o.z+1e-4},o=I(o),i=Z(e,o)),i=I(i);const a=Z(o,i),u=[...t];return u[0]=i.x,u[1]=i.y,u[2]=i.z,u[4]=a.x,u[5]=a.y,u[6]=a.z,u[8]=o.x,u[9]=o.y,u[10]=o.z,u},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]},makeFrustum:p,makeIdentity:z,makeLookAt:function(t,n,r){const e=I(W(t,n)),o=I(Z(r,e)),i=Z(e,o);return[o.x,o.y,o.z,0,i.x,i.y,i.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,1]},makeLookAtView:function(t,n,r){const e=I(W(t,n)),o=I(Z(r,e)),i=Z(e,o),a=-H(o,t),u=-H(i,t),c=-H(e,t);return[o.x,i.x,e.x,0,o.y,i.y,e.y,0,o.z,i.z,e.z,0,a,u,c,1]},makeOrthographic:function(t,n,r,e,o,i){const a=1/(n-t),u=1/(e-r),c=1/(i-o);return[2*a,0,0,-((n+t)*a),0,2*u,0,-((e+r)*u),0,0,-2*c,-((i+o)*c),0,0,0,1]},makePerspective:function(t,n,r,e){const o=t*Math.tan(x(r/2)),i=o*e;return p(-i,i,o,-o,t,n)},makeRotation:w,makeScale:g,makeTRS:function(t,n,r){const e=M(t),o=b(w(n));return _(g(r),_(o,e))},makeTranslation:M,makeZero:d,multiply:_,position:function(t,n){const r=[...t];return r[12]=n[12],r[13]=n[13],r[14]=n[14],r},scale:v,toObject:function(t){return O(t)},toObjectColumnMajor:O,toObjectRowMajor:P,transpose:b});function A(t={}){var n,r,e,o;return{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!==(o=t.order)&&void 0!==o?o:"xyz"}}function k(n,r="xyz",e=!0){const o=e?O(n):P(n);let i=0,a=0,u=0;return"xyz"===r?(a=Math.asin(t(o.m13,-1,1)),Math.abs(o.m13)<.9999999?(i=Math.atan2(-o.m23,o.m33),u=Math.atan2(-o.m12,o.m11)):(i=Math.atan2(o.m32,o.m22),u=0)):"yxz"===r?(i=Math.asin(-t(o.m23,-1,1)),Math.abs(o.m23)<.9999999?(a=Math.atan2(o.m13,o.m33),u=Math.atan2(o.m21,o.m22)):(a=Math.atan2(-o.m31,o.m11),u=0)):"zxy"===r?(i=Math.asin(t(o.m32,-1,1)),Math.abs(o.m32)<.9999999?(a=Math.atan2(-o.m31,o.m33),u=Math.atan2(-o.m12,o.m22)):(a=0,u=Math.atan2(o.m21,o.m11))):"zyx"===r?(a=Math.asin(-t(o.m31,-1,1)),Math.abs(o.m31)<.9999999?(i=Math.atan2(o.m32,o.m33),u=Math.atan2(o.m21,o.m11)):(i=0,u=Math.atan2(-o.m12,o.m22))):"yzx"===r?(u=Math.asin(t(o.m21,-1,1)),Math.abs(o.m21)<.9999999?(i=Math.atan2(-o.m23,o.m22),a=Math.atan2(-o.m31,o.m11)):(i=0,a=Math.atan2(o.m13,o.m33))):"xzy"===r&&(u=Math.asin(-t(o.m12,-1,1)),Math.abs(o.m12)<.9999999?(i=Math.atan2(o.m32,o.m22),a=Math.atan2(o.m13,o.m11)):(i=Math.atan2(-o.m23,o.m33),a=0)),{x:i,y:a,z:u,order:r}}var q=Object.freeze({__proto__:null,create:A,fromDegrees:function(t={}){const{x:n=0,y:r=0,z:e=0,order:o}=t;return A({x:x(n),y:x(r),z:x(e),order:o})},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o="xyz"]=n;return{x:t,y:r,z:e,order:o}}{const{x:t,y:r,z:e,order:o="xyz"}=n;return{x:t,y:r,z:e,order:o}}},fromRotationMatrix:k,isType:function(t){const n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("order")}});function S(t={}){return{x:0,y:0,z:0,w:1,...t}}function R(t){return J(1/T(t),t)}function T(t){return Math.sqrt(t.w*t.w+t.x*t.x+t.y*t.y+t.z*t.z)}function J(t,n){return S({w:n.w*t,x:n.x*t,y:n.y*t,z:n.z*t})}var N=Object.freeze({__proto__:null,create:S,fromAxisAngle:function(t,n){const r=n/2,e=Math.sin(r);return{x:t.x*e,y:t.y*e,z:t.z*e,w:Math.cos(r)}},fromEuler:function(t){const{x:n,y:r,z:e,order:o}=t,i=Math.cos(n/2),a=Math.cos(r/2),u=Math.cos(e/2),c=Math.sin(n/2),s=Math.sin(r/2),m=Math.sin(e/2);let h=0,y=0,x=0,f=0;switch(o){case"xyz":h=c*a*u+i*s*m,y=i*s*u-c*a*m,x=i*a*m+c*s*u,f=i*a*u-c*s*m;break;case"yxz":h=c*a*u+i*s*m,y=i*s*u-c*a*m,x=i*a*m-c*s*u,f=i*a*u+c*s*m;break;case"zxy":h=c*a*u-i*s*m,y=i*s*u+c*a*m,x=i*a*m+c*s*u,f=i*a*u-c*s*m;break;case"zyx":h=c*a*u-i*s*m,y=i*s*u+c*a*m,x=i*a*m-c*s*u,f=i*a*u+c*s*m;break;case"yzx":h=c*a*u+i*s*m,y=i*s*u+c*a*m,x=i*a*m-c*s*u,f=i*a*u-c*s*m;break;case"xzy":h=c*a*u-i*s*m,y=i*s*u-c*a*m,x=i*a*m+c*s*u,f=i*a*u+c*s*m}return{x:h,y:y,z:x,w:f}},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o]=n;return S({x:t,y:r,z:e,w:o})}return S(n)},fromMatrixRotation:function(t){const n=D(t),r=P(v(t,V(1/n.x,1/n.y,1/n.z))),e=r.m11+r.m22+r.m33;if(e>0){const t=2*Math.sqrt(e+1);return{x:(r.m23-r.m32)/t,y:(r.m31-r.m13)/t,z:(r.m12-r.m21)/t,w:.25*t}}if(r.m11>r.m22&&r.m11>r.m33){const t=2*Math.sqrt(1+r.m11-r.m22-r.m33);return{x:.25*t,y:(r.m12+r.m21)/t,z:(r.m31+r.m13)/t,w:(r.m23-r.m32)/t}}if(r.m22>r.m33){const t=2*Math.sqrt(1+r.m22-r.m11-r.m33);return{x:(r.m12+r.m21)/t,y:.25*t,z:(r.m23+r.m32)/t,w:(r.m31-r.m13)/t}}{const t=2*Math.sqrt(1+r.m33-r.m11-r.m22);return{x:(r.m31+r.m13)/t,y:(r.m23+r.m32)/t,z:.25*t,w:(r.m12-r.m21)/t}}},isType:function(t){const n=t;return null!=n&&n.hasOwnProperty("x")&&n.hasOwnProperty("y")&&n.hasOwnProperty("z")&&n.hasOwnProperty("w")},magnitude:T,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}},normalize:R,scale:J});function V(...t){var n,r,e,o,i,a;return 1===t.length?{x:null!==(n=t[0].x)&&void 0!==n?n:0,y:null!==(r=t[0].y)&&void 0!==r?r:0,z:null!==(e=t[0].z)&&void 0!==e?e:0}:3===t.length?{x:null!==(o=t[0])&&void 0!==o?o:0,y:null!==(i=t[1])&&void 0!==i?i:0,z:null!==(a=t[2])&&void 0!==a?a:0}:{x:0,y:0,z:0}}function F({x:t,y:n,z:r}){return[t,n,r].every(t=>Number.isFinite(t)&&!Number.isNaN(t))}function D(t){const n=P(t);return{x:Math.hypot(n.m11,n.m12,n.m13),y:Math.hypot(n.m21,n.m22,n.m23),z:Math.hypot(n.m31,n.m32,n.m33)}}function B(){return V(0,0,-1)}function E(){return V(0,0,0)}function I(t){const n=L(t);return{x:t.x/n,y:t.y/n,z:t.z/n}}function L(t){return Math.sqrt(C(t))}function C(t){return t.x*t.x+t.y*t.y+t.z*t.z}function Z(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 Q(t,...n){return n.reduce((t,n)=>({x:t.x+n.x,y:t.y+n.y,z:t.z+n.z}),t)}function W(t,...n){return n.reduce((t,n)=>({x:t.x-n.x,y:t.y-n.y,z:t.z-n.z}),t)}function G(t,n){return{x:n.x*t,y:n.y*t,z:n.z*t}}function H(t,n){return t.x*n.x+t.y*n.y+t.z*n.z}function K(t,n){const{x:r,y:e,z:o}=t,i=1/(n[3]*r+n[7]*e+n[11]*o+n[15]);return{x:(n[0]*r+n[4]*e+n[8]*o+n[12])*i,y:(n[1]*r+n[5]*e+n[9]*o+n[13])*i,z:(n[2]*r+n[6]*e+n[10]*o+n[14])*i}}function U(t,n){return Math.sqrt(X(t,n))}function X(t,n){const{x:r,y:e,z:o}=W(t,n);return r*r+e*e+o*o}function Y(t,n){return V(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))}function $(t,n){return V(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z))}function tt(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 nt=Object.freeze({__proto__:null,add:Q,angleTo:function(t,n){const r=H(t,n)/(L(t)*L(n));return Math.acos(r)},back:function(){return V(0,0,1)},create:V,cross:Z,distance:U,distanceSquared:X,dot:H,down:function(){return V(0,-1,0)},eulerTo:function(t,n){const r=I(t),e=I(n),o=Math.cos(x(1)),i=H(r,e);return Math.abs(i)>o?i>.999999?A():A({x:Math.PI}):k(w(R(S({w:1+i,...Z(r,e)}))),"xyz",!1)},forward:B,fromArray:function(t,n=0){return V(t[n],t[n+1],t[n+2])},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e]=n;return V(t,r,e)}{const{x:t,y:r,z:e}=n;return V(t,r,e)}},fromMatrixPosition:function(t){const n=P(t);return{x:n.m41,y:n.m42,z:n.m43}},fromMatrixScale:D,isEqual:function(t,n){return t.x===n.x&&t.y===n.y&&t.z===n.z},isValid:F,isZeroVector:function({x:t,y:n,z:r}){return[t,n,r].every(t=>0===t)},left:function(){return V(-1,0,0)},lerp:tt,magnitude:L,magnitudeSquared:C,max:Y,min:$,multiply:function(t,n){return{x:t.x*n.x,y:t.y*n.y,z:t.z*n.z}},multiplyByTransformMatrixColumnMajor:K,multiplyByTransformMatrixRowMajor:function(t,n){const{x:r,y:e,z:o}=t,i=1/(n[12]*r+n[13]*e+n[14]*o+n[15]);return{x:(n[0]*r+n[1]*e+n[2]*o+n[3])*i,y:(n[4]*r+n[5]*e+n[6]*o+n[7])*i,z:(n[8]*r+n[9]*e+n[10]*o+n[11])*i}},negate:function(t){return{x:-t.x,y:-t.y,z:-t.z}},normalize:I,origin:E,project:function(t,n){return G(H(n,t)/L(n),n)},right:function(){return V(1,0,0)},rotateAboutAxis:function(t,n,r,e){if(0!==t){const{x:o,y:i,z:a}=n,{x:u,y:c,z:s}=e,{x:m,y:h,z:y}=r;return{x:(u*(h*h+y*y)-m*(c*h+s*y-m*o-h*i-y*a))*(1-Math.cos(t))+o*Math.cos(t)+(-s*h+c*y-y*i+h*a)*Math.sin(t),y:(c*(m*m+y*y)-h*(u*m+s*y-m*o-h*i-y*a))*(1-Math.cos(t))+i*Math.cos(t)+(s*m-u*y+y*o-m*a)*Math.sin(t),z:(s*(m*m+h*h)-y*(u*m+c*h-m*o-h*i-y*a))*(1-Math.cos(t))+a*Math.cos(t)+(-c*m+u*h-h*o+m*i)*Math.sin(t)}}return n},scale:G,subtract:W,toArray:function({x:t,y:n,z:r}){return[t,n,r]},transformMatrix:function(t,n){return K(t,n)},transformNdcToWorldSpace:function(t,n,r){return K(K(t,r),n)},up:function(){return V(0,1,0)}});const rt=(t,n)=>({min:t,max:n}),et=t=>G(.5,Q(t.min,t.max)),ot=t=>W(t.max,t.min);function it(t,...n){return n.reduce((t,n)=>rt($(t.min,n.min),Y(t.max,n.max)),t)}var at=Object.freeze({__proto__:null,center:et,create:rt,diagonal:ot,epsilon:t=>1e-6*Math.max(Math.max(L(t.max),L(t.min)),L(ot(t))),fromVectors:t=>it(...t.map(t=>rt(t,t))),isValid:function(t){const n=F(t.max),r=F(t.min);return n&&r},lengths:t=>V(t.max.x-t.min.x,t.max.y-t.min.y,t.max.z-t.min.z),union:it});var ut=Object.freeze({__proto__:null,create:t=>{const n=et(t),r=L(W(t.max,n)),e=Math.max(r,L(n));return{center:n,radius:r,epsilon:0===e?1:1e-6*e}}});function ct(t,n,r,e){return{x:t,y:n,width:r,height:e}}function st(t,n){return ct(t.x,t.y,n.width,n.height)}function mt(t,n){const r=Math.min(t.width/n.width,t.height/n.height),o=gt(r,n);return st(e(ft(t),_t(o)),o)}function ht(t,n){const r=Math.max(t.width/n.width,t.height/n.height),o=gt(r,n);return st(e(ft(t),_t(o)),o)}function yt(t,n){const r=Math.min(Math.sqrt(t/xt(n)),1),o=pt(gt(r,n));return st(e(ft(n),_t(o)),o)}function xt(t){return t.width*t.height}function ft(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function lt(t){return r(t.x,t.y)}var zt=Object.freeze({__proto__:null,area:xt,bottomRight:function(t){return r(t.x+t.width,t.y+t.height)},center:ft,containFit:mt,containsPoints:function(t,...n){return n.every(n=>t.x<=n.x&&t.x+t.width>=n.x&&t.y<=n.y&&t.y+t.height>=n.y)},create:ct,cropFit:ht,fromDimensions:function(t){return ct(0,0,t.width,t.height)},fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o]=n;return ct(t,r,e,o)}{const{x:t,y:r,width:e,height:o}=n;return ct(t,r,e,o)}},fromPointAndDimensions:st,fromPoints:function(t,n){const r=Math.min(t.x,n.x),e=Math.min(t.y,n.y);return ct(r,e,Math.max(t.x,n.x)-r,Math.max(t.y,n.y)-e)},isEqual:function(t,n){return i(t,n)&&Mt(t,n)},isLandscape:function(t){return t.width>t.height},isPortrait:function(t){return t.width<t.height},isSquare:function(t){return t.width===t.height},offset:function(t,n){return st(o(lt(n),t),n)},pad:function(t,n){return ct(t.x-n,t.y-n,t.width+2*n,t.height+2*n)},scale:function t(n,r,e){if(null==e)return t(n,r,r);{const{x:t,y:o,width:i,height:a}=n;return ct(t*r,o*e,i*r,a*e)}},scaleFit:yt,topLeft:lt});const dt=(t,n)=>({width:t,height:n}),Mt=(t,n)=>t.width===n.width&&t.height===n.height,wt=(t,n,r)=>({width:r.width*t,height:r.height*n}),gt=(t,n)=>wt(t,t,n),pt=t=>({width:Math.floor(t.width),height:Math.floor(t.height)}),_t=t=>({x:t.width/2,y:t.height/2});function bt(t,n=r()){return st(n,t)}var vt=Object.freeze({__proto__:null,area:({width:t,height:n})=>t*n,aspectRatio:({width:t,height:n})=>t/n,center:_t,containFit:(t,n)=>{const{width:r,height:e}=mt(bt(t),bt(n));return{width:r,height:e}},create:dt,cropFit:(t,n)=>{const{width:r,height:e}=ht(bt(t),bt(n));return{width:r,height:e}},fitToRatio:(t,n)=>n.width>=n.height*t?dt(n.height*t,n.height):dt(n.width,n.width/t),floor:pt,isEqual:Mt,proportionalScale:gt,round:t=>({width:Math.round(t.width),height:Math.round(t.height)}),scale:wt,scaleFit:(t,n)=>{const{width:r,height:e}=yt(t,bt(n));return{width:r,height:e}},square:t=>dt(t,t),toRectangle:bt,trim:(t,n)=>({width:Math.min(t.width,n.width),height:Math.min(t.height,n.height)})});function Ot(t){return W(t.end,t.start)}var Pt=Object.freeze({__proto__:null,center:function(t){return tt(t.start,t.end,.5)},create:function(t={}){var n,r;return{start:null!==(n=t.start)&&void 0!==n?n:E(),end:null!==(r=t.end)&&void 0!==r?r:E()}},direction:Ot,distance:function(t){return U(t.start,t.end)},distanceSquared:function(t){return X(t.start,t.end)},transformMatrix:function(t,n){return{start:K(t.start,n),end:K(t.end,n)}}});const jt=(t=1,n=0,r=0,e=1,o=0,i=0)=>({a:t,b:n,c:r,d:e,tx:o,ty:i}),At=()=>jt(),kt=(t,n)=>{const r=x(t),e=Math.cos(r),o=Math.sin(r),i=n.a*e+n.c*o,a=n.b*e+n.d*o,u=n.a*-o+n.c*e,c=n.b*-o+n.d*e;return jt(i,a,u,c,n.tx,n.ty)},qt=(t,n,r)=>{const e=r.a*t+r.c*n+r.tx,o=r.b*t+r.d*n+r.ty;return jt(r.a,r.b,r.c,r.d,e,o)};var St=Object.freeze({__proto__:null,create:jt,identity:At,rotate:kt,rotation:t=>kt(t,At()),transformPoint:(t,n)=>r(t.a*n.x+t.c*n.y+t.tx,t.b*n.x+t.d*n.y+t.ty),translate:qt,translation:(t,n)=>qt(t,n,At())});var Rt=Object.freeze({__proto__:null,create:function(...t){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 Tt(t={}){return{normal:E(),constant:0,...t}}function Jt(t,n){return H(t.normal,n)+t.constant}var Nt=Object.freeze({__proto__:null,create:Tt,distanceToPoint:Jt,fromNormalAndCoplanarPoint:function(t,n){return Tt({normal:t,constant:-H(n,t)})},intersectLine:function(t,n){const r=Ot(n),e=H(t.normal,r);if(0===e)return 0===Jt(t,n.start)?n.start:void 0;const o=-(H(n.start,t.normal)+t.constant)/e;return o<0||o>1?void 0:Q(G(o,r),n.start)},projectPoint:function(t,n){return Q(n,G(-Jt(t,n),t.normal))}});function Vt(t,n){return Q(G(n,t.direction),t.origin)}function Ft(t,n){const r=H(n.normal,t.direction);if(0===r)return 0===Jt(n,t.origin)?0:void 0;{const e=-(H(t.origin,n.normal)+n.constant)/r;return e>=0?e:void 0}}var Dt=Object.freeze({__proto__:null,at:Vt,create:function(t={}){var n,r;return{origin:null!==(n=t.origin)&&void 0!==n?n:E(),direction:null!==(r=t.direction)&&void 0!==r?r:B()}},distanceToPlane:Ft,intersectPlane:function(t,n){const r=Ft(t,n);return null!=r?Vt(t,r):void 0}});function Bt(t={}){return{x:0,y:0,z:0,w:0,...t}}var Et=Object.freeze({__proto__:null,create:Bt,fromJson:function(t){const n=JSON.parse(t);if(Array.isArray(n)){const[t,r,e,o]=n;return Bt({x:t,y:r,z:e,w:o})}return Bt(n)}});export{f as Angle,at as BoundingBox,ut as BoundingSphere,vt as Dimensions,q as Euler,Pt as Line3,St as Matrix,Rt as Matrix2,j as Matrix4,Nt as Plane,m as Point,N as Quaternion,Dt as Ray,zt as Rectangle,nt as Vector3,Et as Vector4,t as clamp,n as lerp};
|
|
2
2
|
//# sourceMappingURL=bundle.min.js.map
|