UNPKG

phy-engine

Version:

JavaScript 3D Physics for three.js

6 lines 541 kB
/** * @license * Copyright 2010-2025 Phy.js Authors * SPDX-License-Identifier: MIT */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three"),require("three/addons/utils/BufferGeometryUtils.js"),require("three/addons/loaders/SVGLoader.js"),require("three/addons/utils/SkeletonUtils.js"),require("three/addons/loaders/GLTFLoader.js"),require("three/addons/loaders/FBXLoader.js"),require("three/addons/loaders/OBJLoader.js"),require("three/addons/loaders/STLLoader.js"),require("three/addons/loaders/HDRLoader.js"),require("three/addons/loaders/EXRLoader.js"),require("three/addons/loaders/UltraHDRLoader.js"),require("three/addons/loaders/KTX2Loader.js"),require("three/addons/utils/SortUtils.js")):"function"==typeof define&&define.amd?define(["exports","three","three/addons/utils/BufferGeometryUtils.js","three/addons/loaders/SVGLoader.js","three/addons/utils/SkeletonUtils.js","three/addons/loaders/GLTFLoader.js","three/addons/loaders/FBXLoader.js","three/addons/loaders/OBJLoader.js","three/addons/loaders/STLLoader.js","three/addons/loaders/HDRLoader.js","three/addons/loaders/EXRLoader.js","three/addons/loaders/UltraHDRLoader.js","three/addons/loaders/KTX2Loader.js","three/addons/utils/SortUtils.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).PHY={},e.THREE,e.BufferGeometryUtils_js,e.SVGLoader_js,e.SkeletonUtils,e.GLTFLoader_js,e.FBXLoader_js,e.OBJLoader_js,e.STLLoader_js,e.HDRLoader_js,e.EXRLoader_js,e.UltraHDRLoader_js,e.KTX2Loader_js,e.SortUtils_js)}(this,(function(e,t,a,i,s,r,n,c,h,l,b,d,u,f){"use strict";var p="undefined"!=typeof document?document.currentScript:null;function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,i.get?i:{enumerable:!0,get:function(){return e[a]}})}})),t.default=e,Object.freeze(t)}var y=g(s);const x=3.141592653589793,w=x/180,v=180/x,k=Number.EPSILON,j=.5*x,M={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:v,torad:w,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=x/4*a-a*(a-1)*(.2447+.0663*a);return copysign(t>1?x/2-i:i,e)},clampA:(e,t,a)=>Math.max(t,Math.min(a,e)),smoothstep:(e,t,a)=>e*(a=-2*(a=M.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)=>M.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?v: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=M.randInt(e,t);-1===i.indexOf(s)&&i.push(s)}return i},fromTransform:(e,t,a,i=[0,0,0,1],s=!1)=>{let r=M.composeMatrixArray(e,t),n=M.composeMatrixArray(a,i);return s&&(r=M.invertMatrixArray(r)),r=M.multiplyMatrixArray(r,n),[r[12],r[13],r[14]]},fromTransformToQ:(e,t,a=!1)=>{let i=M.composeMatrixArray(e,t),s=M.decomposeFullMatrixArray(i).q;return a&&(s=M.quatInvert(s)),s},lerpTransform:(e,t,a)=>{let i=e[0],s=e[1],r=t[0],n=t[1];return r=M.lerpArray(i,r,a),n=M.slerpQuatArray(s,n,a),[r,n]},composeMatrixArray:(e,t,a=[1,1,1])=>{const i=t[0],s=t[1],r=t[2],n=t[3],o=i+i,c=s+s,h=r+r,l=i*o,b=i*c,d=i*h,u=s*c,f=s*h,m=r*h,p=n*o,g=n*c,y=n*h,x=a[0],w=a[1],v=a[2];return[(1-(u+m))*x,(b+y)*x,(d-g)*x,0,(b-y)*w,(1-(l+m))*w,(f+p)*w,0,(d+g)*v,(f-p)*v,(1-(l+u))*v,0,e[0],e[1],e[2],1]},multiplyMatrixArray:(e,t)=>{const a=e,i=t,s=[],r=a[0],n=a[4],o=a[8],c=a[12],h=a[1],l=a[5],b=a[9],d=a[13],u=a[2],f=a[6],m=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],F=i[13],z=i[2],R=i[6],P=i[10],T=i[14],I=i[3],B=i[7],C=i[11],D=i[15];return s[0]=r*v+n*A+o*z+c*I,s[4]=r*k+n*S+o*R+c*B,s[8]=r*j+n*E+o*P+c*C,s[12]=r*M+n*F+o*T+c*D,s[1]=h*v+l*A+b*z+d*I,s[5]=h*k+l*S+b*R+d*B,s[9]=h*j+l*E+b*P+d*C,s[13]=h*M+l*F+b*T+d*D,s[2]=u*v+f*A+m*z+p*I,s[6]=u*k+f*S+m*R+p*B,s[10]=u*j+f*E+m*P+p*C,s[14]=u*M+f*F+m*T+p*D,s[3]=g*v+y*A+x*z+w*I,s[7]=g*k+y*S+x*R+w*B,s[11]=g*j+y*E+x*P+w*C,s[15]=g*M+y*F+x*T+w*D,s},invertMatrixArray:e=>{const t=e,a=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],c=t[6],h=t[7],l=t[8],b=t[9],d=t[10],u=t[11],f=t[12],m=t[13],p=t[14],g=t[15],y=b*p*h-m*d*h+m*c*u-o*p*u-b*c*g+o*d*g,x=f*d*h-l*p*h-f*c*u+n*p*u+l*c*g-n*d*g,w=l*m*h-f*b*h+f*o*u-n*m*u-l*o*g+n*b*g,v=f*b*c-l*m*c-f*o*d+n*m*d+l*o*p-n*b*p,k=a*y+i*x+s*w+r*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]=(m*d*r-b*p*r-m*s*u+i*p*u+b*s*g-i*d*g)*j,t[2]=(o*p*r-m*c*r+m*s*h-i*p*h-o*s*g+i*c*g)*j,t[3]=(b*c*r-o*d*r-b*s*h+i*d*h+o*s*u-i*c*u)*j,t[4]=x*j,t[5]=(l*p*r-f*d*r+f*s*u-a*p*u-l*s*g+a*d*g)*j,t[6]=(f*c*r-n*p*r-f*s*h+a*p*h+n*s*g-a*c*g)*j,t[7]=(n*d*r-l*c*r+l*s*h-a*d*h-n*s*u+a*c*u)*j,t[8]=w*j,t[9]=(f*b*r-l*m*r-f*i*u+a*m*u+l*i*g-a*b*g)*j,t[10]=(n*m*r-f*o*r+f*i*h-a*m*h-n*i*g+a*o*g)*j,t[11]=(l*o*r-n*b*r-l*i*h+a*b*h+n*i*u-a*o*u)*j,t[12]=v*j,t[13]=(l*m*s-f*b*s+f*i*d-a*m*d-l*i*p+a*b*p)*j,t[14]=(f*o*s-n*m*s-f*i*c+a*m*c+n*i*p-a*o*p)*j,t[15]=(n*b*s-l*o*s+l*i*c-a*b*c-n*i*d+a*o*d)*j,t},matrixArrayDeterminant:e=>{const t=e,a=t[0],i=t[4],s=t[8],r=t[12],n=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]*(+r*c*b-s*h*b-r*o*d+i*h*d+s*o*u-i*c*u)+t[7]*(+a*c*u-a*h*d+r*n*d-s*n*u+s*h*l-r*c*l)+t[11]*(+a*h*b-a*o*u-r*n*b+i*n*u+r*o*l-i*h*l)+t[15]*(-s*o*l-a*c*b+a*o*d+s*n*b-i*n*d+i*c*l)},decomposeMatrixArray:e=>[e[12],e[13],e[14]],decomposeFullMatrixArray:e=>{const t=e;let a=M.lengthArray([t[0],t[1],t[2]]);const i=M.lengthArray([t[4],t[5],t[6]]),s=M.lengthArray([t[8],t[9],t[10]]);M.matrixArrayDeterminant(e)<0&&(a=-a);let r=[...e];const n=1/a,o=1/i,c=1/s;r[0]*=n,r[1]*=n,r[2]*=n,r[4]*=o,r[5]*=o,r[6]*=o,r[8]*=c,r[9]*=c,r[10]*=c;let h=M.quatFromRotationMatrix(r);return{p:[e[12],e[13],e[14]],q:h,s:[a,i,s]}},applyTransformArray:(e,t,a,i=[1,1,1])=>{const s=M.composeMatrixArray(t,a,i),r=e[0],n=e[1],o=e[2],c=1/(s[3]*r+s[7]*n+s[11]*o+s[15]);return[(s[0]*r+s[4]*n+s[8]*o+s[12])*c,(s[1]*r+s[5]*n+s[9]*o+s[13])*c,(s[2]*r+s[6]*n+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],r=e[1],n=e[2],o=e[3],c=t[0],h=t[1],l=t[2],b=t[3];let d=o*b+s*c+r*h+n*l;if(d<0?(i=[-c,-h,-l,-b],d=-d):i=[...t],d>=1)return e;const u=1-d*d;if(u<=k){const e=1-a;return i[3]=e*o+a*i[3],i[0]=e*s+a*i[0],i[1]=e*r+a*i[1],i[2]=e*n+a*i[2],M.quatNomalize(i)}const f=Math.sqrt(u),m=Math.atan2(f,d),p=Math.sin((1-a)*m)/f,g=Math.sin(a*m)/f;return i[3]=o*p+i[3]*g,i[0]=s*p+i[0]*g,i[1]=r*p+i[1]*g,i[2]=n*p+i[2]*g,i},toLocalQuatArray:(e=[0,0,0],t)=>{let a=M.quatFromEuler(e),i=M.quatInvert(t.quaternion.toArray());return M.quatMultiply(i,a)},quatFromRotationMatrix:e=>{let t=[0,0,0,1];const a=e,i=a[0],s=a[4],r=a[8],n=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]=(r-h)*e,t[2]=(n-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+n)/e,t[2]=(r+h)/e}else if(o>b){const e=2*Math.sqrt(1+o-i-b);t[3]=(r-h)/e,t[0]=(s+n)/e,t[1]=.25*e,t[2]=(c+l)/e}else{const e=2*Math.sqrt(1+b-i-o);t[3]=(n-s)/e,t[0]=(r+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?w:1,r=e[0]*s*.5,n=e[1]*s*.5,o=e[2]*s*.5,c=a(r),h=a(n),l=a(o),b=i(r),d=i(n),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?w:1),s=Math.sin(i);return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]},quatNomalize:e=>{let t=M.lengthArray(e);return 0===t?[0,0,0,1]:(t=1/t,M.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],r=e[3],n=t[0],o=t[1],c=t[2],h=t[3];return[a*h+r*n+i*c-s*o,i*h+r*o+s*n-a*c,s*h+r*c+a*o-i*n,r*h-a*n-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],r=e[9];e[2];const n=e[6],o=e[10];let c=[0,0,0];return c[1]=Math.asin(M.clamp(i,-1,1)),Math.abs(i)<.9999999?(c[0]=Math.atan2(-r,o),c[2]=Math.atan2(-a,t)):(c[0]=Math.atan2(n,s),c[2]=0),c},angleTo:(e,t)=>2*Math.acos(Math.abs(M.clamp(M.dotArray(e,t),-1,1))),fixedArray:(e,t)=>{let a=e.length,i=[];for(;a--;)i[a]=M.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>j?a-=j:a+=j;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],r=t[0],n=t[1],o=t[2];return[i*o-s*n,s*r-a*o,a*n-i*r]},applyQuaternion:(e,t)=>{const a=e[0],i=e[1],s=e[2],r=t[0],n=t[1],o=t[2],c=t[3],h=2*(n*s-o*i),l=2*(o*a-r*s),b=2*(r*i-n*a);return[a+c*h+n*b-o*l,i+c*l+o*h-r*b,s+c*b+r*l-n*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)=>M.mulArray(e,1/t,a),scaleArray:(e,t,a)=>M.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])=>M.lengthArray(M.subArray(e,t)),normalizeArray:e=>M.divArray(e,M.lengthArray(e)||1),normalArray:(e,t=[0,0,0])=>M.normalizeArray(M.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=M.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 r=[s[0]-i[0],s[1]-i[1],s[2]-i[2]];return.5*r[0]*8*(.5*r[1])*(.5*r[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=[],r={};new THREE.Vector3;let n,o=0;M.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,n=i.length;for(let t=0;t<n;t++)h=i[t],c.x===h.x&&c.y===h.y&&c.z===h.z&&(l=!0,r[e]=h.id);l||(c.id=b++,i.push(c),s.push([c.x,c.y,c.z]))}return[s,r]},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,r,n,o,c,h=e.length,l=h;for(;l--;)for(i=e[l],a=h;a--;)a!==l&&(s=e[a],r=i.filter((e=>s.includes(e))),r.length>1&&(c=[],n=[...i],o=n.indexOf(r[0]),n.splice(o,1),o=n.indexOf(r[1]),n.splice(o,1),c.push(n[0]),n=[...s],o=n.indexOf(r[0]),n.splice(o,1),o=n.indexOf(r[1]),n.splice(o,1),c.push(n[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"),r=s.count,n=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<r;e++){b=3*e;let t=`${~~(n[b]*h+l)},${~~(n[b+1]*h+l)},${~~(n[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}},A=M,S=["PHYSX","HAVOK"],E=4e3,F=1e3,z=4e3,R=100,P=100,T=50,I=20,B={bodyFull:14,body:8,joint:16,contact:1,ray:11,character:16,vehicle:72,solver:128},C=function(e,t=!1){const a={};let i={body:E*(t?B.bodyFull:B.body),joint:F*B.joint,ray:R*B.ray,contact:z*B.contact,character:P*B.character};"PHYSX"!==e&&"AMMO"!==e||(i.vehicle=T*B.vehicle),"PHYSX"===e&&(i.solver=I*B.solver),"HAVOK"!==e&&"RAPIER"!==e&&"JOLT"!==e||(B.joint=0);let s=0;for(let e in i)a[e]=s,s+=i[e];return a.total=s,a};class D extends t.LineSegments{constructor(e,a=16776960){const i=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]),s=[.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],r=new t.BufferGeometry;r.setIndex(new t.BufferAttribute(i,1)),r.setAttribute("position",new t.Float32BufferAttribute(s,3)),r.setAttribute("color",new t.Float32BufferAttribute([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(r,new t.LineBasicMaterial({color:a,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 L extends t.BufferGeometry{constructor(e=1,a=16,i=16,s=16,r=1){super(),this.type="SphereBox",this.name="SphereBox_"+e+"_"+a+"_"+i+"_"+s+"_"+r,e=e||1,a=Math.floor(a),i=Math.floor(i),s=Math.floor(s);let n,o,c,h=new t.BoxGeometry(1,1,1,a,i,s),l=new t.Vector3,b=new t.Vector3,d=h.attributes.position.count,u=h.attributes.position.array,f=h.attributes.normal.array,m=h.attributes.uv.array,p=h.attributes.uv.count,g=p/6,y=1/3,x=0,w=0;for(let e=0;e<p;e++){switch(c=Math.floor(e/g),c){case 0:x=0,w=.5;break;case 5:x=y,w=.5;break;case 1:x=2*y,w=.5;break;case 4:x=0,w=1;break;case 3:x=y,w=1;break;case 2:x=2*y,w=1}o=2*e,m[o]*=y,m[o]+=x,m[o+1]*=-.5,m[o+1]+=w,m[o]>1&&(m[o]=1),m[o]<0&&(m[o]=0),m[o+1]>1&&(m[o+1]=1),m[o+1]<0&&(m[o+1]=0)}for(let t=0;t<d;t++)n=3*t,l.set(u[n],u[n+1],u[n+2]),b.copy(l).normalize(),l.lerp(b,r).multiplyScalar(e),u[n]=l.x,u[n+1]=l.y,u[n+2]=l.z,l.normalize(),f[n]=l.x,f[n+1]=l.y,f[n+2]=l.z;h.computeTangents(),this.copy(h)}}class O extends t.BufferGeometry{constructor(e=1,i=1,s=12,r=1){super(),this.type="CapsuleGeometry";let n=Math.PI,o=e/(2*e+i),c=1-2*o;s=Math.floor(s),r=Math.floor(r);let h=Math.floor(.5*s),l=2*Math.PI,b=.5*Math.PI,d=new t.CylinderGeometry(e,e,i,s,r,!0);_(d,0,o,1,c);let u=new t.SphereGeometry(e,s,h,0,l,0,b);_(u,0,1-o,1,o);let f=new t.SphereGeometry(e,s,h,0,l,b,b);_(f,0,0,1,o);let m=(new t.Matrix4).makeRotationY(.5*-n),p=(new t.Matrix4).makeTranslation(0,.5*i,0),g=(new t.Matrix4).makeTranslation(0,.5*-i,0);d.applyMatrix4(m),u.applyMatrix4(p),f.applyMatrix4(g);let y=a.mergeVertices(a.mergeGeometries([d,u,f]));this.copy(y)}}class q extends t.BufferGeometry{constructor(e=1,a=.4,i=8,s=6,r=2*Math.PI,n=0,o=Math.PI){super(),this.type="TorusGeometryFix",this.parameters={radius:e,tube:a,radialSegments:i,tubularSegments:s,arc:r},i=Math.floor(i),s=Math.floor(s);const c=[],h=[],l=[],b=[],d=new t.Vector3,u=new t.Vector3,f=new t.Vector3;let m,p;for(m=0;m<=i;m++)for(p=0;p<=s;p++){const t=p/s*r,c=m/i*o+n;u.x=(e+a*Math.cos(c))*Math.cos(t),u.y=(e+a*Math.cos(c))*Math.sin(t),u.z=a*Math.sin(c),h.push(u.x,u.y,u.z),d.x=e*Math.cos(t),d.y=e*Math.sin(t),f.subVectors(u,d).normalize(),l.push(f.x,f.y,f.z),b.push(p/s),b.push(m/i)}for(m=1;m<=i;m++)for(p=1;p<=s;p++){const e=(s+1)*m+p-1,t=(s+1)*(m-1)+p-1,a=(s+1)*(m-1)+p,i=(s+1)*m+p;c.push(e,t,i),c.push(t,a,i)}this.setIndex(c),this.setAttribute("position",new t.Float32BufferAttribute(h,3)),this.setAttribute("normal",new t.Float32BufferAttribute(l,3)),this.setAttribute("uv",new t.Float32BufferAttribute(b,2))}}class V extends t.BufferGeometry{constructor(e=1,i=1,s=1,r=.01,n=12,o=1,c=2){super(),this.type="ChamferCyl",n=Math.floor(n),o=Math.floor(o),c=Math.floor(c);let h=new t.Matrix4,l=new t.Matrix4,b=Math.PI,d=.5*b,u=2*b,f=r/s,m=1-2*f,p=new t.CylinderGeometry(e,i,s-2*r,n,o,!0,0);h.makeRotationY(d),p.applyMatrix4(h),_(p,0,f,1,m);let g=new q(e-r,r,c,n,u,0,d),y=new t.CircleGeometry(e-r,n);l.makeTranslation(0,0,r),y.applyMatrix4(l),_(g,0,1-f,1,f);let x=a.mergeGeometries([g,y]);h.makeTranslation(0,0,.5*s-r),l.makeRotationX(-d),x.applyMatrix4(l.multiply(h)),g=new q(i-r,r,c,n,u,0,d),y=new t.CircleGeometry(i-r,n),l.makeTranslation(0,0,r),y.applyMatrix4(l),_(g,0,1-f,1,f,!0);let w=a.mergeGeometries([g,y]);h.makeTranslation(0,0,.5*s-r),l.makeRotationX(d),w.applyMatrix4(l.multiply(h));let v=a.mergeVertices(a.mergeGeometries([x,p,w]));this.copy(v)}}let H=class extends t.BufferGeometry{constructor(e=1,i=1,s=1,r=.01,n=1,o=1,c=1,h=2){super(),this.type="ChamferBox",n=Math.floor(n),o=Math.floor(o),c=Math.floor(c),h=Math.floor(h);let l=Math.PI,b=.5*l,d=2*r,u=.5*e,f=.5*i,m=.5*s,p=new t.Matrix4,g=new t.Matrix4,y=new t.Matrix4,x=r/e,w=1-2*x,v=r/i,k=1-2*x,j=r/s,M=1-2*j,A=new t.PlaneGeometry(e-d,i-d,n,o),S=new t.CylinderGeometry(r,r,e-d,h,n,!0,0,b),E=new t.CylinderGeometry(r,r,i-d,h,o,!0,0,b),F=new G(r,h,h,0,b,0,-b),z=new G(r,h,h,0,b,0,-b);_(A,-x,v,w,k),_(S,0,x,v,w),g.makeTranslation(0,f-r,0),p.makeRotationX(b),F.applyMatrix4(g.multiply(p)),g.makeTranslation(0,-f+r,0),p.makeRotationX(b),y.makeRotationY(-b),z.applyMatrix4(g.multiply(p).multiply(y));let R=a.mergeGeometries([E,F,z]),P=R.clone();g.makeTranslation(u-r,0,-r),R.applyMatrix4(g),g.makeTranslation(-u+r,0,-r),p.makeRotationZ(l),P.applyMatrix4(g.multiply(p));let T=S.clone();p.makeRotationZ(b),g.makeTranslation(0,f-r,-r),S.applyMatrix4(g.multiply(p)),g.makeTranslation(0,-f+r,-r),p.makeRotationZ(-b),T.applyMatrix4(g.multiply(p));let I=a.mergeGeometries([S,T,A,R,P]),B=I.clone();g.makeTranslation(0,0,m),I.applyMatrix4(g),g.makeTranslation(0,0,-m),p.makeRotationY(l),B.applyMatrix4(g.multiply(p)),A=new t.PlaneGeometry(s-d,i-d,c,o),S=new t.CylinderGeometry(r,r,s-d,h,c,!0,0,b),T=S.clone(),_(A,-j,v,M,k),g.makeTranslation(0,-(f-r),-r,0),p.makeRotationZ(-b),S.applyMatrix4(g.multiply(p)),g.makeTranslation(0,f-r,-r,0),p.makeRotationZ(b),T.applyMatrix4(g.multiply(p));let C=a.mergeGeometries([S,T,A]),D=C.clone();g.makeTranslation(-u,0,0),p.makeRotationY(-b),C.applyMatrix4(g.multiply(p)),g.makeTranslation(u,0,0),p.makeRotationY(b),D.applyMatrix4(g.multiply(p)),A=new t.PlaneGeometry(e-d,s-d,n,c),_(A,-x,j,w,M);let L=A.clone();g.makeTranslation(0,f,0),p.makeRotationX(-b),A.applyMatrix4(g.multiply(p)),g.makeTranslation(0,-f,0),p.makeRotationX(b),L.applyMatrix4(g.multiply(p));let O=a.mergeVertices(a.mergeGeometries([I,B,C,D,A,L]));N(O,"box"),this.copy(O)}},G=class extends t.BufferGeometry{constructor(e=1,a=8,i=6,s=0,r=2*Math.PI,n=0,o=Math.PI){super(),this.type="SphereGeometryFix",this.parameters={radius:e,widthSegments:a,heightSegments:i,phiStart:s,phiLength:r,thetaStart:n,thetaLength:o},a=Math.floor(a),i=Math.floor(i);const c=Math.min(n+o,Math.PI);let h=0;const l=[],b=new t.Vector3,d=new t.Vector3,u=[],f=[],m=[],p=[];for(let t=0;t<=i;t++){const u=[],g=t/i;let y=0;0==t&&0==n?y=.5/a:t==i&&c==Math.PI&&(y=-.5/a);for(let t=0;t<=a;t++){const i=t/a;b.x=-e*Math.cos(s+i*r)*Math.sin(n+g*o),b.y=e*Math.cos(n+g*o),b.z=e*Math.sin(s+i*r)*Math.sin(n+g*o),f.push(b.x,b.y,b.z),d.copy(b).normalize(),m.push(d.x,d.y,d.z),p.push(i+y,1-g),u.push(h++)}l.push(u)}for(let e=0;e<i;e++)for(let t=0;t<a;t++){const a=l[e][t+1],s=l[e][t],r=l[e+1][t],o=l[e+1][t+1];(0!==e||n>0)&&u.push(a,s,o),(e!==i-1||c<Math.PI)&&u.push(s,r,o)}this.setIndex(u),this.setAttribute("position",new t.Float32BufferAttribute(f,3)),this.setAttribute("normal",new t.Float32BufferAttribute(m,3)),this.setAttribute("uv",new t.Float32BufferAttribute(p,2))}};function _(e,t=0,a=0,i=1,s=1,r){let n=e.attributes.uv,o=n.array,c=n.count,h=0;for(;c--;)h=2*c,o[h]=o[h]*i-t,o[h+1]=o[h+1]*s+a,r&&(o[h]=1-o[h],o[h+1]=1-o[h+1])}function N(e,a="sphere",i,s=[0,0,0],r=[0,0,0,1],n){if(void 0===n&&(n=new t.Matrix4),n.compose({x:s[0],y:s[1],z:s[2]},{_x:r[0],_y:r[1],_z:r[2],_w:r[3]},{x:1,y:1,z:1}),void 0===i){e.boundingBox||e.computeBoundingBox();let t=e.boundingBox;i=Math.max(t.max.x-t.min.x,t.max.y-t.min.y,t.max.z-t.min.z)}let o=new t.Box3(new t.Vector3(-i/2,-i/2,-i/2),new t.Vector3(i/2,i/2,i/2)),c=[];c.length=2*e.attributes.position.count,void 0===e.attributes.uv&&e.setAttribute("uv",new t.Float32BufferAttribute(c,2));let h,l,b,d,u,f=function(e,a,i){e.applyMatrix4(n),a.applyMatrix4(n),i.applyMatrix4(n);let s=1/(2*Math.PI),r=1/Math.PI;return e.normalize(),a.normalize(),i.normalize(),{uv0:new t.Vector2(.5-Math.atan(e.z,-e.x)*s,.5-Math.asin(e.y)*r),uv1:new t.Vector2(.5-Math.atan(a.z,-a.x)*s,.5-Math.asin(a.y)*r),uv2:new t.Vector2(.5-Math.atan(i.z,-i.x)*s,.5-Math.asin(i.y)*r)}},m=function(e,a,s){e.applyMatrix4(n),a.applyMatrix4(n),s.applyMatrix4(n);let r=new t.Vector3;r.crossVectors(a.clone().sub(e),a.clone().sub(s)).normalize(),r.x<0||r.y<0||r.z,r.x=Math.abs(r.x),r.y=Math.abs(r.y),r.z=Math.abs(r.z);let c=new t.Vector2,h=new t.Vector2,l=new t.Vector2,b=1/i;return r.y>r.x&&r.y>r.z?(c.set(e.x-o.min.x,o.max.z-e.z).multiplyScalar(b),h.set(a.x-o.min.x,o.max.z-a.z).multiplyScalar(b),l.set(s.x-o.min.x,o.max.z-s.z).multiplyScalar(b)):r.x>r.y&&r.x>r.z?(c.set(e.z-o.min.z,e.y-o.min.y).multiplyScalar(b),h.set(a.z-o.min.z,a.y-o.min.y).multiplyScalar(b),l.set(s.z-o.min.z,s.y-o.min.y).multiplyScalar(b)):r.z>r.y&&r.z>r.x&&(c.set(e.x-o.min.x,e.y-o.min.y).multiplyScalar(b),h.set(a.x-o.min.x,a.y-o.min.y).multiplyScalar(b),l.set(s.x-o.min.x,s.y-o.min.y).multiplyScalar(b)),{uv0:c,uv1:h,uv2:l}},p=new t.Vector3,g=new t.Vector3,y=new t.Vector3;new t.Vector3,new t.Vector3,new t.Vector3;const x=e.getAttribute("position");if(e.getAttribute("normal"),e.index)for(h=0;h<e.index.count;h+=3)l=e.index.getX(h+0),b=e.index.getX(h+1),d=e.index.getX(h+2),p.fromBufferAttribute(x,l),g.fromBufferAttribute(x,b),y.fromBufferAttribute(x,d),u="sphere"===a?f(p,g,y):m(p,g,y),c[2*l]=u.uv0.x,c[2*l+1]=u.uv0.y,c[2*b]=u.uv1.x,c[2*b+1]=u.uv1.y,c[2*d]=u.uv2.x,c[2*d+1]=u.uv2.y;else for(h=0;h<x.count;h+=3){p.fromBufferAttribute(x,h+0),g.fromBufferAttribute(x,h+1),y.fromBufferAttribute(x,h+2),u="sphere"===a?f(p,g,y):m(p,g,y);let e=h,t=h+1,i=h+2;c[2*e]=u.uv0.x,c[2*e+1]=u.uv0.y,c[2*t]=u.uv1.x,c[2*t+1]=u.uv1.y,c[2*i]=u.uv2.x,c[2*i+1]=u.uv2.y}e.attributes.uv.array=new Float32Array(c),e.attributes.uv.needsUpdate=!0}let U=class{constructor(){this.geoN=0,this.geo={}}unic(e){this.geo["geo"+this.geoN++]=e}set(e){this.geo[e.name]=e}get(e,a={}){if(!this.geo[e]){let a;switch(e){case"plane":a=new t.PlaneGeometry(1,1),a.rotateX(.5*-Math.PI);break;case"box":a=new t.BoxGeometry(1,1,1);break;case"sphere":a=new t.SphereGeometry(1,16,12);break;case"highSphere":a=new L(1);break;case"cylinder":a=new t.CylinderGeometry(1,1,1,16);break;case"cone":a=new t.CylinderGeometry(.001,1,1,16);break;case"particle":a=new t.SphereGeometry(1,6,4);break;case"joint":a=(new D).geometry;break;default:return null}this.geo[e]=a}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 K{constructor(e,a="rgb(69,69,69)",i="rgb(39,39,39)"){const s=document.createElement("canvas");s.width=s.height=128;const r=s.getContext("2d");if(r.fillStyle=a,r.fillRect(0,0,128,128),e){let t,s,n,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)":a,b=e?"rgb(160,100,255)":i,d=e?"rgba(100,160,255, 0.5)":"rgba(0,0,0, 0.1)";for(r.strokeStyle=d,r.lineWidth=1,t=0;t<5;t++){o=r.createLinearGradient(0,h[t][0],0,h[t][1]),o.addColorStop(0,b),o.addColorStop(1,l),r.beginPath(),r.fillStyle=o,r.rect(c[t][0],c[t][1],32,64),r.fill();for(let e=0;e<8;e++)n=2*(Math.random()-.5),r.beginPath(),r.moveTo(c[t][0]+n+2+4*e,c[t][1]),r.lineTo(c[t][0]+n+2+4*e,c[t][1]+64),r.stroke()}for(c=[[32,0],[64,32],[96,64],[-32,64],[0,96]],h=[[32,96],[64,128],[96,160],[-32,32],[0,64]],t=0;t<5;t++)for(o=r.createLinearGradient(h[t][0],0,h[t][1],0),o.addColorStop(0,l),o.addColorStop(1,b),r.beginPath(),r.fillStyle=o,r.rect(c[t][0],c[t][1],64,32),r.fill(),s=0;s<8;s++)n=2*(Math.random()-.5),r.beginPath(),r.moveTo(c[t][0],c[t][1]+n+2+4*s),r.lineTo(c[t][0]+64,c[t][1]+n+2+4*s),r.stroke()}else r.beginPath(),r.fillStyle=i,r.rect(0,0,32,64),r.rect(32,32,32,64),r.rect(64,64,32,64),r.rect(96,96,32,64),r.rect(96,-32,32,64),r.fill();const n=new t.CanvasTexture(s);return n.wrapS=n.wrapT=t.RepeatWrapping,n.repeat.x=n.repeat.y=60,e||(n.colorSpace=t.SRGBColorSpace),n}}class J extends t.MeshPhysicalMaterial{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:"",SUBSURFACE:"",USE_UV:""},this.extra={},this.addParametre("sssMap",null),this.addParametre("sssColor",new t.Color(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 a=this;a.onBeforeCompile=function(e){for(let t in a.extra)e.uniforms[t]={value:a.extra[t]};e.fragmentShader=e.fragmentShader.replace("#include <common>",W.common),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_begin>",a.replaceAll(X,"RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );",W.light)),a.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 W={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"},X="\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",Q={metalness:.1,roughness:.9},Y={grey:new t.Color(.18,.18,.18),black:new t.Color(.039,.039,.039),body:new t.Color(13289155),sleep:new t.Color("hsl(33, 15%, 54%)"),solid:new t.Color(7105128),base:new t.Color(13224135),brick:new t.Color(.262,.095,.061),sand:new t.Color(.44,.386,.231),gold:new t.Color(.944,.776,.373),gold2:new t.Color(.998,.981,.751),titanium:new t.Color(.633,.578,.503),titaniumSpec:new t.Color(.728,.68,.55),chrome:new t.Color(.653,.65,.615),chromeSpec:new t.Color(.675,.72,.711),copper:new t.Color(.988,.688,.448),carPaint:new t.Color(.1037792,.59212029,.85064936),clay:new t.Color("hsl(12, 30%, 40%)"),clayWhite:new t.Color(11119017),concrete:new t.Color(.51,.51,.51),Raw_Fire:new t.Color("hsl(40, 18%, 54%)"),Raw_Buff:new t.Color("hsl(33, 15%, 54%)"),Raw_Terracotta:new t.Color("hsl(12, 30%, 40%)"),Raw_Porcelain:new t.Color("hsl(45, 15%, 90%)")},Z={No:t.NoBlending,Normal:t.NormalBlending,Additive:t.AdditiveBlending,Subtractive:t.SubtractiveBlending,Multiply:t.MultiplyBlending,Eadd:t.AddEquation,Esub:t.SubtractEquation,Erev:t.ReverseSubtractEquation,Emin:t.MinEquation,Emaw:t.MaxEquation,Fzero:t.ZeroFactor,Fone:t.OneFactor,Fcolor:t.SrcColorFactor,Fcolorm:t.OneMinusSrcColorFactor,Falpha:t.SrcAlphaFactor,Falpham:t.OneMinusSrcAlphaFactor,Fdstalpha:t.DstAlphaFactor,Fdstalpham:t.OneMinusDstAlphaFactor,Fdstcolor:t.DstColorFactor,Fdstcolorm:t.OneMinusDstColorFactor,Falphasaturate:t.SrcAlphaSaturateFactor,Front:t.FrontSide,Back:t.BackSide,Double:t.DoubleSide};let $=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 a,i=null;if(e.isMaterial)a=e;else{let s=void 0!==e.type?e.type:"Standard";switch(e.type&&delete e.type,i=e.beforeCompile||null,e.beforeCompile&&delete e.beforeCompile,(e.thickness||e.sheen||e.clearcoat||e.transmission||e.specularColor)&&(s="Physical"),e.normalScale&&(e.normalScale.isVector2||(e.normalScale=(new t.Vector2).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 t.Vector2).fromArray(e.clearcoatNormalScale))),s=s.toLowerCase(),s){case"physical":a=new t.MeshPhysicalMaterial(e);break;case"phong":a=new t.MeshPhongMaterial(e);break;case"lambert":a=new t.MeshLambertMaterial(e);break;case"basic":a=new t.MeshBasicMaterial(e);break;case"line":a=new t.LineBasicMaterial(e);break;case"toon":a=new t.MeshToonMaterial(e);break;case"shadow":a=new t.ShadowMaterial(e);break;case"sss":a=new J(e);break;default:a=new t.MeshStandardMaterial(e)}}return this.mat[a.name]?null:(this.set(a,!1,i),a)}findValue(e){return"string"===e?Z[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:Y.grey,metalness:0,roughness:.5});break;case"black":this.create({name:"black",color:Y.black,metalness:0,roughness:.5});break;case"body":this.create({name:"body",color:Y.body,...Q});break;case"sleep":this.create({name:"sleep",color:Y.sleep,...Q});break;case"solid":this.create({name:"solid",color:Y.solid,...Q});break;case"base":this.create({name:"base",color:Y.base,...Q});break;case"clay":this.create({name:"clay",color:Y.clay,metalness:.1,roughness:.7});break;case"clayWhite":this.create({name:"clayWhite",color:Y.clayWhite,metalness:.1,roughness:.7});break;case"concrete":this.create({name:"concrete",color:Y.concrete,metalness:0,roughness:.9});break;case"brick":this.create({name:"brick",color:Y.brick,metalness:0,roughness:.6});break;case"sand":this.create({name:"sand",color:Y.sand,metalness:0,roughness:.9});break;case"chrome":this.create({name:"chrome",color:Y.chrome,specularColor:Y.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:Y.gold,specularColor:Y.gold2,metalness:1,roughness:.02});break;case"copper":this.create({name:"copper",color:Y.copper,metalness:1,roughness:.05});break;case"titanium":this.create({name:"titanium",color:Y.titanium,metalness:1,roughness:0,specularColor:Y.titaniumSpec});break;case"carPaint":this.create({name:"carPaint",color:Y.carPaint,metalness:0,anisotropy:new t.Vector2(.5,.5),roughness:.4,clearcoat:1,clearcoatRoughness:0});break;case"carbon":this.create({name:"carbon",map:new K,normalMap:new K(!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:t.DoubleSide,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:t.DoubleSide,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:t.AdditiveBlending,color:65793,transparent:!0,opacity:.7,reflectivity:.3,metalness:.6,roughness:.1,clearcoat:.2,clearcoatRoughness:.02,side:t.DoubleSide,alphaToCoverage:!0,premultipliedAlpha:!0});break;case"plexi2":this.create({name:"plexi2",blending:t.AdditiveBlending,color:65793,transparent:!1,opacity:.7,reflectivity:.3,metalness:.6,roughness:.1,clearcoat:.2,clearcoatRoughness:.02,side:t.DoubleSide,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:t.BackSide,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,...Q});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:t.DoubleSide})}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 ee{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 te{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 ae(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 ae{constructor(e){this.values=[],this.ready=0,this.key=e}update(){var e,t,a,i,s,r,n=this.fix,o=navigator.getGamepads();for(e=0;e<o.length;e++)if(r=o[e])if(a=r.axes.length,i=r.buttons.length){for(this.values[e]||(this.values[e]=[]),t=0;t<a;t++)s=n(r.axes[t],.08),0==this.ready&&0!==s&&(this.ready=1),this.values[e][t]=s;for(t=0;t<i;t++)s=n(r.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 ie{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 se extends ie{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*B.ray,a.update(e,i,this.motor.reflow.ray[s]||null)}add(e={}){this.setName(e);let t=new re(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 re extends t.Line{constructor(e={},a){super(new t.BufferGeometry,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 t.Vector3,this.end=new t.Vector3(0,1,0),this.tmp=new t.Vector3,this.vnormal=new t.Vector3,this.vv1=new t.Vector3,this.vv2=new t.Vector3,this.fullDistance=0,this.setRay(e);this.geometry.setAttribute("position",new t.Float32BufferAttribute([0,0,0,0,0,0,0,0,0],3)),this.geometry.setAttribute("color",new t.Float32BufferAttribute([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 t.Matrix4,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+