UNPKG

phy-engine

Version:

JavaScript 3D Physics for three.js

6 lines 530 kB
/** * @license * Copyright 2010-2025 Phy.js Authors * SPDX-License-Identifier: MIT */ import{LineSegments as e,BufferGeometry as t,BufferAttribute as a,Float32BufferAttribute as i,LineBasicMaterial as s,BoxGeometry as n,Vector3 as r,Matrix4 as c,CylinderGeometry as h,CircleGeometry as l,PlaneGeometry as b,SphereGeometry as d,Box3 as u,Vector2 as f,CanvasTexture as p,RepeatWrapping as g,SRGBColorSpace as y,MeshPhysicalMaterial as x,Color as w,MeshStandardMaterial as v,ShadowMaterial as k,MeshToonMaterial as j,MeshBasicMaterial as M,MeshLambertMaterial as A,MeshPhongMaterial as S,DoubleSide as E,BackSide as z,FrontSide as F,SrcAlphaSaturateFactor as P,OneMinusDstColorFactor as R,DstColorFactor as T,OneMinusDstAlphaFactor as I,DstAlphaFactor as D,OneMinusSrcAlphaFactor as B,SrcAlphaFactor as C,OneMinusSrcColorFactor as O,SrcColorFactor as q,OneFactor as L,ZeroFactor as H,MaxEquation as _,MinEquation as N,ReverseSubtractEquation as G,SubtractEquation as U,AddEquation as K,MultiplyBlending as V,SubtractiveBlending as J,AdditiveBlending as W,NormalBlending as X,NoBlending as Q,Line as Y,InstancedMesh as Z,Quaternion as $,Mesh as ee,InstancedBufferAttribute as te,Object3D as ae,Line3 as ie,Plane as se,Triangle as ne,ShapeGeometry as re,Euler as oe,Loader as ce,FileLoader as he,LinearSRGBColorSpace as le,LoadingManager as be,EquirectangularReflectionMapping as de,AnimationMixer as ue,TextureLoader as me,NoColorSpace as fe,NearestFilter as pe,Texture as ge,CompressedTexture as ye,ObjectSpaceNormalMap as xe,Vector4 as we,CustomBlending as ve,Group as ke,SkeletonHelper as je,AnimationClip as Me,AnimationUtils as Ae,VectorKeyframeTrack as Se,QuaternionKeyframeTrack as Ee,AdditiveAnimationBlendMode as ze,NormalAnimationBlendMode as Fe,Raycaster as Pe,Sphere as Re,PMREMGenerator as Te,Scene as Ie,WebGLCubeRenderTarget as De,HalfFloatType as Be,LinearFilter as Ce,CubeCamera as Oe,IcosahedronGeometry as qe,ShaderMaterial as Le,NoToneMapping as He,Ray as _e,BatchedMesh as Ne,Frustum as Ge,REVISION as Ue,DataTexture as Ke,FloatType as Ve,UnsignedIntType as Je,IntType as We,WebGLUtils as Xe,ColorManagement as Qe,RGBAFormat as Ye,RGBAIntegerFormat as Ze,RGFormat as $e,RGIntegerFormat as et,RedFormat as tt,RedIntegerFormat as at,WebGLCoordinateSystem as it,AxesHelper as st,Skeleton as nt,MathUtils as rt,Points as ot,InstancedBufferGeometry as ct,InterleavedBuffer as ht,InterleavedBufferAttribute as lt,InstancedInterleavedBuffer as bt,DynamicDrawUsage as dt,Matrix3 as ut}from"three";import{mergeGeometries as mt,mergeVertices as ft}from"three/addons/utils/BufferGeometryUtils.js";import{SVGLoader as pt}from"three/addons/loaders/SVGLoader.js";import*as gt from"three/addons/utils/SkeletonUtils.js";import{GLTFLoader as yt}from"three/addons/loaders/GLTFLoader.js";import{FBXLoader as xt}from"three/addons/loaders/FBXLoader.js";import{OBJLoader as wt}from"three/addons/loaders/OBJLoader.js";import{STLLoader as vt}from"three/addons/loaders/STLLoader.js";import{HDRLoader as kt}from"three/addons/loaders/HDRLoader.js";import{EXRLoader as jt}from"three/addons/loaders/EXRLoader.js";import{UltraHDRLoader as Mt}from"three/addons/loaders/UltraHDRLoader.js";import{KTX2Loader as At}from"three/addons/loaders/KTX2Loader.js";import{radixSort as St}from"three/addons/utils/SortUtils.js";const Et=3.141592653589793,zt=Et/180,Ft=180/Et,Pt=Number.EPSILON,Rt=.5*Et,Tt={luminousPowers:{"110000 lm (1000W)":11e4,"3500 lm (300W)":3500,"1700 lm (100W)":1700,"800 lm (60W)":800,"400 lm (40W)":400,"180 lm (25W)":180,"20 lm (4W)":20,Off:0},luminousIrradiances:{"0.0001 lx (Moonless Night)":1e-4,"0.002 lx (Night Airglow)":.002,"0.5 lx (Full Moon)":.5,"3.4 lx (City Twilight)":3.4,"50 lx (Living Room)":50,"100 lx (Very Overcast)":100,"350 lx (Office Room)":350,"400 lx (Sunrise/Sunset)":400,"1000 lx (Overcast)":1e3,"18000 lx (Daylight)":18e3,"50000 lx (Direct Sun)":5e4},exposure:e=>Math.pow(e,5),candelaToLumens:e=>4*e*Math.PI,lumensToCandela:e=>e/(4*Math.PI),average:e=>e?.reduce(((e,t)=>e+t),0)/e.length,atan2:(e,t)=>Math.fround(Math.atan2(e,t)),pow:(e,t)=>Math.fround(Math.pow(e,t)),sin:e=>Math.fround(Math.sin(e)),cos:e=>Math.fround(Math.cos(e)),sqrt:e=>Math.fround(Math.sqrt(e)),exp:e=>Math.fround(Math.exp(e)),todeg:Ft,torad:zt,toFixed:(e,t=3)=>1*e.toFixed(t),toRound:(e,t=3)=>Math.trunc(e),clamp:(e,t=0,a=1)=>e<t?t:e>a?a:e,min:(e,t)=>e<t?e:t,max:(e,t)=>e>t?e:t,lerp:(e,t,a)=>(1-a)*e+a*t,sign:e=>e>0?1:e<0?-1:0,fast_negexp:e=>1/(1+e+.48*e*e+.235*e*e*e),fast_atan:e=>{let t=Math.abs(e),a=t>1?1/t:t,i=Et/4*a-a*(a-1)*(.2447+.0663*a);return copysign(t>1?Et/2-i:i,e)},clampA:(e,t,a)=>Math.max(t,Math.min(a,e)),smoothstep:(e,t,a)=>e*(a=-2*(a=Tt.clamp(a))*a*a+3*a*a)+t*(1-a),remap:(e,t,a,i,s)=>i+(e-t)*(s-i)/(a-t),damp:(e,t,a,i)=>Tt.lerp(e,t,1-Math.exp(-a*i)),nearAngle:(e,t,a=!1)=>t+Math.atan2(Math.sin(e-t),Math.cos(e-t))*(a?Ft:1),unwrapDeg:e=>e-360*Math.floor((e+180)/360),unwrapRad:e=>Math.atan2(Math.sin(e),Math.cos(e)),nearEquals:(e,t,a=1e-4)=>Math.abs(e-t)<=a,autoSize:(e=[1,1,1],t="box")=>{1===e.length&&(e[1]=e[0]);let a=e[0],i=e[1];return"sphere"===t&&(e=[a,a,a]),"cylinder"!==t&&"wheel"!==t&&"capsule"!==t||(e=[a,i,a]),"cone"!==t&&"pyramid"!==t||(e=[a,i,a]),2===e.length&&(e[2]=e[0]),e},shuffle:e=>{let t=e.map((e=>({value:e,sort:Math.random()}))).sort(((e,t)=>e.sort-t.sort)).map((({value:e})=>e));return t},randomSign:()=>Math.random()<.5?-1:1,randSpread:e=>e*(.5-Math.random()),rand:(e=0,t=1)=>e+Math.random()*(t-e),randInt:(e,t)=>e+Math.floor(Math.random()*(t-e+1)),randIntUnic:(e,t,a)=>{for(var i=[];i.length<a;){var s=Tt.randInt(e,t);-1===i.indexOf(s)&&i.push(s)}return i},fromTransform:(e,t,a,i=[0,0,0,1],s=!1)=>{let n=Tt.composeMatrixArray(e,t),r=Tt.composeMatrixArray(a,i);return s&&(n=Tt.invertMatrixArray(n)),n=Tt.multiplyMatrixArray(n,r),[n[12],n[13],n[14]]},fromTransformToQ:(e,t,a=!1)=>{let i=Tt.composeMatrixArray(e,t),s=Tt.decomposeFullMatrixArray(i).q;return a&&(s=Tt.quatInvert(s)),s},lerpTransform:(e,t,a)=>{let i=e[0],s=e[1],n=t[0],r=t[1];return n=Tt.lerpArray(i,n,a),r=Tt.slerpQuatArray(s,r,a),[n,r]},composeMatrixArray:(e,t,a=[1,1,1])=>{const i=t[0],s=t[1],n=t[2],r=t[3],o=i+i,c=s+s,h=n+n,l=i*o,b=i*c,d=i*h,u=s*c,m=s*h,f=n*h,p=r*o,g=r*c,y=r*h,x=a[0],w=a[1],v=a[2];return[(1-(u+f))*x,(b+y)*x,(d-g)*x,0,(b-y)*w,(1-(l+f))*w,(m+p)*w,0,(d+g)*v,(m-p)*v,(1-(l+u))*v,0,e[0],e[1],e[2],1]},multiplyMatrixArray:(e,t)=>{const a=e,i=t,s=[],n=a[0],r=a[4],o=a[8],c=a[12],h=a[1],l=a[5],b=a[9],d=a[13],u=a[2],m=a[6],f=a[10],p=a[14],g=a[3],y=a[7],x=a[11],w=a[15],v=i[0],k=i[4],j=i[8],M=i[12],A=i[1],S=i[5],E=i[9],z=i[13],F=i[2],P=i[6],R=i[10],T=i[14],I=i[3],D=i[7],B=i[11],C=i[15];return s[0]=n*v+r*A+o*F+c*I,s[4]=n*k+r*S+o*P+c*D,s[8]=n*j+r*E+o*R+c*B,s[12]=n*M+r*z+o*T+c*C,s[1]=h*v+l*A+b*F+d*I,s[5]=h*k+l*S+b*P+d*D,s[9]=h*j+l*E+b*R+d*B,s[13]=h*M+l*z+b*T+d*C,s[2]=u*v+m*A+f*F+p*I,s[6]=u*k+m*S+f*P+p*D,s[10]=u*j+m*E+f*R+p*B,s[14]=u*M+m*z+f*T+p*C,s[3]=g*v+y*A+x*F+w*I,s[7]=g*k+y*S+x*P+w*D,s[11]=g*j+y*E+x*R+w*B,s[15]=g*M+y*z+x*T+w*C,s},invertMatrixArray:e=>{const t=e,a=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],c=t[6],h=t[7],l=t[8],b=t[9],d=t[10],u=t[11],m=t[12],f=t[13],p=t[14],g=t[15],y=b*p*h-f*d*h+f*c*u-o*p*u-b*c*g+o*d*g,x=m*d*h-l*p*h-m*c*u+r*p*u+l*c*g-r*d*g,w=l*f*h-m*b*h+m*o*u-r*f*u-l*o*g+r*b*g,v=m*b*c-l*f*c-m*o*d+r*f*d+l*o*p-r*b*p,k=a*y+i*x+s*w+n*v;if(0===k)return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];const j=1/k;return t[0]=y*j,t[1]=(f*d*n-b*p*n-f*s*u+i*p*u+b*s*g-i*d*g)*j,t[2]=(o*p*n-f*c*n+f*s*h-i*p*h-o*s*g+i*c*g)*j,t[3]=(b*c*n-o*d*n-b*s*h+i*d*h+o*s*u-i*c*u)*j,t[4]=x*j,t[5]=(l*p*n-m*d*n+m*s*u-a*p*u-l*s*g+a*d*g)*j,t[6]=(m*c*n-r*p*n-m*s*h+a*p*h+r*s*g-a*c*g)*j,t[7]=(r*d*n-l*c*n+l*s*h-a*d*h-r*s*u+a*c*u)*j,t[8]=w*j,t[9]=(m*b*n-l*f*n-m*i*u+a*f*u+l*i*g-a*b*g)*j,t[10]=(r*f*n-m*o*n+m*i*h-a*f*h-r*i*g+a*o*g)*j,t[11]=(l*o*n-r*b*n-l*i*h+a*b*h+r*i*u-a*o*u)*j,t[12]=v*j,t[13]=(l*f*s-m*b*s+m*i*d-a*f*d-l*i*p+a*b*p)*j,t[14]=(m*o*s-r*f*s-m*i*c+a*f*c+r*i*p-a*o*p)*j,t[15]=(r*b*s-l*o*s+l*i*c-a*b*c-r*i*d+a*o*d)*j,t},matrixArrayDeterminant:e=>{const t=e,a=t[0],i=t[4],s=t[8],n=t[12],r=t[1],o=t[5],c=t[9],h=t[13],l=t[2],b=t[6],d=t[10],u=t[14];return t[3]*(+n*c*b-s*h*b-n*o*d+i*h*d+s*o*u-i*c*u)+t[7]*(+a*c*u-a*h*d+n*r*d-s*r*u+s*h*l-n*c*l)+t[11]*(+a*h*b-a*o*u-n*r*b+i*r*u+n*o*l-i*h*l)+t[15]*(-s*o*l-a*c*b+a*o*d+s*r*b-i*r*d+i*c*l)},decomposeMatrixArray:e=>[e[12],e[13],e[14]],decomposeFullMatrixArray:e=>{const t=e;let a=Tt.lengthArray([t[0],t[1],t[2]]);const i=Tt.lengthArray([t[4],t[5],t[6]]),s=Tt.lengthArray([t[8],t[9],t[10]]);Tt.matrixArrayDeterminant(e)<0&&(a=-a);let n=[...e];const r=1/a,o=1/i,c=1/s;n[0]*=r,n[1]*=r,n[2]*=r,n[4]*=o,n[5]*=o,n[6]*=o,n[8]*=c,n[9]*=c,n[10]*=c;let h=Tt.quatFromRotationMatrix(n);return{p:[e[12],e[13],e[14]],q:h,s:[a,i,s]}},applyTransformArray:(e,t,a,i=[1,1,1])=>{const s=Tt.composeMatrixArray(t,a,i),n=e[0],r=e[1],o=e[2],c=1/(s[3]*n+s[7]*r+s[11]*o+s[15]);return[(s[0]*n+s[4]*r+s[8]*o+s[12])*c,(s[1]*n+s[5]*r+s[9]*o+s[13])*c,(s[2]*n+s[6]*r+s[10]*o+s[14])*c]},slerpQuatArray:(e,t,a)=>{if(0===a)return e;if(1===a)return t;let i=[...e];const s=e[0],n=e[1],r=e[2],o=e[3],c=t[0],h=t[1],l=t[2],b=t[3];let d=o*b+s*c+n*h+r*l;if(d<0?(i=[-c,-h,-l,-b],d=-d):i=[...t],d>=1)return e;const u=1-d*d;if(u<=Pt){const e=1-a;return i[3]=e*o+a*i[3],i[0]=e*s+a*i[0],i[1]=e*n+a*i[1],i[2]=e*r+a*i[2],Tt.quatNomalize(i)}const m=Math.sqrt(u),f=Math.atan2(m,d),p=Math.sin((1-a)*f)/m,g=Math.sin(a*f)/m;return i[3]=o*p+i[3]*g,i[0]=s*p+i[0]*g,i[1]=n*p+i[1]*g,i[2]=r*p+i[2]*g,i},toLocalQuatArray:(e=[0,0,0],t)=>{let a=Tt.quatFromEuler(e),i=Tt.quatInvert(t.quaternion.toArray());return Tt.quatMultiply(i,a)},quatFromRotationMatrix:e=>{let t=[0,0,0,1];const a=e,i=a[0],s=a[4],n=a[8],r=a[1],o=a[5],c=a[9],h=a[2],l=a[6],b=a[10],d=i+o+b;if(d>0){const e=.5/Math.sqrt(d+1);t[3]=.25/e,t[0]=(l-c)*e,t[1]=(n-h)*e,t[2]=(r-s)*e}else if(i>o&&i>b){const e=2*Math.sqrt(1+i-o-b);t[3]=(l-c)/e,t[0]=.25*e,t[1]=(s+r)/e,t[2]=(n+h)/e}else if(o>b){const e=2*Math.sqrt(1+o-i-b);t[3]=(n-h)/e,t[0]=(s+r)/e,t[1]=.25*e,t[2]=(c+l)/e}else{const e=2*Math.sqrt(1+b-i-o);t[3]=(r-s)/e,t[0]=(n+h)/e,t[1]=(c+l)/e,t[2]=.25*e}return t},quatFromEuler:(e=[0,0,0],t=!0)=>{const a=Math.cos,i=Math.sin,s=t?zt:1,n=e[0]*s*.5,r=e[1]*s*.5,o=e[2]*s*.5,c=a(n),h=a(r),l=a(o),b=i(n),d=i(r),u=i(o);return[b*h*l+c*d*u,c*d*l-b*h*u,c*h*u+b*d*l,c*h*l-b*d*u]},quatFromAxis:(e=[0,0,0],t,a=!0)=>{const i=.5*t*(a?zt:1),s=Math.sin(i);return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]},quatNomalize:e=>{let t=Tt.lengthArray(e);return 0===t?[0,0,0,1]:(t=1/t,Tt.scaleArray(e,t,4))},quatInvert:e=>[-e[0],-e[1],-e[2],e[3]],quatMultiply:(e,t)=>{const a=e[0],i=e[1],s=e[2],n=e[3],r=t[0],o=t[1],c=t[2],h=t[3];return[a*h+n*r+i*c-s*o,i*h+n*o+s*r-a*c,s*h+n*c+a*o-i*r,n*h-a*r-i*o-s*c]},quatToAxis:e=>{let t=2*Math.acos(e[3]);const a=Math.sqrt(1-e[3]*e[3]);return a<1e-4?[1,0,0]:[e[0]/a,e[1]/a,e[2]/a,t]},eulerFromMatrix:e=>{const t=e[0],a=e[4],i=e[8];e[1];const s=e[5],n=e[9];e[2];const r=e[6],o=e[10];let c=[0,0,0];return c[1]=Math.asin(Tt.clamp(i,-1,1)),Math.abs(i)<.9999999?(c[0]=Math.atan2(-n,o),c[2]=Math.atan2(-a,t)):(c[0]=Math.atan2(r,s),c[2]=0),c},angleTo:(e,t)=>2*Math.acos(Math.abs(Tt.clamp(Tt.dotArray(e,t),-1,1))),fixedArray:(e,t)=>{let a=e.length,i=[];for(;a--;)i[a]=Tt.toFixed(e[a],t);return i},getSize:e=>.001*e.byteLength+"kb",perpendicularArray:e=>{const t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);let a=Math.acos(e[1]/t);const i=Math.atan2(e[2],e[0]);a>Rt?a-=Rt:a+=Rt;return[t*Math.sin(a)*Math.cos(i),t*Math.cos(a),t*Math.sin(a)*Math.sin(i)]},crossArray:(e,t)=>{const a=e[0],i=e[1],s=e[2],n=t[0],r=t[1],o=t[2];return[i*o-s*r,s*n-a*o,a*r-i*n]},applyQuaternion:(e,t)=>{const a=e[0],i=e[1],s=e[2],n=t[0],r=t[1],o=t[2],c=t[3],h=2*(r*s-o*i),l=2*(o*a-n*s),b=2*(n*i-r*a);return[a+c*h+r*b-o*l,i+c*l+o*h-n*b,s+c*b+n*l-r*h]},nullArray:(e,t,a)=>{let i=0;for(;a--;)i+=e[t+a];return i},equalArray:(e,t)=>{let a=e.length;for(;a--;)if(e[a]!==t[a])return!1;return!0},lerpArray:(e,t,a)=>{if(0===a)return e;if(1===a)return t;let i=e.length,s=[];for(;i--;)s[i]=e[i],s[i]+=(t[i]-s[i])*a;return s},zeroArray:(e,t=0,a)=>{for(a=a??e.length;a--;)e[t+a]=0;return e},lengthArray:e=>{let t=e.length,a=0;for(;t--;)a+=e[t]*e[t];return Math.sqrt(a)},dotArray:(e,t)=>{let a=e.length,i=0;for(;a--;)i+=e[a]*t[a];return i},addArray:(e,t,a)=>{a=a??e.length;let i=[];for(;a--;)i[a]=e[a]+t[a];return i},subArray:(e,t,a)=>{a=a??e.length;let i=[];for(;a--;)i[a]=e[a]-t[a];return i},mulArray:(e,t,a)=>{if(t instanceof Array){let i=[];for(a=a??e.length;a--;)i[a]=e[a]*t[a];return i}return e.map((e=>e*t))},worldscale:(e,t)=>e.map((e=>e*t)),divArray:(e,t,a)=>Tt.mulArray(e,1/t,a),scaleArray:(e,t,a)=>Tt.mulArray(e,t,a),fillArray:(e,t,a=0,i)=>{for(i=i??e.length;i--;)t[a+i]=e[i]},copyArray:(e,t)=>{},cloneArray:e=>[...e],distanceArray:(e,t=[0,0,0])=>Tt.lengthArray(Tt.subArray(e,t)),normalizeArray:e=>Tt.divArray(e,Tt.lengthArray(e)||1),normalArray:(e,t=[0,0,0])=>Tt.normalizeArray(Tt.subArray(t,e)),getCenter:(e,t)=>(e.computeBoundingBox(),e.boundingBox.getCenter(t)),getVolume:(e,t,a=null)=>{let i=1,s=t;switch(e){case"sphere":i=4*Math.PI*s[0]*s[0]*s[0]/3;break;case"cone":i=Math.PI*s[0]*(.5*s[1])*2;break;case"box":i=.5*s[0]*8*(.5*s[1])*(.5*s[2]);break;case"cylinder":i=Math.PI*s[0]*s[0]*(.5*s[1])*2;break;case"capsule":i=4*Math.PI*s[0]*s[0]*s[0]/3+Math.PI*s[0]*s[0]*(.5*s[1])*2;break;case"convex":case"mesh":i=Tt.getConvexVolume(a)}return i},getConvexVolume:e=>{let t,a=e.length/3,i=[0,0,0],s=[0,0,0];for(;a--;)t=3*a,e[t]<i[0]?i[0]=e[t]:e[t]>s[0]&&(s[0]=e[t]),e[t+1]<i[1]?i[1]=e[t+1]:e[t+1]>s[1]&&(s[1]=e[t+1]),e[t+2]<i[2]?i[2]=e[t+2]:e[t+2]>s[2]&&(s[2]=e[t+2]);let n=[s[0]-i[0],s[1]-i[1],s[2]-i[2]];return.5*n[0]*8*(.5*n[1])*(.5*n[2])},massFromDensity:(e,t)=>e*t,densityFromMass:(e,t)=>e/t,toNonIndexed:e=>e.index?e.clone().toNonIndexed():e,getIndex:(e,t)=>!e.index||t?null:e.index.array||null,getSameVertex:e=>{const t=e.getAttribute("position"),a=t.array,i=[],s=[],n={};new THREE.Vector3;let r,o=0;Tt.getHash(e);let c,h,l=!1,b=0;for(let e=0;e<t.count;e++){o=3*e,c={x:a[o],y:a[o+1],z:a[o+2],id:e},l=!1,r=i.length;for(let t=0;t<r;t++)h=i[t],c.x===h.x&&c.y===h.y&&c.z===h.z&&(l=!0,n[e]=h.id);l||(c.id=b++,i.push(c),s.push([c.x,c.y,c.z]))}return[s,n]},getVertex:(e,t)=>{let a=e.attributes.position.array;return t&&e.index&&(a=(e=e.clone().toNonIndexed()).attributes.position.array),a},getNormal:e=>e.attributes.normal.array,getFaces:e=>{let t=[];if(e.index){let a=e.getIndex();for(let e=0;e<a.count;e+=3)t.push([a.getX(e),a.getX(e+1),a.getX(e+2)])}else{let a=e.getAttribute("position").count;for(let e=0;e<a;e+=3)t.push([e,e+1,e+2])}return t},getConnectedFaces:e=>{const t=[];let a,i,s,n,r,o,c,h=e.length,l=h;for(;l--;)for(i=e[l],a=h;a--;)a!==l&&(s=e[a],n=i.filter((e=>s.includes(e))),n.length>1&&(c=[],r=[...i],o=r.indexOf(n[0]),r.splice(o,1),o=r.indexOf(n[1]),r.splice(o,1),c.push(r[0]),r=[...s],o=r.indexOf(n[0]),r.splice(o,1),o=r.indexOf(n[1]),r.splice(o,1),c.push(r[0]),t.push(c)));return t},reduce:e=>{},barycentric:(e,t)=>{},solve:(e,t)=>{},getHash:(e,t=1e-4)=>{t=Math.max(t,Number.EPSILON);const a={},i={},s=e.getAttribute("position"),n=s.count,r=s.array,o=.5*t,c=Math.log10(1/t),h=Math.pow(10,c),l=o*h;let b;for(let e=0;e<n;e++){b=3*e;let t=`${~~(r[b]*h+l)},${~~(r[b+1]*h+l)},${~~(r[b+2]*h+l)}`;a[t]?a[t].push(e):a[t]=[e]}let d=0;for(let e in a)i[d++]=a[e];return i}},It=Tt,Dt=["PHYSX","HAVOK"],Bt=4e3,Ct=1e3,Ot=4e3,qt=100,Lt=100,Ht=50,_t=20,Nt={bodyFull:14,body:8,joint:16,contact:1,ray:11,character:16,vehicle:72,solver:128},Gt=function(e,t=!1){const a={};let i={body:Bt*(t?Nt.bodyFull:Nt.body),joint:Ct*Nt.joint,ray:qt*Nt.ray,contact:Ot*Nt.contact,character:Lt*Nt.character};"PHYSX"!==e&&"AMMO"!==e||(i.vehicle=Ht*Nt.vehicle),"PHYSX"===e&&(i.solver=_t*Nt.solver),"HAVOK"!==e&&"RAPIER"!==e&&"JOLT"!==e||(Nt.joint=0);let s=0;for(let e in i)a[e]=s,s+=i[e];return a.total=s,a};class Ut extends e{constructor(e,n=16776960){const r=new Uint16Array([0,1,1,2,2,3,3,4,4,5,5,0,6,7,7,8,8,9,9,10,10,11,11,6,12,13,13,14,14,15,15,16,16,17,17,12,18,19,20,21,22,23]),o=[.5,0,0,.25,.433,0,-.25,.433,0,-.5,0,0,-.25,-.433,0,.25,-.433,0,.5,0,0,.25,0,.433,-.25,0,.433,-.5,0,0,-.25,0,-.433,.25,0,-.433,0,.5,0,0,.25,.433,0,-.25,.433,0,-.5,0,0,-.25,-.433,0,.25,-.433,0,0,0,.6,0,0,0,0,0,0,.6,0,0,0,0,0,0,.6],c=new t;c.setIndex(new a(r,1)),c.setAttribute("position",new i(o,3)),c.setAttribute("color",new i([0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1],3)),super(c,new s({color:n,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.box=e,this.type="CircleHelper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Kt extends t{constructor(e=1,t=16,a=16,i=16,s=1){super(),this.type="SphereBox",this.name="SphereBox_"+e+"_"+t+"_"+a+"_"+i+"_"+s,e=e||1,t=Math.floor(t),a=Math.floor(a),i=Math.floor(i);let o,c,h,l=new n(1,1,1,t,a,i),b=new r,d=new r,u=l.attributes.position.count,m=l.attributes.position.array,f=l.attributes.normal.array,p=l.attributes.uv.array,g=l.attributes.uv.count,y=g/6,x=1/3,w=0,v=0;for(let e=0;e<g;e++){switch(h=Math.floor(e/y),h){case 0:w=0,v=.5;break;case 5:w=x,v=.5;break;case 1:w=2*x,v=.5;break;case 4:w=0,v=1;break;case 3:w=x,v=1;break;case 2:w=2*x,v=1}c=2*e,p[c]*=x,p[c]+=w,p[c+1]*=-.5,p[c+1]+=v,p[c]>1&&(p[c]=1),p[c]<0&&(p[c]=0),p[c+1]>1&&(p[c+1]=1),p[c+1]<0&&(p[c+1]=0)}for(let t=0;t<u;t++)o=3*t,b.set(m[o],m[o+1],m[o+2]),d.copy(b).normalize(),b.lerp(d,s).multiplyScalar(e),m[o]=b.x,m[o+1]=b.y,m[o+2]=b.z,b.normalize(),f[o]=b.x,f[o+1]=b.y,f[o+2]=b.z;l.computeTangents(),this.copy(l)}}class Vt extends t{constructor(e=1,t=1,a=12,i=1){super(),this.type="CapsuleGeometry";let s=Math.PI,n=e/(2*e+t),r=1-2*n;a=Math.floor(a),i=Math.floor(i);let o=Math.floor(.5*a),l=2*Math.PI,b=.5*Math.PI,u=new h(e,e,t,a,i,!0);Yt(u,0,n,1,r);let m=new d(e,a,o,0,l,0,b);Yt(m,0,1-n,1,n);let f=new d(e,a,o,0,l,b,b);Yt(f,0,0,1,n);let p=(new c).makeRotationY(.5*-s),g=(new c).makeTranslation(0,.5*t,0),y=(new c).makeTranslation(0,.5*-t,0);u.applyMatrix4(p),m.applyMatrix4(g),f.applyMatrix4(y);let x=ft(mt([u,m,f]));this.copy(x)}}class Jt extends t{constructor(e=1,t=.4,a=8,s=6,n=2*Math.PI,o=0,c=Math.PI){super(),this.type="TorusGeometryFix",this.parameters={radius:e,tube:t,radialSegments:a,tubularSegments:s,arc:n},a=Math.floor(a),s=Math.floor(s);const h=[],l=[],b=[],d=[],u=new r,m=new r,f=new r;let p,g;for(p=0;p<=a;p++)for(g=0;g<=s;g++){const i=g/s*n,r=p/a*c+o;m.x=(e+t*Math.cos(r))*Math.cos(i),m.y=(e+t*Math.cos(r))*Math.sin(i),m.z=t*Math.sin(r),l.push(m.x,m.y,m.z),u.x=e*Math.cos(i),u.y=e*Math.sin(i),f.subVectors(m,u).normalize(),b.push(f.x,f.y,f.z),d.push(g/s),d.push(p/a)}for(p=1;p<=a;p++)for(g=1;g<=s;g++){const e=(s+1)*p+g-1,t=(s+1)*(p-1)+g-1,a=(s+1)*(p-1)+g,i=(s+1)*p+g;h.push(e,t,i),h.push(t,a,i)}this.setIndex(h),this.setAttribute("position",new i(l,3)),this.setAttribute("normal",new i(b,3)),this.setAttribute("uv",new i(d,2))}}class Wt extends t{constructor(e=1,t=1,a=1,i=.01,s=12,n=1,r=2){super(),this.type="ChamferCyl",s=Math.floor(s),n=Math.floor(n),r=Math.floor(r);let o=new c,b=new c,d=Math.PI,u=.5*d,m=2*d,f=i/a,p=1-2*f,g=new h(e,t,a-2*i,s,n,!0,0);o.makeRotationY(u),g.applyMatrix4(o),Yt(g,0,f,1,p);let y=new Jt(e-i,i,r,s,m,0,u),x=new l(e-i,s);b.makeTranslation(0,0,i),x.applyMatrix4(b),Yt(y,0,1-f,1,f);let w=mt([y,x]);o.makeTranslation(0,0,.5*a-i),b.makeRotationX(-u),w.applyMatrix4(b.multiply(o)),y=new Jt(t-i,i,r,s,m,0,u),x=new l(t-i,s),b.makeTranslation(0,0,i),x.applyMatrix4(b),Yt(y,0,1-f,1,f,!0);let v=mt([y,x]);o.makeTranslation(0,0,.5*a-i),b.makeRotationX(u),v.applyMatrix4(b.multiply(o));let k=ft(mt([w,g,v]));this.copy(k)}}let Xt=class extends t{constructor(e=1,t=1,a=1,i=.01,s=1,n=1,r=1,o=2){super(),this.type="ChamferBox",s=Math.floor(s),n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);let l=Math.PI,d=.5*l,u=2*i,m=.5*e,f=.5*t,p=.5*a,g=new c,y=new c,x=new c,w=i/e,v=1-2*w,k=i/t,j=1-2*w,M=i/a,A=1-2*M,S=new b(e-u,t-u,s,n),E=new h(i,i,e-u,o,s,!0,0,d),z=new h(i,i,t-u,o,n,!0,0,d),F=new Qt(i,o,o,0,d,0,-d),P=new Qt(i,o,o,0,d,0,-d);Yt(S,-w,k,v,j),Yt(E,0,w,k,v),y.makeTranslation(0,f-i,0),g.makeRotationX(d),F.applyMatrix4(y.multiply(g)),y.makeTranslation(0,-f+i,0),g.makeRotationX(d),x.makeRotationY(-d),P.applyMatrix4(y.multiply(g).multiply(x));let R=mt([z,F,P]),T=R.clone();y.makeTranslation(m-i,0,-i),R.applyMatrix4(y),y.makeTranslation(-m+i,0,-i),g.makeRotationZ(l),T.applyMatrix4(y.multiply(g));let I=E.clone();g.makeRotationZ(d),y.makeTranslation(0,f-i,-i),E.applyMatrix4(y.multiply(g)),y.makeTranslation(0,-f+i,-i),g.makeRotationZ(-d),I.applyMatrix4(y.multiply(g));let D=mt([E,I,S,R,T]),B=D.clone();y.makeTranslation(0,0,p),D.applyMatrix4(y),y.makeTranslation(0,0,-p),g.makeRotationY(l),B.applyMatrix4(y.multiply(g)),S=new b(a-u,t-u,r,n),E=new h(i,i,a-u,o,r,!0,0,d),I=E.clone(),Yt(S,-M,k,A,j),y.makeTranslation(0,-(f-i),-i,0),g.makeRotationZ(-d),E.applyMatrix4(y.multiply(g)),y.makeTranslation(0,f-i,-i,0),g.makeRotationZ(d),I.applyMatrix4(y.multiply(g));let C=mt([E,I,S]),O=C.clone();y.makeTranslation(-m,0,0),g.makeRotationY(-d),C.applyMatrix4(y.multiply(g)),y.makeTranslation(m,0,0),g.makeRotationY(d),O.applyMatrix4(y.multiply(g)),S=new b(e-u,a-u,s,r),Yt(S,-w,M,v,A);let q=S.clone();y.makeTranslation(0,f,0),g.makeRotationX(-d),S.applyMatrix4(y.multiply(g)),y.makeTranslation(0,-f,0),g.makeRotationX(d),q.applyMatrix4(y.multiply(g));let L=ft(mt([D,B,C,O,S,q]));Zt(L,"box"),this.copy(L)}},Qt=class extends t{constructor(e=1,t=8,a=6,s=0,n=2*Math.PI,o=0,c=Math.PI){super(),this.type="SphereGeometryFix",this.parameters={radius:e,widthSegments:t,heightSegments:a,phiStart:s,phiLength:n,thetaStart:o,thetaLength:c},t=Math.floor(t),a=Math.floor(a);const h=Math.min(o+c,Math.PI);let l=0;const b=[],d=new r,u=new r,m=[],f=[],p=[],g=[];for(let i=0;i<=a;i++){const r=[],m=i/a;let y=0;0==i&&0==o?y=.5/t:i==a&&h==Math.PI&&(y=-.5/t);for(let a=0;a<=t;a++){const i=a/t;d.x=-e*Math.cos(s+i*n)*Math.sin(o+m*c),d.y=e*Math.cos(o+m*c),d.z=e*Math.sin(s+i*n)*Math.sin(o+m*c),f.push(d.x,d.y,d.z),u.copy(d).normalize(),p.push(u.x,u.y,u.z),g.push(i+y,1-m),r.push(l++)}b.push(r)}for(let e=0;e<a;e++)for(let i=0;i<t;i++){const t=b[e][i+1],s=b[e][i],n=b[e+1][i],r=b[e+1][i+1];(0!==e||o>0)&&m.push(t,s,r),(e!==a-1||h<Math.PI)&&m.push(s,n,r)}this.setIndex(m),this.setAttribute("position",new i(f,3)),this.setAttribute("normal",new i(p,3)),this.setAttribute("uv",new i(g,2))}};function Yt(e,t=0,a=0,i=1,s=1,n){let r=e.attributes.uv,o=r.array,c=r.count,h=0;for(;c--;)h=2*c,o[h]=o[h]*i-t,o[h+1]=o[h+1]*s+a,n&&(o[h]=1-o[h],o[h+1]=1-o[h+1])}function Zt(e,t="sphere",a,s=[0,0,0],n=[0,0,0,1],o){if(void 0===o&&(o=new c),o.compose({x:s[0],y:s[1],z:s[2]},{_x:n[0],_y:n[1],_z:n[2],_w:n[3]},{x:1,y:1,z:1}),void 0===a){e.boundingBox||e.computeBoundingBox();let t=e.boundingBox;a=Math.max(t.max.x-t.min.x,t.max.y-t.min.y,t.max.z-t.min.z)}let h=new u(new r(-a/2,-a/2,-a/2),new r(a/2,a/2,a/2)),l=[];l.length=2*e.attributes.position.count,void 0===e.attributes.uv&&e.setAttribute("uv",new i(l,2));let b,d,m,p,g,y=function(e,t,a){e.applyMatrix4(o),t.applyMatrix4(o),a.applyMatrix4(o);let i=1/(2*Math.PI),s=1/Math.PI;return e.normalize(),t.normalize(),a.normalize(),{uv0:new f(.5-Math.atan(e.z,-e.x)*i,.5-Math.asin(e.y)*s),uv1:new f(.5-Math.atan(t.z,-t.x)*i,.5-Math.asin(t.y)*s),uv2:new f(.5-Math.atan(a.z,-a.x)*i,.5-Math.asin(a.y)*s)}},x=function(e,t,i){e.applyMatrix4(o),t.applyMatrix4(o),i.applyMatrix4(o);let s=new r;s.crossVectors(t.clone().sub(e),t.clone().sub(i)).normalize(),s.x<0||s.y<0||s.z,s.x=Math.abs(s.x),s.y=Math.abs(s.y),s.z=Math.abs(s.z);let n=new f,c=new f,l=new f,b=1/a;return s.y>s.x&&s.y>s.z?(n.set(e.x-h.min.x,h.max.z-e.z).multiplyScalar(b),c.set(t.x-h.min.x,h.max.z-t.z).multiplyScalar(b),l.set(i.x-h.min.x,h.max.z-i.z).multiplyScalar(b)):s.x>s.y&&s.x>s.z?(n.set(e.z-h.min.z,e.y-h.min.y).multiplyScalar(b),c.set(t.z-h.min.z,t.y-h.min.y).multiplyScalar(b),l.set(i.z-h.min.z,i.y-h.min.y).multiplyScalar(b)):s.z>s.y&&s.z>s.x&&(n.set(e.x-h.min.x,e.y-h.min.y).multiplyScalar(b),c.set(t.x-h.min.x,t.y-h.min.y).multiplyScalar(b),l.set(i.x-h.min.x,i.y-h.min.y).multiplyScalar(b)),{uv0:n,uv1:c,uv2:l}},w=new r,v=new r,k=new r;new r,new r,new r;const j=e.getAttribute("position");if(e.getAttribute("normal"),e.index)for(b=0;b<e.index.count;b+=3)d=e.index.getX(b+0),m=e.index.getX(b+1),p=e.index.getX(b+2),w.fromBufferAttribute(j,d),v.fromBufferAttribute(j,m),k.fromBufferAttribute(j,p),g="sphere"===t?y(w,v,k):x(w,v,k),l[2*d]=g.uv0.x,l[2*d+1]=g.uv0.y,l[2*m]=g.uv1.x,l[2*m+1]=g.uv1.y,l[2*p]=g.uv2.x,l[2*p+1]=g.uv2.y;else for(b=0;b<j.count;b+=3){w.fromBufferAttribute(j,b+0),v.fromBufferAttribute(j,b+1),k.fromBufferAttribute(j,b+2),g="sphere"===t?y(w,v,k):x(w,v,k);let e=b,a=b+1,i=b+2;l[2*e]=g.uv0.x,l[2*e+1]=g.uv0.y,l[2*a]=g.uv1.x,l[2*a+1]=g.uv1.y,l[2*i]=g.uv2.x,l[2*i+1]=g.uv2.y}e.attributes.uv.array=new Float32Array(l),e.attributes.uv.needsUpdate=!0}let $t=class{constructor(){this.geoN=0,this.geo={}}unic(e){this.geo["geo"+this.geoN++]=e}set(e){this.geo[e.name]=e}get(e,t={}){if(!this.geo[e]){let t;switch(e){case"plane":t=new b(1,1),t.rotateX(.5*-Math.PI);break;case"box":t=new n(1,1,1);break;case"sphere":t=new d(1,16,12);break;case"highSphere":t=new Kt(1);break;case"cylinder":t=new h(1,1,1,16);break;case"cone":t=new h(.001,1,1,16);break;case"particle":t=new d(1,6,4);break;case"joint":t=(new Ut).geometry;break;default:return null}this.geo[e]=t}return this.geo[e]}dispose(){for(let e in this.geo)this.geo[e].isBufferGeometry?this.geo[e].dispose():console.log(this.geo[e]);this.geo={},this.geoN=0}};class ea{constructor(e,t="rgb(69,69,69)",a="rgb(39,39,39)"){const i=document.createElement("canvas");i.width=i.height=128;const s=i.getContext("2d");if(s.fillStyle=t,s.fillRect(0,0,128,128),e){let i,n,r,o,c=[[0,0],[32,32],[64,64],[96,96],[96,-32]],h=[[0,64],[32,96],[64,128],[96,160],[-32,32]],l=e?"rgb(128,128,255)":t,b=e?"rgb(160,100,255)":a,d=e?"rgba(100,160,255, 0.5)":"rgba(0,0,0, 0.1)";for(s.strokeStyle=d,s.lineWidth=1,i=0;i<5;i++){o=s.createLinearGradient(0,h[i][0],0,h[i][1]),o.addColorStop(0,b),o.addColorStop(1,l),s.beginPath(),s.fillStyle=o,s.rect(c[i][0],c[i][1],32,64),s.fill();for(let e=0;e<8;e++)r=2*(Math.random()-.5),s.beginPath(),s.moveTo(c[i][0]+r+2+4*e,c[i][1]),s.lineTo(c[i][0]+r+2+4*e,c[i][1]+64),s.stroke()}for(c=[[32,0],[64,32],[96,64],[-32,64],[0,96]],h=[[32,96],[64,128],[96,160],[-32,32],[0,64]],i=0;i<5;i++)for(o=s.createLinearGradient(h[i][0],0,h[i][1],0),o.addColorStop(0,l),o.addColorStop(1,b),s.beginPath(),s.fillStyle=o,s.rect(c[i][0],c[i][1],64,32),s.fill(),n=0;n<8;n++)r=2*(Math.random()-.5),s.beginPath(),s.moveTo(c[i][0],c[i][1]+r+2+4*n),s.lineTo(c[i][0]+64,c[i][1]+r+2+4*n),s.stroke()}else s.beginPath(),s.fillStyle=a,s.rect(0,0,32,64),s.rect(32,32,32,64),s.rect(64,64,32,64),s.rect(96,96,32,64),s.rect(96,-32,32,64),s.fill();const n=new p(i);return n.wrapS=n.wrapT=g,n.repeat.x=n.repeat.y=60,e||(n.colorSpace=y),n}}class ta extends x{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:"",SUBSURFACE:"",USE_UV:""},this.extra={},this.addParametre("sssMap",null),this.addParametre("sssColor",new w(0,0,0)),this.addParametre("sssAmbient",.5),this.addParametre("sssDistortion",.6),this.addParametre("sssAttenuation",.1),this.addParametre("sssPower",1),this.addParametre("sssScale",6),this.setValues(e);let t=this;t.onBeforeCompile=function(e){for(let a in t.extra)e.uniforms[a]={value:t.extra[a]};e.fragmentShader=e.fragmentShader.replace("#include <common>",aa.common),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_begin>",t.replaceAll(ia,"RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );",aa.light)),t.userData.shader=e}}addParametre(e,t){this.extra[e]=t,Object.defineProperty(this,e,{get:()=>this.extra[e],set:t=>{this.extra[e]=t,this.userData.shader&&(this.userData.shader.uniforms[e].value=this.extra[e])}})}replaceAll(e,t,a){return e.split(t).join(a)}}const aa={common:"\n\t#include <common>\n\tuniform sampler2D sssMap;\n\tuniform float sssPower;\n\tuniform float sssScale;\n\tuniform float sssDistortion;\n\tuniform float sssAmbient;\n\tuniform float sssAttenuation;\n\tuniform vec3 sssColor;\n\n\tvoid RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, inout ReflectedLight reflectedLight) {\n\t\tvec3 thickness = sssColor * texture2D(sssMap, uv).r;\n\t\tvec3 scatteringHalf = normalize(directLight.direction + (geometryNormal * sssDistortion));\n\t\tfloat scatteringDot = pow(saturate(dot(geometryViewDir, -scatteringHalf)), sssPower) * sssScale;\n\t\tvec3 scatteringIllu = (scatteringDot + sssAmbient) * thickness;\n\t\treflectedLight.directDiffuse += scatteringIllu * sssAttenuation * directLight.color;\n\t}\n\t",light:"\n\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t#if defined( SUBSURFACE ) && defined( USE_UV )\n\t\tRE_Direct_Scattering(directLight, vUv, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, reflectedLight);\n\t#endif\n\t"},ia="\n\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n\n#ifdef USE_CLEARCOAT\n\n\tgeometryClearcoatNormal = clearcoatNormal;\n\n#endif\n\n#ifdef USE_IRIDESCENCE\n\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\n\tif ( material.iridescenceThickness == 0.0 ) {\n\n\t\tmaterial.iridescence = 0.0;\n\n\t} else {\n\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\n\t}\n\n\tif ( material.iridescence > 0.0 ) {\n\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\n\t\t// Iridescence F0 approximation\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\n\t}\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\n\t\t// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\t#if defined( USE_LIGHT_PROBES )\n\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\n\t#endif\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",sa={metalness:.1,roughness:.9},na={grey:new w(.18,.18,.18),black:new w(.039,.039,.039),body:new w(13289155),sleep:new w("hsl(33, 15%, 54%)"),solid:new w(7105128),base:new w(13224135),brick:new w(.262,.095,.061),sand:new w(.44,.386,.231),gold:new w(.944,.776,.373),gold2:new w(.998,.981,.751),titanium:new w(.633,.578,.503),titaniumSpec:new w(.728,.68,.55),chrome:new w(.653,.65,.615),chromeSpec:new w(.675,.72,.711),copper:new w(.988,.688,.448),carPaint:new w(.1037792,.59212029,.85064936),clay:new w("hsl(12, 30%, 40%)"),clayWhite:new w(11119017),concrete:new w(.51,.51,.51),Raw_Fire:new w("hsl(40, 18%, 54%)"),Raw_Buff:new w("hsl(33, 15%, 54%)"),Raw_Terracotta:new w("hsl(12, 30%, 40%)"),Raw_Porcelain:new w("hsl(45, 15%, 90%)")},ra={No:Q,Normal:X,Additive:W,Subtractive:J,Multiply:V,Eadd:K,Esub:U,Erev:G,Emin:N,Emaw:_,Fzero:H,Fone:L,Fcolor:q,Fcolorm:O,Falpha:C,Falpham:B,Fdstalpha:D,Fdstalpham:I,Fdstcolor:T,Fdstcolorm:R,Falphasaturate:P,Front:F,Back:z,Double:E};let oa=class{constructor(){this.renderMode={value:0},this.depthPacking={value:0},this.extendMat=!1,this.isRealism=!1,this.realismOption={},this.envMapIntensity=1,this.mat={},this.TmpMat=[]}changeRenderMode(e){this.renderMode.value=e}initExtandShader(){}useRealLight(e){}setColor(e){}set(e,t,a=null){a||(a=e.onBeforeCompile),this.mat[e.name]=e}extendShader(e,t=null){}addToTmp(e){this.TmpMat.push(e)}create(e){let t,a=null;if(e.isMaterial)t=e;else{let i=void 0!==e.type?e.type:"Standard";switch(e.type&&delete e.type,a=e.beforeCompile||null,e.beforeCompile&&delete e.beforeCompile,(e.thickness||e.sheen||e.clearcoat||e.transmission||e.specularColor)&&(i="Physical"),e.normalScale&&(e.normalScale.isVector2||(e.normalScale=(new f).fromArray(e.normalScale))),e.side&&(e.side=this.findValue(e.side)),e.shadowSide&&(e.shadowSide=this.findValue(e.shadowSide)),e.blending&&(e.blending=this.findValue(e.blending)),e.blendEquation&&(e.blendEquation=this.findValue(e.blendEquation)),e.blendEquationAlpha&&(e.blendEquationAlpha=this.findValue(e.blendEquationAlpha)),e.blendSrc&&(e.blendSrc=this.findValue(e.blendSrc)),e.blendDst&&(e.blendDst=this.findValue(e.blendDst)),e.blendDstAlpha&&(e.blendDstAlpha=this.findValue(e.blendDstAlpha)),e.blendSrcAlpha&&(e.blendSrcAlpha=this.findValue(e.blendSrcAlpha)),e.clearcoatNormalScale&&(e.clearcoatNormalScale.isVector2||(e.clearcoatNormalScale=(new f).fromArray(e.clearcoatNormalScale))),i=i.toLowerCase(),i){case"physical":t=new x(e);break;case"phong":t=new S(e);break;case"lambert":t=new A(e);break;case"basic":t=new M(e);break;case"line":t=new s(e);break;case"toon":t=new j(e);break;case"shadow":t=new k(e);break;case"sss":t=new ta(e);break;default:t=new v(e)}}return this.mat[t.name]?null:(this.set(t,!1,a),t)}findValue(e){return"string"===e?ra[e.charAt(0).toUpperCase()+e.slice(1)]:e}addToMat(e){if(this.isRealism)for(let t in e)e[t].onBeforeCompile=function(a){EnhanceLighting(a,this.realismOption),e[t].userData.isRealism=!0,e[t].userData.shader=a};this.mat={...this.mat,...e}}changeType(){}directIntensity(e){for(let e in this.mat);}getList(){let e={...this.mat};const t=["line","debug","hide","svg"];let a=t.length;for(;a--;)delete e[t[a]];return e}get(e){if(!this.mat[e])switch(e){case"grey":this.create({name:"grey",color:na.grey,metalness:0,roughness:.5});break;case"black":this.create({name:"black",color:na.black,metalness:0,roughness:.5});break;case"body":this.create({name:"body",color:na.body,...sa});break;case"sleep":this.create({name:"sleep",color:na.sleep,...sa});break;case"solid":this.create({name:"solid",color:na.solid,...sa});break;case"base":this.create({name:"base",color:na.base,...sa});break;case"clay":this.create({name:"clay",color:na.clay,metalness:.1,roughness:.7});break;case"clayWhite":this.create({name:"clayWhite",color:na.clayWhite,metalness:.1,roughness:.7});break;case"concrete":this.create({name:"concrete",color:na.concrete,metalness:0,roughness:.9});break;case"brick":this.create({name:"brick",color:na.brick,metalness:0,roughness:.6});break;case"sand":this.create({name:"sand",color:na.sand,metalness:0,roughness:.9});break;case"chrome":this.create({name:"chrome",color:na.chrome,specularColor:na.chromeSpec,metalness:1,roughness:.075});break;case"silver":this.create({name:"silver",color:11184810,metalness:.8,roughness:.22});break;case"gold":this.create({name:"gold",color:na.gold,specularColor:na.gold2,metalness:1,roughness:.02});break;case"copper":this.create({name:"copper",color:na.copper,metalness:1,roughness:.05});break;case"titanium":this.create({name:"titanium",color:na.titanium,metalness:1,roughness:0,specularColor:na.titaniumSpec});break;case"carPaint":this.create({name:"carPaint",color:na.carPaint,metalness:0,anisotropy:new f(.5,.5),roughness:.4,clearcoat:1,clearcoatRoughness:0});break;case"carbon":this.create({name:"carbon",map:new ea,normalMap:new ea(!0),clearcoat:1,clearcoatRoughness:.1,roughness:.5});break;case"cloth":this.create({name:"cloth",color:8391119,roughness:.5,sheenColor:13335807,sheen:1,sheenRoughness:.2});break;case"skinny":this.create({name:"skinny",type:"physical",color:16763305,metalness:.1,roughness:.5,sheen:1,sheenColor:16277313,sheenRoughness:.2});break;case"glass":this.create({name:"glass",color:16777215,transparent:!0,roughness:.02,metalness:0,side:E,alphaToCoverage:!0,premultipliedAlpha:!0,transmission:1,clearcoat:1,thickness:.01});break;case"glassX":this.create({name:"glassX",color:16777215,alphaToCoverage:!0,transparent:!0,opacity:1,roughness:0,metalness:0,side:E,transmission:1,clearcoat:1,clearcoatRoughness:0,thickness:.05,ior:1.52,shadowSide:1,reflectivity:.5,iridescence:0,specularIntensity:1,specularColor:16777215});break;case"plexi":this.create({name:"plexi",blending:W,color:65793,transparent:!0,opacity:.7,reflectivity:.3,metalness:.6,roughness:.1,clearcoat:.2,clearcoatRoughness:.02,side:E,alphaToCoverage:!0,premultipliedAlpha:!0});break;case"plexi2":this.create({name:"plexi2",blending:W,color:65793,transparent:!1,opacity:.7,reflectivity:.3,metalness:.6,roughness:.1,clearcoat:.2,clearcoatRoughness:.02,side:E,alphaToCoverage:!1,premultipliedAlpha:!0});break;case"glass2":this.create({name:"glass2",color:15658734,transparent:!0,roughness:0,alphaToCoverage:!0,opacity:.3});break;case"glass3":this.create({name:"glass3",color:0,transparent:!0,roughness:0,alphaToCoverage:!0,opacity:.4});break;case"glass_red":this.create({name:"glass_red",color:16711680,transparent:!0,roughness:0,alphaToCoverage:!0,opacity:.8});break;case"car":this.create({name:"car",color:3158064,metalness:1,roughness:.5,clearcoat:1,clearcoatRoughness:.03,sheen:.5});break;case"carGlass":this.create({name:"carGlass",color:16777215,metalness:0,roughness:0,transmission:1,ior:1.52});break;case"outline":this.create({name:"outline",color:16777215,type:"Basic",side:z,toneMapped:!1,wireframe:!0,transparent:!0,opacity:.25});break;case"debug":this.create({name:"debug",type:"Basic",color:15953986,wireframe:!0,toneMapped:!1,transparent:!0,opacity:.5});break;case"shadow":this.create({name:"shadow",type:"shadow",color:0,opacity:.5});break;case"bones":this.create({name:"bones",color:16639958,wireframe:!0});break;case"bones2":this.create({name:"bones2",type:"basic",color:14664872,transparent:!0,opacity:.5,depthTest:!0,depthWrite:!1,alphaToCoverage:!0});break;case"button":this.create({name:"button",color:16728139,...sa});break;case"line":this.create({name:"line",type:"line",vertexColors:!0,toneMapped:!1});break;case"liner":this.create({name:"liner",type:"line",vertexColors:!0,toneMapped:!1,depthTest:!0,depthWrite:!0,alphaToCoverage:!0});break;case"hide":this.create({name:"hide",type:"basic",visible:!1});break;case"particle":this.create({name:"particle",type:"basic",toneMapped:!1,color:16776960,transparent:!0,opacity:.2});break;case"svg":this.create({name:"svg",type:"basic",toneMapped:!1,vertexColors:!0,transparent:!1,side:E})}return this.mat[e]}dispose(){this.isRealism=!1;for(let e in this.mat)this.mat[e].dispose(),delete this.mat[e];let e=this.TmpMat.length;for(;e--;)this.TmpMat[e].dispose();this.TmpMat=[]}upShader(){let e=this.realismOption;for(let t in this.mat){const a=this.mat[t],i=a.userData.shader;for(let t in e)i&&void 0!==i.uniforms[t]&&(i.uniforms[t].value=e[t]),a[t]&&(a[t]=e[t])}}};class ca{constructor(e=-1){this.perf=window.performance,this.time={now:0,delta:0,then:0,interval:0,tmp:0,n:0,dt:0},this.fps=0,this.delta=0,this.elapsedTime=0,this.unlimited=!1,this.setFramerate(e),this.force=!1}up(e){let t=this.time;return this.unlimited&&(this.force=!0),t.now=void 0!==e?e:this.now(),t.delta=t.now-t.then,this.force&&(t.delta=t.interval,this.force=!1),!!(t.delta>=t.interval||this.unlimited)&&(t.then=this.unlimited?t.now:t.now-t.delta%t.interval,this.delta=.001*t.interval,this.elapsedTime+=this.delta,!0)}setFramerate(e){this.elapsedTime=0,this.framerate=e,this.unlimited=this.framerate<0,this.time.interval=1e3/e,60===e&&(this.time.interval=16.67)}static now(){return this.perf?this.perf.now():Date.now()}static format_time(e){return e>1e3?e/1e3+" sec":e+" ms"}}class ha{constructor(){this.key=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.key2=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.gamepad=new la(this.key),this.useGamepad=!1,this.sameAxis=!0,document.addEventListener("keydown",function(e){this.keyDown(e)}.bind(this),!1),document.addEventListener("keyup",function(e){this.keyUp(e)}.bind(this),!1)}setKey(e,t){this.key[e]=t}update(){return this.gamepad.update(),this.gamepad.ready&&(this.useGamepad||(this.useGamepad=!0),this.gamepad.getValue(0)),this.sameAxis&&(this.key[2]=this.key[0],this.key[3]=this.key[1]),this.key}keyDown(e){var t=this.key,a=this.key2;if(e=e||window.event,this.sameAxis)switch(e.which){case 65:case 81:case 37:t[0]=-1,a[0]=1;break;case 68:case 39:t[0]=1,a[1]=1;break;case 87:case 90:case 38:t[1]=-1;break;case 83:case 40:t[1]=1;break;case 32:t[4]=1;break;case 17:case 67:t[5]=1;break;case 69:t[6]=1;break;case 16:t[7]=1}else switch(e.which){case 65:case 81:t[0]=-1,a[0]=1;break;case 68:t[0]=1,a[1]=1;break;case 87:case 90:t[1]=-1;break;case 83:t[1]=1;break;case 37:t[2]=-1,a[0]=1;break;case 39:t[2]=1,a[1]=1;break;case 38:t[3]=-1;break;case 40:t[3]=1;break;case 32:t[4]=1;break;case 17:case 67:t[5]=1;break;case 69:t[6]=1;break;case 16:t[7]=1}this.gamepad.reset()}keyUp(e){var t=this.key,a=this.key2;if(e=e||window.event,this.sameAxis)switch(e.which){case 65:case 81:case 37:t[0]=t[0]<0?0:t[0],a[0]=0;break;case 68:case 39:t[0]=t[0]>0?0:t[0],a[1]=0;break;case 87:case 90:case 38:t[1]=t[1]<0?0:t[1];break;case 83:case 40:t[1]=t[1]>0?0:t[1];break;case 32:t[4]=0;break;case 17:case 67:t[5]=0;break;case 69:t[6]=0;break;case 16:t[7]=0}else switch(e.which){case 65:case 81:t[0]=t[0]<0?0:t[0],a[0]=0;break;case 68:t[0]=t[0]>0?0:t[0],a[1]=0;break;case 87:case 90:t[1]=t[1]<0?0:t[1];break;case 83:t[1]=t[1]>0?0:t[1];break;case 37:t[2]=t[2]<0?0:t[2],a[0]=0;break;case 39:t[2]=t[2]>0?0:t[2],a[1]=0;break;case 38:t[3]=t[3]<0?0:t[3];break;case 40:t[3]=t[3]>0?0:t[3];break;case 32:t[4]=0;break;case 17:case 67:t[5]=0;break;case 69:t[6]=0;break;case 16:t[7]=0}}}class la{constructor(e){this.values=[],this.ready=0,this.key=e}update(){var e,t,a,i,s,n,r=this.fix,o=navigator.getGamepads();for(e=0;e<o.length;e++)if(n=o[e])if(a=n.axes.length,i=n.buttons.length){for(this.values[e]||(this.values[e]=[]),t=0;t<a;t++)s=r(n.axes[t],.08),0==this.ready&&0!==s&&(this.ready=1),this.values[e][t]=s;for(t=0;t<i;t++)s=r(n.buttons[t].value),0==this.ready&&0!==s&&(this.ready=1),this.values[e][a+t]=s}else this.values[e]&&(this.values[e]=null)}getValue(e){for(var t,a=19;a--;)t=this.values[e][a],0==this.ready&&0!==t&&(this.ready=1),this.key[a]=t}reset(){this.ready=0}fix(e,t){let a=Number(e.toString().substring(0,5));return t&&a<t&&a>-t&&(a=0),a}}class ba{constructor(){this.id=0,this.list=[],this.type="item",this.Utils=null}reset(){let e=this.list.length;for(;e--;)this.dispose(this.list[e]);this.list=[],this.id=0}byName(e){return this.Utils.byName(e)}setName(e={}){let t=void 0!==e.name?e.name:this.type+this.id++;return e.id=this.remove(t,!0),e.name=t,t}addToWorld(e,t=-1){this.Utils.add(e),-1!==t?this.list[t]=e:this.list.push(e)}remove(e,t){let a=this.byName(e);return a?this.clear(a,t):-1}clear(e,t){let a=this.list.indexOf(e);return-1===a||t?this.list[a]=null:this.list.splice(a,1),this.dispose(e),a}dispose(e){null!==e&&this.Utils.remove(e)}add(e={}){}set(e={}){}step(e,t){}}class da extends ba{constructor(e){super(),this.motor=e,this.Utils=this.motor.utils,this.type="ray",this.iType="ray"}step(e,t){let a,i,s=this.list.length;for(;s--;)a=this.list[s],i=t+s*Nt.ray,a.update(e,i,this.motor.reflow.ray[s]||null)}add(e={}){this.setName(e);let t=new ua(e,this.motor);return t.visible=void 0===e.visible||e.visible,this.addToWorld(t,e.id),e.parent&&"string"!=typeof e.parent&&(e.parent=e.parent.name),e.callback&&delete e.callback,this.motor.post({m:"add",o:e}),t}set(e={},t=null){null===t&&(t=this.byName(e.name)),null!==t&&t.setRay(e)}}class ua extends Y{constructor(e={},a){super(new t,a.getMat("line")),this.motor=a,this.Utils=this.motor.utils,this.isRay=!0,this.data={hit:!1,body:"",point:[0,0,0],normal:[0,0,0],distance:0,angle:0,parent:null},this.type="ray",this.name=e.name,this.parentMesh=null,e.parent&&(this.parentMesh="string"==typeof e.parent?this.Utils.byName(e.parent):e.parent,this.data.parent=this.parentMesh),this.callback=e.callback||null,this.c0=[.1,.1,.3],this.c1=[.1,.4,.6],this.c2=[1,.1,.1],this.c3=[.1,1,.1],this.begin=new r,this.end=new r(0,1,0),this.tmp=new r,this.vnormal=new r,this.vv1=new r,this.vv2=new r,this.fullDistance=0,this.setRay(e);this.geometry.setAttribute("position",new i([0,0,0,0,0,0,0,0,0],3)),this.geometry.setAttribute("color",new i([0,0,0,0,0,0,0,0,0],3)),this.vertices=this.geometry.attributes.position,this.colors=this.geometry.attributes.color,this.local=[0,0,0,0,0,0,0,0,0],this.noRotation=e.noRotation||!1,this.fakeMatrix=new c,this.matrixAutoUpdate=!1,this.frustumCulled=!1}setRay(e){e.begin&&this.begin.fromArray(e.begin),e.end&&this.end.fromArray(e.end),this.fullDistance=this.begin.distanceTo(this.end)}update(e,t=0,a=null){if(this.data.hit=0!==e[t],this.data.body=a||"",this.data.distance=e[t+1],this.data.hit)this.local[0]=e[t+2],this.local[1]=e[t+3],this.local[2]=e[t+4],this.tmp.fromArray(e,t+5),this.vnormal.fromArray(e,t+8),this.data.point=this.tmp.toArray(),this.data.normal=this.vnormal.toArray(),this.tmp.toArray(this.local,3),this.vv1.fromArray(this.local).sub(this.tmp).normalize(),this.tmp.addScaledVector(this.vnormal,this.fullDistance-this.data.distance),this.tmp.toArray(this.local,6),this.data.angle=Math.floor(It.angleTo(this.vv1.toArray(),this.data.normal)*Ft);else if(this.parentMesh){let e;e=this.noRotation?this.fakeMatrix.setPosition(this.parentMesh.position.x,this.parentMesh.position.y,this.parentMesh.posit