chunk-FEOWMVRK.js 4.8 KB

1
  1. import{a as u}from"./chunk-LNIYJJXS.js";import{a as r}from"./chunk-4D2ERGZX.js";import{a as y}from"./chunk-EDZQSM3T.js";import{a as i}from"./chunk-PJGSCWXZ.js";import{a as c}from"./chunk-NUC3LT2W.js";function o(e,n){this.x=r(e,0),this.y=r(n,0)}o.fromElements=function(e,n,t){return c(t)?(t.x=e,t.y=n,t):new o(e,n)};o.clone=function(e,n){if(!!c(e))return c(n)?(n.x=e.x,n.y=e.y,n):new o(e.x,e.y)};o.fromCartesian3=o.clone;o.fromCartesian4=o.clone;o.packedLength=2;o.pack=function(e,n,t){return y.typeOf.object("value",e),y.defined("array",n),t=r(t,0),n[t++]=e.x,n[t]=e.y,n};o.unpack=function(e,n,t){return y.defined("array",e),n=r(n,0),c(t)||(t=new o),t.x=e[n++],t.y=e[n],t};o.packArray=function(e,n){y.defined("array",e);var t=e.length,f=t*2;if(!c(n))n=new Array(f);else{if(!Array.isArray(n)&&n.length!==f)throw new i("If result is a typed array, it must have exactly array.length * 2 elements");n.length!==f&&(n.length=f)}for(var p=0;p<t;++p)o.pack(e[p],n,p*2);return n};o.unpackArray=function(e,n){if(y.defined("array",e),y.typeOf.number.greaterThanOrEquals("array.length",e.length,2),e.length%2!==0)throw new i("array length must be a multiple of 2.");var t=e.length;c(n)?n.length=t/2:n=new Array(t/2);for(var f=0;f<t;f+=2){var p=f/2;n[p]=o.unpack(e,f,n[p])}return n};o.fromArray=o.unpack;o.maximumComponent=function(e){return y.typeOf.object("cartesian",e),Math.max(e.x,e.y)};o.minimumComponent=function(e){return y.typeOf.object("cartesian",e),Math.min(e.x,e.y)};o.minimumByComponent=function(e,n,t){return y.typeOf.object("first",e),y.typeOf.object("second",n),y.typeOf.object("result",t),t.x=Math.min(e.x,n.x),t.y=Math.min(e.y,n.y),t};o.maximumByComponent=function(e,n,t){return y.typeOf.object("first",e),y.typeOf.object("second",n),y.typeOf.object("result",t),t.x=Math.max(e.x,n.x),t.y=Math.max(e.y,n.y),t};o.magnitudeSquared=function(e){return y.typeOf.object("cartesian",e),e.x*e.x+e.y*e.y};o.magnitude=function(e){return Math.sqrt(o.magnitudeSquared(e))};var a=new o;o.distance=function(e,n){return y.typeOf.object("left",e),y.typeOf.object("right",n),o.subtract(e,n,a),o.magnitude(a)};o.distanceSquared=function(e,n){return y.typeOf.object("left",e),y.typeOf.object("right",n),o.subtract(e,n,a),o.magnitudeSquared(a)};o.normalize=function(e,n){y.typeOf.object("cartesian",e),y.typeOf.object("result",n);var t=o.magnitude(e);if(n.x=e.x/t,n.y=e.y/t,isNaN(n.x)||isNaN(n.y))throw new i("normalized result is not a number");return n};o.dot=function(e,n){return y.typeOf.object("left",e),y.typeOf.object("right",n),e.x*n.x+e.y*n.y};o.multiplyComponents=function(e,n,t){return y.typeOf.object("left",e),y.typeOf.object("right",n),y.typeOf.object("result",t),t.x=e.x*n.x,t.y=e.y*n.y,t};o.divideComponents=function(e,n,t){return y.typeOf.object("left",e),y.typeOf.object("right",n),y.typeOf.object("result",t),t.x=e.x/n.x,t.y=e.y/n.y,t};o.add=function(e,n,t){return y.typeOf.object("left",e),y.typeOf.object("right",n),y.typeOf.object("result",t),t.x=e.x+n.x,t.y=e.y+n.y,t};o.subtract=function(e,n,t){return y.typeOf.object("left",e),y.typeOf.object("right",n),y.typeOf.object("result",t),t.x=e.x-n.x,t.y=e.y-n.y,t};o.multiplyByScalar=function(e,n,t){return y.typeOf.object("cartesian",e),y.typeOf.number("scalar",n),y.typeOf.object("result",t),t.x=e.x*n,t.y=e.y*n,t};o.divideByScalar=function(e,n,t){return y.typeOf.object("cartesian",e),y.typeOf.number("scalar",n),y.typeOf.object("result",t),t.x=e.x/n,t.y=e.y/n,t};o.negate=function(e,n){return y.typeOf.object("cartesian",e),y.typeOf.object("result",n),n.x=-e.x,n.y=-e.y,n};o.abs=function(e,n){return y.typeOf.object("cartesian",e),y.typeOf.object("result",n),n.x=Math.abs(e.x),n.y=Math.abs(e.y),n};var m=new o;o.lerp=function(e,n,t,f){return y.typeOf.object("start",e),y.typeOf.object("end",n),y.typeOf.number("t",t),y.typeOf.object("result",f),o.multiplyByScalar(n,t,m),f=o.multiplyByScalar(e,1-t,f),o.add(m,f,f)};var b=new o,O=new o;o.angleBetween=function(e,n){return y.typeOf.object("left",e),y.typeOf.object("right",n),o.normalize(e,b),o.normalize(n,O),u.acosClamped(o.dot(b,O))};var x=new o;o.mostOrthogonalAxis=function(e,n){y.typeOf.object("cartesian",e),y.typeOf.object("result",n);var t=o.normalize(e,x);return o.abs(t,t),t.x<=t.y?n=o.clone(o.UNIT_X,n):n=o.clone(o.UNIT_Y,n),n};o.equals=function(e,n){return e===n||c(e)&&c(n)&&e.x===n.x&&e.y===n.y};o.equalsArray=function(e,n,t){return e.x===n[t]&&e.y===n[t+1]};o.equalsEpsilon=function(e,n,t,f){return e===n||c(e)&&c(n)&&u.equalsEpsilon(e.x,n.x,t,f)&&u.equalsEpsilon(e.y,n.y,t,f)};o.ZERO=Object.freeze(new o(0,0));o.UNIT_X=Object.freeze(new o(1,0));o.UNIT_Y=Object.freeze(new o(0,1));o.prototype.clone=function(e){return o.clone(this,e)};o.prototype.equals=function(e){return o.equals(this,e)};o.prototype.equalsEpsilon=function(e,n,t){return o.equalsEpsilon(this,e,n,t)};o.prototype.toString=function(){return"("+this.x+", "+this.y+")"};var v=o;export{v as a};