OimoPhysics.js 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881
  1. var oimo = oimo || {};
  2. if(!oimo.collision) oimo.collision = {};
  3. if(!oimo.collision.broadphase) oimo.collision.broadphase = {};
  4. oimo.collision.broadphase.BroadPhase = class oimo_collision_broadphase_BroadPhase {
  5. constructor(type) {
  6. this._type = type;
  7. this._numProxies = 0;
  8. this._proxyList = null;
  9. this._proxyListLast = null;
  10. this._proxyPairList = null;
  11. this._incremental = false;
  12. this._testCount = 0;
  13. this._proxyPairPool = null;
  14. this._idCount = 0;
  15. this._convexSweep = new oimo.collision.broadphase._BroadPhase.ConvexSweepGeometry();
  16. this._aabb = new oimo.collision.broadphase._BroadPhase.AabbGeometry();
  17. this.identity = new oimo.common.Transform();
  18. this.zero = new oimo.common.Vec3();
  19. this.rayCastHit = new oimo.collision.geometry.RayCastHit();
  20. }
  21. createProxy(userData,aabb) {
  22. return null;
  23. }
  24. destroyProxy(proxy) {
  25. }
  26. moveProxy(proxy,aabb,displacement) {
  27. }
  28. isOverlapping(proxy1,proxy2) {
  29. if(proxy1._aabbMinX < proxy2._aabbMaxX && proxy1._aabbMaxX > proxy2._aabbMinX && proxy1._aabbMinY < proxy2._aabbMaxY && proxy1._aabbMaxY > proxy2._aabbMinY && proxy1._aabbMinZ < proxy2._aabbMaxZ) {
  30. return proxy1._aabbMaxZ > proxy2._aabbMinZ;
  31. } else {
  32. return false;
  33. }
  34. }
  35. collectPairs() {
  36. }
  37. getProxyPairList() {
  38. return this._proxyPairList;
  39. }
  40. isIncremental() {
  41. return this._incremental;
  42. }
  43. getTestCount() {
  44. return this._testCount;
  45. }
  46. rayCast(begin,end,callback) {
  47. }
  48. convexCast(convex,begin,translation,callback) {
  49. }
  50. aabbTest(aabb,callback) {
  51. }
  52. }
  53. if(!oimo.collision.geometry) oimo.collision.geometry = {};
  54. oimo.collision.geometry.Geometry = class oimo_collision_geometry_Geometry {
  55. constructor(type) {
  56. this._type = type;
  57. this._volume = 0;
  58. }
  59. _updateMass() {
  60. }
  61. _computeAabb(aabb,tf) {
  62. }
  63. _rayCastLocal(beginX,beginY,beginZ,endX,endY,endZ,hit) {
  64. return false;
  65. }
  66. getType() {
  67. return this._type;
  68. }
  69. getVolume() {
  70. return this._volume;
  71. }
  72. rayCast(begin,end,transform,hit) {
  73. var beginLocal;
  74. var beginLocalX;
  75. var beginLocalY;
  76. var beginLocalZ;
  77. var endLocal;
  78. var endLocalX;
  79. var endLocalY;
  80. var endLocalZ;
  81. var v = begin;
  82. beginLocalX = v.x;
  83. beginLocalY = v.y;
  84. beginLocalZ = v.z;
  85. var v1 = end;
  86. endLocalX = v1.x;
  87. endLocalY = v1.y;
  88. endLocalZ = v1.z;
  89. beginLocalX -= transform._positionX;
  90. beginLocalY -= transform._positionY;
  91. beginLocalZ -= transform._positionZ;
  92. endLocalX -= transform._positionX;
  93. endLocalY -= transform._positionY;
  94. endLocalZ -= transform._positionZ;
  95. var __tmp__X;
  96. var __tmp__Y;
  97. var __tmp__Z;
  98. __tmp__X = transform._rotation00 * beginLocalX + transform._rotation10 * beginLocalY + transform._rotation20 * beginLocalZ;
  99. __tmp__Y = transform._rotation01 * beginLocalX + transform._rotation11 * beginLocalY + transform._rotation21 * beginLocalZ;
  100. __tmp__Z = transform._rotation02 * beginLocalX + transform._rotation12 * beginLocalY + transform._rotation22 * beginLocalZ;
  101. beginLocalX = __tmp__X;
  102. beginLocalY = __tmp__Y;
  103. beginLocalZ = __tmp__Z;
  104. var __tmp__X1;
  105. var __tmp__Y1;
  106. var __tmp__Z1;
  107. __tmp__X1 = transform._rotation00 * endLocalX + transform._rotation10 * endLocalY + transform._rotation20 * endLocalZ;
  108. __tmp__Y1 = transform._rotation01 * endLocalX + transform._rotation11 * endLocalY + transform._rotation21 * endLocalZ;
  109. __tmp__Z1 = transform._rotation02 * endLocalX + transform._rotation12 * endLocalY + transform._rotation22 * endLocalZ;
  110. endLocalX = __tmp__X1;
  111. endLocalY = __tmp__Y1;
  112. endLocalZ = __tmp__Z1;
  113. if(this._rayCastLocal(beginLocalX,beginLocalY,beginLocalZ,endLocalX,endLocalY,endLocalZ,hit)) {
  114. var localPos;
  115. var localPosX;
  116. var localPosY;
  117. var localPosZ;
  118. var localNormal;
  119. var localNormalX;
  120. var localNormalY;
  121. var localNormalZ;
  122. var v2 = hit.position;
  123. localPosX = v2.x;
  124. localPosY = v2.y;
  125. localPosZ = v2.z;
  126. var v3 = hit.normal;
  127. localNormalX = v3.x;
  128. localNormalY = v3.y;
  129. localNormalZ = v3.z;
  130. var __tmp__X2;
  131. var __tmp__Y2;
  132. var __tmp__Z2;
  133. __tmp__X2 = transform._rotation00 * localPosX + transform._rotation01 * localPosY + transform._rotation02 * localPosZ;
  134. __tmp__Y2 = transform._rotation10 * localPosX + transform._rotation11 * localPosY + transform._rotation12 * localPosZ;
  135. __tmp__Z2 = transform._rotation20 * localPosX + transform._rotation21 * localPosY + transform._rotation22 * localPosZ;
  136. localPosX = __tmp__X2;
  137. localPosY = __tmp__Y2;
  138. localPosZ = __tmp__Z2;
  139. var __tmp__X3;
  140. var __tmp__Y3;
  141. var __tmp__Z3;
  142. __tmp__X3 = transform._rotation00 * localNormalX + transform._rotation01 * localNormalY + transform._rotation02 * localNormalZ;
  143. __tmp__Y3 = transform._rotation10 * localNormalX + transform._rotation11 * localNormalY + transform._rotation12 * localNormalZ;
  144. __tmp__Z3 = transform._rotation20 * localNormalX + transform._rotation21 * localNormalY + transform._rotation22 * localNormalZ;
  145. localNormalX = __tmp__X3;
  146. localNormalY = __tmp__Y3;
  147. localNormalZ = __tmp__Z3;
  148. localPosX += transform._positionX;
  149. localPosY += transform._positionY;
  150. localPosZ += transform._positionZ;
  151. var v4 = hit.position;
  152. v4.x = localPosX;
  153. v4.y = localPosY;
  154. v4.z = localPosZ;
  155. var v5 = hit.normal;
  156. v5.x = localNormalX;
  157. v5.y = localNormalY;
  158. v5.z = localNormalZ;
  159. return true;
  160. }
  161. return false;
  162. }
  163. }
  164. oimo.collision.geometry.ConvexGeometry = class oimo_collision_geometry_ConvexGeometry extends oimo.collision.geometry.Geometry {
  165. constructor(type) {
  166. super(type);
  167. this._gjkMargin = oimo.common.Setting.defaultGJKMargin;
  168. this._useGjkRayCast = false;
  169. }
  170. getGjkMergin() {
  171. return this._gjkMargin;
  172. }
  173. setGjkMergin(gjkMergin) {
  174. if(gjkMergin < 0) {
  175. gjkMergin = 0;
  176. }
  177. this._gjkMargin = gjkMergin;
  178. }
  179. computeLocalSupportingVertex(dir,out) {
  180. }
  181. rayCast(begin,end,transform,hit) {
  182. if(this._useGjkRayCast) {
  183. return oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance.rayCast(this,transform,begin,end,hit);
  184. } else {
  185. return super.rayCast(begin,end,transform,hit);
  186. }
  187. }
  188. }
  189. if(!oimo.collision.broadphase._BroadPhase) oimo.collision.broadphase._BroadPhase = {};
  190. oimo.collision.broadphase._BroadPhase.ConvexSweepGeometry = class oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry extends oimo.collision.geometry.ConvexGeometry {
  191. constructor() {
  192. super(-1);
  193. }
  194. init(c,transform,translation) {
  195. this.c = c;
  196. var tr;
  197. var trX;
  198. var trY;
  199. var trZ;
  200. var v = translation;
  201. trX = v.x;
  202. trY = v.y;
  203. trZ = v.z;
  204. var localTr;
  205. var localTrX;
  206. var localTrY;
  207. var localTrZ;
  208. var __tmp__X;
  209. var __tmp__Y;
  210. var __tmp__Z;
  211. __tmp__X = transform._rotation00 * trX + transform._rotation10 * trY + transform._rotation20 * trZ;
  212. __tmp__Y = transform._rotation01 * trX + transform._rotation11 * trY + transform._rotation21 * trZ;
  213. __tmp__Z = transform._rotation02 * trX + transform._rotation12 * trY + transform._rotation22 * trZ;
  214. localTrX = __tmp__X;
  215. localTrY = __tmp__Y;
  216. localTrZ = __tmp__Z;
  217. this.localTranslation = new oimo.common.Vec3();
  218. var v1 = this.localTranslation;
  219. v1.x = localTrX;
  220. v1.y = localTrY;
  221. v1.z = localTrZ;
  222. this._gjkMargin = c._gjkMargin;
  223. }
  224. computeLocalSupportingVertex(dir,out) {
  225. this.c.computeLocalSupportingVertex(dir,out);
  226. var v = this.localTranslation;
  227. if(dir.x * v.x + dir.y * v.y + dir.z * v.z > 0) {
  228. var v1 = this.localTranslation;
  229. var tx = out.x + v1.x;
  230. var ty = out.y + v1.y;
  231. var tz = out.z + v1.z;
  232. out.x = tx;
  233. out.y = ty;
  234. out.z = tz;
  235. }
  236. }
  237. }
  238. oimo.collision.broadphase._BroadPhase.AabbGeometry = class oimo_collision_broadphase__$BroadPhase_AabbGeometry extends oimo.collision.geometry.ConvexGeometry {
  239. constructor() {
  240. super(-1);
  241. this.min = new oimo.common.Vec3();
  242. this.max = new oimo.common.Vec3();
  243. }
  244. computeLocalSupportingVertex(dir,out) {
  245. out.x = dir.x > 0 ? this.max.x : this.min.x;
  246. out.y = dir.y > 0 ? this.max.y : this.min.y;
  247. out.z = dir.z > 0 ? this.max.z : this.min.z;
  248. }
  249. }
  250. oimo.collision.broadphase.BroadPhaseProxyCallback = class oimo_collision_broadphase_BroadPhaseProxyCallback {
  251. constructor() {
  252. }
  253. process(proxy) {
  254. }
  255. }
  256. oimo.collision.broadphase.BroadPhaseType = class oimo_collision_broadphase_BroadPhaseType {
  257. }
  258. oimo.collision.broadphase.Proxy = class oimo_collision_broadphase_Proxy {
  259. constructor(userData,id) {
  260. this.userData = userData;
  261. this._id = id;
  262. this._prev = null;
  263. this._next = null;
  264. this._aabbMinX = 0;
  265. this._aabbMinY = 0;
  266. this._aabbMinZ = 0;
  267. this._aabbMaxX = 0;
  268. this._aabbMaxY = 0;
  269. this._aabbMaxZ = 0;
  270. }
  271. getId() {
  272. return this._id;
  273. }
  274. getFatAabb() {
  275. var aabb = new oimo.collision.geometry.Aabb();
  276. aabb._minX = this._aabbMinX;
  277. aabb._minY = this._aabbMinY;
  278. aabb._minZ = this._aabbMinZ;
  279. aabb._maxX = this._aabbMaxX;
  280. aabb._maxY = this._aabbMaxY;
  281. aabb._maxZ = this._aabbMaxZ;
  282. return aabb;
  283. }
  284. getFatAabbTo(aabb) {
  285. aabb._minX = this._aabbMinX;
  286. aabb._minY = this._aabbMinY;
  287. aabb._minZ = this._aabbMinZ;
  288. aabb._maxX = this._aabbMaxX;
  289. aabb._maxY = this._aabbMaxY;
  290. aabb._maxZ = this._aabbMaxZ;
  291. }
  292. }
  293. oimo.collision.broadphase.ProxyPair = class oimo_collision_broadphase_ProxyPair {
  294. constructor() {
  295. this._p1 = null;
  296. this._p2 = null;
  297. }
  298. getProxy1() {
  299. return this._p1;
  300. }
  301. getProxy2() {
  302. return this._p2;
  303. }
  304. getNext() {
  305. return this._next;
  306. }
  307. }
  308. if(!oimo.collision.broadphase.bruteforce) oimo.collision.broadphase.bruteforce = {};
  309. oimo.collision.broadphase.bruteforce.BruteForceBroadPhase = class oimo_collision_broadphase_bruteforce_BruteForceBroadPhase extends oimo.collision.broadphase.BroadPhase {
  310. constructor() {
  311. super(1);
  312. this._incremental = false;
  313. }
  314. createProxy(userData,aabb) {
  315. var proxy = new oimo.collision.broadphase.Proxy(userData,this._idCount++);
  316. this._numProxies++;
  317. if(this._proxyList == null) {
  318. this._proxyList = proxy;
  319. this._proxyListLast = proxy;
  320. } else {
  321. this._proxyListLast._next = proxy;
  322. proxy._prev = this._proxyListLast;
  323. this._proxyListLast = proxy;
  324. }
  325. proxy._aabbMinX = aabb._minX;
  326. proxy._aabbMinY = aabb._minY;
  327. proxy._aabbMinZ = aabb._minZ;
  328. proxy._aabbMaxX = aabb._maxX;
  329. proxy._aabbMaxY = aabb._maxY;
  330. proxy._aabbMaxZ = aabb._maxZ;
  331. return proxy;
  332. }
  333. destroyProxy(proxy) {
  334. this._numProxies--;
  335. var prev = proxy._prev;
  336. var next = proxy._next;
  337. if(prev != null) {
  338. prev._next = next;
  339. }
  340. if(next != null) {
  341. next._prev = prev;
  342. }
  343. if(proxy == this._proxyList) {
  344. this._proxyList = this._proxyList._next;
  345. }
  346. if(proxy == this._proxyListLast) {
  347. this._proxyListLast = this._proxyListLast._prev;
  348. }
  349. proxy._next = null;
  350. proxy._prev = null;
  351. proxy.userData = null;
  352. }
  353. moveProxy(proxy,aabb,dislacement) {
  354. proxy._aabbMinX = aabb._minX;
  355. proxy._aabbMinY = aabb._minY;
  356. proxy._aabbMinZ = aabb._minZ;
  357. proxy._aabbMaxX = aabb._maxX;
  358. proxy._aabbMaxY = aabb._maxY;
  359. proxy._aabbMaxZ = aabb._maxZ;
  360. }
  361. collectPairs() {
  362. var p = this._proxyPairList;
  363. if(p != null) {
  364. while(true) {
  365. p._p1 = null;
  366. p._p2 = null;
  367. p = p._next;
  368. if(!(p != null)) {
  369. break;
  370. }
  371. }
  372. this._proxyPairList._next = this._proxyPairPool;
  373. this._proxyPairPool = this._proxyPairList;
  374. this._proxyPairList = null;
  375. }
  376. this._testCount = 0;
  377. var p1 = this._proxyList;
  378. while(p1 != null) {
  379. var n = p1._next;
  380. var p2 = p1._next;
  381. while(p2 != null) {
  382. var n1 = p2._next;
  383. this._testCount++;
  384. if(p1._aabbMinX < p2._aabbMaxX && p1._aabbMaxX > p2._aabbMinX && p1._aabbMinY < p2._aabbMaxY && p1._aabbMaxY > p2._aabbMinY && p1._aabbMinZ < p2._aabbMaxZ && p1._aabbMaxZ > p2._aabbMinZ) {
  385. var first = this._proxyPairPool;
  386. if(first != null) {
  387. this._proxyPairPool = first._next;
  388. first._next = null;
  389. } else {
  390. first = new oimo.collision.broadphase.ProxyPair();
  391. }
  392. var pp = first;
  393. if(this._proxyPairList == null) {
  394. this._proxyPairList = pp;
  395. } else {
  396. pp._next = this._proxyPairList;
  397. this._proxyPairList = pp;
  398. }
  399. pp._p1 = p1;
  400. pp._p2 = p2;
  401. }
  402. p2 = n1;
  403. }
  404. p1 = n;
  405. }
  406. }
  407. rayCast(begin,end,callback) {
  408. var p1;
  409. var p1X;
  410. var p1Y;
  411. var p1Z;
  412. var p2;
  413. var p2X;
  414. var p2Y;
  415. var p2Z;
  416. var dir;
  417. var dirX;
  418. var dirY;
  419. var dirZ;
  420. var v = begin;
  421. p1X = v.x;
  422. p1Y = v.y;
  423. p1Z = v.z;
  424. var v1 = end;
  425. p2X = v1.x;
  426. p2Y = v1.y;
  427. p2Z = v1.z;
  428. dirX = p2X - p1X;
  429. dirY = p2Y - p1Y;
  430. dirZ = p2Z - p1Z;
  431. var min;
  432. var minX;
  433. var minY;
  434. var minZ;
  435. var max;
  436. var maxX;
  437. var maxY;
  438. var maxZ;
  439. minX = p1X < p2X ? p1X : p2X;
  440. minY = p1Y < p2Y ? p1Y : p2Y;
  441. minZ = p1Z < p2Z ? p1Z : p2Z;
  442. maxX = p1X > p2X ? p1X : p2X;
  443. maxY = p1Y > p2Y ? p1Y : p2Y;
  444. maxZ = p1Z > p2Z ? p1Z : p2Z;
  445. var p = this._proxyList;
  446. while(p != null) {
  447. var n = p._next;
  448. var x1 = p1X;
  449. var y1 = p1Y;
  450. var z1 = p1Z;
  451. var x2 = p2X;
  452. var y2 = p2Y;
  453. var z2 = p2Z;
  454. var sminx = x1 < x2 ? x1 : x2;
  455. var sminy = y1 < y2 ? y1 : y2;
  456. var sminz = z1 < z2 ? z1 : z2;
  457. var smaxx = x1 > x2 ? x1 : x2;
  458. var smaxy = y1 > y2 ? y1 : y2;
  459. var smaxz = z1 > z2 ? z1 : z2;
  460. var pminx = p._aabbMinX;
  461. var pminy = p._aabbMinY;
  462. var pminz = p._aabbMinZ;
  463. var pmaxx = p._aabbMaxX;
  464. var pmaxy = p._aabbMaxY;
  465. var pmaxz = p._aabbMaxZ;
  466. var tmp;
  467. if(pminx > smaxx || pmaxx < sminx || pminy > smaxy || pmaxy < sminy || pminz > smaxz || pmaxz < sminz) {
  468. tmp = false;
  469. } else {
  470. var dx = x2 - x1;
  471. var dy = y2 - y1;
  472. var dz = z2 - z1;
  473. var adx = dx < 0 ? -dx : dx;
  474. var ady = dy < 0 ? -dy : dy;
  475. var adz = dz < 0 ? -dz : dz;
  476. var pextx = (pmaxx - pminx) * 0.5;
  477. var pexty = (pmaxy - pminy) * 0.5;
  478. var pextz = (pmaxz - pminz) * 0.5;
  479. var pcntx = (pmaxx + pminx) * 0.5;
  480. var pcnty = (pmaxy + pminy) * 0.5;
  481. var pcntz = (pmaxz + pminz) * 0.5;
  482. var cpx = x1 - pcntx;
  483. var cpy = y1 - pcnty;
  484. var cpz = z1 - pcntz;
  485. var tmp1;
  486. var tmp2;
  487. var x = cpy * dz - cpz * dy;
  488. if(!((x < 0 ? -x : x) - (pexty * adz + pextz * ady) > 0)) {
  489. var x3 = cpz * dx - cpx * dz;
  490. tmp2 = (x3 < 0 ? -x3 : x3) - (pextz * adx + pextx * adz) > 0;
  491. } else {
  492. tmp2 = true;
  493. }
  494. if(!tmp2) {
  495. var x4 = cpx * dy - cpy * dx;
  496. tmp1 = (x4 < 0 ? -x4 : x4) - (pextx * ady + pexty * adx) > 0;
  497. } else {
  498. tmp1 = true;
  499. }
  500. tmp = tmp1 ? false : true;
  501. }
  502. if(tmp) {
  503. callback.process(p);
  504. }
  505. p = n;
  506. }
  507. }
  508. convexCast(convex,begin,translation,callback) {
  509. var p = this._proxyList;
  510. while(p != null) {
  511. var n = p._next;
  512. var v = this._aabb.min;
  513. v.x = p._aabbMinX;
  514. v.y = p._aabbMinY;
  515. v.z = p._aabbMinZ;
  516. var v1 = this._aabb.max;
  517. v1.x = p._aabbMaxX;
  518. v1.y = p._aabbMaxY;
  519. v1.z = p._aabbMaxZ;
  520. this._convexSweep.init(convex,begin,translation);
  521. var gjkEpa = oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance;
  522. if(gjkEpa.computeClosestPointsImpl(this._convexSweep,this._aabb,begin,this.identity,null,false) == 0 && gjkEpa.distance <= 0) {
  523. callback.process(p);
  524. }
  525. p = n;
  526. }
  527. }
  528. aabbTest(aabb,callback) {
  529. var p = this._proxyList;
  530. while(p != null) {
  531. var n = p._next;
  532. if(aabb._minX < p._aabbMaxX && aabb._maxX > p._aabbMinX && aabb._minY < p._aabbMaxY && aabb._maxY > p._aabbMinY && aabb._minZ < p._aabbMaxZ && aabb._maxZ > p._aabbMinZ) {
  533. callback.process(p);
  534. }
  535. p = n;
  536. }
  537. }
  538. }
  539. if(!oimo.collision.broadphase.bvh) oimo.collision.broadphase.bvh = {};
  540. oimo.collision.broadphase.bvh.BvhBroadPhase = class oimo_collision_broadphase_bvh_BvhBroadPhase extends oimo.collision.broadphase.BroadPhase {
  541. constructor() {
  542. super(2);
  543. this._incremental = true;
  544. this._tree = new oimo.collision.broadphase.bvh.BvhTree();
  545. var this1 = new Array(1024);
  546. this.movedProxies = this1;
  547. this.numMovedProxies = 0;
  548. }
  549. collide(n1,n2) {
  550. this._testCount++;
  551. var l1 = n1._height == 0;
  552. var l2 = n2._height == 0;
  553. if(n1 == n2) {
  554. if(l1) {
  555. return;
  556. }
  557. this.collide(n1._children[0],n2);
  558. this.collide(n1._children[1],n2);
  559. return;
  560. }
  561. if(!(n1._aabbMinX < n2._aabbMaxX && n1._aabbMaxX > n2._aabbMinX && n1._aabbMinY < n2._aabbMaxY && n1._aabbMaxY > n2._aabbMinY && n1._aabbMinZ < n2._aabbMaxZ && n1._aabbMaxZ > n2._aabbMinZ)) {
  562. return;
  563. }
  564. if(l1 && l2) {
  565. var p1 = n1._proxy;
  566. var p2 = n2._proxy;
  567. var first = this._proxyPairPool;
  568. if(first != null) {
  569. this._proxyPairPool = first._next;
  570. first._next = null;
  571. } else {
  572. first = new oimo.collision.broadphase.ProxyPair();
  573. }
  574. var pp = first;
  575. if(this._proxyPairList == null) {
  576. this._proxyPairList = pp;
  577. } else {
  578. pp._next = this._proxyPairList;
  579. this._proxyPairList = pp;
  580. }
  581. pp._p1 = p1;
  582. pp._p2 = p2;
  583. return;
  584. }
  585. if(l2 || n1._height > n2._height) {
  586. this.collide(n1._children[0],n2);
  587. this.collide(n1._children[1],n2);
  588. } else {
  589. this.collide(n2._children[0],n1);
  590. this.collide(n2._children[1],n1);
  591. }
  592. }
  593. rayCastRecursive(node,_p1X,_p1Y,_p1Z,_p2X,_p2Y,_p2Z,callback) {
  594. var p1;
  595. var p1X;
  596. var p1Y;
  597. var p1Z;
  598. var p2;
  599. var p2X;
  600. var p2Y;
  601. var p2Z;
  602. p1X = _p1X;
  603. p1Y = _p1Y;
  604. p1Z = _p1Z;
  605. p2X = _p2X;
  606. p2Y = _p2Y;
  607. p2Z = _p2Z;
  608. var x1 = p1X;
  609. var y1 = p1Y;
  610. var z1 = p1Z;
  611. var x2 = p2X;
  612. var y2 = p2Y;
  613. var z2 = p2Z;
  614. var sminx = x1 < x2 ? x1 : x2;
  615. var sminy = y1 < y2 ? y1 : y2;
  616. var sminz = z1 < z2 ? z1 : z2;
  617. var smaxx = x1 > x2 ? x1 : x2;
  618. var smaxy = y1 > y2 ? y1 : y2;
  619. var smaxz = z1 > z2 ? z1 : z2;
  620. var pminx = node._aabbMinX;
  621. var pminy = node._aabbMinY;
  622. var pminz = node._aabbMinZ;
  623. var pmaxx = node._aabbMaxX;
  624. var pmaxy = node._aabbMaxY;
  625. var pmaxz = node._aabbMaxZ;
  626. var tmp;
  627. if(pminx > smaxx || pmaxx < sminx || pminy > smaxy || pmaxy < sminy || pminz > smaxz || pmaxz < sminz) {
  628. tmp = false;
  629. } else {
  630. var dx = x2 - x1;
  631. var dy = y2 - y1;
  632. var dz = z2 - z1;
  633. var adx = dx < 0 ? -dx : dx;
  634. var ady = dy < 0 ? -dy : dy;
  635. var adz = dz < 0 ? -dz : dz;
  636. var pextx = (pmaxx - pminx) * 0.5;
  637. var pexty = (pmaxy - pminy) * 0.5;
  638. var pextz = (pmaxz - pminz) * 0.5;
  639. var pcntx = (pmaxx + pminx) * 0.5;
  640. var pcnty = (pmaxy + pminy) * 0.5;
  641. var pcntz = (pmaxz + pminz) * 0.5;
  642. var cpx = x1 - pcntx;
  643. var cpy = y1 - pcnty;
  644. var cpz = z1 - pcntz;
  645. var tmp1;
  646. var tmp2;
  647. var x = cpy * dz - cpz * dy;
  648. if(!((x < 0 ? -x : x) - (pexty * adz + pextz * ady) > 0)) {
  649. var x3 = cpz * dx - cpx * dz;
  650. tmp2 = (x3 < 0 ? -x3 : x3) - (pextz * adx + pextx * adz) > 0;
  651. } else {
  652. tmp2 = true;
  653. }
  654. if(!tmp2) {
  655. var x4 = cpx * dy - cpy * dx;
  656. tmp1 = (x4 < 0 ? -x4 : x4) - (pextx * ady + pexty * adx) > 0;
  657. } else {
  658. tmp1 = true;
  659. }
  660. tmp = tmp1 ? false : true;
  661. }
  662. if(!tmp) {
  663. return;
  664. }
  665. if(node._height == 0) {
  666. callback.process(node._proxy);
  667. return;
  668. }
  669. this.rayCastRecursive(node._children[0],p1X,p1Y,p1Z,p2X,p2Y,p2Z,callback);
  670. this.rayCastRecursive(node._children[1],p1X,p1Y,p1Z,p2X,p2Y,p2Z,callback);
  671. }
  672. convexCastRecursive(node,convex,begin,translation,callback) {
  673. var v = this._aabb.min;
  674. v.x = node._aabbMinX;
  675. v.y = node._aabbMinY;
  676. v.z = node._aabbMinZ;
  677. var v1 = this._aabb.max;
  678. v1.x = node._aabbMaxX;
  679. v1.y = node._aabbMaxY;
  680. v1.z = node._aabbMaxZ;
  681. this._convexSweep.init(convex,begin,translation);
  682. var gjkEpa = oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance;
  683. if(!(gjkEpa.computeClosestPointsImpl(this._convexSweep,this._aabb,begin,this.identity,null,false) == 0 && gjkEpa.distance <= 0)) {
  684. return;
  685. }
  686. if(node._height == 0) {
  687. callback.process(node._proxy);
  688. return;
  689. }
  690. this.convexCastRecursive(node._children[0],convex,begin,translation,callback);
  691. this.convexCastRecursive(node._children[1],convex,begin,translation,callback);
  692. }
  693. aabbTestRecursive(node,aabb,callback) {
  694. if(!(node._aabbMinX < aabb._maxX && node._aabbMaxX > aabb._minX && node._aabbMinY < aabb._maxY && node._aabbMaxY > aabb._minY && node._aabbMinZ < aabb._maxZ && node._aabbMaxZ > aabb._minZ)) {
  695. return;
  696. }
  697. if(node._height == 0) {
  698. callback.process(node._proxy);
  699. return;
  700. }
  701. this.aabbTestRecursive(node._children[0],aabb,callback);
  702. this.aabbTestRecursive(node._children[1],aabb,callback);
  703. }
  704. createProxy(userData,aabb) {
  705. var p = new oimo.collision.broadphase.bvh.BvhProxy(userData,this._idCount++);
  706. this._numProxies++;
  707. if(this._proxyList == null) {
  708. this._proxyList = p;
  709. this._proxyListLast = p;
  710. } else {
  711. this._proxyListLast._next = p;
  712. p._prev = this._proxyListLast;
  713. this._proxyListLast = p;
  714. }
  715. var displacement = null;
  716. p._aabbMinX = aabb._minX;
  717. p._aabbMinY = aabb._minY;
  718. p._aabbMinZ = aabb._minZ;
  719. p._aabbMaxX = aabb._maxX;
  720. p._aabbMaxY = aabb._maxY;
  721. p._aabbMaxZ = aabb._maxZ;
  722. var padding = oimo.common.Setting.bvhProxyPadding;
  723. var paddingVec;
  724. var paddingVecX;
  725. var paddingVecY;
  726. var paddingVecZ;
  727. paddingVecX = padding;
  728. paddingVecY = padding;
  729. paddingVecZ = padding;
  730. p._aabbMinX -= paddingVecX;
  731. p._aabbMinY -= paddingVecY;
  732. p._aabbMinZ -= paddingVecZ;
  733. p._aabbMaxX += paddingVecX;
  734. p._aabbMaxY += paddingVecY;
  735. p._aabbMaxZ += paddingVecZ;
  736. if(displacement != null) {
  737. var d;
  738. var dX;
  739. var dY;
  740. var dZ;
  741. var zero;
  742. var zeroX;
  743. var zeroY;
  744. var zeroZ;
  745. var addToMin;
  746. var addToMinX;
  747. var addToMinY;
  748. var addToMinZ;
  749. var addToMax;
  750. var addToMaxX;
  751. var addToMaxY;
  752. var addToMaxZ;
  753. zeroX = 0;
  754. zeroY = 0;
  755. zeroZ = 0;
  756. var v = displacement;
  757. dX = v.x;
  758. dY = v.y;
  759. dZ = v.z;
  760. addToMinX = zeroX < dX ? zeroX : dX;
  761. addToMinY = zeroY < dY ? zeroY : dY;
  762. addToMinZ = zeroZ < dZ ? zeroZ : dZ;
  763. addToMaxX = zeroX > dX ? zeroX : dX;
  764. addToMaxY = zeroY > dY ? zeroY : dY;
  765. addToMaxZ = zeroZ > dZ ? zeroZ : dZ;
  766. p._aabbMinX += addToMinX;
  767. p._aabbMinY += addToMinY;
  768. p._aabbMinZ += addToMinZ;
  769. p._aabbMaxX += addToMaxX;
  770. p._aabbMaxY += addToMaxY;
  771. p._aabbMaxZ += addToMaxZ;
  772. }
  773. var _this = this._tree;
  774. var first = _this._nodePool;
  775. if(first != null) {
  776. _this._nodePool = first._next;
  777. first._next = null;
  778. } else {
  779. first = new oimo.collision.broadphase.bvh.BvhNode();
  780. }
  781. var leaf = first;
  782. leaf._proxy = p;
  783. p._leaf = leaf;
  784. leaf._aabbMinX = p._aabbMinX;
  785. leaf._aabbMinY = p._aabbMinY;
  786. leaf._aabbMinZ = p._aabbMinZ;
  787. leaf._aabbMaxX = p._aabbMaxX;
  788. leaf._aabbMaxY = p._aabbMaxY;
  789. leaf._aabbMaxZ = p._aabbMaxZ;
  790. _this._numLeaves++;
  791. if(_this.leafList == null) {
  792. _this.leafList = leaf;
  793. _this.leafListLast = leaf;
  794. } else {
  795. _this.leafListLast._nextLeaf = leaf;
  796. leaf._prevLeaf = _this.leafListLast;
  797. _this.leafListLast = leaf;
  798. }
  799. if(_this._root == null) {
  800. _this._root = leaf;
  801. } else {
  802. var sibling = _this._root;
  803. while(sibling._height > 0) {
  804. var nextStep = _this._strategy._decideInsertion(sibling,leaf);
  805. if(nextStep == -1) {
  806. break;
  807. } else {
  808. sibling = sibling._children[nextStep];
  809. }
  810. }
  811. var parent = sibling._parent;
  812. var first1 = _this._nodePool;
  813. if(first1 != null) {
  814. _this._nodePool = first1._next;
  815. first1._next = null;
  816. } else {
  817. first1 = new oimo.collision.broadphase.bvh.BvhNode();
  818. }
  819. var node = first1;
  820. if(parent == null) {
  821. _this._root = node;
  822. } else {
  823. var index = sibling._childIndex;
  824. parent._children[index] = node;
  825. node._parent = parent;
  826. node._childIndex = index;
  827. }
  828. var index1 = sibling._childIndex;
  829. node._children[index1] = sibling;
  830. sibling._parent = node;
  831. sibling._childIndex = index1;
  832. var index2 = sibling._childIndex ^ 1;
  833. node._children[index2] = leaf;
  834. leaf._parent = node;
  835. leaf._childIndex = index2;
  836. while(node != null) {
  837. if(_this._strategy._balancingEnabled) {
  838. var nh = node._height;
  839. if(nh < 2) {
  840. node = node;
  841. } else {
  842. var p1 = node._parent;
  843. var l = node._children[0];
  844. var r = node._children[1];
  845. var lh = l._height;
  846. var rh = r._height;
  847. var balance = lh - rh;
  848. var nodeIndex = node._childIndex;
  849. if(balance > 1) {
  850. var ll = l._children[0];
  851. var lr = l._children[1];
  852. var llh = ll._height;
  853. var lrh = lr._height;
  854. if(llh > lrh) {
  855. l._children[1] = node;
  856. node._parent = l;
  857. node._childIndex = 1;
  858. node._children[0] = lr;
  859. lr._parent = node;
  860. lr._childIndex = 0;
  861. var c1 = l._children[0];
  862. var c2 = l._children[1];
  863. l._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX;
  864. l._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY;
  865. l._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ;
  866. l._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX;
  867. l._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY;
  868. l._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ;
  869. var h1 = l._children[0]._height;
  870. var h2 = l._children[1]._height;
  871. l._height = (h1 > h2 ? h1 : h2) + 1;
  872. var c11 = node._children[0];
  873. var c21 = node._children[1];
  874. node._aabbMinX = c11._aabbMinX < c21._aabbMinX ? c11._aabbMinX : c21._aabbMinX;
  875. node._aabbMinY = c11._aabbMinY < c21._aabbMinY ? c11._aabbMinY : c21._aabbMinY;
  876. node._aabbMinZ = c11._aabbMinZ < c21._aabbMinZ ? c11._aabbMinZ : c21._aabbMinZ;
  877. node._aabbMaxX = c11._aabbMaxX > c21._aabbMaxX ? c11._aabbMaxX : c21._aabbMaxX;
  878. node._aabbMaxY = c11._aabbMaxY > c21._aabbMaxY ? c11._aabbMaxY : c21._aabbMaxY;
  879. node._aabbMaxZ = c11._aabbMaxZ > c21._aabbMaxZ ? c11._aabbMaxZ : c21._aabbMaxZ;
  880. var h11 = node._children[0]._height;
  881. var h21 = node._children[1]._height;
  882. node._height = (h11 > h21 ? h11 : h21) + 1;
  883. } else {
  884. l._children[0] = node;
  885. node._parent = l;
  886. node._childIndex = 0;
  887. node._children[0] = ll;
  888. ll._parent = node;
  889. ll._childIndex = 0;
  890. var c12 = l._children[0];
  891. var c22 = l._children[1];
  892. l._aabbMinX = c12._aabbMinX < c22._aabbMinX ? c12._aabbMinX : c22._aabbMinX;
  893. l._aabbMinY = c12._aabbMinY < c22._aabbMinY ? c12._aabbMinY : c22._aabbMinY;
  894. l._aabbMinZ = c12._aabbMinZ < c22._aabbMinZ ? c12._aabbMinZ : c22._aabbMinZ;
  895. l._aabbMaxX = c12._aabbMaxX > c22._aabbMaxX ? c12._aabbMaxX : c22._aabbMaxX;
  896. l._aabbMaxY = c12._aabbMaxY > c22._aabbMaxY ? c12._aabbMaxY : c22._aabbMaxY;
  897. l._aabbMaxZ = c12._aabbMaxZ > c22._aabbMaxZ ? c12._aabbMaxZ : c22._aabbMaxZ;
  898. var h12 = l._children[0]._height;
  899. var h22 = l._children[1]._height;
  900. l._height = (h12 > h22 ? h12 : h22) + 1;
  901. var c13 = node._children[0];
  902. var c23 = node._children[1];
  903. node._aabbMinX = c13._aabbMinX < c23._aabbMinX ? c13._aabbMinX : c23._aabbMinX;
  904. node._aabbMinY = c13._aabbMinY < c23._aabbMinY ? c13._aabbMinY : c23._aabbMinY;
  905. node._aabbMinZ = c13._aabbMinZ < c23._aabbMinZ ? c13._aabbMinZ : c23._aabbMinZ;
  906. node._aabbMaxX = c13._aabbMaxX > c23._aabbMaxX ? c13._aabbMaxX : c23._aabbMaxX;
  907. node._aabbMaxY = c13._aabbMaxY > c23._aabbMaxY ? c13._aabbMaxY : c23._aabbMaxY;
  908. node._aabbMaxZ = c13._aabbMaxZ > c23._aabbMaxZ ? c13._aabbMaxZ : c23._aabbMaxZ;
  909. var h13 = node._children[0]._height;
  910. var h23 = node._children[1]._height;
  911. node._height = (h13 > h23 ? h13 : h23) + 1;
  912. }
  913. if(p1 != null) {
  914. p1._children[nodeIndex] = l;
  915. l._parent = p1;
  916. l._childIndex = nodeIndex;
  917. } else {
  918. _this._root = l;
  919. l._parent = null;
  920. }
  921. node = l;
  922. } else if(balance < -1) {
  923. var rl = r._children[0];
  924. var rr = r._children[1];
  925. var rlh = rl._height;
  926. var rrh = rr._height;
  927. if(rlh > rrh) {
  928. r._children[1] = node;
  929. node._parent = r;
  930. node._childIndex = 1;
  931. node._children[1] = rr;
  932. rr._parent = node;
  933. rr._childIndex = 1;
  934. var c14 = r._children[0];
  935. var c24 = r._children[1];
  936. r._aabbMinX = c14._aabbMinX < c24._aabbMinX ? c14._aabbMinX : c24._aabbMinX;
  937. r._aabbMinY = c14._aabbMinY < c24._aabbMinY ? c14._aabbMinY : c24._aabbMinY;
  938. r._aabbMinZ = c14._aabbMinZ < c24._aabbMinZ ? c14._aabbMinZ : c24._aabbMinZ;
  939. r._aabbMaxX = c14._aabbMaxX > c24._aabbMaxX ? c14._aabbMaxX : c24._aabbMaxX;
  940. r._aabbMaxY = c14._aabbMaxY > c24._aabbMaxY ? c14._aabbMaxY : c24._aabbMaxY;
  941. r._aabbMaxZ = c14._aabbMaxZ > c24._aabbMaxZ ? c14._aabbMaxZ : c24._aabbMaxZ;
  942. var h14 = r._children[0]._height;
  943. var h24 = r._children[1]._height;
  944. r._height = (h14 > h24 ? h14 : h24) + 1;
  945. var c15 = node._children[0];
  946. var c25 = node._children[1];
  947. node._aabbMinX = c15._aabbMinX < c25._aabbMinX ? c15._aabbMinX : c25._aabbMinX;
  948. node._aabbMinY = c15._aabbMinY < c25._aabbMinY ? c15._aabbMinY : c25._aabbMinY;
  949. node._aabbMinZ = c15._aabbMinZ < c25._aabbMinZ ? c15._aabbMinZ : c25._aabbMinZ;
  950. node._aabbMaxX = c15._aabbMaxX > c25._aabbMaxX ? c15._aabbMaxX : c25._aabbMaxX;
  951. node._aabbMaxY = c15._aabbMaxY > c25._aabbMaxY ? c15._aabbMaxY : c25._aabbMaxY;
  952. node._aabbMaxZ = c15._aabbMaxZ > c25._aabbMaxZ ? c15._aabbMaxZ : c25._aabbMaxZ;
  953. var h15 = node._children[0]._height;
  954. var h25 = node._children[1]._height;
  955. node._height = (h15 > h25 ? h15 : h25) + 1;
  956. } else {
  957. r._children[0] = node;
  958. node._parent = r;
  959. node._childIndex = 0;
  960. node._children[1] = rl;
  961. rl._parent = node;
  962. rl._childIndex = 1;
  963. var c16 = r._children[0];
  964. var c26 = r._children[1];
  965. r._aabbMinX = c16._aabbMinX < c26._aabbMinX ? c16._aabbMinX : c26._aabbMinX;
  966. r._aabbMinY = c16._aabbMinY < c26._aabbMinY ? c16._aabbMinY : c26._aabbMinY;
  967. r._aabbMinZ = c16._aabbMinZ < c26._aabbMinZ ? c16._aabbMinZ : c26._aabbMinZ;
  968. r._aabbMaxX = c16._aabbMaxX > c26._aabbMaxX ? c16._aabbMaxX : c26._aabbMaxX;
  969. r._aabbMaxY = c16._aabbMaxY > c26._aabbMaxY ? c16._aabbMaxY : c26._aabbMaxY;
  970. r._aabbMaxZ = c16._aabbMaxZ > c26._aabbMaxZ ? c16._aabbMaxZ : c26._aabbMaxZ;
  971. var h16 = r._children[0]._height;
  972. var h26 = r._children[1]._height;
  973. r._height = (h16 > h26 ? h16 : h26) + 1;
  974. var c17 = node._children[0];
  975. var c27 = node._children[1];
  976. node._aabbMinX = c17._aabbMinX < c27._aabbMinX ? c17._aabbMinX : c27._aabbMinX;
  977. node._aabbMinY = c17._aabbMinY < c27._aabbMinY ? c17._aabbMinY : c27._aabbMinY;
  978. node._aabbMinZ = c17._aabbMinZ < c27._aabbMinZ ? c17._aabbMinZ : c27._aabbMinZ;
  979. node._aabbMaxX = c17._aabbMaxX > c27._aabbMaxX ? c17._aabbMaxX : c27._aabbMaxX;
  980. node._aabbMaxY = c17._aabbMaxY > c27._aabbMaxY ? c17._aabbMaxY : c27._aabbMaxY;
  981. node._aabbMaxZ = c17._aabbMaxZ > c27._aabbMaxZ ? c17._aabbMaxZ : c27._aabbMaxZ;
  982. var h17 = node._children[0]._height;
  983. var h27 = node._children[1]._height;
  984. node._height = (h17 > h27 ? h17 : h27) + 1;
  985. }
  986. if(p1 != null) {
  987. p1._children[nodeIndex] = r;
  988. r._parent = p1;
  989. r._childIndex = nodeIndex;
  990. } else {
  991. _this._root = r;
  992. r._parent = null;
  993. }
  994. node = r;
  995. } else {
  996. node = node;
  997. }
  998. }
  999. }
  1000. var h18 = node._children[0]._height;
  1001. var h28 = node._children[1]._height;
  1002. node._height = (h18 > h28 ? h18 : h28) + 1;
  1003. var c18 = node._children[0];
  1004. var c28 = node._children[1];
  1005. node._aabbMinX = c18._aabbMinX < c28._aabbMinX ? c18._aabbMinX : c28._aabbMinX;
  1006. node._aabbMinY = c18._aabbMinY < c28._aabbMinY ? c18._aabbMinY : c28._aabbMinY;
  1007. node._aabbMinZ = c18._aabbMinZ < c28._aabbMinZ ? c18._aabbMinZ : c28._aabbMinZ;
  1008. node._aabbMaxX = c18._aabbMaxX > c28._aabbMaxX ? c18._aabbMaxX : c28._aabbMaxX;
  1009. node._aabbMaxY = c18._aabbMaxY > c28._aabbMaxY ? c18._aabbMaxY : c28._aabbMaxY;
  1010. node._aabbMaxZ = c18._aabbMaxZ > c28._aabbMaxZ ? c18._aabbMaxZ : c28._aabbMaxZ;
  1011. node = node._parent;
  1012. }
  1013. }
  1014. if(!p._moved) {
  1015. p._moved = true;
  1016. if(this.movedProxies.length == this.numMovedProxies) {
  1017. var newLength = this.numMovedProxies << 1;
  1018. var this1 = new Array(newLength);
  1019. var newArray = this1;
  1020. var _g = 0;
  1021. var _g1 = this.numMovedProxies;
  1022. while(_g < _g1) {
  1023. var i = _g++;
  1024. newArray[i] = this.movedProxies[i];
  1025. this.movedProxies[i] = null;
  1026. }
  1027. this.movedProxies = newArray;
  1028. }
  1029. this.movedProxies[this.numMovedProxies++] = p;
  1030. }
  1031. return p;
  1032. }
  1033. destroyProxy(proxy) {
  1034. this._numProxies--;
  1035. var prev = proxy._prev;
  1036. var next = proxy._next;
  1037. if(prev != null) {
  1038. prev._next = next;
  1039. }
  1040. if(next != null) {
  1041. next._prev = prev;
  1042. }
  1043. if(proxy == this._proxyList) {
  1044. this._proxyList = this._proxyList._next;
  1045. }
  1046. if(proxy == this._proxyListLast) {
  1047. this._proxyListLast = this._proxyListLast._prev;
  1048. }
  1049. proxy._next = null;
  1050. proxy._prev = null;
  1051. var bvhProxy = proxy;
  1052. var _this = this._tree;
  1053. var leaf = bvhProxy._leaf;
  1054. _this._numLeaves--;
  1055. var prev1 = leaf._prevLeaf;
  1056. var next1 = leaf._nextLeaf;
  1057. if(prev1 != null) {
  1058. prev1._nextLeaf = next1;
  1059. }
  1060. if(next1 != null) {
  1061. next1._prevLeaf = prev1;
  1062. }
  1063. if(leaf == _this.leafList) {
  1064. _this.leafList = _this.leafList._nextLeaf;
  1065. }
  1066. if(leaf == _this.leafListLast) {
  1067. _this.leafListLast = _this.leafListLast._prevLeaf;
  1068. }
  1069. leaf._nextLeaf = null;
  1070. leaf._prevLeaf = null;
  1071. if(_this._root == leaf) {
  1072. _this._root = null;
  1073. } else {
  1074. var parent = leaf._parent;
  1075. var sibling = parent._children[leaf._childIndex ^ 1];
  1076. var grandParent = parent._parent;
  1077. if(grandParent == null) {
  1078. sibling._parent = null;
  1079. sibling._childIndex = 0;
  1080. _this._root = sibling;
  1081. parent._next = null;
  1082. parent._childIndex = 0;
  1083. parent._children[0] = null;
  1084. parent._children[1] = null;
  1085. parent._childIndex = 0;
  1086. parent._parent = null;
  1087. parent._height = 0;
  1088. parent._proxy = null;
  1089. parent._next = _this._nodePool;
  1090. _this._nodePool = parent;
  1091. } else {
  1092. sibling._parent = grandParent;
  1093. var index = parent._childIndex;
  1094. grandParent._children[index] = sibling;
  1095. sibling._parent = grandParent;
  1096. sibling._childIndex = index;
  1097. parent._next = null;
  1098. parent._childIndex = 0;
  1099. parent._children[0] = null;
  1100. parent._children[1] = null;
  1101. parent._childIndex = 0;
  1102. parent._parent = null;
  1103. parent._height = 0;
  1104. parent._proxy = null;
  1105. parent._next = _this._nodePool;
  1106. _this._nodePool = parent;
  1107. var node = grandParent;
  1108. while(node != null) {
  1109. if(_this._strategy._balancingEnabled) {
  1110. var nh = node._height;
  1111. if(nh < 2) {
  1112. node = node;
  1113. } else {
  1114. var p = node._parent;
  1115. var l = node._children[0];
  1116. var r = node._children[1];
  1117. var lh = l._height;
  1118. var rh = r._height;
  1119. var balance = lh - rh;
  1120. var nodeIndex = node._childIndex;
  1121. if(balance > 1) {
  1122. var ll = l._children[0];
  1123. var lr = l._children[1];
  1124. var llh = ll._height;
  1125. var lrh = lr._height;
  1126. if(llh > lrh) {
  1127. l._children[1] = node;
  1128. node._parent = l;
  1129. node._childIndex = 1;
  1130. node._children[0] = lr;
  1131. lr._parent = node;
  1132. lr._childIndex = 0;
  1133. var c1 = l._children[0];
  1134. var c2 = l._children[1];
  1135. l._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX;
  1136. l._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY;
  1137. l._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ;
  1138. l._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX;
  1139. l._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY;
  1140. l._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ;
  1141. var h1 = l._children[0]._height;
  1142. var h2 = l._children[1]._height;
  1143. l._height = (h1 > h2 ? h1 : h2) + 1;
  1144. var c11 = node._children[0];
  1145. var c21 = node._children[1];
  1146. node._aabbMinX = c11._aabbMinX < c21._aabbMinX ? c11._aabbMinX : c21._aabbMinX;
  1147. node._aabbMinY = c11._aabbMinY < c21._aabbMinY ? c11._aabbMinY : c21._aabbMinY;
  1148. node._aabbMinZ = c11._aabbMinZ < c21._aabbMinZ ? c11._aabbMinZ : c21._aabbMinZ;
  1149. node._aabbMaxX = c11._aabbMaxX > c21._aabbMaxX ? c11._aabbMaxX : c21._aabbMaxX;
  1150. node._aabbMaxY = c11._aabbMaxY > c21._aabbMaxY ? c11._aabbMaxY : c21._aabbMaxY;
  1151. node._aabbMaxZ = c11._aabbMaxZ > c21._aabbMaxZ ? c11._aabbMaxZ : c21._aabbMaxZ;
  1152. var h11 = node._children[0]._height;
  1153. var h21 = node._children[1]._height;
  1154. node._height = (h11 > h21 ? h11 : h21) + 1;
  1155. } else {
  1156. l._children[0] = node;
  1157. node._parent = l;
  1158. node._childIndex = 0;
  1159. node._children[0] = ll;
  1160. ll._parent = node;
  1161. ll._childIndex = 0;
  1162. var c12 = l._children[0];
  1163. var c22 = l._children[1];
  1164. l._aabbMinX = c12._aabbMinX < c22._aabbMinX ? c12._aabbMinX : c22._aabbMinX;
  1165. l._aabbMinY = c12._aabbMinY < c22._aabbMinY ? c12._aabbMinY : c22._aabbMinY;
  1166. l._aabbMinZ = c12._aabbMinZ < c22._aabbMinZ ? c12._aabbMinZ : c22._aabbMinZ;
  1167. l._aabbMaxX = c12._aabbMaxX > c22._aabbMaxX ? c12._aabbMaxX : c22._aabbMaxX;
  1168. l._aabbMaxY = c12._aabbMaxY > c22._aabbMaxY ? c12._aabbMaxY : c22._aabbMaxY;
  1169. l._aabbMaxZ = c12._aabbMaxZ > c22._aabbMaxZ ? c12._aabbMaxZ : c22._aabbMaxZ;
  1170. var h12 = l._children[0]._height;
  1171. var h22 = l._children[1]._height;
  1172. l._height = (h12 > h22 ? h12 : h22) + 1;
  1173. var c13 = node._children[0];
  1174. var c23 = node._children[1];
  1175. node._aabbMinX = c13._aabbMinX < c23._aabbMinX ? c13._aabbMinX : c23._aabbMinX;
  1176. node._aabbMinY = c13._aabbMinY < c23._aabbMinY ? c13._aabbMinY : c23._aabbMinY;
  1177. node._aabbMinZ = c13._aabbMinZ < c23._aabbMinZ ? c13._aabbMinZ : c23._aabbMinZ;
  1178. node._aabbMaxX = c13._aabbMaxX > c23._aabbMaxX ? c13._aabbMaxX : c23._aabbMaxX;
  1179. node._aabbMaxY = c13._aabbMaxY > c23._aabbMaxY ? c13._aabbMaxY : c23._aabbMaxY;
  1180. node._aabbMaxZ = c13._aabbMaxZ > c23._aabbMaxZ ? c13._aabbMaxZ : c23._aabbMaxZ;
  1181. var h13 = node._children[0]._height;
  1182. var h23 = node._children[1]._height;
  1183. node._height = (h13 > h23 ? h13 : h23) + 1;
  1184. }
  1185. if(p != null) {
  1186. p._children[nodeIndex] = l;
  1187. l._parent = p;
  1188. l._childIndex = nodeIndex;
  1189. } else {
  1190. _this._root = l;
  1191. l._parent = null;
  1192. }
  1193. node = l;
  1194. } else if(balance < -1) {
  1195. var rl = r._children[0];
  1196. var rr = r._children[1];
  1197. var rlh = rl._height;
  1198. var rrh = rr._height;
  1199. if(rlh > rrh) {
  1200. r._children[1] = node;
  1201. node._parent = r;
  1202. node._childIndex = 1;
  1203. node._children[1] = rr;
  1204. rr._parent = node;
  1205. rr._childIndex = 1;
  1206. var c14 = r._children[0];
  1207. var c24 = r._children[1];
  1208. r._aabbMinX = c14._aabbMinX < c24._aabbMinX ? c14._aabbMinX : c24._aabbMinX;
  1209. r._aabbMinY = c14._aabbMinY < c24._aabbMinY ? c14._aabbMinY : c24._aabbMinY;
  1210. r._aabbMinZ = c14._aabbMinZ < c24._aabbMinZ ? c14._aabbMinZ : c24._aabbMinZ;
  1211. r._aabbMaxX = c14._aabbMaxX > c24._aabbMaxX ? c14._aabbMaxX : c24._aabbMaxX;
  1212. r._aabbMaxY = c14._aabbMaxY > c24._aabbMaxY ? c14._aabbMaxY : c24._aabbMaxY;
  1213. r._aabbMaxZ = c14._aabbMaxZ > c24._aabbMaxZ ? c14._aabbMaxZ : c24._aabbMaxZ;
  1214. var h14 = r._children[0]._height;
  1215. var h24 = r._children[1]._height;
  1216. r._height = (h14 > h24 ? h14 : h24) + 1;
  1217. var c15 = node._children[0];
  1218. var c25 = node._children[1];
  1219. node._aabbMinX = c15._aabbMinX < c25._aabbMinX ? c15._aabbMinX : c25._aabbMinX;
  1220. node._aabbMinY = c15._aabbMinY < c25._aabbMinY ? c15._aabbMinY : c25._aabbMinY;
  1221. node._aabbMinZ = c15._aabbMinZ < c25._aabbMinZ ? c15._aabbMinZ : c25._aabbMinZ;
  1222. node._aabbMaxX = c15._aabbMaxX > c25._aabbMaxX ? c15._aabbMaxX : c25._aabbMaxX;
  1223. node._aabbMaxY = c15._aabbMaxY > c25._aabbMaxY ? c15._aabbMaxY : c25._aabbMaxY;
  1224. node._aabbMaxZ = c15._aabbMaxZ > c25._aabbMaxZ ? c15._aabbMaxZ : c25._aabbMaxZ;
  1225. var h15 = node._children[0]._height;
  1226. var h25 = node._children[1]._height;
  1227. node._height = (h15 > h25 ? h15 : h25) + 1;
  1228. } else {
  1229. r._children[0] = node;
  1230. node._parent = r;
  1231. node._childIndex = 0;
  1232. node._children[1] = rl;
  1233. rl._parent = node;
  1234. rl._childIndex = 1;
  1235. var c16 = r._children[0];
  1236. var c26 = r._children[1];
  1237. r._aabbMinX = c16._aabbMinX < c26._aabbMinX ? c16._aabbMinX : c26._aabbMinX;
  1238. r._aabbMinY = c16._aabbMinY < c26._aabbMinY ? c16._aabbMinY : c26._aabbMinY;
  1239. r._aabbMinZ = c16._aabbMinZ < c26._aabbMinZ ? c16._aabbMinZ : c26._aabbMinZ;
  1240. r._aabbMaxX = c16._aabbMaxX > c26._aabbMaxX ? c16._aabbMaxX : c26._aabbMaxX;
  1241. r._aabbMaxY = c16._aabbMaxY > c26._aabbMaxY ? c16._aabbMaxY : c26._aabbMaxY;
  1242. r._aabbMaxZ = c16._aabbMaxZ > c26._aabbMaxZ ? c16._aabbMaxZ : c26._aabbMaxZ;
  1243. var h16 = r._children[0]._height;
  1244. var h26 = r._children[1]._height;
  1245. r._height = (h16 > h26 ? h16 : h26) + 1;
  1246. var c17 = node._children[0];
  1247. var c27 = node._children[1];
  1248. node._aabbMinX = c17._aabbMinX < c27._aabbMinX ? c17._aabbMinX : c27._aabbMinX;
  1249. node._aabbMinY = c17._aabbMinY < c27._aabbMinY ? c17._aabbMinY : c27._aabbMinY;
  1250. node._aabbMinZ = c17._aabbMinZ < c27._aabbMinZ ? c17._aabbMinZ : c27._aabbMinZ;
  1251. node._aabbMaxX = c17._aabbMaxX > c27._aabbMaxX ? c17._aabbMaxX : c27._aabbMaxX;
  1252. node._aabbMaxY = c17._aabbMaxY > c27._aabbMaxY ? c17._aabbMaxY : c27._aabbMaxY;
  1253. node._aabbMaxZ = c17._aabbMaxZ > c27._aabbMaxZ ? c17._aabbMaxZ : c27._aabbMaxZ;
  1254. var h17 = node._children[0]._height;
  1255. var h27 = node._children[1]._height;
  1256. node._height = (h17 > h27 ? h17 : h27) + 1;
  1257. }
  1258. if(p != null) {
  1259. p._children[nodeIndex] = r;
  1260. r._parent = p;
  1261. r._childIndex = nodeIndex;
  1262. } else {
  1263. _this._root = r;
  1264. r._parent = null;
  1265. }
  1266. node = r;
  1267. } else {
  1268. node = node;
  1269. }
  1270. }
  1271. }
  1272. var h18 = node._children[0]._height;
  1273. var h28 = node._children[1]._height;
  1274. node._height = (h18 > h28 ? h18 : h28) + 1;
  1275. var c18 = node._children[0];
  1276. var c28 = node._children[1];
  1277. node._aabbMinX = c18._aabbMinX < c28._aabbMinX ? c18._aabbMinX : c28._aabbMinX;
  1278. node._aabbMinY = c18._aabbMinY < c28._aabbMinY ? c18._aabbMinY : c28._aabbMinY;
  1279. node._aabbMinZ = c18._aabbMinZ < c28._aabbMinZ ? c18._aabbMinZ : c28._aabbMinZ;
  1280. node._aabbMaxX = c18._aabbMaxX > c28._aabbMaxX ? c18._aabbMaxX : c28._aabbMaxX;
  1281. node._aabbMaxY = c18._aabbMaxY > c28._aabbMaxY ? c18._aabbMaxY : c28._aabbMaxY;
  1282. node._aabbMaxZ = c18._aabbMaxZ > c28._aabbMaxZ ? c18._aabbMaxZ : c28._aabbMaxZ;
  1283. node = node._parent;
  1284. }
  1285. }
  1286. }
  1287. bvhProxy._leaf = null;
  1288. leaf._next = null;
  1289. leaf._childIndex = 0;
  1290. leaf._children[0] = null;
  1291. leaf._children[1] = null;
  1292. leaf._childIndex = 0;
  1293. leaf._parent = null;
  1294. leaf._height = 0;
  1295. leaf._proxy = null;
  1296. leaf._next = _this._nodePool;
  1297. _this._nodePool = leaf;
  1298. bvhProxy.userData = null;
  1299. bvhProxy._next = null;
  1300. bvhProxy._prev = null;
  1301. if(bvhProxy._moved) {
  1302. bvhProxy._moved = false;
  1303. }
  1304. }
  1305. moveProxy(proxy,aabb,displacement) {
  1306. var p = proxy;
  1307. if(p._aabbMinX <= aabb._minX && p._aabbMaxX >= aabb._maxX && p._aabbMinY <= aabb._minY && p._aabbMaxY >= aabb._maxY && p._aabbMinZ <= aabb._minZ && p._aabbMaxZ >= aabb._maxZ) {
  1308. return;
  1309. }
  1310. p._aabbMinX = aabb._minX;
  1311. p._aabbMinY = aabb._minY;
  1312. p._aabbMinZ = aabb._minZ;
  1313. p._aabbMaxX = aabb._maxX;
  1314. p._aabbMaxY = aabb._maxY;
  1315. p._aabbMaxZ = aabb._maxZ;
  1316. var padding = oimo.common.Setting.bvhProxyPadding;
  1317. var paddingVec;
  1318. var paddingVecX;
  1319. var paddingVecY;
  1320. var paddingVecZ;
  1321. paddingVecX = padding;
  1322. paddingVecY = padding;
  1323. paddingVecZ = padding;
  1324. p._aabbMinX -= paddingVecX;
  1325. p._aabbMinY -= paddingVecY;
  1326. p._aabbMinZ -= paddingVecZ;
  1327. p._aabbMaxX += paddingVecX;
  1328. p._aabbMaxY += paddingVecY;
  1329. p._aabbMaxZ += paddingVecZ;
  1330. if(displacement != null) {
  1331. var d;
  1332. var dX;
  1333. var dY;
  1334. var dZ;
  1335. var zero;
  1336. var zeroX;
  1337. var zeroY;
  1338. var zeroZ;
  1339. var addToMin;
  1340. var addToMinX;
  1341. var addToMinY;
  1342. var addToMinZ;
  1343. var addToMax;
  1344. var addToMaxX;
  1345. var addToMaxY;
  1346. var addToMaxZ;
  1347. zeroX = 0;
  1348. zeroY = 0;
  1349. zeroZ = 0;
  1350. var v = displacement;
  1351. dX = v.x;
  1352. dY = v.y;
  1353. dZ = v.z;
  1354. addToMinX = zeroX < dX ? zeroX : dX;
  1355. addToMinY = zeroY < dY ? zeroY : dY;
  1356. addToMinZ = zeroZ < dZ ? zeroZ : dZ;
  1357. addToMaxX = zeroX > dX ? zeroX : dX;
  1358. addToMaxY = zeroY > dY ? zeroY : dY;
  1359. addToMaxZ = zeroZ > dZ ? zeroZ : dZ;
  1360. p._aabbMinX += addToMinX;
  1361. p._aabbMinY += addToMinY;
  1362. p._aabbMinZ += addToMinZ;
  1363. p._aabbMaxX += addToMaxX;
  1364. p._aabbMaxY += addToMaxY;
  1365. p._aabbMaxZ += addToMaxZ;
  1366. }
  1367. if(!p._moved) {
  1368. p._moved = true;
  1369. if(this.movedProxies.length == this.numMovedProxies) {
  1370. var newLength = this.numMovedProxies << 1;
  1371. var this1 = new Array(newLength);
  1372. var newArray = this1;
  1373. var _g = 0;
  1374. var _g1 = this.numMovedProxies;
  1375. while(_g < _g1) {
  1376. var i = _g++;
  1377. newArray[i] = this.movedProxies[i];
  1378. this.movedProxies[i] = null;
  1379. }
  1380. this.movedProxies = newArray;
  1381. }
  1382. this.movedProxies[this.numMovedProxies++] = p;
  1383. }
  1384. }
  1385. collectPairs() {
  1386. var p = this._proxyPairList;
  1387. if(p != null) {
  1388. while(true) {
  1389. p._p1 = null;
  1390. p._p2 = null;
  1391. p = p._next;
  1392. if(!(p != null)) {
  1393. break;
  1394. }
  1395. }
  1396. this._proxyPairList._next = this._proxyPairPool;
  1397. this._proxyPairPool = this._proxyPairList;
  1398. this._proxyPairList = null;
  1399. }
  1400. this._testCount = 0;
  1401. if(this._numProxies < 2) {
  1402. return;
  1403. }
  1404. var topDown = false;
  1405. if(topDown) {
  1406. while(this.numMovedProxies > 0) this.movedProxies[--this.numMovedProxies] = null;
  1407. var _this = this._tree;
  1408. if(_this._root != null) {
  1409. if(_this._root != null) {
  1410. _this.decomposeRecursive(_this._root);
  1411. _this._root = null;
  1412. }
  1413. while(_this.tmp.length < _this._numLeaves) {
  1414. var newLength = _this.tmp.length << 1;
  1415. var this1 = new Array(newLength);
  1416. var newArray = this1;
  1417. var _g = 0;
  1418. var _g1 = _this.tmp.length;
  1419. while(_g < _g1) {
  1420. var i = _g++;
  1421. newArray[i] = _this.tmp[i];
  1422. _this.tmp[i] = null;
  1423. }
  1424. _this.tmp = newArray;
  1425. }
  1426. var idx = 0;
  1427. var leaf = _this.leafList;
  1428. while(leaf != null) {
  1429. var n = leaf._nextLeaf;
  1430. _this.tmp[idx] = leaf;
  1431. ++idx;
  1432. leaf = n;
  1433. }
  1434. _this._root = _this.buildTopDownRecursive(_this.tmp,0,_this._numLeaves);
  1435. }
  1436. this.collide(this._tree._root,this._tree._root);
  1437. return;
  1438. }
  1439. var incrementalCollision = this.numMovedProxies / this._numProxies < oimo.common.Setting.bvhIncrementalCollisionThreshold;
  1440. var _g2 = 0;
  1441. var _g11 = this.numMovedProxies;
  1442. while(_g2 < _g11) {
  1443. var i1 = _g2++;
  1444. var p1 = this.movedProxies[i1];
  1445. if(p1._moved) {
  1446. var _this1 = this._tree;
  1447. var leaf1 = p1._leaf;
  1448. _this1._numLeaves--;
  1449. var prev = leaf1._prevLeaf;
  1450. var next = leaf1._nextLeaf;
  1451. if(prev != null) {
  1452. prev._nextLeaf = next;
  1453. }
  1454. if(next != null) {
  1455. next._prevLeaf = prev;
  1456. }
  1457. if(leaf1 == _this1.leafList) {
  1458. _this1.leafList = _this1.leafList._nextLeaf;
  1459. }
  1460. if(leaf1 == _this1.leafListLast) {
  1461. _this1.leafListLast = _this1.leafListLast._prevLeaf;
  1462. }
  1463. leaf1._nextLeaf = null;
  1464. leaf1._prevLeaf = null;
  1465. if(_this1._root == leaf1) {
  1466. _this1._root = null;
  1467. } else {
  1468. var parent = leaf1._parent;
  1469. var sibling = parent._children[leaf1._childIndex ^ 1];
  1470. var grandParent = parent._parent;
  1471. if(grandParent == null) {
  1472. sibling._parent = null;
  1473. sibling._childIndex = 0;
  1474. _this1._root = sibling;
  1475. parent._next = null;
  1476. parent._childIndex = 0;
  1477. parent._children[0] = null;
  1478. parent._children[1] = null;
  1479. parent._childIndex = 0;
  1480. parent._parent = null;
  1481. parent._height = 0;
  1482. parent._proxy = null;
  1483. parent._next = _this1._nodePool;
  1484. _this1._nodePool = parent;
  1485. } else {
  1486. sibling._parent = grandParent;
  1487. var index = parent._childIndex;
  1488. grandParent._children[index] = sibling;
  1489. sibling._parent = grandParent;
  1490. sibling._childIndex = index;
  1491. parent._next = null;
  1492. parent._childIndex = 0;
  1493. parent._children[0] = null;
  1494. parent._children[1] = null;
  1495. parent._childIndex = 0;
  1496. parent._parent = null;
  1497. parent._height = 0;
  1498. parent._proxy = null;
  1499. parent._next = _this1._nodePool;
  1500. _this1._nodePool = parent;
  1501. var node = grandParent;
  1502. while(node != null) {
  1503. if(_this1._strategy._balancingEnabled) {
  1504. var nh = node._height;
  1505. if(nh < 2) {
  1506. node = node;
  1507. } else {
  1508. var p2 = node._parent;
  1509. var l = node._children[0];
  1510. var r = node._children[1];
  1511. var lh = l._height;
  1512. var rh = r._height;
  1513. var balance = lh - rh;
  1514. var nodeIndex = node._childIndex;
  1515. if(balance > 1) {
  1516. var ll = l._children[0];
  1517. var lr = l._children[1];
  1518. var llh = ll._height;
  1519. var lrh = lr._height;
  1520. if(llh > lrh) {
  1521. l._children[1] = node;
  1522. node._parent = l;
  1523. node._childIndex = 1;
  1524. node._children[0] = lr;
  1525. lr._parent = node;
  1526. lr._childIndex = 0;
  1527. var c1 = l._children[0];
  1528. var c2 = l._children[1];
  1529. l._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX;
  1530. l._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY;
  1531. l._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ;
  1532. l._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX;
  1533. l._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY;
  1534. l._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ;
  1535. var h1 = l._children[0]._height;
  1536. var h2 = l._children[1]._height;
  1537. l._height = (h1 > h2 ? h1 : h2) + 1;
  1538. var c11 = node._children[0];
  1539. var c21 = node._children[1];
  1540. node._aabbMinX = c11._aabbMinX < c21._aabbMinX ? c11._aabbMinX : c21._aabbMinX;
  1541. node._aabbMinY = c11._aabbMinY < c21._aabbMinY ? c11._aabbMinY : c21._aabbMinY;
  1542. node._aabbMinZ = c11._aabbMinZ < c21._aabbMinZ ? c11._aabbMinZ : c21._aabbMinZ;
  1543. node._aabbMaxX = c11._aabbMaxX > c21._aabbMaxX ? c11._aabbMaxX : c21._aabbMaxX;
  1544. node._aabbMaxY = c11._aabbMaxY > c21._aabbMaxY ? c11._aabbMaxY : c21._aabbMaxY;
  1545. node._aabbMaxZ = c11._aabbMaxZ > c21._aabbMaxZ ? c11._aabbMaxZ : c21._aabbMaxZ;
  1546. var h11 = node._children[0]._height;
  1547. var h21 = node._children[1]._height;
  1548. node._height = (h11 > h21 ? h11 : h21) + 1;
  1549. } else {
  1550. l._children[0] = node;
  1551. node._parent = l;
  1552. node._childIndex = 0;
  1553. node._children[0] = ll;
  1554. ll._parent = node;
  1555. ll._childIndex = 0;
  1556. var c12 = l._children[0];
  1557. var c22 = l._children[1];
  1558. l._aabbMinX = c12._aabbMinX < c22._aabbMinX ? c12._aabbMinX : c22._aabbMinX;
  1559. l._aabbMinY = c12._aabbMinY < c22._aabbMinY ? c12._aabbMinY : c22._aabbMinY;
  1560. l._aabbMinZ = c12._aabbMinZ < c22._aabbMinZ ? c12._aabbMinZ : c22._aabbMinZ;
  1561. l._aabbMaxX = c12._aabbMaxX > c22._aabbMaxX ? c12._aabbMaxX : c22._aabbMaxX;
  1562. l._aabbMaxY = c12._aabbMaxY > c22._aabbMaxY ? c12._aabbMaxY : c22._aabbMaxY;
  1563. l._aabbMaxZ = c12._aabbMaxZ > c22._aabbMaxZ ? c12._aabbMaxZ : c22._aabbMaxZ;
  1564. var h12 = l._children[0]._height;
  1565. var h22 = l._children[1]._height;
  1566. l._height = (h12 > h22 ? h12 : h22) + 1;
  1567. var c13 = node._children[0];
  1568. var c23 = node._children[1];
  1569. node._aabbMinX = c13._aabbMinX < c23._aabbMinX ? c13._aabbMinX : c23._aabbMinX;
  1570. node._aabbMinY = c13._aabbMinY < c23._aabbMinY ? c13._aabbMinY : c23._aabbMinY;
  1571. node._aabbMinZ = c13._aabbMinZ < c23._aabbMinZ ? c13._aabbMinZ : c23._aabbMinZ;
  1572. node._aabbMaxX = c13._aabbMaxX > c23._aabbMaxX ? c13._aabbMaxX : c23._aabbMaxX;
  1573. node._aabbMaxY = c13._aabbMaxY > c23._aabbMaxY ? c13._aabbMaxY : c23._aabbMaxY;
  1574. node._aabbMaxZ = c13._aabbMaxZ > c23._aabbMaxZ ? c13._aabbMaxZ : c23._aabbMaxZ;
  1575. var h13 = node._children[0]._height;
  1576. var h23 = node._children[1]._height;
  1577. node._height = (h13 > h23 ? h13 : h23) + 1;
  1578. }
  1579. if(p2 != null) {
  1580. p2._children[nodeIndex] = l;
  1581. l._parent = p2;
  1582. l._childIndex = nodeIndex;
  1583. } else {
  1584. _this1._root = l;
  1585. l._parent = null;
  1586. }
  1587. node = l;
  1588. } else if(balance < -1) {
  1589. var rl = r._children[0];
  1590. var rr = r._children[1];
  1591. var rlh = rl._height;
  1592. var rrh = rr._height;
  1593. if(rlh > rrh) {
  1594. r._children[1] = node;
  1595. node._parent = r;
  1596. node._childIndex = 1;
  1597. node._children[1] = rr;
  1598. rr._parent = node;
  1599. rr._childIndex = 1;
  1600. var c14 = r._children[0];
  1601. var c24 = r._children[1];
  1602. r._aabbMinX = c14._aabbMinX < c24._aabbMinX ? c14._aabbMinX : c24._aabbMinX;
  1603. r._aabbMinY = c14._aabbMinY < c24._aabbMinY ? c14._aabbMinY : c24._aabbMinY;
  1604. r._aabbMinZ = c14._aabbMinZ < c24._aabbMinZ ? c14._aabbMinZ : c24._aabbMinZ;
  1605. r._aabbMaxX = c14._aabbMaxX > c24._aabbMaxX ? c14._aabbMaxX : c24._aabbMaxX;
  1606. r._aabbMaxY = c14._aabbMaxY > c24._aabbMaxY ? c14._aabbMaxY : c24._aabbMaxY;
  1607. r._aabbMaxZ = c14._aabbMaxZ > c24._aabbMaxZ ? c14._aabbMaxZ : c24._aabbMaxZ;
  1608. var h14 = r._children[0]._height;
  1609. var h24 = r._children[1]._height;
  1610. r._height = (h14 > h24 ? h14 : h24) + 1;
  1611. var c15 = node._children[0];
  1612. var c25 = node._children[1];
  1613. node._aabbMinX = c15._aabbMinX < c25._aabbMinX ? c15._aabbMinX : c25._aabbMinX;
  1614. node._aabbMinY = c15._aabbMinY < c25._aabbMinY ? c15._aabbMinY : c25._aabbMinY;
  1615. node._aabbMinZ = c15._aabbMinZ < c25._aabbMinZ ? c15._aabbMinZ : c25._aabbMinZ;
  1616. node._aabbMaxX = c15._aabbMaxX > c25._aabbMaxX ? c15._aabbMaxX : c25._aabbMaxX;
  1617. node._aabbMaxY = c15._aabbMaxY > c25._aabbMaxY ? c15._aabbMaxY : c25._aabbMaxY;
  1618. node._aabbMaxZ = c15._aabbMaxZ > c25._aabbMaxZ ? c15._aabbMaxZ : c25._aabbMaxZ;
  1619. var h15 = node._children[0]._height;
  1620. var h25 = node._children[1]._height;
  1621. node._height = (h15 > h25 ? h15 : h25) + 1;
  1622. } else {
  1623. r._children[0] = node;
  1624. node._parent = r;
  1625. node._childIndex = 0;
  1626. node._children[1] = rl;
  1627. rl._parent = node;
  1628. rl._childIndex = 1;
  1629. var c16 = r._children[0];
  1630. var c26 = r._children[1];
  1631. r._aabbMinX = c16._aabbMinX < c26._aabbMinX ? c16._aabbMinX : c26._aabbMinX;
  1632. r._aabbMinY = c16._aabbMinY < c26._aabbMinY ? c16._aabbMinY : c26._aabbMinY;
  1633. r._aabbMinZ = c16._aabbMinZ < c26._aabbMinZ ? c16._aabbMinZ : c26._aabbMinZ;
  1634. r._aabbMaxX = c16._aabbMaxX > c26._aabbMaxX ? c16._aabbMaxX : c26._aabbMaxX;
  1635. r._aabbMaxY = c16._aabbMaxY > c26._aabbMaxY ? c16._aabbMaxY : c26._aabbMaxY;
  1636. r._aabbMaxZ = c16._aabbMaxZ > c26._aabbMaxZ ? c16._aabbMaxZ : c26._aabbMaxZ;
  1637. var h16 = r._children[0]._height;
  1638. var h26 = r._children[1]._height;
  1639. r._height = (h16 > h26 ? h16 : h26) + 1;
  1640. var c17 = node._children[0];
  1641. var c27 = node._children[1];
  1642. node._aabbMinX = c17._aabbMinX < c27._aabbMinX ? c17._aabbMinX : c27._aabbMinX;
  1643. node._aabbMinY = c17._aabbMinY < c27._aabbMinY ? c17._aabbMinY : c27._aabbMinY;
  1644. node._aabbMinZ = c17._aabbMinZ < c27._aabbMinZ ? c17._aabbMinZ : c27._aabbMinZ;
  1645. node._aabbMaxX = c17._aabbMaxX > c27._aabbMaxX ? c17._aabbMaxX : c27._aabbMaxX;
  1646. node._aabbMaxY = c17._aabbMaxY > c27._aabbMaxY ? c17._aabbMaxY : c27._aabbMaxY;
  1647. node._aabbMaxZ = c17._aabbMaxZ > c27._aabbMaxZ ? c17._aabbMaxZ : c27._aabbMaxZ;
  1648. var h17 = node._children[0]._height;
  1649. var h27 = node._children[1]._height;
  1650. node._height = (h17 > h27 ? h17 : h27) + 1;
  1651. }
  1652. if(p2 != null) {
  1653. p2._children[nodeIndex] = r;
  1654. r._parent = p2;
  1655. r._childIndex = nodeIndex;
  1656. } else {
  1657. _this1._root = r;
  1658. r._parent = null;
  1659. }
  1660. node = r;
  1661. } else {
  1662. node = node;
  1663. }
  1664. }
  1665. }
  1666. var h18 = node._children[0]._height;
  1667. var h28 = node._children[1]._height;
  1668. node._height = (h18 > h28 ? h18 : h28) + 1;
  1669. var c18 = node._children[0];
  1670. var c28 = node._children[1];
  1671. node._aabbMinX = c18._aabbMinX < c28._aabbMinX ? c18._aabbMinX : c28._aabbMinX;
  1672. node._aabbMinY = c18._aabbMinY < c28._aabbMinY ? c18._aabbMinY : c28._aabbMinY;
  1673. node._aabbMinZ = c18._aabbMinZ < c28._aabbMinZ ? c18._aabbMinZ : c28._aabbMinZ;
  1674. node._aabbMaxX = c18._aabbMaxX > c28._aabbMaxX ? c18._aabbMaxX : c28._aabbMaxX;
  1675. node._aabbMaxY = c18._aabbMaxY > c28._aabbMaxY ? c18._aabbMaxY : c28._aabbMaxY;
  1676. node._aabbMaxZ = c18._aabbMaxZ > c28._aabbMaxZ ? c18._aabbMaxZ : c28._aabbMaxZ;
  1677. node = node._parent;
  1678. }
  1679. }
  1680. }
  1681. p1._leaf = null;
  1682. leaf1._next = null;
  1683. leaf1._childIndex = 0;
  1684. leaf1._children[0] = null;
  1685. leaf1._children[1] = null;
  1686. leaf1._childIndex = 0;
  1687. leaf1._parent = null;
  1688. leaf1._height = 0;
  1689. leaf1._proxy = null;
  1690. leaf1._next = _this1._nodePool;
  1691. _this1._nodePool = leaf1;
  1692. var _this2 = this._tree;
  1693. var first = _this2._nodePool;
  1694. if(first != null) {
  1695. _this2._nodePool = first._next;
  1696. first._next = null;
  1697. } else {
  1698. first = new oimo.collision.broadphase.bvh.BvhNode();
  1699. }
  1700. var leaf2 = first;
  1701. leaf2._proxy = p1;
  1702. p1._leaf = leaf2;
  1703. leaf2._aabbMinX = p1._aabbMinX;
  1704. leaf2._aabbMinY = p1._aabbMinY;
  1705. leaf2._aabbMinZ = p1._aabbMinZ;
  1706. leaf2._aabbMaxX = p1._aabbMaxX;
  1707. leaf2._aabbMaxY = p1._aabbMaxY;
  1708. leaf2._aabbMaxZ = p1._aabbMaxZ;
  1709. _this2._numLeaves++;
  1710. if(_this2.leafList == null) {
  1711. _this2.leafList = leaf2;
  1712. _this2.leafListLast = leaf2;
  1713. } else {
  1714. _this2.leafListLast._nextLeaf = leaf2;
  1715. leaf2._prevLeaf = _this2.leafListLast;
  1716. _this2.leafListLast = leaf2;
  1717. }
  1718. if(_this2._root == null) {
  1719. _this2._root = leaf2;
  1720. } else {
  1721. var sibling1 = _this2._root;
  1722. while(sibling1._height > 0) {
  1723. var nextStep = _this2._strategy._decideInsertion(sibling1,leaf2);
  1724. if(nextStep == -1) {
  1725. break;
  1726. } else {
  1727. sibling1 = sibling1._children[nextStep];
  1728. }
  1729. }
  1730. var parent1 = sibling1._parent;
  1731. var first1 = _this2._nodePool;
  1732. if(first1 != null) {
  1733. _this2._nodePool = first1._next;
  1734. first1._next = null;
  1735. } else {
  1736. first1 = new oimo.collision.broadphase.bvh.BvhNode();
  1737. }
  1738. var node1 = first1;
  1739. if(parent1 == null) {
  1740. _this2._root = node1;
  1741. } else {
  1742. var index1 = sibling1._childIndex;
  1743. parent1._children[index1] = node1;
  1744. node1._parent = parent1;
  1745. node1._childIndex = index1;
  1746. }
  1747. var index2 = sibling1._childIndex;
  1748. node1._children[index2] = sibling1;
  1749. sibling1._parent = node1;
  1750. sibling1._childIndex = index2;
  1751. var index3 = sibling1._childIndex ^ 1;
  1752. node1._children[index3] = leaf2;
  1753. leaf2._parent = node1;
  1754. leaf2._childIndex = index3;
  1755. while(node1 != null) {
  1756. if(_this2._strategy._balancingEnabled) {
  1757. var nh1 = node1._height;
  1758. if(nh1 < 2) {
  1759. node1 = node1;
  1760. } else {
  1761. var p3 = node1._parent;
  1762. var l1 = node1._children[0];
  1763. var r1 = node1._children[1];
  1764. var lh1 = l1._height;
  1765. var rh1 = r1._height;
  1766. var balance1 = lh1 - rh1;
  1767. var nodeIndex1 = node1._childIndex;
  1768. if(balance1 > 1) {
  1769. var ll1 = l1._children[0];
  1770. var lr1 = l1._children[1];
  1771. var llh1 = ll1._height;
  1772. var lrh1 = lr1._height;
  1773. if(llh1 > lrh1) {
  1774. l1._children[1] = node1;
  1775. node1._parent = l1;
  1776. node1._childIndex = 1;
  1777. node1._children[0] = lr1;
  1778. lr1._parent = node1;
  1779. lr1._childIndex = 0;
  1780. var c19 = l1._children[0];
  1781. var c29 = l1._children[1];
  1782. l1._aabbMinX = c19._aabbMinX < c29._aabbMinX ? c19._aabbMinX : c29._aabbMinX;
  1783. l1._aabbMinY = c19._aabbMinY < c29._aabbMinY ? c19._aabbMinY : c29._aabbMinY;
  1784. l1._aabbMinZ = c19._aabbMinZ < c29._aabbMinZ ? c19._aabbMinZ : c29._aabbMinZ;
  1785. l1._aabbMaxX = c19._aabbMaxX > c29._aabbMaxX ? c19._aabbMaxX : c29._aabbMaxX;
  1786. l1._aabbMaxY = c19._aabbMaxY > c29._aabbMaxY ? c19._aabbMaxY : c29._aabbMaxY;
  1787. l1._aabbMaxZ = c19._aabbMaxZ > c29._aabbMaxZ ? c19._aabbMaxZ : c29._aabbMaxZ;
  1788. var h19 = l1._children[0]._height;
  1789. var h29 = l1._children[1]._height;
  1790. l1._height = (h19 > h29 ? h19 : h29) + 1;
  1791. var c110 = node1._children[0];
  1792. var c210 = node1._children[1];
  1793. node1._aabbMinX = c110._aabbMinX < c210._aabbMinX ? c110._aabbMinX : c210._aabbMinX;
  1794. node1._aabbMinY = c110._aabbMinY < c210._aabbMinY ? c110._aabbMinY : c210._aabbMinY;
  1795. node1._aabbMinZ = c110._aabbMinZ < c210._aabbMinZ ? c110._aabbMinZ : c210._aabbMinZ;
  1796. node1._aabbMaxX = c110._aabbMaxX > c210._aabbMaxX ? c110._aabbMaxX : c210._aabbMaxX;
  1797. node1._aabbMaxY = c110._aabbMaxY > c210._aabbMaxY ? c110._aabbMaxY : c210._aabbMaxY;
  1798. node1._aabbMaxZ = c110._aabbMaxZ > c210._aabbMaxZ ? c110._aabbMaxZ : c210._aabbMaxZ;
  1799. var h110 = node1._children[0]._height;
  1800. var h210 = node1._children[1]._height;
  1801. node1._height = (h110 > h210 ? h110 : h210) + 1;
  1802. } else {
  1803. l1._children[0] = node1;
  1804. node1._parent = l1;
  1805. node1._childIndex = 0;
  1806. node1._children[0] = ll1;
  1807. ll1._parent = node1;
  1808. ll1._childIndex = 0;
  1809. var c111 = l1._children[0];
  1810. var c211 = l1._children[1];
  1811. l1._aabbMinX = c111._aabbMinX < c211._aabbMinX ? c111._aabbMinX : c211._aabbMinX;
  1812. l1._aabbMinY = c111._aabbMinY < c211._aabbMinY ? c111._aabbMinY : c211._aabbMinY;
  1813. l1._aabbMinZ = c111._aabbMinZ < c211._aabbMinZ ? c111._aabbMinZ : c211._aabbMinZ;
  1814. l1._aabbMaxX = c111._aabbMaxX > c211._aabbMaxX ? c111._aabbMaxX : c211._aabbMaxX;
  1815. l1._aabbMaxY = c111._aabbMaxY > c211._aabbMaxY ? c111._aabbMaxY : c211._aabbMaxY;
  1816. l1._aabbMaxZ = c111._aabbMaxZ > c211._aabbMaxZ ? c111._aabbMaxZ : c211._aabbMaxZ;
  1817. var h111 = l1._children[0]._height;
  1818. var h211 = l1._children[1]._height;
  1819. l1._height = (h111 > h211 ? h111 : h211) + 1;
  1820. var c112 = node1._children[0];
  1821. var c212 = node1._children[1];
  1822. node1._aabbMinX = c112._aabbMinX < c212._aabbMinX ? c112._aabbMinX : c212._aabbMinX;
  1823. node1._aabbMinY = c112._aabbMinY < c212._aabbMinY ? c112._aabbMinY : c212._aabbMinY;
  1824. node1._aabbMinZ = c112._aabbMinZ < c212._aabbMinZ ? c112._aabbMinZ : c212._aabbMinZ;
  1825. node1._aabbMaxX = c112._aabbMaxX > c212._aabbMaxX ? c112._aabbMaxX : c212._aabbMaxX;
  1826. node1._aabbMaxY = c112._aabbMaxY > c212._aabbMaxY ? c112._aabbMaxY : c212._aabbMaxY;
  1827. node1._aabbMaxZ = c112._aabbMaxZ > c212._aabbMaxZ ? c112._aabbMaxZ : c212._aabbMaxZ;
  1828. var h112 = node1._children[0]._height;
  1829. var h212 = node1._children[1]._height;
  1830. node1._height = (h112 > h212 ? h112 : h212) + 1;
  1831. }
  1832. if(p3 != null) {
  1833. p3._children[nodeIndex1] = l1;
  1834. l1._parent = p3;
  1835. l1._childIndex = nodeIndex1;
  1836. } else {
  1837. _this2._root = l1;
  1838. l1._parent = null;
  1839. }
  1840. node1 = l1;
  1841. } else if(balance1 < -1) {
  1842. var rl1 = r1._children[0];
  1843. var rr1 = r1._children[1];
  1844. var rlh1 = rl1._height;
  1845. var rrh1 = rr1._height;
  1846. if(rlh1 > rrh1) {
  1847. r1._children[1] = node1;
  1848. node1._parent = r1;
  1849. node1._childIndex = 1;
  1850. node1._children[1] = rr1;
  1851. rr1._parent = node1;
  1852. rr1._childIndex = 1;
  1853. var c113 = r1._children[0];
  1854. var c213 = r1._children[1];
  1855. r1._aabbMinX = c113._aabbMinX < c213._aabbMinX ? c113._aabbMinX : c213._aabbMinX;
  1856. r1._aabbMinY = c113._aabbMinY < c213._aabbMinY ? c113._aabbMinY : c213._aabbMinY;
  1857. r1._aabbMinZ = c113._aabbMinZ < c213._aabbMinZ ? c113._aabbMinZ : c213._aabbMinZ;
  1858. r1._aabbMaxX = c113._aabbMaxX > c213._aabbMaxX ? c113._aabbMaxX : c213._aabbMaxX;
  1859. r1._aabbMaxY = c113._aabbMaxY > c213._aabbMaxY ? c113._aabbMaxY : c213._aabbMaxY;
  1860. r1._aabbMaxZ = c113._aabbMaxZ > c213._aabbMaxZ ? c113._aabbMaxZ : c213._aabbMaxZ;
  1861. var h113 = r1._children[0]._height;
  1862. var h213 = r1._children[1]._height;
  1863. r1._height = (h113 > h213 ? h113 : h213) + 1;
  1864. var c114 = node1._children[0];
  1865. var c214 = node1._children[1];
  1866. node1._aabbMinX = c114._aabbMinX < c214._aabbMinX ? c114._aabbMinX : c214._aabbMinX;
  1867. node1._aabbMinY = c114._aabbMinY < c214._aabbMinY ? c114._aabbMinY : c214._aabbMinY;
  1868. node1._aabbMinZ = c114._aabbMinZ < c214._aabbMinZ ? c114._aabbMinZ : c214._aabbMinZ;
  1869. node1._aabbMaxX = c114._aabbMaxX > c214._aabbMaxX ? c114._aabbMaxX : c214._aabbMaxX;
  1870. node1._aabbMaxY = c114._aabbMaxY > c214._aabbMaxY ? c114._aabbMaxY : c214._aabbMaxY;
  1871. node1._aabbMaxZ = c114._aabbMaxZ > c214._aabbMaxZ ? c114._aabbMaxZ : c214._aabbMaxZ;
  1872. var h114 = node1._children[0]._height;
  1873. var h214 = node1._children[1]._height;
  1874. node1._height = (h114 > h214 ? h114 : h214) + 1;
  1875. } else {
  1876. r1._children[0] = node1;
  1877. node1._parent = r1;
  1878. node1._childIndex = 0;
  1879. node1._children[1] = rl1;
  1880. rl1._parent = node1;
  1881. rl1._childIndex = 1;
  1882. var c115 = r1._children[0];
  1883. var c215 = r1._children[1];
  1884. r1._aabbMinX = c115._aabbMinX < c215._aabbMinX ? c115._aabbMinX : c215._aabbMinX;
  1885. r1._aabbMinY = c115._aabbMinY < c215._aabbMinY ? c115._aabbMinY : c215._aabbMinY;
  1886. r1._aabbMinZ = c115._aabbMinZ < c215._aabbMinZ ? c115._aabbMinZ : c215._aabbMinZ;
  1887. r1._aabbMaxX = c115._aabbMaxX > c215._aabbMaxX ? c115._aabbMaxX : c215._aabbMaxX;
  1888. r1._aabbMaxY = c115._aabbMaxY > c215._aabbMaxY ? c115._aabbMaxY : c215._aabbMaxY;
  1889. r1._aabbMaxZ = c115._aabbMaxZ > c215._aabbMaxZ ? c115._aabbMaxZ : c215._aabbMaxZ;
  1890. var h115 = r1._children[0]._height;
  1891. var h215 = r1._children[1]._height;
  1892. r1._height = (h115 > h215 ? h115 : h215) + 1;
  1893. var c116 = node1._children[0];
  1894. var c216 = node1._children[1];
  1895. node1._aabbMinX = c116._aabbMinX < c216._aabbMinX ? c116._aabbMinX : c216._aabbMinX;
  1896. node1._aabbMinY = c116._aabbMinY < c216._aabbMinY ? c116._aabbMinY : c216._aabbMinY;
  1897. node1._aabbMinZ = c116._aabbMinZ < c216._aabbMinZ ? c116._aabbMinZ : c216._aabbMinZ;
  1898. node1._aabbMaxX = c116._aabbMaxX > c216._aabbMaxX ? c116._aabbMaxX : c216._aabbMaxX;
  1899. node1._aabbMaxY = c116._aabbMaxY > c216._aabbMaxY ? c116._aabbMaxY : c216._aabbMaxY;
  1900. node1._aabbMaxZ = c116._aabbMaxZ > c216._aabbMaxZ ? c116._aabbMaxZ : c216._aabbMaxZ;
  1901. var h116 = node1._children[0]._height;
  1902. var h216 = node1._children[1]._height;
  1903. node1._height = (h116 > h216 ? h116 : h216) + 1;
  1904. }
  1905. if(p3 != null) {
  1906. p3._children[nodeIndex1] = r1;
  1907. r1._parent = p3;
  1908. r1._childIndex = nodeIndex1;
  1909. } else {
  1910. _this2._root = r1;
  1911. r1._parent = null;
  1912. }
  1913. node1 = r1;
  1914. } else {
  1915. node1 = node1;
  1916. }
  1917. }
  1918. }
  1919. var h117 = node1._children[0]._height;
  1920. var h217 = node1._children[1]._height;
  1921. node1._height = (h117 > h217 ? h117 : h217) + 1;
  1922. var c117 = node1._children[0];
  1923. var c217 = node1._children[1];
  1924. node1._aabbMinX = c117._aabbMinX < c217._aabbMinX ? c117._aabbMinX : c217._aabbMinX;
  1925. node1._aabbMinY = c117._aabbMinY < c217._aabbMinY ? c117._aabbMinY : c217._aabbMinY;
  1926. node1._aabbMinZ = c117._aabbMinZ < c217._aabbMinZ ? c117._aabbMinZ : c217._aabbMinZ;
  1927. node1._aabbMaxX = c117._aabbMaxX > c217._aabbMaxX ? c117._aabbMaxX : c217._aabbMaxX;
  1928. node1._aabbMaxY = c117._aabbMaxY > c217._aabbMaxY ? c117._aabbMaxY : c217._aabbMaxY;
  1929. node1._aabbMaxZ = c117._aabbMaxZ > c217._aabbMaxZ ? c117._aabbMaxZ : c217._aabbMaxZ;
  1930. node1 = node1._parent;
  1931. }
  1932. }
  1933. if(incrementalCollision) {
  1934. this.collide(this._tree._root,p1._leaf);
  1935. }
  1936. p1._moved = false;
  1937. }
  1938. this.movedProxies[i1] = null;
  1939. }
  1940. if(!incrementalCollision) {
  1941. this.collide(this._tree._root,this._tree._root);
  1942. }
  1943. this.numMovedProxies = 0;
  1944. }
  1945. rayCast(begin,end,callback) {
  1946. if(this._tree._root == null) {
  1947. return;
  1948. }
  1949. var p1;
  1950. var p1X;
  1951. var p1Y;
  1952. var p1Z;
  1953. var p2;
  1954. var p2X;
  1955. var p2Y;
  1956. var p2Z;
  1957. var v = begin;
  1958. p1X = v.x;
  1959. p1Y = v.y;
  1960. p1Z = v.z;
  1961. var v1 = end;
  1962. p2X = v1.x;
  1963. p2Y = v1.y;
  1964. p2Z = v1.z;
  1965. this.rayCastRecursive(this._tree._root,p1X,p1Y,p1Z,p2X,p2Y,p2Z,callback);
  1966. }
  1967. convexCast(convex,begin,translation,callback) {
  1968. if(this._tree._root == null) {
  1969. return;
  1970. }
  1971. this.convexCastRecursive(this._tree._root,convex,begin,translation,callback);
  1972. }
  1973. aabbTest(aabb,callback) {
  1974. if(this._tree._root == null) {
  1975. return;
  1976. }
  1977. this.aabbTestRecursive(this._tree._root,aabb,callback);
  1978. }
  1979. getTreeBalance() {
  1980. return this._tree._getBalance();
  1981. }
  1982. }
  1983. oimo.collision.broadphase.bvh.BvhInsertionStrategy = class oimo_collision_broadphase_bvh_BvhInsertionStrategy {
  1984. }
  1985. oimo.collision.broadphase.bvh.BvhNode = class oimo_collision_broadphase_bvh_BvhNode {
  1986. constructor() {
  1987. this._next = null;
  1988. this._prevLeaf = null;
  1989. this._nextLeaf = null;
  1990. var this1 = new Array(2);
  1991. this._children = this1;
  1992. this._childIndex = 0;
  1993. this._parent = null;
  1994. this._height = 0;
  1995. this._proxy = null;
  1996. this._aabbMinX = 0;
  1997. this._aabbMinY = 0;
  1998. this._aabbMinZ = 0;
  1999. this._aabbMaxX = 0;
  2000. this._aabbMaxY = 0;
  2001. this._aabbMaxZ = 0;
  2002. }
  2003. }
  2004. oimo.collision.broadphase.bvh.BvhProxy = class oimo_collision_broadphase_bvh_BvhProxy extends oimo.collision.broadphase.Proxy {
  2005. constructor(userData,id) {
  2006. super(userData,id);
  2007. this._leaf = null;
  2008. this._moved = false;
  2009. }
  2010. }
  2011. oimo.collision.broadphase.bvh.BvhStrategy = class oimo_collision_broadphase_bvh_BvhStrategy {
  2012. constructor() {
  2013. this._insertionStrategy = 0;
  2014. this._balancingEnabled = false;
  2015. }
  2016. _decideInsertion(currentNode,leaf) {
  2017. switch(this._insertionStrategy) {
  2018. case 0:
  2019. var center;
  2020. var centerX;
  2021. var centerY;
  2022. var centerZ;
  2023. centerX = leaf._aabbMinX + leaf._aabbMaxX;
  2024. centerY = leaf._aabbMinY + leaf._aabbMaxY;
  2025. centerZ = leaf._aabbMinZ + leaf._aabbMaxZ;
  2026. var c1 = currentNode._children[0];
  2027. var c2 = currentNode._children[1];
  2028. var diff1;
  2029. var diff1X;
  2030. var diff1Y;
  2031. var diff1Z;
  2032. var diff2;
  2033. var diff2X;
  2034. var diff2Y;
  2035. var diff2Z;
  2036. diff1X = c1._aabbMinX + c1._aabbMaxX;
  2037. diff1Y = c1._aabbMinY + c1._aabbMaxY;
  2038. diff1Z = c1._aabbMinZ + c1._aabbMaxZ;
  2039. diff2X = c2._aabbMinX + c2._aabbMaxX;
  2040. diff2Y = c2._aabbMinY + c2._aabbMaxY;
  2041. diff2Z = c2._aabbMinZ + c2._aabbMaxZ;
  2042. diff1X -= centerX;
  2043. diff1Y -= centerY;
  2044. diff1Z -= centerZ;
  2045. diff2X -= centerX;
  2046. diff2Y -= centerY;
  2047. diff2Z -= centerZ;
  2048. var dist1 = diff1X * diff1X + diff1Y * diff1Y + diff1Z * diff1Z;
  2049. var dist2 = diff2X * diff2X + diff2Y * diff2Y + diff2Z * diff2Z;
  2050. if(dist1 < dist2) {
  2051. return 0;
  2052. } else {
  2053. return 1;
  2054. }
  2055. break;
  2056. case 1:
  2057. var c11 = currentNode._children[0];
  2058. var c21 = currentNode._children[1];
  2059. var ex = currentNode._aabbMaxX - currentNode._aabbMinX;
  2060. var ey = currentNode._aabbMaxY - currentNode._aabbMinY;
  2061. var ez = currentNode._aabbMaxZ - currentNode._aabbMinZ;
  2062. var oldArea = (ex * (ey + ez) + ey * ez) * 2;
  2063. var combinedMin;
  2064. var combinedMinX;
  2065. var combinedMinY;
  2066. var combinedMinZ;
  2067. var combinedMax;
  2068. var combinedMaxX;
  2069. var combinedMaxY;
  2070. var combinedMaxZ;
  2071. combinedMinX = currentNode._aabbMinX < leaf._aabbMinX ? currentNode._aabbMinX : leaf._aabbMinX;
  2072. combinedMinY = currentNode._aabbMinY < leaf._aabbMinY ? currentNode._aabbMinY : leaf._aabbMinY;
  2073. combinedMinZ = currentNode._aabbMinZ < leaf._aabbMinZ ? currentNode._aabbMinZ : leaf._aabbMinZ;
  2074. combinedMaxX = currentNode._aabbMaxX > leaf._aabbMaxX ? currentNode._aabbMaxX : leaf._aabbMaxX;
  2075. combinedMaxY = currentNode._aabbMaxY > leaf._aabbMaxY ? currentNode._aabbMaxY : leaf._aabbMaxY;
  2076. combinedMaxZ = currentNode._aabbMaxZ > leaf._aabbMaxZ ? currentNode._aabbMaxZ : leaf._aabbMaxZ;
  2077. var ex1 = combinedMaxX - combinedMinX;
  2078. var ey1 = combinedMaxY - combinedMinY;
  2079. var ez1 = combinedMaxZ - combinedMinZ;
  2080. var newArea = (ex1 * (ey1 + ez1) + ey1 * ez1) * 2;
  2081. var creatingCost = newArea * 2;
  2082. var incrementalCost = (newArea - oldArea) * 2;
  2083. var descendingCost1 = incrementalCost;
  2084. combinedMinX = c11._aabbMinX < leaf._aabbMinX ? c11._aabbMinX : leaf._aabbMinX;
  2085. combinedMinY = c11._aabbMinY < leaf._aabbMinY ? c11._aabbMinY : leaf._aabbMinY;
  2086. combinedMinZ = c11._aabbMinZ < leaf._aabbMinZ ? c11._aabbMinZ : leaf._aabbMinZ;
  2087. combinedMaxX = c11._aabbMaxX > leaf._aabbMaxX ? c11._aabbMaxX : leaf._aabbMaxX;
  2088. combinedMaxY = c11._aabbMaxY > leaf._aabbMaxY ? c11._aabbMaxY : leaf._aabbMaxY;
  2089. combinedMaxZ = c11._aabbMaxZ > leaf._aabbMaxZ ? c11._aabbMaxZ : leaf._aabbMaxZ;
  2090. if(c11._height == 0) {
  2091. var ex2 = combinedMaxX - combinedMinX;
  2092. var ey2 = combinedMaxY - combinedMinY;
  2093. var ez2 = combinedMaxZ - combinedMinZ;
  2094. descendingCost1 += (ex2 * (ey2 + ez2) + ey2 * ez2) * 2;
  2095. } else {
  2096. var ex3 = combinedMaxX - combinedMinX;
  2097. var ey3 = combinedMaxY - combinedMinY;
  2098. var ez3 = combinedMaxZ - combinedMinZ;
  2099. var ex4 = c11._aabbMaxX - c11._aabbMinX;
  2100. var ey4 = c11._aabbMaxY - c11._aabbMinY;
  2101. var ez4 = c11._aabbMaxZ - c11._aabbMinZ;
  2102. descendingCost1 += (ex3 * (ey3 + ez3) + ey3 * ez3) * 2 - (ex4 * (ey4 + ez4) + ey4 * ez4) * 2;
  2103. }
  2104. var descendingCost2 = incrementalCost;
  2105. combinedMinX = c21._aabbMinX < leaf._aabbMinX ? c21._aabbMinX : leaf._aabbMinX;
  2106. combinedMinY = c21._aabbMinY < leaf._aabbMinY ? c21._aabbMinY : leaf._aabbMinY;
  2107. combinedMinZ = c21._aabbMinZ < leaf._aabbMinZ ? c21._aabbMinZ : leaf._aabbMinZ;
  2108. combinedMaxX = c21._aabbMaxX > leaf._aabbMaxX ? c21._aabbMaxX : leaf._aabbMaxX;
  2109. combinedMaxY = c21._aabbMaxY > leaf._aabbMaxY ? c21._aabbMaxY : leaf._aabbMaxY;
  2110. combinedMaxZ = c21._aabbMaxZ > leaf._aabbMaxZ ? c21._aabbMaxZ : leaf._aabbMaxZ;
  2111. if(c21._height == 0) {
  2112. var ex5 = combinedMaxX - combinedMinX;
  2113. var ey5 = combinedMaxY - combinedMinY;
  2114. var ez5 = combinedMaxZ - combinedMinZ;
  2115. descendingCost2 += (ex5 * (ey5 + ez5) + ey5 * ez5) * 2;
  2116. } else {
  2117. var ex6 = combinedMaxX - combinedMinX;
  2118. var ey6 = combinedMaxY - combinedMinY;
  2119. var ez6 = combinedMaxZ - combinedMinZ;
  2120. var ex7 = c21._aabbMaxX - c21._aabbMinX;
  2121. var ey7 = c21._aabbMaxY - c21._aabbMinY;
  2122. var ez7 = c21._aabbMaxZ - c21._aabbMinZ;
  2123. descendingCost2 += (ex6 * (ey6 + ez6) + ey6 * ez6) * 2 - (ex7 * (ey7 + ez7) + ey7 * ez7) * 2;
  2124. }
  2125. if(creatingCost < descendingCost1) {
  2126. if(creatingCost < descendingCost2) {
  2127. return -1;
  2128. } else {
  2129. return 1;
  2130. }
  2131. } else if(descendingCost1 < descendingCost2) {
  2132. return 0;
  2133. } else {
  2134. return 1;
  2135. }
  2136. break;
  2137. default:
  2138. console.log("src/oimo/collision/broadphase/bvh/BvhStrategy.hx:37:","invalid BVH insertion strategy: " + this._insertionStrategy);
  2139. return -1;
  2140. }
  2141. }
  2142. _splitLeaves(leaves,from,until) {
  2143. var invN = 1.0 / (until - from);
  2144. var centerMean;
  2145. var centerMeanX;
  2146. var centerMeanY;
  2147. var centerMeanZ;
  2148. centerMeanX = 0;
  2149. centerMeanY = 0;
  2150. centerMeanZ = 0;
  2151. var _g = from;
  2152. var _g1 = until;
  2153. while(_g < _g1) {
  2154. var i = _g++;
  2155. var leaf = leaves[i];
  2156. leaf._tmpX = leaf._aabbMaxX + leaf._aabbMinX;
  2157. leaf._tmpY = leaf._aabbMaxY + leaf._aabbMinY;
  2158. leaf._tmpZ = leaf._aabbMaxZ + leaf._aabbMinZ;
  2159. centerMeanX += leaf._tmpX;
  2160. centerMeanY += leaf._tmpY;
  2161. centerMeanZ += leaf._tmpZ;
  2162. }
  2163. centerMeanX *= invN;
  2164. centerMeanY *= invN;
  2165. centerMeanZ *= invN;
  2166. var variance;
  2167. var varianceX;
  2168. var varianceY;
  2169. var varianceZ;
  2170. varianceX = 0;
  2171. varianceY = 0;
  2172. varianceZ = 0;
  2173. var _g2 = from;
  2174. var _g3 = until;
  2175. while(_g2 < _g3) {
  2176. var i1 = _g2++;
  2177. var leaf1 = leaves[i1];
  2178. var diff;
  2179. var diffX;
  2180. var diffY;
  2181. var diffZ;
  2182. diffX = leaf1._tmpX - centerMeanX;
  2183. diffY = leaf1._tmpY - centerMeanY;
  2184. diffZ = leaf1._tmpZ - centerMeanZ;
  2185. diffX *= diffX;
  2186. diffY *= diffY;
  2187. diffZ *= diffZ;
  2188. varianceX += diffX;
  2189. varianceY += diffY;
  2190. varianceZ += diffZ;
  2191. }
  2192. var varX = varianceX;
  2193. var varY = varianceY;
  2194. var varZ = varianceZ;
  2195. var l = from;
  2196. var r = until - 1;
  2197. if(varX > varY) {
  2198. if(varX > varZ) {
  2199. var mean = centerMeanX;
  2200. while(true) {
  2201. while(true) {
  2202. var leaf2 = leaves[l];
  2203. if(leaf2._tmpX <= mean) {
  2204. break;
  2205. }
  2206. ++l;
  2207. }
  2208. while(true) {
  2209. var leaf3 = leaves[r];
  2210. if(leaf3._tmpX >= mean) {
  2211. break;
  2212. }
  2213. --r;
  2214. }
  2215. if(l >= r) {
  2216. break;
  2217. }
  2218. var tmp = leaves[l];
  2219. leaves[l] = leaves[r];
  2220. leaves[r] = tmp;
  2221. ++l;
  2222. --r;
  2223. }
  2224. } else {
  2225. var mean1 = centerMeanZ;
  2226. while(true) {
  2227. while(true) {
  2228. var leaf4 = leaves[l];
  2229. if(leaf4._tmpZ <= mean1) {
  2230. break;
  2231. }
  2232. ++l;
  2233. }
  2234. while(true) {
  2235. var leaf5 = leaves[r];
  2236. if(leaf5._tmpZ >= mean1) {
  2237. break;
  2238. }
  2239. --r;
  2240. }
  2241. if(l >= r) {
  2242. break;
  2243. }
  2244. var tmp1 = leaves[l];
  2245. leaves[l] = leaves[r];
  2246. leaves[r] = tmp1;
  2247. ++l;
  2248. --r;
  2249. }
  2250. }
  2251. } else if(varY > varZ) {
  2252. var mean2 = centerMeanY;
  2253. while(true) {
  2254. while(true) {
  2255. var leaf6 = leaves[l];
  2256. if(leaf6._tmpY <= mean2) {
  2257. break;
  2258. }
  2259. ++l;
  2260. }
  2261. while(true) {
  2262. var leaf7 = leaves[r];
  2263. if(leaf7._tmpY >= mean2) {
  2264. break;
  2265. }
  2266. --r;
  2267. }
  2268. if(l >= r) {
  2269. break;
  2270. }
  2271. var tmp2 = leaves[l];
  2272. leaves[l] = leaves[r];
  2273. leaves[r] = tmp2;
  2274. ++l;
  2275. --r;
  2276. }
  2277. } else {
  2278. var mean3 = centerMeanZ;
  2279. while(true) {
  2280. while(true) {
  2281. var leaf8 = leaves[l];
  2282. if(leaf8._tmpZ <= mean3) {
  2283. break;
  2284. }
  2285. ++l;
  2286. }
  2287. while(true) {
  2288. var leaf9 = leaves[r];
  2289. if(leaf9._tmpZ >= mean3) {
  2290. break;
  2291. }
  2292. --r;
  2293. }
  2294. if(l >= r) {
  2295. break;
  2296. }
  2297. var tmp3 = leaves[l];
  2298. leaves[l] = leaves[r];
  2299. leaves[r] = tmp3;
  2300. ++l;
  2301. --r;
  2302. }
  2303. }
  2304. return l;
  2305. }
  2306. }
  2307. oimo.collision.broadphase.bvh.BvhTree = class oimo_collision_broadphase_bvh_BvhTree {
  2308. constructor() {
  2309. this._root = null;
  2310. this._numLeaves = 0;
  2311. this._strategy = new oimo.collision.broadphase.bvh.BvhStrategy();
  2312. this._nodePool = null;
  2313. this.leafList = null;
  2314. this.leafListLast = null;
  2315. var this1 = new Array(1024);
  2316. this.tmp = this1;
  2317. }
  2318. _print(root,indent) {
  2319. if(indent == null) {
  2320. indent = "";
  2321. }
  2322. if(root == null) {
  2323. return;
  2324. }
  2325. if(root._height == 0) {
  2326. console.log("src/oimo/collision/broadphase/bvh/BvhTree.hx:39:",indent + root._proxy._id);
  2327. } else {
  2328. this._print(root._children[0],indent + " ");
  2329. var tmp;
  2330. var size;
  2331. var sizeX;
  2332. var sizeY;
  2333. var sizeZ;
  2334. sizeX = root._aabbMaxX - root._aabbMinX;
  2335. sizeY = root._aabbMaxY - root._aabbMinY;
  2336. sizeZ = root._aabbMaxZ - root._aabbMinZ;
  2337. var x = sizeX;
  2338. var y = sizeY;
  2339. var z = sizeZ;
  2340. if(x * (y + z) + y * z > 0) {
  2341. var size1;
  2342. var sizeX1;
  2343. var sizeY1;
  2344. var sizeZ1;
  2345. sizeX1 = root._aabbMaxX - root._aabbMinX;
  2346. sizeY1 = root._aabbMaxY - root._aabbMinY;
  2347. sizeZ1 = root._aabbMaxZ - root._aabbMinZ;
  2348. var x1 = sizeX1;
  2349. var y1 = sizeY1;
  2350. var z1 = sizeZ1;
  2351. tmp = ((x1 * (y1 + z1) + y1 * z1) * 1000 + 0.5 | 0) / 1000;
  2352. } else {
  2353. var size2;
  2354. var sizeX2;
  2355. var sizeY2;
  2356. var sizeZ2;
  2357. sizeX2 = root._aabbMaxX - root._aabbMinX;
  2358. sizeY2 = root._aabbMaxY - root._aabbMinY;
  2359. sizeZ2 = root._aabbMaxZ - root._aabbMinZ;
  2360. var x2 = sizeX2;
  2361. var y2 = sizeY2;
  2362. var z2 = sizeZ2;
  2363. tmp = ((x2 * (y2 + z2) + y2 * z2) * 1000 - 0.5 | 0) / 1000;
  2364. }
  2365. console.log("src/oimo/collision/broadphase/bvh/BvhTree.hx:42:",indent + "#" + root._height + ", " + tmp);
  2366. this._print(root._children[1],indent + " ");
  2367. }
  2368. }
  2369. _getBalance() {
  2370. return this.getBalanceRecursive(this._root);
  2371. }
  2372. deleteRecursive(root) {
  2373. if(root._height == 0) {
  2374. var prev = root._prevLeaf;
  2375. var next = root._nextLeaf;
  2376. if(prev != null) {
  2377. prev._nextLeaf = next;
  2378. }
  2379. if(next != null) {
  2380. next._prevLeaf = prev;
  2381. }
  2382. if(root == this.leafList) {
  2383. this.leafList = this.leafList._nextLeaf;
  2384. }
  2385. if(root == this.leafListLast) {
  2386. this.leafListLast = this.leafListLast._prevLeaf;
  2387. }
  2388. root._nextLeaf = null;
  2389. root._prevLeaf = null;
  2390. root._proxy._leaf = null;
  2391. root._next = null;
  2392. root._childIndex = 0;
  2393. root._children[0] = null;
  2394. root._children[1] = null;
  2395. root._childIndex = 0;
  2396. root._parent = null;
  2397. root._height = 0;
  2398. root._proxy = null;
  2399. root._next = this._nodePool;
  2400. this._nodePool = root;
  2401. return;
  2402. }
  2403. this.deleteRecursive(root._children[0]);
  2404. this.deleteRecursive(root._children[1]);
  2405. root._next = null;
  2406. root._childIndex = 0;
  2407. root._children[0] = null;
  2408. root._children[1] = null;
  2409. root._childIndex = 0;
  2410. root._parent = null;
  2411. root._height = 0;
  2412. root._proxy = null;
  2413. root._next = this._nodePool;
  2414. this._nodePool = root;
  2415. }
  2416. decomposeRecursive(root) {
  2417. if(root._height == 0) {
  2418. root._childIndex = 0;
  2419. root._parent = null;
  2420. return;
  2421. }
  2422. this.decomposeRecursive(root._children[0]);
  2423. this.decomposeRecursive(root._children[1]);
  2424. root._next = null;
  2425. root._childIndex = 0;
  2426. root._children[0] = null;
  2427. root._children[1] = null;
  2428. root._childIndex = 0;
  2429. root._parent = null;
  2430. root._height = 0;
  2431. root._proxy = null;
  2432. root._next = this._nodePool;
  2433. this._nodePool = root;
  2434. }
  2435. buildTopDownRecursive(leaves,from,until) {
  2436. var num = until - from;
  2437. if(num == 1) {
  2438. var leaf = leaves[from];
  2439. var proxy = leaf._proxy;
  2440. leaf._aabbMinX = proxy._aabbMinX;
  2441. leaf._aabbMinY = proxy._aabbMinY;
  2442. leaf._aabbMinZ = proxy._aabbMinZ;
  2443. leaf._aabbMaxX = proxy._aabbMaxX;
  2444. leaf._aabbMaxY = proxy._aabbMaxY;
  2445. leaf._aabbMaxZ = proxy._aabbMaxZ;
  2446. return leaf;
  2447. }
  2448. var splitAt = this._strategy._splitLeaves(leaves,from,until);
  2449. var child1 = this.buildTopDownRecursive(leaves,from,splitAt);
  2450. var child2 = this.buildTopDownRecursive(leaves,splitAt,until);
  2451. var first = this._nodePool;
  2452. if(first != null) {
  2453. this._nodePool = first._next;
  2454. first._next = null;
  2455. } else {
  2456. first = new oimo.collision.broadphase.bvh.BvhNode();
  2457. }
  2458. var parent = first;
  2459. parent._children[0] = child1;
  2460. child1._parent = parent;
  2461. child1._childIndex = 0;
  2462. parent._children[1] = child2;
  2463. child2._parent = parent;
  2464. child2._childIndex = 1;
  2465. var c1 = parent._children[0];
  2466. var c2 = parent._children[1];
  2467. parent._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX;
  2468. parent._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY;
  2469. parent._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ;
  2470. parent._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX;
  2471. parent._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY;
  2472. parent._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ;
  2473. var h1 = parent._children[0]._height;
  2474. var h2 = parent._children[1]._height;
  2475. parent._height = (h1 > h2 ? h1 : h2) + 1;
  2476. return parent;
  2477. }
  2478. getBalanceRecursive(root) {
  2479. if(root == null || root._height == 0) {
  2480. return 0;
  2481. }
  2482. var balance = root._children[0]._height - root._children[1]._height;
  2483. if(balance < 0) {
  2484. balance = -balance;
  2485. }
  2486. return balance + this.getBalanceRecursive(root._children[0]) + this.getBalanceRecursive(root._children[1]);
  2487. }
  2488. }
  2489. oimo.collision.geometry.Aabb = class oimo_collision_geometry_Aabb {
  2490. constructor() {
  2491. this._minX = 0;
  2492. this._minY = 0;
  2493. this._minZ = 0;
  2494. this._maxX = 0;
  2495. this._maxY = 0;
  2496. this._maxZ = 0;
  2497. }
  2498. init(min,max) {
  2499. var v = min;
  2500. this._minX = v.x;
  2501. this._minY = v.y;
  2502. this._minZ = v.z;
  2503. var v1 = max;
  2504. this._maxX = v1.x;
  2505. this._maxY = v1.y;
  2506. this._maxZ = v1.z;
  2507. return this;
  2508. }
  2509. getMin() {
  2510. var min = new oimo.common.Vec3();
  2511. var v = min;
  2512. v.x = this._minX;
  2513. v.y = this._minY;
  2514. v.z = this._minZ;
  2515. return min;
  2516. }
  2517. getMinTo(min) {
  2518. var v = min;
  2519. v.x = this._minX;
  2520. v.y = this._minY;
  2521. v.z = this._minZ;
  2522. }
  2523. setMin(min) {
  2524. var v = min;
  2525. this._minX = v.x;
  2526. this._minY = v.y;
  2527. this._minZ = v.z;
  2528. return this;
  2529. }
  2530. getMax() {
  2531. var max = new oimo.common.Vec3();
  2532. var v = max;
  2533. v.x = this._maxX;
  2534. v.y = this._maxY;
  2535. v.z = this._maxZ;
  2536. return max;
  2537. }
  2538. getMaxTo(max) {
  2539. var v = max;
  2540. v.x = this._maxX;
  2541. v.y = this._maxY;
  2542. v.z = this._maxZ;
  2543. }
  2544. setMax(max) {
  2545. var v = max;
  2546. this._maxX = v.x;
  2547. this._maxY = v.y;
  2548. this._maxZ = v.z;
  2549. return this;
  2550. }
  2551. getCenter() {
  2552. var v = new oimo.common.Vec3();
  2553. var c;
  2554. var cX;
  2555. var cY;
  2556. var cZ;
  2557. cX = this._minX + this._maxX;
  2558. cY = this._minY + this._maxY;
  2559. cZ = this._minZ + this._maxZ;
  2560. cX *= 0.5;
  2561. cY *= 0.5;
  2562. cZ *= 0.5;
  2563. var v1 = v;
  2564. v1.x = cX;
  2565. v1.y = cY;
  2566. v1.z = cZ;
  2567. return v;
  2568. }
  2569. getCenterTo(center) {
  2570. var c;
  2571. var cX;
  2572. var cY;
  2573. var cZ;
  2574. cX = this._minX + this._maxX;
  2575. cY = this._minY + this._maxY;
  2576. cZ = this._minZ + this._maxZ;
  2577. cX *= 0.5;
  2578. cY *= 0.5;
  2579. cZ *= 0.5;
  2580. var v = center;
  2581. v.x = cX;
  2582. v.y = cY;
  2583. v.z = cZ;
  2584. }
  2585. getExtents() {
  2586. var v = new oimo.common.Vec3();
  2587. var c;
  2588. var cX;
  2589. var cY;
  2590. var cZ;
  2591. cX = this._maxX - this._minX;
  2592. cY = this._maxY - this._minY;
  2593. cZ = this._maxZ - this._minZ;
  2594. cX *= 0.5;
  2595. cY *= 0.5;
  2596. cZ *= 0.5;
  2597. var v1 = v;
  2598. v1.x = cX;
  2599. v1.y = cY;
  2600. v1.z = cZ;
  2601. return v;
  2602. }
  2603. getExtentsTo(halfExtents) {
  2604. var c;
  2605. var cX;
  2606. var cY;
  2607. var cZ;
  2608. cX = this._maxX - this._minX;
  2609. cY = this._maxY - this._minY;
  2610. cZ = this._maxZ - this._minZ;
  2611. cX *= 0.5;
  2612. cY *= 0.5;
  2613. cZ *= 0.5;
  2614. var v = halfExtents;
  2615. v.x = cX;
  2616. v.y = cY;
  2617. v.z = cZ;
  2618. }
  2619. combine(other) {
  2620. this._minX = this._minX < other._minX ? this._minX : other._minX;
  2621. this._minY = this._minY < other._minY ? this._minY : other._minY;
  2622. this._minZ = this._minZ < other._minZ ? this._minZ : other._minZ;
  2623. this._maxX = this._maxX > other._maxX ? this._maxX : other._maxX;
  2624. this._maxY = this._maxY > other._maxY ? this._maxY : other._maxY;
  2625. this._maxZ = this._maxZ > other._maxZ ? this._maxZ : other._maxZ;
  2626. return this;
  2627. }
  2628. combined(other) {
  2629. var aabb = new oimo.collision.geometry.Aabb();
  2630. aabb._minX = this._minX < other._minX ? this._minX : other._minX;
  2631. aabb._minY = this._minY < other._minY ? this._minY : other._minY;
  2632. aabb._minZ = this._minZ < other._minZ ? this._minZ : other._minZ;
  2633. aabb._maxX = this._maxX > other._maxX ? this._maxX : other._maxX;
  2634. aabb._maxY = this._maxY > other._maxY ? this._maxY : other._maxY;
  2635. aabb._maxZ = this._maxZ > other._maxZ ? this._maxZ : other._maxZ;
  2636. return aabb;
  2637. }
  2638. overlap(other) {
  2639. if(this._minX < other._maxX && this._maxX > other._minX && this._minY < other._maxY && this._maxY > other._minY && this._minZ < other._maxZ) {
  2640. return this._maxZ > other._minZ;
  2641. } else {
  2642. return false;
  2643. }
  2644. }
  2645. getIntersection(other) {
  2646. var aabb = new oimo.collision.geometry.Aabb();
  2647. aabb._minX = this._minX > other._minX ? this._minX : other._minX;
  2648. aabb._minY = this._minY > other._minY ? this._minY : other._minY;
  2649. aabb._minZ = this._minZ > other._minZ ? this._minZ : other._minZ;
  2650. aabb._maxX = this._maxX < other._maxX ? this._maxX : other._maxX;
  2651. aabb._maxY = this._maxY < other._maxY ? this._maxY : other._maxY;
  2652. aabb._maxZ = this._maxZ < other._maxZ ? this._maxZ : other._maxZ;
  2653. return aabb;
  2654. }
  2655. getIntersectionTo(other,intersection) {
  2656. intersection._minX = this._minX > other._minX ? this._minX : other._minX;
  2657. intersection._minY = this._minY > other._minY ? this._minY : other._minY;
  2658. intersection._minZ = this._minZ > other._minZ ? this._minZ : other._minZ;
  2659. intersection._maxX = this._maxX < other._maxX ? this._maxX : other._maxX;
  2660. intersection._maxY = this._maxY < other._maxY ? this._maxY : other._maxY;
  2661. intersection._maxZ = this._maxZ < other._maxZ ? this._maxZ : other._maxZ;
  2662. }
  2663. copyFrom(aabb) {
  2664. this._minX = aabb._minX;
  2665. this._minY = aabb._minY;
  2666. this._minZ = aabb._minZ;
  2667. this._maxX = aabb._maxX;
  2668. this._maxY = aabb._maxY;
  2669. this._maxZ = aabb._maxZ;
  2670. return this;
  2671. }
  2672. clone() {
  2673. var aabb = new oimo.collision.geometry.Aabb();
  2674. aabb._minX = this._minX;
  2675. aabb._minY = this._minY;
  2676. aabb._minZ = this._minZ;
  2677. aabb._maxX = this._maxX;
  2678. aabb._maxY = this._maxY;
  2679. aabb._maxZ = this._maxZ;
  2680. return aabb;
  2681. }
  2682. }
  2683. oimo.collision.geometry.BoxGeometry = class oimo_collision_geometry_BoxGeometry extends oimo.collision.geometry.ConvexGeometry {
  2684. constructor(halfExtents) {
  2685. super(1);
  2686. var v = halfExtents;
  2687. this._halfExtentsX = v.x;
  2688. this._halfExtentsY = v.y;
  2689. this._halfExtentsZ = v.z;
  2690. this._halfAxisXX = halfExtents.x;
  2691. this._halfAxisXY = 0;
  2692. this._halfAxisXZ = 0;
  2693. this._halfAxisYX = 0;
  2694. this._halfAxisYY = halfExtents.y;
  2695. this._halfAxisYZ = 0;
  2696. this._halfAxisZX = 0;
  2697. this._halfAxisZY = 0;
  2698. this._halfAxisZZ = halfExtents.z;
  2699. this._updateMass();
  2700. var minHalfExtents = halfExtents.x < halfExtents.y ? halfExtents.z < halfExtents.x ? halfExtents.z : halfExtents.x : halfExtents.z < halfExtents.y ? halfExtents.z : halfExtents.y;
  2701. if(this._gjkMargin > minHalfExtents * 0.2) {
  2702. this._gjkMargin = minHalfExtents * 0.2;
  2703. }
  2704. }
  2705. getHalfExtents() {
  2706. var v = new oimo.common.Vec3();
  2707. var v1 = v;
  2708. v1.x = this._halfExtentsX;
  2709. v1.y = this._halfExtentsY;
  2710. v1.z = this._halfExtentsZ;
  2711. return v;
  2712. }
  2713. getHalfExtentsTo(halfExtents) {
  2714. var v = halfExtents;
  2715. v.x = this._halfExtentsX;
  2716. v.y = this._halfExtentsY;
  2717. v.z = this._halfExtentsZ;
  2718. }
  2719. _updateMass() {
  2720. this._volume = 8 * (this._halfExtentsX * this._halfExtentsY * this._halfExtentsZ);
  2721. var sq;
  2722. var sqX;
  2723. var sqY;
  2724. var sqZ;
  2725. sqX = this._halfExtentsX * this._halfExtentsX;
  2726. sqY = this._halfExtentsY * this._halfExtentsY;
  2727. sqZ = this._halfExtentsZ * this._halfExtentsZ;
  2728. this._inertiaCoeff00 = 0.333333333333333315 * (sqY + sqZ);
  2729. this._inertiaCoeff01 = 0;
  2730. this._inertiaCoeff02 = 0;
  2731. this._inertiaCoeff10 = 0;
  2732. this._inertiaCoeff11 = 0.333333333333333315 * (sqZ + sqX);
  2733. this._inertiaCoeff12 = 0;
  2734. this._inertiaCoeff20 = 0;
  2735. this._inertiaCoeff21 = 0;
  2736. this._inertiaCoeff22 = 0.333333333333333315 * (sqX + sqY);
  2737. }
  2738. _computeAabb(aabb,tf) {
  2739. var tfx;
  2740. var tfxX;
  2741. var tfxY;
  2742. var tfxZ;
  2743. var tfy;
  2744. var tfyX;
  2745. var tfyY;
  2746. var tfyZ;
  2747. var tfz;
  2748. var tfzX;
  2749. var tfzY;
  2750. var tfzZ;
  2751. var __tmp__X;
  2752. var __tmp__Y;
  2753. var __tmp__Z;
  2754. __tmp__X = tf._rotation00 * this._halfAxisXX + tf._rotation01 * this._halfAxisXY + tf._rotation02 * this._halfAxisXZ;
  2755. __tmp__Y = tf._rotation10 * this._halfAxisXX + tf._rotation11 * this._halfAxisXY + tf._rotation12 * this._halfAxisXZ;
  2756. __tmp__Z = tf._rotation20 * this._halfAxisXX + tf._rotation21 * this._halfAxisXY + tf._rotation22 * this._halfAxisXZ;
  2757. tfxX = __tmp__X;
  2758. tfxY = __tmp__Y;
  2759. tfxZ = __tmp__Z;
  2760. var __tmp__X1;
  2761. var __tmp__Y1;
  2762. var __tmp__Z1;
  2763. __tmp__X1 = tf._rotation00 * this._halfAxisYX + tf._rotation01 * this._halfAxisYY + tf._rotation02 * this._halfAxisYZ;
  2764. __tmp__Y1 = tf._rotation10 * this._halfAxisYX + tf._rotation11 * this._halfAxisYY + tf._rotation12 * this._halfAxisYZ;
  2765. __tmp__Z1 = tf._rotation20 * this._halfAxisYX + tf._rotation21 * this._halfAxisYY + tf._rotation22 * this._halfAxisYZ;
  2766. tfyX = __tmp__X1;
  2767. tfyY = __tmp__Y1;
  2768. tfyZ = __tmp__Z1;
  2769. var __tmp__X2;
  2770. var __tmp__Y2;
  2771. var __tmp__Z2;
  2772. __tmp__X2 = tf._rotation00 * this._halfAxisZX + tf._rotation01 * this._halfAxisZY + tf._rotation02 * this._halfAxisZZ;
  2773. __tmp__Y2 = tf._rotation10 * this._halfAxisZX + tf._rotation11 * this._halfAxisZY + tf._rotation12 * this._halfAxisZZ;
  2774. __tmp__Z2 = tf._rotation20 * this._halfAxisZX + tf._rotation21 * this._halfAxisZY + tf._rotation22 * this._halfAxisZZ;
  2775. tfzX = __tmp__X2;
  2776. tfzY = __tmp__Y2;
  2777. tfzZ = __tmp__Z2;
  2778. tfxX = tfxX < 0 ? -tfxX : tfxX;
  2779. tfxY = tfxY < 0 ? -tfxY : tfxY;
  2780. tfxZ = tfxZ < 0 ? -tfxZ : tfxZ;
  2781. tfyX = tfyX < 0 ? -tfyX : tfyX;
  2782. tfyY = tfyY < 0 ? -tfyY : tfyY;
  2783. tfyZ = tfyZ < 0 ? -tfyZ : tfyZ;
  2784. tfzX = tfzX < 0 ? -tfzX : tfzX;
  2785. tfzY = tfzY < 0 ? -tfzY : tfzY;
  2786. tfzZ = tfzZ < 0 ? -tfzZ : tfzZ;
  2787. var tfs;
  2788. var tfsX;
  2789. var tfsY;
  2790. var tfsZ;
  2791. tfsX = tfxX + tfyX;
  2792. tfsY = tfxY + tfyY;
  2793. tfsZ = tfxZ + tfyZ;
  2794. tfsX += tfzX;
  2795. tfsY += tfzY;
  2796. tfsZ += tfzZ;
  2797. aabb._minX = tf._positionX - tfsX;
  2798. aabb._minY = tf._positionY - tfsY;
  2799. aabb._minZ = tf._positionZ - tfsZ;
  2800. aabb._maxX = tf._positionX + tfsX;
  2801. aabb._maxY = tf._positionY + tfsY;
  2802. aabb._maxZ = tf._positionZ + tfsZ;
  2803. }
  2804. computeLocalSupportingVertex(dir,out) {
  2805. var gjkMargins;
  2806. var gjkMarginsX;
  2807. var gjkMarginsY;
  2808. var gjkMarginsZ;
  2809. var coreExtents;
  2810. var coreExtentsX;
  2811. var coreExtentsY;
  2812. var coreExtentsZ;
  2813. gjkMarginsX = this._gjkMargin;
  2814. gjkMarginsY = this._gjkMargin;
  2815. gjkMarginsZ = this._gjkMargin;
  2816. gjkMarginsX = gjkMarginsX < this._halfExtentsX ? gjkMarginsX : this._halfExtentsX;
  2817. gjkMarginsY = gjkMarginsY < this._halfExtentsY ? gjkMarginsY : this._halfExtentsY;
  2818. gjkMarginsZ = gjkMarginsZ < this._halfExtentsZ ? gjkMarginsZ : this._halfExtentsZ;
  2819. coreExtentsX = this._halfExtentsX - gjkMarginsX;
  2820. coreExtentsY = this._halfExtentsY - gjkMarginsY;
  2821. coreExtentsZ = this._halfExtentsZ - gjkMarginsZ;
  2822. out.x = dir.x > 0 ? coreExtentsX : -coreExtentsX;
  2823. out.y = dir.y > 0 ? coreExtentsY : -coreExtentsY;
  2824. out.z = dir.z > 0 ? coreExtentsZ : -coreExtentsZ;
  2825. }
  2826. _rayCastLocal(beginX,beginY,beginZ,endX,endY,endZ,hit) {
  2827. var p1x = beginX;
  2828. var p1y = beginY;
  2829. var p1z = beginZ;
  2830. var p2x = endX;
  2831. var p2y = endY;
  2832. var p2z = endZ;
  2833. var halfW = this._halfExtentsX;
  2834. var halfH = this._halfExtentsY;
  2835. var halfD = this._halfExtentsZ;
  2836. var dx = p2x - p1x;
  2837. var dy = p2y - p1y;
  2838. var dz = p2z - p1z;
  2839. var tminx = 0;
  2840. var tminy = 0;
  2841. var tminz = 0;
  2842. var tmaxx = 1;
  2843. var tmaxy = 1;
  2844. var tmaxz = 1;
  2845. if(dx > -1e-6 && dx < 1e-6) {
  2846. if(p1x <= -halfW || p1x >= halfW) {
  2847. return false;
  2848. }
  2849. } else {
  2850. var invDx = 1 / dx;
  2851. var t1 = (-halfW - p1x) * invDx;
  2852. var t2 = (halfW - p1x) * invDx;
  2853. if(t1 > t2) {
  2854. var tmp = t1;
  2855. t1 = t2;
  2856. t2 = tmp;
  2857. }
  2858. if(t1 > 0) {
  2859. tminx = t1;
  2860. }
  2861. if(t2 < 1) {
  2862. tmaxx = t2;
  2863. }
  2864. }
  2865. if(dy > -1e-6 && dy < 1e-6) {
  2866. if(p1y <= -halfH || p1y >= halfH) {
  2867. return false;
  2868. }
  2869. } else {
  2870. var invDy = 1 / dy;
  2871. var t11 = (-halfH - p1y) * invDy;
  2872. var t21 = (halfH - p1y) * invDy;
  2873. if(t11 > t21) {
  2874. var tmp1 = t11;
  2875. t11 = t21;
  2876. t21 = tmp1;
  2877. }
  2878. if(t11 > 0) {
  2879. tminy = t11;
  2880. }
  2881. if(t21 < 1) {
  2882. tmaxy = t21;
  2883. }
  2884. }
  2885. if(dz > -1e-6 && dz < 1e-6) {
  2886. if(p1z <= -halfD || p1z >= halfD) {
  2887. return false;
  2888. }
  2889. } else {
  2890. var invDz = 1 / dz;
  2891. var t12 = (-halfD - p1z) * invDz;
  2892. var t22 = (halfD - p1z) * invDz;
  2893. if(t12 > t22) {
  2894. var tmp2 = t12;
  2895. t12 = t22;
  2896. t22 = tmp2;
  2897. }
  2898. if(t12 > 0) {
  2899. tminz = t12;
  2900. }
  2901. if(t22 < 1) {
  2902. tmaxz = t22;
  2903. }
  2904. }
  2905. if(tminx >= 1 || tminy >= 1 || tminz >= 1 || tmaxx <= 0 || tmaxy <= 0 || tmaxz <= 0) {
  2906. return false;
  2907. }
  2908. var min = tminx;
  2909. var max = tmaxx;
  2910. var hitDirection = 0;
  2911. if(tminy > min) {
  2912. min = tminy;
  2913. hitDirection = 1;
  2914. }
  2915. if(tminz > min) {
  2916. min = tminz;
  2917. hitDirection = 2;
  2918. }
  2919. if(tmaxy < max) {
  2920. max = tmaxy;
  2921. }
  2922. if(tmaxz < max) {
  2923. max = tmaxz;
  2924. }
  2925. if(min > max) {
  2926. return false;
  2927. }
  2928. if(min == 0) {
  2929. return false;
  2930. }
  2931. switch(hitDirection) {
  2932. case 0:
  2933. hit.normal.init(dx > 0 ? -1 : 1,0,0);
  2934. break;
  2935. case 1:
  2936. hit.normal.init(0,dy > 0 ? -1 : 1,0);
  2937. break;
  2938. case 2:
  2939. hit.normal.init(0,0,dz > 0 ? -1 : 1);
  2940. break;
  2941. }
  2942. hit.position.init(p1x + min * dx,p1y + min * dy,p1z + min * dz);
  2943. hit.fraction = min;
  2944. return true;
  2945. }
  2946. }
  2947. oimo.collision.geometry.CapsuleGeometry = class oimo_collision_geometry_CapsuleGeometry extends oimo.collision.geometry.ConvexGeometry {
  2948. constructor(radius,halfHeight) {
  2949. super(4);
  2950. this._radius = radius;
  2951. this._halfHeight = halfHeight;
  2952. this._gjkMargin = this._radius;
  2953. this._updateMass();
  2954. }
  2955. getRadius() {
  2956. return this._radius;
  2957. }
  2958. getHalfHeight() {
  2959. return this._halfHeight;
  2960. }
  2961. _updateMass() {
  2962. var r2 = this._radius * this._radius;
  2963. var hh2 = this._halfHeight * this._halfHeight;
  2964. var cylinderVolume = 6.28318530717958 * r2 * this._halfHeight;
  2965. var sphereVolume = 3.14159265358979 * r2 * this._radius * 4 / 3;
  2966. this._volume = cylinderVolume + sphereVolume;
  2967. var invVolume = this._volume == 0 ? 0 : 1 / this._volume;
  2968. var inertiaY = invVolume * (cylinderVolume * r2 * 0.5 + sphereVolume * r2 * 0.4);
  2969. var inertiaXZ = invVolume * (cylinderVolume * (r2 * 0.25 + hh2 / 3) + sphereVolume * (r2 * 0.4 + this._halfHeight * this._radius * 0.75 + hh2));
  2970. this._inertiaCoeff00 = inertiaXZ;
  2971. this._inertiaCoeff01 = 0;
  2972. this._inertiaCoeff02 = 0;
  2973. this._inertiaCoeff10 = 0;
  2974. this._inertiaCoeff11 = inertiaY;
  2975. this._inertiaCoeff12 = 0;
  2976. this._inertiaCoeff20 = 0;
  2977. this._inertiaCoeff21 = 0;
  2978. this._inertiaCoeff22 = inertiaXZ;
  2979. }
  2980. _computeAabb(aabb,tf) {
  2981. var radVec;
  2982. var radVecX;
  2983. var radVecY;
  2984. var radVecZ;
  2985. radVecX = this._radius;
  2986. radVecY = this._radius;
  2987. radVecZ = this._radius;
  2988. var axis;
  2989. var axisX;
  2990. var axisY;
  2991. var axisZ;
  2992. axisX = tf._rotation01;
  2993. axisY = tf._rotation11;
  2994. axisZ = tf._rotation21;
  2995. axisX = axisX < 0 ? -axisX : axisX;
  2996. axisY = axisY < 0 ? -axisY : axisY;
  2997. axisZ = axisZ < 0 ? -axisZ : axisZ;
  2998. axisX *= this._halfHeight;
  2999. axisY *= this._halfHeight;
  3000. axisZ *= this._halfHeight;
  3001. radVecX += axisX;
  3002. radVecY += axisY;
  3003. radVecZ += axisZ;
  3004. aabb._minX = tf._positionX - radVecX;
  3005. aabb._minY = tf._positionY - radVecY;
  3006. aabb._minZ = tf._positionZ - radVecZ;
  3007. aabb._maxX = tf._positionX + radVecX;
  3008. aabb._maxY = tf._positionY + radVecY;
  3009. aabb._maxZ = tf._positionZ + radVecZ;
  3010. }
  3011. computeLocalSupportingVertex(dir,out) {
  3012. if(dir.y > 0) {
  3013. out.init(0,this._halfHeight,0);
  3014. } else {
  3015. out.init(0,-this._halfHeight,0);
  3016. }
  3017. }
  3018. _rayCastLocal(beginX,beginY,beginZ,endX,endY,endZ,hit) {
  3019. var p1x = beginX;
  3020. var p1y = beginY;
  3021. var p1z = beginZ;
  3022. var p2x = endX;
  3023. var p2y = endY;
  3024. var p2z = endZ;
  3025. var halfH = this._halfHeight;
  3026. var dx = p2x - p1x;
  3027. var dy = p2y - p1y;
  3028. var dz = p2z - p1z;
  3029. var tminxz = 0;
  3030. var tmaxxz = 1;
  3031. var a = dx * dx + dz * dz;
  3032. var b = p1x * dx + p1z * dz;
  3033. var c = p1x * p1x + p1z * p1z - this._radius * this._radius;
  3034. var D = b * b - a * c;
  3035. if(D < 0) {
  3036. return false;
  3037. }
  3038. var t;
  3039. if(a > 0) {
  3040. var sqrtD = Math.sqrt(D);
  3041. tminxz = (-b - sqrtD) / a;
  3042. tmaxxz = (-b + sqrtD) / a;
  3043. if(tminxz >= 1 || tmaxxz <= 0) {
  3044. return false;
  3045. }
  3046. } else {
  3047. if(c >= 0) {
  3048. return false;
  3049. }
  3050. tminxz = 0;
  3051. tmaxxz = 1;
  3052. }
  3053. var crossY = p1y + dy * tminxz;
  3054. var min;
  3055. if(crossY > -halfH && crossY < halfH) {
  3056. if(tminxz > 0) {
  3057. min = tminxz;
  3058. var _this = hit.normal.init(p1x + dx * min,0,p1z + dz * min);
  3059. var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
  3060. if(invLen > 0) {
  3061. invLen = 1 / invLen;
  3062. }
  3063. var tx = _this.x * invLen;
  3064. var ty = _this.y * invLen;
  3065. var tz = _this.z * invLen;
  3066. _this.x = tx;
  3067. _this.y = ty;
  3068. _this.z = tz;
  3069. hit.position.init(p1x + min * dx,crossY,p1z + min * dz);
  3070. hit.fraction = min;
  3071. return true;
  3072. }
  3073. return false;
  3074. }
  3075. var sphereY = crossY < 0 ? -halfH : halfH;
  3076. var spherePos;
  3077. var spherePosX;
  3078. var spherePosY;
  3079. var spherePosZ;
  3080. var sphereToBegin;
  3081. var sphereToBeginX;
  3082. var sphereToBeginY;
  3083. var sphereToBeginZ;
  3084. spherePosX = 0;
  3085. spherePosY = sphereY;
  3086. spherePosZ = 0;
  3087. sphereToBeginX = beginX - spherePosX;
  3088. sphereToBeginY = beginY - spherePosY;
  3089. sphereToBeginZ = beginZ - spherePosZ;
  3090. var d;
  3091. var dX;
  3092. var dY;
  3093. var dZ;
  3094. dX = endX - beginX;
  3095. dY = endY - beginY;
  3096. dZ = endZ - beginZ;
  3097. a = dX * dX + dY * dY + dZ * dZ;
  3098. b = sphereToBeginX * dX + sphereToBeginY * dY + sphereToBeginZ * dZ;
  3099. c = sphereToBeginX * sphereToBeginX + sphereToBeginY * sphereToBeginY + sphereToBeginZ * sphereToBeginZ - this._radius * this._radius;
  3100. D = b * b - a * c;
  3101. if(D < 0) {
  3102. return false;
  3103. }
  3104. var t1 = (-b - Math.sqrt(D)) / a;
  3105. if(t1 < 0 || t1 > 1) {
  3106. return false;
  3107. }
  3108. var hitPos;
  3109. var hitPosX;
  3110. var hitPosY;
  3111. var hitPosZ;
  3112. var hitNormal;
  3113. var hitNormalX;
  3114. var hitNormalY;
  3115. var hitNormalZ;
  3116. hitPosX = sphereToBeginX + dX * t1;
  3117. hitPosY = sphereToBeginY + dY * t1;
  3118. hitPosZ = sphereToBeginZ + dZ * t1;
  3119. var l = hitPosX * hitPosX + hitPosY * hitPosY + hitPosZ * hitPosZ;
  3120. if(l > 0) {
  3121. l = 1 / Math.sqrt(l);
  3122. }
  3123. hitNormalX = hitPosX * l;
  3124. hitNormalY = hitPosY * l;
  3125. hitNormalZ = hitPosZ * l;
  3126. hitPosX += spherePosX;
  3127. hitPosY += spherePosY;
  3128. hitPosZ += spherePosZ;
  3129. var v = hit.position;
  3130. v.x = hitPosX;
  3131. v.y = hitPosY;
  3132. v.z = hitPosZ;
  3133. var v1 = hit.normal;
  3134. v1.x = hitNormalX;
  3135. v1.y = hitNormalY;
  3136. v1.z = hitNormalZ;
  3137. hit.fraction = t1;
  3138. return true;
  3139. }
  3140. }
  3141. oimo.collision.geometry.ConeGeometry = class oimo_collision_geometry_ConeGeometry extends oimo.collision.geometry.ConvexGeometry {
  3142. constructor(radius,halfHeight) {
  3143. super(3);
  3144. this._radius = radius;
  3145. this._halfHeight = halfHeight;
  3146. this.sinTheta = radius / Math.sqrt(radius * radius + 4 * halfHeight * halfHeight);
  3147. this.cosTheta = 2 * halfHeight / Math.sqrt(radius * radius + 4 * halfHeight * halfHeight);
  3148. this._updateMass();
  3149. }
  3150. getRadius() {
  3151. return this._radius;
  3152. }
  3153. getHalfHeight() {
  3154. return this._halfHeight;
  3155. }
  3156. _updateMass() {
  3157. var r2 = this._radius * this._radius;
  3158. var h2 = this._halfHeight * this._halfHeight * 4;
  3159. this._volume = 3.14159265358979 * r2 * this._halfHeight * 2 / 3;
  3160. this._inertiaCoeff00 = 0.05 * (3 * r2 + 2 * h2);
  3161. this._inertiaCoeff01 = 0;
  3162. this._inertiaCoeff02 = 0;
  3163. this._inertiaCoeff10 = 0;
  3164. this._inertiaCoeff11 = 0.3 * r2;
  3165. this._inertiaCoeff12 = 0;
  3166. this._inertiaCoeff20 = 0;
  3167. this._inertiaCoeff21 = 0;
  3168. this._inertiaCoeff22 = 0.05 * (3 * r2 + 2 * h2);
  3169. }
  3170. _computeAabb(aabb,tf) {
  3171. var axis;
  3172. var axisX;
  3173. var axisY;
  3174. var axisZ;
  3175. var axis2;
  3176. var axis2X;
  3177. var axis2Y;
  3178. var axis2Z;
  3179. var eh;
  3180. var ehX;
  3181. var ehY;
  3182. var ehZ;
  3183. var er;
  3184. var erX;
  3185. var erY;
  3186. var erZ;
  3187. axisX = tf._rotation01;
  3188. axisY = tf._rotation11;
  3189. axisZ = tf._rotation21;
  3190. axis2X = axisX * axisX;
  3191. axis2Y = axisY * axisY;
  3192. axis2Z = axisZ * axisZ;
  3193. var axis2x = axis2X;
  3194. var axis2y = axis2Y;
  3195. var axis2z = axis2Z;
  3196. erX = Math.sqrt(1 - axis2x);
  3197. erY = Math.sqrt(1 - axis2y);
  3198. erZ = Math.sqrt(1 - axis2z);
  3199. erX *= this._radius;
  3200. erY *= this._radius;
  3201. erZ *= this._radius;
  3202. ehX = axisX * this._halfHeight;
  3203. ehY = axisY * this._halfHeight;
  3204. ehZ = axisZ * this._halfHeight;
  3205. var rmin;
  3206. var rminX;
  3207. var rminY;
  3208. var rminZ;
  3209. var rmax;
  3210. var rmaxX;
  3211. var rmaxY;
  3212. var rmaxZ;
  3213. rminX = -ehX;
  3214. rminY = -ehY;
  3215. rminZ = -ehZ;
  3216. rminX -= erX;
  3217. rminY -= erY;
  3218. rminZ -= erZ;
  3219. rmaxX = -ehX;
  3220. rmaxY = -ehY;
  3221. rmaxZ = -ehZ;
  3222. rmaxX += erX;
  3223. rmaxY += erY;
  3224. rmaxZ += erZ;
  3225. var max;
  3226. var maxX;
  3227. var maxY;
  3228. var maxZ;
  3229. var min;
  3230. var minX;
  3231. var minY;
  3232. var minZ;
  3233. maxX = rminX > rmaxX ? rminX : rmaxX;
  3234. maxY = rminY > rmaxY ? rminY : rmaxY;
  3235. maxZ = rminZ > rmaxZ ? rminZ : rmaxZ;
  3236. maxX = maxX > ehX ? maxX : ehX;
  3237. maxY = maxY > ehY ? maxY : ehY;
  3238. maxZ = maxZ > ehZ ? maxZ : ehZ;
  3239. minX = rminX < rmaxX ? rminX : rmaxX;
  3240. minY = rminY < rmaxY ? rminY : rmaxY;
  3241. minZ = rminZ < rmaxZ ? rminZ : rmaxZ;
  3242. minX = minX < ehX ? minX : ehX;
  3243. minY = minY < ehY ? minY : ehY;
  3244. minZ = minZ < ehZ ? minZ : ehZ;
  3245. aabb._minX = tf._positionX + minX;
  3246. aabb._minY = tf._positionY + minY;
  3247. aabb._minZ = tf._positionZ + minZ;
  3248. aabb._maxX = tf._positionX + maxX;
  3249. aabb._maxY = tf._positionY + maxY;
  3250. aabb._maxZ = tf._positionZ + maxZ;
  3251. }
  3252. computeLocalSupportingVertex(dir,out) {
  3253. var dx = dir.x;
  3254. var dy = dir.y;
  3255. var dz = dir.z;
  3256. if(dy > 0 && dy * dy > this.sinTheta * this.sinTheta * (dx * dx + dy * dy + dz * dz)) {
  3257. out.init(0,this._halfHeight - this._gjkMargin / this.sinTheta,0);
  3258. if(out.y < 0) {
  3259. out.y = 0;
  3260. }
  3261. return;
  3262. }
  3263. var rx = dir.x;
  3264. var rz = dir.z;
  3265. var len = rx * rx + rz * rz;
  3266. var height = 2 * this._halfHeight;
  3267. var coreRadius = (height - this._gjkMargin) / height * this._radius - this._gjkMargin / this.cosTheta;
  3268. if(coreRadius < 0) {
  3269. coreRadius = 0;
  3270. }
  3271. var invLen = len > 0 ? coreRadius / Math.sqrt(len) : 0;
  3272. var coreHalfHeight = this._halfHeight - this._gjkMargin;
  3273. if(coreHalfHeight < 0) {
  3274. coreHalfHeight = 0;
  3275. }
  3276. out.x = rx * invLen;
  3277. out.y = -coreHalfHeight;
  3278. out.z = rz * invLen;
  3279. }
  3280. _rayCastLocal(beginX,beginY,beginZ,endX,endY,endZ,hit) {
  3281. var p1x = beginX;
  3282. var p1y = beginY;
  3283. var p1z = beginZ;
  3284. var p2x = endX;
  3285. var p2y = endY;
  3286. var p2z = endZ;
  3287. var halfH = this._halfHeight;
  3288. var dx = p2x - p1x;
  3289. var dy = p2y - p1y;
  3290. var dz = p2z - p1z;
  3291. var tminy = 0;
  3292. var tmaxy = 1;
  3293. if(dy > -1e-6 && dy < 1e-6) {
  3294. if(p1y <= -halfH || p1y >= halfH) {
  3295. return false;
  3296. }
  3297. } else {
  3298. var invDy = 1 / dy;
  3299. var t1 = (-halfH - p1y) * invDy;
  3300. var t2 = (halfH - p1y) * invDy;
  3301. if(t1 > t2) {
  3302. var tmp = t1;
  3303. t1 = t2;
  3304. t2 = tmp;
  3305. }
  3306. if(t1 > 0) {
  3307. tminy = t1;
  3308. }
  3309. if(t2 < 1) {
  3310. tmaxy = t2;
  3311. }
  3312. }
  3313. if(tminy >= 1 || tmaxy <= 0) {
  3314. return false;
  3315. }
  3316. var tminxz = 0;
  3317. var tmaxxz = 0;
  3318. p1y -= halfH;
  3319. var cos2 = this.cosTheta * this.cosTheta;
  3320. var a = cos2 * (dx * dx + dy * dy + dz * dz) - dy * dy;
  3321. var b = cos2 * (p1x * dx + p1y * dy + p1z * dz) - p1y * dy;
  3322. var c = cos2 * (p1x * p1x + p1y * p1y + p1z * p1z) - p1y * p1y;
  3323. var D = b * b - a * c;
  3324. if(a != 0) {
  3325. if(D < 0) {
  3326. return false;
  3327. }
  3328. var sqrtD = Math.sqrt(D);
  3329. if(a < 0) {
  3330. if(dy > 0) {
  3331. tminxz = 0;
  3332. tmaxxz = (-b + sqrtD) / a;
  3333. if(tmaxxz <= 0) {
  3334. return false;
  3335. }
  3336. } else {
  3337. tminxz = (-b - sqrtD) / a;
  3338. tmaxxz = 1;
  3339. if(tminxz >= 1) {
  3340. return false;
  3341. }
  3342. }
  3343. } else {
  3344. tminxz = (-b - sqrtD) / a;
  3345. tmaxxz = (-b + sqrtD) / a;
  3346. if(tminxz >= 1 || tmaxxz <= 0) {
  3347. return false;
  3348. }
  3349. }
  3350. } else {
  3351. var t = -c / (2 * b);
  3352. if(b > 0) {
  3353. tminxz = 0;
  3354. tmaxxz = t;
  3355. if(t <= 0) {
  3356. return false;
  3357. }
  3358. } else {
  3359. tminxz = t;
  3360. tmaxxz = 1;
  3361. if(t >= 1) {
  3362. return false;
  3363. }
  3364. }
  3365. }
  3366. p1y += halfH;
  3367. var min;
  3368. if(tmaxxz <= tminy || tmaxy <= tminxz) {
  3369. return false;
  3370. }
  3371. if(tminxz < tminy) {
  3372. min = tminy;
  3373. if(min == 0) {
  3374. return false;
  3375. }
  3376. hit.normal.init(0,dy > 0 ? -1 : 1,0);
  3377. } else {
  3378. min = tminxz;
  3379. if(min == 0) {
  3380. return false;
  3381. }
  3382. var _this = hit.normal.init(p1x + dx * min,0,p1z + dz * min);
  3383. var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
  3384. if(invLen > 0) {
  3385. invLen = 1 / invLen;
  3386. }
  3387. var tx = _this.x * invLen;
  3388. var ty = _this.y * invLen;
  3389. var tz = _this.z * invLen;
  3390. _this.x = tx;
  3391. _this.y = ty;
  3392. _this.z = tz;
  3393. var _this1 = _this;
  3394. var s = this.cosTheta;
  3395. var tx1 = _this1.x * s;
  3396. var ty1 = _this1.y * s;
  3397. var tz1 = _this1.z * s;
  3398. _this1.x = tx1;
  3399. _this1.y = ty1;
  3400. _this1.z = tz1;
  3401. hit.normal.y += this.sinTheta;
  3402. }
  3403. hit.position.init(p1x + min * dx,p1y + min * dy,p1z + min * dz);
  3404. hit.fraction = min;
  3405. return true;
  3406. }
  3407. }
  3408. oimo.collision.geometry.ConvexHullGeometry = class oimo_collision_geometry_ConvexHullGeometry extends oimo.collision.geometry.ConvexGeometry {
  3409. constructor(vertices) {
  3410. super(5);
  3411. this._numVertices = vertices.length;
  3412. var this1 = new Array(this._numVertices);
  3413. this._vertices = this1;
  3414. var this2 = new Array(this._numVertices);
  3415. this._tmpVertices = this2;
  3416. var _g = 0;
  3417. var _g1 = this._numVertices;
  3418. while(_g < _g1) {
  3419. var i = _g++;
  3420. this._vertices[i] = vertices[i];
  3421. this._tmpVertices[i] = new oimo.common.Vec3();
  3422. }
  3423. this._useGjkRayCast = true;
  3424. this._updateMass();
  3425. }
  3426. getVertices() {
  3427. return this._vertices;
  3428. }
  3429. _updateMass() {
  3430. this._volume = 1;
  3431. this._inertiaCoeff00 = 1;
  3432. this._inertiaCoeff01 = 0;
  3433. this._inertiaCoeff02 = 0;
  3434. this._inertiaCoeff10 = 0;
  3435. this._inertiaCoeff11 = 1;
  3436. this._inertiaCoeff12 = 0;
  3437. this._inertiaCoeff20 = 0;
  3438. this._inertiaCoeff21 = 0;
  3439. this._inertiaCoeff22 = 1;
  3440. var minx = this._vertices[0].x;
  3441. var miny = this._vertices[0].y;
  3442. var minz = this._vertices[0].z;
  3443. var maxx = this._vertices[0].x;
  3444. var maxy = this._vertices[0].y;
  3445. var maxz = this._vertices[0].z;
  3446. var _g = 1;
  3447. var _g1 = this._numVertices;
  3448. while(_g < _g1) {
  3449. var i = _g++;
  3450. var vx = this._vertices[i].x;
  3451. var vy = this._vertices[i].y;
  3452. var vz = this._vertices[i].z;
  3453. if(vx < minx) {
  3454. minx = vx;
  3455. } else if(vx > maxx) {
  3456. maxx = vx;
  3457. }
  3458. if(vy < miny) {
  3459. miny = vy;
  3460. } else if(vy > maxy) {
  3461. maxy = vy;
  3462. }
  3463. if(vz < minz) {
  3464. minz = vz;
  3465. } else if(vz > maxz) {
  3466. maxz = vz;
  3467. }
  3468. }
  3469. var sizex = maxx - minx;
  3470. var sizey = maxy - miny;
  3471. var sizez = maxz - minz;
  3472. this._volume = sizex * sizey * sizez;
  3473. var diffCog = ((minx + maxx) * (minx + maxx) + (miny + maxy) * (miny + maxy) + (minz + maxz) * (minz + maxz)) * 0.25;
  3474. sizex = sizex * sizex * 0.25;
  3475. sizey = sizey * sizey * 0.25;
  3476. sizez = sizez * sizez * 0.25;
  3477. this._inertiaCoeff00 = 0.333333333333333315 * (sizey + sizez) + diffCog;
  3478. this._inertiaCoeff01 = 0;
  3479. this._inertiaCoeff02 = 0;
  3480. this._inertiaCoeff10 = 0;
  3481. this._inertiaCoeff11 = 0.333333333333333315 * (sizez + sizex) + diffCog;
  3482. this._inertiaCoeff12 = 0;
  3483. this._inertiaCoeff20 = 0;
  3484. this._inertiaCoeff21 = 0;
  3485. this._inertiaCoeff22 = 0.333333333333333315 * (sizex + sizey) + diffCog;
  3486. }
  3487. _computeAabb(aabb,tf) {
  3488. var min;
  3489. var minX;
  3490. var minY;
  3491. var minZ;
  3492. var max;
  3493. var maxX;
  3494. var maxY;
  3495. var maxZ;
  3496. var margin;
  3497. var marginX;
  3498. var marginY;
  3499. var marginZ;
  3500. marginX = this._gjkMargin;
  3501. marginY = this._gjkMargin;
  3502. marginZ = this._gjkMargin;
  3503. var localV;
  3504. var localVX;
  3505. var localVY;
  3506. var localVZ;
  3507. var v = this._vertices[0];
  3508. localVX = v.x;
  3509. localVY = v.y;
  3510. localVZ = v.z;
  3511. var worldV;
  3512. var worldVX;
  3513. var worldVY;
  3514. var worldVZ;
  3515. var __tmp__X;
  3516. var __tmp__Y;
  3517. var __tmp__Z;
  3518. __tmp__X = tf._rotation00 * localVX + tf._rotation01 * localVY + tf._rotation02 * localVZ;
  3519. __tmp__Y = tf._rotation10 * localVX + tf._rotation11 * localVY + tf._rotation12 * localVZ;
  3520. __tmp__Z = tf._rotation20 * localVX + tf._rotation21 * localVY + tf._rotation22 * localVZ;
  3521. worldVX = __tmp__X;
  3522. worldVY = __tmp__Y;
  3523. worldVZ = __tmp__Z;
  3524. worldVX += tf._positionX;
  3525. worldVY += tf._positionY;
  3526. worldVZ += tf._positionZ;
  3527. minX = worldVX;
  3528. minY = worldVY;
  3529. minZ = worldVZ;
  3530. maxX = worldVX;
  3531. maxY = worldVY;
  3532. maxZ = worldVZ;
  3533. var _g = 1;
  3534. var _g1 = this._numVertices;
  3535. while(_g < _g1) {
  3536. var i = _g++;
  3537. var v1 = this._vertices[i];
  3538. localVX = v1.x;
  3539. localVY = v1.y;
  3540. localVZ = v1.z;
  3541. var __tmp__X1;
  3542. var __tmp__Y1;
  3543. var __tmp__Z1;
  3544. __tmp__X1 = tf._rotation00 * localVX + tf._rotation01 * localVY + tf._rotation02 * localVZ;
  3545. __tmp__Y1 = tf._rotation10 * localVX + tf._rotation11 * localVY + tf._rotation12 * localVZ;
  3546. __tmp__Z1 = tf._rotation20 * localVX + tf._rotation21 * localVY + tf._rotation22 * localVZ;
  3547. worldVX = __tmp__X1;
  3548. worldVY = __tmp__Y1;
  3549. worldVZ = __tmp__Z1;
  3550. worldVX += tf._positionX;
  3551. worldVY += tf._positionY;
  3552. worldVZ += tf._positionZ;
  3553. minX = minX < worldVX ? minX : worldVX;
  3554. minY = minY < worldVY ? minY : worldVY;
  3555. minZ = minZ < worldVZ ? minZ : worldVZ;
  3556. maxX = maxX > worldVX ? maxX : worldVX;
  3557. maxY = maxY > worldVY ? maxY : worldVY;
  3558. maxZ = maxZ > worldVZ ? maxZ : worldVZ;
  3559. }
  3560. aabb._minX = minX - marginX;
  3561. aabb._minY = minY - marginY;
  3562. aabb._minZ = minZ - marginZ;
  3563. aabb._maxX = maxX + marginX;
  3564. aabb._maxY = maxY + marginY;
  3565. aabb._maxZ = maxZ + marginZ;
  3566. }
  3567. computeLocalSupportingVertex(dir,out) {
  3568. var _this = this._vertices[0];
  3569. var maxDot = _this.x * dir.x + _this.y * dir.y + _this.z * dir.z;
  3570. var maxIndex = 0;
  3571. var _g = 1;
  3572. var _g1 = this._numVertices;
  3573. while(_g < _g1) {
  3574. var i = _g++;
  3575. var _this1 = this._vertices[i];
  3576. var dot = _this1.x * dir.x + _this1.y * dir.y + _this1.z * dir.z;
  3577. if(dot > maxDot) {
  3578. maxDot = dot;
  3579. maxIndex = i;
  3580. }
  3581. }
  3582. var v = this._vertices[maxIndex];
  3583. out.x = v.x;
  3584. out.y = v.y;
  3585. out.z = v.z;
  3586. }
  3587. }
  3588. oimo.collision.geometry.CylinderGeometry = class oimo_collision_geometry_CylinderGeometry extends oimo.collision.geometry.ConvexGeometry {
  3589. constructor(radius,halfHeight) {
  3590. super(2);
  3591. this._radius = radius;
  3592. this._halfHeight = halfHeight;
  3593. this._updateMass();
  3594. }
  3595. getRadius() {
  3596. return this._radius;
  3597. }
  3598. getHalfHeight() {
  3599. return this._halfHeight;
  3600. }
  3601. _updateMass() {
  3602. var r2 = this._radius * this._radius;
  3603. var h2 = this._halfHeight * this._halfHeight * 4;
  3604. this._volume = 3.14159265358979 * r2 * this._halfHeight * 2;
  3605. this._inertiaCoeff00 = 0.0833333333333333287 * (3 * r2 + h2);
  3606. this._inertiaCoeff01 = 0;
  3607. this._inertiaCoeff02 = 0;
  3608. this._inertiaCoeff10 = 0;
  3609. this._inertiaCoeff11 = 0.5 * r2;
  3610. this._inertiaCoeff12 = 0;
  3611. this._inertiaCoeff20 = 0;
  3612. this._inertiaCoeff21 = 0;
  3613. this._inertiaCoeff22 = 0.0833333333333333287 * (3 * r2 + h2);
  3614. }
  3615. _computeAabb(aabb,tf) {
  3616. var axis;
  3617. var axisX;
  3618. var axisY;
  3619. var axisZ;
  3620. var axis2;
  3621. var axis2X;
  3622. var axis2Y;
  3623. var axis2Z;
  3624. var eh;
  3625. var ehX;
  3626. var ehY;
  3627. var ehZ;
  3628. var er;
  3629. var erX;
  3630. var erY;
  3631. var erZ;
  3632. axisX = tf._rotation01;
  3633. axisY = tf._rotation11;
  3634. axisZ = tf._rotation21;
  3635. axisX = axisX < 0 ? -axisX : axisX;
  3636. axisY = axisY < 0 ? -axisY : axisY;
  3637. axisZ = axisZ < 0 ? -axisZ : axisZ;
  3638. axis2X = axisX * axisX;
  3639. axis2Y = axisY * axisY;
  3640. axis2Z = axisZ * axisZ;
  3641. var axis2x = axis2X;
  3642. var axis2y = axis2Y;
  3643. var axis2z = axis2Z;
  3644. erX = Math.sqrt(1 - axis2x);
  3645. erY = Math.sqrt(1 - axis2y);
  3646. erZ = Math.sqrt(1 - axis2z);
  3647. erX *= this._radius;
  3648. erY *= this._radius;
  3649. erZ *= this._radius;
  3650. ehX = axisX * this._halfHeight;
  3651. ehY = axisY * this._halfHeight;
  3652. ehZ = axisZ * this._halfHeight;
  3653. var max;
  3654. var maxX;
  3655. var maxY;
  3656. var maxZ;
  3657. maxX = erX + ehX;
  3658. maxY = erY + ehY;
  3659. maxZ = erZ + ehZ;
  3660. aabb._minX = tf._positionX - maxX;
  3661. aabb._minY = tf._positionY - maxY;
  3662. aabb._minZ = tf._positionZ - maxZ;
  3663. aabb._maxX = tf._positionX + maxX;
  3664. aabb._maxY = tf._positionY + maxY;
  3665. aabb._maxZ = tf._positionZ + maxZ;
  3666. }
  3667. computeLocalSupportingVertex(dir,out) {
  3668. var rx = dir.x;
  3669. var rz = dir.z;
  3670. var len = rx * rx + rz * rz;
  3671. var coreRadius = this._radius - this._gjkMargin;
  3672. if(coreRadius < 0) {
  3673. coreRadius = 0;
  3674. }
  3675. var invLen = len > 0 ? coreRadius / Math.sqrt(len) : 0;
  3676. var coreHeight = this._halfHeight - this._gjkMargin;
  3677. if(coreHeight < 0) {
  3678. coreHeight = 0;
  3679. }
  3680. out.x = rx * invLen;
  3681. out.y = dir.y > 0 ? coreHeight : -coreHeight;
  3682. out.z = rz * invLen;
  3683. }
  3684. _rayCastLocal(beginX,beginY,beginZ,endX,endY,endZ,hit) {
  3685. var p1x = beginX;
  3686. var p1y = beginY;
  3687. var p1z = beginZ;
  3688. var p2x = endX;
  3689. var p2y = endY;
  3690. var p2z = endZ;
  3691. var halfH = this._halfHeight;
  3692. var dx = p2x - p1x;
  3693. var dy = p2y - p1y;
  3694. var dz = p2z - p1z;
  3695. var tminy = 0;
  3696. var tmaxy = 1;
  3697. if(dy > -1e-6 && dy < 1e-6) {
  3698. if(p1y <= -halfH || p1y >= halfH) {
  3699. return false;
  3700. }
  3701. } else {
  3702. var invDy = 1 / dy;
  3703. var t1 = (-halfH - p1y) * invDy;
  3704. var t2 = (halfH - p1y) * invDy;
  3705. if(t1 > t2) {
  3706. var tmp = t1;
  3707. t1 = t2;
  3708. t2 = tmp;
  3709. }
  3710. if(t1 > 0) {
  3711. tminy = t1;
  3712. }
  3713. if(t2 < 1) {
  3714. tmaxy = t2;
  3715. }
  3716. }
  3717. if(tminy >= 1 || tmaxy <= 0) {
  3718. return false;
  3719. }
  3720. var tminxz = 0;
  3721. var tmaxxz = 1;
  3722. var a = dx * dx + dz * dz;
  3723. var b = p1x * dx + p1z * dz;
  3724. var c = p1x * p1x + p1z * p1z - this._radius * this._radius;
  3725. var D = b * b - a * c;
  3726. if(D < 0) {
  3727. return false;
  3728. }
  3729. var t;
  3730. if(a > 0) {
  3731. var sqrtD = Math.sqrt(D);
  3732. tminxz = (-b - sqrtD) / a;
  3733. tmaxxz = (-b + sqrtD) / a;
  3734. if(tminxz >= 1 || tmaxxz <= 0) {
  3735. return false;
  3736. }
  3737. } else {
  3738. if(c >= 0) {
  3739. return false;
  3740. }
  3741. tminxz = 0;
  3742. tmaxxz = 1;
  3743. }
  3744. var min;
  3745. if(tmaxxz <= tminy || tmaxy <= tminxz) {
  3746. return false;
  3747. }
  3748. if(tminxz < tminy) {
  3749. min = tminy;
  3750. if(min == 0) {
  3751. return false;
  3752. }
  3753. hit.normal.init(0,dy > 0 ? -1 : 1,0);
  3754. } else {
  3755. min = tminxz;
  3756. if(min == 0) {
  3757. return false;
  3758. }
  3759. var _this = hit.normal.init(p1x + dx * min,0,p1z + dz * min);
  3760. var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
  3761. if(invLen > 0) {
  3762. invLen = 1 / invLen;
  3763. }
  3764. var tx = _this.x * invLen;
  3765. var ty = _this.y * invLen;
  3766. var tz = _this.z * invLen;
  3767. _this.x = tx;
  3768. _this.y = ty;
  3769. _this.z = tz;
  3770. }
  3771. hit.position.init(p1x + min * dx,p1y + min * dy,p1z + min * dz);
  3772. hit.fraction = min;
  3773. return true;
  3774. }
  3775. }
  3776. oimo.collision.geometry.GeometryType = class oimo_collision_geometry_GeometryType {
  3777. }
  3778. oimo.collision.geometry.RayCastHit = class oimo_collision_geometry_RayCastHit {
  3779. constructor() {
  3780. this.position = new oimo.common.Vec3();
  3781. this.normal = new oimo.common.Vec3();
  3782. this.fraction = 0;
  3783. }
  3784. }
  3785. oimo.collision.geometry.SphereGeometry = class oimo_collision_geometry_SphereGeometry extends oimo.collision.geometry.ConvexGeometry {
  3786. constructor(radius) {
  3787. super(0);
  3788. this._radius = radius;
  3789. this._gjkMargin = this._radius;
  3790. this._updateMass();
  3791. }
  3792. getRadius() {
  3793. return this._radius;
  3794. }
  3795. _updateMass() {
  3796. this._volume = 4.18879020478638608 * this._radius * this._radius * this._radius;
  3797. this._inertiaCoeff00 = 0.4 * this._radius * this._radius;
  3798. this._inertiaCoeff01 = 0;
  3799. this._inertiaCoeff02 = 0;
  3800. this._inertiaCoeff10 = 0;
  3801. this._inertiaCoeff11 = 0.4 * this._radius * this._radius;
  3802. this._inertiaCoeff12 = 0;
  3803. this._inertiaCoeff20 = 0;
  3804. this._inertiaCoeff21 = 0;
  3805. this._inertiaCoeff22 = 0.4 * this._radius * this._radius;
  3806. }
  3807. _computeAabb(aabb,tf) {
  3808. var radVec;
  3809. var radVecX;
  3810. var radVecY;
  3811. var radVecZ;
  3812. radVecX = this._radius;
  3813. radVecY = this._radius;
  3814. radVecZ = this._radius;
  3815. aabb._minX = tf._positionX - radVecX;
  3816. aabb._minY = tf._positionY - radVecY;
  3817. aabb._minZ = tf._positionZ - radVecZ;
  3818. aabb._maxX = tf._positionX + radVecX;
  3819. aabb._maxY = tf._positionY + radVecY;
  3820. aabb._maxZ = tf._positionZ + radVecZ;
  3821. }
  3822. computeLocalSupportingVertex(dir,out) {
  3823. out.zero();
  3824. }
  3825. _rayCastLocal(beginX,beginY,beginZ,endX,endY,endZ,hit) {
  3826. var d;
  3827. var dX;
  3828. var dY;
  3829. var dZ;
  3830. dX = endX - beginX;
  3831. dY = endY - beginY;
  3832. dZ = endZ - beginZ;
  3833. var a = dX * dX + dY * dY + dZ * dZ;
  3834. var b = beginX * dX + beginY * dY + beginZ * dZ;
  3835. var c = beginX * beginX + beginY * beginY + beginZ * beginZ - this._radius * this._radius;
  3836. var D = b * b - a * c;
  3837. if(D < 0) {
  3838. return false;
  3839. }
  3840. var t = (-b - Math.sqrt(D)) / a;
  3841. if(t < 0 || t > 1) {
  3842. return false;
  3843. }
  3844. var hitPos;
  3845. var hitPosX;
  3846. var hitPosY;
  3847. var hitPosZ;
  3848. var hitNormal;
  3849. var hitNormalX;
  3850. var hitNormalY;
  3851. var hitNormalZ;
  3852. hitPosX = beginX + dX * t;
  3853. hitPosY = beginY + dY * t;
  3854. hitPosZ = beginZ + dZ * t;
  3855. var l = hitPosX * hitPosX + hitPosY * hitPosY + hitPosZ * hitPosZ;
  3856. if(l > 0) {
  3857. l = 1 / Math.sqrt(l);
  3858. }
  3859. hitNormalX = hitPosX * l;
  3860. hitNormalY = hitPosY * l;
  3861. hitNormalZ = hitPosZ * l;
  3862. var v = hit.position;
  3863. v.x = hitPosX;
  3864. v.y = hitPosY;
  3865. v.z = hitPosZ;
  3866. var v1 = hit.normal;
  3867. v1.x = hitNormalX;
  3868. v1.y = hitNormalY;
  3869. v1.z = hitNormalZ;
  3870. hit.fraction = t;
  3871. return true;
  3872. }
  3873. }
  3874. if(!oimo.collision.narrowphase) oimo.collision.narrowphase = {};
  3875. oimo.collision.narrowphase.CollisionMatrix = class oimo_collision_narrowphase_CollisionMatrix {
  3876. constructor() {
  3877. var this1 = new Array(8);
  3878. this.detectors = this1;
  3879. var this2 = this.detectors;
  3880. var this3 = new Array(8);
  3881. this2[0] = this3;
  3882. var this4 = this.detectors;
  3883. var this5 = new Array(8);
  3884. this4[1] = this5;
  3885. var this6 = this.detectors;
  3886. var this7 = new Array(8);
  3887. this6[2] = this7;
  3888. var this8 = this.detectors;
  3889. var this9 = new Array(8);
  3890. this8[3] = this9;
  3891. var this10 = this.detectors;
  3892. var this11 = new Array(8);
  3893. this10[4] = this11;
  3894. var this12 = this.detectors;
  3895. var this13 = new Array(8);
  3896. this12[5] = this13;
  3897. var gjkEpaDetector = new oimo.collision.narrowphase.detector.GjkEpaDetector();
  3898. var sp = 0;
  3899. var bo = 1;
  3900. var cy = 2;
  3901. var co = 3;
  3902. var ca = 4;
  3903. var ch = 5;
  3904. this.detectors[sp][sp] = new oimo.collision.narrowphase.detector.SphereSphereDetector();
  3905. this.detectors[sp][bo] = new oimo.collision.narrowphase.detector.SphereBoxDetector(false);
  3906. this.detectors[sp][cy] = gjkEpaDetector;
  3907. this.detectors[sp][co] = gjkEpaDetector;
  3908. this.detectors[sp][ca] = new oimo.collision.narrowphase.detector.SphereCapsuleDetector(false);
  3909. this.detectors[sp][ch] = gjkEpaDetector;
  3910. this.detectors[bo][sp] = new oimo.collision.narrowphase.detector.SphereBoxDetector(true);
  3911. this.detectors[bo][bo] = new oimo.collision.narrowphase.detector.BoxBoxDetector();
  3912. this.detectors[bo][cy] = gjkEpaDetector;
  3913. this.detectors[bo][co] = gjkEpaDetector;
  3914. this.detectors[bo][ca] = gjkEpaDetector;
  3915. this.detectors[bo][ch] = gjkEpaDetector;
  3916. this.detectors[cy][sp] = gjkEpaDetector;
  3917. this.detectors[cy][bo] = gjkEpaDetector;
  3918. this.detectors[cy][cy] = gjkEpaDetector;
  3919. this.detectors[cy][co] = gjkEpaDetector;
  3920. this.detectors[cy][ca] = gjkEpaDetector;
  3921. this.detectors[cy][ch] = gjkEpaDetector;
  3922. this.detectors[co][sp] = gjkEpaDetector;
  3923. this.detectors[co][bo] = gjkEpaDetector;
  3924. this.detectors[co][cy] = gjkEpaDetector;
  3925. this.detectors[co][co] = gjkEpaDetector;
  3926. this.detectors[co][ca] = gjkEpaDetector;
  3927. this.detectors[co][ch] = gjkEpaDetector;
  3928. this.detectors[ca][sp] = new oimo.collision.narrowphase.detector.SphereCapsuleDetector(true);
  3929. this.detectors[ca][bo] = gjkEpaDetector;
  3930. this.detectors[ca][cy] = gjkEpaDetector;
  3931. this.detectors[ca][co] = gjkEpaDetector;
  3932. this.detectors[ca][ca] = new oimo.collision.narrowphase.detector.CapsuleCapsuleDetector();
  3933. this.detectors[ca][ch] = gjkEpaDetector;
  3934. this.detectors[ch][sp] = gjkEpaDetector;
  3935. this.detectors[ch][bo] = gjkEpaDetector;
  3936. this.detectors[ch][cy] = gjkEpaDetector;
  3937. this.detectors[ch][co] = gjkEpaDetector;
  3938. this.detectors[ch][ca] = gjkEpaDetector;
  3939. this.detectors[ch][ch] = gjkEpaDetector;
  3940. }
  3941. getDetector(geomType1,geomType2) {
  3942. return this.detectors[geomType1][geomType2];
  3943. }
  3944. }
  3945. oimo.collision.narrowphase.DetectorResult = class oimo_collision_narrowphase_DetectorResult {
  3946. constructor() {
  3947. this.numPoints = 0;
  3948. this.normal = new oimo.common.Vec3();
  3949. var this1 = new Array(oimo.common.Setting.maxManifoldPoints);
  3950. this.points = this1;
  3951. this.incremental = false;
  3952. var _g = 0;
  3953. var _g1 = oimo.common.Setting.maxManifoldPoints;
  3954. while(_g < _g1) {
  3955. var i = _g++;
  3956. this.points[i] = new oimo.collision.narrowphase.DetectorResultPoint();
  3957. }
  3958. }
  3959. getMaxDepth() {
  3960. var max = 0;
  3961. var _g = 0;
  3962. var _g1 = this.numPoints;
  3963. while(_g < _g1) {
  3964. var i = _g++;
  3965. if(this.points[i].depth > max) {
  3966. max = this.points[i].depth;
  3967. }
  3968. }
  3969. return max;
  3970. }
  3971. clear() {
  3972. this.numPoints = 0;
  3973. var _g = 0;
  3974. var _g1 = this.points;
  3975. while(_g < _g1.length) {
  3976. var p = _g1[_g];
  3977. ++_g;
  3978. p.position1.zero();
  3979. p.position2.zero();
  3980. p.depth = 0;
  3981. p.id = 0;
  3982. }
  3983. this.normal.zero();
  3984. }
  3985. }
  3986. oimo.collision.narrowphase.DetectorResultPoint = class oimo_collision_narrowphase_DetectorResultPoint {
  3987. constructor() {
  3988. this.position1 = new oimo.common.Vec3();
  3989. this.position2 = new oimo.common.Vec3();
  3990. this.depth = 0;
  3991. this.id = 0;
  3992. }
  3993. }
  3994. if(!oimo.collision.narrowphase.detector) oimo.collision.narrowphase.detector = {};
  3995. oimo.collision.narrowphase.detector.Detector = class oimo_collision_narrowphase_detector_Detector {
  3996. constructor(swapped) {
  3997. this.swapped = swapped;
  3998. }
  3999. setNormal(result,nX,nY,nZ) {
  4000. var v = result.normal;
  4001. v.x = nX;
  4002. v.y = nY;
  4003. v.z = nZ;
  4004. if(this.swapped) {
  4005. var _this = result.normal;
  4006. var tx = -_this.x;
  4007. var ty = -_this.y;
  4008. var tz = -_this.z;
  4009. _this.x = tx;
  4010. _this.y = ty;
  4011. _this.z = tz;
  4012. }
  4013. }
  4014. addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,depth,id) {
  4015. var p = result.points[result.numPoints++];
  4016. p.depth = depth;
  4017. p.id = id;
  4018. if(this.swapped) {
  4019. var v = p.position1;
  4020. v.x = pos2X;
  4021. v.y = pos2Y;
  4022. v.z = pos2Z;
  4023. var v1 = p.position2;
  4024. v1.x = pos1X;
  4025. v1.y = pos1Y;
  4026. v1.z = pos1Z;
  4027. } else {
  4028. var v2 = p.position1;
  4029. v2.x = pos1X;
  4030. v2.y = pos1Y;
  4031. v2.z = pos1Z;
  4032. var v3 = p.position2;
  4033. v3.x = pos2X;
  4034. v3.y = pos2Y;
  4035. v3.z = pos2Z;
  4036. }
  4037. }
  4038. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  4039. }
  4040. detect(result,geom1,geom2,transform1,transform2,cachedData) {
  4041. result.numPoints = 0;
  4042. var _g = 0;
  4043. var _g1 = result.points;
  4044. while(_g < _g1.length) {
  4045. var p = _g1[_g];
  4046. ++_g;
  4047. p.position1.zero();
  4048. p.position2.zero();
  4049. p.depth = 0;
  4050. p.id = 0;
  4051. }
  4052. result.normal.zero();
  4053. if(this.swapped) {
  4054. this.detectImpl(result,geom2,geom1,transform2,transform1,cachedData);
  4055. } else {
  4056. this.detectImpl(result,geom1,geom2,transform1,transform2,cachedData);
  4057. }
  4058. }
  4059. }
  4060. oimo.collision.narrowphase.detector.BoxBoxDetector = class oimo_collision_narrowphase_detector_BoxBoxDetector extends oimo.collision.narrowphase.detector.Detector {
  4061. constructor() {
  4062. super(false);
  4063. this.clipper = new oimo.collision.narrowphase.detector._BoxBoxDetector.FaceClipper();
  4064. }
  4065. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  4066. var b1 = geom1;
  4067. var b2 = geom2;
  4068. result.incremental = false;
  4069. var c1;
  4070. var c1X;
  4071. var c1Y;
  4072. var c1Z;
  4073. var c2;
  4074. var c2X;
  4075. var c2Y;
  4076. var c2Z;
  4077. var c12;
  4078. var c12X;
  4079. var c12Y;
  4080. var c12Z;
  4081. c1X = tf1._positionX;
  4082. c1Y = tf1._positionY;
  4083. c1Z = tf1._positionZ;
  4084. c2X = tf2._positionX;
  4085. c2Y = tf2._positionY;
  4086. c2Z = tf2._positionZ;
  4087. c12X = c2X - c1X;
  4088. c12Y = c2Y - c1Y;
  4089. c12Z = c2Z - c1Z;
  4090. var x1;
  4091. var x1X;
  4092. var x1Y;
  4093. var x1Z;
  4094. var y1;
  4095. var y1X;
  4096. var y1Y;
  4097. var y1Z;
  4098. var z1;
  4099. var z1X;
  4100. var z1Y;
  4101. var z1Z;
  4102. var x2;
  4103. var x2X;
  4104. var x2Y;
  4105. var x2Z;
  4106. var y2;
  4107. var y2X;
  4108. var y2Y;
  4109. var y2Z;
  4110. var z2;
  4111. var z2X;
  4112. var z2Y;
  4113. var z2Z;
  4114. x1X = tf1._rotation00;
  4115. x1Y = tf1._rotation10;
  4116. x1Z = tf1._rotation20;
  4117. y1X = tf1._rotation01;
  4118. y1Y = tf1._rotation11;
  4119. y1Z = tf1._rotation21;
  4120. z1X = tf1._rotation02;
  4121. z1Y = tf1._rotation12;
  4122. z1Z = tf1._rotation22;
  4123. x2X = tf2._rotation00;
  4124. x2Y = tf2._rotation10;
  4125. x2Z = tf2._rotation20;
  4126. y2X = tf2._rotation01;
  4127. y2Y = tf2._rotation11;
  4128. y2Z = tf2._rotation21;
  4129. z2X = tf2._rotation02;
  4130. z2Y = tf2._rotation12;
  4131. z2Z = tf2._rotation22;
  4132. var w1 = b1._halfExtentsX;
  4133. var h1 = b1._halfExtentsY;
  4134. var d1 = b1._halfExtentsZ;
  4135. var w2 = b2._halfExtentsX;
  4136. var h2 = b2._halfExtentsY;
  4137. var d2 = b2._halfExtentsZ;
  4138. var sx1;
  4139. var sx1X;
  4140. var sx1Y;
  4141. var sx1Z;
  4142. var sy1;
  4143. var sy1X;
  4144. var sy1Y;
  4145. var sy1Z;
  4146. var sz1;
  4147. var sz1X;
  4148. var sz1Y;
  4149. var sz1Z;
  4150. var sx2;
  4151. var sx2X;
  4152. var sx2Y;
  4153. var sx2Z;
  4154. var sy2;
  4155. var sy2X;
  4156. var sy2Y;
  4157. var sy2Z;
  4158. var sz2;
  4159. var sz2X;
  4160. var sz2Y;
  4161. var sz2Z;
  4162. sx1X = x1X * w1;
  4163. sx1Y = x1Y * w1;
  4164. sx1Z = x1Z * w1;
  4165. sy1X = y1X * h1;
  4166. sy1Y = y1Y * h1;
  4167. sy1Z = y1Z * h1;
  4168. sz1X = z1X * d1;
  4169. sz1Y = z1Y * d1;
  4170. sz1Z = z1Z * d1;
  4171. sx2X = x2X * w2;
  4172. sx2Y = x2Y * w2;
  4173. sx2Z = x2Z * w2;
  4174. sy2X = y2X * h2;
  4175. sy2Y = y2Y * h2;
  4176. sy2Z = y2Z * h2;
  4177. sz2X = z2X * d2;
  4178. sz2Y = z2Y * d2;
  4179. sz2Z = z2Z * d2;
  4180. var projSum;
  4181. var projC12Abs;
  4182. var mDepth = 1e65536;
  4183. var mId = -1;
  4184. var mSign = 0;
  4185. var mAxis;
  4186. var mAxisX;
  4187. var mAxisY;
  4188. var mAxisZ;
  4189. mAxisX = 0;
  4190. mAxisY = 0;
  4191. mAxisZ = 0;
  4192. var proj1 = w1;
  4193. var dx = x1X * sx2X + x1Y * sx2Y + x1Z * sx2Z;
  4194. var dy = x1X * sy2X + x1Y * sy2Y + x1Z * sy2Z;
  4195. var dz = x1X * sz2X + x1Y * sz2Y + x1Z * sz2Z;
  4196. if(dx < 0) {
  4197. dx = -dx;
  4198. }
  4199. if(dy < 0) {
  4200. dy = -dy;
  4201. }
  4202. if(dz < 0) {
  4203. dz = -dz;
  4204. }
  4205. var proj2 = dx + dy + dz;
  4206. var projC12 = x1X * c12X + x1Y * c12Y + x1Z * c12Z;
  4207. var sum = proj1 + proj2;
  4208. var neg = projC12 < 0;
  4209. var abs = neg ? -projC12 : projC12;
  4210. if(abs < sum) {
  4211. var depth = sum - abs;
  4212. if(depth < mDepth) {
  4213. mDepth = depth;
  4214. mId = 0;
  4215. mAxisX = x1X;
  4216. mAxisY = x1Y;
  4217. mAxisZ = x1Z;
  4218. mSign = neg ? -1 : 1;
  4219. }
  4220. } else {
  4221. return;
  4222. }
  4223. proj1 = h1;
  4224. var dx1 = y1X * sx2X + y1Y * sx2Y + y1Z * sx2Z;
  4225. var dy1 = y1X * sy2X + y1Y * sy2Y + y1Z * sy2Z;
  4226. var dz1 = y1X * sz2X + y1Y * sz2Y + y1Z * sz2Z;
  4227. if(dx1 < 0) {
  4228. dx1 = -dx1;
  4229. }
  4230. if(dy1 < 0) {
  4231. dy1 = -dy1;
  4232. }
  4233. if(dz1 < 0) {
  4234. dz1 = -dz1;
  4235. }
  4236. proj2 = dx1 + dy1 + dz1;
  4237. projC12 = y1X * c12X + y1Y * c12Y + y1Z * c12Z;
  4238. var sum1 = proj1 + proj2;
  4239. var neg1 = projC12 < 0;
  4240. var abs1 = neg1 ? -projC12 : projC12;
  4241. if(abs1 < sum1) {
  4242. var depth1 = sum1 - abs1;
  4243. if(depth1 < mDepth) {
  4244. mDepth = depth1;
  4245. mId = 1;
  4246. mAxisX = y1X;
  4247. mAxisY = y1Y;
  4248. mAxisZ = y1Z;
  4249. mSign = neg1 ? -1 : 1;
  4250. }
  4251. } else {
  4252. return;
  4253. }
  4254. proj1 = d1;
  4255. var dx2 = z1X * sx2X + z1Y * sx2Y + z1Z * sx2Z;
  4256. var dy2 = z1X * sy2X + z1Y * sy2Y + z1Z * sy2Z;
  4257. var dz2 = z1X * sz2X + z1Y * sz2Y + z1Z * sz2Z;
  4258. if(dx2 < 0) {
  4259. dx2 = -dx2;
  4260. }
  4261. if(dy2 < 0) {
  4262. dy2 = -dy2;
  4263. }
  4264. if(dz2 < 0) {
  4265. dz2 = -dz2;
  4266. }
  4267. proj2 = dx2 + dy2 + dz2;
  4268. projC12 = z1X * c12X + z1Y * c12Y + z1Z * c12Z;
  4269. var sum2 = proj1 + proj2;
  4270. var neg2 = projC12 < 0;
  4271. var abs2 = neg2 ? -projC12 : projC12;
  4272. if(abs2 < sum2) {
  4273. var depth2 = sum2 - abs2;
  4274. if(depth2 < mDepth) {
  4275. mDepth = depth2;
  4276. mId = 2;
  4277. mAxisX = z1X;
  4278. mAxisY = z1Y;
  4279. mAxisZ = z1Z;
  4280. mSign = neg2 ? -1 : 1;
  4281. }
  4282. } else {
  4283. return;
  4284. }
  4285. if(mDepth > oimo.common.Setting.linearSlop) {
  4286. mDepth -= oimo.common.Setting.linearSlop;
  4287. } else {
  4288. mDepth = 0;
  4289. }
  4290. var dx3 = x2X * sx1X + x2Y * sx1Y + x2Z * sx1Z;
  4291. var dy3 = x2X * sy1X + x2Y * sy1Y + x2Z * sy1Z;
  4292. var dz3 = x2X * sz1X + x2Y * sz1Y + x2Z * sz1Z;
  4293. if(dx3 < 0) {
  4294. dx3 = -dx3;
  4295. }
  4296. if(dy3 < 0) {
  4297. dy3 = -dy3;
  4298. }
  4299. if(dz3 < 0) {
  4300. dz3 = -dz3;
  4301. }
  4302. proj1 = dx3 + dy3 + dz3;
  4303. proj2 = w2;
  4304. projC12 = x2X * c12X + x2Y * c12Y + x2Z * c12Z;
  4305. var sum3 = proj1 + proj2;
  4306. var neg3 = projC12 < 0;
  4307. var abs3 = neg3 ? -projC12 : projC12;
  4308. if(abs3 < sum3) {
  4309. var depth3 = sum3 - abs3;
  4310. if(depth3 < mDepth) {
  4311. mDepth = depth3;
  4312. mId = 3;
  4313. mAxisX = x2X;
  4314. mAxisY = x2Y;
  4315. mAxisZ = x2Z;
  4316. mSign = neg3 ? -1 : 1;
  4317. }
  4318. } else {
  4319. return;
  4320. }
  4321. var dx4 = y2X * sx1X + y2Y * sx1Y + y2Z * sx1Z;
  4322. var dy4 = y2X * sy1X + y2Y * sy1Y + y2Z * sy1Z;
  4323. var dz4 = y2X * sz1X + y2Y * sz1Y + y2Z * sz1Z;
  4324. if(dx4 < 0) {
  4325. dx4 = -dx4;
  4326. }
  4327. if(dy4 < 0) {
  4328. dy4 = -dy4;
  4329. }
  4330. if(dz4 < 0) {
  4331. dz4 = -dz4;
  4332. }
  4333. proj1 = dx4 + dy4 + dz4;
  4334. proj2 = h2;
  4335. projC12 = y2X * c12X + y2Y * c12Y + y2Z * c12Z;
  4336. var sum4 = proj1 + proj2;
  4337. var neg4 = projC12 < 0;
  4338. var abs4 = neg4 ? -projC12 : projC12;
  4339. if(abs4 < sum4) {
  4340. var depth4 = sum4 - abs4;
  4341. if(depth4 < mDepth) {
  4342. mDepth = depth4;
  4343. mId = 4;
  4344. mAxisX = y2X;
  4345. mAxisY = y2Y;
  4346. mAxisZ = y2Z;
  4347. mSign = neg4 ? -1 : 1;
  4348. }
  4349. } else {
  4350. return;
  4351. }
  4352. var dx5 = z2X * sx1X + z2Y * sx1Y + z2Z * sx1Z;
  4353. var dy5 = z2X * sy1X + z2Y * sy1Y + z2Z * sy1Z;
  4354. var dz5 = z2X * sz1X + z2Y * sz1Y + z2Z * sz1Z;
  4355. if(dx5 < 0) {
  4356. dx5 = -dx5;
  4357. }
  4358. if(dy5 < 0) {
  4359. dy5 = -dy5;
  4360. }
  4361. if(dz5 < 0) {
  4362. dz5 = -dz5;
  4363. }
  4364. proj1 = dx5 + dy5 + dz5;
  4365. proj2 = d2;
  4366. projC12 = z2X * c12X + z2Y * c12Y + z2Z * c12Z;
  4367. var sum5 = proj1 + proj2;
  4368. var neg5 = projC12 < 0;
  4369. var abs5 = neg5 ? -projC12 : projC12;
  4370. if(abs5 < sum5) {
  4371. var depth5 = sum5 - abs5;
  4372. if(depth5 < mDepth) {
  4373. mDepth = depth5;
  4374. mId = 5;
  4375. mAxisX = z2X;
  4376. mAxisY = z2Y;
  4377. mAxisZ = z2Z;
  4378. mSign = neg5 ? -1 : 1;
  4379. }
  4380. } else {
  4381. return;
  4382. }
  4383. if(mDepth > oimo.common.Setting.linearSlop) {
  4384. mDepth -= oimo.common.Setting.linearSlop;
  4385. } else {
  4386. mDepth = 0;
  4387. }
  4388. var edgeAxis;
  4389. var edgeAxisX;
  4390. var edgeAxisY;
  4391. var edgeAxisZ;
  4392. edgeAxisX = x1Y * x2Z - x1Z * x2Y;
  4393. edgeAxisY = x1Z * x2X - x1X * x2Z;
  4394. edgeAxisZ = x1X * x2Y - x1Y * x2X;
  4395. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4396. var l = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4397. if(l > 0) {
  4398. l = 1 / Math.sqrt(l);
  4399. }
  4400. edgeAxisX *= l;
  4401. edgeAxisY *= l;
  4402. edgeAxisZ *= l;
  4403. var dx6 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z;
  4404. var dy6 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z;
  4405. if(dx6 < 0) {
  4406. dx6 = -dx6;
  4407. }
  4408. if(dy6 < 0) {
  4409. dy6 = -dy6;
  4410. }
  4411. proj1 = dx6 + dy6;
  4412. var dx7 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z;
  4413. var dy7 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z;
  4414. if(dx7 < 0) {
  4415. dx7 = -dx7;
  4416. }
  4417. if(dy7 < 0) {
  4418. dy7 = -dy7;
  4419. }
  4420. proj2 = dx7 + dy7;
  4421. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4422. var sum6 = proj1 + proj2;
  4423. var neg6 = projC12 < 0;
  4424. var abs6 = neg6 ? -projC12 : projC12;
  4425. if(abs6 < sum6) {
  4426. var depth6 = sum6 - abs6;
  4427. if(depth6 < mDepth) {
  4428. mDepth = depth6;
  4429. mId = 6;
  4430. mAxisX = edgeAxisX;
  4431. mAxisY = edgeAxisY;
  4432. mAxisZ = edgeAxisZ;
  4433. mSign = neg6 ? -1 : 1;
  4434. }
  4435. } else {
  4436. return;
  4437. }
  4438. }
  4439. edgeAxisX = x1Y * y2Z - x1Z * y2Y;
  4440. edgeAxisY = x1Z * y2X - x1X * y2Z;
  4441. edgeAxisZ = x1X * y2Y - x1Y * y2X;
  4442. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4443. var l1 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4444. if(l1 > 0) {
  4445. l1 = 1 / Math.sqrt(l1);
  4446. }
  4447. edgeAxisX *= l1;
  4448. edgeAxisY *= l1;
  4449. edgeAxisZ *= l1;
  4450. var dx8 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z;
  4451. var dy8 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z;
  4452. if(dx8 < 0) {
  4453. dx8 = -dx8;
  4454. }
  4455. if(dy8 < 0) {
  4456. dy8 = -dy8;
  4457. }
  4458. proj1 = dx8 + dy8;
  4459. var dx9 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z;
  4460. var dy9 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z;
  4461. if(dx9 < 0) {
  4462. dx9 = -dx9;
  4463. }
  4464. if(dy9 < 0) {
  4465. dy9 = -dy9;
  4466. }
  4467. proj2 = dx9 + dy9;
  4468. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4469. var sum7 = proj1 + proj2;
  4470. var neg7 = projC12 < 0;
  4471. var abs7 = neg7 ? -projC12 : projC12;
  4472. if(abs7 < sum7) {
  4473. var depth7 = sum7 - abs7;
  4474. if(depth7 < mDepth) {
  4475. mDepth = depth7;
  4476. mId = 7;
  4477. mAxisX = edgeAxisX;
  4478. mAxisY = edgeAxisY;
  4479. mAxisZ = edgeAxisZ;
  4480. mSign = neg7 ? -1 : 1;
  4481. }
  4482. } else {
  4483. return;
  4484. }
  4485. }
  4486. edgeAxisX = x1Y * z2Z - x1Z * z2Y;
  4487. edgeAxisY = x1Z * z2X - x1X * z2Z;
  4488. edgeAxisZ = x1X * z2Y - x1Y * z2X;
  4489. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4490. var l2 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4491. if(l2 > 0) {
  4492. l2 = 1 / Math.sqrt(l2);
  4493. }
  4494. edgeAxisX *= l2;
  4495. edgeAxisY *= l2;
  4496. edgeAxisZ *= l2;
  4497. var dx10 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z;
  4498. var dy10 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z;
  4499. if(dx10 < 0) {
  4500. dx10 = -dx10;
  4501. }
  4502. if(dy10 < 0) {
  4503. dy10 = -dy10;
  4504. }
  4505. proj1 = dx10 + dy10;
  4506. var dx11 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z;
  4507. var dy11 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z;
  4508. if(dx11 < 0) {
  4509. dx11 = -dx11;
  4510. }
  4511. if(dy11 < 0) {
  4512. dy11 = -dy11;
  4513. }
  4514. proj2 = dx11 + dy11;
  4515. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4516. var sum8 = proj1 + proj2;
  4517. var neg8 = projC12 < 0;
  4518. var abs8 = neg8 ? -projC12 : projC12;
  4519. if(abs8 < sum8) {
  4520. var depth8 = sum8 - abs8;
  4521. if(depth8 < mDepth) {
  4522. mDepth = depth8;
  4523. mId = 8;
  4524. mAxisX = edgeAxisX;
  4525. mAxisY = edgeAxisY;
  4526. mAxisZ = edgeAxisZ;
  4527. mSign = neg8 ? -1 : 1;
  4528. }
  4529. } else {
  4530. return;
  4531. }
  4532. }
  4533. edgeAxisX = y1Y * x2Z - y1Z * x2Y;
  4534. edgeAxisY = y1Z * x2X - y1X * x2Z;
  4535. edgeAxisZ = y1X * x2Y - y1Y * x2X;
  4536. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4537. var l3 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4538. if(l3 > 0) {
  4539. l3 = 1 / Math.sqrt(l3);
  4540. }
  4541. edgeAxisX *= l3;
  4542. edgeAxisY *= l3;
  4543. edgeAxisZ *= l3;
  4544. var dx12 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z;
  4545. var dy12 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z;
  4546. if(dx12 < 0) {
  4547. dx12 = -dx12;
  4548. }
  4549. if(dy12 < 0) {
  4550. dy12 = -dy12;
  4551. }
  4552. proj1 = dx12 + dy12;
  4553. var dx13 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z;
  4554. var dy13 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z;
  4555. if(dx13 < 0) {
  4556. dx13 = -dx13;
  4557. }
  4558. if(dy13 < 0) {
  4559. dy13 = -dy13;
  4560. }
  4561. proj2 = dx13 + dy13;
  4562. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4563. var sum9 = proj1 + proj2;
  4564. var neg9 = projC12 < 0;
  4565. var abs9 = neg9 ? -projC12 : projC12;
  4566. if(abs9 < sum9) {
  4567. var depth9 = sum9 - abs9;
  4568. if(depth9 < mDepth) {
  4569. mDepth = depth9;
  4570. mId = 9;
  4571. mAxisX = edgeAxisX;
  4572. mAxisY = edgeAxisY;
  4573. mAxisZ = edgeAxisZ;
  4574. mSign = neg9 ? -1 : 1;
  4575. }
  4576. } else {
  4577. return;
  4578. }
  4579. }
  4580. edgeAxisX = y1Y * y2Z - y1Z * y2Y;
  4581. edgeAxisY = y1Z * y2X - y1X * y2Z;
  4582. edgeAxisZ = y1X * y2Y - y1Y * y2X;
  4583. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4584. var l4 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4585. if(l4 > 0) {
  4586. l4 = 1 / Math.sqrt(l4);
  4587. }
  4588. edgeAxisX *= l4;
  4589. edgeAxisY *= l4;
  4590. edgeAxisZ *= l4;
  4591. var dx14 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z;
  4592. var dy14 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z;
  4593. if(dx14 < 0) {
  4594. dx14 = -dx14;
  4595. }
  4596. if(dy14 < 0) {
  4597. dy14 = -dy14;
  4598. }
  4599. proj1 = dx14 + dy14;
  4600. var dx15 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z;
  4601. var dy15 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z;
  4602. if(dx15 < 0) {
  4603. dx15 = -dx15;
  4604. }
  4605. if(dy15 < 0) {
  4606. dy15 = -dy15;
  4607. }
  4608. proj2 = dx15 + dy15;
  4609. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4610. var sum10 = proj1 + proj2;
  4611. var neg10 = projC12 < 0;
  4612. var abs10 = neg10 ? -projC12 : projC12;
  4613. if(abs10 < sum10) {
  4614. var depth10 = sum10 - abs10;
  4615. if(depth10 < mDepth) {
  4616. mDepth = depth10;
  4617. mId = 10;
  4618. mAxisX = edgeAxisX;
  4619. mAxisY = edgeAxisY;
  4620. mAxisZ = edgeAxisZ;
  4621. mSign = neg10 ? -1 : 1;
  4622. }
  4623. } else {
  4624. return;
  4625. }
  4626. }
  4627. edgeAxisX = y1Y * z2Z - y1Z * z2Y;
  4628. edgeAxisY = y1Z * z2X - y1X * z2Z;
  4629. edgeAxisZ = y1X * z2Y - y1Y * z2X;
  4630. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4631. var l5 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4632. if(l5 > 0) {
  4633. l5 = 1 / Math.sqrt(l5);
  4634. }
  4635. edgeAxisX *= l5;
  4636. edgeAxisY *= l5;
  4637. edgeAxisZ *= l5;
  4638. var dx16 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z;
  4639. var dy16 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z;
  4640. if(dx16 < 0) {
  4641. dx16 = -dx16;
  4642. }
  4643. if(dy16 < 0) {
  4644. dy16 = -dy16;
  4645. }
  4646. proj1 = dx16 + dy16;
  4647. var dx17 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z;
  4648. var dy17 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z;
  4649. if(dx17 < 0) {
  4650. dx17 = -dx17;
  4651. }
  4652. if(dy17 < 0) {
  4653. dy17 = -dy17;
  4654. }
  4655. proj2 = dx17 + dy17;
  4656. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4657. var sum11 = proj1 + proj2;
  4658. var neg11 = projC12 < 0;
  4659. var abs11 = neg11 ? -projC12 : projC12;
  4660. if(abs11 < sum11) {
  4661. var depth11 = sum11 - abs11;
  4662. if(depth11 < mDepth) {
  4663. mDepth = depth11;
  4664. mId = 11;
  4665. mAxisX = edgeAxisX;
  4666. mAxisY = edgeAxisY;
  4667. mAxisZ = edgeAxisZ;
  4668. mSign = neg11 ? -1 : 1;
  4669. }
  4670. } else {
  4671. return;
  4672. }
  4673. }
  4674. edgeAxisX = z1Y * x2Z - z1Z * x2Y;
  4675. edgeAxisY = z1Z * x2X - z1X * x2Z;
  4676. edgeAxisZ = z1X * x2Y - z1Y * x2X;
  4677. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4678. var l6 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4679. if(l6 > 0) {
  4680. l6 = 1 / Math.sqrt(l6);
  4681. }
  4682. edgeAxisX *= l6;
  4683. edgeAxisY *= l6;
  4684. edgeAxisZ *= l6;
  4685. var dx18 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z;
  4686. var dy18 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z;
  4687. if(dx18 < 0) {
  4688. dx18 = -dx18;
  4689. }
  4690. if(dy18 < 0) {
  4691. dy18 = -dy18;
  4692. }
  4693. proj1 = dx18 + dy18;
  4694. var dx19 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z;
  4695. var dy19 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z;
  4696. if(dx19 < 0) {
  4697. dx19 = -dx19;
  4698. }
  4699. if(dy19 < 0) {
  4700. dy19 = -dy19;
  4701. }
  4702. proj2 = dx19 + dy19;
  4703. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4704. var sum12 = proj1 + proj2;
  4705. var neg12 = projC12 < 0;
  4706. var abs12 = neg12 ? -projC12 : projC12;
  4707. if(abs12 < sum12) {
  4708. var depth12 = sum12 - abs12;
  4709. if(depth12 < mDepth) {
  4710. mDepth = depth12;
  4711. mId = 12;
  4712. mAxisX = edgeAxisX;
  4713. mAxisY = edgeAxisY;
  4714. mAxisZ = edgeAxisZ;
  4715. mSign = neg12 ? -1 : 1;
  4716. }
  4717. } else {
  4718. return;
  4719. }
  4720. }
  4721. edgeAxisX = z1Y * y2Z - z1Z * y2Y;
  4722. edgeAxisY = z1Z * y2X - z1X * y2Z;
  4723. edgeAxisZ = z1X * y2Y - z1Y * y2X;
  4724. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4725. var l7 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4726. if(l7 > 0) {
  4727. l7 = 1 / Math.sqrt(l7);
  4728. }
  4729. edgeAxisX *= l7;
  4730. edgeAxisY *= l7;
  4731. edgeAxisZ *= l7;
  4732. var dx20 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z;
  4733. var dy20 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z;
  4734. if(dx20 < 0) {
  4735. dx20 = -dx20;
  4736. }
  4737. if(dy20 < 0) {
  4738. dy20 = -dy20;
  4739. }
  4740. proj1 = dx20 + dy20;
  4741. var dx21 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z;
  4742. var dy21 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z;
  4743. if(dx21 < 0) {
  4744. dx21 = -dx21;
  4745. }
  4746. if(dy21 < 0) {
  4747. dy21 = -dy21;
  4748. }
  4749. proj2 = dx21 + dy21;
  4750. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4751. var sum13 = proj1 + proj2;
  4752. var neg13 = projC12 < 0;
  4753. var abs13 = neg13 ? -projC12 : projC12;
  4754. if(abs13 < sum13) {
  4755. var depth13 = sum13 - abs13;
  4756. if(depth13 < mDepth) {
  4757. mDepth = depth13;
  4758. mId = 13;
  4759. mAxisX = edgeAxisX;
  4760. mAxisY = edgeAxisY;
  4761. mAxisZ = edgeAxisZ;
  4762. mSign = neg13 ? -1 : 1;
  4763. }
  4764. } else {
  4765. return;
  4766. }
  4767. }
  4768. edgeAxisX = z1Y * z2Z - z1Z * z2Y;
  4769. edgeAxisY = z1Z * z2X - z1X * z2Z;
  4770. edgeAxisZ = z1X * z2Y - z1Y * z2X;
  4771. if(!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) {
  4772. var l8 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ;
  4773. if(l8 > 0) {
  4774. l8 = 1 / Math.sqrt(l8);
  4775. }
  4776. edgeAxisX *= l8;
  4777. edgeAxisY *= l8;
  4778. edgeAxisZ *= l8;
  4779. var dx22 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z;
  4780. var dy22 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z;
  4781. if(dx22 < 0) {
  4782. dx22 = -dx22;
  4783. }
  4784. if(dy22 < 0) {
  4785. dy22 = -dy22;
  4786. }
  4787. proj1 = dx22 + dy22;
  4788. var dx23 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z;
  4789. var dy23 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z;
  4790. if(dx23 < 0) {
  4791. dx23 = -dx23;
  4792. }
  4793. if(dy23 < 0) {
  4794. dy23 = -dy23;
  4795. }
  4796. proj2 = dx23 + dy23;
  4797. projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z;
  4798. var sum14 = proj1 + proj2;
  4799. var neg14 = projC12 < 0;
  4800. var abs14 = neg14 ? -projC12 : projC12;
  4801. if(abs14 < sum14) {
  4802. var depth14 = sum14 - abs14;
  4803. if(depth14 < mDepth) {
  4804. mDepth = depth14;
  4805. mId = 14;
  4806. mAxisX = edgeAxisX;
  4807. mAxisY = edgeAxisY;
  4808. mAxisZ = edgeAxisZ;
  4809. mSign = neg14 ? -1 : 1;
  4810. }
  4811. } else {
  4812. return;
  4813. }
  4814. }
  4815. if(mId >= 6) {
  4816. mAxisX *= mSign;
  4817. mAxisY *= mSign;
  4818. mAxisZ *= mSign;
  4819. var id1 = (mId - 6) / 3 | 0;
  4820. var id2 = mId - 6 - id1 * 3;
  4821. var p1;
  4822. var p1X;
  4823. var p1Y;
  4824. var p1Z;
  4825. var p2;
  4826. var p2X;
  4827. var p2Y;
  4828. var p2Z;
  4829. var d11;
  4830. var d1X;
  4831. var d1Y;
  4832. var d1Z;
  4833. var d21;
  4834. var d2X;
  4835. var d2Y;
  4836. var d2Z;
  4837. switch(id1) {
  4838. case 0:
  4839. d1X = x1X;
  4840. d1Y = x1Y;
  4841. d1Z = x1Z;
  4842. var signX = sy1X * mAxisX + sy1Y * mAxisY + sy1Z * mAxisZ > 0;
  4843. var signY = sz1X * mAxisX + sz1Y * mAxisY + sz1Z * mAxisZ > 0;
  4844. if(signX) {
  4845. if(signY) {
  4846. p1X = sy1X + sz1X;
  4847. p1Y = sy1Y + sz1Y;
  4848. p1Z = sy1Z + sz1Z;
  4849. } else {
  4850. p1X = sy1X - sz1X;
  4851. p1Y = sy1Y - sz1Y;
  4852. p1Z = sy1Z - sz1Z;
  4853. }
  4854. } else if(signY) {
  4855. p1X = sz1X - sy1X;
  4856. p1Y = sz1Y - sy1Y;
  4857. p1Z = sz1Z - sy1Z;
  4858. } else {
  4859. p1X = sy1X + sz1X;
  4860. p1Y = sy1Y + sz1Y;
  4861. p1Z = sy1Z + sz1Z;
  4862. p1X = -p1X;
  4863. p1Y = -p1Y;
  4864. p1Z = -p1Z;
  4865. }
  4866. break;
  4867. case 1:
  4868. d1X = y1X;
  4869. d1Y = y1Y;
  4870. d1Z = y1Z;
  4871. var signX1 = sx1X * mAxisX + sx1Y * mAxisY + sx1Z * mAxisZ > 0;
  4872. var signY1 = sz1X * mAxisX + sz1Y * mAxisY + sz1Z * mAxisZ > 0;
  4873. if(signX1) {
  4874. if(signY1) {
  4875. p1X = sx1X + sz1X;
  4876. p1Y = sx1Y + sz1Y;
  4877. p1Z = sx1Z + sz1Z;
  4878. } else {
  4879. p1X = sx1X - sz1X;
  4880. p1Y = sx1Y - sz1Y;
  4881. p1Z = sx1Z - sz1Z;
  4882. }
  4883. } else if(signY1) {
  4884. p1X = sz1X - sx1X;
  4885. p1Y = sz1Y - sx1Y;
  4886. p1Z = sz1Z - sx1Z;
  4887. } else {
  4888. p1X = sx1X + sz1X;
  4889. p1Y = sx1Y + sz1Y;
  4890. p1Z = sx1Z + sz1Z;
  4891. p1X = -p1X;
  4892. p1Y = -p1Y;
  4893. p1Z = -p1Z;
  4894. }
  4895. break;
  4896. default:
  4897. d1X = z1X;
  4898. d1Y = z1Y;
  4899. d1Z = z1Z;
  4900. var signX2 = sx1X * mAxisX + sx1Y * mAxisY + sx1Z * mAxisZ > 0;
  4901. var signY2 = sy1X * mAxisX + sy1Y * mAxisY + sy1Z * mAxisZ > 0;
  4902. if(signX2) {
  4903. if(signY2) {
  4904. p1X = sx1X + sy1X;
  4905. p1Y = sx1Y + sy1Y;
  4906. p1Z = sx1Z + sy1Z;
  4907. } else {
  4908. p1X = sx1X - sy1X;
  4909. p1Y = sx1Y - sy1Y;
  4910. p1Z = sx1Z - sy1Z;
  4911. }
  4912. } else if(signY2) {
  4913. p1X = sy1X - sx1X;
  4914. p1Y = sy1Y - sx1Y;
  4915. p1Z = sy1Z - sx1Z;
  4916. } else {
  4917. p1X = sx1X + sy1X;
  4918. p1Y = sx1Y + sy1Y;
  4919. p1Z = sx1Z + sy1Z;
  4920. p1X = -p1X;
  4921. p1Y = -p1Y;
  4922. p1Z = -p1Z;
  4923. }
  4924. }
  4925. p1X = c1X + p1X;
  4926. p1Y = c1Y + p1Y;
  4927. p1Z = c1Z + p1Z;
  4928. switch(id2) {
  4929. case 0:
  4930. d2X = x2X;
  4931. d2Y = x2Y;
  4932. d2Z = x2Z;
  4933. var signX3 = sy2X * mAxisX + sy2Y * mAxisY + sy2Z * mAxisZ > 0;
  4934. var signY3 = sz2X * mAxisX + sz2Y * mAxisY + sz2Z * mAxisZ > 0;
  4935. if(signX3) {
  4936. if(signY3) {
  4937. p2X = sy2X + sz2X;
  4938. p2Y = sy2Y + sz2Y;
  4939. p2Z = sy2Z + sz2Z;
  4940. } else {
  4941. p2X = sy2X - sz2X;
  4942. p2Y = sy2Y - sz2Y;
  4943. p2Z = sy2Z - sz2Z;
  4944. }
  4945. } else if(signY3) {
  4946. p2X = sz2X - sy2X;
  4947. p2Y = sz2Y - sy2Y;
  4948. p2Z = sz2Z - sy2Z;
  4949. } else {
  4950. p2X = sy2X + sz2X;
  4951. p2Y = sy2Y + sz2Y;
  4952. p2Z = sy2Z + sz2Z;
  4953. p2X = -p2X;
  4954. p2Y = -p2Y;
  4955. p2Z = -p2Z;
  4956. }
  4957. break;
  4958. case 1:
  4959. d2X = y2X;
  4960. d2Y = y2Y;
  4961. d2Z = y2Z;
  4962. var signX4 = sx2X * mAxisX + sx2Y * mAxisY + sx2Z * mAxisZ > 0;
  4963. var signY4 = sz2X * mAxisX + sz2Y * mAxisY + sz2Z * mAxisZ > 0;
  4964. if(signX4) {
  4965. if(signY4) {
  4966. p2X = sx2X + sz2X;
  4967. p2Y = sx2Y + sz2Y;
  4968. p2Z = sx2Z + sz2Z;
  4969. } else {
  4970. p2X = sx2X - sz2X;
  4971. p2Y = sx2Y - sz2Y;
  4972. p2Z = sx2Z - sz2Z;
  4973. }
  4974. } else if(signY4) {
  4975. p2X = sz2X - sx2X;
  4976. p2Y = sz2Y - sx2Y;
  4977. p2Z = sz2Z - sx2Z;
  4978. } else {
  4979. p2X = sx2X + sz2X;
  4980. p2Y = sx2Y + sz2Y;
  4981. p2Z = sx2Z + sz2Z;
  4982. p2X = -p2X;
  4983. p2Y = -p2Y;
  4984. p2Z = -p2Z;
  4985. }
  4986. break;
  4987. default:
  4988. d2X = z2X;
  4989. d2Y = z2Y;
  4990. d2Z = z2Z;
  4991. var signX5 = sx2X * mAxisX + sx2Y * mAxisY + sx2Z * mAxisZ > 0;
  4992. var signY5 = sy2X * mAxisX + sy2Y * mAxisY + sy2Z * mAxisZ > 0;
  4993. if(signX5) {
  4994. if(signY5) {
  4995. p2X = sx2X + sy2X;
  4996. p2Y = sx2Y + sy2Y;
  4997. p2Z = sx2Z + sy2Z;
  4998. } else {
  4999. p2X = sx2X - sy2X;
  5000. p2Y = sx2Y - sy2Y;
  5001. p2Z = sx2Z - sy2Z;
  5002. }
  5003. } else if(signY5) {
  5004. p2X = sy2X - sx2X;
  5005. p2Y = sy2Y - sx2Y;
  5006. p2Z = sy2Z - sx2Z;
  5007. } else {
  5008. p2X = sx2X + sy2X;
  5009. p2Y = sx2Y + sy2Y;
  5010. p2Z = sx2Z + sy2Z;
  5011. p2X = -p2X;
  5012. p2Y = -p2Y;
  5013. p2Z = -p2Z;
  5014. }
  5015. }
  5016. p2X = c2X - p2X;
  5017. p2Y = c2Y - p2Y;
  5018. p2Z = c2Z - p2Z;
  5019. var r;
  5020. var rX;
  5021. var rY;
  5022. var rZ;
  5023. rX = p1X - p2X;
  5024. rY = p1Y - p2Y;
  5025. rZ = p1Z - p2Z;
  5026. var dot12 = d1X * d2X + d1Y * d2Y + d1Z * d2Z;
  5027. var dot1r = d1X * rX + d1Y * rY + d1Z * rZ;
  5028. var dot2r = d2X * rX + d2Y * rY + d2Z * rZ;
  5029. var invDet = 1 / (1 - dot12 * dot12);
  5030. var t1 = (dot12 * dot2r - dot1r) * invDet;
  5031. var t2 = (dot2r - dot12 * dot1r) * invDet;
  5032. var cp1;
  5033. var cp1X;
  5034. var cp1Y;
  5035. var cp1Z;
  5036. var cp2;
  5037. var cp2X;
  5038. var cp2Y;
  5039. var cp2Z;
  5040. cp1X = p1X + d1X * t1;
  5041. cp1Y = p1Y + d1Y * t1;
  5042. cp1Z = p1Z + d1Z * t1;
  5043. cp2X = p2X + d2X * t2;
  5044. cp2Y = p2Y + d2Y * t2;
  5045. cp2Z = p2Z + d2Z * t2;
  5046. var normal;
  5047. var normalX;
  5048. var normalY;
  5049. var normalZ;
  5050. normalX = -mAxisX;
  5051. normalY = -mAxisY;
  5052. normalZ = -mAxisZ;
  5053. this.setNormal(result,normalX,normalY,normalZ);
  5054. this.addPoint(result,cp1X,cp1Y,cp1Z,cp2X,cp2Y,cp2Z,mDepth,4);
  5055. return;
  5056. }
  5057. var tmp;
  5058. var tmpX;
  5059. var tmpY;
  5060. var tmpZ;
  5061. var swapped;
  5062. if(mId >= 3) {
  5063. mSign = -mSign;
  5064. c12X = -c12X;
  5065. c12Y = -c12Y;
  5066. c12Z = -c12Z;
  5067. var tmp1 = b1;
  5068. b1 = b2;
  5069. b2 = tmp1;
  5070. var tmp2 = w1;
  5071. w1 = w2;
  5072. w2 = tmp2;
  5073. var tmp3 = h1;
  5074. h1 = h2;
  5075. h2 = tmp3;
  5076. var tmp4 = d1;
  5077. d1 = d2;
  5078. d2 = tmp4;
  5079. tmpX = c1X;
  5080. tmpY = c1Y;
  5081. tmpZ = c1Z;
  5082. c1X = c2X;
  5083. c1Y = c2Y;
  5084. c1Z = c2Z;
  5085. c2X = tmpX;
  5086. c2Y = tmpY;
  5087. c2Z = tmpZ;
  5088. tmpX = x1X;
  5089. tmpY = x1Y;
  5090. tmpZ = x1Z;
  5091. x1X = x2X;
  5092. x1Y = x2Y;
  5093. x1Z = x2Z;
  5094. x2X = tmpX;
  5095. x2Y = tmpY;
  5096. x2Z = tmpZ;
  5097. tmpX = y1X;
  5098. tmpY = y1Y;
  5099. tmpZ = y1Z;
  5100. y1X = y2X;
  5101. y1Y = y2Y;
  5102. y1Z = y2Z;
  5103. y2X = tmpX;
  5104. y2Y = tmpY;
  5105. y2Z = tmpZ;
  5106. tmpX = z1X;
  5107. tmpY = z1Y;
  5108. tmpZ = z1Z;
  5109. z1X = z2X;
  5110. z1Y = z2Y;
  5111. z1Z = z2Z;
  5112. z2X = tmpX;
  5113. z2Y = tmpY;
  5114. z2Z = tmpZ;
  5115. tmpX = sx1X;
  5116. tmpY = sx1Y;
  5117. tmpZ = sx1Z;
  5118. sx1X = sx2X;
  5119. sx1Y = sx2Y;
  5120. sx1Z = sx2Z;
  5121. sx2X = tmpX;
  5122. sx2Y = tmpY;
  5123. sx2Z = tmpZ;
  5124. tmpX = sy1X;
  5125. tmpY = sy1Y;
  5126. tmpZ = sy1Z;
  5127. sy1X = sy2X;
  5128. sy1Y = sy2Y;
  5129. sy1Z = sy2Z;
  5130. sy2X = tmpX;
  5131. sy2Y = tmpY;
  5132. sy2Z = tmpZ;
  5133. tmpX = sz1X;
  5134. tmpY = sz1Y;
  5135. tmpZ = sz1Z;
  5136. sz1X = sz2X;
  5137. sz1Y = sz2Y;
  5138. sz1Z = sz2Z;
  5139. sz2X = tmpX;
  5140. sz2Y = tmpY;
  5141. sz2Z = tmpZ;
  5142. mId -= 3;
  5143. swapped = true;
  5144. } else {
  5145. swapped = false;
  5146. }
  5147. var refCenter;
  5148. var refCenterX;
  5149. var refCenterY;
  5150. var refCenterZ;
  5151. var refNormal;
  5152. var refNormalX;
  5153. var refNormalY;
  5154. var refNormalZ;
  5155. var refX;
  5156. var refXX;
  5157. var refXY;
  5158. var refXZ;
  5159. var refY;
  5160. var refYX;
  5161. var refYY;
  5162. var refYZ;
  5163. var refW;
  5164. var refH;
  5165. switch(mId) {
  5166. case 0:
  5167. refCenterX = sx1X;
  5168. refCenterY = sx1Y;
  5169. refCenterZ = sx1Z;
  5170. refNormalX = x1X;
  5171. refNormalY = x1Y;
  5172. refNormalZ = x1Z;
  5173. refXX = y1X;
  5174. refXY = y1Y;
  5175. refXZ = y1Z;
  5176. refYX = z1X;
  5177. refYY = z1Y;
  5178. refYZ = z1Z;
  5179. refW = h1;
  5180. refH = d1;
  5181. break;
  5182. case 1:
  5183. refCenterX = sy1X;
  5184. refCenterY = sy1Y;
  5185. refCenterZ = sy1Z;
  5186. refNormalX = y1X;
  5187. refNormalY = y1Y;
  5188. refNormalZ = y1Z;
  5189. refXX = z1X;
  5190. refXY = z1Y;
  5191. refXZ = z1Z;
  5192. refYX = x1X;
  5193. refYY = x1Y;
  5194. refYZ = x1Z;
  5195. refW = d1;
  5196. refH = w1;
  5197. break;
  5198. default:
  5199. refCenterX = sz1X;
  5200. refCenterY = sz1Y;
  5201. refCenterZ = sz1Z;
  5202. refNormalX = z1X;
  5203. refNormalY = z1Y;
  5204. refNormalZ = z1Z;
  5205. refXX = x1X;
  5206. refXY = x1Y;
  5207. refXZ = x1Z;
  5208. refYX = y1X;
  5209. refYY = y1Y;
  5210. refYZ = y1Z;
  5211. refW = w1;
  5212. refH = h1;
  5213. }
  5214. if(mSign < 0) {
  5215. refCenterX = -refCenterX;
  5216. refCenterY = -refCenterY;
  5217. refCenterZ = -refCenterZ;
  5218. refNormalX = -refNormalX;
  5219. refNormalY = -refNormalY;
  5220. refNormalZ = -refNormalZ;
  5221. tmpX = refXX;
  5222. tmpY = refXY;
  5223. tmpZ = refXZ;
  5224. refXX = refYX;
  5225. refXY = refYY;
  5226. refXZ = refYZ;
  5227. refYX = tmpX;
  5228. refYY = tmpY;
  5229. refYZ = tmpZ;
  5230. var tmp5 = refW;
  5231. refW = refH;
  5232. refH = tmp5;
  5233. }
  5234. refCenterX += c1X;
  5235. refCenterY += c1Y;
  5236. refCenterZ += c1Z;
  5237. var minIncDot = 1;
  5238. var incId = 0;
  5239. var incDot = refNormalX * x2X + refNormalY * x2Y + refNormalZ * x2Z;
  5240. if(incDot < minIncDot) {
  5241. minIncDot = incDot;
  5242. incId = 0;
  5243. }
  5244. if(-incDot < minIncDot) {
  5245. minIncDot = -incDot;
  5246. incId = 1;
  5247. }
  5248. incDot = refNormalX * y2X + refNormalY * y2Y + refNormalZ * y2Z;
  5249. if(incDot < minIncDot) {
  5250. minIncDot = incDot;
  5251. incId = 2;
  5252. }
  5253. if(-incDot < minIncDot) {
  5254. minIncDot = -incDot;
  5255. incId = 3;
  5256. }
  5257. incDot = refNormalX * z2X + refNormalY * z2Y + refNormalZ * z2Z;
  5258. if(incDot < minIncDot) {
  5259. minIncDot = incDot;
  5260. incId = 4;
  5261. }
  5262. if(-incDot < minIncDot) {
  5263. minIncDot = -incDot;
  5264. incId = 5;
  5265. }
  5266. var incV1;
  5267. var incV1X;
  5268. var incV1Y;
  5269. var incV1Z;
  5270. var incV2;
  5271. var incV2X;
  5272. var incV2Y;
  5273. var incV2Z;
  5274. var incV3;
  5275. var incV3X;
  5276. var incV3Y;
  5277. var incV3Z;
  5278. var incV4;
  5279. var incV4X;
  5280. var incV4Y;
  5281. var incV4Z;
  5282. switch(incId) {
  5283. case 0:
  5284. incV1X = sx2X + sy2X;
  5285. incV1Y = sx2Y + sy2Y;
  5286. incV1Z = sx2Z + sy2Z;
  5287. incV1X += sz2X;
  5288. incV1Y += sz2Y;
  5289. incV1Z += sz2Z;
  5290. incV2X = sx2X - sy2X;
  5291. incV2Y = sx2Y - sy2Y;
  5292. incV2Z = sx2Z - sy2Z;
  5293. incV2X += sz2X;
  5294. incV2Y += sz2Y;
  5295. incV2Z += sz2Z;
  5296. incV3X = sx2X - sy2X;
  5297. incV3Y = sx2Y - sy2Y;
  5298. incV3Z = sx2Z - sy2Z;
  5299. incV3X -= sz2X;
  5300. incV3Y -= sz2Y;
  5301. incV3Z -= sz2Z;
  5302. incV4X = sx2X + sy2X;
  5303. incV4Y = sx2Y + sy2Y;
  5304. incV4Z = sx2Z + sy2Z;
  5305. incV4X -= sz2X;
  5306. incV4Y -= sz2Y;
  5307. incV4Z -= sz2Z;
  5308. break;
  5309. case 1:
  5310. incV1X = sy2X - sx2X;
  5311. incV1Y = sy2Y - sx2Y;
  5312. incV1Z = sy2Z - sx2Z;
  5313. incV1X += sz2X;
  5314. incV1Y += sz2Y;
  5315. incV1Z += sz2Z;
  5316. incV2X = sy2X - sx2X;
  5317. incV2Y = sy2Y - sx2Y;
  5318. incV2Z = sy2Z - sx2Z;
  5319. incV2X -= sz2X;
  5320. incV2Y -= sz2Y;
  5321. incV2Z -= sz2Z;
  5322. incV3X = sx2X + sy2X;
  5323. incV3Y = sx2Y + sy2Y;
  5324. incV3Z = sx2Z + sy2Z;
  5325. incV3X = -incV3X;
  5326. incV3Y = -incV3Y;
  5327. incV3Z = -incV3Z;
  5328. incV3X -= sz2X;
  5329. incV3Y -= sz2Y;
  5330. incV3Z -= sz2Z;
  5331. incV4X = sx2X + sy2X;
  5332. incV4Y = sx2Y + sy2Y;
  5333. incV4Z = sx2Z + sy2Z;
  5334. incV4X = -incV4X;
  5335. incV4Y = -incV4Y;
  5336. incV4Z = -incV4Z;
  5337. incV4X += sz2X;
  5338. incV4Y += sz2Y;
  5339. incV4Z += sz2Z;
  5340. break;
  5341. case 2:
  5342. incV1X = sx2X + sy2X;
  5343. incV1Y = sx2Y + sy2Y;
  5344. incV1Z = sx2Z + sy2Z;
  5345. incV1X += sz2X;
  5346. incV1Y += sz2Y;
  5347. incV1Z += sz2Z;
  5348. incV2X = sx2X + sy2X;
  5349. incV2Y = sx2Y + sy2Y;
  5350. incV2Z = sx2Z + sy2Z;
  5351. incV2X -= sz2X;
  5352. incV2Y -= sz2Y;
  5353. incV2Z -= sz2Z;
  5354. incV3X = sy2X - sx2X;
  5355. incV3Y = sy2Y - sx2Y;
  5356. incV3Z = sy2Z - sx2Z;
  5357. incV3X -= sz2X;
  5358. incV3Y -= sz2Y;
  5359. incV3Z -= sz2Z;
  5360. incV4X = sy2X - sx2X;
  5361. incV4Y = sy2Y - sx2Y;
  5362. incV4Z = sy2Z - sx2Z;
  5363. incV4X += sz2X;
  5364. incV4Y += sz2Y;
  5365. incV4Z += sz2Z;
  5366. break;
  5367. case 3:
  5368. incV1X = sx2X - sy2X;
  5369. incV1Y = sx2Y - sy2Y;
  5370. incV1Z = sx2Z - sy2Z;
  5371. incV1X += sz2X;
  5372. incV1Y += sz2Y;
  5373. incV1Z += sz2Z;
  5374. incV2X = sx2X + sy2X;
  5375. incV2Y = sx2Y + sy2Y;
  5376. incV2Z = sx2Z + sy2Z;
  5377. incV2X = -incV2X;
  5378. incV2Y = -incV2Y;
  5379. incV2Z = -incV2Z;
  5380. incV2X += sz2X;
  5381. incV2Y += sz2Y;
  5382. incV2Z += sz2Z;
  5383. incV3X = sx2X + sy2X;
  5384. incV3Y = sx2Y + sy2Y;
  5385. incV3Z = sx2Z + sy2Z;
  5386. incV3X = -incV3X;
  5387. incV3Y = -incV3Y;
  5388. incV3Z = -incV3Z;
  5389. incV3X -= sz2X;
  5390. incV3Y -= sz2Y;
  5391. incV3Z -= sz2Z;
  5392. incV4X = sx2X - sy2X;
  5393. incV4Y = sx2Y - sy2Y;
  5394. incV4Z = sx2Z - sy2Z;
  5395. incV4X -= sz2X;
  5396. incV4Y -= sz2Y;
  5397. incV4Z -= sz2Z;
  5398. break;
  5399. case 4:
  5400. incV1X = sx2X + sy2X;
  5401. incV1Y = sx2Y + sy2Y;
  5402. incV1Z = sx2Z + sy2Z;
  5403. incV1X += sz2X;
  5404. incV1Y += sz2Y;
  5405. incV1Z += sz2Z;
  5406. incV2X = sy2X - sx2X;
  5407. incV2Y = sy2Y - sx2Y;
  5408. incV2Z = sy2Z - sx2Z;
  5409. incV2X += sz2X;
  5410. incV2Y += sz2Y;
  5411. incV2Z += sz2Z;
  5412. incV3X = sx2X + sy2X;
  5413. incV3Y = sx2Y + sy2Y;
  5414. incV3Z = sx2Z + sy2Z;
  5415. incV3X = -incV3X;
  5416. incV3Y = -incV3Y;
  5417. incV3Z = -incV3Z;
  5418. incV3X += sz2X;
  5419. incV3Y += sz2Y;
  5420. incV3Z += sz2Z;
  5421. incV4X = sx2X - sy2X;
  5422. incV4Y = sx2Y - sy2Y;
  5423. incV4Z = sx2Z - sy2Z;
  5424. incV4X += sz2X;
  5425. incV4Y += sz2Y;
  5426. incV4Z += sz2Z;
  5427. break;
  5428. default:
  5429. incV1X = sx2X + sy2X;
  5430. incV1Y = sx2Y + sy2Y;
  5431. incV1Z = sx2Z + sy2Z;
  5432. incV1X -= sz2X;
  5433. incV1Y -= sz2Y;
  5434. incV1Z -= sz2Z;
  5435. incV2X = sx2X - sy2X;
  5436. incV2Y = sx2Y - sy2Y;
  5437. incV2Z = sx2Z - sy2Z;
  5438. incV2X -= sz2X;
  5439. incV2Y -= sz2Y;
  5440. incV2Z -= sz2Z;
  5441. incV3X = sx2X + sy2X;
  5442. incV3Y = sx2Y + sy2Y;
  5443. incV3Z = sx2Z + sy2Z;
  5444. incV3X = -incV3X;
  5445. incV3Y = -incV3Y;
  5446. incV3Z = -incV3Z;
  5447. incV3X -= sz2X;
  5448. incV3Y -= sz2Y;
  5449. incV3Z -= sz2Z;
  5450. incV4X = sy2X - sx2X;
  5451. incV4Y = sy2Y - sx2Y;
  5452. incV4Z = sy2Z - sx2Z;
  5453. incV4X -= sz2X;
  5454. incV4Y -= sz2Y;
  5455. incV4Z -= sz2Z;
  5456. }
  5457. incV1X += c12X;
  5458. incV1Y += c12Y;
  5459. incV1Z += c12Z;
  5460. incV2X += c12X;
  5461. incV2Y += c12Y;
  5462. incV2Z += c12Z;
  5463. incV3X += c12X;
  5464. incV3Y += c12Y;
  5465. incV3Z += c12Z;
  5466. incV4X += c12X;
  5467. incV4Y += c12Y;
  5468. incV4Z += c12Z;
  5469. var _this = this.clipper;
  5470. _this.w = refW;
  5471. _this.h = refH;
  5472. _this.numVertices = 0;
  5473. _this.numTmpVertices = 0;
  5474. var _this1 = this.clipper;
  5475. var _this2 = _this1.vertices[_this1.numVertices++];
  5476. _this2.x = incV1X * refXX + incV1Y * refXY + incV1Z * refXZ;
  5477. _this2.y = incV1X * refYX + incV1Y * refYY + incV1Z * refYZ;
  5478. _this2.wx = incV1X;
  5479. _this2.wy = incV1Y;
  5480. _this2.wz = incV1Z;
  5481. var _this3 = this.clipper;
  5482. var _this4 = _this3.vertices[_this3.numVertices++];
  5483. _this4.x = incV2X * refXX + incV2Y * refXY + incV2Z * refXZ;
  5484. _this4.y = incV2X * refYX + incV2Y * refYY + incV2Z * refYZ;
  5485. _this4.wx = incV2X;
  5486. _this4.wy = incV2Y;
  5487. _this4.wz = incV2Z;
  5488. var _this5 = this.clipper;
  5489. var _this6 = _this5.vertices[_this5.numVertices++];
  5490. _this6.x = incV3X * refXX + incV3Y * refXY + incV3Z * refXZ;
  5491. _this6.y = incV3X * refYX + incV3Y * refYY + incV3Z * refYZ;
  5492. _this6.wx = incV3X;
  5493. _this6.wy = incV3Y;
  5494. _this6.wz = incV3Z;
  5495. var _this7 = this.clipper;
  5496. var _this8 = _this7.vertices[_this7.numVertices++];
  5497. _this8.x = incV4X * refXX + incV4Y * refXY + incV4Z * refXZ;
  5498. _this8.y = incV4X * refYX + incV4Y * refYY + incV4Z * refYZ;
  5499. _this8.wx = incV4X;
  5500. _this8.wy = incV4Y;
  5501. _this8.wz = incV4Z;
  5502. this.clipper.clip();
  5503. this.clipper.reduce();
  5504. var normal1;
  5505. var normalX1;
  5506. var normalY1;
  5507. var normalZ1;
  5508. if(swapped) {
  5509. normalX1 = refNormalX;
  5510. normalY1 = refNormalY;
  5511. normalZ1 = refNormalZ;
  5512. } else {
  5513. normalX1 = -refNormalX;
  5514. normalY1 = -refNormalY;
  5515. normalZ1 = -refNormalZ;
  5516. }
  5517. this.setNormal(result,normalX1,normalY1,normalZ1);
  5518. var _g = 0;
  5519. var _g1 = this.clipper.numVertices;
  5520. while(_g < _g1) {
  5521. var i = _g++;
  5522. var v = this.clipper.vertices[i];
  5523. var clippedVertex;
  5524. var clippedVertexX;
  5525. var clippedVertexY;
  5526. var clippedVertexZ;
  5527. clippedVertexX = v.wx;
  5528. clippedVertexY = v.wy;
  5529. clippedVertexZ = v.wz;
  5530. clippedVertexX += c1X;
  5531. clippedVertexY += c1Y;
  5532. clippedVertexZ += c1Z;
  5533. var clippedVertexToRefCenter;
  5534. var clippedVertexToRefCenterX;
  5535. var clippedVertexToRefCenterY;
  5536. var clippedVertexToRefCenterZ;
  5537. clippedVertexToRefCenterX = refCenterX - clippedVertexX;
  5538. clippedVertexToRefCenterY = refCenterY - clippedVertexY;
  5539. clippedVertexToRefCenterZ = refCenterZ - clippedVertexZ;
  5540. var depth15 = clippedVertexToRefCenterX * refNormalX + clippedVertexToRefCenterY * refNormalY + clippedVertexToRefCenterZ * refNormalZ;
  5541. var clippedVertexOnRefFace;
  5542. var clippedVertexOnRefFaceX;
  5543. var clippedVertexOnRefFaceY;
  5544. var clippedVertexOnRefFaceZ;
  5545. clippedVertexOnRefFaceX = clippedVertexX + refNormalX * depth15;
  5546. clippedVertexOnRefFaceY = clippedVertexY + refNormalY * depth15;
  5547. clippedVertexOnRefFaceZ = clippedVertexZ + refNormalZ * depth15;
  5548. if(depth15 > -oimo.common.Setting.contactPersistenceThreshold) {
  5549. if(swapped) {
  5550. this.addPoint(result,clippedVertexX,clippedVertexY,clippedVertexZ,clippedVertexOnRefFaceX,clippedVertexOnRefFaceY,clippedVertexOnRefFaceZ,depth15,i);
  5551. } else {
  5552. this.addPoint(result,clippedVertexOnRefFaceX,clippedVertexOnRefFaceY,clippedVertexOnRefFaceZ,clippedVertexX,clippedVertexY,clippedVertexZ,depth15,i);
  5553. }
  5554. }
  5555. }
  5556. }
  5557. }
  5558. if(!oimo.collision.narrowphase.detector._BoxBoxDetector) oimo.collision.narrowphase.detector._BoxBoxDetector = {};
  5559. oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex = class oimo_collision_narrowphase_detector__$BoxBoxDetector_IncidentVertex {
  5560. constructor() {
  5561. this.x = 0;
  5562. this.y = 0;
  5563. this.wx = 0;
  5564. this.wy = 0;
  5565. this.wz = 0;
  5566. }
  5567. }
  5568. oimo.collision.narrowphase.detector._BoxBoxDetector.FaceClipper = class oimo_collision_narrowphase_detector__$BoxBoxDetector_FaceClipper {
  5569. constructor() {
  5570. this.w = 0;
  5571. this.h = 0;
  5572. this.numVertices = 0;
  5573. this.numTmpVertices = 0;
  5574. var this1 = new Array(8);
  5575. this.vertices = this1;
  5576. var this2 = new Array(8);
  5577. this.tmpVertices = this2;
  5578. this.vertices[0] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5579. this.tmpVertices[0] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5580. this.vertices[1] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5581. this.tmpVertices[1] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5582. this.vertices[2] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5583. this.tmpVertices[2] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5584. this.vertices[3] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5585. this.tmpVertices[3] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5586. this.vertices[4] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5587. this.tmpVertices[4] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5588. this.vertices[5] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5589. this.tmpVertices[5] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5590. this.vertices[6] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5591. this.tmpVertices[6] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5592. this.vertices[7] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5593. this.tmpVertices[7] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex();
  5594. }
  5595. clip() {
  5596. var _g = 0;
  5597. var _g1 = this.numVertices;
  5598. while(_g < _g1) {
  5599. var i = _g++;
  5600. var v1 = this.vertices[i];
  5601. var v2 = this.vertices[(i + 1) % this.numVertices];
  5602. var s1 = this.w + v1.x;
  5603. var s2 = this.w + v2.x;
  5604. if(s1 > 0 && s2 > 0) {
  5605. var _this = this.tmpVertices[this.numTmpVertices++];
  5606. _this.x = v1.x;
  5607. _this.y = v1.y;
  5608. _this.wx = v1.wx;
  5609. _this.wy = v1.wy;
  5610. _this.wz = v1.wz;
  5611. } else if(s1 > 0 && s2 <= 0) {
  5612. var _this1 = this.tmpVertices[this.numTmpVertices++];
  5613. _this1.x = v1.x;
  5614. _this1.y = v1.y;
  5615. _this1.wx = v1.wx;
  5616. _this1.wy = v1.wy;
  5617. _this1.wz = v1.wz;
  5618. var t = s1 / (s1 - s2);
  5619. var _this2 = this.tmpVertices[this.numTmpVertices++];
  5620. _this2.x = v1.x + (v2.x - v1.x) * t;
  5621. _this2.y = v1.y + (v2.y - v1.y) * t;
  5622. _this2.wx = v1.wx + (v2.wx - v1.wx) * t;
  5623. _this2.wy = v1.wy + (v2.wy - v1.wy) * t;
  5624. _this2.wz = v1.wz + (v2.wz - v1.wz) * t;
  5625. } else if(s1 <= 0 && s2 > 0) {
  5626. var t1 = s1 / (s1 - s2);
  5627. var _this3 = this.tmpVertices[this.numTmpVertices++];
  5628. _this3.x = v1.x + (v2.x - v1.x) * t1;
  5629. _this3.y = v1.y + (v2.y - v1.y) * t1;
  5630. _this3.wx = v1.wx + (v2.wx - v1.wx) * t1;
  5631. _this3.wy = v1.wy + (v2.wy - v1.wy) * t1;
  5632. _this3.wz = v1.wz + (v2.wz - v1.wz) * t1;
  5633. }
  5634. }
  5635. var tmp = this.vertices;
  5636. this.vertices = this.tmpVertices;
  5637. this.tmpVertices = tmp;
  5638. this.numVertices = this.numTmpVertices;
  5639. this.numTmpVertices = 0;
  5640. var _g2 = 0;
  5641. var _g11 = this.numVertices;
  5642. while(_g2 < _g11) {
  5643. var i1 = _g2++;
  5644. var v11 = this.vertices[i1];
  5645. var v21 = this.vertices[(i1 + 1) % this.numVertices];
  5646. var s11 = this.w - v11.x;
  5647. var s21 = this.w - v21.x;
  5648. if(s11 > 0 && s21 > 0) {
  5649. var _this4 = this.tmpVertices[this.numTmpVertices++];
  5650. _this4.x = v11.x;
  5651. _this4.y = v11.y;
  5652. _this4.wx = v11.wx;
  5653. _this4.wy = v11.wy;
  5654. _this4.wz = v11.wz;
  5655. } else if(s11 > 0 && s21 <= 0) {
  5656. var _this5 = this.tmpVertices[this.numTmpVertices++];
  5657. _this5.x = v11.x;
  5658. _this5.y = v11.y;
  5659. _this5.wx = v11.wx;
  5660. _this5.wy = v11.wy;
  5661. _this5.wz = v11.wz;
  5662. var t2 = s11 / (s11 - s21);
  5663. var _this6 = this.tmpVertices[this.numTmpVertices++];
  5664. _this6.x = v11.x + (v21.x - v11.x) * t2;
  5665. _this6.y = v11.y + (v21.y - v11.y) * t2;
  5666. _this6.wx = v11.wx + (v21.wx - v11.wx) * t2;
  5667. _this6.wy = v11.wy + (v21.wy - v11.wy) * t2;
  5668. _this6.wz = v11.wz + (v21.wz - v11.wz) * t2;
  5669. } else if(s11 <= 0 && s21 > 0) {
  5670. var t3 = s11 / (s11 - s21);
  5671. var _this7 = this.tmpVertices[this.numTmpVertices++];
  5672. _this7.x = v11.x + (v21.x - v11.x) * t3;
  5673. _this7.y = v11.y + (v21.y - v11.y) * t3;
  5674. _this7.wx = v11.wx + (v21.wx - v11.wx) * t3;
  5675. _this7.wy = v11.wy + (v21.wy - v11.wy) * t3;
  5676. _this7.wz = v11.wz + (v21.wz - v11.wz) * t3;
  5677. }
  5678. }
  5679. var tmp1 = this.vertices;
  5680. this.vertices = this.tmpVertices;
  5681. this.tmpVertices = tmp1;
  5682. this.numVertices = this.numTmpVertices;
  5683. this.numTmpVertices = 0;
  5684. var _g3 = 0;
  5685. var _g12 = this.numVertices;
  5686. while(_g3 < _g12) {
  5687. var i2 = _g3++;
  5688. var v12 = this.vertices[i2];
  5689. var v22 = this.vertices[(i2 + 1) % this.numVertices];
  5690. var s12 = this.h + v12.y;
  5691. var s22 = this.h + v22.y;
  5692. if(s12 > 0 && s22 > 0) {
  5693. var _this8 = this.tmpVertices[this.numTmpVertices++];
  5694. _this8.x = v12.x;
  5695. _this8.y = v12.y;
  5696. _this8.wx = v12.wx;
  5697. _this8.wy = v12.wy;
  5698. _this8.wz = v12.wz;
  5699. } else if(s12 > 0 && s22 <= 0) {
  5700. var _this9 = this.tmpVertices[this.numTmpVertices++];
  5701. _this9.x = v12.x;
  5702. _this9.y = v12.y;
  5703. _this9.wx = v12.wx;
  5704. _this9.wy = v12.wy;
  5705. _this9.wz = v12.wz;
  5706. var t4 = s12 / (s12 - s22);
  5707. var _this10 = this.tmpVertices[this.numTmpVertices++];
  5708. _this10.x = v12.x + (v22.x - v12.x) * t4;
  5709. _this10.y = v12.y + (v22.y - v12.y) * t4;
  5710. _this10.wx = v12.wx + (v22.wx - v12.wx) * t4;
  5711. _this10.wy = v12.wy + (v22.wy - v12.wy) * t4;
  5712. _this10.wz = v12.wz + (v22.wz - v12.wz) * t4;
  5713. } else if(s12 <= 0 && s22 > 0) {
  5714. var t5 = s12 / (s12 - s22);
  5715. var _this11 = this.tmpVertices[this.numTmpVertices++];
  5716. _this11.x = v12.x + (v22.x - v12.x) * t5;
  5717. _this11.y = v12.y + (v22.y - v12.y) * t5;
  5718. _this11.wx = v12.wx + (v22.wx - v12.wx) * t5;
  5719. _this11.wy = v12.wy + (v22.wy - v12.wy) * t5;
  5720. _this11.wz = v12.wz + (v22.wz - v12.wz) * t5;
  5721. }
  5722. }
  5723. var tmp2 = this.vertices;
  5724. this.vertices = this.tmpVertices;
  5725. this.tmpVertices = tmp2;
  5726. this.numVertices = this.numTmpVertices;
  5727. this.numTmpVertices = 0;
  5728. var _g4 = 0;
  5729. var _g13 = this.numVertices;
  5730. while(_g4 < _g13) {
  5731. var i3 = _g4++;
  5732. var v13 = this.vertices[i3];
  5733. var v23 = this.vertices[(i3 + 1) % this.numVertices];
  5734. var s13 = this.h - v13.y;
  5735. var s23 = this.h - v23.y;
  5736. if(s13 > 0 && s23 > 0) {
  5737. var _this12 = this.tmpVertices[this.numTmpVertices++];
  5738. _this12.x = v13.x;
  5739. _this12.y = v13.y;
  5740. _this12.wx = v13.wx;
  5741. _this12.wy = v13.wy;
  5742. _this12.wz = v13.wz;
  5743. } else if(s13 > 0 && s23 <= 0) {
  5744. var _this13 = this.tmpVertices[this.numTmpVertices++];
  5745. _this13.x = v13.x;
  5746. _this13.y = v13.y;
  5747. _this13.wx = v13.wx;
  5748. _this13.wy = v13.wy;
  5749. _this13.wz = v13.wz;
  5750. var t6 = s13 / (s13 - s23);
  5751. var _this14 = this.tmpVertices[this.numTmpVertices++];
  5752. _this14.x = v13.x + (v23.x - v13.x) * t6;
  5753. _this14.y = v13.y + (v23.y - v13.y) * t6;
  5754. _this14.wx = v13.wx + (v23.wx - v13.wx) * t6;
  5755. _this14.wy = v13.wy + (v23.wy - v13.wy) * t6;
  5756. _this14.wz = v13.wz + (v23.wz - v13.wz) * t6;
  5757. } else if(s13 <= 0 && s23 > 0) {
  5758. var t7 = s13 / (s13 - s23);
  5759. var _this15 = this.tmpVertices[this.numTmpVertices++];
  5760. _this15.x = v13.x + (v23.x - v13.x) * t7;
  5761. _this15.y = v13.y + (v23.y - v13.y) * t7;
  5762. _this15.wx = v13.wx + (v23.wx - v13.wx) * t7;
  5763. _this15.wy = v13.wy + (v23.wy - v13.wy) * t7;
  5764. _this15.wz = v13.wz + (v23.wz - v13.wz) * t7;
  5765. }
  5766. }
  5767. var tmp3 = this.vertices;
  5768. this.vertices = this.tmpVertices;
  5769. this.tmpVertices = tmp3;
  5770. this.numVertices = this.numTmpVertices;
  5771. this.numTmpVertices = 0;
  5772. }
  5773. reduce() {
  5774. if(this.numVertices < 4) {
  5775. return;
  5776. }
  5777. var max1 = -1e65536;
  5778. var min1 = 1e65536;
  5779. var max2 = -1e65536;
  5780. var min2 = 1e65536;
  5781. var max1V = null;
  5782. var min1V = null;
  5783. var max2V = null;
  5784. var min2V = null;
  5785. var e1x = 1;
  5786. var e1y = 1;
  5787. var e2x = -1;
  5788. var e2y = 1;
  5789. var _g = 0;
  5790. var _g1 = this.numVertices;
  5791. while(_g < _g1) {
  5792. var i = _g++;
  5793. var v = this.vertices[i];
  5794. var dot1 = v.x * e1x + v.y * e1y;
  5795. var dot2 = v.x * e2x + v.y * e2y;
  5796. if(dot1 > max1) {
  5797. max1 = dot1;
  5798. max1V = v;
  5799. }
  5800. if(dot1 < min1) {
  5801. min1 = dot1;
  5802. min1V = v;
  5803. }
  5804. if(dot2 > max2) {
  5805. max2 = dot2;
  5806. max2V = v;
  5807. }
  5808. if(dot2 < min2) {
  5809. min2 = dot2;
  5810. min2V = v;
  5811. }
  5812. }
  5813. var _this = this.tmpVertices[this.numTmpVertices++];
  5814. _this.x = max1V.x;
  5815. _this.y = max1V.y;
  5816. _this.wx = max1V.wx;
  5817. _this.wy = max1V.wy;
  5818. _this.wz = max1V.wz;
  5819. var _this1 = this.tmpVertices[this.numTmpVertices++];
  5820. _this1.x = max2V.x;
  5821. _this1.y = max2V.y;
  5822. _this1.wx = max2V.wx;
  5823. _this1.wy = max2V.wy;
  5824. _this1.wz = max2V.wz;
  5825. var _this2 = this.tmpVertices[this.numTmpVertices++];
  5826. _this2.x = min1V.x;
  5827. _this2.y = min1V.y;
  5828. _this2.wx = min1V.wx;
  5829. _this2.wy = min1V.wy;
  5830. _this2.wz = min1V.wz;
  5831. var _this3 = this.tmpVertices[this.numTmpVertices++];
  5832. _this3.x = min2V.x;
  5833. _this3.y = min2V.y;
  5834. _this3.wx = min2V.wx;
  5835. _this3.wy = min2V.wy;
  5836. _this3.wz = min2V.wz;
  5837. var tmp = this.vertices;
  5838. this.vertices = this.tmpVertices;
  5839. this.tmpVertices = tmp;
  5840. this.numVertices = this.numTmpVertices;
  5841. this.numTmpVertices = 0;
  5842. }
  5843. }
  5844. oimo.collision.narrowphase.detector.BoxBoxDetectorMacro = class oimo_collision_narrowphase_detector_BoxBoxDetectorMacro {
  5845. }
  5846. oimo.collision.narrowphase.detector.CachedDetectorData = class oimo_collision_narrowphase_detector_CachedDetectorData {
  5847. constructor() {
  5848. }
  5849. _clear() {
  5850. if(this._gjkCache != null) {
  5851. this._gjkCache.clear();
  5852. }
  5853. }
  5854. }
  5855. oimo.collision.narrowphase.detector.CapsuleCapsuleDetector = class oimo_collision_narrowphase_detector_CapsuleCapsuleDetector extends oimo.collision.narrowphase.detector.Detector {
  5856. constructor() {
  5857. super(false);
  5858. }
  5859. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  5860. var c1 = geom1;
  5861. var c2 = geom2;
  5862. result.incremental = false;
  5863. var axis1;
  5864. var axis1X;
  5865. var axis1Y;
  5866. var axis1Z;
  5867. var axis2;
  5868. var axis2X;
  5869. var axis2Y;
  5870. var axis2Z;
  5871. axis1X = tf1._rotation01;
  5872. axis1Y = tf1._rotation11;
  5873. axis1Z = tf1._rotation21;
  5874. axis2X = tf2._rotation01;
  5875. axis2Y = tf2._rotation11;
  5876. axis2Z = tf2._rotation21;
  5877. var hh1 = c1._halfHeight;
  5878. var hh2 = c2._halfHeight;
  5879. var r1 = c1._radius;
  5880. var r2 = c2._radius;
  5881. var p1;
  5882. var p1X;
  5883. var p1Y;
  5884. var p1Z;
  5885. var q1;
  5886. var q1X;
  5887. var q1Y;
  5888. var q1Z;
  5889. var p2;
  5890. var p2X;
  5891. var p2Y;
  5892. var p2Z;
  5893. var q2;
  5894. var q2X;
  5895. var q2Y;
  5896. var q2Z;
  5897. p1X = tf1._positionX + axis1X * -hh1;
  5898. p1Y = tf1._positionY + axis1Y * -hh1;
  5899. p1Z = tf1._positionZ + axis1Z * -hh1;
  5900. q1X = tf1._positionX + axis1X * hh1;
  5901. q1Y = tf1._positionY + axis1Y * hh1;
  5902. q1Z = tf1._positionZ + axis1Z * hh1;
  5903. p2X = tf2._positionX + axis2X * -hh2;
  5904. p2Y = tf2._positionY + axis2Y * -hh2;
  5905. p2Z = tf2._positionZ + axis2Z * -hh2;
  5906. q2X = tf2._positionX + axis2X * hh2;
  5907. q2Y = tf2._positionY + axis2Y * hh2;
  5908. q2Z = tf2._positionZ + axis2Z * hh2;
  5909. var p12;
  5910. var p12X;
  5911. var p12Y;
  5912. var p12Z;
  5913. p12X = p1X - p2X;
  5914. p12Y = p1Y - p2Y;
  5915. p12Z = p1Z - p2Z;
  5916. var d1;
  5917. var d1X;
  5918. var d1Y;
  5919. var d1Z;
  5920. var d2;
  5921. var d2X;
  5922. var d2Y;
  5923. var d2Z;
  5924. d1X = q1X - p1X;
  5925. d1Y = q1Y - p1Y;
  5926. d1Z = q1Z - p1Z;
  5927. d2X = q2X - p2X;
  5928. d2Y = q2Y - p2Y;
  5929. d2Z = q2Z - p2Z;
  5930. var p21d1 = -(p12X * d1X + p12Y * d1Y + p12Z * d1Z);
  5931. var p12d2 = p12X * d2X + p12Y * d2Y + p12Z * d2Z;
  5932. var d11 = hh1 * hh1 * 4;
  5933. var d12 = d1X * d2X + d1Y * d2Y + d1Z * d2Z;
  5934. var d22 = hh2 * hh2 * 4;
  5935. var t1;
  5936. var t2;
  5937. if(d11 == 0 && d22 == 0) {
  5938. t1 = 0;
  5939. t2 = 0;
  5940. } else if(d11 == 0) {
  5941. t1 = 0;
  5942. t2 = p12d2;
  5943. if(t2 < 0) {
  5944. t2 = 0;
  5945. } else if(t2 > d22) {
  5946. t2 = 1;
  5947. } else {
  5948. t2 /= d22;
  5949. }
  5950. } else if(d22 == 0) {
  5951. t2 = 0;
  5952. t1 = p21d1;
  5953. if(t1 < 0) {
  5954. t1 = 0;
  5955. } else if(t1 > d11) {
  5956. t1 = 1;
  5957. } else {
  5958. t1 /= d11;
  5959. }
  5960. } else {
  5961. var det = d11 * d22 - d12 * d12;
  5962. if(det == 0) {
  5963. t1 = 0;
  5964. } else {
  5965. t1 = d12 * p12d2 + d22 * p21d1;
  5966. if(t1 < 0) {
  5967. t1 = 0;
  5968. } else if(t1 > det) {
  5969. t1 = 1;
  5970. } else {
  5971. t1 /= det;
  5972. }
  5973. }
  5974. t2 = t1 * d12 + p12d2;
  5975. if(t2 < 0) {
  5976. t2 = 0;
  5977. t1 = p21d1;
  5978. if(t1 < 0) {
  5979. t1 = 0;
  5980. } else if(t1 > d11) {
  5981. t1 = 1;
  5982. } else {
  5983. t1 /= d11;
  5984. }
  5985. } else if(t2 > d22) {
  5986. t2 = 1;
  5987. t1 = d12 + p21d1;
  5988. if(t1 < 0) {
  5989. t1 = 0;
  5990. } else if(t1 > d11) {
  5991. t1 = 1;
  5992. } else {
  5993. t1 /= d11;
  5994. }
  5995. } else {
  5996. t2 /= d22;
  5997. }
  5998. }
  5999. var cp1;
  6000. var cp1X;
  6001. var cp1Y;
  6002. var cp1Z;
  6003. var cp2;
  6004. var cp2X;
  6005. var cp2Y;
  6006. var cp2Z;
  6007. cp1X = p1X + d1X * t1;
  6008. cp1Y = p1Y + d1Y * t1;
  6009. cp1Z = p1Z + d1Z * t1;
  6010. cp2X = p2X + d2X * t2;
  6011. cp2Y = p2Y + d2Y * t2;
  6012. cp2Z = p2Z + d2Z * t2;
  6013. var d;
  6014. var dX;
  6015. var dY;
  6016. var dZ;
  6017. dX = cp1X - cp2X;
  6018. dY = cp1Y - cp2Y;
  6019. dZ = cp1Z - cp2Z;
  6020. var len2 = dX * dX + dY * dY + dZ * dZ;
  6021. if(len2 >= (r1 + r2) * (r1 + r2)) {
  6022. return;
  6023. }
  6024. var len = Math.sqrt(len2);
  6025. var n;
  6026. var nX;
  6027. var nY;
  6028. var nZ;
  6029. if(len > 0) {
  6030. nX = dX * (1 / len);
  6031. nY = dY * (1 / len);
  6032. nZ = dZ * (1 / len);
  6033. } else {
  6034. nX = 1;
  6035. nY = 0;
  6036. nZ = 0;
  6037. }
  6038. this.setNormal(result,nX,nY,nZ);
  6039. var pos1;
  6040. var pos1X;
  6041. var pos1Y;
  6042. var pos1Z;
  6043. var pos2;
  6044. var pos2X;
  6045. var pos2Y;
  6046. var pos2Z;
  6047. pos1X = cp1X + nX * -r1;
  6048. pos1Y = cp1Y + nY * -r1;
  6049. pos1Z = cp1Z + nZ * -r1;
  6050. pos2X = cp2X + nX * r2;
  6051. pos2Y = cp2Y + nY * r2;
  6052. pos2Z = cp2Z + nZ * r2;
  6053. this.addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,r1 + r2 - len,0);
  6054. }
  6055. }
  6056. oimo.collision.narrowphase.detector.GjkEpaDetector = class oimo_collision_narrowphase_detector_GjkEpaDetector extends oimo.collision.narrowphase.detector.Detector {
  6057. constructor() {
  6058. super(false);
  6059. }
  6060. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  6061. var gjkEpa = oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance;
  6062. var g1 = geom1;
  6063. var g2 = geom2;
  6064. var status = gjkEpa.computeClosestPointsImpl(g1,g2,tf1,tf2,oimo.common.Setting.enableGJKCaching ? cachedData : null,true);
  6065. result.incremental = true;
  6066. if(status != oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.SUCCEEDED) {
  6067. console.log("src/oimo/collision/narrowphase/detector/GjkEpaDetector.hx:28:","GJK/EPA failed: status=" + status);
  6068. return;
  6069. }
  6070. var margin1 = g1._gjkMargin;
  6071. var margin2 = g2._gjkMargin;
  6072. if(gjkEpa.distance > margin1 + margin2) {
  6073. return;
  6074. }
  6075. var pos1;
  6076. var pos1X;
  6077. var pos1Y;
  6078. var pos1Z;
  6079. var pos2;
  6080. var pos2X;
  6081. var pos2Y;
  6082. var pos2Z;
  6083. var v = gjkEpa.closestPoint1;
  6084. pos1X = v.x;
  6085. pos1Y = v.y;
  6086. pos1Z = v.z;
  6087. var v1 = gjkEpa.closestPoint2;
  6088. pos2X = v1.x;
  6089. pos2Y = v1.y;
  6090. pos2Z = v1.z;
  6091. var normal;
  6092. var normalX;
  6093. var normalY;
  6094. var normalZ;
  6095. normalX = pos1X - pos2X;
  6096. normalY = pos1Y - pos2Y;
  6097. normalZ = pos1Z - pos2Z;
  6098. if(normalX * normalX + normalY * normalY + normalZ * normalZ == 0) {
  6099. return;
  6100. }
  6101. if(gjkEpa.distance < 0) {
  6102. normalX = -normalX;
  6103. normalY = -normalY;
  6104. normalZ = -normalZ;
  6105. }
  6106. var l = normalX * normalX + normalY * normalY + normalZ * normalZ;
  6107. if(l > 0) {
  6108. l = 1 / Math.sqrt(l);
  6109. }
  6110. normalX *= l;
  6111. normalY *= l;
  6112. normalZ *= l;
  6113. this.setNormal(result,normalX,normalY,normalZ);
  6114. pos1X += normalX * -g1._gjkMargin;
  6115. pos1Y += normalY * -g1._gjkMargin;
  6116. pos1Z += normalZ * -g1._gjkMargin;
  6117. pos2X += normalX * g2._gjkMargin;
  6118. pos2Y += normalY * g2._gjkMargin;
  6119. pos2Z += normalZ * g2._gjkMargin;
  6120. this.addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,g1._gjkMargin + g2._gjkMargin - gjkEpa.distance,0);
  6121. }
  6122. }
  6123. oimo.collision.narrowphase.detector.SphereBoxDetector = class oimo_collision_narrowphase_detector_SphereBoxDetector extends oimo.collision.narrowphase.detector.Detector {
  6124. constructor(swapped) {
  6125. super(swapped);
  6126. }
  6127. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  6128. var s = geom1;
  6129. var b = geom2;
  6130. result.incremental = false;
  6131. var halfExt;
  6132. var halfExtX;
  6133. var halfExtY;
  6134. var halfExtZ;
  6135. var negHalfExt;
  6136. var negHalfExtX;
  6137. var negHalfExtY;
  6138. var negHalfExtZ;
  6139. halfExtX = b._halfExtentsX;
  6140. halfExtY = b._halfExtentsY;
  6141. halfExtZ = b._halfExtentsZ;
  6142. negHalfExtX = -halfExtX;
  6143. negHalfExtY = -halfExtY;
  6144. negHalfExtZ = -halfExtZ;
  6145. var r = s._radius;
  6146. var boxToSphere;
  6147. var boxToSphereX;
  6148. var boxToSphereY;
  6149. var boxToSphereZ;
  6150. boxToSphereX = tf1._positionX - tf2._positionX;
  6151. boxToSphereY = tf1._positionY - tf2._positionY;
  6152. boxToSphereZ = tf1._positionZ - tf2._positionZ;
  6153. var boxToSphereInBox;
  6154. var boxToSphereInBoxX;
  6155. var boxToSphereInBoxY;
  6156. var boxToSphereInBoxZ;
  6157. var __tmp__X;
  6158. var __tmp__Y;
  6159. var __tmp__Z;
  6160. __tmp__X = tf2._rotation00 * boxToSphereX + tf2._rotation10 * boxToSphereY + tf2._rotation20 * boxToSphereZ;
  6161. __tmp__Y = tf2._rotation01 * boxToSphereX + tf2._rotation11 * boxToSphereY + tf2._rotation21 * boxToSphereZ;
  6162. __tmp__Z = tf2._rotation02 * boxToSphereX + tf2._rotation12 * boxToSphereY + tf2._rotation22 * boxToSphereZ;
  6163. boxToSphereInBoxX = __tmp__X;
  6164. boxToSphereInBoxY = __tmp__Y;
  6165. boxToSphereInBoxZ = __tmp__Z;
  6166. var insideBox = negHalfExtX < boxToSphereInBoxX && halfExtX > boxToSphereInBoxX && negHalfExtY < boxToSphereInBoxY && halfExtY > boxToSphereInBoxY && negHalfExtZ < boxToSphereInBoxZ && halfExtZ > boxToSphereInBoxZ;
  6167. if(insideBox) {
  6168. var sphereToBoxSurface;
  6169. var sphereToBoxSurfaceX;
  6170. var sphereToBoxSurfaceY;
  6171. var sphereToBoxSurfaceZ;
  6172. sphereToBoxSurfaceX = boxToSphereInBoxX < 0 ? -boxToSphereInBoxX : boxToSphereInBoxX;
  6173. sphereToBoxSurfaceY = boxToSphereInBoxY < 0 ? -boxToSphereInBoxY : boxToSphereInBoxY;
  6174. sphereToBoxSurfaceZ = boxToSphereInBoxZ < 0 ? -boxToSphereInBoxZ : boxToSphereInBoxZ;
  6175. sphereToBoxSurfaceX = halfExtX - sphereToBoxSurfaceX;
  6176. sphereToBoxSurfaceY = halfExtY - sphereToBoxSurfaceY;
  6177. sphereToBoxSurfaceZ = halfExtZ - sphereToBoxSurfaceZ;
  6178. var normalInBox;
  6179. var normalInBoxX;
  6180. var normalInBoxY;
  6181. var normalInBoxZ;
  6182. var distX = sphereToBoxSurfaceX;
  6183. var distY = sphereToBoxSurfaceY;
  6184. var distZ = sphereToBoxSurfaceZ;
  6185. var depth;
  6186. var projectionMask;
  6187. var projectionMaskX;
  6188. var projectionMaskY;
  6189. var projectionMaskZ;
  6190. if(distX < distY) {
  6191. if(distX < distZ) {
  6192. if(boxToSphereInBoxX > 0) {
  6193. normalInBoxX = 1;
  6194. normalInBoxY = 0;
  6195. normalInBoxZ = 0;
  6196. } else {
  6197. normalInBoxX = -1;
  6198. normalInBoxY = 0;
  6199. normalInBoxZ = 0;
  6200. }
  6201. projectionMaskX = 0;
  6202. projectionMaskY = 1;
  6203. projectionMaskZ = 1;
  6204. depth = distX;
  6205. } else {
  6206. if(boxToSphereInBoxZ > 0) {
  6207. normalInBoxX = 0;
  6208. normalInBoxY = 0;
  6209. normalInBoxZ = 1;
  6210. } else {
  6211. normalInBoxX = 0;
  6212. normalInBoxY = 0;
  6213. normalInBoxZ = -1;
  6214. }
  6215. projectionMaskX = 1;
  6216. projectionMaskY = 1;
  6217. projectionMaskZ = 0;
  6218. depth = distZ;
  6219. }
  6220. } else if(distY < distZ) {
  6221. if(boxToSphereInBoxY > 0) {
  6222. normalInBoxX = 0;
  6223. normalInBoxY = 1;
  6224. normalInBoxZ = 0;
  6225. } else {
  6226. normalInBoxX = 0;
  6227. normalInBoxY = -1;
  6228. normalInBoxZ = 0;
  6229. }
  6230. projectionMaskX = 1;
  6231. projectionMaskY = 0;
  6232. projectionMaskZ = 1;
  6233. depth = distY;
  6234. } else {
  6235. if(boxToSphereInBoxZ > 0) {
  6236. normalInBoxX = 0;
  6237. normalInBoxY = 0;
  6238. normalInBoxZ = 1;
  6239. } else {
  6240. normalInBoxX = 0;
  6241. normalInBoxY = 0;
  6242. normalInBoxZ = -1;
  6243. }
  6244. projectionMaskX = 1;
  6245. projectionMaskY = 1;
  6246. projectionMaskZ = 0;
  6247. depth = distZ;
  6248. }
  6249. var base;
  6250. var baseX;
  6251. var baseY;
  6252. var baseZ;
  6253. baseX = projectionMaskX * boxToSphereInBoxX;
  6254. baseY = projectionMaskY * boxToSphereInBoxY;
  6255. baseZ = projectionMaskZ * boxToSphereInBoxZ;
  6256. var boxToClosestPointInBox;
  6257. var boxToClosestPointInBoxX;
  6258. var boxToClosestPointInBoxY;
  6259. var boxToClosestPointInBoxZ;
  6260. boxToClosestPointInBoxX = normalInBoxX * halfExtX;
  6261. boxToClosestPointInBoxY = normalInBoxY * halfExtY;
  6262. boxToClosestPointInBoxZ = normalInBoxZ * halfExtZ;
  6263. boxToClosestPointInBoxX += baseX;
  6264. boxToClosestPointInBoxY += baseY;
  6265. boxToClosestPointInBoxZ += baseZ;
  6266. var boxToClosestPoint;
  6267. var boxToClosestPointX;
  6268. var boxToClosestPointY;
  6269. var boxToClosestPointZ;
  6270. var normal;
  6271. var normalX;
  6272. var normalY;
  6273. var normalZ;
  6274. var __tmp__X1;
  6275. var __tmp__Y1;
  6276. var __tmp__Z1;
  6277. __tmp__X1 = tf2._rotation00 * boxToClosestPointInBoxX + tf2._rotation01 * boxToClosestPointInBoxY + tf2._rotation02 * boxToClosestPointInBoxZ;
  6278. __tmp__Y1 = tf2._rotation10 * boxToClosestPointInBoxX + tf2._rotation11 * boxToClosestPointInBoxY + tf2._rotation12 * boxToClosestPointInBoxZ;
  6279. __tmp__Z1 = tf2._rotation20 * boxToClosestPointInBoxX + tf2._rotation21 * boxToClosestPointInBoxY + tf2._rotation22 * boxToClosestPointInBoxZ;
  6280. boxToClosestPointX = __tmp__X1;
  6281. boxToClosestPointY = __tmp__Y1;
  6282. boxToClosestPointZ = __tmp__Z1;
  6283. var __tmp__X2;
  6284. var __tmp__Y2;
  6285. var __tmp__Z2;
  6286. __tmp__X2 = tf2._rotation00 * normalInBoxX + tf2._rotation01 * normalInBoxY + tf2._rotation02 * normalInBoxZ;
  6287. __tmp__Y2 = tf2._rotation10 * normalInBoxX + tf2._rotation11 * normalInBoxY + tf2._rotation12 * normalInBoxZ;
  6288. __tmp__Z2 = tf2._rotation20 * normalInBoxX + tf2._rotation21 * normalInBoxY + tf2._rotation22 * normalInBoxZ;
  6289. normalX = __tmp__X2;
  6290. normalY = __tmp__Y2;
  6291. normalZ = __tmp__Z2;
  6292. this.setNormal(result,normalX,normalY,normalZ);
  6293. var pos1;
  6294. var pos1X;
  6295. var pos1Y;
  6296. var pos1Z;
  6297. var pos2;
  6298. var pos2X;
  6299. var pos2Y;
  6300. var pos2Z;
  6301. pos1X = tf1._positionX + normalX * -r;
  6302. pos1Y = tf1._positionY + normalY * -r;
  6303. pos1Z = tf1._positionZ + normalZ * -r;
  6304. pos2X = tf2._positionX + boxToClosestPointX;
  6305. pos2Y = tf2._positionY + boxToClosestPointY;
  6306. pos2Z = tf2._positionZ + boxToClosestPointZ;
  6307. this.addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,depth,0);
  6308. return;
  6309. }
  6310. var boxToClosestPointInBox1;
  6311. var boxToClosestPointInBoxX1;
  6312. var boxToClosestPointInBoxY1;
  6313. var boxToClosestPointInBoxZ1;
  6314. var eps = 1e-9;
  6315. var epsVec;
  6316. var epsVecX;
  6317. var epsVecY;
  6318. var epsVecZ;
  6319. epsVecX = eps;
  6320. epsVecY = eps;
  6321. epsVecZ = eps;
  6322. halfExtX -= epsVecX;
  6323. halfExtY -= epsVecY;
  6324. halfExtZ -= epsVecZ;
  6325. negHalfExtX += epsVecX;
  6326. negHalfExtY += epsVecY;
  6327. negHalfExtZ += epsVecZ;
  6328. boxToClosestPointInBoxX1 = boxToSphereInBoxX < halfExtX ? boxToSphereInBoxX : halfExtX;
  6329. boxToClosestPointInBoxY1 = boxToSphereInBoxY < halfExtY ? boxToSphereInBoxY : halfExtY;
  6330. boxToClosestPointInBoxZ1 = boxToSphereInBoxZ < halfExtZ ? boxToSphereInBoxZ : halfExtZ;
  6331. boxToClosestPointInBoxX1 = boxToClosestPointInBoxX1 > negHalfExtX ? boxToClosestPointInBoxX1 : negHalfExtX;
  6332. boxToClosestPointInBoxY1 = boxToClosestPointInBoxY1 > negHalfExtY ? boxToClosestPointInBoxY1 : negHalfExtY;
  6333. boxToClosestPointInBoxZ1 = boxToClosestPointInBoxZ1 > negHalfExtZ ? boxToClosestPointInBoxZ1 : negHalfExtZ;
  6334. var closestPointToSphereInBox;
  6335. var closestPointToSphereInBoxX;
  6336. var closestPointToSphereInBoxY;
  6337. var closestPointToSphereInBoxZ;
  6338. closestPointToSphereInBoxX = boxToSphereInBoxX - boxToClosestPointInBoxX1;
  6339. closestPointToSphereInBoxY = boxToSphereInBoxY - boxToClosestPointInBoxY1;
  6340. closestPointToSphereInBoxZ = boxToSphereInBoxZ - boxToClosestPointInBoxZ1;
  6341. var dist = closestPointToSphereInBoxX * closestPointToSphereInBoxX + closestPointToSphereInBoxY * closestPointToSphereInBoxY + closestPointToSphereInBoxZ * closestPointToSphereInBoxZ;
  6342. if(dist >= r * r) {
  6343. return;
  6344. }
  6345. dist = Math.sqrt(dist);
  6346. var boxToClosestPoint1;
  6347. var boxToClosestPointX1;
  6348. var boxToClosestPointY1;
  6349. var boxToClosestPointZ1;
  6350. var closestPointToSphere;
  6351. var closestPointToSphereX;
  6352. var closestPointToSphereY;
  6353. var closestPointToSphereZ;
  6354. var __tmp__X3;
  6355. var __tmp__Y3;
  6356. var __tmp__Z3;
  6357. __tmp__X3 = tf2._rotation00 * boxToClosestPointInBoxX1 + tf2._rotation01 * boxToClosestPointInBoxY1 + tf2._rotation02 * boxToClosestPointInBoxZ1;
  6358. __tmp__Y3 = tf2._rotation10 * boxToClosestPointInBoxX1 + tf2._rotation11 * boxToClosestPointInBoxY1 + tf2._rotation12 * boxToClosestPointInBoxZ1;
  6359. __tmp__Z3 = tf2._rotation20 * boxToClosestPointInBoxX1 + tf2._rotation21 * boxToClosestPointInBoxY1 + tf2._rotation22 * boxToClosestPointInBoxZ1;
  6360. boxToClosestPointX1 = __tmp__X3;
  6361. boxToClosestPointY1 = __tmp__Y3;
  6362. boxToClosestPointZ1 = __tmp__Z3;
  6363. var __tmp__X4;
  6364. var __tmp__Y4;
  6365. var __tmp__Z4;
  6366. __tmp__X4 = tf2._rotation00 * closestPointToSphereInBoxX + tf2._rotation01 * closestPointToSphereInBoxY + tf2._rotation02 * closestPointToSphereInBoxZ;
  6367. __tmp__Y4 = tf2._rotation10 * closestPointToSphereInBoxX + tf2._rotation11 * closestPointToSphereInBoxY + tf2._rotation12 * closestPointToSphereInBoxZ;
  6368. __tmp__Z4 = tf2._rotation20 * closestPointToSphereInBoxX + tf2._rotation21 * closestPointToSphereInBoxY + tf2._rotation22 * closestPointToSphereInBoxZ;
  6369. closestPointToSphereX = __tmp__X4;
  6370. closestPointToSphereY = __tmp__Y4;
  6371. closestPointToSphereZ = __tmp__Z4;
  6372. var normal1;
  6373. var normalX1;
  6374. var normalY1;
  6375. var normalZ1;
  6376. var l = closestPointToSphereX * closestPointToSphereX + closestPointToSphereY * closestPointToSphereY + closestPointToSphereZ * closestPointToSphereZ;
  6377. if(l > 0) {
  6378. l = 1 / Math.sqrt(l);
  6379. }
  6380. normalX1 = closestPointToSphereX * l;
  6381. normalY1 = closestPointToSphereY * l;
  6382. normalZ1 = closestPointToSphereZ * l;
  6383. this.setNormal(result,normalX1,normalY1,normalZ1);
  6384. var pos11;
  6385. var pos1X1;
  6386. var pos1Y1;
  6387. var pos1Z1;
  6388. var pos21;
  6389. var pos2X1;
  6390. var pos2Y1;
  6391. var pos2Z1;
  6392. pos1X1 = tf1._positionX + normalX1 * -r;
  6393. pos1Y1 = tf1._positionY + normalY1 * -r;
  6394. pos1Z1 = tf1._positionZ + normalZ1 * -r;
  6395. pos2X1 = tf2._positionX + boxToClosestPointX1;
  6396. pos2Y1 = tf2._positionY + boxToClosestPointY1;
  6397. pos2Z1 = tf2._positionZ + boxToClosestPointZ1;
  6398. this.addPoint(result,pos1X1,pos1Y1,pos1Z1,pos2X1,pos2Y1,pos2Z1,r - dist,0);
  6399. }
  6400. }
  6401. oimo.collision.narrowphase.detector.SphereCapsuleDetector = class oimo_collision_narrowphase_detector_SphereCapsuleDetector extends oimo.collision.narrowphase.detector.Detector {
  6402. constructor(swapped) {
  6403. super(swapped);
  6404. }
  6405. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  6406. var s1 = geom1;
  6407. var c2 = geom2;
  6408. result.incremental = false;
  6409. var hh2 = c2._halfHeight;
  6410. var r1 = s1._radius;
  6411. var r2 = c2._radius;
  6412. var axis2;
  6413. var axis2X;
  6414. var axis2Y;
  6415. var axis2Z;
  6416. axis2X = tf2._rotation01;
  6417. axis2Y = tf2._rotation11;
  6418. axis2Z = tf2._rotation21;
  6419. var cp1;
  6420. var cp1X;
  6421. var cp1Y;
  6422. var cp1Z;
  6423. cp1X = tf1._positionX;
  6424. cp1Y = tf1._positionY;
  6425. cp1Z = tf1._positionZ;
  6426. var p2;
  6427. var p2X;
  6428. var p2Y;
  6429. var p2Z;
  6430. var q2;
  6431. var q2X;
  6432. var q2Y;
  6433. var q2Z;
  6434. p2X = tf2._positionX + axis2X * -hh2;
  6435. p2Y = tf2._positionY + axis2Y * -hh2;
  6436. p2Z = tf2._positionZ + axis2Z * -hh2;
  6437. q2X = tf2._positionX + axis2X * hh2;
  6438. q2Y = tf2._positionY + axis2Y * hh2;
  6439. q2Z = tf2._positionZ + axis2Z * hh2;
  6440. var p12;
  6441. var p12X;
  6442. var p12Y;
  6443. var p12Z;
  6444. p12X = cp1X - p2X;
  6445. p12Y = cp1Y - p2Y;
  6446. p12Z = cp1Z - p2Z;
  6447. var d2;
  6448. var d2X;
  6449. var d2Y;
  6450. var d2Z;
  6451. d2X = q2X - p2X;
  6452. d2Y = q2Y - p2Y;
  6453. d2Z = q2Z - p2Z;
  6454. var d22 = hh2 * hh2 * 4;
  6455. var t = p12X * d2X + p12Y * d2Y + p12Z * d2Z;
  6456. if(t < 0) {
  6457. t = 0;
  6458. } else if(t > d22) {
  6459. t = 1;
  6460. } else {
  6461. t /= d22;
  6462. }
  6463. var cp2;
  6464. var cp2X;
  6465. var cp2Y;
  6466. var cp2Z;
  6467. cp2X = p2X + d2X * t;
  6468. cp2Y = p2Y + d2Y * t;
  6469. cp2Z = p2Z + d2Z * t;
  6470. var d;
  6471. var dX;
  6472. var dY;
  6473. var dZ;
  6474. dX = cp1X - cp2X;
  6475. dY = cp1Y - cp2Y;
  6476. dZ = cp1Z - cp2Z;
  6477. var len2 = dX * dX + dY * dY + dZ * dZ;
  6478. if(len2 >= (r1 + r2) * (r1 + r2)) {
  6479. return;
  6480. }
  6481. var len = Math.sqrt(len2);
  6482. var n;
  6483. var nX;
  6484. var nY;
  6485. var nZ;
  6486. if(len > 0) {
  6487. nX = dX * (1 / len);
  6488. nY = dY * (1 / len);
  6489. nZ = dZ * (1 / len);
  6490. } else {
  6491. nX = 1;
  6492. nY = 0;
  6493. nZ = 0;
  6494. }
  6495. this.setNormal(result,nX,nY,nZ);
  6496. var pos1;
  6497. var pos1X;
  6498. var pos1Y;
  6499. var pos1Z;
  6500. var pos2;
  6501. var pos2X;
  6502. var pos2Y;
  6503. var pos2Z;
  6504. pos1X = cp1X + nX * -r1;
  6505. pos1Y = cp1Y + nY * -r1;
  6506. pos1Z = cp1Z + nZ * -r1;
  6507. pos2X = cp2X + nX * r2;
  6508. pos2Y = cp2Y + nY * r2;
  6509. pos2Z = cp2Z + nZ * r2;
  6510. this.addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,r1 + r2 - len,0);
  6511. }
  6512. }
  6513. oimo.collision.narrowphase.detector.SphereSphereDetector = class oimo_collision_narrowphase_detector_SphereSphereDetector extends oimo.collision.narrowphase.detector.Detector {
  6514. constructor() {
  6515. super(false);
  6516. }
  6517. detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
  6518. var s1 = geom1;
  6519. var s2 = geom2;
  6520. result.incremental = false;
  6521. var d;
  6522. var dX;
  6523. var dY;
  6524. var dZ;
  6525. dX = tf1._positionX - tf2._positionX;
  6526. dY = tf1._positionY - tf2._positionY;
  6527. dZ = tf1._positionZ - tf2._positionZ;
  6528. var r1 = s1._radius;
  6529. var r2 = s2._radius;
  6530. var len2 = dX * dX + dY * dY + dZ * dZ;
  6531. if(len2 >= (r1 + r2) * (r1 + r2)) {
  6532. return;
  6533. }
  6534. var len = Math.sqrt(len2);
  6535. var n;
  6536. var nX;
  6537. var nY;
  6538. var nZ;
  6539. if(len > 0) {
  6540. nX = dX * (1 / len);
  6541. nY = dY * (1 / len);
  6542. nZ = dZ * (1 / len);
  6543. } else {
  6544. nX = 1;
  6545. nY = 0;
  6546. nZ = 0;
  6547. }
  6548. this.setNormal(result,nX,nY,nZ);
  6549. var pos1;
  6550. var pos1X;
  6551. var pos1Y;
  6552. var pos1Z;
  6553. var pos2;
  6554. var pos2X;
  6555. var pos2Y;
  6556. var pos2Z;
  6557. pos1X = tf1._positionX + nX * -r1;
  6558. pos1Y = tf1._positionY + nY * -r1;
  6559. pos1Z = tf1._positionZ + nZ * -r1;
  6560. pos2X = tf2._positionX + nX * r2;
  6561. pos2Y = tf2._positionY + nY * r2;
  6562. pos2Z = tf2._positionZ + nZ * r2;
  6563. this.addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,r1 + r2 - len,0);
  6564. }
  6565. }
  6566. if(!oimo.collision.narrowphase.detector.gjkepa) oimo.collision.narrowphase.detector.gjkepa = {};
  6567. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedron = class oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedron {
  6568. constructor() {
  6569. var this1 = new Array(oimo.common.Setting.maxEPAVertices);
  6570. this._vertices = this1;
  6571. this._center = new oimo.common.Vec3();
  6572. this._numVertices = 0;
  6573. this._triangleList = null;
  6574. this._triangleListLast = null;
  6575. this._numTriangles = 0;
  6576. this._trianglePool = null;
  6577. this._vertexPool = null;
  6578. }
  6579. dumpHoleEdge(first) {
  6580. }
  6581. validate() {
  6582. var t = this._triangleList;
  6583. while(t != null) {
  6584. var n = t._next;
  6585. t._vertices[0]._tmpEdgeLoopOuterTriangle = null;
  6586. t._vertices[0]._tmpEdgeLoopNext = null;
  6587. if(t._adjacentPairIndex[0] == -1) {
  6588. this._status = 2;
  6589. return false;
  6590. }
  6591. if(t._adjacentTriangles[0] == null) {
  6592. this._status = 3;
  6593. return false;
  6594. }
  6595. t._vertices[1]._tmpEdgeLoopOuterTriangle = null;
  6596. t._vertices[1]._tmpEdgeLoopNext = null;
  6597. if(t._adjacentPairIndex[1] == -1) {
  6598. this._status = 2;
  6599. return false;
  6600. }
  6601. if(t._adjacentTriangles[1] == null) {
  6602. this._status = 3;
  6603. return false;
  6604. }
  6605. t._vertices[2]._tmpEdgeLoopOuterTriangle = null;
  6606. t._vertices[2]._tmpEdgeLoopNext = null;
  6607. if(t._adjacentPairIndex[2] == -1) {
  6608. this._status = 2;
  6609. return false;
  6610. }
  6611. if(t._adjacentTriangles[2] == null) {
  6612. this._status = 3;
  6613. return false;
  6614. }
  6615. t = n;
  6616. }
  6617. return true;
  6618. }
  6619. findEdgeLoop(id,base,from) {
  6620. if(base._tmpDfsId == id) {
  6621. return;
  6622. }
  6623. base._tmpDfsId = id;
  6624. var _this = base.tmp;
  6625. _this.x = from.x;
  6626. _this.y = from.y;
  6627. _this.z = from.z;
  6628. var _this1 = _this;
  6629. var v = base._vertices[0].v;
  6630. var tx = _this1.x - v.x;
  6631. var ty = _this1.y - v.y;
  6632. var tz = _this1.z - v.z;
  6633. _this1.x = tx;
  6634. _this1.y = ty;
  6635. _this1.z = tz;
  6636. var _this2 = base.tmp;
  6637. var v1 = base._normal;
  6638. base._tmpDfsVisible = _this2.x * v1.x + _this2.y * v1.y + _this2.z * v1.z > 0;
  6639. if(!base._tmpDfsVisible) {
  6640. this._status = 6;
  6641. return;
  6642. }
  6643. var _g = 0;
  6644. while(_g < 3) {
  6645. var i = _g++;
  6646. var t = base._adjacentTriangles[i];
  6647. if(t == null) {
  6648. continue;
  6649. }
  6650. var _this3 = t.tmp;
  6651. _this3.x = from.x;
  6652. _this3.y = from.y;
  6653. _this3.z = from.z;
  6654. var _this4 = _this3;
  6655. var v2 = t._vertices[0].v;
  6656. var tx1 = _this4.x - v2.x;
  6657. var ty1 = _this4.y - v2.y;
  6658. var tz1 = _this4.z - v2.z;
  6659. _this4.x = tx1;
  6660. _this4.y = ty1;
  6661. _this4.z = tz1;
  6662. var _this5 = t.tmp;
  6663. var v3 = t._normal;
  6664. t._tmpDfsVisible = _this5.x * v3.x + _this5.y * v3.y + _this5.z * v3.z > 0;
  6665. if(t._tmpDfsVisible) {
  6666. this.findEdgeLoop(id,t,from);
  6667. } else {
  6668. var i2 = base._nextIndex[i];
  6669. var v11 = base._vertices[i];
  6670. var v21 = base._vertices[i2];
  6671. v11._tmpEdgeLoopNext = v21;
  6672. v11._tmpEdgeLoopOuterTriangle = t;
  6673. }
  6674. }
  6675. var triangle = base._adjacentTriangles[0];
  6676. if(triangle != null) {
  6677. var pairIndex = base._adjacentPairIndex[0];
  6678. triangle._adjacentTriangles[pairIndex] = null;
  6679. triangle._adjacentPairIndex[pairIndex] = -1;
  6680. base._adjacentTriangles[0] = null;
  6681. base._adjacentPairIndex[0] = -1;
  6682. }
  6683. var triangle1 = base._adjacentTriangles[1];
  6684. if(triangle1 != null) {
  6685. var pairIndex1 = base._adjacentPairIndex[1];
  6686. triangle1._adjacentTriangles[pairIndex1] = null;
  6687. triangle1._adjacentPairIndex[pairIndex1] = -1;
  6688. base._adjacentTriangles[1] = null;
  6689. base._adjacentPairIndex[1] = -1;
  6690. }
  6691. var triangle2 = base._adjacentTriangles[2];
  6692. if(triangle2 != null) {
  6693. var pairIndex2 = base._adjacentPairIndex[2];
  6694. triangle2._adjacentTriangles[pairIndex2] = null;
  6695. triangle2._adjacentPairIndex[pairIndex2] = -1;
  6696. base._adjacentTriangles[2] = null;
  6697. base._adjacentPairIndex[2] = -1;
  6698. }
  6699. this._numTriangles--;
  6700. var prev = base._prev;
  6701. var next = base._next;
  6702. if(prev != null) {
  6703. prev._next = next;
  6704. }
  6705. if(next != null) {
  6706. next._prev = prev;
  6707. }
  6708. if(base == this._triangleList) {
  6709. this._triangleList = this._triangleList._next;
  6710. }
  6711. if(base == this._triangleListLast) {
  6712. this._triangleListLast = this._triangleListLast._prev;
  6713. }
  6714. base._next = null;
  6715. base._prev = null;
  6716. base.removeReferences();
  6717. base._next = this._trianglePool;
  6718. this._trianglePool = base;
  6719. }
  6720. _init(v1,v2,v3,v4) {
  6721. this._status = 0;
  6722. this._numVertices = 4;
  6723. this._vertices[0] = v1;
  6724. this._vertices[1] = v2;
  6725. this._vertices[2] = v3;
  6726. this._vertices[3] = v4;
  6727. var _this = this._center;
  6728. var v = v1.v;
  6729. _this.x = v.x;
  6730. _this.y = v.y;
  6731. _this.z = v.z;
  6732. var _this1 = _this;
  6733. var v5 = v2.v;
  6734. var tx = _this1.x + v5.x;
  6735. var ty = _this1.y + v5.y;
  6736. var tz = _this1.z + v5.z;
  6737. _this1.x = tx;
  6738. _this1.y = ty;
  6739. _this1.z = tz;
  6740. var _this2 = _this1;
  6741. var v6 = v3.v;
  6742. var tx1 = _this2.x + v6.x;
  6743. var ty1 = _this2.y + v6.y;
  6744. var tz1 = _this2.z + v6.z;
  6745. _this2.x = tx1;
  6746. _this2.y = ty1;
  6747. _this2.z = tz1;
  6748. var _this3 = _this2;
  6749. var v7 = v4.v;
  6750. var tx2 = _this3.x + v7.x;
  6751. var ty2 = _this3.y + v7.y;
  6752. var tz2 = _this3.z + v7.z;
  6753. _this3.x = tx2;
  6754. _this3.y = ty2;
  6755. _this3.z = tz2;
  6756. var _this4 = _this3;
  6757. var tx3 = _this4.x * 0.25;
  6758. var ty3 = _this4.y * 0.25;
  6759. var tz3 = _this4.z * 0.25;
  6760. _this4.x = tx3;
  6761. _this4.y = ty3;
  6762. _this4.z = tz3;
  6763. var first = this._trianglePool;
  6764. if(first != null) {
  6765. this._trianglePool = first._next;
  6766. first._next = null;
  6767. } else {
  6768. first = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle();
  6769. }
  6770. var t1 = first;
  6771. var first1 = this._trianglePool;
  6772. if(first1 != null) {
  6773. this._trianglePool = first1._next;
  6774. first1._next = null;
  6775. } else {
  6776. first1 = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle();
  6777. }
  6778. var t2 = first1;
  6779. var first2 = this._trianglePool;
  6780. if(first2 != null) {
  6781. this._trianglePool = first2._next;
  6782. first2._next = null;
  6783. } else {
  6784. first2 = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle();
  6785. }
  6786. var t3 = first2;
  6787. var first3 = this._trianglePool;
  6788. if(first3 != null) {
  6789. this._trianglePool = first3._next;
  6790. first3._next = null;
  6791. } else {
  6792. first3 = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle();
  6793. }
  6794. var t4 = first3;
  6795. var autoCheck = true;
  6796. if(autoCheck == null) {
  6797. autoCheck = false;
  6798. }
  6799. if(!t1.init(v1,v2,v3,this._center,autoCheck)) {
  6800. this._status = 1;
  6801. }
  6802. var autoCheck1 = true;
  6803. if(autoCheck1 == null) {
  6804. autoCheck1 = false;
  6805. }
  6806. if(!t2.init(v1,v2,v4,this._center,autoCheck1)) {
  6807. this._status = 1;
  6808. }
  6809. var autoCheck2 = true;
  6810. if(autoCheck2 == null) {
  6811. autoCheck2 = false;
  6812. }
  6813. if(!t3.init(v1,v3,v4,this._center,autoCheck2)) {
  6814. this._status = 1;
  6815. }
  6816. var autoCheck3 = true;
  6817. if(autoCheck3 == null) {
  6818. autoCheck3 = false;
  6819. }
  6820. if(!t4.init(v2,v3,v4,this._center,autoCheck3)) {
  6821. this._status = 1;
  6822. }
  6823. if(!t1.setAdjacentTriangle(t2)) {
  6824. this._status = 1;
  6825. }
  6826. if(!t1.setAdjacentTriangle(t3)) {
  6827. this._status = 1;
  6828. }
  6829. if(!t1.setAdjacentTriangle(t4)) {
  6830. this._status = 1;
  6831. }
  6832. if(!t2.setAdjacentTriangle(t3)) {
  6833. this._status = 1;
  6834. }
  6835. if(!t2.setAdjacentTriangle(t4)) {
  6836. this._status = 1;
  6837. }
  6838. if(!t3.setAdjacentTriangle(t4)) {
  6839. this._status = 1;
  6840. }
  6841. this._numTriangles++;
  6842. if(this._triangleList == null) {
  6843. this._triangleList = t1;
  6844. this._triangleListLast = t1;
  6845. } else {
  6846. this._triangleListLast._next = t1;
  6847. t1._prev = this._triangleListLast;
  6848. this._triangleListLast = t1;
  6849. }
  6850. this._numTriangles++;
  6851. if(this._triangleList == null) {
  6852. this._triangleList = t2;
  6853. this._triangleListLast = t2;
  6854. } else {
  6855. this._triangleListLast._next = t2;
  6856. t2._prev = this._triangleListLast;
  6857. this._triangleListLast = t2;
  6858. }
  6859. this._numTriangles++;
  6860. if(this._triangleList == null) {
  6861. this._triangleList = t3;
  6862. this._triangleListLast = t3;
  6863. } else {
  6864. this._triangleListLast._next = t3;
  6865. t3._prev = this._triangleListLast;
  6866. this._triangleListLast = t3;
  6867. }
  6868. this._numTriangles++;
  6869. if(this._triangleList == null) {
  6870. this._triangleList = t4;
  6871. this._triangleListLast = t4;
  6872. } else {
  6873. this._triangleListLast._next = t4;
  6874. t4._prev = this._triangleListLast;
  6875. this._triangleListLast = t4;
  6876. }
  6877. return this._status == 0;
  6878. }
  6879. _addVertex(vertex,base) {
  6880. this._vertices[this._numVertices++] = vertex;
  6881. var v1 = base._vertices[0];
  6882. this.findEdgeLoop(this._numVertices,base,vertex.v);
  6883. if(this._status != 0) {
  6884. return false;
  6885. }
  6886. var v = v1;
  6887. var firstV = v1;
  6888. var prevT = null;
  6889. var firstT = null;
  6890. while(true) {
  6891. if(v._tmpEdgeLoopNext == null) {
  6892. this._dumpAsObjModel();
  6893. this._status = 4;
  6894. return false;
  6895. }
  6896. if(v._tmpEdgeLoopOuterTriangle == null) {
  6897. this._status = 5;
  6898. return false;
  6899. }
  6900. var first = this._trianglePool;
  6901. if(first != null) {
  6902. this._trianglePool = first._next;
  6903. first._next = null;
  6904. } else {
  6905. first = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle();
  6906. }
  6907. var t = first;
  6908. if(firstT == null) {
  6909. firstT = t;
  6910. }
  6911. if(!t.init(v,v._tmpEdgeLoopNext,vertex,this._center,false)) {
  6912. this._status = 1;
  6913. }
  6914. if(this._status != 0) {
  6915. return false;
  6916. }
  6917. this._numTriangles++;
  6918. if(this._triangleList == null) {
  6919. this._triangleList = t;
  6920. this._triangleListLast = t;
  6921. } else {
  6922. this._triangleListLast._next = t;
  6923. t._prev = this._triangleListLast;
  6924. this._triangleListLast = t;
  6925. }
  6926. if(!t.setAdjacentTriangle(v._tmpEdgeLoopOuterTriangle)) {
  6927. this._status = 1;
  6928. }
  6929. if(prevT != null) {
  6930. if(!t.setAdjacentTriangle(prevT)) {
  6931. this._status = 1;
  6932. }
  6933. }
  6934. prevT = t;
  6935. v = v._tmpEdgeLoopNext;
  6936. if(!(v != firstV)) {
  6937. break;
  6938. }
  6939. }
  6940. if(!prevT.setAdjacentTriangle(firstT)) {
  6941. this._status = 1;
  6942. }
  6943. if(this._status == 0) {
  6944. return this.validate();
  6945. } else {
  6946. return false;
  6947. }
  6948. }
  6949. _dumpAsObjModel() {
  6950. }
  6951. }
  6952. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState = class oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedronState {
  6953. }
  6954. oimo.collision.narrowphase.detector.gjkepa.EpaTriangle = class oimo_collision_narrowphase_detector_gjkepa_EpaTriangle {
  6955. constructor() {
  6956. this.id = ++oimo.collision.narrowphase.detector.gjkepa.EpaTriangle.count;
  6957. this._next = null;
  6958. this._prev = null;
  6959. this._normal = new oimo.common.Vec3();
  6960. this._distanceSq = 0;
  6961. this._tmpDfsId = 0;
  6962. this._tmpDfsVisible = false;
  6963. var this1 = new Array(3);
  6964. this._vertices = this1;
  6965. var this2 = new Array(3);
  6966. this._adjacentTriangles = this2;
  6967. var this3 = new Array(3);
  6968. this._adjacentPairIndex = this3;
  6969. this.tmp = new oimo.common.Vec3();
  6970. var this4 = new Array(3);
  6971. this._nextIndex = this4;
  6972. this._nextIndex[0] = 1;
  6973. this._nextIndex[1] = 2;
  6974. this._nextIndex[2] = 0;
  6975. }
  6976. init(vertex1,vertex2,vertex3,center,autoCheck) {
  6977. if(autoCheck == null) {
  6978. autoCheck = false;
  6979. }
  6980. var v1;
  6981. var v1X;
  6982. var v1Y;
  6983. var v1Z;
  6984. var v2;
  6985. var v2X;
  6986. var v2Y;
  6987. var v2Z;
  6988. var v3;
  6989. var v3X;
  6990. var v3Y;
  6991. var v3Z;
  6992. var vc;
  6993. var vcX;
  6994. var vcY;
  6995. var vcZ;
  6996. var v = vertex1.v;
  6997. v1X = v.x;
  6998. v1Y = v.y;
  6999. v1Z = v.z;
  7000. var v4 = vertex2.v;
  7001. v2X = v4.x;
  7002. v2Y = v4.y;
  7003. v2Z = v4.z;
  7004. var v5 = vertex3.v;
  7005. v3X = v5.x;
  7006. v3Y = v5.y;
  7007. v3Z = v5.z;
  7008. var v6 = center;
  7009. vcX = v6.x;
  7010. vcY = v6.y;
  7011. vcZ = v6.z;
  7012. var v12;
  7013. var v12X;
  7014. var v12Y;
  7015. var v12Z;
  7016. var v13;
  7017. var v13X;
  7018. var v13Y;
  7019. var v13Z;
  7020. var vc1;
  7021. var vc1X;
  7022. var vc1Y;
  7023. var vc1Z;
  7024. v12X = v2X - v1X;
  7025. v12Y = v2Y - v1Y;
  7026. v12Z = v2Z - v1Z;
  7027. v13X = v3X - v1X;
  7028. v13Y = v3Y - v1Y;
  7029. v13Z = v3Z - v1Z;
  7030. vc1X = v1X - vcX;
  7031. vc1Y = v1Y - vcY;
  7032. vc1Z = v1Z - vcZ;
  7033. var inor;
  7034. var inorX;
  7035. var inorY;
  7036. var inorZ;
  7037. inorX = v12Y * v13Z - v12Z * v13Y;
  7038. inorY = v12Z * v13X - v12X * v13Z;
  7039. inorZ = v12X * v13Y - v12Y * v13X;
  7040. var inverted = false;
  7041. var d = vc1X * inorX + vc1Y * inorY + vc1Z * inorZ;
  7042. if(d < 0) {
  7043. if(autoCheck) {
  7044. var tmp = vertex2;
  7045. vertex2 = vertex3;
  7046. vertex3 = tmp;
  7047. inorX *= -1;
  7048. inorY *= -1;
  7049. inorZ *= -1;
  7050. } else {
  7051. inverted = true;
  7052. }
  7053. }
  7054. this._vertices[0] = vertex1;
  7055. this._vertices[1] = vertex2;
  7056. this._vertices[2] = vertex3;
  7057. var v7 = this._normal;
  7058. v7.x = inorX;
  7059. v7.y = inorY;
  7060. v7.z = inorZ;
  7061. var vec1 = vertex1.v;
  7062. var vec2 = vertex2.v;
  7063. var vec3 = vertex3.v;
  7064. var out = this.tmp;
  7065. var v11;
  7066. var v1X1;
  7067. var v1Y1;
  7068. var v1Z1;
  7069. var v21;
  7070. var v2X1;
  7071. var v2Y1;
  7072. var v2Z1;
  7073. var v31;
  7074. var v3X1;
  7075. var v3Y1;
  7076. var v3Z1;
  7077. var v121;
  7078. var v12X1;
  7079. var v12Y1;
  7080. var v12Z1;
  7081. var v23;
  7082. var v23X;
  7083. var v23Y;
  7084. var v23Z;
  7085. var v311;
  7086. var v31X;
  7087. var v31Y;
  7088. var v31Z;
  7089. var v8 = vec1;
  7090. v1X1 = v8.x;
  7091. v1Y1 = v8.y;
  7092. v1Z1 = v8.z;
  7093. var v9 = vec2;
  7094. v2X1 = v9.x;
  7095. v2Y1 = v9.y;
  7096. v2Z1 = v9.z;
  7097. var v10 = vec3;
  7098. v3X1 = v10.x;
  7099. v3Y1 = v10.y;
  7100. v3Z1 = v10.z;
  7101. v12X1 = v2X1 - v1X1;
  7102. v12Y1 = v2Y1 - v1Y1;
  7103. v12Z1 = v2Z1 - v1Z1;
  7104. v23X = v3X1 - v2X1;
  7105. v23Y = v3Y1 - v2Y1;
  7106. v23Z = v3Z1 - v2Z1;
  7107. v31X = v1X1 - v3X1;
  7108. v31Y = v1Y1 - v3Y1;
  7109. v31Z = v1Z1 - v3Z1;
  7110. var n;
  7111. var nX;
  7112. var nY;
  7113. var nZ;
  7114. nX = v12Y1 * v23Z - v12Z1 * v23Y;
  7115. nY = v12Z1 * v23X - v12X1 * v23Z;
  7116. nZ = v12X1 * v23Y - v12Y1 * v23X;
  7117. var n12;
  7118. var n12X;
  7119. var n12Y;
  7120. var n12Z;
  7121. var n23;
  7122. var n23X;
  7123. var n23Y;
  7124. var n23Z;
  7125. var n31;
  7126. var n31X;
  7127. var n31Y;
  7128. var n31Z;
  7129. n12X = v12Y1 * nZ - v12Z1 * nY;
  7130. n12Y = v12Z1 * nX - v12X1 * nZ;
  7131. n12Z = v12X1 * nY - v12Y1 * nX;
  7132. n23X = v23Y * nZ - v23Z * nY;
  7133. n23Y = v23Z * nX - v23X * nZ;
  7134. n23Z = v23X * nY - v23Y * nX;
  7135. n31X = v31Y * nZ - v31Z * nY;
  7136. n31Y = v31Z * nX - v31X * nZ;
  7137. n31Z = v31X * nY - v31Y * nX;
  7138. var d12 = v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z;
  7139. var d23 = v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z;
  7140. var d31 = v3X1 * n31X + v3Y1 * n31Y + v3Z1 * n31Z;
  7141. var mind = -1;
  7142. var minv;
  7143. var minvX;
  7144. var minvY;
  7145. var minvZ;
  7146. var mini = 0;
  7147. minvX = 0;
  7148. minvY = 0;
  7149. minvZ = 0;
  7150. if(d12 < 0) {
  7151. var v14;
  7152. var v1X2;
  7153. var v1Y2;
  7154. var v1Z2;
  7155. var v22;
  7156. var v2X2;
  7157. var v2Y2;
  7158. var v2Z2;
  7159. var v15 = vec1;
  7160. v1X2 = v15.x;
  7161. v1Y2 = v15.y;
  7162. v1Z2 = v15.z;
  7163. var v16 = vec2;
  7164. v2X2 = v16.x;
  7165. v2Y2 = v16.y;
  7166. v2Z2 = v16.z;
  7167. var v122;
  7168. var v12X2;
  7169. var v12Y2;
  7170. var v12Z2;
  7171. v12X2 = v2X2 - v1X2;
  7172. v12Y2 = v2Y2 - v1Y2;
  7173. v12Z2 = v2Z2 - v1Z2;
  7174. var d1 = v12X2 * v12X2 + v12Y2 * v12Y2 + v12Z2 * v12Z2;
  7175. var t = v12X2 * v1X2 + v12Y2 * v1Y2 + v12Z2 * v1Z2;
  7176. t = -t / d1;
  7177. var b;
  7178. if(t < 0) {
  7179. var v17 = out;
  7180. v17.x = v1X2;
  7181. v17.y = v1Y2;
  7182. v17.z = v1Z2;
  7183. b = 1;
  7184. } else if(t > 1) {
  7185. var v18 = out;
  7186. v18.x = v2X2;
  7187. v18.y = v2Y2;
  7188. v18.z = v2Z2;
  7189. b = 2;
  7190. } else {
  7191. var p;
  7192. var pX;
  7193. var pY;
  7194. var pZ;
  7195. pX = v1X2 + v12X2 * t;
  7196. pY = v1Y2 + v12Y2 * t;
  7197. pZ = v1Z2 + v12Z2 * t;
  7198. var v19 = out;
  7199. v19.x = pX;
  7200. v19.y = pY;
  7201. v19.z = pZ;
  7202. b = 3;
  7203. }
  7204. var d2 = out.x * out.x + out.y * out.y + out.z * out.z;
  7205. mini = b;
  7206. mind = d2;
  7207. var v20 = out;
  7208. minvX = v20.x;
  7209. minvY = v20.y;
  7210. minvZ = v20.z;
  7211. }
  7212. if(d23 < 0) {
  7213. var v110;
  7214. var v1X3;
  7215. var v1Y3;
  7216. var v1Z3;
  7217. var v24;
  7218. var v2X3;
  7219. var v2Y3;
  7220. var v2Z3;
  7221. var v25 = vec2;
  7222. v1X3 = v25.x;
  7223. v1Y3 = v25.y;
  7224. v1Z3 = v25.z;
  7225. var v26 = vec3;
  7226. v2X3 = v26.x;
  7227. v2Y3 = v26.y;
  7228. v2Z3 = v26.z;
  7229. var v123;
  7230. var v12X3;
  7231. var v12Y3;
  7232. var v12Z3;
  7233. v12X3 = v2X3 - v1X3;
  7234. v12Y3 = v2Y3 - v1Y3;
  7235. v12Z3 = v2Z3 - v1Z3;
  7236. var d3 = v12X3 * v12X3 + v12Y3 * v12Y3 + v12Z3 * v12Z3;
  7237. var t1 = v12X3 * v1X3 + v12Y3 * v1Y3 + v12Z3 * v1Z3;
  7238. t1 = -t1 / d3;
  7239. var b1;
  7240. if(t1 < 0) {
  7241. var v27 = out;
  7242. v27.x = v1X3;
  7243. v27.y = v1Y3;
  7244. v27.z = v1Z3;
  7245. b1 = 1;
  7246. } else if(t1 > 1) {
  7247. var v28 = out;
  7248. v28.x = v2X3;
  7249. v28.y = v2Y3;
  7250. v28.z = v2Z3;
  7251. b1 = 2;
  7252. } else {
  7253. var p1;
  7254. var pX1;
  7255. var pY1;
  7256. var pZ1;
  7257. pX1 = v1X3 + v12X3 * t1;
  7258. pY1 = v1Y3 + v12Y3 * t1;
  7259. pZ1 = v1Z3 + v12Z3 * t1;
  7260. var v29 = out;
  7261. v29.x = pX1;
  7262. v29.y = pY1;
  7263. v29.z = pZ1;
  7264. b1 = 3;
  7265. }
  7266. var d4 = out.x * out.x + out.y * out.y + out.z * out.z;
  7267. if(mind < 0 || d4 < mind) {
  7268. mini = b1 << 1;
  7269. mind = d4;
  7270. var v30 = out;
  7271. minvX = v30.x;
  7272. minvY = v30.y;
  7273. minvZ = v30.z;
  7274. }
  7275. }
  7276. if(d31 < 0) {
  7277. var v111;
  7278. var v1X4;
  7279. var v1Y4;
  7280. var v1Z4;
  7281. var v210;
  7282. var v2X4;
  7283. var v2Y4;
  7284. var v2Z4;
  7285. var v32 = vec1;
  7286. v1X4 = v32.x;
  7287. v1Y4 = v32.y;
  7288. v1Z4 = v32.z;
  7289. var v33 = vec3;
  7290. v2X4 = v33.x;
  7291. v2Y4 = v33.y;
  7292. v2Z4 = v33.z;
  7293. var v124;
  7294. var v12X4;
  7295. var v12Y4;
  7296. var v12Z4;
  7297. v12X4 = v2X4 - v1X4;
  7298. v12Y4 = v2Y4 - v1Y4;
  7299. v12Z4 = v2Z4 - v1Z4;
  7300. var d5 = v12X4 * v12X4 + v12Y4 * v12Y4 + v12Z4 * v12Z4;
  7301. var t2 = v12X4 * v1X4 + v12Y4 * v1Y4 + v12Z4 * v1Z4;
  7302. t2 = -t2 / d5;
  7303. var b2;
  7304. if(t2 < 0) {
  7305. var v34 = out;
  7306. v34.x = v1X4;
  7307. v34.y = v1Y4;
  7308. v34.z = v1Z4;
  7309. b2 = 1;
  7310. } else if(t2 > 1) {
  7311. var v35 = out;
  7312. v35.x = v2X4;
  7313. v35.y = v2Y4;
  7314. v35.z = v2Z4;
  7315. b2 = 2;
  7316. } else {
  7317. var p2;
  7318. var pX2;
  7319. var pY2;
  7320. var pZ2;
  7321. pX2 = v1X4 + v12X4 * t2;
  7322. pY2 = v1Y4 + v12Y4 * t2;
  7323. pZ2 = v1Z4 + v12Z4 * t2;
  7324. var v36 = out;
  7325. v36.x = pX2;
  7326. v36.y = pY2;
  7327. v36.z = pZ2;
  7328. b2 = 3;
  7329. }
  7330. var d6 = out.x * out.x + out.y * out.y + out.z * out.z;
  7331. if(mind < 0 || d6 < mind) {
  7332. mini = b2 & 1 | (b2 & 2) << 1;
  7333. mind = d6;
  7334. var v37 = out;
  7335. minvX = v37.x;
  7336. minvY = v37.y;
  7337. minvZ = v37.z;
  7338. }
  7339. }
  7340. if(mind > 0) {
  7341. var v38 = out;
  7342. v38.x = minvX;
  7343. v38.y = minvY;
  7344. v38.z = minvZ;
  7345. } else {
  7346. var l = nX * nX + nY * nY + nZ * nZ;
  7347. if(l > 0) {
  7348. l = 1 / Math.sqrt(l);
  7349. }
  7350. nX *= l;
  7351. nY *= l;
  7352. nZ *= l;
  7353. var dn = v1X1 * nX + v1Y1 * nY + v1Z1 * nZ;
  7354. var l2 = nX * nX + nY * nY + nZ * nZ;
  7355. l2 = dn / l2;
  7356. minvX = nX * l2;
  7357. minvY = nY * l2;
  7358. minvZ = nZ * l2;
  7359. var v39 = out;
  7360. v39.x = minvX;
  7361. v39.y = minvY;
  7362. v39.z = minvZ;
  7363. }
  7364. var _this = this.tmp;
  7365. this._distanceSq = _this.x * _this.x + _this.y * _this.y + _this.z * _this.z;
  7366. this._adjacentTriangles[0] = null;
  7367. this._adjacentTriangles[1] = null;
  7368. this._adjacentTriangles[2] = null;
  7369. this._adjacentPairIndex[0] = -1;
  7370. this._adjacentPairIndex[1] = -1;
  7371. this._adjacentPairIndex[2] = -1;
  7372. return !inverted;
  7373. }
  7374. setAdjacentTriangle(triangle) {
  7375. var count = 0;
  7376. var i2 = this._nextIndex[0];
  7377. var j2 = this._nextIndex[0];
  7378. if(this._vertices[0] == triangle._vertices[j2] && this._vertices[i2] == triangle._vertices[0]) {
  7379. this._adjacentTriangles[0] = triangle;
  7380. this._adjacentPairIndex[0] = 0;
  7381. triangle._adjacentTriangles[0] = this;
  7382. triangle._adjacentPairIndex[0] = 0;
  7383. ++count;
  7384. }
  7385. var i21 = this._nextIndex[0];
  7386. var j21 = this._nextIndex[1];
  7387. if(this._vertices[0] == triangle._vertices[j21] && this._vertices[i21] == triangle._vertices[1]) {
  7388. this._adjacentTriangles[0] = triangle;
  7389. this._adjacentPairIndex[0] = 1;
  7390. triangle._adjacentTriangles[1] = this;
  7391. triangle._adjacentPairIndex[1] = 0;
  7392. ++count;
  7393. }
  7394. var i22 = this._nextIndex[0];
  7395. var j22 = this._nextIndex[2];
  7396. if(this._vertices[0] == triangle._vertices[j22] && this._vertices[i22] == triangle._vertices[2]) {
  7397. this._adjacentTriangles[0] = triangle;
  7398. this._adjacentPairIndex[0] = 2;
  7399. triangle._adjacentTriangles[2] = this;
  7400. triangle._adjacentPairIndex[2] = 0;
  7401. ++count;
  7402. }
  7403. var i23 = this._nextIndex[1];
  7404. var j23 = this._nextIndex[0];
  7405. if(this._vertices[1] == triangle._vertices[j23] && this._vertices[i23] == triangle._vertices[0]) {
  7406. this._adjacentTriangles[1] = triangle;
  7407. this._adjacentPairIndex[1] = 0;
  7408. triangle._adjacentTriangles[0] = this;
  7409. triangle._adjacentPairIndex[0] = 1;
  7410. ++count;
  7411. }
  7412. var i24 = this._nextIndex[1];
  7413. var j24 = this._nextIndex[1];
  7414. if(this._vertices[1] == triangle._vertices[j24] && this._vertices[i24] == triangle._vertices[1]) {
  7415. this._adjacentTriangles[1] = triangle;
  7416. this._adjacentPairIndex[1] = 1;
  7417. triangle._adjacentTriangles[1] = this;
  7418. triangle._adjacentPairIndex[1] = 1;
  7419. ++count;
  7420. }
  7421. var i25 = this._nextIndex[1];
  7422. var j25 = this._nextIndex[2];
  7423. if(this._vertices[1] == triangle._vertices[j25] && this._vertices[i25] == triangle._vertices[2]) {
  7424. this._adjacentTriangles[1] = triangle;
  7425. this._adjacentPairIndex[1] = 2;
  7426. triangle._adjacentTriangles[2] = this;
  7427. triangle._adjacentPairIndex[2] = 1;
  7428. ++count;
  7429. }
  7430. var i26 = this._nextIndex[2];
  7431. var j26 = this._nextIndex[0];
  7432. if(this._vertices[2] == triangle._vertices[j26] && this._vertices[i26] == triangle._vertices[0]) {
  7433. this._adjacentTriangles[2] = triangle;
  7434. this._adjacentPairIndex[2] = 0;
  7435. triangle._adjacentTriangles[0] = this;
  7436. triangle._adjacentPairIndex[0] = 2;
  7437. ++count;
  7438. }
  7439. var i27 = this._nextIndex[2];
  7440. var j27 = this._nextIndex[1];
  7441. if(this._vertices[2] == triangle._vertices[j27] && this._vertices[i27] == triangle._vertices[1]) {
  7442. this._adjacentTriangles[2] = triangle;
  7443. this._adjacentPairIndex[2] = 1;
  7444. triangle._adjacentTriangles[1] = this;
  7445. triangle._adjacentPairIndex[1] = 2;
  7446. ++count;
  7447. }
  7448. var i28 = this._nextIndex[2];
  7449. var j28 = this._nextIndex[2];
  7450. if(this._vertices[2] == triangle._vertices[j28] && this._vertices[i28] == triangle._vertices[2]) {
  7451. this._adjacentTriangles[2] = triangle;
  7452. this._adjacentPairIndex[2] = 2;
  7453. triangle._adjacentTriangles[2] = this;
  7454. triangle._adjacentPairIndex[2] = 2;
  7455. ++count;
  7456. }
  7457. if(count != 1) {
  7458. return false;
  7459. }
  7460. return true;
  7461. }
  7462. removeAdjacentTriangles() {
  7463. var triangle = this._adjacentTriangles[0];
  7464. if(triangle != null) {
  7465. var pairIndex = this._adjacentPairIndex[0];
  7466. triangle._adjacentTriangles[pairIndex] = null;
  7467. triangle._adjacentPairIndex[pairIndex] = -1;
  7468. this._adjacentTriangles[0] = null;
  7469. this._adjacentPairIndex[0] = -1;
  7470. }
  7471. var triangle1 = this._adjacentTriangles[1];
  7472. if(triangle1 != null) {
  7473. var pairIndex1 = this._adjacentPairIndex[1];
  7474. triangle1._adjacentTriangles[pairIndex1] = null;
  7475. triangle1._adjacentPairIndex[pairIndex1] = -1;
  7476. this._adjacentTriangles[1] = null;
  7477. this._adjacentPairIndex[1] = -1;
  7478. }
  7479. var triangle2 = this._adjacentTriangles[2];
  7480. if(triangle2 != null) {
  7481. var pairIndex2 = this._adjacentPairIndex[2];
  7482. triangle2._adjacentTriangles[pairIndex2] = null;
  7483. triangle2._adjacentPairIndex[pairIndex2] = -1;
  7484. this._adjacentTriangles[2] = null;
  7485. this._adjacentPairIndex[2] = -1;
  7486. }
  7487. }
  7488. removeReferences() {
  7489. this._next = null;
  7490. this._prev = null;
  7491. this._tmpDfsId = 0;
  7492. this._tmpDfsVisible = false;
  7493. this._distanceSq = 0;
  7494. this._vertices[0] = null;
  7495. this._vertices[1] = null;
  7496. this._vertices[2] = null;
  7497. this._adjacentTriangles[0] = null;
  7498. this._adjacentTriangles[1] = null;
  7499. this._adjacentTriangles[2] = null;
  7500. this._adjacentPairIndex[0] = 0;
  7501. this._adjacentPairIndex[1] = 0;
  7502. this._adjacentPairIndex[2] = 0;
  7503. }
  7504. dump() {
  7505. }
  7506. }
  7507. oimo.collision.narrowphase.detector.gjkepa.EpaVertex = class oimo_collision_narrowphase_detector_gjkepa_EpaVertex {
  7508. constructor() {
  7509. this.randId = Math.random() * 100000 | 0;
  7510. this.v = new oimo.common.Vec3();
  7511. this.w1 = new oimo.common.Vec3();
  7512. this.w2 = new oimo.common.Vec3();
  7513. }
  7514. init(v,w1,w2) {
  7515. var _this = this.v;
  7516. _this.x = v.x;
  7517. _this.y = v.y;
  7518. _this.z = v.z;
  7519. var _this1 = this.w1;
  7520. _this1.x = w1.x;
  7521. _this1.y = w1.y;
  7522. _this1.z = w1.z;
  7523. var _this2 = this.w2;
  7524. _this2.x = w2.x;
  7525. _this2.y = w2.y;
  7526. _this2.z = w2.z;
  7527. this._next = null;
  7528. this._tmpEdgeLoopNext = null;
  7529. this._tmpEdgeLoopOuterTriangle = null;
  7530. return this;
  7531. }
  7532. removeReferences() {
  7533. this._next = null;
  7534. this._tmpEdgeLoopNext = null;
  7535. this._tmpEdgeLoopOuterTriangle = null;
  7536. }
  7537. }
  7538. oimo.collision.narrowphase.detector.gjkepa.GjkCache = class oimo_collision_narrowphase_detector_gjkepa_GjkCache {
  7539. constructor() {
  7540. this.prevClosestDir = new oimo.common.Vec3();
  7541. }
  7542. clear() {
  7543. this.prevClosestDir.zero();
  7544. }
  7545. }
  7546. if(!oimo.common) oimo.common = {};
  7547. oimo.common.Vec3 = class oimo_common_Vec3 {
  7548. constructor(x,y,z) {
  7549. if(z == null) {
  7550. z = 0;
  7551. }
  7552. if(y == null) {
  7553. y = 0;
  7554. }
  7555. if(x == null) {
  7556. x = 0;
  7557. }
  7558. this.x = x;
  7559. this.y = y;
  7560. this.z = z;
  7561. oimo.common.Vec3.numCreations++;
  7562. }
  7563. init(x,y,z) {
  7564. this.x = x;
  7565. this.y = y;
  7566. this.z = z;
  7567. return this;
  7568. }
  7569. zero() {
  7570. var tx = 0;
  7571. var ty = 0;
  7572. var tz = 0;
  7573. this.x = tx;
  7574. this.y = ty;
  7575. this.z = tz;
  7576. return this;
  7577. }
  7578. add(v) {
  7579. return new oimo.common.Vec3(this.x + v.x,this.y + v.y,this.z + v.z);
  7580. }
  7581. add3(vx,vy,vz) {
  7582. return new oimo.common.Vec3(this.x + vx,this.y + vy,this.z + vz);
  7583. }
  7584. addScaled(v,s) {
  7585. return new oimo.common.Vec3(this.x + v.x * s,this.y + v.y * s,this.z + v.z * s);
  7586. }
  7587. sub(v) {
  7588. return new oimo.common.Vec3(this.x - v.x,this.y - v.y,this.z - v.z);
  7589. }
  7590. sub3(vx,vy,vz) {
  7591. return new oimo.common.Vec3(this.x - vx,this.y - vy,this.z - vz);
  7592. }
  7593. scale(s) {
  7594. return new oimo.common.Vec3(this.x * s,this.y * s,this.z * s);
  7595. }
  7596. scale3(sx,sy,sz) {
  7597. return new oimo.common.Vec3(this.x * sx,this.y * sy,this.z * sz);
  7598. }
  7599. dot(v) {
  7600. return this.x * v.x + this.y * v.y + this.z * v.z;
  7601. }
  7602. cross(v) {
  7603. return new oimo.common.Vec3(this.y * v.z - this.z * v.y,this.z * v.x - this.x * v.z,this.x * v.y - this.y * v.x);
  7604. }
  7605. addEq(v) {
  7606. var tx = this.x + v.x;
  7607. var ty = this.y + v.y;
  7608. var tz = this.z + v.z;
  7609. this.x = tx;
  7610. this.y = ty;
  7611. this.z = tz;
  7612. return this;
  7613. }
  7614. add3Eq(vx,vy,vz) {
  7615. var tx = this.x + vx;
  7616. var ty = this.y + vy;
  7617. var tz = this.z + vz;
  7618. this.x = tx;
  7619. this.y = ty;
  7620. this.z = tz;
  7621. return this;
  7622. }
  7623. addScaledEq(v,s) {
  7624. var tx = this.x + v.x * s;
  7625. var ty = this.y + v.y * s;
  7626. var tz = this.z + v.z * s;
  7627. this.x = tx;
  7628. this.y = ty;
  7629. this.z = tz;
  7630. return this;
  7631. }
  7632. subEq(v) {
  7633. var tx = this.x - v.x;
  7634. var ty = this.y - v.y;
  7635. var tz = this.z - v.z;
  7636. this.x = tx;
  7637. this.y = ty;
  7638. this.z = tz;
  7639. return this;
  7640. }
  7641. sub3Eq(vx,vy,vz) {
  7642. var tx = this.x - vx;
  7643. var ty = this.y - vy;
  7644. var tz = this.z - vz;
  7645. this.x = tx;
  7646. this.y = ty;
  7647. this.z = tz;
  7648. return this;
  7649. }
  7650. scaleEq(s) {
  7651. var tx = this.x * s;
  7652. var ty = this.y * s;
  7653. var tz = this.z * s;
  7654. this.x = tx;
  7655. this.y = ty;
  7656. this.z = tz;
  7657. return this;
  7658. }
  7659. scale3Eq(sx,sy,sz) {
  7660. var tx = this.x * sx;
  7661. var ty = this.y * sy;
  7662. var tz = this.z * sz;
  7663. this.x = tx;
  7664. this.y = ty;
  7665. this.z = tz;
  7666. return this;
  7667. }
  7668. crossEq(v) {
  7669. var tx = this.y * v.z - this.z * v.y;
  7670. var ty = this.z * v.x - this.x * v.z;
  7671. var tz = this.x * v.y - this.y * v.x;
  7672. this.x = tx;
  7673. this.y = ty;
  7674. this.z = tz;
  7675. return this;
  7676. }
  7677. mulMat3(m) {
  7678. return new oimo.common.Vec3(this.x * m.e00 + this.y * m.e01 + this.z * m.e02,this.x * m.e10 + this.y * m.e11 + this.z * m.e12,this.x * m.e20 + this.y * m.e21 + this.z * m.e22);
  7679. }
  7680. mulMat4(m) {
  7681. return new oimo.common.Vec3(this.x * m.e00 + this.y * m.e01 + this.z * m.e02 + m.e03,this.x * m.e10 + this.y * m.e11 + this.z * m.e12 + m.e13,this.x * m.e20 + this.y * m.e21 + this.z * m.e22 + m.e23);
  7682. }
  7683. mulTransform(tf) {
  7684. var v;
  7685. var vX;
  7686. var vY;
  7687. var vZ;
  7688. var v1 = this;
  7689. vX = v1.x;
  7690. vY = v1.y;
  7691. vZ = v1.z;
  7692. var __tmp__X;
  7693. var __tmp__Y;
  7694. var __tmp__Z;
  7695. __tmp__X = tf._rotation00 * vX + tf._rotation01 * vY + tf._rotation02 * vZ;
  7696. __tmp__Y = tf._rotation10 * vX + tf._rotation11 * vY + tf._rotation12 * vZ;
  7697. __tmp__Z = tf._rotation20 * vX + tf._rotation21 * vY + tf._rotation22 * vZ;
  7698. vX = __tmp__X;
  7699. vY = __tmp__Y;
  7700. vZ = __tmp__Z;
  7701. vX += tf._positionX;
  7702. vY += tf._positionY;
  7703. vZ += tf._positionZ;
  7704. var res = new oimo.common.Vec3();
  7705. var v2 = res;
  7706. v2.x = vX;
  7707. v2.y = vY;
  7708. v2.z = vZ;
  7709. return res;
  7710. }
  7711. mulMat3Eq(m) {
  7712. var tx = this.x * m.e00 + this.y * m.e01 + this.z * m.e02;
  7713. var ty = this.x * m.e10 + this.y * m.e11 + this.z * m.e12;
  7714. var tz = this.x * m.e20 + this.y * m.e21 + this.z * m.e22;
  7715. this.x = tx;
  7716. this.y = ty;
  7717. this.z = tz;
  7718. return this;
  7719. }
  7720. mulMat4Eq(m) {
  7721. var tx = this.x * m.e00 + this.y * m.e01 + this.z * m.e02 + m.e03;
  7722. var ty = this.x * m.e10 + this.y * m.e11 + this.z * m.e12 + m.e13;
  7723. var tz = this.x * m.e20 + this.y * m.e21 + this.z * m.e22 + m.e23;
  7724. this.x = tx;
  7725. this.y = ty;
  7726. this.z = tz;
  7727. return this;
  7728. }
  7729. mulTransformEq(tf) {
  7730. var v;
  7731. var vX;
  7732. var vY;
  7733. var vZ;
  7734. var v1 = this;
  7735. vX = v1.x;
  7736. vY = v1.y;
  7737. vZ = v1.z;
  7738. var __tmp__X;
  7739. var __tmp__Y;
  7740. var __tmp__Z;
  7741. __tmp__X = tf._rotation00 * vX + tf._rotation01 * vY + tf._rotation02 * vZ;
  7742. __tmp__Y = tf._rotation10 * vX + tf._rotation11 * vY + tf._rotation12 * vZ;
  7743. __tmp__Z = tf._rotation20 * vX + tf._rotation21 * vY + tf._rotation22 * vZ;
  7744. vX = __tmp__X;
  7745. vY = __tmp__Y;
  7746. vZ = __tmp__Z;
  7747. vX += tf._positionX;
  7748. vY += tf._positionY;
  7749. vZ += tf._positionZ;
  7750. var v2 = this;
  7751. v2.x = vX;
  7752. v2.y = vY;
  7753. v2.z = vZ;
  7754. return this;
  7755. }
  7756. length() {
  7757. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  7758. }
  7759. lengthSq() {
  7760. return this.x * this.x + this.y * this.y + this.z * this.z;
  7761. }
  7762. normalized() {
  7763. var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  7764. if(invLen > 0) {
  7765. invLen = 1 / invLen;
  7766. }
  7767. return new oimo.common.Vec3(this.x * invLen,this.y * invLen,this.z * invLen);
  7768. }
  7769. normalize() {
  7770. var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  7771. if(invLen > 0) {
  7772. invLen = 1 / invLen;
  7773. }
  7774. var tx = this.x * invLen;
  7775. var ty = this.y * invLen;
  7776. var tz = this.z * invLen;
  7777. this.x = tx;
  7778. this.y = ty;
  7779. this.z = tz;
  7780. return this;
  7781. }
  7782. negate() {
  7783. return new oimo.common.Vec3(-this.x,-this.y,-this.z);
  7784. }
  7785. negateEq() {
  7786. var tx = -this.x;
  7787. var ty = -this.y;
  7788. var tz = -this.z;
  7789. this.x = tx;
  7790. this.y = ty;
  7791. this.z = tz;
  7792. return this;
  7793. }
  7794. copyFrom(v) {
  7795. this.x = v.x;
  7796. this.y = v.y;
  7797. this.z = v.z;
  7798. return this;
  7799. }
  7800. clone() {
  7801. return new oimo.common.Vec3(this.x,this.y,this.z);
  7802. }
  7803. toString() {
  7804. return "Vec3[" + (this.x > 0 ? (this.x * 10000000 + 0.5 | 0) / 10000000 : (this.x * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.y > 0 ? (this.y * 10000000 + 0.5 | 0) / 10000000 : (this.y * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.z > 0 ? (this.z * 10000000 + 0.5 | 0) / 10000000 : (this.z * 10000000 - 0.5 | 0) / 10000000) + "]";
  7805. }
  7806. }
  7807. oimo.common.Transform = class oimo_common_Transform {
  7808. constructor() {
  7809. this._positionX = 0;
  7810. this._positionY = 0;
  7811. this._positionZ = 0;
  7812. this._rotation00 = 1;
  7813. this._rotation01 = 0;
  7814. this._rotation02 = 0;
  7815. this._rotation10 = 0;
  7816. this._rotation11 = 1;
  7817. this._rotation12 = 0;
  7818. this._rotation20 = 0;
  7819. this._rotation21 = 0;
  7820. this._rotation22 = 1;
  7821. }
  7822. identity() {
  7823. this._positionX = 0;
  7824. this._positionY = 0;
  7825. this._positionZ = 0;
  7826. this._rotation00 = 1;
  7827. this._rotation01 = 0;
  7828. this._rotation02 = 0;
  7829. this._rotation10 = 0;
  7830. this._rotation11 = 1;
  7831. this._rotation12 = 0;
  7832. this._rotation20 = 0;
  7833. this._rotation21 = 0;
  7834. this._rotation22 = 1;
  7835. return this;
  7836. }
  7837. getPosition() {
  7838. var position = new oimo.common.Vec3();
  7839. var v = position;
  7840. v.x = this._positionX;
  7841. v.y = this._positionY;
  7842. v.z = this._positionZ;
  7843. return position;
  7844. }
  7845. getPositionTo(position) {
  7846. var v = position;
  7847. v.x = this._positionX;
  7848. v.y = this._positionY;
  7849. v.z = this._positionZ;
  7850. }
  7851. setPosition(position) {
  7852. var v = position;
  7853. this._positionX = v.x;
  7854. this._positionY = v.y;
  7855. this._positionZ = v.z;
  7856. return this;
  7857. }
  7858. translate(translation) {
  7859. var diff;
  7860. var diffX;
  7861. var diffY;
  7862. var diffZ;
  7863. var v = translation;
  7864. diffX = v.x;
  7865. diffY = v.y;
  7866. diffZ = v.z;
  7867. this._positionX += diffX;
  7868. this._positionY += diffY;
  7869. this._positionZ += diffZ;
  7870. }
  7871. getRotation() {
  7872. var rotation = new oimo.common.Mat3();
  7873. var m = rotation;
  7874. m.e00 = this._rotation00;
  7875. m.e01 = this._rotation01;
  7876. m.e02 = this._rotation02;
  7877. m.e10 = this._rotation10;
  7878. m.e11 = this._rotation11;
  7879. m.e12 = this._rotation12;
  7880. m.e20 = this._rotation20;
  7881. m.e21 = this._rotation21;
  7882. m.e22 = this._rotation22;
  7883. return rotation;
  7884. }
  7885. getRotationTo(out) {
  7886. var m = out;
  7887. m.e00 = this._rotation00;
  7888. m.e01 = this._rotation01;
  7889. m.e02 = this._rotation02;
  7890. m.e10 = this._rotation10;
  7891. m.e11 = this._rotation11;
  7892. m.e12 = this._rotation12;
  7893. m.e20 = this._rotation20;
  7894. m.e21 = this._rotation21;
  7895. m.e22 = this._rotation22;
  7896. }
  7897. setRotation(rotation) {
  7898. var m = rotation;
  7899. this._rotation00 = m.e00;
  7900. this._rotation01 = m.e01;
  7901. this._rotation02 = m.e02;
  7902. this._rotation10 = m.e10;
  7903. this._rotation11 = m.e11;
  7904. this._rotation12 = m.e12;
  7905. this._rotation20 = m.e20;
  7906. this._rotation21 = m.e21;
  7907. this._rotation22 = m.e22;
  7908. return this;
  7909. }
  7910. setRotationXyz(eulerAngles) {
  7911. var xyz;
  7912. var xyzX;
  7913. var xyzY;
  7914. var xyzZ;
  7915. var v = eulerAngles;
  7916. xyzX = v.x;
  7917. xyzY = v.y;
  7918. xyzZ = v.z;
  7919. var sx = Math.sin(xyzX);
  7920. var sy = Math.sin(xyzY);
  7921. var sz = Math.sin(xyzZ);
  7922. var cx = Math.cos(xyzX);
  7923. var cy = Math.cos(xyzY);
  7924. var cz = Math.cos(xyzZ);
  7925. this._rotation00 = cy * cz;
  7926. this._rotation01 = -cy * sz;
  7927. this._rotation02 = sy;
  7928. this._rotation10 = cx * sz + cz * sx * sy;
  7929. this._rotation11 = cx * cz - sx * sy * sz;
  7930. this._rotation12 = -cy * sx;
  7931. this._rotation20 = sx * sz - cx * cz * sy;
  7932. this._rotation21 = cz * sx + cx * sy * sz;
  7933. this._rotation22 = cx * cy;
  7934. }
  7935. rotate(rotation) {
  7936. var rot;
  7937. var rot00;
  7938. var rot01;
  7939. var rot02;
  7940. var rot10;
  7941. var rot11;
  7942. var rot12;
  7943. var rot20;
  7944. var rot21;
  7945. var rot22;
  7946. var m = rotation;
  7947. rot00 = m.e00;
  7948. rot01 = m.e01;
  7949. rot02 = m.e02;
  7950. rot10 = m.e10;
  7951. rot11 = m.e11;
  7952. rot12 = m.e12;
  7953. rot20 = m.e20;
  7954. rot21 = m.e21;
  7955. rot22 = m.e22;
  7956. var __tmp__00;
  7957. var __tmp__01;
  7958. var __tmp__02;
  7959. var __tmp__10;
  7960. var __tmp__11;
  7961. var __tmp__12;
  7962. var __tmp__20;
  7963. var __tmp__21;
  7964. var __tmp__22;
  7965. __tmp__00 = rot00 * this._rotation00 + rot01 * this._rotation10 + rot02 * this._rotation20;
  7966. __tmp__01 = rot00 * this._rotation01 + rot01 * this._rotation11 + rot02 * this._rotation21;
  7967. __tmp__02 = rot00 * this._rotation02 + rot01 * this._rotation12 + rot02 * this._rotation22;
  7968. __tmp__10 = rot10 * this._rotation00 + rot11 * this._rotation10 + rot12 * this._rotation20;
  7969. __tmp__11 = rot10 * this._rotation01 + rot11 * this._rotation11 + rot12 * this._rotation21;
  7970. __tmp__12 = rot10 * this._rotation02 + rot11 * this._rotation12 + rot12 * this._rotation22;
  7971. __tmp__20 = rot20 * this._rotation00 + rot21 * this._rotation10 + rot22 * this._rotation20;
  7972. __tmp__21 = rot20 * this._rotation01 + rot21 * this._rotation11 + rot22 * this._rotation21;
  7973. __tmp__22 = rot20 * this._rotation02 + rot21 * this._rotation12 + rot22 * this._rotation22;
  7974. this._rotation00 = __tmp__00;
  7975. this._rotation01 = __tmp__01;
  7976. this._rotation02 = __tmp__02;
  7977. this._rotation10 = __tmp__10;
  7978. this._rotation11 = __tmp__11;
  7979. this._rotation12 = __tmp__12;
  7980. this._rotation20 = __tmp__20;
  7981. this._rotation21 = __tmp__21;
  7982. this._rotation22 = __tmp__22;
  7983. }
  7984. rotateXyz(eulerAngles) {
  7985. var xyz;
  7986. var xyzX;
  7987. var xyzY;
  7988. var xyzZ;
  7989. var rot;
  7990. var rot00;
  7991. var rot01;
  7992. var rot02;
  7993. var rot10;
  7994. var rot11;
  7995. var rot12;
  7996. var rot20;
  7997. var rot21;
  7998. var rot22;
  7999. var v = eulerAngles;
  8000. xyzX = v.x;
  8001. xyzY = v.y;
  8002. xyzZ = v.z;
  8003. var sx = Math.sin(xyzX);
  8004. var sy = Math.sin(xyzY);
  8005. var sz = Math.sin(xyzZ);
  8006. var cx = Math.cos(xyzX);
  8007. var cy = Math.cos(xyzY);
  8008. var cz = Math.cos(xyzZ);
  8009. rot00 = cy * cz;
  8010. rot01 = -cy * sz;
  8011. rot02 = sy;
  8012. rot10 = cx * sz + cz * sx * sy;
  8013. rot11 = cx * cz - sx * sy * sz;
  8014. rot12 = -cy * sx;
  8015. rot20 = sx * sz - cx * cz * sy;
  8016. rot21 = cz * sx + cx * sy * sz;
  8017. rot22 = cx * cy;
  8018. var __tmp__00;
  8019. var __tmp__01;
  8020. var __tmp__02;
  8021. var __tmp__10;
  8022. var __tmp__11;
  8023. var __tmp__12;
  8024. var __tmp__20;
  8025. var __tmp__21;
  8026. var __tmp__22;
  8027. __tmp__00 = rot00 * this._rotation00 + rot01 * this._rotation10 + rot02 * this._rotation20;
  8028. __tmp__01 = rot00 * this._rotation01 + rot01 * this._rotation11 + rot02 * this._rotation21;
  8029. __tmp__02 = rot00 * this._rotation02 + rot01 * this._rotation12 + rot02 * this._rotation22;
  8030. __tmp__10 = rot10 * this._rotation00 + rot11 * this._rotation10 + rot12 * this._rotation20;
  8031. __tmp__11 = rot10 * this._rotation01 + rot11 * this._rotation11 + rot12 * this._rotation21;
  8032. __tmp__12 = rot10 * this._rotation02 + rot11 * this._rotation12 + rot12 * this._rotation22;
  8033. __tmp__20 = rot20 * this._rotation00 + rot21 * this._rotation10 + rot22 * this._rotation20;
  8034. __tmp__21 = rot20 * this._rotation01 + rot21 * this._rotation11 + rot22 * this._rotation21;
  8035. __tmp__22 = rot20 * this._rotation02 + rot21 * this._rotation12 + rot22 * this._rotation22;
  8036. this._rotation00 = __tmp__00;
  8037. this._rotation01 = __tmp__01;
  8038. this._rotation02 = __tmp__02;
  8039. this._rotation10 = __tmp__10;
  8040. this._rotation11 = __tmp__11;
  8041. this._rotation12 = __tmp__12;
  8042. this._rotation20 = __tmp__20;
  8043. this._rotation21 = __tmp__21;
  8044. this._rotation22 = __tmp__22;
  8045. }
  8046. getOrientation() {
  8047. var q = new oimo.common.Quat();
  8048. var iq;
  8049. var iqX;
  8050. var iqY;
  8051. var iqZ;
  8052. var iqW;
  8053. var e00 = this._rotation00;
  8054. var e11 = this._rotation11;
  8055. var e22 = this._rotation22;
  8056. var t = e00 + e11 + e22;
  8057. var s;
  8058. if(t > 0) {
  8059. s = Math.sqrt(t + 1);
  8060. iqW = 0.5 * s;
  8061. s = 0.5 / s;
  8062. iqX = (this._rotation21 - this._rotation12) * s;
  8063. iqY = (this._rotation02 - this._rotation20) * s;
  8064. iqZ = (this._rotation10 - this._rotation01) * s;
  8065. } else if(e00 > e11) {
  8066. if(e00 > e22) {
  8067. s = Math.sqrt(e00 - e11 - e22 + 1);
  8068. iqX = 0.5 * s;
  8069. s = 0.5 / s;
  8070. iqY = (this._rotation01 + this._rotation10) * s;
  8071. iqZ = (this._rotation02 + this._rotation20) * s;
  8072. iqW = (this._rotation21 - this._rotation12) * s;
  8073. } else {
  8074. s = Math.sqrt(e22 - e00 - e11 + 1);
  8075. iqZ = 0.5 * s;
  8076. s = 0.5 / s;
  8077. iqX = (this._rotation02 + this._rotation20) * s;
  8078. iqY = (this._rotation12 + this._rotation21) * s;
  8079. iqW = (this._rotation10 - this._rotation01) * s;
  8080. }
  8081. } else if(e11 > e22) {
  8082. s = Math.sqrt(e11 - e22 - e00 + 1);
  8083. iqY = 0.5 * s;
  8084. s = 0.5 / s;
  8085. iqX = (this._rotation01 + this._rotation10) * s;
  8086. iqZ = (this._rotation12 + this._rotation21) * s;
  8087. iqW = (this._rotation02 - this._rotation20) * s;
  8088. } else {
  8089. s = Math.sqrt(e22 - e00 - e11 + 1);
  8090. iqZ = 0.5 * s;
  8091. s = 0.5 / s;
  8092. iqX = (this._rotation02 + this._rotation20) * s;
  8093. iqY = (this._rotation12 + this._rotation21) * s;
  8094. iqW = (this._rotation10 - this._rotation01) * s;
  8095. }
  8096. var q1 = q;
  8097. q1.x = iqX;
  8098. q1.y = iqY;
  8099. q1.z = iqZ;
  8100. q1.w = iqW;
  8101. return q;
  8102. }
  8103. getOrientationTo(orientation) {
  8104. var iq;
  8105. var iqX;
  8106. var iqY;
  8107. var iqZ;
  8108. var iqW;
  8109. var e00 = this._rotation00;
  8110. var e11 = this._rotation11;
  8111. var e22 = this._rotation22;
  8112. var t = e00 + e11 + e22;
  8113. var s;
  8114. if(t > 0) {
  8115. s = Math.sqrt(t + 1);
  8116. iqW = 0.5 * s;
  8117. s = 0.5 / s;
  8118. iqX = (this._rotation21 - this._rotation12) * s;
  8119. iqY = (this._rotation02 - this._rotation20) * s;
  8120. iqZ = (this._rotation10 - this._rotation01) * s;
  8121. } else if(e00 > e11) {
  8122. if(e00 > e22) {
  8123. s = Math.sqrt(e00 - e11 - e22 + 1);
  8124. iqX = 0.5 * s;
  8125. s = 0.5 / s;
  8126. iqY = (this._rotation01 + this._rotation10) * s;
  8127. iqZ = (this._rotation02 + this._rotation20) * s;
  8128. iqW = (this._rotation21 - this._rotation12) * s;
  8129. } else {
  8130. s = Math.sqrt(e22 - e00 - e11 + 1);
  8131. iqZ = 0.5 * s;
  8132. s = 0.5 / s;
  8133. iqX = (this._rotation02 + this._rotation20) * s;
  8134. iqY = (this._rotation12 + this._rotation21) * s;
  8135. iqW = (this._rotation10 - this._rotation01) * s;
  8136. }
  8137. } else if(e11 > e22) {
  8138. s = Math.sqrt(e11 - e22 - e00 + 1);
  8139. iqY = 0.5 * s;
  8140. s = 0.5 / s;
  8141. iqX = (this._rotation01 + this._rotation10) * s;
  8142. iqZ = (this._rotation12 + this._rotation21) * s;
  8143. iqW = (this._rotation02 - this._rotation20) * s;
  8144. } else {
  8145. s = Math.sqrt(e22 - e00 - e11 + 1);
  8146. iqZ = 0.5 * s;
  8147. s = 0.5 / s;
  8148. iqX = (this._rotation02 + this._rotation20) * s;
  8149. iqY = (this._rotation12 + this._rotation21) * s;
  8150. iqW = (this._rotation10 - this._rotation01) * s;
  8151. }
  8152. var q = orientation;
  8153. q.x = iqX;
  8154. q.y = iqY;
  8155. q.z = iqZ;
  8156. q.w = iqW;
  8157. }
  8158. setOrientation(quaternion) {
  8159. var q;
  8160. var qX;
  8161. var qY;
  8162. var qZ;
  8163. var qW;
  8164. var q1 = quaternion;
  8165. qX = q1.x;
  8166. qY = q1.y;
  8167. qZ = q1.z;
  8168. qW = q1.w;
  8169. var x = qX;
  8170. var y = qY;
  8171. var z = qZ;
  8172. var w = qW;
  8173. var x2 = 2 * x;
  8174. var y2 = 2 * y;
  8175. var z2 = 2 * z;
  8176. var xx = x * x2;
  8177. var yy = y * y2;
  8178. var zz = z * z2;
  8179. var xy = x * y2;
  8180. var yz = y * z2;
  8181. var xz = x * z2;
  8182. var wx = w * x2;
  8183. var wy = w * y2;
  8184. var wz = w * z2;
  8185. this._rotation00 = 1 - yy - zz;
  8186. this._rotation01 = xy - wz;
  8187. this._rotation02 = xz + wy;
  8188. this._rotation10 = xy + wz;
  8189. this._rotation11 = 1 - xx - zz;
  8190. this._rotation12 = yz - wx;
  8191. this._rotation20 = xz - wy;
  8192. this._rotation21 = yz + wx;
  8193. this._rotation22 = 1 - xx - yy;
  8194. return this;
  8195. }
  8196. clone() {
  8197. var tf = new oimo.common.Transform();
  8198. tf._positionX = this._positionX;
  8199. tf._positionY = this._positionY;
  8200. tf._positionZ = this._positionZ;
  8201. tf._rotation00 = this._rotation00;
  8202. tf._rotation01 = this._rotation01;
  8203. tf._rotation02 = this._rotation02;
  8204. tf._rotation10 = this._rotation10;
  8205. tf._rotation11 = this._rotation11;
  8206. tf._rotation12 = this._rotation12;
  8207. tf._rotation20 = this._rotation20;
  8208. tf._rotation21 = this._rotation21;
  8209. tf._rotation22 = this._rotation22;
  8210. return tf;
  8211. }
  8212. copyFrom(transform) {
  8213. this._positionX = transform._positionX;
  8214. this._positionY = transform._positionY;
  8215. this._positionZ = transform._positionZ;
  8216. this._rotation00 = transform._rotation00;
  8217. this._rotation01 = transform._rotation01;
  8218. this._rotation02 = transform._rotation02;
  8219. this._rotation10 = transform._rotation10;
  8220. this._rotation11 = transform._rotation11;
  8221. this._rotation12 = transform._rotation12;
  8222. this._rotation20 = transform._rotation20;
  8223. this._rotation21 = transform._rotation21;
  8224. this._rotation22 = transform._rotation22;
  8225. return this;
  8226. }
  8227. }
  8228. oimo.common.Setting = class oimo_common_Setting {
  8229. }
  8230. oimo.collision.narrowphase.detector.gjkepa.GjkEpa = class oimo_collision_narrowphase_detector_gjkepa_GjkEpa {
  8231. constructor() {
  8232. var this1 = new Array(4);
  8233. this.s = this1;
  8234. var this2 = new Array(4);
  8235. this.w1 = this2;
  8236. var this3 = new Array(4);
  8237. this.w2 = this3;
  8238. var this4 = new Array(3);
  8239. this.baseDirs = this4;
  8240. this.baseDirs[0] = new oimo.common.Vec3(1,0,0);
  8241. this.baseDirs[1] = new oimo.common.Vec3(0,1,0);
  8242. this.baseDirs[2] = new oimo.common.Vec3(0,0,1);
  8243. this.tl1 = new oimo.common.Vec3();
  8244. this.tl2 = new oimo.common.Vec3();
  8245. this.rayX = new oimo.common.Vec3();
  8246. this.rayR = new oimo.common.Vec3();
  8247. this.tempTransform = new oimo.common.Transform();
  8248. this.s[0] = new oimo.common.Vec3();
  8249. this.w1[0] = new oimo.common.Vec3();
  8250. this.w2[0] = new oimo.common.Vec3();
  8251. this.s[1] = new oimo.common.Vec3();
  8252. this.w1[1] = new oimo.common.Vec3();
  8253. this.w2[1] = new oimo.common.Vec3();
  8254. this.s[2] = new oimo.common.Vec3();
  8255. this.w1[2] = new oimo.common.Vec3();
  8256. this.w2[2] = new oimo.common.Vec3();
  8257. this.s[3] = new oimo.common.Vec3();
  8258. this.w1[3] = new oimo.common.Vec3();
  8259. this.w2[3] = new oimo.common.Vec3();
  8260. this.dir = new oimo.common.Vec3();
  8261. this.closest = new oimo.common.Vec3();
  8262. this.closestPoint1 = new oimo.common.Vec3();
  8263. this.closestPoint2 = new oimo.common.Vec3();
  8264. this.polyhedron = new oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedron();
  8265. }
  8266. computeClosestPointsImpl(c1,c2,tf1,tf2,cache,useEpa) {
  8267. this.c1 = c1;
  8268. this.c2 = c2;
  8269. this.tf1 = tf1;
  8270. this.tf2 = tf2;
  8271. var s = this.s;
  8272. var w1 = this.w1;
  8273. var w2 = this.w2;
  8274. var closest = this.closest;
  8275. var dir = this.dir;
  8276. if(cache != null) {
  8277. if(cache._gjkCache == null) {
  8278. cache._gjkCache = new oimo.collision.narrowphase.detector.gjkepa.GjkCache();
  8279. }
  8280. this.loadCache(cache._gjkCache);
  8281. } else {
  8282. dir.zero();
  8283. }
  8284. if(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z == 0) {
  8285. var firstDir;
  8286. var firstDirX;
  8287. var firstDirY;
  8288. var firstDirZ;
  8289. firstDirX = tf2._positionX - tf1._positionX;
  8290. firstDirY = tf2._positionY - tf1._positionY;
  8291. firstDirZ = tf2._positionZ - tf1._positionZ;
  8292. var v = dir;
  8293. v.x = firstDirX;
  8294. v.y = firstDirY;
  8295. v.z = firstDirZ;
  8296. if(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < 1e-6) {
  8297. dir.init(1,0,0);
  8298. }
  8299. }
  8300. this.simplexSize = 0;
  8301. this.computeWitnessPoint1(false);
  8302. this.computeWitnessPoint2(false);
  8303. var _this = this.s[this.simplexSize];
  8304. var v1 = this.w1[this.simplexSize];
  8305. _this.x = v1.x;
  8306. _this.y = v1.y;
  8307. _this.z = v1.z;
  8308. var _this1 = _this;
  8309. var v2 = this.w2[this.simplexSize];
  8310. var tx = _this1.x - v2.x;
  8311. var ty = _this1.y - v2.y;
  8312. var tz = _this1.z - v2.z;
  8313. _this1.x = tx;
  8314. _this1.y = ty;
  8315. _this1.z = tz;
  8316. this.simplexSize = 1;
  8317. var count = 0;
  8318. var max = 40;
  8319. var eps = 1e-4;
  8320. var eps2 = eps * eps;
  8321. while(count < max) {
  8322. var v3 = 0;
  8323. switch(this.simplexSize) {
  8324. case 1:
  8325. var v4 = s[0];
  8326. closest.x = v4.x;
  8327. closest.y = v4.y;
  8328. closest.z = v4.z;
  8329. v3 = 1;
  8330. break;
  8331. case 2:
  8332. var v11;
  8333. var v1X;
  8334. var v1Y;
  8335. var v1Z;
  8336. var v21;
  8337. var v2X;
  8338. var v2Y;
  8339. var v2Z;
  8340. var v5 = s[0];
  8341. v1X = v5.x;
  8342. v1Y = v5.y;
  8343. v1Z = v5.z;
  8344. var v6 = s[1];
  8345. v2X = v6.x;
  8346. v2Y = v6.y;
  8347. v2Z = v6.z;
  8348. var v12;
  8349. var v12X;
  8350. var v12Y;
  8351. var v12Z;
  8352. v12X = v2X - v1X;
  8353. v12Y = v2Y - v1Y;
  8354. v12Z = v2Z - v1Z;
  8355. var d = v12X * v12X + v12Y * v12Y + v12Z * v12Z;
  8356. var t = v12X * v1X + v12Y * v1Y + v12Z * v1Z;
  8357. t = -t / d;
  8358. if(t < 0) {
  8359. var v7 = closest;
  8360. v7.x = v1X;
  8361. v7.y = v1Y;
  8362. v7.z = v1Z;
  8363. v3 = 1;
  8364. } else if(t > 1) {
  8365. var v8 = closest;
  8366. v8.x = v2X;
  8367. v8.y = v2Y;
  8368. v8.z = v2Z;
  8369. v3 = 2;
  8370. } else {
  8371. var p;
  8372. var pX;
  8373. var pY;
  8374. var pZ;
  8375. pX = v1X + v12X * t;
  8376. pY = v1Y + v12Y * t;
  8377. pZ = v1Z + v12Z * t;
  8378. var v9 = closest;
  8379. v9.x = pX;
  8380. v9.y = pY;
  8381. v9.z = pZ;
  8382. v3 = 3;
  8383. }
  8384. break;
  8385. case 3:
  8386. var vec1 = s[0];
  8387. var vec2 = s[1];
  8388. var vec3 = s[2];
  8389. var v13;
  8390. var v1X1;
  8391. var v1Y1;
  8392. var v1Z1;
  8393. var v22;
  8394. var v2X1;
  8395. var v2Y1;
  8396. var v2Z1;
  8397. var v31;
  8398. var v3X;
  8399. var v3Y;
  8400. var v3Z;
  8401. var v121;
  8402. var v12X1;
  8403. var v12Y1;
  8404. var v12Z1;
  8405. var v23;
  8406. var v23X;
  8407. var v23Y;
  8408. var v23Z;
  8409. var v311;
  8410. var v31X;
  8411. var v31Y;
  8412. var v31Z;
  8413. var v10 = vec1;
  8414. v1X1 = v10.x;
  8415. v1Y1 = v10.y;
  8416. v1Z1 = v10.z;
  8417. var v14 = vec2;
  8418. v2X1 = v14.x;
  8419. v2Y1 = v14.y;
  8420. v2Z1 = v14.z;
  8421. var v15 = vec3;
  8422. v3X = v15.x;
  8423. v3Y = v15.y;
  8424. v3Z = v15.z;
  8425. v12X1 = v2X1 - v1X1;
  8426. v12Y1 = v2Y1 - v1Y1;
  8427. v12Z1 = v2Z1 - v1Z1;
  8428. v23X = v3X - v2X1;
  8429. v23Y = v3Y - v2Y1;
  8430. v23Z = v3Z - v2Z1;
  8431. v31X = v1X1 - v3X;
  8432. v31Y = v1Y1 - v3Y;
  8433. v31Z = v1Z1 - v3Z;
  8434. var n;
  8435. var nX;
  8436. var nY;
  8437. var nZ;
  8438. nX = v12Y1 * v23Z - v12Z1 * v23Y;
  8439. nY = v12Z1 * v23X - v12X1 * v23Z;
  8440. nZ = v12X1 * v23Y - v12Y1 * v23X;
  8441. var n12;
  8442. var n12X;
  8443. var n12Y;
  8444. var n12Z;
  8445. var n23;
  8446. var n23X;
  8447. var n23Y;
  8448. var n23Z;
  8449. var n31;
  8450. var n31X;
  8451. var n31Y;
  8452. var n31Z;
  8453. n12X = v12Y1 * nZ - v12Z1 * nY;
  8454. n12Y = v12Z1 * nX - v12X1 * nZ;
  8455. n12Z = v12X1 * nY - v12Y1 * nX;
  8456. n23X = v23Y * nZ - v23Z * nY;
  8457. n23Y = v23Z * nX - v23X * nZ;
  8458. n23Z = v23X * nY - v23Y * nX;
  8459. n31X = v31Y * nZ - v31Z * nY;
  8460. n31Y = v31Z * nX - v31X * nZ;
  8461. n31Z = v31X * nY - v31Y * nX;
  8462. var d12 = v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z;
  8463. var d23 = v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z;
  8464. var d31 = v3X * n31X + v3Y * n31Y + v3Z * n31Z;
  8465. var mind = -1;
  8466. var minv;
  8467. var minvX;
  8468. var minvY;
  8469. var minvZ;
  8470. var mini = 0;
  8471. minvX = 0;
  8472. minvY = 0;
  8473. minvZ = 0;
  8474. if(d12 < 0) {
  8475. var v16;
  8476. var v1X2;
  8477. var v1Y2;
  8478. var v1Z2;
  8479. var v24;
  8480. var v2X2;
  8481. var v2Y2;
  8482. var v2Z2;
  8483. var v17 = vec1;
  8484. v1X2 = v17.x;
  8485. v1Y2 = v17.y;
  8486. v1Z2 = v17.z;
  8487. var v18 = vec2;
  8488. v2X2 = v18.x;
  8489. v2Y2 = v18.y;
  8490. v2Z2 = v18.z;
  8491. var v122;
  8492. var v12X2;
  8493. var v12Y2;
  8494. var v12Z2;
  8495. v12X2 = v2X2 - v1X2;
  8496. v12Y2 = v2Y2 - v1Y2;
  8497. v12Z2 = v2Z2 - v1Z2;
  8498. var d1 = v12X2 * v12X2 + v12Y2 * v12Y2 + v12Z2 * v12Z2;
  8499. var t1 = v12X2 * v1X2 + v12Y2 * v1Y2 + v12Z2 * v1Z2;
  8500. t1 = -t1 / d1;
  8501. var b;
  8502. if(t1 < 0) {
  8503. var v19 = closest;
  8504. v19.x = v1X2;
  8505. v19.y = v1Y2;
  8506. v19.z = v1Z2;
  8507. b = 1;
  8508. } else if(t1 > 1) {
  8509. var v20 = closest;
  8510. v20.x = v2X2;
  8511. v20.y = v2Y2;
  8512. v20.z = v2Z2;
  8513. b = 2;
  8514. } else {
  8515. var p1;
  8516. var pX1;
  8517. var pY1;
  8518. var pZ1;
  8519. pX1 = v1X2 + v12X2 * t1;
  8520. pY1 = v1Y2 + v12Y2 * t1;
  8521. pZ1 = v1Z2 + v12Z2 * t1;
  8522. var v25 = closest;
  8523. v25.x = pX1;
  8524. v25.y = pY1;
  8525. v25.z = pZ1;
  8526. b = 3;
  8527. }
  8528. var d2 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  8529. mini = b;
  8530. mind = d2;
  8531. var v26 = closest;
  8532. minvX = v26.x;
  8533. minvY = v26.y;
  8534. minvZ = v26.z;
  8535. }
  8536. if(d23 < 0) {
  8537. var v110;
  8538. var v1X3;
  8539. var v1Y3;
  8540. var v1Z3;
  8541. var v27;
  8542. var v2X3;
  8543. var v2Y3;
  8544. var v2Z3;
  8545. var v28 = vec2;
  8546. v1X3 = v28.x;
  8547. v1Y3 = v28.y;
  8548. v1Z3 = v28.z;
  8549. var v29 = vec3;
  8550. v2X3 = v29.x;
  8551. v2Y3 = v29.y;
  8552. v2Z3 = v29.z;
  8553. var v123;
  8554. var v12X3;
  8555. var v12Y3;
  8556. var v12Z3;
  8557. v12X3 = v2X3 - v1X3;
  8558. v12Y3 = v2Y3 - v1Y3;
  8559. v12Z3 = v2Z3 - v1Z3;
  8560. var d3 = v12X3 * v12X3 + v12Y3 * v12Y3 + v12Z3 * v12Z3;
  8561. var t2 = v12X3 * v1X3 + v12Y3 * v1Y3 + v12Z3 * v1Z3;
  8562. t2 = -t2 / d3;
  8563. var b1;
  8564. if(t2 < 0) {
  8565. var v30 = closest;
  8566. v30.x = v1X3;
  8567. v30.y = v1Y3;
  8568. v30.z = v1Z3;
  8569. b1 = 1;
  8570. } else if(t2 > 1) {
  8571. var v32 = closest;
  8572. v32.x = v2X3;
  8573. v32.y = v2Y3;
  8574. v32.z = v2Z3;
  8575. b1 = 2;
  8576. } else {
  8577. var p2;
  8578. var pX2;
  8579. var pY2;
  8580. var pZ2;
  8581. pX2 = v1X3 + v12X3 * t2;
  8582. pY2 = v1Y3 + v12Y3 * t2;
  8583. pZ2 = v1Z3 + v12Z3 * t2;
  8584. var v33 = closest;
  8585. v33.x = pX2;
  8586. v33.y = pY2;
  8587. v33.z = pZ2;
  8588. b1 = 3;
  8589. }
  8590. var d4 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  8591. if(mind < 0 || d4 < mind) {
  8592. mini = b1 << 1;
  8593. mind = d4;
  8594. var v34 = closest;
  8595. minvX = v34.x;
  8596. minvY = v34.y;
  8597. minvZ = v34.z;
  8598. }
  8599. }
  8600. if(d31 < 0) {
  8601. var v111;
  8602. var v1X4;
  8603. var v1Y4;
  8604. var v1Z4;
  8605. var v210;
  8606. var v2X4;
  8607. var v2Y4;
  8608. var v2Z4;
  8609. var v35 = vec1;
  8610. v1X4 = v35.x;
  8611. v1Y4 = v35.y;
  8612. v1Z4 = v35.z;
  8613. var v36 = vec3;
  8614. v2X4 = v36.x;
  8615. v2Y4 = v36.y;
  8616. v2Z4 = v36.z;
  8617. var v124;
  8618. var v12X4;
  8619. var v12Y4;
  8620. var v12Z4;
  8621. v12X4 = v2X4 - v1X4;
  8622. v12Y4 = v2Y4 - v1Y4;
  8623. v12Z4 = v2Z4 - v1Z4;
  8624. var d5 = v12X4 * v12X4 + v12Y4 * v12Y4 + v12Z4 * v12Z4;
  8625. var t3 = v12X4 * v1X4 + v12Y4 * v1Y4 + v12Z4 * v1Z4;
  8626. t3 = -t3 / d5;
  8627. var b2;
  8628. if(t3 < 0) {
  8629. var v37 = closest;
  8630. v37.x = v1X4;
  8631. v37.y = v1Y4;
  8632. v37.z = v1Z4;
  8633. b2 = 1;
  8634. } else if(t3 > 1) {
  8635. var v38 = closest;
  8636. v38.x = v2X4;
  8637. v38.y = v2Y4;
  8638. v38.z = v2Z4;
  8639. b2 = 2;
  8640. } else {
  8641. var p3;
  8642. var pX3;
  8643. var pY3;
  8644. var pZ3;
  8645. pX3 = v1X4 + v12X4 * t3;
  8646. pY3 = v1Y4 + v12Y4 * t3;
  8647. pZ3 = v1Z4 + v12Z4 * t3;
  8648. var v39 = closest;
  8649. v39.x = pX3;
  8650. v39.y = pY3;
  8651. v39.z = pZ3;
  8652. b2 = 3;
  8653. }
  8654. var d6 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  8655. if(mind < 0 || d6 < mind) {
  8656. mini = b2 & 1 | (b2 & 2) << 1;
  8657. mind = d6;
  8658. var v40 = closest;
  8659. minvX = v40.x;
  8660. minvY = v40.y;
  8661. minvZ = v40.z;
  8662. }
  8663. }
  8664. if(mind > 0) {
  8665. var v41 = closest;
  8666. v41.x = minvX;
  8667. v41.y = minvY;
  8668. v41.z = minvZ;
  8669. v3 = mini;
  8670. } else {
  8671. var l = nX * nX + nY * nY + nZ * nZ;
  8672. if(l > 0) {
  8673. l = 1 / Math.sqrt(l);
  8674. }
  8675. nX *= l;
  8676. nY *= l;
  8677. nZ *= l;
  8678. var dn = v1X1 * nX + v1Y1 * nY + v1Z1 * nZ;
  8679. var l2 = nX * nX + nY * nY + nZ * nZ;
  8680. l2 = dn / l2;
  8681. minvX = nX * l2;
  8682. minvY = nY * l2;
  8683. minvZ = nZ * l2;
  8684. var v42 = closest;
  8685. v42.x = minvX;
  8686. v42.y = minvY;
  8687. v42.z = minvZ;
  8688. v3 = 7;
  8689. }
  8690. break;
  8691. case 4:
  8692. var vec11 = s[0];
  8693. var vec21 = s[1];
  8694. var vec31 = s[2];
  8695. var vec4 = s[3];
  8696. var v112;
  8697. var v1X5;
  8698. var v1Y5;
  8699. var v1Z5;
  8700. var v211;
  8701. var v2X5;
  8702. var v2Y5;
  8703. var v2Z5;
  8704. var v310;
  8705. var v3X1;
  8706. var v3Y1;
  8707. var v3Z1;
  8708. var v43;
  8709. var v4X;
  8710. var v4Y;
  8711. var v4Z;
  8712. var v125;
  8713. var v12X5;
  8714. var v12Y5;
  8715. var v12Z5;
  8716. var v131;
  8717. var v13X;
  8718. var v13Y;
  8719. var v13Z;
  8720. var v141;
  8721. var v14X;
  8722. var v14Y;
  8723. var v14Z;
  8724. var v231;
  8725. var v23X1;
  8726. var v23Y1;
  8727. var v23Z1;
  8728. var v241;
  8729. var v24X;
  8730. var v24Y;
  8731. var v24Z;
  8732. var v341;
  8733. var v34X;
  8734. var v34Y;
  8735. var v34Z;
  8736. var v44 = vec11;
  8737. v1X5 = v44.x;
  8738. v1Y5 = v44.y;
  8739. v1Z5 = v44.z;
  8740. var v45 = vec21;
  8741. v2X5 = v45.x;
  8742. v2Y5 = v45.y;
  8743. v2Z5 = v45.z;
  8744. var v46 = vec31;
  8745. v3X1 = v46.x;
  8746. v3Y1 = v46.y;
  8747. v3Z1 = v46.z;
  8748. var v47 = vec4;
  8749. v4X = v47.x;
  8750. v4Y = v47.y;
  8751. v4Z = v47.z;
  8752. v12X5 = v2X5 - v1X5;
  8753. v12Y5 = v2Y5 - v1Y5;
  8754. v12Z5 = v2Z5 - v1Z5;
  8755. v13X = v3X1 - v1X5;
  8756. v13Y = v3Y1 - v1Y5;
  8757. v13Z = v3Z1 - v1Z5;
  8758. v14X = v4X - v1X5;
  8759. v14Y = v4Y - v1Y5;
  8760. v14Z = v4Z - v1Z5;
  8761. v23X1 = v3X1 - v2X5;
  8762. v23Y1 = v3Y1 - v2Y5;
  8763. v23Z1 = v3Z1 - v2Z5;
  8764. v24X = v4X - v2X5;
  8765. v24Y = v4Y - v2Y5;
  8766. v24Z = v4Z - v2Z5;
  8767. v34X = v4X - v3X1;
  8768. v34Y = v4Y - v3Y1;
  8769. v34Z = v4Z - v3Z1;
  8770. var rev;
  8771. var n123;
  8772. var n123X;
  8773. var n123Y;
  8774. var n123Z;
  8775. var n134;
  8776. var n134X;
  8777. var n134Y;
  8778. var n134Z;
  8779. var n142;
  8780. var n142X;
  8781. var n142Y;
  8782. var n142Z;
  8783. var n243;
  8784. var n243X;
  8785. var n243Y;
  8786. var n243Z;
  8787. var n1;
  8788. var nX1;
  8789. var nY1;
  8790. var nZ1;
  8791. n123X = v12Y5 * v13Z - v12Z5 * v13Y;
  8792. n123Y = v12Z5 * v13X - v12X5 * v13Z;
  8793. n123Z = v12X5 * v13Y - v12Y5 * v13X;
  8794. n134X = v13Y * v14Z - v13Z * v14Y;
  8795. n134Y = v13Z * v14X - v13X * v14Z;
  8796. n134Z = v13X * v14Y - v13Y * v14X;
  8797. n142X = v14Y * v12Z5 - v14Z * v12Y5;
  8798. n142Y = v14Z * v12X5 - v14X * v12Z5;
  8799. n142Z = v14X * v12Y5 - v14Y * v12X5;
  8800. n243X = v24Y * v23Z1 - v24Z * v23Y1;
  8801. n243Y = v24Z * v23X1 - v24X * v23Z1;
  8802. n243Z = v24X * v23Y1 - v24Y * v23X1;
  8803. var sign = v12X5 * n243X + v12Y5 * n243Y + v12Z5 * n243Z > 0 ? 1 : -1;
  8804. var d123 = v1X5 * n123X + v1Y5 * n123Y + v1Z5 * n123Z;
  8805. var d134 = v1X5 * n134X + v1Y5 * n134Y + v1Z5 * n134Z;
  8806. var d142 = v1X5 * n142X + v1Y5 * n142Y + v1Z5 * n142Z;
  8807. var d243 = v2X5 * n243X + v2Y5 * n243Y + v2Z5 * n243Z;
  8808. var mind1 = -1;
  8809. var minv1;
  8810. var minvX1;
  8811. var minvY1;
  8812. var minvZ1;
  8813. var mini1 = 0;
  8814. minvX1 = 0;
  8815. minvY1 = 0;
  8816. minvZ1 = 0;
  8817. if(d123 * sign < 0) {
  8818. var v113;
  8819. var v1X6;
  8820. var v1Y6;
  8821. var v1Z6;
  8822. var v212;
  8823. var v2X6;
  8824. var v2Y6;
  8825. var v2Z6;
  8826. var v312;
  8827. var v3X2;
  8828. var v3Y2;
  8829. var v3Z2;
  8830. var v126;
  8831. var v12X6;
  8832. var v12Y6;
  8833. var v12Z6;
  8834. var v232;
  8835. var v23X2;
  8836. var v23Y2;
  8837. var v23Z2;
  8838. var v313;
  8839. var v31X1;
  8840. var v31Y1;
  8841. var v31Z1;
  8842. var v48 = vec11;
  8843. v1X6 = v48.x;
  8844. v1Y6 = v48.y;
  8845. v1Z6 = v48.z;
  8846. var v49 = vec21;
  8847. v2X6 = v49.x;
  8848. v2Y6 = v49.y;
  8849. v2Z6 = v49.z;
  8850. var v50 = vec31;
  8851. v3X2 = v50.x;
  8852. v3Y2 = v50.y;
  8853. v3Z2 = v50.z;
  8854. v12X6 = v2X6 - v1X6;
  8855. v12Y6 = v2Y6 - v1Y6;
  8856. v12Z6 = v2Z6 - v1Z6;
  8857. v23X2 = v3X2 - v2X6;
  8858. v23Y2 = v3Y2 - v2Y6;
  8859. v23Z2 = v3Z2 - v2Z6;
  8860. v31X1 = v1X6 - v3X2;
  8861. v31Y1 = v1Y6 - v3Y2;
  8862. v31Z1 = v1Z6 - v3Z2;
  8863. var n2;
  8864. var nX2;
  8865. var nY2;
  8866. var nZ2;
  8867. nX2 = v12Y6 * v23Z2 - v12Z6 * v23Y2;
  8868. nY2 = v12Z6 * v23X2 - v12X6 * v23Z2;
  8869. nZ2 = v12X6 * v23Y2 - v12Y6 * v23X2;
  8870. var n121;
  8871. var n12X1;
  8872. var n12Y1;
  8873. var n12Z1;
  8874. var n231;
  8875. var n23X1;
  8876. var n23Y1;
  8877. var n23Z1;
  8878. var n311;
  8879. var n31X1;
  8880. var n31Y1;
  8881. var n31Z1;
  8882. n12X1 = v12Y6 * nZ2 - v12Z6 * nY2;
  8883. n12Y1 = v12Z6 * nX2 - v12X6 * nZ2;
  8884. n12Z1 = v12X6 * nY2 - v12Y6 * nX2;
  8885. n23X1 = v23Y2 * nZ2 - v23Z2 * nY2;
  8886. n23Y1 = v23Z2 * nX2 - v23X2 * nZ2;
  8887. n23Z1 = v23X2 * nY2 - v23Y2 * nX2;
  8888. n31X1 = v31Y1 * nZ2 - v31Z1 * nY2;
  8889. n31Y1 = v31Z1 * nX2 - v31X1 * nZ2;
  8890. n31Z1 = v31X1 * nY2 - v31Y1 * nX2;
  8891. var d121 = v1X6 * n12X1 + v1Y6 * n12Y1 + v1Z6 * n12Z1;
  8892. var d231 = v2X6 * n23X1 + v2Y6 * n23Y1 + v2Z6 * n23Z1;
  8893. var d311 = v3X2 * n31X1 + v3Y2 * n31Y1 + v3Z2 * n31Z1;
  8894. var mind2 = -1;
  8895. var minv2;
  8896. var minvX2;
  8897. var minvY2;
  8898. var minvZ2;
  8899. var mini2 = 0;
  8900. minvX2 = 0;
  8901. minvY2 = 0;
  8902. minvZ2 = 0;
  8903. if(d121 < 0) {
  8904. var v114;
  8905. var v1X7;
  8906. var v1Y7;
  8907. var v1Z7;
  8908. var v213;
  8909. var v2X7;
  8910. var v2Y7;
  8911. var v2Z7;
  8912. var v51 = vec11;
  8913. v1X7 = v51.x;
  8914. v1Y7 = v51.y;
  8915. v1Z7 = v51.z;
  8916. var v52 = vec21;
  8917. v2X7 = v52.x;
  8918. v2Y7 = v52.y;
  8919. v2Z7 = v52.z;
  8920. var v127;
  8921. var v12X7;
  8922. var v12Y7;
  8923. var v12Z7;
  8924. v12X7 = v2X7 - v1X7;
  8925. v12Y7 = v2Y7 - v1Y7;
  8926. v12Z7 = v2Z7 - v1Z7;
  8927. var d7 = v12X7 * v12X7 + v12Y7 * v12Y7 + v12Z7 * v12Z7;
  8928. var t4 = v12X7 * v1X7 + v12Y7 * v1Y7 + v12Z7 * v1Z7;
  8929. t4 = -t4 / d7;
  8930. var b3;
  8931. if(t4 < 0) {
  8932. var v53 = closest;
  8933. v53.x = v1X7;
  8934. v53.y = v1Y7;
  8935. v53.z = v1Z7;
  8936. b3 = 1;
  8937. } else if(t4 > 1) {
  8938. var v54 = closest;
  8939. v54.x = v2X7;
  8940. v54.y = v2Y7;
  8941. v54.z = v2Z7;
  8942. b3 = 2;
  8943. } else {
  8944. var p4;
  8945. var pX4;
  8946. var pY4;
  8947. var pZ4;
  8948. pX4 = v1X7 + v12X7 * t4;
  8949. pY4 = v1Y7 + v12Y7 * t4;
  8950. pZ4 = v1Z7 + v12Z7 * t4;
  8951. var v55 = closest;
  8952. v55.x = pX4;
  8953. v55.y = pY4;
  8954. v55.z = pZ4;
  8955. b3 = 3;
  8956. }
  8957. var d8 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  8958. mini2 = b3;
  8959. mind2 = d8;
  8960. var v56 = closest;
  8961. minvX2 = v56.x;
  8962. minvY2 = v56.y;
  8963. minvZ2 = v56.z;
  8964. }
  8965. if(d231 < 0) {
  8966. var v115;
  8967. var v1X8;
  8968. var v1Y8;
  8969. var v1Z8;
  8970. var v214;
  8971. var v2X8;
  8972. var v2Y8;
  8973. var v2Z8;
  8974. var v57 = vec21;
  8975. v1X8 = v57.x;
  8976. v1Y8 = v57.y;
  8977. v1Z8 = v57.z;
  8978. var v58 = vec31;
  8979. v2X8 = v58.x;
  8980. v2Y8 = v58.y;
  8981. v2Z8 = v58.z;
  8982. var v128;
  8983. var v12X8;
  8984. var v12Y8;
  8985. var v12Z8;
  8986. v12X8 = v2X8 - v1X8;
  8987. v12Y8 = v2Y8 - v1Y8;
  8988. v12Z8 = v2Z8 - v1Z8;
  8989. var d9 = v12X8 * v12X8 + v12Y8 * v12Y8 + v12Z8 * v12Z8;
  8990. var t5 = v12X8 * v1X8 + v12Y8 * v1Y8 + v12Z8 * v1Z8;
  8991. t5 = -t5 / d9;
  8992. var b4;
  8993. if(t5 < 0) {
  8994. var v59 = closest;
  8995. v59.x = v1X8;
  8996. v59.y = v1Y8;
  8997. v59.z = v1Z8;
  8998. b4 = 1;
  8999. } else if(t5 > 1) {
  9000. var v60 = closest;
  9001. v60.x = v2X8;
  9002. v60.y = v2Y8;
  9003. v60.z = v2Z8;
  9004. b4 = 2;
  9005. } else {
  9006. var p5;
  9007. var pX5;
  9008. var pY5;
  9009. var pZ5;
  9010. pX5 = v1X8 + v12X8 * t5;
  9011. pY5 = v1Y8 + v12Y8 * t5;
  9012. pZ5 = v1Z8 + v12Z8 * t5;
  9013. var v61 = closest;
  9014. v61.x = pX5;
  9015. v61.y = pY5;
  9016. v61.z = pZ5;
  9017. b4 = 3;
  9018. }
  9019. var d10 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9020. if(mind2 < 0 || d10 < mind2) {
  9021. mini2 = b4 << 1;
  9022. mind2 = d10;
  9023. var v62 = closest;
  9024. minvX2 = v62.x;
  9025. minvY2 = v62.y;
  9026. minvZ2 = v62.z;
  9027. }
  9028. }
  9029. if(d311 < 0) {
  9030. var v116;
  9031. var v1X9;
  9032. var v1Y9;
  9033. var v1Z9;
  9034. var v215;
  9035. var v2X9;
  9036. var v2Y9;
  9037. var v2Z9;
  9038. var v63 = vec11;
  9039. v1X9 = v63.x;
  9040. v1Y9 = v63.y;
  9041. v1Z9 = v63.z;
  9042. var v64 = vec31;
  9043. v2X9 = v64.x;
  9044. v2Y9 = v64.y;
  9045. v2Z9 = v64.z;
  9046. var v129;
  9047. var v12X9;
  9048. var v12Y9;
  9049. var v12Z9;
  9050. v12X9 = v2X9 - v1X9;
  9051. v12Y9 = v2Y9 - v1Y9;
  9052. v12Z9 = v2Z9 - v1Z9;
  9053. var d11 = v12X9 * v12X9 + v12Y9 * v12Y9 + v12Z9 * v12Z9;
  9054. var t6 = v12X9 * v1X9 + v12Y9 * v1Y9 + v12Z9 * v1Z9;
  9055. t6 = -t6 / d11;
  9056. var b5;
  9057. if(t6 < 0) {
  9058. var v65 = closest;
  9059. v65.x = v1X9;
  9060. v65.y = v1Y9;
  9061. v65.z = v1Z9;
  9062. b5 = 1;
  9063. } else if(t6 > 1) {
  9064. var v66 = closest;
  9065. v66.x = v2X9;
  9066. v66.y = v2Y9;
  9067. v66.z = v2Z9;
  9068. b5 = 2;
  9069. } else {
  9070. var p6;
  9071. var pX6;
  9072. var pY6;
  9073. var pZ6;
  9074. pX6 = v1X9 + v12X9 * t6;
  9075. pY6 = v1Y9 + v12Y9 * t6;
  9076. pZ6 = v1Z9 + v12Z9 * t6;
  9077. var v67 = closest;
  9078. v67.x = pX6;
  9079. v67.y = pY6;
  9080. v67.z = pZ6;
  9081. b5 = 3;
  9082. }
  9083. var d13 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9084. if(mind2 < 0 || d13 < mind2) {
  9085. mini2 = b5 & 1 | (b5 & 2) << 1;
  9086. mind2 = d13;
  9087. var v68 = closest;
  9088. minvX2 = v68.x;
  9089. minvY2 = v68.y;
  9090. minvZ2 = v68.z;
  9091. }
  9092. }
  9093. var b6;
  9094. if(mind2 > 0) {
  9095. var v69 = closest;
  9096. v69.x = minvX2;
  9097. v69.y = minvY2;
  9098. v69.z = minvZ2;
  9099. b6 = mini2;
  9100. } else {
  9101. var l1 = nX2 * nX2 + nY2 * nY2 + nZ2 * nZ2;
  9102. if(l1 > 0) {
  9103. l1 = 1 / Math.sqrt(l1);
  9104. }
  9105. nX2 *= l1;
  9106. nY2 *= l1;
  9107. nZ2 *= l1;
  9108. var dn1 = v1X6 * nX2 + v1Y6 * nY2 + v1Z6 * nZ2;
  9109. var l21 = nX2 * nX2 + nY2 * nY2 + nZ2 * nZ2;
  9110. l21 = dn1 / l21;
  9111. minvX2 = nX2 * l21;
  9112. minvY2 = nY2 * l21;
  9113. minvZ2 = nZ2 * l21;
  9114. var v70 = closest;
  9115. v70.x = minvX2;
  9116. v70.y = minvY2;
  9117. v70.z = minvZ2;
  9118. b6 = 7;
  9119. }
  9120. var d14 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9121. mini1 = b6;
  9122. mind1 = d14;
  9123. var v71 = closest;
  9124. minvX1 = v71.x;
  9125. minvY1 = v71.y;
  9126. minvZ1 = v71.z;
  9127. }
  9128. if(d134 * sign < 0) {
  9129. var v117;
  9130. var v1X10;
  9131. var v1Y10;
  9132. var v1Z10;
  9133. var v216;
  9134. var v2X10;
  9135. var v2Y10;
  9136. var v2Z10;
  9137. var v314;
  9138. var v3X3;
  9139. var v3Y3;
  9140. var v3Z3;
  9141. var v1210;
  9142. var v12X10;
  9143. var v12Y10;
  9144. var v12Z10;
  9145. var v233;
  9146. var v23X3;
  9147. var v23Y3;
  9148. var v23Z3;
  9149. var v315;
  9150. var v31X2;
  9151. var v31Y2;
  9152. var v31Z2;
  9153. var v72 = vec11;
  9154. v1X10 = v72.x;
  9155. v1Y10 = v72.y;
  9156. v1Z10 = v72.z;
  9157. var v73 = vec31;
  9158. v2X10 = v73.x;
  9159. v2Y10 = v73.y;
  9160. v2Z10 = v73.z;
  9161. var v74 = vec4;
  9162. v3X3 = v74.x;
  9163. v3Y3 = v74.y;
  9164. v3Z3 = v74.z;
  9165. v12X10 = v2X10 - v1X10;
  9166. v12Y10 = v2Y10 - v1Y10;
  9167. v12Z10 = v2Z10 - v1Z10;
  9168. v23X3 = v3X3 - v2X10;
  9169. v23Y3 = v3Y3 - v2Y10;
  9170. v23Z3 = v3Z3 - v2Z10;
  9171. v31X2 = v1X10 - v3X3;
  9172. v31Y2 = v1Y10 - v3Y3;
  9173. v31Z2 = v1Z10 - v3Z3;
  9174. var n3;
  9175. var nX3;
  9176. var nY3;
  9177. var nZ3;
  9178. nX3 = v12Y10 * v23Z3 - v12Z10 * v23Y3;
  9179. nY3 = v12Z10 * v23X3 - v12X10 * v23Z3;
  9180. nZ3 = v12X10 * v23Y3 - v12Y10 * v23X3;
  9181. var n122;
  9182. var n12X2;
  9183. var n12Y2;
  9184. var n12Z2;
  9185. var n232;
  9186. var n23X2;
  9187. var n23Y2;
  9188. var n23Z2;
  9189. var n312;
  9190. var n31X2;
  9191. var n31Y2;
  9192. var n31Z2;
  9193. n12X2 = v12Y10 * nZ3 - v12Z10 * nY3;
  9194. n12Y2 = v12Z10 * nX3 - v12X10 * nZ3;
  9195. n12Z2 = v12X10 * nY3 - v12Y10 * nX3;
  9196. n23X2 = v23Y3 * nZ3 - v23Z3 * nY3;
  9197. n23Y2 = v23Z3 * nX3 - v23X3 * nZ3;
  9198. n23Z2 = v23X3 * nY3 - v23Y3 * nX3;
  9199. n31X2 = v31Y2 * nZ3 - v31Z2 * nY3;
  9200. n31Y2 = v31Z2 * nX3 - v31X2 * nZ3;
  9201. n31Z2 = v31X2 * nY3 - v31Y2 * nX3;
  9202. var d122 = v1X10 * n12X2 + v1Y10 * n12Y2 + v1Z10 * n12Z2;
  9203. var d232 = v2X10 * n23X2 + v2Y10 * n23Y2 + v2Z10 * n23Z2;
  9204. var d312 = v3X3 * n31X2 + v3Y3 * n31Y2 + v3Z3 * n31Z2;
  9205. var mind3 = -1;
  9206. var minv3;
  9207. var minvX3;
  9208. var minvY3;
  9209. var minvZ3;
  9210. var mini3 = 0;
  9211. minvX3 = 0;
  9212. minvY3 = 0;
  9213. minvZ3 = 0;
  9214. if(d122 < 0) {
  9215. var v118;
  9216. var v1X11;
  9217. var v1Y11;
  9218. var v1Z11;
  9219. var v217;
  9220. var v2X11;
  9221. var v2Y11;
  9222. var v2Z11;
  9223. var v75 = vec11;
  9224. v1X11 = v75.x;
  9225. v1Y11 = v75.y;
  9226. v1Z11 = v75.z;
  9227. var v76 = vec31;
  9228. v2X11 = v76.x;
  9229. v2Y11 = v76.y;
  9230. v2Z11 = v76.z;
  9231. var v1211;
  9232. var v12X11;
  9233. var v12Y11;
  9234. var v12Z11;
  9235. v12X11 = v2X11 - v1X11;
  9236. v12Y11 = v2Y11 - v1Y11;
  9237. v12Z11 = v2Z11 - v1Z11;
  9238. var d15 = v12X11 * v12X11 + v12Y11 * v12Y11 + v12Z11 * v12Z11;
  9239. var t7 = v12X11 * v1X11 + v12Y11 * v1Y11 + v12Z11 * v1Z11;
  9240. t7 = -t7 / d15;
  9241. var b7;
  9242. if(t7 < 0) {
  9243. var v77 = closest;
  9244. v77.x = v1X11;
  9245. v77.y = v1Y11;
  9246. v77.z = v1Z11;
  9247. b7 = 1;
  9248. } else if(t7 > 1) {
  9249. var v78 = closest;
  9250. v78.x = v2X11;
  9251. v78.y = v2Y11;
  9252. v78.z = v2Z11;
  9253. b7 = 2;
  9254. } else {
  9255. var p7;
  9256. var pX7;
  9257. var pY7;
  9258. var pZ7;
  9259. pX7 = v1X11 + v12X11 * t7;
  9260. pY7 = v1Y11 + v12Y11 * t7;
  9261. pZ7 = v1Z11 + v12Z11 * t7;
  9262. var v79 = closest;
  9263. v79.x = pX7;
  9264. v79.y = pY7;
  9265. v79.z = pZ7;
  9266. b7 = 3;
  9267. }
  9268. var d16 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9269. mini3 = b7;
  9270. mind3 = d16;
  9271. var v80 = closest;
  9272. minvX3 = v80.x;
  9273. minvY3 = v80.y;
  9274. minvZ3 = v80.z;
  9275. }
  9276. if(d232 < 0) {
  9277. var v119;
  9278. var v1X12;
  9279. var v1Y12;
  9280. var v1Z12;
  9281. var v218;
  9282. var v2X12;
  9283. var v2Y12;
  9284. var v2Z12;
  9285. var v81 = vec31;
  9286. v1X12 = v81.x;
  9287. v1Y12 = v81.y;
  9288. v1Z12 = v81.z;
  9289. var v82 = vec4;
  9290. v2X12 = v82.x;
  9291. v2Y12 = v82.y;
  9292. v2Z12 = v82.z;
  9293. var v1212;
  9294. var v12X12;
  9295. var v12Y12;
  9296. var v12Z12;
  9297. v12X12 = v2X12 - v1X12;
  9298. v12Y12 = v2Y12 - v1Y12;
  9299. v12Z12 = v2Z12 - v1Z12;
  9300. var d17 = v12X12 * v12X12 + v12Y12 * v12Y12 + v12Z12 * v12Z12;
  9301. var t8 = v12X12 * v1X12 + v12Y12 * v1Y12 + v12Z12 * v1Z12;
  9302. t8 = -t8 / d17;
  9303. var b8;
  9304. if(t8 < 0) {
  9305. var v83 = closest;
  9306. v83.x = v1X12;
  9307. v83.y = v1Y12;
  9308. v83.z = v1Z12;
  9309. b8 = 1;
  9310. } else if(t8 > 1) {
  9311. var v84 = closest;
  9312. v84.x = v2X12;
  9313. v84.y = v2Y12;
  9314. v84.z = v2Z12;
  9315. b8 = 2;
  9316. } else {
  9317. var p8;
  9318. var pX8;
  9319. var pY8;
  9320. var pZ8;
  9321. pX8 = v1X12 + v12X12 * t8;
  9322. pY8 = v1Y12 + v12Y12 * t8;
  9323. pZ8 = v1Z12 + v12Z12 * t8;
  9324. var v85 = closest;
  9325. v85.x = pX8;
  9326. v85.y = pY8;
  9327. v85.z = pZ8;
  9328. b8 = 3;
  9329. }
  9330. var d18 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9331. if(mind3 < 0 || d18 < mind3) {
  9332. mini3 = b8 << 1;
  9333. mind3 = d18;
  9334. var v86 = closest;
  9335. minvX3 = v86.x;
  9336. minvY3 = v86.y;
  9337. minvZ3 = v86.z;
  9338. }
  9339. }
  9340. if(d312 < 0) {
  9341. var v120;
  9342. var v1X13;
  9343. var v1Y13;
  9344. var v1Z13;
  9345. var v219;
  9346. var v2X13;
  9347. var v2Y13;
  9348. var v2Z13;
  9349. var v87 = vec11;
  9350. v1X13 = v87.x;
  9351. v1Y13 = v87.y;
  9352. v1Z13 = v87.z;
  9353. var v88 = vec4;
  9354. v2X13 = v88.x;
  9355. v2Y13 = v88.y;
  9356. v2Z13 = v88.z;
  9357. var v1213;
  9358. var v12X13;
  9359. var v12Y13;
  9360. var v12Z13;
  9361. v12X13 = v2X13 - v1X13;
  9362. v12Y13 = v2Y13 - v1Y13;
  9363. v12Z13 = v2Z13 - v1Z13;
  9364. var d19 = v12X13 * v12X13 + v12Y13 * v12Y13 + v12Z13 * v12Z13;
  9365. var t9 = v12X13 * v1X13 + v12Y13 * v1Y13 + v12Z13 * v1Z13;
  9366. t9 = -t9 / d19;
  9367. var b9;
  9368. if(t9 < 0) {
  9369. var v89 = closest;
  9370. v89.x = v1X13;
  9371. v89.y = v1Y13;
  9372. v89.z = v1Z13;
  9373. b9 = 1;
  9374. } else if(t9 > 1) {
  9375. var v90 = closest;
  9376. v90.x = v2X13;
  9377. v90.y = v2Y13;
  9378. v90.z = v2Z13;
  9379. b9 = 2;
  9380. } else {
  9381. var p9;
  9382. var pX9;
  9383. var pY9;
  9384. var pZ9;
  9385. pX9 = v1X13 + v12X13 * t9;
  9386. pY9 = v1Y13 + v12Y13 * t9;
  9387. pZ9 = v1Z13 + v12Z13 * t9;
  9388. var v91 = closest;
  9389. v91.x = pX9;
  9390. v91.y = pY9;
  9391. v91.z = pZ9;
  9392. b9 = 3;
  9393. }
  9394. var d20 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9395. if(mind3 < 0 || d20 < mind3) {
  9396. mini3 = b9 & 1 | (b9 & 2) << 1;
  9397. mind3 = d20;
  9398. var v92 = closest;
  9399. minvX3 = v92.x;
  9400. minvY3 = v92.y;
  9401. minvZ3 = v92.z;
  9402. }
  9403. }
  9404. var b10;
  9405. if(mind3 > 0) {
  9406. var v93 = closest;
  9407. v93.x = minvX3;
  9408. v93.y = minvY3;
  9409. v93.z = minvZ3;
  9410. b10 = mini3;
  9411. } else {
  9412. var l3 = nX3 * nX3 + nY3 * nY3 + nZ3 * nZ3;
  9413. if(l3 > 0) {
  9414. l3 = 1 / Math.sqrt(l3);
  9415. }
  9416. nX3 *= l3;
  9417. nY3 *= l3;
  9418. nZ3 *= l3;
  9419. var dn2 = v1X10 * nX3 + v1Y10 * nY3 + v1Z10 * nZ3;
  9420. var l22 = nX3 * nX3 + nY3 * nY3 + nZ3 * nZ3;
  9421. l22 = dn2 / l22;
  9422. minvX3 = nX3 * l22;
  9423. minvY3 = nY3 * l22;
  9424. minvZ3 = nZ3 * l22;
  9425. var v94 = closest;
  9426. v94.x = minvX3;
  9427. v94.y = minvY3;
  9428. v94.z = minvZ3;
  9429. b10 = 7;
  9430. }
  9431. var d21 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9432. if(mind1 < 0 || d21 < mind1) {
  9433. mini1 = b10 & 1 | (b10 & 6) << 1;
  9434. mind1 = d21;
  9435. var v95 = closest;
  9436. minvX1 = v95.x;
  9437. minvY1 = v95.y;
  9438. minvZ1 = v95.z;
  9439. }
  9440. }
  9441. if(d142 * sign < 0) {
  9442. var v130;
  9443. var v1X14;
  9444. var v1Y14;
  9445. var v1Z14;
  9446. var v220;
  9447. var v2X14;
  9448. var v2Y14;
  9449. var v2Z14;
  9450. var v316;
  9451. var v3X4;
  9452. var v3Y4;
  9453. var v3Z4;
  9454. var v1214;
  9455. var v12X14;
  9456. var v12Y14;
  9457. var v12Z14;
  9458. var v234;
  9459. var v23X4;
  9460. var v23Y4;
  9461. var v23Z4;
  9462. var v317;
  9463. var v31X3;
  9464. var v31Y3;
  9465. var v31Z3;
  9466. var v96 = vec11;
  9467. v1X14 = v96.x;
  9468. v1Y14 = v96.y;
  9469. v1Z14 = v96.z;
  9470. var v97 = vec21;
  9471. v2X14 = v97.x;
  9472. v2Y14 = v97.y;
  9473. v2Z14 = v97.z;
  9474. var v98 = vec4;
  9475. v3X4 = v98.x;
  9476. v3Y4 = v98.y;
  9477. v3Z4 = v98.z;
  9478. v12X14 = v2X14 - v1X14;
  9479. v12Y14 = v2Y14 - v1Y14;
  9480. v12Z14 = v2Z14 - v1Z14;
  9481. v23X4 = v3X4 - v2X14;
  9482. v23Y4 = v3Y4 - v2Y14;
  9483. v23Z4 = v3Z4 - v2Z14;
  9484. v31X3 = v1X14 - v3X4;
  9485. v31Y3 = v1Y14 - v3Y4;
  9486. v31Z3 = v1Z14 - v3Z4;
  9487. var n4;
  9488. var nX4;
  9489. var nY4;
  9490. var nZ4;
  9491. nX4 = v12Y14 * v23Z4 - v12Z14 * v23Y4;
  9492. nY4 = v12Z14 * v23X4 - v12X14 * v23Z4;
  9493. nZ4 = v12X14 * v23Y4 - v12Y14 * v23X4;
  9494. var n124;
  9495. var n12X3;
  9496. var n12Y3;
  9497. var n12Z3;
  9498. var n233;
  9499. var n23X3;
  9500. var n23Y3;
  9501. var n23Z3;
  9502. var n313;
  9503. var n31X3;
  9504. var n31Y3;
  9505. var n31Z3;
  9506. n12X3 = v12Y14 * nZ4 - v12Z14 * nY4;
  9507. n12Y3 = v12Z14 * nX4 - v12X14 * nZ4;
  9508. n12Z3 = v12X14 * nY4 - v12Y14 * nX4;
  9509. n23X3 = v23Y4 * nZ4 - v23Z4 * nY4;
  9510. n23Y3 = v23Z4 * nX4 - v23X4 * nZ4;
  9511. n23Z3 = v23X4 * nY4 - v23Y4 * nX4;
  9512. n31X3 = v31Y3 * nZ4 - v31Z3 * nY4;
  9513. n31Y3 = v31Z3 * nX4 - v31X3 * nZ4;
  9514. n31Z3 = v31X3 * nY4 - v31Y3 * nX4;
  9515. var d124 = v1X14 * n12X3 + v1Y14 * n12Y3 + v1Z14 * n12Z3;
  9516. var d233 = v2X14 * n23X3 + v2Y14 * n23Y3 + v2Z14 * n23Z3;
  9517. var d313 = v3X4 * n31X3 + v3Y4 * n31Y3 + v3Z4 * n31Z3;
  9518. var mind4 = -1;
  9519. var minv4;
  9520. var minvX4;
  9521. var minvY4;
  9522. var minvZ4;
  9523. var mini4 = 0;
  9524. minvX4 = 0;
  9525. minvY4 = 0;
  9526. minvZ4 = 0;
  9527. if(d124 < 0) {
  9528. var v132;
  9529. var v1X15;
  9530. var v1Y15;
  9531. var v1Z15;
  9532. var v221;
  9533. var v2X15;
  9534. var v2Y15;
  9535. var v2Z15;
  9536. var v99 = vec11;
  9537. v1X15 = v99.x;
  9538. v1Y15 = v99.y;
  9539. v1Z15 = v99.z;
  9540. var v100 = vec21;
  9541. v2X15 = v100.x;
  9542. v2Y15 = v100.y;
  9543. v2Z15 = v100.z;
  9544. var v1215;
  9545. var v12X15;
  9546. var v12Y15;
  9547. var v12Z15;
  9548. v12X15 = v2X15 - v1X15;
  9549. v12Y15 = v2Y15 - v1Y15;
  9550. v12Z15 = v2Z15 - v1Z15;
  9551. var d22 = v12X15 * v12X15 + v12Y15 * v12Y15 + v12Z15 * v12Z15;
  9552. var t10 = v12X15 * v1X15 + v12Y15 * v1Y15 + v12Z15 * v1Z15;
  9553. t10 = -t10 / d22;
  9554. var b11;
  9555. if(t10 < 0) {
  9556. var v101 = closest;
  9557. v101.x = v1X15;
  9558. v101.y = v1Y15;
  9559. v101.z = v1Z15;
  9560. b11 = 1;
  9561. } else if(t10 > 1) {
  9562. var v102 = closest;
  9563. v102.x = v2X15;
  9564. v102.y = v2Y15;
  9565. v102.z = v2Z15;
  9566. b11 = 2;
  9567. } else {
  9568. var p10;
  9569. var pX10;
  9570. var pY10;
  9571. var pZ10;
  9572. pX10 = v1X15 + v12X15 * t10;
  9573. pY10 = v1Y15 + v12Y15 * t10;
  9574. pZ10 = v1Z15 + v12Z15 * t10;
  9575. var v103 = closest;
  9576. v103.x = pX10;
  9577. v103.y = pY10;
  9578. v103.z = pZ10;
  9579. b11 = 3;
  9580. }
  9581. var d24 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9582. mini4 = b11;
  9583. mind4 = d24;
  9584. var v104 = closest;
  9585. minvX4 = v104.x;
  9586. minvY4 = v104.y;
  9587. minvZ4 = v104.z;
  9588. }
  9589. if(d233 < 0) {
  9590. var v133;
  9591. var v1X16;
  9592. var v1Y16;
  9593. var v1Z16;
  9594. var v222;
  9595. var v2X16;
  9596. var v2Y16;
  9597. var v2Z16;
  9598. var v105 = vec21;
  9599. v1X16 = v105.x;
  9600. v1Y16 = v105.y;
  9601. v1Z16 = v105.z;
  9602. var v106 = vec4;
  9603. v2X16 = v106.x;
  9604. v2Y16 = v106.y;
  9605. v2Z16 = v106.z;
  9606. var v1216;
  9607. var v12X16;
  9608. var v12Y16;
  9609. var v12Z16;
  9610. v12X16 = v2X16 - v1X16;
  9611. v12Y16 = v2Y16 - v1Y16;
  9612. v12Z16 = v2Z16 - v1Z16;
  9613. var d25 = v12X16 * v12X16 + v12Y16 * v12Y16 + v12Z16 * v12Z16;
  9614. var t11 = v12X16 * v1X16 + v12Y16 * v1Y16 + v12Z16 * v1Z16;
  9615. t11 = -t11 / d25;
  9616. var b12;
  9617. if(t11 < 0) {
  9618. var v107 = closest;
  9619. v107.x = v1X16;
  9620. v107.y = v1Y16;
  9621. v107.z = v1Z16;
  9622. b12 = 1;
  9623. } else if(t11 > 1) {
  9624. var v108 = closest;
  9625. v108.x = v2X16;
  9626. v108.y = v2Y16;
  9627. v108.z = v2Z16;
  9628. b12 = 2;
  9629. } else {
  9630. var p11;
  9631. var pX11;
  9632. var pY11;
  9633. var pZ11;
  9634. pX11 = v1X16 + v12X16 * t11;
  9635. pY11 = v1Y16 + v12Y16 * t11;
  9636. pZ11 = v1Z16 + v12Z16 * t11;
  9637. var v109 = closest;
  9638. v109.x = pX11;
  9639. v109.y = pY11;
  9640. v109.z = pZ11;
  9641. b12 = 3;
  9642. }
  9643. var d26 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9644. if(mind4 < 0 || d26 < mind4) {
  9645. mini4 = b12 << 1;
  9646. mind4 = d26;
  9647. var v134 = closest;
  9648. minvX4 = v134.x;
  9649. minvY4 = v134.y;
  9650. minvZ4 = v134.z;
  9651. }
  9652. }
  9653. if(d313 < 0) {
  9654. var v135;
  9655. var v1X17;
  9656. var v1Y17;
  9657. var v1Z17;
  9658. var v223;
  9659. var v2X17;
  9660. var v2Y17;
  9661. var v2Z17;
  9662. var v136 = vec11;
  9663. v1X17 = v136.x;
  9664. v1Y17 = v136.y;
  9665. v1Z17 = v136.z;
  9666. var v137 = vec4;
  9667. v2X17 = v137.x;
  9668. v2Y17 = v137.y;
  9669. v2Z17 = v137.z;
  9670. var v1217;
  9671. var v12X17;
  9672. var v12Y17;
  9673. var v12Z17;
  9674. v12X17 = v2X17 - v1X17;
  9675. v12Y17 = v2Y17 - v1Y17;
  9676. v12Z17 = v2Z17 - v1Z17;
  9677. var d27 = v12X17 * v12X17 + v12Y17 * v12Y17 + v12Z17 * v12Z17;
  9678. var t12 = v12X17 * v1X17 + v12Y17 * v1Y17 + v12Z17 * v1Z17;
  9679. t12 = -t12 / d27;
  9680. var b13;
  9681. if(t12 < 0) {
  9682. var v138 = closest;
  9683. v138.x = v1X17;
  9684. v138.y = v1Y17;
  9685. v138.z = v1Z17;
  9686. b13 = 1;
  9687. } else if(t12 > 1) {
  9688. var v139 = closest;
  9689. v139.x = v2X17;
  9690. v139.y = v2Y17;
  9691. v139.z = v2Z17;
  9692. b13 = 2;
  9693. } else {
  9694. var p12;
  9695. var pX12;
  9696. var pY12;
  9697. var pZ12;
  9698. pX12 = v1X17 + v12X17 * t12;
  9699. pY12 = v1Y17 + v12Y17 * t12;
  9700. pZ12 = v1Z17 + v12Z17 * t12;
  9701. var v140 = closest;
  9702. v140.x = pX12;
  9703. v140.y = pY12;
  9704. v140.z = pZ12;
  9705. b13 = 3;
  9706. }
  9707. var d28 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9708. if(mind4 < 0 || d28 < mind4) {
  9709. mini4 = b13 & 1 | (b13 & 2) << 1;
  9710. mind4 = d28;
  9711. var v142 = closest;
  9712. minvX4 = v142.x;
  9713. minvY4 = v142.y;
  9714. minvZ4 = v142.z;
  9715. }
  9716. }
  9717. var b14;
  9718. if(mind4 > 0) {
  9719. var v143 = closest;
  9720. v143.x = minvX4;
  9721. v143.y = minvY4;
  9722. v143.z = minvZ4;
  9723. b14 = mini4;
  9724. } else {
  9725. var l4 = nX4 * nX4 + nY4 * nY4 + nZ4 * nZ4;
  9726. if(l4 > 0) {
  9727. l4 = 1 / Math.sqrt(l4);
  9728. }
  9729. nX4 *= l4;
  9730. nY4 *= l4;
  9731. nZ4 *= l4;
  9732. var dn3 = v1X14 * nX4 + v1Y14 * nY4 + v1Z14 * nZ4;
  9733. var l23 = nX4 * nX4 + nY4 * nY4 + nZ4 * nZ4;
  9734. l23 = dn3 / l23;
  9735. minvX4 = nX4 * l23;
  9736. minvY4 = nY4 * l23;
  9737. minvZ4 = nZ4 * l23;
  9738. var v144 = closest;
  9739. v144.x = minvX4;
  9740. v144.y = minvY4;
  9741. v144.z = minvZ4;
  9742. b14 = 7;
  9743. }
  9744. var d29 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9745. if(mind1 < 0 || d29 < mind1) {
  9746. mini1 = b14 & 3 | (b14 & 4) << 1;
  9747. mind1 = d29;
  9748. var v145 = closest;
  9749. minvX1 = v145.x;
  9750. minvY1 = v145.y;
  9751. minvZ1 = v145.z;
  9752. }
  9753. }
  9754. if(d243 * sign < 0) {
  9755. var v146;
  9756. var v1X18;
  9757. var v1Y18;
  9758. var v1Z18;
  9759. var v224;
  9760. var v2X18;
  9761. var v2Y18;
  9762. var v2Z18;
  9763. var v318;
  9764. var v3X5;
  9765. var v3Y5;
  9766. var v3Z5;
  9767. var v1218;
  9768. var v12X18;
  9769. var v12Y18;
  9770. var v12Z18;
  9771. var v235;
  9772. var v23X5;
  9773. var v23Y5;
  9774. var v23Z5;
  9775. var v319;
  9776. var v31X4;
  9777. var v31Y4;
  9778. var v31Z4;
  9779. var v147 = vec21;
  9780. v1X18 = v147.x;
  9781. v1Y18 = v147.y;
  9782. v1Z18 = v147.z;
  9783. var v148 = vec31;
  9784. v2X18 = v148.x;
  9785. v2Y18 = v148.y;
  9786. v2Z18 = v148.z;
  9787. var v149 = vec4;
  9788. v3X5 = v149.x;
  9789. v3Y5 = v149.y;
  9790. v3Z5 = v149.z;
  9791. v12X18 = v2X18 - v1X18;
  9792. v12Y18 = v2Y18 - v1Y18;
  9793. v12Z18 = v2Z18 - v1Z18;
  9794. v23X5 = v3X5 - v2X18;
  9795. v23Y5 = v3Y5 - v2Y18;
  9796. v23Z5 = v3Z5 - v2Z18;
  9797. v31X4 = v1X18 - v3X5;
  9798. v31Y4 = v1Y18 - v3Y5;
  9799. v31Z4 = v1Z18 - v3Z5;
  9800. var n5;
  9801. var nX5;
  9802. var nY5;
  9803. var nZ5;
  9804. nX5 = v12Y18 * v23Z5 - v12Z18 * v23Y5;
  9805. nY5 = v12Z18 * v23X5 - v12X18 * v23Z5;
  9806. nZ5 = v12X18 * v23Y5 - v12Y18 * v23X5;
  9807. var n125;
  9808. var n12X4;
  9809. var n12Y4;
  9810. var n12Z4;
  9811. var n234;
  9812. var n23X4;
  9813. var n23Y4;
  9814. var n23Z4;
  9815. var n314;
  9816. var n31X4;
  9817. var n31Y4;
  9818. var n31Z4;
  9819. n12X4 = v12Y18 * nZ5 - v12Z18 * nY5;
  9820. n12Y4 = v12Z18 * nX5 - v12X18 * nZ5;
  9821. n12Z4 = v12X18 * nY5 - v12Y18 * nX5;
  9822. n23X4 = v23Y5 * nZ5 - v23Z5 * nY5;
  9823. n23Y4 = v23Z5 * nX5 - v23X5 * nZ5;
  9824. n23Z4 = v23X5 * nY5 - v23Y5 * nX5;
  9825. n31X4 = v31Y4 * nZ5 - v31Z4 * nY5;
  9826. n31Y4 = v31Z4 * nX5 - v31X4 * nZ5;
  9827. n31Z4 = v31X4 * nY5 - v31Y4 * nX5;
  9828. var d125 = v1X18 * n12X4 + v1Y18 * n12Y4 + v1Z18 * n12Z4;
  9829. var d234 = v2X18 * n23X4 + v2Y18 * n23Y4 + v2Z18 * n23Z4;
  9830. var d314 = v3X5 * n31X4 + v3Y5 * n31Y4 + v3Z5 * n31Z4;
  9831. var mind5 = -1;
  9832. var minv5;
  9833. var minvX5;
  9834. var minvY5;
  9835. var minvZ5;
  9836. var mini5 = 0;
  9837. minvX5 = 0;
  9838. minvY5 = 0;
  9839. minvZ5 = 0;
  9840. if(d125 < 0) {
  9841. var v150;
  9842. var v1X19;
  9843. var v1Y19;
  9844. var v1Z19;
  9845. var v225;
  9846. var v2X19;
  9847. var v2Y19;
  9848. var v2Z19;
  9849. var v151 = vec21;
  9850. v1X19 = v151.x;
  9851. v1Y19 = v151.y;
  9852. v1Z19 = v151.z;
  9853. var v152 = vec31;
  9854. v2X19 = v152.x;
  9855. v2Y19 = v152.y;
  9856. v2Z19 = v152.z;
  9857. var v1219;
  9858. var v12X19;
  9859. var v12Y19;
  9860. var v12Z19;
  9861. v12X19 = v2X19 - v1X19;
  9862. v12Y19 = v2Y19 - v1Y19;
  9863. v12Z19 = v2Z19 - v1Z19;
  9864. var d30 = v12X19 * v12X19 + v12Y19 * v12Y19 + v12Z19 * v12Z19;
  9865. var t13 = v12X19 * v1X19 + v12Y19 * v1Y19 + v12Z19 * v1Z19;
  9866. t13 = -t13 / d30;
  9867. var b15;
  9868. if(t13 < 0) {
  9869. var v153 = closest;
  9870. v153.x = v1X19;
  9871. v153.y = v1Y19;
  9872. v153.z = v1Z19;
  9873. b15 = 1;
  9874. } else if(t13 > 1) {
  9875. var v154 = closest;
  9876. v154.x = v2X19;
  9877. v154.y = v2Y19;
  9878. v154.z = v2Z19;
  9879. b15 = 2;
  9880. } else {
  9881. var p13;
  9882. var pX13;
  9883. var pY13;
  9884. var pZ13;
  9885. pX13 = v1X19 + v12X19 * t13;
  9886. pY13 = v1Y19 + v12Y19 * t13;
  9887. pZ13 = v1Z19 + v12Z19 * t13;
  9888. var v155 = closest;
  9889. v155.x = pX13;
  9890. v155.y = pY13;
  9891. v155.z = pZ13;
  9892. b15 = 3;
  9893. }
  9894. var d32 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9895. mini5 = b15;
  9896. mind5 = d32;
  9897. var v156 = closest;
  9898. minvX5 = v156.x;
  9899. minvY5 = v156.y;
  9900. minvZ5 = v156.z;
  9901. }
  9902. if(d234 < 0) {
  9903. var v157;
  9904. var v1X20;
  9905. var v1Y20;
  9906. var v1Z20;
  9907. var v226;
  9908. var v2X20;
  9909. var v2Y20;
  9910. var v2Z20;
  9911. var v158 = vec31;
  9912. v1X20 = v158.x;
  9913. v1Y20 = v158.y;
  9914. v1Z20 = v158.z;
  9915. var v159 = vec4;
  9916. v2X20 = v159.x;
  9917. v2Y20 = v159.y;
  9918. v2Z20 = v159.z;
  9919. var v1220;
  9920. var v12X20;
  9921. var v12Y20;
  9922. var v12Z20;
  9923. v12X20 = v2X20 - v1X20;
  9924. v12Y20 = v2Y20 - v1Y20;
  9925. v12Z20 = v2Z20 - v1Z20;
  9926. var d33 = v12X20 * v12X20 + v12Y20 * v12Y20 + v12Z20 * v12Z20;
  9927. var t14 = v12X20 * v1X20 + v12Y20 * v1Y20 + v12Z20 * v1Z20;
  9928. t14 = -t14 / d33;
  9929. var b16;
  9930. if(t14 < 0) {
  9931. var v160 = closest;
  9932. v160.x = v1X20;
  9933. v160.y = v1Y20;
  9934. v160.z = v1Z20;
  9935. b16 = 1;
  9936. } else if(t14 > 1) {
  9937. var v161 = closest;
  9938. v161.x = v2X20;
  9939. v161.y = v2Y20;
  9940. v161.z = v2Z20;
  9941. b16 = 2;
  9942. } else {
  9943. var p14;
  9944. var pX14;
  9945. var pY14;
  9946. var pZ14;
  9947. pX14 = v1X20 + v12X20 * t14;
  9948. pY14 = v1Y20 + v12Y20 * t14;
  9949. pZ14 = v1Z20 + v12Z20 * t14;
  9950. var v162 = closest;
  9951. v162.x = pX14;
  9952. v162.y = pY14;
  9953. v162.z = pZ14;
  9954. b16 = 3;
  9955. }
  9956. var d34 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  9957. if(mind5 < 0 || d34 < mind5) {
  9958. mini5 = b16 << 1;
  9959. mind5 = d34;
  9960. var v163 = closest;
  9961. minvX5 = v163.x;
  9962. minvY5 = v163.y;
  9963. minvZ5 = v163.z;
  9964. }
  9965. }
  9966. if(d314 < 0) {
  9967. var v164;
  9968. var v1X21;
  9969. var v1Y21;
  9970. var v1Z21;
  9971. var v227;
  9972. var v2X21;
  9973. var v2Y21;
  9974. var v2Z21;
  9975. var v165 = vec21;
  9976. v1X21 = v165.x;
  9977. v1Y21 = v165.y;
  9978. v1Z21 = v165.z;
  9979. var v166 = vec4;
  9980. v2X21 = v166.x;
  9981. v2Y21 = v166.y;
  9982. v2Z21 = v166.z;
  9983. var v1221;
  9984. var v12X21;
  9985. var v12Y21;
  9986. var v12Z21;
  9987. v12X21 = v2X21 - v1X21;
  9988. v12Y21 = v2Y21 - v1Y21;
  9989. v12Z21 = v2Z21 - v1Z21;
  9990. var d35 = v12X21 * v12X21 + v12Y21 * v12Y21 + v12Z21 * v12Z21;
  9991. var t15 = v12X21 * v1X21 + v12Y21 * v1Y21 + v12Z21 * v1Z21;
  9992. t15 = -t15 / d35;
  9993. var b17;
  9994. if(t15 < 0) {
  9995. var v167 = closest;
  9996. v167.x = v1X21;
  9997. v167.y = v1Y21;
  9998. v167.z = v1Z21;
  9999. b17 = 1;
  10000. } else if(t15 > 1) {
  10001. var v168 = closest;
  10002. v168.x = v2X21;
  10003. v168.y = v2Y21;
  10004. v168.z = v2Z21;
  10005. b17 = 2;
  10006. } else {
  10007. var p15;
  10008. var pX15;
  10009. var pY15;
  10010. var pZ15;
  10011. pX15 = v1X21 + v12X21 * t15;
  10012. pY15 = v1Y21 + v12Y21 * t15;
  10013. pZ15 = v1Z21 + v12Z21 * t15;
  10014. var v169 = closest;
  10015. v169.x = pX15;
  10016. v169.y = pY15;
  10017. v169.z = pZ15;
  10018. b17 = 3;
  10019. }
  10020. var d36 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10021. if(mind5 < 0 || d36 < mind5) {
  10022. mini5 = b17 & 1 | (b17 & 2) << 1;
  10023. mind5 = d36;
  10024. var v170 = closest;
  10025. minvX5 = v170.x;
  10026. minvY5 = v170.y;
  10027. minvZ5 = v170.z;
  10028. }
  10029. }
  10030. var b18;
  10031. if(mind5 > 0) {
  10032. var v171 = closest;
  10033. v171.x = minvX5;
  10034. v171.y = minvY5;
  10035. v171.z = minvZ5;
  10036. b18 = mini5;
  10037. } else {
  10038. var l5 = nX5 * nX5 + nY5 * nY5 + nZ5 * nZ5;
  10039. if(l5 > 0) {
  10040. l5 = 1 / Math.sqrt(l5);
  10041. }
  10042. nX5 *= l5;
  10043. nY5 *= l5;
  10044. nZ5 *= l5;
  10045. var dn4 = v1X18 * nX5 + v1Y18 * nY5 + v1Z18 * nZ5;
  10046. var l24 = nX5 * nX5 + nY5 * nY5 + nZ5 * nZ5;
  10047. l24 = dn4 / l24;
  10048. minvX5 = nX5 * l24;
  10049. minvY5 = nY5 * l24;
  10050. minvZ5 = nZ5 * l24;
  10051. var v172 = closest;
  10052. v172.x = minvX5;
  10053. v172.y = minvY5;
  10054. v172.z = minvZ5;
  10055. b18 = 7;
  10056. }
  10057. var d37 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10058. if(mind1 < 0 || d37 < mind1) {
  10059. mini1 = b18 << 1;
  10060. mind1 = d37;
  10061. var v173 = closest;
  10062. minvX1 = v173.x;
  10063. minvY1 = v173.y;
  10064. minvZ1 = v173.z;
  10065. }
  10066. }
  10067. if(mind1 > 0) {
  10068. var v174 = closest;
  10069. v174.x = minvX1;
  10070. v174.y = minvY1;
  10071. v174.z = minvZ1;
  10072. v3 = mini1;
  10073. } else {
  10074. closest.zero();
  10075. v3 = 15;
  10076. }
  10077. break;
  10078. }
  10079. if(closest.x * closest.x + closest.y * closest.y + closest.z * closest.z < eps2) {
  10080. if(!useEpa) {
  10081. this.distance = 0;
  10082. return 0;
  10083. }
  10084. switch(this.simplexSize) {
  10085. case 1:
  10086. this.pointToTetrahedron();
  10087. break;
  10088. case 2:
  10089. this.lineToTetrahedron();
  10090. break;
  10091. case 3:
  10092. this.triangleToTetrahedron();
  10093. break;
  10094. }
  10095. if(this.simplexSize == 4) {
  10096. var epaState = this.computeDepth(c1,c2,tf1,tf2,s,w1,w2);
  10097. if(epaState != 0) {
  10098. this.distance = 0;
  10099. return epaState;
  10100. }
  10101. this.distance = -this.depth;
  10102. return 0;
  10103. }
  10104. this.distance = 0;
  10105. return 1;
  10106. }
  10107. this.shrinkSimplex(v3);
  10108. dir.x = closest.x;
  10109. dir.y = closest.y;
  10110. dir.z = closest.z;
  10111. var _this2 = dir;
  10112. var tx1 = -_this2.x;
  10113. var ty1 = -_this2.y;
  10114. var tz1 = -_this2.z;
  10115. _this2.x = tx1;
  10116. _this2.y = ty1;
  10117. _this2.z = tz1;
  10118. this.computeWitnessPoint1(false);
  10119. this.computeWitnessPoint2(false);
  10120. var _this3 = this.s[this.simplexSize];
  10121. var v175 = this.w1[this.simplexSize];
  10122. _this3.x = v175.x;
  10123. _this3.y = v175.y;
  10124. _this3.z = v175.z;
  10125. var _this4 = _this3;
  10126. var v176 = this.w2[this.simplexSize];
  10127. var tx2 = _this4.x - v176.x;
  10128. var ty2 = _this4.y - v176.y;
  10129. var tz2 = _this4.z - v176.z;
  10130. _this4.x = tx2;
  10131. _this4.y = ty2;
  10132. _this4.z = tz2;
  10133. if(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < eps2) {
  10134. throw new Error("!?");
  10135. }
  10136. var d110 = closest.x * dir.x + closest.y * dir.y + closest.z * dir.z;
  10137. var _this5 = s[this.simplexSize];
  10138. var d210 = _this5.x * dir.x + _this5.y * dir.y + _this5.z * dir.z;
  10139. if(d210 - d110 < eps2) {
  10140. this.interpolateClosestPoints();
  10141. this.distance = Math.sqrt(closest.x * closest.x + closest.y * closest.y + closest.z * closest.z);
  10142. if(cache != null && cache._gjkCache != null) {
  10143. this.saveCache(cache._gjkCache);
  10144. }
  10145. return 0;
  10146. }
  10147. this.simplexSize++;
  10148. ++count;
  10149. }
  10150. return 2;
  10151. }
  10152. convexCastImpl(c1,c2,tf1,tf2,tl1,tl2,hit) {
  10153. this.c1 = c1;
  10154. this.c2 = c2;
  10155. this.tf1 = tf1;
  10156. this.tf2 = tf2;
  10157. var s = this.s;
  10158. var w1 = this.w1;
  10159. var w2 = this.w2;
  10160. var closest = this.closest;
  10161. var dir = this.dir;
  10162. var firstDir;
  10163. var firstDirX;
  10164. var firstDirY;
  10165. var firstDirZ;
  10166. firstDirX = tf2._positionX - tf1._positionX;
  10167. firstDirY = tf2._positionY - tf1._positionY;
  10168. firstDirZ = tf2._positionZ - tf1._positionZ;
  10169. var v = dir;
  10170. v.x = firstDirX;
  10171. v.y = firstDirY;
  10172. v.z = firstDirZ;
  10173. if(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < 1e-6) {
  10174. dir.init(1,0,0);
  10175. }
  10176. this.simplexSize = 0;
  10177. if(this.c1 != null) {
  10178. this.computeWitnessPoint1(true);
  10179. } else {
  10180. var v1 = this.w1[this.simplexSize];
  10181. v1.x = this.tf1._positionX;
  10182. v1.y = this.tf1._positionY;
  10183. v1.z = this.tf1._positionZ;
  10184. }
  10185. this.computeWitnessPoint2(true);
  10186. var _this = this.s[this.simplexSize];
  10187. var v2 = this.w1[this.simplexSize];
  10188. _this.x = v2.x;
  10189. _this.y = v2.y;
  10190. _this.z = v2.z;
  10191. var _this1 = _this;
  10192. var v3 = this.w2[this.simplexSize];
  10193. var tx = _this1.x - v3.x;
  10194. var ty = _this1.y - v3.y;
  10195. var tz = _this1.z - v3.z;
  10196. _this1.x = tx;
  10197. _this1.y = ty;
  10198. _this1.z = tz;
  10199. this.simplexSize = 1;
  10200. var count = 0;
  10201. var max = 40;
  10202. var lambda = 0.0;
  10203. var rayX = this.rayX;
  10204. var rayR = this.rayR;
  10205. rayX.zero();
  10206. rayR.x = tl2.x;
  10207. rayR.y = tl2.y;
  10208. rayR.z = tl2.z;
  10209. var _this2 = rayR;
  10210. var tx1 = _this2.x - tl1.x;
  10211. var ty1 = _this2.y - tl1.y;
  10212. var tz1 = _this2.z - tl1.z;
  10213. _this2.x = tx1;
  10214. _this2.y = ty1;
  10215. _this2.z = tz1;
  10216. var eps = 1e-4;
  10217. var eps2 = eps * eps;
  10218. while(count < max) {
  10219. var v4 = 0;
  10220. switch(this.simplexSize) {
  10221. case 1:
  10222. var v5 = s[0];
  10223. closest.x = v5.x;
  10224. closest.y = v5.y;
  10225. closest.z = v5.z;
  10226. v4 = 1;
  10227. break;
  10228. case 2:
  10229. var v11;
  10230. var v1X;
  10231. var v1Y;
  10232. var v1Z;
  10233. var v21;
  10234. var v2X;
  10235. var v2Y;
  10236. var v2Z;
  10237. var v6 = s[0];
  10238. v1X = v6.x;
  10239. v1Y = v6.y;
  10240. v1Z = v6.z;
  10241. var v7 = s[1];
  10242. v2X = v7.x;
  10243. v2Y = v7.y;
  10244. v2Z = v7.z;
  10245. var v12;
  10246. var v12X;
  10247. var v12Y;
  10248. var v12Z;
  10249. v12X = v2X - v1X;
  10250. v12Y = v2Y - v1Y;
  10251. v12Z = v2Z - v1Z;
  10252. var d = v12X * v12X + v12Y * v12Y + v12Z * v12Z;
  10253. var t = v12X * v1X + v12Y * v1Y + v12Z * v1Z;
  10254. t = -t / d;
  10255. if(t < 0) {
  10256. var v8 = closest;
  10257. v8.x = v1X;
  10258. v8.y = v1Y;
  10259. v8.z = v1Z;
  10260. v4 = 1;
  10261. } else if(t > 1) {
  10262. var v9 = closest;
  10263. v9.x = v2X;
  10264. v9.y = v2Y;
  10265. v9.z = v2Z;
  10266. v4 = 2;
  10267. } else {
  10268. var p;
  10269. var pX;
  10270. var pY;
  10271. var pZ;
  10272. pX = v1X + v12X * t;
  10273. pY = v1Y + v12Y * t;
  10274. pZ = v1Z + v12Z * t;
  10275. var v10 = closest;
  10276. v10.x = pX;
  10277. v10.y = pY;
  10278. v10.z = pZ;
  10279. v4 = 3;
  10280. }
  10281. break;
  10282. case 3:
  10283. var vec1 = s[0];
  10284. var vec2 = s[1];
  10285. var vec3 = s[2];
  10286. var v13;
  10287. var v1X1;
  10288. var v1Y1;
  10289. var v1Z1;
  10290. var v22;
  10291. var v2X1;
  10292. var v2Y1;
  10293. var v2Z1;
  10294. var v31;
  10295. var v3X;
  10296. var v3Y;
  10297. var v3Z;
  10298. var v121;
  10299. var v12X1;
  10300. var v12Y1;
  10301. var v12Z1;
  10302. var v23;
  10303. var v23X;
  10304. var v23Y;
  10305. var v23Z;
  10306. var v311;
  10307. var v31X;
  10308. var v31Y;
  10309. var v31Z;
  10310. var v14 = vec1;
  10311. v1X1 = v14.x;
  10312. v1Y1 = v14.y;
  10313. v1Z1 = v14.z;
  10314. var v15 = vec2;
  10315. v2X1 = v15.x;
  10316. v2Y1 = v15.y;
  10317. v2Z1 = v15.z;
  10318. var v16 = vec3;
  10319. v3X = v16.x;
  10320. v3Y = v16.y;
  10321. v3Z = v16.z;
  10322. v12X1 = v2X1 - v1X1;
  10323. v12Y1 = v2Y1 - v1Y1;
  10324. v12Z1 = v2Z1 - v1Z1;
  10325. v23X = v3X - v2X1;
  10326. v23Y = v3Y - v2Y1;
  10327. v23Z = v3Z - v2Z1;
  10328. v31X = v1X1 - v3X;
  10329. v31Y = v1Y1 - v3Y;
  10330. v31Z = v1Z1 - v3Z;
  10331. var n;
  10332. var nX;
  10333. var nY;
  10334. var nZ;
  10335. nX = v12Y1 * v23Z - v12Z1 * v23Y;
  10336. nY = v12Z1 * v23X - v12X1 * v23Z;
  10337. nZ = v12X1 * v23Y - v12Y1 * v23X;
  10338. var n12;
  10339. var n12X;
  10340. var n12Y;
  10341. var n12Z;
  10342. var n23;
  10343. var n23X;
  10344. var n23Y;
  10345. var n23Z;
  10346. var n31;
  10347. var n31X;
  10348. var n31Y;
  10349. var n31Z;
  10350. n12X = v12Y1 * nZ - v12Z1 * nY;
  10351. n12Y = v12Z1 * nX - v12X1 * nZ;
  10352. n12Z = v12X1 * nY - v12Y1 * nX;
  10353. n23X = v23Y * nZ - v23Z * nY;
  10354. n23Y = v23Z * nX - v23X * nZ;
  10355. n23Z = v23X * nY - v23Y * nX;
  10356. n31X = v31Y * nZ - v31Z * nY;
  10357. n31Y = v31Z * nX - v31X * nZ;
  10358. n31Z = v31X * nY - v31Y * nX;
  10359. var d12 = v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z;
  10360. var d23 = v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z;
  10361. var d31 = v3X * n31X + v3Y * n31Y + v3Z * n31Z;
  10362. var mind = -1;
  10363. var minv;
  10364. var minvX;
  10365. var minvY;
  10366. var minvZ;
  10367. var mini = 0;
  10368. minvX = 0;
  10369. minvY = 0;
  10370. minvZ = 0;
  10371. if(d12 < 0) {
  10372. var v17;
  10373. var v1X2;
  10374. var v1Y2;
  10375. var v1Z2;
  10376. var v24;
  10377. var v2X2;
  10378. var v2Y2;
  10379. var v2Z2;
  10380. var v18 = vec1;
  10381. v1X2 = v18.x;
  10382. v1Y2 = v18.y;
  10383. v1Z2 = v18.z;
  10384. var v19 = vec2;
  10385. v2X2 = v19.x;
  10386. v2Y2 = v19.y;
  10387. v2Z2 = v19.z;
  10388. var v122;
  10389. var v12X2;
  10390. var v12Y2;
  10391. var v12Z2;
  10392. v12X2 = v2X2 - v1X2;
  10393. v12Y2 = v2Y2 - v1Y2;
  10394. v12Z2 = v2Z2 - v1Z2;
  10395. var d1 = v12X2 * v12X2 + v12Y2 * v12Y2 + v12Z2 * v12Z2;
  10396. var t1 = v12X2 * v1X2 + v12Y2 * v1Y2 + v12Z2 * v1Z2;
  10397. t1 = -t1 / d1;
  10398. var b;
  10399. if(t1 < 0) {
  10400. var v20 = closest;
  10401. v20.x = v1X2;
  10402. v20.y = v1Y2;
  10403. v20.z = v1Z2;
  10404. b = 1;
  10405. } else if(t1 > 1) {
  10406. var v25 = closest;
  10407. v25.x = v2X2;
  10408. v25.y = v2Y2;
  10409. v25.z = v2Z2;
  10410. b = 2;
  10411. } else {
  10412. var p1;
  10413. var pX1;
  10414. var pY1;
  10415. var pZ1;
  10416. pX1 = v1X2 + v12X2 * t1;
  10417. pY1 = v1Y2 + v12Y2 * t1;
  10418. pZ1 = v1Z2 + v12Z2 * t1;
  10419. var v26 = closest;
  10420. v26.x = pX1;
  10421. v26.y = pY1;
  10422. v26.z = pZ1;
  10423. b = 3;
  10424. }
  10425. var d2 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10426. mini = b;
  10427. mind = d2;
  10428. var v27 = closest;
  10429. minvX = v27.x;
  10430. minvY = v27.y;
  10431. minvZ = v27.z;
  10432. }
  10433. if(d23 < 0) {
  10434. var v110;
  10435. var v1X3;
  10436. var v1Y3;
  10437. var v1Z3;
  10438. var v28;
  10439. var v2X3;
  10440. var v2Y3;
  10441. var v2Z3;
  10442. var v29 = vec2;
  10443. v1X3 = v29.x;
  10444. v1Y3 = v29.y;
  10445. v1Z3 = v29.z;
  10446. var v30 = vec3;
  10447. v2X3 = v30.x;
  10448. v2Y3 = v30.y;
  10449. v2Z3 = v30.z;
  10450. var v123;
  10451. var v12X3;
  10452. var v12Y3;
  10453. var v12Z3;
  10454. v12X3 = v2X3 - v1X3;
  10455. v12Y3 = v2Y3 - v1Y3;
  10456. v12Z3 = v2Z3 - v1Z3;
  10457. var d3 = v12X3 * v12X3 + v12Y3 * v12Y3 + v12Z3 * v12Z3;
  10458. var t2 = v12X3 * v1X3 + v12Y3 * v1Y3 + v12Z3 * v1Z3;
  10459. t2 = -t2 / d3;
  10460. var b1;
  10461. if(t2 < 0) {
  10462. var v32 = closest;
  10463. v32.x = v1X3;
  10464. v32.y = v1Y3;
  10465. v32.z = v1Z3;
  10466. b1 = 1;
  10467. } else if(t2 > 1) {
  10468. var v33 = closest;
  10469. v33.x = v2X3;
  10470. v33.y = v2Y3;
  10471. v33.z = v2Z3;
  10472. b1 = 2;
  10473. } else {
  10474. var p2;
  10475. var pX2;
  10476. var pY2;
  10477. var pZ2;
  10478. pX2 = v1X3 + v12X3 * t2;
  10479. pY2 = v1Y3 + v12Y3 * t2;
  10480. pZ2 = v1Z3 + v12Z3 * t2;
  10481. var v34 = closest;
  10482. v34.x = pX2;
  10483. v34.y = pY2;
  10484. v34.z = pZ2;
  10485. b1 = 3;
  10486. }
  10487. var d4 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10488. if(mind < 0 || d4 < mind) {
  10489. mini = b1 << 1;
  10490. mind = d4;
  10491. var v35 = closest;
  10492. minvX = v35.x;
  10493. minvY = v35.y;
  10494. minvZ = v35.z;
  10495. }
  10496. }
  10497. if(d31 < 0) {
  10498. var v111;
  10499. var v1X4;
  10500. var v1Y4;
  10501. var v1Z4;
  10502. var v210;
  10503. var v2X4;
  10504. var v2Y4;
  10505. var v2Z4;
  10506. var v36 = vec1;
  10507. v1X4 = v36.x;
  10508. v1Y4 = v36.y;
  10509. v1Z4 = v36.z;
  10510. var v37 = vec3;
  10511. v2X4 = v37.x;
  10512. v2Y4 = v37.y;
  10513. v2Z4 = v37.z;
  10514. var v124;
  10515. var v12X4;
  10516. var v12Y4;
  10517. var v12Z4;
  10518. v12X4 = v2X4 - v1X4;
  10519. v12Y4 = v2Y4 - v1Y4;
  10520. v12Z4 = v2Z4 - v1Z4;
  10521. var d5 = v12X4 * v12X4 + v12Y4 * v12Y4 + v12Z4 * v12Z4;
  10522. var t3 = v12X4 * v1X4 + v12Y4 * v1Y4 + v12Z4 * v1Z4;
  10523. t3 = -t3 / d5;
  10524. var b2;
  10525. if(t3 < 0) {
  10526. var v38 = closest;
  10527. v38.x = v1X4;
  10528. v38.y = v1Y4;
  10529. v38.z = v1Z4;
  10530. b2 = 1;
  10531. } else if(t3 > 1) {
  10532. var v39 = closest;
  10533. v39.x = v2X4;
  10534. v39.y = v2Y4;
  10535. v39.z = v2Z4;
  10536. b2 = 2;
  10537. } else {
  10538. var p3;
  10539. var pX3;
  10540. var pY3;
  10541. var pZ3;
  10542. pX3 = v1X4 + v12X4 * t3;
  10543. pY3 = v1Y4 + v12Y4 * t3;
  10544. pZ3 = v1Z4 + v12Z4 * t3;
  10545. var v40 = closest;
  10546. v40.x = pX3;
  10547. v40.y = pY3;
  10548. v40.z = pZ3;
  10549. b2 = 3;
  10550. }
  10551. var d6 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10552. if(mind < 0 || d6 < mind) {
  10553. mini = b2 & 1 | (b2 & 2) << 1;
  10554. mind = d6;
  10555. var v41 = closest;
  10556. minvX = v41.x;
  10557. minvY = v41.y;
  10558. minvZ = v41.z;
  10559. }
  10560. }
  10561. if(mind > 0) {
  10562. var v42 = closest;
  10563. v42.x = minvX;
  10564. v42.y = minvY;
  10565. v42.z = minvZ;
  10566. v4 = mini;
  10567. } else {
  10568. var l = nX * nX + nY * nY + nZ * nZ;
  10569. if(l > 0) {
  10570. l = 1 / Math.sqrt(l);
  10571. }
  10572. nX *= l;
  10573. nY *= l;
  10574. nZ *= l;
  10575. var dn = v1X1 * nX + v1Y1 * nY + v1Z1 * nZ;
  10576. var l2 = nX * nX + nY * nY + nZ * nZ;
  10577. l2 = dn / l2;
  10578. minvX = nX * l2;
  10579. minvY = nY * l2;
  10580. minvZ = nZ * l2;
  10581. var v43 = closest;
  10582. v43.x = minvX;
  10583. v43.y = minvY;
  10584. v43.z = minvZ;
  10585. v4 = 7;
  10586. }
  10587. break;
  10588. case 4:
  10589. var vec11 = s[0];
  10590. var vec21 = s[1];
  10591. var vec31 = s[2];
  10592. var vec4 = s[3];
  10593. var v112;
  10594. var v1X5;
  10595. var v1Y5;
  10596. var v1Z5;
  10597. var v211;
  10598. var v2X5;
  10599. var v2Y5;
  10600. var v2Z5;
  10601. var v310;
  10602. var v3X1;
  10603. var v3Y1;
  10604. var v3Z1;
  10605. var v44;
  10606. var v4X;
  10607. var v4Y;
  10608. var v4Z;
  10609. var v125;
  10610. var v12X5;
  10611. var v12Y5;
  10612. var v12Z5;
  10613. var v131;
  10614. var v13X;
  10615. var v13Y;
  10616. var v13Z;
  10617. var v141;
  10618. var v14X;
  10619. var v14Y;
  10620. var v14Z;
  10621. var v231;
  10622. var v23X1;
  10623. var v23Y1;
  10624. var v23Z1;
  10625. var v241;
  10626. var v24X;
  10627. var v24Y;
  10628. var v24Z;
  10629. var v341;
  10630. var v34X;
  10631. var v34Y;
  10632. var v34Z;
  10633. var v45 = vec11;
  10634. v1X5 = v45.x;
  10635. v1Y5 = v45.y;
  10636. v1Z5 = v45.z;
  10637. var v46 = vec21;
  10638. v2X5 = v46.x;
  10639. v2Y5 = v46.y;
  10640. v2Z5 = v46.z;
  10641. var v47 = vec31;
  10642. v3X1 = v47.x;
  10643. v3Y1 = v47.y;
  10644. v3Z1 = v47.z;
  10645. var v48 = vec4;
  10646. v4X = v48.x;
  10647. v4Y = v48.y;
  10648. v4Z = v48.z;
  10649. v12X5 = v2X5 - v1X5;
  10650. v12Y5 = v2Y5 - v1Y5;
  10651. v12Z5 = v2Z5 - v1Z5;
  10652. v13X = v3X1 - v1X5;
  10653. v13Y = v3Y1 - v1Y5;
  10654. v13Z = v3Z1 - v1Z5;
  10655. v14X = v4X - v1X5;
  10656. v14Y = v4Y - v1Y5;
  10657. v14Z = v4Z - v1Z5;
  10658. v23X1 = v3X1 - v2X5;
  10659. v23Y1 = v3Y1 - v2Y5;
  10660. v23Z1 = v3Z1 - v2Z5;
  10661. v24X = v4X - v2X5;
  10662. v24Y = v4Y - v2Y5;
  10663. v24Z = v4Z - v2Z5;
  10664. v34X = v4X - v3X1;
  10665. v34Y = v4Y - v3Y1;
  10666. v34Z = v4Z - v3Z1;
  10667. var rev;
  10668. var n123;
  10669. var n123X;
  10670. var n123Y;
  10671. var n123Z;
  10672. var n134;
  10673. var n134X;
  10674. var n134Y;
  10675. var n134Z;
  10676. var n142;
  10677. var n142X;
  10678. var n142Y;
  10679. var n142Z;
  10680. var n243;
  10681. var n243X;
  10682. var n243Y;
  10683. var n243Z;
  10684. var n1;
  10685. var nX1;
  10686. var nY1;
  10687. var nZ1;
  10688. n123X = v12Y5 * v13Z - v12Z5 * v13Y;
  10689. n123Y = v12Z5 * v13X - v12X5 * v13Z;
  10690. n123Z = v12X5 * v13Y - v12Y5 * v13X;
  10691. n134X = v13Y * v14Z - v13Z * v14Y;
  10692. n134Y = v13Z * v14X - v13X * v14Z;
  10693. n134Z = v13X * v14Y - v13Y * v14X;
  10694. n142X = v14Y * v12Z5 - v14Z * v12Y5;
  10695. n142Y = v14Z * v12X5 - v14X * v12Z5;
  10696. n142Z = v14X * v12Y5 - v14Y * v12X5;
  10697. n243X = v24Y * v23Z1 - v24Z * v23Y1;
  10698. n243Y = v24Z * v23X1 - v24X * v23Z1;
  10699. n243Z = v24X * v23Y1 - v24Y * v23X1;
  10700. var sign = v12X5 * n243X + v12Y5 * n243Y + v12Z5 * n243Z > 0 ? 1 : -1;
  10701. var d123 = v1X5 * n123X + v1Y5 * n123Y + v1Z5 * n123Z;
  10702. var d134 = v1X5 * n134X + v1Y5 * n134Y + v1Z5 * n134Z;
  10703. var d142 = v1X5 * n142X + v1Y5 * n142Y + v1Z5 * n142Z;
  10704. var d243 = v2X5 * n243X + v2Y5 * n243Y + v2Z5 * n243Z;
  10705. var mind1 = -1;
  10706. var minv1;
  10707. var minvX1;
  10708. var minvY1;
  10709. var minvZ1;
  10710. var mini1 = 0;
  10711. minvX1 = 0;
  10712. minvY1 = 0;
  10713. minvZ1 = 0;
  10714. if(d123 * sign < 0) {
  10715. var v113;
  10716. var v1X6;
  10717. var v1Y6;
  10718. var v1Z6;
  10719. var v212;
  10720. var v2X6;
  10721. var v2Y6;
  10722. var v2Z6;
  10723. var v312;
  10724. var v3X2;
  10725. var v3Y2;
  10726. var v3Z2;
  10727. var v126;
  10728. var v12X6;
  10729. var v12Y6;
  10730. var v12Z6;
  10731. var v232;
  10732. var v23X2;
  10733. var v23Y2;
  10734. var v23Z2;
  10735. var v313;
  10736. var v31X1;
  10737. var v31Y1;
  10738. var v31Z1;
  10739. var v49 = vec11;
  10740. v1X6 = v49.x;
  10741. v1Y6 = v49.y;
  10742. v1Z6 = v49.z;
  10743. var v50 = vec21;
  10744. v2X6 = v50.x;
  10745. v2Y6 = v50.y;
  10746. v2Z6 = v50.z;
  10747. var v51 = vec31;
  10748. v3X2 = v51.x;
  10749. v3Y2 = v51.y;
  10750. v3Z2 = v51.z;
  10751. v12X6 = v2X6 - v1X6;
  10752. v12Y6 = v2Y6 - v1Y6;
  10753. v12Z6 = v2Z6 - v1Z6;
  10754. v23X2 = v3X2 - v2X6;
  10755. v23Y2 = v3Y2 - v2Y6;
  10756. v23Z2 = v3Z2 - v2Z6;
  10757. v31X1 = v1X6 - v3X2;
  10758. v31Y1 = v1Y6 - v3Y2;
  10759. v31Z1 = v1Z6 - v3Z2;
  10760. var n2;
  10761. var nX2;
  10762. var nY2;
  10763. var nZ2;
  10764. nX2 = v12Y6 * v23Z2 - v12Z6 * v23Y2;
  10765. nY2 = v12Z6 * v23X2 - v12X6 * v23Z2;
  10766. nZ2 = v12X6 * v23Y2 - v12Y6 * v23X2;
  10767. var n121;
  10768. var n12X1;
  10769. var n12Y1;
  10770. var n12Z1;
  10771. var n231;
  10772. var n23X1;
  10773. var n23Y1;
  10774. var n23Z1;
  10775. var n311;
  10776. var n31X1;
  10777. var n31Y1;
  10778. var n31Z1;
  10779. n12X1 = v12Y6 * nZ2 - v12Z6 * nY2;
  10780. n12Y1 = v12Z6 * nX2 - v12X6 * nZ2;
  10781. n12Z1 = v12X6 * nY2 - v12Y6 * nX2;
  10782. n23X1 = v23Y2 * nZ2 - v23Z2 * nY2;
  10783. n23Y1 = v23Z2 * nX2 - v23X2 * nZ2;
  10784. n23Z1 = v23X2 * nY2 - v23Y2 * nX2;
  10785. n31X1 = v31Y1 * nZ2 - v31Z1 * nY2;
  10786. n31Y1 = v31Z1 * nX2 - v31X1 * nZ2;
  10787. n31Z1 = v31X1 * nY2 - v31Y1 * nX2;
  10788. var d121 = v1X6 * n12X1 + v1Y6 * n12Y1 + v1Z6 * n12Z1;
  10789. var d231 = v2X6 * n23X1 + v2Y6 * n23Y1 + v2Z6 * n23Z1;
  10790. var d311 = v3X2 * n31X1 + v3Y2 * n31Y1 + v3Z2 * n31Z1;
  10791. var mind2 = -1;
  10792. var minv2;
  10793. var minvX2;
  10794. var minvY2;
  10795. var minvZ2;
  10796. var mini2 = 0;
  10797. minvX2 = 0;
  10798. minvY2 = 0;
  10799. minvZ2 = 0;
  10800. if(d121 < 0) {
  10801. var v114;
  10802. var v1X7;
  10803. var v1Y7;
  10804. var v1Z7;
  10805. var v213;
  10806. var v2X7;
  10807. var v2Y7;
  10808. var v2Z7;
  10809. var v52 = vec11;
  10810. v1X7 = v52.x;
  10811. v1Y7 = v52.y;
  10812. v1Z7 = v52.z;
  10813. var v53 = vec21;
  10814. v2X7 = v53.x;
  10815. v2Y7 = v53.y;
  10816. v2Z7 = v53.z;
  10817. var v127;
  10818. var v12X7;
  10819. var v12Y7;
  10820. var v12Z7;
  10821. v12X7 = v2X7 - v1X7;
  10822. v12Y7 = v2Y7 - v1Y7;
  10823. v12Z7 = v2Z7 - v1Z7;
  10824. var d7 = v12X7 * v12X7 + v12Y7 * v12Y7 + v12Z7 * v12Z7;
  10825. var t4 = v12X7 * v1X7 + v12Y7 * v1Y7 + v12Z7 * v1Z7;
  10826. t4 = -t4 / d7;
  10827. var b3;
  10828. if(t4 < 0) {
  10829. var v54 = closest;
  10830. v54.x = v1X7;
  10831. v54.y = v1Y7;
  10832. v54.z = v1Z7;
  10833. b3 = 1;
  10834. } else if(t4 > 1) {
  10835. var v55 = closest;
  10836. v55.x = v2X7;
  10837. v55.y = v2Y7;
  10838. v55.z = v2Z7;
  10839. b3 = 2;
  10840. } else {
  10841. var p4;
  10842. var pX4;
  10843. var pY4;
  10844. var pZ4;
  10845. pX4 = v1X7 + v12X7 * t4;
  10846. pY4 = v1Y7 + v12Y7 * t4;
  10847. pZ4 = v1Z7 + v12Z7 * t4;
  10848. var v56 = closest;
  10849. v56.x = pX4;
  10850. v56.y = pY4;
  10851. v56.z = pZ4;
  10852. b3 = 3;
  10853. }
  10854. var d8 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10855. mini2 = b3;
  10856. mind2 = d8;
  10857. var v57 = closest;
  10858. minvX2 = v57.x;
  10859. minvY2 = v57.y;
  10860. minvZ2 = v57.z;
  10861. }
  10862. if(d231 < 0) {
  10863. var v115;
  10864. var v1X8;
  10865. var v1Y8;
  10866. var v1Z8;
  10867. var v214;
  10868. var v2X8;
  10869. var v2Y8;
  10870. var v2Z8;
  10871. var v58 = vec21;
  10872. v1X8 = v58.x;
  10873. v1Y8 = v58.y;
  10874. v1Z8 = v58.z;
  10875. var v59 = vec31;
  10876. v2X8 = v59.x;
  10877. v2Y8 = v59.y;
  10878. v2Z8 = v59.z;
  10879. var v128;
  10880. var v12X8;
  10881. var v12Y8;
  10882. var v12Z8;
  10883. v12X8 = v2X8 - v1X8;
  10884. v12Y8 = v2Y8 - v1Y8;
  10885. v12Z8 = v2Z8 - v1Z8;
  10886. var d9 = v12X8 * v12X8 + v12Y8 * v12Y8 + v12Z8 * v12Z8;
  10887. var t5 = v12X8 * v1X8 + v12Y8 * v1Y8 + v12Z8 * v1Z8;
  10888. t5 = -t5 / d9;
  10889. var b4;
  10890. if(t5 < 0) {
  10891. var v60 = closest;
  10892. v60.x = v1X8;
  10893. v60.y = v1Y8;
  10894. v60.z = v1Z8;
  10895. b4 = 1;
  10896. } else if(t5 > 1) {
  10897. var v61 = closest;
  10898. v61.x = v2X8;
  10899. v61.y = v2Y8;
  10900. v61.z = v2Z8;
  10901. b4 = 2;
  10902. } else {
  10903. var p5;
  10904. var pX5;
  10905. var pY5;
  10906. var pZ5;
  10907. pX5 = v1X8 + v12X8 * t5;
  10908. pY5 = v1Y8 + v12Y8 * t5;
  10909. pZ5 = v1Z8 + v12Z8 * t5;
  10910. var v62 = closest;
  10911. v62.x = pX5;
  10912. v62.y = pY5;
  10913. v62.z = pZ5;
  10914. b4 = 3;
  10915. }
  10916. var d10 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10917. if(mind2 < 0 || d10 < mind2) {
  10918. mini2 = b4 << 1;
  10919. mind2 = d10;
  10920. var v63 = closest;
  10921. minvX2 = v63.x;
  10922. minvY2 = v63.y;
  10923. minvZ2 = v63.z;
  10924. }
  10925. }
  10926. if(d311 < 0) {
  10927. var v116;
  10928. var v1X9;
  10929. var v1Y9;
  10930. var v1Z9;
  10931. var v215;
  10932. var v2X9;
  10933. var v2Y9;
  10934. var v2Z9;
  10935. var v64 = vec11;
  10936. v1X9 = v64.x;
  10937. v1Y9 = v64.y;
  10938. v1Z9 = v64.z;
  10939. var v65 = vec31;
  10940. v2X9 = v65.x;
  10941. v2Y9 = v65.y;
  10942. v2Z9 = v65.z;
  10943. var v129;
  10944. var v12X9;
  10945. var v12Y9;
  10946. var v12Z9;
  10947. v12X9 = v2X9 - v1X9;
  10948. v12Y9 = v2Y9 - v1Y9;
  10949. v12Z9 = v2Z9 - v1Z9;
  10950. var d11 = v12X9 * v12X9 + v12Y9 * v12Y9 + v12Z9 * v12Z9;
  10951. var t6 = v12X9 * v1X9 + v12Y9 * v1Y9 + v12Z9 * v1Z9;
  10952. t6 = -t6 / d11;
  10953. var b5;
  10954. if(t6 < 0) {
  10955. var v66 = closest;
  10956. v66.x = v1X9;
  10957. v66.y = v1Y9;
  10958. v66.z = v1Z9;
  10959. b5 = 1;
  10960. } else if(t6 > 1) {
  10961. var v67 = closest;
  10962. v67.x = v2X9;
  10963. v67.y = v2Y9;
  10964. v67.z = v2Z9;
  10965. b5 = 2;
  10966. } else {
  10967. var p6;
  10968. var pX6;
  10969. var pY6;
  10970. var pZ6;
  10971. pX6 = v1X9 + v12X9 * t6;
  10972. pY6 = v1Y9 + v12Y9 * t6;
  10973. pZ6 = v1Z9 + v12Z9 * t6;
  10974. var v68 = closest;
  10975. v68.x = pX6;
  10976. v68.y = pY6;
  10977. v68.z = pZ6;
  10978. b5 = 3;
  10979. }
  10980. var d13 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  10981. if(mind2 < 0 || d13 < mind2) {
  10982. mini2 = b5 & 1 | (b5 & 2) << 1;
  10983. mind2 = d13;
  10984. var v69 = closest;
  10985. minvX2 = v69.x;
  10986. minvY2 = v69.y;
  10987. minvZ2 = v69.z;
  10988. }
  10989. }
  10990. var b6;
  10991. if(mind2 > 0) {
  10992. var v70 = closest;
  10993. v70.x = minvX2;
  10994. v70.y = minvY2;
  10995. v70.z = minvZ2;
  10996. b6 = mini2;
  10997. } else {
  10998. var l1 = nX2 * nX2 + nY2 * nY2 + nZ2 * nZ2;
  10999. if(l1 > 0) {
  11000. l1 = 1 / Math.sqrt(l1);
  11001. }
  11002. nX2 *= l1;
  11003. nY2 *= l1;
  11004. nZ2 *= l1;
  11005. var dn1 = v1X6 * nX2 + v1Y6 * nY2 + v1Z6 * nZ2;
  11006. var l21 = nX2 * nX2 + nY2 * nY2 + nZ2 * nZ2;
  11007. l21 = dn1 / l21;
  11008. minvX2 = nX2 * l21;
  11009. minvY2 = nY2 * l21;
  11010. minvZ2 = nZ2 * l21;
  11011. var v71 = closest;
  11012. v71.x = minvX2;
  11013. v71.y = minvY2;
  11014. v71.z = minvZ2;
  11015. b6 = 7;
  11016. }
  11017. var d14 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11018. mini1 = b6;
  11019. mind1 = d14;
  11020. var v72 = closest;
  11021. minvX1 = v72.x;
  11022. minvY1 = v72.y;
  11023. minvZ1 = v72.z;
  11024. }
  11025. if(d134 * sign < 0) {
  11026. var v117;
  11027. var v1X10;
  11028. var v1Y10;
  11029. var v1Z10;
  11030. var v216;
  11031. var v2X10;
  11032. var v2Y10;
  11033. var v2Z10;
  11034. var v314;
  11035. var v3X3;
  11036. var v3Y3;
  11037. var v3Z3;
  11038. var v1210;
  11039. var v12X10;
  11040. var v12Y10;
  11041. var v12Z10;
  11042. var v233;
  11043. var v23X3;
  11044. var v23Y3;
  11045. var v23Z3;
  11046. var v315;
  11047. var v31X2;
  11048. var v31Y2;
  11049. var v31Z2;
  11050. var v73 = vec11;
  11051. v1X10 = v73.x;
  11052. v1Y10 = v73.y;
  11053. v1Z10 = v73.z;
  11054. var v74 = vec31;
  11055. v2X10 = v74.x;
  11056. v2Y10 = v74.y;
  11057. v2Z10 = v74.z;
  11058. var v75 = vec4;
  11059. v3X3 = v75.x;
  11060. v3Y3 = v75.y;
  11061. v3Z3 = v75.z;
  11062. v12X10 = v2X10 - v1X10;
  11063. v12Y10 = v2Y10 - v1Y10;
  11064. v12Z10 = v2Z10 - v1Z10;
  11065. v23X3 = v3X3 - v2X10;
  11066. v23Y3 = v3Y3 - v2Y10;
  11067. v23Z3 = v3Z3 - v2Z10;
  11068. v31X2 = v1X10 - v3X3;
  11069. v31Y2 = v1Y10 - v3Y3;
  11070. v31Z2 = v1Z10 - v3Z3;
  11071. var n3;
  11072. var nX3;
  11073. var nY3;
  11074. var nZ3;
  11075. nX3 = v12Y10 * v23Z3 - v12Z10 * v23Y3;
  11076. nY3 = v12Z10 * v23X3 - v12X10 * v23Z3;
  11077. nZ3 = v12X10 * v23Y3 - v12Y10 * v23X3;
  11078. var n122;
  11079. var n12X2;
  11080. var n12Y2;
  11081. var n12Z2;
  11082. var n232;
  11083. var n23X2;
  11084. var n23Y2;
  11085. var n23Z2;
  11086. var n312;
  11087. var n31X2;
  11088. var n31Y2;
  11089. var n31Z2;
  11090. n12X2 = v12Y10 * nZ3 - v12Z10 * nY3;
  11091. n12Y2 = v12Z10 * nX3 - v12X10 * nZ3;
  11092. n12Z2 = v12X10 * nY3 - v12Y10 * nX3;
  11093. n23X2 = v23Y3 * nZ3 - v23Z3 * nY3;
  11094. n23Y2 = v23Z3 * nX3 - v23X3 * nZ3;
  11095. n23Z2 = v23X3 * nY3 - v23Y3 * nX3;
  11096. n31X2 = v31Y2 * nZ3 - v31Z2 * nY3;
  11097. n31Y2 = v31Z2 * nX3 - v31X2 * nZ3;
  11098. n31Z2 = v31X2 * nY3 - v31Y2 * nX3;
  11099. var d122 = v1X10 * n12X2 + v1Y10 * n12Y2 + v1Z10 * n12Z2;
  11100. var d232 = v2X10 * n23X2 + v2Y10 * n23Y2 + v2Z10 * n23Z2;
  11101. var d312 = v3X3 * n31X2 + v3Y3 * n31Y2 + v3Z3 * n31Z2;
  11102. var mind3 = -1;
  11103. var minv3;
  11104. var minvX3;
  11105. var minvY3;
  11106. var minvZ3;
  11107. var mini3 = 0;
  11108. minvX3 = 0;
  11109. minvY3 = 0;
  11110. minvZ3 = 0;
  11111. if(d122 < 0) {
  11112. var v118;
  11113. var v1X11;
  11114. var v1Y11;
  11115. var v1Z11;
  11116. var v217;
  11117. var v2X11;
  11118. var v2Y11;
  11119. var v2Z11;
  11120. var v76 = vec11;
  11121. v1X11 = v76.x;
  11122. v1Y11 = v76.y;
  11123. v1Z11 = v76.z;
  11124. var v77 = vec31;
  11125. v2X11 = v77.x;
  11126. v2Y11 = v77.y;
  11127. v2Z11 = v77.z;
  11128. var v1211;
  11129. var v12X11;
  11130. var v12Y11;
  11131. var v12Z11;
  11132. v12X11 = v2X11 - v1X11;
  11133. v12Y11 = v2Y11 - v1Y11;
  11134. v12Z11 = v2Z11 - v1Z11;
  11135. var d15 = v12X11 * v12X11 + v12Y11 * v12Y11 + v12Z11 * v12Z11;
  11136. var t7 = v12X11 * v1X11 + v12Y11 * v1Y11 + v12Z11 * v1Z11;
  11137. t7 = -t7 / d15;
  11138. var b7;
  11139. if(t7 < 0) {
  11140. var v78 = closest;
  11141. v78.x = v1X11;
  11142. v78.y = v1Y11;
  11143. v78.z = v1Z11;
  11144. b7 = 1;
  11145. } else if(t7 > 1) {
  11146. var v79 = closest;
  11147. v79.x = v2X11;
  11148. v79.y = v2Y11;
  11149. v79.z = v2Z11;
  11150. b7 = 2;
  11151. } else {
  11152. var p7;
  11153. var pX7;
  11154. var pY7;
  11155. var pZ7;
  11156. pX7 = v1X11 + v12X11 * t7;
  11157. pY7 = v1Y11 + v12Y11 * t7;
  11158. pZ7 = v1Z11 + v12Z11 * t7;
  11159. var v80 = closest;
  11160. v80.x = pX7;
  11161. v80.y = pY7;
  11162. v80.z = pZ7;
  11163. b7 = 3;
  11164. }
  11165. var d16 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11166. mini3 = b7;
  11167. mind3 = d16;
  11168. var v81 = closest;
  11169. minvX3 = v81.x;
  11170. minvY3 = v81.y;
  11171. minvZ3 = v81.z;
  11172. }
  11173. if(d232 < 0) {
  11174. var v119;
  11175. var v1X12;
  11176. var v1Y12;
  11177. var v1Z12;
  11178. var v218;
  11179. var v2X12;
  11180. var v2Y12;
  11181. var v2Z12;
  11182. var v82 = vec31;
  11183. v1X12 = v82.x;
  11184. v1Y12 = v82.y;
  11185. v1Z12 = v82.z;
  11186. var v83 = vec4;
  11187. v2X12 = v83.x;
  11188. v2Y12 = v83.y;
  11189. v2Z12 = v83.z;
  11190. var v1212;
  11191. var v12X12;
  11192. var v12Y12;
  11193. var v12Z12;
  11194. v12X12 = v2X12 - v1X12;
  11195. v12Y12 = v2Y12 - v1Y12;
  11196. v12Z12 = v2Z12 - v1Z12;
  11197. var d17 = v12X12 * v12X12 + v12Y12 * v12Y12 + v12Z12 * v12Z12;
  11198. var t8 = v12X12 * v1X12 + v12Y12 * v1Y12 + v12Z12 * v1Z12;
  11199. t8 = -t8 / d17;
  11200. var b8;
  11201. if(t8 < 0) {
  11202. var v84 = closest;
  11203. v84.x = v1X12;
  11204. v84.y = v1Y12;
  11205. v84.z = v1Z12;
  11206. b8 = 1;
  11207. } else if(t8 > 1) {
  11208. var v85 = closest;
  11209. v85.x = v2X12;
  11210. v85.y = v2Y12;
  11211. v85.z = v2Z12;
  11212. b8 = 2;
  11213. } else {
  11214. var p8;
  11215. var pX8;
  11216. var pY8;
  11217. var pZ8;
  11218. pX8 = v1X12 + v12X12 * t8;
  11219. pY8 = v1Y12 + v12Y12 * t8;
  11220. pZ8 = v1Z12 + v12Z12 * t8;
  11221. var v86 = closest;
  11222. v86.x = pX8;
  11223. v86.y = pY8;
  11224. v86.z = pZ8;
  11225. b8 = 3;
  11226. }
  11227. var d18 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11228. if(mind3 < 0 || d18 < mind3) {
  11229. mini3 = b8 << 1;
  11230. mind3 = d18;
  11231. var v87 = closest;
  11232. minvX3 = v87.x;
  11233. minvY3 = v87.y;
  11234. minvZ3 = v87.z;
  11235. }
  11236. }
  11237. if(d312 < 0) {
  11238. var v120;
  11239. var v1X13;
  11240. var v1Y13;
  11241. var v1Z13;
  11242. var v219;
  11243. var v2X13;
  11244. var v2Y13;
  11245. var v2Z13;
  11246. var v88 = vec11;
  11247. v1X13 = v88.x;
  11248. v1Y13 = v88.y;
  11249. v1Z13 = v88.z;
  11250. var v89 = vec4;
  11251. v2X13 = v89.x;
  11252. v2Y13 = v89.y;
  11253. v2Z13 = v89.z;
  11254. var v1213;
  11255. var v12X13;
  11256. var v12Y13;
  11257. var v12Z13;
  11258. v12X13 = v2X13 - v1X13;
  11259. v12Y13 = v2Y13 - v1Y13;
  11260. v12Z13 = v2Z13 - v1Z13;
  11261. var d19 = v12X13 * v12X13 + v12Y13 * v12Y13 + v12Z13 * v12Z13;
  11262. var t9 = v12X13 * v1X13 + v12Y13 * v1Y13 + v12Z13 * v1Z13;
  11263. t9 = -t9 / d19;
  11264. var b9;
  11265. if(t9 < 0) {
  11266. var v90 = closest;
  11267. v90.x = v1X13;
  11268. v90.y = v1Y13;
  11269. v90.z = v1Z13;
  11270. b9 = 1;
  11271. } else if(t9 > 1) {
  11272. var v91 = closest;
  11273. v91.x = v2X13;
  11274. v91.y = v2Y13;
  11275. v91.z = v2Z13;
  11276. b9 = 2;
  11277. } else {
  11278. var p9;
  11279. var pX9;
  11280. var pY9;
  11281. var pZ9;
  11282. pX9 = v1X13 + v12X13 * t9;
  11283. pY9 = v1Y13 + v12Y13 * t9;
  11284. pZ9 = v1Z13 + v12Z13 * t9;
  11285. var v92 = closest;
  11286. v92.x = pX9;
  11287. v92.y = pY9;
  11288. v92.z = pZ9;
  11289. b9 = 3;
  11290. }
  11291. var d20 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11292. if(mind3 < 0 || d20 < mind3) {
  11293. mini3 = b9 & 1 | (b9 & 2) << 1;
  11294. mind3 = d20;
  11295. var v93 = closest;
  11296. minvX3 = v93.x;
  11297. minvY3 = v93.y;
  11298. minvZ3 = v93.z;
  11299. }
  11300. }
  11301. var b10;
  11302. if(mind3 > 0) {
  11303. var v94 = closest;
  11304. v94.x = minvX3;
  11305. v94.y = minvY3;
  11306. v94.z = minvZ3;
  11307. b10 = mini3;
  11308. } else {
  11309. var l3 = nX3 * nX3 + nY3 * nY3 + nZ3 * nZ3;
  11310. if(l3 > 0) {
  11311. l3 = 1 / Math.sqrt(l3);
  11312. }
  11313. nX3 *= l3;
  11314. nY3 *= l3;
  11315. nZ3 *= l3;
  11316. var dn2 = v1X10 * nX3 + v1Y10 * nY3 + v1Z10 * nZ3;
  11317. var l22 = nX3 * nX3 + nY3 * nY3 + nZ3 * nZ3;
  11318. l22 = dn2 / l22;
  11319. minvX3 = nX3 * l22;
  11320. minvY3 = nY3 * l22;
  11321. minvZ3 = nZ3 * l22;
  11322. var v95 = closest;
  11323. v95.x = minvX3;
  11324. v95.y = minvY3;
  11325. v95.z = minvZ3;
  11326. b10 = 7;
  11327. }
  11328. var d21 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11329. if(mind1 < 0 || d21 < mind1) {
  11330. mini1 = b10 & 1 | (b10 & 6) << 1;
  11331. mind1 = d21;
  11332. var v96 = closest;
  11333. minvX1 = v96.x;
  11334. minvY1 = v96.y;
  11335. minvZ1 = v96.z;
  11336. }
  11337. }
  11338. if(d142 * sign < 0) {
  11339. var v130;
  11340. var v1X14;
  11341. var v1Y14;
  11342. var v1Z14;
  11343. var v220;
  11344. var v2X14;
  11345. var v2Y14;
  11346. var v2Z14;
  11347. var v316;
  11348. var v3X4;
  11349. var v3Y4;
  11350. var v3Z4;
  11351. var v1214;
  11352. var v12X14;
  11353. var v12Y14;
  11354. var v12Z14;
  11355. var v234;
  11356. var v23X4;
  11357. var v23Y4;
  11358. var v23Z4;
  11359. var v317;
  11360. var v31X3;
  11361. var v31Y3;
  11362. var v31Z3;
  11363. var v97 = vec11;
  11364. v1X14 = v97.x;
  11365. v1Y14 = v97.y;
  11366. v1Z14 = v97.z;
  11367. var v98 = vec21;
  11368. v2X14 = v98.x;
  11369. v2Y14 = v98.y;
  11370. v2Z14 = v98.z;
  11371. var v99 = vec4;
  11372. v3X4 = v99.x;
  11373. v3Y4 = v99.y;
  11374. v3Z4 = v99.z;
  11375. v12X14 = v2X14 - v1X14;
  11376. v12Y14 = v2Y14 - v1Y14;
  11377. v12Z14 = v2Z14 - v1Z14;
  11378. v23X4 = v3X4 - v2X14;
  11379. v23Y4 = v3Y4 - v2Y14;
  11380. v23Z4 = v3Z4 - v2Z14;
  11381. v31X3 = v1X14 - v3X4;
  11382. v31Y3 = v1Y14 - v3Y4;
  11383. v31Z3 = v1Z14 - v3Z4;
  11384. var n4;
  11385. var nX4;
  11386. var nY4;
  11387. var nZ4;
  11388. nX4 = v12Y14 * v23Z4 - v12Z14 * v23Y4;
  11389. nY4 = v12Z14 * v23X4 - v12X14 * v23Z4;
  11390. nZ4 = v12X14 * v23Y4 - v12Y14 * v23X4;
  11391. var n124;
  11392. var n12X3;
  11393. var n12Y3;
  11394. var n12Z3;
  11395. var n233;
  11396. var n23X3;
  11397. var n23Y3;
  11398. var n23Z3;
  11399. var n313;
  11400. var n31X3;
  11401. var n31Y3;
  11402. var n31Z3;
  11403. n12X3 = v12Y14 * nZ4 - v12Z14 * nY4;
  11404. n12Y3 = v12Z14 * nX4 - v12X14 * nZ4;
  11405. n12Z3 = v12X14 * nY4 - v12Y14 * nX4;
  11406. n23X3 = v23Y4 * nZ4 - v23Z4 * nY4;
  11407. n23Y3 = v23Z4 * nX4 - v23X4 * nZ4;
  11408. n23Z3 = v23X4 * nY4 - v23Y4 * nX4;
  11409. n31X3 = v31Y3 * nZ4 - v31Z3 * nY4;
  11410. n31Y3 = v31Z3 * nX4 - v31X3 * nZ4;
  11411. n31Z3 = v31X3 * nY4 - v31Y3 * nX4;
  11412. var d124 = v1X14 * n12X3 + v1Y14 * n12Y3 + v1Z14 * n12Z3;
  11413. var d233 = v2X14 * n23X3 + v2Y14 * n23Y3 + v2Z14 * n23Z3;
  11414. var d313 = v3X4 * n31X3 + v3Y4 * n31Y3 + v3Z4 * n31Z3;
  11415. var mind4 = -1;
  11416. var minv4;
  11417. var minvX4;
  11418. var minvY4;
  11419. var minvZ4;
  11420. var mini4 = 0;
  11421. minvX4 = 0;
  11422. minvY4 = 0;
  11423. minvZ4 = 0;
  11424. if(d124 < 0) {
  11425. var v132;
  11426. var v1X15;
  11427. var v1Y15;
  11428. var v1Z15;
  11429. var v221;
  11430. var v2X15;
  11431. var v2Y15;
  11432. var v2Z15;
  11433. var v100 = vec11;
  11434. v1X15 = v100.x;
  11435. v1Y15 = v100.y;
  11436. v1Z15 = v100.z;
  11437. var v101 = vec21;
  11438. v2X15 = v101.x;
  11439. v2Y15 = v101.y;
  11440. v2Z15 = v101.z;
  11441. var v1215;
  11442. var v12X15;
  11443. var v12Y15;
  11444. var v12Z15;
  11445. v12X15 = v2X15 - v1X15;
  11446. v12Y15 = v2Y15 - v1Y15;
  11447. v12Z15 = v2Z15 - v1Z15;
  11448. var d22 = v12X15 * v12X15 + v12Y15 * v12Y15 + v12Z15 * v12Z15;
  11449. var t10 = v12X15 * v1X15 + v12Y15 * v1Y15 + v12Z15 * v1Z15;
  11450. t10 = -t10 / d22;
  11451. var b11;
  11452. if(t10 < 0) {
  11453. var v102 = closest;
  11454. v102.x = v1X15;
  11455. v102.y = v1Y15;
  11456. v102.z = v1Z15;
  11457. b11 = 1;
  11458. } else if(t10 > 1) {
  11459. var v103 = closest;
  11460. v103.x = v2X15;
  11461. v103.y = v2Y15;
  11462. v103.z = v2Z15;
  11463. b11 = 2;
  11464. } else {
  11465. var p10;
  11466. var pX10;
  11467. var pY10;
  11468. var pZ10;
  11469. pX10 = v1X15 + v12X15 * t10;
  11470. pY10 = v1Y15 + v12Y15 * t10;
  11471. pZ10 = v1Z15 + v12Z15 * t10;
  11472. var v104 = closest;
  11473. v104.x = pX10;
  11474. v104.y = pY10;
  11475. v104.z = pZ10;
  11476. b11 = 3;
  11477. }
  11478. var d24 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11479. mini4 = b11;
  11480. mind4 = d24;
  11481. var v105 = closest;
  11482. minvX4 = v105.x;
  11483. minvY4 = v105.y;
  11484. minvZ4 = v105.z;
  11485. }
  11486. if(d233 < 0) {
  11487. var v133;
  11488. var v1X16;
  11489. var v1Y16;
  11490. var v1Z16;
  11491. var v222;
  11492. var v2X16;
  11493. var v2Y16;
  11494. var v2Z16;
  11495. var v106 = vec21;
  11496. v1X16 = v106.x;
  11497. v1Y16 = v106.y;
  11498. v1Z16 = v106.z;
  11499. var v107 = vec4;
  11500. v2X16 = v107.x;
  11501. v2Y16 = v107.y;
  11502. v2Z16 = v107.z;
  11503. var v1216;
  11504. var v12X16;
  11505. var v12Y16;
  11506. var v12Z16;
  11507. v12X16 = v2X16 - v1X16;
  11508. v12Y16 = v2Y16 - v1Y16;
  11509. v12Z16 = v2Z16 - v1Z16;
  11510. var d25 = v12X16 * v12X16 + v12Y16 * v12Y16 + v12Z16 * v12Z16;
  11511. var t11 = v12X16 * v1X16 + v12Y16 * v1Y16 + v12Z16 * v1Z16;
  11512. t11 = -t11 / d25;
  11513. var b12;
  11514. if(t11 < 0) {
  11515. var v108 = closest;
  11516. v108.x = v1X16;
  11517. v108.y = v1Y16;
  11518. v108.z = v1Z16;
  11519. b12 = 1;
  11520. } else if(t11 > 1) {
  11521. var v109 = closest;
  11522. v109.x = v2X16;
  11523. v109.y = v2Y16;
  11524. v109.z = v2Z16;
  11525. b12 = 2;
  11526. } else {
  11527. var p11;
  11528. var pX11;
  11529. var pY11;
  11530. var pZ11;
  11531. pX11 = v1X16 + v12X16 * t11;
  11532. pY11 = v1Y16 + v12Y16 * t11;
  11533. pZ11 = v1Z16 + v12Z16 * t11;
  11534. var v134 = closest;
  11535. v134.x = pX11;
  11536. v134.y = pY11;
  11537. v134.z = pZ11;
  11538. b12 = 3;
  11539. }
  11540. var d26 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11541. if(mind4 < 0 || d26 < mind4) {
  11542. mini4 = b12 << 1;
  11543. mind4 = d26;
  11544. var v135 = closest;
  11545. minvX4 = v135.x;
  11546. minvY4 = v135.y;
  11547. minvZ4 = v135.z;
  11548. }
  11549. }
  11550. if(d313 < 0) {
  11551. var v136;
  11552. var v1X17;
  11553. var v1Y17;
  11554. var v1Z17;
  11555. var v223;
  11556. var v2X17;
  11557. var v2Y17;
  11558. var v2Z17;
  11559. var v137 = vec11;
  11560. v1X17 = v137.x;
  11561. v1Y17 = v137.y;
  11562. v1Z17 = v137.z;
  11563. var v138 = vec4;
  11564. v2X17 = v138.x;
  11565. v2Y17 = v138.y;
  11566. v2Z17 = v138.z;
  11567. var v1217;
  11568. var v12X17;
  11569. var v12Y17;
  11570. var v12Z17;
  11571. v12X17 = v2X17 - v1X17;
  11572. v12Y17 = v2Y17 - v1Y17;
  11573. v12Z17 = v2Z17 - v1Z17;
  11574. var d27 = v12X17 * v12X17 + v12Y17 * v12Y17 + v12Z17 * v12Z17;
  11575. var t12 = v12X17 * v1X17 + v12Y17 * v1Y17 + v12Z17 * v1Z17;
  11576. t12 = -t12 / d27;
  11577. var b13;
  11578. if(t12 < 0) {
  11579. var v139 = closest;
  11580. v139.x = v1X17;
  11581. v139.y = v1Y17;
  11582. v139.z = v1Z17;
  11583. b13 = 1;
  11584. } else if(t12 > 1) {
  11585. var v140 = closest;
  11586. v140.x = v2X17;
  11587. v140.y = v2Y17;
  11588. v140.z = v2Z17;
  11589. b13 = 2;
  11590. } else {
  11591. var p12;
  11592. var pX12;
  11593. var pY12;
  11594. var pZ12;
  11595. pX12 = v1X17 + v12X17 * t12;
  11596. pY12 = v1Y17 + v12Y17 * t12;
  11597. pZ12 = v1Z17 + v12Z17 * t12;
  11598. var v142 = closest;
  11599. v142.x = pX12;
  11600. v142.y = pY12;
  11601. v142.z = pZ12;
  11602. b13 = 3;
  11603. }
  11604. var d28 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11605. if(mind4 < 0 || d28 < mind4) {
  11606. mini4 = b13 & 1 | (b13 & 2) << 1;
  11607. mind4 = d28;
  11608. var v143 = closest;
  11609. minvX4 = v143.x;
  11610. minvY4 = v143.y;
  11611. minvZ4 = v143.z;
  11612. }
  11613. }
  11614. var b14;
  11615. if(mind4 > 0) {
  11616. var v144 = closest;
  11617. v144.x = minvX4;
  11618. v144.y = minvY4;
  11619. v144.z = minvZ4;
  11620. b14 = mini4;
  11621. } else {
  11622. var l4 = nX4 * nX4 + nY4 * nY4 + nZ4 * nZ4;
  11623. if(l4 > 0) {
  11624. l4 = 1 / Math.sqrt(l4);
  11625. }
  11626. nX4 *= l4;
  11627. nY4 *= l4;
  11628. nZ4 *= l4;
  11629. var dn3 = v1X14 * nX4 + v1Y14 * nY4 + v1Z14 * nZ4;
  11630. var l23 = nX4 * nX4 + nY4 * nY4 + nZ4 * nZ4;
  11631. l23 = dn3 / l23;
  11632. minvX4 = nX4 * l23;
  11633. minvY4 = nY4 * l23;
  11634. minvZ4 = nZ4 * l23;
  11635. var v145 = closest;
  11636. v145.x = minvX4;
  11637. v145.y = minvY4;
  11638. v145.z = minvZ4;
  11639. b14 = 7;
  11640. }
  11641. var d29 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11642. if(mind1 < 0 || d29 < mind1) {
  11643. mini1 = b14 & 3 | (b14 & 4) << 1;
  11644. mind1 = d29;
  11645. var v146 = closest;
  11646. minvX1 = v146.x;
  11647. minvY1 = v146.y;
  11648. minvZ1 = v146.z;
  11649. }
  11650. }
  11651. if(d243 * sign < 0) {
  11652. var v147;
  11653. var v1X18;
  11654. var v1Y18;
  11655. var v1Z18;
  11656. var v224;
  11657. var v2X18;
  11658. var v2Y18;
  11659. var v2Z18;
  11660. var v318;
  11661. var v3X5;
  11662. var v3Y5;
  11663. var v3Z5;
  11664. var v1218;
  11665. var v12X18;
  11666. var v12Y18;
  11667. var v12Z18;
  11668. var v235;
  11669. var v23X5;
  11670. var v23Y5;
  11671. var v23Z5;
  11672. var v319;
  11673. var v31X4;
  11674. var v31Y4;
  11675. var v31Z4;
  11676. var v148 = vec21;
  11677. v1X18 = v148.x;
  11678. v1Y18 = v148.y;
  11679. v1Z18 = v148.z;
  11680. var v149 = vec31;
  11681. v2X18 = v149.x;
  11682. v2Y18 = v149.y;
  11683. v2Z18 = v149.z;
  11684. var v150 = vec4;
  11685. v3X5 = v150.x;
  11686. v3Y5 = v150.y;
  11687. v3Z5 = v150.z;
  11688. v12X18 = v2X18 - v1X18;
  11689. v12Y18 = v2Y18 - v1Y18;
  11690. v12Z18 = v2Z18 - v1Z18;
  11691. v23X5 = v3X5 - v2X18;
  11692. v23Y5 = v3Y5 - v2Y18;
  11693. v23Z5 = v3Z5 - v2Z18;
  11694. v31X4 = v1X18 - v3X5;
  11695. v31Y4 = v1Y18 - v3Y5;
  11696. v31Z4 = v1Z18 - v3Z5;
  11697. var n5;
  11698. var nX5;
  11699. var nY5;
  11700. var nZ5;
  11701. nX5 = v12Y18 * v23Z5 - v12Z18 * v23Y5;
  11702. nY5 = v12Z18 * v23X5 - v12X18 * v23Z5;
  11703. nZ5 = v12X18 * v23Y5 - v12Y18 * v23X5;
  11704. var n125;
  11705. var n12X4;
  11706. var n12Y4;
  11707. var n12Z4;
  11708. var n234;
  11709. var n23X4;
  11710. var n23Y4;
  11711. var n23Z4;
  11712. var n314;
  11713. var n31X4;
  11714. var n31Y4;
  11715. var n31Z4;
  11716. n12X4 = v12Y18 * nZ5 - v12Z18 * nY5;
  11717. n12Y4 = v12Z18 * nX5 - v12X18 * nZ5;
  11718. n12Z4 = v12X18 * nY5 - v12Y18 * nX5;
  11719. n23X4 = v23Y5 * nZ5 - v23Z5 * nY5;
  11720. n23Y4 = v23Z5 * nX5 - v23X5 * nZ5;
  11721. n23Z4 = v23X5 * nY5 - v23Y5 * nX5;
  11722. n31X4 = v31Y4 * nZ5 - v31Z4 * nY5;
  11723. n31Y4 = v31Z4 * nX5 - v31X4 * nZ5;
  11724. n31Z4 = v31X4 * nY5 - v31Y4 * nX5;
  11725. var d125 = v1X18 * n12X4 + v1Y18 * n12Y4 + v1Z18 * n12Z4;
  11726. var d234 = v2X18 * n23X4 + v2Y18 * n23Y4 + v2Z18 * n23Z4;
  11727. var d314 = v3X5 * n31X4 + v3Y5 * n31Y4 + v3Z5 * n31Z4;
  11728. var mind5 = -1;
  11729. var minv5;
  11730. var minvX5;
  11731. var minvY5;
  11732. var minvZ5;
  11733. var mini5 = 0;
  11734. minvX5 = 0;
  11735. minvY5 = 0;
  11736. minvZ5 = 0;
  11737. if(d125 < 0) {
  11738. var v151;
  11739. var v1X19;
  11740. var v1Y19;
  11741. var v1Z19;
  11742. var v225;
  11743. var v2X19;
  11744. var v2Y19;
  11745. var v2Z19;
  11746. var v152 = vec21;
  11747. v1X19 = v152.x;
  11748. v1Y19 = v152.y;
  11749. v1Z19 = v152.z;
  11750. var v153 = vec31;
  11751. v2X19 = v153.x;
  11752. v2Y19 = v153.y;
  11753. v2Z19 = v153.z;
  11754. var v1219;
  11755. var v12X19;
  11756. var v12Y19;
  11757. var v12Z19;
  11758. v12X19 = v2X19 - v1X19;
  11759. v12Y19 = v2Y19 - v1Y19;
  11760. v12Z19 = v2Z19 - v1Z19;
  11761. var d30 = v12X19 * v12X19 + v12Y19 * v12Y19 + v12Z19 * v12Z19;
  11762. var t13 = v12X19 * v1X19 + v12Y19 * v1Y19 + v12Z19 * v1Z19;
  11763. t13 = -t13 / d30;
  11764. var b15;
  11765. if(t13 < 0) {
  11766. var v154 = closest;
  11767. v154.x = v1X19;
  11768. v154.y = v1Y19;
  11769. v154.z = v1Z19;
  11770. b15 = 1;
  11771. } else if(t13 > 1) {
  11772. var v155 = closest;
  11773. v155.x = v2X19;
  11774. v155.y = v2Y19;
  11775. v155.z = v2Z19;
  11776. b15 = 2;
  11777. } else {
  11778. var p13;
  11779. var pX13;
  11780. var pY13;
  11781. var pZ13;
  11782. pX13 = v1X19 + v12X19 * t13;
  11783. pY13 = v1Y19 + v12Y19 * t13;
  11784. pZ13 = v1Z19 + v12Z19 * t13;
  11785. var v156 = closest;
  11786. v156.x = pX13;
  11787. v156.y = pY13;
  11788. v156.z = pZ13;
  11789. b15 = 3;
  11790. }
  11791. var d32 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11792. mini5 = b15;
  11793. mind5 = d32;
  11794. var v157 = closest;
  11795. minvX5 = v157.x;
  11796. minvY5 = v157.y;
  11797. minvZ5 = v157.z;
  11798. }
  11799. if(d234 < 0) {
  11800. var v158;
  11801. var v1X20;
  11802. var v1Y20;
  11803. var v1Z20;
  11804. var v226;
  11805. var v2X20;
  11806. var v2Y20;
  11807. var v2Z20;
  11808. var v159 = vec31;
  11809. v1X20 = v159.x;
  11810. v1Y20 = v159.y;
  11811. v1Z20 = v159.z;
  11812. var v160 = vec4;
  11813. v2X20 = v160.x;
  11814. v2Y20 = v160.y;
  11815. v2Z20 = v160.z;
  11816. var v1220;
  11817. var v12X20;
  11818. var v12Y20;
  11819. var v12Z20;
  11820. v12X20 = v2X20 - v1X20;
  11821. v12Y20 = v2Y20 - v1Y20;
  11822. v12Z20 = v2Z20 - v1Z20;
  11823. var d33 = v12X20 * v12X20 + v12Y20 * v12Y20 + v12Z20 * v12Z20;
  11824. var t14 = v12X20 * v1X20 + v12Y20 * v1Y20 + v12Z20 * v1Z20;
  11825. t14 = -t14 / d33;
  11826. var b16;
  11827. if(t14 < 0) {
  11828. var v161 = closest;
  11829. v161.x = v1X20;
  11830. v161.y = v1Y20;
  11831. v161.z = v1Z20;
  11832. b16 = 1;
  11833. } else if(t14 > 1) {
  11834. var v162 = closest;
  11835. v162.x = v2X20;
  11836. v162.y = v2Y20;
  11837. v162.z = v2Z20;
  11838. b16 = 2;
  11839. } else {
  11840. var p14;
  11841. var pX14;
  11842. var pY14;
  11843. var pZ14;
  11844. pX14 = v1X20 + v12X20 * t14;
  11845. pY14 = v1Y20 + v12Y20 * t14;
  11846. pZ14 = v1Z20 + v12Z20 * t14;
  11847. var v163 = closest;
  11848. v163.x = pX14;
  11849. v163.y = pY14;
  11850. v163.z = pZ14;
  11851. b16 = 3;
  11852. }
  11853. var d34 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11854. if(mind5 < 0 || d34 < mind5) {
  11855. mini5 = b16 << 1;
  11856. mind5 = d34;
  11857. var v164 = closest;
  11858. minvX5 = v164.x;
  11859. minvY5 = v164.y;
  11860. minvZ5 = v164.z;
  11861. }
  11862. }
  11863. if(d314 < 0) {
  11864. var v165;
  11865. var v1X21;
  11866. var v1Y21;
  11867. var v1Z21;
  11868. var v227;
  11869. var v2X21;
  11870. var v2Y21;
  11871. var v2Z21;
  11872. var v166 = vec21;
  11873. v1X21 = v166.x;
  11874. v1Y21 = v166.y;
  11875. v1Z21 = v166.z;
  11876. var v167 = vec4;
  11877. v2X21 = v167.x;
  11878. v2Y21 = v167.y;
  11879. v2Z21 = v167.z;
  11880. var v1221;
  11881. var v12X21;
  11882. var v12Y21;
  11883. var v12Z21;
  11884. v12X21 = v2X21 - v1X21;
  11885. v12Y21 = v2Y21 - v1Y21;
  11886. v12Z21 = v2Z21 - v1Z21;
  11887. var d35 = v12X21 * v12X21 + v12Y21 * v12Y21 + v12Z21 * v12Z21;
  11888. var t15 = v12X21 * v1X21 + v12Y21 * v1Y21 + v12Z21 * v1Z21;
  11889. t15 = -t15 / d35;
  11890. var b17;
  11891. if(t15 < 0) {
  11892. var v168 = closest;
  11893. v168.x = v1X21;
  11894. v168.y = v1Y21;
  11895. v168.z = v1Z21;
  11896. b17 = 1;
  11897. } else if(t15 > 1) {
  11898. var v169 = closest;
  11899. v169.x = v2X21;
  11900. v169.y = v2Y21;
  11901. v169.z = v2Z21;
  11902. b17 = 2;
  11903. } else {
  11904. var p15;
  11905. var pX15;
  11906. var pY15;
  11907. var pZ15;
  11908. pX15 = v1X21 + v12X21 * t15;
  11909. pY15 = v1Y21 + v12Y21 * t15;
  11910. pZ15 = v1Z21 + v12Z21 * t15;
  11911. var v170 = closest;
  11912. v170.x = pX15;
  11913. v170.y = pY15;
  11914. v170.z = pZ15;
  11915. b17 = 3;
  11916. }
  11917. var d36 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11918. if(mind5 < 0 || d36 < mind5) {
  11919. mini5 = b17 & 1 | (b17 & 2) << 1;
  11920. mind5 = d36;
  11921. var v171 = closest;
  11922. minvX5 = v171.x;
  11923. minvY5 = v171.y;
  11924. minvZ5 = v171.z;
  11925. }
  11926. }
  11927. var b18;
  11928. if(mind5 > 0) {
  11929. var v172 = closest;
  11930. v172.x = minvX5;
  11931. v172.y = minvY5;
  11932. v172.z = minvZ5;
  11933. b18 = mini5;
  11934. } else {
  11935. var l5 = nX5 * nX5 + nY5 * nY5 + nZ5 * nZ5;
  11936. if(l5 > 0) {
  11937. l5 = 1 / Math.sqrt(l5);
  11938. }
  11939. nX5 *= l5;
  11940. nY5 *= l5;
  11941. nZ5 *= l5;
  11942. var dn4 = v1X18 * nX5 + v1Y18 * nY5 + v1Z18 * nZ5;
  11943. var l24 = nX5 * nX5 + nY5 * nY5 + nZ5 * nZ5;
  11944. l24 = dn4 / l24;
  11945. minvX5 = nX5 * l24;
  11946. minvY5 = nY5 * l24;
  11947. minvZ5 = nZ5 * l24;
  11948. var v173 = closest;
  11949. v173.x = minvX5;
  11950. v173.y = minvY5;
  11951. v173.z = minvZ5;
  11952. b18 = 7;
  11953. }
  11954. var d37 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z;
  11955. if(mind1 < 0 || d37 < mind1) {
  11956. mini1 = b18 << 1;
  11957. mind1 = d37;
  11958. var v174 = closest;
  11959. minvX1 = v174.x;
  11960. minvY1 = v174.y;
  11961. minvZ1 = v174.z;
  11962. }
  11963. }
  11964. if(mind1 > 0) {
  11965. var v175 = closest;
  11966. v175.x = minvX1;
  11967. v175.y = minvY1;
  11968. v175.z = minvZ1;
  11969. v4 = mini1;
  11970. } else {
  11971. closest.zero();
  11972. v4 = 15;
  11973. }
  11974. break;
  11975. }
  11976. this.shrinkSimplex(v4);
  11977. if(closest.x * closest.x + closest.y * closest.y + closest.z * closest.z < eps2) {
  11978. if(lambda == 0 || this.simplexSize == 4) {
  11979. hit.fraction = lambda;
  11980. return false;
  11981. }
  11982. this.interpolateClosestPoints();
  11983. hit.fraction = lambda;
  11984. var _this3 = hit.normal;
  11985. _this3.x = dir.x;
  11986. _this3.y = dir.y;
  11987. _this3.z = dir.z;
  11988. var _this4 = _this3;
  11989. var invLen = Math.sqrt(_this4.x * _this4.x + _this4.y * _this4.y + _this4.z * _this4.z);
  11990. if(invLen > 0) {
  11991. invLen = 1 / invLen;
  11992. }
  11993. var tx2 = _this4.x * invLen;
  11994. var ty2 = _this4.y * invLen;
  11995. var tz2 = _this4.z * invLen;
  11996. _this4.x = tx2;
  11997. _this4.y = ty2;
  11998. _this4.z = tz2;
  11999. var _this5 = hit.position;
  12000. var v176 = this.closestPoint1;
  12001. _this5.x = v176.x;
  12002. _this5.y = v176.y;
  12003. _this5.z = v176.z;
  12004. var _this6 = _this5;
  12005. var tx3 = _this6.x + tl1.x * lambda;
  12006. var ty3 = _this6.y + tl1.y * lambda;
  12007. var tz3 = _this6.z + tl1.z * lambda;
  12008. _this6.x = tx3;
  12009. _this6.y = ty3;
  12010. _this6.z = tz3;
  12011. return true;
  12012. }
  12013. dir.x = closest.x;
  12014. dir.y = closest.y;
  12015. dir.z = closest.z;
  12016. var _this7 = dir;
  12017. var tx4 = -_this7.x;
  12018. var ty4 = -_this7.y;
  12019. var tz4 = -_this7.z;
  12020. _this7.x = tx4;
  12021. _this7.y = ty4;
  12022. _this7.z = tz4;
  12023. if(this.c1 != null) {
  12024. this.computeWitnessPoint1(true);
  12025. } else {
  12026. var v177 = this.w1[this.simplexSize];
  12027. v177.x = this.tf1._positionX;
  12028. v177.y = this.tf1._positionY;
  12029. v177.z = this.tf1._positionZ;
  12030. }
  12031. this.computeWitnessPoint2(true);
  12032. var _this8 = this.s[this.simplexSize];
  12033. var v178 = this.w1[this.simplexSize];
  12034. _this8.x = v178.x;
  12035. _this8.y = v178.y;
  12036. _this8.z = v178.z;
  12037. var _this9 = _this8;
  12038. var v179 = this.w2[this.simplexSize];
  12039. var tx5 = _this9.x - v179.x;
  12040. var ty5 = _this9.y - v179.y;
  12041. var tz5 = _this9.z - v179.z;
  12042. _this9.x = tx5;
  12043. _this9.y = ty5;
  12044. _this9.z = tz5;
  12045. var _this10 = s[this.simplexSize];
  12046. var tx6 = _this10.x - rayX.x;
  12047. var ty6 = _this10.y - rayX.y;
  12048. var tz6 = _this10.z - rayX.z;
  12049. _this10.x = tx6;
  12050. _this10.y = ty6;
  12051. _this10.z = tz6;
  12052. if(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < eps2) {
  12053. throw new Error("!?");
  12054. }
  12055. var p16 = s[this.simplexSize];
  12056. var n6 = dir;
  12057. var pn = p16.x * n6.x + p16.y * n6.y + p16.z * n6.z;
  12058. if(pn < 0) {
  12059. if(rayR.x * n6.x + rayR.y * n6.y + rayR.z * n6.z >= 0) {
  12060. return false;
  12061. }
  12062. var dLambda = pn / (rayR.x * n6.x + rayR.y * n6.y + rayR.z * n6.z);
  12063. lambda += dLambda;
  12064. if(lambda >= 1) {
  12065. return false;
  12066. }
  12067. var tx7 = rayX.x + rayR.x * dLambda;
  12068. var ty7 = rayX.y + rayR.y * dLambda;
  12069. var tz7 = rayX.z + rayR.z * dLambda;
  12070. rayX.x = tx7;
  12071. rayX.y = ty7;
  12072. rayX.z = tz7;
  12073. var _g1 = 0;
  12074. var _g2 = this.simplexSize + 1;
  12075. while(_g1 < _g2) {
  12076. var i = _g1++;
  12077. var _this11 = s[i];
  12078. var s1 = -dLambda;
  12079. var tx8 = _this11.x + rayR.x * s1;
  12080. var ty8 = _this11.y + rayR.y * s1;
  12081. var tz8 = _this11.z + rayR.z * s1;
  12082. _this11.x = tx8;
  12083. _this11.y = ty8;
  12084. _this11.z = tz8;
  12085. }
  12086. }
  12087. var duplicate = false;
  12088. var _g11 = 0;
  12089. var _g21 = this.simplexSize;
  12090. while(_g11 < _g21) {
  12091. var i1 = _g11++;
  12092. var dx = s[i1].x - s[this.simplexSize].x;
  12093. var dy = s[i1].y - s[this.simplexSize].y;
  12094. var dz = s[i1].z - s[this.simplexSize].z;
  12095. if(dx * dx + dy * dy + dz * dz < eps2) {
  12096. duplicate = true;
  12097. break;
  12098. }
  12099. }
  12100. if(!duplicate) {
  12101. this.simplexSize++;
  12102. }
  12103. ++count;
  12104. }
  12105. return false;
  12106. }
  12107. interpolateClosestPoints() {
  12108. switch(this.simplexSize) {
  12109. case 1:
  12110. var _this = this.closestPoint1;
  12111. var v = this.w1[0];
  12112. _this.x = v.x;
  12113. _this.y = v.y;
  12114. _this.z = v.z;
  12115. var _this1 = this.closestPoint2;
  12116. var v1 = this.w2[0];
  12117. _this1.x = v1.x;
  12118. _this1.y = v1.y;
  12119. _this1.z = v1.z;
  12120. break;
  12121. case 2:
  12122. var c;
  12123. var cX;
  12124. var cY;
  12125. var cZ;
  12126. var v2 = this.closest;
  12127. cX = v2.x;
  12128. cY = v2.y;
  12129. cZ = v2.z;
  12130. var s0;
  12131. var s0X;
  12132. var s0Y;
  12133. var s0Z;
  12134. var w10;
  12135. var w10X;
  12136. var w10Y;
  12137. var w10Z;
  12138. var w20;
  12139. var w20X;
  12140. var w20Y;
  12141. var w20Z;
  12142. var s1;
  12143. var s1X;
  12144. var s1Y;
  12145. var s1Z;
  12146. var w11;
  12147. var w11X;
  12148. var w11Y;
  12149. var w11Z;
  12150. var w21;
  12151. var w21X;
  12152. var w21Y;
  12153. var w21Z;
  12154. var s2;
  12155. var s2X;
  12156. var s2Y;
  12157. var s2Z;
  12158. var w12;
  12159. var w12X;
  12160. var w12Y;
  12161. var w12Z;
  12162. var w22;
  12163. var w22X;
  12164. var w22Y;
  12165. var w22Z;
  12166. var v3 = this.s[0];
  12167. s0X = v3.x;
  12168. s0Y = v3.y;
  12169. s0Z = v3.z;
  12170. var v4 = this.w1[0];
  12171. w10X = v4.x;
  12172. w10Y = v4.y;
  12173. w10Z = v4.z;
  12174. var v5 = this.w2[0];
  12175. w20X = v5.x;
  12176. w20Y = v5.y;
  12177. w20Z = v5.z;
  12178. var v6 = this.s[1];
  12179. s1X = v6.x;
  12180. s1Y = v6.y;
  12181. s1Z = v6.z;
  12182. var v7 = this.w1[1];
  12183. w11X = v7.x;
  12184. w11Y = v7.y;
  12185. w11Z = v7.z;
  12186. var v8 = this.w2[1];
  12187. w21X = v8.x;
  12188. w21Y = v8.y;
  12189. w21Z = v8.z;
  12190. var v9 = this.s[2];
  12191. s2X = v9.x;
  12192. s2Y = v9.y;
  12193. s2Z = v9.z;
  12194. var v10 = this.w1[2];
  12195. w12X = v10.x;
  12196. w12Y = v10.y;
  12197. w12Z = v10.z;
  12198. var v11 = this.w2[2];
  12199. w22X = v11.x;
  12200. w22Y = v11.y;
  12201. w22Z = v11.z;
  12202. var s01;
  12203. var s01X;
  12204. var s01Y;
  12205. var s01Z;
  12206. s01X = s1X - s0X;
  12207. s01Y = s1Y - s0Y;
  12208. s01Z = s1Z - s0Z;
  12209. var invDet = s01X * s01X + s01Y * s01Y + s01Z * s01Z;
  12210. if(invDet != 0) {
  12211. invDet = 1 / invDet;
  12212. }
  12213. var s0c;
  12214. var s0cX;
  12215. var s0cY;
  12216. var s0cZ;
  12217. s0cX = cX - s0X;
  12218. s0cY = cY - s0Y;
  12219. s0cZ = cZ - s0Z;
  12220. var t = (s0cX * s01X + s0cY * s01Y + s0cZ * s01Z) * invDet;
  12221. var diff;
  12222. var diffX;
  12223. var diffY;
  12224. var diffZ;
  12225. var cp1;
  12226. var cp1X;
  12227. var cp1Y;
  12228. var cp1Z;
  12229. var cp2;
  12230. var cp2X;
  12231. var cp2Y;
  12232. var cp2Z;
  12233. diffX = w11X - w10X;
  12234. diffY = w11Y - w10Y;
  12235. diffZ = w11Z - w10Z;
  12236. cp1X = w10X + diffX * t;
  12237. cp1Y = w10Y + diffY * t;
  12238. cp1Z = w10Z + diffZ * t;
  12239. diffX = w21X - w20X;
  12240. diffY = w21Y - w20Y;
  12241. diffZ = w21Z - w20Z;
  12242. cp2X = w20X + diffX * t;
  12243. cp2Y = w20Y + diffY * t;
  12244. cp2Z = w20Z + diffZ * t;
  12245. var v12 = this.closestPoint1;
  12246. v12.x = cp1X;
  12247. v12.y = cp1Y;
  12248. v12.z = cp1Z;
  12249. var v13 = this.closestPoint2;
  12250. v13.x = cp2X;
  12251. v13.y = cp2Y;
  12252. v13.z = cp2Z;
  12253. break;
  12254. case 3:
  12255. var c1;
  12256. var cX1;
  12257. var cY1;
  12258. var cZ1;
  12259. var v14 = this.closest;
  12260. cX1 = v14.x;
  12261. cY1 = v14.y;
  12262. cZ1 = v14.z;
  12263. var s02;
  12264. var s0X1;
  12265. var s0Y1;
  12266. var s0Z1;
  12267. var w101;
  12268. var w10X1;
  12269. var w10Y1;
  12270. var w10Z1;
  12271. var w201;
  12272. var w20X1;
  12273. var w20Y1;
  12274. var w20Z1;
  12275. var s11;
  12276. var s1X1;
  12277. var s1Y1;
  12278. var s1Z1;
  12279. var w111;
  12280. var w11X1;
  12281. var w11Y1;
  12282. var w11Z1;
  12283. var w211;
  12284. var w21X1;
  12285. var w21Y1;
  12286. var w21Z1;
  12287. var s21;
  12288. var s2X1;
  12289. var s2Y1;
  12290. var s2Z1;
  12291. var w121;
  12292. var w12X1;
  12293. var w12Y1;
  12294. var w12Z1;
  12295. var w221;
  12296. var w22X1;
  12297. var w22Y1;
  12298. var w22Z1;
  12299. var v15 = this.s[0];
  12300. s0X1 = v15.x;
  12301. s0Y1 = v15.y;
  12302. s0Z1 = v15.z;
  12303. var v16 = this.w1[0];
  12304. w10X1 = v16.x;
  12305. w10Y1 = v16.y;
  12306. w10Z1 = v16.z;
  12307. var v17 = this.w2[0];
  12308. w20X1 = v17.x;
  12309. w20Y1 = v17.y;
  12310. w20Z1 = v17.z;
  12311. var v18 = this.s[1];
  12312. s1X1 = v18.x;
  12313. s1Y1 = v18.y;
  12314. s1Z1 = v18.z;
  12315. var v19 = this.w1[1];
  12316. w11X1 = v19.x;
  12317. w11Y1 = v19.y;
  12318. w11Z1 = v19.z;
  12319. var v20 = this.w2[1];
  12320. w21X1 = v20.x;
  12321. w21Y1 = v20.y;
  12322. w21Z1 = v20.z;
  12323. var v21 = this.s[2];
  12324. s2X1 = v21.x;
  12325. s2Y1 = v21.y;
  12326. s2Z1 = v21.z;
  12327. var v22 = this.w1[2];
  12328. w12X1 = v22.x;
  12329. w12Y1 = v22.y;
  12330. w12Z1 = v22.z;
  12331. var v23 = this.w2[2];
  12332. w22X1 = v23.x;
  12333. w22Y1 = v23.y;
  12334. w22Z1 = v23.z;
  12335. var s011;
  12336. var s01X1;
  12337. var s01Y1;
  12338. var s01Z1;
  12339. var s021;
  12340. var s02X;
  12341. var s02Y;
  12342. var s02Z;
  12343. var s0c1;
  12344. var s0cX1;
  12345. var s0cY1;
  12346. var s0cZ1;
  12347. s01X1 = s1X1 - s0X1;
  12348. s01Y1 = s1Y1 - s0Y1;
  12349. s01Z1 = s1Z1 - s0Z1;
  12350. s02X = s2X1 - s0X1;
  12351. s02Y = s2Y1 - s0Y1;
  12352. s02Z = s2Z1 - s0Z1;
  12353. s0cX1 = cX1 - s0X1;
  12354. s0cY1 = cY1 - s0Y1;
  12355. s0cZ1 = cZ1 - s0Z1;
  12356. var d11 = s01X1 * s01X1 + s01Y1 * s01Y1 + s01Z1 * s01Z1;
  12357. var d12 = s01X1 * s02X + s01Y1 * s02Y + s01Z1 * s02Z;
  12358. var d22 = s02X * s02X + s02Y * s02Y + s02Z * s02Z;
  12359. var d1c = s01X1 * s0cX1 + s01Y1 * s0cY1 + s01Z1 * s0cZ1;
  12360. var d2c = s02X * s0cX1 + s02Y * s0cY1 + s02Z * s0cZ1;
  12361. var invDet1 = d11 * d22 - d12 * d12;
  12362. if(invDet1 != 0) {
  12363. invDet1 = 1 / invDet1;
  12364. }
  12365. var s = (d1c * d22 - d2c * d12) * invDet1;
  12366. var t1 = (-d1c * d12 + d2c * d11) * invDet1;
  12367. var diff1;
  12368. var diffX1;
  12369. var diffY1;
  12370. var diffZ1;
  12371. var cp11;
  12372. var cp1X1;
  12373. var cp1Y1;
  12374. var cp1Z1;
  12375. var cp21;
  12376. var cp2X1;
  12377. var cp2Y1;
  12378. var cp2Z1;
  12379. diffX1 = w11X1 - w10X1;
  12380. diffY1 = w11Y1 - w10Y1;
  12381. diffZ1 = w11Z1 - w10Z1;
  12382. cp1X1 = w10X1 + diffX1 * s;
  12383. cp1Y1 = w10Y1 + diffY1 * s;
  12384. cp1Z1 = w10Z1 + diffZ1 * s;
  12385. diffX1 = w12X1 - w10X1;
  12386. diffY1 = w12Y1 - w10Y1;
  12387. diffZ1 = w12Z1 - w10Z1;
  12388. cp1X1 += diffX1 * t1;
  12389. cp1Y1 += diffY1 * t1;
  12390. cp1Z1 += diffZ1 * t1;
  12391. diffX1 = w21X1 - w20X1;
  12392. diffY1 = w21Y1 - w20Y1;
  12393. diffZ1 = w21Z1 - w20Z1;
  12394. cp2X1 = w20X1 + diffX1 * s;
  12395. cp2Y1 = w20Y1 + diffY1 * s;
  12396. cp2Z1 = w20Z1 + diffZ1 * s;
  12397. diffX1 = w22X1 - w20X1;
  12398. diffY1 = w22Y1 - w20Y1;
  12399. diffZ1 = w22Z1 - w20Z1;
  12400. cp2X1 += diffX1 * t1;
  12401. cp2Y1 += diffY1 * t1;
  12402. cp2Z1 += diffZ1 * t1;
  12403. var v24 = this.closestPoint1;
  12404. v24.x = cp1X1;
  12405. v24.y = cp1Y1;
  12406. v24.z = cp1Z1;
  12407. var v25 = this.closestPoint2;
  12408. v25.x = cp2X1;
  12409. v25.y = cp2Y1;
  12410. v25.z = cp2Z1;
  12411. break;
  12412. default:
  12413. throw new Error("!?");
  12414. }
  12415. }
  12416. loadCache(gjkCache) {
  12417. var _this = this.dir;
  12418. var v = gjkCache.prevClosestDir;
  12419. _this.x = v.x;
  12420. _this.y = v.y;
  12421. _this.z = v.z;
  12422. }
  12423. saveCache(gjkCache) {
  12424. var _this = gjkCache.prevClosestDir;
  12425. var v = this.closest;
  12426. _this.x = v.x;
  12427. _this.y = v.y;
  12428. _this.z = v.z;
  12429. var _this1 = _this;
  12430. var tx = -_this1.x;
  12431. var ty = -_this1.y;
  12432. var tz = -_this1.z;
  12433. _this1.x = tx;
  12434. _this1.y = ty;
  12435. _this1.z = tz;
  12436. }
  12437. shrinkSimplex(vertexBits) {
  12438. this.simplexSize = vertexBits;
  12439. this.simplexSize = (this.simplexSize & 5) + (this.simplexSize >> 1 & 5);
  12440. this.simplexSize = (this.simplexSize & 3) + (this.simplexSize >> 2 & 3);
  12441. switch(vertexBits) {
  12442. case 2:
  12443. var _this = this.s[0];
  12444. var v = this.s[1];
  12445. _this.x = v.x;
  12446. _this.y = v.y;
  12447. _this.z = v.z;
  12448. var _this1 = this.w1[0];
  12449. var v1 = this.w1[1];
  12450. _this1.x = v1.x;
  12451. _this1.y = v1.y;
  12452. _this1.z = v1.z;
  12453. var _this2 = this.w2[0];
  12454. var v2 = this.w2[1];
  12455. _this2.x = v2.x;
  12456. _this2.y = v2.y;
  12457. _this2.z = v2.z;
  12458. break;
  12459. case 4:
  12460. var _this3 = this.s[0];
  12461. var v3 = this.s[2];
  12462. _this3.x = v3.x;
  12463. _this3.y = v3.y;
  12464. _this3.z = v3.z;
  12465. var _this4 = this.w1[0];
  12466. var v4 = this.w1[2];
  12467. _this4.x = v4.x;
  12468. _this4.y = v4.y;
  12469. _this4.z = v4.z;
  12470. var _this5 = this.w2[0];
  12471. var v5 = this.w2[2];
  12472. _this5.x = v5.x;
  12473. _this5.y = v5.y;
  12474. _this5.z = v5.z;
  12475. break;
  12476. case 5:
  12477. var _this6 = this.s[1];
  12478. var v6 = this.s[2];
  12479. _this6.x = v6.x;
  12480. _this6.y = v6.y;
  12481. _this6.z = v6.z;
  12482. var _this7 = this.w1[1];
  12483. var v7 = this.w1[2];
  12484. _this7.x = v7.x;
  12485. _this7.y = v7.y;
  12486. _this7.z = v7.z;
  12487. var _this8 = this.w2[1];
  12488. var v8 = this.w2[2];
  12489. _this8.x = v8.x;
  12490. _this8.y = v8.y;
  12491. _this8.z = v8.z;
  12492. break;
  12493. case 6:
  12494. var _this9 = this.s[0];
  12495. var v9 = this.s[2];
  12496. _this9.x = v9.x;
  12497. _this9.y = v9.y;
  12498. _this9.z = v9.z;
  12499. var _this10 = this.w1[0];
  12500. var v10 = this.w1[2];
  12501. _this10.x = v10.x;
  12502. _this10.y = v10.y;
  12503. _this10.z = v10.z;
  12504. var _this11 = this.w2[0];
  12505. var v11 = this.w2[2];
  12506. _this11.x = v11.x;
  12507. _this11.y = v11.y;
  12508. _this11.z = v11.z;
  12509. break;
  12510. case 8:
  12511. var _this12 = this.s[0];
  12512. var v12 = this.s[3];
  12513. _this12.x = v12.x;
  12514. _this12.y = v12.y;
  12515. _this12.z = v12.z;
  12516. var _this13 = this.w1[0];
  12517. var v13 = this.w1[3];
  12518. _this13.x = v13.x;
  12519. _this13.y = v13.y;
  12520. _this13.z = v13.z;
  12521. var _this14 = this.w2[0];
  12522. var v14 = this.w2[3];
  12523. _this14.x = v14.x;
  12524. _this14.y = v14.y;
  12525. _this14.z = v14.z;
  12526. break;
  12527. case 9:
  12528. var _this15 = this.s[1];
  12529. var v15 = this.s[3];
  12530. _this15.x = v15.x;
  12531. _this15.y = v15.y;
  12532. _this15.z = v15.z;
  12533. var _this16 = this.w1[1];
  12534. var v16 = this.w1[3];
  12535. _this16.x = v16.x;
  12536. _this16.y = v16.y;
  12537. _this16.z = v16.z;
  12538. var _this17 = this.w2[1];
  12539. var v17 = this.w2[3];
  12540. _this17.x = v17.x;
  12541. _this17.y = v17.y;
  12542. _this17.z = v17.z;
  12543. break;
  12544. case 10:
  12545. var _this18 = this.s[0];
  12546. var v18 = this.s[3];
  12547. _this18.x = v18.x;
  12548. _this18.y = v18.y;
  12549. _this18.z = v18.z;
  12550. var _this19 = this.w1[0];
  12551. var v19 = this.w1[3];
  12552. _this19.x = v19.x;
  12553. _this19.y = v19.y;
  12554. _this19.z = v19.z;
  12555. var _this20 = this.w2[0];
  12556. var v20 = this.w2[3];
  12557. _this20.x = v20.x;
  12558. _this20.y = v20.y;
  12559. _this20.z = v20.z;
  12560. break;
  12561. case 11:
  12562. var _this21 = this.s[2];
  12563. var v21 = this.s[3];
  12564. _this21.x = v21.x;
  12565. _this21.y = v21.y;
  12566. _this21.z = v21.z;
  12567. var _this22 = this.w1[2];
  12568. var v22 = this.w1[3];
  12569. _this22.x = v22.x;
  12570. _this22.y = v22.y;
  12571. _this22.z = v22.z;
  12572. var _this23 = this.w2[2];
  12573. var v23 = this.w2[3];
  12574. _this23.x = v23.x;
  12575. _this23.y = v23.y;
  12576. _this23.z = v23.z;
  12577. break;
  12578. case 12:
  12579. var _this24 = this.s[0];
  12580. var v24 = this.s[2];
  12581. _this24.x = v24.x;
  12582. _this24.y = v24.y;
  12583. _this24.z = v24.z;
  12584. var _this25 = this.w1[0];
  12585. var v25 = this.w1[2];
  12586. _this25.x = v25.x;
  12587. _this25.y = v25.y;
  12588. _this25.z = v25.z;
  12589. var _this26 = this.w2[0];
  12590. var v26 = this.w2[2];
  12591. _this26.x = v26.x;
  12592. _this26.y = v26.y;
  12593. _this26.z = v26.z;
  12594. var _this27 = this.s[1];
  12595. var v27 = this.s[3];
  12596. _this27.x = v27.x;
  12597. _this27.y = v27.y;
  12598. _this27.z = v27.z;
  12599. var _this28 = this.w1[1];
  12600. var v28 = this.w1[3];
  12601. _this28.x = v28.x;
  12602. _this28.y = v28.y;
  12603. _this28.z = v28.z;
  12604. var _this29 = this.w2[1];
  12605. var v29 = this.w2[3];
  12606. _this29.x = v29.x;
  12607. _this29.y = v29.y;
  12608. _this29.z = v29.z;
  12609. break;
  12610. case 13:
  12611. var _this30 = this.s[1];
  12612. var v30 = this.s[3];
  12613. _this30.x = v30.x;
  12614. _this30.y = v30.y;
  12615. _this30.z = v30.z;
  12616. var _this31 = this.w1[1];
  12617. var v31 = this.w1[3];
  12618. _this31.x = v31.x;
  12619. _this31.y = v31.y;
  12620. _this31.z = v31.z;
  12621. var _this32 = this.w2[1];
  12622. var v32 = this.w2[3];
  12623. _this32.x = v32.x;
  12624. _this32.y = v32.y;
  12625. _this32.z = v32.z;
  12626. break;
  12627. case 14:
  12628. var _this33 = this.s[0];
  12629. var v33 = this.s[3];
  12630. _this33.x = v33.x;
  12631. _this33.y = v33.y;
  12632. _this33.z = v33.z;
  12633. var _this34 = this.w1[0];
  12634. var v34 = this.w1[3];
  12635. _this34.x = v34.x;
  12636. _this34.y = v34.y;
  12637. _this34.z = v34.z;
  12638. var _this35 = this.w2[0];
  12639. var v35 = this.w2[3];
  12640. _this35.x = v35.x;
  12641. _this35.y = v35.y;
  12642. _this35.z = v35.z;
  12643. break;
  12644. }
  12645. }
  12646. computeWitnessPoint1(addMargin) {
  12647. var tmp;
  12648. var tmpX;
  12649. var tmpY;
  12650. var tmpZ;
  12651. var idir;
  12652. var idirX;
  12653. var idirY;
  12654. var idirZ;
  12655. var v = this.dir;
  12656. idirX = v.x;
  12657. idirY = v.y;
  12658. idirZ = v.z;
  12659. var ldir1;
  12660. var ldir1X;
  12661. var ldir1Y;
  12662. var ldir1Z;
  12663. var __tmp__X;
  12664. var __tmp__Y;
  12665. var __tmp__Z;
  12666. __tmp__X = this.tf1._rotation00 * idirX + this.tf1._rotation10 * idirY + this.tf1._rotation20 * idirZ;
  12667. __tmp__Y = this.tf1._rotation01 * idirX + this.tf1._rotation11 * idirY + this.tf1._rotation21 * idirZ;
  12668. __tmp__Z = this.tf1._rotation02 * idirX + this.tf1._rotation12 * idirY + this.tf1._rotation22 * idirZ;
  12669. ldir1X = __tmp__X;
  12670. ldir1Y = __tmp__Y;
  12671. ldir1Z = __tmp__Z;
  12672. var iw1;
  12673. var iw1X;
  12674. var iw1Y;
  12675. var iw1Z;
  12676. var v1 = this.dir;
  12677. v1.x = ldir1X;
  12678. v1.y = ldir1Y;
  12679. v1.z = ldir1Z;
  12680. this.c1.computeLocalSupportingVertex(this.dir,this.w1[this.simplexSize]);
  12681. if(addMargin) {
  12682. var _this = this.dir;
  12683. var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
  12684. if(invLen > 0) {
  12685. invLen = 1 / invLen;
  12686. }
  12687. var tx = _this.x * invLen;
  12688. var ty = _this.y * invLen;
  12689. var tz = _this.z * invLen;
  12690. _this.x = tx;
  12691. _this.y = ty;
  12692. _this.z = tz;
  12693. var _this1 = this.w1[this.simplexSize];
  12694. var v2 = this.dir;
  12695. var s = this.c1._gjkMargin;
  12696. var tx1 = _this1.x + v2.x * s;
  12697. var ty1 = _this1.y + v2.y * s;
  12698. var tz1 = _this1.z + v2.z * s;
  12699. _this1.x = tx1;
  12700. _this1.y = ty1;
  12701. _this1.z = tz1;
  12702. }
  12703. var v3 = this.w1[this.simplexSize];
  12704. tmpX = v3.x;
  12705. tmpY = v3.y;
  12706. tmpZ = v3.z;
  12707. var __tmp__X1;
  12708. var __tmp__Y1;
  12709. var __tmp__Z1;
  12710. __tmp__X1 = this.tf1._rotation00 * tmpX + this.tf1._rotation01 * tmpY + this.tf1._rotation02 * tmpZ;
  12711. __tmp__Y1 = this.tf1._rotation10 * tmpX + this.tf1._rotation11 * tmpY + this.tf1._rotation12 * tmpZ;
  12712. __tmp__Z1 = this.tf1._rotation20 * tmpX + this.tf1._rotation21 * tmpY + this.tf1._rotation22 * tmpZ;
  12713. iw1X = __tmp__X1;
  12714. iw1Y = __tmp__Y1;
  12715. iw1Z = __tmp__Z1;
  12716. iw1X += this.tf1._positionX;
  12717. iw1Y += this.tf1._positionY;
  12718. iw1Z += this.tf1._positionZ;
  12719. var v4 = this.w1[this.simplexSize];
  12720. v4.x = iw1X;
  12721. v4.y = iw1Y;
  12722. v4.z = iw1Z;
  12723. var v5 = this.dir;
  12724. v5.x = idirX;
  12725. v5.y = idirY;
  12726. v5.z = idirZ;
  12727. }
  12728. computeWitnessPoint2(addMargin) {
  12729. var tmp;
  12730. var tmpX;
  12731. var tmpY;
  12732. var tmpZ;
  12733. var idir;
  12734. var idirX;
  12735. var idirY;
  12736. var idirZ;
  12737. var v = this.dir;
  12738. idirX = v.x;
  12739. idirY = v.y;
  12740. idirZ = v.z;
  12741. var ldir2;
  12742. var ldir2X;
  12743. var ldir2Y;
  12744. var ldir2Z;
  12745. var __tmp__X;
  12746. var __tmp__Y;
  12747. var __tmp__Z;
  12748. __tmp__X = this.tf2._rotation00 * idirX + this.tf2._rotation10 * idirY + this.tf2._rotation20 * idirZ;
  12749. __tmp__Y = this.tf2._rotation01 * idirX + this.tf2._rotation11 * idirY + this.tf2._rotation21 * idirZ;
  12750. __tmp__Z = this.tf2._rotation02 * idirX + this.tf2._rotation12 * idirY + this.tf2._rotation22 * idirZ;
  12751. ldir2X = __tmp__X;
  12752. ldir2Y = __tmp__Y;
  12753. ldir2Z = __tmp__Z;
  12754. ldir2X = -ldir2X;
  12755. ldir2Y = -ldir2Y;
  12756. ldir2Z = -ldir2Z;
  12757. var iw2;
  12758. var iw2X;
  12759. var iw2Y;
  12760. var iw2Z;
  12761. var v1 = this.dir;
  12762. v1.x = ldir2X;
  12763. v1.y = ldir2Y;
  12764. v1.z = ldir2Z;
  12765. this.c2.computeLocalSupportingVertex(this.dir,this.w2[this.simplexSize]);
  12766. if(addMargin) {
  12767. var _this = this.dir;
  12768. var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
  12769. if(invLen > 0) {
  12770. invLen = 1 / invLen;
  12771. }
  12772. var tx = _this.x * invLen;
  12773. var ty = _this.y * invLen;
  12774. var tz = _this.z * invLen;
  12775. _this.x = tx;
  12776. _this.y = ty;
  12777. _this.z = tz;
  12778. var _this1 = this.w2[this.simplexSize];
  12779. var v2 = this.dir;
  12780. var s = this.c2._gjkMargin;
  12781. var tx1 = _this1.x + v2.x * s;
  12782. var ty1 = _this1.y + v2.y * s;
  12783. var tz1 = _this1.z + v2.z * s;
  12784. _this1.x = tx1;
  12785. _this1.y = ty1;
  12786. _this1.z = tz1;
  12787. }
  12788. var v3 = this.w2[this.simplexSize];
  12789. tmpX = v3.x;
  12790. tmpY = v3.y;
  12791. tmpZ = v3.z;
  12792. var __tmp__X1;
  12793. var __tmp__Y1;
  12794. var __tmp__Z1;
  12795. __tmp__X1 = this.tf2._rotation00 * tmpX + this.tf2._rotation01 * tmpY + this.tf2._rotation02 * tmpZ;
  12796. __tmp__Y1 = this.tf2._rotation10 * tmpX + this.tf2._rotation11 * tmpY + this.tf2._rotation12 * tmpZ;
  12797. __tmp__Z1 = this.tf2._rotation20 * tmpX + this.tf2._rotation21 * tmpY + this.tf2._rotation22 * tmpZ;
  12798. iw2X = __tmp__X1;
  12799. iw2Y = __tmp__Y1;
  12800. iw2Z = __tmp__Z1;
  12801. iw2X += this.tf2._positionX;
  12802. iw2Y += this.tf2._positionY;
  12803. iw2Z += this.tf2._positionZ;
  12804. var v4 = this.w2[this.simplexSize];
  12805. v4.x = iw2X;
  12806. v4.y = iw2Y;
  12807. v4.z = iw2Z;
  12808. var v5 = this.dir;
  12809. v5.x = idirX;
  12810. v5.y = idirY;
  12811. v5.z = idirZ;
  12812. }
  12813. pointToTetrahedron() {
  12814. var _g = 0;
  12815. while(_g < 3) {
  12816. var i = _g++;
  12817. var _this = this.dir;
  12818. var v = this.baseDirs[i];
  12819. _this.x = v.x;
  12820. _this.y = v.y;
  12821. _this.z = v.z;
  12822. this.computeWitnessPoint1(false);
  12823. this.computeWitnessPoint2(false);
  12824. var _this1 = this.s[this.simplexSize];
  12825. var v1 = this.w1[this.simplexSize];
  12826. _this1.x = v1.x;
  12827. _this1.y = v1.y;
  12828. _this1.z = v1.z;
  12829. var _this2 = _this1;
  12830. var v2 = this.w2[this.simplexSize];
  12831. var tx = _this2.x - v2.x;
  12832. var ty = _this2.y - v2.y;
  12833. var tz = _this2.z - v2.z;
  12834. _this2.x = tx;
  12835. _this2.y = ty;
  12836. _this2.z = tz;
  12837. this.simplexSize++;
  12838. this.lineToTetrahedron();
  12839. if(this.simplexSize == 4) {
  12840. break;
  12841. }
  12842. this.simplexSize--;
  12843. var _this3 = this.dir;
  12844. var tx1 = -_this3.x;
  12845. var ty1 = -_this3.y;
  12846. var tz1 = -_this3.z;
  12847. _this3.x = tx1;
  12848. _this3.y = ty1;
  12849. _this3.z = tz1;
  12850. this.computeWitnessPoint1(false);
  12851. this.computeWitnessPoint2(false);
  12852. var _this4 = this.s[this.simplexSize];
  12853. var v3 = this.w1[this.simplexSize];
  12854. _this4.x = v3.x;
  12855. _this4.y = v3.y;
  12856. _this4.z = v3.z;
  12857. var _this5 = _this4;
  12858. var v4 = this.w2[this.simplexSize];
  12859. var tx2 = _this5.x - v4.x;
  12860. var ty2 = _this5.y - v4.y;
  12861. var tz2 = _this5.z - v4.z;
  12862. _this5.x = tx2;
  12863. _this5.y = ty2;
  12864. _this5.z = tz2;
  12865. this.simplexSize++;
  12866. this.lineToTetrahedron();
  12867. if(this.simplexSize == 4) {
  12868. break;
  12869. }
  12870. this.simplexSize--;
  12871. }
  12872. }
  12873. lineToTetrahedron() {
  12874. var oldDir;
  12875. var oldDirX;
  12876. var oldDirY;
  12877. var oldDirZ;
  12878. var v = this.dir;
  12879. oldDirX = v.x;
  12880. oldDirY = v.y;
  12881. oldDirZ = v.z;
  12882. var s0;
  12883. var s0X;
  12884. var s0Y;
  12885. var s0Z;
  12886. var s1;
  12887. var s1X;
  12888. var s1Y;
  12889. var s1Z;
  12890. var lineDir;
  12891. var lineDirX;
  12892. var lineDirY;
  12893. var lineDirZ;
  12894. var v1 = this.s[0];
  12895. s0X = v1.x;
  12896. s0Y = v1.y;
  12897. s0Z = v1.z;
  12898. var v2 = this.s[1];
  12899. s1X = v2.x;
  12900. s1Y = v2.y;
  12901. s1Z = v2.z;
  12902. lineDirX = s0X - s1X;
  12903. lineDirY = s0Y - s1Y;
  12904. lineDirZ = s0Z - s1Z;
  12905. var _g = 0;
  12906. while(_g < 3) {
  12907. var i = _g++;
  12908. var baseDir;
  12909. var baseDirX;
  12910. var baseDirY;
  12911. var baseDirZ;
  12912. var v3 = this.baseDirs[i];
  12913. baseDirX = v3.x;
  12914. baseDirY = v3.y;
  12915. baseDirZ = v3.z;
  12916. var newDir;
  12917. var newDirX;
  12918. var newDirY;
  12919. var newDirZ;
  12920. newDirX = lineDirY * baseDirZ - lineDirZ * baseDirY;
  12921. newDirY = lineDirZ * baseDirX - lineDirX * baseDirZ;
  12922. newDirZ = lineDirX * baseDirY - lineDirY * baseDirX;
  12923. var v4 = this.dir;
  12924. v4.x = newDirX;
  12925. v4.y = newDirY;
  12926. v4.z = newDirZ;
  12927. this.computeWitnessPoint1(false);
  12928. this.computeWitnessPoint2(false);
  12929. var _this = this.s[this.simplexSize];
  12930. var v5 = this.w1[this.simplexSize];
  12931. _this.x = v5.x;
  12932. _this.y = v5.y;
  12933. _this.z = v5.z;
  12934. var _this1 = _this;
  12935. var v6 = this.w2[this.simplexSize];
  12936. var tx = _this1.x - v6.x;
  12937. var ty = _this1.y - v6.y;
  12938. var tz = _this1.z - v6.z;
  12939. _this1.x = tx;
  12940. _this1.y = ty;
  12941. _this1.z = tz;
  12942. this.simplexSize++;
  12943. this.triangleToTetrahedron();
  12944. if(this.simplexSize == 4) {
  12945. break;
  12946. }
  12947. this.simplexSize--;
  12948. var _this2 = this.dir;
  12949. var tx1 = -_this2.x;
  12950. var ty1 = -_this2.y;
  12951. var tz1 = -_this2.z;
  12952. _this2.x = tx1;
  12953. _this2.y = ty1;
  12954. _this2.z = tz1;
  12955. this.computeWitnessPoint1(false);
  12956. this.computeWitnessPoint2(false);
  12957. var _this3 = this.s[this.simplexSize];
  12958. var v7 = this.w1[this.simplexSize];
  12959. _this3.x = v7.x;
  12960. _this3.y = v7.y;
  12961. _this3.z = v7.z;
  12962. var _this4 = _this3;
  12963. var v8 = this.w2[this.simplexSize];
  12964. var tx2 = _this4.x - v8.x;
  12965. var ty2 = _this4.y - v8.y;
  12966. var tz2 = _this4.z - v8.z;
  12967. _this4.x = tx2;
  12968. _this4.y = ty2;
  12969. _this4.z = tz2;
  12970. this.simplexSize++;
  12971. this.triangleToTetrahedron();
  12972. if(this.simplexSize == 4) {
  12973. break;
  12974. }
  12975. this.simplexSize--;
  12976. }
  12977. var v9 = this.dir;
  12978. v9.x = oldDirX;
  12979. v9.y = oldDirY;
  12980. v9.z = oldDirZ;
  12981. }
  12982. triangleToTetrahedron() {
  12983. var oldDir;
  12984. var oldDirX;
  12985. var oldDirY;
  12986. var oldDirZ;
  12987. var v = this.dir;
  12988. oldDirX = v.x;
  12989. oldDirY = v.y;
  12990. oldDirZ = v.z;
  12991. while(true) {
  12992. var s0;
  12993. var s0X;
  12994. var s0Y;
  12995. var s0Z;
  12996. var s1;
  12997. var s1X;
  12998. var s1Y;
  12999. var s1Z;
  13000. var s2;
  13001. var s2X;
  13002. var s2Y;
  13003. var s2Z;
  13004. var s01;
  13005. var s01X;
  13006. var s01Y;
  13007. var s01Z;
  13008. var s02;
  13009. var s02X;
  13010. var s02Y;
  13011. var s02Z;
  13012. var v1 = this.s[0];
  13013. s0X = v1.x;
  13014. s0Y = v1.y;
  13015. s0Z = v1.z;
  13016. var v2 = this.s[1];
  13017. s1X = v2.x;
  13018. s1Y = v2.y;
  13019. s1Z = v2.z;
  13020. var v3 = this.s[2];
  13021. s2X = v3.x;
  13022. s2Y = v3.y;
  13023. s2Z = v3.z;
  13024. s01X = s1X - s0X;
  13025. s01Y = s1Y - s0Y;
  13026. s01Z = s1Z - s0Z;
  13027. s02X = s2X - s0X;
  13028. s02Y = s2Y - s0Y;
  13029. s02Z = s2Z - s0Z;
  13030. var n;
  13031. var nX;
  13032. var nY;
  13033. var nZ;
  13034. nX = s01Y * s02Z - s01Z * s02Y;
  13035. nY = s01Z * s02X - s01X * s02Z;
  13036. nZ = s01X * s02Y - s01Y * s02X;
  13037. var v4 = this.dir;
  13038. v4.x = nX;
  13039. v4.y = nY;
  13040. v4.z = nZ;
  13041. this.computeWitnessPoint1(false);
  13042. this.computeWitnessPoint2(false);
  13043. var _this = this.s[this.simplexSize];
  13044. var v5 = this.w1[this.simplexSize];
  13045. _this.x = v5.x;
  13046. _this.y = v5.y;
  13047. _this.z = v5.z;
  13048. var _this1 = _this;
  13049. var v6 = this.w2[this.simplexSize];
  13050. var tx = _this1.x - v6.x;
  13051. var ty = _this1.y - v6.y;
  13052. var tz = _this1.z - v6.z;
  13053. _this1.x = tx;
  13054. _this1.y = ty;
  13055. _this1.z = tz;
  13056. this.simplexSize++;
  13057. if(this.isValidTetrahedron()) {
  13058. break;
  13059. }
  13060. this.simplexSize--;
  13061. var _this2 = this.dir;
  13062. var tx1 = -_this2.x;
  13063. var ty1 = -_this2.y;
  13064. var tz1 = -_this2.z;
  13065. _this2.x = tx1;
  13066. _this2.y = ty1;
  13067. _this2.z = tz1;
  13068. this.computeWitnessPoint1(false);
  13069. this.computeWitnessPoint2(false);
  13070. var _this3 = this.s[this.simplexSize];
  13071. var v7 = this.w1[this.simplexSize];
  13072. _this3.x = v7.x;
  13073. _this3.y = v7.y;
  13074. _this3.z = v7.z;
  13075. var _this4 = _this3;
  13076. var v8 = this.w2[this.simplexSize];
  13077. var tx2 = _this4.x - v8.x;
  13078. var ty2 = _this4.y - v8.y;
  13079. var tz2 = _this4.z - v8.z;
  13080. _this4.x = tx2;
  13081. _this4.y = ty2;
  13082. _this4.z = tz2;
  13083. this.simplexSize++;
  13084. if(this.isValidTetrahedron()) {
  13085. break;
  13086. }
  13087. this.simplexSize--;
  13088. if(!false) {
  13089. break;
  13090. }
  13091. }
  13092. var v9 = this.dir;
  13093. v9.x = oldDirX;
  13094. v9.y = oldDirY;
  13095. v9.z = oldDirZ;
  13096. }
  13097. isValidTetrahedron() {
  13098. var e00 = this.s[1].x - this.s[0].x;
  13099. var e01 = this.s[1].y - this.s[0].y;
  13100. var e02 = this.s[1].z - this.s[0].z;
  13101. var e10 = this.s[2].x - this.s[0].x;
  13102. var e11 = this.s[2].y - this.s[0].y;
  13103. var e12 = this.s[2].z - this.s[0].z;
  13104. var e20 = this.s[3].x - this.s[0].x;
  13105. var e21 = this.s[3].y - this.s[0].y;
  13106. var e22 = this.s[3].z - this.s[0].z;
  13107. var det = e00 * (e11 * e22 - e12 * e21) - e01 * (e10 * e22 - e12 * e20) + e02 * (e10 * e21 - e11 * e20);
  13108. if(!(det > 1e-12)) {
  13109. return det < -1e-12;
  13110. } else {
  13111. return true;
  13112. }
  13113. }
  13114. computeDepth(convex1,convex2,tf1,tf2,initialPolyhedron,initialPolyhedron1,initialPolyhedron2) {
  13115. var _this = this.polyhedron;
  13116. while(_this._numTriangles > 0) {
  13117. var t = _this._triangleList;
  13118. _this._numTriangles--;
  13119. var prev = t._prev;
  13120. var next = t._next;
  13121. if(prev != null) {
  13122. prev._next = next;
  13123. }
  13124. if(next != null) {
  13125. next._prev = prev;
  13126. }
  13127. if(t == _this._triangleList) {
  13128. _this._triangleList = _this._triangleList._next;
  13129. }
  13130. if(t == _this._triangleListLast) {
  13131. _this._triangleListLast = _this._triangleListLast._prev;
  13132. }
  13133. t._next = null;
  13134. t._prev = null;
  13135. t.removeReferences();
  13136. t._next = _this._trianglePool;
  13137. _this._trianglePool = t;
  13138. }
  13139. while(_this._numVertices > 0) {
  13140. var v = _this._vertices[--_this._numVertices];
  13141. v.removeReferences();
  13142. v._next = _this._vertexPool;
  13143. _this._vertexPool = v;
  13144. }
  13145. var tmp = this.polyhedron;
  13146. var _this1 = this.polyhedron;
  13147. var first = _this1._vertexPool;
  13148. if(first != null) {
  13149. _this1._vertexPool = first._next;
  13150. first._next = null;
  13151. } else {
  13152. first = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex();
  13153. }
  13154. var tmp1 = first.init(initialPolyhedron[0],initialPolyhedron1[0],initialPolyhedron2[0]);
  13155. var _this2 = this.polyhedron;
  13156. var first1 = _this2._vertexPool;
  13157. if(first1 != null) {
  13158. _this2._vertexPool = first1._next;
  13159. first1._next = null;
  13160. } else {
  13161. first1 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex();
  13162. }
  13163. var tmp2 = first1.init(initialPolyhedron[1],initialPolyhedron1[1],initialPolyhedron2[1]);
  13164. var _this3 = this.polyhedron;
  13165. var first2 = _this3._vertexPool;
  13166. if(first2 != null) {
  13167. _this3._vertexPool = first2._next;
  13168. first2._next = null;
  13169. } else {
  13170. first2 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex();
  13171. }
  13172. var tmp3 = first2.init(initialPolyhedron[2],initialPolyhedron1[2],initialPolyhedron2[2]);
  13173. var _this4 = this.polyhedron;
  13174. var first3 = _this4._vertexPool;
  13175. if(first3 != null) {
  13176. _this4._vertexPool = first3._next;
  13177. first3._next = null;
  13178. } else {
  13179. first3 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex();
  13180. }
  13181. if(!tmp._init(tmp1,tmp2,tmp3,first3.init(initialPolyhedron[3],initialPolyhedron1[3],initialPolyhedron2[3]))) {
  13182. return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_INIT;
  13183. }
  13184. this.simplexSize = 0;
  13185. var supportingVertex = this.s[0];
  13186. var witness1 = this.w1[0];
  13187. var witness2 = this.w2[0];
  13188. var count = 0;
  13189. var maxIterations = 40;
  13190. while(count < maxIterations) {
  13191. var f = this.polyhedron._triangleList;
  13192. var mind = 1e65536;
  13193. var minf = null;
  13194. while(f != null) {
  13195. var n = f._next;
  13196. if(f._distanceSq < mind) {
  13197. mind = f._distanceSq;
  13198. minf = f;
  13199. }
  13200. f = n;
  13201. }
  13202. var face = minf;
  13203. var _this5 = this.dir;
  13204. var v1 = face._normal;
  13205. _this5.x = v1.x;
  13206. _this5.y = v1.y;
  13207. _this5.z = v1.z;
  13208. var _this6 = _this5;
  13209. var invLen = Math.sqrt(_this6.x * _this6.x + _this6.y * _this6.y + _this6.z * _this6.z);
  13210. if(invLen > 0) {
  13211. invLen = 1 / invLen;
  13212. }
  13213. var tx = _this6.x * invLen;
  13214. var ty = _this6.y * invLen;
  13215. var tz = _this6.z * invLen;
  13216. _this6.x = tx;
  13217. _this6.y = ty;
  13218. _this6.z = tz;
  13219. this.computeWitnessPoint1(false);
  13220. this.computeWitnessPoint2(false);
  13221. var _this7 = this.s[this.simplexSize];
  13222. var v2 = this.w1[this.simplexSize];
  13223. _this7.x = v2.x;
  13224. _this7.y = v2.y;
  13225. _this7.z = v2.z;
  13226. var _this8 = _this7;
  13227. var v3 = this.w2[this.simplexSize];
  13228. var tx1 = _this8.x - v3.x;
  13229. var ty1 = _this8.y - v3.y;
  13230. var tz1 = _this8.z - v3.z;
  13231. _this8.x = tx1;
  13232. _this8.y = ty1;
  13233. _this8.z = tz1;
  13234. var v0 = face._vertices[0];
  13235. var v11 = face._vertices[1];
  13236. var v21 = face._vertices[2];
  13237. var _this9 = v0.v;
  13238. var v4 = this.dir;
  13239. var dot1 = _this9.x * v4.x + _this9.y * v4.y + _this9.z * v4.z;
  13240. var v5 = this.dir;
  13241. var dot2 = supportingVertex.x * v5.x + supportingVertex.y * v5.y + supportingVertex.z * v5.z;
  13242. if(dot2 - dot1 < 1e-6 || count == maxIterations - 1) {
  13243. var _this10 = this.closest;
  13244. var v6 = this.dir;
  13245. _this10.x = v6.x;
  13246. _this10.y = v6.y;
  13247. _this10.z = v6.z;
  13248. var _this11 = _this10;
  13249. var _this12 = this.dir;
  13250. var v7 = v0.v;
  13251. var _this13 = this.dir;
  13252. var s = (_this12.x * v7.x + _this12.y * v7.y + _this12.z * v7.z) / (_this13.x * _this13.x + _this13.y * _this13.y + _this13.z * _this13.z);
  13253. var tx2 = _this11.x * s;
  13254. var ty2 = _this11.y * s;
  13255. var tz2 = _this11.z * s;
  13256. _this11.x = tx2;
  13257. _this11.y = ty2;
  13258. _this11.z = tz2;
  13259. var c;
  13260. var cX;
  13261. var cY;
  13262. var cZ;
  13263. var v8 = this.closest;
  13264. cX = v8.x;
  13265. cY = v8.y;
  13266. cZ = v8.z;
  13267. var s0;
  13268. var s0X;
  13269. var s0Y;
  13270. var s0Z;
  13271. var w10;
  13272. var w10X;
  13273. var w10Y;
  13274. var w10Z;
  13275. var w20;
  13276. var w20X;
  13277. var w20Y;
  13278. var w20Z;
  13279. var s1;
  13280. var s1X;
  13281. var s1Y;
  13282. var s1Z;
  13283. var w11;
  13284. var w11X;
  13285. var w11Y;
  13286. var w11Z;
  13287. var w21;
  13288. var w21X;
  13289. var w21Y;
  13290. var w21Z;
  13291. var s2;
  13292. var s2X;
  13293. var s2Y;
  13294. var s2Z;
  13295. var w12;
  13296. var w12X;
  13297. var w12Y;
  13298. var w12Z;
  13299. var w22;
  13300. var w22X;
  13301. var w22Y;
  13302. var w22Z;
  13303. var v9 = v0.v;
  13304. s0X = v9.x;
  13305. s0Y = v9.y;
  13306. s0Z = v9.z;
  13307. var v10 = v0.w1;
  13308. w10X = v10.x;
  13309. w10Y = v10.y;
  13310. w10Z = v10.z;
  13311. var v12 = v0.w2;
  13312. w20X = v12.x;
  13313. w20Y = v12.y;
  13314. w20Z = v12.z;
  13315. var v13 = v11.v;
  13316. s1X = v13.x;
  13317. s1Y = v13.y;
  13318. s1Z = v13.z;
  13319. var v14 = v11.w1;
  13320. w11X = v14.x;
  13321. w11Y = v14.y;
  13322. w11Z = v14.z;
  13323. var v15 = v11.w2;
  13324. w21X = v15.x;
  13325. w21Y = v15.y;
  13326. w21Z = v15.z;
  13327. var v16 = v21.v;
  13328. s2X = v16.x;
  13329. s2Y = v16.y;
  13330. s2Z = v16.z;
  13331. var v17 = v21.w1;
  13332. w12X = v17.x;
  13333. w12Y = v17.y;
  13334. w12Z = v17.z;
  13335. var v18 = v21.w2;
  13336. w22X = v18.x;
  13337. w22Y = v18.y;
  13338. w22Z = v18.z;
  13339. var s01;
  13340. var s01X;
  13341. var s01Y;
  13342. var s01Z;
  13343. var s02;
  13344. var s02X;
  13345. var s02Y;
  13346. var s02Z;
  13347. var s0c;
  13348. var s0cX;
  13349. var s0cY;
  13350. var s0cZ;
  13351. s01X = s1X - s0X;
  13352. s01Y = s1Y - s0Y;
  13353. s01Z = s1Z - s0Z;
  13354. s02X = s2X - s0X;
  13355. s02Y = s2Y - s0Y;
  13356. s02Z = s2Z - s0Z;
  13357. s0cX = cX - s0X;
  13358. s0cY = cY - s0Y;
  13359. s0cZ = cZ - s0Z;
  13360. var d11 = s01X * s01X + s01Y * s01Y + s01Z * s01Z;
  13361. var d12 = s01X * s02X + s01Y * s02Y + s01Z * s02Z;
  13362. var d22 = s02X * s02X + s02Y * s02Y + s02Z * s02Z;
  13363. var d1c = s01X * s0cX + s01Y * s0cY + s01Z * s0cZ;
  13364. var d2c = s02X * s0cX + s02Y * s0cY + s02Z * s0cZ;
  13365. var invDet = d11 * d22 - d12 * d12;
  13366. if(invDet != 0) {
  13367. invDet = 1 / invDet;
  13368. }
  13369. var s3 = (d1c * d22 - d2c * d12) * invDet;
  13370. var t1 = (-d1c * d12 + d2c * d11) * invDet;
  13371. var diff;
  13372. var diffX;
  13373. var diffY;
  13374. var diffZ;
  13375. var cp1;
  13376. var cp1X;
  13377. var cp1Y;
  13378. var cp1Z;
  13379. var cp2;
  13380. var cp2X;
  13381. var cp2Y;
  13382. var cp2Z;
  13383. diffX = w11X - w10X;
  13384. diffY = w11Y - w10Y;
  13385. diffZ = w11Z - w10Z;
  13386. cp1X = w10X + diffX * s3;
  13387. cp1Y = w10Y + diffY * s3;
  13388. cp1Z = w10Z + diffZ * s3;
  13389. diffX = w12X - w10X;
  13390. diffY = w12Y - w10Y;
  13391. diffZ = w12Z - w10Z;
  13392. cp1X += diffX * t1;
  13393. cp1Y += diffY * t1;
  13394. cp1Z += diffZ * t1;
  13395. diffX = w21X - w20X;
  13396. diffY = w21Y - w20Y;
  13397. diffZ = w21Z - w20Z;
  13398. cp2X = w20X + diffX * s3;
  13399. cp2Y = w20Y + diffY * s3;
  13400. cp2Z = w20Z + diffZ * s3;
  13401. diffX = w22X - w20X;
  13402. diffY = w22Y - w20Y;
  13403. diffZ = w22Z - w20Z;
  13404. cp2X += diffX * t1;
  13405. cp2Y += diffY * t1;
  13406. cp2Z += diffZ * t1;
  13407. var v19 = this.closestPoint1;
  13408. v19.x = cp1X;
  13409. v19.y = cp1Y;
  13410. v19.z = cp1Z;
  13411. var v20 = this.closestPoint2;
  13412. v20.x = cp2X;
  13413. v20.y = cp2Y;
  13414. v20.z = cp2Z;
  13415. var _this14 = this.closest;
  13416. this.depth = Math.sqrt(_this14.x * _this14.x + _this14.y * _this14.y + _this14.z * _this14.z);
  13417. return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.SUCCEEDED;
  13418. }
  13419. var _this15 = this.polyhedron;
  13420. var first4 = _this15._vertexPool;
  13421. if(first4 != null) {
  13422. _this15._vertexPool = first4._next;
  13423. first4._next = null;
  13424. } else {
  13425. first4 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex();
  13426. }
  13427. var epaVertex = first4.init(supportingVertex,witness1,witness2);
  13428. if(!this.polyhedron._addVertex(epaVertex,face)) {
  13429. return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_ADD_VERTEX;
  13430. }
  13431. ++count;
  13432. }
  13433. return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_DID_NOT_CONVERGE;
  13434. }
  13435. computeClosestPoints(c1,c2,tf1,tf2,cache) {
  13436. return this.computeClosestPointsImpl(c1,c2,tf1,tf2,cache,true);
  13437. }
  13438. computeDistance(c1,c2,tf1,tf2,cache) {
  13439. return this.computeClosestPointsImpl(c1,c2,tf1,tf2,cache,false);
  13440. }
  13441. convexCast(c1,c2,tf1,tf2,tl1,tl2,hit) {
  13442. return this.convexCastImpl(c1,c2,tf1,tf2,tl1,tl2,hit);
  13443. }
  13444. rayCast(c,tf,begin,end,hit) {
  13445. var tf1 = this.tempTransform;
  13446. var tf2 = tf;
  13447. var v = begin;
  13448. tf1._positionX = v.x;
  13449. tf1._positionY = v.y;
  13450. tf1._positionZ = v.z;
  13451. var tl1 = this.tl1;
  13452. var tl2 = this.tl2;
  13453. tl1.x = end.x;
  13454. tl1.y = end.y;
  13455. tl1.z = end.z;
  13456. var _this = tl1;
  13457. var tx = _this.x - begin.x;
  13458. var ty = _this.y - begin.y;
  13459. var tz = _this.z - begin.z;
  13460. _this.x = tx;
  13461. _this.y = ty;
  13462. _this.z = tz;
  13463. tl2.zero();
  13464. return this.convexCastImpl(null,c,tf1,tf2,tl1,tl2,hit);
  13465. }
  13466. static getInstance() {
  13467. return oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance;
  13468. }
  13469. }
  13470. oimo.collision.narrowphase.detector.gjkepa.GjkEpaLog = class oimo_collision_narrowphase_detector_gjkepa_GjkEpaLog {
  13471. }
  13472. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState = class oimo_collision_narrowphase_detector_gjkepa_GjkEpaResultState {
  13473. }
  13474. oimo.collision.narrowphase.detector.gjkepa.SimplexUtil = class oimo_collision_narrowphase_detector_gjkepa_SimplexUtil {
  13475. static projectOrigin2(vec1,vec2,out) {
  13476. var v1;
  13477. var v1X;
  13478. var v1Y;
  13479. var v1Z;
  13480. var v2;
  13481. var v2X;
  13482. var v2Y;
  13483. var v2Z;
  13484. var v = vec1;
  13485. v1X = v.x;
  13486. v1Y = v.y;
  13487. v1Z = v.z;
  13488. var v3 = vec2;
  13489. v2X = v3.x;
  13490. v2Y = v3.y;
  13491. v2Z = v3.z;
  13492. var v12;
  13493. var v12X;
  13494. var v12Y;
  13495. var v12Z;
  13496. v12X = v2X - v1X;
  13497. v12Y = v2Y - v1Y;
  13498. v12Z = v2Z - v1Z;
  13499. var d = v12X * v12X + v12Y * v12Y + v12Z * v12Z;
  13500. var t = v12X * v1X + v12Y * v1Y + v12Z * v1Z;
  13501. t = -t / d;
  13502. if(t < 0) {
  13503. var v4 = out;
  13504. v4.x = v1X;
  13505. v4.y = v1Y;
  13506. v4.z = v1Z;
  13507. return 1;
  13508. }
  13509. if(t > 1) {
  13510. var v5 = out;
  13511. v5.x = v2X;
  13512. v5.y = v2Y;
  13513. v5.z = v2Z;
  13514. return 2;
  13515. }
  13516. var p;
  13517. var pX;
  13518. var pY;
  13519. var pZ;
  13520. pX = v1X + v12X * t;
  13521. pY = v1Y + v12Y * t;
  13522. pZ = v1Z + v12Z * t;
  13523. var v6 = out;
  13524. v6.x = pX;
  13525. v6.y = pY;
  13526. v6.z = pZ;
  13527. return 3;
  13528. }
  13529. static projectOrigin3(vec1,vec2,vec3,out) {
  13530. var v1;
  13531. var v1X;
  13532. var v1Y;
  13533. var v1Z;
  13534. var v2;
  13535. var v2X;
  13536. var v2Y;
  13537. var v2Z;
  13538. var v3;
  13539. var v3X;
  13540. var v3Y;
  13541. var v3Z;
  13542. var v12;
  13543. var v12X;
  13544. var v12Y;
  13545. var v12Z;
  13546. var v23;
  13547. var v23X;
  13548. var v23Y;
  13549. var v23Z;
  13550. var v31;
  13551. var v31X;
  13552. var v31Y;
  13553. var v31Z;
  13554. var v = vec1;
  13555. v1X = v.x;
  13556. v1Y = v.y;
  13557. v1Z = v.z;
  13558. var v4 = vec2;
  13559. v2X = v4.x;
  13560. v2Y = v4.y;
  13561. v2Z = v4.z;
  13562. var v5 = vec3;
  13563. v3X = v5.x;
  13564. v3Y = v5.y;
  13565. v3Z = v5.z;
  13566. v12X = v2X - v1X;
  13567. v12Y = v2Y - v1Y;
  13568. v12Z = v2Z - v1Z;
  13569. v23X = v3X - v2X;
  13570. v23Y = v3Y - v2Y;
  13571. v23Z = v3Z - v2Z;
  13572. v31X = v1X - v3X;
  13573. v31Y = v1Y - v3Y;
  13574. v31Z = v1Z - v3Z;
  13575. var n;
  13576. var nX;
  13577. var nY;
  13578. var nZ;
  13579. nX = v12Y * v23Z - v12Z * v23Y;
  13580. nY = v12Z * v23X - v12X * v23Z;
  13581. nZ = v12X * v23Y - v12Y * v23X;
  13582. var n12;
  13583. var n12X;
  13584. var n12Y;
  13585. var n12Z;
  13586. var n23;
  13587. var n23X;
  13588. var n23Y;
  13589. var n23Z;
  13590. var n31;
  13591. var n31X;
  13592. var n31Y;
  13593. var n31Z;
  13594. n12X = v12Y * nZ - v12Z * nY;
  13595. n12Y = v12Z * nX - v12X * nZ;
  13596. n12Z = v12X * nY - v12Y * nX;
  13597. n23X = v23Y * nZ - v23Z * nY;
  13598. n23Y = v23Z * nX - v23X * nZ;
  13599. n23Z = v23X * nY - v23Y * nX;
  13600. n31X = v31Y * nZ - v31Z * nY;
  13601. n31Y = v31Z * nX - v31X * nZ;
  13602. n31Z = v31X * nY - v31Y * nX;
  13603. var d12 = v1X * n12X + v1Y * n12Y + v1Z * n12Z;
  13604. var d23 = v2X * n23X + v2Y * n23Y + v2Z * n23Z;
  13605. var d31 = v3X * n31X + v3Y * n31Y + v3Z * n31Z;
  13606. var mind = -1;
  13607. var minv;
  13608. var minvX;
  13609. var minvY;
  13610. var minvZ;
  13611. var mini = 0;
  13612. minvX = 0;
  13613. minvY = 0;
  13614. minvZ = 0;
  13615. if(d12 < 0) {
  13616. var v11;
  13617. var v1X1;
  13618. var v1Y1;
  13619. var v1Z1;
  13620. var v21;
  13621. var v2X1;
  13622. var v2Y1;
  13623. var v2Z1;
  13624. var v6 = vec1;
  13625. v1X1 = v6.x;
  13626. v1Y1 = v6.y;
  13627. v1Z1 = v6.z;
  13628. var v7 = vec2;
  13629. v2X1 = v7.x;
  13630. v2Y1 = v7.y;
  13631. v2Z1 = v7.z;
  13632. var v121;
  13633. var v12X1;
  13634. var v12Y1;
  13635. var v12Z1;
  13636. v12X1 = v2X1 - v1X1;
  13637. v12Y1 = v2Y1 - v1Y1;
  13638. v12Z1 = v2Z1 - v1Z1;
  13639. var d = v12X1 * v12X1 + v12Y1 * v12Y1 + v12Z1 * v12Z1;
  13640. var t = v12X1 * v1X1 + v12Y1 * v1Y1 + v12Z1 * v1Z1;
  13641. t = -t / d;
  13642. var b;
  13643. if(t < 0) {
  13644. var v8 = out;
  13645. v8.x = v1X1;
  13646. v8.y = v1Y1;
  13647. v8.z = v1Z1;
  13648. b = 1;
  13649. } else if(t > 1) {
  13650. var v9 = out;
  13651. v9.x = v2X1;
  13652. v9.y = v2Y1;
  13653. v9.z = v2Z1;
  13654. b = 2;
  13655. } else {
  13656. var p;
  13657. var pX;
  13658. var pY;
  13659. var pZ;
  13660. pX = v1X1 + v12X1 * t;
  13661. pY = v1Y1 + v12Y1 * t;
  13662. pZ = v1Z1 + v12Z1 * t;
  13663. var v10 = out;
  13664. v10.x = pX;
  13665. v10.y = pY;
  13666. v10.z = pZ;
  13667. b = 3;
  13668. }
  13669. var d1 = out.x * out.x + out.y * out.y + out.z * out.z;
  13670. mini = b;
  13671. mind = d1;
  13672. var v13 = out;
  13673. minvX = v13.x;
  13674. minvY = v13.y;
  13675. minvZ = v13.z;
  13676. }
  13677. if(d23 < 0) {
  13678. var v14;
  13679. var v1X2;
  13680. var v1Y2;
  13681. var v1Z2;
  13682. var v22;
  13683. var v2X2;
  13684. var v2Y2;
  13685. var v2Z2;
  13686. var v15 = vec2;
  13687. v1X2 = v15.x;
  13688. v1Y2 = v15.y;
  13689. v1Z2 = v15.z;
  13690. var v16 = vec3;
  13691. v2X2 = v16.x;
  13692. v2Y2 = v16.y;
  13693. v2Z2 = v16.z;
  13694. var v122;
  13695. var v12X2;
  13696. var v12Y2;
  13697. var v12Z2;
  13698. v12X2 = v2X2 - v1X2;
  13699. v12Y2 = v2Y2 - v1Y2;
  13700. v12Z2 = v2Z2 - v1Z2;
  13701. var d2 = v12X2 * v12X2 + v12Y2 * v12Y2 + v12Z2 * v12Z2;
  13702. var t1 = v12X2 * v1X2 + v12Y2 * v1Y2 + v12Z2 * v1Z2;
  13703. t1 = -t1 / d2;
  13704. var b1;
  13705. if(t1 < 0) {
  13706. var v17 = out;
  13707. v17.x = v1X2;
  13708. v17.y = v1Y2;
  13709. v17.z = v1Z2;
  13710. b1 = 1;
  13711. } else if(t1 > 1) {
  13712. var v18 = out;
  13713. v18.x = v2X2;
  13714. v18.y = v2Y2;
  13715. v18.z = v2Z2;
  13716. b1 = 2;
  13717. } else {
  13718. var p1;
  13719. var pX1;
  13720. var pY1;
  13721. var pZ1;
  13722. pX1 = v1X2 + v12X2 * t1;
  13723. pY1 = v1Y2 + v12Y2 * t1;
  13724. pZ1 = v1Z2 + v12Z2 * t1;
  13725. var v19 = out;
  13726. v19.x = pX1;
  13727. v19.y = pY1;
  13728. v19.z = pZ1;
  13729. b1 = 3;
  13730. }
  13731. var d3 = out.x * out.x + out.y * out.y + out.z * out.z;
  13732. if(mind < 0 || d3 < mind) {
  13733. mini = b1 << 1;
  13734. mind = d3;
  13735. var v20 = out;
  13736. minvX = v20.x;
  13737. minvY = v20.y;
  13738. minvZ = v20.z;
  13739. }
  13740. }
  13741. if(d31 < 0) {
  13742. var v110;
  13743. var v1X3;
  13744. var v1Y3;
  13745. var v1Z3;
  13746. var v24;
  13747. var v2X3;
  13748. var v2Y3;
  13749. var v2Z3;
  13750. var v25 = vec1;
  13751. v1X3 = v25.x;
  13752. v1Y3 = v25.y;
  13753. v1Z3 = v25.z;
  13754. var v26 = vec3;
  13755. v2X3 = v26.x;
  13756. v2Y3 = v26.y;
  13757. v2Z3 = v26.z;
  13758. var v123;
  13759. var v12X3;
  13760. var v12Y3;
  13761. var v12Z3;
  13762. v12X3 = v2X3 - v1X3;
  13763. v12Y3 = v2Y3 - v1Y3;
  13764. v12Z3 = v2Z3 - v1Z3;
  13765. var d4 = v12X3 * v12X3 + v12Y3 * v12Y3 + v12Z3 * v12Z3;
  13766. var t2 = v12X3 * v1X3 + v12Y3 * v1Y3 + v12Z3 * v1Z3;
  13767. t2 = -t2 / d4;
  13768. var b2;
  13769. if(t2 < 0) {
  13770. var v27 = out;
  13771. v27.x = v1X3;
  13772. v27.y = v1Y3;
  13773. v27.z = v1Z3;
  13774. b2 = 1;
  13775. } else if(t2 > 1) {
  13776. var v28 = out;
  13777. v28.x = v2X3;
  13778. v28.y = v2Y3;
  13779. v28.z = v2Z3;
  13780. b2 = 2;
  13781. } else {
  13782. var p2;
  13783. var pX2;
  13784. var pY2;
  13785. var pZ2;
  13786. pX2 = v1X3 + v12X3 * t2;
  13787. pY2 = v1Y3 + v12Y3 * t2;
  13788. pZ2 = v1Z3 + v12Z3 * t2;
  13789. var v29 = out;
  13790. v29.x = pX2;
  13791. v29.y = pY2;
  13792. v29.z = pZ2;
  13793. b2 = 3;
  13794. }
  13795. var d5 = out.x * out.x + out.y * out.y + out.z * out.z;
  13796. if(mind < 0 || d5 < mind) {
  13797. mini = b2 & 1 | (b2 & 2) << 1;
  13798. mind = d5;
  13799. var v30 = out;
  13800. minvX = v30.x;
  13801. minvY = v30.y;
  13802. minvZ = v30.z;
  13803. }
  13804. }
  13805. if(mind > 0) {
  13806. var v32 = out;
  13807. v32.x = minvX;
  13808. v32.y = minvY;
  13809. v32.z = minvZ;
  13810. return mini;
  13811. }
  13812. var l = nX * nX + nY * nY + nZ * nZ;
  13813. if(l > 0) {
  13814. l = 1 / Math.sqrt(l);
  13815. }
  13816. nX *= l;
  13817. nY *= l;
  13818. nZ *= l;
  13819. var dn = v1X * nX + v1Y * nY + v1Z * nZ;
  13820. var l2 = nX * nX + nY * nY + nZ * nZ;
  13821. l2 = dn / l2;
  13822. minvX = nX * l2;
  13823. minvY = nY * l2;
  13824. minvZ = nZ * l2;
  13825. var v33 = out;
  13826. v33.x = minvX;
  13827. v33.y = minvY;
  13828. v33.z = minvZ;
  13829. return 7;
  13830. }
  13831. static projectOrigin4(vec1,vec2,vec3,vec4,out) {
  13832. var v1;
  13833. var v1X;
  13834. var v1Y;
  13835. var v1Z;
  13836. var v2;
  13837. var v2X;
  13838. var v2Y;
  13839. var v2Z;
  13840. var v3;
  13841. var v3X;
  13842. var v3Y;
  13843. var v3Z;
  13844. var v4;
  13845. var v4X;
  13846. var v4Y;
  13847. var v4Z;
  13848. var v12;
  13849. var v12X;
  13850. var v12Y;
  13851. var v12Z;
  13852. var v13;
  13853. var v13X;
  13854. var v13Y;
  13855. var v13Z;
  13856. var v14;
  13857. var v14X;
  13858. var v14Y;
  13859. var v14Z;
  13860. var v23;
  13861. var v23X;
  13862. var v23Y;
  13863. var v23Z;
  13864. var v24;
  13865. var v24X;
  13866. var v24Y;
  13867. var v24Z;
  13868. var v34;
  13869. var v34X;
  13870. var v34Y;
  13871. var v34Z;
  13872. var v = vec1;
  13873. v1X = v.x;
  13874. v1Y = v.y;
  13875. v1Z = v.z;
  13876. var v5 = vec2;
  13877. v2X = v5.x;
  13878. v2Y = v5.y;
  13879. v2Z = v5.z;
  13880. var v6 = vec3;
  13881. v3X = v6.x;
  13882. v3Y = v6.y;
  13883. v3Z = v6.z;
  13884. var v7 = vec4;
  13885. v4X = v7.x;
  13886. v4Y = v7.y;
  13887. v4Z = v7.z;
  13888. v12X = v2X - v1X;
  13889. v12Y = v2Y - v1Y;
  13890. v12Z = v2Z - v1Z;
  13891. v13X = v3X - v1X;
  13892. v13Y = v3Y - v1Y;
  13893. v13Z = v3Z - v1Z;
  13894. v14X = v4X - v1X;
  13895. v14Y = v4Y - v1Y;
  13896. v14Z = v4Z - v1Z;
  13897. v23X = v3X - v2X;
  13898. v23Y = v3Y - v2Y;
  13899. v23Z = v3Z - v2Z;
  13900. v24X = v4X - v2X;
  13901. v24Y = v4Y - v2Y;
  13902. v24Z = v4Z - v2Z;
  13903. v34X = v4X - v3X;
  13904. v34Y = v4Y - v3Y;
  13905. v34Z = v4Z - v3Z;
  13906. var rev;
  13907. var n123;
  13908. var n123X;
  13909. var n123Y;
  13910. var n123Z;
  13911. var n134;
  13912. var n134X;
  13913. var n134Y;
  13914. var n134Z;
  13915. var n142;
  13916. var n142X;
  13917. var n142Y;
  13918. var n142Z;
  13919. var n243;
  13920. var n243X;
  13921. var n243Y;
  13922. var n243Z;
  13923. var n;
  13924. var nX;
  13925. var nY;
  13926. var nZ;
  13927. n123X = v12Y * v13Z - v12Z * v13Y;
  13928. n123Y = v12Z * v13X - v12X * v13Z;
  13929. n123Z = v12X * v13Y - v12Y * v13X;
  13930. n134X = v13Y * v14Z - v13Z * v14Y;
  13931. n134Y = v13Z * v14X - v13X * v14Z;
  13932. n134Z = v13X * v14Y - v13Y * v14X;
  13933. n142X = v14Y * v12Z - v14Z * v12Y;
  13934. n142Y = v14Z * v12X - v14X * v12Z;
  13935. n142Z = v14X * v12Y - v14Y * v12X;
  13936. n243X = v24Y * v23Z - v24Z * v23Y;
  13937. n243Y = v24Z * v23X - v24X * v23Z;
  13938. n243Z = v24X * v23Y - v24Y * v23X;
  13939. var sign = v12X * n243X + v12Y * n243Y + v12Z * n243Z > 0 ? 1 : -1;
  13940. var d123 = v1X * n123X + v1Y * n123Y + v1Z * n123Z;
  13941. var d134 = v1X * n134X + v1Y * n134Y + v1Z * n134Z;
  13942. var d142 = v1X * n142X + v1Y * n142Y + v1Z * n142Z;
  13943. var d243 = v2X * n243X + v2Y * n243Y + v2Z * n243Z;
  13944. var mind = -1;
  13945. var minv;
  13946. var minvX;
  13947. var minvY;
  13948. var minvZ;
  13949. var mini = 0;
  13950. minvX = 0;
  13951. minvY = 0;
  13952. minvZ = 0;
  13953. if(d123 * sign < 0) {
  13954. var v11;
  13955. var v1X1;
  13956. var v1Y1;
  13957. var v1Z1;
  13958. var v21;
  13959. var v2X1;
  13960. var v2Y1;
  13961. var v2Z1;
  13962. var v31;
  13963. var v3X1;
  13964. var v3Y1;
  13965. var v3Z1;
  13966. var v121;
  13967. var v12X1;
  13968. var v12Y1;
  13969. var v12Z1;
  13970. var v231;
  13971. var v23X1;
  13972. var v23Y1;
  13973. var v23Z1;
  13974. var v311;
  13975. var v31X;
  13976. var v31Y;
  13977. var v31Z;
  13978. var v8 = vec1;
  13979. v1X1 = v8.x;
  13980. v1Y1 = v8.y;
  13981. v1Z1 = v8.z;
  13982. var v9 = vec2;
  13983. v2X1 = v9.x;
  13984. v2Y1 = v9.y;
  13985. v2Z1 = v9.z;
  13986. var v10 = vec3;
  13987. v3X1 = v10.x;
  13988. v3Y1 = v10.y;
  13989. v3Z1 = v10.z;
  13990. v12X1 = v2X1 - v1X1;
  13991. v12Y1 = v2Y1 - v1Y1;
  13992. v12Z1 = v2Z1 - v1Z1;
  13993. v23X1 = v3X1 - v2X1;
  13994. v23Y1 = v3Y1 - v2Y1;
  13995. v23Z1 = v3Z1 - v2Z1;
  13996. v31X = v1X1 - v3X1;
  13997. v31Y = v1Y1 - v3Y1;
  13998. v31Z = v1Z1 - v3Z1;
  13999. var n1;
  14000. var nX1;
  14001. var nY1;
  14002. var nZ1;
  14003. nX1 = v12Y1 * v23Z1 - v12Z1 * v23Y1;
  14004. nY1 = v12Z1 * v23X1 - v12X1 * v23Z1;
  14005. nZ1 = v12X1 * v23Y1 - v12Y1 * v23X1;
  14006. var n12;
  14007. var n12X;
  14008. var n12Y;
  14009. var n12Z;
  14010. var n23;
  14011. var n23X;
  14012. var n23Y;
  14013. var n23Z;
  14014. var n31;
  14015. var n31X;
  14016. var n31Y;
  14017. var n31Z;
  14018. n12X = v12Y1 * nZ1 - v12Z1 * nY1;
  14019. n12Y = v12Z1 * nX1 - v12X1 * nZ1;
  14020. n12Z = v12X1 * nY1 - v12Y1 * nX1;
  14021. n23X = v23Y1 * nZ1 - v23Z1 * nY1;
  14022. n23Y = v23Z1 * nX1 - v23X1 * nZ1;
  14023. n23Z = v23X1 * nY1 - v23Y1 * nX1;
  14024. n31X = v31Y * nZ1 - v31Z * nY1;
  14025. n31Y = v31Z * nX1 - v31X * nZ1;
  14026. n31Z = v31X * nY1 - v31Y * nX1;
  14027. var d12 = v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z;
  14028. var d23 = v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z;
  14029. var d31 = v3X1 * n31X + v3Y1 * n31Y + v3Z1 * n31Z;
  14030. var mind1 = -1;
  14031. var minv1;
  14032. var minvX1;
  14033. var minvY1;
  14034. var minvZ1;
  14035. var mini1 = 0;
  14036. minvX1 = 0;
  14037. minvY1 = 0;
  14038. minvZ1 = 0;
  14039. if(d12 < 0) {
  14040. var v15;
  14041. var v1X2;
  14042. var v1Y2;
  14043. var v1Z2;
  14044. var v22;
  14045. var v2X2;
  14046. var v2Y2;
  14047. var v2Z2;
  14048. var v16 = vec1;
  14049. v1X2 = v16.x;
  14050. v1Y2 = v16.y;
  14051. v1Z2 = v16.z;
  14052. var v17 = vec2;
  14053. v2X2 = v17.x;
  14054. v2Y2 = v17.y;
  14055. v2Z2 = v17.z;
  14056. var v122;
  14057. var v12X2;
  14058. var v12Y2;
  14059. var v12Z2;
  14060. v12X2 = v2X2 - v1X2;
  14061. v12Y2 = v2Y2 - v1Y2;
  14062. v12Z2 = v2Z2 - v1Z2;
  14063. var d = v12X2 * v12X2 + v12Y2 * v12Y2 + v12Z2 * v12Z2;
  14064. var t = v12X2 * v1X2 + v12Y2 * v1Y2 + v12Z2 * v1Z2;
  14065. t = -t / d;
  14066. var b;
  14067. if(t < 0) {
  14068. var v18 = out;
  14069. v18.x = v1X2;
  14070. v18.y = v1Y2;
  14071. v18.z = v1Z2;
  14072. b = 1;
  14073. } else if(t > 1) {
  14074. var v19 = out;
  14075. v19.x = v2X2;
  14076. v19.y = v2Y2;
  14077. v19.z = v2Z2;
  14078. b = 2;
  14079. } else {
  14080. var p;
  14081. var pX;
  14082. var pY;
  14083. var pZ;
  14084. pX = v1X2 + v12X2 * t;
  14085. pY = v1Y2 + v12Y2 * t;
  14086. pZ = v1Z2 + v12Z2 * t;
  14087. var v20 = out;
  14088. v20.x = pX;
  14089. v20.y = pY;
  14090. v20.z = pZ;
  14091. b = 3;
  14092. }
  14093. var d1 = out.x * out.x + out.y * out.y + out.z * out.z;
  14094. mini1 = b;
  14095. mind1 = d1;
  14096. var v25 = out;
  14097. minvX1 = v25.x;
  14098. minvY1 = v25.y;
  14099. minvZ1 = v25.z;
  14100. }
  14101. if(d23 < 0) {
  14102. var v110;
  14103. var v1X3;
  14104. var v1Y3;
  14105. var v1Z3;
  14106. var v26;
  14107. var v2X3;
  14108. var v2Y3;
  14109. var v2Z3;
  14110. var v27 = vec2;
  14111. v1X3 = v27.x;
  14112. v1Y3 = v27.y;
  14113. v1Z3 = v27.z;
  14114. var v28 = vec3;
  14115. v2X3 = v28.x;
  14116. v2Y3 = v28.y;
  14117. v2Z3 = v28.z;
  14118. var v123;
  14119. var v12X3;
  14120. var v12Y3;
  14121. var v12Z3;
  14122. v12X3 = v2X3 - v1X3;
  14123. v12Y3 = v2Y3 - v1Y3;
  14124. v12Z3 = v2Z3 - v1Z3;
  14125. var d2 = v12X3 * v12X3 + v12Y3 * v12Y3 + v12Z3 * v12Z3;
  14126. var t1 = v12X3 * v1X3 + v12Y3 * v1Y3 + v12Z3 * v1Z3;
  14127. t1 = -t1 / d2;
  14128. var b1;
  14129. if(t1 < 0) {
  14130. var v29 = out;
  14131. v29.x = v1X3;
  14132. v29.y = v1Y3;
  14133. v29.z = v1Z3;
  14134. b1 = 1;
  14135. } else if(t1 > 1) {
  14136. var v30 = out;
  14137. v30.x = v2X3;
  14138. v30.y = v2Y3;
  14139. v30.z = v2Z3;
  14140. b1 = 2;
  14141. } else {
  14142. var p1;
  14143. var pX1;
  14144. var pY1;
  14145. var pZ1;
  14146. pX1 = v1X3 + v12X3 * t1;
  14147. pY1 = v1Y3 + v12Y3 * t1;
  14148. pZ1 = v1Z3 + v12Z3 * t1;
  14149. var v32 = out;
  14150. v32.x = pX1;
  14151. v32.y = pY1;
  14152. v32.z = pZ1;
  14153. b1 = 3;
  14154. }
  14155. var d3 = out.x * out.x + out.y * out.y + out.z * out.z;
  14156. if(mind1 < 0 || d3 < mind1) {
  14157. mini1 = b1 << 1;
  14158. mind1 = d3;
  14159. var v33 = out;
  14160. minvX1 = v33.x;
  14161. minvY1 = v33.y;
  14162. minvZ1 = v33.z;
  14163. }
  14164. }
  14165. if(d31 < 0) {
  14166. var v111;
  14167. var v1X4;
  14168. var v1Y4;
  14169. var v1Z4;
  14170. var v210;
  14171. var v2X4;
  14172. var v2Y4;
  14173. var v2Z4;
  14174. var v35 = vec1;
  14175. v1X4 = v35.x;
  14176. v1Y4 = v35.y;
  14177. v1Z4 = v35.z;
  14178. var v36 = vec3;
  14179. v2X4 = v36.x;
  14180. v2Y4 = v36.y;
  14181. v2Z4 = v36.z;
  14182. var v124;
  14183. var v12X4;
  14184. var v12Y4;
  14185. var v12Z4;
  14186. v12X4 = v2X4 - v1X4;
  14187. v12Y4 = v2Y4 - v1Y4;
  14188. v12Z4 = v2Z4 - v1Z4;
  14189. var d4 = v12X4 * v12X4 + v12Y4 * v12Y4 + v12Z4 * v12Z4;
  14190. var t2 = v12X4 * v1X4 + v12Y4 * v1Y4 + v12Z4 * v1Z4;
  14191. t2 = -t2 / d4;
  14192. var b2;
  14193. if(t2 < 0) {
  14194. var v37 = out;
  14195. v37.x = v1X4;
  14196. v37.y = v1Y4;
  14197. v37.z = v1Z4;
  14198. b2 = 1;
  14199. } else if(t2 > 1) {
  14200. var v38 = out;
  14201. v38.x = v2X4;
  14202. v38.y = v2Y4;
  14203. v38.z = v2Z4;
  14204. b2 = 2;
  14205. } else {
  14206. var p2;
  14207. var pX2;
  14208. var pY2;
  14209. var pZ2;
  14210. pX2 = v1X4 + v12X4 * t2;
  14211. pY2 = v1Y4 + v12Y4 * t2;
  14212. pZ2 = v1Z4 + v12Z4 * t2;
  14213. var v39 = out;
  14214. v39.x = pX2;
  14215. v39.y = pY2;
  14216. v39.z = pZ2;
  14217. b2 = 3;
  14218. }
  14219. var d5 = out.x * out.x + out.y * out.y + out.z * out.z;
  14220. if(mind1 < 0 || d5 < mind1) {
  14221. mini1 = b2 & 1 | (b2 & 2) << 1;
  14222. mind1 = d5;
  14223. var v40 = out;
  14224. minvX1 = v40.x;
  14225. minvY1 = v40.y;
  14226. minvZ1 = v40.z;
  14227. }
  14228. }
  14229. var b3;
  14230. if(mind1 > 0) {
  14231. var v41 = out;
  14232. v41.x = minvX1;
  14233. v41.y = minvY1;
  14234. v41.z = minvZ1;
  14235. b3 = mini1;
  14236. } else {
  14237. var l = nX1 * nX1 + nY1 * nY1 + nZ1 * nZ1;
  14238. if(l > 0) {
  14239. l = 1 / Math.sqrt(l);
  14240. }
  14241. nX1 *= l;
  14242. nY1 *= l;
  14243. nZ1 *= l;
  14244. var dn = v1X1 * nX1 + v1Y1 * nY1 + v1Z1 * nZ1;
  14245. var l2 = nX1 * nX1 + nY1 * nY1 + nZ1 * nZ1;
  14246. l2 = dn / l2;
  14247. minvX1 = nX1 * l2;
  14248. minvY1 = nY1 * l2;
  14249. minvZ1 = nZ1 * l2;
  14250. var v42 = out;
  14251. v42.x = minvX1;
  14252. v42.y = minvY1;
  14253. v42.z = minvZ1;
  14254. b3 = 7;
  14255. }
  14256. var d6 = out.x * out.x + out.y * out.y + out.z * out.z;
  14257. mini = b3;
  14258. mind = d6;
  14259. var v43 = out;
  14260. minvX = v43.x;
  14261. minvY = v43.y;
  14262. minvZ = v43.z;
  14263. }
  14264. if(d134 * sign < 0) {
  14265. var v112;
  14266. var v1X5;
  14267. var v1Y5;
  14268. var v1Z5;
  14269. var v211;
  14270. var v2X5;
  14271. var v2Y5;
  14272. var v2Z5;
  14273. var v310;
  14274. var v3X2;
  14275. var v3Y2;
  14276. var v3Z2;
  14277. var v125;
  14278. var v12X5;
  14279. var v12Y5;
  14280. var v12Z5;
  14281. var v232;
  14282. var v23X2;
  14283. var v23Y2;
  14284. var v23Z2;
  14285. var v312;
  14286. var v31X1;
  14287. var v31Y1;
  14288. var v31Z1;
  14289. var v44 = vec1;
  14290. v1X5 = v44.x;
  14291. v1Y5 = v44.y;
  14292. v1Z5 = v44.z;
  14293. var v45 = vec3;
  14294. v2X5 = v45.x;
  14295. v2Y5 = v45.y;
  14296. v2Z5 = v45.z;
  14297. var v46 = vec4;
  14298. v3X2 = v46.x;
  14299. v3Y2 = v46.y;
  14300. v3Z2 = v46.z;
  14301. v12X5 = v2X5 - v1X5;
  14302. v12Y5 = v2Y5 - v1Y5;
  14303. v12Z5 = v2Z5 - v1Z5;
  14304. v23X2 = v3X2 - v2X5;
  14305. v23Y2 = v3Y2 - v2Y5;
  14306. v23Z2 = v3Z2 - v2Z5;
  14307. v31X1 = v1X5 - v3X2;
  14308. v31Y1 = v1Y5 - v3Y2;
  14309. v31Z1 = v1Z5 - v3Z2;
  14310. var n2;
  14311. var nX2;
  14312. var nY2;
  14313. var nZ2;
  14314. nX2 = v12Y5 * v23Z2 - v12Z5 * v23Y2;
  14315. nY2 = v12Z5 * v23X2 - v12X5 * v23Z2;
  14316. nZ2 = v12X5 * v23Y2 - v12Y5 * v23X2;
  14317. var n121;
  14318. var n12X1;
  14319. var n12Y1;
  14320. var n12Z1;
  14321. var n231;
  14322. var n23X1;
  14323. var n23Y1;
  14324. var n23Z1;
  14325. var n311;
  14326. var n31X1;
  14327. var n31Y1;
  14328. var n31Z1;
  14329. n12X1 = v12Y5 * nZ2 - v12Z5 * nY2;
  14330. n12Y1 = v12Z5 * nX2 - v12X5 * nZ2;
  14331. n12Z1 = v12X5 * nY2 - v12Y5 * nX2;
  14332. n23X1 = v23Y2 * nZ2 - v23Z2 * nY2;
  14333. n23Y1 = v23Z2 * nX2 - v23X2 * nZ2;
  14334. n23Z1 = v23X2 * nY2 - v23Y2 * nX2;
  14335. n31X1 = v31Y1 * nZ2 - v31Z1 * nY2;
  14336. n31Y1 = v31Z1 * nX2 - v31X1 * nZ2;
  14337. n31Z1 = v31X1 * nY2 - v31Y1 * nX2;
  14338. var d121 = v1X5 * n12X1 + v1Y5 * n12Y1 + v1Z5 * n12Z1;
  14339. var d231 = v2X5 * n23X1 + v2Y5 * n23Y1 + v2Z5 * n23Z1;
  14340. var d311 = v3X2 * n31X1 + v3Y2 * n31Y1 + v3Z2 * n31Z1;
  14341. var mind2 = -1;
  14342. var minv2;
  14343. var minvX2;
  14344. var minvY2;
  14345. var minvZ2;
  14346. var mini2 = 0;
  14347. minvX2 = 0;
  14348. minvY2 = 0;
  14349. minvZ2 = 0;
  14350. if(d121 < 0) {
  14351. var v113;
  14352. var v1X6;
  14353. var v1Y6;
  14354. var v1Z6;
  14355. var v212;
  14356. var v2X6;
  14357. var v2Y6;
  14358. var v2Z6;
  14359. var v47 = vec1;
  14360. v1X6 = v47.x;
  14361. v1Y6 = v47.y;
  14362. v1Z6 = v47.z;
  14363. var v48 = vec3;
  14364. v2X6 = v48.x;
  14365. v2Y6 = v48.y;
  14366. v2Z6 = v48.z;
  14367. var v126;
  14368. var v12X6;
  14369. var v12Y6;
  14370. var v12Z6;
  14371. v12X6 = v2X6 - v1X6;
  14372. v12Y6 = v2Y6 - v1Y6;
  14373. v12Z6 = v2Z6 - v1Z6;
  14374. var d7 = v12X6 * v12X6 + v12Y6 * v12Y6 + v12Z6 * v12Z6;
  14375. var t3 = v12X6 * v1X6 + v12Y6 * v1Y6 + v12Z6 * v1Z6;
  14376. t3 = -t3 / d7;
  14377. var b4;
  14378. if(t3 < 0) {
  14379. var v49 = out;
  14380. v49.x = v1X6;
  14381. v49.y = v1Y6;
  14382. v49.z = v1Z6;
  14383. b4 = 1;
  14384. } else if(t3 > 1) {
  14385. var v50 = out;
  14386. v50.x = v2X6;
  14387. v50.y = v2Y6;
  14388. v50.z = v2Z6;
  14389. b4 = 2;
  14390. } else {
  14391. var p3;
  14392. var pX3;
  14393. var pY3;
  14394. var pZ3;
  14395. pX3 = v1X6 + v12X6 * t3;
  14396. pY3 = v1Y6 + v12Y6 * t3;
  14397. pZ3 = v1Z6 + v12Z6 * t3;
  14398. var v51 = out;
  14399. v51.x = pX3;
  14400. v51.y = pY3;
  14401. v51.z = pZ3;
  14402. b4 = 3;
  14403. }
  14404. var d8 = out.x * out.x + out.y * out.y + out.z * out.z;
  14405. mini2 = b4;
  14406. mind2 = d8;
  14407. var v52 = out;
  14408. minvX2 = v52.x;
  14409. minvY2 = v52.y;
  14410. minvZ2 = v52.z;
  14411. }
  14412. if(d231 < 0) {
  14413. var v114;
  14414. var v1X7;
  14415. var v1Y7;
  14416. var v1Z7;
  14417. var v213;
  14418. var v2X7;
  14419. var v2Y7;
  14420. var v2Z7;
  14421. var v53 = vec3;
  14422. v1X7 = v53.x;
  14423. v1Y7 = v53.y;
  14424. v1Z7 = v53.z;
  14425. var v54 = vec4;
  14426. v2X7 = v54.x;
  14427. v2Y7 = v54.y;
  14428. v2Z7 = v54.z;
  14429. var v127;
  14430. var v12X7;
  14431. var v12Y7;
  14432. var v12Z7;
  14433. v12X7 = v2X7 - v1X7;
  14434. v12Y7 = v2Y7 - v1Y7;
  14435. v12Z7 = v2Z7 - v1Z7;
  14436. var d9 = v12X7 * v12X7 + v12Y7 * v12Y7 + v12Z7 * v12Z7;
  14437. var t4 = v12X7 * v1X7 + v12Y7 * v1Y7 + v12Z7 * v1Z7;
  14438. t4 = -t4 / d9;
  14439. var b5;
  14440. if(t4 < 0) {
  14441. var v55 = out;
  14442. v55.x = v1X7;
  14443. v55.y = v1Y7;
  14444. v55.z = v1Z7;
  14445. b5 = 1;
  14446. } else if(t4 > 1) {
  14447. var v56 = out;
  14448. v56.x = v2X7;
  14449. v56.y = v2Y7;
  14450. v56.z = v2Z7;
  14451. b5 = 2;
  14452. } else {
  14453. var p4;
  14454. var pX4;
  14455. var pY4;
  14456. var pZ4;
  14457. pX4 = v1X7 + v12X7 * t4;
  14458. pY4 = v1Y7 + v12Y7 * t4;
  14459. pZ4 = v1Z7 + v12Z7 * t4;
  14460. var v57 = out;
  14461. v57.x = pX4;
  14462. v57.y = pY4;
  14463. v57.z = pZ4;
  14464. b5 = 3;
  14465. }
  14466. var d10 = out.x * out.x + out.y * out.y + out.z * out.z;
  14467. if(mind2 < 0 || d10 < mind2) {
  14468. mini2 = b5 << 1;
  14469. mind2 = d10;
  14470. var v58 = out;
  14471. minvX2 = v58.x;
  14472. minvY2 = v58.y;
  14473. minvZ2 = v58.z;
  14474. }
  14475. }
  14476. if(d311 < 0) {
  14477. var v115;
  14478. var v1X8;
  14479. var v1Y8;
  14480. var v1Z8;
  14481. var v214;
  14482. var v2X8;
  14483. var v2Y8;
  14484. var v2Z8;
  14485. var v59 = vec1;
  14486. v1X8 = v59.x;
  14487. v1Y8 = v59.y;
  14488. v1Z8 = v59.z;
  14489. var v60 = vec4;
  14490. v2X8 = v60.x;
  14491. v2Y8 = v60.y;
  14492. v2Z8 = v60.z;
  14493. var v128;
  14494. var v12X8;
  14495. var v12Y8;
  14496. var v12Z8;
  14497. v12X8 = v2X8 - v1X8;
  14498. v12Y8 = v2Y8 - v1Y8;
  14499. v12Z8 = v2Z8 - v1Z8;
  14500. var d11 = v12X8 * v12X8 + v12Y8 * v12Y8 + v12Z8 * v12Z8;
  14501. var t5 = v12X8 * v1X8 + v12Y8 * v1Y8 + v12Z8 * v1Z8;
  14502. t5 = -t5 / d11;
  14503. var b6;
  14504. if(t5 < 0) {
  14505. var v61 = out;
  14506. v61.x = v1X8;
  14507. v61.y = v1Y8;
  14508. v61.z = v1Z8;
  14509. b6 = 1;
  14510. } else if(t5 > 1) {
  14511. var v62 = out;
  14512. v62.x = v2X8;
  14513. v62.y = v2Y8;
  14514. v62.z = v2Z8;
  14515. b6 = 2;
  14516. } else {
  14517. var p5;
  14518. var pX5;
  14519. var pY5;
  14520. var pZ5;
  14521. pX5 = v1X8 + v12X8 * t5;
  14522. pY5 = v1Y8 + v12Y8 * t5;
  14523. pZ5 = v1Z8 + v12Z8 * t5;
  14524. var v63 = out;
  14525. v63.x = pX5;
  14526. v63.y = pY5;
  14527. v63.z = pZ5;
  14528. b6 = 3;
  14529. }
  14530. var d13 = out.x * out.x + out.y * out.y + out.z * out.z;
  14531. if(mind2 < 0 || d13 < mind2) {
  14532. mini2 = b6 & 1 | (b6 & 2) << 1;
  14533. mind2 = d13;
  14534. var v64 = out;
  14535. minvX2 = v64.x;
  14536. minvY2 = v64.y;
  14537. minvZ2 = v64.z;
  14538. }
  14539. }
  14540. var b7;
  14541. if(mind2 > 0) {
  14542. var v65 = out;
  14543. v65.x = minvX2;
  14544. v65.y = minvY2;
  14545. v65.z = minvZ2;
  14546. b7 = mini2;
  14547. } else {
  14548. var l1 = nX2 * nX2 + nY2 * nY2 + nZ2 * nZ2;
  14549. if(l1 > 0) {
  14550. l1 = 1 / Math.sqrt(l1);
  14551. }
  14552. nX2 *= l1;
  14553. nY2 *= l1;
  14554. nZ2 *= l1;
  14555. var dn1 = v1X5 * nX2 + v1Y5 * nY2 + v1Z5 * nZ2;
  14556. var l21 = nX2 * nX2 + nY2 * nY2 + nZ2 * nZ2;
  14557. l21 = dn1 / l21;
  14558. minvX2 = nX2 * l21;
  14559. minvY2 = nY2 * l21;
  14560. minvZ2 = nZ2 * l21;
  14561. var v66 = out;
  14562. v66.x = minvX2;
  14563. v66.y = minvY2;
  14564. v66.z = minvZ2;
  14565. b7 = 7;
  14566. }
  14567. var d14 = out.x * out.x + out.y * out.y + out.z * out.z;
  14568. if(mind < 0 || d14 < mind) {
  14569. mini = b7 & 1 | (b7 & 6) << 1;
  14570. mind = d14;
  14571. var v67 = out;
  14572. minvX = v67.x;
  14573. minvY = v67.y;
  14574. minvZ = v67.z;
  14575. }
  14576. }
  14577. if(d142 * sign < 0) {
  14578. var v116;
  14579. var v1X9;
  14580. var v1Y9;
  14581. var v1Z9;
  14582. var v215;
  14583. var v2X9;
  14584. var v2Y9;
  14585. var v2Z9;
  14586. var v313;
  14587. var v3X3;
  14588. var v3Y3;
  14589. var v3Z3;
  14590. var v129;
  14591. var v12X9;
  14592. var v12Y9;
  14593. var v12Z9;
  14594. var v233;
  14595. var v23X3;
  14596. var v23Y3;
  14597. var v23Z3;
  14598. var v314;
  14599. var v31X2;
  14600. var v31Y2;
  14601. var v31Z2;
  14602. var v68 = vec1;
  14603. v1X9 = v68.x;
  14604. v1Y9 = v68.y;
  14605. v1Z9 = v68.z;
  14606. var v69 = vec2;
  14607. v2X9 = v69.x;
  14608. v2Y9 = v69.y;
  14609. v2Z9 = v69.z;
  14610. var v70 = vec4;
  14611. v3X3 = v70.x;
  14612. v3Y3 = v70.y;
  14613. v3Z3 = v70.z;
  14614. v12X9 = v2X9 - v1X9;
  14615. v12Y9 = v2Y9 - v1Y9;
  14616. v12Z9 = v2Z9 - v1Z9;
  14617. v23X3 = v3X3 - v2X9;
  14618. v23Y3 = v3Y3 - v2Y9;
  14619. v23Z3 = v3Z3 - v2Z9;
  14620. v31X2 = v1X9 - v3X3;
  14621. v31Y2 = v1Y9 - v3Y3;
  14622. v31Z2 = v1Z9 - v3Z3;
  14623. var n3;
  14624. var nX3;
  14625. var nY3;
  14626. var nZ3;
  14627. nX3 = v12Y9 * v23Z3 - v12Z9 * v23Y3;
  14628. nY3 = v12Z9 * v23X3 - v12X9 * v23Z3;
  14629. nZ3 = v12X9 * v23Y3 - v12Y9 * v23X3;
  14630. var n122;
  14631. var n12X2;
  14632. var n12Y2;
  14633. var n12Z2;
  14634. var n232;
  14635. var n23X2;
  14636. var n23Y2;
  14637. var n23Z2;
  14638. var n312;
  14639. var n31X2;
  14640. var n31Y2;
  14641. var n31Z2;
  14642. n12X2 = v12Y9 * nZ3 - v12Z9 * nY3;
  14643. n12Y2 = v12Z9 * nX3 - v12X9 * nZ3;
  14644. n12Z2 = v12X9 * nY3 - v12Y9 * nX3;
  14645. n23X2 = v23Y3 * nZ3 - v23Z3 * nY3;
  14646. n23Y2 = v23Z3 * nX3 - v23X3 * nZ3;
  14647. n23Z2 = v23X3 * nY3 - v23Y3 * nX3;
  14648. n31X2 = v31Y2 * nZ3 - v31Z2 * nY3;
  14649. n31Y2 = v31Z2 * nX3 - v31X2 * nZ3;
  14650. n31Z2 = v31X2 * nY3 - v31Y2 * nX3;
  14651. var d122 = v1X9 * n12X2 + v1Y9 * n12Y2 + v1Z9 * n12Z2;
  14652. var d232 = v2X9 * n23X2 + v2Y9 * n23Y2 + v2Z9 * n23Z2;
  14653. var d312 = v3X3 * n31X2 + v3Y3 * n31Y2 + v3Z3 * n31Z2;
  14654. var mind3 = -1;
  14655. var minv3;
  14656. var minvX3;
  14657. var minvY3;
  14658. var minvZ3;
  14659. var mini3 = 0;
  14660. minvX3 = 0;
  14661. minvY3 = 0;
  14662. minvZ3 = 0;
  14663. if(d122 < 0) {
  14664. var v117;
  14665. var v1X10;
  14666. var v1Y10;
  14667. var v1Z10;
  14668. var v216;
  14669. var v2X10;
  14670. var v2Y10;
  14671. var v2Z10;
  14672. var v71 = vec1;
  14673. v1X10 = v71.x;
  14674. v1Y10 = v71.y;
  14675. v1Z10 = v71.z;
  14676. var v72 = vec2;
  14677. v2X10 = v72.x;
  14678. v2Y10 = v72.y;
  14679. v2Z10 = v72.z;
  14680. var v1210;
  14681. var v12X10;
  14682. var v12Y10;
  14683. var v12Z10;
  14684. v12X10 = v2X10 - v1X10;
  14685. v12Y10 = v2Y10 - v1Y10;
  14686. v12Z10 = v2Z10 - v1Z10;
  14687. var d15 = v12X10 * v12X10 + v12Y10 * v12Y10 + v12Z10 * v12Z10;
  14688. var t6 = v12X10 * v1X10 + v12Y10 * v1Y10 + v12Z10 * v1Z10;
  14689. t6 = -t6 / d15;
  14690. var b8;
  14691. if(t6 < 0) {
  14692. var v73 = out;
  14693. v73.x = v1X10;
  14694. v73.y = v1Y10;
  14695. v73.z = v1Z10;
  14696. b8 = 1;
  14697. } else if(t6 > 1) {
  14698. var v74 = out;
  14699. v74.x = v2X10;
  14700. v74.y = v2Y10;
  14701. v74.z = v2Z10;
  14702. b8 = 2;
  14703. } else {
  14704. var p6;
  14705. var pX6;
  14706. var pY6;
  14707. var pZ6;
  14708. pX6 = v1X10 + v12X10 * t6;
  14709. pY6 = v1Y10 + v12Y10 * t6;
  14710. pZ6 = v1Z10 + v12Z10 * t6;
  14711. var v75 = out;
  14712. v75.x = pX6;
  14713. v75.y = pY6;
  14714. v75.z = pZ6;
  14715. b8 = 3;
  14716. }
  14717. var d16 = out.x * out.x + out.y * out.y + out.z * out.z;
  14718. mini3 = b8;
  14719. mind3 = d16;
  14720. var v76 = out;
  14721. minvX3 = v76.x;
  14722. minvY3 = v76.y;
  14723. minvZ3 = v76.z;
  14724. }
  14725. if(d232 < 0) {
  14726. var v118;
  14727. var v1X11;
  14728. var v1Y11;
  14729. var v1Z11;
  14730. var v217;
  14731. var v2X11;
  14732. var v2Y11;
  14733. var v2Z11;
  14734. var v77 = vec2;
  14735. v1X11 = v77.x;
  14736. v1Y11 = v77.y;
  14737. v1Z11 = v77.z;
  14738. var v78 = vec4;
  14739. v2X11 = v78.x;
  14740. v2Y11 = v78.y;
  14741. v2Z11 = v78.z;
  14742. var v1211;
  14743. var v12X11;
  14744. var v12Y11;
  14745. var v12Z11;
  14746. v12X11 = v2X11 - v1X11;
  14747. v12Y11 = v2Y11 - v1Y11;
  14748. v12Z11 = v2Z11 - v1Z11;
  14749. var d17 = v12X11 * v12X11 + v12Y11 * v12Y11 + v12Z11 * v12Z11;
  14750. var t7 = v12X11 * v1X11 + v12Y11 * v1Y11 + v12Z11 * v1Z11;
  14751. t7 = -t7 / d17;
  14752. var b9;
  14753. if(t7 < 0) {
  14754. var v79 = out;
  14755. v79.x = v1X11;
  14756. v79.y = v1Y11;
  14757. v79.z = v1Z11;
  14758. b9 = 1;
  14759. } else if(t7 > 1) {
  14760. var v80 = out;
  14761. v80.x = v2X11;
  14762. v80.y = v2Y11;
  14763. v80.z = v2Z11;
  14764. b9 = 2;
  14765. } else {
  14766. var p7;
  14767. var pX7;
  14768. var pY7;
  14769. var pZ7;
  14770. pX7 = v1X11 + v12X11 * t7;
  14771. pY7 = v1Y11 + v12Y11 * t7;
  14772. pZ7 = v1Z11 + v12Z11 * t7;
  14773. var v81 = out;
  14774. v81.x = pX7;
  14775. v81.y = pY7;
  14776. v81.z = pZ7;
  14777. b9 = 3;
  14778. }
  14779. var d18 = out.x * out.x + out.y * out.y + out.z * out.z;
  14780. if(mind3 < 0 || d18 < mind3) {
  14781. mini3 = b9 << 1;
  14782. mind3 = d18;
  14783. var v82 = out;
  14784. minvX3 = v82.x;
  14785. minvY3 = v82.y;
  14786. minvZ3 = v82.z;
  14787. }
  14788. }
  14789. if(d312 < 0) {
  14790. var v119;
  14791. var v1X12;
  14792. var v1Y12;
  14793. var v1Z12;
  14794. var v218;
  14795. var v2X12;
  14796. var v2Y12;
  14797. var v2Z12;
  14798. var v83 = vec1;
  14799. v1X12 = v83.x;
  14800. v1Y12 = v83.y;
  14801. v1Z12 = v83.z;
  14802. var v84 = vec4;
  14803. v2X12 = v84.x;
  14804. v2Y12 = v84.y;
  14805. v2Z12 = v84.z;
  14806. var v1212;
  14807. var v12X12;
  14808. var v12Y12;
  14809. var v12Z12;
  14810. v12X12 = v2X12 - v1X12;
  14811. v12Y12 = v2Y12 - v1Y12;
  14812. v12Z12 = v2Z12 - v1Z12;
  14813. var d19 = v12X12 * v12X12 + v12Y12 * v12Y12 + v12Z12 * v12Z12;
  14814. var t8 = v12X12 * v1X12 + v12Y12 * v1Y12 + v12Z12 * v1Z12;
  14815. t8 = -t8 / d19;
  14816. var b10;
  14817. if(t8 < 0) {
  14818. var v85 = out;
  14819. v85.x = v1X12;
  14820. v85.y = v1Y12;
  14821. v85.z = v1Z12;
  14822. b10 = 1;
  14823. } else if(t8 > 1) {
  14824. var v86 = out;
  14825. v86.x = v2X12;
  14826. v86.y = v2Y12;
  14827. v86.z = v2Z12;
  14828. b10 = 2;
  14829. } else {
  14830. var p8;
  14831. var pX8;
  14832. var pY8;
  14833. var pZ8;
  14834. pX8 = v1X12 + v12X12 * t8;
  14835. pY8 = v1Y12 + v12Y12 * t8;
  14836. pZ8 = v1Z12 + v12Z12 * t8;
  14837. var v87 = out;
  14838. v87.x = pX8;
  14839. v87.y = pY8;
  14840. v87.z = pZ8;
  14841. b10 = 3;
  14842. }
  14843. var d20 = out.x * out.x + out.y * out.y + out.z * out.z;
  14844. if(mind3 < 0 || d20 < mind3) {
  14845. mini3 = b10 & 1 | (b10 & 2) << 1;
  14846. mind3 = d20;
  14847. var v88 = out;
  14848. minvX3 = v88.x;
  14849. minvY3 = v88.y;
  14850. minvZ3 = v88.z;
  14851. }
  14852. }
  14853. var b11;
  14854. if(mind3 > 0) {
  14855. var v89 = out;
  14856. v89.x = minvX3;
  14857. v89.y = minvY3;
  14858. v89.z = minvZ3;
  14859. b11 = mini3;
  14860. } else {
  14861. var l3 = nX3 * nX3 + nY3 * nY3 + nZ3 * nZ3;
  14862. if(l3 > 0) {
  14863. l3 = 1 / Math.sqrt(l3);
  14864. }
  14865. nX3 *= l3;
  14866. nY3 *= l3;
  14867. nZ3 *= l3;
  14868. var dn2 = v1X9 * nX3 + v1Y9 * nY3 + v1Z9 * nZ3;
  14869. var l22 = nX3 * nX3 + nY3 * nY3 + nZ3 * nZ3;
  14870. l22 = dn2 / l22;
  14871. minvX3 = nX3 * l22;
  14872. minvY3 = nY3 * l22;
  14873. minvZ3 = nZ3 * l22;
  14874. var v90 = out;
  14875. v90.x = minvX3;
  14876. v90.y = minvY3;
  14877. v90.z = minvZ3;
  14878. b11 = 7;
  14879. }
  14880. var d21 = out.x * out.x + out.y * out.y + out.z * out.z;
  14881. if(mind < 0 || d21 < mind) {
  14882. mini = b11 & 3 | (b11 & 4) << 1;
  14883. mind = d21;
  14884. var v91 = out;
  14885. minvX = v91.x;
  14886. minvY = v91.y;
  14887. minvZ = v91.z;
  14888. }
  14889. }
  14890. if(d243 * sign < 0) {
  14891. var v120;
  14892. var v1X13;
  14893. var v1Y13;
  14894. var v1Z13;
  14895. var v219;
  14896. var v2X13;
  14897. var v2Y13;
  14898. var v2Z13;
  14899. var v315;
  14900. var v3X4;
  14901. var v3Y4;
  14902. var v3Z4;
  14903. var v1213;
  14904. var v12X13;
  14905. var v12Y13;
  14906. var v12Z13;
  14907. var v234;
  14908. var v23X4;
  14909. var v23Y4;
  14910. var v23Z4;
  14911. var v316;
  14912. var v31X3;
  14913. var v31Y3;
  14914. var v31Z3;
  14915. var v92 = vec2;
  14916. v1X13 = v92.x;
  14917. v1Y13 = v92.y;
  14918. v1Z13 = v92.z;
  14919. var v93 = vec3;
  14920. v2X13 = v93.x;
  14921. v2Y13 = v93.y;
  14922. v2Z13 = v93.z;
  14923. var v94 = vec4;
  14924. v3X4 = v94.x;
  14925. v3Y4 = v94.y;
  14926. v3Z4 = v94.z;
  14927. v12X13 = v2X13 - v1X13;
  14928. v12Y13 = v2Y13 - v1Y13;
  14929. v12Z13 = v2Z13 - v1Z13;
  14930. v23X4 = v3X4 - v2X13;
  14931. v23Y4 = v3Y4 - v2Y13;
  14932. v23Z4 = v3Z4 - v2Z13;
  14933. v31X3 = v1X13 - v3X4;
  14934. v31Y3 = v1Y13 - v3Y4;
  14935. v31Z3 = v1Z13 - v3Z4;
  14936. var n4;
  14937. var nX4;
  14938. var nY4;
  14939. var nZ4;
  14940. nX4 = v12Y13 * v23Z4 - v12Z13 * v23Y4;
  14941. nY4 = v12Z13 * v23X4 - v12X13 * v23Z4;
  14942. nZ4 = v12X13 * v23Y4 - v12Y13 * v23X4;
  14943. var n124;
  14944. var n12X3;
  14945. var n12Y3;
  14946. var n12Z3;
  14947. var n233;
  14948. var n23X3;
  14949. var n23Y3;
  14950. var n23Z3;
  14951. var n313;
  14952. var n31X3;
  14953. var n31Y3;
  14954. var n31Z3;
  14955. n12X3 = v12Y13 * nZ4 - v12Z13 * nY4;
  14956. n12Y3 = v12Z13 * nX4 - v12X13 * nZ4;
  14957. n12Z3 = v12X13 * nY4 - v12Y13 * nX4;
  14958. n23X3 = v23Y4 * nZ4 - v23Z4 * nY4;
  14959. n23Y3 = v23Z4 * nX4 - v23X4 * nZ4;
  14960. n23Z3 = v23X4 * nY4 - v23Y4 * nX4;
  14961. n31X3 = v31Y3 * nZ4 - v31Z3 * nY4;
  14962. n31Y3 = v31Z3 * nX4 - v31X3 * nZ4;
  14963. n31Z3 = v31X3 * nY4 - v31Y3 * nX4;
  14964. var d124 = v1X13 * n12X3 + v1Y13 * n12Y3 + v1Z13 * n12Z3;
  14965. var d233 = v2X13 * n23X3 + v2Y13 * n23Y3 + v2Z13 * n23Z3;
  14966. var d313 = v3X4 * n31X3 + v3Y4 * n31Y3 + v3Z4 * n31Z3;
  14967. var mind4 = -1;
  14968. var minv4;
  14969. var minvX4;
  14970. var minvY4;
  14971. var minvZ4;
  14972. var mini4 = 0;
  14973. minvX4 = 0;
  14974. minvY4 = 0;
  14975. minvZ4 = 0;
  14976. if(d124 < 0) {
  14977. var v130;
  14978. var v1X14;
  14979. var v1Y14;
  14980. var v1Z14;
  14981. var v220;
  14982. var v2X14;
  14983. var v2Y14;
  14984. var v2Z14;
  14985. var v95 = vec2;
  14986. v1X14 = v95.x;
  14987. v1Y14 = v95.y;
  14988. v1Z14 = v95.z;
  14989. var v96 = vec3;
  14990. v2X14 = v96.x;
  14991. v2Y14 = v96.y;
  14992. v2Z14 = v96.z;
  14993. var v1214;
  14994. var v12X14;
  14995. var v12Y14;
  14996. var v12Z14;
  14997. v12X14 = v2X14 - v1X14;
  14998. v12Y14 = v2Y14 - v1Y14;
  14999. v12Z14 = v2Z14 - v1Z14;
  15000. var d22 = v12X14 * v12X14 + v12Y14 * v12Y14 + v12Z14 * v12Z14;
  15001. var t9 = v12X14 * v1X14 + v12Y14 * v1Y14 + v12Z14 * v1Z14;
  15002. t9 = -t9 / d22;
  15003. var b12;
  15004. if(t9 < 0) {
  15005. var v97 = out;
  15006. v97.x = v1X14;
  15007. v97.y = v1Y14;
  15008. v97.z = v1Z14;
  15009. b12 = 1;
  15010. } else if(t9 > 1) {
  15011. var v98 = out;
  15012. v98.x = v2X14;
  15013. v98.y = v2Y14;
  15014. v98.z = v2Z14;
  15015. b12 = 2;
  15016. } else {
  15017. var p9;
  15018. var pX9;
  15019. var pY9;
  15020. var pZ9;
  15021. pX9 = v1X14 + v12X14 * t9;
  15022. pY9 = v1Y14 + v12Y14 * t9;
  15023. pZ9 = v1Z14 + v12Z14 * t9;
  15024. var v99 = out;
  15025. v99.x = pX9;
  15026. v99.y = pY9;
  15027. v99.z = pZ9;
  15028. b12 = 3;
  15029. }
  15030. var d24 = out.x * out.x + out.y * out.y + out.z * out.z;
  15031. mini4 = b12;
  15032. mind4 = d24;
  15033. var v100 = out;
  15034. minvX4 = v100.x;
  15035. minvY4 = v100.y;
  15036. minvZ4 = v100.z;
  15037. }
  15038. if(d233 < 0) {
  15039. var v131;
  15040. var v1X15;
  15041. var v1Y15;
  15042. var v1Z15;
  15043. var v221;
  15044. var v2X15;
  15045. var v2Y15;
  15046. var v2Z15;
  15047. var v101 = vec3;
  15048. v1X15 = v101.x;
  15049. v1Y15 = v101.y;
  15050. v1Z15 = v101.z;
  15051. var v102 = vec4;
  15052. v2X15 = v102.x;
  15053. v2Y15 = v102.y;
  15054. v2Z15 = v102.z;
  15055. var v1215;
  15056. var v12X15;
  15057. var v12Y15;
  15058. var v12Z15;
  15059. v12X15 = v2X15 - v1X15;
  15060. v12Y15 = v2Y15 - v1Y15;
  15061. v12Z15 = v2Z15 - v1Z15;
  15062. var d25 = v12X15 * v12X15 + v12Y15 * v12Y15 + v12Z15 * v12Z15;
  15063. var t10 = v12X15 * v1X15 + v12Y15 * v1Y15 + v12Z15 * v1Z15;
  15064. t10 = -t10 / d25;
  15065. var b13;
  15066. if(t10 < 0) {
  15067. var v103 = out;
  15068. v103.x = v1X15;
  15069. v103.y = v1Y15;
  15070. v103.z = v1Z15;
  15071. b13 = 1;
  15072. } else if(t10 > 1) {
  15073. var v104 = out;
  15074. v104.x = v2X15;
  15075. v104.y = v2Y15;
  15076. v104.z = v2Z15;
  15077. b13 = 2;
  15078. } else {
  15079. var p10;
  15080. var pX10;
  15081. var pY10;
  15082. var pZ10;
  15083. pX10 = v1X15 + v12X15 * t10;
  15084. pY10 = v1Y15 + v12Y15 * t10;
  15085. pZ10 = v1Z15 + v12Z15 * t10;
  15086. var v105 = out;
  15087. v105.x = pX10;
  15088. v105.y = pY10;
  15089. v105.z = pZ10;
  15090. b13 = 3;
  15091. }
  15092. var d26 = out.x * out.x + out.y * out.y + out.z * out.z;
  15093. if(mind4 < 0 || d26 < mind4) {
  15094. mini4 = b13 << 1;
  15095. mind4 = d26;
  15096. var v106 = out;
  15097. minvX4 = v106.x;
  15098. minvY4 = v106.y;
  15099. minvZ4 = v106.z;
  15100. }
  15101. }
  15102. if(d313 < 0) {
  15103. var v132;
  15104. var v1X16;
  15105. var v1Y16;
  15106. var v1Z16;
  15107. var v222;
  15108. var v2X16;
  15109. var v2Y16;
  15110. var v2Z16;
  15111. var v107 = vec2;
  15112. v1X16 = v107.x;
  15113. v1Y16 = v107.y;
  15114. v1Z16 = v107.z;
  15115. var v108 = vec4;
  15116. v2X16 = v108.x;
  15117. v2Y16 = v108.y;
  15118. v2Z16 = v108.z;
  15119. var v1216;
  15120. var v12X16;
  15121. var v12Y16;
  15122. var v12Z16;
  15123. v12X16 = v2X16 - v1X16;
  15124. v12Y16 = v2Y16 - v1Y16;
  15125. v12Z16 = v2Z16 - v1Z16;
  15126. var d27 = v12X16 * v12X16 + v12Y16 * v12Y16 + v12Z16 * v12Z16;
  15127. var t11 = v12X16 * v1X16 + v12Y16 * v1Y16 + v12Z16 * v1Z16;
  15128. t11 = -t11 / d27;
  15129. var b14;
  15130. if(t11 < 0) {
  15131. var v109 = out;
  15132. v109.x = v1X16;
  15133. v109.y = v1Y16;
  15134. v109.z = v1Z16;
  15135. b14 = 1;
  15136. } else if(t11 > 1) {
  15137. var v133 = out;
  15138. v133.x = v2X16;
  15139. v133.y = v2Y16;
  15140. v133.z = v2Z16;
  15141. b14 = 2;
  15142. } else {
  15143. var p11;
  15144. var pX11;
  15145. var pY11;
  15146. var pZ11;
  15147. pX11 = v1X16 + v12X16 * t11;
  15148. pY11 = v1Y16 + v12Y16 * t11;
  15149. pZ11 = v1Z16 + v12Z16 * t11;
  15150. var v134 = out;
  15151. v134.x = pX11;
  15152. v134.y = pY11;
  15153. v134.z = pZ11;
  15154. b14 = 3;
  15155. }
  15156. var d28 = out.x * out.x + out.y * out.y + out.z * out.z;
  15157. if(mind4 < 0 || d28 < mind4) {
  15158. mini4 = b14 & 1 | (b14 & 2) << 1;
  15159. mind4 = d28;
  15160. var v135 = out;
  15161. minvX4 = v135.x;
  15162. minvY4 = v135.y;
  15163. minvZ4 = v135.z;
  15164. }
  15165. }
  15166. var b15;
  15167. if(mind4 > 0) {
  15168. var v136 = out;
  15169. v136.x = minvX4;
  15170. v136.y = minvY4;
  15171. v136.z = minvZ4;
  15172. b15 = mini4;
  15173. } else {
  15174. var l4 = nX4 * nX4 + nY4 * nY4 + nZ4 * nZ4;
  15175. if(l4 > 0) {
  15176. l4 = 1 / Math.sqrt(l4);
  15177. }
  15178. nX4 *= l4;
  15179. nY4 *= l4;
  15180. nZ4 *= l4;
  15181. var dn3 = v1X13 * nX4 + v1Y13 * nY4 + v1Z13 * nZ4;
  15182. var l23 = nX4 * nX4 + nY4 * nY4 + nZ4 * nZ4;
  15183. l23 = dn3 / l23;
  15184. minvX4 = nX4 * l23;
  15185. minvY4 = nY4 * l23;
  15186. minvZ4 = nZ4 * l23;
  15187. var v137 = out;
  15188. v137.x = minvX4;
  15189. v137.y = minvY4;
  15190. v137.z = minvZ4;
  15191. b15 = 7;
  15192. }
  15193. var d29 = out.x * out.x + out.y * out.y + out.z * out.z;
  15194. if(mind < 0 || d29 < mind) {
  15195. mini = b15 << 1;
  15196. mind = d29;
  15197. var v138 = out;
  15198. minvX = v138.x;
  15199. minvY = v138.y;
  15200. minvZ = v138.z;
  15201. }
  15202. }
  15203. if(mind > 0) {
  15204. var v139 = out;
  15205. v139.x = minvX;
  15206. v139.y = minvY;
  15207. v139.z = minvZ;
  15208. return mini;
  15209. }
  15210. out.zero();
  15211. return 15;
  15212. }
  15213. }
  15214. oimo.common.Mat3 = class oimo_common_Mat3 {
  15215. constructor(e00,e01,e02,e10,e11,e12,e20,e21,e22) {
  15216. if(e22 == null) {
  15217. e22 = 1;
  15218. }
  15219. if(e21 == null) {
  15220. e21 = 0;
  15221. }
  15222. if(e20 == null) {
  15223. e20 = 0;
  15224. }
  15225. if(e12 == null) {
  15226. e12 = 0;
  15227. }
  15228. if(e11 == null) {
  15229. e11 = 1;
  15230. }
  15231. if(e10 == null) {
  15232. e10 = 0;
  15233. }
  15234. if(e02 == null) {
  15235. e02 = 0;
  15236. }
  15237. if(e01 == null) {
  15238. e01 = 0;
  15239. }
  15240. if(e00 == null) {
  15241. e00 = 1;
  15242. }
  15243. this.e00 = e00;
  15244. this.e01 = e01;
  15245. this.e02 = e02;
  15246. this.e10 = e10;
  15247. this.e11 = e11;
  15248. this.e12 = e12;
  15249. this.e20 = e20;
  15250. this.e21 = e21;
  15251. this.e22 = e22;
  15252. oimo.common.Mat3.numCreations++;
  15253. }
  15254. init(e00,e01,e02,e10,e11,e12,e20,e21,e22) {
  15255. this.e00 = e00;
  15256. this.e01 = e01;
  15257. this.e02 = e02;
  15258. this.e10 = e10;
  15259. this.e11 = e11;
  15260. this.e12 = e12;
  15261. this.e20 = e20;
  15262. this.e21 = e21;
  15263. this.e22 = e22;
  15264. return this;
  15265. }
  15266. identity() {
  15267. var t00 = 1;
  15268. var t01 = 0;
  15269. var t02 = 0;
  15270. var t10 = 0;
  15271. var t11 = 1;
  15272. var t12 = 0;
  15273. var t20 = 0;
  15274. var t21 = 0;
  15275. var t22 = 1;
  15276. this.e00 = t00;
  15277. this.e01 = t01;
  15278. this.e02 = t02;
  15279. this.e10 = t10;
  15280. this.e11 = t11;
  15281. this.e12 = t12;
  15282. this.e20 = t20;
  15283. this.e21 = t21;
  15284. this.e22 = t22;
  15285. return this;
  15286. }
  15287. add(m) {
  15288. return new oimo.common.Mat3(this.e00 + m.e00,this.e01 + m.e01,this.e02 + m.e02,this.e10 + m.e10,this.e11 + m.e11,this.e12 + m.e12,this.e20 + m.e20,this.e21 + m.e21,this.e22 + m.e22);
  15289. }
  15290. sub(m) {
  15291. return new oimo.common.Mat3(this.e00 - m.e00,this.e01 - m.e01,this.e02 - m.e02,this.e10 - m.e10,this.e11 - m.e11,this.e12 - m.e12,this.e20 - m.e20,this.e21 - m.e21,this.e22 - m.e22);
  15292. }
  15293. scale(s) {
  15294. return new oimo.common.Mat3(this.e00 * s,this.e01 * s,this.e02 * s,this.e10 * s,this.e11 * s,this.e12 * s,this.e20 * s,this.e21 * s,this.e22 * s);
  15295. }
  15296. mul(m) {
  15297. return new oimo.common.Mat3(this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20,this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21,this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22,this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20,this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21,this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22,this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20,this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21,this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22);
  15298. }
  15299. addEq(m) {
  15300. var t00 = this.e00 + m.e00;
  15301. var t01 = this.e01 + m.e01;
  15302. var t02 = this.e02 + m.e02;
  15303. var t10 = this.e10 + m.e10;
  15304. var t11 = this.e11 + m.e11;
  15305. var t12 = this.e12 + m.e12;
  15306. var t20 = this.e20 + m.e20;
  15307. var t21 = this.e21 + m.e21;
  15308. var t22 = this.e22 + m.e22;
  15309. this.e00 = t00;
  15310. this.e01 = t01;
  15311. this.e02 = t02;
  15312. this.e10 = t10;
  15313. this.e11 = t11;
  15314. this.e12 = t12;
  15315. this.e20 = t20;
  15316. this.e21 = t21;
  15317. this.e22 = t22;
  15318. return this;
  15319. }
  15320. subEq(m) {
  15321. var t00 = this.e00 - m.e00;
  15322. var t01 = this.e01 - m.e01;
  15323. var t02 = this.e02 - m.e02;
  15324. var t10 = this.e10 - m.e10;
  15325. var t11 = this.e11 - m.e11;
  15326. var t12 = this.e12 - m.e12;
  15327. var t20 = this.e20 - m.e20;
  15328. var t21 = this.e21 - m.e21;
  15329. var t22 = this.e22 - m.e22;
  15330. this.e00 = t00;
  15331. this.e01 = t01;
  15332. this.e02 = t02;
  15333. this.e10 = t10;
  15334. this.e11 = t11;
  15335. this.e12 = t12;
  15336. this.e20 = t20;
  15337. this.e21 = t21;
  15338. this.e22 = t22;
  15339. return this;
  15340. }
  15341. scaleEq(s) {
  15342. var t00 = this.e00 * s;
  15343. var t01 = this.e01 * s;
  15344. var t02 = this.e02 * s;
  15345. var t10 = this.e10 * s;
  15346. var t11 = this.e11 * s;
  15347. var t12 = this.e12 * s;
  15348. var t20 = this.e20 * s;
  15349. var t21 = this.e21 * s;
  15350. var t22 = this.e22 * s;
  15351. this.e00 = t00;
  15352. this.e01 = t01;
  15353. this.e02 = t02;
  15354. this.e10 = t10;
  15355. this.e11 = t11;
  15356. this.e12 = t12;
  15357. this.e20 = t20;
  15358. this.e21 = t21;
  15359. this.e22 = t22;
  15360. return this;
  15361. }
  15362. mulEq(m) {
  15363. var t00 = this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20;
  15364. var t01 = this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21;
  15365. var t02 = this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22;
  15366. var t10 = this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20;
  15367. var t11 = this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21;
  15368. var t12 = this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22;
  15369. var t20 = this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20;
  15370. var t21 = this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21;
  15371. var t22 = this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22;
  15372. this.e00 = t00;
  15373. this.e01 = t01;
  15374. this.e02 = t02;
  15375. this.e10 = t10;
  15376. this.e11 = t11;
  15377. this.e12 = t12;
  15378. this.e20 = t20;
  15379. this.e21 = t21;
  15380. this.e22 = t22;
  15381. return this;
  15382. }
  15383. prependScale(sx,sy,sz) {
  15384. return new oimo.common.Mat3(this.e00 * sx,this.e01 * sx,this.e02 * sx,this.e10 * sy,this.e11 * sy,this.e12 * sy,this.e20 * sz,this.e21 * sz,this.e22 * sz);
  15385. }
  15386. appendScale(sx,sy,sz) {
  15387. return new oimo.common.Mat3(this.e00 * sx,this.e01 * sy,this.e02 * sz,this.e10 * sx,this.e11 * sy,this.e12 * sz,this.e20 * sx,this.e21 * sy,this.e22 * sz);
  15388. }
  15389. prependRotation(rad,axisX,axisY,axisZ) {
  15390. var s = Math.sin(rad);
  15391. var c = Math.cos(rad);
  15392. var c1 = 1 - c;
  15393. var r00 = axisX * axisX * c1 + c;
  15394. var r01 = axisX * axisY * c1 - axisZ * s;
  15395. var r02 = axisX * axisZ * c1 + axisY * s;
  15396. var r10 = axisY * axisX * c1 + axisZ * s;
  15397. var r11 = axisY * axisY * c1 + c;
  15398. var r12 = axisY * axisZ * c1 - axisX * s;
  15399. var r20 = axisZ * axisX * c1 - axisY * s;
  15400. var r21 = axisZ * axisY * c1 + axisX * s;
  15401. var r22 = axisZ * axisZ * c1 + c;
  15402. return new oimo.common.Mat3(r00 * this.e00 + r01 * this.e10 + r02 * this.e20,r00 * this.e01 + r01 * this.e11 + r02 * this.e21,r00 * this.e02 + r01 * this.e12 + r02 * this.e22,r10 * this.e00 + r11 * this.e10 + r12 * this.e20,r10 * this.e01 + r11 * this.e11 + r12 * this.e21,r10 * this.e02 + r11 * this.e12 + r12 * this.e22,r20 * this.e00 + r21 * this.e10 + r22 * this.e20,r20 * this.e01 + r21 * this.e11 + r22 * this.e21,r20 * this.e02 + r21 * this.e12 + r22 * this.e22);
  15403. }
  15404. appendRotation(rad,axisX,axisY,axisZ) {
  15405. var s = Math.sin(rad);
  15406. var c = Math.cos(rad);
  15407. var c1 = 1 - c;
  15408. var r00 = axisX * axisX * c1 + c;
  15409. var r01 = axisX * axisY * c1 - axisZ * s;
  15410. var r02 = axisX * axisZ * c1 + axisY * s;
  15411. var r10 = axisY * axisX * c1 + axisZ * s;
  15412. var r11 = axisY * axisY * c1 + c;
  15413. var r12 = axisY * axisZ * c1 - axisX * s;
  15414. var r20 = axisZ * axisX * c1 - axisY * s;
  15415. var r21 = axisZ * axisY * c1 + axisX * s;
  15416. var r22 = axisZ * axisZ * c1 + c;
  15417. return new oimo.common.Mat3(this.e00 * r00 + this.e01 * r10 + this.e02 * r20,this.e00 * r01 + this.e01 * r11 + this.e02 * r21,this.e00 * r02 + this.e01 * r12 + this.e02 * r22,this.e10 * r00 + this.e11 * r10 + this.e12 * r20,this.e10 * r01 + this.e11 * r11 + this.e12 * r21,this.e10 * r02 + this.e11 * r12 + this.e12 * r22,this.e20 * r00 + this.e21 * r10 + this.e22 * r20,this.e20 * r01 + this.e21 * r11 + this.e22 * r21,this.e20 * r02 + this.e21 * r12 + this.e22 * r22);
  15418. }
  15419. prependScaleEq(sx,sy,sz) {
  15420. var t00 = this.e00 * sx;
  15421. var t01 = this.e01 * sx;
  15422. var t02 = this.e02 * sx;
  15423. var t10 = this.e10 * sy;
  15424. var t11 = this.e11 * sy;
  15425. var t12 = this.e12 * sy;
  15426. var t20 = this.e20 * sz;
  15427. var t21 = this.e21 * sz;
  15428. var t22 = this.e22 * sz;
  15429. this.e00 = t00;
  15430. this.e01 = t01;
  15431. this.e02 = t02;
  15432. this.e10 = t10;
  15433. this.e11 = t11;
  15434. this.e12 = t12;
  15435. this.e20 = t20;
  15436. this.e21 = t21;
  15437. this.e22 = t22;
  15438. return this;
  15439. }
  15440. appendScaleEq(sx,sy,sz) {
  15441. var t00 = this.e00 * sx;
  15442. var t01 = this.e01 * sy;
  15443. var t02 = this.e02 * sz;
  15444. var t10 = this.e10 * sx;
  15445. var t11 = this.e11 * sy;
  15446. var t12 = this.e12 * sz;
  15447. var t20 = this.e20 * sx;
  15448. var t21 = this.e21 * sy;
  15449. var t22 = this.e22 * sz;
  15450. this.e00 = t00;
  15451. this.e01 = t01;
  15452. this.e02 = t02;
  15453. this.e10 = t10;
  15454. this.e11 = t11;
  15455. this.e12 = t12;
  15456. this.e20 = t20;
  15457. this.e21 = t21;
  15458. this.e22 = t22;
  15459. return this;
  15460. }
  15461. prependRotationEq(rad,axisX,axisY,axisZ) {
  15462. var s = Math.sin(rad);
  15463. var c = Math.cos(rad);
  15464. var c1 = 1 - c;
  15465. var r00 = axisX * axisX * c1 + c;
  15466. var r01 = axisX * axisY * c1 - axisZ * s;
  15467. var r02 = axisX * axisZ * c1 + axisY * s;
  15468. var r10 = axisY * axisX * c1 + axisZ * s;
  15469. var r11 = axisY * axisY * c1 + c;
  15470. var r12 = axisY * axisZ * c1 - axisX * s;
  15471. var r20 = axisZ * axisX * c1 - axisY * s;
  15472. var r21 = axisZ * axisY * c1 + axisX * s;
  15473. var r22 = axisZ * axisZ * c1 + c;
  15474. var t00 = r00 * this.e00 + r01 * this.e10 + r02 * this.e20;
  15475. var t01 = r00 * this.e01 + r01 * this.e11 + r02 * this.e21;
  15476. var t02 = r00 * this.e02 + r01 * this.e12 + r02 * this.e22;
  15477. var t10 = r10 * this.e00 + r11 * this.e10 + r12 * this.e20;
  15478. var t11 = r10 * this.e01 + r11 * this.e11 + r12 * this.e21;
  15479. var t12 = r10 * this.e02 + r11 * this.e12 + r12 * this.e22;
  15480. var t20 = r20 * this.e00 + r21 * this.e10 + r22 * this.e20;
  15481. var t21 = r20 * this.e01 + r21 * this.e11 + r22 * this.e21;
  15482. var t22 = r20 * this.e02 + r21 * this.e12 + r22 * this.e22;
  15483. this.e00 = t00;
  15484. this.e01 = t01;
  15485. this.e02 = t02;
  15486. this.e10 = t10;
  15487. this.e11 = t11;
  15488. this.e12 = t12;
  15489. this.e20 = t20;
  15490. this.e21 = t21;
  15491. this.e22 = t22;
  15492. return this;
  15493. }
  15494. appendRotationEq(rad,axisX,axisY,axisZ) {
  15495. var s = Math.sin(rad);
  15496. var c = Math.cos(rad);
  15497. var c1 = 1 - c;
  15498. var r00 = axisX * axisX * c1 + c;
  15499. var r01 = axisX * axisY * c1 - axisZ * s;
  15500. var r02 = axisX * axisZ * c1 + axisY * s;
  15501. var r10 = axisY * axisX * c1 + axisZ * s;
  15502. var r11 = axisY * axisY * c1 + c;
  15503. var r12 = axisY * axisZ * c1 - axisX * s;
  15504. var r20 = axisZ * axisX * c1 - axisY * s;
  15505. var r21 = axisZ * axisY * c1 + axisX * s;
  15506. var r22 = axisZ * axisZ * c1 + c;
  15507. var t00 = this.e00 * r00 + this.e01 * r10 + this.e02 * r20;
  15508. var t01 = this.e00 * r01 + this.e01 * r11 + this.e02 * r21;
  15509. var t02 = this.e00 * r02 + this.e01 * r12 + this.e02 * r22;
  15510. var t10 = this.e10 * r00 + this.e11 * r10 + this.e12 * r20;
  15511. var t11 = this.e10 * r01 + this.e11 * r11 + this.e12 * r21;
  15512. var t12 = this.e10 * r02 + this.e11 * r12 + this.e12 * r22;
  15513. var t20 = this.e20 * r00 + this.e21 * r10 + this.e22 * r20;
  15514. var t21 = this.e20 * r01 + this.e21 * r11 + this.e22 * r21;
  15515. var t22 = this.e20 * r02 + this.e21 * r12 + this.e22 * r22;
  15516. this.e00 = t00;
  15517. this.e01 = t01;
  15518. this.e02 = t02;
  15519. this.e10 = t10;
  15520. this.e11 = t11;
  15521. this.e12 = t12;
  15522. this.e20 = t20;
  15523. this.e21 = t21;
  15524. this.e22 = t22;
  15525. return this;
  15526. }
  15527. transpose() {
  15528. return new oimo.common.Mat3(this.e00,this.e10,this.e20,this.e01,this.e11,this.e21,this.e02,this.e12,this.e22);
  15529. }
  15530. transposeEq() {
  15531. var t00 = this.e00;
  15532. var t01 = this.e10;
  15533. var t02 = this.e20;
  15534. var t10 = this.e01;
  15535. var t11 = this.e11;
  15536. var t12 = this.e21;
  15537. var t20 = this.e02;
  15538. var t21 = this.e12;
  15539. var t22 = this.e22;
  15540. this.e00 = t00;
  15541. this.e01 = t01;
  15542. this.e02 = t02;
  15543. this.e10 = t10;
  15544. this.e11 = t11;
  15545. this.e12 = t12;
  15546. this.e20 = t20;
  15547. this.e21 = t21;
  15548. this.e22 = t22;
  15549. return this;
  15550. }
  15551. determinant() {
  15552. return this.e00 * (this.e11 * this.e22 - this.e12 * this.e21) - this.e01 * (this.e10 * this.e22 - this.e12 * this.e20) + this.e02 * (this.e10 * this.e21 - this.e11 * this.e20);
  15553. }
  15554. trace() {
  15555. return this.e00 + this.e11 + this.e22;
  15556. }
  15557. inverse() {
  15558. var d00 = this.e11 * this.e22 - this.e12 * this.e21;
  15559. var d01 = this.e10 * this.e22 - this.e12 * this.e20;
  15560. var d02 = this.e10 * this.e21 - this.e11 * this.e20;
  15561. var d10 = this.e01 * this.e22 - this.e02 * this.e21;
  15562. var d11 = this.e00 * this.e22 - this.e02 * this.e20;
  15563. var d12 = this.e00 * this.e21 - this.e01 * this.e20;
  15564. var d20 = this.e01 * this.e12 - this.e02 * this.e11;
  15565. var d21 = this.e00 * this.e12 - this.e02 * this.e10;
  15566. var d22 = this.e00 * this.e11 - this.e01 * this.e10;
  15567. var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02;
  15568. if(invDet != 0) {
  15569. invDet = 1 / invDet;
  15570. }
  15571. return new oimo.common.Mat3(d00 * invDet,-d10 * invDet,d20 * invDet,-d01 * invDet,d11 * invDet,-d21 * invDet,d02 * invDet,-d12 * invDet,d22 * invDet);
  15572. }
  15573. inverseEq() {
  15574. var d00 = this.e11 * this.e22 - this.e12 * this.e21;
  15575. var d01 = this.e10 * this.e22 - this.e12 * this.e20;
  15576. var d02 = this.e10 * this.e21 - this.e11 * this.e20;
  15577. var d10 = this.e01 * this.e22 - this.e02 * this.e21;
  15578. var d11 = this.e00 * this.e22 - this.e02 * this.e20;
  15579. var d12 = this.e00 * this.e21 - this.e01 * this.e20;
  15580. var d20 = this.e01 * this.e12 - this.e02 * this.e11;
  15581. var d21 = this.e00 * this.e12 - this.e02 * this.e10;
  15582. var d22 = this.e00 * this.e11 - this.e01 * this.e10;
  15583. var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02;
  15584. if(invDet != 0) {
  15585. invDet = 1 / invDet;
  15586. }
  15587. var t00 = d00 * invDet;
  15588. var t01 = -d10 * invDet;
  15589. var t02 = d20 * invDet;
  15590. var t10 = -d01 * invDet;
  15591. var t11 = d11 * invDet;
  15592. var t12 = -d21 * invDet;
  15593. var t20 = d02 * invDet;
  15594. var t21 = -d12 * invDet;
  15595. var t22 = d22 * invDet;
  15596. this.e00 = t00;
  15597. this.e01 = t01;
  15598. this.e02 = t02;
  15599. this.e10 = t10;
  15600. this.e11 = t11;
  15601. this.e12 = t12;
  15602. this.e20 = t20;
  15603. this.e21 = t21;
  15604. this.e22 = t22;
  15605. return this;
  15606. }
  15607. toArray(columnMajor) {
  15608. if(columnMajor == null) {
  15609. columnMajor = false;
  15610. }
  15611. if(columnMajor) {
  15612. return [this.e00,this.e10,this.e20,this.e01,this.e11,this.e21,this.e02,this.e12,this.e22];
  15613. } else {
  15614. return [this.e00,this.e01,this.e02,this.e10,this.e11,this.e12,this.e20,this.e21,this.e22];
  15615. }
  15616. }
  15617. copyFrom(m) {
  15618. this.e00 = m.e00;
  15619. this.e01 = m.e01;
  15620. this.e02 = m.e02;
  15621. this.e10 = m.e10;
  15622. this.e11 = m.e11;
  15623. this.e12 = m.e12;
  15624. this.e20 = m.e20;
  15625. this.e21 = m.e21;
  15626. this.e22 = m.e22;
  15627. return this;
  15628. }
  15629. clone() {
  15630. return new oimo.common.Mat3(this.e00,this.e01,this.e02,this.e10,this.e11,this.e12,this.e20,this.e21,this.e22);
  15631. }
  15632. fromQuat(q) {
  15633. var x = q.x;
  15634. var y = q.y;
  15635. var z = q.z;
  15636. var w = q.w;
  15637. var x2 = 2 * x;
  15638. var y2 = 2 * y;
  15639. var z2 = 2 * z;
  15640. var xx = x * x2;
  15641. var yy = y * y2;
  15642. var zz = z * z2;
  15643. var xy = x * y2;
  15644. var yz = y * z2;
  15645. var xz = x * z2;
  15646. var wx = w * x2;
  15647. var wy = w * y2;
  15648. var wz = w * z2;
  15649. this.e00 = 1 - yy - zz;
  15650. this.e01 = xy - wz;
  15651. this.e02 = xz + wy;
  15652. this.e10 = xy + wz;
  15653. this.e11 = 1 - xx - zz;
  15654. this.e12 = yz - wx;
  15655. this.e20 = xz - wy;
  15656. this.e21 = yz + wx;
  15657. this.e22 = 1 - xx - yy;
  15658. return this;
  15659. }
  15660. toQuat() {
  15661. var _this = new oimo.common.Quat();
  15662. var e00 = this.e00;
  15663. var e11 = this.e11;
  15664. var e22 = this.e22;
  15665. var t = e00 + e11 + e22;
  15666. var s;
  15667. if(t > 0) {
  15668. s = Math.sqrt(t + 1);
  15669. _this.w = 0.5 * s;
  15670. s = 0.5 / s;
  15671. _this.x = (this.e21 - this.e12) * s;
  15672. _this.y = (this.e02 - this.e20) * s;
  15673. _this.z = (this.e10 - this.e01) * s;
  15674. } else if(e00 > e11) {
  15675. if(e00 > e22) {
  15676. s = Math.sqrt(e00 - e11 - e22 + 1);
  15677. _this.x = 0.5 * s;
  15678. s = 0.5 / s;
  15679. _this.y = (this.e01 + this.e10) * s;
  15680. _this.z = (this.e02 + this.e20) * s;
  15681. _this.w = (this.e21 - this.e12) * s;
  15682. } else {
  15683. s = Math.sqrt(e22 - e00 - e11 + 1);
  15684. _this.z = 0.5 * s;
  15685. s = 0.5 / s;
  15686. _this.x = (this.e02 + this.e20) * s;
  15687. _this.y = (this.e12 + this.e21) * s;
  15688. _this.w = (this.e10 - this.e01) * s;
  15689. }
  15690. } else if(e11 > e22) {
  15691. s = Math.sqrt(e11 - e22 - e00 + 1);
  15692. _this.y = 0.5 * s;
  15693. s = 0.5 / s;
  15694. _this.x = (this.e01 + this.e10) * s;
  15695. _this.z = (this.e12 + this.e21) * s;
  15696. _this.w = (this.e02 - this.e20) * s;
  15697. } else {
  15698. s = Math.sqrt(e22 - e00 - e11 + 1);
  15699. _this.z = 0.5 * s;
  15700. s = 0.5 / s;
  15701. _this.x = (this.e02 + this.e20) * s;
  15702. _this.y = (this.e12 + this.e21) * s;
  15703. _this.w = (this.e10 - this.e01) * s;
  15704. }
  15705. return _this;
  15706. }
  15707. fromEulerXyz(eulerAngles) {
  15708. var sx = Math.sin(eulerAngles.x);
  15709. var sy = Math.sin(eulerAngles.y);
  15710. var sz = Math.sin(eulerAngles.z);
  15711. var cx = Math.cos(eulerAngles.x);
  15712. var cy = Math.cos(eulerAngles.y);
  15713. var cz = Math.cos(eulerAngles.z);
  15714. var t00 = cy * cz;
  15715. var t01 = -cy * sz;
  15716. var t02 = sy;
  15717. var t10 = cx * sz + cz * sx * sy;
  15718. var t11 = cx * cz - sx * sy * sz;
  15719. var t12 = -cy * sx;
  15720. var t20 = sx * sz - cx * cz * sy;
  15721. var t21 = cz * sx + cx * sy * sz;
  15722. var t22 = cx * cy;
  15723. this.e00 = t00;
  15724. this.e01 = t01;
  15725. this.e02 = t02;
  15726. this.e10 = t10;
  15727. this.e11 = t11;
  15728. this.e12 = t12;
  15729. this.e20 = t20;
  15730. this.e21 = t21;
  15731. this.e22 = t22;
  15732. return this;
  15733. }
  15734. toEulerXyz() {
  15735. var sy = this.e02;
  15736. if(sy <= -1) {
  15737. var xSubZ = Math.atan2(this.e21,this.e11);
  15738. return new oimo.common.Vec3(xSubZ * 0.5,-1.570796326794895,-xSubZ * 0.5);
  15739. }
  15740. if(sy >= 1) {
  15741. var xAddZ = Math.atan2(this.e21,this.e11);
  15742. return new oimo.common.Vec3(xAddZ * 0.5,1.570796326794895,xAddZ * 0.5);
  15743. }
  15744. var y = Math.asin(sy);
  15745. var x = Math.atan2(-this.e12,this.e22);
  15746. var z = Math.atan2(-this.e01,this.e00);
  15747. return new oimo.common.Vec3(x,y,z);
  15748. }
  15749. getRow(index) {
  15750. if(index == 0) {
  15751. return new oimo.common.Vec3(this.e00,this.e01,this.e02);
  15752. } else if(index == 1) {
  15753. return new oimo.common.Vec3(this.e10,this.e11,this.e12);
  15754. } else if(index == 2) {
  15755. return new oimo.common.Vec3(this.e20,this.e21,this.e22);
  15756. } else {
  15757. return null;
  15758. }
  15759. }
  15760. getCol(index) {
  15761. if(index == 0) {
  15762. return new oimo.common.Vec3(this.e00,this.e10,this.e20);
  15763. } else if(index == 1) {
  15764. return new oimo.common.Vec3(this.e01,this.e11,this.e21);
  15765. } else if(index == 2) {
  15766. return new oimo.common.Vec3(this.e02,this.e12,this.e22);
  15767. } else {
  15768. return null;
  15769. }
  15770. }
  15771. getRowTo(index,dst) {
  15772. if(index == 0) {
  15773. dst.init(this.e00,this.e01,this.e02);
  15774. } else if(index == 1) {
  15775. dst.init(this.e10,this.e11,this.e12);
  15776. } else if(index == 2) {
  15777. dst.init(this.e20,this.e21,this.e22);
  15778. } else {
  15779. dst.zero();
  15780. }
  15781. }
  15782. getColTo(index,dst) {
  15783. if(index == 0) {
  15784. dst.init(this.e00,this.e10,this.e20);
  15785. } else if(index == 1) {
  15786. dst.init(this.e01,this.e11,this.e21);
  15787. } else if(index == 2) {
  15788. dst.init(this.e02,this.e12,this.e22);
  15789. } else {
  15790. dst.zero();
  15791. }
  15792. }
  15793. fromRows(row0,row1,row2) {
  15794. var t00 = row0.x;
  15795. var t01 = row0.y;
  15796. var t02 = row0.z;
  15797. var t10 = row1.x;
  15798. var t11 = row1.y;
  15799. var t12 = row1.z;
  15800. var t20 = row2.x;
  15801. var t21 = row2.y;
  15802. var t22 = row2.z;
  15803. this.e00 = t00;
  15804. this.e01 = t01;
  15805. this.e02 = t02;
  15806. this.e10 = t10;
  15807. this.e11 = t11;
  15808. this.e12 = t12;
  15809. this.e20 = t20;
  15810. this.e21 = t21;
  15811. this.e22 = t22;
  15812. return this;
  15813. }
  15814. fromCols(col0,col1,col2) {
  15815. var t00 = col0.x;
  15816. var t01 = col1.x;
  15817. var t02 = col2.x;
  15818. var t10 = col0.y;
  15819. var t11 = col1.y;
  15820. var t12 = col2.y;
  15821. var t20 = col0.z;
  15822. var t21 = col1.z;
  15823. var t22 = col2.z;
  15824. this.e00 = t00;
  15825. this.e01 = t01;
  15826. this.e02 = t02;
  15827. this.e10 = t10;
  15828. this.e11 = t11;
  15829. this.e12 = t12;
  15830. this.e20 = t20;
  15831. this.e21 = t21;
  15832. this.e22 = t22;
  15833. return this;
  15834. }
  15835. toString() {
  15836. return "Mat3[" + (this.e00 > 0 ? (this.e00 * 10000000 + 0.5 | 0) / 10000000 : (this.e00 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e01 > 0 ? (this.e01 * 10000000 + 0.5 | 0) / 10000000 : (this.e01 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e02 > 0 ? (this.e02 * 10000000 + 0.5 | 0) / 10000000 : (this.e02 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e10 > 0 ? (this.e10 * 10000000 + 0.5 | 0) / 10000000 : (this.e10 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e11 > 0 ? (this.e11 * 10000000 + 0.5 | 0) / 10000000 : (this.e11 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e12 > 0 ? (this.e12 * 10000000 + 0.5 | 0) / 10000000 : (this.e12 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e20 > 0 ? (this.e20 * 10000000 + 0.5 | 0) / 10000000 : (this.e20 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e21 > 0 ? (this.e21 * 10000000 + 0.5 | 0) / 10000000 : (this.e21 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e22 > 0 ? (this.e22 * 10000000 + 0.5 | 0) / 10000000 : (this.e22 * 10000000 - 0.5 | 0) / 10000000) + "]";
  15837. }
  15838. }
  15839. oimo.common.Mat4 = class oimo_common_Mat4 {
  15840. constructor(e00,e01,e02,e03,e10,e11,e12,e13,e20,e21,e22,e23,e30,e31,e32,e33) {
  15841. if(e33 == null) {
  15842. e33 = 1;
  15843. }
  15844. if(e32 == null) {
  15845. e32 = 0;
  15846. }
  15847. if(e31 == null) {
  15848. e31 = 0;
  15849. }
  15850. if(e30 == null) {
  15851. e30 = 0;
  15852. }
  15853. if(e23 == null) {
  15854. e23 = 0;
  15855. }
  15856. if(e22 == null) {
  15857. e22 = 1;
  15858. }
  15859. if(e21 == null) {
  15860. e21 = 0;
  15861. }
  15862. if(e20 == null) {
  15863. e20 = 0;
  15864. }
  15865. if(e13 == null) {
  15866. e13 = 0;
  15867. }
  15868. if(e12 == null) {
  15869. e12 = 0;
  15870. }
  15871. if(e11 == null) {
  15872. e11 = 1;
  15873. }
  15874. if(e10 == null) {
  15875. e10 = 0;
  15876. }
  15877. if(e03 == null) {
  15878. e03 = 0;
  15879. }
  15880. if(e02 == null) {
  15881. e02 = 0;
  15882. }
  15883. if(e01 == null) {
  15884. e01 = 0;
  15885. }
  15886. if(e00 == null) {
  15887. e00 = 1;
  15888. }
  15889. this.e00 = e00;
  15890. this.e01 = e01;
  15891. this.e02 = e02;
  15892. this.e03 = e03;
  15893. this.e10 = e10;
  15894. this.e11 = e11;
  15895. this.e12 = e12;
  15896. this.e13 = e13;
  15897. this.e20 = e20;
  15898. this.e21 = e21;
  15899. this.e22 = e22;
  15900. this.e23 = e23;
  15901. this.e30 = e30;
  15902. this.e31 = e31;
  15903. this.e32 = e32;
  15904. this.e33 = e33;
  15905. oimo.common.Mat4.numCreations++;
  15906. }
  15907. init(e00,e01,e02,e03,e10,e11,e12,e13,e20,e21,e22,e23,e30,e31,e32,e33) {
  15908. this.e00 = e00;
  15909. this.e01 = e01;
  15910. this.e02 = e02;
  15911. this.e03 = e03;
  15912. this.e10 = e10;
  15913. this.e11 = e11;
  15914. this.e12 = e12;
  15915. this.e13 = e13;
  15916. this.e20 = e20;
  15917. this.e21 = e21;
  15918. this.e22 = e22;
  15919. this.e23 = e23;
  15920. this.e30 = e30;
  15921. this.e31 = e31;
  15922. this.e32 = e32;
  15923. this.e33 = e33;
  15924. return this;
  15925. }
  15926. identity() {
  15927. var t00 = 1;
  15928. var t01 = 0;
  15929. var t02 = 0;
  15930. var t03 = 0;
  15931. var t10 = 0;
  15932. var t11 = 1;
  15933. var t12 = 0;
  15934. var t13 = 0;
  15935. var t20 = 0;
  15936. var t21 = 0;
  15937. var t22 = 1;
  15938. var t23 = 0;
  15939. var t30 = 0;
  15940. var t31 = 0;
  15941. var t32 = 0;
  15942. var t33 = 1;
  15943. this.e00 = t00;
  15944. this.e01 = t01;
  15945. this.e02 = t02;
  15946. this.e03 = t03;
  15947. this.e10 = t10;
  15948. this.e11 = t11;
  15949. this.e12 = t12;
  15950. this.e13 = t13;
  15951. this.e20 = t20;
  15952. this.e21 = t21;
  15953. this.e22 = t22;
  15954. this.e23 = t23;
  15955. this.e30 = t30;
  15956. this.e31 = t31;
  15957. this.e32 = t32;
  15958. this.e33 = t33;
  15959. return this;
  15960. }
  15961. add(m) {
  15962. return new oimo.common.Mat4(this.e00 + m.e00,this.e01 + m.e01,this.e02 + m.e02,this.e03 + m.e03,this.e10 + m.e10,this.e11 + m.e11,this.e12 + m.e12,this.e13 + m.e13,this.e20 + m.e20,this.e21 + m.e21,this.e22 + m.e22,this.e23 + m.e23,this.e30 + m.e30,this.e31 + m.e31,this.e32 + m.e32,this.e33 + m.e33);
  15963. }
  15964. sub(m) {
  15965. return new oimo.common.Mat4(this.e00 - m.e00,this.e01 - m.e01,this.e02 - m.e02,this.e03 - m.e03,this.e10 - m.e10,this.e11 - m.e11,this.e12 - m.e12,this.e13 - m.e13,this.e20 - m.e20,this.e21 - m.e21,this.e22 - m.e22,this.e23 - m.e23,this.e30 - m.e30,this.e31 - m.e31,this.e32 - m.e32,this.e33 - m.e33);
  15966. }
  15967. scale(s) {
  15968. return new oimo.common.Mat4(this.e00 * s,this.e01 * s,this.e02 * s,this.e03 * s,this.e10 * s,this.e11 * s,this.e12 * s,this.e13 * s,this.e20 * s,this.e21 * s,this.e22 * s,this.e23 * s,this.e30 * s,this.e31 * s,this.e32 * s,this.e33 * s);
  15969. }
  15970. mul(m) {
  15971. return new oimo.common.Mat4(this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20 + this.e03 * m.e30,this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21 + this.e03 * m.e31,this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22 + this.e03 * m.e32,this.e00 * m.e03 + this.e01 * m.e13 + this.e02 * m.e23 + this.e03 * m.e33,this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20 + this.e13 * m.e30,this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21 + this.e13 * m.e31,this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22 + this.e13 * m.e32,this.e10 * m.e03 + this.e11 * m.e13 + this.e12 * m.e23 + this.e13 * m.e33,this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20 + this.e23 * m.e30,this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21 + this.e23 * m.e31,this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22 + this.e23 * m.e32,this.e20 * m.e03 + this.e21 * m.e13 + this.e22 * m.e23 + this.e23 * m.e33,this.e30 * m.e00 + this.e31 * m.e10 + this.e32 * m.e20 + this.e33 * m.e30,this.e30 * m.e01 + this.e31 * m.e11 + this.e32 * m.e21 + this.e33 * m.e31,this.e30 * m.e02 + this.e31 * m.e12 + this.e32 * m.e22 + this.e33 * m.e32,this.e30 * m.e03 + this.e31 * m.e13 + this.e32 * m.e23 + this.e33 * m.e33);
  15972. }
  15973. addEq(m) {
  15974. var t00 = this.e00 + m.e00;
  15975. var t01 = this.e01 + m.e01;
  15976. var t02 = this.e02 + m.e02;
  15977. var t03 = this.e03 + m.e03;
  15978. var t10 = this.e10 + m.e10;
  15979. var t11 = this.e11 + m.e11;
  15980. var t12 = this.e12 + m.e12;
  15981. var t13 = this.e13 + m.e13;
  15982. var t20 = this.e20 + m.e20;
  15983. var t21 = this.e21 + m.e21;
  15984. var t22 = this.e22 + m.e22;
  15985. var t23 = this.e23 + m.e23;
  15986. var t30 = this.e30 + m.e30;
  15987. var t31 = this.e31 + m.e31;
  15988. var t32 = this.e32 + m.e32;
  15989. var t33 = this.e33 + m.e33;
  15990. this.e00 = t00;
  15991. this.e01 = t01;
  15992. this.e02 = t02;
  15993. this.e03 = t03;
  15994. this.e10 = t10;
  15995. this.e11 = t11;
  15996. this.e12 = t12;
  15997. this.e13 = t13;
  15998. this.e20 = t20;
  15999. this.e21 = t21;
  16000. this.e22 = t22;
  16001. this.e23 = t23;
  16002. this.e30 = t30;
  16003. this.e31 = t31;
  16004. this.e32 = t32;
  16005. this.e33 = t33;
  16006. return this;
  16007. }
  16008. subEq(m) {
  16009. var t00 = this.e00 - m.e00;
  16010. var t01 = this.e01 - m.e01;
  16011. var t02 = this.e02 - m.e02;
  16012. var t03 = this.e03 - m.e03;
  16013. var t10 = this.e10 - m.e10;
  16014. var t11 = this.e11 - m.e11;
  16015. var t12 = this.e12 - m.e12;
  16016. var t13 = this.e13 - m.e13;
  16017. var t20 = this.e20 - m.e20;
  16018. var t21 = this.e21 - m.e21;
  16019. var t22 = this.e22 - m.e22;
  16020. var t23 = this.e23 - m.e23;
  16021. var t30 = this.e30 - m.e30;
  16022. var t31 = this.e31 - m.e31;
  16023. var t32 = this.e32 - m.e32;
  16024. var t33 = this.e33 - m.e33;
  16025. this.e00 = t00;
  16026. this.e01 = t01;
  16027. this.e02 = t02;
  16028. this.e03 = t03;
  16029. this.e10 = t10;
  16030. this.e11 = t11;
  16031. this.e12 = t12;
  16032. this.e13 = t13;
  16033. this.e20 = t20;
  16034. this.e21 = t21;
  16035. this.e22 = t22;
  16036. this.e23 = t23;
  16037. this.e30 = t30;
  16038. this.e31 = t31;
  16039. this.e32 = t32;
  16040. this.e33 = t33;
  16041. return this;
  16042. }
  16043. scaleEq(s) {
  16044. var t00 = this.e00 * s;
  16045. var t01 = this.e01 * s;
  16046. var t02 = this.e02 * s;
  16047. var t03 = this.e03 * s;
  16048. var t10 = this.e10 * s;
  16049. var t11 = this.e11 * s;
  16050. var t12 = this.e12 * s;
  16051. var t13 = this.e13 * s;
  16052. var t20 = this.e20 * s;
  16053. var t21 = this.e21 * s;
  16054. var t22 = this.e22 * s;
  16055. var t23 = this.e23 * s;
  16056. var t30 = this.e30 * s;
  16057. var t31 = this.e31 * s;
  16058. var t32 = this.e32 * s;
  16059. var t33 = this.e33 * s;
  16060. this.e00 = t00;
  16061. this.e01 = t01;
  16062. this.e02 = t02;
  16063. this.e03 = t03;
  16064. this.e10 = t10;
  16065. this.e11 = t11;
  16066. this.e12 = t12;
  16067. this.e13 = t13;
  16068. this.e20 = t20;
  16069. this.e21 = t21;
  16070. this.e22 = t22;
  16071. this.e23 = t23;
  16072. this.e30 = t30;
  16073. this.e31 = t31;
  16074. this.e32 = t32;
  16075. this.e33 = t33;
  16076. return this;
  16077. }
  16078. mulEq(m) {
  16079. var t00 = this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20 + this.e03 * m.e30;
  16080. var t01 = this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21 + this.e03 * m.e31;
  16081. var t02 = this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22 + this.e03 * m.e32;
  16082. var t03 = this.e00 * m.e03 + this.e01 * m.e13 + this.e02 * m.e23 + this.e03 * m.e33;
  16083. var t10 = this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20 + this.e13 * m.e30;
  16084. var t11 = this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21 + this.e13 * m.e31;
  16085. var t12 = this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22 + this.e13 * m.e32;
  16086. var t13 = this.e10 * m.e03 + this.e11 * m.e13 + this.e12 * m.e23 + this.e13 * m.e33;
  16087. var t20 = this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20 + this.e23 * m.e30;
  16088. var t21 = this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21 + this.e23 * m.e31;
  16089. var t22 = this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22 + this.e23 * m.e32;
  16090. var t23 = this.e20 * m.e03 + this.e21 * m.e13 + this.e22 * m.e23 + this.e23 * m.e33;
  16091. var t30 = this.e30 * m.e00 + this.e31 * m.e10 + this.e32 * m.e20 + this.e33 * m.e30;
  16092. var t31 = this.e30 * m.e01 + this.e31 * m.e11 + this.e32 * m.e21 + this.e33 * m.e31;
  16093. var t32 = this.e30 * m.e02 + this.e31 * m.e12 + this.e32 * m.e22 + this.e33 * m.e32;
  16094. var t33 = this.e30 * m.e03 + this.e31 * m.e13 + this.e32 * m.e23 + this.e33 * m.e33;
  16095. this.e00 = t00;
  16096. this.e01 = t01;
  16097. this.e02 = t02;
  16098. this.e03 = t03;
  16099. this.e10 = t10;
  16100. this.e11 = t11;
  16101. this.e12 = t12;
  16102. this.e13 = t13;
  16103. this.e20 = t20;
  16104. this.e21 = t21;
  16105. this.e22 = t22;
  16106. this.e23 = t23;
  16107. this.e30 = t30;
  16108. this.e31 = t31;
  16109. this.e32 = t32;
  16110. this.e33 = t33;
  16111. return this;
  16112. }
  16113. prependScale(sx,sy,sz) {
  16114. return new oimo.common.Mat4(this.e00 * sx,this.e01 * sx,this.e02 * sx,this.e03 * sx,this.e10 * sy,this.e11 * sy,this.e12 * sy,this.e13 * sy,this.e20 * sz,this.e21 * sz,this.e22 * sz,this.e23 * sz,this.e30,this.e31,this.e32,this.e33);
  16115. }
  16116. appendScale(sx,sy,sz) {
  16117. return new oimo.common.Mat4(this.e00 * sx,this.e01 * sy,this.e02 * sz,this.e03,this.e10 * sx,this.e11 * sy,this.e12 * sz,this.e13,this.e20 * sx,this.e21 * sy,this.e22 * sz,this.e23,this.e30 * sx,this.e31 * sy,this.e32 * sz,this.e33);
  16118. }
  16119. prependRotation(rad,axisX,axisY,axisZ) {
  16120. var s = Math.sin(rad);
  16121. var c = Math.cos(rad);
  16122. var c1 = 1 - c;
  16123. var r00 = axisX * axisX * c1 + c;
  16124. var r01 = axisX * axisY * c1 - axisZ * s;
  16125. var r02 = axisX * axisZ * c1 + axisY * s;
  16126. var r10 = axisY * axisX * c1 + axisZ * s;
  16127. var r11 = axisY * axisY * c1 + c;
  16128. var r12 = axisY * axisZ * c1 - axisX * s;
  16129. var r20 = axisZ * axisX * c1 - axisY * s;
  16130. var r21 = axisZ * axisY * c1 + axisX * s;
  16131. var r22 = axisZ * axisZ * c1 + c;
  16132. return new oimo.common.Mat4(r00 * this.e00 + r01 * this.e10 + r02 * this.e20,r00 * this.e01 + r01 * this.e11 + r02 * this.e21,r00 * this.e02 + r01 * this.e12 + r02 * this.e22,r00 * this.e03 + r01 * this.e13 + r02 * this.e23,r10 * this.e00 + r11 * this.e10 + r12 * this.e20,r10 * this.e01 + r11 * this.e11 + r12 * this.e21,r10 * this.e02 + r11 * this.e12 + r12 * this.e22,r10 * this.e03 + r11 * this.e13 + r12 * this.e23,r20 * this.e00 + r21 * this.e10 + r22 * this.e20,r20 * this.e01 + r21 * this.e11 + r22 * this.e21,r20 * this.e02 + r21 * this.e12 + r22 * this.e22,r20 * this.e03 + r21 * this.e13 + r22 * this.e23,this.e30,this.e31,this.e32,this.e33);
  16133. }
  16134. appendRotation(rad,axisX,axisY,axisZ) {
  16135. var s = Math.sin(rad);
  16136. var c = Math.cos(rad);
  16137. var c1 = 1 - c;
  16138. var r00 = axisX * axisX * c1 + c;
  16139. var r01 = axisX * axisY * c1 - axisZ * s;
  16140. var r02 = axisX * axisZ * c1 + axisY * s;
  16141. var r10 = axisY * axisX * c1 + axisZ * s;
  16142. var r11 = axisY * axisY * c1 + c;
  16143. var r12 = axisY * axisZ * c1 - axisX * s;
  16144. var r20 = axisZ * axisX * c1 - axisY * s;
  16145. var r21 = axisZ * axisY * c1 + axisX * s;
  16146. var r22 = axisZ * axisZ * c1 + c;
  16147. return new oimo.common.Mat4(this.e00 * r00 + this.e01 * r10 + this.e02 * r20,this.e00 * r01 + this.e01 * r11 + this.e02 * r21,this.e00 * r02 + this.e01 * r12 + this.e02 * r22,this.e03,this.e10 * r00 + this.e11 * r10 + this.e12 * r20,this.e10 * r01 + this.e11 * r11 + this.e12 * r21,this.e10 * r02 + this.e11 * r12 + this.e12 * r22,this.e13,this.e20 * r00 + this.e21 * r10 + this.e22 * r20,this.e20 * r01 + this.e21 * r11 + this.e22 * r21,this.e20 * r02 + this.e21 * r12 + this.e22 * r22,this.e23,this.e30 * r00 + this.e31 * r10 + this.e32 * r20,this.e30 * r01 + this.e31 * r11 + this.e32 * r21,this.e30 * r02 + this.e31 * r12 + this.e32 * r22,this.e33);
  16148. }
  16149. prependTranslation(tx,ty,tz) {
  16150. return new oimo.common.Mat4(this.e00 + tx * this.e30,this.e01 + tx * this.e31,this.e02 + tx * this.e32,this.e03 + tx * this.e33,this.e10 + ty * this.e30,this.e11 + ty * this.e31,this.e12 + ty * this.e32,this.e13 + ty * this.e33,this.e20 + tz * this.e30,this.e21 + tz * this.e31,this.e22 + tz * this.e32,this.e23 + tz * this.e33,this.e30,this.e31,this.e32,this.e33);
  16151. }
  16152. appendTranslation(tx,ty,tz) {
  16153. return new oimo.common.Mat4(this.e00,this.e01,this.e02,this.e00 * tx + this.e01 * ty + this.e02 * tz + this.e03,this.e10,this.e11,this.e12,this.e10 * tx + this.e11 * ty + this.e12 * tz + this.e13,this.e20,this.e21,this.e22,this.e20 * tx + this.e21 * ty + this.e22 * tz + this.e23,this.e30,this.e31,this.e32,this.e30 * tx + this.e31 * ty + this.e32 * tz + this.e33);
  16154. }
  16155. prependScaleEq(sx,sy,sz) {
  16156. var t00 = this.e00 * sx;
  16157. var t01 = this.e01 * sx;
  16158. var t02 = this.e02 * sx;
  16159. var t03 = this.e03 * sx;
  16160. var t10 = this.e10 * sy;
  16161. var t11 = this.e11 * sy;
  16162. var t12 = this.e12 * sy;
  16163. var t13 = this.e13 * sy;
  16164. var t20 = this.e20 * sz;
  16165. var t21 = this.e21 * sz;
  16166. var t22 = this.e22 * sz;
  16167. var t23 = this.e23 * sz;
  16168. var t30 = this.e30;
  16169. var t31 = this.e31;
  16170. var t32 = this.e32;
  16171. var t33 = this.e33;
  16172. this.e00 = t00;
  16173. this.e01 = t01;
  16174. this.e02 = t02;
  16175. this.e03 = t03;
  16176. this.e10 = t10;
  16177. this.e11 = t11;
  16178. this.e12 = t12;
  16179. this.e13 = t13;
  16180. this.e20 = t20;
  16181. this.e21 = t21;
  16182. this.e22 = t22;
  16183. this.e23 = t23;
  16184. this.e30 = t30;
  16185. this.e31 = t31;
  16186. this.e32 = t32;
  16187. this.e33 = t33;
  16188. return this;
  16189. }
  16190. appendScaleEq(sx,sy,sz) {
  16191. var t00 = this.e00 * sx;
  16192. var t01 = this.e01 * sy;
  16193. var t02 = this.e02 * sz;
  16194. var t03 = this.e03;
  16195. var t10 = this.e10 * sx;
  16196. var t11 = this.e11 * sy;
  16197. var t12 = this.e12 * sz;
  16198. var t13 = this.e13;
  16199. var t20 = this.e20 * sx;
  16200. var t21 = this.e21 * sy;
  16201. var t22 = this.e22 * sz;
  16202. var t23 = this.e23;
  16203. var t30 = this.e30 * sx;
  16204. var t31 = this.e31 * sy;
  16205. var t32 = this.e32 * sz;
  16206. var t33 = this.e33;
  16207. this.e00 = t00;
  16208. this.e01 = t01;
  16209. this.e02 = t02;
  16210. this.e03 = t03;
  16211. this.e10 = t10;
  16212. this.e11 = t11;
  16213. this.e12 = t12;
  16214. this.e13 = t13;
  16215. this.e20 = t20;
  16216. this.e21 = t21;
  16217. this.e22 = t22;
  16218. this.e23 = t23;
  16219. this.e30 = t30;
  16220. this.e31 = t31;
  16221. this.e32 = t32;
  16222. this.e33 = t33;
  16223. return this;
  16224. }
  16225. prependRotationEq(rad,axisX,axisY,axisZ) {
  16226. var s = Math.sin(rad);
  16227. var c = Math.cos(rad);
  16228. var c1 = 1 - c;
  16229. var r00 = axisX * axisX * c1 + c;
  16230. var r01 = axisX * axisY * c1 - axisZ * s;
  16231. var r02 = axisX * axisZ * c1 + axisY * s;
  16232. var r10 = axisY * axisX * c1 + axisZ * s;
  16233. var r11 = axisY * axisY * c1 + c;
  16234. var r12 = axisY * axisZ * c1 - axisX * s;
  16235. var r20 = axisZ * axisX * c1 - axisY * s;
  16236. var r21 = axisZ * axisY * c1 + axisX * s;
  16237. var r22 = axisZ * axisZ * c1 + c;
  16238. var t00 = r00 * this.e00 + r01 * this.e10 + r02 * this.e20;
  16239. var t01 = r00 * this.e01 + r01 * this.e11 + r02 * this.e21;
  16240. var t02 = r00 * this.e02 + r01 * this.e12 + r02 * this.e22;
  16241. var t03 = r00 * this.e03 + r01 * this.e13 + r02 * this.e23;
  16242. var t10 = r10 * this.e00 + r11 * this.e10 + r12 * this.e20;
  16243. var t11 = r10 * this.e01 + r11 * this.e11 + r12 * this.e21;
  16244. var t12 = r10 * this.e02 + r11 * this.e12 + r12 * this.e22;
  16245. var t13 = r10 * this.e03 + r11 * this.e13 + r12 * this.e23;
  16246. var t20 = r20 * this.e00 + r21 * this.e10 + r22 * this.e20;
  16247. var t21 = r20 * this.e01 + r21 * this.e11 + r22 * this.e21;
  16248. var t22 = r20 * this.e02 + r21 * this.e12 + r22 * this.e22;
  16249. var t23 = r20 * this.e03 + r21 * this.e13 + r22 * this.e23;
  16250. var t30 = this.e30;
  16251. var t31 = this.e31;
  16252. var t32 = this.e32;
  16253. var t33 = this.e33;
  16254. this.e00 = t00;
  16255. this.e01 = t01;
  16256. this.e02 = t02;
  16257. this.e03 = t03;
  16258. this.e10 = t10;
  16259. this.e11 = t11;
  16260. this.e12 = t12;
  16261. this.e13 = t13;
  16262. this.e20 = t20;
  16263. this.e21 = t21;
  16264. this.e22 = t22;
  16265. this.e23 = t23;
  16266. this.e30 = t30;
  16267. this.e31 = t31;
  16268. this.e32 = t32;
  16269. this.e33 = t33;
  16270. return this;
  16271. }
  16272. appendRotationEq(rad,axisX,axisY,axisZ) {
  16273. var s = Math.sin(rad);
  16274. var c = Math.cos(rad);
  16275. var c1 = 1 - c;
  16276. var r00 = axisX * axisX * c1 + c;
  16277. var r01 = axisX * axisY * c1 - axisZ * s;
  16278. var r02 = axisX * axisZ * c1 + axisY * s;
  16279. var r10 = axisY * axisX * c1 + axisZ * s;
  16280. var r11 = axisY * axisY * c1 + c;
  16281. var r12 = axisY * axisZ * c1 - axisX * s;
  16282. var r20 = axisZ * axisX * c1 - axisY * s;
  16283. var r21 = axisZ * axisY * c1 + axisX * s;
  16284. var r22 = axisZ * axisZ * c1 + c;
  16285. var t00 = this.e00 * r00 + this.e01 * r10 + this.e02 * r20;
  16286. var t01 = this.e00 * r01 + this.e01 * r11 + this.e02 * r21;
  16287. var t02 = this.e00 * r02 + this.e01 * r12 + this.e02 * r22;
  16288. var t03 = this.e03;
  16289. var t10 = this.e10 * r00 + this.e11 * r10 + this.e12 * r20;
  16290. var t11 = this.e10 * r01 + this.e11 * r11 + this.e12 * r21;
  16291. var t12 = this.e10 * r02 + this.e11 * r12 + this.e12 * r22;
  16292. var t13 = this.e13;
  16293. var t20 = this.e20 * r00 + this.e21 * r10 + this.e22 * r20;
  16294. var t21 = this.e20 * r01 + this.e21 * r11 + this.e22 * r21;
  16295. var t22 = this.e20 * r02 + this.e21 * r12 + this.e22 * r22;
  16296. var t23 = this.e23;
  16297. var t30 = this.e30 * r00 + this.e31 * r10 + this.e32 * r20;
  16298. var t31 = this.e30 * r01 + this.e31 * r11 + this.e32 * r21;
  16299. var t32 = this.e30 * r02 + this.e31 * r12 + this.e32 * r22;
  16300. var t33 = this.e33;
  16301. this.e00 = t00;
  16302. this.e01 = t01;
  16303. this.e02 = t02;
  16304. this.e03 = t03;
  16305. this.e10 = t10;
  16306. this.e11 = t11;
  16307. this.e12 = t12;
  16308. this.e13 = t13;
  16309. this.e20 = t20;
  16310. this.e21 = t21;
  16311. this.e22 = t22;
  16312. this.e23 = t23;
  16313. this.e30 = t30;
  16314. this.e31 = t31;
  16315. this.e32 = t32;
  16316. this.e33 = t33;
  16317. return this;
  16318. }
  16319. prependTranslationEq(tx,ty,tz) {
  16320. var t00 = this.e00 + tx * this.e30;
  16321. var t01 = this.e01 + tx * this.e31;
  16322. var t02 = this.e02 + tx * this.e32;
  16323. var t03 = this.e03 + tx * this.e33;
  16324. var t10 = this.e10 + ty * this.e30;
  16325. var t11 = this.e11 + ty * this.e31;
  16326. var t12 = this.e12 + ty * this.e32;
  16327. var t13 = this.e13 + ty * this.e33;
  16328. var t20 = this.e20 + tz * this.e30;
  16329. var t21 = this.e21 + tz * this.e31;
  16330. var t22 = this.e22 + tz * this.e32;
  16331. var t23 = this.e23 + tz * this.e33;
  16332. var t30 = this.e30;
  16333. var t31 = this.e31;
  16334. var t32 = this.e32;
  16335. var t33 = this.e33;
  16336. this.e00 = t00;
  16337. this.e01 = t01;
  16338. this.e02 = t02;
  16339. this.e03 = t03;
  16340. this.e10 = t10;
  16341. this.e11 = t11;
  16342. this.e12 = t12;
  16343. this.e13 = t13;
  16344. this.e20 = t20;
  16345. this.e21 = t21;
  16346. this.e22 = t22;
  16347. this.e23 = t23;
  16348. this.e30 = t30;
  16349. this.e31 = t31;
  16350. this.e32 = t32;
  16351. this.e33 = t33;
  16352. return this;
  16353. }
  16354. appendTranslationEq(tx,ty,tz) {
  16355. var t00 = this.e00;
  16356. var t01 = this.e01;
  16357. var t02 = this.e02;
  16358. var t03 = this.e00 * tx + this.e01 * ty + this.e02 * tz + this.e03;
  16359. var t10 = this.e10;
  16360. var t11 = this.e11;
  16361. var t12 = this.e12;
  16362. var t13 = this.e10 * tx + this.e11 * ty + this.e12 * tz + this.e13;
  16363. var t20 = this.e20;
  16364. var t21 = this.e21;
  16365. var t22 = this.e22;
  16366. var t23 = this.e20 * tx + this.e21 * ty + this.e22 * tz + this.e23;
  16367. var t30 = this.e30;
  16368. var t31 = this.e31;
  16369. var t32 = this.e32;
  16370. var t33 = this.e30 * tx + this.e31 * ty + this.e32 * tz + this.e33;
  16371. this.e00 = t00;
  16372. this.e01 = t01;
  16373. this.e02 = t02;
  16374. this.e03 = t03;
  16375. this.e10 = t10;
  16376. this.e11 = t11;
  16377. this.e12 = t12;
  16378. this.e13 = t13;
  16379. this.e20 = t20;
  16380. this.e21 = t21;
  16381. this.e22 = t22;
  16382. this.e23 = t23;
  16383. this.e30 = t30;
  16384. this.e31 = t31;
  16385. this.e32 = t32;
  16386. this.e33 = t33;
  16387. return this;
  16388. }
  16389. transpose() {
  16390. return new oimo.common.Mat4(this.e00,this.e10,this.e20,this.e30,this.e01,this.e11,this.e21,this.e31,this.e02,this.e12,this.e22,this.e32,this.e03,this.e13,this.e23,this.e33);
  16391. }
  16392. transposeEq() {
  16393. var t00 = this.e00;
  16394. var t01 = this.e10;
  16395. var t02 = this.e20;
  16396. var t03 = this.e30;
  16397. var t10 = this.e01;
  16398. var t11 = this.e11;
  16399. var t12 = this.e21;
  16400. var t13 = this.e31;
  16401. var t20 = this.e02;
  16402. var t21 = this.e12;
  16403. var t22 = this.e22;
  16404. var t23 = this.e32;
  16405. var t30 = this.e03;
  16406. var t31 = this.e13;
  16407. var t32 = this.e23;
  16408. var t33 = this.e33;
  16409. this.e00 = t00;
  16410. this.e01 = t01;
  16411. this.e02 = t02;
  16412. this.e03 = t03;
  16413. this.e10 = t10;
  16414. this.e11 = t11;
  16415. this.e12 = t12;
  16416. this.e13 = t13;
  16417. this.e20 = t20;
  16418. this.e21 = t21;
  16419. this.e22 = t22;
  16420. this.e23 = t23;
  16421. this.e30 = t30;
  16422. this.e31 = t31;
  16423. this.e32 = t32;
  16424. this.e33 = t33;
  16425. return this;
  16426. }
  16427. determinant() {
  16428. var d23_01 = this.e20 * this.e31 - this.e21 * this.e30;
  16429. var d23_02 = this.e20 * this.e32 - this.e22 * this.e30;
  16430. var d23_03 = this.e20 * this.e33 - this.e23 * this.e30;
  16431. var d23_12 = this.e21 * this.e32 - this.e22 * this.e31;
  16432. var d23_13 = this.e21 * this.e33 - this.e23 * this.e31;
  16433. var d23_23 = this.e22 * this.e33 - this.e23 * this.e32;
  16434. return this.e00 * (this.e11 * d23_23 - this.e12 * d23_13 + this.e13 * d23_12) - this.e01 * (this.e10 * d23_23 - this.e12 * d23_03 + this.e13 * d23_02) + this.e02 * (this.e10 * d23_13 - this.e11 * d23_03 + this.e13 * d23_01) - this.e03 * (this.e10 * d23_12 - this.e11 * d23_02 + this.e12 * d23_01);
  16435. }
  16436. trace() {
  16437. return this.e00 + this.e11 + this.e22 + this.e33;
  16438. }
  16439. inverse() {
  16440. var d01_01 = this.e00 * this.e11 - this.e01 * this.e10;
  16441. var d01_02 = this.e00 * this.e12 - this.e02 * this.e10;
  16442. var d01_03 = this.e00 * this.e13 - this.e03 * this.e10;
  16443. var d01_12 = this.e01 * this.e12 - this.e02 * this.e11;
  16444. var d01_13 = this.e01 * this.e13 - this.e03 * this.e11;
  16445. var d01_23 = this.e02 * this.e13 - this.e03 * this.e12;
  16446. var d23_01 = this.e20 * this.e31 - this.e21 * this.e30;
  16447. var d23_02 = this.e20 * this.e32 - this.e22 * this.e30;
  16448. var d23_03 = this.e20 * this.e33 - this.e23 * this.e30;
  16449. var d23_12 = this.e21 * this.e32 - this.e22 * this.e31;
  16450. var d23_13 = this.e21 * this.e33 - this.e23 * this.e31;
  16451. var d23_23 = this.e22 * this.e33 - this.e23 * this.e32;
  16452. var d00 = this.e11 * d23_23 - this.e12 * d23_13 + this.e13 * d23_12;
  16453. var d01 = this.e10 * d23_23 - this.e12 * d23_03 + this.e13 * d23_02;
  16454. var d02 = this.e10 * d23_13 - this.e11 * d23_03 + this.e13 * d23_01;
  16455. var d03 = this.e10 * d23_12 - this.e11 * d23_02 + this.e12 * d23_01;
  16456. var d10 = this.e01 * d23_23 - this.e02 * d23_13 + this.e03 * d23_12;
  16457. var d11 = this.e00 * d23_23 - this.e02 * d23_03 + this.e03 * d23_02;
  16458. var d12 = this.e00 * d23_13 - this.e01 * d23_03 + this.e03 * d23_01;
  16459. var d13 = this.e00 * d23_12 - this.e01 * d23_02 + this.e02 * d23_01;
  16460. var d20 = this.e31 * d01_23 - this.e32 * d01_13 + this.e33 * d01_12;
  16461. var d21 = this.e30 * d01_23 - this.e32 * d01_03 + this.e33 * d01_02;
  16462. var d22 = this.e30 * d01_13 - this.e31 * d01_03 + this.e33 * d01_01;
  16463. var d23 = this.e30 * d01_12 - this.e31 * d01_02 + this.e32 * d01_01;
  16464. var d30 = this.e21 * d01_23 - this.e22 * d01_13 + this.e23 * d01_12;
  16465. var d31 = this.e20 * d01_23 - this.e22 * d01_03 + this.e23 * d01_02;
  16466. var d32 = this.e20 * d01_13 - this.e21 * d01_03 + this.e23 * d01_01;
  16467. var d33 = this.e20 * d01_12 - this.e21 * d01_02 + this.e22 * d01_01;
  16468. var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02 - this.e03 * d03;
  16469. if(invDet != 0) {
  16470. invDet = 1 / invDet;
  16471. }
  16472. return new oimo.common.Mat4(d00 * invDet,-d10 * invDet,d20 * invDet,-d30 * invDet,-d01 * invDet,d11 * invDet,-d21 * invDet,d31 * invDet,d02 * invDet,-d12 * invDet,d22 * invDet,-d32 * invDet,-d03 * invDet,d13 * invDet,-d23 * invDet,d33 * invDet);
  16473. }
  16474. inverseEq() {
  16475. var d01_01 = this.e00 * this.e11 - this.e01 * this.e10;
  16476. var d01_02 = this.e00 * this.e12 - this.e02 * this.e10;
  16477. var d01_03 = this.e00 * this.e13 - this.e03 * this.e10;
  16478. var d01_12 = this.e01 * this.e12 - this.e02 * this.e11;
  16479. var d01_13 = this.e01 * this.e13 - this.e03 * this.e11;
  16480. var d01_23 = this.e02 * this.e13 - this.e03 * this.e12;
  16481. var d23_01 = this.e20 * this.e31 - this.e21 * this.e30;
  16482. var d23_02 = this.e20 * this.e32 - this.e22 * this.e30;
  16483. var d23_03 = this.e20 * this.e33 - this.e23 * this.e30;
  16484. var d23_12 = this.e21 * this.e32 - this.e22 * this.e31;
  16485. var d23_13 = this.e21 * this.e33 - this.e23 * this.e31;
  16486. var d23_23 = this.e22 * this.e33 - this.e23 * this.e32;
  16487. var d00 = this.e11 * d23_23 - this.e12 * d23_13 + this.e13 * d23_12;
  16488. var d01 = this.e10 * d23_23 - this.e12 * d23_03 + this.e13 * d23_02;
  16489. var d02 = this.e10 * d23_13 - this.e11 * d23_03 + this.e13 * d23_01;
  16490. var d03 = this.e10 * d23_12 - this.e11 * d23_02 + this.e12 * d23_01;
  16491. var d10 = this.e01 * d23_23 - this.e02 * d23_13 + this.e03 * d23_12;
  16492. var d11 = this.e00 * d23_23 - this.e02 * d23_03 + this.e03 * d23_02;
  16493. var d12 = this.e00 * d23_13 - this.e01 * d23_03 + this.e03 * d23_01;
  16494. var d13 = this.e00 * d23_12 - this.e01 * d23_02 + this.e02 * d23_01;
  16495. var d20 = this.e31 * d01_23 - this.e32 * d01_13 + this.e33 * d01_12;
  16496. var d21 = this.e30 * d01_23 - this.e32 * d01_03 + this.e33 * d01_02;
  16497. var d22 = this.e30 * d01_13 - this.e31 * d01_03 + this.e33 * d01_01;
  16498. var d23 = this.e30 * d01_12 - this.e31 * d01_02 + this.e32 * d01_01;
  16499. var d30 = this.e21 * d01_23 - this.e22 * d01_13 + this.e23 * d01_12;
  16500. var d31 = this.e20 * d01_23 - this.e22 * d01_03 + this.e23 * d01_02;
  16501. var d32 = this.e20 * d01_13 - this.e21 * d01_03 + this.e23 * d01_01;
  16502. var d33 = this.e20 * d01_12 - this.e21 * d01_02 + this.e22 * d01_01;
  16503. var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02 - this.e03 * d03;
  16504. if(invDet != 0) {
  16505. invDet = 1 / invDet;
  16506. }
  16507. var t00 = d00 * invDet;
  16508. var t01 = -d10 * invDet;
  16509. var t02 = d20 * invDet;
  16510. var t03 = -d30 * invDet;
  16511. var t10 = -d01 * invDet;
  16512. var t11 = d11 * invDet;
  16513. var t12 = -d21 * invDet;
  16514. var t13 = d31 * invDet;
  16515. var t20 = d02 * invDet;
  16516. var t21 = -d12 * invDet;
  16517. var t22 = d22 * invDet;
  16518. var t23 = -d32 * invDet;
  16519. var t30 = -d03 * invDet;
  16520. var t31 = d13 * invDet;
  16521. var t32 = -d23 * invDet;
  16522. var t33 = d33 * invDet;
  16523. this.e00 = t00;
  16524. this.e01 = t01;
  16525. this.e02 = t02;
  16526. this.e03 = t03;
  16527. this.e10 = t10;
  16528. this.e11 = t11;
  16529. this.e12 = t12;
  16530. this.e13 = t13;
  16531. this.e20 = t20;
  16532. this.e21 = t21;
  16533. this.e22 = t22;
  16534. this.e23 = t23;
  16535. this.e30 = t30;
  16536. this.e31 = t31;
  16537. this.e32 = t32;
  16538. this.e33 = t33;
  16539. return this;
  16540. }
  16541. lookAt(eyeX,eyeY,eyeZ,atX,atY,atZ,upX,upY,upZ) {
  16542. var zx = eyeX - atX;
  16543. var zy = eyeY - atY;
  16544. var zz = eyeZ - atZ;
  16545. var tmp = 1 / Math.sqrt(zx * zx + zy * zy + zz * zz);
  16546. zx *= tmp;
  16547. zy *= tmp;
  16548. zz *= tmp;
  16549. var xx = upY * zz - upZ * zy;
  16550. var xy = upZ * zx - upX * zz;
  16551. var xz = upX * zy - upY * zx;
  16552. tmp = 1 / Math.sqrt(xx * xx + xy * xy + xz * xz);
  16553. xx *= tmp;
  16554. xy *= tmp;
  16555. xz *= tmp;
  16556. var yx = zy * xz - zz * xy;
  16557. var yy = zz * xx - zx * xz;
  16558. var yz = zx * xy - zy * xx;
  16559. this.e00 = xx;
  16560. this.e01 = xy;
  16561. this.e02 = xz;
  16562. this.e03 = -(xx * eyeX + xy * eyeY + xz * eyeZ);
  16563. this.e10 = yx;
  16564. this.e11 = yy;
  16565. this.e12 = yz;
  16566. this.e13 = -(yx * eyeX + yy * eyeY + yz * eyeZ);
  16567. this.e20 = zx;
  16568. this.e21 = zy;
  16569. this.e22 = zz;
  16570. this.e23 = -(zx * eyeX + zy * eyeY + zz * eyeZ);
  16571. this.e30 = 0;
  16572. this.e31 = 0;
  16573. this.e32 = 0;
  16574. this.e33 = 1;
  16575. return this;
  16576. }
  16577. perspective(fovY,aspect,near,far) {
  16578. var h = 1 / Math.tan(fovY * 0.5);
  16579. var fnf = far / (near - far);
  16580. this.e00 = h / aspect;
  16581. this.e01 = 0;
  16582. this.e02 = 0;
  16583. this.e03 = 0;
  16584. this.e10 = 0;
  16585. this.e11 = h;
  16586. this.e12 = 0;
  16587. this.e13 = 0;
  16588. this.e20 = 0;
  16589. this.e21 = 0;
  16590. this.e22 = fnf;
  16591. this.e23 = near * fnf;
  16592. this.e30 = 0;
  16593. this.e31 = 0;
  16594. this.e32 = -1;
  16595. this.e33 = 0;
  16596. return this;
  16597. }
  16598. ortho(width,height,near,far) {
  16599. var nf = 1 / (near - far);
  16600. this.e00 = 2 / width;
  16601. this.e01 = 0;
  16602. this.e02 = 0;
  16603. this.e03 = 0;
  16604. this.e10 = 0;
  16605. this.e11 = 2 / height;
  16606. this.e12 = 0;
  16607. this.e13 = 0;
  16608. this.e20 = 0;
  16609. this.e21 = 0;
  16610. this.e22 = nf;
  16611. this.e23 = near * nf;
  16612. this.e30 = 0;
  16613. this.e31 = 0;
  16614. this.e32 = 0;
  16615. this.e33 = 1;
  16616. return this;
  16617. }
  16618. toArray(columnMajor) {
  16619. if(columnMajor == null) {
  16620. columnMajor = false;
  16621. }
  16622. if(columnMajor) {
  16623. return [this.e00,this.e10,this.e20,this.e30,this.e01,this.e11,this.e21,this.e31,this.e02,this.e12,this.e22,this.e32,this.e03,this.e13,this.e23,this.e33];
  16624. } else {
  16625. return [this.e00,this.e01,this.e02,this.e03,this.e10,this.e11,this.e12,this.e13,this.e20,this.e21,this.e22,this.e23,this.e30,this.e31,this.e32,this.e33];
  16626. }
  16627. }
  16628. copyFrom(m) {
  16629. this.e00 = m.e00;
  16630. this.e01 = m.e01;
  16631. this.e02 = m.e02;
  16632. this.e03 = m.e03;
  16633. this.e10 = m.e10;
  16634. this.e11 = m.e11;
  16635. this.e12 = m.e12;
  16636. this.e13 = m.e13;
  16637. this.e20 = m.e20;
  16638. this.e21 = m.e21;
  16639. this.e22 = m.e22;
  16640. this.e23 = m.e23;
  16641. this.e30 = m.e30;
  16642. this.e31 = m.e31;
  16643. this.e32 = m.e32;
  16644. this.e33 = m.e33;
  16645. return this;
  16646. }
  16647. fromMat3(m) {
  16648. var t00 = m.e00;
  16649. var t01 = m.e01;
  16650. var t02 = m.e02;
  16651. var t03 = 0;
  16652. var t10 = m.e10;
  16653. var t11 = m.e11;
  16654. var t12 = m.e12;
  16655. var t13 = 0;
  16656. var t20 = m.e20;
  16657. var t21 = m.e21;
  16658. var t22 = m.e22;
  16659. var t23 = 0;
  16660. var t30 = 0;
  16661. var t31 = 0;
  16662. var t32 = 0;
  16663. var t33 = 1;
  16664. this.e00 = t00;
  16665. this.e01 = t01;
  16666. this.e02 = t02;
  16667. this.e03 = t03;
  16668. this.e10 = t10;
  16669. this.e11 = t11;
  16670. this.e12 = t12;
  16671. this.e13 = t13;
  16672. this.e20 = t20;
  16673. this.e21 = t21;
  16674. this.e22 = t22;
  16675. this.e23 = t23;
  16676. this.e30 = t30;
  16677. this.e31 = t31;
  16678. this.e32 = t32;
  16679. this.e33 = t33;
  16680. return this;
  16681. }
  16682. fromTransform(transform) {
  16683. var m = this;
  16684. m.e00 = transform._rotation00;
  16685. m.e01 = transform._rotation01;
  16686. m.e02 = transform._rotation02;
  16687. m.e10 = transform._rotation10;
  16688. m.e11 = transform._rotation11;
  16689. m.e12 = transform._rotation12;
  16690. m.e20 = transform._rotation20;
  16691. m.e21 = transform._rotation21;
  16692. m.e22 = transform._rotation22;
  16693. m.e03 = transform._positionX;
  16694. m.e13 = transform._positionY;
  16695. m.e23 = transform._positionZ;
  16696. m.e30 = 0;
  16697. m.e31 = 0;
  16698. m.e32 = 0;
  16699. m.e33 = 1;
  16700. return this;
  16701. }
  16702. clone() {
  16703. return new oimo.common.Mat4(this.e00,this.e01,this.e02,this.e03,this.e10,this.e11,this.e12,this.e13,this.e20,this.e21,this.e22,this.e23,this.e30,this.e31,this.e32,this.e33);
  16704. }
  16705. toString() {
  16706. return "Mat4[" + (this.e00 > 0 ? (this.e00 * 10000000 + 0.5 | 0) / 10000000 : (this.e00 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e01 > 0 ? (this.e01 * 10000000 + 0.5 | 0) / 10000000 : (this.e01 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e02 > 0 ? (this.e02 * 10000000 + 0.5 | 0) / 10000000 : (this.e02 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e03 > 0 ? (this.e03 * 10000000 + 0.5 | 0) / 10000000 : (this.e03 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e10 > 0 ? (this.e10 * 10000000 + 0.5 | 0) / 10000000 : (this.e10 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e11 > 0 ? (this.e11 * 10000000 + 0.5 | 0) / 10000000 : (this.e11 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e12 > 0 ? (this.e12 * 10000000 + 0.5 | 0) / 10000000 : (this.e12 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e13 > 0 ? (this.e13 * 10000000 + 0.5 | 0) / 10000000 : (this.e13 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e20 > 0 ? (this.e20 * 10000000 + 0.5 | 0) / 10000000 : (this.e20 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e21 > 0 ? (this.e21 * 10000000 + 0.5 | 0) / 10000000 : (this.e21 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e22 > 0 ? (this.e22 * 10000000 + 0.5 | 0) / 10000000 : (this.e22 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e23 > 0 ? (this.e23 * 10000000 + 0.5 | 0) / 10000000 : (this.e23 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e30 > 0 ? (this.e30 * 10000000 + 0.5 | 0) / 10000000 : (this.e30 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e31 > 0 ? (this.e31 * 10000000 + 0.5 | 0) / 10000000 : (this.e31 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e32 > 0 ? (this.e32 * 10000000 + 0.5 | 0) / 10000000 : (this.e32 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e33 > 0 ? (this.e33 * 10000000 + 0.5 | 0) / 10000000 : (this.e33 * 10000000 - 0.5 | 0) / 10000000) + "]";
  16707. }
  16708. }
  16709. oimo.common.MathUtil = class oimo_common_MathUtil {
  16710. static abs(x) {
  16711. if(x > 0) {
  16712. return x;
  16713. } else {
  16714. return -x;
  16715. }
  16716. }
  16717. static sin(x) {
  16718. return Math.sin(x);
  16719. }
  16720. static cos(x) {
  16721. return Math.cos(x);
  16722. }
  16723. static tan(x) {
  16724. return Math.tan(x);
  16725. }
  16726. static asin(x) {
  16727. return Math.asin(x);
  16728. }
  16729. static acos(x) {
  16730. return Math.acos(x);
  16731. }
  16732. static atan(x) {
  16733. return Math.atan(x);
  16734. }
  16735. static safeAsin(x) {
  16736. if(x <= -1) {
  16737. return -1.570796326794895;
  16738. }
  16739. if(x >= 1) {
  16740. return 1.570796326794895;
  16741. }
  16742. return Math.asin(x);
  16743. }
  16744. static safeAcos(x) {
  16745. if(x <= -1) {
  16746. return 3.14159265358979;
  16747. }
  16748. if(x >= 1) {
  16749. return 0;
  16750. }
  16751. return Math.acos(x);
  16752. }
  16753. static atan2(y,x) {
  16754. return Math.atan2(y,x);
  16755. }
  16756. static sqrt(x) {
  16757. return Math.sqrt(x);
  16758. }
  16759. static clamp(x,min,max) {
  16760. if(x < min) {
  16761. return min;
  16762. } else if(x > max) {
  16763. return max;
  16764. } else {
  16765. return x;
  16766. }
  16767. }
  16768. static rand() {
  16769. return Math.random();
  16770. }
  16771. static randIn(min,max) {
  16772. return min + Math.random() * (max - min);
  16773. }
  16774. static randVec3In(min,max) {
  16775. return new oimo.common.Vec3(min + Math.random() * (max - min),min + Math.random() * (max - min),min + Math.random() * (max - min));
  16776. }
  16777. static randVec3() {
  16778. return new oimo.common.Vec3(-1 + Math.random() * 2,-1 + Math.random() * 2,-1 + Math.random() * 2);
  16779. }
  16780. }
  16781. oimo.common.Pool = class oimo_common_Pool {
  16782. constructor() {
  16783. var this1 = new Array(256);
  16784. this.stackVec3 = this1;
  16785. this.sizeVec3 = 0;
  16786. var this2 = new Array(256);
  16787. this.stackMat3 = this2;
  16788. this.sizeMat3 = 0;
  16789. var this3 = new Array(256);
  16790. this.stackMat4 = this3;
  16791. this.sizeMat4 = 0;
  16792. var this4 = new Array(256);
  16793. this.stackQuat = this4;
  16794. this.sizeQuat = 0;
  16795. }
  16796. vec3() {
  16797. if(this.sizeVec3 == 0) {
  16798. return new oimo.common.Vec3();
  16799. } else {
  16800. return this.stackVec3[--this.sizeVec3];
  16801. }
  16802. }
  16803. mat3() {
  16804. if(this.sizeMat3 == 0) {
  16805. return new oimo.common.Mat3();
  16806. } else {
  16807. return this.stackMat3[--this.sizeMat3];
  16808. }
  16809. }
  16810. mat4() {
  16811. if(this.sizeMat4 == 0) {
  16812. return new oimo.common.Mat4();
  16813. } else {
  16814. return this.stackMat4[--this.sizeMat4];
  16815. }
  16816. }
  16817. quat() {
  16818. if(this.sizeQuat == 0) {
  16819. return new oimo.common.Quat();
  16820. } else {
  16821. return this.stackQuat[--this.sizeQuat];
  16822. }
  16823. }
  16824. dispose(vec3,mat3,mat4,quat) {
  16825. if(vec3 != null) {
  16826. vec3.zero();
  16827. if(this.sizeVec3 == this.stackVec3.length) {
  16828. var newLength = this.sizeVec3 << 1;
  16829. var this1 = new Array(newLength);
  16830. var newArray = this1;
  16831. var _g = 0;
  16832. var _g1 = this.sizeVec3;
  16833. while(_g < _g1) {
  16834. var i = _g++;
  16835. newArray[i] = this.stackVec3[i];
  16836. this.stackVec3[i] = null;
  16837. }
  16838. this.stackVec3 = newArray;
  16839. }
  16840. this.stackVec3[this.sizeVec3++] = vec3;
  16841. }
  16842. if(mat3 != null) {
  16843. var t00 = 1;
  16844. var t01 = 0;
  16845. var t02 = 0;
  16846. var t10 = 0;
  16847. var t11 = 1;
  16848. var t12 = 0;
  16849. var t20 = 0;
  16850. var t21 = 0;
  16851. var t22 = 1;
  16852. mat3.e00 = t00;
  16853. mat3.e01 = t01;
  16854. mat3.e02 = t02;
  16855. mat3.e10 = t10;
  16856. mat3.e11 = t11;
  16857. mat3.e12 = t12;
  16858. mat3.e20 = t20;
  16859. mat3.e21 = t21;
  16860. mat3.e22 = t22;
  16861. if(this.sizeMat3 == this.stackMat3.length) {
  16862. var newLength1 = this.sizeMat3 << 1;
  16863. var this2 = new Array(newLength1);
  16864. var newArray1 = this2;
  16865. var _g2 = 0;
  16866. var _g11 = this.sizeMat3;
  16867. while(_g2 < _g11) {
  16868. var i1 = _g2++;
  16869. newArray1[i1] = this.stackMat3[i1];
  16870. this.stackMat3[i1] = null;
  16871. }
  16872. this.stackMat3 = newArray1;
  16873. }
  16874. this.stackMat3[this.sizeMat3++] = mat3;
  16875. }
  16876. if(mat4 != null) {
  16877. var t001 = 1;
  16878. var t011 = 0;
  16879. var t021 = 0;
  16880. var t03 = 0;
  16881. var t101 = 0;
  16882. var t111 = 1;
  16883. var t121 = 0;
  16884. var t13 = 0;
  16885. var t201 = 0;
  16886. var t211 = 0;
  16887. var t221 = 1;
  16888. var t23 = 0;
  16889. var t30 = 0;
  16890. var t31 = 0;
  16891. var t32 = 0;
  16892. var t33 = 1;
  16893. mat4.e00 = t001;
  16894. mat4.e01 = t011;
  16895. mat4.e02 = t021;
  16896. mat4.e03 = t03;
  16897. mat4.e10 = t101;
  16898. mat4.e11 = t111;
  16899. mat4.e12 = t121;
  16900. mat4.e13 = t13;
  16901. mat4.e20 = t201;
  16902. mat4.e21 = t211;
  16903. mat4.e22 = t221;
  16904. mat4.e23 = t23;
  16905. mat4.e30 = t30;
  16906. mat4.e31 = t31;
  16907. mat4.e32 = t32;
  16908. mat4.e33 = t33;
  16909. if(this.sizeMat4 == this.stackMat4.length) {
  16910. var newLength2 = this.sizeMat4 << 1;
  16911. var this3 = new Array(newLength2);
  16912. var newArray2 = this3;
  16913. var _g3 = 0;
  16914. var _g12 = this.sizeMat4;
  16915. while(_g3 < _g12) {
  16916. var i2 = _g3++;
  16917. newArray2[i2] = this.stackMat4[i2];
  16918. this.stackMat4[i2] = null;
  16919. }
  16920. this.stackMat4 = newArray2;
  16921. }
  16922. this.stackMat4[this.sizeMat4++] = mat4;
  16923. }
  16924. if(quat != null) {
  16925. var tx = 0;
  16926. var ty = 0;
  16927. var tz = 0;
  16928. var tw = 1;
  16929. quat.x = tx;
  16930. quat.y = ty;
  16931. quat.z = tz;
  16932. quat.w = tw;
  16933. if(this.sizeQuat == this.stackQuat.length) {
  16934. var newLength3 = this.sizeQuat << 1;
  16935. var this4 = new Array(newLength3);
  16936. var newArray3 = this4;
  16937. var _g4 = 0;
  16938. var _g13 = this.sizeQuat;
  16939. while(_g4 < _g13) {
  16940. var i3 = _g4++;
  16941. newArray3[i3] = this.stackQuat[i3];
  16942. this.stackQuat[i3] = null;
  16943. }
  16944. this.stackQuat = newArray3;
  16945. }
  16946. this.stackQuat[this.sizeQuat++] = quat;
  16947. }
  16948. }
  16949. disposeVec3(v) {
  16950. v.zero();
  16951. if(this.sizeVec3 == this.stackVec3.length) {
  16952. var newLength = this.sizeVec3 << 1;
  16953. var this1 = new Array(newLength);
  16954. var newArray = this1;
  16955. var _g = 0;
  16956. var _g1 = this.sizeVec3;
  16957. while(_g < _g1) {
  16958. var i = _g++;
  16959. newArray[i] = this.stackVec3[i];
  16960. this.stackVec3[i] = null;
  16961. }
  16962. this.stackVec3 = newArray;
  16963. }
  16964. this.stackVec3[this.sizeVec3++] = v;
  16965. }
  16966. disposeMat3(m) {
  16967. var t00 = 1;
  16968. var t01 = 0;
  16969. var t02 = 0;
  16970. var t10 = 0;
  16971. var t11 = 1;
  16972. var t12 = 0;
  16973. var t20 = 0;
  16974. var t21 = 0;
  16975. var t22 = 1;
  16976. m.e00 = t00;
  16977. m.e01 = t01;
  16978. m.e02 = t02;
  16979. m.e10 = t10;
  16980. m.e11 = t11;
  16981. m.e12 = t12;
  16982. m.e20 = t20;
  16983. m.e21 = t21;
  16984. m.e22 = t22;
  16985. if(this.sizeMat3 == this.stackMat3.length) {
  16986. var newLength = this.sizeMat3 << 1;
  16987. var this1 = new Array(newLength);
  16988. var newArray = this1;
  16989. var _g = 0;
  16990. var _g1 = this.sizeMat3;
  16991. while(_g < _g1) {
  16992. var i = _g++;
  16993. newArray[i] = this.stackMat3[i];
  16994. this.stackMat3[i] = null;
  16995. }
  16996. this.stackMat3 = newArray;
  16997. }
  16998. this.stackMat3[this.sizeMat3++] = m;
  16999. }
  17000. disposeMat4(m) {
  17001. var t00 = 1;
  17002. var t01 = 0;
  17003. var t02 = 0;
  17004. var t03 = 0;
  17005. var t10 = 0;
  17006. var t11 = 1;
  17007. var t12 = 0;
  17008. var t13 = 0;
  17009. var t20 = 0;
  17010. var t21 = 0;
  17011. var t22 = 1;
  17012. var t23 = 0;
  17013. var t30 = 0;
  17014. var t31 = 0;
  17015. var t32 = 0;
  17016. var t33 = 1;
  17017. m.e00 = t00;
  17018. m.e01 = t01;
  17019. m.e02 = t02;
  17020. m.e03 = t03;
  17021. m.e10 = t10;
  17022. m.e11 = t11;
  17023. m.e12 = t12;
  17024. m.e13 = t13;
  17025. m.e20 = t20;
  17026. m.e21 = t21;
  17027. m.e22 = t22;
  17028. m.e23 = t23;
  17029. m.e30 = t30;
  17030. m.e31 = t31;
  17031. m.e32 = t32;
  17032. m.e33 = t33;
  17033. if(this.sizeMat4 == this.stackMat4.length) {
  17034. var newLength = this.sizeMat4 << 1;
  17035. var this1 = new Array(newLength);
  17036. var newArray = this1;
  17037. var _g = 0;
  17038. var _g1 = this.sizeMat4;
  17039. while(_g < _g1) {
  17040. var i = _g++;
  17041. newArray[i] = this.stackMat4[i];
  17042. this.stackMat4[i] = null;
  17043. }
  17044. this.stackMat4 = newArray;
  17045. }
  17046. this.stackMat4[this.sizeMat4++] = m;
  17047. }
  17048. disposeQuat(q) {
  17049. var tx = 0;
  17050. var ty = 0;
  17051. var tz = 0;
  17052. var tw = 1;
  17053. q.x = tx;
  17054. q.y = ty;
  17055. q.z = tz;
  17056. q.w = tw;
  17057. if(this.sizeQuat == this.stackQuat.length) {
  17058. var newLength = this.sizeQuat << 1;
  17059. var this1 = new Array(newLength);
  17060. var newArray = this1;
  17061. var _g = 0;
  17062. var _g1 = this.sizeQuat;
  17063. while(_g < _g1) {
  17064. var i = _g++;
  17065. newArray[i] = this.stackQuat[i];
  17066. this.stackQuat[i] = null;
  17067. }
  17068. this.stackQuat = newArray;
  17069. }
  17070. this.stackQuat[this.sizeQuat++] = q;
  17071. }
  17072. }
  17073. oimo.common.Quat = class oimo_common_Quat {
  17074. constructor(x,y,z,w) {
  17075. if(w == null) {
  17076. w = 1;
  17077. }
  17078. if(z == null) {
  17079. z = 0;
  17080. }
  17081. if(y == null) {
  17082. y = 0;
  17083. }
  17084. if(x == null) {
  17085. x = 0;
  17086. }
  17087. this.x = x;
  17088. this.y = y;
  17089. this.z = z;
  17090. this.w = w;
  17091. oimo.common.Quat.numCreations++;
  17092. }
  17093. identity() {
  17094. var tx = 0;
  17095. var ty = 0;
  17096. var tz = 0;
  17097. var tw = 1;
  17098. this.x = tx;
  17099. this.y = ty;
  17100. this.z = tz;
  17101. this.w = tw;
  17102. return this;
  17103. }
  17104. init(x,y,z,w) {
  17105. this.x = x;
  17106. this.y = y;
  17107. this.z = z;
  17108. this.w = w;
  17109. return this;
  17110. }
  17111. add(q) {
  17112. return new oimo.common.Quat(this.x + q.x,this.y + q.y,this.z + q.z,this.w + q.w);
  17113. }
  17114. sub(q) {
  17115. return new oimo.common.Quat(this.x - q.x,this.y - q.y,this.z - q.z,this.w - q.w);
  17116. }
  17117. scale(s) {
  17118. return new oimo.common.Quat(this.x * s,this.y * s,this.z * s,this.w * s);
  17119. }
  17120. addEq(q) {
  17121. var tx = this.x + q.x;
  17122. var ty = this.y + q.y;
  17123. var tz = this.z + q.z;
  17124. var tw = this.w + q.w;
  17125. this.x = tx;
  17126. this.y = ty;
  17127. this.z = tz;
  17128. this.w = tw;
  17129. return this;
  17130. }
  17131. subEq(q) {
  17132. var tx = this.x - q.x;
  17133. var ty = this.y - q.y;
  17134. var tz = this.z - q.z;
  17135. var tw = this.w - q.w;
  17136. this.x = tx;
  17137. this.y = ty;
  17138. this.z = tz;
  17139. this.w = tw;
  17140. return this;
  17141. }
  17142. scaleEq(s) {
  17143. var tx = this.x * s;
  17144. var ty = this.y * s;
  17145. var tz = this.z * s;
  17146. var tw = this.w * s;
  17147. this.x = tx;
  17148. this.y = ty;
  17149. this.z = tz;
  17150. this.w = tw;
  17151. return this;
  17152. }
  17153. length() {
  17154. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  17155. }
  17156. lengthSq() {
  17157. return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  17158. }
  17159. dot(q) {
  17160. return this.x * q.x + this.y * q.y + this.z * q.z + this.w * q.w;
  17161. }
  17162. normalized() {
  17163. var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  17164. if(invLen > 0) {
  17165. invLen = 1 / invLen;
  17166. }
  17167. return new oimo.common.Quat(this.x * invLen,this.y * invLen,this.z * invLen,this.w * invLen);
  17168. }
  17169. normalize() {
  17170. var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  17171. if(invLen > 0) {
  17172. invLen = 1 / invLen;
  17173. }
  17174. var tx = this.x * invLen;
  17175. var ty = this.y * invLen;
  17176. var tz = this.z * invLen;
  17177. var tw = this.w * invLen;
  17178. this.x = tx;
  17179. this.y = ty;
  17180. this.z = tz;
  17181. this.w = tw;
  17182. return this;
  17183. }
  17184. setArc(v1,v2) {
  17185. var x1 = v1.x;
  17186. var y1 = v1.y;
  17187. var z1 = v1.z;
  17188. var x2 = v2.x;
  17189. var y2 = v2.y;
  17190. var z2 = v2.z;
  17191. var d = x1 * x2 + y1 * y2 + z1 * z2;
  17192. this.w = Math.sqrt((1 + d) * 0.5);
  17193. if(this.w == 0) {
  17194. x2 = x1 * x1;
  17195. y2 = y1 * y1;
  17196. z2 = z1 * z1;
  17197. if(x2 < y2) {
  17198. if(x2 < z2) {
  17199. d = 1 / Math.sqrt(y2 + z2);
  17200. this.x = 0;
  17201. this.y = z1 * d;
  17202. this.z = -y1 * d;
  17203. } else {
  17204. d = 1 / Math.sqrt(x2 + y2);
  17205. this.z = 0;
  17206. this.x = y1 * d;
  17207. this.y = -x1 * d;
  17208. }
  17209. } else if(y2 < z2) {
  17210. d = 1 / Math.sqrt(z2 + x2);
  17211. this.y = 0;
  17212. this.z = x1 * d;
  17213. this.x = -z1 * d;
  17214. } else {
  17215. d = 1 / Math.sqrt(x2 + y2);
  17216. this.z = 0;
  17217. this.x = y1 * d;
  17218. this.y = -x1 * d;
  17219. }
  17220. return this;
  17221. }
  17222. d = 0.5 / this.w;
  17223. var cx = y1 * z2 - z1 * y2;
  17224. var cy = z1 * x2 - x1 * z2;
  17225. var cz = x1 * y2 - y1 * x2;
  17226. this.x = cx * d;
  17227. this.y = cy * d;
  17228. this.z = cz * d;
  17229. return this;
  17230. }
  17231. slerp(q,t) {
  17232. var qx;
  17233. var qy;
  17234. var qz;
  17235. var qw;
  17236. var d = this.x * q.x + this.y * q.y + this.z * q.z + this.w * q.w;
  17237. if(d < 0) {
  17238. d = -d;
  17239. qx = -q.x;
  17240. qy = -q.y;
  17241. qz = -q.z;
  17242. qw = -q.w;
  17243. } else {
  17244. qx = q.x;
  17245. qy = q.y;
  17246. qz = q.z;
  17247. qw = q.w;
  17248. }
  17249. if(d > 0.999999) {
  17250. var _this = new oimo.common.Quat(this.x + (qx - this.x) * t,this.y + (qy - this.y) * t,this.z + (qz - this.z) * t,this.w + (qw - this.w) * t);
  17251. var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
  17252. if(invLen > 0) {
  17253. invLen = 1 / invLen;
  17254. }
  17255. var tx = _this.x * invLen;
  17256. var ty = _this.y * invLen;
  17257. var tz = _this.z * invLen;
  17258. var tw = _this.w * invLen;
  17259. _this.x = tx;
  17260. _this.y = ty;
  17261. _this.z = tz;
  17262. _this.w = tw;
  17263. return _this;
  17264. }
  17265. var theta = t * Math.acos(d);
  17266. qx -= this.x * d;
  17267. qy -= this.y * d;
  17268. qz -= this.z * d;
  17269. qw -= this.w * d;
  17270. var invLen1 = 1 / Math.sqrt(qx * qx + qy * qy + qz * qz + qw * qw);
  17271. qx *= invLen1;
  17272. qy *= invLen1;
  17273. qz *= invLen1;
  17274. qw *= invLen1;
  17275. var sin = Math.sin(theta);
  17276. var cos = Math.cos(theta);
  17277. return new oimo.common.Quat(this.x * cos + qx * sin,this.y * cos + qy * sin,this.z * cos + qz * sin,this.w * cos + qw * sin);
  17278. }
  17279. copyFrom(q) {
  17280. this.x = q.x;
  17281. this.y = q.y;
  17282. this.z = q.z;
  17283. this.w = q.w;
  17284. return this;
  17285. }
  17286. clone() {
  17287. return new oimo.common.Quat(this.x,this.y,this.z,this.w);
  17288. }
  17289. fromMat3(m) {
  17290. var e00 = m.e00;
  17291. var e11 = m.e11;
  17292. var e22 = m.e22;
  17293. var t = e00 + e11 + e22;
  17294. var s;
  17295. if(t > 0) {
  17296. s = Math.sqrt(t + 1);
  17297. this.w = 0.5 * s;
  17298. s = 0.5 / s;
  17299. this.x = (m.e21 - m.e12) * s;
  17300. this.y = (m.e02 - m.e20) * s;
  17301. this.z = (m.e10 - m.e01) * s;
  17302. } else if(e00 > e11) {
  17303. if(e00 > e22) {
  17304. s = Math.sqrt(e00 - e11 - e22 + 1);
  17305. this.x = 0.5 * s;
  17306. s = 0.5 / s;
  17307. this.y = (m.e01 + m.e10) * s;
  17308. this.z = (m.e02 + m.e20) * s;
  17309. this.w = (m.e21 - m.e12) * s;
  17310. } else {
  17311. s = Math.sqrt(e22 - e00 - e11 + 1);
  17312. this.z = 0.5 * s;
  17313. s = 0.5 / s;
  17314. this.x = (m.e02 + m.e20) * s;
  17315. this.y = (m.e12 + m.e21) * s;
  17316. this.w = (m.e10 - m.e01) * s;
  17317. }
  17318. } else if(e11 > e22) {
  17319. s = Math.sqrt(e11 - e22 - e00 + 1);
  17320. this.y = 0.5 * s;
  17321. s = 0.5 / s;
  17322. this.x = (m.e01 + m.e10) * s;
  17323. this.z = (m.e12 + m.e21) * s;
  17324. this.w = (m.e02 - m.e20) * s;
  17325. } else {
  17326. s = Math.sqrt(e22 - e00 - e11 + 1);
  17327. this.z = 0.5 * s;
  17328. s = 0.5 / s;
  17329. this.x = (m.e02 + m.e20) * s;
  17330. this.y = (m.e12 + m.e21) * s;
  17331. this.w = (m.e10 - m.e01) * s;
  17332. }
  17333. return this;
  17334. }
  17335. toMat3() {
  17336. var _this = new oimo.common.Mat3();
  17337. var x = this.x;
  17338. var y = this.y;
  17339. var z = this.z;
  17340. var w = this.w;
  17341. var x2 = 2 * x;
  17342. var y2 = 2 * y;
  17343. var z2 = 2 * z;
  17344. var xx = x * x2;
  17345. var yy = y * y2;
  17346. var zz = z * z2;
  17347. var xy = x * y2;
  17348. var yz = y * z2;
  17349. var xz = x * z2;
  17350. var wx = w * x2;
  17351. var wy = w * y2;
  17352. var wz = w * z2;
  17353. _this.e00 = 1 - yy - zz;
  17354. _this.e01 = xy - wz;
  17355. _this.e02 = xz + wy;
  17356. _this.e10 = xy + wz;
  17357. _this.e11 = 1 - xx - zz;
  17358. _this.e12 = yz - wx;
  17359. _this.e20 = xz - wy;
  17360. _this.e21 = yz + wx;
  17361. _this.e22 = 1 - xx - yy;
  17362. return _this;
  17363. }
  17364. toString() {
  17365. return "Quat[" + (this.x > 0 ? (this.x * 10000000 + 0.5 | 0) / 10000000 : (this.x * 10000000 - 0.5 | 0) / 10000000) + " i,\n" + " " + (this.y > 0 ? (this.y * 10000000 + 0.5 | 0) / 10000000 : (this.y * 10000000 - 0.5 | 0) / 10000000) + " j,\n" + " " + (this.z > 0 ? (this.z * 10000000 + 0.5 | 0) / 10000000 : (this.z * 10000000 - 0.5 | 0) / 10000000) + " k,\n" + " " + (this.w > 0 ? (this.w * 10000000 + 0.5 | 0) / 10000000 : (this.w * 10000000 - 0.5 | 0) / 10000000) + "]";
  17366. }
  17367. }
  17368. if(!oimo.dynamics) oimo.dynamics = {};
  17369. oimo.dynamics.Contact = class oimo_dynamics_Contact {
  17370. constructor() {
  17371. this._next = null;
  17372. this._prev = null;
  17373. this._link1 = new oimo.dynamics.ContactLink();
  17374. this._link2 = new oimo.dynamics.ContactLink();
  17375. this._s1 = null;
  17376. this._s2 = null;
  17377. this._b1 = null;
  17378. this._b2 = null;
  17379. this._detector = null;
  17380. this._cachedDetectorData = new oimo.collision.narrowphase.detector.CachedDetectorData();
  17381. this._detectorResult = new oimo.collision.narrowphase.DetectorResult();
  17382. this._latest = false;
  17383. this._shouldBeSkipped = false;
  17384. this._manifold = new oimo.dynamics.constraint.contact.Manifold();
  17385. this._updater = new oimo.dynamics.constraint.contact.ManifoldUpdater(this._manifold);
  17386. this._contactConstraint = new oimo.dynamics.constraint.contact.ContactConstraint(this._manifold);
  17387. this._touching = false;
  17388. }
  17389. _updateManifold() {
  17390. if(this._detector == null) {
  17391. return;
  17392. }
  17393. var ptouching = this._touching;
  17394. var result = this._detectorResult;
  17395. this._detector.detect(result,this._s1._geom,this._s2._geom,this._s1._transform,this._s2._transform,this._cachedDetectorData);
  17396. var num = result.numPoints;
  17397. this._touching = num > 0;
  17398. if(this._touching) {
  17399. this._manifold._buildBasis(result.normal);
  17400. if(result.getMaxDepth() > oimo.common.Setting.contactUseAlternativePositionCorrectionAlgorithmDepthThreshold) {
  17401. this._contactConstraint._positionCorrectionAlgorithm = oimo.common.Setting.alternativeContactPositionCorrectionAlgorithm;
  17402. } else {
  17403. this._contactConstraint._positionCorrectionAlgorithm = oimo.common.Setting.defaultContactPositionCorrectionAlgorithm;
  17404. }
  17405. if(result.incremental) {
  17406. this._updater.incrementalUpdate(result,this._b1._transform,this._b2._transform);
  17407. } else {
  17408. this._updater.totalUpdate(result,this._b1._transform,this._b2._transform);
  17409. }
  17410. } else {
  17411. this._manifold._clear();
  17412. }
  17413. if(this._touching && !ptouching) {
  17414. var cc1 = this._s1._contactCallback;
  17415. var cc2 = this._s2._contactCallback;
  17416. if(cc1 == cc2) {
  17417. cc2 = null;
  17418. }
  17419. if(cc1 != null) {
  17420. cc1.beginContact(this);
  17421. }
  17422. if(cc2 != null) {
  17423. cc2.beginContact(this);
  17424. }
  17425. }
  17426. if(!this._touching && ptouching) {
  17427. var cc11 = this._s1._contactCallback;
  17428. var cc21 = this._s2._contactCallback;
  17429. if(cc11 == cc21) {
  17430. cc21 = null;
  17431. }
  17432. if(cc11 != null) {
  17433. cc11.endContact(this);
  17434. }
  17435. if(cc21 != null) {
  17436. cc21.endContact(this);
  17437. }
  17438. }
  17439. if(this._touching) {
  17440. var cc12 = this._s1._contactCallback;
  17441. var cc22 = this._s2._contactCallback;
  17442. if(cc12 == cc22) {
  17443. cc22 = null;
  17444. }
  17445. if(cc12 != null) {
  17446. cc12.preSolve(this);
  17447. }
  17448. if(cc22 != null) {
  17449. cc22.preSolve(this);
  17450. }
  17451. }
  17452. }
  17453. _postSolve() {
  17454. var cc1 = this._s1._contactCallback;
  17455. var cc2 = this._s2._contactCallback;
  17456. if(cc1 == cc2) {
  17457. cc2 = null;
  17458. }
  17459. if(cc1 != null) {
  17460. cc1.postSolve(this);
  17461. }
  17462. if(cc2 != null) {
  17463. cc2.postSolve(this);
  17464. }
  17465. }
  17466. getShape1() {
  17467. return this._s1;
  17468. }
  17469. getShape2() {
  17470. return this._s2;
  17471. }
  17472. isTouching() {
  17473. return this._touching;
  17474. }
  17475. getManifold() {
  17476. return this._manifold;
  17477. }
  17478. getContactConstraint() {
  17479. return this._contactConstraint;
  17480. }
  17481. getPrev() {
  17482. return this._prev;
  17483. }
  17484. getNext() {
  17485. return this._next;
  17486. }
  17487. }
  17488. oimo.dynamics.ContactLink = class oimo_dynamics_ContactLink {
  17489. constructor() {
  17490. this._prev = null;
  17491. this._next = null;
  17492. this._contact = null;
  17493. this._other = null;
  17494. }
  17495. getContact() {
  17496. return this._contact;
  17497. }
  17498. getOther() {
  17499. return this._other;
  17500. }
  17501. getPrev() {
  17502. return this._prev;
  17503. }
  17504. getNext() {
  17505. return this._next;
  17506. }
  17507. }
  17508. oimo.dynamics.ContactManager = class oimo_dynamics_ContactManager {
  17509. constructor(broadPhase) {
  17510. this._broadPhase = broadPhase;
  17511. this._collisionMatrix = new oimo.collision.narrowphase.CollisionMatrix();
  17512. this._numContacts = 0;
  17513. }
  17514. createContacts() {
  17515. var pp = this._broadPhase._proxyPairList;
  17516. while(pp != null) {
  17517. var n = pp._next;
  17518. while(true) {
  17519. var s1;
  17520. var s2;
  17521. if(pp._p1._id < pp._p2._id) {
  17522. s1 = pp._p1.userData;
  17523. s2 = pp._p2.userData;
  17524. } else {
  17525. s1 = pp._p2.userData;
  17526. s2 = pp._p1.userData;
  17527. }
  17528. if(!this.shouldCollide(s1,s2)) {
  17529. break;
  17530. }
  17531. var b1 = s1._rigidBody;
  17532. var b2 = s2._rigidBody;
  17533. var n1 = b1._numContactLinks;
  17534. var n2 = b2._numContactLinks;
  17535. var l;
  17536. if(n1 < n2) {
  17537. l = b1._contactLinkList;
  17538. } else {
  17539. l = b2._contactLinkList;
  17540. }
  17541. var id1 = s1._id;
  17542. var id2 = s2._id;
  17543. var found = false;
  17544. while(l != null) {
  17545. var n3 = l._next;
  17546. var c = l._contact;
  17547. if(c._s1._id == id1 && c._s2._id == id2) {
  17548. c._latest = true;
  17549. found = true;
  17550. break;
  17551. }
  17552. l = n3;
  17553. }
  17554. if(!found) {
  17555. var first = this._contactPool;
  17556. if(first != null) {
  17557. this._contactPool = first._next;
  17558. first._next = null;
  17559. } else {
  17560. first = new oimo.dynamics.Contact();
  17561. }
  17562. var c1 = first;
  17563. if(this._contactList == null) {
  17564. this._contactList = c1;
  17565. this._contactListLast = c1;
  17566. } else {
  17567. this._contactListLast._next = c1;
  17568. c1._prev = this._contactListLast;
  17569. this._contactListLast = c1;
  17570. }
  17571. c1._latest = true;
  17572. var detector = this._collisionMatrix.detectors[s1._geom._type][s2._geom._type];
  17573. c1._s1 = s1;
  17574. c1._s2 = s2;
  17575. c1._b1 = s1._rigidBody;
  17576. c1._b2 = s2._rigidBody;
  17577. c1._touching = false;
  17578. if(c1._b1._contactLinkList == null) {
  17579. c1._b1._contactLinkList = c1._link1;
  17580. c1._b1._contactLinkListLast = c1._link1;
  17581. } else {
  17582. c1._b1._contactLinkListLast._next = c1._link1;
  17583. c1._link1._prev = c1._b1._contactLinkListLast;
  17584. c1._b1._contactLinkListLast = c1._link1;
  17585. }
  17586. if(c1._b2._contactLinkList == null) {
  17587. c1._b2._contactLinkList = c1._link2;
  17588. c1._b2._contactLinkListLast = c1._link2;
  17589. } else {
  17590. c1._b2._contactLinkListLast._next = c1._link2;
  17591. c1._link2._prev = c1._b2._contactLinkListLast;
  17592. c1._b2._contactLinkListLast = c1._link2;
  17593. }
  17594. c1._b1._numContactLinks++;
  17595. c1._b2._numContactLinks++;
  17596. c1._link1._other = c1._b2;
  17597. c1._link2._other = c1._b1;
  17598. c1._link1._contact = c1;
  17599. c1._link2._contact = c1;
  17600. c1._detector = detector;
  17601. var _this = c1._contactConstraint;
  17602. _this._s1 = s1;
  17603. _this._s2 = s2;
  17604. _this._b1 = _this._s1._rigidBody;
  17605. _this._b2 = _this._s2._rigidBody;
  17606. _this._tf1 = _this._b1._transform;
  17607. _this._tf2 = _this._b2._transform;
  17608. this._numContacts++;
  17609. }
  17610. if(!false) {
  17611. break;
  17612. }
  17613. }
  17614. pp = n;
  17615. }
  17616. }
  17617. destroyOutdatedContacts() {
  17618. var incremental = this._broadPhase._incremental;
  17619. var c = this._contactList;
  17620. while(c != null) {
  17621. var n = c._next;
  17622. while(true) {
  17623. if(c._latest) {
  17624. c._latest = false;
  17625. c._shouldBeSkipped = false;
  17626. break;
  17627. }
  17628. if(!incremental) {
  17629. var prev = c._prev;
  17630. var next = c._next;
  17631. if(prev != null) {
  17632. prev._next = next;
  17633. }
  17634. if(next != null) {
  17635. next._prev = prev;
  17636. }
  17637. if(c == this._contactList) {
  17638. this._contactList = this._contactList._next;
  17639. }
  17640. if(c == this._contactListLast) {
  17641. this._contactListLast = this._contactListLast._prev;
  17642. }
  17643. c._next = null;
  17644. c._prev = null;
  17645. if(c._touching) {
  17646. var cc1 = c._s1._contactCallback;
  17647. var cc2 = c._s2._contactCallback;
  17648. if(cc1 == cc2) {
  17649. cc2 = null;
  17650. }
  17651. if(cc1 != null) {
  17652. cc1.endContact(c);
  17653. }
  17654. if(cc2 != null) {
  17655. cc2.endContact(c);
  17656. }
  17657. }
  17658. var prev1 = c._link1._prev;
  17659. var next1 = c._link1._next;
  17660. if(prev1 != null) {
  17661. prev1._next = next1;
  17662. }
  17663. if(next1 != null) {
  17664. next1._prev = prev1;
  17665. }
  17666. if(c._link1 == c._b1._contactLinkList) {
  17667. c._b1._contactLinkList = c._b1._contactLinkList._next;
  17668. }
  17669. if(c._link1 == c._b1._contactLinkListLast) {
  17670. c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev;
  17671. }
  17672. c._link1._next = null;
  17673. c._link1._prev = null;
  17674. var prev2 = c._link2._prev;
  17675. var next2 = c._link2._next;
  17676. if(prev2 != null) {
  17677. prev2._next = next2;
  17678. }
  17679. if(next2 != null) {
  17680. next2._prev = prev2;
  17681. }
  17682. if(c._link2 == c._b2._contactLinkList) {
  17683. c._b2._contactLinkList = c._b2._contactLinkList._next;
  17684. }
  17685. if(c._link2 == c._b2._contactLinkListLast) {
  17686. c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev;
  17687. }
  17688. c._link2._next = null;
  17689. c._link2._prev = null;
  17690. c._b1._numContactLinks--;
  17691. c._b2._numContactLinks--;
  17692. c._link1._other = null;
  17693. c._link2._other = null;
  17694. c._link1._contact = null;
  17695. c._link2._contact = null;
  17696. c._s1 = null;
  17697. c._s2 = null;
  17698. c._b1 = null;
  17699. c._b2 = null;
  17700. c._touching = false;
  17701. c._cachedDetectorData._clear();
  17702. c._manifold._clear();
  17703. c._detector = null;
  17704. var _this = c._contactConstraint;
  17705. _this._s1 = null;
  17706. _this._s2 = null;
  17707. _this._b1 = null;
  17708. _this._b2 = null;
  17709. _this._tf1 = null;
  17710. _this._tf2 = null;
  17711. c._next = this._contactPool;
  17712. this._contactPool = c;
  17713. this._numContacts--;
  17714. break;
  17715. }
  17716. var s1 = c._s1;
  17717. var s2 = c._s2;
  17718. var r1 = s1._rigidBody;
  17719. var r2 = s2._rigidBody;
  17720. var active1 = !r1._sleeping && r1._type != 1;
  17721. var active2 = !r2._sleeping && r2._type != 1;
  17722. if(!active1 && !active2) {
  17723. c._shouldBeSkipped = true;
  17724. break;
  17725. }
  17726. var aabb1 = s1._aabb;
  17727. var aabb2 = s2._aabb;
  17728. var proxy1 = s1._proxy;
  17729. var proxy2 = s2._proxy;
  17730. if(!(proxy1._aabbMinX < proxy2._aabbMaxX && proxy1._aabbMaxX > proxy2._aabbMinX && proxy1._aabbMinY < proxy2._aabbMaxY && proxy1._aabbMaxY > proxy2._aabbMinY && proxy1._aabbMinZ < proxy2._aabbMaxZ && proxy1._aabbMaxZ > proxy2._aabbMinZ) || !this.shouldCollide(s1,s2)) {
  17731. var prev3 = c._prev;
  17732. var next3 = c._next;
  17733. if(prev3 != null) {
  17734. prev3._next = next3;
  17735. }
  17736. if(next3 != null) {
  17737. next3._prev = prev3;
  17738. }
  17739. if(c == this._contactList) {
  17740. this._contactList = this._contactList._next;
  17741. }
  17742. if(c == this._contactListLast) {
  17743. this._contactListLast = this._contactListLast._prev;
  17744. }
  17745. c._next = null;
  17746. c._prev = null;
  17747. if(c._touching) {
  17748. var cc11 = c._s1._contactCallback;
  17749. var cc21 = c._s2._contactCallback;
  17750. if(cc11 == cc21) {
  17751. cc21 = null;
  17752. }
  17753. if(cc11 != null) {
  17754. cc11.endContact(c);
  17755. }
  17756. if(cc21 != null) {
  17757. cc21.endContact(c);
  17758. }
  17759. }
  17760. var prev4 = c._link1._prev;
  17761. var next4 = c._link1._next;
  17762. if(prev4 != null) {
  17763. prev4._next = next4;
  17764. }
  17765. if(next4 != null) {
  17766. next4._prev = prev4;
  17767. }
  17768. if(c._link1 == c._b1._contactLinkList) {
  17769. c._b1._contactLinkList = c._b1._contactLinkList._next;
  17770. }
  17771. if(c._link1 == c._b1._contactLinkListLast) {
  17772. c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev;
  17773. }
  17774. c._link1._next = null;
  17775. c._link1._prev = null;
  17776. var prev5 = c._link2._prev;
  17777. var next5 = c._link2._next;
  17778. if(prev5 != null) {
  17779. prev5._next = next5;
  17780. }
  17781. if(next5 != null) {
  17782. next5._prev = prev5;
  17783. }
  17784. if(c._link2 == c._b2._contactLinkList) {
  17785. c._b2._contactLinkList = c._b2._contactLinkList._next;
  17786. }
  17787. if(c._link2 == c._b2._contactLinkListLast) {
  17788. c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev;
  17789. }
  17790. c._link2._next = null;
  17791. c._link2._prev = null;
  17792. c._b1._numContactLinks--;
  17793. c._b2._numContactLinks--;
  17794. c._link1._other = null;
  17795. c._link2._other = null;
  17796. c._link1._contact = null;
  17797. c._link2._contact = null;
  17798. c._s1 = null;
  17799. c._s2 = null;
  17800. c._b1 = null;
  17801. c._b2 = null;
  17802. c._touching = false;
  17803. c._cachedDetectorData._clear();
  17804. c._manifold._clear();
  17805. c._detector = null;
  17806. var _this1 = c._contactConstraint;
  17807. _this1._s1 = null;
  17808. _this1._s2 = null;
  17809. _this1._b1 = null;
  17810. _this1._b2 = null;
  17811. _this1._tf1 = null;
  17812. _this1._tf2 = null;
  17813. c._next = this._contactPool;
  17814. this._contactPool = c;
  17815. this._numContacts--;
  17816. break;
  17817. }
  17818. var aabbOverlapping = aabb1._minX < aabb2._maxX && aabb1._maxX > aabb2._minX && aabb1._minY < aabb2._maxY && aabb1._maxY > aabb2._minY && aabb1._minZ < aabb2._maxZ && aabb1._maxZ > aabb2._minZ;
  17819. c._shouldBeSkipped = !aabbOverlapping;
  17820. if(!false) {
  17821. break;
  17822. }
  17823. }
  17824. c = n;
  17825. }
  17826. }
  17827. shouldCollide(s1,s2) {
  17828. var r1 = s1._rigidBody;
  17829. var r2 = s2._rigidBody;
  17830. if(r1 == r2) {
  17831. return false;
  17832. }
  17833. if(r1._type != 0 && r2._type != 0) {
  17834. return false;
  17835. }
  17836. if((s1._collisionGroup & s2._collisionMask) == 0 || (s2._collisionGroup & s1._collisionMask) == 0) {
  17837. return false;
  17838. }
  17839. var jl;
  17840. var other;
  17841. if(r1._numJointLinks < r2._numJointLinks) {
  17842. jl = r1._jointLinkList;
  17843. other = r2;
  17844. } else {
  17845. jl = r2._jointLinkList;
  17846. other = r1;
  17847. }
  17848. while(jl != null) {
  17849. var n = jl._next;
  17850. if(jl._other == other && !jl._joint._allowCollision) {
  17851. return false;
  17852. }
  17853. jl = n;
  17854. }
  17855. return true;
  17856. }
  17857. _updateContacts() {
  17858. this._broadPhase.collectPairs();
  17859. this.createContacts();
  17860. this.destroyOutdatedContacts();
  17861. }
  17862. _postSolve() {
  17863. var c = this._contactList;
  17864. while(c != null) {
  17865. var n = c._next;
  17866. if(c._touching) {
  17867. c._postSolve();
  17868. }
  17869. c = n;
  17870. }
  17871. }
  17872. getNumContacts() {
  17873. return this._numContacts;
  17874. }
  17875. getContactList() {
  17876. return this._contactList;
  17877. }
  17878. }
  17879. oimo.dynamics.Island = class oimo_dynamics_Island {
  17880. constructor() {
  17881. var this1 = new Array(oimo.common.Setting.islandInitialRigidBodyArraySize);
  17882. this.rigidBodies = this1;
  17883. var this2 = new Array(oimo.common.Setting.islandInitialConstraintArraySize);
  17884. this.solvers = this2;
  17885. var this3 = new Array(oimo.common.Setting.islandInitialConstraintArraySize);
  17886. this.solversSi = this3;
  17887. var this4 = new Array(oimo.common.Setting.islandInitialConstraintArraySize);
  17888. this.solversNgs = this4;
  17889. this.numRigidBodies = 0;
  17890. this.numSolvers = 0;
  17891. this.numSolversSi = 0;
  17892. this.numSolversNgs = 0;
  17893. }
  17894. _clear() {
  17895. while(this.numRigidBodies > 0) this.rigidBodies[--this.numRigidBodies] = null;
  17896. while(this.numSolvers > 0) this.solvers[--this.numSolvers] = null;
  17897. while(this.numSolversSi > 0) this.solversSi[--this.numSolversSi] = null;
  17898. while(this.numSolversNgs > 0) this.solversNgs[--this.numSolversNgs] = null;
  17899. }
  17900. _addRigidBody(rigidBody) {
  17901. if(this.numRigidBodies == this.rigidBodies.length) {
  17902. var newLength = this.numRigidBodies << 1;
  17903. var this1 = new Array(newLength);
  17904. var newArray = this1;
  17905. var _g = 0;
  17906. var _g1 = this.numRigidBodies;
  17907. while(_g < _g1) {
  17908. var i = _g++;
  17909. newArray[i] = this.rigidBodies[i];
  17910. this.rigidBodies[i] = null;
  17911. }
  17912. this.rigidBodies = newArray;
  17913. }
  17914. rigidBody._addedToIsland = true;
  17915. this.rigidBodies[this.numRigidBodies++] = rigidBody;
  17916. }
  17917. _addConstraintSolver(solver,positionCorrection) {
  17918. if(this.numSolvers == this.solvers.length) {
  17919. var newLength = this.numSolvers << 1;
  17920. var this1 = new Array(newLength);
  17921. var newArray = this1;
  17922. var _g = 0;
  17923. var _g1 = this.numSolvers;
  17924. while(_g < _g1) {
  17925. var i = _g++;
  17926. newArray[i] = this.solvers[i];
  17927. this.solvers[i] = null;
  17928. }
  17929. this.solvers = newArray;
  17930. }
  17931. solver._addedToIsland = true;
  17932. this.solvers[this.numSolvers++] = solver;
  17933. if(positionCorrection == oimo.dynamics.constraint.PositionCorrectionAlgorithm.SPLIT_IMPULSE) {
  17934. if(this.numSolversSi == this.solversSi.length) {
  17935. var newLength1 = this.numSolversSi << 1;
  17936. var this2 = new Array(newLength1);
  17937. var newArray1 = this2;
  17938. var _g2 = 0;
  17939. var _g11 = this.numSolversSi;
  17940. while(_g2 < _g11) {
  17941. var i1 = _g2++;
  17942. newArray1[i1] = this.solversSi[i1];
  17943. this.solversSi[i1] = null;
  17944. }
  17945. this.solversSi = newArray1;
  17946. }
  17947. this.solversSi[this.numSolversSi++] = solver;
  17948. }
  17949. if(positionCorrection == oimo.dynamics.constraint.PositionCorrectionAlgorithm.NGS) {
  17950. if(this.numSolversNgs == this.solversNgs.length) {
  17951. var newLength2 = this.numSolversNgs << 1;
  17952. var this3 = new Array(newLength2);
  17953. var newArray2 = this3;
  17954. var _g3 = 0;
  17955. var _g12 = this.numSolversNgs;
  17956. while(_g3 < _g12) {
  17957. var i2 = _g3++;
  17958. newArray2[i2] = this.solversNgs[i2];
  17959. this.solversNgs[i2] = null;
  17960. }
  17961. this.solversNgs = newArray2;
  17962. }
  17963. this.solversNgs[this.numSolversNgs++] = solver;
  17964. }
  17965. }
  17966. _stepSingleRigidBody(timeStep,rb) {
  17967. var dt = timeStep.dt;
  17968. var dst = rb._ptransform;
  17969. var src = rb._transform;
  17970. dst._positionX = src._positionX;
  17971. dst._positionY = src._positionY;
  17972. dst._positionZ = src._positionZ;
  17973. dst._rotation00 = src._rotation00;
  17974. dst._rotation01 = src._rotation01;
  17975. dst._rotation02 = src._rotation02;
  17976. dst._rotation10 = src._rotation10;
  17977. dst._rotation11 = src._rotation11;
  17978. dst._rotation12 = src._rotation12;
  17979. dst._rotation20 = src._rotation20;
  17980. dst._rotation21 = src._rotation21;
  17981. dst._rotation22 = src._rotation22;
  17982. rb._linearContactImpulseX = 0;
  17983. rb._linearContactImpulseY = 0;
  17984. rb._linearContactImpulseZ = 0;
  17985. rb._angularContactImpulseX = 0;
  17986. rb._angularContactImpulseY = 0;
  17987. rb._angularContactImpulseZ = 0;
  17988. if(rb._autoSleep && rb._velX * rb._velX + rb._velY * rb._velY + rb._velZ * rb._velZ < oimo.common.Setting.sleepingVelocityThreshold * oimo.common.Setting.sleepingVelocityThreshold && rb._angVelX * rb._angVelX + rb._angVelY * rb._angVelY + rb._angVelZ * rb._angVelZ < oimo.common.Setting.sleepingAngularVelocityThreshold * oimo.common.Setting.sleepingAngularVelocityThreshold) {
  17989. rb._sleepTime += dt;
  17990. if(rb._sleepTime > oimo.common.Setting.sleepingTimeThreshold) {
  17991. rb._sleeping = true;
  17992. rb._sleepTime = 0;
  17993. }
  17994. } else {
  17995. rb._sleepTime = 0;
  17996. }
  17997. if(!rb._sleeping) {
  17998. if(rb._type == 0) {
  17999. var x = dt * rb._linearDamping;
  18000. var x2 = x * x;
  18001. var linScale = 1 / (1 + x + x2 * (0.5 + x * 0.166666666666666657 + x2 * 0.0416666666666666644));
  18002. var x1 = dt * rb._angularDamping;
  18003. var x21 = x1 * x1;
  18004. var angScale = 1 / (1 + x1 + x21 * (0.5 + x1 * 0.166666666666666657 + x21 * 0.0416666666666666644));
  18005. var linAcc;
  18006. var linAccX;
  18007. var linAccY;
  18008. var linAccZ;
  18009. var angAcc;
  18010. var angAccX;
  18011. var angAccY;
  18012. var angAccZ;
  18013. linAccX = this.gravityX * rb._gravityScale;
  18014. linAccY = this.gravityY * rb._gravityScale;
  18015. linAccZ = this.gravityZ * rb._gravityScale;
  18016. linAccX += rb._forceX * rb._invMass;
  18017. linAccY += rb._forceY * rb._invMass;
  18018. linAccZ += rb._forceZ * rb._invMass;
  18019. var __tmp__X;
  18020. var __tmp__Y;
  18021. var __tmp__Z;
  18022. __tmp__X = rb._invInertia00 * rb._torqueX + rb._invInertia01 * rb._torqueY + rb._invInertia02 * rb._torqueZ;
  18023. __tmp__Y = rb._invInertia10 * rb._torqueX + rb._invInertia11 * rb._torqueY + rb._invInertia12 * rb._torqueZ;
  18024. __tmp__Z = rb._invInertia20 * rb._torqueX + rb._invInertia21 * rb._torqueY + rb._invInertia22 * rb._torqueZ;
  18025. angAccX = __tmp__X;
  18026. angAccY = __tmp__Y;
  18027. angAccZ = __tmp__Z;
  18028. rb._velX += linAccX * dt;
  18029. rb._velY += linAccY * dt;
  18030. rb._velZ += linAccZ * dt;
  18031. rb._velX *= linScale;
  18032. rb._velY *= linScale;
  18033. rb._velZ *= linScale;
  18034. rb._angVelX += angAccX * dt;
  18035. rb._angVelY += angAccY * dt;
  18036. rb._angVelZ += angAccZ * dt;
  18037. rb._angVelX *= angScale;
  18038. rb._angVelY *= angScale;
  18039. rb._angVelZ *= angScale;
  18040. }
  18041. rb._integrate(dt);
  18042. var s = rb._shapeList;
  18043. while(s != null) {
  18044. var n = s._next;
  18045. var dst1 = s._ptransform;
  18046. var src1 = s._localTransform;
  18047. var src2 = rb._ptransform;
  18048. var __tmp__00;
  18049. var __tmp__01;
  18050. var __tmp__02;
  18051. var __tmp__10;
  18052. var __tmp__11;
  18053. var __tmp__12;
  18054. var __tmp__20;
  18055. var __tmp__21;
  18056. var __tmp__22;
  18057. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  18058. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  18059. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  18060. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  18061. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  18062. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  18063. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  18064. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  18065. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  18066. dst1._rotation00 = __tmp__00;
  18067. dst1._rotation01 = __tmp__01;
  18068. dst1._rotation02 = __tmp__02;
  18069. dst1._rotation10 = __tmp__10;
  18070. dst1._rotation11 = __tmp__11;
  18071. dst1._rotation12 = __tmp__12;
  18072. dst1._rotation20 = __tmp__20;
  18073. dst1._rotation21 = __tmp__21;
  18074. dst1._rotation22 = __tmp__22;
  18075. var __tmp__X1;
  18076. var __tmp__Y1;
  18077. var __tmp__Z1;
  18078. __tmp__X1 = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  18079. __tmp__Y1 = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  18080. __tmp__Z1 = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  18081. dst1._positionX = __tmp__X1;
  18082. dst1._positionY = __tmp__Y1;
  18083. dst1._positionZ = __tmp__Z1;
  18084. dst1._positionX += src2._positionX;
  18085. dst1._positionY += src2._positionY;
  18086. dst1._positionZ += src2._positionZ;
  18087. var dst2 = s._transform;
  18088. var src11 = s._localTransform;
  18089. var src21 = rb._transform;
  18090. var __tmp__001;
  18091. var __tmp__011;
  18092. var __tmp__021;
  18093. var __tmp__101;
  18094. var __tmp__111;
  18095. var __tmp__121;
  18096. var __tmp__201;
  18097. var __tmp__211;
  18098. var __tmp__221;
  18099. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  18100. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  18101. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  18102. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  18103. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  18104. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  18105. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  18106. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  18107. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  18108. dst2._rotation00 = __tmp__001;
  18109. dst2._rotation01 = __tmp__011;
  18110. dst2._rotation02 = __tmp__021;
  18111. dst2._rotation10 = __tmp__101;
  18112. dst2._rotation11 = __tmp__111;
  18113. dst2._rotation12 = __tmp__121;
  18114. dst2._rotation20 = __tmp__201;
  18115. dst2._rotation21 = __tmp__211;
  18116. dst2._rotation22 = __tmp__221;
  18117. var __tmp__X2;
  18118. var __tmp__Y2;
  18119. var __tmp__Z2;
  18120. __tmp__X2 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  18121. __tmp__Y2 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  18122. __tmp__Z2 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  18123. dst2._positionX = __tmp__X2;
  18124. dst2._positionY = __tmp__Y2;
  18125. dst2._positionZ = __tmp__Z2;
  18126. dst2._positionX += src21._positionX;
  18127. dst2._positionY += src21._positionY;
  18128. dst2._positionZ += src21._positionZ;
  18129. var min;
  18130. var minX;
  18131. var minY;
  18132. var minZ;
  18133. var max;
  18134. var maxX;
  18135. var maxY;
  18136. var maxZ;
  18137. s._geom._computeAabb(s._aabb,s._ptransform);
  18138. minX = s._aabb._minX;
  18139. minY = s._aabb._minY;
  18140. minZ = s._aabb._minZ;
  18141. maxX = s._aabb._maxX;
  18142. maxY = s._aabb._maxY;
  18143. maxZ = s._aabb._maxZ;
  18144. s._geom._computeAabb(s._aabb,s._transform);
  18145. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  18146. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  18147. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  18148. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  18149. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  18150. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  18151. if(s._proxy != null) {
  18152. var d;
  18153. var dX;
  18154. var dY;
  18155. var dZ;
  18156. dX = s._transform._positionX - s._ptransform._positionX;
  18157. dY = s._transform._positionY - s._ptransform._positionY;
  18158. dZ = s._transform._positionZ - s._ptransform._positionZ;
  18159. var v = s.displacement;
  18160. v.x = dX;
  18161. v.y = dY;
  18162. v.z = dZ;
  18163. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  18164. }
  18165. s = n;
  18166. }
  18167. }
  18168. }
  18169. _step(timeStep,numVelocityIterations,numPositionIterations) {
  18170. var dt = timeStep.dt;
  18171. var sleepIsland = true;
  18172. var _g = 0;
  18173. var _g1 = this.numRigidBodies;
  18174. while(_g < _g1) {
  18175. var i = _g++;
  18176. var rb = this.rigidBodies[i];
  18177. var dst = rb._ptransform;
  18178. var src = rb._transform;
  18179. dst._positionX = src._positionX;
  18180. dst._positionY = src._positionY;
  18181. dst._positionZ = src._positionZ;
  18182. dst._rotation00 = src._rotation00;
  18183. dst._rotation01 = src._rotation01;
  18184. dst._rotation02 = src._rotation02;
  18185. dst._rotation10 = src._rotation10;
  18186. dst._rotation11 = src._rotation11;
  18187. dst._rotation12 = src._rotation12;
  18188. dst._rotation20 = src._rotation20;
  18189. dst._rotation21 = src._rotation21;
  18190. dst._rotation22 = src._rotation22;
  18191. rb._linearContactImpulseX = 0;
  18192. rb._linearContactImpulseY = 0;
  18193. rb._linearContactImpulseZ = 0;
  18194. rb._angularContactImpulseX = 0;
  18195. rb._angularContactImpulseY = 0;
  18196. rb._angularContactImpulseZ = 0;
  18197. rb._sleeping = false;
  18198. if(rb._autoSleep && rb._velX * rb._velX + rb._velY * rb._velY + rb._velZ * rb._velZ < oimo.common.Setting.sleepingVelocityThreshold * oimo.common.Setting.sleepingVelocityThreshold && rb._angVelX * rb._angVelX + rb._angVelY * rb._angVelY + rb._angVelZ * rb._angVelZ < oimo.common.Setting.sleepingAngularVelocityThreshold * oimo.common.Setting.sleepingAngularVelocityThreshold) {
  18199. rb._sleepTime += dt;
  18200. } else {
  18201. rb._sleepTime = 0;
  18202. }
  18203. if(rb._sleepTime < oimo.common.Setting.sleepingTimeThreshold) {
  18204. sleepIsland = false;
  18205. }
  18206. if(rb._type == 0) {
  18207. var x = dt * rb._linearDamping;
  18208. var x2 = x * x;
  18209. var linScale = 1 / (1 + x + x2 * (0.5 + x * 0.166666666666666657 + x2 * 0.0416666666666666644));
  18210. var x1 = dt * rb._angularDamping;
  18211. var x21 = x1 * x1;
  18212. var angScale = 1 / (1 + x1 + x21 * (0.5 + x1 * 0.166666666666666657 + x21 * 0.0416666666666666644));
  18213. var linAcc;
  18214. var linAccX;
  18215. var linAccY;
  18216. var linAccZ;
  18217. var angAcc;
  18218. var angAccX;
  18219. var angAccY;
  18220. var angAccZ;
  18221. linAccX = this.gravityX * rb._gravityScale;
  18222. linAccY = this.gravityY * rb._gravityScale;
  18223. linAccZ = this.gravityZ * rb._gravityScale;
  18224. linAccX += rb._forceX * rb._invMass;
  18225. linAccY += rb._forceY * rb._invMass;
  18226. linAccZ += rb._forceZ * rb._invMass;
  18227. var __tmp__X;
  18228. var __tmp__Y;
  18229. var __tmp__Z;
  18230. __tmp__X = rb._invInertia00 * rb._torqueX + rb._invInertia01 * rb._torqueY + rb._invInertia02 * rb._torqueZ;
  18231. __tmp__Y = rb._invInertia10 * rb._torqueX + rb._invInertia11 * rb._torqueY + rb._invInertia12 * rb._torqueZ;
  18232. __tmp__Z = rb._invInertia20 * rb._torqueX + rb._invInertia21 * rb._torqueY + rb._invInertia22 * rb._torqueZ;
  18233. angAccX = __tmp__X;
  18234. angAccY = __tmp__Y;
  18235. angAccZ = __tmp__Z;
  18236. rb._velX += linAccX * dt;
  18237. rb._velY += linAccY * dt;
  18238. rb._velZ += linAccZ * dt;
  18239. rb._velX *= linScale;
  18240. rb._velY *= linScale;
  18241. rb._velZ *= linScale;
  18242. rb._angVelX += angAccX * dt;
  18243. rb._angVelY += angAccY * dt;
  18244. rb._angVelZ += angAccZ * dt;
  18245. rb._angVelX *= angScale;
  18246. rb._angVelY *= angScale;
  18247. rb._angVelZ *= angScale;
  18248. }
  18249. }
  18250. if(sleepIsland) {
  18251. var _g2 = 0;
  18252. var _g3 = this.numRigidBodies;
  18253. while(_g2 < _g3) {
  18254. var i1 = _g2++;
  18255. var rb1 = this.rigidBodies[i1];
  18256. rb1._sleeping = true;
  18257. rb1._sleepTime = 0;
  18258. }
  18259. return;
  18260. }
  18261. var _g21 = 0;
  18262. var _g31 = this.numSolvers;
  18263. while(_g21 < _g31) {
  18264. var i2 = _g21++;
  18265. var s = this.solvers[i2];
  18266. s.preSolveVelocity(timeStep);
  18267. }
  18268. var _g4 = 0;
  18269. var _g5 = this.numSolvers;
  18270. while(_g4 < _g5) {
  18271. var i3 = _g4++;
  18272. var s1 = this.solvers[i3];
  18273. s1.warmStart(timeStep);
  18274. }
  18275. var _g6 = 0;
  18276. var _g7 = numVelocityIterations;
  18277. while(_g6 < _g7) {
  18278. var t = _g6++;
  18279. var _g61 = 0;
  18280. var _g71 = this.numSolvers;
  18281. while(_g61 < _g71) {
  18282. var i4 = _g61++;
  18283. var s2 = this.solvers[i4];
  18284. s2.solveVelocity();
  18285. }
  18286. }
  18287. var _g8 = 0;
  18288. var _g9 = this.numSolvers;
  18289. while(_g8 < _g9) {
  18290. var i5 = _g8++;
  18291. var s3 = this.solvers[i5];
  18292. s3.postSolveVelocity(timeStep);
  18293. }
  18294. var _g10 = 0;
  18295. var _g11 = this.numRigidBodies;
  18296. while(_g10 < _g11) {
  18297. var i6 = _g10++;
  18298. var rb2 = this.rigidBodies[i6];
  18299. rb2._integrate(dt);
  18300. }
  18301. var _g12 = 0;
  18302. var _g13 = this.numSolversSi;
  18303. while(_g12 < _g13) {
  18304. var i7 = _g12++;
  18305. var s4 = this.solversSi[i7];
  18306. s4.preSolvePosition(timeStep);
  18307. }
  18308. var _g14 = 0;
  18309. var _g15 = numPositionIterations;
  18310. while(_g14 < _g15) {
  18311. var t1 = _g14++;
  18312. var _g141 = 0;
  18313. var _g151 = this.numSolversSi;
  18314. while(_g141 < _g151) {
  18315. var i8 = _g141++;
  18316. var s5 = this.solversSi[i8];
  18317. s5.solvePositionSplitImpulse();
  18318. }
  18319. }
  18320. var _g16 = 0;
  18321. var _g17 = this.numRigidBodies;
  18322. while(_g16 < _g17) {
  18323. var i9 = _g16++;
  18324. var rb3 = this.rigidBodies[i9];
  18325. rb3._integratePseudoVelocity();
  18326. }
  18327. var _g18 = 0;
  18328. var _g19 = this.numSolversNgs;
  18329. while(_g18 < _g19) {
  18330. var i10 = _g18++;
  18331. var s6 = this.solversNgs[i10];
  18332. s6.preSolvePosition(timeStep);
  18333. }
  18334. var _g20 = 0;
  18335. var _g211 = numPositionIterations;
  18336. while(_g20 < _g211) {
  18337. var t2 = _g20++;
  18338. var _g201 = 0;
  18339. var _g212 = this.numSolversNgs;
  18340. while(_g201 < _g212) {
  18341. var i11 = _g201++;
  18342. var s7 = this.solversNgs[i11];
  18343. s7.solvePositionNgs(timeStep);
  18344. }
  18345. }
  18346. var _g22 = 0;
  18347. var _g23 = this.numSolvers;
  18348. while(_g22 < _g23) {
  18349. var i12 = _g22++;
  18350. var s8 = this.solvers[i12];
  18351. s8.postSolve();
  18352. }
  18353. var _g24 = 0;
  18354. var _g25 = this.numRigidBodies;
  18355. while(_g24 < _g25) {
  18356. var i13 = _g24++;
  18357. var rb4 = this.rigidBodies[i13];
  18358. var s9 = rb4._shapeList;
  18359. while(s9 != null) {
  18360. var n = s9._next;
  18361. var dst1 = s9._ptransform;
  18362. var src1 = s9._localTransform;
  18363. var src2 = rb4._ptransform;
  18364. var __tmp__00;
  18365. var __tmp__01;
  18366. var __tmp__02;
  18367. var __tmp__10;
  18368. var __tmp__11;
  18369. var __tmp__12;
  18370. var __tmp__20;
  18371. var __tmp__21;
  18372. var __tmp__22;
  18373. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  18374. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  18375. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  18376. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  18377. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  18378. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  18379. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  18380. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  18381. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  18382. dst1._rotation00 = __tmp__00;
  18383. dst1._rotation01 = __tmp__01;
  18384. dst1._rotation02 = __tmp__02;
  18385. dst1._rotation10 = __tmp__10;
  18386. dst1._rotation11 = __tmp__11;
  18387. dst1._rotation12 = __tmp__12;
  18388. dst1._rotation20 = __tmp__20;
  18389. dst1._rotation21 = __tmp__21;
  18390. dst1._rotation22 = __tmp__22;
  18391. var __tmp__X1;
  18392. var __tmp__Y1;
  18393. var __tmp__Z1;
  18394. __tmp__X1 = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  18395. __tmp__Y1 = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  18396. __tmp__Z1 = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  18397. dst1._positionX = __tmp__X1;
  18398. dst1._positionY = __tmp__Y1;
  18399. dst1._positionZ = __tmp__Z1;
  18400. dst1._positionX += src2._positionX;
  18401. dst1._positionY += src2._positionY;
  18402. dst1._positionZ += src2._positionZ;
  18403. var dst2 = s9._transform;
  18404. var src11 = s9._localTransform;
  18405. var src21 = rb4._transform;
  18406. var __tmp__001;
  18407. var __tmp__011;
  18408. var __tmp__021;
  18409. var __tmp__101;
  18410. var __tmp__111;
  18411. var __tmp__121;
  18412. var __tmp__201;
  18413. var __tmp__211;
  18414. var __tmp__221;
  18415. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  18416. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  18417. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  18418. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  18419. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  18420. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  18421. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  18422. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  18423. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  18424. dst2._rotation00 = __tmp__001;
  18425. dst2._rotation01 = __tmp__011;
  18426. dst2._rotation02 = __tmp__021;
  18427. dst2._rotation10 = __tmp__101;
  18428. dst2._rotation11 = __tmp__111;
  18429. dst2._rotation12 = __tmp__121;
  18430. dst2._rotation20 = __tmp__201;
  18431. dst2._rotation21 = __tmp__211;
  18432. dst2._rotation22 = __tmp__221;
  18433. var __tmp__X2;
  18434. var __tmp__Y2;
  18435. var __tmp__Z2;
  18436. __tmp__X2 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  18437. __tmp__Y2 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  18438. __tmp__Z2 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  18439. dst2._positionX = __tmp__X2;
  18440. dst2._positionY = __tmp__Y2;
  18441. dst2._positionZ = __tmp__Z2;
  18442. dst2._positionX += src21._positionX;
  18443. dst2._positionY += src21._positionY;
  18444. dst2._positionZ += src21._positionZ;
  18445. var min;
  18446. var minX;
  18447. var minY;
  18448. var minZ;
  18449. var max;
  18450. var maxX;
  18451. var maxY;
  18452. var maxZ;
  18453. s9._geom._computeAabb(s9._aabb,s9._ptransform);
  18454. minX = s9._aabb._minX;
  18455. minY = s9._aabb._minY;
  18456. minZ = s9._aabb._minZ;
  18457. maxX = s9._aabb._maxX;
  18458. maxY = s9._aabb._maxY;
  18459. maxZ = s9._aabb._maxZ;
  18460. s9._geom._computeAabb(s9._aabb,s9._transform);
  18461. s9._aabb._minX = minX < s9._aabb._minX ? minX : s9._aabb._minX;
  18462. s9._aabb._minY = minY < s9._aabb._minY ? minY : s9._aabb._minY;
  18463. s9._aabb._minZ = minZ < s9._aabb._minZ ? minZ : s9._aabb._minZ;
  18464. s9._aabb._maxX = maxX > s9._aabb._maxX ? maxX : s9._aabb._maxX;
  18465. s9._aabb._maxY = maxY > s9._aabb._maxY ? maxY : s9._aabb._maxY;
  18466. s9._aabb._maxZ = maxZ > s9._aabb._maxZ ? maxZ : s9._aabb._maxZ;
  18467. if(s9._proxy != null) {
  18468. var d;
  18469. var dX;
  18470. var dY;
  18471. var dZ;
  18472. dX = s9._transform._positionX - s9._ptransform._positionX;
  18473. dY = s9._transform._positionY - s9._ptransform._positionY;
  18474. dZ = s9._transform._positionZ - s9._ptransform._positionZ;
  18475. var v = s9.displacement;
  18476. v.x = dX;
  18477. v.y = dY;
  18478. v.z = dZ;
  18479. s9._rigidBody._world._broadPhase.moveProxy(s9._proxy,s9._aabb,s9.displacement);
  18480. }
  18481. s9 = n;
  18482. }
  18483. }
  18484. }
  18485. }
  18486. oimo.dynamics.TimeStep = class oimo_dynamics_TimeStep {
  18487. constructor() {
  18488. this.dt = 0;
  18489. this.invDt = 0;
  18490. this.dtRatio = 1;
  18491. }
  18492. }
  18493. oimo.dynamics.World = class oimo_dynamics_World {
  18494. constructor(broadPhaseType,gravity) {
  18495. if(broadPhaseType == null) {
  18496. broadPhaseType = 2;
  18497. }
  18498. switch(broadPhaseType) {
  18499. case 1:
  18500. this._broadPhase = new oimo.collision.broadphase.bruteforce.BruteForceBroadPhase();
  18501. break;
  18502. case 2:
  18503. this._broadPhase = new oimo.collision.broadphase.bvh.BvhBroadPhase();
  18504. break;
  18505. }
  18506. this._contactManager = new oimo.dynamics.ContactManager(this._broadPhase);
  18507. if(gravity == null) {
  18508. gravity = new oimo.common.Vec3(0,-9.80665,0);
  18509. }
  18510. this._gravity = new oimo.common.Vec3(gravity.x,gravity.y,gravity.z);
  18511. this._rigidBodyList = null;
  18512. this._rigidBodyListLast = null;
  18513. this._jointList = null;
  18514. this._jointListLast = null;
  18515. this._numRigidBodies = 0;
  18516. this._numShapes = 0;
  18517. this._numJoints = 0;
  18518. this._numIslands = 0;
  18519. this._numVelocityIterations = 10;
  18520. this._numPositionIterations = 5;
  18521. this._rayCastWrapper = new oimo.dynamics._World.RayCastWrapper();
  18522. this._convexCastWrapper = new oimo.dynamics._World.ConvexCastWrapper();
  18523. this._aabbTestWrapper = new oimo.dynamics._World.AabbTestWrapper();
  18524. this._island = new oimo.dynamics.Island();
  18525. var this1 = new Array(oimo.common.Setting.islandInitialConstraintArraySize);
  18526. this._solversInIslands = this1;
  18527. var this2 = new Array(oimo.common.Setting.islandInitialRigidBodyArraySize);
  18528. this._rigidBodyStack = this2;
  18529. this._timeStep = new oimo.dynamics.TimeStep();
  18530. this._pool = new oimo.common.Pool();
  18531. this._shapeIdCount = 0;
  18532. }
  18533. _updateContacts() {
  18534. var st = Date.now() / 1000;
  18535. this._contactManager._updateContacts();
  18536. var en = Date.now() / 1000;
  18537. oimo.dynamics.common.Performance.broadPhaseCollisionTime = (en - st) * 1000;
  18538. var st1 = Date.now() / 1000;
  18539. var c = this._contactManager._contactList;
  18540. while(c != null) {
  18541. var n = c._next;
  18542. if(!c._shouldBeSkipped) {
  18543. c._updateManifold();
  18544. }
  18545. c = n;
  18546. }
  18547. var en1 = Date.now() / 1000;
  18548. oimo.dynamics.common.Performance.narrowPhaseCollisionTime = (en1 - st1) * 1000;
  18549. }
  18550. _solveIslands() {
  18551. var st = Date.now() / 1000;
  18552. if(oimo.common.Setting.disableSleeping) {
  18553. var b = this._rigidBodyList;
  18554. while(b != null) {
  18555. var n = b._next;
  18556. b._sleeping = false;
  18557. b._sleepTime = 0;
  18558. b = n;
  18559. }
  18560. }
  18561. if(this._rigidBodyStack.length < this._numRigidBodies) {
  18562. var newStackSize = this._rigidBodyStack.length << 1;
  18563. while(newStackSize < this._numRigidBodies) newStackSize <<= 1;
  18564. var this1 = new Array(newStackSize);
  18565. this._rigidBodyStack = this1;
  18566. }
  18567. this._numIslands = 0;
  18568. var _this = this._island;
  18569. var v = this._gravity;
  18570. _this.gravityX = v.x;
  18571. _this.gravityY = v.y;
  18572. _this.gravityZ = v.z;
  18573. var b1 = this._rigidBodyList;
  18574. this._numSolversInIslands = 0;
  18575. while(b1 != null) {
  18576. var n1 = b1._next;
  18577. while(!(b1._addedToIsland || b1._sleeping || b1._type == 1)) {
  18578. if(b1._numContactLinks == 0 && b1._numJointLinks == 0) {
  18579. this._island._stepSingleRigidBody(this._timeStep,b1);
  18580. this._numIslands++;
  18581. break;
  18582. }
  18583. this.buildIsland(b1);
  18584. this._island._step(this._timeStep,this._numVelocityIterations,this._numPositionIterations);
  18585. this._island._clear();
  18586. this._numIslands++;
  18587. if(!false) {
  18588. break;
  18589. }
  18590. }
  18591. b1 = n1;
  18592. }
  18593. this._contactManager._postSolve();
  18594. b1 = this._rigidBodyList;
  18595. while(b1 != null) {
  18596. var n2 = b1._next;
  18597. b1._addedToIsland = false;
  18598. b1 = n2;
  18599. }
  18600. b1 = this._rigidBodyList;
  18601. while(b1 != null) {
  18602. var n3 = b1._next;
  18603. b1._forceX = 0;
  18604. b1._forceY = 0;
  18605. b1._forceZ = 0;
  18606. b1._torqueX = 0;
  18607. b1._torqueY = 0;
  18608. b1._torqueZ = 0;
  18609. b1 = n3;
  18610. }
  18611. while(this._numSolversInIslands > 0) {
  18612. this._solversInIslands[--this._numSolversInIslands]._addedToIsland = false;
  18613. this._solversInIslands[this._numSolversInIslands] = null;
  18614. }
  18615. var en = Date.now() / 1000;
  18616. oimo.dynamics.common.Performance.dynamicsTime = (en - st) * 1000;
  18617. }
  18618. buildIsland(base) {
  18619. var stackCount = 1;
  18620. this._island._addRigidBody(base);
  18621. this._rigidBodyStack[0] = base;
  18622. while(stackCount > 0) {
  18623. var rb = this._rigidBodyStack[--stackCount];
  18624. this._rigidBodyStack[stackCount] = null;
  18625. if(rb._type == 1) {
  18626. continue;
  18627. }
  18628. var cl = rb._contactLinkList;
  18629. while(cl != null) {
  18630. var n = cl._next;
  18631. var cc = cl._contact._contactConstraint;
  18632. var ccs = cl._contact._contactConstraint._solver;
  18633. if(cc.isTouching() && !ccs._addedToIsland) {
  18634. if(this._solversInIslands.length == this._numSolversInIslands) {
  18635. var newLength = this._numSolversInIslands << 1;
  18636. var this1 = new Array(newLength);
  18637. var newArray = this1;
  18638. var _g = 0;
  18639. var _g1 = this._numSolversInIslands;
  18640. while(_g < _g1) {
  18641. var i = _g++;
  18642. newArray[i] = this._solversInIslands[i];
  18643. this._solversInIslands[i] = null;
  18644. }
  18645. this._solversInIslands = newArray;
  18646. }
  18647. this._solversInIslands[this._numSolversInIslands++] = ccs;
  18648. this._island._addConstraintSolver(ccs,cc._positionCorrectionAlgorithm);
  18649. var other = cl._other;
  18650. if(!other._addedToIsland) {
  18651. this._island._addRigidBody(other);
  18652. this._rigidBodyStack[stackCount++] = other;
  18653. }
  18654. }
  18655. cl = n;
  18656. }
  18657. var jl = rb._jointLinkList;
  18658. while(jl != null) {
  18659. var n1 = jl._next;
  18660. var j = jl._joint;
  18661. var js1 = j._solver;
  18662. if(!js1._addedToIsland) {
  18663. if(this._solversInIslands.length == this._numSolversInIslands) {
  18664. var newLength1 = this._numSolversInIslands << 1;
  18665. var this2 = new Array(newLength1);
  18666. var newArray1 = this2;
  18667. var _g2 = 0;
  18668. var _g11 = this._numSolversInIslands;
  18669. while(_g2 < _g11) {
  18670. var i1 = _g2++;
  18671. newArray1[i1] = this._solversInIslands[i1];
  18672. this._solversInIslands[i1] = null;
  18673. }
  18674. this._solversInIslands = newArray1;
  18675. }
  18676. this._solversInIslands[this._numSolversInIslands++] = js1;
  18677. this._island._addConstraintSolver(js1,j._positionCorrectionAlgorithm);
  18678. var other1 = jl._other;
  18679. if(!other1._addedToIsland) {
  18680. this._island._addRigidBody(other1);
  18681. this._rigidBodyStack[stackCount++] = other1;
  18682. }
  18683. }
  18684. jl = n1;
  18685. }
  18686. }
  18687. }
  18688. _drawBvh(d,tree) {
  18689. if(d.drawBvh) {
  18690. this._drawBvhNode(d,tree._root,0,d.style.bvhNodeColor);
  18691. }
  18692. }
  18693. _drawBvhNode(d,node,level,color) {
  18694. if(node == null) {
  18695. return;
  18696. }
  18697. if(level >= d.drawBvhMinLevel && level <= d.drawBvhMaxLevel) {
  18698. var _this = this._pool;
  18699. var min = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  18700. var _this1 = this._pool;
  18701. var max = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  18702. var v = min;
  18703. v.x = node._aabbMinX;
  18704. v.y = node._aabbMinY;
  18705. v.z = node._aabbMinZ;
  18706. var v1 = max;
  18707. v1.x = node._aabbMaxX;
  18708. v1.y = node._aabbMaxY;
  18709. v1.z = node._aabbMaxZ;
  18710. d.aabb(min,max,color);
  18711. var _this2 = this._pool;
  18712. var mat3 = null;
  18713. var mat4 = null;
  18714. var quat = null;
  18715. if(min != null) {
  18716. min.zero();
  18717. if(_this2.sizeVec3 == _this2.stackVec3.length) {
  18718. var newLength = _this2.sizeVec3 << 1;
  18719. var this1 = new Array(newLength);
  18720. var newArray = this1;
  18721. var _g = 0;
  18722. var _g1 = _this2.sizeVec3;
  18723. while(_g < _g1) {
  18724. var i = _g++;
  18725. newArray[i] = _this2.stackVec3[i];
  18726. _this2.stackVec3[i] = null;
  18727. }
  18728. _this2.stackVec3 = newArray;
  18729. }
  18730. _this2.stackVec3[_this2.sizeVec3++] = min;
  18731. }
  18732. if(mat3 != null) {
  18733. var t00 = 1;
  18734. var t01 = 0;
  18735. var t02 = 0;
  18736. var t10 = 0;
  18737. var t11 = 1;
  18738. var t12 = 0;
  18739. var t20 = 0;
  18740. var t21 = 0;
  18741. var t22 = 1;
  18742. mat3.e00 = t00;
  18743. mat3.e01 = t01;
  18744. mat3.e02 = t02;
  18745. mat3.e10 = t10;
  18746. mat3.e11 = t11;
  18747. mat3.e12 = t12;
  18748. mat3.e20 = t20;
  18749. mat3.e21 = t21;
  18750. mat3.e22 = t22;
  18751. if(_this2.sizeMat3 == _this2.stackMat3.length) {
  18752. var newLength1 = _this2.sizeMat3 << 1;
  18753. var this2 = new Array(newLength1);
  18754. var newArray1 = this2;
  18755. var _g2 = 0;
  18756. var _g11 = _this2.sizeMat3;
  18757. while(_g2 < _g11) {
  18758. var i1 = _g2++;
  18759. newArray1[i1] = _this2.stackMat3[i1];
  18760. _this2.stackMat3[i1] = null;
  18761. }
  18762. _this2.stackMat3 = newArray1;
  18763. }
  18764. _this2.stackMat3[_this2.sizeMat3++] = mat3;
  18765. }
  18766. if(mat4 != null) {
  18767. var t001 = 1;
  18768. var t011 = 0;
  18769. var t021 = 0;
  18770. var t03 = 0;
  18771. var t101 = 0;
  18772. var t111 = 1;
  18773. var t121 = 0;
  18774. var t13 = 0;
  18775. var t201 = 0;
  18776. var t211 = 0;
  18777. var t221 = 1;
  18778. var t23 = 0;
  18779. var t30 = 0;
  18780. var t31 = 0;
  18781. var t32 = 0;
  18782. var t33 = 1;
  18783. mat4.e00 = t001;
  18784. mat4.e01 = t011;
  18785. mat4.e02 = t021;
  18786. mat4.e03 = t03;
  18787. mat4.e10 = t101;
  18788. mat4.e11 = t111;
  18789. mat4.e12 = t121;
  18790. mat4.e13 = t13;
  18791. mat4.e20 = t201;
  18792. mat4.e21 = t211;
  18793. mat4.e22 = t221;
  18794. mat4.e23 = t23;
  18795. mat4.e30 = t30;
  18796. mat4.e31 = t31;
  18797. mat4.e32 = t32;
  18798. mat4.e33 = t33;
  18799. if(_this2.sizeMat4 == _this2.stackMat4.length) {
  18800. var newLength2 = _this2.sizeMat4 << 1;
  18801. var this3 = new Array(newLength2);
  18802. var newArray2 = this3;
  18803. var _g3 = 0;
  18804. var _g12 = _this2.sizeMat4;
  18805. while(_g3 < _g12) {
  18806. var i2 = _g3++;
  18807. newArray2[i2] = _this2.stackMat4[i2];
  18808. _this2.stackMat4[i2] = null;
  18809. }
  18810. _this2.stackMat4 = newArray2;
  18811. }
  18812. _this2.stackMat4[_this2.sizeMat4++] = mat4;
  18813. }
  18814. if(quat != null) {
  18815. var tx = 0;
  18816. var ty = 0;
  18817. var tz = 0;
  18818. var tw = 1;
  18819. quat.x = tx;
  18820. quat.y = ty;
  18821. quat.z = tz;
  18822. quat.w = tw;
  18823. if(_this2.sizeQuat == _this2.stackQuat.length) {
  18824. var newLength3 = _this2.sizeQuat << 1;
  18825. var this4 = new Array(newLength3);
  18826. var newArray3 = this4;
  18827. var _g4 = 0;
  18828. var _g13 = _this2.sizeQuat;
  18829. while(_g4 < _g13) {
  18830. var i3 = _g4++;
  18831. newArray3[i3] = _this2.stackQuat[i3];
  18832. _this2.stackQuat[i3] = null;
  18833. }
  18834. _this2.stackQuat = newArray3;
  18835. }
  18836. _this2.stackQuat[_this2.sizeQuat++] = quat;
  18837. }
  18838. var _this3 = this._pool;
  18839. var mat31 = null;
  18840. var mat41 = null;
  18841. var quat1 = null;
  18842. if(max != null) {
  18843. max.zero();
  18844. if(_this3.sizeVec3 == _this3.stackVec3.length) {
  18845. var newLength4 = _this3.sizeVec3 << 1;
  18846. var this5 = new Array(newLength4);
  18847. var newArray4 = this5;
  18848. var _g5 = 0;
  18849. var _g14 = _this3.sizeVec3;
  18850. while(_g5 < _g14) {
  18851. var i4 = _g5++;
  18852. newArray4[i4] = _this3.stackVec3[i4];
  18853. _this3.stackVec3[i4] = null;
  18854. }
  18855. _this3.stackVec3 = newArray4;
  18856. }
  18857. _this3.stackVec3[_this3.sizeVec3++] = max;
  18858. }
  18859. if(mat31 != null) {
  18860. var t002 = 1;
  18861. var t012 = 0;
  18862. var t022 = 0;
  18863. var t102 = 0;
  18864. var t112 = 1;
  18865. var t122 = 0;
  18866. var t202 = 0;
  18867. var t212 = 0;
  18868. var t222 = 1;
  18869. mat31.e00 = t002;
  18870. mat31.e01 = t012;
  18871. mat31.e02 = t022;
  18872. mat31.e10 = t102;
  18873. mat31.e11 = t112;
  18874. mat31.e12 = t122;
  18875. mat31.e20 = t202;
  18876. mat31.e21 = t212;
  18877. mat31.e22 = t222;
  18878. if(_this3.sizeMat3 == _this3.stackMat3.length) {
  18879. var newLength5 = _this3.sizeMat3 << 1;
  18880. var this6 = new Array(newLength5);
  18881. var newArray5 = this6;
  18882. var _g6 = 0;
  18883. var _g15 = _this3.sizeMat3;
  18884. while(_g6 < _g15) {
  18885. var i5 = _g6++;
  18886. newArray5[i5] = _this3.stackMat3[i5];
  18887. _this3.stackMat3[i5] = null;
  18888. }
  18889. _this3.stackMat3 = newArray5;
  18890. }
  18891. _this3.stackMat3[_this3.sizeMat3++] = mat31;
  18892. }
  18893. if(mat41 != null) {
  18894. var t003 = 1;
  18895. var t013 = 0;
  18896. var t023 = 0;
  18897. var t031 = 0;
  18898. var t103 = 0;
  18899. var t113 = 1;
  18900. var t123 = 0;
  18901. var t131 = 0;
  18902. var t203 = 0;
  18903. var t213 = 0;
  18904. var t223 = 1;
  18905. var t231 = 0;
  18906. var t301 = 0;
  18907. var t311 = 0;
  18908. var t321 = 0;
  18909. var t331 = 1;
  18910. mat41.e00 = t003;
  18911. mat41.e01 = t013;
  18912. mat41.e02 = t023;
  18913. mat41.e03 = t031;
  18914. mat41.e10 = t103;
  18915. mat41.e11 = t113;
  18916. mat41.e12 = t123;
  18917. mat41.e13 = t131;
  18918. mat41.e20 = t203;
  18919. mat41.e21 = t213;
  18920. mat41.e22 = t223;
  18921. mat41.e23 = t231;
  18922. mat41.e30 = t301;
  18923. mat41.e31 = t311;
  18924. mat41.e32 = t321;
  18925. mat41.e33 = t331;
  18926. if(_this3.sizeMat4 == _this3.stackMat4.length) {
  18927. var newLength6 = _this3.sizeMat4 << 1;
  18928. var this7 = new Array(newLength6);
  18929. var newArray6 = this7;
  18930. var _g7 = 0;
  18931. var _g16 = _this3.sizeMat4;
  18932. while(_g7 < _g16) {
  18933. var i6 = _g7++;
  18934. newArray6[i6] = _this3.stackMat4[i6];
  18935. _this3.stackMat4[i6] = null;
  18936. }
  18937. _this3.stackMat4 = newArray6;
  18938. }
  18939. _this3.stackMat4[_this3.sizeMat4++] = mat41;
  18940. }
  18941. if(quat1 != null) {
  18942. var tx1 = 0;
  18943. var ty1 = 0;
  18944. var tz1 = 0;
  18945. var tw1 = 1;
  18946. quat1.x = tx1;
  18947. quat1.y = ty1;
  18948. quat1.z = tz1;
  18949. quat1.w = tw1;
  18950. if(_this3.sizeQuat == _this3.stackQuat.length) {
  18951. var newLength7 = _this3.sizeQuat << 1;
  18952. var this8 = new Array(newLength7);
  18953. var newArray7 = this8;
  18954. var _g8 = 0;
  18955. var _g17 = _this3.sizeQuat;
  18956. while(_g8 < _g17) {
  18957. var i7 = _g8++;
  18958. newArray7[i7] = _this3.stackQuat[i7];
  18959. _this3.stackQuat[i7] = null;
  18960. }
  18961. _this3.stackQuat = newArray7;
  18962. }
  18963. _this3.stackQuat[_this3.sizeQuat++] = quat1;
  18964. }
  18965. }
  18966. this._drawBvhNode(d,node._children[0],level + 1,color);
  18967. this._drawBvhNode(d,node._children[1],level + 1,color);
  18968. }
  18969. _drawRigidBodies(d) {
  18970. var style = d.style;
  18971. var r = this._rigidBodyList;
  18972. while(r != null) {
  18973. var n = r._next;
  18974. if(d.drawBases) {
  18975. var style1 = d.style;
  18976. d.basis(r._transform,style1.basisLength,style1.basisColorX,style1.basisColorY,style1.basisColorZ);
  18977. }
  18978. var shapeColor = null;
  18979. var isDynamic = r._type == 0;
  18980. if(!isDynamic) {
  18981. shapeColor = r._type == 2 ? style.kinematicShapeColor : style.staticShapeColor;
  18982. }
  18983. var s = r._shapeList;
  18984. while(s != null) {
  18985. var n1 = s._next;
  18986. if(isDynamic) {
  18987. if((s._id & 1) == 0) {
  18988. shapeColor = r._sleeping ? style.sleepingShapeColor1 : r._sleepTime > oimo.common.Setting.sleepingTimeThreshold ? style.sleepyShapeColor1 : style.shapeColor1;
  18989. } else {
  18990. shapeColor = r._sleeping ? style.sleepingShapeColor2 : r._sleepTime > oimo.common.Setting.sleepingTimeThreshold ? style.sleepyShapeColor2 : style.shapeColor2;
  18991. }
  18992. }
  18993. if(d.drawShapes) {
  18994. var geom = s._geom;
  18995. var tf = s._transform;
  18996. switch(geom._type) {
  18997. case 0:
  18998. d.sphere(tf,geom._radius,shapeColor);
  18999. break;
  19000. case 1:
  19001. var g = geom;
  19002. var _this = this._pool;
  19003. var hx = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  19004. var v = hx;
  19005. v.x = g._halfExtentsX;
  19006. v.y = g._halfExtentsY;
  19007. v.z = g._halfExtentsZ;
  19008. d.box(tf,hx,shapeColor);
  19009. var _this1 = this._pool;
  19010. var mat3 = null;
  19011. var mat4 = null;
  19012. var quat = null;
  19013. if(hx != null) {
  19014. hx.zero();
  19015. if(_this1.sizeVec3 == _this1.stackVec3.length) {
  19016. var newLength = _this1.sizeVec3 << 1;
  19017. var this1 = new Array(newLength);
  19018. var newArray = this1;
  19019. var _g = 0;
  19020. var _g1 = _this1.sizeVec3;
  19021. while(_g < _g1) {
  19022. var i = _g++;
  19023. newArray[i] = _this1.stackVec3[i];
  19024. _this1.stackVec3[i] = null;
  19025. }
  19026. _this1.stackVec3 = newArray;
  19027. }
  19028. _this1.stackVec3[_this1.sizeVec3++] = hx;
  19029. }
  19030. if(mat3 != null) {
  19031. var t00 = 1;
  19032. var t01 = 0;
  19033. var t02 = 0;
  19034. var t10 = 0;
  19035. var t11 = 1;
  19036. var t12 = 0;
  19037. var t20 = 0;
  19038. var t21 = 0;
  19039. var t22 = 1;
  19040. mat3.e00 = t00;
  19041. mat3.e01 = t01;
  19042. mat3.e02 = t02;
  19043. mat3.e10 = t10;
  19044. mat3.e11 = t11;
  19045. mat3.e12 = t12;
  19046. mat3.e20 = t20;
  19047. mat3.e21 = t21;
  19048. mat3.e22 = t22;
  19049. if(_this1.sizeMat3 == _this1.stackMat3.length) {
  19050. var newLength1 = _this1.sizeMat3 << 1;
  19051. var this2 = new Array(newLength1);
  19052. var newArray1 = this2;
  19053. var _g2 = 0;
  19054. var _g11 = _this1.sizeMat3;
  19055. while(_g2 < _g11) {
  19056. var i1 = _g2++;
  19057. newArray1[i1] = _this1.stackMat3[i1];
  19058. _this1.stackMat3[i1] = null;
  19059. }
  19060. _this1.stackMat3 = newArray1;
  19061. }
  19062. _this1.stackMat3[_this1.sizeMat3++] = mat3;
  19063. }
  19064. if(mat4 != null) {
  19065. var t001 = 1;
  19066. var t011 = 0;
  19067. var t021 = 0;
  19068. var t03 = 0;
  19069. var t101 = 0;
  19070. var t111 = 1;
  19071. var t121 = 0;
  19072. var t13 = 0;
  19073. var t201 = 0;
  19074. var t211 = 0;
  19075. var t221 = 1;
  19076. var t23 = 0;
  19077. var t30 = 0;
  19078. var t31 = 0;
  19079. var t32 = 0;
  19080. var t33 = 1;
  19081. mat4.e00 = t001;
  19082. mat4.e01 = t011;
  19083. mat4.e02 = t021;
  19084. mat4.e03 = t03;
  19085. mat4.e10 = t101;
  19086. mat4.e11 = t111;
  19087. mat4.e12 = t121;
  19088. mat4.e13 = t13;
  19089. mat4.e20 = t201;
  19090. mat4.e21 = t211;
  19091. mat4.e22 = t221;
  19092. mat4.e23 = t23;
  19093. mat4.e30 = t30;
  19094. mat4.e31 = t31;
  19095. mat4.e32 = t32;
  19096. mat4.e33 = t33;
  19097. if(_this1.sizeMat4 == _this1.stackMat4.length) {
  19098. var newLength2 = _this1.sizeMat4 << 1;
  19099. var this3 = new Array(newLength2);
  19100. var newArray2 = this3;
  19101. var _g3 = 0;
  19102. var _g12 = _this1.sizeMat4;
  19103. while(_g3 < _g12) {
  19104. var i2 = _g3++;
  19105. newArray2[i2] = _this1.stackMat4[i2];
  19106. _this1.stackMat4[i2] = null;
  19107. }
  19108. _this1.stackMat4 = newArray2;
  19109. }
  19110. _this1.stackMat4[_this1.sizeMat4++] = mat4;
  19111. }
  19112. if(quat != null) {
  19113. var tx = 0;
  19114. var ty = 0;
  19115. var tz = 0;
  19116. var tw = 1;
  19117. quat.x = tx;
  19118. quat.y = ty;
  19119. quat.z = tz;
  19120. quat.w = tw;
  19121. if(_this1.sizeQuat == _this1.stackQuat.length) {
  19122. var newLength3 = _this1.sizeQuat << 1;
  19123. var this4 = new Array(newLength3);
  19124. var newArray3 = this4;
  19125. var _g4 = 0;
  19126. var _g13 = _this1.sizeQuat;
  19127. while(_g4 < _g13) {
  19128. var i3 = _g4++;
  19129. newArray3[i3] = _this1.stackQuat[i3];
  19130. _this1.stackQuat[i3] = null;
  19131. }
  19132. _this1.stackQuat = newArray3;
  19133. }
  19134. _this1.stackQuat[_this1.sizeQuat++] = quat;
  19135. }
  19136. break;
  19137. case 2:
  19138. var g1 = geom;
  19139. d.cylinder(tf,g1._radius,g1._halfHeight,shapeColor);
  19140. break;
  19141. case 3:
  19142. var g2 = geom;
  19143. d.cone(tf,g2._radius,g2._halfHeight,shapeColor);
  19144. break;
  19145. case 4:
  19146. var g3 = geom;
  19147. d.capsule(tf,g3._radius,g3._halfHeight,shapeColor);
  19148. break;
  19149. case 5:
  19150. var g4 = geom;
  19151. var n2 = g4._numVertices;
  19152. var _this2 = this._pool;
  19153. var v1 = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  19154. var _this3 = this._pool;
  19155. var v2 = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  19156. var _this4 = this._pool;
  19157. var v3 = _this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3];
  19158. var _this5 = this._pool;
  19159. var v12 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3];
  19160. var _this6 = this._pool;
  19161. var v13 = _this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3];
  19162. var _this7 = this._pool;
  19163. var normal = _this7.sizeVec3 == 0 ? new oimo.common.Vec3() : _this7.stackVec3[--_this7.sizeVec3];
  19164. var _this8 = this._pool;
  19165. var m = _this8.sizeMat3 == 0 ? new oimo.common.Mat3() : _this8.stackMat3[--_this8.sizeMat3];
  19166. var _this9 = this._pool;
  19167. var o = _this9.sizeVec3 == 0 ? new oimo.common.Vec3() : _this9.stackVec3[--_this9.sizeVec3];
  19168. var m1 = m;
  19169. m1.e00 = tf._rotation00;
  19170. m1.e01 = tf._rotation01;
  19171. m1.e02 = tf._rotation02;
  19172. m1.e10 = tf._rotation10;
  19173. m1.e11 = tf._rotation11;
  19174. m1.e12 = tf._rotation12;
  19175. m1.e20 = tf._rotation20;
  19176. m1.e21 = tf._rotation21;
  19177. m1.e22 = tf._rotation22;
  19178. var v4 = o;
  19179. v4.x = tf._positionX;
  19180. v4.y = tf._positionY;
  19181. v4.z = tf._positionZ;
  19182. var _g5 = 0;
  19183. var _g14 = n2;
  19184. while(_g5 < _g14) {
  19185. var i4 = _g5++;
  19186. var _this10 = g4._tmpVertices[i4];
  19187. var v5 = g4._vertices[i4];
  19188. _this10.x = v5.x;
  19189. _this10.y = v5.y;
  19190. _this10.z = v5.z;
  19191. var _this11 = _this10;
  19192. var tx1 = _this11.x * m.e00 + _this11.y * m.e01 + _this11.z * m.e02;
  19193. var ty1 = _this11.x * m.e10 + _this11.y * m.e11 + _this11.z * m.e12;
  19194. var tz1 = _this11.x * m.e20 + _this11.y * m.e21 + _this11.z * m.e22;
  19195. _this11.x = tx1;
  19196. _this11.y = ty1;
  19197. _this11.z = tz1;
  19198. var _this12 = _this11;
  19199. var tx2 = _this12.x + o.x;
  19200. var ty2 = _this12.y + o.y;
  19201. var tz2 = _this12.z + o.z;
  19202. _this12.x = tx2;
  19203. _this12.y = ty2;
  19204. _this12.z = tz2;
  19205. }
  19206. if(n2 > 30) {
  19207. var _g21 = 0;
  19208. var _g31 = n2;
  19209. while(_g21 < _g31) {
  19210. var i5 = _g21++;
  19211. var v6 = g4._tmpVertices[i5];
  19212. v1.x = v6.x;
  19213. v1.y = v6.y;
  19214. v1.z = v6.z;
  19215. var v7 = g4._tmpVertices[(i5 + 1) % n2];
  19216. v2.x = v7.x;
  19217. v2.y = v7.y;
  19218. v2.z = v7.z;
  19219. d.line(v1,v2,shapeColor);
  19220. }
  19221. } else if(this._debugDraw.wireframe || n2 > 10) {
  19222. var _g22 = 0;
  19223. var _g32 = n2;
  19224. while(_g22 < _g32) {
  19225. var i6 = _g22++;
  19226. var v8 = g4._tmpVertices[i6];
  19227. v1.x = v8.x;
  19228. v1.y = v8.y;
  19229. v1.z = v8.z;
  19230. var _g23 = 0;
  19231. var _g33 = i6;
  19232. while(_g23 < _g33) {
  19233. var j = _g23++;
  19234. var v9 = g4._tmpVertices[j];
  19235. v2.x = v9.x;
  19236. v2.y = v9.y;
  19237. v2.z = v9.z;
  19238. d.line(v1,v2,shapeColor);
  19239. }
  19240. }
  19241. } else {
  19242. var _g24 = 0;
  19243. var _g34 = n2;
  19244. while(_g24 < _g34) {
  19245. var i7 = _g24++;
  19246. var v10 = g4._tmpVertices[i7];
  19247. v1.x = v10.x;
  19248. v1.y = v10.y;
  19249. v1.z = v10.z;
  19250. var _g25 = 0;
  19251. var _g35 = i7;
  19252. while(_g25 < _g35) {
  19253. var j1 = _g25++;
  19254. var v11 = g4._tmpVertices[j1];
  19255. v2.x = v11.x;
  19256. v2.y = v11.y;
  19257. v2.z = v11.z;
  19258. var _g26 = 0;
  19259. var _g36 = j1;
  19260. while(_g26 < _g36) {
  19261. var k = _g26++;
  19262. var v14 = g4._tmpVertices[k];
  19263. v3.x = v14.x;
  19264. v3.y = v14.y;
  19265. v3.z = v14.z;
  19266. v12.x = v2.x;
  19267. v12.y = v2.y;
  19268. v12.z = v2.z;
  19269. var _this13 = v12;
  19270. var tx3 = _this13.x - v1.x;
  19271. var ty3 = _this13.y - v1.y;
  19272. var tz3 = _this13.z - v1.z;
  19273. _this13.x = tx3;
  19274. _this13.y = ty3;
  19275. _this13.z = tz3;
  19276. v13.x = v3.x;
  19277. v13.y = v3.y;
  19278. v13.z = v3.z;
  19279. var _this14 = v13;
  19280. var tx4 = _this14.x - v1.x;
  19281. var ty4 = _this14.y - v1.y;
  19282. var tz4 = _this14.z - v1.z;
  19283. _this14.x = tx4;
  19284. _this14.y = ty4;
  19285. _this14.z = tz4;
  19286. normal.x = v12.x;
  19287. normal.y = v12.y;
  19288. normal.z = v12.z;
  19289. var _this15 = normal;
  19290. var tx5 = _this15.y * v13.z - _this15.z * v13.y;
  19291. var ty5 = _this15.z * v13.x - _this15.x * v13.z;
  19292. var tz5 = _this15.x * v13.y - _this15.y * v13.x;
  19293. _this15.x = tx5;
  19294. _this15.y = ty5;
  19295. _this15.z = tz5;
  19296. var _this16 = _this15;
  19297. var invLen = Math.sqrt(_this16.x * _this16.x + _this16.y * _this16.y + _this16.z * _this16.z);
  19298. if(invLen > 0) {
  19299. invLen = 1 / invLen;
  19300. }
  19301. var tx6 = _this16.x * invLen;
  19302. var ty6 = _this16.y * invLen;
  19303. var tz6 = _this16.z * invLen;
  19304. _this16.x = tx6;
  19305. _this16.y = ty6;
  19306. _this16.z = tz6;
  19307. d.triangle(v1,v2,v3,normal,normal,normal,shapeColor);
  19308. var tx7 = -normal.x;
  19309. var ty7 = -normal.y;
  19310. var tz7 = -normal.z;
  19311. normal.x = tx7;
  19312. normal.y = ty7;
  19313. normal.z = tz7;
  19314. d.triangle(v1,v3,v2,normal,normal,normal,shapeColor);
  19315. }
  19316. }
  19317. }
  19318. }
  19319. var _this17 = this._pool;
  19320. var mat31 = null;
  19321. var mat41 = null;
  19322. var quat1 = null;
  19323. if(v1 != null) {
  19324. v1.zero();
  19325. if(_this17.sizeVec3 == _this17.stackVec3.length) {
  19326. var newLength4 = _this17.sizeVec3 << 1;
  19327. var this5 = new Array(newLength4);
  19328. var newArray4 = this5;
  19329. var _g6 = 0;
  19330. var _g15 = _this17.sizeVec3;
  19331. while(_g6 < _g15) {
  19332. var i8 = _g6++;
  19333. newArray4[i8] = _this17.stackVec3[i8];
  19334. _this17.stackVec3[i8] = null;
  19335. }
  19336. _this17.stackVec3 = newArray4;
  19337. }
  19338. _this17.stackVec3[_this17.sizeVec3++] = v1;
  19339. }
  19340. if(mat31 != null) {
  19341. var t002 = 1;
  19342. var t012 = 0;
  19343. var t022 = 0;
  19344. var t102 = 0;
  19345. var t112 = 1;
  19346. var t122 = 0;
  19347. var t202 = 0;
  19348. var t212 = 0;
  19349. var t222 = 1;
  19350. mat31.e00 = t002;
  19351. mat31.e01 = t012;
  19352. mat31.e02 = t022;
  19353. mat31.e10 = t102;
  19354. mat31.e11 = t112;
  19355. mat31.e12 = t122;
  19356. mat31.e20 = t202;
  19357. mat31.e21 = t212;
  19358. mat31.e22 = t222;
  19359. if(_this17.sizeMat3 == _this17.stackMat3.length) {
  19360. var newLength5 = _this17.sizeMat3 << 1;
  19361. var this6 = new Array(newLength5);
  19362. var newArray5 = this6;
  19363. var _g7 = 0;
  19364. var _g16 = _this17.sizeMat3;
  19365. while(_g7 < _g16) {
  19366. var i9 = _g7++;
  19367. newArray5[i9] = _this17.stackMat3[i9];
  19368. _this17.stackMat3[i9] = null;
  19369. }
  19370. _this17.stackMat3 = newArray5;
  19371. }
  19372. _this17.stackMat3[_this17.sizeMat3++] = mat31;
  19373. }
  19374. if(mat41 != null) {
  19375. var t003 = 1;
  19376. var t013 = 0;
  19377. var t023 = 0;
  19378. var t031 = 0;
  19379. var t103 = 0;
  19380. var t113 = 1;
  19381. var t123 = 0;
  19382. var t131 = 0;
  19383. var t203 = 0;
  19384. var t213 = 0;
  19385. var t223 = 1;
  19386. var t231 = 0;
  19387. var t301 = 0;
  19388. var t311 = 0;
  19389. var t321 = 0;
  19390. var t331 = 1;
  19391. mat41.e00 = t003;
  19392. mat41.e01 = t013;
  19393. mat41.e02 = t023;
  19394. mat41.e03 = t031;
  19395. mat41.e10 = t103;
  19396. mat41.e11 = t113;
  19397. mat41.e12 = t123;
  19398. mat41.e13 = t131;
  19399. mat41.e20 = t203;
  19400. mat41.e21 = t213;
  19401. mat41.e22 = t223;
  19402. mat41.e23 = t231;
  19403. mat41.e30 = t301;
  19404. mat41.e31 = t311;
  19405. mat41.e32 = t321;
  19406. mat41.e33 = t331;
  19407. if(_this17.sizeMat4 == _this17.stackMat4.length) {
  19408. var newLength6 = _this17.sizeMat4 << 1;
  19409. var this7 = new Array(newLength6);
  19410. var newArray6 = this7;
  19411. var _g8 = 0;
  19412. var _g17 = _this17.sizeMat4;
  19413. while(_g8 < _g17) {
  19414. var i10 = _g8++;
  19415. newArray6[i10] = _this17.stackMat4[i10];
  19416. _this17.stackMat4[i10] = null;
  19417. }
  19418. _this17.stackMat4 = newArray6;
  19419. }
  19420. _this17.stackMat4[_this17.sizeMat4++] = mat41;
  19421. }
  19422. if(quat1 != null) {
  19423. var tx8 = 0;
  19424. var ty8 = 0;
  19425. var tz8 = 0;
  19426. var tw1 = 1;
  19427. quat1.x = tx8;
  19428. quat1.y = ty8;
  19429. quat1.z = tz8;
  19430. quat1.w = tw1;
  19431. if(_this17.sizeQuat == _this17.stackQuat.length) {
  19432. var newLength7 = _this17.sizeQuat << 1;
  19433. var this8 = new Array(newLength7);
  19434. var newArray7 = this8;
  19435. var _g9 = 0;
  19436. var _g18 = _this17.sizeQuat;
  19437. while(_g9 < _g18) {
  19438. var i11 = _g9++;
  19439. newArray7[i11] = _this17.stackQuat[i11];
  19440. _this17.stackQuat[i11] = null;
  19441. }
  19442. _this17.stackQuat = newArray7;
  19443. }
  19444. _this17.stackQuat[_this17.sizeQuat++] = quat1;
  19445. }
  19446. var _this18 = this._pool;
  19447. var mat32 = null;
  19448. var mat42 = null;
  19449. var quat2 = null;
  19450. if(v2 != null) {
  19451. v2.zero();
  19452. if(_this18.sizeVec3 == _this18.stackVec3.length) {
  19453. var newLength8 = _this18.sizeVec3 << 1;
  19454. var this9 = new Array(newLength8);
  19455. var newArray8 = this9;
  19456. var _g10 = 0;
  19457. var _g19 = _this18.sizeVec3;
  19458. while(_g10 < _g19) {
  19459. var i12 = _g10++;
  19460. newArray8[i12] = _this18.stackVec3[i12];
  19461. _this18.stackVec3[i12] = null;
  19462. }
  19463. _this18.stackVec3 = newArray8;
  19464. }
  19465. _this18.stackVec3[_this18.sizeVec3++] = v2;
  19466. }
  19467. if(mat32 != null) {
  19468. var t004 = 1;
  19469. var t014 = 0;
  19470. var t024 = 0;
  19471. var t104 = 0;
  19472. var t114 = 1;
  19473. var t124 = 0;
  19474. var t204 = 0;
  19475. var t214 = 0;
  19476. var t224 = 1;
  19477. mat32.e00 = t004;
  19478. mat32.e01 = t014;
  19479. mat32.e02 = t024;
  19480. mat32.e10 = t104;
  19481. mat32.e11 = t114;
  19482. mat32.e12 = t124;
  19483. mat32.e20 = t204;
  19484. mat32.e21 = t214;
  19485. mat32.e22 = t224;
  19486. if(_this18.sizeMat3 == _this18.stackMat3.length) {
  19487. var newLength9 = _this18.sizeMat3 << 1;
  19488. var this10 = new Array(newLength9);
  19489. var newArray9 = this10;
  19490. var _g20 = 0;
  19491. var _g110 = _this18.sizeMat3;
  19492. while(_g20 < _g110) {
  19493. var i13 = _g20++;
  19494. newArray9[i13] = _this18.stackMat3[i13];
  19495. _this18.stackMat3[i13] = null;
  19496. }
  19497. _this18.stackMat3 = newArray9;
  19498. }
  19499. _this18.stackMat3[_this18.sizeMat3++] = mat32;
  19500. }
  19501. if(mat42 != null) {
  19502. var t005 = 1;
  19503. var t015 = 0;
  19504. var t025 = 0;
  19505. var t032 = 0;
  19506. var t105 = 0;
  19507. var t115 = 1;
  19508. var t125 = 0;
  19509. var t132 = 0;
  19510. var t205 = 0;
  19511. var t215 = 0;
  19512. var t225 = 1;
  19513. var t232 = 0;
  19514. var t302 = 0;
  19515. var t312 = 0;
  19516. var t322 = 0;
  19517. var t332 = 1;
  19518. mat42.e00 = t005;
  19519. mat42.e01 = t015;
  19520. mat42.e02 = t025;
  19521. mat42.e03 = t032;
  19522. mat42.e10 = t105;
  19523. mat42.e11 = t115;
  19524. mat42.e12 = t125;
  19525. mat42.e13 = t132;
  19526. mat42.e20 = t205;
  19527. mat42.e21 = t215;
  19528. mat42.e22 = t225;
  19529. mat42.e23 = t232;
  19530. mat42.e30 = t302;
  19531. mat42.e31 = t312;
  19532. mat42.e32 = t322;
  19533. mat42.e33 = t332;
  19534. if(_this18.sizeMat4 == _this18.stackMat4.length) {
  19535. var newLength10 = _this18.sizeMat4 << 1;
  19536. var this11 = new Array(newLength10);
  19537. var newArray10 = this11;
  19538. var _g27 = 0;
  19539. var _g111 = _this18.sizeMat4;
  19540. while(_g27 < _g111) {
  19541. var i14 = _g27++;
  19542. newArray10[i14] = _this18.stackMat4[i14];
  19543. _this18.stackMat4[i14] = null;
  19544. }
  19545. _this18.stackMat4 = newArray10;
  19546. }
  19547. _this18.stackMat4[_this18.sizeMat4++] = mat42;
  19548. }
  19549. if(quat2 != null) {
  19550. var tx9 = 0;
  19551. var ty9 = 0;
  19552. var tz9 = 0;
  19553. var tw2 = 1;
  19554. quat2.x = tx9;
  19555. quat2.y = ty9;
  19556. quat2.z = tz9;
  19557. quat2.w = tw2;
  19558. if(_this18.sizeQuat == _this18.stackQuat.length) {
  19559. var newLength11 = _this18.sizeQuat << 1;
  19560. var this12 = new Array(newLength11);
  19561. var newArray11 = this12;
  19562. var _g28 = 0;
  19563. var _g112 = _this18.sizeQuat;
  19564. while(_g28 < _g112) {
  19565. var i15 = _g28++;
  19566. newArray11[i15] = _this18.stackQuat[i15];
  19567. _this18.stackQuat[i15] = null;
  19568. }
  19569. _this18.stackQuat = newArray11;
  19570. }
  19571. _this18.stackQuat[_this18.sizeQuat++] = quat2;
  19572. }
  19573. var _this19 = this._pool;
  19574. var mat33 = null;
  19575. var mat43 = null;
  19576. var quat3 = null;
  19577. if(v3 != null) {
  19578. v3.zero();
  19579. if(_this19.sizeVec3 == _this19.stackVec3.length) {
  19580. var newLength12 = _this19.sizeVec3 << 1;
  19581. var this13 = new Array(newLength12);
  19582. var newArray12 = this13;
  19583. var _g29 = 0;
  19584. var _g113 = _this19.sizeVec3;
  19585. while(_g29 < _g113) {
  19586. var i16 = _g29++;
  19587. newArray12[i16] = _this19.stackVec3[i16];
  19588. _this19.stackVec3[i16] = null;
  19589. }
  19590. _this19.stackVec3 = newArray12;
  19591. }
  19592. _this19.stackVec3[_this19.sizeVec3++] = v3;
  19593. }
  19594. if(mat33 != null) {
  19595. var t006 = 1;
  19596. var t016 = 0;
  19597. var t026 = 0;
  19598. var t106 = 0;
  19599. var t116 = 1;
  19600. var t126 = 0;
  19601. var t206 = 0;
  19602. var t216 = 0;
  19603. var t226 = 1;
  19604. mat33.e00 = t006;
  19605. mat33.e01 = t016;
  19606. mat33.e02 = t026;
  19607. mat33.e10 = t106;
  19608. mat33.e11 = t116;
  19609. mat33.e12 = t126;
  19610. mat33.e20 = t206;
  19611. mat33.e21 = t216;
  19612. mat33.e22 = t226;
  19613. if(_this19.sizeMat3 == _this19.stackMat3.length) {
  19614. var newLength13 = _this19.sizeMat3 << 1;
  19615. var this14 = new Array(newLength13);
  19616. var newArray13 = this14;
  19617. var _g30 = 0;
  19618. var _g114 = _this19.sizeMat3;
  19619. while(_g30 < _g114) {
  19620. var i17 = _g30++;
  19621. newArray13[i17] = _this19.stackMat3[i17];
  19622. _this19.stackMat3[i17] = null;
  19623. }
  19624. _this19.stackMat3 = newArray13;
  19625. }
  19626. _this19.stackMat3[_this19.sizeMat3++] = mat33;
  19627. }
  19628. if(mat43 != null) {
  19629. var t007 = 1;
  19630. var t017 = 0;
  19631. var t027 = 0;
  19632. var t033 = 0;
  19633. var t107 = 0;
  19634. var t117 = 1;
  19635. var t127 = 0;
  19636. var t133 = 0;
  19637. var t207 = 0;
  19638. var t217 = 0;
  19639. var t227 = 1;
  19640. var t233 = 0;
  19641. var t303 = 0;
  19642. var t313 = 0;
  19643. var t323 = 0;
  19644. var t333 = 1;
  19645. mat43.e00 = t007;
  19646. mat43.e01 = t017;
  19647. mat43.e02 = t027;
  19648. mat43.e03 = t033;
  19649. mat43.e10 = t107;
  19650. mat43.e11 = t117;
  19651. mat43.e12 = t127;
  19652. mat43.e13 = t133;
  19653. mat43.e20 = t207;
  19654. mat43.e21 = t217;
  19655. mat43.e22 = t227;
  19656. mat43.e23 = t233;
  19657. mat43.e30 = t303;
  19658. mat43.e31 = t313;
  19659. mat43.e32 = t323;
  19660. mat43.e33 = t333;
  19661. if(_this19.sizeMat4 == _this19.stackMat4.length) {
  19662. var newLength14 = _this19.sizeMat4 << 1;
  19663. var this15 = new Array(newLength14);
  19664. var newArray14 = this15;
  19665. var _g37 = 0;
  19666. var _g115 = _this19.sizeMat4;
  19667. while(_g37 < _g115) {
  19668. var i18 = _g37++;
  19669. newArray14[i18] = _this19.stackMat4[i18];
  19670. _this19.stackMat4[i18] = null;
  19671. }
  19672. _this19.stackMat4 = newArray14;
  19673. }
  19674. _this19.stackMat4[_this19.sizeMat4++] = mat43;
  19675. }
  19676. if(quat3 != null) {
  19677. var tx10 = 0;
  19678. var ty10 = 0;
  19679. var tz10 = 0;
  19680. var tw3 = 1;
  19681. quat3.x = tx10;
  19682. quat3.y = ty10;
  19683. quat3.z = tz10;
  19684. quat3.w = tw3;
  19685. if(_this19.sizeQuat == _this19.stackQuat.length) {
  19686. var newLength15 = _this19.sizeQuat << 1;
  19687. var this16 = new Array(newLength15);
  19688. var newArray15 = this16;
  19689. var _g38 = 0;
  19690. var _g116 = _this19.sizeQuat;
  19691. while(_g38 < _g116) {
  19692. var i19 = _g38++;
  19693. newArray15[i19] = _this19.stackQuat[i19];
  19694. _this19.stackQuat[i19] = null;
  19695. }
  19696. _this19.stackQuat = newArray15;
  19697. }
  19698. _this19.stackQuat[_this19.sizeQuat++] = quat3;
  19699. }
  19700. var _this20 = this._pool;
  19701. var mat34 = null;
  19702. var mat44 = null;
  19703. var quat4 = null;
  19704. if(v12 != null) {
  19705. v12.zero();
  19706. if(_this20.sizeVec3 == _this20.stackVec3.length) {
  19707. var newLength16 = _this20.sizeVec3 << 1;
  19708. var this17 = new Array(newLength16);
  19709. var newArray16 = this17;
  19710. var _g39 = 0;
  19711. var _g117 = _this20.sizeVec3;
  19712. while(_g39 < _g117) {
  19713. var i20 = _g39++;
  19714. newArray16[i20] = _this20.stackVec3[i20];
  19715. _this20.stackVec3[i20] = null;
  19716. }
  19717. _this20.stackVec3 = newArray16;
  19718. }
  19719. _this20.stackVec3[_this20.sizeVec3++] = v12;
  19720. }
  19721. if(mat34 != null) {
  19722. var t008 = 1;
  19723. var t018 = 0;
  19724. var t028 = 0;
  19725. var t108 = 0;
  19726. var t118 = 1;
  19727. var t128 = 0;
  19728. var t208 = 0;
  19729. var t218 = 0;
  19730. var t228 = 1;
  19731. mat34.e00 = t008;
  19732. mat34.e01 = t018;
  19733. mat34.e02 = t028;
  19734. mat34.e10 = t108;
  19735. mat34.e11 = t118;
  19736. mat34.e12 = t128;
  19737. mat34.e20 = t208;
  19738. mat34.e21 = t218;
  19739. mat34.e22 = t228;
  19740. if(_this20.sizeMat3 == _this20.stackMat3.length) {
  19741. var newLength17 = _this20.sizeMat3 << 1;
  19742. var this18 = new Array(newLength17);
  19743. var newArray17 = this18;
  19744. var _g40 = 0;
  19745. var _g118 = _this20.sizeMat3;
  19746. while(_g40 < _g118) {
  19747. var i21 = _g40++;
  19748. newArray17[i21] = _this20.stackMat3[i21];
  19749. _this20.stackMat3[i21] = null;
  19750. }
  19751. _this20.stackMat3 = newArray17;
  19752. }
  19753. _this20.stackMat3[_this20.sizeMat3++] = mat34;
  19754. }
  19755. if(mat44 != null) {
  19756. var t009 = 1;
  19757. var t019 = 0;
  19758. var t029 = 0;
  19759. var t034 = 0;
  19760. var t109 = 0;
  19761. var t119 = 1;
  19762. var t129 = 0;
  19763. var t134 = 0;
  19764. var t209 = 0;
  19765. var t219 = 0;
  19766. var t229 = 1;
  19767. var t234 = 0;
  19768. var t304 = 0;
  19769. var t314 = 0;
  19770. var t324 = 0;
  19771. var t334 = 1;
  19772. mat44.e00 = t009;
  19773. mat44.e01 = t019;
  19774. mat44.e02 = t029;
  19775. mat44.e03 = t034;
  19776. mat44.e10 = t109;
  19777. mat44.e11 = t119;
  19778. mat44.e12 = t129;
  19779. mat44.e13 = t134;
  19780. mat44.e20 = t209;
  19781. mat44.e21 = t219;
  19782. mat44.e22 = t229;
  19783. mat44.e23 = t234;
  19784. mat44.e30 = t304;
  19785. mat44.e31 = t314;
  19786. mat44.e32 = t324;
  19787. mat44.e33 = t334;
  19788. if(_this20.sizeMat4 == _this20.stackMat4.length) {
  19789. var newLength18 = _this20.sizeMat4 << 1;
  19790. var this19 = new Array(newLength18);
  19791. var newArray18 = this19;
  19792. var _g41 = 0;
  19793. var _g119 = _this20.sizeMat4;
  19794. while(_g41 < _g119) {
  19795. var i22 = _g41++;
  19796. newArray18[i22] = _this20.stackMat4[i22];
  19797. _this20.stackMat4[i22] = null;
  19798. }
  19799. _this20.stackMat4 = newArray18;
  19800. }
  19801. _this20.stackMat4[_this20.sizeMat4++] = mat44;
  19802. }
  19803. if(quat4 != null) {
  19804. var tx11 = 0;
  19805. var ty11 = 0;
  19806. var tz11 = 0;
  19807. var tw4 = 1;
  19808. quat4.x = tx11;
  19809. quat4.y = ty11;
  19810. quat4.z = tz11;
  19811. quat4.w = tw4;
  19812. if(_this20.sizeQuat == _this20.stackQuat.length) {
  19813. var newLength19 = _this20.sizeQuat << 1;
  19814. var this20 = new Array(newLength19);
  19815. var newArray19 = this20;
  19816. var _g42 = 0;
  19817. var _g120 = _this20.sizeQuat;
  19818. while(_g42 < _g120) {
  19819. var i23 = _g42++;
  19820. newArray19[i23] = _this20.stackQuat[i23];
  19821. _this20.stackQuat[i23] = null;
  19822. }
  19823. _this20.stackQuat = newArray19;
  19824. }
  19825. _this20.stackQuat[_this20.sizeQuat++] = quat4;
  19826. }
  19827. var _this21 = this._pool;
  19828. var mat35 = null;
  19829. var mat45 = null;
  19830. var quat5 = null;
  19831. if(v13 != null) {
  19832. v13.zero();
  19833. if(_this21.sizeVec3 == _this21.stackVec3.length) {
  19834. var newLength20 = _this21.sizeVec3 << 1;
  19835. var this21 = new Array(newLength20);
  19836. var newArray20 = this21;
  19837. var _g43 = 0;
  19838. var _g121 = _this21.sizeVec3;
  19839. while(_g43 < _g121) {
  19840. var i24 = _g43++;
  19841. newArray20[i24] = _this21.stackVec3[i24];
  19842. _this21.stackVec3[i24] = null;
  19843. }
  19844. _this21.stackVec3 = newArray20;
  19845. }
  19846. _this21.stackVec3[_this21.sizeVec3++] = v13;
  19847. }
  19848. if(mat35 != null) {
  19849. var t0010 = 1;
  19850. var t0110 = 0;
  19851. var t0210 = 0;
  19852. var t1010 = 0;
  19853. var t1110 = 1;
  19854. var t1210 = 0;
  19855. var t2010 = 0;
  19856. var t2110 = 0;
  19857. var t2210 = 1;
  19858. mat35.e00 = t0010;
  19859. mat35.e01 = t0110;
  19860. mat35.e02 = t0210;
  19861. mat35.e10 = t1010;
  19862. mat35.e11 = t1110;
  19863. mat35.e12 = t1210;
  19864. mat35.e20 = t2010;
  19865. mat35.e21 = t2110;
  19866. mat35.e22 = t2210;
  19867. if(_this21.sizeMat3 == _this21.stackMat3.length) {
  19868. var newLength21 = _this21.sizeMat3 << 1;
  19869. var this22 = new Array(newLength21);
  19870. var newArray21 = this22;
  19871. var _g44 = 0;
  19872. var _g122 = _this21.sizeMat3;
  19873. while(_g44 < _g122) {
  19874. var i25 = _g44++;
  19875. newArray21[i25] = _this21.stackMat3[i25];
  19876. _this21.stackMat3[i25] = null;
  19877. }
  19878. _this21.stackMat3 = newArray21;
  19879. }
  19880. _this21.stackMat3[_this21.sizeMat3++] = mat35;
  19881. }
  19882. if(mat45 != null) {
  19883. var t0011 = 1;
  19884. var t0111 = 0;
  19885. var t0211 = 0;
  19886. var t035 = 0;
  19887. var t1011 = 0;
  19888. var t1111 = 1;
  19889. var t1211 = 0;
  19890. var t135 = 0;
  19891. var t2011 = 0;
  19892. var t2111 = 0;
  19893. var t2211 = 1;
  19894. var t235 = 0;
  19895. var t305 = 0;
  19896. var t315 = 0;
  19897. var t325 = 0;
  19898. var t335 = 1;
  19899. mat45.e00 = t0011;
  19900. mat45.e01 = t0111;
  19901. mat45.e02 = t0211;
  19902. mat45.e03 = t035;
  19903. mat45.e10 = t1011;
  19904. mat45.e11 = t1111;
  19905. mat45.e12 = t1211;
  19906. mat45.e13 = t135;
  19907. mat45.e20 = t2011;
  19908. mat45.e21 = t2111;
  19909. mat45.e22 = t2211;
  19910. mat45.e23 = t235;
  19911. mat45.e30 = t305;
  19912. mat45.e31 = t315;
  19913. mat45.e32 = t325;
  19914. mat45.e33 = t335;
  19915. if(_this21.sizeMat4 == _this21.stackMat4.length) {
  19916. var newLength22 = _this21.sizeMat4 << 1;
  19917. var this23 = new Array(newLength22);
  19918. var newArray22 = this23;
  19919. var _g45 = 0;
  19920. var _g123 = _this21.sizeMat4;
  19921. while(_g45 < _g123) {
  19922. var i26 = _g45++;
  19923. newArray22[i26] = _this21.stackMat4[i26];
  19924. _this21.stackMat4[i26] = null;
  19925. }
  19926. _this21.stackMat4 = newArray22;
  19927. }
  19928. _this21.stackMat4[_this21.sizeMat4++] = mat45;
  19929. }
  19930. if(quat5 != null) {
  19931. var tx12 = 0;
  19932. var ty12 = 0;
  19933. var tz12 = 0;
  19934. var tw5 = 1;
  19935. quat5.x = tx12;
  19936. quat5.y = ty12;
  19937. quat5.z = tz12;
  19938. quat5.w = tw5;
  19939. if(_this21.sizeQuat == _this21.stackQuat.length) {
  19940. var newLength23 = _this21.sizeQuat << 1;
  19941. var this24 = new Array(newLength23);
  19942. var newArray23 = this24;
  19943. var _g46 = 0;
  19944. var _g124 = _this21.sizeQuat;
  19945. while(_g46 < _g124) {
  19946. var i27 = _g46++;
  19947. newArray23[i27] = _this21.stackQuat[i27];
  19948. _this21.stackQuat[i27] = null;
  19949. }
  19950. _this21.stackQuat = newArray23;
  19951. }
  19952. _this21.stackQuat[_this21.sizeQuat++] = quat5;
  19953. }
  19954. var _this22 = this._pool;
  19955. var mat36 = null;
  19956. var mat46 = null;
  19957. var quat6 = null;
  19958. if(normal != null) {
  19959. normal.zero();
  19960. if(_this22.sizeVec3 == _this22.stackVec3.length) {
  19961. var newLength24 = _this22.sizeVec3 << 1;
  19962. var this25 = new Array(newLength24);
  19963. var newArray24 = this25;
  19964. var _g47 = 0;
  19965. var _g125 = _this22.sizeVec3;
  19966. while(_g47 < _g125) {
  19967. var i28 = _g47++;
  19968. newArray24[i28] = _this22.stackVec3[i28];
  19969. _this22.stackVec3[i28] = null;
  19970. }
  19971. _this22.stackVec3 = newArray24;
  19972. }
  19973. _this22.stackVec3[_this22.sizeVec3++] = normal;
  19974. }
  19975. if(mat36 != null) {
  19976. var t0012 = 1;
  19977. var t0112 = 0;
  19978. var t0212 = 0;
  19979. var t1012 = 0;
  19980. var t1112 = 1;
  19981. var t1212 = 0;
  19982. var t2012 = 0;
  19983. var t2112 = 0;
  19984. var t2212 = 1;
  19985. mat36.e00 = t0012;
  19986. mat36.e01 = t0112;
  19987. mat36.e02 = t0212;
  19988. mat36.e10 = t1012;
  19989. mat36.e11 = t1112;
  19990. mat36.e12 = t1212;
  19991. mat36.e20 = t2012;
  19992. mat36.e21 = t2112;
  19993. mat36.e22 = t2212;
  19994. if(_this22.sizeMat3 == _this22.stackMat3.length) {
  19995. var newLength25 = _this22.sizeMat3 << 1;
  19996. var this26 = new Array(newLength25);
  19997. var newArray25 = this26;
  19998. var _g48 = 0;
  19999. var _g126 = _this22.sizeMat3;
  20000. while(_g48 < _g126) {
  20001. var i29 = _g48++;
  20002. newArray25[i29] = _this22.stackMat3[i29];
  20003. _this22.stackMat3[i29] = null;
  20004. }
  20005. _this22.stackMat3 = newArray25;
  20006. }
  20007. _this22.stackMat3[_this22.sizeMat3++] = mat36;
  20008. }
  20009. if(mat46 != null) {
  20010. var t0013 = 1;
  20011. var t0113 = 0;
  20012. var t0213 = 0;
  20013. var t036 = 0;
  20014. var t1013 = 0;
  20015. var t1113 = 1;
  20016. var t1213 = 0;
  20017. var t136 = 0;
  20018. var t2013 = 0;
  20019. var t2113 = 0;
  20020. var t2213 = 1;
  20021. var t236 = 0;
  20022. var t306 = 0;
  20023. var t316 = 0;
  20024. var t326 = 0;
  20025. var t336 = 1;
  20026. mat46.e00 = t0013;
  20027. mat46.e01 = t0113;
  20028. mat46.e02 = t0213;
  20029. mat46.e03 = t036;
  20030. mat46.e10 = t1013;
  20031. mat46.e11 = t1113;
  20032. mat46.e12 = t1213;
  20033. mat46.e13 = t136;
  20034. mat46.e20 = t2013;
  20035. mat46.e21 = t2113;
  20036. mat46.e22 = t2213;
  20037. mat46.e23 = t236;
  20038. mat46.e30 = t306;
  20039. mat46.e31 = t316;
  20040. mat46.e32 = t326;
  20041. mat46.e33 = t336;
  20042. if(_this22.sizeMat4 == _this22.stackMat4.length) {
  20043. var newLength26 = _this22.sizeMat4 << 1;
  20044. var this27 = new Array(newLength26);
  20045. var newArray26 = this27;
  20046. var _g49 = 0;
  20047. var _g127 = _this22.sizeMat4;
  20048. while(_g49 < _g127) {
  20049. var i30 = _g49++;
  20050. newArray26[i30] = _this22.stackMat4[i30];
  20051. _this22.stackMat4[i30] = null;
  20052. }
  20053. _this22.stackMat4 = newArray26;
  20054. }
  20055. _this22.stackMat4[_this22.sizeMat4++] = mat46;
  20056. }
  20057. if(quat6 != null) {
  20058. var tx13 = 0;
  20059. var ty13 = 0;
  20060. var tz13 = 0;
  20061. var tw6 = 1;
  20062. quat6.x = tx13;
  20063. quat6.y = ty13;
  20064. quat6.z = tz13;
  20065. quat6.w = tw6;
  20066. if(_this22.sizeQuat == _this22.stackQuat.length) {
  20067. var newLength27 = _this22.sizeQuat << 1;
  20068. var this28 = new Array(newLength27);
  20069. var newArray27 = this28;
  20070. var _g50 = 0;
  20071. var _g128 = _this22.sizeQuat;
  20072. while(_g50 < _g128) {
  20073. var i31 = _g50++;
  20074. newArray27[i31] = _this22.stackQuat[i31];
  20075. _this22.stackQuat[i31] = null;
  20076. }
  20077. _this22.stackQuat = newArray27;
  20078. }
  20079. _this22.stackQuat[_this22.sizeQuat++] = quat6;
  20080. }
  20081. var _this23 = this._pool;
  20082. var vec3 = null;
  20083. var mat47 = null;
  20084. var quat7 = null;
  20085. if(vec3 != null) {
  20086. vec3.zero();
  20087. if(_this23.sizeVec3 == _this23.stackVec3.length) {
  20088. var newLength28 = _this23.sizeVec3 << 1;
  20089. var this29 = new Array(newLength28);
  20090. var newArray28 = this29;
  20091. var _g51 = 0;
  20092. var _g129 = _this23.sizeVec3;
  20093. while(_g51 < _g129) {
  20094. var i32 = _g51++;
  20095. newArray28[i32] = _this23.stackVec3[i32];
  20096. _this23.stackVec3[i32] = null;
  20097. }
  20098. _this23.stackVec3 = newArray28;
  20099. }
  20100. _this23.stackVec3[_this23.sizeVec3++] = vec3;
  20101. }
  20102. if(m != null) {
  20103. var t0014 = 1;
  20104. var t0114 = 0;
  20105. var t0214 = 0;
  20106. var t1014 = 0;
  20107. var t1114 = 1;
  20108. var t1214 = 0;
  20109. var t2014 = 0;
  20110. var t2114 = 0;
  20111. var t2214 = 1;
  20112. m.e00 = t0014;
  20113. m.e01 = t0114;
  20114. m.e02 = t0214;
  20115. m.e10 = t1014;
  20116. m.e11 = t1114;
  20117. m.e12 = t1214;
  20118. m.e20 = t2014;
  20119. m.e21 = t2114;
  20120. m.e22 = t2214;
  20121. if(_this23.sizeMat3 == _this23.stackMat3.length) {
  20122. var newLength29 = _this23.sizeMat3 << 1;
  20123. var this30 = new Array(newLength29);
  20124. var newArray29 = this30;
  20125. var _g52 = 0;
  20126. var _g130 = _this23.sizeMat3;
  20127. while(_g52 < _g130) {
  20128. var i33 = _g52++;
  20129. newArray29[i33] = _this23.stackMat3[i33];
  20130. _this23.stackMat3[i33] = null;
  20131. }
  20132. _this23.stackMat3 = newArray29;
  20133. }
  20134. _this23.stackMat3[_this23.sizeMat3++] = m;
  20135. }
  20136. if(mat47 != null) {
  20137. var t0015 = 1;
  20138. var t0115 = 0;
  20139. var t0215 = 0;
  20140. var t037 = 0;
  20141. var t1015 = 0;
  20142. var t1115 = 1;
  20143. var t1215 = 0;
  20144. var t137 = 0;
  20145. var t2015 = 0;
  20146. var t2115 = 0;
  20147. var t2215 = 1;
  20148. var t237 = 0;
  20149. var t307 = 0;
  20150. var t317 = 0;
  20151. var t327 = 0;
  20152. var t337 = 1;
  20153. mat47.e00 = t0015;
  20154. mat47.e01 = t0115;
  20155. mat47.e02 = t0215;
  20156. mat47.e03 = t037;
  20157. mat47.e10 = t1015;
  20158. mat47.e11 = t1115;
  20159. mat47.e12 = t1215;
  20160. mat47.e13 = t137;
  20161. mat47.e20 = t2015;
  20162. mat47.e21 = t2115;
  20163. mat47.e22 = t2215;
  20164. mat47.e23 = t237;
  20165. mat47.e30 = t307;
  20166. mat47.e31 = t317;
  20167. mat47.e32 = t327;
  20168. mat47.e33 = t337;
  20169. if(_this23.sizeMat4 == _this23.stackMat4.length) {
  20170. var newLength30 = _this23.sizeMat4 << 1;
  20171. var this31 = new Array(newLength30);
  20172. var newArray30 = this31;
  20173. var _g53 = 0;
  20174. var _g131 = _this23.sizeMat4;
  20175. while(_g53 < _g131) {
  20176. var i34 = _g53++;
  20177. newArray30[i34] = _this23.stackMat4[i34];
  20178. _this23.stackMat4[i34] = null;
  20179. }
  20180. _this23.stackMat4 = newArray30;
  20181. }
  20182. _this23.stackMat4[_this23.sizeMat4++] = mat47;
  20183. }
  20184. if(quat7 != null) {
  20185. var tx14 = 0;
  20186. var ty14 = 0;
  20187. var tz14 = 0;
  20188. var tw7 = 1;
  20189. quat7.x = tx14;
  20190. quat7.y = ty14;
  20191. quat7.z = tz14;
  20192. quat7.w = tw7;
  20193. if(_this23.sizeQuat == _this23.stackQuat.length) {
  20194. var newLength31 = _this23.sizeQuat << 1;
  20195. var this32 = new Array(newLength31);
  20196. var newArray31 = this32;
  20197. var _g54 = 0;
  20198. var _g132 = _this23.sizeQuat;
  20199. while(_g54 < _g132) {
  20200. var i35 = _g54++;
  20201. newArray31[i35] = _this23.stackQuat[i35];
  20202. _this23.stackQuat[i35] = null;
  20203. }
  20204. _this23.stackQuat = newArray31;
  20205. }
  20206. _this23.stackQuat[_this23.sizeQuat++] = quat7;
  20207. }
  20208. var _this24 = this._pool;
  20209. var mat37 = null;
  20210. var mat48 = null;
  20211. var quat8 = null;
  20212. if(o != null) {
  20213. o.zero();
  20214. if(_this24.sizeVec3 == _this24.stackVec3.length) {
  20215. var newLength32 = _this24.sizeVec3 << 1;
  20216. var this33 = new Array(newLength32);
  20217. var newArray32 = this33;
  20218. var _g55 = 0;
  20219. var _g133 = _this24.sizeVec3;
  20220. while(_g55 < _g133) {
  20221. var i36 = _g55++;
  20222. newArray32[i36] = _this24.stackVec3[i36];
  20223. _this24.stackVec3[i36] = null;
  20224. }
  20225. _this24.stackVec3 = newArray32;
  20226. }
  20227. _this24.stackVec3[_this24.sizeVec3++] = o;
  20228. }
  20229. if(mat37 != null) {
  20230. var t0016 = 1;
  20231. var t0116 = 0;
  20232. var t0216 = 0;
  20233. var t1016 = 0;
  20234. var t1116 = 1;
  20235. var t1216 = 0;
  20236. var t2016 = 0;
  20237. var t2116 = 0;
  20238. var t2216 = 1;
  20239. mat37.e00 = t0016;
  20240. mat37.e01 = t0116;
  20241. mat37.e02 = t0216;
  20242. mat37.e10 = t1016;
  20243. mat37.e11 = t1116;
  20244. mat37.e12 = t1216;
  20245. mat37.e20 = t2016;
  20246. mat37.e21 = t2116;
  20247. mat37.e22 = t2216;
  20248. if(_this24.sizeMat3 == _this24.stackMat3.length) {
  20249. var newLength33 = _this24.sizeMat3 << 1;
  20250. var this34 = new Array(newLength33);
  20251. var newArray33 = this34;
  20252. var _g56 = 0;
  20253. var _g134 = _this24.sizeMat3;
  20254. while(_g56 < _g134) {
  20255. var i37 = _g56++;
  20256. newArray33[i37] = _this24.stackMat3[i37];
  20257. _this24.stackMat3[i37] = null;
  20258. }
  20259. _this24.stackMat3 = newArray33;
  20260. }
  20261. _this24.stackMat3[_this24.sizeMat3++] = mat37;
  20262. }
  20263. if(mat48 != null) {
  20264. var t0017 = 1;
  20265. var t0117 = 0;
  20266. var t0217 = 0;
  20267. var t038 = 0;
  20268. var t1017 = 0;
  20269. var t1117 = 1;
  20270. var t1217 = 0;
  20271. var t138 = 0;
  20272. var t2017 = 0;
  20273. var t2117 = 0;
  20274. var t2217 = 1;
  20275. var t238 = 0;
  20276. var t308 = 0;
  20277. var t318 = 0;
  20278. var t328 = 0;
  20279. var t338 = 1;
  20280. mat48.e00 = t0017;
  20281. mat48.e01 = t0117;
  20282. mat48.e02 = t0217;
  20283. mat48.e03 = t038;
  20284. mat48.e10 = t1017;
  20285. mat48.e11 = t1117;
  20286. mat48.e12 = t1217;
  20287. mat48.e13 = t138;
  20288. mat48.e20 = t2017;
  20289. mat48.e21 = t2117;
  20290. mat48.e22 = t2217;
  20291. mat48.e23 = t238;
  20292. mat48.e30 = t308;
  20293. mat48.e31 = t318;
  20294. mat48.e32 = t328;
  20295. mat48.e33 = t338;
  20296. if(_this24.sizeMat4 == _this24.stackMat4.length) {
  20297. var newLength34 = _this24.sizeMat4 << 1;
  20298. var this35 = new Array(newLength34);
  20299. var newArray34 = this35;
  20300. var _g57 = 0;
  20301. var _g135 = _this24.sizeMat4;
  20302. while(_g57 < _g135) {
  20303. var i38 = _g57++;
  20304. newArray34[i38] = _this24.stackMat4[i38];
  20305. _this24.stackMat4[i38] = null;
  20306. }
  20307. _this24.stackMat4 = newArray34;
  20308. }
  20309. _this24.stackMat4[_this24.sizeMat4++] = mat48;
  20310. }
  20311. if(quat8 != null) {
  20312. var tx15 = 0;
  20313. var ty15 = 0;
  20314. var tz15 = 0;
  20315. var tw8 = 1;
  20316. quat8.x = tx15;
  20317. quat8.y = ty15;
  20318. quat8.z = tz15;
  20319. quat8.w = tw8;
  20320. if(_this24.sizeQuat == _this24.stackQuat.length) {
  20321. var newLength35 = _this24.sizeQuat << 1;
  20322. var this36 = new Array(newLength35);
  20323. var newArray35 = this36;
  20324. var _g58 = 0;
  20325. var _g136 = _this24.sizeQuat;
  20326. while(_g58 < _g136) {
  20327. var i39 = _g58++;
  20328. newArray35[i39] = _this24.stackQuat[i39];
  20329. _this24.stackQuat[i39] = null;
  20330. }
  20331. _this24.stackQuat = newArray35;
  20332. }
  20333. _this24.stackQuat[_this24.sizeQuat++] = quat8;
  20334. }
  20335. break;
  20336. }
  20337. }
  20338. if(d.drawAabbs) {
  20339. var aabb = s._aabb;
  20340. var color = style.aabbColor;
  20341. var _this25 = this._pool;
  20342. var min = _this25.sizeVec3 == 0 ? new oimo.common.Vec3() : _this25.stackVec3[--_this25.sizeVec3];
  20343. var _this26 = this._pool;
  20344. var max = _this26.sizeVec3 == 0 ? new oimo.common.Vec3() : _this26.stackVec3[--_this26.sizeVec3];
  20345. var v15 = min;
  20346. v15.x = aabb._minX;
  20347. v15.y = aabb._minY;
  20348. v15.z = aabb._minZ;
  20349. var v16 = max;
  20350. v16.x = aabb._maxX;
  20351. v16.y = aabb._maxY;
  20352. v16.z = aabb._maxZ;
  20353. d.aabb(min,max,color);
  20354. var _this27 = this._pool;
  20355. var mat38 = null;
  20356. var mat49 = null;
  20357. var quat9 = null;
  20358. if(min != null) {
  20359. min.zero();
  20360. if(_this27.sizeVec3 == _this27.stackVec3.length) {
  20361. var newLength36 = _this27.sizeVec3 << 1;
  20362. var this37 = new Array(newLength36);
  20363. var newArray36 = this37;
  20364. var _g59 = 0;
  20365. var _g137 = _this27.sizeVec3;
  20366. while(_g59 < _g137) {
  20367. var i40 = _g59++;
  20368. newArray36[i40] = _this27.stackVec3[i40];
  20369. _this27.stackVec3[i40] = null;
  20370. }
  20371. _this27.stackVec3 = newArray36;
  20372. }
  20373. _this27.stackVec3[_this27.sizeVec3++] = min;
  20374. }
  20375. if(mat38 != null) {
  20376. var t0018 = 1;
  20377. var t0118 = 0;
  20378. var t0218 = 0;
  20379. var t1018 = 0;
  20380. var t1118 = 1;
  20381. var t1218 = 0;
  20382. var t2018 = 0;
  20383. var t2118 = 0;
  20384. var t2218 = 1;
  20385. mat38.e00 = t0018;
  20386. mat38.e01 = t0118;
  20387. mat38.e02 = t0218;
  20388. mat38.e10 = t1018;
  20389. mat38.e11 = t1118;
  20390. mat38.e12 = t1218;
  20391. mat38.e20 = t2018;
  20392. mat38.e21 = t2118;
  20393. mat38.e22 = t2218;
  20394. if(_this27.sizeMat3 == _this27.stackMat3.length) {
  20395. var newLength37 = _this27.sizeMat3 << 1;
  20396. var this38 = new Array(newLength37);
  20397. var newArray37 = this38;
  20398. var _g60 = 0;
  20399. var _g138 = _this27.sizeMat3;
  20400. while(_g60 < _g138) {
  20401. var i41 = _g60++;
  20402. newArray37[i41] = _this27.stackMat3[i41];
  20403. _this27.stackMat3[i41] = null;
  20404. }
  20405. _this27.stackMat3 = newArray37;
  20406. }
  20407. _this27.stackMat3[_this27.sizeMat3++] = mat38;
  20408. }
  20409. if(mat49 != null) {
  20410. var t0019 = 1;
  20411. var t0119 = 0;
  20412. var t0219 = 0;
  20413. var t039 = 0;
  20414. var t1019 = 0;
  20415. var t1119 = 1;
  20416. var t1219 = 0;
  20417. var t139 = 0;
  20418. var t2019 = 0;
  20419. var t2119 = 0;
  20420. var t2219 = 1;
  20421. var t239 = 0;
  20422. var t309 = 0;
  20423. var t319 = 0;
  20424. var t329 = 0;
  20425. var t339 = 1;
  20426. mat49.e00 = t0019;
  20427. mat49.e01 = t0119;
  20428. mat49.e02 = t0219;
  20429. mat49.e03 = t039;
  20430. mat49.e10 = t1019;
  20431. mat49.e11 = t1119;
  20432. mat49.e12 = t1219;
  20433. mat49.e13 = t139;
  20434. mat49.e20 = t2019;
  20435. mat49.e21 = t2119;
  20436. mat49.e22 = t2219;
  20437. mat49.e23 = t239;
  20438. mat49.e30 = t309;
  20439. mat49.e31 = t319;
  20440. mat49.e32 = t329;
  20441. mat49.e33 = t339;
  20442. if(_this27.sizeMat4 == _this27.stackMat4.length) {
  20443. var newLength38 = _this27.sizeMat4 << 1;
  20444. var this39 = new Array(newLength38);
  20445. var newArray38 = this39;
  20446. var _g61 = 0;
  20447. var _g139 = _this27.sizeMat4;
  20448. while(_g61 < _g139) {
  20449. var i42 = _g61++;
  20450. newArray38[i42] = _this27.stackMat4[i42];
  20451. _this27.stackMat4[i42] = null;
  20452. }
  20453. _this27.stackMat4 = newArray38;
  20454. }
  20455. _this27.stackMat4[_this27.sizeMat4++] = mat49;
  20456. }
  20457. if(quat9 != null) {
  20458. var tx16 = 0;
  20459. var ty16 = 0;
  20460. var tz16 = 0;
  20461. var tw9 = 1;
  20462. quat9.x = tx16;
  20463. quat9.y = ty16;
  20464. quat9.z = tz16;
  20465. quat9.w = tw9;
  20466. if(_this27.sizeQuat == _this27.stackQuat.length) {
  20467. var newLength39 = _this27.sizeQuat << 1;
  20468. var this40 = new Array(newLength39);
  20469. var newArray39 = this40;
  20470. var _g62 = 0;
  20471. var _g140 = _this27.sizeQuat;
  20472. while(_g62 < _g140) {
  20473. var i43 = _g62++;
  20474. newArray39[i43] = _this27.stackQuat[i43];
  20475. _this27.stackQuat[i43] = null;
  20476. }
  20477. _this27.stackQuat = newArray39;
  20478. }
  20479. _this27.stackQuat[_this27.sizeQuat++] = quat9;
  20480. }
  20481. var _this28 = this._pool;
  20482. var mat39 = null;
  20483. var mat410 = null;
  20484. var quat10 = null;
  20485. if(max != null) {
  20486. max.zero();
  20487. if(_this28.sizeVec3 == _this28.stackVec3.length) {
  20488. var newLength40 = _this28.sizeVec3 << 1;
  20489. var this41 = new Array(newLength40);
  20490. var newArray40 = this41;
  20491. var _g63 = 0;
  20492. var _g141 = _this28.sizeVec3;
  20493. while(_g63 < _g141) {
  20494. var i44 = _g63++;
  20495. newArray40[i44] = _this28.stackVec3[i44];
  20496. _this28.stackVec3[i44] = null;
  20497. }
  20498. _this28.stackVec3 = newArray40;
  20499. }
  20500. _this28.stackVec3[_this28.sizeVec3++] = max;
  20501. }
  20502. if(mat39 != null) {
  20503. var t0020 = 1;
  20504. var t0120 = 0;
  20505. var t0220 = 0;
  20506. var t1020 = 0;
  20507. var t1120 = 1;
  20508. var t1220 = 0;
  20509. var t2020 = 0;
  20510. var t2120 = 0;
  20511. var t2220 = 1;
  20512. mat39.e00 = t0020;
  20513. mat39.e01 = t0120;
  20514. mat39.e02 = t0220;
  20515. mat39.e10 = t1020;
  20516. mat39.e11 = t1120;
  20517. mat39.e12 = t1220;
  20518. mat39.e20 = t2020;
  20519. mat39.e21 = t2120;
  20520. mat39.e22 = t2220;
  20521. if(_this28.sizeMat3 == _this28.stackMat3.length) {
  20522. var newLength41 = _this28.sizeMat3 << 1;
  20523. var this42 = new Array(newLength41);
  20524. var newArray41 = this42;
  20525. var _g64 = 0;
  20526. var _g142 = _this28.sizeMat3;
  20527. while(_g64 < _g142) {
  20528. var i45 = _g64++;
  20529. newArray41[i45] = _this28.stackMat3[i45];
  20530. _this28.stackMat3[i45] = null;
  20531. }
  20532. _this28.stackMat3 = newArray41;
  20533. }
  20534. _this28.stackMat3[_this28.sizeMat3++] = mat39;
  20535. }
  20536. if(mat410 != null) {
  20537. var t0021 = 1;
  20538. var t0121 = 0;
  20539. var t0221 = 0;
  20540. var t0310 = 0;
  20541. var t1021 = 0;
  20542. var t1121 = 1;
  20543. var t1221 = 0;
  20544. var t1310 = 0;
  20545. var t2021 = 0;
  20546. var t2121 = 0;
  20547. var t2221 = 1;
  20548. var t2310 = 0;
  20549. var t3010 = 0;
  20550. var t3110 = 0;
  20551. var t3210 = 0;
  20552. var t3310 = 1;
  20553. mat410.e00 = t0021;
  20554. mat410.e01 = t0121;
  20555. mat410.e02 = t0221;
  20556. mat410.e03 = t0310;
  20557. mat410.e10 = t1021;
  20558. mat410.e11 = t1121;
  20559. mat410.e12 = t1221;
  20560. mat410.e13 = t1310;
  20561. mat410.e20 = t2021;
  20562. mat410.e21 = t2121;
  20563. mat410.e22 = t2221;
  20564. mat410.e23 = t2310;
  20565. mat410.e30 = t3010;
  20566. mat410.e31 = t3110;
  20567. mat410.e32 = t3210;
  20568. mat410.e33 = t3310;
  20569. if(_this28.sizeMat4 == _this28.stackMat4.length) {
  20570. var newLength42 = _this28.sizeMat4 << 1;
  20571. var this43 = new Array(newLength42);
  20572. var newArray42 = this43;
  20573. var _g65 = 0;
  20574. var _g143 = _this28.sizeMat4;
  20575. while(_g65 < _g143) {
  20576. var i46 = _g65++;
  20577. newArray42[i46] = _this28.stackMat4[i46];
  20578. _this28.stackMat4[i46] = null;
  20579. }
  20580. _this28.stackMat4 = newArray42;
  20581. }
  20582. _this28.stackMat4[_this28.sizeMat4++] = mat410;
  20583. }
  20584. if(quat10 != null) {
  20585. var tx17 = 0;
  20586. var ty17 = 0;
  20587. var tz17 = 0;
  20588. var tw10 = 1;
  20589. quat10.x = tx17;
  20590. quat10.y = ty17;
  20591. quat10.z = tz17;
  20592. quat10.w = tw10;
  20593. if(_this28.sizeQuat == _this28.stackQuat.length) {
  20594. var newLength43 = _this28.sizeQuat << 1;
  20595. var this44 = new Array(newLength43);
  20596. var newArray43 = this44;
  20597. var _g66 = 0;
  20598. var _g144 = _this28.sizeQuat;
  20599. while(_g66 < _g144) {
  20600. var i47 = _g66++;
  20601. newArray43[i47] = _this28.stackQuat[i47];
  20602. _this28.stackQuat[i47] = null;
  20603. }
  20604. _this28.stackQuat = newArray43;
  20605. }
  20606. _this28.stackQuat[_this28.sizeQuat++] = quat10;
  20607. }
  20608. }
  20609. s = n1;
  20610. }
  20611. r = n;
  20612. }
  20613. }
  20614. _drawConstraints(d) {
  20615. var style = d.style;
  20616. if(d.drawPairs || d.drawContacts) {
  20617. var c = this._contactManager._contactList;
  20618. while(c != null) {
  20619. var n = c._next;
  20620. if(d.drawPairs) {
  20621. var color = style.pairColor;
  20622. var _this = this._pool;
  20623. var v1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  20624. var _this1 = this._pool;
  20625. var v2 = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  20626. var v = v1;
  20627. v.x = c._s1._transform._positionX;
  20628. v.y = c._s1._transform._positionY;
  20629. v.z = c._s1._transform._positionZ;
  20630. var v3 = v2;
  20631. v3.x = c._s2._transform._positionX;
  20632. v3.y = c._s2._transform._positionY;
  20633. v3.z = c._s2._transform._positionZ;
  20634. d.line(v1,v2,color);
  20635. var _this2 = this._pool;
  20636. var mat3 = null;
  20637. var mat4 = null;
  20638. var quat = null;
  20639. if(v1 != null) {
  20640. v1.zero();
  20641. if(_this2.sizeVec3 == _this2.stackVec3.length) {
  20642. var newLength = _this2.sizeVec3 << 1;
  20643. var this1 = new Array(newLength);
  20644. var newArray = this1;
  20645. var _g = 0;
  20646. var _g1 = _this2.sizeVec3;
  20647. while(_g < _g1) {
  20648. var i = _g++;
  20649. newArray[i] = _this2.stackVec3[i];
  20650. _this2.stackVec3[i] = null;
  20651. }
  20652. _this2.stackVec3 = newArray;
  20653. }
  20654. _this2.stackVec3[_this2.sizeVec3++] = v1;
  20655. }
  20656. if(mat3 != null) {
  20657. var t00 = 1;
  20658. var t01 = 0;
  20659. var t02 = 0;
  20660. var t10 = 0;
  20661. var t11 = 1;
  20662. var t12 = 0;
  20663. var t20 = 0;
  20664. var t21 = 0;
  20665. var t22 = 1;
  20666. mat3.e00 = t00;
  20667. mat3.e01 = t01;
  20668. mat3.e02 = t02;
  20669. mat3.e10 = t10;
  20670. mat3.e11 = t11;
  20671. mat3.e12 = t12;
  20672. mat3.e20 = t20;
  20673. mat3.e21 = t21;
  20674. mat3.e22 = t22;
  20675. if(_this2.sizeMat3 == _this2.stackMat3.length) {
  20676. var newLength1 = _this2.sizeMat3 << 1;
  20677. var this2 = new Array(newLength1);
  20678. var newArray1 = this2;
  20679. var _g2 = 0;
  20680. var _g11 = _this2.sizeMat3;
  20681. while(_g2 < _g11) {
  20682. var i1 = _g2++;
  20683. newArray1[i1] = _this2.stackMat3[i1];
  20684. _this2.stackMat3[i1] = null;
  20685. }
  20686. _this2.stackMat3 = newArray1;
  20687. }
  20688. _this2.stackMat3[_this2.sizeMat3++] = mat3;
  20689. }
  20690. if(mat4 != null) {
  20691. var t001 = 1;
  20692. var t011 = 0;
  20693. var t021 = 0;
  20694. var t03 = 0;
  20695. var t101 = 0;
  20696. var t111 = 1;
  20697. var t121 = 0;
  20698. var t13 = 0;
  20699. var t201 = 0;
  20700. var t211 = 0;
  20701. var t221 = 1;
  20702. var t23 = 0;
  20703. var t30 = 0;
  20704. var t31 = 0;
  20705. var t32 = 0;
  20706. var t33 = 1;
  20707. mat4.e00 = t001;
  20708. mat4.e01 = t011;
  20709. mat4.e02 = t021;
  20710. mat4.e03 = t03;
  20711. mat4.e10 = t101;
  20712. mat4.e11 = t111;
  20713. mat4.e12 = t121;
  20714. mat4.e13 = t13;
  20715. mat4.e20 = t201;
  20716. mat4.e21 = t211;
  20717. mat4.e22 = t221;
  20718. mat4.e23 = t23;
  20719. mat4.e30 = t30;
  20720. mat4.e31 = t31;
  20721. mat4.e32 = t32;
  20722. mat4.e33 = t33;
  20723. if(_this2.sizeMat4 == _this2.stackMat4.length) {
  20724. var newLength2 = _this2.sizeMat4 << 1;
  20725. var this3 = new Array(newLength2);
  20726. var newArray2 = this3;
  20727. var _g3 = 0;
  20728. var _g12 = _this2.sizeMat4;
  20729. while(_g3 < _g12) {
  20730. var i2 = _g3++;
  20731. newArray2[i2] = _this2.stackMat4[i2];
  20732. _this2.stackMat4[i2] = null;
  20733. }
  20734. _this2.stackMat4 = newArray2;
  20735. }
  20736. _this2.stackMat4[_this2.sizeMat4++] = mat4;
  20737. }
  20738. if(quat != null) {
  20739. var tx = 0;
  20740. var ty = 0;
  20741. var tz = 0;
  20742. var tw = 1;
  20743. quat.x = tx;
  20744. quat.y = ty;
  20745. quat.z = tz;
  20746. quat.w = tw;
  20747. if(_this2.sizeQuat == _this2.stackQuat.length) {
  20748. var newLength3 = _this2.sizeQuat << 1;
  20749. var this4 = new Array(newLength3);
  20750. var newArray3 = this4;
  20751. var _g4 = 0;
  20752. var _g13 = _this2.sizeQuat;
  20753. while(_g4 < _g13) {
  20754. var i3 = _g4++;
  20755. newArray3[i3] = _this2.stackQuat[i3];
  20756. _this2.stackQuat[i3] = null;
  20757. }
  20758. _this2.stackQuat = newArray3;
  20759. }
  20760. _this2.stackQuat[_this2.sizeQuat++] = quat;
  20761. }
  20762. var _this3 = this._pool;
  20763. var mat31 = null;
  20764. var mat41 = null;
  20765. var quat1 = null;
  20766. if(v2 != null) {
  20767. v2.zero();
  20768. if(_this3.sizeVec3 == _this3.stackVec3.length) {
  20769. var newLength4 = _this3.sizeVec3 << 1;
  20770. var this5 = new Array(newLength4);
  20771. var newArray4 = this5;
  20772. var _g5 = 0;
  20773. var _g14 = _this3.sizeVec3;
  20774. while(_g5 < _g14) {
  20775. var i4 = _g5++;
  20776. newArray4[i4] = _this3.stackVec3[i4];
  20777. _this3.stackVec3[i4] = null;
  20778. }
  20779. _this3.stackVec3 = newArray4;
  20780. }
  20781. _this3.stackVec3[_this3.sizeVec3++] = v2;
  20782. }
  20783. if(mat31 != null) {
  20784. var t002 = 1;
  20785. var t012 = 0;
  20786. var t022 = 0;
  20787. var t102 = 0;
  20788. var t112 = 1;
  20789. var t122 = 0;
  20790. var t202 = 0;
  20791. var t212 = 0;
  20792. var t222 = 1;
  20793. mat31.e00 = t002;
  20794. mat31.e01 = t012;
  20795. mat31.e02 = t022;
  20796. mat31.e10 = t102;
  20797. mat31.e11 = t112;
  20798. mat31.e12 = t122;
  20799. mat31.e20 = t202;
  20800. mat31.e21 = t212;
  20801. mat31.e22 = t222;
  20802. if(_this3.sizeMat3 == _this3.stackMat3.length) {
  20803. var newLength5 = _this3.sizeMat3 << 1;
  20804. var this6 = new Array(newLength5);
  20805. var newArray5 = this6;
  20806. var _g6 = 0;
  20807. var _g15 = _this3.sizeMat3;
  20808. while(_g6 < _g15) {
  20809. var i5 = _g6++;
  20810. newArray5[i5] = _this3.stackMat3[i5];
  20811. _this3.stackMat3[i5] = null;
  20812. }
  20813. _this3.stackMat3 = newArray5;
  20814. }
  20815. _this3.stackMat3[_this3.sizeMat3++] = mat31;
  20816. }
  20817. if(mat41 != null) {
  20818. var t003 = 1;
  20819. var t013 = 0;
  20820. var t023 = 0;
  20821. var t031 = 0;
  20822. var t103 = 0;
  20823. var t113 = 1;
  20824. var t123 = 0;
  20825. var t131 = 0;
  20826. var t203 = 0;
  20827. var t213 = 0;
  20828. var t223 = 1;
  20829. var t231 = 0;
  20830. var t301 = 0;
  20831. var t311 = 0;
  20832. var t321 = 0;
  20833. var t331 = 1;
  20834. mat41.e00 = t003;
  20835. mat41.e01 = t013;
  20836. mat41.e02 = t023;
  20837. mat41.e03 = t031;
  20838. mat41.e10 = t103;
  20839. mat41.e11 = t113;
  20840. mat41.e12 = t123;
  20841. mat41.e13 = t131;
  20842. mat41.e20 = t203;
  20843. mat41.e21 = t213;
  20844. mat41.e22 = t223;
  20845. mat41.e23 = t231;
  20846. mat41.e30 = t301;
  20847. mat41.e31 = t311;
  20848. mat41.e32 = t321;
  20849. mat41.e33 = t331;
  20850. if(_this3.sizeMat4 == _this3.stackMat4.length) {
  20851. var newLength6 = _this3.sizeMat4 << 1;
  20852. var this7 = new Array(newLength6);
  20853. var newArray6 = this7;
  20854. var _g7 = 0;
  20855. var _g16 = _this3.sizeMat4;
  20856. while(_g7 < _g16) {
  20857. var i6 = _g7++;
  20858. newArray6[i6] = _this3.stackMat4[i6];
  20859. _this3.stackMat4[i6] = null;
  20860. }
  20861. _this3.stackMat4 = newArray6;
  20862. }
  20863. _this3.stackMat4[_this3.sizeMat4++] = mat41;
  20864. }
  20865. if(quat1 != null) {
  20866. var tx1 = 0;
  20867. var ty1 = 0;
  20868. var tz1 = 0;
  20869. var tw1 = 1;
  20870. quat1.x = tx1;
  20871. quat1.y = ty1;
  20872. quat1.z = tz1;
  20873. quat1.w = tw1;
  20874. if(_this3.sizeQuat == _this3.stackQuat.length) {
  20875. var newLength7 = _this3.sizeQuat << 1;
  20876. var this8 = new Array(newLength7);
  20877. var newArray7 = this8;
  20878. var _g8 = 0;
  20879. var _g17 = _this3.sizeQuat;
  20880. while(_g8 < _g17) {
  20881. var i7 = _g8++;
  20882. newArray7[i7] = _this3.stackQuat[i7];
  20883. _this3.stackQuat[i7] = null;
  20884. }
  20885. _this3.stackQuat = newArray7;
  20886. }
  20887. _this3.stackQuat[_this3.sizeQuat++] = quat1;
  20888. }
  20889. }
  20890. if(d.drawContacts) {
  20891. var cc = c._contactConstraint;
  20892. var ps = c._contactConstraint._manifold._points;
  20893. var _g9 = 0;
  20894. var _g18 = c._contactConstraint._manifold._numPoints;
  20895. while(_g9 < _g18) {
  20896. var i8 = _g9++;
  20897. var p = ps[i8];
  20898. var style1 = d.style;
  20899. var tf1 = cc._s1._transform;
  20900. var tf2 = cc._s2._transform;
  20901. var _this4 = this._pool;
  20902. var pos1 = _this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3];
  20903. var _this5 = this._pool;
  20904. var pos2 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3];
  20905. var _this6 = this._pool;
  20906. var normal = _this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3];
  20907. var _this7 = this._pool;
  20908. var tangent = _this7.sizeVec3 == 0 ? new oimo.common.Vec3() : _this7.stackVec3[--_this7.sizeVec3];
  20909. var _this8 = this._pool;
  20910. var binormal = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3];
  20911. var v4 = pos1;
  20912. v4.x = p._pos1X;
  20913. v4.y = p._pos1Y;
  20914. v4.z = p._pos1Z;
  20915. var v5 = pos2;
  20916. v5.x = p._pos2X;
  20917. v5.y = p._pos2Y;
  20918. v5.z = p._pos2Z;
  20919. var v6 = normal;
  20920. v6.x = cc._manifold._normalX;
  20921. v6.y = cc._manifold._normalY;
  20922. v6.z = cc._manifold._normalZ;
  20923. var v7 = tangent;
  20924. v7.x = cc._manifold._tangentX;
  20925. v7.y = cc._manifold._tangentY;
  20926. v7.z = cc._manifold._tangentZ;
  20927. var v8 = binormal;
  20928. v8.x = cc._manifold._binormalX;
  20929. v8.y = cc._manifold._binormalY;
  20930. v8.z = cc._manifold._binormalZ;
  20931. if(p._disabled) {
  20932. d.point(pos1,style1.disabledContactColor);
  20933. d.point(pos2,style1.disabledContactColor);
  20934. d.line(pos1,pos2,style1.disabledContactColor);
  20935. } else if(p._warmStarted) {
  20936. var color1;
  20937. switch(p._id & 3) {
  20938. case 0:
  20939. color1 = style1.contactColor;
  20940. break;
  20941. case 1:
  20942. color1 = style1.contactColor2;
  20943. break;
  20944. case 2:
  20945. color1 = style1.contactColor3;
  20946. break;
  20947. default:
  20948. color1 = style1.contactColor4;
  20949. }
  20950. d.point(pos1,color1);
  20951. d.point(pos2,color1);
  20952. d.line(pos1,pos2,style1.contactColor);
  20953. } else {
  20954. d.point(pos1,style1.newContactColor);
  20955. d.point(pos2,style1.newContactColor);
  20956. d.line(pos1,pos2,style1.newContactColor);
  20957. }
  20958. pos2.x = pos1.x;
  20959. pos2.y = pos1.y;
  20960. pos2.z = pos1.z;
  20961. var _this9 = pos2;
  20962. var s = style1.contactNormalLength;
  20963. var tx2 = _this9.x + normal.x * s;
  20964. var ty2 = _this9.y + normal.y * s;
  20965. var tz2 = _this9.z + normal.z * s;
  20966. _this9.x = tx2;
  20967. _this9.y = ty2;
  20968. _this9.z = tz2;
  20969. d.line(pos1,pos2,style1.contactNormalColor);
  20970. if(d.drawContactBases) {
  20971. pos2.x = pos1.x;
  20972. pos2.y = pos1.y;
  20973. pos2.z = pos1.z;
  20974. var _this10 = pos2;
  20975. var s1 = style1.contactTangentLength;
  20976. var tx3 = _this10.x + tangent.x * s1;
  20977. var ty3 = _this10.y + tangent.y * s1;
  20978. var tz3 = _this10.z + tangent.z * s1;
  20979. _this10.x = tx3;
  20980. _this10.y = ty3;
  20981. _this10.z = tz3;
  20982. d.line(pos1,pos2,style1.contactTangentColor);
  20983. pos2.x = pos1.x;
  20984. pos2.y = pos1.y;
  20985. pos2.z = pos1.z;
  20986. var _this11 = pos2;
  20987. var s2 = style1.contactBinormalLength;
  20988. var tx4 = _this11.x + binormal.x * s2;
  20989. var ty4 = _this11.y + binormal.y * s2;
  20990. var tz4 = _this11.z + binormal.z * s2;
  20991. _this11.x = tx4;
  20992. _this11.y = ty4;
  20993. _this11.z = tz4;
  20994. d.line(pos1,pos2,style1.contactBinormalColor);
  20995. }
  20996. var _this12 = this._pool;
  20997. var mat32 = null;
  20998. var mat42 = null;
  20999. var quat2 = null;
  21000. if(pos1 != null) {
  21001. pos1.zero();
  21002. if(_this12.sizeVec3 == _this12.stackVec3.length) {
  21003. var newLength8 = _this12.sizeVec3 << 1;
  21004. var this9 = new Array(newLength8);
  21005. var newArray8 = this9;
  21006. var _g10 = 0;
  21007. var _g19 = _this12.sizeVec3;
  21008. while(_g10 < _g19) {
  21009. var i9 = _g10++;
  21010. newArray8[i9] = _this12.stackVec3[i9];
  21011. _this12.stackVec3[i9] = null;
  21012. }
  21013. _this12.stackVec3 = newArray8;
  21014. }
  21015. _this12.stackVec3[_this12.sizeVec3++] = pos1;
  21016. }
  21017. if(mat32 != null) {
  21018. var t004 = 1;
  21019. var t014 = 0;
  21020. var t024 = 0;
  21021. var t104 = 0;
  21022. var t114 = 1;
  21023. var t124 = 0;
  21024. var t204 = 0;
  21025. var t214 = 0;
  21026. var t224 = 1;
  21027. mat32.e00 = t004;
  21028. mat32.e01 = t014;
  21029. mat32.e02 = t024;
  21030. mat32.e10 = t104;
  21031. mat32.e11 = t114;
  21032. mat32.e12 = t124;
  21033. mat32.e20 = t204;
  21034. mat32.e21 = t214;
  21035. mat32.e22 = t224;
  21036. if(_this12.sizeMat3 == _this12.stackMat3.length) {
  21037. var newLength9 = _this12.sizeMat3 << 1;
  21038. var this10 = new Array(newLength9);
  21039. var newArray9 = this10;
  21040. var _g20 = 0;
  21041. var _g110 = _this12.sizeMat3;
  21042. while(_g20 < _g110) {
  21043. var i10 = _g20++;
  21044. newArray9[i10] = _this12.stackMat3[i10];
  21045. _this12.stackMat3[i10] = null;
  21046. }
  21047. _this12.stackMat3 = newArray9;
  21048. }
  21049. _this12.stackMat3[_this12.sizeMat3++] = mat32;
  21050. }
  21051. if(mat42 != null) {
  21052. var t005 = 1;
  21053. var t015 = 0;
  21054. var t025 = 0;
  21055. var t032 = 0;
  21056. var t105 = 0;
  21057. var t115 = 1;
  21058. var t125 = 0;
  21059. var t132 = 0;
  21060. var t205 = 0;
  21061. var t215 = 0;
  21062. var t225 = 1;
  21063. var t232 = 0;
  21064. var t302 = 0;
  21065. var t312 = 0;
  21066. var t322 = 0;
  21067. var t332 = 1;
  21068. mat42.e00 = t005;
  21069. mat42.e01 = t015;
  21070. mat42.e02 = t025;
  21071. mat42.e03 = t032;
  21072. mat42.e10 = t105;
  21073. mat42.e11 = t115;
  21074. mat42.e12 = t125;
  21075. mat42.e13 = t132;
  21076. mat42.e20 = t205;
  21077. mat42.e21 = t215;
  21078. mat42.e22 = t225;
  21079. mat42.e23 = t232;
  21080. mat42.e30 = t302;
  21081. mat42.e31 = t312;
  21082. mat42.e32 = t322;
  21083. mat42.e33 = t332;
  21084. if(_this12.sizeMat4 == _this12.stackMat4.length) {
  21085. var newLength10 = _this12.sizeMat4 << 1;
  21086. var this11 = new Array(newLength10);
  21087. var newArray10 = this11;
  21088. var _g21 = 0;
  21089. var _g111 = _this12.sizeMat4;
  21090. while(_g21 < _g111) {
  21091. var i11 = _g21++;
  21092. newArray10[i11] = _this12.stackMat4[i11];
  21093. _this12.stackMat4[i11] = null;
  21094. }
  21095. _this12.stackMat4 = newArray10;
  21096. }
  21097. _this12.stackMat4[_this12.sizeMat4++] = mat42;
  21098. }
  21099. if(quat2 != null) {
  21100. var tx5 = 0;
  21101. var ty5 = 0;
  21102. var tz5 = 0;
  21103. var tw2 = 1;
  21104. quat2.x = tx5;
  21105. quat2.y = ty5;
  21106. quat2.z = tz5;
  21107. quat2.w = tw2;
  21108. if(_this12.sizeQuat == _this12.stackQuat.length) {
  21109. var newLength11 = _this12.sizeQuat << 1;
  21110. var this12 = new Array(newLength11);
  21111. var newArray11 = this12;
  21112. var _g22 = 0;
  21113. var _g112 = _this12.sizeQuat;
  21114. while(_g22 < _g112) {
  21115. var i12 = _g22++;
  21116. newArray11[i12] = _this12.stackQuat[i12];
  21117. _this12.stackQuat[i12] = null;
  21118. }
  21119. _this12.stackQuat = newArray11;
  21120. }
  21121. _this12.stackQuat[_this12.sizeQuat++] = quat2;
  21122. }
  21123. var _this13 = this._pool;
  21124. var mat33 = null;
  21125. var mat43 = null;
  21126. var quat3 = null;
  21127. if(pos2 != null) {
  21128. pos2.zero();
  21129. if(_this13.sizeVec3 == _this13.stackVec3.length) {
  21130. var newLength12 = _this13.sizeVec3 << 1;
  21131. var this13 = new Array(newLength12);
  21132. var newArray12 = this13;
  21133. var _g23 = 0;
  21134. var _g113 = _this13.sizeVec3;
  21135. while(_g23 < _g113) {
  21136. var i13 = _g23++;
  21137. newArray12[i13] = _this13.stackVec3[i13];
  21138. _this13.stackVec3[i13] = null;
  21139. }
  21140. _this13.stackVec3 = newArray12;
  21141. }
  21142. _this13.stackVec3[_this13.sizeVec3++] = pos2;
  21143. }
  21144. if(mat33 != null) {
  21145. var t006 = 1;
  21146. var t016 = 0;
  21147. var t026 = 0;
  21148. var t106 = 0;
  21149. var t116 = 1;
  21150. var t126 = 0;
  21151. var t206 = 0;
  21152. var t216 = 0;
  21153. var t226 = 1;
  21154. mat33.e00 = t006;
  21155. mat33.e01 = t016;
  21156. mat33.e02 = t026;
  21157. mat33.e10 = t106;
  21158. mat33.e11 = t116;
  21159. mat33.e12 = t126;
  21160. mat33.e20 = t206;
  21161. mat33.e21 = t216;
  21162. mat33.e22 = t226;
  21163. if(_this13.sizeMat3 == _this13.stackMat3.length) {
  21164. var newLength13 = _this13.sizeMat3 << 1;
  21165. var this14 = new Array(newLength13);
  21166. var newArray13 = this14;
  21167. var _g24 = 0;
  21168. var _g114 = _this13.sizeMat3;
  21169. while(_g24 < _g114) {
  21170. var i14 = _g24++;
  21171. newArray13[i14] = _this13.stackMat3[i14];
  21172. _this13.stackMat3[i14] = null;
  21173. }
  21174. _this13.stackMat3 = newArray13;
  21175. }
  21176. _this13.stackMat3[_this13.sizeMat3++] = mat33;
  21177. }
  21178. if(mat43 != null) {
  21179. var t007 = 1;
  21180. var t017 = 0;
  21181. var t027 = 0;
  21182. var t033 = 0;
  21183. var t107 = 0;
  21184. var t117 = 1;
  21185. var t127 = 0;
  21186. var t133 = 0;
  21187. var t207 = 0;
  21188. var t217 = 0;
  21189. var t227 = 1;
  21190. var t233 = 0;
  21191. var t303 = 0;
  21192. var t313 = 0;
  21193. var t323 = 0;
  21194. var t333 = 1;
  21195. mat43.e00 = t007;
  21196. mat43.e01 = t017;
  21197. mat43.e02 = t027;
  21198. mat43.e03 = t033;
  21199. mat43.e10 = t107;
  21200. mat43.e11 = t117;
  21201. mat43.e12 = t127;
  21202. mat43.e13 = t133;
  21203. mat43.e20 = t207;
  21204. mat43.e21 = t217;
  21205. mat43.e22 = t227;
  21206. mat43.e23 = t233;
  21207. mat43.e30 = t303;
  21208. mat43.e31 = t313;
  21209. mat43.e32 = t323;
  21210. mat43.e33 = t333;
  21211. if(_this13.sizeMat4 == _this13.stackMat4.length) {
  21212. var newLength14 = _this13.sizeMat4 << 1;
  21213. var this15 = new Array(newLength14);
  21214. var newArray14 = this15;
  21215. var _g25 = 0;
  21216. var _g115 = _this13.sizeMat4;
  21217. while(_g25 < _g115) {
  21218. var i15 = _g25++;
  21219. newArray14[i15] = _this13.stackMat4[i15];
  21220. _this13.stackMat4[i15] = null;
  21221. }
  21222. _this13.stackMat4 = newArray14;
  21223. }
  21224. _this13.stackMat4[_this13.sizeMat4++] = mat43;
  21225. }
  21226. if(quat3 != null) {
  21227. var tx6 = 0;
  21228. var ty6 = 0;
  21229. var tz6 = 0;
  21230. var tw3 = 1;
  21231. quat3.x = tx6;
  21232. quat3.y = ty6;
  21233. quat3.z = tz6;
  21234. quat3.w = tw3;
  21235. if(_this13.sizeQuat == _this13.stackQuat.length) {
  21236. var newLength15 = _this13.sizeQuat << 1;
  21237. var this16 = new Array(newLength15);
  21238. var newArray15 = this16;
  21239. var _g26 = 0;
  21240. var _g116 = _this13.sizeQuat;
  21241. while(_g26 < _g116) {
  21242. var i16 = _g26++;
  21243. newArray15[i16] = _this13.stackQuat[i16];
  21244. _this13.stackQuat[i16] = null;
  21245. }
  21246. _this13.stackQuat = newArray15;
  21247. }
  21248. _this13.stackQuat[_this13.sizeQuat++] = quat3;
  21249. }
  21250. var _this14 = this._pool;
  21251. var mat34 = null;
  21252. var mat44 = null;
  21253. var quat4 = null;
  21254. if(normal != null) {
  21255. normal.zero();
  21256. if(_this14.sizeVec3 == _this14.stackVec3.length) {
  21257. var newLength16 = _this14.sizeVec3 << 1;
  21258. var this17 = new Array(newLength16);
  21259. var newArray16 = this17;
  21260. var _g27 = 0;
  21261. var _g117 = _this14.sizeVec3;
  21262. while(_g27 < _g117) {
  21263. var i17 = _g27++;
  21264. newArray16[i17] = _this14.stackVec3[i17];
  21265. _this14.stackVec3[i17] = null;
  21266. }
  21267. _this14.stackVec3 = newArray16;
  21268. }
  21269. _this14.stackVec3[_this14.sizeVec3++] = normal;
  21270. }
  21271. if(mat34 != null) {
  21272. var t008 = 1;
  21273. var t018 = 0;
  21274. var t028 = 0;
  21275. var t108 = 0;
  21276. var t118 = 1;
  21277. var t128 = 0;
  21278. var t208 = 0;
  21279. var t218 = 0;
  21280. var t228 = 1;
  21281. mat34.e00 = t008;
  21282. mat34.e01 = t018;
  21283. mat34.e02 = t028;
  21284. mat34.e10 = t108;
  21285. mat34.e11 = t118;
  21286. mat34.e12 = t128;
  21287. mat34.e20 = t208;
  21288. mat34.e21 = t218;
  21289. mat34.e22 = t228;
  21290. if(_this14.sizeMat3 == _this14.stackMat3.length) {
  21291. var newLength17 = _this14.sizeMat3 << 1;
  21292. var this18 = new Array(newLength17);
  21293. var newArray17 = this18;
  21294. var _g28 = 0;
  21295. var _g118 = _this14.sizeMat3;
  21296. while(_g28 < _g118) {
  21297. var i18 = _g28++;
  21298. newArray17[i18] = _this14.stackMat3[i18];
  21299. _this14.stackMat3[i18] = null;
  21300. }
  21301. _this14.stackMat3 = newArray17;
  21302. }
  21303. _this14.stackMat3[_this14.sizeMat3++] = mat34;
  21304. }
  21305. if(mat44 != null) {
  21306. var t009 = 1;
  21307. var t019 = 0;
  21308. var t029 = 0;
  21309. var t034 = 0;
  21310. var t109 = 0;
  21311. var t119 = 1;
  21312. var t129 = 0;
  21313. var t134 = 0;
  21314. var t209 = 0;
  21315. var t219 = 0;
  21316. var t229 = 1;
  21317. var t234 = 0;
  21318. var t304 = 0;
  21319. var t314 = 0;
  21320. var t324 = 0;
  21321. var t334 = 1;
  21322. mat44.e00 = t009;
  21323. mat44.e01 = t019;
  21324. mat44.e02 = t029;
  21325. mat44.e03 = t034;
  21326. mat44.e10 = t109;
  21327. mat44.e11 = t119;
  21328. mat44.e12 = t129;
  21329. mat44.e13 = t134;
  21330. mat44.e20 = t209;
  21331. mat44.e21 = t219;
  21332. mat44.e22 = t229;
  21333. mat44.e23 = t234;
  21334. mat44.e30 = t304;
  21335. mat44.e31 = t314;
  21336. mat44.e32 = t324;
  21337. mat44.e33 = t334;
  21338. if(_this14.sizeMat4 == _this14.stackMat4.length) {
  21339. var newLength18 = _this14.sizeMat4 << 1;
  21340. var this19 = new Array(newLength18);
  21341. var newArray18 = this19;
  21342. var _g29 = 0;
  21343. var _g119 = _this14.sizeMat4;
  21344. while(_g29 < _g119) {
  21345. var i19 = _g29++;
  21346. newArray18[i19] = _this14.stackMat4[i19];
  21347. _this14.stackMat4[i19] = null;
  21348. }
  21349. _this14.stackMat4 = newArray18;
  21350. }
  21351. _this14.stackMat4[_this14.sizeMat4++] = mat44;
  21352. }
  21353. if(quat4 != null) {
  21354. var tx7 = 0;
  21355. var ty7 = 0;
  21356. var tz7 = 0;
  21357. var tw4 = 1;
  21358. quat4.x = tx7;
  21359. quat4.y = ty7;
  21360. quat4.z = tz7;
  21361. quat4.w = tw4;
  21362. if(_this14.sizeQuat == _this14.stackQuat.length) {
  21363. var newLength19 = _this14.sizeQuat << 1;
  21364. var this20 = new Array(newLength19);
  21365. var newArray19 = this20;
  21366. var _g30 = 0;
  21367. var _g120 = _this14.sizeQuat;
  21368. while(_g30 < _g120) {
  21369. var i20 = _g30++;
  21370. newArray19[i20] = _this14.stackQuat[i20];
  21371. _this14.stackQuat[i20] = null;
  21372. }
  21373. _this14.stackQuat = newArray19;
  21374. }
  21375. _this14.stackQuat[_this14.sizeQuat++] = quat4;
  21376. }
  21377. var _this15 = this._pool;
  21378. var mat35 = null;
  21379. var mat45 = null;
  21380. var quat5 = null;
  21381. if(tangent != null) {
  21382. tangent.zero();
  21383. if(_this15.sizeVec3 == _this15.stackVec3.length) {
  21384. var newLength20 = _this15.sizeVec3 << 1;
  21385. var this21 = new Array(newLength20);
  21386. var newArray20 = this21;
  21387. var _g31 = 0;
  21388. var _g121 = _this15.sizeVec3;
  21389. while(_g31 < _g121) {
  21390. var i21 = _g31++;
  21391. newArray20[i21] = _this15.stackVec3[i21];
  21392. _this15.stackVec3[i21] = null;
  21393. }
  21394. _this15.stackVec3 = newArray20;
  21395. }
  21396. _this15.stackVec3[_this15.sizeVec3++] = tangent;
  21397. }
  21398. if(mat35 != null) {
  21399. var t0010 = 1;
  21400. var t0110 = 0;
  21401. var t0210 = 0;
  21402. var t1010 = 0;
  21403. var t1110 = 1;
  21404. var t1210 = 0;
  21405. var t2010 = 0;
  21406. var t2110 = 0;
  21407. var t2210 = 1;
  21408. mat35.e00 = t0010;
  21409. mat35.e01 = t0110;
  21410. mat35.e02 = t0210;
  21411. mat35.e10 = t1010;
  21412. mat35.e11 = t1110;
  21413. mat35.e12 = t1210;
  21414. mat35.e20 = t2010;
  21415. mat35.e21 = t2110;
  21416. mat35.e22 = t2210;
  21417. if(_this15.sizeMat3 == _this15.stackMat3.length) {
  21418. var newLength21 = _this15.sizeMat3 << 1;
  21419. var this22 = new Array(newLength21);
  21420. var newArray21 = this22;
  21421. var _g32 = 0;
  21422. var _g122 = _this15.sizeMat3;
  21423. while(_g32 < _g122) {
  21424. var i22 = _g32++;
  21425. newArray21[i22] = _this15.stackMat3[i22];
  21426. _this15.stackMat3[i22] = null;
  21427. }
  21428. _this15.stackMat3 = newArray21;
  21429. }
  21430. _this15.stackMat3[_this15.sizeMat3++] = mat35;
  21431. }
  21432. if(mat45 != null) {
  21433. var t0011 = 1;
  21434. var t0111 = 0;
  21435. var t0211 = 0;
  21436. var t035 = 0;
  21437. var t1011 = 0;
  21438. var t1111 = 1;
  21439. var t1211 = 0;
  21440. var t135 = 0;
  21441. var t2011 = 0;
  21442. var t2111 = 0;
  21443. var t2211 = 1;
  21444. var t235 = 0;
  21445. var t305 = 0;
  21446. var t315 = 0;
  21447. var t325 = 0;
  21448. var t335 = 1;
  21449. mat45.e00 = t0011;
  21450. mat45.e01 = t0111;
  21451. mat45.e02 = t0211;
  21452. mat45.e03 = t035;
  21453. mat45.e10 = t1011;
  21454. mat45.e11 = t1111;
  21455. mat45.e12 = t1211;
  21456. mat45.e13 = t135;
  21457. mat45.e20 = t2011;
  21458. mat45.e21 = t2111;
  21459. mat45.e22 = t2211;
  21460. mat45.e23 = t235;
  21461. mat45.e30 = t305;
  21462. mat45.e31 = t315;
  21463. mat45.e32 = t325;
  21464. mat45.e33 = t335;
  21465. if(_this15.sizeMat4 == _this15.stackMat4.length) {
  21466. var newLength22 = _this15.sizeMat4 << 1;
  21467. var this23 = new Array(newLength22);
  21468. var newArray22 = this23;
  21469. var _g33 = 0;
  21470. var _g123 = _this15.sizeMat4;
  21471. while(_g33 < _g123) {
  21472. var i23 = _g33++;
  21473. newArray22[i23] = _this15.stackMat4[i23];
  21474. _this15.stackMat4[i23] = null;
  21475. }
  21476. _this15.stackMat4 = newArray22;
  21477. }
  21478. _this15.stackMat4[_this15.sizeMat4++] = mat45;
  21479. }
  21480. if(quat5 != null) {
  21481. var tx8 = 0;
  21482. var ty8 = 0;
  21483. var tz8 = 0;
  21484. var tw5 = 1;
  21485. quat5.x = tx8;
  21486. quat5.y = ty8;
  21487. quat5.z = tz8;
  21488. quat5.w = tw5;
  21489. if(_this15.sizeQuat == _this15.stackQuat.length) {
  21490. var newLength23 = _this15.sizeQuat << 1;
  21491. var this24 = new Array(newLength23);
  21492. var newArray23 = this24;
  21493. var _g34 = 0;
  21494. var _g124 = _this15.sizeQuat;
  21495. while(_g34 < _g124) {
  21496. var i24 = _g34++;
  21497. newArray23[i24] = _this15.stackQuat[i24];
  21498. _this15.stackQuat[i24] = null;
  21499. }
  21500. _this15.stackQuat = newArray23;
  21501. }
  21502. _this15.stackQuat[_this15.sizeQuat++] = quat5;
  21503. }
  21504. var _this16 = this._pool;
  21505. var mat36 = null;
  21506. var mat46 = null;
  21507. var quat6 = null;
  21508. if(binormal != null) {
  21509. binormal.zero();
  21510. if(_this16.sizeVec3 == _this16.stackVec3.length) {
  21511. var newLength24 = _this16.sizeVec3 << 1;
  21512. var this25 = new Array(newLength24);
  21513. var newArray24 = this25;
  21514. var _g35 = 0;
  21515. var _g125 = _this16.sizeVec3;
  21516. while(_g35 < _g125) {
  21517. var i25 = _g35++;
  21518. newArray24[i25] = _this16.stackVec3[i25];
  21519. _this16.stackVec3[i25] = null;
  21520. }
  21521. _this16.stackVec3 = newArray24;
  21522. }
  21523. _this16.stackVec3[_this16.sizeVec3++] = binormal;
  21524. }
  21525. if(mat36 != null) {
  21526. var t0012 = 1;
  21527. var t0112 = 0;
  21528. var t0212 = 0;
  21529. var t1012 = 0;
  21530. var t1112 = 1;
  21531. var t1212 = 0;
  21532. var t2012 = 0;
  21533. var t2112 = 0;
  21534. var t2212 = 1;
  21535. mat36.e00 = t0012;
  21536. mat36.e01 = t0112;
  21537. mat36.e02 = t0212;
  21538. mat36.e10 = t1012;
  21539. mat36.e11 = t1112;
  21540. mat36.e12 = t1212;
  21541. mat36.e20 = t2012;
  21542. mat36.e21 = t2112;
  21543. mat36.e22 = t2212;
  21544. if(_this16.sizeMat3 == _this16.stackMat3.length) {
  21545. var newLength25 = _this16.sizeMat3 << 1;
  21546. var this26 = new Array(newLength25);
  21547. var newArray25 = this26;
  21548. var _g36 = 0;
  21549. var _g126 = _this16.sizeMat3;
  21550. while(_g36 < _g126) {
  21551. var i26 = _g36++;
  21552. newArray25[i26] = _this16.stackMat3[i26];
  21553. _this16.stackMat3[i26] = null;
  21554. }
  21555. _this16.stackMat3 = newArray25;
  21556. }
  21557. _this16.stackMat3[_this16.sizeMat3++] = mat36;
  21558. }
  21559. if(mat46 != null) {
  21560. var t0013 = 1;
  21561. var t0113 = 0;
  21562. var t0213 = 0;
  21563. var t036 = 0;
  21564. var t1013 = 0;
  21565. var t1113 = 1;
  21566. var t1213 = 0;
  21567. var t136 = 0;
  21568. var t2013 = 0;
  21569. var t2113 = 0;
  21570. var t2213 = 1;
  21571. var t236 = 0;
  21572. var t306 = 0;
  21573. var t316 = 0;
  21574. var t326 = 0;
  21575. var t336 = 1;
  21576. mat46.e00 = t0013;
  21577. mat46.e01 = t0113;
  21578. mat46.e02 = t0213;
  21579. mat46.e03 = t036;
  21580. mat46.e10 = t1013;
  21581. mat46.e11 = t1113;
  21582. mat46.e12 = t1213;
  21583. mat46.e13 = t136;
  21584. mat46.e20 = t2013;
  21585. mat46.e21 = t2113;
  21586. mat46.e22 = t2213;
  21587. mat46.e23 = t236;
  21588. mat46.e30 = t306;
  21589. mat46.e31 = t316;
  21590. mat46.e32 = t326;
  21591. mat46.e33 = t336;
  21592. if(_this16.sizeMat4 == _this16.stackMat4.length) {
  21593. var newLength26 = _this16.sizeMat4 << 1;
  21594. var this27 = new Array(newLength26);
  21595. var newArray26 = this27;
  21596. var _g37 = 0;
  21597. var _g127 = _this16.sizeMat4;
  21598. while(_g37 < _g127) {
  21599. var i27 = _g37++;
  21600. newArray26[i27] = _this16.stackMat4[i27];
  21601. _this16.stackMat4[i27] = null;
  21602. }
  21603. _this16.stackMat4 = newArray26;
  21604. }
  21605. _this16.stackMat4[_this16.sizeMat4++] = mat46;
  21606. }
  21607. if(quat6 != null) {
  21608. var tx9 = 0;
  21609. var ty9 = 0;
  21610. var tz9 = 0;
  21611. var tw6 = 1;
  21612. quat6.x = tx9;
  21613. quat6.y = ty9;
  21614. quat6.z = tz9;
  21615. quat6.w = tw6;
  21616. if(_this16.sizeQuat == _this16.stackQuat.length) {
  21617. var newLength27 = _this16.sizeQuat << 1;
  21618. var this28 = new Array(newLength27);
  21619. var newArray27 = this28;
  21620. var _g38 = 0;
  21621. var _g128 = _this16.sizeQuat;
  21622. while(_g38 < _g128) {
  21623. var i28 = _g38++;
  21624. newArray27[i28] = _this16.stackQuat[i28];
  21625. _this16.stackQuat[i28] = null;
  21626. }
  21627. _this16.stackQuat = newArray27;
  21628. }
  21629. _this16.stackQuat[_this16.sizeQuat++] = quat6;
  21630. }
  21631. }
  21632. }
  21633. c = n;
  21634. }
  21635. }
  21636. if(d.drawJoints) {
  21637. var j = this._jointList;
  21638. while(j != null) {
  21639. var n1 = j._next;
  21640. var _this17 = this._pool;
  21641. var p1 = _this17.sizeVec3 == 0 ? new oimo.common.Vec3() : _this17.stackVec3[--_this17.sizeVec3];
  21642. var _this18 = this._pool;
  21643. var p2 = _this18.sizeVec3 == 0 ? new oimo.common.Vec3() : _this18.stackVec3[--_this18.sizeVec3];
  21644. var v9 = p1;
  21645. v9.x = j._b1._transform._positionX;
  21646. v9.y = j._b1._transform._positionY;
  21647. v9.z = j._b1._transform._positionZ;
  21648. var v10 = p2;
  21649. v10.x = j._b2._transform._positionX;
  21650. v10.y = j._b2._transform._positionY;
  21651. v10.z = j._b2._transform._positionZ;
  21652. var _this19 = this._pool;
  21653. var anchor1 = _this19.sizeVec3 == 0 ? new oimo.common.Vec3() : _this19.stackVec3[--_this19.sizeVec3];
  21654. var _this20 = this._pool;
  21655. var anchor2 = _this20.sizeVec3 == 0 ? new oimo.common.Vec3() : _this20.stackVec3[--_this20.sizeVec3];
  21656. var _this21 = this._pool;
  21657. var basisX1 = _this21.sizeVec3 == 0 ? new oimo.common.Vec3() : _this21.stackVec3[--_this21.sizeVec3];
  21658. var _this22 = this._pool;
  21659. var basisY1 = _this22.sizeVec3 == 0 ? new oimo.common.Vec3() : _this22.stackVec3[--_this22.sizeVec3];
  21660. var _this23 = this._pool;
  21661. var basisZ1 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3];
  21662. var _this24 = this._pool;
  21663. var basisX2 = _this24.sizeVec3 == 0 ? new oimo.common.Vec3() : _this24.stackVec3[--_this24.sizeVec3];
  21664. var _this25 = this._pool;
  21665. var basisY2 = _this25.sizeVec3 == 0 ? new oimo.common.Vec3() : _this25.stackVec3[--_this25.sizeVec3];
  21666. var _this26 = this._pool;
  21667. var basisZ2 = _this26.sizeVec3 == 0 ? new oimo.common.Vec3() : _this26.stackVec3[--_this26.sizeVec3];
  21668. var v11 = anchor1;
  21669. v11.x = j._anchor1X;
  21670. v11.y = j._anchor1Y;
  21671. v11.z = j._anchor1Z;
  21672. var v12 = anchor2;
  21673. v12.x = j._anchor2X;
  21674. v12.y = j._anchor2Y;
  21675. v12.z = j._anchor2Z;
  21676. var v13 = basisX1;
  21677. v13.x = j._basisX1X;
  21678. v13.y = j._basisX1Y;
  21679. v13.z = j._basisX1Z;
  21680. var v14 = basisY1;
  21681. v14.x = j._basisY1X;
  21682. v14.y = j._basisY1Y;
  21683. v14.z = j._basisY1Z;
  21684. var v15 = basisZ1;
  21685. v15.x = j._basisZ1X;
  21686. v15.y = j._basisZ1Y;
  21687. v15.z = j._basisZ1Z;
  21688. var v16 = basisX2;
  21689. v16.x = j._basisX2X;
  21690. v16.y = j._basisX2Y;
  21691. v16.z = j._basisX2Z;
  21692. var v17 = basisY2;
  21693. v17.x = j._basisY2X;
  21694. v17.y = j._basisY2Y;
  21695. v17.z = j._basisY2Z;
  21696. var v18 = basisZ2;
  21697. v18.x = j._basisZ2X;
  21698. v18.y = j._basisZ2Y;
  21699. v18.z = j._basisZ2Z;
  21700. d.line(p1,anchor1,d.style.jointLineColor);
  21701. d.line(p2,anchor2,d.style.jointLineColor);
  21702. if(d.drawJointLimits) {
  21703. switch(j._type) {
  21704. case 0:
  21705. break;
  21706. case 1:
  21707. var radius = d.style.jointRotationalConstraintRadius;
  21708. var color2 = d.style.jointLineColor;
  21709. var lm = j._lm;
  21710. this._drawRotationalLimit(d,anchor1,basisY1,basisZ1,basisY2,radius,lm.lowerLimit,lm.upperLimit,color2);
  21711. break;
  21712. case 2:
  21713. var j1 = j;
  21714. var radius1 = d.style.jointRotationalConstraintRadius;
  21715. var color3 = d.style.jointLineColor;
  21716. var rlm = j1._rotLm;
  21717. var tlm = j1._translLm;
  21718. this._drawRotationalLimit(d,anchor2,basisY1,basisZ1,basisY2,radius1,rlm.lowerLimit,rlm.upperLimit,color3);
  21719. this._drawTranslationalLimit(d,anchor1,basisX1,tlm.lowerLimit,tlm.upperLimit,color3);
  21720. break;
  21721. case 3:
  21722. var radius2 = d.style.jointRotationalConstraintRadius;
  21723. var color4 = d.style.jointLineColor;
  21724. var lm1 = j._lm;
  21725. this._drawTranslationalLimit(d,anchor1,basisX1,lm1.lowerLimit,lm1.upperLimit,color4);
  21726. break;
  21727. case 4:
  21728. var j2 = j;
  21729. var radius3 = d.style.jointRotationalConstraintRadius;
  21730. var color5 = d.style.jointLineColor;
  21731. var lm11 = j2._lm1;
  21732. var lm2 = j2._lm2;
  21733. this._drawRotationalLimit(d,anchor1,basisY1,basisZ1,basisY1,radius3,j2._angleX - lm11.upperLimit,j2._angleX - lm11.lowerLimit,color5);
  21734. this._drawRotationalLimit(d,anchor2,basisX2,basisY2,basisX2,radius3,lm2.lowerLimit - j2._angleZ,lm2.upperLimit - j2._angleZ,color5);
  21735. break;
  21736. case 5:
  21737. var j3 = j;
  21738. var radius4 = d.style.jointRotationalConstraintRadius;
  21739. var color6 = d.style.jointLineColor;
  21740. var lm3 = j3._twistLm;
  21741. this._drawRotationalLimit(d,anchor2,basisY2,basisZ2,basisY2,radius4,lm3.lowerLimit - j3._twistAngle,lm3.upperLimit - j3._twistAngle,color6);
  21742. this._drawEllipseOnSphere(d,anchor1,basisX1,basisY1,basisZ1,j3._maxSwingAngle1,j3._maxSwingAngle2,radius4,color6);
  21743. var _this27 = this._pool;
  21744. var _this28 = _this27.sizeVec3 == 0 ? new oimo.common.Vec3() : _this27.stackVec3[--_this27.sizeVec3];
  21745. _this28.x = anchor2.x;
  21746. _this28.y = anchor2.y;
  21747. _this28.z = anchor2.z;
  21748. var _this29 = _this28;
  21749. var tx10 = _this29.x + basisX2.x * radius4;
  21750. var ty10 = _this29.y + basisX2.y * radius4;
  21751. var tz10 = _this29.z + basisX2.z * radius4;
  21752. _this29.x = tx10;
  21753. _this29.y = ty10;
  21754. _this29.z = tz10;
  21755. var to = _this29;
  21756. d.line(anchor2,to,color6);
  21757. var _this30 = this._pool;
  21758. var mat37 = null;
  21759. var mat47 = null;
  21760. var quat7 = null;
  21761. if(to != null) {
  21762. to.zero();
  21763. if(_this30.sizeVec3 == _this30.stackVec3.length) {
  21764. var newLength28 = _this30.sizeVec3 << 1;
  21765. var this29 = new Array(newLength28);
  21766. var newArray28 = this29;
  21767. var _g39 = 0;
  21768. var _g129 = _this30.sizeVec3;
  21769. while(_g39 < _g129) {
  21770. var i29 = _g39++;
  21771. newArray28[i29] = _this30.stackVec3[i29];
  21772. _this30.stackVec3[i29] = null;
  21773. }
  21774. _this30.stackVec3 = newArray28;
  21775. }
  21776. _this30.stackVec3[_this30.sizeVec3++] = to;
  21777. }
  21778. if(mat37 != null) {
  21779. var t0014 = 1;
  21780. var t0114 = 0;
  21781. var t0214 = 0;
  21782. var t1014 = 0;
  21783. var t1114 = 1;
  21784. var t1214 = 0;
  21785. var t2014 = 0;
  21786. var t2114 = 0;
  21787. var t2214 = 1;
  21788. mat37.e00 = t0014;
  21789. mat37.e01 = t0114;
  21790. mat37.e02 = t0214;
  21791. mat37.e10 = t1014;
  21792. mat37.e11 = t1114;
  21793. mat37.e12 = t1214;
  21794. mat37.e20 = t2014;
  21795. mat37.e21 = t2114;
  21796. mat37.e22 = t2214;
  21797. if(_this30.sizeMat3 == _this30.stackMat3.length) {
  21798. var newLength29 = _this30.sizeMat3 << 1;
  21799. var this30 = new Array(newLength29);
  21800. var newArray29 = this30;
  21801. var _g40 = 0;
  21802. var _g130 = _this30.sizeMat3;
  21803. while(_g40 < _g130) {
  21804. var i30 = _g40++;
  21805. newArray29[i30] = _this30.stackMat3[i30];
  21806. _this30.stackMat3[i30] = null;
  21807. }
  21808. _this30.stackMat3 = newArray29;
  21809. }
  21810. _this30.stackMat3[_this30.sizeMat3++] = mat37;
  21811. }
  21812. if(mat47 != null) {
  21813. var t0015 = 1;
  21814. var t0115 = 0;
  21815. var t0215 = 0;
  21816. var t037 = 0;
  21817. var t1015 = 0;
  21818. var t1115 = 1;
  21819. var t1215 = 0;
  21820. var t137 = 0;
  21821. var t2015 = 0;
  21822. var t2115 = 0;
  21823. var t2215 = 1;
  21824. var t237 = 0;
  21825. var t307 = 0;
  21826. var t317 = 0;
  21827. var t327 = 0;
  21828. var t337 = 1;
  21829. mat47.e00 = t0015;
  21830. mat47.e01 = t0115;
  21831. mat47.e02 = t0215;
  21832. mat47.e03 = t037;
  21833. mat47.e10 = t1015;
  21834. mat47.e11 = t1115;
  21835. mat47.e12 = t1215;
  21836. mat47.e13 = t137;
  21837. mat47.e20 = t2015;
  21838. mat47.e21 = t2115;
  21839. mat47.e22 = t2215;
  21840. mat47.e23 = t237;
  21841. mat47.e30 = t307;
  21842. mat47.e31 = t317;
  21843. mat47.e32 = t327;
  21844. mat47.e33 = t337;
  21845. if(_this30.sizeMat4 == _this30.stackMat4.length) {
  21846. var newLength30 = _this30.sizeMat4 << 1;
  21847. var this31 = new Array(newLength30);
  21848. var newArray30 = this31;
  21849. var _g41 = 0;
  21850. var _g131 = _this30.sizeMat4;
  21851. while(_g41 < _g131) {
  21852. var i31 = _g41++;
  21853. newArray30[i31] = _this30.stackMat4[i31];
  21854. _this30.stackMat4[i31] = null;
  21855. }
  21856. _this30.stackMat4 = newArray30;
  21857. }
  21858. _this30.stackMat4[_this30.sizeMat4++] = mat47;
  21859. }
  21860. if(quat7 != null) {
  21861. var tx11 = 0;
  21862. var ty11 = 0;
  21863. var tz11 = 0;
  21864. var tw7 = 1;
  21865. quat7.x = tx11;
  21866. quat7.y = ty11;
  21867. quat7.z = tz11;
  21868. quat7.w = tw7;
  21869. if(_this30.sizeQuat == _this30.stackQuat.length) {
  21870. var newLength31 = _this30.sizeQuat << 1;
  21871. var this32 = new Array(newLength31);
  21872. var newArray31 = this32;
  21873. var _g42 = 0;
  21874. var _g132 = _this30.sizeQuat;
  21875. while(_g42 < _g132) {
  21876. var i32 = _g42++;
  21877. newArray31[i32] = _this30.stackQuat[i32];
  21878. _this30.stackQuat[i32] = null;
  21879. }
  21880. _this30.stackQuat = newArray31;
  21881. }
  21882. _this30.stackQuat[_this30.sizeQuat++] = quat7;
  21883. }
  21884. break;
  21885. case 6:
  21886. var j4 = j;
  21887. var radius5 = d.style.jointRotationalConstraintRadius;
  21888. var color7 = d.style.jointLineColor;
  21889. var txlm = j4._translLms[0];
  21890. var tylm = j4._translLms[1];
  21891. var tzlm = j4._translLms[2];
  21892. var rxlm = j4._rotLms[0];
  21893. var rylm = j4._rotLms[1];
  21894. var rzlm = j4._rotLms[2];
  21895. this._drawTranslationalLimit3D(d,anchor1,basisX1,basisY1,basisZ1,txlm,tylm,tzlm,color7);
  21896. var _this31 = this._pool;
  21897. var rotYAxis = _this31.sizeVec3 == 0 ? new oimo.common.Vec3() : _this31.stackVec3[--_this31.sizeVec3];
  21898. var v19 = rotYAxis;
  21899. v19.x = j4._axisYX;
  21900. v19.y = j4._axisYY;
  21901. v19.z = j4._axisYZ;
  21902. var _this32 = this._pool;
  21903. var _this33 = _this32.sizeVec3 == 0 ? new oimo.common.Vec3() : _this32.stackVec3[--_this32.sizeVec3];
  21904. _this33.x = basisX1.x;
  21905. _this33.y = basisX1.y;
  21906. _this33.z = basisX1.z;
  21907. var rotYBasisX = _this33;
  21908. var _this34 = this._pool;
  21909. var _this35 = _this34.sizeVec3 == 0 ? new oimo.common.Vec3() : _this34.stackVec3[--_this34.sizeVec3];
  21910. _this35.x = basisX1.x;
  21911. _this35.y = basisX1.y;
  21912. _this35.z = basisX1.z;
  21913. var _this36 = _this35;
  21914. var tx12 = _this36.y * rotYAxis.z - _this36.z * rotYAxis.y;
  21915. var ty12 = _this36.z * rotYAxis.x - _this36.x * rotYAxis.z;
  21916. var tz12 = _this36.x * rotYAxis.y - _this36.y * rotYAxis.x;
  21917. _this36.x = tx12;
  21918. _this36.y = ty12;
  21919. _this36.z = tz12;
  21920. var rotYBasisY = _this36;
  21921. this._drawRotationalLimit(d,anchor2,basisY1,basisZ1,basisY1,radius5,j4._angleX - rxlm.upperLimit,j4._angleX - rxlm.lowerLimit,color7);
  21922. this._drawRotationalLimit(d,anchor2,rotYBasisX,rotYBasisY,rotYBasisX,radius5,rylm.lowerLimit - j4._angleY,rylm.upperLimit - j4._angleY,color7);
  21923. this._drawRotationalLimit(d,anchor2,basisX2,basisY2,basisX2,radius5,rzlm.lowerLimit - j4._angleZ,rzlm.upperLimit - j4._angleZ,color7);
  21924. break;
  21925. }
  21926. }
  21927. d.line(anchor1,anchor2,d.style.jointErrorColor);
  21928. var _this37 = this._pool;
  21929. var mat38 = null;
  21930. var mat48 = null;
  21931. var quat8 = null;
  21932. if(p1 != null) {
  21933. p1.zero();
  21934. if(_this37.sizeVec3 == _this37.stackVec3.length) {
  21935. var newLength32 = _this37.sizeVec3 << 1;
  21936. var this33 = new Array(newLength32);
  21937. var newArray32 = this33;
  21938. var _g43 = 0;
  21939. var _g133 = _this37.sizeVec3;
  21940. while(_g43 < _g133) {
  21941. var i33 = _g43++;
  21942. newArray32[i33] = _this37.stackVec3[i33];
  21943. _this37.stackVec3[i33] = null;
  21944. }
  21945. _this37.stackVec3 = newArray32;
  21946. }
  21947. _this37.stackVec3[_this37.sizeVec3++] = p1;
  21948. }
  21949. if(mat38 != null) {
  21950. var t0016 = 1;
  21951. var t0116 = 0;
  21952. var t0216 = 0;
  21953. var t1016 = 0;
  21954. var t1116 = 1;
  21955. var t1216 = 0;
  21956. var t2016 = 0;
  21957. var t2116 = 0;
  21958. var t2216 = 1;
  21959. mat38.e00 = t0016;
  21960. mat38.e01 = t0116;
  21961. mat38.e02 = t0216;
  21962. mat38.e10 = t1016;
  21963. mat38.e11 = t1116;
  21964. mat38.e12 = t1216;
  21965. mat38.e20 = t2016;
  21966. mat38.e21 = t2116;
  21967. mat38.e22 = t2216;
  21968. if(_this37.sizeMat3 == _this37.stackMat3.length) {
  21969. var newLength33 = _this37.sizeMat3 << 1;
  21970. var this34 = new Array(newLength33);
  21971. var newArray33 = this34;
  21972. var _g44 = 0;
  21973. var _g134 = _this37.sizeMat3;
  21974. while(_g44 < _g134) {
  21975. var i34 = _g44++;
  21976. newArray33[i34] = _this37.stackMat3[i34];
  21977. _this37.stackMat3[i34] = null;
  21978. }
  21979. _this37.stackMat3 = newArray33;
  21980. }
  21981. _this37.stackMat3[_this37.sizeMat3++] = mat38;
  21982. }
  21983. if(mat48 != null) {
  21984. var t0017 = 1;
  21985. var t0117 = 0;
  21986. var t0217 = 0;
  21987. var t038 = 0;
  21988. var t1017 = 0;
  21989. var t1117 = 1;
  21990. var t1217 = 0;
  21991. var t138 = 0;
  21992. var t2017 = 0;
  21993. var t2117 = 0;
  21994. var t2217 = 1;
  21995. var t238 = 0;
  21996. var t308 = 0;
  21997. var t318 = 0;
  21998. var t328 = 0;
  21999. var t338 = 1;
  22000. mat48.e00 = t0017;
  22001. mat48.e01 = t0117;
  22002. mat48.e02 = t0217;
  22003. mat48.e03 = t038;
  22004. mat48.e10 = t1017;
  22005. mat48.e11 = t1117;
  22006. mat48.e12 = t1217;
  22007. mat48.e13 = t138;
  22008. mat48.e20 = t2017;
  22009. mat48.e21 = t2117;
  22010. mat48.e22 = t2217;
  22011. mat48.e23 = t238;
  22012. mat48.e30 = t308;
  22013. mat48.e31 = t318;
  22014. mat48.e32 = t328;
  22015. mat48.e33 = t338;
  22016. if(_this37.sizeMat4 == _this37.stackMat4.length) {
  22017. var newLength34 = _this37.sizeMat4 << 1;
  22018. var this35 = new Array(newLength34);
  22019. var newArray34 = this35;
  22020. var _g45 = 0;
  22021. var _g135 = _this37.sizeMat4;
  22022. while(_g45 < _g135) {
  22023. var i35 = _g45++;
  22024. newArray34[i35] = _this37.stackMat4[i35];
  22025. _this37.stackMat4[i35] = null;
  22026. }
  22027. _this37.stackMat4 = newArray34;
  22028. }
  22029. _this37.stackMat4[_this37.sizeMat4++] = mat48;
  22030. }
  22031. if(quat8 != null) {
  22032. var tx13 = 0;
  22033. var ty13 = 0;
  22034. var tz13 = 0;
  22035. var tw8 = 1;
  22036. quat8.x = tx13;
  22037. quat8.y = ty13;
  22038. quat8.z = tz13;
  22039. quat8.w = tw8;
  22040. if(_this37.sizeQuat == _this37.stackQuat.length) {
  22041. var newLength35 = _this37.sizeQuat << 1;
  22042. var this36 = new Array(newLength35);
  22043. var newArray35 = this36;
  22044. var _g46 = 0;
  22045. var _g136 = _this37.sizeQuat;
  22046. while(_g46 < _g136) {
  22047. var i36 = _g46++;
  22048. newArray35[i36] = _this37.stackQuat[i36];
  22049. _this37.stackQuat[i36] = null;
  22050. }
  22051. _this37.stackQuat = newArray35;
  22052. }
  22053. _this37.stackQuat[_this37.sizeQuat++] = quat8;
  22054. }
  22055. var _this38 = this._pool;
  22056. var mat39 = null;
  22057. var mat49 = null;
  22058. var quat9 = null;
  22059. if(p2 != null) {
  22060. p2.zero();
  22061. if(_this38.sizeVec3 == _this38.stackVec3.length) {
  22062. var newLength36 = _this38.sizeVec3 << 1;
  22063. var this37 = new Array(newLength36);
  22064. var newArray36 = this37;
  22065. var _g47 = 0;
  22066. var _g137 = _this38.sizeVec3;
  22067. while(_g47 < _g137) {
  22068. var i37 = _g47++;
  22069. newArray36[i37] = _this38.stackVec3[i37];
  22070. _this38.stackVec3[i37] = null;
  22071. }
  22072. _this38.stackVec3 = newArray36;
  22073. }
  22074. _this38.stackVec3[_this38.sizeVec3++] = p2;
  22075. }
  22076. if(mat39 != null) {
  22077. var t0018 = 1;
  22078. var t0118 = 0;
  22079. var t0218 = 0;
  22080. var t1018 = 0;
  22081. var t1118 = 1;
  22082. var t1218 = 0;
  22083. var t2018 = 0;
  22084. var t2118 = 0;
  22085. var t2218 = 1;
  22086. mat39.e00 = t0018;
  22087. mat39.e01 = t0118;
  22088. mat39.e02 = t0218;
  22089. mat39.e10 = t1018;
  22090. mat39.e11 = t1118;
  22091. mat39.e12 = t1218;
  22092. mat39.e20 = t2018;
  22093. mat39.e21 = t2118;
  22094. mat39.e22 = t2218;
  22095. if(_this38.sizeMat3 == _this38.stackMat3.length) {
  22096. var newLength37 = _this38.sizeMat3 << 1;
  22097. var this38 = new Array(newLength37);
  22098. var newArray37 = this38;
  22099. var _g48 = 0;
  22100. var _g138 = _this38.sizeMat3;
  22101. while(_g48 < _g138) {
  22102. var i38 = _g48++;
  22103. newArray37[i38] = _this38.stackMat3[i38];
  22104. _this38.stackMat3[i38] = null;
  22105. }
  22106. _this38.stackMat3 = newArray37;
  22107. }
  22108. _this38.stackMat3[_this38.sizeMat3++] = mat39;
  22109. }
  22110. if(mat49 != null) {
  22111. var t0019 = 1;
  22112. var t0119 = 0;
  22113. var t0219 = 0;
  22114. var t039 = 0;
  22115. var t1019 = 0;
  22116. var t1119 = 1;
  22117. var t1219 = 0;
  22118. var t139 = 0;
  22119. var t2019 = 0;
  22120. var t2119 = 0;
  22121. var t2219 = 1;
  22122. var t239 = 0;
  22123. var t309 = 0;
  22124. var t319 = 0;
  22125. var t329 = 0;
  22126. var t339 = 1;
  22127. mat49.e00 = t0019;
  22128. mat49.e01 = t0119;
  22129. mat49.e02 = t0219;
  22130. mat49.e03 = t039;
  22131. mat49.e10 = t1019;
  22132. mat49.e11 = t1119;
  22133. mat49.e12 = t1219;
  22134. mat49.e13 = t139;
  22135. mat49.e20 = t2019;
  22136. mat49.e21 = t2119;
  22137. mat49.e22 = t2219;
  22138. mat49.e23 = t239;
  22139. mat49.e30 = t309;
  22140. mat49.e31 = t319;
  22141. mat49.e32 = t329;
  22142. mat49.e33 = t339;
  22143. if(_this38.sizeMat4 == _this38.stackMat4.length) {
  22144. var newLength38 = _this38.sizeMat4 << 1;
  22145. var this39 = new Array(newLength38);
  22146. var newArray38 = this39;
  22147. var _g49 = 0;
  22148. var _g139 = _this38.sizeMat4;
  22149. while(_g49 < _g139) {
  22150. var i39 = _g49++;
  22151. newArray38[i39] = _this38.stackMat4[i39];
  22152. _this38.stackMat4[i39] = null;
  22153. }
  22154. _this38.stackMat4 = newArray38;
  22155. }
  22156. _this38.stackMat4[_this38.sizeMat4++] = mat49;
  22157. }
  22158. if(quat9 != null) {
  22159. var tx14 = 0;
  22160. var ty14 = 0;
  22161. var tz14 = 0;
  22162. var tw9 = 1;
  22163. quat9.x = tx14;
  22164. quat9.y = ty14;
  22165. quat9.z = tz14;
  22166. quat9.w = tw9;
  22167. if(_this38.sizeQuat == _this38.stackQuat.length) {
  22168. var newLength39 = _this38.sizeQuat << 1;
  22169. var this40 = new Array(newLength39);
  22170. var newArray39 = this40;
  22171. var _g50 = 0;
  22172. var _g140 = _this38.sizeQuat;
  22173. while(_g50 < _g140) {
  22174. var i40 = _g50++;
  22175. newArray39[i40] = _this38.stackQuat[i40];
  22176. _this38.stackQuat[i40] = null;
  22177. }
  22178. _this38.stackQuat = newArray39;
  22179. }
  22180. _this38.stackQuat[_this38.sizeQuat++] = quat9;
  22181. }
  22182. var _this39 = this._pool;
  22183. var mat310 = null;
  22184. var mat410 = null;
  22185. var quat10 = null;
  22186. if(anchor1 != null) {
  22187. anchor1.zero();
  22188. if(_this39.sizeVec3 == _this39.stackVec3.length) {
  22189. var newLength40 = _this39.sizeVec3 << 1;
  22190. var this41 = new Array(newLength40);
  22191. var newArray40 = this41;
  22192. var _g51 = 0;
  22193. var _g141 = _this39.sizeVec3;
  22194. while(_g51 < _g141) {
  22195. var i41 = _g51++;
  22196. newArray40[i41] = _this39.stackVec3[i41];
  22197. _this39.stackVec3[i41] = null;
  22198. }
  22199. _this39.stackVec3 = newArray40;
  22200. }
  22201. _this39.stackVec3[_this39.sizeVec3++] = anchor1;
  22202. }
  22203. if(mat310 != null) {
  22204. var t0020 = 1;
  22205. var t0120 = 0;
  22206. var t0220 = 0;
  22207. var t1020 = 0;
  22208. var t1120 = 1;
  22209. var t1220 = 0;
  22210. var t2020 = 0;
  22211. var t2120 = 0;
  22212. var t2220 = 1;
  22213. mat310.e00 = t0020;
  22214. mat310.e01 = t0120;
  22215. mat310.e02 = t0220;
  22216. mat310.e10 = t1020;
  22217. mat310.e11 = t1120;
  22218. mat310.e12 = t1220;
  22219. mat310.e20 = t2020;
  22220. mat310.e21 = t2120;
  22221. mat310.e22 = t2220;
  22222. if(_this39.sizeMat3 == _this39.stackMat3.length) {
  22223. var newLength41 = _this39.sizeMat3 << 1;
  22224. var this42 = new Array(newLength41);
  22225. var newArray41 = this42;
  22226. var _g52 = 0;
  22227. var _g142 = _this39.sizeMat3;
  22228. while(_g52 < _g142) {
  22229. var i42 = _g52++;
  22230. newArray41[i42] = _this39.stackMat3[i42];
  22231. _this39.stackMat3[i42] = null;
  22232. }
  22233. _this39.stackMat3 = newArray41;
  22234. }
  22235. _this39.stackMat3[_this39.sizeMat3++] = mat310;
  22236. }
  22237. if(mat410 != null) {
  22238. var t0021 = 1;
  22239. var t0121 = 0;
  22240. var t0221 = 0;
  22241. var t0310 = 0;
  22242. var t1021 = 0;
  22243. var t1121 = 1;
  22244. var t1221 = 0;
  22245. var t1310 = 0;
  22246. var t2021 = 0;
  22247. var t2121 = 0;
  22248. var t2221 = 1;
  22249. var t2310 = 0;
  22250. var t3010 = 0;
  22251. var t3110 = 0;
  22252. var t3210 = 0;
  22253. var t3310 = 1;
  22254. mat410.e00 = t0021;
  22255. mat410.e01 = t0121;
  22256. mat410.e02 = t0221;
  22257. mat410.e03 = t0310;
  22258. mat410.e10 = t1021;
  22259. mat410.e11 = t1121;
  22260. mat410.e12 = t1221;
  22261. mat410.e13 = t1310;
  22262. mat410.e20 = t2021;
  22263. mat410.e21 = t2121;
  22264. mat410.e22 = t2221;
  22265. mat410.e23 = t2310;
  22266. mat410.e30 = t3010;
  22267. mat410.e31 = t3110;
  22268. mat410.e32 = t3210;
  22269. mat410.e33 = t3310;
  22270. if(_this39.sizeMat4 == _this39.stackMat4.length) {
  22271. var newLength42 = _this39.sizeMat4 << 1;
  22272. var this43 = new Array(newLength42);
  22273. var newArray42 = this43;
  22274. var _g53 = 0;
  22275. var _g143 = _this39.sizeMat4;
  22276. while(_g53 < _g143) {
  22277. var i43 = _g53++;
  22278. newArray42[i43] = _this39.stackMat4[i43];
  22279. _this39.stackMat4[i43] = null;
  22280. }
  22281. _this39.stackMat4 = newArray42;
  22282. }
  22283. _this39.stackMat4[_this39.sizeMat4++] = mat410;
  22284. }
  22285. if(quat10 != null) {
  22286. var tx15 = 0;
  22287. var ty15 = 0;
  22288. var tz15 = 0;
  22289. var tw10 = 1;
  22290. quat10.x = tx15;
  22291. quat10.y = ty15;
  22292. quat10.z = tz15;
  22293. quat10.w = tw10;
  22294. if(_this39.sizeQuat == _this39.stackQuat.length) {
  22295. var newLength43 = _this39.sizeQuat << 1;
  22296. var this44 = new Array(newLength43);
  22297. var newArray43 = this44;
  22298. var _g54 = 0;
  22299. var _g144 = _this39.sizeQuat;
  22300. while(_g54 < _g144) {
  22301. var i44 = _g54++;
  22302. newArray43[i44] = _this39.stackQuat[i44];
  22303. _this39.stackQuat[i44] = null;
  22304. }
  22305. _this39.stackQuat = newArray43;
  22306. }
  22307. _this39.stackQuat[_this39.sizeQuat++] = quat10;
  22308. }
  22309. var _this40 = this._pool;
  22310. var mat311 = null;
  22311. var mat411 = null;
  22312. var quat11 = null;
  22313. if(anchor2 != null) {
  22314. anchor2.zero();
  22315. if(_this40.sizeVec3 == _this40.stackVec3.length) {
  22316. var newLength44 = _this40.sizeVec3 << 1;
  22317. var this45 = new Array(newLength44);
  22318. var newArray44 = this45;
  22319. var _g55 = 0;
  22320. var _g145 = _this40.sizeVec3;
  22321. while(_g55 < _g145) {
  22322. var i45 = _g55++;
  22323. newArray44[i45] = _this40.stackVec3[i45];
  22324. _this40.stackVec3[i45] = null;
  22325. }
  22326. _this40.stackVec3 = newArray44;
  22327. }
  22328. _this40.stackVec3[_this40.sizeVec3++] = anchor2;
  22329. }
  22330. if(mat311 != null) {
  22331. var t0022 = 1;
  22332. var t0122 = 0;
  22333. var t0222 = 0;
  22334. var t1022 = 0;
  22335. var t1122 = 1;
  22336. var t1222 = 0;
  22337. var t2022 = 0;
  22338. var t2122 = 0;
  22339. var t2222 = 1;
  22340. mat311.e00 = t0022;
  22341. mat311.e01 = t0122;
  22342. mat311.e02 = t0222;
  22343. mat311.e10 = t1022;
  22344. mat311.e11 = t1122;
  22345. mat311.e12 = t1222;
  22346. mat311.e20 = t2022;
  22347. mat311.e21 = t2122;
  22348. mat311.e22 = t2222;
  22349. if(_this40.sizeMat3 == _this40.stackMat3.length) {
  22350. var newLength45 = _this40.sizeMat3 << 1;
  22351. var this46 = new Array(newLength45);
  22352. var newArray45 = this46;
  22353. var _g56 = 0;
  22354. var _g146 = _this40.sizeMat3;
  22355. while(_g56 < _g146) {
  22356. var i46 = _g56++;
  22357. newArray45[i46] = _this40.stackMat3[i46];
  22358. _this40.stackMat3[i46] = null;
  22359. }
  22360. _this40.stackMat3 = newArray45;
  22361. }
  22362. _this40.stackMat3[_this40.sizeMat3++] = mat311;
  22363. }
  22364. if(mat411 != null) {
  22365. var t0023 = 1;
  22366. var t0123 = 0;
  22367. var t0223 = 0;
  22368. var t0311 = 0;
  22369. var t1023 = 0;
  22370. var t1123 = 1;
  22371. var t1223 = 0;
  22372. var t1311 = 0;
  22373. var t2023 = 0;
  22374. var t2123 = 0;
  22375. var t2223 = 1;
  22376. var t2311 = 0;
  22377. var t3011 = 0;
  22378. var t3111 = 0;
  22379. var t3211 = 0;
  22380. var t3311 = 1;
  22381. mat411.e00 = t0023;
  22382. mat411.e01 = t0123;
  22383. mat411.e02 = t0223;
  22384. mat411.e03 = t0311;
  22385. mat411.e10 = t1023;
  22386. mat411.e11 = t1123;
  22387. mat411.e12 = t1223;
  22388. mat411.e13 = t1311;
  22389. mat411.e20 = t2023;
  22390. mat411.e21 = t2123;
  22391. mat411.e22 = t2223;
  22392. mat411.e23 = t2311;
  22393. mat411.e30 = t3011;
  22394. mat411.e31 = t3111;
  22395. mat411.e32 = t3211;
  22396. mat411.e33 = t3311;
  22397. if(_this40.sizeMat4 == _this40.stackMat4.length) {
  22398. var newLength46 = _this40.sizeMat4 << 1;
  22399. var this47 = new Array(newLength46);
  22400. var newArray46 = this47;
  22401. var _g57 = 0;
  22402. var _g147 = _this40.sizeMat4;
  22403. while(_g57 < _g147) {
  22404. var i47 = _g57++;
  22405. newArray46[i47] = _this40.stackMat4[i47];
  22406. _this40.stackMat4[i47] = null;
  22407. }
  22408. _this40.stackMat4 = newArray46;
  22409. }
  22410. _this40.stackMat4[_this40.sizeMat4++] = mat411;
  22411. }
  22412. if(quat11 != null) {
  22413. var tx16 = 0;
  22414. var ty16 = 0;
  22415. var tz16 = 0;
  22416. var tw11 = 1;
  22417. quat11.x = tx16;
  22418. quat11.y = ty16;
  22419. quat11.z = tz16;
  22420. quat11.w = tw11;
  22421. if(_this40.sizeQuat == _this40.stackQuat.length) {
  22422. var newLength47 = _this40.sizeQuat << 1;
  22423. var this48 = new Array(newLength47);
  22424. var newArray47 = this48;
  22425. var _g58 = 0;
  22426. var _g148 = _this40.sizeQuat;
  22427. while(_g58 < _g148) {
  22428. var i48 = _g58++;
  22429. newArray47[i48] = _this40.stackQuat[i48];
  22430. _this40.stackQuat[i48] = null;
  22431. }
  22432. _this40.stackQuat = newArray47;
  22433. }
  22434. _this40.stackQuat[_this40.sizeQuat++] = quat11;
  22435. }
  22436. var _this41 = this._pool;
  22437. var mat312 = null;
  22438. var mat412 = null;
  22439. var quat12 = null;
  22440. if(basisX1 != null) {
  22441. basisX1.zero();
  22442. if(_this41.sizeVec3 == _this41.stackVec3.length) {
  22443. var newLength48 = _this41.sizeVec3 << 1;
  22444. var this49 = new Array(newLength48);
  22445. var newArray48 = this49;
  22446. var _g59 = 0;
  22447. var _g149 = _this41.sizeVec3;
  22448. while(_g59 < _g149) {
  22449. var i49 = _g59++;
  22450. newArray48[i49] = _this41.stackVec3[i49];
  22451. _this41.stackVec3[i49] = null;
  22452. }
  22453. _this41.stackVec3 = newArray48;
  22454. }
  22455. _this41.stackVec3[_this41.sizeVec3++] = basisX1;
  22456. }
  22457. if(mat312 != null) {
  22458. var t0024 = 1;
  22459. var t0124 = 0;
  22460. var t0224 = 0;
  22461. var t1024 = 0;
  22462. var t1124 = 1;
  22463. var t1224 = 0;
  22464. var t2024 = 0;
  22465. var t2124 = 0;
  22466. var t2224 = 1;
  22467. mat312.e00 = t0024;
  22468. mat312.e01 = t0124;
  22469. mat312.e02 = t0224;
  22470. mat312.e10 = t1024;
  22471. mat312.e11 = t1124;
  22472. mat312.e12 = t1224;
  22473. mat312.e20 = t2024;
  22474. mat312.e21 = t2124;
  22475. mat312.e22 = t2224;
  22476. if(_this41.sizeMat3 == _this41.stackMat3.length) {
  22477. var newLength49 = _this41.sizeMat3 << 1;
  22478. var this50 = new Array(newLength49);
  22479. var newArray49 = this50;
  22480. var _g60 = 0;
  22481. var _g150 = _this41.sizeMat3;
  22482. while(_g60 < _g150) {
  22483. var i50 = _g60++;
  22484. newArray49[i50] = _this41.stackMat3[i50];
  22485. _this41.stackMat3[i50] = null;
  22486. }
  22487. _this41.stackMat3 = newArray49;
  22488. }
  22489. _this41.stackMat3[_this41.sizeMat3++] = mat312;
  22490. }
  22491. if(mat412 != null) {
  22492. var t0025 = 1;
  22493. var t0125 = 0;
  22494. var t0225 = 0;
  22495. var t0312 = 0;
  22496. var t1025 = 0;
  22497. var t1125 = 1;
  22498. var t1225 = 0;
  22499. var t1312 = 0;
  22500. var t2025 = 0;
  22501. var t2125 = 0;
  22502. var t2225 = 1;
  22503. var t2312 = 0;
  22504. var t3012 = 0;
  22505. var t3112 = 0;
  22506. var t3212 = 0;
  22507. var t3312 = 1;
  22508. mat412.e00 = t0025;
  22509. mat412.e01 = t0125;
  22510. mat412.e02 = t0225;
  22511. mat412.e03 = t0312;
  22512. mat412.e10 = t1025;
  22513. mat412.e11 = t1125;
  22514. mat412.e12 = t1225;
  22515. mat412.e13 = t1312;
  22516. mat412.e20 = t2025;
  22517. mat412.e21 = t2125;
  22518. mat412.e22 = t2225;
  22519. mat412.e23 = t2312;
  22520. mat412.e30 = t3012;
  22521. mat412.e31 = t3112;
  22522. mat412.e32 = t3212;
  22523. mat412.e33 = t3312;
  22524. if(_this41.sizeMat4 == _this41.stackMat4.length) {
  22525. var newLength50 = _this41.sizeMat4 << 1;
  22526. var this51 = new Array(newLength50);
  22527. var newArray50 = this51;
  22528. var _g61 = 0;
  22529. var _g151 = _this41.sizeMat4;
  22530. while(_g61 < _g151) {
  22531. var i51 = _g61++;
  22532. newArray50[i51] = _this41.stackMat4[i51];
  22533. _this41.stackMat4[i51] = null;
  22534. }
  22535. _this41.stackMat4 = newArray50;
  22536. }
  22537. _this41.stackMat4[_this41.sizeMat4++] = mat412;
  22538. }
  22539. if(quat12 != null) {
  22540. var tx17 = 0;
  22541. var ty17 = 0;
  22542. var tz17 = 0;
  22543. var tw12 = 1;
  22544. quat12.x = tx17;
  22545. quat12.y = ty17;
  22546. quat12.z = tz17;
  22547. quat12.w = tw12;
  22548. if(_this41.sizeQuat == _this41.stackQuat.length) {
  22549. var newLength51 = _this41.sizeQuat << 1;
  22550. var this52 = new Array(newLength51);
  22551. var newArray51 = this52;
  22552. var _g62 = 0;
  22553. var _g152 = _this41.sizeQuat;
  22554. while(_g62 < _g152) {
  22555. var i52 = _g62++;
  22556. newArray51[i52] = _this41.stackQuat[i52];
  22557. _this41.stackQuat[i52] = null;
  22558. }
  22559. _this41.stackQuat = newArray51;
  22560. }
  22561. _this41.stackQuat[_this41.sizeQuat++] = quat12;
  22562. }
  22563. var _this42 = this._pool;
  22564. var mat313 = null;
  22565. var mat413 = null;
  22566. var quat13 = null;
  22567. if(basisY1 != null) {
  22568. basisY1.zero();
  22569. if(_this42.sizeVec3 == _this42.stackVec3.length) {
  22570. var newLength52 = _this42.sizeVec3 << 1;
  22571. var this53 = new Array(newLength52);
  22572. var newArray52 = this53;
  22573. var _g63 = 0;
  22574. var _g153 = _this42.sizeVec3;
  22575. while(_g63 < _g153) {
  22576. var i53 = _g63++;
  22577. newArray52[i53] = _this42.stackVec3[i53];
  22578. _this42.stackVec3[i53] = null;
  22579. }
  22580. _this42.stackVec3 = newArray52;
  22581. }
  22582. _this42.stackVec3[_this42.sizeVec3++] = basisY1;
  22583. }
  22584. if(mat313 != null) {
  22585. var t0026 = 1;
  22586. var t0126 = 0;
  22587. var t0226 = 0;
  22588. var t1026 = 0;
  22589. var t1126 = 1;
  22590. var t1226 = 0;
  22591. var t2026 = 0;
  22592. var t2126 = 0;
  22593. var t2226 = 1;
  22594. mat313.e00 = t0026;
  22595. mat313.e01 = t0126;
  22596. mat313.e02 = t0226;
  22597. mat313.e10 = t1026;
  22598. mat313.e11 = t1126;
  22599. mat313.e12 = t1226;
  22600. mat313.e20 = t2026;
  22601. mat313.e21 = t2126;
  22602. mat313.e22 = t2226;
  22603. if(_this42.sizeMat3 == _this42.stackMat3.length) {
  22604. var newLength53 = _this42.sizeMat3 << 1;
  22605. var this54 = new Array(newLength53);
  22606. var newArray53 = this54;
  22607. var _g64 = 0;
  22608. var _g154 = _this42.sizeMat3;
  22609. while(_g64 < _g154) {
  22610. var i54 = _g64++;
  22611. newArray53[i54] = _this42.stackMat3[i54];
  22612. _this42.stackMat3[i54] = null;
  22613. }
  22614. _this42.stackMat3 = newArray53;
  22615. }
  22616. _this42.stackMat3[_this42.sizeMat3++] = mat313;
  22617. }
  22618. if(mat413 != null) {
  22619. var t0027 = 1;
  22620. var t0127 = 0;
  22621. var t0227 = 0;
  22622. var t0313 = 0;
  22623. var t1027 = 0;
  22624. var t1127 = 1;
  22625. var t1227 = 0;
  22626. var t1313 = 0;
  22627. var t2027 = 0;
  22628. var t2127 = 0;
  22629. var t2227 = 1;
  22630. var t2313 = 0;
  22631. var t3013 = 0;
  22632. var t3113 = 0;
  22633. var t3213 = 0;
  22634. var t3313 = 1;
  22635. mat413.e00 = t0027;
  22636. mat413.e01 = t0127;
  22637. mat413.e02 = t0227;
  22638. mat413.e03 = t0313;
  22639. mat413.e10 = t1027;
  22640. mat413.e11 = t1127;
  22641. mat413.e12 = t1227;
  22642. mat413.e13 = t1313;
  22643. mat413.e20 = t2027;
  22644. mat413.e21 = t2127;
  22645. mat413.e22 = t2227;
  22646. mat413.e23 = t2313;
  22647. mat413.e30 = t3013;
  22648. mat413.e31 = t3113;
  22649. mat413.e32 = t3213;
  22650. mat413.e33 = t3313;
  22651. if(_this42.sizeMat4 == _this42.stackMat4.length) {
  22652. var newLength54 = _this42.sizeMat4 << 1;
  22653. var this55 = new Array(newLength54);
  22654. var newArray54 = this55;
  22655. var _g65 = 0;
  22656. var _g155 = _this42.sizeMat4;
  22657. while(_g65 < _g155) {
  22658. var i55 = _g65++;
  22659. newArray54[i55] = _this42.stackMat4[i55];
  22660. _this42.stackMat4[i55] = null;
  22661. }
  22662. _this42.stackMat4 = newArray54;
  22663. }
  22664. _this42.stackMat4[_this42.sizeMat4++] = mat413;
  22665. }
  22666. if(quat13 != null) {
  22667. var tx18 = 0;
  22668. var ty18 = 0;
  22669. var tz18 = 0;
  22670. var tw13 = 1;
  22671. quat13.x = tx18;
  22672. quat13.y = ty18;
  22673. quat13.z = tz18;
  22674. quat13.w = tw13;
  22675. if(_this42.sizeQuat == _this42.stackQuat.length) {
  22676. var newLength55 = _this42.sizeQuat << 1;
  22677. var this56 = new Array(newLength55);
  22678. var newArray55 = this56;
  22679. var _g66 = 0;
  22680. var _g156 = _this42.sizeQuat;
  22681. while(_g66 < _g156) {
  22682. var i56 = _g66++;
  22683. newArray55[i56] = _this42.stackQuat[i56];
  22684. _this42.stackQuat[i56] = null;
  22685. }
  22686. _this42.stackQuat = newArray55;
  22687. }
  22688. _this42.stackQuat[_this42.sizeQuat++] = quat13;
  22689. }
  22690. var _this43 = this._pool;
  22691. var mat314 = null;
  22692. var mat414 = null;
  22693. var quat14 = null;
  22694. if(basisZ1 != null) {
  22695. basisZ1.zero();
  22696. if(_this43.sizeVec3 == _this43.stackVec3.length) {
  22697. var newLength56 = _this43.sizeVec3 << 1;
  22698. var this57 = new Array(newLength56);
  22699. var newArray56 = this57;
  22700. var _g67 = 0;
  22701. var _g157 = _this43.sizeVec3;
  22702. while(_g67 < _g157) {
  22703. var i57 = _g67++;
  22704. newArray56[i57] = _this43.stackVec3[i57];
  22705. _this43.stackVec3[i57] = null;
  22706. }
  22707. _this43.stackVec3 = newArray56;
  22708. }
  22709. _this43.stackVec3[_this43.sizeVec3++] = basisZ1;
  22710. }
  22711. if(mat314 != null) {
  22712. var t0028 = 1;
  22713. var t0128 = 0;
  22714. var t0228 = 0;
  22715. var t1028 = 0;
  22716. var t1128 = 1;
  22717. var t1228 = 0;
  22718. var t2028 = 0;
  22719. var t2128 = 0;
  22720. var t2228 = 1;
  22721. mat314.e00 = t0028;
  22722. mat314.e01 = t0128;
  22723. mat314.e02 = t0228;
  22724. mat314.e10 = t1028;
  22725. mat314.e11 = t1128;
  22726. mat314.e12 = t1228;
  22727. mat314.e20 = t2028;
  22728. mat314.e21 = t2128;
  22729. mat314.e22 = t2228;
  22730. if(_this43.sizeMat3 == _this43.stackMat3.length) {
  22731. var newLength57 = _this43.sizeMat3 << 1;
  22732. var this58 = new Array(newLength57);
  22733. var newArray57 = this58;
  22734. var _g68 = 0;
  22735. var _g158 = _this43.sizeMat3;
  22736. while(_g68 < _g158) {
  22737. var i58 = _g68++;
  22738. newArray57[i58] = _this43.stackMat3[i58];
  22739. _this43.stackMat3[i58] = null;
  22740. }
  22741. _this43.stackMat3 = newArray57;
  22742. }
  22743. _this43.stackMat3[_this43.sizeMat3++] = mat314;
  22744. }
  22745. if(mat414 != null) {
  22746. var t0029 = 1;
  22747. var t0129 = 0;
  22748. var t0229 = 0;
  22749. var t0314 = 0;
  22750. var t1029 = 0;
  22751. var t1129 = 1;
  22752. var t1229 = 0;
  22753. var t1314 = 0;
  22754. var t2029 = 0;
  22755. var t2129 = 0;
  22756. var t2229 = 1;
  22757. var t2314 = 0;
  22758. var t3014 = 0;
  22759. var t3114 = 0;
  22760. var t3214 = 0;
  22761. var t3314 = 1;
  22762. mat414.e00 = t0029;
  22763. mat414.e01 = t0129;
  22764. mat414.e02 = t0229;
  22765. mat414.e03 = t0314;
  22766. mat414.e10 = t1029;
  22767. mat414.e11 = t1129;
  22768. mat414.e12 = t1229;
  22769. mat414.e13 = t1314;
  22770. mat414.e20 = t2029;
  22771. mat414.e21 = t2129;
  22772. mat414.e22 = t2229;
  22773. mat414.e23 = t2314;
  22774. mat414.e30 = t3014;
  22775. mat414.e31 = t3114;
  22776. mat414.e32 = t3214;
  22777. mat414.e33 = t3314;
  22778. if(_this43.sizeMat4 == _this43.stackMat4.length) {
  22779. var newLength58 = _this43.sizeMat4 << 1;
  22780. var this59 = new Array(newLength58);
  22781. var newArray58 = this59;
  22782. var _g69 = 0;
  22783. var _g159 = _this43.sizeMat4;
  22784. while(_g69 < _g159) {
  22785. var i59 = _g69++;
  22786. newArray58[i59] = _this43.stackMat4[i59];
  22787. _this43.stackMat4[i59] = null;
  22788. }
  22789. _this43.stackMat4 = newArray58;
  22790. }
  22791. _this43.stackMat4[_this43.sizeMat4++] = mat414;
  22792. }
  22793. if(quat14 != null) {
  22794. var tx19 = 0;
  22795. var ty19 = 0;
  22796. var tz19 = 0;
  22797. var tw14 = 1;
  22798. quat14.x = tx19;
  22799. quat14.y = ty19;
  22800. quat14.z = tz19;
  22801. quat14.w = tw14;
  22802. if(_this43.sizeQuat == _this43.stackQuat.length) {
  22803. var newLength59 = _this43.sizeQuat << 1;
  22804. var this60 = new Array(newLength59);
  22805. var newArray59 = this60;
  22806. var _g70 = 0;
  22807. var _g160 = _this43.sizeQuat;
  22808. while(_g70 < _g160) {
  22809. var i60 = _g70++;
  22810. newArray59[i60] = _this43.stackQuat[i60];
  22811. _this43.stackQuat[i60] = null;
  22812. }
  22813. _this43.stackQuat = newArray59;
  22814. }
  22815. _this43.stackQuat[_this43.sizeQuat++] = quat14;
  22816. }
  22817. var _this44 = this._pool;
  22818. var mat315 = null;
  22819. var mat415 = null;
  22820. var quat15 = null;
  22821. if(basisX2 != null) {
  22822. basisX2.zero();
  22823. if(_this44.sizeVec3 == _this44.stackVec3.length) {
  22824. var newLength60 = _this44.sizeVec3 << 1;
  22825. var this61 = new Array(newLength60);
  22826. var newArray60 = this61;
  22827. var _g71 = 0;
  22828. var _g161 = _this44.sizeVec3;
  22829. while(_g71 < _g161) {
  22830. var i61 = _g71++;
  22831. newArray60[i61] = _this44.stackVec3[i61];
  22832. _this44.stackVec3[i61] = null;
  22833. }
  22834. _this44.stackVec3 = newArray60;
  22835. }
  22836. _this44.stackVec3[_this44.sizeVec3++] = basisX2;
  22837. }
  22838. if(mat315 != null) {
  22839. var t0030 = 1;
  22840. var t0130 = 0;
  22841. var t0230 = 0;
  22842. var t1030 = 0;
  22843. var t1130 = 1;
  22844. var t1230 = 0;
  22845. var t2030 = 0;
  22846. var t2130 = 0;
  22847. var t2230 = 1;
  22848. mat315.e00 = t0030;
  22849. mat315.e01 = t0130;
  22850. mat315.e02 = t0230;
  22851. mat315.e10 = t1030;
  22852. mat315.e11 = t1130;
  22853. mat315.e12 = t1230;
  22854. mat315.e20 = t2030;
  22855. mat315.e21 = t2130;
  22856. mat315.e22 = t2230;
  22857. if(_this44.sizeMat3 == _this44.stackMat3.length) {
  22858. var newLength61 = _this44.sizeMat3 << 1;
  22859. var this62 = new Array(newLength61);
  22860. var newArray61 = this62;
  22861. var _g72 = 0;
  22862. var _g162 = _this44.sizeMat3;
  22863. while(_g72 < _g162) {
  22864. var i62 = _g72++;
  22865. newArray61[i62] = _this44.stackMat3[i62];
  22866. _this44.stackMat3[i62] = null;
  22867. }
  22868. _this44.stackMat3 = newArray61;
  22869. }
  22870. _this44.stackMat3[_this44.sizeMat3++] = mat315;
  22871. }
  22872. if(mat415 != null) {
  22873. var t0031 = 1;
  22874. var t0131 = 0;
  22875. var t0231 = 0;
  22876. var t0315 = 0;
  22877. var t1031 = 0;
  22878. var t1131 = 1;
  22879. var t1231 = 0;
  22880. var t1315 = 0;
  22881. var t2031 = 0;
  22882. var t2131 = 0;
  22883. var t2231 = 1;
  22884. var t2315 = 0;
  22885. var t3015 = 0;
  22886. var t3115 = 0;
  22887. var t3215 = 0;
  22888. var t3315 = 1;
  22889. mat415.e00 = t0031;
  22890. mat415.e01 = t0131;
  22891. mat415.e02 = t0231;
  22892. mat415.e03 = t0315;
  22893. mat415.e10 = t1031;
  22894. mat415.e11 = t1131;
  22895. mat415.e12 = t1231;
  22896. mat415.e13 = t1315;
  22897. mat415.e20 = t2031;
  22898. mat415.e21 = t2131;
  22899. mat415.e22 = t2231;
  22900. mat415.e23 = t2315;
  22901. mat415.e30 = t3015;
  22902. mat415.e31 = t3115;
  22903. mat415.e32 = t3215;
  22904. mat415.e33 = t3315;
  22905. if(_this44.sizeMat4 == _this44.stackMat4.length) {
  22906. var newLength62 = _this44.sizeMat4 << 1;
  22907. var this63 = new Array(newLength62);
  22908. var newArray62 = this63;
  22909. var _g73 = 0;
  22910. var _g163 = _this44.sizeMat4;
  22911. while(_g73 < _g163) {
  22912. var i63 = _g73++;
  22913. newArray62[i63] = _this44.stackMat4[i63];
  22914. _this44.stackMat4[i63] = null;
  22915. }
  22916. _this44.stackMat4 = newArray62;
  22917. }
  22918. _this44.stackMat4[_this44.sizeMat4++] = mat415;
  22919. }
  22920. if(quat15 != null) {
  22921. var tx20 = 0;
  22922. var ty20 = 0;
  22923. var tz20 = 0;
  22924. var tw15 = 1;
  22925. quat15.x = tx20;
  22926. quat15.y = ty20;
  22927. quat15.z = tz20;
  22928. quat15.w = tw15;
  22929. if(_this44.sizeQuat == _this44.stackQuat.length) {
  22930. var newLength63 = _this44.sizeQuat << 1;
  22931. var this64 = new Array(newLength63);
  22932. var newArray63 = this64;
  22933. var _g74 = 0;
  22934. var _g164 = _this44.sizeQuat;
  22935. while(_g74 < _g164) {
  22936. var i64 = _g74++;
  22937. newArray63[i64] = _this44.stackQuat[i64];
  22938. _this44.stackQuat[i64] = null;
  22939. }
  22940. _this44.stackQuat = newArray63;
  22941. }
  22942. _this44.stackQuat[_this44.sizeQuat++] = quat15;
  22943. }
  22944. var _this45 = this._pool;
  22945. var mat316 = null;
  22946. var mat416 = null;
  22947. var quat16 = null;
  22948. if(basisY2 != null) {
  22949. basisY2.zero();
  22950. if(_this45.sizeVec3 == _this45.stackVec3.length) {
  22951. var newLength64 = _this45.sizeVec3 << 1;
  22952. var this65 = new Array(newLength64);
  22953. var newArray64 = this65;
  22954. var _g75 = 0;
  22955. var _g165 = _this45.sizeVec3;
  22956. while(_g75 < _g165) {
  22957. var i65 = _g75++;
  22958. newArray64[i65] = _this45.stackVec3[i65];
  22959. _this45.stackVec3[i65] = null;
  22960. }
  22961. _this45.stackVec3 = newArray64;
  22962. }
  22963. _this45.stackVec3[_this45.sizeVec3++] = basisY2;
  22964. }
  22965. if(mat316 != null) {
  22966. var t0032 = 1;
  22967. var t0132 = 0;
  22968. var t0232 = 0;
  22969. var t1032 = 0;
  22970. var t1132 = 1;
  22971. var t1232 = 0;
  22972. var t2032 = 0;
  22973. var t2132 = 0;
  22974. var t2232 = 1;
  22975. mat316.e00 = t0032;
  22976. mat316.e01 = t0132;
  22977. mat316.e02 = t0232;
  22978. mat316.e10 = t1032;
  22979. mat316.e11 = t1132;
  22980. mat316.e12 = t1232;
  22981. mat316.e20 = t2032;
  22982. mat316.e21 = t2132;
  22983. mat316.e22 = t2232;
  22984. if(_this45.sizeMat3 == _this45.stackMat3.length) {
  22985. var newLength65 = _this45.sizeMat3 << 1;
  22986. var this66 = new Array(newLength65);
  22987. var newArray65 = this66;
  22988. var _g76 = 0;
  22989. var _g166 = _this45.sizeMat3;
  22990. while(_g76 < _g166) {
  22991. var i66 = _g76++;
  22992. newArray65[i66] = _this45.stackMat3[i66];
  22993. _this45.stackMat3[i66] = null;
  22994. }
  22995. _this45.stackMat3 = newArray65;
  22996. }
  22997. _this45.stackMat3[_this45.sizeMat3++] = mat316;
  22998. }
  22999. if(mat416 != null) {
  23000. var t0033 = 1;
  23001. var t0133 = 0;
  23002. var t0233 = 0;
  23003. var t0316 = 0;
  23004. var t1033 = 0;
  23005. var t1133 = 1;
  23006. var t1233 = 0;
  23007. var t1316 = 0;
  23008. var t2033 = 0;
  23009. var t2133 = 0;
  23010. var t2233 = 1;
  23011. var t2316 = 0;
  23012. var t3016 = 0;
  23013. var t3116 = 0;
  23014. var t3216 = 0;
  23015. var t3316 = 1;
  23016. mat416.e00 = t0033;
  23017. mat416.e01 = t0133;
  23018. mat416.e02 = t0233;
  23019. mat416.e03 = t0316;
  23020. mat416.e10 = t1033;
  23021. mat416.e11 = t1133;
  23022. mat416.e12 = t1233;
  23023. mat416.e13 = t1316;
  23024. mat416.e20 = t2033;
  23025. mat416.e21 = t2133;
  23026. mat416.e22 = t2233;
  23027. mat416.e23 = t2316;
  23028. mat416.e30 = t3016;
  23029. mat416.e31 = t3116;
  23030. mat416.e32 = t3216;
  23031. mat416.e33 = t3316;
  23032. if(_this45.sizeMat4 == _this45.stackMat4.length) {
  23033. var newLength66 = _this45.sizeMat4 << 1;
  23034. var this67 = new Array(newLength66);
  23035. var newArray66 = this67;
  23036. var _g77 = 0;
  23037. var _g167 = _this45.sizeMat4;
  23038. while(_g77 < _g167) {
  23039. var i67 = _g77++;
  23040. newArray66[i67] = _this45.stackMat4[i67];
  23041. _this45.stackMat4[i67] = null;
  23042. }
  23043. _this45.stackMat4 = newArray66;
  23044. }
  23045. _this45.stackMat4[_this45.sizeMat4++] = mat416;
  23046. }
  23047. if(quat16 != null) {
  23048. var tx21 = 0;
  23049. var ty21 = 0;
  23050. var tz21 = 0;
  23051. var tw16 = 1;
  23052. quat16.x = tx21;
  23053. quat16.y = ty21;
  23054. quat16.z = tz21;
  23055. quat16.w = tw16;
  23056. if(_this45.sizeQuat == _this45.stackQuat.length) {
  23057. var newLength67 = _this45.sizeQuat << 1;
  23058. var this68 = new Array(newLength67);
  23059. var newArray67 = this68;
  23060. var _g78 = 0;
  23061. var _g168 = _this45.sizeQuat;
  23062. while(_g78 < _g168) {
  23063. var i68 = _g78++;
  23064. newArray67[i68] = _this45.stackQuat[i68];
  23065. _this45.stackQuat[i68] = null;
  23066. }
  23067. _this45.stackQuat = newArray67;
  23068. }
  23069. _this45.stackQuat[_this45.sizeQuat++] = quat16;
  23070. }
  23071. var _this46 = this._pool;
  23072. var mat317 = null;
  23073. var mat417 = null;
  23074. var quat17 = null;
  23075. if(basisZ2 != null) {
  23076. basisZ2.zero();
  23077. if(_this46.sizeVec3 == _this46.stackVec3.length) {
  23078. var newLength68 = _this46.sizeVec3 << 1;
  23079. var this69 = new Array(newLength68);
  23080. var newArray68 = this69;
  23081. var _g79 = 0;
  23082. var _g169 = _this46.sizeVec3;
  23083. while(_g79 < _g169) {
  23084. var i69 = _g79++;
  23085. newArray68[i69] = _this46.stackVec3[i69];
  23086. _this46.stackVec3[i69] = null;
  23087. }
  23088. _this46.stackVec3 = newArray68;
  23089. }
  23090. _this46.stackVec3[_this46.sizeVec3++] = basisZ2;
  23091. }
  23092. if(mat317 != null) {
  23093. var t0034 = 1;
  23094. var t0134 = 0;
  23095. var t0234 = 0;
  23096. var t1034 = 0;
  23097. var t1134 = 1;
  23098. var t1234 = 0;
  23099. var t2034 = 0;
  23100. var t2134 = 0;
  23101. var t2234 = 1;
  23102. mat317.e00 = t0034;
  23103. mat317.e01 = t0134;
  23104. mat317.e02 = t0234;
  23105. mat317.e10 = t1034;
  23106. mat317.e11 = t1134;
  23107. mat317.e12 = t1234;
  23108. mat317.e20 = t2034;
  23109. mat317.e21 = t2134;
  23110. mat317.e22 = t2234;
  23111. if(_this46.sizeMat3 == _this46.stackMat3.length) {
  23112. var newLength69 = _this46.sizeMat3 << 1;
  23113. var this70 = new Array(newLength69);
  23114. var newArray69 = this70;
  23115. var _g80 = 0;
  23116. var _g170 = _this46.sizeMat3;
  23117. while(_g80 < _g170) {
  23118. var i70 = _g80++;
  23119. newArray69[i70] = _this46.stackMat3[i70];
  23120. _this46.stackMat3[i70] = null;
  23121. }
  23122. _this46.stackMat3 = newArray69;
  23123. }
  23124. _this46.stackMat3[_this46.sizeMat3++] = mat317;
  23125. }
  23126. if(mat417 != null) {
  23127. var t0035 = 1;
  23128. var t0135 = 0;
  23129. var t0235 = 0;
  23130. var t0317 = 0;
  23131. var t1035 = 0;
  23132. var t1135 = 1;
  23133. var t1235 = 0;
  23134. var t1317 = 0;
  23135. var t2035 = 0;
  23136. var t2135 = 0;
  23137. var t2235 = 1;
  23138. var t2317 = 0;
  23139. var t3017 = 0;
  23140. var t3117 = 0;
  23141. var t3217 = 0;
  23142. var t3317 = 1;
  23143. mat417.e00 = t0035;
  23144. mat417.e01 = t0135;
  23145. mat417.e02 = t0235;
  23146. mat417.e03 = t0317;
  23147. mat417.e10 = t1035;
  23148. mat417.e11 = t1135;
  23149. mat417.e12 = t1235;
  23150. mat417.e13 = t1317;
  23151. mat417.e20 = t2035;
  23152. mat417.e21 = t2135;
  23153. mat417.e22 = t2235;
  23154. mat417.e23 = t2317;
  23155. mat417.e30 = t3017;
  23156. mat417.e31 = t3117;
  23157. mat417.e32 = t3217;
  23158. mat417.e33 = t3317;
  23159. if(_this46.sizeMat4 == _this46.stackMat4.length) {
  23160. var newLength70 = _this46.sizeMat4 << 1;
  23161. var this71 = new Array(newLength70);
  23162. var newArray70 = this71;
  23163. var _g81 = 0;
  23164. var _g171 = _this46.sizeMat4;
  23165. while(_g81 < _g171) {
  23166. var i71 = _g81++;
  23167. newArray70[i71] = _this46.stackMat4[i71];
  23168. _this46.stackMat4[i71] = null;
  23169. }
  23170. _this46.stackMat4 = newArray70;
  23171. }
  23172. _this46.stackMat4[_this46.sizeMat4++] = mat417;
  23173. }
  23174. if(quat17 != null) {
  23175. var tx22 = 0;
  23176. var ty22 = 0;
  23177. var tz22 = 0;
  23178. var tw17 = 1;
  23179. quat17.x = tx22;
  23180. quat17.y = ty22;
  23181. quat17.z = tz22;
  23182. quat17.w = tw17;
  23183. if(_this46.sizeQuat == _this46.stackQuat.length) {
  23184. var newLength71 = _this46.sizeQuat << 1;
  23185. var this72 = new Array(newLength71);
  23186. var newArray71 = this72;
  23187. var _g82 = 0;
  23188. var _g172 = _this46.sizeQuat;
  23189. while(_g82 < _g172) {
  23190. var i72 = _g82++;
  23191. newArray71[i72] = _this46.stackQuat[i72];
  23192. _this46.stackQuat[i72] = null;
  23193. }
  23194. _this46.stackQuat = newArray71;
  23195. }
  23196. _this46.stackQuat[_this46.sizeQuat++] = quat17;
  23197. }
  23198. j = n1;
  23199. }
  23200. }
  23201. }
  23202. _drawRotationalLimit(d,center,ex,ey,needle,radius,min,max,color) {
  23203. if(min != max) {
  23204. var _this = this._pool;
  23205. var _this1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  23206. _this1.x = center.x;
  23207. _this1.y = center.y;
  23208. _this1.z = center.z;
  23209. var _this2 = _this1;
  23210. var tx = _this2.x + needle.x * radius;
  23211. var ty = _this2.y + needle.y * radius;
  23212. var tz = _this2.z + needle.z * radius;
  23213. _this2.x = tx;
  23214. _this2.y = ty;
  23215. _this2.z = tz;
  23216. var to = _this2;
  23217. d.line(center,to,color);
  23218. var _this3 = this._pool;
  23219. var mat3 = null;
  23220. var mat4 = null;
  23221. var quat = null;
  23222. if(to != null) {
  23223. to.zero();
  23224. if(_this3.sizeVec3 == _this3.stackVec3.length) {
  23225. var newLength = _this3.sizeVec3 << 1;
  23226. var this1 = new Array(newLength);
  23227. var newArray = this1;
  23228. var _g = 0;
  23229. var _g1 = _this3.sizeVec3;
  23230. while(_g < _g1) {
  23231. var i = _g++;
  23232. newArray[i] = _this3.stackVec3[i];
  23233. _this3.stackVec3[i] = null;
  23234. }
  23235. _this3.stackVec3 = newArray;
  23236. }
  23237. _this3.stackVec3[_this3.sizeVec3++] = to;
  23238. }
  23239. if(mat3 != null) {
  23240. var t00 = 1;
  23241. var t01 = 0;
  23242. var t02 = 0;
  23243. var t10 = 0;
  23244. var t11 = 1;
  23245. var t12 = 0;
  23246. var t20 = 0;
  23247. var t21 = 0;
  23248. var t22 = 1;
  23249. mat3.e00 = t00;
  23250. mat3.e01 = t01;
  23251. mat3.e02 = t02;
  23252. mat3.e10 = t10;
  23253. mat3.e11 = t11;
  23254. mat3.e12 = t12;
  23255. mat3.e20 = t20;
  23256. mat3.e21 = t21;
  23257. mat3.e22 = t22;
  23258. if(_this3.sizeMat3 == _this3.stackMat3.length) {
  23259. var newLength1 = _this3.sizeMat3 << 1;
  23260. var this2 = new Array(newLength1);
  23261. var newArray1 = this2;
  23262. var _g2 = 0;
  23263. var _g11 = _this3.sizeMat3;
  23264. while(_g2 < _g11) {
  23265. var i1 = _g2++;
  23266. newArray1[i1] = _this3.stackMat3[i1];
  23267. _this3.stackMat3[i1] = null;
  23268. }
  23269. _this3.stackMat3 = newArray1;
  23270. }
  23271. _this3.stackMat3[_this3.sizeMat3++] = mat3;
  23272. }
  23273. if(mat4 != null) {
  23274. var t001 = 1;
  23275. var t011 = 0;
  23276. var t021 = 0;
  23277. var t03 = 0;
  23278. var t101 = 0;
  23279. var t111 = 1;
  23280. var t121 = 0;
  23281. var t13 = 0;
  23282. var t201 = 0;
  23283. var t211 = 0;
  23284. var t221 = 1;
  23285. var t23 = 0;
  23286. var t30 = 0;
  23287. var t31 = 0;
  23288. var t32 = 0;
  23289. var t33 = 1;
  23290. mat4.e00 = t001;
  23291. mat4.e01 = t011;
  23292. mat4.e02 = t021;
  23293. mat4.e03 = t03;
  23294. mat4.e10 = t101;
  23295. mat4.e11 = t111;
  23296. mat4.e12 = t121;
  23297. mat4.e13 = t13;
  23298. mat4.e20 = t201;
  23299. mat4.e21 = t211;
  23300. mat4.e22 = t221;
  23301. mat4.e23 = t23;
  23302. mat4.e30 = t30;
  23303. mat4.e31 = t31;
  23304. mat4.e32 = t32;
  23305. mat4.e33 = t33;
  23306. if(_this3.sizeMat4 == _this3.stackMat4.length) {
  23307. var newLength2 = _this3.sizeMat4 << 1;
  23308. var this3 = new Array(newLength2);
  23309. var newArray2 = this3;
  23310. var _g3 = 0;
  23311. var _g12 = _this3.sizeMat4;
  23312. while(_g3 < _g12) {
  23313. var i2 = _g3++;
  23314. newArray2[i2] = _this3.stackMat4[i2];
  23315. _this3.stackMat4[i2] = null;
  23316. }
  23317. _this3.stackMat4 = newArray2;
  23318. }
  23319. _this3.stackMat4[_this3.sizeMat4++] = mat4;
  23320. }
  23321. if(quat != null) {
  23322. var tx1 = 0;
  23323. var ty1 = 0;
  23324. var tz1 = 0;
  23325. var tw = 1;
  23326. quat.x = tx1;
  23327. quat.y = ty1;
  23328. quat.z = tz1;
  23329. quat.w = tw;
  23330. if(_this3.sizeQuat == _this3.stackQuat.length) {
  23331. var newLength3 = _this3.sizeQuat << 1;
  23332. var this4 = new Array(newLength3);
  23333. var newArray3 = this4;
  23334. var _g4 = 0;
  23335. var _g13 = _this3.sizeQuat;
  23336. while(_g4 < _g13) {
  23337. var i3 = _g4++;
  23338. newArray3[i3] = _this3.stackQuat[i3];
  23339. _this3.stackQuat[i3] = null;
  23340. }
  23341. _this3.stackQuat = newArray3;
  23342. }
  23343. _this3.stackQuat[_this3.sizeQuat++] = quat;
  23344. }
  23345. if(min > max) {
  23346. d.ellipse(center,ex,ey,radius,radius,color);
  23347. } else {
  23348. d.arc(center,ex,ey,radius,radius,min,max,true,color);
  23349. }
  23350. }
  23351. }
  23352. _drawTranslationalLimit(d,center,ex,min,max,color) {
  23353. if(min < max) {
  23354. var _this = this._pool;
  23355. var _this1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  23356. _this1.x = center.x;
  23357. _this1.y = center.y;
  23358. _this1.z = center.z;
  23359. var _this2 = _this1;
  23360. var tx = _this2.x + ex.x * min;
  23361. var ty = _this2.y + ex.y * min;
  23362. var tz = _this2.z + ex.z * min;
  23363. _this2.x = tx;
  23364. _this2.y = ty;
  23365. _this2.z = tz;
  23366. var lower = _this2;
  23367. var _this3 = this._pool;
  23368. var _this4 = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  23369. _this4.x = center.x;
  23370. _this4.y = center.y;
  23371. _this4.z = center.z;
  23372. var _this5 = _this4;
  23373. var tx1 = _this5.x + ex.x * max;
  23374. var ty1 = _this5.y + ex.y * max;
  23375. var tz1 = _this5.z + ex.z * max;
  23376. _this5.x = tx1;
  23377. _this5.y = ty1;
  23378. _this5.z = tz1;
  23379. var upper = _this5;
  23380. d.line(lower,upper,color);
  23381. var _this6 = this._pool;
  23382. var mat3 = null;
  23383. var mat4 = null;
  23384. var quat = null;
  23385. if(lower != null) {
  23386. lower.zero();
  23387. if(_this6.sizeVec3 == _this6.stackVec3.length) {
  23388. var newLength = _this6.sizeVec3 << 1;
  23389. var this1 = new Array(newLength);
  23390. var newArray = this1;
  23391. var _g = 0;
  23392. var _g1 = _this6.sizeVec3;
  23393. while(_g < _g1) {
  23394. var i = _g++;
  23395. newArray[i] = _this6.stackVec3[i];
  23396. _this6.stackVec3[i] = null;
  23397. }
  23398. _this6.stackVec3 = newArray;
  23399. }
  23400. _this6.stackVec3[_this6.sizeVec3++] = lower;
  23401. }
  23402. if(mat3 != null) {
  23403. var t00 = 1;
  23404. var t01 = 0;
  23405. var t02 = 0;
  23406. var t10 = 0;
  23407. var t11 = 1;
  23408. var t12 = 0;
  23409. var t20 = 0;
  23410. var t21 = 0;
  23411. var t22 = 1;
  23412. mat3.e00 = t00;
  23413. mat3.e01 = t01;
  23414. mat3.e02 = t02;
  23415. mat3.e10 = t10;
  23416. mat3.e11 = t11;
  23417. mat3.e12 = t12;
  23418. mat3.e20 = t20;
  23419. mat3.e21 = t21;
  23420. mat3.e22 = t22;
  23421. if(_this6.sizeMat3 == _this6.stackMat3.length) {
  23422. var newLength1 = _this6.sizeMat3 << 1;
  23423. var this2 = new Array(newLength1);
  23424. var newArray1 = this2;
  23425. var _g2 = 0;
  23426. var _g11 = _this6.sizeMat3;
  23427. while(_g2 < _g11) {
  23428. var i1 = _g2++;
  23429. newArray1[i1] = _this6.stackMat3[i1];
  23430. _this6.stackMat3[i1] = null;
  23431. }
  23432. _this6.stackMat3 = newArray1;
  23433. }
  23434. _this6.stackMat3[_this6.sizeMat3++] = mat3;
  23435. }
  23436. if(mat4 != null) {
  23437. var t001 = 1;
  23438. var t011 = 0;
  23439. var t021 = 0;
  23440. var t03 = 0;
  23441. var t101 = 0;
  23442. var t111 = 1;
  23443. var t121 = 0;
  23444. var t13 = 0;
  23445. var t201 = 0;
  23446. var t211 = 0;
  23447. var t221 = 1;
  23448. var t23 = 0;
  23449. var t30 = 0;
  23450. var t31 = 0;
  23451. var t32 = 0;
  23452. var t33 = 1;
  23453. mat4.e00 = t001;
  23454. mat4.e01 = t011;
  23455. mat4.e02 = t021;
  23456. mat4.e03 = t03;
  23457. mat4.e10 = t101;
  23458. mat4.e11 = t111;
  23459. mat4.e12 = t121;
  23460. mat4.e13 = t13;
  23461. mat4.e20 = t201;
  23462. mat4.e21 = t211;
  23463. mat4.e22 = t221;
  23464. mat4.e23 = t23;
  23465. mat4.e30 = t30;
  23466. mat4.e31 = t31;
  23467. mat4.e32 = t32;
  23468. mat4.e33 = t33;
  23469. if(_this6.sizeMat4 == _this6.stackMat4.length) {
  23470. var newLength2 = _this6.sizeMat4 << 1;
  23471. var this3 = new Array(newLength2);
  23472. var newArray2 = this3;
  23473. var _g3 = 0;
  23474. var _g12 = _this6.sizeMat4;
  23475. while(_g3 < _g12) {
  23476. var i2 = _g3++;
  23477. newArray2[i2] = _this6.stackMat4[i2];
  23478. _this6.stackMat4[i2] = null;
  23479. }
  23480. _this6.stackMat4 = newArray2;
  23481. }
  23482. _this6.stackMat4[_this6.sizeMat4++] = mat4;
  23483. }
  23484. if(quat != null) {
  23485. var tx2 = 0;
  23486. var ty2 = 0;
  23487. var tz2 = 0;
  23488. var tw = 1;
  23489. quat.x = tx2;
  23490. quat.y = ty2;
  23491. quat.z = tz2;
  23492. quat.w = tw;
  23493. if(_this6.sizeQuat == _this6.stackQuat.length) {
  23494. var newLength3 = _this6.sizeQuat << 1;
  23495. var this4 = new Array(newLength3);
  23496. var newArray3 = this4;
  23497. var _g4 = 0;
  23498. var _g13 = _this6.sizeQuat;
  23499. while(_g4 < _g13) {
  23500. var i3 = _g4++;
  23501. newArray3[i3] = _this6.stackQuat[i3];
  23502. _this6.stackQuat[i3] = null;
  23503. }
  23504. _this6.stackQuat = newArray3;
  23505. }
  23506. _this6.stackQuat[_this6.sizeQuat++] = quat;
  23507. }
  23508. var _this7 = this._pool;
  23509. var mat31 = null;
  23510. var mat41 = null;
  23511. var quat1 = null;
  23512. if(upper != null) {
  23513. upper.zero();
  23514. if(_this7.sizeVec3 == _this7.stackVec3.length) {
  23515. var newLength4 = _this7.sizeVec3 << 1;
  23516. var this5 = new Array(newLength4);
  23517. var newArray4 = this5;
  23518. var _g5 = 0;
  23519. var _g14 = _this7.sizeVec3;
  23520. while(_g5 < _g14) {
  23521. var i4 = _g5++;
  23522. newArray4[i4] = _this7.stackVec3[i4];
  23523. _this7.stackVec3[i4] = null;
  23524. }
  23525. _this7.stackVec3 = newArray4;
  23526. }
  23527. _this7.stackVec3[_this7.sizeVec3++] = upper;
  23528. }
  23529. if(mat31 != null) {
  23530. var t002 = 1;
  23531. var t012 = 0;
  23532. var t022 = 0;
  23533. var t102 = 0;
  23534. var t112 = 1;
  23535. var t122 = 0;
  23536. var t202 = 0;
  23537. var t212 = 0;
  23538. var t222 = 1;
  23539. mat31.e00 = t002;
  23540. mat31.e01 = t012;
  23541. mat31.e02 = t022;
  23542. mat31.e10 = t102;
  23543. mat31.e11 = t112;
  23544. mat31.e12 = t122;
  23545. mat31.e20 = t202;
  23546. mat31.e21 = t212;
  23547. mat31.e22 = t222;
  23548. if(_this7.sizeMat3 == _this7.stackMat3.length) {
  23549. var newLength5 = _this7.sizeMat3 << 1;
  23550. var this6 = new Array(newLength5);
  23551. var newArray5 = this6;
  23552. var _g6 = 0;
  23553. var _g15 = _this7.sizeMat3;
  23554. while(_g6 < _g15) {
  23555. var i5 = _g6++;
  23556. newArray5[i5] = _this7.stackMat3[i5];
  23557. _this7.stackMat3[i5] = null;
  23558. }
  23559. _this7.stackMat3 = newArray5;
  23560. }
  23561. _this7.stackMat3[_this7.sizeMat3++] = mat31;
  23562. }
  23563. if(mat41 != null) {
  23564. var t003 = 1;
  23565. var t013 = 0;
  23566. var t023 = 0;
  23567. var t031 = 0;
  23568. var t103 = 0;
  23569. var t113 = 1;
  23570. var t123 = 0;
  23571. var t131 = 0;
  23572. var t203 = 0;
  23573. var t213 = 0;
  23574. var t223 = 1;
  23575. var t231 = 0;
  23576. var t301 = 0;
  23577. var t311 = 0;
  23578. var t321 = 0;
  23579. var t331 = 1;
  23580. mat41.e00 = t003;
  23581. mat41.e01 = t013;
  23582. mat41.e02 = t023;
  23583. mat41.e03 = t031;
  23584. mat41.e10 = t103;
  23585. mat41.e11 = t113;
  23586. mat41.e12 = t123;
  23587. mat41.e13 = t131;
  23588. mat41.e20 = t203;
  23589. mat41.e21 = t213;
  23590. mat41.e22 = t223;
  23591. mat41.e23 = t231;
  23592. mat41.e30 = t301;
  23593. mat41.e31 = t311;
  23594. mat41.e32 = t321;
  23595. mat41.e33 = t331;
  23596. if(_this7.sizeMat4 == _this7.stackMat4.length) {
  23597. var newLength6 = _this7.sizeMat4 << 1;
  23598. var this7 = new Array(newLength6);
  23599. var newArray6 = this7;
  23600. var _g7 = 0;
  23601. var _g16 = _this7.sizeMat4;
  23602. while(_g7 < _g16) {
  23603. var i6 = _g7++;
  23604. newArray6[i6] = _this7.stackMat4[i6];
  23605. _this7.stackMat4[i6] = null;
  23606. }
  23607. _this7.stackMat4 = newArray6;
  23608. }
  23609. _this7.stackMat4[_this7.sizeMat4++] = mat41;
  23610. }
  23611. if(quat1 != null) {
  23612. var tx3 = 0;
  23613. var ty3 = 0;
  23614. var tz3 = 0;
  23615. var tw1 = 1;
  23616. quat1.x = tx3;
  23617. quat1.y = ty3;
  23618. quat1.z = tz3;
  23619. quat1.w = tw1;
  23620. if(_this7.sizeQuat == _this7.stackQuat.length) {
  23621. var newLength7 = _this7.sizeQuat << 1;
  23622. var this8 = new Array(newLength7);
  23623. var newArray7 = this8;
  23624. var _g8 = 0;
  23625. var _g17 = _this7.sizeQuat;
  23626. while(_g8 < _g17) {
  23627. var i7 = _g8++;
  23628. newArray7[i7] = _this7.stackQuat[i7];
  23629. _this7.stackQuat[i7] = null;
  23630. }
  23631. _this7.stackQuat = newArray7;
  23632. }
  23633. _this7.stackQuat[_this7.sizeQuat++] = quat1;
  23634. }
  23635. }
  23636. }
  23637. _drawTranslationalLimit3D(d,center,ex,ey,ez,xlm,ylm,zlm,color) {
  23638. var minx = xlm.lowerLimit;
  23639. var maxx = xlm.upperLimit;
  23640. var miny = ylm.lowerLimit;
  23641. var maxy = ylm.upperLimit;
  23642. var minz = zlm.lowerLimit;
  23643. var maxz = zlm.upperLimit;
  23644. var _this = this._pool;
  23645. var lower = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  23646. var _this1 = this._pool;
  23647. var upper = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  23648. var _this2 = this._pool;
  23649. var _this3 = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  23650. _this3.x = center.x;
  23651. _this3.y = center.y;
  23652. _this3.z = center.z;
  23653. var _this4 = _this3;
  23654. var tx = _this4.x + ex.x * minx;
  23655. var ty = _this4.y + ex.y * minx;
  23656. var tz = _this4.z + ex.z * minx;
  23657. _this4.x = tx;
  23658. _this4.y = ty;
  23659. _this4.z = tz;
  23660. var _this5 = _this4;
  23661. var tx1 = _this5.x + ey.x * miny;
  23662. var ty1 = _this5.y + ey.y * miny;
  23663. var tz1 = _this5.z + ey.z * miny;
  23664. _this5.x = tx1;
  23665. _this5.y = ty1;
  23666. _this5.z = tz1;
  23667. var _this6 = _this5;
  23668. var tx2 = _this6.x + ez.x * minz;
  23669. var ty2 = _this6.y + ez.y * minz;
  23670. var tz2 = _this6.z + ez.z * minz;
  23671. _this6.x = tx2;
  23672. _this6.y = ty2;
  23673. _this6.z = tz2;
  23674. var xyz = _this6;
  23675. var _this7 = this._pool;
  23676. var _this8 = _this7.sizeVec3 == 0 ? new oimo.common.Vec3() : _this7.stackVec3[--_this7.sizeVec3];
  23677. _this8.x = center.x;
  23678. _this8.y = center.y;
  23679. _this8.z = center.z;
  23680. var _this9 = _this8;
  23681. var tx3 = _this9.x + ex.x * minx;
  23682. var ty3 = _this9.y + ex.y * minx;
  23683. var tz3 = _this9.z + ex.z * minx;
  23684. _this9.x = tx3;
  23685. _this9.y = ty3;
  23686. _this9.z = tz3;
  23687. var _this10 = _this9;
  23688. var tx4 = _this10.x + ey.x * miny;
  23689. var ty4 = _this10.y + ey.y * miny;
  23690. var tz4 = _this10.z + ey.z * miny;
  23691. _this10.x = tx4;
  23692. _this10.y = ty4;
  23693. _this10.z = tz4;
  23694. var _this11 = _this10;
  23695. var tx5 = _this11.x + ez.x * maxz;
  23696. var ty5 = _this11.y + ez.y * maxz;
  23697. var tz5 = _this11.z + ez.z * maxz;
  23698. _this11.x = tx5;
  23699. _this11.y = ty5;
  23700. _this11.z = tz5;
  23701. var xyZ = _this11;
  23702. var _this12 = this._pool;
  23703. var _this13 = _this12.sizeVec3 == 0 ? new oimo.common.Vec3() : _this12.stackVec3[--_this12.sizeVec3];
  23704. _this13.x = center.x;
  23705. _this13.y = center.y;
  23706. _this13.z = center.z;
  23707. var _this14 = _this13;
  23708. var tx6 = _this14.x + ex.x * minx;
  23709. var ty6 = _this14.y + ex.y * minx;
  23710. var tz6 = _this14.z + ex.z * minx;
  23711. _this14.x = tx6;
  23712. _this14.y = ty6;
  23713. _this14.z = tz6;
  23714. var _this15 = _this14;
  23715. var tx7 = _this15.x + ey.x * maxy;
  23716. var ty7 = _this15.y + ey.y * maxy;
  23717. var tz7 = _this15.z + ey.z * maxy;
  23718. _this15.x = tx7;
  23719. _this15.y = ty7;
  23720. _this15.z = tz7;
  23721. var _this16 = _this15;
  23722. var tx8 = _this16.x + ez.x * minz;
  23723. var ty8 = _this16.y + ez.y * minz;
  23724. var tz8 = _this16.z + ez.z * minz;
  23725. _this16.x = tx8;
  23726. _this16.y = ty8;
  23727. _this16.z = tz8;
  23728. var xYz = _this16;
  23729. var _this17 = this._pool;
  23730. var _this18 = _this17.sizeVec3 == 0 ? new oimo.common.Vec3() : _this17.stackVec3[--_this17.sizeVec3];
  23731. _this18.x = center.x;
  23732. _this18.y = center.y;
  23733. _this18.z = center.z;
  23734. var _this19 = _this18;
  23735. var tx9 = _this19.x + ex.x * minx;
  23736. var ty9 = _this19.y + ex.y * minx;
  23737. var tz9 = _this19.z + ex.z * minx;
  23738. _this19.x = tx9;
  23739. _this19.y = ty9;
  23740. _this19.z = tz9;
  23741. var _this20 = _this19;
  23742. var tx10 = _this20.x + ey.x * maxy;
  23743. var ty10 = _this20.y + ey.y * maxy;
  23744. var tz10 = _this20.z + ey.z * maxy;
  23745. _this20.x = tx10;
  23746. _this20.y = ty10;
  23747. _this20.z = tz10;
  23748. var _this21 = _this20;
  23749. var tx11 = _this21.x + ez.x * maxz;
  23750. var ty11 = _this21.y + ez.y * maxz;
  23751. var tz11 = _this21.z + ez.z * maxz;
  23752. _this21.x = tx11;
  23753. _this21.y = ty11;
  23754. _this21.z = tz11;
  23755. var xYZ = _this21;
  23756. var _this22 = this._pool;
  23757. var _this23 = _this22.sizeVec3 == 0 ? new oimo.common.Vec3() : _this22.stackVec3[--_this22.sizeVec3];
  23758. _this23.x = center.x;
  23759. _this23.y = center.y;
  23760. _this23.z = center.z;
  23761. var _this24 = _this23;
  23762. var tx12 = _this24.x + ex.x * maxx;
  23763. var ty12 = _this24.y + ex.y * maxx;
  23764. var tz12 = _this24.z + ex.z * maxx;
  23765. _this24.x = tx12;
  23766. _this24.y = ty12;
  23767. _this24.z = tz12;
  23768. var _this25 = _this24;
  23769. var tx13 = _this25.x + ey.x * miny;
  23770. var ty13 = _this25.y + ey.y * miny;
  23771. var tz13 = _this25.z + ey.z * miny;
  23772. _this25.x = tx13;
  23773. _this25.y = ty13;
  23774. _this25.z = tz13;
  23775. var _this26 = _this25;
  23776. var tx14 = _this26.x + ez.x * minz;
  23777. var ty14 = _this26.y + ez.y * minz;
  23778. var tz14 = _this26.z + ez.z * minz;
  23779. _this26.x = tx14;
  23780. _this26.y = ty14;
  23781. _this26.z = tz14;
  23782. var Xyz = _this26;
  23783. var _this27 = this._pool;
  23784. var _this28 = _this27.sizeVec3 == 0 ? new oimo.common.Vec3() : _this27.stackVec3[--_this27.sizeVec3];
  23785. _this28.x = center.x;
  23786. _this28.y = center.y;
  23787. _this28.z = center.z;
  23788. var _this29 = _this28;
  23789. var tx15 = _this29.x + ex.x * maxx;
  23790. var ty15 = _this29.y + ex.y * maxx;
  23791. var tz15 = _this29.z + ex.z * maxx;
  23792. _this29.x = tx15;
  23793. _this29.y = ty15;
  23794. _this29.z = tz15;
  23795. var _this30 = _this29;
  23796. var tx16 = _this30.x + ey.x * miny;
  23797. var ty16 = _this30.y + ey.y * miny;
  23798. var tz16 = _this30.z + ey.z * miny;
  23799. _this30.x = tx16;
  23800. _this30.y = ty16;
  23801. _this30.z = tz16;
  23802. var _this31 = _this30;
  23803. var tx17 = _this31.x + ez.x * maxz;
  23804. var ty17 = _this31.y + ez.y * maxz;
  23805. var tz17 = _this31.z + ez.z * maxz;
  23806. _this31.x = tx17;
  23807. _this31.y = ty17;
  23808. _this31.z = tz17;
  23809. var XyZ = _this31;
  23810. var _this32 = this._pool;
  23811. var _this33 = _this32.sizeVec3 == 0 ? new oimo.common.Vec3() : _this32.stackVec3[--_this32.sizeVec3];
  23812. _this33.x = center.x;
  23813. _this33.y = center.y;
  23814. _this33.z = center.z;
  23815. var _this34 = _this33;
  23816. var tx18 = _this34.x + ex.x * maxx;
  23817. var ty18 = _this34.y + ex.y * maxx;
  23818. var tz18 = _this34.z + ex.z * maxx;
  23819. _this34.x = tx18;
  23820. _this34.y = ty18;
  23821. _this34.z = tz18;
  23822. var _this35 = _this34;
  23823. var tx19 = _this35.x + ey.x * maxy;
  23824. var ty19 = _this35.y + ey.y * maxy;
  23825. var tz19 = _this35.z + ey.z * maxy;
  23826. _this35.x = tx19;
  23827. _this35.y = ty19;
  23828. _this35.z = tz19;
  23829. var _this36 = _this35;
  23830. var tx20 = _this36.x + ez.x * minz;
  23831. var ty20 = _this36.y + ez.y * minz;
  23832. var tz20 = _this36.z + ez.z * minz;
  23833. _this36.x = tx20;
  23834. _this36.y = ty20;
  23835. _this36.z = tz20;
  23836. var XYz = _this36;
  23837. var _this37 = this._pool;
  23838. var _this38 = _this37.sizeVec3 == 0 ? new oimo.common.Vec3() : _this37.stackVec3[--_this37.sizeVec3];
  23839. _this38.x = center.x;
  23840. _this38.y = center.y;
  23841. _this38.z = center.z;
  23842. var _this39 = _this38;
  23843. var tx21 = _this39.x + ex.x * maxx;
  23844. var ty21 = _this39.y + ex.y * maxx;
  23845. var tz21 = _this39.z + ex.z * maxx;
  23846. _this39.x = tx21;
  23847. _this39.y = ty21;
  23848. _this39.z = tz21;
  23849. var _this40 = _this39;
  23850. var tx22 = _this40.x + ey.x * maxy;
  23851. var ty22 = _this40.y + ey.y * maxy;
  23852. var tz22 = _this40.z + ey.z * maxy;
  23853. _this40.x = tx22;
  23854. _this40.y = ty22;
  23855. _this40.z = tz22;
  23856. var _this41 = _this40;
  23857. var tx23 = _this41.x + ez.x * maxz;
  23858. var ty23 = _this41.y + ez.y * maxz;
  23859. var tz23 = _this41.z + ez.z * maxz;
  23860. _this41.x = tx23;
  23861. _this41.y = ty23;
  23862. _this41.z = tz23;
  23863. var XYZ = _this41;
  23864. d.line(xyz,Xyz,color);
  23865. d.line(xYz,XYz,color);
  23866. d.line(xyZ,XyZ,color);
  23867. d.line(xYZ,XYZ,color);
  23868. d.line(xyz,xYz,color);
  23869. d.line(Xyz,XYz,color);
  23870. d.line(xyZ,xYZ,color);
  23871. d.line(XyZ,XYZ,color);
  23872. d.line(xyz,xyZ,color);
  23873. d.line(Xyz,XyZ,color);
  23874. d.line(xYz,xYZ,color);
  23875. d.line(XYz,XYZ,color);
  23876. var _this42 = this._pool;
  23877. var mat3 = null;
  23878. var mat4 = null;
  23879. var quat = null;
  23880. if(xyz != null) {
  23881. xyz.zero();
  23882. if(_this42.sizeVec3 == _this42.stackVec3.length) {
  23883. var newLength = _this42.sizeVec3 << 1;
  23884. var this1 = new Array(newLength);
  23885. var newArray = this1;
  23886. var _g = 0;
  23887. var _g1 = _this42.sizeVec3;
  23888. while(_g < _g1) {
  23889. var i = _g++;
  23890. newArray[i] = _this42.stackVec3[i];
  23891. _this42.stackVec3[i] = null;
  23892. }
  23893. _this42.stackVec3 = newArray;
  23894. }
  23895. _this42.stackVec3[_this42.sizeVec3++] = xyz;
  23896. }
  23897. if(mat3 != null) {
  23898. var t00 = 1;
  23899. var t01 = 0;
  23900. var t02 = 0;
  23901. var t10 = 0;
  23902. var t11 = 1;
  23903. var t12 = 0;
  23904. var t20 = 0;
  23905. var t21 = 0;
  23906. var t22 = 1;
  23907. mat3.e00 = t00;
  23908. mat3.e01 = t01;
  23909. mat3.e02 = t02;
  23910. mat3.e10 = t10;
  23911. mat3.e11 = t11;
  23912. mat3.e12 = t12;
  23913. mat3.e20 = t20;
  23914. mat3.e21 = t21;
  23915. mat3.e22 = t22;
  23916. if(_this42.sizeMat3 == _this42.stackMat3.length) {
  23917. var newLength1 = _this42.sizeMat3 << 1;
  23918. var this2 = new Array(newLength1);
  23919. var newArray1 = this2;
  23920. var _g2 = 0;
  23921. var _g11 = _this42.sizeMat3;
  23922. while(_g2 < _g11) {
  23923. var i1 = _g2++;
  23924. newArray1[i1] = _this42.stackMat3[i1];
  23925. _this42.stackMat3[i1] = null;
  23926. }
  23927. _this42.stackMat3 = newArray1;
  23928. }
  23929. _this42.stackMat3[_this42.sizeMat3++] = mat3;
  23930. }
  23931. if(mat4 != null) {
  23932. var t001 = 1;
  23933. var t011 = 0;
  23934. var t021 = 0;
  23935. var t03 = 0;
  23936. var t101 = 0;
  23937. var t111 = 1;
  23938. var t121 = 0;
  23939. var t13 = 0;
  23940. var t201 = 0;
  23941. var t211 = 0;
  23942. var t221 = 1;
  23943. var t23 = 0;
  23944. var t30 = 0;
  23945. var t31 = 0;
  23946. var t32 = 0;
  23947. var t33 = 1;
  23948. mat4.e00 = t001;
  23949. mat4.e01 = t011;
  23950. mat4.e02 = t021;
  23951. mat4.e03 = t03;
  23952. mat4.e10 = t101;
  23953. mat4.e11 = t111;
  23954. mat4.e12 = t121;
  23955. mat4.e13 = t13;
  23956. mat4.e20 = t201;
  23957. mat4.e21 = t211;
  23958. mat4.e22 = t221;
  23959. mat4.e23 = t23;
  23960. mat4.e30 = t30;
  23961. mat4.e31 = t31;
  23962. mat4.e32 = t32;
  23963. mat4.e33 = t33;
  23964. if(_this42.sizeMat4 == _this42.stackMat4.length) {
  23965. var newLength2 = _this42.sizeMat4 << 1;
  23966. var this3 = new Array(newLength2);
  23967. var newArray2 = this3;
  23968. var _g3 = 0;
  23969. var _g12 = _this42.sizeMat4;
  23970. while(_g3 < _g12) {
  23971. var i2 = _g3++;
  23972. newArray2[i2] = _this42.stackMat4[i2];
  23973. _this42.stackMat4[i2] = null;
  23974. }
  23975. _this42.stackMat4 = newArray2;
  23976. }
  23977. _this42.stackMat4[_this42.sizeMat4++] = mat4;
  23978. }
  23979. if(quat != null) {
  23980. var tx24 = 0;
  23981. var ty24 = 0;
  23982. var tz24 = 0;
  23983. var tw = 1;
  23984. quat.x = tx24;
  23985. quat.y = ty24;
  23986. quat.z = tz24;
  23987. quat.w = tw;
  23988. if(_this42.sizeQuat == _this42.stackQuat.length) {
  23989. var newLength3 = _this42.sizeQuat << 1;
  23990. var this4 = new Array(newLength3);
  23991. var newArray3 = this4;
  23992. var _g4 = 0;
  23993. var _g13 = _this42.sizeQuat;
  23994. while(_g4 < _g13) {
  23995. var i3 = _g4++;
  23996. newArray3[i3] = _this42.stackQuat[i3];
  23997. _this42.stackQuat[i3] = null;
  23998. }
  23999. _this42.stackQuat = newArray3;
  24000. }
  24001. _this42.stackQuat[_this42.sizeQuat++] = quat;
  24002. }
  24003. var _this43 = this._pool;
  24004. var mat31 = null;
  24005. var mat41 = null;
  24006. var quat1 = null;
  24007. if(xyZ != null) {
  24008. xyZ.zero();
  24009. if(_this43.sizeVec3 == _this43.stackVec3.length) {
  24010. var newLength4 = _this43.sizeVec3 << 1;
  24011. var this5 = new Array(newLength4);
  24012. var newArray4 = this5;
  24013. var _g5 = 0;
  24014. var _g14 = _this43.sizeVec3;
  24015. while(_g5 < _g14) {
  24016. var i4 = _g5++;
  24017. newArray4[i4] = _this43.stackVec3[i4];
  24018. _this43.stackVec3[i4] = null;
  24019. }
  24020. _this43.stackVec3 = newArray4;
  24021. }
  24022. _this43.stackVec3[_this43.sizeVec3++] = xyZ;
  24023. }
  24024. if(mat31 != null) {
  24025. var t002 = 1;
  24026. var t012 = 0;
  24027. var t022 = 0;
  24028. var t102 = 0;
  24029. var t112 = 1;
  24030. var t122 = 0;
  24031. var t202 = 0;
  24032. var t212 = 0;
  24033. var t222 = 1;
  24034. mat31.e00 = t002;
  24035. mat31.e01 = t012;
  24036. mat31.e02 = t022;
  24037. mat31.e10 = t102;
  24038. mat31.e11 = t112;
  24039. mat31.e12 = t122;
  24040. mat31.e20 = t202;
  24041. mat31.e21 = t212;
  24042. mat31.e22 = t222;
  24043. if(_this43.sizeMat3 == _this43.stackMat3.length) {
  24044. var newLength5 = _this43.sizeMat3 << 1;
  24045. var this6 = new Array(newLength5);
  24046. var newArray5 = this6;
  24047. var _g6 = 0;
  24048. var _g15 = _this43.sizeMat3;
  24049. while(_g6 < _g15) {
  24050. var i5 = _g6++;
  24051. newArray5[i5] = _this43.stackMat3[i5];
  24052. _this43.stackMat3[i5] = null;
  24053. }
  24054. _this43.stackMat3 = newArray5;
  24055. }
  24056. _this43.stackMat3[_this43.sizeMat3++] = mat31;
  24057. }
  24058. if(mat41 != null) {
  24059. var t003 = 1;
  24060. var t013 = 0;
  24061. var t023 = 0;
  24062. var t031 = 0;
  24063. var t103 = 0;
  24064. var t113 = 1;
  24065. var t123 = 0;
  24066. var t131 = 0;
  24067. var t203 = 0;
  24068. var t213 = 0;
  24069. var t223 = 1;
  24070. var t231 = 0;
  24071. var t301 = 0;
  24072. var t311 = 0;
  24073. var t321 = 0;
  24074. var t331 = 1;
  24075. mat41.e00 = t003;
  24076. mat41.e01 = t013;
  24077. mat41.e02 = t023;
  24078. mat41.e03 = t031;
  24079. mat41.e10 = t103;
  24080. mat41.e11 = t113;
  24081. mat41.e12 = t123;
  24082. mat41.e13 = t131;
  24083. mat41.e20 = t203;
  24084. mat41.e21 = t213;
  24085. mat41.e22 = t223;
  24086. mat41.e23 = t231;
  24087. mat41.e30 = t301;
  24088. mat41.e31 = t311;
  24089. mat41.e32 = t321;
  24090. mat41.e33 = t331;
  24091. if(_this43.sizeMat4 == _this43.stackMat4.length) {
  24092. var newLength6 = _this43.sizeMat4 << 1;
  24093. var this7 = new Array(newLength6);
  24094. var newArray6 = this7;
  24095. var _g7 = 0;
  24096. var _g16 = _this43.sizeMat4;
  24097. while(_g7 < _g16) {
  24098. var i6 = _g7++;
  24099. newArray6[i6] = _this43.stackMat4[i6];
  24100. _this43.stackMat4[i6] = null;
  24101. }
  24102. _this43.stackMat4 = newArray6;
  24103. }
  24104. _this43.stackMat4[_this43.sizeMat4++] = mat41;
  24105. }
  24106. if(quat1 != null) {
  24107. var tx25 = 0;
  24108. var ty25 = 0;
  24109. var tz25 = 0;
  24110. var tw1 = 1;
  24111. quat1.x = tx25;
  24112. quat1.y = ty25;
  24113. quat1.z = tz25;
  24114. quat1.w = tw1;
  24115. if(_this43.sizeQuat == _this43.stackQuat.length) {
  24116. var newLength7 = _this43.sizeQuat << 1;
  24117. var this8 = new Array(newLength7);
  24118. var newArray7 = this8;
  24119. var _g8 = 0;
  24120. var _g17 = _this43.sizeQuat;
  24121. while(_g8 < _g17) {
  24122. var i7 = _g8++;
  24123. newArray7[i7] = _this43.stackQuat[i7];
  24124. _this43.stackQuat[i7] = null;
  24125. }
  24126. _this43.stackQuat = newArray7;
  24127. }
  24128. _this43.stackQuat[_this43.sizeQuat++] = quat1;
  24129. }
  24130. var _this44 = this._pool;
  24131. var mat32 = null;
  24132. var mat42 = null;
  24133. var quat2 = null;
  24134. if(xYz != null) {
  24135. xYz.zero();
  24136. if(_this44.sizeVec3 == _this44.stackVec3.length) {
  24137. var newLength8 = _this44.sizeVec3 << 1;
  24138. var this9 = new Array(newLength8);
  24139. var newArray8 = this9;
  24140. var _g9 = 0;
  24141. var _g18 = _this44.sizeVec3;
  24142. while(_g9 < _g18) {
  24143. var i8 = _g9++;
  24144. newArray8[i8] = _this44.stackVec3[i8];
  24145. _this44.stackVec3[i8] = null;
  24146. }
  24147. _this44.stackVec3 = newArray8;
  24148. }
  24149. _this44.stackVec3[_this44.sizeVec3++] = xYz;
  24150. }
  24151. if(mat32 != null) {
  24152. var t004 = 1;
  24153. var t014 = 0;
  24154. var t024 = 0;
  24155. var t104 = 0;
  24156. var t114 = 1;
  24157. var t124 = 0;
  24158. var t204 = 0;
  24159. var t214 = 0;
  24160. var t224 = 1;
  24161. mat32.e00 = t004;
  24162. mat32.e01 = t014;
  24163. mat32.e02 = t024;
  24164. mat32.e10 = t104;
  24165. mat32.e11 = t114;
  24166. mat32.e12 = t124;
  24167. mat32.e20 = t204;
  24168. mat32.e21 = t214;
  24169. mat32.e22 = t224;
  24170. if(_this44.sizeMat3 == _this44.stackMat3.length) {
  24171. var newLength9 = _this44.sizeMat3 << 1;
  24172. var this10 = new Array(newLength9);
  24173. var newArray9 = this10;
  24174. var _g10 = 0;
  24175. var _g19 = _this44.sizeMat3;
  24176. while(_g10 < _g19) {
  24177. var i9 = _g10++;
  24178. newArray9[i9] = _this44.stackMat3[i9];
  24179. _this44.stackMat3[i9] = null;
  24180. }
  24181. _this44.stackMat3 = newArray9;
  24182. }
  24183. _this44.stackMat3[_this44.sizeMat3++] = mat32;
  24184. }
  24185. if(mat42 != null) {
  24186. var t005 = 1;
  24187. var t015 = 0;
  24188. var t025 = 0;
  24189. var t032 = 0;
  24190. var t105 = 0;
  24191. var t115 = 1;
  24192. var t125 = 0;
  24193. var t132 = 0;
  24194. var t205 = 0;
  24195. var t215 = 0;
  24196. var t225 = 1;
  24197. var t232 = 0;
  24198. var t302 = 0;
  24199. var t312 = 0;
  24200. var t322 = 0;
  24201. var t332 = 1;
  24202. mat42.e00 = t005;
  24203. mat42.e01 = t015;
  24204. mat42.e02 = t025;
  24205. mat42.e03 = t032;
  24206. mat42.e10 = t105;
  24207. mat42.e11 = t115;
  24208. mat42.e12 = t125;
  24209. mat42.e13 = t132;
  24210. mat42.e20 = t205;
  24211. mat42.e21 = t215;
  24212. mat42.e22 = t225;
  24213. mat42.e23 = t232;
  24214. mat42.e30 = t302;
  24215. mat42.e31 = t312;
  24216. mat42.e32 = t322;
  24217. mat42.e33 = t332;
  24218. if(_this44.sizeMat4 == _this44.stackMat4.length) {
  24219. var newLength10 = _this44.sizeMat4 << 1;
  24220. var this11 = new Array(newLength10);
  24221. var newArray10 = this11;
  24222. var _g20 = 0;
  24223. var _g110 = _this44.sizeMat4;
  24224. while(_g20 < _g110) {
  24225. var i10 = _g20++;
  24226. newArray10[i10] = _this44.stackMat4[i10];
  24227. _this44.stackMat4[i10] = null;
  24228. }
  24229. _this44.stackMat4 = newArray10;
  24230. }
  24231. _this44.stackMat4[_this44.sizeMat4++] = mat42;
  24232. }
  24233. if(quat2 != null) {
  24234. var tx26 = 0;
  24235. var ty26 = 0;
  24236. var tz26 = 0;
  24237. var tw2 = 1;
  24238. quat2.x = tx26;
  24239. quat2.y = ty26;
  24240. quat2.z = tz26;
  24241. quat2.w = tw2;
  24242. if(_this44.sizeQuat == _this44.stackQuat.length) {
  24243. var newLength11 = _this44.sizeQuat << 1;
  24244. var this12 = new Array(newLength11);
  24245. var newArray11 = this12;
  24246. var _g21 = 0;
  24247. var _g111 = _this44.sizeQuat;
  24248. while(_g21 < _g111) {
  24249. var i11 = _g21++;
  24250. newArray11[i11] = _this44.stackQuat[i11];
  24251. _this44.stackQuat[i11] = null;
  24252. }
  24253. _this44.stackQuat = newArray11;
  24254. }
  24255. _this44.stackQuat[_this44.sizeQuat++] = quat2;
  24256. }
  24257. var _this45 = this._pool;
  24258. var mat33 = null;
  24259. var mat43 = null;
  24260. var quat3 = null;
  24261. if(xYZ != null) {
  24262. xYZ.zero();
  24263. if(_this45.sizeVec3 == _this45.stackVec3.length) {
  24264. var newLength12 = _this45.sizeVec3 << 1;
  24265. var this13 = new Array(newLength12);
  24266. var newArray12 = this13;
  24267. var _g22 = 0;
  24268. var _g112 = _this45.sizeVec3;
  24269. while(_g22 < _g112) {
  24270. var i12 = _g22++;
  24271. newArray12[i12] = _this45.stackVec3[i12];
  24272. _this45.stackVec3[i12] = null;
  24273. }
  24274. _this45.stackVec3 = newArray12;
  24275. }
  24276. _this45.stackVec3[_this45.sizeVec3++] = xYZ;
  24277. }
  24278. if(mat33 != null) {
  24279. var t006 = 1;
  24280. var t016 = 0;
  24281. var t026 = 0;
  24282. var t106 = 0;
  24283. var t116 = 1;
  24284. var t126 = 0;
  24285. var t206 = 0;
  24286. var t216 = 0;
  24287. var t226 = 1;
  24288. mat33.e00 = t006;
  24289. mat33.e01 = t016;
  24290. mat33.e02 = t026;
  24291. mat33.e10 = t106;
  24292. mat33.e11 = t116;
  24293. mat33.e12 = t126;
  24294. mat33.e20 = t206;
  24295. mat33.e21 = t216;
  24296. mat33.e22 = t226;
  24297. if(_this45.sizeMat3 == _this45.stackMat3.length) {
  24298. var newLength13 = _this45.sizeMat3 << 1;
  24299. var this14 = new Array(newLength13);
  24300. var newArray13 = this14;
  24301. var _g23 = 0;
  24302. var _g113 = _this45.sizeMat3;
  24303. while(_g23 < _g113) {
  24304. var i13 = _g23++;
  24305. newArray13[i13] = _this45.stackMat3[i13];
  24306. _this45.stackMat3[i13] = null;
  24307. }
  24308. _this45.stackMat3 = newArray13;
  24309. }
  24310. _this45.stackMat3[_this45.sizeMat3++] = mat33;
  24311. }
  24312. if(mat43 != null) {
  24313. var t007 = 1;
  24314. var t017 = 0;
  24315. var t027 = 0;
  24316. var t033 = 0;
  24317. var t107 = 0;
  24318. var t117 = 1;
  24319. var t127 = 0;
  24320. var t133 = 0;
  24321. var t207 = 0;
  24322. var t217 = 0;
  24323. var t227 = 1;
  24324. var t233 = 0;
  24325. var t303 = 0;
  24326. var t313 = 0;
  24327. var t323 = 0;
  24328. var t333 = 1;
  24329. mat43.e00 = t007;
  24330. mat43.e01 = t017;
  24331. mat43.e02 = t027;
  24332. mat43.e03 = t033;
  24333. mat43.e10 = t107;
  24334. mat43.e11 = t117;
  24335. mat43.e12 = t127;
  24336. mat43.e13 = t133;
  24337. mat43.e20 = t207;
  24338. mat43.e21 = t217;
  24339. mat43.e22 = t227;
  24340. mat43.e23 = t233;
  24341. mat43.e30 = t303;
  24342. mat43.e31 = t313;
  24343. mat43.e32 = t323;
  24344. mat43.e33 = t333;
  24345. if(_this45.sizeMat4 == _this45.stackMat4.length) {
  24346. var newLength14 = _this45.sizeMat4 << 1;
  24347. var this15 = new Array(newLength14);
  24348. var newArray14 = this15;
  24349. var _g24 = 0;
  24350. var _g114 = _this45.sizeMat4;
  24351. while(_g24 < _g114) {
  24352. var i14 = _g24++;
  24353. newArray14[i14] = _this45.stackMat4[i14];
  24354. _this45.stackMat4[i14] = null;
  24355. }
  24356. _this45.stackMat4 = newArray14;
  24357. }
  24358. _this45.stackMat4[_this45.sizeMat4++] = mat43;
  24359. }
  24360. if(quat3 != null) {
  24361. var tx27 = 0;
  24362. var ty27 = 0;
  24363. var tz27 = 0;
  24364. var tw3 = 1;
  24365. quat3.x = tx27;
  24366. quat3.y = ty27;
  24367. quat3.z = tz27;
  24368. quat3.w = tw3;
  24369. if(_this45.sizeQuat == _this45.stackQuat.length) {
  24370. var newLength15 = _this45.sizeQuat << 1;
  24371. var this16 = new Array(newLength15);
  24372. var newArray15 = this16;
  24373. var _g25 = 0;
  24374. var _g115 = _this45.sizeQuat;
  24375. while(_g25 < _g115) {
  24376. var i15 = _g25++;
  24377. newArray15[i15] = _this45.stackQuat[i15];
  24378. _this45.stackQuat[i15] = null;
  24379. }
  24380. _this45.stackQuat = newArray15;
  24381. }
  24382. _this45.stackQuat[_this45.sizeQuat++] = quat3;
  24383. }
  24384. var _this46 = this._pool;
  24385. var mat34 = null;
  24386. var mat44 = null;
  24387. var quat4 = null;
  24388. if(Xyz != null) {
  24389. Xyz.zero();
  24390. if(_this46.sizeVec3 == _this46.stackVec3.length) {
  24391. var newLength16 = _this46.sizeVec3 << 1;
  24392. var this17 = new Array(newLength16);
  24393. var newArray16 = this17;
  24394. var _g26 = 0;
  24395. var _g116 = _this46.sizeVec3;
  24396. while(_g26 < _g116) {
  24397. var i16 = _g26++;
  24398. newArray16[i16] = _this46.stackVec3[i16];
  24399. _this46.stackVec3[i16] = null;
  24400. }
  24401. _this46.stackVec3 = newArray16;
  24402. }
  24403. _this46.stackVec3[_this46.sizeVec3++] = Xyz;
  24404. }
  24405. if(mat34 != null) {
  24406. var t008 = 1;
  24407. var t018 = 0;
  24408. var t028 = 0;
  24409. var t108 = 0;
  24410. var t118 = 1;
  24411. var t128 = 0;
  24412. var t208 = 0;
  24413. var t218 = 0;
  24414. var t228 = 1;
  24415. mat34.e00 = t008;
  24416. mat34.e01 = t018;
  24417. mat34.e02 = t028;
  24418. mat34.e10 = t108;
  24419. mat34.e11 = t118;
  24420. mat34.e12 = t128;
  24421. mat34.e20 = t208;
  24422. mat34.e21 = t218;
  24423. mat34.e22 = t228;
  24424. if(_this46.sizeMat3 == _this46.stackMat3.length) {
  24425. var newLength17 = _this46.sizeMat3 << 1;
  24426. var this18 = new Array(newLength17);
  24427. var newArray17 = this18;
  24428. var _g27 = 0;
  24429. var _g117 = _this46.sizeMat3;
  24430. while(_g27 < _g117) {
  24431. var i17 = _g27++;
  24432. newArray17[i17] = _this46.stackMat3[i17];
  24433. _this46.stackMat3[i17] = null;
  24434. }
  24435. _this46.stackMat3 = newArray17;
  24436. }
  24437. _this46.stackMat3[_this46.sizeMat3++] = mat34;
  24438. }
  24439. if(mat44 != null) {
  24440. var t009 = 1;
  24441. var t019 = 0;
  24442. var t029 = 0;
  24443. var t034 = 0;
  24444. var t109 = 0;
  24445. var t119 = 1;
  24446. var t129 = 0;
  24447. var t134 = 0;
  24448. var t209 = 0;
  24449. var t219 = 0;
  24450. var t229 = 1;
  24451. var t234 = 0;
  24452. var t304 = 0;
  24453. var t314 = 0;
  24454. var t324 = 0;
  24455. var t334 = 1;
  24456. mat44.e00 = t009;
  24457. mat44.e01 = t019;
  24458. mat44.e02 = t029;
  24459. mat44.e03 = t034;
  24460. mat44.e10 = t109;
  24461. mat44.e11 = t119;
  24462. mat44.e12 = t129;
  24463. mat44.e13 = t134;
  24464. mat44.e20 = t209;
  24465. mat44.e21 = t219;
  24466. mat44.e22 = t229;
  24467. mat44.e23 = t234;
  24468. mat44.e30 = t304;
  24469. mat44.e31 = t314;
  24470. mat44.e32 = t324;
  24471. mat44.e33 = t334;
  24472. if(_this46.sizeMat4 == _this46.stackMat4.length) {
  24473. var newLength18 = _this46.sizeMat4 << 1;
  24474. var this19 = new Array(newLength18);
  24475. var newArray18 = this19;
  24476. var _g28 = 0;
  24477. var _g118 = _this46.sizeMat4;
  24478. while(_g28 < _g118) {
  24479. var i18 = _g28++;
  24480. newArray18[i18] = _this46.stackMat4[i18];
  24481. _this46.stackMat4[i18] = null;
  24482. }
  24483. _this46.stackMat4 = newArray18;
  24484. }
  24485. _this46.stackMat4[_this46.sizeMat4++] = mat44;
  24486. }
  24487. if(quat4 != null) {
  24488. var tx28 = 0;
  24489. var ty28 = 0;
  24490. var tz28 = 0;
  24491. var tw4 = 1;
  24492. quat4.x = tx28;
  24493. quat4.y = ty28;
  24494. quat4.z = tz28;
  24495. quat4.w = tw4;
  24496. if(_this46.sizeQuat == _this46.stackQuat.length) {
  24497. var newLength19 = _this46.sizeQuat << 1;
  24498. var this20 = new Array(newLength19);
  24499. var newArray19 = this20;
  24500. var _g29 = 0;
  24501. var _g119 = _this46.sizeQuat;
  24502. while(_g29 < _g119) {
  24503. var i19 = _g29++;
  24504. newArray19[i19] = _this46.stackQuat[i19];
  24505. _this46.stackQuat[i19] = null;
  24506. }
  24507. _this46.stackQuat = newArray19;
  24508. }
  24509. _this46.stackQuat[_this46.sizeQuat++] = quat4;
  24510. }
  24511. var _this47 = this._pool;
  24512. var mat35 = null;
  24513. var mat45 = null;
  24514. var quat5 = null;
  24515. if(XyZ != null) {
  24516. XyZ.zero();
  24517. if(_this47.sizeVec3 == _this47.stackVec3.length) {
  24518. var newLength20 = _this47.sizeVec3 << 1;
  24519. var this21 = new Array(newLength20);
  24520. var newArray20 = this21;
  24521. var _g30 = 0;
  24522. var _g120 = _this47.sizeVec3;
  24523. while(_g30 < _g120) {
  24524. var i20 = _g30++;
  24525. newArray20[i20] = _this47.stackVec3[i20];
  24526. _this47.stackVec3[i20] = null;
  24527. }
  24528. _this47.stackVec3 = newArray20;
  24529. }
  24530. _this47.stackVec3[_this47.sizeVec3++] = XyZ;
  24531. }
  24532. if(mat35 != null) {
  24533. var t0010 = 1;
  24534. var t0110 = 0;
  24535. var t0210 = 0;
  24536. var t1010 = 0;
  24537. var t1110 = 1;
  24538. var t1210 = 0;
  24539. var t2010 = 0;
  24540. var t2110 = 0;
  24541. var t2210 = 1;
  24542. mat35.e00 = t0010;
  24543. mat35.e01 = t0110;
  24544. mat35.e02 = t0210;
  24545. mat35.e10 = t1010;
  24546. mat35.e11 = t1110;
  24547. mat35.e12 = t1210;
  24548. mat35.e20 = t2010;
  24549. mat35.e21 = t2110;
  24550. mat35.e22 = t2210;
  24551. if(_this47.sizeMat3 == _this47.stackMat3.length) {
  24552. var newLength21 = _this47.sizeMat3 << 1;
  24553. var this22 = new Array(newLength21);
  24554. var newArray21 = this22;
  24555. var _g31 = 0;
  24556. var _g121 = _this47.sizeMat3;
  24557. while(_g31 < _g121) {
  24558. var i21 = _g31++;
  24559. newArray21[i21] = _this47.stackMat3[i21];
  24560. _this47.stackMat3[i21] = null;
  24561. }
  24562. _this47.stackMat3 = newArray21;
  24563. }
  24564. _this47.stackMat3[_this47.sizeMat3++] = mat35;
  24565. }
  24566. if(mat45 != null) {
  24567. var t0011 = 1;
  24568. var t0111 = 0;
  24569. var t0211 = 0;
  24570. var t035 = 0;
  24571. var t1011 = 0;
  24572. var t1111 = 1;
  24573. var t1211 = 0;
  24574. var t135 = 0;
  24575. var t2011 = 0;
  24576. var t2111 = 0;
  24577. var t2211 = 1;
  24578. var t235 = 0;
  24579. var t305 = 0;
  24580. var t315 = 0;
  24581. var t325 = 0;
  24582. var t335 = 1;
  24583. mat45.e00 = t0011;
  24584. mat45.e01 = t0111;
  24585. mat45.e02 = t0211;
  24586. mat45.e03 = t035;
  24587. mat45.e10 = t1011;
  24588. mat45.e11 = t1111;
  24589. mat45.e12 = t1211;
  24590. mat45.e13 = t135;
  24591. mat45.e20 = t2011;
  24592. mat45.e21 = t2111;
  24593. mat45.e22 = t2211;
  24594. mat45.e23 = t235;
  24595. mat45.e30 = t305;
  24596. mat45.e31 = t315;
  24597. mat45.e32 = t325;
  24598. mat45.e33 = t335;
  24599. if(_this47.sizeMat4 == _this47.stackMat4.length) {
  24600. var newLength22 = _this47.sizeMat4 << 1;
  24601. var this23 = new Array(newLength22);
  24602. var newArray22 = this23;
  24603. var _g32 = 0;
  24604. var _g122 = _this47.sizeMat4;
  24605. while(_g32 < _g122) {
  24606. var i22 = _g32++;
  24607. newArray22[i22] = _this47.stackMat4[i22];
  24608. _this47.stackMat4[i22] = null;
  24609. }
  24610. _this47.stackMat4 = newArray22;
  24611. }
  24612. _this47.stackMat4[_this47.sizeMat4++] = mat45;
  24613. }
  24614. if(quat5 != null) {
  24615. var tx29 = 0;
  24616. var ty29 = 0;
  24617. var tz29 = 0;
  24618. var tw5 = 1;
  24619. quat5.x = tx29;
  24620. quat5.y = ty29;
  24621. quat5.z = tz29;
  24622. quat5.w = tw5;
  24623. if(_this47.sizeQuat == _this47.stackQuat.length) {
  24624. var newLength23 = _this47.sizeQuat << 1;
  24625. var this24 = new Array(newLength23);
  24626. var newArray23 = this24;
  24627. var _g33 = 0;
  24628. var _g123 = _this47.sizeQuat;
  24629. while(_g33 < _g123) {
  24630. var i23 = _g33++;
  24631. newArray23[i23] = _this47.stackQuat[i23];
  24632. _this47.stackQuat[i23] = null;
  24633. }
  24634. _this47.stackQuat = newArray23;
  24635. }
  24636. _this47.stackQuat[_this47.sizeQuat++] = quat5;
  24637. }
  24638. var _this48 = this._pool;
  24639. var mat36 = null;
  24640. var mat46 = null;
  24641. var quat6 = null;
  24642. if(XYz != null) {
  24643. XYz.zero();
  24644. if(_this48.sizeVec3 == _this48.stackVec3.length) {
  24645. var newLength24 = _this48.sizeVec3 << 1;
  24646. var this25 = new Array(newLength24);
  24647. var newArray24 = this25;
  24648. var _g34 = 0;
  24649. var _g124 = _this48.sizeVec3;
  24650. while(_g34 < _g124) {
  24651. var i24 = _g34++;
  24652. newArray24[i24] = _this48.stackVec3[i24];
  24653. _this48.stackVec3[i24] = null;
  24654. }
  24655. _this48.stackVec3 = newArray24;
  24656. }
  24657. _this48.stackVec3[_this48.sizeVec3++] = XYz;
  24658. }
  24659. if(mat36 != null) {
  24660. var t0012 = 1;
  24661. var t0112 = 0;
  24662. var t0212 = 0;
  24663. var t1012 = 0;
  24664. var t1112 = 1;
  24665. var t1212 = 0;
  24666. var t2012 = 0;
  24667. var t2112 = 0;
  24668. var t2212 = 1;
  24669. mat36.e00 = t0012;
  24670. mat36.e01 = t0112;
  24671. mat36.e02 = t0212;
  24672. mat36.e10 = t1012;
  24673. mat36.e11 = t1112;
  24674. mat36.e12 = t1212;
  24675. mat36.e20 = t2012;
  24676. mat36.e21 = t2112;
  24677. mat36.e22 = t2212;
  24678. if(_this48.sizeMat3 == _this48.stackMat3.length) {
  24679. var newLength25 = _this48.sizeMat3 << 1;
  24680. var this26 = new Array(newLength25);
  24681. var newArray25 = this26;
  24682. var _g35 = 0;
  24683. var _g125 = _this48.sizeMat3;
  24684. while(_g35 < _g125) {
  24685. var i25 = _g35++;
  24686. newArray25[i25] = _this48.stackMat3[i25];
  24687. _this48.stackMat3[i25] = null;
  24688. }
  24689. _this48.stackMat3 = newArray25;
  24690. }
  24691. _this48.stackMat3[_this48.sizeMat3++] = mat36;
  24692. }
  24693. if(mat46 != null) {
  24694. var t0013 = 1;
  24695. var t0113 = 0;
  24696. var t0213 = 0;
  24697. var t036 = 0;
  24698. var t1013 = 0;
  24699. var t1113 = 1;
  24700. var t1213 = 0;
  24701. var t136 = 0;
  24702. var t2013 = 0;
  24703. var t2113 = 0;
  24704. var t2213 = 1;
  24705. var t236 = 0;
  24706. var t306 = 0;
  24707. var t316 = 0;
  24708. var t326 = 0;
  24709. var t336 = 1;
  24710. mat46.e00 = t0013;
  24711. mat46.e01 = t0113;
  24712. mat46.e02 = t0213;
  24713. mat46.e03 = t036;
  24714. mat46.e10 = t1013;
  24715. mat46.e11 = t1113;
  24716. mat46.e12 = t1213;
  24717. mat46.e13 = t136;
  24718. mat46.e20 = t2013;
  24719. mat46.e21 = t2113;
  24720. mat46.e22 = t2213;
  24721. mat46.e23 = t236;
  24722. mat46.e30 = t306;
  24723. mat46.e31 = t316;
  24724. mat46.e32 = t326;
  24725. mat46.e33 = t336;
  24726. if(_this48.sizeMat4 == _this48.stackMat4.length) {
  24727. var newLength26 = _this48.sizeMat4 << 1;
  24728. var this27 = new Array(newLength26);
  24729. var newArray26 = this27;
  24730. var _g36 = 0;
  24731. var _g126 = _this48.sizeMat4;
  24732. while(_g36 < _g126) {
  24733. var i26 = _g36++;
  24734. newArray26[i26] = _this48.stackMat4[i26];
  24735. _this48.stackMat4[i26] = null;
  24736. }
  24737. _this48.stackMat4 = newArray26;
  24738. }
  24739. _this48.stackMat4[_this48.sizeMat4++] = mat46;
  24740. }
  24741. if(quat6 != null) {
  24742. var tx30 = 0;
  24743. var ty30 = 0;
  24744. var tz30 = 0;
  24745. var tw6 = 1;
  24746. quat6.x = tx30;
  24747. quat6.y = ty30;
  24748. quat6.z = tz30;
  24749. quat6.w = tw6;
  24750. if(_this48.sizeQuat == _this48.stackQuat.length) {
  24751. var newLength27 = _this48.sizeQuat << 1;
  24752. var this28 = new Array(newLength27);
  24753. var newArray27 = this28;
  24754. var _g37 = 0;
  24755. var _g127 = _this48.sizeQuat;
  24756. while(_g37 < _g127) {
  24757. var i27 = _g37++;
  24758. newArray27[i27] = _this48.stackQuat[i27];
  24759. _this48.stackQuat[i27] = null;
  24760. }
  24761. _this48.stackQuat = newArray27;
  24762. }
  24763. _this48.stackQuat[_this48.sizeQuat++] = quat6;
  24764. }
  24765. var _this49 = this._pool;
  24766. var mat37 = null;
  24767. var mat47 = null;
  24768. var quat7 = null;
  24769. if(XYZ != null) {
  24770. XYZ.zero();
  24771. if(_this49.sizeVec3 == _this49.stackVec3.length) {
  24772. var newLength28 = _this49.sizeVec3 << 1;
  24773. var this29 = new Array(newLength28);
  24774. var newArray28 = this29;
  24775. var _g38 = 0;
  24776. var _g128 = _this49.sizeVec3;
  24777. while(_g38 < _g128) {
  24778. var i28 = _g38++;
  24779. newArray28[i28] = _this49.stackVec3[i28];
  24780. _this49.stackVec3[i28] = null;
  24781. }
  24782. _this49.stackVec3 = newArray28;
  24783. }
  24784. _this49.stackVec3[_this49.sizeVec3++] = XYZ;
  24785. }
  24786. if(mat37 != null) {
  24787. var t0014 = 1;
  24788. var t0114 = 0;
  24789. var t0214 = 0;
  24790. var t1014 = 0;
  24791. var t1114 = 1;
  24792. var t1214 = 0;
  24793. var t2014 = 0;
  24794. var t2114 = 0;
  24795. var t2214 = 1;
  24796. mat37.e00 = t0014;
  24797. mat37.e01 = t0114;
  24798. mat37.e02 = t0214;
  24799. mat37.e10 = t1014;
  24800. mat37.e11 = t1114;
  24801. mat37.e12 = t1214;
  24802. mat37.e20 = t2014;
  24803. mat37.e21 = t2114;
  24804. mat37.e22 = t2214;
  24805. if(_this49.sizeMat3 == _this49.stackMat3.length) {
  24806. var newLength29 = _this49.sizeMat3 << 1;
  24807. var this30 = new Array(newLength29);
  24808. var newArray29 = this30;
  24809. var _g39 = 0;
  24810. var _g129 = _this49.sizeMat3;
  24811. while(_g39 < _g129) {
  24812. var i29 = _g39++;
  24813. newArray29[i29] = _this49.stackMat3[i29];
  24814. _this49.stackMat3[i29] = null;
  24815. }
  24816. _this49.stackMat3 = newArray29;
  24817. }
  24818. _this49.stackMat3[_this49.sizeMat3++] = mat37;
  24819. }
  24820. if(mat47 != null) {
  24821. var t0015 = 1;
  24822. var t0115 = 0;
  24823. var t0215 = 0;
  24824. var t037 = 0;
  24825. var t1015 = 0;
  24826. var t1115 = 1;
  24827. var t1215 = 0;
  24828. var t137 = 0;
  24829. var t2015 = 0;
  24830. var t2115 = 0;
  24831. var t2215 = 1;
  24832. var t237 = 0;
  24833. var t307 = 0;
  24834. var t317 = 0;
  24835. var t327 = 0;
  24836. var t337 = 1;
  24837. mat47.e00 = t0015;
  24838. mat47.e01 = t0115;
  24839. mat47.e02 = t0215;
  24840. mat47.e03 = t037;
  24841. mat47.e10 = t1015;
  24842. mat47.e11 = t1115;
  24843. mat47.e12 = t1215;
  24844. mat47.e13 = t137;
  24845. mat47.e20 = t2015;
  24846. mat47.e21 = t2115;
  24847. mat47.e22 = t2215;
  24848. mat47.e23 = t237;
  24849. mat47.e30 = t307;
  24850. mat47.e31 = t317;
  24851. mat47.e32 = t327;
  24852. mat47.e33 = t337;
  24853. if(_this49.sizeMat4 == _this49.stackMat4.length) {
  24854. var newLength30 = _this49.sizeMat4 << 1;
  24855. var this31 = new Array(newLength30);
  24856. var newArray30 = this31;
  24857. var _g40 = 0;
  24858. var _g130 = _this49.sizeMat4;
  24859. while(_g40 < _g130) {
  24860. var i30 = _g40++;
  24861. newArray30[i30] = _this49.stackMat4[i30];
  24862. _this49.stackMat4[i30] = null;
  24863. }
  24864. _this49.stackMat4 = newArray30;
  24865. }
  24866. _this49.stackMat4[_this49.sizeMat4++] = mat47;
  24867. }
  24868. if(quat7 != null) {
  24869. var tx31 = 0;
  24870. var ty31 = 0;
  24871. var tz31 = 0;
  24872. var tw7 = 1;
  24873. quat7.x = tx31;
  24874. quat7.y = ty31;
  24875. quat7.z = tz31;
  24876. quat7.w = tw7;
  24877. if(_this49.sizeQuat == _this49.stackQuat.length) {
  24878. var newLength31 = _this49.sizeQuat << 1;
  24879. var this32 = new Array(newLength31);
  24880. var newArray31 = this32;
  24881. var _g41 = 0;
  24882. var _g131 = _this49.sizeQuat;
  24883. while(_g41 < _g131) {
  24884. var i31 = _g41++;
  24885. newArray31[i31] = _this49.stackQuat[i31];
  24886. _this49.stackQuat[i31] = null;
  24887. }
  24888. _this49.stackQuat = newArray31;
  24889. }
  24890. _this49.stackQuat[_this49.sizeQuat++] = quat7;
  24891. }
  24892. }
  24893. _drawEllipseOnSphere(d,center,normal,x,y,radiansX,radiansY,radius,color) {
  24894. var n = 16;
  24895. var theta = 0;
  24896. var dTheta = 6.28318530717958 / n;
  24897. var _this = this._pool;
  24898. var rotVec = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  24899. var _this1 = this._pool;
  24900. var rotQ = _this1.sizeQuat == 0 ? new oimo.common.Quat() : _this1.stackQuat[--_this1.sizeQuat];
  24901. var _this2 = this._pool;
  24902. var rotM = _this2.sizeMat3 == 0 ? new oimo.common.Mat3() : _this2.stackMat3[--_this2.sizeMat3];
  24903. var _this3 = this._pool;
  24904. var prevV = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  24905. var _g = 0;
  24906. var _g1 = n + 1;
  24907. while(_g < _g1) {
  24908. var i = _g++;
  24909. var rx = Math.cos(theta) * radiansX;
  24910. var ry = Math.sin(theta) * radiansY;
  24911. var halfRotAng = Math.sqrt(rx * rx + ry * ry);
  24912. var rotSin = Math.sin(halfRotAng * 0.5);
  24913. var rotCos = Math.cos(halfRotAng * 0.5);
  24914. var _this4 = rotVec.zero();
  24915. var tx = _this4.x + x.x * rx;
  24916. var ty = _this4.y + x.y * rx;
  24917. var tz = _this4.z + x.z * rx;
  24918. _this4.x = tx;
  24919. _this4.y = ty;
  24920. _this4.z = tz;
  24921. var _this5 = _this4;
  24922. var tx1 = _this5.x + y.x * ry;
  24923. var ty1 = _this5.y + y.y * ry;
  24924. var tz1 = _this5.z + y.z * ry;
  24925. _this5.x = tx1;
  24926. _this5.y = ty1;
  24927. _this5.z = tz1;
  24928. var s = 1 / halfRotAng * rotSin;
  24929. var tx2 = rotVec.x * s;
  24930. var ty2 = rotVec.y * s;
  24931. var tz2 = rotVec.z * s;
  24932. rotVec.x = tx2;
  24933. rotVec.y = ty2;
  24934. rotVec.z = tz2;
  24935. rotQ.x = rotVec.x;
  24936. rotQ.y = rotVec.y;
  24937. rotQ.z = rotVec.z;
  24938. rotQ.w = rotCos;
  24939. var x1 = rotQ.x;
  24940. var y1 = rotQ.y;
  24941. var z = rotQ.z;
  24942. var w = rotQ.w;
  24943. var x2 = 2 * x1;
  24944. var y2 = 2 * y1;
  24945. var z2 = 2 * z;
  24946. var xx = x1 * x2;
  24947. var yy = y1 * y2;
  24948. var zz = z * z2;
  24949. var xy = x1 * y2;
  24950. var yz = y1 * z2;
  24951. var xz = x1 * z2;
  24952. var wx = w * x2;
  24953. var wy = w * y2;
  24954. var wz = w * z2;
  24955. rotM.e00 = 1 - yy - zz;
  24956. rotM.e01 = xy - wz;
  24957. rotM.e02 = xz + wy;
  24958. rotM.e10 = xy + wz;
  24959. rotM.e11 = 1 - xx - zz;
  24960. rotM.e12 = yz - wx;
  24961. rotM.e20 = xz - wy;
  24962. rotM.e21 = yz + wx;
  24963. rotM.e22 = 1 - xx - yy;
  24964. var _this6 = this._pool;
  24965. var _this7 = _this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3];
  24966. var tx3 = _this7.x + normal.x * radius;
  24967. var ty3 = _this7.y + normal.y * radius;
  24968. var tz3 = _this7.z + normal.z * radius;
  24969. _this7.x = tx3;
  24970. _this7.y = ty3;
  24971. _this7.z = tz3;
  24972. var v = _this7;
  24973. var tx4 = v.x * rotM.e00 + v.y * rotM.e01 + v.z * rotM.e02;
  24974. var ty4 = v.x * rotM.e10 + v.y * rotM.e11 + v.z * rotM.e12;
  24975. var tz4 = v.x * rotM.e20 + v.y * rotM.e21 + v.z * rotM.e22;
  24976. v.x = tx4;
  24977. v.y = ty4;
  24978. v.z = tz4;
  24979. var _this8 = v;
  24980. var tx5 = _this8.x + center.x;
  24981. var ty5 = _this8.y + center.y;
  24982. var tz5 = _this8.z + center.z;
  24983. _this8.x = tx5;
  24984. _this8.y = ty5;
  24985. _this8.z = tz5;
  24986. if(i >= 1) {
  24987. d.line(prevV,v,color);
  24988. }
  24989. var _this9 = this._pool;
  24990. var mat3 = null;
  24991. var mat4 = null;
  24992. var quat = null;
  24993. if(prevV != null) {
  24994. prevV.zero();
  24995. if(_this9.sizeVec3 == _this9.stackVec3.length) {
  24996. var newLength = _this9.sizeVec3 << 1;
  24997. var this1 = new Array(newLength);
  24998. var newArray = this1;
  24999. var _g2 = 0;
  25000. var _g11 = _this9.sizeVec3;
  25001. while(_g2 < _g11) {
  25002. var i1 = _g2++;
  25003. newArray[i1] = _this9.stackVec3[i1];
  25004. _this9.stackVec3[i1] = null;
  25005. }
  25006. _this9.stackVec3 = newArray;
  25007. }
  25008. _this9.stackVec3[_this9.sizeVec3++] = prevV;
  25009. }
  25010. if(mat3 != null) {
  25011. var t00 = 1;
  25012. var t01 = 0;
  25013. var t02 = 0;
  25014. var t10 = 0;
  25015. var t11 = 1;
  25016. var t12 = 0;
  25017. var t20 = 0;
  25018. var t21 = 0;
  25019. var t22 = 1;
  25020. mat3.e00 = t00;
  25021. mat3.e01 = t01;
  25022. mat3.e02 = t02;
  25023. mat3.e10 = t10;
  25024. mat3.e11 = t11;
  25025. mat3.e12 = t12;
  25026. mat3.e20 = t20;
  25027. mat3.e21 = t21;
  25028. mat3.e22 = t22;
  25029. if(_this9.sizeMat3 == _this9.stackMat3.length) {
  25030. var newLength1 = _this9.sizeMat3 << 1;
  25031. var this2 = new Array(newLength1);
  25032. var newArray1 = this2;
  25033. var _g3 = 0;
  25034. var _g12 = _this9.sizeMat3;
  25035. while(_g3 < _g12) {
  25036. var i2 = _g3++;
  25037. newArray1[i2] = _this9.stackMat3[i2];
  25038. _this9.stackMat3[i2] = null;
  25039. }
  25040. _this9.stackMat3 = newArray1;
  25041. }
  25042. _this9.stackMat3[_this9.sizeMat3++] = mat3;
  25043. }
  25044. if(mat4 != null) {
  25045. var t001 = 1;
  25046. var t011 = 0;
  25047. var t021 = 0;
  25048. var t03 = 0;
  25049. var t101 = 0;
  25050. var t111 = 1;
  25051. var t121 = 0;
  25052. var t13 = 0;
  25053. var t201 = 0;
  25054. var t211 = 0;
  25055. var t221 = 1;
  25056. var t23 = 0;
  25057. var t30 = 0;
  25058. var t31 = 0;
  25059. var t32 = 0;
  25060. var t33 = 1;
  25061. mat4.e00 = t001;
  25062. mat4.e01 = t011;
  25063. mat4.e02 = t021;
  25064. mat4.e03 = t03;
  25065. mat4.e10 = t101;
  25066. mat4.e11 = t111;
  25067. mat4.e12 = t121;
  25068. mat4.e13 = t13;
  25069. mat4.e20 = t201;
  25070. mat4.e21 = t211;
  25071. mat4.e22 = t221;
  25072. mat4.e23 = t23;
  25073. mat4.e30 = t30;
  25074. mat4.e31 = t31;
  25075. mat4.e32 = t32;
  25076. mat4.e33 = t33;
  25077. if(_this9.sizeMat4 == _this9.stackMat4.length) {
  25078. var newLength2 = _this9.sizeMat4 << 1;
  25079. var this3 = new Array(newLength2);
  25080. var newArray2 = this3;
  25081. var _g4 = 0;
  25082. var _g13 = _this9.sizeMat4;
  25083. while(_g4 < _g13) {
  25084. var i3 = _g4++;
  25085. newArray2[i3] = _this9.stackMat4[i3];
  25086. _this9.stackMat4[i3] = null;
  25087. }
  25088. _this9.stackMat4 = newArray2;
  25089. }
  25090. _this9.stackMat4[_this9.sizeMat4++] = mat4;
  25091. }
  25092. if(quat != null) {
  25093. var tx6 = 0;
  25094. var ty6 = 0;
  25095. var tz6 = 0;
  25096. var tw = 1;
  25097. quat.x = tx6;
  25098. quat.y = ty6;
  25099. quat.z = tz6;
  25100. quat.w = tw;
  25101. if(_this9.sizeQuat == _this9.stackQuat.length) {
  25102. var newLength3 = _this9.sizeQuat << 1;
  25103. var this4 = new Array(newLength3);
  25104. var newArray3 = this4;
  25105. var _g5 = 0;
  25106. var _g14 = _this9.sizeQuat;
  25107. while(_g5 < _g14) {
  25108. var i4 = _g5++;
  25109. newArray3[i4] = _this9.stackQuat[i4];
  25110. _this9.stackQuat[i4] = null;
  25111. }
  25112. _this9.stackQuat = newArray3;
  25113. }
  25114. _this9.stackQuat[_this9.sizeQuat++] = quat;
  25115. }
  25116. prevV = v;
  25117. theta += dTheta;
  25118. }
  25119. var _this10 = this._pool;
  25120. var mat31 = null;
  25121. var mat41 = null;
  25122. var quat1 = null;
  25123. if(rotVec != null) {
  25124. rotVec.zero();
  25125. if(_this10.sizeVec3 == _this10.stackVec3.length) {
  25126. var newLength4 = _this10.sizeVec3 << 1;
  25127. var this5 = new Array(newLength4);
  25128. var newArray4 = this5;
  25129. var _g6 = 0;
  25130. var _g15 = _this10.sizeVec3;
  25131. while(_g6 < _g15) {
  25132. var i5 = _g6++;
  25133. newArray4[i5] = _this10.stackVec3[i5];
  25134. _this10.stackVec3[i5] = null;
  25135. }
  25136. _this10.stackVec3 = newArray4;
  25137. }
  25138. _this10.stackVec3[_this10.sizeVec3++] = rotVec;
  25139. }
  25140. if(mat31 != null) {
  25141. var t002 = 1;
  25142. var t012 = 0;
  25143. var t022 = 0;
  25144. var t102 = 0;
  25145. var t112 = 1;
  25146. var t122 = 0;
  25147. var t202 = 0;
  25148. var t212 = 0;
  25149. var t222 = 1;
  25150. mat31.e00 = t002;
  25151. mat31.e01 = t012;
  25152. mat31.e02 = t022;
  25153. mat31.e10 = t102;
  25154. mat31.e11 = t112;
  25155. mat31.e12 = t122;
  25156. mat31.e20 = t202;
  25157. mat31.e21 = t212;
  25158. mat31.e22 = t222;
  25159. if(_this10.sizeMat3 == _this10.stackMat3.length) {
  25160. var newLength5 = _this10.sizeMat3 << 1;
  25161. var this6 = new Array(newLength5);
  25162. var newArray5 = this6;
  25163. var _g7 = 0;
  25164. var _g16 = _this10.sizeMat3;
  25165. while(_g7 < _g16) {
  25166. var i6 = _g7++;
  25167. newArray5[i6] = _this10.stackMat3[i6];
  25168. _this10.stackMat3[i6] = null;
  25169. }
  25170. _this10.stackMat3 = newArray5;
  25171. }
  25172. _this10.stackMat3[_this10.sizeMat3++] = mat31;
  25173. }
  25174. if(mat41 != null) {
  25175. var t003 = 1;
  25176. var t013 = 0;
  25177. var t023 = 0;
  25178. var t031 = 0;
  25179. var t103 = 0;
  25180. var t113 = 1;
  25181. var t123 = 0;
  25182. var t131 = 0;
  25183. var t203 = 0;
  25184. var t213 = 0;
  25185. var t223 = 1;
  25186. var t231 = 0;
  25187. var t301 = 0;
  25188. var t311 = 0;
  25189. var t321 = 0;
  25190. var t331 = 1;
  25191. mat41.e00 = t003;
  25192. mat41.e01 = t013;
  25193. mat41.e02 = t023;
  25194. mat41.e03 = t031;
  25195. mat41.e10 = t103;
  25196. mat41.e11 = t113;
  25197. mat41.e12 = t123;
  25198. mat41.e13 = t131;
  25199. mat41.e20 = t203;
  25200. mat41.e21 = t213;
  25201. mat41.e22 = t223;
  25202. mat41.e23 = t231;
  25203. mat41.e30 = t301;
  25204. mat41.e31 = t311;
  25205. mat41.e32 = t321;
  25206. mat41.e33 = t331;
  25207. if(_this10.sizeMat4 == _this10.stackMat4.length) {
  25208. var newLength6 = _this10.sizeMat4 << 1;
  25209. var this7 = new Array(newLength6);
  25210. var newArray6 = this7;
  25211. var _g8 = 0;
  25212. var _g17 = _this10.sizeMat4;
  25213. while(_g8 < _g17) {
  25214. var i7 = _g8++;
  25215. newArray6[i7] = _this10.stackMat4[i7];
  25216. _this10.stackMat4[i7] = null;
  25217. }
  25218. _this10.stackMat4 = newArray6;
  25219. }
  25220. _this10.stackMat4[_this10.sizeMat4++] = mat41;
  25221. }
  25222. if(quat1 != null) {
  25223. var tx7 = 0;
  25224. var ty7 = 0;
  25225. var tz7 = 0;
  25226. var tw1 = 1;
  25227. quat1.x = tx7;
  25228. quat1.y = ty7;
  25229. quat1.z = tz7;
  25230. quat1.w = tw1;
  25231. if(_this10.sizeQuat == _this10.stackQuat.length) {
  25232. var newLength7 = _this10.sizeQuat << 1;
  25233. var this8 = new Array(newLength7);
  25234. var newArray7 = this8;
  25235. var _g9 = 0;
  25236. var _g18 = _this10.sizeQuat;
  25237. while(_g9 < _g18) {
  25238. var i8 = _g9++;
  25239. newArray7[i8] = _this10.stackQuat[i8];
  25240. _this10.stackQuat[i8] = null;
  25241. }
  25242. _this10.stackQuat = newArray7;
  25243. }
  25244. _this10.stackQuat[_this10.sizeQuat++] = quat1;
  25245. }
  25246. var _this11 = this._pool;
  25247. var vec3 = null;
  25248. var mat32 = null;
  25249. var mat42 = null;
  25250. if(vec3 != null) {
  25251. vec3.zero();
  25252. if(_this11.sizeVec3 == _this11.stackVec3.length) {
  25253. var newLength8 = _this11.sizeVec3 << 1;
  25254. var this9 = new Array(newLength8);
  25255. var newArray8 = this9;
  25256. var _g10 = 0;
  25257. var _g19 = _this11.sizeVec3;
  25258. while(_g10 < _g19) {
  25259. var i9 = _g10++;
  25260. newArray8[i9] = _this11.stackVec3[i9];
  25261. _this11.stackVec3[i9] = null;
  25262. }
  25263. _this11.stackVec3 = newArray8;
  25264. }
  25265. _this11.stackVec3[_this11.sizeVec3++] = vec3;
  25266. }
  25267. if(mat32 != null) {
  25268. var t004 = 1;
  25269. var t014 = 0;
  25270. var t024 = 0;
  25271. var t104 = 0;
  25272. var t114 = 1;
  25273. var t124 = 0;
  25274. var t204 = 0;
  25275. var t214 = 0;
  25276. var t224 = 1;
  25277. mat32.e00 = t004;
  25278. mat32.e01 = t014;
  25279. mat32.e02 = t024;
  25280. mat32.e10 = t104;
  25281. mat32.e11 = t114;
  25282. mat32.e12 = t124;
  25283. mat32.e20 = t204;
  25284. mat32.e21 = t214;
  25285. mat32.e22 = t224;
  25286. if(_this11.sizeMat3 == _this11.stackMat3.length) {
  25287. var newLength9 = _this11.sizeMat3 << 1;
  25288. var this10 = new Array(newLength9);
  25289. var newArray9 = this10;
  25290. var _g20 = 0;
  25291. var _g110 = _this11.sizeMat3;
  25292. while(_g20 < _g110) {
  25293. var i10 = _g20++;
  25294. newArray9[i10] = _this11.stackMat3[i10];
  25295. _this11.stackMat3[i10] = null;
  25296. }
  25297. _this11.stackMat3 = newArray9;
  25298. }
  25299. _this11.stackMat3[_this11.sizeMat3++] = mat32;
  25300. }
  25301. if(mat42 != null) {
  25302. var t005 = 1;
  25303. var t015 = 0;
  25304. var t025 = 0;
  25305. var t032 = 0;
  25306. var t105 = 0;
  25307. var t115 = 1;
  25308. var t125 = 0;
  25309. var t132 = 0;
  25310. var t205 = 0;
  25311. var t215 = 0;
  25312. var t225 = 1;
  25313. var t232 = 0;
  25314. var t302 = 0;
  25315. var t312 = 0;
  25316. var t322 = 0;
  25317. var t332 = 1;
  25318. mat42.e00 = t005;
  25319. mat42.e01 = t015;
  25320. mat42.e02 = t025;
  25321. mat42.e03 = t032;
  25322. mat42.e10 = t105;
  25323. mat42.e11 = t115;
  25324. mat42.e12 = t125;
  25325. mat42.e13 = t132;
  25326. mat42.e20 = t205;
  25327. mat42.e21 = t215;
  25328. mat42.e22 = t225;
  25329. mat42.e23 = t232;
  25330. mat42.e30 = t302;
  25331. mat42.e31 = t312;
  25332. mat42.e32 = t322;
  25333. mat42.e33 = t332;
  25334. if(_this11.sizeMat4 == _this11.stackMat4.length) {
  25335. var newLength10 = _this11.sizeMat4 << 1;
  25336. var this11 = new Array(newLength10);
  25337. var newArray10 = this11;
  25338. var _g21 = 0;
  25339. var _g111 = _this11.sizeMat4;
  25340. while(_g21 < _g111) {
  25341. var i11 = _g21++;
  25342. newArray10[i11] = _this11.stackMat4[i11];
  25343. _this11.stackMat4[i11] = null;
  25344. }
  25345. _this11.stackMat4 = newArray10;
  25346. }
  25347. _this11.stackMat4[_this11.sizeMat4++] = mat42;
  25348. }
  25349. if(rotQ != null) {
  25350. var tx8 = 0;
  25351. var ty8 = 0;
  25352. var tz8 = 0;
  25353. var tw2 = 1;
  25354. rotQ.x = tx8;
  25355. rotQ.y = ty8;
  25356. rotQ.z = tz8;
  25357. rotQ.w = tw2;
  25358. if(_this11.sizeQuat == _this11.stackQuat.length) {
  25359. var newLength11 = _this11.sizeQuat << 1;
  25360. var this12 = new Array(newLength11);
  25361. var newArray11 = this12;
  25362. var _g22 = 0;
  25363. var _g112 = _this11.sizeQuat;
  25364. while(_g22 < _g112) {
  25365. var i12 = _g22++;
  25366. newArray11[i12] = _this11.stackQuat[i12];
  25367. _this11.stackQuat[i12] = null;
  25368. }
  25369. _this11.stackQuat = newArray11;
  25370. }
  25371. _this11.stackQuat[_this11.sizeQuat++] = rotQ;
  25372. }
  25373. var _this12 = this._pool;
  25374. var vec31 = null;
  25375. var mat43 = null;
  25376. var quat2 = null;
  25377. if(vec31 != null) {
  25378. vec31.zero();
  25379. if(_this12.sizeVec3 == _this12.stackVec3.length) {
  25380. var newLength12 = _this12.sizeVec3 << 1;
  25381. var this13 = new Array(newLength12);
  25382. var newArray12 = this13;
  25383. var _g23 = 0;
  25384. var _g113 = _this12.sizeVec3;
  25385. while(_g23 < _g113) {
  25386. var i13 = _g23++;
  25387. newArray12[i13] = _this12.stackVec3[i13];
  25388. _this12.stackVec3[i13] = null;
  25389. }
  25390. _this12.stackVec3 = newArray12;
  25391. }
  25392. _this12.stackVec3[_this12.sizeVec3++] = vec31;
  25393. }
  25394. if(rotM != null) {
  25395. var t006 = 1;
  25396. var t016 = 0;
  25397. var t026 = 0;
  25398. var t106 = 0;
  25399. var t116 = 1;
  25400. var t126 = 0;
  25401. var t206 = 0;
  25402. var t216 = 0;
  25403. var t226 = 1;
  25404. rotM.e00 = t006;
  25405. rotM.e01 = t016;
  25406. rotM.e02 = t026;
  25407. rotM.e10 = t106;
  25408. rotM.e11 = t116;
  25409. rotM.e12 = t126;
  25410. rotM.e20 = t206;
  25411. rotM.e21 = t216;
  25412. rotM.e22 = t226;
  25413. if(_this12.sizeMat3 == _this12.stackMat3.length) {
  25414. var newLength13 = _this12.sizeMat3 << 1;
  25415. var this14 = new Array(newLength13);
  25416. var newArray13 = this14;
  25417. var _g24 = 0;
  25418. var _g114 = _this12.sizeMat3;
  25419. while(_g24 < _g114) {
  25420. var i14 = _g24++;
  25421. newArray13[i14] = _this12.stackMat3[i14];
  25422. _this12.stackMat3[i14] = null;
  25423. }
  25424. _this12.stackMat3 = newArray13;
  25425. }
  25426. _this12.stackMat3[_this12.sizeMat3++] = rotM;
  25427. }
  25428. if(mat43 != null) {
  25429. var t007 = 1;
  25430. var t017 = 0;
  25431. var t027 = 0;
  25432. var t033 = 0;
  25433. var t107 = 0;
  25434. var t117 = 1;
  25435. var t127 = 0;
  25436. var t133 = 0;
  25437. var t207 = 0;
  25438. var t217 = 0;
  25439. var t227 = 1;
  25440. var t233 = 0;
  25441. var t303 = 0;
  25442. var t313 = 0;
  25443. var t323 = 0;
  25444. var t333 = 1;
  25445. mat43.e00 = t007;
  25446. mat43.e01 = t017;
  25447. mat43.e02 = t027;
  25448. mat43.e03 = t033;
  25449. mat43.e10 = t107;
  25450. mat43.e11 = t117;
  25451. mat43.e12 = t127;
  25452. mat43.e13 = t133;
  25453. mat43.e20 = t207;
  25454. mat43.e21 = t217;
  25455. mat43.e22 = t227;
  25456. mat43.e23 = t233;
  25457. mat43.e30 = t303;
  25458. mat43.e31 = t313;
  25459. mat43.e32 = t323;
  25460. mat43.e33 = t333;
  25461. if(_this12.sizeMat4 == _this12.stackMat4.length) {
  25462. var newLength14 = _this12.sizeMat4 << 1;
  25463. var this15 = new Array(newLength14);
  25464. var newArray14 = this15;
  25465. var _g25 = 0;
  25466. var _g115 = _this12.sizeMat4;
  25467. while(_g25 < _g115) {
  25468. var i15 = _g25++;
  25469. newArray14[i15] = _this12.stackMat4[i15];
  25470. _this12.stackMat4[i15] = null;
  25471. }
  25472. _this12.stackMat4 = newArray14;
  25473. }
  25474. _this12.stackMat4[_this12.sizeMat4++] = mat43;
  25475. }
  25476. if(quat2 != null) {
  25477. var tx9 = 0;
  25478. var ty9 = 0;
  25479. var tz9 = 0;
  25480. var tw3 = 1;
  25481. quat2.x = tx9;
  25482. quat2.y = ty9;
  25483. quat2.z = tz9;
  25484. quat2.w = tw3;
  25485. if(_this12.sizeQuat == _this12.stackQuat.length) {
  25486. var newLength15 = _this12.sizeQuat << 1;
  25487. var this16 = new Array(newLength15);
  25488. var newArray15 = this16;
  25489. var _g26 = 0;
  25490. var _g116 = _this12.sizeQuat;
  25491. while(_g26 < _g116) {
  25492. var i16 = _g26++;
  25493. newArray15[i16] = _this12.stackQuat[i16];
  25494. _this12.stackQuat[i16] = null;
  25495. }
  25496. _this12.stackQuat = newArray15;
  25497. }
  25498. _this12.stackQuat[_this12.sizeQuat++] = quat2;
  25499. }
  25500. var _this13 = this._pool;
  25501. var mat33 = null;
  25502. var mat44 = null;
  25503. var quat3 = null;
  25504. if(prevV != null) {
  25505. prevV.zero();
  25506. if(_this13.sizeVec3 == _this13.stackVec3.length) {
  25507. var newLength16 = _this13.sizeVec3 << 1;
  25508. var this17 = new Array(newLength16);
  25509. var newArray16 = this17;
  25510. var _g27 = 0;
  25511. var _g117 = _this13.sizeVec3;
  25512. while(_g27 < _g117) {
  25513. var i17 = _g27++;
  25514. newArray16[i17] = _this13.stackVec3[i17];
  25515. _this13.stackVec3[i17] = null;
  25516. }
  25517. _this13.stackVec3 = newArray16;
  25518. }
  25519. _this13.stackVec3[_this13.sizeVec3++] = prevV;
  25520. }
  25521. if(mat33 != null) {
  25522. var t008 = 1;
  25523. var t018 = 0;
  25524. var t028 = 0;
  25525. var t108 = 0;
  25526. var t118 = 1;
  25527. var t128 = 0;
  25528. var t208 = 0;
  25529. var t218 = 0;
  25530. var t228 = 1;
  25531. mat33.e00 = t008;
  25532. mat33.e01 = t018;
  25533. mat33.e02 = t028;
  25534. mat33.e10 = t108;
  25535. mat33.e11 = t118;
  25536. mat33.e12 = t128;
  25537. mat33.e20 = t208;
  25538. mat33.e21 = t218;
  25539. mat33.e22 = t228;
  25540. if(_this13.sizeMat3 == _this13.stackMat3.length) {
  25541. var newLength17 = _this13.sizeMat3 << 1;
  25542. var this18 = new Array(newLength17);
  25543. var newArray17 = this18;
  25544. var _g28 = 0;
  25545. var _g118 = _this13.sizeMat3;
  25546. while(_g28 < _g118) {
  25547. var i18 = _g28++;
  25548. newArray17[i18] = _this13.stackMat3[i18];
  25549. _this13.stackMat3[i18] = null;
  25550. }
  25551. _this13.stackMat3 = newArray17;
  25552. }
  25553. _this13.stackMat3[_this13.sizeMat3++] = mat33;
  25554. }
  25555. if(mat44 != null) {
  25556. var t009 = 1;
  25557. var t019 = 0;
  25558. var t029 = 0;
  25559. var t034 = 0;
  25560. var t109 = 0;
  25561. var t119 = 1;
  25562. var t129 = 0;
  25563. var t134 = 0;
  25564. var t209 = 0;
  25565. var t219 = 0;
  25566. var t229 = 1;
  25567. var t234 = 0;
  25568. var t304 = 0;
  25569. var t314 = 0;
  25570. var t324 = 0;
  25571. var t334 = 1;
  25572. mat44.e00 = t009;
  25573. mat44.e01 = t019;
  25574. mat44.e02 = t029;
  25575. mat44.e03 = t034;
  25576. mat44.e10 = t109;
  25577. mat44.e11 = t119;
  25578. mat44.e12 = t129;
  25579. mat44.e13 = t134;
  25580. mat44.e20 = t209;
  25581. mat44.e21 = t219;
  25582. mat44.e22 = t229;
  25583. mat44.e23 = t234;
  25584. mat44.e30 = t304;
  25585. mat44.e31 = t314;
  25586. mat44.e32 = t324;
  25587. mat44.e33 = t334;
  25588. if(_this13.sizeMat4 == _this13.stackMat4.length) {
  25589. var newLength18 = _this13.sizeMat4 << 1;
  25590. var this19 = new Array(newLength18);
  25591. var newArray18 = this19;
  25592. var _g29 = 0;
  25593. var _g119 = _this13.sizeMat4;
  25594. while(_g29 < _g119) {
  25595. var i19 = _g29++;
  25596. newArray18[i19] = _this13.stackMat4[i19];
  25597. _this13.stackMat4[i19] = null;
  25598. }
  25599. _this13.stackMat4 = newArray18;
  25600. }
  25601. _this13.stackMat4[_this13.sizeMat4++] = mat44;
  25602. }
  25603. if(quat3 != null) {
  25604. var tx10 = 0;
  25605. var ty10 = 0;
  25606. var tz10 = 0;
  25607. var tw4 = 1;
  25608. quat3.x = tx10;
  25609. quat3.y = ty10;
  25610. quat3.z = tz10;
  25611. quat3.w = tw4;
  25612. if(_this13.sizeQuat == _this13.stackQuat.length) {
  25613. var newLength19 = _this13.sizeQuat << 1;
  25614. var this20 = new Array(newLength19);
  25615. var newArray19 = this20;
  25616. var _g30 = 0;
  25617. var _g120 = _this13.sizeQuat;
  25618. while(_g30 < _g120) {
  25619. var i20 = _g30++;
  25620. newArray19[i20] = _this13.stackQuat[i20];
  25621. _this13.stackQuat[i20] = null;
  25622. }
  25623. _this13.stackQuat = newArray19;
  25624. }
  25625. _this13.stackQuat[_this13.sizeQuat++] = quat3;
  25626. }
  25627. }
  25628. step(timeStep) {
  25629. if(this._timeStep.dt > 0) {
  25630. this._timeStep.dtRatio = timeStep / this._timeStep.dt;
  25631. }
  25632. this._timeStep.dt = timeStep;
  25633. this._timeStep.invDt = 1 / timeStep;
  25634. var st = Date.now() / 1000;
  25635. this._updateContacts();
  25636. this._solveIslands();
  25637. var en = Date.now() / 1000;
  25638. oimo.dynamics.common.Performance.totalTime = (en - st) * 1000;
  25639. }
  25640. addRigidBody(rigidBody) {
  25641. if(rigidBody._world != null) {
  25642. throw new Error("A rigid body cannot belong to multiple worlds.");
  25643. }
  25644. if(this._rigidBodyList == null) {
  25645. this._rigidBodyList = rigidBody;
  25646. this._rigidBodyListLast = rigidBody;
  25647. } else {
  25648. this._rigidBodyListLast._next = rigidBody;
  25649. rigidBody._prev = this._rigidBodyListLast;
  25650. this._rigidBodyListLast = rigidBody;
  25651. }
  25652. rigidBody._world = this;
  25653. var s = rigidBody._shapeList;
  25654. while(s != null) {
  25655. var n = s._next;
  25656. s._proxy = this._broadPhase.createProxy(s,s._aabb);
  25657. s._id = this._shapeIdCount++;
  25658. this._numShapes++;
  25659. s = n;
  25660. }
  25661. this._numRigidBodies++;
  25662. }
  25663. removeRigidBody(rigidBody) {
  25664. if(rigidBody._world != this) {
  25665. throw new Error("The rigid body doesn't belong to the world.");
  25666. }
  25667. var prev = rigidBody._prev;
  25668. var next = rigidBody._next;
  25669. if(prev != null) {
  25670. prev._next = next;
  25671. }
  25672. if(next != null) {
  25673. next._prev = prev;
  25674. }
  25675. if(rigidBody == this._rigidBodyList) {
  25676. this._rigidBodyList = this._rigidBodyList._next;
  25677. }
  25678. if(rigidBody == this._rigidBodyListLast) {
  25679. this._rigidBodyListLast = this._rigidBodyListLast._prev;
  25680. }
  25681. rigidBody._next = null;
  25682. rigidBody._prev = null;
  25683. rigidBody._world = null;
  25684. var s = rigidBody._shapeList;
  25685. while(s != null) {
  25686. var n = s._next;
  25687. this._broadPhase.destroyProxy(s._proxy);
  25688. s._proxy = null;
  25689. s._id = -1;
  25690. var cl = s._rigidBody._contactLinkList;
  25691. while(cl != null) {
  25692. var n1 = cl._next;
  25693. var c = cl._contact;
  25694. if(c._s1 == s || c._s2 == s) {
  25695. var _this = cl._other;
  25696. _this._sleeping = false;
  25697. _this._sleepTime = 0;
  25698. var _this1 = this._contactManager;
  25699. var prev1 = c._prev;
  25700. var next1 = c._next;
  25701. if(prev1 != null) {
  25702. prev1._next = next1;
  25703. }
  25704. if(next1 != null) {
  25705. next1._prev = prev1;
  25706. }
  25707. if(c == _this1._contactList) {
  25708. _this1._contactList = _this1._contactList._next;
  25709. }
  25710. if(c == _this1._contactListLast) {
  25711. _this1._contactListLast = _this1._contactListLast._prev;
  25712. }
  25713. c._next = null;
  25714. c._prev = null;
  25715. if(c._touching) {
  25716. var cc1 = c._s1._contactCallback;
  25717. var cc2 = c._s2._contactCallback;
  25718. if(cc1 == cc2) {
  25719. cc2 = null;
  25720. }
  25721. if(cc1 != null) {
  25722. cc1.endContact(c);
  25723. }
  25724. if(cc2 != null) {
  25725. cc2.endContact(c);
  25726. }
  25727. }
  25728. var prev2 = c._link1._prev;
  25729. var next2 = c._link1._next;
  25730. if(prev2 != null) {
  25731. prev2._next = next2;
  25732. }
  25733. if(next2 != null) {
  25734. next2._prev = prev2;
  25735. }
  25736. if(c._link1 == c._b1._contactLinkList) {
  25737. c._b1._contactLinkList = c._b1._contactLinkList._next;
  25738. }
  25739. if(c._link1 == c._b1._contactLinkListLast) {
  25740. c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev;
  25741. }
  25742. c._link1._next = null;
  25743. c._link1._prev = null;
  25744. var prev3 = c._link2._prev;
  25745. var next3 = c._link2._next;
  25746. if(prev3 != null) {
  25747. prev3._next = next3;
  25748. }
  25749. if(next3 != null) {
  25750. next3._prev = prev3;
  25751. }
  25752. if(c._link2 == c._b2._contactLinkList) {
  25753. c._b2._contactLinkList = c._b2._contactLinkList._next;
  25754. }
  25755. if(c._link2 == c._b2._contactLinkListLast) {
  25756. c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev;
  25757. }
  25758. c._link2._next = null;
  25759. c._link2._prev = null;
  25760. c._b1._numContactLinks--;
  25761. c._b2._numContactLinks--;
  25762. c._link1._other = null;
  25763. c._link2._other = null;
  25764. c._link1._contact = null;
  25765. c._link2._contact = null;
  25766. c._s1 = null;
  25767. c._s2 = null;
  25768. c._b1 = null;
  25769. c._b2 = null;
  25770. c._touching = false;
  25771. c._cachedDetectorData._clear();
  25772. c._manifold._clear();
  25773. c._detector = null;
  25774. var _this2 = c._contactConstraint;
  25775. _this2._s1 = null;
  25776. _this2._s2 = null;
  25777. _this2._b1 = null;
  25778. _this2._b2 = null;
  25779. _this2._tf1 = null;
  25780. _this2._tf2 = null;
  25781. c._next = _this1._contactPool;
  25782. _this1._contactPool = c;
  25783. _this1._numContacts--;
  25784. }
  25785. cl = n1;
  25786. }
  25787. this._numShapes--;
  25788. s = n;
  25789. }
  25790. this._numRigidBodies--;
  25791. }
  25792. addJoint(joint) {
  25793. if(joint._world != null) {
  25794. throw new Error("A joint cannot belong to multiple worlds.");
  25795. }
  25796. if(this._jointList == null) {
  25797. this._jointList = joint;
  25798. this._jointListLast = joint;
  25799. } else {
  25800. this._jointListLast._next = joint;
  25801. joint._prev = this._jointListLast;
  25802. this._jointListLast = joint;
  25803. }
  25804. joint._world = this;
  25805. joint._link1._other = joint._b2;
  25806. joint._link2._other = joint._b1;
  25807. if(joint._b1._jointLinkList == null) {
  25808. joint._b1._jointLinkList = joint._link1;
  25809. joint._b1._jointLinkListLast = joint._link1;
  25810. } else {
  25811. joint._b1._jointLinkListLast._next = joint._link1;
  25812. joint._link1._prev = joint._b1._jointLinkListLast;
  25813. joint._b1._jointLinkListLast = joint._link1;
  25814. }
  25815. if(joint._b2._jointLinkList == null) {
  25816. joint._b2._jointLinkList = joint._link2;
  25817. joint._b2._jointLinkListLast = joint._link2;
  25818. } else {
  25819. joint._b2._jointLinkListLast._next = joint._link2;
  25820. joint._link2._prev = joint._b2._jointLinkListLast;
  25821. joint._b2._jointLinkListLast = joint._link2;
  25822. }
  25823. joint._b1._numJointLinks++;
  25824. joint._b2._numJointLinks++;
  25825. var _this = joint._b1;
  25826. _this._sleeping = false;
  25827. _this._sleepTime = 0;
  25828. var _this1 = joint._b2;
  25829. _this1._sleeping = false;
  25830. _this1._sleepTime = 0;
  25831. joint._syncAnchors();
  25832. this._numJoints++;
  25833. }
  25834. removeJoint(joint) {
  25835. if(joint._world != this) {
  25836. throw new Error("The joint doesn't belong to the world.");
  25837. }
  25838. var prev = joint._prev;
  25839. var next = joint._next;
  25840. if(prev != null) {
  25841. prev._next = next;
  25842. }
  25843. if(next != null) {
  25844. next._prev = prev;
  25845. }
  25846. if(joint == this._jointList) {
  25847. this._jointList = this._jointList._next;
  25848. }
  25849. if(joint == this._jointListLast) {
  25850. this._jointListLast = this._jointListLast._prev;
  25851. }
  25852. joint._next = null;
  25853. joint._prev = null;
  25854. joint._world = null;
  25855. var prev1 = joint._link1._prev;
  25856. var next1 = joint._link1._next;
  25857. if(prev1 != null) {
  25858. prev1._next = next1;
  25859. }
  25860. if(next1 != null) {
  25861. next1._prev = prev1;
  25862. }
  25863. if(joint._link1 == joint._b1._jointLinkList) {
  25864. joint._b1._jointLinkList = joint._b1._jointLinkList._next;
  25865. }
  25866. if(joint._link1 == joint._b1._jointLinkListLast) {
  25867. joint._b1._jointLinkListLast = joint._b1._jointLinkListLast._prev;
  25868. }
  25869. joint._link1._next = null;
  25870. joint._link1._prev = null;
  25871. var prev2 = joint._link2._prev;
  25872. var next2 = joint._link2._next;
  25873. if(prev2 != null) {
  25874. prev2._next = next2;
  25875. }
  25876. if(next2 != null) {
  25877. next2._prev = prev2;
  25878. }
  25879. if(joint._link2 == joint._b2._jointLinkList) {
  25880. joint._b2._jointLinkList = joint._b2._jointLinkList._next;
  25881. }
  25882. if(joint._link2 == joint._b2._jointLinkListLast) {
  25883. joint._b2._jointLinkListLast = joint._b2._jointLinkListLast._prev;
  25884. }
  25885. joint._link2._next = null;
  25886. joint._link2._prev = null;
  25887. joint._link1._other = null;
  25888. joint._link2._other = null;
  25889. joint._b1._numJointLinks--;
  25890. joint._b2._numJointLinks--;
  25891. var _this = joint._b1;
  25892. _this._sleeping = false;
  25893. _this._sleepTime = 0;
  25894. var _this1 = joint._b2;
  25895. _this1._sleeping = false;
  25896. _this1._sleepTime = 0;
  25897. this._numJoints--;
  25898. }
  25899. setDebugDraw(debugDraw) {
  25900. this._debugDraw = debugDraw;
  25901. }
  25902. getDebugDraw() {
  25903. return this._debugDraw;
  25904. }
  25905. debugDraw() {
  25906. if(this._debugDraw != null) {
  25907. if(this._broadPhase._type == 2) {
  25908. var bvhBroadPhase = this._broadPhase;
  25909. this._drawBvh(this._debugDraw,bvhBroadPhase._tree);
  25910. }
  25911. this._drawRigidBodies(this._debugDraw);
  25912. this._drawConstraints(this._debugDraw);
  25913. }
  25914. }
  25915. rayCast(begin,end,callback) {
  25916. var _this = this._rayCastWrapper.begin;
  25917. _this.x = begin.x;
  25918. _this.y = begin.y;
  25919. _this.z = begin.z;
  25920. var _this1 = this._rayCastWrapper.end;
  25921. _this1.x = end.x;
  25922. _this1.y = end.y;
  25923. _this1.z = end.z;
  25924. this._rayCastWrapper.callback = callback;
  25925. this._broadPhase.rayCast(begin,end,this._rayCastWrapper);
  25926. }
  25927. convexCast(convex,begin,translation,callback) {
  25928. this._convexCastWrapper.convex = convex;
  25929. var _this = this._convexCastWrapper.begin;
  25930. _this._positionX = begin._positionX;
  25931. _this._positionY = begin._positionY;
  25932. _this._positionZ = begin._positionZ;
  25933. _this._rotation00 = begin._rotation00;
  25934. _this._rotation01 = begin._rotation01;
  25935. _this._rotation02 = begin._rotation02;
  25936. _this._rotation10 = begin._rotation10;
  25937. _this._rotation11 = begin._rotation11;
  25938. _this._rotation12 = begin._rotation12;
  25939. _this._rotation20 = begin._rotation20;
  25940. _this._rotation21 = begin._rotation21;
  25941. _this._rotation22 = begin._rotation22;
  25942. var _this1 = this._convexCastWrapper.translation;
  25943. _this1.x = translation.x;
  25944. _this1.y = translation.y;
  25945. _this1.z = translation.z;
  25946. this._convexCastWrapper.callback = callback;
  25947. this._broadPhase.convexCast(convex,begin,translation,this._convexCastWrapper);
  25948. }
  25949. aabbTest(aabb,callback) {
  25950. this._aabbTestWrapper._aabb.copyFrom(aabb);
  25951. this._aabbTestWrapper._callback = callback;
  25952. this._broadPhase.aabbTest(aabb,this._aabbTestWrapper);
  25953. }
  25954. getRigidBodyList() {
  25955. return this._rigidBodyList;
  25956. }
  25957. getJointList() {
  25958. return this._jointList;
  25959. }
  25960. getBroadPhase() {
  25961. return this._broadPhase;
  25962. }
  25963. getContactManager() {
  25964. return this._contactManager;
  25965. }
  25966. getNumRigidBodies() {
  25967. return this._numRigidBodies;
  25968. }
  25969. getNumJoints() {
  25970. return this._numJoints;
  25971. }
  25972. getNumShapes() {
  25973. return this._numShapes;
  25974. }
  25975. getNumIslands() {
  25976. return this._numIslands;
  25977. }
  25978. getNumVelocityIterations() {
  25979. return this._numVelocityIterations;
  25980. }
  25981. setNumVelocityIterations(numVelocityIterations) {
  25982. this._numVelocityIterations = numVelocityIterations;
  25983. }
  25984. getNumPositionIterations() {
  25985. return this._numPositionIterations;
  25986. }
  25987. setNumPositionIterations(numPositionIterations) {
  25988. this._numPositionIterations = numPositionIterations;
  25989. }
  25990. getGravity() {
  25991. return this._gravity;
  25992. }
  25993. setGravity(gravity) {
  25994. var _this = this._gravity;
  25995. _this.x = gravity.x;
  25996. _this.y = gravity.y;
  25997. _this.z = gravity.z;
  25998. }
  25999. }
  26000. if(!oimo.dynamics._World) oimo.dynamics._World = {};
  26001. oimo.dynamics._World.RayCastWrapper = class oimo_dynamics__$World_RayCastWrapper extends oimo.collision.broadphase.BroadPhaseProxyCallback {
  26002. constructor() {
  26003. super();
  26004. this.rayCastHit = new oimo.collision.geometry.RayCastHit();
  26005. this.begin = new oimo.common.Vec3();
  26006. this.end = new oimo.common.Vec3();
  26007. this.callback = null;
  26008. }
  26009. process(proxy) {
  26010. var shape = proxy.userData;
  26011. if(shape._geom.rayCast(this.begin,this.end,shape._transform,this.rayCastHit)) {
  26012. this.callback.process(shape,this.rayCastHit);
  26013. }
  26014. }
  26015. }
  26016. oimo.dynamics._World.ConvexCastWrapper = class oimo_dynamics__$World_ConvexCastWrapper extends oimo.collision.broadphase.BroadPhaseProxyCallback {
  26017. constructor() {
  26018. super();
  26019. this.rayCastHit = new oimo.collision.geometry.RayCastHit();
  26020. this.begin = new oimo.common.Transform();
  26021. this.translation = new oimo.common.Vec3();
  26022. this.zero = new oimo.common.Vec3();
  26023. this.callback = null;
  26024. this.convex = null;
  26025. }
  26026. process(proxy) {
  26027. var shape = proxy.userData;
  26028. var type = shape._geom._type;
  26029. if(type < 0 || type > 5) {
  26030. return;
  26031. }
  26032. var geom = shape._geom;
  26033. if(oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance.convexCast(this.convex,geom,this.begin,shape._transform,this.translation,this.zero,this.rayCastHit)) {
  26034. this.callback.process(shape,this.rayCastHit);
  26035. }
  26036. }
  26037. }
  26038. oimo.dynamics._World.AabbTestWrapper = class oimo_dynamics__$World_AabbTestWrapper extends oimo.collision.broadphase.BroadPhaseProxyCallback {
  26039. constructor() {
  26040. super();
  26041. this._aabb = new oimo.collision.geometry.Aabb();
  26042. this._callback = null;
  26043. }
  26044. process(proxy) {
  26045. var shape = proxy.userData;
  26046. var shapeAabb = shape._aabb;
  26047. if(shapeAabb._minX < this._aabb._maxX && shapeAabb._maxX > this._aabb._minX && shapeAabb._minY < this._aabb._maxY && shapeAabb._maxY > this._aabb._minY && shapeAabb._minZ < this._aabb._maxZ && shapeAabb._maxZ > this._aabb._minZ) {
  26048. this._callback.process(shape);
  26049. }
  26050. }
  26051. }
  26052. if(!oimo.dynamics.callback) oimo.dynamics.callback = {};
  26053. oimo.dynamics.callback.AabbTestCallback = class oimo_dynamics_callback_AabbTestCallback {
  26054. constructor() {
  26055. }
  26056. process(shape) {
  26057. }
  26058. }
  26059. oimo.dynamics.callback.ContactCallback = class oimo_dynamics_callback_ContactCallback {
  26060. constructor() {
  26061. }
  26062. beginContact(c) {
  26063. }
  26064. preSolve(c) {
  26065. }
  26066. postSolve(c) {
  26067. }
  26068. endContact(c) {
  26069. }
  26070. }
  26071. oimo.dynamics.callback.RayCastCallback = class oimo_dynamics_callback_RayCastCallback {
  26072. constructor() {
  26073. }
  26074. process(shape,hit) {
  26075. }
  26076. }
  26077. oimo.dynamics.callback.RayCastClosest = class oimo_dynamics_callback_RayCastClosest extends oimo.dynamics.callback.RayCastCallback {
  26078. constructor() {
  26079. super();
  26080. this.position = new oimo.common.Vec3();
  26081. this.normal = new oimo.common.Vec3();
  26082. this.shape = null;
  26083. this.fraction = 1;
  26084. this.position.zero();
  26085. this.normal.zero();
  26086. this.hit = false;
  26087. }
  26088. clear() {
  26089. this.shape = null;
  26090. this.fraction = 1;
  26091. this.position.zero();
  26092. this.normal.zero();
  26093. this.hit = false;
  26094. }
  26095. process(shape,hit) {
  26096. if(hit.fraction < this.fraction) {
  26097. this.shape = shape;
  26098. this.hit = true;
  26099. this.fraction = hit.fraction;
  26100. var _this = this.position;
  26101. var v = hit.position;
  26102. _this.x = v.x;
  26103. _this.y = v.y;
  26104. _this.z = v.z;
  26105. var _this1 = this.normal;
  26106. var v1 = hit.normal;
  26107. _this1.x = v1.x;
  26108. _this1.y = v1.y;
  26109. _this1.z = v1.z;
  26110. }
  26111. }
  26112. }
  26113. if(!oimo.dynamics.common) oimo.dynamics.common = {};
  26114. oimo.dynamics.common.DebugDraw = class oimo_dynamics_common_DebugDraw {
  26115. constructor() {
  26116. this.p = new oimo.common.Pool();
  26117. this.wireframe = false;
  26118. this.drawShapes = true;
  26119. this.drawBvh = false;
  26120. this.drawBvhMinLevel = 0;
  26121. this.drawBvhMaxLevel = 65536;
  26122. this.drawAabbs = false;
  26123. this.drawBases = false;
  26124. this.drawPairs = false;
  26125. this.drawContacts = false;
  26126. this.drawJoints = true;
  26127. this.drawJointLimits = false;
  26128. var nt = 4;
  26129. var dt = 3.14159265358979 / nt;
  26130. var np = 8;
  26131. var dp = 6.28318530717958 / np;
  26132. var this1 = new Array(nt + 1);
  26133. this.sphereCoords = this1;
  26134. var this2 = new Array(nt + 1);
  26135. this.tmpSphereVerts = this2;
  26136. var this3 = new Array(nt + 1);
  26137. this.tmpSphereNorms = this3;
  26138. var _g = 0;
  26139. var _g1 = nt + 1;
  26140. while(_g < _g1) {
  26141. var i = _g++;
  26142. var num = i == 0 || i == nt ? 1 : np;
  26143. var this4 = this.sphereCoords;
  26144. var this5 = new Array(num);
  26145. this4[i] = this5;
  26146. var this6 = this.tmpSphereVerts;
  26147. var this7 = new Array(num);
  26148. this6[i] = this7;
  26149. var this8 = this.tmpSphereNorms;
  26150. var this9 = new Array(num);
  26151. this8[i] = this9;
  26152. var _g2 = 0;
  26153. var _g11 = np;
  26154. while(_g2 < _g11) {
  26155. var j = _g2++;
  26156. var theta = i * dt;
  26157. var phi = j * dp;
  26158. this.sphereCoords[i][j] = new oimo.common.Vec3(Math.sin(theta) * Math.cos(phi),Math.cos(theta),-Math.sin(theta) * Math.sin(phi));
  26159. this.tmpSphereVerts[i][j] = new oimo.common.Vec3();
  26160. this.tmpSphereNorms[i][j] = new oimo.common.Vec3();
  26161. }
  26162. }
  26163. var this10 = new Array(8);
  26164. this.circleCoords = this10;
  26165. var this11 = new Array(8);
  26166. this.circleCoordsShift = this11;
  26167. var this12 = new Array(8);
  26168. this.tmpCircleVerts1 = this12;
  26169. var this13 = new Array(8);
  26170. this.tmpCircleVerts2 = this13;
  26171. var this14 = new Array(8);
  26172. this.tmpCircleNorms = this14;
  26173. var td = 0.785398163397447502;
  26174. var _g3 = 0;
  26175. while(_g3 < 8) {
  26176. var i1 = _g3++;
  26177. this.circleCoords[i1] = new oimo.common.Vec3(Math.cos(i1 * td),0,-Math.sin(i1 * td));
  26178. this.circleCoordsShift[i1] = new oimo.common.Vec3(Math.cos((i1 + 0.5) * td),0,-Math.sin((i1 + 0.5) * td));
  26179. this.tmpCircleVerts1[i1] = new oimo.common.Vec3();
  26180. this.tmpCircleVerts2[i1] = new oimo.common.Vec3();
  26181. this.tmpCircleNorms[i1] = new oimo.common.Vec3();
  26182. }
  26183. this.style = new oimo.dynamics.common.DebugDrawStyle();
  26184. }
  26185. aabb(min,max,color) {
  26186. var _this = this.p;
  26187. var v1 = (_this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]).init(min.x,min.y,min.z);
  26188. var _this1 = this.p;
  26189. var v2 = (_this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]).init(min.x,min.y,max.z);
  26190. var _this2 = this.p;
  26191. var v3 = (_this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]).init(min.x,max.y,min.z);
  26192. var _this3 = this.p;
  26193. var v4 = (_this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]).init(min.x,max.y,max.z);
  26194. var _this4 = this.p;
  26195. var v5 = (_this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3]).init(max.x,min.y,min.z);
  26196. var _this5 = this.p;
  26197. var v6 = (_this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]).init(max.x,min.y,max.z);
  26198. var _this6 = this.p;
  26199. var v7 = (_this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3]).init(max.x,max.y,min.z);
  26200. var _this7 = this.p;
  26201. var v8 = (_this7.sizeVec3 == 0 ? new oimo.common.Vec3() : _this7.stackVec3[--_this7.sizeVec3]).init(max.x,max.y,max.z);
  26202. this.line(v1,v2,color);
  26203. this.line(v3,v4,color);
  26204. this.line(v5,v6,color);
  26205. this.line(v7,v8,color);
  26206. this.line(v1,v3,color);
  26207. this.line(v2,v4,color);
  26208. this.line(v5,v7,color);
  26209. this.line(v6,v8,color);
  26210. this.line(v1,v5,color);
  26211. this.line(v2,v6,color);
  26212. this.line(v3,v7,color);
  26213. this.line(v4,v8,color);
  26214. var _this8 = this.p;
  26215. var mat3 = null;
  26216. var mat4 = null;
  26217. var quat = null;
  26218. if(v1 != null) {
  26219. v1.zero();
  26220. if(_this8.sizeVec3 == _this8.stackVec3.length) {
  26221. var newLength = _this8.sizeVec3 << 1;
  26222. var this1 = new Array(newLength);
  26223. var newArray = this1;
  26224. var _g = 0;
  26225. var _g1 = _this8.sizeVec3;
  26226. while(_g < _g1) {
  26227. var i = _g++;
  26228. newArray[i] = _this8.stackVec3[i];
  26229. _this8.stackVec3[i] = null;
  26230. }
  26231. _this8.stackVec3 = newArray;
  26232. }
  26233. _this8.stackVec3[_this8.sizeVec3++] = v1;
  26234. }
  26235. if(mat3 != null) {
  26236. var t00 = 1;
  26237. var t01 = 0;
  26238. var t02 = 0;
  26239. var t10 = 0;
  26240. var t11 = 1;
  26241. var t12 = 0;
  26242. var t20 = 0;
  26243. var t21 = 0;
  26244. var t22 = 1;
  26245. mat3.e00 = t00;
  26246. mat3.e01 = t01;
  26247. mat3.e02 = t02;
  26248. mat3.e10 = t10;
  26249. mat3.e11 = t11;
  26250. mat3.e12 = t12;
  26251. mat3.e20 = t20;
  26252. mat3.e21 = t21;
  26253. mat3.e22 = t22;
  26254. if(_this8.sizeMat3 == _this8.stackMat3.length) {
  26255. var newLength1 = _this8.sizeMat3 << 1;
  26256. var this2 = new Array(newLength1);
  26257. var newArray1 = this2;
  26258. var _g2 = 0;
  26259. var _g11 = _this8.sizeMat3;
  26260. while(_g2 < _g11) {
  26261. var i1 = _g2++;
  26262. newArray1[i1] = _this8.stackMat3[i1];
  26263. _this8.stackMat3[i1] = null;
  26264. }
  26265. _this8.stackMat3 = newArray1;
  26266. }
  26267. _this8.stackMat3[_this8.sizeMat3++] = mat3;
  26268. }
  26269. if(mat4 != null) {
  26270. var t001 = 1;
  26271. var t011 = 0;
  26272. var t021 = 0;
  26273. var t03 = 0;
  26274. var t101 = 0;
  26275. var t111 = 1;
  26276. var t121 = 0;
  26277. var t13 = 0;
  26278. var t201 = 0;
  26279. var t211 = 0;
  26280. var t221 = 1;
  26281. var t23 = 0;
  26282. var t30 = 0;
  26283. var t31 = 0;
  26284. var t32 = 0;
  26285. var t33 = 1;
  26286. mat4.e00 = t001;
  26287. mat4.e01 = t011;
  26288. mat4.e02 = t021;
  26289. mat4.e03 = t03;
  26290. mat4.e10 = t101;
  26291. mat4.e11 = t111;
  26292. mat4.e12 = t121;
  26293. mat4.e13 = t13;
  26294. mat4.e20 = t201;
  26295. mat4.e21 = t211;
  26296. mat4.e22 = t221;
  26297. mat4.e23 = t23;
  26298. mat4.e30 = t30;
  26299. mat4.e31 = t31;
  26300. mat4.e32 = t32;
  26301. mat4.e33 = t33;
  26302. if(_this8.sizeMat4 == _this8.stackMat4.length) {
  26303. var newLength2 = _this8.sizeMat4 << 1;
  26304. var this3 = new Array(newLength2);
  26305. var newArray2 = this3;
  26306. var _g3 = 0;
  26307. var _g12 = _this8.sizeMat4;
  26308. while(_g3 < _g12) {
  26309. var i2 = _g3++;
  26310. newArray2[i2] = _this8.stackMat4[i2];
  26311. _this8.stackMat4[i2] = null;
  26312. }
  26313. _this8.stackMat4 = newArray2;
  26314. }
  26315. _this8.stackMat4[_this8.sizeMat4++] = mat4;
  26316. }
  26317. if(quat != null) {
  26318. var tx = 0;
  26319. var ty = 0;
  26320. var tz = 0;
  26321. var tw = 1;
  26322. quat.x = tx;
  26323. quat.y = ty;
  26324. quat.z = tz;
  26325. quat.w = tw;
  26326. if(_this8.sizeQuat == _this8.stackQuat.length) {
  26327. var newLength3 = _this8.sizeQuat << 1;
  26328. var this4 = new Array(newLength3);
  26329. var newArray3 = this4;
  26330. var _g4 = 0;
  26331. var _g13 = _this8.sizeQuat;
  26332. while(_g4 < _g13) {
  26333. var i3 = _g4++;
  26334. newArray3[i3] = _this8.stackQuat[i3];
  26335. _this8.stackQuat[i3] = null;
  26336. }
  26337. _this8.stackQuat = newArray3;
  26338. }
  26339. _this8.stackQuat[_this8.sizeQuat++] = quat;
  26340. }
  26341. var _this9 = this.p;
  26342. var mat31 = null;
  26343. var mat41 = null;
  26344. var quat1 = null;
  26345. if(v2 != null) {
  26346. v2.zero();
  26347. if(_this9.sizeVec3 == _this9.stackVec3.length) {
  26348. var newLength4 = _this9.sizeVec3 << 1;
  26349. var this5 = new Array(newLength4);
  26350. var newArray4 = this5;
  26351. var _g5 = 0;
  26352. var _g14 = _this9.sizeVec3;
  26353. while(_g5 < _g14) {
  26354. var i4 = _g5++;
  26355. newArray4[i4] = _this9.stackVec3[i4];
  26356. _this9.stackVec3[i4] = null;
  26357. }
  26358. _this9.stackVec3 = newArray4;
  26359. }
  26360. _this9.stackVec3[_this9.sizeVec3++] = v2;
  26361. }
  26362. if(mat31 != null) {
  26363. var t002 = 1;
  26364. var t012 = 0;
  26365. var t022 = 0;
  26366. var t102 = 0;
  26367. var t112 = 1;
  26368. var t122 = 0;
  26369. var t202 = 0;
  26370. var t212 = 0;
  26371. var t222 = 1;
  26372. mat31.e00 = t002;
  26373. mat31.e01 = t012;
  26374. mat31.e02 = t022;
  26375. mat31.e10 = t102;
  26376. mat31.e11 = t112;
  26377. mat31.e12 = t122;
  26378. mat31.e20 = t202;
  26379. mat31.e21 = t212;
  26380. mat31.e22 = t222;
  26381. if(_this9.sizeMat3 == _this9.stackMat3.length) {
  26382. var newLength5 = _this9.sizeMat3 << 1;
  26383. var this6 = new Array(newLength5);
  26384. var newArray5 = this6;
  26385. var _g6 = 0;
  26386. var _g15 = _this9.sizeMat3;
  26387. while(_g6 < _g15) {
  26388. var i5 = _g6++;
  26389. newArray5[i5] = _this9.stackMat3[i5];
  26390. _this9.stackMat3[i5] = null;
  26391. }
  26392. _this9.stackMat3 = newArray5;
  26393. }
  26394. _this9.stackMat3[_this9.sizeMat3++] = mat31;
  26395. }
  26396. if(mat41 != null) {
  26397. var t003 = 1;
  26398. var t013 = 0;
  26399. var t023 = 0;
  26400. var t031 = 0;
  26401. var t103 = 0;
  26402. var t113 = 1;
  26403. var t123 = 0;
  26404. var t131 = 0;
  26405. var t203 = 0;
  26406. var t213 = 0;
  26407. var t223 = 1;
  26408. var t231 = 0;
  26409. var t301 = 0;
  26410. var t311 = 0;
  26411. var t321 = 0;
  26412. var t331 = 1;
  26413. mat41.e00 = t003;
  26414. mat41.e01 = t013;
  26415. mat41.e02 = t023;
  26416. mat41.e03 = t031;
  26417. mat41.e10 = t103;
  26418. mat41.e11 = t113;
  26419. mat41.e12 = t123;
  26420. mat41.e13 = t131;
  26421. mat41.e20 = t203;
  26422. mat41.e21 = t213;
  26423. mat41.e22 = t223;
  26424. mat41.e23 = t231;
  26425. mat41.e30 = t301;
  26426. mat41.e31 = t311;
  26427. mat41.e32 = t321;
  26428. mat41.e33 = t331;
  26429. if(_this9.sizeMat4 == _this9.stackMat4.length) {
  26430. var newLength6 = _this9.sizeMat4 << 1;
  26431. var this7 = new Array(newLength6);
  26432. var newArray6 = this7;
  26433. var _g7 = 0;
  26434. var _g16 = _this9.sizeMat4;
  26435. while(_g7 < _g16) {
  26436. var i6 = _g7++;
  26437. newArray6[i6] = _this9.stackMat4[i6];
  26438. _this9.stackMat4[i6] = null;
  26439. }
  26440. _this9.stackMat4 = newArray6;
  26441. }
  26442. _this9.stackMat4[_this9.sizeMat4++] = mat41;
  26443. }
  26444. if(quat1 != null) {
  26445. var tx1 = 0;
  26446. var ty1 = 0;
  26447. var tz1 = 0;
  26448. var tw1 = 1;
  26449. quat1.x = tx1;
  26450. quat1.y = ty1;
  26451. quat1.z = tz1;
  26452. quat1.w = tw1;
  26453. if(_this9.sizeQuat == _this9.stackQuat.length) {
  26454. var newLength7 = _this9.sizeQuat << 1;
  26455. var this8 = new Array(newLength7);
  26456. var newArray7 = this8;
  26457. var _g8 = 0;
  26458. var _g17 = _this9.sizeQuat;
  26459. while(_g8 < _g17) {
  26460. var i7 = _g8++;
  26461. newArray7[i7] = _this9.stackQuat[i7];
  26462. _this9.stackQuat[i7] = null;
  26463. }
  26464. _this9.stackQuat = newArray7;
  26465. }
  26466. _this9.stackQuat[_this9.sizeQuat++] = quat1;
  26467. }
  26468. var _this10 = this.p;
  26469. var mat32 = null;
  26470. var mat42 = null;
  26471. var quat2 = null;
  26472. if(v3 != null) {
  26473. v3.zero();
  26474. if(_this10.sizeVec3 == _this10.stackVec3.length) {
  26475. var newLength8 = _this10.sizeVec3 << 1;
  26476. var this9 = new Array(newLength8);
  26477. var newArray8 = this9;
  26478. var _g9 = 0;
  26479. var _g18 = _this10.sizeVec3;
  26480. while(_g9 < _g18) {
  26481. var i8 = _g9++;
  26482. newArray8[i8] = _this10.stackVec3[i8];
  26483. _this10.stackVec3[i8] = null;
  26484. }
  26485. _this10.stackVec3 = newArray8;
  26486. }
  26487. _this10.stackVec3[_this10.sizeVec3++] = v3;
  26488. }
  26489. if(mat32 != null) {
  26490. var t004 = 1;
  26491. var t014 = 0;
  26492. var t024 = 0;
  26493. var t104 = 0;
  26494. var t114 = 1;
  26495. var t124 = 0;
  26496. var t204 = 0;
  26497. var t214 = 0;
  26498. var t224 = 1;
  26499. mat32.e00 = t004;
  26500. mat32.e01 = t014;
  26501. mat32.e02 = t024;
  26502. mat32.e10 = t104;
  26503. mat32.e11 = t114;
  26504. mat32.e12 = t124;
  26505. mat32.e20 = t204;
  26506. mat32.e21 = t214;
  26507. mat32.e22 = t224;
  26508. if(_this10.sizeMat3 == _this10.stackMat3.length) {
  26509. var newLength9 = _this10.sizeMat3 << 1;
  26510. var this10 = new Array(newLength9);
  26511. var newArray9 = this10;
  26512. var _g10 = 0;
  26513. var _g19 = _this10.sizeMat3;
  26514. while(_g10 < _g19) {
  26515. var i9 = _g10++;
  26516. newArray9[i9] = _this10.stackMat3[i9];
  26517. _this10.stackMat3[i9] = null;
  26518. }
  26519. _this10.stackMat3 = newArray9;
  26520. }
  26521. _this10.stackMat3[_this10.sizeMat3++] = mat32;
  26522. }
  26523. if(mat42 != null) {
  26524. var t005 = 1;
  26525. var t015 = 0;
  26526. var t025 = 0;
  26527. var t032 = 0;
  26528. var t105 = 0;
  26529. var t115 = 1;
  26530. var t125 = 0;
  26531. var t132 = 0;
  26532. var t205 = 0;
  26533. var t215 = 0;
  26534. var t225 = 1;
  26535. var t232 = 0;
  26536. var t302 = 0;
  26537. var t312 = 0;
  26538. var t322 = 0;
  26539. var t332 = 1;
  26540. mat42.e00 = t005;
  26541. mat42.e01 = t015;
  26542. mat42.e02 = t025;
  26543. mat42.e03 = t032;
  26544. mat42.e10 = t105;
  26545. mat42.e11 = t115;
  26546. mat42.e12 = t125;
  26547. mat42.e13 = t132;
  26548. mat42.e20 = t205;
  26549. mat42.e21 = t215;
  26550. mat42.e22 = t225;
  26551. mat42.e23 = t232;
  26552. mat42.e30 = t302;
  26553. mat42.e31 = t312;
  26554. mat42.e32 = t322;
  26555. mat42.e33 = t332;
  26556. if(_this10.sizeMat4 == _this10.stackMat4.length) {
  26557. var newLength10 = _this10.sizeMat4 << 1;
  26558. var this11 = new Array(newLength10);
  26559. var newArray10 = this11;
  26560. var _g20 = 0;
  26561. var _g110 = _this10.sizeMat4;
  26562. while(_g20 < _g110) {
  26563. var i10 = _g20++;
  26564. newArray10[i10] = _this10.stackMat4[i10];
  26565. _this10.stackMat4[i10] = null;
  26566. }
  26567. _this10.stackMat4 = newArray10;
  26568. }
  26569. _this10.stackMat4[_this10.sizeMat4++] = mat42;
  26570. }
  26571. if(quat2 != null) {
  26572. var tx2 = 0;
  26573. var ty2 = 0;
  26574. var tz2 = 0;
  26575. var tw2 = 1;
  26576. quat2.x = tx2;
  26577. quat2.y = ty2;
  26578. quat2.z = tz2;
  26579. quat2.w = tw2;
  26580. if(_this10.sizeQuat == _this10.stackQuat.length) {
  26581. var newLength11 = _this10.sizeQuat << 1;
  26582. var this12 = new Array(newLength11);
  26583. var newArray11 = this12;
  26584. var _g21 = 0;
  26585. var _g111 = _this10.sizeQuat;
  26586. while(_g21 < _g111) {
  26587. var i11 = _g21++;
  26588. newArray11[i11] = _this10.stackQuat[i11];
  26589. _this10.stackQuat[i11] = null;
  26590. }
  26591. _this10.stackQuat = newArray11;
  26592. }
  26593. _this10.stackQuat[_this10.sizeQuat++] = quat2;
  26594. }
  26595. var _this11 = this.p;
  26596. var mat33 = null;
  26597. var mat43 = null;
  26598. var quat3 = null;
  26599. if(v4 != null) {
  26600. v4.zero();
  26601. if(_this11.sizeVec3 == _this11.stackVec3.length) {
  26602. var newLength12 = _this11.sizeVec3 << 1;
  26603. var this13 = new Array(newLength12);
  26604. var newArray12 = this13;
  26605. var _g22 = 0;
  26606. var _g112 = _this11.sizeVec3;
  26607. while(_g22 < _g112) {
  26608. var i12 = _g22++;
  26609. newArray12[i12] = _this11.stackVec3[i12];
  26610. _this11.stackVec3[i12] = null;
  26611. }
  26612. _this11.stackVec3 = newArray12;
  26613. }
  26614. _this11.stackVec3[_this11.sizeVec3++] = v4;
  26615. }
  26616. if(mat33 != null) {
  26617. var t006 = 1;
  26618. var t016 = 0;
  26619. var t026 = 0;
  26620. var t106 = 0;
  26621. var t116 = 1;
  26622. var t126 = 0;
  26623. var t206 = 0;
  26624. var t216 = 0;
  26625. var t226 = 1;
  26626. mat33.e00 = t006;
  26627. mat33.e01 = t016;
  26628. mat33.e02 = t026;
  26629. mat33.e10 = t106;
  26630. mat33.e11 = t116;
  26631. mat33.e12 = t126;
  26632. mat33.e20 = t206;
  26633. mat33.e21 = t216;
  26634. mat33.e22 = t226;
  26635. if(_this11.sizeMat3 == _this11.stackMat3.length) {
  26636. var newLength13 = _this11.sizeMat3 << 1;
  26637. var this14 = new Array(newLength13);
  26638. var newArray13 = this14;
  26639. var _g23 = 0;
  26640. var _g113 = _this11.sizeMat3;
  26641. while(_g23 < _g113) {
  26642. var i13 = _g23++;
  26643. newArray13[i13] = _this11.stackMat3[i13];
  26644. _this11.stackMat3[i13] = null;
  26645. }
  26646. _this11.stackMat3 = newArray13;
  26647. }
  26648. _this11.stackMat3[_this11.sizeMat3++] = mat33;
  26649. }
  26650. if(mat43 != null) {
  26651. var t007 = 1;
  26652. var t017 = 0;
  26653. var t027 = 0;
  26654. var t033 = 0;
  26655. var t107 = 0;
  26656. var t117 = 1;
  26657. var t127 = 0;
  26658. var t133 = 0;
  26659. var t207 = 0;
  26660. var t217 = 0;
  26661. var t227 = 1;
  26662. var t233 = 0;
  26663. var t303 = 0;
  26664. var t313 = 0;
  26665. var t323 = 0;
  26666. var t333 = 1;
  26667. mat43.e00 = t007;
  26668. mat43.e01 = t017;
  26669. mat43.e02 = t027;
  26670. mat43.e03 = t033;
  26671. mat43.e10 = t107;
  26672. mat43.e11 = t117;
  26673. mat43.e12 = t127;
  26674. mat43.e13 = t133;
  26675. mat43.e20 = t207;
  26676. mat43.e21 = t217;
  26677. mat43.e22 = t227;
  26678. mat43.e23 = t233;
  26679. mat43.e30 = t303;
  26680. mat43.e31 = t313;
  26681. mat43.e32 = t323;
  26682. mat43.e33 = t333;
  26683. if(_this11.sizeMat4 == _this11.stackMat4.length) {
  26684. var newLength14 = _this11.sizeMat4 << 1;
  26685. var this15 = new Array(newLength14);
  26686. var newArray14 = this15;
  26687. var _g24 = 0;
  26688. var _g114 = _this11.sizeMat4;
  26689. while(_g24 < _g114) {
  26690. var i14 = _g24++;
  26691. newArray14[i14] = _this11.stackMat4[i14];
  26692. _this11.stackMat4[i14] = null;
  26693. }
  26694. _this11.stackMat4 = newArray14;
  26695. }
  26696. _this11.stackMat4[_this11.sizeMat4++] = mat43;
  26697. }
  26698. if(quat3 != null) {
  26699. var tx3 = 0;
  26700. var ty3 = 0;
  26701. var tz3 = 0;
  26702. var tw3 = 1;
  26703. quat3.x = tx3;
  26704. quat3.y = ty3;
  26705. quat3.z = tz3;
  26706. quat3.w = tw3;
  26707. if(_this11.sizeQuat == _this11.stackQuat.length) {
  26708. var newLength15 = _this11.sizeQuat << 1;
  26709. var this16 = new Array(newLength15);
  26710. var newArray15 = this16;
  26711. var _g25 = 0;
  26712. var _g115 = _this11.sizeQuat;
  26713. while(_g25 < _g115) {
  26714. var i15 = _g25++;
  26715. newArray15[i15] = _this11.stackQuat[i15];
  26716. _this11.stackQuat[i15] = null;
  26717. }
  26718. _this11.stackQuat = newArray15;
  26719. }
  26720. _this11.stackQuat[_this11.sizeQuat++] = quat3;
  26721. }
  26722. var _this12 = this.p;
  26723. var mat34 = null;
  26724. var mat44 = null;
  26725. var quat4 = null;
  26726. if(v5 != null) {
  26727. v5.zero();
  26728. if(_this12.sizeVec3 == _this12.stackVec3.length) {
  26729. var newLength16 = _this12.sizeVec3 << 1;
  26730. var this17 = new Array(newLength16);
  26731. var newArray16 = this17;
  26732. var _g26 = 0;
  26733. var _g116 = _this12.sizeVec3;
  26734. while(_g26 < _g116) {
  26735. var i16 = _g26++;
  26736. newArray16[i16] = _this12.stackVec3[i16];
  26737. _this12.stackVec3[i16] = null;
  26738. }
  26739. _this12.stackVec3 = newArray16;
  26740. }
  26741. _this12.stackVec3[_this12.sizeVec3++] = v5;
  26742. }
  26743. if(mat34 != null) {
  26744. var t008 = 1;
  26745. var t018 = 0;
  26746. var t028 = 0;
  26747. var t108 = 0;
  26748. var t118 = 1;
  26749. var t128 = 0;
  26750. var t208 = 0;
  26751. var t218 = 0;
  26752. var t228 = 1;
  26753. mat34.e00 = t008;
  26754. mat34.e01 = t018;
  26755. mat34.e02 = t028;
  26756. mat34.e10 = t108;
  26757. mat34.e11 = t118;
  26758. mat34.e12 = t128;
  26759. mat34.e20 = t208;
  26760. mat34.e21 = t218;
  26761. mat34.e22 = t228;
  26762. if(_this12.sizeMat3 == _this12.stackMat3.length) {
  26763. var newLength17 = _this12.sizeMat3 << 1;
  26764. var this18 = new Array(newLength17);
  26765. var newArray17 = this18;
  26766. var _g27 = 0;
  26767. var _g117 = _this12.sizeMat3;
  26768. while(_g27 < _g117) {
  26769. var i17 = _g27++;
  26770. newArray17[i17] = _this12.stackMat3[i17];
  26771. _this12.stackMat3[i17] = null;
  26772. }
  26773. _this12.stackMat3 = newArray17;
  26774. }
  26775. _this12.stackMat3[_this12.sizeMat3++] = mat34;
  26776. }
  26777. if(mat44 != null) {
  26778. var t009 = 1;
  26779. var t019 = 0;
  26780. var t029 = 0;
  26781. var t034 = 0;
  26782. var t109 = 0;
  26783. var t119 = 1;
  26784. var t129 = 0;
  26785. var t134 = 0;
  26786. var t209 = 0;
  26787. var t219 = 0;
  26788. var t229 = 1;
  26789. var t234 = 0;
  26790. var t304 = 0;
  26791. var t314 = 0;
  26792. var t324 = 0;
  26793. var t334 = 1;
  26794. mat44.e00 = t009;
  26795. mat44.e01 = t019;
  26796. mat44.e02 = t029;
  26797. mat44.e03 = t034;
  26798. mat44.e10 = t109;
  26799. mat44.e11 = t119;
  26800. mat44.e12 = t129;
  26801. mat44.e13 = t134;
  26802. mat44.e20 = t209;
  26803. mat44.e21 = t219;
  26804. mat44.e22 = t229;
  26805. mat44.e23 = t234;
  26806. mat44.e30 = t304;
  26807. mat44.e31 = t314;
  26808. mat44.e32 = t324;
  26809. mat44.e33 = t334;
  26810. if(_this12.sizeMat4 == _this12.stackMat4.length) {
  26811. var newLength18 = _this12.sizeMat4 << 1;
  26812. var this19 = new Array(newLength18);
  26813. var newArray18 = this19;
  26814. var _g28 = 0;
  26815. var _g118 = _this12.sizeMat4;
  26816. while(_g28 < _g118) {
  26817. var i18 = _g28++;
  26818. newArray18[i18] = _this12.stackMat4[i18];
  26819. _this12.stackMat4[i18] = null;
  26820. }
  26821. _this12.stackMat4 = newArray18;
  26822. }
  26823. _this12.stackMat4[_this12.sizeMat4++] = mat44;
  26824. }
  26825. if(quat4 != null) {
  26826. var tx4 = 0;
  26827. var ty4 = 0;
  26828. var tz4 = 0;
  26829. var tw4 = 1;
  26830. quat4.x = tx4;
  26831. quat4.y = ty4;
  26832. quat4.z = tz4;
  26833. quat4.w = tw4;
  26834. if(_this12.sizeQuat == _this12.stackQuat.length) {
  26835. var newLength19 = _this12.sizeQuat << 1;
  26836. var this20 = new Array(newLength19);
  26837. var newArray19 = this20;
  26838. var _g29 = 0;
  26839. var _g119 = _this12.sizeQuat;
  26840. while(_g29 < _g119) {
  26841. var i19 = _g29++;
  26842. newArray19[i19] = _this12.stackQuat[i19];
  26843. _this12.stackQuat[i19] = null;
  26844. }
  26845. _this12.stackQuat = newArray19;
  26846. }
  26847. _this12.stackQuat[_this12.sizeQuat++] = quat4;
  26848. }
  26849. var _this13 = this.p;
  26850. var mat35 = null;
  26851. var mat45 = null;
  26852. var quat5 = null;
  26853. if(v6 != null) {
  26854. v6.zero();
  26855. if(_this13.sizeVec3 == _this13.stackVec3.length) {
  26856. var newLength20 = _this13.sizeVec3 << 1;
  26857. var this21 = new Array(newLength20);
  26858. var newArray20 = this21;
  26859. var _g30 = 0;
  26860. var _g120 = _this13.sizeVec3;
  26861. while(_g30 < _g120) {
  26862. var i20 = _g30++;
  26863. newArray20[i20] = _this13.stackVec3[i20];
  26864. _this13.stackVec3[i20] = null;
  26865. }
  26866. _this13.stackVec3 = newArray20;
  26867. }
  26868. _this13.stackVec3[_this13.sizeVec3++] = v6;
  26869. }
  26870. if(mat35 != null) {
  26871. var t0010 = 1;
  26872. var t0110 = 0;
  26873. var t0210 = 0;
  26874. var t1010 = 0;
  26875. var t1110 = 1;
  26876. var t1210 = 0;
  26877. var t2010 = 0;
  26878. var t2110 = 0;
  26879. var t2210 = 1;
  26880. mat35.e00 = t0010;
  26881. mat35.e01 = t0110;
  26882. mat35.e02 = t0210;
  26883. mat35.e10 = t1010;
  26884. mat35.e11 = t1110;
  26885. mat35.e12 = t1210;
  26886. mat35.e20 = t2010;
  26887. mat35.e21 = t2110;
  26888. mat35.e22 = t2210;
  26889. if(_this13.sizeMat3 == _this13.stackMat3.length) {
  26890. var newLength21 = _this13.sizeMat3 << 1;
  26891. var this22 = new Array(newLength21);
  26892. var newArray21 = this22;
  26893. var _g31 = 0;
  26894. var _g121 = _this13.sizeMat3;
  26895. while(_g31 < _g121) {
  26896. var i21 = _g31++;
  26897. newArray21[i21] = _this13.stackMat3[i21];
  26898. _this13.stackMat3[i21] = null;
  26899. }
  26900. _this13.stackMat3 = newArray21;
  26901. }
  26902. _this13.stackMat3[_this13.sizeMat3++] = mat35;
  26903. }
  26904. if(mat45 != null) {
  26905. var t0011 = 1;
  26906. var t0111 = 0;
  26907. var t0211 = 0;
  26908. var t035 = 0;
  26909. var t1011 = 0;
  26910. var t1111 = 1;
  26911. var t1211 = 0;
  26912. var t135 = 0;
  26913. var t2011 = 0;
  26914. var t2111 = 0;
  26915. var t2211 = 1;
  26916. var t235 = 0;
  26917. var t305 = 0;
  26918. var t315 = 0;
  26919. var t325 = 0;
  26920. var t335 = 1;
  26921. mat45.e00 = t0011;
  26922. mat45.e01 = t0111;
  26923. mat45.e02 = t0211;
  26924. mat45.e03 = t035;
  26925. mat45.e10 = t1011;
  26926. mat45.e11 = t1111;
  26927. mat45.e12 = t1211;
  26928. mat45.e13 = t135;
  26929. mat45.e20 = t2011;
  26930. mat45.e21 = t2111;
  26931. mat45.e22 = t2211;
  26932. mat45.e23 = t235;
  26933. mat45.e30 = t305;
  26934. mat45.e31 = t315;
  26935. mat45.e32 = t325;
  26936. mat45.e33 = t335;
  26937. if(_this13.sizeMat4 == _this13.stackMat4.length) {
  26938. var newLength22 = _this13.sizeMat4 << 1;
  26939. var this23 = new Array(newLength22);
  26940. var newArray22 = this23;
  26941. var _g32 = 0;
  26942. var _g122 = _this13.sizeMat4;
  26943. while(_g32 < _g122) {
  26944. var i22 = _g32++;
  26945. newArray22[i22] = _this13.stackMat4[i22];
  26946. _this13.stackMat4[i22] = null;
  26947. }
  26948. _this13.stackMat4 = newArray22;
  26949. }
  26950. _this13.stackMat4[_this13.sizeMat4++] = mat45;
  26951. }
  26952. if(quat5 != null) {
  26953. var tx5 = 0;
  26954. var ty5 = 0;
  26955. var tz5 = 0;
  26956. var tw5 = 1;
  26957. quat5.x = tx5;
  26958. quat5.y = ty5;
  26959. quat5.z = tz5;
  26960. quat5.w = tw5;
  26961. if(_this13.sizeQuat == _this13.stackQuat.length) {
  26962. var newLength23 = _this13.sizeQuat << 1;
  26963. var this24 = new Array(newLength23);
  26964. var newArray23 = this24;
  26965. var _g33 = 0;
  26966. var _g123 = _this13.sizeQuat;
  26967. while(_g33 < _g123) {
  26968. var i23 = _g33++;
  26969. newArray23[i23] = _this13.stackQuat[i23];
  26970. _this13.stackQuat[i23] = null;
  26971. }
  26972. _this13.stackQuat = newArray23;
  26973. }
  26974. _this13.stackQuat[_this13.sizeQuat++] = quat5;
  26975. }
  26976. var _this14 = this.p;
  26977. var mat36 = null;
  26978. var mat46 = null;
  26979. var quat6 = null;
  26980. if(v7 != null) {
  26981. v7.zero();
  26982. if(_this14.sizeVec3 == _this14.stackVec3.length) {
  26983. var newLength24 = _this14.sizeVec3 << 1;
  26984. var this25 = new Array(newLength24);
  26985. var newArray24 = this25;
  26986. var _g34 = 0;
  26987. var _g124 = _this14.sizeVec3;
  26988. while(_g34 < _g124) {
  26989. var i24 = _g34++;
  26990. newArray24[i24] = _this14.stackVec3[i24];
  26991. _this14.stackVec3[i24] = null;
  26992. }
  26993. _this14.stackVec3 = newArray24;
  26994. }
  26995. _this14.stackVec3[_this14.sizeVec3++] = v7;
  26996. }
  26997. if(mat36 != null) {
  26998. var t0012 = 1;
  26999. var t0112 = 0;
  27000. var t0212 = 0;
  27001. var t1012 = 0;
  27002. var t1112 = 1;
  27003. var t1212 = 0;
  27004. var t2012 = 0;
  27005. var t2112 = 0;
  27006. var t2212 = 1;
  27007. mat36.e00 = t0012;
  27008. mat36.e01 = t0112;
  27009. mat36.e02 = t0212;
  27010. mat36.e10 = t1012;
  27011. mat36.e11 = t1112;
  27012. mat36.e12 = t1212;
  27013. mat36.e20 = t2012;
  27014. mat36.e21 = t2112;
  27015. mat36.e22 = t2212;
  27016. if(_this14.sizeMat3 == _this14.stackMat3.length) {
  27017. var newLength25 = _this14.sizeMat3 << 1;
  27018. var this26 = new Array(newLength25);
  27019. var newArray25 = this26;
  27020. var _g35 = 0;
  27021. var _g125 = _this14.sizeMat3;
  27022. while(_g35 < _g125) {
  27023. var i25 = _g35++;
  27024. newArray25[i25] = _this14.stackMat3[i25];
  27025. _this14.stackMat3[i25] = null;
  27026. }
  27027. _this14.stackMat3 = newArray25;
  27028. }
  27029. _this14.stackMat3[_this14.sizeMat3++] = mat36;
  27030. }
  27031. if(mat46 != null) {
  27032. var t0013 = 1;
  27033. var t0113 = 0;
  27034. var t0213 = 0;
  27035. var t036 = 0;
  27036. var t1013 = 0;
  27037. var t1113 = 1;
  27038. var t1213 = 0;
  27039. var t136 = 0;
  27040. var t2013 = 0;
  27041. var t2113 = 0;
  27042. var t2213 = 1;
  27043. var t236 = 0;
  27044. var t306 = 0;
  27045. var t316 = 0;
  27046. var t326 = 0;
  27047. var t336 = 1;
  27048. mat46.e00 = t0013;
  27049. mat46.e01 = t0113;
  27050. mat46.e02 = t0213;
  27051. mat46.e03 = t036;
  27052. mat46.e10 = t1013;
  27053. mat46.e11 = t1113;
  27054. mat46.e12 = t1213;
  27055. mat46.e13 = t136;
  27056. mat46.e20 = t2013;
  27057. mat46.e21 = t2113;
  27058. mat46.e22 = t2213;
  27059. mat46.e23 = t236;
  27060. mat46.e30 = t306;
  27061. mat46.e31 = t316;
  27062. mat46.e32 = t326;
  27063. mat46.e33 = t336;
  27064. if(_this14.sizeMat4 == _this14.stackMat4.length) {
  27065. var newLength26 = _this14.sizeMat4 << 1;
  27066. var this27 = new Array(newLength26);
  27067. var newArray26 = this27;
  27068. var _g36 = 0;
  27069. var _g126 = _this14.sizeMat4;
  27070. while(_g36 < _g126) {
  27071. var i26 = _g36++;
  27072. newArray26[i26] = _this14.stackMat4[i26];
  27073. _this14.stackMat4[i26] = null;
  27074. }
  27075. _this14.stackMat4 = newArray26;
  27076. }
  27077. _this14.stackMat4[_this14.sizeMat4++] = mat46;
  27078. }
  27079. if(quat6 != null) {
  27080. var tx6 = 0;
  27081. var ty6 = 0;
  27082. var tz6 = 0;
  27083. var tw6 = 1;
  27084. quat6.x = tx6;
  27085. quat6.y = ty6;
  27086. quat6.z = tz6;
  27087. quat6.w = tw6;
  27088. if(_this14.sizeQuat == _this14.stackQuat.length) {
  27089. var newLength27 = _this14.sizeQuat << 1;
  27090. var this28 = new Array(newLength27);
  27091. var newArray27 = this28;
  27092. var _g37 = 0;
  27093. var _g127 = _this14.sizeQuat;
  27094. while(_g37 < _g127) {
  27095. var i27 = _g37++;
  27096. newArray27[i27] = _this14.stackQuat[i27];
  27097. _this14.stackQuat[i27] = null;
  27098. }
  27099. _this14.stackQuat = newArray27;
  27100. }
  27101. _this14.stackQuat[_this14.sizeQuat++] = quat6;
  27102. }
  27103. var _this15 = this.p;
  27104. var mat37 = null;
  27105. var mat47 = null;
  27106. var quat7 = null;
  27107. if(v8 != null) {
  27108. v8.zero();
  27109. if(_this15.sizeVec3 == _this15.stackVec3.length) {
  27110. var newLength28 = _this15.sizeVec3 << 1;
  27111. var this29 = new Array(newLength28);
  27112. var newArray28 = this29;
  27113. var _g38 = 0;
  27114. var _g128 = _this15.sizeVec3;
  27115. while(_g38 < _g128) {
  27116. var i28 = _g38++;
  27117. newArray28[i28] = _this15.stackVec3[i28];
  27118. _this15.stackVec3[i28] = null;
  27119. }
  27120. _this15.stackVec3 = newArray28;
  27121. }
  27122. _this15.stackVec3[_this15.sizeVec3++] = v8;
  27123. }
  27124. if(mat37 != null) {
  27125. var t0014 = 1;
  27126. var t0114 = 0;
  27127. var t0214 = 0;
  27128. var t1014 = 0;
  27129. var t1114 = 1;
  27130. var t1214 = 0;
  27131. var t2014 = 0;
  27132. var t2114 = 0;
  27133. var t2214 = 1;
  27134. mat37.e00 = t0014;
  27135. mat37.e01 = t0114;
  27136. mat37.e02 = t0214;
  27137. mat37.e10 = t1014;
  27138. mat37.e11 = t1114;
  27139. mat37.e12 = t1214;
  27140. mat37.e20 = t2014;
  27141. mat37.e21 = t2114;
  27142. mat37.e22 = t2214;
  27143. if(_this15.sizeMat3 == _this15.stackMat3.length) {
  27144. var newLength29 = _this15.sizeMat3 << 1;
  27145. var this30 = new Array(newLength29);
  27146. var newArray29 = this30;
  27147. var _g39 = 0;
  27148. var _g129 = _this15.sizeMat3;
  27149. while(_g39 < _g129) {
  27150. var i29 = _g39++;
  27151. newArray29[i29] = _this15.stackMat3[i29];
  27152. _this15.stackMat3[i29] = null;
  27153. }
  27154. _this15.stackMat3 = newArray29;
  27155. }
  27156. _this15.stackMat3[_this15.sizeMat3++] = mat37;
  27157. }
  27158. if(mat47 != null) {
  27159. var t0015 = 1;
  27160. var t0115 = 0;
  27161. var t0215 = 0;
  27162. var t037 = 0;
  27163. var t1015 = 0;
  27164. var t1115 = 1;
  27165. var t1215 = 0;
  27166. var t137 = 0;
  27167. var t2015 = 0;
  27168. var t2115 = 0;
  27169. var t2215 = 1;
  27170. var t237 = 0;
  27171. var t307 = 0;
  27172. var t317 = 0;
  27173. var t327 = 0;
  27174. var t337 = 1;
  27175. mat47.e00 = t0015;
  27176. mat47.e01 = t0115;
  27177. mat47.e02 = t0215;
  27178. mat47.e03 = t037;
  27179. mat47.e10 = t1015;
  27180. mat47.e11 = t1115;
  27181. mat47.e12 = t1215;
  27182. mat47.e13 = t137;
  27183. mat47.e20 = t2015;
  27184. mat47.e21 = t2115;
  27185. mat47.e22 = t2215;
  27186. mat47.e23 = t237;
  27187. mat47.e30 = t307;
  27188. mat47.e31 = t317;
  27189. mat47.e32 = t327;
  27190. mat47.e33 = t337;
  27191. if(_this15.sizeMat4 == _this15.stackMat4.length) {
  27192. var newLength30 = _this15.sizeMat4 << 1;
  27193. var this31 = new Array(newLength30);
  27194. var newArray30 = this31;
  27195. var _g40 = 0;
  27196. var _g130 = _this15.sizeMat4;
  27197. while(_g40 < _g130) {
  27198. var i30 = _g40++;
  27199. newArray30[i30] = _this15.stackMat4[i30];
  27200. _this15.stackMat4[i30] = null;
  27201. }
  27202. _this15.stackMat4 = newArray30;
  27203. }
  27204. _this15.stackMat4[_this15.sizeMat4++] = mat47;
  27205. }
  27206. if(quat7 != null) {
  27207. var tx7 = 0;
  27208. var ty7 = 0;
  27209. var tz7 = 0;
  27210. var tw7 = 1;
  27211. quat7.x = tx7;
  27212. quat7.y = ty7;
  27213. quat7.z = tz7;
  27214. quat7.w = tw7;
  27215. if(_this15.sizeQuat == _this15.stackQuat.length) {
  27216. var newLength31 = _this15.sizeQuat << 1;
  27217. var this32 = new Array(newLength31);
  27218. var newArray31 = this32;
  27219. var _g41 = 0;
  27220. var _g131 = _this15.sizeQuat;
  27221. while(_g41 < _g131) {
  27222. var i31 = _g41++;
  27223. newArray31[i31] = _this15.stackQuat[i31];
  27224. _this15.stackQuat[i31] = null;
  27225. }
  27226. _this15.stackQuat = newArray31;
  27227. }
  27228. _this15.stackQuat[_this15.sizeQuat++] = quat7;
  27229. }
  27230. }
  27231. basis(transform,length,colorX,colorY,colorZ) {
  27232. var _this = this.p;
  27233. var pos = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  27234. var _this1 = this.p;
  27235. var rot = _this1.sizeMat3 == 0 ? new oimo.common.Mat3() : _this1.stackMat3[--_this1.sizeMat3];
  27236. var _this2 = this.p;
  27237. var ex = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  27238. var _this3 = this.p;
  27239. var ey = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  27240. var _this4 = this.p;
  27241. var ez = _this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3];
  27242. var v = pos;
  27243. v.x = transform._positionX;
  27244. v.y = transform._positionY;
  27245. v.z = transform._positionZ;
  27246. var m = rot;
  27247. m.e00 = transform._rotation00;
  27248. m.e01 = transform._rotation01;
  27249. m.e02 = transform._rotation02;
  27250. m.e10 = transform._rotation10;
  27251. m.e11 = transform._rotation11;
  27252. m.e12 = transform._rotation12;
  27253. m.e20 = transform._rotation20;
  27254. m.e21 = transform._rotation21;
  27255. m.e22 = transform._rotation22;
  27256. ex.init(rot.e00,rot.e10,rot.e20);
  27257. ey.init(rot.e01,rot.e11,rot.e21);
  27258. ez.init(rot.e02,rot.e12,rot.e22);
  27259. var tx = ex.x * length;
  27260. var ty = ex.y * length;
  27261. var tz = ex.z * length;
  27262. ex.x = tx;
  27263. ex.y = ty;
  27264. ex.z = tz;
  27265. var _this5 = ex;
  27266. var tx1 = _this5.x + pos.x;
  27267. var ty1 = _this5.y + pos.y;
  27268. var tz1 = _this5.z + pos.z;
  27269. _this5.x = tx1;
  27270. _this5.y = ty1;
  27271. _this5.z = tz1;
  27272. var tx2 = ey.x * length;
  27273. var ty2 = ey.y * length;
  27274. var tz2 = ey.z * length;
  27275. ey.x = tx2;
  27276. ey.y = ty2;
  27277. ey.z = tz2;
  27278. var _this6 = ey;
  27279. var tx3 = _this6.x + pos.x;
  27280. var ty3 = _this6.y + pos.y;
  27281. var tz3 = _this6.z + pos.z;
  27282. _this6.x = tx3;
  27283. _this6.y = ty3;
  27284. _this6.z = tz3;
  27285. var tx4 = ez.x * length;
  27286. var ty4 = ez.y * length;
  27287. var tz4 = ez.z * length;
  27288. ez.x = tx4;
  27289. ez.y = ty4;
  27290. ez.z = tz4;
  27291. var _this7 = ez;
  27292. var tx5 = _this7.x + pos.x;
  27293. var ty5 = _this7.y + pos.y;
  27294. var tz5 = _this7.z + pos.z;
  27295. _this7.x = tx5;
  27296. _this7.y = ty5;
  27297. _this7.z = tz5;
  27298. this.line(pos,ex,colorX);
  27299. this.line(pos,ey,colorY);
  27300. this.line(pos,ez,colorZ);
  27301. var _this8 = this.p;
  27302. var mat3 = null;
  27303. var mat4 = null;
  27304. var quat = null;
  27305. if(pos != null) {
  27306. pos.zero();
  27307. if(_this8.sizeVec3 == _this8.stackVec3.length) {
  27308. var newLength = _this8.sizeVec3 << 1;
  27309. var this1 = new Array(newLength);
  27310. var newArray = this1;
  27311. var _g = 0;
  27312. var _g1 = _this8.sizeVec3;
  27313. while(_g < _g1) {
  27314. var i = _g++;
  27315. newArray[i] = _this8.stackVec3[i];
  27316. _this8.stackVec3[i] = null;
  27317. }
  27318. _this8.stackVec3 = newArray;
  27319. }
  27320. _this8.stackVec3[_this8.sizeVec3++] = pos;
  27321. }
  27322. if(mat3 != null) {
  27323. var t00 = 1;
  27324. var t01 = 0;
  27325. var t02 = 0;
  27326. var t10 = 0;
  27327. var t11 = 1;
  27328. var t12 = 0;
  27329. var t20 = 0;
  27330. var t21 = 0;
  27331. var t22 = 1;
  27332. mat3.e00 = t00;
  27333. mat3.e01 = t01;
  27334. mat3.e02 = t02;
  27335. mat3.e10 = t10;
  27336. mat3.e11 = t11;
  27337. mat3.e12 = t12;
  27338. mat3.e20 = t20;
  27339. mat3.e21 = t21;
  27340. mat3.e22 = t22;
  27341. if(_this8.sizeMat3 == _this8.stackMat3.length) {
  27342. var newLength1 = _this8.sizeMat3 << 1;
  27343. var this2 = new Array(newLength1);
  27344. var newArray1 = this2;
  27345. var _g2 = 0;
  27346. var _g11 = _this8.sizeMat3;
  27347. while(_g2 < _g11) {
  27348. var i1 = _g2++;
  27349. newArray1[i1] = _this8.stackMat3[i1];
  27350. _this8.stackMat3[i1] = null;
  27351. }
  27352. _this8.stackMat3 = newArray1;
  27353. }
  27354. _this8.stackMat3[_this8.sizeMat3++] = mat3;
  27355. }
  27356. if(mat4 != null) {
  27357. var t001 = 1;
  27358. var t011 = 0;
  27359. var t021 = 0;
  27360. var t03 = 0;
  27361. var t101 = 0;
  27362. var t111 = 1;
  27363. var t121 = 0;
  27364. var t13 = 0;
  27365. var t201 = 0;
  27366. var t211 = 0;
  27367. var t221 = 1;
  27368. var t23 = 0;
  27369. var t30 = 0;
  27370. var t31 = 0;
  27371. var t32 = 0;
  27372. var t33 = 1;
  27373. mat4.e00 = t001;
  27374. mat4.e01 = t011;
  27375. mat4.e02 = t021;
  27376. mat4.e03 = t03;
  27377. mat4.e10 = t101;
  27378. mat4.e11 = t111;
  27379. mat4.e12 = t121;
  27380. mat4.e13 = t13;
  27381. mat4.e20 = t201;
  27382. mat4.e21 = t211;
  27383. mat4.e22 = t221;
  27384. mat4.e23 = t23;
  27385. mat4.e30 = t30;
  27386. mat4.e31 = t31;
  27387. mat4.e32 = t32;
  27388. mat4.e33 = t33;
  27389. if(_this8.sizeMat4 == _this8.stackMat4.length) {
  27390. var newLength2 = _this8.sizeMat4 << 1;
  27391. var this3 = new Array(newLength2);
  27392. var newArray2 = this3;
  27393. var _g3 = 0;
  27394. var _g12 = _this8.sizeMat4;
  27395. while(_g3 < _g12) {
  27396. var i2 = _g3++;
  27397. newArray2[i2] = _this8.stackMat4[i2];
  27398. _this8.stackMat4[i2] = null;
  27399. }
  27400. _this8.stackMat4 = newArray2;
  27401. }
  27402. _this8.stackMat4[_this8.sizeMat4++] = mat4;
  27403. }
  27404. if(quat != null) {
  27405. var tx6 = 0;
  27406. var ty6 = 0;
  27407. var tz6 = 0;
  27408. var tw = 1;
  27409. quat.x = tx6;
  27410. quat.y = ty6;
  27411. quat.z = tz6;
  27412. quat.w = tw;
  27413. if(_this8.sizeQuat == _this8.stackQuat.length) {
  27414. var newLength3 = _this8.sizeQuat << 1;
  27415. var this4 = new Array(newLength3);
  27416. var newArray3 = this4;
  27417. var _g4 = 0;
  27418. var _g13 = _this8.sizeQuat;
  27419. while(_g4 < _g13) {
  27420. var i3 = _g4++;
  27421. newArray3[i3] = _this8.stackQuat[i3];
  27422. _this8.stackQuat[i3] = null;
  27423. }
  27424. _this8.stackQuat = newArray3;
  27425. }
  27426. _this8.stackQuat[_this8.sizeQuat++] = quat;
  27427. }
  27428. var _this9 = this.p;
  27429. var vec3 = null;
  27430. var mat41 = null;
  27431. var quat1 = null;
  27432. if(vec3 != null) {
  27433. vec3.zero();
  27434. if(_this9.sizeVec3 == _this9.stackVec3.length) {
  27435. var newLength4 = _this9.sizeVec3 << 1;
  27436. var this5 = new Array(newLength4);
  27437. var newArray4 = this5;
  27438. var _g5 = 0;
  27439. var _g14 = _this9.sizeVec3;
  27440. while(_g5 < _g14) {
  27441. var i4 = _g5++;
  27442. newArray4[i4] = _this9.stackVec3[i4];
  27443. _this9.stackVec3[i4] = null;
  27444. }
  27445. _this9.stackVec3 = newArray4;
  27446. }
  27447. _this9.stackVec3[_this9.sizeVec3++] = vec3;
  27448. }
  27449. if(rot != null) {
  27450. var t002 = 1;
  27451. var t012 = 0;
  27452. var t022 = 0;
  27453. var t102 = 0;
  27454. var t112 = 1;
  27455. var t122 = 0;
  27456. var t202 = 0;
  27457. var t212 = 0;
  27458. var t222 = 1;
  27459. rot.e00 = t002;
  27460. rot.e01 = t012;
  27461. rot.e02 = t022;
  27462. rot.e10 = t102;
  27463. rot.e11 = t112;
  27464. rot.e12 = t122;
  27465. rot.e20 = t202;
  27466. rot.e21 = t212;
  27467. rot.e22 = t222;
  27468. if(_this9.sizeMat3 == _this9.stackMat3.length) {
  27469. var newLength5 = _this9.sizeMat3 << 1;
  27470. var this6 = new Array(newLength5);
  27471. var newArray5 = this6;
  27472. var _g6 = 0;
  27473. var _g15 = _this9.sizeMat3;
  27474. while(_g6 < _g15) {
  27475. var i5 = _g6++;
  27476. newArray5[i5] = _this9.stackMat3[i5];
  27477. _this9.stackMat3[i5] = null;
  27478. }
  27479. _this9.stackMat3 = newArray5;
  27480. }
  27481. _this9.stackMat3[_this9.sizeMat3++] = rot;
  27482. }
  27483. if(mat41 != null) {
  27484. var t003 = 1;
  27485. var t013 = 0;
  27486. var t023 = 0;
  27487. var t031 = 0;
  27488. var t103 = 0;
  27489. var t113 = 1;
  27490. var t123 = 0;
  27491. var t131 = 0;
  27492. var t203 = 0;
  27493. var t213 = 0;
  27494. var t223 = 1;
  27495. var t231 = 0;
  27496. var t301 = 0;
  27497. var t311 = 0;
  27498. var t321 = 0;
  27499. var t331 = 1;
  27500. mat41.e00 = t003;
  27501. mat41.e01 = t013;
  27502. mat41.e02 = t023;
  27503. mat41.e03 = t031;
  27504. mat41.e10 = t103;
  27505. mat41.e11 = t113;
  27506. mat41.e12 = t123;
  27507. mat41.e13 = t131;
  27508. mat41.e20 = t203;
  27509. mat41.e21 = t213;
  27510. mat41.e22 = t223;
  27511. mat41.e23 = t231;
  27512. mat41.e30 = t301;
  27513. mat41.e31 = t311;
  27514. mat41.e32 = t321;
  27515. mat41.e33 = t331;
  27516. if(_this9.sizeMat4 == _this9.stackMat4.length) {
  27517. var newLength6 = _this9.sizeMat4 << 1;
  27518. var this7 = new Array(newLength6);
  27519. var newArray6 = this7;
  27520. var _g7 = 0;
  27521. var _g16 = _this9.sizeMat4;
  27522. while(_g7 < _g16) {
  27523. var i6 = _g7++;
  27524. newArray6[i6] = _this9.stackMat4[i6];
  27525. _this9.stackMat4[i6] = null;
  27526. }
  27527. _this9.stackMat4 = newArray6;
  27528. }
  27529. _this9.stackMat4[_this9.sizeMat4++] = mat41;
  27530. }
  27531. if(quat1 != null) {
  27532. var tx7 = 0;
  27533. var ty7 = 0;
  27534. var tz7 = 0;
  27535. var tw1 = 1;
  27536. quat1.x = tx7;
  27537. quat1.y = ty7;
  27538. quat1.z = tz7;
  27539. quat1.w = tw1;
  27540. if(_this9.sizeQuat == _this9.stackQuat.length) {
  27541. var newLength7 = _this9.sizeQuat << 1;
  27542. var this8 = new Array(newLength7);
  27543. var newArray7 = this8;
  27544. var _g8 = 0;
  27545. var _g17 = _this9.sizeQuat;
  27546. while(_g8 < _g17) {
  27547. var i7 = _g8++;
  27548. newArray7[i7] = _this9.stackQuat[i7];
  27549. _this9.stackQuat[i7] = null;
  27550. }
  27551. _this9.stackQuat = newArray7;
  27552. }
  27553. _this9.stackQuat[_this9.sizeQuat++] = quat1;
  27554. }
  27555. var _this10 = this.p;
  27556. var mat31 = null;
  27557. var mat42 = null;
  27558. var quat2 = null;
  27559. if(ex != null) {
  27560. ex.zero();
  27561. if(_this10.sizeVec3 == _this10.stackVec3.length) {
  27562. var newLength8 = _this10.sizeVec3 << 1;
  27563. var this9 = new Array(newLength8);
  27564. var newArray8 = this9;
  27565. var _g9 = 0;
  27566. var _g18 = _this10.sizeVec3;
  27567. while(_g9 < _g18) {
  27568. var i8 = _g9++;
  27569. newArray8[i8] = _this10.stackVec3[i8];
  27570. _this10.stackVec3[i8] = null;
  27571. }
  27572. _this10.stackVec3 = newArray8;
  27573. }
  27574. _this10.stackVec3[_this10.sizeVec3++] = ex;
  27575. }
  27576. if(mat31 != null) {
  27577. var t004 = 1;
  27578. var t014 = 0;
  27579. var t024 = 0;
  27580. var t104 = 0;
  27581. var t114 = 1;
  27582. var t124 = 0;
  27583. var t204 = 0;
  27584. var t214 = 0;
  27585. var t224 = 1;
  27586. mat31.e00 = t004;
  27587. mat31.e01 = t014;
  27588. mat31.e02 = t024;
  27589. mat31.e10 = t104;
  27590. mat31.e11 = t114;
  27591. mat31.e12 = t124;
  27592. mat31.e20 = t204;
  27593. mat31.e21 = t214;
  27594. mat31.e22 = t224;
  27595. if(_this10.sizeMat3 == _this10.stackMat3.length) {
  27596. var newLength9 = _this10.sizeMat3 << 1;
  27597. var this10 = new Array(newLength9);
  27598. var newArray9 = this10;
  27599. var _g10 = 0;
  27600. var _g19 = _this10.sizeMat3;
  27601. while(_g10 < _g19) {
  27602. var i9 = _g10++;
  27603. newArray9[i9] = _this10.stackMat3[i9];
  27604. _this10.stackMat3[i9] = null;
  27605. }
  27606. _this10.stackMat3 = newArray9;
  27607. }
  27608. _this10.stackMat3[_this10.sizeMat3++] = mat31;
  27609. }
  27610. if(mat42 != null) {
  27611. var t005 = 1;
  27612. var t015 = 0;
  27613. var t025 = 0;
  27614. var t032 = 0;
  27615. var t105 = 0;
  27616. var t115 = 1;
  27617. var t125 = 0;
  27618. var t132 = 0;
  27619. var t205 = 0;
  27620. var t215 = 0;
  27621. var t225 = 1;
  27622. var t232 = 0;
  27623. var t302 = 0;
  27624. var t312 = 0;
  27625. var t322 = 0;
  27626. var t332 = 1;
  27627. mat42.e00 = t005;
  27628. mat42.e01 = t015;
  27629. mat42.e02 = t025;
  27630. mat42.e03 = t032;
  27631. mat42.e10 = t105;
  27632. mat42.e11 = t115;
  27633. mat42.e12 = t125;
  27634. mat42.e13 = t132;
  27635. mat42.e20 = t205;
  27636. mat42.e21 = t215;
  27637. mat42.e22 = t225;
  27638. mat42.e23 = t232;
  27639. mat42.e30 = t302;
  27640. mat42.e31 = t312;
  27641. mat42.e32 = t322;
  27642. mat42.e33 = t332;
  27643. if(_this10.sizeMat4 == _this10.stackMat4.length) {
  27644. var newLength10 = _this10.sizeMat4 << 1;
  27645. var this11 = new Array(newLength10);
  27646. var newArray10 = this11;
  27647. var _g20 = 0;
  27648. var _g110 = _this10.sizeMat4;
  27649. while(_g20 < _g110) {
  27650. var i10 = _g20++;
  27651. newArray10[i10] = _this10.stackMat4[i10];
  27652. _this10.stackMat4[i10] = null;
  27653. }
  27654. _this10.stackMat4 = newArray10;
  27655. }
  27656. _this10.stackMat4[_this10.sizeMat4++] = mat42;
  27657. }
  27658. if(quat2 != null) {
  27659. var tx8 = 0;
  27660. var ty8 = 0;
  27661. var tz8 = 0;
  27662. var tw2 = 1;
  27663. quat2.x = tx8;
  27664. quat2.y = ty8;
  27665. quat2.z = tz8;
  27666. quat2.w = tw2;
  27667. if(_this10.sizeQuat == _this10.stackQuat.length) {
  27668. var newLength11 = _this10.sizeQuat << 1;
  27669. var this12 = new Array(newLength11);
  27670. var newArray11 = this12;
  27671. var _g21 = 0;
  27672. var _g111 = _this10.sizeQuat;
  27673. while(_g21 < _g111) {
  27674. var i11 = _g21++;
  27675. newArray11[i11] = _this10.stackQuat[i11];
  27676. _this10.stackQuat[i11] = null;
  27677. }
  27678. _this10.stackQuat = newArray11;
  27679. }
  27680. _this10.stackQuat[_this10.sizeQuat++] = quat2;
  27681. }
  27682. var _this11 = this.p;
  27683. var mat32 = null;
  27684. var mat43 = null;
  27685. var quat3 = null;
  27686. if(ey != null) {
  27687. ey.zero();
  27688. if(_this11.sizeVec3 == _this11.stackVec3.length) {
  27689. var newLength12 = _this11.sizeVec3 << 1;
  27690. var this13 = new Array(newLength12);
  27691. var newArray12 = this13;
  27692. var _g22 = 0;
  27693. var _g112 = _this11.sizeVec3;
  27694. while(_g22 < _g112) {
  27695. var i12 = _g22++;
  27696. newArray12[i12] = _this11.stackVec3[i12];
  27697. _this11.stackVec3[i12] = null;
  27698. }
  27699. _this11.stackVec3 = newArray12;
  27700. }
  27701. _this11.stackVec3[_this11.sizeVec3++] = ey;
  27702. }
  27703. if(mat32 != null) {
  27704. var t006 = 1;
  27705. var t016 = 0;
  27706. var t026 = 0;
  27707. var t106 = 0;
  27708. var t116 = 1;
  27709. var t126 = 0;
  27710. var t206 = 0;
  27711. var t216 = 0;
  27712. var t226 = 1;
  27713. mat32.e00 = t006;
  27714. mat32.e01 = t016;
  27715. mat32.e02 = t026;
  27716. mat32.e10 = t106;
  27717. mat32.e11 = t116;
  27718. mat32.e12 = t126;
  27719. mat32.e20 = t206;
  27720. mat32.e21 = t216;
  27721. mat32.e22 = t226;
  27722. if(_this11.sizeMat3 == _this11.stackMat3.length) {
  27723. var newLength13 = _this11.sizeMat3 << 1;
  27724. var this14 = new Array(newLength13);
  27725. var newArray13 = this14;
  27726. var _g23 = 0;
  27727. var _g113 = _this11.sizeMat3;
  27728. while(_g23 < _g113) {
  27729. var i13 = _g23++;
  27730. newArray13[i13] = _this11.stackMat3[i13];
  27731. _this11.stackMat3[i13] = null;
  27732. }
  27733. _this11.stackMat3 = newArray13;
  27734. }
  27735. _this11.stackMat3[_this11.sizeMat3++] = mat32;
  27736. }
  27737. if(mat43 != null) {
  27738. var t007 = 1;
  27739. var t017 = 0;
  27740. var t027 = 0;
  27741. var t033 = 0;
  27742. var t107 = 0;
  27743. var t117 = 1;
  27744. var t127 = 0;
  27745. var t133 = 0;
  27746. var t207 = 0;
  27747. var t217 = 0;
  27748. var t227 = 1;
  27749. var t233 = 0;
  27750. var t303 = 0;
  27751. var t313 = 0;
  27752. var t323 = 0;
  27753. var t333 = 1;
  27754. mat43.e00 = t007;
  27755. mat43.e01 = t017;
  27756. mat43.e02 = t027;
  27757. mat43.e03 = t033;
  27758. mat43.e10 = t107;
  27759. mat43.e11 = t117;
  27760. mat43.e12 = t127;
  27761. mat43.e13 = t133;
  27762. mat43.e20 = t207;
  27763. mat43.e21 = t217;
  27764. mat43.e22 = t227;
  27765. mat43.e23 = t233;
  27766. mat43.e30 = t303;
  27767. mat43.e31 = t313;
  27768. mat43.e32 = t323;
  27769. mat43.e33 = t333;
  27770. if(_this11.sizeMat4 == _this11.stackMat4.length) {
  27771. var newLength14 = _this11.sizeMat4 << 1;
  27772. var this15 = new Array(newLength14);
  27773. var newArray14 = this15;
  27774. var _g24 = 0;
  27775. var _g114 = _this11.sizeMat4;
  27776. while(_g24 < _g114) {
  27777. var i14 = _g24++;
  27778. newArray14[i14] = _this11.stackMat4[i14];
  27779. _this11.stackMat4[i14] = null;
  27780. }
  27781. _this11.stackMat4 = newArray14;
  27782. }
  27783. _this11.stackMat4[_this11.sizeMat4++] = mat43;
  27784. }
  27785. if(quat3 != null) {
  27786. var tx9 = 0;
  27787. var ty9 = 0;
  27788. var tz9 = 0;
  27789. var tw3 = 1;
  27790. quat3.x = tx9;
  27791. quat3.y = ty9;
  27792. quat3.z = tz9;
  27793. quat3.w = tw3;
  27794. if(_this11.sizeQuat == _this11.stackQuat.length) {
  27795. var newLength15 = _this11.sizeQuat << 1;
  27796. var this16 = new Array(newLength15);
  27797. var newArray15 = this16;
  27798. var _g25 = 0;
  27799. var _g115 = _this11.sizeQuat;
  27800. while(_g25 < _g115) {
  27801. var i15 = _g25++;
  27802. newArray15[i15] = _this11.stackQuat[i15];
  27803. _this11.stackQuat[i15] = null;
  27804. }
  27805. _this11.stackQuat = newArray15;
  27806. }
  27807. _this11.stackQuat[_this11.sizeQuat++] = quat3;
  27808. }
  27809. var _this12 = this.p;
  27810. var mat33 = null;
  27811. var mat44 = null;
  27812. var quat4 = null;
  27813. if(ez != null) {
  27814. ez.zero();
  27815. if(_this12.sizeVec3 == _this12.stackVec3.length) {
  27816. var newLength16 = _this12.sizeVec3 << 1;
  27817. var this17 = new Array(newLength16);
  27818. var newArray16 = this17;
  27819. var _g26 = 0;
  27820. var _g116 = _this12.sizeVec3;
  27821. while(_g26 < _g116) {
  27822. var i16 = _g26++;
  27823. newArray16[i16] = _this12.stackVec3[i16];
  27824. _this12.stackVec3[i16] = null;
  27825. }
  27826. _this12.stackVec3 = newArray16;
  27827. }
  27828. _this12.stackVec3[_this12.sizeVec3++] = ez;
  27829. }
  27830. if(mat33 != null) {
  27831. var t008 = 1;
  27832. var t018 = 0;
  27833. var t028 = 0;
  27834. var t108 = 0;
  27835. var t118 = 1;
  27836. var t128 = 0;
  27837. var t208 = 0;
  27838. var t218 = 0;
  27839. var t228 = 1;
  27840. mat33.e00 = t008;
  27841. mat33.e01 = t018;
  27842. mat33.e02 = t028;
  27843. mat33.e10 = t108;
  27844. mat33.e11 = t118;
  27845. mat33.e12 = t128;
  27846. mat33.e20 = t208;
  27847. mat33.e21 = t218;
  27848. mat33.e22 = t228;
  27849. if(_this12.sizeMat3 == _this12.stackMat3.length) {
  27850. var newLength17 = _this12.sizeMat3 << 1;
  27851. var this18 = new Array(newLength17);
  27852. var newArray17 = this18;
  27853. var _g27 = 0;
  27854. var _g117 = _this12.sizeMat3;
  27855. while(_g27 < _g117) {
  27856. var i17 = _g27++;
  27857. newArray17[i17] = _this12.stackMat3[i17];
  27858. _this12.stackMat3[i17] = null;
  27859. }
  27860. _this12.stackMat3 = newArray17;
  27861. }
  27862. _this12.stackMat3[_this12.sizeMat3++] = mat33;
  27863. }
  27864. if(mat44 != null) {
  27865. var t009 = 1;
  27866. var t019 = 0;
  27867. var t029 = 0;
  27868. var t034 = 0;
  27869. var t109 = 0;
  27870. var t119 = 1;
  27871. var t129 = 0;
  27872. var t134 = 0;
  27873. var t209 = 0;
  27874. var t219 = 0;
  27875. var t229 = 1;
  27876. var t234 = 0;
  27877. var t304 = 0;
  27878. var t314 = 0;
  27879. var t324 = 0;
  27880. var t334 = 1;
  27881. mat44.e00 = t009;
  27882. mat44.e01 = t019;
  27883. mat44.e02 = t029;
  27884. mat44.e03 = t034;
  27885. mat44.e10 = t109;
  27886. mat44.e11 = t119;
  27887. mat44.e12 = t129;
  27888. mat44.e13 = t134;
  27889. mat44.e20 = t209;
  27890. mat44.e21 = t219;
  27891. mat44.e22 = t229;
  27892. mat44.e23 = t234;
  27893. mat44.e30 = t304;
  27894. mat44.e31 = t314;
  27895. mat44.e32 = t324;
  27896. mat44.e33 = t334;
  27897. if(_this12.sizeMat4 == _this12.stackMat4.length) {
  27898. var newLength18 = _this12.sizeMat4 << 1;
  27899. var this19 = new Array(newLength18);
  27900. var newArray18 = this19;
  27901. var _g28 = 0;
  27902. var _g118 = _this12.sizeMat4;
  27903. while(_g28 < _g118) {
  27904. var i18 = _g28++;
  27905. newArray18[i18] = _this12.stackMat4[i18];
  27906. _this12.stackMat4[i18] = null;
  27907. }
  27908. _this12.stackMat4 = newArray18;
  27909. }
  27910. _this12.stackMat4[_this12.sizeMat4++] = mat44;
  27911. }
  27912. if(quat4 != null) {
  27913. var tx10 = 0;
  27914. var ty10 = 0;
  27915. var tz10 = 0;
  27916. var tw4 = 1;
  27917. quat4.x = tx10;
  27918. quat4.y = ty10;
  27919. quat4.z = tz10;
  27920. quat4.w = tw4;
  27921. if(_this12.sizeQuat == _this12.stackQuat.length) {
  27922. var newLength19 = _this12.sizeQuat << 1;
  27923. var this20 = new Array(newLength19);
  27924. var newArray19 = this20;
  27925. var _g29 = 0;
  27926. var _g119 = _this12.sizeQuat;
  27927. while(_g29 < _g119) {
  27928. var i19 = _g29++;
  27929. newArray19[i19] = _this12.stackQuat[i19];
  27930. _this12.stackQuat[i19] = null;
  27931. }
  27932. _this12.stackQuat = newArray19;
  27933. }
  27934. _this12.stackQuat[_this12.sizeQuat++] = quat4;
  27935. }
  27936. }
  27937. ellipse(center,ex,ey,radiusX,radiusY,color) {
  27938. this.arc(center,ex,ey,radiusX,radiusY,0,6.28318530717958,false,color);
  27939. }
  27940. arc(center,ex,ey,radiusX,radiusY,startAngle,endAngle,drawSector,color) {
  27941. var _this = this.p;
  27942. var _this1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  27943. _this1.x = ex.x;
  27944. _this1.y = ex.y;
  27945. _this1.z = ex.z;
  27946. var _this2 = _this1;
  27947. var tx = _this2.x * radiusX;
  27948. var ty = _this2.y * radiusX;
  27949. var tz = _this2.z * radiusX;
  27950. _this2.x = tx;
  27951. _this2.y = ty;
  27952. _this2.z = tz;
  27953. ex = _this2;
  27954. var _this3 = this.p;
  27955. var _this4 = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  27956. _this4.x = ey.x;
  27957. _this4.y = ey.y;
  27958. _this4.z = ey.z;
  27959. var _this5 = _this4;
  27960. var tx1 = _this5.x * radiusY;
  27961. var ty1 = _this5.y * radiusY;
  27962. var tz1 = _this5.z * radiusY;
  27963. _this5.x = tx1;
  27964. _this5.y = ty1;
  27965. _this5.z = tz1;
  27966. ey = _this5;
  27967. var step = 0.523598775598298372;
  27968. var angDiff = endAngle - startAngle;
  27969. if(angDiff < 0) {
  27970. angDiff = -angDiff;
  27971. }
  27972. var n = angDiff / step + 0.5 | 0;
  27973. if(n == 0) {
  27974. n = 1;
  27975. }
  27976. var theta = startAngle;
  27977. var dt = (endAngle - startAngle) / n;
  27978. var _this6 = this.p;
  27979. var _this7 = _this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3];
  27980. _this7.x = center.x;
  27981. _this7.y = center.y;
  27982. _this7.z = center.z;
  27983. var _this8 = _this7;
  27984. var s = Math.cos(theta);
  27985. var tx2 = _this8.x + ex.x * s;
  27986. var ty2 = _this8.y + ex.y * s;
  27987. var tz2 = _this8.z + ex.z * s;
  27988. _this8.x = tx2;
  27989. _this8.y = ty2;
  27990. _this8.z = tz2;
  27991. var _this9 = _this8;
  27992. var s1 = Math.sin(theta);
  27993. var tx3 = _this9.x + ey.x * s1;
  27994. var ty3 = _this9.y + ey.y * s1;
  27995. var tz3 = _this9.z + ey.z * s1;
  27996. _this9.x = tx3;
  27997. _this9.y = ty3;
  27998. _this9.z = tz3;
  27999. var v = _this9;
  28000. var prevV = v;
  28001. if(drawSector) {
  28002. this.line(center,prevV,color);
  28003. }
  28004. var _g = 0;
  28005. var _g1 = n;
  28006. while(_g < _g1) {
  28007. var i = _g++;
  28008. theta += dt;
  28009. var _this10 = this.p;
  28010. var _this11 = _this10.sizeVec3 == 0 ? new oimo.common.Vec3() : _this10.stackVec3[--_this10.sizeVec3];
  28011. _this11.x = center.x;
  28012. _this11.y = center.y;
  28013. _this11.z = center.z;
  28014. var _this12 = _this11;
  28015. var s2 = Math.cos(theta);
  28016. var tx4 = _this12.x + ex.x * s2;
  28017. var ty4 = _this12.y + ex.y * s2;
  28018. var tz4 = _this12.z + ex.z * s2;
  28019. _this12.x = tx4;
  28020. _this12.y = ty4;
  28021. _this12.z = tz4;
  28022. var _this13 = _this12;
  28023. var s3 = Math.sin(theta);
  28024. var tx5 = _this13.x + ey.x * s3;
  28025. var ty5 = _this13.y + ey.y * s3;
  28026. var tz5 = _this13.z + ey.z * s3;
  28027. _this13.x = tx5;
  28028. _this13.y = ty5;
  28029. _this13.z = tz5;
  28030. var v1 = _this13;
  28031. var v2 = v1;
  28032. this.line(prevV,v2,color);
  28033. var _this14 = this.p;
  28034. var mat3 = null;
  28035. var mat4 = null;
  28036. var quat = null;
  28037. if(prevV != null) {
  28038. prevV.zero();
  28039. if(_this14.sizeVec3 == _this14.stackVec3.length) {
  28040. var newLength = _this14.sizeVec3 << 1;
  28041. var this1 = new Array(newLength);
  28042. var newArray = this1;
  28043. var _g2 = 0;
  28044. var _g11 = _this14.sizeVec3;
  28045. while(_g2 < _g11) {
  28046. var i1 = _g2++;
  28047. newArray[i1] = _this14.stackVec3[i1];
  28048. _this14.stackVec3[i1] = null;
  28049. }
  28050. _this14.stackVec3 = newArray;
  28051. }
  28052. _this14.stackVec3[_this14.sizeVec3++] = prevV;
  28053. }
  28054. if(mat3 != null) {
  28055. var t00 = 1;
  28056. var t01 = 0;
  28057. var t02 = 0;
  28058. var t10 = 0;
  28059. var t11 = 1;
  28060. var t12 = 0;
  28061. var t20 = 0;
  28062. var t21 = 0;
  28063. var t22 = 1;
  28064. mat3.e00 = t00;
  28065. mat3.e01 = t01;
  28066. mat3.e02 = t02;
  28067. mat3.e10 = t10;
  28068. mat3.e11 = t11;
  28069. mat3.e12 = t12;
  28070. mat3.e20 = t20;
  28071. mat3.e21 = t21;
  28072. mat3.e22 = t22;
  28073. if(_this14.sizeMat3 == _this14.stackMat3.length) {
  28074. var newLength1 = _this14.sizeMat3 << 1;
  28075. var this2 = new Array(newLength1);
  28076. var newArray1 = this2;
  28077. var _g3 = 0;
  28078. var _g12 = _this14.sizeMat3;
  28079. while(_g3 < _g12) {
  28080. var i2 = _g3++;
  28081. newArray1[i2] = _this14.stackMat3[i2];
  28082. _this14.stackMat3[i2] = null;
  28083. }
  28084. _this14.stackMat3 = newArray1;
  28085. }
  28086. _this14.stackMat3[_this14.sizeMat3++] = mat3;
  28087. }
  28088. if(mat4 != null) {
  28089. var t001 = 1;
  28090. var t011 = 0;
  28091. var t021 = 0;
  28092. var t03 = 0;
  28093. var t101 = 0;
  28094. var t111 = 1;
  28095. var t121 = 0;
  28096. var t13 = 0;
  28097. var t201 = 0;
  28098. var t211 = 0;
  28099. var t221 = 1;
  28100. var t23 = 0;
  28101. var t30 = 0;
  28102. var t31 = 0;
  28103. var t32 = 0;
  28104. var t33 = 1;
  28105. mat4.e00 = t001;
  28106. mat4.e01 = t011;
  28107. mat4.e02 = t021;
  28108. mat4.e03 = t03;
  28109. mat4.e10 = t101;
  28110. mat4.e11 = t111;
  28111. mat4.e12 = t121;
  28112. mat4.e13 = t13;
  28113. mat4.e20 = t201;
  28114. mat4.e21 = t211;
  28115. mat4.e22 = t221;
  28116. mat4.e23 = t23;
  28117. mat4.e30 = t30;
  28118. mat4.e31 = t31;
  28119. mat4.e32 = t32;
  28120. mat4.e33 = t33;
  28121. if(_this14.sizeMat4 == _this14.stackMat4.length) {
  28122. var newLength2 = _this14.sizeMat4 << 1;
  28123. var this3 = new Array(newLength2);
  28124. var newArray2 = this3;
  28125. var _g4 = 0;
  28126. var _g13 = _this14.sizeMat4;
  28127. while(_g4 < _g13) {
  28128. var i3 = _g4++;
  28129. newArray2[i3] = _this14.stackMat4[i3];
  28130. _this14.stackMat4[i3] = null;
  28131. }
  28132. _this14.stackMat4 = newArray2;
  28133. }
  28134. _this14.stackMat4[_this14.sizeMat4++] = mat4;
  28135. }
  28136. if(quat != null) {
  28137. var tx6 = 0;
  28138. var ty6 = 0;
  28139. var tz6 = 0;
  28140. var tw = 1;
  28141. quat.x = tx6;
  28142. quat.y = ty6;
  28143. quat.z = tz6;
  28144. quat.w = tw;
  28145. if(_this14.sizeQuat == _this14.stackQuat.length) {
  28146. var newLength3 = _this14.sizeQuat << 1;
  28147. var this4 = new Array(newLength3);
  28148. var newArray3 = this4;
  28149. var _g5 = 0;
  28150. var _g14 = _this14.sizeQuat;
  28151. while(_g5 < _g14) {
  28152. var i4 = _g5++;
  28153. newArray3[i4] = _this14.stackQuat[i4];
  28154. _this14.stackQuat[i4] = null;
  28155. }
  28156. _this14.stackQuat = newArray3;
  28157. }
  28158. _this14.stackQuat[_this14.sizeQuat++] = quat;
  28159. }
  28160. prevV = v2;
  28161. }
  28162. if(drawSector) {
  28163. this.line(center,prevV,color);
  28164. }
  28165. var _this15 = this.p;
  28166. var mat31 = null;
  28167. var mat41 = null;
  28168. var quat1 = null;
  28169. if(prevV != null) {
  28170. prevV.zero();
  28171. if(_this15.sizeVec3 == _this15.stackVec3.length) {
  28172. var newLength4 = _this15.sizeVec3 << 1;
  28173. var this5 = new Array(newLength4);
  28174. var newArray4 = this5;
  28175. var _g6 = 0;
  28176. var _g15 = _this15.sizeVec3;
  28177. while(_g6 < _g15) {
  28178. var i5 = _g6++;
  28179. newArray4[i5] = _this15.stackVec3[i5];
  28180. _this15.stackVec3[i5] = null;
  28181. }
  28182. _this15.stackVec3 = newArray4;
  28183. }
  28184. _this15.stackVec3[_this15.sizeVec3++] = prevV;
  28185. }
  28186. if(mat31 != null) {
  28187. var t002 = 1;
  28188. var t012 = 0;
  28189. var t022 = 0;
  28190. var t102 = 0;
  28191. var t112 = 1;
  28192. var t122 = 0;
  28193. var t202 = 0;
  28194. var t212 = 0;
  28195. var t222 = 1;
  28196. mat31.e00 = t002;
  28197. mat31.e01 = t012;
  28198. mat31.e02 = t022;
  28199. mat31.e10 = t102;
  28200. mat31.e11 = t112;
  28201. mat31.e12 = t122;
  28202. mat31.e20 = t202;
  28203. mat31.e21 = t212;
  28204. mat31.e22 = t222;
  28205. if(_this15.sizeMat3 == _this15.stackMat3.length) {
  28206. var newLength5 = _this15.sizeMat3 << 1;
  28207. var this6 = new Array(newLength5);
  28208. var newArray5 = this6;
  28209. var _g7 = 0;
  28210. var _g16 = _this15.sizeMat3;
  28211. while(_g7 < _g16) {
  28212. var i6 = _g7++;
  28213. newArray5[i6] = _this15.stackMat3[i6];
  28214. _this15.stackMat3[i6] = null;
  28215. }
  28216. _this15.stackMat3 = newArray5;
  28217. }
  28218. _this15.stackMat3[_this15.sizeMat3++] = mat31;
  28219. }
  28220. if(mat41 != null) {
  28221. var t003 = 1;
  28222. var t013 = 0;
  28223. var t023 = 0;
  28224. var t031 = 0;
  28225. var t103 = 0;
  28226. var t113 = 1;
  28227. var t123 = 0;
  28228. var t131 = 0;
  28229. var t203 = 0;
  28230. var t213 = 0;
  28231. var t223 = 1;
  28232. var t231 = 0;
  28233. var t301 = 0;
  28234. var t311 = 0;
  28235. var t321 = 0;
  28236. var t331 = 1;
  28237. mat41.e00 = t003;
  28238. mat41.e01 = t013;
  28239. mat41.e02 = t023;
  28240. mat41.e03 = t031;
  28241. mat41.e10 = t103;
  28242. mat41.e11 = t113;
  28243. mat41.e12 = t123;
  28244. mat41.e13 = t131;
  28245. mat41.e20 = t203;
  28246. mat41.e21 = t213;
  28247. mat41.e22 = t223;
  28248. mat41.e23 = t231;
  28249. mat41.e30 = t301;
  28250. mat41.e31 = t311;
  28251. mat41.e32 = t321;
  28252. mat41.e33 = t331;
  28253. if(_this15.sizeMat4 == _this15.stackMat4.length) {
  28254. var newLength6 = _this15.sizeMat4 << 1;
  28255. var this7 = new Array(newLength6);
  28256. var newArray6 = this7;
  28257. var _g8 = 0;
  28258. var _g17 = _this15.sizeMat4;
  28259. while(_g8 < _g17) {
  28260. var i7 = _g8++;
  28261. newArray6[i7] = _this15.stackMat4[i7];
  28262. _this15.stackMat4[i7] = null;
  28263. }
  28264. _this15.stackMat4 = newArray6;
  28265. }
  28266. _this15.stackMat4[_this15.sizeMat4++] = mat41;
  28267. }
  28268. if(quat1 != null) {
  28269. var tx7 = 0;
  28270. var ty7 = 0;
  28271. var tz7 = 0;
  28272. var tw1 = 1;
  28273. quat1.x = tx7;
  28274. quat1.y = ty7;
  28275. quat1.z = tz7;
  28276. quat1.w = tw1;
  28277. if(_this15.sizeQuat == _this15.stackQuat.length) {
  28278. var newLength7 = _this15.sizeQuat << 1;
  28279. var this8 = new Array(newLength7);
  28280. var newArray7 = this8;
  28281. var _g9 = 0;
  28282. var _g18 = _this15.sizeQuat;
  28283. while(_g9 < _g18) {
  28284. var i8 = _g9++;
  28285. newArray7[i8] = _this15.stackQuat[i8];
  28286. _this15.stackQuat[i8] = null;
  28287. }
  28288. _this15.stackQuat = newArray7;
  28289. }
  28290. _this15.stackQuat[_this15.sizeQuat++] = quat1;
  28291. }
  28292. var _this16 = this.p;
  28293. var mat32 = null;
  28294. var mat42 = null;
  28295. var quat2 = null;
  28296. if(ex != null) {
  28297. ex.zero();
  28298. if(_this16.sizeVec3 == _this16.stackVec3.length) {
  28299. var newLength8 = _this16.sizeVec3 << 1;
  28300. var this9 = new Array(newLength8);
  28301. var newArray8 = this9;
  28302. var _g10 = 0;
  28303. var _g19 = _this16.sizeVec3;
  28304. while(_g10 < _g19) {
  28305. var i9 = _g10++;
  28306. newArray8[i9] = _this16.stackVec3[i9];
  28307. _this16.stackVec3[i9] = null;
  28308. }
  28309. _this16.stackVec3 = newArray8;
  28310. }
  28311. _this16.stackVec3[_this16.sizeVec3++] = ex;
  28312. }
  28313. if(mat32 != null) {
  28314. var t004 = 1;
  28315. var t014 = 0;
  28316. var t024 = 0;
  28317. var t104 = 0;
  28318. var t114 = 1;
  28319. var t124 = 0;
  28320. var t204 = 0;
  28321. var t214 = 0;
  28322. var t224 = 1;
  28323. mat32.e00 = t004;
  28324. mat32.e01 = t014;
  28325. mat32.e02 = t024;
  28326. mat32.e10 = t104;
  28327. mat32.e11 = t114;
  28328. mat32.e12 = t124;
  28329. mat32.e20 = t204;
  28330. mat32.e21 = t214;
  28331. mat32.e22 = t224;
  28332. if(_this16.sizeMat3 == _this16.stackMat3.length) {
  28333. var newLength9 = _this16.sizeMat3 << 1;
  28334. var this10 = new Array(newLength9);
  28335. var newArray9 = this10;
  28336. var _g20 = 0;
  28337. var _g110 = _this16.sizeMat3;
  28338. while(_g20 < _g110) {
  28339. var i10 = _g20++;
  28340. newArray9[i10] = _this16.stackMat3[i10];
  28341. _this16.stackMat3[i10] = null;
  28342. }
  28343. _this16.stackMat3 = newArray9;
  28344. }
  28345. _this16.stackMat3[_this16.sizeMat3++] = mat32;
  28346. }
  28347. if(mat42 != null) {
  28348. var t005 = 1;
  28349. var t015 = 0;
  28350. var t025 = 0;
  28351. var t032 = 0;
  28352. var t105 = 0;
  28353. var t115 = 1;
  28354. var t125 = 0;
  28355. var t132 = 0;
  28356. var t205 = 0;
  28357. var t215 = 0;
  28358. var t225 = 1;
  28359. var t232 = 0;
  28360. var t302 = 0;
  28361. var t312 = 0;
  28362. var t322 = 0;
  28363. var t332 = 1;
  28364. mat42.e00 = t005;
  28365. mat42.e01 = t015;
  28366. mat42.e02 = t025;
  28367. mat42.e03 = t032;
  28368. mat42.e10 = t105;
  28369. mat42.e11 = t115;
  28370. mat42.e12 = t125;
  28371. mat42.e13 = t132;
  28372. mat42.e20 = t205;
  28373. mat42.e21 = t215;
  28374. mat42.e22 = t225;
  28375. mat42.e23 = t232;
  28376. mat42.e30 = t302;
  28377. mat42.e31 = t312;
  28378. mat42.e32 = t322;
  28379. mat42.e33 = t332;
  28380. if(_this16.sizeMat4 == _this16.stackMat4.length) {
  28381. var newLength10 = _this16.sizeMat4 << 1;
  28382. var this11 = new Array(newLength10);
  28383. var newArray10 = this11;
  28384. var _g21 = 0;
  28385. var _g111 = _this16.sizeMat4;
  28386. while(_g21 < _g111) {
  28387. var i11 = _g21++;
  28388. newArray10[i11] = _this16.stackMat4[i11];
  28389. _this16.stackMat4[i11] = null;
  28390. }
  28391. _this16.stackMat4 = newArray10;
  28392. }
  28393. _this16.stackMat4[_this16.sizeMat4++] = mat42;
  28394. }
  28395. if(quat2 != null) {
  28396. var tx8 = 0;
  28397. var ty8 = 0;
  28398. var tz8 = 0;
  28399. var tw2 = 1;
  28400. quat2.x = tx8;
  28401. quat2.y = ty8;
  28402. quat2.z = tz8;
  28403. quat2.w = tw2;
  28404. if(_this16.sizeQuat == _this16.stackQuat.length) {
  28405. var newLength11 = _this16.sizeQuat << 1;
  28406. var this12 = new Array(newLength11);
  28407. var newArray11 = this12;
  28408. var _g22 = 0;
  28409. var _g112 = _this16.sizeQuat;
  28410. while(_g22 < _g112) {
  28411. var i12 = _g22++;
  28412. newArray11[i12] = _this16.stackQuat[i12];
  28413. _this16.stackQuat[i12] = null;
  28414. }
  28415. _this16.stackQuat = newArray11;
  28416. }
  28417. _this16.stackQuat[_this16.sizeQuat++] = quat2;
  28418. }
  28419. var _this17 = this.p;
  28420. var mat33 = null;
  28421. var mat43 = null;
  28422. var quat3 = null;
  28423. if(ey != null) {
  28424. ey.zero();
  28425. if(_this17.sizeVec3 == _this17.stackVec3.length) {
  28426. var newLength12 = _this17.sizeVec3 << 1;
  28427. var this13 = new Array(newLength12);
  28428. var newArray12 = this13;
  28429. var _g23 = 0;
  28430. var _g113 = _this17.sizeVec3;
  28431. while(_g23 < _g113) {
  28432. var i13 = _g23++;
  28433. newArray12[i13] = _this17.stackVec3[i13];
  28434. _this17.stackVec3[i13] = null;
  28435. }
  28436. _this17.stackVec3 = newArray12;
  28437. }
  28438. _this17.stackVec3[_this17.sizeVec3++] = ey;
  28439. }
  28440. if(mat33 != null) {
  28441. var t006 = 1;
  28442. var t016 = 0;
  28443. var t026 = 0;
  28444. var t106 = 0;
  28445. var t116 = 1;
  28446. var t126 = 0;
  28447. var t206 = 0;
  28448. var t216 = 0;
  28449. var t226 = 1;
  28450. mat33.e00 = t006;
  28451. mat33.e01 = t016;
  28452. mat33.e02 = t026;
  28453. mat33.e10 = t106;
  28454. mat33.e11 = t116;
  28455. mat33.e12 = t126;
  28456. mat33.e20 = t206;
  28457. mat33.e21 = t216;
  28458. mat33.e22 = t226;
  28459. if(_this17.sizeMat3 == _this17.stackMat3.length) {
  28460. var newLength13 = _this17.sizeMat3 << 1;
  28461. var this14 = new Array(newLength13);
  28462. var newArray13 = this14;
  28463. var _g24 = 0;
  28464. var _g114 = _this17.sizeMat3;
  28465. while(_g24 < _g114) {
  28466. var i14 = _g24++;
  28467. newArray13[i14] = _this17.stackMat3[i14];
  28468. _this17.stackMat3[i14] = null;
  28469. }
  28470. _this17.stackMat3 = newArray13;
  28471. }
  28472. _this17.stackMat3[_this17.sizeMat3++] = mat33;
  28473. }
  28474. if(mat43 != null) {
  28475. var t007 = 1;
  28476. var t017 = 0;
  28477. var t027 = 0;
  28478. var t033 = 0;
  28479. var t107 = 0;
  28480. var t117 = 1;
  28481. var t127 = 0;
  28482. var t133 = 0;
  28483. var t207 = 0;
  28484. var t217 = 0;
  28485. var t227 = 1;
  28486. var t233 = 0;
  28487. var t303 = 0;
  28488. var t313 = 0;
  28489. var t323 = 0;
  28490. var t333 = 1;
  28491. mat43.e00 = t007;
  28492. mat43.e01 = t017;
  28493. mat43.e02 = t027;
  28494. mat43.e03 = t033;
  28495. mat43.e10 = t107;
  28496. mat43.e11 = t117;
  28497. mat43.e12 = t127;
  28498. mat43.e13 = t133;
  28499. mat43.e20 = t207;
  28500. mat43.e21 = t217;
  28501. mat43.e22 = t227;
  28502. mat43.e23 = t233;
  28503. mat43.e30 = t303;
  28504. mat43.e31 = t313;
  28505. mat43.e32 = t323;
  28506. mat43.e33 = t333;
  28507. if(_this17.sizeMat4 == _this17.stackMat4.length) {
  28508. var newLength14 = _this17.sizeMat4 << 1;
  28509. var this15 = new Array(newLength14);
  28510. var newArray14 = this15;
  28511. var _g25 = 0;
  28512. var _g115 = _this17.sizeMat4;
  28513. while(_g25 < _g115) {
  28514. var i15 = _g25++;
  28515. newArray14[i15] = _this17.stackMat4[i15];
  28516. _this17.stackMat4[i15] = null;
  28517. }
  28518. _this17.stackMat4 = newArray14;
  28519. }
  28520. _this17.stackMat4[_this17.sizeMat4++] = mat43;
  28521. }
  28522. if(quat3 != null) {
  28523. var tx9 = 0;
  28524. var ty9 = 0;
  28525. var tz9 = 0;
  28526. var tw3 = 1;
  28527. quat3.x = tx9;
  28528. quat3.y = ty9;
  28529. quat3.z = tz9;
  28530. quat3.w = tw3;
  28531. if(_this17.sizeQuat == _this17.stackQuat.length) {
  28532. var newLength15 = _this17.sizeQuat << 1;
  28533. var this16 = new Array(newLength15);
  28534. var newArray15 = this16;
  28535. var _g26 = 0;
  28536. var _g116 = _this17.sizeQuat;
  28537. while(_g26 < _g116) {
  28538. var i16 = _g26++;
  28539. newArray15[i16] = _this17.stackQuat[i16];
  28540. _this17.stackQuat[i16] = null;
  28541. }
  28542. _this17.stackQuat = newArray15;
  28543. }
  28544. _this17.stackQuat[_this17.sizeQuat++] = quat3;
  28545. }
  28546. }
  28547. cone(tf,radius,halfHeight,color) {
  28548. var _this = this.p;
  28549. var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  28550. var _this1 = this.p;
  28551. var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  28552. var _this2 = this.p;
  28553. var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  28554. var _this3 = this.p;
  28555. var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  28556. var _this4 = this.p;
  28557. var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3];
  28558. var v = o;
  28559. v.x = tf._positionX;
  28560. v.y = tf._positionY;
  28561. v.z = tf._positionZ;
  28562. var m1 = m;
  28563. m1.e00 = tf._rotation00;
  28564. m1.e01 = tf._rotation01;
  28565. m1.e02 = tf._rotation02;
  28566. m1.e10 = tf._rotation10;
  28567. m1.e11 = tf._rotation11;
  28568. m1.e12 = tf._rotation12;
  28569. m1.e20 = tf._rotation20;
  28570. m1.e21 = tf._rotation21;
  28571. m1.e22 = tf._rotation22;
  28572. ex.init(m.e00,m.e10,m.e20);
  28573. ey.init(m.e01,m.e11,m.e21);
  28574. ez.init(m.e02,m.e12,m.e22);
  28575. var _this5 = this.p;
  28576. var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3];
  28577. _this6.x = o.x;
  28578. _this6.y = o.y;
  28579. _this6.z = o.z;
  28580. var _this7 = _this6;
  28581. var tx = _this7.x + ey.x * halfHeight;
  28582. var ty = _this7.y + ey.y * halfHeight;
  28583. var tz = _this7.z + ey.z * halfHeight;
  28584. _this7.x = tx;
  28585. _this7.y = ty;
  28586. _this7.z = tz;
  28587. var top = _this7;
  28588. var _this8 = this.p;
  28589. var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3];
  28590. _this9.x = o.x;
  28591. _this9.y = o.y;
  28592. _this9.z = o.z;
  28593. var _this10 = _this9;
  28594. var s = -halfHeight;
  28595. var tx1 = _this10.x + ey.x * s;
  28596. var ty1 = _this10.y + ey.y * s;
  28597. var tz1 = _this10.z + ey.z * s;
  28598. _this10.x = tx1;
  28599. _this10.y = ty1;
  28600. _this10.z = tz1;
  28601. var bottom = _this10;
  28602. if(this.wireframe) {
  28603. var _this11 = this.p;
  28604. var _this12 = _this11.sizeVec3 == 0 ? new oimo.common.Vec3() : _this11.stackVec3[--_this11.sizeVec3];
  28605. _this12.x = bottom.x;
  28606. _this12.y = bottom.y;
  28607. _this12.z = bottom.z;
  28608. var _this13 = _this12;
  28609. var s1 = -radius;
  28610. var tx2 = _this13.x + ex.x * s1;
  28611. var ty2 = _this13.y + ex.y * s1;
  28612. var tz2 = _this13.z + ex.z * s1;
  28613. _this13.x = tx2;
  28614. _this13.y = ty2;
  28615. _this13.z = tz2;
  28616. var _this14 = _this13;
  28617. var tx3 = _this14.x + ez.x * 0;
  28618. var ty3 = _this14.y + ez.y * 0;
  28619. var tz3 = _this14.z + ez.z * 0;
  28620. _this14.x = tx3;
  28621. _this14.y = ty3;
  28622. _this14.z = tz3;
  28623. var bottom1 = _this14;
  28624. var _this15 = this.p;
  28625. var _this16 = _this15.sizeVec3 == 0 ? new oimo.common.Vec3() : _this15.stackVec3[--_this15.sizeVec3];
  28626. _this16.x = bottom.x;
  28627. _this16.y = bottom.y;
  28628. _this16.z = bottom.z;
  28629. var _this17 = _this16;
  28630. var tx4 = _this17.x + ex.x * radius;
  28631. var ty4 = _this17.y + ex.y * radius;
  28632. var tz4 = _this17.z + ex.z * radius;
  28633. _this17.x = tx4;
  28634. _this17.y = ty4;
  28635. _this17.z = tz4;
  28636. var _this18 = _this17;
  28637. var tx5 = _this18.x + ez.x * 0;
  28638. var ty5 = _this18.y + ez.y * 0;
  28639. var tz5 = _this18.z + ez.z * 0;
  28640. _this18.x = tx5;
  28641. _this18.y = ty5;
  28642. _this18.z = tz5;
  28643. var bottom2 = _this18;
  28644. var _this19 = this.p;
  28645. var _this20 = _this19.sizeVec3 == 0 ? new oimo.common.Vec3() : _this19.stackVec3[--_this19.sizeVec3];
  28646. _this20.x = bottom.x;
  28647. _this20.y = bottom.y;
  28648. _this20.z = bottom.z;
  28649. var _this21 = _this20;
  28650. var tx6 = _this21.x + ex.x * 0;
  28651. var ty6 = _this21.y + ex.y * 0;
  28652. var tz6 = _this21.z + ex.z * 0;
  28653. _this21.x = tx6;
  28654. _this21.y = ty6;
  28655. _this21.z = tz6;
  28656. var _this22 = _this21;
  28657. var s2 = -radius;
  28658. var tx7 = _this22.x + ez.x * s2;
  28659. var ty7 = _this22.y + ez.y * s2;
  28660. var tz7 = _this22.z + ez.z * s2;
  28661. _this22.x = tx7;
  28662. _this22.y = ty7;
  28663. _this22.z = tz7;
  28664. var bottom3 = _this22;
  28665. var _this23 = this.p;
  28666. var _this24 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3];
  28667. _this24.x = bottom.x;
  28668. _this24.y = bottom.y;
  28669. _this24.z = bottom.z;
  28670. var _this25 = _this24;
  28671. var tx8 = _this25.x + ex.x * 0;
  28672. var ty8 = _this25.y + ex.y * 0;
  28673. var tz8 = _this25.z + ex.z * 0;
  28674. _this25.x = tx8;
  28675. _this25.y = ty8;
  28676. _this25.z = tz8;
  28677. var _this26 = _this25;
  28678. var tx9 = _this26.x + ez.x * radius;
  28679. var ty9 = _this26.y + ez.y * radius;
  28680. var tz9 = _this26.z + ez.z * radius;
  28681. _this26.x = tx9;
  28682. _this26.y = ty9;
  28683. _this26.z = tz9;
  28684. var bottom4 = _this26;
  28685. this.ellipse(bottom,ex,ez,radius,radius,color);
  28686. this.line(top,bottom1,color);
  28687. this.line(top,bottom2,color);
  28688. this.line(top,bottom3,color);
  28689. this.line(top,bottom4,color);
  28690. var _this27 = this.p;
  28691. var mat3 = null;
  28692. var mat4 = null;
  28693. var quat = null;
  28694. if(bottom1 != null) {
  28695. bottom1.zero();
  28696. if(_this27.sizeVec3 == _this27.stackVec3.length) {
  28697. var newLength = _this27.sizeVec3 << 1;
  28698. var this1 = new Array(newLength);
  28699. var newArray = this1;
  28700. var _g = 0;
  28701. var _g1 = _this27.sizeVec3;
  28702. while(_g < _g1) {
  28703. var i = _g++;
  28704. newArray[i] = _this27.stackVec3[i];
  28705. _this27.stackVec3[i] = null;
  28706. }
  28707. _this27.stackVec3 = newArray;
  28708. }
  28709. _this27.stackVec3[_this27.sizeVec3++] = bottom1;
  28710. }
  28711. if(mat3 != null) {
  28712. var t00 = 1;
  28713. var t01 = 0;
  28714. var t02 = 0;
  28715. var t10 = 0;
  28716. var t11 = 1;
  28717. var t12 = 0;
  28718. var t20 = 0;
  28719. var t21 = 0;
  28720. var t22 = 1;
  28721. mat3.e00 = t00;
  28722. mat3.e01 = t01;
  28723. mat3.e02 = t02;
  28724. mat3.e10 = t10;
  28725. mat3.e11 = t11;
  28726. mat3.e12 = t12;
  28727. mat3.e20 = t20;
  28728. mat3.e21 = t21;
  28729. mat3.e22 = t22;
  28730. if(_this27.sizeMat3 == _this27.stackMat3.length) {
  28731. var newLength1 = _this27.sizeMat3 << 1;
  28732. var this2 = new Array(newLength1);
  28733. var newArray1 = this2;
  28734. var _g2 = 0;
  28735. var _g11 = _this27.sizeMat3;
  28736. while(_g2 < _g11) {
  28737. var i1 = _g2++;
  28738. newArray1[i1] = _this27.stackMat3[i1];
  28739. _this27.stackMat3[i1] = null;
  28740. }
  28741. _this27.stackMat3 = newArray1;
  28742. }
  28743. _this27.stackMat3[_this27.sizeMat3++] = mat3;
  28744. }
  28745. if(mat4 != null) {
  28746. var t001 = 1;
  28747. var t011 = 0;
  28748. var t021 = 0;
  28749. var t03 = 0;
  28750. var t101 = 0;
  28751. var t111 = 1;
  28752. var t121 = 0;
  28753. var t13 = 0;
  28754. var t201 = 0;
  28755. var t211 = 0;
  28756. var t221 = 1;
  28757. var t23 = 0;
  28758. var t30 = 0;
  28759. var t31 = 0;
  28760. var t32 = 0;
  28761. var t33 = 1;
  28762. mat4.e00 = t001;
  28763. mat4.e01 = t011;
  28764. mat4.e02 = t021;
  28765. mat4.e03 = t03;
  28766. mat4.e10 = t101;
  28767. mat4.e11 = t111;
  28768. mat4.e12 = t121;
  28769. mat4.e13 = t13;
  28770. mat4.e20 = t201;
  28771. mat4.e21 = t211;
  28772. mat4.e22 = t221;
  28773. mat4.e23 = t23;
  28774. mat4.e30 = t30;
  28775. mat4.e31 = t31;
  28776. mat4.e32 = t32;
  28777. mat4.e33 = t33;
  28778. if(_this27.sizeMat4 == _this27.stackMat4.length) {
  28779. var newLength2 = _this27.sizeMat4 << 1;
  28780. var this3 = new Array(newLength2);
  28781. var newArray2 = this3;
  28782. var _g3 = 0;
  28783. var _g12 = _this27.sizeMat4;
  28784. while(_g3 < _g12) {
  28785. var i2 = _g3++;
  28786. newArray2[i2] = _this27.stackMat4[i2];
  28787. _this27.stackMat4[i2] = null;
  28788. }
  28789. _this27.stackMat4 = newArray2;
  28790. }
  28791. _this27.stackMat4[_this27.sizeMat4++] = mat4;
  28792. }
  28793. if(quat != null) {
  28794. var tx10 = 0;
  28795. var ty10 = 0;
  28796. var tz10 = 0;
  28797. var tw = 1;
  28798. quat.x = tx10;
  28799. quat.y = ty10;
  28800. quat.z = tz10;
  28801. quat.w = tw;
  28802. if(_this27.sizeQuat == _this27.stackQuat.length) {
  28803. var newLength3 = _this27.sizeQuat << 1;
  28804. var this4 = new Array(newLength3);
  28805. var newArray3 = this4;
  28806. var _g4 = 0;
  28807. var _g13 = _this27.sizeQuat;
  28808. while(_g4 < _g13) {
  28809. var i3 = _g4++;
  28810. newArray3[i3] = _this27.stackQuat[i3];
  28811. _this27.stackQuat[i3] = null;
  28812. }
  28813. _this27.stackQuat = newArray3;
  28814. }
  28815. _this27.stackQuat[_this27.sizeQuat++] = quat;
  28816. }
  28817. var _this28 = this.p;
  28818. var mat31 = null;
  28819. var mat41 = null;
  28820. var quat1 = null;
  28821. if(bottom2 != null) {
  28822. bottom2.zero();
  28823. if(_this28.sizeVec3 == _this28.stackVec3.length) {
  28824. var newLength4 = _this28.sizeVec3 << 1;
  28825. var this5 = new Array(newLength4);
  28826. var newArray4 = this5;
  28827. var _g5 = 0;
  28828. var _g14 = _this28.sizeVec3;
  28829. while(_g5 < _g14) {
  28830. var i4 = _g5++;
  28831. newArray4[i4] = _this28.stackVec3[i4];
  28832. _this28.stackVec3[i4] = null;
  28833. }
  28834. _this28.stackVec3 = newArray4;
  28835. }
  28836. _this28.stackVec3[_this28.sizeVec3++] = bottom2;
  28837. }
  28838. if(mat31 != null) {
  28839. var t002 = 1;
  28840. var t012 = 0;
  28841. var t022 = 0;
  28842. var t102 = 0;
  28843. var t112 = 1;
  28844. var t122 = 0;
  28845. var t202 = 0;
  28846. var t212 = 0;
  28847. var t222 = 1;
  28848. mat31.e00 = t002;
  28849. mat31.e01 = t012;
  28850. mat31.e02 = t022;
  28851. mat31.e10 = t102;
  28852. mat31.e11 = t112;
  28853. mat31.e12 = t122;
  28854. mat31.e20 = t202;
  28855. mat31.e21 = t212;
  28856. mat31.e22 = t222;
  28857. if(_this28.sizeMat3 == _this28.stackMat3.length) {
  28858. var newLength5 = _this28.sizeMat3 << 1;
  28859. var this6 = new Array(newLength5);
  28860. var newArray5 = this6;
  28861. var _g6 = 0;
  28862. var _g15 = _this28.sizeMat3;
  28863. while(_g6 < _g15) {
  28864. var i5 = _g6++;
  28865. newArray5[i5] = _this28.stackMat3[i5];
  28866. _this28.stackMat3[i5] = null;
  28867. }
  28868. _this28.stackMat3 = newArray5;
  28869. }
  28870. _this28.stackMat3[_this28.sizeMat3++] = mat31;
  28871. }
  28872. if(mat41 != null) {
  28873. var t003 = 1;
  28874. var t013 = 0;
  28875. var t023 = 0;
  28876. var t031 = 0;
  28877. var t103 = 0;
  28878. var t113 = 1;
  28879. var t123 = 0;
  28880. var t131 = 0;
  28881. var t203 = 0;
  28882. var t213 = 0;
  28883. var t223 = 1;
  28884. var t231 = 0;
  28885. var t301 = 0;
  28886. var t311 = 0;
  28887. var t321 = 0;
  28888. var t331 = 1;
  28889. mat41.e00 = t003;
  28890. mat41.e01 = t013;
  28891. mat41.e02 = t023;
  28892. mat41.e03 = t031;
  28893. mat41.e10 = t103;
  28894. mat41.e11 = t113;
  28895. mat41.e12 = t123;
  28896. mat41.e13 = t131;
  28897. mat41.e20 = t203;
  28898. mat41.e21 = t213;
  28899. mat41.e22 = t223;
  28900. mat41.e23 = t231;
  28901. mat41.e30 = t301;
  28902. mat41.e31 = t311;
  28903. mat41.e32 = t321;
  28904. mat41.e33 = t331;
  28905. if(_this28.sizeMat4 == _this28.stackMat4.length) {
  28906. var newLength6 = _this28.sizeMat4 << 1;
  28907. var this7 = new Array(newLength6);
  28908. var newArray6 = this7;
  28909. var _g7 = 0;
  28910. var _g16 = _this28.sizeMat4;
  28911. while(_g7 < _g16) {
  28912. var i6 = _g7++;
  28913. newArray6[i6] = _this28.stackMat4[i6];
  28914. _this28.stackMat4[i6] = null;
  28915. }
  28916. _this28.stackMat4 = newArray6;
  28917. }
  28918. _this28.stackMat4[_this28.sizeMat4++] = mat41;
  28919. }
  28920. if(quat1 != null) {
  28921. var tx11 = 0;
  28922. var ty11 = 0;
  28923. var tz11 = 0;
  28924. var tw1 = 1;
  28925. quat1.x = tx11;
  28926. quat1.y = ty11;
  28927. quat1.z = tz11;
  28928. quat1.w = tw1;
  28929. if(_this28.sizeQuat == _this28.stackQuat.length) {
  28930. var newLength7 = _this28.sizeQuat << 1;
  28931. var this8 = new Array(newLength7);
  28932. var newArray7 = this8;
  28933. var _g8 = 0;
  28934. var _g17 = _this28.sizeQuat;
  28935. while(_g8 < _g17) {
  28936. var i7 = _g8++;
  28937. newArray7[i7] = _this28.stackQuat[i7];
  28938. _this28.stackQuat[i7] = null;
  28939. }
  28940. _this28.stackQuat = newArray7;
  28941. }
  28942. _this28.stackQuat[_this28.sizeQuat++] = quat1;
  28943. }
  28944. var _this29 = this.p;
  28945. var mat32 = null;
  28946. var mat42 = null;
  28947. var quat2 = null;
  28948. if(bottom3 != null) {
  28949. bottom3.zero();
  28950. if(_this29.sizeVec3 == _this29.stackVec3.length) {
  28951. var newLength8 = _this29.sizeVec3 << 1;
  28952. var this9 = new Array(newLength8);
  28953. var newArray8 = this9;
  28954. var _g9 = 0;
  28955. var _g18 = _this29.sizeVec3;
  28956. while(_g9 < _g18) {
  28957. var i8 = _g9++;
  28958. newArray8[i8] = _this29.stackVec3[i8];
  28959. _this29.stackVec3[i8] = null;
  28960. }
  28961. _this29.stackVec3 = newArray8;
  28962. }
  28963. _this29.stackVec3[_this29.sizeVec3++] = bottom3;
  28964. }
  28965. if(mat32 != null) {
  28966. var t004 = 1;
  28967. var t014 = 0;
  28968. var t024 = 0;
  28969. var t104 = 0;
  28970. var t114 = 1;
  28971. var t124 = 0;
  28972. var t204 = 0;
  28973. var t214 = 0;
  28974. var t224 = 1;
  28975. mat32.e00 = t004;
  28976. mat32.e01 = t014;
  28977. mat32.e02 = t024;
  28978. mat32.e10 = t104;
  28979. mat32.e11 = t114;
  28980. mat32.e12 = t124;
  28981. mat32.e20 = t204;
  28982. mat32.e21 = t214;
  28983. mat32.e22 = t224;
  28984. if(_this29.sizeMat3 == _this29.stackMat3.length) {
  28985. var newLength9 = _this29.sizeMat3 << 1;
  28986. var this10 = new Array(newLength9);
  28987. var newArray9 = this10;
  28988. var _g10 = 0;
  28989. var _g19 = _this29.sizeMat3;
  28990. while(_g10 < _g19) {
  28991. var i9 = _g10++;
  28992. newArray9[i9] = _this29.stackMat3[i9];
  28993. _this29.stackMat3[i9] = null;
  28994. }
  28995. _this29.stackMat3 = newArray9;
  28996. }
  28997. _this29.stackMat3[_this29.sizeMat3++] = mat32;
  28998. }
  28999. if(mat42 != null) {
  29000. var t005 = 1;
  29001. var t015 = 0;
  29002. var t025 = 0;
  29003. var t032 = 0;
  29004. var t105 = 0;
  29005. var t115 = 1;
  29006. var t125 = 0;
  29007. var t132 = 0;
  29008. var t205 = 0;
  29009. var t215 = 0;
  29010. var t225 = 1;
  29011. var t232 = 0;
  29012. var t302 = 0;
  29013. var t312 = 0;
  29014. var t322 = 0;
  29015. var t332 = 1;
  29016. mat42.e00 = t005;
  29017. mat42.e01 = t015;
  29018. mat42.e02 = t025;
  29019. mat42.e03 = t032;
  29020. mat42.e10 = t105;
  29021. mat42.e11 = t115;
  29022. mat42.e12 = t125;
  29023. mat42.e13 = t132;
  29024. mat42.e20 = t205;
  29025. mat42.e21 = t215;
  29026. mat42.e22 = t225;
  29027. mat42.e23 = t232;
  29028. mat42.e30 = t302;
  29029. mat42.e31 = t312;
  29030. mat42.e32 = t322;
  29031. mat42.e33 = t332;
  29032. if(_this29.sizeMat4 == _this29.stackMat4.length) {
  29033. var newLength10 = _this29.sizeMat4 << 1;
  29034. var this11 = new Array(newLength10);
  29035. var newArray10 = this11;
  29036. var _g20 = 0;
  29037. var _g110 = _this29.sizeMat4;
  29038. while(_g20 < _g110) {
  29039. var i10 = _g20++;
  29040. newArray10[i10] = _this29.stackMat4[i10];
  29041. _this29.stackMat4[i10] = null;
  29042. }
  29043. _this29.stackMat4 = newArray10;
  29044. }
  29045. _this29.stackMat4[_this29.sizeMat4++] = mat42;
  29046. }
  29047. if(quat2 != null) {
  29048. var tx12 = 0;
  29049. var ty12 = 0;
  29050. var tz12 = 0;
  29051. var tw2 = 1;
  29052. quat2.x = tx12;
  29053. quat2.y = ty12;
  29054. quat2.z = tz12;
  29055. quat2.w = tw2;
  29056. if(_this29.sizeQuat == _this29.stackQuat.length) {
  29057. var newLength11 = _this29.sizeQuat << 1;
  29058. var this12 = new Array(newLength11);
  29059. var newArray11 = this12;
  29060. var _g21 = 0;
  29061. var _g111 = _this29.sizeQuat;
  29062. while(_g21 < _g111) {
  29063. var i11 = _g21++;
  29064. newArray11[i11] = _this29.stackQuat[i11];
  29065. _this29.stackQuat[i11] = null;
  29066. }
  29067. _this29.stackQuat = newArray11;
  29068. }
  29069. _this29.stackQuat[_this29.sizeQuat++] = quat2;
  29070. }
  29071. var _this30 = this.p;
  29072. var mat33 = null;
  29073. var mat43 = null;
  29074. var quat3 = null;
  29075. if(bottom4 != null) {
  29076. bottom4.zero();
  29077. if(_this30.sizeVec3 == _this30.stackVec3.length) {
  29078. var newLength12 = _this30.sizeVec3 << 1;
  29079. var this13 = new Array(newLength12);
  29080. var newArray12 = this13;
  29081. var _g22 = 0;
  29082. var _g112 = _this30.sizeVec3;
  29083. while(_g22 < _g112) {
  29084. var i12 = _g22++;
  29085. newArray12[i12] = _this30.stackVec3[i12];
  29086. _this30.stackVec3[i12] = null;
  29087. }
  29088. _this30.stackVec3 = newArray12;
  29089. }
  29090. _this30.stackVec3[_this30.sizeVec3++] = bottom4;
  29091. }
  29092. if(mat33 != null) {
  29093. var t006 = 1;
  29094. var t016 = 0;
  29095. var t026 = 0;
  29096. var t106 = 0;
  29097. var t116 = 1;
  29098. var t126 = 0;
  29099. var t206 = 0;
  29100. var t216 = 0;
  29101. var t226 = 1;
  29102. mat33.e00 = t006;
  29103. mat33.e01 = t016;
  29104. mat33.e02 = t026;
  29105. mat33.e10 = t106;
  29106. mat33.e11 = t116;
  29107. mat33.e12 = t126;
  29108. mat33.e20 = t206;
  29109. mat33.e21 = t216;
  29110. mat33.e22 = t226;
  29111. if(_this30.sizeMat3 == _this30.stackMat3.length) {
  29112. var newLength13 = _this30.sizeMat3 << 1;
  29113. var this14 = new Array(newLength13);
  29114. var newArray13 = this14;
  29115. var _g23 = 0;
  29116. var _g113 = _this30.sizeMat3;
  29117. while(_g23 < _g113) {
  29118. var i13 = _g23++;
  29119. newArray13[i13] = _this30.stackMat3[i13];
  29120. _this30.stackMat3[i13] = null;
  29121. }
  29122. _this30.stackMat3 = newArray13;
  29123. }
  29124. _this30.stackMat3[_this30.sizeMat3++] = mat33;
  29125. }
  29126. if(mat43 != null) {
  29127. var t007 = 1;
  29128. var t017 = 0;
  29129. var t027 = 0;
  29130. var t033 = 0;
  29131. var t107 = 0;
  29132. var t117 = 1;
  29133. var t127 = 0;
  29134. var t133 = 0;
  29135. var t207 = 0;
  29136. var t217 = 0;
  29137. var t227 = 1;
  29138. var t233 = 0;
  29139. var t303 = 0;
  29140. var t313 = 0;
  29141. var t323 = 0;
  29142. var t333 = 1;
  29143. mat43.e00 = t007;
  29144. mat43.e01 = t017;
  29145. mat43.e02 = t027;
  29146. mat43.e03 = t033;
  29147. mat43.e10 = t107;
  29148. mat43.e11 = t117;
  29149. mat43.e12 = t127;
  29150. mat43.e13 = t133;
  29151. mat43.e20 = t207;
  29152. mat43.e21 = t217;
  29153. mat43.e22 = t227;
  29154. mat43.e23 = t233;
  29155. mat43.e30 = t303;
  29156. mat43.e31 = t313;
  29157. mat43.e32 = t323;
  29158. mat43.e33 = t333;
  29159. if(_this30.sizeMat4 == _this30.stackMat4.length) {
  29160. var newLength14 = _this30.sizeMat4 << 1;
  29161. var this15 = new Array(newLength14);
  29162. var newArray14 = this15;
  29163. var _g24 = 0;
  29164. var _g114 = _this30.sizeMat4;
  29165. while(_g24 < _g114) {
  29166. var i14 = _g24++;
  29167. newArray14[i14] = _this30.stackMat4[i14];
  29168. _this30.stackMat4[i14] = null;
  29169. }
  29170. _this30.stackMat4 = newArray14;
  29171. }
  29172. _this30.stackMat4[_this30.sizeMat4++] = mat43;
  29173. }
  29174. if(quat3 != null) {
  29175. var tx13 = 0;
  29176. var ty13 = 0;
  29177. var tz13 = 0;
  29178. var tw3 = 1;
  29179. quat3.x = tx13;
  29180. quat3.y = ty13;
  29181. quat3.z = tz13;
  29182. quat3.w = tw3;
  29183. if(_this30.sizeQuat == _this30.stackQuat.length) {
  29184. var newLength15 = _this30.sizeQuat << 1;
  29185. var this16 = new Array(newLength15);
  29186. var newArray15 = this16;
  29187. var _g25 = 0;
  29188. var _g115 = _this30.sizeQuat;
  29189. while(_g25 < _g115) {
  29190. var i15 = _g25++;
  29191. newArray15[i15] = _this30.stackQuat[i15];
  29192. _this30.stackQuat[i15] = null;
  29193. }
  29194. _this30.stackQuat = newArray15;
  29195. }
  29196. _this30.stackQuat[_this30.sizeQuat++] = quat3;
  29197. }
  29198. } else {
  29199. var invDenom = 1 / Math.sqrt(radius * radius + 4 * halfHeight * halfHeight);
  29200. var cos = 2 * halfHeight * invDenom;
  29201. var sin = radius * invDenom;
  29202. var invDenom2 = 1 / Math.sqrt(2 * (1 + cos));
  29203. var _g26 = 0;
  29204. while(_g26 < 8) {
  29205. var i16 = _g26++;
  29206. var _this31 = this.tmpCircleNorms[i16];
  29207. var v1 = this.circleCoords[i16];
  29208. _this31.x = v1.x;
  29209. _this31.y = v1.y;
  29210. _this31.z = v1.z;
  29211. var _this32 = _this31;
  29212. var tx14 = _this32.x * cos;
  29213. var ty14 = _this32.y * cos;
  29214. var tz14 = _this32.z * cos;
  29215. _this32.x = tx14;
  29216. _this32.y = ty14;
  29217. _this32.z = tz14;
  29218. _this32.y += sin;
  29219. var _this33 = this.tmpCircleNorms[i16];
  29220. var tx15 = _this33.x * m.e00 + _this33.y * m.e01 + _this33.z * m.e02;
  29221. var ty15 = _this33.x * m.e10 + _this33.y * m.e11 + _this33.z * m.e12;
  29222. var tz15 = _this33.x * m.e20 + _this33.y * m.e21 + _this33.z * m.e22;
  29223. _this33.x = tx15;
  29224. _this33.y = ty15;
  29225. _this33.z = tz15;
  29226. var _this34 = this.tmpCircleVerts1[i16];
  29227. var v2 = this.circleCoordsShift[i16];
  29228. _this34.x = v2.x;
  29229. _this34.y = v2.y;
  29230. _this34.z = v2.z;
  29231. var _this35 = _this34;
  29232. var tx16 = _this35.x * cos;
  29233. var ty16 = _this35.y * cos;
  29234. var tz16 = _this35.z * cos;
  29235. _this35.x = tx16;
  29236. _this35.y = ty16;
  29237. _this35.z = tz16;
  29238. _this35.y += sin;
  29239. var _this36 = this.tmpCircleVerts1[i16];
  29240. var tx17 = _this36.x * m.e00 + _this36.y * m.e01 + _this36.z * m.e02;
  29241. var ty17 = _this36.x * m.e10 + _this36.y * m.e11 + _this36.z * m.e12;
  29242. var tz17 = _this36.x * m.e20 + _this36.y * m.e21 + _this36.z * m.e22;
  29243. _this36.x = tx17;
  29244. _this36.y = ty17;
  29245. _this36.z = tz17;
  29246. var _this37 = this.tmpCircleVerts2[i16];
  29247. var v3 = this.circleCoords[i16];
  29248. _this37.x = v3.x;
  29249. _this37.y = v3.y;
  29250. _this37.z = v3.z;
  29251. var _this38 = _this37;
  29252. var tx18 = _this38.x * m.e00 + _this38.y * m.e01 + _this38.z * m.e02;
  29253. var ty18 = _this38.x * m.e10 + _this38.y * m.e11 + _this38.z * m.e12;
  29254. var tz18 = _this38.x * m.e20 + _this38.y * m.e21 + _this38.z * m.e22;
  29255. _this38.x = tx18;
  29256. _this38.y = ty18;
  29257. _this38.z = tz18;
  29258. var _this39 = _this38;
  29259. var tx19 = _this39.x * radius;
  29260. var ty19 = _this39.y * radius;
  29261. var tz19 = _this39.z * radius;
  29262. _this39.x = tx19;
  29263. _this39.y = ty19;
  29264. _this39.z = tz19;
  29265. var _this40 = _this39;
  29266. var tx20 = _this40.x + o.x;
  29267. var ty20 = _this40.y + o.y;
  29268. var tz20 = _this40.z + o.z;
  29269. _this40.x = tx20;
  29270. _this40.y = ty20;
  29271. _this40.z = tz20;
  29272. var _this41 = this.tmpCircleVerts2[i16];
  29273. var s3 = -halfHeight;
  29274. var tx21 = _this41.x + ey.x * s3;
  29275. var ty21 = _this41.y + ey.y * s3;
  29276. var tz21 = _this41.z + ey.z * s3;
  29277. _this41.x = tx21;
  29278. _this41.y = ty21;
  29279. _this41.z = tz21;
  29280. }
  29281. var _g116 = 0;
  29282. while(_g116 < 8) {
  29283. var i17 = _g116++;
  29284. var v11 = top;
  29285. var v21 = this.tmpCircleVerts2[i17];
  29286. var v31 = this.tmpCircleVerts2[(i17 + 1) % 8];
  29287. var n1 = this.tmpCircleVerts1[i17];
  29288. var n2 = this.tmpCircleNorms[i17];
  29289. var n3 = this.tmpCircleNorms[(i17 + 1) % 8];
  29290. this.triangle(v11,v21,v31,n1,n2,n3,color);
  29291. v11 = bottom;
  29292. v21 = this.tmpCircleVerts2[(i17 + 1) % 8];
  29293. v31 = this.tmpCircleVerts2[i17];
  29294. var _this42 = this.p;
  29295. var _this43 = _this42.sizeVec3 == 0 ? new oimo.common.Vec3() : _this42.stackVec3[--_this42.sizeVec3];
  29296. _this43.x = ey.x;
  29297. _this43.y = ey.y;
  29298. _this43.z = ey.z;
  29299. var _this44 = _this43;
  29300. var tx22 = -_this44.x;
  29301. var ty22 = -_this44.y;
  29302. var tz22 = -_this44.z;
  29303. _this44.x = tx22;
  29304. _this44.y = ty22;
  29305. _this44.z = tz22;
  29306. n1 = _this44;
  29307. this.triangle(v11,v21,v31,n1,n1,n1,color);
  29308. var _this45 = this.p;
  29309. var mat34 = null;
  29310. var mat44 = null;
  29311. var quat4 = null;
  29312. if(n1 != null) {
  29313. n1.zero();
  29314. if(_this45.sizeVec3 == _this45.stackVec3.length) {
  29315. var newLength16 = _this45.sizeVec3 << 1;
  29316. var this17 = new Array(newLength16);
  29317. var newArray16 = this17;
  29318. var _g27 = 0;
  29319. var _g117 = _this45.sizeVec3;
  29320. while(_g27 < _g117) {
  29321. var i18 = _g27++;
  29322. newArray16[i18] = _this45.stackVec3[i18];
  29323. _this45.stackVec3[i18] = null;
  29324. }
  29325. _this45.stackVec3 = newArray16;
  29326. }
  29327. _this45.stackVec3[_this45.sizeVec3++] = n1;
  29328. }
  29329. if(mat34 != null) {
  29330. var t008 = 1;
  29331. var t018 = 0;
  29332. var t028 = 0;
  29333. var t108 = 0;
  29334. var t118 = 1;
  29335. var t128 = 0;
  29336. var t208 = 0;
  29337. var t218 = 0;
  29338. var t228 = 1;
  29339. mat34.e00 = t008;
  29340. mat34.e01 = t018;
  29341. mat34.e02 = t028;
  29342. mat34.e10 = t108;
  29343. mat34.e11 = t118;
  29344. mat34.e12 = t128;
  29345. mat34.e20 = t208;
  29346. mat34.e21 = t218;
  29347. mat34.e22 = t228;
  29348. if(_this45.sizeMat3 == _this45.stackMat3.length) {
  29349. var newLength17 = _this45.sizeMat3 << 1;
  29350. var this18 = new Array(newLength17);
  29351. var newArray17 = this18;
  29352. var _g28 = 0;
  29353. var _g118 = _this45.sizeMat3;
  29354. while(_g28 < _g118) {
  29355. var i19 = _g28++;
  29356. newArray17[i19] = _this45.stackMat3[i19];
  29357. _this45.stackMat3[i19] = null;
  29358. }
  29359. _this45.stackMat3 = newArray17;
  29360. }
  29361. _this45.stackMat3[_this45.sizeMat3++] = mat34;
  29362. }
  29363. if(mat44 != null) {
  29364. var t009 = 1;
  29365. var t019 = 0;
  29366. var t029 = 0;
  29367. var t034 = 0;
  29368. var t109 = 0;
  29369. var t119 = 1;
  29370. var t129 = 0;
  29371. var t134 = 0;
  29372. var t209 = 0;
  29373. var t219 = 0;
  29374. var t229 = 1;
  29375. var t234 = 0;
  29376. var t304 = 0;
  29377. var t314 = 0;
  29378. var t324 = 0;
  29379. var t334 = 1;
  29380. mat44.e00 = t009;
  29381. mat44.e01 = t019;
  29382. mat44.e02 = t029;
  29383. mat44.e03 = t034;
  29384. mat44.e10 = t109;
  29385. mat44.e11 = t119;
  29386. mat44.e12 = t129;
  29387. mat44.e13 = t134;
  29388. mat44.e20 = t209;
  29389. mat44.e21 = t219;
  29390. mat44.e22 = t229;
  29391. mat44.e23 = t234;
  29392. mat44.e30 = t304;
  29393. mat44.e31 = t314;
  29394. mat44.e32 = t324;
  29395. mat44.e33 = t334;
  29396. if(_this45.sizeMat4 == _this45.stackMat4.length) {
  29397. var newLength18 = _this45.sizeMat4 << 1;
  29398. var this19 = new Array(newLength18);
  29399. var newArray18 = this19;
  29400. var _g29 = 0;
  29401. var _g119 = _this45.sizeMat4;
  29402. while(_g29 < _g119) {
  29403. var i20 = _g29++;
  29404. newArray18[i20] = _this45.stackMat4[i20];
  29405. _this45.stackMat4[i20] = null;
  29406. }
  29407. _this45.stackMat4 = newArray18;
  29408. }
  29409. _this45.stackMat4[_this45.sizeMat4++] = mat44;
  29410. }
  29411. if(quat4 != null) {
  29412. var tx23 = 0;
  29413. var ty23 = 0;
  29414. var tz23 = 0;
  29415. var tw4 = 1;
  29416. quat4.x = tx23;
  29417. quat4.y = ty23;
  29418. quat4.z = tz23;
  29419. quat4.w = tw4;
  29420. if(_this45.sizeQuat == _this45.stackQuat.length) {
  29421. var newLength19 = _this45.sizeQuat << 1;
  29422. var this20 = new Array(newLength19);
  29423. var newArray19 = this20;
  29424. var _g30 = 0;
  29425. var _g120 = _this45.sizeQuat;
  29426. while(_g30 < _g120) {
  29427. var i21 = _g30++;
  29428. newArray19[i21] = _this45.stackQuat[i21];
  29429. _this45.stackQuat[i21] = null;
  29430. }
  29431. _this45.stackQuat = newArray19;
  29432. }
  29433. _this45.stackQuat[_this45.sizeQuat++] = quat4;
  29434. }
  29435. }
  29436. }
  29437. var _this46 = this.p;
  29438. var mat35 = null;
  29439. var mat45 = null;
  29440. var quat5 = null;
  29441. if(top != null) {
  29442. top.zero();
  29443. if(_this46.sizeVec3 == _this46.stackVec3.length) {
  29444. var newLength20 = _this46.sizeVec3 << 1;
  29445. var this21 = new Array(newLength20);
  29446. var newArray20 = this21;
  29447. var _g31 = 0;
  29448. var _g121 = _this46.sizeVec3;
  29449. while(_g31 < _g121) {
  29450. var i22 = _g31++;
  29451. newArray20[i22] = _this46.stackVec3[i22];
  29452. _this46.stackVec3[i22] = null;
  29453. }
  29454. _this46.stackVec3 = newArray20;
  29455. }
  29456. _this46.stackVec3[_this46.sizeVec3++] = top;
  29457. }
  29458. if(mat35 != null) {
  29459. var t0010 = 1;
  29460. var t0110 = 0;
  29461. var t0210 = 0;
  29462. var t1010 = 0;
  29463. var t1110 = 1;
  29464. var t1210 = 0;
  29465. var t2010 = 0;
  29466. var t2110 = 0;
  29467. var t2210 = 1;
  29468. mat35.e00 = t0010;
  29469. mat35.e01 = t0110;
  29470. mat35.e02 = t0210;
  29471. mat35.e10 = t1010;
  29472. mat35.e11 = t1110;
  29473. mat35.e12 = t1210;
  29474. mat35.e20 = t2010;
  29475. mat35.e21 = t2110;
  29476. mat35.e22 = t2210;
  29477. if(_this46.sizeMat3 == _this46.stackMat3.length) {
  29478. var newLength21 = _this46.sizeMat3 << 1;
  29479. var this22 = new Array(newLength21);
  29480. var newArray21 = this22;
  29481. var _g32 = 0;
  29482. var _g122 = _this46.sizeMat3;
  29483. while(_g32 < _g122) {
  29484. var i23 = _g32++;
  29485. newArray21[i23] = _this46.stackMat3[i23];
  29486. _this46.stackMat3[i23] = null;
  29487. }
  29488. _this46.stackMat3 = newArray21;
  29489. }
  29490. _this46.stackMat3[_this46.sizeMat3++] = mat35;
  29491. }
  29492. if(mat45 != null) {
  29493. var t0011 = 1;
  29494. var t0111 = 0;
  29495. var t0211 = 0;
  29496. var t035 = 0;
  29497. var t1011 = 0;
  29498. var t1111 = 1;
  29499. var t1211 = 0;
  29500. var t135 = 0;
  29501. var t2011 = 0;
  29502. var t2111 = 0;
  29503. var t2211 = 1;
  29504. var t235 = 0;
  29505. var t305 = 0;
  29506. var t315 = 0;
  29507. var t325 = 0;
  29508. var t335 = 1;
  29509. mat45.e00 = t0011;
  29510. mat45.e01 = t0111;
  29511. mat45.e02 = t0211;
  29512. mat45.e03 = t035;
  29513. mat45.e10 = t1011;
  29514. mat45.e11 = t1111;
  29515. mat45.e12 = t1211;
  29516. mat45.e13 = t135;
  29517. mat45.e20 = t2011;
  29518. mat45.e21 = t2111;
  29519. mat45.e22 = t2211;
  29520. mat45.e23 = t235;
  29521. mat45.e30 = t305;
  29522. mat45.e31 = t315;
  29523. mat45.e32 = t325;
  29524. mat45.e33 = t335;
  29525. if(_this46.sizeMat4 == _this46.stackMat4.length) {
  29526. var newLength22 = _this46.sizeMat4 << 1;
  29527. var this23 = new Array(newLength22);
  29528. var newArray22 = this23;
  29529. var _g33 = 0;
  29530. var _g123 = _this46.sizeMat4;
  29531. while(_g33 < _g123) {
  29532. var i24 = _g33++;
  29533. newArray22[i24] = _this46.stackMat4[i24];
  29534. _this46.stackMat4[i24] = null;
  29535. }
  29536. _this46.stackMat4 = newArray22;
  29537. }
  29538. _this46.stackMat4[_this46.sizeMat4++] = mat45;
  29539. }
  29540. if(quat5 != null) {
  29541. var tx24 = 0;
  29542. var ty24 = 0;
  29543. var tz24 = 0;
  29544. var tw5 = 1;
  29545. quat5.x = tx24;
  29546. quat5.y = ty24;
  29547. quat5.z = tz24;
  29548. quat5.w = tw5;
  29549. if(_this46.sizeQuat == _this46.stackQuat.length) {
  29550. var newLength23 = _this46.sizeQuat << 1;
  29551. var this24 = new Array(newLength23);
  29552. var newArray23 = this24;
  29553. var _g34 = 0;
  29554. var _g124 = _this46.sizeQuat;
  29555. while(_g34 < _g124) {
  29556. var i25 = _g34++;
  29557. newArray23[i25] = _this46.stackQuat[i25];
  29558. _this46.stackQuat[i25] = null;
  29559. }
  29560. _this46.stackQuat = newArray23;
  29561. }
  29562. _this46.stackQuat[_this46.sizeQuat++] = quat5;
  29563. }
  29564. var _this47 = this.p;
  29565. var mat36 = null;
  29566. var mat46 = null;
  29567. var quat6 = null;
  29568. if(bottom != null) {
  29569. bottom.zero();
  29570. if(_this47.sizeVec3 == _this47.stackVec3.length) {
  29571. var newLength24 = _this47.sizeVec3 << 1;
  29572. var this25 = new Array(newLength24);
  29573. var newArray24 = this25;
  29574. var _g35 = 0;
  29575. var _g125 = _this47.sizeVec3;
  29576. while(_g35 < _g125) {
  29577. var i26 = _g35++;
  29578. newArray24[i26] = _this47.stackVec3[i26];
  29579. _this47.stackVec3[i26] = null;
  29580. }
  29581. _this47.stackVec3 = newArray24;
  29582. }
  29583. _this47.stackVec3[_this47.sizeVec3++] = bottom;
  29584. }
  29585. if(mat36 != null) {
  29586. var t0012 = 1;
  29587. var t0112 = 0;
  29588. var t0212 = 0;
  29589. var t1012 = 0;
  29590. var t1112 = 1;
  29591. var t1212 = 0;
  29592. var t2012 = 0;
  29593. var t2112 = 0;
  29594. var t2212 = 1;
  29595. mat36.e00 = t0012;
  29596. mat36.e01 = t0112;
  29597. mat36.e02 = t0212;
  29598. mat36.e10 = t1012;
  29599. mat36.e11 = t1112;
  29600. mat36.e12 = t1212;
  29601. mat36.e20 = t2012;
  29602. mat36.e21 = t2112;
  29603. mat36.e22 = t2212;
  29604. if(_this47.sizeMat3 == _this47.stackMat3.length) {
  29605. var newLength25 = _this47.sizeMat3 << 1;
  29606. var this26 = new Array(newLength25);
  29607. var newArray25 = this26;
  29608. var _g36 = 0;
  29609. var _g126 = _this47.sizeMat3;
  29610. while(_g36 < _g126) {
  29611. var i27 = _g36++;
  29612. newArray25[i27] = _this47.stackMat3[i27];
  29613. _this47.stackMat3[i27] = null;
  29614. }
  29615. _this47.stackMat3 = newArray25;
  29616. }
  29617. _this47.stackMat3[_this47.sizeMat3++] = mat36;
  29618. }
  29619. if(mat46 != null) {
  29620. var t0013 = 1;
  29621. var t0113 = 0;
  29622. var t0213 = 0;
  29623. var t036 = 0;
  29624. var t1013 = 0;
  29625. var t1113 = 1;
  29626. var t1213 = 0;
  29627. var t136 = 0;
  29628. var t2013 = 0;
  29629. var t2113 = 0;
  29630. var t2213 = 1;
  29631. var t236 = 0;
  29632. var t306 = 0;
  29633. var t316 = 0;
  29634. var t326 = 0;
  29635. var t336 = 1;
  29636. mat46.e00 = t0013;
  29637. mat46.e01 = t0113;
  29638. mat46.e02 = t0213;
  29639. mat46.e03 = t036;
  29640. mat46.e10 = t1013;
  29641. mat46.e11 = t1113;
  29642. mat46.e12 = t1213;
  29643. mat46.e13 = t136;
  29644. mat46.e20 = t2013;
  29645. mat46.e21 = t2113;
  29646. mat46.e22 = t2213;
  29647. mat46.e23 = t236;
  29648. mat46.e30 = t306;
  29649. mat46.e31 = t316;
  29650. mat46.e32 = t326;
  29651. mat46.e33 = t336;
  29652. if(_this47.sizeMat4 == _this47.stackMat4.length) {
  29653. var newLength26 = _this47.sizeMat4 << 1;
  29654. var this27 = new Array(newLength26);
  29655. var newArray26 = this27;
  29656. var _g37 = 0;
  29657. var _g127 = _this47.sizeMat4;
  29658. while(_g37 < _g127) {
  29659. var i28 = _g37++;
  29660. newArray26[i28] = _this47.stackMat4[i28];
  29661. _this47.stackMat4[i28] = null;
  29662. }
  29663. _this47.stackMat4 = newArray26;
  29664. }
  29665. _this47.stackMat4[_this47.sizeMat4++] = mat46;
  29666. }
  29667. if(quat6 != null) {
  29668. var tx25 = 0;
  29669. var ty25 = 0;
  29670. var tz25 = 0;
  29671. var tw6 = 1;
  29672. quat6.x = tx25;
  29673. quat6.y = ty25;
  29674. quat6.z = tz25;
  29675. quat6.w = tw6;
  29676. if(_this47.sizeQuat == _this47.stackQuat.length) {
  29677. var newLength27 = _this47.sizeQuat << 1;
  29678. var this28 = new Array(newLength27);
  29679. var newArray27 = this28;
  29680. var _g38 = 0;
  29681. var _g128 = _this47.sizeQuat;
  29682. while(_g38 < _g128) {
  29683. var i29 = _g38++;
  29684. newArray27[i29] = _this47.stackQuat[i29];
  29685. _this47.stackQuat[i29] = null;
  29686. }
  29687. _this47.stackQuat = newArray27;
  29688. }
  29689. _this47.stackQuat[_this47.sizeQuat++] = quat6;
  29690. }
  29691. var _this48 = this.p;
  29692. var mat37 = null;
  29693. var mat47 = null;
  29694. var quat7 = null;
  29695. if(o != null) {
  29696. o.zero();
  29697. if(_this48.sizeVec3 == _this48.stackVec3.length) {
  29698. var newLength28 = _this48.sizeVec3 << 1;
  29699. var this29 = new Array(newLength28);
  29700. var newArray28 = this29;
  29701. var _g39 = 0;
  29702. var _g129 = _this48.sizeVec3;
  29703. while(_g39 < _g129) {
  29704. var i30 = _g39++;
  29705. newArray28[i30] = _this48.stackVec3[i30];
  29706. _this48.stackVec3[i30] = null;
  29707. }
  29708. _this48.stackVec3 = newArray28;
  29709. }
  29710. _this48.stackVec3[_this48.sizeVec3++] = o;
  29711. }
  29712. if(mat37 != null) {
  29713. var t0014 = 1;
  29714. var t0114 = 0;
  29715. var t0214 = 0;
  29716. var t1014 = 0;
  29717. var t1114 = 1;
  29718. var t1214 = 0;
  29719. var t2014 = 0;
  29720. var t2114 = 0;
  29721. var t2214 = 1;
  29722. mat37.e00 = t0014;
  29723. mat37.e01 = t0114;
  29724. mat37.e02 = t0214;
  29725. mat37.e10 = t1014;
  29726. mat37.e11 = t1114;
  29727. mat37.e12 = t1214;
  29728. mat37.e20 = t2014;
  29729. mat37.e21 = t2114;
  29730. mat37.e22 = t2214;
  29731. if(_this48.sizeMat3 == _this48.stackMat3.length) {
  29732. var newLength29 = _this48.sizeMat3 << 1;
  29733. var this30 = new Array(newLength29);
  29734. var newArray29 = this30;
  29735. var _g40 = 0;
  29736. var _g130 = _this48.sizeMat3;
  29737. while(_g40 < _g130) {
  29738. var i31 = _g40++;
  29739. newArray29[i31] = _this48.stackMat3[i31];
  29740. _this48.stackMat3[i31] = null;
  29741. }
  29742. _this48.stackMat3 = newArray29;
  29743. }
  29744. _this48.stackMat3[_this48.sizeMat3++] = mat37;
  29745. }
  29746. if(mat47 != null) {
  29747. var t0015 = 1;
  29748. var t0115 = 0;
  29749. var t0215 = 0;
  29750. var t037 = 0;
  29751. var t1015 = 0;
  29752. var t1115 = 1;
  29753. var t1215 = 0;
  29754. var t137 = 0;
  29755. var t2015 = 0;
  29756. var t2115 = 0;
  29757. var t2215 = 1;
  29758. var t237 = 0;
  29759. var t307 = 0;
  29760. var t317 = 0;
  29761. var t327 = 0;
  29762. var t337 = 1;
  29763. mat47.e00 = t0015;
  29764. mat47.e01 = t0115;
  29765. mat47.e02 = t0215;
  29766. mat47.e03 = t037;
  29767. mat47.e10 = t1015;
  29768. mat47.e11 = t1115;
  29769. mat47.e12 = t1215;
  29770. mat47.e13 = t137;
  29771. mat47.e20 = t2015;
  29772. mat47.e21 = t2115;
  29773. mat47.e22 = t2215;
  29774. mat47.e23 = t237;
  29775. mat47.e30 = t307;
  29776. mat47.e31 = t317;
  29777. mat47.e32 = t327;
  29778. mat47.e33 = t337;
  29779. if(_this48.sizeMat4 == _this48.stackMat4.length) {
  29780. var newLength30 = _this48.sizeMat4 << 1;
  29781. var this31 = new Array(newLength30);
  29782. var newArray30 = this31;
  29783. var _g41 = 0;
  29784. var _g131 = _this48.sizeMat4;
  29785. while(_g41 < _g131) {
  29786. var i32 = _g41++;
  29787. newArray30[i32] = _this48.stackMat4[i32];
  29788. _this48.stackMat4[i32] = null;
  29789. }
  29790. _this48.stackMat4 = newArray30;
  29791. }
  29792. _this48.stackMat4[_this48.sizeMat4++] = mat47;
  29793. }
  29794. if(quat7 != null) {
  29795. var tx26 = 0;
  29796. var ty26 = 0;
  29797. var tz26 = 0;
  29798. var tw7 = 1;
  29799. quat7.x = tx26;
  29800. quat7.y = ty26;
  29801. quat7.z = tz26;
  29802. quat7.w = tw7;
  29803. if(_this48.sizeQuat == _this48.stackQuat.length) {
  29804. var newLength31 = _this48.sizeQuat << 1;
  29805. var this32 = new Array(newLength31);
  29806. var newArray31 = this32;
  29807. var _g42 = 0;
  29808. var _g132 = _this48.sizeQuat;
  29809. while(_g42 < _g132) {
  29810. var i33 = _g42++;
  29811. newArray31[i33] = _this48.stackQuat[i33];
  29812. _this48.stackQuat[i33] = null;
  29813. }
  29814. _this48.stackQuat = newArray31;
  29815. }
  29816. _this48.stackQuat[_this48.sizeQuat++] = quat7;
  29817. }
  29818. var _this49 = this.p;
  29819. var vec3 = null;
  29820. var mat48 = null;
  29821. var quat8 = null;
  29822. if(vec3 != null) {
  29823. vec3.zero();
  29824. if(_this49.sizeVec3 == _this49.stackVec3.length) {
  29825. var newLength32 = _this49.sizeVec3 << 1;
  29826. var this33 = new Array(newLength32);
  29827. var newArray32 = this33;
  29828. var _g43 = 0;
  29829. var _g133 = _this49.sizeVec3;
  29830. while(_g43 < _g133) {
  29831. var i34 = _g43++;
  29832. newArray32[i34] = _this49.stackVec3[i34];
  29833. _this49.stackVec3[i34] = null;
  29834. }
  29835. _this49.stackVec3 = newArray32;
  29836. }
  29837. _this49.stackVec3[_this49.sizeVec3++] = vec3;
  29838. }
  29839. if(m != null) {
  29840. var t0016 = 1;
  29841. var t0116 = 0;
  29842. var t0216 = 0;
  29843. var t1016 = 0;
  29844. var t1116 = 1;
  29845. var t1216 = 0;
  29846. var t2016 = 0;
  29847. var t2116 = 0;
  29848. var t2216 = 1;
  29849. m.e00 = t0016;
  29850. m.e01 = t0116;
  29851. m.e02 = t0216;
  29852. m.e10 = t1016;
  29853. m.e11 = t1116;
  29854. m.e12 = t1216;
  29855. m.e20 = t2016;
  29856. m.e21 = t2116;
  29857. m.e22 = t2216;
  29858. if(_this49.sizeMat3 == _this49.stackMat3.length) {
  29859. var newLength33 = _this49.sizeMat3 << 1;
  29860. var this34 = new Array(newLength33);
  29861. var newArray33 = this34;
  29862. var _g44 = 0;
  29863. var _g134 = _this49.sizeMat3;
  29864. while(_g44 < _g134) {
  29865. var i35 = _g44++;
  29866. newArray33[i35] = _this49.stackMat3[i35];
  29867. _this49.stackMat3[i35] = null;
  29868. }
  29869. _this49.stackMat3 = newArray33;
  29870. }
  29871. _this49.stackMat3[_this49.sizeMat3++] = m;
  29872. }
  29873. if(mat48 != null) {
  29874. var t0017 = 1;
  29875. var t0117 = 0;
  29876. var t0217 = 0;
  29877. var t038 = 0;
  29878. var t1017 = 0;
  29879. var t1117 = 1;
  29880. var t1217 = 0;
  29881. var t138 = 0;
  29882. var t2017 = 0;
  29883. var t2117 = 0;
  29884. var t2217 = 1;
  29885. var t238 = 0;
  29886. var t308 = 0;
  29887. var t318 = 0;
  29888. var t328 = 0;
  29889. var t338 = 1;
  29890. mat48.e00 = t0017;
  29891. mat48.e01 = t0117;
  29892. mat48.e02 = t0217;
  29893. mat48.e03 = t038;
  29894. mat48.e10 = t1017;
  29895. mat48.e11 = t1117;
  29896. mat48.e12 = t1217;
  29897. mat48.e13 = t138;
  29898. mat48.e20 = t2017;
  29899. mat48.e21 = t2117;
  29900. mat48.e22 = t2217;
  29901. mat48.e23 = t238;
  29902. mat48.e30 = t308;
  29903. mat48.e31 = t318;
  29904. mat48.e32 = t328;
  29905. mat48.e33 = t338;
  29906. if(_this49.sizeMat4 == _this49.stackMat4.length) {
  29907. var newLength34 = _this49.sizeMat4 << 1;
  29908. var this35 = new Array(newLength34);
  29909. var newArray34 = this35;
  29910. var _g45 = 0;
  29911. var _g135 = _this49.sizeMat4;
  29912. while(_g45 < _g135) {
  29913. var i36 = _g45++;
  29914. newArray34[i36] = _this49.stackMat4[i36];
  29915. _this49.stackMat4[i36] = null;
  29916. }
  29917. _this49.stackMat4 = newArray34;
  29918. }
  29919. _this49.stackMat4[_this49.sizeMat4++] = mat48;
  29920. }
  29921. if(quat8 != null) {
  29922. var tx27 = 0;
  29923. var ty27 = 0;
  29924. var tz27 = 0;
  29925. var tw8 = 1;
  29926. quat8.x = tx27;
  29927. quat8.y = ty27;
  29928. quat8.z = tz27;
  29929. quat8.w = tw8;
  29930. if(_this49.sizeQuat == _this49.stackQuat.length) {
  29931. var newLength35 = _this49.sizeQuat << 1;
  29932. var this36 = new Array(newLength35);
  29933. var newArray35 = this36;
  29934. var _g46 = 0;
  29935. var _g136 = _this49.sizeQuat;
  29936. while(_g46 < _g136) {
  29937. var i37 = _g46++;
  29938. newArray35[i37] = _this49.stackQuat[i37];
  29939. _this49.stackQuat[i37] = null;
  29940. }
  29941. _this49.stackQuat = newArray35;
  29942. }
  29943. _this49.stackQuat[_this49.sizeQuat++] = quat8;
  29944. }
  29945. var _this50 = this.p;
  29946. var mat38 = null;
  29947. var mat49 = null;
  29948. var quat9 = null;
  29949. if(ex != null) {
  29950. ex.zero();
  29951. if(_this50.sizeVec3 == _this50.stackVec3.length) {
  29952. var newLength36 = _this50.sizeVec3 << 1;
  29953. var this37 = new Array(newLength36);
  29954. var newArray36 = this37;
  29955. var _g47 = 0;
  29956. var _g137 = _this50.sizeVec3;
  29957. while(_g47 < _g137) {
  29958. var i38 = _g47++;
  29959. newArray36[i38] = _this50.stackVec3[i38];
  29960. _this50.stackVec3[i38] = null;
  29961. }
  29962. _this50.stackVec3 = newArray36;
  29963. }
  29964. _this50.stackVec3[_this50.sizeVec3++] = ex;
  29965. }
  29966. if(mat38 != null) {
  29967. var t0018 = 1;
  29968. var t0118 = 0;
  29969. var t0218 = 0;
  29970. var t1018 = 0;
  29971. var t1118 = 1;
  29972. var t1218 = 0;
  29973. var t2018 = 0;
  29974. var t2118 = 0;
  29975. var t2218 = 1;
  29976. mat38.e00 = t0018;
  29977. mat38.e01 = t0118;
  29978. mat38.e02 = t0218;
  29979. mat38.e10 = t1018;
  29980. mat38.e11 = t1118;
  29981. mat38.e12 = t1218;
  29982. mat38.e20 = t2018;
  29983. mat38.e21 = t2118;
  29984. mat38.e22 = t2218;
  29985. if(_this50.sizeMat3 == _this50.stackMat3.length) {
  29986. var newLength37 = _this50.sizeMat3 << 1;
  29987. var this38 = new Array(newLength37);
  29988. var newArray37 = this38;
  29989. var _g48 = 0;
  29990. var _g138 = _this50.sizeMat3;
  29991. while(_g48 < _g138) {
  29992. var i39 = _g48++;
  29993. newArray37[i39] = _this50.stackMat3[i39];
  29994. _this50.stackMat3[i39] = null;
  29995. }
  29996. _this50.stackMat3 = newArray37;
  29997. }
  29998. _this50.stackMat3[_this50.sizeMat3++] = mat38;
  29999. }
  30000. if(mat49 != null) {
  30001. var t0019 = 1;
  30002. var t0119 = 0;
  30003. var t0219 = 0;
  30004. var t039 = 0;
  30005. var t1019 = 0;
  30006. var t1119 = 1;
  30007. var t1219 = 0;
  30008. var t139 = 0;
  30009. var t2019 = 0;
  30010. var t2119 = 0;
  30011. var t2219 = 1;
  30012. var t239 = 0;
  30013. var t309 = 0;
  30014. var t319 = 0;
  30015. var t329 = 0;
  30016. var t339 = 1;
  30017. mat49.e00 = t0019;
  30018. mat49.e01 = t0119;
  30019. mat49.e02 = t0219;
  30020. mat49.e03 = t039;
  30021. mat49.e10 = t1019;
  30022. mat49.e11 = t1119;
  30023. mat49.e12 = t1219;
  30024. mat49.e13 = t139;
  30025. mat49.e20 = t2019;
  30026. mat49.e21 = t2119;
  30027. mat49.e22 = t2219;
  30028. mat49.e23 = t239;
  30029. mat49.e30 = t309;
  30030. mat49.e31 = t319;
  30031. mat49.e32 = t329;
  30032. mat49.e33 = t339;
  30033. if(_this50.sizeMat4 == _this50.stackMat4.length) {
  30034. var newLength38 = _this50.sizeMat4 << 1;
  30035. var this39 = new Array(newLength38);
  30036. var newArray38 = this39;
  30037. var _g49 = 0;
  30038. var _g139 = _this50.sizeMat4;
  30039. while(_g49 < _g139) {
  30040. var i40 = _g49++;
  30041. newArray38[i40] = _this50.stackMat4[i40];
  30042. _this50.stackMat4[i40] = null;
  30043. }
  30044. _this50.stackMat4 = newArray38;
  30045. }
  30046. _this50.stackMat4[_this50.sizeMat4++] = mat49;
  30047. }
  30048. if(quat9 != null) {
  30049. var tx28 = 0;
  30050. var ty28 = 0;
  30051. var tz28 = 0;
  30052. var tw9 = 1;
  30053. quat9.x = tx28;
  30054. quat9.y = ty28;
  30055. quat9.z = tz28;
  30056. quat9.w = tw9;
  30057. if(_this50.sizeQuat == _this50.stackQuat.length) {
  30058. var newLength39 = _this50.sizeQuat << 1;
  30059. var this40 = new Array(newLength39);
  30060. var newArray39 = this40;
  30061. var _g50 = 0;
  30062. var _g140 = _this50.sizeQuat;
  30063. while(_g50 < _g140) {
  30064. var i41 = _g50++;
  30065. newArray39[i41] = _this50.stackQuat[i41];
  30066. _this50.stackQuat[i41] = null;
  30067. }
  30068. _this50.stackQuat = newArray39;
  30069. }
  30070. _this50.stackQuat[_this50.sizeQuat++] = quat9;
  30071. }
  30072. var _this51 = this.p;
  30073. var mat39 = null;
  30074. var mat410 = null;
  30075. var quat10 = null;
  30076. if(ey != null) {
  30077. ey.zero();
  30078. if(_this51.sizeVec3 == _this51.stackVec3.length) {
  30079. var newLength40 = _this51.sizeVec3 << 1;
  30080. var this41 = new Array(newLength40);
  30081. var newArray40 = this41;
  30082. var _g51 = 0;
  30083. var _g141 = _this51.sizeVec3;
  30084. while(_g51 < _g141) {
  30085. var i42 = _g51++;
  30086. newArray40[i42] = _this51.stackVec3[i42];
  30087. _this51.stackVec3[i42] = null;
  30088. }
  30089. _this51.stackVec3 = newArray40;
  30090. }
  30091. _this51.stackVec3[_this51.sizeVec3++] = ey;
  30092. }
  30093. if(mat39 != null) {
  30094. var t0020 = 1;
  30095. var t0120 = 0;
  30096. var t0220 = 0;
  30097. var t1020 = 0;
  30098. var t1120 = 1;
  30099. var t1220 = 0;
  30100. var t2020 = 0;
  30101. var t2120 = 0;
  30102. var t2220 = 1;
  30103. mat39.e00 = t0020;
  30104. mat39.e01 = t0120;
  30105. mat39.e02 = t0220;
  30106. mat39.e10 = t1020;
  30107. mat39.e11 = t1120;
  30108. mat39.e12 = t1220;
  30109. mat39.e20 = t2020;
  30110. mat39.e21 = t2120;
  30111. mat39.e22 = t2220;
  30112. if(_this51.sizeMat3 == _this51.stackMat3.length) {
  30113. var newLength41 = _this51.sizeMat3 << 1;
  30114. var this42 = new Array(newLength41);
  30115. var newArray41 = this42;
  30116. var _g52 = 0;
  30117. var _g142 = _this51.sizeMat3;
  30118. while(_g52 < _g142) {
  30119. var i43 = _g52++;
  30120. newArray41[i43] = _this51.stackMat3[i43];
  30121. _this51.stackMat3[i43] = null;
  30122. }
  30123. _this51.stackMat3 = newArray41;
  30124. }
  30125. _this51.stackMat3[_this51.sizeMat3++] = mat39;
  30126. }
  30127. if(mat410 != null) {
  30128. var t0021 = 1;
  30129. var t0121 = 0;
  30130. var t0221 = 0;
  30131. var t0310 = 0;
  30132. var t1021 = 0;
  30133. var t1121 = 1;
  30134. var t1221 = 0;
  30135. var t1310 = 0;
  30136. var t2021 = 0;
  30137. var t2121 = 0;
  30138. var t2221 = 1;
  30139. var t2310 = 0;
  30140. var t3010 = 0;
  30141. var t3110 = 0;
  30142. var t3210 = 0;
  30143. var t3310 = 1;
  30144. mat410.e00 = t0021;
  30145. mat410.e01 = t0121;
  30146. mat410.e02 = t0221;
  30147. mat410.e03 = t0310;
  30148. mat410.e10 = t1021;
  30149. mat410.e11 = t1121;
  30150. mat410.e12 = t1221;
  30151. mat410.e13 = t1310;
  30152. mat410.e20 = t2021;
  30153. mat410.e21 = t2121;
  30154. mat410.e22 = t2221;
  30155. mat410.e23 = t2310;
  30156. mat410.e30 = t3010;
  30157. mat410.e31 = t3110;
  30158. mat410.e32 = t3210;
  30159. mat410.e33 = t3310;
  30160. if(_this51.sizeMat4 == _this51.stackMat4.length) {
  30161. var newLength42 = _this51.sizeMat4 << 1;
  30162. var this43 = new Array(newLength42);
  30163. var newArray42 = this43;
  30164. var _g53 = 0;
  30165. var _g143 = _this51.sizeMat4;
  30166. while(_g53 < _g143) {
  30167. var i44 = _g53++;
  30168. newArray42[i44] = _this51.stackMat4[i44];
  30169. _this51.stackMat4[i44] = null;
  30170. }
  30171. _this51.stackMat4 = newArray42;
  30172. }
  30173. _this51.stackMat4[_this51.sizeMat4++] = mat410;
  30174. }
  30175. if(quat10 != null) {
  30176. var tx29 = 0;
  30177. var ty29 = 0;
  30178. var tz29 = 0;
  30179. var tw10 = 1;
  30180. quat10.x = tx29;
  30181. quat10.y = ty29;
  30182. quat10.z = tz29;
  30183. quat10.w = tw10;
  30184. if(_this51.sizeQuat == _this51.stackQuat.length) {
  30185. var newLength43 = _this51.sizeQuat << 1;
  30186. var this44 = new Array(newLength43);
  30187. var newArray43 = this44;
  30188. var _g54 = 0;
  30189. var _g144 = _this51.sizeQuat;
  30190. while(_g54 < _g144) {
  30191. var i45 = _g54++;
  30192. newArray43[i45] = _this51.stackQuat[i45];
  30193. _this51.stackQuat[i45] = null;
  30194. }
  30195. _this51.stackQuat = newArray43;
  30196. }
  30197. _this51.stackQuat[_this51.sizeQuat++] = quat10;
  30198. }
  30199. var _this52 = this.p;
  30200. var mat310 = null;
  30201. var mat411 = null;
  30202. var quat11 = null;
  30203. if(ez != null) {
  30204. ez.zero();
  30205. if(_this52.sizeVec3 == _this52.stackVec3.length) {
  30206. var newLength44 = _this52.sizeVec3 << 1;
  30207. var this45 = new Array(newLength44);
  30208. var newArray44 = this45;
  30209. var _g55 = 0;
  30210. var _g145 = _this52.sizeVec3;
  30211. while(_g55 < _g145) {
  30212. var i46 = _g55++;
  30213. newArray44[i46] = _this52.stackVec3[i46];
  30214. _this52.stackVec3[i46] = null;
  30215. }
  30216. _this52.stackVec3 = newArray44;
  30217. }
  30218. _this52.stackVec3[_this52.sizeVec3++] = ez;
  30219. }
  30220. if(mat310 != null) {
  30221. var t0022 = 1;
  30222. var t0122 = 0;
  30223. var t0222 = 0;
  30224. var t1022 = 0;
  30225. var t1122 = 1;
  30226. var t1222 = 0;
  30227. var t2022 = 0;
  30228. var t2122 = 0;
  30229. var t2222 = 1;
  30230. mat310.e00 = t0022;
  30231. mat310.e01 = t0122;
  30232. mat310.e02 = t0222;
  30233. mat310.e10 = t1022;
  30234. mat310.e11 = t1122;
  30235. mat310.e12 = t1222;
  30236. mat310.e20 = t2022;
  30237. mat310.e21 = t2122;
  30238. mat310.e22 = t2222;
  30239. if(_this52.sizeMat3 == _this52.stackMat3.length) {
  30240. var newLength45 = _this52.sizeMat3 << 1;
  30241. var this46 = new Array(newLength45);
  30242. var newArray45 = this46;
  30243. var _g56 = 0;
  30244. var _g146 = _this52.sizeMat3;
  30245. while(_g56 < _g146) {
  30246. var i47 = _g56++;
  30247. newArray45[i47] = _this52.stackMat3[i47];
  30248. _this52.stackMat3[i47] = null;
  30249. }
  30250. _this52.stackMat3 = newArray45;
  30251. }
  30252. _this52.stackMat3[_this52.sizeMat3++] = mat310;
  30253. }
  30254. if(mat411 != null) {
  30255. var t0023 = 1;
  30256. var t0123 = 0;
  30257. var t0223 = 0;
  30258. var t0311 = 0;
  30259. var t1023 = 0;
  30260. var t1123 = 1;
  30261. var t1223 = 0;
  30262. var t1311 = 0;
  30263. var t2023 = 0;
  30264. var t2123 = 0;
  30265. var t2223 = 1;
  30266. var t2311 = 0;
  30267. var t3011 = 0;
  30268. var t3111 = 0;
  30269. var t3211 = 0;
  30270. var t3311 = 1;
  30271. mat411.e00 = t0023;
  30272. mat411.e01 = t0123;
  30273. mat411.e02 = t0223;
  30274. mat411.e03 = t0311;
  30275. mat411.e10 = t1023;
  30276. mat411.e11 = t1123;
  30277. mat411.e12 = t1223;
  30278. mat411.e13 = t1311;
  30279. mat411.e20 = t2023;
  30280. mat411.e21 = t2123;
  30281. mat411.e22 = t2223;
  30282. mat411.e23 = t2311;
  30283. mat411.e30 = t3011;
  30284. mat411.e31 = t3111;
  30285. mat411.e32 = t3211;
  30286. mat411.e33 = t3311;
  30287. if(_this52.sizeMat4 == _this52.stackMat4.length) {
  30288. var newLength46 = _this52.sizeMat4 << 1;
  30289. var this47 = new Array(newLength46);
  30290. var newArray46 = this47;
  30291. var _g57 = 0;
  30292. var _g147 = _this52.sizeMat4;
  30293. while(_g57 < _g147) {
  30294. var i48 = _g57++;
  30295. newArray46[i48] = _this52.stackMat4[i48];
  30296. _this52.stackMat4[i48] = null;
  30297. }
  30298. _this52.stackMat4 = newArray46;
  30299. }
  30300. _this52.stackMat4[_this52.sizeMat4++] = mat411;
  30301. }
  30302. if(quat11 != null) {
  30303. var tx30 = 0;
  30304. var ty30 = 0;
  30305. var tz30 = 0;
  30306. var tw11 = 1;
  30307. quat11.x = tx30;
  30308. quat11.y = ty30;
  30309. quat11.z = tz30;
  30310. quat11.w = tw11;
  30311. if(_this52.sizeQuat == _this52.stackQuat.length) {
  30312. var newLength47 = _this52.sizeQuat << 1;
  30313. var this48 = new Array(newLength47);
  30314. var newArray47 = this48;
  30315. var _g58 = 0;
  30316. var _g148 = _this52.sizeQuat;
  30317. while(_g58 < _g148) {
  30318. var i49 = _g58++;
  30319. newArray47[i49] = _this52.stackQuat[i49];
  30320. _this52.stackQuat[i49] = null;
  30321. }
  30322. _this52.stackQuat = newArray47;
  30323. }
  30324. _this52.stackQuat[_this52.sizeQuat++] = quat11;
  30325. }
  30326. }
  30327. cylinder(tf,radius,halfHeight,color) {
  30328. var _this = this.p;
  30329. var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  30330. var _this1 = this.p;
  30331. var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  30332. var _this2 = this.p;
  30333. var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  30334. var _this3 = this.p;
  30335. var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  30336. var _this4 = this.p;
  30337. var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3];
  30338. var v = o;
  30339. v.x = tf._positionX;
  30340. v.y = tf._positionY;
  30341. v.z = tf._positionZ;
  30342. var m1 = m;
  30343. m1.e00 = tf._rotation00;
  30344. m1.e01 = tf._rotation01;
  30345. m1.e02 = tf._rotation02;
  30346. m1.e10 = tf._rotation10;
  30347. m1.e11 = tf._rotation11;
  30348. m1.e12 = tf._rotation12;
  30349. m1.e20 = tf._rotation20;
  30350. m1.e21 = tf._rotation21;
  30351. m1.e22 = tf._rotation22;
  30352. ex.init(m.e00,m.e10,m.e20);
  30353. ey.init(m.e01,m.e11,m.e21);
  30354. ez.init(m.e02,m.e12,m.e22);
  30355. var _this5 = this.p;
  30356. var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3];
  30357. _this6.x = o.x;
  30358. _this6.y = o.y;
  30359. _this6.z = o.z;
  30360. var _this7 = _this6;
  30361. var tx = _this7.x + ey.x * halfHeight;
  30362. var ty = _this7.y + ey.y * halfHeight;
  30363. var tz = _this7.z + ey.z * halfHeight;
  30364. _this7.x = tx;
  30365. _this7.y = ty;
  30366. _this7.z = tz;
  30367. var top = _this7;
  30368. var _this8 = this.p;
  30369. var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3];
  30370. _this9.x = o.x;
  30371. _this9.y = o.y;
  30372. _this9.z = o.z;
  30373. var _this10 = _this9;
  30374. var s = -halfHeight;
  30375. var tx1 = _this10.x + ey.x * s;
  30376. var ty1 = _this10.y + ey.y * s;
  30377. var tz1 = _this10.z + ey.z * s;
  30378. _this10.x = tx1;
  30379. _this10.y = ty1;
  30380. _this10.z = tz1;
  30381. var bottom = _this10;
  30382. if(this.wireframe) {
  30383. var _this11 = this.p;
  30384. var _this12 = _this11.sizeVec3 == 0 ? new oimo.common.Vec3() : _this11.stackVec3[--_this11.sizeVec3];
  30385. _this12.x = top.x;
  30386. _this12.y = top.y;
  30387. _this12.z = top.z;
  30388. var _this13 = _this12;
  30389. var s1 = -radius;
  30390. var tx2 = _this13.x + ex.x * s1;
  30391. var ty2 = _this13.y + ex.y * s1;
  30392. var tz2 = _this13.z + ex.z * s1;
  30393. _this13.x = tx2;
  30394. _this13.y = ty2;
  30395. _this13.z = tz2;
  30396. var _this14 = _this13;
  30397. var tx3 = _this14.x + ez.x * 0;
  30398. var ty3 = _this14.y + ez.y * 0;
  30399. var tz3 = _this14.z + ez.z * 0;
  30400. _this14.x = tx3;
  30401. _this14.y = ty3;
  30402. _this14.z = tz3;
  30403. var top1 = _this14;
  30404. var _this15 = this.p;
  30405. var _this16 = _this15.sizeVec3 == 0 ? new oimo.common.Vec3() : _this15.stackVec3[--_this15.sizeVec3];
  30406. _this16.x = top.x;
  30407. _this16.y = top.y;
  30408. _this16.z = top.z;
  30409. var _this17 = _this16;
  30410. var tx4 = _this17.x + ex.x * radius;
  30411. var ty4 = _this17.y + ex.y * radius;
  30412. var tz4 = _this17.z + ex.z * radius;
  30413. _this17.x = tx4;
  30414. _this17.y = ty4;
  30415. _this17.z = tz4;
  30416. var _this18 = _this17;
  30417. var tx5 = _this18.x + ez.x * 0;
  30418. var ty5 = _this18.y + ez.y * 0;
  30419. var tz5 = _this18.z + ez.z * 0;
  30420. _this18.x = tx5;
  30421. _this18.y = ty5;
  30422. _this18.z = tz5;
  30423. var top2 = _this18;
  30424. var _this19 = this.p;
  30425. var _this20 = _this19.sizeVec3 == 0 ? new oimo.common.Vec3() : _this19.stackVec3[--_this19.sizeVec3];
  30426. _this20.x = top.x;
  30427. _this20.y = top.y;
  30428. _this20.z = top.z;
  30429. var _this21 = _this20;
  30430. var tx6 = _this21.x + ex.x * 0;
  30431. var ty6 = _this21.y + ex.y * 0;
  30432. var tz6 = _this21.z + ex.z * 0;
  30433. _this21.x = tx6;
  30434. _this21.y = ty6;
  30435. _this21.z = tz6;
  30436. var _this22 = _this21;
  30437. var s2 = -radius;
  30438. var tx7 = _this22.x + ez.x * s2;
  30439. var ty7 = _this22.y + ez.y * s2;
  30440. var tz7 = _this22.z + ez.z * s2;
  30441. _this22.x = tx7;
  30442. _this22.y = ty7;
  30443. _this22.z = tz7;
  30444. var top3 = _this22;
  30445. var _this23 = this.p;
  30446. var _this24 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3];
  30447. _this24.x = top.x;
  30448. _this24.y = top.y;
  30449. _this24.z = top.z;
  30450. var _this25 = _this24;
  30451. var tx8 = _this25.x + ex.x * 0;
  30452. var ty8 = _this25.y + ex.y * 0;
  30453. var tz8 = _this25.z + ex.z * 0;
  30454. _this25.x = tx8;
  30455. _this25.y = ty8;
  30456. _this25.z = tz8;
  30457. var _this26 = _this25;
  30458. var tx9 = _this26.x + ez.x * radius;
  30459. var ty9 = _this26.y + ez.y * radius;
  30460. var tz9 = _this26.z + ez.z * radius;
  30461. _this26.x = tx9;
  30462. _this26.y = ty9;
  30463. _this26.z = tz9;
  30464. var top4 = _this26;
  30465. var _this27 = this.p;
  30466. var _this28 = _this27.sizeVec3 == 0 ? new oimo.common.Vec3() : _this27.stackVec3[--_this27.sizeVec3];
  30467. _this28.x = bottom.x;
  30468. _this28.y = bottom.y;
  30469. _this28.z = bottom.z;
  30470. var _this29 = _this28;
  30471. var s3 = -radius;
  30472. var tx10 = _this29.x + ex.x * s3;
  30473. var ty10 = _this29.y + ex.y * s3;
  30474. var tz10 = _this29.z + ex.z * s3;
  30475. _this29.x = tx10;
  30476. _this29.y = ty10;
  30477. _this29.z = tz10;
  30478. var _this30 = _this29;
  30479. var tx11 = _this30.x + ez.x * 0;
  30480. var ty11 = _this30.y + ez.y * 0;
  30481. var tz11 = _this30.z + ez.z * 0;
  30482. _this30.x = tx11;
  30483. _this30.y = ty11;
  30484. _this30.z = tz11;
  30485. var bottom1 = _this30;
  30486. var _this31 = this.p;
  30487. var _this32 = _this31.sizeVec3 == 0 ? new oimo.common.Vec3() : _this31.stackVec3[--_this31.sizeVec3];
  30488. _this32.x = bottom.x;
  30489. _this32.y = bottom.y;
  30490. _this32.z = bottom.z;
  30491. var _this33 = _this32;
  30492. var tx12 = _this33.x + ex.x * radius;
  30493. var ty12 = _this33.y + ex.y * radius;
  30494. var tz12 = _this33.z + ex.z * radius;
  30495. _this33.x = tx12;
  30496. _this33.y = ty12;
  30497. _this33.z = tz12;
  30498. var _this34 = _this33;
  30499. var tx13 = _this34.x + ez.x * 0;
  30500. var ty13 = _this34.y + ez.y * 0;
  30501. var tz13 = _this34.z + ez.z * 0;
  30502. _this34.x = tx13;
  30503. _this34.y = ty13;
  30504. _this34.z = tz13;
  30505. var bottom2 = _this34;
  30506. var _this35 = this.p;
  30507. var _this36 = _this35.sizeVec3 == 0 ? new oimo.common.Vec3() : _this35.stackVec3[--_this35.sizeVec3];
  30508. _this36.x = bottom.x;
  30509. _this36.y = bottom.y;
  30510. _this36.z = bottom.z;
  30511. var _this37 = _this36;
  30512. var tx14 = _this37.x + ex.x * 0;
  30513. var ty14 = _this37.y + ex.y * 0;
  30514. var tz14 = _this37.z + ex.z * 0;
  30515. _this37.x = tx14;
  30516. _this37.y = ty14;
  30517. _this37.z = tz14;
  30518. var _this38 = _this37;
  30519. var s4 = -radius;
  30520. var tx15 = _this38.x + ez.x * s4;
  30521. var ty15 = _this38.y + ez.y * s4;
  30522. var tz15 = _this38.z + ez.z * s4;
  30523. _this38.x = tx15;
  30524. _this38.y = ty15;
  30525. _this38.z = tz15;
  30526. var bottom3 = _this38;
  30527. var _this39 = this.p;
  30528. var _this40 = _this39.sizeVec3 == 0 ? new oimo.common.Vec3() : _this39.stackVec3[--_this39.sizeVec3];
  30529. _this40.x = bottom.x;
  30530. _this40.y = bottom.y;
  30531. _this40.z = bottom.z;
  30532. var _this41 = _this40;
  30533. var tx16 = _this41.x + ex.x * 0;
  30534. var ty16 = _this41.y + ex.y * 0;
  30535. var tz16 = _this41.z + ex.z * 0;
  30536. _this41.x = tx16;
  30537. _this41.y = ty16;
  30538. _this41.z = tz16;
  30539. var _this42 = _this41;
  30540. var tx17 = _this42.x + ez.x * radius;
  30541. var ty17 = _this42.y + ez.y * radius;
  30542. var tz17 = _this42.z + ez.z * radius;
  30543. _this42.x = tx17;
  30544. _this42.y = ty17;
  30545. _this42.z = tz17;
  30546. var bottom4 = _this42;
  30547. this.ellipse(top,ex,ez,radius,radius,color);
  30548. this.ellipse(bottom,ex,ez,radius,radius,color);
  30549. this.line(top1,bottom1,color);
  30550. this.line(top2,bottom2,color);
  30551. this.line(top3,bottom3,color);
  30552. this.line(top4,bottom4,color);
  30553. var _this43 = this.p;
  30554. var mat3 = null;
  30555. var mat4 = null;
  30556. var quat = null;
  30557. if(top1 != null) {
  30558. top1.zero();
  30559. if(_this43.sizeVec3 == _this43.stackVec3.length) {
  30560. var newLength = _this43.sizeVec3 << 1;
  30561. var this1 = new Array(newLength);
  30562. var newArray = this1;
  30563. var _g = 0;
  30564. var _g1 = _this43.sizeVec3;
  30565. while(_g < _g1) {
  30566. var i = _g++;
  30567. newArray[i] = _this43.stackVec3[i];
  30568. _this43.stackVec3[i] = null;
  30569. }
  30570. _this43.stackVec3 = newArray;
  30571. }
  30572. _this43.stackVec3[_this43.sizeVec3++] = top1;
  30573. }
  30574. if(mat3 != null) {
  30575. var t00 = 1;
  30576. var t01 = 0;
  30577. var t02 = 0;
  30578. var t10 = 0;
  30579. var t11 = 1;
  30580. var t12 = 0;
  30581. var t20 = 0;
  30582. var t21 = 0;
  30583. var t22 = 1;
  30584. mat3.e00 = t00;
  30585. mat3.e01 = t01;
  30586. mat3.e02 = t02;
  30587. mat3.e10 = t10;
  30588. mat3.e11 = t11;
  30589. mat3.e12 = t12;
  30590. mat3.e20 = t20;
  30591. mat3.e21 = t21;
  30592. mat3.e22 = t22;
  30593. if(_this43.sizeMat3 == _this43.stackMat3.length) {
  30594. var newLength1 = _this43.sizeMat3 << 1;
  30595. var this2 = new Array(newLength1);
  30596. var newArray1 = this2;
  30597. var _g2 = 0;
  30598. var _g11 = _this43.sizeMat3;
  30599. while(_g2 < _g11) {
  30600. var i1 = _g2++;
  30601. newArray1[i1] = _this43.stackMat3[i1];
  30602. _this43.stackMat3[i1] = null;
  30603. }
  30604. _this43.stackMat3 = newArray1;
  30605. }
  30606. _this43.stackMat3[_this43.sizeMat3++] = mat3;
  30607. }
  30608. if(mat4 != null) {
  30609. var t001 = 1;
  30610. var t011 = 0;
  30611. var t021 = 0;
  30612. var t03 = 0;
  30613. var t101 = 0;
  30614. var t111 = 1;
  30615. var t121 = 0;
  30616. var t13 = 0;
  30617. var t201 = 0;
  30618. var t211 = 0;
  30619. var t221 = 1;
  30620. var t23 = 0;
  30621. var t30 = 0;
  30622. var t31 = 0;
  30623. var t32 = 0;
  30624. var t33 = 1;
  30625. mat4.e00 = t001;
  30626. mat4.e01 = t011;
  30627. mat4.e02 = t021;
  30628. mat4.e03 = t03;
  30629. mat4.e10 = t101;
  30630. mat4.e11 = t111;
  30631. mat4.e12 = t121;
  30632. mat4.e13 = t13;
  30633. mat4.e20 = t201;
  30634. mat4.e21 = t211;
  30635. mat4.e22 = t221;
  30636. mat4.e23 = t23;
  30637. mat4.e30 = t30;
  30638. mat4.e31 = t31;
  30639. mat4.e32 = t32;
  30640. mat4.e33 = t33;
  30641. if(_this43.sizeMat4 == _this43.stackMat4.length) {
  30642. var newLength2 = _this43.sizeMat4 << 1;
  30643. var this3 = new Array(newLength2);
  30644. var newArray2 = this3;
  30645. var _g3 = 0;
  30646. var _g12 = _this43.sizeMat4;
  30647. while(_g3 < _g12) {
  30648. var i2 = _g3++;
  30649. newArray2[i2] = _this43.stackMat4[i2];
  30650. _this43.stackMat4[i2] = null;
  30651. }
  30652. _this43.stackMat4 = newArray2;
  30653. }
  30654. _this43.stackMat4[_this43.sizeMat4++] = mat4;
  30655. }
  30656. if(quat != null) {
  30657. var tx18 = 0;
  30658. var ty18 = 0;
  30659. var tz18 = 0;
  30660. var tw = 1;
  30661. quat.x = tx18;
  30662. quat.y = ty18;
  30663. quat.z = tz18;
  30664. quat.w = tw;
  30665. if(_this43.sizeQuat == _this43.stackQuat.length) {
  30666. var newLength3 = _this43.sizeQuat << 1;
  30667. var this4 = new Array(newLength3);
  30668. var newArray3 = this4;
  30669. var _g4 = 0;
  30670. var _g13 = _this43.sizeQuat;
  30671. while(_g4 < _g13) {
  30672. var i3 = _g4++;
  30673. newArray3[i3] = _this43.stackQuat[i3];
  30674. _this43.stackQuat[i3] = null;
  30675. }
  30676. _this43.stackQuat = newArray3;
  30677. }
  30678. _this43.stackQuat[_this43.sizeQuat++] = quat;
  30679. }
  30680. var _this44 = this.p;
  30681. var mat31 = null;
  30682. var mat41 = null;
  30683. var quat1 = null;
  30684. if(top2 != null) {
  30685. top2.zero();
  30686. if(_this44.sizeVec3 == _this44.stackVec3.length) {
  30687. var newLength4 = _this44.sizeVec3 << 1;
  30688. var this5 = new Array(newLength4);
  30689. var newArray4 = this5;
  30690. var _g5 = 0;
  30691. var _g14 = _this44.sizeVec3;
  30692. while(_g5 < _g14) {
  30693. var i4 = _g5++;
  30694. newArray4[i4] = _this44.stackVec3[i4];
  30695. _this44.stackVec3[i4] = null;
  30696. }
  30697. _this44.stackVec3 = newArray4;
  30698. }
  30699. _this44.stackVec3[_this44.sizeVec3++] = top2;
  30700. }
  30701. if(mat31 != null) {
  30702. var t002 = 1;
  30703. var t012 = 0;
  30704. var t022 = 0;
  30705. var t102 = 0;
  30706. var t112 = 1;
  30707. var t122 = 0;
  30708. var t202 = 0;
  30709. var t212 = 0;
  30710. var t222 = 1;
  30711. mat31.e00 = t002;
  30712. mat31.e01 = t012;
  30713. mat31.e02 = t022;
  30714. mat31.e10 = t102;
  30715. mat31.e11 = t112;
  30716. mat31.e12 = t122;
  30717. mat31.e20 = t202;
  30718. mat31.e21 = t212;
  30719. mat31.e22 = t222;
  30720. if(_this44.sizeMat3 == _this44.stackMat3.length) {
  30721. var newLength5 = _this44.sizeMat3 << 1;
  30722. var this6 = new Array(newLength5);
  30723. var newArray5 = this6;
  30724. var _g6 = 0;
  30725. var _g15 = _this44.sizeMat3;
  30726. while(_g6 < _g15) {
  30727. var i5 = _g6++;
  30728. newArray5[i5] = _this44.stackMat3[i5];
  30729. _this44.stackMat3[i5] = null;
  30730. }
  30731. _this44.stackMat3 = newArray5;
  30732. }
  30733. _this44.stackMat3[_this44.sizeMat3++] = mat31;
  30734. }
  30735. if(mat41 != null) {
  30736. var t003 = 1;
  30737. var t013 = 0;
  30738. var t023 = 0;
  30739. var t031 = 0;
  30740. var t103 = 0;
  30741. var t113 = 1;
  30742. var t123 = 0;
  30743. var t131 = 0;
  30744. var t203 = 0;
  30745. var t213 = 0;
  30746. var t223 = 1;
  30747. var t231 = 0;
  30748. var t301 = 0;
  30749. var t311 = 0;
  30750. var t321 = 0;
  30751. var t331 = 1;
  30752. mat41.e00 = t003;
  30753. mat41.e01 = t013;
  30754. mat41.e02 = t023;
  30755. mat41.e03 = t031;
  30756. mat41.e10 = t103;
  30757. mat41.e11 = t113;
  30758. mat41.e12 = t123;
  30759. mat41.e13 = t131;
  30760. mat41.e20 = t203;
  30761. mat41.e21 = t213;
  30762. mat41.e22 = t223;
  30763. mat41.e23 = t231;
  30764. mat41.e30 = t301;
  30765. mat41.e31 = t311;
  30766. mat41.e32 = t321;
  30767. mat41.e33 = t331;
  30768. if(_this44.sizeMat4 == _this44.stackMat4.length) {
  30769. var newLength6 = _this44.sizeMat4 << 1;
  30770. var this7 = new Array(newLength6);
  30771. var newArray6 = this7;
  30772. var _g7 = 0;
  30773. var _g16 = _this44.sizeMat4;
  30774. while(_g7 < _g16) {
  30775. var i6 = _g7++;
  30776. newArray6[i6] = _this44.stackMat4[i6];
  30777. _this44.stackMat4[i6] = null;
  30778. }
  30779. _this44.stackMat4 = newArray6;
  30780. }
  30781. _this44.stackMat4[_this44.sizeMat4++] = mat41;
  30782. }
  30783. if(quat1 != null) {
  30784. var tx19 = 0;
  30785. var ty19 = 0;
  30786. var tz19 = 0;
  30787. var tw1 = 1;
  30788. quat1.x = tx19;
  30789. quat1.y = ty19;
  30790. quat1.z = tz19;
  30791. quat1.w = tw1;
  30792. if(_this44.sizeQuat == _this44.stackQuat.length) {
  30793. var newLength7 = _this44.sizeQuat << 1;
  30794. var this8 = new Array(newLength7);
  30795. var newArray7 = this8;
  30796. var _g8 = 0;
  30797. var _g17 = _this44.sizeQuat;
  30798. while(_g8 < _g17) {
  30799. var i7 = _g8++;
  30800. newArray7[i7] = _this44.stackQuat[i7];
  30801. _this44.stackQuat[i7] = null;
  30802. }
  30803. _this44.stackQuat = newArray7;
  30804. }
  30805. _this44.stackQuat[_this44.sizeQuat++] = quat1;
  30806. }
  30807. var _this45 = this.p;
  30808. var mat32 = null;
  30809. var mat42 = null;
  30810. var quat2 = null;
  30811. if(top3 != null) {
  30812. top3.zero();
  30813. if(_this45.sizeVec3 == _this45.stackVec3.length) {
  30814. var newLength8 = _this45.sizeVec3 << 1;
  30815. var this9 = new Array(newLength8);
  30816. var newArray8 = this9;
  30817. var _g9 = 0;
  30818. var _g18 = _this45.sizeVec3;
  30819. while(_g9 < _g18) {
  30820. var i8 = _g9++;
  30821. newArray8[i8] = _this45.stackVec3[i8];
  30822. _this45.stackVec3[i8] = null;
  30823. }
  30824. _this45.stackVec3 = newArray8;
  30825. }
  30826. _this45.stackVec3[_this45.sizeVec3++] = top3;
  30827. }
  30828. if(mat32 != null) {
  30829. var t004 = 1;
  30830. var t014 = 0;
  30831. var t024 = 0;
  30832. var t104 = 0;
  30833. var t114 = 1;
  30834. var t124 = 0;
  30835. var t204 = 0;
  30836. var t214 = 0;
  30837. var t224 = 1;
  30838. mat32.e00 = t004;
  30839. mat32.e01 = t014;
  30840. mat32.e02 = t024;
  30841. mat32.e10 = t104;
  30842. mat32.e11 = t114;
  30843. mat32.e12 = t124;
  30844. mat32.e20 = t204;
  30845. mat32.e21 = t214;
  30846. mat32.e22 = t224;
  30847. if(_this45.sizeMat3 == _this45.stackMat3.length) {
  30848. var newLength9 = _this45.sizeMat3 << 1;
  30849. var this10 = new Array(newLength9);
  30850. var newArray9 = this10;
  30851. var _g10 = 0;
  30852. var _g19 = _this45.sizeMat3;
  30853. while(_g10 < _g19) {
  30854. var i9 = _g10++;
  30855. newArray9[i9] = _this45.stackMat3[i9];
  30856. _this45.stackMat3[i9] = null;
  30857. }
  30858. _this45.stackMat3 = newArray9;
  30859. }
  30860. _this45.stackMat3[_this45.sizeMat3++] = mat32;
  30861. }
  30862. if(mat42 != null) {
  30863. var t005 = 1;
  30864. var t015 = 0;
  30865. var t025 = 0;
  30866. var t032 = 0;
  30867. var t105 = 0;
  30868. var t115 = 1;
  30869. var t125 = 0;
  30870. var t132 = 0;
  30871. var t205 = 0;
  30872. var t215 = 0;
  30873. var t225 = 1;
  30874. var t232 = 0;
  30875. var t302 = 0;
  30876. var t312 = 0;
  30877. var t322 = 0;
  30878. var t332 = 1;
  30879. mat42.e00 = t005;
  30880. mat42.e01 = t015;
  30881. mat42.e02 = t025;
  30882. mat42.e03 = t032;
  30883. mat42.e10 = t105;
  30884. mat42.e11 = t115;
  30885. mat42.e12 = t125;
  30886. mat42.e13 = t132;
  30887. mat42.e20 = t205;
  30888. mat42.e21 = t215;
  30889. mat42.e22 = t225;
  30890. mat42.e23 = t232;
  30891. mat42.e30 = t302;
  30892. mat42.e31 = t312;
  30893. mat42.e32 = t322;
  30894. mat42.e33 = t332;
  30895. if(_this45.sizeMat4 == _this45.stackMat4.length) {
  30896. var newLength10 = _this45.sizeMat4 << 1;
  30897. var this11 = new Array(newLength10);
  30898. var newArray10 = this11;
  30899. var _g20 = 0;
  30900. var _g110 = _this45.sizeMat4;
  30901. while(_g20 < _g110) {
  30902. var i10 = _g20++;
  30903. newArray10[i10] = _this45.stackMat4[i10];
  30904. _this45.stackMat4[i10] = null;
  30905. }
  30906. _this45.stackMat4 = newArray10;
  30907. }
  30908. _this45.stackMat4[_this45.sizeMat4++] = mat42;
  30909. }
  30910. if(quat2 != null) {
  30911. var tx20 = 0;
  30912. var ty20 = 0;
  30913. var tz20 = 0;
  30914. var tw2 = 1;
  30915. quat2.x = tx20;
  30916. quat2.y = ty20;
  30917. quat2.z = tz20;
  30918. quat2.w = tw2;
  30919. if(_this45.sizeQuat == _this45.stackQuat.length) {
  30920. var newLength11 = _this45.sizeQuat << 1;
  30921. var this12 = new Array(newLength11);
  30922. var newArray11 = this12;
  30923. var _g21 = 0;
  30924. var _g111 = _this45.sizeQuat;
  30925. while(_g21 < _g111) {
  30926. var i11 = _g21++;
  30927. newArray11[i11] = _this45.stackQuat[i11];
  30928. _this45.stackQuat[i11] = null;
  30929. }
  30930. _this45.stackQuat = newArray11;
  30931. }
  30932. _this45.stackQuat[_this45.sizeQuat++] = quat2;
  30933. }
  30934. var _this46 = this.p;
  30935. var mat33 = null;
  30936. var mat43 = null;
  30937. var quat3 = null;
  30938. if(top4 != null) {
  30939. top4.zero();
  30940. if(_this46.sizeVec3 == _this46.stackVec3.length) {
  30941. var newLength12 = _this46.sizeVec3 << 1;
  30942. var this13 = new Array(newLength12);
  30943. var newArray12 = this13;
  30944. var _g22 = 0;
  30945. var _g112 = _this46.sizeVec3;
  30946. while(_g22 < _g112) {
  30947. var i12 = _g22++;
  30948. newArray12[i12] = _this46.stackVec3[i12];
  30949. _this46.stackVec3[i12] = null;
  30950. }
  30951. _this46.stackVec3 = newArray12;
  30952. }
  30953. _this46.stackVec3[_this46.sizeVec3++] = top4;
  30954. }
  30955. if(mat33 != null) {
  30956. var t006 = 1;
  30957. var t016 = 0;
  30958. var t026 = 0;
  30959. var t106 = 0;
  30960. var t116 = 1;
  30961. var t126 = 0;
  30962. var t206 = 0;
  30963. var t216 = 0;
  30964. var t226 = 1;
  30965. mat33.e00 = t006;
  30966. mat33.e01 = t016;
  30967. mat33.e02 = t026;
  30968. mat33.e10 = t106;
  30969. mat33.e11 = t116;
  30970. mat33.e12 = t126;
  30971. mat33.e20 = t206;
  30972. mat33.e21 = t216;
  30973. mat33.e22 = t226;
  30974. if(_this46.sizeMat3 == _this46.stackMat3.length) {
  30975. var newLength13 = _this46.sizeMat3 << 1;
  30976. var this14 = new Array(newLength13);
  30977. var newArray13 = this14;
  30978. var _g23 = 0;
  30979. var _g113 = _this46.sizeMat3;
  30980. while(_g23 < _g113) {
  30981. var i13 = _g23++;
  30982. newArray13[i13] = _this46.stackMat3[i13];
  30983. _this46.stackMat3[i13] = null;
  30984. }
  30985. _this46.stackMat3 = newArray13;
  30986. }
  30987. _this46.stackMat3[_this46.sizeMat3++] = mat33;
  30988. }
  30989. if(mat43 != null) {
  30990. var t007 = 1;
  30991. var t017 = 0;
  30992. var t027 = 0;
  30993. var t033 = 0;
  30994. var t107 = 0;
  30995. var t117 = 1;
  30996. var t127 = 0;
  30997. var t133 = 0;
  30998. var t207 = 0;
  30999. var t217 = 0;
  31000. var t227 = 1;
  31001. var t233 = 0;
  31002. var t303 = 0;
  31003. var t313 = 0;
  31004. var t323 = 0;
  31005. var t333 = 1;
  31006. mat43.e00 = t007;
  31007. mat43.e01 = t017;
  31008. mat43.e02 = t027;
  31009. mat43.e03 = t033;
  31010. mat43.e10 = t107;
  31011. mat43.e11 = t117;
  31012. mat43.e12 = t127;
  31013. mat43.e13 = t133;
  31014. mat43.e20 = t207;
  31015. mat43.e21 = t217;
  31016. mat43.e22 = t227;
  31017. mat43.e23 = t233;
  31018. mat43.e30 = t303;
  31019. mat43.e31 = t313;
  31020. mat43.e32 = t323;
  31021. mat43.e33 = t333;
  31022. if(_this46.sizeMat4 == _this46.stackMat4.length) {
  31023. var newLength14 = _this46.sizeMat4 << 1;
  31024. var this15 = new Array(newLength14);
  31025. var newArray14 = this15;
  31026. var _g24 = 0;
  31027. var _g114 = _this46.sizeMat4;
  31028. while(_g24 < _g114) {
  31029. var i14 = _g24++;
  31030. newArray14[i14] = _this46.stackMat4[i14];
  31031. _this46.stackMat4[i14] = null;
  31032. }
  31033. _this46.stackMat4 = newArray14;
  31034. }
  31035. _this46.stackMat4[_this46.sizeMat4++] = mat43;
  31036. }
  31037. if(quat3 != null) {
  31038. var tx21 = 0;
  31039. var ty21 = 0;
  31040. var tz21 = 0;
  31041. var tw3 = 1;
  31042. quat3.x = tx21;
  31043. quat3.y = ty21;
  31044. quat3.z = tz21;
  31045. quat3.w = tw3;
  31046. if(_this46.sizeQuat == _this46.stackQuat.length) {
  31047. var newLength15 = _this46.sizeQuat << 1;
  31048. var this16 = new Array(newLength15);
  31049. var newArray15 = this16;
  31050. var _g25 = 0;
  31051. var _g115 = _this46.sizeQuat;
  31052. while(_g25 < _g115) {
  31053. var i15 = _g25++;
  31054. newArray15[i15] = _this46.stackQuat[i15];
  31055. _this46.stackQuat[i15] = null;
  31056. }
  31057. _this46.stackQuat = newArray15;
  31058. }
  31059. _this46.stackQuat[_this46.sizeQuat++] = quat3;
  31060. }
  31061. var _this47 = this.p;
  31062. var mat34 = null;
  31063. var mat44 = null;
  31064. var quat4 = null;
  31065. if(bottom1 != null) {
  31066. bottom1.zero();
  31067. if(_this47.sizeVec3 == _this47.stackVec3.length) {
  31068. var newLength16 = _this47.sizeVec3 << 1;
  31069. var this17 = new Array(newLength16);
  31070. var newArray16 = this17;
  31071. var _g26 = 0;
  31072. var _g116 = _this47.sizeVec3;
  31073. while(_g26 < _g116) {
  31074. var i16 = _g26++;
  31075. newArray16[i16] = _this47.stackVec3[i16];
  31076. _this47.stackVec3[i16] = null;
  31077. }
  31078. _this47.stackVec3 = newArray16;
  31079. }
  31080. _this47.stackVec3[_this47.sizeVec3++] = bottom1;
  31081. }
  31082. if(mat34 != null) {
  31083. var t008 = 1;
  31084. var t018 = 0;
  31085. var t028 = 0;
  31086. var t108 = 0;
  31087. var t118 = 1;
  31088. var t128 = 0;
  31089. var t208 = 0;
  31090. var t218 = 0;
  31091. var t228 = 1;
  31092. mat34.e00 = t008;
  31093. mat34.e01 = t018;
  31094. mat34.e02 = t028;
  31095. mat34.e10 = t108;
  31096. mat34.e11 = t118;
  31097. mat34.e12 = t128;
  31098. mat34.e20 = t208;
  31099. mat34.e21 = t218;
  31100. mat34.e22 = t228;
  31101. if(_this47.sizeMat3 == _this47.stackMat3.length) {
  31102. var newLength17 = _this47.sizeMat3 << 1;
  31103. var this18 = new Array(newLength17);
  31104. var newArray17 = this18;
  31105. var _g27 = 0;
  31106. var _g117 = _this47.sizeMat3;
  31107. while(_g27 < _g117) {
  31108. var i17 = _g27++;
  31109. newArray17[i17] = _this47.stackMat3[i17];
  31110. _this47.stackMat3[i17] = null;
  31111. }
  31112. _this47.stackMat3 = newArray17;
  31113. }
  31114. _this47.stackMat3[_this47.sizeMat3++] = mat34;
  31115. }
  31116. if(mat44 != null) {
  31117. var t009 = 1;
  31118. var t019 = 0;
  31119. var t029 = 0;
  31120. var t034 = 0;
  31121. var t109 = 0;
  31122. var t119 = 1;
  31123. var t129 = 0;
  31124. var t134 = 0;
  31125. var t209 = 0;
  31126. var t219 = 0;
  31127. var t229 = 1;
  31128. var t234 = 0;
  31129. var t304 = 0;
  31130. var t314 = 0;
  31131. var t324 = 0;
  31132. var t334 = 1;
  31133. mat44.e00 = t009;
  31134. mat44.e01 = t019;
  31135. mat44.e02 = t029;
  31136. mat44.e03 = t034;
  31137. mat44.e10 = t109;
  31138. mat44.e11 = t119;
  31139. mat44.e12 = t129;
  31140. mat44.e13 = t134;
  31141. mat44.e20 = t209;
  31142. mat44.e21 = t219;
  31143. mat44.e22 = t229;
  31144. mat44.e23 = t234;
  31145. mat44.e30 = t304;
  31146. mat44.e31 = t314;
  31147. mat44.e32 = t324;
  31148. mat44.e33 = t334;
  31149. if(_this47.sizeMat4 == _this47.stackMat4.length) {
  31150. var newLength18 = _this47.sizeMat4 << 1;
  31151. var this19 = new Array(newLength18);
  31152. var newArray18 = this19;
  31153. var _g28 = 0;
  31154. var _g118 = _this47.sizeMat4;
  31155. while(_g28 < _g118) {
  31156. var i18 = _g28++;
  31157. newArray18[i18] = _this47.stackMat4[i18];
  31158. _this47.stackMat4[i18] = null;
  31159. }
  31160. _this47.stackMat4 = newArray18;
  31161. }
  31162. _this47.stackMat4[_this47.sizeMat4++] = mat44;
  31163. }
  31164. if(quat4 != null) {
  31165. var tx22 = 0;
  31166. var ty22 = 0;
  31167. var tz22 = 0;
  31168. var tw4 = 1;
  31169. quat4.x = tx22;
  31170. quat4.y = ty22;
  31171. quat4.z = tz22;
  31172. quat4.w = tw4;
  31173. if(_this47.sizeQuat == _this47.stackQuat.length) {
  31174. var newLength19 = _this47.sizeQuat << 1;
  31175. var this20 = new Array(newLength19);
  31176. var newArray19 = this20;
  31177. var _g29 = 0;
  31178. var _g119 = _this47.sizeQuat;
  31179. while(_g29 < _g119) {
  31180. var i19 = _g29++;
  31181. newArray19[i19] = _this47.stackQuat[i19];
  31182. _this47.stackQuat[i19] = null;
  31183. }
  31184. _this47.stackQuat = newArray19;
  31185. }
  31186. _this47.stackQuat[_this47.sizeQuat++] = quat4;
  31187. }
  31188. var _this48 = this.p;
  31189. var mat35 = null;
  31190. var mat45 = null;
  31191. var quat5 = null;
  31192. if(bottom2 != null) {
  31193. bottom2.zero();
  31194. if(_this48.sizeVec3 == _this48.stackVec3.length) {
  31195. var newLength20 = _this48.sizeVec3 << 1;
  31196. var this21 = new Array(newLength20);
  31197. var newArray20 = this21;
  31198. var _g30 = 0;
  31199. var _g120 = _this48.sizeVec3;
  31200. while(_g30 < _g120) {
  31201. var i20 = _g30++;
  31202. newArray20[i20] = _this48.stackVec3[i20];
  31203. _this48.stackVec3[i20] = null;
  31204. }
  31205. _this48.stackVec3 = newArray20;
  31206. }
  31207. _this48.stackVec3[_this48.sizeVec3++] = bottom2;
  31208. }
  31209. if(mat35 != null) {
  31210. var t0010 = 1;
  31211. var t0110 = 0;
  31212. var t0210 = 0;
  31213. var t1010 = 0;
  31214. var t1110 = 1;
  31215. var t1210 = 0;
  31216. var t2010 = 0;
  31217. var t2110 = 0;
  31218. var t2210 = 1;
  31219. mat35.e00 = t0010;
  31220. mat35.e01 = t0110;
  31221. mat35.e02 = t0210;
  31222. mat35.e10 = t1010;
  31223. mat35.e11 = t1110;
  31224. mat35.e12 = t1210;
  31225. mat35.e20 = t2010;
  31226. mat35.e21 = t2110;
  31227. mat35.e22 = t2210;
  31228. if(_this48.sizeMat3 == _this48.stackMat3.length) {
  31229. var newLength21 = _this48.sizeMat3 << 1;
  31230. var this22 = new Array(newLength21);
  31231. var newArray21 = this22;
  31232. var _g31 = 0;
  31233. var _g121 = _this48.sizeMat3;
  31234. while(_g31 < _g121) {
  31235. var i21 = _g31++;
  31236. newArray21[i21] = _this48.stackMat3[i21];
  31237. _this48.stackMat3[i21] = null;
  31238. }
  31239. _this48.stackMat3 = newArray21;
  31240. }
  31241. _this48.stackMat3[_this48.sizeMat3++] = mat35;
  31242. }
  31243. if(mat45 != null) {
  31244. var t0011 = 1;
  31245. var t0111 = 0;
  31246. var t0211 = 0;
  31247. var t035 = 0;
  31248. var t1011 = 0;
  31249. var t1111 = 1;
  31250. var t1211 = 0;
  31251. var t135 = 0;
  31252. var t2011 = 0;
  31253. var t2111 = 0;
  31254. var t2211 = 1;
  31255. var t235 = 0;
  31256. var t305 = 0;
  31257. var t315 = 0;
  31258. var t325 = 0;
  31259. var t335 = 1;
  31260. mat45.e00 = t0011;
  31261. mat45.e01 = t0111;
  31262. mat45.e02 = t0211;
  31263. mat45.e03 = t035;
  31264. mat45.e10 = t1011;
  31265. mat45.e11 = t1111;
  31266. mat45.e12 = t1211;
  31267. mat45.e13 = t135;
  31268. mat45.e20 = t2011;
  31269. mat45.e21 = t2111;
  31270. mat45.e22 = t2211;
  31271. mat45.e23 = t235;
  31272. mat45.e30 = t305;
  31273. mat45.e31 = t315;
  31274. mat45.e32 = t325;
  31275. mat45.e33 = t335;
  31276. if(_this48.sizeMat4 == _this48.stackMat4.length) {
  31277. var newLength22 = _this48.sizeMat4 << 1;
  31278. var this23 = new Array(newLength22);
  31279. var newArray22 = this23;
  31280. var _g32 = 0;
  31281. var _g122 = _this48.sizeMat4;
  31282. while(_g32 < _g122) {
  31283. var i22 = _g32++;
  31284. newArray22[i22] = _this48.stackMat4[i22];
  31285. _this48.stackMat4[i22] = null;
  31286. }
  31287. _this48.stackMat4 = newArray22;
  31288. }
  31289. _this48.stackMat4[_this48.sizeMat4++] = mat45;
  31290. }
  31291. if(quat5 != null) {
  31292. var tx23 = 0;
  31293. var ty23 = 0;
  31294. var tz23 = 0;
  31295. var tw5 = 1;
  31296. quat5.x = tx23;
  31297. quat5.y = ty23;
  31298. quat5.z = tz23;
  31299. quat5.w = tw5;
  31300. if(_this48.sizeQuat == _this48.stackQuat.length) {
  31301. var newLength23 = _this48.sizeQuat << 1;
  31302. var this24 = new Array(newLength23);
  31303. var newArray23 = this24;
  31304. var _g33 = 0;
  31305. var _g123 = _this48.sizeQuat;
  31306. while(_g33 < _g123) {
  31307. var i23 = _g33++;
  31308. newArray23[i23] = _this48.stackQuat[i23];
  31309. _this48.stackQuat[i23] = null;
  31310. }
  31311. _this48.stackQuat = newArray23;
  31312. }
  31313. _this48.stackQuat[_this48.sizeQuat++] = quat5;
  31314. }
  31315. var _this49 = this.p;
  31316. var mat36 = null;
  31317. var mat46 = null;
  31318. var quat6 = null;
  31319. if(bottom3 != null) {
  31320. bottom3.zero();
  31321. if(_this49.sizeVec3 == _this49.stackVec3.length) {
  31322. var newLength24 = _this49.sizeVec3 << 1;
  31323. var this25 = new Array(newLength24);
  31324. var newArray24 = this25;
  31325. var _g34 = 0;
  31326. var _g124 = _this49.sizeVec3;
  31327. while(_g34 < _g124) {
  31328. var i24 = _g34++;
  31329. newArray24[i24] = _this49.stackVec3[i24];
  31330. _this49.stackVec3[i24] = null;
  31331. }
  31332. _this49.stackVec3 = newArray24;
  31333. }
  31334. _this49.stackVec3[_this49.sizeVec3++] = bottom3;
  31335. }
  31336. if(mat36 != null) {
  31337. var t0012 = 1;
  31338. var t0112 = 0;
  31339. var t0212 = 0;
  31340. var t1012 = 0;
  31341. var t1112 = 1;
  31342. var t1212 = 0;
  31343. var t2012 = 0;
  31344. var t2112 = 0;
  31345. var t2212 = 1;
  31346. mat36.e00 = t0012;
  31347. mat36.e01 = t0112;
  31348. mat36.e02 = t0212;
  31349. mat36.e10 = t1012;
  31350. mat36.e11 = t1112;
  31351. mat36.e12 = t1212;
  31352. mat36.e20 = t2012;
  31353. mat36.e21 = t2112;
  31354. mat36.e22 = t2212;
  31355. if(_this49.sizeMat3 == _this49.stackMat3.length) {
  31356. var newLength25 = _this49.sizeMat3 << 1;
  31357. var this26 = new Array(newLength25);
  31358. var newArray25 = this26;
  31359. var _g35 = 0;
  31360. var _g125 = _this49.sizeMat3;
  31361. while(_g35 < _g125) {
  31362. var i25 = _g35++;
  31363. newArray25[i25] = _this49.stackMat3[i25];
  31364. _this49.stackMat3[i25] = null;
  31365. }
  31366. _this49.stackMat3 = newArray25;
  31367. }
  31368. _this49.stackMat3[_this49.sizeMat3++] = mat36;
  31369. }
  31370. if(mat46 != null) {
  31371. var t0013 = 1;
  31372. var t0113 = 0;
  31373. var t0213 = 0;
  31374. var t036 = 0;
  31375. var t1013 = 0;
  31376. var t1113 = 1;
  31377. var t1213 = 0;
  31378. var t136 = 0;
  31379. var t2013 = 0;
  31380. var t2113 = 0;
  31381. var t2213 = 1;
  31382. var t236 = 0;
  31383. var t306 = 0;
  31384. var t316 = 0;
  31385. var t326 = 0;
  31386. var t336 = 1;
  31387. mat46.e00 = t0013;
  31388. mat46.e01 = t0113;
  31389. mat46.e02 = t0213;
  31390. mat46.e03 = t036;
  31391. mat46.e10 = t1013;
  31392. mat46.e11 = t1113;
  31393. mat46.e12 = t1213;
  31394. mat46.e13 = t136;
  31395. mat46.e20 = t2013;
  31396. mat46.e21 = t2113;
  31397. mat46.e22 = t2213;
  31398. mat46.e23 = t236;
  31399. mat46.e30 = t306;
  31400. mat46.e31 = t316;
  31401. mat46.e32 = t326;
  31402. mat46.e33 = t336;
  31403. if(_this49.sizeMat4 == _this49.stackMat4.length) {
  31404. var newLength26 = _this49.sizeMat4 << 1;
  31405. var this27 = new Array(newLength26);
  31406. var newArray26 = this27;
  31407. var _g36 = 0;
  31408. var _g126 = _this49.sizeMat4;
  31409. while(_g36 < _g126) {
  31410. var i26 = _g36++;
  31411. newArray26[i26] = _this49.stackMat4[i26];
  31412. _this49.stackMat4[i26] = null;
  31413. }
  31414. _this49.stackMat4 = newArray26;
  31415. }
  31416. _this49.stackMat4[_this49.sizeMat4++] = mat46;
  31417. }
  31418. if(quat6 != null) {
  31419. var tx24 = 0;
  31420. var ty24 = 0;
  31421. var tz24 = 0;
  31422. var tw6 = 1;
  31423. quat6.x = tx24;
  31424. quat6.y = ty24;
  31425. quat6.z = tz24;
  31426. quat6.w = tw6;
  31427. if(_this49.sizeQuat == _this49.stackQuat.length) {
  31428. var newLength27 = _this49.sizeQuat << 1;
  31429. var this28 = new Array(newLength27);
  31430. var newArray27 = this28;
  31431. var _g37 = 0;
  31432. var _g127 = _this49.sizeQuat;
  31433. while(_g37 < _g127) {
  31434. var i27 = _g37++;
  31435. newArray27[i27] = _this49.stackQuat[i27];
  31436. _this49.stackQuat[i27] = null;
  31437. }
  31438. _this49.stackQuat = newArray27;
  31439. }
  31440. _this49.stackQuat[_this49.sizeQuat++] = quat6;
  31441. }
  31442. var _this50 = this.p;
  31443. var mat37 = null;
  31444. var mat47 = null;
  31445. var quat7 = null;
  31446. if(bottom4 != null) {
  31447. bottom4.zero();
  31448. if(_this50.sizeVec3 == _this50.stackVec3.length) {
  31449. var newLength28 = _this50.sizeVec3 << 1;
  31450. var this29 = new Array(newLength28);
  31451. var newArray28 = this29;
  31452. var _g38 = 0;
  31453. var _g128 = _this50.sizeVec3;
  31454. while(_g38 < _g128) {
  31455. var i28 = _g38++;
  31456. newArray28[i28] = _this50.stackVec3[i28];
  31457. _this50.stackVec3[i28] = null;
  31458. }
  31459. _this50.stackVec3 = newArray28;
  31460. }
  31461. _this50.stackVec3[_this50.sizeVec3++] = bottom4;
  31462. }
  31463. if(mat37 != null) {
  31464. var t0014 = 1;
  31465. var t0114 = 0;
  31466. var t0214 = 0;
  31467. var t1014 = 0;
  31468. var t1114 = 1;
  31469. var t1214 = 0;
  31470. var t2014 = 0;
  31471. var t2114 = 0;
  31472. var t2214 = 1;
  31473. mat37.e00 = t0014;
  31474. mat37.e01 = t0114;
  31475. mat37.e02 = t0214;
  31476. mat37.e10 = t1014;
  31477. mat37.e11 = t1114;
  31478. mat37.e12 = t1214;
  31479. mat37.e20 = t2014;
  31480. mat37.e21 = t2114;
  31481. mat37.e22 = t2214;
  31482. if(_this50.sizeMat3 == _this50.stackMat3.length) {
  31483. var newLength29 = _this50.sizeMat3 << 1;
  31484. var this30 = new Array(newLength29);
  31485. var newArray29 = this30;
  31486. var _g39 = 0;
  31487. var _g129 = _this50.sizeMat3;
  31488. while(_g39 < _g129) {
  31489. var i29 = _g39++;
  31490. newArray29[i29] = _this50.stackMat3[i29];
  31491. _this50.stackMat3[i29] = null;
  31492. }
  31493. _this50.stackMat3 = newArray29;
  31494. }
  31495. _this50.stackMat3[_this50.sizeMat3++] = mat37;
  31496. }
  31497. if(mat47 != null) {
  31498. var t0015 = 1;
  31499. var t0115 = 0;
  31500. var t0215 = 0;
  31501. var t037 = 0;
  31502. var t1015 = 0;
  31503. var t1115 = 1;
  31504. var t1215 = 0;
  31505. var t137 = 0;
  31506. var t2015 = 0;
  31507. var t2115 = 0;
  31508. var t2215 = 1;
  31509. var t237 = 0;
  31510. var t307 = 0;
  31511. var t317 = 0;
  31512. var t327 = 0;
  31513. var t337 = 1;
  31514. mat47.e00 = t0015;
  31515. mat47.e01 = t0115;
  31516. mat47.e02 = t0215;
  31517. mat47.e03 = t037;
  31518. mat47.e10 = t1015;
  31519. mat47.e11 = t1115;
  31520. mat47.e12 = t1215;
  31521. mat47.e13 = t137;
  31522. mat47.e20 = t2015;
  31523. mat47.e21 = t2115;
  31524. mat47.e22 = t2215;
  31525. mat47.e23 = t237;
  31526. mat47.e30 = t307;
  31527. mat47.e31 = t317;
  31528. mat47.e32 = t327;
  31529. mat47.e33 = t337;
  31530. if(_this50.sizeMat4 == _this50.stackMat4.length) {
  31531. var newLength30 = _this50.sizeMat4 << 1;
  31532. var this31 = new Array(newLength30);
  31533. var newArray30 = this31;
  31534. var _g40 = 0;
  31535. var _g130 = _this50.sizeMat4;
  31536. while(_g40 < _g130) {
  31537. var i30 = _g40++;
  31538. newArray30[i30] = _this50.stackMat4[i30];
  31539. _this50.stackMat4[i30] = null;
  31540. }
  31541. _this50.stackMat4 = newArray30;
  31542. }
  31543. _this50.stackMat4[_this50.sizeMat4++] = mat47;
  31544. }
  31545. if(quat7 != null) {
  31546. var tx25 = 0;
  31547. var ty25 = 0;
  31548. var tz25 = 0;
  31549. var tw7 = 1;
  31550. quat7.x = tx25;
  31551. quat7.y = ty25;
  31552. quat7.z = tz25;
  31553. quat7.w = tw7;
  31554. if(_this50.sizeQuat == _this50.stackQuat.length) {
  31555. var newLength31 = _this50.sizeQuat << 1;
  31556. var this32 = new Array(newLength31);
  31557. var newArray31 = this32;
  31558. var _g41 = 0;
  31559. var _g131 = _this50.sizeQuat;
  31560. while(_g41 < _g131) {
  31561. var i31 = _g41++;
  31562. newArray31[i31] = _this50.stackQuat[i31];
  31563. _this50.stackQuat[i31] = null;
  31564. }
  31565. _this50.stackQuat = newArray31;
  31566. }
  31567. _this50.stackQuat[_this50.sizeQuat++] = quat7;
  31568. }
  31569. } else {
  31570. var _g42 = 0;
  31571. while(_g42 < 8) {
  31572. var i32 = _g42++;
  31573. var _this51 = this.tmpCircleNorms[i32];
  31574. var v1 = this.circleCoords[i32];
  31575. _this51.x = v1.x;
  31576. _this51.y = v1.y;
  31577. _this51.z = v1.z;
  31578. var _this52 = _this51;
  31579. var tx26 = _this52.x * m.e00 + _this52.y * m.e01 + _this52.z * m.e02;
  31580. var ty26 = _this52.x * m.e10 + _this52.y * m.e11 + _this52.z * m.e12;
  31581. var tz26 = _this52.x * m.e20 + _this52.y * m.e21 + _this52.z * m.e22;
  31582. _this52.x = tx26;
  31583. _this52.y = ty26;
  31584. _this52.z = tz26;
  31585. var _this53 = this.tmpCircleVerts1[i32];
  31586. var v2 = this.tmpCircleNorms[i32];
  31587. _this53.x = v2.x;
  31588. _this53.y = v2.y;
  31589. _this53.z = v2.z;
  31590. var _this54 = _this53;
  31591. var tx27 = _this54.x * radius;
  31592. var ty27 = _this54.y * radius;
  31593. var tz27 = _this54.z * radius;
  31594. _this54.x = tx27;
  31595. _this54.y = ty27;
  31596. _this54.z = tz27;
  31597. var _this55 = _this54;
  31598. var tx28 = _this55.x + o.x;
  31599. var ty28 = _this55.y + o.y;
  31600. var tz28 = _this55.z + o.z;
  31601. _this55.x = tx28;
  31602. _this55.y = ty28;
  31603. _this55.z = tz28;
  31604. var _this56 = this.tmpCircleVerts2[i32];
  31605. var v3 = this.tmpCircleVerts1[i32];
  31606. _this56.x = v3.x;
  31607. _this56.y = v3.y;
  31608. _this56.z = v3.z;
  31609. var _this57 = this.tmpCircleVerts1[i32];
  31610. var tx29 = _this57.x + ey.x * halfHeight;
  31611. var ty29 = _this57.y + ey.y * halfHeight;
  31612. var tz29 = _this57.z + ey.z * halfHeight;
  31613. _this57.x = tx29;
  31614. _this57.y = ty29;
  31615. _this57.z = tz29;
  31616. var _this58 = this.tmpCircleVerts2[i32];
  31617. var s5 = -halfHeight;
  31618. var tx30 = _this58.x + ey.x * s5;
  31619. var ty30 = _this58.y + ey.y * s5;
  31620. var tz30 = _this58.z + ey.z * s5;
  31621. _this58.x = tx30;
  31622. _this58.y = ty30;
  31623. _this58.z = tz30;
  31624. }
  31625. var _g132 = 0;
  31626. while(_g132 < 8) {
  31627. var i33 = _g132++;
  31628. var n3;
  31629. var n4;
  31630. var v11 = top;
  31631. var v21 = this.tmpCircleVerts1[i33];
  31632. var v31 = this.tmpCircleVerts1[(i33 + 1) % 8];
  31633. var n1 = ey;
  31634. this.triangle(v11,v21,v31,n1,n1,n1,color);
  31635. v11 = bottom;
  31636. v21 = this.tmpCircleVerts2[(i33 + 1) % 8];
  31637. v31 = this.tmpCircleVerts2[i33];
  31638. var _this59 = this.p;
  31639. var _this60 = _this59.sizeVec3 == 0 ? new oimo.common.Vec3() : _this59.stackVec3[--_this59.sizeVec3];
  31640. _this60.x = ey.x;
  31641. _this60.y = ey.y;
  31642. _this60.z = ey.z;
  31643. var _this61 = _this60;
  31644. var tx31 = -_this61.x;
  31645. var ty31 = -_this61.y;
  31646. var tz31 = -_this61.z;
  31647. _this61.x = tx31;
  31648. _this61.y = ty31;
  31649. _this61.z = tz31;
  31650. n1 = _this61;
  31651. this.triangle(v11,v21,v31,n1,n1,n1,color);
  31652. var _this62 = this.p;
  31653. var mat38 = null;
  31654. var mat48 = null;
  31655. var quat8 = null;
  31656. if(n1 != null) {
  31657. n1.zero();
  31658. if(_this62.sizeVec3 == _this62.stackVec3.length) {
  31659. var newLength32 = _this62.sizeVec3 << 1;
  31660. var this33 = new Array(newLength32);
  31661. var newArray32 = this33;
  31662. var _g43 = 0;
  31663. var _g133 = _this62.sizeVec3;
  31664. while(_g43 < _g133) {
  31665. var i34 = _g43++;
  31666. newArray32[i34] = _this62.stackVec3[i34];
  31667. _this62.stackVec3[i34] = null;
  31668. }
  31669. _this62.stackVec3 = newArray32;
  31670. }
  31671. _this62.stackVec3[_this62.sizeVec3++] = n1;
  31672. }
  31673. if(mat38 != null) {
  31674. var t0016 = 1;
  31675. var t0116 = 0;
  31676. var t0216 = 0;
  31677. var t1016 = 0;
  31678. var t1116 = 1;
  31679. var t1216 = 0;
  31680. var t2016 = 0;
  31681. var t2116 = 0;
  31682. var t2216 = 1;
  31683. mat38.e00 = t0016;
  31684. mat38.e01 = t0116;
  31685. mat38.e02 = t0216;
  31686. mat38.e10 = t1016;
  31687. mat38.e11 = t1116;
  31688. mat38.e12 = t1216;
  31689. mat38.e20 = t2016;
  31690. mat38.e21 = t2116;
  31691. mat38.e22 = t2216;
  31692. if(_this62.sizeMat3 == _this62.stackMat3.length) {
  31693. var newLength33 = _this62.sizeMat3 << 1;
  31694. var this34 = new Array(newLength33);
  31695. var newArray33 = this34;
  31696. var _g44 = 0;
  31697. var _g134 = _this62.sizeMat3;
  31698. while(_g44 < _g134) {
  31699. var i35 = _g44++;
  31700. newArray33[i35] = _this62.stackMat3[i35];
  31701. _this62.stackMat3[i35] = null;
  31702. }
  31703. _this62.stackMat3 = newArray33;
  31704. }
  31705. _this62.stackMat3[_this62.sizeMat3++] = mat38;
  31706. }
  31707. if(mat48 != null) {
  31708. var t0017 = 1;
  31709. var t0117 = 0;
  31710. var t0217 = 0;
  31711. var t038 = 0;
  31712. var t1017 = 0;
  31713. var t1117 = 1;
  31714. var t1217 = 0;
  31715. var t138 = 0;
  31716. var t2017 = 0;
  31717. var t2117 = 0;
  31718. var t2217 = 1;
  31719. var t238 = 0;
  31720. var t308 = 0;
  31721. var t318 = 0;
  31722. var t328 = 0;
  31723. var t338 = 1;
  31724. mat48.e00 = t0017;
  31725. mat48.e01 = t0117;
  31726. mat48.e02 = t0217;
  31727. mat48.e03 = t038;
  31728. mat48.e10 = t1017;
  31729. mat48.e11 = t1117;
  31730. mat48.e12 = t1217;
  31731. mat48.e13 = t138;
  31732. mat48.e20 = t2017;
  31733. mat48.e21 = t2117;
  31734. mat48.e22 = t2217;
  31735. mat48.e23 = t238;
  31736. mat48.e30 = t308;
  31737. mat48.e31 = t318;
  31738. mat48.e32 = t328;
  31739. mat48.e33 = t338;
  31740. if(_this62.sizeMat4 == _this62.stackMat4.length) {
  31741. var newLength34 = _this62.sizeMat4 << 1;
  31742. var this35 = new Array(newLength34);
  31743. var newArray34 = this35;
  31744. var _g45 = 0;
  31745. var _g135 = _this62.sizeMat4;
  31746. while(_g45 < _g135) {
  31747. var i36 = _g45++;
  31748. newArray34[i36] = _this62.stackMat4[i36];
  31749. _this62.stackMat4[i36] = null;
  31750. }
  31751. _this62.stackMat4 = newArray34;
  31752. }
  31753. _this62.stackMat4[_this62.sizeMat4++] = mat48;
  31754. }
  31755. if(quat8 != null) {
  31756. var tx32 = 0;
  31757. var ty32 = 0;
  31758. var tz32 = 0;
  31759. var tw8 = 1;
  31760. quat8.x = tx32;
  31761. quat8.y = ty32;
  31762. quat8.z = tz32;
  31763. quat8.w = tw8;
  31764. if(_this62.sizeQuat == _this62.stackQuat.length) {
  31765. var newLength35 = _this62.sizeQuat << 1;
  31766. var this36 = new Array(newLength35);
  31767. var newArray35 = this36;
  31768. var _g46 = 0;
  31769. var _g136 = _this62.sizeQuat;
  31770. while(_g46 < _g136) {
  31771. var i37 = _g46++;
  31772. newArray35[i37] = _this62.stackQuat[i37];
  31773. _this62.stackQuat[i37] = null;
  31774. }
  31775. _this62.stackQuat = newArray35;
  31776. }
  31777. _this62.stackQuat[_this62.sizeQuat++] = quat8;
  31778. }
  31779. v11 = this.tmpCircleVerts1[i33];
  31780. v21 = this.tmpCircleVerts2[i33];
  31781. v31 = this.tmpCircleVerts2[(i33 + 1) % 8];
  31782. var v4 = this.tmpCircleVerts1[(i33 + 1) % 8];
  31783. n1 = this.tmpCircleNorms[i33];
  31784. var n2 = this.tmpCircleNorms[(i33 + 1) % 8];
  31785. this.rect(v11,v21,v31,v4,n1,n1,n2,n2,color);
  31786. }
  31787. }
  31788. var _this63 = this.p;
  31789. var mat39 = null;
  31790. var mat49 = null;
  31791. var quat9 = null;
  31792. if(top != null) {
  31793. top.zero();
  31794. if(_this63.sizeVec3 == _this63.stackVec3.length) {
  31795. var newLength36 = _this63.sizeVec3 << 1;
  31796. var this37 = new Array(newLength36);
  31797. var newArray36 = this37;
  31798. var _g47 = 0;
  31799. var _g137 = _this63.sizeVec3;
  31800. while(_g47 < _g137) {
  31801. var i38 = _g47++;
  31802. newArray36[i38] = _this63.stackVec3[i38];
  31803. _this63.stackVec3[i38] = null;
  31804. }
  31805. _this63.stackVec3 = newArray36;
  31806. }
  31807. _this63.stackVec3[_this63.sizeVec3++] = top;
  31808. }
  31809. if(mat39 != null) {
  31810. var t0018 = 1;
  31811. var t0118 = 0;
  31812. var t0218 = 0;
  31813. var t1018 = 0;
  31814. var t1118 = 1;
  31815. var t1218 = 0;
  31816. var t2018 = 0;
  31817. var t2118 = 0;
  31818. var t2218 = 1;
  31819. mat39.e00 = t0018;
  31820. mat39.e01 = t0118;
  31821. mat39.e02 = t0218;
  31822. mat39.e10 = t1018;
  31823. mat39.e11 = t1118;
  31824. mat39.e12 = t1218;
  31825. mat39.e20 = t2018;
  31826. mat39.e21 = t2118;
  31827. mat39.e22 = t2218;
  31828. if(_this63.sizeMat3 == _this63.stackMat3.length) {
  31829. var newLength37 = _this63.sizeMat3 << 1;
  31830. var this38 = new Array(newLength37);
  31831. var newArray37 = this38;
  31832. var _g48 = 0;
  31833. var _g138 = _this63.sizeMat3;
  31834. while(_g48 < _g138) {
  31835. var i39 = _g48++;
  31836. newArray37[i39] = _this63.stackMat3[i39];
  31837. _this63.stackMat3[i39] = null;
  31838. }
  31839. _this63.stackMat3 = newArray37;
  31840. }
  31841. _this63.stackMat3[_this63.sizeMat3++] = mat39;
  31842. }
  31843. if(mat49 != null) {
  31844. var t0019 = 1;
  31845. var t0119 = 0;
  31846. var t0219 = 0;
  31847. var t039 = 0;
  31848. var t1019 = 0;
  31849. var t1119 = 1;
  31850. var t1219 = 0;
  31851. var t139 = 0;
  31852. var t2019 = 0;
  31853. var t2119 = 0;
  31854. var t2219 = 1;
  31855. var t239 = 0;
  31856. var t309 = 0;
  31857. var t319 = 0;
  31858. var t329 = 0;
  31859. var t339 = 1;
  31860. mat49.e00 = t0019;
  31861. mat49.e01 = t0119;
  31862. mat49.e02 = t0219;
  31863. mat49.e03 = t039;
  31864. mat49.e10 = t1019;
  31865. mat49.e11 = t1119;
  31866. mat49.e12 = t1219;
  31867. mat49.e13 = t139;
  31868. mat49.e20 = t2019;
  31869. mat49.e21 = t2119;
  31870. mat49.e22 = t2219;
  31871. mat49.e23 = t239;
  31872. mat49.e30 = t309;
  31873. mat49.e31 = t319;
  31874. mat49.e32 = t329;
  31875. mat49.e33 = t339;
  31876. if(_this63.sizeMat4 == _this63.stackMat4.length) {
  31877. var newLength38 = _this63.sizeMat4 << 1;
  31878. var this39 = new Array(newLength38);
  31879. var newArray38 = this39;
  31880. var _g49 = 0;
  31881. var _g139 = _this63.sizeMat4;
  31882. while(_g49 < _g139) {
  31883. var i40 = _g49++;
  31884. newArray38[i40] = _this63.stackMat4[i40];
  31885. _this63.stackMat4[i40] = null;
  31886. }
  31887. _this63.stackMat4 = newArray38;
  31888. }
  31889. _this63.stackMat4[_this63.sizeMat4++] = mat49;
  31890. }
  31891. if(quat9 != null) {
  31892. var tx33 = 0;
  31893. var ty33 = 0;
  31894. var tz33 = 0;
  31895. var tw9 = 1;
  31896. quat9.x = tx33;
  31897. quat9.y = ty33;
  31898. quat9.z = tz33;
  31899. quat9.w = tw9;
  31900. if(_this63.sizeQuat == _this63.stackQuat.length) {
  31901. var newLength39 = _this63.sizeQuat << 1;
  31902. var this40 = new Array(newLength39);
  31903. var newArray39 = this40;
  31904. var _g50 = 0;
  31905. var _g140 = _this63.sizeQuat;
  31906. while(_g50 < _g140) {
  31907. var i41 = _g50++;
  31908. newArray39[i41] = _this63.stackQuat[i41];
  31909. _this63.stackQuat[i41] = null;
  31910. }
  31911. _this63.stackQuat = newArray39;
  31912. }
  31913. _this63.stackQuat[_this63.sizeQuat++] = quat9;
  31914. }
  31915. var _this64 = this.p;
  31916. var mat310 = null;
  31917. var mat410 = null;
  31918. var quat10 = null;
  31919. if(bottom != null) {
  31920. bottom.zero();
  31921. if(_this64.sizeVec3 == _this64.stackVec3.length) {
  31922. var newLength40 = _this64.sizeVec3 << 1;
  31923. var this41 = new Array(newLength40);
  31924. var newArray40 = this41;
  31925. var _g51 = 0;
  31926. var _g141 = _this64.sizeVec3;
  31927. while(_g51 < _g141) {
  31928. var i42 = _g51++;
  31929. newArray40[i42] = _this64.stackVec3[i42];
  31930. _this64.stackVec3[i42] = null;
  31931. }
  31932. _this64.stackVec3 = newArray40;
  31933. }
  31934. _this64.stackVec3[_this64.sizeVec3++] = bottom;
  31935. }
  31936. if(mat310 != null) {
  31937. var t0020 = 1;
  31938. var t0120 = 0;
  31939. var t0220 = 0;
  31940. var t1020 = 0;
  31941. var t1120 = 1;
  31942. var t1220 = 0;
  31943. var t2020 = 0;
  31944. var t2120 = 0;
  31945. var t2220 = 1;
  31946. mat310.e00 = t0020;
  31947. mat310.e01 = t0120;
  31948. mat310.e02 = t0220;
  31949. mat310.e10 = t1020;
  31950. mat310.e11 = t1120;
  31951. mat310.e12 = t1220;
  31952. mat310.e20 = t2020;
  31953. mat310.e21 = t2120;
  31954. mat310.e22 = t2220;
  31955. if(_this64.sizeMat3 == _this64.stackMat3.length) {
  31956. var newLength41 = _this64.sizeMat3 << 1;
  31957. var this42 = new Array(newLength41);
  31958. var newArray41 = this42;
  31959. var _g52 = 0;
  31960. var _g142 = _this64.sizeMat3;
  31961. while(_g52 < _g142) {
  31962. var i43 = _g52++;
  31963. newArray41[i43] = _this64.stackMat3[i43];
  31964. _this64.stackMat3[i43] = null;
  31965. }
  31966. _this64.stackMat3 = newArray41;
  31967. }
  31968. _this64.stackMat3[_this64.sizeMat3++] = mat310;
  31969. }
  31970. if(mat410 != null) {
  31971. var t0021 = 1;
  31972. var t0121 = 0;
  31973. var t0221 = 0;
  31974. var t0310 = 0;
  31975. var t1021 = 0;
  31976. var t1121 = 1;
  31977. var t1221 = 0;
  31978. var t1310 = 0;
  31979. var t2021 = 0;
  31980. var t2121 = 0;
  31981. var t2221 = 1;
  31982. var t2310 = 0;
  31983. var t3010 = 0;
  31984. var t3110 = 0;
  31985. var t3210 = 0;
  31986. var t3310 = 1;
  31987. mat410.e00 = t0021;
  31988. mat410.e01 = t0121;
  31989. mat410.e02 = t0221;
  31990. mat410.e03 = t0310;
  31991. mat410.e10 = t1021;
  31992. mat410.e11 = t1121;
  31993. mat410.e12 = t1221;
  31994. mat410.e13 = t1310;
  31995. mat410.e20 = t2021;
  31996. mat410.e21 = t2121;
  31997. mat410.e22 = t2221;
  31998. mat410.e23 = t2310;
  31999. mat410.e30 = t3010;
  32000. mat410.e31 = t3110;
  32001. mat410.e32 = t3210;
  32002. mat410.e33 = t3310;
  32003. if(_this64.sizeMat4 == _this64.stackMat4.length) {
  32004. var newLength42 = _this64.sizeMat4 << 1;
  32005. var this43 = new Array(newLength42);
  32006. var newArray42 = this43;
  32007. var _g53 = 0;
  32008. var _g143 = _this64.sizeMat4;
  32009. while(_g53 < _g143) {
  32010. var i44 = _g53++;
  32011. newArray42[i44] = _this64.stackMat4[i44];
  32012. _this64.stackMat4[i44] = null;
  32013. }
  32014. _this64.stackMat4 = newArray42;
  32015. }
  32016. _this64.stackMat4[_this64.sizeMat4++] = mat410;
  32017. }
  32018. if(quat10 != null) {
  32019. var tx34 = 0;
  32020. var ty34 = 0;
  32021. var tz34 = 0;
  32022. var tw10 = 1;
  32023. quat10.x = tx34;
  32024. quat10.y = ty34;
  32025. quat10.z = tz34;
  32026. quat10.w = tw10;
  32027. if(_this64.sizeQuat == _this64.stackQuat.length) {
  32028. var newLength43 = _this64.sizeQuat << 1;
  32029. var this44 = new Array(newLength43);
  32030. var newArray43 = this44;
  32031. var _g54 = 0;
  32032. var _g144 = _this64.sizeQuat;
  32033. while(_g54 < _g144) {
  32034. var i45 = _g54++;
  32035. newArray43[i45] = _this64.stackQuat[i45];
  32036. _this64.stackQuat[i45] = null;
  32037. }
  32038. _this64.stackQuat = newArray43;
  32039. }
  32040. _this64.stackQuat[_this64.sizeQuat++] = quat10;
  32041. }
  32042. var _this65 = this.p;
  32043. var mat311 = null;
  32044. var mat411 = null;
  32045. var quat11 = null;
  32046. if(o != null) {
  32047. o.zero();
  32048. if(_this65.sizeVec3 == _this65.stackVec3.length) {
  32049. var newLength44 = _this65.sizeVec3 << 1;
  32050. var this45 = new Array(newLength44);
  32051. var newArray44 = this45;
  32052. var _g55 = 0;
  32053. var _g145 = _this65.sizeVec3;
  32054. while(_g55 < _g145) {
  32055. var i46 = _g55++;
  32056. newArray44[i46] = _this65.stackVec3[i46];
  32057. _this65.stackVec3[i46] = null;
  32058. }
  32059. _this65.stackVec3 = newArray44;
  32060. }
  32061. _this65.stackVec3[_this65.sizeVec3++] = o;
  32062. }
  32063. if(mat311 != null) {
  32064. var t0022 = 1;
  32065. var t0122 = 0;
  32066. var t0222 = 0;
  32067. var t1022 = 0;
  32068. var t1122 = 1;
  32069. var t1222 = 0;
  32070. var t2022 = 0;
  32071. var t2122 = 0;
  32072. var t2222 = 1;
  32073. mat311.e00 = t0022;
  32074. mat311.e01 = t0122;
  32075. mat311.e02 = t0222;
  32076. mat311.e10 = t1022;
  32077. mat311.e11 = t1122;
  32078. mat311.e12 = t1222;
  32079. mat311.e20 = t2022;
  32080. mat311.e21 = t2122;
  32081. mat311.e22 = t2222;
  32082. if(_this65.sizeMat3 == _this65.stackMat3.length) {
  32083. var newLength45 = _this65.sizeMat3 << 1;
  32084. var this46 = new Array(newLength45);
  32085. var newArray45 = this46;
  32086. var _g56 = 0;
  32087. var _g146 = _this65.sizeMat3;
  32088. while(_g56 < _g146) {
  32089. var i47 = _g56++;
  32090. newArray45[i47] = _this65.stackMat3[i47];
  32091. _this65.stackMat3[i47] = null;
  32092. }
  32093. _this65.stackMat3 = newArray45;
  32094. }
  32095. _this65.stackMat3[_this65.sizeMat3++] = mat311;
  32096. }
  32097. if(mat411 != null) {
  32098. var t0023 = 1;
  32099. var t0123 = 0;
  32100. var t0223 = 0;
  32101. var t0311 = 0;
  32102. var t1023 = 0;
  32103. var t1123 = 1;
  32104. var t1223 = 0;
  32105. var t1311 = 0;
  32106. var t2023 = 0;
  32107. var t2123 = 0;
  32108. var t2223 = 1;
  32109. var t2311 = 0;
  32110. var t3011 = 0;
  32111. var t3111 = 0;
  32112. var t3211 = 0;
  32113. var t3311 = 1;
  32114. mat411.e00 = t0023;
  32115. mat411.e01 = t0123;
  32116. mat411.e02 = t0223;
  32117. mat411.e03 = t0311;
  32118. mat411.e10 = t1023;
  32119. mat411.e11 = t1123;
  32120. mat411.e12 = t1223;
  32121. mat411.e13 = t1311;
  32122. mat411.e20 = t2023;
  32123. mat411.e21 = t2123;
  32124. mat411.e22 = t2223;
  32125. mat411.e23 = t2311;
  32126. mat411.e30 = t3011;
  32127. mat411.e31 = t3111;
  32128. mat411.e32 = t3211;
  32129. mat411.e33 = t3311;
  32130. if(_this65.sizeMat4 == _this65.stackMat4.length) {
  32131. var newLength46 = _this65.sizeMat4 << 1;
  32132. var this47 = new Array(newLength46);
  32133. var newArray46 = this47;
  32134. var _g57 = 0;
  32135. var _g147 = _this65.sizeMat4;
  32136. while(_g57 < _g147) {
  32137. var i48 = _g57++;
  32138. newArray46[i48] = _this65.stackMat4[i48];
  32139. _this65.stackMat4[i48] = null;
  32140. }
  32141. _this65.stackMat4 = newArray46;
  32142. }
  32143. _this65.stackMat4[_this65.sizeMat4++] = mat411;
  32144. }
  32145. if(quat11 != null) {
  32146. var tx35 = 0;
  32147. var ty35 = 0;
  32148. var tz35 = 0;
  32149. var tw11 = 1;
  32150. quat11.x = tx35;
  32151. quat11.y = ty35;
  32152. quat11.z = tz35;
  32153. quat11.w = tw11;
  32154. if(_this65.sizeQuat == _this65.stackQuat.length) {
  32155. var newLength47 = _this65.sizeQuat << 1;
  32156. var this48 = new Array(newLength47);
  32157. var newArray47 = this48;
  32158. var _g58 = 0;
  32159. var _g148 = _this65.sizeQuat;
  32160. while(_g58 < _g148) {
  32161. var i49 = _g58++;
  32162. newArray47[i49] = _this65.stackQuat[i49];
  32163. _this65.stackQuat[i49] = null;
  32164. }
  32165. _this65.stackQuat = newArray47;
  32166. }
  32167. _this65.stackQuat[_this65.sizeQuat++] = quat11;
  32168. }
  32169. var _this66 = this.p;
  32170. var vec3 = null;
  32171. var mat412 = null;
  32172. var quat12 = null;
  32173. if(vec3 != null) {
  32174. vec3.zero();
  32175. if(_this66.sizeVec3 == _this66.stackVec3.length) {
  32176. var newLength48 = _this66.sizeVec3 << 1;
  32177. var this49 = new Array(newLength48);
  32178. var newArray48 = this49;
  32179. var _g59 = 0;
  32180. var _g149 = _this66.sizeVec3;
  32181. while(_g59 < _g149) {
  32182. var i50 = _g59++;
  32183. newArray48[i50] = _this66.stackVec3[i50];
  32184. _this66.stackVec3[i50] = null;
  32185. }
  32186. _this66.stackVec3 = newArray48;
  32187. }
  32188. _this66.stackVec3[_this66.sizeVec3++] = vec3;
  32189. }
  32190. if(m != null) {
  32191. var t0024 = 1;
  32192. var t0124 = 0;
  32193. var t0224 = 0;
  32194. var t1024 = 0;
  32195. var t1124 = 1;
  32196. var t1224 = 0;
  32197. var t2024 = 0;
  32198. var t2124 = 0;
  32199. var t2224 = 1;
  32200. m.e00 = t0024;
  32201. m.e01 = t0124;
  32202. m.e02 = t0224;
  32203. m.e10 = t1024;
  32204. m.e11 = t1124;
  32205. m.e12 = t1224;
  32206. m.e20 = t2024;
  32207. m.e21 = t2124;
  32208. m.e22 = t2224;
  32209. if(_this66.sizeMat3 == _this66.stackMat3.length) {
  32210. var newLength49 = _this66.sizeMat3 << 1;
  32211. var this50 = new Array(newLength49);
  32212. var newArray49 = this50;
  32213. var _g60 = 0;
  32214. var _g150 = _this66.sizeMat3;
  32215. while(_g60 < _g150) {
  32216. var i51 = _g60++;
  32217. newArray49[i51] = _this66.stackMat3[i51];
  32218. _this66.stackMat3[i51] = null;
  32219. }
  32220. _this66.stackMat3 = newArray49;
  32221. }
  32222. _this66.stackMat3[_this66.sizeMat3++] = m;
  32223. }
  32224. if(mat412 != null) {
  32225. var t0025 = 1;
  32226. var t0125 = 0;
  32227. var t0225 = 0;
  32228. var t0312 = 0;
  32229. var t1025 = 0;
  32230. var t1125 = 1;
  32231. var t1225 = 0;
  32232. var t1312 = 0;
  32233. var t2025 = 0;
  32234. var t2125 = 0;
  32235. var t2225 = 1;
  32236. var t2312 = 0;
  32237. var t3012 = 0;
  32238. var t3112 = 0;
  32239. var t3212 = 0;
  32240. var t3312 = 1;
  32241. mat412.e00 = t0025;
  32242. mat412.e01 = t0125;
  32243. mat412.e02 = t0225;
  32244. mat412.e03 = t0312;
  32245. mat412.e10 = t1025;
  32246. mat412.e11 = t1125;
  32247. mat412.e12 = t1225;
  32248. mat412.e13 = t1312;
  32249. mat412.e20 = t2025;
  32250. mat412.e21 = t2125;
  32251. mat412.e22 = t2225;
  32252. mat412.e23 = t2312;
  32253. mat412.e30 = t3012;
  32254. mat412.e31 = t3112;
  32255. mat412.e32 = t3212;
  32256. mat412.e33 = t3312;
  32257. if(_this66.sizeMat4 == _this66.stackMat4.length) {
  32258. var newLength50 = _this66.sizeMat4 << 1;
  32259. var this51 = new Array(newLength50);
  32260. var newArray50 = this51;
  32261. var _g61 = 0;
  32262. var _g151 = _this66.sizeMat4;
  32263. while(_g61 < _g151) {
  32264. var i52 = _g61++;
  32265. newArray50[i52] = _this66.stackMat4[i52];
  32266. _this66.stackMat4[i52] = null;
  32267. }
  32268. _this66.stackMat4 = newArray50;
  32269. }
  32270. _this66.stackMat4[_this66.sizeMat4++] = mat412;
  32271. }
  32272. if(quat12 != null) {
  32273. var tx36 = 0;
  32274. var ty36 = 0;
  32275. var tz36 = 0;
  32276. var tw12 = 1;
  32277. quat12.x = tx36;
  32278. quat12.y = ty36;
  32279. quat12.z = tz36;
  32280. quat12.w = tw12;
  32281. if(_this66.sizeQuat == _this66.stackQuat.length) {
  32282. var newLength51 = _this66.sizeQuat << 1;
  32283. var this52 = new Array(newLength51);
  32284. var newArray51 = this52;
  32285. var _g62 = 0;
  32286. var _g152 = _this66.sizeQuat;
  32287. while(_g62 < _g152) {
  32288. var i53 = _g62++;
  32289. newArray51[i53] = _this66.stackQuat[i53];
  32290. _this66.stackQuat[i53] = null;
  32291. }
  32292. _this66.stackQuat = newArray51;
  32293. }
  32294. _this66.stackQuat[_this66.sizeQuat++] = quat12;
  32295. }
  32296. var _this67 = this.p;
  32297. var mat312 = null;
  32298. var mat413 = null;
  32299. var quat13 = null;
  32300. if(ex != null) {
  32301. ex.zero();
  32302. if(_this67.sizeVec3 == _this67.stackVec3.length) {
  32303. var newLength52 = _this67.sizeVec3 << 1;
  32304. var this53 = new Array(newLength52);
  32305. var newArray52 = this53;
  32306. var _g63 = 0;
  32307. var _g153 = _this67.sizeVec3;
  32308. while(_g63 < _g153) {
  32309. var i54 = _g63++;
  32310. newArray52[i54] = _this67.stackVec3[i54];
  32311. _this67.stackVec3[i54] = null;
  32312. }
  32313. _this67.stackVec3 = newArray52;
  32314. }
  32315. _this67.stackVec3[_this67.sizeVec3++] = ex;
  32316. }
  32317. if(mat312 != null) {
  32318. var t0026 = 1;
  32319. var t0126 = 0;
  32320. var t0226 = 0;
  32321. var t1026 = 0;
  32322. var t1126 = 1;
  32323. var t1226 = 0;
  32324. var t2026 = 0;
  32325. var t2126 = 0;
  32326. var t2226 = 1;
  32327. mat312.e00 = t0026;
  32328. mat312.e01 = t0126;
  32329. mat312.e02 = t0226;
  32330. mat312.e10 = t1026;
  32331. mat312.e11 = t1126;
  32332. mat312.e12 = t1226;
  32333. mat312.e20 = t2026;
  32334. mat312.e21 = t2126;
  32335. mat312.e22 = t2226;
  32336. if(_this67.sizeMat3 == _this67.stackMat3.length) {
  32337. var newLength53 = _this67.sizeMat3 << 1;
  32338. var this54 = new Array(newLength53);
  32339. var newArray53 = this54;
  32340. var _g64 = 0;
  32341. var _g154 = _this67.sizeMat3;
  32342. while(_g64 < _g154) {
  32343. var i55 = _g64++;
  32344. newArray53[i55] = _this67.stackMat3[i55];
  32345. _this67.stackMat3[i55] = null;
  32346. }
  32347. _this67.stackMat3 = newArray53;
  32348. }
  32349. _this67.stackMat3[_this67.sizeMat3++] = mat312;
  32350. }
  32351. if(mat413 != null) {
  32352. var t0027 = 1;
  32353. var t0127 = 0;
  32354. var t0227 = 0;
  32355. var t0313 = 0;
  32356. var t1027 = 0;
  32357. var t1127 = 1;
  32358. var t1227 = 0;
  32359. var t1313 = 0;
  32360. var t2027 = 0;
  32361. var t2127 = 0;
  32362. var t2227 = 1;
  32363. var t2313 = 0;
  32364. var t3013 = 0;
  32365. var t3113 = 0;
  32366. var t3213 = 0;
  32367. var t3313 = 1;
  32368. mat413.e00 = t0027;
  32369. mat413.e01 = t0127;
  32370. mat413.e02 = t0227;
  32371. mat413.e03 = t0313;
  32372. mat413.e10 = t1027;
  32373. mat413.e11 = t1127;
  32374. mat413.e12 = t1227;
  32375. mat413.e13 = t1313;
  32376. mat413.e20 = t2027;
  32377. mat413.e21 = t2127;
  32378. mat413.e22 = t2227;
  32379. mat413.e23 = t2313;
  32380. mat413.e30 = t3013;
  32381. mat413.e31 = t3113;
  32382. mat413.e32 = t3213;
  32383. mat413.e33 = t3313;
  32384. if(_this67.sizeMat4 == _this67.stackMat4.length) {
  32385. var newLength54 = _this67.sizeMat4 << 1;
  32386. var this55 = new Array(newLength54);
  32387. var newArray54 = this55;
  32388. var _g65 = 0;
  32389. var _g155 = _this67.sizeMat4;
  32390. while(_g65 < _g155) {
  32391. var i56 = _g65++;
  32392. newArray54[i56] = _this67.stackMat4[i56];
  32393. _this67.stackMat4[i56] = null;
  32394. }
  32395. _this67.stackMat4 = newArray54;
  32396. }
  32397. _this67.stackMat4[_this67.sizeMat4++] = mat413;
  32398. }
  32399. if(quat13 != null) {
  32400. var tx37 = 0;
  32401. var ty37 = 0;
  32402. var tz37 = 0;
  32403. var tw13 = 1;
  32404. quat13.x = tx37;
  32405. quat13.y = ty37;
  32406. quat13.z = tz37;
  32407. quat13.w = tw13;
  32408. if(_this67.sizeQuat == _this67.stackQuat.length) {
  32409. var newLength55 = _this67.sizeQuat << 1;
  32410. var this56 = new Array(newLength55);
  32411. var newArray55 = this56;
  32412. var _g66 = 0;
  32413. var _g156 = _this67.sizeQuat;
  32414. while(_g66 < _g156) {
  32415. var i57 = _g66++;
  32416. newArray55[i57] = _this67.stackQuat[i57];
  32417. _this67.stackQuat[i57] = null;
  32418. }
  32419. _this67.stackQuat = newArray55;
  32420. }
  32421. _this67.stackQuat[_this67.sizeQuat++] = quat13;
  32422. }
  32423. var _this68 = this.p;
  32424. var mat313 = null;
  32425. var mat414 = null;
  32426. var quat14 = null;
  32427. if(ey != null) {
  32428. ey.zero();
  32429. if(_this68.sizeVec3 == _this68.stackVec3.length) {
  32430. var newLength56 = _this68.sizeVec3 << 1;
  32431. var this57 = new Array(newLength56);
  32432. var newArray56 = this57;
  32433. var _g67 = 0;
  32434. var _g157 = _this68.sizeVec3;
  32435. while(_g67 < _g157) {
  32436. var i58 = _g67++;
  32437. newArray56[i58] = _this68.stackVec3[i58];
  32438. _this68.stackVec3[i58] = null;
  32439. }
  32440. _this68.stackVec3 = newArray56;
  32441. }
  32442. _this68.stackVec3[_this68.sizeVec3++] = ey;
  32443. }
  32444. if(mat313 != null) {
  32445. var t0028 = 1;
  32446. var t0128 = 0;
  32447. var t0228 = 0;
  32448. var t1028 = 0;
  32449. var t1128 = 1;
  32450. var t1228 = 0;
  32451. var t2028 = 0;
  32452. var t2128 = 0;
  32453. var t2228 = 1;
  32454. mat313.e00 = t0028;
  32455. mat313.e01 = t0128;
  32456. mat313.e02 = t0228;
  32457. mat313.e10 = t1028;
  32458. mat313.e11 = t1128;
  32459. mat313.e12 = t1228;
  32460. mat313.e20 = t2028;
  32461. mat313.e21 = t2128;
  32462. mat313.e22 = t2228;
  32463. if(_this68.sizeMat3 == _this68.stackMat3.length) {
  32464. var newLength57 = _this68.sizeMat3 << 1;
  32465. var this58 = new Array(newLength57);
  32466. var newArray57 = this58;
  32467. var _g68 = 0;
  32468. var _g158 = _this68.sizeMat3;
  32469. while(_g68 < _g158) {
  32470. var i59 = _g68++;
  32471. newArray57[i59] = _this68.stackMat3[i59];
  32472. _this68.stackMat3[i59] = null;
  32473. }
  32474. _this68.stackMat3 = newArray57;
  32475. }
  32476. _this68.stackMat3[_this68.sizeMat3++] = mat313;
  32477. }
  32478. if(mat414 != null) {
  32479. var t0029 = 1;
  32480. var t0129 = 0;
  32481. var t0229 = 0;
  32482. var t0314 = 0;
  32483. var t1029 = 0;
  32484. var t1129 = 1;
  32485. var t1229 = 0;
  32486. var t1314 = 0;
  32487. var t2029 = 0;
  32488. var t2129 = 0;
  32489. var t2229 = 1;
  32490. var t2314 = 0;
  32491. var t3014 = 0;
  32492. var t3114 = 0;
  32493. var t3214 = 0;
  32494. var t3314 = 1;
  32495. mat414.e00 = t0029;
  32496. mat414.e01 = t0129;
  32497. mat414.e02 = t0229;
  32498. mat414.e03 = t0314;
  32499. mat414.e10 = t1029;
  32500. mat414.e11 = t1129;
  32501. mat414.e12 = t1229;
  32502. mat414.e13 = t1314;
  32503. mat414.e20 = t2029;
  32504. mat414.e21 = t2129;
  32505. mat414.e22 = t2229;
  32506. mat414.e23 = t2314;
  32507. mat414.e30 = t3014;
  32508. mat414.e31 = t3114;
  32509. mat414.e32 = t3214;
  32510. mat414.e33 = t3314;
  32511. if(_this68.sizeMat4 == _this68.stackMat4.length) {
  32512. var newLength58 = _this68.sizeMat4 << 1;
  32513. var this59 = new Array(newLength58);
  32514. var newArray58 = this59;
  32515. var _g69 = 0;
  32516. var _g159 = _this68.sizeMat4;
  32517. while(_g69 < _g159) {
  32518. var i60 = _g69++;
  32519. newArray58[i60] = _this68.stackMat4[i60];
  32520. _this68.stackMat4[i60] = null;
  32521. }
  32522. _this68.stackMat4 = newArray58;
  32523. }
  32524. _this68.stackMat4[_this68.sizeMat4++] = mat414;
  32525. }
  32526. if(quat14 != null) {
  32527. var tx38 = 0;
  32528. var ty38 = 0;
  32529. var tz38 = 0;
  32530. var tw14 = 1;
  32531. quat14.x = tx38;
  32532. quat14.y = ty38;
  32533. quat14.z = tz38;
  32534. quat14.w = tw14;
  32535. if(_this68.sizeQuat == _this68.stackQuat.length) {
  32536. var newLength59 = _this68.sizeQuat << 1;
  32537. var this60 = new Array(newLength59);
  32538. var newArray59 = this60;
  32539. var _g70 = 0;
  32540. var _g160 = _this68.sizeQuat;
  32541. while(_g70 < _g160) {
  32542. var i61 = _g70++;
  32543. newArray59[i61] = _this68.stackQuat[i61];
  32544. _this68.stackQuat[i61] = null;
  32545. }
  32546. _this68.stackQuat = newArray59;
  32547. }
  32548. _this68.stackQuat[_this68.sizeQuat++] = quat14;
  32549. }
  32550. var _this69 = this.p;
  32551. var mat314 = null;
  32552. var mat415 = null;
  32553. var quat15 = null;
  32554. if(ez != null) {
  32555. ez.zero();
  32556. if(_this69.sizeVec3 == _this69.stackVec3.length) {
  32557. var newLength60 = _this69.sizeVec3 << 1;
  32558. var this61 = new Array(newLength60);
  32559. var newArray60 = this61;
  32560. var _g71 = 0;
  32561. var _g161 = _this69.sizeVec3;
  32562. while(_g71 < _g161) {
  32563. var i62 = _g71++;
  32564. newArray60[i62] = _this69.stackVec3[i62];
  32565. _this69.stackVec3[i62] = null;
  32566. }
  32567. _this69.stackVec3 = newArray60;
  32568. }
  32569. _this69.stackVec3[_this69.sizeVec3++] = ez;
  32570. }
  32571. if(mat314 != null) {
  32572. var t0030 = 1;
  32573. var t0130 = 0;
  32574. var t0230 = 0;
  32575. var t1030 = 0;
  32576. var t1130 = 1;
  32577. var t1230 = 0;
  32578. var t2030 = 0;
  32579. var t2130 = 0;
  32580. var t2230 = 1;
  32581. mat314.e00 = t0030;
  32582. mat314.e01 = t0130;
  32583. mat314.e02 = t0230;
  32584. mat314.e10 = t1030;
  32585. mat314.e11 = t1130;
  32586. mat314.e12 = t1230;
  32587. mat314.e20 = t2030;
  32588. mat314.e21 = t2130;
  32589. mat314.e22 = t2230;
  32590. if(_this69.sizeMat3 == _this69.stackMat3.length) {
  32591. var newLength61 = _this69.sizeMat3 << 1;
  32592. var this62 = new Array(newLength61);
  32593. var newArray61 = this62;
  32594. var _g72 = 0;
  32595. var _g162 = _this69.sizeMat3;
  32596. while(_g72 < _g162) {
  32597. var i63 = _g72++;
  32598. newArray61[i63] = _this69.stackMat3[i63];
  32599. _this69.stackMat3[i63] = null;
  32600. }
  32601. _this69.stackMat3 = newArray61;
  32602. }
  32603. _this69.stackMat3[_this69.sizeMat3++] = mat314;
  32604. }
  32605. if(mat415 != null) {
  32606. var t0031 = 1;
  32607. var t0131 = 0;
  32608. var t0231 = 0;
  32609. var t0315 = 0;
  32610. var t1031 = 0;
  32611. var t1131 = 1;
  32612. var t1231 = 0;
  32613. var t1315 = 0;
  32614. var t2031 = 0;
  32615. var t2131 = 0;
  32616. var t2231 = 1;
  32617. var t2315 = 0;
  32618. var t3015 = 0;
  32619. var t3115 = 0;
  32620. var t3215 = 0;
  32621. var t3315 = 1;
  32622. mat415.e00 = t0031;
  32623. mat415.e01 = t0131;
  32624. mat415.e02 = t0231;
  32625. mat415.e03 = t0315;
  32626. mat415.e10 = t1031;
  32627. mat415.e11 = t1131;
  32628. mat415.e12 = t1231;
  32629. mat415.e13 = t1315;
  32630. mat415.e20 = t2031;
  32631. mat415.e21 = t2131;
  32632. mat415.e22 = t2231;
  32633. mat415.e23 = t2315;
  32634. mat415.e30 = t3015;
  32635. mat415.e31 = t3115;
  32636. mat415.e32 = t3215;
  32637. mat415.e33 = t3315;
  32638. if(_this69.sizeMat4 == _this69.stackMat4.length) {
  32639. var newLength62 = _this69.sizeMat4 << 1;
  32640. var this63 = new Array(newLength62);
  32641. var newArray62 = this63;
  32642. var _g73 = 0;
  32643. var _g163 = _this69.sizeMat4;
  32644. while(_g73 < _g163) {
  32645. var i64 = _g73++;
  32646. newArray62[i64] = _this69.stackMat4[i64];
  32647. _this69.stackMat4[i64] = null;
  32648. }
  32649. _this69.stackMat4 = newArray62;
  32650. }
  32651. _this69.stackMat4[_this69.sizeMat4++] = mat415;
  32652. }
  32653. if(quat15 != null) {
  32654. var tx39 = 0;
  32655. var ty39 = 0;
  32656. var tz39 = 0;
  32657. var tw15 = 1;
  32658. quat15.x = tx39;
  32659. quat15.y = ty39;
  32660. quat15.z = tz39;
  32661. quat15.w = tw15;
  32662. if(_this69.sizeQuat == _this69.stackQuat.length) {
  32663. var newLength63 = _this69.sizeQuat << 1;
  32664. var this64 = new Array(newLength63);
  32665. var newArray63 = this64;
  32666. var _g74 = 0;
  32667. var _g164 = _this69.sizeQuat;
  32668. while(_g74 < _g164) {
  32669. var i65 = _g74++;
  32670. newArray63[i65] = _this69.stackQuat[i65];
  32671. _this69.stackQuat[i65] = null;
  32672. }
  32673. _this69.stackQuat = newArray63;
  32674. }
  32675. _this69.stackQuat[_this69.sizeQuat++] = quat15;
  32676. }
  32677. }
  32678. capsule(tf,radius,halfHeight,color) {
  32679. var _this = this.p;
  32680. var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  32681. var _this1 = this.p;
  32682. var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  32683. var _this2 = this.p;
  32684. var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  32685. var _this3 = this.p;
  32686. var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  32687. var _this4 = this.p;
  32688. var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3];
  32689. var v = o;
  32690. v.x = tf._positionX;
  32691. v.y = tf._positionY;
  32692. v.z = tf._positionZ;
  32693. var m1 = m;
  32694. m1.e00 = tf._rotation00;
  32695. m1.e01 = tf._rotation01;
  32696. m1.e02 = tf._rotation02;
  32697. m1.e10 = tf._rotation10;
  32698. m1.e11 = tf._rotation11;
  32699. m1.e12 = tf._rotation12;
  32700. m1.e20 = tf._rotation20;
  32701. m1.e21 = tf._rotation21;
  32702. m1.e22 = tf._rotation22;
  32703. ex.init(m.e00,m.e10,m.e20);
  32704. ey.init(m.e01,m.e11,m.e21);
  32705. ez.init(m.e02,m.e12,m.e22);
  32706. var nt = 4;
  32707. var np = 8;
  32708. var vs = this.tmpSphereVerts;
  32709. var ns = this.tmpSphereNorms;
  32710. var _g = 0;
  32711. var _g1 = nt + 1;
  32712. while(_g < _g1) {
  32713. var i2 = _g++;
  32714. var n = this.tmpSphereVerts[i2].length;
  32715. var _g2 = 0;
  32716. var _g11 = n;
  32717. while(_g2 < _g11) {
  32718. var j2 = _g2++;
  32719. var _this5 = ns[i2][j2];
  32720. var v1 = this.sphereCoords[i2][j2];
  32721. _this5.x = v1.x;
  32722. _this5.y = v1.y;
  32723. _this5.z = v1.z;
  32724. var _this6 = _this5;
  32725. var tx = _this6.x * m.e00 + _this6.y * m.e01 + _this6.z * m.e02;
  32726. var ty = _this6.x * m.e10 + _this6.y * m.e11 + _this6.z * m.e12;
  32727. var tz = _this6.x * m.e20 + _this6.y * m.e21 + _this6.z * m.e22;
  32728. _this6.x = tx;
  32729. _this6.y = ty;
  32730. _this6.z = tz;
  32731. }
  32732. }
  32733. var _g21 = 0;
  32734. var _g3 = nt;
  32735. while(_g21 < _g3) {
  32736. var i = _g21++;
  32737. if(i == 0) {
  32738. var half = nt >> 1;
  32739. var _g22 = 0;
  32740. var _g31 = half + 1;
  32741. while(_g22 < _g31) {
  32742. var i21 = _g22++;
  32743. var n1 = this.tmpSphereVerts[i21].length;
  32744. var _g23 = 0;
  32745. var _g32 = n1;
  32746. while(_g23 < _g32) {
  32747. var j21 = _g23++;
  32748. var _this7 = vs[i21][j21];
  32749. var v2 = ns[i21][j21];
  32750. _this7.x = v2.x;
  32751. _this7.y = v2.y;
  32752. _this7.z = v2.z;
  32753. var _this8 = _this7;
  32754. var tx1 = _this8.x * radius;
  32755. var ty1 = _this8.y * radius;
  32756. var tz1 = _this8.z * radius;
  32757. _this8.x = tx1;
  32758. _this8.y = ty1;
  32759. _this8.z = tz1;
  32760. var _this9 = _this8;
  32761. var tx2 = _this9.x + o.x;
  32762. var ty2 = _this9.y + o.y;
  32763. var tz2 = _this9.z + o.z;
  32764. _this9.x = tx2;
  32765. _this9.y = ty2;
  32766. _this9.z = tz2;
  32767. var _this10 = _this9;
  32768. var tx3 = _this10.x + ey.x * halfHeight;
  32769. var ty3 = _this10.y + ey.y * halfHeight;
  32770. var tz3 = _this10.z + ey.z * halfHeight;
  32771. _this10.x = tx3;
  32772. _this10.y = ty3;
  32773. _this10.z = tz3;
  32774. }
  32775. }
  32776. }
  32777. if(i == nt >> 1) {
  32778. var half1 = nt >> 1;
  32779. var _g24 = half1;
  32780. var _g33 = nt + 1;
  32781. while(_g24 < _g33) {
  32782. var i22 = _g24++;
  32783. var n2 = this.tmpSphereVerts[i22].length;
  32784. var _g25 = 0;
  32785. var _g34 = n2;
  32786. while(_g25 < _g34) {
  32787. var j22 = _g25++;
  32788. var _this11 = vs[i22][j22];
  32789. var v3 = ns[i22][j22];
  32790. _this11.x = v3.x;
  32791. _this11.y = v3.y;
  32792. _this11.z = v3.z;
  32793. var _this12 = _this11;
  32794. var tx4 = _this12.x * radius;
  32795. var ty4 = _this12.y * radius;
  32796. var tz4 = _this12.z * radius;
  32797. _this12.x = tx4;
  32798. _this12.y = ty4;
  32799. _this12.z = tz4;
  32800. var _this13 = _this12;
  32801. var tx5 = _this13.x + o.x;
  32802. var ty5 = _this13.y + o.y;
  32803. var tz5 = _this13.z + o.z;
  32804. _this13.x = tx5;
  32805. _this13.y = ty5;
  32806. _this13.z = tz5;
  32807. var _this14 = _this13;
  32808. var s = -halfHeight;
  32809. var tx6 = _this14.x + ey.x * s;
  32810. var ty6 = _this14.y + ey.y * s;
  32811. var tz6 = _this14.z + ey.z * s;
  32812. _this14.x = tx6;
  32813. _this14.y = ty6;
  32814. _this14.z = tz6;
  32815. }
  32816. }
  32817. }
  32818. var _g26 = 0;
  32819. var _g35 = np;
  32820. while(_g26 < _g35) {
  32821. var j = _g26++;
  32822. var v11;
  32823. var v21;
  32824. var v31;
  32825. var v4;
  32826. var n11;
  32827. var n21;
  32828. var n3;
  32829. var n4;
  32830. if(i == 0) {
  32831. if(this.wireframe) {
  32832. v11 = vs[0][0];
  32833. v21 = vs[1][j];
  32834. this.line(v11,v21,color);
  32835. } else {
  32836. v11 = vs[0][0];
  32837. v21 = vs[1][j];
  32838. v31 = vs[1][(j + 1) % np];
  32839. n11 = ns[0][0];
  32840. n21 = ns[1][j];
  32841. n3 = ns[1][(j + 1) % np];
  32842. this.triangle(v11,v21,v31,n11,n21,n3,color);
  32843. }
  32844. } else if(i == nt - 1) {
  32845. if(this.wireframe) {
  32846. v11 = vs[nt][0];
  32847. v21 = vs[i][(j + 1) % np];
  32848. v31 = vs[i][j];
  32849. this.line(v11,v21,color);
  32850. this.line(v21,v31,color);
  32851. } else {
  32852. v11 = vs[nt][0];
  32853. v21 = vs[i][(j + 1) % np];
  32854. v31 = vs[i][j];
  32855. n11 = ns[nt][0];
  32856. n21 = ns[i][(j + 1) % np];
  32857. n3 = ns[i][j];
  32858. this.triangle(v11,v21,v31,n11,n21,n3,color);
  32859. }
  32860. } else if(this.wireframe) {
  32861. v11 = vs[i][j];
  32862. v21 = vs[i][(j + 1) % np];
  32863. v31 = vs[i + 1][j];
  32864. this.line(v11,v21,color);
  32865. this.line(v11,v31,color);
  32866. } else {
  32867. v11 = vs[i][j];
  32868. v21 = vs[i][(j + 1) % np];
  32869. v31 = vs[i + 1][j];
  32870. v4 = vs[i + 1][(j + 1) % np];
  32871. n11 = ns[i][j];
  32872. n21 = ns[i][(j + 1) % np];
  32873. n3 = ns[i + 1][j];
  32874. n4 = ns[i + 1][(j + 1) % np];
  32875. this.rect(v11,v31,v4,v21,n11,n3,n4,n21,color);
  32876. }
  32877. }
  32878. }
  32879. var _this15 = this.p;
  32880. var _this16 = _this15.sizeVec3 == 0 ? new oimo.common.Vec3() : _this15.stackVec3[--_this15.sizeVec3];
  32881. _this16.x = o.x;
  32882. _this16.y = o.y;
  32883. _this16.z = o.z;
  32884. var _this17 = _this16;
  32885. var tx7 = _this17.x + ey.x * halfHeight;
  32886. var ty7 = _this17.y + ey.y * halfHeight;
  32887. var tz7 = _this17.z + ey.z * halfHeight;
  32888. _this17.x = tx7;
  32889. _this17.y = ty7;
  32890. _this17.z = tz7;
  32891. var top = _this17;
  32892. var _this18 = this.p;
  32893. var _this19 = _this18.sizeVec3 == 0 ? new oimo.common.Vec3() : _this18.stackVec3[--_this18.sizeVec3];
  32894. _this19.x = o.x;
  32895. _this19.y = o.y;
  32896. _this19.z = o.z;
  32897. var _this20 = _this19;
  32898. var s1 = -halfHeight;
  32899. var tx8 = _this20.x + ey.x * s1;
  32900. var ty8 = _this20.y + ey.y * s1;
  32901. var tz8 = _this20.z + ey.z * s1;
  32902. _this20.x = tx8;
  32903. _this20.y = ty8;
  32904. _this20.z = tz8;
  32905. var bottom = _this20;
  32906. if(this.wireframe) {
  32907. var _this21 = this.p;
  32908. var _this22 = _this21.sizeVec3 == 0 ? new oimo.common.Vec3() : _this21.stackVec3[--_this21.sizeVec3];
  32909. _this22.x = top.x;
  32910. _this22.y = top.y;
  32911. _this22.z = top.z;
  32912. var _this23 = _this22;
  32913. var s2 = -radius;
  32914. var tx9 = _this23.x + ex.x * s2;
  32915. var ty9 = _this23.y + ex.y * s2;
  32916. var tz9 = _this23.z + ex.z * s2;
  32917. _this23.x = tx9;
  32918. _this23.y = ty9;
  32919. _this23.z = tz9;
  32920. var _this24 = _this23;
  32921. var tx10 = _this24.x + ez.x * 0;
  32922. var ty10 = _this24.y + ez.y * 0;
  32923. var tz10 = _this24.z + ez.z * 0;
  32924. _this24.x = tx10;
  32925. _this24.y = ty10;
  32926. _this24.z = tz10;
  32927. var top1 = _this24;
  32928. var _this25 = this.p;
  32929. var _this26 = _this25.sizeVec3 == 0 ? new oimo.common.Vec3() : _this25.stackVec3[--_this25.sizeVec3];
  32930. _this26.x = top.x;
  32931. _this26.y = top.y;
  32932. _this26.z = top.z;
  32933. var _this27 = _this26;
  32934. var tx11 = _this27.x + ex.x * radius;
  32935. var ty11 = _this27.y + ex.y * radius;
  32936. var tz11 = _this27.z + ex.z * radius;
  32937. _this27.x = tx11;
  32938. _this27.y = ty11;
  32939. _this27.z = tz11;
  32940. var _this28 = _this27;
  32941. var tx12 = _this28.x + ez.x * 0;
  32942. var ty12 = _this28.y + ez.y * 0;
  32943. var tz12 = _this28.z + ez.z * 0;
  32944. _this28.x = tx12;
  32945. _this28.y = ty12;
  32946. _this28.z = tz12;
  32947. var top2 = _this28;
  32948. var _this29 = this.p;
  32949. var _this30 = _this29.sizeVec3 == 0 ? new oimo.common.Vec3() : _this29.stackVec3[--_this29.sizeVec3];
  32950. _this30.x = top.x;
  32951. _this30.y = top.y;
  32952. _this30.z = top.z;
  32953. var _this31 = _this30;
  32954. var tx13 = _this31.x + ex.x * 0;
  32955. var ty13 = _this31.y + ex.y * 0;
  32956. var tz13 = _this31.z + ex.z * 0;
  32957. _this31.x = tx13;
  32958. _this31.y = ty13;
  32959. _this31.z = tz13;
  32960. var _this32 = _this31;
  32961. var s3 = -radius;
  32962. var tx14 = _this32.x + ez.x * s3;
  32963. var ty14 = _this32.y + ez.y * s3;
  32964. var tz14 = _this32.z + ez.z * s3;
  32965. _this32.x = tx14;
  32966. _this32.y = ty14;
  32967. _this32.z = tz14;
  32968. var top3 = _this32;
  32969. var _this33 = this.p;
  32970. var _this34 = _this33.sizeVec3 == 0 ? new oimo.common.Vec3() : _this33.stackVec3[--_this33.sizeVec3];
  32971. _this34.x = top.x;
  32972. _this34.y = top.y;
  32973. _this34.z = top.z;
  32974. var _this35 = _this34;
  32975. var tx15 = _this35.x + ex.x * 0;
  32976. var ty15 = _this35.y + ex.y * 0;
  32977. var tz15 = _this35.z + ex.z * 0;
  32978. _this35.x = tx15;
  32979. _this35.y = ty15;
  32980. _this35.z = tz15;
  32981. var _this36 = _this35;
  32982. var tx16 = _this36.x + ez.x * radius;
  32983. var ty16 = _this36.y + ez.y * radius;
  32984. var tz16 = _this36.z + ez.z * radius;
  32985. _this36.x = tx16;
  32986. _this36.y = ty16;
  32987. _this36.z = tz16;
  32988. var top4 = _this36;
  32989. var _this37 = this.p;
  32990. var _this38 = _this37.sizeVec3 == 0 ? new oimo.common.Vec3() : _this37.stackVec3[--_this37.sizeVec3];
  32991. _this38.x = bottom.x;
  32992. _this38.y = bottom.y;
  32993. _this38.z = bottom.z;
  32994. var _this39 = _this38;
  32995. var s4 = -radius;
  32996. var tx17 = _this39.x + ex.x * s4;
  32997. var ty17 = _this39.y + ex.y * s4;
  32998. var tz17 = _this39.z + ex.z * s4;
  32999. _this39.x = tx17;
  33000. _this39.y = ty17;
  33001. _this39.z = tz17;
  33002. var _this40 = _this39;
  33003. var tx18 = _this40.x + ez.x * 0;
  33004. var ty18 = _this40.y + ez.y * 0;
  33005. var tz18 = _this40.z + ez.z * 0;
  33006. _this40.x = tx18;
  33007. _this40.y = ty18;
  33008. _this40.z = tz18;
  33009. var bottom1 = _this40;
  33010. var _this41 = this.p;
  33011. var _this42 = _this41.sizeVec3 == 0 ? new oimo.common.Vec3() : _this41.stackVec3[--_this41.sizeVec3];
  33012. _this42.x = bottom.x;
  33013. _this42.y = bottom.y;
  33014. _this42.z = bottom.z;
  33015. var _this43 = _this42;
  33016. var tx19 = _this43.x + ex.x * radius;
  33017. var ty19 = _this43.y + ex.y * radius;
  33018. var tz19 = _this43.z + ex.z * radius;
  33019. _this43.x = tx19;
  33020. _this43.y = ty19;
  33021. _this43.z = tz19;
  33022. var _this44 = _this43;
  33023. var tx20 = _this44.x + ez.x * 0;
  33024. var ty20 = _this44.y + ez.y * 0;
  33025. var tz20 = _this44.z + ez.z * 0;
  33026. _this44.x = tx20;
  33027. _this44.y = ty20;
  33028. _this44.z = tz20;
  33029. var bottom2 = _this44;
  33030. var _this45 = this.p;
  33031. var _this46 = _this45.sizeVec3 == 0 ? new oimo.common.Vec3() : _this45.stackVec3[--_this45.sizeVec3];
  33032. _this46.x = bottom.x;
  33033. _this46.y = bottom.y;
  33034. _this46.z = bottom.z;
  33035. var _this47 = _this46;
  33036. var tx21 = _this47.x + ex.x * 0;
  33037. var ty21 = _this47.y + ex.y * 0;
  33038. var tz21 = _this47.z + ex.z * 0;
  33039. _this47.x = tx21;
  33040. _this47.y = ty21;
  33041. _this47.z = tz21;
  33042. var _this48 = _this47;
  33043. var s5 = -radius;
  33044. var tx22 = _this48.x + ez.x * s5;
  33045. var ty22 = _this48.y + ez.y * s5;
  33046. var tz22 = _this48.z + ez.z * s5;
  33047. _this48.x = tx22;
  33048. _this48.y = ty22;
  33049. _this48.z = tz22;
  33050. var bottom3 = _this48;
  33051. var _this49 = this.p;
  33052. var _this50 = _this49.sizeVec3 == 0 ? new oimo.common.Vec3() : _this49.stackVec3[--_this49.sizeVec3];
  33053. _this50.x = bottom.x;
  33054. _this50.y = bottom.y;
  33055. _this50.z = bottom.z;
  33056. var _this51 = _this50;
  33057. var tx23 = _this51.x + ex.x * 0;
  33058. var ty23 = _this51.y + ex.y * 0;
  33059. var tz23 = _this51.z + ex.z * 0;
  33060. _this51.x = tx23;
  33061. _this51.y = ty23;
  33062. _this51.z = tz23;
  33063. var _this52 = _this51;
  33064. var tx24 = _this52.x + ez.x * radius;
  33065. var ty24 = _this52.y + ez.y * radius;
  33066. var tz24 = _this52.z + ez.z * radius;
  33067. _this52.x = tx24;
  33068. _this52.y = ty24;
  33069. _this52.z = tz24;
  33070. var bottom4 = _this52;
  33071. this.ellipse(top,ex,ez,radius,radius,color);
  33072. this.ellipse(bottom,ex,ez,radius,radius,color);
  33073. this.line(top1,bottom1,color);
  33074. this.line(top2,bottom2,color);
  33075. this.line(top3,bottom3,color);
  33076. this.line(top4,bottom4,color);
  33077. var _this53 = this.p;
  33078. var mat3 = null;
  33079. var mat4 = null;
  33080. var quat = null;
  33081. if(top1 != null) {
  33082. top1.zero();
  33083. if(_this53.sizeVec3 == _this53.stackVec3.length) {
  33084. var newLength = _this53.sizeVec3 << 1;
  33085. var this1 = new Array(newLength);
  33086. var newArray = this1;
  33087. var _g4 = 0;
  33088. var _g12 = _this53.sizeVec3;
  33089. while(_g4 < _g12) {
  33090. var i1 = _g4++;
  33091. newArray[i1] = _this53.stackVec3[i1];
  33092. _this53.stackVec3[i1] = null;
  33093. }
  33094. _this53.stackVec3 = newArray;
  33095. }
  33096. _this53.stackVec3[_this53.sizeVec3++] = top1;
  33097. }
  33098. if(mat3 != null) {
  33099. var t00 = 1;
  33100. var t01 = 0;
  33101. var t02 = 0;
  33102. var t10 = 0;
  33103. var t11 = 1;
  33104. var t12 = 0;
  33105. var t20 = 0;
  33106. var t21 = 0;
  33107. var t22 = 1;
  33108. mat3.e00 = t00;
  33109. mat3.e01 = t01;
  33110. mat3.e02 = t02;
  33111. mat3.e10 = t10;
  33112. mat3.e11 = t11;
  33113. mat3.e12 = t12;
  33114. mat3.e20 = t20;
  33115. mat3.e21 = t21;
  33116. mat3.e22 = t22;
  33117. if(_this53.sizeMat3 == _this53.stackMat3.length) {
  33118. var newLength1 = _this53.sizeMat3 << 1;
  33119. var this2 = new Array(newLength1);
  33120. var newArray1 = this2;
  33121. var _g5 = 0;
  33122. var _g13 = _this53.sizeMat3;
  33123. while(_g5 < _g13) {
  33124. var i3 = _g5++;
  33125. newArray1[i3] = _this53.stackMat3[i3];
  33126. _this53.stackMat3[i3] = null;
  33127. }
  33128. _this53.stackMat3 = newArray1;
  33129. }
  33130. _this53.stackMat3[_this53.sizeMat3++] = mat3;
  33131. }
  33132. if(mat4 != null) {
  33133. var t001 = 1;
  33134. var t011 = 0;
  33135. var t021 = 0;
  33136. var t03 = 0;
  33137. var t101 = 0;
  33138. var t111 = 1;
  33139. var t121 = 0;
  33140. var t13 = 0;
  33141. var t201 = 0;
  33142. var t211 = 0;
  33143. var t221 = 1;
  33144. var t23 = 0;
  33145. var t30 = 0;
  33146. var t31 = 0;
  33147. var t32 = 0;
  33148. var t33 = 1;
  33149. mat4.e00 = t001;
  33150. mat4.e01 = t011;
  33151. mat4.e02 = t021;
  33152. mat4.e03 = t03;
  33153. mat4.e10 = t101;
  33154. mat4.e11 = t111;
  33155. mat4.e12 = t121;
  33156. mat4.e13 = t13;
  33157. mat4.e20 = t201;
  33158. mat4.e21 = t211;
  33159. mat4.e22 = t221;
  33160. mat4.e23 = t23;
  33161. mat4.e30 = t30;
  33162. mat4.e31 = t31;
  33163. mat4.e32 = t32;
  33164. mat4.e33 = t33;
  33165. if(_this53.sizeMat4 == _this53.stackMat4.length) {
  33166. var newLength2 = _this53.sizeMat4 << 1;
  33167. var this3 = new Array(newLength2);
  33168. var newArray2 = this3;
  33169. var _g6 = 0;
  33170. var _g14 = _this53.sizeMat4;
  33171. while(_g6 < _g14) {
  33172. var i4 = _g6++;
  33173. newArray2[i4] = _this53.stackMat4[i4];
  33174. _this53.stackMat4[i4] = null;
  33175. }
  33176. _this53.stackMat4 = newArray2;
  33177. }
  33178. _this53.stackMat4[_this53.sizeMat4++] = mat4;
  33179. }
  33180. if(quat != null) {
  33181. var tx25 = 0;
  33182. var ty25 = 0;
  33183. var tz25 = 0;
  33184. var tw = 1;
  33185. quat.x = tx25;
  33186. quat.y = ty25;
  33187. quat.z = tz25;
  33188. quat.w = tw;
  33189. if(_this53.sizeQuat == _this53.stackQuat.length) {
  33190. var newLength3 = _this53.sizeQuat << 1;
  33191. var this4 = new Array(newLength3);
  33192. var newArray3 = this4;
  33193. var _g7 = 0;
  33194. var _g15 = _this53.sizeQuat;
  33195. while(_g7 < _g15) {
  33196. var i5 = _g7++;
  33197. newArray3[i5] = _this53.stackQuat[i5];
  33198. _this53.stackQuat[i5] = null;
  33199. }
  33200. _this53.stackQuat = newArray3;
  33201. }
  33202. _this53.stackQuat[_this53.sizeQuat++] = quat;
  33203. }
  33204. var _this54 = this.p;
  33205. var mat31 = null;
  33206. var mat41 = null;
  33207. var quat1 = null;
  33208. if(top2 != null) {
  33209. top2.zero();
  33210. if(_this54.sizeVec3 == _this54.stackVec3.length) {
  33211. var newLength4 = _this54.sizeVec3 << 1;
  33212. var this5 = new Array(newLength4);
  33213. var newArray4 = this5;
  33214. var _g8 = 0;
  33215. var _g16 = _this54.sizeVec3;
  33216. while(_g8 < _g16) {
  33217. var i6 = _g8++;
  33218. newArray4[i6] = _this54.stackVec3[i6];
  33219. _this54.stackVec3[i6] = null;
  33220. }
  33221. _this54.stackVec3 = newArray4;
  33222. }
  33223. _this54.stackVec3[_this54.sizeVec3++] = top2;
  33224. }
  33225. if(mat31 != null) {
  33226. var t002 = 1;
  33227. var t012 = 0;
  33228. var t022 = 0;
  33229. var t102 = 0;
  33230. var t112 = 1;
  33231. var t122 = 0;
  33232. var t202 = 0;
  33233. var t212 = 0;
  33234. var t222 = 1;
  33235. mat31.e00 = t002;
  33236. mat31.e01 = t012;
  33237. mat31.e02 = t022;
  33238. mat31.e10 = t102;
  33239. mat31.e11 = t112;
  33240. mat31.e12 = t122;
  33241. mat31.e20 = t202;
  33242. mat31.e21 = t212;
  33243. mat31.e22 = t222;
  33244. if(_this54.sizeMat3 == _this54.stackMat3.length) {
  33245. var newLength5 = _this54.sizeMat3 << 1;
  33246. var this6 = new Array(newLength5);
  33247. var newArray5 = this6;
  33248. var _g9 = 0;
  33249. var _g17 = _this54.sizeMat3;
  33250. while(_g9 < _g17) {
  33251. var i7 = _g9++;
  33252. newArray5[i7] = _this54.stackMat3[i7];
  33253. _this54.stackMat3[i7] = null;
  33254. }
  33255. _this54.stackMat3 = newArray5;
  33256. }
  33257. _this54.stackMat3[_this54.sizeMat3++] = mat31;
  33258. }
  33259. if(mat41 != null) {
  33260. var t003 = 1;
  33261. var t013 = 0;
  33262. var t023 = 0;
  33263. var t031 = 0;
  33264. var t103 = 0;
  33265. var t113 = 1;
  33266. var t123 = 0;
  33267. var t131 = 0;
  33268. var t203 = 0;
  33269. var t213 = 0;
  33270. var t223 = 1;
  33271. var t231 = 0;
  33272. var t301 = 0;
  33273. var t311 = 0;
  33274. var t321 = 0;
  33275. var t331 = 1;
  33276. mat41.e00 = t003;
  33277. mat41.e01 = t013;
  33278. mat41.e02 = t023;
  33279. mat41.e03 = t031;
  33280. mat41.e10 = t103;
  33281. mat41.e11 = t113;
  33282. mat41.e12 = t123;
  33283. mat41.e13 = t131;
  33284. mat41.e20 = t203;
  33285. mat41.e21 = t213;
  33286. mat41.e22 = t223;
  33287. mat41.e23 = t231;
  33288. mat41.e30 = t301;
  33289. mat41.e31 = t311;
  33290. mat41.e32 = t321;
  33291. mat41.e33 = t331;
  33292. if(_this54.sizeMat4 == _this54.stackMat4.length) {
  33293. var newLength6 = _this54.sizeMat4 << 1;
  33294. var this7 = new Array(newLength6);
  33295. var newArray6 = this7;
  33296. var _g10 = 0;
  33297. var _g18 = _this54.sizeMat4;
  33298. while(_g10 < _g18) {
  33299. var i8 = _g10++;
  33300. newArray6[i8] = _this54.stackMat4[i8];
  33301. _this54.stackMat4[i8] = null;
  33302. }
  33303. _this54.stackMat4 = newArray6;
  33304. }
  33305. _this54.stackMat4[_this54.sizeMat4++] = mat41;
  33306. }
  33307. if(quat1 != null) {
  33308. var tx26 = 0;
  33309. var ty26 = 0;
  33310. var tz26 = 0;
  33311. var tw1 = 1;
  33312. quat1.x = tx26;
  33313. quat1.y = ty26;
  33314. quat1.z = tz26;
  33315. quat1.w = tw1;
  33316. if(_this54.sizeQuat == _this54.stackQuat.length) {
  33317. var newLength7 = _this54.sizeQuat << 1;
  33318. var this8 = new Array(newLength7);
  33319. var newArray7 = this8;
  33320. var _g19 = 0;
  33321. var _g110 = _this54.sizeQuat;
  33322. while(_g19 < _g110) {
  33323. var i9 = _g19++;
  33324. newArray7[i9] = _this54.stackQuat[i9];
  33325. _this54.stackQuat[i9] = null;
  33326. }
  33327. _this54.stackQuat = newArray7;
  33328. }
  33329. _this54.stackQuat[_this54.sizeQuat++] = quat1;
  33330. }
  33331. var _this55 = this.p;
  33332. var mat32 = null;
  33333. var mat42 = null;
  33334. var quat2 = null;
  33335. if(top3 != null) {
  33336. top3.zero();
  33337. if(_this55.sizeVec3 == _this55.stackVec3.length) {
  33338. var newLength8 = _this55.sizeVec3 << 1;
  33339. var this9 = new Array(newLength8);
  33340. var newArray8 = this9;
  33341. var _g20 = 0;
  33342. var _g111 = _this55.sizeVec3;
  33343. while(_g20 < _g111) {
  33344. var i10 = _g20++;
  33345. newArray8[i10] = _this55.stackVec3[i10];
  33346. _this55.stackVec3[i10] = null;
  33347. }
  33348. _this55.stackVec3 = newArray8;
  33349. }
  33350. _this55.stackVec3[_this55.sizeVec3++] = top3;
  33351. }
  33352. if(mat32 != null) {
  33353. var t004 = 1;
  33354. var t014 = 0;
  33355. var t024 = 0;
  33356. var t104 = 0;
  33357. var t114 = 1;
  33358. var t124 = 0;
  33359. var t204 = 0;
  33360. var t214 = 0;
  33361. var t224 = 1;
  33362. mat32.e00 = t004;
  33363. mat32.e01 = t014;
  33364. mat32.e02 = t024;
  33365. mat32.e10 = t104;
  33366. mat32.e11 = t114;
  33367. mat32.e12 = t124;
  33368. mat32.e20 = t204;
  33369. mat32.e21 = t214;
  33370. mat32.e22 = t224;
  33371. if(_this55.sizeMat3 == _this55.stackMat3.length) {
  33372. var newLength9 = _this55.sizeMat3 << 1;
  33373. var this10 = new Array(newLength9);
  33374. var newArray9 = this10;
  33375. var _g27 = 0;
  33376. var _g112 = _this55.sizeMat3;
  33377. while(_g27 < _g112) {
  33378. var i11 = _g27++;
  33379. newArray9[i11] = _this55.stackMat3[i11];
  33380. _this55.stackMat3[i11] = null;
  33381. }
  33382. _this55.stackMat3 = newArray9;
  33383. }
  33384. _this55.stackMat3[_this55.sizeMat3++] = mat32;
  33385. }
  33386. if(mat42 != null) {
  33387. var t005 = 1;
  33388. var t015 = 0;
  33389. var t025 = 0;
  33390. var t032 = 0;
  33391. var t105 = 0;
  33392. var t115 = 1;
  33393. var t125 = 0;
  33394. var t132 = 0;
  33395. var t205 = 0;
  33396. var t215 = 0;
  33397. var t225 = 1;
  33398. var t232 = 0;
  33399. var t302 = 0;
  33400. var t312 = 0;
  33401. var t322 = 0;
  33402. var t332 = 1;
  33403. mat42.e00 = t005;
  33404. mat42.e01 = t015;
  33405. mat42.e02 = t025;
  33406. mat42.e03 = t032;
  33407. mat42.e10 = t105;
  33408. mat42.e11 = t115;
  33409. mat42.e12 = t125;
  33410. mat42.e13 = t132;
  33411. mat42.e20 = t205;
  33412. mat42.e21 = t215;
  33413. mat42.e22 = t225;
  33414. mat42.e23 = t232;
  33415. mat42.e30 = t302;
  33416. mat42.e31 = t312;
  33417. mat42.e32 = t322;
  33418. mat42.e33 = t332;
  33419. if(_this55.sizeMat4 == _this55.stackMat4.length) {
  33420. var newLength10 = _this55.sizeMat4 << 1;
  33421. var this11 = new Array(newLength10);
  33422. var newArray10 = this11;
  33423. var _g28 = 0;
  33424. var _g113 = _this55.sizeMat4;
  33425. while(_g28 < _g113) {
  33426. var i12 = _g28++;
  33427. newArray10[i12] = _this55.stackMat4[i12];
  33428. _this55.stackMat4[i12] = null;
  33429. }
  33430. _this55.stackMat4 = newArray10;
  33431. }
  33432. _this55.stackMat4[_this55.sizeMat4++] = mat42;
  33433. }
  33434. if(quat2 != null) {
  33435. var tx27 = 0;
  33436. var ty27 = 0;
  33437. var tz27 = 0;
  33438. var tw2 = 1;
  33439. quat2.x = tx27;
  33440. quat2.y = ty27;
  33441. quat2.z = tz27;
  33442. quat2.w = tw2;
  33443. if(_this55.sizeQuat == _this55.stackQuat.length) {
  33444. var newLength11 = _this55.sizeQuat << 1;
  33445. var this12 = new Array(newLength11);
  33446. var newArray11 = this12;
  33447. var _g29 = 0;
  33448. var _g114 = _this55.sizeQuat;
  33449. while(_g29 < _g114) {
  33450. var i13 = _g29++;
  33451. newArray11[i13] = _this55.stackQuat[i13];
  33452. _this55.stackQuat[i13] = null;
  33453. }
  33454. _this55.stackQuat = newArray11;
  33455. }
  33456. _this55.stackQuat[_this55.sizeQuat++] = quat2;
  33457. }
  33458. var _this56 = this.p;
  33459. var mat33 = null;
  33460. var mat43 = null;
  33461. var quat3 = null;
  33462. if(top4 != null) {
  33463. top4.zero();
  33464. if(_this56.sizeVec3 == _this56.stackVec3.length) {
  33465. var newLength12 = _this56.sizeVec3 << 1;
  33466. var this13 = new Array(newLength12);
  33467. var newArray12 = this13;
  33468. var _g30 = 0;
  33469. var _g115 = _this56.sizeVec3;
  33470. while(_g30 < _g115) {
  33471. var i14 = _g30++;
  33472. newArray12[i14] = _this56.stackVec3[i14];
  33473. _this56.stackVec3[i14] = null;
  33474. }
  33475. _this56.stackVec3 = newArray12;
  33476. }
  33477. _this56.stackVec3[_this56.sizeVec3++] = top4;
  33478. }
  33479. if(mat33 != null) {
  33480. var t006 = 1;
  33481. var t016 = 0;
  33482. var t026 = 0;
  33483. var t106 = 0;
  33484. var t116 = 1;
  33485. var t126 = 0;
  33486. var t206 = 0;
  33487. var t216 = 0;
  33488. var t226 = 1;
  33489. mat33.e00 = t006;
  33490. mat33.e01 = t016;
  33491. mat33.e02 = t026;
  33492. mat33.e10 = t106;
  33493. mat33.e11 = t116;
  33494. mat33.e12 = t126;
  33495. mat33.e20 = t206;
  33496. mat33.e21 = t216;
  33497. mat33.e22 = t226;
  33498. if(_this56.sizeMat3 == _this56.stackMat3.length) {
  33499. var newLength13 = _this56.sizeMat3 << 1;
  33500. var this14 = new Array(newLength13);
  33501. var newArray13 = this14;
  33502. var _g36 = 0;
  33503. var _g116 = _this56.sizeMat3;
  33504. while(_g36 < _g116) {
  33505. var i15 = _g36++;
  33506. newArray13[i15] = _this56.stackMat3[i15];
  33507. _this56.stackMat3[i15] = null;
  33508. }
  33509. _this56.stackMat3 = newArray13;
  33510. }
  33511. _this56.stackMat3[_this56.sizeMat3++] = mat33;
  33512. }
  33513. if(mat43 != null) {
  33514. var t007 = 1;
  33515. var t017 = 0;
  33516. var t027 = 0;
  33517. var t033 = 0;
  33518. var t107 = 0;
  33519. var t117 = 1;
  33520. var t127 = 0;
  33521. var t133 = 0;
  33522. var t207 = 0;
  33523. var t217 = 0;
  33524. var t227 = 1;
  33525. var t233 = 0;
  33526. var t303 = 0;
  33527. var t313 = 0;
  33528. var t323 = 0;
  33529. var t333 = 1;
  33530. mat43.e00 = t007;
  33531. mat43.e01 = t017;
  33532. mat43.e02 = t027;
  33533. mat43.e03 = t033;
  33534. mat43.e10 = t107;
  33535. mat43.e11 = t117;
  33536. mat43.e12 = t127;
  33537. mat43.e13 = t133;
  33538. mat43.e20 = t207;
  33539. mat43.e21 = t217;
  33540. mat43.e22 = t227;
  33541. mat43.e23 = t233;
  33542. mat43.e30 = t303;
  33543. mat43.e31 = t313;
  33544. mat43.e32 = t323;
  33545. mat43.e33 = t333;
  33546. if(_this56.sizeMat4 == _this56.stackMat4.length) {
  33547. var newLength14 = _this56.sizeMat4 << 1;
  33548. var this15 = new Array(newLength14);
  33549. var newArray14 = this15;
  33550. var _g37 = 0;
  33551. var _g117 = _this56.sizeMat4;
  33552. while(_g37 < _g117) {
  33553. var i16 = _g37++;
  33554. newArray14[i16] = _this56.stackMat4[i16];
  33555. _this56.stackMat4[i16] = null;
  33556. }
  33557. _this56.stackMat4 = newArray14;
  33558. }
  33559. _this56.stackMat4[_this56.sizeMat4++] = mat43;
  33560. }
  33561. if(quat3 != null) {
  33562. var tx28 = 0;
  33563. var ty28 = 0;
  33564. var tz28 = 0;
  33565. var tw3 = 1;
  33566. quat3.x = tx28;
  33567. quat3.y = ty28;
  33568. quat3.z = tz28;
  33569. quat3.w = tw3;
  33570. if(_this56.sizeQuat == _this56.stackQuat.length) {
  33571. var newLength15 = _this56.sizeQuat << 1;
  33572. var this16 = new Array(newLength15);
  33573. var newArray15 = this16;
  33574. var _g38 = 0;
  33575. var _g118 = _this56.sizeQuat;
  33576. while(_g38 < _g118) {
  33577. var i17 = _g38++;
  33578. newArray15[i17] = _this56.stackQuat[i17];
  33579. _this56.stackQuat[i17] = null;
  33580. }
  33581. _this56.stackQuat = newArray15;
  33582. }
  33583. _this56.stackQuat[_this56.sizeQuat++] = quat3;
  33584. }
  33585. var _this57 = this.p;
  33586. var mat34 = null;
  33587. var mat44 = null;
  33588. var quat4 = null;
  33589. if(bottom1 != null) {
  33590. bottom1.zero();
  33591. if(_this57.sizeVec3 == _this57.stackVec3.length) {
  33592. var newLength16 = _this57.sizeVec3 << 1;
  33593. var this17 = new Array(newLength16);
  33594. var newArray16 = this17;
  33595. var _g39 = 0;
  33596. var _g119 = _this57.sizeVec3;
  33597. while(_g39 < _g119) {
  33598. var i18 = _g39++;
  33599. newArray16[i18] = _this57.stackVec3[i18];
  33600. _this57.stackVec3[i18] = null;
  33601. }
  33602. _this57.stackVec3 = newArray16;
  33603. }
  33604. _this57.stackVec3[_this57.sizeVec3++] = bottom1;
  33605. }
  33606. if(mat34 != null) {
  33607. var t008 = 1;
  33608. var t018 = 0;
  33609. var t028 = 0;
  33610. var t108 = 0;
  33611. var t118 = 1;
  33612. var t128 = 0;
  33613. var t208 = 0;
  33614. var t218 = 0;
  33615. var t228 = 1;
  33616. mat34.e00 = t008;
  33617. mat34.e01 = t018;
  33618. mat34.e02 = t028;
  33619. mat34.e10 = t108;
  33620. mat34.e11 = t118;
  33621. mat34.e12 = t128;
  33622. mat34.e20 = t208;
  33623. mat34.e21 = t218;
  33624. mat34.e22 = t228;
  33625. if(_this57.sizeMat3 == _this57.stackMat3.length) {
  33626. var newLength17 = _this57.sizeMat3 << 1;
  33627. var this18 = new Array(newLength17);
  33628. var newArray17 = this18;
  33629. var _g40 = 0;
  33630. var _g120 = _this57.sizeMat3;
  33631. while(_g40 < _g120) {
  33632. var i19 = _g40++;
  33633. newArray17[i19] = _this57.stackMat3[i19];
  33634. _this57.stackMat3[i19] = null;
  33635. }
  33636. _this57.stackMat3 = newArray17;
  33637. }
  33638. _this57.stackMat3[_this57.sizeMat3++] = mat34;
  33639. }
  33640. if(mat44 != null) {
  33641. var t009 = 1;
  33642. var t019 = 0;
  33643. var t029 = 0;
  33644. var t034 = 0;
  33645. var t109 = 0;
  33646. var t119 = 1;
  33647. var t129 = 0;
  33648. var t134 = 0;
  33649. var t209 = 0;
  33650. var t219 = 0;
  33651. var t229 = 1;
  33652. var t234 = 0;
  33653. var t304 = 0;
  33654. var t314 = 0;
  33655. var t324 = 0;
  33656. var t334 = 1;
  33657. mat44.e00 = t009;
  33658. mat44.e01 = t019;
  33659. mat44.e02 = t029;
  33660. mat44.e03 = t034;
  33661. mat44.e10 = t109;
  33662. mat44.e11 = t119;
  33663. mat44.e12 = t129;
  33664. mat44.e13 = t134;
  33665. mat44.e20 = t209;
  33666. mat44.e21 = t219;
  33667. mat44.e22 = t229;
  33668. mat44.e23 = t234;
  33669. mat44.e30 = t304;
  33670. mat44.e31 = t314;
  33671. mat44.e32 = t324;
  33672. mat44.e33 = t334;
  33673. if(_this57.sizeMat4 == _this57.stackMat4.length) {
  33674. var newLength18 = _this57.sizeMat4 << 1;
  33675. var this19 = new Array(newLength18);
  33676. var newArray18 = this19;
  33677. var _g41 = 0;
  33678. var _g121 = _this57.sizeMat4;
  33679. while(_g41 < _g121) {
  33680. var i20 = _g41++;
  33681. newArray18[i20] = _this57.stackMat4[i20];
  33682. _this57.stackMat4[i20] = null;
  33683. }
  33684. _this57.stackMat4 = newArray18;
  33685. }
  33686. _this57.stackMat4[_this57.sizeMat4++] = mat44;
  33687. }
  33688. if(quat4 != null) {
  33689. var tx29 = 0;
  33690. var ty29 = 0;
  33691. var tz29 = 0;
  33692. var tw4 = 1;
  33693. quat4.x = tx29;
  33694. quat4.y = ty29;
  33695. quat4.z = tz29;
  33696. quat4.w = tw4;
  33697. if(_this57.sizeQuat == _this57.stackQuat.length) {
  33698. var newLength19 = _this57.sizeQuat << 1;
  33699. var this20 = new Array(newLength19);
  33700. var newArray19 = this20;
  33701. var _g42 = 0;
  33702. var _g122 = _this57.sizeQuat;
  33703. while(_g42 < _g122) {
  33704. var i23 = _g42++;
  33705. newArray19[i23] = _this57.stackQuat[i23];
  33706. _this57.stackQuat[i23] = null;
  33707. }
  33708. _this57.stackQuat = newArray19;
  33709. }
  33710. _this57.stackQuat[_this57.sizeQuat++] = quat4;
  33711. }
  33712. var _this58 = this.p;
  33713. var mat35 = null;
  33714. var mat45 = null;
  33715. var quat5 = null;
  33716. if(bottom2 != null) {
  33717. bottom2.zero();
  33718. if(_this58.sizeVec3 == _this58.stackVec3.length) {
  33719. var newLength20 = _this58.sizeVec3 << 1;
  33720. var this21 = new Array(newLength20);
  33721. var newArray20 = this21;
  33722. var _g43 = 0;
  33723. var _g123 = _this58.sizeVec3;
  33724. while(_g43 < _g123) {
  33725. var i24 = _g43++;
  33726. newArray20[i24] = _this58.stackVec3[i24];
  33727. _this58.stackVec3[i24] = null;
  33728. }
  33729. _this58.stackVec3 = newArray20;
  33730. }
  33731. _this58.stackVec3[_this58.sizeVec3++] = bottom2;
  33732. }
  33733. if(mat35 != null) {
  33734. var t0010 = 1;
  33735. var t0110 = 0;
  33736. var t0210 = 0;
  33737. var t1010 = 0;
  33738. var t1110 = 1;
  33739. var t1210 = 0;
  33740. var t2010 = 0;
  33741. var t2110 = 0;
  33742. var t2210 = 1;
  33743. mat35.e00 = t0010;
  33744. mat35.e01 = t0110;
  33745. mat35.e02 = t0210;
  33746. mat35.e10 = t1010;
  33747. mat35.e11 = t1110;
  33748. mat35.e12 = t1210;
  33749. mat35.e20 = t2010;
  33750. mat35.e21 = t2110;
  33751. mat35.e22 = t2210;
  33752. if(_this58.sizeMat3 == _this58.stackMat3.length) {
  33753. var newLength21 = _this58.sizeMat3 << 1;
  33754. var this22 = new Array(newLength21);
  33755. var newArray21 = this22;
  33756. var _g44 = 0;
  33757. var _g124 = _this58.sizeMat3;
  33758. while(_g44 < _g124) {
  33759. var i25 = _g44++;
  33760. newArray21[i25] = _this58.stackMat3[i25];
  33761. _this58.stackMat3[i25] = null;
  33762. }
  33763. _this58.stackMat3 = newArray21;
  33764. }
  33765. _this58.stackMat3[_this58.sizeMat3++] = mat35;
  33766. }
  33767. if(mat45 != null) {
  33768. var t0011 = 1;
  33769. var t0111 = 0;
  33770. var t0211 = 0;
  33771. var t035 = 0;
  33772. var t1011 = 0;
  33773. var t1111 = 1;
  33774. var t1211 = 0;
  33775. var t135 = 0;
  33776. var t2011 = 0;
  33777. var t2111 = 0;
  33778. var t2211 = 1;
  33779. var t235 = 0;
  33780. var t305 = 0;
  33781. var t315 = 0;
  33782. var t325 = 0;
  33783. var t335 = 1;
  33784. mat45.e00 = t0011;
  33785. mat45.e01 = t0111;
  33786. mat45.e02 = t0211;
  33787. mat45.e03 = t035;
  33788. mat45.e10 = t1011;
  33789. mat45.e11 = t1111;
  33790. mat45.e12 = t1211;
  33791. mat45.e13 = t135;
  33792. mat45.e20 = t2011;
  33793. mat45.e21 = t2111;
  33794. mat45.e22 = t2211;
  33795. mat45.e23 = t235;
  33796. mat45.e30 = t305;
  33797. mat45.e31 = t315;
  33798. mat45.e32 = t325;
  33799. mat45.e33 = t335;
  33800. if(_this58.sizeMat4 == _this58.stackMat4.length) {
  33801. var newLength22 = _this58.sizeMat4 << 1;
  33802. var this23 = new Array(newLength22);
  33803. var newArray22 = this23;
  33804. var _g45 = 0;
  33805. var _g125 = _this58.sizeMat4;
  33806. while(_g45 < _g125) {
  33807. var i26 = _g45++;
  33808. newArray22[i26] = _this58.stackMat4[i26];
  33809. _this58.stackMat4[i26] = null;
  33810. }
  33811. _this58.stackMat4 = newArray22;
  33812. }
  33813. _this58.stackMat4[_this58.sizeMat4++] = mat45;
  33814. }
  33815. if(quat5 != null) {
  33816. var tx30 = 0;
  33817. var ty30 = 0;
  33818. var tz30 = 0;
  33819. var tw5 = 1;
  33820. quat5.x = tx30;
  33821. quat5.y = ty30;
  33822. quat5.z = tz30;
  33823. quat5.w = tw5;
  33824. if(_this58.sizeQuat == _this58.stackQuat.length) {
  33825. var newLength23 = _this58.sizeQuat << 1;
  33826. var this24 = new Array(newLength23);
  33827. var newArray23 = this24;
  33828. var _g46 = 0;
  33829. var _g126 = _this58.sizeQuat;
  33830. while(_g46 < _g126) {
  33831. var i27 = _g46++;
  33832. newArray23[i27] = _this58.stackQuat[i27];
  33833. _this58.stackQuat[i27] = null;
  33834. }
  33835. _this58.stackQuat = newArray23;
  33836. }
  33837. _this58.stackQuat[_this58.sizeQuat++] = quat5;
  33838. }
  33839. var _this59 = this.p;
  33840. var mat36 = null;
  33841. var mat46 = null;
  33842. var quat6 = null;
  33843. if(bottom3 != null) {
  33844. bottom3.zero();
  33845. if(_this59.sizeVec3 == _this59.stackVec3.length) {
  33846. var newLength24 = _this59.sizeVec3 << 1;
  33847. var this25 = new Array(newLength24);
  33848. var newArray24 = this25;
  33849. var _g47 = 0;
  33850. var _g127 = _this59.sizeVec3;
  33851. while(_g47 < _g127) {
  33852. var i28 = _g47++;
  33853. newArray24[i28] = _this59.stackVec3[i28];
  33854. _this59.stackVec3[i28] = null;
  33855. }
  33856. _this59.stackVec3 = newArray24;
  33857. }
  33858. _this59.stackVec3[_this59.sizeVec3++] = bottom3;
  33859. }
  33860. if(mat36 != null) {
  33861. var t0012 = 1;
  33862. var t0112 = 0;
  33863. var t0212 = 0;
  33864. var t1012 = 0;
  33865. var t1112 = 1;
  33866. var t1212 = 0;
  33867. var t2012 = 0;
  33868. var t2112 = 0;
  33869. var t2212 = 1;
  33870. mat36.e00 = t0012;
  33871. mat36.e01 = t0112;
  33872. mat36.e02 = t0212;
  33873. mat36.e10 = t1012;
  33874. mat36.e11 = t1112;
  33875. mat36.e12 = t1212;
  33876. mat36.e20 = t2012;
  33877. mat36.e21 = t2112;
  33878. mat36.e22 = t2212;
  33879. if(_this59.sizeMat3 == _this59.stackMat3.length) {
  33880. var newLength25 = _this59.sizeMat3 << 1;
  33881. var this26 = new Array(newLength25);
  33882. var newArray25 = this26;
  33883. var _g48 = 0;
  33884. var _g128 = _this59.sizeMat3;
  33885. while(_g48 < _g128) {
  33886. var i29 = _g48++;
  33887. newArray25[i29] = _this59.stackMat3[i29];
  33888. _this59.stackMat3[i29] = null;
  33889. }
  33890. _this59.stackMat3 = newArray25;
  33891. }
  33892. _this59.stackMat3[_this59.sizeMat3++] = mat36;
  33893. }
  33894. if(mat46 != null) {
  33895. var t0013 = 1;
  33896. var t0113 = 0;
  33897. var t0213 = 0;
  33898. var t036 = 0;
  33899. var t1013 = 0;
  33900. var t1113 = 1;
  33901. var t1213 = 0;
  33902. var t136 = 0;
  33903. var t2013 = 0;
  33904. var t2113 = 0;
  33905. var t2213 = 1;
  33906. var t236 = 0;
  33907. var t306 = 0;
  33908. var t316 = 0;
  33909. var t326 = 0;
  33910. var t336 = 1;
  33911. mat46.e00 = t0013;
  33912. mat46.e01 = t0113;
  33913. mat46.e02 = t0213;
  33914. mat46.e03 = t036;
  33915. mat46.e10 = t1013;
  33916. mat46.e11 = t1113;
  33917. mat46.e12 = t1213;
  33918. mat46.e13 = t136;
  33919. mat46.e20 = t2013;
  33920. mat46.e21 = t2113;
  33921. mat46.e22 = t2213;
  33922. mat46.e23 = t236;
  33923. mat46.e30 = t306;
  33924. mat46.e31 = t316;
  33925. mat46.e32 = t326;
  33926. mat46.e33 = t336;
  33927. if(_this59.sizeMat4 == _this59.stackMat4.length) {
  33928. var newLength26 = _this59.sizeMat4 << 1;
  33929. var this27 = new Array(newLength26);
  33930. var newArray26 = this27;
  33931. var _g49 = 0;
  33932. var _g129 = _this59.sizeMat4;
  33933. while(_g49 < _g129) {
  33934. var i30 = _g49++;
  33935. newArray26[i30] = _this59.stackMat4[i30];
  33936. _this59.stackMat4[i30] = null;
  33937. }
  33938. _this59.stackMat4 = newArray26;
  33939. }
  33940. _this59.stackMat4[_this59.sizeMat4++] = mat46;
  33941. }
  33942. if(quat6 != null) {
  33943. var tx31 = 0;
  33944. var ty31 = 0;
  33945. var tz31 = 0;
  33946. var tw6 = 1;
  33947. quat6.x = tx31;
  33948. quat6.y = ty31;
  33949. quat6.z = tz31;
  33950. quat6.w = tw6;
  33951. if(_this59.sizeQuat == _this59.stackQuat.length) {
  33952. var newLength27 = _this59.sizeQuat << 1;
  33953. var this28 = new Array(newLength27);
  33954. var newArray27 = this28;
  33955. var _g50 = 0;
  33956. var _g130 = _this59.sizeQuat;
  33957. while(_g50 < _g130) {
  33958. var i31 = _g50++;
  33959. newArray27[i31] = _this59.stackQuat[i31];
  33960. _this59.stackQuat[i31] = null;
  33961. }
  33962. _this59.stackQuat = newArray27;
  33963. }
  33964. _this59.stackQuat[_this59.sizeQuat++] = quat6;
  33965. }
  33966. var _this60 = this.p;
  33967. var mat37 = null;
  33968. var mat47 = null;
  33969. var quat7 = null;
  33970. if(bottom4 != null) {
  33971. bottom4.zero();
  33972. if(_this60.sizeVec3 == _this60.stackVec3.length) {
  33973. var newLength28 = _this60.sizeVec3 << 1;
  33974. var this29 = new Array(newLength28);
  33975. var newArray28 = this29;
  33976. var _g51 = 0;
  33977. var _g131 = _this60.sizeVec3;
  33978. while(_g51 < _g131) {
  33979. var i32 = _g51++;
  33980. newArray28[i32] = _this60.stackVec3[i32];
  33981. _this60.stackVec3[i32] = null;
  33982. }
  33983. _this60.stackVec3 = newArray28;
  33984. }
  33985. _this60.stackVec3[_this60.sizeVec3++] = bottom4;
  33986. }
  33987. if(mat37 != null) {
  33988. var t0014 = 1;
  33989. var t0114 = 0;
  33990. var t0214 = 0;
  33991. var t1014 = 0;
  33992. var t1114 = 1;
  33993. var t1214 = 0;
  33994. var t2014 = 0;
  33995. var t2114 = 0;
  33996. var t2214 = 1;
  33997. mat37.e00 = t0014;
  33998. mat37.e01 = t0114;
  33999. mat37.e02 = t0214;
  34000. mat37.e10 = t1014;
  34001. mat37.e11 = t1114;
  34002. mat37.e12 = t1214;
  34003. mat37.e20 = t2014;
  34004. mat37.e21 = t2114;
  34005. mat37.e22 = t2214;
  34006. if(_this60.sizeMat3 == _this60.stackMat3.length) {
  34007. var newLength29 = _this60.sizeMat3 << 1;
  34008. var this30 = new Array(newLength29);
  34009. var newArray29 = this30;
  34010. var _g52 = 0;
  34011. var _g132 = _this60.sizeMat3;
  34012. while(_g52 < _g132) {
  34013. var i33 = _g52++;
  34014. newArray29[i33] = _this60.stackMat3[i33];
  34015. _this60.stackMat3[i33] = null;
  34016. }
  34017. _this60.stackMat3 = newArray29;
  34018. }
  34019. _this60.stackMat3[_this60.sizeMat3++] = mat37;
  34020. }
  34021. if(mat47 != null) {
  34022. var t0015 = 1;
  34023. var t0115 = 0;
  34024. var t0215 = 0;
  34025. var t037 = 0;
  34026. var t1015 = 0;
  34027. var t1115 = 1;
  34028. var t1215 = 0;
  34029. var t137 = 0;
  34030. var t2015 = 0;
  34031. var t2115 = 0;
  34032. var t2215 = 1;
  34033. var t237 = 0;
  34034. var t307 = 0;
  34035. var t317 = 0;
  34036. var t327 = 0;
  34037. var t337 = 1;
  34038. mat47.e00 = t0015;
  34039. mat47.e01 = t0115;
  34040. mat47.e02 = t0215;
  34041. mat47.e03 = t037;
  34042. mat47.e10 = t1015;
  34043. mat47.e11 = t1115;
  34044. mat47.e12 = t1215;
  34045. mat47.e13 = t137;
  34046. mat47.e20 = t2015;
  34047. mat47.e21 = t2115;
  34048. mat47.e22 = t2215;
  34049. mat47.e23 = t237;
  34050. mat47.e30 = t307;
  34051. mat47.e31 = t317;
  34052. mat47.e32 = t327;
  34053. mat47.e33 = t337;
  34054. if(_this60.sizeMat4 == _this60.stackMat4.length) {
  34055. var newLength30 = _this60.sizeMat4 << 1;
  34056. var this31 = new Array(newLength30);
  34057. var newArray30 = this31;
  34058. var _g53 = 0;
  34059. var _g133 = _this60.sizeMat4;
  34060. while(_g53 < _g133) {
  34061. var i34 = _g53++;
  34062. newArray30[i34] = _this60.stackMat4[i34];
  34063. _this60.stackMat4[i34] = null;
  34064. }
  34065. _this60.stackMat4 = newArray30;
  34066. }
  34067. _this60.stackMat4[_this60.sizeMat4++] = mat47;
  34068. }
  34069. if(quat7 != null) {
  34070. var tx32 = 0;
  34071. var ty32 = 0;
  34072. var tz32 = 0;
  34073. var tw7 = 1;
  34074. quat7.x = tx32;
  34075. quat7.y = ty32;
  34076. quat7.z = tz32;
  34077. quat7.w = tw7;
  34078. if(_this60.sizeQuat == _this60.stackQuat.length) {
  34079. var newLength31 = _this60.sizeQuat << 1;
  34080. var this32 = new Array(newLength31);
  34081. var newArray31 = this32;
  34082. var _g54 = 0;
  34083. var _g134 = _this60.sizeQuat;
  34084. while(_g54 < _g134) {
  34085. var i35 = _g54++;
  34086. newArray31[i35] = _this60.stackQuat[i35];
  34087. _this60.stackQuat[i35] = null;
  34088. }
  34089. _this60.stackQuat = newArray31;
  34090. }
  34091. _this60.stackQuat[_this60.sizeQuat++] = quat7;
  34092. }
  34093. } else {
  34094. var _g410 = 0;
  34095. while(_g410 < 8) {
  34096. var i36 = _g410++;
  34097. var _this61 = this.tmpCircleNorms[i36];
  34098. var v5 = this.circleCoords[i36];
  34099. _this61.x = v5.x;
  34100. _this61.y = v5.y;
  34101. _this61.z = v5.z;
  34102. var _this62 = _this61;
  34103. var tx33 = _this62.x * m.e00 + _this62.y * m.e01 + _this62.z * m.e02;
  34104. var ty33 = _this62.x * m.e10 + _this62.y * m.e11 + _this62.z * m.e12;
  34105. var tz33 = _this62.x * m.e20 + _this62.y * m.e21 + _this62.z * m.e22;
  34106. _this62.x = tx33;
  34107. _this62.y = ty33;
  34108. _this62.z = tz33;
  34109. var _this63 = this.tmpCircleVerts1[i36];
  34110. var v6 = this.tmpCircleNorms[i36];
  34111. _this63.x = v6.x;
  34112. _this63.y = v6.y;
  34113. _this63.z = v6.z;
  34114. var _this64 = _this63;
  34115. var tx34 = _this64.x * radius;
  34116. var ty34 = _this64.y * radius;
  34117. var tz34 = _this64.z * radius;
  34118. _this64.x = tx34;
  34119. _this64.y = ty34;
  34120. _this64.z = tz34;
  34121. var _this65 = _this64;
  34122. var tx35 = _this65.x + o.x;
  34123. var ty35 = _this65.y + o.y;
  34124. var tz35 = _this65.z + o.z;
  34125. _this65.x = tx35;
  34126. _this65.y = ty35;
  34127. _this65.z = tz35;
  34128. var _this66 = this.tmpCircleVerts2[i36];
  34129. var v7 = this.tmpCircleVerts1[i36];
  34130. _this66.x = v7.x;
  34131. _this66.y = v7.y;
  34132. _this66.z = v7.z;
  34133. var _this67 = this.tmpCircleVerts1[i36];
  34134. var tx36 = _this67.x + ey.x * halfHeight;
  34135. var ty36 = _this67.y + ey.y * halfHeight;
  34136. var tz36 = _this67.z + ey.z * halfHeight;
  34137. _this67.x = tx36;
  34138. _this67.y = ty36;
  34139. _this67.z = tz36;
  34140. var _this68 = this.tmpCircleVerts2[i36];
  34141. var s6 = -halfHeight;
  34142. var tx37 = _this68.x + ey.x * s6;
  34143. var ty37 = _this68.y + ey.y * s6;
  34144. var tz37 = _this68.z + ey.z * s6;
  34145. _this68.x = tx37;
  34146. _this68.y = ty37;
  34147. _this68.z = tz37;
  34148. }
  34149. var _g55 = 0;
  34150. while(_g55 < 8) {
  34151. var i37 = _g55++;
  34152. var v12 = this.tmpCircleVerts1[i37];
  34153. var v22 = this.tmpCircleVerts2[i37];
  34154. var v32 = this.tmpCircleVerts2[(i37 + 1) % 8];
  34155. var v41 = this.tmpCircleVerts1[(i37 + 1) % 8];
  34156. var n12 = this.tmpCircleNorms[i37];
  34157. var n22 = this.tmpCircleNorms[(i37 + 1) % 8];
  34158. this.rect(v12,v22,v32,v41,n12,n12,n22,n22,color);
  34159. }
  34160. }
  34161. var _this69 = this.p;
  34162. var mat38 = null;
  34163. var mat48 = null;
  34164. var quat8 = null;
  34165. if(top != null) {
  34166. top.zero();
  34167. if(_this69.sizeVec3 == _this69.stackVec3.length) {
  34168. var newLength32 = _this69.sizeVec3 << 1;
  34169. var this33 = new Array(newLength32);
  34170. var newArray32 = this33;
  34171. var _g56 = 0;
  34172. var _g135 = _this69.sizeVec3;
  34173. while(_g56 < _g135) {
  34174. var i38 = _g56++;
  34175. newArray32[i38] = _this69.stackVec3[i38];
  34176. _this69.stackVec3[i38] = null;
  34177. }
  34178. _this69.stackVec3 = newArray32;
  34179. }
  34180. _this69.stackVec3[_this69.sizeVec3++] = top;
  34181. }
  34182. if(mat38 != null) {
  34183. var t0016 = 1;
  34184. var t0116 = 0;
  34185. var t0216 = 0;
  34186. var t1016 = 0;
  34187. var t1116 = 1;
  34188. var t1216 = 0;
  34189. var t2016 = 0;
  34190. var t2116 = 0;
  34191. var t2216 = 1;
  34192. mat38.e00 = t0016;
  34193. mat38.e01 = t0116;
  34194. mat38.e02 = t0216;
  34195. mat38.e10 = t1016;
  34196. mat38.e11 = t1116;
  34197. mat38.e12 = t1216;
  34198. mat38.e20 = t2016;
  34199. mat38.e21 = t2116;
  34200. mat38.e22 = t2216;
  34201. if(_this69.sizeMat3 == _this69.stackMat3.length) {
  34202. var newLength33 = _this69.sizeMat3 << 1;
  34203. var this34 = new Array(newLength33);
  34204. var newArray33 = this34;
  34205. var _g57 = 0;
  34206. var _g136 = _this69.sizeMat3;
  34207. while(_g57 < _g136) {
  34208. var i39 = _g57++;
  34209. newArray33[i39] = _this69.stackMat3[i39];
  34210. _this69.stackMat3[i39] = null;
  34211. }
  34212. _this69.stackMat3 = newArray33;
  34213. }
  34214. _this69.stackMat3[_this69.sizeMat3++] = mat38;
  34215. }
  34216. if(mat48 != null) {
  34217. var t0017 = 1;
  34218. var t0117 = 0;
  34219. var t0217 = 0;
  34220. var t038 = 0;
  34221. var t1017 = 0;
  34222. var t1117 = 1;
  34223. var t1217 = 0;
  34224. var t138 = 0;
  34225. var t2017 = 0;
  34226. var t2117 = 0;
  34227. var t2217 = 1;
  34228. var t238 = 0;
  34229. var t308 = 0;
  34230. var t318 = 0;
  34231. var t328 = 0;
  34232. var t338 = 1;
  34233. mat48.e00 = t0017;
  34234. mat48.e01 = t0117;
  34235. mat48.e02 = t0217;
  34236. mat48.e03 = t038;
  34237. mat48.e10 = t1017;
  34238. mat48.e11 = t1117;
  34239. mat48.e12 = t1217;
  34240. mat48.e13 = t138;
  34241. mat48.e20 = t2017;
  34242. mat48.e21 = t2117;
  34243. mat48.e22 = t2217;
  34244. mat48.e23 = t238;
  34245. mat48.e30 = t308;
  34246. mat48.e31 = t318;
  34247. mat48.e32 = t328;
  34248. mat48.e33 = t338;
  34249. if(_this69.sizeMat4 == _this69.stackMat4.length) {
  34250. var newLength34 = _this69.sizeMat4 << 1;
  34251. var this35 = new Array(newLength34);
  34252. var newArray34 = this35;
  34253. var _g58 = 0;
  34254. var _g137 = _this69.sizeMat4;
  34255. while(_g58 < _g137) {
  34256. var i40 = _g58++;
  34257. newArray34[i40] = _this69.stackMat4[i40];
  34258. _this69.stackMat4[i40] = null;
  34259. }
  34260. _this69.stackMat4 = newArray34;
  34261. }
  34262. _this69.stackMat4[_this69.sizeMat4++] = mat48;
  34263. }
  34264. if(quat8 != null) {
  34265. var tx38 = 0;
  34266. var ty38 = 0;
  34267. var tz38 = 0;
  34268. var tw8 = 1;
  34269. quat8.x = tx38;
  34270. quat8.y = ty38;
  34271. quat8.z = tz38;
  34272. quat8.w = tw8;
  34273. if(_this69.sizeQuat == _this69.stackQuat.length) {
  34274. var newLength35 = _this69.sizeQuat << 1;
  34275. var this36 = new Array(newLength35);
  34276. var newArray35 = this36;
  34277. var _g59 = 0;
  34278. var _g138 = _this69.sizeQuat;
  34279. while(_g59 < _g138) {
  34280. var i41 = _g59++;
  34281. newArray35[i41] = _this69.stackQuat[i41];
  34282. _this69.stackQuat[i41] = null;
  34283. }
  34284. _this69.stackQuat = newArray35;
  34285. }
  34286. _this69.stackQuat[_this69.sizeQuat++] = quat8;
  34287. }
  34288. var _this70 = this.p;
  34289. var mat39 = null;
  34290. var mat49 = null;
  34291. var quat9 = null;
  34292. if(bottom != null) {
  34293. bottom.zero();
  34294. if(_this70.sizeVec3 == _this70.stackVec3.length) {
  34295. var newLength36 = _this70.sizeVec3 << 1;
  34296. var this37 = new Array(newLength36);
  34297. var newArray36 = this37;
  34298. var _g60 = 0;
  34299. var _g139 = _this70.sizeVec3;
  34300. while(_g60 < _g139) {
  34301. var i42 = _g60++;
  34302. newArray36[i42] = _this70.stackVec3[i42];
  34303. _this70.stackVec3[i42] = null;
  34304. }
  34305. _this70.stackVec3 = newArray36;
  34306. }
  34307. _this70.stackVec3[_this70.sizeVec3++] = bottom;
  34308. }
  34309. if(mat39 != null) {
  34310. var t0018 = 1;
  34311. var t0118 = 0;
  34312. var t0218 = 0;
  34313. var t1018 = 0;
  34314. var t1118 = 1;
  34315. var t1218 = 0;
  34316. var t2018 = 0;
  34317. var t2118 = 0;
  34318. var t2218 = 1;
  34319. mat39.e00 = t0018;
  34320. mat39.e01 = t0118;
  34321. mat39.e02 = t0218;
  34322. mat39.e10 = t1018;
  34323. mat39.e11 = t1118;
  34324. mat39.e12 = t1218;
  34325. mat39.e20 = t2018;
  34326. mat39.e21 = t2118;
  34327. mat39.e22 = t2218;
  34328. if(_this70.sizeMat3 == _this70.stackMat3.length) {
  34329. var newLength37 = _this70.sizeMat3 << 1;
  34330. var this38 = new Array(newLength37);
  34331. var newArray37 = this38;
  34332. var _g61 = 0;
  34333. var _g140 = _this70.sizeMat3;
  34334. while(_g61 < _g140) {
  34335. var i43 = _g61++;
  34336. newArray37[i43] = _this70.stackMat3[i43];
  34337. _this70.stackMat3[i43] = null;
  34338. }
  34339. _this70.stackMat3 = newArray37;
  34340. }
  34341. _this70.stackMat3[_this70.sizeMat3++] = mat39;
  34342. }
  34343. if(mat49 != null) {
  34344. var t0019 = 1;
  34345. var t0119 = 0;
  34346. var t0219 = 0;
  34347. var t039 = 0;
  34348. var t1019 = 0;
  34349. var t1119 = 1;
  34350. var t1219 = 0;
  34351. var t139 = 0;
  34352. var t2019 = 0;
  34353. var t2119 = 0;
  34354. var t2219 = 1;
  34355. var t239 = 0;
  34356. var t309 = 0;
  34357. var t319 = 0;
  34358. var t329 = 0;
  34359. var t339 = 1;
  34360. mat49.e00 = t0019;
  34361. mat49.e01 = t0119;
  34362. mat49.e02 = t0219;
  34363. mat49.e03 = t039;
  34364. mat49.e10 = t1019;
  34365. mat49.e11 = t1119;
  34366. mat49.e12 = t1219;
  34367. mat49.e13 = t139;
  34368. mat49.e20 = t2019;
  34369. mat49.e21 = t2119;
  34370. mat49.e22 = t2219;
  34371. mat49.e23 = t239;
  34372. mat49.e30 = t309;
  34373. mat49.e31 = t319;
  34374. mat49.e32 = t329;
  34375. mat49.e33 = t339;
  34376. if(_this70.sizeMat4 == _this70.stackMat4.length) {
  34377. var newLength38 = _this70.sizeMat4 << 1;
  34378. var this39 = new Array(newLength38);
  34379. var newArray38 = this39;
  34380. var _g62 = 0;
  34381. var _g141 = _this70.sizeMat4;
  34382. while(_g62 < _g141) {
  34383. var i44 = _g62++;
  34384. newArray38[i44] = _this70.stackMat4[i44];
  34385. _this70.stackMat4[i44] = null;
  34386. }
  34387. _this70.stackMat4 = newArray38;
  34388. }
  34389. _this70.stackMat4[_this70.sizeMat4++] = mat49;
  34390. }
  34391. if(quat9 != null) {
  34392. var tx39 = 0;
  34393. var ty39 = 0;
  34394. var tz39 = 0;
  34395. var tw9 = 1;
  34396. quat9.x = tx39;
  34397. quat9.y = ty39;
  34398. quat9.z = tz39;
  34399. quat9.w = tw9;
  34400. if(_this70.sizeQuat == _this70.stackQuat.length) {
  34401. var newLength39 = _this70.sizeQuat << 1;
  34402. var this40 = new Array(newLength39);
  34403. var newArray39 = this40;
  34404. var _g63 = 0;
  34405. var _g142 = _this70.sizeQuat;
  34406. while(_g63 < _g142) {
  34407. var i45 = _g63++;
  34408. newArray39[i45] = _this70.stackQuat[i45];
  34409. _this70.stackQuat[i45] = null;
  34410. }
  34411. _this70.stackQuat = newArray39;
  34412. }
  34413. _this70.stackQuat[_this70.sizeQuat++] = quat9;
  34414. }
  34415. var _this71 = this.p;
  34416. var mat310 = null;
  34417. var mat410 = null;
  34418. var quat10 = null;
  34419. if(o != null) {
  34420. o.zero();
  34421. if(_this71.sizeVec3 == _this71.stackVec3.length) {
  34422. var newLength40 = _this71.sizeVec3 << 1;
  34423. var this41 = new Array(newLength40);
  34424. var newArray40 = this41;
  34425. var _g64 = 0;
  34426. var _g143 = _this71.sizeVec3;
  34427. while(_g64 < _g143) {
  34428. var i46 = _g64++;
  34429. newArray40[i46] = _this71.stackVec3[i46];
  34430. _this71.stackVec3[i46] = null;
  34431. }
  34432. _this71.stackVec3 = newArray40;
  34433. }
  34434. _this71.stackVec3[_this71.sizeVec3++] = o;
  34435. }
  34436. if(mat310 != null) {
  34437. var t0020 = 1;
  34438. var t0120 = 0;
  34439. var t0220 = 0;
  34440. var t1020 = 0;
  34441. var t1120 = 1;
  34442. var t1220 = 0;
  34443. var t2020 = 0;
  34444. var t2120 = 0;
  34445. var t2220 = 1;
  34446. mat310.e00 = t0020;
  34447. mat310.e01 = t0120;
  34448. mat310.e02 = t0220;
  34449. mat310.e10 = t1020;
  34450. mat310.e11 = t1120;
  34451. mat310.e12 = t1220;
  34452. mat310.e20 = t2020;
  34453. mat310.e21 = t2120;
  34454. mat310.e22 = t2220;
  34455. if(_this71.sizeMat3 == _this71.stackMat3.length) {
  34456. var newLength41 = _this71.sizeMat3 << 1;
  34457. var this42 = new Array(newLength41);
  34458. var newArray41 = this42;
  34459. var _g65 = 0;
  34460. var _g144 = _this71.sizeMat3;
  34461. while(_g65 < _g144) {
  34462. var i47 = _g65++;
  34463. newArray41[i47] = _this71.stackMat3[i47];
  34464. _this71.stackMat3[i47] = null;
  34465. }
  34466. _this71.stackMat3 = newArray41;
  34467. }
  34468. _this71.stackMat3[_this71.sizeMat3++] = mat310;
  34469. }
  34470. if(mat410 != null) {
  34471. var t0021 = 1;
  34472. var t0121 = 0;
  34473. var t0221 = 0;
  34474. var t0310 = 0;
  34475. var t1021 = 0;
  34476. var t1121 = 1;
  34477. var t1221 = 0;
  34478. var t1310 = 0;
  34479. var t2021 = 0;
  34480. var t2121 = 0;
  34481. var t2221 = 1;
  34482. var t2310 = 0;
  34483. var t3010 = 0;
  34484. var t3110 = 0;
  34485. var t3210 = 0;
  34486. var t3310 = 1;
  34487. mat410.e00 = t0021;
  34488. mat410.e01 = t0121;
  34489. mat410.e02 = t0221;
  34490. mat410.e03 = t0310;
  34491. mat410.e10 = t1021;
  34492. mat410.e11 = t1121;
  34493. mat410.e12 = t1221;
  34494. mat410.e13 = t1310;
  34495. mat410.e20 = t2021;
  34496. mat410.e21 = t2121;
  34497. mat410.e22 = t2221;
  34498. mat410.e23 = t2310;
  34499. mat410.e30 = t3010;
  34500. mat410.e31 = t3110;
  34501. mat410.e32 = t3210;
  34502. mat410.e33 = t3310;
  34503. if(_this71.sizeMat4 == _this71.stackMat4.length) {
  34504. var newLength42 = _this71.sizeMat4 << 1;
  34505. var this43 = new Array(newLength42);
  34506. var newArray42 = this43;
  34507. var _g66 = 0;
  34508. var _g145 = _this71.sizeMat4;
  34509. while(_g66 < _g145) {
  34510. var i48 = _g66++;
  34511. newArray42[i48] = _this71.stackMat4[i48];
  34512. _this71.stackMat4[i48] = null;
  34513. }
  34514. _this71.stackMat4 = newArray42;
  34515. }
  34516. _this71.stackMat4[_this71.sizeMat4++] = mat410;
  34517. }
  34518. if(quat10 != null) {
  34519. var tx40 = 0;
  34520. var ty40 = 0;
  34521. var tz40 = 0;
  34522. var tw10 = 1;
  34523. quat10.x = tx40;
  34524. quat10.y = ty40;
  34525. quat10.z = tz40;
  34526. quat10.w = tw10;
  34527. if(_this71.sizeQuat == _this71.stackQuat.length) {
  34528. var newLength43 = _this71.sizeQuat << 1;
  34529. var this44 = new Array(newLength43);
  34530. var newArray43 = this44;
  34531. var _g67 = 0;
  34532. var _g146 = _this71.sizeQuat;
  34533. while(_g67 < _g146) {
  34534. var i49 = _g67++;
  34535. newArray43[i49] = _this71.stackQuat[i49];
  34536. _this71.stackQuat[i49] = null;
  34537. }
  34538. _this71.stackQuat = newArray43;
  34539. }
  34540. _this71.stackQuat[_this71.sizeQuat++] = quat10;
  34541. }
  34542. var _this72 = this.p;
  34543. var vec3 = null;
  34544. var mat411 = null;
  34545. var quat11 = null;
  34546. if(vec3 != null) {
  34547. vec3.zero();
  34548. if(_this72.sizeVec3 == _this72.stackVec3.length) {
  34549. var newLength44 = _this72.sizeVec3 << 1;
  34550. var this45 = new Array(newLength44);
  34551. var newArray44 = this45;
  34552. var _g68 = 0;
  34553. var _g147 = _this72.sizeVec3;
  34554. while(_g68 < _g147) {
  34555. var i50 = _g68++;
  34556. newArray44[i50] = _this72.stackVec3[i50];
  34557. _this72.stackVec3[i50] = null;
  34558. }
  34559. _this72.stackVec3 = newArray44;
  34560. }
  34561. _this72.stackVec3[_this72.sizeVec3++] = vec3;
  34562. }
  34563. if(m != null) {
  34564. var t0022 = 1;
  34565. var t0122 = 0;
  34566. var t0222 = 0;
  34567. var t1022 = 0;
  34568. var t1122 = 1;
  34569. var t1222 = 0;
  34570. var t2022 = 0;
  34571. var t2122 = 0;
  34572. var t2222 = 1;
  34573. m.e00 = t0022;
  34574. m.e01 = t0122;
  34575. m.e02 = t0222;
  34576. m.e10 = t1022;
  34577. m.e11 = t1122;
  34578. m.e12 = t1222;
  34579. m.e20 = t2022;
  34580. m.e21 = t2122;
  34581. m.e22 = t2222;
  34582. if(_this72.sizeMat3 == _this72.stackMat3.length) {
  34583. var newLength45 = _this72.sizeMat3 << 1;
  34584. var this46 = new Array(newLength45);
  34585. var newArray45 = this46;
  34586. var _g69 = 0;
  34587. var _g148 = _this72.sizeMat3;
  34588. while(_g69 < _g148) {
  34589. var i51 = _g69++;
  34590. newArray45[i51] = _this72.stackMat3[i51];
  34591. _this72.stackMat3[i51] = null;
  34592. }
  34593. _this72.stackMat3 = newArray45;
  34594. }
  34595. _this72.stackMat3[_this72.sizeMat3++] = m;
  34596. }
  34597. if(mat411 != null) {
  34598. var t0023 = 1;
  34599. var t0123 = 0;
  34600. var t0223 = 0;
  34601. var t0311 = 0;
  34602. var t1023 = 0;
  34603. var t1123 = 1;
  34604. var t1223 = 0;
  34605. var t1311 = 0;
  34606. var t2023 = 0;
  34607. var t2123 = 0;
  34608. var t2223 = 1;
  34609. var t2311 = 0;
  34610. var t3011 = 0;
  34611. var t3111 = 0;
  34612. var t3211 = 0;
  34613. var t3311 = 1;
  34614. mat411.e00 = t0023;
  34615. mat411.e01 = t0123;
  34616. mat411.e02 = t0223;
  34617. mat411.e03 = t0311;
  34618. mat411.e10 = t1023;
  34619. mat411.e11 = t1123;
  34620. mat411.e12 = t1223;
  34621. mat411.e13 = t1311;
  34622. mat411.e20 = t2023;
  34623. mat411.e21 = t2123;
  34624. mat411.e22 = t2223;
  34625. mat411.e23 = t2311;
  34626. mat411.e30 = t3011;
  34627. mat411.e31 = t3111;
  34628. mat411.e32 = t3211;
  34629. mat411.e33 = t3311;
  34630. if(_this72.sizeMat4 == _this72.stackMat4.length) {
  34631. var newLength46 = _this72.sizeMat4 << 1;
  34632. var this47 = new Array(newLength46);
  34633. var newArray46 = this47;
  34634. var _g70 = 0;
  34635. var _g149 = _this72.sizeMat4;
  34636. while(_g70 < _g149) {
  34637. var i52 = _g70++;
  34638. newArray46[i52] = _this72.stackMat4[i52];
  34639. _this72.stackMat4[i52] = null;
  34640. }
  34641. _this72.stackMat4 = newArray46;
  34642. }
  34643. _this72.stackMat4[_this72.sizeMat4++] = mat411;
  34644. }
  34645. if(quat11 != null) {
  34646. var tx41 = 0;
  34647. var ty41 = 0;
  34648. var tz41 = 0;
  34649. var tw11 = 1;
  34650. quat11.x = tx41;
  34651. quat11.y = ty41;
  34652. quat11.z = tz41;
  34653. quat11.w = tw11;
  34654. if(_this72.sizeQuat == _this72.stackQuat.length) {
  34655. var newLength47 = _this72.sizeQuat << 1;
  34656. var this48 = new Array(newLength47);
  34657. var newArray47 = this48;
  34658. var _g71 = 0;
  34659. var _g150 = _this72.sizeQuat;
  34660. while(_g71 < _g150) {
  34661. var i53 = _g71++;
  34662. newArray47[i53] = _this72.stackQuat[i53];
  34663. _this72.stackQuat[i53] = null;
  34664. }
  34665. _this72.stackQuat = newArray47;
  34666. }
  34667. _this72.stackQuat[_this72.sizeQuat++] = quat11;
  34668. }
  34669. var _this73 = this.p;
  34670. var mat311 = null;
  34671. var mat412 = null;
  34672. var quat12 = null;
  34673. if(ex != null) {
  34674. ex.zero();
  34675. if(_this73.sizeVec3 == _this73.stackVec3.length) {
  34676. var newLength48 = _this73.sizeVec3 << 1;
  34677. var this49 = new Array(newLength48);
  34678. var newArray48 = this49;
  34679. var _g72 = 0;
  34680. var _g151 = _this73.sizeVec3;
  34681. while(_g72 < _g151) {
  34682. var i54 = _g72++;
  34683. newArray48[i54] = _this73.stackVec3[i54];
  34684. _this73.stackVec3[i54] = null;
  34685. }
  34686. _this73.stackVec3 = newArray48;
  34687. }
  34688. _this73.stackVec3[_this73.sizeVec3++] = ex;
  34689. }
  34690. if(mat311 != null) {
  34691. var t0024 = 1;
  34692. var t0124 = 0;
  34693. var t0224 = 0;
  34694. var t1024 = 0;
  34695. var t1124 = 1;
  34696. var t1224 = 0;
  34697. var t2024 = 0;
  34698. var t2124 = 0;
  34699. var t2224 = 1;
  34700. mat311.e00 = t0024;
  34701. mat311.e01 = t0124;
  34702. mat311.e02 = t0224;
  34703. mat311.e10 = t1024;
  34704. mat311.e11 = t1124;
  34705. mat311.e12 = t1224;
  34706. mat311.e20 = t2024;
  34707. mat311.e21 = t2124;
  34708. mat311.e22 = t2224;
  34709. if(_this73.sizeMat3 == _this73.stackMat3.length) {
  34710. var newLength49 = _this73.sizeMat3 << 1;
  34711. var this50 = new Array(newLength49);
  34712. var newArray49 = this50;
  34713. var _g73 = 0;
  34714. var _g152 = _this73.sizeMat3;
  34715. while(_g73 < _g152) {
  34716. var i55 = _g73++;
  34717. newArray49[i55] = _this73.stackMat3[i55];
  34718. _this73.stackMat3[i55] = null;
  34719. }
  34720. _this73.stackMat3 = newArray49;
  34721. }
  34722. _this73.stackMat3[_this73.sizeMat3++] = mat311;
  34723. }
  34724. if(mat412 != null) {
  34725. var t0025 = 1;
  34726. var t0125 = 0;
  34727. var t0225 = 0;
  34728. var t0312 = 0;
  34729. var t1025 = 0;
  34730. var t1125 = 1;
  34731. var t1225 = 0;
  34732. var t1312 = 0;
  34733. var t2025 = 0;
  34734. var t2125 = 0;
  34735. var t2225 = 1;
  34736. var t2312 = 0;
  34737. var t3012 = 0;
  34738. var t3112 = 0;
  34739. var t3212 = 0;
  34740. var t3312 = 1;
  34741. mat412.e00 = t0025;
  34742. mat412.e01 = t0125;
  34743. mat412.e02 = t0225;
  34744. mat412.e03 = t0312;
  34745. mat412.e10 = t1025;
  34746. mat412.e11 = t1125;
  34747. mat412.e12 = t1225;
  34748. mat412.e13 = t1312;
  34749. mat412.e20 = t2025;
  34750. mat412.e21 = t2125;
  34751. mat412.e22 = t2225;
  34752. mat412.e23 = t2312;
  34753. mat412.e30 = t3012;
  34754. mat412.e31 = t3112;
  34755. mat412.e32 = t3212;
  34756. mat412.e33 = t3312;
  34757. if(_this73.sizeMat4 == _this73.stackMat4.length) {
  34758. var newLength50 = _this73.sizeMat4 << 1;
  34759. var this51 = new Array(newLength50);
  34760. var newArray50 = this51;
  34761. var _g74 = 0;
  34762. var _g153 = _this73.sizeMat4;
  34763. while(_g74 < _g153) {
  34764. var i56 = _g74++;
  34765. newArray50[i56] = _this73.stackMat4[i56];
  34766. _this73.stackMat4[i56] = null;
  34767. }
  34768. _this73.stackMat4 = newArray50;
  34769. }
  34770. _this73.stackMat4[_this73.sizeMat4++] = mat412;
  34771. }
  34772. if(quat12 != null) {
  34773. var tx42 = 0;
  34774. var ty42 = 0;
  34775. var tz42 = 0;
  34776. var tw12 = 1;
  34777. quat12.x = tx42;
  34778. quat12.y = ty42;
  34779. quat12.z = tz42;
  34780. quat12.w = tw12;
  34781. if(_this73.sizeQuat == _this73.stackQuat.length) {
  34782. var newLength51 = _this73.sizeQuat << 1;
  34783. var this52 = new Array(newLength51);
  34784. var newArray51 = this52;
  34785. var _g75 = 0;
  34786. var _g154 = _this73.sizeQuat;
  34787. while(_g75 < _g154) {
  34788. var i57 = _g75++;
  34789. newArray51[i57] = _this73.stackQuat[i57];
  34790. _this73.stackQuat[i57] = null;
  34791. }
  34792. _this73.stackQuat = newArray51;
  34793. }
  34794. _this73.stackQuat[_this73.sizeQuat++] = quat12;
  34795. }
  34796. var _this74 = this.p;
  34797. var mat312 = null;
  34798. var mat413 = null;
  34799. var quat13 = null;
  34800. if(ey != null) {
  34801. ey.zero();
  34802. if(_this74.sizeVec3 == _this74.stackVec3.length) {
  34803. var newLength52 = _this74.sizeVec3 << 1;
  34804. var this53 = new Array(newLength52);
  34805. var newArray52 = this53;
  34806. var _g76 = 0;
  34807. var _g155 = _this74.sizeVec3;
  34808. while(_g76 < _g155) {
  34809. var i58 = _g76++;
  34810. newArray52[i58] = _this74.stackVec3[i58];
  34811. _this74.stackVec3[i58] = null;
  34812. }
  34813. _this74.stackVec3 = newArray52;
  34814. }
  34815. _this74.stackVec3[_this74.sizeVec3++] = ey;
  34816. }
  34817. if(mat312 != null) {
  34818. var t0026 = 1;
  34819. var t0126 = 0;
  34820. var t0226 = 0;
  34821. var t1026 = 0;
  34822. var t1126 = 1;
  34823. var t1226 = 0;
  34824. var t2026 = 0;
  34825. var t2126 = 0;
  34826. var t2226 = 1;
  34827. mat312.e00 = t0026;
  34828. mat312.e01 = t0126;
  34829. mat312.e02 = t0226;
  34830. mat312.e10 = t1026;
  34831. mat312.e11 = t1126;
  34832. mat312.e12 = t1226;
  34833. mat312.e20 = t2026;
  34834. mat312.e21 = t2126;
  34835. mat312.e22 = t2226;
  34836. if(_this74.sizeMat3 == _this74.stackMat3.length) {
  34837. var newLength53 = _this74.sizeMat3 << 1;
  34838. var this54 = new Array(newLength53);
  34839. var newArray53 = this54;
  34840. var _g77 = 0;
  34841. var _g156 = _this74.sizeMat3;
  34842. while(_g77 < _g156) {
  34843. var i59 = _g77++;
  34844. newArray53[i59] = _this74.stackMat3[i59];
  34845. _this74.stackMat3[i59] = null;
  34846. }
  34847. _this74.stackMat3 = newArray53;
  34848. }
  34849. _this74.stackMat3[_this74.sizeMat3++] = mat312;
  34850. }
  34851. if(mat413 != null) {
  34852. var t0027 = 1;
  34853. var t0127 = 0;
  34854. var t0227 = 0;
  34855. var t0313 = 0;
  34856. var t1027 = 0;
  34857. var t1127 = 1;
  34858. var t1227 = 0;
  34859. var t1313 = 0;
  34860. var t2027 = 0;
  34861. var t2127 = 0;
  34862. var t2227 = 1;
  34863. var t2313 = 0;
  34864. var t3013 = 0;
  34865. var t3113 = 0;
  34866. var t3213 = 0;
  34867. var t3313 = 1;
  34868. mat413.e00 = t0027;
  34869. mat413.e01 = t0127;
  34870. mat413.e02 = t0227;
  34871. mat413.e03 = t0313;
  34872. mat413.e10 = t1027;
  34873. mat413.e11 = t1127;
  34874. mat413.e12 = t1227;
  34875. mat413.e13 = t1313;
  34876. mat413.e20 = t2027;
  34877. mat413.e21 = t2127;
  34878. mat413.e22 = t2227;
  34879. mat413.e23 = t2313;
  34880. mat413.e30 = t3013;
  34881. mat413.e31 = t3113;
  34882. mat413.e32 = t3213;
  34883. mat413.e33 = t3313;
  34884. if(_this74.sizeMat4 == _this74.stackMat4.length) {
  34885. var newLength54 = _this74.sizeMat4 << 1;
  34886. var this55 = new Array(newLength54);
  34887. var newArray54 = this55;
  34888. var _g78 = 0;
  34889. var _g157 = _this74.sizeMat4;
  34890. while(_g78 < _g157) {
  34891. var i60 = _g78++;
  34892. newArray54[i60] = _this74.stackMat4[i60];
  34893. _this74.stackMat4[i60] = null;
  34894. }
  34895. _this74.stackMat4 = newArray54;
  34896. }
  34897. _this74.stackMat4[_this74.sizeMat4++] = mat413;
  34898. }
  34899. if(quat13 != null) {
  34900. var tx43 = 0;
  34901. var ty43 = 0;
  34902. var tz43 = 0;
  34903. var tw13 = 1;
  34904. quat13.x = tx43;
  34905. quat13.y = ty43;
  34906. quat13.z = tz43;
  34907. quat13.w = tw13;
  34908. if(_this74.sizeQuat == _this74.stackQuat.length) {
  34909. var newLength55 = _this74.sizeQuat << 1;
  34910. var this56 = new Array(newLength55);
  34911. var newArray55 = this56;
  34912. var _g79 = 0;
  34913. var _g158 = _this74.sizeQuat;
  34914. while(_g79 < _g158) {
  34915. var i61 = _g79++;
  34916. newArray55[i61] = _this74.stackQuat[i61];
  34917. _this74.stackQuat[i61] = null;
  34918. }
  34919. _this74.stackQuat = newArray55;
  34920. }
  34921. _this74.stackQuat[_this74.sizeQuat++] = quat13;
  34922. }
  34923. var _this75 = this.p;
  34924. var mat313 = null;
  34925. var mat414 = null;
  34926. var quat14 = null;
  34927. if(ez != null) {
  34928. ez.zero();
  34929. if(_this75.sizeVec3 == _this75.stackVec3.length) {
  34930. var newLength56 = _this75.sizeVec3 << 1;
  34931. var this57 = new Array(newLength56);
  34932. var newArray56 = this57;
  34933. var _g80 = 0;
  34934. var _g159 = _this75.sizeVec3;
  34935. while(_g80 < _g159) {
  34936. var i62 = _g80++;
  34937. newArray56[i62] = _this75.stackVec3[i62];
  34938. _this75.stackVec3[i62] = null;
  34939. }
  34940. _this75.stackVec3 = newArray56;
  34941. }
  34942. _this75.stackVec3[_this75.sizeVec3++] = ez;
  34943. }
  34944. if(mat313 != null) {
  34945. var t0028 = 1;
  34946. var t0128 = 0;
  34947. var t0228 = 0;
  34948. var t1028 = 0;
  34949. var t1128 = 1;
  34950. var t1228 = 0;
  34951. var t2028 = 0;
  34952. var t2128 = 0;
  34953. var t2228 = 1;
  34954. mat313.e00 = t0028;
  34955. mat313.e01 = t0128;
  34956. mat313.e02 = t0228;
  34957. mat313.e10 = t1028;
  34958. mat313.e11 = t1128;
  34959. mat313.e12 = t1228;
  34960. mat313.e20 = t2028;
  34961. mat313.e21 = t2128;
  34962. mat313.e22 = t2228;
  34963. if(_this75.sizeMat3 == _this75.stackMat3.length) {
  34964. var newLength57 = _this75.sizeMat3 << 1;
  34965. var this58 = new Array(newLength57);
  34966. var newArray57 = this58;
  34967. var _g81 = 0;
  34968. var _g160 = _this75.sizeMat3;
  34969. while(_g81 < _g160) {
  34970. var i63 = _g81++;
  34971. newArray57[i63] = _this75.stackMat3[i63];
  34972. _this75.stackMat3[i63] = null;
  34973. }
  34974. _this75.stackMat3 = newArray57;
  34975. }
  34976. _this75.stackMat3[_this75.sizeMat3++] = mat313;
  34977. }
  34978. if(mat414 != null) {
  34979. var t0029 = 1;
  34980. var t0129 = 0;
  34981. var t0229 = 0;
  34982. var t0314 = 0;
  34983. var t1029 = 0;
  34984. var t1129 = 1;
  34985. var t1229 = 0;
  34986. var t1314 = 0;
  34987. var t2029 = 0;
  34988. var t2129 = 0;
  34989. var t2229 = 1;
  34990. var t2314 = 0;
  34991. var t3014 = 0;
  34992. var t3114 = 0;
  34993. var t3214 = 0;
  34994. var t3314 = 1;
  34995. mat414.e00 = t0029;
  34996. mat414.e01 = t0129;
  34997. mat414.e02 = t0229;
  34998. mat414.e03 = t0314;
  34999. mat414.e10 = t1029;
  35000. mat414.e11 = t1129;
  35001. mat414.e12 = t1229;
  35002. mat414.e13 = t1314;
  35003. mat414.e20 = t2029;
  35004. mat414.e21 = t2129;
  35005. mat414.e22 = t2229;
  35006. mat414.e23 = t2314;
  35007. mat414.e30 = t3014;
  35008. mat414.e31 = t3114;
  35009. mat414.e32 = t3214;
  35010. mat414.e33 = t3314;
  35011. if(_this75.sizeMat4 == _this75.stackMat4.length) {
  35012. var newLength58 = _this75.sizeMat4 << 1;
  35013. var this59 = new Array(newLength58);
  35014. var newArray58 = this59;
  35015. var _g82 = 0;
  35016. var _g161 = _this75.sizeMat4;
  35017. while(_g82 < _g161) {
  35018. var i64 = _g82++;
  35019. newArray58[i64] = _this75.stackMat4[i64];
  35020. _this75.stackMat4[i64] = null;
  35021. }
  35022. _this75.stackMat4 = newArray58;
  35023. }
  35024. _this75.stackMat4[_this75.sizeMat4++] = mat414;
  35025. }
  35026. if(quat14 != null) {
  35027. var tx44 = 0;
  35028. var ty44 = 0;
  35029. var tz44 = 0;
  35030. var tw14 = 1;
  35031. quat14.x = tx44;
  35032. quat14.y = ty44;
  35033. quat14.z = tz44;
  35034. quat14.w = tw14;
  35035. if(_this75.sizeQuat == _this75.stackQuat.length) {
  35036. var newLength59 = _this75.sizeQuat << 1;
  35037. var this60 = new Array(newLength59);
  35038. var newArray59 = this60;
  35039. var _g83 = 0;
  35040. var _g162 = _this75.sizeQuat;
  35041. while(_g83 < _g162) {
  35042. var i65 = _g83++;
  35043. newArray59[i65] = _this75.stackQuat[i65];
  35044. _this75.stackQuat[i65] = null;
  35045. }
  35046. _this75.stackQuat = newArray59;
  35047. }
  35048. _this75.stackQuat[_this75.sizeQuat++] = quat14;
  35049. }
  35050. }
  35051. sphere(tf,radius,color) {
  35052. var _this = this.p;
  35053. var o = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  35054. var _this1 = this.p;
  35055. var m = _this1.sizeMat3 == 0 ? new oimo.common.Mat3() : _this1.stackMat3[--_this1.sizeMat3];
  35056. var v = o;
  35057. v.x = tf._positionX;
  35058. v.y = tf._positionY;
  35059. v.z = tf._positionZ;
  35060. var m1 = m;
  35061. m1.e00 = tf._rotation00;
  35062. m1.e01 = tf._rotation01;
  35063. m1.e02 = tf._rotation02;
  35064. m1.e10 = tf._rotation10;
  35065. m1.e11 = tf._rotation11;
  35066. m1.e12 = tf._rotation12;
  35067. m1.e20 = tf._rotation20;
  35068. m1.e21 = tf._rotation21;
  35069. m1.e22 = tf._rotation22;
  35070. var nt = 4;
  35071. var np = 8;
  35072. var vs = this.tmpSphereVerts;
  35073. var ns = this.tmpSphereNorms;
  35074. var _g = 0;
  35075. var _g1 = nt + 1;
  35076. while(_g < _g1) {
  35077. var i = _g++;
  35078. var n = this.tmpSphereVerts[i].length;
  35079. var _g2 = 0;
  35080. var _g11 = n;
  35081. while(_g2 < _g11) {
  35082. var j = _g2++;
  35083. var _this2 = ns[i][j];
  35084. var v1 = this.sphereCoords[i][j];
  35085. _this2.x = v1.x;
  35086. _this2.y = v1.y;
  35087. _this2.z = v1.z;
  35088. var _this3 = _this2;
  35089. var tx = _this3.x * m.e00 + _this3.y * m.e01 + _this3.z * m.e02;
  35090. var ty = _this3.x * m.e10 + _this3.y * m.e11 + _this3.z * m.e12;
  35091. var tz = _this3.x * m.e20 + _this3.y * m.e21 + _this3.z * m.e22;
  35092. _this3.x = tx;
  35093. _this3.y = ty;
  35094. _this3.z = tz;
  35095. var _this4 = vs[i][j];
  35096. var v2 = ns[i][j];
  35097. _this4.x = v2.x;
  35098. _this4.y = v2.y;
  35099. _this4.z = v2.z;
  35100. var _this5 = _this4;
  35101. var tx1 = _this5.x * radius;
  35102. var ty1 = _this5.y * radius;
  35103. var tz1 = _this5.z * radius;
  35104. _this5.x = tx1;
  35105. _this5.y = ty1;
  35106. _this5.z = tz1;
  35107. var _this6 = _this5;
  35108. var tx2 = _this6.x + o.x;
  35109. var ty2 = _this6.y + o.y;
  35110. var tz2 = _this6.z + o.z;
  35111. _this6.x = tx2;
  35112. _this6.y = ty2;
  35113. _this6.z = tz2;
  35114. }
  35115. }
  35116. var _g21 = 0;
  35117. var _g3 = nt;
  35118. while(_g21 < _g3) {
  35119. var i1 = _g21++;
  35120. var _g22 = 0;
  35121. var _g31 = np;
  35122. while(_g22 < _g31) {
  35123. var j1 = _g22++;
  35124. var v11;
  35125. var v21;
  35126. var v3;
  35127. var v4;
  35128. var n1;
  35129. var n2;
  35130. var n3;
  35131. var n4;
  35132. if(i1 == 0) {
  35133. if(this.wireframe) {
  35134. v11 = vs[0][0];
  35135. v21 = vs[1][j1];
  35136. this.line(v11,v21,color);
  35137. } else {
  35138. v11 = vs[0][0];
  35139. v21 = vs[1][j1];
  35140. v3 = vs[1][(j1 + 1) % np];
  35141. n1 = ns[0][0];
  35142. n2 = ns[1][j1];
  35143. n3 = ns[1][(j1 + 1) % np];
  35144. this.triangle(v11,v21,v3,n1,n2,n3,color);
  35145. }
  35146. } else if(i1 == nt - 1) {
  35147. if(this.wireframe) {
  35148. v11 = vs[nt][0];
  35149. v21 = vs[i1][(j1 + 1) % np];
  35150. v3 = vs[i1][j1];
  35151. this.line(v11,v21,color);
  35152. this.line(v21,v3,color);
  35153. } else {
  35154. v11 = vs[nt][0];
  35155. v21 = vs[i1][(j1 + 1) % np];
  35156. v3 = vs[i1][j1];
  35157. n1 = ns[nt][0];
  35158. n2 = ns[i1][(j1 + 1) % np];
  35159. n3 = ns[i1][j1];
  35160. this.triangle(v11,v21,v3,n1,n2,n3,color);
  35161. }
  35162. } else if(this.wireframe) {
  35163. v11 = vs[i1][j1];
  35164. v21 = vs[i1][(j1 + 1) % np];
  35165. v3 = vs[i1 + 1][j1];
  35166. this.line(v11,v21,color);
  35167. this.line(v11,v3,color);
  35168. } else {
  35169. v11 = vs[i1][j1];
  35170. v21 = vs[i1][(j1 + 1) % np];
  35171. v3 = vs[i1 + 1][j1];
  35172. v4 = vs[i1 + 1][(j1 + 1) % np];
  35173. n1 = ns[i1][j1];
  35174. n2 = ns[i1][(j1 + 1) % np];
  35175. n3 = ns[i1 + 1][j1];
  35176. n4 = ns[i1 + 1][(j1 + 1) % np];
  35177. this.rect(v11,v3,v4,v21,n1,n3,n4,n2,color);
  35178. }
  35179. }
  35180. }
  35181. var _this7 = this.p;
  35182. var mat3 = null;
  35183. var mat4 = null;
  35184. var quat = null;
  35185. if(o != null) {
  35186. o.zero();
  35187. if(_this7.sizeVec3 == _this7.stackVec3.length) {
  35188. var newLength = _this7.sizeVec3 << 1;
  35189. var this1 = new Array(newLength);
  35190. var newArray = this1;
  35191. var _g4 = 0;
  35192. var _g12 = _this7.sizeVec3;
  35193. while(_g4 < _g12) {
  35194. var i2 = _g4++;
  35195. newArray[i2] = _this7.stackVec3[i2];
  35196. _this7.stackVec3[i2] = null;
  35197. }
  35198. _this7.stackVec3 = newArray;
  35199. }
  35200. _this7.stackVec3[_this7.sizeVec3++] = o;
  35201. }
  35202. if(mat3 != null) {
  35203. var t00 = 1;
  35204. var t01 = 0;
  35205. var t02 = 0;
  35206. var t10 = 0;
  35207. var t11 = 1;
  35208. var t12 = 0;
  35209. var t20 = 0;
  35210. var t21 = 0;
  35211. var t22 = 1;
  35212. mat3.e00 = t00;
  35213. mat3.e01 = t01;
  35214. mat3.e02 = t02;
  35215. mat3.e10 = t10;
  35216. mat3.e11 = t11;
  35217. mat3.e12 = t12;
  35218. mat3.e20 = t20;
  35219. mat3.e21 = t21;
  35220. mat3.e22 = t22;
  35221. if(_this7.sizeMat3 == _this7.stackMat3.length) {
  35222. var newLength1 = _this7.sizeMat3 << 1;
  35223. var this2 = new Array(newLength1);
  35224. var newArray1 = this2;
  35225. var _g5 = 0;
  35226. var _g13 = _this7.sizeMat3;
  35227. while(_g5 < _g13) {
  35228. var i3 = _g5++;
  35229. newArray1[i3] = _this7.stackMat3[i3];
  35230. _this7.stackMat3[i3] = null;
  35231. }
  35232. _this7.stackMat3 = newArray1;
  35233. }
  35234. _this7.stackMat3[_this7.sizeMat3++] = mat3;
  35235. }
  35236. if(mat4 != null) {
  35237. var t001 = 1;
  35238. var t011 = 0;
  35239. var t021 = 0;
  35240. var t03 = 0;
  35241. var t101 = 0;
  35242. var t111 = 1;
  35243. var t121 = 0;
  35244. var t13 = 0;
  35245. var t201 = 0;
  35246. var t211 = 0;
  35247. var t221 = 1;
  35248. var t23 = 0;
  35249. var t30 = 0;
  35250. var t31 = 0;
  35251. var t32 = 0;
  35252. var t33 = 1;
  35253. mat4.e00 = t001;
  35254. mat4.e01 = t011;
  35255. mat4.e02 = t021;
  35256. mat4.e03 = t03;
  35257. mat4.e10 = t101;
  35258. mat4.e11 = t111;
  35259. mat4.e12 = t121;
  35260. mat4.e13 = t13;
  35261. mat4.e20 = t201;
  35262. mat4.e21 = t211;
  35263. mat4.e22 = t221;
  35264. mat4.e23 = t23;
  35265. mat4.e30 = t30;
  35266. mat4.e31 = t31;
  35267. mat4.e32 = t32;
  35268. mat4.e33 = t33;
  35269. if(_this7.sizeMat4 == _this7.stackMat4.length) {
  35270. var newLength2 = _this7.sizeMat4 << 1;
  35271. var this3 = new Array(newLength2);
  35272. var newArray2 = this3;
  35273. var _g6 = 0;
  35274. var _g14 = _this7.sizeMat4;
  35275. while(_g6 < _g14) {
  35276. var i4 = _g6++;
  35277. newArray2[i4] = _this7.stackMat4[i4];
  35278. _this7.stackMat4[i4] = null;
  35279. }
  35280. _this7.stackMat4 = newArray2;
  35281. }
  35282. _this7.stackMat4[_this7.sizeMat4++] = mat4;
  35283. }
  35284. if(quat != null) {
  35285. var tx3 = 0;
  35286. var ty3 = 0;
  35287. var tz3 = 0;
  35288. var tw = 1;
  35289. quat.x = tx3;
  35290. quat.y = ty3;
  35291. quat.z = tz3;
  35292. quat.w = tw;
  35293. if(_this7.sizeQuat == _this7.stackQuat.length) {
  35294. var newLength3 = _this7.sizeQuat << 1;
  35295. var this4 = new Array(newLength3);
  35296. var newArray3 = this4;
  35297. var _g7 = 0;
  35298. var _g15 = _this7.sizeQuat;
  35299. while(_g7 < _g15) {
  35300. var i5 = _g7++;
  35301. newArray3[i5] = _this7.stackQuat[i5];
  35302. _this7.stackQuat[i5] = null;
  35303. }
  35304. _this7.stackQuat = newArray3;
  35305. }
  35306. _this7.stackQuat[_this7.sizeQuat++] = quat;
  35307. }
  35308. var _this8 = this.p;
  35309. var vec3 = null;
  35310. var mat41 = null;
  35311. var quat1 = null;
  35312. if(vec3 != null) {
  35313. vec3.zero();
  35314. if(_this8.sizeVec3 == _this8.stackVec3.length) {
  35315. var newLength4 = _this8.sizeVec3 << 1;
  35316. var this5 = new Array(newLength4);
  35317. var newArray4 = this5;
  35318. var _g8 = 0;
  35319. var _g16 = _this8.sizeVec3;
  35320. while(_g8 < _g16) {
  35321. var i6 = _g8++;
  35322. newArray4[i6] = _this8.stackVec3[i6];
  35323. _this8.stackVec3[i6] = null;
  35324. }
  35325. _this8.stackVec3 = newArray4;
  35326. }
  35327. _this8.stackVec3[_this8.sizeVec3++] = vec3;
  35328. }
  35329. if(m != null) {
  35330. var t002 = 1;
  35331. var t012 = 0;
  35332. var t022 = 0;
  35333. var t102 = 0;
  35334. var t112 = 1;
  35335. var t122 = 0;
  35336. var t202 = 0;
  35337. var t212 = 0;
  35338. var t222 = 1;
  35339. m.e00 = t002;
  35340. m.e01 = t012;
  35341. m.e02 = t022;
  35342. m.e10 = t102;
  35343. m.e11 = t112;
  35344. m.e12 = t122;
  35345. m.e20 = t202;
  35346. m.e21 = t212;
  35347. m.e22 = t222;
  35348. if(_this8.sizeMat3 == _this8.stackMat3.length) {
  35349. var newLength5 = _this8.sizeMat3 << 1;
  35350. var this6 = new Array(newLength5);
  35351. var newArray5 = this6;
  35352. var _g9 = 0;
  35353. var _g17 = _this8.sizeMat3;
  35354. while(_g9 < _g17) {
  35355. var i7 = _g9++;
  35356. newArray5[i7] = _this8.stackMat3[i7];
  35357. _this8.stackMat3[i7] = null;
  35358. }
  35359. _this8.stackMat3 = newArray5;
  35360. }
  35361. _this8.stackMat3[_this8.sizeMat3++] = m;
  35362. }
  35363. if(mat41 != null) {
  35364. var t003 = 1;
  35365. var t013 = 0;
  35366. var t023 = 0;
  35367. var t031 = 0;
  35368. var t103 = 0;
  35369. var t113 = 1;
  35370. var t123 = 0;
  35371. var t131 = 0;
  35372. var t203 = 0;
  35373. var t213 = 0;
  35374. var t223 = 1;
  35375. var t231 = 0;
  35376. var t301 = 0;
  35377. var t311 = 0;
  35378. var t321 = 0;
  35379. var t331 = 1;
  35380. mat41.e00 = t003;
  35381. mat41.e01 = t013;
  35382. mat41.e02 = t023;
  35383. mat41.e03 = t031;
  35384. mat41.e10 = t103;
  35385. mat41.e11 = t113;
  35386. mat41.e12 = t123;
  35387. mat41.e13 = t131;
  35388. mat41.e20 = t203;
  35389. mat41.e21 = t213;
  35390. mat41.e22 = t223;
  35391. mat41.e23 = t231;
  35392. mat41.e30 = t301;
  35393. mat41.e31 = t311;
  35394. mat41.e32 = t321;
  35395. mat41.e33 = t331;
  35396. if(_this8.sizeMat4 == _this8.stackMat4.length) {
  35397. var newLength6 = _this8.sizeMat4 << 1;
  35398. var this7 = new Array(newLength6);
  35399. var newArray6 = this7;
  35400. var _g10 = 0;
  35401. var _g18 = _this8.sizeMat4;
  35402. while(_g10 < _g18) {
  35403. var i8 = _g10++;
  35404. newArray6[i8] = _this8.stackMat4[i8];
  35405. _this8.stackMat4[i8] = null;
  35406. }
  35407. _this8.stackMat4 = newArray6;
  35408. }
  35409. _this8.stackMat4[_this8.sizeMat4++] = mat41;
  35410. }
  35411. if(quat1 != null) {
  35412. var tx4 = 0;
  35413. var ty4 = 0;
  35414. var tz4 = 0;
  35415. var tw1 = 1;
  35416. quat1.x = tx4;
  35417. quat1.y = ty4;
  35418. quat1.z = tz4;
  35419. quat1.w = tw1;
  35420. if(_this8.sizeQuat == _this8.stackQuat.length) {
  35421. var newLength7 = _this8.sizeQuat << 1;
  35422. var this8 = new Array(newLength7);
  35423. var newArray7 = this8;
  35424. var _g19 = 0;
  35425. var _g110 = _this8.sizeQuat;
  35426. while(_g19 < _g110) {
  35427. var i9 = _g19++;
  35428. newArray7[i9] = _this8.stackQuat[i9];
  35429. _this8.stackQuat[i9] = null;
  35430. }
  35431. _this8.stackQuat = newArray7;
  35432. }
  35433. _this8.stackQuat[_this8.sizeQuat++] = quat1;
  35434. }
  35435. }
  35436. box(tf,halfExtents,color) {
  35437. var _this = this.p;
  35438. var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3];
  35439. var _this1 = this.p;
  35440. var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3];
  35441. var _this2 = this.p;
  35442. var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3];
  35443. var _this3 = this.p;
  35444. var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3];
  35445. var _this4 = this.p;
  35446. var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3];
  35447. var v = o;
  35448. v.x = tf._positionX;
  35449. v.y = tf._positionY;
  35450. v.z = tf._positionZ;
  35451. var m1 = m;
  35452. m1.e00 = tf._rotation00;
  35453. m1.e01 = tf._rotation01;
  35454. m1.e02 = tf._rotation02;
  35455. m1.e10 = tf._rotation10;
  35456. m1.e11 = tf._rotation11;
  35457. m1.e12 = tf._rotation12;
  35458. m1.e20 = tf._rotation20;
  35459. m1.e21 = tf._rotation21;
  35460. m1.e22 = tf._rotation22;
  35461. ex.init(m.e00,m.e10,m.e20);
  35462. ey.init(m.e01,m.e11,m.e21);
  35463. ez.init(m.e02,m.e12,m.e22);
  35464. var hx = halfExtents.x;
  35465. var hy = halfExtents.y;
  35466. var hz = halfExtents.z;
  35467. var _this5 = this.p;
  35468. var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3];
  35469. _this6.x = o.x;
  35470. _this6.y = o.y;
  35471. _this6.z = o.z;
  35472. var _this7 = _this6;
  35473. var s = -hx;
  35474. var tx = _this7.x + ex.x * s;
  35475. var ty = _this7.y + ex.y * s;
  35476. var tz = _this7.z + ex.z * s;
  35477. _this7.x = tx;
  35478. _this7.y = ty;
  35479. _this7.z = tz;
  35480. var _this8 = _this7;
  35481. var s1 = -hy;
  35482. var tx1 = _this8.x + ey.x * s1;
  35483. var ty1 = _this8.y + ey.y * s1;
  35484. var tz1 = _this8.z + ey.z * s1;
  35485. _this8.x = tx1;
  35486. _this8.y = ty1;
  35487. _this8.z = tz1;
  35488. var _this9 = _this8;
  35489. var s2 = -hz;
  35490. var tx2 = _this9.x + ez.x * s2;
  35491. var ty2 = _this9.y + ez.y * s2;
  35492. var tz2 = _this9.z + ez.z * s2;
  35493. _this9.x = tx2;
  35494. _this9.y = ty2;
  35495. _this9.z = tz2;
  35496. var v1 = _this9;
  35497. var _this10 = this.p;
  35498. var _this11 = _this10.sizeVec3 == 0 ? new oimo.common.Vec3() : _this10.stackVec3[--_this10.sizeVec3];
  35499. _this11.x = o.x;
  35500. _this11.y = o.y;
  35501. _this11.z = o.z;
  35502. var _this12 = _this11;
  35503. var s3 = -hx;
  35504. var tx3 = _this12.x + ex.x * s3;
  35505. var ty3 = _this12.y + ex.y * s3;
  35506. var tz3 = _this12.z + ex.z * s3;
  35507. _this12.x = tx3;
  35508. _this12.y = ty3;
  35509. _this12.z = tz3;
  35510. var _this13 = _this12;
  35511. var s4 = -hy;
  35512. var tx4 = _this13.x + ey.x * s4;
  35513. var ty4 = _this13.y + ey.y * s4;
  35514. var tz4 = _this13.z + ey.z * s4;
  35515. _this13.x = tx4;
  35516. _this13.y = ty4;
  35517. _this13.z = tz4;
  35518. var _this14 = _this13;
  35519. var tx5 = _this14.x + ez.x * hz;
  35520. var ty5 = _this14.y + ez.y * hz;
  35521. var tz5 = _this14.z + ez.z * hz;
  35522. _this14.x = tx5;
  35523. _this14.y = ty5;
  35524. _this14.z = tz5;
  35525. var v2 = _this14;
  35526. var _this15 = this.p;
  35527. var _this16 = _this15.sizeVec3 == 0 ? new oimo.common.Vec3() : _this15.stackVec3[--_this15.sizeVec3];
  35528. _this16.x = o.x;
  35529. _this16.y = o.y;
  35530. _this16.z = o.z;
  35531. var _this17 = _this16;
  35532. var s5 = -hx;
  35533. var tx6 = _this17.x + ex.x * s5;
  35534. var ty6 = _this17.y + ex.y * s5;
  35535. var tz6 = _this17.z + ex.z * s5;
  35536. _this17.x = tx6;
  35537. _this17.y = ty6;
  35538. _this17.z = tz6;
  35539. var _this18 = _this17;
  35540. var tx7 = _this18.x + ey.x * hy;
  35541. var ty7 = _this18.y + ey.y * hy;
  35542. var tz7 = _this18.z + ey.z * hy;
  35543. _this18.x = tx7;
  35544. _this18.y = ty7;
  35545. _this18.z = tz7;
  35546. var _this19 = _this18;
  35547. var s6 = -hz;
  35548. var tx8 = _this19.x + ez.x * s6;
  35549. var ty8 = _this19.y + ez.y * s6;
  35550. var tz8 = _this19.z + ez.z * s6;
  35551. _this19.x = tx8;
  35552. _this19.y = ty8;
  35553. _this19.z = tz8;
  35554. var v3 = _this19;
  35555. var _this20 = this.p;
  35556. var _this21 = _this20.sizeVec3 == 0 ? new oimo.common.Vec3() : _this20.stackVec3[--_this20.sizeVec3];
  35557. _this21.x = o.x;
  35558. _this21.y = o.y;
  35559. _this21.z = o.z;
  35560. var _this22 = _this21;
  35561. var s7 = -hx;
  35562. var tx9 = _this22.x + ex.x * s7;
  35563. var ty9 = _this22.y + ex.y * s7;
  35564. var tz9 = _this22.z + ex.z * s7;
  35565. _this22.x = tx9;
  35566. _this22.y = ty9;
  35567. _this22.z = tz9;
  35568. var _this23 = _this22;
  35569. var tx10 = _this23.x + ey.x * hy;
  35570. var ty10 = _this23.y + ey.y * hy;
  35571. var tz10 = _this23.z + ey.z * hy;
  35572. _this23.x = tx10;
  35573. _this23.y = ty10;
  35574. _this23.z = tz10;
  35575. var _this24 = _this23;
  35576. var tx11 = _this24.x + ez.x * hz;
  35577. var ty11 = _this24.y + ez.y * hz;
  35578. var tz11 = _this24.z + ez.z * hz;
  35579. _this24.x = tx11;
  35580. _this24.y = ty11;
  35581. _this24.z = tz11;
  35582. var v4 = _this24;
  35583. var _this25 = this.p;
  35584. var _this26 = _this25.sizeVec3 == 0 ? new oimo.common.Vec3() : _this25.stackVec3[--_this25.sizeVec3];
  35585. _this26.x = o.x;
  35586. _this26.y = o.y;
  35587. _this26.z = o.z;
  35588. var _this27 = _this26;
  35589. var tx12 = _this27.x + ex.x * hx;
  35590. var ty12 = _this27.y + ex.y * hx;
  35591. var tz12 = _this27.z + ex.z * hx;
  35592. _this27.x = tx12;
  35593. _this27.y = ty12;
  35594. _this27.z = tz12;
  35595. var _this28 = _this27;
  35596. var s8 = -hy;
  35597. var tx13 = _this28.x + ey.x * s8;
  35598. var ty13 = _this28.y + ey.y * s8;
  35599. var tz13 = _this28.z + ey.z * s8;
  35600. _this28.x = tx13;
  35601. _this28.y = ty13;
  35602. _this28.z = tz13;
  35603. var _this29 = _this28;
  35604. var s9 = -hz;
  35605. var tx14 = _this29.x + ez.x * s9;
  35606. var ty14 = _this29.y + ez.y * s9;
  35607. var tz14 = _this29.z + ez.z * s9;
  35608. _this29.x = tx14;
  35609. _this29.y = ty14;
  35610. _this29.z = tz14;
  35611. var v5 = _this29;
  35612. var _this30 = this.p;
  35613. var _this31 = _this30.sizeVec3 == 0 ? new oimo.common.Vec3() : _this30.stackVec3[--_this30.sizeVec3];
  35614. _this31.x = o.x;
  35615. _this31.y = o.y;
  35616. _this31.z = o.z;
  35617. var _this32 = _this31;
  35618. var tx15 = _this32.x + ex.x * hx;
  35619. var ty15 = _this32.y + ex.y * hx;
  35620. var tz15 = _this32.z + ex.z * hx;
  35621. _this32.x = tx15;
  35622. _this32.y = ty15;
  35623. _this32.z = tz15;
  35624. var _this33 = _this32;
  35625. var s10 = -hy;
  35626. var tx16 = _this33.x + ey.x * s10;
  35627. var ty16 = _this33.y + ey.y * s10;
  35628. var tz16 = _this33.z + ey.z * s10;
  35629. _this33.x = tx16;
  35630. _this33.y = ty16;
  35631. _this33.z = tz16;
  35632. var _this34 = _this33;
  35633. var tx17 = _this34.x + ez.x * hz;
  35634. var ty17 = _this34.y + ez.y * hz;
  35635. var tz17 = _this34.z + ez.z * hz;
  35636. _this34.x = tx17;
  35637. _this34.y = ty17;
  35638. _this34.z = tz17;
  35639. var v6 = _this34;
  35640. var _this35 = this.p;
  35641. var _this36 = _this35.sizeVec3 == 0 ? new oimo.common.Vec3() : _this35.stackVec3[--_this35.sizeVec3];
  35642. _this36.x = o.x;
  35643. _this36.y = o.y;
  35644. _this36.z = o.z;
  35645. var _this37 = _this36;
  35646. var tx18 = _this37.x + ex.x * hx;
  35647. var ty18 = _this37.y + ex.y * hx;
  35648. var tz18 = _this37.z + ex.z * hx;
  35649. _this37.x = tx18;
  35650. _this37.y = ty18;
  35651. _this37.z = tz18;
  35652. var _this38 = _this37;
  35653. var tx19 = _this38.x + ey.x * hy;
  35654. var ty19 = _this38.y + ey.y * hy;
  35655. var tz19 = _this38.z + ey.z * hy;
  35656. _this38.x = tx19;
  35657. _this38.y = ty19;
  35658. _this38.z = tz19;
  35659. var _this39 = _this38;
  35660. var s11 = -hz;
  35661. var tx20 = _this39.x + ez.x * s11;
  35662. var ty20 = _this39.y + ez.y * s11;
  35663. var tz20 = _this39.z + ez.z * s11;
  35664. _this39.x = tx20;
  35665. _this39.y = ty20;
  35666. _this39.z = tz20;
  35667. var v7 = _this39;
  35668. var _this40 = this.p;
  35669. var _this41 = _this40.sizeVec3 == 0 ? new oimo.common.Vec3() : _this40.stackVec3[--_this40.sizeVec3];
  35670. _this41.x = o.x;
  35671. _this41.y = o.y;
  35672. _this41.z = o.z;
  35673. var _this42 = _this41;
  35674. var tx21 = _this42.x + ex.x * hx;
  35675. var ty21 = _this42.y + ex.y * hx;
  35676. var tz21 = _this42.z + ex.z * hx;
  35677. _this42.x = tx21;
  35678. _this42.y = ty21;
  35679. _this42.z = tz21;
  35680. var _this43 = _this42;
  35681. var tx22 = _this43.x + ey.x * hy;
  35682. var ty22 = _this43.y + ey.y * hy;
  35683. var tz22 = _this43.z + ey.z * hy;
  35684. _this43.x = tx22;
  35685. _this43.y = ty22;
  35686. _this43.z = tz22;
  35687. var _this44 = _this43;
  35688. var tx23 = _this44.x + ez.x * hz;
  35689. var ty23 = _this44.y + ez.y * hz;
  35690. var tz23 = _this44.z + ez.z * hz;
  35691. _this44.x = tx23;
  35692. _this44.y = ty23;
  35693. _this44.z = tz23;
  35694. var v8 = _this44;
  35695. if(this.wireframe) {
  35696. this.line(v1,v2,color);
  35697. this.line(v3,v4,color);
  35698. this.line(v5,v6,color);
  35699. this.line(v7,v8,color);
  35700. this.line(v1,v3,color);
  35701. this.line(v2,v4,color);
  35702. this.line(v5,v7,color);
  35703. this.line(v6,v8,color);
  35704. this.line(v1,v5,color);
  35705. this.line(v2,v6,color);
  35706. this.line(v3,v7,color);
  35707. this.line(v4,v8,color);
  35708. } else {
  35709. var _this45 = this.p;
  35710. var _this46 = _this45.sizeVec3 == 0 ? new oimo.common.Vec3() : _this45.stackVec3[--_this45.sizeVec3];
  35711. _this46.x = ex.x;
  35712. _this46.y = ex.y;
  35713. _this46.z = ex.z;
  35714. var _this47 = _this46;
  35715. var tx24 = -_this47.x;
  35716. var ty24 = -_this47.y;
  35717. var tz24 = -_this47.z;
  35718. _this47.x = tx24;
  35719. _this47.y = ty24;
  35720. _this47.z = tz24;
  35721. var nex = _this47;
  35722. var _this48 = this.p;
  35723. var _this49 = _this48.sizeVec3 == 0 ? new oimo.common.Vec3() : _this48.stackVec3[--_this48.sizeVec3];
  35724. _this49.x = ey.x;
  35725. _this49.y = ey.y;
  35726. _this49.z = ey.z;
  35727. var _this50 = _this49;
  35728. var tx25 = -_this50.x;
  35729. var ty25 = -_this50.y;
  35730. var tz25 = -_this50.z;
  35731. _this50.x = tx25;
  35732. _this50.y = ty25;
  35733. _this50.z = tz25;
  35734. var ney = _this50;
  35735. var _this51 = this.p;
  35736. var _this52 = _this51.sizeVec3 == 0 ? new oimo.common.Vec3() : _this51.stackVec3[--_this51.sizeVec3];
  35737. _this52.x = ez.x;
  35738. _this52.y = ez.y;
  35739. _this52.z = ez.z;
  35740. var _this53 = _this52;
  35741. var tx26 = -_this53.x;
  35742. var ty26 = -_this53.y;
  35743. var tz26 = -_this53.z;
  35744. _this53.x = tx26;
  35745. _this53.y = ty26;
  35746. _this53.z = tz26;
  35747. var nez = _this53;
  35748. this.rect(v1,v2,v4,v3,nex,nex,nex,nex,color);
  35749. this.rect(v5,v7,v8,v6,ex,ex,ex,ex,color);
  35750. this.rect(v1,v5,v6,v2,ney,ney,ney,ney,color);
  35751. this.rect(v3,v4,v8,v7,ey,ey,ey,ey,color);
  35752. this.rect(v1,v3,v7,v5,nez,nez,nez,nez,color);
  35753. this.rect(v2,v6,v8,v4,ez,ez,ez,ez,color);
  35754. var _this54 = this.p;
  35755. var mat3 = null;
  35756. var mat4 = null;
  35757. var quat = null;
  35758. if(nex != null) {
  35759. nex.zero();
  35760. if(_this54.sizeVec3 == _this54.stackVec3.length) {
  35761. var newLength = _this54.sizeVec3 << 1;
  35762. var this1 = new Array(newLength);
  35763. var newArray = this1;
  35764. var _g = 0;
  35765. var _g1 = _this54.sizeVec3;
  35766. while(_g < _g1) {
  35767. var i = _g++;
  35768. newArray[i] = _this54.stackVec3[i];
  35769. _this54.stackVec3[i] = null;
  35770. }
  35771. _this54.stackVec3 = newArray;
  35772. }
  35773. _this54.stackVec3[_this54.sizeVec3++] = nex;
  35774. }
  35775. if(mat3 != null) {
  35776. var t00 = 1;
  35777. var t01 = 0;
  35778. var t02 = 0;
  35779. var t10 = 0;
  35780. var t11 = 1;
  35781. var t12 = 0;
  35782. var t20 = 0;
  35783. var t21 = 0;
  35784. var t22 = 1;
  35785. mat3.e00 = t00;
  35786. mat3.e01 = t01;
  35787. mat3.e02 = t02;
  35788. mat3.e10 = t10;
  35789. mat3.e11 = t11;
  35790. mat3.e12 = t12;
  35791. mat3.e20 = t20;
  35792. mat3.e21 = t21;
  35793. mat3.e22 = t22;
  35794. if(_this54.sizeMat3 == _this54.stackMat3.length) {
  35795. var newLength1 = _this54.sizeMat3 << 1;
  35796. var this2 = new Array(newLength1);
  35797. var newArray1 = this2;
  35798. var _g2 = 0;
  35799. var _g11 = _this54.sizeMat3;
  35800. while(_g2 < _g11) {
  35801. var i1 = _g2++;
  35802. newArray1[i1] = _this54.stackMat3[i1];
  35803. _this54.stackMat3[i1] = null;
  35804. }
  35805. _this54.stackMat3 = newArray1;
  35806. }
  35807. _this54.stackMat3[_this54.sizeMat3++] = mat3;
  35808. }
  35809. if(mat4 != null) {
  35810. var t001 = 1;
  35811. var t011 = 0;
  35812. var t021 = 0;
  35813. var t03 = 0;
  35814. var t101 = 0;
  35815. var t111 = 1;
  35816. var t121 = 0;
  35817. var t13 = 0;
  35818. var t201 = 0;
  35819. var t211 = 0;
  35820. var t221 = 1;
  35821. var t23 = 0;
  35822. var t30 = 0;
  35823. var t31 = 0;
  35824. var t32 = 0;
  35825. var t33 = 1;
  35826. mat4.e00 = t001;
  35827. mat4.e01 = t011;
  35828. mat4.e02 = t021;
  35829. mat4.e03 = t03;
  35830. mat4.e10 = t101;
  35831. mat4.e11 = t111;
  35832. mat4.e12 = t121;
  35833. mat4.e13 = t13;
  35834. mat4.e20 = t201;
  35835. mat4.e21 = t211;
  35836. mat4.e22 = t221;
  35837. mat4.e23 = t23;
  35838. mat4.e30 = t30;
  35839. mat4.e31 = t31;
  35840. mat4.e32 = t32;
  35841. mat4.e33 = t33;
  35842. if(_this54.sizeMat4 == _this54.stackMat4.length) {
  35843. var newLength2 = _this54.sizeMat4 << 1;
  35844. var this3 = new Array(newLength2);
  35845. var newArray2 = this3;
  35846. var _g3 = 0;
  35847. var _g12 = _this54.sizeMat4;
  35848. while(_g3 < _g12) {
  35849. var i2 = _g3++;
  35850. newArray2[i2] = _this54.stackMat4[i2];
  35851. _this54.stackMat4[i2] = null;
  35852. }
  35853. _this54.stackMat4 = newArray2;
  35854. }
  35855. _this54.stackMat4[_this54.sizeMat4++] = mat4;
  35856. }
  35857. if(quat != null) {
  35858. var tx27 = 0;
  35859. var ty27 = 0;
  35860. var tz27 = 0;
  35861. var tw = 1;
  35862. quat.x = tx27;
  35863. quat.y = ty27;
  35864. quat.z = tz27;
  35865. quat.w = tw;
  35866. if(_this54.sizeQuat == _this54.stackQuat.length) {
  35867. var newLength3 = _this54.sizeQuat << 1;
  35868. var this4 = new Array(newLength3);
  35869. var newArray3 = this4;
  35870. var _g4 = 0;
  35871. var _g13 = _this54.sizeQuat;
  35872. while(_g4 < _g13) {
  35873. var i3 = _g4++;
  35874. newArray3[i3] = _this54.stackQuat[i3];
  35875. _this54.stackQuat[i3] = null;
  35876. }
  35877. _this54.stackQuat = newArray3;
  35878. }
  35879. _this54.stackQuat[_this54.sizeQuat++] = quat;
  35880. }
  35881. var _this55 = this.p;
  35882. var mat31 = null;
  35883. var mat41 = null;
  35884. var quat1 = null;
  35885. if(ney != null) {
  35886. ney.zero();
  35887. if(_this55.sizeVec3 == _this55.stackVec3.length) {
  35888. var newLength4 = _this55.sizeVec3 << 1;
  35889. var this5 = new Array(newLength4);
  35890. var newArray4 = this5;
  35891. var _g5 = 0;
  35892. var _g14 = _this55.sizeVec3;
  35893. while(_g5 < _g14) {
  35894. var i4 = _g5++;
  35895. newArray4[i4] = _this55.stackVec3[i4];
  35896. _this55.stackVec3[i4] = null;
  35897. }
  35898. _this55.stackVec3 = newArray4;
  35899. }
  35900. _this55.stackVec3[_this55.sizeVec3++] = ney;
  35901. }
  35902. if(mat31 != null) {
  35903. var t002 = 1;
  35904. var t012 = 0;
  35905. var t022 = 0;
  35906. var t102 = 0;
  35907. var t112 = 1;
  35908. var t122 = 0;
  35909. var t202 = 0;
  35910. var t212 = 0;
  35911. var t222 = 1;
  35912. mat31.e00 = t002;
  35913. mat31.e01 = t012;
  35914. mat31.e02 = t022;
  35915. mat31.e10 = t102;
  35916. mat31.e11 = t112;
  35917. mat31.e12 = t122;
  35918. mat31.e20 = t202;
  35919. mat31.e21 = t212;
  35920. mat31.e22 = t222;
  35921. if(_this55.sizeMat3 == _this55.stackMat3.length) {
  35922. var newLength5 = _this55.sizeMat3 << 1;
  35923. var this6 = new Array(newLength5);
  35924. var newArray5 = this6;
  35925. var _g6 = 0;
  35926. var _g15 = _this55.sizeMat3;
  35927. while(_g6 < _g15) {
  35928. var i5 = _g6++;
  35929. newArray5[i5] = _this55.stackMat3[i5];
  35930. _this55.stackMat3[i5] = null;
  35931. }
  35932. _this55.stackMat3 = newArray5;
  35933. }
  35934. _this55.stackMat3[_this55.sizeMat3++] = mat31;
  35935. }
  35936. if(mat41 != null) {
  35937. var t003 = 1;
  35938. var t013 = 0;
  35939. var t023 = 0;
  35940. var t031 = 0;
  35941. var t103 = 0;
  35942. var t113 = 1;
  35943. var t123 = 0;
  35944. var t131 = 0;
  35945. var t203 = 0;
  35946. var t213 = 0;
  35947. var t223 = 1;
  35948. var t231 = 0;
  35949. var t301 = 0;
  35950. var t311 = 0;
  35951. var t321 = 0;
  35952. var t331 = 1;
  35953. mat41.e00 = t003;
  35954. mat41.e01 = t013;
  35955. mat41.e02 = t023;
  35956. mat41.e03 = t031;
  35957. mat41.e10 = t103;
  35958. mat41.e11 = t113;
  35959. mat41.e12 = t123;
  35960. mat41.e13 = t131;
  35961. mat41.e20 = t203;
  35962. mat41.e21 = t213;
  35963. mat41.e22 = t223;
  35964. mat41.e23 = t231;
  35965. mat41.e30 = t301;
  35966. mat41.e31 = t311;
  35967. mat41.e32 = t321;
  35968. mat41.e33 = t331;
  35969. if(_this55.sizeMat4 == _this55.stackMat4.length) {
  35970. var newLength6 = _this55.sizeMat4 << 1;
  35971. var this7 = new Array(newLength6);
  35972. var newArray6 = this7;
  35973. var _g7 = 0;
  35974. var _g16 = _this55.sizeMat4;
  35975. while(_g7 < _g16) {
  35976. var i6 = _g7++;
  35977. newArray6[i6] = _this55.stackMat4[i6];
  35978. _this55.stackMat4[i6] = null;
  35979. }
  35980. _this55.stackMat4 = newArray6;
  35981. }
  35982. _this55.stackMat4[_this55.sizeMat4++] = mat41;
  35983. }
  35984. if(quat1 != null) {
  35985. var tx28 = 0;
  35986. var ty28 = 0;
  35987. var tz28 = 0;
  35988. var tw1 = 1;
  35989. quat1.x = tx28;
  35990. quat1.y = ty28;
  35991. quat1.z = tz28;
  35992. quat1.w = tw1;
  35993. if(_this55.sizeQuat == _this55.stackQuat.length) {
  35994. var newLength7 = _this55.sizeQuat << 1;
  35995. var this8 = new Array(newLength7);
  35996. var newArray7 = this8;
  35997. var _g8 = 0;
  35998. var _g17 = _this55.sizeQuat;
  35999. while(_g8 < _g17) {
  36000. var i7 = _g8++;
  36001. newArray7[i7] = _this55.stackQuat[i7];
  36002. _this55.stackQuat[i7] = null;
  36003. }
  36004. _this55.stackQuat = newArray7;
  36005. }
  36006. _this55.stackQuat[_this55.sizeQuat++] = quat1;
  36007. }
  36008. var _this56 = this.p;
  36009. var mat32 = null;
  36010. var mat42 = null;
  36011. var quat2 = null;
  36012. if(nez != null) {
  36013. nez.zero();
  36014. if(_this56.sizeVec3 == _this56.stackVec3.length) {
  36015. var newLength8 = _this56.sizeVec3 << 1;
  36016. var this9 = new Array(newLength8);
  36017. var newArray8 = this9;
  36018. var _g9 = 0;
  36019. var _g18 = _this56.sizeVec3;
  36020. while(_g9 < _g18) {
  36021. var i8 = _g9++;
  36022. newArray8[i8] = _this56.stackVec3[i8];
  36023. _this56.stackVec3[i8] = null;
  36024. }
  36025. _this56.stackVec3 = newArray8;
  36026. }
  36027. _this56.stackVec3[_this56.sizeVec3++] = nez;
  36028. }
  36029. if(mat32 != null) {
  36030. var t004 = 1;
  36031. var t014 = 0;
  36032. var t024 = 0;
  36033. var t104 = 0;
  36034. var t114 = 1;
  36035. var t124 = 0;
  36036. var t204 = 0;
  36037. var t214 = 0;
  36038. var t224 = 1;
  36039. mat32.e00 = t004;
  36040. mat32.e01 = t014;
  36041. mat32.e02 = t024;
  36042. mat32.e10 = t104;
  36043. mat32.e11 = t114;
  36044. mat32.e12 = t124;
  36045. mat32.e20 = t204;
  36046. mat32.e21 = t214;
  36047. mat32.e22 = t224;
  36048. if(_this56.sizeMat3 == _this56.stackMat3.length) {
  36049. var newLength9 = _this56.sizeMat3 << 1;
  36050. var this10 = new Array(newLength9);
  36051. var newArray9 = this10;
  36052. var _g10 = 0;
  36053. var _g19 = _this56.sizeMat3;
  36054. while(_g10 < _g19) {
  36055. var i9 = _g10++;
  36056. newArray9[i9] = _this56.stackMat3[i9];
  36057. _this56.stackMat3[i9] = null;
  36058. }
  36059. _this56.stackMat3 = newArray9;
  36060. }
  36061. _this56.stackMat3[_this56.sizeMat3++] = mat32;
  36062. }
  36063. if(mat42 != null) {
  36064. var t005 = 1;
  36065. var t015 = 0;
  36066. var t025 = 0;
  36067. var t032 = 0;
  36068. var t105 = 0;
  36069. var t115 = 1;
  36070. var t125 = 0;
  36071. var t132 = 0;
  36072. var t205 = 0;
  36073. var t215 = 0;
  36074. var t225 = 1;
  36075. var t232 = 0;
  36076. var t302 = 0;
  36077. var t312 = 0;
  36078. var t322 = 0;
  36079. var t332 = 1;
  36080. mat42.e00 = t005;
  36081. mat42.e01 = t015;
  36082. mat42.e02 = t025;
  36083. mat42.e03 = t032;
  36084. mat42.e10 = t105;
  36085. mat42.e11 = t115;
  36086. mat42.e12 = t125;
  36087. mat42.e13 = t132;
  36088. mat42.e20 = t205;
  36089. mat42.e21 = t215;
  36090. mat42.e22 = t225;
  36091. mat42.e23 = t232;
  36092. mat42.e30 = t302;
  36093. mat42.e31 = t312;
  36094. mat42.e32 = t322;
  36095. mat42.e33 = t332;
  36096. if(_this56.sizeMat4 == _this56.stackMat4.length) {
  36097. var newLength10 = _this56.sizeMat4 << 1;
  36098. var this11 = new Array(newLength10);
  36099. var newArray10 = this11;
  36100. var _g20 = 0;
  36101. var _g110 = _this56.sizeMat4;
  36102. while(_g20 < _g110) {
  36103. var i10 = _g20++;
  36104. newArray10[i10] = _this56.stackMat4[i10];
  36105. _this56.stackMat4[i10] = null;
  36106. }
  36107. _this56.stackMat4 = newArray10;
  36108. }
  36109. _this56.stackMat4[_this56.sizeMat4++] = mat42;
  36110. }
  36111. if(quat2 != null) {
  36112. var tx29 = 0;
  36113. var ty29 = 0;
  36114. var tz29 = 0;
  36115. var tw2 = 1;
  36116. quat2.x = tx29;
  36117. quat2.y = ty29;
  36118. quat2.z = tz29;
  36119. quat2.w = tw2;
  36120. if(_this56.sizeQuat == _this56.stackQuat.length) {
  36121. var newLength11 = _this56.sizeQuat << 1;
  36122. var this12 = new Array(newLength11);
  36123. var newArray11 = this12;
  36124. var _g21 = 0;
  36125. var _g111 = _this56.sizeQuat;
  36126. while(_g21 < _g111) {
  36127. var i11 = _g21++;
  36128. newArray11[i11] = _this56.stackQuat[i11];
  36129. _this56.stackQuat[i11] = null;
  36130. }
  36131. _this56.stackQuat = newArray11;
  36132. }
  36133. _this56.stackQuat[_this56.sizeQuat++] = quat2;
  36134. }
  36135. }
  36136. var _this57 = this.p;
  36137. var mat33 = null;
  36138. var mat43 = null;
  36139. var quat3 = null;
  36140. if(v1 != null) {
  36141. v1.zero();
  36142. if(_this57.sizeVec3 == _this57.stackVec3.length) {
  36143. var newLength12 = _this57.sizeVec3 << 1;
  36144. var this13 = new Array(newLength12);
  36145. var newArray12 = this13;
  36146. var _g22 = 0;
  36147. var _g112 = _this57.sizeVec3;
  36148. while(_g22 < _g112) {
  36149. var i12 = _g22++;
  36150. newArray12[i12] = _this57.stackVec3[i12];
  36151. _this57.stackVec3[i12] = null;
  36152. }
  36153. _this57.stackVec3 = newArray12;
  36154. }
  36155. _this57.stackVec3[_this57.sizeVec3++] = v1;
  36156. }
  36157. if(mat33 != null) {
  36158. var t006 = 1;
  36159. var t016 = 0;
  36160. var t026 = 0;
  36161. var t106 = 0;
  36162. var t116 = 1;
  36163. var t126 = 0;
  36164. var t206 = 0;
  36165. var t216 = 0;
  36166. var t226 = 1;
  36167. mat33.e00 = t006;
  36168. mat33.e01 = t016;
  36169. mat33.e02 = t026;
  36170. mat33.e10 = t106;
  36171. mat33.e11 = t116;
  36172. mat33.e12 = t126;
  36173. mat33.e20 = t206;
  36174. mat33.e21 = t216;
  36175. mat33.e22 = t226;
  36176. if(_this57.sizeMat3 == _this57.stackMat3.length) {
  36177. var newLength13 = _this57.sizeMat3 << 1;
  36178. var this14 = new Array(newLength13);
  36179. var newArray13 = this14;
  36180. var _g23 = 0;
  36181. var _g113 = _this57.sizeMat3;
  36182. while(_g23 < _g113) {
  36183. var i13 = _g23++;
  36184. newArray13[i13] = _this57.stackMat3[i13];
  36185. _this57.stackMat3[i13] = null;
  36186. }
  36187. _this57.stackMat3 = newArray13;
  36188. }
  36189. _this57.stackMat3[_this57.sizeMat3++] = mat33;
  36190. }
  36191. if(mat43 != null) {
  36192. var t007 = 1;
  36193. var t017 = 0;
  36194. var t027 = 0;
  36195. var t033 = 0;
  36196. var t107 = 0;
  36197. var t117 = 1;
  36198. var t127 = 0;
  36199. var t133 = 0;
  36200. var t207 = 0;
  36201. var t217 = 0;
  36202. var t227 = 1;
  36203. var t233 = 0;
  36204. var t303 = 0;
  36205. var t313 = 0;
  36206. var t323 = 0;
  36207. var t333 = 1;
  36208. mat43.e00 = t007;
  36209. mat43.e01 = t017;
  36210. mat43.e02 = t027;
  36211. mat43.e03 = t033;
  36212. mat43.e10 = t107;
  36213. mat43.e11 = t117;
  36214. mat43.e12 = t127;
  36215. mat43.e13 = t133;
  36216. mat43.e20 = t207;
  36217. mat43.e21 = t217;
  36218. mat43.e22 = t227;
  36219. mat43.e23 = t233;
  36220. mat43.e30 = t303;
  36221. mat43.e31 = t313;
  36222. mat43.e32 = t323;
  36223. mat43.e33 = t333;
  36224. if(_this57.sizeMat4 == _this57.stackMat4.length) {
  36225. var newLength14 = _this57.sizeMat4 << 1;
  36226. var this15 = new Array(newLength14);
  36227. var newArray14 = this15;
  36228. var _g24 = 0;
  36229. var _g114 = _this57.sizeMat4;
  36230. while(_g24 < _g114) {
  36231. var i14 = _g24++;
  36232. newArray14[i14] = _this57.stackMat4[i14];
  36233. _this57.stackMat4[i14] = null;
  36234. }
  36235. _this57.stackMat4 = newArray14;
  36236. }
  36237. _this57.stackMat4[_this57.sizeMat4++] = mat43;
  36238. }
  36239. if(quat3 != null) {
  36240. var tx30 = 0;
  36241. var ty30 = 0;
  36242. var tz30 = 0;
  36243. var tw3 = 1;
  36244. quat3.x = tx30;
  36245. quat3.y = ty30;
  36246. quat3.z = tz30;
  36247. quat3.w = tw3;
  36248. if(_this57.sizeQuat == _this57.stackQuat.length) {
  36249. var newLength15 = _this57.sizeQuat << 1;
  36250. var this16 = new Array(newLength15);
  36251. var newArray15 = this16;
  36252. var _g25 = 0;
  36253. var _g115 = _this57.sizeQuat;
  36254. while(_g25 < _g115) {
  36255. var i15 = _g25++;
  36256. newArray15[i15] = _this57.stackQuat[i15];
  36257. _this57.stackQuat[i15] = null;
  36258. }
  36259. _this57.stackQuat = newArray15;
  36260. }
  36261. _this57.stackQuat[_this57.sizeQuat++] = quat3;
  36262. }
  36263. var _this58 = this.p;
  36264. var mat34 = null;
  36265. var mat44 = null;
  36266. var quat4 = null;
  36267. if(v2 != null) {
  36268. v2.zero();
  36269. if(_this58.sizeVec3 == _this58.stackVec3.length) {
  36270. var newLength16 = _this58.sizeVec3 << 1;
  36271. var this17 = new Array(newLength16);
  36272. var newArray16 = this17;
  36273. var _g26 = 0;
  36274. var _g116 = _this58.sizeVec3;
  36275. while(_g26 < _g116) {
  36276. var i16 = _g26++;
  36277. newArray16[i16] = _this58.stackVec3[i16];
  36278. _this58.stackVec3[i16] = null;
  36279. }
  36280. _this58.stackVec3 = newArray16;
  36281. }
  36282. _this58.stackVec3[_this58.sizeVec3++] = v2;
  36283. }
  36284. if(mat34 != null) {
  36285. var t008 = 1;
  36286. var t018 = 0;
  36287. var t028 = 0;
  36288. var t108 = 0;
  36289. var t118 = 1;
  36290. var t128 = 0;
  36291. var t208 = 0;
  36292. var t218 = 0;
  36293. var t228 = 1;
  36294. mat34.e00 = t008;
  36295. mat34.e01 = t018;
  36296. mat34.e02 = t028;
  36297. mat34.e10 = t108;
  36298. mat34.e11 = t118;
  36299. mat34.e12 = t128;
  36300. mat34.e20 = t208;
  36301. mat34.e21 = t218;
  36302. mat34.e22 = t228;
  36303. if(_this58.sizeMat3 == _this58.stackMat3.length) {
  36304. var newLength17 = _this58.sizeMat3 << 1;
  36305. var this18 = new Array(newLength17);
  36306. var newArray17 = this18;
  36307. var _g27 = 0;
  36308. var _g117 = _this58.sizeMat3;
  36309. while(_g27 < _g117) {
  36310. var i17 = _g27++;
  36311. newArray17[i17] = _this58.stackMat3[i17];
  36312. _this58.stackMat3[i17] = null;
  36313. }
  36314. _this58.stackMat3 = newArray17;
  36315. }
  36316. _this58.stackMat3[_this58.sizeMat3++] = mat34;
  36317. }
  36318. if(mat44 != null) {
  36319. var t009 = 1;
  36320. var t019 = 0;
  36321. var t029 = 0;
  36322. var t034 = 0;
  36323. var t109 = 0;
  36324. var t119 = 1;
  36325. var t129 = 0;
  36326. var t134 = 0;
  36327. var t209 = 0;
  36328. var t219 = 0;
  36329. var t229 = 1;
  36330. var t234 = 0;
  36331. var t304 = 0;
  36332. var t314 = 0;
  36333. var t324 = 0;
  36334. var t334 = 1;
  36335. mat44.e00 = t009;
  36336. mat44.e01 = t019;
  36337. mat44.e02 = t029;
  36338. mat44.e03 = t034;
  36339. mat44.e10 = t109;
  36340. mat44.e11 = t119;
  36341. mat44.e12 = t129;
  36342. mat44.e13 = t134;
  36343. mat44.e20 = t209;
  36344. mat44.e21 = t219;
  36345. mat44.e22 = t229;
  36346. mat44.e23 = t234;
  36347. mat44.e30 = t304;
  36348. mat44.e31 = t314;
  36349. mat44.e32 = t324;
  36350. mat44.e33 = t334;
  36351. if(_this58.sizeMat4 == _this58.stackMat4.length) {
  36352. var newLength18 = _this58.sizeMat4 << 1;
  36353. var this19 = new Array(newLength18);
  36354. var newArray18 = this19;
  36355. var _g28 = 0;
  36356. var _g118 = _this58.sizeMat4;
  36357. while(_g28 < _g118) {
  36358. var i18 = _g28++;
  36359. newArray18[i18] = _this58.stackMat4[i18];
  36360. _this58.stackMat4[i18] = null;
  36361. }
  36362. _this58.stackMat4 = newArray18;
  36363. }
  36364. _this58.stackMat4[_this58.sizeMat4++] = mat44;
  36365. }
  36366. if(quat4 != null) {
  36367. var tx31 = 0;
  36368. var ty31 = 0;
  36369. var tz31 = 0;
  36370. var tw4 = 1;
  36371. quat4.x = tx31;
  36372. quat4.y = ty31;
  36373. quat4.z = tz31;
  36374. quat4.w = tw4;
  36375. if(_this58.sizeQuat == _this58.stackQuat.length) {
  36376. var newLength19 = _this58.sizeQuat << 1;
  36377. var this20 = new Array(newLength19);
  36378. var newArray19 = this20;
  36379. var _g29 = 0;
  36380. var _g119 = _this58.sizeQuat;
  36381. while(_g29 < _g119) {
  36382. var i19 = _g29++;
  36383. newArray19[i19] = _this58.stackQuat[i19];
  36384. _this58.stackQuat[i19] = null;
  36385. }
  36386. _this58.stackQuat = newArray19;
  36387. }
  36388. _this58.stackQuat[_this58.sizeQuat++] = quat4;
  36389. }
  36390. var _this59 = this.p;
  36391. var mat35 = null;
  36392. var mat45 = null;
  36393. var quat5 = null;
  36394. if(v3 != null) {
  36395. v3.zero();
  36396. if(_this59.sizeVec3 == _this59.stackVec3.length) {
  36397. var newLength20 = _this59.sizeVec3 << 1;
  36398. var this21 = new Array(newLength20);
  36399. var newArray20 = this21;
  36400. var _g30 = 0;
  36401. var _g120 = _this59.sizeVec3;
  36402. while(_g30 < _g120) {
  36403. var i20 = _g30++;
  36404. newArray20[i20] = _this59.stackVec3[i20];
  36405. _this59.stackVec3[i20] = null;
  36406. }
  36407. _this59.stackVec3 = newArray20;
  36408. }
  36409. _this59.stackVec3[_this59.sizeVec3++] = v3;
  36410. }
  36411. if(mat35 != null) {
  36412. var t0010 = 1;
  36413. var t0110 = 0;
  36414. var t0210 = 0;
  36415. var t1010 = 0;
  36416. var t1110 = 1;
  36417. var t1210 = 0;
  36418. var t2010 = 0;
  36419. var t2110 = 0;
  36420. var t2210 = 1;
  36421. mat35.e00 = t0010;
  36422. mat35.e01 = t0110;
  36423. mat35.e02 = t0210;
  36424. mat35.e10 = t1010;
  36425. mat35.e11 = t1110;
  36426. mat35.e12 = t1210;
  36427. mat35.e20 = t2010;
  36428. mat35.e21 = t2110;
  36429. mat35.e22 = t2210;
  36430. if(_this59.sizeMat3 == _this59.stackMat3.length) {
  36431. var newLength21 = _this59.sizeMat3 << 1;
  36432. var this22 = new Array(newLength21);
  36433. var newArray21 = this22;
  36434. var _g31 = 0;
  36435. var _g121 = _this59.sizeMat3;
  36436. while(_g31 < _g121) {
  36437. var i21 = _g31++;
  36438. newArray21[i21] = _this59.stackMat3[i21];
  36439. _this59.stackMat3[i21] = null;
  36440. }
  36441. _this59.stackMat3 = newArray21;
  36442. }
  36443. _this59.stackMat3[_this59.sizeMat3++] = mat35;
  36444. }
  36445. if(mat45 != null) {
  36446. var t0011 = 1;
  36447. var t0111 = 0;
  36448. var t0211 = 0;
  36449. var t035 = 0;
  36450. var t1011 = 0;
  36451. var t1111 = 1;
  36452. var t1211 = 0;
  36453. var t135 = 0;
  36454. var t2011 = 0;
  36455. var t2111 = 0;
  36456. var t2211 = 1;
  36457. var t235 = 0;
  36458. var t305 = 0;
  36459. var t315 = 0;
  36460. var t325 = 0;
  36461. var t335 = 1;
  36462. mat45.e00 = t0011;
  36463. mat45.e01 = t0111;
  36464. mat45.e02 = t0211;
  36465. mat45.e03 = t035;
  36466. mat45.e10 = t1011;
  36467. mat45.e11 = t1111;
  36468. mat45.e12 = t1211;
  36469. mat45.e13 = t135;
  36470. mat45.e20 = t2011;
  36471. mat45.e21 = t2111;
  36472. mat45.e22 = t2211;
  36473. mat45.e23 = t235;
  36474. mat45.e30 = t305;
  36475. mat45.e31 = t315;
  36476. mat45.e32 = t325;
  36477. mat45.e33 = t335;
  36478. if(_this59.sizeMat4 == _this59.stackMat4.length) {
  36479. var newLength22 = _this59.sizeMat4 << 1;
  36480. var this23 = new Array(newLength22);
  36481. var newArray22 = this23;
  36482. var _g32 = 0;
  36483. var _g122 = _this59.sizeMat4;
  36484. while(_g32 < _g122) {
  36485. var i22 = _g32++;
  36486. newArray22[i22] = _this59.stackMat4[i22];
  36487. _this59.stackMat4[i22] = null;
  36488. }
  36489. _this59.stackMat4 = newArray22;
  36490. }
  36491. _this59.stackMat4[_this59.sizeMat4++] = mat45;
  36492. }
  36493. if(quat5 != null) {
  36494. var tx32 = 0;
  36495. var ty32 = 0;
  36496. var tz32 = 0;
  36497. var tw5 = 1;
  36498. quat5.x = tx32;
  36499. quat5.y = ty32;
  36500. quat5.z = tz32;
  36501. quat5.w = tw5;
  36502. if(_this59.sizeQuat == _this59.stackQuat.length) {
  36503. var newLength23 = _this59.sizeQuat << 1;
  36504. var this24 = new Array(newLength23);
  36505. var newArray23 = this24;
  36506. var _g33 = 0;
  36507. var _g123 = _this59.sizeQuat;
  36508. while(_g33 < _g123) {
  36509. var i23 = _g33++;
  36510. newArray23[i23] = _this59.stackQuat[i23];
  36511. _this59.stackQuat[i23] = null;
  36512. }
  36513. _this59.stackQuat = newArray23;
  36514. }
  36515. _this59.stackQuat[_this59.sizeQuat++] = quat5;
  36516. }
  36517. var _this60 = this.p;
  36518. var mat36 = null;
  36519. var mat46 = null;
  36520. var quat6 = null;
  36521. if(v4 != null) {
  36522. v4.zero();
  36523. if(_this60.sizeVec3 == _this60.stackVec3.length) {
  36524. var newLength24 = _this60.sizeVec3 << 1;
  36525. var this25 = new Array(newLength24);
  36526. var newArray24 = this25;
  36527. var _g34 = 0;
  36528. var _g124 = _this60.sizeVec3;
  36529. while(_g34 < _g124) {
  36530. var i24 = _g34++;
  36531. newArray24[i24] = _this60.stackVec3[i24];
  36532. _this60.stackVec3[i24] = null;
  36533. }
  36534. _this60.stackVec3 = newArray24;
  36535. }
  36536. _this60.stackVec3[_this60.sizeVec3++] = v4;
  36537. }
  36538. if(mat36 != null) {
  36539. var t0012 = 1;
  36540. var t0112 = 0;
  36541. var t0212 = 0;
  36542. var t1012 = 0;
  36543. var t1112 = 1;
  36544. var t1212 = 0;
  36545. var t2012 = 0;
  36546. var t2112 = 0;
  36547. var t2212 = 1;
  36548. mat36.e00 = t0012;
  36549. mat36.e01 = t0112;
  36550. mat36.e02 = t0212;
  36551. mat36.e10 = t1012;
  36552. mat36.e11 = t1112;
  36553. mat36.e12 = t1212;
  36554. mat36.e20 = t2012;
  36555. mat36.e21 = t2112;
  36556. mat36.e22 = t2212;
  36557. if(_this60.sizeMat3 == _this60.stackMat3.length) {
  36558. var newLength25 = _this60.sizeMat3 << 1;
  36559. var this26 = new Array(newLength25);
  36560. var newArray25 = this26;
  36561. var _g35 = 0;
  36562. var _g125 = _this60.sizeMat3;
  36563. while(_g35 < _g125) {
  36564. var i25 = _g35++;
  36565. newArray25[i25] = _this60.stackMat3[i25];
  36566. _this60.stackMat3[i25] = null;
  36567. }
  36568. _this60.stackMat3 = newArray25;
  36569. }
  36570. _this60.stackMat3[_this60.sizeMat3++] = mat36;
  36571. }
  36572. if(mat46 != null) {
  36573. var t0013 = 1;
  36574. var t0113 = 0;
  36575. var t0213 = 0;
  36576. var t036 = 0;
  36577. var t1013 = 0;
  36578. var t1113 = 1;
  36579. var t1213 = 0;
  36580. var t136 = 0;
  36581. var t2013 = 0;
  36582. var t2113 = 0;
  36583. var t2213 = 1;
  36584. var t236 = 0;
  36585. var t306 = 0;
  36586. var t316 = 0;
  36587. var t326 = 0;
  36588. var t336 = 1;
  36589. mat46.e00 = t0013;
  36590. mat46.e01 = t0113;
  36591. mat46.e02 = t0213;
  36592. mat46.e03 = t036;
  36593. mat46.e10 = t1013;
  36594. mat46.e11 = t1113;
  36595. mat46.e12 = t1213;
  36596. mat46.e13 = t136;
  36597. mat46.e20 = t2013;
  36598. mat46.e21 = t2113;
  36599. mat46.e22 = t2213;
  36600. mat46.e23 = t236;
  36601. mat46.e30 = t306;
  36602. mat46.e31 = t316;
  36603. mat46.e32 = t326;
  36604. mat46.e33 = t336;
  36605. if(_this60.sizeMat4 == _this60.stackMat4.length) {
  36606. var newLength26 = _this60.sizeMat4 << 1;
  36607. var this27 = new Array(newLength26);
  36608. var newArray26 = this27;
  36609. var _g36 = 0;
  36610. var _g126 = _this60.sizeMat4;
  36611. while(_g36 < _g126) {
  36612. var i26 = _g36++;
  36613. newArray26[i26] = _this60.stackMat4[i26];
  36614. _this60.stackMat4[i26] = null;
  36615. }
  36616. _this60.stackMat4 = newArray26;
  36617. }
  36618. _this60.stackMat4[_this60.sizeMat4++] = mat46;
  36619. }
  36620. if(quat6 != null) {
  36621. var tx33 = 0;
  36622. var ty33 = 0;
  36623. var tz33 = 0;
  36624. var tw6 = 1;
  36625. quat6.x = tx33;
  36626. quat6.y = ty33;
  36627. quat6.z = tz33;
  36628. quat6.w = tw6;
  36629. if(_this60.sizeQuat == _this60.stackQuat.length) {
  36630. var newLength27 = _this60.sizeQuat << 1;
  36631. var this28 = new Array(newLength27);
  36632. var newArray27 = this28;
  36633. var _g37 = 0;
  36634. var _g127 = _this60.sizeQuat;
  36635. while(_g37 < _g127) {
  36636. var i27 = _g37++;
  36637. newArray27[i27] = _this60.stackQuat[i27];
  36638. _this60.stackQuat[i27] = null;
  36639. }
  36640. _this60.stackQuat = newArray27;
  36641. }
  36642. _this60.stackQuat[_this60.sizeQuat++] = quat6;
  36643. }
  36644. var _this61 = this.p;
  36645. var mat37 = null;
  36646. var mat47 = null;
  36647. var quat7 = null;
  36648. if(v5 != null) {
  36649. v5.zero();
  36650. if(_this61.sizeVec3 == _this61.stackVec3.length) {
  36651. var newLength28 = _this61.sizeVec3 << 1;
  36652. var this29 = new Array(newLength28);
  36653. var newArray28 = this29;
  36654. var _g38 = 0;
  36655. var _g128 = _this61.sizeVec3;
  36656. while(_g38 < _g128) {
  36657. var i28 = _g38++;
  36658. newArray28[i28] = _this61.stackVec3[i28];
  36659. _this61.stackVec3[i28] = null;
  36660. }
  36661. _this61.stackVec3 = newArray28;
  36662. }
  36663. _this61.stackVec3[_this61.sizeVec3++] = v5;
  36664. }
  36665. if(mat37 != null) {
  36666. var t0014 = 1;
  36667. var t0114 = 0;
  36668. var t0214 = 0;
  36669. var t1014 = 0;
  36670. var t1114 = 1;
  36671. var t1214 = 0;
  36672. var t2014 = 0;
  36673. var t2114 = 0;
  36674. var t2214 = 1;
  36675. mat37.e00 = t0014;
  36676. mat37.e01 = t0114;
  36677. mat37.e02 = t0214;
  36678. mat37.e10 = t1014;
  36679. mat37.e11 = t1114;
  36680. mat37.e12 = t1214;
  36681. mat37.e20 = t2014;
  36682. mat37.e21 = t2114;
  36683. mat37.e22 = t2214;
  36684. if(_this61.sizeMat3 == _this61.stackMat3.length) {
  36685. var newLength29 = _this61.sizeMat3 << 1;
  36686. var this30 = new Array(newLength29);
  36687. var newArray29 = this30;
  36688. var _g39 = 0;
  36689. var _g129 = _this61.sizeMat3;
  36690. while(_g39 < _g129) {
  36691. var i29 = _g39++;
  36692. newArray29[i29] = _this61.stackMat3[i29];
  36693. _this61.stackMat3[i29] = null;
  36694. }
  36695. _this61.stackMat3 = newArray29;
  36696. }
  36697. _this61.stackMat3[_this61.sizeMat3++] = mat37;
  36698. }
  36699. if(mat47 != null) {
  36700. var t0015 = 1;
  36701. var t0115 = 0;
  36702. var t0215 = 0;
  36703. var t037 = 0;
  36704. var t1015 = 0;
  36705. var t1115 = 1;
  36706. var t1215 = 0;
  36707. var t137 = 0;
  36708. var t2015 = 0;
  36709. var t2115 = 0;
  36710. var t2215 = 1;
  36711. var t237 = 0;
  36712. var t307 = 0;
  36713. var t317 = 0;
  36714. var t327 = 0;
  36715. var t337 = 1;
  36716. mat47.e00 = t0015;
  36717. mat47.e01 = t0115;
  36718. mat47.e02 = t0215;
  36719. mat47.e03 = t037;
  36720. mat47.e10 = t1015;
  36721. mat47.e11 = t1115;
  36722. mat47.e12 = t1215;
  36723. mat47.e13 = t137;
  36724. mat47.e20 = t2015;
  36725. mat47.e21 = t2115;
  36726. mat47.e22 = t2215;
  36727. mat47.e23 = t237;
  36728. mat47.e30 = t307;
  36729. mat47.e31 = t317;
  36730. mat47.e32 = t327;
  36731. mat47.e33 = t337;
  36732. if(_this61.sizeMat4 == _this61.stackMat4.length) {
  36733. var newLength30 = _this61.sizeMat4 << 1;
  36734. var this31 = new Array(newLength30);
  36735. var newArray30 = this31;
  36736. var _g40 = 0;
  36737. var _g130 = _this61.sizeMat4;
  36738. while(_g40 < _g130) {
  36739. var i30 = _g40++;
  36740. newArray30[i30] = _this61.stackMat4[i30];
  36741. _this61.stackMat4[i30] = null;
  36742. }
  36743. _this61.stackMat4 = newArray30;
  36744. }
  36745. _this61.stackMat4[_this61.sizeMat4++] = mat47;
  36746. }
  36747. if(quat7 != null) {
  36748. var tx34 = 0;
  36749. var ty34 = 0;
  36750. var tz34 = 0;
  36751. var tw7 = 1;
  36752. quat7.x = tx34;
  36753. quat7.y = ty34;
  36754. quat7.z = tz34;
  36755. quat7.w = tw7;
  36756. if(_this61.sizeQuat == _this61.stackQuat.length) {
  36757. var newLength31 = _this61.sizeQuat << 1;
  36758. var this32 = new Array(newLength31);
  36759. var newArray31 = this32;
  36760. var _g41 = 0;
  36761. var _g131 = _this61.sizeQuat;
  36762. while(_g41 < _g131) {
  36763. var i31 = _g41++;
  36764. newArray31[i31] = _this61.stackQuat[i31];
  36765. _this61.stackQuat[i31] = null;
  36766. }
  36767. _this61.stackQuat = newArray31;
  36768. }
  36769. _this61.stackQuat[_this61.sizeQuat++] = quat7;
  36770. }
  36771. var _this62 = this.p;
  36772. var mat38 = null;
  36773. var mat48 = null;
  36774. var quat8 = null;
  36775. if(v6 != null) {
  36776. v6.zero();
  36777. if(_this62.sizeVec3 == _this62.stackVec3.length) {
  36778. var newLength32 = _this62.sizeVec3 << 1;
  36779. var this33 = new Array(newLength32);
  36780. var newArray32 = this33;
  36781. var _g42 = 0;
  36782. var _g132 = _this62.sizeVec3;
  36783. while(_g42 < _g132) {
  36784. var i32 = _g42++;
  36785. newArray32[i32] = _this62.stackVec3[i32];
  36786. _this62.stackVec3[i32] = null;
  36787. }
  36788. _this62.stackVec3 = newArray32;
  36789. }
  36790. _this62.stackVec3[_this62.sizeVec3++] = v6;
  36791. }
  36792. if(mat38 != null) {
  36793. var t0016 = 1;
  36794. var t0116 = 0;
  36795. var t0216 = 0;
  36796. var t1016 = 0;
  36797. var t1116 = 1;
  36798. var t1216 = 0;
  36799. var t2016 = 0;
  36800. var t2116 = 0;
  36801. var t2216 = 1;
  36802. mat38.e00 = t0016;
  36803. mat38.e01 = t0116;
  36804. mat38.e02 = t0216;
  36805. mat38.e10 = t1016;
  36806. mat38.e11 = t1116;
  36807. mat38.e12 = t1216;
  36808. mat38.e20 = t2016;
  36809. mat38.e21 = t2116;
  36810. mat38.e22 = t2216;
  36811. if(_this62.sizeMat3 == _this62.stackMat3.length) {
  36812. var newLength33 = _this62.sizeMat3 << 1;
  36813. var this34 = new Array(newLength33);
  36814. var newArray33 = this34;
  36815. var _g43 = 0;
  36816. var _g133 = _this62.sizeMat3;
  36817. while(_g43 < _g133) {
  36818. var i33 = _g43++;
  36819. newArray33[i33] = _this62.stackMat3[i33];
  36820. _this62.stackMat3[i33] = null;
  36821. }
  36822. _this62.stackMat3 = newArray33;
  36823. }
  36824. _this62.stackMat3[_this62.sizeMat3++] = mat38;
  36825. }
  36826. if(mat48 != null) {
  36827. var t0017 = 1;
  36828. var t0117 = 0;
  36829. var t0217 = 0;
  36830. var t038 = 0;
  36831. var t1017 = 0;
  36832. var t1117 = 1;
  36833. var t1217 = 0;
  36834. var t138 = 0;
  36835. var t2017 = 0;
  36836. var t2117 = 0;
  36837. var t2217 = 1;
  36838. var t238 = 0;
  36839. var t308 = 0;
  36840. var t318 = 0;
  36841. var t328 = 0;
  36842. var t338 = 1;
  36843. mat48.e00 = t0017;
  36844. mat48.e01 = t0117;
  36845. mat48.e02 = t0217;
  36846. mat48.e03 = t038;
  36847. mat48.e10 = t1017;
  36848. mat48.e11 = t1117;
  36849. mat48.e12 = t1217;
  36850. mat48.e13 = t138;
  36851. mat48.e20 = t2017;
  36852. mat48.e21 = t2117;
  36853. mat48.e22 = t2217;
  36854. mat48.e23 = t238;
  36855. mat48.e30 = t308;
  36856. mat48.e31 = t318;
  36857. mat48.e32 = t328;
  36858. mat48.e33 = t338;
  36859. if(_this62.sizeMat4 == _this62.stackMat4.length) {
  36860. var newLength34 = _this62.sizeMat4 << 1;
  36861. var this35 = new Array(newLength34);
  36862. var newArray34 = this35;
  36863. var _g44 = 0;
  36864. var _g134 = _this62.sizeMat4;
  36865. while(_g44 < _g134) {
  36866. var i34 = _g44++;
  36867. newArray34[i34] = _this62.stackMat4[i34];
  36868. _this62.stackMat4[i34] = null;
  36869. }
  36870. _this62.stackMat4 = newArray34;
  36871. }
  36872. _this62.stackMat4[_this62.sizeMat4++] = mat48;
  36873. }
  36874. if(quat8 != null) {
  36875. var tx35 = 0;
  36876. var ty35 = 0;
  36877. var tz35 = 0;
  36878. var tw8 = 1;
  36879. quat8.x = tx35;
  36880. quat8.y = ty35;
  36881. quat8.z = tz35;
  36882. quat8.w = tw8;
  36883. if(_this62.sizeQuat == _this62.stackQuat.length) {
  36884. var newLength35 = _this62.sizeQuat << 1;
  36885. var this36 = new Array(newLength35);
  36886. var newArray35 = this36;
  36887. var _g45 = 0;
  36888. var _g135 = _this62.sizeQuat;
  36889. while(_g45 < _g135) {
  36890. var i35 = _g45++;
  36891. newArray35[i35] = _this62.stackQuat[i35];
  36892. _this62.stackQuat[i35] = null;
  36893. }
  36894. _this62.stackQuat = newArray35;
  36895. }
  36896. _this62.stackQuat[_this62.sizeQuat++] = quat8;
  36897. }
  36898. var _this63 = this.p;
  36899. var mat39 = null;
  36900. var mat49 = null;
  36901. var quat9 = null;
  36902. if(v7 != null) {
  36903. v7.zero();
  36904. if(_this63.sizeVec3 == _this63.stackVec3.length) {
  36905. var newLength36 = _this63.sizeVec3 << 1;
  36906. var this37 = new Array(newLength36);
  36907. var newArray36 = this37;
  36908. var _g46 = 0;
  36909. var _g136 = _this63.sizeVec3;
  36910. while(_g46 < _g136) {
  36911. var i36 = _g46++;
  36912. newArray36[i36] = _this63.stackVec3[i36];
  36913. _this63.stackVec3[i36] = null;
  36914. }
  36915. _this63.stackVec3 = newArray36;
  36916. }
  36917. _this63.stackVec3[_this63.sizeVec3++] = v7;
  36918. }
  36919. if(mat39 != null) {
  36920. var t0018 = 1;
  36921. var t0118 = 0;
  36922. var t0218 = 0;
  36923. var t1018 = 0;
  36924. var t1118 = 1;
  36925. var t1218 = 0;
  36926. var t2018 = 0;
  36927. var t2118 = 0;
  36928. var t2218 = 1;
  36929. mat39.e00 = t0018;
  36930. mat39.e01 = t0118;
  36931. mat39.e02 = t0218;
  36932. mat39.e10 = t1018;
  36933. mat39.e11 = t1118;
  36934. mat39.e12 = t1218;
  36935. mat39.e20 = t2018;
  36936. mat39.e21 = t2118;
  36937. mat39.e22 = t2218;
  36938. if(_this63.sizeMat3 == _this63.stackMat3.length) {
  36939. var newLength37 = _this63.sizeMat3 << 1;
  36940. var this38 = new Array(newLength37);
  36941. var newArray37 = this38;
  36942. var _g47 = 0;
  36943. var _g137 = _this63.sizeMat3;
  36944. while(_g47 < _g137) {
  36945. var i37 = _g47++;
  36946. newArray37[i37] = _this63.stackMat3[i37];
  36947. _this63.stackMat3[i37] = null;
  36948. }
  36949. _this63.stackMat3 = newArray37;
  36950. }
  36951. _this63.stackMat3[_this63.sizeMat3++] = mat39;
  36952. }
  36953. if(mat49 != null) {
  36954. var t0019 = 1;
  36955. var t0119 = 0;
  36956. var t0219 = 0;
  36957. var t039 = 0;
  36958. var t1019 = 0;
  36959. var t1119 = 1;
  36960. var t1219 = 0;
  36961. var t139 = 0;
  36962. var t2019 = 0;
  36963. var t2119 = 0;
  36964. var t2219 = 1;
  36965. var t239 = 0;
  36966. var t309 = 0;
  36967. var t319 = 0;
  36968. var t329 = 0;
  36969. var t339 = 1;
  36970. mat49.e00 = t0019;
  36971. mat49.e01 = t0119;
  36972. mat49.e02 = t0219;
  36973. mat49.e03 = t039;
  36974. mat49.e10 = t1019;
  36975. mat49.e11 = t1119;
  36976. mat49.e12 = t1219;
  36977. mat49.e13 = t139;
  36978. mat49.e20 = t2019;
  36979. mat49.e21 = t2119;
  36980. mat49.e22 = t2219;
  36981. mat49.e23 = t239;
  36982. mat49.e30 = t309;
  36983. mat49.e31 = t319;
  36984. mat49.e32 = t329;
  36985. mat49.e33 = t339;
  36986. if(_this63.sizeMat4 == _this63.stackMat4.length) {
  36987. var newLength38 = _this63.sizeMat4 << 1;
  36988. var this39 = new Array(newLength38);
  36989. var newArray38 = this39;
  36990. var _g48 = 0;
  36991. var _g138 = _this63.sizeMat4;
  36992. while(_g48 < _g138) {
  36993. var i38 = _g48++;
  36994. newArray38[i38] = _this63.stackMat4[i38];
  36995. _this63.stackMat4[i38] = null;
  36996. }
  36997. _this63.stackMat4 = newArray38;
  36998. }
  36999. _this63.stackMat4[_this63.sizeMat4++] = mat49;
  37000. }
  37001. if(quat9 != null) {
  37002. var tx36 = 0;
  37003. var ty36 = 0;
  37004. var tz36 = 0;
  37005. var tw9 = 1;
  37006. quat9.x = tx36;
  37007. quat9.y = ty36;
  37008. quat9.z = tz36;
  37009. quat9.w = tw9;
  37010. if(_this63.sizeQuat == _this63.stackQuat.length) {
  37011. var newLength39 = _this63.sizeQuat << 1;
  37012. var this40 = new Array(newLength39);
  37013. var newArray39 = this40;
  37014. var _g49 = 0;
  37015. var _g139 = _this63.sizeQuat;
  37016. while(_g49 < _g139) {
  37017. var i39 = _g49++;
  37018. newArray39[i39] = _this63.stackQuat[i39];
  37019. _this63.stackQuat[i39] = null;
  37020. }
  37021. _this63.stackQuat = newArray39;
  37022. }
  37023. _this63.stackQuat[_this63.sizeQuat++] = quat9;
  37024. }
  37025. var _this64 = this.p;
  37026. var mat310 = null;
  37027. var mat410 = null;
  37028. var quat10 = null;
  37029. if(v8 != null) {
  37030. v8.zero();
  37031. if(_this64.sizeVec3 == _this64.stackVec3.length) {
  37032. var newLength40 = _this64.sizeVec3 << 1;
  37033. var this41 = new Array(newLength40);
  37034. var newArray40 = this41;
  37035. var _g50 = 0;
  37036. var _g140 = _this64.sizeVec3;
  37037. while(_g50 < _g140) {
  37038. var i40 = _g50++;
  37039. newArray40[i40] = _this64.stackVec3[i40];
  37040. _this64.stackVec3[i40] = null;
  37041. }
  37042. _this64.stackVec3 = newArray40;
  37043. }
  37044. _this64.stackVec3[_this64.sizeVec3++] = v8;
  37045. }
  37046. if(mat310 != null) {
  37047. var t0020 = 1;
  37048. var t0120 = 0;
  37049. var t0220 = 0;
  37050. var t1020 = 0;
  37051. var t1120 = 1;
  37052. var t1220 = 0;
  37053. var t2020 = 0;
  37054. var t2120 = 0;
  37055. var t2220 = 1;
  37056. mat310.e00 = t0020;
  37057. mat310.e01 = t0120;
  37058. mat310.e02 = t0220;
  37059. mat310.e10 = t1020;
  37060. mat310.e11 = t1120;
  37061. mat310.e12 = t1220;
  37062. mat310.e20 = t2020;
  37063. mat310.e21 = t2120;
  37064. mat310.e22 = t2220;
  37065. if(_this64.sizeMat3 == _this64.stackMat3.length) {
  37066. var newLength41 = _this64.sizeMat3 << 1;
  37067. var this42 = new Array(newLength41);
  37068. var newArray41 = this42;
  37069. var _g51 = 0;
  37070. var _g141 = _this64.sizeMat3;
  37071. while(_g51 < _g141) {
  37072. var i41 = _g51++;
  37073. newArray41[i41] = _this64.stackMat3[i41];
  37074. _this64.stackMat3[i41] = null;
  37075. }
  37076. _this64.stackMat3 = newArray41;
  37077. }
  37078. _this64.stackMat3[_this64.sizeMat3++] = mat310;
  37079. }
  37080. if(mat410 != null) {
  37081. var t0021 = 1;
  37082. var t0121 = 0;
  37083. var t0221 = 0;
  37084. var t0310 = 0;
  37085. var t1021 = 0;
  37086. var t1121 = 1;
  37087. var t1221 = 0;
  37088. var t1310 = 0;
  37089. var t2021 = 0;
  37090. var t2121 = 0;
  37091. var t2221 = 1;
  37092. var t2310 = 0;
  37093. var t3010 = 0;
  37094. var t3110 = 0;
  37095. var t3210 = 0;
  37096. var t3310 = 1;
  37097. mat410.e00 = t0021;
  37098. mat410.e01 = t0121;
  37099. mat410.e02 = t0221;
  37100. mat410.e03 = t0310;
  37101. mat410.e10 = t1021;
  37102. mat410.e11 = t1121;
  37103. mat410.e12 = t1221;
  37104. mat410.e13 = t1310;
  37105. mat410.e20 = t2021;
  37106. mat410.e21 = t2121;
  37107. mat410.e22 = t2221;
  37108. mat410.e23 = t2310;
  37109. mat410.e30 = t3010;
  37110. mat410.e31 = t3110;
  37111. mat410.e32 = t3210;
  37112. mat410.e33 = t3310;
  37113. if(_this64.sizeMat4 == _this64.stackMat4.length) {
  37114. var newLength42 = _this64.sizeMat4 << 1;
  37115. var this43 = new Array(newLength42);
  37116. var newArray42 = this43;
  37117. var _g52 = 0;
  37118. var _g142 = _this64.sizeMat4;
  37119. while(_g52 < _g142) {
  37120. var i42 = _g52++;
  37121. newArray42[i42] = _this64.stackMat4[i42];
  37122. _this64.stackMat4[i42] = null;
  37123. }
  37124. _this64.stackMat4 = newArray42;
  37125. }
  37126. _this64.stackMat4[_this64.sizeMat4++] = mat410;
  37127. }
  37128. if(quat10 != null) {
  37129. var tx37 = 0;
  37130. var ty37 = 0;
  37131. var tz37 = 0;
  37132. var tw10 = 1;
  37133. quat10.x = tx37;
  37134. quat10.y = ty37;
  37135. quat10.z = tz37;
  37136. quat10.w = tw10;
  37137. if(_this64.sizeQuat == _this64.stackQuat.length) {
  37138. var newLength43 = _this64.sizeQuat << 1;
  37139. var this44 = new Array(newLength43);
  37140. var newArray43 = this44;
  37141. var _g53 = 0;
  37142. var _g143 = _this64.sizeQuat;
  37143. while(_g53 < _g143) {
  37144. var i43 = _g53++;
  37145. newArray43[i43] = _this64.stackQuat[i43];
  37146. _this64.stackQuat[i43] = null;
  37147. }
  37148. _this64.stackQuat = newArray43;
  37149. }
  37150. _this64.stackQuat[_this64.sizeQuat++] = quat10;
  37151. }
  37152. var _this65 = this.p;
  37153. var mat311 = null;
  37154. var mat411 = null;
  37155. var quat11 = null;
  37156. if(o != null) {
  37157. o.zero();
  37158. if(_this65.sizeVec3 == _this65.stackVec3.length) {
  37159. var newLength44 = _this65.sizeVec3 << 1;
  37160. var this45 = new Array(newLength44);
  37161. var newArray44 = this45;
  37162. var _g54 = 0;
  37163. var _g144 = _this65.sizeVec3;
  37164. while(_g54 < _g144) {
  37165. var i44 = _g54++;
  37166. newArray44[i44] = _this65.stackVec3[i44];
  37167. _this65.stackVec3[i44] = null;
  37168. }
  37169. _this65.stackVec3 = newArray44;
  37170. }
  37171. _this65.stackVec3[_this65.sizeVec3++] = o;
  37172. }
  37173. if(mat311 != null) {
  37174. var t0022 = 1;
  37175. var t0122 = 0;
  37176. var t0222 = 0;
  37177. var t1022 = 0;
  37178. var t1122 = 1;
  37179. var t1222 = 0;
  37180. var t2022 = 0;
  37181. var t2122 = 0;
  37182. var t2222 = 1;
  37183. mat311.e00 = t0022;
  37184. mat311.e01 = t0122;
  37185. mat311.e02 = t0222;
  37186. mat311.e10 = t1022;
  37187. mat311.e11 = t1122;
  37188. mat311.e12 = t1222;
  37189. mat311.e20 = t2022;
  37190. mat311.e21 = t2122;
  37191. mat311.e22 = t2222;
  37192. if(_this65.sizeMat3 == _this65.stackMat3.length) {
  37193. var newLength45 = _this65.sizeMat3 << 1;
  37194. var this46 = new Array(newLength45);
  37195. var newArray45 = this46;
  37196. var _g55 = 0;
  37197. var _g145 = _this65.sizeMat3;
  37198. while(_g55 < _g145) {
  37199. var i45 = _g55++;
  37200. newArray45[i45] = _this65.stackMat3[i45];
  37201. _this65.stackMat3[i45] = null;
  37202. }
  37203. _this65.stackMat3 = newArray45;
  37204. }
  37205. _this65.stackMat3[_this65.sizeMat3++] = mat311;
  37206. }
  37207. if(mat411 != null) {
  37208. var t0023 = 1;
  37209. var t0123 = 0;
  37210. var t0223 = 0;
  37211. var t0311 = 0;
  37212. var t1023 = 0;
  37213. var t1123 = 1;
  37214. var t1223 = 0;
  37215. var t1311 = 0;
  37216. var t2023 = 0;
  37217. var t2123 = 0;
  37218. var t2223 = 1;
  37219. var t2311 = 0;
  37220. var t3011 = 0;
  37221. var t3111 = 0;
  37222. var t3211 = 0;
  37223. var t3311 = 1;
  37224. mat411.e00 = t0023;
  37225. mat411.e01 = t0123;
  37226. mat411.e02 = t0223;
  37227. mat411.e03 = t0311;
  37228. mat411.e10 = t1023;
  37229. mat411.e11 = t1123;
  37230. mat411.e12 = t1223;
  37231. mat411.e13 = t1311;
  37232. mat411.e20 = t2023;
  37233. mat411.e21 = t2123;
  37234. mat411.e22 = t2223;
  37235. mat411.e23 = t2311;
  37236. mat411.e30 = t3011;
  37237. mat411.e31 = t3111;
  37238. mat411.e32 = t3211;
  37239. mat411.e33 = t3311;
  37240. if(_this65.sizeMat4 == _this65.stackMat4.length) {
  37241. var newLength46 = _this65.sizeMat4 << 1;
  37242. var this47 = new Array(newLength46);
  37243. var newArray46 = this47;
  37244. var _g56 = 0;
  37245. var _g146 = _this65.sizeMat4;
  37246. while(_g56 < _g146) {
  37247. var i46 = _g56++;
  37248. newArray46[i46] = _this65.stackMat4[i46];
  37249. _this65.stackMat4[i46] = null;
  37250. }
  37251. _this65.stackMat4 = newArray46;
  37252. }
  37253. _this65.stackMat4[_this65.sizeMat4++] = mat411;
  37254. }
  37255. if(quat11 != null) {
  37256. var tx38 = 0;
  37257. var ty38 = 0;
  37258. var tz38 = 0;
  37259. var tw11 = 1;
  37260. quat11.x = tx38;
  37261. quat11.y = ty38;
  37262. quat11.z = tz38;
  37263. quat11.w = tw11;
  37264. if(_this65.sizeQuat == _this65.stackQuat.length) {
  37265. var newLength47 = _this65.sizeQuat << 1;
  37266. var this48 = new Array(newLength47);
  37267. var newArray47 = this48;
  37268. var _g57 = 0;
  37269. var _g147 = _this65.sizeQuat;
  37270. while(_g57 < _g147) {
  37271. var i47 = _g57++;
  37272. newArray47[i47] = _this65.stackQuat[i47];
  37273. _this65.stackQuat[i47] = null;
  37274. }
  37275. _this65.stackQuat = newArray47;
  37276. }
  37277. _this65.stackQuat[_this65.sizeQuat++] = quat11;
  37278. }
  37279. var _this66 = this.p;
  37280. var vec3 = null;
  37281. var mat412 = null;
  37282. var quat12 = null;
  37283. if(vec3 != null) {
  37284. vec3.zero();
  37285. if(_this66.sizeVec3 == _this66.stackVec3.length) {
  37286. var newLength48 = _this66.sizeVec3 << 1;
  37287. var this49 = new Array(newLength48);
  37288. var newArray48 = this49;
  37289. var _g58 = 0;
  37290. var _g148 = _this66.sizeVec3;
  37291. while(_g58 < _g148) {
  37292. var i48 = _g58++;
  37293. newArray48[i48] = _this66.stackVec3[i48];
  37294. _this66.stackVec3[i48] = null;
  37295. }
  37296. _this66.stackVec3 = newArray48;
  37297. }
  37298. _this66.stackVec3[_this66.sizeVec3++] = vec3;
  37299. }
  37300. if(m != null) {
  37301. var t0024 = 1;
  37302. var t0124 = 0;
  37303. var t0224 = 0;
  37304. var t1024 = 0;
  37305. var t1124 = 1;
  37306. var t1224 = 0;
  37307. var t2024 = 0;
  37308. var t2124 = 0;
  37309. var t2224 = 1;
  37310. m.e00 = t0024;
  37311. m.e01 = t0124;
  37312. m.e02 = t0224;
  37313. m.e10 = t1024;
  37314. m.e11 = t1124;
  37315. m.e12 = t1224;
  37316. m.e20 = t2024;
  37317. m.e21 = t2124;
  37318. m.e22 = t2224;
  37319. if(_this66.sizeMat3 == _this66.stackMat3.length) {
  37320. var newLength49 = _this66.sizeMat3 << 1;
  37321. var this50 = new Array(newLength49);
  37322. var newArray49 = this50;
  37323. var _g59 = 0;
  37324. var _g149 = _this66.sizeMat3;
  37325. while(_g59 < _g149) {
  37326. var i49 = _g59++;
  37327. newArray49[i49] = _this66.stackMat3[i49];
  37328. _this66.stackMat3[i49] = null;
  37329. }
  37330. _this66.stackMat3 = newArray49;
  37331. }
  37332. _this66.stackMat3[_this66.sizeMat3++] = m;
  37333. }
  37334. if(mat412 != null) {
  37335. var t0025 = 1;
  37336. var t0125 = 0;
  37337. var t0225 = 0;
  37338. var t0312 = 0;
  37339. var t1025 = 0;
  37340. var t1125 = 1;
  37341. var t1225 = 0;
  37342. var t1312 = 0;
  37343. var t2025 = 0;
  37344. var t2125 = 0;
  37345. var t2225 = 1;
  37346. var t2312 = 0;
  37347. var t3012 = 0;
  37348. var t3112 = 0;
  37349. var t3212 = 0;
  37350. var t3312 = 1;
  37351. mat412.e00 = t0025;
  37352. mat412.e01 = t0125;
  37353. mat412.e02 = t0225;
  37354. mat412.e03 = t0312;
  37355. mat412.e10 = t1025;
  37356. mat412.e11 = t1125;
  37357. mat412.e12 = t1225;
  37358. mat412.e13 = t1312;
  37359. mat412.e20 = t2025;
  37360. mat412.e21 = t2125;
  37361. mat412.e22 = t2225;
  37362. mat412.e23 = t2312;
  37363. mat412.e30 = t3012;
  37364. mat412.e31 = t3112;
  37365. mat412.e32 = t3212;
  37366. mat412.e33 = t3312;
  37367. if(_this66.sizeMat4 == _this66.stackMat4.length) {
  37368. var newLength50 = _this66.sizeMat4 << 1;
  37369. var this51 = new Array(newLength50);
  37370. var newArray50 = this51;
  37371. var _g60 = 0;
  37372. var _g150 = _this66.sizeMat4;
  37373. while(_g60 < _g150) {
  37374. var i50 = _g60++;
  37375. newArray50[i50] = _this66.stackMat4[i50];
  37376. _this66.stackMat4[i50] = null;
  37377. }
  37378. _this66.stackMat4 = newArray50;
  37379. }
  37380. _this66.stackMat4[_this66.sizeMat4++] = mat412;
  37381. }
  37382. if(quat12 != null) {
  37383. var tx39 = 0;
  37384. var ty39 = 0;
  37385. var tz39 = 0;
  37386. var tw12 = 1;
  37387. quat12.x = tx39;
  37388. quat12.y = ty39;
  37389. quat12.z = tz39;
  37390. quat12.w = tw12;
  37391. if(_this66.sizeQuat == _this66.stackQuat.length) {
  37392. var newLength51 = _this66.sizeQuat << 1;
  37393. var this52 = new Array(newLength51);
  37394. var newArray51 = this52;
  37395. var _g61 = 0;
  37396. var _g151 = _this66.sizeQuat;
  37397. while(_g61 < _g151) {
  37398. var i51 = _g61++;
  37399. newArray51[i51] = _this66.stackQuat[i51];
  37400. _this66.stackQuat[i51] = null;
  37401. }
  37402. _this66.stackQuat = newArray51;
  37403. }
  37404. _this66.stackQuat[_this66.sizeQuat++] = quat12;
  37405. }
  37406. var _this67 = this.p;
  37407. var mat312 = null;
  37408. var mat413 = null;
  37409. var quat13 = null;
  37410. if(ex != null) {
  37411. ex.zero();
  37412. if(_this67.sizeVec3 == _this67.stackVec3.length) {
  37413. var newLength52 = _this67.sizeVec3 << 1;
  37414. var this53 = new Array(newLength52);
  37415. var newArray52 = this53;
  37416. var _g62 = 0;
  37417. var _g152 = _this67.sizeVec3;
  37418. while(_g62 < _g152) {
  37419. var i52 = _g62++;
  37420. newArray52[i52] = _this67.stackVec3[i52];
  37421. _this67.stackVec3[i52] = null;
  37422. }
  37423. _this67.stackVec3 = newArray52;
  37424. }
  37425. _this67.stackVec3[_this67.sizeVec3++] = ex;
  37426. }
  37427. if(mat312 != null) {
  37428. var t0026 = 1;
  37429. var t0126 = 0;
  37430. var t0226 = 0;
  37431. var t1026 = 0;
  37432. var t1126 = 1;
  37433. var t1226 = 0;
  37434. var t2026 = 0;
  37435. var t2126 = 0;
  37436. var t2226 = 1;
  37437. mat312.e00 = t0026;
  37438. mat312.e01 = t0126;
  37439. mat312.e02 = t0226;
  37440. mat312.e10 = t1026;
  37441. mat312.e11 = t1126;
  37442. mat312.e12 = t1226;
  37443. mat312.e20 = t2026;
  37444. mat312.e21 = t2126;
  37445. mat312.e22 = t2226;
  37446. if(_this67.sizeMat3 == _this67.stackMat3.length) {
  37447. var newLength53 = _this67.sizeMat3 << 1;
  37448. var this54 = new Array(newLength53);
  37449. var newArray53 = this54;
  37450. var _g63 = 0;
  37451. var _g153 = _this67.sizeMat3;
  37452. while(_g63 < _g153) {
  37453. var i53 = _g63++;
  37454. newArray53[i53] = _this67.stackMat3[i53];
  37455. _this67.stackMat3[i53] = null;
  37456. }
  37457. _this67.stackMat3 = newArray53;
  37458. }
  37459. _this67.stackMat3[_this67.sizeMat3++] = mat312;
  37460. }
  37461. if(mat413 != null) {
  37462. var t0027 = 1;
  37463. var t0127 = 0;
  37464. var t0227 = 0;
  37465. var t0313 = 0;
  37466. var t1027 = 0;
  37467. var t1127 = 1;
  37468. var t1227 = 0;
  37469. var t1313 = 0;
  37470. var t2027 = 0;
  37471. var t2127 = 0;
  37472. var t2227 = 1;
  37473. var t2313 = 0;
  37474. var t3013 = 0;
  37475. var t3113 = 0;
  37476. var t3213 = 0;
  37477. var t3313 = 1;
  37478. mat413.e00 = t0027;
  37479. mat413.e01 = t0127;
  37480. mat413.e02 = t0227;
  37481. mat413.e03 = t0313;
  37482. mat413.e10 = t1027;
  37483. mat413.e11 = t1127;
  37484. mat413.e12 = t1227;
  37485. mat413.e13 = t1313;
  37486. mat413.e20 = t2027;
  37487. mat413.e21 = t2127;
  37488. mat413.e22 = t2227;
  37489. mat413.e23 = t2313;
  37490. mat413.e30 = t3013;
  37491. mat413.e31 = t3113;
  37492. mat413.e32 = t3213;
  37493. mat413.e33 = t3313;
  37494. if(_this67.sizeMat4 == _this67.stackMat4.length) {
  37495. var newLength54 = _this67.sizeMat4 << 1;
  37496. var this55 = new Array(newLength54);
  37497. var newArray54 = this55;
  37498. var _g64 = 0;
  37499. var _g154 = _this67.sizeMat4;
  37500. while(_g64 < _g154) {
  37501. var i54 = _g64++;
  37502. newArray54[i54] = _this67.stackMat4[i54];
  37503. _this67.stackMat4[i54] = null;
  37504. }
  37505. _this67.stackMat4 = newArray54;
  37506. }
  37507. _this67.stackMat4[_this67.sizeMat4++] = mat413;
  37508. }
  37509. if(quat13 != null) {
  37510. var tx40 = 0;
  37511. var ty40 = 0;
  37512. var tz40 = 0;
  37513. var tw13 = 1;
  37514. quat13.x = tx40;
  37515. quat13.y = ty40;
  37516. quat13.z = tz40;
  37517. quat13.w = tw13;
  37518. if(_this67.sizeQuat == _this67.stackQuat.length) {
  37519. var newLength55 = _this67.sizeQuat << 1;
  37520. var this56 = new Array(newLength55);
  37521. var newArray55 = this56;
  37522. var _g65 = 0;
  37523. var _g155 = _this67.sizeQuat;
  37524. while(_g65 < _g155) {
  37525. var i55 = _g65++;
  37526. newArray55[i55] = _this67.stackQuat[i55];
  37527. _this67.stackQuat[i55] = null;
  37528. }
  37529. _this67.stackQuat = newArray55;
  37530. }
  37531. _this67.stackQuat[_this67.sizeQuat++] = quat13;
  37532. }
  37533. var _this68 = this.p;
  37534. var mat313 = null;
  37535. var mat414 = null;
  37536. var quat14 = null;
  37537. if(ey != null) {
  37538. ey.zero();
  37539. if(_this68.sizeVec3 == _this68.stackVec3.length) {
  37540. var newLength56 = _this68.sizeVec3 << 1;
  37541. var this57 = new Array(newLength56);
  37542. var newArray56 = this57;
  37543. var _g66 = 0;
  37544. var _g156 = _this68.sizeVec3;
  37545. while(_g66 < _g156) {
  37546. var i56 = _g66++;
  37547. newArray56[i56] = _this68.stackVec3[i56];
  37548. _this68.stackVec3[i56] = null;
  37549. }
  37550. _this68.stackVec3 = newArray56;
  37551. }
  37552. _this68.stackVec3[_this68.sizeVec3++] = ey;
  37553. }
  37554. if(mat313 != null) {
  37555. var t0028 = 1;
  37556. var t0128 = 0;
  37557. var t0228 = 0;
  37558. var t1028 = 0;
  37559. var t1128 = 1;
  37560. var t1228 = 0;
  37561. var t2028 = 0;
  37562. var t2128 = 0;
  37563. var t2228 = 1;
  37564. mat313.e00 = t0028;
  37565. mat313.e01 = t0128;
  37566. mat313.e02 = t0228;
  37567. mat313.e10 = t1028;
  37568. mat313.e11 = t1128;
  37569. mat313.e12 = t1228;
  37570. mat313.e20 = t2028;
  37571. mat313.e21 = t2128;
  37572. mat313.e22 = t2228;
  37573. if(_this68.sizeMat3 == _this68.stackMat3.length) {
  37574. var newLength57 = _this68.sizeMat3 << 1;
  37575. var this58 = new Array(newLength57);
  37576. var newArray57 = this58;
  37577. var _g67 = 0;
  37578. var _g157 = _this68.sizeMat3;
  37579. while(_g67 < _g157) {
  37580. var i57 = _g67++;
  37581. newArray57[i57] = _this68.stackMat3[i57];
  37582. _this68.stackMat3[i57] = null;
  37583. }
  37584. _this68.stackMat3 = newArray57;
  37585. }
  37586. _this68.stackMat3[_this68.sizeMat3++] = mat313;
  37587. }
  37588. if(mat414 != null) {
  37589. var t0029 = 1;
  37590. var t0129 = 0;
  37591. var t0229 = 0;
  37592. var t0314 = 0;
  37593. var t1029 = 0;
  37594. var t1129 = 1;
  37595. var t1229 = 0;
  37596. var t1314 = 0;
  37597. var t2029 = 0;
  37598. var t2129 = 0;
  37599. var t2229 = 1;
  37600. var t2314 = 0;
  37601. var t3014 = 0;
  37602. var t3114 = 0;
  37603. var t3214 = 0;
  37604. var t3314 = 1;
  37605. mat414.e00 = t0029;
  37606. mat414.e01 = t0129;
  37607. mat414.e02 = t0229;
  37608. mat414.e03 = t0314;
  37609. mat414.e10 = t1029;
  37610. mat414.e11 = t1129;
  37611. mat414.e12 = t1229;
  37612. mat414.e13 = t1314;
  37613. mat414.e20 = t2029;
  37614. mat414.e21 = t2129;
  37615. mat414.e22 = t2229;
  37616. mat414.e23 = t2314;
  37617. mat414.e30 = t3014;
  37618. mat414.e31 = t3114;
  37619. mat414.e32 = t3214;
  37620. mat414.e33 = t3314;
  37621. if(_this68.sizeMat4 == _this68.stackMat4.length) {
  37622. var newLength58 = _this68.sizeMat4 << 1;
  37623. var this59 = new Array(newLength58);
  37624. var newArray58 = this59;
  37625. var _g68 = 0;
  37626. var _g158 = _this68.sizeMat4;
  37627. while(_g68 < _g158) {
  37628. var i58 = _g68++;
  37629. newArray58[i58] = _this68.stackMat4[i58];
  37630. _this68.stackMat4[i58] = null;
  37631. }
  37632. _this68.stackMat4 = newArray58;
  37633. }
  37634. _this68.stackMat4[_this68.sizeMat4++] = mat414;
  37635. }
  37636. if(quat14 != null) {
  37637. var tx41 = 0;
  37638. var ty41 = 0;
  37639. var tz41 = 0;
  37640. var tw14 = 1;
  37641. quat14.x = tx41;
  37642. quat14.y = ty41;
  37643. quat14.z = tz41;
  37644. quat14.w = tw14;
  37645. if(_this68.sizeQuat == _this68.stackQuat.length) {
  37646. var newLength59 = _this68.sizeQuat << 1;
  37647. var this60 = new Array(newLength59);
  37648. var newArray59 = this60;
  37649. var _g69 = 0;
  37650. var _g159 = _this68.sizeQuat;
  37651. while(_g69 < _g159) {
  37652. var i59 = _g69++;
  37653. newArray59[i59] = _this68.stackQuat[i59];
  37654. _this68.stackQuat[i59] = null;
  37655. }
  37656. _this68.stackQuat = newArray59;
  37657. }
  37658. _this68.stackQuat[_this68.sizeQuat++] = quat14;
  37659. }
  37660. var _this69 = this.p;
  37661. var mat314 = null;
  37662. var mat415 = null;
  37663. var quat15 = null;
  37664. if(ez != null) {
  37665. ez.zero();
  37666. if(_this69.sizeVec3 == _this69.stackVec3.length) {
  37667. var newLength60 = _this69.sizeVec3 << 1;
  37668. var this61 = new Array(newLength60);
  37669. var newArray60 = this61;
  37670. var _g70 = 0;
  37671. var _g160 = _this69.sizeVec3;
  37672. while(_g70 < _g160) {
  37673. var i60 = _g70++;
  37674. newArray60[i60] = _this69.stackVec3[i60];
  37675. _this69.stackVec3[i60] = null;
  37676. }
  37677. _this69.stackVec3 = newArray60;
  37678. }
  37679. _this69.stackVec3[_this69.sizeVec3++] = ez;
  37680. }
  37681. if(mat314 != null) {
  37682. var t0030 = 1;
  37683. var t0130 = 0;
  37684. var t0230 = 0;
  37685. var t1030 = 0;
  37686. var t1130 = 1;
  37687. var t1230 = 0;
  37688. var t2030 = 0;
  37689. var t2130 = 0;
  37690. var t2230 = 1;
  37691. mat314.e00 = t0030;
  37692. mat314.e01 = t0130;
  37693. mat314.e02 = t0230;
  37694. mat314.e10 = t1030;
  37695. mat314.e11 = t1130;
  37696. mat314.e12 = t1230;
  37697. mat314.e20 = t2030;
  37698. mat314.e21 = t2130;
  37699. mat314.e22 = t2230;
  37700. if(_this69.sizeMat3 == _this69.stackMat3.length) {
  37701. var newLength61 = _this69.sizeMat3 << 1;
  37702. var this62 = new Array(newLength61);
  37703. var newArray61 = this62;
  37704. var _g71 = 0;
  37705. var _g161 = _this69.sizeMat3;
  37706. while(_g71 < _g161) {
  37707. var i61 = _g71++;
  37708. newArray61[i61] = _this69.stackMat3[i61];
  37709. _this69.stackMat3[i61] = null;
  37710. }
  37711. _this69.stackMat3 = newArray61;
  37712. }
  37713. _this69.stackMat3[_this69.sizeMat3++] = mat314;
  37714. }
  37715. if(mat415 != null) {
  37716. var t0031 = 1;
  37717. var t0131 = 0;
  37718. var t0231 = 0;
  37719. var t0315 = 0;
  37720. var t1031 = 0;
  37721. var t1131 = 1;
  37722. var t1231 = 0;
  37723. var t1315 = 0;
  37724. var t2031 = 0;
  37725. var t2131 = 0;
  37726. var t2231 = 1;
  37727. var t2315 = 0;
  37728. var t3015 = 0;
  37729. var t3115 = 0;
  37730. var t3215 = 0;
  37731. var t3315 = 1;
  37732. mat415.e00 = t0031;
  37733. mat415.e01 = t0131;
  37734. mat415.e02 = t0231;
  37735. mat415.e03 = t0315;
  37736. mat415.e10 = t1031;
  37737. mat415.e11 = t1131;
  37738. mat415.e12 = t1231;
  37739. mat415.e13 = t1315;
  37740. mat415.e20 = t2031;
  37741. mat415.e21 = t2131;
  37742. mat415.e22 = t2231;
  37743. mat415.e23 = t2315;
  37744. mat415.e30 = t3015;
  37745. mat415.e31 = t3115;
  37746. mat415.e32 = t3215;
  37747. mat415.e33 = t3315;
  37748. if(_this69.sizeMat4 == _this69.stackMat4.length) {
  37749. var newLength62 = _this69.sizeMat4 << 1;
  37750. var this63 = new Array(newLength62);
  37751. var newArray62 = this63;
  37752. var _g72 = 0;
  37753. var _g162 = _this69.sizeMat4;
  37754. while(_g72 < _g162) {
  37755. var i62 = _g72++;
  37756. newArray62[i62] = _this69.stackMat4[i62];
  37757. _this69.stackMat4[i62] = null;
  37758. }
  37759. _this69.stackMat4 = newArray62;
  37760. }
  37761. _this69.stackMat4[_this69.sizeMat4++] = mat415;
  37762. }
  37763. if(quat15 != null) {
  37764. var tx42 = 0;
  37765. var ty42 = 0;
  37766. var tz42 = 0;
  37767. var tw15 = 1;
  37768. quat15.x = tx42;
  37769. quat15.y = ty42;
  37770. quat15.z = tz42;
  37771. quat15.w = tw15;
  37772. if(_this69.sizeQuat == _this69.stackQuat.length) {
  37773. var newLength63 = _this69.sizeQuat << 1;
  37774. var this64 = new Array(newLength63);
  37775. var newArray63 = this64;
  37776. var _g73 = 0;
  37777. var _g163 = _this69.sizeQuat;
  37778. while(_g73 < _g163) {
  37779. var i63 = _g73++;
  37780. newArray63[i63] = _this69.stackQuat[i63];
  37781. _this69.stackQuat[i63] = null;
  37782. }
  37783. _this69.stackQuat = newArray63;
  37784. }
  37785. _this69.stackQuat[_this69.sizeQuat++] = quat15;
  37786. }
  37787. }
  37788. rect(v1,v2,v3,v4,n1,n2,n3,n4,color) {
  37789. this.triangle(v1,v2,v3,n1,n2,n3,color);
  37790. this.triangle(v1,v3,v4,n1,n3,n4,color);
  37791. }
  37792. point(v,color) {
  37793. }
  37794. triangle(v1,v2,v3,n1,n2,n3,color) {
  37795. }
  37796. line(v1,v2,color) {
  37797. }
  37798. }
  37799. oimo.dynamics.common.DebugDrawStyle = class oimo_dynamics_common_DebugDrawStyle {
  37800. constructor() {
  37801. this.basisColorZ = new oimo.common.Vec3(0.0,0.0,1.0);
  37802. this.basisColorY = new oimo.common.Vec3(0.0,1.0,0.0);
  37803. this.basisColorX = new oimo.common.Vec3(1.0,0.0,0.0);
  37804. this.basisLength = 0.5;
  37805. this.jointRotationalConstraintRadius = 0.3;
  37806. this.jointErrorColor = new oimo.common.Vec3(1.0,0.1,0.1);
  37807. this.jointLineColor = new oimo.common.Vec3(0.8,0.8,0.8);
  37808. this.contactBinormalLength = 0.5;
  37809. this.contactTangentLength = 0.5;
  37810. this.contactNormalLength = 0.5;
  37811. this.contactBinormalColor = new oimo.common.Vec3(0.2,0.2,1.0);
  37812. this.contactTangentColor = new oimo.common.Vec3(0.1,0.8,0.1);
  37813. this.contactNormalColor = new oimo.common.Vec3(1.0,0.1,0.1);
  37814. this.disabledContactColor = new oimo.common.Vec3(0.5,0.1,0.1);
  37815. this.newContactColor = new oimo.common.Vec3(1.0,1.0,0.1);
  37816. this.contactColor4 = new oimo.common.Vec3(0.8,0.1,1.0);
  37817. this.contactColor3 = new oimo.common.Vec3(0.1,0.8,0.6);
  37818. this.contactColor2 = new oimo.common.Vec3(1.0,0.6,0.1);
  37819. this.contactColor = new oimo.common.Vec3(1.0,0.1,0.1);
  37820. this.pairColor = new oimo.common.Vec3(1.0,1.0,0.1);
  37821. this.bvhNodeColor = new oimo.common.Vec3(0.4,0.4,0.4);
  37822. this.aabbColor = new oimo.common.Vec3(1.0,0.1,0.1);
  37823. this.kinematicShapeColor = new oimo.common.Vec3(1.0,0.5,0.1);
  37824. this.staticShapeColor = new oimo.common.Vec3(0.7,0.7,0.7);
  37825. this.sleepingShapeColor2 = new oimo.common.Vec3(0.2,0.8,0.5);
  37826. this.sleepingShapeColor1 = new oimo.common.Vec3(0.3,0.3,0.8);
  37827. this.sleepyShapeColor2 = new oimo.common.Vec3(0.6,0.8,0.3);
  37828. this.sleepyShapeColor1 = new oimo.common.Vec3(0.5,0.25,0.6);
  37829. this.shapeColor2 = new oimo.common.Vec3(1.0,0.8,0.1);
  37830. this.shapeColor1 = new oimo.common.Vec3(0.7,0.2,0.4);
  37831. }
  37832. }
  37833. oimo.dynamics.common.Performance = class oimo_dynamics_common_Performance {
  37834. }
  37835. if(!oimo.dynamics.constraint) oimo.dynamics.constraint = {};
  37836. oimo.dynamics.constraint.ConstraintSolver = class oimo_dynamics_constraint_ConstraintSolver {
  37837. constructor() {
  37838. this._b1 = null;
  37839. this._b2 = null;
  37840. this._addedToIsland = false;
  37841. }
  37842. preSolveVelocity(timeStep) {
  37843. }
  37844. warmStart(timeStep) {
  37845. }
  37846. solveVelocity() {
  37847. }
  37848. postSolveVelocity(timeStep) {
  37849. }
  37850. preSolvePosition(timeStep) {
  37851. }
  37852. solvePositionSplitImpulse() {
  37853. }
  37854. solvePositionNgs(timeStep) {
  37855. }
  37856. postSolve() {
  37857. }
  37858. }
  37859. oimo.dynamics.constraint.PositionCorrectionAlgorithm = class oimo_dynamics_constraint_PositionCorrectionAlgorithm {
  37860. }
  37861. if(!oimo.dynamics.constraint.contact) oimo.dynamics.constraint.contact = {};
  37862. oimo.dynamics.constraint.contact.ContactConstraint = class oimo_dynamics_constraint_contact_ContactConstraint {
  37863. constructor(manifold) {
  37864. this._solver = new oimo.dynamics.constraint.solver.pgs.PgsContactConstraintSolver(this);
  37865. this._manifold = manifold;
  37866. }
  37867. _getVelocitySolverInfo(timeStep,info) {
  37868. info.b1 = this._b1;
  37869. info.b2 = this._b2;
  37870. var normal;
  37871. var normalX;
  37872. var normalY;
  37873. var normalZ;
  37874. var tangent;
  37875. var tangentX;
  37876. var tangentY;
  37877. var tangentZ;
  37878. var binormal;
  37879. var binormalX;
  37880. var binormalY;
  37881. var binormalZ;
  37882. normalX = this._manifold._normalX;
  37883. normalY = this._manifold._normalY;
  37884. normalZ = this._manifold._normalZ;
  37885. tangentX = this._manifold._tangentX;
  37886. tangentY = this._manifold._tangentY;
  37887. tangentZ = this._manifold._tangentZ;
  37888. binormalX = this._manifold._binormalX;
  37889. binormalY = this._manifold._binormalY;
  37890. binormalZ = this._manifold._binormalZ;
  37891. var friction = Math.sqrt(this._s1._friction * this._s2._friction);
  37892. var restitution = Math.sqrt(this._s1._restitution * this._s2._restitution);
  37893. var num = this._manifold._numPoints;
  37894. info.numRows = 0;
  37895. var posDiff;
  37896. var posDiffX;
  37897. var posDiffY;
  37898. var posDiffZ;
  37899. posDiffX = this._tf1._positionX - this._tf2._positionX;
  37900. posDiffY = this._tf1._positionY - this._tf2._positionY;
  37901. posDiffZ = this._tf1._positionZ - this._tf2._positionZ;
  37902. var _g = 0;
  37903. var _g1 = num;
  37904. while(_g < _g1) {
  37905. var i = _g++;
  37906. var p = this._manifold._points[i];
  37907. if(p._depth < 0) {
  37908. p._disabled = true;
  37909. var _this = p._impulse;
  37910. _this.impulseN = 0;
  37911. _this.impulseT = 0;
  37912. _this.impulseB = 0;
  37913. _this.impulseP = 0;
  37914. _this.impulseLX = 0;
  37915. _this.impulseLY = 0;
  37916. _this.impulseLZ = 0;
  37917. continue;
  37918. } else {
  37919. p._disabled = false;
  37920. }
  37921. var row = info.rows[info.numRows++];
  37922. row.friction = friction;
  37923. row.cfm = 0;
  37924. var j = row.jacobianN;
  37925. j.lin1X = normalX;
  37926. j.lin1Y = normalY;
  37927. j.lin1Z = normalZ;
  37928. j.lin2X = normalX;
  37929. j.lin2Y = normalY;
  37930. j.lin2Z = normalZ;
  37931. j.ang1X = p._relPos1Y * normalZ - p._relPos1Z * normalY;
  37932. j.ang1Y = p._relPos1Z * normalX - p._relPos1X * normalZ;
  37933. j.ang1Z = p._relPos1X * normalY - p._relPos1Y * normalX;
  37934. j.ang2X = p._relPos2Y * normalZ - p._relPos2Z * normalY;
  37935. j.ang2Y = p._relPos2Z * normalX - p._relPos2X * normalZ;
  37936. j.ang2Z = p._relPos2X * normalY - p._relPos2Y * normalX;
  37937. j = row.jacobianT;
  37938. j.lin1X = tangentX;
  37939. j.lin1Y = tangentY;
  37940. j.lin1Z = tangentZ;
  37941. j.lin2X = tangentX;
  37942. j.lin2Y = tangentY;
  37943. j.lin2Z = tangentZ;
  37944. j.ang1X = p._relPos1Y * tangentZ - p._relPos1Z * tangentY;
  37945. j.ang1Y = p._relPos1Z * tangentX - p._relPos1X * tangentZ;
  37946. j.ang1Z = p._relPos1X * tangentY - p._relPos1Y * tangentX;
  37947. j.ang2X = p._relPos2Y * tangentZ - p._relPos2Z * tangentY;
  37948. j.ang2Y = p._relPos2Z * tangentX - p._relPos2X * tangentZ;
  37949. j.ang2Z = p._relPos2X * tangentY - p._relPos2Y * tangentX;
  37950. j = row.jacobianB;
  37951. j.lin1X = binormalX;
  37952. j.lin1Y = binormalY;
  37953. j.lin1Z = binormalZ;
  37954. j.lin2X = binormalX;
  37955. j.lin2Y = binormalY;
  37956. j.lin2Z = binormalZ;
  37957. j.ang1X = p._relPos1Y * binormalZ - p._relPos1Z * binormalY;
  37958. j.ang1Y = p._relPos1Z * binormalX - p._relPos1X * binormalZ;
  37959. j.ang1Z = p._relPos1X * binormalY - p._relPos1Y * binormalX;
  37960. j.ang2X = p._relPos2Y * binormalZ - p._relPos2Z * binormalY;
  37961. j.ang2Y = p._relPos2Z * binormalX - p._relPos2X * binormalZ;
  37962. j.ang2Z = p._relPos2X * binormalY - p._relPos2Y * binormalX;
  37963. j = row.jacobianN;
  37964. var rvn = j.lin1X * this._b1._velX + j.lin1Y * this._b1._velY + j.lin1Z * this._b1._velZ + (j.ang1X * this._b1._angVelX + j.ang1Y * this._b1._angVelY + j.ang1Z * this._b1._angVelZ) - (j.lin2X * this._b2._velX + j.lin2Y * this._b2._velY + j.lin2Z * this._b2._velZ + (j.ang2X * this._b2._angVelX + j.ang2Y * this._b2._angVelY + j.ang2Z * this._b2._angVelZ));
  37965. if(rvn < -oimo.common.Setting.contactEnableBounceThreshold && !p._warmStarted) {
  37966. row.rhs = -rvn * restitution;
  37967. } else {
  37968. row.rhs = 0;
  37969. }
  37970. if(this._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE) {
  37971. if(p._depth > oimo.common.Setting.linearSlop) {
  37972. var minRhs = (p._depth - oimo.common.Setting.linearSlop) * oimo.common.Setting.velocityBaumgarte * timeStep.invDt;
  37973. if(row.rhs < minRhs) {
  37974. row.rhs = minRhs;
  37975. }
  37976. }
  37977. }
  37978. if(!p._warmStarted) {
  37979. var _this1 = p._impulse;
  37980. _this1.impulseN = 0;
  37981. _this1.impulseT = 0;
  37982. _this1.impulseB = 0;
  37983. _this1.impulseP = 0;
  37984. _this1.impulseLX = 0;
  37985. _this1.impulseLY = 0;
  37986. _this1.impulseLZ = 0;
  37987. }
  37988. row.impulse = p._impulse;
  37989. }
  37990. }
  37991. _getPositionSolverInfo(info) {
  37992. info.b1 = this._b1;
  37993. info.b2 = this._b2;
  37994. var normal;
  37995. var normalX;
  37996. var normalY;
  37997. var normalZ;
  37998. normalX = this._manifold._normalX;
  37999. normalY = this._manifold._normalY;
  38000. normalZ = this._manifold._normalZ;
  38001. var num = this._manifold._numPoints;
  38002. info.numRows = 0;
  38003. var _g = 0;
  38004. var _g1 = num;
  38005. while(_g < _g1) {
  38006. var i = _g++;
  38007. var p = this._manifold._points[i];
  38008. if(p._disabled) {
  38009. continue;
  38010. }
  38011. var row = info.rows[info.numRows++];
  38012. var j = row.jacobianN;
  38013. j.lin1X = normalX;
  38014. j.lin1Y = normalY;
  38015. j.lin1Z = normalZ;
  38016. j.lin2X = normalX;
  38017. j.lin2Y = normalY;
  38018. j.lin2Z = normalZ;
  38019. j.ang1X = p._relPos1Y * normalZ - p._relPos1Z * normalY;
  38020. j.ang1Y = p._relPos1Z * normalX - p._relPos1X * normalZ;
  38021. j.ang1Z = p._relPos1X * normalY - p._relPos1Y * normalX;
  38022. j.ang2X = p._relPos2Y * normalZ - p._relPos2Z * normalY;
  38023. j.ang2Y = p._relPos2Z * normalX - p._relPos2X * normalZ;
  38024. j.ang2Z = p._relPos2X * normalY - p._relPos2Y * normalX;
  38025. row.rhs = p._depth - oimo.common.Setting.linearSlop;
  38026. if(row.rhs < 0) {
  38027. row.rhs = 0;
  38028. }
  38029. row.impulse = p._impulse;
  38030. }
  38031. }
  38032. _syncManifold() {
  38033. this._manifold._updateDepthsAndPositions(this._tf1,this._tf2);
  38034. }
  38035. getShape1() {
  38036. return this._s1;
  38037. }
  38038. getShape2() {
  38039. return this._s2;
  38040. }
  38041. getManifold() {
  38042. return this._manifold;
  38043. }
  38044. isTouching() {
  38045. var _g = 0;
  38046. var _g1 = this._manifold._numPoints;
  38047. while(_g < _g1) {
  38048. var i = _g++;
  38049. if(this._manifold._points[i]._depth >= 0) {
  38050. return true;
  38051. }
  38052. }
  38053. return false;
  38054. }
  38055. }
  38056. oimo.dynamics.constraint.contact.ContactImpulse = class oimo_dynamics_constraint_contact_ContactImpulse {
  38057. constructor() {
  38058. this.impulseN = 0;
  38059. this.impulseT = 0;
  38060. this.impulseB = 0;
  38061. this.impulseP = 0;
  38062. this.impulseLX = 0;
  38063. this.impulseLY = 0;
  38064. this.impulseLZ = 0;
  38065. }
  38066. copyFrom(imp) {
  38067. this.impulseN = imp.impulseN;
  38068. this.impulseT = imp.impulseT;
  38069. this.impulseB = imp.impulseB;
  38070. this.impulseLX = imp.impulseLX;
  38071. this.impulseLY = imp.impulseLY;
  38072. this.impulseLZ = imp.impulseLZ;
  38073. }
  38074. }
  38075. oimo.dynamics.constraint.contact.Manifold = class oimo_dynamics_constraint_contact_Manifold {
  38076. constructor() {
  38077. this._normalX = 0;
  38078. this._normalY = 0;
  38079. this._normalZ = 0;
  38080. this._tangentX = 0;
  38081. this._tangentY = 0;
  38082. this._tangentZ = 0;
  38083. this._binormalX = 0;
  38084. this._binormalY = 0;
  38085. this._binormalZ = 0;
  38086. this._numPoints = 0;
  38087. var this1 = new Array(oimo.common.Setting.maxManifoldPoints);
  38088. this._points = this1;
  38089. var _g = 0;
  38090. var _g1 = oimo.common.Setting.maxManifoldPoints;
  38091. while(_g < _g1) {
  38092. var i = _g++;
  38093. this._points[i] = new oimo.dynamics.constraint.contact.ManifoldPoint();
  38094. }
  38095. }
  38096. _clear() {
  38097. var _g = 0;
  38098. var _g1 = this._numPoints;
  38099. while(_g < _g1) {
  38100. var i = _g++;
  38101. var _this = this._points[i];
  38102. _this._localPos1X = 0;
  38103. _this._localPos1Y = 0;
  38104. _this._localPos1Z = 0;
  38105. _this._localPos2X = 0;
  38106. _this._localPos2Y = 0;
  38107. _this._localPos2Z = 0;
  38108. _this._relPos1X = 0;
  38109. _this._relPos1Y = 0;
  38110. _this._relPos1Z = 0;
  38111. _this._relPos2X = 0;
  38112. _this._relPos2Y = 0;
  38113. _this._relPos2Z = 0;
  38114. _this._pos1X = 0;
  38115. _this._pos1Y = 0;
  38116. _this._pos1Z = 0;
  38117. _this._pos2X = 0;
  38118. _this._pos2Y = 0;
  38119. _this._pos2Z = 0;
  38120. _this._depth = 0;
  38121. var _this1 = _this._impulse;
  38122. _this1.impulseN = 0;
  38123. _this1.impulseT = 0;
  38124. _this1.impulseB = 0;
  38125. _this1.impulseP = 0;
  38126. _this1.impulseLX = 0;
  38127. _this1.impulseLY = 0;
  38128. _this1.impulseLZ = 0;
  38129. _this._warmStarted = false;
  38130. _this._disabled = false;
  38131. _this._id = -1;
  38132. }
  38133. this._numPoints = 0;
  38134. }
  38135. _buildBasis(normal) {
  38136. var v = normal;
  38137. this._normalX = v.x;
  38138. this._normalY = v.y;
  38139. this._normalZ = v.z;
  38140. var nx = normal.x;
  38141. var ny = normal.y;
  38142. var nz = normal.z;
  38143. var nx2 = nx * nx;
  38144. var ny2 = ny * ny;
  38145. var nz2 = nz * nz;
  38146. var tx;
  38147. var ty;
  38148. var tz;
  38149. var bx;
  38150. var by;
  38151. var bz;
  38152. if(nx2 < ny2) {
  38153. if(nx2 < nz2) {
  38154. var invL = 1 / Math.sqrt(ny2 + nz2);
  38155. tx = 0;
  38156. ty = -nz * invL;
  38157. tz = ny * invL;
  38158. bx = ny * tz - nz * ty;
  38159. by = -nx * tz;
  38160. bz = nx * ty;
  38161. } else {
  38162. var invL1 = 1 / Math.sqrt(nx2 + ny2);
  38163. tx = -ny * invL1;
  38164. ty = nx * invL1;
  38165. tz = 0;
  38166. bx = -nz * ty;
  38167. by = nz * tx;
  38168. bz = nx * ty - ny * tx;
  38169. }
  38170. } else if(ny2 < nz2) {
  38171. var invL2 = 1 / Math.sqrt(nx2 + nz2);
  38172. tx = nz * invL2;
  38173. ty = 0;
  38174. tz = -nx * invL2;
  38175. bx = ny * tz;
  38176. by = nz * tx - nx * tz;
  38177. bz = -ny * tx;
  38178. } else {
  38179. var invL3 = 1 / Math.sqrt(nx2 + ny2);
  38180. tx = -ny * invL3;
  38181. ty = nx * invL3;
  38182. tz = 0;
  38183. bx = -nz * ty;
  38184. by = nz * tx;
  38185. bz = nx * ty - ny * tx;
  38186. }
  38187. this._tangentX = tx;
  38188. this._tangentY = ty;
  38189. this._tangentZ = tz;
  38190. this._binormalX = bx;
  38191. this._binormalY = by;
  38192. this._binormalZ = bz;
  38193. }
  38194. _updateDepthsAndPositions(tf1,tf2) {
  38195. var _g = 0;
  38196. var _g1 = this._numPoints;
  38197. while(_g < _g1) {
  38198. var i = _g++;
  38199. var p = this._points[i];
  38200. var __tmp__X;
  38201. var __tmp__Y;
  38202. var __tmp__Z;
  38203. __tmp__X = tf1._rotation00 * p._localPos1X + tf1._rotation01 * p._localPos1Y + tf1._rotation02 * p._localPos1Z;
  38204. __tmp__Y = tf1._rotation10 * p._localPos1X + tf1._rotation11 * p._localPos1Y + tf1._rotation12 * p._localPos1Z;
  38205. __tmp__Z = tf1._rotation20 * p._localPos1X + tf1._rotation21 * p._localPos1Y + tf1._rotation22 * p._localPos1Z;
  38206. p._relPos1X = __tmp__X;
  38207. p._relPos1Y = __tmp__Y;
  38208. p._relPos1Z = __tmp__Z;
  38209. var __tmp__X1;
  38210. var __tmp__Y1;
  38211. var __tmp__Z1;
  38212. __tmp__X1 = tf2._rotation00 * p._localPos2X + tf2._rotation01 * p._localPos2Y + tf2._rotation02 * p._localPos2Z;
  38213. __tmp__Y1 = tf2._rotation10 * p._localPos2X + tf2._rotation11 * p._localPos2Y + tf2._rotation12 * p._localPos2Z;
  38214. __tmp__Z1 = tf2._rotation20 * p._localPos2X + tf2._rotation21 * p._localPos2Y + tf2._rotation22 * p._localPos2Z;
  38215. p._relPos2X = __tmp__X1;
  38216. p._relPos2Y = __tmp__Y1;
  38217. p._relPos2Z = __tmp__Z1;
  38218. p._pos1X = p._relPos1X + tf1._positionX;
  38219. p._pos1Y = p._relPos1Y + tf1._positionY;
  38220. p._pos1Z = p._relPos1Z + tf1._positionZ;
  38221. p._pos2X = p._relPos2X + tf2._positionX;
  38222. p._pos2Y = p._relPos2Y + tf2._positionY;
  38223. p._pos2Z = p._relPos2Z + tf2._positionZ;
  38224. var diff;
  38225. var diffX;
  38226. var diffY;
  38227. var diffZ;
  38228. diffX = p._pos1X - p._pos2X;
  38229. diffY = p._pos1Y - p._pos2Y;
  38230. diffZ = p._pos1Z - p._pos2Z;
  38231. var dotN = diffX * this._normalX + diffY * this._normalY + diffZ * this._normalZ;
  38232. p._depth = -dotN;
  38233. }
  38234. }
  38235. getNormal() {
  38236. var v = new oimo.common.Vec3();
  38237. var v1 = v;
  38238. v1.x = this._normalX;
  38239. v1.y = this._normalY;
  38240. v1.z = this._normalZ;
  38241. return v;
  38242. }
  38243. getNormalTo(normal) {
  38244. var v = normal;
  38245. v.x = this._normalX;
  38246. v.y = this._normalY;
  38247. v.z = this._normalZ;
  38248. }
  38249. getTangent() {
  38250. var v = new oimo.common.Vec3();
  38251. var v1 = v;
  38252. v1.x = this._tangentX;
  38253. v1.y = this._tangentY;
  38254. v1.z = this._tangentZ;
  38255. return v;
  38256. }
  38257. getTangentTo(tangent) {
  38258. var v = tangent;
  38259. v.x = this._tangentX;
  38260. v.y = this._tangentY;
  38261. v.z = this._tangentZ;
  38262. }
  38263. getBinormal() {
  38264. var v = new oimo.common.Vec3();
  38265. var v1 = v;
  38266. v1.x = this._binormalX;
  38267. v1.y = this._binormalY;
  38268. v1.z = this._binormalZ;
  38269. return v;
  38270. }
  38271. getBinormalTo(binormal) {
  38272. var v = binormal;
  38273. v.x = this._binormalX;
  38274. v.y = this._binormalY;
  38275. v.z = this._binormalZ;
  38276. }
  38277. getPoints() {
  38278. return this._points;
  38279. }
  38280. getNumPoints() {
  38281. return this._numPoints;
  38282. }
  38283. }
  38284. oimo.dynamics.constraint.contact.ManifoldPoint = class oimo_dynamics_constraint_contact_ManifoldPoint {
  38285. constructor() {
  38286. this._localPos1X = 0;
  38287. this._localPos1Y = 0;
  38288. this._localPos1Z = 0;
  38289. this._localPos2X = 0;
  38290. this._localPos2Y = 0;
  38291. this._localPos2Z = 0;
  38292. this._relPos1X = 0;
  38293. this._relPos1Y = 0;
  38294. this._relPos1Z = 0;
  38295. this._relPos2X = 0;
  38296. this._relPos2Y = 0;
  38297. this._relPos2Z = 0;
  38298. this._pos1X = 0;
  38299. this._pos1Y = 0;
  38300. this._pos1Z = 0;
  38301. this._pos2X = 0;
  38302. this._pos2Y = 0;
  38303. this._pos2Z = 0;
  38304. this._depth = 0;
  38305. this._impulse = new oimo.dynamics.constraint.contact.ContactImpulse();
  38306. this._warmStarted = false;
  38307. this._disabled = false;
  38308. this._id = -1;
  38309. }
  38310. getPosition1() {
  38311. var v = new oimo.common.Vec3();
  38312. var v1 = v;
  38313. v1.x = this._pos1X;
  38314. v1.y = this._pos1Y;
  38315. v1.z = this._pos1Z;
  38316. return v;
  38317. }
  38318. getPosition1To(position) {
  38319. var v = position;
  38320. v.x = this._pos1X;
  38321. v.y = this._pos1Y;
  38322. v.z = this._pos1Z;
  38323. }
  38324. getPosition2() {
  38325. var v = new oimo.common.Vec3();
  38326. var v1 = v;
  38327. v1.x = this._pos2X;
  38328. v1.y = this._pos2Y;
  38329. v1.z = this._pos2Z;
  38330. return v;
  38331. }
  38332. getPosition2To(position) {
  38333. var v = position;
  38334. v.x = this._pos2X;
  38335. v.y = this._pos2Y;
  38336. v.z = this._pos2Z;
  38337. }
  38338. getDepth() {
  38339. return this._depth;
  38340. }
  38341. isWarmStarted() {
  38342. return this._warmStarted;
  38343. }
  38344. getNormalImpulse() {
  38345. return this._impulse.impulseN;
  38346. }
  38347. getTangentImpulse() {
  38348. return this._impulse.impulseT;
  38349. }
  38350. getBinormalImpulse() {
  38351. return this._impulse.impulseB;
  38352. }
  38353. isEnabled() {
  38354. return !this._disabled;
  38355. }
  38356. }
  38357. oimo.dynamics.constraint.contact.ManifoldUpdater = class oimo_dynamics_constraint_contact_ManifoldUpdater {
  38358. constructor(manifold) {
  38359. this._manifold = manifold;
  38360. this.numOldPoints = 0;
  38361. var this1 = new Array(oimo.common.Setting.maxManifoldPoints);
  38362. this.oldPoints = this1;
  38363. var _g = 0;
  38364. var _g1 = oimo.common.Setting.maxManifoldPoints;
  38365. while(_g < _g1) {
  38366. var i = _g++;
  38367. this.oldPoints[i] = new oimo.dynamics.constraint.contact.ManifoldPoint();
  38368. }
  38369. }
  38370. removeOutdatedPoints() {
  38371. var num = this._manifold._numPoints;
  38372. var index = num;
  38373. while(--index >= 0) {
  38374. var p = this._manifold._points[index];
  38375. var diff;
  38376. var diffX;
  38377. var diffY;
  38378. var diffZ;
  38379. diffX = p._pos1X - p._pos2X;
  38380. diffY = p._pos1Y - p._pos2Y;
  38381. diffZ = p._pos1Z - p._pos2Z;
  38382. var dotN = this._manifold._normalX * diffX + this._manifold._normalY * diffY + this._manifold._normalZ * diffZ;
  38383. if(dotN > oimo.common.Setting.contactPersistenceThreshold) {
  38384. this.removeManifoldPoint(index);
  38385. continue;
  38386. }
  38387. diffX += this._manifold._normalX * -dotN;
  38388. diffY += this._manifold._normalY * -dotN;
  38389. diffZ += this._manifold._normalZ * -dotN;
  38390. if(diffX * diffX + diffY * diffY + diffZ * diffZ > oimo.common.Setting.contactPersistenceThreshold * oimo.common.Setting.contactPersistenceThreshold) {
  38391. this.removeManifoldPoint(index);
  38392. continue;
  38393. }
  38394. }
  38395. }
  38396. removeManifoldPoint(index) {
  38397. var lastIndex = --this._manifold._numPoints;
  38398. if(index != lastIndex) {
  38399. var tmp = this._manifold._points[index];
  38400. this._manifold._points[index] = this._manifold._points[lastIndex];
  38401. this._manifold._points[lastIndex] = tmp;
  38402. }
  38403. var _this = this._manifold._points[lastIndex];
  38404. _this._localPos1X = 0;
  38405. _this._localPos1Y = 0;
  38406. _this._localPos1Z = 0;
  38407. _this._localPos2X = 0;
  38408. _this._localPos2Y = 0;
  38409. _this._localPos2Z = 0;
  38410. _this._relPos1X = 0;
  38411. _this._relPos1Y = 0;
  38412. _this._relPos1Z = 0;
  38413. _this._relPos2X = 0;
  38414. _this._relPos2Y = 0;
  38415. _this._relPos2Z = 0;
  38416. _this._pos1X = 0;
  38417. _this._pos1Y = 0;
  38418. _this._pos1Z = 0;
  38419. _this._pos2X = 0;
  38420. _this._pos2Y = 0;
  38421. _this._pos2Z = 0;
  38422. _this._depth = 0;
  38423. var _this1 = _this._impulse;
  38424. _this1.impulseN = 0;
  38425. _this1.impulseT = 0;
  38426. _this1.impulseB = 0;
  38427. _this1.impulseP = 0;
  38428. _this1.impulseLX = 0;
  38429. _this1.impulseLY = 0;
  38430. _this1.impulseLZ = 0;
  38431. _this._warmStarted = false;
  38432. _this._disabled = false;
  38433. _this._id = -1;
  38434. }
  38435. addManifoldPoint(point,tf1,tf2) {
  38436. var num = this._manifold._numPoints;
  38437. if(num == oimo.common.Setting.maxManifoldPoints) {
  38438. var targetIndex = this.computeTargetIndex(point,tf1,tf2);
  38439. var _this = this._manifold._points[targetIndex];
  38440. var v = point.position1;
  38441. _this._pos1X = v.x;
  38442. _this._pos1Y = v.y;
  38443. _this._pos1Z = v.z;
  38444. var v1 = point.position2;
  38445. _this._pos2X = v1.x;
  38446. _this._pos2Y = v1.y;
  38447. _this._pos2Z = v1.z;
  38448. _this._relPos1X = _this._pos1X - tf1._positionX;
  38449. _this._relPos1Y = _this._pos1Y - tf1._positionY;
  38450. _this._relPos1Z = _this._pos1Z - tf1._positionZ;
  38451. _this._relPos2X = _this._pos2X - tf2._positionX;
  38452. _this._relPos2Y = _this._pos2Y - tf2._positionY;
  38453. _this._relPos2Z = _this._pos2Z - tf2._positionZ;
  38454. var __tmp__X;
  38455. var __tmp__Y;
  38456. var __tmp__Z;
  38457. __tmp__X = tf1._rotation00 * _this._relPos1X + tf1._rotation10 * _this._relPos1Y + tf1._rotation20 * _this._relPos1Z;
  38458. __tmp__Y = tf1._rotation01 * _this._relPos1X + tf1._rotation11 * _this._relPos1Y + tf1._rotation21 * _this._relPos1Z;
  38459. __tmp__Z = tf1._rotation02 * _this._relPos1X + tf1._rotation12 * _this._relPos1Y + tf1._rotation22 * _this._relPos1Z;
  38460. _this._localPos1X = __tmp__X;
  38461. _this._localPos1Y = __tmp__Y;
  38462. _this._localPos1Z = __tmp__Z;
  38463. var __tmp__X1;
  38464. var __tmp__Y1;
  38465. var __tmp__Z1;
  38466. __tmp__X1 = tf2._rotation00 * _this._relPos2X + tf2._rotation10 * _this._relPos2Y + tf2._rotation20 * _this._relPos2Z;
  38467. __tmp__Y1 = tf2._rotation01 * _this._relPos2X + tf2._rotation11 * _this._relPos2Y + tf2._rotation21 * _this._relPos2Z;
  38468. __tmp__Z1 = tf2._rotation02 * _this._relPos2X + tf2._rotation12 * _this._relPos2Y + tf2._rotation22 * _this._relPos2Z;
  38469. _this._localPos2X = __tmp__X1;
  38470. _this._localPos2Y = __tmp__Y1;
  38471. _this._localPos2Z = __tmp__Z1;
  38472. _this._depth = point.depth;
  38473. var _this1 = _this._impulse;
  38474. _this1.impulseN = 0;
  38475. _this1.impulseT = 0;
  38476. _this1.impulseB = 0;
  38477. _this1.impulseP = 0;
  38478. _this1.impulseLX = 0;
  38479. _this1.impulseLY = 0;
  38480. _this1.impulseLZ = 0;
  38481. _this._id = point.id;
  38482. _this._warmStarted = false;
  38483. _this._disabled = false;
  38484. return;
  38485. }
  38486. var _this2 = this._manifold._points[num];
  38487. var v2 = point.position1;
  38488. _this2._pos1X = v2.x;
  38489. _this2._pos1Y = v2.y;
  38490. _this2._pos1Z = v2.z;
  38491. var v3 = point.position2;
  38492. _this2._pos2X = v3.x;
  38493. _this2._pos2Y = v3.y;
  38494. _this2._pos2Z = v3.z;
  38495. _this2._relPos1X = _this2._pos1X - tf1._positionX;
  38496. _this2._relPos1Y = _this2._pos1Y - tf1._positionY;
  38497. _this2._relPos1Z = _this2._pos1Z - tf1._positionZ;
  38498. _this2._relPos2X = _this2._pos2X - tf2._positionX;
  38499. _this2._relPos2Y = _this2._pos2Y - tf2._positionY;
  38500. _this2._relPos2Z = _this2._pos2Z - tf2._positionZ;
  38501. var __tmp__X2;
  38502. var __tmp__Y2;
  38503. var __tmp__Z2;
  38504. __tmp__X2 = tf1._rotation00 * _this2._relPos1X + tf1._rotation10 * _this2._relPos1Y + tf1._rotation20 * _this2._relPos1Z;
  38505. __tmp__Y2 = tf1._rotation01 * _this2._relPos1X + tf1._rotation11 * _this2._relPos1Y + tf1._rotation21 * _this2._relPos1Z;
  38506. __tmp__Z2 = tf1._rotation02 * _this2._relPos1X + tf1._rotation12 * _this2._relPos1Y + tf1._rotation22 * _this2._relPos1Z;
  38507. _this2._localPos1X = __tmp__X2;
  38508. _this2._localPos1Y = __tmp__Y2;
  38509. _this2._localPos1Z = __tmp__Z2;
  38510. var __tmp__X3;
  38511. var __tmp__Y3;
  38512. var __tmp__Z3;
  38513. __tmp__X3 = tf2._rotation00 * _this2._relPos2X + tf2._rotation10 * _this2._relPos2Y + tf2._rotation20 * _this2._relPos2Z;
  38514. __tmp__Y3 = tf2._rotation01 * _this2._relPos2X + tf2._rotation11 * _this2._relPos2Y + tf2._rotation21 * _this2._relPos2Z;
  38515. __tmp__Z3 = tf2._rotation02 * _this2._relPos2X + tf2._rotation12 * _this2._relPos2Y + tf2._rotation22 * _this2._relPos2Z;
  38516. _this2._localPos2X = __tmp__X3;
  38517. _this2._localPos2Y = __tmp__Y3;
  38518. _this2._localPos2Z = __tmp__Z3;
  38519. _this2._depth = point.depth;
  38520. var _this3 = _this2._impulse;
  38521. _this3.impulseN = 0;
  38522. _this3.impulseT = 0;
  38523. _this3.impulseB = 0;
  38524. _this3.impulseP = 0;
  38525. _this3.impulseLX = 0;
  38526. _this3.impulseLY = 0;
  38527. _this3.impulseLZ = 0;
  38528. _this2._id = point.id;
  38529. _this2._warmStarted = false;
  38530. _this2._disabled = false;
  38531. this._manifold._numPoints++;
  38532. }
  38533. computeTargetIndex(newPoint,tf1,tf2) {
  38534. var p1 = this._manifold._points[0];
  38535. var p2 = this._manifold._points[1];
  38536. var p3 = this._manifold._points[2];
  38537. var p4 = this._manifold._points[3];
  38538. var maxDepth = p1._depth;
  38539. var maxDepthIndex = 0;
  38540. if(p2._depth > maxDepth) {
  38541. maxDepth = p2._depth;
  38542. maxDepthIndex = 1;
  38543. }
  38544. if(p3._depth > maxDepth) {
  38545. maxDepth = p3._depth;
  38546. maxDepthIndex = 2;
  38547. }
  38548. if(p4._depth > maxDepth) {
  38549. maxDepth = p4._depth;
  38550. maxDepthIndex = 3;
  38551. }
  38552. var rp1;
  38553. var rp1X;
  38554. var rp1Y;
  38555. var rp1Z;
  38556. var v = newPoint.position1;
  38557. rp1X = v.x;
  38558. rp1Y = v.y;
  38559. rp1Z = v.z;
  38560. rp1X -= tf1._positionX;
  38561. rp1Y -= tf1._positionY;
  38562. rp1Z -= tf1._positionZ;
  38563. var p1X = p2._relPos1X;
  38564. var p1Y = p2._relPos1Y;
  38565. var p1Z = p2._relPos1Z;
  38566. var p2X = p3._relPos1X;
  38567. var p2Y = p3._relPos1Y;
  38568. var p2Z = p3._relPos1Z;
  38569. var p3X = p4._relPos1X;
  38570. var p3Y = p4._relPos1Y;
  38571. var p3Z = p4._relPos1Z;
  38572. var v12;
  38573. var v12X;
  38574. var v12Y;
  38575. var v12Z;
  38576. var v34;
  38577. var v34X;
  38578. var v34Y;
  38579. var v34Z;
  38580. var v13;
  38581. var v13X;
  38582. var v13Y;
  38583. var v13Z;
  38584. var v24;
  38585. var v24X;
  38586. var v24Y;
  38587. var v24Z;
  38588. var v14;
  38589. var v14X;
  38590. var v14Y;
  38591. var v14Z;
  38592. var v23;
  38593. var v23X;
  38594. var v23Y;
  38595. var v23Z;
  38596. v12X = p2X - p1X;
  38597. v12Y = p2Y - p1Y;
  38598. v12Z = p2Z - p1Z;
  38599. v34X = rp1X - p3X;
  38600. v34Y = rp1Y - p3Y;
  38601. v34Z = rp1Z - p3Z;
  38602. v13X = p3X - p1X;
  38603. v13Y = p3Y - p1Y;
  38604. v13Z = p3Z - p1Z;
  38605. v24X = rp1X - p2X;
  38606. v24Y = rp1Y - p2Y;
  38607. v24Z = rp1Z - p2Z;
  38608. v14X = rp1X - p1X;
  38609. v14Y = rp1Y - p1Y;
  38610. v14Z = rp1Z - p1Z;
  38611. v23X = p3X - p2X;
  38612. v23Y = p3Y - p2Y;
  38613. v23Z = p3Z - p2Z;
  38614. var cross1;
  38615. var cross1X;
  38616. var cross1Y;
  38617. var cross1Z;
  38618. var cross2;
  38619. var cross2X;
  38620. var cross2Y;
  38621. var cross2Z;
  38622. var cross3;
  38623. var cross3X;
  38624. var cross3Y;
  38625. var cross3Z;
  38626. cross1X = v12Y * v34Z - v12Z * v34Y;
  38627. cross1Y = v12Z * v34X - v12X * v34Z;
  38628. cross1Z = v12X * v34Y - v12Y * v34X;
  38629. cross2X = v13Y * v24Z - v13Z * v24Y;
  38630. cross2Y = v13Z * v24X - v13X * v24Z;
  38631. cross2Z = v13X * v24Y - v13Y * v24X;
  38632. cross3X = v14Y * v23Z - v14Z * v23Y;
  38633. cross3Y = v14Z * v23X - v14X * v23Z;
  38634. cross3Z = v14X * v23Y - v14Y * v23X;
  38635. var a1 = cross1X * cross1X + cross1Y * cross1Y + cross1Z * cross1Z;
  38636. var a2 = cross2X * cross2X + cross2Y * cross2Y + cross2Z * cross2Z;
  38637. var a3 = cross3X * cross3X + cross3Y * cross3Y + cross3Z * cross3Z;
  38638. var a11 = a1 > a2 ? a1 > a3 ? a1 : a3 : a2 > a3 ? a2 : a3;
  38639. var p1X1 = p1._relPos1X;
  38640. var p1Y1 = p1._relPos1Y;
  38641. var p1Z1 = p1._relPos1Z;
  38642. var p2X1 = p3._relPos1X;
  38643. var p2Y1 = p3._relPos1Y;
  38644. var p2Z1 = p3._relPos1Z;
  38645. var p3X1 = p4._relPos1X;
  38646. var p3Y1 = p4._relPos1Y;
  38647. var p3Z1 = p4._relPos1Z;
  38648. var v121;
  38649. var v12X1;
  38650. var v12Y1;
  38651. var v12Z1;
  38652. var v341;
  38653. var v34X1;
  38654. var v34Y1;
  38655. var v34Z1;
  38656. var v131;
  38657. var v13X1;
  38658. var v13Y1;
  38659. var v13Z1;
  38660. var v241;
  38661. var v24X1;
  38662. var v24Y1;
  38663. var v24Z1;
  38664. var v141;
  38665. var v14X1;
  38666. var v14Y1;
  38667. var v14Z1;
  38668. var v231;
  38669. var v23X1;
  38670. var v23Y1;
  38671. var v23Z1;
  38672. v12X1 = p2X1 - p1X1;
  38673. v12Y1 = p2Y1 - p1Y1;
  38674. v12Z1 = p2Z1 - p1Z1;
  38675. v34X1 = rp1X - p3X1;
  38676. v34Y1 = rp1Y - p3Y1;
  38677. v34Z1 = rp1Z - p3Z1;
  38678. v13X1 = p3X1 - p1X1;
  38679. v13Y1 = p3Y1 - p1Y1;
  38680. v13Z1 = p3Z1 - p1Z1;
  38681. v24X1 = rp1X - p2X1;
  38682. v24Y1 = rp1Y - p2Y1;
  38683. v24Z1 = rp1Z - p2Z1;
  38684. v14X1 = rp1X - p1X1;
  38685. v14Y1 = rp1Y - p1Y1;
  38686. v14Z1 = rp1Z - p1Z1;
  38687. v23X1 = p3X1 - p2X1;
  38688. v23Y1 = p3Y1 - p2Y1;
  38689. v23Z1 = p3Z1 - p2Z1;
  38690. var cross11;
  38691. var cross1X1;
  38692. var cross1Y1;
  38693. var cross1Z1;
  38694. var cross21;
  38695. var cross2X1;
  38696. var cross2Y1;
  38697. var cross2Z1;
  38698. var cross31;
  38699. var cross3X1;
  38700. var cross3Y1;
  38701. var cross3Z1;
  38702. cross1X1 = v12Y1 * v34Z1 - v12Z1 * v34Y1;
  38703. cross1Y1 = v12Z1 * v34X1 - v12X1 * v34Z1;
  38704. cross1Z1 = v12X1 * v34Y1 - v12Y1 * v34X1;
  38705. cross2X1 = v13Y1 * v24Z1 - v13Z1 * v24Y1;
  38706. cross2Y1 = v13Z1 * v24X1 - v13X1 * v24Z1;
  38707. cross2Z1 = v13X1 * v24Y1 - v13Y1 * v24X1;
  38708. cross3X1 = v14Y1 * v23Z1 - v14Z1 * v23Y1;
  38709. cross3Y1 = v14Z1 * v23X1 - v14X1 * v23Z1;
  38710. cross3Z1 = v14X1 * v23Y1 - v14Y1 * v23X1;
  38711. var a12 = cross1X1 * cross1X1 + cross1Y1 * cross1Y1 + cross1Z1 * cross1Z1;
  38712. var a21 = cross2X1 * cross2X1 + cross2Y1 * cross2Y1 + cross2Z1 * cross2Z1;
  38713. var a31 = cross3X1 * cross3X1 + cross3Y1 * cross3Y1 + cross3Z1 * cross3Z1;
  38714. var a22 = a12 > a21 ? a12 > a31 ? a12 : a31 : a21 > a31 ? a21 : a31;
  38715. var p1X2 = p1._relPos1X;
  38716. var p1Y2 = p1._relPos1Y;
  38717. var p1Z2 = p1._relPos1Z;
  38718. var p2X2 = p2._relPos1X;
  38719. var p2Y2 = p2._relPos1Y;
  38720. var p2Z2 = p2._relPos1Z;
  38721. var p3X2 = p4._relPos1X;
  38722. var p3Y2 = p4._relPos1Y;
  38723. var p3Z2 = p4._relPos1Z;
  38724. var v122;
  38725. var v12X2;
  38726. var v12Y2;
  38727. var v12Z2;
  38728. var v342;
  38729. var v34X2;
  38730. var v34Y2;
  38731. var v34Z2;
  38732. var v132;
  38733. var v13X2;
  38734. var v13Y2;
  38735. var v13Z2;
  38736. var v242;
  38737. var v24X2;
  38738. var v24Y2;
  38739. var v24Z2;
  38740. var v142;
  38741. var v14X2;
  38742. var v14Y2;
  38743. var v14Z2;
  38744. var v232;
  38745. var v23X2;
  38746. var v23Y2;
  38747. var v23Z2;
  38748. v12X2 = p2X2 - p1X2;
  38749. v12Y2 = p2Y2 - p1Y2;
  38750. v12Z2 = p2Z2 - p1Z2;
  38751. v34X2 = rp1X - p3X2;
  38752. v34Y2 = rp1Y - p3Y2;
  38753. v34Z2 = rp1Z - p3Z2;
  38754. v13X2 = p3X2 - p1X2;
  38755. v13Y2 = p3Y2 - p1Y2;
  38756. v13Z2 = p3Z2 - p1Z2;
  38757. v24X2 = rp1X - p2X2;
  38758. v24Y2 = rp1Y - p2Y2;
  38759. v24Z2 = rp1Z - p2Z2;
  38760. v14X2 = rp1X - p1X2;
  38761. v14Y2 = rp1Y - p1Y2;
  38762. v14Z2 = rp1Z - p1Z2;
  38763. v23X2 = p3X2 - p2X2;
  38764. v23Y2 = p3Y2 - p2Y2;
  38765. v23Z2 = p3Z2 - p2Z2;
  38766. var cross12;
  38767. var cross1X2;
  38768. var cross1Y2;
  38769. var cross1Z2;
  38770. var cross22;
  38771. var cross2X2;
  38772. var cross2Y2;
  38773. var cross2Z2;
  38774. var cross32;
  38775. var cross3X2;
  38776. var cross3Y2;
  38777. var cross3Z2;
  38778. cross1X2 = v12Y2 * v34Z2 - v12Z2 * v34Y2;
  38779. cross1Y2 = v12Z2 * v34X2 - v12X2 * v34Z2;
  38780. cross1Z2 = v12X2 * v34Y2 - v12Y2 * v34X2;
  38781. cross2X2 = v13Y2 * v24Z2 - v13Z2 * v24Y2;
  38782. cross2Y2 = v13Z2 * v24X2 - v13X2 * v24Z2;
  38783. cross2Z2 = v13X2 * v24Y2 - v13Y2 * v24X2;
  38784. cross3X2 = v14Y2 * v23Z2 - v14Z2 * v23Y2;
  38785. cross3Y2 = v14Z2 * v23X2 - v14X2 * v23Z2;
  38786. cross3Z2 = v14X2 * v23Y2 - v14Y2 * v23X2;
  38787. var a13 = cross1X2 * cross1X2 + cross1Y2 * cross1Y2 + cross1Z2 * cross1Z2;
  38788. var a23 = cross2X2 * cross2X2 + cross2Y2 * cross2Y2 + cross2Z2 * cross2Z2;
  38789. var a32 = cross3X2 * cross3X2 + cross3Y2 * cross3Y2 + cross3Z2 * cross3Z2;
  38790. var a33 = a13 > a23 ? a13 > a32 ? a13 : a32 : a23 > a32 ? a23 : a32;
  38791. var p1X3 = p1._relPos1X;
  38792. var p1Y3 = p1._relPos1Y;
  38793. var p1Z3 = p1._relPos1Z;
  38794. var p2X3 = p2._relPos1X;
  38795. var p2Y3 = p2._relPos1Y;
  38796. var p2Z3 = p2._relPos1Z;
  38797. var p3X3 = p3._relPos1X;
  38798. var p3Y3 = p3._relPos1Y;
  38799. var p3Z3 = p3._relPos1Z;
  38800. var v123;
  38801. var v12X3;
  38802. var v12Y3;
  38803. var v12Z3;
  38804. var v343;
  38805. var v34X3;
  38806. var v34Y3;
  38807. var v34Z3;
  38808. var v133;
  38809. var v13X3;
  38810. var v13Y3;
  38811. var v13Z3;
  38812. var v243;
  38813. var v24X3;
  38814. var v24Y3;
  38815. var v24Z3;
  38816. var v143;
  38817. var v14X3;
  38818. var v14Y3;
  38819. var v14Z3;
  38820. var v233;
  38821. var v23X3;
  38822. var v23Y3;
  38823. var v23Z3;
  38824. v12X3 = p2X3 - p1X3;
  38825. v12Y3 = p2Y3 - p1Y3;
  38826. v12Z3 = p2Z3 - p1Z3;
  38827. v34X3 = rp1X - p3X3;
  38828. v34Y3 = rp1Y - p3Y3;
  38829. v34Z3 = rp1Z - p3Z3;
  38830. v13X3 = p3X3 - p1X3;
  38831. v13Y3 = p3Y3 - p1Y3;
  38832. v13Z3 = p3Z3 - p1Z3;
  38833. v24X3 = rp1X - p2X3;
  38834. v24Y3 = rp1Y - p2Y3;
  38835. v24Z3 = rp1Z - p2Z3;
  38836. v14X3 = rp1X - p1X3;
  38837. v14Y3 = rp1Y - p1Y3;
  38838. v14Z3 = rp1Z - p1Z3;
  38839. v23X3 = p3X3 - p2X3;
  38840. v23Y3 = p3Y3 - p2Y3;
  38841. v23Z3 = p3Z3 - p2Z3;
  38842. var cross13;
  38843. var cross1X3;
  38844. var cross1Y3;
  38845. var cross1Z3;
  38846. var cross23;
  38847. var cross2X3;
  38848. var cross2Y3;
  38849. var cross2Z3;
  38850. var cross33;
  38851. var cross3X3;
  38852. var cross3Y3;
  38853. var cross3Z3;
  38854. cross1X3 = v12Y3 * v34Z3 - v12Z3 * v34Y3;
  38855. cross1Y3 = v12Z3 * v34X3 - v12X3 * v34Z3;
  38856. cross1Z3 = v12X3 * v34Y3 - v12Y3 * v34X3;
  38857. cross2X3 = v13Y3 * v24Z3 - v13Z3 * v24Y3;
  38858. cross2Y3 = v13Z3 * v24X3 - v13X3 * v24Z3;
  38859. cross2Z3 = v13X3 * v24Y3 - v13Y3 * v24X3;
  38860. cross3X3 = v14Y3 * v23Z3 - v14Z3 * v23Y3;
  38861. cross3Y3 = v14Z3 * v23X3 - v14X3 * v23Z3;
  38862. cross3Z3 = v14X3 * v23Y3 - v14Y3 * v23X3;
  38863. var a14 = cross1X3 * cross1X3 + cross1Y3 * cross1Y3 + cross1Z3 * cross1Z3;
  38864. var a24 = cross2X3 * cross2X3 + cross2Y3 * cross2Y3 + cross2Z3 * cross2Z3;
  38865. var a34 = cross3X3 * cross3X3 + cross3Y3 * cross3Y3 + cross3Z3 * cross3Z3;
  38866. var a4 = a14 > a24 ? a14 > a34 ? a14 : a34 : a24 > a34 ? a24 : a34;
  38867. var max = a11;
  38868. var target = 0;
  38869. if(a22 > max && maxDepthIndex != 1 || maxDepthIndex == 0) {
  38870. max = a22;
  38871. target = 1;
  38872. }
  38873. if(a33 > max && maxDepthIndex != 2) {
  38874. max = a33;
  38875. target = 2;
  38876. }
  38877. if(a4 > max && maxDepthIndex != 3) {
  38878. max = a4;
  38879. target = 3;
  38880. }
  38881. return target;
  38882. }
  38883. computeRelativePositions(tf1,tf2) {
  38884. var num = this._manifold._numPoints;
  38885. var _g = 0;
  38886. var _g1 = num;
  38887. while(_g < _g1) {
  38888. var i = _g++;
  38889. var p = this._manifold._points[i];
  38890. var __tmp__X;
  38891. var __tmp__Y;
  38892. var __tmp__Z;
  38893. __tmp__X = tf1._rotation00 * p._localPos1X + tf1._rotation01 * p._localPos1Y + tf1._rotation02 * p._localPos1Z;
  38894. __tmp__Y = tf1._rotation10 * p._localPos1X + tf1._rotation11 * p._localPos1Y + tf1._rotation12 * p._localPos1Z;
  38895. __tmp__Z = tf1._rotation20 * p._localPos1X + tf1._rotation21 * p._localPos1Y + tf1._rotation22 * p._localPos1Z;
  38896. p._relPos1X = __tmp__X;
  38897. p._relPos1Y = __tmp__Y;
  38898. p._relPos1Z = __tmp__Z;
  38899. var __tmp__X1;
  38900. var __tmp__Y1;
  38901. var __tmp__Z1;
  38902. __tmp__X1 = tf2._rotation00 * p._localPos2X + tf2._rotation01 * p._localPos2Y + tf2._rotation02 * p._localPos2Z;
  38903. __tmp__Y1 = tf2._rotation10 * p._localPos2X + tf2._rotation11 * p._localPos2Y + tf2._rotation12 * p._localPos2Z;
  38904. __tmp__Z1 = tf2._rotation20 * p._localPos2X + tf2._rotation21 * p._localPos2Y + tf2._rotation22 * p._localPos2Z;
  38905. p._relPos2X = __tmp__X1;
  38906. p._relPos2Y = __tmp__Y1;
  38907. p._relPos2Z = __tmp__Z1;
  38908. p._warmStarted = true;
  38909. }
  38910. }
  38911. findNearestContactPointIndex(target,tf1,tf2) {
  38912. var nearestSq = oimo.common.Setting.contactPersistenceThreshold * oimo.common.Setting.contactPersistenceThreshold;
  38913. var idx = -1;
  38914. var _g = 0;
  38915. var _g1 = this._manifold._numPoints;
  38916. while(_g < _g1) {
  38917. var i = _g++;
  38918. var mp = this._manifold._points[i];
  38919. var rp1;
  38920. var rp1X;
  38921. var rp1Y;
  38922. var rp1Z;
  38923. var rp2;
  38924. var rp2X;
  38925. var rp2Y;
  38926. var rp2Z;
  38927. var v = target.position1;
  38928. rp1X = v.x;
  38929. rp1Y = v.y;
  38930. rp1Z = v.z;
  38931. var v1 = target.position2;
  38932. rp2X = v1.x;
  38933. rp2Y = v1.y;
  38934. rp2Z = v1.z;
  38935. rp1X -= tf1._positionX;
  38936. rp1Y -= tf1._positionY;
  38937. rp1Z -= tf1._positionZ;
  38938. rp2X -= tf2._positionX;
  38939. rp2Y -= tf2._positionY;
  38940. rp2Z -= tf2._positionZ;
  38941. var diff1;
  38942. var diff1X;
  38943. var diff1Y;
  38944. var diff1Z;
  38945. var diff2;
  38946. var diff2X;
  38947. var diff2Y;
  38948. var diff2Z;
  38949. diff1X = mp._relPos1X - rp1X;
  38950. diff1Y = mp._relPos1Y - rp1Y;
  38951. diff1Z = mp._relPos1Z - rp1Z;
  38952. diff2X = mp._relPos2X - rp2X;
  38953. diff2Y = mp._relPos2Y - rp2Y;
  38954. diff2Z = mp._relPos2Z - rp2Z;
  38955. var sq1 = diff1X * diff1X + diff1Y * diff1Y + diff1Z * diff1Z;
  38956. var sq2 = diff2X * diff2X + diff2Y * diff2Y + diff2Z * diff2Z;
  38957. var d = sq1 < sq2 ? sq1 : sq2;
  38958. if(d < nearestSq) {
  38959. nearestSq = d;
  38960. idx = i;
  38961. }
  38962. }
  38963. return idx;
  38964. }
  38965. totalUpdate(result,tf1,tf2) {
  38966. this.numOldPoints = this._manifold._numPoints;
  38967. var _g = 0;
  38968. var _g1 = this.numOldPoints;
  38969. while(_g < _g1) {
  38970. var i = _g++;
  38971. var _this = this.oldPoints[i];
  38972. var cp = this._manifold._points[i];
  38973. _this._localPos1X = cp._localPos1X;
  38974. _this._localPos1Y = cp._localPos1Y;
  38975. _this._localPos1Z = cp._localPos1Z;
  38976. _this._localPos2X = cp._localPos2X;
  38977. _this._localPos2Y = cp._localPos2Y;
  38978. _this._localPos2Z = cp._localPos2Z;
  38979. _this._relPos1X = cp._relPos1X;
  38980. _this._relPos1Y = cp._relPos1Y;
  38981. _this._relPos1Z = cp._relPos1Z;
  38982. _this._relPos2X = cp._relPos2X;
  38983. _this._relPos2Y = cp._relPos2Y;
  38984. _this._relPos2Z = cp._relPos2Z;
  38985. _this._pos1X = cp._pos1X;
  38986. _this._pos1Y = cp._pos1Y;
  38987. _this._pos1Z = cp._pos1Z;
  38988. _this._pos2X = cp._pos2X;
  38989. _this._pos2Y = cp._pos2Y;
  38990. _this._pos2Z = cp._pos2Z;
  38991. _this._depth = cp._depth;
  38992. _this._impulse.copyFrom(cp._impulse);
  38993. _this._id = cp._id;
  38994. _this._warmStarted = cp._warmStarted;
  38995. _this._disabled = false;
  38996. }
  38997. var num = result.numPoints;
  38998. this._manifold._numPoints = num;
  38999. var _g2 = 0;
  39000. var _g11 = num;
  39001. while(_g2 < _g11) {
  39002. var i1 = _g2++;
  39003. var p = this._manifold._points[i1];
  39004. var ref = result.points[i1];
  39005. var v = ref.position1;
  39006. p._pos1X = v.x;
  39007. p._pos1Y = v.y;
  39008. p._pos1Z = v.z;
  39009. var v1 = ref.position2;
  39010. p._pos2X = v1.x;
  39011. p._pos2Y = v1.y;
  39012. p._pos2Z = v1.z;
  39013. p._relPos1X = p._pos1X - tf1._positionX;
  39014. p._relPos1Y = p._pos1Y - tf1._positionY;
  39015. p._relPos1Z = p._pos1Z - tf1._positionZ;
  39016. p._relPos2X = p._pos2X - tf2._positionX;
  39017. p._relPos2Y = p._pos2Y - tf2._positionY;
  39018. p._relPos2Z = p._pos2Z - tf2._positionZ;
  39019. var __tmp__X;
  39020. var __tmp__Y;
  39021. var __tmp__Z;
  39022. __tmp__X = tf1._rotation00 * p._relPos1X + tf1._rotation10 * p._relPos1Y + tf1._rotation20 * p._relPos1Z;
  39023. __tmp__Y = tf1._rotation01 * p._relPos1X + tf1._rotation11 * p._relPos1Y + tf1._rotation21 * p._relPos1Z;
  39024. __tmp__Z = tf1._rotation02 * p._relPos1X + tf1._rotation12 * p._relPos1Y + tf1._rotation22 * p._relPos1Z;
  39025. p._localPos1X = __tmp__X;
  39026. p._localPos1Y = __tmp__Y;
  39027. p._localPos1Z = __tmp__Z;
  39028. var __tmp__X1;
  39029. var __tmp__Y1;
  39030. var __tmp__Z1;
  39031. __tmp__X1 = tf2._rotation00 * p._relPos2X + tf2._rotation10 * p._relPos2Y + tf2._rotation20 * p._relPos2Z;
  39032. __tmp__Y1 = tf2._rotation01 * p._relPos2X + tf2._rotation11 * p._relPos2Y + tf2._rotation21 * p._relPos2Z;
  39033. __tmp__Z1 = tf2._rotation02 * p._relPos2X + tf2._rotation12 * p._relPos2Y + tf2._rotation22 * p._relPos2Z;
  39034. p._localPos2X = __tmp__X1;
  39035. p._localPos2Y = __tmp__Y1;
  39036. p._localPos2Z = __tmp__Z1;
  39037. p._depth = ref.depth;
  39038. var _this1 = p._impulse;
  39039. _this1.impulseN = 0;
  39040. _this1.impulseT = 0;
  39041. _this1.impulseB = 0;
  39042. _this1.impulseP = 0;
  39043. _this1.impulseLX = 0;
  39044. _this1.impulseLY = 0;
  39045. _this1.impulseLZ = 0;
  39046. p._id = ref.id;
  39047. p._warmStarted = false;
  39048. p._disabled = false;
  39049. var _g3 = 0;
  39050. var _g12 = this.numOldPoints;
  39051. while(_g3 < _g12) {
  39052. var i2 = _g3++;
  39053. var ocp = this.oldPoints[i2];
  39054. if(p._id == ocp._id) {
  39055. p._impulse.copyFrom(ocp._impulse);
  39056. p._warmStarted = true;
  39057. break;
  39058. }
  39059. }
  39060. }
  39061. }
  39062. incrementalUpdate(result,tf1,tf2) {
  39063. this._manifold._updateDepthsAndPositions(tf1,tf2);
  39064. var _g = 0;
  39065. var _g1 = this._manifold._numPoints;
  39066. while(_g < _g1) {
  39067. var i = _g++;
  39068. this._manifold._points[i]._warmStarted = true;
  39069. }
  39070. var newPoint = result.points[0];
  39071. var index = this.findNearestContactPointIndex(newPoint,tf1,tf2);
  39072. if(index == -1) {
  39073. this.addManifoldPoint(newPoint,tf1,tf2);
  39074. } else {
  39075. var cp = this._manifold._points[index];
  39076. var v = newPoint.position1;
  39077. cp._pos1X = v.x;
  39078. cp._pos1Y = v.y;
  39079. cp._pos1Z = v.z;
  39080. var v1 = newPoint.position2;
  39081. cp._pos2X = v1.x;
  39082. cp._pos2Y = v1.y;
  39083. cp._pos2Z = v1.z;
  39084. cp._relPos1X = cp._pos1X - tf1._positionX;
  39085. cp._relPos1Y = cp._pos1Y - tf1._positionY;
  39086. cp._relPos1Z = cp._pos1Z - tf1._positionZ;
  39087. cp._relPos2X = cp._pos2X - tf2._positionX;
  39088. cp._relPos2Y = cp._pos2Y - tf2._positionY;
  39089. cp._relPos2Z = cp._pos2Z - tf2._positionZ;
  39090. var __tmp__X;
  39091. var __tmp__Y;
  39092. var __tmp__Z;
  39093. __tmp__X = tf1._rotation00 * cp._relPos1X + tf1._rotation10 * cp._relPos1Y + tf1._rotation20 * cp._relPos1Z;
  39094. __tmp__Y = tf1._rotation01 * cp._relPos1X + tf1._rotation11 * cp._relPos1Y + tf1._rotation21 * cp._relPos1Z;
  39095. __tmp__Z = tf1._rotation02 * cp._relPos1X + tf1._rotation12 * cp._relPos1Y + tf1._rotation22 * cp._relPos1Z;
  39096. cp._localPos1X = __tmp__X;
  39097. cp._localPos1Y = __tmp__Y;
  39098. cp._localPos1Z = __tmp__Z;
  39099. var __tmp__X1;
  39100. var __tmp__Y1;
  39101. var __tmp__Z1;
  39102. __tmp__X1 = tf2._rotation00 * cp._relPos2X + tf2._rotation10 * cp._relPos2Y + tf2._rotation20 * cp._relPos2Z;
  39103. __tmp__Y1 = tf2._rotation01 * cp._relPos2X + tf2._rotation11 * cp._relPos2Y + tf2._rotation21 * cp._relPos2Z;
  39104. __tmp__Z1 = tf2._rotation02 * cp._relPos2X + tf2._rotation12 * cp._relPos2Y + tf2._rotation22 * cp._relPos2Z;
  39105. cp._localPos2X = __tmp__X1;
  39106. cp._localPos2Y = __tmp__Y1;
  39107. cp._localPos2Z = __tmp__Z1;
  39108. cp._depth = newPoint.depth;
  39109. }
  39110. this.removeOutdatedPoints();
  39111. }
  39112. }
  39113. if(!oimo.dynamics.constraint.info) oimo.dynamics.constraint.info = {};
  39114. oimo.dynamics.constraint.info.JacobianRow = class oimo_dynamics_constraint_info_JacobianRow {
  39115. constructor() {
  39116. this.lin1X = 0;
  39117. this.lin1Y = 0;
  39118. this.lin1Z = 0;
  39119. this.lin2X = 0;
  39120. this.lin2Y = 0;
  39121. this.lin2Z = 0;
  39122. this.ang1X = 0;
  39123. this.ang1Y = 0;
  39124. this.ang1Z = 0;
  39125. this.ang2X = 0;
  39126. this.ang2Y = 0;
  39127. this.ang2Z = 0;
  39128. this.flag = 0;
  39129. }
  39130. updateSparsity() {
  39131. this.flag = 0;
  39132. if(!(this.lin1X == 0 && this.lin1Y == 0 && this.lin1Z == 0) || !(this.lin2X == 0 && this.lin2Y == 0 && this.lin2Z == 0)) {
  39133. this.flag |= 1;
  39134. }
  39135. if(!(this.ang1X == 0 && this.ang1Y == 0 && this.ang1Z == 0) || !(this.ang2X == 0 && this.ang2Y == 0 && this.ang2Z == 0)) {
  39136. this.flag |= 2;
  39137. }
  39138. }
  39139. }
  39140. if(!oimo.dynamics.constraint.info.contact) oimo.dynamics.constraint.info.contact = {};
  39141. oimo.dynamics.constraint.info.contact.ContactSolverInfo = class oimo_dynamics_constraint_info_contact_ContactSolverInfo {
  39142. constructor() {
  39143. this.b1 = null;
  39144. this.b2 = null;
  39145. this.numRows = 0;
  39146. var this1 = new Array(oimo.common.Setting.maxManifoldPoints);
  39147. this.rows = this1;
  39148. var _g = 0;
  39149. var _g1 = this.rows.length;
  39150. while(_g < _g1) {
  39151. var i = _g++;
  39152. this.rows[i] = new oimo.dynamics.constraint.info.contact.ContactSolverInfoRow();
  39153. }
  39154. }
  39155. }
  39156. oimo.dynamics.constraint.info.contact.ContactSolverInfoRow = class oimo_dynamics_constraint_info_contact_ContactSolverInfoRow {
  39157. constructor() {
  39158. this.jacobianN = new oimo.dynamics.constraint.info.JacobianRow();
  39159. this.jacobianT = new oimo.dynamics.constraint.info.JacobianRow();
  39160. this.jacobianB = new oimo.dynamics.constraint.info.JacobianRow();
  39161. this.rhs = 0;
  39162. this.cfm = 0;
  39163. this.friction = 0;
  39164. this.impulse = null;
  39165. }
  39166. }
  39167. if(!oimo.dynamics.constraint.info.joint) oimo.dynamics.constraint.info.joint = {};
  39168. oimo.dynamics.constraint.info.joint.JointSolverInfo = class oimo_dynamics_constraint_info_joint_JointSolverInfo {
  39169. constructor() {
  39170. this.b1 = null;
  39171. this.b2 = null;
  39172. this.numRows = 0;
  39173. var this1 = new Array(oimo.common.Setting.maxJacobianRows);
  39174. this.rows = this1;
  39175. var _g = 0;
  39176. var _g1 = this.rows.length;
  39177. while(_g < _g1) {
  39178. var i = _g++;
  39179. this.rows[i] = new oimo.dynamics.constraint.info.joint.JointSolverInfoRow();
  39180. }
  39181. }
  39182. }
  39183. oimo.dynamics.constraint.info.joint.JointSolverInfoRow = class oimo_dynamics_constraint_info_joint_JointSolverInfoRow {
  39184. constructor() {
  39185. this.jacobian = new oimo.dynamics.constraint.info.JacobianRow();
  39186. this.rhs = 0;
  39187. this.cfm = 0;
  39188. this.minImpulse = 0;
  39189. this.maxImpulse = 0;
  39190. this.motorSpeed = 0;
  39191. this.motorMaxImpulse = 0;
  39192. this.impulse = null;
  39193. }
  39194. }
  39195. if(!oimo.dynamics.constraint.joint) oimo.dynamics.constraint.joint = {};
  39196. oimo.dynamics.constraint.joint.BasisTracker = class oimo_dynamics_constraint_joint_BasisTracker {
  39197. constructor(joint) {
  39198. this.joint = joint;
  39199. this.xX = 0;
  39200. this.xY = 0;
  39201. this.xZ = 0;
  39202. this.yX = 0;
  39203. this.yY = 0;
  39204. this.yZ = 0;
  39205. this.zX = 0;
  39206. this.zY = 0;
  39207. this.zZ = 0;
  39208. }
  39209. }
  39210. oimo.dynamics.constraint.joint.Joint = class oimo_dynamics_constraint_joint_Joint {
  39211. constructor(config,type) {
  39212. this._link1 = new oimo.dynamics.constraint.joint.JointLink(this);
  39213. this._link2 = new oimo.dynamics.constraint.joint.JointLink(this);
  39214. this._positionCorrectionAlgorithm = oimo.common.Setting.defaultJointPositionCorrectionAlgorithm;
  39215. this._type = type;
  39216. this._world = null;
  39217. this._b1 = config.rigidBody1;
  39218. this._b2 = config.rigidBody2;
  39219. this._allowCollision = config.allowCollision;
  39220. this._breakForce = config.breakForce;
  39221. this._breakTorque = config.breakTorque;
  39222. switch(config.solverType) {
  39223. case 0:
  39224. this._solver = new oimo.dynamics.constraint.solver.pgs.PgsJointConstraintSolver(this);
  39225. break;
  39226. case 1:
  39227. this._solver = new oimo.dynamics.constraint.solver.direct.DirectJointConstraintSolver(this);
  39228. break;
  39229. }
  39230. var v = config.localAnchor1;
  39231. this._localAnchor1X = v.x;
  39232. this._localAnchor1Y = v.y;
  39233. this._localAnchor1Z = v.z;
  39234. var v1 = config.localAnchor2;
  39235. this._localAnchor2X = v1.x;
  39236. this._localAnchor2Y = v1.y;
  39237. this._localAnchor2Z = v1.z;
  39238. this._relativeAnchor1X = 0;
  39239. this._relativeAnchor1Y = 0;
  39240. this._relativeAnchor1Z = 0;
  39241. this._relativeAnchor2X = 0;
  39242. this._relativeAnchor2Y = 0;
  39243. this._relativeAnchor2Z = 0;
  39244. this._anchor1X = 0;
  39245. this._anchor1Y = 0;
  39246. this._anchor1Z = 0;
  39247. this._anchor2X = 0;
  39248. this._anchor2Y = 0;
  39249. this._anchor2Z = 0;
  39250. this._localBasisX1X = 0;
  39251. this._localBasisX1Y = 0;
  39252. this._localBasisX1Z = 0;
  39253. this._localBasisY1X = 0;
  39254. this._localBasisY1Y = 0;
  39255. this._localBasisY1Z = 0;
  39256. this._localBasisZ1X = 0;
  39257. this._localBasisZ1Y = 0;
  39258. this._localBasisZ1Z = 0;
  39259. this._localBasisX2X = 0;
  39260. this._localBasisX2Y = 0;
  39261. this._localBasisX2Z = 0;
  39262. this._localBasisY2X = 0;
  39263. this._localBasisY2Y = 0;
  39264. this._localBasisY2Z = 0;
  39265. this._localBasisZ2X = 0;
  39266. this._localBasisZ2Y = 0;
  39267. this._localBasisZ2Z = 0;
  39268. var this1 = new Array(oimo.common.Setting.maxJacobianRows);
  39269. this._impulses = this1;
  39270. var _g1 = 0;
  39271. var _g2 = oimo.common.Setting.maxJacobianRows;
  39272. while(_g1 < _g2) {
  39273. var i = _g1++;
  39274. this._impulses[i] = new oimo.dynamics.constraint.joint.JointImpulse();
  39275. }
  39276. }
  39277. buildLocalBasesFromX() {
  39278. if(this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) {
  39279. this._localBasisX1X = 1;
  39280. this._localBasisX1Y = 0;
  39281. this._localBasisX1Z = 0;
  39282. } else {
  39283. var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z;
  39284. if(l > 0) {
  39285. l = 1 / Math.sqrt(l);
  39286. }
  39287. this._localBasisX1X *= l;
  39288. this._localBasisX1Y *= l;
  39289. this._localBasisX1Z *= l;
  39290. }
  39291. if(this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z == 0) {
  39292. this._localBasisX2X = 1;
  39293. this._localBasisX2Y = 0;
  39294. this._localBasisX2Z = 0;
  39295. } else {
  39296. var l1 = this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z;
  39297. if(l1 > 0) {
  39298. l1 = 1 / Math.sqrt(l1);
  39299. }
  39300. this._localBasisX2X *= l1;
  39301. this._localBasisX2Y *= l1;
  39302. this._localBasisX2Z *= l1;
  39303. }
  39304. var slerpQ;
  39305. var slerpQX;
  39306. var slerpQY;
  39307. var slerpQZ;
  39308. var slerpQW;
  39309. var slerpM;
  39310. var slerpM00;
  39311. var slerpM01;
  39312. var slerpM02;
  39313. var slerpM10;
  39314. var slerpM11;
  39315. var slerpM12;
  39316. var slerpM20;
  39317. var slerpM21;
  39318. var slerpM22;
  39319. var d = this._localBasisX1X * this._localBasisX2X + this._localBasisX1Y * this._localBasisX2Y + this._localBasisX1Z * this._localBasisX2Z;
  39320. if(d < -0.999999999) {
  39321. var vX;
  39322. var vY;
  39323. var vZ;
  39324. var x1 = this._localBasisX1X;
  39325. var y1 = this._localBasisX1Y;
  39326. var z1 = this._localBasisX1Z;
  39327. var x2 = x1 * x1;
  39328. var y2 = y1 * y1;
  39329. var z2 = z1 * z1;
  39330. var d1;
  39331. if(x2 < y2) {
  39332. if(x2 < z2) {
  39333. d1 = 1 / Math.sqrt(y2 + z2);
  39334. vX = 0;
  39335. vY = z1 * d1;
  39336. vZ = -y1 * d1;
  39337. } else {
  39338. d1 = 1 / Math.sqrt(x2 + y2);
  39339. vX = y1 * d1;
  39340. vY = -x1 * d1;
  39341. vZ = 0;
  39342. }
  39343. } else if(y2 < z2) {
  39344. d1 = 1 / Math.sqrt(z2 + x2);
  39345. vX = -z1 * d1;
  39346. vY = 0;
  39347. vZ = x1 * d1;
  39348. } else {
  39349. d1 = 1 / Math.sqrt(x2 + y2);
  39350. vX = y1 * d1;
  39351. vY = -x1 * d1;
  39352. vZ = 0;
  39353. }
  39354. slerpQX = vX;
  39355. slerpQY = vY;
  39356. slerpQZ = vZ;
  39357. slerpQW = 0;
  39358. } else {
  39359. var cX;
  39360. var cY;
  39361. var cZ;
  39362. cX = this._localBasisX1Y * this._localBasisX2Z - this._localBasisX1Z * this._localBasisX2Y;
  39363. cY = this._localBasisX1Z * this._localBasisX2X - this._localBasisX1X * this._localBasisX2Z;
  39364. cZ = this._localBasisX1X * this._localBasisX2Y - this._localBasisX1Y * this._localBasisX2X;
  39365. var w = Math.sqrt((1 + d) * 0.5);
  39366. d = 0.5 / w;
  39367. cX *= d;
  39368. cY *= d;
  39369. cZ *= d;
  39370. slerpQX = cX;
  39371. slerpQY = cY;
  39372. slerpQZ = cZ;
  39373. slerpQW = w;
  39374. }
  39375. var x = slerpQX;
  39376. var y = slerpQY;
  39377. var z = slerpQZ;
  39378. var w1 = slerpQW;
  39379. var x21 = 2 * x;
  39380. var y21 = 2 * y;
  39381. var z21 = 2 * z;
  39382. var xx = x * x21;
  39383. var yy = y * y21;
  39384. var zz = z * z21;
  39385. var xy = x * y21;
  39386. var yz = y * z21;
  39387. var xz = x * z21;
  39388. var wx = w1 * x21;
  39389. var wy = w1 * y21;
  39390. var wz = w1 * z21;
  39391. slerpM00 = 1 - yy - zz;
  39392. slerpM01 = xy - wz;
  39393. slerpM02 = xz + wy;
  39394. slerpM10 = xy + wz;
  39395. slerpM11 = 1 - xx - zz;
  39396. slerpM12 = yz - wx;
  39397. slerpM20 = xz - wy;
  39398. slerpM21 = yz + wx;
  39399. slerpM22 = 1 - xx - yy;
  39400. var x11 = this._localBasisX1X;
  39401. var y11 = this._localBasisX1Y;
  39402. var z11 = this._localBasisX1Z;
  39403. var x22 = x11 * x11;
  39404. var y22 = y11 * y11;
  39405. var z22 = z11 * z11;
  39406. var d2;
  39407. if(x22 < y22) {
  39408. if(x22 < z22) {
  39409. d2 = 1 / Math.sqrt(y22 + z22);
  39410. this._localBasisY1X = 0;
  39411. this._localBasisY1Y = z11 * d2;
  39412. this._localBasisY1Z = -y11 * d2;
  39413. } else {
  39414. d2 = 1 / Math.sqrt(x22 + y22);
  39415. this._localBasisY1X = y11 * d2;
  39416. this._localBasisY1Y = -x11 * d2;
  39417. this._localBasisY1Z = 0;
  39418. }
  39419. } else if(y22 < z22) {
  39420. d2 = 1 / Math.sqrt(z22 + x22);
  39421. this._localBasisY1X = -z11 * d2;
  39422. this._localBasisY1Y = 0;
  39423. this._localBasisY1Z = x11 * d2;
  39424. } else {
  39425. d2 = 1 / Math.sqrt(x22 + y22);
  39426. this._localBasisY1X = y11 * d2;
  39427. this._localBasisY1Y = -x11 * d2;
  39428. this._localBasisY1Z = 0;
  39429. }
  39430. this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y;
  39431. this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z;
  39432. this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X;
  39433. var __tmp__X;
  39434. var __tmp__Y;
  39435. var __tmp__Z;
  39436. __tmp__X = slerpM00 * this._localBasisX1X + slerpM01 * this._localBasisX1Y + slerpM02 * this._localBasisX1Z;
  39437. __tmp__Y = slerpM10 * this._localBasisX1X + slerpM11 * this._localBasisX1Y + slerpM12 * this._localBasisX1Z;
  39438. __tmp__Z = slerpM20 * this._localBasisX1X + slerpM21 * this._localBasisX1Y + slerpM22 * this._localBasisX1Z;
  39439. this._localBasisX2X = __tmp__X;
  39440. this._localBasisX2Y = __tmp__Y;
  39441. this._localBasisX2Z = __tmp__Z;
  39442. var __tmp__X1;
  39443. var __tmp__Y1;
  39444. var __tmp__Z1;
  39445. __tmp__X1 = slerpM00 * this._localBasisY1X + slerpM01 * this._localBasisY1Y + slerpM02 * this._localBasisY1Z;
  39446. __tmp__Y1 = slerpM10 * this._localBasisY1X + slerpM11 * this._localBasisY1Y + slerpM12 * this._localBasisY1Z;
  39447. __tmp__Z1 = slerpM20 * this._localBasisY1X + slerpM21 * this._localBasisY1Y + slerpM22 * this._localBasisY1Z;
  39448. this._localBasisY2X = __tmp__X1;
  39449. this._localBasisY2Y = __tmp__Y1;
  39450. this._localBasisY2Z = __tmp__Z1;
  39451. var __tmp__X2;
  39452. var __tmp__Y2;
  39453. var __tmp__Z2;
  39454. __tmp__X2 = slerpM00 * this._localBasisZ1X + slerpM01 * this._localBasisZ1Y + slerpM02 * this._localBasisZ1Z;
  39455. __tmp__Y2 = slerpM10 * this._localBasisZ1X + slerpM11 * this._localBasisZ1Y + slerpM12 * this._localBasisZ1Z;
  39456. __tmp__Z2 = slerpM20 * this._localBasisZ1X + slerpM21 * this._localBasisZ1Y + slerpM22 * this._localBasisZ1Z;
  39457. this._localBasisZ2X = __tmp__X2;
  39458. this._localBasisZ2Y = __tmp__Y2;
  39459. this._localBasisZ2Z = __tmp__Z2;
  39460. }
  39461. buildLocalBasesFromXY() {
  39462. if(this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) {
  39463. this._localBasisX1X = 1;
  39464. this._localBasisX1Y = 0;
  39465. this._localBasisX1Z = 0;
  39466. } else {
  39467. var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z;
  39468. if(l > 0) {
  39469. l = 1 / Math.sqrt(l);
  39470. }
  39471. this._localBasisX1X *= l;
  39472. this._localBasisX1Y *= l;
  39473. this._localBasisX1Z *= l;
  39474. }
  39475. if(this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z == 0) {
  39476. this._localBasisX2X = 1;
  39477. this._localBasisX2Y = 0;
  39478. this._localBasisX2Z = 0;
  39479. } else {
  39480. var l1 = this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z;
  39481. if(l1 > 0) {
  39482. l1 = 1 / Math.sqrt(l1);
  39483. }
  39484. this._localBasisX2X *= l1;
  39485. this._localBasisX2Y *= l1;
  39486. this._localBasisX2Z *= l1;
  39487. }
  39488. this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y;
  39489. this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z;
  39490. this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X;
  39491. this._localBasisZ2X = this._localBasisX2Y * this._localBasisY2Z - this._localBasisX2Z * this._localBasisY2Y;
  39492. this._localBasisZ2Y = this._localBasisX2Z * this._localBasisY2X - this._localBasisX2X * this._localBasisY2Z;
  39493. this._localBasisZ2Z = this._localBasisX2X * this._localBasisY2Y - this._localBasisX2Y * this._localBasisY2X;
  39494. if(this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z == 0) {
  39495. var x1 = this._localBasisX1X;
  39496. var y1 = this._localBasisX1Y;
  39497. var z1 = this._localBasisX1Z;
  39498. var x2 = x1 * x1;
  39499. var y2 = y1 * y1;
  39500. var z2 = z1 * z1;
  39501. var d;
  39502. if(x2 < y2) {
  39503. if(x2 < z2) {
  39504. d = 1 / Math.sqrt(y2 + z2);
  39505. this._localBasisY1X = 0;
  39506. this._localBasisY1Y = z1 * d;
  39507. this._localBasisY1Z = -y1 * d;
  39508. } else {
  39509. d = 1 / Math.sqrt(x2 + y2);
  39510. this._localBasisY1X = y1 * d;
  39511. this._localBasisY1Y = -x1 * d;
  39512. this._localBasisY1Z = 0;
  39513. }
  39514. } else if(y2 < z2) {
  39515. d = 1 / Math.sqrt(z2 + x2);
  39516. this._localBasisY1X = -z1 * d;
  39517. this._localBasisY1Y = 0;
  39518. this._localBasisY1Z = x1 * d;
  39519. } else {
  39520. d = 1 / Math.sqrt(x2 + y2);
  39521. this._localBasisY1X = y1 * d;
  39522. this._localBasisY1Y = -x1 * d;
  39523. this._localBasisY1Z = 0;
  39524. }
  39525. this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y;
  39526. this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z;
  39527. this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X;
  39528. } else {
  39529. var l2 = this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z;
  39530. if(l2 > 0) {
  39531. l2 = 1 / Math.sqrt(l2);
  39532. }
  39533. this._localBasisZ1X *= l2;
  39534. this._localBasisZ1Y *= l2;
  39535. this._localBasisZ1Z *= l2;
  39536. this._localBasisY1X = this._localBasisZ1Y * this._localBasisX1Z - this._localBasisZ1Z * this._localBasisX1Y;
  39537. this._localBasisY1Y = this._localBasisZ1Z * this._localBasisX1X - this._localBasisZ1X * this._localBasisX1Z;
  39538. this._localBasisY1Z = this._localBasisZ1X * this._localBasisX1Y - this._localBasisZ1Y * this._localBasisX1X;
  39539. }
  39540. if(this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z == 0) {
  39541. var x11 = this._localBasisX2X;
  39542. var y11 = this._localBasisX2Y;
  39543. var z11 = this._localBasisX2Z;
  39544. var x21 = x11 * x11;
  39545. var y21 = y11 * y11;
  39546. var z21 = z11 * z11;
  39547. var d1;
  39548. if(x21 < y21) {
  39549. if(x21 < z21) {
  39550. d1 = 1 / Math.sqrt(y21 + z21);
  39551. this._localBasisY2X = 0;
  39552. this._localBasisY2Y = z11 * d1;
  39553. this._localBasisY2Z = -y11 * d1;
  39554. } else {
  39555. d1 = 1 / Math.sqrt(x21 + y21);
  39556. this._localBasisY2X = y11 * d1;
  39557. this._localBasisY2Y = -x11 * d1;
  39558. this._localBasisY2Z = 0;
  39559. }
  39560. } else if(y21 < z21) {
  39561. d1 = 1 / Math.sqrt(z21 + x21);
  39562. this._localBasisY2X = -z11 * d1;
  39563. this._localBasisY2Y = 0;
  39564. this._localBasisY2Z = x11 * d1;
  39565. } else {
  39566. d1 = 1 / Math.sqrt(x21 + y21);
  39567. this._localBasisY2X = y11 * d1;
  39568. this._localBasisY2Y = -x11 * d1;
  39569. this._localBasisY2Z = 0;
  39570. }
  39571. this._localBasisZ2X = this._localBasisX2Y * this._localBasisY2Z - this._localBasisX2Z * this._localBasisY2Y;
  39572. this._localBasisZ2Y = this._localBasisX2Z * this._localBasisY2X - this._localBasisX2X * this._localBasisY2Z;
  39573. this._localBasisZ2Z = this._localBasisX2X * this._localBasisY2Y - this._localBasisX2Y * this._localBasisY2X;
  39574. } else {
  39575. var l3 = this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z;
  39576. if(l3 > 0) {
  39577. l3 = 1 / Math.sqrt(l3);
  39578. }
  39579. this._localBasisZ2X *= l3;
  39580. this._localBasisZ2Y *= l3;
  39581. this._localBasisZ2Z *= l3;
  39582. this._localBasisY2X = this._localBasisZ2Y * this._localBasisX2Z - this._localBasisZ2Z * this._localBasisX2Y;
  39583. this._localBasisY2Y = this._localBasisZ2Z * this._localBasisX2X - this._localBasisZ2X * this._localBasisX2Z;
  39584. this._localBasisY2Z = this._localBasisZ2X * this._localBasisX2Y - this._localBasisZ2Y * this._localBasisX2X;
  39585. }
  39586. }
  39587. buildLocalBasesFromX1Z2() {
  39588. if(this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) {
  39589. this._localBasisX1X = 1;
  39590. this._localBasisX1Y = 0;
  39591. this._localBasisX1Z = 0;
  39592. } else {
  39593. var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z;
  39594. if(l > 0) {
  39595. l = 1 / Math.sqrt(l);
  39596. }
  39597. this._localBasisX1X *= l;
  39598. this._localBasisX1Y *= l;
  39599. this._localBasisX1Z *= l;
  39600. }
  39601. if(this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z == 0) {
  39602. this._localBasisZ2X = 0;
  39603. this._localBasisZ2Y = 0;
  39604. this._localBasisZ2Z = 1;
  39605. } else {
  39606. var l1 = this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z;
  39607. if(l1 > 0) {
  39608. l1 = 1 / Math.sqrt(l1);
  39609. }
  39610. this._localBasisZ2X *= l1;
  39611. this._localBasisZ2Y *= l1;
  39612. this._localBasisZ2Z *= l1;
  39613. }
  39614. var tf1 = this._b1._transform;
  39615. var tf2 = this._b2._transform;
  39616. var worldX1;
  39617. var worldX1X;
  39618. var worldX1Y;
  39619. var worldX1Z;
  39620. var worldZ1;
  39621. var worldZ1X;
  39622. var worldZ1Y;
  39623. var worldZ1Z;
  39624. var worldY;
  39625. var worldYX;
  39626. var worldYY;
  39627. var worldYZ;
  39628. var worldX2;
  39629. var worldX2X;
  39630. var worldX2Y;
  39631. var worldX2Z;
  39632. var worldZ2;
  39633. var worldZ2X;
  39634. var worldZ2Y;
  39635. var worldZ2Z;
  39636. var __tmp__X;
  39637. var __tmp__Y;
  39638. var __tmp__Z;
  39639. __tmp__X = tf1._rotation00 * this._localBasisX1X + tf1._rotation01 * this._localBasisX1Y + tf1._rotation02 * this._localBasisX1Z;
  39640. __tmp__Y = tf1._rotation10 * this._localBasisX1X + tf1._rotation11 * this._localBasisX1Y + tf1._rotation12 * this._localBasisX1Z;
  39641. __tmp__Z = tf1._rotation20 * this._localBasisX1X + tf1._rotation21 * this._localBasisX1Y + tf1._rotation22 * this._localBasisX1Z;
  39642. worldX1X = __tmp__X;
  39643. worldX1Y = __tmp__Y;
  39644. worldX1Z = __tmp__Z;
  39645. var __tmp__X1;
  39646. var __tmp__Y1;
  39647. var __tmp__Z1;
  39648. __tmp__X1 = tf2._rotation00 * this._localBasisZ2X + tf2._rotation01 * this._localBasisZ2Y + tf2._rotation02 * this._localBasisZ2Z;
  39649. __tmp__Y1 = tf2._rotation10 * this._localBasisZ2X + tf2._rotation11 * this._localBasisZ2Y + tf2._rotation12 * this._localBasisZ2Z;
  39650. __tmp__Z1 = tf2._rotation20 * this._localBasisZ2X + tf2._rotation21 * this._localBasisZ2Y + tf2._rotation22 * this._localBasisZ2Z;
  39651. worldZ2X = __tmp__X1;
  39652. worldZ2Y = __tmp__Y1;
  39653. worldZ2Z = __tmp__Z1;
  39654. worldYX = worldZ2Y * worldX1Z - worldZ2Z * worldX1Y;
  39655. worldYY = worldZ2Z * worldX1X - worldZ2X * worldX1Z;
  39656. worldYZ = worldZ2X * worldX1Y - worldZ2Y * worldX1X;
  39657. if(worldYX * worldYX + worldYY * worldYY + worldYZ * worldYZ == 0) {
  39658. var x1 = worldX1X;
  39659. var y1 = worldX1Y;
  39660. var z1 = worldX1Z;
  39661. var x2 = x1 * x1;
  39662. var y2 = y1 * y1;
  39663. var z2 = z1 * z1;
  39664. var d;
  39665. if(x2 < y2) {
  39666. if(x2 < z2) {
  39667. d = 1 / Math.sqrt(y2 + z2);
  39668. worldYX = 0;
  39669. worldYY = z1 * d;
  39670. worldYZ = -y1 * d;
  39671. } else {
  39672. d = 1 / Math.sqrt(x2 + y2);
  39673. worldYX = y1 * d;
  39674. worldYY = -x1 * d;
  39675. worldYZ = 0;
  39676. }
  39677. } else if(y2 < z2) {
  39678. d = 1 / Math.sqrt(z2 + x2);
  39679. worldYX = -z1 * d;
  39680. worldYY = 0;
  39681. worldYZ = x1 * d;
  39682. } else {
  39683. d = 1 / Math.sqrt(x2 + y2);
  39684. worldYX = y1 * d;
  39685. worldYY = -x1 * d;
  39686. worldYZ = 0;
  39687. }
  39688. }
  39689. worldZ1X = worldX1Y * worldYZ - worldX1Z * worldYY;
  39690. worldZ1Y = worldX1Z * worldYX - worldX1X * worldYZ;
  39691. worldZ1Z = worldX1X * worldYY - worldX1Y * worldYX;
  39692. worldX2X = worldYY * worldZ2Z - worldYZ * worldZ2Y;
  39693. worldX2Y = worldYZ * worldZ2X - worldYX * worldZ2Z;
  39694. worldX2Z = worldYX * worldZ2Y - worldYY * worldZ2X;
  39695. var __tmp__X2;
  39696. var __tmp__Y2;
  39697. var __tmp__Z2;
  39698. __tmp__X2 = tf1._rotation00 * worldX1X + tf1._rotation10 * worldX1Y + tf1._rotation20 * worldX1Z;
  39699. __tmp__Y2 = tf1._rotation01 * worldX1X + tf1._rotation11 * worldX1Y + tf1._rotation21 * worldX1Z;
  39700. __tmp__Z2 = tf1._rotation02 * worldX1X + tf1._rotation12 * worldX1Y + tf1._rotation22 * worldX1Z;
  39701. this._localBasisX1X = __tmp__X2;
  39702. this._localBasisX1Y = __tmp__Y2;
  39703. this._localBasisX1Z = __tmp__Z2;
  39704. var __tmp__X3;
  39705. var __tmp__Y3;
  39706. var __tmp__Z3;
  39707. __tmp__X3 = tf1._rotation00 * worldYX + tf1._rotation10 * worldYY + tf1._rotation20 * worldYZ;
  39708. __tmp__Y3 = tf1._rotation01 * worldYX + tf1._rotation11 * worldYY + tf1._rotation21 * worldYZ;
  39709. __tmp__Z3 = tf1._rotation02 * worldYX + tf1._rotation12 * worldYY + tf1._rotation22 * worldYZ;
  39710. this._localBasisY1X = __tmp__X3;
  39711. this._localBasisY1Y = __tmp__Y3;
  39712. this._localBasisY1Z = __tmp__Z3;
  39713. var __tmp__X4;
  39714. var __tmp__Y4;
  39715. var __tmp__Z4;
  39716. __tmp__X4 = tf1._rotation00 * worldZ1X + tf1._rotation10 * worldZ1Y + tf1._rotation20 * worldZ1Z;
  39717. __tmp__Y4 = tf1._rotation01 * worldZ1X + tf1._rotation11 * worldZ1Y + tf1._rotation21 * worldZ1Z;
  39718. __tmp__Z4 = tf1._rotation02 * worldZ1X + tf1._rotation12 * worldZ1Y + tf1._rotation22 * worldZ1Z;
  39719. this._localBasisZ1X = __tmp__X4;
  39720. this._localBasisZ1Y = __tmp__Y4;
  39721. this._localBasisZ1Z = __tmp__Z4;
  39722. var __tmp__X5;
  39723. var __tmp__Y5;
  39724. var __tmp__Z5;
  39725. __tmp__X5 = tf2._rotation00 * worldX2X + tf2._rotation10 * worldX2Y + tf2._rotation20 * worldX2Z;
  39726. __tmp__Y5 = tf2._rotation01 * worldX2X + tf2._rotation11 * worldX2Y + tf2._rotation21 * worldX2Z;
  39727. __tmp__Z5 = tf2._rotation02 * worldX2X + tf2._rotation12 * worldX2Y + tf2._rotation22 * worldX2Z;
  39728. this._localBasisX2X = __tmp__X5;
  39729. this._localBasisX2Y = __tmp__Y5;
  39730. this._localBasisX2Z = __tmp__Z5;
  39731. var __tmp__X6;
  39732. var __tmp__Y6;
  39733. var __tmp__Z6;
  39734. __tmp__X6 = tf2._rotation00 * worldYX + tf2._rotation10 * worldYY + tf2._rotation20 * worldYZ;
  39735. __tmp__Y6 = tf2._rotation01 * worldYX + tf2._rotation11 * worldYY + tf2._rotation21 * worldYZ;
  39736. __tmp__Z6 = tf2._rotation02 * worldYX + tf2._rotation12 * worldYY + tf2._rotation22 * worldYZ;
  39737. this._localBasisY2X = __tmp__X6;
  39738. this._localBasisY2Y = __tmp__Y6;
  39739. this._localBasisY2Z = __tmp__Z6;
  39740. var __tmp__X7;
  39741. var __tmp__Y7;
  39742. var __tmp__Z7;
  39743. __tmp__X7 = tf2._rotation00 * worldZ2X + tf2._rotation10 * worldZ2Y + tf2._rotation20 * worldZ2Z;
  39744. __tmp__Y7 = tf2._rotation01 * worldZ2X + tf2._rotation11 * worldZ2Y + tf2._rotation21 * worldZ2Z;
  39745. __tmp__Z7 = tf2._rotation02 * worldZ2X + tf2._rotation12 * worldZ2Y + tf2._rotation22 * worldZ2Z;
  39746. this._localBasisZ2X = __tmp__X7;
  39747. this._localBasisZ2Y = __tmp__Y7;
  39748. this._localBasisZ2Z = __tmp__Z7;
  39749. }
  39750. buildLocalBasesFromXY1X2() {
  39751. if(this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) {
  39752. this._localBasisX1X = 1;
  39753. this._localBasisX1Y = 0;
  39754. this._localBasisX1Z = 0;
  39755. } else {
  39756. var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z;
  39757. if(l > 0) {
  39758. l = 1 / Math.sqrt(l);
  39759. }
  39760. this._localBasisX1X *= l;
  39761. this._localBasisX1Y *= l;
  39762. this._localBasisX1Z *= l;
  39763. }
  39764. this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y;
  39765. this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z;
  39766. this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X;
  39767. if(this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z == 0) {
  39768. var x1 = this._localBasisX1X;
  39769. var y1 = this._localBasisX1Y;
  39770. var z1 = this._localBasisX1Z;
  39771. var x2 = x1 * x1;
  39772. var y2 = y1 * y1;
  39773. var z2 = z1 * z1;
  39774. var d;
  39775. if(x2 < y2) {
  39776. if(x2 < z2) {
  39777. d = 1 / Math.sqrt(y2 + z2);
  39778. this._localBasisY1X = 0;
  39779. this._localBasisY1Y = z1 * d;
  39780. this._localBasisY1Z = -y1 * d;
  39781. } else {
  39782. d = 1 / Math.sqrt(x2 + y2);
  39783. this._localBasisY1X = y1 * d;
  39784. this._localBasisY1Y = -x1 * d;
  39785. this._localBasisY1Z = 0;
  39786. }
  39787. } else if(y2 < z2) {
  39788. d = 1 / Math.sqrt(z2 + x2);
  39789. this._localBasisY1X = -z1 * d;
  39790. this._localBasisY1Y = 0;
  39791. this._localBasisY1Z = x1 * d;
  39792. } else {
  39793. d = 1 / Math.sqrt(x2 + y2);
  39794. this._localBasisY1X = y1 * d;
  39795. this._localBasisY1Y = -x1 * d;
  39796. this._localBasisY1Z = 0;
  39797. }
  39798. this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y;
  39799. this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z;
  39800. this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X;
  39801. } else {
  39802. var l1 = this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z;
  39803. if(l1 > 0) {
  39804. l1 = 1 / Math.sqrt(l1);
  39805. }
  39806. this._localBasisZ1X *= l1;
  39807. this._localBasisZ1Y *= l1;
  39808. this._localBasisZ1Z *= l1;
  39809. this._localBasisY1X = this._localBasisZ1Y * this._localBasisX1Z - this._localBasisZ1Z * this._localBasisX1Y;
  39810. this._localBasisY1Y = this._localBasisZ1Z * this._localBasisX1X - this._localBasisZ1X * this._localBasisX1Z;
  39811. this._localBasisY1Z = this._localBasisZ1X * this._localBasisX1Y - this._localBasisZ1Y * this._localBasisX1X;
  39812. }
  39813. var slerpQ;
  39814. var slerpQX;
  39815. var slerpQY;
  39816. var slerpQZ;
  39817. var slerpQW;
  39818. var slerpM;
  39819. var slerpM00;
  39820. var slerpM01;
  39821. var slerpM02;
  39822. var slerpM10;
  39823. var slerpM11;
  39824. var slerpM12;
  39825. var slerpM20;
  39826. var slerpM21;
  39827. var slerpM22;
  39828. var d1 = this._localBasisX1X * this._localBasisX2X + this._localBasisX1Y * this._localBasisX2Y + this._localBasisX1Z * this._localBasisX2Z;
  39829. if(d1 < -0.999999999) {
  39830. var vX;
  39831. var vY;
  39832. var vZ;
  39833. var x11 = this._localBasisX1X;
  39834. var y11 = this._localBasisX1Y;
  39835. var z11 = this._localBasisX1Z;
  39836. var x21 = x11 * x11;
  39837. var y21 = y11 * y11;
  39838. var z21 = z11 * z11;
  39839. var d2;
  39840. if(x21 < y21) {
  39841. if(x21 < z21) {
  39842. d2 = 1 / Math.sqrt(y21 + z21);
  39843. vX = 0;
  39844. vY = z11 * d2;
  39845. vZ = -y11 * d2;
  39846. } else {
  39847. d2 = 1 / Math.sqrt(x21 + y21);
  39848. vX = y11 * d2;
  39849. vY = -x11 * d2;
  39850. vZ = 0;
  39851. }
  39852. } else if(y21 < z21) {
  39853. d2 = 1 / Math.sqrt(z21 + x21);
  39854. vX = -z11 * d2;
  39855. vY = 0;
  39856. vZ = x11 * d2;
  39857. } else {
  39858. d2 = 1 / Math.sqrt(x21 + y21);
  39859. vX = y11 * d2;
  39860. vY = -x11 * d2;
  39861. vZ = 0;
  39862. }
  39863. slerpQX = vX;
  39864. slerpQY = vY;
  39865. slerpQZ = vZ;
  39866. slerpQW = 0;
  39867. } else {
  39868. var cX;
  39869. var cY;
  39870. var cZ;
  39871. cX = this._localBasisX1Y * this._localBasisX2Z - this._localBasisX1Z * this._localBasisX2Y;
  39872. cY = this._localBasisX1Z * this._localBasisX2X - this._localBasisX1X * this._localBasisX2Z;
  39873. cZ = this._localBasisX1X * this._localBasisX2Y - this._localBasisX1Y * this._localBasisX2X;
  39874. var w = Math.sqrt((1 + d1) * 0.5);
  39875. d1 = 0.5 / w;
  39876. cX *= d1;
  39877. cY *= d1;
  39878. cZ *= d1;
  39879. slerpQX = cX;
  39880. slerpQY = cY;
  39881. slerpQZ = cZ;
  39882. slerpQW = w;
  39883. }
  39884. var x = slerpQX;
  39885. var y = slerpQY;
  39886. var z = slerpQZ;
  39887. var w1 = slerpQW;
  39888. var x22 = 2 * x;
  39889. var y22 = 2 * y;
  39890. var z22 = 2 * z;
  39891. var xx = x * x22;
  39892. var yy = y * y22;
  39893. var zz = z * z22;
  39894. var xy = x * y22;
  39895. var yz = y * z22;
  39896. var xz = x * z22;
  39897. var wx = w1 * x22;
  39898. var wy = w1 * y22;
  39899. var wz = w1 * z22;
  39900. slerpM00 = 1 - yy - zz;
  39901. slerpM01 = xy - wz;
  39902. slerpM02 = xz + wy;
  39903. slerpM10 = xy + wz;
  39904. slerpM11 = 1 - xx - zz;
  39905. slerpM12 = yz - wx;
  39906. slerpM20 = xz - wy;
  39907. slerpM21 = yz + wx;
  39908. slerpM22 = 1 - xx - yy;
  39909. var __tmp__X;
  39910. var __tmp__Y;
  39911. var __tmp__Z;
  39912. __tmp__X = slerpM00 * this._localBasisX1X + slerpM01 * this._localBasisX1Y + slerpM02 * this._localBasisX1Z;
  39913. __tmp__Y = slerpM10 * this._localBasisX1X + slerpM11 * this._localBasisX1Y + slerpM12 * this._localBasisX1Z;
  39914. __tmp__Z = slerpM20 * this._localBasisX1X + slerpM21 * this._localBasisX1Y + slerpM22 * this._localBasisX1Z;
  39915. this._localBasisX2X = __tmp__X;
  39916. this._localBasisX2Y = __tmp__Y;
  39917. this._localBasisX2Z = __tmp__Z;
  39918. var __tmp__X1;
  39919. var __tmp__Y1;
  39920. var __tmp__Z1;
  39921. __tmp__X1 = slerpM00 * this._localBasisY1X + slerpM01 * this._localBasisY1Y + slerpM02 * this._localBasisY1Z;
  39922. __tmp__Y1 = slerpM10 * this._localBasisY1X + slerpM11 * this._localBasisY1Y + slerpM12 * this._localBasisY1Z;
  39923. __tmp__Z1 = slerpM20 * this._localBasisY1X + slerpM21 * this._localBasisY1Y + slerpM22 * this._localBasisY1Z;
  39924. this._localBasisY2X = __tmp__X1;
  39925. this._localBasisY2Y = __tmp__Y1;
  39926. this._localBasisY2Z = __tmp__Z1;
  39927. var __tmp__X2;
  39928. var __tmp__Y2;
  39929. var __tmp__Z2;
  39930. __tmp__X2 = slerpM00 * this._localBasisZ1X + slerpM01 * this._localBasisZ1Y + slerpM02 * this._localBasisZ1Z;
  39931. __tmp__Y2 = slerpM10 * this._localBasisZ1X + slerpM11 * this._localBasisZ1Y + slerpM12 * this._localBasisZ1Z;
  39932. __tmp__Z2 = slerpM20 * this._localBasisZ1X + slerpM21 * this._localBasisZ1Y + slerpM22 * this._localBasisZ1Z;
  39933. this._localBasisZ2X = __tmp__X2;
  39934. this._localBasisZ2Y = __tmp__Y2;
  39935. this._localBasisZ2Z = __tmp__Z2;
  39936. }
  39937. setSolverInfoRowLinear(row,diff,lm,mass,sd,timeStep,isPositionPart) {
  39938. var cfmFactor;
  39939. var erp;
  39940. var slop = oimo.common.Setting.linearSlop;
  39941. if(isPositionPart) {
  39942. cfmFactor = 0;
  39943. erp = 1;
  39944. } else {
  39945. if(sd.frequency > 0) {
  39946. slop = 0;
  39947. var omega = 6.28318530717958 * sd.frequency;
  39948. var zeta = sd.dampingRatio;
  39949. if(zeta < oimo.common.Setting.minSpringDamperDampingRatio) {
  39950. zeta = oimo.common.Setting.minSpringDamperDampingRatio;
  39951. }
  39952. var h = timeStep.dt;
  39953. var c = 2 * zeta * omega;
  39954. var k = omega * omega;
  39955. if(sd.useSymplecticEuler) {
  39956. cfmFactor = 1 / (h * c);
  39957. erp = k / c;
  39958. } else {
  39959. cfmFactor = 1 / (h * (h * k + c));
  39960. erp = k / (h * k + c);
  39961. }
  39962. } else {
  39963. cfmFactor = 0;
  39964. erp = this.getErp(timeStep,false);
  39965. }
  39966. if(lm.motorForce > 0) {
  39967. row.motorSpeed = lm.motorSpeed;
  39968. row.motorMaxImpulse = lm.motorForce * timeStep.dt;
  39969. } else {
  39970. row.motorSpeed = 0;
  39971. row.motorMaxImpulse = 0;
  39972. }
  39973. }
  39974. var lower = lm.lowerLimit;
  39975. var upper = lm.upperLimit;
  39976. var minImp;
  39977. var maxImp;
  39978. var error;
  39979. if(lower > upper) {
  39980. minImp = 0;
  39981. maxImp = 0;
  39982. error = 0;
  39983. } else if(lower == upper) {
  39984. minImp = -1e65536;
  39985. maxImp = 1e65536;
  39986. error = diff - lower;
  39987. } else if(diff < lower) {
  39988. minImp = -1e65536;
  39989. maxImp = 0;
  39990. error = diff - lower + slop;
  39991. if(error > 0) {
  39992. error = 0;
  39993. }
  39994. } else if(diff > upper) {
  39995. minImp = 0;
  39996. maxImp = 1e65536;
  39997. error = diff - upper - slop;
  39998. if(error < 0) {
  39999. error = 0;
  40000. }
  40001. } else {
  40002. minImp = 0;
  40003. maxImp = 0;
  40004. error = 0;
  40005. }
  40006. var invMass = mass == 0 ? 0 : 1 / mass;
  40007. row.minImpulse = minImp;
  40008. row.maxImpulse = maxImp;
  40009. row.cfm = cfmFactor * invMass;
  40010. row.rhs = error * erp;
  40011. }
  40012. setSolverInfoRowAngular(row,diff,lm,mass,sd,timeStep,isPositionPart) {
  40013. var cfmFactor;
  40014. var erp;
  40015. var slop = oimo.common.Setting.angularSlop;
  40016. if(isPositionPart) {
  40017. cfmFactor = 0;
  40018. erp = 1;
  40019. } else {
  40020. if(sd.frequency > 0) {
  40021. slop = 0;
  40022. var omega = 6.28318530717958 * sd.frequency;
  40023. var zeta = sd.dampingRatio;
  40024. if(zeta < oimo.common.Setting.minSpringDamperDampingRatio) {
  40025. zeta = oimo.common.Setting.minSpringDamperDampingRatio;
  40026. }
  40027. var h = timeStep.dt;
  40028. var c = 2 * zeta * omega;
  40029. var k = omega * omega;
  40030. if(sd.useSymplecticEuler) {
  40031. cfmFactor = 1 / (h * c);
  40032. erp = k / c;
  40033. } else {
  40034. cfmFactor = 1 / (h * (h * k + c));
  40035. erp = k / (h * k + c);
  40036. }
  40037. } else {
  40038. cfmFactor = 0;
  40039. erp = this.getErp(timeStep,false);
  40040. }
  40041. if(lm.motorTorque > 0) {
  40042. row.motorSpeed = lm.motorSpeed;
  40043. row.motorMaxImpulse = lm.motorTorque * timeStep.dt;
  40044. } else {
  40045. row.motorSpeed = 0;
  40046. row.motorMaxImpulse = 0;
  40047. }
  40048. }
  40049. var lower = lm.lowerLimit;
  40050. var upper = lm.upperLimit;
  40051. var mid = (lower + upper) * 0.5;
  40052. diff -= mid;
  40053. diff = ((diff + 3.14159265358979) % 6.28318530717958 + 6.28318530717958) % 6.28318530717958 - 3.14159265358979;
  40054. diff += mid;
  40055. var minImp;
  40056. var maxImp;
  40057. var error;
  40058. if(lower > upper) {
  40059. minImp = 0;
  40060. maxImp = 0;
  40061. error = 0;
  40062. } else if(lower == upper) {
  40063. minImp = -1e65536;
  40064. maxImp = 1e65536;
  40065. error = diff - lower;
  40066. } else if(diff < lower) {
  40067. minImp = -1e65536;
  40068. maxImp = 0;
  40069. error = diff - lower + slop;
  40070. if(error > 0) {
  40071. error = 0;
  40072. }
  40073. } else if(diff > upper) {
  40074. minImp = 0;
  40075. maxImp = 1e65536;
  40076. error = diff - upper - slop;
  40077. if(error < 0) {
  40078. error = 0;
  40079. }
  40080. } else {
  40081. minImp = 0;
  40082. maxImp = 0;
  40083. error = 0;
  40084. }
  40085. var invMass = mass == 0 ? 0 : 1 / mass;
  40086. row.minImpulse = minImp;
  40087. row.maxImpulse = maxImp;
  40088. row.cfm = cfmFactor * invMass;
  40089. row.rhs = error * erp;
  40090. }
  40091. getErp(timeStep,isPositionPart) {
  40092. if(isPositionPart) {
  40093. return 1;
  40094. } else if(this._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE) {
  40095. return timeStep.invDt * oimo.common.Setting.velocityBaumgarte;
  40096. } else {
  40097. return 0;
  40098. }
  40099. }
  40100. computeEffectiveInertiaMoment(axisX,axisY,axisZ) {
  40101. var ia1;
  40102. var ia1X;
  40103. var ia1Y;
  40104. var ia1Z;
  40105. var ia2;
  40106. var ia2X;
  40107. var ia2Y;
  40108. var ia2Z;
  40109. var __tmp__X;
  40110. var __tmp__Y;
  40111. var __tmp__Z;
  40112. __tmp__X = this._b1._invInertia00 * axisX + this._b1._invInertia01 * axisY + this._b1._invInertia02 * axisZ;
  40113. __tmp__Y = this._b1._invInertia10 * axisX + this._b1._invInertia11 * axisY + this._b1._invInertia12 * axisZ;
  40114. __tmp__Z = this._b1._invInertia20 * axisX + this._b1._invInertia21 * axisY + this._b1._invInertia22 * axisZ;
  40115. ia1X = __tmp__X;
  40116. ia1Y = __tmp__Y;
  40117. ia1Z = __tmp__Z;
  40118. var __tmp__X1;
  40119. var __tmp__Y1;
  40120. var __tmp__Z1;
  40121. __tmp__X1 = this._b2._invInertia00 * axisX + this._b2._invInertia01 * axisY + this._b2._invInertia02 * axisZ;
  40122. __tmp__Y1 = this._b2._invInertia10 * axisX + this._b2._invInertia11 * axisY + this._b2._invInertia12 * axisZ;
  40123. __tmp__Z1 = this._b2._invInertia20 * axisX + this._b2._invInertia21 * axisY + this._b2._invInertia22 * axisZ;
  40124. ia2X = __tmp__X1;
  40125. ia2Y = __tmp__Y1;
  40126. ia2Z = __tmp__Z1;
  40127. var invI1 = ia1X * axisX + ia1Y * axisY + ia1Z * axisZ;
  40128. var invI2 = ia2X * axisX + ia2Y * axisY + ia2Z * axisZ;
  40129. if(invI1 > 0) {
  40130. var rsq = this._relativeAnchor1X * this._relativeAnchor1X + this._relativeAnchor1Y * this._relativeAnchor1Y + this._relativeAnchor1Z * this._relativeAnchor1Z;
  40131. var dot = axisX * this._relativeAnchor1X + axisY * this._relativeAnchor1Y + axisZ * this._relativeAnchor1Z;
  40132. var projsq = rsq - dot * dot;
  40133. if(projsq > 0) {
  40134. if(this._b1._invMass > 0) {
  40135. invI1 = 1 / (1 / invI1 + this._b1._mass * projsq);
  40136. } else {
  40137. invI1 = 0;
  40138. }
  40139. }
  40140. }
  40141. if(invI2 > 0) {
  40142. var rsq1 = this._relativeAnchor2X * this._relativeAnchor2X + this._relativeAnchor2Y * this._relativeAnchor2Y + this._relativeAnchor2Z * this._relativeAnchor2Z;
  40143. var dot1 = axisX * this._relativeAnchor2X + axisY * this._relativeAnchor2Y + axisZ * this._relativeAnchor2Z;
  40144. var projsq1 = rsq1 - dot1 * dot1;
  40145. if(projsq1 > 0) {
  40146. if(this._b2._invMass > 0) {
  40147. invI2 = 1 / (1 / invI2 + this._b2._mass * projsq1);
  40148. } else {
  40149. invI2 = 0;
  40150. }
  40151. }
  40152. }
  40153. if(invI1 + invI2 == 0) {
  40154. return 0;
  40155. } else {
  40156. return 1 / (invI1 + invI2);
  40157. }
  40158. }
  40159. computeEffectiveInertiaMoment2(axis1X,axis1Y,axis1Z,axis2X,axis2Y,axis2Z) {
  40160. var ia1;
  40161. var ia1X;
  40162. var ia1Y;
  40163. var ia1Z;
  40164. var ia2;
  40165. var ia2X;
  40166. var ia2Y;
  40167. var ia2Z;
  40168. var __tmp__X;
  40169. var __tmp__Y;
  40170. var __tmp__Z;
  40171. __tmp__X = this._b1._invInertia00 * axis1X + this._b1._invInertia01 * axis1Y + this._b1._invInertia02 * axis1Z;
  40172. __tmp__Y = this._b1._invInertia10 * axis1X + this._b1._invInertia11 * axis1Y + this._b1._invInertia12 * axis1Z;
  40173. __tmp__Z = this._b1._invInertia20 * axis1X + this._b1._invInertia21 * axis1Y + this._b1._invInertia22 * axis1Z;
  40174. ia1X = __tmp__X;
  40175. ia1Y = __tmp__Y;
  40176. ia1Z = __tmp__Z;
  40177. var __tmp__X1;
  40178. var __tmp__Y1;
  40179. var __tmp__Z1;
  40180. __tmp__X1 = this._b2._invInertia00 * axis2X + this._b2._invInertia01 * axis2Y + this._b2._invInertia02 * axis2Z;
  40181. __tmp__Y1 = this._b2._invInertia10 * axis2X + this._b2._invInertia11 * axis2Y + this._b2._invInertia12 * axis2Z;
  40182. __tmp__Z1 = this._b2._invInertia20 * axis2X + this._b2._invInertia21 * axis2Y + this._b2._invInertia22 * axis2Z;
  40183. ia2X = __tmp__X1;
  40184. ia2Y = __tmp__Y1;
  40185. ia2Z = __tmp__Z1;
  40186. var invI1 = ia1X * axis1X + ia1Y * axis1Y + ia1Z * axis1Z;
  40187. var invI2 = ia2X * axis2X + ia2Y * axis2Y + ia2Z * axis2Z;
  40188. if(invI1 > 0) {
  40189. var rsq = this._relativeAnchor1X * this._relativeAnchor1X + this._relativeAnchor1Y * this._relativeAnchor1Y + this._relativeAnchor1Z * this._relativeAnchor1Z;
  40190. var dot = axis1X * this._relativeAnchor1X + axis1Y * this._relativeAnchor1Y + axis1Z * this._relativeAnchor1Z;
  40191. var projsq = rsq * rsq - dot * dot;
  40192. if(projsq > 0) {
  40193. if(this._b1._invMass > 0) {
  40194. invI1 = 1 / (1 / invI1 + this._b1._mass * projsq);
  40195. } else {
  40196. invI1 = 0;
  40197. }
  40198. }
  40199. }
  40200. if(invI2 > 0) {
  40201. var rsq1 = this._relativeAnchor2X * this._relativeAnchor2X + this._relativeAnchor2Y * this._relativeAnchor2Y + this._relativeAnchor2Z * this._relativeAnchor2Z;
  40202. var dot1 = axis2X * this._relativeAnchor2X + axis2Y * this._relativeAnchor2Y + axis2Z * this._relativeAnchor2Z;
  40203. var projsq1 = rsq1 * rsq1 - dot1 * dot1;
  40204. if(projsq1 > 0) {
  40205. if(this._b2._invMass > 0) {
  40206. invI2 = 1 / (1 / invI2 + this._b2._mass * projsq1);
  40207. } else {
  40208. invI2 = 0;
  40209. }
  40210. }
  40211. }
  40212. if(invI1 + invI2 == 0) {
  40213. return 0;
  40214. } else {
  40215. return 1 / (invI1 + invI2);
  40216. }
  40217. }
  40218. _syncAnchors() {
  40219. var tf1 = this._b1._transform;
  40220. var tf2 = this._b2._transform;
  40221. var __tmp__X;
  40222. var __tmp__Y;
  40223. var __tmp__Z;
  40224. __tmp__X = tf1._rotation00 * this._localAnchor1X + tf1._rotation01 * this._localAnchor1Y + tf1._rotation02 * this._localAnchor1Z;
  40225. __tmp__Y = tf1._rotation10 * this._localAnchor1X + tf1._rotation11 * this._localAnchor1Y + tf1._rotation12 * this._localAnchor1Z;
  40226. __tmp__Z = tf1._rotation20 * this._localAnchor1X + tf1._rotation21 * this._localAnchor1Y + tf1._rotation22 * this._localAnchor1Z;
  40227. this._relativeAnchor1X = __tmp__X;
  40228. this._relativeAnchor1Y = __tmp__Y;
  40229. this._relativeAnchor1Z = __tmp__Z;
  40230. var __tmp__X1;
  40231. var __tmp__Y1;
  40232. var __tmp__Z1;
  40233. __tmp__X1 = tf2._rotation00 * this._localAnchor2X + tf2._rotation01 * this._localAnchor2Y + tf2._rotation02 * this._localAnchor2Z;
  40234. __tmp__Y1 = tf2._rotation10 * this._localAnchor2X + tf2._rotation11 * this._localAnchor2Y + tf2._rotation12 * this._localAnchor2Z;
  40235. __tmp__Z1 = tf2._rotation20 * this._localAnchor2X + tf2._rotation21 * this._localAnchor2Y + tf2._rotation22 * this._localAnchor2Z;
  40236. this._relativeAnchor2X = __tmp__X1;
  40237. this._relativeAnchor2Y = __tmp__Y1;
  40238. this._relativeAnchor2Z = __tmp__Z1;
  40239. this._anchor1X = this._relativeAnchor1X + tf1._positionX;
  40240. this._anchor1Y = this._relativeAnchor1Y + tf1._positionY;
  40241. this._anchor1Z = this._relativeAnchor1Z + tf1._positionZ;
  40242. this._anchor2X = this._relativeAnchor2X + tf2._positionX;
  40243. this._anchor2Y = this._relativeAnchor2Y + tf2._positionY;
  40244. this._anchor2Z = this._relativeAnchor2Z + tf2._positionZ;
  40245. var __tmp__X2;
  40246. var __tmp__Y2;
  40247. var __tmp__Z2;
  40248. __tmp__X2 = tf1._rotation00 * this._localBasisX1X + tf1._rotation01 * this._localBasisX1Y + tf1._rotation02 * this._localBasisX1Z;
  40249. __tmp__Y2 = tf1._rotation10 * this._localBasisX1X + tf1._rotation11 * this._localBasisX1Y + tf1._rotation12 * this._localBasisX1Z;
  40250. __tmp__Z2 = tf1._rotation20 * this._localBasisX1X + tf1._rotation21 * this._localBasisX1Y + tf1._rotation22 * this._localBasisX1Z;
  40251. this._basisX1X = __tmp__X2;
  40252. this._basisX1Y = __tmp__Y2;
  40253. this._basisX1Z = __tmp__Z2;
  40254. var __tmp__X3;
  40255. var __tmp__Y3;
  40256. var __tmp__Z3;
  40257. __tmp__X3 = tf1._rotation00 * this._localBasisY1X + tf1._rotation01 * this._localBasisY1Y + tf1._rotation02 * this._localBasisY1Z;
  40258. __tmp__Y3 = tf1._rotation10 * this._localBasisY1X + tf1._rotation11 * this._localBasisY1Y + tf1._rotation12 * this._localBasisY1Z;
  40259. __tmp__Z3 = tf1._rotation20 * this._localBasisY1X + tf1._rotation21 * this._localBasisY1Y + tf1._rotation22 * this._localBasisY1Z;
  40260. this._basisY1X = __tmp__X3;
  40261. this._basisY1Y = __tmp__Y3;
  40262. this._basisY1Z = __tmp__Z3;
  40263. var __tmp__X4;
  40264. var __tmp__Y4;
  40265. var __tmp__Z4;
  40266. __tmp__X4 = tf1._rotation00 * this._localBasisZ1X + tf1._rotation01 * this._localBasisZ1Y + tf1._rotation02 * this._localBasisZ1Z;
  40267. __tmp__Y4 = tf1._rotation10 * this._localBasisZ1X + tf1._rotation11 * this._localBasisZ1Y + tf1._rotation12 * this._localBasisZ1Z;
  40268. __tmp__Z4 = tf1._rotation20 * this._localBasisZ1X + tf1._rotation21 * this._localBasisZ1Y + tf1._rotation22 * this._localBasisZ1Z;
  40269. this._basisZ1X = __tmp__X4;
  40270. this._basisZ1Y = __tmp__Y4;
  40271. this._basisZ1Z = __tmp__Z4;
  40272. var __tmp__X5;
  40273. var __tmp__Y5;
  40274. var __tmp__Z5;
  40275. __tmp__X5 = tf2._rotation00 * this._localBasisX2X + tf2._rotation01 * this._localBasisX2Y + tf2._rotation02 * this._localBasisX2Z;
  40276. __tmp__Y5 = tf2._rotation10 * this._localBasisX2X + tf2._rotation11 * this._localBasisX2Y + tf2._rotation12 * this._localBasisX2Z;
  40277. __tmp__Z5 = tf2._rotation20 * this._localBasisX2X + tf2._rotation21 * this._localBasisX2Y + tf2._rotation22 * this._localBasisX2Z;
  40278. this._basisX2X = __tmp__X5;
  40279. this._basisX2Y = __tmp__Y5;
  40280. this._basisX2Z = __tmp__Z5;
  40281. var __tmp__X6;
  40282. var __tmp__Y6;
  40283. var __tmp__Z6;
  40284. __tmp__X6 = tf2._rotation00 * this._localBasisY2X + tf2._rotation01 * this._localBasisY2Y + tf2._rotation02 * this._localBasisY2Z;
  40285. __tmp__Y6 = tf2._rotation10 * this._localBasisY2X + tf2._rotation11 * this._localBasisY2Y + tf2._rotation12 * this._localBasisY2Z;
  40286. __tmp__Z6 = tf2._rotation20 * this._localBasisY2X + tf2._rotation21 * this._localBasisY2Y + tf2._rotation22 * this._localBasisY2Z;
  40287. this._basisY2X = __tmp__X6;
  40288. this._basisY2Y = __tmp__Y6;
  40289. this._basisY2Z = __tmp__Z6;
  40290. var __tmp__X7;
  40291. var __tmp__Y7;
  40292. var __tmp__Z7;
  40293. __tmp__X7 = tf2._rotation00 * this._localBasisZ2X + tf2._rotation01 * this._localBasisZ2Y + tf2._rotation02 * this._localBasisZ2Z;
  40294. __tmp__Y7 = tf2._rotation10 * this._localBasisZ2X + tf2._rotation11 * this._localBasisZ2Y + tf2._rotation12 * this._localBasisZ2Z;
  40295. __tmp__Z7 = tf2._rotation20 * this._localBasisZ2X + tf2._rotation21 * this._localBasisZ2Y + tf2._rotation22 * this._localBasisZ2Z;
  40296. this._basisZ2X = __tmp__X7;
  40297. this._basisZ2Y = __tmp__Y7;
  40298. this._basisZ2Z = __tmp__Z7;
  40299. }
  40300. _getVelocitySolverInfo(timeStep,info) {
  40301. info.b1 = this._b1;
  40302. info.b2 = this._b2;
  40303. info.numRows = 0;
  40304. }
  40305. _getPositionSolverInfo(info) {
  40306. info.b1 = this._b1;
  40307. info.b2 = this._b2;
  40308. info.numRows = 0;
  40309. }
  40310. _checkDestruction() {
  40311. var forceSq = this._appliedForceX * this._appliedForceX + this._appliedForceY * this._appliedForceY + this._appliedForceZ * this._appliedForceZ;
  40312. var torqueSq = this._appliedTorqueX * this._appliedTorqueX + this._appliedTorqueY * this._appliedTorqueY + this._appliedTorqueZ * this._appliedTorqueZ;
  40313. if(this._breakForce > 0 && forceSq > this._breakForce * this._breakForce) {
  40314. this._world.removeJoint(this);
  40315. return;
  40316. }
  40317. if(this._breakTorque > 0 && torqueSq > this._breakTorque * this._breakTorque) {
  40318. this._world.removeJoint(this);
  40319. return;
  40320. }
  40321. }
  40322. getRigidBody1() {
  40323. return this._b1;
  40324. }
  40325. getRigidBody2() {
  40326. return this._b2;
  40327. }
  40328. getType() {
  40329. return this._type;
  40330. }
  40331. getAnchor1() {
  40332. var v = new oimo.common.Vec3();
  40333. var v1 = v;
  40334. v1.x = this._anchor1X;
  40335. v1.y = this._anchor1Y;
  40336. v1.z = this._anchor1Z;
  40337. return v;
  40338. }
  40339. getAnchor2() {
  40340. var v = new oimo.common.Vec3();
  40341. var v1 = v;
  40342. v1.x = this._anchor2X;
  40343. v1.y = this._anchor2Y;
  40344. v1.z = this._anchor2Z;
  40345. return v;
  40346. }
  40347. getAnchor1To(anchor) {
  40348. var v = anchor;
  40349. v.x = this._anchor1X;
  40350. v.y = this._anchor1Y;
  40351. v.z = this._anchor1Z;
  40352. }
  40353. getAnchor2To(anchor) {
  40354. var v = anchor;
  40355. v.x = this._anchor2X;
  40356. v.y = this._anchor2Y;
  40357. v.z = this._anchor2Z;
  40358. }
  40359. getLocalAnchor1() {
  40360. var v = new oimo.common.Vec3();
  40361. var v1 = v;
  40362. v1.x = this._localAnchor1X;
  40363. v1.y = this._localAnchor1Y;
  40364. v1.z = this._localAnchor1Z;
  40365. return v;
  40366. }
  40367. getLocalAnchor2() {
  40368. var v = new oimo.common.Vec3();
  40369. var v1 = v;
  40370. v1.x = this._localAnchor2X;
  40371. v1.y = this._localAnchor2Y;
  40372. v1.z = this._localAnchor2Z;
  40373. return v;
  40374. }
  40375. getLocalAnchor1To(localAnchor) {
  40376. var v = localAnchor;
  40377. v.x = this._localAnchor1X;
  40378. v.y = this._localAnchor1Y;
  40379. v.z = this._localAnchor1Z;
  40380. }
  40381. getLocalAnchor2To(localAnchor) {
  40382. var v = localAnchor;
  40383. v.x = this._localAnchor2X;
  40384. v.y = this._localAnchor2Y;
  40385. v.z = this._localAnchor2Z;
  40386. }
  40387. getBasis1() {
  40388. var m = new oimo.common.Mat3();
  40389. var b;
  40390. var b00;
  40391. var b01;
  40392. var b02;
  40393. var b10;
  40394. var b11;
  40395. var b12;
  40396. var b20;
  40397. var b21;
  40398. var b22;
  40399. b00 = this._basisX1X;
  40400. b01 = this._basisY1X;
  40401. b02 = this._basisZ1X;
  40402. b10 = this._basisX1Y;
  40403. b11 = this._basisY1Y;
  40404. b12 = this._basisZ1Y;
  40405. b20 = this._basisX1Z;
  40406. b21 = this._basisY1Z;
  40407. b22 = this._basisZ1Z;
  40408. var m1 = m;
  40409. m1.e00 = b00;
  40410. m1.e01 = b01;
  40411. m1.e02 = b02;
  40412. m1.e10 = b10;
  40413. m1.e11 = b11;
  40414. m1.e12 = b12;
  40415. m1.e20 = b20;
  40416. m1.e21 = b21;
  40417. m1.e22 = b22;
  40418. return m;
  40419. }
  40420. getBasis2() {
  40421. var m = new oimo.common.Mat3();
  40422. var b;
  40423. var b00;
  40424. var b01;
  40425. var b02;
  40426. var b10;
  40427. var b11;
  40428. var b12;
  40429. var b20;
  40430. var b21;
  40431. var b22;
  40432. b00 = this._basisX2X;
  40433. b01 = this._basisY2X;
  40434. b02 = this._basisZ2X;
  40435. b10 = this._basisX2Y;
  40436. b11 = this._basisY2Y;
  40437. b12 = this._basisZ2Y;
  40438. b20 = this._basisX2Z;
  40439. b21 = this._basisY2Z;
  40440. b22 = this._basisZ2Z;
  40441. var m1 = m;
  40442. m1.e00 = b00;
  40443. m1.e01 = b01;
  40444. m1.e02 = b02;
  40445. m1.e10 = b10;
  40446. m1.e11 = b11;
  40447. m1.e12 = b12;
  40448. m1.e20 = b20;
  40449. m1.e21 = b21;
  40450. m1.e22 = b22;
  40451. return m;
  40452. }
  40453. getBasis1To(basis) {
  40454. var b;
  40455. var b00;
  40456. var b01;
  40457. var b02;
  40458. var b10;
  40459. var b11;
  40460. var b12;
  40461. var b20;
  40462. var b21;
  40463. var b22;
  40464. b00 = this._basisX1X;
  40465. b01 = this._basisY1X;
  40466. b02 = this._basisZ1X;
  40467. b10 = this._basisX1Y;
  40468. b11 = this._basisY1Y;
  40469. b12 = this._basisZ1Y;
  40470. b20 = this._basisX1Z;
  40471. b21 = this._basisY1Z;
  40472. b22 = this._basisZ1Z;
  40473. var m = basis;
  40474. m.e00 = b00;
  40475. m.e01 = b01;
  40476. m.e02 = b02;
  40477. m.e10 = b10;
  40478. m.e11 = b11;
  40479. m.e12 = b12;
  40480. m.e20 = b20;
  40481. m.e21 = b21;
  40482. m.e22 = b22;
  40483. }
  40484. getBasis2To(basis) {
  40485. var b;
  40486. var b00;
  40487. var b01;
  40488. var b02;
  40489. var b10;
  40490. var b11;
  40491. var b12;
  40492. var b20;
  40493. var b21;
  40494. var b22;
  40495. b00 = this._basisX2X;
  40496. b01 = this._basisY2X;
  40497. b02 = this._basisZ2X;
  40498. b10 = this._basisX2Y;
  40499. b11 = this._basisY2Y;
  40500. b12 = this._basisZ2Y;
  40501. b20 = this._basisX2Z;
  40502. b21 = this._basisY2Z;
  40503. b22 = this._basisZ2Z;
  40504. var m = basis;
  40505. m.e00 = b00;
  40506. m.e01 = b01;
  40507. m.e02 = b02;
  40508. m.e10 = b10;
  40509. m.e11 = b11;
  40510. m.e12 = b12;
  40511. m.e20 = b20;
  40512. m.e21 = b21;
  40513. m.e22 = b22;
  40514. }
  40515. getAllowCollision() {
  40516. return this._allowCollision;
  40517. }
  40518. setAllowCollision(allowCollision) {
  40519. this._allowCollision = allowCollision;
  40520. }
  40521. getBreakForce() {
  40522. return this._breakForce;
  40523. }
  40524. setBreakForce(breakForce) {
  40525. this._breakForce = breakForce;
  40526. }
  40527. getBreakTorque() {
  40528. return this._breakTorque;
  40529. }
  40530. setBreakTorque(breakTorque) {
  40531. this._breakTorque = breakTorque;
  40532. }
  40533. getPositionCorrectionAlgorithm() {
  40534. return this._positionCorrectionAlgorithm;
  40535. }
  40536. setPositionCorrectionAlgorithm(positionCorrectionAlgorithm) {
  40537. switch(positionCorrectionAlgorithm) {
  40538. case 0:case 1:case 2:
  40539. break;
  40540. default:
  40541. throw new Error("invalid position correction algorithm id: " + positionCorrectionAlgorithm);
  40542. }
  40543. this._positionCorrectionAlgorithm = positionCorrectionAlgorithm;
  40544. }
  40545. getAppliedForce() {
  40546. var v = new oimo.common.Vec3();
  40547. var v1 = v;
  40548. v1.x = this._appliedForceX;
  40549. v1.y = this._appliedForceY;
  40550. v1.z = this._appliedForceZ;
  40551. return v;
  40552. }
  40553. getAppliedForceTo(appliedForce) {
  40554. var v = appliedForce;
  40555. v.x = this._appliedForceX;
  40556. v.y = this._appliedForceY;
  40557. v.z = this._appliedForceZ;
  40558. }
  40559. getAppliedTorque() {
  40560. var v = new oimo.common.Vec3();
  40561. var v1 = v;
  40562. v1.x = this._appliedTorqueX;
  40563. v1.y = this._appliedTorqueY;
  40564. v1.z = this._appliedTorqueZ;
  40565. return v;
  40566. }
  40567. getAppliedTorqueTo(appliedTorque) {
  40568. var v = appliedTorque;
  40569. v.x = this._appliedTorqueX;
  40570. v.y = this._appliedTorqueY;
  40571. v.z = this._appliedTorqueZ;
  40572. }
  40573. getPrev() {
  40574. return this._prev;
  40575. }
  40576. getNext() {
  40577. return this._next;
  40578. }
  40579. }
  40580. oimo.dynamics.constraint.joint.CylindricalJoint = class oimo_dynamics_constraint_joint_CylindricalJoint extends oimo.dynamics.constraint.joint.Joint {
  40581. constructor(config) {
  40582. super(config,2);
  40583. var v = config.localAxis1;
  40584. this._localBasisX1X = v.x;
  40585. this._localBasisX1Y = v.y;
  40586. this._localBasisX1Z = v.z;
  40587. var v1 = config.localAxis2;
  40588. this._localBasisX2X = v1.x;
  40589. this._localBasisX2Y = v1.y;
  40590. this._localBasisX2Z = v1.z;
  40591. this.buildLocalBasesFromX();
  40592. this.angle = 0;
  40593. this.angularErrorY = 0;
  40594. this.angularErrorZ = 0;
  40595. this.translation = 0;
  40596. this.linearErrorY = 0;
  40597. this.linearErrorZ = 0;
  40598. this._basis = new oimo.dynamics.constraint.joint.BasisTracker(this);
  40599. this._translSd = config.translationalSpringDamper.clone();
  40600. this._translLm = config.translationalLimitMotor.clone();
  40601. this._rotSd = config.rotationalSpringDamper.clone();
  40602. this._rotLm = config.rotationalLimitMotor.clone();
  40603. }
  40604. getInfo(info,timeStep,isPositionPart) {
  40605. var erp = this.getErp(timeStep,isPositionPart);
  40606. var linRhsY = this.linearErrorY * erp;
  40607. var linRhsZ = this.linearErrorZ * erp;
  40608. var angRhsY = this.angularErrorY * erp;
  40609. var angRhsZ = this.angularErrorZ * erp;
  40610. var row;
  40611. var j;
  40612. var translationalMotorMass = 1 / (this._b1._invMass + this._b2._invMass);
  40613. var rotationalMotorMass = this.computeEffectiveInertiaMoment(this._basis.xX,this._basis.xY,this._basis.xZ);
  40614. if(this._translSd.frequency <= 0 || !isPositionPart) {
  40615. var impulse = this._impulses[0];
  40616. var row1 = info.rows[info.numRows++];
  40617. var _this = row1.jacobian;
  40618. _this.lin1X = 0;
  40619. _this.lin1Y = 0;
  40620. _this.lin1Z = 0;
  40621. _this.lin2X = 0;
  40622. _this.lin2Y = 0;
  40623. _this.lin2Z = 0;
  40624. _this.ang1X = 0;
  40625. _this.ang1Y = 0;
  40626. _this.ang1Z = 0;
  40627. _this.ang2X = 0;
  40628. _this.ang2Y = 0;
  40629. _this.ang2Z = 0;
  40630. row1.rhs = 0;
  40631. row1.cfm = 0;
  40632. row1.minImpulse = 0;
  40633. row1.maxImpulse = 0;
  40634. row1.motorSpeed = 0;
  40635. row1.motorMaxImpulse = 0;
  40636. row1.impulse = null;
  40637. row1.impulse = impulse;
  40638. row = row1;
  40639. this.setSolverInfoRowLinear(row,this.translation,this._translLm,translationalMotorMass,this._translSd,timeStep,isPositionPart);
  40640. j = row.jacobian;
  40641. j.lin1X = this._basis.xX;
  40642. j.lin1Y = this._basis.xY;
  40643. j.lin1Z = this._basis.xZ;
  40644. j.lin2X = this._basis.xX;
  40645. j.lin2Y = this._basis.xY;
  40646. j.lin2Z = this._basis.xZ;
  40647. j.ang1X = this._relativeAnchor1Y * this._basis.xZ - this._relativeAnchor1Z * this._basis.xY;
  40648. j.ang1Y = this._relativeAnchor1Z * this._basis.xX - this._relativeAnchor1X * this._basis.xZ;
  40649. j.ang1Z = this._relativeAnchor1X * this._basis.xY - this._relativeAnchor1Y * this._basis.xX;
  40650. j.ang2X = this._relativeAnchor2Y * this._basis.xZ - this._relativeAnchor2Z * this._basis.xY;
  40651. j.ang2Y = this._relativeAnchor2Z * this._basis.xX - this._relativeAnchor2X * this._basis.xZ;
  40652. j.ang2Z = this._relativeAnchor2X * this._basis.xY - this._relativeAnchor2Y * this._basis.xX;
  40653. }
  40654. var impulse1 = this._impulses[1];
  40655. var row2 = info.rows[info.numRows++];
  40656. var _this1 = row2.jacobian;
  40657. _this1.lin1X = 0;
  40658. _this1.lin1Y = 0;
  40659. _this1.lin1Z = 0;
  40660. _this1.lin2X = 0;
  40661. _this1.lin2Y = 0;
  40662. _this1.lin2Z = 0;
  40663. _this1.ang1X = 0;
  40664. _this1.ang1Y = 0;
  40665. _this1.ang1Z = 0;
  40666. _this1.ang2X = 0;
  40667. _this1.ang2Y = 0;
  40668. _this1.ang2Z = 0;
  40669. row2.rhs = 0;
  40670. row2.cfm = 0;
  40671. row2.minImpulse = 0;
  40672. row2.maxImpulse = 0;
  40673. row2.motorSpeed = 0;
  40674. row2.motorMaxImpulse = 0;
  40675. row2.impulse = null;
  40676. row2.impulse = impulse1;
  40677. row = row2;
  40678. row.rhs = linRhsY;
  40679. row.cfm = 0;
  40680. row.minImpulse = -1e65536;
  40681. row.maxImpulse = 1e65536;
  40682. j = row.jacobian;
  40683. j.lin1X = this._basis.yX;
  40684. j.lin1Y = this._basis.yY;
  40685. j.lin1Z = this._basis.yZ;
  40686. j.lin2X = this._basis.yX;
  40687. j.lin2Y = this._basis.yY;
  40688. j.lin2Z = this._basis.yZ;
  40689. j.ang1X = this._relativeAnchor1Y * this._basis.yZ - this._relativeAnchor1Z * this._basis.yY;
  40690. j.ang1Y = this._relativeAnchor1Z * this._basis.yX - this._relativeAnchor1X * this._basis.yZ;
  40691. j.ang1Z = this._relativeAnchor1X * this._basis.yY - this._relativeAnchor1Y * this._basis.yX;
  40692. j.ang2X = this._relativeAnchor2Y * this._basis.yZ - this._relativeAnchor2Z * this._basis.yY;
  40693. j.ang2Y = this._relativeAnchor2Z * this._basis.yX - this._relativeAnchor2X * this._basis.yZ;
  40694. j.ang2Z = this._relativeAnchor2X * this._basis.yY - this._relativeAnchor2Y * this._basis.yX;
  40695. var impulse2 = this._impulses[2];
  40696. var row3 = info.rows[info.numRows++];
  40697. var _this2 = row3.jacobian;
  40698. _this2.lin1X = 0;
  40699. _this2.lin1Y = 0;
  40700. _this2.lin1Z = 0;
  40701. _this2.lin2X = 0;
  40702. _this2.lin2Y = 0;
  40703. _this2.lin2Z = 0;
  40704. _this2.ang1X = 0;
  40705. _this2.ang1Y = 0;
  40706. _this2.ang1Z = 0;
  40707. _this2.ang2X = 0;
  40708. _this2.ang2Y = 0;
  40709. _this2.ang2Z = 0;
  40710. row3.rhs = 0;
  40711. row3.cfm = 0;
  40712. row3.minImpulse = 0;
  40713. row3.maxImpulse = 0;
  40714. row3.motorSpeed = 0;
  40715. row3.motorMaxImpulse = 0;
  40716. row3.impulse = null;
  40717. row3.impulse = impulse2;
  40718. row = row3;
  40719. row.rhs = linRhsZ;
  40720. row.cfm = 0;
  40721. row.minImpulse = -1e65536;
  40722. row.maxImpulse = 1e65536;
  40723. j = row.jacobian;
  40724. j.lin1X = this._basis.zX;
  40725. j.lin1Y = this._basis.zY;
  40726. j.lin1Z = this._basis.zZ;
  40727. j.lin2X = this._basis.zX;
  40728. j.lin2Y = this._basis.zY;
  40729. j.lin2Z = this._basis.zZ;
  40730. j.ang1X = this._relativeAnchor1Y * this._basis.zZ - this._relativeAnchor1Z * this._basis.zY;
  40731. j.ang1Y = this._relativeAnchor1Z * this._basis.zX - this._relativeAnchor1X * this._basis.zZ;
  40732. j.ang1Z = this._relativeAnchor1X * this._basis.zY - this._relativeAnchor1Y * this._basis.zX;
  40733. j.ang2X = this._relativeAnchor2Y * this._basis.zZ - this._relativeAnchor2Z * this._basis.zY;
  40734. j.ang2Y = this._relativeAnchor2Z * this._basis.zX - this._relativeAnchor2X * this._basis.zZ;
  40735. j.ang2Z = this._relativeAnchor2X * this._basis.zY - this._relativeAnchor2Y * this._basis.zX;
  40736. if(this._rotSd.frequency <= 0 || !isPositionPart) {
  40737. var impulse3 = this._impulses[3];
  40738. var row4 = info.rows[info.numRows++];
  40739. var _this3 = row4.jacobian;
  40740. _this3.lin1X = 0;
  40741. _this3.lin1Y = 0;
  40742. _this3.lin1Z = 0;
  40743. _this3.lin2X = 0;
  40744. _this3.lin2Y = 0;
  40745. _this3.lin2Z = 0;
  40746. _this3.ang1X = 0;
  40747. _this3.ang1Y = 0;
  40748. _this3.ang1Z = 0;
  40749. _this3.ang2X = 0;
  40750. _this3.ang2Y = 0;
  40751. _this3.ang2Z = 0;
  40752. row4.rhs = 0;
  40753. row4.cfm = 0;
  40754. row4.minImpulse = 0;
  40755. row4.maxImpulse = 0;
  40756. row4.motorSpeed = 0;
  40757. row4.motorMaxImpulse = 0;
  40758. row4.impulse = null;
  40759. row4.impulse = impulse3;
  40760. row = row4;
  40761. this.setSolverInfoRowAngular(row,this.angle,this._rotLm,rotationalMotorMass,this._rotSd,timeStep,isPositionPart);
  40762. j = row.jacobian;
  40763. j.ang1X = this._basis.xX;
  40764. j.ang1Y = this._basis.xY;
  40765. j.ang1Z = this._basis.xZ;
  40766. j.ang2X = this._basis.xX;
  40767. j.ang2Y = this._basis.xY;
  40768. j.ang2Z = this._basis.xZ;
  40769. }
  40770. var impulse4 = this._impulses[4];
  40771. var row5 = info.rows[info.numRows++];
  40772. var _this4 = row5.jacobian;
  40773. _this4.lin1X = 0;
  40774. _this4.lin1Y = 0;
  40775. _this4.lin1Z = 0;
  40776. _this4.lin2X = 0;
  40777. _this4.lin2Y = 0;
  40778. _this4.lin2Z = 0;
  40779. _this4.ang1X = 0;
  40780. _this4.ang1Y = 0;
  40781. _this4.ang1Z = 0;
  40782. _this4.ang2X = 0;
  40783. _this4.ang2Y = 0;
  40784. _this4.ang2Z = 0;
  40785. row5.rhs = 0;
  40786. row5.cfm = 0;
  40787. row5.minImpulse = 0;
  40788. row5.maxImpulse = 0;
  40789. row5.motorSpeed = 0;
  40790. row5.motorMaxImpulse = 0;
  40791. row5.impulse = null;
  40792. row5.impulse = impulse4;
  40793. row = row5;
  40794. row.rhs = angRhsY;
  40795. row.cfm = 0;
  40796. row.minImpulse = -1e65536;
  40797. row.maxImpulse = 1e65536;
  40798. j = row.jacobian;
  40799. j.ang1X = this._basis.yX;
  40800. j.ang1Y = this._basis.yY;
  40801. j.ang1Z = this._basis.yZ;
  40802. j.ang2X = this._basis.yX;
  40803. j.ang2Y = this._basis.yY;
  40804. j.ang2Z = this._basis.yZ;
  40805. var impulse5 = this._impulses[5];
  40806. var row6 = info.rows[info.numRows++];
  40807. var _this5 = row6.jacobian;
  40808. _this5.lin1X = 0;
  40809. _this5.lin1Y = 0;
  40810. _this5.lin1Z = 0;
  40811. _this5.lin2X = 0;
  40812. _this5.lin2Y = 0;
  40813. _this5.lin2Z = 0;
  40814. _this5.ang1X = 0;
  40815. _this5.ang1Y = 0;
  40816. _this5.ang1Z = 0;
  40817. _this5.ang2X = 0;
  40818. _this5.ang2Y = 0;
  40819. _this5.ang2Z = 0;
  40820. row6.rhs = 0;
  40821. row6.cfm = 0;
  40822. row6.minImpulse = 0;
  40823. row6.maxImpulse = 0;
  40824. row6.motorSpeed = 0;
  40825. row6.motorMaxImpulse = 0;
  40826. row6.impulse = null;
  40827. row6.impulse = impulse5;
  40828. row = row6;
  40829. row.rhs = angRhsZ;
  40830. row.cfm = 0;
  40831. row.minImpulse = -1e65536;
  40832. row.maxImpulse = 1e65536;
  40833. j = row.jacobian;
  40834. j.ang1X = this._basis.zX;
  40835. j.ang1Y = this._basis.zY;
  40836. j.ang1Z = this._basis.zZ;
  40837. j.ang2X = this._basis.zX;
  40838. j.ang2Y = this._basis.zY;
  40839. j.ang2Z = this._basis.zZ;
  40840. }
  40841. _syncAnchors() {
  40842. super._syncAnchors();
  40843. var _this = this._basis;
  40844. var invM1 = _this.joint._b1._invMass;
  40845. var invM2 = _this.joint._b2._invMass;
  40846. var q;
  40847. var qX;
  40848. var qY;
  40849. var qZ;
  40850. var qW;
  40851. var idQ;
  40852. var idQX;
  40853. var idQY;
  40854. var idQZ;
  40855. var idQW;
  40856. var slerpQ;
  40857. var slerpQX;
  40858. var slerpQY;
  40859. var slerpQZ;
  40860. var slerpQW;
  40861. var slerpM;
  40862. var slerpM00;
  40863. var slerpM01;
  40864. var slerpM02;
  40865. var slerpM10;
  40866. var slerpM11;
  40867. var slerpM12;
  40868. var slerpM20;
  40869. var slerpM21;
  40870. var slerpM22;
  40871. var newX;
  40872. var newXX;
  40873. var newXY;
  40874. var newXZ;
  40875. var newY;
  40876. var newYX;
  40877. var newYY;
  40878. var newYZ;
  40879. var newZ;
  40880. var newZX;
  40881. var newZY;
  40882. var newZZ;
  40883. var prevX;
  40884. var prevXX;
  40885. var prevXY;
  40886. var prevXZ;
  40887. var prevY;
  40888. var prevYX;
  40889. var prevYY;
  40890. var prevYZ;
  40891. var d = _this.joint._basisX1X * _this.joint._basisX2X + _this.joint._basisX1Y * _this.joint._basisX2Y + _this.joint._basisX1Z * _this.joint._basisX2Z;
  40892. if(d < -0.999999999) {
  40893. var vX;
  40894. var vY;
  40895. var vZ;
  40896. var x1 = _this.joint._basisX1X;
  40897. var y1 = _this.joint._basisX1Y;
  40898. var z1 = _this.joint._basisX1Z;
  40899. var x2 = x1 * x1;
  40900. var y2 = y1 * y1;
  40901. var z2 = z1 * z1;
  40902. var d1;
  40903. if(x2 < y2) {
  40904. if(x2 < z2) {
  40905. d1 = 1 / Math.sqrt(y2 + z2);
  40906. vX = 0;
  40907. vY = z1 * d1;
  40908. vZ = -y1 * d1;
  40909. } else {
  40910. d1 = 1 / Math.sqrt(x2 + y2);
  40911. vX = y1 * d1;
  40912. vY = -x1 * d1;
  40913. vZ = 0;
  40914. }
  40915. } else if(y2 < z2) {
  40916. d1 = 1 / Math.sqrt(z2 + x2);
  40917. vX = -z1 * d1;
  40918. vY = 0;
  40919. vZ = x1 * d1;
  40920. } else {
  40921. d1 = 1 / Math.sqrt(x2 + y2);
  40922. vX = y1 * d1;
  40923. vY = -x1 * d1;
  40924. vZ = 0;
  40925. }
  40926. qX = vX;
  40927. qY = vY;
  40928. qZ = vZ;
  40929. qW = 0;
  40930. } else {
  40931. var cX;
  40932. var cY;
  40933. var cZ;
  40934. cX = _this.joint._basisX1Y * _this.joint._basisX2Z - _this.joint._basisX1Z * _this.joint._basisX2Y;
  40935. cY = _this.joint._basisX1Z * _this.joint._basisX2X - _this.joint._basisX1X * _this.joint._basisX2Z;
  40936. cZ = _this.joint._basisX1X * _this.joint._basisX2Y - _this.joint._basisX1Y * _this.joint._basisX2X;
  40937. var w = Math.sqrt((1 + d) * 0.5);
  40938. d = 0.5 / w;
  40939. cX *= d;
  40940. cY *= d;
  40941. cZ *= d;
  40942. qX = cX;
  40943. qY = cY;
  40944. qZ = cZ;
  40945. qW = w;
  40946. }
  40947. idQX = 0;
  40948. idQY = 0;
  40949. idQZ = 0;
  40950. idQW = 1;
  40951. var qx;
  40952. var qy;
  40953. var qz;
  40954. var qw;
  40955. var q1X;
  40956. var q1Y;
  40957. var q1Z;
  40958. var q1W;
  40959. var q2X;
  40960. var q2Y;
  40961. var q2Z;
  40962. var q2W;
  40963. q1X = idQX;
  40964. q1Y = idQY;
  40965. q1Z = idQZ;
  40966. q1W = idQW;
  40967. q2X = qX;
  40968. q2Y = qY;
  40969. q2Z = qZ;
  40970. q2W = qW;
  40971. var d2 = q1X * q2X + q1Y * q2Y + q1Z * q2Z + q1W * q2W;
  40972. if(d2 < 0) {
  40973. d2 = -d2;
  40974. q2X = -q2X;
  40975. q2Y = -q2Y;
  40976. q2Z = -q2Z;
  40977. q2W = -q2W;
  40978. }
  40979. if(d2 > 0.999999) {
  40980. var dqX;
  40981. var dqY;
  40982. var dqZ;
  40983. var dqW;
  40984. dqX = q2X - q1X;
  40985. dqY = q2Y - q1Y;
  40986. dqZ = q2Z - q1Z;
  40987. dqW = q2W - q1W;
  40988. q2X = q1X + dqX * (invM1 / (invM1 + invM2));
  40989. q2Y = q1Y + dqY * (invM1 / (invM1 + invM2));
  40990. q2Z = q1Z + dqZ * (invM1 / (invM1 + invM2));
  40991. q2W = q1W + dqW * (invM1 / (invM1 + invM2));
  40992. var l = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W;
  40993. if(l > 1e-32) {
  40994. l = 1 / Math.sqrt(l);
  40995. }
  40996. slerpQX = q2X * l;
  40997. slerpQY = q2Y * l;
  40998. slerpQZ = q2Z * l;
  40999. slerpQW = q2W * l;
  41000. } else {
  41001. var theta = invM1 / (invM1 + invM2) * Math.acos(d2);
  41002. q2X += q1X * -d2;
  41003. q2Y += q1Y * -d2;
  41004. q2Z += q1Z * -d2;
  41005. q2W += q1W * -d2;
  41006. var l1 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W;
  41007. if(l1 > 1e-32) {
  41008. l1 = 1 / Math.sqrt(l1);
  41009. }
  41010. q2X *= l1;
  41011. q2Y *= l1;
  41012. q2Z *= l1;
  41013. q2W *= l1;
  41014. var sin = Math.sin(theta);
  41015. var cos = Math.cos(theta);
  41016. q1X *= cos;
  41017. q1Y *= cos;
  41018. q1Z *= cos;
  41019. q1W *= cos;
  41020. slerpQX = q1X + q2X * sin;
  41021. slerpQY = q1Y + q2Y * sin;
  41022. slerpQZ = q1Z + q2Z * sin;
  41023. slerpQW = q1W + q2W * sin;
  41024. }
  41025. var x = slerpQX;
  41026. var y = slerpQY;
  41027. var z = slerpQZ;
  41028. var w1 = slerpQW;
  41029. var x21 = 2 * x;
  41030. var y21 = 2 * y;
  41031. var z21 = 2 * z;
  41032. var xx = x * x21;
  41033. var yy = y * y21;
  41034. var zz = z * z21;
  41035. var xy = x * y21;
  41036. var yz = y * z21;
  41037. var xz = x * z21;
  41038. var wx = w1 * x21;
  41039. var wy = w1 * y21;
  41040. var wz = w1 * z21;
  41041. slerpM00 = 1 - yy - zz;
  41042. slerpM01 = xy - wz;
  41043. slerpM02 = xz + wy;
  41044. slerpM10 = xy + wz;
  41045. slerpM11 = 1 - xx - zz;
  41046. slerpM12 = yz - wx;
  41047. slerpM20 = xz - wy;
  41048. slerpM21 = yz + wx;
  41049. slerpM22 = 1 - xx - yy;
  41050. var __tmp__X;
  41051. var __tmp__Y;
  41052. var __tmp__Z;
  41053. __tmp__X = slerpM00 * _this.joint._basisX1X + slerpM01 * _this.joint._basisX1Y + slerpM02 * _this.joint._basisX1Z;
  41054. __tmp__Y = slerpM10 * _this.joint._basisX1X + slerpM11 * _this.joint._basisX1Y + slerpM12 * _this.joint._basisX1Z;
  41055. __tmp__Z = slerpM20 * _this.joint._basisX1X + slerpM21 * _this.joint._basisX1Y + slerpM22 * _this.joint._basisX1Z;
  41056. newXX = __tmp__X;
  41057. newXY = __tmp__Y;
  41058. newXZ = __tmp__Z;
  41059. prevXX = _this.xX;
  41060. prevXY = _this.xY;
  41061. prevXZ = _this.xZ;
  41062. prevYX = _this.yX;
  41063. prevYY = _this.yY;
  41064. prevYZ = _this.yZ;
  41065. var d3 = prevXX * newXX + prevXY * newXY + prevXZ * newXZ;
  41066. if(d3 < -0.999999999) {
  41067. var vX1;
  41068. var vY1;
  41069. var vZ1;
  41070. var x11 = prevXX;
  41071. var y11 = prevXY;
  41072. var z11 = prevXZ;
  41073. var x22 = x11 * x11;
  41074. var y22 = y11 * y11;
  41075. var z22 = z11 * z11;
  41076. var d4;
  41077. if(x22 < y22) {
  41078. if(x22 < z22) {
  41079. d4 = 1 / Math.sqrt(y22 + z22);
  41080. vX1 = 0;
  41081. vY1 = z11 * d4;
  41082. vZ1 = -y11 * d4;
  41083. } else {
  41084. d4 = 1 / Math.sqrt(x22 + y22);
  41085. vX1 = y11 * d4;
  41086. vY1 = -x11 * d4;
  41087. vZ1 = 0;
  41088. }
  41089. } else if(y22 < z22) {
  41090. d4 = 1 / Math.sqrt(z22 + x22);
  41091. vX1 = -z11 * d4;
  41092. vY1 = 0;
  41093. vZ1 = x11 * d4;
  41094. } else {
  41095. d4 = 1 / Math.sqrt(x22 + y22);
  41096. vX1 = y11 * d4;
  41097. vY1 = -x11 * d4;
  41098. vZ1 = 0;
  41099. }
  41100. slerpQX = vX1;
  41101. slerpQY = vY1;
  41102. slerpQZ = vZ1;
  41103. slerpQW = 0;
  41104. } else {
  41105. var cX1;
  41106. var cY1;
  41107. var cZ1;
  41108. cX1 = prevXY * newXZ - prevXZ * newXY;
  41109. cY1 = prevXZ * newXX - prevXX * newXZ;
  41110. cZ1 = prevXX * newXY - prevXY * newXX;
  41111. var w2 = Math.sqrt((1 + d3) * 0.5);
  41112. d3 = 0.5 / w2;
  41113. cX1 *= d3;
  41114. cY1 *= d3;
  41115. cZ1 *= d3;
  41116. slerpQX = cX1;
  41117. slerpQY = cY1;
  41118. slerpQZ = cZ1;
  41119. slerpQW = w2;
  41120. }
  41121. var x3 = slerpQX;
  41122. var y3 = slerpQY;
  41123. var z3 = slerpQZ;
  41124. var w3 = slerpQW;
  41125. var x23 = 2 * x3;
  41126. var y23 = 2 * y3;
  41127. var z23 = 2 * z3;
  41128. var xx1 = x3 * x23;
  41129. var yy1 = y3 * y23;
  41130. var zz1 = z3 * z23;
  41131. var xy1 = x3 * y23;
  41132. var yz1 = y3 * z23;
  41133. var xz1 = x3 * z23;
  41134. var wx1 = w3 * x23;
  41135. var wy1 = w3 * y23;
  41136. var wz1 = w3 * z23;
  41137. slerpM00 = 1 - yy1 - zz1;
  41138. slerpM01 = xy1 - wz1;
  41139. slerpM02 = xz1 + wy1;
  41140. slerpM10 = xy1 + wz1;
  41141. slerpM11 = 1 - xx1 - zz1;
  41142. slerpM12 = yz1 - wx1;
  41143. slerpM20 = xz1 - wy1;
  41144. slerpM21 = yz1 + wx1;
  41145. slerpM22 = 1 - xx1 - yy1;
  41146. var __tmp__X1;
  41147. var __tmp__Y1;
  41148. var __tmp__Z1;
  41149. __tmp__X1 = slerpM00 * prevYX + slerpM01 * prevYY + slerpM02 * prevYZ;
  41150. __tmp__Y1 = slerpM10 * prevYX + slerpM11 * prevYY + slerpM12 * prevYZ;
  41151. __tmp__Z1 = slerpM20 * prevYX + slerpM21 * prevYY + slerpM22 * prevYZ;
  41152. newYX = __tmp__X1;
  41153. newYY = __tmp__Y1;
  41154. newYZ = __tmp__Z1;
  41155. newZX = newXY * newYZ - newXZ * newYY;
  41156. newZY = newXZ * newYX - newXX * newYZ;
  41157. newZZ = newXX * newYY - newXY * newYX;
  41158. if(newZX * newZX + newZY * newZY + newZZ * newZZ > 1e-6) {
  41159. var l2 = newZX * newZX + newZY * newZY + newZZ * newZZ;
  41160. if(l2 > 0) {
  41161. l2 = 1 / Math.sqrt(l2);
  41162. }
  41163. newZX *= l2;
  41164. newZY *= l2;
  41165. newZZ *= l2;
  41166. } else {
  41167. var x12 = newXX;
  41168. var y12 = newXY;
  41169. var z12 = newXZ;
  41170. var x24 = x12 * x12;
  41171. var y24 = y12 * y12;
  41172. var z24 = z12 * z12;
  41173. var d5;
  41174. if(x24 < y24) {
  41175. if(x24 < z24) {
  41176. d5 = 1 / Math.sqrt(y24 + z24);
  41177. newZX = 0;
  41178. newZY = z12 * d5;
  41179. newZZ = -y12 * d5;
  41180. } else {
  41181. d5 = 1 / Math.sqrt(x24 + y24);
  41182. newZX = y12 * d5;
  41183. newZY = -x12 * d5;
  41184. newZZ = 0;
  41185. }
  41186. } else if(y24 < z24) {
  41187. d5 = 1 / Math.sqrt(z24 + x24);
  41188. newZX = -z12 * d5;
  41189. newZY = 0;
  41190. newZZ = x12 * d5;
  41191. } else {
  41192. d5 = 1 / Math.sqrt(x24 + y24);
  41193. newZX = y12 * d5;
  41194. newZY = -x12 * d5;
  41195. newZZ = 0;
  41196. }
  41197. }
  41198. newYX = newZY * newXZ - newZZ * newXY;
  41199. newYY = newZZ * newXX - newZX * newXZ;
  41200. newYZ = newZX * newXY - newZY * newXX;
  41201. _this.xX = newXX;
  41202. _this.xY = newXY;
  41203. _this.xZ = newXZ;
  41204. _this.yX = newYX;
  41205. _this.yY = newYY;
  41206. _this.yZ = newYZ;
  41207. _this.zX = newZX;
  41208. _this.zY = newZY;
  41209. _this.zZ = newZZ;
  41210. var angError;
  41211. var angErrorX;
  41212. var angErrorY;
  41213. var angErrorZ;
  41214. angErrorX = this._basisX1Y * this._basisX2Z - this._basisX1Z * this._basisX2Y;
  41215. angErrorY = this._basisX1Z * this._basisX2X - this._basisX1X * this._basisX2Z;
  41216. angErrorZ = this._basisX1X * this._basisX2Y - this._basisX1Y * this._basisX2X;
  41217. var cos1 = this._basisX1X * this._basisX2X + this._basisX1Y * this._basisX2Y + this._basisX1Z * this._basisX2Z;
  41218. var theta1 = cos1 <= -1 ? 3.14159265358979 : cos1 >= 1 ? 0 : Math.acos(cos1);
  41219. var l3 = angErrorX * angErrorX + angErrorY * angErrorY + angErrorZ * angErrorZ;
  41220. if(l3 > 0) {
  41221. l3 = 1 / Math.sqrt(l3);
  41222. }
  41223. angErrorX *= l3;
  41224. angErrorY *= l3;
  41225. angErrorZ *= l3;
  41226. angErrorX *= theta1;
  41227. angErrorY *= theta1;
  41228. angErrorZ *= theta1;
  41229. this.angularErrorY = angErrorX * this._basis.yX + angErrorY * this._basis.yY + angErrorZ * this._basis.yZ;
  41230. this.angularErrorZ = angErrorX * this._basis.zX + angErrorY * this._basis.zY + angErrorZ * this._basis.zZ;
  41231. var perpCross;
  41232. var perpCrossX;
  41233. var perpCrossY;
  41234. var perpCrossZ;
  41235. perpCrossX = this._basisY1Y * this._basisY2Z - this._basisY1Z * this._basisY2Y;
  41236. perpCrossY = this._basisY1Z * this._basisY2X - this._basisY1X * this._basisY2Z;
  41237. perpCrossZ = this._basisY1X * this._basisY2Y - this._basisY1Y * this._basisY2X;
  41238. cos1 = this._basisY1X * this._basisY2X + this._basisY1Y * this._basisY2Y + this._basisY1Z * this._basisY2Z;
  41239. this.angle = cos1 <= -1 ? 3.14159265358979 : cos1 >= 1 ? 0 : Math.acos(cos1);
  41240. if(perpCrossX * this._basis.xX + perpCrossY * this._basis.xY + perpCrossZ * this._basis.xZ < 0) {
  41241. this.angle = -this.angle;
  41242. }
  41243. var anchorDiff;
  41244. var anchorDiffX;
  41245. var anchorDiffY;
  41246. var anchorDiffZ;
  41247. anchorDiffX = this._anchor2X - this._anchor1X;
  41248. anchorDiffY = this._anchor2Y - this._anchor1Y;
  41249. anchorDiffZ = this._anchor2Z - this._anchor1Z;
  41250. this.translation = anchorDiffX * this._basis.xX + anchorDiffY * this._basis.xY + anchorDiffZ * this._basis.xZ;
  41251. this.linearErrorY = anchorDiffX * this._basis.yX + anchorDiffY * this._basis.yY + anchorDiffZ * this._basis.yZ;
  41252. this.linearErrorZ = anchorDiffX * this._basis.zX + anchorDiffY * this._basis.zY + anchorDiffZ * this._basis.zZ;
  41253. }
  41254. _getVelocitySolverInfo(timeStep,info) {
  41255. super._getVelocitySolverInfo(timeStep,info);
  41256. this.getInfo(info,timeStep,false);
  41257. }
  41258. _getPositionSolverInfo(info) {
  41259. super._getPositionSolverInfo(info);
  41260. this.getInfo(info,null,true);
  41261. }
  41262. getAxis1() {
  41263. var v = new oimo.common.Vec3();
  41264. var v1 = v;
  41265. v1.x = this._basisX1X;
  41266. v1.y = this._basisX1Y;
  41267. v1.z = this._basisX1Z;
  41268. return v;
  41269. }
  41270. getAxis2() {
  41271. var v = new oimo.common.Vec3();
  41272. var v1 = v;
  41273. v1.x = this._basisX2X;
  41274. v1.y = this._basisX2Y;
  41275. v1.z = this._basisX2Z;
  41276. return v;
  41277. }
  41278. getAxis1To(axis) {
  41279. var v = axis;
  41280. v.x = this._basisX1X;
  41281. v.y = this._basisX1Y;
  41282. v.z = this._basisX1Z;
  41283. }
  41284. getAxis2To(axis) {
  41285. var v = axis;
  41286. v.x = this._basisX2X;
  41287. v.y = this._basisX2Y;
  41288. v.z = this._basisX2Z;
  41289. }
  41290. getLocalAxis1() {
  41291. var v = new oimo.common.Vec3();
  41292. var v1 = v;
  41293. v1.x = this._localBasisX1X;
  41294. v1.y = this._localBasisX1Y;
  41295. v1.z = this._localBasisX1Z;
  41296. return v;
  41297. }
  41298. getLocalAxis2() {
  41299. var v = new oimo.common.Vec3();
  41300. var v1 = v;
  41301. v1.x = this._localBasisX2X;
  41302. v1.y = this._localBasisX2Y;
  41303. v1.z = this._localBasisX2Z;
  41304. return v;
  41305. }
  41306. getLocalAxis1To(axis) {
  41307. var v = axis;
  41308. v.x = this._localBasisX1X;
  41309. v.y = this._localBasisX1Y;
  41310. v.z = this._localBasisX1Z;
  41311. }
  41312. getLocalAxis2To(axis) {
  41313. var v = axis;
  41314. v.x = this._localBasisX2X;
  41315. v.y = this._localBasisX2Y;
  41316. v.z = this._localBasisX2Z;
  41317. }
  41318. getTranslationalSpringDamper() {
  41319. return this._translSd;
  41320. }
  41321. getRotationalSpringDamper() {
  41322. return this._rotSd;
  41323. }
  41324. getTranslationalLimitMotor() {
  41325. return this._translLm;
  41326. }
  41327. getRotationalLimitMotor() {
  41328. return this._rotLm;
  41329. }
  41330. getAngle() {
  41331. return this.angle;
  41332. }
  41333. getTranslation() {
  41334. return this.translation;
  41335. }
  41336. }
  41337. oimo.dynamics.constraint.joint.JointConfig = class oimo_dynamics_constraint_joint_JointConfig {
  41338. constructor() {
  41339. this.rigidBody1 = null;
  41340. this.rigidBody2 = null;
  41341. this.localAnchor1 = new oimo.common.Vec3();
  41342. this.localAnchor2 = new oimo.common.Vec3();
  41343. this.allowCollision = false;
  41344. this.solverType = oimo.common.Setting.defaultJointConstraintSolverType;
  41345. this.positionCorrectionAlgorithm = oimo.common.Setting.defaultJointPositionCorrectionAlgorithm;
  41346. this.breakForce = 0;
  41347. this.breakTorque = 0;
  41348. }
  41349. _init(rb1,rb2,worldAnchor) {
  41350. this.rigidBody1 = rb1;
  41351. this.rigidBody2 = rb2;
  41352. var _this = this.rigidBody1;
  41353. var v;
  41354. var vX;
  41355. var vY;
  41356. var vZ;
  41357. var v1 = worldAnchor;
  41358. vX = v1.x;
  41359. vY = v1.y;
  41360. vZ = v1.z;
  41361. vX -= _this._transform._positionX;
  41362. vY -= _this._transform._positionY;
  41363. vZ -= _this._transform._positionZ;
  41364. var __tmp__X;
  41365. var __tmp__Y;
  41366. var __tmp__Z;
  41367. __tmp__X = _this._transform._rotation00 * vX + _this._transform._rotation10 * vY + _this._transform._rotation20 * vZ;
  41368. __tmp__Y = _this._transform._rotation01 * vX + _this._transform._rotation11 * vY + _this._transform._rotation21 * vZ;
  41369. __tmp__Z = _this._transform._rotation02 * vX + _this._transform._rotation12 * vY + _this._transform._rotation22 * vZ;
  41370. vX = __tmp__X;
  41371. vY = __tmp__Y;
  41372. vZ = __tmp__Z;
  41373. var v2 = this.localAnchor1;
  41374. v2.x = vX;
  41375. v2.y = vY;
  41376. v2.z = vZ;
  41377. var _this1 = this.rigidBody2;
  41378. var v3;
  41379. var vX1;
  41380. var vY1;
  41381. var vZ1;
  41382. var v4 = worldAnchor;
  41383. vX1 = v4.x;
  41384. vY1 = v4.y;
  41385. vZ1 = v4.z;
  41386. vX1 -= _this1._transform._positionX;
  41387. vY1 -= _this1._transform._positionY;
  41388. vZ1 -= _this1._transform._positionZ;
  41389. var __tmp__X1;
  41390. var __tmp__Y1;
  41391. var __tmp__Z1;
  41392. __tmp__X1 = _this1._transform._rotation00 * vX1 + _this1._transform._rotation10 * vY1 + _this1._transform._rotation20 * vZ1;
  41393. __tmp__Y1 = _this1._transform._rotation01 * vX1 + _this1._transform._rotation11 * vY1 + _this1._transform._rotation21 * vZ1;
  41394. __tmp__Z1 = _this1._transform._rotation02 * vX1 + _this1._transform._rotation12 * vY1 + _this1._transform._rotation22 * vZ1;
  41395. vX1 = __tmp__X1;
  41396. vY1 = __tmp__Y1;
  41397. vZ1 = __tmp__Z1;
  41398. var v5 = this.localAnchor2;
  41399. v5.x = vX1;
  41400. v5.y = vY1;
  41401. v5.z = vZ1;
  41402. }
  41403. }
  41404. oimo.dynamics.constraint.joint.CylindricalJointConfig = class oimo_dynamics_constraint_joint_CylindricalJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  41405. constructor() {
  41406. super();
  41407. this.localAxis1 = new oimo.common.Vec3(1,0,0);
  41408. this.localAxis2 = new oimo.common.Vec3(1,0,0);
  41409. this.translationalLimitMotor = new oimo.dynamics.constraint.joint.TranslationalLimitMotor();
  41410. this.translationalSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  41411. this.rotationalLimitMotor = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  41412. this.rotationalSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  41413. }
  41414. init(rigidBody1,rigidBody2,worldAnchor,worldAxis) {
  41415. this._init(rigidBody1,rigidBody2,worldAnchor);
  41416. var v;
  41417. var vX;
  41418. var vY;
  41419. var vZ;
  41420. var v1 = worldAxis;
  41421. vX = v1.x;
  41422. vY = v1.y;
  41423. vZ = v1.z;
  41424. var __tmp__X;
  41425. var __tmp__Y;
  41426. var __tmp__Z;
  41427. __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ;
  41428. __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ;
  41429. __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ;
  41430. vX = __tmp__X;
  41431. vY = __tmp__Y;
  41432. vZ = __tmp__Z;
  41433. var v2 = this.localAxis1;
  41434. v2.x = vX;
  41435. v2.y = vY;
  41436. v2.z = vZ;
  41437. var v3;
  41438. var vX1;
  41439. var vY1;
  41440. var vZ1;
  41441. var v4 = worldAxis;
  41442. vX1 = v4.x;
  41443. vY1 = v4.y;
  41444. vZ1 = v4.z;
  41445. var __tmp__X1;
  41446. var __tmp__Y1;
  41447. var __tmp__Z1;
  41448. __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1;
  41449. __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1;
  41450. __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1;
  41451. vX1 = __tmp__X1;
  41452. vY1 = __tmp__Y1;
  41453. vZ1 = __tmp__Z1;
  41454. var v5 = this.localAxis2;
  41455. v5.x = vX1;
  41456. v5.y = vY1;
  41457. v5.z = vZ1;
  41458. return this;
  41459. }
  41460. }
  41461. oimo.dynamics.constraint.joint.GenericJoint = class oimo_dynamics_constraint_joint_GenericJoint extends oimo.dynamics.constraint.joint.Joint {
  41462. constructor(config) {
  41463. super(config,oimo.dynamics.constraint.joint.JointType.GENERIC);
  41464. var tmp;
  41465. var _this = config.localBasis1;
  41466. if(!(_this.e00 * (_this.e11 * _this.e22 - _this.e12 * _this.e21) - _this.e01 * (_this.e10 * _this.e22 - _this.e12 * _this.e20) + _this.e02 * (_this.e10 * _this.e21 - _this.e11 * _this.e20) < 0)) {
  41467. var _this1 = config.localBasis2;
  41468. tmp = _this1.e00 * (_this1.e11 * _this1.e22 - _this1.e12 * _this1.e21) - _this1.e01 * (_this1.e10 * _this1.e22 - _this1.e12 * _this1.e20) + _this1.e02 * (_this1.e10 * _this1.e21 - _this1.e11 * _this1.e20) < 0;
  41469. } else {
  41470. tmp = true;
  41471. }
  41472. if(tmp) {
  41473. console.log("src/oimo/dynamics/constraint/joint/GenericJoint.hx:50:","[warning] joint basis must be right handed");
  41474. }
  41475. var lb1;
  41476. var lb100;
  41477. var lb101;
  41478. var lb102;
  41479. var lb110;
  41480. var lb111;
  41481. var lb112;
  41482. var lb120;
  41483. var lb121;
  41484. var lb122;
  41485. var lb2;
  41486. var lb200;
  41487. var lb201;
  41488. var lb202;
  41489. var lb210;
  41490. var lb211;
  41491. var lb212;
  41492. var lb220;
  41493. var lb221;
  41494. var lb222;
  41495. var m = config.localBasis1;
  41496. lb100 = m.e00;
  41497. lb101 = m.e01;
  41498. lb102 = m.e02;
  41499. lb110 = m.e10;
  41500. lb111 = m.e11;
  41501. lb112 = m.e12;
  41502. lb120 = m.e20;
  41503. lb121 = m.e21;
  41504. lb122 = m.e22;
  41505. var m1 = config.localBasis2;
  41506. lb200 = m1.e00;
  41507. lb201 = m1.e01;
  41508. lb202 = m1.e02;
  41509. lb210 = m1.e10;
  41510. lb211 = m1.e11;
  41511. lb212 = m1.e12;
  41512. lb220 = m1.e20;
  41513. lb221 = m1.e21;
  41514. lb222 = m1.e22;
  41515. this._localBasisX1X = lb100;
  41516. this._localBasisX1Y = lb110;
  41517. this._localBasisX1Z = lb120;
  41518. this._localBasisY1X = lb101;
  41519. this._localBasisY1Y = lb111;
  41520. this._localBasisY1Z = lb121;
  41521. this._localBasisZ1X = lb102;
  41522. this._localBasisZ1Y = lb112;
  41523. this._localBasisZ1Z = lb122;
  41524. this._localBasisX2X = lb200;
  41525. this._localBasisX2Y = lb210;
  41526. this._localBasisX2Z = lb220;
  41527. this._localBasisY2X = lb201;
  41528. this._localBasisY2Y = lb211;
  41529. this._localBasisY2Z = lb221;
  41530. this._localBasisZ2X = lb202;
  41531. this._localBasisZ2Y = lb212;
  41532. this._localBasisZ2Z = lb222;
  41533. this._angleX = 0;
  41534. this._angleY = 0;
  41535. this._angleZ = 0;
  41536. this.translationX = 0;
  41537. this.translationY = 0;
  41538. this.translationZ = 0;
  41539. this.xSingular = false;
  41540. this.ySingular = false;
  41541. this.zSingular = false;
  41542. var this1 = new Array(3);
  41543. this._translLms = this1;
  41544. var this2 = new Array(3);
  41545. this._translSds = this2;
  41546. var this3 = new Array(3);
  41547. this._rotLms = this3;
  41548. var this4 = new Array(3);
  41549. this._rotSds = this4;
  41550. this._translLms[0] = config.translationalLimitMotors[0].clone();
  41551. this._translLms[1] = config.translationalLimitMotors[1].clone();
  41552. this._translLms[2] = config.translationalLimitMotors[2].clone();
  41553. this._translSds[0] = config.translationalSpringDampers[0].clone();
  41554. this._translSds[1] = config.translationalSpringDampers[1].clone();
  41555. this._translSds[2] = config.translationalSpringDampers[2].clone();
  41556. this._rotLms[0] = config.rotationalLimitMotors[0].clone();
  41557. this._rotLms[1] = config.rotationalLimitMotors[1].clone();
  41558. this._rotLms[2] = config.rotationalLimitMotors[2].clone();
  41559. this._rotSds[0] = config.rotationalSpringDampers[0].clone();
  41560. this._rotSds[1] = config.rotationalSpringDampers[1].clone();
  41561. this._rotSds[2] = config.rotationalSpringDampers[2].clone();
  41562. }
  41563. getInfo(info,timeStep,isPositionPart) {
  41564. var row;
  41565. var j;
  41566. var translMotorMass = 1 / (this._b1._invMass + this._b2._invMass);
  41567. var motorMassX = this.computeEffectiveInertiaMoment(this._axisXX,this._axisXY,this._axisXZ);
  41568. var motorMassY = this.computeEffectiveInertiaMoment(this._axisYX,this._axisYY,this._axisYZ);
  41569. var motorMassZ = this.computeEffectiveInertiaMoment(this._axisZX,this._axisZY,this._axisZZ);
  41570. if(this._translSds[0].frequency <= 0 || !isPositionPart) {
  41571. var impulse = this._impulses[0];
  41572. var row1 = info.rows[info.numRows++];
  41573. var _this = row1.jacobian;
  41574. _this.lin1X = 0;
  41575. _this.lin1Y = 0;
  41576. _this.lin1Z = 0;
  41577. _this.lin2X = 0;
  41578. _this.lin2Y = 0;
  41579. _this.lin2Z = 0;
  41580. _this.ang1X = 0;
  41581. _this.ang1Y = 0;
  41582. _this.ang1Z = 0;
  41583. _this.ang2X = 0;
  41584. _this.ang2Y = 0;
  41585. _this.ang2Z = 0;
  41586. row1.rhs = 0;
  41587. row1.cfm = 0;
  41588. row1.minImpulse = 0;
  41589. row1.maxImpulse = 0;
  41590. row1.motorSpeed = 0;
  41591. row1.motorMaxImpulse = 0;
  41592. row1.impulse = null;
  41593. row1.impulse = impulse;
  41594. row = row1;
  41595. this.setSolverInfoRowLinear(row,this.translationX,this._translLms[0],translMotorMass,this._translSds[0],timeStep,isPositionPart);
  41596. j = row.jacobian;
  41597. j.lin1X = this._basisX1X;
  41598. j.lin1Y = this._basisX1Y;
  41599. j.lin1Z = this._basisX1Z;
  41600. j.lin2X = this._basisX1X;
  41601. j.lin2Y = this._basisX1Y;
  41602. j.lin2Z = this._basisX1Z;
  41603. j.ang1X = this._relativeAnchor1Y * this._basisX1Z - this._relativeAnchor1Z * this._basisX1Y;
  41604. j.ang1Y = this._relativeAnchor1Z * this._basisX1X - this._relativeAnchor1X * this._basisX1Z;
  41605. j.ang1Z = this._relativeAnchor1X * this._basisX1Y - this._relativeAnchor1Y * this._basisX1X;
  41606. j.ang2X = this._relativeAnchor2Y * this._basisX1Z - this._relativeAnchor2Z * this._basisX1Y;
  41607. j.ang2Y = this._relativeAnchor2Z * this._basisX1X - this._relativeAnchor2X * this._basisX1Z;
  41608. j.ang2Z = this._relativeAnchor2X * this._basisX1Y - this._relativeAnchor2Y * this._basisX1X;
  41609. }
  41610. if(this._translSds[1].frequency <= 0 || !isPositionPart) {
  41611. var impulse1 = this._impulses[1];
  41612. var row2 = info.rows[info.numRows++];
  41613. var _this1 = row2.jacobian;
  41614. _this1.lin1X = 0;
  41615. _this1.lin1Y = 0;
  41616. _this1.lin1Z = 0;
  41617. _this1.lin2X = 0;
  41618. _this1.lin2Y = 0;
  41619. _this1.lin2Z = 0;
  41620. _this1.ang1X = 0;
  41621. _this1.ang1Y = 0;
  41622. _this1.ang1Z = 0;
  41623. _this1.ang2X = 0;
  41624. _this1.ang2Y = 0;
  41625. _this1.ang2Z = 0;
  41626. row2.rhs = 0;
  41627. row2.cfm = 0;
  41628. row2.minImpulse = 0;
  41629. row2.maxImpulse = 0;
  41630. row2.motorSpeed = 0;
  41631. row2.motorMaxImpulse = 0;
  41632. row2.impulse = null;
  41633. row2.impulse = impulse1;
  41634. row = row2;
  41635. this.setSolverInfoRowLinear(row,this.translationY,this._translLms[1],translMotorMass,this._translSds[1],timeStep,isPositionPart);
  41636. j = row.jacobian;
  41637. j.lin1X = this._basisY1X;
  41638. j.lin1Y = this._basisY1Y;
  41639. j.lin1Z = this._basisY1Z;
  41640. j.lin2X = this._basisY1X;
  41641. j.lin2Y = this._basisY1Y;
  41642. j.lin2Z = this._basisY1Z;
  41643. j.ang1X = this._relativeAnchor1Y * this._basisY1Z - this._relativeAnchor1Z * this._basisY1Y;
  41644. j.ang1Y = this._relativeAnchor1Z * this._basisY1X - this._relativeAnchor1X * this._basisY1Z;
  41645. j.ang1Z = this._relativeAnchor1X * this._basisY1Y - this._relativeAnchor1Y * this._basisY1X;
  41646. j.ang2X = this._relativeAnchor2Y * this._basisY1Z - this._relativeAnchor2Z * this._basisY1Y;
  41647. j.ang2Y = this._relativeAnchor2Z * this._basisY1X - this._relativeAnchor2X * this._basisY1Z;
  41648. j.ang2Z = this._relativeAnchor2X * this._basisY1Y - this._relativeAnchor2Y * this._basisY1X;
  41649. }
  41650. if(this._translSds[2].frequency <= 0 || !isPositionPart) {
  41651. var impulse2 = this._impulses[2];
  41652. var row3 = info.rows[info.numRows++];
  41653. var _this2 = row3.jacobian;
  41654. _this2.lin1X = 0;
  41655. _this2.lin1Y = 0;
  41656. _this2.lin1Z = 0;
  41657. _this2.lin2X = 0;
  41658. _this2.lin2Y = 0;
  41659. _this2.lin2Z = 0;
  41660. _this2.ang1X = 0;
  41661. _this2.ang1Y = 0;
  41662. _this2.ang1Z = 0;
  41663. _this2.ang2X = 0;
  41664. _this2.ang2Y = 0;
  41665. _this2.ang2Z = 0;
  41666. row3.rhs = 0;
  41667. row3.cfm = 0;
  41668. row3.minImpulse = 0;
  41669. row3.maxImpulse = 0;
  41670. row3.motorSpeed = 0;
  41671. row3.motorMaxImpulse = 0;
  41672. row3.impulse = null;
  41673. row3.impulse = impulse2;
  41674. row = row3;
  41675. this.setSolverInfoRowLinear(row,this.translationZ,this._translLms[2],translMotorMass,this._translSds[2],timeStep,isPositionPart);
  41676. j = row.jacobian;
  41677. j.lin1X = this._basisZ1X;
  41678. j.lin1Y = this._basisZ1Y;
  41679. j.lin1Z = this._basisZ1Z;
  41680. j.lin2X = this._basisZ1X;
  41681. j.lin2Y = this._basisZ1Y;
  41682. j.lin2Z = this._basisZ1Z;
  41683. j.ang1X = this._relativeAnchor1Y * this._basisZ1Z - this._relativeAnchor1Z * this._basisZ1Y;
  41684. j.ang1Y = this._relativeAnchor1Z * this._basisZ1X - this._relativeAnchor1X * this._basisZ1Z;
  41685. j.ang1Z = this._relativeAnchor1X * this._basisZ1Y - this._relativeAnchor1Y * this._basisZ1X;
  41686. j.ang2X = this._relativeAnchor2Y * this._basisZ1Z - this._relativeAnchor2Z * this._basisZ1Y;
  41687. j.ang2Y = this._relativeAnchor2Z * this._basisZ1X - this._relativeAnchor2X * this._basisZ1Z;
  41688. j.ang2Z = this._relativeAnchor2X * this._basisZ1Y - this._relativeAnchor2Y * this._basisZ1X;
  41689. }
  41690. if(!this.xSingular && (this._rotSds[0].frequency <= 0 || !isPositionPart)) {
  41691. var impulse3 = this._impulses[3];
  41692. var row4 = info.rows[info.numRows++];
  41693. var _this3 = row4.jacobian;
  41694. _this3.lin1X = 0;
  41695. _this3.lin1Y = 0;
  41696. _this3.lin1Z = 0;
  41697. _this3.lin2X = 0;
  41698. _this3.lin2Y = 0;
  41699. _this3.lin2Z = 0;
  41700. _this3.ang1X = 0;
  41701. _this3.ang1Y = 0;
  41702. _this3.ang1Z = 0;
  41703. _this3.ang2X = 0;
  41704. _this3.ang2Y = 0;
  41705. _this3.ang2Z = 0;
  41706. row4.rhs = 0;
  41707. row4.cfm = 0;
  41708. row4.minImpulse = 0;
  41709. row4.maxImpulse = 0;
  41710. row4.motorSpeed = 0;
  41711. row4.motorMaxImpulse = 0;
  41712. row4.impulse = null;
  41713. row4.impulse = impulse3;
  41714. row = row4;
  41715. this.setSolverInfoRowAngular(row,this._angleX,this._rotLms[0],motorMassX,this._rotSds[0],timeStep,isPositionPart);
  41716. j = row.jacobian;
  41717. j.ang1X = this._axisXX;
  41718. j.ang1Y = this._axisXY;
  41719. j.ang1Z = this._axisXZ;
  41720. j.ang2X = this._axisXX;
  41721. j.ang2Y = this._axisXY;
  41722. j.ang2Z = this._axisXZ;
  41723. }
  41724. if(!this.ySingular && (this._rotSds[1].frequency <= 0 || !isPositionPart)) {
  41725. var impulse4 = this._impulses[4];
  41726. var row5 = info.rows[info.numRows++];
  41727. var _this4 = row5.jacobian;
  41728. _this4.lin1X = 0;
  41729. _this4.lin1Y = 0;
  41730. _this4.lin1Z = 0;
  41731. _this4.lin2X = 0;
  41732. _this4.lin2Y = 0;
  41733. _this4.lin2Z = 0;
  41734. _this4.ang1X = 0;
  41735. _this4.ang1Y = 0;
  41736. _this4.ang1Z = 0;
  41737. _this4.ang2X = 0;
  41738. _this4.ang2Y = 0;
  41739. _this4.ang2Z = 0;
  41740. row5.rhs = 0;
  41741. row5.cfm = 0;
  41742. row5.minImpulse = 0;
  41743. row5.maxImpulse = 0;
  41744. row5.motorSpeed = 0;
  41745. row5.motorMaxImpulse = 0;
  41746. row5.impulse = null;
  41747. row5.impulse = impulse4;
  41748. row = row5;
  41749. this.setSolverInfoRowAngular(row,this._angleY,this._rotLms[1],motorMassY,this._rotSds[1],timeStep,isPositionPart);
  41750. j = row.jacobian;
  41751. j.ang1X = this._axisYX;
  41752. j.ang1Y = this._axisYY;
  41753. j.ang1Z = this._axisYZ;
  41754. j.ang2X = this._axisYX;
  41755. j.ang2Y = this._axisYY;
  41756. j.ang2Z = this._axisYZ;
  41757. }
  41758. if(!this.zSingular && (this._rotSds[2].frequency <= 0 || !isPositionPart)) {
  41759. var impulse5 = this._impulses[5];
  41760. var row6 = info.rows[info.numRows++];
  41761. var _this5 = row6.jacobian;
  41762. _this5.lin1X = 0;
  41763. _this5.lin1Y = 0;
  41764. _this5.lin1Z = 0;
  41765. _this5.lin2X = 0;
  41766. _this5.lin2Y = 0;
  41767. _this5.lin2Z = 0;
  41768. _this5.ang1X = 0;
  41769. _this5.ang1Y = 0;
  41770. _this5.ang1Z = 0;
  41771. _this5.ang2X = 0;
  41772. _this5.ang2Y = 0;
  41773. _this5.ang2Z = 0;
  41774. row6.rhs = 0;
  41775. row6.cfm = 0;
  41776. row6.minImpulse = 0;
  41777. row6.maxImpulse = 0;
  41778. row6.motorSpeed = 0;
  41779. row6.motorMaxImpulse = 0;
  41780. row6.impulse = null;
  41781. row6.impulse = impulse5;
  41782. row = row6;
  41783. this.setSolverInfoRowAngular(row,this._angleZ,this._rotLms[2],motorMassZ,this._rotSds[2],timeStep,isPositionPart);
  41784. j = row.jacobian;
  41785. j.ang1X = this._axisZX;
  41786. j.ang1Y = this._axisZY;
  41787. j.ang1Z = this._axisZZ;
  41788. j.ang2X = this._axisZX;
  41789. j.ang2Y = this._axisZY;
  41790. j.ang2Z = this._axisZZ;
  41791. }
  41792. }
  41793. _syncAnchors() {
  41794. super._syncAnchors();
  41795. var rot1;
  41796. var rot100;
  41797. var rot101;
  41798. var rot102;
  41799. var rot110;
  41800. var rot111;
  41801. var rot112;
  41802. var rot120;
  41803. var rot121;
  41804. var rot122;
  41805. var rot2;
  41806. var rot200;
  41807. var rot201;
  41808. var rot202;
  41809. var rot210;
  41810. var rot211;
  41811. var rot212;
  41812. var rot220;
  41813. var rot221;
  41814. var rot222;
  41815. rot100 = this._basisX1X;
  41816. rot101 = this._basisY1X;
  41817. rot102 = this._basisZ1X;
  41818. rot110 = this._basisX1Y;
  41819. rot111 = this._basisY1Y;
  41820. rot112 = this._basisZ1Y;
  41821. rot120 = this._basisX1Z;
  41822. rot121 = this._basisY1Z;
  41823. rot122 = this._basisZ1Z;
  41824. rot200 = this._basisX2X;
  41825. rot201 = this._basisY2X;
  41826. rot202 = this._basisZ2X;
  41827. rot210 = this._basisX2Y;
  41828. rot211 = this._basisY2Y;
  41829. rot212 = this._basisZ2Y;
  41830. rot220 = this._basisX2Z;
  41831. rot221 = this._basisY2Z;
  41832. rot222 = this._basisZ2Z;
  41833. var relRot;
  41834. var relRot00;
  41835. var relRot01;
  41836. var relRot02;
  41837. var relRot10;
  41838. var relRot11;
  41839. var relRot12;
  41840. var relRot20;
  41841. var relRot21;
  41842. var relRot22;
  41843. var __tmp__00;
  41844. var __tmp__01;
  41845. var __tmp__02;
  41846. var __tmp__10;
  41847. var __tmp__11;
  41848. var __tmp__12;
  41849. var __tmp__20;
  41850. var __tmp__21;
  41851. var __tmp__22;
  41852. __tmp__00 = rot100 * rot200 + rot110 * rot210 + rot120 * rot220;
  41853. __tmp__01 = rot100 * rot201 + rot110 * rot211 + rot120 * rot221;
  41854. __tmp__02 = rot100 * rot202 + rot110 * rot212 + rot120 * rot222;
  41855. __tmp__10 = rot101 * rot200 + rot111 * rot210 + rot121 * rot220;
  41856. __tmp__11 = rot101 * rot201 + rot111 * rot211 + rot121 * rot221;
  41857. __tmp__12 = rot101 * rot202 + rot111 * rot212 + rot121 * rot222;
  41858. __tmp__20 = rot102 * rot200 + rot112 * rot210 + rot122 * rot220;
  41859. __tmp__21 = rot102 * rot201 + rot112 * rot211 + rot122 * rot221;
  41860. __tmp__22 = rot102 * rot202 + rot112 * rot212 + rot122 * rot222;
  41861. relRot00 = __tmp__00;
  41862. relRot01 = __tmp__01;
  41863. relRot02 = __tmp__02;
  41864. relRot10 = __tmp__10;
  41865. relRot11 = __tmp__11;
  41866. relRot12 = __tmp__12;
  41867. relRot20 = __tmp__20;
  41868. relRot21 = __tmp__21;
  41869. relRot22 = __tmp__22;
  41870. var angleAxisX;
  41871. var angleAxisXX;
  41872. var angleAxisXY;
  41873. var angleAxisXZ;
  41874. var angleAxisY;
  41875. var angleAxisYX;
  41876. var angleAxisYY;
  41877. var angleAxisYZ;
  41878. var angleAxisZ;
  41879. var angleAxisZX;
  41880. var angleAxisZY;
  41881. var angleAxisZZ;
  41882. angleAxisXX = this._basisX1X;
  41883. angleAxisXY = this._basisX1Y;
  41884. angleAxisXZ = this._basisX1Z;
  41885. angleAxisZX = this._basisZ2X;
  41886. angleAxisZY = this._basisZ2Y;
  41887. angleAxisZZ = this._basisZ2Z;
  41888. angleAxisYX = angleAxisZY * angleAxisXZ - angleAxisZZ * angleAxisXY;
  41889. angleAxisYY = angleAxisZZ * angleAxisXX - angleAxisZX * angleAxisXZ;
  41890. angleAxisYZ = angleAxisZX * angleAxisXY - angleAxisZY * angleAxisXX;
  41891. this._axisXX = angleAxisYY * angleAxisZZ - angleAxisYZ * angleAxisZY;
  41892. this._axisXY = angleAxisYZ * angleAxisZX - angleAxisYX * angleAxisZZ;
  41893. this._axisXZ = angleAxisYX * angleAxisZY - angleAxisYY * angleAxisZX;
  41894. this._axisYX = angleAxisYX;
  41895. this._axisYY = angleAxisYY;
  41896. this._axisYZ = angleAxisYZ;
  41897. this._axisZX = angleAxisXY * angleAxisYZ - angleAxisXZ * angleAxisYY;
  41898. this._axisZY = angleAxisXZ * angleAxisYX - angleAxisXX * angleAxisYZ;
  41899. this._axisZZ = angleAxisXX * angleAxisYY - angleAxisXY * angleAxisYX;
  41900. var l = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ;
  41901. if(l > 0) {
  41902. l = 1 / Math.sqrt(l);
  41903. }
  41904. this._axisXX *= l;
  41905. this._axisXY *= l;
  41906. this._axisXZ *= l;
  41907. var l1 = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ;
  41908. if(l1 > 0) {
  41909. l1 = 1 / Math.sqrt(l1);
  41910. }
  41911. this._axisYX *= l1;
  41912. this._axisYY *= l1;
  41913. this._axisYZ *= l1;
  41914. var l2 = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ;
  41915. if(l2 > 0) {
  41916. l2 = 1 / Math.sqrt(l2);
  41917. }
  41918. this._axisZX *= l2;
  41919. this._axisZY *= l2;
  41920. this._axisZZ *= l2;
  41921. this.xSingular = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ == 0;
  41922. this.ySingular = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ == 0;
  41923. this.zSingular = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ == 0;
  41924. var rot11;
  41925. var rot1001;
  41926. var rot1011;
  41927. var rot1021;
  41928. var rot1101;
  41929. var rot1111;
  41930. var rot1121;
  41931. var rot1201;
  41932. var rot1211;
  41933. var rot1221;
  41934. var rot21;
  41935. var rot2001;
  41936. var rot2011;
  41937. var rot2021;
  41938. var rot2101;
  41939. var rot2111;
  41940. var rot2121;
  41941. var rot2201;
  41942. var rot2211;
  41943. var rot2221;
  41944. rot1001 = this._basisX1X;
  41945. rot1011 = this._basisY1X;
  41946. rot1021 = this._basisZ1X;
  41947. rot1101 = this._basisX1Y;
  41948. rot1111 = this._basisY1Y;
  41949. rot1121 = this._basisZ1Y;
  41950. rot1201 = this._basisX1Z;
  41951. rot1211 = this._basisY1Z;
  41952. rot1221 = this._basisZ1Z;
  41953. rot2001 = this._basisX2X;
  41954. rot2011 = this._basisY2X;
  41955. rot2021 = this._basisZ2X;
  41956. rot2101 = this._basisX2Y;
  41957. rot2111 = this._basisY2Y;
  41958. rot2121 = this._basisZ2Y;
  41959. rot2201 = this._basisX2Z;
  41960. rot2211 = this._basisY2Z;
  41961. rot2221 = this._basisZ2Z;
  41962. var relRot1;
  41963. var relRot001;
  41964. var relRot011;
  41965. var relRot021;
  41966. var relRot101;
  41967. var relRot111;
  41968. var relRot121;
  41969. var relRot201;
  41970. var relRot211;
  41971. var relRot221;
  41972. var __tmp__001;
  41973. var __tmp__011;
  41974. var __tmp__021;
  41975. var __tmp__101;
  41976. var __tmp__111;
  41977. var __tmp__121;
  41978. var __tmp__201;
  41979. var __tmp__211;
  41980. var __tmp__221;
  41981. __tmp__001 = rot1001 * rot2001 + rot1101 * rot2101 + rot1201 * rot2201;
  41982. __tmp__011 = rot1001 * rot2011 + rot1101 * rot2111 + rot1201 * rot2211;
  41983. __tmp__021 = rot1001 * rot2021 + rot1101 * rot2121 + rot1201 * rot2221;
  41984. __tmp__101 = rot1011 * rot2001 + rot1111 * rot2101 + rot1211 * rot2201;
  41985. __tmp__111 = rot1011 * rot2011 + rot1111 * rot2111 + rot1211 * rot2211;
  41986. __tmp__121 = rot1011 * rot2021 + rot1111 * rot2121 + rot1211 * rot2221;
  41987. __tmp__201 = rot1021 * rot2001 + rot1121 * rot2101 + rot1221 * rot2201;
  41988. __tmp__211 = rot1021 * rot2011 + rot1121 * rot2111 + rot1221 * rot2211;
  41989. __tmp__221 = rot1021 * rot2021 + rot1121 * rot2121 + rot1221 * rot2221;
  41990. relRot001 = __tmp__001;
  41991. relRot011 = __tmp__011;
  41992. relRot021 = __tmp__021;
  41993. relRot101 = __tmp__101;
  41994. relRot111 = __tmp__111;
  41995. relRot121 = __tmp__121;
  41996. relRot201 = __tmp__201;
  41997. relRot211 = __tmp__211;
  41998. relRot221 = __tmp__221;
  41999. var angles;
  42000. var anglesX;
  42001. var anglesY;
  42002. var anglesZ;
  42003. var sy = relRot021;
  42004. if(sy <= -1) {
  42005. var xSubZ = Math.atan2(relRot211,relRot111);
  42006. anglesX = xSubZ * 0.5;
  42007. anglesY = -1.570796326794895;
  42008. anglesZ = -xSubZ * 0.5;
  42009. } else if(sy >= 1) {
  42010. var xAddZ = Math.atan2(relRot211,relRot111);
  42011. anglesX = xAddZ * 0.5;
  42012. anglesY = 1.570796326794895;
  42013. anglesZ = xAddZ * 0.5;
  42014. } else {
  42015. var y = Math.asin(sy);
  42016. var x = Math.atan2(-relRot121,relRot221);
  42017. var z = Math.atan2(-relRot011,relRot001);
  42018. anglesX = x;
  42019. anglesY = y;
  42020. anglesZ = z;
  42021. }
  42022. this._angleX = anglesX;
  42023. this._angleY = anglesY;
  42024. this._angleZ = anglesZ;
  42025. var anchorDiff;
  42026. var anchorDiffX;
  42027. var anchorDiffY;
  42028. var anchorDiffZ;
  42029. anchorDiffX = this._anchor2X - this._anchor1X;
  42030. anchorDiffY = this._anchor2Y - this._anchor1Y;
  42031. anchorDiffZ = this._anchor2Z - this._anchor1Z;
  42032. this.translationX = anchorDiffX * this._basisX1X + anchorDiffY * this._basisX1Y + anchorDiffZ * this._basisX1Z;
  42033. this.translationY = anchorDiffX * this._basisY1X + anchorDiffY * this._basisY1Y + anchorDiffZ * this._basisY1Z;
  42034. this.translationZ = anchorDiffX * this._basisZ1X + anchorDiffY * this._basisZ1Y + anchorDiffZ * this._basisZ1Z;
  42035. }
  42036. _getVelocitySolverInfo(timeStep,info) {
  42037. super._getVelocitySolverInfo(timeStep,info);
  42038. this.getInfo(info,timeStep,false);
  42039. }
  42040. _getPositionSolverInfo(info) {
  42041. super._getPositionSolverInfo(info);
  42042. this.getInfo(info,null,true);
  42043. }
  42044. getAxisX() {
  42045. var v = new oimo.common.Vec3();
  42046. var v1 = v;
  42047. v1.x = this._basisX1X;
  42048. v1.y = this._basisX1Y;
  42049. v1.z = this._basisX1Z;
  42050. return v;
  42051. }
  42052. getAxisY() {
  42053. var v = new oimo.common.Vec3();
  42054. var v1 = v;
  42055. v1.x = this._axisYX;
  42056. v1.y = this._axisYY;
  42057. v1.z = this._axisYZ;
  42058. return v;
  42059. }
  42060. getAxisZ() {
  42061. var v = new oimo.common.Vec3();
  42062. var v1 = v;
  42063. v1.x = this._basisZ2X;
  42064. v1.y = this._basisZ2Y;
  42065. v1.z = this._basisZ2Z;
  42066. return v;
  42067. }
  42068. getTranslationalSpringDampers() {
  42069. return this._translSds.slice(0);
  42070. }
  42071. getRotationalSpringDampers() {
  42072. return this._translSds.slice(0);
  42073. }
  42074. getTranslationalLimitMotors() {
  42075. return this._translLms.slice(0);
  42076. }
  42077. getRotationalLimitMotors() {
  42078. return this._rotLms.slice(0);
  42079. }
  42080. getAngles() {
  42081. return new oimo.common.Vec3(this._angleX,this._angleY,this._angleZ);
  42082. }
  42083. getTranslations() {
  42084. return new oimo.common.Vec3(this.translationX,this.translationY,this.translationZ);
  42085. }
  42086. }
  42087. oimo.dynamics.constraint.joint.GenericJointConfig = class oimo_dynamics_constraint_joint_GenericJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  42088. constructor() {
  42089. super();
  42090. this.localBasis1 = new oimo.common.Mat3();
  42091. this.localBasis2 = new oimo.common.Mat3();
  42092. var _g = [];
  42093. _g.push(new oimo.dynamics.constraint.joint.TranslationalLimitMotor().setLimits(0,0));
  42094. _g.push(new oimo.dynamics.constraint.joint.TranslationalLimitMotor().setLimits(0,0));
  42095. _g.push(new oimo.dynamics.constraint.joint.TranslationalLimitMotor().setLimits(0,0));
  42096. this.translationalLimitMotors = _g;
  42097. var _g1 = [];
  42098. _g1.push(new oimo.dynamics.constraint.joint.RotationalLimitMotor().setLimits(0,0));
  42099. _g1.push(new oimo.dynamics.constraint.joint.RotationalLimitMotor().setLimits(0,0));
  42100. _g1.push(new oimo.dynamics.constraint.joint.RotationalLimitMotor().setLimits(0,0));
  42101. this.rotationalLimitMotors = _g1;
  42102. this.translationalSpringDampers = [new oimo.dynamics.constraint.joint.SpringDamper(),new oimo.dynamics.constraint.joint.SpringDamper(),new oimo.dynamics.constraint.joint.SpringDamper()];
  42103. this.rotationalSpringDampers = [new oimo.dynamics.constraint.joint.SpringDamper(),new oimo.dynamics.constraint.joint.SpringDamper(),new oimo.dynamics.constraint.joint.SpringDamper()];
  42104. }
  42105. init(rigidBody1,rigidBody2,worldAnchor,worldBasis1,worldBasis2) {
  42106. this._init(rigidBody1,rigidBody2,worldAnchor);
  42107. var tf1 = rigidBody1._transform;
  42108. var tf2 = rigidBody2._transform;
  42109. var wb1;
  42110. var wb100;
  42111. var wb101;
  42112. var wb102;
  42113. var wb110;
  42114. var wb111;
  42115. var wb112;
  42116. var wb120;
  42117. var wb121;
  42118. var wb122;
  42119. var wb2;
  42120. var wb200;
  42121. var wb201;
  42122. var wb202;
  42123. var wb210;
  42124. var wb211;
  42125. var wb212;
  42126. var wb220;
  42127. var wb221;
  42128. var wb222;
  42129. var lb1;
  42130. var lb100;
  42131. var lb101;
  42132. var lb102;
  42133. var lb110;
  42134. var lb111;
  42135. var lb112;
  42136. var lb120;
  42137. var lb121;
  42138. var lb122;
  42139. var lb2;
  42140. var lb200;
  42141. var lb201;
  42142. var lb202;
  42143. var lb210;
  42144. var lb211;
  42145. var lb212;
  42146. var lb220;
  42147. var lb221;
  42148. var lb222;
  42149. var m = worldBasis1;
  42150. wb100 = m.e00;
  42151. wb101 = m.e01;
  42152. wb102 = m.e02;
  42153. wb110 = m.e10;
  42154. wb111 = m.e11;
  42155. wb112 = m.e12;
  42156. wb120 = m.e20;
  42157. wb121 = m.e21;
  42158. wb122 = m.e22;
  42159. var m1 = worldBasis2;
  42160. wb200 = m1.e00;
  42161. wb201 = m1.e01;
  42162. wb202 = m1.e02;
  42163. wb210 = m1.e10;
  42164. wb211 = m1.e11;
  42165. wb212 = m1.e12;
  42166. wb220 = m1.e20;
  42167. wb221 = m1.e21;
  42168. wb222 = m1.e22;
  42169. var __tmp__00;
  42170. var __tmp__01;
  42171. var __tmp__02;
  42172. var __tmp__10;
  42173. var __tmp__11;
  42174. var __tmp__12;
  42175. var __tmp__20;
  42176. var __tmp__21;
  42177. var __tmp__22;
  42178. __tmp__00 = tf1._rotation00 * wb100 + tf1._rotation10 * wb110 + tf1._rotation20 * wb120;
  42179. __tmp__01 = tf1._rotation00 * wb101 + tf1._rotation10 * wb111 + tf1._rotation20 * wb121;
  42180. __tmp__02 = tf1._rotation00 * wb102 + tf1._rotation10 * wb112 + tf1._rotation20 * wb122;
  42181. __tmp__10 = tf1._rotation01 * wb100 + tf1._rotation11 * wb110 + tf1._rotation21 * wb120;
  42182. __tmp__11 = tf1._rotation01 * wb101 + tf1._rotation11 * wb111 + tf1._rotation21 * wb121;
  42183. __tmp__12 = tf1._rotation01 * wb102 + tf1._rotation11 * wb112 + tf1._rotation21 * wb122;
  42184. __tmp__20 = tf1._rotation02 * wb100 + tf1._rotation12 * wb110 + tf1._rotation22 * wb120;
  42185. __tmp__21 = tf1._rotation02 * wb101 + tf1._rotation12 * wb111 + tf1._rotation22 * wb121;
  42186. __tmp__22 = tf1._rotation02 * wb102 + tf1._rotation12 * wb112 + tf1._rotation22 * wb122;
  42187. lb100 = __tmp__00;
  42188. lb101 = __tmp__01;
  42189. lb102 = __tmp__02;
  42190. lb110 = __tmp__10;
  42191. lb111 = __tmp__11;
  42192. lb112 = __tmp__12;
  42193. lb120 = __tmp__20;
  42194. lb121 = __tmp__21;
  42195. lb122 = __tmp__22;
  42196. var __tmp__001;
  42197. var __tmp__011;
  42198. var __tmp__021;
  42199. var __tmp__101;
  42200. var __tmp__111;
  42201. var __tmp__121;
  42202. var __tmp__201;
  42203. var __tmp__211;
  42204. var __tmp__221;
  42205. __tmp__001 = tf2._rotation00 * wb200 + tf2._rotation10 * wb210 + tf2._rotation20 * wb220;
  42206. __tmp__011 = tf2._rotation00 * wb201 + tf2._rotation10 * wb211 + tf2._rotation20 * wb221;
  42207. __tmp__021 = tf2._rotation00 * wb202 + tf2._rotation10 * wb212 + tf2._rotation20 * wb222;
  42208. __tmp__101 = tf2._rotation01 * wb200 + tf2._rotation11 * wb210 + tf2._rotation21 * wb220;
  42209. __tmp__111 = tf2._rotation01 * wb201 + tf2._rotation11 * wb211 + tf2._rotation21 * wb221;
  42210. __tmp__121 = tf2._rotation01 * wb202 + tf2._rotation11 * wb212 + tf2._rotation21 * wb222;
  42211. __tmp__201 = tf2._rotation02 * wb200 + tf2._rotation12 * wb210 + tf2._rotation22 * wb220;
  42212. __tmp__211 = tf2._rotation02 * wb201 + tf2._rotation12 * wb211 + tf2._rotation22 * wb221;
  42213. __tmp__221 = tf2._rotation02 * wb202 + tf2._rotation12 * wb212 + tf2._rotation22 * wb222;
  42214. lb200 = __tmp__001;
  42215. lb201 = __tmp__011;
  42216. lb202 = __tmp__021;
  42217. lb210 = __tmp__101;
  42218. lb211 = __tmp__111;
  42219. lb212 = __tmp__121;
  42220. lb220 = __tmp__201;
  42221. lb221 = __tmp__211;
  42222. lb222 = __tmp__221;
  42223. var m2 = this.localBasis1;
  42224. m2.e00 = lb100;
  42225. m2.e01 = lb101;
  42226. m2.e02 = lb102;
  42227. m2.e10 = lb110;
  42228. m2.e11 = lb111;
  42229. m2.e12 = lb112;
  42230. m2.e20 = lb120;
  42231. m2.e21 = lb121;
  42232. m2.e22 = lb122;
  42233. var m3 = this.localBasis2;
  42234. m3.e00 = lb200;
  42235. m3.e01 = lb201;
  42236. m3.e02 = lb202;
  42237. m3.e10 = lb210;
  42238. m3.e11 = lb211;
  42239. m3.e12 = lb212;
  42240. m3.e20 = lb220;
  42241. m3.e21 = lb221;
  42242. m3.e22 = lb222;
  42243. return this;
  42244. }
  42245. }
  42246. oimo.dynamics.constraint.joint.JointImpulse = class oimo_dynamics_constraint_joint_JointImpulse {
  42247. constructor() {
  42248. this.impulse = 0;
  42249. this.impulseM = 0;
  42250. this.impulseP = 0;
  42251. }
  42252. }
  42253. oimo.dynamics.constraint.joint.JointLink = class oimo_dynamics_constraint_joint_JointLink {
  42254. constructor(joint) {
  42255. this._joint = joint;
  42256. }
  42257. getContact() {
  42258. return this._joint;
  42259. }
  42260. getOther() {
  42261. return this._other;
  42262. }
  42263. getPrev() {
  42264. return this._prev;
  42265. }
  42266. getNext() {
  42267. return this._next;
  42268. }
  42269. }
  42270. oimo.dynamics.constraint.joint.JointMacro = class oimo_dynamics_constraint_joint_JointMacro {
  42271. }
  42272. oimo.dynamics.constraint.joint.JointType = class oimo_dynamics_constraint_joint_JointType {
  42273. }
  42274. oimo.dynamics.constraint.joint.PrismaticJoint = class oimo_dynamics_constraint_joint_PrismaticJoint extends oimo.dynamics.constraint.joint.Joint {
  42275. constructor(config) {
  42276. super(config,oimo.dynamics.constraint.joint.JointType.PRISMATIC);
  42277. var v = config.localAxis1;
  42278. this._localBasisX1X = v.x;
  42279. this._localBasisX1Y = v.y;
  42280. this._localBasisX1Z = v.z;
  42281. var v1 = config.localAxis2;
  42282. this._localBasisX2X = v1.x;
  42283. this._localBasisX2Y = v1.y;
  42284. this._localBasisX2Z = v1.z;
  42285. this.buildLocalBasesFromX();
  42286. this._basis = new oimo.dynamics.constraint.joint.BasisTracker(this);
  42287. this.translation = 0;
  42288. this.linearErrorY = 0;
  42289. this.linearErrorZ = 0;
  42290. this.angularErrorX = 0;
  42291. this.angularErrorY = 0;
  42292. this.angularErrorZ = 0;
  42293. this._sd = config.springDamper.clone();
  42294. this._lm = config.limitMotor.clone();
  42295. }
  42296. getInfo(info,timeStep,isPositionPart) {
  42297. var erp = this.getErp(timeStep,isPositionPart);
  42298. var linRhsY = this.linearErrorY * erp;
  42299. var linRhsZ = this.linearErrorZ * erp;
  42300. var angRhsX = this.angularErrorX * erp;
  42301. var angRhsY = this.angularErrorY * erp;
  42302. var angRhsZ = this.angularErrorZ * erp;
  42303. var row;
  42304. var j;
  42305. var motorMass = 1 / (this._b1._invMass + this._b2._invMass);
  42306. if(this._sd.frequency <= 0 || !isPositionPart) {
  42307. var impulse = this._impulses[0];
  42308. var row1 = info.rows[info.numRows++];
  42309. var _this = row1.jacobian;
  42310. _this.lin1X = 0;
  42311. _this.lin1Y = 0;
  42312. _this.lin1Z = 0;
  42313. _this.lin2X = 0;
  42314. _this.lin2Y = 0;
  42315. _this.lin2Z = 0;
  42316. _this.ang1X = 0;
  42317. _this.ang1Y = 0;
  42318. _this.ang1Z = 0;
  42319. _this.ang2X = 0;
  42320. _this.ang2Y = 0;
  42321. _this.ang2Z = 0;
  42322. row1.rhs = 0;
  42323. row1.cfm = 0;
  42324. row1.minImpulse = 0;
  42325. row1.maxImpulse = 0;
  42326. row1.motorSpeed = 0;
  42327. row1.motorMaxImpulse = 0;
  42328. row1.impulse = null;
  42329. row1.impulse = impulse;
  42330. row = row1;
  42331. this.setSolverInfoRowLinear(row,this.translation,this._lm,motorMass,this._sd,timeStep,isPositionPart);
  42332. j = row.jacobian;
  42333. j.lin1X = this._basis.xX;
  42334. j.lin1Y = this._basis.xY;
  42335. j.lin1Z = this._basis.xZ;
  42336. j.lin2X = this._basis.xX;
  42337. j.lin2Y = this._basis.xY;
  42338. j.lin2Z = this._basis.xZ;
  42339. j.ang1X = this._relativeAnchor1Y * this._basis.xZ - this._relativeAnchor1Z * this._basis.xY;
  42340. j.ang1Y = this._relativeAnchor1Z * this._basis.xX - this._relativeAnchor1X * this._basis.xZ;
  42341. j.ang1Z = this._relativeAnchor1X * this._basis.xY - this._relativeAnchor1Y * this._basis.xX;
  42342. j.ang2X = this._relativeAnchor2Y * this._basis.xZ - this._relativeAnchor2Z * this._basis.xY;
  42343. j.ang2Y = this._relativeAnchor2Z * this._basis.xX - this._relativeAnchor2X * this._basis.xZ;
  42344. j.ang2Z = this._relativeAnchor2X * this._basis.xY - this._relativeAnchor2Y * this._basis.xX;
  42345. }
  42346. var impulse1 = this._impulses[1];
  42347. var row2 = info.rows[info.numRows++];
  42348. var _this1 = row2.jacobian;
  42349. _this1.lin1X = 0;
  42350. _this1.lin1Y = 0;
  42351. _this1.lin1Z = 0;
  42352. _this1.lin2X = 0;
  42353. _this1.lin2Y = 0;
  42354. _this1.lin2Z = 0;
  42355. _this1.ang1X = 0;
  42356. _this1.ang1Y = 0;
  42357. _this1.ang1Z = 0;
  42358. _this1.ang2X = 0;
  42359. _this1.ang2Y = 0;
  42360. _this1.ang2Z = 0;
  42361. row2.rhs = 0;
  42362. row2.cfm = 0;
  42363. row2.minImpulse = 0;
  42364. row2.maxImpulse = 0;
  42365. row2.motorSpeed = 0;
  42366. row2.motorMaxImpulse = 0;
  42367. row2.impulse = null;
  42368. row2.impulse = impulse1;
  42369. row = row2;
  42370. row.rhs = linRhsY;
  42371. row.cfm = 0;
  42372. row.minImpulse = -1e65536;
  42373. row.maxImpulse = 1e65536;
  42374. j = row.jacobian;
  42375. j.lin1X = this._basis.yX;
  42376. j.lin1Y = this._basis.yY;
  42377. j.lin1Z = this._basis.yZ;
  42378. j.lin2X = this._basis.yX;
  42379. j.lin2Y = this._basis.yY;
  42380. j.lin2Z = this._basis.yZ;
  42381. j.ang1X = this._relativeAnchor1Y * this._basis.yZ - this._relativeAnchor1Z * this._basis.yY;
  42382. j.ang1Y = this._relativeAnchor1Z * this._basis.yX - this._relativeAnchor1X * this._basis.yZ;
  42383. j.ang1Z = this._relativeAnchor1X * this._basis.yY - this._relativeAnchor1Y * this._basis.yX;
  42384. j.ang2X = this._relativeAnchor2Y * this._basis.yZ - this._relativeAnchor2Z * this._basis.yY;
  42385. j.ang2Y = this._relativeAnchor2Z * this._basis.yX - this._relativeAnchor2X * this._basis.yZ;
  42386. j.ang2Z = this._relativeAnchor2X * this._basis.yY - this._relativeAnchor2Y * this._basis.yX;
  42387. var impulse2 = this._impulses[2];
  42388. var row3 = info.rows[info.numRows++];
  42389. var _this2 = row3.jacobian;
  42390. _this2.lin1X = 0;
  42391. _this2.lin1Y = 0;
  42392. _this2.lin1Z = 0;
  42393. _this2.lin2X = 0;
  42394. _this2.lin2Y = 0;
  42395. _this2.lin2Z = 0;
  42396. _this2.ang1X = 0;
  42397. _this2.ang1Y = 0;
  42398. _this2.ang1Z = 0;
  42399. _this2.ang2X = 0;
  42400. _this2.ang2Y = 0;
  42401. _this2.ang2Z = 0;
  42402. row3.rhs = 0;
  42403. row3.cfm = 0;
  42404. row3.minImpulse = 0;
  42405. row3.maxImpulse = 0;
  42406. row3.motorSpeed = 0;
  42407. row3.motorMaxImpulse = 0;
  42408. row3.impulse = null;
  42409. row3.impulse = impulse2;
  42410. row = row3;
  42411. row.rhs = linRhsZ;
  42412. row.cfm = 0;
  42413. row.minImpulse = -1e65536;
  42414. row.maxImpulse = 1e65536;
  42415. j = row.jacobian;
  42416. j.lin1X = this._basis.zX;
  42417. j.lin1Y = this._basis.zY;
  42418. j.lin1Z = this._basis.zZ;
  42419. j.lin2X = this._basis.zX;
  42420. j.lin2Y = this._basis.zY;
  42421. j.lin2Z = this._basis.zZ;
  42422. j.ang1X = this._relativeAnchor1Y * this._basis.zZ - this._relativeAnchor1Z * this._basis.zY;
  42423. j.ang1Y = this._relativeAnchor1Z * this._basis.zX - this._relativeAnchor1X * this._basis.zZ;
  42424. j.ang1Z = this._relativeAnchor1X * this._basis.zY - this._relativeAnchor1Y * this._basis.zX;
  42425. j.ang2X = this._relativeAnchor2Y * this._basis.zZ - this._relativeAnchor2Z * this._basis.zY;
  42426. j.ang2Y = this._relativeAnchor2Z * this._basis.zX - this._relativeAnchor2X * this._basis.zZ;
  42427. j.ang2Z = this._relativeAnchor2X * this._basis.zY - this._relativeAnchor2Y * this._basis.zX;
  42428. var impulse3 = this._impulses[3];
  42429. var row4 = info.rows[info.numRows++];
  42430. var _this3 = row4.jacobian;
  42431. _this3.lin1X = 0;
  42432. _this3.lin1Y = 0;
  42433. _this3.lin1Z = 0;
  42434. _this3.lin2X = 0;
  42435. _this3.lin2Y = 0;
  42436. _this3.lin2Z = 0;
  42437. _this3.ang1X = 0;
  42438. _this3.ang1Y = 0;
  42439. _this3.ang1Z = 0;
  42440. _this3.ang2X = 0;
  42441. _this3.ang2Y = 0;
  42442. _this3.ang2Z = 0;
  42443. row4.rhs = 0;
  42444. row4.cfm = 0;
  42445. row4.minImpulse = 0;
  42446. row4.maxImpulse = 0;
  42447. row4.motorSpeed = 0;
  42448. row4.motorMaxImpulse = 0;
  42449. row4.impulse = null;
  42450. row4.impulse = impulse3;
  42451. row = row4;
  42452. row.rhs = angRhsX;
  42453. row.cfm = 0;
  42454. row.minImpulse = -1e65536;
  42455. row.maxImpulse = 1e65536;
  42456. j = row.jacobian;
  42457. j.ang1X = 1;
  42458. j.ang1Y = 0;
  42459. j.ang1Z = 0;
  42460. j.ang2X = 1;
  42461. j.ang2Y = 0;
  42462. j.ang2Z = 0;
  42463. var impulse4 = this._impulses[4];
  42464. var row5 = info.rows[info.numRows++];
  42465. var _this4 = row5.jacobian;
  42466. _this4.lin1X = 0;
  42467. _this4.lin1Y = 0;
  42468. _this4.lin1Z = 0;
  42469. _this4.lin2X = 0;
  42470. _this4.lin2Y = 0;
  42471. _this4.lin2Z = 0;
  42472. _this4.ang1X = 0;
  42473. _this4.ang1Y = 0;
  42474. _this4.ang1Z = 0;
  42475. _this4.ang2X = 0;
  42476. _this4.ang2Y = 0;
  42477. _this4.ang2Z = 0;
  42478. row5.rhs = 0;
  42479. row5.cfm = 0;
  42480. row5.minImpulse = 0;
  42481. row5.maxImpulse = 0;
  42482. row5.motorSpeed = 0;
  42483. row5.motorMaxImpulse = 0;
  42484. row5.impulse = null;
  42485. row5.impulse = impulse4;
  42486. row = row5;
  42487. row.rhs = angRhsY;
  42488. row.cfm = 0;
  42489. row.minImpulse = -1e65536;
  42490. row.maxImpulse = 1e65536;
  42491. j = row.jacobian;
  42492. j.ang1X = 0;
  42493. j.ang1Y = 1;
  42494. j.ang1Z = 0;
  42495. j.ang2X = 0;
  42496. j.ang2Y = 1;
  42497. j.ang2Z = 0;
  42498. var impulse5 = this._impulses[5];
  42499. var row6 = info.rows[info.numRows++];
  42500. var _this5 = row6.jacobian;
  42501. _this5.lin1X = 0;
  42502. _this5.lin1Y = 0;
  42503. _this5.lin1Z = 0;
  42504. _this5.lin2X = 0;
  42505. _this5.lin2Y = 0;
  42506. _this5.lin2Z = 0;
  42507. _this5.ang1X = 0;
  42508. _this5.ang1Y = 0;
  42509. _this5.ang1Z = 0;
  42510. _this5.ang2X = 0;
  42511. _this5.ang2Y = 0;
  42512. _this5.ang2Z = 0;
  42513. row6.rhs = 0;
  42514. row6.cfm = 0;
  42515. row6.minImpulse = 0;
  42516. row6.maxImpulse = 0;
  42517. row6.motorSpeed = 0;
  42518. row6.motorMaxImpulse = 0;
  42519. row6.impulse = null;
  42520. row6.impulse = impulse5;
  42521. row = row6;
  42522. row.rhs = angRhsZ;
  42523. row.cfm = 0;
  42524. row.minImpulse = -1e65536;
  42525. row.maxImpulse = 1e65536;
  42526. j = row.jacobian;
  42527. j.ang1X = 0;
  42528. j.ang1Y = 0;
  42529. j.ang1Z = 1;
  42530. j.ang2X = 0;
  42531. j.ang2Y = 0;
  42532. j.ang2Z = 1;
  42533. }
  42534. _syncAnchors() {
  42535. super._syncAnchors();
  42536. var _this = this._basis;
  42537. var invM1 = _this.joint._b1._invMass;
  42538. var invM2 = _this.joint._b2._invMass;
  42539. var q;
  42540. var qX;
  42541. var qY;
  42542. var qZ;
  42543. var qW;
  42544. var idQ;
  42545. var idQX;
  42546. var idQY;
  42547. var idQZ;
  42548. var idQW;
  42549. var slerpQ;
  42550. var slerpQX;
  42551. var slerpQY;
  42552. var slerpQZ;
  42553. var slerpQW;
  42554. var slerpM;
  42555. var slerpM00;
  42556. var slerpM01;
  42557. var slerpM02;
  42558. var slerpM10;
  42559. var slerpM11;
  42560. var slerpM12;
  42561. var slerpM20;
  42562. var slerpM21;
  42563. var slerpM22;
  42564. var newX;
  42565. var newXX;
  42566. var newXY;
  42567. var newXZ;
  42568. var newY;
  42569. var newYX;
  42570. var newYY;
  42571. var newYZ;
  42572. var newZ;
  42573. var newZX;
  42574. var newZY;
  42575. var newZZ;
  42576. var prevX;
  42577. var prevXX;
  42578. var prevXY;
  42579. var prevXZ;
  42580. var prevY;
  42581. var prevYX;
  42582. var prevYY;
  42583. var prevYZ;
  42584. var d = _this.joint._basisX1X * _this.joint._basisX2X + _this.joint._basisX1Y * _this.joint._basisX2Y + _this.joint._basisX1Z * _this.joint._basisX2Z;
  42585. if(d < -0.999999999) {
  42586. var vX;
  42587. var vY;
  42588. var vZ;
  42589. var x1 = _this.joint._basisX1X;
  42590. var y1 = _this.joint._basisX1Y;
  42591. var z1 = _this.joint._basisX1Z;
  42592. var x2 = x1 * x1;
  42593. var y2 = y1 * y1;
  42594. var z2 = z1 * z1;
  42595. var d1;
  42596. if(x2 < y2) {
  42597. if(x2 < z2) {
  42598. d1 = 1 / Math.sqrt(y2 + z2);
  42599. vX = 0;
  42600. vY = z1 * d1;
  42601. vZ = -y1 * d1;
  42602. } else {
  42603. d1 = 1 / Math.sqrt(x2 + y2);
  42604. vX = y1 * d1;
  42605. vY = -x1 * d1;
  42606. vZ = 0;
  42607. }
  42608. } else if(y2 < z2) {
  42609. d1 = 1 / Math.sqrt(z2 + x2);
  42610. vX = -z1 * d1;
  42611. vY = 0;
  42612. vZ = x1 * d1;
  42613. } else {
  42614. d1 = 1 / Math.sqrt(x2 + y2);
  42615. vX = y1 * d1;
  42616. vY = -x1 * d1;
  42617. vZ = 0;
  42618. }
  42619. qX = vX;
  42620. qY = vY;
  42621. qZ = vZ;
  42622. qW = 0;
  42623. } else {
  42624. var cX;
  42625. var cY;
  42626. var cZ;
  42627. cX = _this.joint._basisX1Y * _this.joint._basisX2Z - _this.joint._basisX1Z * _this.joint._basisX2Y;
  42628. cY = _this.joint._basisX1Z * _this.joint._basisX2X - _this.joint._basisX1X * _this.joint._basisX2Z;
  42629. cZ = _this.joint._basisX1X * _this.joint._basisX2Y - _this.joint._basisX1Y * _this.joint._basisX2X;
  42630. var w = Math.sqrt((1 + d) * 0.5);
  42631. d = 0.5 / w;
  42632. cX *= d;
  42633. cY *= d;
  42634. cZ *= d;
  42635. qX = cX;
  42636. qY = cY;
  42637. qZ = cZ;
  42638. qW = w;
  42639. }
  42640. idQX = 0;
  42641. idQY = 0;
  42642. idQZ = 0;
  42643. idQW = 1;
  42644. var qx;
  42645. var qy;
  42646. var qz;
  42647. var qw;
  42648. var q1X;
  42649. var q1Y;
  42650. var q1Z;
  42651. var q1W;
  42652. var q2X;
  42653. var q2Y;
  42654. var q2Z;
  42655. var q2W;
  42656. q1X = idQX;
  42657. q1Y = idQY;
  42658. q1Z = idQZ;
  42659. q1W = idQW;
  42660. q2X = qX;
  42661. q2Y = qY;
  42662. q2Z = qZ;
  42663. q2W = qW;
  42664. var d2 = q1X * q2X + q1Y * q2Y + q1Z * q2Z + q1W * q2W;
  42665. if(d2 < 0) {
  42666. d2 = -d2;
  42667. q2X = -q2X;
  42668. q2Y = -q2Y;
  42669. q2Z = -q2Z;
  42670. q2W = -q2W;
  42671. }
  42672. if(d2 > 0.999999) {
  42673. var dqX;
  42674. var dqY;
  42675. var dqZ;
  42676. var dqW;
  42677. dqX = q2X - q1X;
  42678. dqY = q2Y - q1Y;
  42679. dqZ = q2Z - q1Z;
  42680. dqW = q2W - q1W;
  42681. q2X = q1X + dqX * (invM1 / (invM1 + invM2));
  42682. q2Y = q1Y + dqY * (invM1 / (invM1 + invM2));
  42683. q2Z = q1Z + dqZ * (invM1 / (invM1 + invM2));
  42684. q2W = q1W + dqW * (invM1 / (invM1 + invM2));
  42685. var l = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W;
  42686. if(l > 1e-32) {
  42687. l = 1 / Math.sqrt(l);
  42688. }
  42689. slerpQX = q2X * l;
  42690. slerpQY = q2Y * l;
  42691. slerpQZ = q2Z * l;
  42692. slerpQW = q2W * l;
  42693. } else {
  42694. var theta = invM1 / (invM1 + invM2) * Math.acos(d2);
  42695. q2X += q1X * -d2;
  42696. q2Y += q1Y * -d2;
  42697. q2Z += q1Z * -d2;
  42698. q2W += q1W * -d2;
  42699. var l1 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W;
  42700. if(l1 > 1e-32) {
  42701. l1 = 1 / Math.sqrt(l1);
  42702. }
  42703. q2X *= l1;
  42704. q2Y *= l1;
  42705. q2Z *= l1;
  42706. q2W *= l1;
  42707. var sin = Math.sin(theta);
  42708. var cos = Math.cos(theta);
  42709. q1X *= cos;
  42710. q1Y *= cos;
  42711. q1Z *= cos;
  42712. q1W *= cos;
  42713. slerpQX = q1X + q2X * sin;
  42714. slerpQY = q1Y + q2Y * sin;
  42715. slerpQZ = q1Z + q2Z * sin;
  42716. slerpQW = q1W + q2W * sin;
  42717. }
  42718. var x = slerpQX;
  42719. var y = slerpQY;
  42720. var z = slerpQZ;
  42721. var w1 = slerpQW;
  42722. var x21 = 2 * x;
  42723. var y21 = 2 * y;
  42724. var z21 = 2 * z;
  42725. var xx = x * x21;
  42726. var yy = y * y21;
  42727. var zz = z * z21;
  42728. var xy = x * y21;
  42729. var yz = y * z21;
  42730. var xz = x * z21;
  42731. var wx = w1 * x21;
  42732. var wy = w1 * y21;
  42733. var wz = w1 * z21;
  42734. slerpM00 = 1 - yy - zz;
  42735. slerpM01 = xy - wz;
  42736. slerpM02 = xz + wy;
  42737. slerpM10 = xy + wz;
  42738. slerpM11 = 1 - xx - zz;
  42739. slerpM12 = yz - wx;
  42740. slerpM20 = xz - wy;
  42741. slerpM21 = yz + wx;
  42742. slerpM22 = 1 - xx - yy;
  42743. var __tmp__X;
  42744. var __tmp__Y;
  42745. var __tmp__Z;
  42746. __tmp__X = slerpM00 * _this.joint._basisX1X + slerpM01 * _this.joint._basisX1Y + slerpM02 * _this.joint._basisX1Z;
  42747. __tmp__Y = slerpM10 * _this.joint._basisX1X + slerpM11 * _this.joint._basisX1Y + slerpM12 * _this.joint._basisX1Z;
  42748. __tmp__Z = slerpM20 * _this.joint._basisX1X + slerpM21 * _this.joint._basisX1Y + slerpM22 * _this.joint._basisX1Z;
  42749. newXX = __tmp__X;
  42750. newXY = __tmp__Y;
  42751. newXZ = __tmp__Z;
  42752. prevXX = _this.xX;
  42753. prevXY = _this.xY;
  42754. prevXZ = _this.xZ;
  42755. prevYX = _this.yX;
  42756. prevYY = _this.yY;
  42757. prevYZ = _this.yZ;
  42758. var d3 = prevXX * newXX + prevXY * newXY + prevXZ * newXZ;
  42759. if(d3 < -0.999999999) {
  42760. var vX1;
  42761. var vY1;
  42762. var vZ1;
  42763. var x11 = prevXX;
  42764. var y11 = prevXY;
  42765. var z11 = prevXZ;
  42766. var x22 = x11 * x11;
  42767. var y22 = y11 * y11;
  42768. var z22 = z11 * z11;
  42769. var d4;
  42770. if(x22 < y22) {
  42771. if(x22 < z22) {
  42772. d4 = 1 / Math.sqrt(y22 + z22);
  42773. vX1 = 0;
  42774. vY1 = z11 * d4;
  42775. vZ1 = -y11 * d4;
  42776. } else {
  42777. d4 = 1 / Math.sqrt(x22 + y22);
  42778. vX1 = y11 * d4;
  42779. vY1 = -x11 * d4;
  42780. vZ1 = 0;
  42781. }
  42782. } else if(y22 < z22) {
  42783. d4 = 1 / Math.sqrt(z22 + x22);
  42784. vX1 = -z11 * d4;
  42785. vY1 = 0;
  42786. vZ1 = x11 * d4;
  42787. } else {
  42788. d4 = 1 / Math.sqrt(x22 + y22);
  42789. vX1 = y11 * d4;
  42790. vY1 = -x11 * d4;
  42791. vZ1 = 0;
  42792. }
  42793. slerpQX = vX1;
  42794. slerpQY = vY1;
  42795. slerpQZ = vZ1;
  42796. slerpQW = 0;
  42797. } else {
  42798. var cX1;
  42799. var cY1;
  42800. var cZ1;
  42801. cX1 = prevXY * newXZ - prevXZ * newXY;
  42802. cY1 = prevXZ * newXX - prevXX * newXZ;
  42803. cZ1 = prevXX * newXY - prevXY * newXX;
  42804. var w2 = Math.sqrt((1 + d3) * 0.5);
  42805. d3 = 0.5 / w2;
  42806. cX1 *= d3;
  42807. cY1 *= d3;
  42808. cZ1 *= d3;
  42809. slerpQX = cX1;
  42810. slerpQY = cY1;
  42811. slerpQZ = cZ1;
  42812. slerpQW = w2;
  42813. }
  42814. var x3 = slerpQX;
  42815. var y3 = slerpQY;
  42816. var z3 = slerpQZ;
  42817. var w3 = slerpQW;
  42818. var x23 = 2 * x3;
  42819. var y23 = 2 * y3;
  42820. var z23 = 2 * z3;
  42821. var xx1 = x3 * x23;
  42822. var yy1 = y3 * y23;
  42823. var zz1 = z3 * z23;
  42824. var xy1 = x3 * y23;
  42825. var yz1 = y3 * z23;
  42826. var xz1 = x3 * z23;
  42827. var wx1 = w3 * x23;
  42828. var wy1 = w3 * y23;
  42829. var wz1 = w3 * z23;
  42830. slerpM00 = 1 - yy1 - zz1;
  42831. slerpM01 = xy1 - wz1;
  42832. slerpM02 = xz1 + wy1;
  42833. slerpM10 = xy1 + wz1;
  42834. slerpM11 = 1 - xx1 - zz1;
  42835. slerpM12 = yz1 - wx1;
  42836. slerpM20 = xz1 - wy1;
  42837. slerpM21 = yz1 + wx1;
  42838. slerpM22 = 1 - xx1 - yy1;
  42839. var __tmp__X1;
  42840. var __tmp__Y1;
  42841. var __tmp__Z1;
  42842. __tmp__X1 = slerpM00 * prevYX + slerpM01 * prevYY + slerpM02 * prevYZ;
  42843. __tmp__Y1 = slerpM10 * prevYX + slerpM11 * prevYY + slerpM12 * prevYZ;
  42844. __tmp__Z1 = slerpM20 * prevYX + slerpM21 * prevYY + slerpM22 * prevYZ;
  42845. newYX = __tmp__X1;
  42846. newYY = __tmp__Y1;
  42847. newYZ = __tmp__Z1;
  42848. newZX = newXY * newYZ - newXZ * newYY;
  42849. newZY = newXZ * newYX - newXX * newYZ;
  42850. newZZ = newXX * newYY - newXY * newYX;
  42851. if(newZX * newZX + newZY * newZY + newZZ * newZZ > 1e-6) {
  42852. var l2 = newZX * newZX + newZY * newZY + newZZ * newZZ;
  42853. if(l2 > 0) {
  42854. l2 = 1 / Math.sqrt(l2);
  42855. }
  42856. newZX *= l2;
  42857. newZY *= l2;
  42858. newZZ *= l2;
  42859. } else {
  42860. var x12 = newXX;
  42861. var y12 = newXY;
  42862. var z12 = newXZ;
  42863. var x24 = x12 * x12;
  42864. var y24 = y12 * y12;
  42865. var z24 = z12 * z12;
  42866. var d5;
  42867. if(x24 < y24) {
  42868. if(x24 < z24) {
  42869. d5 = 1 / Math.sqrt(y24 + z24);
  42870. newZX = 0;
  42871. newZY = z12 * d5;
  42872. newZZ = -y12 * d5;
  42873. } else {
  42874. d5 = 1 / Math.sqrt(x24 + y24);
  42875. newZX = y12 * d5;
  42876. newZY = -x12 * d5;
  42877. newZZ = 0;
  42878. }
  42879. } else if(y24 < z24) {
  42880. d5 = 1 / Math.sqrt(z24 + x24);
  42881. newZX = -z12 * d5;
  42882. newZY = 0;
  42883. newZZ = x12 * d5;
  42884. } else {
  42885. d5 = 1 / Math.sqrt(x24 + y24);
  42886. newZX = y12 * d5;
  42887. newZY = -x12 * d5;
  42888. newZZ = 0;
  42889. }
  42890. }
  42891. newYX = newZY * newXZ - newZZ * newXY;
  42892. newYY = newZZ * newXX - newZX * newXZ;
  42893. newYZ = newZX * newXY - newZY * newXX;
  42894. _this.xX = newXX;
  42895. _this.xY = newXY;
  42896. _this.xZ = newXZ;
  42897. _this.yX = newYX;
  42898. _this.yY = newYY;
  42899. _this.yZ = newYZ;
  42900. _this.zX = newZX;
  42901. _this.zY = newZY;
  42902. _this.zZ = newZZ;
  42903. var rot1;
  42904. var rot100;
  42905. var rot101;
  42906. var rot102;
  42907. var rot110;
  42908. var rot111;
  42909. var rot112;
  42910. var rot120;
  42911. var rot121;
  42912. var rot122;
  42913. var rot2;
  42914. var rot200;
  42915. var rot201;
  42916. var rot202;
  42917. var rot210;
  42918. var rot211;
  42919. var rot212;
  42920. var rot220;
  42921. var rot221;
  42922. var rot222;
  42923. rot100 = this._basisX1X;
  42924. rot101 = this._basisY1X;
  42925. rot102 = this._basisZ1X;
  42926. rot110 = this._basisX1Y;
  42927. rot111 = this._basisY1Y;
  42928. rot112 = this._basisZ1Y;
  42929. rot120 = this._basisX1Z;
  42930. rot121 = this._basisY1Z;
  42931. rot122 = this._basisZ1Z;
  42932. rot200 = this._basisX2X;
  42933. rot201 = this._basisY2X;
  42934. rot202 = this._basisZ2X;
  42935. rot210 = this._basisX2Y;
  42936. rot211 = this._basisY2Y;
  42937. rot212 = this._basisZ2Y;
  42938. rot220 = this._basisX2Z;
  42939. rot221 = this._basisY2Z;
  42940. rot222 = this._basisZ2Z;
  42941. var relRot;
  42942. var relRot00;
  42943. var relRot01;
  42944. var relRot02;
  42945. var relRot10;
  42946. var relRot11;
  42947. var relRot12;
  42948. var relRot20;
  42949. var relRot21;
  42950. var relRot22;
  42951. var __tmp__00;
  42952. var __tmp__01;
  42953. var __tmp__02;
  42954. var __tmp__10;
  42955. var __tmp__11;
  42956. var __tmp__12;
  42957. var __tmp__20;
  42958. var __tmp__21;
  42959. var __tmp__22;
  42960. __tmp__00 = rot200 * rot100 + rot201 * rot101 + rot202 * rot102;
  42961. __tmp__01 = rot200 * rot110 + rot201 * rot111 + rot202 * rot112;
  42962. __tmp__02 = rot200 * rot120 + rot201 * rot121 + rot202 * rot122;
  42963. __tmp__10 = rot210 * rot100 + rot211 * rot101 + rot212 * rot102;
  42964. __tmp__11 = rot210 * rot110 + rot211 * rot111 + rot212 * rot112;
  42965. __tmp__12 = rot210 * rot120 + rot211 * rot121 + rot212 * rot122;
  42966. __tmp__20 = rot220 * rot100 + rot221 * rot101 + rot222 * rot102;
  42967. __tmp__21 = rot220 * rot110 + rot221 * rot111 + rot222 * rot112;
  42968. __tmp__22 = rot220 * rot120 + rot221 * rot121 + rot222 * rot122;
  42969. relRot00 = __tmp__00;
  42970. relRot01 = __tmp__01;
  42971. relRot02 = __tmp__02;
  42972. relRot10 = __tmp__10;
  42973. relRot11 = __tmp__11;
  42974. relRot12 = __tmp__12;
  42975. relRot20 = __tmp__20;
  42976. relRot21 = __tmp__21;
  42977. relRot22 = __tmp__22;
  42978. var relQ;
  42979. var relQX;
  42980. var relQY;
  42981. var relQZ;
  42982. var relQW;
  42983. var e00 = relRot00;
  42984. var e11 = relRot11;
  42985. var e22 = relRot22;
  42986. var t = e00 + e11 + e22;
  42987. var s;
  42988. if(t > 0) {
  42989. s = Math.sqrt(t + 1);
  42990. relQW = 0.5 * s;
  42991. s = 0.5 / s;
  42992. relQX = (relRot21 - relRot12) * s;
  42993. relQY = (relRot02 - relRot20) * s;
  42994. relQZ = (relRot10 - relRot01) * s;
  42995. } else if(e00 > e11) {
  42996. if(e00 > e22) {
  42997. s = Math.sqrt(e00 - e11 - e22 + 1);
  42998. relQX = 0.5 * s;
  42999. s = 0.5 / s;
  43000. relQY = (relRot01 + relRot10) * s;
  43001. relQZ = (relRot02 + relRot20) * s;
  43002. relQW = (relRot21 - relRot12) * s;
  43003. } else {
  43004. s = Math.sqrt(e22 - e00 - e11 + 1);
  43005. relQZ = 0.5 * s;
  43006. s = 0.5 / s;
  43007. relQX = (relRot02 + relRot20) * s;
  43008. relQY = (relRot12 + relRot21) * s;
  43009. relQW = (relRot10 - relRot01) * s;
  43010. }
  43011. } else if(e11 > e22) {
  43012. s = Math.sqrt(e11 - e22 - e00 + 1);
  43013. relQY = 0.5 * s;
  43014. s = 0.5 / s;
  43015. relQX = (relRot01 + relRot10) * s;
  43016. relQZ = (relRot12 + relRot21) * s;
  43017. relQW = (relRot02 - relRot20) * s;
  43018. } else {
  43019. s = Math.sqrt(e22 - e00 - e11 + 1);
  43020. relQZ = 0.5 * s;
  43021. s = 0.5 / s;
  43022. relQX = (relRot02 + relRot20) * s;
  43023. relQY = (relRot12 + relRot21) * s;
  43024. relQW = (relRot10 - relRot01) * s;
  43025. }
  43026. var cosHalfTheta = relQW;
  43027. var theta1 = (cosHalfTheta <= -1 ? 3.14159265358979 : cosHalfTheta >= 1 ? 0 : Math.acos(cosHalfTheta)) * 2;
  43028. this.angularErrorX = relQX;
  43029. this.angularErrorY = relQY;
  43030. this.angularErrorZ = relQZ;
  43031. var l3 = this.angularErrorX * this.angularErrorX + this.angularErrorY * this.angularErrorY + this.angularErrorZ * this.angularErrorZ;
  43032. if(l3 > 0) {
  43033. l3 = 1 / Math.sqrt(l3);
  43034. }
  43035. this.angularErrorX *= l3;
  43036. this.angularErrorY *= l3;
  43037. this.angularErrorZ *= l3;
  43038. this.angularErrorX *= theta1;
  43039. this.angularErrorY *= theta1;
  43040. this.angularErrorZ *= theta1;
  43041. var anchorDiff;
  43042. var anchorDiffX;
  43043. var anchorDiffY;
  43044. var anchorDiffZ;
  43045. anchorDiffX = this._anchor2X - this._anchor1X;
  43046. anchorDiffY = this._anchor2Y - this._anchor1Y;
  43047. anchorDiffZ = this._anchor2Z - this._anchor1Z;
  43048. this.translation = anchorDiffX * this._basis.xX + anchorDiffY * this._basis.xY + anchorDiffZ * this._basis.xZ;
  43049. this.linearErrorY = anchorDiffX * this._basis.yX + anchorDiffY * this._basis.yY + anchorDiffZ * this._basis.yZ;
  43050. this.linearErrorZ = anchorDiffX * this._basis.zX + anchorDiffY * this._basis.zY + anchorDiffZ * this._basis.zZ;
  43051. }
  43052. _getVelocitySolverInfo(timeStep,info) {
  43053. super._getVelocitySolverInfo(timeStep,info);
  43054. this.getInfo(info,timeStep,false);
  43055. }
  43056. _getPositionSolverInfo(info) {
  43057. super._getPositionSolverInfo(info);
  43058. this.getInfo(info,null,true);
  43059. }
  43060. getAxis1() {
  43061. var v = new oimo.common.Vec3();
  43062. var v1 = v;
  43063. v1.x = this._basisX1X;
  43064. v1.y = this._basisX1Y;
  43065. v1.z = this._basisX1Z;
  43066. return v;
  43067. }
  43068. getAxis2() {
  43069. var v = new oimo.common.Vec3();
  43070. var v1 = v;
  43071. v1.x = this._basisX2X;
  43072. v1.y = this._basisX2Y;
  43073. v1.z = this._basisX2Z;
  43074. return v;
  43075. }
  43076. getAxis1To(axis) {
  43077. var v = axis;
  43078. v.x = this._basisX1X;
  43079. v.y = this._basisX1Y;
  43080. v.z = this._basisX1Z;
  43081. }
  43082. getAxis2To(axis) {
  43083. var v = axis;
  43084. v.x = this._basisX2X;
  43085. v.y = this._basisX2Y;
  43086. v.z = this._basisX2Z;
  43087. }
  43088. getLocalAxis1() {
  43089. var v = new oimo.common.Vec3();
  43090. var v1 = v;
  43091. v1.x = this._localBasisX1X;
  43092. v1.y = this._localBasisX1Y;
  43093. v1.z = this._localBasisX1Z;
  43094. return v;
  43095. }
  43096. getLocalAxis2() {
  43097. var v = new oimo.common.Vec3();
  43098. var v1 = v;
  43099. v1.x = this._localBasisX2X;
  43100. v1.y = this._localBasisX2Y;
  43101. v1.z = this._localBasisX2Z;
  43102. return v;
  43103. }
  43104. getLocalAxis1To(axis) {
  43105. var v = axis;
  43106. v.x = this._localBasisX1X;
  43107. v.y = this._localBasisX1Y;
  43108. v.z = this._localBasisX1Z;
  43109. }
  43110. getLocalAxis2To(axis) {
  43111. var v = axis;
  43112. v.x = this._localBasisX2X;
  43113. v.y = this._localBasisX2Y;
  43114. v.z = this._localBasisX2Z;
  43115. }
  43116. getSpringDamper() {
  43117. return this._sd;
  43118. }
  43119. getLimitMotor() {
  43120. return this._lm;
  43121. }
  43122. getTranslation() {
  43123. return this.translation;
  43124. }
  43125. }
  43126. oimo.dynamics.constraint.joint.PrismaticJointConfig = class oimo_dynamics_constraint_joint_PrismaticJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  43127. constructor() {
  43128. super();
  43129. this.localAxis1 = new oimo.common.Vec3(1,0,0);
  43130. this.localAxis2 = new oimo.common.Vec3(1,0,0);
  43131. this.limitMotor = new oimo.dynamics.constraint.joint.TranslationalLimitMotor();
  43132. this.springDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  43133. }
  43134. init(rigidBody1,rigidBody2,worldAnchor,worldAxis) {
  43135. this._init(rigidBody1,rigidBody2,worldAnchor);
  43136. var v;
  43137. var vX;
  43138. var vY;
  43139. var vZ;
  43140. var v1 = worldAxis;
  43141. vX = v1.x;
  43142. vY = v1.y;
  43143. vZ = v1.z;
  43144. var __tmp__X;
  43145. var __tmp__Y;
  43146. var __tmp__Z;
  43147. __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ;
  43148. __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ;
  43149. __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ;
  43150. vX = __tmp__X;
  43151. vY = __tmp__Y;
  43152. vZ = __tmp__Z;
  43153. var v2 = this.localAxis1;
  43154. v2.x = vX;
  43155. v2.y = vY;
  43156. v2.z = vZ;
  43157. var v3;
  43158. var vX1;
  43159. var vY1;
  43160. var vZ1;
  43161. var v4 = worldAxis;
  43162. vX1 = v4.x;
  43163. vY1 = v4.y;
  43164. vZ1 = v4.z;
  43165. var __tmp__X1;
  43166. var __tmp__Y1;
  43167. var __tmp__Z1;
  43168. __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1;
  43169. __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1;
  43170. __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1;
  43171. vX1 = __tmp__X1;
  43172. vY1 = __tmp__Y1;
  43173. vZ1 = __tmp__Z1;
  43174. var v5 = this.localAxis2;
  43175. v5.x = vX1;
  43176. v5.y = vY1;
  43177. v5.z = vZ1;
  43178. return this;
  43179. }
  43180. }
  43181. oimo.dynamics.constraint.joint.RagdollJoint = class oimo_dynamics_constraint_joint_RagdollJoint extends oimo.dynamics.constraint.joint.Joint {
  43182. constructor(config) {
  43183. super(config,oimo.dynamics.constraint.joint.JointType.RAGDOLL);
  43184. var v = config.localTwistAxis1;
  43185. this._localBasisX1X = v.x;
  43186. this._localBasisX1Y = v.y;
  43187. this._localBasisX1Z = v.z;
  43188. var v1 = config.localSwingAxis1;
  43189. this._localBasisY1X = v1.x;
  43190. this._localBasisY1Y = v1.y;
  43191. this._localBasisY1Z = v1.z;
  43192. var v2 = config.localTwistAxis2;
  43193. this._localBasisX2X = v2.x;
  43194. this._localBasisX2Y = v2.y;
  43195. this._localBasisX2Z = v2.z;
  43196. this.buildLocalBasesFromXY1X2();
  43197. this._twistSd = config.twistSpringDamper.clone();
  43198. this._twistLm = config.twistLimitMotor.clone();
  43199. this._swingSd = config.swingSpringDamper.clone();
  43200. this._maxSwingAngle1 = config.maxSwingAngle1;
  43201. this._maxSwingAngle2 = config.maxSwingAngle2;
  43202. if(this._maxSwingAngle1 < oimo.common.Setting.minRagdollMaxSwingAngle) {
  43203. this._maxSwingAngle1 = oimo.common.Setting.minRagdollMaxSwingAngle;
  43204. }
  43205. if(this._maxSwingAngle2 < oimo.common.Setting.minRagdollMaxSwingAngle) {
  43206. this._maxSwingAngle2 = oimo.common.Setting.minRagdollMaxSwingAngle;
  43207. }
  43208. this.dummySwingLm = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  43209. this.dummySwingLm.lowerLimit = -1;
  43210. this.dummySwingLm.upperLimit = 0;
  43211. this._swingAngle = 0;
  43212. this._twistAngle = 0;
  43213. this.swingError = 0;
  43214. this.swingAxisX = 0;
  43215. this.swingAxisY = 0;
  43216. this.swingAxisZ = 0;
  43217. this.twistAxisX = 0;
  43218. this.twistAxisY = 0;
  43219. this.twistAxisZ = 0;
  43220. }
  43221. getInfo(info,timeStep,isPositionPart) {
  43222. var erp = this.getErp(timeStep,isPositionPart);
  43223. var linearRhs;
  43224. var linearRhsX;
  43225. var linearRhsY;
  43226. var linearRhsZ;
  43227. linearRhsX = this.linearErrorX * erp;
  43228. linearRhsY = this.linearErrorY * erp;
  43229. linearRhsZ = this.linearErrorZ * erp;
  43230. var linRhsX = linearRhsX;
  43231. var linRhsY = linearRhsY;
  43232. var linRhsZ = linearRhsZ;
  43233. var crossR1;
  43234. var crossR100;
  43235. var crossR101;
  43236. var crossR102;
  43237. var crossR110;
  43238. var crossR111;
  43239. var crossR112;
  43240. var crossR120;
  43241. var crossR121;
  43242. var crossR122;
  43243. var crossR2;
  43244. var crossR200;
  43245. var crossR201;
  43246. var crossR202;
  43247. var crossR210;
  43248. var crossR211;
  43249. var crossR212;
  43250. var crossR220;
  43251. var crossR221;
  43252. var crossR222;
  43253. crossR100 = 0;
  43254. crossR101 = -this._relativeAnchor1Z;
  43255. crossR102 = this._relativeAnchor1Y;
  43256. crossR110 = this._relativeAnchor1Z;
  43257. crossR111 = 0;
  43258. crossR112 = -this._relativeAnchor1X;
  43259. crossR120 = -this._relativeAnchor1Y;
  43260. crossR121 = this._relativeAnchor1X;
  43261. crossR122 = 0;
  43262. crossR200 = 0;
  43263. crossR201 = -this._relativeAnchor2Z;
  43264. crossR202 = this._relativeAnchor2Y;
  43265. crossR210 = this._relativeAnchor2Z;
  43266. crossR211 = 0;
  43267. crossR212 = -this._relativeAnchor2X;
  43268. crossR220 = -this._relativeAnchor2Y;
  43269. crossR221 = this._relativeAnchor2X;
  43270. crossR222 = 0;
  43271. crossR100 = -crossR100;
  43272. crossR101 = -crossR101;
  43273. crossR102 = -crossR102;
  43274. crossR110 = -crossR110;
  43275. crossR111 = -crossR111;
  43276. crossR112 = -crossR112;
  43277. crossR120 = -crossR120;
  43278. crossR121 = -crossR121;
  43279. crossR122 = -crossR122;
  43280. crossR200 = -crossR200;
  43281. crossR201 = -crossR201;
  43282. crossR202 = -crossR202;
  43283. crossR210 = -crossR210;
  43284. crossR211 = -crossR211;
  43285. crossR212 = -crossR212;
  43286. crossR220 = -crossR220;
  43287. crossR221 = -crossR221;
  43288. crossR222 = -crossR222;
  43289. var swingMass = this.computeEffectiveInertiaMoment(this.swingAxisX,this.swingAxisY,this.swingAxisZ);
  43290. var twistMass = this.computeEffectiveInertiaMoment(this._basisX2X,this._basisX2Y,this._basisX2Z);
  43291. var impulse = this._impulses[0];
  43292. var row = info.rows[info.numRows++];
  43293. var _this = row.jacobian;
  43294. _this.lin1X = 0;
  43295. _this.lin1Y = 0;
  43296. _this.lin1Z = 0;
  43297. _this.lin2X = 0;
  43298. _this.lin2Y = 0;
  43299. _this.lin2Z = 0;
  43300. _this.ang1X = 0;
  43301. _this.ang1Y = 0;
  43302. _this.ang1Z = 0;
  43303. _this.ang2X = 0;
  43304. _this.ang2Y = 0;
  43305. _this.ang2Z = 0;
  43306. row.rhs = 0;
  43307. row.cfm = 0;
  43308. row.minImpulse = 0;
  43309. row.maxImpulse = 0;
  43310. row.motorSpeed = 0;
  43311. row.motorMaxImpulse = 0;
  43312. row.impulse = null;
  43313. row.impulse = impulse;
  43314. var row1 = row;
  43315. row1.rhs = linRhsX;
  43316. row1.cfm = 0;
  43317. row1.minImpulse = -1e65536;
  43318. row1.maxImpulse = 1e65536;
  43319. var j = row1.jacobian;
  43320. j.lin1X = 1;
  43321. j.lin1Y = 0;
  43322. j.lin1Z = 0;
  43323. j.lin2X = 1;
  43324. j.lin2Y = 0;
  43325. j.lin2Z = 0;
  43326. j.ang1X = crossR100;
  43327. j.ang1Y = crossR101;
  43328. j.ang1Z = crossR102;
  43329. j.ang2X = crossR200;
  43330. j.ang2Y = crossR201;
  43331. j.ang2Z = crossR202;
  43332. var impulse1 = this._impulses[1];
  43333. var row2 = info.rows[info.numRows++];
  43334. var _this1 = row2.jacobian;
  43335. _this1.lin1X = 0;
  43336. _this1.lin1Y = 0;
  43337. _this1.lin1Z = 0;
  43338. _this1.lin2X = 0;
  43339. _this1.lin2Y = 0;
  43340. _this1.lin2Z = 0;
  43341. _this1.ang1X = 0;
  43342. _this1.ang1Y = 0;
  43343. _this1.ang1Z = 0;
  43344. _this1.ang2X = 0;
  43345. _this1.ang2Y = 0;
  43346. _this1.ang2Z = 0;
  43347. row2.rhs = 0;
  43348. row2.cfm = 0;
  43349. row2.minImpulse = 0;
  43350. row2.maxImpulse = 0;
  43351. row2.motorSpeed = 0;
  43352. row2.motorMaxImpulse = 0;
  43353. row2.impulse = null;
  43354. row2.impulse = impulse1;
  43355. row1 = row2;
  43356. row1.rhs = linRhsY;
  43357. row1.cfm = 0;
  43358. row1.minImpulse = -1e65536;
  43359. row1.maxImpulse = 1e65536;
  43360. j = row1.jacobian;
  43361. j.lin1X = 0;
  43362. j.lin1Y = 1;
  43363. j.lin1Z = 0;
  43364. j.lin2X = 0;
  43365. j.lin2Y = 1;
  43366. j.lin2Z = 0;
  43367. j.ang1X = crossR110;
  43368. j.ang1Y = crossR111;
  43369. j.ang1Z = crossR112;
  43370. j.ang2X = crossR210;
  43371. j.ang2Y = crossR211;
  43372. j.ang2Z = crossR212;
  43373. var impulse2 = this._impulses[2];
  43374. var row3 = info.rows[info.numRows++];
  43375. var _this2 = row3.jacobian;
  43376. _this2.lin1X = 0;
  43377. _this2.lin1Y = 0;
  43378. _this2.lin1Z = 0;
  43379. _this2.lin2X = 0;
  43380. _this2.lin2Y = 0;
  43381. _this2.lin2Z = 0;
  43382. _this2.ang1X = 0;
  43383. _this2.ang1Y = 0;
  43384. _this2.ang1Z = 0;
  43385. _this2.ang2X = 0;
  43386. _this2.ang2Y = 0;
  43387. _this2.ang2Z = 0;
  43388. row3.rhs = 0;
  43389. row3.cfm = 0;
  43390. row3.minImpulse = 0;
  43391. row3.maxImpulse = 0;
  43392. row3.motorSpeed = 0;
  43393. row3.motorMaxImpulse = 0;
  43394. row3.impulse = null;
  43395. row3.impulse = impulse2;
  43396. row1 = row3;
  43397. row1.rhs = linRhsZ;
  43398. row1.cfm = 0;
  43399. row1.minImpulse = -1e65536;
  43400. row1.maxImpulse = 1e65536;
  43401. j = row1.jacobian;
  43402. j.lin1X = 0;
  43403. j.lin1Y = 0;
  43404. j.lin1Z = 1;
  43405. j.lin2X = 0;
  43406. j.lin2Y = 0;
  43407. j.lin2Z = 1;
  43408. j.ang1X = crossR120;
  43409. j.ang1Y = crossR121;
  43410. j.ang1Z = crossR122;
  43411. j.ang2X = crossR220;
  43412. j.ang2Y = crossR221;
  43413. j.ang2Z = crossR222;
  43414. if(this.swingError > 0 && (this._swingSd.frequency <= 0 || !isPositionPart)) {
  43415. var impulse3 = this._impulses[3];
  43416. var row4 = info.rows[info.numRows++];
  43417. var _this3 = row4.jacobian;
  43418. _this3.lin1X = 0;
  43419. _this3.lin1Y = 0;
  43420. _this3.lin1Z = 0;
  43421. _this3.lin2X = 0;
  43422. _this3.lin2Y = 0;
  43423. _this3.lin2Z = 0;
  43424. _this3.ang1X = 0;
  43425. _this3.ang1Y = 0;
  43426. _this3.ang1Z = 0;
  43427. _this3.ang2X = 0;
  43428. _this3.ang2Y = 0;
  43429. _this3.ang2Z = 0;
  43430. row4.rhs = 0;
  43431. row4.cfm = 0;
  43432. row4.minImpulse = 0;
  43433. row4.maxImpulse = 0;
  43434. row4.motorSpeed = 0;
  43435. row4.motorMaxImpulse = 0;
  43436. row4.impulse = null;
  43437. row4.impulse = impulse3;
  43438. row1 = row4;
  43439. this.setSolverInfoRowAngular(row1,this.swingError,this.dummySwingLm,swingMass,this._swingSd,timeStep,isPositionPart);
  43440. j = row1.jacobian;
  43441. j.ang1X = this.swingAxisX;
  43442. j.ang1Y = this.swingAxisY;
  43443. j.ang1Z = this.swingAxisZ;
  43444. j.ang2X = this.swingAxisX;
  43445. j.ang2Y = this.swingAxisY;
  43446. j.ang2Z = this.swingAxisZ;
  43447. }
  43448. if(this._twistSd.frequency <= 0 || !isPositionPart) {
  43449. var impulse4 = this._impulses[4];
  43450. var row5 = info.rows[info.numRows++];
  43451. var _this4 = row5.jacobian;
  43452. _this4.lin1X = 0;
  43453. _this4.lin1Y = 0;
  43454. _this4.lin1Z = 0;
  43455. _this4.lin2X = 0;
  43456. _this4.lin2Y = 0;
  43457. _this4.lin2Z = 0;
  43458. _this4.ang1X = 0;
  43459. _this4.ang1Y = 0;
  43460. _this4.ang1Z = 0;
  43461. _this4.ang2X = 0;
  43462. _this4.ang2Y = 0;
  43463. _this4.ang2Z = 0;
  43464. row5.rhs = 0;
  43465. row5.cfm = 0;
  43466. row5.minImpulse = 0;
  43467. row5.maxImpulse = 0;
  43468. row5.motorSpeed = 0;
  43469. row5.motorMaxImpulse = 0;
  43470. row5.impulse = null;
  43471. row5.impulse = impulse4;
  43472. row1 = row5;
  43473. this.setSolverInfoRowAngular(row1,this._twistAngle,this._twistLm,twistMass,this._twistSd,timeStep,isPositionPart);
  43474. j = row1.jacobian;
  43475. j.ang1X = this.twistAxisX;
  43476. j.ang1Y = this.twistAxisY;
  43477. j.ang1Z = this.twistAxisZ;
  43478. j.ang2X = this.twistAxisX;
  43479. j.ang2Y = this.twistAxisY;
  43480. j.ang2Z = this.twistAxisZ;
  43481. }
  43482. }
  43483. _syncAnchors() {
  43484. super._syncAnchors();
  43485. var tf1 = this._b1._transform;
  43486. var tf2 = this._b2._transform;
  43487. var axis1;
  43488. var axis1X;
  43489. var axis1Y;
  43490. var axis1Z;
  43491. var axis2;
  43492. var axis2X;
  43493. var axis2Y;
  43494. var axis2Z;
  43495. axis1X = this._basisX1X;
  43496. axis1Y = this._basisX1Y;
  43497. axis1Z = this._basisX1Z;
  43498. axis2X = this._basisX2X;
  43499. axis2Y = this._basisX2Y;
  43500. axis2Z = this._basisX2Z;
  43501. var basis1Mat;
  43502. var basis1Mat00;
  43503. var basis1Mat01;
  43504. var basis1Mat02;
  43505. var basis1Mat10;
  43506. var basis1Mat11;
  43507. var basis1Mat12;
  43508. var basis1Mat20;
  43509. var basis1Mat21;
  43510. var basis1Mat22;
  43511. var basis2Mat;
  43512. var basis2Mat00;
  43513. var basis2Mat01;
  43514. var basis2Mat02;
  43515. var basis2Mat10;
  43516. var basis2Mat11;
  43517. var basis2Mat12;
  43518. var basis2Mat20;
  43519. var basis2Mat21;
  43520. var basis2Mat22;
  43521. basis1Mat00 = this._basisX1X;
  43522. basis1Mat01 = this._basisY1X;
  43523. basis1Mat02 = this._basisZ1X;
  43524. basis1Mat10 = this._basisX1Y;
  43525. basis1Mat11 = this._basisY1Y;
  43526. basis1Mat12 = this._basisZ1Y;
  43527. basis1Mat20 = this._basisX1Z;
  43528. basis1Mat21 = this._basisY1Z;
  43529. basis1Mat22 = this._basisZ1Z;
  43530. basis2Mat00 = this._basisX2X;
  43531. basis2Mat01 = this._basisY2X;
  43532. basis2Mat02 = this._basisZ2X;
  43533. basis2Mat10 = this._basisX2Y;
  43534. basis2Mat11 = this._basisY2Y;
  43535. basis2Mat12 = this._basisZ2Y;
  43536. basis2Mat20 = this._basisX2Z;
  43537. basis2Mat21 = this._basisY2Z;
  43538. basis2Mat22 = this._basisZ2Z;
  43539. var swingQ;
  43540. var swingQX;
  43541. var swingQY;
  43542. var swingQZ;
  43543. var swingQW;
  43544. var swingM;
  43545. var swingM00;
  43546. var swingM01;
  43547. var swingM02;
  43548. var swingM10;
  43549. var swingM11;
  43550. var swingM12;
  43551. var swingM20;
  43552. var swingM21;
  43553. var swingM22;
  43554. var swingV;
  43555. var swingVX;
  43556. var swingVY;
  43557. var swingVZ;
  43558. var d = axis1X * axis2X + axis1Y * axis2Y + axis1Z * axis2Z;
  43559. if(d < -0.999999999) {
  43560. var vX;
  43561. var vY;
  43562. var vZ;
  43563. var x1 = axis1X;
  43564. var y1 = axis1Y;
  43565. var z1 = axis1Z;
  43566. var x2 = x1 * x1;
  43567. var y2 = y1 * y1;
  43568. var z2 = z1 * z1;
  43569. var d1;
  43570. if(x2 < y2) {
  43571. if(x2 < z2) {
  43572. d1 = 1 / Math.sqrt(y2 + z2);
  43573. vX = 0;
  43574. vY = z1 * d1;
  43575. vZ = -y1 * d1;
  43576. } else {
  43577. d1 = 1 / Math.sqrt(x2 + y2);
  43578. vX = y1 * d1;
  43579. vY = -x1 * d1;
  43580. vZ = 0;
  43581. }
  43582. } else if(y2 < z2) {
  43583. d1 = 1 / Math.sqrt(z2 + x2);
  43584. vX = -z1 * d1;
  43585. vY = 0;
  43586. vZ = x1 * d1;
  43587. } else {
  43588. d1 = 1 / Math.sqrt(x2 + y2);
  43589. vX = y1 * d1;
  43590. vY = -x1 * d1;
  43591. vZ = 0;
  43592. }
  43593. swingQX = vX;
  43594. swingQY = vY;
  43595. swingQZ = vZ;
  43596. swingQW = 0;
  43597. } else {
  43598. var cX;
  43599. var cY;
  43600. var cZ;
  43601. cX = axis1Y * axis2Z - axis1Z * axis2Y;
  43602. cY = axis1Z * axis2X - axis1X * axis2Z;
  43603. cZ = axis1X * axis2Y - axis1Y * axis2X;
  43604. var w = Math.sqrt((1 + d) * 0.5);
  43605. d = 0.5 / w;
  43606. cX *= d;
  43607. cY *= d;
  43608. cZ *= d;
  43609. swingQX = cX;
  43610. swingQY = cY;
  43611. swingQZ = cZ;
  43612. swingQW = w;
  43613. }
  43614. var x = swingQX;
  43615. var y = swingQY;
  43616. var z = swingQZ;
  43617. var w1 = swingQW;
  43618. var x21 = 2 * x;
  43619. var y21 = 2 * y;
  43620. var z21 = 2 * z;
  43621. var xx = x * x21;
  43622. var yy = y * y21;
  43623. var zz = z * z21;
  43624. var xy = x * y21;
  43625. var yz = y * z21;
  43626. var xz = x * z21;
  43627. var wx = w1 * x21;
  43628. var wy = w1 * y21;
  43629. var wz = w1 * z21;
  43630. swingM00 = 1 - yy - zz;
  43631. swingM01 = xy - wz;
  43632. swingM02 = xz + wy;
  43633. swingM10 = xy + wz;
  43634. swingM11 = 1 - xx - zz;
  43635. swingM12 = yz - wx;
  43636. swingM20 = xz - wy;
  43637. swingM21 = yz + wx;
  43638. swingM22 = 1 - xx - yy;
  43639. this._swingAngle = (swingQW <= -1 ? 3.14159265358979 : swingQW >= 1 ? 0 : Math.acos(swingQW)) * 2;
  43640. swingVX = swingQX;
  43641. swingVY = swingQY;
  43642. swingVZ = swingQZ;
  43643. var basisY2In1;
  43644. var basisY2In1X;
  43645. var basisY2In1Y;
  43646. var basisY2In1Z;
  43647. var __tmp__X;
  43648. var __tmp__Y;
  43649. var __tmp__Z;
  43650. __tmp__X = swingM00 * this._basisY2X + swingM10 * this._basisY2Y + swingM20 * this._basisY2Z;
  43651. __tmp__Y = swingM01 * this._basisY2X + swingM11 * this._basisY2Y + swingM21 * this._basisY2Z;
  43652. __tmp__Z = swingM02 * this._basisY2X + swingM12 * this._basisY2Y + swingM22 * this._basisY2Z;
  43653. basisY2In1X = __tmp__X;
  43654. basisY2In1Y = __tmp__Y;
  43655. basisY2In1Z = __tmp__Z;
  43656. var yCoord = this._basisY1X * basisY2In1X + this._basisY1Y * basisY2In1Y + this._basisY1Z * basisY2In1Z;
  43657. var zCoord = this._basisZ1X * basisY2In1X + this._basisZ1Y * basisY2In1Y + this._basisZ1Z * basisY2In1Z;
  43658. this._twistAngle = Math.atan2(zCoord,yCoord);
  43659. this.twistAxisX = this._basisX1X + this._basisX2X;
  43660. this.twistAxisY = this._basisX1Y + this._basisX2Y;
  43661. this.twistAxisZ = this._basisX1Z + this._basisX2Z;
  43662. var l = this.twistAxisX * this.twistAxisX + this.twistAxisY * this.twistAxisY + this.twistAxisZ * this.twistAxisZ;
  43663. if(l > 0) {
  43664. l = 1 / Math.sqrt(l);
  43665. }
  43666. this.twistAxisX *= l;
  43667. this.twistAxisY *= l;
  43668. this.twistAxisZ *= l;
  43669. var invLen = Math.sqrt(swingVX * swingVX + swingVY * swingVY + swingVZ * swingVZ);
  43670. if(invLen > 0) {
  43671. invLen = 1 / invLen;
  43672. }
  43673. swingVX *= invLen * this._swingAngle;
  43674. swingVY *= invLen * this._swingAngle;
  43675. swingVZ *= invLen * this._swingAngle;
  43676. var __tmp__X1;
  43677. var __tmp__Y1;
  43678. var __tmp__Z1;
  43679. __tmp__X1 = basis1Mat00 * swingVX + basis1Mat10 * swingVY + basis1Mat20 * swingVZ;
  43680. __tmp__Y1 = basis1Mat01 * swingVX + basis1Mat11 * swingVY + basis1Mat21 * swingVZ;
  43681. __tmp__Z1 = basis1Mat02 * swingVX + basis1Mat12 * swingVY + basis1Mat22 * swingVZ;
  43682. swingVX = __tmp__X1;
  43683. swingVY = __tmp__Y1;
  43684. swingVZ = __tmp__Z1;
  43685. var x3 = swingVY;
  43686. var y3 = swingVZ;
  43687. var a = this._maxSwingAngle1;
  43688. var b = this._maxSwingAngle2;
  43689. var invA2 = 1 / (a * a);
  43690. var invB2 = 1 / (b * b);
  43691. var w2 = x3 * x3 * invA2 + y3 * y3 * invB2;
  43692. if(w2 == 0) {
  43693. this.swingAxisX = 0;
  43694. this.swingAxisY = 0;
  43695. this.swingAxisZ = 0;
  43696. this.swingError = 0;
  43697. } else {
  43698. var t = Math.sqrt(1 / w2);
  43699. var x0 = x3 * t;
  43700. var y0 = y3 * t;
  43701. var nx = x0 * invA2;
  43702. var ny = y0 * invB2;
  43703. invLen = 1 / Math.sqrt(nx * nx + ny * ny);
  43704. nx *= invLen;
  43705. ny *= invLen;
  43706. var depth = (x3 - x0) * nx + (y3 - y0) * ny;
  43707. if(depth > 0) {
  43708. this.swingError = depth;
  43709. this.swingAxisX = 0;
  43710. this.swingAxisY = nx;
  43711. this.swingAxisZ = ny;
  43712. var __tmp__X2;
  43713. var __tmp__Y2;
  43714. var __tmp__Z2;
  43715. __tmp__X2 = basis1Mat00 * this.swingAxisX + basis1Mat01 * this.swingAxisY + basis1Mat02 * this.swingAxisZ;
  43716. __tmp__Y2 = basis1Mat10 * this.swingAxisX + basis1Mat11 * this.swingAxisY + basis1Mat12 * this.swingAxisZ;
  43717. __tmp__Z2 = basis1Mat20 * this.swingAxisX + basis1Mat21 * this.swingAxisY + basis1Mat22 * this.swingAxisZ;
  43718. this.swingAxisX = __tmp__X2;
  43719. this.swingAxisY = __tmp__Y2;
  43720. this.swingAxisZ = __tmp__Z2;
  43721. var __tmp__X3;
  43722. var __tmp__Y3;
  43723. var __tmp__Z3;
  43724. __tmp__X3 = swingM00 * this.swingAxisX + swingM01 * this.swingAxisY + swingM02 * this.swingAxisZ;
  43725. __tmp__Y3 = swingM10 * this.swingAxisX + swingM11 * this.swingAxisY + swingM12 * this.swingAxisZ;
  43726. __tmp__Z3 = swingM20 * this.swingAxisX + swingM21 * this.swingAxisY + swingM22 * this.swingAxisZ;
  43727. this.swingAxisX = __tmp__X3;
  43728. this.swingAxisY = __tmp__Y3;
  43729. this.swingAxisZ = __tmp__Z3;
  43730. } else {
  43731. this.swingError = 0;
  43732. }
  43733. }
  43734. this.linearErrorX = this._anchor2X - this._anchor1X;
  43735. this.linearErrorY = this._anchor2Y - this._anchor1Y;
  43736. this.linearErrorZ = this._anchor2Z - this._anchor1Z;
  43737. }
  43738. _getVelocitySolverInfo(timeStep,info) {
  43739. super._getVelocitySolverInfo(timeStep,info);
  43740. this.getInfo(info,timeStep,false);
  43741. }
  43742. _getPositionSolverInfo(info) {
  43743. super._getPositionSolverInfo(info);
  43744. this.getInfo(info,null,true);
  43745. }
  43746. getAxis1() {
  43747. var v = new oimo.common.Vec3();
  43748. var v1 = v;
  43749. v1.x = this._basisX1X;
  43750. v1.y = this._basisX1Y;
  43751. v1.z = this._basisX1Z;
  43752. return v;
  43753. }
  43754. getAxis2() {
  43755. var v = new oimo.common.Vec3();
  43756. var v1 = v;
  43757. v1.x = this._basisX2X;
  43758. v1.y = this._basisX2Y;
  43759. v1.z = this._basisX2Z;
  43760. return v;
  43761. }
  43762. getAxis1To(axis) {
  43763. var v = axis;
  43764. v.x = this._basisX1X;
  43765. v.y = this._basisX1Y;
  43766. v.z = this._basisX1Z;
  43767. }
  43768. getAxis2To(axis) {
  43769. var v = axis;
  43770. v.x = this._basisX2X;
  43771. v.y = this._basisX2Y;
  43772. v.z = this._basisX2Z;
  43773. }
  43774. getLocalAxis1() {
  43775. var v = new oimo.common.Vec3();
  43776. var v1 = v;
  43777. v1.x = this._localBasisX1X;
  43778. v1.y = this._localBasisX1Y;
  43779. v1.z = this._localBasisX1Z;
  43780. return v;
  43781. }
  43782. getLocalAxis2() {
  43783. var v = new oimo.common.Vec3();
  43784. var v1 = v;
  43785. v1.x = this._localBasisX2X;
  43786. v1.y = this._localBasisX2Y;
  43787. v1.z = this._localBasisX2Z;
  43788. return v;
  43789. }
  43790. getLocalAxis1To(axis) {
  43791. var v = axis;
  43792. v.x = this._localBasisX1X;
  43793. v.y = this._localBasisX1Y;
  43794. v.z = this._localBasisX1Z;
  43795. }
  43796. getLocalAxis2To(axis) {
  43797. var v = axis;
  43798. v.x = this._localBasisX2X;
  43799. v.y = this._localBasisX2Y;
  43800. v.z = this._localBasisX2Z;
  43801. }
  43802. getTwistSpringDamper() {
  43803. return this._twistSd;
  43804. }
  43805. getTwistLimitMotor() {
  43806. return this._twistLm;
  43807. }
  43808. getSwingSpringDamper() {
  43809. return this._swingSd;
  43810. }
  43811. getSwingAxis() {
  43812. var v = new oimo.common.Vec3();
  43813. var v1 = v;
  43814. v1.x = this.swingAxisX;
  43815. v1.y = this.swingAxisY;
  43816. v1.z = this.swingAxisZ;
  43817. return v;
  43818. }
  43819. getSwingAxisTo(axis) {
  43820. var v = axis;
  43821. v.x = this.swingAxisX;
  43822. v.y = this.swingAxisY;
  43823. v.z = this.swingAxisZ;
  43824. }
  43825. getSwingAngle() {
  43826. return this._swingAngle;
  43827. }
  43828. getTwistAngle() {
  43829. return this._twistAngle;
  43830. }
  43831. }
  43832. oimo.dynamics.constraint.joint.RagdollJointConfig = class oimo_dynamics_constraint_joint_RagdollJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  43833. constructor() {
  43834. super();
  43835. this.localTwistAxis1 = new oimo.common.Vec3(1,0,0);
  43836. this.localTwistAxis2 = new oimo.common.Vec3(1,0,0);
  43837. this.localSwingAxis1 = new oimo.common.Vec3(0,1,0);
  43838. this.twistSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  43839. this.swingSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  43840. this.twistLimitMotor = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  43841. this.maxSwingAngle1 = 3.14159265358979;
  43842. this.maxSwingAngle2 = 3.14159265358979;
  43843. }
  43844. init(rigidBody1,rigidBody2,worldAnchor,worldTwistAxis,worldSwingAxis) {
  43845. this._init(rigidBody1,rigidBody2,worldAnchor);
  43846. var v;
  43847. var vX;
  43848. var vY;
  43849. var vZ;
  43850. var v1 = worldTwistAxis;
  43851. vX = v1.x;
  43852. vY = v1.y;
  43853. vZ = v1.z;
  43854. var __tmp__X;
  43855. var __tmp__Y;
  43856. var __tmp__Z;
  43857. __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ;
  43858. __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ;
  43859. __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ;
  43860. vX = __tmp__X;
  43861. vY = __tmp__Y;
  43862. vZ = __tmp__Z;
  43863. var v2 = this.localTwistAxis1;
  43864. v2.x = vX;
  43865. v2.y = vY;
  43866. v2.z = vZ;
  43867. var v3;
  43868. var vX1;
  43869. var vY1;
  43870. var vZ1;
  43871. var v4 = worldTwistAxis;
  43872. vX1 = v4.x;
  43873. vY1 = v4.y;
  43874. vZ1 = v4.z;
  43875. var __tmp__X1;
  43876. var __tmp__Y1;
  43877. var __tmp__Z1;
  43878. __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1;
  43879. __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1;
  43880. __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1;
  43881. vX1 = __tmp__X1;
  43882. vY1 = __tmp__Y1;
  43883. vZ1 = __tmp__Z1;
  43884. var v5 = this.localTwistAxis2;
  43885. v5.x = vX1;
  43886. v5.y = vY1;
  43887. v5.z = vZ1;
  43888. var v6;
  43889. var vX2;
  43890. var vY2;
  43891. var vZ2;
  43892. var v7 = worldSwingAxis;
  43893. vX2 = v7.x;
  43894. vY2 = v7.y;
  43895. vZ2 = v7.z;
  43896. var __tmp__X2;
  43897. var __tmp__Y2;
  43898. var __tmp__Z2;
  43899. __tmp__X2 = rigidBody1._transform._rotation00 * vX2 + rigidBody1._transform._rotation10 * vY2 + rigidBody1._transform._rotation20 * vZ2;
  43900. __tmp__Y2 = rigidBody1._transform._rotation01 * vX2 + rigidBody1._transform._rotation11 * vY2 + rigidBody1._transform._rotation21 * vZ2;
  43901. __tmp__Z2 = rigidBody1._transform._rotation02 * vX2 + rigidBody1._transform._rotation12 * vY2 + rigidBody1._transform._rotation22 * vZ2;
  43902. vX2 = __tmp__X2;
  43903. vY2 = __tmp__Y2;
  43904. vZ2 = __tmp__Z2;
  43905. var v8 = this.localSwingAxis1;
  43906. v8.x = vX2;
  43907. v8.y = vY2;
  43908. v8.z = vZ2;
  43909. return this;
  43910. }
  43911. }
  43912. oimo.dynamics.constraint.joint.RevoluteJoint = class oimo_dynamics_constraint_joint_RevoluteJoint extends oimo.dynamics.constraint.joint.Joint {
  43913. constructor(config) {
  43914. super(config,1);
  43915. var v = config.localAxis1;
  43916. this._localBasisX1X = v.x;
  43917. this._localBasisX1Y = v.y;
  43918. this._localBasisX1Z = v.z;
  43919. var v1 = config.localAxis2;
  43920. this._localBasisX2X = v1.x;
  43921. this._localBasisX2Y = v1.y;
  43922. this._localBasisX2Z = v1.z;
  43923. this.buildLocalBasesFromX();
  43924. this.angle = 0;
  43925. this.angularErrorY = 0;
  43926. this.angularErrorZ = 0;
  43927. this._basis = new oimo.dynamics.constraint.joint.BasisTracker(this);
  43928. this._sd = config.springDamper.clone();
  43929. this._lm = config.limitMotor.clone();
  43930. }
  43931. getInfo(info,timeStep,isPositionPart) {
  43932. var erp = this.getErp(timeStep,isPositionPart);
  43933. var linearRhs;
  43934. var linearRhsX;
  43935. var linearRhsY;
  43936. var linearRhsZ;
  43937. linearRhsX = this.linearErrorX * erp;
  43938. linearRhsY = this.linearErrorY * erp;
  43939. linearRhsZ = this.linearErrorZ * erp;
  43940. var linRhsX = linearRhsX;
  43941. var linRhsY = linearRhsY;
  43942. var linRhsZ = linearRhsZ;
  43943. var angRhsY = this.angularErrorY * erp;
  43944. var angRhsZ = this.angularErrorZ * erp;
  43945. var crossR1;
  43946. var crossR100;
  43947. var crossR101;
  43948. var crossR102;
  43949. var crossR110;
  43950. var crossR111;
  43951. var crossR112;
  43952. var crossR120;
  43953. var crossR121;
  43954. var crossR122;
  43955. var crossR2;
  43956. var crossR200;
  43957. var crossR201;
  43958. var crossR202;
  43959. var crossR210;
  43960. var crossR211;
  43961. var crossR212;
  43962. var crossR220;
  43963. var crossR221;
  43964. var crossR222;
  43965. crossR100 = 0;
  43966. crossR101 = -this._relativeAnchor1Z;
  43967. crossR102 = this._relativeAnchor1Y;
  43968. crossR110 = this._relativeAnchor1Z;
  43969. crossR111 = 0;
  43970. crossR112 = -this._relativeAnchor1X;
  43971. crossR120 = -this._relativeAnchor1Y;
  43972. crossR121 = this._relativeAnchor1X;
  43973. crossR122 = 0;
  43974. crossR200 = 0;
  43975. crossR201 = -this._relativeAnchor2Z;
  43976. crossR202 = this._relativeAnchor2Y;
  43977. crossR210 = this._relativeAnchor2Z;
  43978. crossR211 = 0;
  43979. crossR212 = -this._relativeAnchor2X;
  43980. crossR220 = -this._relativeAnchor2Y;
  43981. crossR221 = this._relativeAnchor2X;
  43982. crossR222 = 0;
  43983. crossR100 = -crossR100;
  43984. crossR101 = -crossR101;
  43985. crossR102 = -crossR102;
  43986. crossR110 = -crossR110;
  43987. crossR111 = -crossR111;
  43988. crossR112 = -crossR112;
  43989. crossR120 = -crossR120;
  43990. crossR121 = -crossR121;
  43991. crossR122 = -crossR122;
  43992. crossR200 = -crossR200;
  43993. crossR201 = -crossR201;
  43994. crossR202 = -crossR202;
  43995. crossR210 = -crossR210;
  43996. crossR211 = -crossR211;
  43997. crossR212 = -crossR212;
  43998. crossR220 = -crossR220;
  43999. crossR221 = -crossR221;
  44000. crossR222 = -crossR222;
  44001. var motorMass = this.computeEffectiveInertiaMoment(this._basis.xX,this._basis.xY,this._basis.xZ);
  44002. var impulse = this._impulses[0];
  44003. var row = info.rows[info.numRows++];
  44004. var _this = row.jacobian;
  44005. _this.lin1X = 0;
  44006. _this.lin1Y = 0;
  44007. _this.lin1Z = 0;
  44008. _this.lin2X = 0;
  44009. _this.lin2Y = 0;
  44010. _this.lin2Z = 0;
  44011. _this.ang1X = 0;
  44012. _this.ang1Y = 0;
  44013. _this.ang1Z = 0;
  44014. _this.ang2X = 0;
  44015. _this.ang2Y = 0;
  44016. _this.ang2Z = 0;
  44017. row.rhs = 0;
  44018. row.cfm = 0;
  44019. row.minImpulse = 0;
  44020. row.maxImpulse = 0;
  44021. row.motorSpeed = 0;
  44022. row.motorMaxImpulse = 0;
  44023. row.impulse = null;
  44024. row.impulse = impulse;
  44025. var row1 = row;
  44026. row1.rhs = linRhsX;
  44027. row1.cfm = 0;
  44028. row1.minImpulse = -1e65536;
  44029. row1.maxImpulse = 1e65536;
  44030. var j = row1.jacobian;
  44031. j.lin1X = 1;
  44032. j.lin1Y = 0;
  44033. j.lin1Z = 0;
  44034. j.lin2X = 1;
  44035. j.lin2Y = 0;
  44036. j.lin2Z = 0;
  44037. j.ang1X = crossR100;
  44038. j.ang1Y = crossR101;
  44039. j.ang1Z = crossR102;
  44040. j.ang2X = crossR200;
  44041. j.ang2Y = crossR201;
  44042. j.ang2Z = crossR202;
  44043. var impulse1 = this._impulses[1];
  44044. var row2 = info.rows[info.numRows++];
  44045. var _this1 = row2.jacobian;
  44046. _this1.lin1X = 0;
  44047. _this1.lin1Y = 0;
  44048. _this1.lin1Z = 0;
  44049. _this1.lin2X = 0;
  44050. _this1.lin2Y = 0;
  44051. _this1.lin2Z = 0;
  44052. _this1.ang1X = 0;
  44053. _this1.ang1Y = 0;
  44054. _this1.ang1Z = 0;
  44055. _this1.ang2X = 0;
  44056. _this1.ang2Y = 0;
  44057. _this1.ang2Z = 0;
  44058. row2.rhs = 0;
  44059. row2.cfm = 0;
  44060. row2.minImpulse = 0;
  44061. row2.maxImpulse = 0;
  44062. row2.motorSpeed = 0;
  44063. row2.motorMaxImpulse = 0;
  44064. row2.impulse = null;
  44065. row2.impulse = impulse1;
  44066. row1 = row2;
  44067. row1.rhs = linRhsY;
  44068. row1.cfm = 0;
  44069. row1.minImpulse = -1e65536;
  44070. row1.maxImpulse = 1e65536;
  44071. j = row1.jacobian;
  44072. j.lin1X = 0;
  44073. j.lin1Y = 1;
  44074. j.lin1Z = 0;
  44075. j.lin2X = 0;
  44076. j.lin2Y = 1;
  44077. j.lin2Z = 0;
  44078. j.ang1X = crossR110;
  44079. j.ang1Y = crossR111;
  44080. j.ang1Z = crossR112;
  44081. j.ang2X = crossR210;
  44082. j.ang2Y = crossR211;
  44083. j.ang2Z = crossR212;
  44084. var impulse2 = this._impulses[2];
  44085. var row3 = info.rows[info.numRows++];
  44086. var _this2 = row3.jacobian;
  44087. _this2.lin1X = 0;
  44088. _this2.lin1Y = 0;
  44089. _this2.lin1Z = 0;
  44090. _this2.lin2X = 0;
  44091. _this2.lin2Y = 0;
  44092. _this2.lin2Z = 0;
  44093. _this2.ang1X = 0;
  44094. _this2.ang1Y = 0;
  44095. _this2.ang1Z = 0;
  44096. _this2.ang2X = 0;
  44097. _this2.ang2Y = 0;
  44098. _this2.ang2Z = 0;
  44099. row3.rhs = 0;
  44100. row3.cfm = 0;
  44101. row3.minImpulse = 0;
  44102. row3.maxImpulse = 0;
  44103. row3.motorSpeed = 0;
  44104. row3.motorMaxImpulse = 0;
  44105. row3.impulse = null;
  44106. row3.impulse = impulse2;
  44107. row1 = row3;
  44108. row1.rhs = linRhsZ;
  44109. row1.cfm = 0;
  44110. row1.minImpulse = -1e65536;
  44111. row1.maxImpulse = 1e65536;
  44112. j = row1.jacobian;
  44113. j.lin1X = 0;
  44114. j.lin1Y = 0;
  44115. j.lin1Z = 1;
  44116. j.lin2X = 0;
  44117. j.lin2Y = 0;
  44118. j.lin2Z = 1;
  44119. j.ang1X = crossR120;
  44120. j.ang1Y = crossR121;
  44121. j.ang1Z = crossR122;
  44122. j.ang2X = crossR220;
  44123. j.ang2Y = crossR221;
  44124. j.ang2Z = crossR222;
  44125. if(this._sd.frequency <= 0 || !isPositionPart) {
  44126. var impulse3 = this._impulses[3];
  44127. var row4 = info.rows[info.numRows++];
  44128. var _this3 = row4.jacobian;
  44129. _this3.lin1X = 0;
  44130. _this3.lin1Y = 0;
  44131. _this3.lin1Z = 0;
  44132. _this3.lin2X = 0;
  44133. _this3.lin2Y = 0;
  44134. _this3.lin2Z = 0;
  44135. _this3.ang1X = 0;
  44136. _this3.ang1Y = 0;
  44137. _this3.ang1Z = 0;
  44138. _this3.ang2X = 0;
  44139. _this3.ang2Y = 0;
  44140. _this3.ang2Z = 0;
  44141. row4.rhs = 0;
  44142. row4.cfm = 0;
  44143. row4.minImpulse = 0;
  44144. row4.maxImpulse = 0;
  44145. row4.motorSpeed = 0;
  44146. row4.motorMaxImpulse = 0;
  44147. row4.impulse = null;
  44148. row4.impulse = impulse3;
  44149. row1 = row4;
  44150. this.setSolverInfoRowAngular(row1,this.angle,this._lm,motorMass,this._sd,timeStep,isPositionPart);
  44151. j = row1.jacobian;
  44152. j.ang1X = this._basis.xX;
  44153. j.ang1Y = this._basis.xY;
  44154. j.ang1Z = this._basis.xZ;
  44155. j.ang2X = this._basis.xX;
  44156. j.ang2Y = this._basis.xY;
  44157. j.ang2Z = this._basis.xZ;
  44158. }
  44159. var impulse4 = this._impulses[4];
  44160. var row5 = info.rows[info.numRows++];
  44161. var _this4 = row5.jacobian;
  44162. _this4.lin1X = 0;
  44163. _this4.lin1Y = 0;
  44164. _this4.lin1Z = 0;
  44165. _this4.lin2X = 0;
  44166. _this4.lin2Y = 0;
  44167. _this4.lin2Z = 0;
  44168. _this4.ang1X = 0;
  44169. _this4.ang1Y = 0;
  44170. _this4.ang1Z = 0;
  44171. _this4.ang2X = 0;
  44172. _this4.ang2Y = 0;
  44173. _this4.ang2Z = 0;
  44174. row5.rhs = 0;
  44175. row5.cfm = 0;
  44176. row5.minImpulse = 0;
  44177. row5.maxImpulse = 0;
  44178. row5.motorSpeed = 0;
  44179. row5.motorMaxImpulse = 0;
  44180. row5.impulse = null;
  44181. row5.impulse = impulse4;
  44182. row1 = row5;
  44183. row1.rhs = angRhsY;
  44184. row1.cfm = 0;
  44185. row1.minImpulse = -1e65536;
  44186. row1.maxImpulse = 1e65536;
  44187. j = row1.jacobian;
  44188. j.ang1X = this._basis.yX;
  44189. j.ang1Y = this._basis.yY;
  44190. j.ang1Z = this._basis.yZ;
  44191. j.ang2X = this._basis.yX;
  44192. j.ang2Y = this._basis.yY;
  44193. j.ang2Z = this._basis.yZ;
  44194. var impulse5 = this._impulses[5];
  44195. var row6 = info.rows[info.numRows++];
  44196. var _this5 = row6.jacobian;
  44197. _this5.lin1X = 0;
  44198. _this5.lin1Y = 0;
  44199. _this5.lin1Z = 0;
  44200. _this5.lin2X = 0;
  44201. _this5.lin2Y = 0;
  44202. _this5.lin2Z = 0;
  44203. _this5.ang1X = 0;
  44204. _this5.ang1Y = 0;
  44205. _this5.ang1Z = 0;
  44206. _this5.ang2X = 0;
  44207. _this5.ang2Y = 0;
  44208. _this5.ang2Z = 0;
  44209. row6.rhs = 0;
  44210. row6.cfm = 0;
  44211. row6.minImpulse = 0;
  44212. row6.maxImpulse = 0;
  44213. row6.motorSpeed = 0;
  44214. row6.motorMaxImpulse = 0;
  44215. row6.impulse = null;
  44216. row6.impulse = impulse5;
  44217. row1 = row6;
  44218. row1.rhs = angRhsZ;
  44219. row1.cfm = 0;
  44220. row1.minImpulse = -1e65536;
  44221. row1.maxImpulse = 1e65536;
  44222. j = row1.jacobian;
  44223. j.ang1X = this._basis.zX;
  44224. j.ang1Y = this._basis.zY;
  44225. j.ang1Z = this._basis.zZ;
  44226. j.ang2X = this._basis.zX;
  44227. j.ang2Y = this._basis.zY;
  44228. j.ang2Z = this._basis.zZ;
  44229. }
  44230. _syncAnchors() {
  44231. super._syncAnchors();
  44232. var _this = this._basis;
  44233. var invM1 = _this.joint._b1._invMass;
  44234. var invM2 = _this.joint._b2._invMass;
  44235. var q;
  44236. var qX;
  44237. var qY;
  44238. var qZ;
  44239. var qW;
  44240. var idQ;
  44241. var idQX;
  44242. var idQY;
  44243. var idQZ;
  44244. var idQW;
  44245. var slerpQ;
  44246. var slerpQX;
  44247. var slerpQY;
  44248. var slerpQZ;
  44249. var slerpQW;
  44250. var slerpM;
  44251. var slerpM00;
  44252. var slerpM01;
  44253. var slerpM02;
  44254. var slerpM10;
  44255. var slerpM11;
  44256. var slerpM12;
  44257. var slerpM20;
  44258. var slerpM21;
  44259. var slerpM22;
  44260. var newX;
  44261. var newXX;
  44262. var newXY;
  44263. var newXZ;
  44264. var newY;
  44265. var newYX;
  44266. var newYY;
  44267. var newYZ;
  44268. var newZ;
  44269. var newZX;
  44270. var newZY;
  44271. var newZZ;
  44272. var prevX;
  44273. var prevXX;
  44274. var prevXY;
  44275. var prevXZ;
  44276. var prevY;
  44277. var prevYX;
  44278. var prevYY;
  44279. var prevYZ;
  44280. var d = _this.joint._basisX1X * _this.joint._basisX2X + _this.joint._basisX1Y * _this.joint._basisX2Y + _this.joint._basisX1Z * _this.joint._basisX2Z;
  44281. if(d < -0.999999999) {
  44282. var vX;
  44283. var vY;
  44284. var vZ;
  44285. var x1 = _this.joint._basisX1X;
  44286. var y1 = _this.joint._basisX1Y;
  44287. var z1 = _this.joint._basisX1Z;
  44288. var x2 = x1 * x1;
  44289. var y2 = y1 * y1;
  44290. var z2 = z1 * z1;
  44291. var d1;
  44292. if(x2 < y2) {
  44293. if(x2 < z2) {
  44294. d1 = 1 / Math.sqrt(y2 + z2);
  44295. vX = 0;
  44296. vY = z1 * d1;
  44297. vZ = -y1 * d1;
  44298. } else {
  44299. d1 = 1 / Math.sqrt(x2 + y2);
  44300. vX = y1 * d1;
  44301. vY = -x1 * d1;
  44302. vZ = 0;
  44303. }
  44304. } else if(y2 < z2) {
  44305. d1 = 1 / Math.sqrt(z2 + x2);
  44306. vX = -z1 * d1;
  44307. vY = 0;
  44308. vZ = x1 * d1;
  44309. } else {
  44310. d1 = 1 / Math.sqrt(x2 + y2);
  44311. vX = y1 * d1;
  44312. vY = -x1 * d1;
  44313. vZ = 0;
  44314. }
  44315. qX = vX;
  44316. qY = vY;
  44317. qZ = vZ;
  44318. qW = 0;
  44319. } else {
  44320. var cX;
  44321. var cY;
  44322. var cZ;
  44323. cX = _this.joint._basisX1Y * _this.joint._basisX2Z - _this.joint._basisX1Z * _this.joint._basisX2Y;
  44324. cY = _this.joint._basisX1Z * _this.joint._basisX2X - _this.joint._basisX1X * _this.joint._basisX2Z;
  44325. cZ = _this.joint._basisX1X * _this.joint._basisX2Y - _this.joint._basisX1Y * _this.joint._basisX2X;
  44326. var w = Math.sqrt((1 + d) * 0.5);
  44327. d = 0.5 / w;
  44328. cX *= d;
  44329. cY *= d;
  44330. cZ *= d;
  44331. qX = cX;
  44332. qY = cY;
  44333. qZ = cZ;
  44334. qW = w;
  44335. }
  44336. idQX = 0;
  44337. idQY = 0;
  44338. idQZ = 0;
  44339. idQW = 1;
  44340. var qx;
  44341. var qy;
  44342. var qz;
  44343. var qw;
  44344. var q1X;
  44345. var q1Y;
  44346. var q1Z;
  44347. var q1W;
  44348. var q2X;
  44349. var q2Y;
  44350. var q2Z;
  44351. var q2W;
  44352. q1X = idQX;
  44353. q1Y = idQY;
  44354. q1Z = idQZ;
  44355. q1W = idQW;
  44356. q2X = qX;
  44357. q2Y = qY;
  44358. q2Z = qZ;
  44359. q2W = qW;
  44360. var d2 = q1X * q2X + q1Y * q2Y + q1Z * q2Z + q1W * q2W;
  44361. if(d2 < 0) {
  44362. d2 = -d2;
  44363. q2X = -q2X;
  44364. q2Y = -q2Y;
  44365. q2Z = -q2Z;
  44366. q2W = -q2W;
  44367. }
  44368. if(d2 > 0.999999) {
  44369. var dqX;
  44370. var dqY;
  44371. var dqZ;
  44372. var dqW;
  44373. dqX = q2X - q1X;
  44374. dqY = q2Y - q1Y;
  44375. dqZ = q2Z - q1Z;
  44376. dqW = q2W - q1W;
  44377. q2X = q1X + dqX * (invM1 / (invM1 + invM2));
  44378. q2Y = q1Y + dqY * (invM1 / (invM1 + invM2));
  44379. q2Z = q1Z + dqZ * (invM1 / (invM1 + invM2));
  44380. q2W = q1W + dqW * (invM1 / (invM1 + invM2));
  44381. var l = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W;
  44382. if(l > 1e-32) {
  44383. l = 1 / Math.sqrt(l);
  44384. }
  44385. slerpQX = q2X * l;
  44386. slerpQY = q2Y * l;
  44387. slerpQZ = q2Z * l;
  44388. slerpQW = q2W * l;
  44389. } else {
  44390. var theta = invM1 / (invM1 + invM2) * Math.acos(d2);
  44391. q2X += q1X * -d2;
  44392. q2Y += q1Y * -d2;
  44393. q2Z += q1Z * -d2;
  44394. q2W += q1W * -d2;
  44395. var l1 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W;
  44396. if(l1 > 1e-32) {
  44397. l1 = 1 / Math.sqrt(l1);
  44398. }
  44399. q2X *= l1;
  44400. q2Y *= l1;
  44401. q2Z *= l1;
  44402. q2W *= l1;
  44403. var sin = Math.sin(theta);
  44404. var cos = Math.cos(theta);
  44405. q1X *= cos;
  44406. q1Y *= cos;
  44407. q1Z *= cos;
  44408. q1W *= cos;
  44409. slerpQX = q1X + q2X * sin;
  44410. slerpQY = q1Y + q2Y * sin;
  44411. slerpQZ = q1Z + q2Z * sin;
  44412. slerpQW = q1W + q2W * sin;
  44413. }
  44414. var x = slerpQX;
  44415. var y = slerpQY;
  44416. var z = slerpQZ;
  44417. var w1 = slerpQW;
  44418. var x21 = 2 * x;
  44419. var y21 = 2 * y;
  44420. var z21 = 2 * z;
  44421. var xx = x * x21;
  44422. var yy = y * y21;
  44423. var zz = z * z21;
  44424. var xy = x * y21;
  44425. var yz = y * z21;
  44426. var xz = x * z21;
  44427. var wx = w1 * x21;
  44428. var wy = w1 * y21;
  44429. var wz = w1 * z21;
  44430. slerpM00 = 1 - yy - zz;
  44431. slerpM01 = xy - wz;
  44432. slerpM02 = xz + wy;
  44433. slerpM10 = xy + wz;
  44434. slerpM11 = 1 - xx - zz;
  44435. slerpM12 = yz - wx;
  44436. slerpM20 = xz - wy;
  44437. slerpM21 = yz + wx;
  44438. slerpM22 = 1 - xx - yy;
  44439. var __tmp__X;
  44440. var __tmp__Y;
  44441. var __tmp__Z;
  44442. __tmp__X = slerpM00 * _this.joint._basisX1X + slerpM01 * _this.joint._basisX1Y + slerpM02 * _this.joint._basisX1Z;
  44443. __tmp__Y = slerpM10 * _this.joint._basisX1X + slerpM11 * _this.joint._basisX1Y + slerpM12 * _this.joint._basisX1Z;
  44444. __tmp__Z = slerpM20 * _this.joint._basisX1X + slerpM21 * _this.joint._basisX1Y + slerpM22 * _this.joint._basisX1Z;
  44445. newXX = __tmp__X;
  44446. newXY = __tmp__Y;
  44447. newXZ = __tmp__Z;
  44448. prevXX = _this.xX;
  44449. prevXY = _this.xY;
  44450. prevXZ = _this.xZ;
  44451. prevYX = _this.yX;
  44452. prevYY = _this.yY;
  44453. prevYZ = _this.yZ;
  44454. var d3 = prevXX * newXX + prevXY * newXY + prevXZ * newXZ;
  44455. if(d3 < -0.999999999) {
  44456. var vX1;
  44457. var vY1;
  44458. var vZ1;
  44459. var x11 = prevXX;
  44460. var y11 = prevXY;
  44461. var z11 = prevXZ;
  44462. var x22 = x11 * x11;
  44463. var y22 = y11 * y11;
  44464. var z22 = z11 * z11;
  44465. var d4;
  44466. if(x22 < y22) {
  44467. if(x22 < z22) {
  44468. d4 = 1 / Math.sqrt(y22 + z22);
  44469. vX1 = 0;
  44470. vY1 = z11 * d4;
  44471. vZ1 = -y11 * d4;
  44472. } else {
  44473. d4 = 1 / Math.sqrt(x22 + y22);
  44474. vX1 = y11 * d4;
  44475. vY1 = -x11 * d4;
  44476. vZ1 = 0;
  44477. }
  44478. } else if(y22 < z22) {
  44479. d4 = 1 / Math.sqrt(z22 + x22);
  44480. vX1 = -z11 * d4;
  44481. vY1 = 0;
  44482. vZ1 = x11 * d4;
  44483. } else {
  44484. d4 = 1 / Math.sqrt(x22 + y22);
  44485. vX1 = y11 * d4;
  44486. vY1 = -x11 * d4;
  44487. vZ1 = 0;
  44488. }
  44489. slerpQX = vX1;
  44490. slerpQY = vY1;
  44491. slerpQZ = vZ1;
  44492. slerpQW = 0;
  44493. } else {
  44494. var cX1;
  44495. var cY1;
  44496. var cZ1;
  44497. cX1 = prevXY * newXZ - prevXZ * newXY;
  44498. cY1 = prevXZ * newXX - prevXX * newXZ;
  44499. cZ1 = prevXX * newXY - prevXY * newXX;
  44500. var w2 = Math.sqrt((1 + d3) * 0.5);
  44501. d3 = 0.5 / w2;
  44502. cX1 *= d3;
  44503. cY1 *= d3;
  44504. cZ1 *= d3;
  44505. slerpQX = cX1;
  44506. slerpQY = cY1;
  44507. slerpQZ = cZ1;
  44508. slerpQW = w2;
  44509. }
  44510. var x3 = slerpQX;
  44511. var y3 = slerpQY;
  44512. var z3 = slerpQZ;
  44513. var w3 = slerpQW;
  44514. var x23 = 2 * x3;
  44515. var y23 = 2 * y3;
  44516. var z23 = 2 * z3;
  44517. var xx1 = x3 * x23;
  44518. var yy1 = y3 * y23;
  44519. var zz1 = z3 * z23;
  44520. var xy1 = x3 * y23;
  44521. var yz1 = y3 * z23;
  44522. var xz1 = x3 * z23;
  44523. var wx1 = w3 * x23;
  44524. var wy1 = w3 * y23;
  44525. var wz1 = w3 * z23;
  44526. slerpM00 = 1 - yy1 - zz1;
  44527. slerpM01 = xy1 - wz1;
  44528. slerpM02 = xz1 + wy1;
  44529. slerpM10 = xy1 + wz1;
  44530. slerpM11 = 1 - xx1 - zz1;
  44531. slerpM12 = yz1 - wx1;
  44532. slerpM20 = xz1 - wy1;
  44533. slerpM21 = yz1 + wx1;
  44534. slerpM22 = 1 - xx1 - yy1;
  44535. var __tmp__X1;
  44536. var __tmp__Y1;
  44537. var __tmp__Z1;
  44538. __tmp__X1 = slerpM00 * prevYX + slerpM01 * prevYY + slerpM02 * prevYZ;
  44539. __tmp__Y1 = slerpM10 * prevYX + slerpM11 * prevYY + slerpM12 * prevYZ;
  44540. __tmp__Z1 = slerpM20 * prevYX + slerpM21 * prevYY + slerpM22 * prevYZ;
  44541. newYX = __tmp__X1;
  44542. newYY = __tmp__Y1;
  44543. newYZ = __tmp__Z1;
  44544. newZX = newXY * newYZ - newXZ * newYY;
  44545. newZY = newXZ * newYX - newXX * newYZ;
  44546. newZZ = newXX * newYY - newXY * newYX;
  44547. if(newZX * newZX + newZY * newZY + newZZ * newZZ > 1e-6) {
  44548. var l2 = newZX * newZX + newZY * newZY + newZZ * newZZ;
  44549. if(l2 > 0) {
  44550. l2 = 1 / Math.sqrt(l2);
  44551. }
  44552. newZX *= l2;
  44553. newZY *= l2;
  44554. newZZ *= l2;
  44555. } else {
  44556. var x12 = newXX;
  44557. var y12 = newXY;
  44558. var z12 = newXZ;
  44559. var x24 = x12 * x12;
  44560. var y24 = y12 * y12;
  44561. var z24 = z12 * z12;
  44562. var d5;
  44563. if(x24 < y24) {
  44564. if(x24 < z24) {
  44565. d5 = 1 / Math.sqrt(y24 + z24);
  44566. newZX = 0;
  44567. newZY = z12 * d5;
  44568. newZZ = -y12 * d5;
  44569. } else {
  44570. d5 = 1 / Math.sqrt(x24 + y24);
  44571. newZX = y12 * d5;
  44572. newZY = -x12 * d5;
  44573. newZZ = 0;
  44574. }
  44575. } else if(y24 < z24) {
  44576. d5 = 1 / Math.sqrt(z24 + x24);
  44577. newZX = -z12 * d5;
  44578. newZY = 0;
  44579. newZZ = x12 * d5;
  44580. } else {
  44581. d5 = 1 / Math.sqrt(x24 + y24);
  44582. newZX = y12 * d5;
  44583. newZY = -x12 * d5;
  44584. newZZ = 0;
  44585. }
  44586. }
  44587. newYX = newZY * newXZ - newZZ * newXY;
  44588. newYY = newZZ * newXX - newZX * newXZ;
  44589. newYZ = newZX * newXY - newZY * newXX;
  44590. _this.xX = newXX;
  44591. _this.xY = newXY;
  44592. _this.xZ = newXZ;
  44593. _this.yX = newYX;
  44594. _this.yY = newYY;
  44595. _this.yZ = newYZ;
  44596. _this.zX = newZX;
  44597. _this.zY = newZY;
  44598. _this.zZ = newZZ;
  44599. var angError;
  44600. var angErrorX;
  44601. var angErrorY;
  44602. var angErrorZ;
  44603. angErrorX = this._basisX1Y * this._basisX2Z - this._basisX1Z * this._basisX2Y;
  44604. angErrorY = this._basisX1Z * this._basisX2X - this._basisX1X * this._basisX2Z;
  44605. angErrorZ = this._basisX1X * this._basisX2Y - this._basisX1Y * this._basisX2X;
  44606. var cos1 = this._basisX1X * this._basisX2X + this._basisX1Y * this._basisX2Y + this._basisX1Z * this._basisX2Z;
  44607. var theta1 = cos1 <= -1 ? 3.14159265358979 : cos1 >= 1 ? 0 : Math.acos(cos1);
  44608. var l3 = angErrorX * angErrorX + angErrorY * angErrorY + angErrorZ * angErrorZ;
  44609. if(l3 > 0) {
  44610. l3 = 1 / Math.sqrt(l3);
  44611. }
  44612. angErrorX *= l3;
  44613. angErrorY *= l3;
  44614. angErrorZ *= l3;
  44615. angErrorX *= theta1;
  44616. angErrorY *= theta1;
  44617. angErrorZ *= theta1;
  44618. this.angularErrorY = angErrorX * this._basis.yX + angErrorY * this._basis.yY + angErrorZ * this._basis.yZ;
  44619. this.angularErrorZ = angErrorX * this._basis.zX + angErrorY * this._basis.zY + angErrorZ * this._basis.zZ;
  44620. var perpCross;
  44621. var perpCrossX;
  44622. var perpCrossY;
  44623. var perpCrossZ;
  44624. perpCrossX = this._basisY1Y * this._basisY2Z - this._basisY1Z * this._basisY2Y;
  44625. perpCrossY = this._basisY1Z * this._basisY2X - this._basisY1X * this._basisY2Z;
  44626. perpCrossZ = this._basisY1X * this._basisY2Y - this._basisY1Y * this._basisY2X;
  44627. cos1 = this._basisY1X * this._basisY2X + this._basisY1Y * this._basisY2Y + this._basisY1Z * this._basisY2Z;
  44628. this.angle = cos1 <= -1 ? 3.14159265358979 : cos1 >= 1 ? 0 : Math.acos(cos1);
  44629. if(perpCrossX * this._basis.xX + perpCrossY * this._basis.xY + perpCrossZ * this._basis.xZ < 0) {
  44630. this.angle = -this.angle;
  44631. }
  44632. this.linearErrorX = this._anchor2X - this._anchor1X;
  44633. this.linearErrorY = this._anchor2Y - this._anchor1Y;
  44634. this.linearErrorZ = this._anchor2Z - this._anchor1Z;
  44635. }
  44636. _getVelocitySolverInfo(timeStep,info) {
  44637. super._getVelocitySolverInfo(timeStep,info);
  44638. this.getInfo(info,timeStep,false);
  44639. }
  44640. _getPositionSolverInfo(info) {
  44641. super._getPositionSolverInfo(info);
  44642. this.getInfo(info,null,true);
  44643. }
  44644. getAxis1() {
  44645. var v = new oimo.common.Vec3();
  44646. var v1 = v;
  44647. v1.x = this._basisX1X;
  44648. v1.y = this._basisX1Y;
  44649. v1.z = this._basisX1Z;
  44650. return v;
  44651. }
  44652. getAxis2() {
  44653. var v = new oimo.common.Vec3();
  44654. var v1 = v;
  44655. v1.x = this._basisX2X;
  44656. v1.y = this._basisX2Y;
  44657. v1.z = this._basisX2Z;
  44658. return v;
  44659. }
  44660. getAxis1To(axis) {
  44661. var v = axis;
  44662. v.x = this._basisX1X;
  44663. v.y = this._basisX1Y;
  44664. v.z = this._basisX1Z;
  44665. }
  44666. getAxis2To(axis) {
  44667. var v = axis;
  44668. v.x = this._basisX2X;
  44669. v.y = this._basisX2Y;
  44670. v.z = this._basisX2Z;
  44671. }
  44672. getLocalAxis1() {
  44673. var v = new oimo.common.Vec3();
  44674. var v1 = v;
  44675. v1.x = this._localBasisX1X;
  44676. v1.y = this._localBasisX1Y;
  44677. v1.z = this._localBasisX1Z;
  44678. return v;
  44679. }
  44680. getLocalAxis2() {
  44681. var v = new oimo.common.Vec3();
  44682. var v1 = v;
  44683. v1.x = this._localBasisX2X;
  44684. v1.y = this._localBasisX2Y;
  44685. v1.z = this._localBasisX2Z;
  44686. return v;
  44687. }
  44688. getLocalAxis1To(axis) {
  44689. var v = axis;
  44690. v.x = this._localBasisX1X;
  44691. v.y = this._localBasisX1Y;
  44692. v.z = this._localBasisX1Z;
  44693. }
  44694. getLocalAxis2To(axis) {
  44695. var v = axis;
  44696. v.x = this._localBasisX2X;
  44697. v.y = this._localBasisX2Y;
  44698. v.z = this._localBasisX2Z;
  44699. }
  44700. getSpringDamper() {
  44701. return this._sd;
  44702. }
  44703. getLimitMotor() {
  44704. return this._lm;
  44705. }
  44706. getAngle() {
  44707. return this.angle;
  44708. }
  44709. }
  44710. oimo.dynamics.constraint.joint.RevoluteJointConfig = class oimo_dynamics_constraint_joint_RevoluteJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  44711. constructor() {
  44712. super();
  44713. this.localAxis1 = new oimo.common.Vec3(1,0,0);
  44714. this.localAxis2 = new oimo.common.Vec3(1,0,0);
  44715. this.springDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  44716. this.limitMotor = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  44717. }
  44718. init(rigidBody1,rigidBody2,worldAnchor,worldAxis) {
  44719. this._init(rigidBody1,rigidBody2,worldAnchor);
  44720. var v;
  44721. var vX;
  44722. var vY;
  44723. var vZ;
  44724. var v1 = worldAxis;
  44725. vX = v1.x;
  44726. vY = v1.y;
  44727. vZ = v1.z;
  44728. var __tmp__X;
  44729. var __tmp__Y;
  44730. var __tmp__Z;
  44731. __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ;
  44732. __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ;
  44733. __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ;
  44734. vX = __tmp__X;
  44735. vY = __tmp__Y;
  44736. vZ = __tmp__Z;
  44737. var v2 = this.localAxis1;
  44738. v2.x = vX;
  44739. v2.y = vY;
  44740. v2.z = vZ;
  44741. var v3;
  44742. var vX1;
  44743. var vY1;
  44744. var vZ1;
  44745. var v4 = worldAxis;
  44746. vX1 = v4.x;
  44747. vY1 = v4.y;
  44748. vZ1 = v4.z;
  44749. var __tmp__X1;
  44750. var __tmp__Y1;
  44751. var __tmp__Z1;
  44752. __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1;
  44753. __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1;
  44754. __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1;
  44755. vX1 = __tmp__X1;
  44756. vY1 = __tmp__Y1;
  44757. vZ1 = __tmp__Z1;
  44758. var v5 = this.localAxis2;
  44759. v5.x = vX1;
  44760. v5.y = vY1;
  44761. v5.z = vZ1;
  44762. return this;
  44763. }
  44764. }
  44765. oimo.dynamics.constraint.joint.RotationalLimitMotor = class oimo_dynamics_constraint_joint_RotationalLimitMotor {
  44766. constructor() {
  44767. this.lowerLimit = 1;
  44768. this.upperLimit = 0;
  44769. this.motorTorque = 0;
  44770. }
  44771. setLimits(lower,upper) {
  44772. this.lowerLimit = lower;
  44773. this.upperLimit = upper;
  44774. return this;
  44775. }
  44776. setMotor(speed,torque) {
  44777. this.motorSpeed = speed;
  44778. this.motorTorque = torque;
  44779. return this;
  44780. }
  44781. clone() {
  44782. var lm = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  44783. lm.lowerLimit = this.lowerLimit;
  44784. lm.upperLimit = this.upperLimit;
  44785. lm.motorSpeed = this.motorSpeed;
  44786. lm.motorTorque = this.motorTorque;
  44787. return lm;
  44788. }
  44789. }
  44790. oimo.dynamics.constraint.joint.SphericalJoint = class oimo_dynamics_constraint_joint_SphericalJoint extends oimo.dynamics.constraint.joint.Joint {
  44791. constructor(config) {
  44792. super(config,0);
  44793. this._sd = config.springDamper.clone();
  44794. }
  44795. getInfo(info,timeStep,isPositionPart) {
  44796. if(this._sd.frequency > 0 && isPositionPart) {
  44797. return;
  44798. }
  44799. var error;
  44800. var errorX;
  44801. var errorY;
  44802. var errorZ;
  44803. errorX = this._anchor2X - this._anchor1X;
  44804. errorY = this._anchor2Y - this._anchor1Y;
  44805. errorZ = this._anchor2Z - this._anchor1Z;
  44806. var cfm;
  44807. var erp;
  44808. if(this._sd.frequency > 0) {
  44809. var omega = 6.28318530717958 * this._sd.frequency;
  44810. var zeta = this._sd.dampingRatio;
  44811. if(zeta < oimo.common.Setting.minSpringDamperDampingRatio) {
  44812. zeta = oimo.common.Setting.minSpringDamperDampingRatio;
  44813. }
  44814. var h = timeStep.dt;
  44815. var c = 2 * zeta * omega;
  44816. var k = omega * omega;
  44817. if(this._sd.useSymplecticEuler) {
  44818. cfm = 1 / (h * c);
  44819. erp = k / c;
  44820. } else {
  44821. cfm = 1 / (h * (h * k + c));
  44822. erp = k / (h * k + c);
  44823. }
  44824. cfm *= this._b1._invMass + this._b2._invMass;
  44825. } else {
  44826. cfm = 0;
  44827. erp = this.getErp(timeStep,isPositionPart);
  44828. }
  44829. var linearRhs;
  44830. var linearRhsX;
  44831. var linearRhsY;
  44832. var linearRhsZ;
  44833. linearRhsX = errorX * erp;
  44834. linearRhsY = errorY * erp;
  44835. linearRhsZ = errorZ * erp;
  44836. var linRhsX = linearRhsX;
  44837. var linRhsY = linearRhsY;
  44838. var linRhsZ = linearRhsZ;
  44839. var crossR1;
  44840. var crossR100;
  44841. var crossR101;
  44842. var crossR102;
  44843. var crossR110;
  44844. var crossR111;
  44845. var crossR112;
  44846. var crossR120;
  44847. var crossR121;
  44848. var crossR122;
  44849. var crossR2;
  44850. var crossR200;
  44851. var crossR201;
  44852. var crossR202;
  44853. var crossR210;
  44854. var crossR211;
  44855. var crossR212;
  44856. var crossR220;
  44857. var crossR221;
  44858. var crossR222;
  44859. crossR100 = 0;
  44860. crossR101 = -this._relativeAnchor1Z;
  44861. crossR102 = this._relativeAnchor1Y;
  44862. crossR110 = this._relativeAnchor1Z;
  44863. crossR111 = 0;
  44864. crossR112 = -this._relativeAnchor1X;
  44865. crossR120 = -this._relativeAnchor1Y;
  44866. crossR121 = this._relativeAnchor1X;
  44867. crossR122 = 0;
  44868. crossR200 = 0;
  44869. crossR201 = -this._relativeAnchor2Z;
  44870. crossR202 = this._relativeAnchor2Y;
  44871. crossR210 = this._relativeAnchor2Z;
  44872. crossR211 = 0;
  44873. crossR212 = -this._relativeAnchor2X;
  44874. crossR220 = -this._relativeAnchor2Y;
  44875. crossR221 = this._relativeAnchor2X;
  44876. crossR222 = 0;
  44877. crossR100 = -crossR100;
  44878. crossR101 = -crossR101;
  44879. crossR102 = -crossR102;
  44880. crossR110 = -crossR110;
  44881. crossR111 = -crossR111;
  44882. crossR112 = -crossR112;
  44883. crossR120 = -crossR120;
  44884. crossR121 = -crossR121;
  44885. crossR122 = -crossR122;
  44886. crossR200 = -crossR200;
  44887. crossR201 = -crossR201;
  44888. crossR202 = -crossR202;
  44889. crossR210 = -crossR210;
  44890. crossR211 = -crossR211;
  44891. crossR212 = -crossR212;
  44892. crossR220 = -crossR220;
  44893. crossR221 = -crossR221;
  44894. crossR222 = -crossR222;
  44895. var impulse = this._impulses[0];
  44896. var row = info.rows[info.numRows++];
  44897. var _this = row.jacobian;
  44898. _this.lin1X = 0;
  44899. _this.lin1Y = 0;
  44900. _this.lin1Z = 0;
  44901. _this.lin2X = 0;
  44902. _this.lin2Y = 0;
  44903. _this.lin2Z = 0;
  44904. _this.ang1X = 0;
  44905. _this.ang1Y = 0;
  44906. _this.ang1Z = 0;
  44907. _this.ang2X = 0;
  44908. _this.ang2Y = 0;
  44909. _this.ang2Z = 0;
  44910. row.rhs = 0;
  44911. row.cfm = 0;
  44912. row.minImpulse = 0;
  44913. row.maxImpulse = 0;
  44914. row.motorSpeed = 0;
  44915. row.motorMaxImpulse = 0;
  44916. row.impulse = null;
  44917. row.impulse = impulse;
  44918. var row1 = row;
  44919. row1.rhs = linRhsX;
  44920. row1.cfm = cfm;
  44921. row1.minImpulse = -1e65536;
  44922. row1.maxImpulse = 1e65536;
  44923. var j = row1.jacobian;
  44924. j.lin1X = 1;
  44925. j.lin1Y = 0;
  44926. j.lin1Z = 0;
  44927. j.lin2X = 1;
  44928. j.lin2Y = 0;
  44929. j.lin2Z = 0;
  44930. j.ang1X = crossR100;
  44931. j.ang1Y = crossR101;
  44932. j.ang1Z = crossR102;
  44933. j.ang2X = crossR200;
  44934. j.ang2Y = crossR201;
  44935. j.ang2Z = crossR202;
  44936. var impulse1 = this._impulses[1];
  44937. var row2 = info.rows[info.numRows++];
  44938. var _this1 = row2.jacobian;
  44939. _this1.lin1X = 0;
  44940. _this1.lin1Y = 0;
  44941. _this1.lin1Z = 0;
  44942. _this1.lin2X = 0;
  44943. _this1.lin2Y = 0;
  44944. _this1.lin2Z = 0;
  44945. _this1.ang1X = 0;
  44946. _this1.ang1Y = 0;
  44947. _this1.ang1Z = 0;
  44948. _this1.ang2X = 0;
  44949. _this1.ang2Y = 0;
  44950. _this1.ang2Z = 0;
  44951. row2.rhs = 0;
  44952. row2.cfm = 0;
  44953. row2.minImpulse = 0;
  44954. row2.maxImpulse = 0;
  44955. row2.motorSpeed = 0;
  44956. row2.motorMaxImpulse = 0;
  44957. row2.impulse = null;
  44958. row2.impulse = impulse1;
  44959. row1 = row2;
  44960. row1.rhs = linRhsY;
  44961. row1.cfm = cfm;
  44962. row1.minImpulse = -1e65536;
  44963. row1.maxImpulse = 1e65536;
  44964. j = row1.jacobian;
  44965. j.lin1X = 0;
  44966. j.lin1Y = 1;
  44967. j.lin1Z = 0;
  44968. j.lin2X = 0;
  44969. j.lin2Y = 1;
  44970. j.lin2Z = 0;
  44971. j.ang1X = crossR110;
  44972. j.ang1Y = crossR111;
  44973. j.ang1Z = crossR112;
  44974. j.ang2X = crossR210;
  44975. j.ang2Y = crossR211;
  44976. j.ang2Z = crossR212;
  44977. var impulse2 = this._impulses[2];
  44978. var row3 = info.rows[info.numRows++];
  44979. var _this2 = row3.jacobian;
  44980. _this2.lin1X = 0;
  44981. _this2.lin1Y = 0;
  44982. _this2.lin1Z = 0;
  44983. _this2.lin2X = 0;
  44984. _this2.lin2Y = 0;
  44985. _this2.lin2Z = 0;
  44986. _this2.ang1X = 0;
  44987. _this2.ang1Y = 0;
  44988. _this2.ang1Z = 0;
  44989. _this2.ang2X = 0;
  44990. _this2.ang2Y = 0;
  44991. _this2.ang2Z = 0;
  44992. row3.rhs = 0;
  44993. row3.cfm = 0;
  44994. row3.minImpulse = 0;
  44995. row3.maxImpulse = 0;
  44996. row3.motorSpeed = 0;
  44997. row3.motorMaxImpulse = 0;
  44998. row3.impulse = null;
  44999. row3.impulse = impulse2;
  45000. row1 = row3;
  45001. row1.rhs = linRhsZ;
  45002. row1.cfm = cfm;
  45003. row1.minImpulse = -1e65536;
  45004. row1.maxImpulse = 1e65536;
  45005. j = row1.jacobian;
  45006. j.lin1X = 0;
  45007. j.lin1Y = 0;
  45008. j.lin1Z = 1;
  45009. j.lin2X = 0;
  45010. j.lin2Y = 0;
  45011. j.lin2Z = 1;
  45012. j.ang1X = crossR120;
  45013. j.ang1Y = crossR121;
  45014. j.ang1Z = crossR122;
  45015. j.ang2X = crossR220;
  45016. j.ang2Y = crossR221;
  45017. j.ang2Z = crossR222;
  45018. }
  45019. _getVelocitySolverInfo(timeStep,info) {
  45020. super._getVelocitySolverInfo(timeStep,info);
  45021. this.getInfo(info,timeStep,false);
  45022. }
  45023. _getPositionSolverInfo(info) {
  45024. super._getPositionSolverInfo(info);
  45025. this.getInfo(info,null,true);
  45026. }
  45027. getSpringDamper() {
  45028. return this._sd;
  45029. }
  45030. }
  45031. oimo.dynamics.constraint.joint.SphericalJointConfig = class oimo_dynamics_constraint_joint_SphericalJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  45032. constructor() {
  45033. super();
  45034. this.springDamper = new oimo.dynamics.constraint.joint.SpringDamper();
  45035. }
  45036. init(rigidBody1,rigidBody2,worldAnchor) {
  45037. this._init(rigidBody1,rigidBody2,worldAnchor);
  45038. return this;
  45039. }
  45040. }
  45041. oimo.dynamics.constraint.joint.SpringDamper = class oimo_dynamics_constraint_joint_SpringDamper {
  45042. constructor() {
  45043. this.frequency = 0;
  45044. this.dampingRatio = 0;
  45045. this.useSymplecticEuler = false;
  45046. }
  45047. setSpring(frequency,dampingRatio) {
  45048. this.frequency = frequency;
  45049. this.dampingRatio = dampingRatio;
  45050. return this;
  45051. }
  45052. setSymplecticEuler(useSymplecticEuler) {
  45053. this.useSymplecticEuler = useSymplecticEuler;
  45054. return this;
  45055. }
  45056. clone() {
  45057. var sd = new oimo.dynamics.constraint.joint.SpringDamper();
  45058. sd.frequency = this.frequency;
  45059. sd.dampingRatio = this.dampingRatio;
  45060. sd.useSymplecticEuler = this.useSymplecticEuler;
  45061. return sd;
  45062. }
  45063. }
  45064. oimo.dynamics.constraint.joint.TranslationalLimitMotor = class oimo_dynamics_constraint_joint_TranslationalLimitMotor {
  45065. constructor() {
  45066. this.lowerLimit = 1;
  45067. this.upperLimit = 0;
  45068. this.motorForce = 0;
  45069. }
  45070. setLimits(lower,upper) {
  45071. this.lowerLimit = lower;
  45072. this.upperLimit = upper;
  45073. return this;
  45074. }
  45075. setMotor(speed,force) {
  45076. this.motorSpeed = speed;
  45077. this.motorForce = force;
  45078. return this;
  45079. }
  45080. clone() {
  45081. var lm = new oimo.dynamics.constraint.joint.TranslationalLimitMotor();
  45082. lm.lowerLimit = this.lowerLimit;
  45083. lm.upperLimit = this.upperLimit;
  45084. lm.motorSpeed = this.motorSpeed;
  45085. lm.motorForce = this.motorForce;
  45086. return lm;
  45087. }
  45088. }
  45089. oimo.dynamics.constraint.joint.UniversalJoint = class oimo_dynamics_constraint_joint_UniversalJoint extends oimo.dynamics.constraint.joint.Joint {
  45090. constructor(config) {
  45091. super(config,oimo.dynamics.constraint.joint.JointType.UNIVERSAL);
  45092. var v = config.localAxis1;
  45093. this._localBasisX1X = v.x;
  45094. this._localBasisX1Y = v.y;
  45095. this._localBasisX1Z = v.z;
  45096. var v1 = config.localAxis2;
  45097. this._localBasisZ2X = v1.x;
  45098. this._localBasisZ2Y = v1.y;
  45099. this._localBasisZ2Z = v1.z;
  45100. this.buildLocalBasesFromX1Z2();
  45101. this._angleX = 0;
  45102. this._angleY = 0;
  45103. this._angleZ = 0;
  45104. this.xSingular = false;
  45105. this.ySingular = false;
  45106. this.zSingular = false;
  45107. this._sd1 = config.springDamper1.clone();
  45108. this._sd2 = config.springDamper2.clone();
  45109. this._lm1 = config.limitMotor1.clone();
  45110. this._lm2 = config.limitMotor2.clone();
  45111. }
  45112. getInfo(info,timeStep,isPositionPart) {
  45113. var erp = this.getErp(timeStep,isPositionPart);
  45114. var linearRhs;
  45115. var linearRhsX;
  45116. var linearRhsY;
  45117. var linearRhsZ;
  45118. linearRhsX = this.linearErrorX * erp;
  45119. linearRhsY = this.linearErrorY * erp;
  45120. linearRhsZ = this.linearErrorZ * erp;
  45121. var linRhsX = linearRhsX;
  45122. var linRhsY = linearRhsY;
  45123. var linRhsZ = linearRhsZ;
  45124. var angRhsY = this._angleY * erp;
  45125. var crossR1;
  45126. var crossR100;
  45127. var crossR101;
  45128. var crossR102;
  45129. var crossR110;
  45130. var crossR111;
  45131. var crossR112;
  45132. var crossR120;
  45133. var crossR121;
  45134. var crossR122;
  45135. var crossR2;
  45136. var crossR200;
  45137. var crossR201;
  45138. var crossR202;
  45139. var crossR210;
  45140. var crossR211;
  45141. var crossR212;
  45142. var crossR220;
  45143. var crossR221;
  45144. var crossR222;
  45145. crossR100 = 0;
  45146. crossR101 = -this._relativeAnchor1Z;
  45147. crossR102 = this._relativeAnchor1Y;
  45148. crossR110 = this._relativeAnchor1Z;
  45149. crossR111 = 0;
  45150. crossR112 = -this._relativeAnchor1X;
  45151. crossR120 = -this._relativeAnchor1Y;
  45152. crossR121 = this._relativeAnchor1X;
  45153. crossR122 = 0;
  45154. crossR200 = 0;
  45155. crossR201 = -this._relativeAnchor2Z;
  45156. crossR202 = this._relativeAnchor2Y;
  45157. crossR210 = this._relativeAnchor2Z;
  45158. crossR211 = 0;
  45159. crossR212 = -this._relativeAnchor2X;
  45160. crossR220 = -this._relativeAnchor2Y;
  45161. crossR221 = this._relativeAnchor2X;
  45162. crossR222 = 0;
  45163. crossR100 = -crossR100;
  45164. crossR101 = -crossR101;
  45165. crossR102 = -crossR102;
  45166. crossR110 = -crossR110;
  45167. crossR111 = -crossR111;
  45168. crossR112 = -crossR112;
  45169. crossR120 = -crossR120;
  45170. crossR121 = -crossR121;
  45171. crossR122 = -crossR122;
  45172. crossR200 = -crossR200;
  45173. crossR201 = -crossR201;
  45174. crossR202 = -crossR202;
  45175. crossR210 = -crossR210;
  45176. crossR211 = -crossR211;
  45177. crossR212 = -crossR212;
  45178. crossR220 = -crossR220;
  45179. crossR221 = -crossR221;
  45180. crossR222 = -crossR222;
  45181. var motorMassX = this.computeEffectiveInertiaMoment(this._axisXX,this._axisXY,this._axisXZ);
  45182. var motorMassZ = this.computeEffectiveInertiaMoment(this._axisZX,this._axisZY,this._axisZZ);
  45183. var impulse = this._impulses[0];
  45184. var row = info.rows[info.numRows++];
  45185. var _this = row.jacobian;
  45186. _this.lin1X = 0;
  45187. _this.lin1Y = 0;
  45188. _this.lin1Z = 0;
  45189. _this.lin2X = 0;
  45190. _this.lin2Y = 0;
  45191. _this.lin2Z = 0;
  45192. _this.ang1X = 0;
  45193. _this.ang1Y = 0;
  45194. _this.ang1Z = 0;
  45195. _this.ang2X = 0;
  45196. _this.ang2Y = 0;
  45197. _this.ang2Z = 0;
  45198. row.rhs = 0;
  45199. row.cfm = 0;
  45200. row.minImpulse = 0;
  45201. row.maxImpulse = 0;
  45202. row.motorSpeed = 0;
  45203. row.motorMaxImpulse = 0;
  45204. row.impulse = null;
  45205. row.impulse = impulse;
  45206. var row1 = row;
  45207. row1.rhs = linRhsX;
  45208. row1.cfm = 0;
  45209. row1.minImpulse = -1e65536;
  45210. row1.maxImpulse = 1e65536;
  45211. var j = row1.jacobian;
  45212. j.lin1X = 1;
  45213. j.lin1Y = 0;
  45214. j.lin1Z = 0;
  45215. j.lin2X = 1;
  45216. j.lin2Y = 0;
  45217. j.lin2Z = 0;
  45218. j.ang1X = crossR100;
  45219. j.ang1Y = crossR101;
  45220. j.ang1Z = crossR102;
  45221. j.ang2X = crossR200;
  45222. j.ang2Y = crossR201;
  45223. j.ang2Z = crossR202;
  45224. var impulse1 = this._impulses[1];
  45225. var row2 = info.rows[info.numRows++];
  45226. var _this1 = row2.jacobian;
  45227. _this1.lin1X = 0;
  45228. _this1.lin1Y = 0;
  45229. _this1.lin1Z = 0;
  45230. _this1.lin2X = 0;
  45231. _this1.lin2Y = 0;
  45232. _this1.lin2Z = 0;
  45233. _this1.ang1X = 0;
  45234. _this1.ang1Y = 0;
  45235. _this1.ang1Z = 0;
  45236. _this1.ang2X = 0;
  45237. _this1.ang2Y = 0;
  45238. _this1.ang2Z = 0;
  45239. row2.rhs = 0;
  45240. row2.cfm = 0;
  45241. row2.minImpulse = 0;
  45242. row2.maxImpulse = 0;
  45243. row2.motorSpeed = 0;
  45244. row2.motorMaxImpulse = 0;
  45245. row2.impulse = null;
  45246. row2.impulse = impulse1;
  45247. row1 = row2;
  45248. row1.rhs = linRhsY;
  45249. row1.cfm = 0;
  45250. row1.minImpulse = -1e65536;
  45251. row1.maxImpulse = 1e65536;
  45252. j = row1.jacobian;
  45253. j.lin1X = 0;
  45254. j.lin1Y = 1;
  45255. j.lin1Z = 0;
  45256. j.lin2X = 0;
  45257. j.lin2Y = 1;
  45258. j.lin2Z = 0;
  45259. j.ang1X = crossR110;
  45260. j.ang1Y = crossR111;
  45261. j.ang1Z = crossR112;
  45262. j.ang2X = crossR210;
  45263. j.ang2Y = crossR211;
  45264. j.ang2Z = crossR212;
  45265. var impulse2 = this._impulses[2];
  45266. var row3 = info.rows[info.numRows++];
  45267. var _this2 = row3.jacobian;
  45268. _this2.lin1X = 0;
  45269. _this2.lin1Y = 0;
  45270. _this2.lin1Z = 0;
  45271. _this2.lin2X = 0;
  45272. _this2.lin2Y = 0;
  45273. _this2.lin2Z = 0;
  45274. _this2.ang1X = 0;
  45275. _this2.ang1Y = 0;
  45276. _this2.ang1Z = 0;
  45277. _this2.ang2X = 0;
  45278. _this2.ang2Y = 0;
  45279. _this2.ang2Z = 0;
  45280. row3.rhs = 0;
  45281. row3.cfm = 0;
  45282. row3.minImpulse = 0;
  45283. row3.maxImpulse = 0;
  45284. row3.motorSpeed = 0;
  45285. row3.motorMaxImpulse = 0;
  45286. row3.impulse = null;
  45287. row3.impulse = impulse2;
  45288. row1 = row3;
  45289. row1.rhs = linRhsZ;
  45290. row1.cfm = 0;
  45291. row1.minImpulse = -1e65536;
  45292. row1.maxImpulse = 1e65536;
  45293. j = row1.jacobian;
  45294. j.lin1X = 0;
  45295. j.lin1Y = 0;
  45296. j.lin1Z = 1;
  45297. j.lin2X = 0;
  45298. j.lin2Y = 0;
  45299. j.lin2Z = 1;
  45300. j.ang1X = crossR120;
  45301. j.ang1Y = crossR121;
  45302. j.ang1Z = crossR122;
  45303. j.ang2X = crossR220;
  45304. j.ang2Y = crossR221;
  45305. j.ang2Z = crossR222;
  45306. if(!this.xSingular && (this._sd1.frequency <= 0 || !isPositionPart)) {
  45307. var impulse3 = this._impulses[3];
  45308. var row4 = info.rows[info.numRows++];
  45309. var _this3 = row4.jacobian;
  45310. _this3.lin1X = 0;
  45311. _this3.lin1Y = 0;
  45312. _this3.lin1Z = 0;
  45313. _this3.lin2X = 0;
  45314. _this3.lin2Y = 0;
  45315. _this3.lin2Z = 0;
  45316. _this3.ang1X = 0;
  45317. _this3.ang1Y = 0;
  45318. _this3.ang1Z = 0;
  45319. _this3.ang2X = 0;
  45320. _this3.ang2Y = 0;
  45321. _this3.ang2Z = 0;
  45322. row4.rhs = 0;
  45323. row4.cfm = 0;
  45324. row4.minImpulse = 0;
  45325. row4.maxImpulse = 0;
  45326. row4.motorSpeed = 0;
  45327. row4.motorMaxImpulse = 0;
  45328. row4.impulse = null;
  45329. row4.impulse = impulse3;
  45330. row1 = row4;
  45331. this.setSolverInfoRowAngular(row1,this._angleX,this._lm1,motorMassX,this._sd1,timeStep,isPositionPart);
  45332. j = row1.jacobian;
  45333. j.ang1X = this._axisXX;
  45334. j.ang1Y = this._axisXY;
  45335. j.ang1Z = this._axisXZ;
  45336. j.ang2X = this._axisXX;
  45337. j.ang2Y = this._axisXY;
  45338. j.ang2Z = this._axisXZ;
  45339. }
  45340. if(!this.ySingular) {
  45341. var impulse4 = this._impulses[4];
  45342. var row5 = info.rows[info.numRows++];
  45343. var _this4 = row5.jacobian;
  45344. _this4.lin1X = 0;
  45345. _this4.lin1Y = 0;
  45346. _this4.lin1Z = 0;
  45347. _this4.lin2X = 0;
  45348. _this4.lin2Y = 0;
  45349. _this4.lin2Z = 0;
  45350. _this4.ang1X = 0;
  45351. _this4.ang1Y = 0;
  45352. _this4.ang1Z = 0;
  45353. _this4.ang2X = 0;
  45354. _this4.ang2Y = 0;
  45355. _this4.ang2Z = 0;
  45356. row5.rhs = 0;
  45357. row5.cfm = 0;
  45358. row5.minImpulse = 0;
  45359. row5.maxImpulse = 0;
  45360. row5.motorSpeed = 0;
  45361. row5.motorMaxImpulse = 0;
  45362. row5.impulse = null;
  45363. row5.impulse = impulse4;
  45364. row1 = row5;
  45365. row1.rhs = angRhsY;
  45366. row1.cfm = 0;
  45367. row1.minImpulse = -1e65536;
  45368. row1.maxImpulse = 1e65536;
  45369. j = row1.jacobian;
  45370. j.ang1X = this._axisYX;
  45371. j.ang1Y = this._axisYY;
  45372. j.ang1Z = this._axisYZ;
  45373. j.ang2X = this._axisYX;
  45374. j.ang2Y = this._axisYY;
  45375. j.ang2Z = this._axisYZ;
  45376. }
  45377. if(!this.zSingular && (this._sd2.frequency <= 0 || !isPositionPart)) {
  45378. var impulse5 = this._impulses[5];
  45379. var row6 = info.rows[info.numRows++];
  45380. var _this5 = row6.jacobian;
  45381. _this5.lin1X = 0;
  45382. _this5.lin1Y = 0;
  45383. _this5.lin1Z = 0;
  45384. _this5.lin2X = 0;
  45385. _this5.lin2Y = 0;
  45386. _this5.lin2Z = 0;
  45387. _this5.ang1X = 0;
  45388. _this5.ang1Y = 0;
  45389. _this5.ang1Z = 0;
  45390. _this5.ang2X = 0;
  45391. _this5.ang2Y = 0;
  45392. _this5.ang2Z = 0;
  45393. row6.rhs = 0;
  45394. row6.cfm = 0;
  45395. row6.minImpulse = 0;
  45396. row6.maxImpulse = 0;
  45397. row6.motorSpeed = 0;
  45398. row6.motorMaxImpulse = 0;
  45399. row6.impulse = null;
  45400. row6.impulse = impulse5;
  45401. row1 = row6;
  45402. this.setSolverInfoRowAngular(row1,this._angleZ,this._lm2,motorMassZ,this._sd2,timeStep,isPositionPart);
  45403. j = row1.jacobian;
  45404. j.ang1X = this._axisZX;
  45405. j.ang1Y = this._axisZY;
  45406. j.ang1Z = this._axisZZ;
  45407. j.ang2X = this._axisZX;
  45408. j.ang2Y = this._axisZY;
  45409. j.ang2Z = this._axisZZ;
  45410. }
  45411. }
  45412. _syncAnchors() {
  45413. super._syncAnchors();
  45414. var rot1;
  45415. var rot100;
  45416. var rot101;
  45417. var rot102;
  45418. var rot110;
  45419. var rot111;
  45420. var rot112;
  45421. var rot120;
  45422. var rot121;
  45423. var rot122;
  45424. var rot2;
  45425. var rot200;
  45426. var rot201;
  45427. var rot202;
  45428. var rot210;
  45429. var rot211;
  45430. var rot212;
  45431. var rot220;
  45432. var rot221;
  45433. var rot222;
  45434. rot100 = this._basisX1X;
  45435. rot101 = this._basisY1X;
  45436. rot102 = this._basisZ1X;
  45437. rot110 = this._basisX1Y;
  45438. rot111 = this._basisY1Y;
  45439. rot112 = this._basisZ1Y;
  45440. rot120 = this._basisX1Z;
  45441. rot121 = this._basisY1Z;
  45442. rot122 = this._basisZ1Z;
  45443. rot200 = this._basisX2X;
  45444. rot201 = this._basisY2X;
  45445. rot202 = this._basisZ2X;
  45446. rot210 = this._basisX2Y;
  45447. rot211 = this._basisY2Y;
  45448. rot212 = this._basisZ2Y;
  45449. rot220 = this._basisX2Z;
  45450. rot221 = this._basisY2Z;
  45451. rot222 = this._basisZ2Z;
  45452. var relRot;
  45453. var relRot00;
  45454. var relRot01;
  45455. var relRot02;
  45456. var relRot10;
  45457. var relRot11;
  45458. var relRot12;
  45459. var relRot20;
  45460. var relRot21;
  45461. var relRot22;
  45462. var __tmp__00;
  45463. var __tmp__01;
  45464. var __tmp__02;
  45465. var __tmp__10;
  45466. var __tmp__11;
  45467. var __tmp__12;
  45468. var __tmp__20;
  45469. var __tmp__21;
  45470. var __tmp__22;
  45471. __tmp__00 = rot100 * rot200 + rot110 * rot210 + rot120 * rot220;
  45472. __tmp__01 = rot100 * rot201 + rot110 * rot211 + rot120 * rot221;
  45473. __tmp__02 = rot100 * rot202 + rot110 * rot212 + rot120 * rot222;
  45474. __tmp__10 = rot101 * rot200 + rot111 * rot210 + rot121 * rot220;
  45475. __tmp__11 = rot101 * rot201 + rot111 * rot211 + rot121 * rot221;
  45476. __tmp__12 = rot101 * rot202 + rot111 * rot212 + rot121 * rot222;
  45477. __tmp__20 = rot102 * rot200 + rot112 * rot210 + rot122 * rot220;
  45478. __tmp__21 = rot102 * rot201 + rot112 * rot211 + rot122 * rot221;
  45479. __tmp__22 = rot102 * rot202 + rot112 * rot212 + rot122 * rot222;
  45480. relRot00 = __tmp__00;
  45481. relRot01 = __tmp__01;
  45482. relRot02 = __tmp__02;
  45483. relRot10 = __tmp__10;
  45484. relRot11 = __tmp__11;
  45485. relRot12 = __tmp__12;
  45486. relRot20 = __tmp__20;
  45487. relRot21 = __tmp__21;
  45488. relRot22 = __tmp__22;
  45489. var angleAxisX;
  45490. var angleAxisXX;
  45491. var angleAxisXY;
  45492. var angleAxisXZ;
  45493. var angleAxisY;
  45494. var angleAxisYX;
  45495. var angleAxisYY;
  45496. var angleAxisYZ;
  45497. var angleAxisZ;
  45498. var angleAxisZX;
  45499. var angleAxisZY;
  45500. var angleAxisZZ;
  45501. angleAxisXX = this._basisX1X;
  45502. angleAxisXY = this._basisX1Y;
  45503. angleAxisXZ = this._basisX1Z;
  45504. angleAxisZX = this._basisZ2X;
  45505. angleAxisZY = this._basisZ2Y;
  45506. angleAxisZZ = this._basisZ2Z;
  45507. angleAxisYX = angleAxisZY * angleAxisXZ - angleAxisZZ * angleAxisXY;
  45508. angleAxisYY = angleAxisZZ * angleAxisXX - angleAxisZX * angleAxisXZ;
  45509. angleAxisYZ = angleAxisZX * angleAxisXY - angleAxisZY * angleAxisXX;
  45510. this._axisXX = angleAxisYY * angleAxisZZ - angleAxisYZ * angleAxisZY;
  45511. this._axisXY = angleAxisYZ * angleAxisZX - angleAxisYX * angleAxisZZ;
  45512. this._axisXZ = angleAxisYX * angleAxisZY - angleAxisYY * angleAxisZX;
  45513. this._axisYX = angleAxisYX;
  45514. this._axisYY = angleAxisYY;
  45515. this._axisYZ = angleAxisYZ;
  45516. this._axisZX = angleAxisXY * angleAxisYZ - angleAxisXZ * angleAxisYY;
  45517. this._axisZY = angleAxisXZ * angleAxisYX - angleAxisXX * angleAxisYZ;
  45518. this._axisZZ = angleAxisXX * angleAxisYY - angleAxisXY * angleAxisYX;
  45519. var l = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ;
  45520. if(l > 0) {
  45521. l = 1 / Math.sqrt(l);
  45522. }
  45523. this._axisXX *= l;
  45524. this._axisXY *= l;
  45525. this._axisXZ *= l;
  45526. var l1 = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ;
  45527. if(l1 > 0) {
  45528. l1 = 1 / Math.sqrt(l1);
  45529. }
  45530. this._axisYX *= l1;
  45531. this._axisYY *= l1;
  45532. this._axisYZ *= l1;
  45533. var l2 = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ;
  45534. if(l2 > 0) {
  45535. l2 = 1 / Math.sqrt(l2);
  45536. }
  45537. this._axisZX *= l2;
  45538. this._axisZY *= l2;
  45539. this._axisZZ *= l2;
  45540. this.xSingular = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ == 0;
  45541. this.ySingular = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ == 0;
  45542. this.zSingular = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ == 0;
  45543. var rot11;
  45544. var rot1001;
  45545. var rot1011;
  45546. var rot1021;
  45547. var rot1101;
  45548. var rot1111;
  45549. var rot1121;
  45550. var rot1201;
  45551. var rot1211;
  45552. var rot1221;
  45553. var rot21;
  45554. var rot2001;
  45555. var rot2011;
  45556. var rot2021;
  45557. var rot2101;
  45558. var rot2111;
  45559. var rot2121;
  45560. var rot2201;
  45561. var rot2211;
  45562. var rot2221;
  45563. rot1001 = this._basisX1X;
  45564. rot1011 = this._basisY1X;
  45565. rot1021 = this._basisZ1X;
  45566. rot1101 = this._basisX1Y;
  45567. rot1111 = this._basisY1Y;
  45568. rot1121 = this._basisZ1Y;
  45569. rot1201 = this._basisX1Z;
  45570. rot1211 = this._basisY1Z;
  45571. rot1221 = this._basisZ1Z;
  45572. rot2001 = this._basisX2X;
  45573. rot2011 = this._basisY2X;
  45574. rot2021 = this._basisZ2X;
  45575. rot2101 = this._basisX2Y;
  45576. rot2111 = this._basisY2Y;
  45577. rot2121 = this._basisZ2Y;
  45578. rot2201 = this._basisX2Z;
  45579. rot2211 = this._basisY2Z;
  45580. rot2221 = this._basisZ2Z;
  45581. var relRot1;
  45582. var relRot001;
  45583. var relRot011;
  45584. var relRot021;
  45585. var relRot101;
  45586. var relRot111;
  45587. var relRot121;
  45588. var relRot201;
  45589. var relRot211;
  45590. var relRot221;
  45591. var __tmp__001;
  45592. var __tmp__011;
  45593. var __tmp__021;
  45594. var __tmp__101;
  45595. var __tmp__111;
  45596. var __tmp__121;
  45597. var __tmp__201;
  45598. var __tmp__211;
  45599. var __tmp__221;
  45600. __tmp__001 = rot1001 * rot2001 + rot1101 * rot2101 + rot1201 * rot2201;
  45601. __tmp__011 = rot1001 * rot2011 + rot1101 * rot2111 + rot1201 * rot2211;
  45602. __tmp__021 = rot1001 * rot2021 + rot1101 * rot2121 + rot1201 * rot2221;
  45603. __tmp__101 = rot1011 * rot2001 + rot1111 * rot2101 + rot1211 * rot2201;
  45604. __tmp__111 = rot1011 * rot2011 + rot1111 * rot2111 + rot1211 * rot2211;
  45605. __tmp__121 = rot1011 * rot2021 + rot1111 * rot2121 + rot1211 * rot2221;
  45606. __tmp__201 = rot1021 * rot2001 + rot1121 * rot2101 + rot1221 * rot2201;
  45607. __tmp__211 = rot1021 * rot2011 + rot1121 * rot2111 + rot1221 * rot2211;
  45608. __tmp__221 = rot1021 * rot2021 + rot1121 * rot2121 + rot1221 * rot2221;
  45609. relRot001 = __tmp__001;
  45610. relRot011 = __tmp__011;
  45611. relRot021 = __tmp__021;
  45612. relRot101 = __tmp__101;
  45613. relRot111 = __tmp__111;
  45614. relRot121 = __tmp__121;
  45615. relRot201 = __tmp__201;
  45616. relRot211 = __tmp__211;
  45617. relRot221 = __tmp__221;
  45618. var angles;
  45619. var anglesX;
  45620. var anglesY;
  45621. var anglesZ;
  45622. var sy = relRot021;
  45623. if(sy <= -1) {
  45624. var xSubZ = Math.atan2(relRot211,relRot111);
  45625. anglesX = xSubZ * 0.5;
  45626. anglesY = -1.570796326794895;
  45627. anglesZ = -xSubZ * 0.5;
  45628. } else if(sy >= 1) {
  45629. var xAddZ = Math.atan2(relRot211,relRot111);
  45630. anglesX = xAddZ * 0.5;
  45631. anglesY = 1.570796326794895;
  45632. anglesZ = xAddZ * 0.5;
  45633. } else {
  45634. var y = Math.asin(sy);
  45635. var x = Math.atan2(-relRot121,relRot221);
  45636. var z = Math.atan2(-relRot011,relRot001);
  45637. anglesX = x;
  45638. anglesY = y;
  45639. anglesZ = z;
  45640. }
  45641. this._angleX = anglesX;
  45642. this._angleY = anglesY;
  45643. this._angleZ = anglesZ;
  45644. this.linearErrorX = this._anchor2X - this._anchor1X;
  45645. this.linearErrorY = this._anchor2Y - this._anchor1Y;
  45646. this.linearErrorZ = this._anchor2Z - this._anchor1Z;
  45647. }
  45648. _getVelocitySolverInfo(timeStep,info) {
  45649. super._getVelocitySolverInfo(timeStep,info);
  45650. this.getInfo(info,timeStep,false);
  45651. }
  45652. _getPositionSolverInfo(info) {
  45653. super._getPositionSolverInfo(info);
  45654. this.getInfo(info,null,true);
  45655. }
  45656. getAxis1() {
  45657. var v = new oimo.common.Vec3();
  45658. var v1 = v;
  45659. v1.x = this._basisX1X;
  45660. v1.y = this._basisX1Y;
  45661. v1.z = this._basisX1Z;
  45662. return v;
  45663. }
  45664. getAxis2() {
  45665. var v = new oimo.common.Vec3();
  45666. var v1 = v;
  45667. v1.x = this._basisZ2X;
  45668. v1.y = this._basisZ2Y;
  45669. v1.z = this._basisZ2Z;
  45670. return v;
  45671. }
  45672. getAxis1To(axis) {
  45673. var v = axis;
  45674. v.x = this._basisX1X;
  45675. v.y = this._basisX1Y;
  45676. v.z = this._basisX1Z;
  45677. }
  45678. getAxis2To(axis) {
  45679. var v = axis;
  45680. v.x = this._basisZ2X;
  45681. v.y = this._basisZ2Y;
  45682. v.z = this._basisZ2Z;
  45683. }
  45684. getLocalAxis1() {
  45685. var v = new oimo.common.Vec3();
  45686. var v1 = v;
  45687. v1.x = this._localBasisX1X;
  45688. v1.y = this._localBasisX1Y;
  45689. v1.z = this._localBasisX1Z;
  45690. return v;
  45691. }
  45692. getLocalAxis2() {
  45693. var v = new oimo.common.Vec3();
  45694. var v1 = v;
  45695. v1.x = this._localBasisZ2X;
  45696. v1.y = this._localBasisZ2Y;
  45697. v1.z = this._localBasisZ2Z;
  45698. return v;
  45699. }
  45700. getLocalAxis1To(axis) {
  45701. var v = axis;
  45702. v.x = this._localBasisX1X;
  45703. v.y = this._localBasisX1Y;
  45704. v.z = this._localBasisX1Z;
  45705. }
  45706. getLocalAxis2To(axis) {
  45707. var v = axis;
  45708. v.x = this._localBasisZ2X;
  45709. v.y = this._localBasisZ2Y;
  45710. v.z = this._localBasisZ2Z;
  45711. }
  45712. getSpringDamper1() {
  45713. return this._sd1;
  45714. }
  45715. getSpringDamper2() {
  45716. return this._sd2;
  45717. }
  45718. getLimitMotor1() {
  45719. return this._lm1;
  45720. }
  45721. getLimitMotor2() {
  45722. return this._lm2;
  45723. }
  45724. getAngle1() {
  45725. return this._angleX;
  45726. }
  45727. getAngle2() {
  45728. return this._angleZ;
  45729. }
  45730. }
  45731. oimo.dynamics.constraint.joint.UniversalJointConfig = class oimo_dynamics_constraint_joint_UniversalJointConfig extends oimo.dynamics.constraint.joint.JointConfig {
  45732. constructor() {
  45733. super();
  45734. this.localAxis1 = new oimo.common.Vec3(1,0,0);
  45735. this.localAxis2 = new oimo.common.Vec3(1,0,0);
  45736. this.springDamper1 = new oimo.dynamics.constraint.joint.SpringDamper();
  45737. this.springDamper2 = new oimo.dynamics.constraint.joint.SpringDamper();
  45738. this.limitMotor1 = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  45739. this.limitMotor2 = new oimo.dynamics.constraint.joint.RotationalLimitMotor();
  45740. }
  45741. init(rigidBody1,rigidBody2,worldAnchor,worldAxis1,worldAxis2) {
  45742. this._init(rigidBody1,rigidBody2,worldAnchor);
  45743. var v;
  45744. var vX;
  45745. var vY;
  45746. var vZ;
  45747. var v1 = worldAxis1;
  45748. vX = v1.x;
  45749. vY = v1.y;
  45750. vZ = v1.z;
  45751. var __tmp__X;
  45752. var __tmp__Y;
  45753. var __tmp__Z;
  45754. __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ;
  45755. __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ;
  45756. __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ;
  45757. vX = __tmp__X;
  45758. vY = __tmp__Y;
  45759. vZ = __tmp__Z;
  45760. var v2 = this.localAxis1;
  45761. v2.x = vX;
  45762. v2.y = vY;
  45763. v2.z = vZ;
  45764. var v3;
  45765. var vX1;
  45766. var vY1;
  45767. var vZ1;
  45768. var v4 = worldAxis2;
  45769. vX1 = v4.x;
  45770. vY1 = v4.y;
  45771. vZ1 = v4.z;
  45772. var __tmp__X1;
  45773. var __tmp__Y1;
  45774. var __tmp__Z1;
  45775. __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1;
  45776. __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1;
  45777. __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1;
  45778. vX1 = __tmp__X1;
  45779. vY1 = __tmp__Y1;
  45780. vZ1 = __tmp__Z1;
  45781. var v5 = this.localAxis2;
  45782. v5.x = vX1;
  45783. v5.y = vY1;
  45784. v5.z = vZ1;
  45785. return this;
  45786. }
  45787. }
  45788. if(!oimo.dynamics.constraint.solver) oimo.dynamics.constraint.solver = {};
  45789. oimo.dynamics.constraint.solver.ConstraintSolverType = class oimo_dynamics_constraint_solver_ConstraintSolverType {
  45790. }
  45791. if(!oimo.dynamics.constraint.solver.common) oimo.dynamics.constraint.solver.common = {};
  45792. oimo.dynamics.constraint.solver.common.ContactSolverMassDataRow = class oimo_dynamics_constraint_solver_common_ContactSolverMassDataRow {
  45793. constructor() {
  45794. this.invMLinN1X = 0;
  45795. this.invMLinN1Y = 0;
  45796. this.invMLinN1Z = 0;
  45797. this.invMLinN2X = 0;
  45798. this.invMLinN2Y = 0;
  45799. this.invMLinN2Z = 0;
  45800. this.invMAngN1X = 0;
  45801. this.invMAngN1Y = 0;
  45802. this.invMAngN1Z = 0;
  45803. this.invMAngN2X = 0;
  45804. this.invMAngN2Y = 0;
  45805. this.invMAngN2Z = 0;
  45806. this.invMLinT1X = 0;
  45807. this.invMLinT1Y = 0;
  45808. this.invMLinT1Z = 0;
  45809. this.invMLinT2X = 0;
  45810. this.invMLinT2Y = 0;
  45811. this.invMLinT2Z = 0;
  45812. this.invMAngT1X = 0;
  45813. this.invMAngT1Y = 0;
  45814. this.invMAngT1Z = 0;
  45815. this.invMAngT2X = 0;
  45816. this.invMAngT2Y = 0;
  45817. this.invMAngT2Z = 0;
  45818. this.invMLinB1X = 0;
  45819. this.invMLinB1Y = 0;
  45820. this.invMLinB1Z = 0;
  45821. this.invMLinB2X = 0;
  45822. this.invMLinB2Y = 0;
  45823. this.invMLinB2Z = 0;
  45824. this.invMAngB1X = 0;
  45825. this.invMAngB1Y = 0;
  45826. this.invMAngB1Z = 0;
  45827. this.invMAngB2X = 0;
  45828. this.invMAngB2Y = 0;
  45829. this.invMAngB2Z = 0;
  45830. this.massN = 0;
  45831. this.massTB00 = 0;
  45832. this.massTB01 = 0;
  45833. this.massTB10 = 0;
  45834. this.massTB11 = 0;
  45835. }
  45836. }
  45837. oimo.dynamics.constraint.solver.common.JointSolverMassDataRow = class oimo_dynamics_constraint_solver_common_JointSolverMassDataRow {
  45838. constructor() {
  45839. this.invMLin1X = 0;
  45840. this.invMLin1Y = 0;
  45841. this.invMLin1Z = 0;
  45842. this.invMLin2X = 0;
  45843. this.invMLin2Y = 0;
  45844. this.invMLin2Z = 0;
  45845. this.invMAng1X = 0;
  45846. this.invMAng1Y = 0;
  45847. this.invMAng1Z = 0;
  45848. this.invMAng2X = 0;
  45849. this.invMAng2Y = 0;
  45850. this.invMAng2Z = 0;
  45851. this.mass = 0;
  45852. this.massWithoutCfm = 0;
  45853. }
  45854. }
  45855. if(!oimo.dynamics.constraint.solver.direct) oimo.dynamics.constraint.solver.direct = {};
  45856. oimo.dynamics.constraint.solver.direct.Boundary = class oimo_dynamics_constraint_solver_direct_Boundary {
  45857. constructor(maxRows) {
  45858. var this1 = new Array(maxRows);
  45859. this.iBounded = this1;
  45860. var this2 = new Array(maxRows);
  45861. this.iUnbounded = this2;
  45862. var this3 = new Array(maxRows);
  45863. this.signs = this3;
  45864. var this4 = new Array(maxRows);
  45865. this.b = this4;
  45866. this.numBounded = 0;
  45867. this.numUnbounded = 0;
  45868. this.matrixId = 0;
  45869. }
  45870. init(buildInfo) {
  45871. this.numBounded = buildInfo.numBounded;
  45872. var _g = 0;
  45873. var _g1 = this.numBounded;
  45874. while(_g < _g1) {
  45875. var i = _g++;
  45876. this.iBounded[i] = buildInfo.iBounded[i];
  45877. this.signs[i] = buildInfo.signs[i];
  45878. }
  45879. this.numUnbounded = buildInfo.numUnbounded;
  45880. this.matrixId = 0;
  45881. var _g2 = 0;
  45882. var _g3 = this.numUnbounded;
  45883. while(_g2 < _g3) {
  45884. var i1 = _g2++;
  45885. var idx = buildInfo.iUnbounded[i1];
  45886. this.iUnbounded[i1] = idx;
  45887. this.matrixId |= 1 << idx;
  45888. }
  45889. }
  45890. computeImpulses(info,mass,relVels,impulses,dImpulses,impulseFactor,noCheck) {
  45891. var _g = 0;
  45892. var _g1 = this.numUnbounded;
  45893. while(_g < _g1) {
  45894. var i = _g++;
  45895. var idx = this.iUnbounded[i];
  45896. var row = info.rows[idx];
  45897. var relVel = relVels[idx];
  45898. this.b[idx] = row.rhs * impulseFactor - relVel - row.cfm * impulses[idx];
  45899. }
  45900. var invMassWithoutCfm = mass._invMassWithoutCfm;
  45901. var _g2 = 0;
  45902. var _g3 = this.numBounded;
  45903. while(_g2 < _g3) {
  45904. var i1 = _g2++;
  45905. var idx1 = this.iBounded[i1];
  45906. var sign = this.signs[i1];
  45907. var row1 = info.rows[idx1];
  45908. var oldImpulse = impulses[idx1];
  45909. var impulse = sign < 0 ? row1.minImpulse : sign > 0 ? row1.maxImpulse : 0;
  45910. var dImpulse = impulse - oldImpulse;
  45911. dImpulses[idx1] = dImpulse;
  45912. if(dImpulse != 0) {
  45913. var _g21 = 0;
  45914. var _g31 = this.numUnbounded;
  45915. while(_g21 < _g31) {
  45916. var j = _g21++;
  45917. var idx2 = this.iUnbounded[j];
  45918. var dRelVel = invMassWithoutCfm[idx1][idx2] * dImpulse;
  45919. var _g22 = idx2;
  45920. var _g32 = this.b;
  45921. _g32[_g22] = _g32[_g22] - dRelVel;
  45922. }
  45923. }
  45924. }
  45925. var indices = this.iUnbounded;
  45926. var n = this.numUnbounded;
  45927. var id = 0;
  45928. var _g4 = 0;
  45929. var _g11 = n;
  45930. while(_g4 < _g11) {
  45931. var i2 = _g4++;
  45932. id |= 1 << indices[i2];
  45933. }
  45934. var massMatrix;
  45935. if(mass._cacheComputed[id]) {
  45936. massMatrix = mass._cachedSubmatrices[id];
  45937. } else {
  45938. mass.computeSubmatrix(id,indices,n);
  45939. mass._cacheComputed[id] = true;
  45940. massMatrix = mass._cachedSubmatrices[id];
  45941. }
  45942. var ok = true;
  45943. var _g41 = 0;
  45944. var _g5 = this.numUnbounded;
  45945. while(_g41 < _g5) {
  45946. var i3 = _g41++;
  45947. var idx3 = this.iUnbounded[i3];
  45948. var row2 = info.rows[idx3];
  45949. var oldImpulse1 = impulses[idx3];
  45950. var impulse1 = oldImpulse1;
  45951. var _g42 = 0;
  45952. var _g51 = this.numUnbounded;
  45953. while(_g42 < _g51) {
  45954. var j1 = _g42++;
  45955. var idx21 = this.iUnbounded[j1];
  45956. impulse1 += this.b[idx21] * massMatrix[i3][j1];
  45957. }
  45958. if(impulse1 < row2.minImpulse - oimo.common.Setting.directMlcpSolverEps || impulse1 > row2.maxImpulse + oimo.common.Setting.directMlcpSolverEps) {
  45959. ok = false;
  45960. break;
  45961. }
  45962. dImpulses[idx3] = impulse1 - oldImpulse1;
  45963. }
  45964. if(noCheck) {
  45965. return true;
  45966. }
  45967. if(!ok) {
  45968. return false;
  45969. }
  45970. var _g6 = 0;
  45971. var _g7 = this.numBounded;
  45972. while(_g6 < _g7) {
  45973. var i4 = _g6++;
  45974. var idx4 = this.iBounded[i4];
  45975. var row3 = info.rows[idx4];
  45976. var sign1 = this.signs[i4];
  45977. var error = 0;
  45978. var newImpulse = impulses[idx4] + dImpulses[idx4];
  45979. var relVel1 = relVels[idx4];
  45980. var _g61 = 0;
  45981. var _g71 = info.numRows;
  45982. while(_g61 < _g71) {
  45983. var j2 = _g61++;
  45984. relVel1 += invMassWithoutCfm[idx4][j2] * dImpulses[j2];
  45985. }
  45986. error = row3.rhs * impulseFactor - relVel1 - row3.cfm * newImpulse;
  45987. if(sign1 < 0 && error > oimo.common.Setting.directMlcpSolverEps || sign1 > 0 && error < -oimo.common.Setting.directMlcpSolverEps) {
  45988. ok = false;
  45989. break;
  45990. }
  45991. }
  45992. return ok;
  45993. }
  45994. }
  45995. oimo.dynamics.constraint.solver.direct.BoundaryBuildInfo = class oimo_dynamics_constraint_solver_direct_BoundaryBuildInfo {
  45996. constructor(size) {
  45997. this.size = size;
  45998. this.numBounded = 0;
  45999. var this1 = new Array(size);
  46000. this.iBounded = this1;
  46001. var this2 = new Array(size);
  46002. this.signs = this2;
  46003. this.numUnbounded = 0;
  46004. var this3 = new Array(size);
  46005. this.iUnbounded = this3;
  46006. }
  46007. }
  46008. oimo.dynamics.constraint.solver.direct.BoundaryBuilder = class oimo_dynamics_constraint_solver_direct_BoundaryBuilder {
  46009. constructor(maxRows) {
  46010. this.maxRows = maxRows;
  46011. this.numBoundaries = 0;
  46012. var this1 = new Array(1 << maxRows);
  46013. this.boundaries = this1;
  46014. this.bbInfo = new oimo.dynamics.constraint.solver.direct.BoundaryBuildInfo(maxRows);
  46015. }
  46016. buildBoundariesRecursive(info,i) {
  46017. if(i == info.numRows) {
  46018. if(this.boundaries[this.numBoundaries] == null) {
  46019. this.boundaries[this.numBoundaries] = new oimo.dynamics.constraint.solver.direct.Boundary(this.maxRows);
  46020. }
  46021. this.boundaries[this.numBoundaries++].init(this.bbInfo);
  46022. return;
  46023. }
  46024. var row = info.rows[i];
  46025. var lowerLimitEnabled = row.minImpulse > -1e65536;
  46026. var upperLimitEnabled = row.maxImpulse < 1e65536;
  46027. var disabled = row.minImpulse == 0 && row.maxImpulse == 0;
  46028. if(disabled) {
  46029. var _this = this.bbInfo;
  46030. _this.iBounded[_this.numBounded] = i;
  46031. _this.signs[_this.numBounded] = 0;
  46032. _this.numBounded++;
  46033. this.buildBoundariesRecursive(info,i + 1);
  46034. this.bbInfo.numBounded--;
  46035. return;
  46036. }
  46037. var _this1 = this.bbInfo;
  46038. _this1.iUnbounded[_this1.numUnbounded] = i;
  46039. _this1.numUnbounded++;
  46040. this.buildBoundariesRecursive(info,i + 1);
  46041. this.bbInfo.numUnbounded--;
  46042. if(lowerLimitEnabled) {
  46043. var _this2 = this.bbInfo;
  46044. _this2.iBounded[_this2.numBounded] = i;
  46045. _this2.signs[_this2.numBounded] = -1;
  46046. _this2.numBounded++;
  46047. this.buildBoundariesRecursive(info,i + 1);
  46048. this.bbInfo.numBounded--;
  46049. }
  46050. if(upperLimitEnabled) {
  46051. var _this3 = this.bbInfo;
  46052. _this3.iBounded[_this3.numBounded] = i;
  46053. _this3.signs[_this3.numBounded] = 1;
  46054. _this3.numBounded++;
  46055. this.buildBoundariesRecursive(info,i + 1);
  46056. this.bbInfo.numBounded--;
  46057. }
  46058. }
  46059. buildBoundaries(info) {
  46060. this.numBoundaries = 0;
  46061. var _this = this.bbInfo;
  46062. _this.numBounded = 0;
  46063. _this.numUnbounded = 0;
  46064. this.buildBoundariesRecursive(info,0);
  46065. }
  46066. }
  46067. oimo.dynamics.constraint.solver.direct.BoundarySelector = class oimo_dynamics_constraint_solver_direct_BoundarySelector {
  46068. constructor(n) {
  46069. this.n = n;
  46070. var this1 = new Array(n);
  46071. this.indices = this1;
  46072. var this2 = new Array(n);
  46073. this.tmpIndices = this2;
  46074. var _g = 0;
  46075. var _g1 = n;
  46076. while(_g < _g1) {
  46077. var i = _g++;
  46078. this.indices[i] = i;
  46079. }
  46080. }
  46081. getIndex(i) {
  46082. return this.indices[i];
  46083. }
  46084. select(index) {
  46085. var i = 0;
  46086. while(this.indices[i] != index) ++i;
  46087. while(i > 0) {
  46088. var tmp = this.indices[i];
  46089. this.indices[i] = this.indices[i - 1];
  46090. this.indices[i - 1] = tmp;
  46091. --i;
  46092. }
  46093. }
  46094. setSize(size) {
  46095. var numSmaller = 0;
  46096. var numGreater = 0;
  46097. var _g = 0;
  46098. var _g1 = this.n;
  46099. while(_g < _g1) {
  46100. var i = _g++;
  46101. var idx = this.indices[i];
  46102. if(idx < size) {
  46103. this.tmpIndices[numSmaller] = idx;
  46104. ++numSmaller;
  46105. } else {
  46106. this.tmpIndices[size + numGreater] = idx;
  46107. ++numGreater;
  46108. }
  46109. }
  46110. var tmp = this.indices;
  46111. this.indices = this.tmpIndices;
  46112. this.tmpIndices = tmp;
  46113. }
  46114. }
  46115. oimo.dynamics.constraint.solver.direct.DirectJointConstraintSolver = class oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver extends oimo.dynamics.constraint.ConstraintSolver {
  46116. constructor(joint) {
  46117. super();
  46118. this.joint = joint;
  46119. this.info = new oimo.dynamics.constraint.info.joint.JointSolverInfo();
  46120. var maxRows = oimo.common.Setting.maxJacobianRows;
  46121. this.massMatrix = new oimo.dynamics.constraint.solver.direct.MassMatrix(maxRows);
  46122. this.boundaryBuilder = new oimo.dynamics.constraint.solver.direct.BoundaryBuilder(maxRows);
  46123. var this1 = new Array(maxRows);
  46124. this.massData = this1;
  46125. var _g = 0;
  46126. var _g1 = this.massData.length;
  46127. while(_g < _g1) {
  46128. var i = _g++;
  46129. this.massData[i] = new oimo.dynamics.constraint.solver.common.JointSolverMassDataRow();
  46130. }
  46131. var numMaxBoundaries = this.boundaryBuilder.boundaries.length;
  46132. this.velBoundarySelector = new oimo.dynamics.constraint.solver.direct.BoundarySelector(numMaxBoundaries);
  46133. this.posBoundarySelector = new oimo.dynamics.constraint.solver.direct.BoundarySelector(numMaxBoundaries);
  46134. var this2 = new Array(maxRows);
  46135. this.relVels = this2;
  46136. var this3 = new Array(maxRows);
  46137. this.impulses = this3;
  46138. var this4 = new Array(maxRows);
  46139. this.dImpulses = this4;
  46140. var this5 = new Array(maxRows);
  46141. this.dTotalImpulses = this5;
  46142. var _g2 = 0;
  46143. var _g3 = maxRows;
  46144. while(_g2 < _g3) {
  46145. var i1 = _g2++;
  46146. this.relVels[i1] = 0;
  46147. this.impulses[i1] = 0;
  46148. this.dImpulses[i1] = 0;
  46149. this.dTotalImpulses[i1] = 0;
  46150. }
  46151. }
  46152. preSolveVelocity(timeStep) {
  46153. this.joint._syncAnchors();
  46154. this.joint._getVelocitySolverInfo(timeStep,this.info);
  46155. this._b1 = this.info.b1;
  46156. this._b2 = this.info.b2;
  46157. this.massMatrix.computeInvMass(this.info,this.massData);
  46158. var _this = this.boundaryBuilder;
  46159. _this.numBoundaries = 0;
  46160. var _this1 = _this.bbInfo;
  46161. _this1.numBounded = 0;
  46162. _this1.numUnbounded = 0;
  46163. _this.buildBoundariesRecursive(this.info,0);
  46164. var _this2 = this.velBoundarySelector;
  46165. var size = this.boundaryBuilder.numBoundaries;
  46166. var numSmaller = 0;
  46167. var numGreater = 0;
  46168. var _g = 0;
  46169. var _g1 = _this2.n;
  46170. while(_g < _g1) {
  46171. var i = _g++;
  46172. var idx = _this2.indices[i];
  46173. if(idx < size) {
  46174. _this2.tmpIndices[numSmaller] = idx;
  46175. ++numSmaller;
  46176. } else {
  46177. _this2.tmpIndices[size + numGreater] = idx;
  46178. ++numGreater;
  46179. }
  46180. }
  46181. var tmp = _this2.indices;
  46182. _this2.indices = _this2.tmpIndices;
  46183. _this2.tmpIndices = tmp;
  46184. }
  46185. warmStart(timeStep) {
  46186. var factor = this.joint._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE ? oimo.common.Setting.jointWarmStartingFactorForBaungarte : oimo.common.Setting.jointWarmStartingFactor;
  46187. factor *= timeStep.dtRatio;
  46188. if(factor <= 0) {
  46189. var _g = 0;
  46190. var _g1 = this.info.numRows;
  46191. while(_g < _g1) {
  46192. var i = _g++;
  46193. var row = this.info.rows[i];
  46194. var _this = row.impulse;
  46195. _this.impulse = 0;
  46196. _this.impulseM = 0;
  46197. _this.impulseP = 0;
  46198. }
  46199. return;
  46200. }
  46201. var _g2 = 0;
  46202. var _g11 = this.info.numRows;
  46203. while(_g2 < _g11) {
  46204. var i1 = _g2++;
  46205. var row1 = this.info.rows[i1];
  46206. var imp = row1.impulse;
  46207. var impulse = imp.impulse * factor;
  46208. if(impulse < row1.minImpulse) {
  46209. impulse = row1.minImpulse;
  46210. } else if(impulse > row1.maxImpulse) {
  46211. impulse = row1.maxImpulse;
  46212. }
  46213. imp.impulse = impulse;
  46214. if(row1.motorMaxImpulse > 0) {
  46215. var impulseM = imp.impulseM * factor;
  46216. var max = row1.motorMaxImpulse;
  46217. if(impulseM < -max) {
  46218. impulseM = -max;
  46219. } else if(impulseM > max) {
  46220. impulseM = max;
  46221. }
  46222. imp.impulseM = impulseM;
  46223. } else {
  46224. imp.impulseM = 0;
  46225. }
  46226. this.dImpulses[i1] = imp.impulse + imp.impulseM;
  46227. }
  46228. var impulses = this.dImpulses;
  46229. var linearSet = false;
  46230. var angularSet = false;
  46231. var lv1;
  46232. var lv1X;
  46233. var lv1Y;
  46234. var lv1Z;
  46235. var lv2;
  46236. var lv2X;
  46237. var lv2Y;
  46238. var lv2Z;
  46239. var av1;
  46240. var av1X;
  46241. var av1Y;
  46242. var av1Z;
  46243. var av2;
  46244. var av2X;
  46245. var av2Y;
  46246. var av2Z;
  46247. lv1X = this._b1._velX;
  46248. lv1Y = this._b1._velY;
  46249. lv1Z = this._b1._velZ;
  46250. lv2X = this._b2._velX;
  46251. lv2Y = this._b2._velY;
  46252. lv2Z = this._b2._velZ;
  46253. av1X = this._b1._angVelX;
  46254. av1Y = this._b1._angVelY;
  46255. av1Z = this._b1._angVelZ;
  46256. av2X = this._b2._angVelX;
  46257. av2Y = this._b2._angVelY;
  46258. av2Z = this._b2._angVelZ;
  46259. var _g3 = 0;
  46260. var _g12 = this.info.numRows;
  46261. while(_g3 < _g12) {
  46262. var i2 = _g3++;
  46263. var row2 = this.info.rows[i2];
  46264. var j = row2.jacobian;
  46265. var md = this.massData[i2];
  46266. var imp1 = impulses[i2];
  46267. if((j.flag & 1) != 0) {
  46268. lv1X += md.invMLin1X * imp1;
  46269. lv1Y += md.invMLin1Y * imp1;
  46270. lv1Z += md.invMLin1Z * imp1;
  46271. lv2X += md.invMLin2X * -imp1;
  46272. lv2Y += md.invMLin2Y * -imp1;
  46273. lv2Z += md.invMLin2Z * -imp1;
  46274. linearSet = true;
  46275. }
  46276. if((j.flag & 2) != 0) {
  46277. av1X += md.invMAng1X * imp1;
  46278. av1Y += md.invMAng1Y * imp1;
  46279. av1Z += md.invMAng1Z * imp1;
  46280. av2X += md.invMAng2X * -imp1;
  46281. av2Y += md.invMAng2Y * -imp1;
  46282. av2Z += md.invMAng2Z * -imp1;
  46283. angularSet = true;
  46284. }
  46285. }
  46286. if(linearSet) {
  46287. this._b1._velX = lv1X;
  46288. this._b1._velY = lv1Y;
  46289. this._b1._velZ = lv1Z;
  46290. this._b2._velX = lv2X;
  46291. this._b2._velY = lv2Y;
  46292. this._b2._velZ = lv2Z;
  46293. }
  46294. if(angularSet) {
  46295. this._b1._angVelX = av1X;
  46296. this._b1._angVelY = av1Y;
  46297. this._b1._angVelZ = av1Z;
  46298. this._b2._angVelX = av2X;
  46299. this._b2._angVelY = av2Y;
  46300. this._b2._angVelZ = av2Z;
  46301. }
  46302. }
  46303. solveVelocity() {
  46304. var numRows = this.info.numRows;
  46305. var lv1;
  46306. var lv1X;
  46307. var lv1Y;
  46308. var lv1Z;
  46309. var lv2;
  46310. var lv2X;
  46311. var lv2Y;
  46312. var lv2Z;
  46313. var av1;
  46314. var av1X;
  46315. var av1Y;
  46316. var av1Z;
  46317. var av2;
  46318. var av2X;
  46319. var av2Y;
  46320. var av2Z;
  46321. lv1X = this._b1._velX;
  46322. lv1Y = this._b1._velY;
  46323. lv1Z = this._b1._velZ;
  46324. lv2X = this._b2._velX;
  46325. lv2Y = this._b2._velY;
  46326. lv2Z = this._b2._velZ;
  46327. av1X = this._b1._angVelX;
  46328. av1Y = this._b1._angVelY;
  46329. av1Z = this._b1._angVelZ;
  46330. av2X = this._b2._angVelX;
  46331. av2Y = this._b2._angVelY;
  46332. av2Z = this._b2._angVelZ;
  46333. var _g = 0;
  46334. var _g1 = numRows;
  46335. while(_g < _g1) {
  46336. var i = _g++;
  46337. var row = this.info.rows[i];
  46338. var imp = row.impulse;
  46339. var j = row.jacobian;
  46340. var relVel = 0;
  46341. relVel += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  46342. relVel -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  46343. relVel += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  46344. relVel -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  46345. this.relVels[i] = relVel;
  46346. this.impulses[i] = imp.impulse;
  46347. this.dTotalImpulses[i] = 0;
  46348. }
  46349. var invMass = this.massMatrix._invMassWithoutCfm;
  46350. var _g2 = 0;
  46351. var _g3 = numRows;
  46352. while(_g2 < _g3) {
  46353. var i1 = _g2++;
  46354. var row1 = this.info.rows[i1];
  46355. var imp1 = row1.impulse;
  46356. var md = this.massData[i1];
  46357. if(row1.motorMaxImpulse > 0) {
  46358. var oldImpulseM = imp1.impulseM;
  46359. var impulseM = oldImpulseM + md.massWithoutCfm * (-row1.motorSpeed - this.relVels[i1]);
  46360. var maxImpulseM = row1.motorMaxImpulse;
  46361. if(impulseM < -maxImpulseM) {
  46362. impulseM = -maxImpulseM;
  46363. } else if(impulseM > maxImpulseM) {
  46364. impulseM = maxImpulseM;
  46365. }
  46366. imp1.impulseM = impulseM;
  46367. var dImpulseM = impulseM - oldImpulseM;
  46368. this.dTotalImpulses[i1] = dImpulseM;
  46369. var _g21 = 0;
  46370. var _g31 = numRows;
  46371. while(_g21 < _g31) {
  46372. var j1 = _g21++;
  46373. var _g22 = j1;
  46374. var _g32 = this.relVels;
  46375. _g32[_g22] = _g32[_g22] + dImpulseM * invMass[i1][j1];
  46376. }
  46377. }
  46378. }
  46379. var solved = false;
  46380. var _g4 = 0;
  46381. var _g5 = this.boundaryBuilder.numBoundaries;
  46382. while(_g4 < _g5) {
  46383. var i2 = _g4++;
  46384. var idx = this.velBoundarySelector.indices[i2];
  46385. var b = this.boundaryBuilder.boundaries[idx];
  46386. if(b.computeImpulses(this.info,this.massMatrix,this.relVels,this.impulses,this.dImpulses,1,false)) {
  46387. var _g41 = 0;
  46388. var _g51 = numRows;
  46389. while(_g41 < _g51) {
  46390. var j2 = _g41++;
  46391. var row2 = this.info.rows[j2];
  46392. var imp2 = row2.impulse;
  46393. var dimp = this.dImpulses[j2];
  46394. imp2.impulse += dimp;
  46395. var _g42 = j2;
  46396. var _g52 = this.dTotalImpulses;
  46397. _g52[_g42] = _g52[_g42] + dimp;
  46398. }
  46399. var impulses = this.dTotalImpulses;
  46400. var linearSet = false;
  46401. var angularSet = false;
  46402. var lv11;
  46403. var lv1X1;
  46404. var lv1Y1;
  46405. var lv1Z1;
  46406. var lv21;
  46407. var lv2X1;
  46408. var lv2Y1;
  46409. var lv2Z1;
  46410. var av11;
  46411. var av1X1;
  46412. var av1Y1;
  46413. var av1Z1;
  46414. var av21;
  46415. var av2X1;
  46416. var av2Y1;
  46417. var av2Z1;
  46418. lv1X1 = this._b1._velX;
  46419. lv1Y1 = this._b1._velY;
  46420. lv1Z1 = this._b1._velZ;
  46421. lv2X1 = this._b2._velX;
  46422. lv2Y1 = this._b2._velY;
  46423. lv2Z1 = this._b2._velZ;
  46424. av1X1 = this._b1._angVelX;
  46425. av1Y1 = this._b1._angVelY;
  46426. av1Z1 = this._b1._angVelZ;
  46427. av2X1 = this._b2._angVelX;
  46428. av2Y1 = this._b2._angVelY;
  46429. av2Z1 = this._b2._angVelZ;
  46430. var _g6 = 0;
  46431. var _g11 = this.info.numRows;
  46432. while(_g6 < _g11) {
  46433. var i3 = _g6++;
  46434. var row3 = this.info.rows[i3];
  46435. var j3 = row3.jacobian;
  46436. var md1 = this.massData[i3];
  46437. var imp3 = impulses[i3];
  46438. if((j3.flag & 1) != 0) {
  46439. lv1X1 += md1.invMLin1X * imp3;
  46440. lv1Y1 += md1.invMLin1Y * imp3;
  46441. lv1Z1 += md1.invMLin1Z * imp3;
  46442. lv2X1 += md1.invMLin2X * -imp3;
  46443. lv2Y1 += md1.invMLin2Y * -imp3;
  46444. lv2Z1 += md1.invMLin2Z * -imp3;
  46445. linearSet = true;
  46446. }
  46447. if((j3.flag & 2) != 0) {
  46448. av1X1 += md1.invMAng1X * imp3;
  46449. av1Y1 += md1.invMAng1Y * imp3;
  46450. av1Z1 += md1.invMAng1Z * imp3;
  46451. av2X1 += md1.invMAng2X * -imp3;
  46452. av2Y1 += md1.invMAng2Y * -imp3;
  46453. av2Z1 += md1.invMAng2Z * -imp3;
  46454. angularSet = true;
  46455. }
  46456. }
  46457. if(linearSet) {
  46458. this._b1._velX = lv1X1;
  46459. this._b1._velY = lv1Y1;
  46460. this._b1._velZ = lv1Z1;
  46461. this._b2._velX = lv2X1;
  46462. this._b2._velY = lv2Y1;
  46463. this._b2._velZ = lv2Z1;
  46464. }
  46465. if(angularSet) {
  46466. this._b1._angVelX = av1X1;
  46467. this._b1._angVelY = av1Y1;
  46468. this._b1._angVelZ = av1Z1;
  46469. this._b2._angVelX = av2X1;
  46470. this._b2._angVelY = av2Y1;
  46471. this._b2._angVelZ = av2Z1;
  46472. }
  46473. var _this = this.velBoundarySelector;
  46474. var i4 = 0;
  46475. while(_this.indices[i4] != idx) ++i4;
  46476. while(i4 > 0) {
  46477. var tmp = _this.indices[i4];
  46478. _this.indices[i4] = _this.indices[i4 - 1];
  46479. _this.indices[i4 - 1] = tmp;
  46480. --i4;
  46481. }
  46482. solved = true;
  46483. break;
  46484. }
  46485. }
  46486. if(!solved) {
  46487. console.log("src/oimo/dynamics/constraint/solver/direct/DirectJointConstraintSolver.hx:335:","could not find solution. (velocity)");
  46488. return;
  46489. }
  46490. }
  46491. postSolveVelocity(timeStep) {
  46492. var lin;
  46493. var linX;
  46494. var linY;
  46495. var linZ;
  46496. var ang;
  46497. var angX;
  46498. var angY;
  46499. var angZ;
  46500. linX = 0;
  46501. linY = 0;
  46502. linZ = 0;
  46503. angX = 0;
  46504. angY = 0;
  46505. angZ = 0;
  46506. var _g = 0;
  46507. var _g1 = this.info.numRows;
  46508. while(_g < _g1) {
  46509. var i = _g++;
  46510. var row = this.info.rows[i];
  46511. var imp = row.impulse;
  46512. var j = row.jacobian;
  46513. if((j.flag & 1) != 0) {
  46514. linX += j.lin1X * imp.impulse;
  46515. linY += j.lin1Y * imp.impulse;
  46516. linZ += j.lin1Z * imp.impulse;
  46517. } else if((j.flag & 2) != 0) {
  46518. angX += j.ang1X * imp.impulse;
  46519. angY += j.ang1Y * imp.impulse;
  46520. angZ += j.ang1Z * imp.impulse;
  46521. }
  46522. }
  46523. this.joint._appliedForceX = linX * timeStep.invDt;
  46524. this.joint._appliedForceY = linY * timeStep.invDt;
  46525. this.joint._appliedForceZ = linZ * timeStep.invDt;
  46526. this.joint._appliedTorqueX = angX * timeStep.invDt;
  46527. this.joint._appliedTorqueY = angY * timeStep.invDt;
  46528. this.joint._appliedTorqueZ = angZ * timeStep.invDt;
  46529. }
  46530. preSolvePosition(timeStep) {
  46531. this.joint._syncAnchors();
  46532. this.joint._getPositionSolverInfo(this.info);
  46533. this._b1 = this.info.b1;
  46534. this._b2 = this.info.b2;
  46535. this.massMatrix.computeInvMass(this.info,this.massData);
  46536. var _this = this.boundaryBuilder;
  46537. _this.numBoundaries = 0;
  46538. var _this1 = _this.bbInfo;
  46539. _this1.numBounded = 0;
  46540. _this1.numUnbounded = 0;
  46541. _this.buildBoundariesRecursive(this.info,0);
  46542. var _this2 = this.posBoundarySelector;
  46543. var size = this.boundaryBuilder.numBoundaries;
  46544. var numSmaller = 0;
  46545. var numGreater = 0;
  46546. var _g = 0;
  46547. var _g1 = _this2.n;
  46548. while(_g < _g1) {
  46549. var i = _g++;
  46550. var idx = _this2.indices[i];
  46551. if(idx < size) {
  46552. _this2.tmpIndices[numSmaller] = idx;
  46553. ++numSmaller;
  46554. } else {
  46555. _this2.tmpIndices[size + numGreater] = idx;
  46556. ++numGreater;
  46557. }
  46558. }
  46559. var tmp = _this2.indices;
  46560. _this2.indices = _this2.tmpIndices;
  46561. _this2.tmpIndices = tmp;
  46562. var _g2 = 0;
  46563. var _g11 = this.info.numRows;
  46564. while(_g2 < _g11) {
  46565. var i1 = _g2++;
  46566. this.info.rows[i1].impulse.impulseP = 0;
  46567. }
  46568. }
  46569. solvePositionSplitImpulse() {
  46570. var numRows = this.info.numRows;
  46571. var lv1;
  46572. var lv1X;
  46573. var lv1Y;
  46574. var lv1Z;
  46575. var lv2;
  46576. var lv2X;
  46577. var lv2Y;
  46578. var lv2Z;
  46579. var av1;
  46580. var av1X;
  46581. var av1Y;
  46582. var av1Z;
  46583. var av2;
  46584. var av2X;
  46585. var av2Y;
  46586. var av2Z;
  46587. lv1X = this._b1._pseudoVelX;
  46588. lv1Y = this._b1._pseudoVelY;
  46589. lv1Z = this._b1._pseudoVelZ;
  46590. lv2X = this._b2._pseudoVelX;
  46591. lv2Y = this._b2._pseudoVelY;
  46592. lv2Z = this._b2._pseudoVelZ;
  46593. av1X = this._b1._angPseudoVelX;
  46594. av1Y = this._b1._angPseudoVelY;
  46595. av1Z = this._b1._angPseudoVelZ;
  46596. av2X = this._b2._angPseudoVelX;
  46597. av2Y = this._b2._angPseudoVelY;
  46598. av2Z = this._b2._angPseudoVelZ;
  46599. var _g = 0;
  46600. var _g1 = numRows;
  46601. while(_g < _g1) {
  46602. var i = _g++;
  46603. var row = this.info.rows[i];
  46604. var imp = row.impulse;
  46605. var j = row.jacobian;
  46606. var relVel = 0;
  46607. relVel += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  46608. relVel -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  46609. relVel += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  46610. relVel -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  46611. this.relVels[i] = relVel;
  46612. this.impulses[i] = imp.impulseP;
  46613. }
  46614. var solved = false;
  46615. var _g2 = 0;
  46616. var _g3 = this.boundaryBuilder.numBoundaries;
  46617. while(_g2 < _g3) {
  46618. var i1 = _g2++;
  46619. var idx = this.posBoundarySelector.indices[i1];
  46620. var b = this.boundaryBuilder.boundaries[idx];
  46621. if(b.computeImpulses(this.info,this.massMatrix,this.relVels,this.impulses,this.dImpulses,oimo.common.Setting.positionSplitImpulseBaumgarte,false)) {
  46622. var _g21 = 0;
  46623. var _g31 = numRows;
  46624. while(_g21 < _g31) {
  46625. var j1 = _g21++;
  46626. var row1 = this.info.rows[j1];
  46627. var imp1 = row1.impulse;
  46628. var dimp = this.dImpulses[j1];
  46629. imp1.impulseP += dimp;
  46630. }
  46631. var impulses = this.dImpulses;
  46632. var linearSet = false;
  46633. var angularSet = false;
  46634. var lv11;
  46635. var lv1X1;
  46636. var lv1Y1;
  46637. var lv1Z1;
  46638. var lv21;
  46639. var lv2X1;
  46640. var lv2Y1;
  46641. var lv2Z1;
  46642. var av11;
  46643. var av1X1;
  46644. var av1Y1;
  46645. var av1Z1;
  46646. var av21;
  46647. var av2X1;
  46648. var av2Y1;
  46649. var av2Z1;
  46650. lv1X1 = this._b1._pseudoVelX;
  46651. lv1Y1 = this._b1._pseudoVelY;
  46652. lv1Z1 = this._b1._pseudoVelZ;
  46653. lv2X1 = this._b2._pseudoVelX;
  46654. lv2Y1 = this._b2._pseudoVelY;
  46655. lv2Z1 = this._b2._pseudoVelZ;
  46656. av1X1 = this._b1._angPseudoVelX;
  46657. av1Y1 = this._b1._angPseudoVelY;
  46658. av1Z1 = this._b1._angPseudoVelZ;
  46659. av2X1 = this._b2._angPseudoVelX;
  46660. av2Y1 = this._b2._angPseudoVelY;
  46661. av2Z1 = this._b2._angPseudoVelZ;
  46662. var _g4 = 0;
  46663. var _g11 = this.info.numRows;
  46664. while(_g4 < _g11) {
  46665. var i2 = _g4++;
  46666. var row2 = this.info.rows[i2];
  46667. var j2 = row2.jacobian;
  46668. var md = this.massData[i2];
  46669. var imp2 = impulses[i2];
  46670. if((j2.flag & 1) != 0) {
  46671. lv1X1 += md.invMLin1X * imp2;
  46672. lv1Y1 += md.invMLin1Y * imp2;
  46673. lv1Z1 += md.invMLin1Z * imp2;
  46674. lv2X1 += md.invMLin2X * -imp2;
  46675. lv2Y1 += md.invMLin2Y * -imp2;
  46676. lv2Z1 += md.invMLin2Z * -imp2;
  46677. linearSet = true;
  46678. }
  46679. if((j2.flag & 2) != 0) {
  46680. av1X1 += md.invMAng1X * imp2;
  46681. av1Y1 += md.invMAng1Y * imp2;
  46682. av1Z1 += md.invMAng1Z * imp2;
  46683. av2X1 += md.invMAng2X * -imp2;
  46684. av2Y1 += md.invMAng2Y * -imp2;
  46685. av2Z1 += md.invMAng2Z * -imp2;
  46686. angularSet = true;
  46687. }
  46688. }
  46689. if(linearSet) {
  46690. this._b1._pseudoVelX = lv1X1;
  46691. this._b1._pseudoVelY = lv1Y1;
  46692. this._b1._pseudoVelZ = lv1Z1;
  46693. this._b2._pseudoVelX = lv2X1;
  46694. this._b2._pseudoVelY = lv2Y1;
  46695. this._b2._pseudoVelZ = lv2Z1;
  46696. }
  46697. if(angularSet) {
  46698. this._b1._angPseudoVelX = av1X1;
  46699. this._b1._angPseudoVelY = av1Y1;
  46700. this._b1._angPseudoVelZ = av1Z1;
  46701. this._b2._angPseudoVelX = av2X1;
  46702. this._b2._angPseudoVelY = av2Y1;
  46703. this._b2._angPseudoVelZ = av2Z1;
  46704. }
  46705. var _this = this.posBoundarySelector;
  46706. var i3 = 0;
  46707. while(_this.indices[i3] != idx) ++i3;
  46708. while(i3 > 0) {
  46709. var tmp = _this.indices[i3];
  46710. _this.indices[i3] = _this.indices[i3 - 1];
  46711. _this.indices[i3 - 1] = tmp;
  46712. --i3;
  46713. }
  46714. solved = true;
  46715. break;
  46716. }
  46717. }
  46718. if(!solved) {
  46719. console.log("src/oimo/dynamics/constraint/solver/direct/DirectJointConstraintSolver.hx:450:","could not find solution. (split impulse)");
  46720. return;
  46721. }
  46722. }
  46723. solvePositionNgs(timeStep) {
  46724. this.joint._syncAnchors();
  46725. this.joint._getPositionSolverInfo(this.info);
  46726. this._b1 = this.info.b1;
  46727. this._b2 = this.info.b2;
  46728. this.massMatrix.computeInvMass(this.info,this.massData);
  46729. var _this = this.boundaryBuilder;
  46730. _this.numBoundaries = 0;
  46731. var _this1 = _this.bbInfo;
  46732. _this1.numBounded = 0;
  46733. _this1.numUnbounded = 0;
  46734. _this.buildBoundariesRecursive(this.info,0);
  46735. var _this2 = this.posBoundarySelector;
  46736. var size = this.boundaryBuilder.numBoundaries;
  46737. var numSmaller = 0;
  46738. var numGreater = 0;
  46739. var _g = 0;
  46740. var _g1 = _this2.n;
  46741. while(_g < _g1) {
  46742. var i = _g++;
  46743. var idx = _this2.indices[i];
  46744. if(idx < size) {
  46745. _this2.tmpIndices[numSmaller] = idx;
  46746. ++numSmaller;
  46747. } else {
  46748. _this2.tmpIndices[size + numGreater] = idx;
  46749. ++numGreater;
  46750. }
  46751. }
  46752. var tmp = _this2.indices;
  46753. _this2.indices = _this2.tmpIndices;
  46754. _this2.tmpIndices = tmp;
  46755. var numRows = this.info.numRows;
  46756. var _g2 = 0;
  46757. var _g11 = numRows;
  46758. while(_g2 < _g11) {
  46759. var i1 = _g2++;
  46760. var row = this.info.rows[i1];
  46761. var imp = row.impulse;
  46762. var j = row.jacobian;
  46763. this.relVels[i1] = 0;
  46764. this.impulses[i1] = imp.impulseP;
  46765. }
  46766. var solved = false;
  46767. var _g21 = 0;
  46768. var _g3 = this.boundaryBuilder.numBoundaries;
  46769. while(_g21 < _g3) {
  46770. var i2 = _g21++;
  46771. var idx1 = this.posBoundarySelector.indices[i2];
  46772. var b = this.boundaryBuilder.boundaries[idx1];
  46773. if(b.computeImpulses(this.info,this.massMatrix,this.relVels,this.impulses,this.dImpulses,oimo.common.Setting.positionNgsBaumgarte,false)) {
  46774. var _g22 = 0;
  46775. var _g31 = numRows;
  46776. while(_g22 < _g31) {
  46777. var j1 = _g22++;
  46778. var row1 = this.info.rows[j1];
  46779. var imp1 = row1.impulse;
  46780. var dimp = this.dImpulses[j1];
  46781. imp1.impulseP += dimp;
  46782. }
  46783. var impulses = this.dImpulses;
  46784. var linearSet = false;
  46785. var angularSet = false;
  46786. var lv1;
  46787. var lv1X;
  46788. var lv1Y;
  46789. var lv1Z;
  46790. var lv2;
  46791. var lv2X;
  46792. var lv2Y;
  46793. var lv2Z;
  46794. var av1;
  46795. var av1X;
  46796. var av1Y;
  46797. var av1Z;
  46798. var av2;
  46799. var av2X;
  46800. var av2Y;
  46801. var av2Z;
  46802. lv1X = 0;
  46803. lv1Y = 0;
  46804. lv1Z = 0;
  46805. lv2X = 0;
  46806. lv2Y = 0;
  46807. lv2Z = 0;
  46808. av1X = 0;
  46809. av1Y = 0;
  46810. av1Z = 0;
  46811. av2X = 0;
  46812. av2Y = 0;
  46813. av2Z = 0;
  46814. var _g4 = 0;
  46815. var _g12 = this.info.numRows;
  46816. while(_g4 < _g12) {
  46817. var i3 = _g4++;
  46818. var row2 = this.info.rows[i3];
  46819. var j2 = row2.jacobian;
  46820. var md = this.massData[i3];
  46821. var imp2 = impulses[i3];
  46822. if((j2.flag & 1) != 0) {
  46823. lv1X += md.invMLin1X * imp2;
  46824. lv1Y += md.invMLin1Y * imp2;
  46825. lv1Z += md.invMLin1Z * imp2;
  46826. lv2X += md.invMLin2X * -imp2;
  46827. lv2Y += md.invMLin2Y * -imp2;
  46828. lv2Z += md.invMLin2Z * -imp2;
  46829. linearSet = true;
  46830. }
  46831. if((j2.flag & 2) != 0) {
  46832. av1X += md.invMAng1X * imp2;
  46833. av1Y += md.invMAng1Y * imp2;
  46834. av1Z += md.invMAng1Z * imp2;
  46835. av2X += md.invMAng2X * -imp2;
  46836. av2Y += md.invMAng2Y * -imp2;
  46837. av2Z += md.invMAng2Z * -imp2;
  46838. angularSet = true;
  46839. }
  46840. }
  46841. if(linearSet) {
  46842. var _this3 = this._b1;
  46843. _this3._transform._positionX += lv1X;
  46844. _this3._transform._positionY += lv1Y;
  46845. _this3._transform._positionZ += lv1Z;
  46846. var _this4 = this._b2;
  46847. _this4._transform._positionX += lv2X;
  46848. _this4._transform._positionY += lv2Y;
  46849. _this4._transform._positionZ += lv2Z;
  46850. }
  46851. if(angularSet) {
  46852. var _this5 = this._b1;
  46853. var theta = Math.sqrt(av1X * av1X + av1Y * av1Y + av1Z * av1Z);
  46854. var halfTheta = theta * 0.5;
  46855. var rotationToSinAxisFactor;
  46856. var cosHalfTheta;
  46857. if(halfTheta < 0.5) {
  46858. var ht2 = halfTheta * halfTheta;
  46859. rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.166666666666666657 + ht2 * ht2 * 0.00833333333333333322);
  46860. cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.0416666666666666644;
  46861. } else {
  46862. rotationToSinAxisFactor = Math.sin(halfTheta) / theta;
  46863. cosHalfTheta = Math.cos(halfTheta);
  46864. }
  46865. var sinAxis;
  46866. var sinAxisX;
  46867. var sinAxisY;
  46868. var sinAxisZ;
  46869. sinAxisX = av1X * rotationToSinAxisFactor;
  46870. sinAxisY = av1Y * rotationToSinAxisFactor;
  46871. sinAxisZ = av1Z * rotationToSinAxisFactor;
  46872. var dq;
  46873. var dqX;
  46874. var dqY;
  46875. var dqZ;
  46876. var dqW;
  46877. dqX = sinAxisX;
  46878. dqY = sinAxisY;
  46879. dqZ = sinAxisZ;
  46880. dqW = cosHalfTheta;
  46881. var q;
  46882. var qX;
  46883. var qY;
  46884. var qZ;
  46885. var qW;
  46886. var e00 = _this5._transform._rotation00;
  46887. var e11 = _this5._transform._rotation11;
  46888. var e22 = _this5._transform._rotation22;
  46889. var t = e00 + e11 + e22;
  46890. var s;
  46891. if(t > 0) {
  46892. s = Math.sqrt(t + 1);
  46893. qW = 0.5 * s;
  46894. s = 0.5 / s;
  46895. qX = (_this5._transform._rotation21 - _this5._transform._rotation12) * s;
  46896. qY = (_this5._transform._rotation02 - _this5._transform._rotation20) * s;
  46897. qZ = (_this5._transform._rotation10 - _this5._transform._rotation01) * s;
  46898. } else if(e00 > e11) {
  46899. if(e00 > e22) {
  46900. s = Math.sqrt(e00 - e11 - e22 + 1);
  46901. qX = 0.5 * s;
  46902. s = 0.5 / s;
  46903. qY = (_this5._transform._rotation01 + _this5._transform._rotation10) * s;
  46904. qZ = (_this5._transform._rotation02 + _this5._transform._rotation20) * s;
  46905. qW = (_this5._transform._rotation21 - _this5._transform._rotation12) * s;
  46906. } else {
  46907. s = Math.sqrt(e22 - e00 - e11 + 1);
  46908. qZ = 0.5 * s;
  46909. s = 0.5 / s;
  46910. qX = (_this5._transform._rotation02 + _this5._transform._rotation20) * s;
  46911. qY = (_this5._transform._rotation12 + _this5._transform._rotation21) * s;
  46912. qW = (_this5._transform._rotation10 - _this5._transform._rotation01) * s;
  46913. }
  46914. } else if(e11 > e22) {
  46915. s = Math.sqrt(e11 - e22 - e00 + 1);
  46916. qY = 0.5 * s;
  46917. s = 0.5 / s;
  46918. qX = (_this5._transform._rotation01 + _this5._transform._rotation10) * s;
  46919. qZ = (_this5._transform._rotation12 + _this5._transform._rotation21) * s;
  46920. qW = (_this5._transform._rotation02 - _this5._transform._rotation20) * s;
  46921. } else {
  46922. s = Math.sqrt(e22 - e00 - e11 + 1);
  46923. qZ = 0.5 * s;
  46924. s = 0.5 / s;
  46925. qX = (_this5._transform._rotation02 + _this5._transform._rotation20) * s;
  46926. qY = (_this5._transform._rotation12 + _this5._transform._rotation21) * s;
  46927. qW = (_this5._transform._rotation10 - _this5._transform._rotation01) * s;
  46928. }
  46929. qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY;
  46930. qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX;
  46931. qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW;
  46932. qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ;
  46933. var l = qX * qX + qY * qY + qZ * qZ + qW * qW;
  46934. if(l > 1e-32) {
  46935. l = 1 / Math.sqrt(l);
  46936. }
  46937. qX *= l;
  46938. qY *= l;
  46939. qZ *= l;
  46940. qW *= l;
  46941. var x = qX;
  46942. var y = qY;
  46943. var z = qZ;
  46944. var w = qW;
  46945. var x2 = 2 * x;
  46946. var y2 = 2 * y;
  46947. var z2 = 2 * z;
  46948. var xx = x * x2;
  46949. var yy = y * y2;
  46950. var zz = z * z2;
  46951. var xy = x * y2;
  46952. var yz = y * z2;
  46953. var xz = x * z2;
  46954. var wx = w * x2;
  46955. var wy = w * y2;
  46956. var wz = w * z2;
  46957. _this5._transform._rotation00 = 1 - yy - zz;
  46958. _this5._transform._rotation01 = xy - wz;
  46959. _this5._transform._rotation02 = xz + wy;
  46960. _this5._transform._rotation10 = xy + wz;
  46961. _this5._transform._rotation11 = 1 - xx - zz;
  46962. _this5._transform._rotation12 = yz - wx;
  46963. _this5._transform._rotation20 = xz - wy;
  46964. _this5._transform._rotation21 = yz + wx;
  46965. _this5._transform._rotation22 = 1 - xx - yy;
  46966. var __tmp__00;
  46967. var __tmp__01;
  46968. var __tmp__02;
  46969. var __tmp__10;
  46970. var __tmp__11;
  46971. var __tmp__12;
  46972. var __tmp__20;
  46973. var __tmp__21;
  46974. var __tmp__22;
  46975. __tmp__00 = _this5._transform._rotation00 * _this5._invLocalInertia00 + _this5._transform._rotation01 * _this5._invLocalInertia10 + _this5._transform._rotation02 * _this5._invLocalInertia20;
  46976. __tmp__01 = _this5._transform._rotation00 * _this5._invLocalInertia01 + _this5._transform._rotation01 * _this5._invLocalInertia11 + _this5._transform._rotation02 * _this5._invLocalInertia21;
  46977. __tmp__02 = _this5._transform._rotation00 * _this5._invLocalInertia02 + _this5._transform._rotation01 * _this5._invLocalInertia12 + _this5._transform._rotation02 * _this5._invLocalInertia22;
  46978. __tmp__10 = _this5._transform._rotation10 * _this5._invLocalInertia00 + _this5._transform._rotation11 * _this5._invLocalInertia10 + _this5._transform._rotation12 * _this5._invLocalInertia20;
  46979. __tmp__11 = _this5._transform._rotation10 * _this5._invLocalInertia01 + _this5._transform._rotation11 * _this5._invLocalInertia11 + _this5._transform._rotation12 * _this5._invLocalInertia21;
  46980. __tmp__12 = _this5._transform._rotation10 * _this5._invLocalInertia02 + _this5._transform._rotation11 * _this5._invLocalInertia12 + _this5._transform._rotation12 * _this5._invLocalInertia22;
  46981. __tmp__20 = _this5._transform._rotation20 * _this5._invLocalInertia00 + _this5._transform._rotation21 * _this5._invLocalInertia10 + _this5._transform._rotation22 * _this5._invLocalInertia20;
  46982. __tmp__21 = _this5._transform._rotation20 * _this5._invLocalInertia01 + _this5._transform._rotation21 * _this5._invLocalInertia11 + _this5._transform._rotation22 * _this5._invLocalInertia21;
  46983. __tmp__22 = _this5._transform._rotation20 * _this5._invLocalInertia02 + _this5._transform._rotation21 * _this5._invLocalInertia12 + _this5._transform._rotation22 * _this5._invLocalInertia22;
  46984. _this5._invInertia00 = __tmp__00;
  46985. _this5._invInertia01 = __tmp__01;
  46986. _this5._invInertia02 = __tmp__02;
  46987. _this5._invInertia10 = __tmp__10;
  46988. _this5._invInertia11 = __tmp__11;
  46989. _this5._invInertia12 = __tmp__12;
  46990. _this5._invInertia20 = __tmp__20;
  46991. _this5._invInertia21 = __tmp__21;
  46992. _this5._invInertia22 = __tmp__22;
  46993. var __tmp__001;
  46994. var __tmp__011;
  46995. var __tmp__021;
  46996. var __tmp__101;
  46997. var __tmp__111;
  46998. var __tmp__121;
  46999. var __tmp__201;
  47000. var __tmp__211;
  47001. var __tmp__221;
  47002. __tmp__001 = _this5._invInertia00 * _this5._transform._rotation00 + _this5._invInertia01 * _this5._transform._rotation01 + _this5._invInertia02 * _this5._transform._rotation02;
  47003. __tmp__011 = _this5._invInertia00 * _this5._transform._rotation10 + _this5._invInertia01 * _this5._transform._rotation11 + _this5._invInertia02 * _this5._transform._rotation12;
  47004. __tmp__021 = _this5._invInertia00 * _this5._transform._rotation20 + _this5._invInertia01 * _this5._transform._rotation21 + _this5._invInertia02 * _this5._transform._rotation22;
  47005. __tmp__101 = _this5._invInertia10 * _this5._transform._rotation00 + _this5._invInertia11 * _this5._transform._rotation01 + _this5._invInertia12 * _this5._transform._rotation02;
  47006. __tmp__111 = _this5._invInertia10 * _this5._transform._rotation10 + _this5._invInertia11 * _this5._transform._rotation11 + _this5._invInertia12 * _this5._transform._rotation12;
  47007. __tmp__121 = _this5._invInertia10 * _this5._transform._rotation20 + _this5._invInertia11 * _this5._transform._rotation21 + _this5._invInertia12 * _this5._transform._rotation22;
  47008. __tmp__201 = _this5._invInertia20 * _this5._transform._rotation00 + _this5._invInertia21 * _this5._transform._rotation01 + _this5._invInertia22 * _this5._transform._rotation02;
  47009. __tmp__211 = _this5._invInertia20 * _this5._transform._rotation10 + _this5._invInertia21 * _this5._transform._rotation11 + _this5._invInertia22 * _this5._transform._rotation12;
  47010. __tmp__221 = _this5._invInertia20 * _this5._transform._rotation20 + _this5._invInertia21 * _this5._transform._rotation21 + _this5._invInertia22 * _this5._transform._rotation22;
  47011. _this5._invInertia00 = __tmp__001;
  47012. _this5._invInertia01 = __tmp__011;
  47013. _this5._invInertia02 = __tmp__021;
  47014. _this5._invInertia10 = __tmp__101;
  47015. _this5._invInertia11 = __tmp__111;
  47016. _this5._invInertia12 = __tmp__121;
  47017. _this5._invInertia20 = __tmp__201;
  47018. _this5._invInertia21 = __tmp__211;
  47019. _this5._invInertia22 = __tmp__221;
  47020. _this5._invInertia00 *= _this5._rotFactor.x;
  47021. _this5._invInertia01 *= _this5._rotFactor.x;
  47022. _this5._invInertia02 *= _this5._rotFactor.x;
  47023. _this5._invInertia10 *= _this5._rotFactor.y;
  47024. _this5._invInertia11 *= _this5._rotFactor.y;
  47025. _this5._invInertia12 *= _this5._rotFactor.y;
  47026. _this5._invInertia20 *= _this5._rotFactor.z;
  47027. _this5._invInertia21 *= _this5._rotFactor.z;
  47028. _this5._invInertia22 *= _this5._rotFactor.z;
  47029. var _this6 = this._b2;
  47030. var theta1 = Math.sqrt(av2X * av2X + av2Y * av2Y + av2Z * av2Z);
  47031. var halfTheta1 = theta1 * 0.5;
  47032. var rotationToSinAxisFactor1;
  47033. var cosHalfTheta1;
  47034. if(halfTheta1 < 0.5) {
  47035. var ht21 = halfTheta1 * halfTheta1;
  47036. rotationToSinAxisFactor1 = 0.5 * (1 - ht21 * 0.166666666666666657 + ht21 * ht21 * 0.00833333333333333322);
  47037. cosHalfTheta1 = 1 - ht21 * 0.5 + ht21 * ht21 * 0.0416666666666666644;
  47038. } else {
  47039. rotationToSinAxisFactor1 = Math.sin(halfTheta1) / theta1;
  47040. cosHalfTheta1 = Math.cos(halfTheta1);
  47041. }
  47042. var sinAxis1;
  47043. var sinAxisX1;
  47044. var sinAxisY1;
  47045. var sinAxisZ1;
  47046. sinAxisX1 = av2X * rotationToSinAxisFactor1;
  47047. sinAxisY1 = av2Y * rotationToSinAxisFactor1;
  47048. sinAxisZ1 = av2Z * rotationToSinAxisFactor1;
  47049. var dq1;
  47050. var dqX1;
  47051. var dqY1;
  47052. var dqZ1;
  47053. var dqW1;
  47054. dqX1 = sinAxisX1;
  47055. dqY1 = sinAxisY1;
  47056. dqZ1 = sinAxisZ1;
  47057. dqW1 = cosHalfTheta1;
  47058. var q1;
  47059. var qX1;
  47060. var qY1;
  47061. var qZ1;
  47062. var qW1;
  47063. var e001 = _this6._transform._rotation00;
  47064. var e111 = _this6._transform._rotation11;
  47065. var e221 = _this6._transform._rotation22;
  47066. var t1 = e001 + e111 + e221;
  47067. var s1;
  47068. if(t1 > 0) {
  47069. s1 = Math.sqrt(t1 + 1);
  47070. qW1 = 0.5 * s1;
  47071. s1 = 0.5 / s1;
  47072. qX1 = (_this6._transform._rotation21 - _this6._transform._rotation12) * s1;
  47073. qY1 = (_this6._transform._rotation02 - _this6._transform._rotation20) * s1;
  47074. qZ1 = (_this6._transform._rotation10 - _this6._transform._rotation01) * s1;
  47075. } else if(e001 > e111) {
  47076. if(e001 > e221) {
  47077. s1 = Math.sqrt(e001 - e111 - e221 + 1);
  47078. qX1 = 0.5 * s1;
  47079. s1 = 0.5 / s1;
  47080. qY1 = (_this6._transform._rotation01 + _this6._transform._rotation10) * s1;
  47081. qZ1 = (_this6._transform._rotation02 + _this6._transform._rotation20) * s1;
  47082. qW1 = (_this6._transform._rotation21 - _this6._transform._rotation12) * s1;
  47083. } else {
  47084. s1 = Math.sqrt(e221 - e001 - e111 + 1);
  47085. qZ1 = 0.5 * s1;
  47086. s1 = 0.5 / s1;
  47087. qX1 = (_this6._transform._rotation02 + _this6._transform._rotation20) * s1;
  47088. qY1 = (_this6._transform._rotation12 + _this6._transform._rotation21) * s1;
  47089. qW1 = (_this6._transform._rotation10 - _this6._transform._rotation01) * s1;
  47090. }
  47091. } else if(e111 > e221) {
  47092. s1 = Math.sqrt(e111 - e221 - e001 + 1);
  47093. qY1 = 0.5 * s1;
  47094. s1 = 0.5 / s1;
  47095. qX1 = (_this6._transform._rotation01 + _this6._transform._rotation10) * s1;
  47096. qZ1 = (_this6._transform._rotation12 + _this6._transform._rotation21) * s1;
  47097. qW1 = (_this6._transform._rotation02 - _this6._transform._rotation20) * s1;
  47098. } else {
  47099. s1 = Math.sqrt(e221 - e001 - e111 + 1);
  47100. qZ1 = 0.5 * s1;
  47101. s1 = 0.5 / s1;
  47102. qX1 = (_this6._transform._rotation02 + _this6._transform._rotation20) * s1;
  47103. qY1 = (_this6._transform._rotation12 + _this6._transform._rotation21) * s1;
  47104. qW1 = (_this6._transform._rotation10 - _this6._transform._rotation01) * s1;
  47105. }
  47106. qX1 = dqW1 * qX1 + dqX1 * qW1 + dqY1 * qZ1 - dqZ1 * qY1;
  47107. qY1 = dqW1 * qY1 - dqX1 * qZ1 + dqY1 * qW1 + dqZ1 * qX1;
  47108. qZ1 = dqW1 * qZ1 + dqX1 * qY1 - dqY1 * qX1 + dqZ1 * qW1;
  47109. qW1 = dqW1 * qW1 - dqX1 * qX1 - dqY1 * qY1 - dqZ1 * qZ1;
  47110. var l1 = qX1 * qX1 + qY1 * qY1 + qZ1 * qZ1 + qW1 * qW1;
  47111. if(l1 > 1e-32) {
  47112. l1 = 1 / Math.sqrt(l1);
  47113. }
  47114. qX1 *= l1;
  47115. qY1 *= l1;
  47116. qZ1 *= l1;
  47117. qW1 *= l1;
  47118. var x1 = qX1;
  47119. var y1 = qY1;
  47120. var z1 = qZ1;
  47121. var w1 = qW1;
  47122. var x21 = 2 * x1;
  47123. var y21 = 2 * y1;
  47124. var z21 = 2 * z1;
  47125. var xx1 = x1 * x21;
  47126. var yy1 = y1 * y21;
  47127. var zz1 = z1 * z21;
  47128. var xy1 = x1 * y21;
  47129. var yz1 = y1 * z21;
  47130. var xz1 = x1 * z21;
  47131. var wx1 = w1 * x21;
  47132. var wy1 = w1 * y21;
  47133. var wz1 = w1 * z21;
  47134. _this6._transform._rotation00 = 1 - yy1 - zz1;
  47135. _this6._transform._rotation01 = xy1 - wz1;
  47136. _this6._transform._rotation02 = xz1 + wy1;
  47137. _this6._transform._rotation10 = xy1 + wz1;
  47138. _this6._transform._rotation11 = 1 - xx1 - zz1;
  47139. _this6._transform._rotation12 = yz1 - wx1;
  47140. _this6._transform._rotation20 = xz1 - wy1;
  47141. _this6._transform._rotation21 = yz1 + wx1;
  47142. _this6._transform._rotation22 = 1 - xx1 - yy1;
  47143. var __tmp__002;
  47144. var __tmp__012;
  47145. var __tmp__022;
  47146. var __tmp__102;
  47147. var __tmp__112;
  47148. var __tmp__122;
  47149. var __tmp__202;
  47150. var __tmp__212;
  47151. var __tmp__222;
  47152. __tmp__002 = _this6._transform._rotation00 * _this6._invLocalInertia00 + _this6._transform._rotation01 * _this6._invLocalInertia10 + _this6._transform._rotation02 * _this6._invLocalInertia20;
  47153. __tmp__012 = _this6._transform._rotation00 * _this6._invLocalInertia01 + _this6._transform._rotation01 * _this6._invLocalInertia11 + _this6._transform._rotation02 * _this6._invLocalInertia21;
  47154. __tmp__022 = _this6._transform._rotation00 * _this6._invLocalInertia02 + _this6._transform._rotation01 * _this6._invLocalInertia12 + _this6._transform._rotation02 * _this6._invLocalInertia22;
  47155. __tmp__102 = _this6._transform._rotation10 * _this6._invLocalInertia00 + _this6._transform._rotation11 * _this6._invLocalInertia10 + _this6._transform._rotation12 * _this6._invLocalInertia20;
  47156. __tmp__112 = _this6._transform._rotation10 * _this6._invLocalInertia01 + _this6._transform._rotation11 * _this6._invLocalInertia11 + _this6._transform._rotation12 * _this6._invLocalInertia21;
  47157. __tmp__122 = _this6._transform._rotation10 * _this6._invLocalInertia02 + _this6._transform._rotation11 * _this6._invLocalInertia12 + _this6._transform._rotation12 * _this6._invLocalInertia22;
  47158. __tmp__202 = _this6._transform._rotation20 * _this6._invLocalInertia00 + _this6._transform._rotation21 * _this6._invLocalInertia10 + _this6._transform._rotation22 * _this6._invLocalInertia20;
  47159. __tmp__212 = _this6._transform._rotation20 * _this6._invLocalInertia01 + _this6._transform._rotation21 * _this6._invLocalInertia11 + _this6._transform._rotation22 * _this6._invLocalInertia21;
  47160. __tmp__222 = _this6._transform._rotation20 * _this6._invLocalInertia02 + _this6._transform._rotation21 * _this6._invLocalInertia12 + _this6._transform._rotation22 * _this6._invLocalInertia22;
  47161. _this6._invInertia00 = __tmp__002;
  47162. _this6._invInertia01 = __tmp__012;
  47163. _this6._invInertia02 = __tmp__022;
  47164. _this6._invInertia10 = __tmp__102;
  47165. _this6._invInertia11 = __tmp__112;
  47166. _this6._invInertia12 = __tmp__122;
  47167. _this6._invInertia20 = __tmp__202;
  47168. _this6._invInertia21 = __tmp__212;
  47169. _this6._invInertia22 = __tmp__222;
  47170. var __tmp__003;
  47171. var __tmp__013;
  47172. var __tmp__023;
  47173. var __tmp__103;
  47174. var __tmp__113;
  47175. var __tmp__123;
  47176. var __tmp__203;
  47177. var __tmp__213;
  47178. var __tmp__223;
  47179. __tmp__003 = _this6._invInertia00 * _this6._transform._rotation00 + _this6._invInertia01 * _this6._transform._rotation01 + _this6._invInertia02 * _this6._transform._rotation02;
  47180. __tmp__013 = _this6._invInertia00 * _this6._transform._rotation10 + _this6._invInertia01 * _this6._transform._rotation11 + _this6._invInertia02 * _this6._transform._rotation12;
  47181. __tmp__023 = _this6._invInertia00 * _this6._transform._rotation20 + _this6._invInertia01 * _this6._transform._rotation21 + _this6._invInertia02 * _this6._transform._rotation22;
  47182. __tmp__103 = _this6._invInertia10 * _this6._transform._rotation00 + _this6._invInertia11 * _this6._transform._rotation01 + _this6._invInertia12 * _this6._transform._rotation02;
  47183. __tmp__113 = _this6._invInertia10 * _this6._transform._rotation10 + _this6._invInertia11 * _this6._transform._rotation11 + _this6._invInertia12 * _this6._transform._rotation12;
  47184. __tmp__123 = _this6._invInertia10 * _this6._transform._rotation20 + _this6._invInertia11 * _this6._transform._rotation21 + _this6._invInertia12 * _this6._transform._rotation22;
  47185. __tmp__203 = _this6._invInertia20 * _this6._transform._rotation00 + _this6._invInertia21 * _this6._transform._rotation01 + _this6._invInertia22 * _this6._transform._rotation02;
  47186. __tmp__213 = _this6._invInertia20 * _this6._transform._rotation10 + _this6._invInertia21 * _this6._transform._rotation11 + _this6._invInertia22 * _this6._transform._rotation12;
  47187. __tmp__223 = _this6._invInertia20 * _this6._transform._rotation20 + _this6._invInertia21 * _this6._transform._rotation21 + _this6._invInertia22 * _this6._transform._rotation22;
  47188. _this6._invInertia00 = __tmp__003;
  47189. _this6._invInertia01 = __tmp__013;
  47190. _this6._invInertia02 = __tmp__023;
  47191. _this6._invInertia10 = __tmp__103;
  47192. _this6._invInertia11 = __tmp__113;
  47193. _this6._invInertia12 = __tmp__123;
  47194. _this6._invInertia20 = __tmp__203;
  47195. _this6._invInertia21 = __tmp__213;
  47196. _this6._invInertia22 = __tmp__223;
  47197. _this6._invInertia00 *= _this6._rotFactor.x;
  47198. _this6._invInertia01 *= _this6._rotFactor.x;
  47199. _this6._invInertia02 *= _this6._rotFactor.x;
  47200. _this6._invInertia10 *= _this6._rotFactor.y;
  47201. _this6._invInertia11 *= _this6._rotFactor.y;
  47202. _this6._invInertia12 *= _this6._rotFactor.y;
  47203. _this6._invInertia20 *= _this6._rotFactor.z;
  47204. _this6._invInertia21 *= _this6._rotFactor.z;
  47205. _this6._invInertia22 *= _this6._rotFactor.z;
  47206. }
  47207. var _this7 = this.posBoundarySelector;
  47208. var i4 = 0;
  47209. while(_this7.indices[i4] != idx1) ++i4;
  47210. while(i4 > 0) {
  47211. var tmp1 = _this7.indices[i4];
  47212. _this7.indices[i4] = _this7.indices[i4 - 1];
  47213. _this7.indices[i4 - 1] = tmp1;
  47214. --i4;
  47215. }
  47216. solved = true;
  47217. break;
  47218. }
  47219. }
  47220. if(!solved) {
  47221. console.log("src/oimo/dynamics/constraint/solver/direct/DirectJointConstraintSolver.hx:502:","could not find solution. (NGS)");
  47222. return;
  47223. }
  47224. }
  47225. postSolve() {
  47226. this.joint._syncAnchors();
  47227. this.joint._checkDestruction();
  47228. }
  47229. }
  47230. oimo.dynamics.constraint.solver.direct.MassMatrix = class oimo_dynamics_constraint_solver_direct_MassMatrix {
  47231. constructor(size) {
  47232. this._size = size;
  47233. var this1 = new Array(this._size);
  47234. this.tmpMatrix = this1;
  47235. var this2 = new Array(this._size);
  47236. this._invMass = this2;
  47237. var this3 = new Array(this._size);
  47238. this._invMassWithoutCfm = this3;
  47239. var _g = 0;
  47240. var _g1 = this._size;
  47241. while(_g < _g1) {
  47242. var i = _g++;
  47243. var this4 = this.tmpMatrix;
  47244. var this5 = new Array(this._size);
  47245. this4[i] = this5;
  47246. var this6 = this._invMass;
  47247. var this7 = new Array(this._size);
  47248. this6[i] = this7;
  47249. var this8 = this._invMassWithoutCfm;
  47250. var this9 = new Array(this._size);
  47251. this8[i] = this9;
  47252. var _g2 = 0;
  47253. var _g11 = this._size;
  47254. while(_g2 < _g11) {
  47255. var j = _g2++;
  47256. this.tmpMatrix[i][j] = 0;
  47257. this._invMass[i][j] = 0;
  47258. this._invMassWithoutCfm[i][j] = 0;
  47259. }
  47260. }
  47261. this._maxSubmatrixId = 1 << this._size;
  47262. var this10 = new Array(this._maxSubmatrixId);
  47263. this._cacheComputed = this10;
  47264. var this11 = new Array(this._maxSubmatrixId);
  47265. this._cachedSubmatrices = this11;
  47266. var _g21 = 0;
  47267. var _g3 = this._maxSubmatrixId;
  47268. while(_g21 < _g3) {
  47269. var i1 = _g21++;
  47270. var t = i1;
  47271. t = (t & 85) + (t >> 1 & 85);
  47272. t = (t & 51) + (t >> 2 & 51);
  47273. t = (t & 15) + (t >> 4 & 15);
  47274. var matrixSize = t;
  47275. var this12 = new Array(matrixSize);
  47276. var subMatrix = this12;
  47277. var _g22 = 0;
  47278. var _g31 = matrixSize;
  47279. while(_g22 < _g31) {
  47280. var j1 = _g22++;
  47281. var this13 = new Array(matrixSize);
  47282. subMatrix[j1] = this13;
  47283. var _g23 = 0;
  47284. var _g32 = matrixSize;
  47285. while(_g23 < _g32) {
  47286. var k = _g23++;
  47287. subMatrix[j1][k] = 0;
  47288. }
  47289. }
  47290. this._cacheComputed[i1] = false;
  47291. this._cachedSubmatrices[i1] = subMatrix;
  47292. }
  47293. }
  47294. computeSubmatrix(id,indices,size) {
  47295. var _g = 0;
  47296. var _g1 = size;
  47297. while(_g < _g1) {
  47298. var i = _g++;
  47299. var ii = indices[i];
  47300. var _g2 = 0;
  47301. var _g11 = size;
  47302. while(_g2 < _g11) {
  47303. var j = _g2++;
  47304. this.tmpMatrix[i][j] = this._invMass[ii][indices[j]];
  47305. }
  47306. }
  47307. var src = this.tmpMatrix;
  47308. var dst = this._cachedSubmatrices[id];
  47309. var srci;
  47310. var dsti;
  47311. var srcj;
  47312. var dstj;
  47313. var diag;
  47314. switch(size) {
  47315. case 4:
  47316. srci = src[0];
  47317. dsti = dst[0];
  47318. diag = 1 / srci[0];
  47319. dsti[0] = diag;
  47320. srci[1] = srci[1] * diag;
  47321. srci[2] = srci[2] * diag;
  47322. srci[3] = srci[3] * diag;
  47323. srcj = src[1];
  47324. dstj = dst[1];
  47325. dstj[0] = -diag * srcj[0];
  47326. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47327. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47328. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47329. srcj = src[2];
  47330. dstj = dst[2];
  47331. dstj[0] = -diag * srcj[0];
  47332. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47333. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47334. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47335. srcj = src[3];
  47336. dstj = dst[3];
  47337. dstj[0] = -diag * srcj[0];
  47338. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47339. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47340. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47341. srci = src[1];
  47342. dsti = dst[1];
  47343. diag = 1 / srci[1];
  47344. dsti[1] = diag;
  47345. dsti[0] = dsti[0] * diag;
  47346. srci[2] = srci[2] * diag;
  47347. srci[3] = srci[3] * diag;
  47348. srcj = src[0];
  47349. dstj = dst[0];
  47350. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47351. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47352. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47353. srcj = src[2];
  47354. dstj = dst[2];
  47355. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47356. dstj[1] = -diag * srcj[1];
  47357. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47358. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47359. srcj = src[3];
  47360. dstj = dst[3];
  47361. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47362. dstj[1] = -diag * srcj[1];
  47363. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47364. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47365. srci = src[2];
  47366. dsti = dst[2];
  47367. diag = 1 / srci[2];
  47368. dsti[2] = diag;
  47369. dsti[0] = dsti[0] * diag;
  47370. dsti[1] = dsti[1] * diag;
  47371. srci[3] = srci[3] * diag;
  47372. srcj = src[0];
  47373. dstj = dst[0];
  47374. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47375. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47376. srcj = src[1];
  47377. dstj = dst[1];
  47378. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47379. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47380. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47381. srcj = src[3];
  47382. dstj = dst[3];
  47383. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47384. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47385. dstj[2] = -diag * srcj[2];
  47386. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47387. srci = src[3];
  47388. dsti = dst[3];
  47389. diag = 1 / srci[3];
  47390. dsti[3] = diag;
  47391. dsti[0] = dsti[0] * diag;
  47392. dsti[1] = dsti[1] * diag;
  47393. dsti[2] = dsti[2] * diag;
  47394. srcj = src[0];
  47395. dstj = dst[0];
  47396. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47397. srcj = src[1];
  47398. dstj = dst[1];
  47399. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47400. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47401. srcj = src[2];
  47402. dstj = dst[2];
  47403. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47404. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47405. dstj[2] = dstj[2] - dsti[2] * srcj[3];
  47406. dsti = dst[1];
  47407. dst[0][1] = dsti[0];
  47408. dsti = dst[2];
  47409. dst[0][2] = dsti[0];
  47410. dst[1][2] = dsti[1];
  47411. dsti = dst[3];
  47412. dst[0][3] = dsti[0];
  47413. dst[1][3] = dsti[1];
  47414. dst[2][3] = dsti[2];
  47415. break;
  47416. case 5:
  47417. srci = src[0];
  47418. dsti = dst[0];
  47419. diag = 1 / srci[0];
  47420. dsti[0] = diag;
  47421. srci[1] = srci[1] * diag;
  47422. srci[2] = srci[2] * diag;
  47423. srci[3] = srci[3] * diag;
  47424. srci[4] = srci[4] * diag;
  47425. srcj = src[1];
  47426. dstj = dst[1];
  47427. dstj[0] = -diag * srcj[0];
  47428. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47429. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47430. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47431. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47432. srcj = src[2];
  47433. dstj = dst[2];
  47434. dstj[0] = -diag * srcj[0];
  47435. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47436. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47437. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47438. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47439. srcj = src[3];
  47440. dstj = dst[3];
  47441. dstj[0] = -diag * srcj[0];
  47442. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47443. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47444. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47445. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47446. srcj = src[4];
  47447. dstj = dst[4];
  47448. dstj[0] = -diag * srcj[0];
  47449. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47450. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47451. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47452. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47453. srci = src[1];
  47454. dsti = dst[1];
  47455. diag = 1 / srci[1];
  47456. dsti[1] = diag;
  47457. dsti[0] = dsti[0] * diag;
  47458. srci[2] = srci[2] * diag;
  47459. srci[3] = srci[3] * diag;
  47460. srci[4] = srci[4] * diag;
  47461. srcj = src[0];
  47462. dstj = dst[0];
  47463. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47464. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47465. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47466. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47467. srcj = src[2];
  47468. dstj = dst[2];
  47469. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47470. dstj[1] = -diag * srcj[1];
  47471. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47472. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47473. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47474. srcj = src[3];
  47475. dstj = dst[3];
  47476. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47477. dstj[1] = -diag * srcj[1];
  47478. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47479. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47480. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47481. srcj = src[4];
  47482. dstj = dst[4];
  47483. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47484. dstj[1] = -diag * srcj[1];
  47485. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47486. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47487. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47488. srci = src[2];
  47489. dsti = dst[2];
  47490. diag = 1 / srci[2];
  47491. dsti[2] = diag;
  47492. dsti[0] = dsti[0] * diag;
  47493. dsti[1] = dsti[1] * diag;
  47494. srci[3] = srci[3] * diag;
  47495. srci[4] = srci[4] * diag;
  47496. srcj = src[0];
  47497. dstj = dst[0];
  47498. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47499. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47500. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47501. srcj = src[1];
  47502. dstj = dst[1];
  47503. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47504. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47505. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47506. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47507. srcj = src[3];
  47508. dstj = dst[3];
  47509. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47510. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47511. dstj[2] = -diag * srcj[2];
  47512. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47513. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47514. srcj = src[4];
  47515. dstj = dst[4];
  47516. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47517. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47518. dstj[2] = -diag * srcj[2];
  47519. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47520. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47521. srci = src[3];
  47522. dsti = dst[3];
  47523. diag = 1 / srci[3];
  47524. dsti[3] = diag;
  47525. dsti[0] = dsti[0] * diag;
  47526. dsti[1] = dsti[1] * diag;
  47527. dsti[2] = dsti[2] * diag;
  47528. srci[4] = srci[4] * diag;
  47529. srcj = src[0];
  47530. dstj = dst[0];
  47531. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47532. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47533. srcj = src[1];
  47534. dstj = dst[1];
  47535. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47536. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47537. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47538. srcj = src[2];
  47539. dstj = dst[2];
  47540. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47541. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47542. dstj[2] = dstj[2] - dsti[2] * srcj[3];
  47543. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47544. srcj = src[4];
  47545. dstj = dst[4];
  47546. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47547. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47548. dstj[2] = dstj[2] - dsti[2] * srcj[3];
  47549. dstj[3] = -diag * srcj[3];
  47550. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47551. srci = src[4];
  47552. dsti = dst[4];
  47553. diag = 1 / srci[4];
  47554. dsti[4] = diag;
  47555. dsti[0] = dsti[0] * diag;
  47556. dsti[1] = dsti[1] * diag;
  47557. dsti[2] = dsti[2] * diag;
  47558. dsti[3] = dsti[3] * diag;
  47559. srcj = src[0];
  47560. dstj = dst[0];
  47561. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47562. srcj = src[1];
  47563. dstj = dst[1];
  47564. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47565. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47566. srcj = src[2];
  47567. dstj = dst[2];
  47568. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47569. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47570. dstj[2] = dstj[2] - dsti[2] * srcj[4];
  47571. srcj = src[3];
  47572. dstj = dst[3];
  47573. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47574. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47575. dstj[2] = dstj[2] - dsti[2] * srcj[4];
  47576. dstj[3] = dstj[3] - dsti[3] * srcj[4];
  47577. dsti = dst[1];
  47578. dst[0][1] = dsti[0];
  47579. dsti = dst[2];
  47580. dst[0][2] = dsti[0];
  47581. dst[1][2] = dsti[1];
  47582. dsti = dst[3];
  47583. dst[0][3] = dsti[0];
  47584. dst[1][3] = dsti[1];
  47585. dst[2][3] = dsti[2];
  47586. dsti = dst[4];
  47587. dst[0][4] = dsti[0];
  47588. dst[1][4] = dsti[1];
  47589. dst[2][4] = dsti[2];
  47590. dst[3][4] = dsti[3];
  47591. break;
  47592. case 6:
  47593. srci = src[0];
  47594. dsti = dst[0];
  47595. diag = 1 / srci[0];
  47596. dsti[0] = diag;
  47597. srci[1] = srci[1] * diag;
  47598. srci[2] = srci[2] * diag;
  47599. srci[3] = srci[3] * diag;
  47600. srci[4] = srci[4] * diag;
  47601. srci[5] = srci[5] * diag;
  47602. srcj = src[1];
  47603. dstj = dst[1];
  47604. dstj[0] = -diag * srcj[0];
  47605. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47606. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47607. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47608. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47609. srcj[5] = srcj[5] - srci[5] * srcj[0];
  47610. srcj = src[2];
  47611. dstj = dst[2];
  47612. dstj[0] = -diag * srcj[0];
  47613. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47614. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47615. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47616. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47617. srcj[5] = srcj[5] - srci[5] * srcj[0];
  47618. srcj = src[3];
  47619. dstj = dst[3];
  47620. dstj[0] = -diag * srcj[0];
  47621. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47622. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47623. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47624. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47625. srcj[5] = srcj[5] - srci[5] * srcj[0];
  47626. srcj = src[4];
  47627. dstj = dst[4];
  47628. dstj[0] = -diag * srcj[0];
  47629. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47630. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47631. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47632. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47633. srcj[5] = srcj[5] - srci[5] * srcj[0];
  47634. srcj = src[5];
  47635. dstj = dst[5];
  47636. dstj[0] = -diag * srcj[0];
  47637. srcj[1] = srcj[1] - srci[1] * srcj[0];
  47638. srcj[2] = srcj[2] - srci[2] * srcj[0];
  47639. srcj[3] = srcj[3] - srci[3] * srcj[0];
  47640. srcj[4] = srcj[4] - srci[4] * srcj[0];
  47641. srcj[5] = srcj[5] - srci[5] * srcj[0];
  47642. srci = src[1];
  47643. dsti = dst[1];
  47644. diag = 1 / srci[1];
  47645. dsti[1] = diag;
  47646. dsti[0] = dsti[0] * diag;
  47647. srci[2] = srci[2] * diag;
  47648. srci[3] = srci[3] * diag;
  47649. srci[4] = srci[4] * diag;
  47650. srci[5] = srci[5] * diag;
  47651. srcj = src[0];
  47652. dstj = dst[0];
  47653. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47654. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47655. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47656. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47657. srcj[5] = srcj[5] - srci[5] * srcj[1];
  47658. srcj = src[2];
  47659. dstj = dst[2];
  47660. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47661. dstj[1] = -diag * srcj[1];
  47662. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47663. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47664. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47665. srcj[5] = srcj[5] - srci[5] * srcj[1];
  47666. srcj = src[3];
  47667. dstj = dst[3];
  47668. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47669. dstj[1] = -diag * srcj[1];
  47670. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47671. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47672. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47673. srcj[5] = srcj[5] - srci[5] * srcj[1];
  47674. srcj = src[4];
  47675. dstj = dst[4];
  47676. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47677. dstj[1] = -diag * srcj[1];
  47678. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47679. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47680. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47681. srcj[5] = srcj[5] - srci[5] * srcj[1];
  47682. srcj = src[5];
  47683. dstj = dst[5];
  47684. dstj[0] = dstj[0] - dsti[0] * srcj[1];
  47685. dstj[1] = -diag * srcj[1];
  47686. srcj[2] = srcj[2] - srci[2] * srcj[1];
  47687. srcj[3] = srcj[3] - srci[3] * srcj[1];
  47688. srcj[4] = srcj[4] - srci[4] * srcj[1];
  47689. srcj[5] = srcj[5] - srci[5] * srcj[1];
  47690. srci = src[2];
  47691. dsti = dst[2];
  47692. diag = 1 / srci[2];
  47693. dsti[2] = diag;
  47694. dsti[0] = dsti[0] * diag;
  47695. dsti[1] = dsti[1] * diag;
  47696. srci[3] = srci[3] * diag;
  47697. srci[4] = srci[4] * diag;
  47698. srci[5] = srci[5] * diag;
  47699. srcj = src[0];
  47700. dstj = dst[0];
  47701. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47702. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47703. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47704. srcj[5] = srcj[5] - srci[5] * srcj[2];
  47705. srcj = src[1];
  47706. dstj = dst[1];
  47707. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47708. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47709. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47710. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47711. srcj[5] = srcj[5] - srci[5] * srcj[2];
  47712. srcj = src[3];
  47713. dstj = dst[3];
  47714. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47715. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47716. dstj[2] = -diag * srcj[2];
  47717. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47718. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47719. srcj[5] = srcj[5] - srci[5] * srcj[2];
  47720. srcj = src[4];
  47721. dstj = dst[4];
  47722. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47723. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47724. dstj[2] = -diag * srcj[2];
  47725. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47726. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47727. srcj[5] = srcj[5] - srci[5] * srcj[2];
  47728. srcj = src[5];
  47729. dstj = dst[5];
  47730. dstj[0] = dstj[0] - dsti[0] * srcj[2];
  47731. dstj[1] = dstj[1] - dsti[1] * srcj[2];
  47732. dstj[2] = -diag * srcj[2];
  47733. srcj[3] = srcj[3] - srci[3] * srcj[2];
  47734. srcj[4] = srcj[4] - srci[4] * srcj[2];
  47735. srcj[5] = srcj[5] - srci[5] * srcj[2];
  47736. srci = src[3];
  47737. dsti = dst[3];
  47738. diag = 1 / srci[3];
  47739. dsti[3] = diag;
  47740. dsti[0] = dsti[0] * diag;
  47741. dsti[1] = dsti[1] * diag;
  47742. dsti[2] = dsti[2] * diag;
  47743. srci[4] = srci[4] * diag;
  47744. srci[5] = srci[5] * diag;
  47745. srcj = src[0];
  47746. dstj = dst[0];
  47747. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47748. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47749. srcj[5] = srcj[5] - srci[5] * srcj[3];
  47750. srcj = src[1];
  47751. dstj = dst[1];
  47752. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47753. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47754. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47755. srcj[5] = srcj[5] - srci[5] * srcj[3];
  47756. srcj = src[2];
  47757. dstj = dst[2];
  47758. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47759. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47760. dstj[2] = dstj[2] - dsti[2] * srcj[3];
  47761. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47762. srcj[5] = srcj[5] - srci[5] * srcj[3];
  47763. srcj = src[4];
  47764. dstj = dst[4];
  47765. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47766. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47767. dstj[2] = dstj[2] - dsti[2] * srcj[3];
  47768. dstj[3] = -diag * srcj[3];
  47769. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47770. srcj[5] = srcj[5] - srci[5] * srcj[3];
  47771. srcj = src[5];
  47772. dstj = dst[5];
  47773. dstj[0] = dstj[0] - dsti[0] * srcj[3];
  47774. dstj[1] = dstj[1] - dsti[1] * srcj[3];
  47775. dstj[2] = dstj[2] - dsti[2] * srcj[3];
  47776. dstj[3] = -diag * srcj[3];
  47777. srcj[4] = srcj[4] - srci[4] * srcj[3];
  47778. srcj[5] = srcj[5] - srci[5] * srcj[3];
  47779. srci = src[4];
  47780. dsti = dst[4];
  47781. diag = 1 / srci[4];
  47782. dsti[4] = diag;
  47783. dsti[0] = dsti[0] * diag;
  47784. dsti[1] = dsti[1] * diag;
  47785. dsti[2] = dsti[2] * diag;
  47786. dsti[3] = dsti[3] * diag;
  47787. srci[5] = srci[5] * diag;
  47788. srcj = src[0];
  47789. dstj = dst[0];
  47790. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47791. srcj[5] = srcj[5] - srci[5] * srcj[4];
  47792. srcj = src[1];
  47793. dstj = dst[1];
  47794. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47795. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47796. srcj[5] = srcj[5] - srci[5] * srcj[4];
  47797. srcj = src[2];
  47798. dstj = dst[2];
  47799. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47800. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47801. dstj[2] = dstj[2] - dsti[2] * srcj[4];
  47802. srcj[5] = srcj[5] - srci[5] * srcj[4];
  47803. srcj = src[3];
  47804. dstj = dst[3];
  47805. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47806. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47807. dstj[2] = dstj[2] - dsti[2] * srcj[4];
  47808. dstj[3] = dstj[3] - dsti[3] * srcj[4];
  47809. srcj[5] = srcj[5] - srci[5] * srcj[4];
  47810. srcj = src[5];
  47811. dstj = dst[5];
  47812. dstj[0] = dstj[0] - dsti[0] * srcj[4];
  47813. dstj[1] = dstj[1] - dsti[1] * srcj[4];
  47814. dstj[2] = dstj[2] - dsti[2] * srcj[4];
  47815. dstj[3] = dstj[3] - dsti[3] * srcj[4];
  47816. dstj[4] = -diag * srcj[4];
  47817. srcj[5] = srcj[5] - srci[5] * srcj[4];
  47818. srci = src[5];
  47819. dsti = dst[5];
  47820. diag = 1 / srci[5];
  47821. dsti[5] = diag;
  47822. dsti[0] = dsti[0] * diag;
  47823. dsti[1] = dsti[1] * diag;
  47824. dsti[2] = dsti[2] * diag;
  47825. dsti[3] = dsti[3] * diag;
  47826. dsti[4] = dsti[4] * diag;
  47827. srcj = src[0];
  47828. dstj = dst[0];
  47829. dstj[0] = dstj[0] - dsti[0] * srcj[5];
  47830. srcj = src[1];
  47831. dstj = dst[1];
  47832. dstj[0] = dstj[0] - dsti[0] * srcj[5];
  47833. dstj[1] = dstj[1] - dsti[1] * srcj[5];
  47834. srcj = src[2];
  47835. dstj = dst[2];
  47836. dstj[0] = dstj[0] - dsti[0] * srcj[5];
  47837. dstj[1] = dstj[1] - dsti[1] * srcj[5];
  47838. dstj[2] = dstj[2] - dsti[2] * srcj[5];
  47839. srcj = src[3];
  47840. dstj = dst[3];
  47841. dstj[0] = dstj[0] - dsti[0] * srcj[5];
  47842. dstj[1] = dstj[1] - dsti[1] * srcj[5];
  47843. dstj[2] = dstj[2] - dsti[2] * srcj[5];
  47844. dstj[3] = dstj[3] - dsti[3] * srcj[5];
  47845. srcj = src[4];
  47846. dstj = dst[4];
  47847. dstj[0] = dstj[0] - dsti[0] * srcj[5];
  47848. dstj[1] = dstj[1] - dsti[1] * srcj[5];
  47849. dstj[2] = dstj[2] - dsti[2] * srcj[5];
  47850. dstj[3] = dstj[3] - dsti[3] * srcj[5];
  47851. dstj[4] = dstj[4] - dsti[4] * srcj[5];
  47852. dsti = dst[1];
  47853. dst[0][1] = dsti[0];
  47854. dsti = dst[2];
  47855. dst[0][2] = dsti[0];
  47856. dst[1][2] = dsti[1];
  47857. dsti = dst[3];
  47858. dst[0][3] = dsti[0];
  47859. dst[1][3] = dsti[1];
  47860. dst[2][3] = dsti[2];
  47861. dsti = dst[4];
  47862. dst[0][4] = dsti[0];
  47863. dst[1][4] = dsti[1];
  47864. dst[2][4] = dsti[2];
  47865. dst[3][4] = dsti[3];
  47866. dsti = dst[5];
  47867. dst[0][5] = dsti[0];
  47868. dst[1][5] = dsti[1];
  47869. dst[2][5] = dsti[2];
  47870. dst[3][5] = dsti[3];
  47871. dst[4][5] = dsti[4];
  47872. break;
  47873. default:
  47874. var _g21 = 0;
  47875. var _g3 = size;
  47876. while(_g21 < _g3) {
  47877. var i1 = _g21++;
  47878. srci = src[i1];
  47879. dsti = dst[i1];
  47880. var diag1 = 1 / srci[i1];
  47881. dsti[i1] = diag1;
  47882. var _g22 = 0;
  47883. var _g31 = i1;
  47884. while(_g22 < _g31) {
  47885. var j1 = _g22++;
  47886. dsti[j1] = dsti[j1] * diag1;
  47887. }
  47888. var _g4 = i1 + 1;
  47889. var _g5 = size;
  47890. while(_g4 < _g5) {
  47891. var j2 = _g4++;
  47892. srci[j2] = srci[j2] * diag1;
  47893. }
  47894. var _g6 = 0;
  47895. var _g7 = i1;
  47896. while(_g6 < _g7) {
  47897. var j3 = _g6++;
  47898. srcj = src[j3];
  47899. dstj = dst[j3];
  47900. var _g61 = 0;
  47901. var _g71 = j3 + 1;
  47902. while(_g61 < _g71) {
  47903. var k = _g61++;
  47904. dstj[k] = dstj[k] - dsti[k] * srcj[i1];
  47905. }
  47906. var _g8 = i1 + 1;
  47907. var _g9 = size;
  47908. while(_g8 < _g9) {
  47909. var k1 = _g8++;
  47910. srcj[k1] = srcj[k1] - srci[k1] * srcj[i1];
  47911. }
  47912. }
  47913. var _g81 = i1 + 1;
  47914. var _g91 = size;
  47915. while(_g81 < _g91) {
  47916. var j4 = _g81++;
  47917. srcj = src[j4];
  47918. dstj = dst[j4];
  47919. var _g82 = 0;
  47920. var _g92 = i1;
  47921. while(_g82 < _g92) {
  47922. var k2 = _g82++;
  47923. dstj[k2] = dstj[k2] - dsti[k2] * srcj[i1];
  47924. }
  47925. dstj[i1] = -diag1 * srcj[i1];
  47926. var _g10 = i1 + 1;
  47927. var _g111 = size;
  47928. while(_g10 < _g111) {
  47929. var k3 = _g10++;
  47930. srcj[k3] = srcj[k3] - srci[k3] * srcj[i1];
  47931. }
  47932. }
  47933. }
  47934. var _g41 = 1;
  47935. var _g51 = size;
  47936. while(_g41 < _g51) {
  47937. var i2 = _g41++;
  47938. dsti = dst[i2];
  47939. var _g42 = 0;
  47940. var _g52 = i2;
  47941. while(_g42 < _g52) {
  47942. var j5 = _g42++;
  47943. dst[j5][i2] = dsti[j5];
  47944. }
  47945. }
  47946. }
  47947. }
  47948. computeInvMass(info,massData) {
  47949. var invMass = this._invMass;
  47950. var invMassWithoutCfm = this._invMassWithoutCfm;
  47951. var numRows = info.numRows;
  47952. var b1 = info.b1;
  47953. var b2 = info.b2;
  47954. var invM1 = b1._invMass;
  47955. var invM2 = b2._invMass;
  47956. var invI1;
  47957. var invI100;
  47958. var invI101;
  47959. var invI102;
  47960. var invI110;
  47961. var invI111;
  47962. var invI112;
  47963. var invI120;
  47964. var invI121;
  47965. var invI122;
  47966. var invI2;
  47967. var invI200;
  47968. var invI201;
  47969. var invI202;
  47970. var invI210;
  47971. var invI211;
  47972. var invI212;
  47973. var invI220;
  47974. var invI221;
  47975. var invI222;
  47976. invI100 = b1._invInertia00;
  47977. invI101 = b1._invInertia01;
  47978. invI102 = b1._invInertia02;
  47979. invI110 = b1._invInertia10;
  47980. invI111 = b1._invInertia11;
  47981. invI112 = b1._invInertia12;
  47982. invI120 = b1._invInertia20;
  47983. invI121 = b1._invInertia21;
  47984. invI122 = b1._invInertia22;
  47985. invI200 = b2._invInertia00;
  47986. invI201 = b2._invInertia01;
  47987. invI202 = b2._invInertia02;
  47988. invI210 = b2._invInertia10;
  47989. invI211 = b2._invInertia11;
  47990. invI212 = b2._invInertia12;
  47991. invI220 = b2._invInertia20;
  47992. invI221 = b2._invInertia21;
  47993. invI222 = b2._invInertia22;
  47994. var _g = 0;
  47995. var _g1 = numRows;
  47996. while(_g < _g1) {
  47997. var i = _g++;
  47998. var j = info.rows[i].jacobian;
  47999. var md = massData[i];
  48000. j.updateSparsity();
  48001. if((j.flag & 1) != 0) {
  48002. md.invMLin1X = j.lin1X * invM1;
  48003. md.invMLin1Y = j.lin1Y * invM1;
  48004. md.invMLin1Z = j.lin1Z * invM1;
  48005. md.invMLin2X = j.lin2X * invM2;
  48006. md.invMLin2Y = j.lin2Y * invM2;
  48007. md.invMLin2Z = j.lin2Z * invM2;
  48008. } else {
  48009. md.invMLin1X = 0;
  48010. md.invMLin1Y = 0;
  48011. md.invMLin1Z = 0;
  48012. md.invMLin2X = 0;
  48013. md.invMLin2Y = 0;
  48014. md.invMLin2Z = 0;
  48015. }
  48016. if((j.flag & 2) != 0) {
  48017. var __tmp__X;
  48018. var __tmp__Y;
  48019. var __tmp__Z;
  48020. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  48021. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  48022. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  48023. md.invMAng1X = __tmp__X;
  48024. md.invMAng1Y = __tmp__Y;
  48025. md.invMAng1Z = __tmp__Z;
  48026. var __tmp__X1;
  48027. var __tmp__Y1;
  48028. var __tmp__Z1;
  48029. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  48030. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  48031. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  48032. md.invMAng2X = __tmp__X1;
  48033. md.invMAng2Y = __tmp__Y1;
  48034. md.invMAng2Z = __tmp__Z1;
  48035. } else {
  48036. md.invMAng1X = 0;
  48037. md.invMAng1Y = 0;
  48038. md.invMAng1Z = 0;
  48039. md.invMAng2X = 0;
  48040. md.invMAng2Y = 0;
  48041. md.invMAng2Z = 0;
  48042. }
  48043. }
  48044. var _g2 = 0;
  48045. var _g3 = numRows;
  48046. while(_g2 < _g3) {
  48047. var i1 = _g2++;
  48048. var j1 = info.rows[i1].jacobian;
  48049. var _g21 = i1;
  48050. var _g31 = numRows;
  48051. while(_g21 < _g31) {
  48052. var j2 = _g21++;
  48053. var j21 = info.rows[j2].jacobian;
  48054. var md2 = massData[j2];
  48055. var val = j1.lin1X * md2.invMLin1X + j1.lin1Y * md2.invMLin1Y + j1.lin1Z * md2.invMLin1Z + (j1.ang1X * md2.invMAng1X + j1.ang1Y * md2.invMAng1Y + j1.ang1Z * md2.invMAng1Z) + (j1.lin2X * md2.invMLin2X + j1.lin2Y * md2.invMLin2Y + j1.lin2Z * md2.invMLin2Z) + (j1.ang2X * md2.invMAng2X + j1.ang2Y * md2.invMAng2Y + j1.ang2Z * md2.invMAng2Z);
  48056. if(i1 == j2) {
  48057. invMass[i1][j2] = val + info.rows[i1].cfm;
  48058. invMassWithoutCfm[i1][j2] = val;
  48059. md2.mass = val + info.rows[i1].cfm;
  48060. md2.massWithoutCfm = val;
  48061. if(md2.mass != 0) {
  48062. md2.mass = 1 / md2.mass;
  48063. }
  48064. if(md2.massWithoutCfm != 0) {
  48065. md2.massWithoutCfm = 1 / md2.massWithoutCfm;
  48066. }
  48067. } else {
  48068. invMass[i1][j2] = val;
  48069. invMass[j2][i1] = val;
  48070. invMassWithoutCfm[i1][j2] = val;
  48071. invMassWithoutCfm[j2][i1] = val;
  48072. }
  48073. }
  48074. }
  48075. var _g4 = 0;
  48076. var _g11 = this._maxSubmatrixId;
  48077. while(_g4 < _g11) {
  48078. var i2 = _g4++;
  48079. this._cacheComputed[i2] = false;
  48080. }
  48081. }
  48082. }
  48083. if(!oimo.dynamics.constraint.solver.pgs) oimo.dynamics.constraint.solver.pgs = {};
  48084. oimo.dynamics.constraint.solver.pgs.PgsContactConstraintSolver = class oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver extends oimo.dynamics.constraint.ConstraintSolver {
  48085. constructor(constraint) {
  48086. super();
  48087. this.constraint = constraint;
  48088. this.info = new oimo.dynamics.constraint.info.contact.ContactSolverInfo();
  48089. var this1 = new Array(oimo.common.Setting.maxManifoldPoints);
  48090. this.massData = this1;
  48091. var _g = 0;
  48092. var _g1 = this.massData.length;
  48093. while(_g < _g1) {
  48094. var i = _g++;
  48095. this.massData[i] = new oimo.dynamics.constraint.solver.common.ContactSolverMassDataRow();
  48096. }
  48097. }
  48098. preSolveVelocity(timeStep) {
  48099. this.constraint._getVelocitySolverInfo(timeStep,this.info);
  48100. this._b1 = this.info.b1;
  48101. this._b2 = this.info.b2;
  48102. var invM1 = this._b1._invMass;
  48103. var invM2 = this._b2._invMass;
  48104. var invI1;
  48105. var invI100;
  48106. var invI101;
  48107. var invI102;
  48108. var invI110;
  48109. var invI111;
  48110. var invI112;
  48111. var invI120;
  48112. var invI121;
  48113. var invI122;
  48114. var invI2;
  48115. var invI200;
  48116. var invI201;
  48117. var invI202;
  48118. var invI210;
  48119. var invI211;
  48120. var invI212;
  48121. var invI220;
  48122. var invI221;
  48123. var invI222;
  48124. invI100 = this._b1._invInertia00;
  48125. invI101 = this._b1._invInertia01;
  48126. invI102 = this._b1._invInertia02;
  48127. invI110 = this._b1._invInertia10;
  48128. invI111 = this._b1._invInertia11;
  48129. invI112 = this._b1._invInertia12;
  48130. invI120 = this._b1._invInertia20;
  48131. invI121 = this._b1._invInertia21;
  48132. invI122 = this._b1._invInertia22;
  48133. invI200 = this._b2._invInertia00;
  48134. invI201 = this._b2._invInertia01;
  48135. invI202 = this._b2._invInertia02;
  48136. invI210 = this._b2._invInertia10;
  48137. invI211 = this._b2._invInertia11;
  48138. invI212 = this._b2._invInertia12;
  48139. invI220 = this._b2._invInertia20;
  48140. invI221 = this._b2._invInertia21;
  48141. invI222 = this._b2._invInertia22;
  48142. var _g = 0;
  48143. var _g1 = this.info.numRows;
  48144. while(_g < _g1) {
  48145. var i = _g++;
  48146. var row = this.info.rows[i];
  48147. var md = this.massData[i];
  48148. var j = row.jacobianN;
  48149. md.invMLinN1X = j.lin1X * invM1;
  48150. md.invMLinN1Y = j.lin1Y * invM1;
  48151. md.invMLinN1Z = j.lin1Z * invM1;
  48152. md.invMLinN2X = j.lin2X * invM2;
  48153. md.invMLinN2Y = j.lin2Y * invM2;
  48154. md.invMLinN2Z = j.lin2Z * invM2;
  48155. var __tmp__X;
  48156. var __tmp__Y;
  48157. var __tmp__Z;
  48158. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  48159. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  48160. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  48161. md.invMAngN1X = __tmp__X;
  48162. md.invMAngN1Y = __tmp__Y;
  48163. md.invMAngN1Z = __tmp__Z;
  48164. var __tmp__X1;
  48165. var __tmp__Y1;
  48166. var __tmp__Z1;
  48167. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  48168. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  48169. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  48170. md.invMAngN2X = __tmp__X1;
  48171. md.invMAngN2Y = __tmp__Y1;
  48172. md.invMAngN2Z = __tmp__Z1;
  48173. md.massN = invM1 + invM2 + (md.invMAngN1X * j.ang1X + md.invMAngN1Y * j.ang1Y + md.invMAngN1Z * j.ang1Z) + (md.invMAngN2X * j.ang2X + md.invMAngN2Y * j.ang2Y + md.invMAngN2Z * j.ang2Z);
  48174. if(md.massN != 0) {
  48175. md.massN = 1 / md.massN;
  48176. }
  48177. var jt = row.jacobianT;
  48178. var jb = row.jacobianB;
  48179. md.invMLinT1X = jt.lin1X * invM1;
  48180. md.invMLinT1Y = jt.lin1Y * invM1;
  48181. md.invMLinT1Z = jt.lin1Z * invM1;
  48182. md.invMLinT2X = jt.lin2X * invM2;
  48183. md.invMLinT2Y = jt.lin2Y * invM2;
  48184. md.invMLinT2Z = jt.lin2Z * invM2;
  48185. md.invMLinB1X = jb.lin1X * invM1;
  48186. md.invMLinB1Y = jb.lin1Y * invM1;
  48187. md.invMLinB1Z = jb.lin1Z * invM1;
  48188. md.invMLinB2X = jb.lin2X * invM2;
  48189. md.invMLinB2Y = jb.lin2Y * invM2;
  48190. md.invMLinB2Z = jb.lin2Z * invM2;
  48191. var __tmp__X2;
  48192. var __tmp__Y2;
  48193. var __tmp__Z2;
  48194. __tmp__X2 = invI100 * jt.ang1X + invI101 * jt.ang1Y + invI102 * jt.ang1Z;
  48195. __tmp__Y2 = invI110 * jt.ang1X + invI111 * jt.ang1Y + invI112 * jt.ang1Z;
  48196. __tmp__Z2 = invI120 * jt.ang1X + invI121 * jt.ang1Y + invI122 * jt.ang1Z;
  48197. md.invMAngT1X = __tmp__X2;
  48198. md.invMAngT1Y = __tmp__Y2;
  48199. md.invMAngT1Z = __tmp__Z2;
  48200. var __tmp__X3;
  48201. var __tmp__Y3;
  48202. var __tmp__Z3;
  48203. __tmp__X3 = invI200 * jt.ang2X + invI201 * jt.ang2Y + invI202 * jt.ang2Z;
  48204. __tmp__Y3 = invI210 * jt.ang2X + invI211 * jt.ang2Y + invI212 * jt.ang2Z;
  48205. __tmp__Z3 = invI220 * jt.ang2X + invI221 * jt.ang2Y + invI222 * jt.ang2Z;
  48206. md.invMAngT2X = __tmp__X3;
  48207. md.invMAngT2Y = __tmp__Y3;
  48208. md.invMAngT2Z = __tmp__Z3;
  48209. var __tmp__X4;
  48210. var __tmp__Y4;
  48211. var __tmp__Z4;
  48212. __tmp__X4 = invI100 * jb.ang1X + invI101 * jb.ang1Y + invI102 * jb.ang1Z;
  48213. __tmp__Y4 = invI110 * jb.ang1X + invI111 * jb.ang1Y + invI112 * jb.ang1Z;
  48214. __tmp__Z4 = invI120 * jb.ang1X + invI121 * jb.ang1Y + invI122 * jb.ang1Z;
  48215. md.invMAngB1X = __tmp__X4;
  48216. md.invMAngB1Y = __tmp__Y4;
  48217. md.invMAngB1Z = __tmp__Z4;
  48218. var __tmp__X5;
  48219. var __tmp__Y5;
  48220. var __tmp__Z5;
  48221. __tmp__X5 = invI200 * jb.ang2X + invI201 * jb.ang2Y + invI202 * jb.ang2Z;
  48222. __tmp__Y5 = invI210 * jb.ang2X + invI211 * jb.ang2Y + invI212 * jb.ang2Z;
  48223. __tmp__Z5 = invI220 * jb.ang2X + invI221 * jb.ang2Y + invI222 * jb.ang2Z;
  48224. md.invMAngB2X = __tmp__X5;
  48225. md.invMAngB2Y = __tmp__Y5;
  48226. md.invMAngB2Z = __tmp__Z5;
  48227. var invMassTB00 = invM1 + invM2 + (md.invMAngT1X * jt.ang1X + md.invMAngT1Y * jt.ang1Y + md.invMAngT1Z * jt.ang1Z) + (md.invMAngT2X * jt.ang2X + md.invMAngT2Y * jt.ang2Y + md.invMAngT2Z * jt.ang2Z);
  48228. var invMassTB01 = md.invMAngT1X * jb.ang1X + md.invMAngT1Y * jb.ang1Y + md.invMAngT1Z * jb.ang1Z + (md.invMAngT2X * jb.ang2X + md.invMAngT2Y * jb.ang2Y + md.invMAngT2Z * jb.ang2Z);
  48229. var invMassTB10 = invMassTB01;
  48230. var invMassTB11 = invM1 + invM2 + (md.invMAngB1X * jb.ang1X + md.invMAngB1Y * jb.ang1Y + md.invMAngB1Z * jb.ang1Z) + (md.invMAngB2X * jb.ang2X + md.invMAngB2Y * jb.ang2Y + md.invMAngB2Z * jb.ang2Z);
  48231. var invDet = invMassTB00 * invMassTB11 - invMassTB01 * invMassTB10;
  48232. if(invDet != 0) {
  48233. invDet = 1 / invDet;
  48234. }
  48235. md.massTB00 = invMassTB11 * invDet;
  48236. md.massTB01 = -invMassTB01 * invDet;
  48237. md.massTB10 = -invMassTB10 * invDet;
  48238. md.massTB11 = invMassTB00 * invDet;
  48239. }
  48240. }
  48241. warmStart(timeStep) {
  48242. var lv1;
  48243. var lv1X;
  48244. var lv1Y;
  48245. var lv1Z;
  48246. var lv2;
  48247. var lv2X;
  48248. var lv2Y;
  48249. var lv2Z;
  48250. var av1;
  48251. var av1X;
  48252. var av1Y;
  48253. var av1Z;
  48254. var av2;
  48255. var av2X;
  48256. var av2Y;
  48257. var av2Z;
  48258. lv1X = this._b1._velX;
  48259. lv1Y = this._b1._velY;
  48260. lv1Z = this._b1._velZ;
  48261. lv2X = this._b2._velX;
  48262. lv2Y = this._b2._velY;
  48263. lv2Z = this._b2._velZ;
  48264. av1X = this._b1._angVelX;
  48265. av1Y = this._b1._angVelY;
  48266. av1Z = this._b1._angVelZ;
  48267. av2X = this._b2._angVelX;
  48268. av2Y = this._b2._angVelY;
  48269. av2Z = this._b2._angVelZ;
  48270. var _g = 0;
  48271. var _g1 = this.info.numRows;
  48272. while(_g < _g1) {
  48273. var i = _g++;
  48274. var row = this.info.rows[i];
  48275. var imp = row.impulse;
  48276. var md = this.massData[i];
  48277. var jt = row.jacobianT;
  48278. var jb = row.jacobianB;
  48279. var impulseN = imp.impulseN;
  48280. var impulseT = imp.impulseLX * jt.lin1X + imp.impulseLY * jt.lin1Y + imp.impulseLZ * jt.lin1Z;
  48281. var impulseB = imp.impulseLX * jb.lin1X + imp.impulseLY * jb.lin1Y + imp.impulseLZ * jb.lin1Z;
  48282. imp.impulseT = impulseT;
  48283. imp.impulseB = impulseB;
  48284. imp.impulseN *= timeStep.dtRatio;
  48285. imp.impulseT *= timeStep.dtRatio;
  48286. imp.impulseB *= timeStep.dtRatio;
  48287. lv1X += md.invMLinN1X * impulseN;
  48288. lv1Y += md.invMLinN1Y * impulseN;
  48289. lv1Z += md.invMLinN1Z * impulseN;
  48290. lv1X += md.invMLinT1X * impulseT;
  48291. lv1Y += md.invMLinT1Y * impulseT;
  48292. lv1Z += md.invMLinT1Z * impulseT;
  48293. lv1X += md.invMLinB1X * impulseB;
  48294. lv1Y += md.invMLinB1Y * impulseB;
  48295. lv1Z += md.invMLinB1Z * impulseB;
  48296. lv2X += md.invMLinN2X * -impulseN;
  48297. lv2Y += md.invMLinN2Y * -impulseN;
  48298. lv2Z += md.invMLinN2Z * -impulseN;
  48299. lv2X += md.invMLinT2X * -impulseT;
  48300. lv2Y += md.invMLinT2Y * -impulseT;
  48301. lv2Z += md.invMLinT2Z * -impulseT;
  48302. lv2X += md.invMLinB2X * -impulseB;
  48303. lv2Y += md.invMLinB2Y * -impulseB;
  48304. lv2Z += md.invMLinB2Z * -impulseB;
  48305. av1X += md.invMAngN1X * impulseN;
  48306. av1Y += md.invMAngN1Y * impulseN;
  48307. av1Z += md.invMAngN1Z * impulseN;
  48308. av1X += md.invMAngT1X * impulseT;
  48309. av1Y += md.invMAngT1Y * impulseT;
  48310. av1Z += md.invMAngT1Z * impulseT;
  48311. av1X += md.invMAngB1X * impulseB;
  48312. av1Y += md.invMAngB1Y * impulseB;
  48313. av1Z += md.invMAngB1Z * impulseB;
  48314. av2X += md.invMAngN2X * -impulseN;
  48315. av2Y += md.invMAngN2Y * -impulseN;
  48316. av2Z += md.invMAngN2Z * -impulseN;
  48317. av2X += md.invMAngT2X * -impulseT;
  48318. av2Y += md.invMAngT2Y * -impulseT;
  48319. av2Z += md.invMAngT2Z * -impulseT;
  48320. av2X += md.invMAngB2X * -impulseB;
  48321. av2Y += md.invMAngB2Y * -impulseB;
  48322. av2Z += md.invMAngB2Z * -impulseB;
  48323. }
  48324. this._b1._velX = lv1X;
  48325. this._b1._velY = lv1Y;
  48326. this._b1._velZ = lv1Z;
  48327. this._b2._velX = lv2X;
  48328. this._b2._velY = lv2Y;
  48329. this._b2._velZ = lv2Z;
  48330. this._b1._angVelX = av1X;
  48331. this._b1._angVelY = av1Y;
  48332. this._b1._angVelZ = av1Z;
  48333. this._b2._angVelX = av2X;
  48334. this._b2._angVelY = av2Y;
  48335. this._b2._angVelZ = av2Z;
  48336. }
  48337. solveVelocity() {
  48338. var lv1;
  48339. var lv1X;
  48340. var lv1Y;
  48341. var lv1Z;
  48342. var lv2;
  48343. var lv2X;
  48344. var lv2Y;
  48345. var lv2Z;
  48346. var av1;
  48347. var av1X;
  48348. var av1Y;
  48349. var av1Z;
  48350. var av2;
  48351. var av2X;
  48352. var av2Y;
  48353. var av2Z;
  48354. lv1X = this._b1._velX;
  48355. lv1Y = this._b1._velY;
  48356. lv1Z = this._b1._velZ;
  48357. lv2X = this._b2._velX;
  48358. lv2Y = this._b2._velY;
  48359. lv2Z = this._b2._velZ;
  48360. av1X = this._b1._angVelX;
  48361. av1Y = this._b1._angVelY;
  48362. av1Z = this._b1._angVelZ;
  48363. av2X = this._b2._angVelX;
  48364. av2Y = this._b2._angVelY;
  48365. av2Z = this._b2._angVelZ;
  48366. var _g = 0;
  48367. var _g1 = this.info.numRows;
  48368. while(_g < _g1) {
  48369. var i = _g++;
  48370. var row = this.info.rows[i];
  48371. var md = this.massData[i];
  48372. var imp = row.impulse;
  48373. var rvt = 0;
  48374. var j = row.jacobianT;
  48375. rvt += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  48376. rvt -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  48377. rvt += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  48378. rvt -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  48379. var rvb = 0;
  48380. j = row.jacobianB;
  48381. rvb += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  48382. rvb -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  48383. rvb += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  48384. rvb -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  48385. var impulseT = -(rvt * md.massTB00 + rvb * md.massTB01);
  48386. var impulseB = -(rvt * md.massTB10 + rvb * md.massTB11);
  48387. var oldImpulseT = imp.impulseT;
  48388. var oldImpulseB = imp.impulseB;
  48389. imp.impulseT += impulseT;
  48390. imp.impulseB += impulseB;
  48391. var maxImpulse = row.friction * imp.impulseN;
  48392. if(maxImpulse == 0) {
  48393. imp.impulseT = 0;
  48394. imp.impulseB = 0;
  48395. } else {
  48396. var impulseLengthSq = imp.impulseT * imp.impulseT + imp.impulseB * imp.impulseB;
  48397. if(impulseLengthSq > maxImpulse * maxImpulse) {
  48398. var invL = maxImpulse / Math.sqrt(impulseLengthSq);
  48399. imp.impulseT *= invL;
  48400. imp.impulseB *= invL;
  48401. }
  48402. }
  48403. impulseT = imp.impulseT - oldImpulseT;
  48404. impulseB = imp.impulseB - oldImpulseB;
  48405. lv1X += md.invMLinT1X * impulseT;
  48406. lv1Y += md.invMLinT1Y * impulseT;
  48407. lv1Z += md.invMLinT1Z * impulseT;
  48408. lv1X += md.invMLinB1X * impulseB;
  48409. lv1Y += md.invMLinB1Y * impulseB;
  48410. lv1Z += md.invMLinB1Z * impulseB;
  48411. lv2X += md.invMLinT2X * -impulseT;
  48412. lv2Y += md.invMLinT2Y * -impulseT;
  48413. lv2Z += md.invMLinT2Z * -impulseT;
  48414. lv2X += md.invMLinB2X * -impulseB;
  48415. lv2Y += md.invMLinB2Y * -impulseB;
  48416. lv2Z += md.invMLinB2Z * -impulseB;
  48417. av1X += md.invMAngT1X * impulseT;
  48418. av1Y += md.invMAngT1Y * impulseT;
  48419. av1Z += md.invMAngT1Z * impulseT;
  48420. av1X += md.invMAngB1X * impulseB;
  48421. av1Y += md.invMAngB1Y * impulseB;
  48422. av1Z += md.invMAngB1Z * impulseB;
  48423. av2X += md.invMAngT2X * -impulseT;
  48424. av2Y += md.invMAngT2Y * -impulseT;
  48425. av2Z += md.invMAngT2Z * -impulseT;
  48426. av2X += md.invMAngB2X * -impulseB;
  48427. av2Y += md.invMAngB2Y * -impulseB;
  48428. av2Z += md.invMAngB2Z * -impulseB;
  48429. }
  48430. var _g2 = 0;
  48431. var _g3 = this.info.numRows;
  48432. while(_g2 < _g3) {
  48433. var i1 = _g2++;
  48434. var row1 = this.info.rows[i1];
  48435. var md1 = this.massData[i1];
  48436. var imp1 = row1.impulse;
  48437. var rvn = 0;
  48438. var j1 = row1.jacobianN;
  48439. rvn += lv1X * j1.lin1X + lv1Y * j1.lin1Y + lv1Z * j1.lin1Z;
  48440. rvn -= lv2X * j1.lin2X + lv2Y * j1.lin2Y + lv2Z * j1.lin2Z;
  48441. rvn += av1X * j1.ang1X + av1Y * j1.ang1Y + av1Z * j1.ang1Z;
  48442. rvn -= av2X * j1.ang2X + av2Y * j1.ang2Y + av2Z * j1.ang2Z;
  48443. var impulseN = (row1.rhs - rvn) * md1.massN;
  48444. var oldImpulseN = imp1.impulseN;
  48445. imp1.impulseN += impulseN;
  48446. if(imp1.impulseN < 0) {
  48447. imp1.impulseN = 0;
  48448. }
  48449. impulseN = imp1.impulseN - oldImpulseN;
  48450. lv1X += md1.invMLinN1X * impulseN;
  48451. lv1Y += md1.invMLinN1Y * impulseN;
  48452. lv1Z += md1.invMLinN1Z * impulseN;
  48453. lv2X += md1.invMLinN2X * -impulseN;
  48454. lv2Y += md1.invMLinN2Y * -impulseN;
  48455. lv2Z += md1.invMLinN2Z * -impulseN;
  48456. av1X += md1.invMAngN1X * impulseN;
  48457. av1Y += md1.invMAngN1Y * impulseN;
  48458. av1Z += md1.invMAngN1Z * impulseN;
  48459. av2X += md1.invMAngN2X * -impulseN;
  48460. av2Y += md1.invMAngN2Y * -impulseN;
  48461. av2Z += md1.invMAngN2Z * -impulseN;
  48462. }
  48463. this._b1._velX = lv1X;
  48464. this._b1._velY = lv1Y;
  48465. this._b1._velZ = lv1Z;
  48466. this._b2._velX = lv2X;
  48467. this._b2._velY = lv2Y;
  48468. this._b2._velZ = lv2Z;
  48469. this._b1._angVelX = av1X;
  48470. this._b1._angVelY = av1Y;
  48471. this._b1._angVelZ = av1Z;
  48472. this._b2._angVelX = av2X;
  48473. this._b2._angVelY = av2Y;
  48474. this._b2._angVelZ = av2Z;
  48475. }
  48476. preSolvePosition(timeStep) {
  48477. this.constraint._syncManifold();
  48478. this.constraint._getPositionSolverInfo(this.info);
  48479. var invM1 = this._b1._invMass;
  48480. var invM2 = this._b2._invMass;
  48481. var invI1;
  48482. var invI100;
  48483. var invI101;
  48484. var invI102;
  48485. var invI110;
  48486. var invI111;
  48487. var invI112;
  48488. var invI120;
  48489. var invI121;
  48490. var invI122;
  48491. var invI2;
  48492. var invI200;
  48493. var invI201;
  48494. var invI202;
  48495. var invI210;
  48496. var invI211;
  48497. var invI212;
  48498. var invI220;
  48499. var invI221;
  48500. var invI222;
  48501. invI100 = this._b1._invInertia00;
  48502. invI101 = this._b1._invInertia01;
  48503. invI102 = this._b1._invInertia02;
  48504. invI110 = this._b1._invInertia10;
  48505. invI111 = this._b1._invInertia11;
  48506. invI112 = this._b1._invInertia12;
  48507. invI120 = this._b1._invInertia20;
  48508. invI121 = this._b1._invInertia21;
  48509. invI122 = this._b1._invInertia22;
  48510. invI200 = this._b2._invInertia00;
  48511. invI201 = this._b2._invInertia01;
  48512. invI202 = this._b2._invInertia02;
  48513. invI210 = this._b2._invInertia10;
  48514. invI211 = this._b2._invInertia11;
  48515. invI212 = this._b2._invInertia12;
  48516. invI220 = this._b2._invInertia20;
  48517. invI221 = this._b2._invInertia21;
  48518. invI222 = this._b2._invInertia22;
  48519. var _g = 0;
  48520. var _g1 = this.info.numRows;
  48521. while(_g < _g1) {
  48522. var i = _g++;
  48523. var row = this.info.rows[i];
  48524. var md = this.massData[i];
  48525. var j = row.jacobianN;
  48526. md.invMLinN1X = j.lin1X * invM1;
  48527. md.invMLinN1Y = j.lin1Y * invM1;
  48528. md.invMLinN1Z = j.lin1Z * invM1;
  48529. md.invMLinN2X = j.lin2X * invM2;
  48530. md.invMLinN2Y = j.lin2Y * invM2;
  48531. md.invMLinN2Z = j.lin2Z * invM2;
  48532. var __tmp__X;
  48533. var __tmp__Y;
  48534. var __tmp__Z;
  48535. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  48536. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  48537. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  48538. md.invMAngN1X = __tmp__X;
  48539. md.invMAngN1Y = __tmp__Y;
  48540. md.invMAngN1Z = __tmp__Z;
  48541. var __tmp__X1;
  48542. var __tmp__Y1;
  48543. var __tmp__Z1;
  48544. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  48545. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  48546. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  48547. md.invMAngN2X = __tmp__X1;
  48548. md.invMAngN2Y = __tmp__Y1;
  48549. md.invMAngN2Z = __tmp__Z1;
  48550. md.massN = invM1 + invM2 + (md.invMAngN1X * j.ang1X + md.invMAngN1Y * j.ang1Y + md.invMAngN1Z * j.ang1Z) + (md.invMAngN2X * j.ang2X + md.invMAngN2Y * j.ang2Y + md.invMAngN2Z * j.ang2Z);
  48551. if(md.massN != 0) {
  48552. md.massN = 1 / md.massN;
  48553. }
  48554. }
  48555. var _g2 = 0;
  48556. var _g11 = this.info.numRows;
  48557. while(_g2 < _g11) {
  48558. var i1 = _g2++;
  48559. this.info.rows[i1].impulse.impulseP = 0;
  48560. }
  48561. }
  48562. solvePositionSplitImpulse() {
  48563. var lv1;
  48564. var lv1X;
  48565. var lv1Y;
  48566. var lv1Z;
  48567. var lv2;
  48568. var lv2X;
  48569. var lv2Y;
  48570. var lv2Z;
  48571. var av1;
  48572. var av1X;
  48573. var av1Y;
  48574. var av1Z;
  48575. var av2;
  48576. var av2X;
  48577. var av2Y;
  48578. var av2Z;
  48579. lv1X = this._b1._pseudoVelX;
  48580. lv1Y = this._b1._pseudoVelY;
  48581. lv1Z = this._b1._pseudoVelZ;
  48582. lv2X = this._b2._pseudoVelX;
  48583. lv2Y = this._b2._pseudoVelY;
  48584. lv2Z = this._b2._pseudoVelZ;
  48585. av1X = this._b1._angPseudoVelX;
  48586. av1Y = this._b1._angPseudoVelY;
  48587. av1Z = this._b1._angPseudoVelZ;
  48588. av2X = this._b2._angPseudoVelX;
  48589. av2Y = this._b2._angPseudoVelY;
  48590. av2Z = this._b2._angPseudoVelZ;
  48591. var _g = 0;
  48592. var _g1 = this.info.numRows;
  48593. while(_g < _g1) {
  48594. var i = _g++;
  48595. var row = this.info.rows[i];
  48596. var md = this.massData[i];
  48597. var imp = row.impulse;
  48598. var j = row.jacobianN;
  48599. var rvn = 0;
  48600. rvn += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  48601. rvn -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  48602. rvn += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  48603. rvn -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  48604. var impulseP = (row.rhs - rvn) * md.massN * oimo.common.Setting.positionSplitImpulseBaumgarte;
  48605. var oldImpulseP = imp.impulseP;
  48606. imp.impulseP += impulseP;
  48607. if(imp.impulseP < 0) {
  48608. imp.impulseP = 0;
  48609. }
  48610. impulseP = imp.impulseP - oldImpulseP;
  48611. lv1X += md.invMLinN1X * impulseP;
  48612. lv1Y += md.invMLinN1Y * impulseP;
  48613. lv1Z += md.invMLinN1Z * impulseP;
  48614. lv2X += md.invMLinN2X * -impulseP;
  48615. lv2Y += md.invMLinN2Y * -impulseP;
  48616. lv2Z += md.invMLinN2Z * -impulseP;
  48617. av1X += md.invMAngN1X * impulseP;
  48618. av1Y += md.invMAngN1Y * impulseP;
  48619. av1Z += md.invMAngN1Z * impulseP;
  48620. av2X += md.invMAngN2X * -impulseP;
  48621. av2Y += md.invMAngN2Y * -impulseP;
  48622. av2Z += md.invMAngN2Z * -impulseP;
  48623. }
  48624. this._b1._pseudoVelX = lv1X;
  48625. this._b1._pseudoVelY = lv1Y;
  48626. this._b1._pseudoVelZ = lv1Z;
  48627. this._b2._pseudoVelX = lv2X;
  48628. this._b2._pseudoVelY = lv2Y;
  48629. this._b2._pseudoVelZ = lv2Z;
  48630. this._b1._angPseudoVelX = av1X;
  48631. this._b1._angPseudoVelY = av1Y;
  48632. this._b1._angPseudoVelZ = av1Z;
  48633. this._b2._angPseudoVelX = av2X;
  48634. this._b2._angPseudoVelY = av2Y;
  48635. this._b2._angPseudoVelZ = av2Z;
  48636. }
  48637. solvePositionNgs(timeStep) {
  48638. this.constraint._syncManifold();
  48639. this.constraint._getPositionSolverInfo(this.info);
  48640. var invM1 = this._b1._invMass;
  48641. var invM2 = this._b2._invMass;
  48642. var invI1;
  48643. var invI100;
  48644. var invI101;
  48645. var invI102;
  48646. var invI110;
  48647. var invI111;
  48648. var invI112;
  48649. var invI120;
  48650. var invI121;
  48651. var invI122;
  48652. var invI2;
  48653. var invI200;
  48654. var invI201;
  48655. var invI202;
  48656. var invI210;
  48657. var invI211;
  48658. var invI212;
  48659. var invI220;
  48660. var invI221;
  48661. var invI222;
  48662. invI100 = this._b1._invInertia00;
  48663. invI101 = this._b1._invInertia01;
  48664. invI102 = this._b1._invInertia02;
  48665. invI110 = this._b1._invInertia10;
  48666. invI111 = this._b1._invInertia11;
  48667. invI112 = this._b1._invInertia12;
  48668. invI120 = this._b1._invInertia20;
  48669. invI121 = this._b1._invInertia21;
  48670. invI122 = this._b1._invInertia22;
  48671. invI200 = this._b2._invInertia00;
  48672. invI201 = this._b2._invInertia01;
  48673. invI202 = this._b2._invInertia02;
  48674. invI210 = this._b2._invInertia10;
  48675. invI211 = this._b2._invInertia11;
  48676. invI212 = this._b2._invInertia12;
  48677. invI220 = this._b2._invInertia20;
  48678. invI221 = this._b2._invInertia21;
  48679. invI222 = this._b2._invInertia22;
  48680. var _g = 0;
  48681. var _g1 = this.info.numRows;
  48682. while(_g < _g1) {
  48683. var i = _g++;
  48684. var row = this.info.rows[i];
  48685. var md = this.massData[i];
  48686. var j = row.jacobianN;
  48687. md.invMLinN1X = j.lin1X * invM1;
  48688. md.invMLinN1Y = j.lin1Y * invM1;
  48689. md.invMLinN1Z = j.lin1Z * invM1;
  48690. md.invMLinN2X = j.lin2X * invM2;
  48691. md.invMLinN2Y = j.lin2Y * invM2;
  48692. md.invMLinN2Z = j.lin2Z * invM2;
  48693. var __tmp__X;
  48694. var __tmp__Y;
  48695. var __tmp__Z;
  48696. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  48697. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  48698. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  48699. md.invMAngN1X = __tmp__X;
  48700. md.invMAngN1Y = __tmp__Y;
  48701. md.invMAngN1Z = __tmp__Z;
  48702. var __tmp__X1;
  48703. var __tmp__Y1;
  48704. var __tmp__Z1;
  48705. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  48706. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  48707. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  48708. md.invMAngN2X = __tmp__X1;
  48709. md.invMAngN2Y = __tmp__Y1;
  48710. md.invMAngN2Z = __tmp__Z1;
  48711. md.massN = invM1 + invM2 + (md.invMAngN1X * j.ang1X + md.invMAngN1Y * j.ang1Y + md.invMAngN1Z * j.ang1Z) + (md.invMAngN2X * j.ang2X + md.invMAngN2Y * j.ang2Y + md.invMAngN2Z * j.ang2Z);
  48712. if(md.massN != 0) {
  48713. md.massN = 1 / md.massN;
  48714. }
  48715. }
  48716. var lv1;
  48717. var lv1X;
  48718. var lv1Y;
  48719. var lv1Z;
  48720. var lv2;
  48721. var lv2X;
  48722. var lv2Y;
  48723. var lv2Z;
  48724. var av1;
  48725. var av1X;
  48726. var av1Y;
  48727. var av1Z;
  48728. var av2;
  48729. var av2X;
  48730. var av2Y;
  48731. var av2Z;
  48732. lv1X = 0;
  48733. lv1Y = 0;
  48734. lv1Z = 0;
  48735. lv2X = 0;
  48736. lv2Y = 0;
  48737. lv2Z = 0;
  48738. av1X = 0;
  48739. av1Y = 0;
  48740. av1Z = 0;
  48741. av2X = 0;
  48742. av2Y = 0;
  48743. av2Z = 0;
  48744. var _g2 = 0;
  48745. var _g11 = this.info.numRows;
  48746. while(_g2 < _g11) {
  48747. var i1 = _g2++;
  48748. var row1 = this.info.rows[i1];
  48749. var md1 = this.massData[i1];
  48750. var imp = row1.impulse;
  48751. var j1 = row1.jacobianN;
  48752. var rvn = 0;
  48753. rvn += lv1X * j1.lin1X + lv1Y * j1.lin1Y + lv1Z * j1.lin1Z;
  48754. rvn -= lv2X * j1.lin2X + lv2Y * j1.lin2Y + lv2Z * j1.lin2Z;
  48755. rvn += av1X * j1.ang1X + av1Y * j1.ang1Y + av1Z * j1.ang1Z;
  48756. rvn -= av2X * j1.ang2X + av2Y * j1.ang2Y + av2Z * j1.ang2Z;
  48757. var impulseP = (row1.rhs - rvn) * md1.massN * oimo.common.Setting.positionNgsBaumgarte;
  48758. var oldImpulseP = imp.impulseP;
  48759. imp.impulseP += impulseP;
  48760. if(imp.impulseP < 0) {
  48761. imp.impulseP = 0;
  48762. }
  48763. impulseP = imp.impulseP - oldImpulseP;
  48764. lv1X += md1.invMLinN1X * impulseP;
  48765. lv1Y += md1.invMLinN1Y * impulseP;
  48766. lv1Z += md1.invMLinN1Z * impulseP;
  48767. lv2X += md1.invMLinN2X * -impulseP;
  48768. lv2Y += md1.invMLinN2Y * -impulseP;
  48769. lv2Z += md1.invMLinN2Z * -impulseP;
  48770. av1X += md1.invMAngN1X * impulseP;
  48771. av1Y += md1.invMAngN1Y * impulseP;
  48772. av1Z += md1.invMAngN1Z * impulseP;
  48773. av2X += md1.invMAngN2X * -impulseP;
  48774. av2Y += md1.invMAngN2Y * -impulseP;
  48775. av2Z += md1.invMAngN2Z * -impulseP;
  48776. }
  48777. var _this = this._b1;
  48778. _this._transform._positionX += lv1X;
  48779. _this._transform._positionY += lv1Y;
  48780. _this._transform._positionZ += lv1Z;
  48781. var _this1 = this._b2;
  48782. _this1._transform._positionX += lv2X;
  48783. _this1._transform._positionY += lv2Y;
  48784. _this1._transform._positionZ += lv2Z;
  48785. var _this2 = this._b1;
  48786. var theta = Math.sqrt(av1X * av1X + av1Y * av1Y + av1Z * av1Z);
  48787. var halfTheta = theta * 0.5;
  48788. var rotationToSinAxisFactor;
  48789. var cosHalfTheta;
  48790. if(halfTheta < 0.5) {
  48791. var ht2 = halfTheta * halfTheta;
  48792. rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.166666666666666657 + ht2 * ht2 * 0.00833333333333333322);
  48793. cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.0416666666666666644;
  48794. } else {
  48795. rotationToSinAxisFactor = Math.sin(halfTheta) / theta;
  48796. cosHalfTheta = Math.cos(halfTheta);
  48797. }
  48798. var sinAxis;
  48799. var sinAxisX;
  48800. var sinAxisY;
  48801. var sinAxisZ;
  48802. sinAxisX = av1X * rotationToSinAxisFactor;
  48803. sinAxisY = av1Y * rotationToSinAxisFactor;
  48804. sinAxisZ = av1Z * rotationToSinAxisFactor;
  48805. var dq;
  48806. var dqX;
  48807. var dqY;
  48808. var dqZ;
  48809. var dqW;
  48810. dqX = sinAxisX;
  48811. dqY = sinAxisY;
  48812. dqZ = sinAxisZ;
  48813. dqW = cosHalfTheta;
  48814. var q;
  48815. var qX;
  48816. var qY;
  48817. var qZ;
  48818. var qW;
  48819. var e00 = _this2._transform._rotation00;
  48820. var e11 = _this2._transform._rotation11;
  48821. var e22 = _this2._transform._rotation22;
  48822. var t = e00 + e11 + e22;
  48823. var s;
  48824. if(t > 0) {
  48825. s = Math.sqrt(t + 1);
  48826. qW = 0.5 * s;
  48827. s = 0.5 / s;
  48828. qX = (_this2._transform._rotation21 - _this2._transform._rotation12) * s;
  48829. qY = (_this2._transform._rotation02 - _this2._transform._rotation20) * s;
  48830. qZ = (_this2._transform._rotation10 - _this2._transform._rotation01) * s;
  48831. } else if(e00 > e11) {
  48832. if(e00 > e22) {
  48833. s = Math.sqrt(e00 - e11 - e22 + 1);
  48834. qX = 0.5 * s;
  48835. s = 0.5 / s;
  48836. qY = (_this2._transform._rotation01 + _this2._transform._rotation10) * s;
  48837. qZ = (_this2._transform._rotation02 + _this2._transform._rotation20) * s;
  48838. qW = (_this2._transform._rotation21 - _this2._transform._rotation12) * s;
  48839. } else {
  48840. s = Math.sqrt(e22 - e00 - e11 + 1);
  48841. qZ = 0.5 * s;
  48842. s = 0.5 / s;
  48843. qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s;
  48844. qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s;
  48845. qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s;
  48846. }
  48847. } else if(e11 > e22) {
  48848. s = Math.sqrt(e11 - e22 - e00 + 1);
  48849. qY = 0.5 * s;
  48850. s = 0.5 / s;
  48851. qX = (_this2._transform._rotation01 + _this2._transform._rotation10) * s;
  48852. qZ = (_this2._transform._rotation12 + _this2._transform._rotation21) * s;
  48853. qW = (_this2._transform._rotation02 - _this2._transform._rotation20) * s;
  48854. } else {
  48855. s = Math.sqrt(e22 - e00 - e11 + 1);
  48856. qZ = 0.5 * s;
  48857. s = 0.5 / s;
  48858. qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s;
  48859. qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s;
  48860. qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s;
  48861. }
  48862. qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY;
  48863. qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX;
  48864. qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW;
  48865. qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ;
  48866. var l = qX * qX + qY * qY + qZ * qZ + qW * qW;
  48867. if(l > 1e-32) {
  48868. l = 1 / Math.sqrt(l);
  48869. }
  48870. qX *= l;
  48871. qY *= l;
  48872. qZ *= l;
  48873. qW *= l;
  48874. var x = qX;
  48875. var y = qY;
  48876. var z = qZ;
  48877. var w = qW;
  48878. var x2 = 2 * x;
  48879. var y2 = 2 * y;
  48880. var z2 = 2 * z;
  48881. var xx = x * x2;
  48882. var yy = y * y2;
  48883. var zz = z * z2;
  48884. var xy = x * y2;
  48885. var yz = y * z2;
  48886. var xz = x * z2;
  48887. var wx = w * x2;
  48888. var wy = w * y2;
  48889. var wz = w * z2;
  48890. _this2._transform._rotation00 = 1 - yy - zz;
  48891. _this2._transform._rotation01 = xy - wz;
  48892. _this2._transform._rotation02 = xz + wy;
  48893. _this2._transform._rotation10 = xy + wz;
  48894. _this2._transform._rotation11 = 1 - xx - zz;
  48895. _this2._transform._rotation12 = yz - wx;
  48896. _this2._transform._rotation20 = xz - wy;
  48897. _this2._transform._rotation21 = yz + wx;
  48898. _this2._transform._rotation22 = 1 - xx - yy;
  48899. var __tmp__00;
  48900. var __tmp__01;
  48901. var __tmp__02;
  48902. var __tmp__10;
  48903. var __tmp__11;
  48904. var __tmp__12;
  48905. var __tmp__20;
  48906. var __tmp__21;
  48907. var __tmp__22;
  48908. __tmp__00 = _this2._transform._rotation00 * _this2._invLocalInertia00 + _this2._transform._rotation01 * _this2._invLocalInertia10 + _this2._transform._rotation02 * _this2._invLocalInertia20;
  48909. __tmp__01 = _this2._transform._rotation00 * _this2._invLocalInertia01 + _this2._transform._rotation01 * _this2._invLocalInertia11 + _this2._transform._rotation02 * _this2._invLocalInertia21;
  48910. __tmp__02 = _this2._transform._rotation00 * _this2._invLocalInertia02 + _this2._transform._rotation01 * _this2._invLocalInertia12 + _this2._transform._rotation02 * _this2._invLocalInertia22;
  48911. __tmp__10 = _this2._transform._rotation10 * _this2._invLocalInertia00 + _this2._transform._rotation11 * _this2._invLocalInertia10 + _this2._transform._rotation12 * _this2._invLocalInertia20;
  48912. __tmp__11 = _this2._transform._rotation10 * _this2._invLocalInertia01 + _this2._transform._rotation11 * _this2._invLocalInertia11 + _this2._transform._rotation12 * _this2._invLocalInertia21;
  48913. __tmp__12 = _this2._transform._rotation10 * _this2._invLocalInertia02 + _this2._transform._rotation11 * _this2._invLocalInertia12 + _this2._transform._rotation12 * _this2._invLocalInertia22;
  48914. __tmp__20 = _this2._transform._rotation20 * _this2._invLocalInertia00 + _this2._transform._rotation21 * _this2._invLocalInertia10 + _this2._transform._rotation22 * _this2._invLocalInertia20;
  48915. __tmp__21 = _this2._transform._rotation20 * _this2._invLocalInertia01 + _this2._transform._rotation21 * _this2._invLocalInertia11 + _this2._transform._rotation22 * _this2._invLocalInertia21;
  48916. __tmp__22 = _this2._transform._rotation20 * _this2._invLocalInertia02 + _this2._transform._rotation21 * _this2._invLocalInertia12 + _this2._transform._rotation22 * _this2._invLocalInertia22;
  48917. _this2._invInertia00 = __tmp__00;
  48918. _this2._invInertia01 = __tmp__01;
  48919. _this2._invInertia02 = __tmp__02;
  48920. _this2._invInertia10 = __tmp__10;
  48921. _this2._invInertia11 = __tmp__11;
  48922. _this2._invInertia12 = __tmp__12;
  48923. _this2._invInertia20 = __tmp__20;
  48924. _this2._invInertia21 = __tmp__21;
  48925. _this2._invInertia22 = __tmp__22;
  48926. var __tmp__001;
  48927. var __tmp__011;
  48928. var __tmp__021;
  48929. var __tmp__101;
  48930. var __tmp__111;
  48931. var __tmp__121;
  48932. var __tmp__201;
  48933. var __tmp__211;
  48934. var __tmp__221;
  48935. __tmp__001 = _this2._invInertia00 * _this2._transform._rotation00 + _this2._invInertia01 * _this2._transform._rotation01 + _this2._invInertia02 * _this2._transform._rotation02;
  48936. __tmp__011 = _this2._invInertia00 * _this2._transform._rotation10 + _this2._invInertia01 * _this2._transform._rotation11 + _this2._invInertia02 * _this2._transform._rotation12;
  48937. __tmp__021 = _this2._invInertia00 * _this2._transform._rotation20 + _this2._invInertia01 * _this2._transform._rotation21 + _this2._invInertia02 * _this2._transform._rotation22;
  48938. __tmp__101 = _this2._invInertia10 * _this2._transform._rotation00 + _this2._invInertia11 * _this2._transform._rotation01 + _this2._invInertia12 * _this2._transform._rotation02;
  48939. __tmp__111 = _this2._invInertia10 * _this2._transform._rotation10 + _this2._invInertia11 * _this2._transform._rotation11 + _this2._invInertia12 * _this2._transform._rotation12;
  48940. __tmp__121 = _this2._invInertia10 * _this2._transform._rotation20 + _this2._invInertia11 * _this2._transform._rotation21 + _this2._invInertia12 * _this2._transform._rotation22;
  48941. __tmp__201 = _this2._invInertia20 * _this2._transform._rotation00 + _this2._invInertia21 * _this2._transform._rotation01 + _this2._invInertia22 * _this2._transform._rotation02;
  48942. __tmp__211 = _this2._invInertia20 * _this2._transform._rotation10 + _this2._invInertia21 * _this2._transform._rotation11 + _this2._invInertia22 * _this2._transform._rotation12;
  48943. __tmp__221 = _this2._invInertia20 * _this2._transform._rotation20 + _this2._invInertia21 * _this2._transform._rotation21 + _this2._invInertia22 * _this2._transform._rotation22;
  48944. _this2._invInertia00 = __tmp__001;
  48945. _this2._invInertia01 = __tmp__011;
  48946. _this2._invInertia02 = __tmp__021;
  48947. _this2._invInertia10 = __tmp__101;
  48948. _this2._invInertia11 = __tmp__111;
  48949. _this2._invInertia12 = __tmp__121;
  48950. _this2._invInertia20 = __tmp__201;
  48951. _this2._invInertia21 = __tmp__211;
  48952. _this2._invInertia22 = __tmp__221;
  48953. _this2._invInertia00 *= _this2._rotFactor.x;
  48954. _this2._invInertia01 *= _this2._rotFactor.x;
  48955. _this2._invInertia02 *= _this2._rotFactor.x;
  48956. _this2._invInertia10 *= _this2._rotFactor.y;
  48957. _this2._invInertia11 *= _this2._rotFactor.y;
  48958. _this2._invInertia12 *= _this2._rotFactor.y;
  48959. _this2._invInertia20 *= _this2._rotFactor.z;
  48960. _this2._invInertia21 *= _this2._rotFactor.z;
  48961. _this2._invInertia22 *= _this2._rotFactor.z;
  48962. var _this3 = this._b2;
  48963. var theta1 = Math.sqrt(av2X * av2X + av2Y * av2Y + av2Z * av2Z);
  48964. var halfTheta1 = theta1 * 0.5;
  48965. var rotationToSinAxisFactor1;
  48966. var cosHalfTheta1;
  48967. if(halfTheta1 < 0.5) {
  48968. var ht21 = halfTheta1 * halfTheta1;
  48969. rotationToSinAxisFactor1 = 0.5 * (1 - ht21 * 0.166666666666666657 + ht21 * ht21 * 0.00833333333333333322);
  48970. cosHalfTheta1 = 1 - ht21 * 0.5 + ht21 * ht21 * 0.0416666666666666644;
  48971. } else {
  48972. rotationToSinAxisFactor1 = Math.sin(halfTheta1) / theta1;
  48973. cosHalfTheta1 = Math.cos(halfTheta1);
  48974. }
  48975. var sinAxis1;
  48976. var sinAxisX1;
  48977. var sinAxisY1;
  48978. var sinAxisZ1;
  48979. sinAxisX1 = av2X * rotationToSinAxisFactor1;
  48980. sinAxisY1 = av2Y * rotationToSinAxisFactor1;
  48981. sinAxisZ1 = av2Z * rotationToSinAxisFactor1;
  48982. var dq1;
  48983. var dqX1;
  48984. var dqY1;
  48985. var dqZ1;
  48986. var dqW1;
  48987. dqX1 = sinAxisX1;
  48988. dqY1 = sinAxisY1;
  48989. dqZ1 = sinAxisZ1;
  48990. dqW1 = cosHalfTheta1;
  48991. var q1;
  48992. var qX1;
  48993. var qY1;
  48994. var qZ1;
  48995. var qW1;
  48996. var e001 = _this3._transform._rotation00;
  48997. var e111 = _this3._transform._rotation11;
  48998. var e221 = _this3._transform._rotation22;
  48999. var t1 = e001 + e111 + e221;
  49000. var s1;
  49001. if(t1 > 0) {
  49002. s1 = Math.sqrt(t1 + 1);
  49003. qW1 = 0.5 * s1;
  49004. s1 = 0.5 / s1;
  49005. qX1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1;
  49006. qY1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1;
  49007. qZ1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1;
  49008. } else if(e001 > e111) {
  49009. if(e001 > e221) {
  49010. s1 = Math.sqrt(e001 - e111 - e221 + 1);
  49011. qX1 = 0.5 * s1;
  49012. s1 = 0.5 / s1;
  49013. qY1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1;
  49014. qZ1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1;
  49015. qW1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1;
  49016. } else {
  49017. s1 = Math.sqrt(e221 - e001 - e111 + 1);
  49018. qZ1 = 0.5 * s1;
  49019. s1 = 0.5 / s1;
  49020. qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1;
  49021. qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1;
  49022. qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1;
  49023. }
  49024. } else if(e111 > e221) {
  49025. s1 = Math.sqrt(e111 - e221 - e001 + 1);
  49026. qY1 = 0.5 * s1;
  49027. s1 = 0.5 / s1;
  49028. qX1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1;
  49029. qZ1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1;
  49030. qW1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1;
  49031. } else {
  49032. s1 = Math.sqrt(e221 - e001 - e111 + 1);
  49033. qZ1 = 0.5 * s1;
  49034. s1 = 0.5 / s1;
  49035. qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1;
  49036. qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1;
  49037. qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1;
  49038. }
  49039. qX1 = dqW1 * qX1 + dqX1 * qW1 + dqY1 * qZ1 - dqZ1 * qY1;
  49040. qY1 = dqW1 * qY1 - dqX1 * qZ1 + dqY1 * qW1 + dqZ1 * qX1;
  49041. qZ1 = dqW1 * qZ1 + dqX1 * qY1 - dqY1 * qX1 + dqZ1 * qW1;
  49042. qW1 = dqW1 * qW1 - dqX1 * qX1 - dqY1 * qY1 - dqZ1 * qZ1;
  49043. var l1 = qX1 * qX1 + qY1 * qY1 + qZ1 * qZ1 + qW1 * qW1;
  49044. if(l1 > 1e-32) {
  49045. l1 = 1 / Math.sqrt(l1);
  49046. }
  49047. qX1 *= l1;
  49048. qY1 *= l1;
  49049. qZ1 *= l1;
  49050. qW1 *= l1;
  49051. var x1 = qX1;
  49052. var y1 = qY1;
  49053. var z1 = qZ1;
  49054. var w1 = qW1;
  49055. var x21 = 2 * x1;
  49056. var y21 = 2 * y1;
  49057. var z21 = 2 * z1;
  49058. var xx1 = x1 * x21;
  49059. var yy1 = y1 * y21;
  49060. var zz1 = z1 * z21;
  49061. var xy1 = x1 * y21;
  49062. var yz1 = y1 * z21;
  49063. var xz1 = x1 * z21;
  49064. var wx1 = w1 * x21;
  49065. var wy1 = w1 * y21;
  49066. var wz1 = w1 * z21;
  49067. _this3._transform._rotation00 = 1 - yy1 - zz1;
  49068. _this3._transform._rotation01 = xy1 - wz1;
  49069. _this3._transform._rotation02 = xz1 + wy1;
  49070. _this3._transform._rotation10 = xy1 + wz1;
  49071. _this3._transform._rotation11 = 1 - xx1 - zz1;
  49072. _this3._transform._rotation12 = yz1 - wx1;
  49073. _this3._transform._rotation20 = xz1 - wy1;
  49074. _this3._transform._rotation21 = yz1 + wx1;
  49075. _this3._transform._rotation22 = 1 - xx1 - yy1;
  49076. var __tmp__002;
  49077. var __tmp__012;
  49078. var __tmp__022;
  49079. var __tmp__102;
  49080. var __tmp__112;
  49081. var __tmp__122;
  49082. var __tmp__202;
  49083. var __tmp__212;
  49084. var __tmp__222;
  49085. __tmp__002 = _this3._transform._rotation00 * _this3._invLocalInertia00 + _this3._transform._rotation01 * _this3._invLocalInertia10 + _this3._transform._rotation02 * _this3._invLocalInertia20;
  49086. __tmp__012 = _this3._transform._rotation00 * _this3._invLocalInertia01 + _this3._transform._rotation01 * _this3._invLocalInertia11 + _this3._transform._rotation02 * _this3._invLocalInertia21;
  49087. __tmp__022 = _this3._transform._rotation00 * _this3._invLocalInertia02 + _this3._transform._rotation01 * _this3._invLocalInertia12 + _this3._transform._rotation02 * _this3._invLocalInertia22;
  49088. __tmp__102 = _this3._transform._rotation10 * _this3._invLocalInertia00 + _this3._transform._rotation11 * _this3._invLocalInertia10 + _this3._transform._rotation12 * _this3._invLocalInertia20;
  49089. __tmp__112 = _this3._transform._rotation10 * _this3._invLocalInertia01 + _this3._transform._rotation11 * _this3._invLocalInertia11 + _this3._transform._rotation12 * _this3._invLocalInertia21;
  49090. __tmp__122 = _this3._transform._rotation10 * _this3._invLocalInertia02 + _this3._transform._rotation11 * _this3._invLocalInertia12 + _this3._transform._rotation12 * _this3._invLocalInertia22;
  49091. __tmp__202 = _this3._transform._rotation20 * _this3._invLocalInertia00 + _this3._transform._rotation21 * _this3._invLocalInertia10 + _this3._transform._rotation22 * _this3._invLocalInertia20;
  49092. __tmp__212 = _this3._transform._rotation20 * _this3._invLocalInertia01 + _this3._transform._rotation21 * _this3._invLocalInertia11 + _this3._transform._rotation22 * _this3._invLocalInertia21;
  49093. __tmp__222 = _this3._transform._rotation20 * _this3._invLocalInertia02 + _this3._transform._rotation21 * _this3._invLocalInertia12 + _this3._transform._rotation22 * _this3._invLocalInertia22;
  49094. _this3._invInertia00 = __tmp__002;
  49095. _this3._invInertia01 = __tmp__012;
  49096. _this3._invInertia02 = __tmp__022;
  49097. _this3._invInertia10 = __tmp__102;
  49098. _this3._invInertia11 = __tmp__112;
  49099. _this3._invInertia12 = __tmp__122;
  49100. _this3._invInertia20 = __tmp__202;
  49101. _this3._invInertia21 = __tmp__212;
  49102. _this3._invInertia22 = __tmp__222;
  49103. var __tmp__003;
  49104. var __tmp__013;
  49105. var __tmp__023;
  49106. var __tmp__103;
  49107. var __tmp__113;
  49108. var __tmp__123;
  49109. var __tmp__203;
  49110. var __tmp__213;
  49111. var __tmp__223;
  49112. __tmp__003 = _this3._invInertia00 * _this3._transform._rotation00 + _this3._invInertia01 * _this3._transform._rotation01 + _this3._invInertia02 * _this3._transform._rotation02;
  49113. __tmp__013 = _this3._invInertia00 * _this3._transform._rotation10 + _this3._invInertia01 * _this3._transform._rotation11 + _this3._invInertia02 * _this3._transform._rotation12;
  49114. __tmp__023 = _this3._invInertia00 * _this3._transform._rotation20 + _this3._invInertia01 * _this3._transform._rotation21 + _this3._invInertia02 * _this3._transform._rotation22;
  49115. __tmp__103 = _this3._invInertia10 * _this3._transform._rotation00 + _this3._invInertia11 * _this3._transform._rotation01 + _this3._invInertia12 * _this3._transform._rotation02;
  49116. __tmp__113 = _this3._invInertia10 * _this3._transform._rotation10 + _this3._invInertia11 * _this3._transform._rotation11 + _this3._invInertia12 * _this3._transform._rotation12;
  49117. __tmp__123 = _this3._invInertia10 * _this3._transform._rotation20 + _this3._invInertia11 * _this3._transform._rotation21 + _this3._invInertia12 * _this3._transform._rotation22;
  49118. __tmp__203 = _this3._invInertia20 * _this3._transform._rotation00 + _this3._invInertia21 * _this3._transform._rotation01 + _this3._invInertia22 * _this3._transform._rotation02;
  49119. __tmp__213 = _this3._invInertia20 * _this3._transform._rotation10 + _this3._invInertia21 * _this3._transform._rotation11 + _this3._invInertia22 * _this3._transform._rotation12;
  49120. __tmp__223 = _this3._invInertia20 * _this3._transform._rotation20 + _this3._invInertia21 * _this3._transform._rotation21 + _this3._invInertia22 * _this3._transform._rotation22;
  49121. _this3._invInertia00 = __tmp__003;
  49122. _this3._invInertia01 = __tmp__013;
  49123. _this3._invInertia02 = __tmp__023;
  49124. _this3._invInertia10 = __tmp__103;
  49125. _this3._invInertia11 = __tmp__113;
  49126. _this3._invInertia12 = __tmp__123;
  49127. _this3._invInertia20 = __tmp__203;
  49128. _this3._invInertia21 = __tmp__213;
  49129. _this3._invInertia22 = __tmp__223;
  49130. _this3._invInertia00 *= _this3._rotFactor.x;
  49131. _this3._invInertia01 *= _this3._rotFactor.x;
  49132. _this3._invInertia02 *= _this3._rotFactor.x;
  49133. _this3._invInertia10 *= _this3._rotFactor.y;
  49134. _this3._invInertia11 *= _this3._rotFactor.y;
  49135. _this3._invInertia12 *= _this3._rotFactor.y;
  49136. _this3._invInertia20 *= _this3._rotFactor.z;
  49137. _this3._invInertia21 *= _this3._rotFactor.z;
  49138. _this3._invInertia22 *= _this3._rotFactor.z;
  49139. }
  49140. postSolve() {
  49141. var lin1;
  49142. var lin1X;
  49143. var lin1Y;
  49144. var lin1Z;
  49145. var ang1;
  49146. var ang1X;
  49147. var ang1Y;
  49148. var ang1Z;
  49149. var ang2;
  49150. var ang2X;
  49151. var ang2Y;
  49152. var ang2Z;
  49153. lin1X = 0;
  49154. lin1Y = 0;
  49155. lin1Z = 0;
  49156. ang1X = 0;
  49157. ang1Y = 0;
  49158. ang1Z = 0;
  49159. ang2X = 0;
  49160. ang2Y = 0;
  49161. ang2Z = 0;
  49162. var _g = 0;
  49163. var _g1 = this.info.numRows;
  49164. while(_g < _g1) {
  49165. var i = _g++;
  49166. var row = this.info.rows[i];
  49167. var imp = row.impulse;
  49168. var jn = row.jacobianN;
  49169. var jt = row.jacobianT;
  49170. var jb = row.jacobianB;
  49171. var impN = imp.impulseN;
  49172. var impT = imp.impulseT;
  49173. var impB = imp.impulseB;
  49174. var impulseL;
  49175. var impulseLX;
  49176. var impulseLY;
  49177. var impulseLZ;
  49178. impulseLX = 0;
  49179. impulseLY = 0;
  49180. impulseLZ = 0;
  49181. impulseLX += jt.lin1X * impT;
  49182. impulseLY += jt.lin1Y * impT;
  49183. impulseLZ += jt.lin1Z * impT;
  49184. impulseLX += jb.lin1X * impB;
  49185. impulseLY += jb.lin1Y * impB;
  49186. impulseLZ += jb.lin1Z * impB;
  49187. imp.impulseLX = impulseLX;
  49188. imp.impulseLY = impulseLY;
  49189. imp.impulseLZ = impulseLZ;
  49190. lin1X += jn.lin1X * impN;
  49191. lin1Y += jn.lin1Y * impN;
  49192. lin1Z += jn.lin1Z * impN;
  49193. ang1X += jn.ang1X * impN;
  49194. ang1Y += jn.ang1Y * impN;
  49195. ang1Z += jn.ang1Z * impN;
  49196. ang2X += jn.ang2X * impN;
  49197. ang2Y += jn.ang2Y * impN;
  49198. ang2Z += jn.ang2Z * impN;
  49199. lin1X += jt.lin1X * impT;
  49200. lin1Y += jt.lin1Y * impT;
  49201. lin1Z += jt.lin1Z * impT;
  49202. ang1X += jt.ang1X * impT;
  49203. ang1Y += jt.ang1Y * impT;
  49204. ang1Z += jt.ang1Z * impT;
  49205. ang2X += jt.ang2X * impT;
  49206. ang2Y += jt.ang2Y * impT;
  49207. ang2Z += jt.ang2Z * impT;
  49208. lin1X += jb.lin1X * impB;
  49209. lin1Y += jb.lin1Y * impB;
  49210. lin1Z += jb.lin1Z * impB;
  49211. ang1X += jb.ang1X * impB;
  49212. ang1Y += jb.ang1Y * impB;
  49213. ang1Z += jb.ang1Z * impB;
  49214. ang2X += jb.ang2X * impB;
  49215. ang2Y += jb.ang2Y * impB;
  49216. ang2Z += jb.ang2Z * impB;
  49217. }
  49218. this._b1._linearContactImpulseX += lin1X;
  49219. this._b1._linearContactImpulseY += lin1Y;
  49220. this._b1._linearContactImpulseZ += lin1Z;
  49221. this._b1._angularContactImpulseX += ang1X;
  49222. this._b1._angularContactImpulseY += ang1Y;
  49223. this._b1._angularContactImpulseZ += ang1Z;
  49224. this._b2._linearContactImpulseX -= lin1X;
  49225. this._b2._linearContactImpulseY -= lin1Y;
  49226. this._b2._linearContactImpulseZ -= lin1Z;
  49227. this._b2._angularContactImpulseX -= ang2X;
  49228. this._b2._angularContactImpulseY -= ang2Y;
  49229. this._b2._angularContactImpulseZ -= ang2Z;
  49230. this.constraint._syncManifold();
  49231. }
  49232. }
  49233. oimo.dynamics.constraint.solver.pgs.PgsJointConstraintSolver = class oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver extends oimo.dynamics.constraint.ConstraintSolver {
  49234. constructor(joint) {
  49235. super();
  49236. this.joint = joint;
  49237. this.info = new oimo.dynamics.constraint.info.joint.JointSolverInfo();
  49238. var this1 = new Array(oimo.common.Setting.maxJacobianRows);
  49239. this.massData = this1;
  49240. var _g = 0;
  49241. var _g1 = this.massData.length;
  49242. while(_g < _g1) {
  49243. var i = _g++;
  49244. this.massData[i] = new oimo.dynamics.constraint.solver.common.JointSolverMassDataRow();
  49245. }
  49246. }
  49247. preSolveVelocity(timeStep) {
  49248. this.joint._syncAnchors();
  49249. this.joint._getVelocitySolverInfo(timeStep,this.info);
  49250. this._b1 = this.info.b1;
  49251. this._b2 = this.info.b2;
  49252. var invM1 = this._b1._invMass;
  49253. var invM2 = this._b2._invMass;
  49254. var invI1;
  49255. var invI100;
  49256. var invI101;
  49257. var invI102;
  49258. var invI110;
  49259. var invI111;
  49260. var invI112;
  49261. var invI120;
  49262. var invI121;
  49263. var invI122;
  49264. var invI2;
  49265. var invI200;
  49266. var invI201;
  49267. var invI202;
  49268. var invI210;
  49269. var invI211;
  49270. var invI212;
  49271. var invI220;
  49272. var invI221;
  49273. var invI222;
  49274. invI100 = this._b1._invInertia00;
  49275. invI101 = this._b1._invInertia01;
  49276. invI102 = this._b1._invInertia02;
  49277. invI110 = this._b1._invInertia10;
  49278. invI111 = this._b1._invInertia11;
  49279. invI112 = this._b1._invInertia12;
  49280. invI120 = this._b1._invInertia20;
  49281. invI121 = this._b1._invInertia21;
  49282. invI122 = this._b1._invInertia22;
  49283. invI200 = this._b2._invInertia00;
  49284. invI201 = this._b2._invInertia01;
  49285. invI202 = this._b2._invInertia02;
  49286. invI210 = this._b2._invInertia10;
  49287. invI211 = this._b2._invInertia11;
  49288. invI212 = this._b2._invInertia12;
  49289. invI220 = this._b2._invInertia20;
  49290. invI221 = this._b2._invInertia21;
  49291. invI222 = this._b2._invInertia22;
  49292. var _g = 0;
  49293. var _g1 = this.info.numRows;
  49294. while(_g < _g1) {
  49295. var i = _g++;
  49296. var row = this.info.rows[i];
  49297. var md = this.massData[i];
  49298. var j = row.jacobian;
  49299. j.updateSparsity();
  49300. if((j.flag & 1) != 0) {
  49301. md.invMLin1X = j.lin1X * invM1;
  49302. md.invMLin1Y = j.lin1Y * invM1;
  49303. md.invMLin1Z = j.lin1Z * invM1;
  49304. md.invMLin2X = j.lin2X * invM2;
  49305. md.invMLin2Y = j.lin2Y * invM2;
  49306. md.invMLin2Z = j.lin2Z * invM2;
  49307. } else {
  49308. md.invMLin1X = 0;
  49309. md.invMLin1Y = 0;
  49310. md.invMLin1Z = 0;
  49311. md.invMLin2X = 0;
  49312. md.invMLin2Y = 0;
  49313. md.invMLin2Z = 0;
  49314. }
  49315. if((j.flag & 2) != 0) {
  49316. var __tmp__X;
  49317. var __tmp__Y;
  49318. var __tmp__Z;
  49319. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  49320. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  49321. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  49322. md.invMAng1X = __tmp__X;
  49323. md.invMAng1Y = __tmp__Y;
  49324. md.invMAng1Z = __tmp__Z;
  49325. var __tmp__X1;
  49326. var __tmp__Y1;
  49327. var __tmp__Z1;
  49328. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  49329. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  49330. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  49331. md.invMAng2X = __tmp__X1;
  49332. md.invMAng2Y = __tmp__Y1;
  49333. md.invMAng2Z = __tmp__Z1;
  49334. } else {
  49335. md.invMAng1X = 0;
  49336. md.invMAng1Y = 0;
  49337. md.invMAng1Z = 0;
  49338. md.invMAng2X = 0;
  49339. md.invMAng2Y = 0;
  49340. md.invMAng2Z = 0;
  49341. }
  49342. md.massWithoutCfm = md.invMLin1X * j.lin1X + md.invMLin1Y * j.lin1Y + md.invMLin1Z * j.lin1Z + (md.invMLin2X * j.lin2X + md.invMLin2Y * j.lin2Y + md.invMLin2Z * j.lin2Z) + (md.invMAng1X * j.ang1X + md.invMAng1Y * j.ang1Y + md.invMAng1Z * j.ang1Z) + (md.invMAng2X * j.ang2X + md.invMAng2Y * j.ang2Y + md.invMAng2Z * j.ang2Z);
  49343. md.mass = md.massWithoutCfm + row.cfm;
  49344. if(md.massWithoutCfm != 0) {
  49345. md.massWithoutCfm = 1 / md.massWithoutCfm;
  49346. }
  49347. if(md.mass != 0) {
  49348. md.mass = 1 / md.mass;
  49349. }
  49350. }
  49351. }
  49352. warmStart(timeStep) {
  49353. var factor = this.joint._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE ? oimo.common.Setting.jointWarmStartingFactorForBaungarte : oimo.common.Setting.jointWarmStartingFactor;
  49354. factor *= timeStep.dtRatio;
  49355. if(factor <= 0) {
  49356. var _g = 0;
  49357. var _g1 = this.info.numRows;
  49358. while(_g < _g1) {
  49359. var i = _g++;
  49360. var row = this.info.rows[i];
  49361. var _this = row.impulse;
  49362. _this.impulse = 0;
  49363. _this.impulseM = 0;
  49364. _this.impulseP = 0;
  49365. }
  49366. return;
  49367. }
  49368. var lv1;
  49369. var lv1X;
  49370. var lv1Y;
  49371. var lv1Z;
  49372. var lv2;
  49373. var lv2X;
  49374. var lv2Y;
  49375. var lv2Z;
  49376. var av1;
  49377. var av1X;
  49378. var av1Y;
  49379. var av1Z;
  49380. var av2;
  49381. var av2X;
  49382. var av2Y;
  49383. var av2Z;
  49384. lv1X = this._b1._velX;
  49385. lv1Y = this._b1._velY;
  49386. lv1Z = this._b1._velZ;
  49387. lv2X = this._b2._velX;
  49388. lv2Y = this._b2._velY;
  49389. lv2Z = this._b2._velZ;
  49390. av1X = this._b1._angVelX;
  49391. av1Y = this._b1._angVelY;
  49392. av1Z = this._b1._angVelZ;
  49393. av2X = this._b2._angVelX;
  49394. av2Y = this._b2._angVelY;
  49395. av2Z = this._b2._angVelZ;
  49396. var _g2 = 0;
  49397. var _g11 = this.info.numRows;
  49398. while(_g2 < _g11) {
  49399. var i1 = _g2++;
  49400. var row1 = this.info.rows[i1];
  49401. var md = this.massData[i1];
  49402. var imp = row1.impulse;
  49403. var j = row1.jacobian;
  49404. imp.impulse *= factor;
  49405. imp.impulseM *= factor;
  49406. var impulse = imp.impulse + imp.impulseM;
  49407. lv1X += md.invMLin1X * impulse;
  49408. lv1Y += md.invMLin1Y * impulse;
  49409. lv1Z += md.invMLin1Z * impulse;
  49410. lv2X += md.invMLin2X * -impulse;
  49411. lv2Y += md.invMLin2Y * -impulse;
  49412. lv2Z += md.invMLin2Z * -impulse;
  49413. av1X += md.invMAng1X * impulse;
  49414. av1Y += md.invMAng1Y * impulse;
  49415. av1Z += md.invMAng1Z * impulse;
  49416. av2X += md.invMAng2X * -impulse;
  49417. av2Y += md.invMAng2Y * -impulse;
  49418. av2Z += md.invMAng2Z * -impulse;
  49419. }
  49420. this._b1._velX = lv1X;
  49421. this._b1._velY = lv1Y;
  49422. this._b1._velZ = lv1Z;
  49423. this._b2._velX = lv2X;
  49424. this._b2._velY = lv2Y;
  49425. this._b2._velZ = lv2Z;
  49426. this._b1._angVelX = av1X;
  49427. this._b1._angVelY = av1Y;
  49428. this._b1._angVelZ = av1Z;
  49429. this._b2._angVelX = av2X;
  49430. this._b2._angVelY = av2Y;
  49431. this._b2._angVelZ = av2Z;
  49432. }
  49433. solveVelocity() {
  49434. var lv1;
  49435. var lv1X;
  49436. var lv1Y;
  49437. var lv1Z;
  49438. var lv2;
  49439. var lv2X;
  49440. var lv2Y;
  49441. var lv2Z;
  49442. var av1;
  49443. var av1X;
  49444. var av1Y;
  49445. var av1Z;
  49446. var av2;
  49447. var av2X;
  49448. var av2Y;
  49449. var av2Z;
  49450. lv1X = this._b1._velX;
  49451. lv1Y = this._b1._velY;
  49452. lv1Z = this._b1._velZ;
  49453. lv2X = this._b2._velX;
  49454. lv2Y = this._b2._velY;
  49455. lv2Z = this._b2._velZ;
  49456. av1X = this._b1._angVelX;
  49457. av1Y = this._b1._angVelY;
  49458. av1Z = this._b1._angVelZ;
  49459. av2X = this._b2._angVelX;
  49460. av2Y = this._b2._angVelY;
  49461. av2Z = this._b2._angVelZ;
  49462. var _g = 0;
  49463. var _g1 = this.info.numRows;
  49464. while(_g < _g1) {
  49465. var i = _g++;
  49466. var row = this.info.rows[i];
  49467. var md = this.massData[i];
  49468. var imp = row.impulse;
  49469. var j = row.jacobian;
  49470. if(row.motorMaxImpulse == 0) {
  49471. continue;
  49472. }
  49473. var rv = 0;
  49474. rv += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  49475. rv -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  49476. rv += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  49477. rv -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  49478. var impulseM = (-row.motorSpeed - rv) * md.massWithoutCfm;
  49479. var oldImpulseM = imp.impulseM;
  49480. imp.impulseM += impulseM;
  49481. if(imp.impulseM < -row.motorMaxImpulse) {
  49482. imp.impulseM = -row.motorMaxImpulse;
  49483. } else if(imp.impulseM > row.motorMaxImpulse) {
  49484. imp.impulseM = row.motorMaxImpulse;
  49485. }
  49486. impulseM = imp.impulseM - oldImpulseM;
  49487. if((j.flag & 1) != 0) {
  49488. lv1X += md.invMLin1X * impulseM;
  49489. lv1Y += md.invMLin1Y * impulseM;
  49490. lv1Z += md.invMLin1Z * impulseM;
  49491. lv2X += md.invMLin2X * -impulseM;
  49492. lv2Y += md.invMLin2Y * -impulseM;
  49493. lv2Z += md.invMLin2Z * -impulseM;
  49494. }
  49495. if((j.flag & 2) != 0) {
  49496. av1X += md.invMAng1X * impulseM;
  49497. av1Y += md.invMAng1Y * impulseM;
  49498. av1Z += md.invMAng1Z * impulseM;
  49499. av2X += md.invMAng2X * -impulseM;
  49500. av2Y += md.invMAng2Y * -impulseM;
  49501. av2Z += md.invMAng2Z * -impulseM;
  49502. }
  49503. }
  49504. var _g2 = 0;
  49505. var _g3 = this.info.numRows;
  49506. while(_g2 < _g3) {
  49507. var i1 = _g2++;
  49508. var row1 = this.info.rows[i1];
  49509. var md1 = this.massData[i1];
  49510. var imp1 = row1.impulse;
  49511. var j1 = row1.jacobian;
  49512. var rv1 = 0;
  49513. rv1 += lv1X * j1.lin1X + lv1Y * j1.lin1Y + lv1Z * j1.lin1Z;
  49514. rv1 -= lv2X * j1.lin2X + lv2Y * j1.lin2Y + lv2Z * j1.lin2Z;
  49515. rv1 += av1X * j1.ang1X + av1Y * j1.ang1Y + av1Z * j1.ang1Z;
  49516. rv1 -= av2X * j1.ang2X + av2Y * j1.ang2Y + av2Z * j1.ang2Z;
  49517. var impulse = (row1.rhs - rv1 - imp1.impulse * row1.cfm) * md1.mass;
  49518. var oldImpulse = imp1.impulse;
  49519. imp1.impulse += impulse;
  49520. if(imp1.impulse < row1.minImpulse) {
  49521. imp1.impulse = row1.minImpulse;
  49522. } else if(imp1.impulse > row1.maxImpulse) {
  49523. imp1.impulse = row1.maxImpulse;
  49524. }
  49525. impulse = imp1.impulse - oldImpulse;
  49526. if((j1.flag & 1) != 0) {
  49527. lv1X += md1.invMLin1X * impulse;
  49528. lv1Y += md1.invMLin1Y * impulse;
  49529. lv1Z += md1.invMLin1Z * impulse;
  49530. lv2X += md1.invMLin2X * -impulse;
  49531. lv2Y += md1.invMLin2Y * -impulse;
  49532. lv2Z += md1.invMLin2Z * -impulse;
  49533. }
  49534. if((j1.flag & 2) != 0) {
  49535. av1X += md1.invMAng1X * impulse;
  49536. av1Y += md1.invMAng1Y * impulse;
  49537. av1Z += md1.invMAng1Z * impulse;
  49538. av2X += md1.invMAng2X * -impulse;
  49539. av2Y += md1.invMAng2Y * -impulse;
  49540. av2Z += md1.invMAng2Z * -impulse;
  49541. }
  49542. }
  49543. this._b1._velX = lv1X;
  49544. this._b1._velY = lv1Y;
  49545. this._b1._velZ = lv1Z;
  49546. this._b2._velX = lv2X;
  49547. this._b2._velY = lv2Y;
  49548. this._b2._velZ = lv2Z;
  49549. this._b1._angVelX = av1X;
  49550. this._b1._angVelY = av1Y;
  49551. this._b1._angVelZ = av1Z;
  49552. this._b2._angVelX = av2X;
  49553. this._b2._angVelY = av2Y;
  49554. this._b2._angVelZ = av2Z;
  49555. }
  49556. postSolveVelocity(timeStep) {
  49557. var lin;
  49558. var linX;
  49559. var linY;
  49560. var linZ;
  49561. var ang;
  49562. var angX;
  49563. var angY;
  49564. var angZ;
  49565. linX = 0;
  49566. linY = 0;
  49567. linZ = 0;
  49568. angX = 0;
  49569. angY = 0;
  49570. angZ = 0;
  49571. var _g = 0;
  49572. var _g1 = this.info.numRows;
  49573. while(_g < _g1) {
  49574. var i = _g++;
  49575. var row = this.info.rows[i];
  49576. var imp = row.impulse;
  49577. var j = row.jacobian;
  49578. if((j.flag & 1) != 0) {
  49579. linX += j.lin1X * imp.impulse;
  49580. linY += j.lin1Y * imp.impulse;
  49581. linZ += j.lin1Z * imp.impulse;
  49582. } else if((j.flag & 2) != 0) {
  49583. angX += j.ang1X * imp.impulse;
  49584. angY += j.ang1Y * imp.impulse;
  49585. angZ += j.ang1Z * imp.impulse;
  49586. }
  49587. }
  49588. this.joint._appliedForceX = linX * timeStep.invDt;
  49589. this.joint._appliedForceY = linY * timeStep.invDt;
  49590. this.joint._appliedForceZ = linZ * timeStep.invDt;
  49591. this.joint._appliedTorqueX = angX * timeStep.invDt;
  49592. this.joint._appliedTorqueY = angY * timeStep.invDt;
  49593. this.joint._appliedTorqueZ = angZ * timeStep.invDt;
  49594. }
  49595. preSolvePosition(timeStep) {
  49596. this.joint._syncAnchors();
  49597. this.joint._getPositionSolverInfo(this.info);
  49598. this._b1 = this.info.b1;
  49599. this._b2 = this.info.b2;
  49600. var invM1 = this._b1._invMass;
  49601. var invM2 = this._b2._invMass;
  49602. var invI1;
  49603. var invI100;
  49604. var invI101;
  49605. var invI102;
  49606. var invI110;
  49607. var invI111;
  49608. var invI112;
  49609. var invI120;
  49610. var invI121;
  49611. var invI122;
  49612. var invI2;
  49613. var invI200;
  49614. var invI201;
  49615. var invI202;
  49616. var invI210;
  49617. var invI211;
  49618. var invI212;
  49619. var invI220;
  49620. var invI221;
  49621. var invI222;
  49622. invI100 = this._b1._invInertia00;
  49623. invI101 = this._b1._invInertia01;
  49624. invI102 = this._b1._invInertia02;
  49625. invI110 = this._b1._invInertia10;
  49626. invI111 = this._b1._invInertia11;
  49627. invI112 = this._b1._invInertia12;
  49628. invI120 = this._b1._invInertia20;
  49629. invI121 = this._b1._invInertia21;
  49630. invI122 = this._b1._invInertia22;
  49631. invI200 = this._b2._invInertia00;
  49632. invI201 = this._b2._invInertia01;
  49633. invI202 = this._b2._invInertia02;
  49634. invI210 = this._b2._invInertia10;
  49635. invI211 = this._b2._invInertia11;
  49636. invI212 = this._b2._invInertia12;
  49637. invI220 = this._b2._invInertia20;
  49638. invI221 = this._b2._invInertia21;
  49639. invI222 = this._b2._invInertia22;
  49640. var _g = 0;
  49641. var _g1 = this.info.numRows;
  49642. while(_g < _g1) {
  49643. var i = _g++;
  49644. var row = this.info.rows[i];
  49645. var md = this.massData[i];
  49646. var imp = row.impulse;
  49647. var j = row.jacobian;
  49648. md.invMLin1X = j.lin1X * invM1;
  49649. md.invMLin1Y = j.lin1Y * invM1;
  49650. md.invMLin1Z = j.lin1Z * invM1;
  49651. md.invMLin2X = j.lin2X * invM2;
  49652. md.invMLin2Y = j.lin2Y * invM2;
  49653. md.invMLin2Z = j.lin2Z * invM2;
  49654. var __tmp__X;
  49655. var __tmp__Y;
  49656. var __tmp__Z;
  49657. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  49658. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  49659. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  49660. md.invMAng1X = __tmp__X;
  49661. md.invMAng1Y = __tmp__Y;
  49662. md.invMAng1Z = __tmp__Z;
  49663. var __tmp__X1;
  49664. var __tmp__Y1;
  49665. var __tmp__Z1;
  49666. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  49667. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  49668. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  49669. md.invMAng2X = __tmp__X1;
  49670. md.invMAng2Y = __tmp__Y1;
  49671. md.invMAng2Z = __tmp__Z1;
  49672. md.mass = md.invMLin1X * j.lin1X + md.invMLin1Y * j.lin1Y + md.invMLin1Z * j.lin1Z + (md.invMLin2X * j.lin2X + md.invMLin2Y * j.lin2Y + md.invMLin2Z * j.lin2Z) + (md.invMAng1X * j.ang1X + md.invMAng1Y * j.ang1Y + md.invMAng1Z * j.ang1Z) + (md.invMAng2X * j.ang2X + md.invMAng2Y * j.ang2Y + md.invMAng2Z * j.ang2Z);
  49673. if(md.mass != 0) {
  49674. md.mass = 1 / md.mass;
  49675. }
  49676. }
  49677. var _g2 = 0;
  49678. var _g11 = this.info.numRows;
  49679. while(_g2 < _g11) {
  49680. var i1 = _g2++;
  49681. this.info.rows[i1].impulse.impulseP = 0;
  49682. }
  49683. }
  49684. solvePositionSplitImpulse() {
  49685. var lv1;
  49686. var lv1X;
  49687. var lv1Y;
  49688. var lv1Z;
  49689. var lv2;
  49690. var lv2X;
  49691. var lv2Y;
  49692. var lv2Z;
  49693. var av1;
  49694. var av1X;
  49695. var av1Y;
  49696. var av1Z;
  49697. var av2;
  49698. var av2X;
  49699. var av2Y;
  49700. var av2Z;
  49701. lv1X = this._b1._pseudoVelX;
  49702. lv1Y = this._b1._pseudoVelY;
  49703. lv1Z = this._b1._pseudoVelZ;
  49704. lv2X = this._b2._pseudoVelX;
  49705. lv2Y = this._b2._pseudoVelY;
  49706. lv2Z = this._b2._pseudoVelZ;
  49707. av1X = this._b1._angPseudoVelX;
  49708. av1Y = this._b1._angPseudoVelY;
  49709. av1Z = this._b1._angPseudoVelZ;
  49710. av2X = this._b2._angPseudoVelX;
  49711. av2Y = this._b2._angPseudoVelY;
  49712. av2Z = this._b2._angPseudoVelZ;
  49713. var _g = 0;
  49714. var _g1 = this.info.numRows;
  49715. while(_g < _g1) {
  49716. var i = _g++;
  49717. var row = this.info.rows[i];
  49718. var md = this.massData[i];
  49719. var imp = row.impulse;
  49720. var j = row.jacobian;
  49721. var rv = 0;
  49722. rv += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z;
  49723. rv -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z;
  49724. rv += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z;
  49725. rv -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z;
  49726. var impulseP = (row.rhs * oimo.common.Setting.positionSplitImpulseBaumgarte - rv) * md.mass;
  49727. var oldImpulseP = imp.impulseP;
  49728. imp.impulseP += impulseP;
  49729. if(imp.impulseP < row.minImpulse) {
  49730. imp.impulseP = row.minImpulse;
  49731. } else if(imp.impulseP > row.maxImpulse) {
  49732. imp.impulseP = row.maxImpulse;
  49733. }
  49734. impulseP = imp.impulseP - oldImpulseP;
  49735. lv1X += md.invMLin1X * impulseP;
  49736. lv1Y += md.invMLin1Y * impulseP;
  49737. lv1Z += md.invMLin1Z * impulseP;
  49738. lv2X += md.invMLin2X * -impulseP;
  49739. lv2Y += md.invMLin2Y * -impulseP;
  49740. lv2Z += md.invMLin2Z * -impulseP;
  49741. av1X += md.invMAng1X * impulseP;
  49742. av1Y += md.invMAng1Y * impulseP;
  49743. av1Z += md.invMAng1Z * impulseP;
  49744. av2X += md.invMAng2X * -impulseP;
  49745. av2Y += md.invMAng2Y * -impulseP;
  49746. av2Z += md.invMAng2Z * -impulseP;
  49747. }
  49748. this._b1._pseudoVelX = lv1X;
  49749. this._b1._pseudoVelY = lv1Y;
  49750. this._b1._pseudoVelZ = lv1Z;
  49751. this._b2._pseudoVelX = lv2X;
  49752. this._b2._pseudoVelY = lv2Y;
  49753. this._b2._pseudoVelZ = lv2Z;
  49754. this._b1._angPseudoVelX = av1X;
  49755. this._b1._angPseudoVelY = av1Y;
  49756. this._b1._angPseudoVelZ = av1Z;
  49757. this._b2._angPseudoVelX = av2X;
  49758. this._b2._angPseudoVelY = av2Y;
  49759. this._b2._angPseudoVelZ = av2Z;
  49760. }
  49761. solvePositionNgs(timeStep) {
  49762. this.joint._syncAnchors();
  49763. this.joint._getPositionSolverInfo(this.info);
  49764. this._b1 = this.info.b1;
  49765. this._b2 = this.info.b2;
  49766. var invM1 = this._b1._invMass;
  49767. var invM2 = this._b2._invMass;
  49768. var invI1;
  49769. var invI100;
  49770. var invI101;
  49771. var invI102;
  49772. var invI110;
  49773. var invI111;
  49774. var invI112;
  49775. var invI120;
  49776. var invI121;
  49777. var invI122;
  49778. var invI2;
  49779. var invI200;
  49780. var invI201;
  49781. var invI202;
  49782. var invI210;
  49783. var invI211;
  49784. var invI212;
  49785. var invI220;
  49786. var invI221;
  49787. var invI222;
  49788. invI100 = this._b1._invInertia00;
  49789. invI101 = this._b1._invInertia01;
  49790. invI102 = this._b1._invInertia02;
  49791. invI110 = this._b1._invInertia10;
  49792. invI111 = this._b1._invInertia11;
  49793. invI112 = this._b1._invInertia12;
  49794. invI120 = this._b1._invInertia20;
  49795. invI121 = this._b1._invInertia21;
  49796. invI122 = this._b1._invInertia22;
  49797. invI200 = this._b2._invInertia00;
  49798. invI201 = this._b2._invInertia01;
  49799. invI202 = this._b2._invInertia02;
  49800. invI210 = this._b2._invInertia10;
  49801. invI211 = this._b2._invInertia11;
  49802. invI212 = this._b2._invInertia12;
  49803. invI220 = this._b2._invInertia20;
  49804. invI221 = this._b2._invInertia21;
  49805. invI222 = this._b2._invInertia22;
  49806. var _g = 0;
  49807. var _g1 = this.info.numRows;
  49808. while(_g < _g1) {
  49809. var i = _g++;
  49810. var row = this.info.rows[i];
  49811. var md = this.massData[i];
  49812. var imp = row.impulse;
  49813. var j = row.jacobian;
  49814. md.invMLin1X = j.lin1X * invM1;
  49815. md.invMLin1Y = j.lin1Y * invM1;
  49816. md.invMLin1Z = j.lin1Z * invM1;
  49817. md.invMLin2X = j.lin2X * invM2;
  49818. md.invMLin2Y = j.lin2Y * invM2;
  49819. md.invMLin2Z = j.lin2Z * invM2;
  49820. var __tmp__X;
  49821. var __tmp__Y;
  49822. var __tmp__Z;
  49823. __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z;
  49824. __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z;
  49825. __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z;
  49826. md.invMAng1X = __tmp__X;
  49827. md.invMAng1Y = __tmp__Y;
  49828. md.invMAng1Z = __tmp__Z;
  49829. var __tmp__X1;
  49830. var __tmp__Y1;
  49831. var __tmp__Z1;
  49832. __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z;
  49833. __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z;
  49834. __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z;
  49835. md.invMAng2X = __tmp__X1;
  49836. md.invMAng2Y = __tmp__Y1;
  49837. md.invMAng2Z = __tmp__Z1;
  49838. md.mass = md.invMLin1X * j.lin1X + md.invMLin1Y * j.lin1Y + md.invMLin1Z * j.lin1Z + (md.invMLin2X * j.lin2X + md.invMLin2Y * j.lin2Y + md.invMLin2Z * j.lin2Z) + (md.invMAng1X * j.ang1X + md.invMAng1Y * j.ang1Y + md.invMAng1Z * j.ang1Z) + (md.invMAng2X * j.ang2X + md.invMAng2Y * j.ang2Y + md.invMAng2Z * j.ang2Z);
  49839. if(md.mass != 0) {
  49840. md.mass = 1 / md.mass;
  49841. }
  49842. }
  49843. var lv1;
  49844. var lv1X;
  49845. var lv1Y;
  49846. var lv1Z;
  49847. var lv2;
  49848. var lv2X;
  49849. var lv2Y;
  49850. var lv2Z;
  49851. var av1;
  49852. var av1X;
  49853. var av1Y;
  49854. var av1Z;
  49855. var av2;
  49856. var av2X;
  49857. var av2Y;
  49858. var av2Z;
  49859. lv1X = 0;
  49860. lv1Y = 0;
  49861. lv1Z = 0;
  49862. lv2X = 0;
  49863. lv2Y = 0;
  49864. lv2Z = 0;
  49865. av1X = 0;
  49866. av1Y = 0;
  49867. av1Z = 0;
  49868. av2X = 0;
  49869. av2Y = 0;
  49870. av2Z = 0;
  49871. var _g2 = 0;
  49872. var _g11 = this.info.numRows;
  49873. while(_g2 < _g11) {
  49874. var i1 = _g2++;
  49875. var row1 = this.info.rows[i1];
  49876. var md1 = this.massData[i1];
  49877. var imp1 = row1.impulse;
  49878. var j1 = row1.jacobian;
  49879. var rv = 0;
  49880. rv += lv1X * j1.lin1X + lv1Y * j1.lin1Y + lv1Z * j1.lin1Z;
  49881. rv -= lv2X * j1.lin2X + lv2Y * j1.lin2Y + lv2Z * j1.lin2Z;
  49882. rv += av1X * j1.ang1X + av1Y * j1.ang1Y + av1Z * j1.ang1Z;
  49883. rv -= av2X * j1.ang2X + av2Y * j1.ang2Y + av2Z * j1.ang2Z;
  49884. var impulseP = (row1.rhs * oimo.common.Setting.positionNgsBaumgarte - rv) * md1.mass;
  49885. var oldImpulseP = imp1.impulseP;
  49886. imp1.impulseP += impulseP;
  49887. if(imp1.impulseP < row1.minImpulse) {
  49888. imp1.impulseP = row1.minImpulse;
  49889. } else if(imp1.impulseP > row1.maxImpulse) {
  49890. imp1.impulseP = row1.maxImpulse;
  49891. }
  49892. impulseP = imp1.impulseP - oldImpulseP;
  49893. lv1X += md1.invMLin1X * impulseP;
  49894. lv1Y += md1.invMLin1Y * impulseP;
  49895. lv1Z += md1.invMLin1Z * impulseP;
  49896. lv2X += md1.invMLin2X * -impulseP;
  49897. lv2Y += md1.invMLin2Y * -impulseP;
  49898. lv2Z += md1.invMLin2Z * -impulseP;
  49899. av1X += md1.invMAng1X * impulseP;
  49900. av1Y += md1.invMAng1Y * impulseP;
  49901. av1Z += md1.invMAng1Z * impulseP;
  49902. av2X += md1.invMAng2X * -impulseP;
  49903. av2Y += md1.invMAng2Y * -impulseP;
  49904. av2Z += md1.invMAng2Z * -impulseP;
  49905. }
  49906. var _this = this._b1;
  49907. _this._transform._positionX += lv1X;
  49908. _this._transform._positionY += lv1Y;
  49909. _this._transform._positionZ += lv1Z;
  49910. var _this1 = this._b2;
  49911. _this1._transform._positionX += lv2X;
  49912. _this1._transform._positionY += lv2Y;
  49913. _this1._transform._positionZ += lv2Z;
  49914. var _this2 = this._b1;
  49915. var theta = Math.sqrt(av1X * av1X + av1Y * av1Y + av1Z * av1Z);
  49916. var halfTheta = theta * 0.5;
  49917. var rotationToSinAxisFactor;
  49918. var cosHalfTheta;
  49919. if(halfTheta < 0.5) {
  49920. var ht2 = halfTheta * halfTheta;
  49921. rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.166666666666666657 + ht2 * ht2 * 0.00833333333333333322);
  49922. cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.0416666666666666644;
  49923. } else {
  49924. rotationToSinAxisFactor = Math.sin(halfTheta) / theta;
  49925. cosHalfTheta = Math.cos(halfTheta);
  49926. }
  49927. var sinAxis;
  49928. var sinAxisX;
  49929. var sinAxisY;
  49930. var sinAxisZ;
  49931. sinAxisX = av1X * rotationToSinAxisFactor;
  49932. sinAxisY = av1Y * rotationToSinAxisFactor;
  49933. sinAxisZ = av1Z * rotationToSinAxisFactor;
  49934. var dq;
  49935. var dqX;
  49936. var dqY;
  49937. var dqZ;
  49938. var dqW;
  49939. dqX = sinAxisX;
  49940. dqY = sinAxisY;
  49941. dqZ = sinAxisZ;
  49942. dqW = cosHalfTheta;
  49943. var q;
  49944. var qX;
  49945. var qY;
  49946. var qZ;
  49947. var qW;
  49948. var e00 = _this2._transform._rotation00;
  49949. var e11 = _this2._transform._rotation11;
  49950. var e22 = _this2._transform._rotation22;
  49951. var t = e00 + e11 + e22;
  49952. var s;
  49953. if(t > 0) {
  49954. s = Math.sqrt(t + 1);
  49955. qW = 0.5 * s;
  49956. s = 0.5 / s;
  49957. qX = (_this2._transform._rotation21 - _this2._transform._rotation12) * s;
  49958. qY = (_this2._transform._rotation02 - _this2._transform._rotation20) * s;
  49959. qZ = (_this2._transform._rotation10 - _this2._transform._rotation01) * s;
  49960. } else if(e00 > e11) {
  49961. if(e00 > e22) {
  49962. s = Math.sqrt(e00 - e11 - e22 + 1);
  49963. qX = 0.5 * s;
  49964. s = 0.5 / s;
  49965. qY = (_this2._transform._rotation01 + _this2._transform._rotation10) * s;
  49966. qZ = (_this2._transform._rotation02 + _this2._transform._rotation20) * s;
  49967. qW = (_this2._transform._rotation21 - _this2._transform._rotation12) * s;
  49968. } else {
  49969. s = Math.sqrt(e22 - e00 - e11 + 1);
  49970. qZ = 0.5 * s;
  49971. s = 0.5 / s;
  49972. qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s;
  49973. qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s;
  49974. qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s;
  49975. }
  49976. } else if(e11 > e22) {
  49977. s = Math.sqrt(e11 - e22 - e00 + 1);
  49978. qY = 0.5 * s;
  49979. s = 0.5 / s;
  49980. qX = (_this2._transform._rotation01 + _this2._transform._rotation10) * s;
  49981. qZ = (_this2._transform._rotation12 + _this2._transform._rotation21) * s;
  49982. qW = (_this2._transform._rotation02 - _this2._transform._rotation20) * s;
  49983. } else {
  49984. s = Math.sqrt(e22 - e00 - e11 + 1);
  49985. qZ = 0.5 * s;
  49986. s = 0.5 / s;
  49987. qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s;
  49988. qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s;
  49989. qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s;
  49990. }
  49991. qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY;
  49992. qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX;
  49993. qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW;
  49994. qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ;
  49995. var l = qX * qX + qY * qY + qZ * qZ + qW * qW;
  49996. if(l > 1e-32) {
  49997. l = 1 / Math.sqrt(l);
  49998. }
  49999. qX *= l;
  50000. qY *= l;
  50001. qZ *= l;
  50002. qW *= l;
  50003. var x = qX;
  50004. var y = qY;
  50005. var z = qZ;
  50006. var w = qW;
  50007. var x2 = 2 * x;
  50008. var y2 = 2 * y;
  50009. var z2 = 2 * z;
  50010. var xx = x * x2;
  50011. var yy = y * y2;
  50012. var zz = z * z2;
  50013. var xy = x * y2;
  50014. var yz = y * z2;
  50015. var xz = x * z2;
  50016. var wx = w * x2;
  50017. var wy = w * y2;
  50018. var wz = w * z2;
  50019. _this2._transform._rotation00 = 1 - yy - zz;
  50020. _this2._transform._rotation01 = xy - wz;
  50021. _this2._transform._rotation02 = xz + wy;
  50022. _this2._transform._rotation10 = xy + wz;
  50023. _this2._transform._rotation11 = 1 - xx - zz;
  50024. _this2._transform._rotation12 = yz - wx;
  50025. _this2._transform._rotation20 = xz - wy;
  50026. _this2._transform._rotation21 = yz + wx;
  50027. _this2._transform._rotation22 = 1 - xx - yy;
  50028. var __tmp__00;
  50029. var __tmp__01;
  50030. var __tmp__02;
  50031. var __tmp__10;
  50032. var __tmp__11;
  50033. var __tmp__12;
  50034. var __tmp__20;
  50035. var __tmp__21;
  50036. var __tmp__22;
  50037. __tmp__00 = _this2._transform._rotation00 * _this2._invLocalInertia00 + _this2._transform._rotation01 * _this2._invLocalInertia10 + _this2._transform._rotation02 * _this2._invLocalInertia20;
  50038. __tmp__01 = _this2._transform._rotation00 * _this2._invLocalInertia01 + _this2._transform._rotation01 * _this2._invLocalInertia11 + _this2._transform._rotation02 * _this2._invLocalInertia21;
  50039. __tmp__02 = _this2._transform._rotation00 * _this2._invLocalInertia02 + _this2._transform._rotation01 * _this2._invLocalInertia12 + _this2._transform._rotation02 * _this2._invLocalInertia22;
  50040. __tmp__10 = _this2._transform._rotation10 * _this2._invLocalInertia00 + _this2._transform._rotation11 * _this2._invLocalInertia10 + _this2._transform._rotation12 * _this2._invLocalInertia20;
  50041. __tmp__11 = _this2._transform._rotation10 * _this2._invLocalInertia01 + _this2._transform._rotation11 * _this2._invLocalInertia11 + _this2._transform._rotation12 * _this2._invLocalInertia21;
  50042. __tmp__12 = _this2._transform._rotation10 * _this2._invLocalInertia02 + _this2._transform._rotation11 * _this2._invLocalInertia12 + _this2._transform._rotation12 * _this2._invLocalInertia22;
  50043. __tmp__20 = _this2._transform._rotation20 * _this2._invLocalInertia00 + _this2._transform._rotation21 * _this2._invLocalInertia10 + _this2._transform._rotation22 * _this2._invLocalInertia20;
  50044. __tmp__21 = _this2._transform._rotation20 * _this2._invLocalInertia01 + _this2._transform._rotation21 * _this2._invLocalInertia11 + _this2._transform._rotation22 * _this2._invLocalInertia21;
  50045. __tmp__22 = _this2._transform._rotation20 * _this2._invLocalInertia02 + _this2._transform._rotation21 * _this2._invLocalInertia12 + _this2._transform._rotation22 * _this2._invLocalInertia22;
  50046. _this2._invInertia00 = __tmp__00;
  50047. _this2._invInertia01 = __tmp__01;
  50048. _this2._invInertia02 = __tmp__02;
  50049. _this2._invInertia10 = __tmp__10;
  50050. _this2._invInertia11 = __tmp__11;
  50051. _this2._invInertia12 = __tmp__12;
  50052. _this2._invInertia20 = __tmp__20;
  50053. _this2._invInertia21 = __tmp__21;
  50054. _this2._invInertia22 = __tmp__22;
  50055. var __tmp__001;
  50056. var __tmp__011;
  50057. var __tmp__021;
  50058. var __tmp__101;
  50059. var __tmp__111;
  50060. var __tmp__121;
  50061. var __tmp__201;
  50062. var __tmp__211;
  50063. var __tmp__221;
  50064. __tmp__001 = _this2._invInertia00 * _this2._transform._rotation00 + _this2._invInertia01 * _this2._transform._rotation01 + _this2._invInertia02 * _this2._transform._rotation02;
  50065. __tmp__011 = _this2._invInertia00 * _this2._transform._rotation10 + _this2._invInertia01 * _this2._transform._rotation11 + _this2._invInertia02 * _this2._transform._rotation12;
  50066. __tmp__021 = _this2._invInertia00 * _this2._transform._rotation20 + _this2._invInertia01 * _this2._transform._rotation21 + _this2._invInertia02 * _this2._transform._rotation22;
  50067. __tmp__101 = _this2._invInertia10 * _this2._transform._rotation00 + _this2._invInertia11 * _this2._transform._rotation01 + _this2._invInertia12 * _this2._transform._rotation02;
  50068. __tmp__111 = _this2._invInertia10 * _this2._transform._rotation10 + _this2._invInertia11 * _this2._transform._rotation11 + _this2._invInertia12 * _this2._transform._rotation12;
  50069. __tmp__121 = _this2._invInertia10 * _this2._transform._rotation20 + _this2._invInertia11 * _this2._transform._rotation21 + _this2._invInertia12 * _this2._transform._rotation22;
  50070. __tmp__201 = _this2._invInertia20 * _this2._transform._rotation00 + _this2._invInertia21 * _this2._transform._rotation01 + _this2._invInertia22 * _this2._transform._rotation02;
  50071. __tmp__211 = _this2._invInertia20 * _this2._transform._rotation10 + _this2._invInertia21 * _this2._transform._rotation11 + _this2._invInertia22 * _this2._transform._rotation12;
  50072. __tmp__221 = _this2._invInertia20 * _this2._transform._rotation20 + _this2._invInertia21 * _this2._transform._rotation21 + _this2._invInertia22 * _this2._transform._rotation22;
  50073. _this2._invInertia00 = __tmp__001;
  50074. _this2._invInertia01 = __tmp__011;
  50075. _this2._invInertia02 = __tmp__021;
  50076. _this2._invInertia10 = __tmp__101;
  50077. _this2._invInertia11 = __tmp__111;
  50078. _this2._invInertia12 = __tmp__121;
  50079. _this2._invInertia20 = __tmp__201;
  50080. _this2._invInertia21 = __tmp__211;
  50081. _this2._invInertia22 = __tmp__221;
  50082. _this2._invInertia00 *= _this2._rotFactor.x;
  50083. _this2._invInertia01 *= _this2._rotFactor.x;
  50084. _this2._invInertia02 *= _this2._rotFactor.x;
  50085. _this2._invInertia10 *= _this2._rotFactor.y;
  50086. _this2._invInertia11 *= _this2._rotFactor.y;
  50087. _this2._invInertia12 *= _this2._rotFactor.y;
  50088. _this2._invInertia20 *= _this2._rotFactor.z;
  50089. _this2._invInertia21 *= _this2._rotFactor.z;
  50090. _this2._invInertia22 *= _this2._rotFactor.z;
  50091. var _this3 = this._b2;
  50092. var theta1 = Math.sqrt(av2X * av2X + av2Y * av2Y + av2Z * av2Z);
  50093. var halfTheta1 = theta1 * 0.5;
  50094. var rotationToSinAxisFactor1;
  50095. var cosHalfTheta1;
  50096. if(halfTheta1 < 0.5) {
  50097. var ht21 = halfTheta1 * halfTheta1;
  50098. rotationToSinAxisFactor1 = 0.5 * (1 - ht21 * 0.166666666666666657 + ht21 * ht21 * 0.00833333333333333322);
  50099. cosHalfTheta1 = 1 - ht21 * 0.5 + ht21 * ht21 * 0.0416666666666666644;
  50100. } else {
  50101. rotationToSinAxisFactor1 = Math.sin(halfTheta1) / theta1;
  50102. cosHalfTheta1 = Math.cos(halfTheta1);
  50103. }
  50104. var sinAxis1;
  50105. var sinAxisX1;
  50106. var sinAxisY1;
  50107. var sinAxisZ1;
  50108. sinAxisX1 = av2X * rotationToSinAxisFactor1;
  50109. sinAxisY1 = av2Y * rotationToSinAxisFactor1;
  50110. sinAxisZ1 = av2Z * rotationToSinAxisFactor1;
  50111. var dq1;
  50112. var dqX1;
  50113. var dqY1;
  50114. var dqZ1;
  50115. var dqW1;
  50116. dqX1 = sinAxisX1;
  50117. dqY1 = sinAxisY1;
  50118. dqZ1 = sinAxisZ1;
  50119. dqW1 = cosHalfTheta1;
  50120. var q1;
  50121. var qX1;
  50122. var qY1;
  50123. var qZ1;
  50124. var qW1;
  50125. var e001 = _this3._transform._rotation00;
  50126. var e111 = _this3._transform._rotation11;
  50127. var e221 = _this3._transform._rotation22;
  50128. var t1 = e001 + e111 + e221;
  50129. var s1;
  50130. if(t1 > 0) {
  50131. s1 = Math.sqrt(t1 + 1);
  50132. qW1 = 0.5 * s1;
  50133. s1 = 0.5 / s1;
  50134. qX1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1;
  50135. qY1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1;
  50136. qZ1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1;
  50137. } else if(e001 > e111) {
  50138. if(e001 > e221) {
  50139. s1 = Math.sqrt(e001 - e111 - e221 + 1);
  50140. qX1 = 0.5 * s1;
  50141. s1 = 0.5 / s1;
  50142. qY1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1;
  50143. qZ1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1;
  50144. qW1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1;
  50145. } else {
  50146. s1 = Math.sqrt(e221 - e001 - e111 + 1);
  50147. qZ1 = 0.5 * s1;
  50148. s1 = 0.5 / s1;
  50149. qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1;
  50150. qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1;
  50151. qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1;
  50152. }
  50153. } else if(e111 > e221) {
  50154. s1 = Math.sqrt(e111 - e221 - e001 + 1);
  50155. qY1 = 0.5 * s1;
  50156. s1 = 0.5 / s1;
  50157. qX1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1;
  50158. qZ1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1;
  50159. qW1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1;
  50160. } else {
  50161. s1 = Math.sqrt(e221 - e001 - e111 + 1);
  50162. qZ1 = 0.5 * s1;
  50163. s1 = 0.5 / s1;
  50164. qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1;
  50165. qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1;
  50166. qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1;
  50167. }
  50168. qX1 = dqW1 * qX1 + dqX1 * qW1 + dqY1 * qZ1 - dqZ1 * qY1;
  50169. qY1 = dqW1 * qY1 - dqX1 * qZ1 + dqY1 * qW1 + dqZ1 * qX1;
  50170. qZ1 = dqW1 * qZ1 + dqX1 * qY1 - dqY1 * qX1 + dqZ1 * qW1;
  50171. qW1 = dqW1 * qW1 - dqX1 * qX1 - dqY1 * qY1 - dqZ1 * qZ1;
  50172. var l1 = qX1 * qX1 + qY1 * qY1 + qZ1 * qZ1 + qW1 * qW1;
  50173. if(l1 > 1e-32) {
  50174. l1 = 1 / Math.sqrt(l1);
  50175. }
  50176. qX1 *= l1;
  50177. qY1 *= l1;
  50178. qZ1 *= l1;
  50179. qW1 *= l1;
  50180. var x1 = qX1;
  50181. var y1 = qY1;
  50182. var z1 = qZ1;
  50183. var w1 = qW1;
  50184. var x21 = 2 * x1;
  50185. var y21 = 2 * y1;
  50186. var z21 = 2 * z1;
  50187. var xx1 = x1 * x21;
  50188. var yy1 = y1 * y21;
  50189. var zz1 = z1 * z21;
  50190. var xy1 = x1 * y21;
  50191. var yz1 = y1 * z21;
  50192. var xz1 = x1 * z21;
  50193. var wx1 = w1 * x21;
  50194. var wy1 = w1 * y21;
  50195. var wz1 = w1 * z21;
  50196. _this3._transform._rotation00 = 1 - yy1 - zz1;
  50197. _this3._transform._rotation01 = xy1 - wz1;
  50198. _this3._transform._rotation02 = xz1 + wy1;
  50199. _this3._transform._rotation10 = xy1 + wz1;
  50200. _this3._transform._rotation11 = 1 - xx1 - zz1;
  50201. _this3._transform._rotation12 = yz1 - wx1;
  50202. _this3._transform._rotation20 = xz1 - wy1;
  50203. _this3._transform._rotation21 = yz1 + wx1;
  50204. _this3._transform._rotation22 = 1 - xx1 - yy1;
  50205. var __tmp__002;
  50206. var __tmp__012;
  50207. var __tmp__022;
  50208. var __tmp__102;
  50209. var __tmp__112;
  50210. var __tmp__122;
  50211. var __tmp__202;
  50212. var __tmp__212;
  50213. var __tmp__222;
  50214. __tmp__002 = _this3._transform._rotation00 * _this3._invLocalInertia00 + _this3._transform._rotation01 * _this3._invLocalInertia10 + _this3._transform._rotation02 * _this3._invLocalInertia20;
  50215. __tmp__012 = _this3._transform._rotation00 * _this3._invLocalInertia01 + _this3._transform._rotation01 * _this3._invLocalInertia11 + _this3._transform._rotation02 * _this3._invLocalInertia21;
  50216. __tmp__022 = _this3._transform._rotation00 * _this3._invLocalInertia02 + _this3._transform._rotation01 * _this3._invLocalInertia12 + _this3._transform._rotation02 * _this3._invLocalInertia22;
  50217. __tmp__102 = _this3._transform._rotation10 * _this3._invLocalInertia00 + _this3._transform._rotation11 * _this3._invLocalInertia10 + _this3._transform._rotation12 * _this3._invLocalInertia20;
  50218. __tmp__112 = _this3._transform._rotation10 * _this3._invLocalInertia01 + _this3._transform._rotation11 * _this3._invLocalInertia11 + _this3._transform._rotation12 * _this3._invLocalInertia21;
  50219. __tmp__122 = _this3._transform._rotation10 * _this3._invLocalInertia02 + _this3._transform._rotation11 * _this3._invLocalInertia12 + _this3._transform._rotation12 * _this3._invLocalInertia22;
  50220. __tmp__202 = _this3._transform._rotation20 * _this3._invLocalInertia00 + _this3._transform._rotation21 * _this3._invLocalInertia10 + _this3._transform._rotation22 * _this3._invLocalInertia20;
  50221. __tmp__212 = _this3._transform._rotation20 * _this3._invLocalInertia01 + _this3._transform._rotation21 * _this3._invLocalInertia11 + _this3._transform._rotation22 * _this3._invLocalInertia21;
  50222. __tmp__222 = _this3._transform._rotation20 * _this3._invLocalInertia02 + _this3._transform._rotation21 * _this3._invLocalInertia12 + _this3._transform._rotation22 * _this3._invLocalInertia22;
  50223. _this3._invInertia00 = __tmp__002;
  50224. _this3._invInertia01 = __tmp__012;
  50225. _this3._invInertia02 = __tmp__022;
  50226. _this3._invInertia10 = __tmp__102;
  50227. _this3._invInertia11 = __tmp__112;
  50228. _this3._invInertia12 = __tmp__122;
  50229. _this3._invInertia20 = __tmp__202;
  50230. _this3._invInertia21 = __tmp__212;
  50231. _this3._invInertia22 = __tmp__222;
  50232. var __tmp__003;
  50233. var __tmp__013;
  50234. var __tmp__023;
  50235. var __tmp__103;
  50236. var __tmp__113;
  50237. var __tmp__123;
  50238. var __tmp__203;
  50239. var __tmp__213;
  50240. var __tmp__223;
  50241. __tmp__003 = _this3._invInertia00 * _this3._transform._rotation00 + _this3._invInertia01 * _this3._transform._rotation01 + _this3._invInertia02 * _this3._transform._rotation02;
  50242. __tmp__013 = _this3._invInertia00 * _this3._transform._rotation10 + _this3._invInertia01 * _this3._transform._rotation11 + _this3._invInertia02 * _this3._transform._rotation12;
  50243. __tmp__023 = _this3._invInertia00 * _this3._transform._rotation20 + _this3._invInertia01 * _this3._transform._rotation21 + _this3._invInertia02 * _this3._transform._rotation22;
  50244. __tmp__103 = _this3._invInertia10 * _this3._transform._rotation00 + _this3._invInertia11 * _this3._transform._rotation01 + _this3._invInertia12 * _this3._transform._rotation02;
  50245. __tmp__113 = _this3._invInertia10 * _this3._transform._rotation10 + _this3._invInertia11 * _this3._transform._rotation11 + _this3._invInertia12 * _this3._transform._rotation12;
  50246. __tmp__123 = _this3._invInertia10 * _this3._transform._rotation20 + _this3._invInertia11 * _this3._transform._rotation21 + _this3._invInertia12 * _this3._transform._rotation22;
  50247. __tmp__203 = _this3._invInertia20 * _this3._transform._rotation00 + _this3._invInertia21 * _this3._transform._rotation01 + _this3._invInertia22 * _this3._transform._rotation02;
  50248. __tmp__213 = _this3._invInertia20 * _this3._transform._rotation10 + _this3._invInertia21 * _this3._transform._rotation11 + _this3._invInertia22 * _this3._transform._rotation12;
  50249. __tmp__223 = _this3._invInertia20 * _this3._transform._rotation20 + _this3._invInertia21 * _this3._transform._rotation21 + _this3._invInertia22 * _this3._transform._rotation22;
  50250. _this3._invInertia00 = __tmp__003;
  50251. _this3._invInertia01 = __tmp__013;
  50252. _this3._invInertia02 = __tmp__023;
  50253. _this3._invInertia10 = __tmp__103;
  50254. _this3._invInertia11 = __tmp__113;
  50255. _this3._invInertia12 = __tmp__123;
  50256. _this3._invInertia20 = __tmp__203;
  50257. _this3._invInertia21 = __tmp__213;
  50258. _this3._invInertia22 = __tmp__223;
  50259. _this3._invInertia00 *= _this3._rotFactor.x;
  50260. _this3._invInertia01 *= _this3._rotFactor.x;
  50261. _this3._invInertia02 *= _this3._rotFactor.x;
  50262. _this3._invInertia10 *= _this3._rotFactor.y;
  50263. _this3._invInertia11 *= _this3._rotFactor.y;
  50264. _this3._invInertia12 *= _this3._rotFactor.y;
  50265. _this3._invInertia20 *= _this3._rotFactor.z;
  50266. _this3._invInertia21 *= _this3._rotFactor.z;
  50267. _this3._invInertia22 *= _this3._rotFactor.z;
  50268. }
  50269. postSolve() {
  50270. this.joint._syncAnchors();
  50271. this.joint._checkDestruction();
  50272. }
  50273. }
  50274. if(!oimo.dynamics.rigidbody) oimo.dynamics.rigidbody = {};
  50275. oimo.dynamics.rigidbody.MassData = class oimo_dynamics_rigidbody_MassData {
  50276. constructor() {
  50277. this.mass = 0;
  50278. this.localInertia = new oimo.common.Mat3();
  50279. }
  50280. }
  50281. oimo.dynamics.rigidbody.RigidBody = class oimo_dynamics_rigidbody_RigidBody {
  50282. constructor(config) {
  50283. this._next = null;
  50284. this._prev = null;
  50285. this._shapeList = null;
  50286. this._shapeListLast = null;
  50287. this._numShapes = 0;
  50288. this._contactLinkList = null;
  50289. this._contactLinkListLast = null;
  50290. this._numContactLinks = 0;
  50291. this._jointLinkList = null;
  50292. this._jointLinkListLast = null;
  50293. this._numJointLinks = 0;
  50294. var v = config.linearVelocity;
  50295. this._velX = v.x;
  50296. this._velY = v.y;
  50297. this._velZ = v.z;
  50298. var v1 = config.angularVelocity;
  50299. this._angVelX = v1.x;
  50300. this._angVelY = v1.y;
  50301. this._angVelZ = v1.z;
  50302. this._pseudoVelX = 0;
  50303. this._pseudoVelY = 0;
  50304. this._pseudoVelZ = 0;
  50305. this._angPseudoVelX = 0;
  50306. this._angPseudoVelY = 0;
  50307. this._angPseudoVelZ = 0;
  50308. this._ptransform = new oimo.common.Transform();
  50309. this._transform = new oimo.common.Transform();
  50310. var v2 = config.position;
  50311. this._ptransform._positionX = v2.x;
  50312. this._ptransform._positionY = v2.y;
  50313. this._ptransform._positionZ = v2.z;
  50314. var m = config.rotation;
  50315. this._ptransform._rotation00 = m.e00;
  50316. this._ptransform._rotation01 = m.e01;
  50317. this._ptransform._rotation02 = m.e02;
  50318. this._ptransform._rotation10 = m.e10;
  50319. this._ptransform._rotation11 = m.e11;
  50320. this._ptransform._rotation12 = m.e12;
  50321. this._ptransform._rotation20 = m.e20;
  50322. this._ptransform._rotation21 = m.e21;
  50323. this._ptransform._rotation22 = m.e22;
  50324. var dst = this._transform;
  50325. var src = this._ptransform;
  50326. dst._positionX = src._positionX;
  50327. dst._positionY = src._positionY;
  50328. dst._positionZ = src._positionZ;
  50329. dst._rotation00 = src._rotation00;
  50330. dst._rotation01 = src._rotation01;
  50331. dst._rotation02 = src._rotation02;
  50332. dst._rotation10 = src._rotation10;
  50333. dst._rotation11 = src._rotation11;
  50334. dst._rotation12 = src._rotation12;
  50335. dst._rotation20 = src._rotation20;
  50336. dst._rotation21 = src._rotation21;
  50337. dst._rotation22 = src._rotation22;
  50338. this._type = config.type;
  50339. this._sleepTime = 0;
  50340. this._sleeping = false;
  50341. this._autoSleep = config.autoSleep;
  50342. this._mass = 0;
  50343. this._invMass = 0;
  50344. this._localInertia00 = 0;
  50345. this._localInertia01 = 0;
  50346. this._localInertia02 = 0;
  50347. this._localInertia10 = 0;
  50348. this._localInertia11 = 0;
  50349. this._localInertia12 = 0;
  50350. this._localInertia20 = 0;
  50351. this._localInertia21 = 0;
  50352. this._localInertia22 = 0;
  50353. this._invLocalInertia00 = 0;
  50354. this._invLocalInertia01 = 0;
  50355. this._invLocalInertia02 = 0;
  50356. this._invLocalInertia10 = 0;
  50357. this._invLocalInertia11 = 0;
  50358. this._invLocalInertia12 = 0;
  50359. this._invLocalInertia20 = 0;
  50360. this._invLocalInertia21 = 0;
  50361. this._invLocalInertia22 = 0;
  50362. this._invLocalInertiaWithoutRotFactor00 = 0;
  50363. this._invLocalInertiaWithoutRotFactor01 = 0;
  50364. this._invLocalInertiaWithoutRotFactor02 = 0;
  50365. this._invLocalInertiaWithoutRotFactor10 = 0;
  50366. this._invLocalInertiaWithoutRotFactor11 = 0;
  50367. this._invLocalInertiaWithoutRotFactor12 = 0;
  50368. this._invLocalInertiaWithoutRotFactor20 = 0;
  50369. this._invLocalInertiaWithoutRotFactor21 = 0;
  50370. this._invLocalInertiaWithoutRotFactor22 = 0;
  50371. this._invInertia00 = 0;
  50372. this._invInertia01 = 0;
  50373. this._invInertia02 = 0;
  50374. this._invInertia10 = 0;
  50375. this._invInertia11 = 0;
  50376. this._invInertia12 = 0;
  50377. this._invInertia20 = 0;
  50378. this._invInertia21 = 0;
  50379. this._invInertia22 = 0;
  50380. this._linearDamping = config.linearDamping;
  50381. this._angularDamping = config.angularDamping;
  50382. this._forceX = 0;
  50383. this._forceY = 0;
  50384. this._forceZ = 0;
  50385. this._torqueX = 0;
  50386. this._torqueY = 0;
  50387. this._torqueZ = 0;
  50388. this._linearContactImpulseX = 0;
  50389. this._linearContactImpulseY = 0;
  50390. this._linearContactImpulseZ = 0;
  50391. this._angularContactImpulseX = 0;
  50392. this._angularContactImpulseY = 0;
  50393. this._angularContactImpulseZ = 0;
  50394. this._rotFactor = new oimo.common.Vec3(1,1,1);
  50395. this._addedToIsland = false;
  50396. this._gravityScale = 1;
  50397. this._world = null;
  50398. }
  50399. _integrate(dt) {
  50400. switch(this._type) {
  50401. case 1:
  50402. this._velX = 0;
  50403. this._velY = 0;
  50404. this._velZ = 0;
  50405. this._angVelX = 0;
  50406. this._angVelY = 0;
  50407. this._angVelZ = 0;
  50408. this._pseudoVelX = 0;
  50409. this._pseudoVelY = 0;
  50410. this._pseudoVelZ = 0;
  50411. this._angPseudoVelX = 0;
  50412. this._angPseudoVelY = 0;
  50413. this._angPseudoVelZ = 0;
  50414. break;
  50415. case 0:case 2:
  50416. var translation;
  50417. var translationX;
  50418. var translationY;
  50419. var translationZ;
  50420. var rotation;
  50421. var rotationX;
  50422. var rotationY;
  50423. var rotationZ;
  50424. translationX = this._velX * dt;
  50425. translationY = this._velY * dt;
  50426. translationZ = this._velZ * dt;
  50427. rotationX = this._angVelX * dt;
  50428. rotationY = this._angVelY * dt;
  50429. rotationZ = this._angVelZ * dt;
  50430. var translationLengthSq = translationX * translationX + translationY * translationY + translationZ * translationZ;
  50431. var rotationLengthSq = rotationX * rotationX + rotationY * rotationY + rotationZ * rotationZ;
  50432. if(translationLengthSq == 0 && rotationLengthSq == 0) {
  50433. return;
  50434. }
  50435. if(translationLengthSq > oimo.common.Setting.maxTranslationPerStep * oimo.common.Setting.maxTranslationPerStep) {
  50436. var l = oimo.common.Setting.maxTranslationPerStep / Math.sqrt(translationLengthSq);
  50437. this._velX *= l;
  50438. this._velY *= l;
  50439. this._velZ *= l;
  50440. translationX *= l;
  50441. translationY *= l;
  50442. translationZ *= l;
  50443. }
  50444. if(rotationLengthSq > oimo.common.Setting.maxRotationPerStep * oimo.common.Setting.maxRotationPerStep) {
  50445. var l1 = oimo.common.Setting.maxRotationPerStep / Math.sqrt(rotationLengthSq);
  50446. this._angVelX *= l1;
  50447. this._angVelY *= l1;
  50448. this._angVelZ *= l1;
  50449. rotationX *= l1;
  50450. rotationY *= l1;
  50451. rotationZ *= l1;
  50452. }
  50453. this._transform._positionX += translationX;
  50454. this._transform._positionY += translationY;
  50455. this._transform._positionZ += translationZ;
  50456. var theta = Math.sqrt(rotationX * rotationX + rotationY * rotationY + rotationZ * rotationZ);
  50457. var halfTheta = theta * 0.5;
  50458. var rotationToSinAxisFactor;
  50459. var cosHalfTheta;
  50460. if(halfTheta < 0.5) {
  50461. var ht2 = halfTheta * halfTheta;
  50462. rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.166666666666666657 + ht2 * ht2 * 0.00833333333333333322);
  50463. cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.0416666666666666644;
  50464. } else {
  50465. rotationToSinAxisFactor = Math.sin(halfTheta) / theta;
  50466. cosHalfTheta = Math.cos(halfTheta);
  50467. }
  50468. var sinAxis;
  50469. var sinAxisX;
  50470. var sinAxisY;
  50471. var sinAxisZ;
  50472. sinAxisX = rotationX * rotationToSinAxisFactor;
  50473. sinAxisY = rotationY * rotationToSinAxisFactor;
  50474. sinAxisZ = rotationZ * rotationToSinAxisFactor;
  50475. var dq;
  50476. var dqX;
  50477. var dqY;
  50478. var dqZ;
  50479. var dqW;
  50480. dqX = sinAxisX;
  50481. dqY = sinAxisY;
  50482. dqZ = sinAxisZ;
  50483. dqW = cosHalfTheta;
  50484. var q;
  50485. var qX;
  50486. var qY;
  50487. var qZ;
  50488. var qW;
  50489. var e00 = this._transform._rotation00;
  50490. var e11 = this._transform._rotation11;
  50491. var e22 = this._transform._rotation22;
  50492. var t = e00 + e11 + e22;
  50493. var s;
  50494. if(t > 0) {
  50495. s = Math.sqrt(t + 1);
  50496. qW = 0.5 * s;
  50497. s = 0.5 / s;
  50498. qX = (this._transform._rotation21 - this._transform._rotation12) * s;
  50499. qY = (this._transform._rotation02 - this._transform._rotation20) * s;
  50500. qZ = (this._transform._rotation10 - this._transform._rotation01) * s;
  50501. } else if(e00 > e11) {
  50502. if(e00 > e22) {
  50503. s = Math.sqrt(e00 - e11 - e22 + 1);
  50504. qX = 0.5 * s;
  50505. s = 0.5 / s;
  50506. qY = (this._transform._rotation01 + this._transform._rotation10) * s;
  50507. qZ = (this._transform._rotation02 + this._transform._rotation20) * s;
  50508. qW = (this._transform._rotation21 - this._transform._rotation12) * s;
  50509. } else {
  50510. s = Math.sqrt(e22 - e00 - e11 + 1);
  50511. qZ = 0.5 * s;
  50512. s = 0.5 / s;
  50513. qX = (this._transform._rotation02 + this._transform._rotation20) * s;
  50514. qY = (this._transform._rotation12 + this._transform._rotation21) * s;
  50515. qW = (this._transform._rotation10 - this._transform._rotation01) * s;
  50516. }
  50517. } else if(e11 > e22) {
  50518. s = Math.sqrt(e11 - e22 - e00 + 1);
  50519. qY = 0.5 * s;
  50520. s = 0.5 / s;
  50521. qX = (this._transform._rotation01 + this._transform._rotation10) * s;
  50522. qZ = (this._transform._rotation12 + this._transform._rotation21) * s;
  50523. qW = (this._transform._rotation02 - this._transform._rotation20) * s;
  50524. } else {
  50525. s = Math.sqrt(e22 - e00 - e11 + 1);
  50526. qZ = 0.5 * s;
  50527. s = 0.5 / s;
  50528. qX = (this._transform._rotation02 + this._transform._rotation20) * s;
  50529. qY = (this._transform._rotation12 + this._transform._rotation21) * s;
  50530. qW = (this._transform._rotation10 - this._transform._rotation01) * s;
  50531. }
  50532. qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY;
  50533. qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX;
  50534. qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW;
  50535. qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ;
  50536. var l2 = qX * qX + qY * qY + qZ * qZ + qW * qW;
  50537. if(l2 > 1e-32) {
  50538. l2 = 1 / Math.sqrt(l2);
  50539. }
  50540. qX *= l2;
  50541. qY *= l2;
  50542. qZ *= l2;
  50543. qW *= l2;
  50544. var x = qX;
  50545. var y = qY;
  50546. var z = qZ;
  50547. var w = qW;
  50548. var x2 = 2 * x;
  50549. var y2 = 2 * y;
  50550. var z2 = 2 * z;
  50551. var xx = x * x2;
  50552. var yy = y * y2;
  50553. var zz = z * z2;
  50554. var xy = x * y2;
  50555. var yz = y * z2;
  50556. var xz = x * z2;
  50557. var wx = w * x2;
  50558. var wy = w * y2;
  50559. var wz = w * z2;
  50560. this._transform._rotation00 = 1 - yy - zz;
  50561. this._transform._rotation01 = xy - wz;
  50562. this._transform._rotation02 = xz + wy;
  50563. this._transform._rotation10 = xy + wz;
  50564. this._transform._rotation11 = 1 - xx - zz;
  50565. this._transform._rotation12 = yz - wx;
  50566. this._transform._rotation20 = xz - wy;
  50567. this._transform._rotation21 = yz + wx;
  50568. this._transform._rotation22 = 1 - xx - yy;
  50569. var __tmp__00;
  50570. var __tmp__01;
  50571. var __tmp__02;
  50572. var __tmp__10;
  50573. var __tmp__11;
  50574. var __tmp__12;
  50575. var __tmp__20;
  50576. var __tmp__21;
  50577. var __tmp__22;
  50578. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  50579. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  50580. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  50581. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  50582. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  50583. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  50584. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  50585. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  50586. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  50587. this._invInertia00 = __tmp__00;
  50588. this._invInertia01 = __tmp__01;
  50589. this._invInertia02 = __tmp__02;
  50590. this._invInertia10 = __tmp__10;
  50591. this._invInertia11 = __tmp__11;
  50592. this._invInertia12 = __tmp__12;
  50593. this._invInertia20 = __tmp__20;
  50594. this._invInertia21 = __tmp__21;
  50595. this._invInertia22 = __tmp__22;
  50596. var __tmp__001;
  50597. var __tmp__011;
  50598. var __tmp__021;
  50599. var __tmp__101;
  50600. var __tmp__111;
  50601. var __tmp__121;
  50602. var __tmp__201;
  50603. var __tmp__211;
  50604. var __tmp__221;
  50605. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  50606. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  50607. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  50608. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  50609. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  50610. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  50611. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  50612. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  50613. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  50614. this._invInertia00 = __tmp__001;
  50615. this._invInertia01 = __tmp__011;
  50616. this._invInertia02 = __tmp__021;
  50617. this._invInertia10 = __tmp__101;
  50618. this._invInertia11 = __tmp__111;
  50619. this._invInertia12 = __tmp__121;
  50620. this._invInertia20 = __tmp__201;
  50621. this._invInertia21 = __tmp__211;
  50622. this._invInertia22 = __tmp__221;
  50623. this._invInertia00 *= this._rotFactor.x;
  50624. this._invInertia01 *= this._rotFactor.x;
  50625. this._invInertia02 *= this._rotFactor.x;
  50626. this._invInertia10 *= this._rotFactor.y;
  50627. this._invInertia11 *= this._rotFactor.y;
  50628. this._invInertia12 *= this._rotFactor.y;
  50629. this._invInertia20 *= this._rotFactor.z;
  50630. this._invInertia21 *= this._rotFactor.z;
  50631. this._invInertia22 *= this._rotFactor.z;
  50632. break;
  50633. }
  50634. }
  50635. _integratePseudoVelocity() {
  50636. var pseudoVelLengthSq = this._pseudoVelX * this._pseudoVelX + this._pseudoVelY * this._pseudoVelY + this._pseudoVelZ * this._pseudoVelZ;
  50637. var angPseudoVelLengthSq = this._angPseudoVelX * this._angPseudoVelX + this._angPseudoVelY * this._angPseudoVelY + this._angPseudoVelZ * this._angPseudoVelZ;
  50638. if(pseudoVelLengthSq == 0 && angPseudoVelLengthSq == 0) {
  50639. return;
  50640. }
  50641. switch(this._type) {
  50642. case 1:
  50643. this._pseudoVelX = 0;
  50644. this._pseudoVelY = 0;
  50645. this._pseudoVelZ = 0;
  50646. this._angPseudoVelX = 0;
  50647. this._angPseudoVelY = 0;
  50648. this._angPseudoVelZ = 0;
  50649. break;
  50650. case 0:case 2:
  50651. var translation;
  50652. var translationX;
  50653. var translationY;
  50654. var translationZ;
  50655. var rotation;
  50656. var rotationX;
  50657. var rotationY;
  50658. var rotationZ;
  50659. translationX = this._pseudoVelX;
  50660. translationY = this._pseudoVelY;
  50661. translationZ = this._pseudoVelZ;
  50662. rotationX = this._angPseudoVelX;
  50663. rotationY = this._angPseudoVelY;
  50664. rotationZ = this._angPseudoVelZ;
  50665. this._pseudoVelX = 0;
  50666. this._pseudoVelY = 0;
  50667. this._pseudoVelZ = 0;
  50668. this._angPseudoVelX = 0;
  50669. this._angPseudoVelY = 0;
  50670. this._angPseudoVelZ = 0;
  50671. this._transform._positionX += translationX;
  50672. this._transform._positionY += translationY;
  50673. this._transform._positionZ += translationZ;
  50674. var theta = Math.sqrt(rotationX * rotationX + rotationY * rotationY + rotationZ * rotationZ);
  50675. var halfTheta = theta * 0.5;
  50676. var rotationToSinAxisFactor;
  50677. var cosHalfTheta;
  50678. if(halfTheta < 0.5) {
  50679. var ht2 = halfTheta * halfTheta;
  50680. rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.166666666666666657 + ht2 * ht2 * 0.00833333333333333322);
  50681. cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.0416666666666666644;
  50682. } else {
  50683. rotationToSinAxisFactor = Math.sin(halfTheta) / theta;
  50684. cosHalfTheta = Math.cos(halfTheta);
  50685. }
  50686. var sinAxis;
  50687. var sinAxisX;
  50688. var sinAxisY;
  50689. var sinAxisZ;
  50690. sinAxisX = rotationX * rotationToSinAxisFactor;
  50691. sinAxisY = rotationY * rotationToSinAxisFactor;
  50692. sinAxisZ = rotationZ * rotationToSinAxisFactor;
  50693. var dq;
  50694. var dqX;
  50695. var dqY;
  50696. var dqZ;
  50697. var dqW;
  50698. dqX = sinAxisX;
  50699. dqY = sinAxisY;
  50700. dqZ = sinAxisZ;
  50701. dqW = cosHalfTheta;
  50702. var q;
  50703. var qX;
  50704. var qY;
  50705. var qZ;
  50706. var qW;
  50707. var e00 = this._transform._rotation00;
  50708. var e11 = this._transform._rotation11;
  50709. var e22 = this._transform._rotation22;
  50710. var t = e00 + e11 + e22;
  50711. var s;
  50712. if(t > 0) {
  50713. s = Math.sqrt(t + 1);
  50714. qW = 0.5 * s;
  50715. s = 0.5 / s;
  50716. qX = (this._transform._rotation21 - this._transform._rotation12) * s;
  50717. qY = (this._transform._rotation02 - this._transform._rotation20) * s;
  50718. qZ = (this._transform._rotation10 - this._transform._rotation01) * s;
  50719. } else if(e00 > e11) {
  50720. if(e00 > e22) {
  50721. s = Math.sqrt(e00 - e11 - e22 + 1);
  50722. qX = 0.5 * s;
  50723. s = 0.5 / s;
  50724. qY = (this._transform._rotation01 + this._transform._rotation10) * s;
  50725. qZ = (this._transform._rotation02 + this._transform._rotation20) * s;
  50726. qW = (this._transform._rotation21 - this._transform._rotation12) * s;
  50727. } else {
  50728. s = Math.sqrt(e22 - e00 - e11 + 1);
  50729. qZ = 0.5 * s;
  50730. s = 0.5 / s;
  50731. qX = (this._transform._rotation02 + this._transform._rotation20) * s;
  50732. qY = (this._transform._rotation12 + this._transform._rotation21) * s;
  50733. qW = (this._transform._rotation10 - this._transform._rotation01) * s;
  50734. }
  50735. } else if(e11 > e22) {
  50736. s = Math.sqrt(e11 - e22 - e00 + 1);
  50737. qY = 0.5 * s;
  50738. s = 0.5 / s;
  50739. qX = (this._transform._rotation01 + this._transform._rotation10) * s;
  50740. qZ = (this._transform._rotation12 + this._transform._rotation21) * s;
  50741. qW = (this._transform._rotation02 - this._transform._rotation20) * s;
  50742. } else {
  50743. s = Math.sqrt(e22 - e00 - e11 + 1);
  50744. qZ = 0.5 * s;
  50745. s = 0.5 / s;
  50746. qX = (this._transform._rotation02 + this._transform._rotation20) * s;
  50747. qY = (this._transform._rotation12 + this._transform._rotation21) * s;
  50748. qW = (this._transform._rotation10 - this._transform._rotation01) * s;
  50749. }
  50750. qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY;
  50751. qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX;
  50752. qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW;
  50753. qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ;
  50754. var l = qX * qX + qY * qY + qZ * qZ + qW * qW;
  50755. if(l > 1e-32) {
  50756. l = 1 / Math.sqrt(l);
  50757. }
  50758. qX *= l;
  50759. qY *= l;
  50760. qZ *= l;
  50761. qW *= l;
  50762. var x = qX;
  50763. var y = qY;
  50764. var z = qZ;
  50765. var w = qW;
  50766. var x2 = 2 * x;
  50767. var y2 = 2 * y;
  50768. var z2 = 2 * z;
  50769. var xx = x * x2;
  50770. var yy = y * y2;
  50771. var zz = z * z2;
  50772. var xy = x * y2;
  50773. var yz = y * z2;
  50774. var xz = x * z2;
  50775. var wx = w * x2;
  50776. var wy = w * y2;
  50777. var wz = w * z2;
  50778. this._transform._rotation00 = 1 - yy - zz;
  50779. this._transform._rotation01 = xy - wz;
  50780. this._transform._rotation02 = xz + wy;
  50781. this._transform._rotation10 = xy + wz;
  50782. this._transform._rotation11 = 1 - xx - zz;
  50783. this._transform._rotation12 = yz - wx;
  50784. this._transform._rotation20 = xz - wy;
  50785. this._transform._rotation21 = yz + wx;
  50786. this._transform._rotation22 = 1 - xx - yy;
  50787. var __tmp__00;
  50788. var __tmp__01;
  50789. var __tmp__02;
  50790. var __tmp__10;
  50791. var __tmp__11;
  50792. var __tmp__12;
  50793. var __tmp__20;
  50794. var __tmp__21;
  50795. var __tmp__22;
  50796. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  50797. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  50798. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  50799. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  50800. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  50801. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  50802. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  50803. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  50804. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  50805. this._invInertia00 = __tmp__00;
  50806. this._invInertia01 = __tmp__01;
  50807. this._invInertia02 = __tmp__02;
  50808. this._invInertia10 = __tmp__10;
  50809. this._invInertia11 = __tmp__11;
  50810. this._invInertia12 = __tmp__12;
  50811. this._invInertia20 = __tmp__20;
  50812. this._invInertia21 = __tmp__21;
  50813. this._invInertia22 = __tmp__22;
  50814. var __tmp__001;
  50815. var __tmp__011;
  50816. var __tmp__021;
  50817. var __tmp__101;
  50818. var __tmp__111;
  50819. var __tmp__121;
  50820. var __tmp__201;
  50821. var __tmp__211;
  50822. var __tmp__221;
  50823. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  50824. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  50825. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  50826. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  50827. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  50828. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  50829. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  50830. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  50831. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  50832. this._invInertia00 = __tmp__001;
  50833. this._invInertia01 = __tmp__011;
  50834. this._invInertia02 = __tmp__021;
  50835. this._invInertia10 = __tmp__101;
  50836. this._invInertia11 = __tmp__111;
  50837. this._invInertia12 = __tmp__121;
  50838. this._invInertia20 = __tmp__201;
  50839. this._invInertia21 = __tmp__211;
  50840. this._invInertia22 = __tmp__221;
  50841. this._invInertia00 *= this._rotFactor.x;
  50842. this._invInertia01 *= this._rotFactor.x;
  50843. this._invInertia02 *= this._rotFactor.x;
  50844. this._invInertia10 *= this._rotFactor.y;
  50845. this._invInertia11 *= this._rotFactor.y;
  50846. this._invInertia12 *= this._rotFactor.y;
  50847. this._invInertia20 *= this._rotFactor.z;
  50848. this._invInertia21 *= this._rotFactor.z;
  50849. this._invInertia22 *= this._rotFactor.z;
  50850. break;
  50851. }
  50852. }
  50853. updateMass() {
  50854. var totalInertia;
  50855. var totalInertia00;
  50856. var totalInertia01;
  50857. var totalInertia02;
  50858. var totalInertia10;
  50859. var totalInertia11;
  50860. var totalInertia12;
  50861. var totalInertia20;
  50862. var totalInertia21;
  50863. var totalInertia22;
  50864. totalInertia00 = 0;
  50865. totalInertia01 = 0;
  50866. totalInertia02 = 0;
  50867. totalInertia10 = 0;
  50868. totalInertia11 = 0;
  50869. totalInertia12 = 0;
  50870. totalInertia20 = 0;
  50871. totalInertia21 = 0;
  50872. totalInertia22 = 0;
  50873. var totalMass = 0;
  50874. var s = this._shapeList;
  50875. while(s != null) {
  50876. var n = s._next;
  50877. var g = s._geom;
  50878. g._updateMass();
  50879. var mass = s._density * g._volume;
  50880. var inertia;
  50881. var inertia00;
  50882. var inertia01;
  50883. var inertia02;
  50884. var inertia10;
  50885. var inertia11;
  50886. var inertia12;
  50887. var inertia20;
  50888. var inertia21;
  50889. var inertia22;
  50890. var __tmp__00;
  50891. var __tmp__01;
  50892. var __tmp__02;
  50893. var __tmp__10;
  50894. var __tmp__11;
  50895. var __tmp__12;
  50896. var __tmp__20;
  50897. var __tmp__21;
  50898. var __tmp__22;
  50899. __tmp__00 = s._localTransform._rotation00 * g._inertiaCoeff00 + s._localTransform._rotation01 * g._inertiaCoeff10 + s._localTransform._rotation02 * g._inertiaCoeff20;
  50900. __tmp__01 = s._localTransform._rotation00 * g._inertiaCoeff01 + s._localTransform._rotation01 * g._inertiaCoeff11 + s._localTransform._rotation02 * g._inertiaCoeff21;
  50901. __tmp__02 = s._localTransform._rotation00 * g._inertiaCoeff02 + s._localTransform._rotation01 * g._inertiaCoeff12 + s._localTransform._rotation02 * g._inertiaCoeff22;
  50902. __tmp__10 = s._localTransform._rotation10 * g._inertiaCoeff00 + s._localTransform._rotation11 * g._inertiaCoeff10 + s._localTransform._rotation12 * g._inertiaCoeff20;
  50903. __tmp__11 = s._localTransform._rotation10 * g._inertiaCoeff01 + s._localTransform._rotation11 * g._inertiaCoeff11 + s._localTransform._rotation12 * g._inertiaCoeff21;
  50904. __tmp__12 = s._localTransform._rotation10 * g._inertiaCoeff02 + s._localTransform._rotation11 * g._inertiaCoeff12 + s._localTransform._rotation12 * g._inertiaCoeff22;
  50905. __tmp__20 = s._localTransform._rotation20 * g._inertiaCoeff00 + s._localTransform._rotation21 * g._inertiaCoeff10 + s._localTransform._rotation22 * g._inertiaCoeff20;
  50906. __tmp__21 = s._localTransform._rotation20 * g._inertiaCoeff01 + s._localTransform._rotation21 * g._inertiaCoeff11 + s._localTransform._rotation22 * g._inertiaCoeff21;
  50907. __tmp__22 = s._localTransform._rotation20 * g._inertiaCoeff02 + s._localTransform._rotation21 * g._inertiaCoeff12 + s._localTransform._rotation22 * g._inertiaCoeff22;
  50908. inertia00 = __tmp__00;
  50909. inertia01 = __tmp__01;
  50910. inertia02 = __tmp__02;
  50911. inertia10 = __tmp__10;
  50912. inertia11 = __tmp__11;
  50913. inertia12 = __tmp__12;
  50914. inertia20 = __tmp__20;
  50915. inertia21 = __tmp__21;
  50916. inertia22 = __tmp__22;
  50917. var __tmp__001;
  50918. var __tmp__011;
  50919. var __tmp__021;
  50920. var __tmp__101;
  50921. var __tmp__111;
  50922. var __tmp__121;
  50923. var __tmp__201;
  50924. var __tmp__211;
  50925. var __tmp__221;
  50926. __tmp__001 = inertia00 * s._localTransform._rotation00 + inertia01 * s._localTransform._rotation01 + inertia02 * s._localTransform._rotation02;
  50927. __tmp__011 = inertia00 * s._localTransform._rotation10 + inertia01 * s._localTransform._rotation11 + inertia02 * s._localTransform._rotation12;
  50928. __tmp__021 = inertia00 * s._localTransform._rotation20 + inertia01 * s._localTransform._rotation21 + inertia02 * s._localTransform._rotation22;
  50929. __tmp__101 = inertia10 * s._localTransform._rotation00 + inertia11 * s._localTransform._rotation01 + inertia12 * s._localTransform._rotation02;
  50930. __tmp__111 = inertia10 * s._localTransform._rotation10 + inertia11 * s._localTransform._rotation11 + inertia12 * s._localTransform._rotation12;
  50931. __tmp__121 = inertia10 * s._localTransform._rotation20 + inertia11 * s._localTransform._rotation21 + inertia12 * s._localTransform._rotation22;
  50932. __tmp__201 = inertia20 * s._localTransform._rotation00 + inertia21 * s._localTransform._rotation01 + inertia22 * s._localTransform._rotation02;
  50933. __tmp__211 = inertia20 * s._localTransform._rotation10 + inertia21 * s._localTransform._rotation11 + inertia22 * s._localTransform._rotation12;
  50934. __tmp__221 = inertia20 * s._localTransform._rotation20 + inertia21 * s._localTransform._rotation21 + inertia22 * s._localTransform._rotation22;
  50935. inertia00 = __tmp__001;
  50936. inertia01 = __tmp__011;
  50937. inertia02 = __tmp__021;
  50938. inertia10 = __tmp__101;
  50939. inertia11 = __tmp__111;
  50940. inertia12 = __tmp__121;
  50941. inertia20 = __tmp__201;
  50942. inertia21 = __tmp__211;
  50943. inertia22 = __tmp__221;
  50944. inertia00 *= mass;
  50945. inertia01 *= mass;
  50946. inertia02 *= mass;
  50947. inertia10 *= mass;
  50948. inertia11 *= mass;
  50949. inertia12 *= mass;
  50950. inertia20 *= mass;
  50951. inertia21 *= mass;
  50952. inertia22 *= mass;
  50953. var cogInertia;
  50954. var cogInertia00;
  50955. var cogInertia01;
  50956. var cogInertia02;
  50957. var cogInertia10;
  50958. var cogInertia11;
  50959. var cogInertia12;
  50960. var cogInertia20;
  50961. var cogInertia21;
  50962. var cogInertia22;
  50963. var xx = s._localTransform._positionX * s._localTransform._positionX;
  50964. var yy = s._localTransform._positionY * s._localTransform._positionY;
  50965. var zz = s._localTransform._positionZ * s._localTransform._positionZ;
  50966. var xy = -s._localTransform._positionX * s._localTransform._positionY;
  50967. var yz = -s._localTransform._positionY * s._localTransform._positionZ;
  50968. var zx = -s._localTransform._positionZ * s._localTransform._positionX;
  50969. cogInertia00 = yy + zz;
  50970. cogInertia01 = xy;
  50971. cogInertia02 = zx;
  50972. cogInertia10 = xy;
  50973. cogInertia11 = xx + zz;
  50974. cogInertia12 = yz;
  50975. cogInertia20 = zx;
  50976. cogInertia21 = yz;
  50977. cogInertia22 = xx + yy;
  50978. inertia00 += cogInertia00 * mass;
  50979. inertia01 += cogInertia01 * mass;
  50980. inertia02 += cogInertia02 * mass;
  50981. inertia10 += cogInertia10 * mass;
  50982. inertia11 += cogInertia11 * mass;
  50983. inertia12 += cogInertia12 * mass;
  50984. inertia20 += cogInertia20 * mass;
  50985. inertia21 += cogInertia21 * mass;
  50986. inertia22 += cogInertia22 * mass;
  50987. totalMass += mass;
  50988. totalInertia00 += inertia00;
  50989. totalInertia01 += inertia01;
  50990. totalInertia02 += inertia02;
  50991. totalInertia10 += inertia10;
  50992. totalInertia11 += inertia11;
  50993. totalInertia12 += inertia12;
  50994. totalInertia20 += inertia20;
  50995. totalInertia21 += inertia21;
  50996. totalInertia22 += inertia22;
  50997. s = n;
  50998. }
  50999. this._mass = totalMass;
  51000. this._localInertia00 = totalInertia00;
  51001. this._localInertia01 = totalInertia01;
  51002. this._localInertia02 = totalInertia02;
  51003. this._localInertia10 = totalInertia10;
  51004. this._localInertia11 = totalInertia11;
  51005. this._localInertia12 = totalInertia12;
  51006. this._localInertia20 = totalInertia20;
  51007. this._localInertia21 = totalInertia21;
  51008. this._localInertia22 = totalInertia22;
  51009. var d00 = this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21;
  51010. var d01 = this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20;
  51011. var d02 = this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20;
  51012. var det = this._localInertia00 * d00 - this._localInertia01 * d01 + this._localInertia02 * d02;
  51013. if(this._mass > 0 && det > 0 && this._type == 0) {
  51014. this._invMass = 1 / this._mass;
  51015. var d001 = this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21;
  51016. var d011 = this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20;
  51017. var d021 = this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20;
  51018. var d10 = this._localInertia01 * this._localInertia22 - this._localInertia02 * this._localInertia21;
  51019. var d11 = this._localInertia00 * this._localInertia22 - this._localInertia02 * this._localInertia20;
  51020. var d12 = this._localInertia00 * this._localInertia21 - this._localInertia01 * this._localInertia20;
  51021. var d20 = this._localInertia01 * this._localInertia12 - this._localInertia02 * this._localInertia11;
  51022. var d21 = this._localInertia00 * this._localInertia12 - this._localInertia02 * this._localInertia10;
  51023. var d22 = this._localInertia00 * this._localInertia11 - this._localInertia01 * this._localInertia10;
  51024. var d = this._localInertia00 * d001 - this._localInertia01 * d011 + this._localInertia02 * d021;
  51025. if(d < -1e-32 || d > 1e-32) {
  51026. d = 1 / d;
  51027. }
  51028. this._invLocalInertia00 = d001 * d;
  51029. this._invLocalInertia01 = -d10 * d;
  51030. this._invLocalInertia02 = d20 * d;
  51031. this._invLocalInertia10 = -d011 * d;
  51032. this._invLocalInertia11 = d11 * d;
  51033. this._invLocalInertia12 = -d21 * d;
  51034. this._invLocalInertia20 = d021 * d;
  51035. this._invLocalInertia21 = -d12 * d;
  51036. this._invLocalInertia22 = d22 * d;
  51037. this._invLocalInertiaWithoutRotFactor00 = this._invLocalInertia00;
  51038. this._invLocalInertiaWithoutRotFactor01 = this._invLocalInertia01;
  51039. this._invLocalInertiaWithoutRotFactor02 = this._invLocalInertia02;
  51040. this._invLocalInertiaWithoutRotFactor10 = this._invLocalInertia10;
  51041. this._invLocalInertiaWithoutRotFactor11 = this._invLocalInertia11;
  51042. this._invLocalInertiaWithoutRotFactor12 = this._invLocalInertia12;
  51043. this._invLocalInertiaWithoutRotFactor20 = this._invLocalInertia20;
  51044. this._invLocalInertiaWithoutRotFactor21 = this._invLocalInertia21;
  51045. this._invLocalInertiaWithoutRotFactor22 = this._invLocalInertia22;
  51046. this._invLocalInertia00 = this._invLocalInertiaWithoutRotFactor00 * this._rotFactor.x;
  51047. this._invLocalInertia01 = this._invLocalInertiaWithoutRotFactor01 * this._rotFactor.x;
  51048. this._invLocalInertia02 = this._invLocalInertiaWithoutRotFactor02 * this._rotFactor.x;
  51049. this._invLocalInertia10 = this._invLocalInertiaWithoutRotFactor10 * this._rotFactor.y;
  51050. this._invLocalInertia11 = this._invLocalInertiaWithoutRotFactor11 * this._rotFactor.y;
  51051. this._invLocalInertia12 = this._invLocalInertiaWithoutRotFactor12 * this._rotFactor.y;
  51052. this._invLocalInertia20 = this._invLocalInertiaWithoutRotFactor20 * this._rotFactor.z;
  51053. this._invLocalInertia21 = this._invLocalInertiaWithoutRotFactor21 * this._rotFactor.z;
  51054. this._invLocalInertia22 = this._invLocalInertiaWithoutRotFactor22 * this._rotFactor.z;
  51055. } else {
  51056. this._invMass = 0;
  51057. this._invLocalInertia00 = 0;
  51058. this._invLocalInertia01 = 0;
  51059. this._invLocalInertia02 = 0;
  51060. this._invLocalInertia10 = 0;
  51061. this._invLocalInertia11 = 0;
  51062. this._invLocalInertia12 = 0;
  51063. this._invLocalInertia20 = 0;
  51064. this._invLocalInertia21 = 0;
  51065. this._invLocalInertia22 = 0;
  51066. this._invLocalInertiaWithoutRotFactor00 = 0;
  51067. this._invLocalInertiaWithoutRotFactor01 = 0;
  51068. this._invLocalInertiaWithoutRotFactor02 = 0;
  51069. this._invLocalInertiaWithoutRotFactor10 = 0;
  51070. this._invLocalInertiaWithoutRotFactor11 = 0;
  51071. this._invLocalInertiaWithoutRotFactor12 = 0;
  51072. this._invLocalInertiaWithoutRotFactor20 = 0;
  51073. this._invLocalInertiaWithoutRotFactor21 = 0;
  51074. this._invLocalInertiaWithoutRotFactor22 = 0;
  51075. if(this._type == 0) {
  51076. this._type = 1;
  51077. }
  51078. }
  51079. var __tmp__002;
  51080. var __tmp__012;
  51081. var __tmp__022;
  51082. var __tmp__102;
  51083. var __tmp__112;
  51084. var __tmp__122;
  51085. var __tmp__202;
  51086. var __tmp__212;
  51087. var __tmp__222;
  51088. __tmp__002 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  51089. __tmp__012 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  51090. __tmp__022 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  51091. __tmp__102 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  51092. __tmp__112 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  51093. __tmp__122 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  51094. __tmp__202 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  51095. __tmp__212 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  51096. __tmp__222 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  51097. this._invInertia00 = __tmp__002;
  51098. this._invInertia01 = __tmp__012;
  51099. this._invInertia02 = __tmp__022;
  51100. this._invInertia10 = __tmp__102;
  51101. this._invInertia11 = __tmp__112;
  51102. this._invInertia12 = __tmp__122;
  51103. this._invInertia20 = __tmp__202;
  51104. this._invInertia21 = __tmp__212;
  51105. this._invInertia22 = __tmp__222;
  51106. var __tmp__003;
  51107. var __tmp__013;
  51108. var __tmp__023;
  51109. var __tmp__103;
  51110. var __tmp__113;
  51111. var __tmp__123;
  51112. var __tmp__203;
  51113. var __tmp__213;
  51114. var __tmp__223;
  51115. __tmp__003 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  51116. __tmp__013 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  51117. __tmp__023 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  51118. __tmp__103 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  51119. __tmp__113 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  51120. __tmp__123 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  51121. __tmp__203 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  51122. __tmp__213 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  51123. __tmp__223 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  51124. this._invInertia00 = __tmp__003;
  51125. this._invInertia01 = __tmp__013;
  51126. this._invInertia02 = __tmp__023;
  51127. this._invInertia10 = __tmp__103;
  51128. this._invInertia11 = __tmp__113;
  51129. this._invInertia12 = __tmp__123;
  51130. this._invInertia20 = __tmp__203;
  51131. this._invInertia21 = __tmp__213;
  51132. this._invInertia22 = __tmp__223;
  51133. this._invInertia00 *= this._rotFactor.x;
  51134. this._invInertia01 *= this._rotFactor.x;
  51135. this._invInertia02 *= this._rotFactor.x;
  51136. this._invInertia10 *= this._rotFactor.y;
  51137. this._invInertia11 *= this._rotFactor.y;
  51138. this._invInertia12 *= this._rotFactor.y;
  51139. this._invInertia20 *= this._rotFactor.z;
  51140. this._invInertia21 *= this._rotFactor.z;
  51141. this._invInertia22 *= this._rotFactor.z;
  51142. this._sleeping = false;
  51143. this._sleepTime = 0;
  51144. }
  51145. getPosition() {
  51146. var v = new oimo.common.Vec3();
  51147. var v1 = v;
  51148. v1.x = this._transform._positionX;
  51149. v1.y = this._transform._positionY;
  51150. v1.z = this._transform._positionZ;
  51151. return v;
  51152. }
  51153. getPositionTo(position) {
  51154. var v = position;
  51155. v.x = this._transform._positionX;
  51156. v.y = this._transform._positionY;
  51157. v.z = this._transform._positionZ;
  51158. }
  51159. setPosition(position) {
  51160. var v = position;
  51161. this._transform._positionX = v.x;
  51162. this._transform._positionY = v.y;
  51163. this._transform._positionZ = v.z;
  51164. var dst = this._ptransform;
  51165. var src = this._transform;
  51166. dst._positionX = src._positionX;
  51167. dst._positionY = src._positionY;
  51168. dst._positionZ = src._positionZ;
  51169. dst._rotation00 = src._rotation00;
  51170. dst._rotation01 = src._rotation01;
  51171. dst._rotation02 = src._rotation02;
  51172. dst._rotation10 = src._rotation10;
  51173. dst._rotation11 = src._rotation11;
  51174. dst._rotation12 = src._rotation12;
  51175. dst._rotation20 = src._rotation20;
  51176. dst._rotation21 = src._rotation21;
  51177. dst._rotation22 = src._rotation22;
  51178. var s = this._shapeList;
  51179. while(s != null) {
  51180. var n = s._next;
  51181. var dst1 = s._ptransform;
  51182. var src1 = s._localTransform;
  51183. var src2 = this._ptransform;
  51184. var __tmp__00;
  51185. var __tmp__01;
  51186. var __tmp__02;
  51187. var __tmp__10;
  51188. var __tmp__11;
  51189. var __tmp__12;
  51190. var __tmp__20;
  51191. var __tmp__21;
  51192. var __tmp__22;
  51193. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  51194. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  51195. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  51196. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  51197. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  51198. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  51199. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  51200. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  51201. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  51202. dst1._rotation00 = __tmp__00;
  51203. dst1._rotation01 = __tmp__01;
  51204. dst1._rotation02 = __tmp__02;
  51205. dst1._rotation10 = __tmp__10;
  51206. dst1._rotation11 = __tmp__11;
  51207. dst1._rotation12 = __tmp__12;
  51208. dst1._rotation20 = __tmp__20;
  51209. dst1._rotation21 = __tmp__21;
  51210. dst1._rotation22 = __tmp__22;
  51211. var __tmp__X;
  51212. var __tmp__Y;
  51213. var __tmp__Z;
  51214. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  51215. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  51216. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  51217. dst1._positionX = __tmp__X;
  51218. dst1._positionY = __tmp__Y;
  51219. dst1._positionZ = __tmp__Z;
  51220. dst1._positionX += src2._positionX;
  51221. dst1._positionY += src2._positionY;
  51222. dst1._positionZ += src2._positionZ;
  51223. var dst2 = s._transform;
  51224. var src11 = s._localTransform;
  51225. var src21 = this._transform;
  51226. var __tmp__001;
  51227. var __tmp__011;
  51228. var __tmp__021;
  51229. var __tmp__101;
  51230. var __tmp__111;
  51231. var __tmp__121;
  51232. var __tmp__201;
  51233. var __tmp__211;
  51234. var __tmp__221;
  51235. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  51236. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  51237. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  51238. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  51239. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  51240. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  51241. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  51242. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  51243. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  51244. dst2._rotation00 = __tmp__001;
  51245. dst2._rotation01 = __tmp__011;
  51246. dst2._rotation02 = __tmp__021;
  51247. dst2._rotation10 = __tmp__101;
  51248. dst2._rotation11 = __tmp__111;
  51249. dst2._rotation12 = __tmp__121;
  51250. dst2._rotation20 = __tmp__201;
  51251. dst2._rotation21 = __tmp__211;
  51252. dst2._rotation22 = __tmp__221;
  51253. var __tmp__X1;
  51254. var __tmp__Y1;
  51255. var __tmp__Z1;
  51256. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  51257. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  51258. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  51259. dst2._positionX = __tmp__X1;
  51260. dst2._positionY = __tmp__Y1;
  51261. dst2._positionZ = __tmp__Z1;
  51262. dst2._positionX += src21._positionX;
  51263. dst2._positionY += src21._positionY;
  51264. dst2._positionZ += src21._positionZ;
  51265. var min;
  51266. var minX;
  51267. var minY;
  51268. var minZ;
  51269. var max;
  51270. var maxX;
  51271. var maxY;
  51272. var maxZ;
  51273. s._geom._computeAabb(s._aabb,s._ptransform);
  51274. minX = s._aabb._minX;
  51275. minY = s._aabb._minY;
  51276. minZ = s._aabb._minZ;
  51277. maxX = s._aabb._maxX;
  51278. maxY = s._aabb._maxY;
  51279. maxZ = s._aabb._maxZ;
  51280. s._geom._computeAabb(s._aabb,s._transform);
  51281. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  51282. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  51283. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  51284. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  51285. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  51286. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  51287. if(s._proxy != null) {
  51288. var d;
  51289. var dX;
  51290. var dY;
  51291. var dZ;
  51292. dX = s._transform._positionX - s._ptransform._positionX;
  51293. dY = s._transform._positionY - s._ptransform._positionY;
  51294. dZ = s._transform._positionZ - s._ptransform._positionZ;
  51295. var v1 = s.displacement;
  51296. v1.x = dX;
  51297. v1.y = dY;
  51298. v1.z = dZ;
  51299. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  51300. }
  51301. s = n;
  51302. }
  51303. this._sleeping = false;
  51304. this._sleepTime = 0;
  51305. }
  51306. translate(translation) {
  51307. var diff;
  51308. var diffX;
  51309. var diffY;
  51310. var diffZ;
  51311. var v = translation;
  51312. diffX = v.x;
  51313. diffY = v.y;
  51314. diffZ = v.z;
  51315. this._transform._positionX += diffX;
  51316. this._transform._positionY += diffY;
  51317. this._transform._positionZ += diffZ;
  51318. var dst = this._ptransform;
  51319. var src = this._transform;
  51320. dst._positionX = src._positionX;
  51321. dst._positionY = src._positionY;
  51322. dst._positionZ = src._positionZ;
  51323. dst._rotation00 = src._rotation00;
  51324. dst._rotation01 = src._rotation01;
  51325. dst._rotation02 = src._rotation02;
  51326. dst._rotation10 = src._rotation10;
  51327. dst._rotation11 = src._rotation11;
  51328. dst._rotation12 = src._rotation12;
  51329. dst._rotation20 = src._rotation20;
  51330. dst._rotation21 = src._rotation21;
  51331. dst._rotation22 = src._rotation22;
  51332. var s = this._shapeList;
  51333. while(s != null) {
  51334. var n = s._next;
  51335. var dst1 = s._ptransform;
  51336. var src1 = s._localTransform;
  51337. var src2 = this._ptransform;
  51338. var __tmp__00;
  51339. var __tmp__01;
  51340. var __tmp__02;
  51341. var __tmp__10;
  51342. var __tmp__11;
  51343. var __tmp__12;
  51344. var __tmp__20;
  51345. var __tmp__21;
  51346. var __tmp__22;
  51347. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  51348. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  51349. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  51350. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  51351. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  51352. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  51353. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  51354. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  51355. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  51356. dst1._rotation00 = __tmp__00;
  51357. dst1._rotation01 = __tmp__01;
  51358. dst1._rotation02 = __tmp__02;
  51359. dst1._rotation10 = __tmp__10;
  51360. dst1._rotation11 = __tmp__11;
  51361. dst1._rotation12 = __tmp__12;
  51362. dst1._rotation20 = __tmp__20;
  51363. dst1._rotation21 = __tmp__21;
  51364. dst1._rotation22 = __tmp__22;
  51365. var __tmp__X;
  51366. var __tmp__Y;
  51367. var __tmp__Z;
  51368. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  51369. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  51370. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  51371. dst1._positionX = __tmp__X;
  51372. dst1._positionY = __tmp__Y;
  51373. dst1._positionZ = __tmp__Z;
  51374. dst1._positionX += src2._positionX;
  51375. dst1._positionY += src2._positionY;
  51376. dst1._positionZ += src2._positionZ;
  51377. var dst2 = s._transform;
  51378. var src11 = s._localTransform;
  51379. var src21 = this._transform;
  51380. var __tmp__001;
  51381. var __tmp__011;
  51382. var __tmp__021;
  51383. var __tmp__101;
  51384. var __tmp__111;
  51385. var __tmp__121;
  51386. var __tmp__201;
  51387. var __tmp__211;
  51388. var __tmp__221;
  51389. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  51390. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  51391. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  51392. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  51393. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  51394. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  51395. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  51396. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  51397. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  51398. dst2._rotation00 = __tmp__001;
  51399. dst2._rotation01 = __tmp__011;
  51400. dst2._rotation02 = __tmp__021;
  51401. dst2._rotation10 = __tmp__101;
  51402. dst2._rotation11 = __tmp__111;
  51403. dst2._rotation12 = __tmp__121;
  51404. dst2._rotation20 = __tmp__201;
  51405. dst2._rotation21 = __tmp__211;
  51406. dst2._rotation22 = __tmp__221;
  51407. var __tmp__X1;
  51408. var __tmp__Y1;
  51409. var __tmp__Z1;
  51410. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  51411. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  51412. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  51413. dst2._positionX = __tmp__X1;
  51414. dst2._positionY = __tmp__Y1;
  51415. dst2._positionZ = __tmp__Z1;
  51416. dst2._positionX += src21._positionX;
  51417. dst2._positionY += src21._positionY;
  51418. dst2._positionZ += src21._positionZ;
  51419. var min;
  51420. var minX;
  51421. var minY;
  51422. var minZ;
  51423. var max;
  51424. var maxX;
  51425. var maxY;
  51426. var maxZ;
  51427. s._geom._computeAabb(s._aabb,s._ptransform);
  51428. minX = s._aabb._minX;
  51429. minY = s._aabb._minY;
  51430. minZ = s._aabb._minZ;
  51431. maxX = s._aabb._maxX;
  51432. maxY = s._aabb._maxY;
  51433. maxZ = s._aabb._maxZ;
  51434. s._geom._computeAabb(s._aabb,s._transform);
  51435. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  51436. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  51437. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  51438. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  51439. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  51440. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  51441. if(s._proxy != null) {
  51442. var d;
  51443. var dX;
  51444. var dY;
  51445. var dZ;
  51446. dX = s._transform._positionX - s._ptransform._positionX;
  51447. dY = s._transform._positionY - s._ptransform._positionY;
  51448. dZ = s._transform._positionZ - s._ptransform._positionZ;
  51449. var v1 = s.displacement;
  51450. v1.x = dX;
  51451. v1.y = dY;
  51452. v1.z = dZ;
  51453. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  51454. }
  51455. s = n;
  51456. }
  51457. this._sleeping = false;
  51458. this._sleepTime = 0;
  51459. }
  51460. getRotation() {
  51461. var m = new oimo.common.Mat3();
  51462. var m1 = m;
  51463. m1.e00 = this._transform._rotation00;
  51464. m1.e01 = this._transform._rotation01;
  51465. m1.e02 = this._transform._rotation02;
  51466. m1.e10 = this._transform._rotation10;
  51467. m1.e11 = this._transform._rotation11;
  51468. m1.e12 = this._transform._rotation12;
  51469. m1.e20 = this._transform._rotation20;
  51470. m1.e21 = this._transform._rotation21;
  51471. m1.e22 = this._transform._rotation22;
  51472. return m;
  51473. }
  51474. getRotationTo(rotation) {
  51475. var m = rotation;
  51476. m.e00 = this._transform._rotation00;
  51477. m.e01 = this._transform._rotation01;
  51478. m.e02 = this._transform._rotation02;
  51479. m.e10 = this._transform._rotation10;
  51480. m.e11 = this._transform._rotation11;
  51481. m.e12 = this._transform._rotation12;
  51482. m.e20 = this._transform._rotation20;
  51483. m.e21 = this._transform._rotation21;
  51484. m.e22 = this._transform._rotation22;
  51485. }
  51486. setRotation(rotation) {
  51487. var m = rotation;
  51488. this._transform._rotation00 = m.e00;
  51489. this._transform._rotation01 = m.e01;
  51490. this._transform._rotation02 = m.e02;
  51491. this._transform._rotation10 = m.e10;
  51492. this._transform._rotation11 = m.e11;
  51493. this._transform._rotation12 = m.e12;
  51494. this._transform._rotation20 = m.e20;
  51495. this._transform._rotation21 = m.e21;
  51496. this._transform._rotation22 = m.e22;
  51497. var __tmp__00;
  51498. var __tmp__01;
  51499. var __tmp__02;
  51500. var __tmp__10;
  51501. var __tmp__11;
  51502. var __tmp__12;
  51503. var __tmp__20;
  51504. var __tmp__21;
  51505. var __tmp__22;
  51506. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  51507. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  51508. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  51509. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  51510. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  51511. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  51512. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  51513. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  51514. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  51515. this._invInertia00 = __tmp__00;
  51516. this._invInertia01 = __tmp__01;
  51517. this._invInertia02 = __tmp__02;
  51518. this._invInertia10 = __tmp__10;
  51519. this._invInertia11 = __tmp__11;
  51520. this._invInertia12 = __tmp__12;
  51521. this._invInertia20 = __tmp__20;
  51522. this._invInertia21 = __tmp__21;
  51523. this._invInertia22 = __tmp__22;
  51524. var __tmp__001;
  51525. var __tmp__011;
  51526. var __tmp__021;
  51527. var __tmp__101;
  51528. var __tmp__111;
  51529. var __tmp__121;
  51530. var __tmp__201;
  51531. var __tmp__211;
  51532. var __tmp__221;
  51533. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  51534. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  51535. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  51536. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  51537. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  51538. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  51539. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  51540. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  51541. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  51542. this._invInertia00 = __tmp__001;
  51543. this._invInertia01 = __tmp__011;
  51544. this._invInertia02 = __tmp__021;
  51545. this._invInertia10 = __tmp__101;
  51546. this._invInertia11 = __tmp__111;
  51547. this._invInertia12 = __tmp__121;
  51548. this._invInertia20 = __tmp__201;
  51549. this._invInertia21 = __tmp__211;
  51550. this._invInertia22 = __tmp__221;
  51551. this._invInertia00 *= this._rotFactor.x;
  51552. this._invInertia01 *= this._rotFactor.x;
  51553. this._invInertia02 *= this._rotFactor.x;
  51554. this._invInertia10 *= this._rotFactor.y;
  51555. this._invInertia11 *= this._rotFactor.y;
  51556. this._invInertia12 *= this._rotFactor.y;
  51557. this._invInertia20 *= this._rotFactor.z;
  51558. this._invInertia21 *= this._rotFactor.z;
  51559. this._invInertia22 *= this._rotFactor.z;
  51560. var dst = this._ptransform;
  51561. var src = this._transform;
  51562. dst._positionX = src._positionX;
  51563. dst._positionY = src._positionY;
  51564. dst._positionZ = src._positionZ;
  51565. dst._rotation00 = src._rotation00;
  51566. dst._rotation01 = src._rotation01;
  51567. dst._rotation02 = src._rotation02;
  51568. dst._rotation10 = src._rotation10;
  51569. dst._rotation11 = src._rotation11;
  51570. dst._rotation12 = src._rotation12;
  51571. dst._rotation20 = src._rotation20;
  51572. dst._rotation21 = src._rotation21;
  51573. dst._rotation22 = src._rotation22;
  51574. var s = this._shapeList;
  51575. while(s != null) {
  51576. var n = s._next;
  51577. var dst1 = s._ptransform;
  51578. var src1 = s._localTransform;
  51579. var src2 = this._ptransform;
  51580. var __tmp__002;
  51581. var __tmp__012;
  51582. var __tmp__022;
  51583. var __tmp__102;
  51584. var __tmp__112;
  51585. var __tmp__122;
  51586. var __tmp__202;
  51587. var __tmp__212;
  51588. var __tmp__222;
  51589. __tmp__002 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  51590. __tmp__012 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  51591. __tmp__022 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  51592. __tmp__102 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  51593. __tmp__112 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  51594. __tmp__122 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  51595. __tmp__202 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  51596. __tmp__212 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  51597. __tmp__222 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  51598. dst1._rotation00 = __tmp__002;
  51599. dst1._rotation01 = __tmp__012;
  51600. dst1._rotation02 = __tmp__022;
  51601. dst1._rotation10 = __tmp__102;
  51602. dst1._rotation11 = __tmp__112;
  51603. dst1._rotation12 = __tmp__122;
  51604. dst1._rotation20 = __tmp__202;
  51605. dst1._rotation21 = __tmp__212;
  51606. dst1._rotation22 = __tmp__222;
  51607. var __tmp__X;
  51608. var __tmp__Y;
  51609. var __tmp__Z;
  51610. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  51611. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  51612. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  51613. dst1._positionX = __tmp__X;
  51614. dst1._positionY = __tmp__Y;
  51615. dst1._positionZ = __tmp__Z;
  51616. dst1._positionX += src2._positionX;
  51617. dst1._positionY += src2._positionY;
  51618. dst1._positionZ += src2._positionZ;
  51619. var dst2 = s._transform;
  51620. var src11 = s._localTransform;
  51621. var src21 = this._transform;
  51622. var __tmp__003;
  51623. var __tmp__013;
  51624. var __tmp__023;
  51625. var __tmp__103;
  51626. var __tmp__113;
  51627. var __tmp__123;
  51628. var __tmp__203;
  51629. var __tmp__213;
  51630. var __tmp__223;
  51631. __tmp__003 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  51632. __tmp__013 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  51633. __tmp__023 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  51634. __tmp__103 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  51635. __tmp__113 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  51636. __tmp__123 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  51637. __tmp__203 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  51638. __tmp__213 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  51639. __tmp__223 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  51640. dst2._rotation00 = __tmp__003;
  51641. dst2._rotation01 = __tmp__013;
  51642. dst2._rotation02 = __tmp__023;
  51643. dst2._rotation10 = __tmp__103;
  51644. dst2._rotation11 = __tmp__113;
  51645. dst2._rotation12 = __tmp__123;
  51646. dst2._rotation20 = __tmp__203;
  51647. dst2._rotation21 = __tmp__213;
  51648. dst2._rotation22 = __tmp__223;
  51649. var __tmp__X1;
  51650. var __tmp__Y1;
  51651. var __tmp__Z1;
  51652. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  51653. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  51654. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  51655. dst2._positionX = __tmp__X1;
  51656. dst2._positionY = __tmp__Y1;
  51657. dst2._positionZ = __tmp__Z1;
  51658. dst2._positionX += src21._positionX;
  51659. dst2._positionY += src21._positionY;
  51660. dst2._positionZ += src21._positionZ;
  51661. var min;
  51662. var minX;
  51663. var minY;
  51664. var minZ;
  51665. var max;
  51666. var maxX;
  51667. var maxY;
  51668. var maxZ;
  51669. s._geom._computeAabb(s._aabb,s._ptransform);
  51670. minX = s._aabb._minX;
  51671. minY = s._aabb._minY;
  51672. minZ = s._aabb._minZ;
  51673. maxX = s._aabb._maxX;
  51674. maxY = s._aabb._maxY;
  51675. maxZ = s._aabb._maxZ;
  51676. s._geom._computeAabb(s._aabb,s._transform);
  51677. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  51678. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  51679. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  51680. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  51681. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  51682. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  51683. if(s._proxy != null) {
  51684. var d;
  51685. var dX;
  51686. var dY;
  51687. var dZ;
  51688. dX = s._transform._positionX - s._ptransform._positionX;
  51689. dY = s._transform._positionY - s._ptransform._positionY;
  51690. dZ = s._transform._positionZ - s._ptransform._positionZ;
  51691. var v = s.displacement;
  51692. v.x = dX;
  51693. v.y = dY;
  51694. v.z = dZ;
  51695. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  51696. }
  51697. s = n;
  51698. }
  51699. this._sleeping = false;
  51700. this._sleepTime = 0;
  51701. }
  51702. setRotationXyz(eulerAngles) {
  51703. var xyz;
  51704. var xyzX;
  51705. var xyzY;
  51706. var xyzZ;
  51707. var v = eulerAngles;
  51708. xyzX = v.x;
  51709. xyzY = v.y;
  51710. xyzZ = v.z;
  51711. var sx = Math.sin(xyzX);
  51712. var sy = Math.sin(xyzY);
  51713. var sz = Math.sin(xyzZ);
  51714. var cx = Math.cos(xyzX);
  51715. var cy = Math.cos(xyzY);
  51716. var cz = Math.cos(xyzZ);
  51717. this._transform._rotation00 = cy * cz;
  51718. this._transform._rotation01 = -cy * sz;
  51719. this._transform._rotation02 = sy;
  51720. this._transform._rotation10 = cx * sz + cz * sx * sy;
  51721. this._transform._rotation11 = cx * cz - sx * sy * sz;
  51722. this._transform._rotation12 = -cy * sx;
  51723. this._transform._rotation20 = sx * sz - cx * cz * sy;
  51724. this._transform._rotation21 = cz * sx + cx * sy * sz;
  51725. this._transform._rotation22 = cx * cy;
  51726. var __tmp__00;
  51727. var __tmp__01;
  51728. var __tmp__02;
  51729. var __tmp__10;
  51730. var __tmp__11;
  51731. var __tmp__12;
  51732. var __tmp__20;
  51733. var __tmp__21;
  51734. var __tmp__22;
  51735. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  51736. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  51737. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  51738. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  51739. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  51740. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  51741. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  51742. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  51743. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  51744. this._invInertia00 = __tmp__00;
  51745. this._invInertia01 = __tmp__01;
  51746. this._invInertia02 = __tmp__02;
  51747. this._invInertia10 = __tmp__10;
  51748. this._invInertia11 = __tmp__11;
  51749. this._invInertia12 = __tmp__12;
  51750. this._invInertia20 = __tmp__20;
  51751. this._invInertia21 = __tmp__21;
  51752. this._invInertia22 = __tmp__22;
  51753. var __tmp__001;
  51754. var __tmp__011;
  51755. var __tmp__021;
  51756. var __tmp__101;
  51757. var __tmp__111;
  51758. var __tmp__121;
  51759. var __tmp__201;
  51760. var __tmp__211;
  51761. var __tmp__221;
  51762. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  51763. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  51764. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  51765. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  51766. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  51767. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  51768. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  51769. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  51770. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  51771. this._invInertia00 = __tmp__001;
  51772. this._invInertia01 = __tmp__011;
  51773. this._invInertia02 = __tmp__021;
  51774. this._invInertia10 = __tmp__101;
  51775. this._invInertia11 = __tmp__111;
  51776. this._invInertia12 = __tmp__121;
  51777. this._invInertia20 = __tmp__201;
  51778. this._invInertia21 = __tmp__211;
  51779. this._invInertia22 = __tmp__221;
  51780. this._invInertia00 *= this._rotFactor.x;
  51781. this._invInertia01 *= this._rotFactor.x;
  51782. this._invInertia02 *= this._rotFactor.x;
  51783. this._invInertia10 *= this._rotFactor.y;
  51784. this._invInertia11 *= this._rotFactor.y;
  51785. this._invInertia12 *= this._rotFactor.y;
  51786. this._invInertia20 *= this._rotFactor.z;
  51787. this._invInertia21 *= this._rotFactor.z;
  51788. this._invInertia22 *= this._rotFactor.z;
  51789. var dst = this._ptransform;
  51790. var src = this._transform;
  51791. dst._positionX = src._positionX;
  51792. dst._positionY = src._positionY;
  51793. dst._positionZ = src._positionZ;
  51794. dst._rotation00 = src._rotation00;
  51795. dst._rotation01 = src._rotation01;
  51796. dst._rotation02 = src._rotation02;
  51797. dst._rotation10 = src._rotation10;
  51798. dst._rotation11 = src._rotation11;
  51799. dst._rotation12 = src._rotation12;
  51800. dst._rotation20 = src._rotation20;
  51801. dst._rotation21 = src._rotation21;
  51802. dst._rotation22 = src._rotation22;
  51803. var s = this._shapeList;
  51804. while(s != null) {
  51805. var n = s._next;
  51806. var dst1 = s._ptransform;
  51807. var src1 = s._localTransform;
  51808. var src2 = this._ptransform;
  51809. var __tmp__002;
  51810. var __tmp__012;
  51811. var __tmp__022;
  51812. var __tmp__102;
  51813. var __tmp__112;
  51814. var __tmp__122;
  51815. var __tmp__202;
  51816. var __tmp__212;
  51817. var __tmp__222;
  51818. __tmp__002 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  51819. __tmp__012 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  51820. __tmp__022 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  51821. __tmp__102 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  51822. __tmp__112 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  51823. __tmp__122 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  51824. __tmp__202 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  51825. __tmp__212 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  51826. __tmp__222 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  51827. dst1._rotation00 = __tmp__002;
  51828. dst1._rotation01 = __tmp__012;
  51829. dst1._rotation02 = __tmp__022;
  51830. dst1._rotation10 = __tmp__102;
  51831. dst1._rotation11 = __tmp__112;
  51832. dst1._rotation12 = __tmp__122;
  51833. dst1._rotation20 = __tmp__202;
  51834. dst1._rotation21 = __tmp__212;
  51835. dst1._rotation22 = __tmp__222;
  51836. var __tmp__X;
  51837. var __tmp__Y;
  51838. var __tmp__Z;
  51839. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  51840. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  51841. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  51842. dst1._positionX = __tmp__X;
  51843. dst1._positionY = __tmp__Y;
  51844. dst1._positionZ = __tmp__Z;
  51845. dst1._positionX += src2._positionX;
  51846. dst1._positionY += src2._positionY;
  51847. dst1._positionZ += src2._positionZ;
  51848. var dst2 = s._transform;
  51849. var src11 = s._localTransform;
  51850. var src21 = this._transform;
  51851. var __tmp__003;
  51852. var __tmp__013;
  51853. var __tmp__023;
  51854. var __tmp__103;
  51855. var __tmp__113;
  51856. var __tmp__123;
  51857. var __tmp__203;
  51858. var __tmp__213;
  51859. var __tmp__223;
  51860. __tmp__003 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  51861. __tmp__013 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  51862. __tmp__023 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  51863. __tmp__103 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  51864. __tmp__113 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  51865. __tmp__123 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  51866. __tmp__203 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  51867. __tmp__213 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  51868. __tmp__223 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  51869. dst2._rotation00 = __tmp__003;
  51870. dst2._rotation01 = __tmp__013;
  51871. dst2._rotation02 = __tmp__023;
  51872. dst2._rotation10 = __tmp__103;
  51873. dst2._rotation11 = __tmp__113;
  51874. dst2._rotation12 = __tmp__123;
  51875. dst2._rotation20 = __tmp__203;
  51876. dst2._rotation21 = __tmp__213;
  51877. dst2._rotation22 = __tmp__223;
  51878. var __tmp__X1;
  51879. var __tmp__Y1;
  51880. var __tmp__Z1;
  51881. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  51882. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  51883. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  51884. dst2._positionX = __tmp__X1;
  51885. dst2._positionY = __tmp__Y1;
  51886. dst2._positionZ = __tmp__Z1;
  51887. dst2._positionX += src21._positionX;
  51888. dst2._positionY += src21._positionY;
  51889. dst2._positionZ += src21._positionZ;
  51890. var min;
  51891. var minX;
  51892. var minY;
  51893. var minZ;
  51894. var max;
  51895. var maxX;
  51896. var maxY;
  51897. var maxZ;
  51898. s._geom._computeAabb(s._aabb,s._ptransform);
  51899. minX = s._aabb._minX;
  51900. minY = s._aabb._minY;
  51901. minZ = s._aabb._minZ;
  51902. maxX = s._aabb._maxX;
  51903. maxY = s._aabb._maxY;
  51904. maxZ = s._aabb._maxZ;
  51905. s._geom._computeAabb(s._aabb,s._transform);
  51906. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  51907. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  51908. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  51909. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  51910. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  51911. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  51912. if(s._proxy != null) {
  51913. var d;
  51914. var dX;
  51915. var dY;
  51916. var dZ;
  51917. dX = s._transform._positionX - s._ptransform._positionX;
  51918. dY = s._transform._positionY - s._ptransform._positionY;
  51919. dZ = s._transform._positionZ - s._ptransform._positionZ;
  51920. var v1 = s.displacement;
  51921. v1.x = dX;
  51922. v1.y = dY;
  51923. v1.z = dZ;
  51924. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  51925. }
  51926. s = n;
  51927. }
  51928. this._sleeping = false;
  51929. this._sleepTime = 0;
  51930. }
  51931. rotate(rotation) {
  51932. var rot;
  51933. var rot00;
  51934. var rot01;
  51935. var rot02;
  51936. var rot10;
  51937. var rot11;
  51938. var rot12;
  51939. var rot20;
  51940. var rot21;
  51941. var rot22;
  51942. var m = rotation;
  51943. rot00 = m.e00;
  51944. rot01 = m.e01;
  51945. rot02 = m.e02;
  51946. rot10 = m.e10;
  51947. rot11 = m.e11;
  51948. rot12 = m.e12;
  51949. rot20 = m.e20;
  51950. rot21 = m.e21;
  51951. rot22 = m.e22;
  51952. var __tmp__00;
  51953. var __tmp__01;
  51954. var __tmp__02;
  51955. var __tmp__10;
  51956. var __tmp__11;
  51957. var __tmp__12;
  51958. var __tmp__20;
  51959. var __tmp__21;
  51960. var __tmp__22;
  51961. __tmp__00 = rot00 * this._transform._rotation00 + rot01 * this._transform._rotation10 + rot02 * this._transform._rotation20;
  51962. __tmp__01 = rot00 * this._transform._rotation01 + rot01 * this._transform._rotation11 + rot02 * this._transform._rotation21;
  51963. __tmp__02 = rot00 * this._transform._rotation02 + rot01 * this._transform._rotation12 + rot02 * this._transform._rotation22;
  51964. __tmp__10 = rot10 * this._transform._rotation00 + rot11 * this._transform._rotation10 + rot12 * this._transform._rotation20;
  51965. __tmp__11 = rot10 * this._transform._rotation01 + rot11 * this._transform._rotation11 + rot12 * this._transform._rotation21;
  51966. __tmp__12 = rot10 * this._transform._rotation02 + rot11 * this._transform._rotation12 + rot12 * this._transform._rotation22;
  51967. __tmp__20 = rot20 * this._transform._rotation00 + rot21 * this._transform._rotation10 + rot22 * this._transform._rotation20;
  51968. __tmp__21 = rot20 * this._transform._rotation01 + rot21 * this._transform._rotation11 + rot22 * this._transform._rotation21;
  51969. __tmp__22 = rot20 * this._transform._rotation02 + rot21 * this._transform._rotation12 + rot22 * this._transform._rotation22;
  51970. this._transform._rotation00 = __tmp__00;
  51971. this._transform._rotation01 = __tmp__01;
  51972. this._transform._rotation02 = __tmp__02;
  51973. this._transform._rotation10 = __tmp__10;
  51974. this._transform._rotation11 = __tmp__11;
  51975. this._transform._rotation12 = __tmp__12;
  51976. this._transform._rotation20 = __tmp__20;
  51977. this._transform._rotation21 = __tmp__21;
  51978. this._transform._rotation22 = __tmp__22;
  51979. var __tmp__001;
  51980. var __tmp__011;
  51981. var __tmp__021;
  51982. var __tmp__101;
  51983. var __tmp__111;
  51984. var __tmp__121;
  51985. var __tmp__201;
  51986. var __tmp__211;
  51987. var __tmp__221;
  51988. __tmp__001 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  51989. __tmp__011 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  51990. __tmp__021 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  51991. __tmp__101 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  51992. __tmp__111 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  51993. __tmp__121 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  51994. __tmp__201 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  51995. __tmp__211 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  51996. __tmp__221 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  51997. this._invInertia00 = __tmp__001;
  51998. this._invInertia01 = __tmp__011;
  51999. this._invInertia02 = __tmp__021;
  52000. this._invInertia10 = __tmp__101;
  52001. this._invInertia11 = __tmp__111;
  52002. this._invInertia12 = __tmp__121;
  52003. this._invInertia20 = __tmp__201;
  52004. this._invInertia21 = __tmp__211;
  52005. this._invInertia22 = __tmp__221;
  52006. var __tmp__002;
  52007. var __tmp__012;
  52008. var __tmp__022;
  52009. var __tmp__102;
  52010. var __tmp__112;
  52011. var __tmp__122;
  52012. var __tmp__202;
  52013. var __tmp__212;
  52014. var __tmp__222;
  52015. __tmp__002 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  52016. __tmp__012 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  52017. __tmp__022 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  52018. __tmp__102 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  52019. __tmp__112 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  52020. __tmp__122 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  52021. __tmp__202 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  52022. __tmp__212 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  52023. __tmp__222 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  52024. this._invInertia00 = __tmp__002;
  52025. this._invInertia01 = __tmp__012;
  52026. this._invInertia02 = __tmp__022;
  52027. this._invInertia10 = __tmp__102;
  52028. this._invInertia11 = __tmp__112;
  52029. this._invInertia12 = __tmp__122;
  52030. this._invInertia20 = __tmp__202;
  52031. this._invInertia21 = __tmp__212;
  52032. this._invInertia22 = __tmp__222;
  52033. this._invInertia00 *= this._rotFactor.x;
  52034. this._invInertia01 *= this._rotFactor.x;
  52035. this._invInertia02 *= this._rotFactor.x;
  52036. this._invInertia10 *= this._rotFactor.y;
  52037. this._invInertia11 *= this._rotFactor.y;
  52038. this._invInertia12 *= this._rotFactor.y;
  52039. this._invInertia20 *= this._rotFactor.z;
  52040. this._invInertia21 *= this._rotFactor.z;
  52041. this._invInertia22 *= this._rotFactor.z;
  52042. var dst = this._ptransform;
  52043. var src = this._transform;
  52044. dst._positionX = src._positionX;
  52045. dst._positionY = src._positionY;
  52046. dst._positionZ = src._positionZ;
  52047. dst._rotation00 = src._rotation00;
  52048. dst._rotation01 = src._rotation01;
  52049. dst._rotation02 = src._rotation02;
  52050. dst._rotation10 = src._rotation10;
  52051. dst._rotation11 = src._rotation11;
  52052. dst._rotation12 = src._rotation12;
  52053. dst._rotation20 = src._rotation20;
  52054. dst._rotation21 = src._rotation21;
  52055. dst._rotation22 = src._rotation22;
  52056. var s = this._shapeList;
  52057. while(s != null) {
  52058. var n = s._next;
  52059. var dst1 = s._ptransform;
  52060. var src1 = s._localTransform;
  52061. var src2 = this._ptransform;
  52062. var __tmp__003;
  52063. var __tmp__013;
  52064. var __tmp__023;
  52065. var __tmp__103;
  52066. var __tmp__113;
  52067. var __tmp__123;
  52068. var __tmp__203;
  52069. var __tmp__213;
  52070. var __tmp__223;
  52071. __tmp__003 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  52072. __tmp__013 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  52073. __tmp__023 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  52074. __tmp__103 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  52075. __tmp__113 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  52076. __tmp__123 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  52077. __tmp__203 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  52078. __tmp__213 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  52079. __tmp__223 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  52080. dst1._rotation00 = __tmp__003;
  52081. dst1._rotation01 = __tmp__013;
  52082. dst1._rotation02 = __tmp__023;
  52083. dst1._rotation10 = __tmp__103;
  52084. dst1._rotation11 = __tmp__113;
  52085. dst1._rotation12 = __tmp__123;
  52086. dst1._rotation20 = __tmp__203;
  52087. dst1._rotation21 = __tmp__213;
  52088. dst1._rotation22 = __tmp__223;
  52089. var __tmp__X;
  52090. var __tmp__Y;
  52091. var __tmp__Z;
  52092. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  52093. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  52094. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  52095. dst1._positionX = __tmp__X;
  52096. dst1._positionY = __tmp__Y;
  52097. dst1._positionZ = __tmp__Z;
  52098. dst1._positionX += src2._positionX;
  52099. dst1._positionY += src2._positionY;
  52100. dst1._positionZ += src2._positionZ;
  52101. var dst2 = s._transform;
  52102. var src11 = s._localTransform;
  52103. var src21 = this._transform;
  52104. var __tmp__004;
  52105. var __tmp__014;
  52106. var __tmp__024;
  52107. var __tmp__104;
  52108. var __tmp__114;
  52109. var __tmp__124;
  52110. var __tmp__204;
  52111. var __tmp__214;
  52112. var __tmp__224;
  52113. __tmp__004 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  52114. __tmp__014 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  52115. __tmp__024 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  52116. __tmp__104 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  52117. __tmp__114 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  52118. __tmp__124 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  52119. __tmp__204 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  52120. __tmp__214 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  52121. __tmp__224 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  52122. dst2._rotation00 = __tmp__004;
  52123. dst2._rotation01 = __tmp__014;
  52124. dst2._rotation02 = __tmp__024;
  52125. dst2._rotation10 = __tmp__104;
  52126. dst2._rotation11 = __tmp__114;
  52127. dst2._rotation12 = __tmp__124;
  52128. dst2._rotation20 = __tmp__204;
  52129. dst2._rotation21 = __tmp__214;
  52130. dst2._rotation22 = __tmp__224;
  52131. var __tmp__X1;
  52132. var __tmp__Y1;
  52133. var __tmp__Z1;
  52134. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  52135. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  52136. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  52137. dst2._positionX = __tmp__X1;
  52138. dst2._positionY = __tmp__Y1;
  52139. dst2._positionZ = __tmp__Z1;
  52140. dst2._positionX += src21._positionX;
  52141. dst2._positionY += src21._positionY;
  52142. dst2._positionZ += src21._positionZ;
  52143. var min;
  52144. var minX;
  52145. var minY;
  52146. var minZ;
  52147. var max;
  52148. var maxX;
  52149. var maxY;
  52150. var maxZ;
  52151. s._geom._computeAabb(s._aabb,s._ptransform);
  52152. minX = s._aabb._minX;
  52153. minY = s._aabb._minY;
  52154. minZ = s._aabb._minZ;
  52155. maxX = s._aabb._maxX;
  52156. maxY = s._aabb._maxY;
  52157. maxZ = s._aabb._maxZ;
  52158. s._geom._computeAabb(s._aabb,s._transform);
  52159. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  52160. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  52161. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  52162. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  52163. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  52164. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  52165. if(s._proxy != null) {
  52166. var d;
  52167. var dX;
  52168. var dY;
  52169. var dZ;
  52170. dX = s._transform._positionX - s._ptransform._positionX;
  52171. dY = s._transform._positionY - s._ptransform._positionY;
  52172. dZ = s._transform._positionZ - s._ptransform._positionZ;
  52173. var v = s.displacement;
  52174. v.x = dX;
  52175. v.y = dY;
  52176. v.z = dZ;
  52177. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  52178. }
  52179. s = n;
  52180. }
  52181. this._sleeping = false;
  52182. this._sleepTime = 0;
  52183. }
  52184. rotateXyz(eulerAngles) {
  52185. var xyz;
  52186. var xyzX;
  52187. var xyzY;
  52188. var xyzZ;
  52189. var rot;
  52190. var rot00;
  52191. var rot01;
  52192. var rot02;
  52193. var rot10;
  52194. var rot11;
  52195. var rot12;
  52196. var rot20;
  52197. var rot21;
  52198. var rot22;
  52199. var v = eulerAngles;
  52200. xyzX = v.x;
  52201. xyzY = v.y;
  52202. xyzZ = v.z;
  52203. var sx = Math.sin(xyzX);
  52204. var sy = Math.sin(xyzY);
  52205. var sz = Math.sin(xyzZ);
  52206. var cx = Math.cos(xyzX);
  52207. var cy = Math.cos(xyzY);
  52208. var cz = Math.cos(xyzZ);
  52209. rot00 = cy * cz;
  52210. rot01 = -cy * sz;
  52211. rot02 = sy;
  52212. rot10 = cx * sz + cz * sx * sy;
  52213. rot11 = cx * cz - sx * sy * sz;
  52214. rot12 = -cy * sx;
  52215. rot20 = sx * sz - cx * cz * sy;
  52216. rot21 = cz * sx + cx * sy * sz;
  52217. rot22 = cx * cy;
  52218. var __tmp__00;
  52219. var __tmp__01;
  52220. var __tmp__02;
  52221. var __tmp__10;
  52222. var __tmp__11;
  52223. var __tmp__12;
  52224. var __tmp__20;
  52225. var __tmp__21;
  52226. var __tmp__22;
  52227. __tmp__00 = rot00 * this._transform._rotation00 + rot01 * this._transform._rotation10 + rot02 * this._transform._rotation20;
  52228. __tmp__01 = rot00 * this._transform._rotation01 + rot01 * this._transform._rotation11 + rot02 * this._transform._rotation21;
  52229. __tmp__02 = rot00 * this._transform._rotation02 + rot01 * this._transform._rotation12 + rot02 * this._transform._rotation22;
  52230. __tmp__10 = rot10 * this._transform._rotation00 + rot11 * this._transform._rotation10 + rot12 * this._transform._rotation20;
  52231. __tmp__11 = rot10 * this._transform._rotation01 + rot11 * this._transform._rotation11 + rot12 * this._transform._rotation21;
  52232. __tmp__12 = rot10 * this._transform._rotation02 + rot11 * this._transform._rotation12 + rot12 * this._transform._rotation22;
  52233. __tmp__20 = rot20 * this._transform._rotation00 + rot21 * this._transform._rotation10 + rot22 * this._transform._rotation20;
  52234. __tmp__21 = rot20 * this._transform._rotation01 + rot21 * this._transform._rotation11 + rot22 * this._transform._rotation21;
  52235. __tmp__22 = rot20 * this._transform._rotation02 + rot21 * this._transform._rotation12 + rot22 * this._transform._rotation22;
  52236. this._transform._rotation00 = __tmp__00;
  52237. this._transform._rotation01 = __tmp__01;
  52238. this._transform._rotation02 = __tmp__02;
  52239. this._transform._rotation10 = __tmp__10;
  52240. this._transform._rotation11 = __tmp__11;
  52241. this._transform._rotation12 = __tmp__12;
  52242. this._transform._rotation20 = __tmp__20;
  52243. this._transform._rotation21 = __tmp__21;
  52244. this._transform._rotation22 = __tmp__22;
  52245. var __tmp__001;
  52246. var __tmp__011;
  52247. var __tmp__021;
  52248. var __tmp__101;
  52249. var __tmp__111;
  52250. var __tmp__121;
  52251. var __tmp__201;
  52252. var __tmp__211;
  52253. var __tmp__221;
  52254. __tmp__001 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  52255. __tmp__011 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  52256. __tmp__021 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  52257. __tmp__101 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  52258. __tmp__111 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  52259. __tmp__121 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  52260. __tmp__201 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  52261. __tmp__211 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  52262. __tmp__221 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  52263. this._invInertia00 = __tmp__001;
  52264. this._invInertia01 = __tmp__011;
  52265. this._invInertia02 = __tmp__021;
  52266. this._invInertia10 = __tmp__101;
  52267. this._invInertia11 = __tmp__111;
  52268. this._invInertia12 = __tmp__121;
  52269. this._invInertia20 = __tmp__201;
  52270. this._invInertia21 = __tmp__211;
  52271. this._invInertia22 = __tmp__221;
  52272. var __tmp__002;
  52273. var __tmp__012;
  52274. var __tmp__022;
  52275. var __tmp__102;
  52276. var __tmp__112;
  52277. var __tmp__122;
  52278. var __tmp__202;
  52279. var __tmp__212;
  52280. var __tmp__222;
  52281. __tmp__002 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  52282. __tmp__012 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  52283. __tmp__022 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  52284. __tmp__102 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  52285. __tmp__112 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  52286. __tmp__122 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  52287. __tmp__202 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  52288. __tmp__212 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  52289. __tmp__222 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  52290. this._invInertia00 = __tmp__002;
  52291. this._invInertia01 = __tmp__012;
  52292. this._invInertia02 = __tmp__022;
  52293. this._invInertia10 = __tmp__102;
  52294. this._invInertia11 = __tmp__112;
  52295. this._invInertia12 = __tmp__122;
  52296. this._invInertia20 = __tmp__202;
  52297. this._invInertia21 = __tmp__212;
  52298. this._invInertia22 = __tmp__222;
  52299. this._invInertia00 *= this._rotFactor.x;
  52300. this._invInertia01 *= this._rotFactor.x;
  52301. this._invInertia02 *= this._rotFactor.x;
  52302. this._invInertia10 *= this._rotFactor.y;
  52303. this._invInertia11 *= this._rotFactor.y;
  52304. this._invInertia12 *= this._rotFactor.y;
  52305. this._invInertia20 *= this._rotFactor.z;
  52306. this._invInertia21 *= this._rotFactor.z;
  52307. this._invInertia22 *= this._rotFactor.z;
  52308. var dst = this._ptransform;
  52309. var src = this._transform;
  52310. dst._positionX = src._positionX;
  52311. dst._positionY = src._positionY;
  52312. dst._positionZ = src._positionZ;
  52313. dst._rotation00 = src._rotation00;
  52314. dst._rotation01 = src._rotation01;
  52315. dst._rotation02 = src._rotation02;
  52316. dst._rotation10 = src._rotation10;
  52317. dst._rotation11 = src._rotation11;
  52318. dst._rotation12 = src._rotation12;
  52319. dst._rotation20 = src._rotation20;
  52320. dst._rotation21 = src._rotation21;
  52321. dst._rotation22 = src._rotation22;
  52322. var s = this._shapeList;
  52323. while(s != null) {
  52324. var n = s._next;
  52325. var dst1 = s._ptransform;
  52326. var src1 = s._localTransform;
  52327. var src2 = this._ptransform;
  52328. var __tmp__003;
  52329. var __tmp__013;
  52330. var __tmp__023;
  52331. var __tmp__103;
  52332. var __tmp__113;
  52333. var __tmp__123;
  52334. var __tmp__203;
  52335. var __tmp__213;
  52336. var __tmp__223;
  52337. __tmp__003 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  52338. __tmp__013 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  52339. __tmp__023 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  52340. __tmp__103 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  52341. __tmp__113 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  52342. __tmp__123 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  52343. __tmp__203 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  52344. __tmp__213 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  52345. __tmp__223 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  52346. dst1._rotation00 = __tmp__003;
  52347. dst1._rotation01 = __tmp__013;
  52348. dst1._rotation02 = __tmp__023;
  52349. dst1._rotation10 = __tmp__103;
  52350. dst1._rotation11 = __tmp__113;
  52351. dst1._rotation12 = __tmp__123;
  52352. dst1._rotation20 = __tmp__203;
  52353. dst1._rotation21 = __tmp__213;
  52354. dst1._rotation22 = __tmp__223;
  52355. var __tmp__X;
  52356. var __tmp__Y;
  52357. var __tmp__Z;
  52358. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  52359. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  52360. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  52361. dst1._positionX = __tmp__X;
  52362. dst1._positionY = __tmp__Y;
  52363. dst1._positionZ = __tmp__Z;
  52364. dst1._positionX += src2._positionX;
  52365. dst1._positionY += src2._positionY;
  52366. dst1._positionZ += src2._positionZ;
  52367. var dst2 = s._transform;
  52368. var src11 = s._localTransform;
  52369. var src21 = this._transform;
  52370. var __tmp__004;
  52371. var __tmp__014;
  52372. var __tmp__024;
  52373. var __tmp__104;
  52374. var __tmp__114;
  52375. var __tmp__124;
  52376. var __tmp__204;
  52377. var __tmp__214;
  52378. var __tmp__224;
  52379. __tmp__004 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  52380. __tmp__014 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  52381. __tmp__024 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  52382. __tmp__104 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  52383. __tmp__114 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  52384. __tmp__124 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  52385. __tmp__204 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  52386. __tmp__214 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  52387. __tmp__224 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  52388. dst2._rotation00 = __tmp__004;
  52389. dst2._rotation01 = __tmp__014;
  52390. dst2._rotation02 = __tmp__024;
  52391. dst2._rotation10 = __tmp__104;
  52392. dst2._rotation11 = __tmp__114;
  52393. dst2._rotation12 = __tmp__124;
  52394. dst2._rotation20 = __tmp__204;
  52395. dst2._rotation21 = __tmp__214;
  52396. dst2._rotation22 = __tmp__224;
  52397. var __tmp__X1;
  52398. var __tmp__Y1;
  52399. var __tmp__Z1;
  52400. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  52401. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  52402. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  52403. dst2._positionX = __tmp__X1;
  52404. dst2._positionY = __tmp__Y1;
  52405. dst2._positionZ = __tmp__Z1;
  52406. dst2._positionX += src21._positionX;
  52407. dst2._positionY += src21._positionY;
  52408. dst2._positionZ += src21._positionZ;
  52409. var min;
  52410. var minX;
  52411. var minY;
  52412. var minZ;
  52413. var max;
  52414. var maxX;
  52415. var maxY;
  52416. var maxZ;
  52417. s._geom._computeAabb(s._aabb,s._ptransform);
  52418. minX = s._aabb._minX;
  52419. minY = s._aabb._minY;
  52420. minZ = s._aabb._minZ;
  52421. maxX = s._aabb._maxX;
  52422. maxY = s._aabb._maxY;
  52423. maxZ = s._aabb._maxZ;
  52424. s._geom._computeAabb(s._aabb,s._transform);
  52425. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  52426. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  52427. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  52428. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  52429. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  52430. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  52431. if(s._proxy != null) {
  52432. var d;
  52433. var dX;
  52434. var dY;
  52435. var dZ;
  52436. dX = s._transform._positionX - s._ptransform._positionX;
  52437. dY = s._transform._positionY - s._ptransform._positionY;
  52438. dZ = s._transform._positionZ - s._ptransform._positionZ;
  52439. var v1 = s.displacement;
  52440. v1.x = dX;
  52441. v1.y = dY;
  52442. v1.z = dZ;
  52443. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  52444. }
  52445. s = n;
  52446. }
  52447. this._sleeping = false;
  52448. this._sleepTime = 0;
  52449. }
  52450. getOrientation() {
  52451. var q = new oimo.common.Quat();
  52452. var iq;
  52453. var iqX;
  52454. var iqY;
  52455. var iqZ;
  52456. var iqW;
  52457. var e00 = this._transform._rotation00;
  52458. var e11 = this._transform._rotation11;
  52459. var e22 = this._transform._rotation22;
  52460. var t = e00 + e11 + e22;
  52461. var s;
  52462. if(t > 0) {
  52463. s = Math.sqrt(t + 1);
  52464. iqW = 0.5 * s;
  52465. s = 0.5 / s;
  52466. iqX = (this._transform._rotation21 - this._transform._rotation12) * s;
  52467. iqY = (this._transform._rotation02 - this._transform._rotation20) * s;
  52468. iqZ = (this._transform._rotation10 - this._transform._rotation01) * s;
  52469. } else if(e00 > e11) {
  52470. if(e00 > e22) {
  52471. s = Math.sqrt(e00 - e11 - e22 + 1);
  52472. iqX = 0.5 * s;
  52473. s = 0.5 / s;
  52474. iqY = (this._transform._rotation01 + this._transform._rotation10) * s;
  52475. iqZ = (this._transform._rotation02 + this._transform._rotation20) * s;
  52476. iqW = (this._transform._rotation21 - this._transform._rotation12) * s;
  52477. } else {
  52478. s = Math.sqrt(e22 - e00 - e11 + 1);
  52479. iqZ = 0.5 * s;
  52480. s = 0.5 / s;
  52481. iqX = (this._transform._rotation02 + this._transform._rotation20) * s;
  52482. iqY = (this._transform._rotation12 + this._transform._rotation21) * s;
  52483. iqW = (this._transform._rotation10 - this._transform._rotation01) * s;
  52484. }
  52485. } else if(e11 > e22) {
  52486. s = Math.sqrt(e11 - e22 - e00 + 1);
  52487. iqY = 0.5 * s;
  52488. s = 0.5 / s;
  52489. iqX = (this._transform._rotation01 + this._transform._rotation10) * s;
  52490. iqZ = (this._transform._rotation12 + this._transform._rotation21) * s;
  52491. iqW = (this._transform._rotation02 - this._transform._rotation20) * s;
  52492. } else {
  52493. s = Math.sqrt(e22 - e00 - e11 + 1);
  52494. iqZ = 0.5 * s;
  52495. s = 0.5 / s;
  52496. iqX = (this._transform._rotation02 + this._transform._rotation20) * s;
  52497. iqY = (this._transform._rotation12 + this._transform._rotation21) * s;
  52498. iqW = (this._transform._rotation10 - this._transform._rotation01) * s;
  52499. }
  52500. var q1 = q;
  52501. q1.x = iqX;
  52502. q1.y = iqY;
  52503. q1.z = iqZ;
  52504. q1.w = iqW;
  52505. return q;
  52506. }
  52507. getOrientationTo(orientation) {
  52508. var iq;
  52509. var iqX;
  52510. var iqY;
  52511. var iqZ;
  52512. var iqW;
  52513. var e00 = this._transform._rotation00;
  52514. var e11 = this._transform._rotation11;
  52515. var e22 = this._transform._rotation22;
  52516. var t = e00 + e11 + e22;
  52517. var s;
  52518. if(t > 0) {
  52519. s = Math.sqrt(t + 1);
  52520. iqW = 0.5 * s;
  52521. s = 0.5 / s;
  52522. iqX = (this._transform._rotation21 - this._transform._rotation12) * s;
  52523. iqY = (this._transform._rotation02 - this._transform._rotation20) * s;
  52524. iqZ = (this._transform._rotation10 - this._transform._rotation01) * s;
  52525. } else if(e00 > e11) {
  52526. if(e00 > e22) {
  52527. s = Math.sqrt(e00 - e11 - e22 + 1);
  52528. iqX = 0.5 * s;
  52529. s = 0.5 / s;
  52530. iqY = (this._transform._rotation01 + this._transform._rotation10) * s;
  52531. iqZ = (this._transform._rotation02 + this._transform._rotation20) * s;
  52532. iqW = (this._transform._rotation21 - this._transform._rotation12) * s;
  52533. } else {
  52534. s = Math.sqrt(e22 - e00 - e11 + 1);
  52535. iqZ = 0.5 * s;
  52536. s = 0.5 / s;
  52537. iqX = (this._transform._rotation02 + this._transform._rotation20) * s;
  52538. iqY = (this._transform._rotation12 + this._transform._rotation21) * s;
  52539. iqW = (this._transform._rotation10 - this._transform._rotation01) * s;
  52540. }
  52541. } else if(e11 > e22) {
  52542. s = Math.sqrt(e11 - e22 - e00 + 1);
  52543. iqY = 0.5 * s;
  52544. s = 0.5 / s;
  52545. iqX = (this._transform._rotation01 + this._transform._rotation10) * s;
  52546. iqZ = (this._transform._rotation12 + this._transform._rotation21) * s;
  52547. iqW = (this._transform._rotation02 - this._transform._rotation20) * s;
  52548. } else {
  52549. s = Math.sqrt(e22 - e00 - e11 + 1);
  52550. iqZ = 0.5 * s;
  52551. s = 0.5 / s;
  52552. iqX = (this._transform._rotation02 + this._transform._rotation20) * s;
  52553. iqY = (this._transform._rotation12 + this._transform._rotation21) * s;
  52554. iqW = (this._transform._rotation10 - this._transform._rotation01) * s;
  52555. }
  52556. var q = orientation;
  52557. q.x = iqX;
  52558. q.y = iqY;
  52559. q.z = iqZ;
  52560. q.w = iqW;
  52561. }
  52562. setOrientation(quaternion) {
  52563. var q;
  52564. var qX;
  52565. var qY;
  52566. var qZ;
  52567. var qW;
  52568. var q1 = quaternion;
  52569. qX = q1.x;
  52570. qY = q1.y;
  52571. qZ = q1.z;
  52572. qW = q1.w;
  52573. var x = qX;
  52574. var y = qY;
  52575. var z = qZ;
  52576. var w = qW;
  52577. var x2 = 2 * x;
  52578. var y2 = 2 * y;
  52579. var z2 = 2 * z;
  52580. var xx = x * x2;
  52581. var yy = y * y2;
  52582. var zz = z * z2;
  52583. var xy = x * y2;
  52584. var yz = y * z2;
  52585. var xz = x * z2;
  52586. var wx = w * x2;
  52587. var wy = w * y2;
  52588. var wz = w * z2;
  52589. this._transform._rotation00 = 1 - yy - zz;
  52590. this._transform._rotation01 = xy - wz;
  52591. this._transform._rotation02 = xz + wy;
  52592. this._transform._rotation10 = xy + wz;
  52593. this._transform._rotation11 = 1 - xx - zz;
  52594. this._transform._rotation12 = yz - wx;
  52595. this._transform._rotation20 = xz - wy;
  52596. this._transform._rotation21 = yz + wx;
  52597. this._transform._rotation22 = 1 - xx - yy;
  52598. var __tmp__00;
  52599. var __tmp__01;
  52600. var __tmp__02;
  52601. var __tmp__10;
  52602. var __tmp__11;
  52603. var __tmp__12;
  52604. var __tmp__20;
  52605. var __tmp__21;
  52606. var __tmp__22;
  52607. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  52608. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  52609. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  52610. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  52611. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  52612. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  52613. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  52614. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  52615. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  52616. this._invInertia00 = __tmp__00;
  52617. this._invInertia01 = __tmp__01;
  52618. this._invInertia02 = __tmp__02;
  52619. this._invInertia10 = __tmp__10;
  52620. this._invInertia11 = __tmp__11;
  52621. this._invInertia12 = __tmp__12;
  52622. this._invInertia20 = __tmp__20;
  52623. this._invInertia21 = __tmp__21;
  52624. this._invInertia22 = __tmp__22;
  52625. var __tmp__001;
  52626. var __tmp__011;
  52627. var __tmp__021;
  52628. var __tmp__101;
  52629. var __tmp__111;
  52630. var __tmp__121;
  52631. var __tmp__201;
  52632. var __tmp__211;
  52633. var __tmp__221;
  52634. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  52635. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  52636. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  52637. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  52638. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  52639. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  52640. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  52641. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  52642. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  52643. this._invInertia00 = __tmp__001;
  52644. this._invInertia01 = __tmp__011;
  52645. this._invInertia02 = __tmp__021;
  52646. this._invInertia10 = __tmp__101;
  52647. this._invInertia11 = __tmp__111;
  52648. this._invInertia12 = __tmp__121;
  52649. this._invInertia20 = __tmp__201;
  52650. this._invInertia21 = __tmp__211;
  52651. this._invInertia22 = __tmp__221;
  52652. this._invInertia00 *= this._rotFactor.x;
  52653. this._invInertia01 *= this._rotFactor.x;
  52654. this._invInertia02 *= this._rotFactor.x;
  52655. this._invInertia10 *= this._rotFactor.y;
  52656. this._invInertia11 *= this._rotFactor.y;
  52657. this._invInertia12 *= this._rotFactor.y;
  52658. this._invInertia20 *= this._rotFactor.z;
  52659. this._invInertia21 *= this._rotFactor.z;
  52660. this._invInertia22 *= this._rotFactor.z;
  52661. var dst = this._ptransform;
  52662. var src = this._transform;
  52663. dst._positionX = src._positionX;
  52664. dst._positionY = src._positionY;
  52665. dst._positionZ = src._positionZ;
  52666. dst._rotation00 = src._rotation00;
  52667. dst._rotation01 = src._rotation01;
  52668. dst._rotation02 = src._rotation02;
  52669. dst._rotation10 = src._rotation10;
  52670. dst._rotation11 = src._rotation11;
  52671. dst._rotation12 = src._rotation12;
  52672. dst._rotation20 = src._rotation20;
  52673. dst._rotation21 = src._rotation21;
  52674. dst._rotation22 = src._rotation22;
  52675. var s = this._shapeList;
  52676. while(s != null) {
  52677. var n = s._next;
  52678. var dst1 = s._ptransform;
  52679. var src1 = s._localTransform;
  52680. var src2 = this._ptransform;
  52681. var __tmp__002;
  52682. var __tmp__012;
  52683. var __tmp__022;
  52684. var __tmp__102;
  52685. var __tmp__112;
  52686. var __tmp__122;
  52687. var __tmp__202;
  52688. var __tmp__212;
  52689. var __tmp__222;
  52690. __tmp__002 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  52691. __tmp__012 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  52692. __tmp__022 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  52693. __tmp__102 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  52694. __tmp__112 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  52695. __tmp__122 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  52696. __tmp__202 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  52697. __tmp__212 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  52698. __tmp__222 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  52699. dst1._rotation00 = __tmp__002;
  52700. dst1._rotation01 = __tmp__012;
  52701. dst1._rotation02 = __tmp__022;
  52702. dst1._rotation10 = __tmp__102;
  52703. dst1._rotation11 = __tmp__112;
  52704. dst1._rotation12 = __tmp__122;
  52705. dst1._rotation20 = __tmp__202;
  52706. dst1._rotation21 = __tmp__212;
  52707. dst1._rotation22 = __tmp__222;
  52708. var __tmp__X;
  52709. var __tmp__Y;
  52710. var __tmp__Z;
  52711. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  52712. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  52713. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  52714. dst1._positionX = __tmp__X;
  52715. dst1._positionY = __tmp__Y;
  52716. dst1._positionZ = __tmp__Z;
  52717. dst1._positionX += src2._positionX;
  52718. dst1._positionY += src2._positionY;
  52719. dst1._positionZ += src2._positionZ;
  52720. var dst2 = s._transform;
  52721. var src11 = s._localTransform;
  52722. var src21 = this._transform;
  52723. var __tmp__003;
  52724. var __tmp__013;
  52725. var __tmp__023;
  52726. var __tmp__103;
  52727. var __tmp__113;
  52728. var __tmp__123;
  52729. var __tmp__203;
  52730. var __tmp__213;
  52731. var __tmp__223;
  52732. __tmp__003 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  52733. __tmp__013 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  52734. __tmp__023 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  52735. __tmp__103 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  52736. __tmp__113 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  52737. __tmp__123 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  52738. __tmp__203 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  52739. __tmp__213 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  52740. __tmp__223 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  52741. dst2._rotation00 = __tmp__003;
  52742. dst2._rotation01 = __tmp__013;
  52743. dst2._rotation02 = __tmp__023;
  52744. dst2._rotation10 = __tmp__103;
  52745. dst2._rotation11 = __tmp__113;
  52746. dst2._rotation12 = __tmp__123;
  52747. dst2._rotation20 = __tmp__203;
  52748. dst2._rotation21 = __tmp__213;
  52749. dst2._rotation22 = __tmp__223;
  52750. var __tmp__X1;
  52751. var __tmp__Y1;
  52752. var __tmp__Z1;
  52753. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  52754. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  52755. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  52756. dst2._positionX = __tmp__X1;
  52757. dst2._positionY = __tmp__Y1;
  52758. dst2._positionZ = __tmp__Z1;
  52759. dst2._positionX += src21._positionX;
  52760. dst2._positionY += src21._positionY;
  52761. dst2._positionZ += src21._positionZ;
  52762. var min;
  52763. var minX;
  52764. var minY;
  52765. var minZ;
  52766. var max;
  52767. var maxX;
  52768. var maxY;
  52769. var maxZ;
  52770. s._geom._computeAabb(s._aabb,s._ptransform);
  52771. minX = s._aabb._minX;
  52772. minY = s._aabb._minY;
  52773. minZ = s._aabb._minZ;
  52774. maxX = s._aabb._maxX;
  52775. maxY = s._aabb._maxY;
  52776. maxZ = s._aabb._maxZ;
  52777. s._geom._computeAabb(s._aabb,s._transform);
  52778. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  52779. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  52780. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  52781. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  52782. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  52783. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  52784. if(s._proxy != null) {
  52785. var d;
  52786. var dX;
  52787. var dY;
  52788. var dZ;
  52789. dX = s._transform._positionX - s._ptransform._positionX;
  52790. dY = s._transform._positionY - s._ptransform._positionY;
  52791. dZ = s._transform._positionZ - s._ptransform._positionZ;
  52792. var v = s.displacement;
  52793. v.x = dX;
  52794. v.y = dY;
  52795. v.z = dZ;
  52796. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  52797. }
  52798. s = n;
  52799. }
  52800. this._sleeping = false;
  52801. this._sleepTime = 0;
  52802. }
  52803. getTransform() {
  52804. var _this = this._transform;
  52805. var tf = new oimo.common.Transform();
  52806. tf._positionX = _this._positionX;
  52807. tf._positionY = _this._positionY;
  52808. tf._positionZ = _this._positionZ;
  52809. tf._rotation00 = _this._rotation00;
  52810. tf._rotation01 = _this._rotation01;
  52811. tf._rotation02 = _this._rotation02;
  52812. tf._rotation10 = _this._rotation10;
  52813. tf._rotation11 = _this._rotation11;
  52814. tf._rotation12 = _this._rotation12;
  52815. tf._rotation20 = _this._rotation20;
  52816. tf._rotation21 = _this._rotation21;
  52817. tf._rotation22 = _this._rotation22;
  52818. return tf;
  52819. }
  52820. getTransformTo(transform) {
  52821. var transform1 = this._transform;
  52822. transform._positionX = transform1._positionX;
  52823. transform._positionY = transform1._positionY;
  52824. transform._positionZ = transform1._positionZ;
  52825. transform._rotation00 = transform1._rotation00;
  52826. transform._rotation01 = transform1._rotation01;
  52827. transform._rotation02 = transform1._rotation02;
  52828. transform._rotation10 = transform1._rotation10;
  52829. transform._rotation11 = transform1._rotation11;
  52830. transform._rotation12 = transform1._rotation12;
  52831. transform._rotation20 = transform1._rotation20;
  52832. transform._rotation21 = transform1._rotation21;
  52833. transform._rotation22 = transform1._rotation22;
  52834. }
  52835. setTransform(transform) {
  52836. this._transform._positionX = transform._positionX;
  52837. this._transform._positionY = transform._positionY;
  52838. this._transform._positionZ = transform._positionZ;
  52839. this._transform._rotation00 = transform._rotation00;
  52840. this._transform._rotation01 = transform._rotation01;
  52841. this._transform._rotation02 = transform._rotation02;
  52842. this._transform._rotation10 = transform._rotation10;
  52843. this._transform._rotation11 = transform._rotation11;
  52844. this._transform._rotation12 = transform._rotation12;
  52845. this._transform._rotation20 = transform._rotation20;
  52846. this._transform._rotation21 = transform._rotation21;
  52847. this._transform._rotation22 = transform._rotation22;
  52848. var __tmp__00;
  52849. var __tmp__01;
  52850. var __tmp__02;
  52851. var __tmp__10;
  52852. var __tmp__11;
  52853. var __tmp__12;
  52854. var __tmp__20;
  52855. var __tmp__21;
  52856. var __tmp__22;
  52857. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  52858. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  52859. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  52860. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  52861. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  52862. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  52863. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  52864. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  52865. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  52866. this._invInertia00 = __tmp__00;
  52867. this._invInertia01 = __tmp__01;
  52868. this._invInertia02 = __tmp__02;
  52869. this._invInertia10 = __tmp__10;
  52870. this._invInertia11 = __tmp__11;
  52871. this._invInertia12 = __tmp__12;
  52872. this._invInertia20 = __tmp__20;
  52873. this._invInertia21 = __tmp__21;
  52874. this._invInertia22 = __tmp__22;
  52875. var __tmp__001;
  52876. var __tmp__011;
  52877. var __tmp__021;
  52878. var __tmp__101;
  52879. var __tmp__111;
  52880. var __tmp__121;
  52881. var __tmp__201;
  52882. var __tmp__211;
  52883. var __tmp__221;
  52884. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  52885. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  52886. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  52887. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  52888. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  52889. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  52890. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  52891. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  52892. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  52893. this._invInertia00 = __tmp__001;
  52894. this._invInertia01 = __tmp__011;
  52895. this._invInertia02 = __tmp__021;
  52896. this._invInertia10 = __tmp__101;
  52897. this._invInertia11 = __tmp__111;
  52898. this._invInertia12 = __tmp__121;
  52899. this._invInertia20 = __tmp__201;
  52900. this._invInertia21 = __tmp__211;
  52901. this._invInertia22 = __tmp__221;
  52902. this._invInertia00 *= this._rotFactor.x;
  52903. this._invInertia01 *= this._rotFactor.x;
  52904. this._invInertia02 *= this._rotFactor.x;
  52905. this._invInertia10 *= this._rotFactor.y;
  52906. this._invInertia11 *= this._rotFactor.y;
  52907. this._invInertia12 *= this._rotFactor.y;
  52908. this._invInertia20 *= this._rotFactor.z;
  52909. this._invInertia21 *= this._rotFactor.z;
  52910. this._invInertia22 *= this._rotFactor.z;
  52911. var dst = this._ptransform;
  52912. var src = this._transform;
  52913. dst._positionX = src._positionX;
  52914. dst._positionY = src._positionY;
  52915. dst._positionZ = src._positionZ;
  52916. dst._rotation00 = src._rotation00;
  52917. dst._rotation01 = src._rotation01;
  52918. dst._rotation02 = src._rotation02;
  52919. dst._rotation10 = src._rotation10;
  52920. dst._rotation11 = src._rotation11;
  52921. dst._rotation12 = src._rotation12;
  52922. dst._rotation20 = src._rotation20;
  52923. dst._rotation21 = src._rotation21;
  52924. dst._rotation22 = src._rotation22;
  52925. var s = this._shapeList;
  52926. while(s != null) {
  52927. var n = s._next;
  52928. var dst1 = s._ptransform;
  52929. var src1 = s._localTransform;
  52930. var src2 = this._ptransform;
  52931. var __tmp__002;
  52932. var __tmp__012;
  52933. var __tmp__022;
  52934. var __tmp__102;
  52935. var __tmp__112;
  52936. var __tmp__122;
  52937. var __tmp__202;
  52938. var __tmp__212;
  52939. var __tmp__222;
  52940. __tmp__002 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  52941. __tmp__012 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  52942. __tmp__022 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  52943. __tmp__102 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  52944. __tmp__112 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  52945. __tmp__122 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  52946. __tmp__202 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  52947. __tmp__212 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  52948. __tmp__222 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  52949. dst1._rotation00 = __tmp__002;
  52950. dst1._rotation01 = __tmp__012;
  52951. dst1._rotation02 = __tmp__022;
  52952. dst1._rotation10 = __tmp__102;
  52953. dst1._rotation11 = __tmp__112;
  52954. dst1._rotation12 = __tmp__122;
  52955. dst1._rotation20 = __tmp__202;
  52956. dst1._rotation21 = __tmp__212;
  52957. dst1._rotation22 = __tmp__222;
  52958. var __tmp__X;
  52959. var __tmp__Y;
  52960. var __tmp__Z;
  52961. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  52962. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  52963. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  52964. dst1._positionX = __tmp__X;
  52965. dst1._positionY = __tmp__Y;
  52966. dst1._positionZ = __tmp__Z;
  52967. dst1._positionX += src2._positionX;
  52968. dst1._positionY += src2._positionY;
  52969. dst1._positionZ += src2._positionZ;
  52970. var dst2 = s._transform;
  52971. var src11 = s._localTransform;
  52972. var src21 = this._transform;
  52973. var __tmp__003;
  52974. var __tmp__013;
  52975. var __tmp__023;
  52976. var __tmp__103;
  52977. var __tmp__113;
  52978. var __tmp__123;
  52979. var __tmp__203;
  52980. var __tmp__213;
  52981. var __tmp__223;
  52982. __tmp__003 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  52983. __tmp__013 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  52984. __tmp__023 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  52985. __tmp__103 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  52986. __tmp__113 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  52987. __tmp__123 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  52988. __tmp__203 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  52989. __tmp__213 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  52990. __tmp__223 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  52991. dst2._rotation00 = __tmp__003;
  52992. dst2._rotation01 = __tmp__013;
  52993. dst2._rotation02 = __tmp__023;
  52994. dst2._rotation10 = __tmp__103;
  52995. dst2._rotation11 = __tmp__113;
  52996. dst2._rotation12 = __tmp__123;
  52997. dst2._rotation20 = __tmp__203;
  52998. dst2._rotation21 = __tmp__213;
  52999. dst2._rotation22 = __tmp__223;
  53000. var __tmp__X1;
  53001. var __tmp__Y1;
  53002. var __tmp__Z1;
  53003. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  53004. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  53005. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  53006. dst2._positionX = __tmp__X1;
  53007. dst2._positionY = __tmp__Y1;
  53008. dst2._positionZ = __tmp__Z1;
  53009. dst2._positionX += src21._positionX;
  53010. dst2._positionY += src21._positionY;
  53011. dst2._positionZ += src21._positionZ;
  53012. var min;
  53013. var minX;
  53014. var minY;
  53015. var minZ;
  53016. var max;
  53017. var maxX;
  53018. var maxY;
  53019. var maxZ;
  53020. s._geom._computeAabb(s._aabb,s._ptransform);
  53021. minX = s._aabb._minX;
  53022. minY = s._aabb._minY;
  53023. minZ = s._aabb._minZ;
  53024. maxX = s._aabb._maxX;
  53025. maxY = s._aabb._maxY;
  53026. maxZ = s._aabb._maxZ;
  53027. s._geom._computeAabb(s._aabb,s._transform);
  53028. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  53029. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  53030. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  53031. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  53032. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  53033. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  53034. if(s._proxy != null) {
  53035. var d;
  53036. var dX;
  53037. var dY;
  53038. var dZ;
  53039. dX = s._transform._positionX - s._ptransform._positionX;
  53040. dY = s._transform._positionY - s._ptransform._positionY;
  53041. dZ = s._transform._positionZ - s._ptransform._positionZ;
  53042. var v = s.displacement;
  53043. v.x = dX;
  53044. v.y = dY;
  53045. v.z = dZ;
  53046. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  53047. }
  53048. s = n;
  53049. }
  53050. this._sleeping = false;
  53051. this._sleepTime = 0;
  53052. }
  53053. getMass() {
  53054. return this._mass;
  53055. }
  53056. getLocalInertia() {
  53057. var m = new oimo.common.Mat3();
  53058. var m1 = m;
  53059. m1.e00 = this._localInertia00;
  53060. m1.e01 = this._localInertia01;
  53061. m1.e02 = this._localInertia02;
  53062. m1.e10 = this._localInertia10;
  53063. m1.e11 = this._localInertia11;
  53064. m1.e12 = this._localInertia12;
  53065. m1.e20 = this._localInertia20;
  53066. m1.e21 = this._localInertia21;
  53067. m1.e22 = this._localInertia22;
  53068. return m;
  53069. }
  53070. getLocalInertiaTo(inertia) {
  53071. var m = inertia;
  53072. m.e00 = this._localInertia00;
  53073. m.e01 = this._localInertia01;
  53074. m.e02 = this._localInertia02;
  53075. m.e10 = this._localInertia10;
  53076. m.e11 = this._localInertia11;
  53077. m.e12 = this._localInertia12;
  53078. m.e20 = this._localInertia20;
  53079. m.e21 = this._localInertia21;
  53080. m.e22 = this._localInertia22;
  53081. }
  53082. getMassData() {
  53083. var md = new oimo.dynamics.rigidbody.MassData();
  53084. md.mass = this._mass;
  53085. var m = md.localInertia;
  53086. m.e00 = this._localInertia00;
  53087. m.e01 = this._localInertia01;
  53088. m.e02 = this._localInertia02;
  53089. m.e10 = this._localInertia10;
  53090. m.e11 = this._localInertia11;
  53091. m.e12 = this._localInertia12;
  53092. m.e20 = this._localInertia20;
  53093. m.e21 = this._localInertia21;
  53094. m.e22 = this._localInertia22;
  53095. return md;
  53096. }
  53097. getMassDataTo(massData) {
  53098. massData.mass = this._mass;
  53099. var m = massData.localInertia;
  53100. m.e00 = this._localInertia00;
  53101. m.e01 = this._localInertia01;
  53102. m.e02 = this._localInertia02;
  53103. m.e10 = this._localInertia10;
  53104. m.e11 = this._localInertia11;
  53105. m.e12 = this._localInertia12;
  53106. m.e20 = this._localInertia20;
  53107. m.e21 = this._localInertia21;
  53108. m.e22 = this._localInertia22;
  53109. }
  53110. setMassData(massData) {
  53111. this._mass = massData.mass;
  53112. var m = massData.localInertia;
  53113. this._localInertia00 = m.e00;
  53114. this._localInertia01 = m.e01;
  53115. this._localInertia02 = m.e02;
  53116. this._localInertia10 = m.e10;
  53117. this._localInertia11 = m.e11;
  53118. this._localInertia12 = m.e12;
  53119. this._localInertia20 = m.e20;
  53120. this._localInertia21 = m.e21;
  53121. this._localInertia22 = m.e22;
  53122. var d00 = this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21;
  53123. var d01 = this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20;
  53124. var d02 = this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20;
  53125. var det = this._localInertia00 * d00 - this._localInertia01 * d01 + this._localInertia02 * d02;
  53126. if(this._mass > 0 && det > 0 && this._type == 0) {
  53127. this._invMass = 1 / this._mass;
  53128. var d001 = this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21;
  53129. var d011 = this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20;
  53130. var d021 = this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20;
  53131. var d10 = this._localInertia01 * this._localInertia22 - this._localInertia02 * this._localInertia21;
  53132. var d11 = this._localInertia00 * this._localInertia22 - this._localInertia02 * this._localInertia20;
  53133. var d12 = this._localInertia00 * this._localInertia21 - this._localInertia01 * this._localInertia20;
  53134. var d20 = this._localInertia01 * this._localInertia12 - this._localInertia02 * this._localInertia11;
  53135. var d21 = this._localInertia00 * this._localInertia12 - this._localInertia02 * this._localInertia10;
  53136. var d22 = this._localInertia00 * this._localInertia11 - this._localInertia01 * this._localInertia10;
  53137. var d = this._localInertia00 * d001 - this._localInertia01 * d011 + this._localInertia02 * d021;
  53138. if(d < -1e-32 || d > 1e-32) {
  53139. d = 1 / d;
  53140. }
  53141. this._invLocalInertia00 = d001 * d;
  53142. this._invLocalInertia01 = -d10 * d;
  53143. this._invLocalInertia02 = d20 * d;
  53144. this._invLocalInertia10 = -d011 * d;
  53145. this._invLocalInertia11 = d11 * d;
  53146. this._invLocalInertia12 = -d21 * d;
  53147. this._invLocalInertia20 = d021 * d;
  53148. this._invLocalInertia21 = -d12 * d;
  53149. this._invLocalInertia22 = d22 * d;
  53150. this._invLocalInertiaWithoutRotFactor00 = this._invLocalInertia00;
  53151. this._invLocalInertiaWithoutRotFactor01 = this._invLocalInertia01;
  53152. this._invLocalInertiaWithoutRotFactor02 = this._invLocalInertia02;
  53153. this._invLocalInertiaWithoutRotFactor10 = this._invLocalInertia10;
  53154. this._invLocalInertiaWithoutRotFactor11 = this._invLocalInertia11;
  53155. this._invLocalInertiaWithoutRotFactor12 = this._invLocalInertia12;
  53156. this._invLocalInertiaWithoutRotFactor20 = this._invLocalInertia20;
  53157. this._invLocalInertiaWithoutRotFactor21 = this._invLocalInertia21;
  53158. this._invLocalInertiaWithoutRotFactor22 = this._invLocalInertia22;
  53159. this._invLocalInertia00 = this._invLocalInertiaWithoutRotFactor00 * this._rotFactor.x;
  53160. this._invLocalInertia01 = this._invLocalInertiaWithoutRotFactor01 * this._rotFactor.x;
  53161. this._invLocalInertia02 = this._invLocalInertiaWithoutRotFactor02 * this._rotFactor.x;
  53162. this._invLocalInertia10 = this._invLocalInertiaWithoutRotFactor10 * this._rotFactor.y;
  53163. this._invLocalInertia11 = this._invLocalInertiaWithoutRotFactor11 * this._rotFactor.y;
  53164. this._invLocalInertia12 = this._invLocalInertiaWithoutRotFactor12 * this._rotFactor.y;
  53165. this._invLocalInertia20 = this._invLocalInertiaWithoutRotFactor20 * this._rotFactor.z;
  53166. this._invLocalInertia21 = this._invLocalInertiaWithoutRotFactor21 * this._rotFactor.z;
  53167. this._invLocalInertia22 = this._invLocalInertiaWithoutRotFactor22 * this._rotFactor.z;
  53168. } else {
  53169. this._invMass = 0;
  53170. this._invLocalInertia00 = 0;
  53171. this._invLocalInertia01 = 0;
  53172. this._invLocalInertia02 = 0;
  53173. this._invLocalInertia10 = 0;
  53174. this._invLocalInertia11 = 0;
  53175. this._invLocalInertia12 = 0;
  53176. this._invLocalInertia20 = 0;
  53177. this._invLocalInertia21 = 0;
  53178. this._invLocalInertia22 = 0;
  53179. this._invLocalInertiaWithoutRotFactor00 = 0;
  53180. this._invLocalInertiaWithoutRotFactor01 = 0;
  53181. this._invLocalInertiaWithoutRotFactor02 = 0;
  53182. this._invLocalInertiaWithoutRotFactor10 = 0;
  53183. this._invLocalInertiaWithoutRotFactor11 = 0;
  53184. this._invLocalInertiaWithoutRotFactor12 = 0;
  53185. this._invLocalInertiaWithoutRotFactor20 = 0;
  53186. this._invLocalInertiaWithoutRotFactor21 = 0;
  53187. this._invLocalInertiaWithoutRotFactor22 = 0;
  53188. if(this._type == 0) {
  53189. this._type = 1;
  53190. }
  53191. }
  53192. var __tmp__00;
  53193. var __tmp__01;
  53194. var __tmp__02;
  53195. var __tmp__10;
  53196. var __tmp__11;
  53197. var __tmp__12;
  53198. var __tmp__20;
  53199. var __tmp__21;
  53200. var __tmp__22;
  53201. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  53202. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  53203. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  53204. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  53205. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  53206. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  53207. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  53208. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  53209. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  53210. this._invInertia00 = __tmp__00;
  53211. this._invInertia01 = __tmp__01;
  53212. this._invInertia02 = __tmp__02;
  53213. this._invInertia10 = __tmp__10;
  53214. this._invInertia11 = __tmp__11;
  53215. this._invInertia12 = __tmp__12;
  53216. this._invInertia20 = __tmp__20;
  53217. this._invInertia21 = __tmp__21;
  53218. this._invInertia22 = __tmp__22;
  53219. var __tmp__001;
  53220. var __tmp__011;
  53221. var __tmp__021;
  53222. var __tmp__101;
  53223. var __tmp__111;
  53224. var __tmp__121;
  53225. var __tmp__201;
  53226. var __tmp__211;
  53227. var __tmp__221;
  53228. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  53229. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  53230. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  53231. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  53232. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  53233. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  53234. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  53235. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  53236. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  53237. this._invInertia00 = __tmp__001;
  53238. this._invInertia01 = __tmp__011;
  53239. this._invInertia02 = __tmp__021;
  53240. this._invInertia10 = __tmp__101;
  53241. this._invInertia11 = __tmp__111;
  53242. this._invInertia12 = __tmp__121;
  53243. this._invInertia20 = __tmp__201;
  53244. this._invInertia21 = __tmp__211;
  53245. this._invInertia22 = __tmp__221;
  53246. this._invInertia00 *= this._rotFactor.x;
  53247. this._invInertia01 *= this._rotFactor.x;
  53248. this._invInertia02 *= this._rotFactor.x;
  53249. this._invInertia10 *= this._rotFactor.y;
  53250. this._invInertia11 *= this._rotFactor.y;
  53251. this._invInertia12 *= this._rotFactor.y;
  53252. this._invInertia20 *= this._rotFactor.z;
  53253. this._invInertia21 *= this._rotFactor.z;
  53254. this._invInertia22 *= this._rotFactor.z;
  53255. this._sleeping = false;
  53256. this._sleepTime = 0;
  53257. }
  53258. getRotationFactor() {
  53259. var _this = this._rotFactor;
  53260. return new oimo.common.Vec3(_this.x,_this.y,_this.z);
  53261. }
  53262. setRotationFactor(rotationFactor) {
  53263. var _this = this._rotFactor;
  53264. _this.x = rotationFactor.x;
  53265. _this.y = rotationFactor.y;
  53266. _this.z = rotationFactor.z;
  53267. var __tmp__00;
  53268. var __tmp__01;
  53269. var __tmp__02;
  53270. var __tmp__10;
  53271. var __tmp__11;
  53272. var __tmp__12;
  53273. var __tmp__20;
  53274. var __tmp__21;
  53275. var __tmp__22;
  53276. __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20;
  53277. __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21;
  53278. __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22;
  53279. __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20;
  53280. __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21;
  53281. __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22;
  53282. __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20;
  53283. __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21;
  53284. __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22;
  53285. this._invInertia00 = __tmp__00;
  53286. this._invInertia01 = __tmp__01;
  53287. this._invInertia02 = __tmp__02;
  53288. this._invInertia10 = __tmp__10;
  53289. this._invInertia11 = __tmp__11;
  53290. this._invInertia12 = __tmp__12;
  53291. this._invInertia20 = __tmp__20;
  53292. this._invInertia21 = __tmp__21;
  53293. this._invInertia22 = __tmp__22;
  53294. var __tmp__001;
  53295. var __tmp__011;
  53296. var __tmp__021;
  53297. var __tmp__101;
  53298. var __tmp__111;
  53299. var __tmp__121;
  53300. var __tmp__201;
  53301. var __tmp__211;
  53302. var __tmp__221;
  53303. __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02;
  53304. __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12;
  53305. __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22;
  53306. __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02;
  53307. __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12;
  53308. __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22;
  53309. __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02;
  53310. __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12;
  53311. __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22;
  53312. this._invInertia00 = __tmp__001;
  53313. this._invInertia01 = __tmp__011;
  53314. this._invInertia02 = __tmp__021;
  53315. this._invInertia10 = __tmp__101;
  53316. this._invInertia11 = __tmp__111;
  53317. this._invInertia12 = __tmp__121;
  53318. this._invInertia20 = __tmp__201;
  53319. this._invInertia21 = __tmp__211;
  53320. this._invInertia22 = __tmp__221;
  53321. this._invInertia00 *= this._rotFactor.x;
  53322. this._invInertia01 *= this._rotFactor.x;
  53323. this._invInertia02 *= this._rotFactor.x;
  53324. this._invInertia10 *= this._rotFactor.y;
  53325. this._invInertia11 *= this._rotFactor.y;
  53326. this._invInertia12 *= this._rotFactor.y;
  53327. this._invInertia20 *= this._rotFactor.z;
  53328. this._invInertia21 *= this._rotFactor.z;
  53329. this._invInertia22 *= this._rotFactor.z;
  53330. this._sleeping = false;
  53331. this._sleepTime = 0;
  53332. }
  53333. getLinearVelocity() {
  53334. var v = new oimo.common.Vec3();
  53335. var v1 = v;
  53336. v1.x = this._velX;
  53337. v1.y = this._velY;
  53338. v1.z = this._velZ;
  53339. return v;
  53340. }
  53341. getLinearVelocityTo(linearVelocity) {
  53342. var v = linearVelocity;
  53343. v.x = this._velX;
  53344. v.y = this._velY;
  53345. v.z = this._velZ;
  53346. }
  53347. setLinearVelocity(linearVelocity) {
  53348. if(this._type == 1) {
  53349. this._velX = 0;
  53350. this._velY = 0;
  53351. this._velZ = 0;
  53352. } else {
  53353. var v = linearVelocity;
  53354. this._velX = v.x;
  53355. this._velY = v.y;
  53356. this._velZ = v.z;
  53357. }
  53358. this._sleeping = false;
  53359. this._sleepTime = 0;
  53360. }
  53361. getAngularVelocity() {
  53362. var v = new oimo.common.Vec3();
  53363. var v1 = v;
  53364. v1.x = this._angVelX;
  53365. v1.y = this._angVelY;
  53366. v1.z = this._angVelZ;
  53367. return v;
  53368. }
  53369. getAngularVelocityTo(angularVelocity) {
  53370. var v = angularVelocity;
  53371. v.x = this._velX;
  53372. v.y = this._velY;
  53373. v.z = this._velZ;
  53374. }
  53375. setAngularVelocity(angularVelocity) {
  53376. if(this._type == 1) {
  53377. this._angVelX = 0;
  53378. this._angVelY = 0;
  53379. this._angVelZ = 0;
  53380. } else {
  53381. var v = angularVelocity;
  53382. this._angVelX = v.x;
  53383. this._angVelY = v.y;
  53384. this._angVelZ = v.z;
  53385. }
  53386. this._sleeping = false;
  53387. this._sleepTime = 0;
  53388. }
  53389. addLinearVelocity(linearVelocityChange) {
  53390. if(this._type != 1) {
  53391. var d;
  53392. var dX;
  53393. var dY;
  53394. var dZ;
  53395. var v = linearVelocityChange;
  53396. dX = v.x;
  53397. dY = v.y;
  53398. dZ = v.z;
  53399. this._velX += dX;
  53400. this._velY += dY;
  53401. this._velZ += dZ;
  53402. }
  53403. this._sleeping = false;
  53404. this._sleepTime = 0;
  53405. }
  53406. addAngularVelocity(angularVelocityChange) {
  53407. if(this._type != 1) {
  53408. var d;
  53409. var dX;
  53410. var dY;
  53411. var dZ;
  53412. var v = angularVelocityChange;
  53413. dX = v.x;
  53414. dY = v.y;
  53415. dZ = v.z;
  53416. this._angVelX += dX;
  53417. this._angVelY += dY;
  53418. this._angVelZ += dZ;
  53419. }
  53420. this._sleeping = false;
  53421. this._sleepTime = 0;
  53422. }
  53423. applyImpulse(impulse,positionInWorld) {
  53424. var imp;
  53425. var impX;
  53426. var impY;
  53427. var impZ;
  53428. var v = impulse;
  53429. impX = v.x;
  53430. impY = v.y;
  53431. impZ = v.z;
  53432. this._velX += impX * this._invMass;
  53433. this._velY += impY * this._invMass;
  53434. this._velZ += impZ * this._invMass;
  53435. var aimp;
  53436. var aimpX;
  53437. var aimpY;
  53438. var aimpZ;
  53439. var pos;
  53440. var posX;
  53441. var posY;
  53442. var posZ;
  53443. var v1 = positionInWorld;
  53444. posX = v1.x;
  53445. posY = v1.y;
  53446. posZ = v1.z;
  53447. posX -= this._transform._positionX;
  53448. posY -= this._transform._positionY;
  53449. posZ -= this._transform._positionZ;
  53450. aimpX = posY * impZ - posZ * impY;
  53451. aimpY = posZ * impX - posX * impZ;
  53452. aimpZ = posX * impY - posY * impX;
  53453. var __tmp__X;
  53454. var __tmp__Y;
  53455. var __tmp__Z;
  53456. __tmp__X = this._invInertia00 * aimpX + this._invInertia01 * aimpY + this._invInertia02 * aimpZ;
  53457. __tmp__Y = this._invInertia10 * aimpX + this._invInertia11 * aimpY + this._invInertia12 * aimpZ;
  53458. __tmp__Z = this._invInertia20 * aimpX + this._invInertia21 * aimpY + this._invInertia22 * aimpZ;
  53459. aimpX = __tmp__X;
  53460. aimpY = __tmp__Y;
  53461. aimpZ = __tmp__Z;
  53462. this._angVelX += aimpX;
  53463. this._angVelY += aimpY;
  53464. this._angVelZ += aimpZ;
  53465. this._sleeping = false;
  53466. this._sleepTime = 0;
  53467. }
  53468. applyLinearImpulse(impulse) {
  53469. var imp;
  53470. var impX;
  53471. var impY;
  53472. var impZ;
  53473. var v = impulse;
  53474. impX = v.x;
  53475. impY = v.y;
  53476. impZ = v.z;
  53477. this._velX += impX * this._invMass;
  53478. this._velY += impY * this._invMass;
  53479. this._velZ += impZ * this._invMass;
  53480. this._sleeping = false;
  53481. this._sleepTime = 0;
  53482. }
  53483. applyAngularImpulse(impulse) {
  53484. var imp;
  53485. var impX;
  53486. var impY;
  53487. var impZ;
  53488. var v = impulse;
  53489. impX = v.x;
  53490. impY = v.y;
  53491. impZ = v.z;
  53492. var __tmp__X;
  53493. var __tmp__Y;
  53494. var __tmp__Z;
  53495. __tmp__X = this._invInertia00 * impX + this._invInertia01 * impY + this._invInertia02 * impZ;
  53496. __tmp__Y = this._invInertia10 * impX + this._invInertia11 * impY + this._invInertia12 * impZ;
  53497. __tmp__Z = this._invInertia20 * impX + this._invInertia21 * impY + this._invInertia22 * impZ;
  53498. impX = __tmp__X;
  53499. impY = __tmp__Y;
  53500. impZ = __tmp__Z;
  53501. this._angVelX += impX;
  53502. this._angVelY += impY;
  53503. this._angVelZ += impZ;
  53504. this._sleeping = false;
  53505. this._sleepTime = 0;
  53506. }
  53507. applyForce(force,positionInWorld) {
  53508. var iforce;
  53509. var iforceX;
  53510. var iforceY;
  53511. var iforceZ;
  53512. var v = force;
  53513. iforceX = v.x;
  53514. iforceY = v.y;
  53515. iforceZ = v.z;
  53516. this._forceX += iforceX;
  53517. this._forceY += iforceY;
  53518. this._forceZ += iforceZ;
  53519. var itorque;
  53520. var itorqueX;
  53521. var itorqueY;
  53522. var itorqueZ;
  53523. var pos;
  53524. var posX;
  53525. var posY;
  53526. var posZ;
  53527. var v1 = positionInWorld;
  53528. posX = v1.x;
  53529. posY = v1.y;
  53530. posZ = v1.z;
  53531. posX -= this._transform._positionX;
  53532. posY -= this._transform._positionY;
  53533. posZ -= this._transform._positionZ;
  53534. itorqueX = posY * iforceZ - posZ * iforceY;
  53535. itorqueY = posZ * iforceX - posX * iforceZ;
  53536. itorqueZ = posX * iforceY - posY * iforceX;
  53537. this._torqueX += itorqueX;
  53538. this._torqueY += itorqueY;
  53539. this._torqueZ += itorqueZ;
  53540. this._sleeping = false;
  53541. this._sleepTime = 0;
  53542. }
  53543. applyForceToCenter(force) {
  53544. var iforce;
  53545. var iforceX;
  53546. var iforceY;
  53547. var iforceZ;
  53548. var v = force;
  53549. iforceX = v.x;
  53550. iforceY = v.y;
  53551. iforceZ = v.z;
  53552. this._forceX += iforceX;
  53553. this._forceY += iforceY;
  53554. this._forceZ += iforceZ;
  53555. this._sleeping = false;
  53556. this._sleepTime = 0;
  53557. }
  53558. applyTorque(torque) {
  53559. var itorque;
  53560. var itorqueX;
  53561. var itorqueY;
  53562. var itorqueZ;
  53563. var v = torque;
  53564. itorqueX = v.x;
  53565. itorqueY = v.y;
  53566. itorqueZ = v.z;
  53567. this._torqueX += itorqueX;
  53568. this._torqueY += itorqueY;
  53569. this._torqueZ += itorqueZ;
  53570. this._sleeping = false;
  53571. this._sleepTime = 0;
  53572. }
  53573. getLinearContactImpulse() {
  53574. var res = new oimo.common.Vec3();
  53575. var v = res;
  53576. v.x = this._linearContactImpulseX;
  53577. v.y = this._linearContactImpulseY;
  53578. v.z = this._linearContactImpulseZ;
  53579. return res;
  53580. }
  53581. getLinearContactImpulseTo(linearContactImpulse) {
  53582. var v = linearContactImpulse;
  53583. v.x = this._linearContactImpulseX;
  53584. v.y = this._linearContactImpulseY;
  53585. v.z = this._linearContactImpulseZ;
  53586. }
  53587. getAngularContactImpulse() {
  53588. var res = new oimo.common.Vec3();
  53589. var v = res;
  53590. v.x = this._angularContactImpulseX;
  53591. v.y = this._angularContactImpulseY;
  53592. v.z = this._angularContactImpulseZ;
  53593. return res;
  53594. }
  53595. getAngularContactImpulseTo(angularContactImpulse) {
  53596. var v = angularContactImpulse;
  53597. v.x = this._angularContactImpulseX;
  53598. v.y = this._angularContactImpulseY;
  53599. v.z = this._angularContactImpulseZ;
  53600. }
  53601. getGravityScale() {
  53602. return this._gravityScale;
  53603. }
  53604. setGravityScale(gravityScale) {
  53605. this._gravityScale = gravityScale;
  53606. this._sleeping = false;
  53607. this._sleepTime = 0;
  53608. }
  53609. getLocalPoint(worldPoint) {
  53610. var v;
  53611. var vX;
  53612. var vY;
  53613. var vZ;
  53614. var v1 = worldPoint;
  53615. vX = v1.x;
  53616. vY = v1.y;
  53617. vZ = v1.z;
  53618. vX -= this._transform._positionX;
  53619. vY -= this._transform._positionY;
  53620. vZ -= this._transform._positionZ;
  53621. var __tmp__X;
  53622. var __tmp__Y;
  53623. var __tmp__Z;
  53624. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ;
  53625. __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ;
  53626. __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ;
  53627. vX = __tmp__X;
  53628. vY = __tmp__Y;
  53629. vZ = __tmp__Z;
  53630. var res = new oimo.common.Vec3();
  53631. var v2 = res;
  53632. v2.x = vX;
  53633. v2.y = vY;
  53634. v2.z = vZ;
  53635. return res;
  53636. }
  53637. getLocalPointTo(worldPoint,localPoint) {
  53638. var v;
  53639. var vX;
  53640. var vY;
  53641. var vZ;
  53642. var v1 = worldPoint;
  53643. vX = v1.x;
  53644. vY = v1.y;
  53645. vZ = v1.z;
  53646. vX -= this._transform._positionX;
  53647. vY -= this._transform._positionY;
  53648. vZ -= this._transform._positionZ;
  53649. var __tmp__X;
  53650. var __tmp__Y;
  53651. var __tmp__Z;
  53652. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ;
  53653. __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ;
  53654. __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ;
  53655. vX = __tmp__X;
  53656. vY = __tmp__Y;
  53657. vZ = __tmp__Z;
  53658. var v2 = localPoint;
  53659. v2.x = vX;
  53660. v2.y = vY;
  53661. v2.z = vZ;
  53662. }
  53663. getLocalVector(worldVector) {
  53664. var v;
  53665. var vX;
  53666. var vY;
  53667. var vZ;
  53668. var v1 = worldVector;
  53669. vX = v1.x;
  53670. vY = v1.y;
  53671. vZ = v1.z;
  53672. var __tmp__X;
  53673. var __tmp__Y;
  53674. var __tmp__Z;
  53675. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ;
  53676. __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ;
  53677. __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ;
  53678. vX = __tmp__X;
  53679. vY = __tmp__Y;
  53680. vZ = __tmp__Z;
  53681. var res = new oimo.common.Vec3();
  53682. var v2 = res;
  53683. v2.x = vX;
  53684. v2.y = vY;
  53685. v2.z = vZ;
  53686. return res;
  53687. }
  53688. getLocalVectorTo(worldVector,localVector) {
  53689. var v;
  53690. var vX;
  53691. var vY;
  53692. var vZ;
  53693. var v1 = worldVector;
  53694. vX = v1.x;
  53695. vY = v1.y;
  53696. vZ = v1.z;
  53697. var __tmp__X;
  53698. var __tmp__Y;
  53699. var __tmp__Z;
  53700. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ;
  53701. __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ;
  53702. __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ;
  53703. vX = __tmp__X;
  53704. vY = __tmp__Y;
  53705. vZ = __tmp__Z;
  53706. var v2 = localVector;
  53707. v2.x = vX;
  53708. v2.y = vY;
  53709. v2.z = vZ;
  53710. }
  53711. getWorldPoint(localPoint) {
  53712. var v;
  53713. var vX;
  53714. var vY;
  53715. var vZ;
  53716. var v1 = localPoint;
  53717. vX = v1.x;
  53718. vY = v1.y;
  53719. vZ = v1.z;
  53720. var __tmp__X;
  53721. var __tmp__Y;
  53722. var __tmp__Z;
  53723. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ;
  53724. __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ;
  53725. __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ;
  53726. vX = __tmp__X;
  53727. vY = __tmp__Y;
  53728. vZ = __tmp__Z;
  53729. vX += this._transform._positionX;
  53730. vY += this._transform._positionY;
  53731. vZ += this._transform._positionZ;
  53732. var res = new oimo.common.Vec3();
  53733. var v2 = res;
  53734. v2.x = vX;
  53735. v2.y = vY;
  53736. v2.z = vZ;
  53737. return res;
  53738. }
  53739. getWorldPointTo(localPoint,worldPoint) {
  53740. var v;
  53741. var vX;
  53742. var vY;
  53743. var vZ;
  53744. var v1 = localPoint;
  53745. vX = v1.x;
  53746. vY = v1.y;
  53747. vZ = v1.z;
  53748. var __tmp__X;
  53749. var __tmp__Y;
  53750. var __tmp__Z;
  53751. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ;
  53752. __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ;
  53753. __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ;
  53754. vX = __tmp__X;
  53755. vY = __tmp__Y;
  53756. vZ = __tmp__Z;
  53757. vX += this._transform._positionX;
  53758. vY += this._transform._positionY;
  53759. vZ += this._transform._positionZ;
  53760. var v2 = worldPoint;
  53761. v2.x = vX;
  53762. v2.y = vY;
  53763. v2.z = vZ;
  53764. }
  53765. getWorldVector(localVector) {
  53766. var v;
  53767. var vX;
  53768. var vY;
  53769. var vZ;
  53770. var v1 = localVector;
  53771. vX = v1.x;
  53772. vY = v1.y;
  53773. vZ = v1.z;
  53774. var __tmp__X;
  53775. var __tmp__Y;
  53776. var __tmp__Z;
  53777. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ;
  53778. __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ;
  53779. __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ;
  53780. vX = __tmp__X;
  53781. vY = __tmp__Y;
  53782. vZ = __tmp__Z;
  53783. var res = new oimo.common.Vec3();
  53784. var v2 = res;
  53785. v2.x = vX;
  53786. v2.y = vY;
  53787. v2.z = vZ;
  53788. return res;
  53789. }
  53790. getWorldVectorTo(localVector,worldVector) {
  53791. var v;
  53792. var vX;
  53793. var vY;
  53794. var vZ;
  53795. var v1 = localVector;
  53796. vX = v1.x;
  53797. vY = v1.y;
  53798. vZ = v1.z;
  53799. var __tmp__X;
  53800. var __tmp__Y;
  53801. var __tmp__Z;
  53802. __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ;
  53803. __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ;
  53804. __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ;
  53805. vX = __tmp__X;
  53806. vY = __tmp__Y;
  53807. vZ = __tmp__Z;
  53808. var v2 = worldVector;
  53809. v2.x = vX;
  53810. v2.y = vY;
  53811. v2.z = vZ;
  53812. }
  53813. getNumShapes() {
  53814. return this._numShapes;
  53815. }
  53816. getShapeList() {
  53817. return this._shapeList;
  53818. }
  53819. getNumContectLinks() {
  53820. return this._numContactLinks;
  53821. }
  53822. getContactLinkList() {
  53823. return this._contactLinkList;
  53824. }
  53825. getNumJointLinks() {
  53826. return this._numJointLinks;
  53827. }
  53828. getJointLinkList() {
  53829. return this._jointLinkList;
  53830. }
  53831. addShape(shape) {
  53832. if(this._shapeList == null) {
  53833. this._shapeList = shape;
  53834. this._shapeListLast = shape;
  53835. } else {
  53836. this._shapeListLast._next = shape;
  53837. shape._prev = this._shapeListLast;
  53838. this._shapeListLast = shape;
  53839. }
  53840. this._numShapes++;
  53841. shape._rigidBody = this;
  53842. if(this._world != null) {
  53843. var _this = this._world;
  53844. shape._proxy = _this._broadPhase.createProxy(shape,shape._aabb);
  53845. shape._id = _this._shapeIdCount++;
  53846. _this._numShapes++;
  53847. }
  53848. this.updateMass();
  53849. var s = this._shapeList;
  53850. while(s != null) {
  53851. var n = s._next;
  53852. var dst = s._ptransform;
  53853. var src1 = s._localTransform;
  53854. var src2 = this._ptransform;
  53855. var __tmp__00;
  53856. var __tmp__01;
  53857. var __tmp__02;
  53858. var __tmp__10;
  53859. var __tmp__11;
  53860. var __tmp__12;
  53861. var __tmp__20;
  53862. var __tmp__21;
  53863. var __tmp__22;
  53864. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  53865. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  53866. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  53867. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  53868. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  53869. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  53870. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  53871. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  53872. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  53873. dst._rotation00 = __tmp__00;
  53874. dst._rotation01 = __tmp__01;
  53875. dst._rotation02 = __tmp__02;
  53876. dst._rotation10 = __tmp__10;
  53877. dst._rotation11 = __tmp__11;
  53878. dst._rotation12 = __tmp__12;
  53879. dst._rotation20 = __tmp__20;
  53880. dst._rotation21 = __tmp__21;
  53881. dst._rotation22 = __tmp__22;
  53882. var __tmp__X;
  53883. var __tmp__Y;
  53884. var __tmp__Z;
  53885. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  53886. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  53887. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  53888. dst._positionX = __tmp__X;
  53889. dst._positionY = __tmp__Y;
  53890. dst._positionZ = __tmp__Z;
  53891. dst._positionX += src2._positionX;
  53892. dst._positionY += src2._positionY;
  53893. dst._positionZ += src2._positionZ;
  53894. var dst1 = s._transform;
  53895. var src11 = s._localTransform;
  53896. var src21 = this._transform;
  53897. var __tmp__001;
  53898. var __tmp__011;
  53899. var __tmp__021;
  53900. var __tmp__101;
  53901. var __tmp__111;
  53902. var __tmp__121;
  53903. var __tmp__201;
  53904. var __tmp__211;
  53905. var __tmp__221;
  53906. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  53907. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  53908. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  53909. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  53910. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  53911. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  53912. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  53913. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  53914. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  53915. dst1._rotation00 = __tmp__001;
  53916. dst1._rotation01 = __tmp__011;
  53917. dst1._rotation02 = __tmp__021;
  53918. dst1._rotation10 = __tmp__101;
  53919. dst1._rotation11 = __tmp__111;
  53920. dst1._rotation12 = __tmp__121;
  53921. dst1._rotation20 = __tmp__201;
  53922. dst1._rotation21 = __tmp__211;
  53923. dst1._rotation22 = __tmp__221;
  53924. var __tmp__X1;
  53925. var __tmp__Y1;
  53926. var __tmp__Z1;
  53927. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  53928. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  53929. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  53930. dst1._positionX = __tmp__X1;
  53931. dst1._positionY = __tmp__Y1;
  53932. dst1._positionZ = __tmp__Z1;
  53933. dst1._positionX += src21._positionX;
  53934. dst1._positionY += src21._positionY;
  53935. dst1._positionZ += src21._positionZ;
  53936. var min;
  53937. var minX;
  53938. var minY;
  53939. var minZ;
  53940. var max;
  53941. var maxX;
  53942. var maxY;
  53943. var maxZ;
  53944. s._geom._computeAabb(s._aabb,s._ptransform);
  53945. minX = s._aabb._minX;
  53946. minY = s._aabb._minY;
  53947. minZ = s._aabb._minZ;
  53948. maxX = s._aabb._maxX;
  53949. maxY = s._aabb._maxY;
  53950. maxZ = s._aabb._maxZ;
  53951. s._geom._computeAabb(s._aabb,s._transform);
  53952. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  53953. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  53954. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  53955. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  53956. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  53957. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  53958. if(s._proxy != null) {
  53959. var d;
  53960. var dX;
  53961. var dY;
  53962. var dZ;
  53963. dX = s._transform._positionX - s._ptransform._positionX;
  53964. dY = s._transform._positionY - s._ptransform._positionY;
  53965. dZ = s._transform._positionZ - s._ptransform._positionZ;
  53966. var v = s.displacement;
  53967. v.x = dX;
  53968. v.y = dY;
  53969. v.z = dZ;
  53970. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  53971. }
  53972. s = n;
  53973. }
  53974. }
  53975. removeShape(shape) {
  53976. var prev = shape._prev;
  53977. var next = shape._next;
  53978. if(prev != null) {
  53979. prev._next = next;
  53980. }
  53981. if(next != null) {
  53982. next._prev = prev;
  53983. }
  53984. if(shape == this._shapeList) {
  53985. this._shapeList = this._shapeList._next;
  53986. }
  53987. if(shape == this._shapeListLast) {
  53988. this._shapeListLast = this._shapeListLast._prev;
  53989. }
  53990. shape._next = null;
  53991. shape._prev = null;
  53992. this._numShapes--;
  53993. shape._rigidBody = null;
  53994. if(this._world != null) {
  53995. var _this = this._world;
  53996. _this._broadPhase.destroyProxy(shape._proxy);
  53997. shape._proxy = null;
  53998. shape._id = -1;
  53999. var cl = shape._rigidBody._contactLinkList;
  54000. while(cl != null) {
  54001. var n = cl._next;
  54002. var c = cl._contact;
  54003. if(c._s1 == shape || c._s2 == shape) {
  54004. var _this1 = cl._other;
  54005. _this1._sleeping = false;
  54006. _this1._sleepTime = 0;
  54007. var _this2 = _this._contactManager;
  54008. var prev1 = c._prev;
  54009. var next1 = c._next;
  54010. if(prev1 != null) {
  54011. prev1._next = next1;
  54012. }
  54013. if(next1 != null) {
  54014. next1._prev = prev1;
  54015. }
  54016. if(c == _this2._contactList) {
  54017. _this2._contactList = _this2._contactList._next;
  54018. }
  54019. if(c == _this2._contactListLast) {
  54020. _this2._contactListLast = _this2._contactListLast._prev;
  54021. }
  54022. c._next = null;
  54023. c._prev = null;
  54024. if(c._touching) {
  54025. var cc1 = c._s1._contactCallback;
  54026. var cc2 = c._s2._contactCallback;
  54027. if(cc1 == cc2) {
  54028. cc2 = null;
  54029. }
  54030. if(cc1 != null) {
  54031. cc1.endContact(c);
  54032. }
  54033. if(cc2 != null) {
  54034. cc2.endContact(c);
  54035. }
  54036. }
  54037. var prev2 = c._link1._prev;
  54038. var next2 = c._link1._next;
  54039. if(prev2 != null) {
  54040. prev2._next = next2;
  54041. }
  54042. if(next2 != null) {
  54043. next2._prev = prev2;
  54044. }
  54045. if(c._link1 == c._b1._contactLinkList) {
  54046. c._b1._contactLinkList = c._b1._contactLinkList._next;
  54047. }
  54048. if(c._link1 == c._b1._contactLinkListLast) {
  54049. c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev;
  54050. }
  54051. c._link1._next = null;
  54052. c._link1._prev = null;
  54053. var prev3 = c._link2._prev;
  54054. var next3 = c._link2._next;
  54055. if(prev3 != null) {
  54056. prev3._next = next3;
  54057. }
  54058. if(next3 != null) {
  54059. next3._prev = prev3;
  54060. }
  54061. if(c._link2 == c._b2._contactLinkList) {
  54062. c._b2._contactLinkList = c._b2._contactLinkList._next;
  54063. }
  54064. if(c._link2 == c._b2._contactLinkListLast) {
  54065. c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev;
  54066. }
  54067. c._link2._next = null;
  54068. c._link2._prev = null;
  54069. c._b1._numContactLinks--;
  54070. c._b2._numContactLinks--;
  54071. c._link1._other = null;
  54072. c._link2._other = null;
  54073. c._link1._contact = null;
  54074. c._link2._contact = null;
  54075. c._s1 = null;
  54076. c._s2 = null;
  54077. c._b1 = null;
  54078. c._b2 = null;
  54079. c._touching = false;
  54080. c._cachedDetectorData._clear();
  54081. c._manifold._clear();
  54082. c._detector = null;
  54083. var _this3 = c._contactConstraint;
  54084. _this3._s1 = null;
  54085. _this3._s2 = null;
  54086. _this3._b1 = null;
  54087. _this3._b2 = null;
  54088. _this3._tf1 = null;
  54089. _this3._tf2 = null;
  54090. c._next = _this2._contactPool;
  54091. _this2._contactPool = c;
  54092. _this2._numContacts--;
  54093. }
  54094. cl = n;
  54095. }
  54096. _this._numShapes--;
  54097. }
  54098. this.updateMass();
  54099. var s = this._shapeList;
  54100. while(s != null) {
  54101. var n1 = s._next;
  54102. var dst = s._ptransform;
  54103. var src1 = s._localTransform;
  54104. var src2 = this._ptransform;
  54105. var __tmp__00;
  54106. var __tmp__01;
  54107. var __tmp__02;
  54108. var __tmp__10;
  54109. var __tmp__11;
  54110. var __tmp__12;
  54111. var __tmp__20;
  54112. var __tmp__21;
  54113. var __tmp__22;
  54114. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  54115. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  54116. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  54117. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  54118. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  54119. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  54120. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  54121. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  54122. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  54123. dst._rotation00 = __tmp__00;
  54124. dst._rotation01 = __tmp__01;
  54125. dst._rotation02 = __tmp__02;
  54126. dst._rotation10 = __tmp__10;
  54127. dst._rotation11 = __tmp__11;
  54128. dst._rotation12 = __tmp__12;
  54129. dst._rotation20 = __tmp__20;
  54130. dst._rotation21 = __tmp__21;
  54131. dst._rotation22 = __tmp__22;
  54132. var __tmp__X;
  54133. var __tmp__Y;
  54134. var __tmp__Z;
  54135. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  54136. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  54137. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  54138. dst._positionX = __tmp__X;
  54139. dst._positionY = __tmp__Y;
  54140. dst._positionZ = __tmp__Z;
  54141. dst._positionX += src2._positionX;
  54142. dst._positionY += src2._positionY;
  54143. dst._positionZ += src2._positionZ;
  54144. var dst1 = s._transform;
  54145. var src11 = s._localTransform;
  54146. var src21 = this._transform;
  54147. var __tmp__001;
  54148. var __tmp__011;
  54149. var __tmp__021;
  54150. var __tmp__101;
  54151. var __tmp__111;
  54152. var __tmp__121;
  54153. var __tmp__201;
  54154. var __tmp__211;
  54155. var __tmp__221;
  54156. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  54157. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  54158. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  54159. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  54160. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  54161. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  54162. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  54163. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  54164. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  54165. dst1._rotation00 = __tmp__001;
  54166. dst1._rotation01 = __tmp__011;
  54167. dst1._rotation02 = __tmp__021;
  54168. dst1._rotation10 = __tmp__101;
  54169. dst1._rotation11 = __tmp__111;
  54170. dst1._rotation12 = __tmp__121;
  54171. dst1._rotation20 = __tmp__201;
  54172. dst1._rotation21 = __tmp__211;
  54173. dst1._rotation22 = __tmp__221;
  54174. var __tmp__X1;
  54175. var __tmp__Y1;
  54176. var __tmp__Z1;
  54177. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  54178. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  54179. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  54180. dst1._positionX = __tmp__X1;
  54181. dst1._positionY = __tmp__Y1;
  54182. dst1._positionZ = __tmp__Z1;
  54183. dst1._positionX += src21._positionX;
  54184. dst1._positionY += src21._positionY;
  54185. dst1._positionZ += src21._positionZ;
  54186. var min;
  54187. var minX;
  54188. var minY;
  54189. var minZ;
  54190. var max;
  54191. var maxX;
  54192. var maxY;
  54193. var maxZ;
  54194. s._geom._computeAabb(s._aabb,s._ptransform);
  54195. minX = s._aabb._minX;
  54196. minY = s._aabb._minY;
  54197. minZ = s._aabb._minZ;
  54198. maxX = s._aabb._maxX;
  54199. maxY = s._aabb._maxY;
  54200. maxZ = s._aabb._maxZ;
  54201. s._geom._computeAabb(s._aabb,s._transform);
  54202. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  54203. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  54204. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  54205. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  54206. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  54207. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  54208. if(s._proxy != null) {
  54209. var d;
  54210. var dX;
  54211. var dY;
  54212. var dZ;
  54213. dX = s._transform._positionX - s._ptransform._positionX;
  54214. dY = s._transform._positionY - s._ptransform._positionY;
  54215. dZ = s._transform._positionZ - s._ptransform._positionZ;
  54216. var v = s.displacement;
  54217. v.x = dX;
  54218. v.y = dY;
  54219. v.z = dZ;
  54220. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  54221. }
  54222. s = n1;
  54223. }
  54224. }
  54225. getType() {
  54226. return this._type;
  54227. }
  54228. setType(type) {
  54229. this._type = type;
  54230. this.updateMass();
  54231. }
  54232. wakeUp() {
  54233. this._sleeping = false;
  54234. this._sleepTime = 0;
  54235. }
  54236. sleep() {
  54237. this._sleeping = true;
  54238. this._sleepTime = 0;
  54239. }
  54240. isSleeping() {
  54241. return this._sleeping;
  54242. }
  54243. getSleepTime() {
  54244. return this._sleepTime;
  54245. }
  54246. setAutoSleep(autoSleepEnabled) {
  54247. this._autoSleep = autoSleepEnabled;
  54248. this._sleeping = false;
  54249. this._sleepTime = 0;
  54250. }
  54251. getLinearDamping() {
  54252. return this._linearDamping;
  54253. }
  54254. setLinearDamping(damping) {
  54255. this._linearDamping = damping;
  54256. }
  54257. getAngularDamping() {
  54258. return this._angularDamping;
  54259. }
  54260. setAngularDamping(damping) {
  54261. this._angularDamping = damping;
  54262. }
  54263. getPrev() {
  54264. return this._prev;
  54265. }
  54266. getNext() {
  54267. return this._next;
  54268. }
  54269. }
  54270. oimo.dynamics.rigidbody.RigidBodyConfig = class oimo_dynamics_rigidbody_RigidBodyConfig {
  54271. constructor() {
  54272. this.position = new oimo.common.Vec3();
  54273. this.rotation = new oimo.common.Mat3();
  54274. this.linearVelocity = new oimo.common.Vec3();
  54275. this.angularVelocity = new oimo.common.Vec3();
  54276. this.type = 0;
  54277. this.autoSleep = true;
  54278. this.linearDamping = 0;
  54279. this.angularDamping = 0;
  54280. }
  54281. }
  54282. oimo.dynamics.rigidbody.RigidBodyType = class oimo_dynamics_rigidbody_RigidBodyType {
  54283. }
  54284. oimo.dynamics.rigidbody.Shape = class oimo_dynamics_rigidbody_Shape {
  54285. constructor(config) {
  54286. this._id = -1;
  54287. this._localTransform = new oimo.common.Transform();
  54288. this._ptransform = new oimo.common.Transform();
  54289. this._transform = new oimo.common.Transform();
  54290. var v = config.position;
  54291. this._localTransform._positionX = v.x;
  54292. this._localTransform._positionY = v.y;
  54293. this._localTransform._positionZ = v.z;
  54294. var m = config.rotation;
  54295. this._localTransform._rotation00 = m.e00;
  54296. this._localTransform._rotation01 = m.e01;
  54297. this._localTransform._rotation02 = m.e02;
  54298. this._localTransform._rotation10 = m.e10;
  54299. this._localTransform._rotation11 = m.e11;
  54300. this._localTransform._rotation12 = m.e12;
  54301. this._localTransform._rotation20 = m.e20;
  54302. this._localTransform._rotation21 = m.e21;
  54303. this._localTransform._rotation22 = m.e22;
  54304. var dst = this._ptransform;
  54305. var src = this._localTransform;
  54306. dst._positionX = src._positionX;
  54307. dst._positionY = src._positionY;
  54308. dst._positionZ = src._positionZ;
  54309. dst._rotation00 = src._rotation00;
  54310. dst._rotation01 = src._rotation01;
  54311. dst._rotation02 = src._rotation02;
  54312. dst._rotation10 = src._rotation10;
  54313. dst._rotation11 = src._rotation11;
  54314. dst._rotation12 = src._rotation12;
  54315. dst._rotation20 = src._rotation20;
  54316. dst._rotation21 = src._rotation21;
  54317. dst._rotation22 = src._rotation22;
  54318. var dst1 = this._transform;
  54319. var src1 = this._localTransform;
  54320. dst1._positionX = src1._positionX;
  54321. dst1._positionY = src1._positionY;
  54322. dst1._positionZ = src1._positionZ;
  54323. dst1._rotation00 = src1._rotation00;
  54324. dst1._rotation01 = src1._rotation01;
  54325. dst1._rotation02 = src1._rotation02;
  54326. dst1._rotation10 = src1._rotation10;
  54327. dst1._rotation11 = src1._rotation11;
  54328. dst1._rotation12 = src1._rotation12;
  54329. dst1._rotation20 = src1._rotation20;
  54330. dst1._rotation21 = src1._rotation21;
  54331. dst1._rotation22 = src1._rotation22;
  54332. this._restitution = config.restitution;
  54333. this._friction = config.friction;
  54334. this._density = config.density;
  54335. this._geom = config.geometry;
  54336. this._collisionGroup = config.collisionGroup;
  54337. this._collisionMask = config.collisionMask;
  54338. this._contactCallback = config.contactCallback;
  54339. this._aabb = new oimo.collision.geometry.Aabb();
  54340. this._proxy = null;
  54341. this.displacement = new oimo.common.Vec3();
  54342. }
  54343. getFriction() {
  54344. return this._friction;
  54345. }
  54346. setFriction(friction) {
  54347. this._friction = friction;
  54348. }
  54349. getRestitution() {
  54350. return this._restitution;
  54351. }
  54352. setRestitution(restitution) {
  54353. this._restitution = restitution;
  54354. }
  54355. getLocalTransform() {
  54356. var _this = this._localTransform;
  54357. var tf = new oimo.common.Transform();
  54358. tf._positionX = _this._positionX;
  54359. tf._positionY = _this._positionY;
  54360. tf._positionZ = _this._positionZ;
  54361. tf._rotation00 = _this._rotation00;
  54362. tf._rotation01 = _this._rotation01;
  54363. tf._rotation02 = _this._rotation02;
  54364. tf._rotation10 = _this._rotation10;
  54365. tf._rotation11 = _this._rotation11;
  54366. tf._rotation12 = _this._rotation12;
  54367. tf._rotation20 = _this._rotation20;
  54368. tf._rotation21 = _this._rotation21;
  54369. tf._rotation22 = _this._rotation22;
  54370. return tf;
  54371. }
  54372. getLocalTransformTo(transform) {
  54373. var transform1 = this._localTransform;
  54374. transform._positionX = transform1._positionX;
  54375. transform._positionY = transform1._positionY;
  54376. transform._positionZ = transform1._positionZ;
  54377. transform._rotation00 = transform1._rotation00;
  54378. transform._rotation01 = transform1._rotation01;
  54379. transform._rotation02 = transform1._rotation02;
  54380. transform._rotation10 = transform1._rotation10;
  54381. transform._rotation11 = transform1._rotation11;
  54382. transform._rotation12 = transform1._rotation12;
  54383. transform._rotation20 = transform1._rotation20;
  54384. transform._rotation21 = transform1._rotation21;
  54385. transform._rotation22 = transform1._rotation22;
  54386. }
  54387. getTransform() {
  54388. var _this = this._transform;
  54389. var tf = new oimo.common.Transform();
  54390. tf._positionX = _this._positionX;
  54391. tf._positionY = _this._positionY;
  54392. tf._positionZ = _this._positionZ;
  54393. tf._rotation00 = _this._rotation00;
  54394. tf._rotation01 = _this._rotation01;
  54395. tf._rotation02 = _this._rotation02;
  54396. tf._rotation10 = _this._rotation10;
  54397. tf._rotation11 = _this._rotation11;
  54398. tf._rotation12 = _this._rotation12;
  54399. tf._rotation20 = _this._rotation20;
  54400. tf._rotation21 = _this._rotation21;
  54401. tf._rotation22 = _this._rotation22;
  54402. return tf;
  54403. }
  54404. getTransformTo(transform) {
  54405. var transform1 = this._transform;
  54406. transform._positionX = transform1._positionX;
  54407. transform._positionY = transform1._positionY;
  54408. transform._positionZ = transform1._positionZ;
  54409. transform._rotation00 = transform1._rotation00;
  54410. transform._rotation01 = transform1._rotation01;
  54411. transform._rotation02 = transform1._rotation02;
  54412. transform._rotation10 = transform1._rotation10;
  54413. transform._rotation11 = transform1._rotation11;
  54414. transform._rotation12 = transform1._rotation12;
  54415. transform._rotation20 = transform1._rotation20;
  54416. transform._rotation21 = transform1._rotation21;
  54417. transform._rotation22 = transform1._rotation22;
  54418. }
  54419. setLocalTransform(transform) {
  54420. var _this = this._localTransform;
  54421. _this._positionX = transform._positionX;
  54422. _this._positionY = transform._positionY;
  54423. _this._positionZ = transform._positionZ;
  54424. _this._rotation00 = transform._rotation00;
  54425. _this._rotation01 = transform._rotation01;
  54426. _this._rotation02 = transform._rotation02;
  54427. _this._rotation10 = transform._rotation10;
  54428. _this._rotation11 = transform._rotation11;
  54429. _this._rotation12 = transform._rotation12;
  54430. _this._rotation20 = transform._rotation20;
  54431. _this._rotation21 = transform._rotation21;
  54432. _this._rotation22 = transform._rotation22;
  54433. if(this._rigidBody != null) {
  54434. var _this1 = this._rigidBody;
  54435. _this1.updateMass();
  54436. var s = _this1._shapeList;
  54437. while(s != null) {
  54438. var n = s._next;
  54439. var dst = s._ptransform;
  54440. var src1 = s._localTransform;
  54441. var src2 = _this1._ptransform;
  54442. var __tmp__00;
  54443. var __tmp__01;
  54444. var __tmp__02;
  54445. var __tmp__10;
  54446. var __tmp__11;
  54447. var __tmp__12;
  54448. var __tmp__20;
  54449. var __tmp__21;
  54450. var __tmp__22;
  54451. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  54452. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  54453. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  54454. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  54455. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  54456. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  54457. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  54458. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  54459. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  54460. dst._rotation00 = __tmp__00;
  54461. dst._rotation01 = __tmp__01;
  54462. dst._rotation02 = __tmp__02;
  54463. dst._rotation10 = __tmp__10;
  54464. dst._rotation11 = __tmp__11;
  54465. dst._rotation12 = __tmp__12;
  54466. dst._rotation20 = __tmp__20;
  54467. dst._rotation21 = __tmp__21;
  54468. dst._rotation22 = __tmp__22;
  54469. var __tmp__X;
  54470. var __tmp__Y;
  54471. var __tmp__Z;
  54472. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  54473. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  54474. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  54475. dst._positionX = __tmp__X;
  54476. dst._positionY = __tmp__Y;
  54477. dst._positionZ = __tmp__Z;
  54478. dst._positionX += src2._positionX;
  54479. dst._positionY += src2._positionY;
  54480. dst._positionZ += src2._positionZ;
  54481. var dst1 = s._transform;
  54482. var src11 = s._localTransform;
  54483. var src21 = _this1._transform;
  54484. var __tmp__001;
  54485. var __tmp__011;
  54486. var __tmp__021;
  54487. var __tmp__101;
  54488. var __tmp__111;
  54489. var __tmp__121;
  54490. var __tmp__201;
  54491. var __tmp__211;
  54492. var __tmp__221;
  54493. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  54494. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  54495. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  54496. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  54497. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  54498. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  54499. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  54500. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  54501. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  54502. dst1._rotation00 = __tmp__001;
  54503. dst1._rotation01 = __tmp__011;
  54504. dst1._rotation02 = __tmp__021;
  54505. dst1._rotation10 = __tmp__101;
  54506. dst1._rotation11 = __tmp__111;
  54507. dst1._rotation12 = __tmp__121;
  54508. dst1._rotation20 = __tmp__201;
  54509. dst1._rotation21 = __tmp__211;
  54510. dst1._rotation22 = __tmp__221;
  54511. var __tmp__X1;
  54512. var __tmp__Y1;
  54513. var __tmp__Z1;
  54514. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  54515. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  54516. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  54517. dst1._positionX = __tmp__X1;
  54518. dst1._positionY = __tmp__Y1;
  54519. dst1._positionZ = __tmp__Z1;
  54520. dst1._positionX += src21._positionX;
  54521. dst1._positionY += src21._positionY;
  54522. dst1._positionZ += src21._positionZ;
  54523. var min;
  54524. var minX;
  54525. var minY;
  54526. var minZ;
  54527. var max;
  54528. var maxX;
  54529. var maxY;
  54530. var maxZ;
  54531. s._geom._computeAabb(s._aabb,s._ptransform);
  54532. minX = s._aabb._minX;
  54533. minY = s._aabb._minY;
  54534. minZ = s._aabb._minZ;
  54535. maxX = s._aabb._maxX;
  54536. maxY = s._aabb._maxY;
  54537. maxZ = s._aabb._maxZ;
  54538. s._geom._computeAabb(s._aabb,s._transform);
  54539. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  54540. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  54541. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  54542. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  54543. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  54544. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  54545. if(s._proxy != null) {
  54546. var d;
  54547. var dX;
  54548. var dY;
  54549. var dZ;
  54550. dX = s._transform._positionX - s._ptransform._positionX;
  54551. dY = s._transform._positionY - s._ptransform._positionY;
  54552. dZ = s._transform._positionZ - s._ptransform._positionZ;
  54553. var v = s.displacement;
  54554. v.x = dX;
  54555. v.y = dY;
  54556. v.z = dZ;
  54557. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  54558. }
  54559. s = n;
  54560. }
  54561. }
  54562. }
  54563. getDensity() {
  54564. return this._density;
  54565. }
  54566. setDensity(density) {
  54567. this._density = density;
  54568. if(this._rigidBody != null) {
  54569. var _this = this._rigidBody;
  54570. _this.updateMass();
  54571. var s = _this._shapeList;
  54572. while(s != null) {
  54573. var n = s._next;
  54574. var dst = s._ptransform;
  54575. var src1 = s._localTransform;
  54576. var src2 = _this._ptransform;
  54577. var __tmp__00;
  54578. var __tmp__01;
  54579. var __tmp__02;
  54580. var __tmp__10;
  54581. var __tmp__11;
  54582. var __tmp__12;
  54583. var __tmp__20;
  54584. var __tmp__21;
  54585. var __tmp__22;
  54586. __tmp__00 = src2._rotation00 * src1._rotation00 + src2._rotation01 * src1._rotation10 + src2._rotation02 * src1._rotation20;
  54587. __tmp__01 = src2._rotation00 * src1._rotation01 + src2._rotation01 * src1._rotation11 + src2._rotation02 * src1._rotation21;
  54588. __tmp__02 = src2._rotation00 * src1._rotation02 + src2._rotation01 * src1._rotation12 + src2._rotation02 * src1._rotation22;
  54589. __tmp__10 = src2._rotation10 * src1._rotation00 + src2._rotation11 * src1._rotation10 + src2._rotation12 * src1._rotation20;
  54590. __tmp__11 = src2._rotation10 * src1._rotation01 + src2._rotation11 * src1._rotation11 + src2._rotation12 * src1._rotation21;
  54591. __tmp__12 = src2._rotation10 * src1._rotation02 + src2._rotation11 * src1._rotation12 + src2._rotation12 * src1._rotation22;
  54592. __tmp__20 = src2._rotation20 * src1._rotation00 + src2._rotation21 * src1._rotation10 + src2._rotation22 * src1._rotation20;
  54593. __tmp__21 = src2._rotation20 * src1._rotation01 + src2._rotation21 * src1._rotation11 + src2._rotation22 * src1._rotation21;
  54594. __tmp__22 = src2._rotation20 * src1._rotation02 + src2._rotation21 * src1._rotation12 + src2._rotation22 * src1._rotation22;
  54595. dst._rotation00 = __tmp__00;
  54596. dst._rotation01 = __tmp__01;
  54597. dst._rotation02 = __tmp__02;
  54598. dst._rotation10 = __tmp__10;
  54599. dst._rotation11 = __tmp__11;
  54600. dst._rotation12 = __tmp__12;
  54601. dst._rotation20 = __tmp__20;
  54602. dst._rotation21 = __tmp__21;
  54603. dst._rotation22 = __tmp__22;
  54604. var __tmp__X;
  54605. var __tmp__Y;
  54606. var __tmp__Z;
  54607. __tmp__X = src2._rotation00 * src1._positionX + src2._rotation01 * src1._positionY + src2._rotation02 * src1._positionZ;
  54608. __tmp__Y = src2._rotation10 * src1._positionX + src2._rotation11 * src1._positionY + src2._rotation12 * src1._positionZ;
  54609. __tmp__Z = src2._rotation20 * src1._positionX + src2._rotation21 * src1._positionY + src2._rotation22 * src1._positionZ;
  54610. dst._positionX = __tmp__X;
  54611. dst._positionY = __tmp__Y;
  54612. dst._positionZ = __tmp__Z;
  54613. dst._positionX += src2._positionX;
  54614. dst._positionY += src2._positionY;
  54615. dst._positionZ += src2._positionZ;
  54616. var dst1 = s._transform;
  54617. var src11 = s._localTransform;
  54618. var src21 = _this._transform;
  54619. var __tmp__001;
  54620. var __tmp__011;
  54621. var __tmp__021;
  54622. var __tmp__101;
  54623. var __tmp__111;
  54624. var __tmp__121;
  54625. var __tmp__201;
  54626. var __tmp__211;
  54627. var __tmp__221;
  54628. __tmp__001 = src21._rotation00 * src11._rotation00 + src21._rotation01 * src11._rotation10 + src21._rotation02 * src11._rotation20;
  54629. __tmp__011 = src21._rotation00 * src11._rotation01 + src21._rotation01 * src11._rotation11 + src21._rotation02 * src11._rotation21;
  54630. __tmp__021 = src21._rotation00 * src11._rotation02 + src21._rotation01 * src11._rotation12 + src21._rotation02 * src11._rotation22;
  54631. __tmp__101 = src21._rotation10 * src11._rotation00 + src21._rotation11 * src11._rotation10 + src21._rotation12 * src11._rotation20;
  54632. __tmp__111 = src21._rotation10 * src11._rotation01 + src21._rotation11 * src11._rotation11 + src21._rotation12 * src11._rotation21;
  54633. __tmp__121 = src21._rotation10 * src11._rotation02 + src21._rotation11 * src11._rotation12 + src21._rotation12 * src11._rotation22;
  54634. __tmp__201 = src21._rotation20 * src11._rotation00 + src21._rotation21 * src11._rotation10 + src21._rotation22 * src11._rotation20;
  54635. __tmp__211 = src21._rotation20 * src11._rotation01 + src21._rotation21 * src11._rotation11 + src21._rotation22 * src11._rotation21;
  54636. __tmp__221 = src21._rotation20 * src11._rotation02 + src21._rotation21 * src11._rotation12 + src21._rotation22 * src11._rotation22;
  54637. dst1._rotation00 = __tmp__001;
  54638. dst1._rotation01 = __tmp__011;
  54639. dst1._rotation02 = __tmp__021;
  54640. dst1._rotation10 = __tmp__101;
  54641. dst1._rotation11 = __tmp__111;
  54642. dst1._rotation12 = __tmp__121;
  54643. dst1._rotation20 = __tmp__201;
  54644. dst1._rotation21 = __tmp__211;
  54645. dst1._rotation22 = __tmp__221;
  54646. var __tmp__X1;
  54647. var __tmp__Y1;
  54648. var __tmp__Z1;
  54649. __tmp__X1 = src21._rotation00 * src11._positionX + src21._rotation01 * src11._positionY + src21._rotation02 * src11._positionZ;
  54650. __tmp__Y1 = src21._rotation10 * src11._positionX + src21._rotation11 * src11._positionY + src21._rotation12 * src11._positionZ;
  54651. __tmp__Z1 = src21._rotation20 * src11._positionX + src21._rotation21 * src11._positionY + src21._rotation22 * src11._positionZ;
  54652. dst1._positionX = __tmp__X1;
  54653. dst1._positionY = __tmp__Y1;
  54654. dst1._positionZ = __tmp__Z1;
  54655. dst1._positionX += src21._positionX;
  54656. dst1._positionY += src21._positionY;
  54657. dst1._positionZ += src21._positionZ;
  54658. var min;
  54659. var minX;
  54660. var minY;
  54661. var minZ;
  54662. var max;
  54663. var maxX;
  54664. var maxY;
  54665. var maxZ;
  54666. s._geom._computeAabb(s._aabb,s._ptransform);
  54667. minX = s._aabb._minX;
  54668. minY = s._aabb._minY;
  54669. minZ = s._aabb._minZ;
  54670. maxX = s._aabb._maxX;
  54671. maxY = s._aabb._maxY;
  54672. maxZ = s._aabb._maxZ;
  54673. s._geom._computeAabb(s._aabb,s._transform);
  54674. s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX;
  54675. s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY;
  54676. s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ;
  54677. s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX;
  54678. s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY;
  54679. s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ;
  54680. if(s._proxy != null) {
  54681. var d;
  54682. var dX;
  54683. var dY;
  54684. var dZ;
  54685. dX = s._transform._positionX - s._ptransform._positionX;
  54686. dY = s._transform._positionY - s._ptransform._positionY;
  54687. dZ = s._transform._positionZ - s._ptransform._positionZ;
  54688. var v = s.displacement;
  54689. v.x = dX;
  54690. v.y = dY;
  54691. v.z = dZ;
  54692. s._rigidBody._world._broadPhase.moveProxy(s._proxy,s._aabb,s.displacement);
  54693. }
  54694. s = n;
  54695. }
  54696. }
  54697. }
  54698. getAabb() {
  54699. return this._aabb.clone();
  54700. }
  54701. getAabbTo(aabb) {
  54702. aabb.copyFrom(this._aabb);
  54703. }
  54704. getGeometry() {
  54705. return this._geom;
  54706. }
  54707. getRigidBody() {
  54708. return this._rigidBody;
  54709. }
  54710. getCollisionGroup() {
  54711. return this._collisionGroup;
  54712. }
  54713. setCollisionGroup(collisionGroup) {
  54714. this._collisionGroup = collisionGroup;
  54715. }
  54716. getCollisionMask() {
  54717. return this._collisionMask;
  54718. }
  54719. setCollisionMask(collisionMask) {
  54720. this._collisionMask = collisionMask;
  54721. }
  54722. getContactCallback() {
  54723. return this._contactCallback;
  54724. }
  54725. setContactCallback(callback) {
  54726. this._contactCallback = callback;
  54727. }
  54728. getPrev() {
  54729. return this._prev;
  54730. }
  54731. getNext() {
  54732. return this._next;
  54733. }
  54734. }
  54735. oimo.dynamics.rigidbody.ShapeConfig = class oimo_dynamics_rigidbody_ShapeConfig {
  54736. constructor() {
  54737. this.position = new oimo.common.Vec3();
  54738. this.rotation = new oimo.common.Mat3();
  54739. this.friction = oimo.common.Setting.defaultFriction;
  54740. this.restitution = oimo.common.Setting.defaultRestitution;
  54741. this.density = oimo.common.Setting.defaultDensity;
  54742. this.collisionGroup = oimo.common.Setting.defaultCollisionGroup;
  54743. this.collisionMask = oimo.common.Setting.defaultCollisionMask;
  54744. this.geometry = null;
  54745. this.contactCallback = null;
  54746. }
  54747. }
  54748. if(!oimo.m) oimo.m = {};
  54749. oimo.m.M = class oimo_m_M {
  54750. }
  54751. oimo.collision.broadphase.BroadPhaseType._BRUTE_FORCE = 1;
  54752. oimo.collision.broadphase.BroadPhaseType._BVH = 2;
  54753. oimo.collision.broadphase.BroadPhaseType.BRUTE_FORCE = 1;
  54754. oimo.collision.broadphase.BroadPhaseType.BVH = 2;
  54755. oimo.collision.broadphase.bvh.BvhInsertionStrategy.SIMPLE = 0;
  54756. oimo.collision.broadphase.bvh.BvhInsertionStrategy.MINIMIZE_SURFACE_AREA = 1;
  54757. oimo.collision.geometry.GeometryType._SPHERE = 0;
  54758. oimo.collision.geometry.GeometryType._BOX = 1;
  54759. oimo.collision.geometry.GeometryType._CYLINDER = 2;
  54760. oimo.collision.geometry.GeometryType._CONE = 3;
  54761. oimo.collision.geometry.GeometryType._CAPSULE = 4;
  54762. oimo.collision.geometry.GeometryType._CONVEX_HULL = 5;
  54763. oimo.collision.geometry.GeometryType._CONVEX_MIN = 0;
  54764. oimo.collision.geometry.GeometryType._CONVEX_MAX = 5;
  54765. oimo.collision.geometry.GeometryType.SPHERE = 0;
  54766. oimo.collision.geometry.GeometryType.BOX = 1;
  54767. oimo.collision.geometry.GeometryType.CYLINDER = 2;
  54768. oimo.collision.geometry.GeometryType.CONE = 3;
  54769. oimo.collision.geometry.GeometryType.CAPSULE = 4;
  54770. oimo.collision.geometry.GeometryType.CONVEX_HULL = 5;
  54771. oimo.collision.narrowphase.detector.BoxBoxDetector.EDGE_BIAS_MULT = 1.0;
  54772. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.OK = 0;
  54773. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.INVALID_TRIANGLE = 1;
  54774. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.NO_ADJACENT_PAIR_INDEX = 2;
  54775. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.NO_ADJACENT_TRIANGLE = 3;
  54776. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.EDGE_LOOP_BROKEN = 4;
  54777. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.NO_OUTER_TRIANGLE = 5;
  54778. oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.TRIANGLE_INVISIBLE = 6;
  54779. oimo.collision.narrowphase.detector.gjkepa.EpaTriangle.count = 0;
  54780. oimo.common.Vec3.numCreations = 0;
  54781. oimo.common.Setting.defaultFriction = 0.2;
  54782. oimo.common.Setting.defaultRestitution = 0.2;
  54783. oimo.common.Setting.defaultDensity = 1;
  54784. oimo.common.Setting.defaultCollisionGroup = 1;
  54785. oimo.common.Setting.defaultCollisionMask = 1;
  54786. oimo.common.Setting.maxTranslationPerStep = 20;
  54787. oimo.common.Setting.maxRotationPerStep = 3.14159265358979;
  54788. oimo.common.Setting.bvhProxyPadding = 0.1;
  54789. oimo.common.Setting.bvhIncrementalCollisionThreshold = 0.45;
  54790. oimo.common.Setting.defaultGJKMargin = 0.05;
  54791. oimo.common.Setting.enableGJKCaching = true;
  54792. oimo.common.Setting.maxEPAVertices = 128;
  54793. oimo.common.Setting.maxEPAPolyhedronFaces = 128;
  54794. oimo.common.Setting.contactEnableBounceThreshold = 0.5;
  54795. oimo.common.Setting.velocityBaumgarte = 0.2;
  54796. oimo.common.Setting.positionSplitImpulseBaumgarte = 0.4;
  54797. oimo.common.Setting.positionNgsBaumgarte = 1.0;
  54798. oimo.common.Setting.contactUseAlternativePositionCorrectionAlgorithmDepthThreshold = 0.05;
  54799. oimo.common.Setting.defaultContactPositionCorrectionAlgorithm = 0;
  54800. oimo.common.Setting.alternativeContactPositionCorrectionAlgorithm = 1;
  54801. oimo.common.Setting.contactPersistenceThreshold = 0.05;
  54802. oimo.common.Setting.maxManifoldPoints = 4;
  54803. oimo.common.Setting.defaultJointConstraintSolverType = 0;
  54804. oimo.common.Setting.defaultJointPositionCorrectionAlgorithm = 0;
  54805. oimo.common.Setting.jointWarmStartingFactorForBaungarte = 0.8;
  54806. oimo.common.Setting.jointWarmStartingFactor = 0.95;
  54807. oimo.common.Setting.minSpringDamperDampingRatio = 1e-6;
  54808. oimo.common.Setting.minRagdollMaxSwingAngle = 1e-6;
  54809. oimo.common.Setting.maxJacobianRows = 6;
  54810. oimo.common.Setting.directMlcpSolverEps = 1e-9;
  54811. oimo.common.Setting.islandInitialRigidBodyArraySize = 128;
  54812. oimo.common.Setting.islandInitialConstraintArraySize = 128;
  54813. oimo.common.Setting.sleepingVelocityThreshold = 0.2;
  54814. oimo.common.Setting.sleepingAngularVelocityThreshold = 0.5;
  54815. oimo.common.Setting.sleepingTimeThreshold = 1.0;
  54816. oimo.common.Setting.disableSleeping = false;
  54817. oimo.common.Setting.linearSlop = 0.005;
  54818. oimo.common.Setting.angularSlop = 0.0174532925199432781;
  54819. oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance = new oimo.collision.narrowphase.detector.gjkepa.GjkEpa();
  54820. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._SUCCEEDED = 0;
  54821. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._GJK_FAILED_TO_MAKE_TETRAHEDRON = 1;
  54822. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._GJK_DID_NOT_CONVERGE = 2;
  54823. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._EPA_FAILED_TO_INIT = 257;
  54824. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._EPA_FAILED_TO_ADD_VERTEX = 258;
  54825. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._EPA_DID_NOT_CONVERGE = 259;
  54826. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.SUCCEEDED = 0;
  54827. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.GJK_FAILED_TO_MAKE_TETRAHEDRON = 1;
  54828. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.GJK_DID_NOT_CONVERGE = 2;
  54829. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_INIT = 257;
  54830. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_ADD_VERTEX = 258;
  54831. oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_DID_NOT_CONVERGE = 259;
  54832. oimo.common.Mat3.numCreations = 0;
  54833. oimo.common.Mat4.numCreations = 0;
  54834. oimo.common.MathUtil.POSITIVE_INFINITY = 1e65536;
  54835. oimo.common.MathUtil.NEGATIVE_INFINITY = -1e65536;
  54836. oimo.common.MathUtil.PI = 3.14159265358979;
  54837. oimo.common.MathUtil.TWO_PI = 6.28318530717958;
  54838. oimo.common.MathUtil.HALF_PI = 1.570796326794895;
  54839. oimo.common.MathUtil.TO_RADIANS = 0.0174532925199432781;
  54840. oimo.common.MathUtil.TO_DEGREES = 57.2957795130823797;
  54841. oimo.common.Quat.numCreations = 0;
  54842. oimo.dynamics.common.DebugDraw.SPHERE_PHI_DIVISION = 8;
  54843. oimo.dynamics.common.DebugDraw.SPHERE_THETA_DIVISION = 4;
  54844. oimo.dynamics.common.DebugDraw.CIRCLE_THETA_DIVISION = 8;
  54845. oimo.dynamics.common.Performance.broadPhaseCollisionTime = 0;
  54846. oimo.dynamics.common.Performance.narrowPhaseCollisionTime = 0;
  54847. oimo.dynamics.common.Performance.dynamicsTime = 0;
  54848. oimo.dynamics.common.Performance.totalTime = 0;
  54849. oimo.dynamics.constraint.PositionCorrectionAlgorithm._BAUMGARTE = 0;
  54850. oimo.dynamics.constraint.PositionCorrectionAlgorithm._SPLIT_IMPULSE = 1;
  54851. oimo.dynamics.constraint.PositionCorrectionAlgorithm._NGS = 2;
  54852. oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE = 0;
  54853. oimo.dynamics.constraint.PositionCorrectionAlgorithm.SPLIT_IMPULSE = 1;
  54854. oimo.dynamics.constraint.PositionCorrectionAlgorithm.NGS = 2;
  54855. oimo.dynamics.constraint.info.JacobianRow.BIT_LINEAR_SET = 1;
  54856. oimo.dynamics.constraint.info.JacobianRow.BIT_ANGULAR_SET = 2;
  54857. oimo.dynamics.constraint.joint.JointType._SPHERICAL = 0;
  54858. oimo.dynamics.constraint.joint.JointType._REVOLUTE = 1;
  54859. oimo.dynamics.constraint.joint.JointType._CYLINDRICAL = 2;
  54860. oimo.dynamics.constraint.joint.JointType._PRISMATIC = 3;
  54861. oimo.dynamics.constraint.joint.JointType._UNIVERSAL = 4;
  54862. oimo.dynamics.constraint.joint.JointType._RAGDOLL = 5;
  54863. oimo.dynamics.constraint.joint.JointType._GENERIC = 6;
  54864. oimo.dynamics.constraint.joint.JointType.SPHERICAL = 0;
  54865. oimo.dynamics.constraint.joint.JointType.REVOLUTE = 1;
  54866. oimo.dynamics.constraint.joint.JointType.CYLINDRICAL = 2;
  54867. oimo.dynamics.constraint.joint.JointType.PRISMATIC = 3;
  54868. oimo.dynamics.constraint.joint.JointType.UNIVERSAL = 4;
  54869. oimo.dynamics.constraint.joint.JointType.RAGDOLL = 5;
  54870. oimo.dynamics.constraint.joint.JointType.GENERIC = 6;
  54871. oimo.dynamics.constraint.solver.ConstraintSolverType._ITERATIVE = 0;
  54872. oimo.dynamics.constraint.solver.ConstraintSolverType._DIRECT = 1;
  54873. oimo.dynamics.constraint.solver.ConstraintSolverType.ITERATIVE = 0;
  54874. oimo.dynamics.constraint.solver.ConstraintSolverType.DIRECT = 1;
  54875. oimo.dynamics.rigidbody.RigidBodyType._DYNAMIC = 0;
  54876. oimo.dynamics.rigidbody.RigidBodyType._STATIC = 1;
  54877. oimo.dynamics.rigidbody.RigidBodyType._KINEMATIC = 2;
  54878. oimo.dynamics.rigidbody.RigidBodyType.DYNAMIC = 0;
  54879. oimo.dynamics.rigidbody.RigidBodyType.STATIC = 1;
  54880. oimo.dynamics.rigidbody.RigidBodyType.KINEMATIC = 2;
  54881. export {oimo};