UNPKG

phy-engine

Version:

JavaScript 3D Physics for three.js

3 lines 9.82 MB
const A=new Map,I=new Map,g=new Map,C={Ar:null,ArPos:{},needTrigger:!1,needContact:!1,byName:null,world:null,scene:null,gravity:null,ccd:!1,cooking:null,cookingParams:null,tolerances:null,defaultMaterial:null,bodyRef:null,garbage:[],delta:0,ms:0,substep:1,tmpStep:0,restitution:0,pv:3,setFilter:null,setFilterData:null,getAggregate:null,key:[],reflow:{ray:[],point:{},contact:{},velocity:{},stat:{fps:0,delta:0,ms:0}},aggregates:{}},B={solverAxis:null,D6Axis:null,HEAPU8:Uint8Array,clear:()=>{A.clear(),I.clear(),g.clear()},byName:I=>A.has(I)?A.get(I):null,byPtr:A=>I.has(A)?I.get(A):null,byContact:A=>g.has(A),clearContact:()=>{g.clear()},addContact:(A,I={})=>{B.byContact(A)||g.set(A,I)},removeContact:A=>{B.byContact(A)&&g.delete(A)},add:(g,B)=>{switch(g.type){case"body":case"solid":null!==g.aggregate?g.aggregate.addActor(g,B):g.isBone||C.scene.addActor(g,B),I.set(g.ptr,g.name)}A.set(g.name,g)},remove:g=>{if("ray"!==g.type&&"contact"!==g.type)switch(g.type){case"joint":case"solver":case"vehicle":case"terrain":g.release();break;default:g.isBone||(null!==g.aggregate?g.aggregate.removeActor(g):C.scene.removeActor(g),I.delete(g.ptr),g.release())}A.delete(g.name)},stats:()=>{},mallocBase:(A,I)=>{const g=A.length*A.BYTES_PER_ELEMENT;return void 0===I&&(I=PhysX._webidl_malloc(g)),new Uint8Array(PhysX.HEAPU8.buffer,I,g).set(new Uint8Array(A.buffer)),I},malloc:(A,I)=>{const g=A.length,C=g*A.BYTES_PER_ELEMENT;void 0===I&&(I=PhysX._webidl_malloc(C));const B=new Float32Array(PhysX.HEAPU8.buffer,I,g);for(let I=0;I<g;I++)B[I]=A[I];return B.byteOffset},mallocIndex:(A,I=!1)=>{const g=A.length,C=g/3,B=g*A.BYTES_PER_ELEMENT,Q=PhysX._webidl_malloc(B),i=new Int32Array(PhysX.HEAPU8.buffer,Q,g);let e,E=C,o=0;for(;E--;)e=3*o,I?(i[e+0]=A[e+2],i[e+1]=A[e+1],i[e+2]=A[e+0]):(i[e+0]=A[e+0],i[e+1]=A[e+1],i[e+2]=A[e+2]),o++;return i.byteOffset},free:A=>{A&&PhysX._webidl_free(A)},extends:()=>{B.cookingPreProcess={eWELD_VERTICES:PhysX._emscripten_enum_PxMeshPreprocessingFlagEnum_eWELD_VERTICES(),eDISABLE_CLEAN_MESH:PhysX._emscripten_enum_PxMeshPreprocessingFlagEnum_eDISABLE_CLEAN_MESH(),eDISABLE_ACTIVE_EDGES_PRECOMPUTE:PhysX._emscripten_enum_PxMeshPreprocessingFlagEnum_eDISABLE_ACTIVE_EDGES_PRECOMPUTE(),eFORCE_32BIT_INDICES:PhysX._emscripten_enum_PxMeshPreprocessingFlagEnum_eFORCE_32BIT_INDICES()},B.HitFlag={ePOSITION:PhysX._emscripten_enum_PxHitFlagEnum_ePOSITION(),eNORMAL:PhysX._emscripten_enum_PxHitFlagEnum_eNORMAL(),eUV:PhysX._emscripten_enum_PxHitFlagEnum_eUV(),eASSUME_NO_INITIAL_OVERLAP:PhysX._emscripten_enum_PxHitFlagEnum_eASSUME_NO_INITIAL_OVERLAP(),eMESH_MULTIPLE:PhysX._emscripten_enum_PxHitFlagEnum_eMESH_MULTIPLE(),eMESH_BOTH_SIDES:PhysX._emscripten_enum_PxHitFlagEnum_eMESH_BOTH_SIDES(),ePRECISE_SWEEP:PhysX._emscripten_enum_PxHitFlagEnum_ePRECISE_SWEEP(),eMTD:PhysX._emscripten_enum_PxHitFlagEnum_eMTD(),eFACE_INDEX:PhysX._emscripten_enum_PxHitFlagEnum_eFACE_INDEX(),eDEFAULT:PhysX._emscripten_enum_PxHitFlagEnum_eDEFAULT(),eMODIFIABLE_FLAGS:PhysX._emscripten_enum_PxHitFlagEnum_eMODIFIABLE_FLAGS()},B.QueryFlag={eSTATIC:PhysX._emscripten_enum_PxQueryFlagEnum_eSTATIC(),eDYNAMIC:PhysX._emscripten_enum_PxQueryFlagEnum_eDYNAMIC(),ePREFILTER:PhysX._emscripten_enum_PxQueryFlagEnum_ePREFILTER(),ePOSTFILTER:PhysX._emscripten_enum_PxQueryFlagEnum_ePOSTFILTER(),eANY_HIT:PhysX._emscripten_enum_PxQueryFlagEnum_eANY_HIT(),eNO_BLOCK:PhysX._emscripten_enum_PxQueryFlagEnum_eNO_BLOCK()},B.ForceMode={force:PhysX._emscripten_enum_PxForceModeEnum_eFORCE(),impulse:PhysX._emscripten_enum_PxForceModeEnum_eIMPULSE(),velocity:PhysX._emscripten_enum_PxForceModeEnum_eVELOCITY_CHANGE(),acceleration:PhysX._emscripten_enum_PxForceModeEnum_eACCELERATION()},B.solverAxis={x:PhysX._emscripten_enum_PxArticulationAxisEnum_eX(),y:PhysX._emscripten_enum_PxArticulationAxisEnum_eY(),z:PhysX._emscripten_enum_PxArticulationAxisEnum_eZ(),rx:PhysX._emscripten_enum_PxArticulationAxisEnum_eTWIST(),ry:PhysX._emscripten_enum_PxArticulationAxisEnum_eSWING1(),rz:PhysX._emscripten_enum_PxArticulationAxisEnum_eSWING2(),twist:PhysX._emscripten_enum_PxArticulationAxisEnum_eTWIST(),swing1:PhysX._emscripten_enum_PxArticulationAxisEnum_eSWING1(),swing2:PhysX._emscripten_enum_PxArticulationAxisEnum_eSWING2()},B.D6Axis={x:PhysX._emscripten_enum_PxD6AxisEnum_eX(),y:PhysX._emscripten_enum_PxD6AxisEnum_eY(),z:PhysX._emscripten_enum_PxD6AxisEnum_eZ(),rx:PhysX._emscripten_enum_PxD6AxisEnum_eTWIST(),ry:PhysX._emscripten_enum_PxD6AxisEnum_eSWING1(),rz:PhysX._emscripten_enum_PxD6AxisEnum_eSWING2(),twist:PhysX._emscripten_enum_PxD6AxisEnum_eTWIST(),swing1:PhysX._emscripten_enum_PxD6AxisEnum_eSWING1(),swing2:PhysX._emscripten_enum_PxD6AxisEnum_eSWING2()},B.CacheFlag={velocity:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eVELOCITY(),acceleration:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eACCELERATION(),position:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_ePOSITION(),force:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eFORCE(),velocity:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eLINK_VELOCITY(),link_acceleration:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eLINK_ACCELERATION(),root_transform:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eROOT_TRANSFORM(),root_velocity:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eROOT_VELOCITIES(),joint_force:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eLINK_INCOMING_JOINT_FORCE(),joint_target_position:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eJOINT_TARGET_POSITIONS(),joint_target_velocity:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eJOINT_TARGET_VELOCITIES(),all:PhysX._emscripten_enum_PxArticulationCacheFlagEnum_eALL()},B.PairFlag={SOLVE_CONTACT:PhysX._emscripten_enum_PxPairFlagEnum_eSOLVE_CONTACT(),MODIFY_CONTACTS:PhysX._emscripten_enum_PxPairFlagEnum_eMODIFY_CONTACTS(),NOTIFY_TOUCH_FOUND:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_TOUCH_FOUND(),NOTIFY_TOUCH_PERSISTS:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_TOUCH_PERSISTS(),NOTIFY_TOUCH_LOST:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_TOUCH_LOST(),NOTIFY_TOUCH_CCD:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_TOUCH_CCD(),NOTIFY_THRESHOLD_FORCE_FOUND:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_THRESHOLD_FORCE_FOUND(),NOTIFY_THRESHOLD_FORCE_PERSISTS:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_THRESHOLD_FORCE_PERSISTS(),NOTIFY_THRESHOLD_FORCE_LOST:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_THRESHOLD_FORCE_LOST(),NOTIFY_CONTACT_POINTS:PhysX._emscripten_enum_PxPairFlagEnum_eNOTIFY_CONTACT_POINTS(),DETECT_DISCRETE_CONTACT:PhysX._emscripten_enum_PxPairFlagEnum_eDETECT_DISCRETE_CONTACT(),DETECT_CCD_CONTACT:PhysX._emscripten_enum_PxPairFlagEnum_eDETECT_CCD_CONTACT(),PRE_SOLVER_VELOCITY:PhysX._emscripten_enum_PxPairFlagEnum_ePRE_SOLVER_VELOCITY(),POST_SOLVER_VELOCITY:PhysX._emscripten_enum_PxPairFlagEnum_ePOST_SOLVER_VELOCITY(),CONTACT_EVENT_POSE:PhysX._emscripten_enum_PxPairFlagEnum_eCONTACT_EVENT_POSE(),NEXT_FREE:PhysX._emscripten_enum_PxPairFlagEnum_eNEXT_FREE(),CONTACT_DEFAULT:PhysX._emscripten_enum_PxPairFlagEnum_eCONTACT_DEFAULT(),TRIGGER_DEFAULT:PhysX._emscripten_enum_PxPairFlagEnum_eTRIGGER_DEFAULT()},PhysX.PxVec3.prototype.set=function(A,I,g){return this.x=A,this.y=I,this.z=g,this},PhysX.PxVec3.prototype.toArray=function(A,I){let g=void 0!==A;if(g||(A=[]),A[I=I||0]=this.x,A[I+1]=this.y,A[I+2]=this.z,!g)return A},PhysX.PxVec3.prototype.multiplyScalar=function(A){return this.x*=A,this.y*=A,this.z*=A,this},PhysX.PxVec3.prototype.divideScalar=function(A){return this.multiplyScalar(1/A)},PhysX.PxVec3.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},PhysX.PxVec3.prototype.normalize=function(){return this.divideScalar(this.length()||1)},PhysX.PxVec3.prototype.directionVector=function(A){const I=b.x-this.x,g=b.y-this.y,C=b.z-this.z;return Math.sqrt(I*I+g*g+C*C)},PhysX.PxVec3.prototype.distanceTo=function(A){const I=this.x-A.x,g=this.y-A.y,C=this.z-A.z;return Math.sqrt(I*I+g*g+C*C)},PhysX.PxVec3.prototype.op_sub=function(A){return this.set(this.x-A.x,this.y-A.y,this.z-A.z),this},PhysX.PxVec3.prototype.fromArray=function(A,I){return I=I||0,this.set(A[I],A[I+1],A[I+2]),this},PhysX.PxVec3.prototype.copy=function(A){return this.set(A.x,A.y,A.z),this},PhysX.PxVec3.prototype.dot=function(A){return this.x*A.x+this.y*A.y+this.z*A.z},PhysX.PxVec3.prototype.applyQuaternion=function(A){const I=this.x,g=this.y,C=this.z,B=A.x,Q=A.y,i=A.z,e=A.w,E=e*I+Q*C-i*g,o=e*g+i*I-B*C,t=e*C+B*g-Q*I,s=-B*I-Q*g-i*C;return this.x=E*e+s*-B+o*-i-t*-Q,this.y=o*e+s*-Q+t*-B-E*-i,this.z=t*e+s*-i+E*-Q-o*-B,this},PhysX.PxVec3.prototype.applyMatrix3=function(A){const I=this.x,g=this.y,C=this.z,B=A.getBasis();return this.x=B[0]*I+B[3]*g+B[6]*C,this.y=B[1]*I+B[4]*g+B[7]*C,this.z=B[2]*I+B[5]*g+B[8]*C,this},PhysX.PxVec3.prototype.lerp=function(A,I){return this.x+=(A.x-this.x)*I,this.y+=(A.y-this.y)*I,this.z+=(A.z-this.z)*I,this},PhysX.PxVec3.prototype.free=function(){PhysX.destroy(this)},PhysX.PxQuat.prototype.identity=function(){return this.set(0,0,0,1)},PhysX.PxQuat.prototype.set=function(A,I,g,C){return this.x=A,this.y=I,this.z=g,this.w=C,this},PhysX.PxQuat.prototype.toArray=function(A,I){let g=void 0!==A;if(g||(A=[]),A[I=I||0]=this.x,A[I+1]=this.y,A[I+2]=this.z,A[I+3]=this.w,!g)return A},PhysX.PxQuat.prototype.multiplyQuaternions=function(A,I){const g=A.x,C=A.y,B=A.z,Q=A.w,i=I.x,e=I.y,E=I.z,o=I.w;return this.x=g*o+Q*i+C*E-B*e,this.y=C*o+Q*e+B*i-g*E,this.z=B*o+Q*E+g*e-C*i,this.w=Q*o-g*i-C*e-B*E,this},PhysX.PxQuat.prototype.premultiply=function(A){return this.multiplyQuaternions(A,this)},PhysX.PxQuat.prototype.multiply=function(A){return this.multiplyQuaternions(this,A)},PhysX.PxQuat.prototype.fromArray=function(A,I){return I=I||0,this.set(A[I],A[I+1],A[I+2],A[I+3]),this},PhysX.PxQuat.prototype.fromAxisAngle=function(A,I){const g=.5*I,C=Math.sin(g);return this.x=A[0]*C,this.y=A[1]*C,this.z=A[2]*C,this.w=Math.cos(g),this},PhysX.PxQuat.prototype.fromAxis=function(A){let I=A.toArray();if(I[2]>.99999)this.set(0,0,0,1);else if(I[2]<-.99999)this.set(1,0,0,0);else{let A=[I[1],I[0],0],g=Math.acos(I[2]);this.fromAxisAngle(A,g)}return this},PhysX.PxQuat.prototype.setFromRotationMatrix=function(A){const I=A[0],g=A[4],C=A[8],B=A[1],Q=A[5],i=A[9],e=A[2],E=A[6],o=A[10],t=I+Q+o;if(t>0){const A=.5/Math.sqrt(t+1);this.w=.25/A,this.x=(E-i)*A,this.y=(C-e)*A,this.z=(B-g)*A}else if(I>Q&&I>o){const A=2*Math.sqrt(1+I-Q-o);this.w=(E-i)/A,this.x=.25*A,this.y=(g+B)/A,this.z=(C+e)/A}else if(Q>o){const A=2*Math.sqrt(1+Q-I-o);this.w=(C-e)/A,this.x=(g+B)/A,this.y=.25*A,this.z=(i+E)/A}else{const A=2*Math.sqrt(1+o-I-Q);this.w=(B-g)/A,this.x=(C+e)/A,this.y=(i+E)/A,this.z=.25*A}return this},PhysX.PxQuat.prototype.free=function(){PhysX.destroy(this)},PhysX.PxTransform.prototype.set=function(A,I){return this.p=A,this.q=I,this},PhysX.PxTransform.prototype.identity=function(){return this.p.fromArray([0,0,0]),this.q.fromArray([0,0,0,1]),this},PhysX.PxTransform.prototype.fromArray=function(A,I,g,C){return this.p.fromArray(A||[0,0,0],g||0),this.q.fromArray(I||[0,0,0,1],C||0),this},PhysX.PxTransform.prototype.multiply=function(A){const I=this.getElements(),g=A.getElements(),C=[],B=I[0],Q=I[4],i=I[8],e=I[12],E=I[1],o=I[5],t=I[9],s=I[13],_=I[2],D=I[6],n=I[10],a=I[14],r=I[3],c=I[7],S=I[11],p=I[15],h=g[0],l=g[4],y=g[8],G=g[12],k=g[1],F=g[5],J=g[9],K=g[13],U=g[2],d=g[6],m=g[10],w=g[14],R=g[3],N=g[7],M=g[11],Y=g[15];return C[0]=B*h+Q*k+i*U+e*R,C[4]=B*l+Q*F+i*d+e*N,C[8]=B*y+Q*J+i*m+e*M,C[12]=B*G+Q*K+i*w+e*Y,C[1]=E*h+o*k+t*U+s*R,C[5]=E*l+o*F+t*d+s*N,C[9]=E*y+o*J+t*m+s*M,C[13]=E*G+o*K+t*w+s*Y,C[2]=_*h+D*k+n*U+a*R,C[6]=_*l+D*F+n*d+a*N,C[10]=_*y+D*J+n*m+a*M,C[14]=_*G+D*K+n*w+a*Y,C[3]=r*h+c*k+S*U+p*R,C[7]=r*l+c*F+S*d+p*N,C[11]=r*y+c*J+S*m+p*M,C[15]=r*G+c*K+S*w+p*Y,this.decompose(C)},PhysX.PxTransform.prototype.decompose=function(A){return this.p.set(A[12],A[13],A[14]),this.q.setFromRotationMatrix(A),this},PhysX.PxTransform.prototype.getElements=function(A,I,g){const C=[];A=A||this.p,g=g||{x:1,y:1,z:1};const B=(I=I||this.q).x,Q=I.y,i=I.z,e=I.w,E=B+B,o=Q+Q,t=i+i,s=B*E,_=B*o,D=B*t,n=Q*o,a=Q*t,r=i*t,c=e*E,S=e*o,p=e*t,h=g.x,l=g.y,y=g.z;return C[0]=(1-(n+r))*h,C[1]=(_+p)*h,C[2]=(D-S)*h,C[3]=0,C[4]=(_-p)*l,C[5]=(1-(s+r))*l,C[6]=(a+c)*l,C[7]=0,C[8]=(D+S)*y,C[9]=(a-c)*y,C[10]=(1-(s+n))*y,C[11]=0,C[12]=A.x,C[13]=A.y,C[14]=A.z,C[15]=1,C},PhysX.PxTransform.prototype.getBasis=function(){let A=this.getElements();return[A[0],A[4],A[8],A[1],A[5],A[9],A[2],A[6],A[10]]},PhysX.PxTransform.prototype.toArray=function(A,I){I=I||0,this.p.toArray(A,I),this.q.toArray(A,I+3)},PhysX.PxTransform.prototype.copy=function(A){return this.p=A.p,this.q=A.q,this},PhysX.PxTransform.prototype.rotationFromAxis=function(A){return this.q.fromAxis(A),this},PhysX.PxTransform.prototype.free=function(){PhysX.destroy(this)},PhysX.PxTransform.prototype.clone=function(){return(new PhysX.PxTransform).copy(this)}}},Q=4e3,i=1e3,e=4e3,E=100,o=100,t=50,s=20,_={bodyFull:14,body:8,joint:16,contact:1,ray:11,character:16,vehicle:72,solver:128};class D{constructor(){this.id=0,this.list=[],this.type="item",this.Utils=null}reset(){let A=this.list.length;for(;A--;)this.dispose(this.list[A]);this.list=[],this.id=0}byName(A){return this.Utils.byName(A)}setName(A={}){let I=void 0!==A.name?A.name:this.type+this.id++;return A.id=this.remove(I,!0),A.name=I,I}addToWorld(A,I=-1){this.Utils.add(A),-1!==I?this.list[I]=A:this.list.push(A)}remove(A,I){let g=this.byName(A);return g?this.clear(g,I):-1}clear(A,I){let g=this.list.indexOf(A);return-1===g||I?this.list[g]=null:this.list.splice(g,1),this.dispose(A),g}dispose(A){null!==A&&this.Utils.remove(A)}add(A={}){}set(A={}){}step(A,I){}}const n=3.141592653589793,a=n/180,r=180/n,c=Number.MAX_SAFE_INTEGER,S=Number.EPSILON,p=.5*n,h={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:A=>Math.pow(A,5),candelaToLumens:A=>4*A*Math.PI,lumensToCandela:A=>A/(4*Math.PI),average:A=>A?.reduce(((A,I)=>A+I),0)/A.length,atan2:(A,I)=>Math.fround(Math.atan2(A,I)),pow:(A,I)=>Math.fround(Math.pow(A,I)),sin:A=>Math.fround(Math.sin(A)),cos:A=>Math.fround(Math.cos(A)),sqrt:A=>Math.fround(Math.sqrt(A)),exp:A=>Math.fround(Math.exp(A)),todeg:r,torad:a,toFixed:(A,I=3)=>1*A.toFixed(I),toRound:(A,I=3)=>Math.trunc(A),clamp:(A,I=0,g=1)=>A<I?I:A>g?g:A,min:(A,I)=>A<I?A:I,max:(A,I)=>A>I?A:I,lerp:(A,I,g)=>(1-g)*A+g*I,sign:A=>A>0?1:A<0?-1:0,fast_negexp:A=>1/(1+A+.48*A*A+.235*A*A*A),fast_atan:A=>{let I=Math.abs(A),g=I>1?1/I:I,C=n/4*g-g*(g-1)*(.2447+.0663*g);return copysign(I>1?n/2-C:C,A)},clampA:(A,I,g)=>Math.max(I,Math.min(g,A)),smoothstep:(A,I,g)=>A*(g=-2*(g=h.clamp(g))*g*g+3*g*g)+I*(1-g),remap:(A,I,g,C,B)=>C+(A-I)*(B-C)/(g-I),damp:(A,I,g,C)=>h.lerp(A,I,1-Math.exp(-g*C)),nearAngle:(A,I,g=!1)=>I+Math.atan2(Math.sin(A-I),Math.cos(A-I))*(g?r:1),unwrapDeg:A=>A-360*Math.floor((A+180)/360),unwrapRad:A=>Math.atan2(Math.sin(A),Math.cos(A)),nearEquals:(A,I,g=1e-4)=>Math.abs(A-I)<=g,autoSize:(A=[1,1,1],I="box")=>{1===A.length&&(A[1]=A[0]);let g=A[0],C=A[1];return"sphere"===I&&(A=[g,g,g]),"cylinder"!==I&&"wheel"!==I&&"capsule"!==I||(A=[g,C,g]),"cone"!==I&&"pyramid"!==I||(A=[g,C,g]),2===A.length&&(A[2]=A[0]),A},shuffle:A=>A.map((A=>({value:A,sort:Math.random()}))).sort(((A,I)=>A.sort-I.sort)).map((({value:A})=>A)),randomSign:()=>Math.random()<.5?-1:1,randSpread:A=>A*(.5-Math.random()),rand:(A=0,I=1)=>A+Math.random()*(I-A),randInt:(A,I)=>A+Math.floor(Math.random()*(I-A+1)),randIntUnic:(A,I,g)=>{for(var C=[];C.length<g;){var B=h.randInt(A,I);-1===C.indexOf(B)&&C.push(B)}return C},fromTransform:(A,I,g,C=[0,0,0,1],B=!1)=>{let Q=h.composeMatrixArray(A,I),i=h.composeMatrixArray(g,C);return B&&(Q=h.invertMatrixArray(Q)),Q=h.multiplyMatrixArray(Q,i),[Q[12],Q[13],Q[14]]},fromTransformToQ:(A,I,g=!1)=>{let C=h.composeMatrixArray(A,I),B=h.decomposeFullMatrixArray(C).q;return g&&(B=h.quatInvert(B)),B},lerpTransform:(A,I,g)=>{let C=A[0],B=A[1],Q=I[0],i=I[1];return Q=h.lerpArray(C,Q,g),i=h.slerpQuatArray(B,i,g),[Q,i]},composeMatrixArray:(A,I,g=[1,1,1])=>{const C=I[0],B=I[1],Q=I[2],i=I[3],e=C+C,E=B+B,o=Q+Q,t=C*e,s=C*E,_=C*o,D=B*E,n=B*o,a=Q*o,r=i*e,c=i*E,S=i*o,p=g[0],h=g[1],l=g[2];return[(1-(D+a))*p,(s+S)*p,(_-c)*p,0,(s-S)*h,(1-(t+a))*h,(n+r)*h,0,(_+c)*l,(n-r)*l,(1-(t+D))*l,0,A[0],A[1],A[2],1]},multiplyMatrixArray:(A,I)=>{const g=A,C=I,B=[],Q=g[0],i=g[4],e=g[8],E=g[12],o=g[1],t=g[5],s=g[9],_=g[13],D=g[2],n=g[6],a=g[10],r=g[14],c=g[3],S=g[7],p=g[11],h=g[15],l=C[0],y=C[4],G=C[8],k=C[12],F=C[1],J=C[5],K=C[9],U=C[13],d=C[2],m=C[6],w=C[10],R=C[14],N=C[3],M=C[7],Y=C[11],b=C[15];return B[0]=Q*l+i*F+e*d+E*N,B[4]=Q*y+i*J+e*m+E*M,B[8]=Q*G+i*K+e*w+E*Y,B[12]=Q*k+i*U+e*R+E*b,B[1]=o*l+t*F+s*d+_*N,B[5]=o*y+t*J+s*m+_*M,B[9]=o*G+t*K+s*w+_*Y,B[13]=o*k+t*U+s*R+_*b,B[2]=D*l+n*F+a*d+r*N,B[6]=D*y+n*J+a*m+r*M,B[10]=D*G+n*K+a*w+r*Y,B[14]=D*k+n*U+a*R+r*b,B[3]=c*l+S*F+p*d+h*N,B[7]=c*y+S*J+p*m+h*M,B[11]=c*G+S*K+p*w+h*Y,B[15]=c*k+S*U+p*R+h*b,B},invertMatrixArray:A=>{const I=A,g=I[0],C=I[1],B=I[2],Q=I[3],i=I[4],e=I[5],E=I[6],o=I[7],t=I[8],s=I[9],_=I[10],D=I[11],n=I[12],a=I[13],r=I[14],c=I[15],S=s*r*o-a*_*o+a*E*D-e*r*D-s*E*c+e*_*c,p=n*_*o-t*r*o-n*E*D+i*r*D+t*E*c-i*_*c,h=t*a*o-n*s*o+n*e*D-i*a*D-t*e*c+i*s*c,l=n*s*E-t*a*E-n*e*_+i*a*_+t*e*r-i*s*r,y=g*S+C*p+B*h+Q*l;if(0===y)return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];const G=1/y;return I[0]=S*G,I[1]=(a*_*Q-s*r*Q-a*B*D+C*r*D+s*B*c-C*_*c)*G,I[2]=(e*r*Q-a*E*Q+a*B*o-C*r*o-e*B*c+C*E*c)*G,I[3]=(s*E*Q-e*_*Q-s*B*o+C*_*o+e*B*D-C*E*D)*G,I[4]=p*G,I[5]=(t*r*Q-n*_*Q+n*B*D-g*r*D-t*B*c+g*_*c)*G,I[6]=(n*E*Q-i*r*Q-n*B*o+g*r*o+i*B*c-g*E*c)*G,I[7]=(i*_*Q-t*E*Q+t*B*o-g*_*o-i*B*D+g*E*D)*G,I[8]=h*G,I[9]=(n*s*Q-t*a*Q-n*C*D+g*a*D+t*C*c-g*s*c)*G,I[10]=(i*a*Q-n*e*Q+n*C*o-g*a*o-i*C*c+g*e*c)*G,I[11]=(t*e*Q-i*s*Q-t*C*o+g*s*o+i*C*D-g*e*D)*G,I[12]=l*G,I[13]=(t*a*B-n*s*B+n*C*_-g*a*_-t*C*r+g*s*r)*G,I[14]=(n*e*B-i*a*B-n*C*E+g*a*E+i*C*r-g*e*r)*G,I[15]=(i*s*B-t*e*B+t*C*E-g*s*E-i*C*_+g*e*_)*G,I},matrixArrayDeterminant:A=>{const I=A,g=I[0],C=I[4],B=I[8],Q=I[12],i=I[1],e=I[5],E=I[9],o=I[13],t=I[2],s=I[6],_=I[10],D=I[14];return I[3]*(+Q*E*s-B*o*s-Q*e*_+C*o*_+B*e*D-C*E*D)+I[7]*(+g*E*D-g*o*_+Q*i*_-B*i*D+B*o*t-Q*E*t)+I[11]*(+g*o*s-g*e*D-Q*i*s+C*i*D+Q*e*t-C*o*t)+I[15]*(-B*e*t-g*E*s+g*e*_+B*i*s-C*i*_+C*E*t)},decomposeMatrixArray:A=>[A[12],A[13],A[14]],decomposeFullMatrixArray:A=>{const I=A;let g=h.lengthArray([I[0],I[1],I[2]]);const C=h.lengthArray([I[4],I[5],I[6]]),B=h.lengthArray([I[8],I[9],I[10]]);h.matrixArrayDeterminant(A)<0&&(g=-g);let Q=[...A];const i=1/g,e=1/C,E=1/B;Q[0]*=i,Q[1]*=i,Q[2]*=i,Q[4]*=e,Q[5]*=e,Q[6]*=e,Q[8]*=E,Q[9]*=E,Q[10]*=E;let o=h.quatFromRotationMatrix(Q);return{p:[A[12],A[13],A[14]],q:o,s:[g,C,B]}},applyTransformArray:(A,I,g,C=[1,1,1])=>{const B=h.composeMatrixArray(I,g,C),Q=A[0],i=A[1],e=A[2],E=1/(B[3]*Q+B[7]*i+B[11]*e+B[15]);return[(B[0]*Q+B[4]*i+B[8]*e+B[12])*E,(B[1]*Q+B[5]*i+B[9]*e+B[13])*E,(B[2]*Q+B[6]*i+B[10]*e+B[14])*E]},slerpQuatArray:(A,I,g)=>{if(0===g)return A;if(1===g)return I;let C=[...A];const B=A[0],Q=A[1],i=A[2],e=A[3],E=I[0],o=I[1],t=I[2],s=I[3];let _=e*s+B*E+Q*o+i*t;if(_<0?(C=[-E,-o,-t,-s],_=-_):C=[...I],_>=1)return A;const D=1-_*_;if(D<=S){const A=1-g;return C[3]=A*e+g*C[3],C[0]=A*B+g*C[0],C[1]=A*Q+g*C[1],C[2]=A*i+g*C[2],h.quatNomalize(C)}const n=Math.sqrt(D),a=Math.atan2(n,_),r=Math.sin((1-g)*a)/n,c=Math.sin(g*a)/n;return C[3]=e*r+C[3]*c,C[0]=B*r+C[0]*c,C[1]=Q*r+C[1]*c,C[2]=i*r+C[2]*c,C},toLocalQuatArray:(A=[0,0,0],I)=>{let g=h.quatFromEuler(A),C=h.quatInvert(I.quaternion.toArray());return h.quatMultiply(C,g)},quatFromRotationMatrix:A=>{let I=[0,0,0,1];const g=A,C=g[0],B=g[4],Q=g[8],i=g[1],e=g[5],E=g[9],o=g[2],t=g[6],s=g[10],_=C+e+s;if(_>0){const A=.5/Math.sqrt(_+1);I[3]=.25/A,I[0]=(t-E)*A,I[1]=(Q-o)*A,I[2]=(i-B)*A}else if(C>e&&C>s){const A=2*Math.sqrt(1+C-e-s);I[3]=(t-E)/A,I[0]=.25*A,I[1]=(B+i)/A,I[2]=(Q+o)/A}else if(e>s){const A=2*Math.sqrt(1+e-C-s);I[3]=(Q-o)/A,I[0]=(B+i)/A,I[1]=.25*A,I[2]=(E+t)/A}else{const A=2*Math.sqrt(1+s-C-e);I[3]=(i-B)/A,I[0]=(Q+o)/A,I[1]=(E+t)/A,I[2]=.25*A}return I},quatFromEuler:(A=[0,0,0],I=!0)=>{const g=Math.cos,C=Math.sin,B=I?a:1,Q=A[0]*B*.5,i=A[1]*B*.5,e=A[2]*B*.5,E=g(Q),o=g(i),t=g(e),s=C(Q),_=C(i),D=C(e);return[s*o*t+E*_*D,E*_*t-s*o*D,E*o*D+s*_*t,E*o*t-s*_*D]},quatFromAxis:(A=[0,0,0],I,g=!0)=>{const C=.5*I*(g?a:1),B=Math.sin(C);return[A[0]*B,A[1]*B,A[2]*B,Math.cos(C)]},quatNomalize:A=>{let I=h.lengthArray(A);return 0===I?[0,0,0,1]:(I=1/I,h.scaleArray(A,I,4))},quatInvert:A=>[-A[0],-A[1],-A[2],A[3]],quatMultiply:(A,I)=>{const g=A[0],C=A[1],B=A[2],Q=A[3],i=I[0],e=I[1],E=I[2],o=I[3];return[g*o+Q*i+C*E-B*e,C*o+Q*e+B*i-g*E,B*o+Q*E+g*e-C*i,Q*o-g*i-C*e-B*E]},quatToAxis:A=>{let I=2*Math.acos(A[3]);const g=Math.sqrt(1-A[3]*A[3]);return g<1e-4?[1,0,0]:[A[0]/g,A[1]/g,A[2]/g,I]},eulerFromMatrix:A=>{const I=A[0],g=A[4],C=A[8];A[1];const B=A[5],Q=A[9];A[2];const i=A[6],e=A[10];let E=[0,0,0];return E[1]=Math.asin(h.clamp(C,-1,1)),Math.abs(C)<.9999999?(E[0]=Math.atan2(-Q,e),E[2]=Math.atan2(-g,I)):(E[0]=Math.atan2(i,B),E[2]=0),E},angleTo:(A,I)=>2*Math.acos(Math.abs(h.clamp(h.dotArray(A,I),-1,1))),fixedArray:(A,I)=>{let g=A.length,C=[];for(;g--;)C[g]=h.toFixed(A[g],I);return C},getSize:A=>.001*A.byteLength+"kb",perpendicularArray:A=>{const I=Math.sqrt(A[0]*A[0]+A[1]*A[1]+A[2]*A[2]);let g=Math.acos(A[1]/I);const C=Math.atan2(A[2],A[0]);g>p?g-=p:g+=p;return[I*Math.sin(g)*Math.cos(C),I*Math.cos(g),I*Math.sin(g)*Math.sin(C)]},crossArray:(A,I)=>{const g=A[0],C=A[1],B=A[2],Q=I[0],i=I[1],e=I[2];return[C*e-B*i,B*Q-g*e,g*i-C*Q]},applyQuaternion:(A,I)=>{const g=A[0],C=A[1],B=A[2],Q=I[0],i=I[1],e=I[2],E=I[3],o=2*(i*B-e*C),t=2*(e*g-Q*B),s=2*(Q*C-i*g);return[g+E*o+i*s-e*t,C+E*t+e*o-Q*s,B+E*s+Q*t-i*o]},nullArray:(A,I,g)=>{let C=0;for(;g--;)C+=A[I+g];return C},equalArray:(A,I)=>{let g=A.length;for(;g--;)if(A[g]!==I[g])return!1;return!0},lerpArray:(A,I,g)=>{if(0===g)return A;if(1===g)return I;let C=A.length,B=[];for(;C--;)B[C]=A[C],B[C]+=(I[C]-B[C])*g;return B},zeroArray:(A,I=0,g)=>{for(g=g??A.length;g--;)A[I+g]=0;return A},lengthArray:A=>{let I=A.length,g=0;for(;I--;)g+=A[I]*A[I];return Math.sqrt(g)},dotArray:(A,I)=>{let g=A.length,C=0;for(;g--;)C+=A[g]*I[g];return C},addArray:(A,I,g)=>{g=g??A.length;let C=[];for(;g--;)C[g]=A[g]+I[g];return C},subArray:(A,I,g)=>{g=g??A.length;let C=[];for(;g--;)C[g]=A[g]-I[g];return C},mulArray:(A,I,g)=>{if(I instanceof Array){let C=[];for(g=g??A.length;g--;)C[g]=A[g]*I[g];return C}return A.map((A=>A*I))},worldscale:(A,I)=>A.map((A=>A*I)),divArray:(A,I,g)=>h.mulArray(A,1/I,g),scaleArray:(A,I,g)=>h.mulArray(A,I,g),fillArray:(A,I,g=0,C)=>{for(C=C??A.length;C--;)I[g+C]=A[C]},copyArray:(A,I)=>{},cloneArray:A=>[...A],distanceArray:(A,I=[0,0,0])=>h.lengthArray(h.subArray(A,I)),normalizeArray:A=>h.divArray(A,h.lengthArray(A)||1),normalArray:(A,I=[0,0,0])=>h.normalizeArray(h.subArray(I,A)),getCenter:(A,I)=>(A.computeBoundingBox(),A.boundingBox.getCenter(I)),getVolume:(A,I,g=null)=>{let C=1,B=I;switch(A){case"sphere":C=4*Math.PI*B[0]*B[0]*B[0]/3;break;case"cone":C=Math.PI*B[0]*(.5*B[1])*2;break;case"box":C=.5*B[0]*8*(.5*B[1])*(.5*B[2]);break;case"cylinder":C=Math.PI*B[0]*B[0]*(.5*B[1])*2;break;case"capsule":C=4*Math.PI*B[0]*B[0]*B[0]/3+Math.PI*B[0]*B[0]*(.5*B[1])*2;break;case"convex":case"mesh":C=h.getConvexVolume(g)}return C},getConvexVolume:A=>{let I,g=A.length/3,C=[0,0,0],B=[0,0,0];for(;g--;)I=3*g,A[I]<C[0]?C[0]=A[I]:A[I]>B[0]&&(B[0]=A[I]),A[I+1]<C[1]?C[1]=A[I+1]:A[I+1]>B[1]&&(B[1]=A[I+1]),A[I+2]<C[2]?C[2]=A[I+2]:A[I+2]>B[2]&&(B[2]=A[I+2]);let Q=[B[0]-C[0],B[1]-C[1],B[2]-C[2]];return.5*Q[0]*8*(.5*Q[1])*(.5*Q[2])},massFromDensity:(A,I)=>A*I,densityFromMass:(A,I)=>A/I,toNonIndexed:A=>A.index?A.clone().toNonIndexed():A,getIndex:(A,I)=>!A.index||I?null:A.index.array||null,getSameVertex:A=>{const I=A.getAttribute("position"),g=I.array,C=[],B=[],Q={};new THREE.Vector3;let i,e=0;h.getHash(A);let E,o,t=!1,s=0;for(let A=0;A<I.count;A++){e=3*A,E={x:g[e],y:g[e+1],z:g[e+2],id:A},t=!1,i=C.length;for(let I=0;I<i;I++)o=C[I],E.x===o.x&&E.y===o.y&&E.z===o.z&&(t=!0,Q[A]=o.id);t||(E.id=s++,C.push(E),B.push([E.x,E.y,E.z]))}return[B,Q]},getVertex:(A,I)=>{let g=A.attributes.position.array;return I&&A.index&&(g=(A=A.clone().toNonIndexed()).attributes.position.array),g},getNormal:A=>A.attributes.normal.array,getFaces:A=>{let I=[];if(A.index){let g=A.getIndex();for(let A=0;A<g.count;A+=3)I.push([g.getX(A),g.getX(A+1),g.getX(A+2)])}else{let g=A.getAttribute("position").count;for(let A=0;A<g;A+=3)I.push([A,A+1,A+2])}return I},getConnectedFaces:A=>{const I=[];let g,C,B,Q,i,e,E,o=A.length,t=o;for(;t--;)for(C=A[t],g=o;g--;)g!==t&&(B=A[g],Q=C.filter((A=>B.includes(A))),Q.length>1&&(E=[],i=[...C],e=i.indexOf(Q[0]),i.splice(e,1),e=i.indexOf(Q[1]),i.splice(e,1),E.push(i[0]),i=[...B],e=i.indexOf(Q[0]),i.splice(e,1),e=i.indexOf(Q[1]),i.splice(e,1),E.push(i[0]),I.push(E)));return I},reduce:A=>{},barycentric:(A,I)=>{},solve:(A,I)=>{},getHash:(A,I=1e-4)=>{I=Math.max(I,Number.EPSILON);const g={},C={},B=A.getAttribute("position"),Q=B.count,i=B.array,e=.5*I,E=Math.log10(1/I),o=Math.pow(10,E),t=e*o;let s;for(let A=0;A<Q;A++){s=3*A;let I=`${~~(i[s]*o+t)},${~~(i[s+1]*o+t)},${~~(i[s+2]*o+t)}`;g[I]?g[I].push(A):g[I]=[A]}let _=0;for(let A in g)C[_++]=g[A];return C}},l=h;class y extends D{constructor(){super(),this.Utils=B,this.type="ray",this.init()}init(){this.rayBuffer=new PhysX.PxRaycastBuffer10,this.rayBuffer.hasBlock=!0,this.rayFlags=new PhysX.PxHitFlags(B.HitFlag.eDEFAULT|B.HitFlag.eANY_HIT),this.rayFilter=new PhysX.PxQueryFilterData,this.v1=new PhysX.PxVec3(0,0,0),this.v2=new PhysX.PxVec3(0,0,0)}byPtr(A){return B.byPtr(A)}step(){const A=C.Ar,I=C.ArPos[this.type];C.reflow.ray=[];let g,B,Q,i,e,E,o=this.list.length;for(;o--;){if(B=I+o*_.ray,g=this.list[o],e=g.getPoint(),this.v1.fromArray(e[0]),this.v2.fromArray(e[1]),i=l.distanceArray(e[0],e[1]),A[B]=0,A[B+1]=i,this.v2.fromArray(l.normalArray(e[0],e[1])),this.v1.toArray(A,B+2),C.setFilterData(this.rayFilter.get_data(),[2,1,[3,5]]),E=null,C.scene.raycast(this.v1,this.v2,i,this.rayBuffer,this.rayFlags,this.rayFilter)){let I=this.rayBuffer.getNbTouches();for(;I--;)E=this.rayBuffer.getTouch(I),Q=this.byPtr(E.actor.ptr),!g.selfHit&&g.parent&&Q===g.parent||0!==A[B]&&E.distance>A[B+1]||(A[B]=1,A[B+1]=E.distance,E.position.toArray(A,B+5),E.normal.toArray(A,B+8),C.reflow.ray[o]=Q)}}}applyResult(){}add(A={}){this.setName(A);let I=new G(A);this.addToWorld(I,A.id)}set(A={},I=null){null===I&&(I=this.byName(A.name)),null!==I&&(A.begin&&(I.begin=A.begin),A.end&&(I.end=A.end))}}class G{constructor(A={}){this.type="ray",this.name=A.name,this.parent=A.parent||"",this.noRotation=A.noRotation||!1,this.selfHit=A.selfHit||!1,this.begin=A.begin||[0,0,0],this.end=A.end||[0,0,1],this.precision=A.precision||1,this.group=void 0!==A.group||16,this.mask=void 0!==A.mask||2}getPoint(){if(this.parent){const A=B.byName(this.parent);if(A){const I=A.getGlobalPose(),g=I.p.toArray(),C=this.noRotation?[0,0,0,1]:I.q.toArray();return[l.applyTransformArray(this.begin,g,C),l.applyTransformArray(this.end,g,C)]}}return[this.begin,this.end]}}class k{constructor(I,g=128,B=128,Q=!1){this.name=I,this.type="group",this.numActors=0,this.maxActors=g,this.maxShapes=B,this.selfCollisions=Q,this.aggregate=C.world.createAggregate(this.maxActors,this.maxShapes,this.selfCollisions),C.scene.addAggregate(this.aggregate),A.set(this.name,this)}set(A){}addActor(A,I){this.aggregate.addActor(A,I),this.numActors++}removeActor(A){this.aggregate.removeActor(A),this.numActors--,0===this.numActors&&this.release()}release(){this.aggregate&&(C.scene.removeAggregate(this.aggregate,!1),this.aggregate.release(),this.aggregate=null,A.delete(this.name))}}const F=.02;class J extends D{constructor(){super(),this.Utils=B,this.type="body",this.itype="body",this.num=_[this.type],this.full=!1,this.tv=null,this.v=new PhysX.PxVec3,this.v2=new PhysX.PxVec3,this.q=new PhysX.PxQuat,this.qr=new PhysX.PxQuat,this.t=new PhysX.PxTransform}setFull(A){this.num=_[A?"bodyFull":"body"],this.full=A}step(){const A=C.Ar,I=C.ArPos[this.itype];let g,B,Q,i,e,E=this.list.length;for(;E--;)g=this.list[E],B=I+E*this.num,g.isKinematic&&(g.first?g.first=!1:g.setKinematicTarget(g.tmpTransform)),e=g.isBone?g.getArticulation().isSleeping():g.isSleeping(),A[B]=e?0:1,g.isKinematic?g.tmpTransform.toArray(A,B+1):g.getGlobalPose().toArray(A,B+1),this.full?(Q=g.getLinearVelocity(),i=g.getAngularVelocity(),Q.toArray(A,B+8),i.toArray(A,B+11),1===A[B]&&(A[B]=9.8*Q.length())):g.getVelocity&&(Q=g.getLinearVelocity().toArray(),i=g.getAngularVelocity().toArray(),C.reflow.velocity[g.name]=[...Q,...i]),g.selfGravity&&this.upGravity(g)}preRotate(A=[0,0,0,1],I="Z"){let g;switch(I){case"Y":g=[0,.7071067811865475,0,.7071067811865476];break;case"Z":g=[0,0,.7071067811865475,.7071067811865476]}return this.q.fromArray(A).premultiply(this.qr.fromArray(g)).toArray()}shape(A={}){let I,g,Q,i,e,E,o,t=A.type||"box",s=A.size||[1,1,1],_=null,D=null,n=null,a=null;switch(t){case"plane":I=new PhysX.PxPlaneGeometry;break;case"box":I=new PhysX.PxBoxGeometry(.5*s[0],.5*s[1],.5*s[2]);break;case"particle":I=new PhysX.PxSphereGeometry(A.pSize||.05);break;case"sphere":I=new PhysX.PxSphereGeometry(s[0]);break;case"capsule":I=new PhysX.PxCapsuleGeometry(s[0],.5*s[1]);break;case"cylinder":o=new PhysX.PxConvexCoreCylinder(s[1],s[0]),I=new PhysX.PxConvexCoreGeometryFactory.prototype.createFromCylinder(o,A.margin||F),PhysX.destroy(o);break;case"cone":o=new PhysX.PxConvexCoreCone(.5*s[1],s[0]),I=new PhysX.PxConvexCoreGeometryFactory.prototype.createFromCone(o,A.margin||F),PhysX.destroy(o);break;case"ellipsoid":o=new PhysX.PxConvexCoreEllipsoid(s[0],s[1],s[2]),I=new PhysX.PxConvexCoreGeometryFactory.prototype.createFromEllipsoid(o,A.margin||F),PhysX.destroy(o);break;case"point":o=new PhysX.PxConvexCorePoint,I=new PhysX.PxConvexCoreGeometryFactory.prototype.createFromPoint(o,A.margin||F),PhysX.destroy(o);break;case"segment":o=new PhysX.PxConvexCoreSegment(s[0]),I=new PhysX.PxConvexCoreGeometryFactory.prototype.createFromSegment(o,A.margin||F),PhysX.destroy(o);break;case"convex":g=new PhysX.PxConvexMeshDesc,Q=A.v,_=B.malloc(Q),g.points.stride=3*Q.BYTES_PER_ELEMENT,g.points.count=Q.length/3,g.points.data=_;let t=0;t|=PhysX._emscripten_enum_PxConvexFlagEnum_eCOMPUTE_CONVEX(),t|=PhysX._emscripten_enum_PxConvexFlagEnum_eQUANTIZE_INPUT(),t|=PhysX._emscripten_enum_PxConvexFlagEnum_eDISABLE_MESH_VALIDATION(),n=new PhysX.PxConvexFlags(t),g.flags=n,i=PhysX.PxTopLevelFunctions.prototype.CreateConvexMesh(C.cookingParams,g),e=new PhysX.PxMeshScale,E=new PhysX.PxConvexMeshGeometryFlags,I=new PhysX.PxConvexMeshGeometry(i,e,E),C.garbage.push(i),PhysX.destroy(n),PhysX.destroy(e),PhysX.destroy(E),PhysX.destroy(g),B.free(_);break;case"mesh":g=new PhysX.PxTriangleMeshDesc,Q=A.v,a=A.index||null,a&&a.constructor===Uint16Array&&(a=new Uint32Array(a)),_=B.malloc(Q),g.points.stride=3*Q.BYTES_PER_ELEMENT,g.points.count=Q.length/3,g.points.data=_,null!==a&&(D=B.mallocIndex(a),g.triangles.stride=3*a.BYTES_PER_ELEMENT,g.triangles.count=a.length/3,g.triangles.data=D),i=PhysX.PxTopLevelFunctions.prototype.CreateTriangleMesh(C.cookingParams,g),e=new PhysX.PxMeshScale(new PhysX.PxVec3(1,1,1),new PhysX.PxQuat(0,0,0,1)),I=new PhysX.PxTriangleMeshGeometry(i,e),I.isValid()||console.error("trimesh",A.name,"is not valid for physx"),C.garbage.push(i),n&&PhysX.destroy(n),PhysX.destroy(e),PhysX.destroy(g),B.free(_),B.free(D)}return I.volume=l.getVolume(t,s,A.v),I}setShapeFlag(A="default"){let I;switch(A){case"default":case 1:I=PhysX._emscripten_enum_PxShapeFlagEnum_eSCENE_QUERY_SHAPE()|PhysX._emscripten_enum_PxShapeFlagEnum_eSIMULATION_SHAPE();break;case"noCollision":case 0:I=PhysX._emscripten_enum_PxShapeFlagEnum_eSCENE_QUERY_SHAPE();break;case"noQuery":case 2:I=PhysX._emscripten_enum_PxShapeFlagEnum_eSIMULATION_SHAPE();break;case"ghost":case 3:I=PhysX._emscripten_enum_PxShapeFlagEnum_eTRIGGER_SHAPE();break;case"ghostAndQuery":case 4:I=PhysX._emscripten_enum_PxShapeFlagEnum_eTRIGGER_SHAPE()|PhysX._emscripten_enum_PxShapeFlagEnum_eSCENE_QUERY_SHAPE();break;case"none":case 5:I=0}return new PhysX.PxShapeFlags(I)}add(A={}){let I=this.setName(A),g="mesh"===A.type,Q=["body"===this.type?1:2,-1,0,0];void 0!==A.filter&&(Q=A.filter,delete A.filter),void 0!==A.group&&(Q[0]=A.group),void 0!==A.mask&&(Q[1]=A.mask),A.isTrigger&&(Q[1]=-1,Q[2]=[2,4,10],A.flags="ghostAndQuery"),(A.enableCCD||A.bullet)&&(Q[2]=[1,2,3,4,5,10,11,12]),void 0===A.friction&&(A.friction=.5),void 0===A.staticFriction&&(A.staticFriction=A.friction),void 0===A.restitution&&(A.restitution=C.restitution);let i,e,E,o=.5===A.friction&&.5===A.staticFriction&&A.restitution===C.restitution,t=o?C.defaultMaterial:C.world.createMaterial(A.staticFriction,A.friction,A.restitution),s=[];switch(A.type){case"null":Q[1]=0,i=this.shape({type:"sphere",size:[.01]}),E=this.setShapeFlag(0),s.push(C.world.createShape(i,t,void 0===A.isExclusive||A.isExclusive,E)),PhysX.destroy(E),PhysX.destroy(i);break;case"compound":let I,g;s=[],E=this.setShapeFlag(A.flags);for(let B=0;B<A.shapes.length;B++)I=A.shapes[B],i=this.shape(I),g=C.world.createShape(i,t,A.isExclusive||!1,E),"plane"!==I.type&&"capsule"!==I.type||(I.quat=this.preRotate(I.quat)),g.setLocalPose(this.t.fromArray(I.pos,I.quat)),PhysX.destroy(i),s.push(g);PhysX.destroy(E);break;default:A.shapeType&&(A.type=A.shapeType),i=this.shape(A),E="particle"===A.type?this.setShapeFlag(1):this.setShapeFlag(A.flags),s.push(C.world.createShape(i,t,void 0===A.isExclusive||A.isExclusive,E));let B=A.localPos||[0,0,0],e=A.localQuat||[0,0,0,1];"plane"!==A.type&&"capsule"!==A.type||(e=this.preRotate(e)),"cylinder"===A.type&&(e=this.preRotate(e)),s[0].setLocalPose(this.t.fromArray(B,e)),i?PhysX.destroy(i):console.log(A),PhysX.destroy(E)}if(o||t.release(),this.t.fromArray(A.pos,A.quat),A.solver){let g=B.byName(A.solver);null!==g&&(e=g.addBone(I,this.t,A.linked),e.isBone=!0)}else e="body"===this.type?C.world.createRigidDynamic(this.t):C.world.createRigidStatic(this.t);let _=s.length;for(;_--;)C.setFilter(s[_],Q),e.attachShape(s[_]),s[_].release();if(A.mass&&A.density&&!g&&delete A.density,"body"===this.type){let I=this.v.fromArray(A.massCenter||[0,0,0]);const g=!1;A.density?(PhysX.PxRigidBodyExt.prototype.updateMassAndInertia(e,A.density,I,g),delete A.density):A.mass&&PhysX.PxRigidBodyExt.prototype.setMassAndUpdateInertia(e,A.mass,I,g),A.mass&&delete A.mass}if(e){if(e.name=I,e.type=this.type,e.isKinematic=A.kinematic||!1,e.breakable=A.breakable||!1,e.trigger=A.isTrigger||!1,e.filter=Q,e.aggregate=null,A.aggregate){let I=B.byName(A.aggregate);null===I&&(I=new k(A.aggregate,A.aggregateMax,A.aggregateMax,A.aggregateCollisions)),e.aggregate=I}A.kinematic&&(e.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eKINEMATIC(),A.kinematic),e.tmpTransform=e.getGlobalPose().clone(),e.first=!0,delete A.kinematic),delete A.pos,delete A.quat,this.addToWorld(e,A.id),this.set(A,e)}}upGravity(A){A.selfGravity&&A.addForce(this.v.fromArray(A.selfGravity),B.ForceMode.force,!1)}setGravityScale(A,I){A.selfGravity||A.setActorFlag(PhysX._emscripten_enum_PxActorFlagEnum_eDISABLE_GRAVITY(),!0);let g=C.gravity.toArray();I*=2,A.selfGravity=[I*g[0],I*g[1],I*g[2]]}set(A={},I=null){if(null===I&&(I=this.byName(A.name)),null===I)return;void 0!==A.getVelocity&&(I.getVelocity=A.getVelocity),void 0!==A.kinematic&&"body"===I.type&&(I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eKINEMATIC(),A.kinematic),I.isKinematic=A.kinematic,I.isKinematic&&(I.tmpTransform=I.getGlobalPose().clone())),void 0!==A.gravityScale&&this.setGravityScale(I,A.gravityScale),void 0!==A.gravity&&I.setActorFlag(PhysX._emscripten_enum_PxActorFlagEnum_eDISABLE_GRAVITY(),!A.gravity),A.noGravity&&I.setActorFlag(PhysX._emscripten_enum_PxActorFlagEnum_eDISABLE_GRAVITY(),!0),void 0!==A.disable&&I.setActorFlag(PhysX._emscripten_enum_PxActorFlagEnum_eDISABLE_SIMULATION(),A.disable);let g=void 0===A.activate||A.activate;if(I.isBone||"body"!==I.type||(A.sleep&&(I.putToSleep(),g=!1),A.wake&&I.wakeUp(),void 0!==A.neverSleep&&(A.sleepThreshold=A.neverSleep?0:.005,A.neverSleep&&!A.wake&&I.wakeUp()),void 0!==A.stabilization&&I.setStabilizationThreshold(A.stabilization),void 0!==A.sleepThreshold&&I.setSleepThreshold(A.sleepThreshold)),(A.pos||A.quat)&&(A.pos||(A.pos=I.getGlobalPose().p.toArray()),A.quat||(A.quat=I.getGlobalPose().q.toArray()),this.t.fromArray(A.pos,A.quat),I.isKinematic?I.tmpTransform.copy(this.t):I.setGlobalPose(this.t,g)),"body"===I.type&&(this.changeMass(I,A),A.impulse&&(A.impulseCenter?PhysX.PxRigidBodyExt.prototype.addForceAtPos(I,this.v.fromArray(A.impulse),this.v2.fromArray(A.impulseCenter),B.ForceMode.impulse,g):I.addForce(this.v.fromArray(A.impulse),B.ForceMode.impulse,g)),A.force&&(A.forcePosition?PhysX.PxRigidBodyExt.prototype.addForceAtPos(I,this.v.fromArray(A.force),this.v2.fromArray(A.forcePosition),B.ForceMode[A.forceMode||"force"],g):I.addForce(this.v.fromArray(A.force),B.ForceMode[A.forceMode||"force"],g)),A.torque&&I.addTorque(this.v.fromArray(A.torque),B.ForceMode[A.torqueMode||"force"],g),A.linearVelocity&&(A.linear=A.linearVelocity),A.angularVelocity&&(A.angular=A.angularVelocity),A.velocityOperation?this.velocityOperation(A,I,g):(A.linear&&I.setLinearVelocity(this.v.fromArray(A.linear),g),A.angular&&I.setAngularVelocity(this.v.fromArray(A.angular),g)),void 0!==A.linearFactor&&(I.setRigidDynamicLockFlag(PhysX.eLOCK_LINEAR_X,!A.linearFactor[0]),I.setRigidDynamicLockFlag(PhysX.eLOCK_LINEAR_Y,!A.linearFactor[1]),I.setRigidDynamicLockFlag(PhysX.eLOCK_LINEAR_Z,!A.linearFactor[2])),void 0!==A.angularFactor&&(I.setRigidDynamicLockFlag(PhysX.eLOCK_ANGULAR_X,!A.angularFactor[0]),I.setRigidDynamicLockFlag(PhysX.eLOCK_ANGULAR_Y,!A.angularFactor[1]),I.setRigidDynamicLockFlag(PhysX.eLOCK_ANGULAR_Z,!A.angularFactor[2])),void 0!==A.damping&&(I.setLinearDamping(A.damping[0]),I.setAngularDamping(A.damping[1])),void 0!==A.maxVelocity&&(I.setMaxLinearVelocity(A.maxVelocity[0]),I.setMaxAngularVelocity(A.maxVelocity[1])),A.reset&&I.setLinearVelocity&&(I.setLinearVelocity(this.v.set(0,0,0),g),I.setAngularVelocity(this.v.set(0,0,0),g))),A.iterations&&I.setSolverIterationCounts&&I.setSolverIterationCounts(A.iterations[0],A.iterations[1]),void 0!==A.minCCD&&I.setMinCCDAdvanceCoefficient(A.minCCD),"body"===I.type&&(void 0!==A.kinematicTarget&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES(),A.kinematicTarget),void 0!==A.bullet&&(A.enableCCD=!0),void 0!==A.enableCCD&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eENABLE_CCD(),A.enableCCD),void 0!==A.enableCCD_FRICTION&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eENABLE_CCD_FRICTION(),A.enableCCD_FRICTION),void 0!==A.speculativeCCD&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eENABLE_SPECULATIVE_CCD(),A.speculativeCCD),void 0!==A.enablePose&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eENABLE_POSE_INTEGRATION_PREVIEW(),A.enablePose),void 0!==A.ccdMaxContact&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eENABLE_CCD_MAX_CONTACT_IMPULSE(),A.ccdMaxContact),void 0!==A.retainAcc&&I.setRigidBodyFlag(PhysX._emscripten_enum_PxRigidBodyFlagEnum_eRETAIN_ACCELERATIONS(),A.retainAcc),I.setMaxDepenetrationVelocity(C.pv),void 0!==A.pv&&(A.depenetrationVelocity=A.pv),void 0!==A.penetrationVelocity&&(A.depenetrationVelocity=A.pv),void 0!==A.depenetrationVelocity&&I.setMaxDepenetrationVelocity(A.depenetrationVelocity),void 0!==A.mci&&(A.maxContactImpulse=A.mci),void 0!==A.maxContactImpulse&&I.setMaxContactImpulse(A.maxContactImpulse),A.inertiaTensor&&(A.massSpaceInertiaTensor=A.inertiaTensor),A.massSpaceInertiaTensor&&I.setMassSpaceInertiaTensor(this.v.fromArray(A.massSpaceInertiaTensor)),A.inertia&&I.setMassSpaceInertiaTensor(this.v.fromArray(A.inertia)),void 0!==A.inertiaScale)){let g=I.getMassSpaceInertiaTensor().toArray();I.setMassSpaceInertiaTensor(this.v.fromArray([g[0]*A.inertiaScale,g[1]*A.inertiaScale,g[2]*A.inertiaScale]))}A.dmv&&(void 0!==A.dmv[0]&&I.setLinearDamping(A.dmv[0]),void 0!==A.dmv[1]&&I.setAngularDamping(A.dmv[1]),void 0!==A.dmv[2]&&I.setMaxLinearVelocity(A.dmv[2]),void 0!==A.dmv[3]&&I.setMaxAngularVelocity(A.dmv[3])),A.massInfo&&this.getMassInfo(I)}velocityOperation(A,I,g){let B=I.getLinearVelocity().toArray(),Q=I.getAngularVelocity().toArray();switch(A.velocityOperation){case"xz":A.linear&&(B=[A.linear[0],B[1],A.linear[2]]);break;case"add":A.linear&&(B=l.addArray(B,A.linear,3)),A.angular&&(Q=l.addArray(Q,A.angular,3));break;case"sub":A.linear&&(B=l.subArray(B,A.linear,3)),A.angular&&(Q=l.subArray(Q,A.angular,3));break;case"multy":A.linear&&(B=l.mulArray(B,A.linear,3)),A.angular&&(Q=l.mulArray(Q,A.angular,3));break;case"lerp":A.linear&&(B=l.lerpArray(B,A.linear,A.time)),A.angular&&(Q=l.lerpArray(Q,A.angular,A.time));break;case"step":A.linear&&(B=l.mulArray(B,C.substep)),A.angular&&(Q=l.mulArray(Q,C.substep));break;case"local":let g=I.getGlobalPose().q.toArray();A.linear&&(B=l.applyQuaternion(B,g)),A.angular&&(Q=l.applyQuaternion(Q,g))}I.setLinearVelocity(this.v.fromArray(B),g),I.setAngularVelocity(this.v.fromArray(Q),g)}setShapes(A={},I=null){let g,B=I.getNbShapes();for(;B--;)g=PhysX.SupportFunctions.prototype.PxActor_getShape(I,B),A.filter&&C.setFilter(g,A.filter)}changeMass(A,I={}){if(I.density||I.mass){let g=this.v.fromArray(I.massCenter||[0,0,0]);const C=!1;I.density&&!I.mass&&PhysX.PxRigidBodyExt.prototype.updateMassAndInertia(A,I.density,g,C),I.mass&&PhysX.PxRigidBodyExt.prototype.setMassAndUpdateInertia(A,I.mass,g,C)}I.massCenter&&A.setCMassLocalPose(this.t.fromArray(I.massCenter)),I.inertia&&A.setMassSpaceInertiaTensor(this.v.fromArray(I.inertia))}getMassInfo(A=null){if("string"==typeof A&&(A=this.byName(A)),null===A)return;if("body"!==this.type)return;const I={mass:A.getMass(),invMass:A.getInvMass(),massCenter:A.getCMassLocalPose().p.toArray(),inertia:A.getMassSpaceInertiaTensor().toArray(),invInertia:A.getMassSpaceInvInertiaTensor().toArray(),damping:[A.getLinearDamping(),A.getAngularDamping()]};console.log(I)}addCollisionCallback(A,I){A.trigger?C.setCollisionFilter(A,I?[2,4,10]:[-1]):C.ccd?C.setCollisionFilter(A,I?[1,2,3,4,5,6,10,11,12]:[-1]):C.setCollisionFilter(A,I?[1,2,3,4,5,10,11]:[-1])}}class K extends D{constructor(){super(),this.Utils=B,this.type="joint",this.t1=new PhysX.PxTransform,this.t2=new PhysX.PxTransform,this.v1=new PhysX.PxVec3,this.v2=new PhysX.PxVec3,this.p1=new PhysX.PxVec3,this.p2=new PhysX.PxVec3,this.q1=new PhysX.PxQuat,this.q2=new PhysX.PxQuat,this.q3=new PhysX.PxQuat}step(){const A=C.Ar,I=C.ArPos[this.type];let g,B,Q=this.list.length;for(;Q--;)g=this.list[Q],B=I+Q*_.joint,g.visible&&(g.b1?this.t1.copy(g.b1.getGlobalPose()).multiply(g.formA).toArray(A,B):this.t1.copy(g.formA).toArray(A,B),g.b2?this.t1.copy(g.b2.getGlobalPose()).multiply(g.formB).toArray(A,B+7):this.t1.copy(g.formB).toArray(A,B+7))}add(A={}){this.v;let I=this.setName(A),g=this.byName(A.b1),B=this.byName(A.b2);null!==g&&"vehicle"===g.type&&(g=g.vehicleActor),null!==B&&"vehicle"===B.type&&(B=B.vehicleActor);let Q=this.v1.fromArray(A.pos1||[0,0,0]),i=this.v2.fromArray(A.pos2||[0,0,0]),e=this.q1.fromArray(A.quat1||[0,0,0,1]),E=this.q2.fromArray(A.quat2||[0,0,0,1]),o=this.p1.fromArray(A.axis1||[0,0,1]),t=this.p2.fromArray(A.axis2||[0,0,1]);A.quat1||e.fromAxis(o).normalize(),A.quat2||E.fromAxis(t).normalize();const s=new PhysX.PxTransform(Q,e),_=new PhysX.PxTransform(i,E);let D,n=A.mode||"hinge";switch(n){case"fixe":D=new PhysX.PxTopLevelFunctions.prototype.FixedJointCreate(C.world,g,s,B,_);break;case"hinge":D=new PhysX.PxTopLevelFunctions.prototype.RevoluteJointCreate(C.world,g,s,B,_);break;case"spherical":D=new PhysX.PxTopLevelFunctions.prototype.SphericalJointCreate(C.world,g,s,B,_);break;case"prismatic":D=new PhysX.PxTopLevelFunctions.prototype.PrismaticJointCreate(C.world,g,s,B,_);break;case"distance":D=new PhysX.PxTopLevelFunctions.prototype.DistanceJointCreate(C.world,g,s,B,_);break;case"ragdoll":case"cylindrical":case"generic":if("cylindrical"===n){let I=A.lm?A.lm:[0,0],g=A.lmr?A.lmr:[0,0];A.lm&&delete A.lm,A.lmr&&delete A.lmr,A.lm=[["x",...I],["rx",...g]]}D=new PhysX.PxTopLevelFunctions.prototype.D6JointCreate(C.world,g,s,B,_)}D.name=I,D.mode=n,D.type=this.type,D.b1=g,D.b2=B,D.formA=s,D.formB=_,D.visible=!1,this.set(A,D);let a=void 0!==A.collision&&A.collision;D.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_eCOLLISION_ENABLED(),a),this.addToWorld(D,A.id)}set(A={},I=null){if(null===I&&(I=this.byName(A.name)),null===I)return;let g,C,Q,i,e,E,o;void 0!==A.visible&&(I.visible=A.visible);let t=void 0===A.wake||A.wake;switch(void 0!==A.project1&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_ePROJECT_TO_ACTOR0(),A.project1),void 0!==A.project2&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_ePROJECT_TO_ACTOR1(),A.project2),void 0!==A.tolerance&&this.tolerance(I,A.tolerance),void 0!==A.alway&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_eALWAYS_UPDATE(),A.alway),void 0!==A.improveSlerp&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_eIMPROVED_SLERP(),A.improveSlerp),void 0!==A.noPreProcess&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_eDISABLE_PREPROCESSING(),A.noPreProcess),void 0!==A.extendedLimit&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_eENABLE_EXTENDED_LIMITS(),A.extendedLimit),void 0!==A.limitAreForce&&I.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_eDRIVE_LIMITS_ARE_FORCES(),A.limitAreForce), //!!!need PxSimulationEventCallbackImpl::onConstraintBreak. void 0!==A.break&&I.setBreakForce(A.break[0],A.break[1]),I.mode){case"spherical":A.limit&&(g=this.coneLimit(A.limit,A.spring),I.setLimitCone(g),I.setSphericalJointFlag(PhysX._emscripten_enum_PxSphericalJointFlagEnum_eLIMIT_ENABLED(),!0));break;case"prismatic":A.limit&&(g=this.linearLimit(A.limit,A.spring),I.setLimit(g),I.setPrismaticJointFlag(PhysX._emscripten_enum_PxPrismaticJointFlagEnum_eLIMIT_ENABLED(),!0));break;case"hinge":void 0!==A.limit&&(g=this.angularLimit(A.limit,A.spring),I.setLimit(g),I.setRevoluteJointFlag(PhysX._emscripten_enum_PxRevoluteJointFlagEnum_eLIMIT_ENABLED(),!0)),void 0!==A.driveFree&&I.setRevoluteJointFlag(PhysX._emscripten_enum_PxRevoluteJointFlagEnum_eDRIVE_FREESPIN(),A.driveFree),void 0!==A.driveForceLimit&&I.setDriveForceLimit(A.driveForceLimit),void 0!==A.gearRatio&&I.setDriveGearRatio(A.gearRatio),A.motor&&(A.motor instanceof Array?(I.setDriveVelocity(A.motor[0]*a,t),A.motor[1]&&I.setDriveForceLimit(A.motor[1])):I.setDriveVelocity(A.motor*a,t),I.setRevoluteJointFlag(PhysX._emscripten_enum_PxRevoluteJointFlagEnum_eDRIVE_ENABLED(),!0));break;case"distance":A.limit&&(I.setMinDistance(A.limit[0]),I.setMaxDistance(A.limit[1]),I.setDistanceJointFlag(PhysX._emscripten_enum_PxDistanceJointFlagEnum_eMAX_DISTANCE_ENABLED(),!0),I.setDistanceJointFlag(PhysX._emscripten_enum_PxDistanceJointFlagEnum_eMIN_DISTANCE_ENABLED(),!0)),A.spring&&(void 0!==A.spring[0]&&I.setStiffness(A.spring[0]||0),void 0!==A.spring[1]&&I.setDamping(A.spring[1]||0),void 0!==A.spring[2]&&I.setTolerance(A.spring[2]),I.setDistanceJointFlag(PhysX._emscripten_enum_PxDistanceJointFlagEnum_eSPRING_ENABLED(),!0));break;case"ragdoll":case"generic":case"cylindrical":A.acc&&I.setConstraintFlag(PhysX._emscripten_enum_PxD6JointDriveFlagEnum_eACCELERATION(),!0);const s=A.autoDrive||!1;if(A.lm)for(s&&!A.drives&&(A.drives=[]),C=A.lm.length;C--;){switch(e=A.lm[C],E=e.slice(1),o=B.D6Axis[e[0]],I.setMotion(o,PhysX._emscripten_enum_PxD6MotionEnum_eLIMITED()),e[0]){case"rx":case"twist":g=this.angularLimit(E),I.setTwistLimit(g);break;case"ry":case"swing1":case"rz":case"swing2":g=this.coneLimit(E),I.setSwingLimit(g);break;default:g=this.linearLimit(E),I.setLinearLimit(o,g)}s&&A.drives.push([e[0],e[2]||0,e[3]||0])}if(A.motion&&(A.motions=A.motion),A.motions)for(C=A.motions.length;C--;)Q=A.motions[C],"rx"===Q[0]&&(Q[0]="twist"),"ry"===Q[0]&&(Q[0]="swing1"),"rz"===Q[0]&&(Q[0]="swing2"),I.setMotion(B.D6Axis[Q[0]],PhysX["_emscripten_enum_PxD6MotionEnum_e"+Q[1].toUpperCase()]());if(A.drive&&(A.drives=A.drive),A.drives)for(C=A.drives.length;C--;)Q=A.drives[C],"rx"!==Q[0]&&"twist"!==Q[0]||(Q[0]="twist"),"ry"!==Q[0]&&"swing1"!==Q[0]||(Q[0]="swing"),"rz"!==Q[0]&&"swing2"!==Q[0]||(Q[0]="slerp"),i=new PhysX.PxD6JointDrive(Q[1]||0,Q[2]||0,Q[3]||c,void 0!==Q[4]?Q[4]?1:0:1),I.setDrive(PhysX["_emscripten_enum_PxD6DriveEnum_e"+Q[0].toUpperCase()](),i);A.drivePosition&&I.setDrivePosition(this.t1.fromArray(A.drivePosition.pos||[0,0,0],A.drivePosition.quat||[0,0,0,1]),t),A.driveVelocity&&I.setDriveVelocity(this.v1.fromArray(A.driveVelocity[0]),this.v2.fromArray(A.driveVelocity[1]),t),void 0!==A.distanceLimit&&(g=this.distanceLimit(A.distanceLimit),I.setDistanceLimit(g))}}tolerance(A,I){I&&(A.setProjectionLinearTolerance(I[0]),A.setProjectionAngularTolerance(I[1]*a)),A.setConstraintFlag(PhysX._emscripten_enum_PxConstraintFlagEnum_ePROJECTION(),!0)}distanceLimit(A,I){let g=new PhysX.PxJointLinearLimit(A[0]);return A.length>2&&this.spring(g,A),g}linearLimit(A,I){let g=new PhysX.PxJointLinearLimitPair(A[0],A[1]);return A.length>2&&this.spring(g,A),I&&(void 0!==I[0]&&g.set_stiffness(I[0]),void 0!==I[1]&&g.set_damping(I[1])),g}angularLimit(A,I){let g=new PhysX.PxJointAngularLimitPair(A[0]*a,A[1]*a);return A.length>2&&this.spring(g,A),g}coneLimit(A,I){let g=new PhysX.PxJointLimitCone(Math.abs(A[0])*a,Math.abs(A[1])*a);return A.length>2&&this.spring(g,A),g}pyramidLimit(A,I){let g=new PhysX.PxJointLimitPyramid(-A[0]*a,A[0]*a,-A[1]*a,A[1]*a);return A.length>2&&this.sring(g,A),g}spring(A,I){void 0!==I[2]&&A.set_stiffness(I[2]),void 0!==I[3]&&A.set_damping(I[3]),void 0!==I[4]&&A.set_restitution(I[4]),void 0!==I[5]&&A.set_bounceThreshold(I[5])}}class U extends D{constructor(){super(),this.type="solver",this.Utils=B}step(){const A=C.Ar,I=C.ArPos[this.type];let g,B=this.l