chunk-CB3KB2D3.js 6.2 KB

1
  1. import{a as b}from"./chunk-LNIYJJXS.js";import{a as t}from"./chunk-4D2ERGZX.js";import{a as f}from"./chunk-EDZQSM3T.js";import{a as c}from"./chunk-PJGSCWXZ.js";import{a as m}from"./chunk-NUC3LT2W.js";function e(n,o,y,p){this.x=t(n,0),this.y=t(o,0),this.z=t(y,0),this.w=t(p,0)}e.fromElements=function(n,o,y,p,w){return m(w)?(w.x=n,w.y=o,w.z=y,w.w=p,w):new e(n,o,y,p)};e.fromColor=function(n,o){return f.typeOf.object("color",n),m(o)?(o.x=n.red,o.y=n.green,o.z=n.blue,o.w=n.alpha,o):new e(n.red,n.green,n.blue,n.alpha)};e.clone=function(n,o){if(!!m(n))return m(o)?(o.x=n.x,o.y=n.y,o.z=n.z,o.w=n.w,o):new e(n.x,n.y,n.z,n.w)};e.packedLength=4;e.pack=function(n,o,y){return f.typeOf.object("value",n),f.defined("array",o),y=t(y,0),o[y++]=n.x,o[y++]=n.y,o[y++]=n.z,o[y]=n.w,o};e.unpack=function(n,o,y){return f.defined("array",n),o=t(o,0),m(y)||(y=new e),y.x=n[o++],y.y=n[o++],y.z=n[o++],y.w=n[o],y};e.packArray=function(n,o){f.defined("array",n);var y=n.length,p=y*4;if(!m(o))o=new Array(p);else{if(!Array.isArray(o)&&o.length!==p)throw new c("If result is a typed array, it must have exactly array.length * 4 elements");o.length!==p&&(o.length=p)}for(var w=0;w<y;++w)e.pack(n[w],o,w*4);return o};e.unpackArray=function(n,o){if(f.defined("array",n),f.typeOf.number.greaterThanOrEquals("array.length",n.length,4),n.length%4!==0)throw new c("array length must be a multiple of 4.");var y=n.length;m(o)?o.length=y/4:o=new Array(y/4);for(var p=0;p<y;p+=4){var w=p/4;o[w]=e.unpack(n,p,o[w])}return o};e.fromArray=e.unpack;e.maximumComponent=function(n){return f.typeOf.object("cartesian",n),Math.max(n.x,n.y,n.z,n.w)};e.minimumComponent=function(n){return f.typeOf.object("cartesian",n),Math.min(n.x,n.y,n.z,n.w)};e.minimumByComponent=function(n,o,y){return f.typeOf.object("first",n),f.typeOf.object("second",o),f.typeOf.object("result",y),y.x=Math.min(n.x,o.x),y.y=Math.min(n.y,o.y),y.z=Math.min(n.z,o.z),y.w=Math.min(n.w,o.w),y};e.maximumByComponent=function(n,o,y){return f.typeOf.object("first",n),f.typeOf.object("second",o),f.typeOf.object("result",y),y.x=Math.max(n.x,o.x),y.y=Math.max(n.y,o.y),y.z=Math.max(n.z,o.z),y.w=Math.max(n.w,o.w),y};e.magnitudeSquared=function(n){return f.typeOf.object("cartesian",n),n.x*n.x+n.y*n.y+n.z*n.z+n.w*n.w};e.magnitude=function(n){return Math.sqrt(e.magnitudeSquared(n))};var O=new e;e.distance=function(n,o){return f.typeOf.object("left",n),f.typeOf.object("right",o),e.subtract(n,o,O),e.magnitude(O)};e.distanceSquared=function(n,o){return f.typeOf.object("left",n),f.typeOf.object("right",o),e.subtract(n,o,O),e.magnitudeSquared(O)};e.normalize=function(n,o){f.typeOf.object("cartesian",n),f.typeOf.object("result",o);var y=e.magnitude(n);if(o.x=n.x/y,o.y=n.y/y,o.z=n.z/y,o.w=n.w/y,isNaN(o.x)||isNaN(o.y)||isNaN(o.z)||isNaN(o.w))throw new c("normalized result is not a number");return o};e.dot=function(n,o){return f.typeOf.object("left",n),f.typeOf.object("right",o),n.x*o.x+n.y*o.y+n.z*o.z+n.w*o.w};e.multiplyComponents=function(n,o,y){return f.typeOf.object("left",n),f.typeOf.object("right",o),f.typeOf.object("result",y),y.x=n.x*o.x,y.y=n.y*o.y,y.z=n.z*o.z,y.w=n.w*o.w,y};e.divideComponents=function(n,o,y){return f.typeOf.object("left",n),f.typeOf.object("right",o),f.typeOf.object("result",y),y.x=n.x/o.x,y.y=n.y/o.y,y.z=n.z/o.z,y.w=n.w/o.w,y};e.add=function(n,o,y){return f.typeOf.object("left",n),f.typeOf.object("right",o),f.typeOf.object("result",y),y.x=n.x+o.x,y.y=n.y+o.y,y.z=n.z+o.z,y.w=n.w+o.w,y};e.subtract=function(n,o,y){return f.typeOf.object("left",n),f.typeOf.object("right",o),f.typeOf.object("result",y),y.x=n.x-o.x,y.y=n.y-o.y,y.z=n.z-o.z,y.w=n.w-o.w,y};e.multiplyByScalar=function(n,o,y){return f.typeOf.object("cartesian",n),f.typeOf.number("scalar",o),f.typeOf.object("result",y),y.x=n.x*o,y.y=n.y*o,y.z=n.z*o,y.w=n.w*o,y};e.divideByScalar=function(n,o,y){return f.typeOf.object("cartesian",n),f.typeOf.number("scalar",o),f.typeOf.object("result",y),y.x=n.x/o,y.y=n.y/o,y.z=n.z/o,y.w=n.w/o,y};e.negate=function(n,o){return f.typeOf.object("cartesian",n),f.typeOf.object("result",o),o.x=-n.x,o.y=-n.y,o.z=-n.z,o.w=-n.w,o};e.abs=function(n,o){return f.typeOf.object("cartesian",n),f.typeOf.object("result",o),o.x=Math.abs(n.x),o.y=Math.abs(n.y),o.z=Math.abs(n.z),o.w=Math.abs(n.w),o};var j=new e;e.lerp=function(n,o,y,p){return f.typeOf.object("start",n),f.typeOf.object("end",o),f.typeOf.number("t",y),f.typeOf.object("result",p),e.multiplyByScalar(o,y,j),p=e.multiplyByScalar(n,1-y,p),e.add(j,p,p)};var h=new e;e.mostOrthogonalAxis=function(n,o){f.typeOf.object("cartesian",n),f.typeOf.object("result",o);var y=e.normalize(n,h);return e.abs(y,y),y.x<=y.y?y.x<=y.z?y.x<=y.w?o=e.clone(e.UNIT_X,o):o=e.clone(e.UNIT_W,o):y.z<=y.w?o=e.clone(e.UNIT_Z,o):o=e.clone(e.UNIT_W,o):y.y<=y.z?y.y<=y.w?o=e.clone(e.UNIT_Y,o):o=e.clone(e.UNIT_W,o):y.z<=y.w?o=e.clone(e.UNIT_Z,o):o=e.clone(e.UNIT_W,o),o};e.equals=function(n,o){return n===o||m(n)&&m(o)&&n.x===o.x&&n.y===o.y&&n.z===o.z&&n.w===o.w};e.equalsArray=function(n,o,y){return n.x===o[y]&&n.y===o[y+1]&&n.z===o[y+2]&&n.w===o[y+3]};e.equalsEpsilon=function(n,o,y,p){return n===o||m(n)&&m(o)&&b.equalsEpsilon(n.x,o.x,y,p)&&b.equalsEpsilon(n.y,o.y,y,p)&&b.equalsEpsilon(n.z,o.z,y,p)&&b.equalsEpsilon(n.w,o.w,y,p)};e.ZERO=Object.freeze(new e(0,0,0,0));e.UNIT_X=Object.freeze(new e(1,0,0,0));e.UNIT_Y=Object.freeze(new e(0,1,0,0));e.UNIT_Z=Object.freeze(new e(0,0,1,0));e.UNIT_W=Object.freeze(new e(0,0,0,1));e.prototype.clone=function(n){return e.clone(this,n)};e.prototype.equals=function(n){return e.equals(this,n)};e.prototype.equalsEpsilon=function(n,o,y){return e.equalsEpsilon(this,n,o,y)};e.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+", "+this.w+")"};var i=new Float32Array(1),z=256,T=65536,N=16777216,_=1/z,M=1/T,d=1/N,x=38;e.packFloat=function(n,o){if(f.typeOf.number("value",n),m(o)||(o=new e),i[0]=n,n=i[0],n===0)return e.clone(e.ZERO,o);var y=n<0?1:0,p;isFinite(n)?(n=Math.abs(n),p=Math.floor(b.logBase(n,10))+1,n=n/Math.pow(10,p)):(n=.1,p=x);var w=n*z;return o.x=Math.floor(w),w=(w-o.x)*z,o.y=Math.floor(w),w=(w-o.y)*z,o.z=Math.floor(w),o.w=(p+x)*2+y,o};e.unpackFloat=function(n){f.typeOf.object("packedFloat",n);var o=n.w/2,y=Math.floor(o),p=(o-y)*2;if(y=y-x,p=p*2-1,p=-p,y>=x)return p<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY;var w=p*n.x*_;return w+=p*n.y*M,w+=p*n.z*d,w*Math.pow(10,y)};var v=e;export{v as a};