init.lua 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459
  1. return {
  2. callbacks = {
  3. {
  4. name = "conf",
  5. tag = "callbacks",
  6. summary = "Called to read configuration settings at startup.",
  7. description = "The `lovr.conf` callback lets you configure default settings for LÖVR. It is called once right before the game starts. Make sure you put `lovr.conf` in a file called `conf.lua`, a special file that's loaded before the rest of the framework initializes.",
  8. key = "lovr.conf",
  9. module = "lovr",
  10. examples = {
  11. {
  12. description = "A noop conf.lua that sets all configuration settings to their defaults:",
  13. code = "function lovr.conf(t)\n\n -- Set the project version and identity\n t.version = '0.17.0'\n t.identity = 'default'\n\n -- Set save directory precedence\n t.saveprecedence = true\n\n -- Enable or disable different modules\n t.modules.audio = true\n t.modules.data = true\n t.modules.event = true\n t.modules.graphics = true\n t.modules.headset = true\n t.modules.math = true\n t.modules.physics = true\n t.modules.system = true\n t.modules.thread = true\n t.modules.timer = true\n\n -- Audio\n t.audio.spatializer = nil\n t.audio.samplerate = 48000\n t.audio.start = true\n\n -- Graphics\n t.graphics.debug = false\n t.graphics.vsync = true\n t.graphics.stencil = false\n t.graphics.antialias = true\n t.graphics.shadercache = true\n\n -- Headset settings\n t.headset.drivers = { 'openxr', 'desktop' }\n t.headset.supersample = false\n t.headset.seated = false\n t.headset.antialias = true\n t.headset.stencil = false\n t.headset.submitdepth = true\n t.headset.overlay = false\n\n -- Math settings\n t.math.globals = true\n\n -- Configure the desktop window\n t.window.width = 1080\n t.window.height = 600\n t.window.fullscreen = false\n t.window.resizable = false\n t.window.title = 'LÖVR'\n t.window.icon = nil\nend"
  14. }
  15. },
  16. notes = "Disabling unused modules can improve startup time.\n\n`t.window` can be set to nil to avoid creating the window. The window can later be opened manually using `lovr.system.openWindow`.\n\nEnabling the `t.graphics.debug` flag will add additional error checks and will send messages from the GPU driver to the `lovr.log` callback. This will decrease performance but can help provide information on performance problems or other bugs. It will also cause `lovr.graphics.newShader` to embed debugging information in shaders which allows inspecting variables and stepping through shaders line-by-line in tools like RenderDoc.\n\n`t.graphics.debug` can also be enabled using the `--graphics-debug` command line option.",
  17. related = {
  18. "lovr.load"
  19. },
  20. variants = {
  21. {
  22. arguments = {
  23. {
  24. name = "t",
  25. type = "table",
  26. description = "The table to edit the configuration settings on.",
  27. table = {
  28. {
  29. name = "version",
  30. type = "string",
  31. description = "The version of LÖVR this project targets (not used yet)."
  32. },
  33. {
  34. name = "identity",
  35. type = "string",
  36. description = "A unique label for this project."
  37. },
  38. {
  39. name = "saveprecedence",
  40. type = "boolean",
  41. description = "Whether the files in the save directory should have precedence over files in the source archive."
  42. },
  43. {
  44. name = "modules",
  45. type = "table",
  46. description = "The set of enabled modules to use.",
  47. table = {
  48. {
  49. name = "audio",
  50. type = "boolean",
  51. description = "Whether the audio module should be enabled."
  52. },
  53. {
  54. name = "data",
  55. type = "boolean",
  56. description = "Whether the data module should be enabled."
  57. },
  58. {
  59. name = "event",
  60. type = "boolean",
  61. description = "Whether the event module should be enabled."
  62. },
  63. {
  64. name = "graphics",
  65. type = "boolean",
  66. description = "Whether the graphics module should be enabled."
  67. },
  68. {
  69. name = "headset",
  70. type = "boolean",
  71. description = "Whether the headset module should be enabled."
  72. },
  73. {
  74. name = "math",
  75. type = "boolean",
  76. description = "Whether the math module should be enabled."
  77. },
  78. {
  79. name = "physics",
  80. type = "boolean",
  81. description = "Whether the physics module should be enabled."
  82. },
  83. {
  84. name = "system",
  85. type = "boolean",
  86. description = "Whether the system module should be enabled."
  87. },
  88. {
  89. name = "thread",
  90. type = "boolean",
  91. description = "Whether the thread module should be enabled."
  92. },
  93. {
  94. name = "timer",
  95. type = "boolean",
  96. description = "Whether the timer module should be enabled."
  97. }
  98. }
  99. },
  100. {
  101. name = "audio",
  102. type = "table",
  103. description = "Configuration for the audio module.",
  104. table = {
  105. {
  106. name = "spatializer",
  107. type = "string",
  108. description = "An audio spatializer to use (`simple`, `oculus`, or `phonon`). If `nil`, all of them are attempted."
  109. },
  110. {
  111. name = "samplerate",
  112. type = "number",
  113. description = "The sample rate to use for audio playback."
  114. },
  115. {
  116. name = "start",
  117. type = "boolean",
  118. description = "Whether the playback device should be automatically started."
  119. }
  120. }
  121. },
  122. {
  123. name = "graphics",
  124. type = "table",
  125. description = "Configuration for the graphics module.",
  126. table = {
  127. {
  128. name = "debug",
  129. type = "boolean",
  130. description = "Whether debug messages from the GPU should get sent to lovr.log."
  131. },
  132. {
  133. name = "vsync",
  134. type = "boolean",
  135. description = "Whether vsync is enabled (forced off when VR is active)."
  136. },
  137. {
  138. name = "stencil",
  139. type = "boolean",
  140. description = "Whether the desktop window should have a stencil buffer."
  141. },
  142. {
  143. name = "antialias",
  144. type = "boolean",
  145. description = "Whether the desktop window rendering should be antialiased."
  146. },
  147. {
  148. name = "shadercache",
  149. type = "boolean",
  150. description = "Whether the shader cache should be loaded and saved to disk."
  151. }
  152. }
  153. },
  154. {
  155. name = "headset",
  156. type = "table",
  157. description = "Configuration for the headset.",
  158. table = {
  159. {
  160. name = "drivers",
  161. type = "table",
  162. description = "An ordered list of preferred headset drivers."
  163. },
  164. {
  165. name = "supersample",
  166. type = "number",
  167. description = "A scaling factor to apply to the headset texture. Can be any positive floating point number, which gets multiplied by the default texture resolution. A value greater than 1 improves visual quality but reduces performance. Can also be a boolean, where \"true\" means \"2.0\"."
  168. },
  169. {
  170. name = "seated",
  171. type = "boolean",
  172. description = "Whether <a data-key=\"lovr.headset.isSeated\">seated mode</a> should be used instead of standing, changing the headset coordinate space to place y=0 at eye level."
  173. },
  174. {
  175. name = "antialias",
  176. type = "boolean",
  177. description = "Whether headset rendering should be antialiased."
  178. },
  179. {
  180. name = "stencil",
  181. type = "boolean",
  182. description = "Whether headset rendering should have a stencil buffer."
  183. },
  184. {
  185. name = "submitdepth",
  186. type = "boolean",
  187. description = "Whether the depth buffer should be sent to the VR runtime (improves reprojection)."
  188. },
  189. {
  190. name = "overlay",
  191. type = "boolean",
  192. description = "Whether the project should run as an overlay. Can also be a number to control sort order against other overlays (default is zero, higher numbers go on top)."
  193. }
  194. }
  195. },
  196. {
  197. name = "math",
  198. type = "table",
  199. description = "Configuration for the math module.",
  200. table = {
  201. {
  202. name = "globals",
  203. type = "boolean",
  204. description = "Whether vector object functions should be added to the global scope."
  205. }
  206. }
  207. },
  208. {
  209. name = "window",
  210. type = "table",
  211. description = "Configuration for the window.",
  212. table = {
  213. {
  214. name = "width",
  215. type = "number",
  216. description = "The width of the window."
  217. },
  218. {
  219. name = "height",
  220. type = "number",
  221. description = "The height of the window."
  222. },
  223. {
  224. name = "fullscreen",
  225. type = "boolean",
  226. description = "Whether the window is fullscreen."
  227. },
  228. {
  229. name = "resizable",
  230. type = "boolean",
  231. description = "Whether the window is resizable."
  232. },
  233. {
  234. name = "title",
  235. type = "string",
  236. description = "The window title."
  237. },
  238. {
  239. name = "icon",
  240. type = "string",
  241. description = "The path to the window icon file."
  242. }
  243. }
  244. }
  245. }
  246. }
  247. },
  248. returns = {}
  249. }
  250. }
  251. },
  252. {
  253. name = "draw",
  254. tag = "callbacks",
  255. summary = "Called continuously to render frames to the display.",
  256. description = "This callback is called every frame, and receives a `Pass` object as an argument which can be used to render graphics to the display. If a VR headset is connected, this function renders to the headset display, otherwise it will render to the desktop window.",
  257. key = "lovr.draw",
  258. module = "lovr",
  259. notes = "To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback.\n\nThe display is cleared to the global background color before this callback is called, which can be changed using `lovr.graphics.setBackgroundColor`.\n\nSince the `lovr.graphics.submit` function always returns true, the following idiom can be used to submit graphics work manually and override the default submission:\n\n function lovr.draw(pass)\n local passes = {}\n\n -- ... record multiple passes and add to passes table\n\n return lovr.graphics.submit(passes)\n end",
  260. related = {
  261. "lovr.mirror",
  262. "lovr.headset.getPass",
  263. "lovr.graphics.getWindowPass",
  264. "lovr.graphics.setBackgroundColor"
  265. },
  266. variants = {
  267. {
  268. arguments = {
  269. {
  270. name = "pass",
  271. type = "Pass",
  272. description = "A render pass targeting the main display (headset or window)."
  273. }
  274. },
  275. returns = {
  276. {
  277. name = "skip",
  278. type = "boolean",
  279. description = "If truthy, the input Pass will not be submitted to the GPU."
  280. }
  281. }
  282. }
  283. }
  284. },
  285. {
  286. name = "errhand",
  287. tag = "callbacks",
  288. summary = "Called when an error occurs.",
  289. description = "The `lovr.errhand` callback is run whenever an error occurs. It receives a parameter containing the error message. It should return a handler function that will run in a loop to render the error screen.\n\nThis handler function is of the same type as the one returned by `lovr.run` and has the same requirements (such as pumping events). If an error occurs while this handler is running, the program will terminate immediately -- `lovr.errhand` will not be given a second chance. Errors which occur in the error handler or in the handler it returns may not be cleanly reported, so be careful.\n\nA default error handler is supplied that renders the error message as text to the headset and to the window.",
  290. key = "lovr.errhand",
  291. module = "lovr",
  292. examples = {
  293. {
  294. description = "The default error handler.",
  295. code = "function lovr.errhand(message)\n local function formatTraceback(s)\n return s:gsub('\\n[^\\n]+$', ''):gsub('\\t', ''):gsub('stack traceback:', '\\nStack:\\n')\n end\n\n message = 'Error:\\n\\n' .. tostring(message) .. formatTraceback(debug.traceback('', 4))\n\n print(message)\n\n if not lovr.graphics or not lovr.graphics.isInitialized() then\n return function() return 1 end\n end\n\n if lovr.audio then lovr.audio.stop() end\n\n if not lovr.headset or lovr.headset.getPassthrough() == 'opaque' then\n lovr.graphics.setBackgroundColor(.11, .10, .14)\n else\n lovr.graphics.setBackgroundColor(0, 0, 0, 0)\n end\n\n local font = lovr.graphics.getDefaultFont()\n\n return function()\n lovr.system.pollEvents()\n\n for name, a in lovr.event.poll() do\n if name == 'quit' then return a or 1\n elseif name == 'restart' then return 'restart', lovr.restart and lovr.restart()\n elseif name == 'keypressed' and a == 'f5' then lovr.event.restart()\n elseif name == 'keypressed' and a == 'escape' then lovr.event.quit() end\n end\n\n if lovr.headset and lovr.headset.getDriver() ~= 'desktop' then\n lovr.headset.update()\n local pass = lovr.headset.getPass()\n if pass then\n font:setPixelDensity()\n\n local scale = .35\n local font = lovr.graphics.getDefaultFont()\n local wrap = .7 * font:getPixelDensity()\n local lines = font:getLines(message, wrap)\n local width = math.min(font:getWidth(message), wrap) * scale\n local height = .8 + #lines * font:getHeight() * scale\n local x = -width / 2\n local y = math.min(height / 2, 10)\n local z = -10\n\n pass:setColor(.95, .95, .95)\n pass:text(message, x, y, z, scale, 0, 0, 0, 0, wrap, 'left', 'top')\n\n lovr.graphics.submit(pass)\n lovr.headset.submit()\n end\n end\n\n if lovr.system.isWindowOpen() then\n local pass = lovr.graphics.getWindowPass()\n if pass then\n local w, h = lovr.system.getWindowDimensions()\n pass:setProjection(1, lovr.math.mat4():orthographic(0, w, 0, h, -1, 1))\n font:setPixelDensity(1)\n\n local scale = .6\n local wrap = w * .8 / scale\n local width = math.min(font:getWidth(message), wrap) * scale\n local x = w / 2 - width / 2\n\n pass:setColor(.95, .95, .95)\n pass:text(message, x, h / 2, 0, scale, 0, 0, 0, 0, wrap, 'left', 'middle')\n\n lovr.graphics.submit(pass)\n lovr.graphics.present()\n end\n end\n\n lovr.math.drain()\n end\nend"
  296. }
  297. },
  298. related = {
  299. "lovr.quit"
  300. },
  301. variants = {
  302. {
  303. arguments = {
  304. {
  305. name = "message",
  306. type = "string",
  307. description = "The error message."
  308. }
  309. },
  310. returns = {
  311. {
  312. name = "handler",
  313. type = "function",
  314. description = "The error handler function. It should return nil to continue running, \"restart\" to restart the app, or a number representing an exit status.",
  315. arguments = {},
  316. returns = {
  317. {
  318. name = "result",
  319. type = "*"
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. },
  327. {
  328. name = "focus",
  329. tag = "callbacks",
  330. summary = "Called when the application gains or loses input focus.",
  331. description = "The `lovr.focus` callback is called whenever the application acquires or loses focus (for example, when opening or closing the Steam dashboard). The callback receives a single argument, focused, which is a boolean indicating whether or not the application is now focused. It may make sense to pause the game or reduce visual fidelity when the application loses focus.",
  332. key = "lovr.focus",
  333. module = "lovr",
  334. related = {
  335. "lovr.headset.isFocused",
  336. "lovr.visible"
  337. },
  338. variants = {
  339. {
  340. arguments = {
  341. {
  342. name = "focused",
  343. type = "boolean",
  344. description = "Whether the program is now focused."
  345. }
  346. },
  347. returns = {}
  348. }
  349. }
  350. },
  351. {
  352. name = "keypressed",
  353. tag = "callbacks",
  354. summary = "Called when a key is pressed.",
  355. description = "This callback is called when a key is pressed.",
  356. key = "lovr.keypressed",
  357. module = "lovr",
  358. related = {
  359. "lovr.system.wasKeyPressed",
  360. "lovr.keyreleased",
  361. "lovr.textinput",
  362. "lovr.system.isKeyDown"
  363. },
  364. variants = {
  365. {
  366. arguments = {
  367. {
  368. name = "key",
  369. type = "KeyCode",
  370. description = "The key that was pressed."
  371. },
  372. {
  373. name = "scancode",
  374. type = "number",
  375. description = "The id of the key (ignores keyboard layout, may vary between keyboards)."
  376. },
  377. {
  378. name = "repeating",
  379. type = "boolean",
  380. description = "Whether the event is the result of a key repeat instead of an actual press."
  381. }
  382. },
  383. returns = {}
  384. }
  385. }
  386. },
  387. {
  388. name = "keyreleased",
  389. tag = "callbacks",
  390. summary = "Called when a key is released.",
  391. description = "This callback is called when a key is released.",
  392. key = "lovr.keyreleased",
  393. module = "lovr",
  394. related = {
  395. "lovr.system.wasKeyReleased",
  396. "lovr.keypressed",
  397. "lovr.textinput",
  398. "lovr.system.isKeyDown"
  399. },
  400. variants = {
  401. {
  402. arguments = {
  403. {
  404. name = "key",
  405. type = "KeyCode",
  406. description = "The key that was released."
  407. },
  408. {
  409. name = "scancode",
  410. type = "number",
  411. description = "The id of the key (ignores keyboard layout, may vary between keyboards)."
  412. }
  413. },
  414. returns = {}
  415. }
  416. }
  417. },
  418. {
  419. name = "load",
  420. tag = "callbacks",
  421. summary = "Called once at startup.",
  422. description = "This callback is called once when the app starts. It should be used to perform initial setup work, like loading resources and initializing classes and variables.",
  423. key = "lovr.load",
  424. module = "lovr",
  425. examples = {
  426. {
  427. code = "function lovr.load(arg)\n model = lovr.graphics.newModel('sponza.gltf')\n texture = lovr.graphics.newTexture('cena.png')\n effects = lovr.graphics.newShader('vert.glsl', 'frag.glsl')\n loadLevel(1)\nend"
  428. }
  429. },
  430. notes = "If the project was loaded from a restart using `lovr.event.restart`, the return value from the previously-run `lovr.restart` callback will be made available to this callback as the `restart` key in the `arg` table.\n\nThe `arg` table follows the [Lua standard](https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter). The arguments passed in from the shell are put into a global table named `arg` and passed to `lovr.load`, but with indices offset such that the \"script\" (the project path) is at index 0. So all arguments (if any) intended for the project are at successive indices starting with 1, and the executable and its \"internal\" arguments are in normal order but stored in negative indices.",
  431. related = {
  432. "lovr.quit"
  433. },
  434. variants = {
  435. {
  436. arguments = {
  437. {
  438. name = "arg",
  439. type = "table",
  440. description = "The command line arguments provided to the program."
  441. }
  442. },
  443. returns = {}
  444. }
  445. }
  446. },
  447. {
  448. name = "log",
  449. tag = "callbacks",
  450. summary = "Called when a message is logged.",
  451. description = "This callback is called when a message is logged. The default implementation of this callback prints the message to the console using `print`, but it's possible to override this callback to render messages in VR, write them to a file, filter messages, and more.\n\nThe message can have a \"tag\" that is a short string representing the sender, and a \"level\" indicating how severe the message is.\n\nThe `t.graphics.debug` flag in `lovr.conf` can be used to get log messages from the GPU driver (tagged as `GPU`). It is also possible to emit customlog messages using `lovr.event.push`, or by calling the callback.",
  452. key = "lovr.log",
  453. module = "lovr",
  454. related = {
  455. "Pass:text"
  456. },
  457. variants = {
  458. {
  459. arguments = {
  460. {
  461. name = "message",
  462. type = "string",
  463. description = "The log message. It may end in a newline."
  464. },
  465. {
  466. name = "level",
  467. type = "string",
  468. description = "The log level (`debug`, `info`, `warn`, or `error`)."
  469. },
  470. {
  471. name = "tag",
  472. type = "string",
  473. description = "The log tag."
  474. }
  475. },
  476. returns = {}
  477. }
  478. }
  479. },
  480. {
  481. name = "mirror",
  482. tag = "callbacks",
  483. summary = "Called to render content to the desktop window.",
  484. description = "This callback is called every frame after rendering to the headset and is usually used to render a mirror of the headset display onto the desktop window. It can be overridden for custom mirroring behavior. For example, a stereo view could be drawn instead of a single eye or a 2D HUD could be rendered.",
  485. key = "lovr.mirror",
  486. module = "lovr",
  487. examples = {
  488. {
  489. description = "The default `lovr.mirror` implementation draws the headset mirror texture to the window if the headset is active, or just calls `lovr.draw` if there isn't a headset.",
  490. code = "function lovr.mirror(pass)\n if lovr.headset then\n local texture = lovr.headset.getTexture()\n if texture then\n pass:fill(texture)\n else\n return true\n end\n else\n return lovr.draw and lovr.draw(pass)\n end\nend"
  491. }
  492. },
  493. related = {
  494. "lovr.system.openWindow",
  495. "lovr.draw"
  496. },
  497. variants = {
  498. {
  499. arguments = {
  500. {
  501. name = "pass",
  502. type = "Pass",
  503. description = "A render pass targeting the window."
  504. }
  505. },
  506. returns = {
  507. {
  508. name = "skip",
  509. type = "boolean",
  510. description = "If truthy, the input Pass will not be submitted to the GPU."
  511. }
  512. }
  513. }
  514. }
  515. },
  516. {
  517. name = "mousemoved",
  518. tag = "callbacks",
  519. summary = "Called when the mouse is moved.",
  520. description = "This callback is called when the mouse is moved.",
  521. key = "lovr.mousemoved",
  522. module = "lovr",
  523. related = {
  524. "lovr.mousepressed",
  525. "lovr.mousereleased",
  526. "lovr.wheelmoved",
  527. "lovr.system.getMouseX",
  528. "lovr.system.getMouseY",
  529. "lovr.system.getMousePosition"
  530. },
  531. variants = {
  532. {
  533. arguments = {
  534. {
  535. name = "x",
  536. type = "number",
  537. description = "The new x position of the mouse."
  538. },
  539. {
  540. name = "y",
  541. type = "number",
  542. description = "The new y position of the mouse."
  543. },
  544. {
  545. name = "dx",
  546. type = "number",
  547. description = "The movement on the x axis since the last mousemove event."
  548. },
  549. {
  550. name = "dy",
  551. type = "number",
  552. description = "The movement on the y axis since the last mousemove event."
  553. }
  554. },
  555. returns = {}
  556. }
  557. }
  558. },
  559. {
  560. name = "mousepressed",
  561. tag = "callbacks",
  562. summary = "Called when a mouse button is pressed.",
  563. description = "This callback is called when a mouse button is pressed.",
  564. key = "lovr.mousepressed",
  565. module = "lovr",
  566. related = {
  567. "lovr.mousereleased",
  568. "lovr.mousemoved",
  569. "lovr.wheelmoved",
  570. "lovr.system.isMouseDown"
  571. },
  572. variants = {
  573. {
  574. arguments = {
  575. {
  576. name = "x",
  577. type = "number",
  578. description = "The x position of the mouse when the button was pressed."
  579. },
  580. {
  581. name = "y",
  582. type = "number",
  583. description = "The y position of the mouse when the button was pressed."
  584. },
  585. {
  586. name = "button",
  587. type = "number",
  588. description = "The button that was pressed. Will be 1 for the primary button, 2 for the secondary button, or 3 for the middle mouse button."
  589. }
  590. },
  591. returns = {}
  592. }
  593. }
  594. },
  595. {
  596. name = "mousereleased",
  597. tag = "callbacks",
  598. summary = "Called when a mouse button is released.",
  599. description = "This callback is called when a mouse button is released.",
  600. key = "lovr.mousereleased",
  601. module = "lovr",
  602. related = {
  603. "lovr.mousepressed",
  604. "lovr.mousemoved",
  605. "lovr.wheelmoved",
  606. "lovr.system.isMouseDown"
  607. },
  608. variants = {
  609. {
  610. arguments = {
  611. {
  612. name = "x",
  613. type = "number",
  614. description = "The x position of the mouse when the button was released."
  615. },
  616. {
  617. name = "y",
  618. type = "number",
  619. description = "The y position of the mouse when the button was released."
  620. },
  621. {
  622. name = "button",
  623. type = "number",
  624. description = "The button that was released. Will be 1 for the primary button, 2 for the secondary button, or 3 for the middle mouse button."
  625. }
  626. },
  627. returns = {}
  628. }
  629. }
  630. },
  631. {
  632. name = "permission",
  633. tag = "callbacks",
  634. summary = "Called when a permission request is answered.",
  635. description = "This callback contains a permission response previously requested with `lovr.system.requestPermission`. The callback contains information on whether permission was granted or denied.",
  636. key = "lovr.permission",
  637. module = "lovr",
  638. related = {
  639. "lovr.system.requestPermission"
  640. },
  641. variants = {
  642. {
  643. arguments = {
  644. {
  645. name = "permission",
  646. type = "Permission",
  647. description = "The type of permission."
  648. },
  649. {
  650. name = "granted",
  651. type = "boolean",
  652. description = "Whether permission was granted or denied."
  653. }
  654. },
  655. returns = {}
  656. }
  657. }
  658. },
  659. {
  660. name = "quit",
  661. tag = "callbacks",
  662. summary = "Called before quitting.",
  663. description = "This callback is called right before the application is about to quit. Use it to perform any necessary cleanup work. A truthy value can be returned from this callback to abort quitting.",
  664. key = "lovr.quit",
  665. module = "lovr",
  666. examples = {
  667. {
  668. code = "function lovr.quit()\n if shouldQuit() then\n return false\n else\n return true\n end\nend"
  669. }
  670. },
  671. related = {
  672. "lovr.event.quit",
  673. "lovr.load"
  674. },
  675. variants = {
  676. {
  677. arguments = {},
  678. returns = {
  679. {
  680. name = "abort",
  681. type = "boolean",
  682. description = "Whether quitting should be aborted."
  683. }
  684. }
  685. }
  686. }
  687. },
  688. {
  689. name = "recenter",
  690. tag = "callbacks",
  691. summary = "Called when the user recenters the coordinate space.",
  692. description = "The `lovr.recenter` callback is called whenever the user performs a \"recenter\" gesture to realign the virtual coordinate space. On most VR systems this will move the origin to the user's current position and rotate its yaw to match the view direction. The y=0 position will always be on the floor or at eye level, depending on whether `t.headset.seated` was set in `lovr.conf`.",
  693. key = "lovr.recenter",
  694. module = "lovr",
  695. notes = "Note that the pose of the `floor` device will not always be at the origin of the coordinate space. It uses a fixed position on the floor in the real world, usually the center of the configured play area. This allows virtual objects to be positioned in a room without having them jump around after a recenter.",
  696. related = {
  697. "lovr.headset.getBoundsWidth",
  698. "lovr.headset.getBoundsDepth",
  699. "lovr.headset.getBoundsDimensions",
  700. "lovr.headset.getBoundsGeometry",
  701. "lovr.headset.isSeated"
  702. },
  703. variants = {
  704. {
  705. arguments = {},
  706. returns = {}
  707. }
  708. }
  709. },
  710. {
  711. name = "resize",
  712. tag = "callbacks",
  713. summary = "Called when the window is resized.",
  714. description = "This callback is called when the desktop window is resized.",
  715. key = "lovr.resize",
  716. module = "lovr",
  717. related = {
  718. "Pass:getDimensions",
  719. "Pass:getWidth",
  720. "Pass:getHeight",
  721. "lovr.headset.getDisplayDimensions",
  722. "lovr.conf"
  723. },
  724. variants = {
  725. {
  726. arguments = {
  727. {
  728. name = "width",
  729. type = "number",
  730. description = "The new width of the window."
  731. },
  732. {
  733. name = "height",
  734. type = "number",
  735. description = "The new height of the window."
  736. }
  737. },
  738. returns = {}
  739. }
  740. }
  741. },
  742. {
  743. name = "restart",
  744. tag = "callbacks",
  745. summary = "Called when restarting.",
  746. description = "This callback is called when a restart from `lovr.event.restart` is happening. A value can be returned to send it to the next LÖVR instance, available as the `restart` key in the argument table passed to `lovr.load`. Object instances can not be used as the restart value, since they are destroyed as part of the cleanup process.",
  747. key = "lovr.restart",
  748. module = "lovr",
  749. examples = {
  750. {
  751. code = "function lovr.restart()\n return currentLevel:getName()\nend"
  752. }
  753. },
  754. notes = "Only nil, booleans, numbers, and strings are supported types for the return value.",
  755. related = {
  756. "lovr.event.restart",
  757. "lovr.load",
  758. "lovr.quit"
  759. },
  760. variants = {
  761. {
  762. arguments = {},
  763. returns = {
  764. {
  765. name = "cookie",
  766. type = "*",
  767. description = "The value to send to the next `lovr.load`."
  768. }
  769. }
  770. }
  771. }
  772. },
  773. {
  774. name = "run",
  775. tag = "callbacks",
  776. summary = "The main entry point.",
  777. description = "This callback is the main entry point for a LÖVR program. It calls `lovr.load` and returns a function that will be called every frame.",
  778. key = "lovr.run",
  779. module = "lovr",
  780. examples = {
  781. {
  782. description = "The default `lovr.run`:",
  783. code = "function lovr.run()\n if lovr.timer then lovr.timer.step() end\n if lovr.load then lovr.load(arg) end\n return function()\n if lovr.system then lovr.system.pollEvents() end\n if lovr.event then\n for name, a, b, c, d in lovr.event.poll() do\n if name == 'restart' then\n local cookie = lovr.restart and lovr.restart()\n return 'restart', cookie\n elseif name == 'quit' and (not lovr.quit or not lovr.quit(a)) then\n return a or 0\n end\n if lovr.handlers[name] then lovr.handlers[name](a, b, c, d) end\n end\n end\n local dt = 0\n if lovr.timer then dt = lovr.timer.step() end\n if lovr.headset then dt = lovr.headset.update() end\n if lovr.update then lovr.update(dt) end\n if lovr.graphics then\n local headset = lovr.headset and lovr.headset.getPass()\n if headset and (not lovr.draw or lovr.draw(headset)) then headset = nil end\n local window = lovr.graphics.getWindowPass()\n if window and (not lovr.mirror or lovr.mirror(window)) then window = nil end\n lovr.graphics.submit(headset, window)\n lovr.graphics.present()\n end\n if lovr.headset then lovr.headset.submit() end\n if lovr.math then lovr.math.drain() end\n end\nend"
  784. }
  785. },
  786. notes = "The main loop function can return one of the following values:\n\n- Returning `nil` will keep the main loop running.\n- Returning the string 'restart' plus an optional value will restart LÖVR. The value can be\n accessed in the `restart` key of the `arg` global.\n- Returning a number will exit LÖVR using the number as the exit code (0 means success).\n\nCare should be taken when overriding this callback. For example, if the main loop does not call `lovr.system.pollEvents` then the OS will think LÖVR is unresponsive, or if the quit event is not handled then closing the window won't work.",
  787. related = {
  788. "lovr.load",
  789. "lovr.quit"
  790. },
  791. variants = {
  792. {
  793. arguments = {},
  794. returns = {
  795. {
  796. name = "loop",
  797. type = "function",
  798. description = "The main loop function.",
  799. arguments = {},
  800. returns = {
  801. {
  802. name = "result",
  803. type = "*"
  804. }
  805. }
  806. }
  807. }
  808. }
  809. }
  810. },
  811. {
  812. name = "textinput",
  813. tag = "callbacks",
  814. summary = "Called when text has been entered.",
  815. description = "This callback is called when text has been entered.\n\nFor example, when `shift + 1` is pressed on an American keyboard, `lovr.textinput` will be called with `!`.",
  816. key = "lovr.textinput",
  817. module = "lovr",
  818. notes = "Some characters in UTF-8 unicode take multiple bytes to encode. Due to the way Lua works, the length of these strings will be bigger than 1 even though they are just a single character. The `utf8` library included with LÖVR can be used to manipulate UTF-8 strings. `Pass:text` will also correctly handle UTF-8.",
  819. related = {
  820. "lovr.keypressed",
  821. "lovr.keyreleased"
  822. },
  823. variants = {
  824. {
  825. arguments = {
  826. {
  827. name = "text",
  828. type = "string",
  829. description = "The UTF-8 encoded character."
  830. },
  831. {
  832. name = "code",
  833. type = "number",
  834. description = "The integer codepoint of the character."
  835. }
  836. },
  837. returns = {}
  838. }
  839. }
  840. },
  841. {
  842. name = "threaderror",
  843. tag = "callbacks",
  844. summary = "Called when an error occurs in a thread.",
  845. description = "The `lovr.threaderror` callback is called whenever an error occurs in a Thread. It receives the Thread object where the error occurred and an error message.\n\nThe default implementation of this callback will call `lovr.errhand` with the error.",
  846. key = "lovr.threaderror",
  847. module = "lovr",
  848. related = {
  849. "Thread",
  850. "Thread:getError",
  851. "lovr.errhand"
  852. },
  853. variants = {
  854. {
  855. arguments = {
  856. {
  857. name = "thread",
  858. type = "Thread",
  859. description = "The Thread that errored."
  860. },
  861. {
  862. name = "message",
  863. type = "string",
  864. description = "The error message."
  865. }
  866. },
  867. returns = {}
  868. }
  869. }
  870. },
  871. {
  872. name = "update",
  873. tag = "callbacks",
  874. summary = "Called every frame to update the application logic.",
  875. description = "The `lovr.update` callback should be used to update your game's logic. It receives a single parameter, `dt`, which represents the amount of elapsed time between frames. You can use this value to scale timers, physics, and animations in your game so they play at a smooth, consistent speed.",
  876. key = "lovr.update",
  877. module = "lovr",
  878. examples = {
  879. {
  880. code = "function lovr.update(dt)\n ball.vy = ball.vy + ball.gravity * dt\n ball.y = ball.y + ball.vy * dt\nend"
  881. }
  882. },
  883. related = {
  884. "lovr.timer.getDelta"
  885. },
  886. variants = {
  887. {
  888. arguments = {
  889. {
  890. name = "dt",
  891. type = "number",
  892. description = "The number of seconds elapsed since the last update."
  893. }
  894. },
  895. returns = {}
  896. }
  897. }
  898. },
  899. {
  900. name = "visible",
  901. tag = "callbacks",
  902. summary = "Called when the application gains or loses visibility.",
  903. description = "The `lovr.visible` callback is called whenever the application becomes visible or invisible. `lovr.draw` may still be called even while invisible to give the VR runtime timing info. If the VR runtime decides the application doesn't need to render anymore, LÖVR will detect this and stop calling `lovr.draw`.",
  904. key = "lovr.visible",
  905. module = "lovr",
  906. related = {
  907. "lovr.headset.isVisible",
  908. "lovr.focus"
  909. },
  910. variants = {
  911. {
  912. arguments = {
  913. {
  914. name = "visible",
  915. type = "boolean",
  916. description = "Whether the application is visible in the headset display."
  917. }
  918. },
  919. returns = {}
  920. }
  921. }
  922. },
  923. {
  924. name = "wheelmoved",
  925. tag = "callbacks",
  926. summary = "Called when a mouse wheel is moved.",
  927. description = "This callback is called on scroll action, from a mouse wheel or a touchpad",
  928. key = "lovr.wheelmoved",
  929. module = "lovr",
  930. related = {
  931. "lovr.mousepressed",
  932. "lovr.mousereleased",
  933. "lovr.mousemoved",
  934. "lovr.system.isMouseDown"
  935. },
  936. variants = {
  937. {
  938. arguments = {
  939. {
  940. name = "deltaX",
  941. type = "number",
  942. description = "The relative horizontal motion; rightward movement resuts in positive values."
  943. },
  944. {
  945. name = "deltaY",
  946. type = "number",
  947. description = "The relative vertical motion; upward movement results in positive values."
  948. }
  949. },
  950. returns = {}
  951. }
  952. }
  953. }
  954. },
  955. modules = {
  956. {
  957. name = "enet",
  958. tag = "libraries",
  959. summary = "UDP networking library.",
  960. description = "ENet is a UDP networking plugin bundled with LÖVR that can be used for networking and multiplayer experiences. ENet allows messages to be marked for reliable and in-order delivery, allowing the speed of UDP to be used without sacrificing reliability.\n\nThe full documentation and examples can be found on the [lua-enet](http://leafo.net/lua-enet/) page. LÖVE also has lua-enet documentation [here](https://love2d.org/wiki/lua-enet).",
  961. key = "enet",
  962. enums = {},
  963. examples = {
  964. {
  965. description = "Here's a simple echo server example. The client sends a message to the server and waits for a response. The server waits for a message and sends it back to the client.",
  966. code = "-- client/main.lua\nlocal enet = require 'enet'\n\nfunction lovr.load()\n local host = enet.host_create()\n local server = host:connect('localhost:6789')\n\n local done = false\n while not done do\n local event = host:service(100)\n if event then\n if event.type == 'connect' then\n print('Connected to', event.peer)\n event.peer:send('hello world')\n elseif event.type == 'receive' then\n print('Got message: ', event.data, event.peer)\n done = true\n end\n end\n end\n\n server:disconnect()\n host:flush()\nend\n\n-- server/main.lua\nlocal enet = require 'enet'\n\nfunction lovr.load()\n local host = enet.host_create('localhost:6789')\n while true do\n local event = host:service(100)\n if event and event.type == 'receive' then\n print('Got message: ', event.data, event.peer)\n event.peer:send(event.data)\n end\n end\nend"
  967. }
  968. },
  969. external = true,
  970. functions = {},
  971. objects = {}
  972. },
  973. {
  974. name = "http",
  975. tag = "libraries",
  976. summary = "HTTP(S) requests.",
  977. description = "The [lovr-http](https://github.com/bjornbytes/lovr-http) plugin performs HTTP requests.\n\nFirst, `require` the plugin and save it into a variable: `local http = require 'http'`.\n\nThe module has one function:\n\n status, data, headers = http.request(url, [options])\n\nThis will perform an HTTP request and block until the request is complete.\n\n### Arguments\n\n`url` is the URL to request. If it doesn't have a protocol, then `http://` will be added.\n\n`options` is optional, and is used for advanced request settings.\n\n`options.method` is the HTTP method to use, also called the verb. `GET` is used by default if there's no data in the request, otherwise it defauls to `POST`. It will be converted to all-caps.\n\n`options.data` is the data to send to the server, also called the body. It can be a few different types:\n\n- When `data` is nil, no request body will be sent (and `method` will default to `GET`).\n- When `data` is a string, the string will be used directly as the request body.\n- When `data` is a table, then pairs in the table will be URL encoded and concatenated together\n to form an `application/x-www-form-urlencoded` body. For example, if data is\n `{ n = 10, k = 'v!' }`, then the request body will be something like `k=v%21&n=10`. Table\n pairs will only be used if the key is a string and the value is a string or number.\n- When `data` is a lightuserdata, the data pointed to by the lightuserdata will be used as the\n request body. Additionally, the `datasize` option should be an integer indicating how big the\n request body is, in bytes.\n\nWhen `options.data` is set, the `Content-Type` request header will default to `application/x-www-urlencoded` unless it's set to something else.\n\n`options.headers` is a table of request headers to send to the server. Pairs in the table will only be used if the key is a string and the value is a string or number.\n\n### Returns\n\nIf an error occurs, the function returns `nil, errormessage`.\n\nOtherwise, 3 values are returned:\n\n- `status` is an integer with the HTTP status code (200 is OK, 404 is Not Found, etc.).\n- `data` is a string with the data sent by the server (HTML, JSON, binary, etc.).\n- `headers` is a table of response headers.",
  978. key = "http",
  979. enums = {},
  980. examples = {
  981. {
  982. code = "local http = require 'http'\n\nlocal status, data, headers = http.request('https://zombo.com')\n\nprint('welcome')\nprint(status)\nprint(data)\nprint('headers:')\nfor k, v in pairs(headers) do\n print('\\t' .. k, v)\nend"
  983. }
  984. },
  985. external = true,
  986. functions = {},
  987. notes = "On Linux, this module requires the `curl` library to be installed. Example on Debian-based distributions:\n\n sudo apt install libcurl4-openssl-dev",
  988. objects = {}
  989. },
  990. {
  991. name = "lovr",
  992. summary = "In the beginning, there was nothing.",
  993. description = "`lovr` is the single global table that is exposed to every LÖVR app. It contains a set of **modules** and a set of **callbacks**.",
  994. key = "lovr",
  995. enums = {},
  996. functions = {
  997. {
  998. name = "getVersion",
  999. tag = "version",
  1000. summary = "Get the current version.",
  1001. description = "Get the current major, minor, and patch version of LÖVR.",
  1002. key = "lovr.getVersion",
  1003. module = "lovr",
  1004. variants = {
  1005. {
  1006. arguments = {},
  1007. returns = {
  1008. {
  1009. name = "major",
  1010. type = "number",
  1011. description = "The major version."
  1012. },
  1013. {
  1014. name = "minor",
  1015. type = "number",
  1016. description = "The minor version."
  1017. },
  1018. {
  1019. name = "patch",
  1020. type = "number",
  1021. description = "The patch number."
  1022. }
  1023. }
  1024. }
  1025. }
  1026. }
  1027. },
  1028. objects = {
  1029. {
  1030. name = "Object",
  1031. summary = "The base object.",
  1032. description = "The superclass of all LÖVR objects. All objects have these methods.",
  1033. key = "Object",
  1034. module = "lovr",
  1035. methods = {
  1036. {
  1037. name = "release",
  1038. summary = "Immediately release the Lua reference to an object.",
  1039. description = "Immediately destroys Lua's reference to the object it's called on. After calling this function on an object, it is an error to do anything with the object from Lua (call methods on it, pass it to other functions, etc.). If nothing else is using the object, it will be destroyed immediately, which can be used to destroy something earlier than it would normally be garbage collected in order to reduce memory.",
  1040. key = "Object:release",
  1041. module = "lovr",
  1042. notes = "The object may not be destroyed immediately if something else is referring to it (e.g. it is pushed to a Channel or exists in the payload of a pending event).",
  1043. variants = {
  1044. {
  1045. arguments = {},
  1046. returns = {}
  1047. }
  1048. }
  1049. },
  1050. {
  1051. name = "type",
  1052. summary = "Get the type name of the object.",
  1053. description = "Returns the name of the object's type as a string.",
  1054. key = "Object:type",
  1055. module = "lovr",
  1056. examples = {
  1057. {
  1058. code = "function isTexture(obj)\n return type(obj) == 'userdata' and obj:type() == 'Texture'\nend"
  1059. }
  1060. },
  1061. variants = {
  1062. {
  1063. arguments = {},
  1064. returns = {
  1065. {
  1066. name = "type",
  1067. type = "string",
  1068. description = "The type of the object."
  1069. }
  1070. }
  1071. }
  1072. }
  1073. }
  1074. },
  1075. notes = "Note that the functions here don't apply to any vector objects, see `Vectors`."
  1076. }
  1077. },
  1078. sections = {
  1079. {
  1080. name = "Modules",
  1081. tag = "modules",
  1082. description = "Modules are the **what** of your app; you can use the functions in modules to tell LÖVR to do things. For example, you can draw things on the screen, figure out what buttons on a controller are pressed, or load a 3D model from a file. Each module does what it says on the tin, so the `lovr.graphics` module deals with rendering graphics and `lovr.headset` allows you to interact with VR hardware."
  1083. },
  1084. {
  1085. name = "Callbacks",
  1086. tag = "callbacks",
  1087. description = "Callbacks are the **when** of the application; you write code inside callbacks which LÖVR then calls at certain points in time. For example, the `lovr.load` callback is called once at startup, and `lovr.focus` is called when the VR application gains or loses input focus."
  1088. },
  1089. {
  1090. name = "Version",
  1091. tag = "version",
  1092. description = "This function can be used to get the current version of LÖVR."
  1093. },
  1094. {
  1095. name = "Libraries",
  1096. tag = "libraries",
  1097. description = "LÖVR bundles a few third-party modules by default."
  1098. }
  1099. }
  1100. },
  1101. {
  1102. name = "audio",
  1103. tag = "modules",
  1104. summary = "Plays sound.",
  1105. description = "The `lovr.audio` module is responsible for playing sound effects and music. To play a sound, create a `Source` object and call `Source:play` on it. Currently ogg, wav, and mp3 audio formats are supported.",
  1106. key = "lovr.audio",
  1107. enums = {
  1108. {
  1109. name = "AudioMaterial",
  1110. summary = "Different types of audio materials.",
  1111. description = "Different types of audio material presets, for use with `lovr.audio.setGeometry`.",
  1112. key = "AudioMaterial",
  1113. module = "lovr.audio",
  1114. values = {
  1115. {
  1116. name = "generic",
  1117. description = "Generic default audio material."
  1118. },
  1119. {
  1120. name = "brick",
  1121. description = "Brick."
  1122. },
  1123. {
  1124. name = "carpet",
  1125. description = "Carpet."
  1126. },
  1127. {
  1128. name = "ceramic",
  1129. description = "Ceramic."
  1130. },
  1131. {
  1132. name = "concrete",
  1133. description = "Concrete."
  1134. },
  1135. {
  1136. name = "glass",
  1137. description = "Glass."
  1138. },
  1139. {
  1140. name = "gravel",
  1141. description = "Gravel."
  1142. },
  1143. {
  1144. name = "metal",
  1145. description = "Metal."
  1146. },
  1147. {
  1148. name = "plaster",
  1149. description = "Plaster."
  1150. },
  1151. {
  1152. name = "rock",
  1153. description = "Rock."
  1154. },
  1155. {
  1156. name = "wood",
  1157. description = "Wood."
  1158. }
  1159. }
  1160. },
  1161. {
  1162. name = "AudioShareMode",
  1163. summary = "How audio devices are shared on the system.",
  1164. description = "Audio devices can be created in shared mode or exclusive mode. In exclusive mode, the audio device is the only one active on the system, which gives better performance and lower latency. However, exclusive devices aren't always supported and might not be allowed, so there is a higher chance that creating one will fail.",
  1165. key = "AudioShareMode",
  1166. module = "lovr.audio",
  1167. related = {
  1168. "lovr.audio.setDevice"
  1169. },
  1170. values = {
  1171. {
  1172. name = "shared",
  1173. description = "Shared mode."
  1174. },
  1175. {
  1176. name = "exclusive",
  1177. description = "Exclusive mode."
  1178. }
  1179. }
  1180. },
  1181. {
  1182. name = "AudioType",
  1183. summary = "Different types of audio devices",
  1184. description = "When referencing audio devices, this indicates whether it's the playback or capture device.",
  1185. key = "AudioType",
  1186. module = "lovr.audio",
  1187. related = {
  1188. "lovr.audio.getDevices",
  1189. "lovr.audio.setDevice",
  1190. "lovr.audio.start",
  1191. "lovr.audio.stop",
  1192. "lovr.audio.isStarted"
  1193. },
  1194. values = {
  1195. {
  1196. name = "playback",
  1197. description = "The playback device (speakers, headphones)."
  1198. },
  1199. {
  1200. name = "capture",
  1201. description = "The capture device (microphone)."
  1202. }
  1203. }
  1204. },
  1205. {
  1206. name = "Effect",
  1207. summary = "Different types of Source effects.",
  1208. description = "Different types of effects that can be applied with `Source:setEffectEnabled`.",
  1209. key = "Effect",
  1210. module = "lovr.audio",
  1211. notes = "The active spatializer will determine which effects are supported. If an unsupported effect is enabled on a Source, no error will be reported. Instead, it will be silently ignored.\n\nSee `lovr.audio.getSpatializer` for a table of the supported effects for each spatializer.",
  1212. values = {
  1213. {
  1214. name = "absorption",
  1215. description = "Models absorption as sound travels through the air, water, etc."
  1216. },
  1217. {
  1218. name = "attenuation",
  1219. description = "Decreases audio volume with distance (1 / max(distance, 1))."
  1220. },
  1221. {
  1222. name = "occlusion",
  1223. description = "Causes audio to drop off when the Source is occluded by geometry."
  1224. },
  1225. {
  1226. name = "reverb",
  1227. description = "Models reverb caused by audio bouncing off of geometry."
  1228. },
  1229. {
  1230. name = "spatialization",
  1231. description = "Spatializes the Source using either simple panning or an HRTF."
  1232. },
  1233. {
  1234. name = "transmission",
  1235. description = "Causes audio to be heard through walls when occluded, based on audio materials."
  1236. }
  1237. }
  1238. },
  1239. {
  1240. name = "TimeUnit",
  1241. summary = "Time units for sound samples.",
  1242. description = "When figuring out how long a Source is or seeking to a specific position in the sound file, units can be expressed in terms of seconds or in terms of frames. A frame is one set of samples for each channel (one sample for mono, two samples for stereo).",
  1243. key = "TimeUnit",
  1244. module = "lovr.audio",
  1245. values = {
  1246. {
  1247. name = "seconds",
  1248. description = "Seconds."
  1249. },
  1250. {
  1251. name = "frames",
  1252. description = "Frames."
  1253. }
  1254. }
  1255. },
  1256. {
  1257. name = "VolumeUnit",
  1258. summary = "Different units of volume.",
  1259. description = "When accessing the volume of Sources or the audio listener, this can be done in linear units with a 0 to 1 range, or in decibels with a range of -∞ to 0.",
  1260. key = "VolumeUnit",
  1261. module = "lovr.audio",
  1262. values = {
  1263. {
  1264. name = "linear",
  1265. description = "Linear volume range."
  1266. },
  1267. {
  1268. name = "db",
  1269. description = "Decibels."
  1270. }
  1271. }
  1272. }
  1273. },
  1274. functions = {
  1275. {
  1276. name = "getAbsorption",
  1277. summary = "Get the absorption coefficients.",
  1278. description = "Returns the global air absorption coefficients for the medium. This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.). The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. This can be used to apply \"underwater\" effects and stuff.",
  1279. key = "lovr.audio.getAbsorption",
  1280. module = "lovr.audio",
  1281. notes = "Absorption is currently only supported by the phonon spatializer.\n\nThe frequency bands correspond to `400Hz`, `2.5KHz`, and `15KHz`.\n\nThe default coefficients are `.0002`, `.0017`, and `.0182` for low, mid, and high.",
  1282. variants = {
  1283. {
  1284. arguments = {},
  1285. returns = {
  1286. {
  1287. name = "low",
  1288. type = "number",
  1289. description = "The absorption coefficient for the low frequency band."
  1290. },
  1291. {
  1292. name = "mid",
  1293. type = "number",
  1294. description = "The absorption coefficient for the mid frequency band."
  1295. },
  1296. {
  1297. name = "high",
  1298. type = "number",
  1299. description = "The absorption coefficient for the high frequency band."
  1300. }
  1301. }
  1302. }
  1303. }
  1304. },
  1305. {
  1306. name = "getDevice",
  1307. tag = "devices",
  1308. summary = "Get the current audio device.",
  1309. description = "Returns information about the active playback or capture device.",
  1310. key = "lovr.audio.getDevice",
  1311. module = "lovr.audio",
  1312. notes = "If no device has been set yet, this function returns `nil`.\n\nThe device doesn't need to be started.",
  1313. related = {
  1314. "lovr.audio.getDevices",
  1315. "lovr.audio.setDevice"
  1316. },
  1317. variants = {
  1318. {
  1319. arguments = {
  1320. {
  1321. name = "type",
  1322. type = "AudioType",
  1323. description = "The type of device to query.",
  1324. default = "'playback'"
  1325. }
  1326. },
  1327. returns = {
  1328. {
  1329. name = "name",
  1330. type = "string",
  1331. description = "The name of the device."
  1332. },
  1333. {
  1334. name = "id",
  1335. type = "userdata",
  1336. description = "The opaque id of the device."
  1337. }
  1338. }
  1339. }
  1340. }
  1341. },
  1342. {
  1343. name = "getDevices",
  1344. tag = "devices",
  1345. summary = "Get a list of audio devices.",
  1346. description = "Returns a list of playback or capture devices. Each device has an `id`, `name`, and a `default` flag indicating whether it's the default device.\n\nTo use a specific device id for playback or capture, pass it to `lovr.audio.setDevice`.",
  1347. key = "lovr.audio.getDevices",
  1348. module = "lovr.audio",
  1349. related = {
  1350. "lovr.audio.setDevice",
  1351. "lovr.audio.getDevice",
  1352. "lovr.audio.start",
  1353. "lovr.audio.stop"
  1354. },
  1355. variants = {
  1356. {
  1357. arguments = {
  1358. {
  1359. name = "type",
  1360. type = "AudioType",
  1361. description = "The type of devices to query (playback or capture).",
  1362. default = "'playback'"
  1363. }
  1364. },
  1365. returns = {
  1366. {
  1367. name = "devices",
  1368. type = "table",
  1369. description = "The list of devices.",
  1370. table = {
  1371. {
  1372. name = "[].id",
  1373. type = "userdata",
  1374. description = "A unique, opaque id for the device."
  1375. },
  1376. {
  1377. name = "[].name",
  1378. type = "string",
  1379. description = "A human readable name for the device."
  1380. },
  1381. {
  1382. name = "[].default",
  1383. type = "boolean",
  1384. description = "Whether the device is the default audio device."
  1385. }
  1386. }
  1387. }
  1388. }
  1389. }
  1390. }
  1391. },
  1392. {
  1393. name = "getOrientation",
  1394. tag = "listener",
  1395. summary = "Get the orientation of the listener.",
  1396. description = "Returns the orientation of the virtual audio listener in angle/axis representation.",
  1397. key = "lovr.audio.getOrientation",
  1398. module = "lovr.audio",
  1399. related = {
  1400. "lovr.audio.getPosition",
  1401. "lovr.audio.getPose",
  1402. "Source:getOrientation"
  1403. },
  1404. variants = {
  1405. {
  1406. arguments = {},
  1407. returns = {
  1408. {
  1409. name = "angle",
  1410. type = "number",
  1411. description = "The number of radians the listener is rotated around its axis of rotation."
  1412. },
  1413. {
  1414. name = "ax",
  1415. type = "number",
  1416. description = "The x component of the axis of rotation."
  1417. },
  1418. {
  1419. name = "ay",
  1420. type = "number",
  1421. description = "The y component of the axis of rotation."
  1422. },
  1423. {
  1424. name = "az",
  1425. type = "number",
  1426. description = "The z component of the axis of rotation."
  1427. }
  1428. }
  1429. }
  1430. }
  1431. },
  1432. {
  1433. name = "getPose",
  1434. tag = "listener",
  1435. summary = "Get the pose of the listener.",
  1436. description = "Returns the position and orientation of the virtual audio listener.",
  1437. key = "lovr.audio.getPose",
  1438. module = "lovr.audio",
  1439. related = {
  1440. "lovr.audio.getPosition",
  1441. "lovr.audio.getOrientation",
  1442. "Source:getPose"
  1443. },
  1444. variants = {
  1445. {
  1446. arguments = {},
  1447. returns = {
  1448. {
  1449. name = "x",
  1450. type = "number",
  1451. description = "The x position of the listener, in meters."
  1452. },
  1453. {
  1454. name = "y",
  1455. type = "number",
  1456. description = "The y position of the listener, in meters."
  1457. },
  1458. {
  1459. name = "z",
  1460. type = "number",
  1461. description = "The z position of the listener, in meters."
  1462. },
  1463. {
  1464. name = "angle",
  1465. type = "number",
  1466. description = "The number of radians the listener is rotated around its axis of rotation."
  1467. },
  1468. {
  1469. name = "ax",
  1470. type = "number",
  1471. description = "The x component of the axis of rotation."
  1472. },
  1473. {
  1474. name = "ay",
  1475. type = "number",
  1476. description = "The y component of the axis of rotation."
  1477. },
  1478. {
  1479. name = "az",
  1480. type = "number",
  1481. description = "The z component of the axis of rotation."
  1482. }
  1483. }
  1484. }
  1485. }
  1486. },
  1487. {
  1488. name = "getPosition",
  1489. tag = "listener",
  1490. summary = "Get the position of the listener.",
  1491. description = "Returns the position of the virtual audio listener, in meters.",
  1492. key = "lovr.audio.getPosition",
  1493. module = "lovr.audio",
  1494. variants = {
  1495. {
  1496. arguments = {},
  1497. returns = {
  1498. {
  1499. name = "x",
  1500. type = "number",
  1501. description = "The x position of the listener."
  1502. },
  1503. {
  1504. name = "y",
  1505. type = "number",
  1506. description = "The y position of the listener."
  1507. },
  1508. {
  1509. name = "z",
  1510. type = "number",
  1511. description = "The z position of the listener."
  1512. }
  1513. }
  1514. }
  1515. }
  1516. },
  1517. {
  1518. name = "getSampleRate",
  1519. tag = "devices",
  1520. summary = "Get the playback device sample rate.",
  1521. description = "Returns the sample rate used by the playback device. This can be changed using `lovr.conf`.",
  1522. key = "lovr.audio.getSampleRate",
  1523. module = "lovr.audio",
  1524. related = {
  1525. "lovr.conf"
  1526. },
  1527. variants = {
  1528. {
  1529. arguments = {},
  1530. returns = {
  1531. {
  1532. name = "rate",
  1533. type = "number",
  1534. description = "The sample rate of the playback device, in Hz."
  1535. }
  1536. }
  1537. }
  1538. }
  1539. },
  1540. {
  1541. name = "getSpatializer",
  1542. tag = "listener",
  1543. summary = "Get the name of the active spatializer",
  1544. description = "Returns the name of the active spatializer (`simple`, `oculus`, or `phonon`).\n\nThe `t.audio.spatializer` setting in `lovr.conf` can be used to express a preference for a particular spatializer. If it's `nil`, all spatializers will be tried in the following order: `phonon`, `oculus`, `simple`.",
  1545. key = "lovr.audio.getSpatializer",
  1546. module = "lovr.audio",
  1547. notes = "Using a feature or effect that is not supported by the current spatializer will not error, it just won't do anything.\n\n<table>\n <thead>\n <tr>\n <td>Feature</td>\n <td>simple</td>\n <td>phonon</td>\n <td>oculus</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>Effect: Spatialization</td>\n <td>x</td>\n <td>x</td>\n <td>x</td>\n </tr>\n <tr>\n <td>Effect: Attenuation</td>\n <td>x</td>\n <td>x</td>\n <td>x</td>\n </tr>\n <tr>\n <td>Effect: Absorption</td>\n <td></td>\n <td>x</td>\n <td></td>\n </tr>\n <tr>\n <td>Effect: Occlusion</td>\n <td></td>\n <td>x</td>\n <td></td>\n </tr>\n <tr>\n <td>Effect: Transmission</td>\n <td></td>\n <td>x</td>\n <td></td>\n </tr>\n <tr>\n <td>Effect: Reverb</td>\n <td></td>\n <td>x</td>\n <td></td>\n </tr>\n <tr>\n <td>lovr.audio.setGeometry</td>\n <td></td>\n <td>x</td>\n <td></td>\n </tr>\n <tr>\n <td>Source:setDirectivity</td>\n <td>x</td>\n <td>x</td>\n <td></td>\n </tr>\n <tr>\n <td>Source:setRadius</td>\n <td></td>\n <td>x</td>\n <td></td>\n </tr>\n </tbody> </table>",
  1548. related = {
  1549. "lovr.conf"
  1550. },
  1551. variants = {
  1552. {
  1553. arguments = {},
  1554. returns = {
  1555. {
  1556. name = "spatializer",
  1557. type = "string",
  1558. description = "The name of the active spatializer."
  1559. }
  1560. }
  1561. }
  1562. }
  1563. },
  1564. {
  1565. name = "getVolume",
  1566. tag = "listener",
  1567. summary = "Get the master volume.",
  1568. description = "Returns the master volume. All audio sent to the playback device has its volume multiplied by this factor.",
  1569. key = "lovr.audio.getVolume",
  1570. module = "lovr.audio",
  1571. notes = "The default volume is 1.0 (0 dB).",
  1572. variants = {
  1573. {
  1574. arguments = {
  1575. {
  1576. name = "units",
  1577. type = "VolumeUnit",
  1578. description = "The units to return (linear or db).",
  1579. default = "'linear'"
  1580. }
  1581. },
  1582. returns = {
  1583. {
  1584. name = "volume",
  1585. type = "number",
  1586. description = "The master volume."
  1587. }
  1588. }
  1589. }
  1590. }
  1591. },
  1592. {
  1593. name = "isStarted",
  1594. tag = "devices",
  1595. summary = "Check if an audio device is started.",
  1596. description = "Returns whether an audio device is started.",
  1597. key = "lovr.audio.isStarted",
  1598. module = "lovr.audio",
  1599. related = {
  1600. "lovr.audio.start",
  1601. "lovr.audio.stop"
  1602. },
  1603. variants = {
  1604. {
  1605. arguments = {
  1606. {
  1607. name = "type",
  1608. type = "AudioType",
  1609. description = "The type of device to check.",
  1610. default = "'playback'"
  1611. }
  1612. },
  1613. returns = {
  1614. {
  1615. name = "started",
  1616. type = "boolean",
  1617. description = "Whether the device is active."
  1618. }
  1619. }
  1620. }
  1621. }
  1622. },
  1623. {
  1624. name = "newSource",
  1625. tag = "sources",
  1626. summary = "Create a new Source.",
  1627. description = "Creates a new Source from an ogg, wav, or mp3 file.",
  1628. key = "lovr.audio.newSource",
  1629. module = "lovr.audio",
  1630. examples = {
  1631. {
  1632. code = "function lovr.load()\n sandstorm = lovr.audio.newSource('darude.ogg', {\n decode = false,\n effects = { 'spatialization', attenuation = false, reverb = true }\n })\n\n sandstorm:play()\nend"
  1633. }
  1634. },
  1635. related = {
  1636. "Source:clone"
  1637. },
  1638. variants = {
  1639. {
  1640. arguments = {
  1641. {
  1642. name = "filename",
  1643. type = "string",
  1644. description = "The filename of the sound to load."
  1645. },
  1646. {
  1647. name = "options",
  1648. type = "table",
  1649. description = "Optional options.",
  1650. table = {
  1651. {
  1652. name = "decode",
  1653. type = "boolean",
  1654. description = "Whether to immediately decode compressed sounds, instead of progressively decoding as the Source plays. Enabling this will use more memory but reduce CPU overhead during playback. Recommended for short sound effects.",
  1655. default = "false"
  1656. },
  1657. {
  1658. name = "pitchable",
  1659. type = "boolean",
  1660. description = "Whether the pitch of the Source can be changed with `Source:setPitch`. Setting this to false will improve performance slightly.",
  1661. default = "true"
  1662. },
  1663. {
  1664. name = "spatial",
  1665. type = "boolean",
  1666. description = "Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing. Enabling an effect on a non-spatial source will raise an error.",
  1667. default = "true"
  1668. },
  1669. {
  1670. name = "effects",
  1671. type = "table",
  1672. description = "A table of `Effect`s to enable on the Source. This can be a list (numeric keys, effect name values) or a map (effect name keys, boolean values) or a mix of the two. Effects can also be enabled later using `Source:setEffectEnabled`. If nil, all effects will be enabled. Ignored if the `spatial` flag is false.",
  1673. default = "nil"
  1674. }
  1675. }
  1676. }
  1677. },
  1678. returns = {
  1679. {
  1680. name = "source",
  1681. type = "Source",
  1682. description = "The new Source."
  1683. }
  1684. }
  1685. },
  1686. {
  1687. arguments = {
  1688. {
  1689. name = "blob",
  1690. type = "Blob",
  1691. description = "The Blob containing the Source data."
  1692. },
  1693. {
  1694. name = "options",
  1695. type = "table",
  1696. description = "Optional options.",
  1697. table = {
  1698. {
  1699. name = "decode",
  1700. type = "boolean",
  1701. description = "Whether to immediately decode compressed sounds, instead of progressively decoding as the Source plays. Enabling this will use more memory but reduce CPU overhead during playback. Recommended for short sound effects.",
  1702. default = "false"
  1703. },
  1704. {
  1705. name = "pitchable",
  1706. type = "boolean",
  1707. description = "Whether the pitch of the Source can be changed with `Source:setPitch`. Setting this to false will improve performance slightly.",
  1708. default = "true"
  1709. },
  1710. {
  1711. name = "spatial",
  1712. type = "boolean",
  1713. description = "Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing. Enabling an effect on a non-spatial source will raise an error.",
  1714. default = "true"
  1715. },
  1716. {
  1717. name = "effects",
  1718. type = "table",
  1719. description = "A table of `Effect`s to enable on the Source. This can be a list (numeric keys, effect name values) or a map (effect name keys, boolean values) or a mix of the two. Effects can also be enabled later using `Source:setEffectEnabled`. If nil, all effects will be enabled. Ignored if the `spatial` flag is false.",
  1720. default = "nil"
  1721. }
  1722. }
  1723. }
  1724. },
  1725. returns = {
  1726. {
  1727. name = "source",
  1728. type = "Source",
  1729. description = "The new Source."
  1730. }
  1731. }
  1732. },
  1733. {
  1734. arguments = {
  1735. {
  1736. name = "sound",
  1737. type = "Sound",
  1738. description = "The Sound containing raw audio samples to play."
  1739. },
  1740. {
  1741. name = "options",
  1742. type = "table",
  1743. description = "Optional options.",
  1744. table = {
  1745. {
  1746. name = "decode",
  1747. type = "boolean",
  1748. description = "Whether to immediately decode compressed sounds, instead of progressively decoding as the Source plays. Enabling this will use more memory but reduce CPU overhead during playback. Recommended for short sound effects.",
  1749. default = "false"
  1750. },
  1751. {
  1752. name = "pitchable",
  1753. type = "boolean",
  1754. description = "Whether the pitch of the Source can be changed with `Source:setPitch`. Setting this to false will improve performance slightly.",
  1755. default = "true"
  1756. },
  1757. {
  1758. name = "spatial",
  1759. type = "boolean",
  1760. description = "Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing. Enabling an effect on a non-spatial source will raise an error.",
  1761. default = "true"
  1762. },
  1763. {
  1764. name = "effects",
  1765. type = "table",
  1766. description = "A table of `Effect`s to enable on the Source. This can be a list (numeric keys, effect name values) or a map (effect name keys, boolean values) or a mix of the two. Effects can also be enabled later using `Source:setEffectEnabled`. If nil, all effects will be enabled. Ignored if the `spatial` flag is false.",
  1767. default = "nil"
  1768. }
  1769. }
  1770. }
  1771. },
  1772. returns = {
  1773. {
  1774. name = "source",
  1775. type = "Source",
  1776. description = "The new Source."
  1777. }
  1778. }
  1779. }
  1780. }
  1781. },
  1782. {
  1783. name = "setAbsorption",
  1784. summary = "Set the absorption coefficients.",
  1785. description = "Sets the global air absorption coefficients for the medium. This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.). The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. This can be used to apply \"underwater\" effects and stuff.",
  1786. key = "lovr.audio.setAbsorption",
  1787. module = "lovr.audio",
  1788. notes = "Absorption is currently only supported by the phonon spatializer.\n\nThe frequency bands correspond to `400Hz`, `2.5KHz`, and `15KHz`.\n\nThe default coefficients are `.0002`, `.0017`, and `.0182` for low, mid, and high.",
  1789. variants = {
  1790. {
  1791. arguments = {
  1792. {
  1793. name = "low",
  1794. type = "number",
  1795. description = "The absorption coefficient for the low frequency band."
  1796. },
  1797. {
  1798. name = "mid",
  1799. type = "number",
  1800. description = "The absorption coefficient for the mid frequency band."
  1801. },
  1802. {
  1803. name = "high",
  1804. type = "number",
  1805. description = "The absorption coefficient for the high frequency band."
  1806. }
  1807. },
  1808. returns = {}
  1809. }
  1810. }
  1811. },
  1812. {
  1813. name = "setDevice",
  1814. tag = "devices",
  1815. summary = "Switch audio devices.",
  1816. description = "Switches either the playback or capture device to a new one.\n\nIf a device for the given type is already active, it will be stopped and destroyed. The new device will not be started automatically, use `lovr.audio.start` to start it.\n\nA device id (previously retrieved using `lovr.audio.getDevices`) can be given to use a specific audio device, or `nil` can be used for the id to use the default audio device.\n\nA sink can be also be provided when changing the device. A sink is an audio stream (`Sound` object with a `stream` type) that will receive all audio samples played (for playback) or all audio samples captured (for capture). When an audio device with a sink is started, be sure to periodically call `Sound:read` on the sink to read audio samples from it, otherwise it will overflow and discard old data. The sink can have any format, data will be converted as needed. Using a sink for the playback device will reduce performance, but this isn't the case for capture devices.\n\nAudio devices can be started in `shared` or `exclusive` mode. Exclusive devices may have lower latency than shared devices, but there's a higher chance that requesting exclusive access to an audio device will fail (either because it isn't supported or allowed). One strategy is to first try the device in exclusive mode, switching to shared if it doesn't work.",
  1817. key = "lovr.audio.setDevice",
  1818. module = "lovr.audio",
  1819. related = {
  1820. "lovr.audio.getDevice",
  1821. "lovr.audio.getDevices",
  1822. "lovr.audio.start",
  1823. "lovr.audio.stop"
  1824. },
  1825. variants = {
  1826. {
  1827. arguments = {
  1828. {
  1829. name = "type",
  1830. type = "AudioType",
  1831. description = "The device to switch.",
  1832. default = "'playback'"
  1833. },
  1834. {
  1835. name = "id",
  1836. type = "userdata",
  1837. description = "The id of the device to use, or `nil` to use the default device.",
  1838. default = "nil"
  1839. },
  1840. {
  1841. name = "sink",
  1842. type = "Sound",
  1843. description = "An optional audio stream to use as a sink for the device.",
  1844. default = "nil"
  1845. },
  1846. {
  1847. name = "mode",
  1848. type = "AudioShareMode",
  1849. description = "The sharing mode for the device.",
  1850. default = "shared"
  1851. }
  1852. },
  1853. returns = {
  1854. {
  1855. name = "success",
  1856. type = "boolean",
  1857. description = "Whether creating the audio device succeeded."
  1858. }
  1859. }
  1860. }
  1861. }
  1862. },
  1863. {
  1864. name = "setGeometry",
  1865. tag = "listener",
  1866. summary = "Set the geometry for audio effects.",
  1867. description = "Sets a mesh of triangles to use for modeling audio effects, using a table of vertices or a Model. When the appropriate effects are enabled, audio from `Source` objects will correctly be occluded by walls and bounce around to create realistic reverb.\n\nAn optional `AudioMaterial` may be provided to specify the acoustic properties of the geometry.",
  1868. key = "lovr.audio.setGeometry",
  1869. module = "lovr.audio",
  1870. notes = "This is currently only supported/used by the `phonon` spatializer.\n\nThe `Effect`s that use geometry are:\n\n- `occlusion`\n- `reverb`\n- `transmission`\n\nIf an existing geometry has been set, this function will replace it.\n\nThe triangles must use counterclockwise winding.",
  1871. related = {
  1872. "lovr.audio.getSpatializer",
  1873. "Source:setEffectEnabled"
  1874. },
  1875. variants = {
  1876. {
  1877. arguments = {
  1878. {
  1879. name = "vertices",
  1880. type = "table",
  1881. description = "A flat table of vertices. Each vertex is 3 numbers representing its x, y, and z position. The units used for audio coordinates are up to you, but meters are recommended."
  1882. },
  1883. {
  1884. name = "indices",
  1885. type = "table",
  1886. description = "A list of indices, indicating how the vertices are connected into triangles. Indices are 1-indexed and are 32 bits (they can be bigger than 65535)."
  1887. },
  1888. {
  1889. name = "material",
  1890. type = "AudioMaterial",
  1891. description = "The acoustic material to use.",
  1892. default = "'generic'"
  1893. }
  1894. },
  1895. returns = {
  1896. {
  1897. name = "success",
  1898. type = "boolean",
  1899. description = "Whether audio geometry is supported by the current spatializer and the geometry was loaded successfully."
  1900. }
  1901. }
  1902. },
  1903. {
  1904. arguments = {
  1905. {
  1906. name = "model",
  1907. type = "Model",
  1908. description = "A model to use for the audio geometry."
  1909. },
  1910. {
  1911. name = "material",
  1912. type = "AudioMaterial",
  1913. description = "The acoustic material to use.",
  1914. default = "'generic'"
  1915. }
  1916. },
  1917. returns = {
  1918. {
  1919. name = "success",
  1920. type = "boolean",
  1921. description = "Whether audio geometry is supported by the current spatializer and the geometry was loaded successfully."
  1922. }
  1923. }
  1924. }
  1925. }
  1926. },
  1927. {
  1928. name = "setOrientation",
  1929. tag = "listener",
  1930. summary = "Set the orientation of the listener.",
  1931. description = "Sets the orientation of the virtual audio listener in angle/axis representation.",
  1932. key = "lovr.audio.setOrientation",
  1933. module = "lovr.audio",
  1934. related = {
  1935. "lovr.audio.setPosition",
  1936. "lovr.audio.setPose",
  1937. "Source:setOrientation"
  1938. },
  1939. variants = {
  1940. {
  1941. description = "Set the listener orientation using numbers.",
  1942. arguments = {
  1943. {
  1944. name = "angle",
  1945. type = "number",
  1946. description = "The number of radians the listener should be rotated around its rotation axis."
  1947. },
  1948. {
  1949. name = "ax",
  1950. type = "number",
  1951. description = "The x component of the axis of rotation."
  1952. },
  1953. {
  1954. name = "ay",
  1955. type = "number",
  1956. description = "The y component of the axis of rotation."
  1957. },
  1958. {
  1959. name = "az",
  1960. type = "number",
  1961. description = "The z component of the axis of rotation."
  1962. }
  1963. },
  1964. returns = {}
  1965. },
  1966. {
  1967. description = "Set the listener orientation using a vector.",
  1968. arguments = {
  1969. {
  1970. name = "orientation",
  1971. type = "Quat",
  1972. description = "The orientation of the listener."
  1973. }
  1974. },
  1975. returns = {}
  1976. }
  1977. }
  1978. },
  1979. {
  1980. name = "setPose",
  1981. tag = "listener",
  1982. summary = "Set the pose of the listener.",
  1983. description = "Sets the position and orientation of the virtual audio listener.",
  1984. key = "lovr.audio.setPose",
  1985. module = "lovr.audio",
  1986. notes = "The position of the listener doesn't use any specific units, but usually they can be thought of as meters to match the headset module.",
  1987. related = {
  1988. "lovr.audio.setPosition",
  1989. "lovr.audio.setOrientation",
  1990. "Source:setPose"
  1991. },
  1992. variants = {
  1993. {
  1994. description = "Set the pose of the listener using numbers.",
  1995. arguments = {
  1996. {
  1997. name = "x",
  1998. type = "number",
  1999. description = "The x position of the listener."
  2000. },
  2001. {
  2002. name = "y",
  2003. type = "number",
  2004. description = "The y position of the listener."
  2005. },
  2006. {
  2007. name = "z",
  2008. type = "number",
  2009. description = "The z position of the listener."
  2010. },
  2011. {
  2012. name = "angle",
  2013. type = "number",
  2014. description = "The number of radians the listener is rotated around its axis of rotation."
  2015. },
  2016. {
  2017. name = "ax",
  2018. type = "number",
  2019. description = "The x component of the axis of rotation."
  2020. },
  2021. {
  2022. name = "ay",
  2023. type = "number",
  2024. description = "The y component of the axis of rotation."
  2025. },
  2026. {
  2027. name = "az",
  2028. type = "number",
  2029. description = "The z component of the axis of rotation."
  2030. }
  2031. },
  2032. returns = {}
  2033. },
  2034. {
  2035. description = "Set the pose of the listener using vector types.",
  2036. arguments = {
  2037. {
  2038. name = "position",
  2039. type = "Vec3",
  2040. description = "The position of the listener."
  2041. },
  2042. {
  2043. name = "orientation",
  2044. type = "Quat",
  2045. description = "The orientation of the listener."
  2046. }
  2047. },
  2048. returns = {}
  2049. }
  2050. }
  2051. },
  2052. {
  2053. name = "setPosition",
  2054. tag = "listener",
  2055. summary = "Set the position of the listener.",
  2056. description = "Sets the position of the virtual audio listener. The position doesn't have any specific units, but usually they can be thought of as meters, to match the headset module.",
  2057. key = "lovr.audio.setPosition",
  2058. module = "lovr.audio",
  2059. related = {
  2060. "lovr.audio.setOrientation",
  2061. "lovr.audio.setPose",
  2062. "Source:setPosition"
  2063. },
  2064. variants = {
  2065. {
  2066. description = "Set the listener position using numbers.",
  2067. arguments = {
  2068. {
  2069. name = "x",
  2070. type = "number",
  2071. description = "The x position of the listener."
  2072. },
  2073. {
  2074. name = "y",
  2075. type = "number",
  2076. description = "The y position of the listener."
  2077. },
  2078. {
  2079. name = "z",
  2080. type = "number",
  2081. description = "The z position of the listener."
  2082. }
  2083. },
  2084. returns = {}
  2085. },
  2086. {
  2087. description = "Set the listener position using a vector.",
  2088. arguments = {
  2089. {
  2090. name = "position",
  2091. type = "Vec3",
  2092. description = "The listener position."
  2093. }
  2094. },
  2095. returns = {}
  2096. }
  2097. }
  2098. },
  2099. {
  2100. name = "setVolume",
  2101. tag = "listener",
  2102. summary = "Set the master volume.",
  2103. description = "Sets the master volume. All audio sent to the playback device has its volume multiplied by this factor.",
  2104. key = "lovr.audio.setVolume",
  2105. module = "lovr.audio",
  2106. notes = "The volume will be clamped to a 0-1 range (0 dB).",
  2107. variants = {
  2108. {
  2109. arguments = {
  2110. {
  2111. name = "volume",
  2112. type = "number",
  2113. description = "The master volume."
  2114. },
  2115. {
  2116. name = "units",
  2117. type = "VolumeUnit",
  2118. description = "The units of the value.",
  2119. default = "'linear'"
  2120. }
  2121. },
  2122. returns = {}
  2123. }
  2124. }
  2125. },
  2126. {
  2127. name = "start",
  2128. tag = "devices",
  2129. summary = "Start an audio device.",
  2130. description = "Starts the active playback or capture device. By default the playback device is initialized and started, but this can be controlled using the `t.audio.start` flag in `lovr.conf`.",
  2131. key = "lovr.audio.start",
  2132. module = "lovr.audio",
  2133. notes = "Starting an audio device may fail if:\n\n- The device is already started\n- No device was initialized with `lovr.audio.setDevice`\n- Lack of `audiocapture` permission on Android (see `lovr.system.requestPermission`)\n- Some other problem accessing the audio device",
  2134. related = {
  2135. "lovr.audio.getDevices",
  2136. "lovr.audio.setDevice",
  2137. "lovr.audio.stop",
  2138. "lovr.audio.isStarted",
  2139. "lovr.system.requestPermission",
  2140. "lovr.permission"
  2141. },
  2142. variants = {
  2143. {
  2144. arguments = {
  2145. {
  2146. name = "type",
  2147. type = "AudioType",
  2148. description = "The type of device to start.",
  2149. default = "'playback'"
  2150. }
  2151. },
  2152. returns = {
  2153. {
  2154. name = "started",
  2155. type = "boolean",
  2156. description = "Whether the device was successfully started."
  2157. }
  2158. }
  2159. }
  2160. }
  2161. },
  2162. {
  2163. name = "stop",
  2164. tag = "devices",
  2165. summary = "Stop an audio device.",
  2166. description = "Stops the active playback or capture device. This may fail if:\n\n- The device is not started\n- No device was initialized with `lovr.audio.setDevice`",
  2167. key = "lovr.audio.stop",
  2168. module = "lovr.audio",
  2169. notes = "Switching devices with `lovr.audio.setDevice` will stop the existing one.",
  2170. related = {
  2171. "lovr.audio.getDevices",
  2172. "lovr.audio.setDevice",
  2173. "lovr.audio.start",
  2174. "lovr.audio.isStarted"
  2175. },
  2176. variants = {
  2177. {
  2178. arguments = {
  2179. {
  2180. name = "type",
  2181. type = "AudioType",
  2182. description = "The type of device to stop.",
  2183. default = "'playback'"
  2184. }
  2185. },
  2186. returns = {
  2187. {
  2188. name = "stopped",
  2189. type = "boolean",
  2190. description = "Whether the device was successfully stopped."
  2191. }
  2192. }
  2193. }
  2194. }
  2195. }
  2196. },
  2197. objects = {
  2198. {
  2199. name = "Source",
  2200. summary = "A playable sound object.",
  2201. description = "A Source is an object representing a single sound. Currently ogg, wav, and mp3 formats are supported.\n\nWhen a Source is playing, it will send audio to the speakers. Sources do not play automatically when they are created. Instead, the `play`, `pause`, and `stop` functions can be used to control when they should play.\n\n`Source:seek` and `Source:tell` can be used to control the playback position of the Source. A Source can be set to loop when it reaches the end using `Source:setLooping`.",
  2202. key = "Source",
  2203. module = "lovr.audio",
  2204. constructors = {
  2205. "lovr.audio.newSource",
  2206. "Source:clone"
  2207. },
  2208. methods = {
  2209. {
  2210. name = "clone",
  2211. tag = "sourceUtility",
  2212. summary = "Create an identical copy of the Source.",
  2213. description = "Creates a copy of the Source, referencing the same `Sound` object and inheriting all of the settings of this Source. However, it will be created in the stopped state and will be rewound to the beginning.",
  2214. key = "Source:clone",
  2215. module = "lovr.audio",
  2216. notes = "This is a good way to create multiple Sources that play the same sound, since the audio data won't be loaded multiple times and can just be reused. You can also create multiple `Source` objects and pass in the same `Sound` object for each one, which will have the same effect.",
  2217. related = {
  2218. "lovr.audio.newSource"
  2219. },
  2220. variants = {
  2221. {
  2222. arguments = {},
  2223. returns = {
  2224. {
  2225. name = "source",
  2226. type = "Source",
  2227. description = "A genetically identical copy of the Source."
  2228. }
  2229. }
  2230. }
  2231. }
  2232. },
  2233. {
  2234. name = "getDirectivity",
  2235. tag = "sourceEffects",
  2236. summary = "Get the directivity of the Source.",
  2237. description = "Returns the directivity settings for the Source.\n\nThe directivity is controlled by two parameters: the weight and the power.\n\nThe weight is a number between 0 and 1 controlling the general \"shape\" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions. 1.0 results in a full dipole shape that can be heard only from the front and back. 0.5 results in a cardioid shape that can only be heard from one direction. Numbers in between will smoothly transition between these.\n\nThe power is a number that controls how \"focused\" or sharp the shape is. Lower power values can be heard from a wider set of angles. It is an exponent, so it can get arbitrarily large. Note that a power of zero will still result in an omnidirectional source, regardless of the weight.",
  2238. key = "Source:getDirectivity",
  2239. module = "lovr.audio",
  2240. variants = {
  2241. {
  2242. arguments = {},
  2243. returns = {
  2244. {
  2245. name = "weight",
  2246. type = "number",
  2247. description = "The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid."
  2248. },
  2249. {
  2250. name = "power",
  2251. type = "number",
  2252. description = "The dipole power, controlling how focused the directivity shape is."
  2253. }
  2254. }
  2255. }
  2256. }
  2257. },
  2258. {
  2259. name = "getDuration",
  2260. tag = "sourcePlayback",
  2261. summary = "Get the duration of the Source.",
  2262. description = "Returns the duration of the Source.",
  2263. key = "Source:getDuration",
  2264. module = "lovr.audio",
  2265. related = {
  2266. "Sound:getDuration"
  2267. },
  2268. variants = {
  2269. {
  2270. arguments = {
  2271. {
  2272. name = "unit",
  2273. type = "TimeUnit",
  2274. description = "The unit to return.",
  2275. default = "'seconds'"
  2276. }
  2277. },
  2278. returns = {
  2279. {
  2280. name = "duration",
  2281. type = "number",
  2282. description = "The duration of the Source."
  2283. }
  2284. }
  2285. }
  2286. }
  2287. },
  2288. {
  2289. name = "getOrientation",
  2290. tag = "sourceEffects",
  2291. summary = "Get the orientation of the Source.",
  2292. description = "Returns the orientation of the Source, in angle/axis representation.",
  2293. key = "Source:getOrientation",
  2294. module = "lovr.audio",
  2295. related = {
  2296. "Source:getPosition",
  2297. "Source:getPose",
  2298. "lovr.audio.getOrientation"
  2299. },
  2300. variants = {
  2301. {
  2302. arguments = {},
  2303. returns = {
  2304. {
  2305. name = "angle",
  2306. type = "number",
  2307. description = "The number of radians the Source is rotated around its axis of rotation."
  2308. },
  2309. {
  2310. name = "ax",
  2311. type = "number",
  2312. description = "The x component of the axis of rotation."
  2313. },
  2314. {
  2315. name = "ay",
  2316. type = "number",
  2317. description = "The y component of the axis of rotation."
  2318. },
  2319. {
  2320. name = "az",
  2321. type = "number",
  2322. description = "The z component of the axis of rotation."
  2323. }
  2324. }
  2325. }
  2326. }
  2327. },
  2328. {
  2329. name = "getPitch",
  2330. tag = "sourcePlayback",
  2331. summary = "Get the pitch of the Source.",
  2332. description = "Returns the pitch of the Source.",
  2333. key = "Source:getPitch",
  2334. module = "lovr.audio",
  2335. notes = "The default pitch is 1. Every doubling/halving of the pitch will raise/lower the pitch by one octave. Changing the pitch also changes the playback speed.",
  2336. variants = {
  2337. {
  2338. arguments = {},
  2339. returns = {
  2340. {
  2341. name = "pitch",
  2342. type = "number",
  2343. description = "The pitch."
  2344. }
  2345. }
  2346. }
  2347. }
  2348. },
  2349. {
  2350. name = "getPose",
  2351. tag = "sourceEffects",
  2352. summary = "Get the pose of the Source.",
  2353. description = "Returns the position and orientation of the Source.",
  2354. key = "Source:getPose",
  2355. module = "lovr.audio",
  2356. related = {
  2357. "Source:getPosition",
  2358. "Source:getOrientation",
  2359. "lovr.audio.getPose"
  2360. },
  2361. variants = {
  2362. {
  2363. arguments = {},
  2364. returns = {
  2365. {
  2366. name = "x",
  2367. type = "number",
  2368. description = "The x position of the Source, in meters."
  2369. },
  2370. {
  2371. name = "y",
  2372. type = "number",
  2373. description = "The y position of the Source, in meters."
  2374. },
  2375. {
  2376. name = "z",
  2377. type = "number",
  2378. description = "The z position of the Source, in meters."
  2379. },
  2380. {
  2381. name = "angle",
  2382. type = "number",
  2383. description = "The number of radians the Source is rotated around its axis of rotation."
  2384. },
  2385. {
  2386. name = "ax",
  2387. type = "number",
  2388. description = "The x component of the axis of rotation."
  2389. },
  2390. {
  2391. name = "ay",
  2392. type = "number",
  2393. description = "The y component of the axis of rotation."
  2394. },
  2395. {
  2396. name = "az",
  2397. type = "number",
  2398. description = "The z component of the axis of rotation."
  2399. }
  2400. }
  2401. }
  2402. }
  2403. },
  2404. {
  2405. name = "getPosition",
  2406. tag = "sourceEffects",
  2407. summary = "Get the position of the Source.",
  2408. description = "Returns the position of the Source, in meters. Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener.",
  2409. key = "Source:getPosition",
  2410. module = "lovr.audio",
  2411. related = {
  2412. "Source:getOrientation",
  2413. "Source:getPose",
  2414. "lovr.audio.getPosition"
  2415. },
  2416. variants = {
  2417. {
  2418. arguments = {},
  2419. returns = {
  2420. {
  2421. name = "x",
  2422. type = "number",
  2423. description = "The x coordinate."
  2424. },
  2425. {
  2426. name = "y",
  2427. type = "number",
  2428. description = "The y coordinate."
  2429. },
  2430. {
  2431. name = "z",
  2432. type = "number",
  2433. description = "The z coordinate."
  2434. }
  2435. }
  2436. }
  2437. }
  2438. },
  2439. {
  2440. name = "getRadius",
  2441. tag = "sourceEffects",
  2442. summary = "Get the radius of the Source.",
  2443. description = "Returns the radius of the Source, in meters.\n\nThis does not control falloff or attenuation. It is only used for smoothing out occlusion. If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop. Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism.",
  2444. key = "Source:getRadius",
  2445. module = "lovr.audio",
  2446. variants = {
  2447. {
  2448. arguments = {},
  2449. returns = {
  2450. {
  2451. name = "radius",
  2452. type = "number",
  2453. description = "The radius of the Source, in meters."
  2454. }
  2455. }
  2456. }
  2457. }
  2458. },
  2459. {
  2460. name = "getSound",
  2461. tag = "sourceUtility",
  2462. summary = "Get the Sound object backing the Source.",
  2463. description = "Returns the `Sound` object backing the Source. Multiple Sources can share one Sound, allowing its data to only be loaded once. An easy way to do this sharing is by using `Source:clone`.",
  2464. key = "Source:getSound",
  2465. module = "lovr.audio",
  2466. related = {
  2467. "Source:clone",
  2468. "lovr.audio.newSource"
  2469. },
  2470. variants = {
  2471. {
  2472. arguments = {},
  2473. returns = {
  2474. {
  2475. name = "sound",
  2476. type = "Sound",
  2477. description = "The Sound object."
  2478. }
  2479. }
  2480. }
  2481. }
  2482. },
  2483. {
  2484. name = "getVolume",
  2485. tag = "sourcePlayback",
  2486. summary = "Get the volume of the Source.",
  2487. description = "Returns the current volume factor for the Source.",
  2488. key = "Source:getVolume",
  2489. module = "lovr.audio",
  2490. variants = {
  2491. {
  2492. arguments = {
  2493. {
  2494. name = "units",
  2495. type = "VolumeUnit",
  2496. description = "The units to return (linear or db).",
  2497. default = "'linear'"
  2498. }
  2499. },
  2500. returns = {
  2501. {
  2502. name = "volume",
  2503. type = "number",
  2504. description = "The volume of the Source."
  2505. }
  2506. }
  2507. }
  2508. }
  2509. },
  2510. {
  2511. name = "isEffectEnabled",
  2512. tag = "sourceEffects",
  2513. summary = "Check if an effect is enabled.",
  2514. description = "Returns whether a given `Effect` is enabled for the Source.",
  2515. key = "Source:isEffectEnabled",
  2516. module = "lovr.audio",
  2517. notes = "The active spatializer will determine which effects are supported. If an unsupported effect is enabled on a Source, no error will be reported. Instead, it will be silently ignored. See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer.\n\nCalling this function on a non-spatial Source will always return false.",
  2518. related = {
  2519. "Source:isSpatial"
  2520. },
  2521. variants = {
  2522. {
  2523. arguments = {
  2524. {
  2525. name = "effect",
  2526. type = "Effect",
  2527. description = "The effect."
  2528. }
  2529. },
  2530. returns = {
  2531. {
  2532. name = "enabled",
  2533. type = "boolean",
  2534. description = "Whether the effect is enabled."
  2535. }
  2536. }
  2537. }
  2538. }
  2539. },
  2540. {
  2541. name = "isLooping",
  2542. tag = "sourcePlayback",
  2543. summary = "Check if the Source is looping.",
  2544. description = "Returns whether or not the Source will loop when it finishes.",
  2545. key = "Source:isLooping",
  2546. module = "lovr.audio",
  2547. variants = {
  2548. {
  2549. arguments = {},
  2550. returns = {
  2551. {
  2552. name = "looping",
  2553. type = "boolean",
  2554. description = "Whether or not the Source is looping."
  2555. }
  2556. }
  2557. }
  2558. }
  2559. },
  2560. {
  2561. name = "isPlaying",
  2562. tag = "sourcePlayback",
  2563. summary = "Check if the Source is playing.",
  2564. description = "Returns whether or not the Source is playing.",
  2565. key = "Source:isPlaying",
  2566. module = "lovr.audio",
  2567. related = {
  2568. "Source:play",
  2569. "Source:pause",
  2570. "Source:stop"
  2571. },
  2572. variants = {
  2573. {
  2574. arguments = {},
  2575. returns = {
  2576. {
  2577. name = "playing",
  2578. type = "boolean",
  2579. description = "Whether the Source is playing."
  2580. }
  2581. }
  2582. }
  2583. }
  2584. },
  2585. {
  2586. name = "isSpatial",
  2587. tag = "sourceEffects",
  2588. summary = "Check if the Source is spatial.",
  2589. description = "Returns whether the Source was created with the `spatial` flag. Non-spatial sources are routed directly to the speakers and can not use effects.",
  2590. key = "Source:isSpatial",
  2591. module = "lovr.audio",
  2592. related = {
  2593. "Source:isEffectEnabled",
  2594. "Source:setEffectEnabled"
  2595. },
  2596. variants = {
  2597. {
  2598. arguments = {},
  2599. returns = {
  2600. {
  2601. name = "spatial",
  2602. type = "boolean",
  2603. description = "Whether the source is spatial."
  2604. }
  2605. }
  2606. }
  2607. }
  2608. },
  2609. {
  2610. name = "pause",
  2611. tag = "sourcePlayback",
  2612. summary = "Pause the Source.",
  2613. description = "Pauses the source. It can be resumed with `Source:resume` or `Source:play`. If a paused source is rewound, it will remain paused.",
  2614. key = "Source:pause",
  2615. module = "lovr.audio",
  2616. variants = {
  2617. {
  2618. arguments = {},
  2619. returns = {}
  2620. }
  2621. }
  2622. },
  2623. {
  2624. name = "play",
  2625. tag = "sourcePlayback",
  2626. summary = "Play the Source.",
  2627. description = "Plays the Source. This doesn't do anything if the Source is already playing.",
  2628. key = "Source:play",
  2629. module = "lovr.audio",
  2630. notes = "There is a maximum of 64 Sources that can be playing at once. If 64 Sources are already playing, this function will return `false`.",
  2631. variants = {
  2632. {
  2633. arguments = {},
  2634. returns = {
  2635. {
  2636. name = "success",
  2637. type = "boolean",
  2638. description = "Whether the Source successfully started playing."
  2639. }
  2640. }
  2641. }
  2642. }
  2643. },
  2644. {
  2645. name = "seek",
  2646. tag = "sourcePlayback",
  2647. summary = "Set the playback position of the Source.",
  2648. description = "Seeks the Source to the specified position.",
  2649. key = "Source:seek",
  2650. module = "lovr.audio",
  2651. notes = "Seeking a Source backed by a stream `Sound` has no meaningful effect.",
  2652. variants = {
  2653. {
  2654. arguments = {
  2655. {
  2656. name = "position",
  2657. type = "number",
  2658. description = "The position to seek to."
  2659. },
  2660. {
  2661. name = "unit",
  2662. type = "TimeUnit",
  2663. description = "The units for the seek position.",
  2664. default = "'seconds'"
  2665. }
  2666. },
  2667. returns = {}
  2668. }
  2669. }
  2670. },
  2671. {
  2672. name = "setDirectivity",
  2673. tag = "sourceEffects",
  2674. summary = "Set the directivity of the Source.",
  2675. description = "Sets the directivity settings for the Source.\n\nThe directivity is controlled by two parameters: the weight and the power.\n\nThe weight is a number between 0 and 1 controlling the general \"shape\" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions. 1.0 results in a full dipole shape that can be heard only from the front and back. 0.5 results in a cardioid shape that can only be heard from one direction. Numbers in between will smoothly transition between these.\n\nThe power is a number that controls how \"focused\" or sharp the shape is. Lower power values can be heard from a wider set of angles. It is an exponent, so it can get arbitrarily large. Note that a power of zero will still result in an omnidirectional source, regardless of the weight.",
  2676. key = "Source:setDirectivity",
  2677. module = "lovr.audio",
  2678. variants = {
  2679. {
  2680. arguments = {
  2681. {
  2682. name = "weight",
  2683. type = "number",
  2684. description = "The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid."
  2685. },
  2686. {
  2687. name = "power",
  2688. type = "number",
  2689. description = "The dipole power, controlling how focused the directivity shape is."
  2690. }
  2691. },
  2692. returns = {}
  2693. }
  2694. }
  2695. },
  2696. {
  2697. name = "setEffectEnabled",
  2698. tag = "sourceEffects",
  2699. summary = "Enable or disable an effect.",
  2700. description = "Enables or disables an effect on the Source.",
  2701. key = "Source:setEffectEnabled",
  2702. module = "lovr.audio",
  2703. notes = "The active spatializer will determine which effects are supported. If an unsupported effect is enabled on a Source, no error will be reported. Instead, it will be silently ignored. See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer.\n\nCalling this function on a non-spatial Source will throw an error.",
  2704. related = {
  2705. "Source:isSpatial"
  2706. },
  2707. variants = {
  2708. {
  2709. arguments = {
  2710. {
  2711. name = "effect",
  2712. type = "Effect",
  2713. description = "The effect."
  2714. },
  2715. {
  2716. name = "enable",
  2717. type = "boolean",
  2718. description = "Whether the effect should be enabled."
  2719. }
  2720. },
  2721. returns = {}
  2722. }
  2723. }
  2724. },
  2725. {
  2726. name = "setLooping",
  2727. tag = "sourcePlayback",
  2728. summary = "Set whether or not the Source loops.",
  2729. description = "Sets whether or not the Source loops.",
  2730. key = "Source:setLooping",
  2731. module = "lovr.audio",
  2732. notes = "Attempting to loop a Source backed by a stream `Sound` will cause an error.",
  2733. variants = {
  2734. {
  2735. arguments = {
  2736. {
  2737. name = "loop",
  2738. type = "boolean",
  2739. description = "Whether or not the Source will loop."
  2740. }
  2741. },
  2742. returns = {}
  2743. }
  2744. }
  2745. },
  2746. {
  2747. name = "setOrientation",
  2748. tag = "sourceEffects",
  2749. summary = "Set the orientation of the Source.",
  2750. description = "Sets the orientation of the Source in angle/axis representation.",
  2751. key = "Source:setOrientation",
  2752. module = "lovr.audio",
  2753. related = {
  2754. "Source:setPosition",
  2755. "Source:setPose",
  2756. "lovr.audio.setOrientation"
  2757. },
  2758. variants = {
  2759. {
  2760. description = "Set the orientation using angle/axis numbers.",
  2761. arguments = {
  2762. {
  2763. name = "angle",
  2764. type = "number",
  2765. description = "The number of radians the Source should be rotated around its rotation axis."
  2766. },
  2767. {
  2768. name = "ax",
  2769. type = "number",
  2770. description = "The x component of the axis of rotation."
  2771. },
  2772. {
  2773. name = "ay",
  2774. type = "number",
  2775. description = "The y component of the axis of rotation."
  2776. },
  2777. {
  2778. name = "az",
  2779. type = "number",
  2780. description = "The z component of the axis of rotation."
  2781. }
  2782. },
  2783. returns = {}
  2784. },
  2785. {
  2786. description = "Set the orientation using a quaternion.",
  2787. arguments = {
  2788. {
  2789. name = "orientation",
  2790. type = "Quat",
  2791. description = "The orientation."
  2792. }
  2793. },
  2794. returns = {}
  2795. }
  2796. }
  2797. },
  2798. {
  2799. name = "setPitch",
  2800. tag = "sourcePlayback",
  2801. summary = "Set the pitch of the Source.",
  2802. description = "Sets the pitch of the Source.",
  2803. key = "Source:setPitch",
  2804. module = "lovr.audio",
  2805. notes = "The default pitch is 1. Every doubling/halving of the pitch will raise/lower the pitch by one octave. Changing the pitch also changes the playback speed.",
  2806. variants = {
  2807. {
  2808. arguments = {
  2809. {
  2810. name = "pitch",
  2811. type = "number",
  2812. description = "The new pitch."
  2813. }
  2814. },
  2815. returns = {}
  2816. }
  2817. }
  2818. },
  2819. {
  2820. name = "setPose",
  2821. tag = "sourceEffects",
  2822. summary = "Set the pose of the Source.",
  2823. description = "Sets the position and orientation of the Source.",
  2824. key = "Source:setPose",
  2825. module = "lovr.audio",
  2826. notes = "The position doesn't have any defined units, but meters are used by convention.",
  2827. related = {
  2828. "Source:setPosition",
  2829. "Source:setOrientation",
  2830. "lovr.audio.setPose"
  2831. },
  2832. variants = {
  2833. {
  2834. description = "Set the pose using numbers.",
  2835. arguments = {
  2836. {
  2837. name = "x",
  2838. type = "number",
  2839. description = "The x position of the Source."
  2840. },
  2841. {
  2842. name = "y",
  2843. type = "number",
  2844. description = "The y position of the Source."
  2845. },
  2846. {
  2847. name = "z",
  2848. type = "number",
  2849. description = "The z position of the Source."
  2850. },
  2851. {
  2852. name = "angle",
  2853. type = "number",
  2854. description = "The number of radians the Source is rotated around its axis of rotation."
  2855. },
  2856. {
  2857. name = "ax",
  2858. type = "number",
  2859. description = "The x component of the axis of rotation."
  2860. },
  2861. {
  2862. name = "ay",
  2863. type = "number",
  2864. description = "The y component of the axis of rotation."
  2865. },
  2866. {
  2867. name = "az",
  2868. type = "number",
  2869. description = "The z component of the axis of rotation."
  2870. }
  2871. },
  2872. returns = {}
  2873. },
  2874. {
  2875. description = "Set the pose using vector types.",
  2876. arguments = {
  2877. {
  2878. name = "position",
  2879. type = "Vec3",
  2880. description = "The position."
  2881. },
  2882. {
  2883. name = "orientation",
  2884. type = "Quat",
  2885. description = "The orientation."
  2886. }
  2887. },
  2888. returns = {}
  2889. }
  2890. }
  2891. },
  2892. {
  2893. name = "setPosition",
  2894. tag = "sourceEffects",
  2895. summary = "Set the position of the Source.",
  2896. description = "Sets the position of the Source. Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener.\n\nOnly mono sources can be positioned. Setting the position of a stereo Source will cause an error.",
  2897. key = "Source:setPosition",
  2898. module = "lovr.audio",
  2899. notes = "The position doesn't have any defined units, but meters are used by convention.",
  2900. related = {
  2901. "Source:setOrientation",
  2902. "Source:setPose"
  2903. },
  2904. variants = {
  2905. {
  2906. description = "Set the position using numbers.",
  2907. arguments = {
  2908. {
  2909. name = "x",
  2910. type = "number",
  2911. description = "The x coordinate of the position."
  2912. },
  2913. {
  2914. name = "y",
  2915. type = "number",
  2916. description = "The y coordinate of the position."
  2917. },
  2918. {
  2919. name = "z",
  2920. type = "number",
  2921. description = "The z coordinate of the position."
  2922. }
  2923. },
  2924. returns = {}
  2925. },
  2926. {
  2927. description = "Set the position using a vector.",
  2928. arguments = {
  2929. {
  2930. name = "position",
  2931. type = "Vec3",
  2932. description = "The position."
  2933. }
  2934. },
  2935. returns = {}
  2936. }
  2937. }
  2938. },
  2939. {
  2940. name = "setRadius",
  2941. tag = "sourceEffects",
  2942. summary = "Set the radius of the Source.",
  2943. description = "Sets the radius of the Source, in meters.\n\nThis does not control falloff or attenuation. It is only used for smoothing out occlusion. If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop. Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism.",
  2944. key = "Source:setRadius",
  2945. module = "lovr.audio",
  2946. variants = {
  2947. {
  2948. arguments = {
  2949. {
  2950. name = "radius",
  2951. type = "number",
  2952. description = "The new radius of the Source, in meters."
  2953. }
  2954. },
  2955. returns = {}
  2956. }
  2957. }
  2958. },
  2959. {
  2960. name = "setVolume",
  2961. tag = "sourcePlayback",
  2962. summary = "Set the volume of the Source.",
  2963. description = "Sets the current volume factor for the Source.",
  2964. key = "Source:setVolume",
  2965. module = "lovr.audio",
  2966. notes = "The volume will be clamped to a 0-1 range (0 dB).",
  2967. variants = {
  2968. {
  2969. arguments = {
  2970. {
  2971. name = "volume",
  2972. type = "number",
  2973. description = "The new volume."
  2974. },
  2975. {
  2976. name = "units",
  2977. type = "VolumeUnit",
  2978. description = "The units of the value.",
  2979. default = "'linear'"
  2980. }
  2981. },
  2982. returns = {}
  2983. }
  2984. }
  2985. },
  2986. {
  2987. name = "stop",
  2988. tag = "sourcePlayback",
  2989. summary = "Stop the Source.",
  2990. description = "Stops the source, also rewinding it to the beginning.",
  2991. key = "Source:stop",
  2992. module = "lovr.audio",
  2993. related = {
  2994. "Source:play",
  2995. "Source:pause",
  2996. "Source:isPlaying"
  2997. },
  2998. variants = {
  2999. {
  3000. arguments = {},
  3001. returns = {}
  3002. }
  3003. }
  3004. },
  3005. {
  3006. name = "tell",
  3007. tag = "sourcePlayback",
  3008. summary = "Get the playback position of the Source.",
  3009. description = "Returns the current playback position of the Source.",
  3010. key = "Source:tell",
  3011. module = "lovr.audio",
  3012. notes = "The return value for Sources backed by a stream `Sound` has no meaning.",
  3013. variants = {
  3014. {
  3015. arguments = {
  3016. {
  3017. name = "unit",
  3018. type = "TimeUnit",
  3019. description = "The unit to return.",
  3020. default = "'seconds'"
  3021. }
  3022. },
  3023. returns = {
  3024. {
  3025. name = "position",
  3026. type = "number",
  3027. description = "The current playback position."
  3028. }
  3029. }
  3030. }
  3031. }
  3032. }
  3033. },
  3034. sections = {
  3035. {
  3036. name = "Playback",
  3037. tag = "sourcePlayback"
  3038. },
  3039. {
  3040. name = "Spatial Effects",
  3041. tag = "sourceEffects"
  3042. },
  3043. {
  3044. name = "Utility",
  3045. tag = "sourceUtility"
  3046. }
  3047. }
  3048. }
  3049. },
  3050. sections = {
  3051. {
  3052. name = "Sources",
  3053. tag = "sources",
  3054. description = "Sources are objects that represent a single sound instance."
  3055. },
  3056. {
  3057. name = "Listener",
  3058. tag = "listener",
  3059. description = "The listener is a virtual object in 3D space that \"hears\" all the sounds that are playing. It can be positioned and oriented in 3D space, which controls how Sources in the world are heard. Usually this would be locked to the headset pose."
  3060. },
  3061. {
  3062. name = "Devices",
  3063. tag = "devices",
  3064. description = "It's possible to list the available audio devices on the system, and pick a specific device to use for either playback or capture. Devices can also be manually started and stopped. Other useful features of `lovr.audio.setDevice` include the ability to stream all audio data to a custom sink and the option to create a device in exclusive mode for higher performance. By default, the default playback device is automatically initialized and started, but this can be configured using `lovr.conf`."
  3065. }
  3066. }
  3067. },
  3068. {
  3069. name = "data",
  3070. tag = "modules",
  3071. summary = "Exposes low level functions for working with data.",
  3072. description = "The `lovr.data` module provides functions for accessing underlying data representations for several LÖVR objects.",
  3073. key = "lovr.data",
  3074. enums = {
  3075. {
  3076. name = "AnimationProperty",
  3077. summary = "Different animated properties.",
  3078. description = "This indicates the different node properties that can be animated.",
  3079. key = "AnimationProperty",
  3080. module = "lovr.data",
  3081. values = {
  3082. {
  3083. name = "translation",
  3084. description = "Node translation."
  3085. },
  3086. {
  3087. name = "rotation",
  3088. description = "Node rotation."
  3089. },
  3090. {
  3091. name = "scale",
  3092. description = "Node scale."
  3093. },
  3094. {
  3095. name = "weights",
  3096. description = "Node blend shape weights."
  3097. }
  3098. }
  3099. },
  3100. {
  3101. name = "AttributeType",
  3102. summary = "Data types for vertex attributes in meshes.",
  3103. description = "These are the data types that can be used by vertex data in meshes.",
  3104. key = "AttributeType",
  3105. module = "lovr.data",
  3106. values = {
  3107. {
  3108. name = "i8",
  3109. description = "Signed 8 bit integers (-128 to 127)."
  3110. },
  3111. {
  3112. name = "u8",
  3113. description = "Unsigned 8 bit integers (0 to 255)."
  3114. },
  3115. {
  3116. name = "i16",
  3117. description = "Signed 16 bit integers (-32768 to 32767)."
  3118. },
  3119. {
  3120. name = "u16",
  3121. description = "Unsigned 16 bit integers (0 to 65535)."
  3122. },
  3123. {
  3124. name = "i32",
  3125. description = "Signed 32 bit integers (-2147483648 to 2147483647)."
  3126. },
  3127. {
  3128. name = "u32",
  3129. description = "Unsigned 32 bit integers (0 to 429467295)."
  3130. },
  3131. {
  3132. name = "f32",
  3133. description = "Floating point numbers."
  3134. }
  3135. }
  3136. },
  3137. {
  3138. name = "ChannelLayout",
  3139. summary = "Different channel layouts for Sounds.",
  3140. description = "Sounds can have different numbers of channels, and those channels can map to various speaker layouts.",
  3141. key = "ChannelLayout",
  3142. module = "lovr.data",
  3143. related = {
  3144. "lovr.data.newSound",
  3145. "Sound:getFormat"
  3146. },
  3147. values = {
  3148. {
  3149. name = "mono",
  3150. description = "1 channel."
  3151. },
  3152. {
  3153. name = "stereo",
  3154. description = "2 channels. The first channel is for the left speaker and the second is for the right."
  3155. },
  3156. {
  3157. name = "ambisonic",
  3158. description = "4 channels. Ambisonic channels don't map directly to speakers but instead represent directions in 3D space, sort of like the images of a skybox. Currently, ambisonic sounds can only be loaded, not played."
  3159. }
  3160. }
  3161. },
  3162. {
  3163. name = "DefaultAttribute",
  3164. summary = "Attributes that can be loaded from a model.",
  3165. description = "These are the different types of attributes that may be present in meshes loaded from models.",
  3166. key = "DefaultAttribute",
  3167. module = "lovr.data",
  3168. values = {
  3169. {
  3170. name = "position",
  3171. description = "Vertex positions."
  3172. },
  3173. {
  3174. name = "normal",
  3175. description = "Vertex normal vectors."
  3176. },
  3177. {
  3178. name = "uv",
  3179. description = "Vertex texture coordinates."
  3180. },
  3181. {
  3182. name = "color",
  3183. description = "Vertex colors."
  3184. },
  3185. {
  3186. name = "tangent",
  3187. description = "Vertex tangent vectors."
  3188. },
  3189. {
  3190. name = "joints",
  3191. description = "Vertex joint indices."
  3192. },
  3193. {
  3194. name = "weights",
  3195. description = "Vertex joint weights."
  3196. }
  3197. }
  3198. },
  3199. {
  3200. name = "ModelDrawMode",
  3201. summary = "Different draw modes for meshes in ModelDatas.",
  3202. description = "The DrawMode of a mesh determines how its vertices are connected together.",
  3203. key = "ModelDrawMode",
  3204. module = "lovr.data",
  3205. related = {
  3206. "ModelData:getMeshDrawMode"
  3207. },
  3208. values = {
  3209. {
  3210. name = "points",
  3211. description = "Each vertex is draw as a single point."
  3212. },
  3213. {
  3214. name = "lines",
  3215. description = "Every pair of vertices is drawn as a line."
  3216. },
  3217. {
  3218. name = "linestrip",
  3219. description = "Draws a single line through all of the vertices."
  3220. },
  3221. {
  3222. name = "lineloop",
  3223. description = "Draws a single line through all of the vertices, then connects back to the first vertex."
  3224. },
  3225. {
  3226. name = "strip",
  3227. description = "Vertices are rendered as triangles. After the first 3 vertices, each subsequent vertex connects to the previous two."
  3228. },
  3229. {
  3230. name = "triangles",
  3231. description = "Every 3 vertices forms a triangle."
  3232. },
  3233. {
  3234. name = "fan",
  3235. description = "Vertices are rendered as triangles. After the first 3 vertices, each subsequent vertex is connected to the previous vertex and the first vertex."
  3236. }
  3237. }
  3238. },
  3239. {
  3240. name = "SampleFormat",
  3241. summary = "Different data types for samples in a Sound.",
  3242. description = "Sounds can store audio samples as 16 bit integers or 32 bit floats.",
  3243. key = "SampleFormat",
  3244. module = "lovr.data",
  3245. related = {
  3246. "lovr.data.newSound",
  3247. "Sound:getFormat"
  3248. },
  3249. values = {
  3250. {
  3251. name = "f32",
  3252. description = "32 bit floating point samples (between -1.0 and 1.0)."
  3253. },
  3254. {
  3255. name = "i16",
  3256. description = "16 bit integer samples (between -32768 and 32767)."
  3257. }
  3258. }
  3259. },
  3260. {
  3261. name = "SmoothMode",
  3262. summary = "Different ways to interpolate between animation keyframes.",
  3263. description = "Different ways to interpolate between animation keyframes.",
  3264. key = "SmoothMode",
  3265. module = "lovr.data",
  3266. values = {
  3267. {
  3268. name = "step",
  3269. description = "The animated property will snap to the nearest keyframe."
  3270. },
  3271. {
  3272. name = "linear",
  3273. description = "The animated property will linearly interpolate between keyframes."
  3274. },
  3275. {
  3276. name = "cubic",
  3277. description = "The animated property will follow a smooth curve between nearby keyframes."
  3278. }
  3279. }
  3280. },
  3281. {
  3282. name = "TextureFormat",
  3283. description = "Different data layouts for pixels in `Image` and `Texture` objects.\n\nFormats starting with `d` are depth formats, used for depth/stencil render targets.\n\nFormats starting with `bc` and `astc` are compressed formats. Compressed formats have better performance since they stay compressed on the CPU and GPU, reducing the amount of memory bandwidth required to look up all the pixels needed for shading.\n\nFormats without the `f` suffix are unsigned normalized formats, which store values in the range `[0,1]`. The `f` suffix indicates a floating point format which can store values outside this range, and is used for HDR rendering or storing data in a texture.",
  3284. key = "TextureFormat",
  3285. module = "lovr.data",
  3286. values = {
  3287. {
  3288. name = "r8",
  3289. description = "One 8-bit channel. 1 byte per pixel."
  3290. },
  3291. {
  3292. name = "rg8",
  3293. description = "Two 8-bit channels. 2 bytes per pixel."
  3294. },
  3295. {
  3296. name = "rgba8",
  3297. description = "Four 8-bit channels. 4 bytes per pixel."
  3298. },
  3299. {
  3300. name = "r16",
  3301. description = "One 16-bit channel. 2 bytes per pixel."
  3302. },
  3303. {
  3304. name = "rg16",
  3305. description = "Two 16-bit channels. 4 bytes per pixel."
  3306. },
  3307. {
  3308. name = "rgba16",
  3309. description = "Four 16-bit channels. 8 bytes per pixel."
  3310. },
  3311. {
  3312. name = "r16f",
  3313. description = "One 16-bit floating point channel. 2 bytes per pixel."
  3314. },
  3315. {
  3316. name = "rg16f",
  3317. description = "Two 16-bit floating point channels. 4 bytes per pixel."
  3318. },
  3319. {
  3320. name = "rgba16f",
  3321. description = "Four 16-bit floating point channels. 8 bytes per pixel."
  3322. },
  3323. {
  3324. name = "r32f",
  3325. description = "One 32-bit floating point channel. 4 bytes per pixel."
  3326. },
  3327. {
  3328. name = "rg32f",
  3329. description = "Two 32-bit floating point channels. 8 bytes per pixel."
  3330. },
  3331. {
  3332. name = "rgba32f",
  3333. description = "Four 32-bit floating point channels. 16 bytes per pixel."
  3334. },
  3335. {
  3336. name = "rgb565",
  3337. description = "Packs three channels into 16 bits. 2 bytes per pixel."
  3338. },
  3339. {
  3340. name = "rgb5a1",
  3341. description = "Packs four channels into 16 bits, with \"cutout\" alpha. 2 bytes per pixel."
  3342. },
  3343. {
  3344. name = "rgb10a2",
  3345. description = "Packs four channels into 32 bits. 4 bytes per pixel."
  3346. },
  3347. {
  3348. name = "rg11b10f",
  3349. description = "Packs three unsigned floating point channels into 32 bits. 4 bytes per pixel."
  3350. },
  3351. {
  3352. name = "d16",
  3353. description = "One 16-bit depth channel. 2 bytes per pixel."
  3354. },
  3355. {
  3356. name = "d24s8",
  3357. description = "One 24-bit depth channel and one 8-bit stencil channel. 4 bytes per pixel."
  3358. },
  3359. {
  3360. name = "d32f",
  3361. description = "One 32-bit floating point depth channel. 4 bytes per pixel."
  3362. },
  3363. {
  3364. name = "d32fs8",
  3365. description = "One 32-bit floating point depth channel and one 8-bit stencil channel. 5 bytes per pixel."
  3366. },
  3367. {
  3368. name = "bc1",
  3369. description = "3 channels. 8 bytes per 4x4 block, or 0.5 bytes per pixel. Good for opaque images."
  3370. },
  3371. {
  3372. name = "bc2",
  3373. description = "Four channels. 16 bytes per 4x4 block or 1 byte per pixel. Not good for anything, because it only has 16 distinct levels of alpha."
  3374. },
  3375. {
  3376. name = "bc3",
  3377. description = "Four channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for color images with transparency."
  3378. },
  3379. {
  3380. name = "bc4u",
  3381. description = "One unsigned normalized channel. 8 bytes per 4x4 block or 0.5 bytes per pixel. Good for grayscale images, like heightmaps."
  3382. },
  3383. {
  3384. name = "bc4s",
  3385. description = "One signed normalized channel. 8 bytes per 4x4 block or 0.5 bytes per pixel. Similar to bc4u but has a range of -1 to 1."
  3386. },
  3387. {
  3388. name = "bc5u",
  3389. description = "Two unsigned normalized channels. 16 bytes per 4x4 block, or 1 byte per pixel. Good for normal maps."
  3390. },
  3391. {
  3392. name = "bc5s",
  3393. description = "Two signed normalized channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for normal maps."
  3394. },
  3395. {
  3396. name = "bc6uf",
  3397. description = "Three unsigned floating point channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for HDR images."
  3398. },
  3399. {
  3400. name = "bc6sf",
  3401. description = "Three floating point channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for HDR images."
  3402. },
  3403. {
  3404. name = "bc7",
  3405. description = "Four channels. 16 bytes per 4x4 block or 1 byte per pixel. High quality. Good for most color images, including transparency."
  3406. },
  3407. {
  3408. name = "astc4x4",
  3409. description = "Four channels, 16 bytes per 4x4 block or 1 byte per pixel."
  3410. },
  3411. {
  3412. name = "astc5x4",
  3413. description = "Four channels, 16 bytes per 5x4 block or 0.80 bytes per pixel."
  3414. },
  3415. {
  3416. name = "astc5x5",
  3417. description = "Four channels, 16 bytes per 5x5 block or 0.64 bytes per pixel."
  3418. },
  3419. {
  3420. name = "astc6x5",
  3421. description = "Four channels, 16 bytes per 6x5 block or 0.53 bytes per pixel."
  3422. },
  3423. {
  3424. name = "astc6x6",
  3425. description = "Four channels, 16 bytes per 6x6 block or 0.44 bytes per pixel."
  3426. },
  3427. {
  3428. name = "astc8x5",
  3429. description = "Four channels, 16 bytes per 8x5 block or 0.40 bytes per pixel."
  3430. },
  3431. {
  3432. name = "astc8x6",
  3433. description = "Four channels, 16 bytes per 8x6 block or 0.33 bytes per pixel."
  3434. },
  3435. {
  3436. name = "astc8x8",
  3437. description = "Four channels, 16 bytes per 8x8 block or 0.25 bytes per pixel."
  3438. },
  3439. {
  3440. name = "astc10x5",
  3441. description = "Four channels, 16 bytes per 10x5 block or 0.32 bytes per pixel."
  3442. },
  3443. {
  3444. name = "astc10x6",
  3445. description = "Four channels, 16 bytes per 10x6 block or 0.27 bytes per pixel."
  3446. },
  3447. {
  3448. name = "astc10x8",
  3449. description = "Four channels, 16 bytes per 10x8 block or 0.20 bytes per pixel."
  3450. },
  3451. {
  3452. name = "astc10x10",
  3453. description = "Four channels, 16 bytes per 10x10 block or 0.16 bytes per pixel."
  3454. },
  3455. {
  3456. name = "astc12x10",
  3457. description = "Four channels, 16 bytes per 12x10 block or 0.13 bytes per pixel."
  3458. },
  3459. {
  3460. name = "astc12x12",
  3461. description = "Four channels, 16 bytes per 12x12 block or 0.11 bytes per pixel."
  3462. }
  3463. }
  3464. }
  3465. },
  3466. functions = {
  3467. {
  3468. name = "newBlob",
  3469. summary = "Create a new Blob.",
  3470. description = "Creates a new Blob.",
  3471. key = "lovr.data.newBlob",
  3472. module = "lovr.data",
  3473. related = {
  3474. "lovr.filesystem.newBlob"
  3475. },
  3476. variants = {
  3477. {
  3478. arguments = {
  3479. {
  3480. name = "size",
  3481. type = "number",
  3482. description = "The amount of data to allocate for the Blob, in bytes. All of the bytes will be filled with zeroes."
  3483. },
  3484. {
  3485. name = "name",
  3486. type = "string",
  3487. description = "A name for the Blob (used in error messages)",
  3488. default = "''"
  3489. }
  3490. },
  3491. returns = {
  3492. {
  3493. name = "blob",
  3494. type = "Blob",
  3495. description = "The new Blob."
  3496. }
  3497. }
  3498. },
  3499. {
  3500. arguments = {
  3501. {
  3502. name = "contents",
  3503. type = "string",
  3504. description = "A string to use for the Blob's contents."
  3505. },
  3506. {
  3507. name = "name",
  3508. type = "string",
  3509. description = "A name for the Blob (used in error messages)",
  3510. default = "''"
  3511. }
  3512. },
  3513. returns = {
  3514. {
  3515. name = "blob",
  3516. type = "Blob",
  3517. description = "The new Blob."
  3518. }
  3519. }
  3520. },
  3521. {
  3522. arguments = {
  3523. {
  3524. name = "source",
  3525. type = "Blob",
  3526. description = "A Blob to copy the contents from."
  3527. },
  3528. {
  3529. name = "name",
  3530. type = "string",
  3531. description = "A name for the Blob (used in error messages)",
  3532. default = "''"
  3533. }
  3534. },
  3535. returns = {
  3536. {
  3537. name = "blob",
  3538. type = "Blob",
  3539. description = "The new Blob."
  3540. }
  3541. }
  3542. }
  3543. }
  3544. },
  3545. {
  3546. name = "newImage",
  3547. summary = "Create a new Image.",
  3548. description = "Creates a new Image. Image data can be loaded and decoded from an image file, or a raw block of pixels with a specified width, height, and format can be created.",
  3549. key = "lovr.data.newImage",
  3550. module = "lovr.data",
  3551. notes = "The supported image file formats are png, jpg, hdr, dds, ktx1, ktx2, and astc.\n\nDDS and KTX files can contain cubemaps and array textures, in any of the texture formats LÖVR supports.",
  3552. variants = {
  3553. {
  3554. description = "Load image data from a file.",
  3555. arguments = {
  3556. {
  3557. name = "filename",
  3558. type = "string",
  3559. description = "The filename of the image to load."
  3560. }
  3561. },
  3562. returns = {
  3563. {
  3564. name = "image",
  3565. type = "Image",
  3566. description = "The new Image."
  3567. }
  3568. }
  3569. },
  3570. {
  3571. description = "Create an Image with a given size and pixel format.",
  3572. arguments = {
  3573. {
  3574. name = "width",
  3575. type = "number",
  3576. description = "The width of the texture."
  3577. },
  3578. {
  3579. name = "height",
  3580. type = "number",
  3581. description = "The height of the texture."
  3582. },
  3583. {
  3584. name = "format",
  3585. type = "TextureFormat",
  3586. description = "The format of the texture's pixels.",
  3587. default = "rgba8"
  3588. },
  3589. {
  3590. name = "data",
  3591. type = "Blob",
  3592. description = "Raw pixel values to use as the contents. If `nil`, the data will all be zero.",
  3593. default = "nil"
  3594. }
  3595. },
  3596. returns = {
  3597. {
  3598. name = "image",
  3599. type = "Image",
  3600. description = "The new Image."
  3601. }
  3602. }
  3603. },
  3604. {
  3605. description = "Clone an existing Image.",
  3606. arguments = {
  3607. {
  3608. name = "source",
  3609. type = "Image",
  3610. description = "The Image to clone."
  3611. }
  3612. },
  3613. returns = {
  3614. {
  3615. name = "image",
  3616. type = "Image",
  3617. description = "The new Image."
  3618. }
  3619. }
  3620. },
  3621. {
  3622. description = "Decode image data from a Blob.",
  3623. arguments = {
  3624. {
  3625. name = "blob",
  3626. type = "Blob",
  3627. description = "The Blob containing image data to decode."
  3628. }
  3629. },
  3630. returns = {
  3631. {
  3632. name = "image",
  3633. type = "Image",
  3634. description = "The new Image."
  3635. }
  3636. }
  3637. }
  3638. }
  3639. },
  3640. {
  3641. name = "newModelData",
  3642. summary = "Create a new ModelData.",
  3643. description = "Loads a 3D model from a file. The supported 3D file formats are OBJ and glTF.",
  3644. key = "lovr.data.newModelData",
  3645. module = "lovr.data",
  3646. variants = {
  3647. {
  3648. arguments = {
  3649. {
  3650. name = "filename",
  3651. type = "string",
  3652. description = "The filename of the model to load."
  3653. }
  3654. },
  3655. returns = {
  3656. {
  3657. name = "modelData",
  3658. type = "ModelData",
  3659. description = "The new ModelData."
  3660. }
  3661. }
  3662. },
  3663. {
  3664. arguments = {
  3665. {
  3666. name = "blob",
  3667. type = "Blob",
  3668. description = "The Blob containing data for a model to decode."
  3669. }
  3670. },
  3671. returns = {
  3672. {
  3673. name = "modelData",
  3674. type = "ModelData",
  3675. description = "The new ModelData."
  3676. }
  3677. }
  3678. }
  3679. }
  3680. },
  3681. {
  3682. name = "newRasterizer",
  3683. summary = "Create a new Rasterizer.",
  3684. description = "Creates a new Rasterizer from a TTF file.",
  3685. key = "lovr.data.newRasterizer",
  3686. module = "lovr.data",
  3687. variants = {
  3688. {
  3689. description = "Create a Rasterizer for the default font included with LÖVR (Varela Round).",
  3690. arguments = {
  3691. {
  3692. name = "size",
  3693. type = "number",
  3694. description = "The resolution to render the fonts at, in pixels. Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations.",
  3695. default = "32"
  3696. }
  3697. },
  3698. returns = {
  3699. {
  3700. name = "rasterizer",
  3701. type = "Rasterizer",
  3702. description = "The new Rasterizer."
  3703. }
  3704. }
  3705. },
  3706. {
  3707. arguments = {
  3708. {
  3709. name = "filename",
  3710. type = "string",
  3711. description = "The filename of the font file to load."
  3712. },
  3713. {
  3714. name = "size",
  3715. type = "number",
  3716. description = "The resolution to render the fonts at, in pixels. Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations.",
  3717. default = "32"
  3718. }
  3719. },
  3720. returns = {
  3721. {
  3722. name = "rasterizer",
  3723. type = "Rasterizer",
  3724. description = "The new Rasterizer."
  3725. }
  3726. }
  3727. },
  3728. {
  3729. arguments = {
  3730. {
  3731. name = "blob",
  3732. type = "Blob",
  3733. description = "The Blob containing font data."
  3734. },
  3735. {
  3736. name = "size",
  3737. type = "number",
  3738. description = "The resolution to render the fonts at, in pixels. Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations.",
  3739. default = "32"
  3740. }
  3741. },
  3742. returns = {
  3743. {
  3744. name = "rasterizer",
  3745. type = "Rasterizer",
  3746. description = "The new Rasterizer."
  3747. }
  3748. }
  3749. }
  3750. }
  3751. },
  3752. {
  3753. name = "newSound",
  3754. summary = "Create a new Sound.",
  3755. description = "Creates a new Sound. A sound can be loaded from an audio file, or it can be created empty with capacity for a certain number of audio frames.\n\nWhen loading audio from a file, use the `decode` option to control whether compressed audio should remain compressed or immediately get decoded to raw samples.\n\nWhen creating an empty sound, the `contents` parameter can be set to `'stream'` to create an audio stream. On streams, `Sound:setFrames` will always write to the end of the stream, and `Sound:getFrames` will always read the oldest samples from the beginning. The number of frames in the sound is the total capacity of the stream's buffer.",
  3756. key = "lovr.data.newSound",
  3757. module = "lovr.data",
  3758. notes = "It is highly recommended to use an audio format that matches the format of the audio module: `f32` sample formats at a sample rate of 48000, with 1 channel for spatialized sources or 2 channels for unspatialized sources. This will avoid the need to convert audio during playback, which boosts performance of the audio thread.\n\nThe WAV importer supports 16, 24, and 32 bit integer data and 32 bit floating point data. The data must be mono, stereo, or 4-channel full-sphere ambisonic. The `WAVE_FORMAT_EXTENSIBLE` extension is supported.\n\nAmbisonic channel layouts are supported for import (but not yet for playback). Ambisonic data can be loaded from WAV files. It must be first-order full-sphere ambisonic data with 4 channels. If the WAV has a `WAVE_FORMAT_EXTENSIBLE` chunk with an `AMBISONIC_B_FORMAT` format GUID, then the data is understood as using the AMB format with Furse-Malham channel ordering and normalization. *All other* 4-channel files are assumed to be using the AmbiX format with ACN channel ordering and SN3D normalization. AMB files will get automatically converted to AmbiX on import, so ambisonic Sounds will always be in a consistent format.\n\nOGG and MP3 files will always have the `f32` format when loaded.",
  3759. variants = {
  3760. {
  3761. description = "Create a raw or stream Sound from a frame count and format info:",
  3762. arguments = {
  3763. {
  3764. name = "frames",
  3765. type = "number",
  3766. description = "The number of frames the Sound can hold."
  3767. },
  3768. {
  3769. name = "format",
  3770. type = "SampleFormat",
  3771. description = "The sample data type.",
  3772. default = "'f32'"
  3773. },
  3774. {
  3775. name = "channels",
  3776. type = "ChannelLayout",
  3777. description = "The channel layout.",
  3778. default = "'stereo'"
  3779. },
  3780. {
  3781. name = "sampleRate",
  3782. type = "number",
  3783. description = "The sample rate, in Hz.",
  3784. default = "48000"
  3785. },
  3786. {
  3787. name = "contents",
  3788. type = "*",
  3789. description = "A Blob containing raw audio samples to use as the initial contents, 'stream' to create an audio stream, or `nil` to leave the data initialized to zero.",
  3790. default = "nil"
  3791. }
  3792. },
  3793. returns = {
  3794. {
  3795. name = "sound",
  3796. type = "Sound",
  3797. description = "Sounds good."
  3798. }
  3799. }
  3800. },
  3801. {
  3802. description = "Load a sound from a file. Compressed audio formats (OGG, MP3) can optionally be decoded into raw sounds.",
  3803. arguments = {
  3804. {
  3805. name = "filename",
  3806. type = "string",
  3807. description = "The filename of a sound to load."
  3808. },
  3809. {
  3810. name = "decode",
  3811. type = "boolean",
  3812. description = "Whether compressed audio files should be immediately decoded."
  3813. }
  3814. },
  3815. returns = {
  3816. {
  3817. name = "sound",
  3818. type = "Sound",
  3819. description = "Sounds good."
  3820. }
  3821. }
  3822. },
  3823. {
  3824. description = "Load a sound from a Blob containing the data of an audio file. Compressed audio formats (OGG, MP3) can optionally be decoded into raw sounds.\n\nIf the Blob contains raw audio samples, use the first variant instead of this one.",
  3825. arguments = {
  3826. {
  3827. name = "blob",
  3828. type = "Blob",
  3829. description = "The Blob containing audio file data to load."
  3830. },
  3831. {
  3832. name = "decode",
  3833. type = "boolean",
  3834. description = "Whether compressed audio files should be immediately decoded."
  3835. }
  3836. },
  3837. returns = {
  3838. {
  3839. name = "sound",
  3840. type = "Sound",
  3841. description = "Sounds good."
  3842. }
  3843. }
  3844. }
  3845. }
  3846. }
  3847. },
  3848. objects = {
  3849. {
  3850. name = "Blob",
  3851. summary = "A chunk of binary data.",
  3852. description = "A Blob is an object that holds binary data. It can be passed to most functions that take filename arguments, like `lovr.graphics.newModel` or `lovr.audio.newSource`. Blobs aren't usually necessary for simple projects, but they can be really helpful if:\n\n- You need to work with low level binary data, potentially using the LuaJIT FFI for increased\n performance.\n- You are working with data that isn't stored as a file, such as programmatically generated data\n or a string from a network request.\n- You want to load data from a file once and then use it to create many different objects.\n\nA Blob's size cannot be changed once it is created.",
  3853. key = "Blob",
  3854. module = "lovr.data",
  3855. constructors = {
  3856. "lovr.data.newBlob",
  3857. "lovr.filesystem.newBlob"
  3858. },
  3859. methods = {
  3860. {
  3861. name = "getSize",
  3862. summary = "Get the size of the Blob, in bytes.",
  3863. description = "Returns the size of the Blob's contents, in bytes.",
  3864. key = "Blob:getSize",
  3865. module = "lovr.data",
  3866. variants = {
  3867. {
  3868. arguments = {},
  3869. returns = {
  3870. {
  3871. name = "bytes",
  3872. type = "number",
  3873. description = "The size of the Blob, in bytes."
  3874. }
  3875. }
  3876. }
  3877. }
  3878. },
  3879. {
  3880. name = "getName",
  3881. summary = "Get the label of the Blob.",
  3882. description = "Returns the filename the Blob was loaded from, or the custom name given to it when it was created. This label is also used in error messages.",
  3883. key = "Blob:getName",
  3884. module = "lovr.data",
  3885. variants = {
  3886. {
  3887. arguments = {},
  3888. returns = {
  3889. {
  3890. name = "name",
  3891. type = "string",
  3892. description = "The name of the Blob."
  3893. }
  3894. }
  3895. }
  3896. }
  3897. },
  3898. {
  3899. name = "getPointer",
  3900. summary = "Get a raw pointer to the Blob's data.",
  3901. description = "Returns a raw pointer to the Blob's data. This can be used to interface with other C libraries using the LuaJIT FFI. Use this only if you know what you're doing!",
  3902. key = "Blob:getPointer",
  3903. module = "lovr.data",
  3904. variants = {
  3905. {
  3906. arguments = {},
  3907. returns = {
  3908. {
  3909. name = "pointer",
  3910. type = "userdata",
  3911. description = "A pointer to the data."
  3912. }
  3913. }
  3914. }
  3915. }
  3916. },
  3917. {
  3918. name = "getString",
  3919. summary = "Get the Blob's contents as a string.",
  3920. description = "Returns a binary string containing the Blob's data.",
  3921. key = "Blob:getString",
  3922. module = "lovr.data",
  3923. examples = {
  3924. {
  3925. description = "Print each byte of the main.lua file:",
  3926. code = "blob = lovr.filesystem.newBlob('main.lua')\nstr = blob:getString()\n\nfor i = 1, #str do\n print(string.byte(str, i))\nend"
  3927. }
  3928. },
  3929. notes = "This effectively allocates a new copy of the Blob as a Lua string, so this should be avoided for really big Blobs!",
  3930. variants = {
  3931. {
  3932. arguments = {
  3933. {
  3934. name = "offset",
  3935. type = "number",
  3936. description = "A byte offset into the Blob where the string will start.",
  3937. default = "0"
  3938. },
  3939. {
  3940. name = "size",
  3941. type = "number",
  3942. description = "The number of bytes the string will contain. If nil, the rest of the data in the Blob will be used, based on the `offset` parameter.",
  3943. default = "nil"
  3944. }
  3945. },
  3946. returns = {
  3947. {
  3948. name = "data",
  3949. type = "string",
  3950. description = "The Blob's data."
  3951. }
  3952. }
  3953. }
  3954. }
  3955. },
  3956. {
  3957. name = "getI8",
  3958. summary = "Unpack signed 8-bit integers from the Blob.",
  3959. description = "Returns signed 8-bit integers from the data in the Blob.",
  3960. key = "Blob:getI8",
  3961. module = "lovr.data",
  3962. related = {
  3963. "Blob:getU8",
  3964. "Blob:getI16",
  3965. "Blob:getU16",
  3966. "Blob:getI32",
  3967. "Blob:getU32",
  3968. "Blob:getF32",
  3969. "Blob:getF64"
  3970. },
  3971. variants = {
  3972. {
  3973. arguments = {
  3974. {
  3975. name = "offset",
  3976. type = "number",
  3977. description = "A non-negative byte offset to read from.",
  3978. default = "0"
  3979. },
  3980. {
  3981. name = "count",
  3982. type = "number",
  3983. description = "The number of integers to read.",
  3984. default = "1"
  3985. }
  3986. },
  3987. returns = {
  3988. {
  3989. name = "...",
  3990. type = "number",
  3991. description = "`count` signed 8-bit integers, from -128 to 127."
  3992. }
  3993. }
  3994. }
  3995. }
  3996. },
  3997. {
  3998. name = "getU8",
  3999. summary = "Unpack unsigned 8-bit integers from the Blob.",
  4000. description = "Returns unsigned 8-bit integers from the data in the Blob.",
  4001. key = "Blob:getU8",
  4002. module = "lovr.data",
  4003. related = {
  4004. "Blob:getI8",
  4005. "Blob:getI16",
  4006. "Blob:getU16",
  4007. "Blob:getI32",
  4008. "Blob:getU32",
  4009. "Blob:getF32",
  4010. "Blob:getF64"
  4011. },
  4012. variants = {
  4013. {
  4014. arguments = {
  4015. {
  4016. name = "offset",
  4017. type = "number",
  4018. description = "A non-negative byte offset to read from.",
  4019. default = "0"
  4020. },
  4021. {
  4022. name = "count",
  4023. type = "number",
  4024. description = "The number of integers to read.",
  4025. default = "1"
  4026. }
  4027. },
  4028. returns = {
  4029. {
  4030. name = "...",
  4031. type = "number",
  4032. description = "`count` unsigned 8-bit integers, from 0 to 255."
  4033. }
  4034. }
  4035. }
  4036. }
  4037. },
  4038. {
  4039. name = "getI16",
  4040. summary = "Unpack signed 16-bit integers from the Blob.",
  4041. description = "Returns signed 16-bit integers from the data in the Blob.",
  4042. key = "Blob:getI16",
  4043. module = "lovr.data",
  4044. related = {
  4045. "Blob:getI8",
  4046. "Blob:getU8",
  4047. "Blob:getU16",
  4048. "Blob:getI32",
  4049. "Blob:getU32",
  4050. "Blob:getF32",
  4051. "Blob:getF64"
  4052. },
  4053. variants = {
  4054. {
  4055. arguments = {
  4056. {
  4057. name = "offset",
  4058. type = "number",
  4059. description = "A non-negative byte offset to read from.",
  4060. default = "0"
  4061. },
  4062. {
  4063. name = "count",
  4064. type = "number",
  4065. description = "The number of integers to read.",
  4066. default = "1"
  4067. }
  4068. },
  4069. returns = {
  4070. {
  4071. name = "...",
  4072. type = "number",
  4073. description = "`count` signed 16-bit integers, from -32768 to 32767."
  4074. }
  4075. }
  4076. }
  4077. }
  4078. },
  4079. {
  4080. name = "getU16",
  4081. summary = "Unpack unsigned 16-bit integers from the Blob.",
  4082. description = "Returns unsigned 16-bit integers from the data in the Blob.",
  4083. key = "Blob:getU16",
  4084. module = "lovr.data",
  4085. related = {
  4086. "Blob:getI8",
  4087. "Blob:getU8",
  4088. "Blob:getI16",
  4089. "Blob:getI32",
  4090. "Blob:getU32",
  4091. "Blob:getF32",
  4092. "Blob:getF64"
  4093. },
  4094. variants = {
  4095. {
  4096. arguments = {
  4097. {
  4098. name = "offset",
  4099. type = "number",
  4100. description = "A non-negative byte offset to read from.",
  4101. default = "0"
  4102. },
  4103. {
  4104. name = "count",
  4105. type = "number",
  4106. description = "The number of integers to read.",
  4107. default = "1"
  4108. }
  4109. },
  4110. returns = {
  4111. {
  4112. name = "...",
  4113. type = "number",
  4114. description = "`count` unsigned 16-bit integers, from 0 to 65535."
  4115. }
  4116. }
  4117. }
  4118. }
  4119. },
  4120. {
  4121. name = "getI32",
  4122. summary = "Unpack signed 32-bit integers from the Blob.",
  4123. description = "Returns signed 32-bit integers from the data in the Blob.",
  4124. key = "Blob:getI32",
  4125. module = "lovr.data",
  4126. related = {
  4127. "Blob:getI8",
  4128. "Blob:getU8",
  4129. "Blob:getI16",
  4130. "Blob:getU16",
  4131. "Blob:getU32",
  4132. "Blob:getF32",
  4133. "Blob:getF64"
  4134. },
  4135. variants = {
  4136. {
  4137. arguments = {
  4138. {
  4139. name = "offset",
  4140. type = "number",
  4141. description = "A non-negative byte offset to read from.",
  4142. default = "0"
  4143. },
  4144. {
  4145. name = "count",
  4146. type = "number",
  4147. description = "The number of integers to read.",
  4148. default = "1"
  4149. }
  4150. },
  4151. returns = {
  4152. {
  4153. name = "...",
  4154. type = "number",
  4155. description = "`count` signed 32-bit integers, from -2147483648 to 2147483647."
  4156. }
  4157. }
  4158. }
  4159. }
  4160. },
  4161. {
  4162. name = "getU32",
  4163. summary = "Unpack unsigned 32-bit integers from the Blob.",
  4164. description = "Returns unsigned 32-bit integers from the data in the Blob.",
  4165. key = "Blob:getU32",
  4166. module = "lovr.data",
  4167. related = {
  4168. "Blob:getI8",
  4169. "Blob:getU8",
  4170. "Blob:getI16",
  4171. "Blob:getU16",
  4172. "Blob:getI32",
  4173. "Blob:getF32",
  4174. "Blob:getF64"
  4175. },
  4176. variants = {
  4177. {
  4178. arguments = {
  4179. {
  4180. name = "offset",
  4181. type = "number",
  4182. description = "A non-negative byte offset to read from.",
  4183. default = "0"
  4184. },
  4185. {
  4186. name = "count",
  4187. type = "number",
  4188. description = "The number of integers to read.",
  4189. default = "1"
  4190. }
  4191. },
  4192. returns = {
  4193. {
  4194. name = "...",
  4195. type = "number",
  4196. description = "`count` unsigned 32-bit integers, from 0 to 4294967296."
  4197. }
  4198. }
  4199. }
  4200. }
  4201. },
  4202. {
  4203. name = "getF32",
  4204. summary = "Unpack 32-bit floating point numbers from the Blob.",
  4205. description = "Returns 32-bit floating point numbers from the data in the Blob.",
  4206. key = "Blob:getF32",
  4207. module = "lovr.data",
  4208. related = {
  4209. "Blob:getI8",
  4210. "Blob:getU8",
  4211. "Blob:getI16",
  4212. "Blob:getU16",
  4213. "Blob:getI32",
  4214. "Blob:getU32",
  4215. "Blob:getF64"
  4216. },
  4217. variants = {
  4218. {
  4219. arguments = {
  4220. {
  4221. name = "offset",
  4222. type = "number",
  4223. description = "A non-negative byte offset to read from.",
  4224. default = "0"
  4225. },
  4226. {
  4227. name = "count",
  4228. type = "number",
  4229. description = "The number of floats to read.",
  4230. default = "1"
  4231. }
  4232. },
  4233. returns = {
  4234. {
  4235. name = "...",
  4236. type = "number",
  4237. description = "`count` 32-bit floats."
  4238. }
  4239. }
  4240. }
  4241. }
  4242. },
  4243. {
  4244. name = "getF64",
  4245. summary = "Unpack 64-bit floating point numbers from the Blob.",
  4246. description = "Returns 64-bit floating point numbers from the data in the Blob.",
  4247. key = "Blob:getF64",
  4248. module = "lovr.data",
  4249. related = {
  4250. "Blob:getI8",
  4251. "Blob:getU8",
  4252. "Blob:getI16",
  4253. "Blob:getU16",
  4254. "Blob:getI32",
  4255. "Blob:getU32",
  4256. "Blob:getF32"
  4257. },
  4258. variants = {
  4259. {
  4260. arguments = {
  4261. {
  4262. name = "offset",
  4263. type = "number",
  4264. description = "A non-negative byte offset to read from.",
  4265. default = "0"
  4266. },
  4267. {
  4268. name = "count",
  4269. type = "number",
  4270. description = "The number of doubles to read.",
  4271. default = "1"
  4272. }
  4273. },
  4274. returns = {
  4275. {
  4276. name = "...",
  4277. type = "number",
  4278. description = "`count` 64-bit doubles."
  4279. }
  4280. }
  4281. }
  4282. }
  4283. }
  4284. }
  4285. },
  4286. {
  4287. name = "Image",
  4288. summary = "An object that stores pixel data for Textures.",
  4289. description = "An Image stores raw 2D pixel info for `Texture`s. It has a width, height, and format. The Image can be initialized with the contents of an image file or it can be created with uninitialized contents. The supported image formats are `png`, `jpg`, `hdr`, `dds`, `ktx`, and `astc`.\n\nUsually you can just use Textures, but Image can be useful if you want to manipulate individual pixels, load Textures in a background thread, or use the FFI to efficiently access the raw image data.",
  4290. key = "Image",
  4291. module = "lovr.data",
  4292. constructors = {
  4293. "lovr.data.newImage"
  4294. },
  4295. methods = {
  4296. {
  4297. name = "encode",
  4298. summary = "Encode the Image as png.",
  4299. description = "Encodes the Image to an uncompressed png. This intended mainly for debugging.",
  4300. key = "Image:encode",
  4301. module = "lovr.data",
  4302. related = {
  4303. "lovr.filesystem.write"
  4304. },
  4305. variants = {
  4306. {
  4307. arguments = {},
  4308. returns = {
  4309. {
  4310. name = "blob",
  4311. type = "Blob",
  4312. description = "A new Blob containing the PNG image data."
  4313. }
  4314. }
  4315. }
  4316. }
  4317. },
  4318. {
  4319. name = "getBlob",
  4320. summary = "Get the bytes backing this Image as a `Blob`.",
  4321. description = "Returns a Blob containing the raw bytes of the Image.",
  4322. key = "Image:getBlob",
  4323. module = "lovr.data",
  4324. related = {
  4325. "Blob:getPointer",
  4326. "Sound:getBlob"
  4327. },
  4328. variants = {
  4329. {
  4330. arguments = {},
  4331. returns = {
  4332. {
  4333. name = "blob",
  4334. type = "Blob",
  4335. description = "The Blob instance containing the bytes for the `Image`."
  4336. }
  4337. }
  4338. }
  4339. }
  4340. },
  4341. {
  4342. name = "getDimensions",
  4343. summary = "Get the dimensions of the Image.",
  4344. description = "Returns the dimensions of the Image, in pixels.",
  4345. key = "Image:getDimensions",
  4346. module = "lovr.data",
  4347. related = {
  4348. "Image:getWidth",
  4349. "Image:getHeight",
  4350. "Texture:getDimensions"
  4351. },
  4352. variants = {
  4353. {
  4354. arguments = {},
  4355. returns = {
  4356. {
  4357. name = "width",
  4358. type = "number",
  4359. description = "The width of the Image, in pixels."
  4360. },
  4361. {
  4362. name = "height",
  4363. type = "number",
  4364. description = "The height of the Image, in pixels."
  4365. }
  4366. }
  4367. }
  4368. }
  4369. },
  4370. {
  4371. name = "getFormat",
  4372. summary = "Get the pixel format of the Image.",
  4373. description = "Returns the format of the Image.",
  4374. key = "Image:getFormat",
  4375. module = "lovr.data",
  4376. related = {
  4377. "TextureFormat",
  4378. "Texture:getFormat"
  4379. },
  4380. variants = {
  4381. {
  4382. arguments = {},
  4383. returns = {
  4384. {
  4385. name = "format",
  4386. type = "TextureFormat",
  4387. description = "The format of the pixels in the Image."
  4388. }
  4389. }
  4390. }
  4391. }
  4392. },
  4393. {
  4394. name = "getHeight",
  4395. summary = "Get the height of the Image.",
  4396. description = "Returns the height of the Image, in pixels.",
  4397. key = "Image:getHeight",
  4398. module = "lovr.data",
  4399. related = {
  4400. "Image:getWidth",
  4401. "Image:getDimensions",
  4402. "Texture:getHeight"
  4403. },
  4404. variants = {
  4405. {
  4406. arguments = {},
  4407. returns = {
  4408. {
  4409. name = "height",
  4410. type = "number",
  4411. description = "The height of the Image, in pixels."
  4412. }
  4413. }
  4414. }
  4415. }
  4416. },
  4417. {
  4418. name = "getPixel",
  4419. summary = "Get the value of a pixel of the Image.",
  4420. description = "Returns the value of a pixel of the Image.",
  4421. key = "Image:getPixel",
  4422. module = "lovr.data",
  4423. notes = "The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`.",
  4424. related = {
  4425. "Image:setPixel",
  4426. "Image:mapPixel",
  4427. "TextureFormat",
  4428. "Texture:getPixels",
  4429. "Texture:setPixels",
  4430. "Texture:newReadback"
  4431. },
  4432. variants = {
  4433. {
  4434. arguments = {
  4435. {
  4436. name = "x",
  4437. type = "number",
  4438. description = "The x coordinate of the pixel to get (0-indexed)."
  4439. },
  4440. {
  4441. name = "y",
  4442. type = "number",
  4443. description = "The y coordinate of the pixel to get (0-indexed)."
  4444. }
  4445. },
  4446. returns = {
  4447. {
  4448. name = "r",
  4449. type = "number",
  4450. description = "The red component of the pixel, from 0.0 to 1.0."
  4451. },
  4452. {
  4453. name = "g",
  4454. type = "number",
  4455. description = "The green component of the pixel, from 0.0 to 1.0."
  4456. },
  4457. {
  4458. name = "b",
  4459. type = "number",
  4460. description = "The blue component of the pixel, from 0.0 to 1.0."
  4461. },
  4462. {
  4463. name = "a",
  4464. type = "number",
  4465. description = "The alpha component of the pixel, from 0.0 to 1.0."
  4466. }
  4467. }
  4468. }
  4469. }
  4470. },
  4471. {
  4472. name = "getWidth",
  4473. summary = "Get the width of the Image.",
  4474. description = "Returns the width of the Image, in pixels.",
  4475. key = "Image:getWidth",
  4476. module = "lovr.data",
  4477. related = {
  4478. "Image:getHeight",
  4479. "Image:getDimensions",
  4480. "Texture:getWidth"
  4481. },
  4482. variants = {
  4483. {
  4484. arguments = {},
  4485. returns = {
  4486. {
  4487. name = "width",
  4488. type = "number",
  4489. description = "The width of the Image, in pixels."
  4490. }
  4491. }
  4492. }
  4493. }
  4494. },
  4495. {
  4496. name = "mapPixel",
  4497. summary = "Transform an Image by applying a function to every pixel.",
  4498. description = "Transforms pixels in the Image using a function.\n\nThe callback function passed to this function will be called once for each pixel. For each pixel, the function will be called with its x and y coordinate and the red, green, blue, and alpha components of its color. Whatever the function returns will be used as the new color for the pixel.\n\nThe callback function will potentially be called thousands of times, so it's best to keep the amount of code in there small and fast.",
  4499. key = "Image:mapPixel",
  4500. module = "lovr.data",
  4501. examples = {
  4502. {
  4503. description = "Convert an Image to grayscale.",
  4504. code = "image:mapPixel(function(x, y, r, g, b, a)\n local brightness = .21 * r + .72 * g + .07 * b\n return brightness, brightness, brightness, a\nend)"
  4505. },
  4506. {
  4507. description = "Efficient Image updates using FFI. Due to the low-level nature, this will be a lot faster, but it's specialized to the `rgba8` image format and risks crashing if used improperly.",
  4508. code = "local ffi = require 'ffi'\n\nfunction lovr.load()\n local w, h = 256, 256\n\n image = lovr.data.newImage(w, h)\n\n local pointer = ffi.cast('uint8_t*', image:getPointer())\n\n for y = 0, h - 1 do\n for x = 0, w - 1 do\n pointer[(y * w + x) * 4 + 0] = (x / w) * 255\n pointer[(y * w + x) * 4 + 1] = (y / h) * 255\n pointer[(y * w + x) * 4 + 2] = 255\n pointer[(y * w + x) * 4 + 3] = 255\n end\n end\n\n texture = lovr.graphics.newTexture(image)\nend\n\nfunction lovr.draw(pass)\n pass:fill(texture)\nend"
  4509. }
  4510. },
  4511. notes = "The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`.",
  4512. related = {
  4513. "Image:setPixel",
  4514. "Image:getPixel",
  4515. "TextureFormat",
  4516. "Texture:setPixels"
  4517. },
  4518. variants = {
  4519. {
  4520. arguments = {
  4521. {
  4522. name = "callback",
  4523. type = "function",
  4524. description = "The function that will be called for each pixel."
  4525. },
  4526. {
  4527. name = "x",
  4528. type = "number",
  4529. description = "The x coordinate of the upper-left corner of the area of the Image to affect.",
  4530. default = "0"
  4531. },
  4532. {
  4533. name = "y",
  4534. type = "number",
  4535. description = "The y coordinate of the upper-left corner of the area of the Image to affect.",
  4536. default = "0"
  4537. },
  4538. {
  4539. name = "w",
  4540. type = "number",
  4541. description = "The width of the area to affect.",
  4542. default = "image:getWidth()"
  4543. },
  4544. {
  4545. name = "h",
  4546. type = "number",
  4547. description = "The height of the area to affect.",
  4548. default = "image:getHeight()"
  4549. }
  4550. },
  4551. returns = {}
  4552. }
  4553. }
  4554. },
  4555. {
  4556. name = "paste",
  4557. summary = "Copy pixels from another Image to this one.",
  4558. description = "Copies a rectangle of pixels from one Image to this one.",
  4559. key = "Image:paste",
  4560. module = "lovr.data",
  4561. notes = "The two Images must have the same pixel format.\n\nCompressed images cannot be copied.\n\nThe rectangle cannot go outside the dimensions of the source or destination textures.",
  4562. related = {
  4563. "Image:getPixel",
  4564. "Image:setPixel",
  4565. "Texture:setPixels"
  4566. },
  4567. variants = {
  4568. {
  4569. arguments = {
  4570. {
  4571. name = "source",
  4572. type = "Image",
  4573. description = "The Image to copy pixels from."
  4574. },
  4575. {
  4576. name = "x",
  4577. type = "number",
  4578. description = "The x coordinate to paste to (0-indexed).",
  4579. default = "0"
  4580. },
  4581. {
  4582. name = "y",
  4583. type = "number",
  4584. description = "The y coordinate to paste to (0-indexed).",
  4585. default = "0"
  4586. },
  4587. {
  4588. name = "fromX",
  4589. type = "number",
  4590. description = "The x coordinate in the source to paste from (0-indexed).",
  4591. default = "0"
  4592. },
  4593. {
  4594. name = "fromY",
  4595. type = "number",
  4596. description = "The y coordinate in the source to paste from (0-indexed).",
  4597. default = "0"
  4598. },
  4599. {
  4600. name = "width",
  4601. type = "number",
  4602. description = "The width of the region to copy.",
  4603. default = "source:getWidth()"
  4604. },
  4605. {
  4606. name = "height",
  4607. type = "number",
  4608. description = "The height of the region to copy.",
  4609. default = "source:getHeight()"
  4610. }
  4611. },
  4612. returns = {}
  4613. }
  4614. }
  4615. },
  4616. {
  4617. name = "setPixel",
  4618. summary = "Set the value of a pixel of the Image.",
  4619. description = "Sets the value of a single pixel of the Image.\n\nIf you need to change a bunch of pixels, consider using `Image:mapPixel`.",
  4620. key = "Image:setPixel",
  4621. module = "lovr.data",
  4622. notes = "The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`.",
  4623. related = {
  4624. "Image:mapPixel",
  4625. "Image:getPixel",
  4626. "TextureFormat",
  4627. "Texture:setPixels"
  4628. },
  4629. variants = {
  4630. {
  4631. arguments = {
  4632. {
  4633. name = "x",
  4634. type = "number",
  4635. description = "The x coordinate of the pixel to set (0-indexed)."
  4636. },
  4637. {
  4638. name = "y",
  4639. type = "number",
  4640. description = "The y coordinate of the pixel to set (0-indexed)."
  4641. },
  4642. {
  4643. name = "r",
  4644. type = "number",
  4645. description = "The red component of the pixel, from 0.0 to 1.0."
  4646. },
  4647. {
  4648. name = "g",
  4649. type = "number",
  4650. description = "The green component of the pixel, from 0.0 to 1.0."
  4651. },
  4652. {
  4653. name = "b",
  4654. type = "number",
  4655. description = "The blue component of the pixel, from 0.0 to 1.0."
  4656. },
  4657. {
  4658. name = "a",
  4659. type = "number",
  4660. description = "The alpha component of the pixel, from 0.0 to 1.0.",
  4661. default = "1.0"
  4662. }
  4663. },
  4664. returns = {}
  4665. }
  4666. }
  4667. }
  4668. }
  4669. },
  4670. {
  4671. name = "ModelData",
  4672. summary = "An object that loads and stores data for 3D models.",
  4673. description = "A ModelData is a container object that loads and holds data contained in 3D model files. This can include a variety of things like the node structure of the asset, the vertex data it contains, contains, the `Image` and `Material` properties, and any included animations.\n\nThe current supported formats are OBJ, glTF, and STL.\n\nUsually you can just load a `Model` directly, but using a `ModelData` can be helpful if you want to load models in a thread or access more low-level information about the Model.",
  4674. key = "ModelData",
  4675. module = "lovr.data",
  4676. constructors = {
  4677. "lovr.data.newModelData"
  4678. },
  4679. methods = {
  4680. {
  4681. name = "getAnimationChannelCount",
  4682. summary = "Get the number of channels in an animation.",
  4683. description = "Returns the number of channels in an animation.\n\nA channel is a set of keyframes for a single property of a node.",
  4684. key = "ModelData:getAnimationChannelCount",
  4685. module = "lovr.data",
  4686. related = {
  4687. "ModelData:getAnimationNode",
  4688. "ModelData:getAnimationProperty"
  4689. },
  4690. variants = {
  4691. {
  4692. arguments = {
  4693. {
  4694. name = "index",
  4695. type = "number",
  4696. description = "The index of an animation."
  4697. }
  4698. },
  4699. returns = {
  4700. {
  4701. name = "count",
  4702. type = "number",
  4703. description = "The number of channels in the animation."
  4704. }
  4705. }
  4706. },
  4707. {
  4708. arguments = {
  4709. {
  4710. name = "name",
  4711. type = "string",
  4712. description = "The name of an animation."
  4713. }
  4714. },
  4715. returns = {
  4716. {
  4717. name = "count",
  4718. type = "number",
  4719. description = "The number of channels in the animation."
  4720. }
  4721. }
  4722. }
  4723. }
  4724. },
  4725. {
  4726. name = "getAnimationCount",
  4727. summary = "Get the number of animations in the model.",
  4728. description = "Returns the number of animations in the model.",
  4729. key = "ModelData:getAnimationCount",
  4730. module = "lovr.data",
  4731. related = {
  4732. "Model:getAnimationCount"
  4733. },
  4734. variants = {
  4735. {
  4736. arguments = {},
  4737. returns = {
  4738. {
  4739. name = "count",
  4740. type = "number",
  4741. description = "The number of animations in the model."
  4742. }
  4743. }
  4744. }
  4745. }
  4746. },
  4747. {
  4748. name = "getAnimationDuration",
  4749. summary = "Get the duration of an animation.",
  4750. description = "Returns the duration of an animation.",
  4751. key = "ModelData:getAnimationDuration",
  4752. module = "lovr.data",
  4753. notes = "The duration of the animation is calculated as the latest timestamp of all of its channels.",
  4754. related = {
  4755. "Model:getAnimationDuration"
  4756. },
  4757. variants = {
  4758. {
  4759. arguments = {
  4760. {
  4761. name = "index",
  4762. type = "number",
  4763. description = "The index of the animation."
  4764. }
  4765. },
  4766. returns = {
  4767. {
  4768. name = "duration",
  4769. type = "number",
  4770. description = "The duration of the animation, in seconds."
  4771. }
  4772. }
  4773. },
  4774. {
  4775. arguments = {
  4776. {
  4777. name = "name",
  4778. type = "string",
  4779. description = "The name of the animation."
  4780. }
  4781. },
  4782. returns = {
  4783. {
  4784. name = "duration",
  4785. type = "number",
  4786. description = "The duration of the animation, in seconds."
  4787. }
  4788. }
  4789. }
  4790. }
  4791. },
  4792. {
  4793. name = "getAnimationKeyframe",
  4794. summary = "Get a keyframe in a channel of an animation.",
  4795. description = "Returns a single keyframe in a channel of an animation.",
  4796. key = "ModelData:getAnimationKeyframe",
  4797. module = "lovr.data",
  4798. related = {
  4799. "ModelData:getAnimationSmoothMode",
  4800. "ModelData:getAnimationKeyframeCount"
  4801. },
  4802. variants = {
  4803. {
  4804. arguments = {
  4805. {
  4806. name = "index",
  4807. type = "number",
  4808. description = "The index of an animation."
  4809. },
  4810. {
  4811. name = "channel",
  4812. type = "number",
  4813. description = "The index of a channel in the animation."
  4814. },
  4815. {
  4816. name = "keyframe",
  4817. type = "number",
  4818. description = "The index of a keyframe in the channel."
  4819. }
  4820. },
  4821. returns = {
  4822. {
  4823. name = "time",
  4824. type = "number",
  4825. description = "The timestamp of the keyframe."
  4826. },
  4827. {
  4828. name = "...",
  4829. type = "number",
  4830. description = "The data for the keyframe (either 3 or 4 numbers depending on the property)."
  4831. }
  4832. }
  4833. },
  4834. {
  4835. arguments = {
  4836. {
  4837. name = "name",
  4838. type = "string",
  4839. description = "The name of an animation."
  4840. },
  4841. {
  4842. name = "channel",
  4843. type = "number",
  4844. description = "The index of a channel in the animation."
  4845. },
  4846. {
  4847. name = "keyframe",
  4848. type = "number",
  4849. description = "The index of a keyframe in the channel."
  4850. }
  4851. },
  4852. returns = {
  4853. {
  4854. name = "time",
  4855. type = "number",
  4856. description = "The timestamp of the keyframe."
  4857. },
  4858. {
  4859. name = "...",
  4860. type = "number",
  4861. description = "The data for the keyframe (either 3 or 4 numbers depending on the property)."
  4862. }
  4863. }
  4864. }
  4865. }
  4866. },
  4867. {
  4868. name = "getAnimationKeyframeCount",
  4869. summary = "Get the number of keyframes in a channel of an animation.",
  4870. description = "Returns the number of keyframes in a channel of an animation.",
  4871. key = "ModelData:getAnimationKeyframeCount",
  4872. module = "lovr.data",
  4873. related = {
  4874. "ModelData:getAnimationSmoothMode",
  4875. "ModelData:getAnimationKeyframe"
  4876. },
  4877. variants = {
  4878. {
  4879. arguments = {
  4880. {
  4881. name = "index",
  4882. type = "number",
  4883. description = "The index of an animation."
  4884. },
  4885. {
  4886. name = "channel",
  4887. type = "number",
  4888. description = "The index of a channel in the animation."
  4889. }
  4890. },
  4891. returns = {
  4892. {
  4893. name = "count",
  4894. type = "number",
  4895. description = "The number of keyframes in the channel."
  4896. }
  4897. }
  4898. },
  4899. {
  4900. arguments = {
  4901. {
  4902. name = "name",
  4903. type = "string",
  4904. description = "The name of an animation."
  4905. },
  4906. {
  4907. name = "channel",
  4908. type = "number",
  4909. description = "The index of a channel in the animation."
  4910. }
  4911. },
  4912. returns = {
  4913. {
  4914. name = "count",
  4915. type = "number",
  4916. description = "The number of keyframes in the channel."
  4917. }
  4918. }
  4919. }
  4920. }
  4921. },
  4922. {
  4923. name = "getAnimationName",
  4924. summary = "Get the name of an animation.",
  4925. description = "Returns the name of an animation.",
  4926. key = "ModelData:getAnimationName",
  4927. module = "lovr.data",
  4928. notes = "If the animation does not have a name, this function returns `nil`.",
  4929. related = {
  4930. "Model:getAnimationName"
  4931. },
  4932. variants = {
  4933. {
  4934. arguments = {
  4935. {
  4936. name = "index",
  4937. type = "number",
  4938. description = "The index of the animation."
  4939. }
  4940. },
  4941. returns = {
  4942. {
  4943. name = "name",
  4944. type = "string",
  4945. description = "The name of the animation."
  4946. }
  4947. }
  4948. }
  4949. }
  4950. },
  4951. {
  4952. name = "getAnimationNode",
  4953. summary = "Get the node targeted by the channel of an animation.",
  4954. description = "Returns the index of a node targeted by an animation's channel.",
  4955. key = "ModelData:getAnimationNode",
  4956. module = "lovr.data",
  4957. related = {
  4958. "ModelData:getAnimationProperty",
  4959. "ModelData:getAnimationSmoothMode"
  4960. },
  4961. variants = {
  4962. {
  4963. arguments = {
  4964. {
  4965. name = "index",
  4966. type = "number",
  4967. description = "The index of an animation."
  4968. },
  4969. {
  4970. name = "channel",
  4971. type = "number",
  4972. description = "The index of a channel in the animation."
  4973. }
  4974. },
  4975. returns = {
  4976. {
  4977. name = "node",
  4978. type = "number",
  4979. description = "The index of the node targeted by the channel."
  4980. }
  4981. }
  4982. },
  4983. {
  4984. arguments = {
  4985. {
  4986. name = "name",
  4987. type = "string",
  4988. description = "The name of an animation."
  4989. },
  4990. {
  4991. name = "channel",
  4992. type = "number",
  4993. description = "The index of a channel in the animation."
  4994. }
  4995. },
  4996. returns = {
  4997. {
  4998. name = "node",
  4999. type = "number",
  5000. description = "The index of the node targeted by the channel."
  5001. }
  5002. }
  5003. }
  5004. }
  5005. },
  5006. {
  5007. name = "getAnimationProperty",
  5008. summary = "Get the property targeted by the channel of an animation.",
  5009. description = "Returns the property targeted by an animation's channel.",
  5010. key = "ModelData:getAnimationProperty",
  5011. module = "lovr.data",
  5012. related = {
  5013. "ModelData:getAnimationNode",
  5014. "ModelData:getAnimationSmoothMode"
  5015. },
  5016. variants = {
  5017. {
  5018. arguments = {
  5019. {
  5020. name = "index",
  5021. type = "number",
  5022. description = "The index of an animation."
  5023. },
  5024. {
  5025. name = "channel",
  5026. type = "number",
  5027. description = "The index of a channel in the animation."
  5028. }
  5029. },
  5030. returns = {
  5031. {
  5032. name = "property",
  5033. type = "AnimationProperty",
  5034. description = "The property (translation, rotation, scale, weights) affected by the keyframes."
  5035. }
  5036. }
  5037. },
  5038. {
  5039. arguments = {
  5040. {
  5041. name = "name",
  5042. type = "string",
  5043. description = "The name of an animation."
  5044. },
  5045. {
  5046. name = "channel",
  5047. type = "number",
  5048. description = "The index of a channel in the animation."
  5049. }
  5050. },
  5051. returns = {
  5052. {
  5053. name = "property",
  5054. type = "AnimationProperty",
  5055. description = "The property (translation, rotation, scale, weights) affected by the keyframes."
  5056. }
  5057. }
  5058. }
  5059. }
  5060. },
  5061. {
  5062. name = "getAnimationSmoothMode",
  5063. summary = "Get the smooth mode of a channel in an animation.",
  5064. description = "Returns the smooth mode of a channel in an animation.",
  5065. key = "ModelData:getAnimationSmoothMode",
  5066. module = "lovr.data",
  5067. related = {
  5068. "ModelData:getAnimationNode",
  5069. "ModelData:getAnimationProperty"
  5070. },
  5071. variants = {
  5072. {
  5073. arguments = {
  5074. {
  5075. name = "index",
  5076. type = "number",
  5077. description = "The index of an animation."
  5078. },
  5079. {
  5080. name = "channel",
  5081. type = "number",
  5082. description = "The index of a channel in the animation."
  5083. }
  5084. },
  5085. returns = {
  5086. {
  5087. name = "smooth",
  5088. type = "SmoothMode",
  5089. description = "The smooth mode of the keyframes."
  5090. }
  5091. }
  5092. },
  5093. {
  5094. arguments = {
  5095. {
  5096. name = "name",
  5097. type = "string",
  5098. description = "The name of an animation."
  5099. },
  5100. {
  5101. name = "channel",
  5102. type = "number",
  5103. description = "The index of a channel in the animation."
  5104. }
  5105. },
  5106. returns = {
  5107. {
  5108. name = "smooth",
  5109. type = "SmoothMode",
  5110. description = "The smooth mode of the keyframes."
  5111. }
  5112. }
  5113. }
  5114. }
  5115. },
  5116. {
  5117. name = "getBlendShapeCount",
  5118. summary = "Get the number of blend shapes in the model.",
  5119. description = "Returns the number of blend shapes in the model.",
  5120. key = "ModelData:getBlendShapeCount",
  5121. module = "lovr.data",
  5122. related = {
  5123. "ModelData:getBlendShapeName",
  5124. "Model:getBlendShapeCount"
  5125. },
  5126. variants = {
  5127. {
  5128. arguments = {},
  5129. returns = {
  5130. {
  5131. name = "count",
  5132. type = "number",
  5133. description = "The number of blend shapes in the model."
  5134. }
  5135. }
  5136. }
  5137. }
  5138. },
  5139. {
  5140. name = "getBlendShapeName",
  5141. summary = "Get the name of a blend shape in the model.",
  5142. description = "Returns the name of a blend shape in the model.",
  5143. key = "ModelData:getBlendShapeName",
  5144. module = "lovr.data",
  5145. notes = "This function will throw an error if the blend shape index is invalid.",
  5146. related = {
  5147. "ModelData:getBlendShapeCount",
  5148. "Model:getBlendShapeName"
  5149. },
  5150. variants = {
  5151. {
  5152. arguments = {
  5153. {
  5154. name = "index",
  5155. type = "number",
  5156. description = "The index of a blend shape."
  5157. }
  5158. },
  5159. returns = {
  5160. {
  5161. name = "name",
  5162. type = "string",
  5163. description = "The name of the blend shape."
  5164. }
  5165. }
  5166. }
  5167. }
  5168. },
  5169. {
  5170. name = "getBlob",
  5171. summary = "Get a Blob in the model.",
  5172. description = "Returns one of the Blobs in the model, by index.",
  5173. key = "ModelData:getBlob",
  5174. module = "lovr.data",
  5175. related = {
  5176. "ModelData:getBlobCount",
  5177. "ModelData:getImage"
  5178. },
  5179. variants = {
  5180. {
  5181. arguments = {
  5182. {
  5183. name = "index",
  5184. type = "number",
  5185. description = "The index of the Blob to get."
  5186. }
  5187. },
  5188. returns = {
  5189. {
  5190. name = "blob",
  5191. type = "Blob",
  5192. description = "The Blob object."
  5193. }
  5194. }
  5195. }
  5196. }
  5197. },
  5198. {
  5199. name = "getBlobCount",
  5200. summary = "Get the number of Blobs stored in the model.",
  5201. description = "Returns the number of Blobs in the model.",
  5202. key = "ModelData:getBlobCount",
  5203. module = "lovr.data",
  5204. related = {
  5205. "ModelData:getBlob",
  5206. "ModelData:getImageCount"
  5207. },
  5208. variants = {
  5209. {
  5210. arguments = {},
  5211. returns = {
  5212. {
  5213. name = "count",
  5214. type = "number",
  5215. description = "The number of Blobs in the model."
  5216. }
  5217. }
  5218. }
  5219. }
  5220. },
  5221. {
  5222. name = "getBoundingBox",
  5223. summary = "Get the bounding box of the model.",
  5224. description = "Returns the 6 values of the model's axis-aligned bounding box.",
  5225. key = "ModelData:getBoundingBox",
  5226. module = "lovr.data",
  5227. related = {
  5228. "ModelData:getWidth",
  5229. "ModelData:getHeight",
  5230. "ModelData:getDepth",
  5231. "ModelData:getDimensions",
  5232. "ModelData:getCenter",
  5233. "ModelData:getBoundingSphere",
  5234. "Model:getBoundingBox"
  5235. },
  5236. variants = {
  5237. {
  5238. arguments = {},
  5239. returns = {
  5240. {
  5241. name = "minx",
  5242. type = "number",
  5243. description = "The minimum x coordinate of the vertices in the model."
  5244. },
  5245. {
  5246. name = "maxx",
  5247. type = "number",
  5248. description = "The maximum x coordinate of the vertices in the model."
  5249. },
  5250. {
  5251. name = "miny",
  5252. type = "number",
  5253. description = "The minimum y coordinate of the vertices in the model."
  5254. },
  5255. {
  5256. name = "maxy",
  5257. type = "number",
  5258. description = "The maximum y coordinate of the vertices in the model."
  5259. },
  5260. {
  5261. name = "minz",
  5262. type = "number",
  5263. description = "The minimum z coordinate of the vertices in the model."
  5264. },
  5265. {
  5266. name = "maxz",
  5267. type = "number",
  5268. description = "The maximum z coordinate of the vertices in the model."
  5269. }
  5270. }
  5271. }
  5272. }
  5273. },
  5274. {
  5275. name = "getBoundingSphere",
  5276. summary = "Get the bounding sphere of the model.",
  5277. description = "Returns a sphere approximately enclosing the vertices in the model.",
  5278. key = "ModelData:getBoundingSphere",
  5279. module = "lovr.data",
  5280. related = {
  5281. "ModelData:getWidth",
  5282. "ModelData:getHeight",
  5283. "ModelData:getDepth",
  5284. "ModelData:getDimensions",
  5285. "ModelData:getCenter",
  5286. "ModelData:getBoundingBox",
  5287. "Model:getBoundingSphere"
  5288. },
  5289. variants = {
  5290. {
  5291. arguments = {},
  5292. returns = {
  5293. {
  5294. name = "x",
  5295. type = "number",
  5296. description = "The x coordinate of the position of the sphere."
  5297. },
  5298. {
  5299. name = "y",
  5300. type = "number",
  5301. description = "The y coordinate of the position of the sphere."
  5302. },
  5303. {
  5304. name = "z",
  5305. type = "number",
  5306. description = "The z coordinate of the position of the sphere."
  5307. },
  5308. {
  5309. name = "radius",
  5310. type = "number",
  5311. description = "The radius of the bounding sphere."
  5312. }
  5313. }
  5314. }
  5315. }
  5316. },
  5317. {
  5318. name = "getCenter",
  5319. summary = "Get the center of the model's bounding box.",
  5320. description = "Returns the center of the model's axis-aligned bounding box, relative to the model's origin.",
  5321. key = "ModelData:getCenter",
  5322. module = "lovr.data",
  5323. related = {
  5324. "ModelData:getWidth",
  5325. "ModelData:getHeight",
  5326. "ModelData:getDepth",
  5327. "ModelData:getDimensions",
  5328. "ModelData:getBoundingBox",
  5329. "Model:getCenter"
  5330. },
  5331. variants = {
  5332. {
  5333. arguments = {},
  5334. returns = {
  5335. {
  5336. name = "x",
  5337. type = "number",
  5338. description = "The x offset of the center of the bounding box."
  5339. },
  5340. {
  5341. name = "y",
  5342. type = "number",
  5343. description = "The y offset of the center of the bounding box."
  5344. },
  5345. {
  5346. name = "z",
  5347. type = "number",
  5348. description = "The z offset of the center of the bounding box."
  5349. }
  5350. }
  5351. }
  5352. }
  5353. },
  5354. {
  5355. name = "getDepth",
  5356. summary = "Get the depth of the model.",
  5357. description = "Returns the depth of the model, computed from its axis-aligned bounding box.",
  5358. key = "ModelData:getDepth",
  5359. module = "lovr.data",
  5360. related = {
  5361. "ModelData:getWidth",
  5362. "ModelData:getHeight",
  5363. "ModelData:getDimensions",
  5364. "ModelData:getCenter",
  5365. "ModelData:getBoundingBox",
  5366. "Model:getDepth"
  5367. },
  5368. variants = {
  5369. {
  5370. arguments = {},
  5371. returns = {
  5372. {
  5373. name = "depth",
  5374. type = "number",
  5375. description = "The depth of the model."
  5376. }
  5377. }
  5378. }
  5379. }
  5380. },
  5381. {
  5382. name = "getDimensions",
  5383. summary = "Get the dimensions of the model.",
  5384. description = "Returns the width, height, and depth of the model, computed from its axis-aligned bounding box.",
  5385. key = "ModelData:getDimensions",
  5386. module = "lovr.data",
  5387. related = {
  5388. "ModelData:getWidth",
  5389. "ModelData:getHeight",
  5390. "ModelData:getDepth",
  5391. "ModelData:getCenter",
  5392. "ModelData:getBoundingBox",
  5393. "Model:getDimensions"
  5394. },
  5395. variants = {
  5396. {
  5397. arguments = {},
  5398. returns = {
  5399. {
  5400. name = "width",
  5401. type = "number",
  5402. description = "The width of the model."
  5403. },
  5404. {
  5405. name = "height",
  5406. type = "number",
  5407. description = "The height of the model."
  5408. },
  5409. {
  5410. name = "depth",
  5411. type = "number",
  5412. description = "The depth of the model."
  5413. }
  5414. }
  5415. }
  5416. }
  5417. },
  5418. {
  5419. name = "getHeight",
  5420. summary = "Get the height of the model.",
  5421. description = "Returns the height of the model, computed from its axis-aligned bounding box.",
  5422. key = "ModelData:getHeight",
  5423. module = "lovr.data",
  5424. related = {
  5425. "ModelData:getWidth",
  5426. "ModelData:getDepth",
  5427. "ModelData:getDimensions",
  5428. "ModelData:getCenter",
  5429. "ModelData:getBoundingBox",
  5430. "Model:getHeight"
  5431. },
  5432. variants = {
  5433. {
  5434. arguments = {},
  5435. returns = {
  5436. {
  5437. name = "height",
  5438. type = "number",
  5439. description = "The height of the model."
  5440. }
  5441. }
  5442. }
  5443. }
  5444. },
  5445. {
  5446. name = "getImage",
  5447. summary = "Get an Image in the model.",
  5448. description = "Returns one of the Images in the model, by index.",
  5449. key = "ModelData:getImage",
  5450. module = "lovr.data",
  5451. related = {
  5452. "ModelData:getImageCount",
  5453. "ModelData:getBlob"
  5454. },
  5455. variants = {
  5456. {
  5457. arguments = {
  5458. {
  5459. name = "index",
  5460. type = "number",
  5461. description = "The index of the Image to get."
  5462. }
  5463. },
  5464. returns = {
  5465. {
  5466. name = "image",
  5467. type = "Image",
  5468. description = "The Image object."
  5469. }
  5470. }
  5471. }
  5472. }
  5473. },
  5474. {
  5475. name = "getImageCount",
  5476. summary = "Get the number of Images stored in the model.",
  5477. description = "Returns the number of Images in the model.",
  5478. key = "ModelData:getImageCount",
  5479. module = "lovr.data",
  5480. related = {
  5481. "ModelData:getImage",
  5482. "ModelData:getBlobCount"
  5483. },
  5484. variants = {
  5485. {
  5486. arguments = {},
  5487. returns = {
  5488. {
  5489. name = "count",
  5490. type = "number",
  5491. description = "The number of Images in the model."
  5492. }
  5493. }
  5494. }
  5495. }
  5496. },
  5497. {
  5498. name = "getMaterial",
  5499. summary = "Get the material properties for a material in the model.",
  5500. description = "Returns a table with all of the properties of a material.",
  5501. key = "ModelData:getMaterial",
  5502. module = "lovr.data",
  5503. notes = "All images are optional and may be `nil`.",
  5504. related = {
  5505. "ModelData:getMaterialCount",
  5506. "ModelData:getMeshMaterial",
  5507. "lovr.graphics.newMaterial",
  5508. "Model:getMaterial"
  5509. },
  5510. variants = {
  5511. {
  5512. arguments = {
  5513. {
  5514. name = "index",
  5515. type = "number",
  5516. description = "The index of a material."
  5517. }
  5518. },
  5519. returns = {
  5520. {
  5521. name = "properties",
  5522. type = "table",
  5523. description = "The material properties.",
  5524. table = {
  5525. {
  5526. name = "color",
  5527. type = "table",
  5528. description = "The color of the material. The table contains the `r`, `g`, `b`, and `a` components of the color, from 0 to 1."
  5529. },
  5530. {
  5531. name = "glow",
  5532. type = "table",
  5533. description = "The glow color of the material (sometimes called emissive). The table contains the `r`, `g`, and `b` components of the color from 0 to 1, and a fourth number indicating the strength of the glow."
  5534. },
  5535. {
  5536. name = "uvShift",
  5537. type = "table",
  5538. description = "A table with 2 numbers indicating an offset to apply to UVs."
  5539. },
  5540. {
  5541. name = "uvScale",
  5542. type = "table",
  5543. description = "A table with 2 numbers indicating a scale to apply to UVs. By default, shaders apply the UV scale before the UV offset."
  5544. },
  5545. {
  5546. name = "metalness",
  5547. type = "number",
  5548. description = "The metalness parameter of the material. This is typically 0 or 1. By default, shaders multiply this property with the value from the metalness texture (when present) to get the final metalness used for shading."
  5549. },
  5550. {
  5551. name = "roughness",
  5552. type = "number",
  5553. description = "The roughness parameter of the material. By default, shaders multiply this property with the value from the roughness texture (when present) to get the final roughness used for shading."
  5554. },
  5555. {
  5556. name = "clearcoat",
  5557. type = "number",
  5558. description = "The clearcoat parameter of the material."
  5559. },
  5560. {
  5561. name = "clearcoatRoughness",
  5562. type = "number",
  5563. description = "The roughness of the clearcoat layer."
  5564. },
  5565. {
  5566. name = "occlusionStrength",
  5567. type = "number",
  5568. description = "A number multiplied by the value from the ambient occlusion texture to control how strong the occlusion effect is."
  5569. },
  5570. {
  5571. name = "normalScale",
  5572. type = "number",
  5573. description = "A number multiplied by the value from the normal texture to control how strong the normal mapping effect is."
  5574. },
  5575. {
  5576. name = "alphaCutoff",
  5577. type = "number",
  5578. description = "If a pixel has an alpha value less than the alpha cutoff, it will be discarded, which prevents it from occluding things behind it. This is sometimes called \"holepunch\" or \"cutout\" alpha. It's useful for textures with transparency."
  5579. },
  5580. {
  5581. name = "texture",
  5582. type = "number",
  5583. description = "The index of the Image used for the color texture."
  5584. },
  5585. {
  5586. name = "glowTexture",
  5587. type = "number",
  5588. description = "The index of the Image used for the glow texture."
  5589. },
  5590. {
  5591. name = "occlusionTexture",
  5592. type = "number",
  5593. description = "The index of the Image used for the ambient occlusion texture. The red channel of the texture is used for ambient occlusion, allowing multiple parameters to use the same texture."
  5594. },
  5595. {
  5596. name = "metalnessTexture",
  5597. type = "number",
  5598. description = "The index of the Image used for the metalness texture. The blue channel of the texture is used for metalness, allowing multiple parameters to use the same texture."
  5599. },
  5600. {
  5601. name = "roughnessTexture",
  5602. type = "number",
  5603. description = "The index of the Image to use for the roughness texture. The green channel of the texture is used for roughness, allowing multiple parameters to use the same texture."
  5604. },
  5605. {
  5606. name = "clearcoatTexture",
  5607. type = "number",
  5608. description = "The index of the Image to use for the clearcoat texture. The red channel of the texture is used for the clearcoat parameter, allowing multiple parameters to use the same texture."
  5609. },
  5610. {
  5611. name = "normalTexture",
  5612. type = "number",
  5613. description = "The index of the Image to use for the normal map."
  5614. }
  5615. }
  5616. }
  5617. }
  5618. },
  5619. {
  5620. arguments = {
  5621. {
  5622. name = "name",
  5623. type = "string",
  5624. description = "The name of a material."
  5625. }
  5626. },
  5627. returns = {
  5628. {
  5629. name = "properties",
  5630. type = "table",
  5631. description = "The material properties.",
  5632. table = {
  5633. {
  5634. name = "color",
  5635. type = "table",
  5636. description = "The color of the material. The table contains the `r`, `g`, `b`, and `a` components of the color, from 0 to 1."
  5637. },
  5638. {
  5639. name = "glow",
  5640. type = "table",
  5641. description = "The glow color of the material (sometimes called emissive). The table contains the `r`, `g`, and `b` components of the color from 0 to 1, and a fourth number indicating the strength of the glow."
  5642. },
  5643. {
  5644. name = "uvShift",
  5645. type = "table",
  5646. description = "A table with 2 numbers indicating an offset to apply to UVs."
  5647. },
  5648. {
  5649. name = "uvScale",
  5650. type = "table",
  5651. description = "A table with 2 numbers indicating a scale to apply to UVs. By default, shaders apply the UV scale before the UV offset."
  5652. },
  5653. {
  5654. name = "metalness",
  5655. type = "number",
  5656. description = "The metalness parameter of the material. This is typically 0 or 1. By default, shaders multiply this property with the value from the metalness texture (when present) to get the final metalness used for shading."
  5657. },
  5658. {
  5659. name = "roughness",
  5660. type = "number",
  5661. description = "The roughness parameter of the material. By default, shaders multiply this property with the value from the roughness texture (when present) to get the final roughness used for shading."
  5662. },
  5663. {
  5664. name = "clearcoat",
  5665. type = "number",
  5666. description = "The clearcoat parameter of the material."
  5667. },
  5668. {
  5669. name = "clearcoatRoughness",
  5670. type = "number",
  5671. description = "The roughness of the clearcoat layer."
  5672. },
  5673. {
  5674. name = "occlusionStrength",
  5675. type = "number",
  5676. description = "A number multiplied by the value from the ambient occlusion texture to control how strong the occlusion effect is."
  5677. },
  5678. {
  5679. name = "normalScale",
  5680. type = "number",
  5681. description = "A number multiplied by the value from the normal texture to control how strong the normal mapping effect is."
  5682. },
  5683. {
  5684. name = "alphaCutoff",
  5685. type = "number",
  5686. description = "If a pixel has an alpha value less than the alpha cutoff, it will be discarded, which prevents it from occluding things behind it. This is sometimes called \"holepunch\" or \"cutout\" alpha. It's useful for textures with transparency."
  5687. },
  5688. {
  5689. name = "texture",
  5690. type = "number",
  5691. description = "The index of the Image used for the color texture."
  5692. },
  5693. {
  5694. name = "glowTexture",
  5695. type = "number",
  5696. description = "The index of the Image used for the glow texture."
  5697. },
  5698. {
  5699. name = "occlusionTexture",
  5700. type = "number",
  5701. description = "The index of the Image used for the ambient occlusion texture. The red channel of the texture is used for ambient occlusion, allowing multiple parameters to use the same texture."
  5702. },
  5703. {
  5704. name = "metalnessTexture",
  5705. type = "number",
  5706. description = "The index of the Image used for the metalness texture. The blue channel of the texture is used for metalness, allowing multiple parameters to use the same texture."
  5707. },
  5708. {
  5709. name = "roughnessTexture",
  5710. type = "number",
  5711. description = "The index of the Image to use for the roughness texture. The green channel of the texture is used for roughness, allowing multiple parameters to use the same texture."
  5712. },
  5713. {
  5714. name = "clearcoatTexture",
  5715. type = "number",
  5716. description = "The index of the Image to use for the clearcoat texture. The red channel of the texture is used for the clearcoat parameter, allowing multiple parameters to use the same texture."
  5717. },
  5718. {
  5719. name = "normalTexture",
  5720. type = "number",
  5721. description = "The index of the Image to use for the normal map."
  5722. }
  5723. }
  5724. }
  5725. }
  5726. }
  5727. }
  5728. },
  5729. {
  5730. name = "getMaterialCount",
  5731. summary = "Get the number of materials in the model.",
  5732. description = "Returns the number of materials in the model.",
  5733. key = "ModelData:getMaterialCount",
  5734. module = "lovr.data",
  5735. related = {
  5736. "ModelData:getMaterialName",
  5737. "ModelData:getMeshMaterial",
  5738. "ModelData:getMaterial",
  5739. "Model:getMaterialCount"
  5740. },
  5741. variants = {
  5742. {
  5743. arguments = {},
  5744. returns = {
  5745. {
  5746. name = "count",
  5747. type = "number",
  5748. description = "The number of materials in the model."
  5749. }
  5750. }
  5751. }
  5752. }
  5753. },
  5754. {
  5755. name = "getMaterialName",
  5756. summary = "Get the name of a material in the model.",
  5757. description = "Returns the name of a material in the model.",
  5758. key = "ModelData:getMaterialName",
  5759. module = "lovr.data",
  5760. related = {
  5761. "ModelData:getMaterialCount",
  5762. "ModelData:getMeshMaterial",
  5763. "ModelData:getMaterial",
  5764. "Model:getMaterialName"
  5765. },
  5766. variants = {
  5767. {
  5768. arguments = {
  5769. {
  5770. name = "index",
  5771. type = "number",
  5772. description = "The index of a material."
  5773. }
  5774. },
  5775. returns = {
  5776. {
  5777. name = "name",
  5778. type = "string",
  5779. description = "The name of the material, or nil if the material does not have a name."
  5780. }
  5781. }
  5782. }
  5783. }
  5784. },
  5785. {
  5786. name = "getMeshCount",
  5787. summary = "Get the number of meshes in the model.",
  5788. description = "Returns the number of meshes in the model.",
  5789. key = "ModelData:getMeshCount",
  5790. module = "lovr.data",
  5791. related = {
  5792. "ModelData:getNodeMeshes"
  5793. },
  5794. variants = {
  5795. {
  5796. arguments = {},
  5797. returns = {
  5798. {
  5799. name = "count",
  5800. type = "number",
  5801. description = "The number of meshes in the model."
  5802. }
  5803. }
  5804. }
  5805. }
  5806. },
  5807. {
  5808. name = "getMeshDrawMode",
  5809. summary = "Get the draw mode of a mesh.",
  5810. description = "Returns the draw mode of a mesh. This controls how its vertices are connected together (points, lines, or triangles).",
  5811. key = "ModelData:getMeshDrawMode",
  5812. module = "lovr.data",
  5813. variants = {
  5814. {
  5815. arguments = {
  5816. {
  5817. name = "mesh",
  5818. type = "number",
  5819. description = "The index of a mesh."
  5820. }
  5821. },
  5822. returns = {
  5823. {
  5824. name = "mode",
  5825. type = "ModelDrawMode",
  5826. description = "The draw mode of the mesh."
  5827. }
  5828. }
  5829. }
  5830. }
  5831. },
  5832. {
  5833. name = "getMeshIndex",
  5834. summary = "Get one of the vertex indices in a mesh.",
  5835. description = "Returns one of the vertex indices in a mesh. If a mesh has vertex indices, they define the order and connectivity of the vertices in the mesh, allowing a vertex to be reused multiple times without duplicating its data.",
  5836. key = "ModelData:getMeshIndex",
  5837. module = "lovr.data",
  5838. related = {
  5839. "ModelData:getMeshIndexFormat",
  5840. "ModelData:getMeshIndexCount",
  5841. "ModelData:getMeshVertex",
  5842. "ModelData:getTriangles"
  5843. },
  5844. variants = {
  5845. {
  5846. arguments = {
  5847. {
  5848. name = "mesh",
  5849. type = "number",
  5850. description = "The index of a mesh to get the vertex from."
  5851. },
  5852. {
  5853. name = "index",
  5854. type = "number",
  5855. description = "The index of a vertex index in the mesh to retrieve."
  5856. }
  5857. },
  5858. returns = {
  5859. {
  5860. name = "vertexindex",
  5861. type = "number",
  5862. description = "The vertex index. Like all indices in Lua, this is 1-indexed."
  5863. }
  5864. }
  5865. }
  5866. }
  5867. },
  5868. {
  5869. name = "getMeshIndexCount",
  5870. summary = "Get the number of vertex indices in a mesh.",
  5871. description = "Returns the number of vertex indices in a mesh. Vertex indices allow for vertices to be reused when defining triangles.",
  5872. key = "ModelData:getMeshIndexCount",
  5873. module = "lovr.data",
  5874. notes = "This may return zero if the mesh does not use indices.",
  5875. variants = {
  5876. {
  5877. arguments = {
  5878. {
  5879. name = "mesh",
  5880. type = "number",
  5881. description = "The index of a mesh."
  5882. }
  5883. },
  5884. returns = {
  5885. {
  5886. name = "count",
  5887. type = "number",
  5888. description = "The number of vertex indices in the mesh."
  5889. }
  5890. }
  5891. }
  5892. }
  5893. },
  5894. {
  5895. name = "getMeshIndexFormat",
  5896. summary = "Get the data format of vertex indices in a mesh.",
  5897. description = "Returns the data format of vertex indices in a mesh. If a mesh doesn't use vertex indices, this function returns nil.",
  5898. key = "ModelData:getMeshIndexFormat",
  5899. module = "lovr.data",
  5900. related = {
  5901. "ModelData:getMeshVertexFormat"
  5902. },
  5903. variants = {
  5904. {
  5905. arguments = {
  5906. {
  5907. name = "mesh",
  5908. type = "number",
  5909. description = "The index of a mesh."
  5910. }
  5911. },
  5912. returns = {
  5913. {
  5914. name = "type",
  5915. type = "AttributeType",
  5916. description = "The data type of each vertex index (always u16 or u32)."
  5917. },
  5918. {
  5919. name = "blob",
  5920. type = "number",
  5921. description = "The index of a Blob in the mesh where the binary data is stored."
  5922. },
  5923. {
  5924. name = "offset",
  5925. type = "number",
  5926. description = "A byte offset into the Blob's data where the index data starts."
  5927. },
  5928. {
  5929. name = "stride",
  5930. type = "number",
  5931. description = "The number of bytes between subsequent vertex indices. Indices are always tightly packed, so this will always be 2 or 4 depending on the data type."
  5932. }
  5933. }
  5934. }
  5935. }
  5936. },
  5937. {
  5938. name = "getMeshMaterial",
  5939. summary = "Get the index of the material applied to a mesh.",
  5940. description = "Returns the index of the material applied to a mesh.",
  5941. key = "ModelData:getMeshMaterial",
  5942. module = "lovr.data",
  5943. variants = {
  5944. {
  5945. arguments = {
  5946. {
  5947. name = "mesh",
  5948. type = "number",
  5949. description = "The index of a mesh."
  5950. }
  5951. },
  5952. returns = {
  5953. {
  5954. name = "material",
  5955. type = "number",
  5956. description = "The index of the material applied to the mesh, or nil if the mesh does not have a material."
  5957. }
  5958. }
  5959. }
  5960. }
  5961. },
  5962. {
  5963. name = "getMeshVertex",
  5964. summary = "Get the data for a single vertex in a mesh.",
  5965. description = "Returns the data for a single vertex in a mesh. The data returned depends on the vertex format of a mesh, which is given by `ModelData:getMeshVertexFormat`.",
  5966. key = "ModelData:getMeshVertex",
  5967. module = "lovr.data",
  5968. related = {
  5969. "ModelData:getMeshVertexFormat",
  5970. "ModelData:getMeshVertexCount",
  5971. "ModelData:getMeshIndex",
  5972. "ModelData:getTriangles"
  5973. },
  5974. variants = {
  5975. {
  5976. arguments = {
  5977. {
  5978. name = "mesh",
  5979. type = "number",
  5980. description = "The index of a mesh to get the vertex from."
  5981. },
  5982. {
  5983. name = "vertex",
  5984. type = "number",
  5985. description = "The index of a vertex in the mesh to retrieve."
  5986. }
  5987. },
  5988. returns = {
  5989. {
  5990. name = "...",
  5991. type = "number",
  5992. description = "The data for all of the attributes of the vertex."
  5993. }
  5994. }
  5995. }
  5996. }
  5997. },
  5998. {
  5999. name = "getMeshVertexCount",
  6000. summary = "Get the number of vertices in a mesh.",
  6001. description = "Returns the number of vertices in a mesh.",
  6002. key = "ModelData:getMeshVertexCount",
  6003. module = "lovr.data",
  6004. related = {
  6005. "ModelData:getMeshIndexCount"
  6006. },
  6007. variants = {
  6008. {
  6009. arguments = {
  6010. {
  6011. name = "mesh",
  6012. type = "number",
  6013. description = "The index of a mesh."
  6014. }
  6015. },
  6016. returns = {
  6017. {
  6018. name = "count",
  6019. type = "number",
  6020. description = "The number of vertices in the mesh."
  6021. }
  6022. }
  6023. }
  6024. }
  6025. },
  6026. {
  6027. name = "getMeshVertexFormat",
  6028. summary = "Get the vertex format of a mesh.",
  6029. description = "Returns the vertex format of a mesh. The vertex format defines the properties associated with each vertex (position, color, etc.), including their types and binary data layout.",
  6030. key = "ModelData:getMeshVertexFormat",
  6031. module = "lovr.data",
  6032. notes = "The format is given as a table of vertex attributes. Each attribute is a table containing the following:\n\n { name, type, components, blob, offset, stride }\n\n- The `name` will be a `DefaultAttribute`.\n- The `type` will be an `AttributeType`.\n- The `component` count will be 1-4.\n- The `blob` is an index of one of the Blobs in the model (see `ModelData:getBlob`).\n- The `offset` is a byte offset from the start of the Blob where the attribute's data starts.\n- The `stride` is the number of bytes between consecutive values.",
  6033. related = {
  6034. "ModelData:getMeshIndexFormat"
  6035. },
  6036. variants = {
  6037. {
  6038. arguments = {
  6039. {
  6040. name = "mesh",
  6041. type = "number",
  6042. description = "The index of a mesh."
  6043. }
  6044. },
  6045. returns = {
  6046. {
  6047. name = "format",
  6048. type = "table",
  6049. description = "The vertex format of the mesh."
  6050. }
  6051. }
  6052. }
  6053. }
  6054. },
  6055. {
  6056. name = "getMetadata",
  6057. summary = "Get extra information from the model file.",
  6058. description = "Returns extra information stored in the model file. Currently this is only implemented for glTF models and returns the JSON string from the glTF or glb file. The metadata can be used to get application-specific data or add support for glTF extensions not supported by LÖVR.",
  6059. key = "ModelData:getMetadata",
  6060. module = "lovr.data",
  6061. related = {
  6062. "Model:getMetadata"
  6063. },
  6064. variants = {
  6065. {
  6066. arguments = {},
  6067. returns = {
  6068. {
  6069. name = "metadata",
  6070. type = "string",
  6071. description = "The metadata from the model file."
  6072. }
  6073. }
  6074. }
  6075. }
  6076. },
  6077. {
  6078. name = "getNodeChildren",
  6079. summary = "Get the children of a node.",
  6080. description = "Given a parent node, this function returns a table with the indices of its children.",
  6081. key = "ModelData:getNodeChildren",
  6082. module = "lovr.data",
  6083. notes = "If the node does not have any children, this function returns an empty table.",
  6084. related = {
  6085. "ModelData:getNodeParent",
  6086. "ModelData:getRootNode",
  6087. "Model:getNodeChildren"
  6088. },
  6089. variants = {
  6090. {
  6091. arguments = {
  6092. {
  6093. name = "index",
  6094. type = "number",
  6095. description = "The index of the parent node."
  6096. }
  6097. },
  6098. returns = {
  6099. {
  6100. name = "children",
  6101. type = "table",
  6102. description = "A table containing a node index for each child of the node."
  6103. }
  6104. }
  6105. },
  6106. {
  6107. arguments = {
  6108. {
  6109. name = "name",
  6110. type = "string",
  6111. description = "The name of the parent node."
  6112. }
  6113. },
  6114. returns = {
  6115. {
  6116. name = "children",
  6117. type = "table",
  6118. description = "A table containing a node index for each child of the node."
  6119. }
  6120. }
  6121. }
  6122. }
  6123. },
  6124. {
  6125. name = "getNodeCount",
  6126. summary = "Get the number of nodes in the model.",
  6127. description = "Returns the number of nodes in the model.",
  6128. key = "ModelData:getNodeCount",
  6129. module = "lovr.data",
  6130. related = {
  6131. "Model:getNodeCount"
  6132. },
  6133. variants = {
  6134. {
  6135. arguments = {},
  6136. returns = {
  6137. {
  6138. name = "count",
  6139. type = "number",
  6140. description = "The number of nodes in the model."
  6141. }
  6142. }
  6143. }
  6144. }
  6145. },
  6146. {
  6147. name = "getNodeMeshes",
  6148. summary = "Get the indices of meshes attached to a node.",
  6149. description = "Returns a table of mesh indices attached to a node. Meshes define the geometry and materials of a model, as opposed to the nodes which define the transforms and hierarchy. A node can have multiple meshes, and meshes can be reused in multiple nodes.",
  6150. key = "ModelData:getNodeMeshes",
  6151. module = "lovr.data",
  6152. related = {
  6153. "ModelData:getMeshCount"
  6154. },
  6155. variants = {
  6156. {
  6157. arguments = {
  6158. {
  6159. name = "index",
  6160. type = "number",
  6161. description = "The index of the node."
  6162. }
  6163. },
  6164. returns = {
  6165. {
  6166. name = "meshes",
  6167. type = "table",
  6168. description = "A table with the node's mesh indices."
  6169. }
  6170. }
  6171. },
  6172. {
  6173. arguments = {
  6174. {
  6175. name = "name",
  6176. type = "string",
  6177. description = "The name of the node."
  6178. }
  6179. },
  6180. returns = {
  6181. {
  6182. name = "meshes",
  6183. type = "table",
  6184. description = "A table with the node's mesh indices."
  6185. }
  6186. }
  6187. }
  6188. }
  6189. },
  6190. {
  6191. name = "getNodeName",
  6192. summary = "Get the name of a node.",
  6193. description = "Returns the name of a node.",
  6194. key = "ModelData:getNodeName",
  6195. module = "lovr.data",
  6196. notes = "If the node does not have a name, this function returns `nil`.",
  6197. related = {
  6198. "Model:getNodeName"
  6199. },
  6200. variants = {
  6201. {
  6202. arguments = {
  6203. {
  6204. name = "index",
  6205. type = "number",
  6206. description = "The index of the node."
  6207. }
  6208. },
  6209. returns = {
  6210. {
  6211. name = "name",
  6212. type = "string",
  6213. description = "The name of the node."
  6214. }
  6215. }
  6216. }
  6217. }
  6218. },
  6219. {
  6220. name = "getNodeOrientation",
  6221. summary = "Get the local orientation of a node.",
  6222. description = "Returns local orientation of a node, relative to its parent.",
  6223. key = "ModelData:getNodeOrientation",
  6224. module = "lovr.data",
  6225. related = {
  6226. "ModelData:getNodePosition",
  6227. "ModelData:getNodeScale",
  6228. "ModelData:getNodePose",
  6229. "ModelData:getNodeTransform"
  6230. },
  6231. variants = {
  6232. {
  6233. arguments = {
  6234. {
  6235. name = "index",
  6236. type = "number",
  6237. description = "The index of the node."
  6238. }
  6239. },
  6240. returns = {
  6241. {
  6242. name = "angle",
  6243. type = "number",
  6244. description = "The number of radians the node is rotated around its axis of rotation."
  6245. },
  6246. {
  6247. name = "ax",
  6248. type = "number",
  6249. description = "The x component of the axis of rotation."
  6250. },
  6251. {
  6252. name = "ay",
  6253. type = "number",
  6254. description = "The y component of the axis of rotation."
  6255. },
  6256. {
  6257. name = "az",
  6258. type = "number",
  6259. description = "The z component of the axis of rotation."
  6260. }
  6261. }
  6262. },
  6263. {
  6264. arguments = {
  6265. {
  6266. name = "name",
  6267. type = "string",
  6268. description = "The name of the node."
  6269. }
  6270. },
  6271. returns = {
  6272. {
  6273. name = "angle",
  6274. type = "number",
  6275. description = "The number of radians the node is rotated around its axis of rotation."
  6276. },
  6277. {
  6278. name = "ax",
  6279. type = "number",
  6280. description = "The x component of the axis of rotation."
  6281. },
  6282. {
  6283. name = "ay",
  6284. type = "number",
  6285. description = "The y component of the axis of rotation."
  6286. },
  6287. {
  6288. name = "az",
  6289. type = "number",
  6290. description = "The z component of the axis of rotation."
  6291. }
  6292. }
  6293. }
  6294. }
  6295. },
  6296. {
  6297. name = "getNodeParent",
  6298. summary = "Get the parent of a node.",
  6299. description = "Given a child node, this function returns the index of its parent.",
  6300. key = "ModelData:getNodeParent",
  6301. module = "lovr.data",
  6302. related = {
  6303. "ModelData:getNodeChildren",
  6304. "ModelData:getRootNode",
  6305. "Model:getNodeParent"
  6306. },
  6307. variants = {
  6308. {
  6309. arguments = {
  6310. {
  6311. name = "index",
  6312. type = "number",
  6313. description = "The index of the child node."
  6314. }
  6315. },
  6316. returns = {
  6317. {
  6318. name = "parent",
  6319. type = "number",
  6320. description = "The index of the parent."
  6321. }
  6322. }
  6323. },
  6324. {
  6325. arguments = {
  6326. {
  6327. name = "name",
  6328. type = "string",
  6329. description = "The name of the child node."
  6330. }
  6331. },
  6332. returns = {
  6333. {
  6334. name = "parent",
  6335. type = "number",
  6336. description = "The index of the parent."
  6337. }
  6338. }
  6339. }
  6340. }
  6341. },
  6342. {
  6343. name = "getNodePose",
  6344. summary = "Get the local pose of a node.",
  6345. description = "Returns local pose (position and orientation) of a node, relative to its parent.",
  6346. key = "ModelData:getNodePose",
  6347. module = "lovr.data",
  6348. related = {
  6349. "ModelData:getNodePosition",
  6350. "ModelData:getNodeOrientation",
  6351. "ModelData:getNodeScale",
  6352. "ModelData:getNodeTransform"
  6353. },
  6354. variants = {
  6355. {
  6356. arguments = {
  6357. {
  6358. name = "index",
  6359. type = "number",
  6360. description = "The index of the node."
  6361. }
  6362. },
  6363. returns = {
  6364. {
  6365. name = "x",
  6366. type = "number",
  6367. description = "The x coordinate."
  6368. },
  6369. {
  6370. name = "y",
  6371. type = "number",
  6372. description = "The y coordinate."
  6373. },
  6374. {
  6375. name = "z",
  6376. type = "number",
  6377. description = "The z coordinate."
  6378. },
  6379. {
  6380. name = "angle",
  6381. type = "number",
  6382. description = "The number of radians the node is rotated around its axis of rotation."
  6383. },
  6384. {
  6385. name = "ax",
  6386. type = "number",
  6387. description = "The x component of the axis of rotation."
  6388. },
  6389. {
  6390. name = "ay",
  6391. type = "number",
  6392. description = "The y component of the axis of rotation."
  6393. },
  6394. {
  6395. name = "az",
  6396. type = "number",
  6397. description = "The z component of the axis of rotation."
  6398. }
  6399. }
  6400. },
  6401. {
  6402. arguments = {
  6403. {
  6404. name = "name",
  6405. type = "string",
  6406. description = "The name of the node."
  6407. }
  6408. },
  6409. returns = {
  6410. {
  6411. name = "x",
  6412. type = "number",
  6413. description = "The x coordinate."
  6414. },
  6415. {
  6416. name = "y",
  6417. type = "number",
  6418. description = "The y coordinate."
  6419. },
  6420. {
  6421. name = "z",
  6422. type = "number",
  6423. description = "The z coordinate."
  6424. },
  6425. {
  6426. name = "angle",
  6427. type = "number",
  6428. description = "The number of radians the node is rotated around its axis of rotation."
  6429. },
  6430. {
  6431. name = "ax",
  6432. type = "number",
  6433. description = "The x component of the axis of rotation."
  6434. },
  6435. {
  6436. name = "ay",
  6437. type = "number",
  6438. description = "The y component of the axis of rotation."
  6439. },
  6440. {
  6441. name = "az",
  6442. type = "number",
  6443. description = "The z component of the axis of rotation."
  6444. }
  6445. }
  6446. }
  6447. }
  6448. },
  6449. {
  6450. name = "getNodePosition",
  6451. summary = "Get the local position of a node.",
  6452. description = "Returns local position of a node, relative to its parent.",
  6453. key = "ModelData:getNodePosition",
  6454. module = "lovr.data",
  6455. related = {
  6456. "ModelData:getNodeOrientation",
  6457. "ModelData:getNodeScale",
  6458. "ModelData:getNodePose",
  6459. "ModelData:getNodeTransform"
  6460. },
  6461. variants = {
  6462. {
  6463. arguments = {
  6464. {
  6465. name = "index",
  6466. type = "number",
  6467. description = "The index of the node."
  6468. }
  6469. },
  6470. returns = {
  6471. {
  6472. name = "x",
  6473. type = "number",
  6474. description = "The x coordinate."
  6475. },
  6476. {
  6477. name = "y",
  6478. type = "number",
  6479. description = "The y coordinate."
  6480. },
  6481. {
  6482. name = "z",
  6483. type = "number",
  6484. description = "The z coordinate."
  6485. }
  6486. }
  6487. },
  6488. {
  6489. arguments = {
  6490. {
  6491. name = "name",
  6492. type = "string",
  6493. description = "The name of the node."
  6494. }
  6495. },
  6496. returns = {
  6497. {
  6498. name = "x",
  6499. type = "number",
  6500. description = "The x coordinate."
  6501. },
  6502. {
  6503. name = "y",
  6504. type = "number",
  6505. description = "The y coordinate."
  6506. },
  6507. {
  6508. name = "z",
  6509. type = "number",
  6510. description = "The z coordinate."
  6511. }
  6512. }
  6513. }
  6514. }
  6515. },
  6516. {
  6517. name = "getNodeScale",
  6518. summary = "Get the local scale of a node.",
  6519. description = "Returns local scale of a node, relative to its parent.",
  6520. key = "ModelData:getNodeScale",
  6521. module = "lovr.data",
  6522. related = {
  6523. "ModelData:getNodePosition",
  6524. "ModelData:getNodeOrientation",
  6525. "ModelData:getNodePose",
  6526. "ModelData:getNodeTransform"
  6527. },
  6528. variants = {
  6529. {
  6530. arguments = {
  6531. {
  6532. name = "index",
  6533. type = "number",
  6534. description = "The index of the node."
  6535. }
  6536. },
  6537. returns = {
  6538. {
  6539. name = "sx",
  6540. type = "number",
  6541. description = "The x scale."
  6542. },
  6543. {
  6544. name = "sy",
  6545. type = "number",
  6546. description = "The y scale."
  6547. },
  6548. {
  6549. name = "sz",
  6550. type = "number",
  6551. description = "The z scale."
  6552. }
  6553. }
  6554. },
  6555. {
  6556. arguments = {
  6557. {
  6558. name = "name",
  6559. type = "string",
  6560. description = "The name of the node."
  6561. }
  6562. },
  6563. returns = {
  6564. {
  6565. name = "sx",
  6566. type = "number",
  6567. description = "The x scale."
  6568. },
  6569. {
  6570. name = "sy",
  6571. type = "number",
  6572. description = "The y scale."
  6573. },
  6574. {
  6575. name = "sz",
  6576. type = "number",
  6577. description = "The z scale."
  6578. }
  6579. }
  6580. }
  6581. }
  6582. },
  6583. {
  6584. name = "getNodeSkin",
  6585. summary = "Get the index of the skin used by a node.",
  6586. description = "Returns the index of the skin used by a node. Skins are collections of joints used for skeletal animation. A model can have multiple skins, and each node can use at most one skin to drive the animation of its meshes.",
  6587. key = "ModelData:getNodeSkin",
  6588. module = "lovr.data",
  6589. related = {
  6590. "ModelData:getSkinCount"
  6591. },
  6592. variants = {
  6593. {
  6594. arguments = {
  6595. {
  6596. name = "index",
  6597. type = "number",
  6598. description = "The index of the node."
  6599. }
  6600. },
  6601. returns = {
  6602. {
  6603. name = "skin",
  6604. type = "number",
  6605. description = "The index of the node's skin, or nil if the node isn't skeletally animated."
  6606. }
  6607. }
  6608. },
  6609. {
  6610. arguments = {
  6611. {
  6612. name = "name",
  6613. type = "string",
  6614. description = "The name of the node."
  6615. }
  6616. },
  6617. returns = {
  6618. {
  6619. name = "skin",
  6620. type = "number",
  6621. description = "The index of the node's skin, or nil if the node isn't skeletally animated."
  6622. }
  6623. }
  6624. }
  6625. }
  6626. },
  6627. {
  6628. name = "getNodeTransform",
  6629. summary = "Get the local transform of a node.",
  6630. description = "Returns local transform (position, orientation, and scale) of a node, relative to its parent.",
  6631. key = "ModelData:getNodeTransform",
  6632. module = "lovr.data",
  6633. notes = "For best results when animating, it's recommended to keep the 3 components of the scale the same.",
  6634. related = {
  6635. "ModelData:getNodePosition",
  6636. "ModelData:getNodeOrientation",
  6637. "ModelData:getNodeScale",
  6638. "ModelData:getNodePose"
  6639. },
  6640. variants = {
  6641. {
  6642. arguments = {
  6643. {
  6644. name = "index",
  6645. type = "number",
  6646. description = "The index of the node."
  6647. }
  6648. },
  6649. returns = {
  6650. {
  6651. name = "x",
  6652. type = "number",
  6653. description = "The x coordinate."
  6654. },
  6655. {
  6656. name = "y",
  6657. type = "number",
  6658. description = "The y coordinate."
  6659. },
  6660. {
  6661. name = "z",
  6662. type = "number",
  6663. description = "The z coordinate."
  6664. },
  6665. {
  6666. name = "sx",
  6667. type = "number",
  6668. description = "The x scale."
  6669. },
  6670. {
  6671. name = "sy",
  6672. type = "number",
  6673. description = "The y scale."
  6674. },
  6675. {
  6676. name = "sz",
  6677. type = "number",
  6678. description = "The z scale."
  6679. },
  6680. {
  6681. name = "angle",
  6682. type = "number",
  6683. description = "The number of radians the node is rotated around its axis of rotation."
  6684. },
  6685. {
  6686. name = "ax",
  6687. type = "number",
  6688. description = "The x component of the axis of rotation."
  6689. },
  6690. {
  6691. name = "ay",
  6692. type = "number",
  6693. description = "The y component of the axis of rotation."
  6694. },
  6695. {
  6696. name = "az",
  6697. type = "number",
  6698. description = "The z component of the axis of rotation."
  6699. }
  6700. }
  6701. },
  6702. {
  6703. arguments = {
  6704. {
  6705. name = "name",
  6706. type = "string",
  6707. description = "The name of the node."
  6708. }
  6709. },
  6710. returns = {
  6711. {
  6712. name = "x",
  6713. type = "number",
  6714. description = "The x coordinate."
  6715. },
  6716. {
  6717. name = "y",
  6718. type = "number",
  6719. description = "The y coordinate."
  6720. },
  6721. {
  6722. name = "z",
  6723. type = "number",
  6724. description = "The z coordinate."
  6725. },
  6726. {
  6727. name = "sx",
  6728. type = "number",
  6729. description = "The x scale."
  6730. },
  6731. {
  6732. name = "sy",
  6733. type = "number",
  6734. description = "The y scale."
  6735. },
  6736. {
  6737. name = "sz",
  6738. type = "number",
  6739. description = "The z scale."
  6740. },
  6741. {
  6742. name = "angle",
  6743. type = "number",
  6744. description = "The number of radians the node is rotated around its axis of rotation."
  6745. },
  6746. {
  6747. name = "ax",
  6748. type = "number",
  6749. description = "The x component of the axis of rotation."
  6750. },
  6751. {
  6752. name = "ay",
  6753. type = "number",
  6754. description = "The y component of the axis of rotation."
  6755. },
  6756. {
  6757. name = "az",
  6758. type = "number",
  6759. description = "The z component of the axis of rotation."
  6760. }
  6761. }
  6762. }
  6763. }
  6764. },
  6765. {
  6766. name = "getRootNode",
  6767. summary = "Get the index of the root node.",
  6768. description = "Returns the index of the model's root node.",
  6769. key = "ModelData:getRootNode",
  6770. module = "lovr.data",
  6771. related = {
  6772. "ModelData:getNodeCount",
  6773. "ModelData:getNodeParent",
  6774. "Model:getRootNode"
  6775. },
  6776. variants = {
  6777. {
  6778. arguments = {},
  6779. returns = {
  6780. {
  6781. name = "root",
  6782. type = "number",
  6783. description = "The index of the root node."
  6784. }
  6785. }
  6786. }
  6787. }
  6788. },
  6789. {
  6790. name = "getSkinCount",
  6791. summary = "Get the number of skins in the model.",
  6792. description = "Returns the number of skins in the model. A skin is a collection of joints targeted by an animation.",
  6793. key = "ModelData:getSkinCount",
  6794. module = "lovr.data",
  6795. notes = "There is currently a maximum of 256 skins.",
  6796. related = {
  6797. "Model:hasJoints"
  6798. },
  6799. variants = {
  6800. {
  6801. arguments = {},
  6802. returns = {
  6803. {
  6804. name = "count",
  6805. type = "number",
  6806. description = "The number of skins in the model."
  6807. }
  6808. }
  6809. }
  6810. }
  6811. },
  6812. {
  6813. name = "getSkinInverseBindMatrix",
  6814. summary = "Get the inverse bind matrix for a joint in the skin.",
  6815. description = "Returns the inverse bind matrix for a joint in the skin.",
  6816. key = "ModelData:getSkinInverseBindMatrix",
  6817. module = "lovr.data",
  6818. variants = {
  6819. {
  6820. arguments = {
  6821. {
  6822. name = "skin",
  6823. type = "number",
  6824. description = "The index of a skin."
  6825. },
  6826. {
  6827. name = "joint",
  6828. type = "number",
  6829. description = "The index of a joint in the skin."
  6830. }
  6831. },
  6832. returns = {
  6833. {
  6834. name = "...",
  6835. type = "number",
  6836. description = "The 16 components of the 4x4 inverse bind matrix, in column-major order."
  6837. }
  6838. }
  6839. }
  6840. }
  6841. },
  6842. {
  6843. name = "getSkinJoints",
  6844. summary = "Get the joints in a skin.",
  6845. description = "Returns a table with the node indices of the joints in a skin.",
  6846. key = "ModelData:getSkinJoints",
  6847. module = "lovr.data",
  6848. variants = {
  6849. {
  6850. arguments = {
  6851. {
  6852. name = "skin",
  6853. type = "number",
  6854. description = "The index of a skin."
  6855. }
  6856. },
  6857. returns = {
  6858. {
  6859. name = "joints",
  6860. type = "table",
  6861. description = "The joints in the skin."
  6862. }
  6863. }
  6864. }
  6865. }
  6866. },
  6867. {
  6868. name = "getTriangleCount",
  6869. summary = "Get the total number of triangles in the model.",
  6870. description = "Returns the total number of triangles in the model. This count includes meshes that are attached to multiple nodes, and the count corresponds to the triangles returned by `ModelData:getTriangles`.",
  6871. key = "ModelData:getTriangleCount",
  6872. module = "lovr.data",
  6873. related = {
  6874. "ModelData:getTriangles",
  6875. "ModelData:getVertexCount",
  6876. "Model:getTriangleCount"
  6877. },
  6878. variants = {
  6879. {
  6880. arguments = {},
  6881. returns = {
  6882. {
  6883. name = "count",
  6884. type = "number",
  6885. description = "The total number of triangles in the model."
  6886. }
  6887. }
  6888. }
  6889. }
  6890. },
  6891. {
  6892. name = "getTriangles",
  6893. summary = "Get all the triangles in the model.",
  6894. description = "Returns the data for all triangles in the model. There are a few differences between this and the mesh-specific functions like `ModelData:getMeshVertex` and `ModelData:getMeshIndex`:\n\n- Only vertex positions are returned, not other vertex attributes.\n- Positions are relative to the origin of the whole model, instead of local to a node.\n- If a mesh is attached to more than one node, its vertices will be in the table multiple times.\n- Vertex indices will be relative to the whole triangle list instead of a mesh.",
  6895. key = "ModelData:getTriangles",
  6896. module = "lovr.data",
  6897. notes = "After this function is called on a ModelData once, the result is cached.",
  6898. related = {
  6899. "ModelData:getTriangleCount",
  6900. "ModelData:getVertexCount",
  6901. "Model:getTriangles"
  6902. },
  6903. variants = {
  6904. {
  6905. arguments = {},
  6906. returns = {
  6907. {
  6908. name = "vertices",
  6909. type = "table",
  6910. description = "The triangle vertex positions, returned as a flat (non-nested) table of numbers. The position of each vertex is given as an x, y, and z coordinate."
  6911. },
  6912. {
  6913. name = "indices",
  6914. type = "table",
  6915. description = "The vertex indices. Every 3 indices describes a triangle."
  6916. }
  6917. }
  6918. }
  6919. }
  6920. },
  6921. {
  6922. name = "getVertexCount",
  6923. summary = "Get the total vertex count of the model.",
  6924. description = "Returns the total vertex count of a model. This count includes meshes that are attached to multiple nodes, and the count corresponds to the vertices returned by `ModelData:getTriangles`.",
  6925. key = "ModelData:getVertexCount",
  6926. module = "lovr.data",
  6927. related = {
  6928. "ModelData:getTriangles",
  6929. "ModelData:getTriangleCount",
  6930. "Model:getVertexCount"
  6931. },
  6932. variants = {
  6933. {
  6934. arguments = {},
  6935. returns = {
  6936. {
  6937. name = "count",
  6938. type = "number",
  6939. description = "The total number of vertices in the model."
  6940. }
  6941. }
  6942. }
  6943. }
  6944. },
  6945. {
  6946. name = "getWidth",
  6947. summary = "Get the width of the model.",
  6948. description = "Returns the width of the model, computed from its axis-aligned bounding box.",
  6949. key = "ModelData:getWidth",
  6950. module = "lovr.data",
  6951. related = {
  6952. "ModelData:getHeight",
  6953. "ModelData:getDepth",
  6954. "ModelData:getDimensions",
  6955. "ModelData:getCenter",
  6956. "ModelData:getBoundingBox",
  6957. "Model:getWidth"
  6958. },
  6959. variants = {
  6960. {
  6961. arguments = {},
  6962. returns = {
  6963. {
  6964. name = "width",
  6965. type = "number",
  6966. description = "The width of the model."
  6967. }
  6968. }
  6969. }
  6970. }
  6971. }
  6972. }
  6973. },
  6974. {
  6975. name = "Rasterizer",
  6976. summary = "An object that rasterizes glyphs from font files.",
  6977. description = "A Rasterizer is an object that parses a TTF file, decoding and rendering glyphs from it.\n\nUsually you can just use `Font` objects.",
  6978. key = "Rasterizer",
  6979. module = "lovr.data",
  6980. constructors = {
  6981. "lovr.data.newRasterizer"
  6982. },
  6983. methods = {
  6984. {
  6985. name = "getAdvance",
  6986. summary = "Get the advance of a glyph.",
  6987. description = "Returns the advance metric for a glyph, in pixels. The advance is the horizontal distance to advance the cursor after rendering the glyph.",
  6988. key = "Rasterizer:getAdvance",
  6989. module = "lovr.data",
  6990. variants = {
  6991. {
  6992. arguments = {
  6993. {
  6994. name = "character",
  6995. type = "string",
  6996. description = "A character."
  6997. }
  6998. },
  6999. returns = {
  7000. {
  7001. name = "advance",
  7002. type = "number",
  7003. description = "The advance of the glyph, in pixels."
  7004. }
  7005. }
  7006. },
  7007. {
  7008. arguments = {
  7009. {
  7010. name = "codepoint",
  7011. type = "number",
  7012. description = "A codepoint."
  7013. }
  7014. },
  7015. returns = {
  7016. {
  7017. name = "advance",
  7018. type = "number",
  7019. description = "The advance of the glyph, in pixels."
  7020. }
  7021. }
  7022. }
  7023. }
  7024. },
  7025. {
  7026. name = "getAscent",
  7027. summary = "Get the ascent of the font.",
  7028. description = "Returns the ascent metric of the font, in pixels. The ascent represents how far any glyph of the font ascends above the baseline.",
  7029. key = "Rasterizer:getAscent",
  7030. module = "lovr.data",
  7031. related = {
  7032. "Rasterizer:getDescent",
  7033. "Font:getAscent"
  7034. },
  7035. variants = {
  7036. {
  7037. arguments = {},
  7038. returns = {
  7039. {
  7040. name = "ascent",
  7041. type = "number",
  7042. description = "The ascent of the font, in pixels."
  7043. }
  7044. }
  7045. }
  7046. }
  7047. },
  7048. {
  7049. name = "getBearing",
  7050. summary = "Get the bearing of a glyph.",
  7051. description = "Returns the bearing metric for a glyph, in pixels. The bearing is the horizontal distance from the cursor to the edge of the glyph.",
  7052. key = "Rasterizer:getBearing",
  7053. module = "lovr.data",
  7054. variants = {
  7055. {
  7056. arguments = {
  7057. {
  7058. name = "character",
  7059. type = "string",
  7060. description = "A character."
  7061. }
  7062. },
  7063. returns = {
  7064. {
  7065. name = "bearing",
  7066. type = "number",
  7067. description = "The bearing of the glyph, in pixels."
  7068. }
  7069. }
  7070. },
  7071. {
  7072. arguments = {
  7073. {
  7074. name = "codepoint",
  7075. type = "number",
  7076. description = "A codepoint."
  7077. }
  7078. },
  7079. returns = {
  7080. {
  7081. name = "bearing",
  7082. type = "number",
  7083. description = "The bearing of the glyph, in pixels."
  7084. }
  7085. }
  7086. }
  7087. }
  7088. },
  7089. {
  7090. name = "getBoundingBox",
  7091. summary = "Get the bounding box of a glyph, or the font.",
  7092. description = "Returns the bounding box of a glyph, or the bounding box surrounding all glyphs. Note that font coordinates use a cartesian \"y up\" coordinate system.",
  7093. key = "Rasterizer:getBoundingBox",
  7094. module = "lovr.data",
  7095. related = {
  7096. "Rasterizer:getWidth",
  7097. "Rasterizer:getHeight",
  7098. "Rasterizer:getDimensions"
  7099. },
  7100. variants = {
  7101. {
  7102. arguments = {
  7103. {
  7104. name = "character",
  7105. type = "string",
  7106. description = "A character."
  7107. }
  7108. },
  7109. returns = {
  7110. {
  7111. name = "x1",
  7112. type = "number",
  7113. description = "The left edge of the bounding box, in pixels."
  7114. },
  7115. {
  7116. name = "y1",
  7117. type = "number",
  7118. description = "The bottom edge of the bounding box, in pixels."
  7119. },
  7120. {
  7121. name = "x2",
  7122. type = "number",
  7123. description = "The right edge of the bounding box, in pixels."
  7124. },
  7125. {
  7126. name = "y2",
  7127. type = "number",
  7128. description = "The top edge of the bounding box, in pixels."
  7129. }
  7130. }
  7131. },
  7132. {
  7133. arguments = {
  7134. {
  7135. name = "codepoint",
  7136. type = "number",
  7137. description = "A codepoint."
  7138. }
  7139. },
  7140. returns = {
  7141. {
  7142. name = "x1",
  7143. type = "number",
  7144. description = "The left edge of the bounding box, in pixels."
  7145. },
  7146. {
  7147. name = "y1",
  7148. type = "number",
  7149. description = "The bottom edge of the bounding box, in pixels."
  7150. },
  7151. {
  7152. name = "x2",
  7153. type = "number",
  7154. description = "The right edge of the bounding box, in pixels."
  7155. },
  7156. {
  7157. name = "y2",
  7158. type = "number",
  7159. description = "The top edge of the bounding box, in pixels."
  7160. }
  7161. }
  7162. },
  7163. {
  7164. arguments = {},
  7165. returns = {
  7166. {
  7167. name = "x1",
  7168. type = "number",
  7169. description = "The left edge of the bounding box, in pixels."
  7170. },
  7171. {
  7172. name = "y1",
  7173. type = "number",
  7174. description = "The bottom edge of the bounding box, in pixels."
  7175. },
  7176. {
  7177. name = "x2",
  7178. type = "number",
  7179. description = "The right edge of the bounding box, in pixels."
  7180. },
  7181. {
  7182. name = "y2",
  7183. type = "number",
  7184. description = "The top edge of the bounding box, in pixels."
  7185. }
  7186. }
  7187. }
  7188. }
  7189. },
  7190. {
  7191. name = "getCurves",
  7192. summary = "Get the bezier curves defining a glyph.",
  7193. description = "Returns the bezier curve control points defining the shape of a glyph.",
  7194. key = "Rasterizer:getCurves",
  7195. module = "lovr.data",
  7196. related = {
  7197. "Curve",
  7198. "Rasterizer:newImage"
  7199. },
  7200. variants = {
  7201. {
  7202. arguments = {
  7203. {
  7204. name = "character",
  7205. type = "string",
  7206. description = "A character."
  7207. },
  7208. {
  7209. name = "three",
  7210. type = "boolean",
  7211. description = "Whether the control points should be 3D or 2D."
  7212. }
  7213. },
  7214. returns = {
  7215. {
  7216. name = "curves",
  7217. type = "table",
  7218. description = "A table of curves. Each curve is a table of numbers representing the control points (2 for a line, 3 for a quadratic curve, etc.)."
  7219. }
  7220. }
  7221. },
  7222. {
  7223. arguments = {
  7224. {
  7225. name = "codepoint",
  7226. type = "number",
  7227. description = "A codepoint."
  7228. },
  7229. {
  7230. name = "three",
  7231. type = "boolean",
  7232. description = "Whether the control points should be 3D or 2D."
  7233. }
  7234. },
  7235. returns = {
  7236. {
  7237. name = "curves",
  7238. type = "table",
  7239. description = "A table of curves. Each curve is a table of numbers representing the control points (2 for a line, 3 for a quadratic curve, etc.)."
  7240. }
  7241. }
  7242. }
  7243. }
  7244. },
  7245. {
  7246. name = "getDescent",
  7247. summary = "Get the descent of the font.",
  7248. description = "Returns the descent metric of the font, in pixels. The descent represents how far any glyph of the font descends below the baseline.",
  7249. key = "Rasterizer:getDescent",
  7250. module = "lovr.data",
  7251. related = {
  7252. "Rasterizer:getAscent",
  7253. "Font:getDescent"
  7254. },
  7255. variants = {
  7256. {
  7257. arguments = {},
  7258. returns = {
  7259. {
  7260. name = "descent",
  7261. type = "number",
  7262. description = "The descent of the font, in pixels."
  7263. }
  7264. }
  7265. }
  7266. }
  7267. },
  7268. {
  7269. name = "getDimensions",
  7270. summary = "Get the dimensions of a glyph, or the font.",
  7271. description = "Returns the dimensions of a glyph, or the dimensions of any glyph.",
  7272. key = "Rasterizer:getDimensions",
  7273. module = "lovr.data",
  7274. related = {
  7275. "Rasterizer:getWidth",
  7276. "Rasterizer:getHeight",
  7277. "Rasterizer:getBoundingBox"
  7278. },
  7279. variants = {
  7280. {
  7281. arguments = {
  7282. {
  7283. name = "character",
  7284. type = "string",
  7285. description = "A character."
  7286. }
  7287. },
  7288. returns = {
  7289. {
  7290. name = "width",
  7291. type = "number",
  7292. description = "The width, in pixels."
  7293. },
  7294. {
  7295. name = "height",
  7296. type = "number",
  7297. description = "The height, in pixels."
  7298. }
  7299. }
  7300. },
  7301. {
  7302. arguments = {
  7303. {
  7304. name = "codepoint",
  7305. type = "number",
  7306. description = "A codepoint."
  7307. }
  7308. },
  7309. returns = {
  7310. {
  7311. name = "width",
  7312. type = "number",
  7313. description = "The width, in pixels."
  7314. },
  7315. {
  7316. name = "height",
  7317. type = "number",
  7318. description = "The height, in pixels."
  7319. }
  7320. }
  7321. },
  7322. {
  7323. arguments = {},
  7324. returns = {
  7325. {
  7326. name = "width",
  7327. type = "number",
  7328. description = "The width, in pixels."
  7329. },
  7330. {
  7331. name = "height",
  7332. type = "number",
  7333. description = "The height, in pixels."
  7334. }
  7335. }
  7336. }
  7337. }
  7338. },
  7339. {
  7340. name = "getFontSize",
  7341. summary = "Get the size of the font.",
  7342. description = "Returns the size of the font, in pixels. This is the size the rasterizer was created with, and defines the size of images it rasterizes.",
  7343. key = "Rasterizer:getFontSize",
  7344. module = "lovr.data",
  7345. related = {
  7346. "Rasterizer:getHeight"
  7347. },
  7348. variants = {
  7349. {
  7350. arguments = {},
  7351. returns = {
  7352. {
  7353. name = "size",
  7354. type = "number",
  7355. description = "The font size, in pixels."
  7356. }
  7357. }
  7358. }
  7359. }
  7360. },
  7361. {
  7362. name = "getGlyphCount",
  7363. summary = "Get the number of glyphs stored in the font file.",
  7364. description = "Returns the number of glyphs stored in the font file.",
  7365. key = "Rasterizer:getGlyphCount",
  7366. module = "lovr.data",
  7367. related = {
  7368. "Rasterizer:hasGlyphs"
  7369. },
  7370. variants = {
  7371. {
  7372. arguments = {},
  7373. returns = {
  7374. {
  7375. name = "count",
  7376. type = "number",
  7377. description = "The number of glyphs stored in the font file."
  7378. }
  7379. }
  7380. }
  7381. }
  7382. },
  7383. {
  7384. name = "getHeight",
  7385. summary = "Get the height of a glyph, or the font.",
  7386. description = "Returns the height of a glyph, or the maximum height of any glyph.",
  7387. key = "Rasterizer:getHeight",
  7388. module = "lovr.data",
  7389. related = {
  7390. "Rasterizer:getWidth",
  7391. "Rasterizer:getDimensions",
  7392. "Rasterizer:getBoundingBox"
  7393. },
  7394. variants = {
  7395. {
  7396. arguments = {
  7397. {
  7398. name = "character",
  7399. type = "string",
  7400. description = "A character."
  7401. }
  7402. },
  7403. returns = {
  7404. {
  7405. name = "height",
  7406. type = "number",
  7407. description = "The height, in pixels."
  7408. }
  7409. }
  7410. },
  7411. {
  7412. arguments = {
  7413. {
  7414. name = "codepoint",
  7415. type = "number",
  7416. description = "A codepoint."
  7417. }
  7418. },
  7419. returns = {
  7420. {
  7421. name = "height",
  7422. type = "number",
  7423. description = "The height, in pixels."
  7424. }
  7425. }
  7426. },
  7427. {
  7428. arguments = {},
  7429. returns = {
  7430. {
  7431. name = "height",
  7432. type = "number",
  7433. description = "The height, in pixels."
  7434. }
  7435. }
  7436. }
  7437. }
  7438. },
  7439. {
  7440. name = "getKerning",
  7441. summary = "Get the kerning between two glyphs.",
  7442. description = "Returns the kerning between 2 glyphs, in pixels. Kerning is a slight horizontal adjustment between 2 glyphs to improve the visual appearance. It will often be negative.",
  7443. key = "Rasterizer:getKerning",
  7444. module = "lovr.data",
  7445. related = {
  7446. "Font:getKerning"
  7447. },
  7448. variants = {
  7449. {
  7450. arguments = {
  7451. {
  7452. name = "first",
  7453. type = "string",
  7454. description = "The first character."
  7455. },
  7456. {
  7457. name = "second",
  7458. type = "string",
  7459. description = "The second character."
  7460. }
  7461. },
  7462. returns = {
  7463. {
  7464. name = "keming",
  7465. type = "number",
  7466. description = "The kerning between the two glyphs."
  7467. }
  7468. }
  7469. },
  7470. {
  7471. arguments = {
  7472. {
  7473. name = "firstCodepoint",
  7474. type = "number",
  7475. description = "The first codepoint."
  7476. },
  7477. {
  7478. name = "second",
  7479. type = "string",
  7480. description = "The second character."
  7481. }
  7482. },
  7483. returns = {
  7484. {
  7485. name = "keming",
  7486. type = "number",
  7487. description = "The kerning between the two glyphs."
  7488. }
  7489. }
  7490. },
  7491. {
  7492. arguments = {
  7493. {
  7494. name = "first",
  7495. type = "string",
  7496. description = "The first character."
  7497. },
  7498. {
  7499. name = "secondCodepoint",
  7500. type = "number",
  7501. description = "The second codepoint."
  7502. }
  7503. },
  7504. returns = {
  7505. {
  7506. name = "keming",
  7507. type = "number",
  7508. description = "The kerning between the two glyphs."
  7509. }
  7510. }
  7511. },
  7512. {
  7513. arguments = {
  7514. {
  7515. name = "firstCodepoint",
  7516. type = "number",
  7517. description = "The first codepoint."
  7518. },
  7519. {
  7520. name = "secondCodepoint",
  7521. type = "number",
  7522. description = "The second codepoint."
  7523. }
  7524. },
  7525. returns = {
  7526. {
  7527. name = "keming",
  7528. type = "number",
  7529. description = "The kerning between the two glyphs."
  7530. }
  7531. }
  7532. }
  7533. }
  7534. },
  7535. {
  7536. name = "getLeading",
  7537. summary = "Get the leading of the font.",
  7538. description = "Returns the leading metric of the font, in pixels. This is the full amount of space between lines.",
  7539. key = "Rasterizer:getLeading",
  7540. module = "lovr.data",
  7541. related = {
  7542. "Rasterizer:getAscent",
  7543. "Rasterizer:getDescent"
  7544. },
  7545. variants = {
  7546. {
  7547. arguments = {},
  7548. returns = {
  7549. {
  7550. name = "leading",
  7551. type = "number",
  7552. description = "The font leading, in pixels."
  7553. }
  7554. }
  7555. }
  7556. }
  7557. },
  7558. {
  7559. name = "getWidth",
  7560. summary = "Get the width of a glyph, or the font.",
  7561. description = "Returns the width of a glyph, or the maximum width of any glyph.",
  7562. key = "Rasterizer:getWidth",
  7563. module = "lovr.data",
  7564. related = {
  7565. "Rasterizer:getHeight",
  7566. "Rasterizer:getDimensions",
  7567. "Rasterizer:getBoundingBox"
  7568. },
  7569. variants = {
  7570. {
  7571. arguments = {
  7572. {
  7573. name = "character",
  7574. type = "string",
  7575. description = "A character."
  7576. }
  7577. },
  7578. returns = {
  7579. {
  7580. name = "width",
  7581. type = "number",
  7582. description = "The width, in pixels."
  7583. }
  7584. }
  7585. },
  7586. {
  7587. arguments = {
  7588. {
  7589. name = "codepoint",
  7590. type = "number",
  7591. description = "A codepoint."
  7592. }
  7593. },
  7594. returns = {
  7595. {
  7596. name = "width",
  7597. type = "number",
  7598. description = "The width, in pixels."
  7599. }
  7600. }
  7601. },
  7602. {
  7603. arguments = {},
  7604. returns = {
  7605. {
  7606. name = "width",
  7607. type = "number",
  7608. description = "The width, in pixels."
  7609. }
  7610. }
  7611. }
  7612. }
  7613. },
  7614. {
  7615. name = "hasGlyphs",
  7616. summary = "Get whether the Rasterizer can rasterize a set of glyphs.",
  7617. description = "Returns whether the Rasterizer can rasterize a set of glyphs.",
  7618. key = "Rasterizer:hasGlyphs",
  7619. module = "lovr.data",
  7620. related = {
  7621. "Rasterizer:getGlyphCount"
  7622. },
  7623. variants = {
  7624. {
  7625. arguments = {
  7626. {
  7627. name = "...",
  7628. type = "*",
  7629. description = "Strings (sets of characters) or numbers (character codes) to check for."
  7630. }
  7631. },
  7632. returns = {
  7633. {
  7634. name = "hasGlyphs",
  7635. type = "boolean",
  7636. description = "true if the Rasterizer can rasterize all of the supplied characters, false otherwise."
  7637. }
  7638. }
  7639. }
  7640. }
  7641. },
  7642. {
  7643. name = "newImage",
  7644. summary = "Get an Image of a rasterized glyph.",
  7645. description = "Returns an `Image` containing a rasterized glyph.",
  7646. key = "Rasterizer:newImage",
  7647. module = "lovr.data",
  7648. related = {
  7649. "Rasterizer:getCurves"
  7650. },
  7651. variants = {
  7652. {
  7653. arguments = {
  7654. {
  7655. name = "character",
  7656. type = "string",
  7657. description = "A character."
  7658. },
  7659. {
  7660. name = "spread",
  7661. type = "number",
  7662. description = "The width of the distance field, for signed distance field rasterization.",
  7663. default = "4.0"
  7664. },
  7665. {
  7666. name = "padding",
  7667. type = "number",
  7668. description = "The number of pixels of padding to add at the edges of the image.",
  7669. default = "spread / 2"
  7670. }
  7671. },
  7672. returns = {
  7673. {
  7674. name = "image",
  7675. type = "Image",
  7676. description = "The glyph image. It will be in the `rgba32f` format."
  7677. }
  7678. }
  7679. },
  7680. {
  7681. arguments = {
  7682. {
  7683. name = "codepoint",
  7684. type = "number",
  7685. description = "A codepoint."
  7686. },
  7687. {
  7688. name = "spread",
  7689. type = "number",
  7690. description = "The width of the distance field, for signed distance field rasterization.",
  7691. default = "4.0"
  7692. },
  7693. {
  7694. name = "padding",
  7695. type = "number",
  7696. description = "The number of pixels of padding to add at the edges of the image.",
  7697. default = "spread / 2"
  7698. }
  7699. },
  7700. returns = {
  7701. {
  7702. name = "image",
  7703. type = "Image",
  7704. description = "The glyph image. It will be in the `rgba32f` format."
  7705. }
  7706. }
  7707. }
  7708. }
  7709. }
  7710. }
  7711. },
  7712. {
  7713. name = "Sound",
  7714. summary = "An object that holds raw audio samples.",
  7715. description = "A Sound stores the data for a sound. The supported sound formats are OGG, WAV, and MP3. Sounds cannot be played directly. Instead, there are `Source` objects in `lovr.audio` that are used for audio playback. All Source objects are backed by one of these Sounds, and multiple Sources can share a single Sound to reduce memory usage.\n\nMetadata\n---\n\nSounds hold a fixed number of frames. Each frame contains one audio sample for each channel. The `SampleFormat` of the Sound is the data type used for each sample (floating point, integer, etc.). The Sound has a `ChannelLayout`, representing the number of audio channels and how they map to speakers (mono, stereo, etc.). The sample rate of the Sound indicates how many frames should be played per second. The duration of the sound (in seconds) is the number of frames divided by the sample rate.\n\nCompression\n---\n\nSounds can be compressed. Compressed sounds are stored compressed in memory and are decoded as they are played. This uses a lot less memory but increases CPU usage during playback. OGG and MP3 are compressed audio formats. When creating a sound from a compressed format, there is an option to immediately decode it, storing it uncompressed in memory. It can be a good idea to decode short sound effects, since they won't use very much memory even when uncompressed and it will improve CPU usage. Compressed sounds can not be written to using `Sound:setFrames`.\n\nStreams\n---\n\nSounds can be created as a stream by passing `'stream'` as their contents when creating them. Audio frames can be written to the end of the stream, and read from the beginning. This works well for situations where data is being generated in real time or streamed in from some other data source.\n\nSources can be backed by a stream and they'll just play whatever audio is pushed to the stream. The audio module also lets you use a stream as a \"sink\" for an audio device. For playback devices, this works like loopback, so the mixed audio from all playing Sources will get written to the stream. For capture devices, all the microphone input will get written to the stream. Conversion between sample formats, channel layouts, and sample rates will happen automatically.\n\nKeep in mind that streams can still only hold a fixed number of frames. If too much data is written before it is read, older frames will start to get overwritten. Similary, it's possible to read too much data without writing fast enough.\n\nAmbisonics\n---\n\nAmbisonic sounds can be imported from WAVs, but can not yet be played. Sounds with a `ChannelLayout` of `ambisonic` are stored as first-order full-sphere ambisonics using the AmbiX format (ACN channel ordering and SN3D channel normalization). The AMB format is supported for import and will automatically get converted to AmbiX. See `lovr.data.newSound` for more info.",
  7716. key = "Sound",
  7717. module = "lovr.data",
  7718. constructors = {
  7719. "lovr.data.newSound"
  7720. },
  7721. methods = {
  7722. {
  7723. name = "getBlob",
  7724. summary = "Get the bytes backing this Sound as a Blob.",
  7725. description = "Returns a Blob containing the raw bytes of the Sound.",
  7726. key = "Sound:getBlob",
  7727. module = "lovr.data",
  7728. notes = "Samples for each channel are stored interleaved. The data type of each sample is given by `Sound:getFormat`.",
  7729. related = {
  7730. "Blob:getPointer",
  7731. "Image:getBlob"
  7732. },
  7733. variants = {
  7734. {
  7735. arguments = {},
  7736. returns = {
  7737. {
  7738. name = "blob",
  7739. type = "Blob",
  7740. description = "The Blob instance containing the bytes for the `Sound`."
  7741. }
  7742. }
  7743. }
  7744. }
  7745. },
  7746. {
  7747. name = "getCapacity",
  7748. summary = "Get the number of frames that can be written to the Sound.",
  7749. description = "Returns the number of frames that can be written to the Sound. For stream sounds, this is the number of frames that can be written without overwriting existing data. For normal sounds, this returns the same value as `Sound:getFrameCount`.",
  7750. key = "Sound:getCapacity",
  7751. module = "lovr.data",
  7752. related = {
  7753. "Sound:getFrameCount",
  7754. "Sound:getSampleCount",
  7755. "Source:getDuration"
  7756. },
  7757. variants = {
  7758. {
  7759. arguments = {},
  7760. returns = {
  7761. {
  7762. name = "capacity",
  7763. type = "number",
  7764. description = "The number of frames that can be written to the Sound."
  7765. }
  7766. }
  7767. }
  7768. }
  7769. },
  7770. {
  7771. name = "getChannelCount",
  7772. summary = "Get the number of channels in the Sound.",
  7773. description = "Returns the number of channels in the Sound. Mono sounds have 1 channel, stereo sounds have 2 channels, and ambisonic sounds have 4 channels.",
  7774. key = "Sound:getChannelCount",
  7775. module = "lovr.data",
  7776. related = {
  7777. "Sound:getChannelLayout"
  7778. },
  7779. variants = {
  7780. {
  7781. arguments = {},
  7782. returns = {
  7783. {
  7784. name = "channels",
  7785. type = "number",
  7786. description = "The number of channels in the sound."
  7787. }
  7788. }
  7789. }
  7790. }
  7791. },
  7792. {
  7793. name = "getChannelLayout",
  7794. summary = "Get the channel layout of the Sound.",
  7795. description = "Returns the channel layout of the Sound.",
  7796. key = "Sound:getChannelLayout",
  7797. module = "lovr.data",
  7798. related = {
  7799. "Sound:getChannelCount"
  7800. },
  7801. variants = {
  7802. {
  7803. arguments = {},
  7804. returns = {
  7805. {
  7806. name = "channels",
  7807. type = "ChannelLayout",
  7808. description = "The channel layout."
  7809. }
  7810. }
  7811. }
  7812. }
  7813. },
  7814. {
  7815. name = "getDuration",
  7816. summary = "Get the duration of the Sound.",
  7817. description = "Returns the duration of the Sound, in seconds.",
  7818. key = "Sound:getDuration",
  7819. module = "lovr.data",
  7820. notes = "This can be computed as `(frameCount / sampleRate)`.",
  7821. related = {
  7822. "Sound:getFrameCount",
  7823. "Sound:getSampleCount",
  7824. "Sound:getSampleRate",
  7825. "Source:getDuration"
  7826. },
  7827. variants = {
  7828. {
  7829. arguments = {},
  7830. returns = {
  7831. {
  7832. name = "duration",
  7833. type = "number",
  7834. description = "The duration of the Sound, in seconds."
  7835. }
  7836. }
  7837. }
  7838. }
  7839. },
  7840. {
  7841. name = "getFormat",
  7842. summary = "Get the sample format of the Sound.",
  7843. description = "Returns the sample format of the Sound.",
  7844. key = "Sound:getFormat",
  7845. module = "lovr.data",
  7846. related = {
  7847. "Sound:getChannelLayout",
  7848. "Sound:getSampleRate"
  7849. },
  7850. variants = {
  7851. {
  7852. arguments = {},
  7853. returns = {
  7854. {
  7855. name = "format",
  7856. type = "SampleFormat",
  7857. description = "The data type of each sample."
  7858. }
  7859. }
  7860. }
  7861. }
  7862. },
  7863. {
  7864. name = "getFrameCount",
  7865. summary = "Get the number of frames in the Sound.",
  7866. description = "Returns the number of frames in the Sound. A frame stores one sample for each channel.",
  7867. key = "Sound:getFrameCount",
  7868. module = "lovr.data",
  7869. notes = "For streams, this returns the number of frames in the stream's buffer.",
  7870. related = {
  7871. "Sound:getDuration",
  7872. "Sound:getSampleCount",
  7873. "Sound:getChannelCount"
  7874. },
  7875. variants = {
  7876. {
  7877. arguments = {},
  7878. returns = {
  7879. {
  7880. name = "frames",
  7881. type = "number",
  7882. description = "The number of frames in the Sound."
  7883. }
  7884. }
  7885. }
  7886. }
  7887. },
  7888. {
  7889. name = "getFrames",
  7890. summary = "Read frames from the Sound.",
  7891. description = "Reads frames from the Sound into a table, Blob, or another Sound.",
  7892. key = "Sound:getFrames",
  7893. module = "lovr.data",
  7894. variants = {
  7895. {
  7896. arguments = {
  7897. {
  7898. name = "count",
  7899. type = "number",
  7900. description = "The number of frames to read. If nil, reads as many frames as possible.\n\nCompressed sounds will automatically be decoded.\n\nReading from a stream will ignore the source offset and read the oldest frames.",
  7901. default = "nil"
  7902. },
  7903. {
  7904. name = "srcOffset",
  7905. type = "number",
  7906. description = "A frame offset to apply to the sound when reading frames.",
  7907. default = "0"
  7908. }
  7909. },
  7910. returns = {
  7911. {
  7912. name = "t",
  7913. type = "table",
  7914. description = "A table containing audio frames."
  7915. },
  7916. {
  7917. name = "count",
  7918. type = "number",
  7919. description = "The number of frames read."
  7920. }
  7921. }
  7922. },
  7923. {
  7924. arguments = {
  7925. {
  7926. name = "t",
  7927. type = "table",
  7928. description = "An existing table to read frames into."
  7929. },
  7930. {
  7931. name = "count",
  7932. type = "number",
  7933. description = "The number of frames to read. If nil, reads as many frames as possible.\n\nCompressed sounds will automatically be decoded.\n\nReading from a stream will ignore the source offset and read the oldest frames.",
  7934. default = "nil"
  7935. },
  7936. {
  7937. name = "srcOffset",
  7938. type = "number",
  7939. description = "A frame offset to apply to the sound when reading frames.",
  7940. default = "0"
  7941. },
  7942. {
  7943. name = "dstOffset",
  7944. type = "number",
  7945. description = "An offset to apply to the destination when writing frames (indices for tables, bytes for Blobs, frames for Sounds).",
  7946. default = "0"
  7947. }
  7948. },
  7949. returns = {
  7950. {
  7951. name = "t",
  7952. type = "table",
  7953. description = "A table containing audio frames."
  7954. },
  7955. {
  7956. name = "count",
  7957. type = "number",
  7958. description = "The number of frames read."
  7959. }
  7960. }
  7961. },
  7962. {
  7963. arguments = {
  7964. {
  7965. name = "blob",
  7966. type = "Blob",
  7967. description = "A Blob to read frames into."
  7968. },
  7969. {
  7970. name = "count",
  7971. type = "number",
  7972. description = "The number of frames to read. If nil, reads as many frames as possible.\n\nCompressed sounds will automatically be decoded.\n\nReading from a stream will ignore the source offset and read the oldest frames.",
  7973. default = "nil"
  7974. },
  7975. {
  7976. name = "srcOffset",
  7977. type = "number",
  7978. description = "A frame offset to apply to the sound when reading frames.",
  7979. default = "0"
  7980. },
  7981. {
  7982. name = "dstOffset",
  7983. type = "number",
  7984. description = "An offset to apply to the destination when writing frames (indices for tables, bytes for Blobs, frames for Sounds).",
  7985. default = "0"
  7986. }
  7987. },
  7988. returns = {
  7989. {
  7990. name = "count",
  7991. type = "number",
  7992. description = "The number of frames read."
  7993. }
  7994. }
  7995. },
  7996. {
  7997. arguments = {
  7998. {
  7999. name = "sound",
  8000. type = "Sound",
  8001. description = "Another Sound to copy frames into."
  8002. },
  8003. {
  8004. name = "count",
  8005. type = "number",
  8006. description = "The number of frames to read. If nil, reads as many frames as possible.\n\nCompressed sounds will automatically be decoded.\n\nReading from a stream will ignore the source offset and read the oldest frames.",
  8007. default = "nil"
  8008. },
  8009. {
  8010. name = "srcOffset",
  8011. type = "number",
  8012. description = "A frame offset to apply to the sound when reading frames.",
  8013. default = "0"
  8014. },
  8015. {
  8016. name = "dstOffset",
  8017. type = "number",
  8018. description = "An offset to apply to the destination when writing frames (indices for tables, bytes for Blobs, frames for Sounds).",
  8019. default = "0"
  8020. }
  8021. },
  8022. returns = {
  8023. {
  8024. name = "count",
  8025. type = "number",
  8026. description = "The number of frames read."
  8027. }
  8028. }
  8029. }
  8030. }
  8031. },
  8032. {
  8033. name = "getSampleCount",
  8034. summary = "Get the number of samples in the Sound.",
  8035. description = "Returns the total number of samples in the Sound.",
  8036. key = "Sound:getSampleCount",
  8037. module = "lovr.data",
  8038. notes = "For streams, this returns the number of samples in the stream's buffer.",
  8039. related = {
  8040. "Sound:getDuration",
  8041. "Sound:getFrameCount",
  8042. "Sound:getChannelCount"
  8043. },
  8044. variants = {
  8045. {
  8046. arguments = {},
  8047. returns = {
  8048. {
  8049. name = "samples",
  8050. type = "number",
  8051. description = "The total number of samples in the Sound."
  8052. }
  8053. }
  8054. }
  8055. }
  8056. },
  8057. {
  8058. name = "getSampleRate",
  8059. summary = "Get the sample rate of the Sound.",
  8060. description = "Returns the sample rate of the Sound, in Hz. This is the number of frames that are played every second. It's usually a high number like 48000.",
  8061. key = "Sound:getSampleRate",
  8062. module = "lovr.data",
  8063. variants = {
  8064. {
  8065. arguments = {},
  8066. returns = {
  8067. {
  8068. name = "frequency",
  8069. type = "number",
  8070. description = "The number of frames per second in the Sound."
  8071. }
  8072. }
  8073. }
  8074. }
  8075. },
  8076. {
  8077. name = "isCompressed",
  8078. summary = "Check if the Sound is compressed.",
  8079. description = "Returns whether the Sound is compressed. Compressed sounds are loaded from compressed audio formats like MP3 and OGG. They use a lot less memory but require some extra CPU work during playback. Compressed sounds can not be modified using `Sound:setFrames`.",
  8080. key = "Sound:isCompressed",
  8081. module = "lovr.data",
  8082. related = {
  8083. "Sound:isStream",
  8084. "lovr.data.newSound"
  8085. },
  8086. variants = {
  8087. {
  8088. arguments = {},
  8089. returns = {
  8090. {
  8091. name = "compressed",
  8092. type = "boolean",
  8093. description = "Whether the Sound is compressed."
  8094. }
  8095. }
  8096. }
  8097. }
  8098. },
  8099. {
  8100. name = "isStream",
  8101. summary = "Check if the Sound is a stream.",
  8102. description = "Returns whether the Sound is a stream.",
  8103. key = "Sound:isStream",
  8104. module = "lovr.data",
  8105. related = {
  8106. "Sound:isCompressed",
  8107. "lovr.data.newSound"
  8108. },
  8109. variants = {
  8110. {
  8111. arguments = {},
  8112. returns = {
  8113. {
  8114. name = "stream",
  8115. type = "boolean",
  8116. description = "Whether the Sound is a stream."
  8117. }
  8118. }
  8119. }
  8120. }
  8121. },
  8122. {
  8123. name = "setFrames",
  8124. summary = "Write frames to the Sound.",
  8125. description = "Writes frames to the Sound.",
  8126. key = "Sound:setFrames",
  8127. module = "lovr.data",
  8128. examples = {
  8129. {
  8130. description = "Generate a sine wave.",
  8131. code = "function lovr.load()\n local length = 1\n local rate = 48000\n local frames = length * rate\n local frequency = 440\n local volume = 1.0\n\n sound = lovr.data.newSound(frames, 'f32', 'stereo', rate)\n\n local data = {}\n for i = 1, frames do\n local amplitude = math.sin((i - 1) * frequency / rate * (2 * math.pi)) * volume\n data[2 * i - 1] = amplitude\n data[2 * i - 0] = amplitude\n end\n\n sound:setFrames(data)\n\n source = lovr.audio.newSource(sound)\n source:setLooping(true)\n source:play()\nend"
  8132. }
  8133. },
  8134. variants = {
  8135. {
  8136. arguments = {
  8137. {
  8138. name = "t",
  8139. type = "table",
  8140. description = "A table containing frames to write."
  8141. },
  8142. {
  8143. name = "count",
  8144. type = "number",
  8145. description = "How many frames to write. If nil, writes as many as possible.",
  8146. default = "nil"
  8147. },
  8148. {
  8149. name = "dstOffset",
  8150. type = "number",
  8151. description = "A frame offset to apply when writing the frames.",
  8152. default = "0"
  8153. },
  8154. {
  8155. name = "srcOffset",
  8156. type = "number",
  8157. description = "A frame, byte, or index offset to apply when reading frames from the source.",
  8158. default = "0"
  8159. }
  8160. },
  8161. returns = {
  8162. {
  8163. name = "count",
  8164. type = "number",
  8165. description = "The number of frames written."
  8166. }
  8167. }
  8168. },
  8169. {
  8170. arguments = {
  8171. {
  8172. name = "blob",
  8173. type = "Blob",
  8174. description = "A Blob containing frames to write."
  8175. },
  8176. {
  8177. name = "count",
  8178. type = "number",
  8179. description = "How many frames to write. If nil, writes as many as possible.",
  8180. default = "nil"
  8181. },
  8182. {
  8183. name = "dstOffset",
  8184. type = "number",
  8185. description = "A frame offset to apply when writing the frames.",
  8186. default = "0"
  8187. },
  8188. {
  8189. name = "srcOffset",
  8190. type = "number",
  8191. description = "A frame, byte, or index offset to apply when reading frames from the source.",
  8192. default = "0"
  8193. }
  8194. },
  8195. returns = {
  8196. {
  8197. name = "count",
  8198. type = "number",
  8199. description = "The number of frames written."
  8200. }
  8201. }
  8202. },
  8203. {
  8204. arguments = {
  8205. {
  8206. name = "sound",
  8207. type = "Sound",
  8208. description = "Another Sound to copy frames from."
  8209. },
  8210. {
  8211. name = "count",
  8212. type = "number",
  8213. description = "How many frames to write. If nil, writes as many as possible.",
  8214. default = "nil"
  8215. },
  8216. {
  8217. name = "dstOffset",
  8218. type = "number",
  8219. description = "A frame offset to apply when writing the frames.",
  8220. default = "0"
  8221. },
  8222. {
  8223. name = "srcOffset",
  8224. type = "number",
  8225. description = "A frame, byte, or index offset to apply when reading frames from the source.",
  8226. default = "0"
  8227. }
  8228. },
  8229. returns = {
  8230. {
  8231. name = "count",
  8232. type = "number",
  8233. description = "The number of frames written."
  8234. }
  8235. }
  8236. }
  8237. }
  8238. }
  8239. }
  8240. }
  8241. }
  8242. },
  8243. {
  8244. name = "event",
  8245. tag = "modules",
  8246. summary = "Handles events from the operating system.",
  8247. description = "The `lovr.event` module handles events from the operating system.\n\nDue to its low-level nature, it's rare to use `lovr.event` in simple projects.",
  8248. key = "lovr.event",
  8249. enums = {
  8250. {
  8251. name = "KeyCode",
  8252. summary = "Keys that can be pressed.",
  8253. description = "Keys that can be pressed on a keyboard. Notably, numpad keys are missing right now.",
  8254. key = "KeyCode",
  8255. module = "lovr.event",
  8256. related = {
  8257. "lovr.keypressed",
  8258. "lovr.keyreleased"
  8259. },
  8260. values = {
  8261. {
  8262. name = "a",
  8263. description = "The A key."
  8264. },
  8265. {
  8266. name = "b",
  8267. description = "The B key."
  8268. },
  8269. {
  8270. name = "c",
  8271. description = "The C key."
  8272. },
  8273. {
  8274. name = "d",
  8275. description = "The D key."
  8276. },
  8277. {
  8278. name = "e",
  8279. description = "The E key."
  8280. },
  8281. {
  8282. name = "f",
  8283. description = "The F key."
  8284. },
  8285. {
  8286. name = "g",
  8287. description = "The G key."
  8288. },
  8289. {
  8290. name = "h",
  8291. description = "The H key."
  8292. },
  8293. {
  8294. name = "i",
  8295. description = "The I key."
  8296. },
  8297. {
  8298. name = "j",
  8299. description = "The J key."
  8300. },
  8301. {
  8302. name = "k",
  8303. description = "The K key."
  8304. },
  8305. {
  8306. name = "l",
  8307. description = "The L key."
  8308. },
  8309. {
  8310. name = "m",
  8311. description = "The M key."
  8312. },
  8313. {
  8314. name = "n",
  8315. description = "The N key."
  8316. },
  8317. {
  8318. name = "o",
  8319. description = "The O key."
  8320. },
  8321. {
  8322. name = "p",
  8323. description = "The P key."
  8324. },
  8325. {
  8326. name = "q",
  8327. description = "The Q key."
  8328. },
  8329. {
  8330. name = "r",
  8331. description = "The R key."
  8332. },
  8333. {
  8334. name = "s",
  8335. description = "The S key."
  8336. },
  8337. {
  8338. name = "t",
  8339. description = "The T key."
  8340. },
  8341. {
  8342. name = "u",
  8343. description = "The U key."
  8344. },
  8345. {
  8346. name = "v",
  8347. description = "The V key."
  8348. },
  8349. {
  8350. name = "w",
  8351. description = "The W key."
  8352. },
  8353. {
  8354. name = "x",
  8355. description = "The X key."
  8356. },
  8357. {
  8358. name = "y",
  8359. description = "The Y key."
  8360. },
  8361. {
  8362. name = "z",
  8363. description = "The Z key."
  8364. },
  8365. {
  8366. name = "0",
  8367. description = "The 0 key."
  8368. },
  8369. {
  8370. name = "1",
  8371. description = "The 1 key."
  8372. },
  8373. {
  8374. name = "2",
  8375. description = "The 2 key."
  8376. },
  8377. {
  8378. name = "3",
  8379. description = "The 3 key."
  8380. },
  8381. {
  8382. name = "4",
  8383. description = "The 4 key."
  8384. },
  8385. {
  8386. name = "5",
  8387. description = "The 5 key."
  8388. },
  8389. {
  8390. name = "6",
  8391. description = "The 6 key."
  8392. },
  8393. {
  8394. name = "7",
  8395. description = "The 7 key."
  8396. },
  8397. {
  8398. name = "8",
  8399. description = "The 8 key."
  8400. },
  8401. {
  8402. name = "9",
  8403. description = "The 9 key."
  8404. },
  8405. {
  8406. name = "space",
  8407. description = "The space bar."
  8408. },
  8409. {
  8410. name = "return",
  8411. description = "The enter key."
  8412. },
  8413. {
  8414. name = "tab",
  8415. description = "The tab key."
  8416. },
  8417. {
  8418. name = "escape",
  8419. description = "The escape key."
  8420. },
  8421. {
  8422. name = "backspace",
  8423. description = "The backspace key."
  8424. },
  8425. {
  8426. name = "up",
  8427. description = "The up arrow key."
  8428. },
  8429. {
  8430. name = "down",
  8431. description = "The down arrow key."
  8432. },
  8433. {
  8434. name = "left",
  8435. description = "The left arrow key."
  8436. },
  8437. {
  8438. name = "right",
  8439. description = "The right arrow key."
  8440. },
  8441. {
  8442. name = "home",
  8443. description = "The home key."
  8444. },
  8445. {
  8446. name = "end",
  8447. description = "The end key."
  8448. },
  8449. {
  8450. name = "pageup",
  8451. description = "The page up key."
  8452. },
  8453. {
  8454. name = "pagedown",
  8455. description = "The page down key."
  8456. },
  8457. {
  8458. name = "insert",
  8459. description = "The insert key."
  8460. },
  8461. {
  8462. name = "delete",
  8463. description = "The delete key."
  8464. },
  8465. {
  8466. name = "f1",
  8467. description = "The F1 key."
  8468. },
  8469. {
  8470. name = "f2",
  8471. description = "The F2 key."
  8472. },
  8473. {
  8474. name = "f3",
  8475. description = "The F3 key."
  8476. },
  8477. {
  8478. name = "f4",
  8479. description = "The F4 key."
  8480. },
  8481. {
  8482. name = "f5",
  8483. description = "The F5 key."
  8484. },
  8485. {
  8486. name = "f6",
  8487. description = "The F6 key."
  8488. },
  8489. {
  8490. name = "f7",
  8491. description = "The F7 key."
  8492. },
  8493. {
  8494. name = "f8",
  8495. description = "The F8 key."
  8496. },
  8497. {
  8498. name = "f9",
  8499. description = "The F9 key."
  8500. },
  8501. {
  8502. name = "f10",
  8503. description = "The F10 key."
  8504. },
  8505. {
  8506. name = "f11",
  8507. description = "The F11 key."
  8508. },
  8509. {
  8510. name = "f12",
  8511. description = "The F12 key."
  8512. },
  8513. {
  8514. name = "`",
  8515. description = "The backtick/backquote/grave accent key."
  8516. },
  8517. {
  8518. name = "-",
  8519. description = "The dash/hyphen/minus key."
  8520. },
  8521. {
  8522. name = "=",
  8523. description = "The equal sign key."
  8524. },
  8525. {
  8526. name = "[",
  8527. description = "The left bracket key."
  8528. },
  8529. {
  8530. name = "]",
  8531. description = "The right bracket key."
  8532. },
  8533. {
  8534. name = "\\",
  8535. description = "The backslash key."
  8536. },
  8537. {
  8538. name = ";",
  8539. description = "The semicolon key."
  8540. },
  8541. {
  8542. name = "'",
  8543. description = "The single quote key."
  8544. },
  8545. {
  8546. name = ",",
  8547. description = "The comma key."
  8548. },
  8549. {
  8550. name = ".",
  8551. description = "The period key."
  8552. },
  8553. {
  8554. name = "/",
  8555. description = "The slash key."
  8556. },
  8557. {
  8558. name = "lctrl",
  8559. description = "The left control key."
  8560. },
  8561. {
  8562. name = "lshift",
  8563. description = "The left shift key."
  8564. },
  8565. {
  8566. name = "lalt",
  8567. description = "The left alt key."
  8568. },
  8569. {
  8570. name = "lgui",
  8571. description = "The left OS key (windows, command, super)."
  8572. },
  8573. {
  8574. name = "rctrl",
  8575. description = "The right control key."
  8576. },
  8577. {
  8578. name = "rshift",
  8579. description = "The right shift key."
  8580. },
  8581. {
  8582. name = "ralt",
  8583. description = "The right alt key."
  8584. },
  8585. {
  8586. name = "rgui",
  8587. description = "The right OS key (windows, command, super)."
  8588. },
  8589. {
  8590. name = "capslock",
  8591. description = "The caps lock key."
  8592. },
  8593. {
  8594. name = "scrolllock",
  8595. description = "The scroll lock key."
  8596. },
  8597. {
  8598. name = "numlock",
  8599. description = "The numlock key."
  8600. }
  8601. }
  8602. }
  8603. },
  8604. examples = {
  8605. {
  8606. description = "Adding a custom event.",
  8607. code = "function lovr.load()\n lovr.handlers['customevent'] = function(a, b, c)\n print('custom event handled with args:', a, b, c)\n end\n\n lovr.event.push('customevent', 1, 2, 3)\nend"
  8608. }
  8609. },
  8610. functions = {
  8611. {
  8612. name = "clear",
  8613. summary = "Clear the event queue.",
  8614. description = "Clears the event queue, removing any unprocessed events.",
  8615. key = "lovr.event.clear",
  8616. module = "lovr.event",
  8617. variants = {
  8618. {
  8619. arguments = {},
  8620. returns = {}
  8621. }
  8622. }
  8623. },
  8624. {
  8625. name = "poll",
  8626. summary = "Iterate over unprocessed events in the queue.",
  8627. description = "This function returns a Lua iterator for all of the unprocessed items in the event queue. Each event consists of a name as a string, followed by event-specific arguments. This function is called in the default implementation of `lovr.run`, so it is normally not necessary to poll for events yourself.",
  8628. key = "lovr.event.poll",
  8629. module = "lovr.event",
  8630. variants = {
  8631. {
  8632. arguments = {},
  8633. returns = {
  8634. {
  8635. name = "iterator",
  8636. type = "function",
  8637. description = "The iterator function, usable in a for loop.",
  8638. arguments = {},
  8639. returns = {}
  8640. }
  8641. }
  8642. }
  8643. }
  8644. },
  8645. {
  8646. name = "push",
  8647. summary = "Manually push an event onto the queue.",
  8648. description = "Pushes an event onto the event queue. It will be processed the next time `lovr.event.poll` is called. For an event to be processed properly, there needs to be a function in the `lovr.handlers` table with a key that's the same as the event name.",
  8649. key = "lovr.event.push",
  8650. module = "lovr.event",
  8651. notes = "Only nil, booleans, numbers, strings, and LÖVR objects are supported types for event data.",
  8652. related = {
  8653. "lovr.event.poll",
  8654. "lovr.event.quit"
  8655. },
  8656. variants = {
  8657. {
  8658. arguments = {
  8659. {
  8660. name = "name",
  8661. type = "string",
  8662. description = "The name of the event."
  8663. },
  8664. {
  8665. name = "...",
  8666. type = "*",
  8667. description = "The arguments for the event. Currently, up to 4 are supported."
  8668. }
  8669. },
  8670. returns = {}
  8671. }
  8672. }
  8673. },
  8674. {
  8675. name = "quit",
  8676. summary = "Quit the application.",
  8677. description = "Pushes an event to quit. An optional number can be passed to set the exit code for the application. An exit code of zero indicates normal termination, whereas a nonzero exit code indicates that an error occurred.",
  8678. key = "lovr.event.quit",
  8679. module = "lovr.event",
  8680. notes = "This function is equivalent to calling `lovr.event.push('quit', <args>)`.\n\nThe event won't be processed until the next time `lovr.event.poll` is called.\n\nThe `lovr.quit` callback will be called when the event is processed, which can be used to do any cleanup work. The callback can also return `false` to abort the quitting process.",
  8681. related = {
  8682. "lovr.quit",
  8683. "lovr.event.poll",
  8684. "lovr.event.restart"
  8685. },
  8686. variants = {
  8687. {
  8688. arguments = {
  8689. {
  8690. name = "code",
  8691. type = "number",
  8692. description = "The exit code of the program.",
  8693. default = "0"
  8694. }
  8695. },
  8696. returns = {}
  8697. }
  8698. }
  8699. },
  8700. {
  8701. name = "restart",
  8702. summary = "Restart the application.",
  8703. description = "Pushes an event to restart the framework.",
  8704. key = "lovr.event.restart",
  8705. module = "lovr.event",
  8706. notes = "The event won't be processed until the next time `lovr.event.poll` is called.\n\nThe `lovr.restart` callback can be used to persist a value between restarts.",
  8707. related = {
  8708. "lovr.restart",
  8709. "lovr.event.poll",
  8710. "lovr.event.quit"
  8711. },
  8712. variants = {
  8713. {
  8714. arguments = {},
  8715. returns = {}
  8716. }
  8717. }
  8718. }
  8719. },
  8720. notes = "You can define your own custom events by adding a function to the `lovr.handlers` table with a key of the name of the event you want to add. Then, push the event using `lovr.event.push`.",
  8721. objects = {}
  8722. },
  8723. {
  8724. name = "filesystem",
  8725. tag = "modules",
  8726. summary = "Provides access to the filesystem.",
  8727. description = "The `lovr.filesystem` module provides access to the filesystem.\n\nAll files written will go in a special folder called the \"save directory\". The location of the save directory is platform-specific:\n\n<table>\n <tr>\n <td>Windows</td>\n <td><code>C:\\Users\\&lt;user&gt;\\AppData\\Roaming\\LOVR\\&lt;identity&gt;</code></td>\n </tr>\n <tr>\n <td>macOS</td>\n <td><code>/Users/&lt;user&gt;/Library/Application Support/LOVR/&lt;identity&gt;</code></td>\n </tr>\n <tr>\n <td>Linux</td>\n <td><code>/home/&lt;user&gt;/.local/share/LOVR/&lt;identity&gt;</code></td>\n </tr>\n <tr>\n <td>Android</td>\n <td><code>/sdcard/Android/data/&lt;identity&gt;/files</code></td>\n </tr> </table>\n\n`<identity>` is a unique identifier for the project, and can be set in `lovr.conf`. On Android, the identity can not be changed and will always be the package id (e.g. `org.lovr.app`).\n\nWhen files are read, they will be searched for in multiple places. By default, the save directory is checked first, then the project source (folder or zip). That way, when data is written to a file, any future reads will see the new data. The `t.saveprecedence` conf setting can be used to change this precedence.\n\nConceptually, `lovr.filesystem` uses a \"virtual filesystem\", which is an ordered list of folders and zip files that are merged into a single filesystem hierarchy. Folders and archives in the list can be added and removed with `lovr.filesystem.mount` and `lovr.filesystem.unmount`.\n\nLÖVR extends Lua's `require` function to look for modules in the virtual filesystem. The search patterns can be changed with `lovr.filesystem.setRequirePath`, similar to `package.path`.",
  8728. key = "lovr.filesystem",
  8729. enums = {},
  8730. functions = {
  8731. {
  8732. name = "append",
  8733. tag = "filesystem-files",
  8734. summary = "Append content to the end of a file.",
  8735. description = "Appends content to the end of a file.",
  8736. key = "lovr.filesystem.append",
  8737. module = "lovr.filesystem",
  8738. notes = "If the file does not exist, it is created.",
  8739. variants = {
  8740. {
  8741. arguments = {
  8742. {
  8743. name = "filename",
  8744. type = "string",
  8745. description = "The file to append to."
  8746. },
  8747. {
  8748. name = "content",
  8749. type = "string",
  8750. description = "A string to write to the end of the file."
  8751. }
  8752. },
  8753. returns = {
  8754. {
  8755. name = "bytes",
  8756. type = "number",
  8757. description = "The number of bytes actually appended to the file."
  8758. }
  8759. }
  8760. },
  8761. {
  8762. arguments = {
  8763. {
  8764. name = "filename",
  8765. type = "string",
  8766. description = "The file to append to."
  8767. },
  8768. {
  8769. name = "blob",
  8770. type = "Blob",
  8771. description = "A Blob containing data to append to the file."
  8772. }
  8773. },
  8774. returns = {
  8775. {
  8776. name = "bytes",
  8777. type = "number",
  8778. description = "The number of bytes actually appended to the file."
  8779. }
  8780. }
  8781. }
  8782. }
  8783. },
  8784. {
  8785. name = "createDirectory",
  8786. tag = "filesystem-files",
  8787. summary = "Create a directory.",
  8788. description = "Creates a directory in the save directory. Any parent directories that don't exist will also be created.",
  8789. key = "lovr.filesystem.createDirectory",
  8790. module = "lovr.filesystem",
  8791. variants = {
  8792. {
  8793. arguments = {
  8794. {
  8795. name = "path",
  8796. type = "string",
  8797. description = "The directory to create, recursively."
  8798. }
  8799. },
  8800. returns = {
  8801. {
  8802. name = "success",
  8803. type = "boolean",
  8804. description = "Whether the directory was created."
  8805. }
  8806. }
  8807. }
  8808. }
  8809. },
  8810. {
  8811. name = "getAppdataDirectory",
  8812. tag = "filesystem-paths",
  8813. summary = "Get the application data directory.",
  8814. description = "Returns the application data directory. This will be something like:\n\n- `C:\\Users\\user\\AppData\\Roaming` on Windows.\n- `/home/user/.config` on Linux.\n- `/Users/user/Library/Application Support` on macOS.",
  8815. key = "lovr.filesystem.getAppdataDirectory",
  8816. module = "lovr.filesystem",
  8817. variants = {
  8818. {
  8819. arguments = {},
  8820. returns = {
  8821. {
  8822. name = "path",
  8823. type = "string",
  8824. description = "The absolute path to the appdata directory."
  8825. }
  8826. }
  8827. }
  8828. }
  8829. },
  8830. {
  8831. name = "getDirectoryItems",
  8832. tag = "filesystem-files",
  8833. summary = "Get a list of files in a directory.",
  8834. description = "Returns a sorted table containing all files and folders in a single directory.",
  8835. key = "lovr.filesystem.getDirectoryItems",
  8836. module = "lovr.filesystem",
  8837. notes = "This function calls `table.sort` to sort the results, so if `table.sort` is not available in the global scope the results are not guaranteed to be sorted.",
  8838. variants = {
  8839. {
  8840. arguments = {
  8841. {
  8842. name = "path",
  8843. type = "string",
  8844. description = "The directory."
  8845. }
  8846. },
  8847. returns = {
  8848. {
  8849. name = "items",
  8850. type = "table",
  8851. description = "A table with a string for each file and subfolder in the directory."
  8852. }
  8853. }
  8854. }
  8855. }
  8856. },
  8857. {
  8858. name = "getExecutablePath",
  8859. tag = "filesystem-paths",
  8860. summary = "Get the path of the LÖVR executable.",
  8861. description = "Returns the absolute path of the LÖVR executable.",
  8862. key = "lovr.filesystem.getExecutablePath",
  8863. module = "lovr.filesystem",
  8864. variants = {
  8865. {
  8866. arguments = {},
  8867. returns = {
  8868. {
  8869. name = "path",
  8870. type = "string",
  8871. description = "The absolute path of the LÖVR executable, or `nil` if it is unknown."
  8872. }
  8873. }
  8874. }
  8875. }
  8876. },
  8877. {
  8878. name = "getIdentity",
  8879. tag = "filesystem-virtual",
  8880. summary = "Get the name of the save directory.",
  8881. description = "Returns the identity of the game, which is used as the name of the save directory. The default is `default`. It can be changed using `t.identity` in `lovr.conf`.",
  8882. key = "lovr.filesystem.getIdentity",
  8883. module = "lovr.filesystem",
  8884. notes = "On Android, this is always the package id (like `org.lovr.app`).",
  8885. variants = {
  8886. {
  8887. arguments = {},
  8888. returns = {
  8889. {
  8890. name = "identity",
  8891. type = "string",
  8892. description = "The name of the save directory, or `nil` if it isn't set."
  8893. }
  8894. }
  8895. }
  8896. }
  8897. },
  8898. {
  8899. name = "getLastModified",
  8900. tag = "filesystem-files",
  8901. summary = "Get the modification time of a file.",
  8902. description = "Returns when a file was last modified, since some arbitrary time in the past.",
  8903. key = "lovr.filesystem.getLastModified",
  8904. module = "lovr.filesystem",
  8905. variants = {
  8906. {
  8907. arguments = {
  8908. {
  8909. name = "path",
  8910. type = "string",
  8911. description = "The file to check."
  8912. }
  8913. },
  8914. returns = {
  8915. {
  8916. name = "time",
  8917. type = "number",
  8918. description = "The modification time of the file, in seconds, or `nil` if it's unknown."
  8919. }
  8920. }
  8921. }
  8922. }
  8923. },
  8924. {
  8925. name = "getRealDirectory",
  8926. tag = "filesystem-virtual",
  8927. summary = "Get the absolute path to a file.",
  8928. description = "Get the absolute path of the mounted archive containing a path in the virtual filesystem. This can be used to determine if a file is in the game's source directory or the save directory.",
  8929. key = "lovr.filesystem.getRealDirectory",
  8930. module = "lovr.filesystem",
  8931. variants = {
  8932. {
  8933. arguments = {
  8934. {
  8935. name = "path",
  8936. type = "string",
  8937. description = "The path to check."
  8938. }
  8939. },
  8940. returns = {
  8941. {
  8942. name = "realpath",
  8943. type = "string",
  8944. description = "The absolute path of the mounted archive containing `path`."
  8945. }
  8946. }
  8947. }
  8948. }
  8949. },
  8950. {
  8951. name = "getRequirePath",
  8952. tag = "filesystem-lua",
  8953. summary = "Get the require path.",
  8954. description = "Returns the require path. The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d. Any question marks in the pattern will be replaced with the module that is being required. It is similar to Lua\\'s `package.path` variable, but the main difference is that the patterns are relative to the virtual filesystem.",
  8955. key = "lovr.filesystem.getRequirePath",
  8956. module = "lovr.filesystem",
  8957. notes = "The default reqiure path is '?.lua;?/init.lua'.",
  8958. variants = {
  8959. {
  8960. arguments = {},
  8961. returns = {
  8962. {
  8963. name = "path",
  8964. type = "string",
  8965. description = "The semicolon separated list of search patterns."
  8966. }
  8967. }
  8968. }
  8969. }
  8970. },
  8971. {
  8972. name = "getSaveDirectory",
  8973. tag = "filesystem-paths",
  8974. summary = "Get the location of the save directory.",
  8975. description = "Returns the absolute path to the save directory.",
  8976. key = "lovr.filesystem.getSaveDirectory",
  8977. module = "lovr.filesystem",
  8978. notes = "The save directory takes the following form:\n\n <appdata>/LOVR/<identity>\n\nWhere `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`.",
  8979. related = {
  8980. "lovr.filesystem.getIdentity",
  8981. "lovr.filesystem.getAppdataDirectory"
  8982. },
  8983. variants = {
  8984. {
  8985. arguments = {},
  8986. returns = {
  8987. {
  8988. name = "path",
  8989. type = "string",
  8990. description = "The absolute path to the save directory."
  8991. }
  8992. }
  8993. }
  8994. }
  8995. },
  8996. {
  8997. name = "getSize",
  8998. tag = "filesystem-files",
  8999. summary = "Get the size of a file.",
  9000. description = "Returns the size of a file, in bytes.",
  9001. key = "lovr.filesystem.getSize",
  9002. module = "lovr.filesystem",
  9003. notes = "If the file does not exist, an error is thrown.",
  9004. variants = {
  9005. {
  9006. arguments = {
  9007. {
  9008. name = "file",
  9009. type = "string",
  9010. description = "The file."
  9011. }
  9012. },
  9013. returns = {
  9014. {
  9015. name = "size",
  9016. type = "number",
  9017. description = "The size of the file, in bytes."
  9018. }
  9019. }
  9020. }
  9021. }
  9022. },
  9023. {
  9024. name = "getSource",
  9025. tag = "filesystem-paths",
  9026. summary = "Get the location of the project source.",
  9027. description = "Get the absolute path of the project's source directory or archive.",
  9028. key = "lovr.filesystem.getSource",
  9029. module = "lovr.filesystem",
  9030. variants = {
  9031. {
  9032. arguments = {},
  9033. returns = {
  9034. {
  9035. name = "path",
  9036. type = "string",
  9037. description = "The absolute path of the project's source, or `nil` if it's unknown."
  9038. }
  9039. }
  9040. }
  9041. }
  9042. },
  9043. {
  9044. name = "getUserDirectory",
  9045. tag = "filesystem-paths",
  9046. summary = "Get the location of the user's home directory.",
  9047. description = "Returns the absolute path of the user's home directory.",
  9048. key = "lovr.filesystem.getUserDirectory",
  9049. module = "lovr.filesystem",
  9050. variants = {
  9051. {
  9052. arguments = {},
  9053. returns = {
  9054. {
  9055. name = "path",
  9056. type = "string",
  9057. description = "The absolute path of the user's home directory."
  9058. }
  9059. }
  9060. }
  9061. }
  9062. },
  9063. {
  9064. name = "getWorkingDirectory",
  9065. tag = "filesystem-paths",
  9066. summary = "Get the current working directory.",
  9067. description = "Returns the absolute path of the working directory. Usually this is where the executable was started from.",
  9068. key = "lovr.filesystem.getWorkingDirectory",
  9069. module = "lovr.filesystem",
  9070. variants = {
  9071. {
  9072. arguments = {},
  9073. returns = {
  9074. {
  9075. name = "path",
  9076. type = "string",
  9077. description = "The current working directory, or `nil` if it's unknown."
  9078. }
  9079. }
  9080. }
  9081. }
  9082. },
  9083. {
  9084. name = "isDirectory",
  9085. tag = "filesystem-files",
  9086. summary = "Check whether a path is a directory.",
  9087. description = "Check if a path exists and is a directory.",
  9088. key = "lovr.filesystem.isDirectory",
  9089. module = "lovr.filesystem",
  9090. related = {
  9091. "lovr.filesystem.isFile"
  9092. },
  9093. variants = {
  9094. {
  9095. arguments = {
  9096. {
  9097. name = "path",
  9098. type = "string",
  9099. description = "The path to check."
  9100. }
  9101. },
  9102. returns = {
  9103. {
  9104. name = "isDirectory",
  9105. type = "boolean",
  9106. description = "Whether or not the path is a directory."
  9107. }
  9108. }
  9109. }
  9110. }
  9111. },
  9112. {
  9113. name = "isFile",
  9114. tag = "filesystem-files",
  9115. summary = "Check whether a path is a file.",
  9116. description = "Check if a path exists and is a file.",
  9117. key = "lovr.filesystem.isFile",
  9118. module = "lovr.filesystem",
  9119. related = {
  9120. "lovr.filesystem.isDirectory"
  9121. },
  9122. variants = {
  9123. {
  9124. arguments = {
  9125. {
  9126. name = "path",
  9127. type = "string",
  9128. description = "The path to check."
  9129. }
  9130. },
  9131. returns = {
  9132. {
  9133. name = "isFile",
  9134. type = "boolean",
  9135. description = "Whether or not the path is a file."
  9136. }
  9137. }
  9138. }
  9139. }
  9140. },
  9141. {
  9142. name = "isFused",
  9143. tag = "filesystem-virtual",
  9144. summary = "Check if the project is fused.",
  9145. description = "Returns whether the current project source is fused to the executable.",
  9146. key = "lovr.filesystem.isFused",
  9147. module = "lovr.filesystem",
  9148. variants = {
  9149. {
  9150. arguments = {},
  9151. returns = {
  9152. {
  9153. name = "fused",
  9154. type = "boolean",
  9155. description = "Whether or not the project is fused."
  9156. }
  9157. }
  9158. }
  9159. }
  9160. },
  9161. {
  9162. name = "load",
  9163. tag = "filesystem-lua",
  9164. summary = "Load a file as Lua code.",
  9165. description = "Load a file containing Lua code, returning a Lua chunk that can be run.",
  9166. key = "lovr.filesystem.load",
  9167. module = "lovr.filesystem",
  9168. examples = {
  9169. {
  9170. description = "Safely loading code:",
  9171. code = "local success, chunk = pcall(lovr.filesystem.load, filename)\nif not success then\n print('Oh no! There was an error: ' .. tostring(chunk))\nelse\n local success, result = pcall(chunk)\n print(success, result)\nend"
  9172. }
  9173. },
  9174. notes = "An error is thrown if the file contains syntax errors.",
  9175. variants = {
  9176. {
  9177. arguments = {
  9178. {
  9179. name = "filename",
  9180. type = "string",
  9181. description = "The file to load."
  9182. },
  9183. {
  9184. name = "mode",
  9185. type = "string",
  9186. description = "The type of code that can be loaded. `t` allows text, `b` allows binary, and `bt` allows both.",
  9187. default = "'bt'"
  9188. }
  9189. },
  9190. returns = {
  9191. {
  9192. name = "chunk",
  9193. type = "function",
  9194. description = "The runnable chunk."
  9195. }
  9196. }
  9197. }
  9198. }
  9199. },
  9200. {
  9201. name = "mount",
  9202. tag = "filesystem-virtual",
  9203. summary = "Mount a directory or archive.",
  9204. description = "Mounts a directory or `.zip` archive, adding it to the virtual filesystem. This allows you to read files from it.",
  9205. key = "lovr.filesystem.mount",
  9206. module = "lovr.filesystem",
  9207. examples = {
  9208. {
  9209. description = "Mount `data.zip` with a file `images/background.png`:",
  9210. code = "lovr.filesystem.mount('data.zip', 'assets')\nprint(lovr.filesystem.isFile('assets/images/background.png')) -- true"
  9211. }
  9212. },
  9213. notes = "The `append` option lets you control the priority of the archive's files in the event of naming collisions.\n\nThis function is not thread safe. Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported.",
  9214. related = {
  9215. "lovr.filesystem.unmount"
  9216. },
  9217. variants = {
  9218. {
  9219. arguments = {
  9220. {
  9221. name = "path",
  9222. type = "string",
  9223. description = "The path to mount."
  9224. },
  9225. {
  9226. name = "mountpoint",
  9227. type = "string",
  9228. description = "The path in the virtual filesystem to mount to.",
  9229. default = "'/'"
  9230. },
  9231. {
  9232. name = "append",
  9233. type = "boolean",
  9234. description = "Whether the archive will be added to the end or the beginning of the search path.",
  9235. default = "false"
  9236. },
  9237. {
  9238. name = "root",
  9239. type = "string",
  9240. description = "A subdirectory inside the archive to use as the root. If `nil`, the actual root of the archive is used.",
  9241. default = "nil"
  9242. }
  9243. },
  9244. returns = {
  9245. {
  9246. name = "success",
  9247. type = "boolean",
  9248. description = "Whether the archive was successfully mounted."
  9249. }
  9250. }
  9251. }
  9252. }
  9253. },
  9254. {
  9255. name = "newBlob",
  9256. tag = "filesystem-files",
  9257. summary = "Create a new Blob from a file.",
  9258. description = "Creates a new Blob that contains the contents of a file.",
  9259. key = "lovr.filesystem.newBlob",
  9260. module = "lovr.filesystem",
  9261. related = {
  9262. "lovr.data.newBlob",
  9263. "Blob"
  9264. },
  9265. variants = {
  9266. {
  9267. arguments = {
  9268. {
  9269. name = "filename",
  9270. type = "string",
  9271. description = "The file to load."
  9272. }
  9273. },
  9274. returns = {
  9275. {
  9276. name = "blob",
  9277. type = "Blob",
  9278. description = "The new Blob."
  9279. }
  9280. }
  9281. }
  9282. }
  9283. },
  9284. {
  9285. name = "read",
  9286. tag = "filesystem-files",
  9287. summary = "Read a file.",
  9288. description = "Read the contents of a file.",
  9289. key = "lovr.filesystem.read",
  9290. module = "lovr.filesystem",
  9291. notes = "If the file does not exist or cannot be read, nil is returned.",
  9292. variants = {
  9293. {
  9294. arguments = {
  9295. {
  9296. name = "filename",
  9297. type = "string",
  9298. description = "The name of the file to read."
  9299. },
  9300. {
  9301. name = "bytes",
  9302. type = "number",
  9303. description = "The number of bytes to read (if -1, all bytes will be read).",
  9304. default = "-1"
  9305. }
  9306. },
  9307. returns = {
  9308. {
  9309. name = "contents",
  9310. type = "string",
  9311. description = "The contents of the file."
  9312. },
  9313. {
  9314. name = "bytes",
  9315. type = "number",
  9316. description = "The number of bytes read from the file."
  9317. }
  9318. }
  9319. }
  9320. }
  9321. },
  9322. {
  9323. name = "remove",
  9324. tag = "filesystem-files",
  9325. summary = "Remove a file or directory.",
  9326. description = "Remove a file or directory in the save directory.",
  9327. key = "lovr.filesystem.remove",
  9328. module = "lovr.filesystem",
  9329. notes = "A directory can only be removed if it is empty.\n\nTo recursively remove a folder, use this function with `lovr.filesystem.getDirectoryItems`.",
  9330. variants = {
  9331. {
  9332. arguments = {
  9333. {
  9334. name = "path",
  9335. type = "string",
  9336. description = "The file or directory to remove."
  9337. }
  9338. },
  9339. returns = {
  9340. {
  9341. name = "success",
  9342. type = "boolean",
  9343. description = "Whether the path was removed."
  9344. }
  9345. }
  9346. }
  9347. }
  9348. },
  9349. {
  9350. name = "setIdentity",
  9351. tag = "filesystem-virtual",
  9352. summary = "Set the name of the save directory.",
  9353. description = "Set the name of the save directory. This function can only be called once and is called automatically at startup, so this function normally isn't called manually. However, the identity can be changed by setting the `t.identity` option in `lovr.conf`.",
  9354. key = "lovr.filesystem.setIdentity",
  9355. module = "lovr.filesystem",
  9356. related = {
  9357. "lovr.conf",
  9358. "lovr.filesystem.getSaveDirectory"
  9359. },
  9360. variants = {
  9361. {
  9362. arguments = {
  9363. {
  9364. name = "identity",
  9365. type = "string",
  9366. description = "The name of the save directory."
  9367. }
  9368. },
  9369. returns = {}
  9370. }
  9371. }
  9372. },
  9373. {
  9374. name = "setRequirePath",
  9375. tag = "filesystem-lua",
  9376. summary = "Set the require path.",
  9377. description = "Sets the require path. The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d. Any question marks in the pattern will be replaced with the module that is being required. It is similar to Lua\\'s `package.path` variable, except the patterns will be checked using `lovr.filesystem` APIs. This allows `require` to work even when the project is packaged into a zip archive, or when the project is launched from a different directory.",
  9378. key = "lovr.filesystem.setRequirePath",
  9379. module = "lovr.filesystem",
  9380. notes = "The default reqiure path is '?.lua;?/init.lua'.",
  9381. variants = {
  9382. {
  9383. arguments = {
  9384. {
  9385. name = "path",
  9386. type = "string",
  9387. description = "An optional semicolon separated list of search patterns.",
  9388. default = "nil"
  9389. }
  9390. },
  9391. returns = {}
  9392. }
  9393. }
  9394. },
  9395. {
  9396. name = "unmount",
  9397. tag = "filesystem-virtual",
  9398. summary = "Unmount a mounted archive.",
  9399. description = "Unmounts a directory or archive previously mounted with `lovr.filesystem.mount`.",
  9400. key = "lovr.filesystem.unmount",
  9401. module = "lovr.filesystem",
  9402. notes = "This function is not thread safe. Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported.",
  9403. related = {
  9404. "lovr.filesystem.mount"
  9405. },
  9406. variants = {
  9407. {
  9408. arguments = {
  9409. {
  9410. name = "path",
  9411. type = "string",
  9412. description = "The path to unmount."
  9413. }
  9414. },
  9415. returns = {
  9416. {
  9417. name = "success",
  9418. type = "boolean",
  9419. description = "Whether the archive was unmounted."
  9420. }
  9421. }
  9422. }
  9423. }
  9424. },
  9425. {
  9426. name = "write",
  9427. tag = "filesystem-files",
  9428. summary = "Write to a file.",
  9429. description = "Write to a file in the save directory.",
  9430. key = "lovr.filesystem.write",
  9431. module = "lovr.filesystem",
  9432. notes = "If the file does not exist, it is created.\n\nIf the file already has data in it, it will be replaced with the new content.\n\nIf the path contains subdirectories, all of the parent directories need to exist first or the write will fail. Use `lovr.filesystem.createDirectory` to make sure they're created first.",
  9433. related = {
  9434. "lovr.filesystem.append",
  9435. "lovr.filesystem.getSaveDirectory",
  9436. "lovr.filesystem.read"
  9437. },
  9438. variants = {
  9439. {
  9440. arguments = {
  9441. {
  9442. name = "filename",
  9443. type = "string",
  9444. description = "The file to write to."
  9445. },
  9446. {
  9447. name = "content",
  9448. type = "string",
  9449. description = "A string to write to the file."
  9450. }
  9451. },
  9452. returns = {
  9453. {
  9454. name = "success",
  9455. type = "boolean",
  9456. description = "Whether the write was successful."
  9457. }
  9458. }
  9459. },
  9460. {
  9461. arguments = {
  9462. {
  9463. name = "filename",
  9464. type = "string",
  9465. description = "The file to write to."
  9466. },
  9467. {
  9468. name = "blob",
  9469. type = "Blob",
  9470. description = "A Blob containing data to write to the file."
  9471. }
  9472. },
  9473. returns = {
  9474. {
  9475. name = "success",
  9476. type = "boolean",
  9477. description = "Whether the write was successful."
  9478. }
  9479. }
  9480. }
  9481. }
  9482. }
  9483. },
  9484. objects = {},
  9485. sections = {
  9486. {
  9487. name = "Files",
  9488. tag = "filesystem-files",
  9489. description = "Operations for reading/writing files and querying their metadata."
  9490. },
  9491. {
  9492. name = "Virtual Filesystem",
  9493. tag = "filesystem-virtual"
  9494. },
  9495. {
  9496. name = "Paths",
  9497. tag = "filesystem-paths",
  9498. description = "Useful system paths."
  9499. },
  9500. {
  9501. name = "Lua",
  9502. tag = "filesystem-lua"
  9503. }
  9504. }
  9505. },
  9506. {
  9507. name = "graphics",
  9508. tag = "modules",
  9509. summary = "Renders graphics using the GPU.",
  9510. description = "The graphics module renders graphics and performs computation using the GPU.\n\nMost of the graphics functions are on the `Pass` object.",
  9511. key = "lovr.graphics",
  9512. enums = {
  9513. {
  9514. name = "BlendAlphaMode",
  9515. summary = "Whether premultiplied alpha is enabled.",
  9516. description = "Controls whether premultiplied alpha is enabled.",
  9517. key = "BlendAlphaMode",
  9518. module = "lovr.graphics",
  9519. notes = "The premultiplied mode should be used if pixels being drawn have already been blended, or \"pre-multiplied\", by the alpha channel. This happens when rendering to a texture that contains pixels with transparent alpha values, since the stored color values have already been faded by alpha and don't need to be faded a second time with the alphamultiply blend mode.",
  9520. related = {
  9521. "BlendMode",
  9522. "Pass:setBlendMode"
  9523. },
  9524. values = {
  9525. {
  9526. name = "alphamultiply",
  9527. description = "Color channel values are multiplied by the alpha channel during blending."
  9528. },
  9529. {
  9530. name = "premultiplied",
  9531. description = "Color channel values are not multiplied by the alpha. Instead, it's assumed that the colors have already been multiplied by the alpha. This should be used if the pixels being drawn have already been blended, or \"pre-multiplied\"."
  9532. }
  9533. }
  9534. },
  9535. {
  9536. name = "BlendMode",
  9537. summary = "Blend modes.",
  9538. description = "Different ways pixels can blend with the pixels behind them.",
  9539. key = "BlendMode",
  9540. module = "lovr.graphics",
  9541. related = {
  9542. "BlendAlphaMode",
  9543. "Pass:setBlendMode"
  9544. },
  9545. values = {
  9546. {
  9547. name = "alpha",
  9548. description = "Colors will be mixed based on alpha."
  9549. },
  9550. {
  9551. name = "add",
  9552. description = "Colors will be added to the existing color, alpha will not be changed."
  9553. },
  9554. {
  9555. name = "subtract",
  9556. description = "Colors will be subtracted from the existing color, alpha will not be changed."
  9557. },
  9558. {
  9559. name = "multiply",
  9560. description = "All color channels will be multiplied together, producing a darkening effect."
  9561. },
  9562. {
  9563. name = "lighten",
  9564. description = "The maximum value of each color channel will be used."
  9565. },
  9566. {
  9567. name = "darken",
  9568. description = "The minimum value of each color channel will be used."
  9569. },
  9570. {
  9571. name = "screen",
  9572. description = "The opposite of multiply: the pixel colors are inverted, multiplied, and inverted again, producing a lightening effect."
  9573. }
  9574. }
  9575. },
  9576. {
  9577. name = "CompareMode",
  9578. summary = "Different ways of performing comparisons.",
  9579. description = "The method used to compare depth and stencil values when performing the depth and stencil tests. Also used for compare modes in `Sampler`s.",
  9580. key = "CompareMode",
  9581. module = "lovr.graphics",
  9582. notes = "This type can also be specified using mathematical notation, e.g. `=`, `>`, `<=`, etc. `notequal` can be provided as `~=` or `!=`.",
  9583. related = {
  9584. "Pass:setDepthTest",
  9585. "Pass:setStencilTest",
  9586. "Pass:setDepthWrite",
  9587. "Pass:setStencilWrite"
  9588. },
  9589. values = {
  9590. {
  9591. name = "none",
  9592. description = "The test does not take place, and acts as though it always passes."
  9593. },
  9594. {
  9595. name = "equal",
  9596. description = "The test passes if the values are equal."
  9597. },
  9598. {
  9599. name = "notequal",
  9600. description = "The test passes if the values are not equal."
  9601. },
  9602. {
  9603. name = "less",
  9604. description = "The test passes if the value is less than the existing one."
  9605. },
  9606. {
  9607. name = "lequal",
  9608. description = "The test passes if the value is less than or equal to the existing one."
  9609. },
  9610. {
  9611. name = "greater",
  9612. description = "The test passes if the value is greater than the existing one."
  9613. },
  9614. {
  9615. name = "gequal",
  9616. description = "The test passes if the value is greater than or equal to the existing one."
  9617. }
  9618. }
  9619. },
  9620. {
  9621. name = "CullMode",
  9622. summary = "Different ways of doing face culling.",
  9623. description = "The different ways of doing triangle backface culling.",
  9624. key = "CullMode",
  9625. module = "lovr.graphics",
  9626. related = {
  9627. "Winding",
  9628. "Pass:setCullMode",
  9629. "Pass:setWinding"
  9630. },
  9631. values = {
  9632. {
  9633. name = "none",
  9634. description = "Both sides of triangles will be drawn."
  9635. },
  9636. {
  9637. name = "back",
  9638. description = "Skips rendering the back side of triangles."
  9639. },
  9640. {
  9641. name = "front",
  9642. description = "Skips rendering the front side of triangles."
  9643. }
  9644. }
  9645. },
  9646. {
  9647. name = "DataLayout",
  9648. description = "The different ways to pack Buffer fields into memory.\n\nThe default is `packed`, which is suitable for vertex buffers and index buffers. It doesn't add any padding between elements, and so it doesn't waste any space. However, this layout won't necessarily work for uniform buffers and storage buffers.\n\nThe `std140` layout corresponds to the std140 layout used for uniform buffers in GLSL. It adds the most padding between fields, and requires the stride to be a multiple of 16. Example:\n\n layout(std140) uniform ObjectScales { float scales[64]; };\n\nThe `std430` layout corresponds to the std430 layout used for storage buffers in GLSL. It adds some padding between certain types, and may round up the stride. Example:\n\n layout(std430) buffer TileSizes { vec2 sizes[]; }",
  9649. key = "DataLayout",
  9650. module = "lovr.graphics",
  9651. related = {
  9652. "lovr.graphics.newBuffer",
  9653. "Buffer:getFormat",
  9654. "Buffer:getStride",
  9655. "DataType"
  9656. },
  9657. values = {
  9658. {
  9659. name = "packed",
  9660. description = "The packed layout, without any padding."
  9661. },
  9662. {
  9663. name = "std140",
  9664. description = "The std140 layout."
  9665. },
  9666. {
  9667. name = "std430",
  9668. description = "The std430 layout."
  9669. }
  9670. }
  9671. },
  9672. {
  9673. name = "DataType",
  9674. description = "Different types for `Buffer` fields. These are scalar, vector, or matrix types, usually packed into small amounts of space to reduce the amount of memory they occupy.\n\nThe names are encoded as follows:\n\n- The data type:\n - `i` for signed integer\n - `u` for unsigned integer\n - `sn` for signed normalized (-1 to 1)\n - `un` for unsigned normalized (0 to 1)\n - `f` for floating point\n- The bit depth of each component\n- The letter `x` followed by the component count (for vectors)",
  9675. key = "DataType",
  9676. module = "lovr.graphics",
  9677. notes = "In addition to these values, the following aliases can be used:\n\n<table>\n <thead>\n <tr>\n <td>Alias</td>\n <td>Maps to</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><code>vec2</code></td>\n <td><code>f32x2</code></td>\n </tr>\n <tr>\n <td><code>vec3</code></td>\n <td><code>f32x3</code></td>\n </tr>\n <tr>\n <td><code>vec4</code></td>\n <td><code>f32x4</code></td>\n </tr>\n <tr>\n <td><code>int</code></td>\n <td><code>i32</code></td>\n </tr>\n <tr>\n <td><code>uint</code></td>\n <td><code>u32</code></td>\n </tr>\n <tr>\n <td><code>float</code></td>\n <td><code>f32</code></td>\n </tr>\n <tr>\n <td><code>color</code></td>\n <td><code>un8x4</code></td>\n </tr>\n </tbody> </table>\n\nAdditionally, the following convenience rules apply:\n\n- Field types can end in an `s`, which will be stripped off.\n- Field types can end in `x1`, which will be stripped off.\n\nSo you can write, e.g. `lovr.graphics.newBuffer(4, 'floats')`, which is cute!",
  9678. related = {
  9679. "lovr.graphics.newBuffer",
  9680. "Buffer:getFormat"
  9681. },
  9682. values = {
  9683. {
  9684. name = "i8x4",
  9685. description = "Four 8-bit signed integers."
  9686. },
  9687. {
  9688. name = "u8x4",
  9689. description = "Four 8-bit unsigned integers."
  9690. },
  9691. {
  9692. name = "sn8x4",
  9693. description = "Four 8-bit signed normalized values."
  9694. },
  9695. {
  9696. name = "un8x4",
  9697. description = "Four 8-bit unsigned normalized values (aka `color`)."
  9698. },
  9699. {
  9700. name = "un10x3",
  9701. description = "Three 10-bit unsigned normalized values, and 2 padding bits (aka `normal`)."
  9702. },
  9703. {
  9704. name = "i16",
  9705. description = "One 16-bit signed integer."
  9706. },
  9707. {
  9708. name = "i16x2",
  9709. description = "Two 16-bit signed integers."
  9710. },
  9711. {
  9712. name = "i16x4",
  9713. description = "Four 16-bit signed integers."
  9714. },
  9715. {
  9716. name = "u16",
  9717. description = "One 16-bit unsigned integer."
  9718. },
  9719. {
  9720. name = "u16x2",
  9721. description = "Two 16-bit unsigned integers."
  9722. },
  9723. {
  9724. name = "u16x4",
  9725. description = "Four 16-bit unsigned integers."
  9726. },
  9727. {
  9728. name = "sn16x2",
  9729. description = "Two 16-bit signed normalized values."
  9730. },
  9731. {
  9732. name = "sn16x4",
  9733. description = "Four 16-bit signed normalized values."
  9734. },
  9735. {
  9736. name = "un16x2",
  9737. description = "Two 16-bit unsigned normalized values."
  9738. },
  9739. {
  9740. name = "un16x4",
  9741. description = "Four 16-bit unsigned normalized values."
  9742. },
  9743. {
  9744. name = "i32",
  9745. description = "One 32-bit signed integer (aka `int`)."
  9746. },
  9747. {
  9748. name = "i32x2",
  9749. description = "Two 32-bit signed integers."
  9750. },
  9751. {
  9752. name = "i32x2",
  9753. description = "Two 32-bit signed integers."
  9754. },
  9755. {
  9756. name = "i32x3",
  9757. description = "Three 32-bit signed integers."
  9758. },
  9759. {
  9760. name = "i32x4",
  9761. description = "Four 32-bit signed integers."
  9762. },
  9763. {
  9764. name = "u32",
  9765. description = "One 32-bit unsigned integer (aka `uint`)."
  9766. },
  9767. {
  9768. name = "u32x2",
  9769. description = "Two 32-bit unsigned integers."
  9770. },
  9771. {
  9772. name = "u32x3",
  9773. description = "Three 32-bit unsigned integers."
  9774. },
  9775. {
  9776. name = "u32x4",
  9777. description = "Four 32-bit unsigned integers."
  9778. },
  9779. {
  9780. name = "f16x2",
  9781. description = "Two 16-bit floating point numbers."
  9782. },
  9783. {
  9784. name = "f16x4",
  9785. description = "Four 16-bit floating point numbers."
  9786. },
  9787. {
  9788. name = "f32",
  9789. description = "One 32-bit floating point number (aka `float`)."
  9790. },
  9791. {
  9792. name = "f32x2",
  9793. description = "Two 32-bit floating point numbers (aka `vec2`)."
  9794. },
  9795. {
  9796. name = "f32x3",
  9797. description = "Three 32-bit floating point numbers (aka `vec3`)."
  9798. },
  9799. {
  9800. name = "f32x4",
  9801. description = "Four 32-bit floating point numbers (aka `vec4`)."
  9802. },
  9803. {
  9804. name = "mat2",
  9805. description = "A 2x2 matrix containing four 32-bit floats."
  9806. },
  9807. {
  9808. name = "mat3",
  9809. description = "A 3x3 matrix containing nine 32-bit floats."
  9810. },
  9811. {
  9812. name = "mat4",
  9813. description = "A 4x4 matrix containing sixteen 32-bit floats."
  9814. },
  9815. {
  9816. name = "index16",
  9817. description = "Like u16, but 1-indexed."
  9818. },
  9819. {
  9820. name = "index32",
  9821. description = "Like u32, but 1-indexed."
  9822. }
  9823. }
  9824. },
  9825. {
  9826. name = "DefaultShader",
  9827. summary = "Built-in shaders.",
  9828. description = "The set of shaders built in to LÖVR. These can be passed to `Pass:setShader` or `lovr.graphics.newShader` instead of writing GLSL code. The shaders can be further customized by using the `flags` option to change their behavior. If the active shader is set to `nil`, LÖVR picks one of these shaders to use.",
  9829. key = "DefaultShader",
  9830. module = "lovr.graphics",
  9831. values = {
  9832. {
  9833. name = "unlit",
  9834. description = "Basic shader without lighting that uses colors and a texture."
  9835. },
  9836. {
  9837. name = "normal",
  9838. description = "Shades triangles based on their normal, resulting in a cool rainbow effect."
  9839. },
  9840. {
  9841. name = "font",
  9842. description = "Renders font glyphs."
  9843. },
  9844. {
  9845. name = "cubemap",
  9846. description = "Renders cubemaps."
  9847. },
  9848. {
  9849. name = "equirect",
  9850. description = "Renders spherical textures."
  9851. },
  9852. {
  9853. name = "fill",
  9854. description = "Renders a fullscreen triangle."
  9855. }
  9856. }
  9857. },
  9858. {
  9859. name = "DrawMode",
  9860. summary = "Different ways to draw mesh vertices.",
  9861. description = "Different ways vertices in a mesh can be connected together and filled in with pixels.",
  9862. key = "DrawMode",
  9863. module = "lovr.graphics",
  9864. values = {
  9865. {
  9866. name = "points",
  9867. description = "Each vertex is rendered as a single point. The size of the point can be controlled using the `pointSize` shader flag, or by writing to the `PointSize` variable in shaders. The maximum point size is given by the `pointSize` limit from `lovr.graphics.getLimits`."
  9868. },
  9869. {
  9870. name = "lines",
  9871. description = "Pairs of vertices are connected with line segments. To draw a single line through all of the vertices, an index buffer can be used to repeat vertices. It is not currently possible to change the width of the lines, although cylinders or capsules can be used as an alternative."
  9872. },
  9873. {
  9874. name = "triangles",
  9875. description = "Every 3 vertices form a triangle, which is filled in with pixels (unless `Pass:setWireframe` is used). This mode is the most commonly used."
  9876. }
  9877. }
  9878. },
  9879. {
  9880. name = "DrawStyle",
  9881. summary = "Different styles to draw shapes.",
  9882. description = "Whether a shape should be drawn filled or outlined.",
  9883. key = "DrawStyle",
  9884. module = "lovr.graphics",
  9885. related = {
  9886. "Pass:plane",
  9887. "Pass:cube",
  9888. "Pass:box",
  9889. "Pass:circle"
  9890. },
  9891. values = {
  9892. {
  9893. name = "fill",
  9894. description = "The shape will be filled in (the default)."
  9895. },
  9896. {
  9897. name = "line",
  9898. description = "The shape will be outlined."
  9899. }
  9900. }
  9901. },
  9902. {
  9903. name = "FilterMode",
  9904. summary = "Different ways to smooth textures.",
  9905. description = "Controls how `Sampler` objects smooth pixels in textures.",
  9906. key = "FilterMode",
  9907. module = "lovr.graphics",
  9908. related = {
  9909. "lovr.graphics.newSampler",
  9910. "Sampler:getFilter",
  9911. "Texture:setPixels"
  9912. },
  9913. values = {
  9914. {
  9915. name = "nearest",
  9916. description = "A pixelated appearance where the \"nearest neighbor\" pixel is used."
  9917. },
  9918. {
  9919. name = "linear",
  9920. description = "A smooth appearance where neighboring pixels are averaged."
  9921. }
  9922. }
  9923. },
  9924. {
  9925. name = "HorizontalAlign",
  9926. summary = "Different ways to horizontally align text.",
  9927. description = "Different ways to horizontally align text with `Pass:text`.",
  9928. key = "HorizontalAlign",
  9929. module = "lovr.graphics",
  9930. related = {
  9931. "VerticalAlign",
  9932. "Pass:text",
  9933. "Font:getVertices"
  9934. },
  9935. values = {
  9936. {
  9937. name = "left",
  9938. description = "Left-aligned text."
  9939. },
  9940. {
  9941. name = "center",
  9942. description = "Centered text."
  9943. },
  9944. {
  9945. name = "right",
  9946. description = "Right-aligned text."
  9947. }
  9948. }
  9949. },
  9950. {
  9951. name = "MeshStorage",
  9952. summary = "Whether a Mesh stores its data on the CPU or GPU.",
  9953. description = "Whether a Mesh stores its data on the CPU or GPU.",
  9954. key = "MeshStorage",
  9955. module = "lovr.graphics",
  9956. notes = "There are some significant differences and tradeoffs between the two modes:\n\n- CPU meshes store a second copy of the vertices in RAM, which can be expensive for large\n meshes.\n- When vertices are modified, CPU meshes will update the CPU copy, and only upload to the GPU\n the next time the Mesh is drawn. GPU meshes, on the other hand, will immediately upload\n modified vertices to the GPU. This means that calling `Mesh:setVertices` multiple times per\n frame will be faster with a CPU mesh.\n- CPU meshes have an internal vertex buffer that can't be accessed from Lua.\n- CPU meshes can compute their bounding box using `Mesh:computeBoundingBox`. GPU meshes can't.",
  9957. related = {
  9958. "lovr.graphics.newMesh"
  9959. },
  9960. values = {
  9961. {
  9962. name = "cpu",
  9963. description = "The Mesh will store a copy of the vertices on the CPU."
  9964. },
  9965. {
  9966. name = "gpu",
  9967. description = "The Mesh will not keep a CPU copy, only storing vertices on the GPU."
  9968. }
  9969. }
  9970. },
  9971. {
  9972. name = "OriginType",
  9973. summary = "Different coordinate spaces for nodes in a Model.",
  9974. description = "Different coordinate spaces for nodes in a `Model`.",
  9975. key = "OriginType",
  9976. module = "lovr.graphics",
  9977. related = {
  9978. "Model:getNodePosition",
  9979. "Model:getNodeOrientation",
  9980. "Model:getNodeScale",
  9981. "Model:getNodePose",
  9982. "Model:getNodeTransform",
  9983. "Model:getRootNode",
  9984. "Model:getNodeParent"
  9985. },
  9986. values = {
  9987. {
  9988. name = "root",
  9989. description = "Transforms are relative to the origin (root) of the Model."
  9990. },
  9991. {
  9992. name = "parent",
  9993. description = "Transforms are relative to the parent of the node."
  9994. }
  9995. }
  9996. },
  9997. {
  9998. name = "PassType",
  9999. summary = "Different types of Passes.",
  10000. description = "The three different types of `Pass` objects. Each Pass has a single type, which determines the type of work it does and which functions can be called on it.",
  10001. key = "PassType",
  10002. module = "lovr.graphics",
  10003. deprecated = true,
  10004. related = {
  10005. "lovr.graphics.getPass",
  10006. "lovr.graphics.submit",
  10007. "Pass:getType"
  10008. },
  10009. values = {
  10010. {
  10011. name = "render",
  10012. description = "A render pass renders graphics to a set of up to four color textures and an optional depth texture. The textures all need to have the same dimensions and sample counts. The textures can have multiple layers, and all rendering work will be broadcast to each layer. Each layer can use a different camera pose, which is used for stereo rendering."
  10013. },
  10014. {
  10015. name = "compute",
  10016. description = "A compute pass runs compute shaders. Compute passes usually only call `Pass:setShader`, `Pass:send`, and `Pass:compute`. All of the compute work in a single compute pass is run in parallel, so multiple compute passes should be used if one compute pass needs to happen after a different one."
  10017. },
  10018. {
  10019. name = "transfer",
  10020. description = "A transfer pass copies data to and from GPU memory in `Buffer` and `Texture` objects. Transfer passes use `Pass:copy`, `Pass:clear`, `Pass:blit`, `Pass:mipmap`, and `Pass:read`. Similar to compute passes, all the work in a transfer pass happens in parallel, so multiple passes should be used if the transfers need to be ordered."
  10021. }
  10022. }
  10023. },
  10024. {
  10025. name = "ShaderStage",
  10026. summary = "Different shader stages.",
  10027. description = "Different shader stages. Graphics shaders have a `vertex` and `fragment` stage, and compute shaders have a single `compute` stage.",
  10028. key = "ShaderStage",
  10029. module = "lovr.graphics",
  10030. values = {
  10031. {
  10032. name = "vertex",
  10033. description = "The vertex stage, which computes transformed vertex positions."
  10034. },
  10035. {
  10036. name = "fragment",
  10037. description = "The fragment stage, which computes pixel colors."
  10038. },
  10039. {
  10040. name = "compute",
  10041. description = "The compute stage, which performs arbitrary computation."
  10042. }
  10043. }
  10044. },
  10045. {
  10046. name = "ShaderType",
  10047. summary = "Different types of Shaders.",
  10048. description = "The two types of shaders that can be created.",
  10049. key = "ShaderType",
  10050. module = "lovr.graphics",
  10051. related = {
  10052. "lovr.graphics.newShader",
  10053. "Shader:getType",
  10054. "ShaderStage"
  10055. },
  10056. values = {
  10057. {
  10058. name = "graphics",
  10059. description = "A graphics shader with a vertex and pixel stage."
  10060. },
  10061. {
  10062. name = "compute",
  10063. description = "A compute shader with a single compute stage."
  10064. }
  10065. }
  10066. },
  10067. {
  10068. name = "StackType",
  10069. summary = "Types of stacks that can be pushed and popped.",
  10070. description = "Different types of stacks that can be pushed and popped with `Pass:push` and `Pass:pop`.",
  10071. key = "StackType",
  10072. module = "lovr.graphics",
  10073. values = {
  10074. {
  10075. name = "transform",
  10076. description = "The transform stack (`Pass:transform`, `Pass:translate`, etc.)."
  10077. },
  10078. {
  10079. name = "state",
  10080. description = "Graphics state, like `Pass:setColor`, `Pass:setFont`, etc. Notably this does not include camera poses/projections or shader variables changed with `Pass:send`."
  10081. }
  10082. }
  10083. },
  10084. {
  10085. name = "StencilAction",
  10086. summary = "Different ways of updating the stencil buffer.",
  10087. description = "Different ways of updating the stencil buffer with `Pass:setStencilWrite`.",
  10088. key = "StencilAction",
  10089. module = "lovr.graphics",
  10090. related = {
  10091. "Pass:setStencilWrite",
  10092. "Pass:setStencilTest",
  10093. "Pass:setColorWrite"
  10094. },
  10095. values = {
  10096. {
  10097. name = "keep",
  10098. description = "Stencil buffer pixels will not be changed by draws."
  10099. },
  10100. {
  10101. name = "zero",
  10102. description = "Stencil buffer pixels will be set to zero."
  10103. },
  10104. {
  10105. name = "replace",
  10106. description = "Stencil buffer pixels will be replaced with a custom value."
  10107. },
  10108. {
  10109. name = "increment",
  10110. description = "Stencil buffer pixels will be incremented each time they're rendered to."
  10111. },
  10112. {
  10113. name = "decrement",
  10114. description = "Stencil buffer pixels will be decremented each time they're rendered to."
  10115. },
  10116. {
  10117. name = "incrementwrap",
  10118. description = "Similar to increment, but will wrap around to 0 when it exceeds 255."
  10119. },
  10120. {
  10121. name = "decrementwrap",
  10122. description = "Similar to decrement, but will wrap around to 255 when it goes below 0."
  10123. },
  10124. {
  10125. name = "invert",
  10126. description = "The bits in the stencil buffer pixels will be inverted."
  10127. }
  10128. }
  10129. },
  10130. {
  10131. name = "TextureFeature",
  10132. summary = "Different ways Textures can be used.",
  10133. description = "These are the different ways `Texture` objects can be used. These are passed in to `lovr.graphics.isFormatSupported` to see which texture operations are supported by the GPU for a given format.",
  10134. key = "TextureFeature",
  10135. module = "lovr.graphics",
  10136. values = {
  10137. {
  10138. name = "sample",
  10139. description = "The Texture can be sampled (e.g. a `texture2D` or `sampler2D` variable in shaders)."
  10140. },
  10141. {
  10142. name = "filter",
  10143. description = "The Texture can be used with a `Sampler` using a `FilterMode` of `linear`."
  10144. },
  10145. {
  10146. name = "render",
  10147. description = "The Texture can be rendered to by using it as a target in a render `Pass`."
  10148. },
  10149. {
  10150. name = "blend",
  10151. description = "Blending can be enabled when rendering to this format in a render pass."
  10152. },
  10153. {
  10154. name = "storage",
  10155. description = "The Texture can be sent to an image variable in shaders (e.g. `image2D`)."
  10156. },
  10157. {
  10158. name = "atomic",
  10159. description = "Atomic operations can be used on storage textures with this format."
  10160. },
  10161. {
  10162. name = "blitsrc",
  10163. description = "Source textures in `Pass:blit` can use this format."
  10164. },
  10165. {
  10166. name = "blitdst",
  10167. description = "Destination textures in `Pass:blit` can use this format."
  10168. }
  10169. }
  10170. },
  10171. {
  10172. name = "TextureType",
  10173. description = "Different types of textures. Textures are multidimensional blocks of GPU memory, and the texture's type determines how many dimensions there are, and adds some semantics about what the 3rd dimension means.",
  10174. key = "TextureType",
  10175. module = "lovr.graphics",
  10176. values = {
  10177. {
  10178. name = "2d",
  10179. description = "A single 2D image, the most common type."
  10180. },
  10181. {
  10182. name = "3d",
  10183. description = "A 3D image, where a sequence of 2D images defines a 3D volume. Each mipmap level of a 3D texture gets smaller in the x, y, and z axes, unlike cubemap and array textures."
  10184. },
  10185. {
  10186. name = "cube",
  10187. description = "Six square 2D images with the same dimensions that define the faces of a cubemap, used for skyboxes or other \"directional\" images."
  10188. },
  10189. {
  10190. name = "array",
  10191. description = "Array textures are sequences of distinct 2D images that all have the same dimensions."
  10192. }
  10193. }
  10194. },
  10195. {
  10196. name = "TextureUsage",
  10197. description = "These are the different things `Texture`s can be used for. When creating a Texture, a set of these flags can be provided, restricting what operations are allowed on the texture. Using a smaller set of flags may improve performance. If none are provided, the only usage flag applied is `sample`.",
  10198. key = "TextureUsage",
  10199. module = "lovr.graphics",
  10200. values = {
  10201. {
  10202. name = "sample",
  10203. description = "Whether the texture can be sampled from in Shaders (i.e. used in a material, or bound to a variable with a `texture` type, like `texture2D`)."
  10204. },
  10205. {
  10206. name = "render",
  10207. description = "Whether the texture can be rendered to (i.e. by using it as a render target in `lovr.graphics.pass`)."
  10208. },
  10209. {
  10210. name = "storage",
  10211. description = "Whether the texture can be used as a storage texture for compute operations (i.e. bound to a variable with an `image` type, like `image2D`)."
  10212. },
  10213. {
  10214. name = "transfer",
  10215. description = "Whether the texture can be used in a transfer pass."
  10216. }
  10217. }
  10218. },
  10219. {
  10220. name = "VerticalAlign",
  10221. summary = "Different ways to vertically align text.",
  10222. description = "Different ways to vertically align text with `Pass:text`.",
  10223. key = "VerticalAlign",
  10224. module = "lovr.graphics",
  10225. related = {
  10226. "HorizontalAlign",
  10227. "Pass:text",
  10228. "Font:getVertices"
  10229. },
  10230. values = {
  10231. {
  10232. name = "top",
  10233. description = "Top-aligned text."
  10234. },
  10235. {
  10236. name = "middle",
  10237. description = "Centered text."
  10238. },
  10239. {
  10240. name = "bottom",
  10241. description = "Bottom-aligned text."
  10242. }
  10243. }
  10244. },
  10245. {
  10246. name = "Winding",
  10247. summary = "Different triangle windings.",
  10248. description = "Indicates whether the front face of a triangle uses the clockwise or counterclockwise vertex order.",
  10249. key = "Winding",
  10250. module = "lovr.graphics",
  10251. related = {
  10252. "Pass:setWinding",
  10253. "Pass:setCullMode"
  10254. },
  10255. values = {
  10256. {
  10257. name = "clockwise",
  10258. description = "Clockwise winding."
  10259. },
  10260. {
  10261. name = "counterclockwise",
  10262. description = "Counterclockwise winding."
  10263. }
  10264. }
  10265. },
  10266. {
  10267. name = "WrapMode",
  10268. summary = "Different ways to wrap textures.",
  10269. description = "Controls how `Sampler` objects wrap textures.",
  10270. key = "WrapMode",
  10271. module = "lovr.graphics",
  10272. values = {
  10273. {
  10274. name = "clamp",
  10275. description = "Pixels will be clamped to the edge, with pixels outside the 0-1 uv range using colors from the nearest edge."
  10276. },
  10277. {
  10278. name = "repeat",
  10279. description = "Tiles the texture."
  10280. }
  10281. }
  10282. }
  10283. },
  10284. functions = {
  10285. {
  10286. name = "compileShader",
  10287. tag = "graphics-objects",
  10288. summary = "Compile shader code to bytecode.",
  10289. description = "Compiles shader code to SPIR-V bytecode. The bytecode can be passed to `lovr.graphics.newShader` to create shaders, which will be faster than creating it from GLSL. The bytecode is portable, so bytecode compiled on one platform will work on other platforms. This allows shaders to be precompiled in a build step.",
  10290. key = "lovr.graphics.compileShader",
  10291. module = "lovr.graphics",
  10292. notes = "The input can be GLSL or SPIR-V. If it's SPIR-V, it will be returned unchanged as a Blob.\n\nIf the shader fails to compile, an error will be thrown with the error message.",
  10293. related = {
  10294. "lovr.graphics.newShader",
  10295. "Shader"
  10296. },
  10297. variants = {
  10298. {
  10299. arguments = {
  10300. {
  10301. name = "stage",
  10302. type = "ShaderStage",
  10303. description = "The type of shader to compile."
  10304. },
  10305. {
  10306. name = "source",
  10307. type = "string",
  10308. description = "A string or filename with shader code."
  10309. }
  10310. },
  10311. returns = {
  10312. {
  10313. name = "bytecode",
  10314. type = "Blob",
  10315. description = "A Blob containing compiled SPIR-V code."
  10316. }
  10317. }
  10318. },
  10319. {
  10320. arguments = {
  10321. {
  10322. name = "stage",
  10323. type = "ShaderStage",
  10324. description = "The type of shader to compile."
  10325. },
  10326. {
  10327. name = "blob",
  10328. type = "Blob",
  10329. description = "A Blob containing shader code."
  10330. }
  10331. },
  10332. returns = {
  10333. {
  10334. name = "bytecode",
  10335. type = "Blob",
  10336. description = "A Blob containing compiled SPIR-V code."
  10337. }
  10338. }
  10339. }
  10340. }
  10341. },
  10342. {
  10343. name = "getBackgroundColor",
  10344. tag = "graphics-global",
  10345. summary = "Get the background color.",
  10346. description = "Returns the global background color. The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified. Additionally, the headset and window will be cleared to this color before rendering.",
  10347. key = "lovr.graphics.getBackgroundColor",
  10348. module = "lovr.graphics",
  10349. notes = "Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called.\n\nInternally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getWindowPass`. Both are called automatically by the default `lovr.run` implementation.\n\nUsing the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.",
  10350. related = {
  10351. "lovr.graphics.newPass",
  10352. "Pass:setClear",
  10353. "Texture:clear",
  10354. "Pass:fill"
  10355. },
  10356. variants = {
  10357. {
  10358. arguments = {},
  10359. returns = {
  10360. {
  10361. name = "r",
  10362. type = "number",
  10363. description = "The red component of the background color."
  10364. },
  10365. {
  10366. name = "g",
  10367. type = "number",
  10368. description = "The green component of the background color."
  10369. },
  10370. {
  10371. name = "b",
  10372. type = "number",
  10373. description = "The blue component of the background color."
  10374. },
  10375. {
  10376. name = "a",
  10377. type = "number",
  10378. description = "The alpha component of the background color."
  10379. }
  10380. }
  10381. }
  10382. }
  10383. },
  10384. {
  10385. name = "getBuffer",
  10386. tag = "graphics-objects",
  10387. summary = "Get a temporary Buffer.",
  10388. description = "Returns a temporary Buffer.",
  10389. key = "lovr.graphics.getBuffer",
  10390. module = "lovr.graphics",
  10391. deprecated = true,
  10392. examples = {
  10393. {
  10394. description = "Examples of different buffer formats.",
  10395. code = "-- 2 matrices\nlovr.graphics.getBuffer('mat4', 2)\n\n-- 3 integers, with initial data\nlovr.graphics.getBuffer('int', { 1, 2, 3 })\n\n-- a simple mesh:\nlovr.graphics.getBuffer({\n { name = 'VertexPosition', type = 'vec3' },\n { name = 'VertexColor', type = 'color' }\n}, 4)\n\n-- a uniform buffer with vec3's, using the std140 packing\nlovr.graphics.getBuffer({ 'vec3', layout = 'std140' }, data)\n\n-- a uniform buffer with key-value fields\nlovr.graphics.getBuffer({\n { 'AmbientColor', 'vec3' },\n { 'LightPosition', 'vec3' },\n { 'LightType', 'u32' },\n { 'LightColor', 'vec4' },\n layout = 'std140'\n})\n\n-- a buffer with nested structure and array types\nlovr.graphics.getBuffer({\n { 'globals', {\n { 'ObjectCount', 'int' },\n { 'WorldSize', 'vec2' },\n { 'Scale', 'float' }\n }},\n { 'materials', {\n { 'Color', 'vec4' },\n { 'Glow', 'vec3' },\n { 'Roughness', 'float' }\n }, length = 32 },\n layout = 'std430'\n})\n\n-- a buffer using a variable from a shader:\nlovr.graphics.getBuffer(shader:getBufferFormat('transforms'))"
  10396. }
  10397. },
  10398. notes = "The format table can contain a list of `DataType`s or a list of tables to provide extra information about each field. Each inner table has the following keys:\n\n- `type` is the `DataType` of the field and is required.\n- `name` is the name of the field, used to match table keys and vertex attribute names.\n- `offset` is the byte offset of the field. Any fields with a `nil` offset will be placed next\n to each other sequentially in memory, subject to any padding required by the Buffer's layout.\n In practice this means that you probably want to provide an `offset` for either all of the\n fields or none of them.\n- `length` is the array size of the field.\n\nAs a shorthand, the name, type, and optionally the length of a field can be provided as a list instead of using keys.\n\nIf no table or Blob is used to define the initial Buffer contents, its data will be undefined.",
  10399. variants = {
  10400. {
  10401. arguments = {
  10402. {
  10403. name = "size",
  10404. type = "number",
  10405. description = "The size of the Buffer, in bytes."
  10406. }
  10407. },
  10408. returns = {
  10409. {
  10410. name = "buffer",
  10411. type = "Buffer",
  10412. description = "The new Buffer."
  10413. }
  10414. }
  10415. },
  10416. {
  10417. arguments = {
  10418. {
  10419. name = "blob",
  10420. type = "Blob",
  10421. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  10422. }
  10423. },
  10424. returns = {
  10425. {
  10426. name = "buffer",
  10427. type = "Buffer",
  10428. description = "The new Buffer."
  10429. }
  10430. }
  10431. },
  10432. {
  10433. arguments = {
  10434. {
  10435. name = "format",
  10436. type = "table",
  10437. description = "A list of fields in the Buffer.",
  10438. table = {
  10439. {
  10440. name = "layout",
  10441. type = "DataLayout",
  10442. description = "How to lay out the Buffer fields in memory.",
  10443. default = "packed"
  10444. },
  10445. {
  10446. name = "stride",
  10447. type = "number",
  10448. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  10449. }
  10450. }
  10451. },
  10452. {
  10453. name = "length",
  10454. type = "number",
  10455. description = "The length of the Buffer.",
  10456. default = "1"
  10457. }
  10458. },
  10459. returns = {
  10460. {
  10461. name = "buffer",
  10462. type = "Buffer",
  10463. description = "The new Buffer."
  10464. }
  10465. }
  10466. },
  10467. {
  10468. arguments = {
  10469. {
  10470. name = "format",
  10471. type = "table",
  10472. description = "A list of fields in the Buffer.",
  10473. table = {
  10474. {
  10475. name = "layout",
  10476. type = "DataLayout",
  10477. description = "How to lay out the Buffer fields in memory.",
  10478. default = "packed"
  10479. },
  10480. {
  10481. name = "stride",
  10482. type = "number",
  10483. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  10484. }
  10485. }
  10486. },
  10487. {
  10488. name = "data",
  10489. type = "table",
  10490. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  10491. }
  10492. },
  10493. returns = {
  10494. {
  10495. name = "buffer",
  10496. type = "Buffer",
  10497. description = "The new Buffer."
  10498. }
  10499. }
  10500. },
  10501. {
  10502. arguments = {
  10503. {
  10504. name = "format",
  10505. type = "table",
  10506. description = "A list of fields in the Buffer.",
  10507. table = {
  10508. {
  10509. name = "layout",
  10510. type = "DataLayout",
  10511. description = "How to lay out the Buffer fields in memory.",
  10512. default = "packed"
  10513. },
  10514. {
  10515. name = "stride",
  10516. type = "number",
  10517. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  10518. }
  10519. }
  10520. },
  10521. {
  10522. name = "blob",
  10523. type = "Blob",
  10524. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  10525. }
  10526. },
  10527. returns = {
  10528. {
  10529. name = "buffer",
  10530. type = "Buffer",
  10531. description = "The new Buffer."
  10532. }
  10533. }
  10534. },
  10535. {
  10536. arguments = {
  10537. {
  10538. name = "type",
  10539. type = "DataType",
  10540. description = "The type of each item in the Buffer."
  10541. },
  10542. {
  10543. name = "length",
  10544. type = "number",
  10545. description = "The length of the Buffer.",
  10546. default = "1"
  10547. }
  10548. },
  10549. returns = {
  10550. {
  10551. name = "buffer",
  10552. type = "Buffer",
  10553. description = "The new Buffer."
  10554. }
  10555. }
  10556. },
  10557. {
  10558. arguments = {
  10559. {
  10560. name = "type",
  10561. type = "DataType",
  10562. description = "The type of each item in the Buffer."
  10563. },
  10564. {
  10565. name = "data",
  10566. type = "table",
  10567. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  10568. }
  10569. },
  10570. returns = {
  10571. {
  10572. name = "buffer",
  10573. type = "Buffer",
  10574. description = "The new Buffer."
  10575. }
  10576. }
  10577. },
  10578. {
  10579. arguments = {
  10580. {
  10581. name = "type",
  10582. type = "DataType",
  10583. description = "The type of each item in the Buffer."
  10584. },
  10585. {
  10586. name = "blob",
  10587. type = "Blob",
  10588. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  10589. }
  10590. },
  10591. returns = {
  10592. {
  10593. name = "buffer",
  10594. type = "Buffer",
  10595. description = "The new Buffer."
  10596. }
  10597. }
  10598. },
  10599. {
  10600. arguments = {
  10601. {
  10602. name = "length",
  10603. type = "number",
  10604. description = "The length of the Buffer.",
  10605. default = "1"
  10606. },
  10607. {
  10608. name = "type",
  10609. type = "DataType",
  10610. description = "The type of each item in the Buffer."
  10611. }
  10612. },
  10613. returns = {
  10614. {
  10615. name = "buffer",
  10616. type = "Buffer",
  10617. description = "The new Buffer."
  10618. }
  10619. },
  10620. deprecated = true
  10621. },
  10622. {
  10623. arguments = {
  10624. {
  10625. name = "data",
  10626. type = "table",
  10627. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  10628. },
  10629. {
  10630. name = "type",
  10631. type = "DataType",
  10632. description = "The type of each item in the Buffer."
  10633. }
  10634. },
  10635. returns = {
  10636. {
  10637. name = "buffer",
  10638. type = "Buffer",
  10639. description = "The new Buffer."
  10640. }
  10641. },
  10642. deprecated = true
  10643. },
  10644. {
  10645. arguments = {
  10646. {
  10647. name = "length",
  10648. type = "number",
  10649. description = "The length of the Buffer.",
  10650. default = "1"
  10651. },
  10652. {
  10653. name = "format",
  10654. type = "table",
  10655. description = "A list of fields in the Buffer.",
  10656. table = {
  10657. {
  10658. name = "layout",
  10659. type = "DataLayout",
  10660. description = "How to lay out the Buffer fields in memory.",
  10661. default = "packed"
  10662. },
  10663. {
  10664. name = "stride",
  10665. type = "number",
  10666. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  10667. }
  10668. }
  10669. }
  10670. },
  10671. returns = {
  10672. {
  10673. name = "buffer",
  10674. type = "Buffer",
  10675. description = "The new Buffer."
  10676. }
  10677. },
  10678. deprecated = true
  10679. },
  10680. {
  10681. arguments = {
  10682. {
  10683. name = "data",
  10684. type = "table",
  10685. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  10686. },
  10687. {
  10688. name = "format",
  10689. type = "table",
  10690. description = "A list of fields in the Buffer.",
  10691. table = {
  10692. {
  10693. name = "layout",
  10694. type = "DataLayout",
  10695. description = "How to lay out the Buffer fields in memory.",
  10696. default = "packed"
  10697. },
  10698. {
  10699. name = "stride",
  10700. type = "number",
  10701. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  10702. }
  10703. }
  10704. }
  10705. },
  10706. returns = {
  10707. {
  10708. name = "buffer",
  10709. type = "Buffer",
  10710. description = "The new Buffer."
  10711. }
  10712. },
  10713. deprecated = true
  10714. },
  10715. {
  10716. arguments = {
  10717. {
  10718. name = "blob",
  10719. type = "Blob",
  10720. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  10721. },
  10722. {
  10723. name = "type",
  10724. type = "DataType",
  10725. description = "The type of each item in the Buffer."
  10726. }
  10727. },
  10728. returns = {
  10729. {
  10730. name = "buffer",
  10731. type = "Buffer",
  10732. description = "The new Buffer."
  10733. }
  10734. },
  10735. deprecated = true
  10736. },
  10737. {
  10738. arguments = {
  10739. {
  10740. name = "blob",
  10741. type = "Blob",
  10742. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  10743. },
  10744. {
  10745. name = "format",
  10746. type = "table",
  10747. description = "A list of fields in the Buffer.",
  10748. table = {
  10749. {
  10750. name = "layout",
  10751. type = "DataLayout",
  10752. description = "How to lay out the Buffer fields in memory.",
  10753. default = "packed"
  10754. },
  10755. {
  10756. name = "stride",
  10757. type = "number",
  10758. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  10759. }
  10760. }
  10761. }
  10762. },
  10763. returns = {
  10764. {
  10765. name = "buffer",
  10766. type = "Buffer",
  10767. description = "The new Buffer."
  10768. }
  10769. },
  10770. deprecated = true
  10771. }
  10772. }
  10773. },
  10774. {
  10775. name = "getDefaultFont",
  10776. tag = "graphics-objects",
  10777. summary = "Get the default Font.",
  10778. description = "Returns the default Font. The default font is Varela Round, created at 32px with a spread value of `4.0`. It's used by `Pass:text` if no Font is provided.",
  10779. key = "lovr.graphics.getDefaultFont",
  10780. module = "lovr.graphics",
  10781. related = {
  10782. "Pass:text",
  10783. "lovr.graphics.newFont"
  10784. },
  10785. variants = {
  10786. {
  10787. arguments = {},
  10788. returns = {
  10789. {
  10790. name = "font",
  10791. type = "Font",
  10792. description = "The default Font object."
  10793. }
  10794. }
  10795. }
  10796. }
  10797. },
  10798. {
  10799. name = "getDevice",
  10800. tag = "graphics-misc",
  10801. summary = "Get information about the graphics device and driver.",
  10802. description = "Returns information about the graphics device and driver.",
  10803. key = "lovr.graphics.getDevice",
  10804. module = "lovr.graphics",
  10805. notes = "The device and vendor ID numbers will usually be PCI IDs, which are standardized numbers consisting of 4 hex digits. Various online databases and system utilities can be used to look up these numbers. Here are some example vendor IDs for a few popular GPU manufacturers:\n\n<table>\n <thead>\n <tr>\n <td>ID</td>\n <td>Vendor</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><code>0x1002</code></td>\n <td>Advanced Micro Devices, Inc.</td>\n </tr>\n <tr>\n <td><code>0x8086</code></td>\n <td>Intel Corporation</td>\n </tr>\n <tr>\n <td><code>0x10de</code></td>\n <td>NVIDIA Corporation</td>\n </tr>\n </tbody> </table>\n\nIt is not currently possible to get the version of the driver, although this could be added.\n\nRegarding multiple GPUs: If OpenXR is enabled, the OpenXR runtime has control over which GPU is used, which ensures best compatibility with the VR headset. Otherwise, the \"first\" GPU returned by the renderer will be used. There is currently no other way to pick a GPU to use.",
  10806. related = {
  10807. "lovr.graphics.getFeatures",
  10808. "lovr.graphics.getLimits"
  10809. },
  10810. variants = {
  10811. {
  10812. arguments = {},
  10813. returns = {
  10814. {
  10815. name = "device",
  10816. type = "table",
  10817. table = {
  10818. {
  10819. name = "id",
  10820. type = "number",
  10821. description = "The vendor-unique number for this GPU."
  10822. },
  10823. {
  10824. name = "vendor",
  10825. type = "number",
  10826. description = "The identifier of the GPU vendor."
  10827. },
  10828. {
  10829. name = "name",
  10830. type = "string",
  10831. description = "The name of the GPU."
  10832. },
  10833. {
  10834. name = "renderer",
  10835. type = "string",
  10836. description = "The renderer in use, currently either \"Vulkan\" or \"WebGPU\"."
  10837. },
  10838. {
  10839. name = "subgroupSize",
  10840. type = "number",
  10841. description = "The number of threads that run in a single GPU compute unit. This is usually 32 or 64, and is sometimes called the \"wave\" or \"warp\" size. This can be used to optimize compute shaders for the current hardware."
  10842. },
  10843. {
  10844. name = "discrete",
  10845. type = "boolean",
  10846. description = "Whether the GPU is a discrete graphics card."
  10847. }
  10848. }
  10849. }
  10850. }
  10851. }
  10852. }
  10853. },
  10854. {
  10855. name = "getFeatures",
  10856. tag = "graphics-misc",
  10857. summary = "Get the supported GPU features.",
  10858. description = "Returns a table indicating which features are supported by the GPU.",
  10859. key = "lovr.graphics.getFeatures",
  10860. module = "lovr.graphics",
  10861. related = {
  10862. "lovr.graphics.isFormatSupported",
  10863. "lovr.graphics.getDevice",
  10864. "lovr.graphics.getLimits"
  10865. },
  10866. variants = {
  10867. {
  10868. arguments = {},
  10869. returns = {
  10870. {
  10871. name = "features",
  10872. type = "table",
  10873. description = "",
  10874. table = {
  10875. {
  10876. name = "textureBC",
  10877. type = "boolean",
  10878. description = "Whether `TextureFormat`s starting with `bc` are supported. This will almost always be `true` on desktop GPUs and will almost always be `false` on mobile GPUs."
  10879. },
  10880. {
  10881. name = "textureASTC",
  10882. type = "boolean",
  10883. description = "Whether `TextureFormat`s beginning with `astc` are supported. This will almost always be `true` on mobile GPUs and will almost always be `false` on desktop GPUs."
  10884. },
  10885. {
  10886. name = "wireframe",
  10887. type = "boolean",
  10888. description = "When supported, `Pass:setWireframe` will work, otherwise it will do nothing. This will always be `true` when using Vulkan, and will always be `false` when using WebGPU."
  10889. },
  10890. {
  10891. name = "depthClamp",
  10892. type = "boolean",
  10893. description = "When supported, `Pass:setDepthClamp` will work, otherwise it will do nothing."
  10894. },
  10895. {
  10896. name = "depthResolve",
  10897. type = "boolean",
  10898. description = "When supported, multisampled render passes can use a non-multisampled depth texture. Otherwise, the depth texture sample count needs to match the render pass sample count."
  10899. },
  10900. {
  10901. name = "indirectDrawFirstInstance",
  10902. type = "boolean",
  10903. description = "Whether indirect draws can set the firstInstance property of buffer memory to something other than zero."
  10904. },
  10905. {
  10906. name = "float64",
  10907. type = "boolean",
  10908. description = "Whether shader code can use doubles."
  10909. },
  10910. {
  10911. name = "int64",
  10912. type = "boolean",
  10913. description = "Whether shader code can use signed and unsigned 64-bit integers."
  10914. },
  10915. {
  10916. name = "int16",
  10917. type = "boolean",
  10918. description = "Whether shader code can use signed and unsigned 16-bit integers."
  10919. }
  10920. }
  10921. }
  10922. }
  10923. }
  10924. }
  10925. },
  10926. {
  10927. name = "getLimits",
  10928. tag = "graphics-misc",
  10929. summary = "Get the limits of the current GPU.",
  10930. description = "Returns limits of the current GPU.",
  10931. key = "lovr.graphics.getLimits",
  10932. module = "lovr.graphics",
  10933. notes = "The limit ranges are as follows:\n\n<table>\n <thead>\n <tr>\n <td>Limit</td>\n <td>Minimum</td>\n <td>Maximum</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><code>textureSize2D</code></td>\n <td>4096</td>\n <td></td>\n </tr>\n <tr>\n <td><code>textureSize3D</code></td>\n <td>256</td>\n <td></td>\n </tr>\n <tr>\n <td><code>textureSizeCube</code></td>\n <td>4096</td>\n <td></td>\n </tr>\n <tr>\n <td><code>textureLayers</code></td>\n <td>256</td>\n <td></td>\n </tr>\n <tr>\n <td><code>renderSize</code></td>\n <td>{ 4096, 4096, 6 }</td>\n <td></td>\n </tr>\n <tr>\n <td><code>uniformBuffersPerStage</code></td>\n <td>9</td>\n <td>32*</td>\n </tr>\n <tr>\n <td><code>storageBuffersPerStage</code></td>\n <td>4</td>\n <td>32*</td>\n </tr>\n <tr>\n <td><code>sampledTexturesPerStage</code></td>\n <td>32</td>\n <td>32*</td>\n </tr>\n <tr>\n <td><code>storageTexturesPerStage</code></td>\n <td>4</td>\n <td>32*</td>\n </tr>\n <tr>\n <td><code>samplersPerStage</code></td>\n <td>15</td>\n <td>32*</td>\n </tr>\n <tr>\n <td><code>resourcesPerShader</code></td>\n <td>32</td>\n <td>32*</td>\n </tr>\n <tr>\n <td><code>uniformBufferRange</code></td>\n <td>65536</td>\n <td></td>\n </tr>\n <tr>\n <td><code>storageBufferRange</code></td>\n <td>134217728 (128MB)</td>\n <td>1073741824 (1GB)*</td>\n </tr>\n <tr>\n <td><code>uniformBufferAlign</code></td>\n <td></td>\n <td>256</td>\n </tr>\n <tr>\n <td><code>storageBufferAlign</code></td>\n <td></td>\n <td>64</td>\n </tr>\n <tr>\n <td><code>vertexAttributes</code></td>\n <td>16</td>\n <td>16*</td>\n </tr>\n <tr>\n <td><code>vertexBufferStride</code></td>\n <td>2048</td>\n <td>65535*</td>\n </tr>\n <tr>\n <td><code>vertexShaderOutputs</code></td>\n <td>64</td>\n <td></td>\n </tr>\n <tr>\n <td><code>clipDistances</code></td>\n <td>0</td>\n <td></td>\n </tr>\n <tr>\n <td><code>cullDistances</code></td>\n <td>0</td>\n <td></td>\n </tr>\n <tr>\n <td><code>clipAndCullDistances</code></td>\n <td>0</td>\n <td></td>\n </tr>\n <tr>\n <td><code>computeDispatchCount</code></td>\n <td>{ 65536, 65536, 65536 }</td>\n <td></td>\n </tr>\n <tr>\n <td><code>computeWorkgroupSize</code></td>\n <td>{ 128, 128, 64 }</td>\n <td></td>\n </tr>\n <tr>\n <td><code>computeWorkgroupVolume</code></td>\n <td>128</td>\n <td></td>\n </tr>\n <tr>\n <td><code>computeSharedMemory</code></td>\n <td>16384 (16KB)</td>\n <td></td>\n </tr>\n <tr>\n <td><code>pushConstantSize</code></td>\n <td>128</td>\n <td>256*</td>\n </tr>\n <tr>\n <td><code>indirectDrawCount</code></td>\n <td>1</td>\n <td></td>\n </tr>\n <tr>\n <td><code>instances</code></td>\n <td>134217727</td>\n <td></td>\n </tr>\n <tr>\n <td><code>anisotropy</code></td>\n <td>0.0</td>\n <td></td>\n </tr>\n <tr>\n <td><code>pointSize</code></td>\n <td>1.0</td>\n <td></td>\n </tr>\n </tbody> </table>\n\nNote: in the table above, `*` means that LÖVR itself is imposing a cap on the limit, instead of the GPU.",
  10934. related = {
  10935. "lovr.graphics.isFormatSupported",
  10936. "lovr.graphics.getDevice",
  10937. "lovr.graphics.getFeatures"
  10938. },
  10939. variants = {
  10940. {
  10941. arguments = {},
  10942. returns = {
  10943. {
  10944. name = "limits",
  10945. type = "table",
  10946. description = "",
  10947. table = {
  10948. {
  10949. name = "textureSize2D",
  10950. type = "number",
  10951. description = "The maximum width/height of `2d` and `array` textures."
  10952. },
  10953. {
  10954. name = "textureSize3D",
  10955. type = "number",
  10956. description = "The maximum width/height/depth of `3d` textures."
  10957. },
  10958. {
  10959. name = "textureSizeCube",
  10960. type = "number",
  10961. description = "The maximum width/height of `cube` textures."
  10962. },
  10963. {
  10964. name = "textureLayers",
  10965. type = "number",
  10966. description = "The maximum depth of `array` textures."
  10967. },
  10968. {
  10969. name = "renderSize",
  10970. type = "table",
  10971. description = "The maximum width, height, and layer count of a texture (or texture view) used as a render target."
  10972. },
  10973. {
  10974. name = "uniformBuffersPerStage",
  10975. type = "number",
  10976. description = "The maximum number of uniform buffers in a shader stage."
  10977. },
  10978. {
  10979. name = "storageBuffersPerStage",
  10980. type = "number",
  10981. description = "The maximum number of storage buffers in a shader stage."
  10982. },
  10983. {
  10984. name = "sampledTexturesPerStage",
  10985. type = "number",
  10986. description = "The maximum number of sampled textures in a shader stage."
  10987. },
  10988. {
  10989. name = "storageTexturesPerStage",
  10990. type = "number",
  10991. description = "The maximum number of storage textures in a shader stage."
  10992. },
  10993. {
  10994. name = "samplersPerStage",
  10995. type = "number",
  10996. description = "The maximum number of samplers in a shader stage."
  10997. },
  10998. {
  10999. name = "resourcesPerShader",
  11000. type = "number",
  11001. description = "The maximum combined number of buffers, textures, and sampler variables in a Shader."
  11002. },
  11003. {
  11004. name = "uniformBufferRange",
  11005. type = "number",
  11006. description = "The maximum range of bytes that can be bound to a uniform buffer in a shader."
  11007. },
  11008. {
  11009. name = "storageBufferRange",
  11010. type = "number",
  11011. description = "The maximum range of bytes that can be bound to a storage buffer in a shader."
  11012. },
  11013. {
  11014. name = "uniformBufferAlign",
  11015. type = "number",
  11016. description = "When binding a range of bytes to a uniform buffer binding in a shader, the byte offset of the range must be a multiple of this limit's value."
  11017. },
  11018. {
  11019. name = "storageBufferAlign",
  11020. type = "number",
  11021. description = "When binding a range of bytes to a storage buffer binding in a shader, the byte offset of the range must be a multiple of this limit's value."
  11022. },
  11023. {
  11024. name = "vertexAttributes",
  11025. type = "number",
  11026. description = "The maximum number of input attributes in a vertex shader."
  11027. },
  11028. {
  11029. name = "vertexBufferStride",
  11030. type = "number",
  11031. description = "The maximum stride of a buffer used as a vertex buffer, in bytes."
  11032. },
  11033. {
  11034. name = "vertexShaderOutputs",
  11035. type = "number",
  11036. description = "The maximum number of components output from a vertex shader."
  11037. },
  11038. {
  11039. name = "clipDistances",
  11040. type = "number",
  11041. description = "The maximum number of clipping planes declared by a shader."
  11042. },
  11043. {
  11044. name = "cullDistances",
  11045. type = "number",
  11046. description = "The maximum number of cull distances declared by a shader."
  11047. },
  11048. {
  11049. name = "clipAndCullDistances",
  11050. type = "number",
  11051. description = "The maximum number of clipping planes and cull distances declared by a shader."
  11052. },
  11053. {
  11054. name = "workgroupCount",
  11055. type = "table",
  11056. description = "The maximum values of `x`, `y`, and `z` in `Pass:compute`."
  11057. },
  11058. {
  11059. name = "workgroupSize",
  11060. type = "table",
  11061. description = "The maximum values of `local_size_x`, `local_size_y`, and `local_size_z` declared in a compute shader."
  11062. },
  11063. {
  11064. name = "totalWorkgroupSize",
  11065. type = "number",
  11066. description = "The maximum product of `local_size_x`, `local_size_y`, and `local_size_z` in a compute shader."
  11067. },
  11068. {
  11069. name = "computeSharedMemory",
  11070. type = "number",
  11071. description = "The maximum number of bytes used by `shared` variables in compute shaders."
  11072. },
  11073. {
  11074. name = "shaderConstantSize",
  11075. type = "number",
  11076. description = "The maximum number of bytes of push constants that can be in a Shader. Push constants are shared between stages, so the stage with the largest amount of push constant data will count towards this limit."
  11077. },
  11078. {
  11079. name = "indirectDrawCount",
  11080. type = "number",
  11081. description = "The maximum number of draws that can be issued by an indirect draw call."
  11082. },
  11083. {
  11084. name = "instances",
  11085. type = "number",
  11086. description = "The maximum number of instances that can be rendered in a draw call."
  11087. },
  11088. {
  11089. name = "anisotropy",
  11090. type = "number",
  11091. description = "The maximum value of the `anisotropy` parameter in `lovr.graphics.newSampler`."
  11092. },
  11093. {
  11094. name = "pointSize",
  11095. type = "number",
  11096. description = "The maximum point size."
  11097. }
  11098. }
  11099. }
  11100. }
  11101. }
  11102. }
  11103. },
  11104. {
  11105. name = "getPass",
  11106. tag = "graphics-objects",
  11107. summary = "Get a temporary Pass.",
  11108. description = "Creates and returns a temporary Pass object.",
  11109. key = "lovr.graphics.getPass",
  11110. module = "lovr.graphics",
  11111. deprecated = true,
  11112. notes = "Fun facts about render passes:\n\n- Textures must have been created with the `render` `TextureUsage`.\n- Textures must have the same dimensions, layer counts, and sample counts.\n- When rendering to textures with multiple layers, each draw will be broadcast to all layers.\n Render passes have multiple \"views\" (cameras), and each layer uses a corresponding view,\n allowing each layer to be rendered from a different viewpoint. This enables fast stereo\n rendering, but can also be used to efficiently render to cubemaps. The `ViewIndex` variable\n can also be used in shaders to set up any desired per-view behavior.\n- Mipmaps will automatically be generated for textures at the end of the render pass.\n- It's okay to have zero color textures, but in this case there must be a depth texture.\n- It's possible to render to a specific mipmap level of a Texture, or a subset of its layers, by\n rendering to texture views, see `Texture:newView`.\n\nFor `compute` passes, all of the commands in the pass act as though they run in parallel. This means that writing to the same element of a buffer twice, or writing to it and reading from it again is not guaranteed to work properly on all GPUs. If compute or transfers need to be sequenced, multiple passes should be used. It is, however, completely fine to read and write to non-overlapping regions of the same buffer or texture.",
  11113. related = {
  11114. "lovr.graphics.submit",
  11115. "lovr.graphics.getWindowPass",
  11116. "lovr.headset.getPass"
  11117. },
  11118. variants = {
  11119. {
  11120. description = "Create a compute pass.",
  11121. arguments = {
  11122. {
  11123. name = "type",
  11124. type = "PassType",
  11125. description = "The type of pass to create."
  11126. }
  11127. },
  11128. returns = {
  11129. {
  11130. name = "pass",
  11131. type = "Pass",
  11132. description = "The new Pass."
  11133. }
  11134. }
  11135. },
  11136. {
  11137. description = "Create a render pass.",
  11138. arguments = {
  11139. {
  11140. name = "type",
  11141. type = "PassType",
  11142. description = "The type of pass to create."
  11143. },
  11144. {
  11145. name = "texture",
  11146. type = "Texture",
  11147. description = "The texture the render pass will render to. Ignored for non-render passes."
  11148. }
  11149. },
  11150. returns = {
  11151. {
  11152. name = "pass",
  11153. type = "Pass",
  11154. description = "The new Pass."
  11155. }
  11156. }
  11157. },
  11158. {
  11159. description = "Create a render pass, with options.",
  11160. arguments = {
  11161. {
  11162. name = "type",
  11163. type = "PassType",
  11164. description = "The type of pass to create."
  11165. },
  11166. {
  11167. name = "canvas",
  11168. type = "table",
  11169. description = "Render pass configuration. Up to 4 textures can be provided in table keys 1 through 4. Ignored for non-render passes.",
  11170. table = {
  11171. {
  11172. name = "depth",
  11173. type = "table",
  11174. description = "Depth/stencil buffer configuration. In addition to a table, it can be a `Texture`, a `TextureFormat`, or `false` to disable the depth buffer.",
  11175. table = {
  11176. {
  11177. name = "format",
  11178. type = "TextureFormat",
  11179. description = "The format of the depth buffer texture, which must be a depth format (the ones that start with `d`). LÖVR will create or reuse an internal depth buffer with this format.",
  11180. default = "'d32f'"
  11181. },
  11182. {
  11183. name = "texture",
  11184. type = "Texture",
  11185. description = "A Texture to use as the depth buffer. Takes precedence over `format`."
  11186. }
  11187. }
  11188. },
  11189. {
  11190. name = "samples",
  11191. type = "number",
  11192. description = "The number of multisamples to use. Can be 4 for antialiasing, or 1 to disable antialiasing.",
  11193. default = "4"
  11194. }
  11195. }
  11196. }
  11197. },
  11198. returns = {
  11199. {
  11200. name = "pass",
  11201. type = "Pass",
  11202. description = "The new Pass."
  11203. }
  11204. }
  11205. }
  11206. }
  11207. },
  11208. {
  11209. name = "getWindowPass",
  11210. tag = "graphics-objects",
  11211. summary = "Get the window pass.",
  11212. description = "Returns the window pass. This is a builtin render `Pass` object that renders to the desktop window texture. If the desktop window was not open when the graphics module was initialized, this function will return `nil`.",
  11213. key = "lovr.graphics.getWindowPass",
  11214. module = "lovr.graphics",
  11215. notes = "`lovr.conf` may be used to change the settings for the pass: `t.graphics.antialias` enables antialiasing, and `t.graphics.stencil` enables the stencil buffer.\n\nThis pass clears the window texture to the background color, which can be changed using `lovr.graphics.setBackgroundColor`.",
  11216. variants = {
  11217. {
  11218. arguments = {},
  11219. returns = {
  11220. {
  11221. name = "pass",
  11222. type = "Pass",
  11223. description = "The window pass, or `nil` if there is no window."
  11224. }
  11225. }
  11226. }
  11227. }
  11228. },
  11229. {
  11230. name = "isFormatSupported",
  11231. tag = "graphics-misc",
  11232. summary = "Check if a Texture format is supported.",
  11233. description = "Returns the type of operations the GPU supports for a texture format, if any.",
  11234. key = "lovr.graphics.isFormatSupported",
  11235. module = "lovr.graphics",
  11236. related = {
  11237. "lovr.graphics.getDevice",
  11238. "lovr.graphics.getFeatures",
  11239. "lovr.graphics.getLimits"
  11240. },
  11241. variants = {
  11242. {
  11243. arguments = {
  11244. {
  11245. name = "format",
  11246. type = "TextureFormat",
  11247. description = "The texture format to query."
  11248. },
  11249. {
  11250. name = "...features",
  11251. type = "TextureFeature",
  11252. description = "Zero or more features to check. If no features are given, this function will return whether the GPU supports *any* feature for this format. Otherwise, this function will only return true if *all* of the input features are supported."
  11253. }
  11254. },
  11255. returns = {
  11256. {
  11257. name = "linear",
  11258. type = "boolean",
  11259. description = "Whether the GPU supports these operations for textures with this format, when created with the `linear` flag set to `true`."
  11260. },
  11261. {
  11262. name = "srgb",
  11263. type = "boolean",
  11264. description = "Whether the GPU supports these operations for textures with this format, when created with the `linear` flag set to `false`."
  11265. }
  11266. }
  11267. }
  11268. }
  11269. },
  11270. {
  11271. name = "isTimingEnabled",
  11272. tag = "graphics-global",
  11273. summary = "Check if timing stats are enabled.",
  11274. description = "Returns whether timing stats are enabled. When enabled, `Pass:getStats` will return `submitTime` and `gpuTime` durations. Timing is enabled by default when `t.graphics.debug` is set in `lovr.conf`. Timing has a small amount of overhead, so it should only be enabled when needed.",
  11275. key = "lovr.graphics.isTimingEnabled",
  11276. module = "lovr.graphics",
  11277. related = {
  11278. "Pass:getStats"
  11279. },
  11280. variants = {
  11281. {
  11282. arguments = {},
  11283. returns = {
  11284. {
  11285. name = "enabled",
  11286. type = "boolean",
  11287. description = "Whether timing is enabled."
  11288. }
  11289. }
  11290. }
  11291. }
  11292. },
  11293. {
  11294. name = "newBuffer",
  11295. tag = "graphics-objects",
  11296. summary = "Create a new Buffer.",
  11297. description = "Creates a Buffer.",
  11298. key = "lovr.graphics.newBuffer",
  11299. module = "lovr.graphics",
  11300. examples = {
  11301. {
  11302. description = "Examples of different buffer formats.",
  11303. code = "-- 2 matrices\nlovr.graphics.newBuffer('mat4', 2)\n\n-- 3 integers, with initial data\nlovr.graphics.newBuffer('int', { 1, 2, 3 })\n\n-- a simple mesh:\nlovr.graphics.newBuffer({\n { name = 'VertexPosition', type = 'vec3' },\n { name = 'VertexColor', type = 'color' }\n}, 4)\n\n-- a uniform buffer with vec3's, using the std140 packing\nlovr.graphics.newBuffer({ 'vec3', layout = 'std140' }, data)\n\n-- a uniform buffer with key-value fields\nlovr.graphics.newBuffer({\n { 'AmbientColor', 'vec3' },\n { 'LightPosition', 'vec3' },\n { 'LightType', 'u32' },\n { 'LightColor', 'vec4' },\n layout = 'std140'\n})\n\n-- a buffer with nested structure and array types\nlovr.graphics.newBuffer({\n { 'globals', {\n { 'ObjectCount', 'int' },\n { 'WorldSize', 'vec2' },\n { 'Scale', 'float' }\n }},\n { 'materials', {\n { 'Color', 'vec4' },\n { 'Glow', 'vec3' },\n { 'Roughness', 'float' }\n }, length = 32 },\n layout = 'std430'\n})\n\n-- a buffer using a variable from a shader:\nlovr.graphics.newBuffer(shader:getBufferFormat('transforms'))"
  11304. }
  11305. },
  11306. notes = "The format table can contain a list of `DataType`s or a list of tables to provide extra information about each field. Each inner table has the following keys:\n\n- `type` is the `DataType` of the field and is required.\n- `name` is the name of the field, used to match table keys and vertex attribute names.\n- `offset` is the byte offset of the field. Any fields with a `nil` offset will be placed next\n to each other sequentially in memory, subject to any padding required by the Buffer's layout.\n In practice this means that you probably want to provide an `offset` for either all of the\n fields or none of them.\n- `length` is the array size of the field.\n\nAs a shorthand, the name, type, and optionally the length of a field can be provided as a list instead of using keys.\n\nIf no table or Blob is used to define the initial Buffer contents, its data will be undefined.",
  11307. related = {
  11308. "Shader:getBufferFormat"
  11309. },
  11310. variants = {
  11311. {
  11312. arguments = {
  11313. {
  11314. name = "size",
  11315. type = "number",
  11316. description = "The size of the Buffer, in bytes."
  11317. }
  11318. },
  11319. returns = {
  11320. {
  11321. name = "buffer",
  11322. type = "Buffer",
  11323. description = "The new Buffer."
  11324. }
  11325. }
  11326. },
  11327. {
  11328. arguments = {
  11329. {
  11330. name = "blob",
  11331. type = "Blob",
  11332. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  11333. }
  11334. },
  11335. returns = {
  11336. {
  11337. name = "buffer",
  11338. type = "Buffer",
  11339. description = "The new Buffer."
  11340. }
  11341. }
  11342. },
  11343. {
  11344. arguments = {
  11345. {
  11346. name = "format",
  11347. type = "table",
  11348. description = "A list of fields in the Buffer.",
  11349. table = {
  11350. {
  11351. name = "layout",
  11352. type = "DataLayout",
  11353. description = "How to lay out the Buffer fields in memory.",
  11354. default = "packed"
  11355. },
  11356. {
  11357. name = "stride",
  11358. type = "number",
  11359. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  11360. }
  11361. }
  11362. },
  11363. {
  11364. name = "length",
  11365. type = "number",
  11366. description = "The length of the Buffer.",
  11367. default = "1"
  11368. }
  11369. },
  11370. returns = {
  11371. {
  11372. name = "buffer",
  11373. type = "Buffer",
  11374. description = "The new Buffer."
  11375. }
  11376. }
  11377. },
  11378. {
  11379. arguments = {
  11380. {
  11381. name = "format",
  11382. type = "table",
  11383. description = "A list of fields in the Buffer.",
  11384. table = {
  11385. {
  11386. name = "layout",
  11387. type = "DataLayout",
  11388. description = "How to lay out the Buffer fields in memory.",
  11389. default = "packed"
  11390. },
  11391. {
  11392. name = "stride",
  11393. type = "number",
  11394. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  11395. }
  11396. }
  11397. },
  11398. {
  11399. name = "data",
  11400. type = "table",
  11401. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  11402. }
  11403. },
  11404. returns = {
  11405. {
  11406. name = "buffer",
  11407. type = "Buffer",
  11408. description = "The new Buffer."
  11409. }
  11410. }
  11411. },
  11412. {
  11413. arguments = {
  11414. {
  11415. name = "format",
  11416. type = "table",
  11417. description = "A list of fields in the Buffer.",
  11418. table = {
  11419. {
  11420. name = "layout",
  11421. type = "DataLayout",
  11422. description = "How to lay out the Buffer fields in memory.",
  11423. default = "packed"
  11424. },
  11425. {
  11426. name = "stride",
  11427. type = "number",
  11428. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  11429. }
  11430. }
  11431. },
  11432. {
  11433. name = "blob",
  11434. type = "Blob",
  11435. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  11436. }
  11437. },
  11438. returns = {
  11439. {
  11440. name = "buffer",
  11441. type = "Buffer",
  11442. description = "The new Buffer."
  11443. }
  11444. }
  11445. },
  11446. {
  11447. arguments = {
  11448. {
  11449. name = "type",
  11450. type = "DataType",
  11451. description = "The type of each item in the Buffer."
  11452. },
  11453. {
  11454. name = "length",
  11455. type = "number",
  11456. description = "The length of the Buffer.",
  11457. default = "1"
  11458. }
  11459. },
  11460. returns = {
  11461. {
  11462. name = "buffer",
  11463. type = "Buffer",
  11464. description = "The new Buffer."
  11465. }
  11466. }
  11467. },
  11468. {
  11469. arguments = {
  11470. {
  11471. name = "type",
  11472. type = "DataType",
  11473. description = "The type of each item in the Buffer."
  11474. },
  11475. {
  11476. name = "data",
  11477. type = "table",
  11478. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  11479. }
  11480. },
  11481. returns = {
  11482. {
  11483. name = "buffer",
  11484. type = "Buffer",
  11485. description = "The new Buffer."
  11486. }
  11487. }
  11488. },
  11489. {
  11490. arguments = {
  11491. {
  11492. name = "type",
  11493. type = "DataType",
  11494. description = "The type of each item in the Buffer."
  11495. },
  11496. {
  11497. name = "blob",
  11498. type = "Blob",
  11499. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  11500. }
  11501. },
  11502. returns = {
  11503. {
  11504. name = "buffer",
  11505. type = "Buffer",
  11506. description = "The new Buffer."
  11507. }
  11508. }
  11509. },
  11510. {
  11511. arguments = {
  11512. {
  11513. name = "length",
  11514. type = "number",
  11515. description = "The length of the Buffer.",
  11516. default = "1"
  11517. },
  11518. {
  11519. name = "type",
  11520. type = "DataType",
  11521. description = "The type of each item in the Buffer."
  11522. }
  11523. },
  11524. returns = {
  11525. {
  11526. name = "buffer",
  11527. type = "Buffer",
  11528. description = "The new Buffer."
  11529. }
  11530. },
  11531. deprecated = true
  11532. },
  11533. {
  11534. arguments = {
  11535. {
  11536. name = "data",
  11537. type = "table",
  11538. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  11539. },
  11540. {
  11541. name = "type",
  11542. type = "DataType",
  11543. description = "The type of each item in the Buffer."
  11544. }
  11545. },
  11546. returns = {
  11547. {
  11548. name = "buffer",
  11549. type = "Buffer",
  11550. description = "The new Buffer."
  11551. }
  11552. },
  11553. deprecated = true
  11554. },
  11555. {
  11556. arguments = {
  11557. {
  11558. name = "length",
  11559. type = "number",
  11560. description = "The length of the Buffer.",
  11561. default = "1"
  11562. },
  11563. {
  11564. name = "format",
  11565. type = "table",
  11566. description = "A list of fields in the Buffer.",
  11567. table = {
  11568. {
  11569. name = "layout",
  11570. type = "DataLayout",
  11571. description = "How to lay out the Buffer fields in memory.",
  11572. default = "packed"
  11573. },
  11574. {
  11575. name = "stride",
  11576. type = "number",
  11577. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  11578. }
  11579. }
  11580. }
  11581. },
  11582. returns = {
  11583. {
  11584. name = "buffer",
  11585. type = "Buffer",
  11586. description = "The new Buffer."
  11587. }
  11588. },
  11589. deprecated = true
  11590. },
  11591. {
  11592. arguments = {
  11593. {
  11594. name = "data",
  11595. type = "table",
  11596. description = "The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data."
  11597. },
  11598. {
  11599. name = "format",
  11600. type = "table",
  11601. description = "A list of fields in the Buffer.",
  11602. table = {
  11603. {
  11604. name = "layout",
  11605. type = "DataLayout",
  11606. description = "How to lay out the Buffer fields in memory.",
  11607. default = "packed"
  11608. },
  11609. {
  11610. name = "stride",
  11611. type = "number",
  11612. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  11613. }
  11614. }
  11615. }
  11616. },
  11617. returns = {
  11618. {
  11619. name = "buffer",
  11620. type = "Buffer",
  11621. description = "The new Buffer."
  11622. }
  11623. },
  11624. deprecated = true
  11625. },
  11626. {
  11627. arguments = {
  11628. {
  11629. name = "blob",
  11630. type = "Blob",
  11631. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  11632. },
  11633. {
  11634. name = "type",
  11635. type = "DataType",
  11636. description = "The type of each item in the Buffer."
  11637. }
  11638. },
  11639. returns = {
  11640. {
  11641. name = "buffer",
  11642. type = "Buffer",
  11643. description = "The new Buffer."
  11644. }
  11645. },
  11646. deprecated = true
  11647. },
  11648. {
  11649. arguments = {
  11650. {
  11651. name = "blob",
  11652. type = "Blob",
  11653. description = "A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer."
  11654. },
  11655. {
  11656. name = "format",
  11657. type = "table",
  11658. description = "A list of fields in the Buffer.",
  11659. table = {
  11660. {
  11661. name = "layout",
  11662. type = "DataLayout",
  11663. description = "How to lay out the Buffer fields in memory.",
  11664. default = "packed"
  11665. },
  11666. {
  11667. name = "stride",
  11668. type = "number",
  11669. description = "The stride of the Buffer, in bytes. When `nil`, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride."
  11670. }
  11671. }
  11672. }
  11673. },
  11674. returns = {
  11675. {
  11676. name = "buffer",
  11677. type = "Buffer",
  11678. description = "The new Buffer."
  11679. }
  11680. },
  11681. deprecated = true
  11682. }
  11683. }
  11684. },
  11685. {
  11686. name = "newFont",
  11687. tag = "graphics-objects",
  11688. summary = "Create a new Font.",
  11689. description = "Creates a new Font.",
  11690. key = "lovr.graphics.newFont",
  11691. module = "lovr.graphics",
  11692. related = {
  11693. "lovr.graphics.getDefaultFont",
  11694. "lovr.data.newRasterizer",
  11695. "Pass:text"
  11696. },
  11697. variants = {
  11698. {
  11699. description = "Creates a new Font from a TTF file.",
  11700. arguments = {
  11701. {
  11702. name = "filename",
  11703. type = "string",
  11704. description = "A path to a TTF file."
  11705. },
  11706. {
  11707. name = "size",
  11708. type = "number",
  11709. description = "The size of the Font in pixels. Larger sizes are slower to initialize and use more memory, but have better quality.",
  11710. default = "32"
  11711. },
  11712. {
  11713. name = "spread",
  11714. type = "number",
  11715. description = "For signed distance field fonts (currently all fonts), the width of the SDF, in pixels. The greater the distance the font is viewed from, the larger this value needs to be for the font to remain properly antialiased. Increasing this will have a performance penalty similar to increasing the size of the font.",
  11716. default = "4"
  11717. }
  11718. },
  11719. returns = {
  11720. {
  11721. name = "font",
  11722. type = "Font",
  11723. description = "The new Font."
  11724. }
  11725. }
  11726. },
  11727. {
  11728. description = "Creates a new Font from TTF data.",
  11729. arguments = {
  11730. {
  11731. name = "blob",
  11732. type = "Blob",
  11733. description = "A Blob containing TTF file data."
  11734. },
  11735. {
  11736. name = "size",
  11737. type = "number",
  11738. description = "The size of the Font in pixels. Larger sizes are slower to initialize and use more memory, but have better quality.",
  11739. default = "32"
  11740. },
  11741. {
  11742. name = "spread",
  11743. type = "number",
  11744. description = "For signed distance field fonts (currently all fonts), the width of the SDF, in pixels. The greater the distance the font is viewed from, the larger this value needs to be for the font to remain properly antialiased. Increasing this will have a performance penalty similar to increasing the size of the font.",
  11745. default = "4"
  11746. }
  11747. },
  11748. returns = {
  11749. {
  11750. name = "font",
  11751. type = "Font",
  11752. description = "The new Font."
  11753. }
  11754. }
  11755. },
  11756. {
  11757. description = "Creates a new Font using the default typeface (Varela Round).",
  11758. arguments = {
  11759. {
  11760. name = "size",
  11761. type = "number",
  11762. description = "The size of the Font in pixels. Larger sizes are slower to initialize and use more memory, but have better quality.",
  11763. default = "32"
  11764. },
  11765. {
  11766. name = "spread",
  11767. type = "number",
  11768. description = "For signed distance field fonts (currently all fonts), the width of the SDF, in pixels. The greater the distance the font is viewed from, the larger this value needs to be for the font to remain properly antialiased. Increasing this will have a performance penalty similar to increasing the size of the font.",
  11769. default = "4"
  11770. }
  11771. },
  11772. returns = {
  11773. {
  11774. name = "font",
  11775. type = "Font",
  11776. description = "The new Font."
  11777. }
  11778. }
  11779. },
  11780. {
  11781. description = "Creates a new Font from an existing Rasterizer.",
  11782. arguments = {
  11783. {
  11784. name = "rasterizer",
  11785. type = "Rasterizer",
  11786. description = "An existing Rasterizer to use to load glyph images."
  11787. },
  11788. {
  11789. name = "spread",
  11790. type = "number",
  11791. description = "For signed distance field fonts (currently all fonts), the width of the SDF, in pixels. The greater the distance the font is viewed from, the larger this value needs to be for the font to remain properly antialiased. Increasing this will have a performance penalty similar to increasing the size of the font.",
  11792. default = "4"
  11793. }
  11794. },
  11795. returns = {
  11796. {
  11797. name = "font",
  11798. type = "Font",
  11799. description = "The new Font."
  11800. }
  11801. }
  11802. }
  11803. }
  11804. },
  11805. {
  11806. name = "newMaterial",
  11807. tag = "graphics-objects",
  11808. summary = "Create a new Material.",
  11809. description = "Creates a new Material from a table of properties and textures. All fields are optional. Once a Material is created, its properties can not be changed. Instead, a new Material should be created with the updated properties.",
  11810. key = "lovr.graphics.newMaterial",
  11811. module = "lovr.graphics",
  11812. notes = "The non-texture material properties can be accessed in shaders using `Material.<property>`, where the property is the same as the Lua table key. The textures use capitalized names in shader code, e.g. `ColorTexture`.",
  11813. variants = {
  11814. {
  11815. arguments = {
  11816. {
  11817. name = "properties",
  11818. type = "table",
  11819. description = "Material properties.",
  11820. table = {
  11821. {
  11822. name = "color",
  11823. type = "Vec4",
  11824. description = "The base color of the surface. Can be a `Vec3`, `Vec4`, table of numbers, or hexcode. Can be toggled in shaders using the `materialColor` flag, which defaults to `true`.",
  11825. default = "{ 1, 1, 1, 1 }"
  11826. },
  11827. {
  11828. name = "glow",
  11829. type = "Vec4",
  11830. description = "The glow color of the surface, sometimes called \"emissive\". The glow is not affected by lighting, so it's a good fit for e.g. headlights on a car or LED lights on a panel. The alpha of the glow color is used as the glow strength. Can be a `Vec3`, `Vec4`, table of numbers, or hexcode. Can be toggled in shaders using the `glow` flag, which defaults to `false`.",
  11831. default = "{ 0, 0, 0, 0 }"
  11832. },
  11833. {
  11834. name = "uvShift",
  11835. type = "Vec2",
  11836. description = "An offset to apply to the UV coordinates used to sample textures. The offset is not affected by `uvScale`. This can be used to map UV coordinates to a sub-rectangle of a texture atlas. Can be a `Vec2`, table of numbers, or a single number which gets assigned to both axes. Can be toggled in shaders using the `uvTransform` flag, which defaults to `true`.",
  11837. default = "{ 0, 0 }"
  11838. },
  11839. {
  11840. name = "uvScale",
  11841. type = "Vec2",
  11842. description = "A scale factor to apply to the UV coordinates used to sample textures. The scale is not affected by `uvOffset`. This can be used to map UV coordinates to a sub-rectangle of a texture atlas, or repeat a texture multiple times across a surface. Can be a `Vec2`, table of numbers, or a single number which gets assigned to both axes. Can be toggled in shaders using the `uvTransform` flag, which defaults to `true`.",
  11843. default = "{ 1, 1 }"
  11844. },
  11845. {
  11846. name = "metalness",
  11847. type = "number",
  11848. description = "The metalness the surface, used for physically-based rendering. 1.0 means the surface is metallic (conductor), and 0.0 means the surface is non-metallic (dielectric). Values in between are seldom used and are only used in textures to transition between a metallic and non-metallic surface. Metals reflect light differently than non-metals. Used by the lighting helper functions `initSurface` and `getLighting`.",
  11849. default = "0"
  11850. },
  11851. {
  11852. name = "roughness",
  11853. type = "number",
  11854. description = "The roughness of the surface, used for physically-based rendering. 1.0 means the surface is rough (blurry reflections), and 0.0 means the surface is smooth (sharp reflections). Used by the lighting helper functions `initSurface` and `getLighting`.",
  11855. default = "0"
  11856. },
  11857. {
  11858. name = "clearcoat",
  11859. type = "number",
  11860. description = "The clearcoat factor. Not currently used by LÖVR.",
  11861. default = "0"
  11862. },
  11863. {
  11864. name = "clearcoatRoughness",
  11865. type = "number",
  11866. description = "The roughness of the clearcoat layer. Not currently used by LÖVR.",
  11867. default = "0"
  11868. },
  11869. {
  11870. name = "occlusionStrength",
  11871. type = "number",
  11872. description = "The strength of the ambient occlusion effect. Ambient occlusion only affects indirect lighting. Used by the lighting helper functions `initSurface` and `getIndirectLighting`. Can be toggled in shaders using the `ambientOcclusion` flag, which defaults to `true`.",
  11873. default = "1"
  11874. },
  11875. {
  11876. name = "normalScale",
  11877. type = "number",
  11878. description = "The strength of the normal map. Used by the `initSurface` function to bend the surface normal. Can be toggled in shaders using the `normalMap` flag, which defaults to `false`.",
  11879. default = "1"
  11880. },
  11881. {
  11882. name = "alphaCutoff",
  11883. type = "number",
  11884. description = "The alpha cutoff. At the end of the fragment shader, if the alpha of the final color is below the alpha cutoff, then the pixel will be \"discarded\" which means that it won't write a depth value. Often used for transparent textures, especially with the \"alpha to coverage\" state set by `Pass:setAlphaToCoverage`. Can be toggled in shaders using the `alphaCutoff` flag, which defaults to `false`.",
  11885. default = "0"
  11886. },
  11887. {
  11888. name = "texture",
  11889. type = "Texture",
  11890. description = "The base color texture. In shaders this gets multiplied with the `color` property to get the base color of the pixel. Can be toggled in shaders using the `colorTexture` flag, which defaults to `true`."
  11891. },
  11892. {
  11893. name = "glowTexture",
  11894. type = "Texture",
  11895. description = "The glow color texture. In shaders, samples from this texture get multiplied with the `glow` property to get the glow color of the pixel. Can be toggled in shaders using the `glowTexture` flag, which defaults to `true` (also requires the `glow` flag to be enabled)."
  11896. },
  11897. {
  11898. name = "metalnessTexture",
  11899. type = "Texture",
  11900. description = "The metalness texture. In shaders, samples from the blue channel of this texture get multiplied with the `metalness` property to get the metalness value of the pixel. Can be toggled in shaders using the `metalnessTexture` flag, which defaults to `true`."
  11901. },
  11902. {
  11903. name = "roughnessTexture",
  11904. type = "Texture",
  11905. description = "The roughness texture. In shaders, samples from the green channel of this texture get multiplied with the `roughness` property to get the roughness value of the pixel. Can be toggled in shaders using the `roughnessTexture` flag, which defaults to `true`."
  11906. },
  11907. {
  11908. name = "clearcoatTexture",
  11909. type = "Texture",
  11910. description = "Not currently used by LÖVR."
  11911. },
  11912. {
  11913. name = "occlusionTexture",
  11914. type = "Texture",
  11915. description = "The ambient occlusion texture. In shaders, samples from the red channel of this texture get multiplied with the `occlusionStrength` property to get the ambient occlusion value of the pixel. Used by the lighting helper functions `initSurface` and `getIndirectLighting`. Can be toggled in shaders using the `ambientOcclusion` flag, which defaults to `true`."
  11916. },
  11917. {
  11918. name = "normalTexture",
  11919. type = "Texture",
  11920. description = "The normal map, used to apply details to a surface without adding mesh geometry. The `normalScale` property can be used to control how strong the effect is. Can be toggled in shaders using the `normalMap` flag, which defaults to `false`."
  11921. }
  11922. }
  11923. }
  11924. },
  11925. returns = {
  11926. {
  11927. name = "material",
  11928. type = "Material",
  11929. description = "The new material."
  11930. }
  11931. }
  11932. }
  11933. }
  11934. },
  11935. {
  11936. name = "newMesh",
  11937. tag = "graphics-objects",
  11938. summary = "Create a new Mesh.",
  11939. description = "Creates a Mesh. The capacity of the Mesh must be provided upfront, using either a vertex count or the vertex data itself. A custom vertex format can be given to specify the set of attributes in each vertex, which get sent to the vertex shader. If the format isn't given, the default vertex format will be used:\n\n {\n { 'VertexPosition', 'vec3' },\n { 'VertexNormal', 'vec3' },\n { 'VertexUV', 'vec2' }\n }",
  11940. key = "lovr.graphics.newMesh",
  11941. module = "lovr.graphics",
  11942. examples = {
  11943. {
  11944. code = "function lovr.load()\n mesh = lovr.graphics.newMesh({\n { 'VertexPosition', 'vec3' },\n { 'VertexColor', 'vec4' }\n }, {\n { 0, .4, 0 , 1, 0, 0, 1 },\n { -.5, -.4, 0 , 0, 1, 0, 1 },\n { .5, -.4, 0 , 0, 0, 1, 1 }\n })\nend\n\nfunction lovr.draw(pass)\n pass:draw(mesh, 0, 1.7, -1)\nend"
  11945. }
  11946. },
  11947. notes = "The Mesh will always use the `gpu` storage mode if it's created from a vertex buffer.",
  11948. related = {
  11949. "lovr.graphics.newBuffer",
  11950. "lovr.graphics.newModel"
  11951. },
  11952. variants = {
  11953. {
  11954. arguments = {
  11955. {
  11956. name = "count",
  11957. type = "number",
  11958. description = "The number of vertices in the Mesh."
  11959. },
  11960. {
  11961. name = "storage",
  11962. type = "MeshStorage",
  11963. description = "The storage mode of the Mesh.",
  11964. default = "'cpu'"
  11965. }
  11966. },
  11967. returns = {
  11968. {
  11969. name = "mesh",
  11970. type = "Mesh",
  11971. description = "The new Mesh."
  11972. }
  11973. }
  11974. },
  11975. {
  11976. arguments = {
  11977. {
  11978. name = "vertices",
  11979. type = "table",
  11980. description = "A table of vertices, formatted according to the vertex format. The length of the table will be used to set the vertex count of the Mesh."
  11981. },
  11982. {
  11983. name = "storage",
  11984. type = "MeshStorage",
  11985. description = "The storage mode of the Mesh.",
  11986. default = "'cpu'"
  11987. }
  11988. },
  11989. returns = {
  11990. {
  11991. name = "mesh",
  11992. type = "Mesh",
  11993. description = "The new Mesh."
  11994. }
  11995. }
  11996. },
  11997. {
  11998. arguments = {
  11999. {
  12000. name = "blob",
  12001. type = "Blob",
  12002. description = "A Blob containing vertex data, formatted according to the vertex format. The size of the Blob will be used to set the vertex count of the Mesh, and must be a multiple of the vertex size."
  12003. },
  12004. {
  12005. name = "storage",
  12006. type = "MeshStorage",
  12007. description = "The storage mode of the Mesh.",
  12008. default = "'cpu'"
  12009. }
  12010. },
  12011. returns = {
  12012. {
  12013. name = "mesh",
  12014. type = "Mesh",
  12015. description = "The new Mesh."
  12016. }
  12017. }
  12018. },
  12019. {
  12020. arguments = {
  12021. {
  12022. name = "format",
  12023. type = "table",
  12024. description = "A table of attributes describing the format of each vertex. Each attribute is a table that must have `name` and `type` keys, where the name is a string and the type is a `DataType`. Attributes can also have an `offset` key, which is a byte offset relative to the start of the vertex. As a shorthand, the name and type can be given as a pair without keys. Additionally, the format can have a `stride` key to set the number of bytes between subsequent vertices."
  12025. },
  12026. {
  12027. name = "count",
  12028. type = "number",
  12029. description = "The number of vertices in the Mesh."
  12030. },
  12031. {
  12032. name = "storage",
  12033. type = "MeshStorage",
  12034. description = "The storage mode of the Mesh.",
  12035. default = "'cpu'"
  12036. }
  12037. },
  12038. returns = {
  12039. {
  12040. name = "mesh",
  12041. type = "Mesh",
  12042. description = "The new Mesh."
  12043. }
  12044. }
  12045. },
  12046. {
  12047. arguments = {
  12048. {
  12049. name = "format",
  12050. type = "table",
  12051. description = "A table of attributes describing the format of each vertex. Each attribute is a table that must have `name` and `type` keys, where the name is a string and the type is a `DataType`. Attributes can also have an `offset` key, which is a byte offset relative to the start of the vertex. As a shorthand, the name and type can be given as a pair without keys. Additionally, the format can have a `stride` key to set the number of bytes between subsequent vertices."
  12052. },
  12053. {
  12054. name = "vertices",
  12055. type = "table",
  12056. description = "A table of vertices, formatted according to the vertex format. The length of the table will be used to set the vertex count of the Mesh."
  12057. },
  12058. {
  12059. name = "storage",
  12060. type = "MeshStorage",
  12061. description = "The storage mode of the Mesh.",
  12062. default = "'cpu'"
  12063. }
  12064. },
  12065. returns = {
  12066. {
  12067. name = "mesh",
  12068. type = "Mesh",
  12069. description = "The new Mesh."
  12070. }
  12071. }
  12072. },
  12073. {
  12074. arguments = {
  12075. {
  12076. name = "format",
  12077. type = "table",
  12078. description = "A table of attributes describing the format of each vertex. Each attribute is a table that must have `name` and `type` keys, where the name is a string and the type is a `DataType`. Attributes can also have an `offset` key, which is a byte offset relative to the start of the vertex. As a shorthand, the name and type can be given as a pair without keys. Additionally, the format can have a `stride` key to set the number of bytes between subsequent vertices."
  12079. },
  12080. {
  12081. name = "blob",
  12082. type = "Blob",
  12083. description = "A Blob containing vertex data, formatted according to the vertex format. The size of the Blob will be used to set the vertex count of the Mesh, and must be a multiple of the vertex size."
  12084. },
  12085. {
  12086. name = "storage",
  12087. type = "MeshStorage",
  12088. description = "The storage mode of the Mesh.",
  12089. default = "'cpu'"
  12090. }
  12091. },
  12092. returns = {
  12093. {
  12094. name = "mesh",
  12095. type = "Mesh",
  12096. description = "The new Mesh."
  12097. }
  12098. }
  12099. },
  12100. {
  12101. arguments = {
  12102. {
  12103. name = "buffer",
  12104. type = "Buffer",
  12105. description = "A Buffer containing vertex data. Its length will be used as the vertex count, and its format will be used as the vertex format."
  12106. }
  12107. },
  12108. returns = {
  12109. {
  12110. name = "mesh",
  12111. type = "Mesh",
  12112. description = "The new Mesh."
  12113. }
  12114. }
  12115. }
  12116. }
  12117. },
  12118. {
  12119. name = "newModel",
  12120. tag = "graphics-objects",
  12121. summary = "Create a new Model.",
  12122. description = "Loads a 3D model from a file. Currently, OBJ, glTF, and binary STL files are supported.",
  12123. key = "lovr.graphics.newModel",
  12124. module = "lovr.graphics",
  12125. notes = "Currently, the following features are not supported by the model importer:\n\n- glTF: Only the default scene is loaded.\n- glTF: Currently, each skin in a Model can have up to 256 joints.\n- glTF: Meshes can't appear multiple times in the node hierarchy with different skins, they need\n to use 1 skin consistently.\n- glTF: `KHR_texture_transform` is supported, but all textures in a material will use the same\n transform.\n- STL: ASCII STL files are not supported.\n\nDiffuse and emissive textures will be loaded using sRGB encoding, all other textures will be loaded as linear.\n\nLoading a model file will fail if the asset references textures or other files using absolute paths. Relative paths should be used instead, and will be relative to the model file within the virtual filesystem.",
  12126. related = {
  12127. "lovr.data.newModelData",
  12128. "Pass:draw"
  12129. },
  12130. variants = {
  12131. {
  12132. arguments = {
  12133. {
  12134. name = "filename",
  12135. type = "string",
  12136. description = "The path to model file."
  12137. },
  12138. {
  12139. name = "options",
  12140. type = "table",
  12141. description = "Model options.",
  12142. table = {
  12143. {
  12144. name = "mipmaps",
  12145. type = "boolean",
  12146. description = "Whether the textures created for the Model should have mipmaps generated.",
  12147. default = "true"
  12148. },
  12149. {
  12150. name = "materials",
  12151. type = "boolean",
  12152. description = "Whether the textures and materials in the Model should be loaded. When false, the model will use the material set with `Pass:setMaterial`, although it will apply to all nodes.",
  12153. default = "true"
  12154. }
  12155. }
  12156. }
  12157. },
  12158. returns = {
  12159. {
  12160. name = "model",
  12161. type = "Model",
  12162. description = "The new Model."
  12163. }
  12164. }
  12165. },
  12166. {
  12167. arguments = {
  12168. {
  12169. name = "blob",
  12170. type = "Blob",
  12171. description = "A Blob containing 3D model data."
  12172. },
  12173. {
  12174. name = "options",
  12175. type = "table",
  12176. description = "Model options.",
  12177. table = {
  12178. {
  12179. name = "mipmaps",
  12180. type = "boolean",
  12181. description = "Whether the textures created for the Model should have mipmaps generated.",
  12182. default = "true"
  12183. },
  12184. {
  12185. name = "materials",
  12186. type = "boolean",
  12187. description = "Whether the textures and materials in the Model should be loaded. When false, the model will use the material set with `Pass:setMaterial`, although it will apply to all nodes.",
  12188. default = "true"
  12189. }
  12190. }
  12191. }
  12192. },
  12193. returns = {
  12194. {
  12195. name = "model",
  12196. type = "Model",
  12197. description = "The new Model."
  12198. }
  12199. }
  12200. },
  12201. {
  12202. arguments = {
  12203. {
  12204. name = "modelData",
  12205. type = "ModelData",
  12206. description = "An existing ModelData object to use for the Model."
  12207. },
  12208. {
  12209. name = "options",
  12210. type = "table",
  12211. description = "Model options.",
  12212. table = {
  12213. {
  12214. name = "mipmaps",
  12215. type = "boolean",
  12216. description = "Whether the textures created for the Model should have mipmaps generated.",
  12217. default = "true"
  12218. },
  12219. {
  12220. name = "materials",
  12221. type = "boolean",
  12222. description = "Whether the textures and materials in the Model should be loaded. When false, the model will use the material set with `Pass:setMaterial`, although it will apply to all nodes.",
  12223. default = "true"
  12224. }
  12225. }
  12226. }
  12227. },
  12228. returns = {
  12229. {
  12230. name = "model",
  12231. type = "Model",
  12232. description = "The new Model."
  12233. }
  12234. }
  12235. }
  12236. }
  12237. },
  12238. {
  12239. name = "newPass",
  12240. tag = "graphics-objects",
  12241. summary = "Create a new Pass.",
  12242. description = "Creates and returns a new Pass object. The canvas (the set of textures the Pass renders to) can be specified when creating the Pass, or later using `Pass:setCanvas`.",
  12243. key = "lovr.graphics.newPass",
  12244. module = "lovr.graphics",
  12245. notes = "Fun facts about render passes:\n\n- Textures must have been created with the `render` `TextureUsage`.\n- Textures must have the same dimensions, layer counts, and sample counts.\n- When rendering to textures with multiple layers, each draw will be broadcast to all layers.\n Render passes have multiple \"views\" (cameras), and each layer uses a corresponding view,\n allowing each layer to be rendered from a different viewpoint. This enables fast stereo\n rendering, but can also be used to efficiently render to cubemaps. The `ViewIndex` variable\n can also be used in shaders to set up any desired per-view behavior.\n- Mipmaps will automatically be generated for textures at the end of the render pass.\n- It's okay to have zero color textures, but in this case there must be a depth texture.\n- It's possible to render to a specific mipmap level of a Texture, or a subset of its layers, by\n rendering to texture views, see `Texture:newView`.",
  12246. related = {
  12247. "lovr.graphics.submit",
  12248. "lovr.graphics.getWindowPass",
  12249. "lovr.headset.getPass"
  12250. },
  12251. variants = {
  12252. {
  12253. description = "Create a pass that renders to a set of textures.",
  12254. arguments = {
  12255. {
  12256. name = "...textures",
  12257. type = "Texture",
  12258. description = "One or more textures the pass will render to. This can be changed later using `Pass:setCanvas`."
  12259. }
  12260. },
  12261. returns = {
  12262. {
  12263. name = "pass",
  12264. type = "Pass",
  12265. description = "The new Pass."
  12266. }
  12267. }
  12268. },
  12269. {
  12270. description = "Create a pass, with extra canvas settings.",
  12271. arguments = {
  12272. {
  12273. name = "canvas",
  12274. type = "table",
  12275. description = "Render target configuration. Up to 4 textures can be provided in table keys 1 through 4, as well as the following keys:",
  12276. table = {
  12277. {
  12278. name = "depth",
  12279. type = "table",
  12280. description = "Depth/stencil buffer settings. In addition to a table, it can be a `Texture`, a `TextureFormat`, or `false` to disable the depth buffer.",
  12281. table = {
  12282. {
  12283. name = "format",
  12284. type = "TextureFormat",
  12285. description = "The format of the depth buffer texture, which must be a depth format (the ones that start with `d`). LÖVR will create or reuse an internal depth buffer with this format.",
  12286. default = "'d32f'"
  12287. },
  12288. {
  12289. name = "texture",
  12290. type = "Texture",
  12291. description = "A Texture to use as the depth buffer. Takes precedence over `format`."
  12292. }
  12293. }
  12294. },
  12295. {
  12296. name = "samples",
  12297. type = "number",
  12298. description = "The number of multisamples to use. Can be 4 for antialiasing, or 1 to disable antialiasing.",
  12299. default = "4"
  12300. }
  12301. }
  12302. }
  12303. },
  12304. returns = {
  12305. {
  12306. name = "pass",
  12307. type = "Pass",
  12308. description = "The new Pass."
  12309. }
  12310. }
  12311. },
  12312. {
  12313. description = "Create an empty Pass without a canvas.",
  12314. arguments = {},
  12315. returns = {
  12316. {
  12317. name = "pass",
  12318. type = "Pass",
  12319. description = "The new Pass."
  12320. }
  12321. }
  12322. }
  12323. }
  12324. },
  12325. {
  12326. name = "newSampler",
  12327. tag = "graphics-objects",
  12328. summary = "Create a new Sampler.",
  12329. description = "Creates a new Sampler. Samplers are immutable, meaning their parameters can not be changed after the sampler is created. Instead, a new sampler should be created with the updated properties.",
  12330. key = "lovr.graphics.newSampler",
  12331. module = "lovr.graphics",
  12332. related = {
  12333. "Pass:setSampler"
  12334. },
  12335. variants = {
  12336. {
  12337. arguments = {
  12338. {
  12339. name = "parameters",
  12340. type = "table",
  12341. description = "Parameters for the sampler.",
  12342. table = {
  12343. {
  12344. name = "filter",
  12345. type = "table",
  12346. description = "How the sampler smooths texture pixels. Can be a table of 3 FilterModes, or a single FilterMode to use for all three.",
  12347. default = "'linear'",
  12348. table = {
  12349. {
  12350. name = "[1]",
  12351. type = "FilterMode",
  12352. description = "The filter mode to use when minifying a texture (drawing it at a smaller size than its native pixel resolution)."
  12353. },
  12354. {
  12355. name = "[2]",
  12356. type = "FilterMode",
  12357. description = "The filter mode to use when magnifying a texture (drawing it at a larger size than its native pixel resolution)."
  12358. },
  12359. {
  12360. name = "[3]",
  12361. type = "FilterMode",
  12362. description = "The filter mode used to smooth between mipmap levels in a texture."
  12363. }
  12364. }
  12365. },
  12366. {
  12367. name = "wrap",
  12368. type = "table",
  12369. description = "How the sampler behaves when wrapping UVs outside the 0-1 range. Can be a table of 3 WrapModes, or a single WrapMode to use for all three axes.",
  12370. default = "'repeat'",
  12371. table = {
  12372. {
  12373. name = "[1]",
  12374. type = "WrapMode",
  12375. description = "The horizontal wrap mode."
  12376. },
  12377. {
  12378. name = "[2]",
  12379. type = "WrapMode",
  12380. description = "The vertical wrap mode."
  12381. },
  12382. {
  12383. name = "[3]",
  12384. type = "WrapMode",
  12385. description = "The \"z\" wrap mode for 3D textures."
  12386. }
  12387. }
  12388. },
  12389. {
  12390. name = "compare",
  12391. type = "CompareMode",
  12392. description = "The compare mode of the sampler (for shadow samplers).",
  12393. default = "'none'"
  12394. },
  12395. {
  12396. name = "anisotropy",
  12397. type = "number",
  12398. description = "The maximum amount of anisotropic filtering to use.",
  12399. default = "1"
  12400. },
  12401. {
  12402. name = "mipmaprange",
  12403. type = "table",
  12404. description = "A table of 2 mipmap levels the sampler will clamp to."
  12405. }
  12406. }
  12407. }
  12408. },
  12409. returns = {
  12410. {
  12411. name = "sampler",
  12412. type = "Sampler",
  12413. description = "The new sampler."
  12414. }
  12415. }
  12416. }
  12417. }
  12418. },
  12419. {
  12420. name = "newShader",
  12421. tag = "graphics-objects",
  12422. summary = "Create a new Shader.",
  12423. description = "Creates a Shader, which is a small program that runs on the GPU.\n\nShader code is usually written in GLSL and compiled to SPIR-V bytecode. SPIR-V is faster to load but requires a build step. Either form can be used to create a shader.",
  12424. key = "lovr.graphics.newShader",
  12425. module = "lovr.graphics",
  12426. related = {
  12427. "lovr.graphics.compileShader",
  12428. "ShaderType",
  12429. "ShaderStage"
  12430. },
  12431. variants = {
  12432. {
  12433. description = "Create a graphics shader. It has a vertex stage that computes vertex positions, and a fragment stage that computes pixel colors.",
  12434. arguments = {
  12435. {
  12436. name = "vertex",
  12437. type = "string",
  12438. description = "A string, path to a file, or Blob containing GLSL or SPIR-V code for the vertex stage. Can also be a `DefaultShader` to use that shader's vertex code."
  12439. },
  12440. {
  12441. name = "fragment",
  12442. type = "string",
  12443. description = "A string, path to a file, or Blob containing GLSL or SPIR-V code for the fragment stage. Can also be a `DefaultShader` to use that shader's fragment code."
  12444. },
  12445. {
  12446. name = "options",
  12447. type = "table",
  12448. description = "Shader options.",
  12449. table = {
  12450. {
  12451. name = "flags",
  12452. type = "table",
  12453. description = "A table of shader flags. The keys of the table should be flag names or flag ID numbers. The values can be numbers or booleans, depending on the type of the flag as declared in the shader."
  12454. },
  12455. {
  12456. name = "label",
  12457. type = "string",
  12458. description = "A label to use for the shader in debugging tools."
  12459. }
  12460. }
  12461. }
  12462. },
  12463. returns = {
  12464. {
  12465. name = "shader",
  12466. type = "Shader",
  12467. description = "The new shader."
  12468. }
  12469. }
  12470. },
  12471. {
  12472. description = "Create a compute shader.",
  12473. arguments = {
  12474. {
  12475. name = "compute",
  12476. type = "string",
  12477. description = "A string, path to a file, or Blob containing GLSL or SPIR-V code for the compute stage."
  12478. },
  12479. {
  12480. name = "options",
  12481. type = "table",
  12482. description = "Shader options.",
  12483. table = {
  12484. {
  12485. name = "flags",
  12486. type = "table",
  12487. description = "A table of shader flags. The keys of the table should be flag names or flag ID numbers. The values can be numbers or booleans, depending on the type of the flag as declared in the shader."
  12488. },
  12489. {
  12490. name = "label",
  12491. type = "string",
  12492. description = "A label to use for the shader in debugging tools."
  12493. }
  12494. }
  12495. }
  12496. },
  12497. returns = {
  12498. {
  12499. name = "shader",
  12500. type = "Shader",
  12501. description = "The new shader."
  12502. }
  12503. }
  12504. },
  12505. {
  12506. description = "Create a copy of one of the default shaders (used to provide different flags).",
  12507. arguments = {
  12508. {
  12509. name = "default",
  12510. type = "DefaultShader",
  12511. description = "The default shader to use."
  12512. },
  12513. {
  12514. name = "options",
  12515. type = "table",
  12516. description = "Shader options.",
  12517. table = {
  12518. {
  12519. name = "flags",
  12520. type = "table",
  12521. description = "A table of shader flags. The keys of the table should be flag names or flag ID numbers. The values can be numbers or booleans, depending on the type of the flag as declared in the shader."
  12522. },
  12523. {
  12524. name = "label",
  12525. type = "string",
  12526. description = "A label to use for the shader in debugging tools."
  12527. }
  12528. }
  12529. }
  12530. },
  12531. returns = {
  12532. {
  12533. name = "shader",
  12534. type = "Shader",
  12535. description = "The new shader."
  12536. }
  12537. }
  12538. }
  12539. }
  12540. },
  12541. {
  12542. name = "newTexture",
  12543. tag = "graphics-objects",
  12544. summary = "Create a new Texture.",
  12545. description = "Creates a new Texture. Image filenames or `Image` objects can be used to provide the initial pixel data and the dimensions, format, and type. Alternatively, dimensions can be provided, which will create an empty texture.",
  12546. key = "lovr.graphics.newTexture",
  12547. module = "lovr.graphics",
  12548. notes = "If no `type` is provided in the options table, LÖVR will guess the `TextureType` of the Texture based on the number of layers:\n\n- If there's only 1 layer, the type will be `2d`.\n- If there are 6 images provided, the type will be `cube`.\n- Otherwise, the type will be `array`.\n\nNote that an Image can contain multiple layers and mipmaps. When a single Image is provided, its layer count will be used as the Texture's layer count.\n\nIf multiple Images are used to initialize the Texture, they must all have a single layer, and their dimensions, format, and mipmap counts must match.\n\nWhen providing cubemap images in a table, they can be in one of the following forms:\n\n { 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' }\n { right = 'px.png', left = 'nx.png', top = 'py.png', bottom = 'ny.png', back = 'pz.png', front = 'nz.png' }\n { px = 'px.png', nx = 'nx.png', py = 'py.png', ny = 'ny.png', pz = 'pz.png', nz = 'nz.png' }\n\n(Where 'p' stands for positive and 'n' stands for negative).\n\nIf no `usage` is provided in the options table, LÖVR will guess the `TextureUsage` of the Texture. The `sample` usage is always included, but if the texture was created without any images then the texture will have the `render` usage as well.\n\nThe supported image formats are png, jpg, hdr, dds, ktx1, ktx2, and astc.\n\nIf image data is provided, mipmaps will be generated for any missing mipmap levels.",
  12549. related = {
  12550. "Texture:newView"
  12551. },
  12552. variants = {
  12553. {
  12554. arguments = {
  12555. {
  12556. name = "filename",
  12557. type = "string",
  12558. description = "The filename of an image to load."
  12559. },
  12560. {
  12561. name = "options",
  12562. type = "table",
  12563. description = "Texture options.",
  12564. table = {
  12565. {
  12566. name = "type",
  12567. type = "TextureType",
  12568. description = "The type of the texture."
  12569. },
  12570. {
  12571. name = "format",
  12572. type = "TextureFormat",
  12573. description = "The format of the texture (ignored when images are provided).",
  12574. default = "'rgba8'"
  12575. },
  12576. {
  12577. name = "linear",
  12578. type = "boolean",
  12579. description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
  12580. default = "false"
  12581. },
  12582. {
  12583. name = "samples",
  12584. type = "number",
  12585. description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
  12586. default = "1"
  12587. },
  12588. {
  12589. name = "mipmaps",
  12590. type = "*",
  12591. description = "The number of mipmap levels in the texture, or a boolean. If true, a full mipmap chain will be created. If false, the texture will only have a single mipmap.",
  12592. default = "true"
  12593. },
  12594. {
  12595. name = "usage",
  12596. type = "table",
  12597. description = "A list of `TextureUsage` indicating how the texture will be used."
  12598. },
  12599. {
  12600. name = "label",
  12601. type = "string",
  12602. description = "A label for the Texture that will show up in debugging tools."
  12603. }
  12604. }
  12605. }
  12606. },
  12607. returns = {
  12608. {
  12609. name = "texture",
  12610. type = "Texture",
  12611. description = "The new Texture."
  12612. }
  12613. }
  12614. },
  12615. {
  12616. arguments = {
  12617. {
  12618. name = "width",
  12619. type = "number",
  12620. description = "The width of the Texture, in pixels."
  12621. },
  12622. {
  12623. name = "height",
  12624. type = "number",
  12625. description = "The height of the Texture, in pixels."
  12626. },
  12627. {
  12628. name = "options",
  12629. type = "table",
  12630. description = "Texture options.",
  12631. table = {
  12632. {
  12633. name = "type",
  12634. type = "TextureType",
  12635. description = "The type of the texture."
  12636. },
  12637. {
  12638. name = "format",
  12639. type = "TextureFormat",
  12640. description = "The format of the texture (ignored when images are provided).",
  12641. default = "'rgba8'"
  12642. },
  12643. {
  12644. name = "linear",
  12645. type = "boolean",
  12646. description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
  12647. default = "false"
  12648. },
  12649. {
  12650. name = "samples",
  12651. type = "number",
  12652. description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
  12653. default = "1"
  12654. },
  12655. {
  12656. name = "mipmaps",
  12657. type = "*",
  12658. description = "The number of mipmap levels in the texture, or a boolean. If true, a full mipmap chain will be created. If false, the texture will only have a single mipmap.",
  12659. default = "true"
  12660. },
  12661. {
  12662. name = "usage",
  12663. type = "table",
  12664. description = "A list of `TextureUsage` indicating how the texture will be used."
  12665. },
  12666. {
  12667. name = "label",
  12668. type = "string",
  12669. description = "A label for the Texture that will show up in debugging tools."
  12670. }
  12671. }
  12672. }
  12673. },
  12674. returns = {
  12675. {
  12676. name = "texture",
  12677. type = "Texture",
  12678. description = "The new Texture."
  12679. }
  12680. }
  12681. },
  12682. {
  12683. arguments = {
  12684. {
  12685. name = "width",
  12686. type = "number",
  12687. description = "The width of the Texture, in pixels."
  12688. },
  12689. {
  12690. name = "height",
  12691. type = "number",
  12692. description = "The height of the Texture, in pixels."
  12693. },
  12694. {
  12695. name = "layers",
  12696. type = "number",
  12697. description = "The number of layers in the Texture."
  12698. },
  12699. {
  12700. name = "options",
  12701. type = "table",
  12702. description = "Texture options.",
  12703. table = {
  12704. {
  12705. name = "type",
  12706. type = "TextureType",
  12707. description = "The type of the texture."
  12708. },
  12709. {
  12710. name = "format",
  12711. type = "TextureFormat",
  12712. description = "The format of the texture (ignored when images are provided).",
  12713. default = "'rgba8'"
  12714. },
  12715. {
  12716. name = "linear",
  12717. type = "boolean",
  12718. description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
  12719. default = "false"
  12720. },
  12721. {
  12722. name = "samples",
  12723. type = "number",
  12724. description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
  12725. default = "1"
  12726. },
  12727. {
  12728. name = "mipmaps",
  12729. type = "*",
  12730. description = "The number of mipmap levels in the texture, or a boolean. If true, a full mipmap chain will be created. If false, the texture will only have a single mipmap.",
  12731. default = "true"
  12732. },
  12733. {
  12734. name = "usage",
  12735. type = "table",
  12736. description = "A list of `TextureUsage` indicating how the texture will be used."
  12737. },
  12738. {
  12739. name = "label",
  12740. type = "string",
  12741. description = "A label for the Texture that will show up in debugging tools."
  12742. }
  12743. }
  12744. }
  12745. },
  12746. returns = {
  12747. {
  12748. name = "texture",
  12749. type = "Texture",
  12750. description = "The new Texture."
  12751. }
  12752. }
  12753. },
  12754. {
  12755. arguments = {
  12756. {
  12757. name = "image",
  12758. type = "string",
  12759. description = "An Image object holding pixel data to load into the Texture."
  12760. },
  12761. {
  12762. name = "options",
  12763. type = "table",
  12764. description = "Texture options.",
  12765. table = {
  12766. {
  12767. name = "type",
  12768. type = "TextureType",
  12769. description = "The type of the texture."
  12770. },
  12771. {
  12772. name = "format",
  12773. type = "TextureFormat",
  12774. description = "The format of the texture (ignored when images are provided).",
  12775. default = "'rgba8'"
  12776. },
  12777. {
  12778. name = "linear",
  12779. type = "boolean",
  12780. description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
  12781. default = "false"
  12782. },
  12783. {
  12784. name = "samples",
  12785. type = "number",
  12786. description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
  12787. default = "1"
  12788. },
  12789. {
  12790. name = "mipmaps",
  12791. type = "*",
  12792. description = "The number of mipmap levels in the texture, or a boolean. If true, a full mipmap chain will be created. If false, the texture will only have a single mipmap.",
  12793. default = "true"
  12794. },
  12795. {
  12796. name = "usage",
  12797. type = "table",
  12798. description = "A list of `TextureUsage` indicating how the texture will be used."
  12799. },
  12800. {
  12801. name = "label",
  12802. type = "string",
  12803. description = "A label for the Texture that will show up in debugging tools."
  12804. }
  12805. }
  12806. }
  12807. },
  12808. returns = {
  12809. {
  12810. name = "texture",
  12811. type = "Texture",
  12812. description = "The new Texture."
  12813. }
  12814. }
  12815. },
  12816. {
  12817. arguments = {
  12818. {
  12819. name = "images",
  12820. type = "table",
  12821. description = "A table of filenames or Images to load into the Texture."
  12822. },
  12823. {
  12824. name = "options",
  12825. type = "table",
  12826. description = "Texture options.",
  12827. table = {
  12828. {
  12829. name = "type",
  12830. type = "TextureType",
  12831. description = "The type of the texture."
  12832. },
  12833. {
  12834. name = "format",
  12835. type = "TextureFormat",
  12836. description = "The format of the texture (ignored when images are provided).",
  12837. default = "'rgba8'"
  12838. },
  12839. {
  12840. name = "linear",
  12841. type = "boolean",
  12842. description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
  12843. default = "false"
  12844. },
  12845. {
  12846. name = "samples",
  12847. type = "number",
  12848. description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
  12849. default = "1"
  12850. },
  12851. {
  12852. name = "mipmaps",
  12853. type = "*",
  12854. description = "The number of mipmap levels in the texture, or a boolean. If true, a full mipmap chain will be created. If false, the texture will only have a single mipmap.",
  12855. default = "true"
  12856. },
  12857. {
  12858. name = "usage",
  12859. type = "table",
  12860. description = "A list of `TextureUsage` indicating how the texture will be used."
  12861. },
  12862. {
  12863. name = "label",
  12864. type = "string",
  12865. description = "A label for the Texture that will show up in debugging tools."
  12866. }
  12867. }
  12868. }
  12869. },
  12870. returns = {
  12871. {
  12872. name = "texture",
  12873. type = "Texture",
  12874. description = "The new Texture."
  12875. }
  12876. }
  12877. },
  12878. {
  12879. arguments = {
  12880. {
  12881. name = "blob",
  12882. type = "Blob",
  12883. description = "A Blob object holding pixel data to load into the Texture."
  12884. },
  12885. {
  12886. name = "options",
  12887. type = "table",
  12888. description = "Texture options.",
  12889. table = {
  12890. {
  12891. name = "type",
  12892. type = "TextureType",
  12893. description = "The type of the texture."
  12894. },
  12895. {
  12896. name = "format",
  12897. type = "TextureFormat",
  12898. description = "The format of the texture (ignored when images are provided).",
  12899. default = "'rgba8'"
  12900. },
  12901. {
  12902. name = "linear",
  12903. type = "boolean",
  12904. description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
  12905. default = "false"
  12906. },
  12907. {
  12908. name = "samples",
  12909. type = "number",
  12910. description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
  12911. default = "1"
  12912. },
  12913. {
  12914. name = "mipmaps",
  12915. type = "*",
  12916. description = "The number of mipmap levels in the texture, or a boolean. If true, a full mipmap chain will be created. If false, the texture will only have a single mipmap.",
  12917. default = "true"
  12918. },
  12919. {
  12920. name = "usage",
  12921. type = "table",
  12922. description = "A list of `TextureUsage` indicating how the texture will be used."
  12923. },
  12924. {
  12925. name = "label",
  12926. type = "string",
  12927. description = "A label for the Texture that will show up in debugging tools."
  12928. }
  12929. }
  12930. }
  12931. },
  12932. returns = {
  12933. {
  12934. name = "texture",
  12935. type = "Texture",
  12936. description = "The new Texture."
  12937. }
  12938. }
  12939. }
  12940. }
  12941. },
  12942. {
  12943. name = "present",
  12944. tag = "work-submission",
  12945. summary = "Update the desktop window contents.",
  12946. description = "Presents the window texture to the desktop window. This function is called automatically by the default implementation of `lovr.run`, so it normally does not need to be called.",
  12947. key = "lovr.graphics.present",
  12948. module = "lovr.graphics",
  12949. notes = "This should be called after submitting the window pass (`lovr.graphics.getWindowPass`). If the window texture has not been rendered to since the last present, this function does nothing.",
  12950. related = {
  12951. "lovr.graphics.submit",
  12952. "lovr.graphics.getWindowPass"
  12953. },
  12954. variants = {
  12955. {
  12956. arguments = {},
  12957. returns = {}
  12958. }
  12959. }
  12960. },
  12961. {
  12962. name = "setBackgroundColor",
  12963. tag = "graphics-global",
  12964. summary = "Set the background color.",
  12965. description = "Changes the global background color. The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified. Additionally, the headset and window will be cleared to this color before rendering.",
  12966. key = "lovr.graphics.setBackgroundColor",
  12967. module = "lovr.graphics",
  12968. notes = "Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called.\n\nInternally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getWindowPass`. Both are called automatically by the default `lovr.run` implementation.\n\nUsing the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.",
  12969. related = {
  12970. "lovr.graphics.newPass",
  12971. "Pass:setClear",
  12972. "Texture:clear",
  12973. "Pass:fill"
  12974. },
  12975. variants = {
  12976. {
  12977. arguments = {
  12978. {
  12979. name = "r",
  12980. type = "number",
  12981. description = "The red component of the background color."
  12982. },
  12983. {
  12984. name = "g",
  12985. type = "number",
  12986. description = "The green component of the background color."
  12987. },
  12988. {
  12989. name = "b",
  12990. type = "number",
  12991. description = "The blue component of the background color."
  12992. },
  12993. {
  12994. name = "a",
  12995. type = "number",
  12996. description = "The alpha component of the background color.",
  12997. default = "1.0"
  12998. }
  12999. },
  13000. returns = {}
  13001. },
  13002. {
  13003. arguments = {
  13004. {
  13005. name = "hex",
  13006. type = "number",
  13007. description = "A hexcode (like `0xffffff`) to use for the background color (does not support alpha)."
  13008. },
  13009. {
  13010. name = "a",
  13011. type = "number",
  13012. description = "The alpha component of the background color.",
  13013. default = "1.0"
  13014. }
  13015. },
  13016. returns = {}
  13017. },
  13018. {
  13019. arguments = {
  13020. {
  13021. name = "table",
  13022. type = "table",
  13023. description = "A table containing 3 or 4 color components."
  13024. }
  13025. },
  13026. returns = {}
  13027. }
  13028. }
  13029. },
  13030. {
  13031. name = "setTimingEnabled",
  13032. tag = "graphics-global",
  13033. summary = "Enable or disable timing stats.",
  13034. description = "Enables or disables timing stats. When enabled, `Pass:getStats` will return `submitTime` and `gpuTime` durations. Timing is enabled by default when `t.graphics.debug` is set in `lovr.conf`. Timing has a small amount of overhead, so it should only be enabled when needed.",
  13035. key = "lovr.graphics.setTimingEnabled",
  13036. module = "lovr.graphics",
  13037. related = {
  13038. "Pass:getStats"
  13039. },
  13040. variants = {
  13041. {
  13042. arguments = {
  13043. {
  13044. name = "enable",
  13045. type = "boolean",
  13046. description = "Whether timing should be enabled."
  13047. }
  13048. },
  13049. returns = {}
  13050. }
  13051. }
  13052. },
  13053. {
  13054. name = "submit",
  13055. tag = "work-submission",
  13056. summary = "Submit recorded graphics work to the GPU.",
  13057. description = "Submits work to the GPU.",
  13058. key = "lovr.graphics.submit",
  13059. module = "lovr.graphics",
  13060. notes = "The submitted `Pass` objects will run in the order specified. Commands within a single Pass do not have any ordering guarantees.\n\nSubmitting work to the GPU is not thread safe. No other `lovr.graphics` or `Pass` functions may run at the same time as `lovr.graphics.submit`.\n\nCalling this function will invalidate any temporary buffers or passes that were created during the frame.\n\nSubmitting work to the GPU is a relatively expensive operation. It's a good idea to batch all `Pass` objects into 1 submission if possible, unless there's a good reason not to. One such reason would be that the frame has so much work that some of it needs to be submitted early to prevent the GPU from running out of things to do. Another would be for `Readback` objects.\n\nBy default, this function is called with the default pass at the end of `lovr.draw` and `lovr.mirror`.\n\nIt is valid to submit zero passes. This will send an empty batch of work to the GPU.",
  13061. related = {
  13062. "lovr.graphics.wait"
  13063. },
  13064. variants = {
  13065. {
  13066. arguments = {
  13067. {
  13068. name = "...",
  13069. type = "Pass",
  13070. description = "The pass objects to submit. Falsy values will be skipped."
  13071. }
  13072. },
  13073. returns = {
  13074. {
  13075. name = "true",
  13076. type = "boolean",
  13077. description = "Always returns true, for convenience when returning from `lovr.draw`."
  13078. }
  13079. }
  13080. },
  13081. {
  13082. arguments = {
  13083. {
  13084. name = "t",
  13085. type = "table",
  13086. description = "A table of passes to submit. Falsy values will be skipped."
  13087. }
  13088. },
  13089. returns = {
  13090. {
  13091. name = "true",
  13092. type = "boolean",
  13093. description = "Always returns true, for convenience when returning from `lovr.draw`."
  13094. }
  13095. }
  13096. }
  13097. }
  13098. },
  13099. {
  13100. name = "wait",
  13101. tag = "work-submission",
  13102. summary = "Stall the CPU until all submitted GPU work is finished.",
  13103. description = "Waits for all submitted GPU work to finish. A normal application that is trying to render graphics at a high framerate should never use this function, since waiting like this prevents the CPU from doing other useful work. Otherwise, reasons to use this function might be for debugging or to force a `Readback` to finish immediately.",
  13104. key = "lovr.graphics.wait",
  13105. module = "lovr.graphics",
  13106. related = {
  13107. "lovr.graphics.submit"
  13108. },
  13109. variants = {
  13110. {
  13111. arguments = {},
  13112. returns = {}
  13113. }
  13114. }
  13115. }
  13116. },
  13117. objects = {
  13118. {
  13119. name = "Buffer",
  13120. summary = "A block of memory on the GPU.",
  13121. description = "A Buffer is a block of memory on the GPU. It's like a GPU version of a `Blob`. Lua code can write data to the buffer which uploads to VRAM, and shaders read buffer data during rendering. Compute shaders can also write to buffers.\n\nThe **size** of a Buffer is the number of bytes of VRAM it occupies. It's set when the Buffer is created and can't be changed afterwards.\n\nBuffers can optionally have a **format**, which defines the type of data stored in the buffer. The format determines how Lua values are converted into binary. Like the size, it can't change after the buffer is created. `Shader:getBufferFormat` returns the format of a variable in a `Shader`.\n\nWhen a Buffer has a format, it also has a **length**, which is the number of items it holds, and a **stride**, which is the number of bytes between each item.\n\n`Buffer:setData` is used to upload data to the Buffer. `Buffer:clear` can also be used to efficiently zero out a Buffer.\n\n`Buffer:getData` can be used to download data from the Buffer, but be aware that it stalls the GPU until the download is complete, which is very slow! `Buffer:newReadback` will instead download the data in the background, which avoids costly stalls.\n\nBuffers are often used for mesh data. Vertices stored in buffers can be drawn using `Pass:mesh`. `Mesh` objects can also be used, which wrap Buffers along with some extra metadata.\n\nBuffers can be \"bound\" to a variable in a Shader using `Pass:send`. That means that the next time the shader runs, the data from the Buffer will be used for the stuff in the variable.\n\nIt's important to understand that data from a Buffer will only be used at the point when graphics commands are actually submitted. This example records 2 draws, changing the buffer data between each one:\n\n buffer:setData(data1)\n pass:mesh(buffer)\n buffer:setData(data2)\n pass:mesh(buffer)\n lovr.graphics.submit(pass)\n\n**Both** draws will use `data2` here! That's because `lovr.graphics.submit` is where the draws actually get processed, so they both see the \"final\" state of the buffer. The data in a Buffer can't be 2 things at once! If you need multiple versions of data, it's best to use a bigger buffer with offsets (or multiple buffers).",
  13122. key = "Buffer",
  13123. module = "lovr.graphics",
  13124. constructors = {
  13125. "lovr.graphics.newBuffer",
  13126. "lovr.graphics.getBuffer"
  13127. },
  13128. methods = {
  13129. {
  13130. name = "clear",
  13131. tag = "buffer-transfer",
  13132. summary = "Clear data in the Buffer.",
  13133. description = "Clears a range of data in the Buffer to a value.",
  13134. key = "Buffer:clear",
  13135. module = "lovr.graphics",
  13136. related = {
  13137. "Texture:clear"
  13138. },
  13139. variants = {
  13140. {
  13141. arguments = {
  13142. {
  13143. name = "offset",
  13144. type = "number",
  13145. description = "The offset of the range of the Buffer to clear, in bytes. Must be a multiple of 4.",
  13146. default = "0"
  13147. },
  13148. {
  13149. name = "extent",
  13150. type = "number",
  13151. description = "The number of bytes to clear. If `nil`, clears to the end of the Buffer. Must be a multiple of 4.",
  13152. default = "nil"
  13153. },
  13154. {
  13155. name = "value",
  13156. type = "number",
  13157. description = "The value to clear to. This will be interpreted as a 32 bit number, which will be repeated across the clear range.",
  13158. default = "0x00000000"
  13159. }
  13160. },
  13161. returns = {}
  13162. }
  13163. }
  13164. },
  13165. {
  13166. name = "getData",
  13167. tag = "buffer-transfer",
  13168. summary = "Get the data in the Buffer.",
  13169. description = "Downloads the Buffer's data from VRAM and returns it as a table. This function is very very slow because it stalls the CPU until the data is finished downloading, so it should only be used for debugging or non-interactive scripts. `Buffer:newReadback` is an alternative that returns a `Readback` object, which will not block the CPU.",
  13170. key = "Buffer:getData",
  13171. module = "lovr.graphics",
  13172. notes = "The length of the table will equal the number of items read. Here are some examples of how the table is formatted:\n\n buffer = lovr.graphics.newBuffer('int', { 7 })\n buffer:getData() --> returns { 7 }\n\n buffer = lovr.graphics.newBuffer('vec3', { 7, 8, 9 })\n buffer:getData() --> returns {{ 7, 8, 9 }}\n\n buffer = lovr.graphics.newBuffer('int', { 1, 2, 3 })\n buffer:getData() --> returns { 1, 2, 3 }\n\n buffer = lovr.graphics.newBuffer({ 'vec2', 'vec2' }, {\n vec2(1,2), vec2(3,4),\n vec2(5,6), vec2(7,8)\n })\n buffer:getData() --> returns { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } }\n\n buffer = lovr.graphics.newBuffer({\n { 'a', 'float' },\n { 'b', 'float' }\n }, { a = 1, b = 2 })\n buffer:getData() --> returns { { 1, 2 } }\n\n buffer = lovr.graphics.newBuffer({\n { 'x', 'int', 3 }\n }, { x = { 1, 2, 3 } })\n buffer:getData() --> returns { { x = { 1, 2, 3 } } }\n\n buffer = lovr.graphics.newBuffer({\n { 'lights', {\n { 'pos', 'vec3' },\n { 'size', 'float' },\n }, 10}\n }, data)\n buffer:getData() --> returns { { lights = { { pos = ..., size = ... }, ... } } }\n\nIn summary, each individual item is wrapped in a table, except if the format is a single number. If the format has nested types or arrays then the tables will be key-value, otherwise they will use numeric keys.",
  13173. related = {
  13174. "Buffer:newReadback",
  13175. "Buffer:mapData",
  13176. "Readback:getData"
  13177. },
  13178. variants = {
  13179. {
  13180. arguments = {
  13181. {
  13182. name = "index",
  13183. type = "number",
  13184. description = "The index of the first item to read.",
  13185. default = "1"
  13186. },
  13187. {
  13188. name = "count",
  13189. type = "number",
  13190. description = "The number of items to read. If nil, reads the remainder of the buffer.",
  13191. default = "nil"
  13192. }
  13193. },
  13194. returns = {
  13195. {
  13196. name = "t",
  13197. type = "table",
  13198. description = "The table with the Buffer's data."
  13199. }
  13200. }
  13201. }
  13202. }
  13203. },
  13204. {
  13205. name = "getFormat",
  13206. tag = "buffer-metadata",
  13207. summary = "Get the format of the Buffer.",
  13208. description = "Returns the format the Buffer was created with.",
  13209. key = "Buffer:getFormat",
  13210. module = "lovr.graphics",
  13211. examples = {
  13212. {
  13213. code = "function lovr.load()\n buffer = lovr.graphics.newBuffer({\n { 'a', 'float' },\n { 'b', 'un16x2' }\n })\n\n for i, field in ipairs(buffer:getFormat()) do\n print(('%s: %s'):format(field.name, field.type))\n end\n\n -- prints the following:\n -- a: f32\n -- b: un16x2\nend"
  13214. }
  13215. },
  13216. related = {
  13217. "Buffer:getSize",
  13218. "Buffer:getLength",
  13219. "Buffer:getStride"
  13220. },
  13221. variants = {
  13222. {
  13223. arguments = {},
  13224. returns = {
  13225. {
  13226. name = "format",
  13227. type = "table",
  13228. description = "A list of fields comprising the format.",
  13229. table = {
  13230. {
  13231. name = "[].name",
  13232. type = "string",
  13233. description = "The name of the field (if fields were created with names)."
  13234. },
  13235. {
  13236. name = "[].type",
  13237. type = "*",
  13238. description = "The `DataType` of the field, or a recursive table with the sub-format."
  13239. },
  13240. {
  13241. name = "[].offset",
  13242. type = "number",
  13243. description = "The offset of the field relative to its parent, in bytes."
  13244. },
  13245. {
  13246. name = "[].length",
  13247. type = "number",
  13248. description = "The array length of the field, or `nil` if it's not an array."
  13249. },
  13250. {
  13251. name = "[].stride",
  13252. type = "number",
  13253. description = "The stride of the field in bytes, or `nil` if it's not an array."
  13254. }
  13255. }
  13256. }
  13257. }
  13258. }
  13259. }
  13260. },
  13261. {
  13262. name = "getLength",
  13263. tag = "buffer-metadata",
  13264. summary = "Get the length of the Buffer.",
  13265. description = "Returns the length of the Buffer, or `nil` if the Buffer was not created with a format.",
  13266. key = "Buffer:getLength",
  13267. module = "lovr.graphics",
  13268. related = {
  13269. "Buffer:getSize",
  13270. "Buffer:getStride"
  13271. },
  13272. variants = {
  13273. {
  13274. arguments = {},
  13275. returns = {
  13276. {
  13277. name = "length",
  13278. type = "number",
  13279. description = "The length of the Buffer."
  13280. }
  13281. }
  13282. }
  13283. }
  13284. },
  13285. {
  13286. name = "getPointer",
  13287. tag = "buffer-transfer",
  13288. summary = "Get a writable pointer to the Buffer's memory.",
  13289. description = "Returns a pointer to GPU memory and schedules a copy from this pointer to the buffer's data. The data in the pointer will replace the data in the buffer. This is intended for use with the LuaJIT FFI or for passing to C libraries.",
  13290. key = "Buffer:getPointer",
  13291. module = "lovr.graphics",
  13292. deprecated = true,
  13293. notes = "The pointer remains valid until the next call to `lovr.graphics.submit`, during which the data in the pointer will be uploaded to the buffer.\n\nThe initial contents of the pointer are undefined.\n\nSpecial care should be taken when writing data:\n\n- Reading data from the pointer will be very slow on some systems, and should be avoided.\n- It is better to write data to the pointer sequentially. Random access may be slower.",
  13294. related = {
  13295. "Blob:getPointer",
  13296. "Buffer:mapData"
  13297. },
  13298. variants = {
  13299. {
  13300. arguments = {
  13301. {
  13302. name = "offset",
  13303. type = "number",
  13304. description = "A byte offset in the buffer to write to.",
  13305. default = "0"
  13306. },
  13307. {
  13308. name = "extent",
  13309. type = "number",
  13310. description = "The number of bytes to replace. If nil, writes to the rest of the buffer.",
  13311. default = "nil"
  13312. }
  13313. },
  13314. returns = {
  13315. {
  13316. name = "pointer",
  13317. type = "lightuserdata",
  13318. description = "A pointer to the Buffer's memory."
  13319. }
  13320. }
  13321. }
  13322. }
  13323. },
  13324. {
  13325. name = "getSize",
  13326. tag = "buffer-metadata",
  13327. summary = "Get the size of the Buffer, in bytes.",
  13328. description = "Returns the size of the Buffer in VRAM, in bytes. This is the same as `length * stride`.\n\nThe size of the Buffer can't change after it's created.",
  13329. key = "Buffer:getSize",
  13330. module = "lovr.graphics",
  13331. related = {
  13332. "Buffer:getLength",
  13333. "Buffer:getStride"
  13334. },
  13335. variants = {
  13336. {
  13337. arguments = {},
  13338. returns = {
  13339. {
  13340. name = "size",
  13341. type = "number",
  13342. description = "The size of the Buffer, in bytes."
  13343. }
  13344. }
  13345. }
  13346. }
  13347. },
  13348. {
  13349. name = "getStride",
  13350. tag = "buffer-metadata",
  13351. summary = "Get the stride of the Buffer, in bytes.",
  13352. description = "Returns the distance between each item in the Buffer, in bytes, or `nil` if the Buffer was not created with a format.",
  13353. key = "Buffer:getStride",
  13354. module = "lovr.graphics",
  13355. notes = "When a Buffer is created, the stride can be set explicitly, otherwise it will be automatically computed based on the fields in the Buffer.\n\nStrides can not be zero, and can not be smaller than the size of a single item.",
  13356. related = {
  13357. "Buffer:getSize",
  13358. "Buffer:getLength"
  13359. },
  13360. variants = {
  13361. {
  13362. arguments = {},
  13363. returns = {
  13364. {
  13365. name = "stride",
  13366. type = "number",
  13367. description = "The stride of the Buffer, in bytes."
  13368. }
  13369. }
  13370. }
  13371. }
  13372. },
  13373. {
  13374. name = "isTemporary",
  13375. tag = "buffer-metadata",
  13376. summary = "Check if the Buffer is temporary.",
  13377. description = "Returns whether the Buffer is temporary.",
  13378. key = "Buffer:isTemporary",
  13379. module = "lovr.graphics",
  13380. deprecated = true,
  13381. related = {
  13382. "lovr.graphics.getBuffer"
  13383. },
  13384. variants = {
  13385. {
  13386. arguments = {},
  13387. returns = {
  13388. {
  13389. name = "temporary",
  13390. type = "boolean",
  13391. description = "Whether the Buffer is temporary."
  13392. }
  13393. }
  13394. }
  13395. }
  13396. },
  13397. {
  13398. name = "mapData",
  13399. tag = "buffer-transfer",
  13400. summary = "Get a writable pointer to the Buffer's memory.",
  13401. description = "Returns a pointer to GPU memory and schedules a copy from this pointer to the buffer's data. The data in the pointer will replace the data in the buffer. This is intended for use with the LuaJIT FFI or for passing to C libraries.",
  13402. key = "Buffer:mapData",
  13403. module = "lovr.graphics",
  13404. notes = "The pointer remains valid until the next call to `lovr.graphics.submit`, during which the data in the pointer will be uploaded to the buffer.\n\nThe initial contents of the pointer are undefined.\n\nSpecial care should be taken when writing data:\n\n- Reading data from the pointer will be very slow on some systems, and should be avoided.\n- It is better to write data to the pointer sequentially. Random access may be slower.",
  13405. related = {
  13406. "Blob:getPointer",
  13407. "Buffer:getPointer"
  13408. },
  13409. variants = {
  13410. {
  13411. arguments = {
  13412. {
  13413. name = "offset",
  13414. type = "number",
  13415. description = "A byte offset in the buffer to write to.",
  13416. default = "0"
  13417. },
  13418. {
  13419. name = "extent",
  13420. type = "number",
  13421. description = "The number of bytes to replace. If nil, writes to the rest of the buffer.",
  13422. default = "nil"
  13423. }
  13424. },
  13425. returns = {
  13426. {
  13427. name = "pointer",
  13428. type = "lightuserdata",
  13429. description = "A pointer to the Buffer's memory."
  13430. }
  13431. }
  13432. }
  13433. }
  13434. },
  13435. {
  13436. name = "newReadback",
  13437. tag = "buffer-transfer",
  13438. summary = "Read back the contents of the Buffer asynchronously.",
  13439. description = "Creates and returns a new `Readback` that will download the data in the Buffer from VRAM. Once the readback is complete, `Readback:getData` returns the data as a table, or `Readback:getBlob` returns the data as a `Blob`.",
  13440. key = "Buffer:newReadback",
  13441. module = "lovr.graphics",
  13442. notes = "The offset and extent arguments must be a multiple of the Buffer's stride (unless it was created without a format).",
  13443. related = {
  13444. "Buffer:getData",
  13445. "Texture:newReadback"
  13446. },
  13447. variants = {
  13448. {
  13449. arguments = {
  13450. {
  13451. name = "offset",
  13452. type = "number",
  13453. description = "A byte offset to read from.",
  13454. default = "0"
  13455. },
  13456. {
  13457. name = "extent",
  13458. type = "number",
  13459. description = "The number of bytes to read. If nil, reads the rest of the buffer.",
  13460. default = "nil"
  13461. }
  13462. },
  13463. returns = {
  13464. {
  13465. name = "readback",
  13466. type = "Readback",
  13467. description = "A new Readback object."
  13468. }
  13469. }
  13470. }
  13471. }
  13472. },
  13473. {
  13474. name = "setData",
  13475. tag = "buffer-transfer",
  13476. summary = "Change the data in the Buffer.",
  13477. description = "Copies data to the Buffer from either a table, `Blob`, or `Buffer`.",
  13478. key = "Buffer:setData",
  13479. module = "lovr.graphics",
  13480. examples = {
  13481. {
  13482. description = "Various examples of copying different formats.",
  13483. code = "function lovr.load()\n buffer = lovr.graphics.newBuffer('int', 3)\n buffer:setData({ 1, 2, 3 })\n\n buffer = lovr.graphics.newBuffer('vec3', 2)\n buffer:setData({ 1,2,3, 4,5,6 })\n buffer:setData({ { 1, 2, 3 }, { 4, 5, 6 } })\n buffer:setData({ vec3(1, 2, 3), vec3(4, 5, 6) })\n\n -- When the Buffer's length is 1, wrapping in table is optional:\n buffer = lovr.graphics.newBuffer('vec3')\n buffer:setData(1, 2, 3)\n buffer:setData(vec3(1, 2, 3))\n\n -- Same for key-value structs\n buffer = lovr.graphics.newBuffer({\n { 'x', 'float' },\n { 'y', 'float' }\n })\n buffer:setData({ x = 1, y = 2 })\n\n -- Key/value formats\n buffer = lovr.graphics.newBuffer({\n { 'x', 'float' },\n { 'y', 'float' }\n }, 3)\n buffer:setData({\n { x = 1, y = 2 },\n { x = 3, y = 4 },\n { x = 5, y = 6 }\n })\n buffer:setData({ 1, 2, 3, 4, 5, 6 })\n buffer:setData({ { 1, 2 }, { 3, 4 }, { 5, 6 } })\n\n -- Nested formats\n buffer = lovr.graphics.newBuffer({\n { 'a', {\n {'b', {\n 'c', 'float'\n }}\n }}\n })\n buffer:setData({ a = { b = { c = 42 } } })\n\n -- Inner arrays\n buffer = lovr.graphics.newBuffer({\n { 'positions', 'vec3', 10 },\n { 'sizes', 'float', 10 },\n layout = 'std140'\n })\n local data = { positions = {}, sizes = {} }\n for i = 1, buffer:getLength() do\n data.positions[i] = vec3(i, i, i)\n data.sizes[i] = i\n end\n buffer:setData(data)\nend"
  13484. }
  13485. },
  13486. notes = "One gotcha is that unspecified fields will be set to zero. Here's an example:\n\n buffer = lovr.graphics.newBuffer({{ 'x', 'int' }, { 'y', 'int' }})\n buffer:setData({ x = 1, y = 1 }) -- set the data\n buffer:setData({ x = 1 }) -- set the data, partially\n -- buffer data is now {x=1, y=0}!\n\nThis doesn't apply to separate items in the buffer. For example, if the Buffer's length is 2 and only the 1st item is set, the second item will remain undisturbed:\n\n buffer = lovr.graphics.newBuffer({{ 'x', 'int' }, { 'y', 'int' }}, 2)\n buffer:setData({{ x = 1, y = 1 }, { x = 2, y = 2 }}) -- set the data\n buffer:setData({{ x = 1 }}) -- set one item, partially\n -- buffer data is now {{x=1, y=0}, {x=2, y=2}}",
  13487. variants = {
  13488. {
  13489. arguments = {
  13490. {
  13491. name = "table",
  13492. type = "table",
  13493. description = "A flat or nested table of items to copy to the Buffer (see notes for format)."
  13494. },
  13495. {
  13496. name = "destinationIndex",
  13497. type = "number",
  13498. description = "The index of the first value in the Buffer to update.",
  13499. default = "1"
  13500. },
  13501. {
  13502. name = "sourceIndex",
  13503. type = "number",
  13504. description = "The index in the table to copy from.",
  13505. default = "1"
  13506. },
  13507. {
  13508. name = "count",
  13509. type = "number",
  13510. description = "The number of items to copy. `nil` will copy as many items as possible, based on the lengths of the source and destination.",
  13511. default = "nil"
  13512. }
  13513. },
  13514. returns = {}
  13515. },
  13516. {
  13517. description = "Copies a single field to a buffer with numbers (buffer length must be 1).",
  13518. arguments = {
  13519. {
  13520. name = "...numbers",
  13521. type = "number",
  13522. description = "Numerical components to copy to the buffer."
  13523. }
  13524. },
  13525. returns = {}
  13526. },
  13527. {
  13528. description = "Copies a single vector to a buffer (buffer length must be 1).",
  13529. arguments = {
  13530. {
  13531. name = "vector",
  13532. type = "*",
  13533. description = "Vector objects to copy to the buffer."
  13534. }
  13535. },
  13536. returns = {}
  13537. },
  13538. {
  13539. arguments = {
  13540. {
  13541. name = "blob",
  13542. type = "Blob",
  13543. description = "The Blob to copy data from."
  13544. },
  13545. {
  13546. name = "destinationOffset",
  13547. type = "number",
  13548. description = "The byte offset to copy to.",
  13549. default = "0"
  13550. },
  13551. {
  13552. name = "sourceOffset",
  13553. type = "number",
  13554. description = "The byte offset to copy from.",
  13555. default = "0"
  13556. },
  13557. {
  13558. name = "size",
  13559. type = "number",
  13560. description = "The number of bytes to copy. If nil, copies as many bytes as possible.",
  13561. default = "nil"
  13562. }
  13563. },
  13564. returns = {}
  13565. },
  13566. {
  13567. arguments = {
  13568. {
  13569. name = "buffer",
  13570. type = "Buffer",
  13571. description = "The Buffer to copy data from."
  13572. },
  13573. {
  13574. name = "destinationOffset",
  13575. type = "number",
  13576. description = "The byte offset to copy to.",
  13577. default = "0"
  13578. },
  13579. {
  13580. name = "sourceOffset",
  13581. type = "number",
  13582. description = "The byte offset to copy from.",
  13583. default = "0"
  13584. },
  13585. {
  13586. name = "size",
  13587. type = "number",
  13588. description = "The number of bytes to copy. If nil, copies as many bytes as possible.",
  13589. default = "nil"
  13590. }
  13591. },
  13592. returns = {}
  13593. }
  13594. }
  13595. }
  13596. },
  13597. sections = {
  13598. {
  13599. name = "Metadata",
  13600. tag = "buffer-metadata"
  13601. },
  13602. {
  13603. name = "Transfers",
  13604. tag = "buffer-transfer"
  13605. }
  13606. }
  13607. },
  13608. {
  13609. name = "Font",
  13610. summary = "A Font used to render text.",
  13611. description = "Font objects are used to render text with `Pass:text`. The active font can be changed using `Pass:setFont`. The default font is Varela Round, which is used when no font is active, and can be retrieved using `lovr.graphics.getDefaultFont`. Custom fonts can be loaded from TTF files using `lovr.graphics.newFont`.\n\nEach Font uses a `Rasterizer` to load the TTF file and create images for each glyph. As text is drawn, the Font uploads images from the Rasterizer to a GPU texture atlas as needed. The Font also performs text layout and mesh generation for strings of text.\n\nLÖVR uses a text rendering technique called \"multichannel signed distance fields\" (MSDF), which makes the font rendering remain crisp when text is viewed up close.",
  13612. key = "Font",
  13613. module = "lovr.graphics",
  13614. constructors = {
  13615. "lovr.graphics.newFont",
  13616. "lovr.graphics.getDefaultFont"
  13617. },
  13618. methods = {
  13619. {
  13620. name = "getAscent",
  13621. summary = "Get the ascent of the Font.",
  13622. description = "Returns the ascent of the font. The ascent is the maximum amount glyphs ascend above the baseline. The units depend on the font's pixel density. With the default density, the units correspond to meters.",
  13623. key = "Font:getAscent",
  13624. module = "lovr.graphics",
  13625. related = {
  13626. "Rasterizer:getAscent",
  13627. "Font:getDescent",
  13628. "Font:getHeight",
  13629. "Font:getKerning",
  13630. "Font:getWidth"
  13631. },
  13632. variants = {
  13633. {
  13634. arguments = {},
  13635. returns = {
  13636. {
  13637. name = "ascent",
  13638. type = "number",
  13639. description = "The ascent of the font."
  13640. }
  13641. }
  13642. }
  13643. }
  13644. },
  13645. {
  13646. name = "getDescent",
  13647. summary = "Get the descent of the Font.",
  13648. description = "Returns the descent of the font. The descent is the maximum amount glyphs descend below the baseline. The units depend on the font's pixel density. With the default density, the units correspond to meters.",
  13649. key = "Font:getDescent",
  13650. module = "lovr.graphics",
  13651. related = {
  13652. "Rasterizer:getDescent",
  13653. "Font:getAscent",
  13654. "Font:getHeight",
  13655. "Font:getKerning",
  13656. "Font:getWidth"
  13657. },
  13658. variants = {
  13659. {
  13660. arguments = {},
  13661. returns = {
  13662. {
  13663. name = "descent",
  13664. type = "number",
  13665. description = "The descent of the font."
  13666. }
  13667. }
  13668. }
  13669. }
  13670. },
  13671. {
  13672. name = "getHeight",
  13673. summary = "Get the height of the Font.",
  13674. description = "Returns the height of the font, sometimes also called the leading. This is the full height of a line of text, including the space between lines. Each line of a multiline string is separated on the y axis by this height, multiplied by the font's line spacing. The units depend on the font's pixel density. With the default density, the units correspond to meters.",
  13675. key = "Font:getHeight",
  13676. module = "lovr.graphics",
  13677. related = {
  13678. "Rasterizer:getLeading",
  13679. "Font:getLineSpacing",
  13680. "Font:setLineSpacing",
  13681. "Font:getAscent",
  13682. "Font:getDescent",
  13683. "Font:getKerning",
  13684. "Font:getWidth",
  13685. "Font:getLines"
  13686. },
  13687. variants = {
  13688. {
  13689. arguments = {},
  13690. returns = {
  13691. {
  13692. name = "height",
  13693. type = "number",
  13694. description = "The height of the font."
  13695. }
  13696. }
  13697. }
  13698. }
  13699. },
  13700. {
  13701. name = "getKerning",
  13702. summary = "Get the kerning between 2 glyphs.",
  13703. description = "Returns the kerning between 2 glyphs. Kerning is a slight horizontal adjustment between 2 glyphs to improve the visual appearance. It will often be negative. The units depend on the font's pixel density. With the default density, the units correspond to meters.",
  13704. key = "Font:getKerning",
  13705. module = "lovr.graphics",
  13706. related = {
  13707. "Rasterizer:getKerning",
  13708. "Font:getAscent",
  13709. "Font:getDescent",
  13710. "Font:getHeight",
  13711. "Font:getWidth"
  13712. },
  13713. variants = {
  13714. {
  13715. arguments = {
  13716. {
  13717. name = "first",
  13718. type = "string",
  13719. description = "The first character."
  13720. },
  13721. {
  13722. name = "second",
  13723. type = "string",
  13724. description = "The second character."
  13725. }
  13726. },
  13727. returns = {
  13728. {
  13729. name = "keming",
  13730. type = "number",
  13731. description = "The kerning between the two glyphs."
  13732. }
  13733. }
  13734. },
  13735. {
  13736. arguments = {
  13737. {
  13738. name = "firstCodepoint",
  13739. type = "number",
  13740. description = "The first codepoint."
  13741. },
  13742. {
  13743. name = "second",
  13744. type = "string",
  13745. description = "The second character."
  13746. }
  13747. },
  13748. returns = {
  13749. {
  13750. name = "keming",
  13751. type = "number",
  13752. description = "The kerning between the two glyphs."
  13753. }
  13754. }
  13755. },
  13756. {
  13757. arguments = {
  13758. {
  13759. name = "first",
  13760. type = "string",
  13761. description = "The first character."
  13762. },
  13763. {
  13764. name = "secondCodepoint",
  13765. type = "number",
  13766. description = "The second codepoint."
  13767. }
  13768. },
  13769. returns = {
  13770. {
  13771. name = "keming",
  13772. type = "number",
  13773. description = "The kerning between the two glyphs."
  13774. }
  13775. }
  13776. },
  13777. {
  13778. arguments = {
  13779. {
  13780. name = "firstCodepoint",
  13781. type = "number",
  13782. description = "The first codepoint."
  13783. },
  13784. {
  13785. name = "secondCodepoint",
  13786. type = "number",
  13787. description = "The second codepoint."
  13788. }
  13789. },
  13790. returns = {
  13791. {
  13792. name = "keming",
  13793. type = "number",
  13794. description = "The kerning between the two glyphs."
  13795. }
  13796. }
  13797. }
  13798. }
  13799. },
  13800. {
  13801. name = "getLineSpacing",
  13802. summary = "Get the line spacing of the Font.",
  13803. description = "Returns the line spacing of the Font. When spacing out lines, the height of the font is multiplied the line spacing to get the final spacing value. The default is 1.0.",
  13804. key = "Font:getLineSpacing",
  13805. module = "lovr.graphics",
  13806. related = {
  13807. "Font:getHeight"
  13808. },
  13809. variants = {
  13810. {
  13811. arguments = {},
  13812. returns = {
  13813. {
  13814. name = "spacing",
  13815. type = "number",
  13816. description = "The line spacing of the font."
  13817. }
  13818. }
  13819. }
  13820. }
  13821. },
  13822. {
  13823. name = "getLines",
  13824. summary = "Wrap a string into a sequence of lines.",
  13825. description = "Returns a table of wrapped lines for a piece of text, given a line length limit. Newlines are handled correctly. The wrap limit units depend on the pixel density of the font. With the default pixel density, the units correspond to meters when the font is drawn at 1.0 scale.",
  13826. key = "Font:getLines",
  13827. module = "lovr.graphics",
  13828. related = {
  13829. "Font:getWidth",
  13830. "Font:getHeight",
  13831. "Pass:text"
  13832. },
  13833. variants = {
  13834. {
  13835. arguments = {
  13836. {
  13837. name = "string",
  13838. type = "string",
  13839. description = "The text to wrap."
  13840. },
  13841. {
  13842. name = "wrap",
  13843. type = "number",
  13844. description = "The line length to wrap at."
  13845. }
  13846. },
  13847. returns = {
  13848. {
  13849. name = "lines",
  13850. type = "table",
  13851. description = "A table strings, one for each wrapped line (without any color information)."
  13852. }
  13853. }
  13854. },
  13855. {
  13856. arguments = {
  13857. {
  13858. name = "strings",
  13859. type = "table",
  13860. description = "A table of colored strings, each given as a `{ color, string }` pair. The color can be a `Vec3`, `Vec4`, table, or hexcode."
  13861. },
  13862. {
  13863. name = "wrap",
  13864. type = "number",
  13865. description = "The line length to wrap at."
  13866. }
  13867. },
  13868. returns = {
  13869. {
  13870. name = "lines",
  13871. type = "table",
  13872. description = "A table strings, one for each wrapped line (without any color information)."
  13873. }
  13874. }
  13875. }
  13876. }
  13877. },
  13878. {
  13879. name = "getPixelDensity",
  13880. summary = "Get the pixel density of the Font.",
  13881. description = "Returns the pixel density of the font. The density is a \"pixels per world unit\" factor that controls how the pixels in the font's texture are mapped to units in the coordinate space.\n\nThe default pixel density is set to the height of the font. This means that lines of text rendered with a scale of 1.0 come out to 1 unit (meter) tall. However, if this font was drawn to a 2D texture where the units are in pixels, the font would still be drawn 1 unit (pixel) tall! Scaling the coordinate space or the size of the text by the height of the font would fix this. However, a more convenient option is to set the pixel density of the font to 1.0 when doing 2D rendering to make the font's size match up with the pixels of the canvas.",
  13882. key = "Font:getPixelDensity",
  13883. module = "lovr.graphics",
  13884. variants = {
  13885. {
  13886. arguments = {},
  13887. returns = {
  13888. {
  13889. name = "density",
  13890. type = "number",
  13891. description = "The pixel density of the font."
  13892. }
  13893. }
  13894. }
  13895. }
  13896. },
  13897. {
  13898. name = "getRasterizer",
  13899. summary = "Get the Font's Rasterizer.",
  13900. description = "Returns the Rasterizer object backing the Font.",
  13901. key = "Font:getRasterizer",
  13902. module = "lovr.graphics",
  13903. related = {
  13904. "lovr.graphics.newFont",
  13905. "lovr.data.newRasterizer"
  13906. },
  13907. variants = {
  13908. {
  13909. arguments = {},
  13910. returns = {
  13911. {
  13912. name = "rasterizer",
  13913. type = "Rasterizer",
  13914. description = "The Rasterizer."
  13915. }
  13916. }
  13917. }
  13918. }
  13919. },
  13920. {
  13921. name = "getVertices",
  13922. summary = "Get the vertices for a piece of text.",
  13923. description = "Returns a table of vertices for a piece of text, along with a Material to use when rendering it. The Material returned by this function may not be the same if the Font's texture atlas needs to be recreated with a bigger size to make room for more glyphs.",
  13924. key = "Font:getVertices",
  13925. module = "lovr.graphics",
  13926. notes = "Each vertex is a table of 4 floating point numbers with the following data:\n\n { x, y, u, v }\n\nThese could be placed in a vertex buffer using the following buffer format:\n\n { 'vec2:VertexPosition', 'vec2:VertexUV' }",
  13927. variants = {
  13928. {
  13929. arguments = {
  13930. {
  13931. name = "string",
  13932. type = "string",
  13933. description = "The text to render."
  13934. },
  13935. {
  13936. name = "wrap",
  13937. type = "number",
  13938. description = "The maximum line length. The units depend on the pixel density of the font, but are in meters by default.",
  13939. default = "0"
  13940. },
  13941. {
  13942. name = "halign",
  13943. type = "HorizontalAlign",
  13944. description = "The horizontal align."
  13945. },
  13946. {
  13947. name = "valign",
  13948. type = "VerticalAlign",
  13949. description = "The vertical align."
  13950. }
  13951. },
  13952. returns = {
  13953. {
  13954. name = "vertices",
  13955. type = "table",
  13956. description = "The table of vertices. See below for the format of each vertex."
  13957. },
  13958. {
  13959. name = "material",
  13960. type = "Material",
  13961. description = "A Material to use when rendering the vertices."
  13962. }
  13963. }
  13964. },
  13965. {
  13966. arguments = {
  13967. {
  13968. name = "strings",
  13969. type = "table",
  13970. description = "A table of colored strings, each given as a `{ color, string }` pair. The color can be a `Vec3`, `Vec4`, table, or hexcode."
  13971. },
  13972. {
  13973. name = "wrap",
  13974. type = "number",
  13975. description = "The maximum line length. The units depend on the pixel density of the font, but are in meters by default.",
  13976. default = "0"
  13977. },
  13978. {
  13979. name = "halign",
  13980. type = "HorizontalAlign",
  13981. description = "The horizontal align."
  13982. },
  13983. {
  13984. name = "valign",
  13985. type = "VerticalAlign",
  13986. description = "The vertical align."
  13987. }
  13988. },
  13989. returns = {
  13990. {
  13991. name = "vertices",
  13992. type = "table",
  13993. description = "The table of vertices. See below for the format of each vertex."
  13994. },
  13995. {
  13996. name = "material",
  13997. type = "Material",
  13998. description = "A Material to use when rendering the vertices."
  13999. }
  14000. }
  14001. }
  14002. }
  14003. },
  14004. {
  14005. name = "getWidth",
  14006. summary = "Get the width of rendered text.",
  14007. description = "Returns the maximum width of a piece of text. This function does not perform wrapping but does respect newlines in the text.",
  14008. key = "Font:getWidth",
  14009. module = "lovr.graphics",
  14010. related = {
  14011. "Font:getAscent",
  14012. "Font:getDescent",
  14013. "Font:getHeight",
  14014. "Font:getKerning",
  14015. "Font:getLines"
  14016. },
  14017. variants = {
  14018. {
  14019. arguments = {
  14020. {
  14021. name = "string",
  14022. type = "string",
  14023. description = "The text to measure."
  14024. }
  14025. },
  14026. returns = {
  14027. {
  14028. name = "width",
  14029. type = "number",
  14030. description = "The maximum width of the text."
  14031. }
  14032. }
  14033. },
  14034. {
  14035. arguments = {
  14036. {
  14037. name = "strings",
  14038. type = "table",
  14039. description = "A table of colored strings, each given as a `{ color, string }` pair. The color can be a `Vec3`, `Vec4`, table, or hexcode."
  14040. }
  14041. },
  14042. returns = {
  14043. {
  14044. name = "width",
  14045. type = "number",
  14046. description = "The maximum width of the text."
  14047. }
  14048. }
  14049. }
  14050. }
  14051. },
  14052. {
  14053. name = "setLineSpacing",
  14054. summary = "Set the line spacing of the Font.",
  14055. description = "Sets the line spacing of the Font. When spacing out lines, the height of the font is multiplied by the line spacing to get the final spacing value. The default is 1.0.",
  14056. key = "Font:setLineSpacing",
  14057. module = "lovr.graphics",
  14058. related = {
  14059. "Font:getHeight"
  14060. },
  14061. variants = {
  14062. {
  14063. arguments = {
  14064. {
  14065. name = "spacing",
  14066. type = "number",
  14067. description = "The new line spacing."
  14068. }
  14069. },
  14070. returns = {}
  14071. }
  14072. }
  14073. },
  14074. {
  14075. name = "setPixelDensity",
  14076. summary = "Set the pixel density of the Font.",
  14077. description = "Sets the pixel density of the font. The density is a \"pixels per world unit\" factor that controls how the pixels in the font's texture are mapped to units in the coordinate space.\n\nThe default pixel density is set to the height of the font. This means that lines of text rendered with a scale of 1.0 come out to 1 unit (meter) tall. However, if this font was drawn to a 2D texture where the units are in pixels, the font would still be drawn 1 unit (pixel) tall! Scaling the coordinate space or the size of the text by the height of the font would fix this. However, a more convenient option is to set the pixel density of the font to 1.0 when doing 2D rendering to make the font's size match up with the pixels of the canvas.",
  14078. key = "Font:setPixelDensity",
  14079. module = "lovr.graphics",
  14080. variants = {
  14081. {
  14082. arguments = {
  14083. {
  14084. name = "density",
  14085. type = "number",
  14086. description = "The new pixel density of the font."
  14087. }
  14088. },
  14089. returns = {}
  14090. },
  14091. {
  14092. description = "Resets the pixel density to the default, which is given by `Font:getHeight`.",
  14093. arguments = {},
  14094. returns = {}
  14095. }
  14096. }
  14097. }
  14098. },
  14099. notes = "MSDF text requires a special shader to work. LÖVR will automatically switch to this shader if no shader is active on the `Pass`. This font shader is also available as a `DefaultShader`."
  14100. },
  14101. {
  14102. name = "Material",
  14103. summary = "A set of properties and textures that define the properties of a surface.",
  14104. description = "Materials are a set of properties and textures that define the properties of a surface, like what color it is, how bumpy or shiny it is, etc. `Shader` code can use the data from a material to compute lighting.\n\nMaterials are immutable, and can't be changed after they are created. Instead, a new Material should be created with the updated properties.\n\n`Pass:setMaterial` changes the active material, causing it to affect rendering until the active material is changed again.\n\nUsing material objects is optional. `Pass:setMaterial` can take a `Texture`, and `Pass:setColor` can change the color of objects, so basic tinting and texturing of surfaces does not require a full material to be created. Also, a custom material system could be developed by sending textures and other data to shaders manually.\n\n`Model` objects will create materials for all of the materials defined in the model file.\n\nIn shader code, non-texture material properties can be accessed as `Material.<property>`, and material textures can be accessed as `<Type>Texture`, e.g. `RoughnessTexture`.",
  14105. key = "Material",
  14106. module = "lovr.graphics",
  14107. constructors = {
  14108. "lovr.graphics.newMaterial"
  14109. },
  14110. methods = {
  14111. {
  14112. name = "getProperties",
  14113. summary = "Get the properties of the Material.",
  14114. description = "Returns the properties of the Material in a table.",
  14115. key = "Material:getProperties",
  14116. module = "lovr.graphics",
  14117. variants = {
  14118. {
  14119. arguments = {},
  14120. returns = {
  14121. {
  14122. name = "properties",
  14123. type = "table",
  14124. description = "The Material properties."
  14125. }
  14126. }
  14127. }
  14128. }
  14129. }
  14130. }
  14131. },
  14132. {
  14133. name = "Mesh",
  14134. summary = "A drawable triangle mesh.",
  14135. description = "Meshes store arbitrary geometry data, and can be drawn with `Pass:draw`.\n\nMeshes hold a list of **vertices**. The number of vertices is declared upfront when the Mesh is created, and it can not be resized afterwards.\n\nThe Mesh has a **vertex format**, which is a set of **attributes** comprising each vertex, like a `position`, `color`, etc.\n\nThe **vertex indices** in the Mesh describe the order that the vertices are rendered in. This is an optimization that allows vertices to be reused if they are used for multiple triangles, without duplicating all of their data.\n\nThe Mesh has a **draw mode**, which controls how the vertices are connected together to create pixels. It can either be `points`, `lines`, or `triangles`.\n\nThe Mesh can have a `Material` applied, which defines colors, textures, and other properties of its surface.\n\nThe **draw range** of the Mesh defines a subset of the vertices to render when the Mesh is drawn.\n\nThe **bounding box** of the Mesh allows LÖVR to skip rendering it when it's out of view.",
  14136. key = "Mesh",
  14137. module = "lovr.graphics",
  14138. constructors = {
  14139. "lovr.graphics.newMesh"
  14140. },
  14141. methods = {
  14142. {
  14143. name = "computeBoundingBox",
  14144. summary = "Compute the bounding box of the Mesh.",
  14145. description = "Computes the axis-aligned bounding box of the Mesh from its vertices.\n\nIf the Mesh was created with the `gpu` storage mode, this function will do nothing and return `false`.\n\nIf the Mesh does not have an attribute named `VertexPosition` with the `f32x3` (aka `vec3`) type, this function will do nothing and return `false`.\n\nOtherwise, the bounding box will be set and the return value will be `true`.\n\nThe bounding box can also be assigned manually using `Mesh:setBoundingBox`, which can be used to set the bounding box on a `gpu` mesh or for cases where the bounding box is already known.\n\nPasses will use the bounding box of a Mesh to cull it against the cameras when `Pass:setViewCull` is enabled, which avoids rendering it when it's out of view.",
  14146. key = "Mesh:computeBoundingBox",
  14147. module = "lovr.graphics",
  14148. related = {
  14149. "Mesh:getBoundingBox",
  14150. "Mesh:setBoundingBox",
  14151. "Pass:setViewCull",
  14152. "Collider:getAABB",
  14153. "Shape:getAABB",
  14154. "Model:getBoundingBox",
  14155. "ModelData:getBoundingBox"
  14156. },
  14157. variants = {
  14158. {
  14159. arguments = {},
  14160. returns = {
  14161. {
  14162. name = "updated",
  14163. type = "boolean",
  14164. description = "Whether the bounding box was updated."
  14165. }
  14166. }
  14167. }
  14168. }
  14169. },
  14170. {
  14171. name = "getBoundingBox",
  14172. summary = "Get the bounding box of the Mesh.",
  14173. description = "Returns the axis-aligned bounding box of the Mesh, or `nil` if the Mesh doesn't have a bounding box.\n\nMeshes with the `cpu` storage mode can compute their bounding box automatically using `Mesh:computeBoundingBox`. The bounding box can also be set manually using `Mesh:setBoundingBox`.\n\nPasses will use the bounding box of a Mesh to cull it against the cameras when `Pass:setViewCull` is enabled, which avoids rendering it when it's out of view.",
  14174. key = "Mesh:getBoundingBox",
  14175. module = "lovr.graphics",
  14176. related = {
  14177. "Mesh:computeBoundingBox",
  14178. "Pass:setViewCull",
  14179. "Collider:getAABB",
  14180. "Shape:getAABB",
  14181. "Model:getBoundingBox",
  14182. "ModelData:getBoundingBox"
  14183. },
  14184. variants = {
  14185. {
  14186. arguments = {},
  14187. returns = {
  14188. {
  14189. name = "minx",
  14190. type = "number",
  14191. description = "The minimum x coordinate of the bounding box."
  14192. },
  14193. {
  14194. name = "maxx",
  14195. type = "number",
  14196. description = "The maximum x coordinate of the bounding box."
  14197. },
  14198. {
  14199. name = "miny",
  14200. type = "number",
  14201. description = "The minimum y coordinate of the bounding box."
  14202. },
  14203. {
  14204. name = "maxy",
  14205. type = "number",
  14206. description = "The maximum y coordinate of the bounding box."
  14207. },
  14208. {
  14209. name = "minz",
  14210. type = "number",
  14211. description = "The minimum z coordinate of the bounding box."
  14212. },
  14213. {
  14214. name = "maxz",
  14215. type = "number",
  14216. description = "The maximum z coordinate of the bounding box."
  14217. }
  14218. }
  14219. }
  14220. }
  14221. },
  14222. {
  14223. name = "getDrawMode",
  14224. summary = "Get the draw mode of the Mesh.",
  14225. description = "Returns the `DrawMode` of the mesh, which controls how the vertices in the Mesh are connected together to create pixels. The default is `triangles`.",
  14226. key = "Mesh:getDrawMode",
  14227. module = "lovr.graphics",
  14228. related = {
  14229. "Pass:setMeshMode"
  14230. },
  14231. variants = {
  14232. {
  14233. arguments = {},
  14234. returns = {
  14235. {
  14236. name = "mode",
  14237. type = "DrawMode",
  14238. description = "The current draw mode."
  14239. }
  14240. }
  14241. }
  14242. }
  14243. },
  14244. {
  14245. name = "getIndexBuffer",
  14246. summary = "Get the Buffer backing the vertex indices of the Mesh.",
  14247. description = "Returns the `Buffer` object that holds the data for the vertex indices in the Mesh.\n\nThis can be `nil` if the Mesh doesn't have any indices.\n\nIf a Mesh uses the `cpu` storage mode, the index buffer is internal to the `Mesh` and this function will return `nil`. This ensures that the CPU data for the Mesh does not get out of sync with the GPU data in the Buffer.",
  14248. key = "Mesh:getIndexBuffer",
  14249. module = "lovr.graphics",
  14250. related = {
  14251. "Mesh:getIndices",
  14252. "Mesh:setIndices",
  14253. "Mesh:getVertexBuffer"
  14254. },
  14255. variants = {
  14256. {
  14257. arguments = {},
  14258. returns = {
  14259. {
  14260. name = "buffer",
  14261. type = "Buffer",
  14262. description = "The index buffer."
  14263. }
  14264. }
  14265. }
  14266. }
  14267. },
  14268. {
  14269. name = "getIndices",
  14270. summary = "Get the vertex indices in the Mesh.",
  14271. description = "Returns a table with the Mesh's vertex indices.",
  14272. key = "Mesh:getIndices",
  14273. module = "lovr.graphics",
  14274. notes = "This function will be very very slow if the Mesh's storage is `gpu`, because the data needs to be downloaded from the GPU.",
  14275. related = {
  14276. "Mesh:getIndexBuffer",
  14277. "Mesh:setIndexBuffer"
  14278. },
  14279. variants = {
  14280. {
  14281. arguments = {},
  14282. returns = {
  14283. {
  14284. name = "t",
  14285. type = "table",
  14286. description = "A table of numbers with the 1-based vertex indices."
  14287. }
  14288. }
  14289. }
  14290. }
  14291. },
  14292. {
  14293. name = "getMaterial",
  14294. summary = "Get the Material applied to the Mesh.",
  14295. description = "Returns the `Material` applied to the Mesh.",
  14296. key = "Mesh:getMaterial",
  14297. module = "lovr.graphics",
  14298. related = {
  14299. "Pass:setMaterial",
  14300. "Model:getMaterial",
  14301. "lovr.graphics.newMaterial"
  14302. },
  14303. variants = {
  14304. {
  14305. arguments = {},
  14306. returns = {
  14307. {
  14308. name = "material",
  14309. type = "Material",
  14310. description = "The material."
  14311. }
  14312. }
  14313. }
  14314. }
  14315. },
  14316. {
  14317. name = "getVertexBuffer",
  14318. summary = "Get the Buffer backing the vertices of the Mesh.",
  14319. description = "Returns the `Buffer` object that holds the data for the vertices in the Mesh.\n\nIf a Mesh uses the `cpu` storage mode, the vertex buffer is internal to the `Mesh` and this function will return `nil`. This ensures that the CPU data for the Mesh does not get out of sync with the GPU data in the Buffer.",
  14320. key = "Mesh:getVertexBuffer",
  14321. module = "lovr.graphics",
  14322. related = {
  14323. "Mesh:getVertices",
  14324. "Mesh:setVertices",
  14325. "Mesh:getIndexBuffer"
  14326. },
  14327. variants = {
  14328. {
  14329. arguments = {},
  14330. returns = {
  14331. {
  14332. name = "buffer",
  14333. type = "Buffer",
  14334. description = "The vertex buffer."
  14335. }
  14336. }
  14337. }
  14338. }
  14339. },
  14340. {
  14341. name = "getVertexCount",
  14342. summary = "Get the number of vertices in the Mesh.",
  14343. description = "Returns the number of vertices in the Mesh. The vertex count is set when the Mesh is created and can't change afterwards.",
  14344. key = "Mesh:getVertexCount",
  14345. module = "lovr.graphics",
  14346. related = {
  14347. "Mesh:getVertexStride",
  14348. "Mesh:getVertexFormat",
  14349. "lovr.graphics.newMesh"
  14350. },
  14351. variants = {
  14352. {
  14353. arguments = {},
  14354. returns = {
  14355. {
  14356. name = "count",
  14357. type = "number",
  14358. description = "The number of vertices in the Mesh."
  14359. }
  14360. }
  14361. }
  14362. }
  14363. },
  14364. {
  14365. name = "getVertexFormat",
  14366. summary = "Get the vertex format of the Mesh.",
  14367. description = "Returns the vertex format of the Mesh, which is a list of \"attributes\" that make up the data for each vertex (position, color, UV, etc.).",
  14368. key = "Mesh:getVertexFormat",
  14369. module = "lovr.graphics",
  14370. notes = "If no vertex format is given when the Mesh is created, it will use a default format:\n\n {\n { 'VertexPosition', 'vec3', 0 },\n { 'VertexNormal', 'vec3', 12 },\n { 'VertexUV', 'vec2', 24 }\n }\n\nThe name of the vertex attribute corresponds to an `in` input variable in a vertex shader.\n\nThere are a few built-in attributes that all shaders will understand and use by default:\n\n<table>\n <thead>\n <tr>\n <td>Name</td>\n <td>Description</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><code>VertexPosition</code></td>\n <td>The position of the vertex.</td>\n </tr>\n <tr>\n <td><code>VertexNormal</code></td>\n <td>The normal vector of the vertex.</td>\n </tr>\n <tr>\n <td><code>VertexUV</code></td>\n <td>The texture coordinate of the vertex.</td>\n </tr>\n <tr>\n <td><code>VertexColor</code></td>\n <td>The color of the vertex (linear color space).</td>\n </tr>\n <tr>\n <td><code>VertexTangent</code></td>\n <td>The tangent vector of the vertex.</td>\n </tr>\n </tbody> </table>\n\nSee the `Shaders` and `Meshes` guides for more info.",
  14371. related = {
  14372. "Mesh:getVertexCount",
  14373. "Mesh:getVertexStride",
  14374. "lovr.graphics.newMesh"
  14375. },
  14376. variants = {
  14377. {
  14378. arguments = {},
  14379. returns = {
  14380. {
  14381. name = "format",
  14382. type = "table",
  14383. description = "The vertex format.",
  14384. table = {
  14385. {
  14386. name = "[][1]",
  14387. type = "string",
  14388. description = "The name of the attribute."
  14389. },
  14390. {
  14391. name = "[][2]",
  14392. type = "DataType",
  14393. description = "The type of the attribute."
  14394. },
  14395. {
  14396. name = "[][3]",
  14397. type = "number",
  14398. description = "The byte offset of the attribute."
  14399. }
  14400. }
  14401. }
  14402. }
  14403. }
  14404. }
  14405. },
  14406. {
  14407. name = "getVertexStride",
  14408. summary = "Get the size of each vertex in the Mesh.",
  14409. description = "Returns the stride of the Mesh, which is the number of bytes used by each vertex.",
  14410. key = "Mesh:getVertexStride",
  14411. module = "lovr.graphics",
  14412. related = {
  14413. "Mesh:getVertexCount",
  14414. "Mesh:getVertexFormat",
  14415. "lovr.graphics.newMesh"
  14416. },
  14417. variants = {
  14418. {
  14419. arguments = {},
  14420. returns = {
  14421. {
  14422. name = "stride",
  14423. type = "number",
  14424. description = "The stride of the Mesh, in bytes."
  14425. }
  14426. }
  14427. }
  14428. }
  14429. },
  14430. {
  14431. name = "getVertices",
  14432. summary = "Get the vertices in the Mesh.",
  14433. description = "Returns the vertices in the Mesh.",
  14434. key = "Mesh:getVertices",
  14435. module = "lovr.graphics",
  14436. notes = "> **This function will be very very slow if the storage mode of the Mesh is `gpu`, because the\n> data will be downloaded from VRAM. A better option is to call `Buffer:newReadback` on the\n> Mesh's underlying vertex buffer (`Mesh:getVertexBuffer`), which will download in the\n> background instead of waiting for it to complete.**",
  14437. related = {
  14438. "Mesh:getVertexBuffer",
  14439. "Mesh:getVertexFormat",
  14440. "Mesh:getIndices",
  14441. "Mesh:setIndices"
  14442. },
  14443. variants = {
  14444. {
  14445. arguments = {
  14446. {
  14447. name = "index",
  14448. type = "number",
  14449. description = "The index of the first vertex to return.",
  14450. default = "1"
  14451. },
  14452. {
  14453. name = "count",
  14454. type = "number",
  14455. description = "The number of vertices to return. If nil, returns the \"rest\" of the vertices, based on the `index` argument.",
  14456. default = "nil"
  14457. }
  14458. },
  14459. returns = {
  14460. {
  14461. name = "vertices",
  14462. type = "table",
  14463. description = "A table of vertices. Each vertex is a table of numbers for each vertex attribute, given by the vertex format of the Mesh."
  14464. }
  14465. }
  14466. }
  14467. }
  14468. },
  14469. {
  14470. name = "setBoundingBox",
  14471. summary = "Set or remove the bounding box of the Mesh.",
  14472. description = "Sets or removes the axis-aligned bounding box of the Mesh.\n\nMeshes with the `cpu` storage mode can compute their bounding box automatically using `Mesh:computeBoundingBox`.\n\nPasses will use the bounding box of a Mesh to cull it against the cameras when `Pass:setViewCull` is enabled, which avoids rendering it when it's out of view.",
  14473. key = "Mesh:setBoundingBox",
  14474. module = "lovr.graphics",
  14475. related = {
  14476. "Mesh:computeBoundingBox",
  14477. "Pass:setViewCull",
  14478. "Collider:getAABB",
  14479. "Shape:getAABB",
  14480. "Model:getBoundingBox",
  14481. "ModelData:getBoundingBox"
  14482. },
  14483. variants = {
  14484. {
  14485. arguments = {
  14486. {
  14487. name = "minx",
  14488. type = "number",
  14489. description = "The minimum x coordinate of the bounding box."
  14490. },
  14491. {
  14492. name = "maxx",
  14493. type = "number",
  14494. description = "The maximum x coordinate of the bounding box."
  14495. },
  14496. {
  14497. name = "miny",
  14498. type = "number",
  14499. description = "The minimum y coordinate of the bounding box."
  14500. },
  14501. {
  14502. name = "maxy",
  14503. type = "number",
  14504. description = "The maximum y coordinate of the bounding box."
  14505. },
  14506. {
  14507. name = "minz",
  14508. type = "number",
  14509. description = "The minimum z coordinate of the bounding box."
  14510. },
  14511. {
  14512. name = "maxz",
  14513. type = "number",
  14514. description = "The maximum z coordinate of the bounding box."
  14515. }
  14516. },
  14517. returns = {}
  14518. },
  14519. {
  14520. description = "Remove the bounding box.",
  14521. arguments = {},
  14522. returns = {}
  14523. }
  14524. }
  14525. },
  14526. {
  14527. name = "setDrawMode",
  14528. summary = "Set the draw mode of the Mesh.",
  14529. description = "Changes the `DrawMode` of the mesh, which controls how the vertices in the Mesh are connected together to create pixels. The default is `triangles`.",
  14530. key = "Mesh:setDrawMode",
  14531. module = "lovr.graphics",
  14532. related = {
  14533. "Pass:setMeshMode"
  14534. },
  14535. variants = {
  14536. {
  14537. arguments = {
  14538. {
  14539. name = "mode",
  14540. type = "DrawMode",
  14541. description = "The current draw mode."
  14542. }
  14543. },
  14544. returns = {}
  14545. }
  14546. }
  14547. },
  14548. {
  14549. name = "setIndexBuffer",
  14550. summary = "Set a Buffer for the Mesh to use for vertex indices.",
  14551. description = "Sets a `Buffer` object the Mesh will use for vertex indices.\n\nThis can only be used if the Mesh uses the `gpu` storage mode.\n\nThe Buffer must have a single field with the `u16`, `u32`, `index16`, or `index32` type.",
  14552. key = "Mesh:setIndexBuffer",
  14553. module = "lovr.graphics",
  14554. examples = {
  14555. {
  14556. description = "Use an index buffer to draw a plane.",
  14557. code = "function lovr.load()\n mesh = lovr.graphics.newMesh({\n { -1, 1, 0 }, -- upper left\n { 1, 1, 0 }, -- upper right\n { -1, -1, 0 }, -- lower left\n { 1, -1, 0 }, -- lower right\n }, 'gpu')\n\n -- 2 triangles\n local indices = { 1,3,2, 2,3,4 }\n\n local indexBuffer = lovr.graphics.newBuffer('index16', indices)\n mesh:setIndexBuffer(indexBuffer)\nend\n\nfunction lovr.draw(pass)\n pass:draw(mesh, 0, 1.7, -2)\nend"
  14558. }
  14559. },
  14560. notes = "The index buffer stores a list of numbers where each number is the index of a vertex in the Mesh. When drawing the Mesh, the data from the vertex corresponding to the index is used. This can be used to reorder or reuse vertices, which uses less data than repeating a vertex multiple times in the Mesh.",
  14561. related = {
  14562. "Mesh:getIndices",
  14563. "Mesh:setIndices",
  14564. "Mesh:getVertexBuffer"
  14565. },
  14566. variants = {
  14567. {
  14568. arguments = {
  14569. {
  14570. name = "buffer",
  14571. type = "Buffer",
  14572. description = "The index buffer."
  14573. }
  14574. },
  14575. returns = {}
  14576. }
  14577. }
  14578. },
  14579. {
  14580. name = "setIndices",
  14581. summary = "Set the vertex indices of the Mesh.",
  14582. description = "Sets or clears the vertex indices of the Mesh. Vertex indices define the list of triangles in the mesh. They allow vertices to be reused multiple times without duplicating all their data, which can save a lot of memory and processing time if a vertex is used for multiple triangles.\n\nIf a Mesh doesn't have vertex indices, then the vertices are rendered in order.",
  14583. key = "Mesh:setIndices",
  14584. module = "lovr.graphics",
  14585. related = {
  14586. "Mesh:getIndexBuffer",
  14587. "Mesh:setIndexBuffer",
  14588. "Mesh:setVertices"
  14589. },
  14590. variants = {
  14591. {
  14592. description = "Set vertex indices using a table.",
  14593. arguments = {
  14594. {
  14595. name = "t",
  14596. type = "table",
  14597. description = "A list of numbers (1-based)."
  14598. }
  14599. },
  14600. returns = {}
  14601. },
  14602. {
  14603. description = "Set vertex indices using a Blob.",
  14604. arguments = {
  14605. {
  14606. name = "blob",
  14607. type = "Blob",
  14608. description = "The Blob with index data."
  14609. },
  14610. {
  14611. name = "type",
  14612. type = "DataType",
  14613. description = "The type of index data in the Blob. Must be `u16` or `u32`."
  14614. }
  14615. },
  14616. returns = {}
  14617. },
  14618. {
  14619. description = "Disable vertex indices.",
  14620. arguments = {},
  14621. returns = {}
  14622. }
  14623. }
  14624. },
  14625. {
  14626. name = "setMaterial",
  14627. summary = "Set a Material to use when drawing the Mesh.",
  14628. description = "Sets a `Material` to use when drawing the Mesh.",
  14629. key = "Mesh:setMaterial",
  14630. module = "lovr.graphics",
  14631. related = {
  14632. "Pass:setMaterial",
  14633. "Model:getMaterial",
  14634. "lovr.graphics.newMaterial"
  14635. },
  14636. variants = {
  14637. {
  14638. arguments = {
  14639. {
  14640. name = "material",
  14641. type = "Material",
  14642. description = "The material to use."
  14643. }
  14644. },
  14645. returns = {}
  14646. }
  14647. }
  14648. },
  14649. {
  14650. name = "setVertices",
  14651. summary = "Set vertices in the Mesh.",
  14652. description = "Sets the data for vertices in the Mesh.",
  14653. key = "Mesh:setVertices",
  14654. module = "lovr.graphics",
  14655. notes = "CPU meshes will write the data to CPU memory and upload any changes to the GPU before the Mesh is drawn. GPU meshes don't store this CPU copy of the data, and will immediately upload the new vertex data to VRAM. This means that multiple calls to this function might be slower on a `gpu` mesh.",
  14656. related = {
  14657. "Mesh:getVertexBuffer",
  14658. "Mesh:getVertexFormat",
  14659. "Mesh:getIndices",
  14660. "Mesh:setIndices"
  14661. },
  14662. variants = {
  14663. {
  14664. arguments = {
  14665. {
  14666. name = "vertices",
  14667. type = "table",
  14668. description = "A table of vertices, where each vertex is a table of numbers matching the vertex format of the Mesh."
  14669. },
  14670. {
  14671. name = "index",
  14672. type = "number",
  14673. description = "The index of the first vertex to return.",
  14674. default = "1"
  14675. },
  14676. {
  14677. name = "count",
  14678. type = "number",
  14679. description = "The number of vertices to return. If nil, returns the \"rest\" of the vertices, based on the `index` argument.",
  14680. default = "nil"
  14681. }
  14682. },
  14683. returns = {}
  14684. },
  14685. {
  14686. arguments = {
  14687. {
  14688. name = "blob",
  14689. type = "Blob",
  14690. description = "A Blob containing binary vertex data."
  14691. },
  14692. {
  14693. name = "index",
  14694. type = "number",
  14695. description = "The index of the first vertex to return.",
  14696. default = "1"
  14697. },
  14698. {
  14699. name = "count",
  14700. type = "number",
  14701. description = "The number of vertices to return. If nil, returns the \"rest\" of the vertices, based on the `index` argument.",
  14702. default = "nil"
  14703. }
  14704. },
  14705. returns = {}
  14706. }
  14707. }
  14708. }
  14709. }
  14710. },
  14711. {
  14712. name = "Model",
  14713. summary = "A 3D model.",
  14714. description = "Models are 3D model assets loaded from files. Currently, OBJ, glTF, and binary STL files are supported.\n\nA model can be drawn using `Pass:draw`.\n\nThe raw CPU data for a model is held in a `ModelData` object, which can be loaded on threads or reused for multiple Model instances.\n\nModels have a hierarchy of nodes which can have their transforms modified. Meshes are attached to these nodes. The same mesh can be attached to multiple nodes, allowing it to be drawn multiple times while only storing a single copy of its data.\n\nModels can have animations. Animations have keyframes which affect the transforms of nodes. Right now each model can only be drawn with a single animated pose per frame.\n\nModels can have materials, which are collections of properties and textures that define how its surface is affected by lighting. Each mesh in the model can use a single material.",
  14715. key = "Model",
  14716. module = "lovr.graphics",
  14717. constructors = {
  14718. "lovr.graphics.newModel",
  14719. "lovr.headset.newModel"
  14720. },
  14721. methods = {
  14722. {
  14723. name = "animate",
  14724. summary = "Animate the Model.",
  14725. description = "Animates a Model by setting or blending the transforms of nodes using data stored in the keyframes of an animation.\n\nThe animation from the model file is evaluated at the timestamp, resulting in a set of node properties. These properties are then applied to the nodes in the model, using an optional blend factor. If the animation doesn't have keyframes that target a given node, the node will remain unchanged.",
  14726. key = "Model:animate",
  14727. module = "lovr.graphics",
  14728. notes = "If the timestamp is larger than the duration of the animation, it will wrap back around to zero, so looping an animation doesn't require using the modulo operator.\n\nTo change the speed of the animation, multiply the timestamp by a speed factor.\n\nFor each animated property in the animation, if the timestamp used for the animation is less than the timestamp of the first keyframe, the data of the first keyframe will be used.\n\nThis function can be called multiple times to layer and blend animations. The model joints will be drawn in the final resulting pose.\n\n`Model:resetNodeTransforms` can be used to reset the model nodes to their initial transforms, which is helpful to ensure animating starts from a clean slate.",
  14729. related = {
  14730. "Model:resetNodeTransforms",
  14731. "Model:getAnimationCount",
  14732. "Model:getAnimationName",
  14733. "Model:getAnimationDuration",
  14734. "Model:getNodePosition",
  14735. "Model:setNodePosition",
  14736. "Model:getNodeOrientation",
  14737. "Model:setNodeOrientation",
  14738. "Model:getNodeScale",
  14739. "Model:setNodeScale",
  14740. "Model:getNodeTransform",
  14741. "Model:setNodeTransform"
  14742. },
  14743. variants = {
  14744. {
  14745. arguments = {
  14746. {
  14747. name = "name",
  14748. type = "string",
  14749. description = "The name of an animation in the model file."
  14750. },
  14751. {
  14752. name = "time",
  14753. type = "number",
  14754. description = "The timestamp to evaluate the keyframes at, in seconds."
  14755. },
  14756. {
  14757. name = "blend",
  14758. type = "number",
  14759. description = "How much of the animation's pose to blend into the nodes, from 0 to 1.",
  14760. default = "1.0"
  14761. }
  14762. },
  14763. returns = {}
  14764. },
  14765. {
  14766. arguments = {
  14767. {
  14768. name = "index",
  14769. type = "number",
  14770. description = "The index of an animation in the model file."
  14771. },
  14772. {
  14773. name = "time",
  14774. type = "number",
  14775. description = "The timestamp to evaluate the keyframes at, in seconds."
  14776. },
  14777. {
  14778. name = "blend",
  14779. type = "number",
  14780. description = "How much of the animation's pose to blend into the nodes, from 0 to 1.",
  14781. default = "1.0"
  14782. }
  14783. },
  14784. returns = {}
  14785. }
  14786. }
  14787. },
  14788. {
  14789. name = "clone",
  14790. summary = "Return a lightweight copy of the Model with its own animation state.",
  14791. description = "Returns a lightweight copy of a Model. Most of the data will be shared between the two copies of the model, like the materials, textures, and metadata. However, the clone has its own set of node transforms, allowing it to be animated separately from its parent. This allows a single model to be rendered in multiple different animation poses in a frame.",
  14792. key = "Model:clone",
  14793. module = "lovr.graphics",
  14794. notes = "The node transforms of the clone will be reset to their initial setup poses.",
  14795. related = {
  14796. "lovr.graphics.newModel"
  14797. },
  14798. variants = {
  14799. {
  14800. arguments = {},
  14801. returns = {
  14802. {
  14803. name = "model",
  14804. type = "Model",
  14805. description = "A genetically identical copy of the Model."
  14806. }
  14807. }
  14808. }
  14809. }
  14810. },
  14811. {
  14812. name = "getAnimationCount",
  14813. summary = "Get the number of animations in the Model.",
  14814. description = "Returns the number of animations in the Model.",
  14815. key = "Model:getAnimationCount",
  14816. module = "lovr.graphics",
  14817. related = {
  14818. "Model:getAnimationName",
  14819. "Model:getAnimationDuration",
  14820. "Model:animate"
  14821. },
  14822. variants = {
  14823. {
  14824. arguments = {},
  14825. returns = {
  14826. {
  14827. name = "count",
  14828. type = "number",
  14829. description = "The number of animations in the Model."
  14830. }
  14831. }
  14832. }
  14833. }
  14834. },
  14835. {
  14836. name = "getAnimationDuration",
  14837. summary = "Get the duration of an animation in the Model.",
  14838. description = "Returns the duration of an animation in the Model, in seconds.",
  14839. key = "Model:getAnimationDuration",
  14840. module = "lovr.graphics",
  14841. notes = "The duration of an animation is calculated as the largest timestamp of all of its keyframes.",
  14842. related = {
  14843. "Model:getAnimationCount",
  14844. "Model:getAnimationName",
  14845. "Model:animate"
  14846. },
  14847. variants = {
  14848. {
  14849. arguments = {
  14850. {
  14851. name = "index",
  14852. type = "number",
  14853. description = "The animation index."
  14854. }
  14855. },
  14856. returns = {
  14857. {
  14858. name = "duration",
  14859. type = "number",
  14860. description = "The duration of the animation, in seconds."
  14861. }
  14862. }
  14863. },
  14864. {
  14865. arguments = {
  14866. {
  14867. name = "name",
  14868. type = "string",
  14869. description = "The name of the animation."
  14870. }
  14871. },
  14872. returns = {
  14873. {
  14874. name = "duration",
  14875. type = "number",
  14876. description = "The duration of the animation, in seconds."
  14877. }
  14878. }
  14879. }
  14880. }
  14881. },
  14882. {
  14883. name = "getAnimationName",
  14884. summary = "Get the name of an animation in the Model.",
  14885. description = "Returns the name of an animation in the Model.",
  14886. key = "Model:getAnimationName",
  14887. module = "lovr.graphics",
  14888. related = {
  14889. "Model:getAnimationCount",
  14890. "Model:getAnimationDuration"
  14891. },
  14892. variants = {
  14893. {
  14894. arguments = {
  14895. {
  14896. name = "index",
  14897. type = "number",
  14898. description = "The index of an animation."
  14899. }
  14900. },
  14901. returns = {
  14902. {
  14903. name = "name",
  14904. type = "string",
  14905. description = "The name of the animation."
  14906. }
  14907. }
  14908. }
  14909. }
  14910. },
  14911. {
  14912. name = "getBlendShapeCount",
  14913. summary = "Get the number of blend shapes in the model.",
  14914. description = "Returns the number of blend shapes in the model.",
  14915. key = "Model:getBlendShapeCount",
  14916. module = "lovr.graphics",
  14917. related = {
  14918. "Model:getBlendShapeName",
  14919. "ModelData:getBlendShapeCount"
  14920. },
  14921. variants = {
  14922. {
  14923. arguments = {},
  14924. returns = {
  14925. {
  14926. name = "count",
  14927. type = "number",
  14928. description = "The number of blend shapes in the model."
  14929. }
  14930. }
  14931. }
  14932. }
  14933. },
  14934. {
  14935. name = "getBlendShapeName",
  14936. summary = "Get the name of a blend shape in the model.",
  14937. description = "Returns the name of a blend shape in the model.",
  14938. key = "Model:getBlendShapeName",
  14939. module = "lovr.graphics",
  14940. notes = "This function will throw an error if the blend shape index is invalid.",
  14941. related = {
  14942. "Model:getBlendShapeCount",
  14943. "ModelData:getBlendShapeName"
  14944. },
  14945. variants = {
  14946. {
  14947. arguments = {
  14948. {
  14949. name = "index",
  14950. type = "number",
  14951. description = "The index of a blend shape."
  14952. }
  14953. },
  14954. returns = {
  14955. {
  14956. name = "name",
  14957. type = "string",
  14958. description = "The name of the blend shape."
  14959. }
  14960. }
  14961. }
  14962. }
  14963. },
  14964. {
  14965. name = "getBlendShapeWeight",
  14966. summary = "Get the weight of a blend shape.",
  14967. description = "Returns the weight of a blend shape. A blend shape contains offset values for the vertices of one of the meshes in a Model. Whenever the Model is drawn, the offsets are multiplied by the weight of the blend shape, allowing for smooth blending between different meshes. A weight of zero won't apply any displacement and will skip processing of the blend shape.",
  14968. key = "Model:getBlendShapeWeight",
  14969. module = "lovr.graphics",
  14970. notes = "The initial weights are declared in the model file.\n\nWeights can be any number, but usually they're kept between 0 and 1.\n\nThis function will throw an error if the blend shape name or index doesn't exist.",
  14971. related = {
  14972. "Model:getBlendShapeCount",
  14973. "Model:getBlendShapeName"
  14974. },
  14975. variants = {
  14976. {
  14977. arguments = {
  14978. {
  14979. name = "index",
  14980. type = "number",
  14981. description = "The index of a blend shape."
  14982. }
  14983. },
  14984. returns = {
  14985. {
  14986. name = "weight",
  14987. type = "number",
  14988. description = "The weight of the blend shape."
  14989. }
  14990. }
  14991. },
  14992. {
  14993. arguments = {
  14994. {
  14995. name = "name",
  14996. type = "string",
  14997. description = "The name of a blend shape."
  14998. }
  14999. },
  15000. returns = {
  15001. {
  15002. name = "weight",
  15003. type = "number",
  15004. description = "The weight of the blend shape."
  15005. }
  15006. }
  15007. }
  15008. }
  15009. },
  15010. {
  15011. name = "getBoundingBox",
  15012. summary = "Get the bounding box of the Model.",
  15013. description = "Returns the 6 values of the Model's axis-aligned bounding box.",
  15014. key = "Model:getBoundingBox",
  15015. module = "lovr.graphics",
  15016. related = {
  15017. "Model:getWidth",
  15018. "Model:getHeight",
  15019. "Model:getDepth",
  15020. "Model:getDimensions",
  15021. "Model:getCenter",
  15022. "Model:getBoundingSphere",
  15023. "ModelData:getBoundingBox",
  15024. "Collider:getAABB"
  15025. },
  15026. variants = {
  15027. {
  15028. arguments = {},
  15029. returns = {
  15030. {
  15031. name = "minx",
  15032. type = "number",
  15033. description = "The minimum x coordinate of the vertices in the Model."
  15034. },
  15035. {
  15036. name = "maxx",
  15037. type = "number",
  15038. description = "The maximum x coordinate of the vertices in the Model."
  15039. },
  15040. {
  15041. name = "miny",
  15042. type = "number",
  15043. description = "The minimum y coordinate of the vertices in the Model."
  15044. },
  15045. {
  15046. name = "maxy",
  15047. type = "number",
  15048. description = "The maximum y coordinate of the vertices in the Model."
  15049. },
  15050. {
  15051. name = "minz",
  15052. type = "number",
  15053. description = "The minimum z coordinate of the vertices in the Model."
  15054. },
  15055. {
  15056. name = "maxz",
  15057. type = "number",
  15058. description = "The maximum z coordinate of the vertices in the Model."
  15059. }
  15060. }
  15061. }
  15062. }
  15063. },
  15064. {
  15065. name = "getBoundingSphere",
  15066. summary = "Get the bounding sphere of the Model.",
  15067. description = "Returns a sphere approximately enclosing the vertices in the Model.",
  15068. key = "Model:getBoundingSphere",
  15069. module = "lovr.graphics",
  15070. related = {
  15071. "Model:getWidth",
  15072. "Model:getHeight",
  15073. "Model:getDepth",
  15074. "Model:getDimensions",
  15075. "Model:getCenter",
  15076. "Model:getBoundingBox",
  15077. "ModelData:getBoundingSphere"
  15078. },
  15079. variants = {
  15080. {
  15081. arguments = {},
  15082. returns = {
  15083. {
  15084. name = "x",
  15085. type = "number",
  15086. description = "The x coordinate of the position of the sphere."
  15087. },
  15088. {
  15089. name = "y",
  15090. type = "number",
  15091. description = "The y coordinate of the position of the sphere."
  15092. },
  15093. {
  15094. name = "z",
  15095. type = "number",
  15096. description = "The z coordinate of the position of the sphere."
  15097. },
  15098. {
  15099. name = "radius",
  15100. type = "number",
  15101. description = "The radius of the bounding sphere."
  15102. }
  15103. }
  15104. }
  15105. }
  15106. },
  15107. {
  15108. name = "getCenter",
  15109. summary = "Get the center of the Model's bounding box.",
  15110. description = "Returns the center of the Model's axis-aligned bounding box, relative to the Model's origin.",
  15111. key = "Model:getCenter",
  15112. module = "lovr.graphics",
  15113. related = {
  15114. "Model:getWidth",
  15115. "Model:getHeight",
  15116. "Model:getDepth",
  15117. "Model:getDimensions",
  15118. "Model:getBoundingBox",
  15119. "ModelData:getCenter"
  15120. },
  15121. variants = {
  15122. {
  15123. arguments = {},
  15124. returns = {
  15125. {
  15126. name = "x",
  15127. type = "number",
  15128. description = "The x offset of the center of the bounding box."
  15129. },
  15130. {
  15131. name = "y",
  15132. type = "number",
  15133. description = "The y offset of the center of the bounding box."
  15134. },
  15135. {
  15136. name = "z",
  15137. type = "number",
  15138. description = "The z offset of the center of the bounding box."
  15139. }
  15140. }
  15141. }
  15142. }
  15143. },
  15144. {
  15145. name = "getData",
  15146. summary = "Get the ModelData backing the Model.",
  15147. description = "Returns the ModelData this Model was created from.",
  15148. key = "Model:getData",
  15149. module = "lovr.graphics",
  15150. related = {
  15151. "lovr.data.newModelData"
  15152. },
  15153. variants = {
  15154. {
  15155. arguments = {},
  15156. returns = {
  15157. {
  15158. name = "data",
  15159. type = "ModelData",
  15160. description = "The ModelData."
  15161. }
  15162. }
  15163. }
  15164. }
  15165. },
  15166. {
  15167. name = "getDepth",
  15168. summary = "Get the depth of the Model.",
  15169. description = "Returns the depth of the Model, computed from its axis-aligned bounding box.",
  15170. key = "Model:getDepth",
  15171. module = "lovr.graphics",
  15172. related = {
  15173. "Model:getWidth",
  15174. "Model:getHeight",
  15175. "Model:getDimensions",
  15176. "Model:getCenter",
  15177. "Model:getBoundingBox",
  15178. "ModelData:getDepth"
  15179. },
  15180. variants = {
  15181. {
  15182. arguments = {},
  15183. returns = {
  15184. {
  15185. name = "depth",
  15186. type = "number",
  15187. description = "The depth of the Model."
  15188. }
  15189. }
  15190. }
  15191. }
  15192. },
  15193. {
  15194. name = "getDimensions",
  15195. summary = "Get the dimensions of the Model.",
  15196. description = "Returns the width, height, and depth of the Model, computed from its axis-aligned bounding box.",
  15197. key = "Model:getDimensions",
  15198. module = "lovr.graphics",
  15199. related = {
  15200. "Model:getWidth",
  15201. "Model:getHeight",
  15202. "Model:getDepth",
  15203. "Model:getCenter",
  15204. "Model:getBoundingBox",
  15205. "ModelData:getDimensions"
  15206. },
  15207. variants = {
  15208. {
  15209. arguments = {},
  15210. returns = {
  15211. {
  15212. name = "width",
  15213. type = "number",
  15214. description = "The width of the Model."
  15215. },
  15216. {
  15217. name = "height",
  15218. type = "number",
  15219. description = "The height of the Model."
  15220. },
  15221. {
  15222. name = "depth",
  15223. type = "number",
  15224. description = "The depth of the Model."
  15225. }
  15226. }
  15227. }
  15228. }
  15229. },
  15230. {
  15231. name = "getHeight",
  15232. summary = "Get the height of the Model.",
  15233. description = "Returns the height of the Model, computed from its axis-aligned bounding box.",
  15234. key = "Model:getHeight",
  15235. module = "lovr.graphics",
  15236. related = {
  15237. "Model:getWidth",
  15238. "Model:getDepth",
  15239. "Model:getDimensions",
  15240. "Model:getCenter",
  15241. "Model:getBoundingBox",
  15242. "ModelData:getHeight"
  15243. },
  15244. variants = {
  15245. {
  15246. arguments = {},
  15247. returns = {
  15248. {
  15249. name = "height",
  15250. type = "number",
  15251. description = "The height of the Model."
  15252. }
  15253. }
  15254. }
  15255. }
  15256. },
  15257. {
  15258. name = "getIndexBuffer",
  15259. summary = "Get a Buffer containing the triangle indices in the Model.",
  15260. description = "Returns the index buffer used by the Model. The index buffer describes the order used to draw the vertices in each mesh.",
  15261. key = "Model:getIndexBuffer",
  15262. module = "lovr.graphics",
  15263. related = {
  15264. "Model:getVertexBuffer"
  15265. },
  15266. variants = {
  15267. {
  15268. arguments = {},
  15269. returns = {
  15270. {
  15271. name = "buffer",
  15272. type = "Buffer",
  15273. description = "The index buffer."
  15274. }
  15275. }
  15276. }
  15277. }
  15278. },
  15279. {
  15280. name = "getMaterial",
  15281. summary = "Get a Material from the Model.",
  15282. description = "Returns a `Material` loaded from the Model.",
  15283. key = "Model:getMaterial",
  15284. module = "lovr.graphics",
  15285. related = {
  15286. "Model:getMaterialCount",
  15287. "Model:getMaterialName"
  15288. },
  15289. variants = {
  15290. {
  15291. arguments = {
  15292. {
  15293. name = "name",
  15294. type = "string",
  15295. description = "The name of the Material to return."
  15296. }
  15297. },
  15298. returns = {
  15299. {
  15300. name = "material",
  15301. type = "Material",
  15302. description = "The material."
  15303. }
  15304. }
  15305. },
  15306. {
  15307. arguments = {
  15308. {
  15309. name = "index",
  15310. type = "number",
  15311. description = "The index of the Material to return."
  15312. }
  15313. },
  15314. returns = {
  15315. {
  15316. name = "material",
  15317. type = "Material",
  15318. description = "The material."
  15319. }
  15320. }
  15321. }
  15322. }
  15323. },
  15324. {
  15325. name = "getMaterialCount",
  15326. summary = "Get the number of materials in the Model.",
  15327. description = "Returns the number of materials in the Model.",
  15328. key = "Model:getMaterialCount",
  15329. module = "lovr.graphics",
  15330. related = {
  15331. "Model:getMaterialName",
  15332. "Model:getMaterial"
  15333. },
  15334. variants = {
  15335. {
  15336. arguments = {},
  15337. returns = {
  15338. {
  15339. name = "count",
  15340. type = "number",
  15341. description = "The number of materials in the Model."
  15342. }
  15343. }
  15344. }
  15345. }
  15346. },
  15347. {
  15348. name = "getMaterialName",
  15349. summary = "Get the name of a material in the Model.",
  15350. description = "Returns the name of a material in the Model.",
  15351. key = "Model:getMaterialName",
  15352. module = "lovr.graphics",
  15353. related = {
  15354. "Model:getMaterialCount",
  15355. "Model:getMaterial"
  15356. },
  15357. variants = {
  15358. {
  15359. arguments = {
  15360. {
  15361. name = "index",
  15362. type = "number",
  15363. description = "The index of a material."
  15364. }
  15365. },
  15366. returns = {
  15367. {
  15368. name = "name",
  15369. type = "string",
  15370. description = "The name of the material."
  15371. }
  15372. }
  15373. }
  15374. }
  15375. },
  15376. {
  15377. name = "getMetadata",
  15378. summary = "Get extra information from the model file.",
  15379. description = "Returns extra information stored in the model file. Currently this is only implemented for glTF models and returns the JSON string from the glTF or glb file. The metadata can be used to get application-specific data or add support for glTF extensions not supported by LÖVR.",
  15380. key = "Model:getMetadata",
  15381. module = "lovr.graphics",
  15382. variants = {
  15383. {
  15384. arguments = {},
  15385. returns = {
  15386. {
  15387. name = "metadata",
  15388. type = "string",
  15389. description = "The metadata from the model file."
  15390. }
  15391. }
  15392. }
  15393. }
  15394. },
  15395. {
  15396. name = "getNodeChildren",
  15397. summary = "Get the children of a node.",
  15398. description = "Given a parent node, this function returns a table with the indices of its children.",
  15399. key = "Model:getNodeChildren",
  15400. module = "lovr.graphics",
  15401. notes = "If the node does not have any children, this function returns an empty table.",
  15402. related = {
  15403. "Model:getNodeParent",
  15404. "Model:getRootNode"
  15405. },
  15406. variants = {
  15407. {
  15408. arguments = {
  15409. {
  15410. name = "index",
  15411. type = "number",
  15412. description = "The index of the parent node."
  15413. }
  15414. },
  15415. returns = {
  15416. {
  15417. name = "children",
  15418. type = "table",
  15419. description = "A table containing a node index for each child of the node."
  15420. }
  15421. }
  15422. },
  15423. {
  15424. arguments = {
  15425. {
  15426. name = "name",
  15427. type = "string",
  15428. description = "The name of the parent node."
  15429. }
  15430. },
  15431. returns = {
  15432. {
  15433. name = "children",
  15434. type = "table",
  15435. description = "A table containing a node index for each child of the node."
  15436. }
  15437. }
  15438. }
  15439. }
  15440. },
  15441. {
  15442. name = "getNodeCount",
  15443. summary = "Get the number of nodes in the model.",
  15444. description = "Returns the number of nodes in the model.",
  15445. key = "Model:getNodeCount",
  15446. module = "lovr.graphics",
  15447. variants = {
  15448. {
  15449. arguments = {},
  15450. returns = {
  15451. {
  15452. name = "count",
  15453. type = "number",
  15454. description = "The number of nodes in the model."
  15455. }
  15456. }
  15457. }
  15458. }
  15459. },
  15460. {
  15461. name = "getNodeName",
  15462. summary = "Get the name of a node in the Model.",
  15463. description = "Returns the name of a node.",
  15464. key = "Model:getNodeName",
  15465. module = "lovr.graphics",
  15466. related = {
  15467. "Model:getNodeCount",
  15468. "Model:getAnimationName",
  15469. "Model:getMaterialName"
  15470. },
  15471. variants = {
  15472. {
  15473. arguments = {
  15474. {
  15475. name = "index",
  15476. type = "number",
  15477. description = "The index of the node."
  15478. }
  15479. },
  15480. returns = {
  15481. {
  15482. name = "name",
  15483. type = "string",
  15484. description = "The name of the node."
  15485. }
  15486. }
  15487. }
  15488. }
  15489. },
  15490. {
  15491. name = "getNodeOrientation",
  15492. summary = "Get the orientation of a node.",
  15493. description = "Returns the orientation of a node.",
  15494. key = "Model:getNodeOrientation",
  15495. module = "lovr.graphics",
  15496. related = {
  15497. "Model:getNodePosition",
  15498. "Model:setNodePosition",
  15499. "Model:getNodeScale",
  15500. "Model:setNodeScale",
  15501. "Model:getNodePose",
  15502. "Model:setNodePose",
  15503. "Model:getNodeTransform",
  15504. "Model:setNodeTransform",
  15505. "Model:animate"
  15506. },
  15507. variants = {
  15508. {
  15509. arguments = {
  15510. {
  15511. name = "index",
  15512. type = "number",
  15513. description = "The index of the node."
  15514. },
  15515. {
  15516. name = "origin",
  15517. type = "OriginType",
  15518. description = "Whether the orientation should be returned relative to the root node or the node's parent.",
  15519. default = "'root'"
  15520. }
  15521. },
  15522. returns = {
  15523. {
  15524. name = "angle",
  15525. type = "number",
  15526. description = "The number of radians the node is rotated around its axis of rotation."
  15527. },
  15528. {
  15529. name = "ax",
  15530. type = "number",
  15531. description = "The x component of the axis of rotation."
  15532. },
  15533. {
  15534. name = "ay",
  15535. type = "number",
  15536. description = "The y component of the axis of rotation."
  15537. },
  15538. {
  15539. name = "az",
  15540. type = "number",
  15541. description = "The z component of the axis of rotation."
  15542. }
  15543. }
  15544. },
  15545. {
  15546. arguments = {
  15547. {
  15548. name = "name",
  15549. type = "string",
  15550. description = "The name of the node."
  15551. },
  15552. {
  15553. name = "origin",
  15554. type = "OriginType",
  15555. description = "Whether the orientation should be returned relative to the root node or the node's parent.",
  15556. default = "'root'"
  15557. }
  15558. },
  15559. returns = {
  15560. {
  15561. name = "angle",
  15562. type = "number",
  15563. description = "The number of radians the node is rotated around its axis of rotation."
  15564. },
  15565. {
  15566. name = "ax",
  15567. type = "number",
  15568. description = "The x component of the axis of rotation."
  15569. },
  15570. {
  15571. name = "ay",
  15572. type = "number",
  15573. description = "The y component of the axis of rotation."
  15574. },
  15575. {
  15576. name = "az",
  15577. type = "number",
  15578. description = "The z component of the axis of rotation."
  15579. }
  15580. }
  15581. }
  15582. }
  15583. },
  15584. {
  15585. name = "getNodeParent",
  15586. summary = "Get the parent of a node.",
  15587. description = "Given a child node, this function returns the index of its parent.",
  15588. key = "Model:getNodeParent",
  15589. module = "lovr.graphics",
  15590. related = {
  15591. "Model:getNodeChildren",
  15592. "Model:getRootNode"
  15593. },
  15594. variants = {
  15595. {
  15596. arguments = {
  15597. {
  15598. name = "index",
  15599. type = "number",
  15600. description = "The index of the child node."
  15601. }
  15602. },
  15603. returns = {
  15604. {
  15605. name = "parent",
  15606. type = "number",
  15607. description = "The index of the parent."
  15608. }
  15609. }
  15610. },
  15611. {
  15612. arguments = {
  15613. {
  15614. name = "name",
  15615. type = "string",
  15616. description = "The name of the child node."
  15617. }
  15618. },
  15619. returns = {
  15620. {
  15621. name = "parent",
  15622. type = "number",
  15623. description = "The index of the parent."
  15624. }
  15625. }
  15626. }
  15627. }
  15628. },
  15629. {
  15630. name = "getNodePose",
  15631. summary = "Get the pose of a node.",
  15632. description = "Returns the pose (position and orientation) of a node.",
  15633. key = "Model:getNodePose",
  15634. module = "lovr.graphics",
  15635. related = {
  15636. "Model:getNodePosition",
  15637. "Model:setNodePosition",
  15638. "Model:getNodeOrientation",
  15639. "Model:setNodeOrientation",
  15640. "Model:getNodeScale",
  15641. "Model:setNodeScale",
  15642. "Model:getNodeTransform",
  15643. "Model:setNodeTransform",
  15644. "Model:animate"
  15645. },
  15646. variants = {
  15647. {
  15648. arguments = {
  15649. {
  15650. name = "index",
  15651. type = "number",
  15652. description = "The index of a node."
  15653. },
  15654. {
  15655. name = "origin",
  15656. type = "OriginType",
  15657. description = "Whether the pose should be returned relative to the root node or the node's parent.",
  15658. default = "'root'"
  15659. }
  15660. },
  15661. returns = {
  15662. {
  15663. name = "x",
  15664. type = "number",
  15665. description = "The x position of the node."
  15666. },
  15667. {
  15668. name = "y",
  15669. type = "number",
  15670. description = "The y position of the node."
  15671. },
  15672. {
  15673. name = "z",
  15674. type = "number",
  15675. description = "The z position of the node."
  15676. },
  15677. {
  15678. name = "angle",
  15679. type = "number",
  15680. description = "The number of radians the node is rotated around its axis of rotation."
  15681. },
  15682. {
  15683. name = "ax",
  15684. type = "number",
  15685. description = "The x component of the axis of rotation."
  15686. },
  15687. {
  15688. name = "ay",
  15689. type = "number",
  15690. description = "The y component of the axis of rotation."
  15691. },
  15692. {
  15693. name = "az",
  15694. type = "number",
  15695. description = "The z component of the axis of rotation."
  15696. }
  15697. }
  15698. },
  15699. {
  15700. arguments = {
  15701. {
  15702. name = "name",
  15703. type = "string",
  15704. description = "The name of a node."
  15705. },
  15706. {
  15707. name = "origin",
  15708. type = "OriginType",
  15709. description = "Whether the pose should be returned relative to the root node or the node's parent.",
  15710. default = "'root'"
  15711. }
  15712. },
  15713. returns = {
  15714. {
  15715. name = "x",
  15716. type = "number",
  15717. description = "The x position of the node."
  15718. },
  15719. {
  15720. name = "y",
  15721. type = "number",
  15722. description = "The y position of the node."
  15723. },
  15724. {
  15725. name = "z",
  15726. type = "number",
  15727. description = "The z position of the node."
  15728. },
  15729. {
  15730. name = "angle",
  15731. type = "number",
  15732. description = "The number of radians the node is rotated around its axis of rotation."
  15733. },
  15734. {
  15735. name = "ax",
  15736. type = "number",
  15737. description = "The x component of the axis of rotation."
  15738. },
  15739. {
  15740. name = "ay",
  15741. type = "number",
  15742. description = "The y component of the axis of rotation."
  15743. },
  15744. {
  15745. name = "az",
  15746. type = "number",
  15747. description = "The z component of the axis of rotation."
  15748. }
  15749. }
  15750. }
  15751. }
  15752. },
  15753. {
  15754. name = "getNodePosition",
  15755. summary = "Get the position of a node.",
  15756. description = "Returns the position of a node.",
  15757. key = "Model:getNodePosition",
  15758. module = "lovr.graphics",
  15759. related = {
  15760. "Model:getNodeOrientation",
  15761. "Model:setNodeOrientation",
  15762. "Model:getNodeScale",
  15763. "Model:setNodeScale",
  15764. "Model:getNodePose",
  15765. "Model:setNodePose",
  15766. "Model:getNodeTransform",
  15767. "Model:setNodeTransform",
  15768. "Model:animate"
  15769. },
  15770. variants = {
  15771. {
  15772. arguments = {
  15773. {
  15774. name = "index",
  15775. type = "number",
  15776. description = "The index of the node."
  15777. },
  15778. {
  15779. name = "space",
  15780. type = "OriginType",
  15781. description = "Whether the position should be returned relative to the root node or the node's parent.",
  15782. default = "'root'"
  15783. }
  15784. },
  15785. returns = {
  15786. {
  15787. name = "x",
  15788. type = "number",
  15789. description = "The x coordinate."
  15790. },
  15791. {
  15792. name = "y",
  15793. type = "number",
  15794. description = "The y coordinate."
  15795. },
  15796. {
  15797. name = "z",
  15798. type = "number",
  15799. description = "The z coordinate."
  15800. }
  15801. }
  15802. },
  15803. {
  15804. arguments = {
  15805. {
  15806. name = "name",
  15807. type = "string",
  15808. description = "The name of the node."
  15809. },
  15810. {
  15811. name = "space",
  15812. type = "OriginType",
  15813. description = "Whether the position should be returned relative to the root node or the node's parent.",
  15814. default = "'root'"
  15815. }
  15816. },
  15817. returns = {
  15818. {
  15819. name = "x",
  15820. type = "number",
  15821. description = "The x coordinate."
  15822. },
  15823. {
  15824. name = "y",
  15825. type = "number",
  15826. description = "The y coordinate."
  15827. },
  15828. {
  15829. name = "z",
  15830. type = "number",
  15831. description = "The z coordinate."
  15832. }
  15833. }
  15834. }
  15835. }
  15836. },
  15837. {
  15838. name = "getNodeScale",
  15839. summary = "Get the scale of a node.",
  15840. description = "Returns the scale of a node.",
  15841. key = "Model:getNodeScale",
  15842. module = "lovr.graphics",
  15843. related = {
  15844. "Model:getNodePosition",
  15845. "Model:setNodePosition",
  15846. "Model:getNodeOrientation",
  15847. "Model:setNodeOrientation",
  15848. "Model:getNodePose",
  15849. "Model:setNodePose",
  15850. "Model:getNodeTransform",
  15851. "Model:setNodeTransform",
  15852. "Model:animate"
  15853. },
  15854. variants = {
  15855. {
  15856. arguments = {
  15857. {
  15858. name = "index",
  15859. type = "number",
  15860. description = "The index of the node."
  15861. },
  15862. {
  15863. name = "origin",
  15864. type = "OriginType",
  15865. description = "Whether the scale should be returned relative to the root node or the node's parent.",
  15866. default = "'root'"
  15867. }
  15868. },
  15869. returns = {
  15870. {
  15871. name = "x",
  15872. type = "number",
  15873. description = "The x scale."
  15874. },
  15875. {
  15876. name = "y",
  15877. type = "number",
  15878. description = "The y scale."
  15879. },
  15880. {
  15881. name = "z",
  15882. type = "number",
  15883. description = "The z scale."
  15884. }
  15885. }
  15886. },
  15887. {
  15888. arguments = {
  15889. {
  15890. name = "name",
  15891. type = "string",
  15892. description = "The name of the node."
  15893. },
  15894. {
  15895. name = "origin",
  15896. type = "OriginType",
  15897. description = "Whether the scale should be returned relative to the root node or the node's parent.",
  15898. default = "'root'"
  15899. }
  15900. },
  15901. returns = {
  15902. {
  15903. name = "x",
  15904. type = "number",
  15905. description = "The x scale."
  15906. },
  15907. {
  15908. name = "y",
  15909. type = "number",
  15910. description = "The y scale."
  15911. },
  15912. {
  15913. name = "z",
  15914. type = "number",
  15915. description = "The z scale."
  15916. }
  15917. }
  15918. }
  15919. }
  15920. },
  15921. {
  15922. name = "getNodeTransform",
  15923. summary = "Get the transform of a node.",
  15924. description = "Returns the transform (position, scale, and rotation) of a node.",
  15925. key = "Model:getNodeTransform",
  15926. module = "lovr.graphics",
  15927. related = {
  15928. "Model:getNodePosition",
  15929. "Model:setNodePosition",
  15930. "Model:getNodeOrientation",
  15931. "Model:setNodeOrientation",
  15932. "Model:getNodeScale",
  15933. "Model:setNodeScale",
  15934. "Model:getNodePose",
  15935. "Model:setNodePose",
  15936. "Model:animate"
  15937. },
  15938. variants = {
  15939. {
  15940. arguments = {
  15941. {
  15942. name = "index",
  15943. type = "number",
  15944. description = "The index of a node."
  15945. },
  15946. {
  15947. name = "origin",
  15948. type = "OriginType",
  15949. description = "Whether the transform should be returned relative to the root node or the node's parent.",
  15950. default = "'root'"
  15951. }
  15952. },
  15953. returns = {
  15954. {
  15955. name = "x",
  15956. type = "number",
  15957. description = "The x position of the node."
  15958. },
  15959. {
  15960. name = "y",
  15961. type = "number",
  15962. description = "The y position of the node."
  15963. },
  15964. {
  15965. name = "z",
  15966. type = "number",
  15967. description = "The z position of the node."
  15968. },
  15969. {
  15970. name = "sx",
  15971. type = "number",
  15972. description = "The x scale of the node."
  15973. },
  15974. {
  15975. name = "sy",
  15976. type = "number",
  15977. description = "The y scale of the node."
  15978. },
  15979. {
  15980. name = "sz",
  15981. type = "number",
  15982. description = "The z scale of the node."
  15983. },
  15984. {
  15985. name = "angle",
  15986. type = "number",
  15987. description = "The number of radians the node is rotated around its axis of rotation."
  15988. },
  15989. {
  15990. name = "ax",
  15991. type = "number",
  15992. description = "The x component of the axis of rotation."
  15993. },
  15994. {
  15995. name = "ay",
  15996. type = "number",
  15997. description = "The y component of the axis of rotation."
  15998. },
  15999. {
  16000. name = "az",
  16001. type = "number",
  16002. description = "The z component of the axis of rotation."
  16003. }
  16004. }
  16005. },
  16006. {
  16007. arguments = {
  16008. {
  16009. name = "name",
  16010. type = "string",
  16011. description = "The name of a node."
  16012. },
  16013. {
  16014. name = "origin",
  16015. type = "OriginType",
  16016. description = "Whether the transform should be returned relative to the root node or the node's parent.",
  16017. default = "'root'"
  16018. }
  16019. },
  16020. returns = {
  16021. {
  16022. name = "x",
  16023. type = "number",
  16024. description = "The x position of the node."
  16025. },
  16026. {
  16027. name = "y",
  16028. type = "number",
  16029. description = "The y position of the node."
  16030. },
  16031. {
  16032. name = "z",
  16033. type = "number",
  16034. description = "The z position of the node."
  16035. },
  16036. {
  16037. name = "sx",
  16038. type = "number",
  16039. description = "The x scale of the node."
  16040. },
  16041. {
  16042. name = "sy",
  16043. type = "number",
  16044. description = "The y scale of the node."
  16045. },
  16046. {
  16047. name = "sz",
  16048. type = "number",
  16049. description = "The z scale of the node."
  16050. },
  16051. {
  16052. name = "angle",
  16053. type = "number",
  16054. description = "The number of radians the node is rotated around its axis of rotation."
  16055. },
  16056. {
  16057. name = "ax",
  16058. type = "number",
  16059. description = "The x component of the axis of rotation."
  16060. },
  16061. {
  16062. name = "ay",
  16063. type = "number",
  16064. description = "The y component of the axis of rotation."
  16065. },
  16066. {
  16067. name = "az",
  16068. type = "number",
  16069. description = "The z component of the axis of rotation."
  16070. }
  16071. }
  16072. }
  16073. }
  16074. },
  16075. {
  16076. name = "getRootNode",
  16077. summary = "Get the index of the root node.",
  16078. description = "Returns the index of the model's root node.",
  16079. key = "Model:getRootNode",
  16080. module = "lovr.graphics",
  16081. related = {
  16082. "Model:getNodeCount",
  16083. "Model:getNodeParent"
  16084. },
  16085. variants = {
  16086. {
  16087. arguments = {},
  16088. returns = {
  16089. {
  16090. name = "root",
  16091. type = "number",
  16092. description = "The index of the root node."
  16093. }
  16094. }
  16095. }
  16096. }
  16097. },
  16098. {
  16099. name = "getTexture",
  16100. summary = "Get one of the textures in the Model.",
  16101. description = "Returns one of the textures in the Model.",
  16102. key = "Model:getTexture",
  16103. module = "lovr.graphics",
  16104. related = {
  16105. "Model:getTextureCount",
  16106. "Model:getMaterial"
  16107. },
  16108. variants = {
  16109. {
  16110. arguments = {
  16111. {
  16112. name = "index",
  16113. type = "number",
  16114. description = "The index of the texture to get."
  16115. }
  16116. },
  16117. returns = {
  16118. {
  16119. name = "texture",
  16120. type = "Texture",
  16121. description = "The texture."
  16122. }
  16123. }
  16124. }
  16125. }
  16126. },
  16127. {
  16128. name = "getTextureCount",
  16129. summary = "Get the number of textures in the Model.",
  16130. description = "Returns the number of textures in the Model.",
  16131. key = "Model:getTextureCount",
  16132. module = "lovr.graphics",
  16133. related = {
  16134. "Model:getTexture"
  16135. },
  16136. variants = {
  16137. {
  16138. arguments = {},
  16139. returns = {
  16140. {
  16141. name = "count",
  16142. type = "number",
  16143. description = "The number of textures in the Model."
  16144. }
  16145. }
  16146. }
  16147. }
  16148. },
  16149. {
  16150. name = "getTriangleCount",
  16151. summary = "Get the total number of triangles in the Model.",
  16152. description = "Returns the total number of triangles in the Model.",
  16153. key = "Model:getTriangleCount",
  16154. module = "lovr.graphics",
  16155. notes = "This isn't always related to the length of the vertex buffer, since a mesh in the Model could be drawn by multiple nodes.",
  16156. related = {
  16157. "Model:getTriangles",
  16158. "Model:getVertexCount",
  16159. "ModelData:getTriangleCount"
  16160. },
  16161. variants = {
  16162. {
  16163. arguments = {},
  16164. returns = {
  16165. {
  16166. name = "count",
  16167. type = "number",
  16168. description = "The total number of triangles in the Model."
  16169. }
  16170. }
  16171. }
  16172. }
  16173. },
  16174. {
  16175. name = "getTriangles",
  16176. summary = "Get all the triangles in the Model.",
  16177. description = "Returns 2 tables containing mesh data for the Model.\n\nThe first table is a list of vertex positions and contains 3 numbers for the x, y, and z coordinate of each vertex. The second table is a list of triangles and contains 1-based indices into the first table representing the first, second, and third vertices that make up each triangle.\n\nThe vertex positions will be affected by node transforms.",
  16178. key = "Model:getTriangles",
  16179. module = "lovr.graphics",
  16180. notes = "After this function is called on a Model once, the result is cached (in its ModelData).",
  16181. related = {
  16182. "Model:getTriangleCount",
  16183. "Model:getVertexCount",
  16184. "ModelData:getTriangles"
  16185. },
  16186. variants = {
  16187. {
  16188. arguments = {},
  16189. returns = {
  16190. {
  16191. name = "vertices",
  16192. type = "table",
  16193. description = "The triangle vertex positions, returned as a flat (non-nested) table of numbers. The position of each vertex is given as an x, y, and z coordinate."
  16194. },
  16195. {
  16196. name = "indices",
  16197. type = "table",
  16198. description = "The vertex indices. Every 3 indices describes a triangle."
  16199. }
  16200. }
  16201. }
  16202. }
  16203. },
  16204. {
  16205. name = "getVertexBuffer",
  16206. summary = "Get a Buffer containing the vertices in the Model.",
  16207. description = "Returns a `Buffer` that holds the vertices of all of the meshes in the Model.",
  16208. key = "Model:getVertexBuffer",
  16209. module = "lovr.graphics",
  16210. related = {
  16211. "Model:getIndexBuffer"
  16212. },
  16213. variants = {
  16214. {
  16215. arguments = {},
  16216. returns = {
  16217. {
  16218. name = "buffer",
  16219. type = "Buffer",
  16220. description = "The vertex buffer."
  16221. }
  16222. }
  16223. }
  16224. }
  16225. },
  16226. {
  16227. name = "getVertexCount",
  16228. summary = "Get the total vertex count of the Model.",
  16229. description = "Returns the total vertex count of the Model.",
  16230. key = "Model:getVertexCount",
  16231. module = "lovr.graphics",
  16232. notes = "This isn't always the same as the length of the vertex buffer, since a mesh in the Model could be drawn by multiple nodes.",
  16233. related = {
  16234. "Model:getTriangles",
  16235. "Model:getTriangleCount",
  16236. "ModelData:getVertexCount"
  16237. },
  16238. variants = {
  16239. {
  16240. arguments = {},
  16241. returns = {
  16242. {
  16243. name = "count",
  16244. type = "number",
  16245. description = "The total number of vertices."
  16246. }
  16247. }
  16248. }
  16249. }
  16250. },
  16251. {
  16252. name = "getWidth",
  16253. summary = "Get the width of the Model.",
  16254. description = "Returns the width of the Model, computed from its axis-aligned bounding box.",
  16255. key = "Model:getWidth",
  16256. module = "lovr.graphics",
  16257. related = {
  16258. "Model:getHeight",
  16259. "Model:getDepth",
  16260. "Model:getDimensions",
  16261. "Model:getCenter",
  16262. "Model:getBoundingBox",
  16263. "ModelData:getWidth"
  16264. },
  16265. variants = {
  16266. {
  16267. arguments = {},
  16268. returns = {
  16269. {
  16270. name = "width",
  16271. type = "number",
  16272. description = "The width of the Model."
  16273. }
  16274. }
  16275. }
  16276. }
  16277. },
  16278. {
  16279. name = "hasJoints",
  16280. summary = "Check if the Model uses joints for skeletal animation.",
  16281. description = "Returns whether the Model has any skeletal animations.",
  16282. key = "Model:hasJoints",
  16283. module = "lovr.graphics",
  16284. notes = "This will return when there's at least one skin in the model, as returned by `ModelData:getSkinCount`.\n\nEven if this function returns true, the model could still have non-skeletal animations.\n\nRight now a model can only be drawn with one skeletal pose per frame.",
  16285. variants = {
  16286. {
  16287. arguments = {},
  16288. returns = {
  16289. {
  16290. name = "jointed",
  16291. type = "boolean",
  16292. description = "Whether the animation uses joint nodes for skeletal animation."
  16293. }
  16294. }
  16295. }
  16296. }
  16297. },
  16298. {
  16299. name = "resetNodeTransforms",
  16300. summary = "Reset node transforms.",
  16301. description = "Resets node transforms to the original ones defined in the model file.",
  16302. key = "Model:resetNodeTransforms",
  16303. module = "lovr.graphics",
  16304. variants = {
  16305. {
  16306. arguments = {},
  16307. returns = {}
  16308. }
  16309. }
  16310. },
  16311. {
  16312. name = "setBlendShapeWeight",
  16313. summary = "Set the weight of a blend shape.",
  16314. description = "Sets the weight of a blend shape. A blend shape contains offset values for the vertices of one of the meshes in a Model. Whenever the Model is drawn, the offsets are multiplied by the weight of the blend shape, allowing for smooth blending between different meshes. A weight of zero won't apply any displacement and will skip processing of the blend shape.",
  16315. key = "Model:setBlendShapeWeight",
  16316. module = "lovr.graphics",
  16317. notes = "The initial weights are declared in the model file.\n\nWeights can be any number, but usually they're kept between 0 and 1.\n\nThis function will throw an error if the blend shape name or index doesn't exist.",
  16318. related = {
  16319. "Model:getBlendShapeCount",
  16320. "Model:getBlendShapeName"
  16321. },
  16322. variants = {
  16323. {
  16324. arguments = {
  16325. {
  16326. name = "index",
  16327. type = "number",
  16328. description = "The index of a blend shape."
  16329. },
  16330. {
  16331. name = "weight",
  16332. type = "number",
  16333. description = "The new weight for the blend shape."
  16334. }
  16335. },
  16336. returns = {}
  16337. },
  16338. {
  16339. arguments = {
  16340. {
  16341. name = "name",
  16342. type = "string",
  16343. description = "The name of a blend shape."
  16344. },
  16345. {
  16346. name = "weight",
  16347. type = "number",
  16348. description = "The new weight for the blend shape."
  16349. }
  16350. },
  16351. returns = {}
  16352. }
  16353. }
  16354. },
  16355. {
  16356. name = "setNodeOrientation",
  16357. summary = "Set or blend the orientation of a node.",
  16358. description = "Sets or blends the orientation of a node to a new orientation. This sets the local orientation of the node, relative to its parent.",
  16359. key = "Model:setNodeOrientation",
  16360. module = "lovr.graphics",
  16361. related = {
  16362. "Model:getNodePosition",
  16363. "Model:setNodePosition",
  16364. "Model:getNodeScale",
  16365. "Model:setNodeScale",
  16366. "Model:getNodePose",
  16367. "Model:setNodePose",
  16368. "Model:getNodeTransform",
  16369. "Model:setNodeTransform",
  16370. "Model:animate"
  16371. },
  16372. variants = {
  16373. {
  16374. arguments = {
  16375. {
  16376. name = "index",
  16377. type = "number",
  16378. description = "The index of the node."
  16379. },
  16380. {
  16381. name = "angle",
  16382. type = "number",
  16383. description = "The number of radians the node should be rotated around its rotation axis."
  16384. },
  16385. {
  16386. name = "ax",
  16387. type = "number",
  16388. description = "The x component of the axis of rotation."
  16389. },
  16390. {
  16391. name = "ay",
  16392. type = "number",
  16393. description = "The y component of the axis of rotation."
  16394. },
  16395. {
  16396. name = "az",
  16397. type = "number",
  16398. description = "The z component of the axis of rotation."
  16399. },
  16400. {
  16401. name = "blend",
  16402. type = "number",
  16403. description = "A number from 0 to 1 indicating how much of the target orientation to blend in. A value of 0 will not change the node's orientation at all, whereas 1 will fully blend to the target orientation.",
  16404. default = "1.0"
  16405. }
  16406. },
  16407. returns = {}
  16408. },
  16409. {
  16410. arguments = {
  16411. {
  16412. name = "name",
  16413. type = "string",
  16414. description = "The name of the node."
  16415. },
  16416. {
  16417. name = "angle",
  16418. type = "number",
  16419. description = "The number of radians the node should be rotated around its rotation axis."
  16420. },
  16421. {
  16422. name = "ax",
  16423. type = "number",
  16424. description = "The x component of the axis of rotation."
  16425. },
  16426. {
  16427. name = "ay",
  16428. type = "number",
  16429. description = "The y component of the axis of rotation."
  16430. },
  16431. {
  16432. name = "az",
  16433. type = "number",
  16434. description = "The z component of the axis of rotation."
  16435. },
  16436. {
  16437. name = "blend",
  16438. type = "number",
  16439. description = "A number from 0 to 1 indicating how much of the target orientation to blend in. A value of 0 will not change the node's orientation at all, whereas 1 will fully blend to the target orientation.",
  16440. default = "1.0"
  16441. }
  16442. },
  16443. returns = {}
  16444. },
  16445. {
  16446. arguments = {
  16447. {
  16448. name = "index",
  16449. type = "number",
  16450. description = "The index of the node."
  16451. },
  16452. {
  16453. name = "orientation",
  16454. type = "Quat",
  16455. description = "The orientation."
  16456. },
  16457. {
  16458. name = "blend",
  16459. type = "number",
  16460. description = "A number from 0 to 1 indicating how much of the target orientation to blend in. A value of 0 will not change the node's orientation at all, whereas 1 will fully blend to the target orientation.",
  16461. default = "1.0"
  16462. }
  16463. },
  16464. returns = {}
  16465. },
  16466. {
  16467. arguments = {
  16468. {
  16469. name = "name",
  16470. type = "string",
  16471. description = "The name of the node."
  16472. },
  16473. {
  16474. name = "orientation",
  16475. type = "Quat",
  16476. description = "The orientation."
  16477. },
  16478. {
  16479. name = "blend",
  16480. type = "number",
  16481. description = "A number from 0 to 1 indicating how much of the target orientation to blend in. A value of 0 will not change the node's orientation at all, whereas 1 will fully blend to the target orientation.",
  16482. default = "1.0"
  16483. }
  16484. },
  16485. returns = {}
  16486. }
  16487. }
  16488. },
  16489. {
  16490. name = "setNodePose",
  16491. summary = "Set or blend the pose of a node.",
  16492. description = "Sets or blends the pose (position and orientation) of a node to a new pose. This sets the local pose of the node, relative to its parent. The scale will remain unchanged.",
  16493. key = "Model:setNodePose",
  16494. module = "lovr.graphics",
  16495. related = {
  16496. "Model:getNodePosition",
  16497. "Model:setNodePosition",
  16498. "Model:getNodeOrientation",
  16499. "Model:setNodeOrientation",
  16500. "Model:getNodeScale",
  16501. "Model:setNodeScale",
  16502. "Model:getNodeTransform",
  16503. "Model:setNodeTransform",
  16504. "Model:animate"
  16505. },
  16506. variants = {
  16507. {
  16508. arguments = {
  16509. {
  16510. name = "index",
  16511. type = "number",
  16512. description = "The index of the node."
  16513. },
  16514. {
  16515. name = "x",
  16516. type = "number",
  16517. description = "The x component of the position."
  16518. },
  16519. {
  16520. name = "y",
  16521. type = "number",
  16522. description = "The y component of the position."
  16523. },
  16524. {
  16525. name = "z",
  16526. type = "number",
  16527. description = "The z component of the position."
  16528. },
  16529. {
  16530. name = "angle",
  16531. type = "number",
  16532. description = "The number of radians the node should be rotated around its rotation axis."
  16533. },
  16534. {
  16535. name = "ax",
  16536. type = "number",
  16537. description = "The x component of the axis of rotation."
  16538. },
  16539. {
  16540. name = "ay",
  16541. type = "number",
  16542. description = "The y component of the axis of rotation."
  16543. },
  16544. {
  16545. name = "az",
  16546. type = "number",
  16547. description = "The z component of the axis of rotation."
  16548. },
  16549. {
  16550. name = "blend",
  16551. type = "number",
  16552. description = "A number from 0 to 1 indicating how much of the target pose to blend in. A value of 0 will not change the node's pose at all, whereas 1 will fully blend to the target pose.",
  16553. default = "1.0"
  16554. }
  16555. },
  16556. returns = {}
  16557. },
  16558. {
  16559. arguments = {
  16560. {
  16561. name = "name",
  16562. type = "string",
  16563. description = "The name of the node."
  16564. },
  16565. {
  16566. name = "x",
  16567. type = "number",
  16568. description = "The x component of the position."
  16569. },
  16570. {
  16571. name = "y",
  16572. type = "number",
  16573. description = "The y component of the position."
  16574. },
  16575. {
  16576. name = "z",
  16577. type = "number",
  16578. description = "The z component of the position."
  16579. },
  16580. {
  16581. name = "angle",
  16582. type = "number",
  16583. description = "The number of radians the node should be rotated around its rotation axis."
  16584. },
  16585. {
  16586. name = "ax",
  16587. type = "number",
  16588. description = "The x component of the axis of rotation."
  16589. },
  16590. {
  16591. name = "ay",
  16592. type = "number",
  16593. description = "The y component of the axis of rotation."
  16594. },
  16595. {
  16596. name = "az",
  16597. type = "number",
  16598. description = "The z component of the axis of rotation."
  16599. },
  16600. {
  16601. name = "blend",
  16602. type = "number",
  16603. description = "A number from 0 to 1 indicating how much of the target pose to blend in. A value of 0 will not change the node's pose at all, whereas 1 will fully blend to the target pose.",
  16604. default = "1.0"
  16605. }
  16606. },
  16607. returns = {}
  16608. },
  16609. {
  16610. arguments = {
  16611. {
  16612. name = "index",
  16613. type = "number",
  16614. description = "The index of the node."
  16615. },
  16616. {
  16617. name = "position",
  16618. type = "Vec3",
  16619. description = "The target position. Can also be provided as 3 numbers."
  16620. },
  16621. {
  16622. name = "orientation",
  16623. type = "Quat",
  16624. description = "The target orientation. Can also be provided as 4 numbers in angle-axis form."
  16625. },
  16626. {
  16627. name = "blend",
  16628. type = "number",
  16629. description = "A number from 0 to 1 indicating how much of the target pose to blend in. A value of 0 will not change the node's pose at all, whereas 1 will fully blend to the target pose.",
  16630. default = "1.0"
  16631. }
  16632. },
  16633. returns = {}
  16634. },
  16635. {
  16636. arguments = {
  16637. {
  16638. name = "name",
  16639. type = "string",
  16640. description = "The name of the node."
  16641. },
  16642. {
  16643. name = "position",
  16644. type = "Vec3",
  16645. description = "The target position. Can also be provided as 3 numbers."
  16646. },
  16647. {
  16648. name = "orientation",
  16649. type = "Quat",
  16650. description = "The target orientation. Can also be provided as 4 numbers in angle-axis form."
  16651. },
  16652. {
  16653. name = "blend",
  16654. type = "number",
  16655. description = "A number from 0 to 1 indicating how much of the target pose to blend in. A value of 0 will not change the node's pose at all, whereas 1 will fully blend to the target pose.",
  16656. default = "1.0"
  16657. }
  16658. },
  16659. returns = {}
  16660. }
  16661. }
  16662. },
  16663. {
  16664. name = "setNodePosition",
  16665. summary = "Set or blend the position of a node.",
  16666. description = "Sets or blends the position of a node. This sets the local position of the node, relative to its parent.",
  16667. key = "Model:setNodePosition",
  16668. module = "lovr.graphics",
  16669. related = {
  16670. "Model:getNodeOrientation",
  16671. "Model:setNodeOrientation",
  16672. "Model:getNodeScale",
  16673. "Model:setNodeScale",
  16674. "Model:getNodePose",
  16675. "Model:setNodePose",
  16676. "Model:getNodeTransform",
  16677. "Model:setNodeTransform",
  16678. "Model:animate"
  16679. },
  16680. variants = {
  16681. {
  16682. arguments = {
  16683. {
  16684. name = "index",
  16685. type = "number",
  16686. description = "The index of the node."
  16687. },
  16688. {
  16689. name = "x",
  16690. type = "number",
  16691. description = "The x coordinate of the new position."
  16692. },
  16693. {
  16694. name = "y",
  16695. type = "number",
  16696. description = "The y coordinate of the new position."
  16697. },
  16698. {
  16699. name = "z",
  16700. type = "number",
  16701. description = "The z coordinate of the new position."
  16702. },
  16703. {
  16704. name = "blend",
  16705. type = "number",
  16706. description = "A number from 0 to 1 indicating how much of the new position to blend in. A value of 0 will not change the node's position at all, whereas 1 will fully blend to the target position.",
  16707. default = "1.0"
  16708. }
  16709. },
  16710. returns = {}
  16711. },
  16712. {
  16713. arguments = {
  16714. {
  16715. name = "name",
  16716. type = "string",
  16717. description = "The name of the node."
  16718. },
  16719. {
  16720. name = "x",
  16721. type = "number",
  16722. description = "The x coordinate of the new position."
  16723. },
  16724. {
  16725. name = "y",
  16726. type = "number",
  16727. description = "The y coordinate of the new position."
  16728. },
  16729. {
  16730. name = "z",
  16731. type = "number",
  16732. description = "The z coordinate of the new position."
  16733. },
  16734. {
  16735. name = "blend",
  16736. type = "number",
  16737. description = "A number from 0 to 1 indicating how much of the new position to blend in. A value of 0 will not change the node's position at all, whereas 1 will fully blend to the target position.",
  16738. default = "1.0"
  16739. }
  16740. },
  16741. returns = {}
  16742. },
  16743. {
  16744. arguments = {
  16745. {
  16746. name = "index",
  16747. type = "number",
  16748. description = "The index of the node."
  16749. },
  16750. {
  16751. name = "position",
  16752. type = "Vec3",
  16753. description = "The new position."
  16754. },
  16755. {
  16756. name = "blend",
  16757. type = "number",
  16758. description = "A number from 0 to 1 indicating how much of the new position to blend in. A value of 0 will not change the node's position at all, whereas 1 will fully blend to the target position.",
  16759. default = "1.0"
  16760. }
  16761. },
  16762. returns = {}
  16763. },
  16764. {
  16765. arguments = {
  16766. {
  16767. name = "name",
  16768. type = "string",
  16769. description = "The name of the node."
  16770. },
  16771. {
  16772. name = "position",
  16773. type = "Vec3",
  16774. description = "The new position."
  16775. },
  16776. {
  16777. name = "blend",
  16778. type = "number",
  16779. description = "A number from 0 to 1 indicating how much of the new position to blend in. A value of 0 will not change the node's position at all, whereas 1 will fully blend to the target position.",
  16780. default = "1.0"
  16781. }
  16782. },
  16783. returns = {}
  16784. }
  16785. }
  16786. },
  16787. {
  16788. name = "setNodeScale",
  16789. summary = "Set or blend the scale of a node.",
  16790. description = "Sets or blends the scale of a node to a new scale. This sets the local scale of the node, relative to its parent.",
  16791. key = "Model:setNodeScale",
  16792. module = "lovr.graphics",
  16793. notes = "For best results when animating, it's recommended to keep the 3 scale components the same.",
  16794. related = {
  16795. "Model:getNodePosition",
  16796. "Model:setNodePosition",
  16797. "Model:getNodeOrientation",
  16798. "Model:setNodeOrientation",
  16799. "Model:getNodePose",
  16800. "Model:setNodePose",
  16801. "Model:getNodeTransform",
  16802. "Model:setNodeTransform",
  16803. "Model:animate"
  16804. },
  16805. variants = {
  16806. {
  16807. arguments = {
  16808. {
  16809. name = "index",
  16810. type = "number",
  16811. description = "The index of the node."
  16812. },
  16813. {
  16814. name = "sx",
  16815. type = "number",
  16816. description = "The x scale."
  16817. },
  16818. {
  16819. name = "sy",
  16820. type = "number",
  16821. description = "The y scale."
  16822. },
  16823. {
  16824. name = "sz",
  16825. type = "number",
  16826. description = "The z scale."
  16827. },
  16828. {
  16829. name = "blend",
  16830. type = "number",
  16831. description = "A number from 0 to 1 indicating how much of the new scale to blend in. A value of 0 will not change the node's scale at all, whereas 1 will fully blend to the target scale.",
  16832. default = "1.0"
  16833. }
  16834. },
  16835. returns = {}
  16836. },
  16837. {
  16838. arguments = {
  16839. {
  16840. name = "name",
  16841. type = "string",
  16842. description = "The name of the node."
  16843. },
  16844. {
  16845. name = "sx",
  16846. type = "number",
  16847. description = "The x scale."
  16848. },
  16849. {
  16850. name = "sy",
  16851. type = "number",
  16852. description = "The y scale."
  16853. },
  16854. {
  16855. name = "sz",
  16856. type = "number",
  16857. description = "The z scale."
  16858. },
  16859. {
  16860. name = "blend",
  16861. type = "number",
  16862. description = "A number from 0 to 1 indicating how much of the new scale to blend in. A value of 0 will not change the node's scale at all, whereas 1 will fully blend to the target scale.",
  16863. default = "1.0"
  16864. }
  16865. },
  16866. returns = {}
  16867. },
  16868. {
  16869. arguments = {
  16870. {
  16871. name = "index",
  16872. type = "number",
  16873. description = "The index of the node."
  16874. },
  16875. {
  16876. name = "scale",
  16877. type = "Vec3",
  16878. description = "The new scale."
  16879. },
  16880. {
  16881. name = "blend",
  16882. type = "number",
  16883. description = "A number from 0 to 1 indicating how much of the new scale to blend in. A value of 0 will not change the node's scale at all, whereas 1 will fully blend to the target scale.",
  16884. default = "1.0"
  16885. }
  16886. },
  16887. returns = {}
  16888. },
  16889. {
  16890. arguments = {
  16891. {
  16892. name = "name",
  16893. type = "string",
  16894. description = "The name of the node."
  16895. },
  16896. {
  16897. name = "scale",
  16898. type = "Vec3",
  16899. description = "The new scale."
  16900. },
  16901. {
  16902. name = "blend",
  16903. type = "number",
  16904. description = "A number from 0 to 1 indicating how much of the new scale to blend in. A value of 0 will not change the node's scale at all, whereas 1 will fully blend to the target scale.",
  16905. default = "1.0"
  16906. }
  16907. },
  16908. returns = {}
  16909. }
  16910. }
  16911. },
  16912. {
  16913. name = "setNodeTransform",
  16914. summary = "Set or blend the transform of a node.",
  16915. description = "Sets or blends the transform of a node to a new transform. This sets the local transform of the node, relative to its parent.",
  16916. key = "Model:setNodeTransform",
  16917. module = "lovr.graphics",
  16918. notes = "For best results when animating, it's recommended to keep the 3 components of the scale the same.\n\nEven though the translation, scale, and rotation parameters are given in TSR order, they are applied in the normal TRS order.",
  16919. related = {
  16920. "Model:getNodePosition",
  16921. "Model:setNodePosition",
  16922. "Model:getNodeOrientation",
  16923. "Model:setNodeOrientation",
  16924. "Model:getNodeScale",
  16925. "Model:setNodeScale",
  16926. "Model:getNodePose",
  16927. "Model:setNodePose",
  16928. "Model:animate"
  16929. },
  16930. variants = {
  16931. {
  16932. arguments = {
  16933. {
  16934. name = "index",
  16935. type = "number",
  16936. description = "The index of the node."
  16937. },
  16938. {
  16939. name = "x",
  16940. type = "number",
  16941. description = "The x component of the position."
  16942. },
  16943. {
  16944. name = "y",
  16945. type = "number",
  16946. description = "The y component of the position."
  16947. },
  16948. {
  16949. name = "z",
  16950. type = "number",
  16951. description = "The z component of the position."
  16952. },
  16953. {
  16954. name = "sx",
  16955. type = "number",
  16956. description = "The x component of the scale."
  16957. },
  16958. {
  16959. name = "sy",
  16960. type = "number",
  16961. description = "The y component of the scale."
  16962. },
  16963. {
  16964. name = "sz",
  16965. type = "number",
  16966. description = "The z component of the scale."
  16967. },
  16968. {
  16969. name = "angle",
  16970. type = "number",
  16971. description = "The number of radians the node should be rotated around its rotation axis."
  16972. },
  16973. {
  16974. name = "ax",
  16975. type = "number",
  16976. description = "The x component of the axis of rotation."
  16977. },
  16978. {
  16979. name = "ay",
  16980. type = "number",
  16981. description = "The y component of the axis of rotation."
  16982. },
  16983. {
  16984. name = "az",
  16985. type = "number",
  16986. description = "The z component of the axis of rotation."
  16987. },
  16988. {
  16989. name = "blend",
  16990. type = "number",
  16991. description = "A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform.",
  16992. default = "1.0"
  16993. }
  16994. },
  16995. returns = {}
  16996. },
  16997. {
  16998. arguments = {
  16999. {
  17000. name = "name",
  17001. type = "string",
  17002. description = "The name of the node."
  17003. },
  17004. {
  17005. name = "x",
  17006. type = "number",
  17007. description = "The x component of the position."
  17008. },
  17009. {
  17010. name = "y",
  17011. type = "number",
  17012. description = "The y component of the position."
  17013. },
  17014. {
  17015. name = "z",
  17016. type = "number",
  17017. description = "The z component of the position."
  17018. },
  17019. {
  17020. name = "sx",
  17021. type = "number",
  17022. description = "The x component of the scale."
  17023. },
  17024. {
  17025. name = "sy",
  17026. type = "number",
  17027. description = "The y component of the scale."
  17028. },
  17029. {
  17030. name = "sz",
  17031. type = "number",
  17032. description = "The z component of the scale."
  17033. },
  17034. {
  17035. name = "angle",
  17036. type = "number",
  17037. description = "The number of radians the node should be rotated around its rotation axis."
  17038. },
  17039. {
  17040. name = "ax",
  17041. type = "number",
  17042. description = "The x component of the axis of rotation."
  17043. },
  17044. {
  17045. name = "ay",
  17046. type = "number",
  17047. description = "The y component of the axis of rotation."
  17048. },
  17049. {
  17050. name = "az",
  17051. type = "number",
  17052. description = "The z component of the axis of rotation."
  17053. },
  17054. {
  17055. name = "blend",
  17056. type = "number",
  17057. description = "A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform.",
  17058. default = "1.0"
  17059. }
  17060. },
  17061. returns = {}
  17062. },
  17063. {
  17064. arguments = {
  17065. {
  17066. name = "index",
  17067. type = "number",
  17068. description = "The index of the node."
  17069. },
  17070. {
  17071. name = "position",
  17072. type = "Vec3",
  17073. description = "The position."
  17074. },
  17075. {
  17076. name = "scale",
  17077. type = "Vec3",
  17078. description = "The scale."
  17079. },
  17080. {
  17081. name = "orientation",
  17082. type = "Quat",
  17083. description = "The orientation."
  17084. },
  17085. {
  17086. name = "blend",
  17087. type = "number",
  17088. description = "A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform.",
  17089. default = "1.0"
  17090. }
  17091. },
  17092. returns = {}
  17093. },
  17094. {
  17095. arguments = {
  17096. {
  17097. name = "name",
  17098. type = "string",
  17099. description = "The name of the node."
  17100. },
  17101. {
  17102. name = "position",
  17103. type = "Vec3",
  17104. description = "The position."
  17105. },
  17106. {
  17107. name = "scale",
  17108. type = "Vec3",
  17109. description = "The scale."
  17110. },
  17111. {
  17112. name = "orientation",
  17113. type = "Quat",
  17114. description = "The orientation."
  17115. },
  17116. {
  17117. name = "blend",
  17118. type = "number",
  17119. description = "A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform.",
  17120. default = "1.0"
  17121. }
  17122. },
  17123. returns = {}
  17124. },
  17125. {
  17126. arguments = {
  17127. {
  17128. name = "index",
  17129. type = "number",
  17130. description = "The index of the node."
  17131. },
  17132. {
  17133. name = "transform",
  17134. type = "Mat4",
  17135. description = "The transform."
  17136. },
  17137. {
  17138. name = "blend",
  17139. type = "number",
  17140. description = "A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform.",
  17141. default = "1.0"
  17142. }
  17143. },
  17144. returns = {}
  17145. },
  17146. {
  17147. arguments = {
  17148. {
  17149. name = "name",
  17150. type = "string",
  17151. description = "The name of the node."
  17152. },
  17153. {
  17154. name = "transform",
  17155. type = "Mat4",
  17156. description = "The transform."
  17157. },
  17158. {
  17159. name = "blend",
  17160. type = "number",
  17161. description = "A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform.",
  17162. default = "1.0"
  17163. }
  17164. },
  17165. returns = {}
  17166. }
  17167. }
  17168. }
  17169. }
  17170. },
  17171. {
  17172. name = "Pass",
  17173. summary = "A stream of graphics commands.",
  17174. description = "Pass objects record work for the GPU. They contain a list of things to draw and a list of compute shaders to run.\n\nMethods like `Pass:sphere` will \"record\" a draw on the Pass, which adds it to the list. Other methods like `Pass:setBlendMode` or `Pass:setShader` will change the way the next draws are processed.\n\nOnce all of the work has been recorded to a Pass, it can be sent to the GPU using `lovr.graphics.submit`, which will start processing all of the compute work and draws (in that order).\n\nA Pass can have a canvas, which is a set of textures that the draws will render to.\n\n`Pass:reset` is used to clear all of the computes and draws, putting the Pass in a fresh state.\n\n`lovr.draw` is called every frame with a `Pass` that is configured to render to either the headset or the window. The Pass will automatically get submitted afterwards.",
  17175. key = "Pass",
  17176. module = "lovr.graphics",
  17177. constructors = {
  17178. "lovr.graphics.newPass",
  17179. "lovr.graphics.getWindowPass",
  17180. "lovr.headset.getPass",
  17181. "lovr.graphics.getPass"
  17182. },
  17183. methods = {
  17184. {
  17185. name = "barrier",
  17186. tag = "compute",
  17187. summary = "Synchronize compute work.",
  17188. description = "Synchronizes compute work.\n\nBy default, within a single Pass, multiple calls to `Pass:compute` can run on the GPU in any order, or all at the same time. This is great because it lets the GPU process the work as efficiently as possible, but sometimes multiple compute dispatches need to be sequenced.\n\nCalling this function will insert a barrier. All compute operations on the Pass after the barrier will only start once all of the previous compute operations on the Pass are finished.",
  17189. key = "Pass:barrier",
  17190. module = "lovr.graphics",
  17191. examples = {
  17192. {
  17193. code = "pass = lovr.graphics.newPass()\npass:setShader(computeShader)\n\npass:compute(x, y, z)\npass:compute(x, y, z)\npass:barrier()\npass:compute(x, y, z) --> waits for the previous 2 :computes to complete"
  17194. }
  17195. },
  17196. notes = "It's only necessary to use a barrier if a compute shader is reading/writing the same bytes of memory that a previous compute operation in the same Pass read/wrote.\n\nBarriers will slow things down because they reduce parallelism by causing the GPU to wait. Strategic reordering of non-dependent :compute calls around the barrier can help.\n\nCalling this function before recording any :computes will do nothing, and calling it after the last :compute will do nothing.",
  17197. related = {
  17198. "Pass:compute"
  17199. },
  17200. variants = {
  17201. {
  17202. arguments = {},
  17203. returns = {}
  17204. }
  17205. }
  17206. },
  17207. {
  17208. name = "beginTally",
  17209. tag = "tally",
  17210. summary = "Begin a tally.",
  17211. description = "Begins a new tally. The tally will count the number of pixels touched by any draws that occur while the tally is active. If a pixel fails the depth test or stencil test then it won't be counted, so the tally is a way to detect if objects are visible.\n\nThe results for all the tallies in the pass can be copied to a `Buffer` when the Pass finishes by setting a buffer with `Pass:setTallyBuffer`.",
  17212. key = "Pass:beginTally",
  17213. module = "lovr.graphics",
  17214. notes = "There is currently a maximum of 256 tallies per pass.\n\nIf a tally is already active, this function will error.",
  17215. related = {
  17216. "Pass:finishTally"
  17217. },
  17218. variants = {
  17219. {
  17220. arguments = {},
  17221. returns = {
  17222. {
  17223. name = "index",
  17224. type = "number",
  17225. description = "The index of the tally that was started."
  17226. }
  17227. }
  17228. }
  17229. }
  17230. },
  17231. {
  17232. name = "box",
  17233. tag = "drawing",
  17234. summary = "Draw a box.",
  17235. description = "Draw a box. This is like `Pass:cube`, except it takes 3 separate values for the scale.",
  17236. key = "Pass:box",
  17237. module = "lovr.graphics",
  17238. related = {
  17239. "Pass:cube"
  17240. },
  17241. variants = {
  17242. {
  17243. arguments = {
  17244. {
  17245. name = "x",
  17246. type = "number",
  17247. description = "The x coordinate of the center of the box.",
  17248. default = "0"
  17249. },
  17250. {
  17251. name = "y",
  17252. type = "number",
  17253. description = "The y coordinate of the center of the box.",
  17254. default = "0"
  17255. },
  17256. {
  17257. name = "z",
  17258. type = "number",
  17259. description = "The z coordinate of the center of the box.",
  17260. default = "0"
  17261. },
  17262. {
  17263. name = "width",
  17264. type = "number",
  17265. description = "The width of the box.",
  17266. default = "1"
  17267. },
  17268. {
  17269. name = "height",
  17270. type = "number",
  17271. description = "The height of the box.",
  17272. default = "1"
  17273. },
  17274. {
  17275. name = "depth",
  17276. type = "number",
  17277. description = "The depth of the box.",
  17278. default = "1"
  17279. },
  17280. {
  17281. name = "angle",
  17282. type = "number",
  17283. description = "The rotation of the box around its rotation axis, in radians.",
  17284. default = "0"
  17285. },
  17286. {
  17287. name = "ax",
  17288. type = "number",
  17289. description = "The x component of the axis of rotation.",
  17290. default = "0"
  17291. },
  17292. {
  17293. name = "ay",
  17294. type = "number",
  17295. description = "The y component of the axis of rotation.",
  17296. default = "1"
  17297. },
  17298. {
  17299. name = "az",
  17300. type = "number",
  17301. description = "The z component of the axis of rotation.",
  17302. default = "0"
  17303. },
  17304. {
  17305. name = "style",
  17306. type = "DrawStyle",
  17307. description = "Whether the box should be drawn filled or outlined.",
  17308. default = "'fill'"
  17309. }
  17310. },
  17311. returns = {}
  17312. },
  17313. {
  17314. arguments = {
  17315. {
  17316. name = "position",
  17317. type = "Vec3",
  17318. description = "The position of the box."
  17319. },
  17320. {
  17321. name = "size",
  17322. type = "Vec3",
  17323. description = "The size of the box."
  17324. },
  17325. {
  17326. name = "orientation",
  17327. type = "Quat",
  17328. description = "The orientation of the box."
  17329. },
  17330. {
  17331. name = "style",
  17332. type = "DrawStyle",
  17333. description = "Whether the box should be drawn filled or outlined.",
  17334. default = "'fill'"
  17335. }
  17336. },
  17337. returns = {}
  17338. },
  17339. {
  17340. arguments = {
  17341. {
  17342. name = "transform",
  17343. type = "Mat4",
  17344. description = "The transform of the box."
  17345. },
  17346. {
  17347. name = "style",
  17348. type = "DrawStyle",
  17349. description = "Whether the box should be drawn filled or outlined.",
  17350. default = "'fill'"
  17351. }
  17352. },
  17353. returns = {}
  17354. }
  17355. }
  17356. },
  17357. {
  17358. name = "capsule",
  17359. tag = "drawing",
  17360. summary = "Draw a capsule.",
  17361. description = "Draws a capsule. A capsule is shaped like a cylinder with a hemisphere on each end.",
  17362. key = "Pass:capsule",
  17363. module = "lovr.graphics",
  17364. notes = "The length of the capsule does not include the end caps. The local origin of the capsule is in the center, and the local z axis points towards the end caps.",
  17365. variants = {
  17366. {
  17367. arguments = {
  17368. {
  17369. name = "x",
  17370. type = "number",
  17371. description = "The x coordinate of the center of the capsule.",
  17372. default = "0"
  17373. },
  17374. {
  17375. name = "y",
  17376. type = "number",
  17377. description = "The y coordinate of the center of the capsule.",
  17378. default = "0"
  17379. },
  17380. {
  17381. name = "z",
  17382. type = "number",
  17383. description = "The z coordinate of the center of the capsule.",
  17384. default = "0"
  17385. },
  17386. {
  17387. name = "radius",
  17388. type = "number",
  17389. description = "The radius of the capsule.",
  17390. default = "1.0"
  17391. },
  17392. {
  17393. name = "length",
  17394. type = "number",
  17395. description = "The length of the capsule.",
  17396. default = "1"
  17397. },
  17398. {
  17399. name = "angle",
  17400. type = "number",
  17401. description = "The rotation of the capsule around its rotation axis, in radians.",
  17402. default = "0"
  17403. },
  17404. {
  17405. name = "ax",
  17406. type = "number",
  17407. description = "The x component of the axis of rotation.",
  17408. default = "0"
  17409. },
  17410. {
  17411. name = "ay",
  17412. type = "number",
  17413. description = "The y component of the axis of rotation.",
  17414. default = "1"
  17415. },
  17416. {
  17417. name = "az",
  17418. type = "number",
  17419. description = "The z component of the axis of rotation.",
  17420. default = "0"
  17421. },
  17422. {
  17423. name = "segments",
  17424. type = "number",
  17425. description = "The number of circular segments to render.",
  17426. default = "32"
  17427. }
  17428. },
  17429. returns = {}
  17430. },
  17431. {
  17432. arguments = {
  17433. {
  17434. name = "position",
  17435. type = "Vec3",
  17436. description = "The position of the center of the capsule."
  17437. },
  17438. {
  17439. name = "radius",
  17440. type = "number",
  17441. description = "The radius of the capsule.",
  17442. default = "1.0"
  17443. },
  17444. {
  17445. name = "length",
  17446. type = "number",
  17447. description = "The length of the capsule.",
  17448. default = "1"
  17449. },
  17450. {
  17451. name = "orientation",
  17452. type = "Quat",
  17453. description = "The orientation of the capsule."
  17454. },
  17455. {
  17456. name = "segments",
  17457. type = "number",
  17458. description = "The number of circular segments to render.",
  17459. default = "32"
  17460. }
  17461. },
  17462. returns = {}
  17463. },
  17464. {
  17465. arguments = {
  17466. {
  17467. name = "transform",
  17468. type = "Mat4",
  17469. description = "The transform of the capsule."
  17470. },
  17471. {
  17472. name = "segments",
  17473. type = "number",
  17474. description = "The number of circular segments to render.",
  17475. default = "32"
  17476. }
  17477. },
  17478. returns = {}
  17479. },
  17480. {
  17481. description = "Draws a capsule between two points.",
  17482. arguments = {
  17483. {
  17484. name = "p1",
  17485. type = "Vec3",
  17486. description = "The starting point of the capsule."
  17487. },
  17488. {
  17489. name = "p2",
  17490. type = "Vec3",
  17491. description = "The ending point of the capsule."
  17492. },
  17493. {
  17494. name = "radius",
  17495. type = "number",
  17496. description = "The radius of the capsule.",
  17497. default = "1.0"
  17498. },
  17499. {
  17500. name = "segments",
  17501. type = "number",
  17502. description = "The number of circular segments to render.",
  17503. default = "32"
  17504. }
  17505. },
  17506. returns = {}
  17507. }
  17508. }
  17509. },
  17510. {
  17511. name = "circle",
  17512. tag = "drawing",
  17513. summary = "Draw a circle.",
  17514. description = "Draws a circle.",
  17515. key = "Pass:circle",
  17516. module = "lovr.graphics",
  17517. notes = "The local origin of the circle is in its center. The local z axis is perpendicular to the circle.",
  17518. variants = {
  17519. {
  17520. arguments = {
  17521. {
  17522. name = "x",
  17523. type = "number",
  17524. description = "The x coordinate of the center of the circle.",
  17525. default = "0"
  17526. },
  17527. {
  17528. name = "y",
  17529. type = "number",
  17530. description = "The y coordinate of the center of the circle.",
  17531. default = "0"
  17532. },
  17533. {
  17534. name = "z",
  17535. type = "number",
  17536. description = "The z coordinate of the center of the circle.",
  17537. default = "0"
  17538. },
  17539. {
  17540. name = "radius",
  17541. type = "number",
  17542. description = "The radius of the circle.",
  17543. default = "1"
  17544. },
  17545. {
  17546. name = "angle",
  17547. type = "number",
  17548. description = "The rotation of the circle around its rotation axis, in radians.",
  17549. default = "0"
  17550. },
  17551. {
  17552. name = "ax",
  17553. type = "number",
  17554. description = "The x component of the axis of rotation.",
  17555. default = "0"
  17556. },
  17557. {
  17558. name = "ay",
  17559. type = "number",
  17560. description = "The y component of the axis of rotation.",
  17561. default = "1"
  17562. },
  17563. {
  17564. name = "az",
  17565. type = "number",
  17566. description = "The z component of the axis of rotation.",
  17567. default = "0"
  17568. },
  17569. {
  17570. name = "style",
  17571. type = "DrawStyle",
  17572. description = "Whether the circle should be filled or outlined.",
  17573. default = "'fill'"
  17574. },
  17575. {
  17576. name = "angle1",
  17577. type = "number",
  17578. description = "The angle of the beginning of the arc.",
  17579. default = "0"
  17580. },
  17581. {
  17582. name = "angle2",
  17583. type = "number",
  17584. description = "angle of the end of the arc.",
  17585. default = "2 * math.pi"
  17586. },
  17587. {
  17588. name = "segments",
  17589. type = "number",
  17590. description = "The number of segments to render.",
  17591. default = "64"
  17592. }
  17593. },
  17594. returns = {}
  17595. },
  17596. {
  17597. arguments = {
  17598. {
  17599. name = "position",
  17600. type = "Vec3",
  17601. description = "The position of the circle."
  17602. },
  17603. {
  17604. name = "radius",
  17605. type = "number",
  17606. description = "The radius of the circle.",
  17607. default = "1"
  17608. },
  17609. {
  17610. name = "orientation",
  17611. type = "Quat",
  17612. description = "The orientation of the circle."
  17613. },
  17614. {
  17615. name = "style",
  17616. type = "DrawStyle",
  17617. description = "Whether the circle should be filled or outlined.",
  17618. default = "'fill'"
  17619. },
  17620. {
  17621. name = "angle1",
  17622. type = "number",
  17623. description = "The angle of the beginning of the arc.",
  17624. default = "0"
  17625. },
  17626. {
  17627. name = "angle2",
  17628. type = "number",
  17629. description = "angle of the end of the arc.",
  17630. default = "2 * math.pi"
  17631. },
  17632. {
  17633. name = "segments",
  17634. type = "number",
  17635. description = "The number of segments to render.",
  17636. default = "64"
  17637. }
  17638. },
  17639. returns = {}
  17640. },
  17641. {
  17642. arguments = {
  17643. {
  17644. name = "transform",
  17645. type = "Mat4",
  17646. description = "The transform of the circle."
  17647. },
  17648. {
  17649. name = "style",
  17650. type = "DrawStyle",
  17651. description = "Whether the circle should be filled or outlined.",
  17652. default = "'fill'"
  17653. },
  17654. {
  17655. name = "angle1",
  17656. type = "number",
  17657. description = "The angle of the beginning of the arc.",
  17658. default = "0"
  17659. },
  17660. {
  17661. name = "angle2",
  17662. type = "number",
  17663. description = "angle of the end of the arc.",
  17664. default = "2 * math.pi"
  17665. },
  17666. {
  17667. name = "segments",
  17668. type = "number",
  17669. description = "The number of segments to render.",
  17670. default = "64"
  17671. }
  17672. },
  17673. returns = {}
  17674. }
  17675. }
  17676. },
  17677. {
  17678. name = "compute",
  17679. tag = "compute",
  17680. summary = "Run a compute shader.",
  17681. description = "Runs a compute shader. There must be an active compute shader set using `Pass:setShader`.\n\nAll of the compute shader dispatches in a Pass will run **before** all of the draws in the Pass (if any). They will also run at the same time in parallel, unless `Pass:barrier` is used to control the order.",
  17682. key = "Pass:compute",
  17683. module = "lovr.graphics",
  17684. examples = {
  17685. {
  17686. description = "A compute shader that makes a texture grayscale.",
  17687. code = "function lovr.load()\n shader = lovr.graphics.newShader([[\n layout(local_size_x = 8, local_size_y = 8) in;\n layout(set = 0, binding = 0, rgba8) uniform image2D image;\n\n void lovrmain() {\n ivec2 size = imageSize(image);\n ivec2 pixel = ivec2(GlobalThreadID.xy);\n\n if (pixel.x >= size.x || pixel.y >= size.y) {\n return;\n }\n\n vec4 color = imageLoad(image, pixel);\n color.rgb = vec3(color.r * .2126 + color.g * .7512 + color.b * .0722);\n imageStore(image, pixel, color);\n }\n ]])\n\n texture = lovr.graphics.newTexture('image.png', {\n usage = { 'storage', 'sample', 'transfer' },\n linear = true -- srgb textures don't always support storage usage\n })\n\n local tw, th = texture:getDimensions()\n local sx, sy = shader:getWorkgroupSize()\n local gx, gy = math.ceil(tw / sx), math.ceil(th / sy)\n\n local computer = lovr.graphics.newPass()\n\n computer:setShader(shader)\n computer:send('image', texture)\n computer:compute(gx, gy)\n lovr.graphics.submit(computer)\n\n texture:generateMipmaps()\nend\n\nfunction lovr.draw(pass)\n pass:draw(texture, 0, 1.7, -1)\nend"
  17688. }
  17689. },
  17690. notes = "Compute shaders are usually run once for each pixel in an image, once per particle, once per object, etc. The 3 arguments represent how many times to run, or \"dispatch\", the compute shader, in up to 3 dimensions. Each element of this grid is called a **workgroup**.\n\nTo make things even more complicated, each workgroup itself is made up of a set of \"mini GPU threads\", which are called **local workgroups**. Like workgroups, the local workgroup size can also be 3D. It's declared in the shader code, like this:\n\n layout(local_size_x = w, local_size_y = h, local_size_z = d) in;\n\nAll these 3D grids can get confusing, but the basic idea is to make the local workgroup size a small block of e.g. 32 particles or 8x8 pixels or 4x4x4 voxels, and then dispatch however many workgroups are needed to cover a list of particles, image, voxel field, etc.\n\nThe reason to do it this way is that the GPU runs its threads in little fixed-size bundles called subgroups. Subgroups are usually 32 or 64 threads (the exact size is given by the `subgroupSize` property of `lovr.graphics.getDevice`) and all run together. If the local workgroup size was `1x1x1`, then the GPU would only run 1 thread per subgroup and waste the other 31 or 63. So for the best performance, be sure to set a local workgroup size bigger than 1!\n\nInside the compute shader, a few builtin variables can be used to figure out which workgroup is running:\n\n- `uvec3 WorkgroupCount` is the workgroup count per axis (the `Pass:compute` arguments).\n- `uvec3 WorkgroupSize` is the local workgroup size (declared in the shader).\n- `uvec3 WorkgroupID` is the index of the current (global) workgroup.\n- `uvec3 LocalThreadID` is the index of the local workgroup inside its workgroup.\n- `uint LocalThreadIndex` is a 1D version of `LocalThreadID`.\n- `uvec3 GlobalThreadID` is the unique identifier for a thread within all workgroups in a\n dispatch. It's equivalent to `WorkgroupID * WorkgroupSize + LocalThreadID` (usually what you\n want!)\n\nIndirect compute dispatches are useful to \"chain\" compute shaders together, while keeping all of the data on the GPU. The first dispatch can do some computation and write some results to buffers, then the second indirect dispatch can use the data in those buffers to know how many times it should run. An example would be a compute shader that does some sort of object culling, writing the number of visible objects to a buffer along with the IDs of each one. Subsequent compute shaders can be indirectly dispatched to perform extra processing on the visible objects. Finally, an indirect draw can be used to render them.",
  17691. related = {
  17692. "Pass:barrier",
  17693. "Pass:setShader",
  17694. "Pass:send"
  17695. },
  17696. variants = {
  17697. {
  17698. arguments = {
  17699. {
  17700. name = "x",
  17701. type = "number",
  17702. description = "The number of workgroups to dispatch in the x dimension.",
  17703. default = "1"
  17704. },
  17705. {
  17706. name = "y",
  17707. type = "number",
  17708. description = "The number of workgroups to dispatch in the y dimension.",
  17709. default = "1"
  17710. },
  17711. {
  17712. name = "z",
  17713. type = "number",
  17714. description = "The number of workgroups to dispatch in the z dimension.",
  17715. default = "1"
  17716. }
  17717. },
  17718. returns = {}
  17719. },
  17720. {
  17721. description = "Perform an \"indirect\" dispatch. Instead of passing in the workgroup counts directly from Lua, the workgroup counts are read from a `Buffer` object at a particular byte offset. Each count should be a 4-byte integer, so in total 12 bytes will be read from the buffer.",
  17722. arguments = {
  17723. {
  17724. name = "buffer",
  17725. type = "Buffer",
  17726. description = "A Buffer object containing the x, y, and z workgroup counts, stored as 4 byte unsigned integers."
  17727. },
  17728. {
  17729. name = "offset",
  17730. type = "number",
  17731. description = "The byte offset to read the workgroup counts from in the Buffer.",
  17732. default = "0"
  17733. }
  17734. },
  17735. returns = {}
  17736. }
  17737. }
  17738. },
  17739. {
  17740. name = "cone",
  17741. tag = "drawing",
  17742. summary = "Draw a cone.",
  17743. description = "Draws a cone.",
  17744. key = "Pass:cone",
  17745. module = "lovr.graphics",
  17746. notes = "The local origin is at the center of the base of the cone, and the negative z axis points towards the tip.",
  17747. variants = {
  17748. {
  17749. arguments = {
  17750. {
  17751. name = "x",
  17752. type = "number",
  17753. description = "The x coordinate of the center of the base of the cone.",
  17754. default = "0"
  17755. },
  17756. {
  17757. name = "y",
  17758. type = "number",
  17759. description = "The y coordinate of the center of the base of the cone.",
  17760. default = "0"
  17761. },
  17762. {
  17763. name = "z",
  17764. type = "number",
  17765. description = "The z coordinate of the center of the base of the cone.",
  17766. default = "0"
  17767. },
  17768. {
  17769. name = "radius",
  17770. type = "number",
  17771. description = "The radius of the cone.",
  17772. default = "1"
  17773. },
  17774. {
  17775. name = "length",
  17776. type = "number",
  17777. description = "The length of the cone.",
  17778. default = "1"
  17779. },
  17780. {
  17781. name = "angle",
  17782. type = "number",
  17783. description = "The rotation of the cone around its rotation axis, in radians.",
  17784. default = "0"
  17785. },
  17786. {
  17787. name = "ax",
  17788. type = "number",
  17789. description = "The x component of the axis of rotation.",
  17790. default = "0"
  17791. },
  17792. {
  17793. name = "ay",
  17794. type = "number",
  17795. description = "The y component of the axis of rotation.",
  17796. default = "1"
  17797. },
  17798. {
  17799. name = "az",
  17800. type = "number",
  17801. description = "The z component of the axis of rotation.",
  17802. default = "0"
  17803. },
  17804. {
  17805. name = "segments",
  17806. type = "number",
  17807. description = "The number of segments in the cone.",
  17808. default = "64"
  17809. }
  17810. },
  17811. returns = {}
  17812. },
  17813. {
  17814. arguments = {
  17815. {
  17816. name = "position",
  17817. type = "Vec3",
  17818. description = "The position of the center of the base of the cone."
  17819. },
  17820. {
  17821. name = "radius",
  17822. type = "number",
  17823. description = "The radius of the cone.",
  17824. default = "1"
  17825. },
  17826. {
  17827. name = "length",
  17828. type = "number",
  17829. description = "The length of the cone.",
  17830. default = "1"
  17831. },
  17832. {
  17833. name = "orientation",
  17834. type = "Quat",
  17835. description = "The orientation of the cone."
  17836. },
  17837. {
  17838. name = "segments",
  17839. type = "number",
  17840. description = "The number of segments in the cone.",
  17841. default = "64"
  17842. }
  17843. },
  17844. returns = {}
  17845. },
  17846. {
  17847. arguments = {
  17848. {
  17849. name = "transform",
  17850. type = "Mat4",
  17851. description = "The transform of the cone."
  17852. },
  17853. {
  17854. name = "segments",
  17855. type = "number",
  17856. description = "The number of segments in the cone.",
  17857. default = "64"
  17858. }
  17859. },
  17860. returns = {}
  17861. },
  17862. {
  17863. arguments = {
  17864. {
  17865. name = "p1",
  17866. type = "Vec3",
  17867. description = "The position of the base of the cone."
  17868. },
  17869. {
  17870. name = "p2",
  17871. type = "Vec3",
  17872. description = "The position of the tip of the cone."
  17873. },
  17874. {
  17875. name = "radius",
  17876. type = "number",
  17877. description = "The radius of the cone.",
  17878. default = "1"
  17879. },
  17880. {
  17881. name = "segments",
  17882. type = "number",
  17883. description = "The number of segments in the cone.",
  17884. default = "64"
  17885. }
  17886. },
  17887. returns = {}
  17888. }
  17889. }
  17890. },
  17891. {
  17892. name = "cube",
  17893. tag = "drawing",
  17894. summary = "Draw a cube.",
  17895. description = "Draws a cube.",
  17896. key = "Pass:cube",
  17897. module = "lovr.graphics",
  17898. notes = "The local origin is in the center of the cube.",
  17899. variants = {
  17900. {
  17901. arguments = {
  17902. {
  17903. name = "x",
  17904. type = "number",
  17905. description = "The x coordinate of the center of the cube.",
  17906. default = "0"
  17907. },
  17908. {
  17909. name = "y",
  17910. type = "number",
  17911. description = "The y coordinate of the center of the cube.",
  17912. default = "0"
  17913. },
  17914. {
  17915. name = "z",
  17916. type = "number",
  17917. description = "The z coordinate of the center of the cube.",
  17918. default = "0"
  17919. },
  17920. {
  17921. name = "size",
  17922. type = "number",
  17923. description = "The size of the cube.",
  17924. default = "1"
  17925. },
  17926. {
  17927. name = "angle",
  17928. type = "number",
  17929. description = "The rotation of the cube around its rotation axis, in radians.",
  17930. default = "0"
  17931. },
  17932. {
  17933. name = "ax",
  17934. type = "number",
  17935. description = "The x component of the axis of rotation.",
  17936. default = "0"
  17937. },
  17938. {
  17939. name = "ay",
  17940. type = "number",
  17941. description = "The y component of the axis of rotation.",
  17942. default = "1"
  17943. },
  17944. {
  17945. name = "az",
  17946. type = "number",
  17947. description = "The z component of the axis of rotation.",
  17948. default = "0"
  17949. },
  17950. {
  17951. name = "style",
  17952. type = "DrawStyle",
  17953. description = "Whether the cube should be drawn filled or outlined.",
  17954. default = "'fill'"
  17955. }
  17956. },
  17957. returns = {}
  17958. },
  17959. {
  17960. arguments = {
  17961. {
  17962. name = "position",
  17963. type = "Vec3",
  17964. description = "The position of the cube."
  17965. },
  17966. {
  17967. name = "size",
  17968. type = "number",
  17969. description = "The size of the cube.",
  17970. default = "1"
  17971. },
  17972. {
  17973. name = "orientation",
  17974. type = "Quat",
  17975. description = "The orientation of the cube."
  17976. },
  17977. {
  17978. name = "style",
  17979. type = "DrawStyle",
  17980. description = "Whether the cube should be drawn filled or outlined.",
  17981. default = "'fill'"
  17982. }
  17983. },
  17984. returns = {}
  17985. },
  17986. {
  17987. arguments = {
  17988. {
  17989. name = "transform",
  17990. type = "Mat4",
  17991. description = "The transform of the cube."
  17992. },
  17993. {
  17994. name = "style",
  17995. type = "DrawStyle",
  17996. description = "Whether the cube should be drawn filled or outlined.",
  17997. default = "'fill'"
  17998. }
  17999. },
  18000. returns = {}
  18001. }
  18002. }
  18003. },
  18004. {
  18005. name = "cylinder",
  18006. tag = "drawing",
  18007. summary = "Draw a cylinder.",
  18008. description = "Draws a cylinder.",
  18009. key = "Pass:cylinder",
  18010. module = "lovr.graphics",
  18011. notes = "The local origin is in the center of the cylinder, and the length of the cylinder is along the z axis.",
  18012. variants = {
  18013. {
  18014. arguments = {
  18015. {
  18016. name = "x",
  18017. type = "number",
  18018. description = "The x coordinate of the center of the cylinder.",
  18019. default = "0"
  18020. },
  18021. {
  18022. name = "y",
  18023. type = "number",
  18024. description = "The y coordinate of the center of the cylinder.",
  18025. default = "0"
  18026. },
  18027. {
  18028. name = "z",
  18029. type = "number",
  18030. description = "The z coordinate of the center of the cylinder.",
  18031. default = "0"
  18032. },
  18033. {
  18034. name = "radius",
  18035. type = "number",
  18036. description = "The radius of the cylinder.",
  18037. default = "1"
  18038. },
  18039. {
  18040. name = "length",
  18041. type = "number",
  18042. description = "The length of the cylinder.",
  18043. default = "1"
  18044. },
  18045. {
  18046. name = "angle",
  18047. type = "number",
  18048. description = "The rotation of the cylinder around its rotation axis, in radians.",
  18049. default = "0"
  18050. },
  18051. {
  18052. name = "ax",
  18053. type = "number",
  18054. description = "The x component of the axis of rotation.",
  18055. default = "0"
  18056. },
  18057. {
  18058. name = "ay",
  18059. type = "number",
  18060. description = "The y component of the axis of rotation.",
  18061. default = "1"
  18062. },
  18063. {
  18064. name = "az",
  18065. type = "number",
  18066. description = "The z component of the axis of rotation.",
  18067. default = "0"
  18068. },
  18069. {
  18070. name = "capped",
  18071. type = "boolean",
  18072. description = "Whether the tops and bottoms of the cylinder should be rendered.",
  18073. default = "true"
  18074. },
  18075. {
  18076. name = "angle1",
  18077. type = "number",
  18078. description = "The angle of the beginning of the arc.",
  18079. default = "0"
  18080. },
  18081. {
  18082. name = "angle2",
  18083. type = "number",
  18084. description = "angle of the end of the arc.",
  18085. default = "2 * math.pi"
  18086. },
  18087. {
  18088. name = "segments",
  18089. type = "number",
  18090. description = "The number of circular segments to render.",
  18091. default = "64"
  18092. }
  18093. },
  18094. returns = {}
  18095. },
  18096. {
  18097. arguments = {
  18098. {
  18099. name = "position",
  18100. type = "Vec3",
  18101. description = "The position of the center of the cylinder."
  18102. },
  18103. {
  18104. name = "radius",
  18105. type = "number",
  18106. description = "The radius of the cylinder.",
  18107. default = "1"
  18108. },
  18109. {
  18110. name = "length",
  18111. type = "number",
  18112. description = "The length of the cylinder.",
  18113. default = "1"
  18114. },
  18115. {
  18116. name = "orientation",
  18117. type = "Quat",
  18118. description = "The orientation of the cylinder."
  18119. },
  18120. {
  18121. name = "capped",
  18122. type = "boolean",
  18123. description = "Whether the tops and bottoms of the cylinder should be rendered.",
  18124. default = "true"
  18125. },
  18126. {
  18127. name = "angle1",
  18128. type = "number",
  18129. description = "The angle of the beginning of the arc.",
  18130. default = "0"
  18131. },
  18132. {
  18133. name = "angle2",
  18134. type = "number",
  18135. description = "angle of the end of the arc.",
  18136. default = "2 * math.pi"
  18137. },
  18138. {
  18139. name = "segments",
  18140. type = "number",
  18141. description = "The number of circular segments to render.",
  18142. default = "64"
  18143. }
  18144. },
  18145. returns = {}
  18146. },
  18147. {
  18148. arguments = {
  18149. {
  18150. name = "transform",
  18151. type = "Mat4",
  18152. description = "The transform of the cylinder."
  18153. },
  18154. {
  18155. name = "capped",
  18156. type = "boolean",
  18157. description = "Whether the tops and bottoms of the cylinder should be rendered.",
  18158. default = "true"
  18159. },
  18160. {
  18161. name = "angle1",
  18162. type = "number",
  18163. description = "The angle of the beginning of the arc.",
  18164. default = "0"
  18165. },
  18166. {
  18167. name = "angle2",
  18168. type = "number",
  18169. description = "angle of the end of the arc.",
  18170. default = "2 * math.pi"
  18171. },
  18172. {
  18173. name = "segments",
  18174. type = "number",
  18175. description = "The number of circular segments to render.",
  18176. default = "64"
  18177. }
  18178. },
  18179. returns = {}
  18180. },
  18181. {
  18182. arguments = {
  18183. {
  18184. name = "p1",
  18185. type = "Vec3",
  18186. description = "The starting point of the cylinder."
  18187. },
  18188. {
  18189. name = "p2",
  18190. type = "Vec3",
  18191. description = "The ending point of the cylinder."
  18192. },
  18193. {
  18194. name = "radius",
  18195. type = "number",
  18196. description = "The radius of the cylinder.",
  18197. default = "1"
  18198. },
  18199. {
  18200. name = "capped",
  18201. type = "boolean",
  18202. description = "Whether the tops and bottoms of the cylinder should be rendered.",
  18203. default = "true"
  18204. },
  18205. {
  18206. name = "angle1",
  18207. type = "number",
  18208. description = "The angle of the beginning of the arc.",
  18209. default = "0"
  18210. },
  18211. {
  18212. name = "angle2",
  18213. type = "number",
  18214. description = "angle of the end of the arc.",
  18215. default = "2 * math.pi"
  18216. },
  18217. {
  18218. name = "segments",
  18219. type = "number",
  18220. description = "The number of circular segments to render.",
  18221. default = "64"
  18222. }
  18223. },
  18224. returns = {}
  18225. }
  18226. }
  18227. },
  18228. {
  18229. name = "draw",
  18230. tag = "drawing",
  18231. summary = "Draw a Model, Mesh, or Texture.",
  18232. description = "Draws a `Model`, `Mesh`, or `Texture`.",
  18233. key = "Pass:draw",
  18234. module = "lovr.graphics",
  18235. notes = "`Model:getMesh` can be used to draw individual meshes of a model.\n\nTextures ignore the `instances` parameter.\n\nWhen drawing a Texture, the plane will be 1 meter wide at 1.0 scale and the height will be adjusted based on the Texture's aspect ratio.",
  18236. variants = {
  18237. {
  18238. arguments = {
  18239. {
  18240. name = "object",
  18241. type = "*",
  18242. description = "The Model, Mesh, or Texture to draw."
  18243. },
  18244. {
  18245. name = "x",
  18246. type = "number",
  18247. description = "The x coordinate to draw the object at.",
  18248. default = "0"
  18249. },
  18250. {
  18251. name = "y",
  18252. type = "number",
  18253. description = "The y coordinate to draw the object at.",
  18254. default = "0"
  18255. },
  18256. {
  18257. name = "z",
  18258. type = "number",
  18259. description = "The z coordinate to draw the object at.",
  18260. default = "0"
  18261. },
  18262. {
  18263. name = "scale",
  18264. type = "number",
  18265. description = "The scale of the object.",
  18266. default = "1"
  18267. },
  18268. {
  18269. name = "angle",
  18270. type = "number",
  18271. description = "The rotation of the object around its rotation axis, in radians.",
  18272. default = "0"
  18273. },
  18274. {
  18275. name = "ax",
  18276. type = "number",
  18277. description = "The x component of the axis of rotation.",
  18278. default = "0"
  18279. },
  18280. {
  18281. name = "ay",
  18282. type = "number",
  18283. description = "The y component of the axis of rotation.",
  18284. default = "1"
  18285. },
  18286. {
  18287. name = "az",
  18288. type = "number",
  18289. description = "The z component of the axis of rotation.",
  18290. default = "0"
  18291. },
  18292. {
  18293. name = "instances",
  18294. type = "number",
  18295. description = "The number of instances to draw.",
  18296. default = "1"
  18297. }
  18298. },
  18299. returns = {}
  18300. },
  18301. {
  18302. arguments = {
  18303. {
  18304. name = "object",
  18305. type = "*",
  18306. description = "The Model, Mesh, or Texture to draw."
  18307. },
  18308. {
  18309. name = "position",
  18310. type = "Vec3",
  18311. description = "The position to draw the object at."
  18312. },
  18313. {
  18314. name = "scale",
  18315. type = "number",
  18316. description = "The scale of the object.",
  18317. default = "1"
  18318. },
  18319. {
  18320. name = "orientation",
  18321. type = "Quat",
  18322. description = "The orientation of the object."
  18323. },
  18324. {
  18325. name = "instances",
  18326. type = "number",
  18327. description = "The number of instances to draw.",
  18328. default = "1"
  18329. }
  18330. },
  18331. returns = {}
  18332. },
  18333. {
  18334. arguments = {
  18335. {
  18336. name = "object",
  18337. type = "*",
  18338. description = "The Model, Mesh, or Texture to draw."
  18339. },
  18340. {
  18341. name = "transform",
  18342. type = "Mat4",
  18343. description = "The transform of the object."
  18344. },
  18345. {
  18346. name = "instances",
  18347. type = "number",
  18348. description = "The number of instances to draw.",
  18349. default = "1"
  18350. }
  18351. },
  18352. returns = {}
  18353. }
  18354. }
  18355. },
  18356. {
  18357. name = "fill",
  18358. tag = "drawing",
  18359. summary = "Draw a fullscreen triangle.",
  18360. description = "Draws a fullscreen triangle. The `fill` shader is used, which stretches the triangle across the screen.",
  18361. key = "Pass:fill",
  18362. module = "lovr.graphics",
  18363. notes = "This function has some special behavior for array textures:\n\n- Filling a single-layer texture to a multi-layer canvas will mirror the texture to all layers,\n just like regular drawing.\n- Filling a 2-layer texture to a mono canvas will render the 2 layers side-by-side.\n- Filling a multi-layer texture to a multi-layer canvas will do a layer-by-layer fill (the layer\n counts must match).",
  18364. variants = {
  18365. {
  18366. arguments = {
  18367. {
  18368. name = "texture",
  18369. type = "Texture",
  18370. description = "The texture to fill. If nil, the texture from the active material is used."
  18371. }
  18372. },
  18373. returns = {}
  18374. },
  18375. {
  18376. arguments = {},
  18377. returns = {}
  18378. }
  18379. }
  18380. },
  18381. {
  18382. name = "finishTally",
  18383. tag = "tally",
  18384. summary = "Finish a tally.",
  18385. description = "Finishes a tally that was previously started with `Pass:beginTally`. This will stop counting the number of pixels affected by draws.\n\nThe results for all the tallies in the pass can be copied to a `Buffer` when the Pass finishes by setting a buffer with `Pass:setTallyBuffer`.",
  18386. key = "Pass:finishTally",
  18387. module = "lovr.graphics",
  18388. notes = "There is currently a maximum of 256 tallies per pass.\n\nIf no tally is active, this function will error.",
  18389. related = {
  18390. "Pass:beginTally"
  18391. },
  18392. variants = {
  18393. {
  18394. arguments = {},
  18395. returns = {
  18396. {
  18397. name = "index",
  18398. type = "number",
  18399. description = "The index of the tally that was finished."
  18400. }
  18401. }
  18402. }
  18403. }
  18404. },
  18405. {
  18406. name = "getCanvas",
  18407. tag = "canvas",
  18408. summary = "Get the Pass's canvas.",
  18409. description = "Returns the Pass's canvas, or `nil` if the Pass doesn't have a canvas. The canvas is a set of textures that the Pass will draw to when it's submitted.",
  18410. key = "Pass:getCanvas",
  18411. module = "lovr.graphics",
  18412. notes = "If the Pass has multiple color textures, a fragment shader should be used to write a different color to each texture. Here's an example that writes red to the first texture and blue to the second texture:\n\n // Declare an output variable for the second texture\n layout(location = 1) out vec4 secondColor;\n\n vec4 lovrmain() {\n secondColor = vec4(0, 0, 1, 1);\n return vec4(1, 0, 0, 1);\n }",
  18413. related = {
  18414. "Pass:getClear",
  18415. "Pass:setClear",
  18416. "Pass:getWidth",
  18417. "Pass:getHeight",
  18418. "Pass:getDimensions"
  18419. },
  18420. variants = {
  18421. {
  18422. arguments = {},
  18423. returns = {
  18424. {
  18425. name = "canvas",
  18426. type = "table",
  18427. description = "The canvas. Numeric keys will contain the color Textures, along with the following keys:",
  18428. table = {
  18429. {
  18430. name = "depth",
  18431. type = "*",
  18432. description = "A `Texture` or `TextureFormat` with the depth buffer."
  18433. },
  18434. {
  18435. name = "samples",
  18436. type = "number",
  18437. description = "The number of multisamples used for antialiasing (either 1 or 4)."
  18438. }
  18439. }
  18440. }
  18441. }
  18442. },
  18443. {
  18444. description = "This function returns nil when a canvas hasn't been set.",
  18445. arguments = {},
  18446. returns = {}
  18447. }
  18448. }
  18449. },
  18450. {
  18451. name = "getClear",
  18452. tag = "canvas",
  18453. summary = "Return the clear values of the Pass.",
  18454. description = "Returns the clear values of the pass.",
  18455. key = "Pass:getClear",
  18456. module = "lovr.graphics",
  18457. notes = "The default clear color is transparent black.",
  18458. related = {
  18459. "Pass:getCanvas"
  18460. },
  18461. variants = {
  18462. {
  18463. arguments = {},
  18464. returns = {
  18465. {
  18466. name = "clears",
  18467. type = "table",
  18468. description = "The clear values for the pass. Each color texture's clear value is stored at its index, as either a 4-number rgba table or a boolean. If the pass has a depth texture, there will also be a `depth` key with its clear value as a number or boolean."
  18469. }
  18470. }
  18471. }
  18472. }
  18473. },
  18474. {
  18475. name = "getDimensions",
  18476. tag = "canvas",
  18477. summary = "Get the dimensions of the Pass's canvas.",
  18478. description = "Returns the dimensions of the textures of the Pass's canvas, in pixels.",
  18479. key = "Pass:getDimensions",
  18480. module = "lovr.graphics",
  18481. notes = "If the pass doesn't have a canvas, this function returns zeros.",
  18482. related = {
  18483. "Pass:getWidth",
  18484. "Pass:getHeight",
  18485. "Pass:getViewCount",
  18486. "Pass:getCanvas",
  18487. "Pass:setCanvas",
  18488. "lovr.system.getWindowDimensions",
  18489. "lovr.headset.getDisplayDimensions"
  18490. },
  18491. variants = {
  18492. {
  18493. arguments = {},
  18494. returns = {
  18495. {
  18496. name = "width",
  18497. type = "number",
  18498. description = "The texture width."
  18499. },
  18500. {
  18501. name = "height",
  18502. type = "number",
  18503. description = "The texture height."
  18504. }
  18505. }
  18506. }
  18507. }
  18508. },
  18509. {
  18510. name = "getHeight",
  18511. tag = "canvas",
  18512. summary = "Get the height of the Pass's canvas.",
  18513. description = "Returns the height of the textures of the Pass's canvas, in pixels.",
  18514. key = "Pass:getHeight",
  18515. module = "lovr.graphics",
  18516. notes = "If the pass doesn't have a canvas, this function returns zero.",
  18517. related = {
  18518. "Pass:getWidth",
  18519. "Pass:getDimensions",
  18520. "Pass:getViewCount",
  18521. "Pass:getCanvas",
  18522. "Pass:setCanvas",
  18523. "lovr.system.getWindowHeight",
  18524. "lovr.headset.getDisplayHeight"
  18525. },
  18526. variants = {
  18527. {
  18528. arguments = {},
  18529. returns = {
  18530. {
  18531. name = "height",
  18532. type = "number",
  18533. description = "The texture height."
  18534. }
  18535. }
  18536. }
  18537. }
  18538. },
  18539. {
  18540. name = "getProjection",
  18541. tag = "camera",
  18542. summary = "Get the field of view.",
  18543. description = "Returns the projection for a single view.",
  18544. key = "Pass:getProjection",
  18545. module = "lovr.graphics",
  18546. related = {
  18547. "lovr.headset.getViewAngles",
  18548. "lovr.headset.getViewCount",
  18549. "Pass:getViewPose",
  18550. "Pass:setViewPose"
  18551. },
  18552. variants = {
  18553. {
  18554. arguments = {
  18555. {
  18556. name = "view",
  18557. type = "number",
  18558. description = "The view index."
  18559. }
  18560. },
  18561. returns = {
  18562. {
  18563. name = "left",
  18564. type = "number",
  18565. description = "The left field of view angle, in radians."
  18566. },
  18567. {
  18568. name = "right",
  18569. type = "number",
  18570. description = "The right field of view angle, in radians."
  18571. },
  18572. {
  18573. name = "up",
  18574. type = "number",
  18575. description = "The top field of view angle, in radians."
  18576. },
  18577. {
  18578. name = "down",
  18579. type = "number",
  18580. description = "The bottom field of view angle, in radians."
  18581. }
  18582. }
  18583. },
  18584. {
  18585. arguments = {
  18586. {
  18587. name = "view",
  18588. type = "number",
  18589. description = "The view index."
  18590. },
  18591. {
  18592. name = "matrix",
  18593. type = "Mat4",
  18594. description = "The matrix to fill with the projection."
  18595. }
  18596. },
  18597. returns = {
  18598. {
  18599. name = "matrix",
  18600. type = "Mat4",
  18601. description = "The matrix containing the projection."
  18602. }
  18603. }
  18604. }
  18605. }
  18606. },
  18607. {
  18608. name = "getSampleCount",
  18609. tag = "canvas",
  18610. summary = "Get the antialiasing setting of a render pass.",
  18611. description = "Returns the antialiasing setting of a render pass.",
  18612. key = "Pass:getSampleCount",
  18613. module = "lovr.graphics",
  18614. deprecated = true,
  18615. variants = {
  18616. {
  18617. arguments = {},
  18618. returns = {
  18619. {
  18620. name = "samples",
  18621. type = "number",
  18622. description = "The number of samples used for rendering. Currently, will be 1 or 4."
  18623. }
  18624. }
  18625. }
  18626. }
  18627. },
  18628. {
  18629. name = "getScissor",
  18630. tag = "camera",
  18631. summary = "Get the scissor rectangle.",
  18632. description = "Returns the scissor rectangle, or `nil` if no scissor is set. Any pixels outside the scissor rectangle will not be drawn.",
  18633. key = "Pass:getScissor",
  18634. module = "lovr.graphics",
  18635. notes = "The scissor will apply to all draws in a Pass when the pass is submitted.\n\nThe default scissor rectangle covers the entire dimensions of the render pass textures.",
  18636. related = {
  18637. "Pass:getViewport",
  18638. "Pass:setViewport"
  18639. },
  18640. variants = {
  18641. {
  18642. arguments = {},
  18643. returns = {
  18644. {
  18645. name = "x",
  18646. type = "number",
  18647. description = "The x coordinate of the upper-left corner of the scissor rectangle."
  18648. },
  18649. {
  18650. name = "y",
  18651. type = "number",
  18652. description = "The y coordinate of the upper-left corner of the scissor rectangle."
  18653. },
  18654. {
  18655. name = "w",
  18656. type = "number",
  18657. description = "The width of the scissor rectangle."
  18658. },
  18659. {
  18660. name = "h",
  18661. type = "number",
  18662. description = "The height of the scissor rectangle."
  18663. }
  18664. }
  18665. }
  18666. }
  18667. },
  18668. {
  18669. name = "getStats",
  18670. tag = "pass-misc",
  18671. summary = "Get statistics for the Pass.",
  18672. description = "Returns statistics for the Pass.",
  18673. key = "Pass:getStats",
  18674. module = "lovr.graphics",
  18675. examples = {
  18676. {
  18677. description = "See how long it takes the GPU to render a cube.",
  18678. code = "lovr.graphics.setTimingEnabled(true)\n\nfunction lovr.draw(pass)\n pass:cube(0, 1.7, -1, .5, lovr.timer.getTime() * .2, 0, 1, 0)\n\n local stats = pass:getStats()\n print(('Rendering a cube takes %f microseconds'):format(stats.gpuTime * 1e6))\nend"
  18679. }
  18680. },
  18681. related = {
  18682. "lovr.graphics.isTimingEnabled",
  18683. "lovr.graphics.setTimingEnabled",
  18684. "Pass:setViewCull"
  18685. },
  18686. variants = {
  18687. {
  18688. arguments = {},
  18689. returns = {
  18690. {
  18691. name = "stats",
  18692. type = "table",
  18693. description = "A table with statistics.",
  18694. table = {
  18695. {
  18696. name = "draws",
  18697. type = "number",
  18698. description = "The number of draws added to the Pass."
  18699. },
  18700. {
  18701. name = "computes",
  18702. type = "number",
  18703. description = "The number of compute calls added to the Pass."
  18704. },
  18705. {
  18706. name = "drawsCulled",
  18707. type = "number",
  18708. description = "The number of draw calls that were culled the last time the Pass was submitted."
  18709. },
  18710. {
  18711. name = "cpuMemoryReserved",
  18712. type = "number",
  18713. description = "The amount of CPU memory the Pass has reserved, in bytes."
  18714. },
  18715. {
  18716. name = "cpuMemoryUsed",
  18717. type = "number",
  18718. description = "The amount of CPU memory the Pass is currently using, in bytes."
  18719. },
  18720. {
  18721. name = "submitTime",
  18722. type = "number",
  18723. description = "The amount of time taken on the CPU to submit the Pass the last time it was submitted, in seconds. Only updates when timing stats have been enabled with `lovr.graphics.setTimingEnabled`, and has a few frames of delay."
  18724. },
  18725. {
  18726. name = "gpuTime",
  18727. type = "number",
  18728. description = "The amount of time taken on the GPU to process the Pass, in seconds. Only updates when timing stats have been enabled with `lovr.graphics.setTimingEnabled`, and has a few frames of delay."
  18729. }
  18730. }
  18731. }
  18732. }
  18733. }
  18734. }
  18735. },
  18736. {
  18737. name = "getTallyBuffer",
  18738. tag = "tally",
  18739. summary = "Get the Buffer that tally results will be written to.",
  18740. description = "Returns the Buffer that tally results will be written to. Each time the render pass finishes, the results of all the tallies will be copied to the Buffer at the specified offset. The buffer can be used in a later pass in a compute shader, or the data in the buffer can be read back using e.g. `Buffer:newReadback`.\n\nIf no buffer has been set, this function will return `nil`.",
  18741. key = "Pass:getTallyBuffer",
  18742. module = "lovr.graphics",
  18743. related = {
  18744. "Pass:beginTally",
  18745. "Pass:finishTally"
  18746. },
  18747. variants = {
  18748. {
  18749. arguments = {},
  18750. returns = {
  18751. {
  18752. name = "buffer",
  18753. type = "Buffer",
  18754. description = "The buffer."
  18755. },
  18756. {
  18757. name = "offset",
  18758. type = "number",
  18759. description = "An offset in the buffer where results will be written."
  18760. }
  18761. }
  18762. }
  18763. }
  18764. },
  18765. {
  18766. name = "getTarget",
  18767. tag = "canvas",
  18768. summary = "Get the textures a render pass is rendering to.",
  18769. description = "Returns the textures a render pass is rendering to.",
  18770. key = "Pass:getTarget",
  18771. module = "lovr.graphics",
  18772. deprecated = true,
  18773. related = {
  18774. "Pass:getClear"
  18775. },
  18776. variants = {
  18777. {
  18778. arguments = {},
  18779. returns = {
  18780. {
  18781. name = "target",
  18782. type = "table",
  18783. description = "A table of the color textures targeted by the pass, with an additional `depth` key if the pass has a depth texture."
  18784. }
  18785. }
  18786. }
  18787. }
  18788. },
  18789. {
  18790. name = "getType",
  18791. tag = "pass-misc",
  18792. summary = "Get the type of the Pass.",
  18793. description = "Returns the type of the pass (render, compute, or transfer). The type restricts what kinds of functions can be called on the pass.",
  18794. key = "Pass:getType",
  18795. module = "lovr.graphics",
  18796. deprecated = true,
  18797. variants = {
  18798. {
  18799. arguments = {},
  18800. returns = {
  18801. {
  18802. name = "type",
  18803. type = "PassType",
  18804. description = "The type of the Pass."
  18805. }
  18806. }
  18807. }
  18808. }
  18809. },
  18810. {
  18811. name = "getViewCount",
  18812. tag = "camera",
  18813. summary = "Returns the view count of a render pass.",
  18814. description = "Returns the view count of a render pass. This is the layer count of the textures it is rendering to.",
  18815. key = "Pass:getViewCount",
  18816. module = "lovr.graphics",
  18817. notes = "A render pass has one \"camera\" for each view. Whenever something is drawn, it is broadcast to each view (layer) of each texture, using the corresponding camera.",
  18818. related = {
  18819. "Pass:getViewPose",
  18820. "Pass:setViewPose",
  18821. "Pass:getProjection",
  18822. "Pass:setProjection",
  18823. "lovr.headset.getViewCount"
  18824. },
  18825. variants = {
  18826. {
  18827. arguments = {},
  18828. returns = {
  18829. {
  18830. name = "views",
  18831. type = "number",
  18832. description = "The view count."
  18833. }
  18834. }
  18835. }
  18836. }
  18837. },
  18838. {
  18839. name = "getViewPose",
  18840. tag = "camera",
  18841. summary = "Get the camera pose.",
  18842. description = "Get the pose of a single view.",
  18843. key = "Pass:getViewPose",
  18844. module = "lovr.graphics",
  18845. related = {
  18846. "lovr.headset.getViewPose",
  18847. "lovr.headset.getViewCount",
  18848. "Pass:getProjection",
  18849. "Pass:setProjection"
  18850. },
  18851. variants = {
  18852. {
  18853. arguments = {
  18854. {
  18855. name = "view",
  18856. type = "number",
  18857. description = "The view index."
  18858. }
  18859. },
  18860. returns = {
  18861. {
  18862. name = "x",
  18863. type = "number",
  18864. description = "The x position of the viewer, in meters."
  18865. },
  18866. {
  18867. name = "y",
  18868. type = "number",
  18869. description = "The y position of the viewer, in meters."
  18870. },
  18871. {
  18872. name = "z",
  18873. type = "number",
  18874. description = "The z position of the viewer, in meters."
  18875. },
  18876. {
  18877. name = "angle",
  18878. type = "number",
  18879. description = "The number of radians the viewer is rotated around its axis of rotation."
  18880. },
  18881. {
  18882. name = "ax",
  18883. type = "number",
  18884. description = "The x component of the axis of rotation."
  18885. },
  18886. {
  18887. name = "ay",
  18888. type = "number",
  18889. description = "The y component of the axis of rotation."
  18890. },
  18891. {
  18892. name = "az",
  18893. type = "number",
  18894. description = "The z component of the axis of rotation."
  18895. }
  18896. }
  18897. },
  18898. {
  18899. arguments = {
  18900. {
  18901. name = "view",
  18902. type = "number",
  18903. description = "The view index."
  18904. },
  18905. {
  18906. name = "matrix",
  18907. type = "Mat4",
  18908. description = "The matrix to fill with the view pose."
  18909. },
  18910. {
  18911. name = "invert",
  18912. type = "boolean",
  18913. description = "Whether the matrix should be inverted."
  18914. }
  18915. },
  18916. returns = {
  18917. {
  18918. name = "matrix",
  18919. type = "Mat4",
  18920. description = "The matrix containing the view pose."
  18921. }
  18922. }
  18923. }
  18924. }
  18925. },
  18926. {
  18927. name = "getViewport",
  18928. tag = "camera",
  18929. summary = "Get the viewport.",
  18930. description = "Returns the viewport, or `nil` if no viewport is set. Everything rendered will get mapped to the rectangle defined by the viewport. More specifically, this defines the transformation from normalized device coordinates to pixel coordinates.",
  18931. key = "Pass:getViewport",
  18932. module = "lovr.graphics",
  18933. notes = "The viewport will apply to all draws in a Pass when the pass is submitted.\n\nThe viewport rectangle can use floating point numbers.\n\nA negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically.\n\nThe default viewport extends from `(0, 0)` to the dimensions of the target textures, with min depth and max depth respectively set to 0 and 1.",
  18934. related = {
  18935. "Pass:getScissor",
  18936. "Pass:setScissor",
  18937. "Pass:getDimensions"
  18938. },
  18939. variants = {
  18940. {
  18941. arguments = {},
  18942. returns = {
  18943. {
  18944. name = "x",
  18945. type = "number",
  18946. description = "The x coordinate of the upper-left corner of the viewport."
  18947. },
  18948. {
  18949. name = "y",
  18950. type = "number",
  18951. description = "The y coordinate of the upper-left corner of the viewport."
  18952. },
  18953. {
  18954. name = "w",
  18955. type = "number",
  18956. description = "The width of the viewport."
  18957. },
  18958. {
  18959. name = "h",
  18960. type = "number",
  18961. description = "The height of the viewport. May be negative."
  18962. },
  18963. {
  18964. name = "dmin",
  18965. type = "number",
  18966. description = "The min component of the depth range.",
  18967. default = "0.0"
  18968. },
  18969. {
  18970. name = "dmax",
  18971. type = "number",
  18972. description = "The max component of the depth range.",
  18973. default = "1.0"
  18974. }
  18975. }
  18976. }
  18977. }
  18978. },
  18979. {
  18980. name = "getWidth",
  18981. tag = "canvas",
  18982. summary = "Get the width of the Pass's canvas.",
  18983. description = "Returns the width of the textures of the Pass's canvas, in pixels.",
  18984. key = "Pass:getWidth",
  18985. module = "lovr.graphics",
  18986. notes = "If the pass doesn't have a canvas, this function returns zero.",
  18987. related = {
  18988. "Pass:getHeight",
  18989. "Pass:getDimensions",
  18990. "Pass:getViewCount",
  18991. "Pass:getCanvas",
  18992. "Pass:setCanvas",
  18993. "lovr.system.getWindowWidth",
  18994. "lovr.headset.getDisplayWidth"
  18995. },
  18996. variants = {
  18997. {
  18998. arguments = {},
  18999. returns = {
  19000. {
  19001. name = "width",
  19002. type = "number",
  19003. description = "The texture width."
  19004. }
  19005. }
  19006. }
  19007. }
  19008. },
  19009. {
  19010. name = "line",
  19011. tag = "drawing",
  19012. summary = "Draw a line.",
  19013. description = "Draws a line between points. `Pass:mesh` can also be used to draw line segments using the `line` `DrawMode`.",
  19014. key = "Pass:line",
  19015. module = "lovr.graphics",
  19016. notes = "There is currently no way to increase line thickness.",
  19017. variants = {
  19018. {
  19019. arguments = {
  19020. {
  19021. name = "x1",
  19022. type = "number",
  19023. description = "The x coordinate of the first point."
  19024. },
  19025. {
  19026. name = "y1",
  19027. type = "number",
  19028. description = "The y coordinate of the first point."
  19029. },
  19030. {
  19031. name = "z1",
  19032. type = "number",
  19033. description = "The z coordinate of the first point."
  19034. },
  19035. {
  19036. name = "x2",
  19037. type = "number",
  19038. description = "The x coordinate of the next point."
  19039. },
  19040. {
  19041. name = "y2",
  19042. type = "number",
  19043. description = "The y coordinate of the next point."
  19044. },
  19045. {
  19046. name = "z2",
  19047. type = "number",
  19048. description = "The z coordinate of the next point."
  19049. },
  19050. {
  19051. name = "...",
  19052. type = "*",
  19053. description = "More points to add to the line."
  19054. }
  19055. },
  19056. returns = {}
  19057. },
  19058. {
  19059. arguments = {
  19060. {
  19061. name = "t",
  19062. type = "table",
  19063. description = "A table of numbers or `Vec3` objects (not a mix) representing points of the line."
  19064. }
  19065. },
  19066. returns = {}
  19067. },
  19068. {
  19069. arguments = {
  19070. {
  19071. name = "v1",
  19072. type = "Vec3",
  19073. description = "A vector containing the position of the first point of the line."
  19074. },
  19075. {
  19076. name = "v2",
  19077. type = "Vec3",
  19078. description = "A vector containing the position of the next point on the line."
  19079. },
  19080. {
  19081. name = "...",
  19082. type = "*",
  19083. description = "More points to add to the line."
  19084. }
  19085. },
  19086. returns = {}
  19087. }
  19088. }
  19089. },
  19090. {
  19091. name = "mesh",
  19092. tag = "drawing",
  19093. summary = "Draw a mesh.",
  19094. description = "Draws a mesh.",
  19095. key = "Pass:mesh",
  19096. module = "lovr.graphics",
  19097. examples = {
  19098. {
  19099. code = "function lovr.load()\n local vertices = {\n vec3( 0, .4, 0), vec4(1, 0, 0, 1),\n vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),\n vec3( .5, -.4, 0), vec4(0, 0, 1, 1)\n }\n\n local format = {\n { name = 'VertexPosition', type = 'vec3' },\n { name = 'VertexColor', type = 'vec4' }\n }\n\n triangle = lovr.graphics.newBuffer(format, vertices)\nend\n\nfunction lovr.draw(pass)\n pass:mesh(triangle, 0, 1.7, -1)\nend"
  19100. }
  19101. },
  19102. notes = "The index buffer defines the order the vertices are drawn in. It can be used to reorder, reuse, or omit vertices from the mesh.\n\nWhen drawing without a vertex buffer, the `VertexIndex` variable can be used in shaders to compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture` resources.\n\nThe active `DrawMode` controls whether the vertices are drawn as points, lines, or triangles.\n\nThe active `Material` is applied to the mesh.",
  19103. variants = {
  19104. {
  19105. description = "Draw a range of vertices from a Buffer, using numbers for the transform.",
  19106. arguments = {
  19107. {
  19108. name = "vertices",
  19109. type = "Buffer",
  19110. description = "The buffer containing the vertices to draw.",
  19111. default = "nil"
  19112. },
  19113. {
  19114. name = "x",
  19115. type = "number",
  19116. description = "The x coordinate of the position to draw the mesh at.",
  19117. default = "0"
  19118. },
  19119. {
  19120. name = "y",
  19121. type = "number",
  19122. description = "The y coordinate of the position to draw the mesh at.",
  19123. default = "0"
  19124. },
  19125. {
  19126. name = "z",
  19127. type = "number",
  19128. description = "The z coordinate of the position to draw the mesh at.",
  19129. default = "0"
  19130. },
  19131. {
  19132. name = "scale",
  19133. type = "number",
  19134. description = "The scale of the mesh.",
  19135. default = "1"
  19136. },
  19137. {
  19138. name = "angle",
  19139. type = "number",
  19140. description = "The number of radians the mesh is rotated around its rotational axis.",
  19141. default = "0"
  19142. },
  19143. {
  19144. name = "ax",
  19145. type = "number",
  19146. description = "The x component of the axis of rotation.",
  19147. default = "0"
  19148. },
  19149. {
  19150. name = "ay",
  19151. type = "number",
  19152. description = "The y component of the axis of rotation.",
  19153. default = "1"
  19154. },
  19155. {
  19156. name = "az",
  19157. type = "number",
  19158. description = "The z component of the axis of rotation.",
  19159. default = "0"
  19160. },
  19161. {
  19162. name = "start",
  19163. type = "number",
  19164. description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
  19165. default = "1"
  19166. },
  19167. {
  19168. name = "count",
  19169. type = "number",
  19170. description = "The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`).",
  19171. default = "nil"
  19172. },
  19173. {
  19174. name = "instances",
  19175. type = "number",
  19176. description = "The number of copies of the mesh to render.",
  19177. default = "1"
  19178. }
  19179. },
  19180. returns = {}
  19181. },
  19182. {
  19183. description = "Draw a range of vertices from a Buffer, using vector types for the transform.",
  19184. arguments = {
  19185. {
  19186. name = "vertices",
  19187. type = "Buffer",
  19188. description = "The buffer containing the vertices to draw.",
  19189. default = "nil"
  19190. },
  19191. {
  19192. name = "position",
  19193. type = "Vec3",
  19194. description = "The position to draw the mesh at."
  19195. },
  19196. {
  19197. name = "scales",
  19198. type = "Vec3",
  19199. description = "The scale of the mesh."
  19200. },
  19201. {
  19202. name = "orientation",
  19203. type = "Quat",
  19204. description = "The orientation of the mesh."
  19205. },
  19206. {
  19207. name = "start",
  19208. type = "number",
  19209. description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
  19210. default = "1"
  19211. },
  19212. {
  19213. name = "count",
  19214. type = "number",
  19215. description = "The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`).",
  19216. default = "nil"
  19217. },
  19218. {
  19219. name = "instances",
  19220. type = "number",
  19221. description = "The number of copies of the mesh to render.",
  19222. default = "1"
  19223. }
  19224. },
  19225. returns = {}
  19226. },
  19227. {
  19228. description = "Draw a range of vertices from a Buffer, using a matrix for the transform.",
  19229. arguments = {
  19230. {
  19231. name = "vertices",
  19232. type = "Buffer",
  19233. description = "The buffer containing the vertices to draw.",
  19234. default = "nil"
  19235. },
  19236. {
  19237. name = "transform",
  19238. type = "Mat4",
  19239. description = "The transform to apply to the mesh."
  19240. },
  19241. {
  19242. name = "start",
  19243. type = "number",
  19244. description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
  19245. default = "1"
  19246. },
  19247. {
  19248. name = "count",
  19249. type = "number",
  19250. description = "The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`).",
  19251. default = "nil"
  19252. },
  19253. {
  19254. name = "instances",
  19255. type = "number",
  19256. description = "The number of copies of the mesh to render.",
  19257. default = "1"
  19258. }
  19259. },
  19260. returns = {}
  19261. },
  19262. {
  19263. description = "Draw a mesh using a vertex buffer and an index buffer, using numbers for the transform.",
  19264. arguments = {
  19265. {
  19266. name = "vertices",
  19267. type = "Buffer",
  19268. description = "The buffer containing the vertices to draw.",
  19269. default = "nil"
  19270. },
  19271. {
  19272. name = "indices",
  19273. type = "Buffer",
  19274. description = "The buffer containing the vertex indices to draw."
  19275. },
  19276. {
  19277. name = "x",
  19278. type = "number",
  19279. description = "The x coordinate of the position to draw the mesh at.",
  19280. default = "0"
  19281. },
  19282. {
  19283. name = "y",
  19284. type = "number",
  19285. description = "The y coordinate of the position to draw the mesh at.",
  19286. default = "0"
  19287. },
  19288. {
  19289. name = "z",
  19290. type = "number",
  19291. description = "The z coordinate of the position to draw the mesh at.",
  19292. default = "0"
  19293. },
  19294. {
  19295. name = "scale",
  19296. type = "number",
  19297. description = "The scale of the mesh.",
  19298. default = "1"
  19299. },
  19300. {
  19301. name = "angle",
  19302. type = "number",
  19303. description = "The number of radians the mesh is rotated around its rotational axis.",
  19304. default = "0"
  19305. },
  19306. {
  19307. name = "ax",
  19308. type = "number",
  19309. description = "The x component of the axis of rotation.",
  19310. default = "0"
  19311. },
  19312. {
  19313. name = "ay",
  19314. type = "number",
  19315. description = "The y component of the axis of rotation.",
  19316. default = "1"
  19317. },
  19318. {
  19319. name = "az",
  19320. type = "number",
  19321. description = "The z component of the axis of rotation.",
  19322. default = "0"
  19323. },
  19324. {
  19325. name = "start",
  19326. type = "number",
  19327. description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
  19328. default = "1"
  19329. },
  19330. {
  19331. name = "count",
  19332. type = "number",
  19333. description = "The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`).",
  19334. default = "nil"
  19335. },
  19336. {
  19337. name = "instances",
  19338. type = "number",
  19339. description = "The number of copies of the mesh to render.",
  19340. default = "1"
  19341. },
  19342. {
  19343. name = "base",
  19344. type = "number",
  19345. description = "A base offset to apply to vertex indices.",
  19346. default = "0"
  19347. }
  19348. },
  19349. returns = {}
  19350. },
  19351. {
  19352. description = "Draw a mesh using a vertex buffer and an index buffer, using vector types for the transform.",
  19353. arguments = {
  19354. {
  19355. name = "vertices",
  19356. type = "Buffer",
  19357. description = "The buffer containing the vertices to draw.",
  19358. default = "nil"
  19359. },
  19360. {
  19361. name = "indices",
  19362. type = "Buffer",
  19363. description = "The buffer containing the vertex indices to draw."
  19364. },
  19365. {
  19366. name = "position",
  19367. type = "Vec3",
  19368. description = "The position to draw the mesh at."
  19369. },
  19370. {
  19371. name = "scales",
  19372. type = "Vec3",
  19373. description = "The scale of the mesh."
  19374. },
  19375. {
  19376. name = "orientation",
  19377. type = "Quat",
  19378. description = "The orientation of the mesh."
  19379. },
  19380. {
  19381. name = "start",
  19382. type = "number",
  19383. description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
  19384. default = "1"
  19385. },
  19386. {
  19387. name = "count",
  19388. type = "number",
  19389. description = "The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`).",
  19390. default = "nil"
  19391. },
  19392. {
  19393. name = "instances",
  19394. type = "number",
  19395. description = "The number of copies of the mesh to render.",
  19396. default = "1"
  19397. },
  19398. {
  19399. name = "base",
  19400. type = "number",
  19401. description = "A base offset to apply to vertex indices.",
  19402. default = "0"
  19403. }
  19404. },
  19405. returns = {}
  19406. },
  19407. {
  19408. description = "Draw a mesh using a vertex buffer and an index buffer, using a matrix for the transform.",
  19409. arguments = {
  19410. {
  19411. name = "vertices",
  19412. type = "Buffer",
  19413. description = "The buffer containing the vertices to draw.",
  19414. default = "nil"
  19415. },
  19416. {
  19417. name = "indices",
  19418. type = "Buffer",
  19419. description = "The buffer containing the vertex indices to draw."
  19420. },
  19421. {
  19422. name = "transform",
  19423. type = "Mat4",
  19424. description = "The transform to apply to the mesh."
  19425. },
  19426. {
  19427. name = "start",
  19428. type = "number",
  19429. description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
  19430. default = "1"
  19431. },
  19432. {
  19433. name = "count",
  19434. type = "number",
  19435. description = "The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`).",
  19436. default = "nil"
  19437. },
  19438. {
  19439. name = "instances",
  19440. type = "number",
  19441. description = "The number of copies of the mesh to render.",
  19442. default = "1"
  19443. },
  19444. {
  19445. name = "base",
  19446. type = "number",
  19447. description = "A base offset to apply to vertex indices.",
  19448. default = "0"
  19449. }
  19450. },
  19451. returns = {}
  19452. },
  19453. {
  19454. description = "Perform indirect draws. `drawcount` meshes from the vertex and index buffer will be drawn, using parameters starting from `offset` bytes in the `draws` buffer.",
  19455. arguments = {
  19456. {
  19457. name = "vertices",
  19458. type = "Buffer",
  19459. description = "The buffer containing the vertices to draw.",
  19460. default = "nil"
  19461. },
  19462. {
  19463. name = "indices",
  19464. type = "Buffer",
  19465. description = "The buffer containing the vertex indices to draw."
  19466. },
  19467. {
  19468. name = "draws",
  19469. type = "Buffer",
  19470. description = "The buffer containing indirect draw commands."
  19471. },
  19472. {
  19473. name = "drawcount",
  19474. type = "number",
  19475. description = "The number of indirect draws to draw."
  19476. },
  19477. {
  19478. name = "offset",
  19479. type = "number",
  19480. description = "A byte offset into the draw buffer."
  19481. },
  19482. {
  19483. name = "stride",
  19484. type = "number",
  19485. description = "The number of bytes between consecutive elements in the draw buffer."
  19486. }
  19487. },
  19488. returns = {}
  19489. }
  19490. }
  19491. },
  19492. {
  19493. name = "origin",
  19494. tag = "transform",
  19495. summary = "Reset the transform to the origin.",
  19496. description = "Resets the transform back to the origin.",
  19497. key = "Pass:origin",
  19498. module = "lovr.graphics",
  19499. related = {
  19500. "Pass:translate",
  19501. "Pass:rotate",
  19502. "Pass:scale",
  19503. "Pass:transform",
  19504. "Pass:push",
  19505. "Pass:pop"
  19506. },
  19507. variants = {
  19508. {
  19509. arguments = {},
  19510. returns = {}
  19511. }
  19512. }
  19513. },
  19514. {
  19515. name = "plane",
  19516. tag = "drawing",
  19517. summary = "Draw a plane.",
  19518. description = "Draws a plane.",
  19519. key = "Pass:plane",
  19520. module = "lovr.graphics",
  19521. variants = {
  19522. {
  19523. arguments = {
  19524. {
  19525. name = "x",
  19526. type = "number",
  19527. description = "The x coordinate of the center of the plane.",
  19528. default = "0"
  19529. },
  19530. {
  19531. name = "y",
  19532. type = "number",
  19533. description = "The y coordinate of the center of the plane.",
  19534. default = "0"
  19535. },
  19536. {
  19537. name = "z",
  19538. type = "number",
  19539. description = "The z coordinate of the center of the plane.",
  19540. default = "0"
  19541. },
  19542. {
  19543. name = "width",
  19544. type = "number",
  19545. description = "The width of the plane.",
  19546. default = "1"
  19547. },
  19548. {
  19549. name = "height",
  19550. type = "number",
  19551. description = "The height of the plane.",
  19552. default = "1"
  19553. },
  19554. {
  19555. name = "angle",
  19556. type = "number",
  19557. description = "The rotation of the plane around its rotation axis, in radians.",
  19558. default = "0"
  19559. },
  19560. {
  19561. name = "ax",
  19562. type = "number",
  19563. description = "The x component of the axis of rotation.",
  19564. default = "0"
  19565. },
  19566. {
  19567. name = "ay",
  19568. type = "number",
  19569. description = "The y component of the axis of rotation.",
  19570. default = "1"
  19571. },
  19572. {
  19573. name = "az",
  19574. type = "number",
  19575. description = "The z component of the axis of rotation.",
  19576. default = "0"
  19577. },
  19578. {
  19579. name = "style",
  19580. type = "DrawStyle",
  19581. description = "Whether the plane should be drawn filled or outlined.",
  19582. default = "'fill'"
  19583. },
  19584. {
  19585. name = "columns",
  19586. type = "number",
  19587. description = "The number of horizontal segments in the plane.",
  19588. default = "1"
  19589. },
  19590. {
  19591. name = "rows",
  19592. type = "number",
  19593. description = "The number of vertical segments in the plane.",
  19594. default = "columns"
  19595. }
  19596. },
  19597. returns = {}
  19598. },
  19599. {
  19600. arguments = {
  19601. {
  19602. name = "position",
  19603. type = "Vec3",
  19604. description = "The position of the plane."
  19605. },
  19606. {
  19607. name = "size",
  19608. type = "Vec2",
  19609. description = "The size of the plane."
  19610. },
  19611. {
  19612. name = "orientation",
  19613. type = "Quat",
  19614. description = "The orientation of the plane."
  19615. },
  19616. {
  19617. name = "style",
  19618. type = "DrawStyle",
  19619. description = "Whether the plane should be drawn filled or outlined.",
  19620. default = "'fill'"
  19621. },
  19622. {
  19623. name = "columns",
  19624. type = "number",
  19625. description = "The number of horizontal segments in the plane.",
  19626. default = "1"
  19627. },
  19628. {
  19629. name = "rows",
  19630. type = "number",
  19631. description = "The number of vertical segments in the plane.",
  19632. default = "columns"
  19633. }
  19634. },
  19635. returns = {}
  19636. },
  19637. {
  19638. arguments = {
  19639. {
  19640. name = "transform",
  19641. type = "Mat4",
  19642. description = "The transform of the plane."
  19643. },
  19644. {
  19645. name = "style",
  19646. type = "DrawStyle",
  19647. description = "Whether the plane should be drawn filled or outlined.",
  19648. default = "'fill'"
  19649. },
  19650. {
  19651. name = "columns",
  19652. type = "number",
  19653. description = "The number of horizontal segments in the plane.",
  19654. default = "1"
  19655. },
  19656. {
  19657. name = "rows",
  19658. type = "number",
  19659. description = "The number of vertical segments in the plane.",
  19660. default = "columns"
  19661. }
  19662. },
  19663. returns = {}
  19664. }
  19665. }
  19666. },
  19667. {
  19668. name = "points",
  19669. tag = "drawing",
  19670. summary = "Draw points.",
  19671. description = "Draws points. `Pass:mesh` can also be used to draw points using a `Buffer`.",
  19672. key = "Pass:points",
  19673. module = "lovr.graphics",
  19674. notes = "To change the size of points, set the `pointSize` shader flag in `lovr.graphics.newShader` or write to the `PointSize` variable in the vertex shader. Points are always the same size on the screen, regardless of distance, and the units are in pixels.",
  19675. variants = {
  19676. {
  19677. arguments = {
  19678. {
  19679. name = "x",
  19680. type = "number",
  19681. description = "The x coordinate of the first point."
  19682. },
  19683. {
  19684. name = "y",
  19685. type = "number",
  19686. description = "The y coordinate of the first point."
  19687. },
  19688. {
  19689. name = "z",
  19690. type = "number",
  19691. description = "The z coordinate of the first point."
  19692. },
  19693. {
  19694. name = "...",
  19695. type = "*",
  19696. description = "More points."
  19697. }
  19698. },
  19699. returns = {}
  19700. },
  19701. {
  19702. arguments = {
  19703. {
  19704. name = "t",
  19705. type = "table",
  19706. description = "A table of numbers or Vec3 objects (not both) representing point positions."
  19707. }
  19708. },
  19709. returns = {}
  19710. },
  19711. {
  19712. arguments = {
  19713. {
  19714. name = "v",
  19715. type = "Vec3",
  19716. description = "A vector containing the position of the first point to draw."
  19717. },
  19718. {
  19719. name = "...",
  19720. type = "*",
  19721. description = "More points."
  19722. }
  19723. },
  19724. returns = {}
  19725. }
  19726. }
  19727. },
  19728. {
  19729. name = "pop",
  19730. tag = "transform",
  19731. summary = "Pop one of the stacks.",
  19732. description = "Pops the transform or render state stack, restoring it to the state it was in when it was last pushed.",
  19733. key = "Pass:pop",
  19734. module = "lovr.graphics",
  19735. notes = "If a stack is popped without a corresponding push, the stack \"underflows\" which causes an error.",
  19736. related = {
  19737. "Pass:push",
  19738. "StackType"
  19739. },
  19740. variants = {
  19741. {
  19742. arguments = {
  19743. {
  19744. name = "stack",
  19745. type = "StackType",
  19746. description = "The type of stack to pop.",
  19747. default = "'transform'"
  19748. }
  19749. },
  19750. returns = {}
  19751. }
  19752. }
  19753. },
  19754. {
  19755. name = "push",
  19756. tag = "transform",
  19757. summary = "Push state onto a stack.",
  19758. description = "Saves a copy of the transform or render states. Further changes can be made to the transform or render states, and afterwards `Pass:pop` can be used to restore the original state. Pushes and pops can be nested, but it's an error to pop without a corresponding push.",
  19759. key = "Pass:push",
  19760. module = "lovr.graphics",
  19761. notes = "Each stack has a limit of the number of copies it can store. There can be 16 transforms and 4 render states saved.\n\nThe `state` stack does not save the camera info or shader variables changed with `Pass:send`.",
  19762. related = {
  19763. "Pass:pop",
  19764. "StackType"
  19765. },
  19766. variants = {
  19767. {
  19768. arguments = {
  19769. {
  19770. name = "stack",
  19771. type = "StackType",
  19772. description = "The type of stack to push.",
  19773. default = "'transform'"
  19774. }
  19775. },
  19776. returns = {}
  19777. }
  19778. }
  19779. },
  19780. {
  19781. name = "reset",
  19782. tag = "pass-misc",
  19783. summary = "Reset the Pass.",
  19784. description = "Resets the Pass, clearing all of its draws and computes and resetting all of its state to the default values.",
  19785. key = "Pass:reset",
  19786. module = "lovr.graphics",
  19787. notes = "The following things won't be reset:\n\n- Pass canvas, set with `Pass:setCanvas`.\n- Pass clears, set with `Pass:setClear`.\n- The tally buffer, set with `Pass:setTallyBuffer`.",
  19788. variants = {
  19789. {
  19790. arguments = {},
  19791. returns = {}
  19792. }
  19793. }
  19794. },
  19795. {
  19796. name = "rotate",
  19797. tag = "transform",
  19798. summary = "Rotate the coordinate system.",
  19799. description = "Rotates the coordinate system.",
  19800. key = "Pass:rotate",
  19801. module = "lovr.graphics",
  19802. related = {
  19803. "Pass:translate",
  19804. "Pass:scale",
  19805. "Pass:transform",
  19806. "Pass:origin",
  19807. "Pass:push",
  19808. "Pass:pop"
  19809. },
  19810. variants = {
  19811. {
  19812. description = "Rotate the coordinate system using numbers.",
  19813. arguments = {
  19814. {
  19815. name = "angle",
  19816. type = "number",
  19817. description = "The amount to rotate the coordinate system by, in radians."
  19818. },
  19819. {
  19820. name = "ax",
  19821. type = "number",
  19822. description = "The x component of the axis of rotation."
  19823. },
  19824. {
  19825. name = "ay",
  19826. type = "number",
  19827. description = "The y component of the axis of rotation."
  19828. },
  19829. {
  19830. name = "az",
  19831. type = "number",
  19832. description = "The z component of the axis of rotation."
  19833. }
  19834. },
  19835. returns = {}
  19836. },
  19837. {
  19838. description = "Rotate the coordinate system using a quaternion.",
  19839. arguments = {
  19840. {
  19841. name = "rotation",
  19842. type = "Quat",
  19843. description = "A quaternion containing the rotation to apply."
  19844. }
  19845. },
  19846. returns = {}
  19847. }
  19848. }
  19849. },
  19850. {
  19851. name = "roundrect",
  19852. tag = "drawing",
  19853. summary = "Draw a rounded rectangle.",
  19854. description = "Draws a rounded rectangle.",
  19855. key = "Pass:roundrect",
  19856. module = "lovr.graphics",
  19857. variants = {
  19858. {
  19859. arguments = {
  19860. {
  19861. name = "x",
  19862. type = "number",
  19863. description = "The x coordinate of the center of the rectangle.",
  19864. default = "0"
  19865. },
  19866. {
  19867. name = "y",
  19868. type = "number",
  19869. description = "The y coordinate of the center of the rectangle.",
  19870. default = "0"
  19871. },
  19872. {
  19873. name = "z",
  19874. type = "number",
  19875. description = "The z coordinate of the center of the rectangle.",
  19876. default = "0"
  19877. },
  19878. {
  19879. name = "width",
  19880. type = "number",
  19881. description = "The width of the rectangle.",
  19882. default = "1"
  19883. },
  19884. {
  19885. name = "height",
  19886. type = "number",
  19887. description = "The height of the rectangle.",
  19888. default = "1"
  19889. },
  19890. {
  19891. name = "thickness",
  19892. type = "number",
  19893. description = "The thickness of the rectangle.",
  19894. default = "1"
  19895. },
  19896. {
  19897. name = "angle",
  19898. type = "number",
  19899. description = "The rotation of the rectangle around its rotation axis, in radians.",
  19900. default = "0"
  19901. },
  19902. {
  19903. name = "ax",
  19904. type = "number",
  19905. description = "The x component of the axis of rotation.",
  19906. default = "0"
  19907. },
  19908. {
  19909. name = "ay",
  19910. type = "number",
  19911. description = "The y component of the axis of rotation.",
  19912. default = "1"
  19913. },
  19914. {
  19915. name = "az",
  19916. type = "number",
  19917. description = "The z component of the axis of rotation.",
  19918. default = "0"
  19919. },
  19920. {
  19921. name = "radius",
  19922. type = "number",
  19923. description = "The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners.",
  19924. default = "0"
  19925. },
  19926. {
  19927. name = "segments",
  19928. type = "number",
  19929. description = "The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh.",
  19930. default = "8"
  19931. }
  19932. },
  19933. returns = {}
  19934. },
  19935. {
  19936. arguments = {
  19937. {
  19938. name = "position",
  19939. type = "Vec3",
  19940. description = "The position of the rectangle."
  19941. },
  19942. {
  19943. name = "size",
  19944. type = "Vec3",
  19945. description = "The size of the rectangle (width, height, thickness)."
  19946. },
  19947. {
  19948. name = "orientation",
  19949. type = "Quat",
  19950. description = "The orientation of the rectangle."
  19951. },
  19952. {
  19953. name = "radius",
  19954. type = "number",
  19955. description = "The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners.",
  19956. default = "0"
  19957. },
  19958. {
  19959. name = "segments",
  19960. type = "number",
  19961. description = "The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh.",
  19962. default = "8"
  19963. }
  19964. },
  19965. returns = {}
  19966. },
  19967. {
  19968. arguments = {
  19969. {
  19970. name = "transform",
  19971. type = "Mat4",
  19972. description = "The transform of the rectangle."
  19973. },
  19974. {
  19975. name = "radius",
  19976. type = "number",
  19977. description = "The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners.",
  19978. default = "0"
  19979. },
  19980. {
  19981. name = "segments",
  19982. type = "number",
  19983. description = "The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh.",
  19984. default = "8"
  19985. }
  19986. },
  19987. returns = {}
  19988. }
  19989. }
  19990. },
  19991. {
  19992. name = "scale",
  19993. tag = "transform",
  19994. summary = "Scale the coordinate system.",
  19995. description = "Scales the coordinate system.",
  19996. key = "Pass:scale",
  19997. module = "lovr.graphics",
  19998. related = {
  19999. "Pass:translate",
  20000. "Pass:rotate",
  20001. "Pass:transform",
  20002. "Pass:origin",
  20003. "Pass:push",
  20004. "Pass:pop"
  20005. },
  20006. variants = {
  20007. {
  20008. description = "Scale the coordinate system using numbers.",
  20009. arguments = {
  20010. {
  20011. name = "sx",
  20012. type = "number",
  20013. description = "The x component of the scale."
  20014. },
  20015. {
  20016. name = "sy",
  20017. type = "number",
  20018. description = "The y component of the scale.",
  20019. default = "sx"
  20020. },
  20021. {
  20022. name = "sz",
  20023. type = "number",
  20024. description = "The z component of the scale.",
  20025. default = "sx"
  20026. }
  20027. },
  20028. returns = {}
  20029. },
  20030. {
  20031. description = "Scale the coordinate system using a vector.",
  20032. arguments = {
  20033. {
  20034. name = "scale",
  20035. type = "Vec3",
  20036. description = "The scale to apply."
  20037. }
  20038. },
  20039. returns = {}
  20040. }
  20041. }
  20042. },
  20043. {
  20044. name = "send",
  20045. tag = "shaders",
  20046. summary = "Set the value of a shader variable.",
  20047. description = "Sends a value to a variable in the Pass's active `Shader`. The active shader is changed using `Pass:setShader`.",
  20048. key = "Pass:send",
  20049. module = "lovr.graphics",
  20050. examples = {
  20051. {
  20052. code = "function lovr.load()\n shader = lovr.graphics.newShader([[\n layout(set = 2, binding = 0) uniform sampler mySampler;\n layout(set = 2, binding = 1) uniform Colors { vec4 colors[256]; };\n layout(set = 2, binding = 2) uniform texture2D rocks;\n\n Constants {\n uint constant;\n };\n\n vec4 lovrmain() {\n return DefaultPosition;\n }\n ]], 'unlit')\n\n clampler = lovr.graphics.newSampler({ wrap = 'clamp' })\n colorBuffer = lovr.graphics.newBuffer(256, 'vec4')\n rockTexture = lovr.graphics.newTexture('rocks.jpg')\nend\n\nfunction lovr.draw(pass)\n pass:setShader(shader)\n pass:send('mySampler', clampler)\n pass:send('Colors', colorBuffer)\n pass:send('rocks', rockTexture)\n pass:send('constant', 42)\n -- Draw\nend"
  20053. }
  20054. },
  20055. notes = "Shader variables can be in different \"sets\". Variables changed by this function must be in set #2, because LÖVR uses set #0 and set #1 internally.\n\nThe new value will persist until a new shader is set that uses a different \"type\" for the binding number of the variable. See `Pass:setShader` for more details.",
  20056. variants = {
  20057. {
  20058. arguments = {
  20059. {
  20060. name = "name",
  20061. type = "string",
  20062. description = "The name of the Shader variable."
  20063. },
  20064. {
  20065. name = "buffer",
  20066. type = "Buffer",
  20067. description = "The Buffer to assign."
  20068. },
  20069. {
  20070. name = "offset",
  20071. type = "number",
  20072. description = "An offset from the start of the buffer where data will be read, in bytes.",
  20073. default = "0"
  20074. },
  20075. {
  20076. name = "extent",
  20077. type = "number",
  20078. description = "The number of bytes that will be available for reading. If zero, as much data as possible will be bound, depending on the offset, buffer size, and the `uniformBufferRange` or `storageBufferRange` limit.",
  20079. default = "0"
  20080. }
  20081. },
  20082. returns = {}
  20083. },
  20084. {
  20085. arguments = {
  20086. {
  20087. name = "name",
  20088. type = "string",
  20089. description = "The name of the Shader variable."
  20090. },
  20091. {
  20092. name = "texture",
  20093. type = "Texture",
  20094. description = "The Texture to assign."
  20095. }
  20096. },
  20097. returns = {}
  20098. },
  20099. {
  20100. arguments = {
  20101. {
  20102. name = "name",
  20103. type = "string",
  20104. description = "The name of the Shader variable."
  20105. },
  20106. {
  20107. name = "sampler",
  20108. type = "Sampler",
  20109. description = "The Sampler to assign."
  20110. }
  20111. },
  20112. returns = {}
  20113. },
  20114. {
  20115. arguments = {
  20116. {
  20117. name = "name",
  20118. type = "string",
  20119. description = "The name of the Shader variable."
  20120. },
  20121. {
  20122. name = "constant",
  20123. type = "*",
  20124. description = "Numbers, vectors, or tables to assign to the constant or uniform buffer."
  20125. }
  20126. },
  20127. returns = {}
  20128. },
  20129. {
  20130. arguments = {
  20131. {
  20132. name = "binding",
  20133. type = "number",
  20134. description = "The binding number of the Shader variable."
  20135. },
  20136. {
  20137. name = "buffer",
  20138. type = "Buffer",
  20139. description = "The Buffer to assign."
  20140. },
  20141. {
  20142. name = "offset",
  20143. type = "number",
  20144. description = "An offset from the start of the buffer where data will be read, in bytes.",
  20145. default = "0"
  20146. },
  20147. {
  20148. name = "extent",
  20149. type = "number",
  20150. description = "The number of bytes that will be available for reading. If zero, as much data as possible will be bound, depending on the offset, buffer size, and the `uniformBufferRange` or `storageBufferRange` limit.",
  20151. default = "0"
  20152. }
  20153. },
  20154. returns = {}
  20155. },
  20156. {
  20157. arguments = {
  20158. {
  20159. name = "binding",
  20160. type = "number",
  20161. description = "The binding number of the Shader variable."
  20162. },
  20163. {
  20164. name = "texture",
  20165. type = "Texture",
  20166. description = "The Texture to assign."
  20167. }
  20168. },
  20169. returns = {}
  20170. },
  20171. {
  20172. arguments = {
  20173. {
  20174. name = "binding",
  20175. type = "number",
  20176. description = "The binding number of the Shader variable."
  20177. },
  20178. {
  20179. name = "sampler",
  20180. type = "Sampler",
  20181. description = "The Sampler to assign."
  20182. }
  20183. },
  20184. returns = {}
  20185. }
  20186. }
  20187. },
  20188. {
  20189. name = "setAlphaToCoverage",
  20190. tag = "pipeline",
  20191. summary = "Enable or disable alpha to coverage.",
  20192. description = "Sets whether alpha to coverage is enabled. Alpha to coverage factors the alpha of a pixel into antialiasing calculations. It can be used to get antialiased edges on textures with transparency. It's often used for foliage.",
  20193. key = "Pass:setAlphaToCoverage",
  20194. module = "lovr.graphics",
  20195. notes = "By default, alpha to coverage is disabled.",
  20196. variants = {
  20197. {
  20198. arguments = {
  20199. {
  20200. name = "enable",
  20201. type = "boolean",
  20202. description = "Whether alpha to coverage should be enabled."
  20203. }
  20204. },
  20205. returns = {}
  20206. }
  20207. }
  20208. },
  20209. {
  20210. name = "setBlendMode",
  20211. tag = "pipeline",
  20212. summary = "Set the blend mode.",
  20213. description = "Sets the blend mode. When a pixel is drawn, the blend mode controls how it is mixed with the color and alpha of the pixel underneath it.",
  20214. key = "Pass:setBlendMode",
  20215. module = "lovr.graphics",
  20216. notes = "The default blend mode is `alpha` with the `alphamultiply` alpha mode.",
  20217. variants = {
  20218. {
  20219. description = "Sets the blend mode for all canvas textures.",
  20220. arguments = {
  20221. {
  20222. name = "blend",
  20223. type = "BlendMode",
  20224. description = "The blend mode."
  20225. },
  20226. {
  20227. name = "alphaBlend",
  20228. type = "BlendAlphaMode",
  20229. description = "The alpha blend mode, used to control premultiplied alpha."
  20230. }
  20231. },
  20232. returns = {}
  20233. },
  20234. {
  20235. description = "Disables blending. When something is drawn, its pixel colors will replace any existing color in the target texture. This can work okay for opaque objects, but won't render text or transparency properly.",
  20236. arguments = {},
  20237. returns = {}
  20238. },
  20239. {
  20240. description = "Sets the blend mode for a single canvas texture.",
  20241. arguments = {
  20242. {
  20243. name = "index",
  20244. type = "number",
  20245. description = "The index of the canvas texture that will use the new blend mode."
  20246. },
  20247. {
  20248. name = "blend",
  20249. type = "BlendMode",
  20250. description = "The blend mode."
  20251. },
  20252. {
  20253. name = "alphaBlend",
  20254. type = "BlendAlphaMode",
  20255. description = "The alpha blend mode, used to control premultiplied alpha."
  20256. }
  20257. },
  20258. returns = {}
  20259. },
  20260. {
  20261. description = "Disables blending for a single canvas texture.",
  20262. arguments = {
  20263. {
  20264. name = "index",
  20265. type = "number",
  20266. description = "The index of the canvas texture that will use the new blend mode."
  20267. }
  20268. },
  20269. returns = {}
  20270. }
  20271. }
  20272. },
  20273. {
  20274. name = "setCanvas",
  20275. tag = "canvas",
  20276. summary = "Set the Pass's canvas.",
  20277. description = "Sets the Pass's canvas. The canvas is a set of textures that the Pass will draw to when it's submitted, along with configuration for the depth buffer and antialiasing.",
  20278. key = "Pass:setCanvas",
  20279. module = "lovr.graphics",
  20280. notes = "Changing the canvas will reset the pass, as though `Pass:reset` was called.\n\nAll textures must have the same dimensions, layer counts, and multisample counts. They also must have been created with the `render` usage flag.\n\nThe number of layers in the textures determines how many views (cameras) the pass has. Each draw will be rendered to all texture layers, as seen from the corresponding camera. For example, VR rendering will use a canvas texture with 2 layers, one for each eye.\n\nTo render to a specific mipmap level or layer of a texture, use texture views (`Texture:newView`).\n\nMipmaps will be regenerated for all of canvas textures at the end of a render pass.\n\nIf the Pass has multiple color textures, a fragment shader should be used to write a different color to each texture. Here's an example that writes red to the first texture and blue to the second texture:\n\n // Declare an output variable for the second texture\n layout(location = 1) out vec4 secondColor;\n\n vec4 lovrmain() {\n secondColor = vec4(0, 0, 1, 1);\n return vec4(1, 0, 0, 1);\n }",
  20281. related = {
  20282. "Pass:getClear",
  20283. "Pass:setClear",
  20284. "Pass:getWidth",
  20285. "Pass:getHeight",
  20286. "Pass:getDimensions"
  20287. },
  20288. variants = {
  20289. {
  20290. arguments = {
  20291. {
  20292. name = "...textures",
  20293. type = "Texture",
  20294. description = "One or more color textures the pass will render to."
  20295. }
  20296. },
  20297. returns = {}
  20298. },
  20299. {
  20300. arguments = {
  20301. {
  20302. name = "canvas",
  20303. type = "table",
  20304. description = "The canvas. Each numeric key is a color texture to render to (up to 4), along with the following keys to control depth buffer and antialiasing settings:",
  20305. table = {
  20306. {
  20307. name = "depth",
  20308. type = "*",
  20309. description = "A `Texture` or `TextureFormat` with the depth buffer.",
  20310. default = "d32f"
  20311. },
  20312. {
  20313. name = "samples",
  20314. type = "number",
  20315. description = "The number of multisamples used for antialiasing (either 1 or 4).",
  20316. default = "4"
  20317. }
  20318. }
  20319. }
  20320. },
  20321. returns = {}
  20322. },
  20323. {
  20324. description = "Disable the canvas. Any draws in the Pass will be skipped when it is submitted (compute shaders will still run though).",
  20325. arguments = {},
  20326. returns = {}
  20327. }
  20328. }
  20329. },
  20330. {
  20331. name = "setClear",
  20332. tag = "canvas",
  20333. summary = "Set the clear values of the Pass.",
  20334. description = "Sets the clear values of the pass. This controls the initial colors of the canvas texture pixels at the beginning of the render pass. For each color texture, it can be one of the following:\n\n- A specific RGBA color value (or number for the depth texture).\n- `true`, to do a \"fast clear\" to undefined values. This is useful if the pass is going to end\n up drawing to all of the texture's pixels.\n- `false`, to avoid clearing and load the texture's existing pixels. This can be slow on mobile\n GPUs.",
  20335. key = "Pass:setClear",
  20336. module = "lovr.graphics",
  20337. notes = "If the depth clear is not given, it will be set to 0.\n\nAll clear colors will default to transparent black (all zeros) when the Pass is created.",
  20338. related = {
  20339. "Pass:setCanvas",
  20340. "Texture:clear"
  20341. },
  20342. variants = {
  20343. {
  20344. description = "Set the clear color for all color textures, using a hexcode.",
  20345. arguments = {
  20346. {
  20347. name = "hex",
  20348. type = "number",
  20349. description = "A hexcode color to clear all color textures to."
  20350. }
  20351. },
  20352. returns = {}
  20353. },
  20354. {
  20355. description = "Set the clear color for all color textures, using numbers.",
  20356. arguments = {
  20357. {
  20358. name = "r",
  20359. type = "number",
  20360. description = "The red component of the clear color."
  20361. },
  20362. {
  20363. name = "g",
  20364. type = "number",
  20365. description = "The green component of the clear color."
  20366. },
  20367. {
  20368. name = "b",
  20369. type = "number",
  20370. description = "The blue component of the clear color."
  20371. },
  20372. {
  20373. name = "a",
  20374. type = "number",
  20375. description = "The alpha component of the clear color.",
  20376. default = "1.0"
  20377. }
  20378. },
  20379. returns = {}
  20380. },
  20381. {
  20382. description = "Set the clear color for all color textures, using a boolean.",
  20383. arguments = {
  20384. {
  20385. name = "clear",
  20386. type = "boolean",
  20387. description = "Whether color textures should be cleared."
  20388. }
  20389. },
  20390. returns = {}
  20391. },
  20392. {
  20393. description = "Set the clear color for all color textures using a table, or set clear values for individual textures.",
  20394. arguments = {
  20395. {
  20396. name = "t",
  20397. type = "table",
  20398. description = "A table of clear values. This can be a table of 4 numbers to use for all color textures, or it can be a list of boolean and/or RGBA tables to use for each individual color texture. It can also have a `depth` key with a boolean/number for the depth texture's clear."
  20399. }
  20400. },
  20401. returns = {}
  20402. }
  20403. }
  20404. },
  20405. {
  20406. name = "setColor",
  20407. tag = "pipeline",
  20408. summary = "Set the color.",
  20409. description = "Sets the color used for drawing. Color components are from 0 to 1.",
  20410. key = "Pass:setColor",
  20411. module = "lovr.graphics",
  20412. notes = "The default color is `(1, 1, 1, 1)`.",
  20413. variants = {
  20414. {
  20415. arguments = {
  20416. {
  20417. name = "r",
  20418. type = "number",
  20419. description = "The red component of the color."
  20420. },
  20421. {
  20422. name = "g",
  20423. type = "number",
  20424. description = "The green component of the color."
  20425. },
  20426. {
  20427. name = "b",
  20428. type = "number",
  20429. description = "The blue component of the color."
  20430. },
  20431. {
  20432. name = "a",
  20433. type = "number",
  20434. description = "The alpha component of the color.",
  20435. default = "1.0"
  20436. }
  20437. },
  20438. returns = {}
  20439. },
  20440. {
  20441. arguments = {
  20442. {
  20443. name = "t",
  20444. type = "table",
  20445. descriptioin = "A table of 3 or 4 color components."
  20446. }
  20447. },
  20448. returns = {}
  20449. },
  20450. {
  20451. arguments = {
  20452. {
  20453. name = "hex",
  20454. type = "number",
  20455. description = "A hexcode."
  20456. },
  20457. {
  20458. name = "a",
  20459. type = "number",
  20460. description = "The alpha component of the color.",
  20461. default = "1.0"
  20462. }
  20463. },
  20464. returns = {}
  20465. }
  20466. }
  20467. },
  20468. {
  20469. name = "setColorWrite",
  20470. tag = "pipeline",
  20471. summary = "Change the color channels affected by drawing.",
  20472. description = "Sets the color channels affected by drawing, on a per-channel basis. Disabling color writes is often used to render to the depth or stencil buffer without affecting existing pixel colors.",
  20473. key = "Pass:setColorWrite",
  20474. module = "lovr.graphics",
  20475. notes = "By default, color writes are enabled for all channels.",
  20476. related = {
  20477. "Pass:setDepthWrite",
  20478. "Pass:setStencilWrite"
  20479. },
  20480. variants = {
  20481. {
  20482. arguments = {
  20483. {
  20484. name = "enable",
  20485. type = "boolean",
  20486. description = "Whether all color components should be affected by draws."
  20487. }
  20488. },
  20489. returns = {}
  20490. },
  20491. {
  20492. arguments = {
  20493. {
  20494. name = "r",
  20495. type = "boolean",
  20496. description = "Whether the red component should be affected by draws."
  20497. },
  20498. {
  20499. name = "g",
  20500. type = "boolean",
  20501. description = "Whether the green component should be affected by draws."
  20502. },
  20503. {
  20504. name = "b",
  20505. type = "boolean",
  20506. description = "Whether the blue component should be affected by draws."
  20507. },
  20508. {
  20509. name = "a",
  20510. type = "boolean",
  20511. description = "Whether the alpha component should be affected by draws."
  20512. }
  20513. },
  20514. returns = {}
  20515. },
  20516. {
  20517. arguments = {
  20518. {
  20519. name = "index",
  20520. type = "number",
  20521. description = "The index of the canvas texture to update."
  20522. },
  20523. {
  20524. name = "enable",
  20525. type = "boolean",
  20526. description = "Whether all color components should be affected by draws."
  20527. }
  20528. },
  20529. returns = {}
  20530. },
  20531. {
  20532. arguments = {
  20533. {
  20534. name = "index",
  20535. type = "number",
  20536. description = "The index of the canvas texture to update."
  20537. },
  20538. {
  20539. name = "r",
  20540. type = "boolean",
  20541. description = "Whether the red component should be affected by draws."
  20542. },
  20543. {
  20544. name = "g",
  20545. type = "boolean",
  20546. description = "Whether the green component should be affected by draws."
  20547. },
  20548. {
  20549. name = "b",
  20550. type = "boolean",
  20551. description = "Whether the blue component should be affected by draws."
  20552. },
  20553. {
  20554. name = "a",
  20555. type = "boolean",
  20556. description = "Whether the alpha component should be affected by draws."
  20557. }
  20558. },
  20559. returns = {}
  20560. }
  20561. }
  20562. },
  20563. {
  20564. name = "setCullMode",
  20565. tag = "pipeline",
  20566. summary = "Control triangle face culling.",
  20567. description = "Sets whether the front or back faces of triangles are culled.",
  20568. key = "Pass:setCullMode",
  20569. module = "lovr.graphics",
  20570. notes = "By default, face culling is disabled.",
  20571. related = {
  20572. "Pass:setViewCull",
  20573. "Pass:setWinding"
  20574. },
  20575. variants = {
  20576. {
  20577. arguments = {
  20578. {
  20579. name = "mode",
  20580. type = "CullMode",
  20581. description = "Whether `front` faces, `back` faces, or `none` of the faces should be culled."
  20582. }
  20583. },
  20584. returns = {}
  20585. },
  20586. {
  20587. description = "Disable face culling.",
  20588. arguments = {},
  20589. returns = {}
  20590. }
  20591. }
  20592. },
  20593. {
  20594. name = "setDepthClamp",
  20595. tag = "pipeline",
  20596. summary = "Enable or disable depth clamp.",
  20597. description = "Enables or disables depth clamp. Normally, when pixels fall outside of the clipping planes, they are clipped (not rendered). Depth clamp will instead render these pixels, clamping their depth on to the clipping planes.",
  20598. key = "Pass:setDepthClamp",
  20599. module = "lovr.graphics",
  20600. notes = "This isn\\'t supported on all GPUs. Use the `depthClamp` feature of `lovr.graphics.getFeatures` to check for support. If depth clamp is enabled when unsupported, it will silently fall back to depth clipping.\n\nDepth clamping is not enabled by default.",
  20601. related = {
  20602. "Pass:setDepthTest",
  20603. "Pass:setDepthWrite",
  20604. "Pass:setDepthOffset"
  20605. },
  20606. variants = {
  20607. {
  20608. arguments = {
  20609. {
  20610. name = "enable",
  20611. type = "boolean",
  20612. description = "Whether depth clamp should be enabled."
  20613. }
  20614. },
  20615. returns = {}
  20616. }
  20617. }
  20618. },
  20619. {
  20620. name = "setDepthOffset",
  20621. tag = "pipeline",
  20622. summary = "Configure the depth offset.",
  20623. description = "Set the depth offset. This is a constant offset added to the depth value of pixels, as well as a \"sloped\" depth offset that is scaled based on the \"slope\" of the depth at the pixel.\n\nThis can be used to fix Z fighting when rendering decals or other nearly-overlapping objects, and is also useful for shadow biasing when implementing shadow mapping.",
  20624. key = "Pass:setDepthOffset",
  20625. module = "lovr.graphics",
  20626. notes = "The default depth offset is zero for both values.\n\nThis only applies to triangles, not points or lines.\n\nThe units for these offsets aren't specified very well -- they depend on the format of the depth texture, and the GPU can use them slightly differently for its depth calculations. However, an `offset` of 1 will roughly correspond to the smallest-possible depth difference (e.g. 2^-16 for a `d16` depth texture).\n\nThe sloped depth scale is multiplied by the slope of the depth of the triangle. For example, if pixels in the triangle all have the same depth (i.e. the triangle is facing the camera), then the slope of the depth will be zero and the sloped depth offset won't have any effect. As the triangle starts to face away from the camera, the slope of the depth will increase and the sloped depth offset will begin to apply. This can also be thought of corresponding to the normal vector of the triangle relative to the camera.\n\nNote that the offsets can be negative. With LÖVR's default projection matrix, depth values of zero are far away and one are close up, so positive depth offsets will push depth values \"closer\" to the viewer. With flipped projection matrices (a depth test of `lequal`), negative depth offsets would be used instead.",
  20627. related = {
  20628. "Pass:setDepthTest",
  20629. "Pass:setDepthWrite"
  20630. },
  20631. variants = {
  20632. {
  20633. arguments = {
  20634. {
  20635. name = "offset",
  20636. type = "number",
  20637. description = "The depth offset.",
  20638. default = "0.0"
  20639. },
  20640. {
  20641. name = "sloped",
  20642. type = "number",
  20643. description = "The sloped depth offset.",
  20644. default = "0.0"
  20645. }
  20646. },
  20647. returns = {}
  20648. }
  20649. }
  20650. },
  20651. {
  20652. name = "setDepthTest",
  20653. tag = "pipeline",
  20654. summary = "Configure the depth test.",
  20655. description = "Sets the depth test.",
  20656. key = "Pass:setDepthTest",
  20657. module = "lovr.graphics",
  20658. notes = "When using LÖVR's default projection (reverse Z with infinite far plane) the default depth test is `gequal`, depth values of 0.0 are on the far plane and depth values of 1.0 are on the near plane, closer to the camera.\n\nThe near and far clipping planes are set with `Pass:setProjection`. The default is set with `lovr.headset.setClipDistance`.\n\nA depth buffer must be present to use the depth test, but this is enabled by default.",
  20659. related = {
  20660. "Pass:setDepthWrite",
  20661. "Pass:setDepthOffset",
  20662. "Pass:setDepthClamp",
  20663. "Pass:setStencilTest",
  20664. "Pass:setProjection"
  20665. },
  20666. variants = {
  20667. {
  20668. arguments = {
  20669. {
  20670. name = "test",
  20671. type = "CompareMode",
  20672. description = "The new depth test to use."
  20673. }
  20674. },
  20675. returns = {}
  20676. },
  20677. {
  20678. description = "Disable the depth test.",
  20679. arguments = {},
  20680. returns = {}
  20681. }
  20682. }
  20683. },
  20684. {
  20685. name = "setDepthWrite",
  20686. tag = "pipeline",
  20687. summary = "Set whether draws write to the depth buffer.",
  20688. description = "Sets whether draws write to the depth buffer. When a pixel is drawn, if depth writes are enabled and the pixel passes the depth test, the depth buffer will be updated with the pixel's depth value.",
  20689. key = "Pass:setDepthWrite",
  20690. module = "lovr.graphics",
  20691. notes = "The default depth write is `true`.",
  20692. related = {
  20693. "Pass:setStencilWrite",
  20694. "Pass:setColorWrite",
  20695. "Pass:setDepthTest"
  20696. },
  20697. variants = {
  20698. {
  20699. arguments = {
  20700. {
  20701. name = "write",
  20702. type = "boolean",
  20703. description = "Whether the depth buffer should be affected by draws."
  20704. }
  20705. },
  20706. returns = {}
  20707. }
  20708. }
  20709. },
  20710. {
  20711. name = "setFont",
  20712. tag = "pipeline",
  20713. summary = "Set the font.",
  20714. description = "Sets the font used for `Pass:text`.",
  20715. key = "Pass:setFont",
  20716. module = "lovr.graphics",
  20717. related = {
  20718. "Pass:text",
  20719. "lovr.graphics.newFont",
  20720. "lovr.graphics.getDefaultFont"
  20721. },
  20722. variants = {
  20723. {
  20724. arguments = {
  20725. {
  20726. name = "font",
  20727. type = "Font",
  20728. description = "The Font to use when rendering text."
  20729. }
  20730. },
  20731. returns = {}
  20732. }
  20733. }
  20734. },
  20735. {
  20736. name = "setMaterial",
  20737. tag = "pipeline",
  20738. summary = "Set the material.",
  20739. description = "Sets the material. This will apply to most drawing, except for text, skyboxes, and models, which use their own materials.",
  20740. key = "Pass:setMaterial",
  20741. module = "lovr.graphics",
  20742. variants = {
  20743. {
  20744. arguments = {
  20745. {
  20746. name = "material",
  20747. type = "Material",
  20748. description = "The material to use for drawing."
  20749. }
  20750. },
  20751. returns = {}
  20752. },
  20753. {
  20754. arguments = {
  20755. {
  20756. name = "texture",
  20757. type = "Texture",
  20758. description = "The texture to use as the material."
  20759. }
  20760. },
  20761. returns = {}
  20762. },
  20763. {
  20764. description = "Use the default material.",
  20765. arguments = {},
  20766. returns = {}
  20767. }
  20768. }
  20769. },
  20770. {
  20771. name = "setMeshMode",
  20772. tag = "pipeline",
  20773. summary = "Change the way vertices are connected together.",
  20774. description = "Changes the way vertices are connected together when drawing using `Pass:mesh`.",
  20775. key = "Pass:setMeshMode",
  20776. module = "lovr.graphics",
  20777. notes = "The default mesh mode is `triangles`.",
  20778. variants = {
  20779. {
  20780. arguments = {
  20781. {
  20782. name = "mode",
  20783. type = "DrawMode",
  20784. description = "The mesh mode to use."
  20785. }
  20786. },
  20787. returns = {}
  20788. }
  20789. }
  20790. },
  20791. {
  20792. name = "setProjection",
  20793. tag = "camera",
  20794. summary = "Set the field of view.",
  20795. description = "Sets the projection for a single view. 4 field of view angles can be used, similar to the field of view returned by `lovr.headset.getViewAngles`. Alternatively, a projection matrix can be used for other types of projections like orthographic, oblique, etc.\n\nUp to 6 views are supported. The Pass returned by `lovr.headset.getPass` will have its views automatically configured to match the headset.",
  20796. key = "Pass:setProjection",
  20797. module = "lovr.graphics",
  20798. notes = "A far clipping plane of 0.0 can be used for an infinite far plane with reversed Z range. This is the default because it improves depth precision and reduces Z fighting. Using a non-infinite far plane requires the depth buffer to be cleared to 1.0 instead of 0.0 and the default depth test to be changed to `lequal` instead of `gequal`.\n\nBy default, the projection is set by the headset. Each HMD has a specific field of view given by `lovr.headset.getViewAngles`, and the clipping planes can be customized with `lovr.headset.setClipDistance`.",
  20799. related = {
  20800. "lovr.headset.getViewAngles",
  20801. "lovr.headset.getViewCount",
  20802. "Pass:getViewPose",
  20803. "Pass:setViewPose"
  20804. },
  20805. variants = {
  20806. {
  20807. arguments = {
  20808. {
  20809. name = "view",
  20810. type = "number",
  20811. description = "The index of the view to update."
  20812. },
  20813. {
  20814. name = "left",
  20815. type = "number",
  20816. description = "The left field of view angle, in radians."
  20817. },
  20818. {
  20819. name = "right",
  20820. type = "number",
  20821. description = "The right field of view angle, in radians."
  20822. },
  20823. {
  20824. name = "up",
  20825. type = "number",
  20826. description = "The top field of view angle, in radians."
  20827. },
  20828. {
  20829. name = "down",
  20830. type = "number",
  20831. description = "The bottom field of view angle, in radians."
  20832. },
  20833. {
  20834. name = "near",
  20835. type = "number",
  20836. description = "The near clipping plane distance, in meters.",
  20837. default = ".01"
  20838. },
  20839. {
  20840. name = "far",
  20841. type = "number",
  20842. description = "The far clipping plane distance, in meters.",
  20843. default = "0.0"
  20844. }
  20845. },
  20846. returns = {}
  20847. },
  20848. {
  20849. arguments = {
  20850. {
  20851. name = "view",
  20852. type = "number",
  20853. description = "The index of the view to update."
  20854. },
  20855. {
  20856. name = "matrix",
  20857. type = "Mat4",
  20858. description = "The projection matrix for the view."
  20859. }
  20860. },
  20861. returns = {}
  20862. }
  20863. }
  20864. },
  20865. {
  20866. name = "setSampler",
  20867. tag = "pipeline",
  20868. summary = "Set the sampler.",
  20869. description = "Sets the default `Sampler` to use when sampling textures. It is also possible to send a custom sampler to a shader using `Pass:send` and use that instead, which allows customizing the sampler on a per-texture basis.",
  20870. key = "Pass:setSampler",
  20871. module = "lovr.graphics",
  20872. examples = {
  20873. {
  20874. code = "function lovr.draw(pass)\n pass:setSampler('nearest') -- activate minecraft mode\n pass:setMaterial(rock)\n pass:cube(x, y, z)\nend"
  20875. }
  20876. },
  20877. notes = "The `getPixel` shader helper function will use this sampler.\n\nWhen a Pass is reset, its sampler will be reset to `linear`.\n\nThe sampler applies to all draws in the pass on submit, regardless of when the sampler is set.",
  20878. variants = {
  20879. {
  20880. arguments = {
  20881. {
  20882. name = "filter",
  20883. type = "FilterMode",
  20884. description = "The default filter mode to use when sampling textures (the `repeat` wrap mode will be used).",
  20885. default = "'linear'"
  20886. }
  20887. },
  20888. returns = {}
  20889. },
  20890. {
  20891. arguments = {
  20892. {
  20893. name = "sampler",
  20894. type = "Sampler",
  20895. description = "The default sampler shaders will use when reading from textures."
  20896. }
  20897. },
  20898. returns = {}
  20899. }
  20900. }
  20901. },
  20902. {
  20903. name = "setScissor",
  20904. tag = "camera",
  20905. summary = "Set the scissor rectangle.",
  20906. description = "Sets the scissor rectangle. Any pixels outside the scissor rectangle will not be drawn.",
  20907. key = "Pass:setScissor",
  20908. module = "lovr.graphics",
  20909. notes = "The scissor will apply to all draws in a Pass when the pass is submitted, even if this function is called after adding the draws.\n\n`x` and `y` can not be negative. `w` and `h` must be positive.\n\nBy default, the scissor is disabled and will cover the entire render area.",
  20910. related = {
  20911. "Pass:getViewport",
  20912. "Pass:setViewport"
  20913. },
  20914. variants = {
  20915. {
  20916. arguments = {
  20917. {
  20918. name = "x",
  20919. type = "number",
  20920. description = "The x coordinate of the upper-left corner of the scissor rectangle."
  20921. },
  20922. {
  20923. name = "y",
  20924. type = "number",
  20925. description = "The y coordinate of the upper-left corner of the scissor rectangle."
  20926. },
  20927. {
  20928. name = "w",
  20929. type = "number",
  20930. description = "The width of the scissor rectangle."
  20931. },
  20932. {
  20933. name = "h",
  20934. type = "number",
  20935. description = "The height of the scissor rectangle."
  20936. }
  20937. },
  20938. returns = {}
  20939. },
  20940. {
  20941. description = "Disable the scissor.",
  20942. arguments = {},
  20943. returns = {}
  20944. }
  20945. }
  20946. },
  20947. {
  20948. name = "setShader",
  20949. tag = "shaders",
  20950. summary = "Set the active Shader.",
  20951. description = "Sets the active shader. In a render pass, the Shader will affect all drawing operations until it is changed again. In a compute pass, the Shader will be run when `Pass:compute` is called.",
  20952. key = "Pass:setShader",
  20953. module = "lovr.graphics",
  20954. notes = "Changing the shader will preserve resource bindings (the ones set using `Pass:send`) **unless** the new shader declares a resource for a binding number using a different type than the current shader. In this case, the resource \"type\" means one of the following:\n\n- Uniform buffer (`uniform`).\n- Storage buffer (`buffer`).\n- Sampled texture, (`uniform texture<type>`).\n- Storage texture, (`uniform image<type>`).\n- Sampler (`uniform sampler`).\n\nIf the new shader doesn't declare a resource in a particular binding number, any resource there will be preserved.\n\nIf there's a clash in resource types like this, the variable will be \"cleared\". Using a buffer variable that has been cleared is not well-defined, and may return random data or even crash the GPU. For textures, white pixels will be returned. Samplers will use `linear` filtering and the `repeat` wrap mode.\n\nChanging the shader will not clear push constants set in the `Constants` block.",
  20955. related = {
  20956. "Pass:send",
  20957. "Pass:compute"
  20958. },
  20959. variants = {
  20960. {
  20961. arguments = {
  20962. {
  20963. name = "shader",
  20964. type = "Shader",
  20965. description = "The shader to use."
  20966. }
  20967. },
  20968. returns = {}
  20969. },
  20970. {
  20971. description = "Use one of the default shaders for drawing.",
  20972. arguments = {
  20973. {
  20974. name = "default",
  20975. type = "DefaultShader",
  20976. description = "One of the default shaders to use."
  20977. }
  20978. },
  20979. returns = {}
  20980. },
  20981. {
  20982. description = "Switch back to using an automatic shader for drawing.",
  20983. arguments = {},
  20984. returns = {}
  20985. }
  20986. }
  20987. },
  20988. {
  20989. name = "setStencilTest",
  20990. tag = "pipeline",
  20991. summary = "Configure the stencil test.",
  20992. description = "Sets the stencil test. Any pixels that fail the stencil test won't be drawn. For example, setting the stencil test to `('equal', 1)` will only draw pixels that have a stencil value of 1. The stencil buffer can be modified by drawing while stencil writes are enabled with `lovr.graphics.setStencilWrite`.",
  20993. key = "Pass:setStencilTest",
  20994. module = "lovr.graphics",
  20995. notes = "The stencil test is disabled by default.\n\nSetting the stencil test requires the `Pass` to have a depth texture with the `d24s8` or `d32fs8` format (the `s` means \"stencil\"). The `t.graphics.stencil` and `t.headset.stencil` flags in `lovr.conf` can be used to request a stencil format for the default window and headset passes, respectively.",
  20996. related = {
  20997. "Pass:setStencilWrite",
  20998. "Pass:setDepthTest"
  20999. },
  21000. variants = {
  21001. {
  21002. arguments = {
  21003. {
  21004. name = "test",
  21005. type = "CompareMode",
  21006. description = "The new stencil test to use."
  21007. },
  21008. {
  21009. name = "value",
  21010. type = "number",
  21011. description = "The stencil value to compare against."
  21012. },
  21013. {
  21014. name = "mask",
  21015. type = "number",
  21016. description = "An optional mask to apply to stencil values before the comparison.",
  21017. default = "0xff"
  21018. }
  21019. },
  21020. returns = {}
  21021. },
  21022. {
  21023. description = "Disable the stencil test.",
  21024. arguments = {},
  21025. returns = {}
  21026. }
  21027. }
  21028. },
  21029. {
  21030. name = "setStencilWrite",
  21031. tag = "pipeline",
  21032. summary = "Set whether draws write to the stencil buffer.",
  21033. description = "Sets or disables stencil writes. When stencil writes are enabled, any pixels drawn will update the values in the stencil buffer using the `StencilAction` set.",
  21034. key = "Pass:setStencilWrite",
  21035. module = "lovr.graphics",
  21036. notes = "By default, stencil writes are disabled.\n\nSetting the stencil test requires the `Pass` to have a depth texture with the `d24s8` or `d32fs8` format (the `s` means \"stencil\"). The `t.graphics.stencil` and `t.headset.stencil` flags in `lovr.conf` can be used to request a stencil format for the default window and headset passes, respectively.",
  21037. related = {
  21038. "Pass:setStencilTest",
  21039. "Pass:setDepthTest"
  21040. },
  21041. variants = {
  21042. {
  21043. arguments = {
  21044. {
  21045. name = "action",
  21046. type = "StencilAction",
  21047. description = "How pixels drawn will update the stencil buffer."
  21048. },
  21049. {
  21050. name = "value",
  21051. type = "number",
  21052. description = "When using the 'replace' action, this is the value to replace with.",
  21053. default = "1"
  21054. },
  21055. {
  21056. name = "mask",
  21057. type = "number",
  21058. description = "An optional mask to apply to stencil values before writing.",
  21059. default = "0xff"
  21060. }
  21061. },
  21062. returns = {}
  21063. },
  21064. {
  21065. arguments = {
  21066. {
  21067. name = "actions",
  21068. type = "table",
  21069. description = "A list of 3 stencil actions, used when a pixel fails the stencil test, fails the depth test, or passes the stencil test, respectively."
  21070. },
  21071. {
  21072. name = "value",
  21073. type = "number",
  21074. description = "When using the 'replace' action, this is the value to replace with.",
  21075. default = "1"
  21076. },
  21077. {
  21078. name = "mask",
  21079. type = "number",
  21080. description = "An optional mask to apply to stencil values before writing.",
  21081. default = "0xff"
  21082. }
  21083. },
  21084. returns = {}
  21085. },
  21086. {
  21087. description = "Disables stencil writing.",
  21088. arguments = {},
  21089. returns = {}
  21090. }
  21091. }
  21092. },
  21093. {
  21094. name = "setTallyBuffer",
  21095. tag = "tally",
  21096. summary = "Set the Buffer that tally results will be written to.",
  21097. description = "Sets the Buffer where tally results will be written to. Each time the render pass finishes, the results of all the tallies will be copied to the Buffer at the specified offset. The buffer can be used in a later pass in a compute shader, or the data in the buffer can be read back using e.g. `Buffer:newReadback`.",
  21098. key = "Pass:setTallyBuffer",
  21099. module = "lovr.graphics",
  21100. notes = "Each tally result is a 4-byte unsigned integer with the number of samples that passed the depth and stencil tests.\n\nIf the buffer doesn't have enough room to store all the tallies, the number of tallies copied will be clamped to the minimum number that will fit.",
  21101. related = {
  21102. "Pass:beginTally",
  21103. "Pass:finishTally"
  21104. },
  21105. variants = {
  21106. {
  21107. arguments = {
  21108. {
  21109. name = "buffer",
  21110. type = "Buffer",
  21111. description = "The buffer."
  21112. },
  21113. {
  21114. name = "offset",
  21115. type = "number",
  21116. description = "A byte offset where results will be written. Must be a multiple of 4."
  21117. }
  21118. },
  21119. returns = {}
  21120. },
  21121. {
  21122. description = "Unset the tally buffer.",
  21123. arguments = {},
  21124. returns = {}
  21125. }
  21126. }
  21127. },
  21128. {
  21129. name = "setViewCull",
  21130. tag = "pipeline",
  21131. summary = "Enable or disable view frustum culling.",
  21132. description = "Enables or disables view frustum culling. When enabled, if an object is drawn outside of the camera view, the draw will be skipped. This can improve performance.",
  21133. key = "Pass:setViewCull",
  21134. module = "lovr.graphics",
  21135. notes = "View frustum culling is disabled by default.\n\nObjects will be culled against all views in the Pass. The pose and projection for these views is controlled using `Pass:setViewPose` and `Pass:setProjection`.\n\nView frustum culling will increase CPU usage, but will reduce GPU usage depending on how many objects get culled and how many vertices they have.\n\nFor most scenes that draw objects all around the camera, frustum culling will usually result in large speedups. However, it's always good to measure to be sure. For example, if every object drawn is in view, then frustum culling will only make things slower, because LÖVR will spend time checking if objects are in view without actually culling any of them.\n\n`Pass:getStats` will return `draws` and `drawsCulled` fields. The `submitTime` and `gpuTime` fields (with `lovr.graphics.setTimingEnabled`) are a good way to measure the impact of culling.\n\nTo cull an object against a view frustum, LÖVR needs to know the object's bounding box. The following types of draws have bounding boxes:\n\n- `Pass:plane`\n- `Pass:roundrect`\n- `Pass:cube`\n- `Pass:box`\n- `Pass:circle`\n- `Pass:sphere`\n- `Pass:cylinder`\n- `Pass:cone`\n- `Pass:capsule`\n- `Pass:torus`\n- `Pass:draw` (see notes below for `Model` and `Mesh` objects)\n\nThe following draws do **not** currently have bounding boxes, and will not be culled:\n\n- `Pass:points`\n- `Pass:line`\n- `Pass:text`\n- `Pass:skybox`\n- `Pass:fill`\n- `Pass:mesh`\n\n`Model` objects only compute their bounding box when they're loaded, using the initial node transforms. If a node's transform changes, either manually with `Model:setNodeTransform` or from an animation, then the bounding box will become out of sync and culling will not work properly. View culling should be disabled when rendering these models.\n\n`Mesh` objects will not have a bounding box by default. Meshes with a storage type of `cpu` can compute their bounding boxes using `Mesh:computeBoundingBox`, which should be called after creating the Mesh or whenever its vertices change. Any type of Mesh can have its bounding box set manually using `Mesh:setBoundingBox`. This can be faster than `Mesh:computeBoundingBox` if the bounding box is already known, and is the only way to give a `gpu` Mesh a bounding box.",
  21136. related = {
  21137. "Pass:setCullMode",
  21138. "Mesh:computeBoundingBox",
  21139. "Mesh:setBoundingBox",
  21140. "Pass:setViewPose",
  21141. "Pass:setProjection"
  21142. },
  21143. variants = {
  21144. {
  21145. arguments = {
  21146. {
  21147. name = "enable",
  21148. type = "boolean",
  21149. description = "Whether frustum culling should be enabled."
  21150. }
  21151. },
  21152. returns = {}
  21153. }
  21154. }
  21155. },
  21156. {
  21157. name = "setViewPose",
  21158. tag = "camera",
  21159. summary = "Set the camera pose.",
  21160. description = "Sets the pose for a single view. Objects rendered in this view will appear as though the camera is positioned using the given pose.\n\nUp to 6 views are supported. When rendering to the headset, views are changed to match the eye positions. These view poses are also available using `lovr.headset.getViewPose`.",
  21161. key = "Pass:setViewPose",
  21162. module = "lovr.graphics",
  21163. related = {
  21164. "lovr.headset.getViewPose",
  21165. "lovr.headset.getViewCount",
  21166. "Pass:getProjection",
  21167. "Pass:setProjection"
  21168. },
  21169. variants = {
  21170. {
  21171. description = "Set the pose of the view using numbers.",
  21172. arguments = {
  21173. {
  21174. name = "view",
  21175. type = "number",
  21176. description = "The index of the view to update."
  21177. },
  21178. {
  21179. name = "x",
  21180. type = "number",
  21181. description = "The x position of the viewer, in meters."
  21182. },
  21183. {
  21184. name = "y",
  21185. type = "number",
  21186. description = "The y position of the viewer, in meters."
  21187. },
  21188. {
  21189. name = "z",
  21190. type = "number",
  21191. description = "The z position of the viewer, in meters."
  21192. },
  21193. {
  21194. name = "angle",
  21195. type = "number",
  21196. description = "The number of radians the viewer is rotated around its axis of rotation."
  21197. },
  21198. {
  21199. name = "ax",
  21200. type = "number",
  21201. description = "The x component of the axis of rotation."
  21202. },
  21203. {
  21204. name = "ay",
  21205. type = "number",
  21206. description = "The y component of the axis of rotation."
  21207. },
  21208. {
  21209. name = "az",
  21210. type = "number",
  21211. description = "The z component of the axis of rotation."
  21212. }
  21213. },
  21214. returns = {}
  21215. },
  21216. {
  21217. description = "Set the pose of the view using vectors.",
  21218. arguments = {
  21219. {
  21220. name = "view",
  21221. type = "number",
  21222. description = "The index of the view to update."
  21223. },
  21224. {
  21225. name = "position",
  21226. type = "Vec3",
  21227. description = "The position of the viewer, in meters."
  21228. },
  21229. {
  21230. name = "orientation",
  21231. type = "Quat",
  21232. description = "The orientation of the viewer."
  21233. }
  21234. },
  21235. returns = {}
  21236. },
  21237. {
  21238. description = "Set the pose of the view using a matrix.",
  21239. arguments = {
  21240. {
  21241. name = "view",
  21242. type = "number",
  21243. description = "The index of the view to update."
  21244. },
  21245. {
  21246. name = "matrix",
  21247. type = "Mat4",
  21248. description = "A matrix containing the viewer pose."
  21249. },
  21250. {
  21251. name = "inverted",
  21252. type = "boolean",
  21253. description = "Whether the matrix is an inverted pose (a view matrix)."
  21254. }
  21255. },
  21256. returns = {}
  21257. }
  21258. }
  21259. },
  21260. {
  21261. name = "setViewport",
  21262. tag = "camera",
  21263. summary = "Set the viewport.",
  21264. description = "Sets the viewport. Everything rendered will get mapped to the rectangle defined by the viewport. More specifically, this defines the transformation from normalized device coordinates to pixel coordinates.",
  21265. key = "Pass:setViewport",
  21266. module = "lovr.graphics",
  21267. notes = "The viewport will apply to all draws in a Pass when the pass is submitted, even if this function is called after adding the draws.\n\nThe viewport rectangle can use floating point numbers.\n\nA negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically.\n\nThe default viewport extends from `(0, 0)` to the dimensions of the target textures, with min depth and max depth respectively set to 0 and 1.",
  21268. related = {
  21269. "Pass:getScissor",
  21270. "Pass:setScissor",
  21271. "Pass:getDimensions"
  21272. },
  21273. variants = {
  21274. {
  21275. arguments = {
  21276. {
  21277. name = "x",
  21278. type = "number",
  21279. description = "The x coordinate of the upper-left corner of the viewport."
  21280. },
  21281. {
  21282. name = "y",
  21283. type = "number",
  21284. description = "The y coordinate of the upper-left corner of the viewport."
  21285. },
  21286. {
  21287. name = "w",
  21288. type = "number",
  21289. description = "The width of the viewport. Must be positive."
  21290. },
  21291. {
  21292. name = "h",
  21293. type = "number",
  21294. description = "The height of the viewport. May be negative."
  21295. },
  21296. {
  21297. name = "dmin",
  21298. type = "number",
  21299. description = "The min component of the depth range, between 0 and 1.",
  21300. default = "0.0"
  21301. },
  21302. {
  21303. name = "dmax",
  21304. type = "number",
  21305. description = "The max component of the depth range, between 0 and 1.",
  21306. default = "1.0"
  21307. }
  21308. },
  21309. returns = {}
  21310. },
  21311. {
  21312. description = "Disable the viewport.",
  21313. arguments = {},
  21314. returns = {}
  21315. }
  21316. }
  21317. },
  21318. {
  21319. name = "setWinding",
  21320. tag = "pipeline",
  21321. summary = "Set the winding direction of triangle vertices.",
  21322. description = "Sets whether vertices in the clockwise or counterclockwise order vertices are considered the \"front\" face of a triangle. This is used for culling with `Pass:setCullMode`.",
  21323. key = "Pass:setWinding",
  21324. module = "lovr.graphics",
  21325. notes = "The default winding is counterclockwise. LÖVR's builtin shapes are wound counterclockwise.",
  21326. related = {
  21327. "Pass:setCullMode"
  21328. },
  21329. variants = {
  21330. {
  21331. arguments = {
  21332. {
  21333. name = "winding",
  21334. type = "Winding",
  21335. description = "Whether triangle vertices are ordered `clockwise` or `counterclockwise`."
  21336. }
  21337. },
  21338. returns = {}
  21339. }
  21340. }
  21341. },
  21342. {
  21343. name = "setWireframe",
  21344. tag = "pipeline",
  21345. summary = "Enable or disable wireframe rendering.",
  21346. description = "Enables or disables wireframe rendering. This will draw all triangles as lines while active. It's intended to be used for debugging, since it usually has a performance cost.",
  21347. key = "Pass:setWireframe",
  21348. module = "lovr.graphics",
  21349. notes = "Wireframe rendering is disabled by default.\n\nThere is currently no way to change the thickness of the lines.",
  21350. related = {
  21351. "Pass:setMeshMode"
  21352. },
  21353. variants = {
  21354. {
  21355. arguments = {
  21356. {
  21357. name = "enable",
  21358. type = "boolean",
  21359. description = "Whether wireframe rendering should be enabled."
  21360. }
  21361. },
  21362. returns = {}
  21363. }
  21364. }
  21365. },
  21366. {
  21367. name = "skybox",
  21368. tag = "drawing",
  21369. summary = "Draw a skybox.",
  21370. description = "Draws a skybox.",
  21371. key = "Pass:skybox",
  21372. module = "lovr.graphics",
  21373. notes = "The skybox will be rotated based on the camera rotation.\n\nThe skybox is drawn using a fullscreen triangle.\n\nThe skybox uses a custom shader, so set the shader to `nil` before calling this function (unless explicitly using a custom shader).",
  21374. variants = {
  21375. {
  21376. arguments = {
  21377. {
  21378. name = "skybox",
  21379. type = "Texture",
  21380. description = "The skybox to render. Its `TextureType` can be `cube` to render as a cubemap, or `2d` to render as an equirectangular (spherical) 2D image."
  21381. }
  21382. },
  21383. returns = {}
  21384. },
  21385. {
  21386. arguments = {},
  21387. returns = {}
  21388. }
  21389. }
  21390. },
  21391. {
  21392. name = "sphere",
  21393. tag = "drawing",
  21394. summary = "Draw a sphere.",
  21395. description = "Draws a sphere",
  21396. key = "Pass:sphere",
  21397. module = "lovr.graphics",
  21398. notes = "The local origin of the sphere is in its center.",
  21399. variants = {
  21400. {
  21401. arguments = {
  21402. {
  21403. name = "x",
  21404. type = "number",
  21405. description = "The x coordinate of the center of the sphere.",
  21406. default = "0"
  21407. },
  21408. {
  21409. name = "y",
  21410. type = "number",
  21411. description = "The y coordinate of the center of the sphere.",
  21412. default = "0"
  21413. },
  21414. {
  21415. name = "z",
  21416. type = "number",
  21417. description = "The z coordinate of the center of the sphere.",
  21418. default = "0"
  21419. },
  21420. {
  21421. name = "radius",
  21422. type = "number",
  21423. description = "The radius of the sphere.",
  21424. default = "1"
  21425. },
  21426. {
  21427. name = "angle",
  21428. type = "number",
  21429. description = "The rotation of the sphere around its rotation axis, in radians.",
  21430. default = "0"
  21431. },
  21432. {
  21433. name = "ax",
  21434. type = "number",
  21435. description = "The x component of the axis of rotation.",
  21436. default = "0"
  21437. },
  21438. {
  21439. name = "ay",
  21440. type = "number",
  21441. description = "The y component of the axis of rotation.",
  21442. default = "1"
  21443. },
  21444. {
  21445. name = "az",
  21446. type = "number",
  21447. description = "The z component of the axis of rotation.",
  21448. default = "0"
  21449. },
  21450. {
  21451. name = "longitudes",
  21452. type = "number",
  21453. description = "The number of \"horizontal\" segments.",
  21454. default = "48"
  21455. },
  21456. {
  21457. name = "latitudes",
  21458. type = "number",
  21459. description = "The number of \"vertical\" segments.",
  21460. default = "longitudes / 2"
  21461. }
  21462. },
  21463. returns = {}
  21464. },
  21465. {
  21466. arguments = {
  21467. {
  21468. name = "position",
  21469. type = "Vec3",
  21470. description = "The position of the sphere."
  21471. },
  21472. {
  21473. name = "radius",
  21474. type = "number",
  21475. description = "The radius of the sphere.",
  21476. default = "1"
  21477. },
  21478. {
  21479. name = "orientation",
  21480. type = "Quat",
  21481. description = "The orientation of the sphere."
  21482. },
  21483. {
  21484. name = "longitudes",
  21485. type = "number",
  21486. description = "The number of \"horizontal\" segments.",
  21487. default = "48"
  21488. },
  21489. {
  21490. name = "latitudes",
  21491. type = "number",
  21492. description = "The number of \"vertical\" segments.",
  21493. default = "longitudes / 2"
  21494. }
  21495. },
  21496. returns = {}
  21497. },
  21498. {
  21499. arguments = {
  21500. {
  21501. name = "transform",
  21502. type = "Mat4",
  21503. description = "The transform of the sphere."
  21504. },
  21505. {
  21506. name = "longitudes",
  21507. type = "number",
  21508. description = "The number of \"horizontal\" segments.",
  21509. default = "48"
  21510. },
  21511. {
  21512. name = "latitudes",
  21513. type = "number",
  21514. description = "The number of \"vertical\" segments.",
  21515. default = "longitudes / 2"
  21516. }
  21517. },
  21518. returns = {}
  21519. }
  21520. }
  21521. },
  21522. {
  21523. name = "text",
  21524. tag = "drawing",
  21525. summary = "Draw text.",
  21526. description = "Draws text. The font can be changed using `Pass:setFont`.",
  21527. key = "Pass:text",
  21528. module = "lovr.graphics",
  21529. notes = "UTF-8 encoded strings are supported.\n\nNewlines will start a new line of text. Tabs will be rendered as four spaces. Carriage returns are ignored.\n\nWith the default font pixel density, a scale of 1.0 makes the text height 1 meter.\n\nThe wrap value does not take into account the text's scale.\n\nText rendering requires a special shader, which will only be automatically used when the active shader is set to `nil`.\n\nBlending should be enabled when rendering text (it's on by default).\n\nThis function can draw up to 16384 visible characters at a time, and will currently throw an error if the string is too long.",
  21530. related = {
  21531. "Pass:setFont",
  21532. "lovr.graphics.getDefaultFont",
  21533. "Pass:setShader",
  21534. "Font:getWidth",
  21535. "Font:getHeight",
  21536. "Font:getLines",
  21537. "Font:getVertices",
  21538. "Font"
  21539. },
  21540. variants = {
  21541. {
  21542. arguments = {
  21543. {
  21544. name = "text",
  21545. type = "string",
  21546. description = "The text to render."
  21547. },
  21548. {
  21549. name = "x",
  21550. type = "number",
  21551. description = "The x coordinate of the text origin.",
  21552. default = "0"
  21553. },
  21554. {
  21555. name = "y",
  21556. type = "number",
  21557. description = "The y coordinate of the text origin.",
  21558. default = "0"
  21559. },
  21560. {
  21561. name = "z",
  21562. type = "number",
  21563. description = "The z coordinate of the text origin.",
  21564. default = "0"
  21565. },
  21566. {
  21567. name = "scale",
  21568. type = "number",
  21569. description = "The scale of the text (with the default pixel density, units are meters).",
  21570. default = "1"
  21571. },
  21572. {
  21573. name = "angle",
  21574. type = "number",
  21575. description = "The rotation of the text around its rotation axis, in radians.",
  21576. default = "0"
  21577. },
  21578. {
  21579. name = "ax",
  21580. type = "number",
  21581. description = "The x component of the axis of rotation.",
  21582. default = "0"
  21583. },
  21584. {
  21585. name = "ay",
  21586. type = "number",
  21587. description = "The y component of the axis of rotation.",
  21588. default = "1"
  21589. },
  21590. {
  21591. name = "az",
  21592. type = "number",
  21593. description = "The z component of the axis of rotation.",
  21594. default = "0"
  21595. },
  21596. {
  21597. name = "wrap",
  21598. type = "number",
  21599. description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
  21600. default = "0"
  21601. },
  21602. {
  21603. name = "halign",
  21604. type = "HorizontalAlign",
  21605. description = "The horizontal alignment relative to the text origin.",
  21606. default = "'center'"
  21607. },
  21608. {
  21609. name = "valign",
  21610. type = "VerticalAlign",
  21611. description = "The vertical alignment relative to the text origin.",
  21612. default = "'middle'"
  21613. }
  21614. },
  21615. returns = {}
  21616. },
  21617. {
  21618. arguments = {
  21619. {
  21620. name = "text",
  21621. type = "string",
  21622. description = "The text to render."
  21623. },
  21624. {
  21625. name = "position",
  21626. type = "Vec3",
  21627. description = "The position of the text."
  21628. },
  21629. {
  21630. name = "scale",
  21631. type = "number",
  21632. description = "The scale of the text (with the default pixel density, units are meters).",
  21633. default = "1"
  21634. },
  21635. {
  21636. name = "orientation",
  21637. type = "Quat",
  21638. description = "The orientation of the text."
  21639. },
  21640. {
  21641. name = "wrap",
  21642. type = "number",
  21643. description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
  21644. default = "0"
  21645. },
  21646. {
  21647. name = "halign",
  21648. type = "HorizontalAlign",
  21649. description = "The horizontal alignment relative to the text origin.",
  21650. default = "'center'"
  21651. },
  21652. {
  21653. name = "valign",
  21654. type = "VerticalAlign",
  21655. description = "The vertical alignment relative to the text origin.",
  21656. default = "'middle'"
  21657. }
  21658. },
  21659. returns = {}
  21660. },
  21661. {
  21662. arguments = {
  21663. {
  21664. name = "text",
  21665. type = "string",
  21666. description = "The text to render."
  21667. },
  21668. {
  21669. name = "transform",
  21670. type = "Mat4",
  21671. description = "The transform of the text."
  21672. },
  21673. {
  21674. name = "wrap",
  21675. type = "number",
  21676. description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
  21677. default = "0"
  21678. },
  21679. {
  21680. name = "halign",
  21681. type = "HorizontalAlign",
  21682. description = "The horizontal alignment relative to the text origin.",
  21683. default = "'center'"
  21684. },
  21685. {
  21686. name = "valign",
  21687. type = "VerticalAlign",
  21688. description = "The vertical alignment relative to the text origin.",
  21689. default = "'middle'"
  21690. }
  21691. },
  21692. returns = {}
  21693. },
  21694. {
  21695. description = "Renders multicolor text.",
  21696. arguments = {
  21697. {
  21698. name = "colortext",
  21699. type = "table",
  21700. description = "A table of strings with colors to render, in the form `{ color1, string1, color2, string2 }`, where color is a `Vec3`, `Vec4`, hexcode, or table of numbers."
  21701. },
  21702. {
  21703. name = "x",
  21704. type = "number",
  21705. description = "The x coordinate of the text origin.",
  21706. default = "0"
  21707. },
  21708. {
  21709. name = "y",
  21710. type = "number",
  21711. description = "The y coordinate of the text origin.",
  21712. default = "0"
  21713. },
  21714. {
  21715. name = "z",
  21716. type = "number",
  21717. description = "The z coordinate of the text origin.",
  21718. default = "0"
  21719. },
  21720. {
  21721. name = "scale",
  21722. type = "number",
  21723. description = "The scale of the text (with the default pixel density, units are meters).",
  21724. default = "1"
  21725. },
  21726. {
  21727. name = "angle",
  21728. type = "number",
  21729. description = "The rotation of the text around its rotation axis, in radians.",
  21730. default = "0"
  21731. },
  21732. {
  21733. name = "ax",
  21734. type = "number",
  21735. description = "The x component of the axis of rotation.",
  21736. default = "0"
  21737. },
  21738. {
  21739. name = "ay",
  21740. type = "number",
  21741. description = "The y component of the axis of rotation.",
  21742. default = "1"
  21743. },
  21744. {
  21745. name = "az",
  21746. type = "number",
  21747. description = "The z component of the axis of rotation.",
  21748. default = "0"
  21749. },
  21750. {
  21751. name = "wrap",
  21752. type = "number",
  21753. description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
  21754. default = "0"
  21755. },
  21756. {
  21757. name = "halign",
  21758. type = "HorizontalAlign",
  21759. description = "The horizontal alignment relative to the text origin.",
  21760. default = "'center'"
  21761. },
  21762. {
  21763. name = "valign",
  21764. type = "VerticalAlign",
  21765. description = "The vertical alignment relative to the text origin.",
  21766. default = "'middle'"
  21767. }
  21768. },
  21769. returns = {}
  21770. },
  21771. {
  21772. description = "Renders multicolor text.",
  21773. arguments = {
  21774. {
  21775. name = "colortext",
  21776. type = "table",
  21777. description = "A table of strings with colors to render, in the form `{ color1, string1, color2, string2 }`, where color is a `Vec3`, `Vec4`, hexcode, or table of numbers."
  21778. },
  21779. {
  21780. name = "position",
  21781. type = "Vec3",
  21782. description = "The position of the text."
  21783. },
  21784. {
  21785. name = "scale",
  21786. type = "number",
  21787. description = "The scale of the text (with the default pixel density, units are meters).",
  21788. default = "1"
  21789. },
  21790. {
  21791. name = "orientation",
  21792. type = "Quat",
  21793. description = "The orientation of the text."
  21794. },
  21795. {
  21796. name = "wrap",
  21797. type = "number",
  21798. description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
  21799. default = "0"
  21800. },
  21801. {
  21802. name = "halign",
  21803. type = "HorizontalAlign",
  21804. description = "The horizontal alignment relative to the text origin.",
  21805. default = "'center'"
  21806. },
  21807. {
  21808. name = "valign",
  21809. type = "VerticalAlign",
  21810. description = "The vertical alignment relative to the text origin.",
  21811. default = "'middle'"
  21812. }
  21813. },
  21814. returns = {}
  21815. },
  21816. {
  21817. description = "Renders multicolor text.",
  21818. arguments = {
  21819. {
  21820. name = "colortext",
  21821. type = "table",
  21822. description = "A table of strings with colors to render, in the form `{ color1, string1, color2, string2 }`, where color is a `Vec3`, `Vec4`, hexcode, or table of numbers."
  21823. },
  21824. {
  21825. name = "transform",
  21826. type = "Mat4",
  21827. description = "The transform of the text."
  21828. },
  21829. {
  21830. name = "wrap",
  21831. type = "number",
  21832. description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
  21833. default = "0"
  21834. },
  21835. {
  21836. name = "halign",
  21837. type = "HorizontalAlign",
  21838. description = "The horizontal alignment relative to the text origin.",
  21839. default = "'center'"
  21840. },
  21841. {
  21842. name = "valign",
  21843. type = "VerticalAlign",
  21844. description = "The vertical alignment relative to the text origin.",
  21845. default = "'middle'"
  21846. }
  21847. },
  21848. returns = {}
  21849. }
  21850. }
  21851. },
  21852. {
  21853. name = "torus",
  21854. tag = "drawing",
  21855. summary = "Draw a donut.",
  21856. description = "Draws a torus.",
  21857. key = "Pass:torus",
  21858. module = "lovr.graphics",
  21859. notes = "The local origin is in the center of the torus, and the torus forms a circle around the local Z axis.",
  21860. variants = {
  21861. {
  21862. arguments = {
  21863. {
  21864. name = "x",
  21865. type = "number",
  21866. description = "The x coordinate of the center of the torus.",
  21867. default = "0"
  21868. },
  21869. {
  21870. name = "y",
  21871. type = "number",
  21872. description = "The y coordinate of the center of the torus.",
  21873. default = "0"
  21874. },
  21875. {
  21876. name = "z",
  21877. type = "number",
  21878. description = "The z coordinate of the center of the torus.",
  21879. default = "0"
  21880. },
  21881. {
  21882. name = "radius",
  21883. type = "number",
  21884. description = "The radius of the torus.",
  21885. default = "1"
  21886. },
  21887. {
  21888. name = "thickness",
  21889. type = "number",
  21890. description = "The thickness of the torus.",
  21891. default = "1"
  21892. },
  21893. {
  21894. name = "angle",
  21895. type = "number",
  21896. description = "The rotation of the torus around its rotation axis, in radians.",
  21897. default = "0"
  21898. },
  21899. {
  21900. name = "ax",
  21901. type = "number",
  21902. description = "The x component of the axis of rotation.",
  21903. default = "0"
  21904. },
  21905. {
  21906. name = "ay",
  21907. type = "number",
  21908. description = "The y component of the axis of rotation.",
  21909. default = "1"
  21910. },
  21911. {
  21912. name = "az",
  21913. type = "number",
  21914. description = "The z component of the axis of rotation.",
  21915. default = "0"
  21916. },
  21917. {
  21918. name = "tsegments",
  21919. type = "number",
  21920. description = "The number of toroidal (circular) segments to render.",
  21921. default = "64"
  21922. },
  21923. {
  21924. name = "psegments",
  21925. type = "number",
  21926. description = "The number of poloidal (tubular) segments to render.",
  21927. default = "32"
  21928. }
  21929. },
  21930. returns = {}
  21931. },
  21932. {
  21933. arguments = {
  21934. {
  21935. name = "position",
  21936. type = "Vec3",
  21937. description = "The position of the center of the torus."
  21938. },
  21939. {
  21940. name = "scale",
  21941. type = "Vec3",
  21942. description = "The size of the torus (x and y scale the radius, z is the thickness)."
  21943. },
  21944. {
  21945. name = "orientation",
  21946. type = "Quat",
  21947. description = "The orientation of the torus."
  21948. },
  21949. {
  21950. name = "tsegments",
  21951. type = "number",
  21952. description = "The number of toroidal (circular) segments to render.",
  21953. default = "64"
  21954. },
  21955. {
  21956. name = "psegments",
  21957. type = "number",
  21958. description = "The number of poloidal (tubular) segments to render.",
  21959. default = "32"
  21960. }
  21961. },
  21962. returns = {}
  21963. },
  21964. {
  21965. arguments = {
  21966. {
  21967. name = "transform",
  21968. type = "Mat4",
  21969. description = "The transform of the torus."
  21970. },
  21971. {
  21972. name = "tsegments",
  21973. type = "number",
  21974. description = "The number of toroidal (circular) segments to render.",
  21975. default = "64"
  21976. },
  21977. {
  21978. name = "psegments",
  21979. type = "number",
  21980. description = "The number of poloidal (tubular) segments to render.",
  21981. default = "32"
  21982. }
  21983. },
  21984. returns = {}
  21985. }
  21986. }
  21987. },
  21988. {
  21989. name = "transform",
  21990. tag = "transform",
  21991. summary = "Apply a general transform to the coordinate system.",
  21992. description = "Transforms the coordinate system.",
  21993. key = "Pass:transform",
  21994. module = "lovr.graphics",
  21995. related = {
  21996. "Pass:translate",
  21997. "Pass:rotate",
  21998. "Pass:scale",
  21999. "Pass:origin",
  22000. "Pass:push",
  22001. "Pass:pop"
  22002. },
  22003. variants = {
  22004. {
  22005. description = "Transform the coordinate system using numbers.",
  22006. arguments = {
  22007. {
  22008. name = "x",
  22009. type = "number",
  22010. description = "The x component of the translation."
  22011. },
  22012. {
  22013. name = "y",
  22014. type = "number",
  22015. description = "The y component of the translation."
  22016. },
  22017. {
  22018. name = "z",
  22019. type = "number",
  22020. description = "The z component of the translation."
  22021. },
  22022. {
  22023. name = "sx",
  22024. type = "number",
  22025. description = "The x component of the scale."
  22026. },
  22027. {
  22028. name = "sy",
  22029. type = "number",
  22030. description = "The y component of the scale."
  22031. },
  22032. {
  22033. name = "sz",
  22034. type = "number",
  22035. description = "The z component of the scale."
  22036. },
  22037. {
  22038. name = "angle",
  22039. type = "number",
  22040. description = "The amount to rotate the coordinate system by, in radians."
  22041. },
  22042. {
  22043. name = "ax",
  22044. type = "number",
  22045. description = "The x component of the axis of rotation."
  22046. },
  22047. {
  22048. name = "ay",
  22049. type = "number",
  22050. description = "The y component of the axis of rotation."
  22051. },
  22052. {
  22053. name = "az",
  22054. type = "number",
  22055. description = "The z component of the axis of rotation."
  22056. }
  22057. },
  22058. returns = {}
  22059. },
  22060. {
  22061. description = "Transform the coordinate system using vector types.",
  22062. arguments = {
  22063. {
  22064. name = "translation",
  22065. type = "Vec3",
  22066. description = "The translation to apply."
  22067. },
  22068. {
  22069. name = "scale",
  22070. type = "Vec3",
  22071. description = "The scale to apply."
  22072. },
  22073. {
  22074. name = "rotation",
  22075. type = "Quat",
  22076. description = "A quaternion containing the rotation to apply."
  22077. }
  22078. },
  22079. returns = {}
  22080. },
  22081. {
  22082. description = "Transform the coordinate system using a matrix.",
  22083. arguments = {
  22084. {
  22085. name = "transform",
  22086. type = "Mat4",
  22087. description = "A matrix containing the transformation to apply."
  22088. }
  22089. },
  22090. returns = {}
  22091. }
  22092. }
  22093. },
  22094. {
  22095. name = "translate",
  22096. tag = "transform",
  22097. summary = "Translate the coordinate system.",
  22098. description = "Translates the coordinate system.",
  22099. key = "Pass:translate",
  22100. module = "lovr.graphics",
  22101. notes = "Order matters when scaling, translating, and rotating the coordinate system.",
  22102. related = {
  22103. "Pass:rotate",
  22104. "Pass:scale",
  22105. "Pass:transform",
  22106. "Pass:origin",
  22107. "Pass:push",
  22108. "Pass:pop"
  22109. },
  22110. variants = {
  22111. {
  22112. description = "Translate the coordinate system using numbers.",
  22113. arguments = {
  22114. {
  22115. name = "x",
  22116. type = "number",
  22117. description = "The x component of the translation."
  22118. },
  22119. {
  22120. name = "y",
  22121. type = "number",
  22122. description = "The y component of the translation."
  22123. },
  22124. {
  22125. name = "z",
  22126. type = "number",
  22127. description = "The z component of the translation."
  22128. }
  22129. },
  22130. returns = {}
  22131. },
  22132. {
  22133. description = "Translate the coordinate system using a vector.",
  22134. arguments = {
  22135. {
  22136. name = "translation",
  22137. type = "Vec3",
  22138. description = "The translation."
  22139. }
  22140. },
  22141. returns = {}
  22142. }
  22143. }
  22144. }
  22145. },
  22146. sections = {
  22147. {
  22148. name = "Drawing",
  22149. tag = "drawing",
  22150. description = "Draw objects and shapes."
  22151. },
  22152. {
  22153. name = "Coordinate System",
  22154. tag = "transform",
  22155. description = "Manipulate the 3D coordinate system."
  22156. },
  22157. {
  22158. name = "Render States",
  22159. tag = "pipeline",
  22160. description = "Set render states that change the way draws appear. Render states can be saved and restored using `Pass:push` and `Pass:pop`."
  22161. },
  22162. {
  22163. name = "Shaders",
  22164. tag = "shaders",
  22165. description = "Change the shader used for draws or computes, and set variables in the active shader."
  22166. },
  22167. {
  22168. name = "Compute",
  22169. tag = "compute"
  22170. },
  22171. {
  22172. name = "Tally",
  22173. tag = "tally",
  22174. description = "Tallies count the number of pixels that were visible for a draw."
  22175. },
  22176. {
  22177. name = "Camera",
  22178. tag = "camera"
  22179. },
  22180. {
  22181. name = "Canvas",
  22182. tag = "canvas"
  22183. },
  22184. {
  22185. name = "Miscellaneous",
  22186. tag = "pass-misc"
  22187. }
  22188. }
  22189. },
  22190. {
  22191. name = "Readback",
  22192. summary = "An asynchronous read of a GPU resource.",
  22193. description = "Readbacks track the progress of an asynchronous read of a `Buffer` or `Texture`. Once a Readback is created in a transfer pass, and the transfer pass is submitted, the Readback can be polled for completion or the CPU can wait for it to finish using `Readback:wait`.",
  22194. key = "Readback",
  22195. module = "lovr.graphics",
  22196. constructors = {
  22197. "Buffer:newReadback",
  22198. "Texture:newReadback"
  22199. },
  22200. methods = {
  22201. {
  22202. name = "getBlob",
  22203. summary = "Get Readback's data as a Blob.",
  22204. description = "Returns the Readback's data as a Blob.",
  22205. key = "Readback:getBlob",
  22206. module = "lovr.graphics",
  22207. notes = "If the Readback is reading back a Texture, returns `nil`.",
  22208. related = {
  22209. "Readback:getData",
  22210. "Readback:getImage"
  22211. },
  22212. variants = {
  22213. {
  22214. arguments = {},
  22215. returns = {
  22216. {
  22217. name = "blob",
  22218. type = "Blob",
  22219. description = "The Blob."
  22220. }
  22221. }
  22222. }
  22223. }
  22224. },
  22225. {
  22226. name = "getData",
  22227. summary = "Get Readback's data as a table.",
  22228. description = "Returns the data from the Readback, as a table. See `Buffer:getData` for the way the table is structured.",
  22229. key = "Readback:getData",
  22230. module = "lovr.graphics",
  22231. notes = "This returns `nil` for readbacks of `Texture` objects.",
  22232. related = {
  22233. "Readback:getBlob",
  22234. "Readback:getImage"
  22235. },
  22236. variants = {
  22237. {
  22238. arguments = {},
  22239. returns = {
  22240. {
  22241. name = "data",
  22242. type = "table",
  22243. description = "A table containing the data that was read back."
  22244. }
  22245. }
  22246. }
  22247. }
  22248. },
  22249. {
  22250. name = "getImage",
  22251. summary = "Get Readback's data as an Image.",
  22252. description = "Returns the Readback's data as an Image.",
  22253. key = "Readback:getImage",
  22254. module = "lovr.graphics",
  22255. notes = "If the Readback is not reading back a Texture, returns `nil`.",
  22256. related = {
  22257. "Readback:getData",
  22258. "Readback:getBlob"
  22259. },
  22260. variants = {
  22261. {
  22262. arguments = {},
  22263. returns = {
  22264. {
  22265. name = "image",
  22266. type = "Image",
  22267. description = "The Image."
  22268. }
  22269. }
  22270. }
  22271. }
  22272. },
  22273. {
  22274. name = "isComplete",
  22275. summary = "Check if a Readback is complete.",
  22276. description = "Returns whether the Readback has completed on the GPU and its data is available.",
  22277. key = "Readback:isComplete",
  22278. module = "lovr.graphics",
  22279. variants = {
  22280. {
  22281. arguments = {},
  22282. returns = {
  22283. {
  22284. name = "complete",
  22285. type = "boolean",
  22286. description = "Whether the readback is complete."
  22287. }
  22288. }
  22289. }
  22290. }
  22291. },
  22292. {
  22293. name = "wait",
  22294. summary = "Wait for the Readback to finish.",
  22295. description = "Blocks the CPU until the Readback is finished on the GPU.",
  22296. key = "Readback:wait",
  22297. module = "lovr.graphics",
  22298. notes = "If the transfer pass that created the readback has not been submitted yet, no wait will occur and this function will return `false`.",
  22299. variants = {
  22300. {
  22301. arguments = {},
  22302. returns = {
  22303. {
  22304. name = "waited",
  22305. type = "boolean",
  22306. description = "Whether the CPU had to be blocked for waiting."
  22307. }
  22308. }
  22309. }
  22310. }
  22311. }
  22312. }
  22313. },
  22314. {
  22315. name = "Sampler",
  22316. summary = "An object that controls how texture pixels are read.",
  22317. description = "Samplers are objects that control how pixels are read from a texture. They can control whether the pixels are smoothed, whether the texture wraps at the edge of its UVs, and more.\n\nEach `Pass` has a default sampler that will be used by default, which can be changed using `Pass:setSampler`. Also, samplers can be declared in shaders using the following syntax:\n\n layout(set = 2, binding = X) uniform sampler mySampler;\n\nA Sampler can be sent to the variable using `Pass:send('mySampler', sampler)`.\n\nThe properties of a Sampler are immutable, and can't be changed after it's created.",
  22318. key = "Sampler",
  22319. module = "lovr.graphics",
  22320. constructors = {
  22321. "lovr.graphics.newSampler"
  22322. },
  22323. methods = {
  22324. {
  22325. name = "getAnisotropy",
  22326. summary = "Get the anisotropy level of the Sampler.",
  22327. description = "Returns the anisotropy level of the Sampler. Anisotropy smooths out a texture's appearance when viewed at grazing angles.",
  22328. key = "Sampler:getAnisotropy",
  22329. module = "lovr.graphics",
  22330. notes = "Not all GPUs support anisotropy. The maximum anisotropy level is given by the `anisotropy` limit of `lovr.graphics.getLimits`, which may be zero. It's very common for the maximum to be 16, however.",
  22331. related = {
  22332. "Sampler:getFilter",
  22333. "Sampler:getWrap",
  22334. "Sampler:getCompareMode",
  22335. "Sampler:getMipmapRange"
  22336. },
  22337. variants = {
  22338. {
  22339. arguments = {},
  22340. returns = {
  22341. {
  22342. name = "anisotropy",
  22343. type = "number",
  22344. description = "The anisotropy level of the sampler."
  22345. }
  22346. }
  22347. }
  22348. }
  22349. },
  22350. {
  22351. name = "getCompareMode",
  22352. summary = "Get the compare mode of the Sampler.",
  22353. description = "Returns the compare mode of the Sampler. This is a feature typically only used for shadow mapping. Using a sampler with a compare mode requires it to be declared in a shader as a `samplerShadow` instead of a `sampler` variable, and used with a texture that has a depth format. The result of sampling a depth texture with a shadow sampler is a number between 0 and 1, indicating the percentage of sampled pixels that passed the comparison.",
  22354. key = "Sampler:getCompareMode",
  22355. module = "lovr.graphics",
  22356. related = {
  22357. "Sampler:getFilter",
  22358. "Sampler:getWrap",
  22359. "Sampler:getAnisotropy",
  22360. "Sampler:getMipmapRange"
  22361. },
  22362. variants = {
  22363. {
  22364. arguments = {},
  22365. returns = {
  22366. {
  22367. name = "compare",
  22368. type = "CompareMode",
  22369. description = "The compare mode of the sampler."
  22370. }
  22371. }
  22372. }
  22373. }
  22374. },
  22375. {
  22376. name = "getFilter",
  22377. summary = "Get the filter mode of the Sampler.",
  22378. description = "Returns the filter mode of the Sampler.",
  22379. key = "Sampler:getFilter",
  22380. module = "lovr.graphics",
  22381. related = {
  22382. "Sampler:getWrap",
  22383. "Sampler:getCompareMode",
  22384. "Sampler:getAnisotropy",
  22385. "Sampler:getMipmapRange"
  22386. },
  22387. variants = {
  22388. {
  22389. arguments = {},
  22390. returns = {
  22391. {
  22392. name = "min",
  22393. type = "FilterMode",
  22394. description = "The filter mode used when the texture is minified."
  22395. },
  22396. {
  22397. name = "mag",
  22398. type = "FilterMode",
  22399. description = "The filter mode used when the texture is magnified."
  22400. },
  22401. {
  22402. name = "mip",
  22403. type = "FilterMode",
  22404. description = "The filter mode used to select a mipmap level."
  22405. }
  22406. }
  22407. }
  22408. }
  22409. },
  22410. {
  22411. name = "getMipmapRange",
  22412. summary = "Get the mipmap range of the Sampler.",
  22413. description = "Returns the mipmap range of the Sampler. This is used to clamp the range of mipmap levels that can be accessed from a texture.",
  22414. key = "Sampler:getMipmapRange",
  22415. module = "lovr.graphics",
  22416. related = {
  22417. "Sampler:getFilter",
  22418. "Sampler:getWrap",
  22419. "Sampler:getCompareMode",
  22420. "Sampler:getAnisotropy"
  22421. },
  22422. variants = {
  22423. {
  22424. arguments = {},
  22425. returns = {
  22426. {
  22427. name = "min",
  22428. type = "number",
  22429. description = "The minimum mipmap level that will be sampled (0 is the largest image)."
  22430. },
  22431. {
  22432. name = "max",
  22433. type = "number",
  22434. description = "The maximum mipmap level that will be sampled."
  22435. }
  22436. }
  22437. }
  22438. }
  22439. },
  22440. {
  22441. name = "getWrap",
  22442. summary = "Get the wrap mode of the Sampler.",
  22443. description = "Returns the wrap mode of the sampler, used to wrap or clamp texture coordinates when the extend outside of the 0-1 range.",
  22444. key = "Sampler:getWrap",
  22445. module = "lovr.graphics",
  22446. related = {
  22447. "Sampler:getFilter",
  22448. "Sampler:getCompareMode",
  22449. "Sampler:getAnisotropy",
  22450. "Sampler:getMipmapRange"
  22451. },
  22452. variants = {
  22453. {
  22454. arguments = {},
  22455. returns = {
  22456. {
  22457. name = "x",
  22458. type = "WrapMode",
  22459. description = "The wrap mode used in the horizontal direction."
  22460. },
  22461. {
  22462. name = "y",
  22463. type = "WrapMode",
  22464. description = "The wrap mode used in the vertical direction."
  22465. },
  22466. {
  22467. name = "z",
  22468. type = "WrapMode",
  22469. description = "The wrap mode used in the \"z\" direction, for 3D textures only."
  22470. }
  22471. }
  22472. }
  22473. }
  22474. }
  22475. }
  22476. },
  22477. {
  22478. name = "Shader",
  22479. summary = "GPU program.",
  22480. description = "Shaders are small GPU programs. See the `Shaders` guide for a full introduction to Shaders.",
  22481. key = "Shader",
  22482. module = "lovr.graphics",
  22483. constructors = {
  22484. "lovr.graphics.newShader",
  22485. "Shader:clone"
  22486. },
  22487. methods = {
  22488. {
  22489. name = "clone",
  22490. summary = "Clone a Shader.",
  22491. description = "Clones a shader. This creates an inexpensive copy of it with different flags. It can be used to create several variants of a shader with different behavior.",
  22492. key = "Shader:clone",
  22493. module = "lovr.graphics",
  22494. variants = {
  22495. {
  22496. arguments = {
  22497. {
  22498. name = "source",
  22499. type = "Shader",
  22500. description = "The Shader to clone."
  22501. },
  22502. {
  22503. name = "flags",
  22504. type = "table",
  22505. description = "The flags used by the clone."
  22506. }
  22507. },
  22508. returns = {
  22509. {
  22510. name = "shader",
  22511. type = "Shader",
  22512. description = "The new Shader."
  22513. }
  22514. }
  22515. }
  22516. }
  22517. },
  22518. {
  22519. name = "getBufferFormat",
  22520. summary = "Get the format of a buffer in the Shader.",
  22521. description = "Returns the format of a buffer declared in shader code. The return type matches the same syntax used by `lovr.graphics.newBuffer` and `Buffer:getFormat`, so it can be used to quickly create a Buffer that matches a variable from a Shader.",
  22522. key = "Shader:getBufferFormat",
  22523. module = "lovr.graphics",
  22524. examples = {
  22525. {
  22526. code = "shader = lovr.graphics.newShader([[\n layout(set = 2, binding = 0) uniform Transforms {\n mat4 transforms[32];\n };\n\n vec4 lovrmain() {\n return Projection * View * transforms[InstanceIndex] * VertexPosition;\n }\n]], 'unlit')\n\nlocal format, length = shader:getBufferFormat('Transforms')\nprint(length) --> 32\nprint(format[1].name) --> 'transforms'\nprint(format[1].type) --> 'mat4'\n\n-- Can pass the 2 results directly to newBuffer:\ntransforms = lovr.graphics.newBuffer(shader:getBufferFormat('Transforms'))\n\n-- Or override the length with some initial data:\ntransforms = lovr.graphics.newBuffer(shader:getBufferFormat('Transforms'), objects)"
  22527. }
  22528. },
  22529. notes = "If the buffer only has a single array field, the format will be \"unwrapped\" to an array instead of a single-field struct with an array in it. Example:\n\n shader = lovr.graphics.newShader([[\n layout(set = 0, binding = 0) buffer Numbers {\n uint numbers[64];\n };\n\n void lovrmain(){}\n ]])\n\n shader:getBufferFormat('Numbers')\n -- returns {{ name = 'numbers', type = 'u32' }}, 64\n -- not {{ name = 'numbers', type = 'u32', length = 64 }}, 1\n\nSimilarly, if the buffer only has a single struct field, the format will be \"unwrapped\" to the inner struct. This lets you use a struct for a Buffer's data without having to wrap everything in an extra namespace. Example:\n\n shader = lovr.graphics.newShader([[\n struct HandParams {\n vec3 pos;\n float grip;\n };\n\n layout(set = 0, binding = 0) buffer Hand {\n HandParams params;\n };\n\n void lovrmain(){}\n ]])\n\n shader:getBufferFormat('Hand')\n -- returns {{ name = 'pos', type = 'vec3' }, { name = 'grip', type = 'float' }}, 1\n -- not {{ name = 'params', type = {...}}}, 1",
  22530. related = {
  22531. "lovr.graphics.newBuffer",
  22532. "Buffer:getFormat"
  22533. },
  22534. variants = {
  22535. {
  22536. arguments = {
  22537. {
  22538. name = "name",
  22539. type = "string",
  22540. description = "The name of the buffer variable to return the format of."
  22541. }
  22542. },
  22543. returns = {
  22544. {
  22545. name = "format",
  22546. type = "table",
  22547. description = "A list of fields that match the type declaration of the buffer in the shader code. Each field has `name`, `type`, and `offset` keys. If the field is an array, it will have `length` and `stride` keys as well. The top-level table also has a `stride` key. Offsets and strides are in bytes."
  22548. },
  22549. {
  22550. name = "length",
  22551. type = "number",
  22552. description = "The number of items in the buffer (or 1 if the buffer is not an array)."
  22553. }
  22554. }
  22555. }
  22556. }
  22557. },
  22558. {
  22559. name = "getType",
  22560. summary = "Get the type of the Shader.",
  22561. description = "Returns whether the shader is a graphics or compute shader.",
  22562. key = "Shader:getType",
  22563. module = "lovr.graphics",
  22564. related = {
  22565. "Shader:hasStage",
  22566. "lovr.graphics.newShader"
  22567. },
  22568. variants = {
  22569. {
  22570. arguments = {},
  22571. returns = {
  22572. {
  22573. name = "type",
  22574. type = "ShaderType",
  22575. description = "The type of the Shader."
  22576. }
  22577. }
  22578. }
  22579. }
  22580. },
  22581. {
  22582. name = "getWorkgroupSize",
  22583. summary = "Get the workgroup size of a compute shader.",
  22584. description = "Returns the workgroup size of a compute shader. The workgroup size defines how many times a compute shader is invoked for each workgroup dispatched by `Pass:compute`.",
  22585. key = "Shader:getWorkgroupSize",
  22586. module = "lovr.graphics",
  22587. notes = "For example, if the workgroup size is `8x8x1` and `16x16x16` workgroups are dispatched, then the compute shader will run `16 * 16 * 16 * (8 * 8 * 1) = 262144` times.",
  22588. variants = {
  22589. {
  22590. arguments = {},
  22591. returns = {
  22592. {
  22593. name = "x",
  22594. type = "number",
  22595. description = "The x size of a workgroup."
  22596. },
  22597. {
  22598. name = "y",
  22599. type = "number",
  22600. description = "The y size of a workgroup."
  22601. },
  22602. {
  22603. name = "z",
  22604. type = "number",
  22605. description = "The z size of a workgroup."
  22606. }
  22607. }
  22608. }
  22609. }
  22610. },
  22611. {
  22612. name = "hasAttribute",
  22613. summary = "Check if the Shader has a given vertex attribute.",
  22614. description = "Returns whether the Shader has a vertex attribute, by name or location.",
  22615. key = "Shader:hasAttribute",
  22616. module = "lovr.graphics",
  22617. examples = {
  22618. {
  22619. code = "function lovr.load()\n shader = lovr.graphics.newShader([[\n layout(location = 7) in uint coolAttribute;\n\n vec4 lovrmain() {\n return DefaultPosition;\n }\n ]], [[\n vec4 lovrmain() {\n return DefaultColor;\n }\n ]])\n\n print(shader:hasAttribute('coolAttribute')) --> true\n print(shader:hasAttribute(7)) --> true\n print(shader:hasAttribute(8)) --> false\nend"
  22620. }
  22621. },
  22622. variants = {
  22623. {
  22624. arguments = {
  22625. {
  22626. name = "name",
  22627. type = "string",
  22628. description = "The name of an attribute."
  22629. }
  22630. },
  22631. returns = {
  22632. {
  22633. name = "exists",
  22634. type = "boolean",
  22635. description = "Whether the Shader has the attribute."
  22636. }
  22637. }
  22638. },
  22639. {
  22640. arguments = {
  22641. {
  22642. name = "location",
  22643. type = "number",
  22644. description = "The location of an attribute."
  22645. }
  22646. },
  22647. returns = {
  22648. {
  22649. name = "exists",
  22650. type = "boolean",
  22651. description = "Whether the Shader has the attribute."
  22652. }
  22653. }
  22654. }
  22655. }
  22656. },
  22657. {
  22658. name = "hasStage",
  22659. summary = "Check if the Shader has a given stage.",
  22660. description = "Returns whether the Shader has a given stage.",
  22661. key = "Shader:hasStage",
  22662. module = "lovr.graphics",
  22663. related = {
  22664. "Shader:getType"
  22665. },
  22666. variants = {
  22667. {
  22668. arguments = {
  22669. {
  22670. name = "stage",
  22671. type = "ShaderStage",
  22672. description = "The stage."
  22673. }
  22674. },
  22675. returns = {
  22676. {
  22677. name = "exists",
  22678. type = "boolean",
  22679. description = "Whether the Shader has the stage."
  22680. }
  22681. }
  22682. }
  22683. }
  22684. }
  22685. }
  22686. },
  22687. {
  22688. name = "Texture",
  22689. summary = "A multidimensional block of memory on the GPU.",
  22690. description = "Textures are multidimensional blocks of memory on the GPU, contrasted with `Buffer` objects which are one-dimensional. Textures are used as the destination for rendering operations, and textures loaded from images provide surface data to `Material` objects.",
  22691. key = "Texture",
  22692. module = "lovr.graphics",
  22693. constructors = {
  22694. "lovr.graphics.newTexture",
  22695. "Texture:newView"
  22696. },
  22697. methods = {
  22698. {
  22699. name = "clear",
  22700. tag = "texture-transfer",
  22701. summary = "Clear the Texture to a color.",
  22702. description = "Clears layers and mipmaps in a texture to a given color.\n\nWhen a Texture is being used as a canvas for a `Pass`, the clear color can be set with `Pass:setClear`, which a more efficient way to clear the texture before rendering.",
  22703. key = "Texture:clear",
  22704. module = "lovr.graphics",
  22705. notes = "The texture must have been created with the `transfer` usage to clear it.\n\nThe clear color will be interpreted as a linear color for sRGB formats.",
  22706. related = {
  22707. "Buffer:clear",
  22708. "Texture:setPixels",
  22709. "Pass:setClear"
  22710. },
  22711. variants = {
  22712. {
  22713. description = "Clear the whole texture to zero (transparent black).",
  22714. arguments = {},
  22715. returns = {}
  22716. },
  22717. {
  22718. arguments = {
  22719. {
  22720. name = "hex",
  22721. type = "number",
  22722. description = "The hexcode color to clear to."
  22723. },
  22724. {
  22725. name = "layer",
  22726. type = "number",
  22727. description = "The index of the first layer to clear.",
  22728. default = "1"
  22729. },
  22730. {
  22731. name = "layerCount",
  22732. type = "number",
  22733. description = "The number of layers to clear. If nil, clears the rest of the layers.",
  22734. default = "nil"
  22735. },
  22736. {
  22737. name = "mipmap",
  22738. type = "number",
  22739. description = "The index of the first mipmap to clear.",
  22740. default = "1"
  22741. },
  22742. {
  22743. name = "mipmapCount",
  22744. type = "number",
  22745. description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
  22746. default = "nil"
  22747. }
  22748. },
  22749. returns = {}
  22750. },
  22751. {
  22752. arguments = {
  22753. {
  22754. name = "r",
  22755. type = "number",
  22756. description = "The red component of the clear color."
  22757. },
  22758. {
  22759. name = "g",
  22760. type = "number",
  22761. description = "The green component of the clear color."
  22762. },
  22763. {
  22764. name = "b",
  22765. type = "number",
  22766. description = "The blue component of the clear color."
  22767. },
  22768. {
  22769. name = "a",
  22770. type = "number",
  22771. description = "The alpha component of the clear color."
  22772. },
  22773. {
  22774. name = "layer",
  22775. type = "number",
  22776. description = "The index of the first layer to clear.",
  22777. default = "1"
  22778. },
  22779. {
  22780. name = "layerCount",
  22781. type = "number",
  22782. description = "The number of layers to clear. If nil, clears the rest of the layers.",
  22783. default = "nil"
  22784. },
  22785. {
  22786. name = "mipmap",
  22787. type = "number",
  22788. description = "The index of the first mipmap to clear.",
  22789. default = "1"
  22790. },
  22791. {
  22792. name = "mipmapCount",
  22793. type = "number",
  22794. description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
  22795. default = "nil"
  22796. }
  22797. },
  22798. returns = {}
  22799. },
  22800. {
  22801. arguments = {
  22802. {
  22803. name = "t",
  22804. type = "table",
  22805. description = "A table with color components."
  22806. },
  22807. {
  22808. name = "layer",
  22809. type = "number",
  22810. description = "The index of the first layer to clear.",
  22811. default = "1"
  22812. },
  22813. {
  22814. name = "layerCount",
  22815. type = "number",
  22816. description = "The number of layers to clear. If nil, clears the rest of the layers.",
  22817. default = "nil"
  22818. },
  22819. {
  22820. name = "mipmap",
  22821. type = "number",
  22822. description = "The index of the first mipmap to clear.",
  22823. default = "1"
  22824. },
  22825. {
  22826. name = "mipmapCount",
  22827. type = "number",
  22828. description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
  22829. default = "nil"
  22830. }
  22831. },
  22832. returns = {}
  22833. },
  22834. {
  22835. arguments = {
  22836. {
  22837. name = "v3",
  22838. type = "Vec3",
  22839. description = "A vec3 with the clear color."
  22840. },
  22841. {
  22842. name = "layer",
  22843. type = "number",
  22844. description = "The index of the first layer to clear.",
  22845. default = "1"
  22846. },
  22847. {
  22848. name = "layerCount",
  22849. type = "number",
  22850. description = "The number of layers to clear. If nil, clears the rest of the layers.",
  22851. default = "nil"
  22852. },
  22853. {
  22854. name = "mipmap",
  22855. type = "number",
  22856. description = "The index of the first mipmap to clear.",
  22857. default = "1"
  22858. },
  22859. {
  22860. name = "mipmapCount",
  22861. type = "number",
  22862. description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
  22863. default = "nil"
  22864. }
  22865. },
  22866. returns = {}
  22867. },
  22868. {
  22869. arguments = {
  22870. {
  22871. name = "v4",
  22872. type = "Vec4",
  22873. description = "A vec4 with the clear color."
  22874. },
  22875. {
  22876. name = "layer",
  22877. type = "number",
  22878. description = "The index of the first layer to clear.",
  22879. default = "1"
  22880. },
  22881. {
  22882. name = "layerCount",
  22883. type = "number",
  22884. description = "The number of layers to clear. If nil, clears the rest of the layers.",
  22885. default = "nil"
  22886. },
  22887. {
  22888. name = "mipmap",
  22889. type = "number",
  22890. description = "The index of the first mipmap to clear.",
  22891. default = "1"
  22892. },
  22893. {
  22894. name = "mipmapCount",
  22895. type = "number",
  22896. description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
  22897. default = "nil"
  22898. }
  22899. },
  22900. returns = {}
  22901. }
  22902. }
  22903. },
  22904. {
  22905. name = "generateMipmaps",
  22906. tag = "texture-transfer",
  22907. summary = "Regenerate mipmaps for a Texture.",
  22908. description = "Regenerates mipmap levels of a texture. This downscales pixels from the texture to progressively smaller sizes and saves them. If the texture is drawn at a smaller scale later, the mipmaps are used, which smooths out the appearance and improves performance.",
  22909. key = "Texture:generateMipmaps",
  22910. module = "lovr.graphics",
  22911. notes = "Mipmaps will automatically be regenerated for textures after rendering to them in a `Pass`. This can be disabled by rendering to a single-level texture view instead.\n\nThe texture must have been created with the `transfer` usage to mipmap it.\n\nThe texture can not be multisampled.\n\nTexture views can not currently be mipmapped.",
  22912. related = {
  22913. "Texture:setPixels",
  22914. "Texture:getMipmapCount"
  22915. },
  22916. variants = {
  22917. {
  22918. arguments = {
  22919. {
  22920. name = "base",
  22921. type = "number",
  22922. description = "The base mipmap level which will be used to generate subsequent mipmaps.",
  22923. default = "1"
  22924. },
  22925. {
  22926. name = "count",
  22927. type = "number",
  22928. description = "The number of mipmap levels to generate. If nil, the rest of the mipmaps will be generated.",
  22929. default = "nil"
  22930. }
  22931. },
  22932. returns = {}
  22933. }
  22934. }
  22935. },
  22936. {
  22937. name = "getDimensions",
  22938. tag = "texture-metadata",
  22939. summary = "Get the dimensions of the Texture.",
  22940. description = "Returns the width, height, and depth of the Texture.",
  22941. key = "Texture:getDimensions",
  22942. module = "lovr.graphics",
  22943. related = {
  22944. "Texture:getWidth",
  22945. "Texture:getHeight",
  22946. "Texture:getLayerCount"
  22947. },
  22948. variants = {
  22949. {
  22950. arguments = {},
  22951. returns = {
  22952. {
  22953. name = "width",
  22954. type = "number",
  22955. description = "The width of the Texture."
  22956. },
  22957. {
  22958. name = "height",
  22959. type = "number",
  22960. description = "The height of the Texture."
  22961. },
  22962. {
  22963. name = "layers",
  22964. type = "number",
  22965. description = "The number of layers in the Texture."
  22966. }
  22967. }
  22968. }
  22969. }
  22970. },
  22971. {
  22972. name = "getFormat",
  22973. tag = "texture-metadata",
  22974. summary = "Get the format of the Texture.",
  22975. description = "Returns the format of the texture.",
  22976. key = "Texture:getFormat",
  22977. module = "lovr.graphics",
  22978. variants = {
  22979. {
  22980. arguments = {},
  22981. returns = {
  22982. {
  22983. name = "format",
  22984. type = "TextureFormat",
  22985. description = "The format of the Texture."
  22986. }
  22987. }
  22988. }
  22989. }
  22990. },
  22991. {
  22992. name = "getHeight",
  22993. tag = "texture-metadata",
  22994. summary = "Get the height of the Texture, in pixels.",
  22995. description = "Returns the height of the Texture, in pixels.",
  22996. key = "Texture:getHeight",
  22997. module = "lovr.graphics",
  22998. related = {
  22999. "Texture:getWidth",
  23000. "Texture:getLayerCount",
  23001. "Texture:getDimensions"
  23002. },
  23003. variants = {
  23004. {
  23005. arguments = {},
  23006. returns = {
  23007. {
  23008. name = "height",
  23009. type = "number",
  23010. description = "The height of the Texture, in pixels."
  23011. }
  23012. }
  23013. }
  23014. }
  23015. },
  23016. {
  23017. name = "getLayerCount",
  23018. tag = "texture-metadata",
  23019. summary = "Get the layer count of the Texture.",
  23020. description = "Returns the layer count of the Texture. 2D textures always have 1 layer and cubemaps always have 6 layers. 3D and array textures have a variable number of layers.",
  23021. key = "Texture:getLayerCount",
  23022. module = "lovr.graphics",
  23023. related = {
  23024. "Texture:getWidth",
  23025. "Texture:getHeight",
  23026. "Texture:getDimensions"
  23027. },
  23028. variants = {
  23029. {
  23030. arguments = {},
  23031. returns = {
  23032. {
  23033. name = "layers",
  23034. type = "number",
  23035. description = "The layer count of the Texture."
  23036. }
  23037. }
  23038. }
  23039. }
  23040. },
  23041. {
  23042. name = "getMipmapCount",
  23043. tag = "texture-metadata",
  23044. summary = "Get the number of mipmap levels in the Texture.",
  23045. description = "Returns the number of mipmap levels in the Texture.",
  23046. key = "Texture:getMipmapCount",
  23047. module = "lovr.graphics",
  23048. related = {
  23049. "lovr.graphics.newTexture",
  23050. "Sampler:getMipmapRange",
  23051. "Texture:generateMipmaps"
  23052. },
  23053. variants = {
  23054. {
  23055. arguments = {},
  23056. returns = {
  23057. {
  23058. name = "mipmaps",
  23059. type = "number",
  23060. description = "The number of mipmap levels in the Texture."
  23061. }
  23062. }
  23063. }
  23064. }
  23065. },
  23066. {
  23067. name = "getParent",
  23068. tag = "texture-view",
  23069. summary = "Get the parent of a texture view.",
  23070. description = "Returns the parent of a Texture view, which is the Texture that it references. Returns `nil` if the Texture is not a view.",
  23071. key = "Texture:getParent",
  23072. module = "lovr.graphics",
  23073. related = {
  23074. "Texture:isView",
  23075. "Texture:newView"
  23076. },
  23077. variants = {
  23078. {
  23079. arguments = {},
  23080. returns = {
  23081. {
  23082. name = "parent",
  23083. type = "Texture",
  23084. description = "The parent of the texture, or `nil` if the texture is not a view."
  23085. }
  23086. }
  23087. }
  23088. }
  23089. },
  23090. {
  23091. name = "getPixels",
  23092. tag = "texture-transfer",
  23093. summary = "Get the pixels of the Texture.",
  23094. description = "Creates and returns a new `Image` object with the current pixels of the Texture. This function is very very slow because it stalls the CPU until the download is complete. It should only be used for debugging, non-interactive scripts, etc. For an asynchronous version that doesn't stall the CPU, see `Texture:newReadback`.",
  23095. key = "Texture:getPixels",
  23096. module = "lovr.graphics",
  23097. notes = "The texture must have been created with the `transfer` usage.\n\nMultisampled textures can not be read back.\n\nIt is not currently possible to read back a texture view.",
  23098. related = {
  23099. "Texture:newReadback"
  23100. },
  23101. variants = {
  23102. {
  23103. arguments = {
  23104. {
  23105. name = "x",
  23106. type = "number",
  23107. description = "The x offset of the region to download.",
  23108. default = "0"
  23109. },
  23110. {
  23111. name = "y",
  23112. type = "number",
  23113. description = "The y offset of the region to download.",
  23114. default = "0"
  23115. },
  23116. {
  23117. name = "layer",
  23118. type = "number",
  23119. description = "The index of the layer to download.",
  23120. default = "1"
  23121. },
  23122. {
  23123. name = "mipmap",
  23124. type = "number",
  23125. description = "The index of the mipmap level to download.",
  23126. default = "1"
  23127. },
  23128. {
  23129. name = "width",
  23130. type = "number",
  23131. description = "The width of the pixel rectangle to download. If nil, the \"rest\" of the width will be used, based on the texture width and x offset.",
  23132. default = "nil"
  23133. },
  23134. {
  23135. name = "height",
  23136. type = "number",
  23137. description = "The height of the pixel rectangle to download. If nil, the \"rest\" of the height will be used, based on the texture height and y offset.",
  23138. default = "nil"
  23139. }
  23140. },
  23141. returns = {
  23142. {
  23143. name = "image",
  23144. type = "Image",
  23145. description = "The new image with the pixels."
  23146. }
  23147. }
  23148. }
  23149. }
  23150. },
  23151. {
  23152. name = "getSampleCount",
  23153. tag = "texture-metadata",
  23154. summary = "Get the number of MSAA samples in the Texture.",
  23155. description = "Returns the number of samples in the texture. Multiple samples are used for multisample antialiasing when rendering to the texture. Currently, the sample count is either 1 (not antialiased) or 4 (antialiased).",
  23156. key = "Texture:getSampleCount",
  23157. module = "lovr.graphics",
  23158. related = {
  23159. "lovr.graphics.newTexture",
  23160. "Pass:getSampleCount"
  23161. },
  23162. variants = {
  23163. {
  23164. arguments = {},
  23165. returns = {
  23166. {
  23167. name = "samples",
  23168. type = "number",
  23169. description = "The number of samples in the Texture."
  23170. }
  23171. }
  23172. }
  23173. }
  23174. },
  23175. {
  23176. name = "getType",
  23177. tag = "texture-metadata",
  23178. summary = "Get the type of the Texture.",
  23179. description = "Returns the type of the texture.",
  23180. key = "Texture:getType",
  23181. module = "lovr.graphics",
  23182. variants = {
  23183. {
  23184. arguments = {},
  23185. returns = {
  23186. {
  23187. name = "type",
  23188. type = "TextureType",
  23189. description = "The type of the Texture."
  23190. }
  23191. }
  23192. }
  23193. }
  23194. },
  23195. {
  23196. name = "getWidth",
  23197. tag = "texture-metadata",
  23198. summary = "Get the width of the Texture, in pixels.",
  23199. description = "Returns the width of the Texture, in pixels.",
  23200. key = "Texture:getWidth",
  23201. module = "lovr.graphics",
  23202. related = {
  23203. "Texture:getHeight",
  23204. "Texture:getLayerCount",
  23205. "Texture:getDimensions"
  23206. },
  23207. variants = {
  23208. {
  23209. arguments = {},
  23210. returns = {
  23211. {
  23212. name = "width",
  23213. type = "number",
  23214. description = "The width of the Texture, in pixels."
  23215. }
  23216. }
  23217. }
  23218. }
  23219. },
  23220. {
  23221. name = "hasUsage",
  23222. tag = "texture-metadata",
  23223. summary = "Check if a Texture was created with a set of usage flags.",
  23224. description = "Returns whether a Texture was created with a set of `TextureUsage` flags. Usage flags are specified when the Texture is created, and restrict what you can do with a Texture object. By default, only the `sample` usage is enabled. Applying a smaller set of usage flags helps LÖVR optimize things better.",
  23225. key = "Texture:hasUsage",
  23226. module = "lovr.graphics",
  23227. related = {
  23228. "lovr.graphics.newTexture"
  23229. },
  23230. variants = {
  23231. {
  23232. arguments = {
  23233. {
  23234. name = "...",
  23235. type = "TextureUsage",
  23236. description = "One or more usage flags."
  23237. }
  23238. },
  23239. returns = {
  23240. {
  23241. name = "supported",
  23242. type = "boolean",
  23243. description = "Whether the Texture has all the provided usage flags."
  23244. }
  23245. }
  23246. }
  23247. }
  23248. },
  23249. {
  23250. name = "isView",
  23251. tag = "texture-view",
  23252. summary = "Check if a Texture is a texture view.",
  23253. description = "Returns whether a Texture is a texture view, created with `Texture:newView`.",
  23254. key = "Texture:isView",
  23255. module = "lovr.graphics",
  23256. related = {
  23257. "Texture:getParent",
  23258. "Texture:newView"
  23259. },
  23260. variants = {
  23261. {
  23262. arguments = {},
  23263. returns = {
  23264. {
  23265. name = "view",
  23266. type = "boolean",
  23267. description = "Whether the Texture is a texture view."
  23268. }
  23269. }
  23270. }
  23271. }
  23272. },
  23273. {
  23274. name = "newReadback",
  23275. tag = "texture-transfer",
  23276. summary = "Read back the contents of the Texture asynchronously.",
  23277. description = "Creates and returns a new `Readback` that will download the pixels in the Texture from VRAM. Once the readback is complete, `Readback:getImage` returns an `Image` with a CPU copy of the data.",
  23278. key = "Texture:newReadback",
  23279. module = "lovr.graphics",
  23280. examples = {
  23281. {
  23282. description = "Take a screenshot when pressing a key. This uses an intermediate texture and render pass, to work around the fact that the window/headset textures don't support transfers.",
  23283. code = "local screenshot = false\nlocal readback\nlocal texture\nlocal pass\n\nfunction lovr.keypressed(key)\n if key == 'p' then screenshot = true end\nend\n\nfunction lovr.load()\n local width, height = lovr.headset.getDisplayDimensions()\n\n texture = lovr.graphics.newTexture(width, height, {\n usage = { 'render', 'transfer', 'sample' }\n })\n\n pass = lovr.graphics.newPass(texture)\nend\n\nfunction lovr.update()\n pass:reset()\n for i = 1, lovr.headset.getViewCount() do\n pass:setViewPose(i, lovr.headset.getViewPose(i))\n pass:setProjection(i, lovr.headset.getViewAngles(i))\n end\n pass:text('hellooo', 0, 1.7, -1, .1)\n lovr.graphics.submit(pass)\n\n if screenshot and not readback then\n readback = texture:newReadback()\n screenshot = false\n end\n\n if readback and readback:isComplete() then\n local filename = 'screenshot.png'\n lovr.filesystem.write(filename, readback:getImage():encode())\n print('saved screenshot to ' .. filename)\n readback = nil\n end\nend\n\nfunction lovr.draw(p)\n p:fill(texture)\nend"
  23284. }
  23285. },
  23286. notes = "The texture must have been created with the `transfer` usage.\n\nMultisampled textures can not be read back.\n\nIt is not currently possible to read back a texture view.",
  23287. related = {
  23288. "Texture:getPixels",
  23289. "Buffer:newReadback"
  23290. },
  23291. variants = {
  23292. {
  23293. arguments = {
  23294. {
  23295. name = "x",
  23296. type = "number",
  23297. description = "The x offset of the region to download.",
  23298. default = "0"
  23299. },
  23300. {
  23301. name = "y",
  23302. type = "number",
  23303. description = "The y offset of the region to download.",
  23304. default = "0"
  23305. },
  23306. {
  23307. name = "layer",
  23308. type = "number",
  23309. description = "The index of the layer to download.",
  23310. default = "1"
  23311. },
  23312. {
  23313. name = "mipmap",
  23314. type = "number",
  23315. description = "The index of the mipmap level to download.",
  23316. default = "1"
  23317. },
  23318. {
  23319. name = "width",
  23320. type = "number",
  23321. description = "The width of the pixel rectangle to download. If nil, the \"rest\" of the width will be used, based on the texture width and x offset.",
  23322. default = "nil"
  23323. },
  23324. {
  23325. name = "height",
  23326. type = "number",
  23327. description = "The height of the pixel rectangle to download. If nil, the \"rest\" of the height will be used, based on the texture height and y offset.",
  23328. default = "nil"
  23329. }
  23330. },
  23331. returns = {
  23332. {
  23333. name = "readback",
  23334. type = "Readback",
  23335. description = "A new Readback object."
  23336. }
  23337. }
  23338. }
  23339. }
  23340. },
  23341. {
  23342. name = "newView",
  23343. tag = "texture-view",
  23344. summary = "Create a texture view referencing a parent Texture.",
  23345. description = "Creates a new Texture view. A texture view does not store any pixels on its own, but instead uses the pixel data of a \"parent\" Texture object. The width, height, format, sample count, and usage flags all match the parent. The view may have a different `TextureType` from the parent, and it may reference a subset of the parent texture's layers and mipmap levels.\n\nTexture views can be used as render targets in a render pass and they can be bound to Shaders. They can not currently be used for transfer operations. They are used for:\n\n- Reinterpretation of texture contents. For example, a cubemap can be treated as\n an array texture.\n- Rendering to a particular image or mipmap level of a texture.\n- Binding a particular image or mipmap level to a shader.",
  23346. key = "Texture:newView",
  23347. module = "lovr.graphics",
  23348. related = {
  23349. "Texture:isView",
  23350. "Texture:getParent",
  23351. "lovr.graphics.newTexture"
  23352. },
  23353. variants = {
  23354. {
  23355. description = "Create a 2D texture view referencing a single layer and mipmap.",
  23356. arguments = {
  23357. {
  23358. name = "layer",
  23359. type = "number",
  23360. description = "The index of the first layer in the view.",
  23361. default = "1"
  23362. },
  23363. {
  23364. name = "mipmap",
  23365. type = "number",
  23366. description = "The index of the first mipmap in the view.",
  23367. default = "1"
  23368. }
  23369. },
  23370. returns = {
  23371. {
  23372. name = "view",
  23373. type = "Texture",
  23374. description = "The new texture view."
  23375. }
  23376. }
  23377. },
  23378. {
  23379. description = "Create a texture view with an explicit type, layer range, and mipmap range.",
  23380. arguments = {
  23381. {
  23382. name = "type",
  23383. type = "TextureType",
  23384. description = "The texture type of the view."
  23385. },
  23386. {
  23387. name = "layer",
  23388. type = "number",
  23389. description = "The index of the first layer in the view.",
  23390. default = "1"
  23391. },
  23392. {
  23393. name = "layerCount",
  23394. type = "number",
  23395. description = "The number of layers in the view, or `nil` to use all remaining layers.",
  23396. default = "nil"
  23397. },
  23398. {
  23399. name = "mipmap",
  23400. type = "number",
  23401. description = "The index of the first mipmap in the view.",
  23402. default = "1"
  23403. },
  23404. {
  23405. name = "mipmapCount",
  23406. type = "number",
  23407. description = "The number of mipmaps in the view, or `nil` to use all remaining mipmaps.",
  23408. default = "nil"
  23409. }
  23410. },
  23411. returns = {
  23412. {
  23413. name = "view",
  23414. type = "Texture",
  23415. description = "The new texture view."
  23416. }
  23417. }
  23418. }
  23419. }
  23420. },
  23421. {
  23422. name = "setPixels",
  23423. tag = "texture-transfer",
  23424. summary = "Replace pixels in the Texture.",
  23425. description = "Sets pixels in the texture. The source data can be an `Image` with the pixels to upload, or another `Texture` object to copy from.",
  23426. key = "Texture:setPixels",
  23427. module = "lovr.graphics",
  23428. notes = "Note that calling `Texture:setPixels(Image)` will only update the first mipmap of the texture, leaving the other mipmaps as-is. You may want to regenerate the texture's mipmaps afterwards by calling `Texture:generateMipmaps`, or disable mipmaps entirely by setting `mipmaps` to false in `lovr.graphics.newTexture`.\n\nThe destination and source textures must have been created with the `transfer` usage.\n\nMultisampled textures can not be copied.\n\nIt is not currently possible to copy to or from a texture view.\n\nCopying between textures requires them to have the same format.\n\nWhen using different region sizes in a texture-to-texture copy:\n\n- It is not possible to mix 3D with non-3D textures.\n- Not every texture format is supported, use `lovr.graphics.isFormatSupported` to check.",
  23429. related = {
  23430. "Texture:newReadback",
  23431. "Texture:generateMipmaps",
  23432. "Image:paste"
  23433. },
  23434. variants = {
  23435. {
  23436. arguments = {
  23437. {
  23438. name = "image",
  23439. type = "Image",
  23440. description = "The image to copy to the texture."
  23441. },
  23442. {
  23443. name = "dstx",
  23444. type = "number",
  23445. description = "The x offset to copy to.",
  23446. default = "0"
  23447. },
  23448. {
  23449. name = "dsty",
  23450. type = "number",
  23451. description = "The y offset to copy to.",
  23452. default = "0"
  23453. },
  23454. {
  23455. name = "dstlayer",
  23456. type = "number",
  23457. description = "The index of the layer to copy to.",
  23458. default = "1"
  23459. },
  23460. {
  23461. name = "dstmipmap",
  23462. type = "number",
  23463. description = "The index of the mipmap level to copy to.",
  23464. default = "1"
  23465. },
  23466. {
  23467. name = "srcx",
  23468. type = "number",
  23469. description = "The x offset to copy from.",
  23470. default = "0"
  23471. },
  23472. {
  23473. name = "srcy",
  23474. type = "number",
  23475. description = "The y offset to copy from.",
  23476. default = "0"
  23477. },
  23478. {
  23479. name = "srclayer",
  23480. type = "number",
  23481. description = "The index of the layer to copy from.",
  23482. default = "1"
  23483. },
  23484. {
  23485. name = "srcmipmap",
  23486. type = "number",
  23487. description = "The index of the mipmap level to copy from.",
  23488. default = "1"
  23489. },
  23490. {
  23491. name = "width",
  23492. type = "number",
  23493. description = "The width of the region of pixels to copy. If nil, the maximum possible width will be used, based on the widths of the source/destination and the offset parameters.",
  23494. default = "nil"
  23495. },
  23496. {
  23497. name = "height",
  23498. type = "number",
  23499. description = "The height of the region of pixels to copy. If nil, the maximum possible height will be used, based on the heights of the source/destination and the offset parameters.",
  23500. default = "nil"
  23501. },
  23502. {
  23503. name = "layers",
  23504. type = "number",
  23505. description = "The number of layers to copy. If nil, copies as many layers as possible.",
  23506. default = "nil"
  23507. }
  23508. },
  23509. returns = {}
  23510. },
  23511. {
  23512. arguments = {
  23513. {
  23514. name = "texture",
  23515. type = "Texture",
  23516. description = "The texture to copy from."
  23517. },
  23518. {
  23519. name = "dstx",
  23520. type = "number",
  23521. description = "The x offset to copy to.",
  23522. default = "0"
  23523. },
  23524. {
  23525. name = "dsty",
  23526. type = "number",
  23527. description = "The y offset to copy to.",
  23528. default = "0"
  23529. },
  23530. {
  23531. name = "dstlayer",
  23532. type = "number",
  23533. description = "The index of the layer to copy to.",
  23534. default = "1"
  23535. },
  23536. {
  23537. name = "dstmipmap",
  23538. type = "number",
  23539. description = "The index of the mipmap level to copy to.",
  23540. default = "1"
  23541. },
  23542. {
  23543. name = "srcx",
  23544. type = "number",
  23545. description = "The x offset to copy from.",
  23546. default = "0"
  23547. },
  23548. {
  23549. name = "srcy",
  23550. type = "number",
  23551. description = "The y offset to copy from.",
  23552. default = "0"
  23553. },
  23554. {
  23555. name = "srclayer",
  23556. type = "number",
  23557. description = "The index of the layer to copy from.",
  23558. default = "1"
  23559. },
  23560. {
  23561. name = "srcmipmap",
  23562. type = "number",
  23563. description = "The index of the mipmap level to copy from.",
  23564. default = "1"
  23565. },
  23566. {
  23567. name = "width",
  23568. type = "number",
  23569. description = "The width of the region of pixels to copy. If nil, the maximum possible width will be used, based on the widths of the source/destination and the offset parameters.",
  23570. default = "nil"
  23571. },
  23572. {
  23573. name = "height",
  23574. type = "number",
  23575. description = "The height of the region of pixels to copy. If nil, the maximum possible height will be used, based on the heights of the source/destination and the offset parameters.",
  23576. default = "nil"
  23577. },
  23578. {
  23579. name = "layers",
  23580. type = "number",
  23581. description = "The number of layers to copy. If nil, copies as many layers as possible.",
  23582. default = "nil"
  23583. },
  23584. {
  23585. name = "srcwidth",
  23586. type = "number",
  23587. description = "The width of the region in the source texture to copy. If it doesn't match `width`, the copy will be scaled up or down to fit.",
  23588. default = "width"
  23589. },
  23590. {
  23591. name = "srcheight",
  23592. type = "number",
  23593. description = "The height of the region in the source texture to copy. If it doesn't match `height`, the copy will be scaled up or down to fit.",
  23594. default = "width"
  23595. },
  23596. {
  23597. name = "srcdepth",
  23598. type = "number",
  23599. description = "The depth of the region in the source texture to copy (`3d` textures only).",
  23600. default = "layers"
  23601. },
  23602. {
  23603. name = "filter",
  23604. type = "FilterMode",
  23605. description = "The filtering mode used to scale the copy when the source and destination sizes don't match.",
  23606. default = "'linear'"
  23607. }
  23608. },
  23609. returns = {}
  23610. }
  23611. }
  23612. }
  23613. },
  23614. sections = {
  23615. {
  23616. name = "Metadata",
  23617. tag = "texture-metadata"
  23618. },
  23619. {
  23620. name = "Transfers",
  23621. tag = "texture-transfer"
  23622. },
  23623. {
  23624. name = "Texture Views",
  23625. tag = "texture-view"
  23626. }
  23627. }
  23628. }
  23629. },
  23630. sections = {
  23631. {
  23632. name = "Objects",
  23633. tag = "graphics-objects"
  23634. },
  23635. {
  23636. name = "Global State",
  23637. tag = "graphics-global"
  23638. },
  23639. {
  23640. name = "Work Submission",
  23641. tag = "work-submission",
  23642. description = "The only way to get the GPU to do anything is to submit `Pass` objects to it. LÖVR submits the default pass automatically at the end of `lovr.draw`, but work can also be submitted manually."
  23643. },
  23644. {
  23645. name = "System Info",
  23646. tag = "graphics-misc",
  23647. description = "Information about the GPU hardware and the features it supports."
  23648. }
  23649. }
  23650. },
  23651. {
  23652. name = "headset",
  23653. tag = "modules",
  23654. summary = "Connects to VR hardware.",
  23655. description = "The `lovr.headset` module is where all the magical VR functionality is. With it, you can access connected VR hardware and get information about the available space the player has. Note that all units are reported in meters. Position `(0, 0, 0)` is on the floor in the center of the play area.",
  23656. key = "lovr.headset",
  23657. enums = {
  23658. {
  23659. name = "Device",
  23660. description = "Different types of input devices supported by the `lovr.headset` module.",
  23661. key = "Device",
  23662. module = "lovr.headset",
  23663. notes = "The `grip` pose is used to render an object held in the user's hand. It's positioned at the surface of the palm. The X axis of the grip orientation is perpendicular to the palm, pointing away from the left palm or into the right palm. If you imagine the hand holding a stick, the Z axis will be parallel to the stick.\n\n<img src=\"/img/grip.svg\" width=\"600\" alt=\"Hand Grip Pose\" class=\"flat\"/>\n\n*Image from the [OpenXR Specification](https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#_grip_pose)*\n\n---\n\nThe `point` pose is used to aim or point at objects. It's usually positioned slightly in front of the hand or controller, and is oriented so the -Z axis points in a natural forward direction.\n\n<img src=\"/img/aim.svg\" width=\"600\" alt=\"Hand Point Pose\" class=\"flat\"/>\n\n*Image from the [OpenXR Specification](https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#_aim_pose)*\n\n---\n\nThe `pinch` pose is a stable point between the thumb and index finger on a hand, or a point slightly in front of a controller. The -Z axis will point forward, away from the hand. It's good for precise, close-range interaction.\n\n<img src=\"/img/pinch.svg\" width=\"600\" alt=\"Hand Pinch Pose\" class=\"flat\"/>\n\n*Image from the [OpenXR Specification](https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#_pinch_pose)*\n\n---\n\nThe `poke` pose is a position located at the tip of the index finger, or a point slightly in front of a controller. The -Z axis will point forward out of the tip of the finger, the +Y axis will be perpendicular to the fingernail.\n\n<img src=\"/img/poke.svg\" width=\"600\" alt=\"Hand Poke Pose\" class=\"flat\"/>\n\n*Image from the [OpenXR Specification](https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#_poke_pose)*\n\n---\n\nThese \"hand pose devices\" do not report any button input with e.g. `lovr.headset.isDown`. The main `hand/left` and `hand/right` devices should be used for buttons and haptics.",
  23664. related = {
  23665. "DeviceAxis",
  23666. "DeviceButton",
  23667. "lovr.headset.getPose",
  23668. "lovr.headset.getPosition",
  23669. "lovr.headset.getOrientation",
  23670. "lovr.headset.getVelocity",
  23671. "lovr.headset.getAngularVelocity",
  23672. "lovr.headset.getSkeleton",
  23673. "lovr.headset.isTracked",
  23674. "lovr.headset.isDown",
  23675. "lovr.headset.isTouched",
  23676. "lovr.headset.wasPressed",
  23677. "lovr.headset.wasReleased",
  23678. "lovr.headset.getAxis",
  23679. "lovr.headset.vibrate",
  23680. "lovr.headset.animate"
  23681. },
  23682. values = {
  23683. {
  23684. name = "head",
  23685. description = "The headset."
  23686. },
  23687. {
  23688. name = "floor",
  23689. description = "A device representing the floor, at the center of the play area. The pose of this device in physical space will remain constant, even after recentering."
  23690. },
  23691. {
  23692. name = "left",
  23693. description = "A shorthand for hand/left."
  23694. },
  23695. {
  23696. name = "right",
  23697. description = "A shorthand for hand/right."
  23698. },
  23699. {
  23700. name = "hand/left",
  23701. description = "The left hand."
  23702. },
  23703. {
  23704. name = "hand/right",
  23705. description = "The right hand."
  23706. },
  23707. {
  23708. name = "hand/left/grip",
  23709. description = "The left hand grip pose, used for held objects."
  23710. },
  23711. {
  23712. name = "hand/right/grip",
  23713. description = "The right hand grip pose, used for held objects."
  23714. },
  23715. {
  23716. name = "hand/left/point",
  23717. description = "The left hand pointer pose, used for pointing or aiming."
  23718. },
  23719. {
  23720. name = "hand/right/point",
  23721. description = "The right hand pointer pose, used for pointing or aiming."
  23722. },
  23723. {
  23724. name = "hand/left/pinch",
  23725. description = "The left hand pinch pose between the thumb and index fingers, used for precise, close-range interactions."
  23726. },
  23727. {
  23728. name = "hand/right/pinch",
  23729. description = "The right hand pinch pose between the thumb and index fingers, used for precise, close-range interactions."
  23730. },
  23731. {
  23732. name = "hand/left/poke",
  23733. description = "The left hand poke pose, on the tip of the index finger or in front of a controller."
  23734. },
  23735. {
  23736. name = "hand/right/poke",
  23737. description = "The right hand poke pose, on the tip of the index finger or in front of a controller."
  23738. },
  23739. {
  23740. name = "elbow/left",
  23741. description = "A device tracking the left elbow."
  23742. },
  23743. {
  23744. name = "elbow/right",
  23745. description = "A device tracking the right elbow."
  23746. },
  23747. {
  23748. name = "shoulder/left",
  23749. description = "A device tracking the left shoulder."
  23750. },
  23751. {
  23752. name = "shoulder/right",
  23753. description = "A device tracking the right shoulder."
  23754. },
  23755. {
  23756. name = "chest",
  23757. description = "A device tracking the chest."
  23758. },
  23759. {
  23760. name = "waist",
  23761. description = "A device tracking the waist."
  23762. },
  23763. {
  23764. name = "knee/left",
  23765. description = "A device tracking the left knee."
  23766. },
  23767. {
  23768. name = "knee/right",
  23769. description = "A device tracking the right knee."
  23770. },
  23771. {
  23772. name = "foot/left",
  23773. description = "A device tracking the left foot or ankle."
  23774. },
  23775. {
  23776. name = "foot/right",
  23777. description = "A device tracking the right foot or ankle."
  23778. },
  23779. {
  23780. name = "camera",
  23781. description = "A camera device, often used for recording \"mixed reality\" footage."
  23782. },
  23783. {
  23784. name = "keyboard",
  23785. description = "A tracked keyboard."
  23786. },
  23787. {
  23788. name = "eye/left",
  23789. description = "The left eye."
  23790. },
  23791. {
  23792. name = "eye/right",
  23793. description = "The right eye."
  23794. },
  23795. {
  23796. name = "eye/gaze",
  23797. description = "The combined eye gaze pose. The position is between the eyes. The orientation aligns the\n-Z axis in the direction the user is looking and the +Y axis to the head's \"up\" vector. This provides more accurate eye tracking information compared to using the individual eye devices."
  23798. }
  23799. }
  23800. },
  23801. {
  23802. name = "DeviceAxis",
  23803. description = "Axes on an input device.",
  23804. key = "DeviceAxis",
  23805. module = "lovr.headset",
  23806. related = {
  23807. "lovr.headset.getAxis",
  23808. "DeviceButton"
  23809. },
  23810. values = {
  23811. {
  23812. name = "trigger",
  23813. description = "A trigger (1D)."
  23814. },
  23815. {
  23816. name = "thumbstick",
  23817. description = "A thumbstick (2D)."
  23818. },
  23819. {
  23820. name = "touchpad",
  23821. description = "A touchpad (2D)."
  23822. },
  23823. {
  23824. name = "grip",
  23825. description = "A grip button or grab gesture (1D)."
  23826. }
  23827. }
  23828. },
  23829. {
  23830. name = "DeviceButton",
  23831. description = "Buttons on an input device.",
  23832. key = "DeviceButton",
  23833. module = "lovr.headset",
  23834. values = {
  23835. {
  23836. name = "trigger",
  23837. description = "The trigger button."
  23838. },
  23839. {
  23840. name = "thumbstick",
  23841. description = "The thumbstick."
  23842. },
  23843. {
  23844. name = "touchpad",
  23845. description = "The touchpad."
  23846. },
  23847. {
  23848. name = "grip",
  23849. description = "The grip button."
  23850. },
  23851. {
  23852. name = "menu",
  23853. description = "The menu button."
  23854. },
  23855. {
  23856. name = "a",
  23857. description = "The A button."
  23858. },
  23859. {
  23860. name = "b",
  23861. description = "The B button."
  23862. },
  23863. {
  23864. name = "x",
  23865. description = "The X button."
  23866. },
  23867. {
  23868. name = "y",
  23869. description = "The Y button."
  23870. },
  23871. {
  23872. name = "proximity",
  23873. description = "The proximity sensor on a headset."
  23874. }
  23875. }
  23876. },
  23877. {
  23878. name = "HeadsetDriver",
  23879. summary = "VR APIs.",
  23880. description = "These are all of the supported VR APIs that LÖVR can use to power the lovr.headset module. You can change the order of headset drivers using `lovr.conf` to prefer or exclude specific VR APIs.\n\nAt startup, LÖVR searches through the list of drivers in order.",
  23881. key = "HeadsetDriver",
  23882. module = "lovr.headset",
  23883. values = {
  23884. {
  23885. name = "desktop",
  23886. description = "A VR simulator using keyboard/mouse."
  23887. },
  23888. {
  23889. name = "openxr",
  23890. description = "OpenXR."
  23891. }
  23892. }
  23893. },
  23894. {
  23895. name = "HeadsetOrigin",
  23896. summary = "Different types of coordinate space origins.",
  23897. description = "Represents the different types of origins for coordinate spaces. An origin of \"floor\" means that the origin is on the floor in the middle of a room-scale play area. An origin of \"head\" means that no positional tracking is available, and consequently the origin is always at the position of the headset.",
  23898. key = "HeadsetOrigin",
  23899. module = "lovr.headset",
  23900. values = {
  23901. {
  23902. name = "head",
  23903. description = "The origin is at the head."
  23904. },
  23905. {
  23906. name = "floor",
  23907. description = "The origin is on the floor."
  23908. }
  23909. }
  23910. },
  23911. {
  23912. name = "PassthroughMode",
  23913. summary = "Passthrough modes.",
  23914. description = "Different passthrough modes, set using `lovr.headset.setPassthrough`.\n\nFor best results, the `blend` and `add` modes should use a transparent background color, which can be changed with `lovr.graphics.setBackgroundColor`.",
  23915. key = "PassthroughMode",
  23916. module = "lovr.headset",
  23917. related = {
  23918. "lovr.headset.getPassthrough",
  23919. "lovr.headset.setPassthrough",
  23920. "lovr.headset.getPassthroughModes"
  23921. },
  23922. values = {
  23923. {
  23924. name = "opaque",
  23925. description = "The headset display will not blend with anything behind it. Most VR headsets use this mode."
  23926. },
  23927. {
  23928. name = "blend",
  23929. description = "The real world will blend with the headset display using the alpha channel. This is supported on VR headsets with camera passthrough, as well as some AR displays."
  23930. },
  23931. {
  23932. name = "add",
  23933. description = "Color values from virtual content will be added to the real world. This is the most common mode used for AR. Notably, black pixels will not show up at all."
  23934. }
  23935. }
  23936. }
  23937. },
  23938. functions = {
  23939. {
  23940. name = "animate",
  23941. tag = "controller-models",
  23942. summary = "Animate a model to match its Device input state.",
  23943. description = "Animates a model to match its input state. The buttons and joysticks on a controller will move as they're pressed/moved and hand models will move to match hand tracking joints.\n\nThe model must have been created using `lovr.headset.newModel` with the `animated` flag set to `true`.",
  23944. key = "lovr.headset.animate",
  23945. module = "lovr.headset",
  23946. examples = {
  23947. {
  23948. code = "function lovr.load()\n models = {\n left = lovr.headset.newModel('hand/left'),\n right = lovr.headset.newModel('hand/right')\n }\nend\n\nfunction lovr.draw(pass)\n for hand, model in pairs(models) do\n if lovr.headset.isTracked(hand) then\n lovr.headset.animate(model)\n pass:draw(model, mat4(lovr.headset.getPose(hand)))\n end\n end\n\n if not next(models) then\n pass:text('No models loaded', 0, 1.7, -1, .1)\n end\nend"
  23949. }
  23950. },
  23951. notes = "It's possible to animate a custom hand model by retargeting joint poses, see the `Interaction/Custom_Hand_Rig` example.",
  23952. related = {
  23953. "lovr.headset.newModel",
  23954. "Model:animate"
  23955. },
  23956. variants = {
  23957. {
  23958. arguments = {
  23959. {
  23960. name = "model",
  23961. type = "Model",
  23962. description = "The model to animate."
  23963. }
  23964. },
  23965. returns = {
  23966. {
  23967. name = "success",
  23968. type = "boolean",
  23969. description = "Whether the animation was applied successfully to the Model. If the Model was not compatible or animation data for the device was not available, this will be `false`."
  23970. }
  23971. }
  23972. },
  23973. {
  23974. arguments = {
  23975. {
  23976. name = "device",
  23977. type = "Device",
  23978. description = "The device to use for the animation data.",
  23979. default = "'head'"
  23980. },
  23981. {
  23982. name = "model",
  23983. type = "Model",
  23984. description = "The model to animate."
  23985. }
  23986. },
  23987. returns = {
  23988. {
  23989. name = "success",
  23990. type = "boolean",
  23991. description = "Whether the animation was applied successfully to the Model. If the Model was not compatible or animation data for the device was not available, this will be `false`."
  23992. }
  23993. },
  23994. deprecated = true
  23995. }
  23996. }
  23997. },
  23998. {
  23999. name = "getAngularVelocity",
  24000. tag = "input",
  24001. summary = "Get the angular velocity of a device.",
  24002. description = "Returns the current angular velocity of a device.",
  24003. key = "lovr.headset.getAngularVelocity",
  24004. module = "lovr.headset",
  24005. notes = "If the device isn't tracked, all zeroes will be returned.",
  24006. related = {
  24007. "lovr.headset.getVelocity",
  24008. "lovr.headset.getPosition",
  24009. "lovr.headset.getOrientation"
  24010. },
  24011. variants = {
  24012. {
  24013. arguments = {
  24014. {
  24015. name = "device",
  24016. type = "Device",
  24017. description = "The device to get the velocity of.",
  24018. default = "'head'"
  24019. }
  24020. },
  24021. returns = {
  24022. {
  24023. name = "x",
  24024. type = "number",
  24025. description = "The x component of the angular velocity."
  24026. },
  24027. {
  24028. name = "y",
  24029. type = "number",
  24030. description = "The y component of the angular velocity."
  24031. },
  24032. {
  24033. name = "z",
  24034. type = "number",
  24035. description = "The z component of the angular velocity."
  24036. }
  24037. }
  24038. }
  24039. }
  24040. },
  24041. {
  24042. name = "getAxis",
  24043. tag = "input",
  24044. summary = "Get the state of an analog axis on a device.",
  24045. description = "Get the current state of an analog axis on a device. Some axes are multidimensional, for example a 2D touchpad or thumbstick with x/y axes. For multidimensional axes, this function will return multiple values, one number for each axis. In these cases, it can be useful to use the `select` function built in to Lua to select a particular axis component.",
  24046. key = "lovr.headset.getAxis",
  24047. module = "lovr.headset",
  24048. notes = "The axis values will be between 0 and 1 for 1D axes, and between -1 and 1 for each component of a multidimensional axis.\n\nWhen hand tracking is active, pinch strength will be mapped to the `trigger` axis.",
  24049. related = {
  24050. "DeviceAxis",
  24051. "lovr.headset.isDown"
  24052. },
  24053. variants = {
  24054. {
  24055. arguments = {
  24056. {
  24057. name = "device",
  24058. type = "Device",
  24059. description = "The device."
  24060. },
  24061. {
  24062. name = "axis",
  24063. type = "DeviceAxis",
  24064. description = "The axis."
  24065. }
  24066. },
  24067. returns = {
  24068. {
  24069. name = "...",
  24070. type = "number",
  24071. description = "The current state of the components of the axis, or `nil` if the device does not have any information about the axis."
  24072. }
  24073. }
  24074. }
  24075. }
  24076. },
  24077. {
  24078. name = "getBoundsDepth",
  24079. tag = "playArea",
  24080. summary = "Get the depth of the play area.",
  24081. description = "Returns the depth of the play area, in meters.",
  24082. key = "lovr.headset.getBoundsDepth",
  24083. module = "lovr.headset",
  24084. related = {
  24085. "lovr.headset.getBoundsWidth",
  24086. "lovr.headset.getBoundsDimensions"
  24087. },
  24088. variants = {
  24089. {
  24090. arguments = {},
  24091. returns = {
  24092. {
  24093. name = "depth",
  24094. type = "number",
  24095. description = "The depth of the play area, in meters."
  24096. }
  24097. }
  24098. }
  24099. }
  24100. },
  24101. {
  24102. name = "getBoundsDimensions",
  24103. tag = "playArea",
  24104. summary = "Get the size of the play area.",
  24105. description = "Returns the size of the play area, in meters.",
  24106. key = "lovr.headset.getBoundsDimensions",
  24107. module = "lovr.headset",
  24108. related = {
  24109. "lovr.headset.getBoundsWidth",
  24110. "lovr.headset.getBoundsDepth",
  24111. "lovr.headset.getBoundsGeometry"
  24112. },
  24113. variants = {
  24114. {
  24115. arguments = {},
  24116. returns = {
  24117. {
  24118. name = "width",
  24119. type = "number",
  24120. description = "The width of the play area, in meters."
  24121. },
  24122. {
  24123. name = "depth",
  24124. type = "number",
  24125. description = "The depth of the play area, in meters."
  24126. }
  24127. }
  24128. }
  24129. }
  24130. },
  24131. {
  24132. name = "getBoundsGeometry",
  24133. tag = "playArea",
  24134. summary = "Get a list of points that make up the play area boundary.",
  24135. description = "Returns a list of points representing the boundaries of the play area, or `nil` if the current headset driver does not expose this information.",
  24136. key = "lovr.headset.getBoundsGeometry",
  24137. module = "lovr.headset",
  24138. related = {
  24139. "lovr.headset.getBoundsDimensions"
  24140. },
  24141. variants = {
  24142. {
  24143. arguments = {
  24144. {
  24145. name = "t",
  24146. type = "table",
  24147. description = "A table to fill with the points. If `nil`, a new table will be created.",
  24148. default = "nil"
  24149. }
  24150. },
  24151. returns = {
  24152. {
  24153. name = "points",
  24154. type = "table",
  24155. description = "A flat table of 3D points representing the play area boundaries."
  24156. }
  24157. }
  24158. }
  24159. }
  24160. },
  24161. {
  24162. name = "getBoundsWidth",
  24163. tag = "playArea",
  24164. summary = "Get the width of the play area.",
  24165. description = "Returns the width of the play area, in meters.",
  24166. key = "lovr.headset.getBoundsWidth",
  24167. module = "lovr.headset",
  24168. related = {
  24169. "lovr.headset.getBoundsDepth",
  24170. "lovr.headset.getBoundsDimensions"
  24171. },
  24172. variants = {
  24173. {
  24174. arguments = {},
  24175. returns = {
  24176. {
  24177. name = "width",
  24178. type = "number",
  24179. description = "The width of the play area, in meters."
  24180. }
  24181. }
  24182. }
  24183. }
  24184. },
  24185. {
  24186. name = "getClipDistance",
  24187. tag = "headset",
  24188. summary = "Get the near and far clipping planes of the headset.",
  24189. description = "Returns the near and far clipping planes used to render to the headset. Objects closer than the near clipping plane or further than the far clipping plane will be clipped out of view.",
  24190. key = "lovr.headset.getClipDistance",
  24191. module = "lovr.headset",
  24192. notes = "The default near and far clipping planes are 0.01 meters and 0.0 meters.",
  24193. variants = {
  24194. {
  24195. arguments = {},
  24196. returns = {
  24197. {
  24198. name = "near",
  24199. type = "number",
  24200. description = "The distance to the near clipping plane, in meters."
  24201. },
  24202. {
  24203. name = "far",
  24204. type = "number",
  24205. description = "The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range."
  24206. }
  24207. }
  24208. }
  24209. }
  24210. },
  24211. {
  24212. name = "getDeltaTime",
  24213. tag = "headset-misc",
  24214. summary = "Get the predicted delta time.",
  24215. description = "Returns the headset delta time, which is the difference between the current and previous predicted display times. When the headset is active, this will be the `dt` value passed in to `lovr.update`.",
  24216. key = "lovr.headset.getDeltaTime",
  24217. module = "lovr.headset",
  24218. related = {
  24219. "lovr.headset.getTime",
  24220. "lovr.timer.getTime",
  24221. "lovr.timer.getDelta"
  24222. },
  24223. variants = {
  24224. {
  24225. arguments = {},
  24226. returns = {
  24227. {
  24228. name = "dt",
  24229. type = "number",
  24230. description = "The delta time."
  24231. }
  24232. }
  24233. }
  24234. }
  24235. },
  24236. {
  24237. name = "getDirection",
  24238. tag = "input",
  24239. summary = "Get the direction a device is pointing.",
  24240. description = "Returns the direction a device is pointing. It will always be normalized.",
  24241. key = "lovr.headset.getDirection",
  24242. module = "lovr.headset",
  24243. notes = "If the device isn't tracked, all zeroes will be returned.\n\nThis is the same as `quat(lovr.headset.getOrientation(device)):direction():unpack()`.",
  24244. related = {
  24245. "lovr.headset.getPose",
  24246. "lovr.headset.getOrientation",
  24247. "lovr.headset.getVelocity",
  24248. "lovr.headset.getAngularVelocity",
  24249. "lovr.headset.isTracked",
  24250. "lovr.headset.getDriver"
  24251. },
  24252. variants = {
  24253. {
  24254. arguments = {
  24255. {
  24256. name = "device",
  24257. type = "Device",
  24258. description = "The device to get the direction of.",
  24259. default = "'head'"
  24260. }
  24261. },
  24262. returns = {
  24263. {
  24264. name = "x",
  24265. type = "number",
  24266. description = "The x component of the direction."
  24267. },
  24268. {
  24269. name = "y",
  24270. type = "number",
  24271. description = "The y component of the direction."
  24272. },
  24273. {
  24274. name = "z",
  24275. type = "number",
  24276. description = "The z component of the direction."
  24277. }
  24278. }
  24279. }
  24280. }
  24281. },
  24282. {
  24283. name = "getDisplayDimensions",
  24284. tag = "headset",
  24285. summary = "Get the dimensions of the headset display.",
  24286. description = "Returns the texture dimensions of the headset display (for one eye), in pixels.",
  24287. key = "lovr.headset.getDisplayDimensions",
  24288. module = "lovr.headset",
  24289. related = {
  24290. "lovr.headset.getDisplayWidth",
  24291. "lovr.headset.getDisplayHeight"
  24292. },
  24293. variants = {
  24294. {
  24295. arguments = {},
  24296. returns = {
  24297. {
  24298. name = "width",
  24299. type = "number",
  24300. description = "The width of the display."
  24301. },
  24302. {
  24303. name = "height",
  24304. type = "number",
  24305. description = "The height of the display."
  24306. }
  24307. }
  24308. }
  24309. }
  24310. },
  24311. {
  24312. name = "getDisplayFrequencies",
  24313. tag = "headset",
  24314. summary = "Get the list of refresh rates supported by the display.",
  24315. description = "Returns a table with all the refresh rates supported by the headset display, in Hz.",
  24316. key = "lovr.headset.getDisplayFrequencies",
  24317. module = "lovr.headset",
  24318. deprecated = true,
  24319. related = {
  24320. "lovr.headset.setDisplayFrequency"
  24321. },
  24322. variants = {
  24323. {
  24324. arguments = {},
  24325. returns = {
  24326. {
  24327. name = "frequencies",
  24328. type = "table",
  24329. description = "A flat table of the refresh rates supported by the headset display, nil if not supported."
  24330. }
  24331. }
  24332. }
  24333. }
  24334. },
  24335. {
  24336. name = "getDisplayFrequency",
  24337. tag = "headset",
  24338. summary = "Get the refresh rate of the display.",
  24339. description = "Returns the refresh rate of the headset display, in Hz.",
  24340. key = "lovr.headset.getDisplayFrequency",
  24341. module = "lovr.headset",
  24342. deprecated = true,
  24343. variants = {
  24344. {
  24345. arguments = {},
  24346. returns = {
  24347. {
  24348. name = "frequency",
  24349. type = "number",
  24350. description = "The frequency of the display, or `nil` if I have no idea what it is."
  24351. }
  24352. }
  24353. }
  24354. }
  24355. },
  24356. {
  24357. name = "getDisplayHeight",
  24358. tag = "headset",
  24359. summary = "Get the height of the headset display.",
  24360. description = "Returns the height of the headset display (for one eye), in pixels.",
  24361. key = "lovr.headset.getDisplayHeight",
  24362. module = "lovr.headset",
  24363. related = {
  24364. "lovr.headset.getDisplayWidth",
  24365. "lovr.headset.getDisplayDimensions"
  24366. },
  24367. variants = {
  24368. {
  24369. arguments = {},
  24370. returns = {
  24371. {
  24372. name = "height",
  24373. type = "number",
  24374. description = "The height of the display."
  24375. }
  24376. }
  24377. }
  24378. }
  24379. },
  24380. {
  24381. name = "getDisplayWidth",
  24382. tag = "headset",
  24383. summary = "Get the width of the headset display.",
  24384. description = "Returns the width of the headset display (for one eye), in pixels.",
  24385. key = "lovr.headset.getDisplayWidth",
  24386. module = "lovr.headset",
  24387. related = {
  24388. "lovr.headset.getDisplayHeight",
  24389. "lovr.headset.getDisplayDimensions"
  24390. },
  24391. variants = {
  24392. {
  24393. arguments = {},
  24394. returns = {
  24395. {
  24396. name = "width",
  24397. type = "number",
  24398. description = "The width of the display."
  24399. }
  24400. }
  24401. }
  24402. }
  24403. },
  24404. {
  24405. name = "getDriver",
  24406. tag = "headset-misc",
  24407. summary = "Get the VR API currently in use for a device.",
  24408. description = "Returns the `HeadsetDriver` that is currently in use, plus the name of the VR runtime. The order of headset drivers can be changed using `lovr.conf`.",
  24409. key = "lovr.headset.getDriver",
  24410. module = "lovr.headset",
  24411. related = {
  24412. "lovr.headset.getName"
  24413. },
  24414. variants = {
  24415. {
  24416. arguments = {},
  24417. returns = {
  24418. {
  24419. name = "driver",
  24420. type = "HeadsetDriver",
  24421. description = "The current headset backend, e.g. `openxr` or `simulator`."
  24422. },
  24423. {
  24424. name = "runtime",
  24425. type = "string",
  24426. description = "The name of the VR runtime, e.g. `SteamVR/OpenXR`."
  24427. }
  24428. }
  24429. }
  24430. }
  24431. },
  24432. {
  24433. name = "getHands",
  24434. tag = "input",
  24435. summary = "Get a list of currently tracked hand devices.",
  24436. description = "Returns a table with all of the currently tracked hand devices.",
  24437. key = "lovr.headset.getHands",
  24438. module = "lovr.headset",
  24439. examples = {
  24440. {
  24441. code = "function lovr.update(dt)\n for i, hand in ipairs(lovr.headset.getHands()) do\n print(hand, lovr.headset.getPose(hand))\n end\nend"
  24442. }
  24443. },
  24444. notes = "The hand paths will *always* be either `hand/left` or `hand/right`.",
  24445. variants = {
  24446. {
  24447. arguments = {},
  24448. returns = {
  24449. {
  24450. name = "hands",
  24451. type = "table",
  24452. description = "The currently tracked hand devices.",
  24453. arguments = {},
  24454. returns = {}
  24455. }
  24456. }
  24457. }
  24458. }
  24459. },
  24460. {
  24461. name = "getName",
  24462. tag = "headset-misc",
  24463. summary = "Get the name of the connected headset display.",
  24464. description = "Returns the name of the headset as a string. The exact string that is returned depends on the hardware and VR SDK that is currently in use.",
  24465. key = "lovr.headset.getName",
  24466. module = "lovr.headset",
  24467. notes = "The desktop driver name will always be `Simulator`.",
  24468. variants = {
  24469. {
  24470. arguments = {},
  24471. returns = {
  24472. {
  24473. name = "name",
  24474. type = "string",
  24475. description = "The name of the headset as a string."
  24476. }
  24477. }
  24478. }
  24479. }
  24480. },
  24481. {
  24482. name = "getOrientation",
  24483. tag = "input",
  24484. summary = "Get the orientation of a device.",
  24485. description = "Returns the current orientation of a device, in angle/axis form.",
  24486. key = "lovr.headset.getOrientation",
  24487. module = "lovr.headset",
  24488. notes = "If the device isn't tracked, all zeroes will be returned.",
  24489. related = {
  24490. "lovr.headset.getPose",
  24491. "lovr.headset.getPosition",
  24492. "lovr.headset.getDirection",
  24493. "lovr.headset.getVelocity",
  24494. "lovr.headset.getAngularVelocity",
  24495. "lovr.headset.isTracked",
  24496. "lovr.headset.getDriver"
  24497. },
  24498. variants = {
  24499. {
  24500. arguments = {
  24501. {
  24502. name = "device",
  24503. type = "Device",
  24504. description = "The device to get the orientation of.",
  24505. default = "'head'"
  24506. }
  24507. },
  24508. returns = {
  24509. {
  24510. name = "angle",
  24511. type = "number",
  24512. description = "The amount of rotation around the axis of rotation, in radians."
  24513. },
  24514. {
  24515. name = "ax",
  24516. type = "number",
  24517. description = "The x component of the axis of rotation."
  24518. },
  24519. {
  24520. name = "ay",
  24521. type = "number",
  24522. description = "The y component of the axis of rotation."
  24523. },
  24524. {
  24525. name = "az",
  24526. type = "number",
  24527. description = "The z component of the axis of rotation."
  24528. }
  24529. }
  24530. }
  24531. }
  24532. },
  24533. {
  24534. name = "getOriginType",
  24535. tag = "playArea",
  24536. summary = "Get the type of tracking origin of the headset.",
  24537. description = "Returns the type of origin used for the tracking volume. The different types of origins are explained on the `HeadsetOrigin` page.",
  24538. key = "lovr.headset.getOriginType",
  24539. module = "lovr.headset",
  24540. deprecated = true,
  24541. related = {
  24542. "HeadsetOrigin"
  24543. },
  24544. variants = {
  24545. {
  24546. arguments = {},
  24547. returns = {
  24548. {
  24549. name = "origin",
  24550. type = "HeadsetOrigin",
  24551. description = "The type of origin."
  24552. }
  24553. }
  24554. }
  24555. }
  24556. },
  24557. {
  24558. name = "getPass",
  24559. tag = "headset-misc",
  24560. summary = "Get a Pass that renders to the headset.",
  24561. description = "Returns a `Pass` that renders to the headset display.",
  24562. key = "lovr.headset.getPass",
  24563. module = "lovr.headset",
  24564. notes = "The same Pass will be returned until `lovr.headset.submit` is called.\n\nThe first time this function is called during a frame, the views of the Pass will be initialized with the headset view poses and view angles.\n\nThe pass will be cleared to the background color, which can be changed using `lovr.graphics.setBackgroundColor`.\n\nThe pass will have a depth buffer. If `t.headset.stencil` was set to a truthy value in `lovr.conf`, the depth buffer will use the `d32fs8` format, otherwise `d32f` will be used.\n\nIf `t.headset.antialias` was set to a truthy value in `lovr.conf`, the pass will be multisampled.",
  24565. related = {
  24566. "lovr.graphics.newPass",
  24567. "lovr.graphics.getWindowPass",
  24568. "lovr.conf"
  24569. },
  24570. variants = {
  24571. {
  24572. arguments = {},
  24573. returns = {
  24574. {
  24575. name = "pass",
  24576. type = "Pass",
  24577. description = "The pass."
  24578. }
  24579. }
  24580. }
  24581. }
  24582. },
  24583. {
  24584. name = "getPassthrough",
  24585. tag = "headset",
  24586. summary = "Get the current passthrough mode.",
  24587. description = "Returns the current passthrough mode.",
  24588. key = "lovr.headset.getPassthrough",
  24589. module = "lovr.headset",
  24590. related = {
  24591. "lovr.headset.getPassthroughModes"
  24592. },
  24593. variants = {
  24594. {
  24595. arguments = {},
  24596. returns = {
  24597. {
  24598. name = "mode",
  24599. type = "PassthroughMode",
  24600. description = "The current passthrough mode."
  24601. }
  24602. }
  24603. }
  24604. }
  24605. },
  24606. {
  24607. name = "getPassthroughModes",
  24608. tag = "headset",
  24609. summary = "Get the supported passthrough modes.",
  24610. description = "Returns the set of supported passthrough modes.",
  24611. key = "lovr.headset.getPassthroughModes",
  24612. module = "lovr.headset",
  24613. related = {
  24614. "lovr.headset.getPassthrough",
  24615. "lovr.headset.setPassthrough"
  24616. },
  24617. variants = {
  24618. {
  24619. arguments = {},
  24620. returns = {
  24621. {
  24622. name = "modes",
  24623. type = "table",
  24624. description = "The set of supported passthrough modes. Keys will be `PassthroughMode` strings, and values will be booleans indicating whether the mode is supported."
  24625. }
  24626. }
  24627. }
  24628. }
  24629. },
  24630. {
  24631. name = "getPose",
  24632. tag = "input",
  24633. summary = "Get the pose of a device.",
  24634. description = "Returns the current position and orientation of a device.",
  24635. key = "lovr.headset.getPose",
  24636. module = "lovr.headset",
  24637. notes = "Units are in meters.\n\nIf the device isn't tracked, all zeroes will be returned.",
  24638. related = {
  24639. "lovr.headset.getPosition",
  24640. "lovr.headset.getOrientation",
  24641. "lovr.headset.getVelocity",
  24642. "lovr.headset.getAngularVelocity",
  24643. "lovr.headset.getSkeleton",
  24644. "lovr.headset.isTracked",
  24645. "lovr.headset.getDriver"
  24646. },
  24647. variants = {
  24648. {
  24649. arguments = {
  24650. {
  24651. name = "device",
  24652. type = "Device",
  24653. description = "The device to get the pose of.",
  24654. default = "'head'"
  24655. }
  24656. },
  24657. returns = {
  24658. {
  24659. name = "x",
  24660. type = "number",
  24661. description = "The x position."
  24662. },
  24663. {
  24664. name = "y",
  24665. type = "number",
  24666. description = "The y position."
  24667. },
  24668. {
  24669. name = "z",
  24670. type = "number",
  24671. description = "The z position."
  24672. },
  24673. {
  24674. name = "angle",
  24675. type = "number",
  24676. description = "The amount of rotation around the axis of rotation, in radians."
  24677. },
  24678. {
  24679. name = "ax",
  24680. type = "number",
  24681. description = "The x component of the axis of rotation."
  24682. },
  24683. {
  24684. name = "ay",
  24685. type = "number",
  24686. description = "The y component of the axis of rotation."
  24687. },
  24688. {
  24689. name = "az",
  24690. type = "number",
  24691. description = "The z component of the axis of rotation."
  24692. }
  24693. }
  24694. }
  24695. }
  24696. },
  24697. {
  24698. name = "getPosition",
  24699. tag = "input",
  24700. summary = "Get the position of a device.",
  24701. description = "Returns the current position of a device, in meters, relative to the play area.",
  24702. key = "lovr.headset.getPosition",
  24703. module = "lovr.headset",
  24704. notes = "If the device isn't tracked, all zeroes will be returned.",
  24705. related = {
  24706. "lovr.headset.getPose",
  24707. "lovr.headset.getOrientation",
  24708. "lovr.headset.getVelocity",
  24709. "lovr.headset.getAngularVelocity",
  24710. "lovr.headset.isTracked",
  24711. "lovr.headset.getDriver"
  24712. },
  24713. variants = {
  24714. {
  24715. arguments = {
  24716. {
  24717. name = "device",
  24718. type = "Device",
  24719. description = "The device to get the position of.",
  24720. default = "'head'"
  24721. }
  24722. },
  24723. returns = {
  24724. {
  24725. name = "x",
  24726. type = "number",
  24727. description = "The x position of the device."
  24728. },
  24729. {
  24730. name = "y",
  24731. type = "number",
  24732. description = "The y position of the device."
  24733. },
  24734. {
  24735. name = "z",
  24736. type = "number",
  24737. description = "The z position of the device."
  24738. }
  24739. }
  24740. }
  24741. }
  24742. },
  24743. {
  24744. name = "getRefreshRate",
  24745. tag = "headset",
  24746. summary = "Get the refresh rate of the headset display.",
  24747. description = "Returns the refresh rate of the headset display, in Hz.",
  24748. key = "lovr.headset.getRefreshRate",
  24749. module = "lovr.headset",
  24750. related = {
  24751. "lovr.headset.getRefreshRates"
  24752. },
  24753. variants = {
  24754. {
  24755. arguments = {},
  24756. returns = {
  24757. {
  24758. name = "rate",
  24759. type = "number",
  24760. description = "The refresh rate of the display, or `nil` if I have no idea what it is."
  24761. }
  24762. }
  24763. }
  24764. }
  24765. },
  24766. {
  24767. name = "getRefreshRates",
  24768. tag = "headset",
  24769. summary = "Get the list of refresh rates supported by the display.",
  24770. description = "Returns a table with all the refresh rates supported by the headset display, in Hz.",
  24771. key = "lovr.headset.getRefreshRates",
  24772. module = "lovr.headset",
  24773. related = {
  24774. "lovr.headset.getRefreshRate",
  24775. "lovr.headset.setRefreshRate"
  24776. },
  24777. variants = {
  24778. {
  24779. arguments = {},
  24780. returns = {
  24781. {
  24782. name = "rates",
  24783. type = "table",
  24784. description = "A flat table of the refresh rates supported by the headset display, or nil if not supported."
  24785. }
  24786. }
  24787. }
  24788. }
  24789. },
  24790. {
  24791. name = "getSkeleton",
  24792. tag = "input",
  24793. summary = "Get skeletal joint transforms tracked by a device.",
  24794. description = "Returns a list of joint transforms tracked by a device. Currently, only hand devices are able to track joints.",
  24795. key = "lovr.headset.getSkeleton",
  24796. module = "lovr.headset",
  24797. examples = {
  24798. {
  24799. code = "function lovr.draw(pass)\n for _, hand in ipairs({ 'left', 'right' }) do\n for _, joint in ipairs(lovr.headset.getSkeleton(hand) or {}) do\n pass:points(unpack(joint, 1, 3))\n end\n end\nend"
  24800. }
  24801. },
  24802. notes = "If the Device does not support tracking joints or the transforms are unavailable, `nil` is returned.\n\nThe joint orientation is similar to the graphics coordinate system: -Z is the forwards direction, pointing towards the fingertips. The +Y direction is \"up\", pointing out of the back of the hand. The +X direction is to the right, perpendicular to X and Z.\n\nHere's a picture, courtesy of Khronos Group:\n\n![Hand Skeleton Joints](https://lovr.org/img/hand-skeleton.png)\n\nHand joints are returned in the following order:\n\n<table>\n <thead>\n <tr>\n <td colspan=\"2\">Joint</td>\n <td>Index</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td colspan=\"2\">Palm</td>\n <td>1</td>\n </tr>\n <tr>\n <td colspan=\"2\">Wrist</td>\n <td>2</td>\n </tr>\n <tr>\n <td rowspan=\"4\">Thumb</td>\n <td>Metacarpal</td>\n <td>3</td>\n </tr>\n <tr>\n <td>Proximal</td>\n <td>4</td>\n </tr>\n <tr>\n <td>Distal</td>\n <td>5</td>\n </tr>\n <tr>\n <td>Tip</td>\n <td>6</td>\n </tr>\n <tr>\n <td rowspan=\"5\">Index</td>\n <td>Metacarpal</td>\n <td>7</td>\n </tr>\n <tr>\n <td>Proximal</td>\n <td>8</td>\n </tr>\n <tr>\n <td>Intermediate</td>\n <td>9</td>\n </tr>\n <tr>\n <td>Distal</td>\n <td>10</td>\n </tr>\n <tr>\n <td>Tip</td>\n <td>11</td>\n </tr>\n <tr>\n <td rowspan=\"5\">Middle</td>\n <td>Metacarpal</td>\n <td>12</td>\n </tr>\n <tr>\n <td>Proximal</td>\n <td>13</td>\n </tr>\n <tr>\n <td>Intermediate</td>\n <td>14</td>\n </tr>\n <tr>\n <td>Distal</td>\n <td>15</td>\n </tr>\n <tr>\n <td>Tip</td>\n <td>16</td>\n </tr>\n <tr>\n <td rowspan=\"5\">Ring</td>\n <td>Metacarpal</td>\n <td>17</td>\n </tr>\n <tr>\n <td>Proximal</td>\n <td>18</td>\n </tr>\n <tr>\n <td>Intermediate</td>\n <td>19</td>\n </tr>\n <tr>\n <td>Distal</td>\n <td>20</td>\n </tr>\n <tr>\n <td>Tip</td>\n <td>21</td>\n </tr>\n <tr>\n <td rowspan=\"5\">Pinky</td>\n <td>Metacarpal</td>\n <td>22</td>\n </tr>\n <tr>\n <td>Proximal</td>\n <td>23</td>\n </tr>\n <tr>\n <td>Intermediate</td>\n <td>24</td>\n </tr>\n <tr>\n <td>Distal</td>\n <td>25</td>\n </tr>\n <tr>\n <td>Tip</td>\n <td>26</td>\n </tr>\n </tbody> </table>",
  24803. related = {
  24804. "lovr.headset.getPose",
  24805. "lovr.headset.animate"
  24806. },
  24807. variants = {
  24808. {
  24809. arguments = {
  24810. {
  24811. name = "device",
  24812. type = "Device",
  24813. description = "The Device to query."
  24814. }
  24815. },
  24816. returns = {
  24817. {
  24818. name = "transforms",
  24819. type = "table",
  24820. description = "A list of joint transforms for the device. Each transform is a table with 3 numbers for the position of the joint, 1 number for the joint radius (in meters), and 4 numbers for the angle/axis orientation of the joint. There is also a `radius` key with the radius of the joint as well."
  24821. }
  24822. }
  24823. },
  24824. {
  24825. arguments = {
  24826. {
  24827. name = "device",
  24828. type = "Device",
  24829. description = "The Device to query."
  24830. },
  24831. {
  24832. name = "t",
  24833. type = "table",
  24834. description = "A table to fill with the joint transforms, instead of allocating a new one."
  24835. }
  24836. },
  24837. returns = {
  24838. {
  24839. name = "transforms",
  24840. type = "table",
  24841. description = "A list of joint transforms for the device. Each transform is a table with 3 numbers for the position of the joint, 1 number for the joint radius (in meters), and 4 numbers for the angle/axis orientation of the joint. There is also a `radius` key with the radius of the joint as well."
  24842. }
  24843. }
  24844. }
  24845. }
  24846. },
  24847. {
  24848. name = "getTexture",
  24849. tag = "headset-misc",
  24850. summary = "Get the Texture for the headset display.",
  24851. description = "Returns a Texture that will be submitted to the headset display. This will be the render target used in the headset's render pass. The texture is not guaranteed to be the same every frame, and must be called every frame to get the current texture.",
  24852. key = "lovr.headset.getTexture",
  24853. module = "lovr.headset",
  24854. notes = "This function may return `nil` if the headset is not being rendered to this frame.",
  24855. related = {
  24856. "lovr.headset.getPass",
  24857. "lovr.mirror"
  24858. },
  24859. variants = {
  24860. {
  24861. arguments = {},
  24862. returns = {
  24863. {
  24864. name = "texture",
  24865. type = "Texture",
  24866. description = "The headset texture."
  24867. }
  24868. }
  24869. }
  24870. }
  24871. },
  24872. {
  24873. name = "getTime",
  24874. tag = "headset-misc",
  24875. summary = "Get the predicted display time.",
  24876. description = "Returns the estimated time in the future at which the light from the pixels of the current frame will hit the eyes of the user.\n\nThis can be used as a replacement for `lovr.timer.getTime` for timestamps that are used for rendering to get a smoother result that is synchronized with the display of the headset.",
  24877. key = "lovr.headset.getTime",
  24878. module = "lovr.headset",
  24879. notes = "This has a different epoch than `lovr.timer.getTime`, so it is not guaranteed to be close to that value.",
  24880. related = {
  24881. "lovr.headset.getDeltaTime",
  24882. "lovr.timer.getTime"
  24883. },
  24884. variants = {
  24885. {
  24886. arguments = {},
  24887. returns = {
  24888. {
  24889. name = "time",
  24890. type = "number",
  24891. description = "The predicted display time, in seconds."
  24892. }
  24893. }
  24894. }
  24895. }
  24896. },
  24897. {
  24898. name = "getVelocity",
  24899. tag = "input",
  24900. summary = "Get the linear velocity of a device.",
  24901. description = "Returns the current linear velocity of a device, in meters per second.",
  24902. key = "lovr.headset.getVelocity",
  24903. module = "lovr.headset",
  24904. notes = "If the device isn't tracked, all zeroes will be returned.",
  24905. related = {
  24906. "lovr.headset.getAngularVelocity",
  24907. "lovr.headset.getPose",
  24908. "lovr.headset.getPosition",
  24909. "lovr.headset.getOrientation"
  24910. },
  24911. variants = {
  24912. {
  24913. arguments = {
  24914. {
  24915. name = "device",
  24916. type = "Device",
  24917. description = "The device to get the velocity of.",
  24918. default = "'head'"
  24919. }
  24920. },
  24921. returns = {
  24922. {
  24923. name = "vx",
  24924. type = "number",
  24925. description = "The x component of the linear velocity."
  24926. },
  24927. {
  24928. name = "vy",
  24929. type = "number",
  24930. description = "The y component of the linear velocity."
  24931. },
  24932. {
  24933. name = "vz",
  24934. type = "number",
  24935. description = "The z component of the linear velocity."
  24936. }
  24937. }
  24938. }
  24939. }
  24940. },
  24941. {
  24942. name = "getViewAngles",
  24943. tag = "headset",
  24944. summary = "Get the field of view angles of a view.",
  24945. description = "Returns the view angles of one of the headset views.\n\nThese can be used with `Mat4:fov` to create a projection matrix.\n\nIf tracking data is unavailable for the view or the index is invalid, `nil` is returned.",
  24946. key = "lovr.headset.getViewAngles",
  24947. module = "lovr.headset",
  24948. related = {
  24949. "lovr.headset.getViewCount",
  24950. "lovr.headset.getViewPose"
  24951. },
  24952. variants = {
  24953. {
  24954. arguments = {
  24955. {
  24956. name = "view",
  24957. type = "number",
  24958. description = "The view index."
  24959. }
  24960. },
  24961. returns = {
  24962. {
  24963. name = "left",
  24964. type = "number",
  24965. description = "The left view angle, in radians."
  24966. },
  24967. {
  24968. name = "right",
  24969. type = "number",
  24970. description = "The right view angle, in radians."
  24971. },
  24972. {
  24973. name = "top",
  24974. type = "number",
  24975. description = "The top view angle, in radians."
  24976. },
  24977. {
  24978. name = "bottom",
  24979. type = "number",
  24980. description = "The bottom view angle, in radians."
  24981. }
  24982. }
  24983. }
  24984. }
  24985. },
  24986. {
  24987. name = "getViewCount",
  24988. tag = "headset",
  24989. summary = "Get the number of views used for rendering.",
  24990. description = "Returns the number of views used for rendering. Each view consists of a pose in space and a set of angle values that determine the field of view.\n\nThis is usually 2 for stereo rendering configurations, but it can also be different. For example, one way of doing foveated rendering uses 2 views for each eye -- one low quality view with a wider field of view, and a high quality view with a narrower field of view.",
  24991. key = "lovr.headset.getViewCount",
  24992. module = "lovr.headset",
  24993. related = {
  24994. "lovr.headset.getViewPose",
  24995. "lovr.headset.getViewAngles"
  24996. },
  24997. variants = {
  24998. {
  24999. arguments = {},
  25000. returns = {
  25001. {
  25002. name = "count",
  25003. type = "number",
  25004. description = "The number of views."
  25005. }
  25006. }
  25007. }
  25008. }
  25009. },
  25010. {
  25011. name = "getViewPose",
  25012. tag = "headset",
  25013. summary = "Get the pose of one of the views.",
  25014. description = "Returns the pose of one of the headset views. This info can be used to create view matrices or do other eye-dependent calculations.\n\nIf tracking data is unavailable for the view or the index is invalid, `nil` is returned.",
  25015. key = "lovr.headset.getViewPose",
  25016. module = "lovr.headset",
  25017. related = {
  25018. "lovr.headset.getViewCount",
  25019. "lovr.headset.getViewAngles"
  25020. },
  25021. variants = {
  25022. {
  25023. arguments = {
  25024. {
  25025. name = "view",
  25026. type = "number",
  25027. description = "The view index."
  25028. }
  25029. },
  25030. returns = {
  25031. {
  25032. name = "x",
  25033. type = "number",
  25034. description = "The x coordinate of the view position, in meters."
  25035. },
  25036. {
  25037. name = "y",
  25038. type = "number",
  25039. description = "The y coordinate of the view position, in meters."
  25040. },
  25041. {
  25042. name = "z",
  25043. type = "number",
  25044. description = "The z coordinate of the view position, in meters."
  25045. },
  25046. {
  25047. name = "angle",
  25048. type = "number",
  25049. description = "The amount of rotation around the rotation axis, in radians."
  25050. },
  25051. {
  25052. name = "ax",
  25053. type = "number",
  25054. description = "The x component of the axis of rotation."
  25055. },
  25056. {
  25057. name = "ay",
  25058. type = "number",
  25059. description = "The y component of the axis of rotation."
  25060. },
  25061. {
  25062. name = "az",
  25063. type = "number",
  25064. description = "The z component of the axis of rotation."
  25065. }
  25066. }
  25067. }
  25068. }
  25069. },
  25070. {
  25071. name = "isDown",
  25072. tag = "input",
  25073. summary = "Get the state of a button on a device.",
  25074. description = "Returns whether a button on a device is pressed.",
  25075. key = "lovr.headset.isDown",
  25076. module = "lovr.headset",
  25077. notes = "When hand tracking is active, pinching will be mapped to the `trigger` button.",
  25078. related = {
  25079. "DeviceButton",
  25080. "lovr.headset.wasPressed",
  25081. "lovr.headset.wasReleased",
  25082. "lovr.headset.isTouched",
  25083. "lovr.headset.getAxis"
  25084. },
  25085. variants = {
  25086. {
  25087. arguments = {
  25088. {
  25089. name = "device",
  25090. type = "Device",
  25091. description = "The device."
  25092. },
  25093. {
  25094. name = "button",
  25095. type = "DeviceButton",
  25096. description = "The button."
  25097. }
  25098. },
  25099. returns = {
  25100. {
  25101. name = "down",
  25102. type = "boolean",
  25103. description = "Whether the button on the device is currently pressed, or `nil` if the device does not have the specified button."
  25104. }
  25105. }
  25106. }
  25107. }
  25108. },
  25109. {
  25110. name = "isFocused",
  25111. tag = "headset-misc",
  25112. summary = "Check if LÖVR has VR input focus.",
  25113. description = "Returns whether LÖVR has VR input focus. Focus is lost when the VR system menu is shown. The `lovr.focus` callback can be used to detect when this changes.",
  25114. key = "lovr.headset.isFocused",
  25115. module = "lovr.headset",
  25116. related = {
  25117. "lovr.focus"
  25118. },
  25119. variants = {
  25120. {
  25121. arguments = {},
  25122. returns = {
  25123. {
  25124. name = "focused",
  25125. type = "boolean",
  25126. description = "Whether the application is focused."
  25127. }
  25128. }
  25129. }
  25130. }
  25131. },
  25132. {
  25133. name = "isSeated",
  25134. tag = "playArea",
  25135. summary = "Check if the coordinate space is standing or seated.",
  25136. description = "Returns whether the headset coordinate space is in seated mode.\n\nSeated mode is enabled by setting `t.headset.seated` to true in `lovr.conf`. In seated mode, `y=0` will be at eye level, instead of on the floor like in standing-scale experiences.\n\nThe seated coordinate space can be more convenient for applications that are rendering a simple interface in front of the user (like a video player) instead of a roomscale 3D scene. y=0 will also be at the correct height at startup, whether the user is sitting or standing.",
  25137. key = "lovr.headset.isSeated",
  25138. module = "lovr.headset",
  25139. related = {
  25140. "lovr.conf",
  25141. "lovr.recenter"
  25142. },
  25143. variants = {
  25144. {
  25145. arguments = {},
  25146. returns = {
  25147. {
  25148. name = "seated",
  25149. type = "boolean",
  25150. description = "Whether the experience is seated."
  25151. }
  25152. }
  25153. }
  25154. }
  25155. },
  25156. {
  25157. name = "isTouched",
  25158. tag = "input",
  25159. summary = "Check if a button on a device is touched.",
  25160. description = "Returns whether a button on a device is currently touched.",
  25161. key = "lovr.headset.isTouched",
  25162. module = "lovr.headset",
  25163. related = {
  25164. "DeviceButton",
  25165. "lovr.headset.isDown",
  25166. "lovr.headset.getAxis"
  25167. },
  25168. variants = {
  25169. {
  25170. arguments = {
  25171. {
  25172. name = "device",
  25173. type = "Device",
  25174. description = "The device."
  25175. },
  25176. {
  25177. name = "button",
  25178. type = "DeviceButton",
  25179. description = "The button."
  25180. }
  25181. },
  25182. returns = {
  25183. {
  25184. name = "touched",
  25185. type = "boolean",
  25186. description = "Whether the button on the device is currently touched, or `nil` if the device does not have the button or it isn't touch-sensitive."
  25187. }
  25188. }
  25189. }
  25190. }
  25191. },
  25192. {
  25193. name = "isTracked",
  25194. tag = "input",
  25195. summary = "Check if a device is currently tracked.",
  25196. description = "Returns whether any active headset driver is currently returning pose information for a device.",
  25197. key = "lovr.headset.isTracked",
  25198. module = "lovr.headset",
  25199. notes = "If a device is tracked, it is guaranteed to return a valid pose until the next call to `lovr.headset.update`.",
  25200. variants = {
  25201. {
  25202. arguments = {
  25203. {
  25204. name = "device",
  25205. type = "Device",
  25206. description = "The device to get the pose of.",
  25207. default = "'head'"
  25208. }
  25209. },
  25210. returns = {
  25211. {
  25212. name = "tracked",
  25213. type = "boolean",
  25214. description = "Whether the device is currently tracked."
  25215. }
  25216. }
  25217. }
  25218. }
  25219. },
  25220. {
  25221. name = "isVisible",
  25222. tag = "headset-misc",
  25223. summary = "Check if content is being shown in the headset display.",
  25224. description = "Returns whether LÖVR's content is being presented to the headset display. Normally this will be true, but some VR runtimes allow applications to be hidden or \"minimized\", similar to desktop windows.",
  25225. key = "lovr.headset.isVisible",
  25226. module = "lovr.headset",
  25227. notes = "`lovr.draw` may still be called even when the application is invisible, and apps should continue to render the scene normally because the VR system may use this for timing info. If the VR system decides that the application no longer needs to render, LÖVR will stop calling `lovr.draw`.",
  25228. related = {
  25229. "lovr.visible",
  25230. "lovr.headset.isFocused",
  25231. "lovr.focus"
  25232. },
  25233. variants = {
  25234. {
  25235. arguments = {},
  25236. returns = {
  25237. {
  25238. name = "visible",
  25239. type = "boolean",
  25240. description = "Whether the application is visible."
  25241. }
  25242. }
  25243. }
  25244. }
  25245. },
  25246. {
  25247. name = "newModel",
  25248. tag = "controller-models",
  25249. summary = "Get a Model for a device.",
  25250. description = "Returns a new Model for the specified device.",
  25251. key = "lovr.headset.newModel",
  25252. module = "lovr.headset",
  25253. examples = {
  25254. {
  25255. code = "local models = {}\n\nfunction lovr.draw(pass)\n for i, hand in ipairs(lovr.headset.getHands()) do\n models[hand] = models[hand] or lovr.headset.newModel(hand)\n\n if models[hand] then\n local x, y, z, angle, ax, ay, az = lovr.headset.getPose(hand)\n pass:draw(models[hand], x, y, z, 1, angle, ax, ay, az)\n end\n end\nend"
  25256. }
  25257. },
  25258. notes = "Currently this is only implemented for hand models on the Oculus Quest.",
  25259. related = {
  25260. "lovr.headset.animate"
  25261. },
  25262. variants = {
  25263. {
  25264. arguments = {
  25265. {
  25266. name = "device",
  25267. type = "Device",
  25268. description = "The device to load a model for.",
  25269. default = "'head'"
  25270. },
  25271. {
  25272. name = "options",
  25273. type = "table",
  25274. description = "Options for loading the model.",
  25275. default = "{}",
  25276. table = {
  25277. {
  25278. name = "animated",
  25279. type = "boolean",
  25280. description = "Whether an animatable model should be loaded, for use with `lovr.headset.animate`.",
  25281. default = "false"
  25282. }
  25283. }
  25284. }
  25285. },
  25286. returns = {
  25287. {
  25288. name = "model",
  25289. type = "Model",
  25290. description = "The new Model, or `nil` if a model could not be loaded."
  25291. }
  25292. }
  25293. }
  25294. }
  25295. },
  25296. {
  25297. name = "setClipDistance",
  25298. tag = "headset",
  25299. summary = "Set the near and far clipping planes of the headset.",
  25300. description = "Sets the near and far clipping planes used to render to the headset. Objects closer than the near clipping plane or further than the far clipping plane will be clipped out of view.",
  25301. key = "lovr.headset.setClipDistance",
  25302. module = "lovr.headset",
  25303. notes = "The default clip distances are 0.01 and 0.0.",
  25304. variants = {
  25305. {
  25306. arguments = {
  25307. {
  25308. name = "near",
  25309. type = "number",
  25310. description = "The distance to the near clipping plane, in meters."
  25311. },
  25312. {
  25313. name = "far",
  25314. type = "number",
  25315. description = "The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range."
  25316. }
  25317. },
  25318. returns = {}
  25319. }
  25320. }
  25321. },
  25322. {
  25323. name = "setDisplayFrequency",
  25324. tag = "headset",
  25325. summary = "Set the display refresh rate.",
  25326. description = "Sets the display refresh rate, in Hz.",
  25327. key = "lovr.headset.setDisplayFrequency",
  25328. module = "lovr.headset",
  25329. deprecated = true,
  25330. notes = "Changing the display refresh-rate also changes the frequency of lovr.update() and lovr.draw() as they depend on the display frequency.",
  25331. variants = {
  25332. {
  25333. arguments = {
  25334. {
  25335. name = "frequency",
  25336. type = "number",
  25337. description = "The new refresh rate, in Hz."
  25338. }
  25339. },
  25340. returns = {
  25341. {
  25342. name = "success",
  25343. type = "boolean",
  25344. description = "Whether the display refresh rate was successfully set."
  25345. }
  25346. }
  25347. }
  25348. }
  25349. },
  25350. {
  25351. name = "setPassthrough",
  25352. tag = "headset",
  25353. summary = "Change current passthrough mode.",
  25354. description = "Sets a new passthrough mode. Not all headsets support all passthrough modes. Use `lovr.headset.getPassthroughModes` to see which modes are supported.",
  25355. key = "lovr.headset.setPassthrough",
  25356. module = "lovr.headset",
  25357. notes = "When using one of the transparent passthrough modes, be sure to set the alpha of the background color to zero using `lovr.graphics.setBackgroundColor`, so the background shows through.",
  25358. related = {
  25359. "lovr.headset.getPassthroughModes"
  25360. },
  25361. variants = {
  25362. {
  25363. arguments = {
  25364. {
  25365. name = "mode",
  25366. type = "PassthroughMode",
  25367. description = "The passthrough mode to request."
  25368. }
  25369. },
  25370. returns = {
  25371. {
  25372. name = "success",
  25373. type = "boolean",
  25374. description = "Whether the passthrough mode was supported and successfully enabled."
  25375. }
  25376. }
  25377. },
  25378. {
  25379. arguments = {
  25380. {
  25381. name = "transparent",
  25382. type = "boolean",
  25383. description = "Whether the headset should use a transparent passthrough mode. When false, this will request the `opaque` mode. When true, either `blend` or `add` will be requested, based on what the VR runtime supports."
  25384. }
  25385. },
  25386. returns = {
  25387. {
  25388. name = "success",
  25389. type = "boolean",
  25390. description = "Whether the passthrough mode was supported and successfully enabled."
  25391. }
  25392. }
  25393. },
  25394. {
  25395. description = "Switch to the headset's default passthrough mode.",
  25396. arguments = {},
  25397. returns = {
  25398. {
  25399. name = "success",
  25400. type = "boolean",
  25401. description = "Whether the passthrough mode was supported and successfully enabled."
  25402. }
  25403. }
  25404. }
  25405. }
  25406. },
  25407. {
  25408. name = "setRefreshRate",
  25409. tag = "headset",
  25410. summary = "Set the display refresh rate.",
  25411. description = "Sets the display refresh rate, in Hz.",
  25412. key = "lovr.headset.setRefreshRate",
  25413. module = "lovr.headset",
  25414. notes = "Changing the display refresh-rate usually also changes the frequency of lovr.update() and lovr.draw() as they depend on the refresh rate. However, it's ultimately up to the VR runtime to decide how often the application gets to render, based on available resources.",
  25415. related = {
  25416. "lovr.headset.getRefreshRates"
  25417. },
  25418. variants = {
  25419. {
  25420. arguments = {
  25421. {
  25422. name = "rate",
  25423. type = "number",
  25424. description = "The new refresh rate, in Hz."
  25425. }
  25426. },
  25427. returns = {
  25428. {
  25429. name = "success",
  25430. type = "boolean",
  25431. description = "Whether the display refresh rate was successfully set."
  25432. }
  25433. }
  25434. }
  25435. }
  25436. },
  25437. {
  25438. name = "start",
  25439. summary = "Starts the headset session.",
  25440. description = "Starts the headset session. This must be called after the graphics module is initialized, and can only be called once. Normally it is called automatically by `boot.lua`.",
  25441. key = "lovr.headset.start",
  25442. module = "lovr.headset",
  25443. variants = {
  25444. {
  25445. arguments = {},
  25446. returns = {}
  25447. }
  25448. }
  25449. },
  25450. {
  25451. name = "stopVibration",
  25452. tag = "input",
  25453. summary = "Stop vibration on a device.",
  25454. description = "Causes the device to stop any active haptics vibration.",
  25455. key = "lovr.headset.stopVibration",
  25456. module = "lovr.headset",
  25457. related = {
  25458. "lovr.headset.vibrate"
  25459. },
  25460. variants = {
  25461. {
  25462. arguments = {
  25463. {
  25464. name = "device",
  25465. type = "Device",
  25466. description = "The device to stop the vibration on.",
  25467. default = "'head'"
  25468. }
  25469. },
  25470. returns = {}
  25471. }
  25472. }
  25473. },
  25474. {
  25475. name = "submit",
  25476. tag = "headset-misc",
  25477. summary = "Submit a frame to the headset display.",
  25478. description = "Submits the current headset texture to the VR display. This should be called after calling `lovr.graphics.submit` with the headset render pass. Normally this is taken care of by `lovr.run`.",
  25479. key = "lovr.headset.submit",
  25480. module = "lovr.headset",
  25481. related = {
  25482. "lovr.headset.getPass",
  25483. "lovr.headset.getTexture"
  25484. },
  25485. variants = {
  25486. {
  25487. arguments = {},
  25488. returns = {}
  25489. }
  25490. }
  25491. },
  25492. {
  25493. name = "vibrate",
  25494. tag = "input",
  25495. summary = "Make a device go BZZZ!",
  25496. description = "Causes the device to vibrate with a custom strength, duration, and frequency, if possible.",
  25497. key = "lovr.headset.vibrate",
  25498. module = "lovr.headset",
  25499. related = {
  25500. "lovr.headset.stopVibration"
  25501. },
  25502. variants = {
  25503. {
  25504. arguments = {
  25505. {
  25506. name = "device",
  25507. type = "Device",
  25508. description = "The device to vibrate.",
  25509. default = "'head'"
  25510. },
  25511. {
  25512. name = "strength",
  25513. type = "number",
  25514. description = "The strength of the vibration (amplitude), between 0 and 1.",
  25515. default = "1"
  25516. },
  25517. {
  25518. name = "duration",
  25519. type = "number",
  25520. description = "The duration of the vibration, in seconds.",
  25521. default = ".5"
  25522. },
  25523. {
  25524. name = "frequency",
  25525. type = "number",
  25526. description = "The frequency of the vibration, in hertz. 0 will use a default frequency.",
  25527. default = "0"
  25528. }
  25529. },
  25530. returns = {
  25531. {
  25532. name = "vibrated",
  25533. type = "boolean",
  25534. description = "Whether the vibration was successfully triggered by an active headset driver."
  25535. }
  25536. }
  25537. }
  25538. }
  25539. },
  25540. {
  25541. name = "wasPressed",
  25542. tag = "input",
  25543. summary = "Check if a button was just pressed.",
  25544. description = "Returns whether a button on a device was pressed this frame.",
  25545. key = "lovr.headset.wasPressed",
  25546. module = "lovr.headset",
  25547. notes = "Some headset backends are not able to return pressed/released information. These drivers will always return false for `lovr.headset.wasPressed` and `lovr.headset.wasReleased`.\n\nTypically the internal `lovr.headset.update` function will update pressed/released status.",
  25548. related = {
  25549. "DeviceButton",
  25550. "lovr.headset.isDown",
  25551. "lovr.headset.wasReleased",
  25552. "lovr.headset.isTouched",
  25553. "lovr.headset.getAxis"
  25554. },
  25555. variants = {
  25556. {
  25557. arguments = {
  25558. {
  25559. name = "device",
  25560. type = "Device",
  25561. description = "The device."
  25562. },
  25563. {
  25564. name = "button",
  25565. type = "DeviceButton",
  25566. description = "The button to check."
  25567. }
  25568. },
  25569. returns = {
  25570. {
  25571. name = "pressed",
  25572. type = "boolean",
  25573. description = "Whether the button on the device was pressed this frame."
  25574. }
  25575. }
  25576. }
  25577. }
  25578. },
  25579. {
  25580. name = "wasReleased",
  25581. tag = "input",
  25582. summary = "Check if a button was just released.",
  25583. description = "Returns whether a button on a device was released this frame.",
  25584. key = "lovr.headset.wasReleased",
  25585. module = "lovr.headset",
  25586. notes = "Some headset backends are not able to return pressed/released information. These drivers will always return false for `lovr.headset.wasPressed` and `lovr.headset.wasReleased`.\n\nTypically the internal `lovr.headset.update` function will update pressed/released status.",
  25587. related = {
  25588. "DeviceButton",
  25589. "lovr.headset.isDown",
  25590. "lovr.headset.wasPressed",
  25591. "lovr.headset.isTouched",
  25592. "lovr.headset.getAxis"
  25593. },
  25594. variants = {
  25595. {
  25596. arguments = {
  25597. {
  25598. name = "device",
  25599. type = "Device",
  25600. description = "The device."
  25601. },
  25602. {
  25603. name = "button",
  25604. type = "DeviceButton",
  25605. description = "The button to check."
  25606. }
  25607. },
  25608. returns = {
  25609. {
  25610. name = "released",
  25611. type = "boolean",
  25612. description = "Whether the button on the device was released this frame."
  25613. }
  25614. }
  25615. }
  25616. }
  25617. }
  25618. },
  25619. objects = {},
  25620. sections = {
  25621. {
  25622. name = "Input",
  25623. tag = "input",
  25624. description = "Functions for accessing input devices, like controllers, hands, trackers, or gamepads."
  25625. },
  25626. {
  25627. name = "Controller Models",
  25628. tag = "controller-models"
  25629. },
  25630. {
  25631. name = "Display",
  25632. tag = "headset",
  25633. description = "Functions that return information about the active head mounted display (HMD)."
  25634. },
  25635. {
  25636. name = "Play area",
  25637. tag = "playArea",
  25638. description = "Retrieve information about the size and shape of the room the player is in, and provides information about the \"chaperone\", a visual indicator that appears whenever a player is about to run into a wall."
  25639. },
  25640. {
  25641. name = "Miscellaneous",
  25642. tag = "headset-misc",
  25643. description = "Functions that are internal or return information about the VR session."
  25644. }
  25645. }
  25646. },
  25647. {
  25648. name = "math",
  25649. tag = "modules",
  25650. summary = "Contains useful math helpers.",
  25651. description = "The `lovr.math` module provides math helpers commonly used for 3D applications.",
  25652. key = "lovr.math",
  25653. enums = {},
  25654. functions = {
  25655. {
  25656. name = "drain",
  25657. tag = "vectors",
  25658. summary = "Drain the temporary vector pool.",
  25659. description = "Drains the temporary vector pool, invalidating existing temporary vectors.\n\nThis is called automatically at the end of each frame.",
  25660. key = "lovr.math.drain",
  25661. module = "lovr.math",
  25662. variants = {
  25663. {
  25664. arguments = {},
  25665. returns = {}
  25666. }
  25667. }
  25668. },
  25669. {
  25670. name = "gammaToLinear",
  25671. tag = "mathOther",
  25672. summary = "Convert a color from gamma space to linear space.",
  25673. description = "Converts a color from gamma space to linear space.",
  25674. key = "lovr.math.gammaToLinear",
  25675. module = "lovr.math",
  25676. related = {
  25677. "lovr.math.linearToGamma"
  25678. },
  25679. variants = {
  25680. {
  25681. arguments = {
  25682. {
  25683. name = "gr",
  25684. type = "number",
  25685. description = "The red component of the gamma-space color."
  25686. },
  25687. {
  25688. name = "gg",
  25689. type = "number",
  25690. description = "The green component of the gamma-space color."
  25691. },
  25692. {
  25693. name = "gb",
  25694. type = "number",
  25695. description = "The blue component of the gamma-space color."
  25696. }
  25697. },
  25698. returns = {
  25699. {
  25700. name = "lr",
  25701. type = "number",
  25702. description = "The red component of the resulting linear-space color."
  25703. },
  25704. {
  25705. name = "lg",
  25706. type = "number",
  25707. description = "The green component of the resulting linear-space color."
  25708. },
  25709. {
  25710. name = "lb",
  25711. type = "number",
  25712. description = "The blue component of the resulting linear-space color."
  25713. }
  25714. }
  25715. },
  25716. {
  25717. description = "A table can also be used.",
  25718. arguments = {
  25719. {
  25720. name = "color",
  25721. type = "table",
  25722. description = "A table containing the components of a gamma-space color."
  25723. }
  25724. },
  25725. returns = {
  25726. {
  25727. name = "lr",
  25728. type = "number",
  25729. description = "The red component of the resulting linear-space color."
  25730. },
  25731. {
  25732. name = "lg",
  25733. type = "number",
  25734. description = "The green component of the resulting linear-space color."
  25735. },
  25736. {
  25737. name = "lb",
  25738. type = "number",
  25739. description = "The blue component of the resulting linear-space color."
  25740. }
  25741. }
  25742. },
  25743. {
  25744. description = "Convert a single color channel.",
  25745. arguments = {
  25746. {
  25747. name = "x",
  25748. type = "number",
  25749. description = "The color channel to convert."
  25750. }
  25751. },
  25752. returns = {
  25753. {
  25754. name = "y",
  25755. type = "number",
  25756. description = "The converted color channel."
  25757. }
  25758. }
  25759. }
  25760. }
  25761. },
  25762. {
  25763. name = "getRandomSeed",
  25764. tag = "random",
  25765. summary = "Get the random seed.",
  25766. description = "Get the seed used to initialize the random generator.",
  25767. key = "lovr.math.getRandomSeed",
  25768. module = "lovr.math",
  25769. variants = {
  25770. {
  25771. arguments = {},
  25772. returns = {
  25773. {
  25774. name = "seed",
  25775. type = "number",
  25776. description = "The new seed."
  25777. }
  25778. }
  25779. }
  25780. }
  25781. },
  25782. {
  25783. name = "linearToGamma",
  25784. tag = "mathOther",
  25785. summary = "Convert a color from linear space to gamma space.",
  25786. description = "Converts a color from linear space to gamma space.",
  25787. key = "lovr.math.linearToGamma",
  25788. module = "lovr.math",
  25789. related = {
  25790. "lovr.math.gammaToLinear"
  25791. },
  25792. variants = {
  25793. {
  25794. arguments = {
  25795. {
  25796. name = "lr",
  25797. type = "number",
  25798. description = "The red component of the linear-space color."
  25799. },
  25800. {
  25801. name = "lg",
  25802. type = "number",
  25803. description = "The green component of the linear-space color."
  25804. },
  25805. {
  25806. name = "lb",
  25807. type = "number",
  25808. description = "The blue component of the linear-space color."
  25809. }
  25810. },
  25811. returns = {
  25812. {
  25813. name = "gr",
  25814. type = "number",
  25815. description = "The red component of the resulting gamma-space color."
  25816. },
  25817. {
  25818. name = "gg",
  25819. type = "number",
  25820. description = "The green component of the resulting gamma-space color."
  25821. },
  25822. {
  25823. name = "gb",
  25824. type = "number",
  25825. description = "The blue component of the resulting gamma-space color."
  25826. }
  25827. }
  25828. },
  25829. {
  25830. description = "A table can also be used.",
  25831. arguments = {
  25832. {
  25833. name = "color",
  25834. type = "table",
  25835. description = "A table containing the components of a linear-space color."
  25836. }
  25837. },
  25838. returns = {
  25839. {
  25840. name = "gr",
  25841. type = "number",
  25842. description = "The red component of the resulting gamma-space color."
  25843. },
  25844. {
  25845. name = "gg",
  25846. type = "number",
  25847. description = "The green component of the resulting gamma-space color."
  25848. },
  25849. {
  25850. name = "gb",
  25851. type = "number",
  25852. description = "The blue component of the resulting gamma-space color."
  25853. }
  25854. }
  25855. },
  25856. {
  25857. description = "Convert a single color channel.",
  25858. arguments = {
  25859. {
  25860. name = "x",
  25861. type = "number",
  25862. description = "The color channel to convert."
  25863. }
  25864. },
  25865. returns = {
  25866. {
  25867. name = "y",
  25868. type = "number",
  25869. description = "The converted color channel."
  25870. }
  25871. }
  25872. }
  25873. }
  25874. },
  25875. {
  25876. name = "mat4",
  25877. tag = "vectors",
  25878. summary = "Create a temporary Mat4.",
  25879. description = "Creates a temporary 4D matrix. This function takes the same arguments as `Mat4:set`.",
  25880. key = "lovr.math.mat4",
  25881. module = "lovr.math",
  25882. related = {
  25883. "lovr.math.newMat4",
  25884. "Mat4",
  25885. "Vectors"
  25886. },
  25887. variants = {
  25888. {
  25889. description = "Sets the matrix to the identity matrix.",
  25890. arguments = {},
  25891. returns = {
  25892. {
  25893. name = "m",
  25894. type = "Mat4",
  25895. description = "The new matrix."
  25896. }
  25897. }
  25898. },
  25899. {
  25900. description = "Copies the values from an existing matrix.",
  25901. arguments = {
  25902. {
  25903. name = "n",
  25904. type = "Mat4",
  25905. description = "An existing matrix to copy the values from."
  25906. }
  25907. },
  25908. returns = {
  25909. {
  25910. name = "m",
  25911. type = "Mat4",
  25912. description = "The new matrix."
  25913. }
  25914. }
  25915. },
  25916. {
  25917. arguments = {
  25918. {
  25919. name = "position",
  25920. type = "Vec3",
  25921. description = "The translation of the matrix.",
  25922. default = "0, 0, 0"
  25923. },
  25924. {
  25925. name = "scale",
  25926. type = "Vec3",
  25927. description = "The scale of the matrix.",
  25928. default = "1, 1, 1"
  25929. },
  25930. {
  25931. name = "rotation",
  25932. type = "Quat",
  25933. description = "The rotation of the matrix.",
  25934. default = "0, 0, 0, 1"
  25935. }
  25936. },
  25937. returns = {
  25938. {
  25939. name = "m",
  25940. type = "Mat4",
  25941. description = "The new matrix."
  25942. }
  25943. }
  25944. },
  25945. {
  25946. arguments = {
  25947. {
  25948. name = "position",
  25949. type = "Vec3",
  25950. description = "The translation of the matrix.",
  25951. default = "0, 0, 0"
  25952. },
  25953. {
  25954. name = "rotation",
  25955. type = "Quat",
  25956. description = "The rotation of the matrix.",
  25957. default = "0, 0, 0, 1"
  25958. }
  25959. },
  25960. returns = {
  25961. {
  25962. name = "m",
  25963. type = "Mat4",
  25964. description = "The new matrix."
  25965. }
  25966. }
  25967. },
  25968. {
  25969. arguments = {
  25970. {
  25971. name = "...",
  25972. type = "number",
  25973. description = "16 numbers to use as the raw values of the matrix (column-major)."
  25974. }
  25975. },
  25976. returns = {
  25977. {
  25978. name = "m",
  25979. type = "Mat4",
  25980. description = "The new matrix."
  25981. }
  25982. }
  25983. },
  25984. {
  25985. description = "Sets the diagonal values to a number and everything else to 0.",
  25986. arguments = {
  25987. {
  25988. name = "d",
  25989. type = "number",
  25990. description = "A number to use for the diagonal elements."
  25991. }
  25992. },
  25993. returns = {
  25994. {
  25995. name = "m",
  25996. type = "Mat4",
  25997. description = "The new matrix."
  25998. }
  25999. }
  26000. }
  26001. }
  26002. },
  26003. {
  26004. name = "newCurve",
  26005. tag = "mathOther",
  26006. summary = "Create a new Curve.",
  26007. description = "Creates a new `Curve` from a list of control points.",
  26008. key = "lovr.math.newCurve",
  26009. module = "lovr.math",
  26010. variants = {
  26011. {
  26012. description = "Create a Curve from a set of initial control points.",
  26013. arguments = {
  26014. {
  26015. name = "x",
  26016. type = "number",
  26017. description = "The x coordinate of the first control point."
  26018. },
  26019. {
  26020. name = "y",
  26021. type = "number",
  26022. description = "The y coordinate of the first control point."
  26023. },
  26024. {
  26025. name = "z",
  26026. type = "number",
  26027. description = "The z coordinate of the first control point."
  26028. },
  26029. {
  26030. name = "...",
  26031. type = "*",
  26032. description = "Additional control points."
  26033. }
  26034. },
  26035. returns = {
  26036. {
  26037. name = "curve",
  26038. type = "Curve",
  26039. description = "The new Curve."
  26040. }
  26041. }
  26042. },
  26043. {
  26044. description = "Create a Curve from a set of initial control points, using vectors.",
  26045. arguments = {
  26046. {
  26047. name = "v",
  26048. type = "Vec3",
  26049. description = "The first control point."
  26050. },
  26051. {
  26052. name = "...",
  26053. type = "*",
  26054. description = "Additional control points."
  26055. }
  26056. },
  26057. returns = {
  26058. {
  26059. name = "curve",
  26060. type = "Curve",
  26061. description = "The new Curve."
  26062. }
  26063. }
  26064. },
  26065. {
  26066. description = "Create a Curve from control points in a table. The table values can be numbers or `Vec3` objects.",
  26067. arguments = {
  26068. {
  26069. name = "points",
  26070. type = "table",
  26071. description = "A table of control points, formatted as numbers or `Vec3` objects."
  26072. }
  26073. },
  26074. returns = {
  26075. {
  26076. name = "curve",
  26077. type = "Curve",
  26078. description = "The new Curve."
  26079. }
  26080. }
  26081. },
  26082. {
  26083. description = "Create an empty Curve, reserving space ahead of time for a certain number of control points.",
  26084. arguments = {
  26085. {
  26086. name = "n",
  26087. type = "number",
  26088. description = "The number of points to reserve for the Curve."
  26089. }
  26090. },
  26091. returns = {
  26092. {
  26093. name = "curve",
  26094. type = "Curve",
  26095. description = "The new Curve."
  26096. }
  26097. }
  26098. }
  26099. }
  26100. },
  26101. {
  26102. name = "newMat4",
  26103. tag = "vectors",
  26104. summary = "Create a new Mat4.",
  26105. description = "Creates a new 4D matrix. This function takes the same arguments as `Mat4:set`.",
  26106. key = "lovr.math.newMat4",
  26107. module = "lovr.math",
  26108. related = {
  26109. "lovr.math.mat4",
  26110. "Mat4",
  26111. "Vectors"
  26112. },
  26113. variants = {
  26114. {
  26115. description = "Sets the matrix to the identity matrix.",
  26116. arguments = {},
  26117. returns = {
  26118. {
  26119. name = "m",
  26120. type = "Mat4",
  26121. description = "The new matrix."
  26122. }
  26123. }
  26124. },
  26125. {
  26126. description = "Copies the values from an existing matrix.",
  26127. arguments = {
  26128. {
  26129. name = "n",
  26130. type = "Mat4",
  26131. description = "An existing matrix to copy the values from."
  26132. }
  26133. },
  26134. returns = {
  26135. {
  26136. name = "m",
  26137. type = "Mat4",
  26138. description = "The new matrix."
  26139. }
  26140. }
  26141. },
  26142. {
  26143. arguments = {
  26144. {
  26145. name = "position",
  26146. type = "Vec3",
  26147. description = "The translation of the matrix.",
  26148. default = "0, 0, 0"
  26149. },
  26150. {
  26151. name = "scale",
  26152. type = "Vec3",
  26153. description = "The scale of the matrix.",
  26154. default = "1, 1, 1"
  26155. },
  26156. {
  26157. name = "rotation",
  26158. type = "Quat",
  26159. description = "The rotation of the matrix.",
  26160. default = "0, 0, 0, 1"
  26161. }
  26162. },
  26163. returns = {
  26164. {
  26165. name = "m",
  26166. type = "Mat4",
  26167. description = "The new matrix."
  26168. }
  26169. }
  26170. },
  26171. {
  26172. arguments = {
  26173. {
  26174. name = "position",
  26175. type = "Vec3",
  26176. description = "The translation of the matrix.",
  26177. default = "0, 0, 0"
  26178. },
  26179. {
  26180. name = "rotation",
  26181. type = "Quat",
  26182. description = "The rotation of the matrix.",
  26183. default = "0, 0, 0, 1"
  26184. }
  26185. },
  26186. returns = {
  26187. {
  26188. name = "m",
  26189. type = "Mat4",
  26190. description = "The new matrix."
  26191. }
  26192. }
  26193. },
  26194. {
  26195. arguments = {
  26196. {
  26197. name = "...",
  26198. type = "number",
  26199. description = "16 numbers to use as the raw values of the matrix (column-major)."
  26200. }
  26201. },
  26202. returns = {
  26203. {
  26204. name = "m",
  26205. type = "Mat4",
  26206. description = "The new matrix."
  26207. }
  26208. }
  26209. },
  26210. {
  26211. description = "Sets the diagonal values to a number and everything else to 0.",
  26212. arguments = {
  26213. {
  26214. name = "d",
  26215. type = "number",
  26216. description = "A number to use for the diagonal elements."
  26217. }
  26218. },
  26219. returns = {
  26220. {
  26221. name = "m",
  26222. type = "Mat4",
  26223. description = "The new matrix."
  26224. }
  26225. }
  26226. }
  26227. }
  26228. },
  26229. {
  26230. name = "newQuat",
  26231. tag = "vectors",
  26232. summary = "Create a new Quat.",
  26233. description = "Creates a new quaternion. This function takes the same arguments as `Quat:set`.",
  26234. key = "lovr.math.newQuat",
  26235. module = "lovr.math",
  26236. related = {
  26237. "lovr.math.quat",
  26238. "Quat",
  26239. "Vectors"
  26240. },
  26241. variants = {
  26242. {
  26243. arguments = {
  26244. {
  26245. name = "angle",
  26246. type = "number",
  26247. description = "An angle to use for the rotation, in radians.",
  26248. default = "0"
  26249. },
  26250. {
  26251. name = "ax",
  26252. type = "number",
  26253. description = "The x component of the axis of rotation.",
  26254. default = "0"
  26255. },
  26256. {
  26257. name = "ay",
  26258. type = "number",
  26259. description = "The y component of the axis of rotation.",
  26260. default = "0"
  26261. },
  26262. {
  26263. name = "az",
  26264. type = "number",
  26265. description = "The z component of the axis of rotation.",
  26266. default = "0"
  26267. },
  26268. {
  26269. name = "raw",
  26270. type = "boolean",
  26271. description = "Whether the components should be interpreted as raw `(x, y, z, w)` components.",
  26272. default = "false"
  26273. }
  26274. },
  26275. returns = {
  26276. {
  26277. name = "q",
  26278. type = "Quat",
  26279. description = "The new quaternion."
  26280. }
  26281. }
  26282. },
  26283. {
  26284. arguments = {
  26285. {
  26286. name = "r",
  26287. type = "Quat",
  26288. description = "An existing quaternion to copy the values from."
  26289. }
  26290. },
  26291. returns = {
  26292. {
  26293. name = "q",
  26294. type = "Quat",
  26295. description = "The new quaternion."
  26296. }
  26297. }
  26298. },
  26299. {
  26300. description = "Uses the direction of a vector.",
  26301. arguments = {
  26302. {
  26303. name = "v",
  26304. type = "Vec3",
  26305. description = "A normalized direction vector."
  26306. }
  26307. },
  26308. returns = {
  26309. {
  26310. name = "q",
  26311. type = "Quat",
  26312. description = "The new quaternion."
  26313. }
  26314. }
  26315. },
  26316. {
  26317. description = "Sets the rotation to represent the rotation between two vectors.",
  26318. arguments = {
  26319. {
  26320. name = "v",
  26321. type = "Vec3",
  26322. description = "A normalized direction vector."
  26323. },
  26324. {
  26325. name = "u",
  26326. type = "Vec3",
  26327. description = "Another normalized direction vector."
  26328. }
  26329. },
  26330. returns = {
  26331. {
  26332. name = "q",
  26333. type = "Quat",
  26334. description = "The new quaternion."
  26335. }
  26336. }
  26337. },
  26338. {
  26339. arguments = {
  26340. {
  26341. name = "m",
  26342. type = "Mat4",
  26343. description = "A matrix to use the rotation from."
  26344. }
  26345. },
  26346. returns = {
  26347. {
  26348. name = "q",
  26349. type = "Quat",
  26350. description = "The new quaternion."
  26351. }
  26352. }
  26353. },
  26354. {
  26355. description = "Set the quaternion to the identity (0, 0, 0, 1).",
  26356. arguments = {},
  26357. returns = {
  26358. {
  26359. name = "q",
  26360. type = "Quat",
  26361. description = "The new quaternion."
  26362. }
  26363. }
  26364. }
  26365. }
  26366. },
  26367. {
  26368. name = "newRandomGenerator",
  26369. tag = "random",
  26370. summary = "Create a new RandomGenerator.",
  26371. description = "Creates a new `RandomGenerator`, which can be used to generate random numbers. If you just want some random numbers, you can use `lovr.math.random`. Individual RandomGenerator objects are useful if you need more control over the random sequence used or need a random generator isolated from other instances.",
  26372. key = "lovr.math.newRandomGenerator",
  26373. module = "lovr.math",
  26374. variants = {
  26375. {
  26376. description = "Create a RandomGenerator with a default seed.",
  26377. arguments = {},
  26378. returns = {
  26379. {
  26380. name = "randomGenerator",
  26381. type = "RandomGenerator",
  26382. description = "The new RandomGenerator."
  26383. }
  26384. }
  26385. },
  26386. {
  26387. arguments = {
  26388. {
  26389. name = "seed",
  26390. type = "number",
  26391. description = "The initial seed for the RandomGenerator."
  26392. }
  26393. },
  26394. returns = {
  26395. {
  26396. name = "randomGenerator",
  26397. type = "RandomGenerator",
  26398. description = "The new RandomGenerator."
  26399. }
  26400. }
  26401. },
  26402. {
  26403. description = "This variant allows creation of random generators with precise 64-bit seed values, since Lua's number format loses precision with really big numbers.",
  26404. arguments = {
  26405. {
  26406. name = "low",
  26407. type = "number",
  26408. description = "The lower 32 bits of the seed."
  26409. },
  26410. {
  26411. name = "high",
  26412. type = "number",
  26413. description = "The upper 32 bits of the seed."
  26414. }
  26415. },
  26416. returns = {
  26417. {
  26418. name = "randomGenerator",
  26419. type = "RandomGenerator",
  26420. description = "The new RandomGenerator."
  26421. }
  26422. }
  26423. }
  26424. }
  26425. },
  26426. {
  26427. name = "newVec2",
  26428. tag = "vectors",
  26429. summary = "Create a new Vec2.",
  26430. description = "Creates a new 2D vector. This function takes the same arguments as `Vec2:set`.",
  26431. key = "lovr.math.newVec2",
  26432. module = "lovr.math",
  26433. related = {
  26434. "lovr.math.vec2",
  26435. "Vec2",
  26436. "Vectors"
  26437. },
  26438. variants = {
  26439. {
  26440. arguments = {
  26441. {
  26442. name = "x",
  26443. type = "number",
  26444. description = "The x value of the vector.",
  26445. default = "0"
  26446. },
  26447. {
  26448. name = "y",
  26449. type = "number",
  26450. description = "The y value of the vector.",
  26451. default = "x"
  26452. }
  26453. },
  26454. returns = {
  26455. {
  26456. name = "v",
  26457. type = "Vec2",
  26458. description = "The new vector."
  26459. }
  26460. }
  26461. },
  26462. {
  26463. arguments = {
  26464. {
  26465. name = "u",
  26466. type = "Vec2",
  26467. description = "A vector to copy the values from."
  26468. }
  26469. },
  26470. returns = {
  26471. {
  26472. name = "v",
  26473. type = "Vec2",
  26474. description = "The new vector."
  26475. }
  26476. }
  26477. }
  26478. }
  26479. },
  26480. {
  26481. name = "newVec3",
  26482. tag = "vectors",
  26483. summary = "Create a new Vec3.",
  26484. description = "Creates a new 3D vector. This function takes the same arguments as `Vec3:set`.",
  26485. key = "lovr.math.newVec3",
  26486. module = "lovr.math",
  26487. related = {
  26488. "lovr.math.vec3",
  26489. "Vec3",
  26490. "Vectors"
  26491. },
  26492. variants = {
  26493. {
  26494. arguments = {
  26495. {
  26496. name = "x",
  26497. type = "number",
  26498. description = "The x value of the vector.",
  26499. default = "0"
  26500. },
  26501. {
  26502. name = "y",
  26503. type = "number",
  26504. description = "The y value of the vector.",
  26505. default = "x"
  26506. },
  26507. {
  26508. name = "z",
  26509. type = "number",
  26510. description = "The z value of the vector.",
  26511. default = "x"
  26512. }
  26513. },
  26514. returns = {
  26515. {
  26516. name = "v",
  26517. type = "Vec3",
  26518. description = "The new vector."
  26519. }
  26520. }
  26521. },
  26522. {
  26523. arguments = {
  26524. {
  26525. name = "u",
  26526. type = "Vec3",
  26527. description = "A vector to copy the values from."
  26528. }
  26529. },
  26530. returns = {
  26531. {
  26532. name = "v",
  26533. type = "Vec3",
  26534. description = "The new vector."
  26535. }
  26536. }
  26537. },
  26538. {
  26539. arguments = {
  26540. {
  26541. name = "m",
  26542. type = "Mat4",
  26543. description = "A matrix to use the position of."
  26544. }
  26545. },
  26546. returns = {
  26547. {
  26548. name = "v",
  26549. type = "Vec3",
  26550. description = "The new vector."
  26551. }
  26552. }
  26553. },
  26554. {
  26555. arguments = {
  26556. {
  26557. name = "q",
  26558. type = "Quat",
  26559. description = "A quat to use the direction of."
  26560. }
  26561. },
  26562. returns = {
  26563. {
  26564. name = "v",
  26565. type = "Vec3",
  26566. description = "The new vector."
  26567. }
  26568. }
  26569. }
  26570. }
  26571. },
  26572. {
  26573. name = "newVec4",
  26574. tag = "vectors",
  26575. summary = "Create a new Vec4.",
  26576. description = "Creates a new 4D vector. This function takes the same arguments as `Vec4:set`.",
  26577. key = "lovr.math.newVec4",
  26578. module = "lovr.math",
  26579. related = {
  26580. "lovr.math.vec4",
  26581. "Vec4",
  26582. "Vectors"
  26583. },
  26584. variants = {
  26585. {
  26586. arguments = {
  26587. {
  26588. name = "x",
  26589. type = "number",
  26590. description = "The x value of the vector.",
  26591. default = "0"
  26592. },
  26593. {
  26594. name = "y",
  26595. type = "number",
  26596. description = "The y value of the vector.",
  26597. default = "x"
  26598. },
  26599. {
  26600. name = "z",
  26601. type = "number",
  26602. description = "The z value of the vector.",
  26603. default = "x"
  26604. },
  26605. {
  26606. name = "w",
  26607. type = "number",
  26608. description = "The w value of the vector.",
  26609. default = "x"
  26610. }
  26611. },
  26612. returns = {
  26613. {
  26614. name = "v",
  26615. type = "Vec4",
  26616. description = "The new vector."
  26617. }
  26618. }
  26619. },
  26620. {
  26621. arguments = {
  26622. {
  26623. name = "u",
  26624. type = "Vec4",
  26625. description = "A vector to copy the values from."
  26626. }
  26627. },
  26628. returns = {
  26629. {
  26630. name = "v",
  26631. type = "Vec4",
  26632. description = "The new vector."
  26633. }
  26634. }
  26635. }
  26636. }
  26637. },
  26638. {
  26639. name = "noise",
  26640. tag = "random",
  26641. summary = "Generate simplex noise.",
  26642. description = "Returns a 1D, 2D, 3D, or 4D simplex noise value. The number will be between 0 and 1.",
  26643. key = "lovr.math.noise",
  26644. module = "lovr.math",
  26645. related = {
  26646. "lovr.math.random"
  26647. },
  26648. variants = {
  26649. {
  26650. arguments = {
  26651. {
  26652. name = "x",
  26653. type = "number",
  26654. description = "The x coordinate of the input."
  26655. }
  26656. },
  26657. returns = {
  26658. {
  26659. name = "noise",
  26660. type = "number",
  26661. description = "The noise value, between 0 and 1."
  26662. }
  26663. }
  26664. },
  26665. {
  26666. arguments = {
  26667. {
  26668. name = "x",
  26669. type = "number",
  26670. description = "The x coordinate of the input."
  26671. },
  26672. {
  26673. name = "y",
  26674. type = "number",
  26675. description = "The y coordinate of the input."
  26676. }
  26677. },
  26678. returns = {
  26679. {
  26680. name = "noise",
  26681. type = "number",
  26682. description = "The noise value, between 0 and 1."
  26683. }
  26684. }
  26685. },
  26686. {
  26687. arguments = {
  26688. {
  26689. name = "x",
  26690. type = "number",
  26691. description = "The x coordinate of the input."
  26692. },
  26693. {
  26694. name = "y",
  26695. type = "number",
  26696. description = "The y coordinate of the input."
  26697. },
  26698. {
  26699. name = "z",
  26700. type = "number",
  26701. description = "The z coordinate of the input."
  26702. }
  26703. },
  26704. returns = {
  26705. {
  26706. name = "noise",
  26707. type = "number",
  26708. description = "The noise value, between 0 and 1."
  26709. }
  26710. }
  26711. },
  26712. {
  26713. arguments = {
  26714. {
  26715. name = "x",
  26716. type = "number",
  26717. description = "The x coordinate of the input."
  26718. },
  26719. {
  26720. name = "y",
  26721. type = "number",
  26722. description = "The y coordinate of the input."
  26723. },
  26724. {
  26725. name = "z",
  26726. type = "number",
  26727. description = "The z coordinate of the input."
  26728. },
  26729. {
  26730. name = "w",
  26731. type = "number",
  26732. description = "The w coordinate of the input."
  26733. }
  26734. },
  26735. returns = {
  26736. {
  26737. name = "noise",
  26738. type = "number",
  26739. description = "The noise value, between 0 and 1."
  26740. }
  26741. }
  26742. }
  26743. }
  26744. },
  26745. {
  26746. name = "quat",
  26747. tag = "vectors",
  26748. summary = "Create a temporary Quat.",
  26749. description = "Creates a temporary quaternion. This function takes the same arguments as `Quat:set`.",
  26750. key = "lovr.math.quat",
  26751. module = "lovr.math",
  26752. related = {
  26753. "lovr.math.newQuat",
  26754. "Quat",
  26755. "Vectors"
  26756. },
  26757. variants = {
  26758. {
  26759. arguments = {
  26760. {
  26761. name = "angle",
  26762. type = "number",
  26763. description = "An angle to use for the rotation, in radians.",
  26764. default = "0"
  26765. },
  26766. {
  26767. name = "ax",
  26768. type = "number",
  26769. description = "The x component of the axis of rotation.",
  26770. default = "0"
  26771. },
  26772. {
  26773. name = "ay",
  26774. type = "number",
  26775. description = "The y component of the axis of rotation.",
  26776. default = "0"
  26777. },
  26778. {
  26779. name = "az",
  26780. type = "number",
  26781. description = "The z component of the axis of rotation.",
  26782. default = "0"
  26783. },
  26784. {
  26785. name = "raw",
  26786. type = "boolean",
  26787. description = "Whether the components should be interpreted as raw `(x, y, z, w)` components.",
  26788. default = "false"
  26789. }
  26790. },
  26791. returns = {
  26792. {
  26793. name = "q",
  26794. type = "Quat",
  26795. description = "The new quaternion."
  26796. }
  26797. }
  26798. },
  26799. {
  26800. arguments = {
  26801. {
  26802. name = "r",
  26803. type = "Quat",
  26804. description = "An existing quaternion to copy the values from."
  26805. }
  26806. },
  26807. returns = {
  26808. {
  26809. name = "q",
  26810. type = "Quat",
  26811. description = "The new quaternion."
  26812. }
  26813. }
  26814. },
  26815. {
  26816. description = "Uses the direction of a vector.",
  26817. arguments = {
  26818. {
  26819. name = "v",
  26820. type = "Vec3",
  26821. description = "A normalized direction vector."
  26822. }
  26823. },
  26824. returns = {
  26825. {
  26826. name = "q",
  26827. type = "Quat",
  26828. description = "The new quaternion."
  26829. }
  26830. }
  26831. },
  26832. {
  26833. description = "Sets the rotation to represent the rotation between two vectors.",
  26834. arguments = {
  26835. {
  26836. name = "v",
  26837. type = "Vec3",
  26838. description = "A normalized direction vector."
  26839. },
  26840. {
  26841. name = "u",
  26842. type = "Vec3",
  26843. description = "Another normalized direction vector."
  26844. }
  26845. },
  26846. returns = {
  26847. {
  26848. name = "q",
  26849. type = "Quat",
  26850. description = "The new quaternion."
  26851. }
  26852. }
  26853. },
  26854. {
  26855. arguments = {
  26856. {
  26857. name = "m",
  26858. type = "Mat4",
  26859. description = "A matrix to use the rotation from."
  26860. }
  26861. },
  26862. returns = {
  26863. {
  26864. name = "q",
  26865. type = "Quat",
  26866. description = "The new quaternion."
  26867. }
  26868. }
  26869. },
  26870. {
  26871. description = "Set the quaternion to the identity (0, 0, 0, 1).",
  26872. arguments = {},
  26873. returns = {
  26874. {
  26875. name = "q",
  26876. type = "Quat",
  26877. description = "The new quaternion."
  26878. }
  26879. }
  26880. }
  26881. }
  26882. },
  26883. {
  26884. name = "random",
  26885. tag = "random",
  26886. summary = "Get a random number.",
  26887. description = "Returns a uniformly distributed pseudo-random number. This function has improved randomness over Lua's `math.random` and also guarantees that the sequence of random numbers will be the same on all platforms (given the same seed).",
  26888. key = "lovr.math.random",
  26889. module = "lovr.math",
  26890. notes = "You can set the random seed using `lovr.math.setRandomSeed`.",
  26891. related = {
  26892. "lovr.math.randomNormal",
  26893. "RandomGenerator",
  26894. "lovr.math.noise"
  26895. },
  26896. variants = {
  26897. {
  26898. description = "Generate a pseudo-random floating point number in the range `[0,1)`",
  26899. arguments = {},
  26900. returns = {
  26901. {
  26902. name = "x",
  26903. type = "number",
  26904. description = "A pseudo-random number."
  26905. }
  26906. }
  26907. },
  26908. {
  26909. description = "Generate a pseudo-random integer in the range `[1,high]`",
  26910. arguments = {
  26911. {
  26912. name = "high",
  26913. type = "number",
  26914. description = "The maximum number to generate."
  26915. }
  26916. },
  26917. returns = {
  26918. {
  26919. name = "x",
  26920. type = "number",
  26921. description = "A pseudo-random number."
  26922. }
  26923. }
  26924. },
  26925. {
  26926. description = "Generate a pseudo-random integer in the range `[low,high]`",
  26927. arguments = {
  26928. {
  26929. name = "low",
  26930. type = "number",
  26931. description = "The minimum number to generate."
  26932. },
  26933. {
  26934. name = "high",
  26935. type = "number",
  26936. description = "The maximum number to generate."
  26937. }
  26938. },
  26939. returns = {
  26940. {
  26941. name = "x",
  26942. type = "number",
  26943. description = "A pseudo-random number."
  26944. }
  26945. }
  26946. }
  26947. }
  26948. },
  26949. {
  26950. name = "randomNormal",
  26951. tag = "random",
  26952. summary = "Get a random number from a normal distribution.",
  26953. description = "Returns a pseudo-random number from a normal distribution (a bell curve). You can control the center of the bell curve (the mean value) and the overall width (sigma, or standard deviation).",
  26954. key = "lovr.math.randomNormal",
  26955. module = "lovr.math",
  26956. related = {
  26957. "lovr.math.random",
  26958. "RandomGenerator"
  26959. },
  26960. variants = {
  26961. {
  26962. arguments = {
  26963. {
  26964. name = "sigma",
  26965. type = "number",
  26966. description = "The standard deviation of the distribution. This can be thought of how \"wide\" the range of numbers is or how much variability there is.",
  26967. default = "1"
  26968. },
  26969. {
  26970. name = "mu",
  26971. type = "number",
  26972. description = "The average value returned.",
  26973. default = "0"
  26974. }
  26975. },
  26976. returns = {
  26977. {
  26978. name = "x",
  26979. type = "number",
  26980. description = "A normally distributed pseudo-random number."
  26981. }
  26982. }
  26983. }
  26984. }
  26985. },
  26986. {
  26987. name = "setRandomSeed",
  26988. tag = "random",
  26989. summary = "Set the random seed.",
  26990. description = "Seed the random generator with a new seed. Each seed will cause `lovr.math.random` and `lovr.math.randomNormal` to produce a unique sequence of random numbers. This is done once automatically at startup by `lovr.run`.",
  26991. key = "lovr.math.setRandomSeed",
  26992. module = "lovr.math",
  26993. variants = {
  26994. {
  26995. arguments = {
  26996. {
  26997. name = "seed",
  26998. type = "number",
  26999. description = "The new seed."
  27000. }
  27001. },
  27002. returns = {}
  27003. }
  27004. }
  27005. },
  27006. {
  27007. name = "vec2",
  27008. tag = "vectors",
  27009. summary = "Create a temporary Vec2.",
  27010. description = "Creates a temporary 2D vector. This function takes the same arguments as `Vec2:set`.",
  27011. key = "lovr.math.vec2",
  27012. module = "lovr.math",
  27013. related = {
  27014. "lovr.math.newVec2",
  27015. "Vec2",
  27016. "Vectors"
  27017. },
  27018. variants = {
  27019. {
  27020. arguments = {
  27021. {
  27022. name = "x",
  27023. type = "number",
  27024. description = "The x value of the vector.",
  27025. default = "0"
  27026. },
  27027. {
  27028. name = "y",
  27029. type = "number",
  27030. description = "The y value of the vector.",
  27031. default = "x"
  27032. }
  27033. },
  27034. returns = {
  27035. {
  27036. name = "v",
  27037. type = "Vec2",
  27038. description = "The new vector."
  27039. }
  27040. }
  27041. },
  27042. {
  27043. arguments = {
  27044. {
  27045. name = "u",
  27046. type = "Vec2",
  27047. description = "A vector to copy the values from."
  27048. }
  27049. },
  27050. returns = {
  27051. {
  27052. name = "v",
  27053. type = "Vec2",
  27054. description = "The new vector."
  27055. }
  27056. }
  27057. }
  27058. }
  27059. },
  27060. {
  27061. name = "vec3",
  27062. tag = "vectors",
  27063. summary = "Create a temporary Vec3.",
  27064. description = "Creates a temporary 3D vector. This function takes the same arguments as `Vec3:set`.",
  27065. key = "lovr.math.vec3",
  27066. module = "lovr.math",
  27067. related = {
  27068. "lovr.math.newVec3",
  27069. "Vec3",
  27070. "Vectors"
  27071. },
  27072. variants = {
  27073. {
  27074. arguments = {
  27075. {
  27076. name = "x",
  27077. type = "number",
  27078. description = "The x value of the vector.",
  27079. default = "0"
  27080. },
  27081. {
  27082. name = "y",
  27083. type = "number",
  27084. description = "The y value of the vector.",
  27085. default = "x"
  27086. },
  27087. {
  27088. name = "z",
  27089. type = "number",
  27090. description = "The z value of the vector.",
  27091. default = "x"
  27092. }
  27093. },
  27094. returns = {
  27095. {
  27096. name = "v",
  27097. type = "Vec3",
  27098. description = "The new vector."
  27099. }
  27100. }
  27101. },
  27102. {
  27103. arguments = {
  27104. {
  27105. name = "u",
  27106. type = "Vec3",
  27107. description = "A vector to copy the values from."
  27108. }
  27109. },
  27110. returns = {
  27111. {
  27112. name = "v",
  27113. type = "Vec3",
  27114. description = "The new vector."
  27115. }
  27116. }
  27117. },
  27118. {
  27119. arguments = {
  27120. {
  27121. name = "m",
  27122. type = "Mat4",
  27123. description = "A matrix to use the position of."
  27124. }
  27125. },
  27126. returns = {
  27127. {
  27128. name = "v",
  27129. type = "Vec3",
  27130. description = "The new vector."
  27131. }
  27132. }
  27133. },
  27134. {
  27135. arguments = {
  27136. {
  27137. name = "q",
  27138. type = "Quat",
  27139. description = "A quat to use the direction of."
  27140. }
  27141. },
  27142. returns = {
  27143. {
  27144. name = "v",
  27145. type = "Vec3",
  27146. description = "The new vector."
  27147. }
  27148. }
  27149. }
  27150. }
  27151. },
  27152. {
  27153. name = "vec4",
  27154. tag = "vectors",
  27155. summary = "Create a temporary Vec4.",
  27156. description = "Creates a temporary 4D vector. This function takes the same arguments as `Vec4:set`.",
  27157. key = "lovr.math.vec4",
  27158. module = "lovr.math",
  27159. related = {
  27160. "lovr.math.newVec4",
  27161. "Vec4",
  27162. "Vectors"
  27163. },
  27164. variants = {
  27165. {
  27166. arguments = {
  27167. {
  27168. name = "x",
  27169. type = "number",
  27170. description = "The x value of the vector.",
  27171. default = "0"
  27172. },
  27173. {
  27174. name = "y",
  27175. type = "number",
  27176. description = "The y value of the vector.",
  27177. default = "x"
  27178. },
  27179. {
  27180. name = "z",
  27181. type = "number",
  27182. description = "The z value of the vector.",
  27183. default = "x"
  27184. },
  27185. {
  27186. name = "w",
  27187. type = "number",
  27188. description = "The w value of the vector.",
  27189. default = "x"
  27190. }
  27191. },
  27192. returns = {
  27193. {
  27194. name = "v",
  27195. type = "Vec4",
  27196. description = "The new vector."
  27197. }
  27198. }
  27199. },
  27200. {
  27201. arguments = {
  27202. {
  27203. name = "u",
  27204. type = "Vec4",
  27205. description = "A vector to copy the values from."
  27206. }
  27207. },
  27208. returns = {
  27209. {
  27210. name = "v",
  27211. type = "Vec4",
  27212. description = "The new vector."
  27213. }
  27214. }
  27215. }
  27216. }
  27217. }
  27218. },
  27219. objects = {
  27220. {
  27221. name = "Curve",
  27222. summary = "A Bézier curve.",
  27223. description = "A Curve is an object that represents a Bézier curve in three dimensions. Curves are defined by an arbitrary number of control points (note that the curve only passes through the first and last control point).\n\nOnce a Curve is created with `lovr.math.newCurve`, you can use `Curve:evaluate` to get a point on the curve or `Curve:render` to get a list of all of the points on the curve. These points can be passed directly to `Pass:points` or `Pass:line` to render the curve.\n\nNote that for longer or more complicated curves (like in a drawing application) it can be easier to store the path as several Curve objects.",
  27224. key = "Curve",
  27225. module = "lovr.math",
  27226. constructors = {
  27227. "lovr.math.newCurve",
  27228. "Curve:slice"
  27229. },
  27230. methods = {
  27231. {
  27232. name = "addPoint",
  27233. summary = "Add a new control point to the Curve.",
  27234. description = "Inserts a new control point into the Curve at the specified index.",
  27235. key = "Curve:addPoint",
  27236. module = "lovr.math",
  27237. notes = "An error will be thrown if the index is less than one or more than the number of control points.",
  27238. related = {
  27239. "Curve:getPointCount",
  27240. "Curve:getPoint",
  27241. "Curve:setPoint",
  27242. "Curve:removePoint"
  27243. },
  27244. variants = {
  27245. {
  27246. arguments = {
  27247. {
  27248. name = "x",
  27249. type = "number",
  27250. description = "The x coordinate of the control point."
  27251. },
  27252. {
  27253. name = "y",
  27254. type = "number",
  27255. description = "The y coordinate of the control point."
  27256. },
  27257. {
  27258. name = "z",
  27259. type = "number",
  27260. description = "The z coordinate of the control point."
  27261. },
  27262. {
  27263. name = "index",
  27264. type = "number",
  27265. description = "The index to insert the control point at. If nil, the control point is added to the end of the list of control points.",
  27266. default = "nil"
  27267. }
  27268. },
  27269. returns = {}
  27270. }
  27271. }
  27272. },
  27273. {
  27274. name = "evaluate",
  27275. summary = "Turn a number from 0 to 1 into a point on the Curve.",
  27276. description = "Returns a point on the Curve given a parameter `t` from 0 to 1. 0 will return the first control point, 1 will return the last point, .5 will return a point in the \"middle\" of the Curve, etc.",
  27277. key = "Curve:evaluate",
  27278. module = "lovr.math",
  27279. notes = "An error will be thrown if `t` is not between 0 and 1, or if the Curve has less than two points.",
  27280. related = {
  27281. "Curve:getTangent",
  27282. "Curve:render",
  27283. "Curve:slice"
  27284. },
  27285. variants = {
  27286. {
  27287. arguments = {
  27288. {
  27289. name = "t",
  27290. type = "number",
  27291. description = "The parameter to evaluate the Curve at."
  27292. }
  27293. },
  27294. returns = {
  27295. {
  27296. name = "x",
  27297. type = "number",
  27298. description = "The x position of the point."
  27299. },
  27300. {
  27301. name = "y",
  27302. type = "number",
  27303. description = "The y position of the point."
  27304. },
  27305. {
  27306. name = "z",
  27307. type = "number",
  27308. description = "The z position of the point."
  27309. }
  27310. }
  27311. }
  27312. }
  27313. },
  27314. {
  27315. name = "getPoint",
  27316. summary = "Get a control point of the Curve.",
  27317. description = "Returns a control point of the Curve.",
  27318. key = "Curve:getPoint",
  27319. module = "lovr.math",
  27320. notes = "An error will be thrown if the index is less than one or more than the number of control points.",
  27321. related = {
  27322. "Curve:getPointCount",
  27323. "Curve:setPoint",
  27324. "Curve:addPoint",
  27325. "Curve:removePoint"
  27326. },
  27327. variants = {
  27328. {
  27329. arguments = {
  27330. {
  27331. name = "index",
  27332. type = "number",
  27333. description = "The index to retrieve."
  27334. }
  27335. },
  27336. returns = {
  27337. {
  27338. name = "x",
  27339. type = "number",
  27340. description = "The x coordinate of the control point."
  27341. },
  27342. {
  27343. name = "y",
  27344. type = "number",
  27345. description = "The y coordinate of the control point."
  27346. },
  27347. {
  27348. name = "z",
  27349. type = "number",
  27350. description = "The z coordinate of the control point."
  27351. }
  27352. }
  27353. }
  27354. }
  27355. },
  27356. {
  27357. name = "getPointCount",
  27358. summary = "Get the number of control points in the Curve.",
  27359. description = "Returns the number of control points in the Curve.",
  27360. key = "Curve:getPointCount",
  27361. module = "lovr.math",
  27362. related = {
  27363. "Curve:getPoint",
  27364. "Curve:setPoint",
  27365. "Curve:addPoint",
  27366. "Curve:removePoint"
  27367. },
  27368. variants = {
  27369. {
  27370. arguments = {},
  27371. returns = {
  27372. {
  27373. name = "count",
  27374. type = "number",
  27375. description = "The number of control points."
  27376. }
  27377. }
  27378. }
  27379. }
  27380. },
  27381. {
  27382. name = "getTangent",
  27383. summary = "Get the direction of the Curve at a point.",
  27384. description = "Returns a direction vector for the Curve given a parameter `t` from 0 to 1. 0 will return the direction at the first control point, 1 will return the direction at the last point, .5 will return the direction at the \"middle\" of the Curve, etc.",
  27385. key = "Curve:getTangent",
  27386. module = "lovr.math",
  27387. notes = "The direction vector returned by this function will have a length of one.",
  27388. related = {
  27389. "Curve:evaluate",
  27390. "Curve:render",
  27391. "Curve:slice"
  27392. },
  27393. variants = {
  27394. {
  27395. arguments = {
  27396. {
  27397. name = "t",
  27398. type = "number",
  27399. description = "Where on the Curve to compute the direction."
  27400. }
  27401. },
  27402. returns = {
  27403. {
  27404. name = "x",
  27405. type = "number",
  27406. description = "The x position of the point."
  27407. },
  27408. {
  27409. name = "y",
  27410. type = "number",
  27411. description = "The y position of the point."
  27412. },
  27413. {
  27414. name = "z",
  27415. type = "number",
  27416. description = "The z position of the point."
  27417. }
  27418. }
  27419. }
  27420. }
  27421. },
  27422. {
  27423. name = "removePoint",
  27424. summary = "Remove a control point from the Curve.",
  27425. description = "Removes a control point from the Curve.",
  27426. key = "Curve:removePoint",
  27427. module = "lovr.math",
  27428. notes = "An error will be thrown if the index is less than one or more than the number of control points.",
  27429. related = {
  27430. "Curve:getPointCount",
  27431. "Curve:getPoint",
  27432. "Curve:setPoint",
  27433. "Curve:addPoint"
  27434. },
  27435. variants = {
  27436. {
  27437. arguments = {
  27438. {
  27439. name = "index",
  27440. type = "number",
  27441. description = "The index of the control point to remove."
  27442. }
  27443. },
  27444. returns = {}
  27445. }
  27446. }
  27447. },
  27448. {
  27449. name = "render",
  27450. summary = "Get a list of points on the Curve.",
  27451. description = "Returns a list of points on the Curve. The number of points can be specified to get a more or less detailed representation, and it is also possible to render a subsection of the Curve.",
  27452. key = "Curve:render",
  27453. module = "lovr.math",
  27454. notes = "This function will always return 2 points if the Curve is a line with only 2 control points.",
  27455. related = {
  27456. "Curve:evaluate",
  27457. "Curve:slice",
  27458. "Pass:points",
  27459. "Pass:line",
  27460. "Pass:mesh"
  27461. },
  27462. variants = {
  27463. {
  27464. arguments = {
  27465. {
  27466. name = "n",
  27467. type = "number",
  27468. description = "The number of points to use.",
  27469. default = "32"
  27470. },
  27471. {
  27472. name = "t1",
  27473. type = "number",
  27474. description = "How far along the curve to start rendering.",
  27475. default = "0"
  27476. },
  27477. {
  27478. name = "t2",
  27479. type = "number",
  27480. description = "How far along the curve to stop rendering.",
  27481. default = "1"
  27482. }
  27483. },
  27484. returns = {
  27485. {
  27486. name = "t",
  27487. type = "table",
  27488. description = "A (flat) table of 3D points along the curve."
  27489. }
  27490. }
  27491. }
  27492. }
  27493. },
  27494. {
  27495. name = "setPoint",
  27496. summary = "Set a control point of the Curve.",
  27497. description = "Changes the position of a control point on the Curve.",
  27498. key = "Curve:setPoint",
  27499. module = "lovr.math",
  27500. notes = "An error will be thrown if the index is less than one or more than the number of control points.",
  27501. related = {
  27502. "Curve:getPointCount",
  27503. "Curve:getPoint",
  27504. "Curve:addPoint",
  27505. "Curve:removePoint"
  27506. },
  27507. variants = {
  27508. {
  27509. arguments = {
  27510. {
  27511. name = "index",
  27512. type = "number",
  27513. description = "The index to modify."
  27514. },
  27515. {
  27516. name = "x",
  27517. type = "number",
  27518. description = "The new x coordinate."
  27519. },
  27520. {
  27521. name = "y",
  27522. type = "number",
  27523. description = "The new y coordinate."
  27524. },
  27525. {
  27526. name = "z",
  27527. type = "number",
  27528. description = "The new z coordinate."
  27529. }
  27530. },
  27531. returns = {}
  27532. }
  27533. }
  27534. },
  27535. {
  27536. name = "slice",
  27537. summary = "Get a new Curve from a slice of an existing one.",
  27538. description = "Returns a new Curve created by slicing the Curve at the specified start and end points.",
  27539. key = "Curve:slice",
  27540. module = "lovr.math",
  27541. notes = "The new Curve will have the same number of control points as the existing curve.\n\nAn error will be thrown if t1 or t2 are not between 0 and 1, or if the Curve has less than two points.",
  27542. related = {
  27543. "Curve:evaluate",
  27544. "Curve:render"
  27545. },
  27546. variants = {
  27547. {
  27548. arguments = {
  27549. {
  27550. name = "t1",
  27551. type = "number",
  27552. description = "The starting point to slice at."
  27553. },
  27554. {
  27555. name = "t2",
  27556. type = "number",
  27557. description = "The ending point to slice at."
  27558. }
  27559. },
  27560. returns = {
  27561. {
  27562. name = "curve",
  27563. type = "Curve",
  27564. description = "A new Curve."
  27565. }
  27566. }
  27567. }
  27568. }
  27569. }
  27570. }
  27571. },
  27572. {
  27573. name = "Mat4",
  27574. summary = "A 4x4 matrix.",
  27575. description = "A `mat4` is a math type that holds 16 values in a 4x4 grid.",
  27576. key = "Mat4",
  27577. module = "lovr.math",
  27578. constructors = {
  27579. "lovr.math.newMat4",
  27580. "lovr.math.mat4"
  27581. },
  27582. methods = {
  27583. {
  27584. name = "equals",
  27585. summary = "Check if a matrix equals another matrix.",
  27586. description = "Returns whether a matrix is approximately equal to another matrix.",
  27587. key = "Mat4:equals",
  27588. module = "lovr.math",
  27589. related = {
  27590. "Vec2:equals",
  27591. "Vec3:equals",
  27592. "Vec4:equals",
  27593. "Quat:equals"
  27594. },
  27595. variants = {
  27596. {
  27597. arguments = {
  27598. {
  27599. name = "n",
  27600. type = "Mat4",
  27601. description = "The other matrix."
  27602. }
  27603. },
  27604. returns = {
  27605. {
  27606. name = "equal",
  27607. type = "boolean",
  27608. description = "Whether the 2 matrices approximately equal each other."
  27609. }
  27610. }
  27611. }
  27612. }
  27613. },
  27614. {
  27615. name = "fov",
  27616. summary = "Set a projection using raw field of view angles.",
  27617. description = "Sets a projection matrix using raw projection angles and clipping planes.\n\nThis can be used for asymmetric or oblique projections.",
  27618. key = "Mat4:fov",
  27619. module = "lovr.math",
  27620. related = {
  27621. "Mat4:orthographic",
  27622. "Mat4:perspective",
  27623. "Pass:setProjection"
  27624. },
  27625. variants = {
  27626. {
  27627. arguments = {
  27628. {
  27629. name = "left",
  27630. type = "number",
  27631. description = "The left half-angle of the projection, in radians."
  27632. },
  27633. {
  27634. name = "right",
  27635. type = "number",
  27636. description = "The right half-angle of the projection, in radians."
  27637. },
  27638. {
  27639. name = "up",
  27640. type = "number",
  27641. description = "The top half-angle of the projection, in radians."
  27642. },
  27643. {
  27644. name = "down",
  27645. type = "number",
  27646. description = "The bottom half-angle of the projection, in radians."
  27647. },
  27648. {
  27649. name = "near",
  27650. type = "number",
  27651. description = "The near plane of the projection."
  27652. },
  27653. {
  27654. name = "far",
  27655. type = "number",
  27656. description = "The far plane. Zero is a special value that will set an infinite far plane with a reversed Z range, which improves depth buffer precision and is the default.",
  27657. default = "0"
  27658. }
  27659. },
  27660. returns = {
  27661. {
  27662. name = "self",
  27663. type = "Mat4",
  27664. description = "The modified matrix."
  27665. }
  27666. }
  27667. }
  27668. }
  27669. },
  27670. {
  27671. name = "getOrientation",
  27672. summary = "Get the angle/axis rotation of the matrix.",
  27673. description = "Returns the angle/axis rotation of the matrix.",
  27674. key = "Mat4:getOrientation",
  27675. module = "lovr.math",
  27676. related = {
  27677. "Mat4:getPosition",
  27678. "Mat4:getScale",
  27679. "Mat4:getPose",
  27680. "Mat4:unpack",
  27681. "Mat4:set"
  27682. },
  27683. variants = {
  27684. {
  27685. arguments = {},
  27686. returns = {
  27687. {
  27688. name = "angle",
  27689. type = "number",
  27690. description = "The number of radians the matrix rotates around its rotation axis."
  27691. },
  27692. {
  27693. name = "ax",
  27694. type = "number",
  27695. description = "The x component of the axis of rotation."
  27696. },
  27697. {
  27698. name = "ay",
  27699. type = "number",
  27700. description = "The y component of the axis of rotation."
  27701. },
  27702. {
  27703. name = "az",
  27704. type = "number",
  27705. description = "The z component of the axis of rotation."
  27706. }
  27707. }
  27708. }
  27709. }
  27710. },
  27711. {
  27712. name = "getPose",
  27713. summary = "Get the position and rotation of the matrix.",
  27714. description = "Returns the position and rotation of the matrix.",
  27715. key = "Mat4:getPose",
  27716. module = "lovr.math",
  27717. related = {
  27718. "Mat4:getPosition",
  27719. "Mat4:getOrientation",
  27720. "Mat4:getScale",
  27721. "Mat4:unpack",
  27722. "Mat4:set"
  27723. },
  27724. variants = {
  27725. {
  27726. arguments = {},
  27727. returns = {
  27728. {
  27729. name = "x",
  27730. type = "number",
  27731. description = "The x translation."
  27732. },
  27733. {
  27734. name = "y",
  27735. type = "number",
  27736. description = "The y translation."
  27737. },
  27738. {
  27739. name = "z",
  27740. type = "number",
  27741. description = "The z translation."
  27742. },
  27743. {
  27744. name = "angle",
  27745. type = "number",
  27746. description = "The number of radians the matrix rotates around its rotation axis."
  27747. },
  27748. {
  27749. name = "ax",
  27750. type = "number",
  27751. description = "The x component of the axis of rotation."
  27752. },
  27753. {
  27754. name = "ay",
  27755. type = "number",
  27756. description = "The y component of the axis of rotation."
  27757. },
  27758. {
  27759. name = "az",
  27760. type = "number",
  27761. description = "The z component of the axis of rotation."
  27762. }
  27763. }
  27764. }
  27765. }
  27766. },
  27767. {
  27768. name = "getPosition",
  27769. summary = "Get the translation of the matrix.",
  27770. description = "Returns the translation of the matrix. This is the last column of the matrix.",
  27771. key = "Mat4:getPosition",
  27772. module = "lovr.math",
  27773. related = {
  27774. "Mat4:getOrientation",
  27775. "Mat4:getScale",
  27776. "Mat4:getPose",
  27777. "Mat4:unpack",
  27778. "Mat4:set"
  27779. },
  27780. variants = {
  27781. {
  27782. arguments = {},
  27783. returns = {
  27784. {
  27785. name = "x",
  27786. type = "number",
  27787. description = "The x translation."
  27788. },
  27789. {
  27790. name = "y",
  27791. type = "number",
  27792. description = "The y translation."
  27793. },
  27794. {
  27795. name = "z",
  27796. type = "number",
  27797. description = "The z translation."
  27798. }
  27799. }
  27800. }
  27801. }
  27802. },
  27803. {
  27804. name = "getScale",
  27805. summary = "Get the scale factor of the matrix.",
  27806. description = "Returns the scale factor of the matrix.",
  27807. key = "Mat4:getScale",
  27808. module = "lovr.math",
  27809. related = {
  27810. "Mat4:getPosition",
  27811. "Mat4:getOrientation",
  27812. "Mat4:getPose",
  27813. "Mat4:unpack",
  27814. "Mat4:set"
  27815. },
  27816. variants = {
  27817. {
  27818. arguments = {},
  27819. returns = {
  27820. {
  27821. name = "sx",
  27822. type = "number",
  27823. description = "The x scale."
  27824. },
  27825. {
  27826. name = "sy",
  27827. type = "number",
  27828. description = "The y scale."
  27829. },
  27830. {
  27831. name = "sz",
  27832. type = "number",
  27833. description = "The z scale."
  27834. }
  27835. }
  27836. }
  27837. }
  27838. },
  27839. {
  27840. name = "identity",
  27841. summary = "Reset the matrix to the identity.",
  27842. description = "Resets the matrix to the identity, effectively setting its translation to zero, its scale to 1, and clearing any rotation.",
  27843. key = "Mat4:identity",
  27844. module = "lovr.math",
  27845. related = {
  27846. "Pass:origin"
  27847. },
  27848. variants = {
  27849. {
  27850. arguments = {},
  27851. returns = {
  27852. {
  27853. name = "self",
  27854. type = "Mat4",
  27855. description = "The modified matrix."
  27856. }
  27857. }
  27858. }
  27859. }
  27860. },
  27861. {
  27862. name = "invert",
  27863. summary = "Invert the matrix.",
  27864. description = "Inverts the matrix, causing it to represent the opposite of its old transform.",
  27865. key = "Mat4:invert",
  27866. module = "lovr.math",
  27867. variants = {
  27868. {
  27869. arguments = {},
  27870. returns = {
  27871. {
  27872. name = "self",
  27873. type = "Mat4",
  27874. description = "The inverted matrix."
  27875. }
  27876. }
  27877. }
  27878. }
  27879. },
  27880. {
  27881. name = "lookAt",
  27882. summary = "Create a view transform that looks from a position to target position.",
  27883. description = "Sets a view transform matrix that moves and orients camera to look at a target point.\n\nThis is useful for changing camera position and orientation. The resulting Mat4 matrix can be passed to `lovr.graphics.transform()` directly (without inverting) before rendering the scene.\n\nThe lookAt() function produces same result as target() after matrix inversion.",
  27884. key = "Mat4:lookAt",
  27885. module = "lovr.math",
  27886. related = {
  27887. "Mat4:target",
  27888. "Quat:direction"
  27889. },
  27890. variants = {
  27891. {
  27892. arguments = {
  27893. {
  27894. name = "from",
  27895. type = "Vec3",
  27896. description = "The position of the viewer."
  27897. },
  27898. {
  27899. name = "to",
  27900. type = "Vec3",
  27901. description = "The position of the target."
  27902. },
  27903. {
  27904. name = "up",
  27905. type = "Vec3",
  27906. description = "The up vector of the viewer.",
  27907. default = "Vec3(0, 1, 0)"
  27908. }
  27909. },
  27910. returns = {
  27911. {
  27912. name = "self",
  27913. type = "Mat4",
  27914. description = "The modified matrix."
  27915. }
  27916. }
  27917. }
  27918. }
  27919. },
  27920. {
  27921. name = "mul",
  27922. summary = "Multiply a matrix with another matrix or a vector.",
  27923. description = "Multiplies this matrix by another value. Multiplying by a matrix combines their two transforms together. Multiplying by a vector applies the transformation from the matrix to the vector and returns the vector.",
  27924. key = "Mat4:mul",
  27925. module = "lovr.math",
  27926. notes = "When multiplying by a vec4, the vector is treated as either a point if its w component is 1, or a direction vector if the w is 0 (the matrix translation won't be applied).",
  27927. related = {
  27928. "Mat4:translate",
  27929. "Mat4:rotate",
  27930. "Mat4:scale"
  27931. },
  27932. variants = {
  27933. {
  27934. arguments = {
  27935. {
  27936. name = "n",
  27937. type = "Mat4",
  27938. description = "The matrix."
  27939. }
  27940. },
  27941. returns = {
  27942. {
  27943. name = "self",
  27944. type = "Mat4",
  27945. description = "The modified matrix."
  27946. }
  27947. }
  27948. },
  27949. {
  27950. arguments = {
  27951. {
  27952. name = "v3",
  27953. type = "Vec3",
  27954. description = "A 3D vector, treated as a point."
  27955. }
  27956. },
  27957. returns = {
  27958. {
  27959. name = "v3",
  27960. type = "Vec3",
  27961. description = "The transformed vector."
  27962. }
  27963. }
  27964. },
  27965. {
  27966. arguments = {
  27967. {
  27968. name = "v4",
  27969. type = "Vec4",
  27970. description = "A 4D vector."
  27971. }
  27972. },
  27973. returns = {
  27974. {
  27975. name = "v4",
  27976. type = "Vec4",
  27977. description = "The transformed vector."
  27978. }
  27979. }
  27980. }
  27981. }
  27982. },
  27983. {
  27984. name = "orthographic",
  27985. summary = "Turn the matrix into an orthographic projection.",
  27986. description = "Sets this matrix to represent an orthographic projection, useful for 2D/isometric rendering.\n\nThis can be used with `Pass:setProjection`, or it can be sent to a `Shader` for use in GLSL.",
  27987. key = "Mat4:orthographic",
  27988. module = "lovr.math",
  27989. related = {
  27990. "Mat4:perspective",
  27991. "Mat4:fov",
  27992. "Pass:setProjection"
  27993. },
  27994. variants = {
  27995. {
  27996. arguments = {
  27997. {
  27998. name = "left",
  27999. type = "number",
  28000. description = "The left edge of the projection."
  28001. },
  28002. {
  28003. name = "right",
  28004. type = "number",
  28005. description = "The right edge of the projection."
  28006. },
  28007. {
  28008. name = "bottom",
  28009. type = "number",
  28010. description = "The bottom edge of the projection."
  28011. },
  28012. {
  28013. name = "top",
  28014. type = "number",
  28015. description = "The top edge of the projection."
  28016. },
  28017. {
  28018. name = "near",
  28019. type = "number",
  28020. description = "The position of the near clipping plane."
  28021. },
  28022. {
  28023. name = "far",
  28024. type = "number",
  28025. description = "The position of the far clipping plane."
  28026. }
  28027. },
  28028. returns = {
  28029. {
  28030. name = "self",
  28031. type = "Mat4",
  28032. description = "The modified matrix."
  28033. }
  28034. }
  28035. },
  28036. {
  28037. arguments = {
  28038. {
  28039. name = "width",
  28040. type = "number",
  28041. description = "The width of the projection."
  28042. },
  28043. {
  28044. name = "height",
  28045. type = "number",
  28046. description = "The height of the projection."
  28047. },
  28048. {
  28049. name = "near",
  28050. type = "number",
  28051. description = "The position of the near clipping plane."
  28052. },
  28053. {
  28054. name = "far",
  28055. type = "number",
  28056. description = "The position of the far clipping plane."
  28057. }
  28058. },
  28059. returns = {
  28060. {
  28061. name = "self",
  28062. type = "Mat4",
  28063. description = "The modified matrix."
  28064. }
  28065. }
  28066. }
  28067. }
  28068. },
  28069. {
  28070. name = "perspective",
  28071. summary = "Turn the matrix into a perspective projection.",
  28072. description = "Sets this matrix to represent a perspective projection.\n\nThis can be used with `Pass:setProjection`, or it can be sent to a `Shader` for use in GLSL.",
  28073. key = "Mat4:perspective",
  28074. module = "lovr.math",
  28075. related = {
  28076. "Mat4:orthographic",
  28077. "Mat4:fov",
  28078. "Pass:setProjection"
  28079. },
  28080. variants = {
  28081. {
  28082. arguments = {
  28083. {
  28084. name = "fov",
  28085. type = "number",
  28086. description = "The vertical field of view (in radians)."
  28087. },
  28088. {
  28089. name = "aspect",
  28090. type = "number",
  28091. description = "The horizontal aspect ratio of the projection (width / height)."
  28092. },
  28093. {
  28094. name = "near",
  28095. type = "number",
  28096. description = "The near plane."
  28097. },
  28098. {
  28099. name = "far",
  28100. type = "number",
  28101. description = "The far plane. Zero is a special value that will set an infinite far plane with a reversed Z range, which improves depth buffer precision and is the default.",
  28102. default = "0"
  28103. }
  28104. },
  28105. returns = {
  28106. {
  28107. name = "self",
  28108. type = "Mat4",
  28109. description = "The modified matrix."
  28110. }
  28111. }
  28112. }
  28113. }
  28114. },
  28115. {
  28116. name = "reflect",
  28117. summary = "Create a matrix that reflects across a plane.",
  28118. description = "Turns the matrix into a reflection matrix that transforms values as though they were reflected across a plane.",
  28119. key = "Mat4:reflect",
  28120. module = "lovr.math",
  28121. variants = {
  28122. {
  28123. arguments = {
  28124. {
  28125. name = "position",
  28126. type = "Vec3",
  28127. description = "The position of the plane."
  28128. },
  28129. {
  28130. name = "normal",
  28131. type = "Vec3",
  28132. description = "The normal vector of the plane."
  28133. }
  28134. },
  28135. returns = {
  28136. {
  28137. name = "self",
  28138. type = "Mat4",
  28139. description = "The reflected matrix."
  28140. }
  28141. }
  28142. }
  28143. }
  28144. },
  28145. {
  28146. name = "rotate",
  28147. summary = "Rotate the matrix.",
  28148. description = "Rotates the matrix using a quaternion or an angle/axis rotation.",
  28149. key = "Mat4:rotate",
  28150. module = "lovr.math",
  28151. related = {
  28152. "Mat4:translate",
  28153. "Mat4:scale",
  28154. "Mat4:identity"
  28155. },
  28156. variants = {
  28157. {
  28158. arguments = {
  28159. {
  28160. name = "q",
  28161. type = "Quat",
  28162. description = "The rotation to apply to the matrix."
  28163. }
  28164. },
  28165. returns = {
  28166. {
  28167. name = "self",
  28168. type = "Mat4",
  28169. description = "The rotated matrix."
  28170. }
  28171. }
  28172. },
  28173. {
  28174. arguments = {
  28175. {
  28176. name = "angle",
  28177. type = "number",
  28178. description = "The angle component of the angle/axis rotation (radians)."
  28179. },
  28180. {
  28181. name = "ax",
  28182. type = "number",
  28183. description = "The x component of the axis of rotation.",
  28184. default = "0"
  28185. },
  28186. {
  28187. name = "ay",
  28188. type = "number",
  28189. description = "The y component of the axis of rotation.",
  28190. default = "1"
  28191. },
  28192. {
  28193. name = "az",
  28194. type = "number",
  28195. description = "The z component of the axis of rotation.",
  28196. default = "0"
  28197. }
  28198. },
  28199. returns = {
  28200. {
  28201. name = "self",
  28202. type = "Mat4",
  28203. description = "The rotated matrix."
  28204. }
  28205. }
  28206. }
  28207. }
  28208. },
  28209. {
  28210. name = "scale",
  28211. summary = "Scale the matrix.",
  28212. description = "Scales the matrix.",
  28213. key = "Mat4:scale",
  28214. module = "lovr.math",
  28215. related = {
  28216. "Mat4:translate",
  28217. "Mat4:rotate",
  28218. "Mat4:identity"
  28219. },
  28220. variants = {
  28221. {
  28222. arguments = {
  28223. {
  28224. name = "scale",
  28225. type = "Vec3",
  28226. description = "The 3D scale to apply."
  28227. }
  28228. },
  28229. returns = {
  28230. {
  28231. name = "self",
  28232. type = "Mat4",
  28233. description = "The modified matrix."
  28234. }
  28235. }
  28236. },
  28237. {
  28238. arguments = {
  28239. {
  28240. name = "sx",
  28241. type = "number",
  28242. description = "The x component of the scale to apply."
  28243. },
  28244. {
  28245. name = "sy",
  28246. type = "number",
  28247. description = "The y component of the scale to apply.",
  28248. default = "sx"
  28249. },
  28250. {
  28251. name = "sz",
  28252. type = "number",
  28253. description = "The z component of the scale to apply.",
  28254. default = "sx"
  28255. }
  28256. },
  28257. returns = {
  28258. {
  28259. name = "self",
  28260. type = "Mat4",
  28261. description = "The modified matrix."
  28262. }
  28263. }
  28264. }
  28265. }
  28266. },
  28267. {
  28268. name = "set",
  28269. summary = "Set the components of the matrix.",
  28270. description = "Sets the components of the matrix from separate position, rotation, and scale arguments or an existing matrix.",
  28271. key = "Mat4:set",
  28272. module = "lovr.math",
  28273. related = {
  28274. "Mat4:unpack"
  28275. },
  28276. variants = {
  28277. {
  28278. description = "Resets the matrix to the identity matrix, without any translation, rotation, or scale.",
  28279. arguments = {},
  28280. returns = {
  28281. {
  28282. name = "m",
  28283. type = "Mat4",
  28284. description = "The input matrix."
  28285. }
  28286. }
  28287. },
  28288. {
  28289. description = "Copies the values from an existing matrix.",
  28290. arguments = {
  28291. {
  28292. name = "n",
  28293. type = "Mat4",
  28294. description = "An existing matrix to copy the values from."
  28295. }
  28296. },
  28297. returns = {
  28298. {
  28299. name = "m",
  28300. type = "Mat4",
  28301. description = "The input matrix."
  28302. }
  28303. }
  28304. },
  28305. {
  28306. description = "Sets the position, scale, and rotation of the matrix using numbers.",
  28307. arguments = {
  28308. {
  28309. name = "x",
  28310. type = "number",
  28311. description = "The x component of the translation."
  28312. },
  28313. {
  28314. name = "y",
  28315. type = "number",
  28316. description = "The y component of the translation."
  28317. },
  28318. {
  28319. name = "z",
  28320. type = "number",
  28321. description = "The z component of the translation."
  28322. },
  28323. {
  28324. name = "sx",
  28325. type = "number",
  28326. description = "The x component of the scale."
  28327. },
  28328. {
  28329. name = "sy",
  28330. type = "number",
  28331. description = "The y component of the scale."
  28332. },
  28333. {
  28334. name = "sz",
  28335. type = "number",
  28336. description = "The z component of the scale."
  28337. },
  28338. {
  28339. name = "angle",
  28340. type = "number",
  28341. description = "The angle of the rotation, in radians."
  28342. },
  28343. {
  28344. name = "ax",
  28345. type = "number",
  28346. description = "The x component of the axis of rotation."
  28347. },
  28348. {
  28349. name = "ay",
  28350. type = "number",
  28351. description = "The y component of the axis of rotation."
  28352. },
  28353. {
  28354. name = "az",
  28355. type = "number",
  28356. description = "The z component of the axis of rotation."
  28357. }
  28358. },
  28359. returns = {
  28360. {
  28361. name = "m",
  28362. type = "Mat4",
  28363. description = "The input matrix."
  28364. }
  28365. }
  28366. },
  28367. {
  28368. description = "Sets the pose (position and orientation) of the matrix using numbers. The scale is set to 1 on all axes.",
  28369. arguments = {
  28370. {
  28371. name = "x",
  28372. type = "number",
  28373. description = "The x component of the translation."
  28374. },
  28375. {
  28376. name = "y",
  28377. type = "number",
  28378. description = "The y component of the translation."
  28379. },
  28380. {
  28381. name = "z",
  28382. type = "number",
  28383. description = "The z component of the translation."
  28384. },
  28385. {
  28386. name = "angle",
  28387. type = "number",
  28388. description = "The angle of the rotation, in radians."
  28389. },
  28390. {
  28391. name = "ax",
  28392. type = "number",
  28393. description = "The x component of the axis of rotation."
  28394. },
  28395. {
  28396. name = "ay",
  28397. type = "number",
  28398. description = "The y component of the axis of rotation."
  28399. },
  28400. {
  28401. name = "az",
  28402. type = "number",
  28403. description = "The z component of the axis of rotation."
  28404. }
  28405. },
  28406. returns = {
  28407. {
  28408. name = "m",
  28409. type = "Mat4",
  28410. description = "The input matrix."
  28411. }
  28412. }
  28413. },
  28414. {
  28415. arguments = {
  28416. {
  28417. name = "position",
  28418. type = "Vec3",
  28419. description = "The translation of the matrix."
  28420. },
  28421. {
  28422. name = "scale",
  28423. type = "Vec3",
  28424. description = "The scale of the matrix."
  28425. },
  28426. {
  28427. name = "rotation",
  28428. type = "Quat",
  28429. description = "The rotation of the matrix."
  28430. }
  28431. },
  28432. returns = {
  28433. {
  28434. name = "m",
  28435. type = "Mat4",
  28436. description = "The input matrix."
  28437. }
  28438. }
  28439. },
  28440. {
  28441. arguments = {
  28442. {
  28443. name = "position",
  28444. type = "Vec3",
  28445. description = "The translation of the matrix."
  28446. },
  28447. {
  28448. name = "rotation",
  28449. type = "Quat",
  28450. description = "The rotation of the matrix."
  28451. }
  28452. },
  28453. returns = {
  28454. {
  28455. name = "m",
  28456. type = "Mat4",
  28457. description = "The input matrix."
  28458. }
  28459. }
  28460. },
  28461. {
  28462. description = "Sets the raw components of the matrix using 16 numbers in column-major order.",
  28463. arguments = {
  28464. {
  28465. name = "...",
  28466. type = "number",
  28467. description = "The raw values of the matrix, in column-major order."
  28468. }
  28469. },
  28470. returns = {
  28471. {
  28472. name = "m",
  28473. type = "Mat4",
  28474. description = "The input matrix."
  28475. }
  28476. }
  28477. },
  28478. {
  28479. description = "Sets the diagonal values to a number and everything else to 0.",
  28480. arguments = {
  28481. {
  28482. name = "d",
  28483. type = "number",
  28484. description = "A number to use for the diagonal elements."
  28485. }
  28486. },
  28487. returns = {
  28488. {
  28489. name = "m",
  28490. type = "Mat4",
  28491. description = "The input matrix."
  28492. }
  28493. }
  28494. }
  28495. }
  28496. },
  28497. {
  28498. name = "target",
  28499. summary = "Create a model transform that targets from a position to target position.",
  28500. description = "Sets a model transform matrix that moves to `from` and orients model towards `to` point.\n\nThis is used when rendered model should always point towards a point of interest. The resulting Mat4 object can be used as model pose.\n\nThe target() function produces same result as lookAt() after matrix inversion.",
  28501. key = "Mat4:target",
  28502. module = "lovr.math",
  28503. related = {
  28504. "Mat4:lookAt",
  28505. "Quat:direction"
  28506. },
  28507. variants = {
  28508. {
  28509. arguments = {
  28510. {
  28511. name = "from",
  28512. type = "Vec3",
  28513. description = "The position of the viewer."
  28514. },
  28515. {
  28516. name = "to",
  28517. type = "Vec3",
  28518. description = "The position of the target."
  28519. },
  28520. {
  28521. name = "up",
  28522. type = "Vec3",
  28523. description = "The up vector of the viewer.",
  28524. default = "Vec3(0, 1, 0)"
  28525. }
  28526. },
  28527. returns = {
  28528. {
  28529. name = "self",
  28530. type = "Mat4",
  28531. description = "The modified matrix."
  28532. }
  28533. }
  28534. }
  28535. }
  28536. },
  28537. {
  28538. name = "translate",
  28539. summary = "Translate the matrix.",
  28540. description = "Translates the matrix.",
  28541. key = "Mat4:translate",
  28542. module = "lovr.math",
  28543. related = {
  28544. "Mat4:rotate",
  28545. "Mat4:scale",
  28546. "Mat4:identity"
  28547. },
  28548. variants = {
  28549. {
  28550. arguments = {
  28551. {
  28552. name = "v",
  28553. type = "Vec3",
  28554. description = "The translation vector."
  28555. }
  28556. },
  28557. returns = {
  28558. {
  28559. name = "self",
  28560. type = "Mat4",
  28561. description = "The translated matrix."
  28562. }
  28563. }
  28564. },
  28565. {
  28566. arguments = {
  28567. {
  28568. name = "x",
  28569. type = "number",
  28570. description = "The x component of the translation."
  28571. },
  28572. {
  28573. name = "y",
  28574. type = "number",
  28575. description = "The y component of the translation."
  28576. },
  28577. {
  28578. name = "z",
  28579. type = "number",
  28580. description = "The z component of the translation."
  28581. }
  28582. },
  28583. returns = {
  28584. {
  28585. name = "self",
  28586. type = "Mat4",
  28587. description = "The translated matrix."
  28588. }
  28589. }
  28590. }
  28591. }
  28592. },
  28593. {
  28594. name = "transpose",
  28595. summary = "Transpose the matrix.",
  28596. description = "Transposes the matrix, mirroring its values along the diagonal.",
  28597. key = "Mat4:transpose",
  28598. module = "lovr.math",
  28599. variants = {
  28600. {
  28601. arguments = {},
  28602. returns = {
  28603. {
  28604. name = "self",
  28605. type = "Mat4",
  28606. description = "The transposed matrix."
  28607. }
  28608. }
  28609. }
  28610. }
  28611. },
  28612. {
  28613. name = "unpack",
  28614. summary = "Get the individual components of the matrix.",
  28615. description = "Returns the components of matrix, either as 10 separated numbers representing the position, scale, and rotation, or as 16 raw numbers representing the individual components of the matrix in column-major order.",
  28616. key = "Mat4:unpack",
  28617. module = "lovr.math",
  28618. related = {
  28619. "Mat4:set",
  28620. "Mat4:getPosition",
  28621. "Mat4:getOrientation",
  28622. "Mat4:getScale",
  28623. "Mat4:getPose"
  28624. },
  28625. variants = {
  28626. {
  28627. arguments = {
  28628. {
  28629. name = "raw",
  28630. type = "boolean",
  28631. description = "Whether to return the 16 raw components.",
  28632. default = "false"
  28633. }
  28634. },
  28635. returns = {
  28636. {
  28637. name = "...",
  28638. type = "number",
  28639. description = "The requested components of the matrix."
  28640. }
  28641. }
  28642. }
  28643. }
  28644. }
  28645. },
  28646. related = {
  28647. "Vec3",
  28648. "Quat",
  28649. "Vectors"
  28650. }
  28651. },
  28652. {
  28653. name = "Quat",
  28654. summary = "A quaternion.",
  28655. description = "A `quat` is a math type that represents a 3D rotation, stored as four numbers.",
  28656. key = "Quat",
  28657. module = "lovr.math",
  28658. constructors = {
  28659. "lovr.math.newQuat",
  28660. "lovr.math.quat"
  28661. },
  28662. methods = {
  28663. {
  28664. name = "conjugate",
  28665. summary = "Conjugate (invert) the quaternion.",
  28666. description = "Conjugates the input quaternion in place, returning the input. If the quaternion is normalized, this is the same as inverting it. It negates the (x, y, z) components of the quaternion.",
  28667. key = "Quat:conjugate",
  28668. module = "lovr.math",
  28669. variants = {
  28670. {
  28671. arguments = {},
  28672. returns = {
  28673. {
  28674. name = "self",
  28675. type = "Quat",
  28676. description = "The inverted quaternion."
  28677. }
  28678. }
  28679. }
  28680. }
  28681. },
  28682. {
  28683. name = "direction",
  28684. summary = "Get the direction of the quaternion.",
  28685. description = "Creates a new temporary vec3 facing the forward direction, rotates it by this quaternion, and returns the vector.",
  28686. key = "Quat:direction",
  28687. module = "lovr.math",
  28688. related = {
  28689. "Mat4:lookAt"
  28690. },
  28691. variants = {
  28692. {
  28693. arguments = {},
  28694. returns = {
  28695. {
  28696. name = "v",
  28697. type = "Vec3",
  28698. description = "The direction vector."
  28699. }
  28700. }
  28701. }
  28702. }
  28703. },
  28704. {
  28705. name = "equals",
  28706. summary = "Check if a quaternion equals another quaternion.",
  28707. description = "Returns whether a quaternion is approximately equal to another quaternion.",
  28708. key = "Quat:equals",
  28709. module = "lovr.math",
  28710. related = {
  28711. "Vec2:equals",
  28712. "Vec3:equals",
  28713. "Vec4:equals",
  28714. "Mat4:equals"
  28715. },
  28716. variants = {
  28717. {
  28718. arguments = {
  28719. {
  28720. name = "r",
  28721. type = "Quat",
  28722. description = "The other quaternion."
  28723. }
  28724. },
  28725. returns = {
  28726. {
  28727. name = "equal",
  28728. type = "boolean",
  28729. description = "Whether the 2 quaternions approximately equal each other."
  28730. }
  28731. }
  28732. }
  28733. }
  28734. },
  28735. {
  28736. name = "length",
  28737. summary = "Get the length of the quaternion.",
  28738. description = "Returns the length of the quaternion.",
  28739. key = "Quat:length",
  28740. module = "lovr.math",
  28741. related = {
  28742. "Quat:normalize"
  28743. },
  28744. variants = {
  28745. {
  28746. arguments = {},
  28747. returns = {
  28748. {
  28749. name = "length",
  28750. type = "number",
  28751. description = "The length of the quaternion."
  28752. }
  28753. }
  28754. }
  28755. }
  28756. },
  28757. {
  28758. name = "mul",
  28759. summary = "Multiply a quaternion by another quaternion or a vector.",
  28760. description = "Multiplies this quaternion by another value. If the value is a quaternion, the rotations in the two quaternions are applied sequentially and the result is stored in the first quaternion. If the value is a vector, then the input vector is rotated by the quaternion and returned.",
  28761. key = "Quat:mul",
  28762. module = "lovr.math",
  28763. variants = {
  28764. {
  28765. arguments = {
  28766. {
  28767. name = "r",
  28768. type = "Quat",
  28769. description = "A quaternion to combine with the original."
  28770. }
  28771. },
  28772. returns = {
  28773. {
  28774. name = "self",
  28775. type = "Quat",
  28776. description = "The modified quaternion."
  28777. }
  28778. }
  28779. },
  28780. {
  28781. arguments = {
  28782. {
  28783. name = "v3",
  28784. type = "Vec3",
  28785. description = "A vector to rotate."
  28786. }
  28787. },
  28788. returns = {
  28789. {
  28790. name = "v3",
  28791. type = "Vec3",
  28792. description = "The rotated vector."
  28793. }
  28794. }
  28795. }
  28796. }
  28797. },
  28798. {
  28799. name = "normalize",
  28800. summary = "Normalize the length of the quaternion to 1.",
  28801. description = "Adjusts the values in the quaternion so that its length becomes 1.",
  28802. key = "Quat:normalize",
  28803. module = "lovr.math",
  28804. notes = "A common source of bugs with quaternions is to forget to normalize them after performing a series of operations on them. Try normalizing a quaternion if some of the calculations aren't working quite right!",
  28805. related = {
  28806. "Quat:length"
  28807. },
  28808. variants = {
  28809. {
  28810. arguments = {},
  28811. returns = {
  28812. {
  28813. name = "self",
  28814. type = "Quat",
  28815. description = "The normalized quaternion."
  28816. }
  28817. }
  28818. }
  28819. }
  28820. },
  28821. {
  28822. name = "set",
  28823. summary = "Set the components of the quaternion.",
  28824. description = "Sets the components of the quaternion. There are lots of different ways to specify the new components, the summary is:\n\n- Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.\n- Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion.\n- An existing quaternion can be passed in to copy its values.\n- A single direction vector can be specified to turn its direction (relative to the default\n forward direction of \"negative z\") into a rotation.\n- Two direction vectors can be specified to set the quaternion equal to the rotation between the\n two vectors.\n- A matrix can be passed in to extract the rotation of the matrix into a quaternion.",
  28825. key = "Quat:set",
  28826. module = "lovr.math",
  28827. related = {
  28828. "Quat:unpack"
  28829. },
  28830. variants = {
  28831. {
  28832. arguments = {
  28833. {
  28834. name = "angle",
  28835. type = "number",
  28836. description = "The angle to use for the rotation, in radians.",
  28837. default = "0"
  28838. },
  28839. {
  28840. name = "ax",
  28841. type = "number",
  28842. description = "The x component of the axis of rotation.",
  28843. default = "0"
  28844. },
  28845. {
  28846. name = "ay",
  28847. type = "number",
  28848. description = "The y component of the axis of rotation.",
  28849. default = "0"
  28850. },
  28851. {
  28852. name = "az",
  28853. type = "number",
  28854. description = "The z component of the axis of rotation.",
  28855. default = "0"
  28856. },
  28857. {
  28858. name = "raw",
  28859. type = "boolean",
  28860. description = "Whether the components should be interpreted as raw `(x, y, z, w)` components.",
  28861. default = "false"
  28862. }
  28863. },
  28864. returns = {
  28865. {
  28866. name = "self",
  28867. type = "Quat",
  28868. description = "The modified quaternion."
  28869. }
  28870. }
  28871. },
  28872. {
  28873. arguments = {
  28874. {
  28875. name = "r",
  28876. type = "Quat",
  28877. description = "An existing quaternion to copy the values from."
  28878. }
  28879. },
  28880. returns = {
  28881. {
  28882. name = "self",
  28883. type = "Quat",
  28884. description = "The modified quaternion."
  28885. }
  28886. }
  28887. },
  28888. {
  28889. description = "Sets the values from a direction vector.",
  28890. arguments = {
  28891. {
  28892. name = "v",
  28893. type = "Vec3",
  28894. description = "A normalized direction vector."
  28895. }
  28896. },
  28897. returns = {
  28898. {
  28899. name = "self",
  28900. type = "Quat",
  28901. description = "The modified quaternion."
  28902. }
  28903. }
  28904. },
  28905. {
  28906. description = "Sets the values to represent the rotation between two vectors.",
  28907. arguments = {
  28908. {
  28909. name = "v",
  28910. type = "Vec3",
  28911. description = "A normalized direction vector."
  28912. },
  28913. {
  28914. name = "u",
  28915. type = "Vec3",
  28916. description = "Another normalized direction vector."
  28917. }
  28918. },
  28919. returns = {
  28920. {
  28921. name = "self",
  28922. type = "Quat",
  28923. description = "The modified quaternion."
  28924. }
  28925. }
  28926. },
  28927. {
  28928. arguments = {
  28929. {
  28930. name = "m",
  28931. type = "Mat4",
  28932. description = "A matrix to use the rotation from."
  28933. }
  28934. },
  28935. returns = {
  28936. {
  28937. name = "self",
  28938. type = "Quat",
  28939. description = "The modified quaternion."
  28940. }
  28941. }
  28942. },
  28943. {
  28944. description = "Reset the quaternion to the identity (0, 0, 0, 1).",
  28945. arguments = {},
  28946. returns = {
  28947. {
  28948. name = "self",
  28949. type = "Quat",
  28950. description = "The modified quaternion."
  28951. }
  28952. }
  28953. }
  28954. }
  28955. },
  28956. {
  28957. name = "slerp",
  28958. summary = "Moves this quaternion some amount towards another one.",
  28959. description = "Performs a spherical linear interpolation between this quaternion and another one, which can be used for smoothly animating between two rotations.\n\nThe amount of interpolation is controlled by a parameter `t`. A `t` value of zero leaves the original quaternion unchanged, whereas a `t` of one sets the original quaternion exactly equal to the target. A value between `0` and `1` returns a rotation between the two based on the value.",
  28960. key = "Quat:slerp",
  28961. module = "lovr.math",
  28962. related = {
  28963. "Vec3:lerp"
  28964. },
  28965. variants = {
  28966. {
  28967. arguments = {
  28968. {
  28969. name = "r",
  28970. type = "Quat",
  28971. description = "The quaternion to slerp towards."
  28972. },
  28973. {
  28974. name = "t",
  28975. type = "number",
  28976. description = "The lerping parameter."
  28977. }
  28978. },
  28979. returns = {
  28980. {
  28981. name = "self",
  28982. type = "Quat",
  28983. description = "The modified quaternion, containing the new lerped values."
  28984. }
  28985. }
  28986. }
  28987. }
  28988. },
  28989. {
  28990. name = "unpack",
  28991. summary = "Get the components of the quaternion.",
  28992. description = "Returns the components of the quaternion as numbers, either in an angle/axis representation or as raw quaternion values.",
  28993. key = "Quat:unpack",
  28994. module = "lovr.math",
  28995. related = {
  28996. "Quat:set"
  28997. },
  28998. variants = {
  28999. {
  29000. arguments = {
  29001. {
  29002. name = "raw",
  29003. type = "boolean",
  29004. description = "Whether the values should be returned as raw values instead of angle/axis.",
  29005. default = "false"
  29006. }
  29007. },
  29008. returns = {
  29009. {
  29010. name = "a",
  29011. type = "number",
  29012. description = "The angle in radians, or the x value."
  29013. },
  29014. {
  29015. name = "b",
  29016. type = "number",
  29017. description = "The x component of the rotation axis or the y value."
  29018. },
  29019. {
  29020. name = "c",
  29021. type = "number",
  29022. description = "The y component of the rotation axis or the z value."
  29023. },
  29024. {
  29025. name = "d",
  29026. type = "number",
  29027. description = "The z component of the rotation axis or the w value."
  29028. }
  29029. }
  29030. }
  29031. }
  29032. }
  29033. },
  29034. related = {
  29035. "Vec3",
  29036. "Mat4",
  29037. "Vectors"
  29038. }
  29039. },
  29040. {
  29041. name = "RandomGenerator",
  29042. summary = "A pseudo-random number generator.",
  29043. description = "A RandomGenerator is a standalone object that can be used to independently generate pseudo-random numbers. If you just need basic randomness, you can use `lovr.math.random` without needing to create a random generator.",
  29044. key = "RandomGenerator",
  29045. module = "lovr.math",
  29046. constructors = {
  29047. "lovr.math.newRandomGenerator"
  29048. },
  29049. methods = {
  29050. {
  29051. name = "getSeed",
  29052. summary = "Get the seed value of the RandomGenerator.",
  29053. description = "Returns the seed used to initialize the RandomGenerator.",
  29054. key = "RandomGenerator:getSeed",
  29055. module = "lovr.math",
  29056. notes = "Since the seed is a 64 bit integer, each 32 bits of the seed are returned separately to avoid precision issues.",
  29057. related = {
  29058. "lovr.math.newRandomGenerator"
  29059. },
  29060. variants = {
  29061. {
  29062. arguments = {},
  29063. returns = {
  29064. {
  29065. name = "low",
  29066. type = "number",
  29067. description = "The lower 32 bits of the seed."
  29068. },
  29069. {
  29070. name = "high",
  29071. type = "number",
  29072. description = "The upper 32 bits of the seed."
  29073. }
  29074. }
  29075. }
  29076. }
  29077. },
  29078. {
  29079. name = "getState",
  29080. summary = "Get the current state of the RandomGenerator.",
  29081. description = "Returns the current state of the RandomGenerator. This can be used with `RandomGenerator:setState` to reliably restore a previous state of the generator.",
  29082. key = "RandomGenerator:getState",
  29083. module = "lovr.math",
  29084. notes = "The seed represents the starting state of the RandomGenerator, whereas the state represents the current state of the generator.",
  29085. variants = {
  29086. {
  29087. arguments = {},
  29088. returns = {
  29089. {
  29090. name = "state",
  29091. type = "string",
  29092. description = "The serialized state."
  29093. }
  29094. }
  29095. }
  29096. }
  29097. },
  29098. {
  29099. name = "random",
  29100. summary = "Get a random number.",
  29101. description = "Returns the next uniformly distributed pseudo-random number from the RandomGenerator's sequence.",
  29102. key = "RandomGenerator:random",
  29103. module = "lovr.math",
  29104. related = {
  29105. "lovr.math.random",
  29106. "RandomGenerator:randomNormal"
  29107. },
  29108. variants = {
  29109. {
  29110. description = "Generate a pseudo-random floating point number in the range `[0,1)`",
  29111. arguments = {},
  29112. returns = {
  29113. {
  29114. name = "x",
  29115. type = "number",
  29116. description = "A pseudo-random number."
  29117. }
  29118. }
  29119. },
  29120. {
  29121. description = "Generate a pseudo-random integer in the range `[1,high]`",
  29122. arguments = {
  29123. {
  29124. name = "high",
  29125. type = "number",
  29126. description = "The maximum number to generate."
  29127. }
  29128. },
  29129. returns = {
  29130. {
  29131. name = "x",
  29132. type = "number",
  29133. description = "A pseudo-random number."
  29134. }
  29135. }
  29136. },
  29137. {
  29138. description = "Generate a pseudo-random integer in the range `[low,high]`",
  29139. arguments = {
  29140. {
  29141. name = "low",
  29142. type = "number",
  29143. description = "The minimum number to generate."
  29144. },
  29145. {
  29146. name = "high",
  29147. type = "number",
  29148. description = "The maximum number to generate."
  29149. }
  29150. },
  29151. returns = {
  29152. {
  29153. name = "x",
  29154. type = "number",
  29155. description = "A pseudo-random number."
  29156. }
  29157. }
  29158. }
  29159. }
  29160. },
  29161. {
  29162. name = "randomNormal",
  29163. summary = "Get a random number from a normal distribution.",
  29164. description = "Returns a pseudo-random number from a normal distribution (a bell curve). You can control the center of the bell curve (the mean value) and the overall width (sigma, or standard deviation).",
  29165. key = "RandomGenerator:randomNormal",
  29166. module = "lovr.math",
  29167. related = {
  29168. "lovr.math.randomNormal",
  29169. "RandomGenerator:random"
  29170. },
  29171. variants = {
  29172. {
  29173. arguments = {
  29174. {
  29175. name = "sigma",
  29176. type = "number",
  29177. description = "The standard deviation of the distribution. This can be thought of how \"wide\" the range of numbers is or how much variability there is.",
  29178. default = "1"
  29179. },
  29180. {
  29181. name = "mu",
  29182. type = "number",
  29183. description = "The average value returned.",
  29184. default = "0"
  29185. }
  29186. },
  29187. returns = {
  29188. {
  29189. name = "x",
  29190. type = "number",
  29191. description = "A normally distributed pseudo-random number."
  29192. }
  29193. }
  29194. }
  29195. }
  29196. },
  29197. {
  29198. name = "setSeed",
  29199. summary = "Reinitialize the RandomGenerator with a new seed.",
  29200. description = "Seed the RandomGenerator with a new seed. Each seed will cause the RandomGenerator to produce a unique sequence of random numbers.",
  29201. key = "RandomGenerator:setSeed",
  29202. module = "lovr.math",
  29203. notes = "For precise 64 bit seeds, you should specify the lower and upper 32 bits of the seed separately. Otherwise, seeds larger than 2^53 will start to lose precision.",
  29204. variants = {
  29205. {
  29206. arguments = {
  29207. {
  29208. name = "seed",
  29209. type = "number",
  29210. description = "The random seed."
  29211. }
  29212. },
  29213. returns = {}
  29214. },
  29215. {
  29216. arguments = {
  29217. {
  29218. name = "low",
  29219. type = "number",
  29220. description = "The lower 32 bits of the seed."
  29221. },
  29222. {
  29223. name = "high",
  29224. type = "number",
  29225. description = "The upper 32 bits of the seed."
  29226. }
  29227. },
  29228. returns = {}
  29229. }
  29230. }
  29231. },
  29232. {
  29233. name = "setState",
  29234. summary = "Set the state of the RandomGenerator.",
  29235. description = "Sets the state of the RandomGenerator, as previously obtained using `RandomGenerator:getState`. This can be used to reliably restore a previous state of the generator.",
  29236. key = "RandomGenerator:setState",
  29237. module = "lovr.math",
  29238. notes = "The seed represents the starting state of the RandomGenerator, whereas the state represents the current state of the generator.",
  29239. variants = {
  29240. {
  29241. arguments = {
  29242. {
  29243. name = "state",
  29244. type = "string",
  29245. description = "The serialized state."
  29246. }
  29247. },
  29248. returns = {}
  29249. }
  29250. }
  29251. }
  29252. }
  29253. },
  29254. {
  29255. name = "Vec2",
  29256. summary = "A 2D vector.",
  29257. description = "A vector object that holds two numbers.",
  29258. key = "Vec2",
  29259. module = "lovr.math",
  29260. constructors = {
  29261. "lovr.math.newVec2",
  29262. "lovr.math.vec2"
  29263. },
  29264. methods = {
  29265. {
  29266. name = "add",
  29267. summary = "Add a vector or a number to the vector.",
  29268. description = "Adds a vector or a number to the vector.",
  29269. key = "Vec2:add",
  29270. module = "lovr.math",
  29271. related = {
  29272. "Vec2:sub",
  29273. "Vec2:mul",
  29274. "Vec2:div"
  29275. },
  29276. variants = {
  29277. {
  29278. arguments = {
  29279. {
  29280. name = "u",
  29281. type = "Vec2",
  29282. description = "The other vector."
  29283. }
  29284. },
  29285. returns = {
  29286. {
  29287. name = "self",
  29288. type = "Vec2",
  29289. description = "The modified vector."
  29290. }
  29291. }
  29292. },
  29293. {
  29294. arguments = {
  29295. {
  29296. name = "x",
  29297. type = "number",
  29298. description = "A value to add to x component."
  29299. },
  29300. {
  29301. name = "y",
  29302. type = "number",
  29303. description = "A value to add to y component.",
  29304. default = "x"
  29305. }
  29306. },
  29307. returns = {
  29308. {
  29309. name = "self",
  29310. type = "Vec2",
  29311. description = "The modified vector."
  29312. }
  29313. }
  29314. }
  29315. }
  29316. },
  29317. {
  29318. name = "angle",
  29319. summary = "Get the angle to another vector.",
  29320. description = "Returns the angle between vectors.",
  29321. key = "Vec2:angle",
  29322. module = "lovr.math",
  29323. notes = "If any of the two vectors have a length of zero, the angle between them is not well defined. In this case the function returns `math.pi / 2`.",
  29324. related = {
  29325. "Vec2:distance",
  29326. "Vec2:length"
  29327. },
  29328. variants = {
  29329. {
  29330. arguments = {
  29331. {
  29332. name = "u",
  29333. type = "Vec2",
  29334. description = "The other vector."
  29335. }
  29336. },
  29337. returns = {
  29338. {
  29339. name = "angle",
  29340. type = "number",
  29341. description = "The angle to the other vector, in radians."
  29342. }
  29343. }
  29344. },
  29345. {
  29346. arguments = {
  29347. {
  29348. name = "x",
  29349. type = "number",
  29350. description = "The x component of the other vector."
  29351. },
  29352. {
  29353. name = "y",
  29354. type = "number",
  29355. description = "The y component of the other vector."
  29356. }
  29357. },
  29358. returns = {
  29359. {
  29360. name = "angle",
  29361. type = "number",
  29362. description = "The angle to the other vector, in radians."
  29363. }
  29364. }
  29365. }
  29366. }
  29367. },
  29368. {
  29369. name = "distance",
  29370. summary = "Get the distance to another vector.",
  29371. description = "Returns the distance to another vector.",
  29372. key = "Vec2:distance",
  29373. module = "lovr.math",
  29374. related = {
  29375. "Vec2:angle",
  29376. "Vec2:length"
  29377. },
  29378. variants = {
  29379. {
  29380. arguments = {
  29381. {
  29382. name = "u",
  29383. type = "Vec2",
  29384. description = "The vector to measure the distance to."
  29385. }
  29386. },
  29387. returns = {
  29388. {
  29389. name = "distance",
  29390. type = "number",
  29391. description = "The distance to `u`."
  29392. }
  29393. }
  29394. },
  29395. {
  29396. arguments = {
  29397. {
  29398. name = "x",
  29399. type = "number",
  29400. description = "A value of x component to measure distance to."
  29401. },
  29402. {
  29403. name = "y",
  29404. type = "number",
  29405. description = "A value of y component to measure distance to."
  29406. }
  29407. },
  29408. returns = {
  29409. {
  29410. name = "distance",
  29411. type = "number",
  29412. description = "The distance to `u`."
  29413. }
  29414. }
  29415. }
  29416. }
  29417. },
  29418. {
  29419. name = "div",
  29420. summary = "Divides the vector by a vector or a number.",
  29421. description = "Divides the vector by a vector or a number.",
  29422. key = "Vec2:div",
  29423. module = "lovr.math",
  29424. related = {
  29425. "Vec2:add",
  29426. "Vec2:sub",
  29427. "Vec2:mul"
  29428. },
  29429. variants = {
  29430. {
  29431. arguments = {
  29432. {
  29433. name = "u",
  29434. type = "Vec2",
  29435. description = "The other vector to divide the components by."
  29436. }
  29437. },
  29438. returns = {
  29439. {
  29440. name = "self",
  29441. type = "Vec2",
  29442. description = "The modified vector."
  29443. }
  29444. }
  29445. },
  29446. {
  29447. arguments = {
  29448. {
  29449. name = "x",
  29450. type = "number",
  29451. description = "A value to divide x component by."
  29452. },
  29453. {
  29454. name = "y",
  29455. type = "number",
  29456. description = "A value to divide y component by.",
  29457. default = "x"
  29458. }
  29459. },
  29460. returns = {
  29461. {
  29462. name = "self",
  29463. type = "Vec2",
  29464. description = "The modified vector."
  29465. }
  29466. }
  29467. }
  29468. }
  29469. },
  29470. {
  29471. name = "dot",
  29472. summary = "Get the dot product with another vector.",
  29473. description = "Returns the dot product between this vector and another one.",
  29474. key = "Vec2:dot",
  29475. module = "lovr.math",
  29476. notes = "This is computed as:\n\n dot = v.x * u.x + v.y * u.y\n\nThe vectors are not normalized before computing the dot product.",
  29477. variants = {
  29478. {
  29479. arguments = {
  29480. {
  29481. name = "u",
  29482. type = "Vec2",
  29483. description = "The vector to compute the dot product with."
  29484. }
  29485. },
  29486. returns = {
  29487. {
  29488. name = "dot",
  29489. type = "number",
  29490. description = "The dot product between `v` and `u`."
  29491. }
  29492. }
  29493. },
  29494. {
  29495. arguments = {
  29496. {
  29497. name = "x",
  29498. type = "number",
  29499. description = "A value of x component to compute the dot product with."
  29500. },
  29501. {
  29502. name = "y",
  29503. type = "number",
  29504. description = "A value of y component to compute the dot product with."
  29505. }
  29506. },
  29507. returns = {
  29508. {
  29509. name = "dot",
  29510. type = "number",
  29511. description = "The dot product between `v` and `u`."
  29512. }
  29513. }
  29514. }
  29515. }
  29516. },
  29517. {
  29518. name = "equals",
  29519. summary = "Check if a vector equals another vector.",
  29520. description = "Returns whether a vector is approximately equal to another vector.",
  29521. key = "Vec2:equals",
  29522. module = "lovr.math",
  29523. notes = "To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`.",
  29524. related = {
  29525. "Vec3:equals",
  29526. "Vec4:equals",
  29527. "Quat:equals",
  29528. "Mat4:equals"
  29529. },
  29530. variants = {
  29531. {
  29532. arguments = {
  29533. {
  29534. name = "u",
  29535. type = "Vec2",
  29536. description = "The other vector."
  29537. }
  29538. },
  29539. returns = {
  29540. {
  29541. name = "equal",
  29542. type = "boolean",
  29543. description = "Whether the 2 vectors approximately equal each other."
  29544. }
  29545. }
  29546. },
  29547. {
  29548. arguments = {
  29549. {
  29550. name = "x",
  29551. type = "number",
  29552. description = "The x component of the other vector."
  29553. },
  29554. {
  29555. name = "y",
  29556. type = "number",
  29557. description = "The y component of the other vector."
  29558. }
  29559. },
  29560. returns = {
  29561. {
  29562. name = "equal",
  29563. type = "boolean",
  29564. description = "Whether the 2 vectors approximately equal each other."
  29565. }
  29566. }
  29567. }
  29568. }
  29569. },
  29570. {
  29571. name = "length",
  29572. summary = "Get the length of the vector.",
  29573. description = "Returns the length of the vector.",
  29574. key = "Vec2:length",
  29575. module = "lovr.math",
  29576. notes = "The length is equivalent to this:\n\n math.sqrt(v.x * v.x + v.y * v.y)",
  29577. related = {
  29578. "Vec2:normalize",
  29579. "Vec2:distance"
  29580. },
  29581. variants = {
  29582. {
  29583. arguments = {},
  29584. returns = {
  29585. {
  29586. name = "length",
  29587. type = "number",
  29588. description = "The length of the vector."
  29589. }
  29590. }
  29591. }
  29592. }
  29593. },
  29594. {
  29595. name = "lerp",
  29596. summary = "Moves this vector some amount towards another one.",
  29597. description = "Performs a linear interpolation between this vector and another one, which can be used to smoothly animate between two vectors, based on a parameter value. A parameter value of `0` will leave the vector unchanged, a parameter value of `1` will set the vector to be equal to the input vector, and a value of `.5` will set the components to be halfway between the two vectors.",
  29598. key = "Vec2:lerp",
  29599. module = "lovr.math",
  29600. related = {
  29601. "Quat:slerp"
  29602. },
  29603. variants = {
  29604. {
  29605. arguments = {
  29606. {
  29607. name = "u",
  29608. type = "Vec2",
  29609. description = "The vector to lerp towards."
  29610. },
  29611. {
  29612. name = "t",
  29613. type = "number",
  29614. description = "The lerping parameter."
  29615. }
  29616. },
  29617. returns = {
  29618. {
  29619. name = "self",
  29620. type = "Vec2",
  29621. description = "The interpolated vector."
  29622. }
  29623. }
  29624. },
  29625. {
  29626. arguments = {
  29627. {
  29628. name = "x",
  29629. type = "number",
  29630. description = "A value of x component to lerp towards."
  29631. },
  29632. {
  29633. name = "y",
  29634. type = "number",
  29635. description = "A value of y component to lerp towards."
  29636. },
  29637. {
  29638. name = "t",
  29639. type = "number",
  29640. description = "The lerping parameter."
  29641. }
  29642. },
  29643. returns = {
  29644. {
  29645. name = "self",
  29646. type = "Vec2",
  29647. description = "The interpolated vector."
  29648. }
  29649. }
  29650. }
  29651. }
  29652. },
  29653. {
  29654. name = "mul",
  29655. summary = "Multiply the vector by a vector or a number.",
  29656. description = "Multiplies the vector by a vector or a number.",
  29657. key = "Vec2:mul",
  29658. module = "lovr.math",
  29659. related = {
  29660. "Vec2:add",
  29661. "Vec2:sub",
  29662. "Vec2:div"
  29663. },
  29664. variants = {
  29665. {
  29666. arguments = {
  29667. {
  29668. name = "u",
  29669. type = "Vec2",
  29670. description = "The other vector to multiply the components by."
  29671. }
  29672. },
  29673. returns = {
  29674. {
  29675. name = "self",
  29676. type = "Vec2",
  29677. description = "The modified vector."
  29678. }
  29679. }
  29680. },
  29681. {
  29682. arguments = {
  29683. {
  29684. name = "x",
  29685. type = "number",
  29686. description = "A value to multiply x component by."
  29687. },
  29688. {
  29689. name = "y",
  29690. type = "number",
  29691. description = "A value to multiply y component by.",
  29692. default = "x"
  29693. }
  29694. },
  29695. returns = {
  29696. {
  29697. name = "self",
  29698. type = "Vec2",
  29699. description = "The modified vector."
  29700. }
  29701. }
  29702. }
  29703. }
  29704. },
  29705. {
  29706. name = "normalize",
  29707. summary = "Normalize the length of the vector to 1.",
  29708. description = "Adjusts the values in the vector so that its direction stays the same but its length becomes 1.",
  29709. key = "Vec2:normalize",
  29710. module = "lovr.math",
  29711. related = {
  29712. "Vec2:length"
  29713. },
  29714. variants = {
  29715. {
  29716. arguments = {},
  29717. returns = {
  29718. {
  29719. name = "self",
  29720. type = "Vec2",
  29721. description = "The normalized vector."
  29722. }
  29723. }
  29724. }
  29725. }
  29726. },
  29727. {
  29728. name = "set",
  29729. summary = "Set the components of the vector.",
  29730. description = "Sets the components of the vector, either from numbers or an existing vector.",
  29731. key = "Vec2:set",
  29732. module = "lovr.math",
  29733. related = {
  29734. "Vec2:unpack"
  29735. },
  29736. variants = {
  29737. {
  29738. arguments = {
  29739. {
  29740. name = "x",
  29741. type = "number",
  29742. description = "The new x value of the vector.",
  29743. default = "0"
  29744. },
  29745. {
  29746. name = "y",
  29747. type = "number",
  29748. description = "The new y value of the vector.",
  29749. default = "x"
  29750. }
  29751. },
  29752. returns = {
  29753. {
  29754. name = "v",
  29755. type = "Vec2",
  29756. description = "The input vector."
  29757. }
  29758. }
  29759. },
  29760. {
  29761. arguments = {
  29762. {
  29763. name = "u",
  29764. type = "Vec2",
  29765. description = "The vector to copy the values from."
  29766. }
  29767. },
  29768. returns = {
  29769. {
  29770. name = "v",
  29771. type = "Vec2",
  29772. description = "The input vector."
  29773. }
  29774. }
  29775. }
  29776. }
  29777. },
  29778. {
  29779. name = "sub",
  29780. summary = "Subtract a vector or a number from the vector.",
  29781. description = "Subtracts a vector or a number from the vector.",
  29782. key = "Vec2:sub",
  29783. module = "lovr.math",
  29784. related = {
  29785. "Vec2:add",
  29786. "Vec2:mul",
  29787. "Vec2:div"
  29788. },
  29789. variants = {
  29790. {
  29791. arguments = {
  29792. {
  29793. name = "u",
  29794. type = "Vec2",
  29795. description = "The other vector."
  29796. }
  29797. },
  29798. returns = {
  29799. {
  29800. name = "self",
  29801. type = "Vec2",
  29802. description = "The modified vector."
  29803. }
  29804. }
  29805. },
  29806. {
  29807. arguments = {
  29808. {
  29809. name = "x",
  29810. type = "number",
  29811. description = "A value to subtract from x component."
  29812. },
  29813. {
  29814. name = "y",
  29815. type = "number",
  29816. description = "A value to subtract from y component.",
  29817. default = "x"
  29818. }
  29819. },
  29820. returns = {
  29821. {
  29822. name = "self",
  29823. type = "Vec2",
  29824. description = "The modified vector."
  29825. }
  29826. }
  29827. }
  29828. }
  29829. },
  29830. {
  29831. name = "unpack",
  29832. summary = "Get the components of the vector.",
  29833. description = "Returns the 2 components of the vector as numbers.",
  29834. key = "Vec2:unpack",
  29835. module = "lovr.math",
  29836. related = {
  29837. "Vec2:set"
  29838. },
  29839. variants = {
  29840. {
  29841. arguments = {},
  29842. returns = {
  29843. {
  29844. name = "x",
  29845. type = "number",
  29846. description = "The x value."
  29847. },
  29848. {
  29849. name = "y",
  29850. type = "number",
  29851. description = "The y value."
  29852. }
  29853. }
  29854. }
  29855. }
  29856. }
  29857. },
  29858. related = {
  29859. "Vec3",
  29860. "Vec4",
  29861. "Vectors"
  29862. }
  29863. },
  29864. {
  29865. name = "Vec3",
  29866. summary = "A 3D vector.",
  29867. description = "A vector object that holds three numbers.",
  29868. key = "Vec3",
  29869. module = "lovr.math",
  29870. constructors = {
  29871. "lovr.math.newVec3",
  29872. "lovr.math.vec3"
  29873. },
  29874. methods = {
  29875. {
  29876. name = "add",
  29877. summary = "Add a vector or a number to the vector.",
  29878. description = "Adds a vector or a number to the vector.",
  29879. key = "Vec3:add",
  29880. module = "lovr.math",
  29881. related = {
  29882. "Vec3:sub",
  29883. "Vec3:mul",
  29884. "Vec3:div"
  29885. },
  29886. variants = {
  29887. {
  29888. arguments = {
  29889. {
  29890. name = "u",
  29891. type = "Vec3",
  29892. description = "The other vector."
  29893. }
  29894. },
  29895. returns = {
  29896. {
  29897. name = "self",
  29898. type = "Vec3",
  29899. description = "The modified vector."
  29900. }
  29901. }
  29902. },
  29903. {
  29904. arguments = {
  29905. {
  29906. name = "x",
  29907. type = "number",
  29908. description = "A value to add to x component."
  29909. },
  29910. {
  29911. name = "y",
  29912. type = "number",
  29913. description = "A value to add to y component.",
  29914. default = "x"
  29915. },
  29916. {
  29917. name = "z",
  29918. type = "number",
  29919. description = "A value to add to z component.",
  29920. default = "x"
  29921. }
  29922. },
  29923. returns = {
  29924. {
  29925. name = "self",
  29926. type = "Vec3",
  29927. description = "The modified vector."
  29928. }
  29929. }
  29930. }
  29931. }
  29932. },
  29933. {
  29934. name = "angle",
  29935. summary = "Get the angle to another vector.",
  29936. description = "Returns the angle between vectors.",
  29937. key = "Vec3:angle",
  29938. module = "lovr.math",
  29939. notes = "If any of the two vectors have a length of zero, the angle between them is not well defined. In this case the function returns `math.pi / 2`.",
  29940. related = {
  29941. "Vec3:distance",
  29942. "Vec3:length"
  29943. },
  29944. variants = {
  29945. {
  29946. arguments = {
  29947. {
  29948. name = "u",
  29949. type = "Vec3",
  29950. description = "The other vector."
  29951. }
  29952. },
  29953. returns = {
  29954. {
  29955. name = "angle",
  29956. type = "number",
  29957. description = "The angle to the other vector, in radians."
  29958. }
  29959. }
  29960. },
  29961. {
  29962. arguments = {
  29963. {
  29964. name = "x",
  29965. type = "number",
  29966. description = "The x component of the other vector."
  29967. },
  29968. {
  29969. name = "y",
  29970. type = "number",
  29971. description = "The y component of the other vector."
  29972. },
  29973. {
  29974. name = "z",
  29975. type = "number",
  29976. description = "The z component of the other vector."
  29977. }
  29978. },
  29979. returns = {
  29980. {
  29981. name = "angle",
  29982. type = "number",
  29983. description = "The angle to the other vector, in radians."
  29984. }
  29985. }
  29986. }
  29987. }
  29988. },
  29989. {
  29990. name = "cross",
  29991. summary = "Get the cross product with another vector.",
  29992. description = "Sets this vector to be equal to the cross product between this vector and another one. The new `v` will be perpendicular to both the old `v` and `u`.",
  29993. key = "Vec3:cross",
  29994. module = "lovr.math",
  29995. notes = "The vectors are not normalized before or after computing the cross product.",
  29996. related = {
  29997. "Vec3:dot"
  29998. },
  29999. variants = {
  30000. {
  30001. arguments = {
  30002. {
  30003. name = "u",
  30004. type = "Vec3",
  30005. description = "The vector to compute the cross product with."
  30006. }
  30007. },
  30008. returns = {
  30009. {
  30010. name = "self",
  30011. type = "Vec3",
  30012. description = "The modified vector."
  30013. }
  30014. }
  30015. },
  30016. {
  30017. arguments = {
  30018. {
  30019. name = "x",
  30020. type = "number",
  30021. description = "A value of x component to compute cross product with."
  30022. },
  30023. {
  30024. name = "y",
  30025. type = "number",
  30026. description = "A value of y component to compute cross product with."
  30027. },
  30028. {
  30029. name = "z",
  30030. type = "number",
  30031. description = "A value of z component to compute cross product with."
  30032. }
  30033. },
  30034. returns = {
  30035. {
  30036. name = "self",
  30037. type = "Vec3",
  30038. description = "The modified vector."
  30039. }
  30040. }
  30041. }
  30042. }
  30043. },
  30044. {
  30045. name = "distance",
  30046. summary = "Get the distance to another vector.",
  30047. description = "Returns the distance to another vector.",
  30048. key = "Vec3:distance",
  30049. module = "lovr.math",
  30050. related = {
  30051. "Vec3:angle",
  30052. "Vec3:length"
  30053. },
  30054. variants = {
  30055. {
  30056. arguments = {
  30057. {
  30058. name = "u",
  30059. type = "Vec3",
  30060. description = "The vector to measure the distance to."
  30061. }
  30062. },
  30063. returns = {
  30064. {
  30065. name = "distance",
  30066. type = "number",
  30067. description = "The distance to `u`."
  30068. }
  30069. }
  30070. },
  30071. {
  30072. arguments = {
  30073. {
  30074. name = "x",
  30075. type = "number",
  30076. description = "A value of x component to measure distance to."
  30077. },
  30078. {
  30079. name = "y",
  30080. type = "number",
  30081. description = "A value of y component to measure distance to."
  30082. },
  30083. {
  30084. name = "z",
  30085. type = "number",
  30086. description = "A value of z component to measure distance to."
  30087. }
  30088. },
  30089. returns = {
  30090. {
  30091. name = "distance",
  30092. type = "number",
  30093. description = "The distance to `u`."
  30094. }
  30095. }
  30096. }
  30097. }
  30098. },
  30099. {
  30100. name = "div",
  30101. summary = "Divides the vector by a vector or a number.",
  30102. description = "Divides the vector by a vector or a number.",
  30103. key = "Vec3:div",
  30104. module = "lovr.math",
  30105. related = {
  30106. "Vec3:add",
  30107. "Vec3:sub",
  30108. "Vec3:mul"
  30109. },
  30110. variants = {
  30111. {
  30112. arguments = {
  30113. {
  30114. name = "u",
  30115. type = "Vec3",
  30116. description = "The other vector to divide the components by."
  30117. }
  30118. },
  30119. returns = {
  30120. {
  30121. name = "self",
  30122. type = "Vec3",
  30123. description = "The modified vector."
  30124. }
  30125. }
  30126. },
  30127. {
  30128. arguments = {
  30129. {
  30130. name = "x",
  30131. type = "number",
  30132. description = "A value to divide x component by."
  30133. },
  30134. {
  30135. name = "y",
  30136. type = "number",
  30137. description = "A value to divide y component by.",
  30138. default = "x"
  30139. },
  30140. {
  30141. name = "z",
  30142. type = "number",
  30143. description = "A value to divide z component by.",
  30144. default = "x"
  30145. }
  30146. },
  30147. returns = {
  30148. {
  30149. name = "self",
  30150. type = "Vec3",
  30151. description = "The modified vector."
  30152. }
  30153. }
  30154. }
  30155. }
  30156. },
  30157. {
  30158. name = "dot",
  30159. summary = "Get the dot product with another vector.",
  30160. description = "Returns the dot product between this vector and another one.",
  30161. key = "Vec3:dot",
  30162. module = "lovr.math",
  30163. notes = "This is computed as:\n\n dot = v.x * u.x + v.y * u.y + v.z * u.z\n\nThe vectors are not normalized before computing the dot product.",
  30164. related = {
  30165. "Vec3:cross"
  30166. },
  30167. variants = {
  30168. {
  30169. arguments = {
  30170. {
  30171. name = "u",
  30172. type = "Vec3",
  30173. description = "The vector to compute the dot product with."
  30174. }
  30175. },
  30176. returns = {
  30177. {
  30178. name = "dot",
  30179. type = "number",
  30180. description = "The dot product between `v` and `u`."
  30181. }
  30182. }
  30183. },
  30184. {
  30185. arguments = {
  30186. {
  30187. name = "x",
  30188. type = "number",
  30189. description = "A value of x component to compute the dot product with."
  30190. },
  30191. {
  30192. name = "y",
  30193. type = "number",
  30194. description = "A value of y component to compute the dot product with."
  30195. },
  30196. {
  30197. name = "z",
  30198. type = "number",
  30199. description = "A value of z component to compute the dot product with."
  30200. }
  30201. },
  30202. returns = {
  30203. {
  30204. name = "dot",
  30205. type = "number",
  30206. description = "The dot product between `v` and `u`."
  30207. }
  30208. }
  30209. }
  30210. }
  30211. },
  30212. {
  30213. name = "equals",
  30214. summary = "Check if a vector equals another vector.",
  30215. description = "Returns whether a vector is approximately equal to another vector.",
  30216. key = "Vec3:equals",
  30217. module = "lovr.math",
  30218. notes = "To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`.",
  30219. related = {
  30220. "Vec2:equals",
  30221. "Vec4:equals",
  30222. "Quat:equals",
  30223. "Mat4:equals"
  30224. },
  30225. variants = {
  30226. {
  30227. arguments = {
  30228. {
  30229. name = "u",
  30230. type = "Vec3",
  30231. description = "The other vector."
  30232. }
  30233. },
  30234. returns = {
  30235. {
  30236. name = "equal",
  30237. type = "boolean",
  30238. description = "Whether the 2 vectors approximately equal each other."
  30239. }
  30240. }
  30241. },
  30242. {
  30243. arguments = {
  30244. {
  30245. name = "x",
  30246. type = "number",
  30247. description = "The x component of the other vector."
  30248. },
  30249. {
  30250. name = "y",
  30251. type = "number",
  30252. description = "The y component of the other vector."
  30253. },
  30254. {
  30255. name = "z",
  30256. type = "number",
  30257. description = "The z component of the other vector."
  30258. }
  30259. },
  30260. returns = {
  30261. {
  30262. name = "equal",
  30263. type = "boolean",
  30264. description = "Whether the 2 vectors approximately equal each other."
  30265. }
  30266. }
  30267. }
  30268. }
  30269. },
  30270. {
  30271. name = "length",
  30272. summary = "Get the length of the vector.",
  30273. description = "Returns the length of the vector.",
  30274. key = "Vec3:length",
  30275. module = "lovr.math",
  30276. notes = "The length is equivalent to this:\n\n math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)",
  30277. related = {
  30278. "Vec3:normalize",
  30279. "Vec3:distance"
  30280. },
  30281. variants = {
  30282. {
  30283. arguments = {},
  30284. returns = {
  30285. {
  30286. name = "length",
  30287. type = "number",
  30288. description = "The length of the vector."
  30289. }
  30290. }
  30291. }
  30292. }
  30293. },
  30294. {
  30295. name = "lerp",
  30296. summary = "Moves this vector some amount towards another one.",
  30297. description = "Performs a linear interpolation between this vector and another one, which can be used to smoothly animate between two vectors, based on a parameter value. A parameter value of `0` will leave the vector unchanged, a parameter value of `1` will set the vector to be equal to the input vector, and a value of `.5` will set the components to be halfway between the two vectors.",
  30298. key = "Vec3:lerp",
  30299. module = "lovr.math",
  30300. related = {
  30301. "Quat:slerp"
  30302. },
  30303. variants = {
  30304. {
  30305. arguments = {
  30306. {
  30307. name = "u",
  30308. type = "Vec3",
  30309. description = "The vector to lerp towards."
  30310. },
  30311. {
  30312. name = "t",
  30313. type = "number",
  30314. description = "The lerping parameter."
  30315. }
  30316. },
  30317. returns = {
  30318. {
  30319. name = "self",
  30320. type = "Vec3",
  30321. description = "The interpolated vector."
  30322. }
  30323. }
  30324. },
  30325. {
  30326. arguments = {
  30327. {
  30328. name = "x",
  30329. type = "number",
  30330. description = "A value of x component to lerp towards."
  30331. },
  30332. {
  30333. name = "y",
  30334. type = "number",
  30335. description = "A value of y component to lerp towards."
  30336. },
  30337. {
  30338. name = "z",
  30339. type = "number",
  30340. description = "A value of z component to lerp towards."
  30341. },
  30342. {
  30343. name = "t",
  30344. type = "number",
  30345. description = "The lerping parameter."
  30346. }
  30347. },
  30348. returns = {
  30349. {
  30350. name = "self",
  30351. type = "Vec3",
  30352. description = "The interpolated vector."
  30353. }
  30354. }
  30355. }
  30356. }
  30357. },
  30358. {
  30359. name = "mul",
  30360. summary = "Multiply the vector by a vector or a number.",
  30361. description = "Multiplies the vector by a vector or a number.",
  30362. key = "Vec3:mul",
  30363. module = "lovr.math",
  30364. related = {
  30365. "Vec3:add",
  30366. "Vec3:sub",
  30367. "Vec3:div"
  30368. },
  30369. variants = {
  30370. {
  30371. arguments = {
  30372. {
  30373. name = "u",
  30374. type = "Vec3",
  30375. description = "The other vector to multiply the components by."
  30376. }
  30377. },
  30378. returns = {
  30379. {
  30380. name = "self",
  30381. type = "Vec3",
  30382. description = "The modified vector."
  30383. }
  30384. }
  30385. },
  30386. {
  30387. arguments = {
  30388. {
  30389. name = "x",
  30390. type = "number",
  30391. description = "A value to multiply x component by."
  30392. },
  30393. {
  30394. name = "y",
  30395. type = "number",
  30396. description = "A value to multiply y component by.",
  30397. default = "x"
  30398. },
  30399. {
  30400. name = "z",
  30401. type = "number",
  30402. description = "A value to multiply z component by.",
  30403. default = "x"
  30404. }
  30405. },
  30406. returns = {
  30407. {
  30408. name = "self",
  30409. type = "Vec3",
  30410. description = "The modified vector."
  30411. }
  30412. }
  30413. }
  30414. }
  30415. },
  30416. {
  30417. name = "normalize",
  30418. summary = "Normalize the length of the vector to 1.",
  30419. description = "Adjusts the values in the vector so that its direction stays the same but its length becomes 1.",
  30420. key = "Vec3:normalize",
  30421. module = "lovr.math",
  30422. related = {
  30423. "Vec3:length"
  30424. },
  30425. variants = {
  30426. {
  30427. arguments = {},
  30428. returns = {
  30429. {
  30430. name = "self",
  30431. type = "Vec3",
  30432. description = "The normalized vector."
  30433. }
  30434. }
  30435. }
  30436. }
  30437. },
  30438. {
  30439. name = "rotate",
  30440. summary = "Apply a rotation to the vector.",
  30441. description = "Applies a rotation to the vector, using a `Quat` or an angle/axis rotation.",
  30442. key = "Vec3:rotate",
  30443. module = "lovr.math",
  30444. related = {
  30445. "Quat:mul"
  30446. },
  30447. variants = {
  30448. {
  30449. arguments = {
  30450. {
  30451. name = "q",
  30452. type = "Quat",
  30453. description = "The quaternion to apply."
  30454. }
  30455. },
  30456. returns = {
  30457. {
  30458. name = "self",
  30459. type = "Vec3",
  30460. description = "The modified vector."
  30461. }
  30462. }
  30463. },
  30464. {
  30465. arguments = {
  30466. {
  30467. name = "angle",
  30468. type = "number",
  30469. description = "The number of radians to rotate."
  30470. },
  30471. {
  30472. name = "ax",
  30473. type = "number",
  30474. description = "The x component of the axis to rotate around."
  30475. },
  30476. {
  30477. name = "ay",
  30478. type = "number",
  30479. description = "The y component of the axis to rotate around."
  30480. },
  30481. {
  30482. name = "az",
  30483. type = "number",
  30484. description = "The z component of the axis to rotate around."
  30485. }
  30486. },
  30487. returns = {
  30488. {
  30489. name = "self",
  30490. type = "Vec3",
  30491. description = "The modified vector."
  30492. }
  30493. }
  30494. }
  30495. }
  30496. },
  30497. {
  30498. name = "set",
  30499. summary = "Set the components of the vector.",
  30500. description = "Sets the components of the vector, either from numbers or an existing vector.",
  30501. key = "Vec3:set",
  30502. module = "lovr.math",
  30503. related = {
  30504. "Vec3:unpack"
  30505. },
  30506. variants = {
  30507. {
  30508. arguments = {
  30509. {
  30510. name = "x",
  30511. type = "number",
  30512. description = "The new x value of the vector.",
  30513. default = "0"
  30514. },
  30515. {
  30516. name = "y",
  30517. type = "number",
  30518. description = "The new y value of the vector.",
  30519. default = "x"
  30520. },
  30521. {
  30522. name = "z",
  30523. type = "number",
  30524. description = "The new z value of the vector.",
  30525. default = "x"
  30526. }
  30527. },
  30528. returns = {
  30529. {
  30530. name = "v",
  30531. type = "Vec3",
  30532. description = "The input vector."
  30533. }
  30534. }
  30535. },
  30536. {
  30537. arguments = {
  30538. {
  30539. name = "u",
  30540. type = "Vec3",
  30541. description = "The vector to copy the values from."
  30542. }
  30543. },
  30544. returns = {
  30545. {
  30546. name = "v",
  30547. type = "Vec3",
  30548. description = "The input vector."
  30549. }
  30550. }
  30551. },
  30552. {
  30553. arguments = {
  30554. {
  30555. name = "q",
  30556. type = "Quat",
  30557. description = "A quat to use the direction of."
  30558. }
  30559. },
  30560. returns = {
  30561. {
  30562. name = "v",
  30563. type = "Vec3",
  30564. description = "The input vector."
  30565. }
  30566. }
  30567. },
  30568. {
  30569. arguments = {
  30570. {
  30571. name = "m",
  30572. type = "Mat4",
  30573. description = "The matrix to use the position of."
  30574. }
  30575. },
  30576. returns = {
  30577. {
  30578. name = "v",
  30579. type = "Vec3",
  30580. description = "The input vector."
  30581. }
  30582. }
  30583. }
  30584. }
  30585. },
  30586. {
  30587. name = "sub",
  30588. summary = "Subtract a vector or a number from the vector.",
  30589. description = "Subtracts a vector or a number from the vector.",
  30590. key = "Vec3:sub",
  30591. module = "lovr.math",
  30592. related = {
  30593. "Vec3:add",
  30594. "Vec3:mul",
  30595. "Vec3:div"
  30596. },
  30597. variants = {
  30598. {
  30599. arguments = {
  30600. {
  30601. name = "u",
  30602. type = "Vec3",
  30603. description = "The other vector."
  30604. }
  30605. },
  30606. returns = {
  30607. {
  30608. name = "self",
  30609. type = "Vec3",
  30610. description = "The modified vector."
  30611. }
  30612. }
  30613. },
  30614. {
  30615. arguments = {
  30616. {
  30617. name = "x",
  30618. type = "number",
  30619. description = "A value to subtract from x component."
  30620. },
  30621. {
  30622. name = "y",
  30623. type = "number",
  30624. description = "A value to subtract from y component.",
  30625. default = "x"
  30626. },
  30627. {
  30628. name = "z",
  30629. type = "number",
  30630. description = "A value to subtract from z component.",
  30631. default = "x"
  30632. }
  30633. },
  30634. returns = {
  30635. {
  30636. name = "self",
  30637. type = "Vec3",
  30638. description = "The modified vector."
  30639. }
  30640. }
  30641. }
  30642. }
  30643. },
  30644. {
  30645. name = "transform",
  30646. summary = "Apply a transform to the vector.",
  30647. description = "Applies a transform (translation, rotation, scale) to the vector using a `Mat4` or numbers. This is the same as multiplying the vector by a matrix. This treats the vector as a point.",
  30648. key = "Vec3:transform",
  30649. module = "lovr.math",
  30650. related = {
  30651. "Mat4:mul",
  30652. "Vec4:transform",
  30653. "Vec3:rotate"
  30654. },
  30655. variants = {
  30656. {
  30657. arguments = {
  30658. {
  30659. name = "m",
  30660. type = "Mat4",
  30661. description = "The matrix to apply."
  30662. }
  30663. },
  30664. returns = {
  30665. {
  30666. name = "self",
  30667. type = "Vec3",
  30668. description = "The original vector, with transformed components."
  30669. }
  30670. }
  30671. },
  30672. {
  30673. arguments = {
  30674. {
  30675. name = "x",
  30676. type = "number",
  30677. description = "The x component of the translation.",
  30678. default = "0"
  30679. },
  30680. {
  30681. name = "y",
  30682. type = "number",
  30683. description = "The y component of the translation.",
  30684. default = "0"
  30685. },
  30686. {
  30687. name = "z",
  30688. type = "number",
  30689. description = "The z component of the translation.",
  30690. default = "0"
  30691. },
  30692. {
  30693. name = "scale",
  30694. type = "number",
  30695. description = "The scale factor.",
  30696. default = "1"
  30697. },
  30698. {
  30699. name = "angle",
  30700. type = "number",
  30701. description = "The number of radians to rotate around the rotation axis.",
  30702. default = "0"
  30703. },
  30704. {
  30705. name = "ax",
  30706. type = "number",
  30707. description = "The x component of the axis of rotation.",
  30708. default = "0"
  30709. },
  30710. {
  30711. name = "ay",
  30712. type = "number",
  30713. description = "The y component of the axis of rotation.",
  30714. default = "1"
  30715. },
  30716. {
  30717. name = "az",
  30718. type = "number",
  30719. description = "The z component of the axis of rotation.",
  30720. default = "0"
  30721. }
  30722. },
  30723. returns = {
  30724. {
  30725. name = "self",
  30726. type = "Vec3",
  30727. description = "The original vector, with transformed components."
  30728. }
  30729. }
  30730. },
  30731. {
  30732. arguments = {
  30733. {
  30734. name = "translation",
  30735. type = "Vec3",
  30736. description = "The translation to apply."
  30737. },
  30738. {
  30739. name = "scale",
  30740. type = "number",
  30741. description = "The scale factor.",
  30742. default = "1"
  30743. },
  30744. {
  30745. name = "rotation",
  30746. type = "Quat",
  30747. description = "The rotation to apply."
  30748. }
  30749. },
  30750. returns = {
  30751. {
  30752. name = "self",
  30753. type = "Vec3",
  30754. description = "The original vector, with transformed components."
  30755. }
  30756. }
  30757. }
  30758. }
  30759. },
  30760. {
  30761. name = "unpack",
  30762. summary = "Get the components of the vector.",
  30763. description = "Returns the 3 components of the vector as numbers.",
  30764. key = "Vec3:unpack",
  30765. module = "lovr.math",
  30766. related = {
  30767. "Vec3:set"
  30768. },
  30769. variants = {
  30770. {
  30771. arguments = {},
  30772. returns = {
  30773. {
  30774. name = "x",
  30775. type = "number",
  30776. description = "The x value."
  30777. },
  30778. {
  30779. name = "y",
  30780. type = "number",
  30781. description = "The y value."
  30782. },
  30783. {
  30784. name = "z",
  30785. type = "number",
  30786. description = "The z value."
  30787. }
  30788. }
  30789. }
  30790. }
  30791. }
  30792. },
  30793. related = {
  30794. "Vec2",
  30795. "Vec4",
  30796. "Vectors"
  30797. }
  30798. },
  30799. {
  30800. name = "Vec4",
  30801. summary = "A 4D vector.",
  30802. description = "A vector object that holds four numbers.",
  30803. key = "Vec4",
  30804. module = "lovr.math",
  30805. constructors = {
  30806. "lovr.math.newVec4",
  30807. "lovr.math.vec4"
  30808. },
  30809. methods = {
  30810. {
  30811. name = "add",
  30812. summary = "Add a vector or a number to the vector.",
  30813. description = "Adds a vector or a number to the vector.",
  30814. key = "Vec4:add",
  30815. module = "lovr.math",
  30816. related = {
  30817. "Vec4:sub",
  30818. "Vec4:mul",
  30819. "Vec4:div"
  30820. },
  30821. variants = {
  30822. {
  30823. arguments = {
  30824. {
  30825. name = "u",
  30826. type = "Vec4",
  30827. description = "The other vector."
  30828. }
  30829. },
  30830. returns = {
  30831. {
  30832. name = "self",
  30833. type = "Vec4",
  30834. description = "The modified vector."
  30835. }
  30836. }
  30837. },
  30838. {
  30839. arguments = {
  30840. {
  30841. name = "x",
  30842. type = "number",
  30843. description = "A value to add to x component."
  30844. },
  30845. {
  30846. name = "y",
  30847. type = "number",
  30848. description = "A value to add to y component.",
  30849. default = "x"
  30850. },
  30851. {
  30852. name = "z",
  30853. type = "number",
  30854. description = "A value to add to z component.",
  30855. default = "x"
  30856. },
  30857. {
  30858. name = "w",
  30859. type = "number",
  30860. description = "A value to add to w component.",
  30861. default = "x"
  30862. }
  30863. },
  30864. returns = {
  30865. {
  30866. name = "self",
  30867. type = "Vec4",
  30868. description = "The modified vector."
  30869. }
  30870. }
  30871. }
  30872. }
  30873. },
  30874. {
  30875. name = "angle",
  30876. summary = "Get the angle to another vector.",
  30877. description = "Returns the angle between vectors.",
  30878. key = "Vec4:angle",
  30879. module = "lovr.math",
  30880. notes = "If any of the two vectors have a length of zero, the angle between them is not well defined. In this case the function returns `math.pi / 2`.",
  30881. related = {
  30882. "Vec4:distance",
  30883. "Vec4:length"
  30884. },
  30885. variants = {
  30886. {
  30887. arguments = {
  30888. {
  30889. name = "u",
  30890. type = "Vec4",
  30891. description = "The other vector."
  30892. }
  30893. },
  30894. returns = {
  30895. {
  30896. name = "angle",
  30897. type = "number",
  30898. description = "The angle to other vector, in radians."
  30899. }
  30900. }
  30901. },
  30902. {
  30903. arguments = {
  30904. {
  30905. name = "x",
  30906. type = "number",
  30907. description = "The x component of the other vector."
  30908. },
  30909. {
  30910. name = "y",
  30911. type = "number",
  30912. description = "The y component of the other vector."
  30913. },
  30914. {
  30915. name = "z",
  30916. type = "number",
  30917. description = "The z component of the other vector."
  30918. },
  30919. {
  30920. name = "w",
  30921. type = "number",
  30922. description = "The w component of the other vector."
  30923. }
  30924. },
  30925. returns = {
  30926. {
  30927. name = "angle",
  30928. type = "number",
  30929. description = "The angle to other vector, in radians."
  30930. }
  30931. }
  30932. }
  30933. }
  30934. },
  30935. {
  30936. name = "distance",
  30937. summary = "Get the distance to another vector.",
  30938. description = "Returns the distance to another vector.",
  30939. key = "Vec4:distance",
  30940. module = "lovr.math",
  30941. related = {
  30942. "Vec4:angle",
  30943. "Vec4:length"
  30944. },
  30945. variants = {
  30946. {
  30947. arguments = {
  30948. {
  30949. name = "u",
  30950. type = "Vec4",
  30951. description = "The vector to measure the distance to."
  30952. }
  30953. },
  30954. returns = {
  30955. {
  30956. name = "distance",
  30957. type = "number",
  30958. description = "The distance to `u`."
  30959. }
  30960. }
  30961. },
  30962. {
  30963. arguments = {
  30964. {
  30965. name = "x",
  30966. type = "number",
  30967. description = "A value of x component to measure distance to."
  30968. },
  30969. {
  30970. name = "y",
  30971. type = "number",
  30972. description = "A value of y component to measure distance to."
  30973. },
  30974. {
  30975. name = "z",
  30976. type = "number",
  30977. description = "A value of z component to measure distance to."
  30978. },
  30979. {
  30980. name = "w",
  30981. type = "number",
  30982. description = "A value of w component to measure distance to."
  30983. }
  30984. },
  30985. returns = {
  30986. {
  30987. name = "distance",
  30988. type = "number",
  30989. description = "The distance to `u`."
  30990. }
  30991. }
  30992. }
  30993. }
  30994. },
  30995. {
  30996. name = "div",
  30997. summary = "Divides the vector by a vector or a number.",
  30998. description = "Divides the vector by a vector or a number.",
  30999. key = "Vec4:div",
  31000. module = "lovr.math",
  31001. related = {
  31002. "Vec4:add",
  31003. "Vec4:sub",
  31004. "Vec4:mul"
  31005. },
  31006. variants = {
  31007. {
  31008. arguments = {
  31009. {
  31010. name = "u",
  31011. type = "Vec4",
  31012. description = "The other vector to divide the components by."
  31013. }
  31014. },
  31015. returns = {
  31016. {
  31017. name = "self",
  31018. type = "Vec4",
  31019. description = "The modified vector."
  31020. }
  31021. }
  31022. },
  31023. {
  31024. arguments = {
  31025. {
  31026. name = "x",
  31027. type = "number",
  31028. description = "A value to divide x component by."
  31029. },
  31030. {
  31031. name = "y",
  31032. type = "number",
  31033. description = "A value to divide y component by.",
  31034. default = "x"
  31035. },
  31036. {
  31037. name = "z",
  31038. type = "number",
  31039. description = "A value to divide z component by.",
  31040. default = "x"
  31041. },
  31042. {
  31043. name = "w",
  31044. type = "number",
  31045. description = "A value to divide w component by.",
  31046. default = "x"
  31047. }
  31048. },
  31049. returns = {
  31050. {
  31051. name = "self",
  31052. type = "Vec4",
  31053. description = "The modified vector."
  31054. }
  31055. }
  31056. }
  31057. }
  31058. },
  31059. {
  31060. name = "dot",
  31061. summary = "Get the dot product with another vector.",
  31062. description = "Returns the dot product between this vector and another one.",
  31063. key = "Vec4:dot",
  31064. module = "lovr.math",
  31065. notes = "This is computed as:\n\n dot = v.x * u.x + v.y * u.y + v.z * u.z + v.w * u.w\n\nThe vectors are not normalized before computing the dot product.",
  31066. variants = {
  31067. {
  31068. arguments = {
  31069. {
  31070. name = "u",
  31071. type = "Vec4",
  31072. description = "The vector to compute the dot product with."
  31073. }
  31074. },
  31075. returns = {
  31076. {
  31077. name = "dot",
  31078. type = "number",
  31079. description = "The dot product between `v` and `u`."
  31080. }
  31081. }
  31082. },
  31083. {
  31084. arguments = {
  31085. {
  31086. name = "x",
  31087. type = "number",
  31088. description = "A value of x component to compute the dot product with."
  31089. },
  31090. {
  31091. name = "y",
  31092. type = "number",
  31093. description = "A value of y component to compute the dot product with."
  31094. },
  31095. {
  31096. name = "z",
  31097. type = "number",
  31098. description = "A value of z component to compute the dot product with."
  31099. },
  31100. {
  31101. name = "w",
  31102. type = "number",
  31103. description = "A value of w component to compute the dot product with."
  31104. }
  31105. },
  31106. returns = {
  31107. {
  31108. name = "dot",
  31109. type = "number",
  31110. description = "The dot product between `v` and `u`."
  31111. }
  31112. }
  31113. }
  31114. }
  31115. },
  31116. {
  31117. name = "equals",
  31118. summary = "Check if a vector equals another vector.",
  31119. description = "Returns whether a vector is approximately equal to another vector.",
  31120. key = "Vec4:equals",
  31121. module = "lovr.math",
  31122. notes = "To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`.",
  31123. related = {
  31124. "Vec2:equals",
  31125. "Vec3:equals",
  31126. "Quat:equals",
  31127. "Mat4:equals"
  31128. },
  31129. variants = {
  31130. {
  31131. arguments = {
  31132. {
  31133. name = "u",
  31134. type = "Vec4",
  31135. description = "The other vector."
  31136. }
  31137. },
  31138. returns = {
  31139. {
  31140. name = "equal",
  31141. type = "boolean",
  31142. description = "Whether the 2 vectors approximately equal each other."
  31143. }
  31144. }
  31145. },
  31146. {
  31147. arguments = {
  31148. {
  31149. name = "x",
  31150. type = "number",
  31151. description = "The x component of the other vector."
  31152. },
  31153. {
  31154. name = "y",
  31155. type = "number",
  31156. description = "The y component of the other vector."
  31157. },
  31158. {
  31159. name = "z",
  31160. type = "number",
  31161. description = "The z component of the other vector."
  31162. },
  31163. {
  31164. name = "w",
  31165. type = "number",
  31166. description = "The w component of the other vector."
  31167. }
  31168. },
  31169. returns = {
  31170. {
  31171. name = "equal",
  31172. type = "boolean",
  31173. description = "Whether the 2 vectors approximately equal each other."
  31174. }
  31175. }
  31176. }
  31177. }
  31178. },
  31179. {
  31180. name = "length",
  31181. summary = "Get the length of the vector.",
  31182. description = "Returns the length of the vector.",
  31183. key = "Vec4:length",
  31184. module = "lovr.math",
  31185. notes = "The length is equivalent to this:\n\n math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w)",
  31186. related = {
  31187. "Vec4:normalize",
  31188. "Vec4:distance"
  31189. },
  31190. variants = {
  31191. {
  31192. arguments = {},
  31193. returns = {
  31194. {
  31195. name = "length",
  31196. type = "number",
  31197. description = "The length of the vector."
  31198. }
  31199. }
  31200. }
  31201. }
  31202. },
  31203. {
  31204. name = "lerp",
  31205. summary = "Moves this vector some amount towards another one.",
  31206. description = "Performs a linear interpolation between this vector and another one, which can be used to smoothly animate between two vectors, based on a parameter value. A parameter value of `0` will leave the vector unchanged, a parameter value of `1` will set the vector to be equal to the input vector, and a value of `.5` will set the components to be halfway between the two vectors.",
  31207. key = "Vec4:lerp",
  31208. module = "lovr.math",
  31209. related = {
  31210. "Quat:slerp"
  31211. },
  31212. variants = {
  31213. {
  31214. arguments = {
  31215. {
  31216. name = "u",
  31217. type = "Vec4",
  31218. description = "The vector to lerp towards."
  31219. },
  31220. {
  31221. name = "t",
  31222. type = "number",
  31223. description = "The lerping parameter."
  31224. }
  31225. },
  31226. returns = {
  31227. {
  31228. name = "self",
  31229. type = "Vec4",
  31230. description = "The interpolated vector."
  31231. }
  31232. }
  31233. },
  31234. {
  31235. arguments = {
  31236. {
  31237. name = "x",
  31238. type = "number",
  31239. description = "A value of x component to lerp towards."
  31240. },
  31241. {
  31242. name = "y",
  31243. type = "number",
  31244. description = "A value of y component to lerp towards."
  31245. },
  31246. {
  31247. name = "z",
  31248. type = "number",
  31249. description = "A value of z component to lerp towards."
  31250. },
  31251. {
  31252. name = "w",
  31253. type = "number",
  31254. description = "A value of w component to lerp towards."
  31255. },
  31256. {
  31257. name = "t",
  31258. type = "number",
  31259. description = "The lerping parameter."
  31260. }
  31261. },
  31262. returns = {
  31263. {
  31264. name = "self",
  31265. type = "Vec4",
  31266. description = "The interpolated vector."
  31267. }
  31268. }
  31269. }
  31270. }
  31271. },
  31272. {
  31273. name = "mul",
  31274. summary = "Multiply the vector by a vector or a number.",
  31275. description = "Multiplies the vector by a vector or a number.",
  31276. key = "Vec4:mul",
  31277. module = "lovr.math",
  31278. related = {
  31279. "Vec4:add",
  31280. "Vec4:sub",
  31281. "Vec4:div"
  31282. },
  31283. variants = {
  31284. {
  31285. arguments = {
  31286. {
  31287. name = "u",
  31288. type = "Vec4",
  31289. description = "The other vector to multiply the components by."
  31290. }
  31291. },
  31292. returns = {
  31293. {
  31294. name = "self",
  31295. type = "Vec4",
  31296. description = "The modified vector."
  31297. }
  31298. }
  31299. },
  31300. {
  31301. arguments = {
  31302. {
  31303. name = "x",
  31304. type = "number",
  31305. description = "A value to multiply x component by."
  31306. },
  31307. {
  31308. name = "y",
  31309. type = "number",
  31310. description = "A value to multiply y component by.",
  31311. default = "x"
  31312. },
  31313. {
  31314. name = "z",
  31315. type = "number",
  31316. description = "A value to multiply z component by.",
  31317. default = "x"
  31318. },
  31319. {
  31320. name = "w",
  31321. type = "number",
  31322. description = "A value to multiply w component by.",
  31323. default = "x"
  31324. }
  31325. },
  31326. returns = {
  31327. {
  31328. name = "self",
  31329. type = "Vec4",
  31330. description = "The modified vector."
  31331. }
  31332. }
  31333. }
  31334. }
  31335. },
  31336. {
  31337. name = "normalize",
  31338. summary = "Normalize the length of the vector to 1.",
  31339. description = "Adjusts the values in the vector so that its direction stays the same but its length becomes 1.",
  31340. key = "Vec4:normalize",
  31341. module = "lovr.math",
  31342. related = {
  31343. "Vec4:length"
  31344. },
  31345. variants = {
  31346. {
  31347. arguments = {},
  31348. returns = {
  31349. {
  31350. name = "self",
  31351. type = "Vec4",
  31352. description = "The normalized vector."
  31353. }
  31354. }
  31355. }
  31356. }
  31357. },
  31358. {
  31359. name = "set",
  31360. summary = "Set the components of the vector.",
  31361. description = "Sets the components of the vector, either from numbers or an existing vector.",
  31362. key = "Vec4:set",
  31363. module = "lovr.math",
  31364. related = {
  31365. "Vec4:unpack"
  31366. },
  31367. variants = {
  31368. {
  31369. arguments = {
  31370. {
  31371. name = "x",
  31372. type = "number",
  31373. description = "The new x value of the vector.",
  31374. default = "0"
  31375. },
  31376. {
  31377. name = "y",
  31378. type = "number",
  31379. description = "The new y value of the vector.",
  31380. default = "x"
  31381. },
  31382. {
  31383. name = "z",
  31384. type = "number",
  31385. description = "The new z value of the vector.",
  31386. default = "x"
  31387. },
  31388. {
  31389. name = "w",
  31390. type = "number",
  31391. description = "The new w value of the vector.",
  31392. default = "x"
  31393. }
  31394. },
  31395. returns = {
  31396. {
  31397. name = "v",
  31398. type = "Vec4",
  31399. description = "The input vector."
  31400. }
  31401. }
  31402. },
  31403. {
  31404. arguments = {
  31405. {
  31406. name = "u",
  31407. type = "Vec4",
  31408. description = "The vector to copy the values from."
  31409. }
  31410. },
  31411. returns = {
  31412. {
  31413. name = "v",
  31414. type = "Vec4",
  31415. description = "The input vector."
  31416. }
  31417. }
  31418. }
  31419. }
  31420. },
  31421. {
  31422. name = "sub",
  31423. summary = "Subtract a vector or a number from the vector.",
  31424. description = "Subtracts a vector or a number from the vector.",
  31425. key = "Vec4:sub",
  31426. module = "lovr.math",
  31427. related = {
  31428. "Vec4:add",
  31429. "Vec4:mul",
  31430. "Vec4:div"
  31431. },
  31432. variants = {
  31433. {
  31434. arguments = {
  31435. {
  31436. name = "u",
  31437. type = "Vec4",
  31438. description = "The other vector."
  31439. }
  31440. },
  31441. returns = {
  31442. {
  31443. name = "self",
  31444. type = "Vec4",
  31445. description = "The modified vector."
  31446. }
  31447. }
  31448. },
  31449. {
  31450. arguments = {
  31451. {
  31452. name = "x",
  31453. type = "number",
  31454. description = "A value to subtract from x component."
  31455. },
  31456. {
  31457. name = "y",
  31458. type = "number",
  31459. description = "A value to subtract from y component.",
  31460. default = "x"
  31461. },
  31462. {
  31463. name = "z",
  31464. type = "number",
  31465. description = "A value to subtract from z component.",
  31466. default = "x"
  31467. },
  31468. {
  31469. name = "w",
  31470. type = "number",
  31471. description = "A value to subtract from w component.",
  31472. default = "x"
  31473. }
  31474. },
  31475. returns = {
  31476. {
  31477. name = "self",
  31478. type = "Vec4",
  31479. description = "The modified vector."
  31480. }
  31481. }
  31482. }
  31483. }
  31484. },
  31485. {
  31486. name = "transform",
  31487. summary = "Apply a transform to the vector.",
  31488. description = "Applies a transform (translation, rotation, scale) to the vector using a `Mat4` or numbers. This is the same as multiplying the vector by a matrix.",
  31489. key = "Vec4:transform",
  31490. module = "lovr.math",
  31491. related = {
  31492. "Mat4:mul",
  31493. "Vec3:transform"
  31494. },
  31495. variants = {
  31496. {
  31497. arguments = {
  31498. {
  31499. name = "m",
  31500. type = "Mat4",
  31501. description = "The matrix to apply."
  31502. }
  31503. },
  31504. returns = {
  31505. {
  31506. name = "self",
  31507. type = "Vec4",
  31508. description = "The original vector, with transformed components."
  31509. }
  31510. }
  31511. },
  31512. {
  31513. arguments = {
  31514. {
  31515. name = "x",
  31516. type = "number",
  31517. description = "The x component of the translation.",
  31518. default = "0"
  31519. },
  31520. {
  31521. name = "y",
  31522. type = "number",
  31523. description = "The y component of the translation.",
  31524. default = "0"
  31525. },
  31526. {
  31527. name = "z",
  31528. type = "number",
  31529. description = "The z component of the translation.",
  31530. default = "0"
  31531. },
  31532. {
  31533. name = "scale",
  31534. type = "number",
  31535. description = "The scale factor.",
  31536. default = "1"
  31537. },
  31538. {
  31539. name = "angle",
  31540. type = "number",
  31541. description = "The number of radians to rotate around the rotation axis.",
  31542. default = "0"
  31543. },
  31544. {
  31545. name = "ax",
  31546. type = "number",
  31547. description = "The x component of the axis of rotation.",
  31548. default = "0"
  31549. },
  31550. {
  31551. name = "ay",
  31552. type = "number",
  31553. description = "The y component of the axis of rotation.",
  31554. default = "1"
  31555. },
  31556. {
  31557. name = "az",
  31558. type = "number",
  31559. description = "The z component of the axis of rotation.",
  31560. default = "0"
  31561. }
  31562. },
  31563. returns = {
  31564. {
  31565. name = "self",
  31566. type = "Vec4",
  31567. description = "The original vector, with transformed components."
  31568. }
  31569. }
  31570. },
  31571. {
  31572. arguments = {
  31573. {
  31574. name = "translation",
  31575. type = "Vec3",
  31576. description = "The translation to apply."
  31577. },
  31578. {
  31579. name = "scale",
  31580. type = "number",
  31581. description = "The scale factor.",
  31582. default = "1"
  31583. },
  31584. {
  31585. name = "rotation",
  31586. type = "Quat",
  31587. description = "The rotation to apply."
  31588. }
  31589. },
  31590. returns = {
  31591. {
  31592. name = "self",
  31593. type = "Vec4",
  31594. description = "The original vector, with transformed components."
  31595. }
  31596. }
  31597. }
  31598. }
  31599. },
  31600. {
  31601. name = "unpack",
  31602. summary = "Get the components of the vector.",
  31603. description = "Returns the 4 components of the vector as numbers.",
  31604. key = "Vec4:unpack",
  31605. module = "lovr.math",
  31606. related = {
  31607. "Vec4:set"
  31608. },
  31609. variants = {
  31610. {
  31611. arguments = {},
  31612. returns = {
  31613. {
  31614. name = "x",
  31615. type = "number",
  31616. description = "The x value."
  31617. },
  31618. {
  31619. name = "y",
  31620. type = "number",
  31621. description = "The y value."
  31622. },
  31623. {
  31624. name = "z",
  31625. type = "number",
  31626. description = "The z value."
  31627. },
  31628. {
  31629. name = "w",
  31630. type = "number",
  31631. description = "The w value."
  31632. }
  31633. }
  31634. }
  31635. }
  31636. }
  31637. },
  31638. related = {
  31639. "Vec2",
  31640. "Vec3",
  31641. "Vectors"
  31642. }
  31643. },
  31644. {
  31645. name = "Vectors",
  31646. summary = "What is your vector victor.",
  31647. description = "LÖVR has math objects for vectors, matrices, and quaternions, collectively called \"vector objects\". Vectors are useful because they can represent a multidimensional quantity (like a 3D position) using just a single value.",
  31648. key = "Vectors",
  31649. module = "lovr.math",
  31650. constructors = {
  31651. "lovr.math.vec2",
  31652. "lovr.math.vec3",
  31653. "lovr.math.vec4",
  31654. "lovr.math.quat",
  31655. "lovr.math.mat4",
  31656. "lovr.math.newVec2",
  31657. "lovr.math.newVec3",
  31658. "lovr.math.newVec4",
  31659. "lovr.math.newQuat",
  31660. "lovr.math.newMat4"
  31661. },
  31662. methods = {},
  31663. notes = "Most LÖVR functions that accept positions, orientations, transforms, velocities, etc. also accept vector objects, so they can be used interchangeably with numbers:\n\n function lovr.draw(pass)\n -- position and size are vec3's, rotation is a quat\n pass:box(position, size, rotation)\n end\n\n### Temporary vs. Permanent\n\nVectors can be created in two different ways: **permanent** and **temporary**.\n\n**Permanent** vectors behave like normal Lua values. They are individual objects that are garbage collected when no longer needed. They're created using the usual `lovr.math.new<Type>` syntax:\n\n self.position = lovr.math.newVec3(x, y, z)\n\n**Temporary** vectors are created from a shared pool of vector objects. This makes them faster because they use temporary memory and do not need to be garbage collected. To make a temporary vector, leave off the `new` prefix:\n\n local position = lovr.math.vec3(x, y, z)\n\nAs a shortcut, vector constructors are placed on the global scope. The uppercase name of the vector is a function that will create a permanent vector, and the lowercase name will create a temporary vector. This can be disabled using the `t.math.globals` option in `lovr.conf`.\n\n local position = vec3(x1, y1, z1) + vec3(x2, y2, z2)\n local transform = Mat4()\n\nTemporary vectors, with all their speed, come with an important restriction: they can only be used during the frame in which they were created. Saving them into variables and using them later on will throw an error:\n\n local position = vec3(1, 2, 3)\n\n function lovr.update(dt)\n -- Reusing the temporary 'position' vector across frames will error:\n position:add(vec3(dt))\n end\n\nIt's possible to overflow the temporary vector pool. If that happens, `lovr.math.drain` can be used to periodically drain the pool, invalidating any existing temporary vectors.\n\n### Metamethods\n\nVectors have metamethods, allowing them to be used using the normal math operators like `+`, `-`, `*`, `/`, etc.\n\n print(vec3(2, 4, 6) * .5 + vec3(10, 20, 30))\n\nThese metamethods will create new temporary vectors.\n\n### Components and Swizzles\n\nThe raw components of a vector can be accessed like normal fields:\n\n print(vec3(1, 2, 3).z) --> 3\n print(mat4()[16]) --> 1\n\nAlso, multiple fields can be accessed and combined into a new (temporary) vector, called swizzling:\n\n local position = vec3(10, 5, 1)\n print(position.xy) --> vec2(10, 5)\n print(position.xyy) --> vec3(10, 5, 5)\n print(position.zyxz) --> vec4(1, 5, 10, 1)\n\nThe following fields are supported for vectors:\n\n- `x`, `y`, `z`, `w`\n- `r`, `g`, `b`, `a`\n- `s`, `t`, `p`, `q`\n\nQuaternions support `x`, `y`, `z`, and `w`.\n\nMatrices use numbers for accessing individual components in \"column-major\" order.\n\nAll fields can also be assigned to.\n\n -- Swap the components of a 2D vector\n v.xy = v.yx\n\nThe `unpack` function can be used (on any vector type) to access all of the individual components of a vector object. For quaternions you can choose whether you want to unpack the angle/axis representation or the raw quaternion components. Similarly, matrices support raw unpacking as well as decomposition into translation/scale/rotation values.\n\n### Vector Constants\n\nThe following vector constants are available. They return new temporary vectors each time they are used:\n\n- `vec2.zero` (0, 0)\n- `vec2.one` (1, 1)\n- `vec3.zero` (0, 0, 0)\n- `vec3.one` (1, 1, 1)\n- `vec3.left` (-1, 0, 0)\n- `vec3.right` (1, 0, 0)\n- `vec3.up` (0, 1, 0)\n- `vec3.down` (0, -1, 0)\n- `vec3.back` (0, 0, 1)\n- `vec3.forward` (0, 0, -1)\n- `vec4.zero` (0, 0, 0, 0)\n- `vec4.one` (1, 1, 1, 1)\n- `quat.identity` (0, 0, 0, 1)"
  31664. }
  31665. },
  31666. sections = {
  31667. {
  31668. name = "Randomization",
  31669. tag = "random",
  31670. description = "Functions for generating random numbers and noise."
  31671. },
  31672. {
  31673. name = "Vectors",
  31674. tag = "vectors",
  31675. description = "A collection of vector objects. Check out the `Vectors` guide for an introduction."
  31676. },
  31677. {
  31678. name = "Other",
  31679. tag = "mathOther",
  31680. description = "Other miscellaneous math objects/helpers."
  31681. }
  31682. }
  31683. },
  31684. {
  31685. name = "physics",
  31686. tag = "modules",
  31687. summary = "Simulates 3D physics.",
  31688. description = "The `lovr.physics` module simulates 3D rigid body physics.",
  31689. key = "lovr.physics",
  31690. enums = {
  31691. {
  31692. name = "JointType",
  31693. summary = "Types of physics joints.",
  31694. description = "Represents the different types of physics Joints available.",
  31695. key = "JointType",
  31696. module = "lovr.physics",
  31697. related = {
  31698. "Joint",
  31699. "BallJoint",
  31700. "DistanceJoint",
  31701. "HingeJoint",
  31702. "SliderJoint"
  31703. },
  31704. values = {
  31705. {
  31706. name = "ball",
  31707. description = "A BallJoint."
  31708. },
  31709. {
  31710. name = "distance",
  31711. description = "A DistanceJoint."
  31712. },
  31713. {
  31714. name = "hinge",
  31715. description = "A HingeJoint."
  31716. },
  31717. {
  31718. name = "slider",
  31719. description = "A SliderJoint."
  31720. }
  31721. }
  31722. },
  31723. {
  31724. name = "ShapeType",
  31725. summary = "Types of physics shapes.",
  31726. description = "Represents the different types of physics Shapes available.",
  31727. key = "ShapeType",
  31728. module = "lovr.physics",
  31729. related = {
  31730. "Shape",
  31731. "BoxShape",
  31732. "CapsuleShape",
  31733. "CylinderShape",
  31734. "SphereShape"
  31735. },
  31736. values = {
  31737. {
  31738. name = "box",
  31739. description = "A BoxShape."
  31740. },
  31741. {
  31742. name = "capsule",
  31743. description = "A CapsuleShape."
  31744. },
  31745. {
  31746. name = "cylinder",
  31747. description = "A CylinderShape."
  31748. },
  31749. {
  31750. name = "sphere",
  31751. description = "A SphereShape."
  31752. }
  31753. }
  31754. }
  31755. },
  31756. functions = {
  31757. {
  31758. name = "newBallJoint",
  31759. tag = "joints",
  31760. summary = "Create a new BallJoint.",
  31761. description = "Creates a new BallJoint.",
  31762. key = "lovr.physics.newBallJoint",
  31763. module = "lovr.physics",
  31764. notes = "A ball joint is like a ball and socket between the two colliders. It tries to keep the distance between the colliders and the anchor position the same, but does not constrain the angle between them.",
  31765. related = {
  31766. "lovr.physics.newDistanceJoint",
  31767. "lovr.physics.newHingeJoint",
  31768. "lovr.physics.newSliderJoint"
  31769. },
  31770. variants = {
  31771. {
  31772. arguments = {
  31773. {
  31774. name = "colliderA",
  31775. type = "Collider",
  31776. description = "The first collider to attach the Joint to."
  31777. },
  31778. {
  31779. name = "colliderB",
  31780. type = "Collider",
  31781. description = "The second collider to attach the Joint to."
  31782. },
  31783. {
  31784. name = "x",
  31785. type = "number",
  31786. description = "The x position of the joint anchor point, in world coordinates."
  31787. },
  31788. {
  31789. name = "y",
  31790. type = "number",
  31791. description = "The y position of the joint anchor point, in world coordinates."
  31792. },
  31793. {
  31794. name = "z",
  31795. type = "number",
  31796. description = "The z position of the joint anchor point, in world coordinates."
  31797. }
  31798. },
  31799. returns = {
  31800. {
  31801. name = "ball",
  31802. type = "BallJoint",
  31803. description = "The new BallJoint."
  31804. }
  31805. }
  31806. },
  31807. {
  31808. arguments = {
  31809. {
  31810. name = "colliderA",
  31811. type = "Collider",
  31812. description = "The first collider to attach the Joint to."
  31813. },
  31814. {
  31815. name = "colliderB",
  31816. type = "Collider",
  31817. description = "The second collider to attach the Joint to."
  31818. },
  31819. {
  31820. name = "anchor",
  31821. type = "Vec3",
  31822. description = "The joint anchor point, in world coordinates."
  31823. }
  31824. },
  31825. returns = {
  31826. {
  31827. name = "ball",
  31828. type = "BallJoint",
  31829. description = "The new BallJoint."
  31830. }
  31831. }
  31832. }
  31833. }
  31834. },
  31835. {
  31836. name = "newBoxShape",
  31837. tag = "shapes",
  31838. summary = "Create a new BoxShape.",
  31839. description = "Creates a new BoxShape.",
  31840. key = "lovr.physics.newBoxShape",
  31841. module = "lovr.physics",
  31842. notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
  31843. related = {
  31844. "BoxShape",
  31845. "lovr.physics.newCapsuleShape",
  31846. "lovr.physics.newCylinderShape",
  31847. "lovr.physics.newMeshShape",
  31848. "lovr.physics.newSphereShape",
  31849. "lovr.physics.newTerrainShape"
  31850. },
  31851. variants = {
  31852. {
  31853. arguments = {
  31854. {
  31855. name = "width",
  31856. type = "number",
  31857. description = "The width of the box, in meters.",
  31858. default = "1"
  31859. },
  31860. {
  31861. name = "height",
  31862. type = "number",
  31863. description = "The height of the box, in meters.",
  31864. default = "width"
  31865. },
  31866. {
  31867. name = "depth",
  31868. type = "number",
  31869. description = "The depth of the box, in meters.",
  31870. default = "width"
  31871. }
  31872. },
  31873. returns = {
  31874. {
  31875. name = "box",
  31876. type = "BoxShape",
  31877. description = "The new BoxShape."
  31878. }
  31879. }
  31880. }
  31881. }
  31882. },
  31883. {
  31884. name = "newCapsuleShape",
  31885. tag = "shapes",
  31886. summary = "Create a new CapsuleShape.",
  31887. description = "Creates a new CapsuleShape. Capsules are cylinders with hemispheres on each end.",
  31888. key = "lovr.physics.newCapsuleShape",
  31889. module = "lovr.physics",
  31890. notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
  31891. related = {
  31892. "CapsuleShape",
  31893. "lovr.physics.newBoxShape",
  31894. "lovr.physics.newCylinderShape",
  31895. "lovr.physics.newMeshShape",
  31896. "lovr.physics.newSphereShape",
  31897. "lovr.physics.newTerrainShape"
  31898. },
  31899. variants = {
  31900. {
  31901. arguments = {
  31902. {
  31903. name = "radius",
  31904. type = "number",
  31905. description = "The radius of the capsule, in meters.",
  31906. default = "1"
  31907. },
  31908. {
  31909. name = "length",
  31910. type = "number",
  31911. description = "The length of the capsule, not including the caps, in meters.",
  31912. default = "1"
  31913. }
  31914. },
  31915. returns = {
  31916. {
  31917. name = "capsule",
  31918. type = "CapsuleShape",
  31919. description = "The new CapsuleShape."
  31920. }
  31921. }
  31922. }
  31923. }
  31924. },
  31925. {
  31926. name = "newCylinderShape",
  31927. tag = "shapes",
  31928. summary = "Create a new CylinderShape.",
  31929. description = "Creates a new CylinderShape.",
  31930. key = "lovr.physics.newCylinderShape",
  31931. module = "lovr.physics",
  31932. notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
  31933. related = {
  31934. "CylinderShape",
  31935. "lovr.physics.newBoxShape",
  31936. "lovr.physics.newCapsuleShape",
  31937. "lovr.physics.newMeshShape",
  31938. "lovr.physics.newSphereShape",
  31939. "lovr.physics.newTerrainShape"
  31940. },
  31941. variants = {
  31942. {
  31943. arguments = {
  31944. {
  31945. name = "radius",
  31946. type = "number",
  31947. description = "The radius of the cylinder, in meters.",
  31948. default = "1"
  31949. },
  31950. {
  31951. name = "length",
  31952. type = "number",
  31953. description = "The length of the cylinder, in meters.",
  31954. default = "1"
  31955. }
  31956. },
  31957. returns = {
  31958. {
  31959. name = "cylinder",
  31960. type = "CylinderShape",
  31961. description = "The new CylinderShape."
  31962. }
  31963. }
  31964. }
  31965. }
  31966. },
  31967. {
  31968. name = "newDistanceJoint",
  31969. tag = "joints",
  31970. summary = "Create a new DistanceJoint.",
  31971. description = "Creates a new DistanceJoint.",
  31972. key = "lovr.physics.newDistanceJoint",
  31973. module = "lovr.physics",
  31974. notes = "A distance joint tries to keep the two colliders a fixed distance apart. The distance is determined by the initial distance between the anchor points. The joint allows for rotation on the anchor points.",
  31975. related = {
  31976. "lovr.physics.newBallJoint",
  31977. "lovr.physics.newHingeJoint",
  31978. "lovr.physics.newSliderJoint"
  31979. },
  31980. variants = {
  31981. {
  31982. arguments = {
  31983. {
  31984. name = "colliderA",
  31985. type = "Collider",
  31986. description = "The first collider to attach the Joint to."
  31987. },
  31988. {
  31989. name = "colliderB",
  31990. type = "Collider",
  31991. description = "The second collider to attach the Joint to."
  31992. },
  31993. {
  31994. name = "x1",
  31995. type = "number",
  31996. description = "The x position of the first anchor point, in world coordinates."
  31997. },
  31998. {
  31999. name = "y1",
  32000. type = "number",
  32001. description = "The y position of the first anchor point, in world coordinates."
  32002. },
  32003. {
  32004. name = "z1",
  32005. type = "number",
  32006. description = "The z position of the first anchor point, in world coordinates."
  32007. },
  32008. {
  32009. name = "x2",
  32010. type = "number",
  32011. description = "The x position of the second anchor point, in world coordinates."
  32012. },
  32013. {
  32014. name = "y2",
  32015. type = "number",
  32016. description = "The y position of the second anchor point, in world coordinates."
  32017. },
  32018. {
  32019. name = "z2",
  32020. type = "number",
  32021. description = "The z position of the second anchor point, in world coordinates."
  32022. }
  32023. },
  32024. returns = {
  32025. {
  32026. name = "joint",
  32027. type = "DistanceJoint",
  32028. description = "The new DistanceJoint."
  32029. }
  32030. }
  32031. },
  32032. {
  32033. arguments = {
  32034. {
  32035. name = "colliderA",
  32036. type = "Collider",
  32037. description = "The first collider to attach the Joint to."
  32038. },
  32039. {
  32040. name = "colliderB",
  32041. type = "Collider",
  32042. description = "The second collider to attach the Joint to."
  32043. },
  32044. {
  32045. name = "first",
  32046. type = "Vec3",
  32047. description = "The first anchor point, in world coordinates."
  32048. },
  32049. {
  32050. name = "second",
  32051. type = "Vec3",
  32052. description = "The second anchor point, in world coordinates."
  32053. }
  32054. },
  32055. returns = {
  32056. {
  32057. name = "joint",
  32058. type = "DistanceJoint",
  32059. description = "The new DistanceJoint."
  32060. }
  32061. }
  32062. }
  32063. }
  32064. },
  32065. {
  32066. name = "newHingeJoint",
  32067. tag = "joints",
  32068. summary = "Create a new HingeJoint.",
  32069. description = "Creates a new HingeJoint.",
  32070. key = "lovr.physics.newHingeJoint",
  32071. module = "lovr.physics",
  32072. notes = "A hinge joint constrains two colliders to allow rotation only around the hinge's axis.",
  32073. related = {
  32074. "lovr.physics.newBallJoint",
  32075. "lovr.physics.newDistanceJoint",
  32076. "lovr.physics.newSliderJoint"
  32077. },
  32078. variants = {
  32079. {
  32080. arguments = {
  32081. {
  32082. name = "colliderA",
  32083. type = "Collider",
  32084. description = "The first collider to attach the Joint to."
  32085. },
  32086. {
  32087. name = "colliderB",
  32088. type = "Collider",
  32089. description = "The second collider to attach the Joint to."
  32090. },
  32091. {
  32092. name = "x",
  32093. type = "number",
  32094. description = "The x position of the hinge anchor, in world coordinates."
  32095. },
  32096. {
  32097. name = "y",
  32098. type = "number",
  32099. description = "The y position of the hinge anchor, in world coordinates."
  32100. },
  32101. {
  32102. name = "z",
  32103. type = "number",
  32104. description = "The z position of the hinge anchor, in world coordinates."
  32105. },
  32106. {
  32107. name = "ax",
  32108. type = "number",
  32109. description = "The x component of the hinge axis direction."
  32110. },
  32111. {
  32112. name = "ay",
  32113. type = "number",
  32114. description = "The y component of the hinge axis direction."
  32115. },
  32116. {
  32117. name = "az",
  32118. type = "number",
  32119. description = "The z component of the hinge axis direction."
  32120. }
  32121. },
  32122. returns = {
  32123. {
  32124. name = "hinge",
  32125. type = "HingeJoint",
  32126. description = "The new HingeJoint."
  32127. }
  32128. }
  32129. },
  32130. {
  32131. arguments = {
  32132. {
  32133. name = "colliderA",
  32134. type = "Collider",
  32135. description = "The first collider to attach the Joint to."
  32136. },
  32137. {
  32138. name = "colliderB",
  32139. type = "Collider",
  32140. description = "The second collider to attach the Joint to."
  32141. },
  32142. {
  32143. name = "anchor",
  32144. type = "Vec3",
  32145. description = "The anchor point, in world coordinates."
  32146. },
  32147. {
  32148. name = "axis",
  32149. type = "Vec3",
  32150. description = "The hinge axis direction."
  32151. }
  32152. },
  32153. returns = {
  32154. {
  32155. name = "hinge",
  32156. type = "HingeJoint",
  32157. description = "The new HingeJoint."
  32158. }
  32159. }
  32160. }
  32161. }
  32162. },
  32163. {
  32164. name = "newMeshShape",
  32165. tag = "shapes",
  32166. summary = "Create a new MeshShape.",
  32167. description = "Creates a new MeshShape.",
  32168. key = "lovr.physics.newMeshShape",
  32169. module = "lovr.physics",
  32170. notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
  32171. related = {
  32172. "MeshShape",
  32173. "lovr.physics.newBoxShape",
  32174. "lovr.physics.newCapsuleShape",
  32175. "lovr.physics.newCylinderShape",
  32176. "lovr.physics.newSphereShape",
  32177. "lovr.physics.newTerrainShape",
  32178. "Model:getTriangles"
  32179. },
  32180. variants = {
  32181. {
  32182. arguments = {
  32183. {
  32184. name = "vertices",
  32185. type = "table",
  32186. description = "The table of vertices in the mesh. Each vertex is a table with 3 numbers."
  32187. },
  32188. {
  32189. name = "indices",
  32190. type = "table",
  32191. description = "A table of triangle indices representing how the vertices are connected in the Mesh."
  32192. }
  32193. },
  32194. returns = {
  32195. {
  32196. name = "mesh",
  32197. type = "MeshShape",
  32198. description = "The new MeshShape."
  32199. }
  32200. }
  32201. },
  32202. {
  32203. arguments = {
  32204. {
  32205. name = "model",
  32206. type = "Model",
  32207. description = "A Model to use for the mesh data. Similar to calling `Model:getTriangles` and passing it to this function, but has better performance."
  32208. }
  32209. },
  32210. returns = {
  32211. {
  32212. name = "mesh",
  32213. type = "MeshShape",
  32214. description = "The new MeshShape."
  32215. }
  32216. }
  32217. }
  32218. }
  32219. },
  32220. {
  32221. name = "newSliderJoint",
  32222. tag = "joints",
  32223. summary = "Create a new SliderJoint.",
  32224. description = "Creates a new SliderJoint.",
  32225. key = "lovr.physics.newSliderJoint",
  32226. module = "lovr.physics",
  32227. notes = "A slider joint constrains two colliders to only allow movement along the slider's axis.",
  32228. related = {
  32229. "lovr.physics.newBallJoint",
  32230. "lovr.physics.newDistanceJoint",
  32231. "lovr.physics.newHingeJoint"
  32232. },
  32233. variants = {
  32234. {
  32235. arguments = {
  32236. {
  32237. name = "colliderA",
  32238. type = "Collider",
  32239. description = "The first collider to attach the Joint to."
  32240. },
  32241. {
  32242. name = "colliderB",
  32243. type = "Collider",
  32244. description = "The second collider to attach the Joint to."
  32245. },
  32246. {
  32247. name = "ax",
  32248. type = "number",
  32249. description = "The x component of the slider axis."
  32250. },
  32251. {
  32252. name = "ay",
  32253. type = "number",
  32254. description = "The y component of the slider axis."
  32255. },
  32256. {
  32257. name = "az",
  32258. type = "number",
  32259. description = "The z component of the slider axis."
  32260. }
  32261. },
  32262. returns = {
  32263. {
  32264. name = "slider",
  32265. type = "SliderJoint",
  32266. description = "The new SliderJoint."
  32267. }
  32268. }
  32269. },
  32270. {
  32271. arguments = {
  32272. {
  32273. name = "colliderA",
  32274. type = "Collider",
  32275. description = "The first collider to attach the Joint to."
  32276. },
  32277. {
  32278. name = "colliderB",
  32279. type = "Collider",
  32280. description = "The second collider to attach the Joint to."
  32281. },
  32282. {
  32283. name = "axis",
  32284. type = "Vec3",
  32285. description = "The slider axis direction."
  32286. }
  32287. },
  32288. returns = {
  32289. {
  32290. name = "slider",
  32291. type = "SliderJoint",
  32292. description = "The new SliderJoint."
  32293. }
  32294. }
  32295. }
  32296. }
  32297. },
  32298. {
  32299. name = "newSphereShape",
  32300. tag = "shapes",
  32301. summary = "Create a new SphereShape.",
  32302. description = "Creates a new SphereShape.",
  32303. key = "lovr.physics.newSphereShape",
  32304. module = "lovr.physics",
  32305. notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
  32306. related = {
  32307. "SphereShape",
  32308. "lovr.physics.newBoxShape",
  32309. "lovr.physics.newCapsuleShape",
  32310. "lovr.physics.newCylinderShape",
  32311. "lovr.physics.newMeshShape",
  32312. "lovr.physics.newTerrainShape"
  32313. },
  32314. variants = {
  32315. {
  32316. arguments = {
  32317. {
  32318. name = "radius",
  32319. type = "number",
  32320. description = "The radius of the sphere, in meters.",
  32321. default = "1"
  32322. }
  32323. },
  32324. returns = {
  32325. {
  32326. name = "sphere",
  32327. type = "SphereShape",
  32328. description = "The new SphereShape."
  32329. }
  32330. }
  32331. }
  32332. }
  32333. },
  32334. {
  32335. name = "newTerrainShape",
  32336. tag = "shapes",
  32337. summary = "Create a new TerrainShape.",
  32338. description = "Creates a new TerrainShape.",
  32339. key = "lovr.physics.newTerrainShape",
  32340. module = "lovr.physics",
  32341. notes = "A Shape can be attached to a Collider using `Collider:addShape`. For immobile terrain use the `Collider:setKinematic`.",
  32342. related = {
  32343. "TerrainShape",
  32344. "lovr.physics.newBoxShape",
  32345. "lovr.physics.newCapsuleShape",
  32346. "lovr.physics.newCylinderShape",
  32347. "lovr.physics.newMeshShape",
  32348. "lovr.physics.newSphereShape",
  32349. "lovr.data.newImage"
  32350. },
  32351. variants = {
  32352. {
  32353. description = "Create a flat floor collider.",
  32354. arguments = {
  32355. {
  32356. name = "scale",
  32357. type = "number",
  32358. description = "The width and depth of the terrain, in meters."
  32359. }
  32360. },
  32361. returns = {
  32362. {
  32363. name = "terrain",
  32364. type = "TerrainShape",
  32365. description = "The new TerrainShape."
  32366. }
  32367. }
  32368. },
  32369. {
  32370. description = "Create terrain from a heightmap image.",
  32371. arguments = {
  32372. {
  32373. name = "scale",
  32374. type = "number",
  32375. description = "The width and depth of the terrain, in meters."
  32376. },
  32377. {
  32378. name = "heightmap",
  32379. type = "Image",
  32380. description = "A heightmap image describing the terrain elevation at different points. The red channel brightness of each pixel determines the elevation at corresponding coordinates."
  32381. },
  32382. {
  32383. name = "stretch",
  32384. type = "number",
  32385. description = "A vertical multiplier for height values to obtain terrain height. When the image format has pixel values only in the 0 to 1 range, this can be used to scale the height to meters.",
  32386. default = "1.0"
  32387. }
  32388. },
  32389. returns = {
  32390. {
  32391. name = "terrain",
  32392. type = "TerrainShape",
  32393. description = "The new TerrainShape."
  32394. }
  32395. }
  32396. },
  32397. {
  32398. description = "Create terrain defined with a callback function.",
  32399. arguments = {
  32400. {
  32401. name = "scale",
  32402. type = "number",
  32403. description = "The width and depth of the terrain, in meters."
  32404. },
  32405. {
  32406. name = "callback",
  32407. type = "function",
  32408. description = "A function that computes terrain height from x and z coordinates. The x and z inputs will range from `-scale / 2` to `scale / 2`.",
  32409. arguments = {
  32410. {
  32411. name = "x",
  32412. type = "number"
  32413. },
  32414. {
  32415. name = "z",
  32416. type = "number"
  32417. }
  32418. },
  32419. returns = {
  32420. name = "height",
  32421. type = "number"
  32422. }
  32423. },
  32424. {
  32425. name = "samples",
  32426. type = "number",
  32427. description = "The number of samples taken across the x and z dimensions. More samples will result in higher terrain fidelity, but use more CPU and memory.",
  32428. default = "100"
  32429. }
  32430. },
  32431. returns = {
  32432. {
  32433. name = "terrain",
  32434. type = "TerrainShape",
  32435. description = "The new TerrainShape."
  32436. }
  32437. }
  32438. }
  32439. }
  32440. },
  32441. {
  32442. name = "newWorld",
  32443. tag = "world",
  32444. summary = "Create a new World.",
  32445. description = "Creates a new physics World, which tracks the overall physics simulation, holds collider objects, and resolves collisions between them.",
  32446. key = "lovr.physics.newWorld",
  32447. module = "lovr.physics",
  32448. examples = {
  32449. {
  32450. description = "Create a new world, add a collider to it, and update it, printing out its position as it falls.",
  32451. code = "function lovr.load()\n world = lovr.physics.newWorld()\n box = world:newBoxCollider()\nend\n\nfunction lovr.update(dt)\n world:update(dt)\n print(box:getPosition())\nend"
  32452. }
  32453. },
  32454. notes = "A World must be updated with `World:update` in `lovr.update` for the physics simulation to advance.",
  32455. variants = {
  32456. {
  32457. arguments = {
  32458. {
  32459. name = "xg",
  32460. type = "number",
  32461. description = "The x component of the gravity force.",
  32462. default = "0"
  32463. },
  32464. {
  32465. name = "yg",
  32466. type = "number",
  32467. description = "The y component of the gravity force.",
  32468. default = "-9.81"
  32469. },
  32470. {
  32471. name = "zg",
  32472. type = "number",
  32473. description = "The z component of the gravity force.",
  32474. default = "0"
  32475. },
  32476. {
  32477. name = "allowSleep",
  32478. type = "boolean",
  32479. description = "Whether or not colliders will automatically be put to sleep.",
  32480. default = "true"
  32481. },
  32482. {
  32483. name = "tags",
  32484. type = "table",
  32485. description = "A list of collision tags colliders can be assigned to.",
  32486. default = "{}"
  32487. }
  32488. },
  32489. returns = {
  32490. {
  32491. name = "world",
  32492. type = "World",
  32493. description = "A whole new World."
  32494. }
  32495. }
  32496. }
  32497. }
  32498. }
  32499. },
  32500. objects = {
  32501. {
  32502. name = "BallJoint",
  32503. summary = "A ball and socket joint.",
  32504. description = "A BallJoint is a type of `Joint` that acts like a ball and socket between two colliders. It allows the colliders to rotate freely around an anchor point, but does not allow the colliders' distance from the anchor point to change.",
  32505. key = "BallJoint",
  32506. module = "lovr.physics",
  32507. constructors = {
  32508. "lovr.physics.newBallJoint"
  32509. },
  32510. extends = "Joint",
  32511. methods = {
  32512. {
  32513. name = "getAnchors",
  32514. summary = "Get the anchor points of the BallJoint.",
  32515. description = "Returns the anchor points of the BallJoint, in world coordinates. The first point is the anchor on the first collider, and the second point is on the second collider. The joint tries to keep these points the same, but they may be different if the joint is forced apart by some other means.",
  32516. key = "BallJoint:getAnchors",
  32517. module = "lovr.physics",
  32518. variants = {
  32519. {
  32520. arguments = {},
  32521. returns = {
  32522. {
  32523. name = "x1",
  32524. type = "number",
  32525. description = "The x coordinate of the first anchor point, in world coordinates."
  32526. },
  32527. {
  32528. name = "y1",
  32529. type = "number",
  32530. description = "The y coordinate of the first anchor point, in world coordinates."
  32531. },
  32532. {
  32533. name = "z1",
  32534. type = "number",
  32535. description = "The z coordinate of the first anchor point, in world coordinates."
  32536. },
  32537. {
  32538. name = "x2",
  32539. type = "number",
  32540. description = "The x coordinate of the second anchor point, in world coordinates."
  32541. },
  32542. {
  32543. name = "y2",
  32544. type = "number",
  32545. description = "The y coordinate of the second anchor point, in world coordinates."
  32546. },
  32547. {
  32548. name = "z2",
  32549. type = "number",
  32550. description = "The z coordinate of the second anchor point, in world coordinates."
  32551. }
  32552. }
  32553. }
  32554. }
  32555. },
  32556. {
  32557. name = "getResponseTime",
  32558. summary = "Get the response time of the joint.",
  32559. description = "Returns the response time of the joint. See `World:setResponseTime` for more info.",
  32560. key = "BallJoint:getResponseTime",
  32561. module = "lovr.physics",
  32562. related = {
  32563. "DistanceJoint:getResponseTime",
  32564. "DistanceJoint:setResponseTime",
  32565. "World:getResponseTime",
  32566. "World:setResponseTime"
  32567. },
  32568. variants = {
  32569. {
  32570. arguments = {},
  32571. returns = {
  32572. {
  32573. name = "responseTime",
  32574. type = "number",
  32575. description = "The response time setting for the joint."
  32576. }
  32577. }
  32578. }
  32579. }
  32580. },
  32581. {
  32582. name = "getTightness",
  32583. summary = "Get the joint tightness.",
  32584. description = "Returns the tightness of the joint. See `World:setTightness` for how this affects the joint.",
  32585. key = "BallJoint:getTightness",
  32586. module = "lovr.physics",
  32587. related = {
  32588. "DistanceJoint:getTightness",
  32589. "DistanceJoint:setTightness",
  32590. "World:getTightness",
  32591. "World:setTightness"
  32592. },
  32593. variants = {
  32594. {
  32595. arguments = {},
  32596. returns = {
  32597. {
  32598. name = "tightness",
  32599. type = "number",
  32600. description = "The tightness of the joint."
  32601. }
  32602. }
  32603. }
  32604. }
  32605. },
  32606. {
  32607. name = "setAnchor",
  32608. summary = "Set the anchor point of the BallJoint.",
  32609. description = "Sets a new anchor point for the BallJoint.",
  32610. key = "BallJoint:setAnchor",
  32611. module = "lovr.physics",
  32612. variants = {
  32613. {
  32614. description = "Sets the anchor point using numbers.",
  32615. arguments = {
  32616. {
  32617. name = "x",
  32618. type = "number",
  32619. description = "The x coordinate of the anchor point, in world coordinates."
  32620. },
  32621. {
  32622. name = "y",
  32623. type = "number",
  32624. description = "The y coordinate of the anchor point, in world coordinates."
  32625. },
  32626. {
  32627. name = "z",
  32628. type = "number",
  32629. description = "The z coordinate of the anchor point, in world coordinates."
  32630. }
  32631. },
  32632. returns = {}
  32633. },
  32634. {
  32635. description = "Sets the anchor point using a vector.",
  32636. arguments = {
  32637. {
  32638. name = "anchor",
  32639. type = "Vec3",
  32640. description = "The anchor point, in world coordinates."
  32641. }
  32642. },
  32643. returns = {}
  32644. }
  32645. }
  32646. },
  32647. {
  32648. name = "setResponseTime",
  32649. summary = "Set the response time of the joint.",
  32650. description = "Sets the response time of the joint. See `World:setResponseTime` for more info.",
  32651. key = "BallJoint:setResponseTime",
  32652. module = "lovr.physics",
  32653. related = {
  32654. "DistanceJoint:getResponseTime",
  32655. "DistanceJoint:setResponseTime",
  32656. "World:getResponseTime",
  32657. "World:setResponseTime"
  32658. },
  32659. variants = {
  32660. {
  32661. arguments = {
  32662. {
  32663. name = "responseTime",
  32664. type = "number",
  32665. description = "The new response time setting for the joint."
  32666. }
  32667. },
  32668. returns = {}
  32669. }
  32670. }
  32671. },
  32672. {
  32673. name = "setTightness",
  32674. summary = "Set the joint tightness.",
  32675. description = "Sets the tightness of the joint. See `World:setTightness` for how this affects the joint.",
  32676. key = "BallJoint:setTightness",
  32677. module = "lovr.physics",
  32678. related = {
  32679. "DistanceJoint:getTightness",
  32680. "DistanceJoint:setTightness",
  32681. "World:getTightness",
  32682. "World:setTightness"
  32683. },
  32684. variants = {
  32685. {
  32686. arguments = {
  32687. {
  32688. name = "tightness",
  32689. type = "number",
  32690. description = "The tightness of the joint."
  32691. }
  32692. },
  32693. returns = {}
  32694. }
  32695. }
  32696. }
  32697. },
  32698. related = {
  32699. "Collider"
  32700. }
  32701. },
  32702. {
  32703. name = "BoxShape",
  32704. summary = "A box Shape.",
  32705. description = "A type of `Shape` that can be used for cubes or boxes.",
  32706. key = "BoxShape",
  32707. module = "lovr.physics",
  32708. constructors = {
  32709. "lovr.physics.newBoxShape",
  32710. "World:newBoxCollider"
  32711. },
  32712. extends = "Shape",
  32713. methods = {
  32714. {
  32715. name = "getDimensions",
  32716. summary = "Get the dimensions of the BoxShape.",
  32717. description = "Returns the width, height, and depth of the BoxShape.",
  32718. key = "BoxShape:getDimensions",
  32719. module = "lovr.physics",
  32720. variants = {
  32721. {
  32722. arguments = {},
  32723. returns = {
  32724. {
  32725. name = "width",
  32726. type = "number",
  32727. description = "The width of the box, in meters."
  32728. },
  32729. {
  32730. name = "height",
  32731. type = "number",
  32732. description = "The height of the box, in meters."
  32733. },
  32734. {
  32735. name = "depth",
  32736. type = "number",
  32737. description = "The depth of the box, in meters."
  32738. }
  32739. }
  32740. }
  32741. }
  32742. },
  32743. {
  32744. name = "setDimensions",
  32745. summary = "Set the dimensions of the BoxShape.",
  32746. description = "Sets the width, height, and depth of the BoxShape.",
  32747. key = "BoxShape:setDimensions",
  32748. module = "lovr.physics",
  32749. variants = {
  32750. {
  32751. arguments = {
  32752. {
  32753. name = "width",
  32754. type = "number",
  32755. description = "The width of the box, in meters."
  32756. },
  32757. {
  32758. name = "height",
  32759. type = "number",
  32760. description = "The height of the box, in meters."
  32761. },
  32762. {
  32763. name = "depth",
  32764. type = "number",
  32765. description = "The depth of the box, in meters."
  32766. }
  32767. },
  32768. returns = {}
  32769. }
  32770. }
  32771. }
  32772. }
  32773. },
  32774. {
  32775. name = "CapsuleShape",
  32776. summary = "A capsule Shape.",
  32777. description = "A type of `Shape` that can be used for capsule-shaped things.",
  32778. key = "CapsuleShape",
  32779. module = "lovr.physics",
  32780. constructors = {
  32781. "lovr.physics.newCapsuleShape",
  32782. "World:newCapsuleCollider"
  32783. },
  32784. extends = "Shape",
  32785. methods = {
  32786. {
  32787. name = "getLength",
  32788. summary = "Get the length of the CapsuleShape.",
  32789. description = "Returns the length of the CapsuleShape, not including the caps.",
  32790. key = "CapsuleShape:getLength",
  32791. module = "lovr.physics",
  32792. variants = {
  32793. {
  32794. arguments = {},
  32795. returns = {
  32796. {
  32797. name = "length",
  32798. type = "number",
  32799. description = "The length of the capsule, in meters."
  32800. }
  32801. }
  32802. }
  32803. }
  32804. },
  32805. {
  32806. name = "getRadius",
  32807. summary = "Get the radius of the CapsuleShape.",
  32808. description = "Returns the radius of the CapsuleShape.",
  32809. key = "CapsuleShape:getRadius",
  32810. module = "lovr.physics",
  32811. variants = {
  32812. {
  32813. arguments = {},
  32814. returns = {
  32815. {
  32816. name = "radius",
  32817. type = "number",
  32818. description = "The radius of the capsule, in meters."
  32819. }
  32820. }
  32821. }
  32822. }
  32823. },
  32824. {
  32825. name = "setLength",
  32826. summary = "Set the length of the CapsuleShape.",
  32827. description = "Sets the length of the CapsuleShape.",
  32828. key = "CapsuleShape:setLength",
  32829. module = "lovr.physics",
  32830. variants = {
  32831. {
  32832. arguments = {
  32833. {
  32834. name = "length",
  32835. type = "number",
  32836. description = "The new length, in meters, not including the caps."
  32837. }
  32838. },
  32839. returns = {}
  32840. }
  32841. }
  32842. },
  32843. {
  32844. name = "setRadius",
  32845. summary = "Set the radius of the CapsuleShape.",
  32846. description = "Sets the radius of the CapsuleShape.",
  32847. key = "CapsuleShape:setRadius",
  32848. module = "lovr.physics",
  32849. variants = {
  32850. {
  32851. arguments = {
  32852. {
  32853. name = "radius",
  32854. type = "number",
  32855. description = "The new radius, in meters."
  32856. }
  32857. },
  32858. returns = {}
  32859. }
  32860. }
  32861. }
  32862. }
  32863. },
  32864. {
  32865. name = "Collider",
  32866. summary = "A single entity in a physics simulation.",
  32867. description = "Colliders are objects that represent a single rigid body in a physics simulation. They can have forces applied to them and collide with other colliders.",
  32868. key = "Collider",
  32869. module = "lovr.physics",
  32870. constructors = {
  32871. "World:newCollider",
  32872. "World:newBoxCollider",
  32873. "World:newCapsuleCollider",
  32874. "World:newCylinderCollider",
  32875. "World:newSphereCollider",
  32876. "World:newMeshCollider",
  32877. "World:newTerrainCollider"
  32878. },
  32879. methods = {
  32880. {
  32881. name = "addShape",
  32882. summary = "Add a Shape to the Collider.",
  32883. description = "Attaches a Shape to the collider. Attached shapes will collide with other shapes in the world.",
  32884. key = "Collider:addShape",
  32885. module = "lovr.physics",
  32886. related = {
  32887. "Collider:removeShape",
  32888. "Collider:getShapes",
  32889. "Shape"
  32890. },
  32891. variants = {
  32892. {
  32893. arguments = {
  32894. {
  32895. name = "shape",
  32896. type = "Shape",
  32897. description = "The Shape to attach."
  32898. }
  32899. },
  32900. returns = {}
  32901. }
  32902. }
  32903. },
  32904. {
  32905. name = "applyForce",
  32906. summary = "Apply a force to the Collider.",
  32907. description = "Applies a force to the Collider.",
  32908. key = "Collider:applyForce",
  32909. module = "lovr.physics",
  32910. notes = "If the Collider is asleep, it will need to be woken up with `Collider:setAwake` for this function to have any affect.",
  32911. related = {
  32912. "Collider:applyTorque"
  32913. },
  32914. variants = {
  32915. {
  32916. arguments = {
  32917. {
  32918. name = "x",
  32919. type = "number",
  32920. description = "The x component of the force to apply."
  32921. },
  32922. {
  32923. name = "y",
  32924. type = "number",
  32925. description = "The y component of the force to apply."
  32926. },
  32927. {
  32928. name = "z",
  32929. type = "number",
  32930. description = "The z component of the force to apply."
  32931. }
  32932. },
  32933. returns = {}
  32934. },
  32935. {
  32936. arguments = {
  32937. {
  32938. name = "x",
  32939. type = "number",
  32940. description = "The x component of the force to apply."
  32941. },
  32942. {
  32943. name = "y",
  32944. type = "number",
  32945. description = "The y component of the force to apply."
  32946. },
  32947. {
  32948. name = "z",
  32949. type = "number",
  32950. description = "The z component of the force to apply."
  32951. },
  32952. {
  32953. name = "px",
  32954. type = "number",
  32955. description = "The x position to apply the force at, in world coordinates."
  32956. },
  32957. {
  32958. name = "py",
  32959. type = "number",
  32960. description = "The y position to apply the force at, in world coordinates."
  32961. },
  32962. {
  32963. name = "pz",
  32964. type = "number",
  32965. description = "The z position to apply the force at, in world coordinates."
  32966. }
  32967. },
  32968. returns = {}
  32969. },
  32970. {
  32971. arguments = {
  32972. {
  32973. name = "force",
  32974. type = "Vec3",
  32975. description = "The force vector to apply."
  32976. }
  32977. },
  32978. returns = {}
  32979. },
  32980. {
  32981. arguments = {
  32982. {
  32983. name = "force",
  32984. type = "Vec3",
  32985. description = "The force vector to apply."
  32986. },
  32987. {
  32988. name = "position",
  32989. type = "Vec3",
  32990. description = "The position to apply the force at, in world coordinates."
  32991. }
  32992. },
  32993. returns = {}
  32994. }
  32995. }
  32996. },
  32997. {
  32998. name = "applyTorque",
  32999. summary = "Apply torque to the Collider.",
  33000. description = "Applies torque to the Collider.",
  33001. key = "Collider:applyTorque",
  33002. module = "lovr.physics",
  33003. notes = "If the Collider is asleep, it will need to be woken up with `Collider:setAwake` for this function to have any effect.",
  33004. related = {
  33005. "Collider:applyForce"
  33006. },
  33007. variants = {
  33008. {
  33009. arguments = {
  33010. {
  33011. name = "x",
  33012. type = "number",
  33013. description = "The x component of the torque."
  33014. },
  33015. {
  33016. name = "y",
  33017. type = "number",
  33018. description = "The y component of the torque."
  33019. },
  33020. {
  33021. name = "z",
  33022. type = "number",
  33023. description = "The z component of the torque."
  33024. }
  33025. },
  33026. returns = {}
  33027. },
  33028. {
  33029. arguments = {
  33030. {
  33031. name = "torque",
  33032. type = "Vec3",
  33033. description = "The torque to apply."
  33034. }
  33035. },
  33036. returns = {}
  33037. }
  33038. }
  33039. },
  33040. {
  33041. name = "destroy",
  33042. summary = "Destroy the Collider.",
  33043. description = "Destroy the Collider, removing it from the World.",
  33044. key = "Collider:destroy",
  33045. module = "lovr.physics",
  33046. notes = "Calling functions on the collider after destroying it is a bad idea.",
  33047. related = {
  33048. "Collider:isDestroyed",
  33049. "World:destroy",
  33050. "Shape:destroy",
  33051. "Joint:destroy"
  33052. },
  33053. variants = {
  33054. {
  33055. arguments = {},
  33056. returns = {}
  33057. }
  33058. }
  33059. },
  33060. {
  33061. name = "getAABB",
  33062. summary = "Get the Collider's axis aligned bounding box.",
  33063. description = "Returns the bounding box for the Collider, computed from attached shapes.",
  33064. key = "Collider:getAABB",
  33065. module = "lovr.physics",
  33066. related = {
  33067. "Shape:getAABB"
  33068. },
  33069. variants = {
  33070. {
  33071. arguments = {},
  33072. returns = {
  33073. {
  33074. name = "minx",
  33075. type = "number",
  33076. description = "The minimum x coordinate of the box."
  33077. },
  33078. {
  33079. name = "maxx",
  33080. type = "number",
  33081. description = "The maximum x coordinate of the box."
  33082. },
  33083. {
  33084. name = "miny",
  33085. type = "number",
  33086. description = "The minimum y coordinate of the box."
  33087. },
  33088. {
  33089. name = "maxy",
  33090. type = "number",
  33091. description = "The maximum y coordinate of the box."
  33092. },
  33093. {
  33094. name = "minz",
  33095. type = "number",
  33096. description = "The minimum z coordinate of the box."
  33097. },
  33098. {
  33099. name = "maxz",
  33100. type = "number",
  33101. description = "The maximum z coordinate of the box."
  33102. }
  33103. }
  33104. }
  33105. }
  33106. },
  33107. {
  33108. name = "getAngularDamping",
  33109. summary = "Get the angular damping of the Collider.",
  33110. description = "Returns the angular damping parameters of the Collider. Angular damping makes things less \"spinny\", making them slow down their angular velocity over time.",
  33111. key = "Collider:getAngularDamping",
  33112. module = "lovr.physics",
  33113. notes = "When the Collider is created, it will use the world's angular damping value, which is set using `World:setAngularDamping`.",
  33114. related = {
  33115. "World:getAngularDamping",
  33116. "World:setAngularDamping"
  33117. },
  33118. variants = {
  33119. {
  33120. arguments = {},
  33121. returns = {
  33122. {
  33123. name = "damping",
  33124. type = "number",
  33125. description = "The angular damping."
  33126. },
  33127. {
  33128. name = "threshold",
  33129. type = "number",
  33130. description = "Velocity limit below which the damping is not applied."
  33131. }
  33132. }
  33133. }
  33134. }
  33135. },
  33136. {
  33137. name = "getAngularVelocity",
  33138. summary = "Get the angular velocity of the Collider.",
  33139. description = "Returns the angular velocity of the Collider.",
  33140. key = "Collider:getAngularVelocity",
  33141. module = "lovr.physics",
  33142. related = {
  33143. "Collider:getLinearVelocity",
  33144. "Collider:setLinearVelocity",
  33145. "Collider:applyTorque",
  33146. "Collider:getOrientation",
  33147. "Collider:setOrientation"
  33148. },
  33149. variants = {
  33150. {
  33151. arguments = {},
  33152. returns = {
  33153. {
  33154. name = "vx",
  33155. type = "number",
  33156. description = "The x component of the angular velocity."
  33157. },
  33158. {
  33159. name = "vy",
  33160. type = "number",
  33161. description = "The y component of the angular velocity."
  33162. },
  33163. {
  33164. name = "vz",
  33165. type = "number",
  33166. description = "The z component of the angular velocity."
  33167. }
  33168. }
  33169. }
  33170. }
  33171. },
  33172. {
  33173. name = "getFriction",
  33174. summary = "Get the friction of the Collider.",
  33175. description = "Returns the friction of the Collider. By default, the friction of two Colliders is combined (multiplied) when they collide to generate a friction force. The initial friction is 0.",
  33176. key = "Collider:getFriction",
  33177. module = "lovr.physics",
  33178. related = {
  33179. "Collider:getRestitution",
  33180. "Collider:setRestitution",
  33181. "World:collide"
  33182. },
  33183. variants = {
  33184. {
  33185. arguments = {},
  33186. returns = {
  33187. {
  33188. name = "friction",
  33189. type = "number",
  33190. description = "The friction of the Collider."
  33191. }
  33192. }
  33193. }
  33194. }
  33195. },
  33196. {
  33197. name = "getJoints",
  33198. summary = "Get a list of Joints attached to the Collider.",
  33199. description = "Returns a list of Joints attached to the Collider.",
  33200. key = "Collider:getJoints",
  33201. module = "lovr.physics",
  33202. related = {
  33203. "Joint"
  33204. },
  33205. variants = {
  33206. {
  33207. arguments = {},
  33208. returns = {
  33209. {
  33210. name = "joints",
  33211. type = "table",
  33212. description = "A list of Joints attached to the Collider."
  33213. }
  33214. }
  33215. }
  33216. }
  33217. },
  33218. {
  33219. name = "getLinearDamping",
  33220. summary = "Get the linear damping of the Collider.",
  33221. description = "Returns the Collider's linear damping parameters. Linear damping is similar to drag or air resistance, slowing the Collider down over time.",
  33222. key = "Collider:getLinearDamping",
  33223. module = "lovr.physics",
  33224. notes = "When the Collider is created, it will use the world's linear damping value, which is set using `World:setLinearDamping`.\n\nA linear damping of 0 means the Collider won't slow down over time.",
  33225. related = {
  33226. "World:getLinearDamping",
  33227. "World:setLinearDamping"
  33228. },
  33229. variants = {
  33230. {
  33231. arguments = {},
  33232. returns = {
  33233. {
  33234. name = "damping",
  33235. type = "number",
  33236. description = "The linear damping."
  33237. },
  33238. {
  33239. name = "threshold",
  33240. type = "number",
  33241. description = "Velocity limit below which the damping is not applied."
  33242. }
  33243. }
  33244. }
  33245. }
  33246. },
  33247. {
  33248. name = "getLinearVelocity",
  33249. summary = "Get the linear velocity of the Collider.",
  33250. description = "Returns the linear velocity of the Collider. This is how fast the Collider is moving. There is also angular velocity, which is how fast the Collider is spinning.",
  33251. key = "Collider:getLinearVelocity",
  33252. module = "lovr.physics",
  33253. related = {
  33254. "Collider:getLinearVelocityFromLocalPoint",
  33255. "Collider:getLinearVelocityFromWorldPoint",
  33256. "Collider:getAngularVelocity",
  33257. "Collider:setAngularVelocity",
  33258. "Collider:applyForce",
  33259. "Collider:getPosition",
  33260. "Collider:setPosition"
  33261. },
  33262. variants = {
  33263. {
  33264. arguments = {},
  33265. returns = {
  33266. {
  33267. name = "vx",
  33268. type = "number",
  33269. description = "The x velocity of the Collider, in meters per second."
  33270. },
  33271. {
  33272. name = "vy",
  33273. type = "number",
  33274. description = "The y velocity of the Collider, in meters per second."
  33275. },
  33276. {
  33277. name = "vz",
  33278. type = "number",
  33279. description = "The z velocity of the Collider, in meters per second."
  33280. }
  33281. }
  33282. }
  33283. }
  33284. },
  33285. {
  33286. name = "getLinearVelocityFromLocalPoint",
  33287. summary = "Get the linear velocity of the Collider at a point.",
  33288. description = "Returns the linear velocity of a point relative to the Collider.",
  33289. key = "Collider:getLinearVelocityFromLocalPoint",
  33290. module = "lovr.physics",
  33291. related = {
  33292. "Collider:getLinearVelocity",
  33293. "Collider:getLinearVelocityFromWorldPoint"
  33294. },
  33295. variants = {
  33296. {
  33297. arguments = {
  33298. {
  33299. name = "x",
  33300. type = "number",
  33301. description = "The x coordinate."
  33302. },
  33303. {
  33304. name = "y",
  33305. type = "number",
  33306. description = "The y coordinate."
  33307. },
  33308. {
  33309. name = "z",
  33310. type = "number",
  33311. description = "The z coordinate."
  33312. }
  33313. },
  33314. returns = {
  33315. {
  33316. name = "vx",
  33317. type = "number",
  33318. description = "The x component of the velocity of the point."
  33319. },
  33320. {
  33321. name = "vy",
  33322. type = "number",
  33323. description = "The y component of the velocity of the point."
  33324. },
  33325. {
  33326. name = "vz",
  33327. type = "number",
  33328. description = "The z component of the velocity of the point."
  33329. }
  33330. }
  33331. },
  33332. {
  33333. arguments = {
  33334. {
  33335. name = "point",
  33336. type = "Vec3",
  33337. description = "The point."
  33338. }
  33339. },
  33340. returns = {
  33341. {
  33342. name = "vx",
  33343. type = "number",
  33344. description = "The x component of the velocity of the point."
  33345. },
  33346. {
  33347. name = "vy",
  33348. type = "number",
  33349. description = "The y component of the velocity of the point."
  33350. },
  33351. {
  33352. name = "vz",
  33353. type = "number",
  33354. description = "The z component of the velocity of the point."
  33355. }
  33356. }
  33357. }
  33358. }
  33359. },
  33360. {
  33361. name = "getLinearVelocityFromWorldPoint",
  33362. summary = "Get the linear velocity of the Collider at a world space point.",
  33363. description = "Returns the linear velocity of a point on the Collider specified in world space.",
  33364. key = "Collider:getLinearVelocityFromWorldPoint",
  33365. module = "lovr.physics",
  33366. related = {
  33367. "Collider:getLinearVelocity",
  33368. "Collider:getLinearVelocityFromLocalPoint"
  33369. },
  33370. variants = {
  33371. {
  33372. arguments = {
  33373. {
  33374. name = "x",
  33375. type = "number",
  33376. description = "The x coordinate in world space."
  33377. },
  33378. {
  33379. name = "y",
  33380. type = "number",
  33381. description = "The y coordinate in world space."
  33382. },
  33383. {
  33384. name = "z",
  33385. type = "number",
  33386. description = "The z coordinate in world space."
  33387. }
  33388. },
  33389. returns = {
  33390. {
  33391. name = "vx",
  33392. type = "number",
  33393. description = "The x component of the velocity of the point."
  33394. },
  33395. {
  33396. name = "vy",
  33397. type = "number",
  33398. description = "The y component of the velocity of the point."
  33399. },
  33400. {
  33401. name = "vz",
  33402. type = "number",
  33403. description = "The z component of the velocity of the point."
  33404. }
  33405. }
  33406. },
  33407. {
  33408. arguments = {
  33409. {
  33410. name = "point",
  33411. type = "Vec3",
  33412. description = "The point."
  33413. }
  33414. },
  33415. returns = {
  33416. {
  33417. name = "vx",
  33418. type = "number",
  33419. description = "The x component of the velocity of the point."
  33420. },
  33421. {
  33422. name = "vy",
  33423. type = "number",
  33424. description = "The y component of the velocity of the point."
  33425. },
  33426. {
  33427. name = "vz",
  33428. type = "number",
  33429. description = "The z component of the velocity of the point."
  33430. }
  33431. }
  33432. }
  33433. }
  33434. },
  33435. {
  33436. name = "getLocalCenter",
  33437. summary = "Get the Collider's center of mass.",
  33438. description = "Returns the Collider's center of mass.",
  33439. key = "Collider:getLocalCenter",
  33440. module = "lovr.physics",
  33441. related = {
  33442. "Collider:getLocalPoint",
  33443. "Collider:getMassData",
  33444. "Collider:setMassData"
  33445. },
  33446. variants = {
  33447. {
  33448. arguments = {},
  33449. returns = {
  33450. {
  33451. name = "cx",
  33452. type = "number",
  33453. description = "The x position of the center of mass."
  33454. },
  33455. {
  33456. name = "cy",
  33457. type = "number",
  33458. description = "The y position of the center of mass."
  33459. },
  33460. {
  33461. name = "cz",
  33462. type = "number",
  33463. description = "The z position of the center of mass."
  33464. }
  33465. }
  33466. }
  33467. }
  33468. },
  33469. {
  33470. name = "getLocalPoint",
  33471. summary = "Convert a point from world space to collider space.",
  33472. description = "Converts a point from world coordinates into local coordinates relative to the Collider.",
  33473. key = "Collider:getLocalPoint",
  33474. module = "lovr.physics",
  33475. related = {
  33476. "Collider:getWorldPoint",
  33477. "Collider:getLocalVector",
  33478. "Collider:getWorldVector"
  33479. },
  33480. variants = {
  33481. {
  33482. arguments = {
  33483. {
  33484. name = "wx",
  33485. type = "number",
  33486. description = "The x coordinate of the world point."
  33487. },
  33488. {
  33489. name = "wy",
  33490. type = "number",
  33491. description = "The y coordinate of the world point."
  33492. },
  33493. {
  33494. name = "wz",
  33495. type = "number",
  33496. description = "The z coordinate of the world point."
  33497. }
  33498. },
  33499. returns = {
  33500. {
  33501. name = "x",
  33502. type = "number",
  33503. description = "The x position of the local-space point."
  33504. },
  33505. {
  33506. name = "y",
  33507. type = "number",
  33508. description = "The y position of the local-space point."
  33509. },
  33510. {
  33511. name = "z",
  33512. type = "number",
  33513. description = "The z position of the local-space point."
  33514. }
  33515. }
  33516. },
  33517. {
  33518. arguments = {
  33519. {
  33520. name = "point",
  33521. type = "Vec3",
  33522. description = "The world point."
  33523. }
  33524. },
  33525. returns = {
  33526. {
  33527. name = "x",
  33528. type = "number",
  33529. description = "The x position of the local-space point."
  33530. },
  33531. {
  33532. name = "y",
  33533. type = "number",
  33534. description = "The y position of the local-space point."
  33535. },
  33536. {
  33537. name = "z",
  33538. type = "number",
  33539. description = "The z position of the local-space point."
  33540. }
  33541. }
  33542. }
  33543. }
  33544. },
  33545. {
  33546. name = "getLocalVector",
  33547. summary = "Convert a vector from world space to local space.",
  33548. description = "Converts a direction vector from world space to local space.",
  33549. key = "Collider:getLocalVector",
  33550. module = "lovr.physics",
  33551. related = {
  33552. "Collider:getWorldVector",
  33553. "Collider:getLocalPoint",
  33554. "Collider:getWorldPoint"
  33555. },
  33556. variants = {
  33557. {
  33558. arguments = {
  33559. {
  33560. name = "wx",
  33561. type = "number",
  33562. description = "The x component of the world vector."
  33563. },
  33564. {
  33565. name = "wy",
  33566. type = "number",
  33567. description = "The y component of the world vector."
  33568. },
  33569. {
  33570. name = "wz",
  33571. type = "number",
  33572. description = "The z component of the world vector."
  33573. }
  33574. },
  33575. returns = {
  33576. {
  33577. name = "x",
  33578. type = "number",
  33579. description = "The x coordinate of the local vector."
  33580. },
  33581. {
  33582. name = "y",
  33583. type = "number",
  33584. description = "The y coordinate of the local vector."
  33585. },
  33586. {
  33587. name = "z",
  33588. type = "number",
  33589. description = "The z coordinate of the local vector."
  33590. }
  33591. }
  33592. },
  33593. {
  33594. arguments = {
  33595. {
  33596. name = "vector",
  33597. type = "Vec3",
  33598. description = "The world vector."
  33599. }
  33600. },
  33601. returns = {
  33602. {
  33603. name = "x",
  33604. type = "number",
  33605. description = "The x coordinate of the local vector."
  33606. },
  33607. {
  33608. name = "y",
  33609. type = "number",
  33610. description = "The y coordinate of the local vector."
  33611. },
  33612. {
  33613. name = "z",
  33614. type = "number",
  33615. description = "The z coordinate of the local vector."
  33616. }
  33617. }
  33618. }
  33619. }
  33620. },
  33621. {
  33622. name = "getMass",
  33623. summary = "Get the total mass of the Collider.",
  33624. description = "Returns the total mass of the Collider. The mass of a Collider depends on its attached shapes.",
  33625. key = "Collider:getMass",
  33626. module = "lovr.physics",
  33627. related = {
  33628. "Collider:getMassData",
  33629. "Collider:setMassData",
  33630. "Shape:getMass"
  33631. },
  33632. variants = {
  33633. {
  33634. arguments = {},
  33635. returns = {
  33636. {
  33637. name = "mass",
  33638. type = "number",
  33639. description = "The mass of the Collider, in kilograms."
  33640. }
  33641. }
  33642. }
  33643. }
  33644. },
  33645. {
  33646. name = "getMassData",
  33647. summary = "Compute mass properties for the Collider.",
  33648. description = "Computes mass properties for the Collider.",
  33649. key = "Collider:getMassData",
  33650. module = "lovr.physics",
  33651. related = {
  33652. "Collider:getMass",
  33653. "Collider:setMass",
  33654. "Shape:getMass"
  33655. },
  33656. variants = {
  33657. {
  33658. arguments = {},
  33659. returns = {
  33660. {
  33661. name = "cx",
  33662. type = "number",
  33663. description = "The x position of the center of mass."
  33664. },
  33665. {
  33666. name = "cy",
  33667. type = "number",
  33668. description = "The y position of the center of mass."
  33669. },
  33670. {
  33671. name = "cz",
  33672. type = "number",
  33673. description = "The z position of the center of mass."
  33674. },
  33675. {
  33676. name = "mass",
  33677. type = "number",
  33678. description = "The computed mass of the Collider."
  33679. },
  33680. {
  33681. name = "inertia",
  33682. type = "table",
  33683. description = "A table containing 6 values of the rotational inertia tensor matrix. The table contains the 3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements of the upper right portion of the 3x3 matrix."
  33684. }
  33685. }
  33686. }
  33687. }
  33688. },
  33689. {
  33690. name = "getOrientation",
  33691. summary = "Get the orientation of the Collider.",
  33692. description = "Returns the orientation of the Collider in angle/axis representation.",
  33693. key = "Collider:getOrientation",
  33694. module = "lovr.physics",
  33695. related = {
  33696. "Collider:applyTorque",
  33697. "Collider:getAngularVelocity",
  33698. "Collider:setAngularVelocity",
  33699. "Collider:getPosition",
  33700. "Collider:setPosition",
  33701. "Collider:getPose",
  33702. "Collider:setPose"
  33703. },
  33704. variants = {
  33705. {
  33706. arguments = {},
  33707. returns = {
  33708. {
  33709. name = "angle",
  33710. type = "number",
  33711. description = "The number of radians the Collider is rotated around its axis of rotation."
  33712. },
  33713. {
  33714. name = "ax",
  33715. type = "number",
  33716. description = "The x component of the axis of rotation."
  33717. },
  33718. {
  33719. name = "ay",
  33720. type = "number",
  33721. description = "The y component of the axis of rotation."
  33722. },
  33723. {
  33724. name = "az",
  33725. type = "number",
  33726. description = "The z component of the axis of rotation."
  33727. }
  33728. }
  33729. }
  33730. }
  33731. },
  33732. {
  33733. name = "getPose",
  33734. summary = "Get the pose of the Collider.",
  33735. description = "Returns the position and orientation of the Collider.",
  33736. key = "Collider:getPose",
  33737. module = "lovr.physics",
  33738. related = {
  33739. "Collider:getPosition",
  33740. "Collider:getOrientation"
  33741. },
  33742. variants = {
  33743. {
  33744. arguments = {},
  33745. returns = {
  33746. {
  33747. name = "x",
  33748. type = "number",
  33749. description = "The x position of the Collider, in meters."
  33750. },
  33751. {
  33752. name = "y",
  33753. type = "number",
  33754. description = "The y position of the Collider, in meters."
  33755. },
  33756. {
  33757. name = "z",
  33758. type = "number",
  33759. description = "The z position of the Collider, in meters."
  33760. },
  33761. {
  33762. name = "angle",
  33763. type = "number",
  33764. description = "The number of radians the Collider is rotated around its axis of rotation."
  33765. },
  33766. {
  33767. name = "ax",
  33768. type = "number",
  33769. description = "The x component of the axis of rotation."
  33770. },
  33771. {
  33772. name = "ay",
  33773. type = "number",
  33774. description = "The y component of the axis of rotation."
  33775. },
  33776. {
  33777. name = "az",
  33778. type = "number",
  33779. description = "The z component of the axis of rotation."
  33780. }
  33781. }
  33782. }
  33783. }
  33784. },
  33785. {
  33786. name = "getPosition",
  33787. summary = "Get the position of the Collider.",
  33788. description = "Returns the position of the Collider.",
  33789. key = "Collider:getPosition",
  33790. module = "lovr.physics",
  33791. related = {
  33792. "Collider:applyForce",
  33793. "Collider:getLinearVelocity",
  33794. "Collider:setLinearVelocity",
  33795. "Collider:getOrientation",
  33796. "Collider:setOrientation",
  33797. "Collider:getPose",
  33798. "Collider:setPose"
  33799. },
  33800. variants = {
  33801. {
  33802. arguments = {},
  33803. returns = {
  33804. {
  33805. name = "x",
  33806. type = "number",
  33807. description = "The x position of the Collider, in meters."
  33808. },
  33809. {
  33810. name = "y",
  33811. type = "number",
  33812. description = "The y position of the Collider, in meters."
  33813. },
  33814. {
  33815. name = "z",
  33816. type = "number",
  33817. description = "The z position of the Collider, in meters."
  33818. }
  33819. }
  33820. }
  33821. }
  33822. },
  33823. {
  33824. name = "getRestitution",
  33825. summary = "Get the bounciness of the Collider.",
  33826. description = "Returns the restitution (bounciness) of the Collider. By default, the restitution of two Colliders is combined (the max is used) when they collide to cause them to bounce away from each other. The initial restitution is 0.",
  33827. key = "Collider:getRestitution",
  33828. module = "lovr.physics",
  33829. related = {
  33830. "Collider:getFriction",
  33831. "Collider:setFriction",
  33832. "World:collide"
  33833. },
  33834. variants = {
  33835. {
  33836. arguments = {},
  33837. returns = {
  33838. {
  33839. name = "restitution",
  33840. type = "number",
  33841. description = "The restitution of the Collider."
  33842. }
  33843. }
  33844. }
  33845. }
  33846. },
  33847. {
  33848. name = "getShapes",
  33849. summary = "Get a list of Shapes attached to the Collider.",
  33850. description = "Returns a list of Shapes attached to the Collider.",
  33851. key = "Collider:getShapes",
  33852. module = "lovr.physics",
  33853. related = {
  33854. "Collider:addShape",
  33855. "Collider:removeShape",
  33856. "Shape"
  33857. },
  33858. variants = {
  33859. {
  33860. arguments = {},
  33861. returns = {
  33862. {
  33863. name = "shapes",
  33864. type = "table",
  33865. description = "A list of Shapes attached to the Collider."
  33866. }
  33867. }
  33868. }
  33869. }
  33870. },
  33871. {
  33872. name = "getTag",
  33873. summary = "Get the Collider's tag.",
  33874. description = "Returns the Collider's tag.",
  33875. key = "Collider:getTag",
  33876. module = "lovr.physics",
  33877. notes = "Collision between tags can be enabled and disabled using `World:enableCollisionBetween` and `World:disableCollisionBetween`.",
  33878. related = {
  33879. "World:disableCollisionBetween",
  33880. "World:enableCollisionBetween",
  33881. "World:isCollisionEnabledBetween",
  33882. "lovr.physics.newWorld"
  33883. },
  33884. variants = {
  33885. {
  33886. arguments = {},
  33887. returns = {
  33888. {
  33889. name = "tag",
  33890. type = "string",
  33891. description = "The Collider's collision tag, or `nil` if the Collider doesn't have a tag."
  33892. }
  33893. }
  33894. }
  33895. }
  33896. },
  33897. {
  33898. name = "getUserData",
  33899. summary = "Get the Collider's user data.",
  33900. description = "Returns the user data associated with the Collider.",
  33901. key = "Collider:getUserData",
  33902. module = "lovr.physics",
  33903. notes = "User data can be useful to identify the Collider in callbacks.",
  33904. variants = {
  33905. {
  33906. arguments = {},
  33907. returns = {
  33908. {
  33909. name = "data",
  33910. type = "*",
  33911. description = "The custom value associated with the Collider."
  33912. }
  33913. }
  33914. }
  33915. }
  33916. },
  33917. {
  33918. name = "getWorld",
  33919. summary = "Get the World the Collider is in.",
  33920. description = "Returns the World the Collider is in.",
  33921. key = "Collider:getWorld",
  33922. module = "lovr.physics",
  33923. notes = "Colliders can only be in one World at a time.",
  33924. related = {
  33925. "World"
  33926. },
  33927. variants = {
  33928. {
  33929. arguments = {},
  33930. returns = {
  33931. {
  33932. name = "world",
  33933. type = "World",
  33934. description = "The World the Collider is in."
  33935. }
  33936. }
  33937. }
  33938. }
  33939. },
  33940. {
  33941. name = "getWorldPoint",
  33942. summary = "Convert a point from local space to world space.",
  33943. description = "Convert a point relative to the collider to a point in world coordinates.",
  33944. key = "Collider:getWorldPoint",
  33945. module = "lovr.physics",
  33946. related = {
  33947. "Collider:getLocalPoint",
  33948. "Collider:getLocalVector",
  33949. "Collider:getWorldVector"
  33950. },
  33951. variants = {
  33952. {
  33953. arguments = {
  33954. {
  33955. name = "x",
  33956. type = "number",
  33957. description = "The x position of the point."
  33958. },
  33959. {
  33960. name = "y",
  33961. type = "number",
  33962. description = "The y position of the point."
  33963. },
  33964. {
  33965. name = "z",
  33966. type = "number",
  33967. description = "The z position of the point."
  33968. }
  33969. },
  33970. returns = {
  33971. {
  33972. name = "wx",
  33973. type = "number",
  33974. description = "The x coordinate of the world point."
  33975. },
  33976. {
  33977. name = "wy",
  33978. type = "number",
  33979. description = "The y coordinate of the world point."
  33980. },
  33981. {
  33982. name = "wz",
  33983. type = "number",
  33984. description = "The z coordinate of the world point."
  33985. }
  33986. }
  33987. },
  33988. {
  33989. arguments = {
  33990. {
  33991. name = "point",
  33992. type = "Vec3",
  33993. description = "The local point."
  33994. }
  33995. },
  33996. returns = {
  33997. {
  33998. name = "wx",
  33999. type = "number",
  34000. description = "The x coordinate of the world point."
  34001. },
  34002. {
  34003. name = "wy",
  34004. type = "number",
  34005. description = "The y coordinate of the world point."
  34006. },
  34007. {
  34008. name = "wz",
  34009. type = "number",
  34010. description = "The z coordinate of the world point."
  34011. }
  34012. }
  34013. }
  34014. }
  34015. },
  34016. {
  34017. name = "getWorldVector",
  34018. summary = "Convert a vector from local space to world space.",
  34019. description = "Converts a direction vector from local space to world space.",
  34020. key = "Collider:getWorldVector",
  34021. module = "lovr.physics",
  34022. related = {
  34023. "Collider:getLocalVector",
  34024. "Collider:getLocalPoint",
  34025. "Collider:getWorldPoint"
  34026. },
  34027. variants = {
  34028. {
  34029. arguments = {
  34030. {
  34031. name = "x",
  34032. type = "number",
  34033. description = "The x coordinate of the local vector."
  34034. },
  34035. {
  34036. name = "y",
  34037. type = "number",
  34038. description = "The y coordinate of the local vector."
  34039. },
  34040. {
  34041. name = "z",
  34042. type = "number",
  34043. description = "The z coordinate of the local vector."
  34044. }
  34045. },
  34046. returns = {
  34047. {
  34048. name = "wx",
  34049. type = "number",
  34050. description = "The x component of the world vector."
  34051. },
  34052. {
  34053. name = "wy",
  34054. type = "number",
  34055. description = "The y component of the world vector."
  34056. },
  34057. {
  34058. name = "wz",
  34059. type = "number",
  34060. description = "The z component of the world vector."
  34061. }
  34062. }
  34063. },
  34064. {
  34065. arguments = {
  34066. {
  34067. name = "vector",
  34068. type = "Vec3",
  34069. description = "The local vector."
  34070. }
  34071. },
  34072. returns = {
  34073. {
  34074. name = "wx",
  34075. type = "number",
  34076. description = "The x component of the world vector."
  34077. },
  34078. {
  34079. name = "wy",
  34080. type = "number",
  34081. description = "The y component of the world vector."
  34082. },
  34083. {
  34084. name = "wz",
  34085. type = "number",
  34086. description = "The z component of the world vector."
  34087. }
  34088. }
  34089. }
  34090. }
  34091. },
  34092. {
  34093. name = "isAwake",
  34094. summary = "Check if the Collider is awake.",
  34095. description = "Returns whether the Collider is currently awake.",
  34096. key = "Collider:isAwake",
  34097. module = "lovr.physics",
  34098. related = {
  34099. "World:isSleepingAllowed",
  34100. "World:setSleepingAllowed",
  34101. "Collider:isSleepingAllowed",
  34102. "Collider:setSleepingAllowed"
  34103. },
  34104. variants = {
  34105. {
  34106. arguments = {},
  34107. returns = {
  34108. {
  34109. name = "awake",
  34110. type = "boolean",
  34111. description = "Whether the Collider is awake."
  34112. }
  34113. }
  34114. }
  34115. }
  34116. },
  34117. {
  34118. name = "isDestroyed",
  34119. summary = "Check if the Collider has been destroyed.",
  34120. description = "Returns whether the collider has been destroyed.",
  34121. key = "Collider:isDestroyed",
  34122. module = "lovr.physics",
  34123. notes = "Calling functions on a collider after destroying it is a bad idea.",
  34124. related = {
  34125. "Collider:destroy",
  34126. "World:destroy",
  34127. "Shape:destroy",
  34128. "Joint:destroy"
  34129. },
  34130. variants = {
  34131. {
  34132. arguments = {},
  34133. returns = {
  34134. {
  34135. name = "destroyed",
  34136. type = "boolean",
  34137. description = "Whether the collider has been destroyed."
  34138. }
  34139. }
  34140. }
  34141. }
  34142. },
  34143. {
  34144. name = "isGravityIgnored",
  34145. summary = "Check if the Collider ignores gravity.",
  34146. description = "Returns whether the Collider is currently ignoring gravity.",
  34147. key = "Collider:isGravityIgnored",
  34148. module = "lovr.physics",
  34149. variants = {
  34150. {
  34151. arguments = {},
  34152. returns = {
  34153. {
  34154. name = "ignored",
  34155. type = "boolean",
  34156. description = "Whether gravity is ignored for this Collider."
  34157. }
  34158. }
  34159. }
  34160. }
  34161. },
  34162. {
  34163. name = "isKinematic",
  34164. summary = "Check if the Collider is kinematic.",
  34165. description = "Returns whether the Collider is kinematic.",
  34166. key = "Collider:isKinematic",
  34167. module = "lovr.physics",
  34168. notes = "Kinematic colliders behave as though they have infinite mass, ignoring external forces like gravity, joints, or collisions (though non-kinematic colliders will collide with them). They can be useful for static objects like floors or walls.",
  34169. variants = {
  34170. {
  34171. arguments = {},
  34172. returns = {
  34173. {
  34174. name = "kinematic",
  34175. type = "boolean",
  34176. description = "Whether the Collider is kinematic."
  34177. }
  34178. }
  34179. }
  34180. }
  34181. },
  34182. {
  34183. name = "isSleepingAllowed",
  34184. summary = "Check if the Collider is allowed to sleep.",
  34185. description = "Returns whether the Collider is allowed to sleep.",
  34186. key = "Collider:isSleepingAllowed",
  34187. module = "lovr.physics",
  34188. notes = "If sleeping is enabled, the simulation will put the Collider to sleep if it hasn't moved in a while. Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly.\n\nIt is possible to set the default value for new colliders using `World:setSleepingAllowed`.\n\nColliders can be manually put to sleep or woken up using `Collider:setAwake`.",
  34189. related = {
  34190. "World:isSleepingAllowed",
  34191. "World:setSleepingAllowed",
  34192. "Collider:isAwake",
  34193. "Collider:setAwake"
  34194. },
  34195. variants = {
  34196. {
  34197. arguments = {},
  34198. returns = {
  34199. {
  34200. name = "allowed",
  34201. type = "boolean",
  34202. description = "Whether the Collider can go to sleep."
  34203. }
  34204. }
  34205. }
  34206. }
  34207. },
  34208. {
  34209. name = "removeShape",
  34210. summary = "Remove a Shape from the Collider.",
  34211. description = "Removes a Shape from the Collider.",
  34212. key = "Collider:removeShape",
  34213. module = "lovr.physics",
  34214. notes = "Colliders without any shapes won't collide with anything.",
  34215. related = {
  34216. "Collider:addShape",
  34217. "Collider:getShapes",
  34218. "Shape"
  34219. },
  34220. variants = {
  34221. {
  34222. arguments = {
  34223. {
  34224. name = "shape",
  34225. type = "Shape",
  34226. description = "The Shape to remove."
  34227. }
  34228. },
  34229. returns = {}
  34230. }
  34231. }
  34232. },
  34233. {
  34234. name = "setAngularDamping",
  34235. summary = "Set the angular damping of the Collider.",
  34236. description = "Sets the angular damping of the Collider. Angular damping makes things less \"spinny\", causing them to slow down their angular velocity over time. Damping is only applied when angular velocity is over the threshold value.",
  34237. key = "Collider:setAngularDamping",
  34238. module = "lovr.physics",
  34239. notes = "When the Collider is created, it will use the world's angular damping value, which is set using `World:setAngularDamping`.",
  34240. related = {
  34241. "World:getAngularDamping",
  34242. "World:setAngularDamping"
  34243. },
  34244. variants = {
  34245. {
  34246. arguments = {
  34247. {
  34248. name = "damping",
  34249. type = "number",
  34250. description = "The angular damping."
  34251. },
  34252. {
  34253. name = "threshold",
  34254. type = "number",
  34255. description = "Velocity limit below which the damping is not applied.",
  34256. default = "0"
  34257. }
  34258. },
  34259. returns = {}
  34260. }
  34261. }
  34262. },
  34263. {
  34264. name = "setAngularVelocity",
  34265. summary = "Set the angular velocity of the Collider.",
  34266. description = "Sets the angular velocity of the Collider.",
  34267. key = "Collider:setAngularVelocity",
  34268. module = "lovr.physics",
  34269. related = {
  34270. "Collider:getLinearVelocity",
  34271. "Collider:setLinearVelocity",
  34272. "Collider:applyTorque",
  34273. "Collider:getOrientation",
  34274. "Collider:setOrientation"
  34275. },
  34276. variants = {
  34277. {
  34278. description = "Sets the angular velocity of the Collider using numbers.",
  34279. arguments = {
  34280. {
  34281. name = "vx",
  34282. type = "number",
  34283. description = "The x component of the angular velocity."
  34284. },
  34285. {
  34286. name = "vy",
  34287. type = "number",
  34288. description = "The y component of the angular velocity."
  34289. },
  34290. {
  34291. name = "vz",
  34292. type = "number",
  34293. description = "The z component of the angular velocity."
  34294. }
  34295. },
  34296. returns = {}
  34297. },
  34298. {
  34299. description = "Sets the angular velocity of the Collider using a vector.",
  34300. arguments = {
  34301. {
  34302. name = "velocity",
  34303. type = "Vec3",
  34304. description = "The angular velocity of the Collider."
  34305. }
  34306. },
  34307. returns = {}
  34308. }
  34309. }
  34310. },
  34311. {
  34312. name = "setAwake",
  34313. summary = "Put the Collider to sleep or wake it up.",
  34314. description = "Manually puts the Collider to sleep or wakes it up. You can do this if you know a Collider won't be touched for a while or if you need to it be active.",
  34315. key = "Collider:setAwake",
  34316. module = "lovr.physics",
  34317. related = {
  34318. "World:isSleepingAllowed",
  34319. "World:setSleepingAllowed",
  34320. "Collider:isSleepingAllowed",
  34321. "Collider:setSleepingAllowed"
  34322. },
  34323. variants = {
  34324. {
  34325. arguments = {
  34326. {
  34327. name = "awake",
  34328. type = "boolean",
  34329. description = "Whether the Collider should be awake."
  34330. }
  34331. },
  34332. returns = {}
  34333. }
  34334. }
  34335. },
  34336. {
  34337. name = "setFriction",
  34338. summary = "Set the friction of the Collider.",
  34339. description = "Sets the friction of the Collider. By default, the friction of two Colliders is combined (multiplied) when they collide to generate a friction force. The initial friction is 0.",
  34340. key = "Collider:setFriction",
  34341. module = "lovr.physics",
  34342. related = {
  34343. "Collider:getRestitution",
  34344. "Collider:setRestitution",
  34345. "World:collide"
  34346. },
  34347. variants = {
  34348. {
  34349. arguments = {
  34350. {
  34351. name = "friction",
  34352. type = "number",
  34353. description = "The new friction."
  34354. }
  34355. },
  34356. returns = {}
  34357. }
  34358. }
  34359. },
  34360. {
  34361. name = "setGravityIgnored",
  34362. summary = "Set whether the Collider ignores gravity.",
  34363. description = "Sets whether the Collider should ignore gravity.",
  34364. key = "Collider:setGravityIgnored",
  34365. module = "lovr.physics",
  34366. variants = {
  34367. {
  34368. arguments = {
  34369. {
  34370. name = "ignored",
  34371. type = "boolean",
  34372. description = "Whether gravity should be ignored."
  34373. }
  34374. },
  34375. returns = {}
  34376. }
  34377. }
  34378. },
  34379. {
  34380. name = "setKinematic",
  34381. summary = "Set whether the Collider is kinematic.",
  34382. description = "Sets whether the Collider is kinematic.",
  34383. key = "Collider:setKinematic",
  34384. module = "lovr.physics",
  34385. notes = "Kinematic colliders behave as though they have infinite mass, ignoring external forces like gravity, joints, or collisions (though non-kinematic colliders will collide with them). They can be useful for static objects like floors or walls.",
  34386. variants = {
  34387. {
  34388. arguments = {
  34389. {
  34390. name = "kinematic",
  34391. type = "boolean",
  34392. description = "Whether the Collider is kinematic."
  34393. }
  34394. },
  34395. returns = {}
  34396. }
  34397. }
  34398. },
  34399. {
  34400. name = "setLinearDamping",
  34401. summary = "Set the linear damping of the Collider.",
  34402. description = "Sets the Collider's linear damping parameter. Linear damping is similar to drag or air resistance, slowing the Collider down over time. Damping is only applied when linear velocity is over the threshold value.",
  34403. key = "Collider:setLinearDamping",
  34404. module = "lovr.physics",
  34405. notes = "When the Collider is created, it will use the world's linear damping value, which is set using `World:setLinearDamping`.\n\nA linear damping of 0 means the Collider won't slow down over time.",
  34406. related = {
  34407. "World:getLinearDamping",
  34408. "World:setLinearDamping"
  34409. },
  34410. variants = {
  34411. {
  34412. arguments = {
  34413. {
  34414. name = "damping",
  34415. type = "number",
  34416. description = "The linear damping."
  34417. },
  34418. {
  34419. name = "threshold",
  34420. type = "number",
  34421. description = "Velocity limit below which the damping is not applied.",
  34422. default = "0"
  34423. }
  34424. },
  34425. returns = {}
  34426. }
  34427. }
  34428. },
  34429. {
  34430. name = "setLinearVelocity",
  34431. summary = "Set the linear velocity of the Collider.",
  34432. description = "Sets the linear velocity of the Collider directly. Usually it's preferred to use `Collider:applyForce` to change velocity since instantaneous velocity changes can lead to weird glitches.",
  34433. key = "Collider:setLinearVelocity",
  34434. module = "lovr.physics",
  34435. related = {
  34436. "Collider:getLinearVelocityFromLocalPoint",
  34437. "Collider:getLinearVelocityFromWorldPoint",
  34438. "Collider:getAngularVelocity",
  34439. "Collider:setAngularVelocity",
  34440. "Collider:applyForce",
  34441. "Collider:getPosition",
  34442. "Collider:setPosition"
  34443. },
  34444. variants = {
  34445. {
  34446. description = "Set the linear velocity of the collider using numbers.",
  34447. arguments = {
  34448. {
  34449. name = "vx",
  34450. type = "number",
  34451. description = "The x velocity of the Collider, in meters per second."
  34452. },
  34453. {
  34454. name = "vy",
  34455. type = "number",
  34456. description = "The y velocity of the Collider, in meters per second."
  34457. },
  34458. {
  34459. name = "vz",
  34460. type = "number",
  34461. description = "The z velocity of the Collider, in meters per second."
  34462. }
  34463. },
  34464. returns = {}
  34465. },
  34466. {
  34467. description = "Set the linear velocity of the collider using a vector.",
  34468. arguments = {
  34469. {
  34470. name = "velocity",
  34471. type = "Vec3",
  34472. description = "The velocity of the Collider, in meters per second."
  34473. }
  34474. },
  34475. returns = {}
  34476. }
  34477. }
  34478. },
  34479. {
  34480. name = "setMass",
  34481. summary = "Set the total mass of the Collider.",
  34482. description = "Sets the total mass of the Collider.",
  34483. key = "Collider:setMass",
  34484. module = "lovr.physics",
  34485. related = {
  34486. "Collider:getMassData",
  34487. "Collider:setMassData",
  34488. "Shape:getMass"
  34489. },
  34490. variants = {
  34491. {
  34492. arguments = {
  34493. {
  34494. name = "mass",
  34495. type = "number",
  34496. description = "The new mass for the Collider, in kilograms."
  34497. }
  34498. },
  34499. returns = {}
  34500. }
  34501. }
  34502. },
  34503. {
  34504. name = "setMassData",
  34505. summary = "Set mass properties for the Collider.",
  34506. description = "Sets mass properties for the Collider.",
  34507. key = "Collider:setMassData",
  34508. module = "lovr.physics",
  34509. related = {
  34510. "Collider:getMass",
  34511. "Collider:setMass",
  34512. "Shape:getMass"
  34513. },
  34514. variants = {
  34515. {
  34516. arguments = {
  34517. {
  34518. name = "cx",
  34519. type = "number",
  34520. description = "The x position of the center of mass."
  34521. },
  34522. {
  34523. name = "cy",
  34524. type = "number",
  34525. description = "The y position of the center of mass."
  34526. },
  34527. {
  34528. name = "cz",
  34529. type = "number",
  34530. description = "The z position of the center of mass."
  34531. },
  34532. {
  34533. name = "mass",
  34534. type = "number",
  34535. description = "The computed mass of the Collider."
  34536. },
  34537. {
  34538. name = "inertia",
  34539. type = "table",
  34540. description = "A table containing 6 values of the rotational inertia tensor matrix. The table contains the 3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements of the upper right portion of the 3x3 matrix."
  34541. }
  34542. },
  34543. returns = {}
  34544. }
  34545. }
  34546. },
  34547. {
  34548. name = "setOrientation",
  34549. summary = "Set the orientation of the Collider.",
  34550. description = "Sets the orientation of the Collider in angle/axis representation.",
  34551. key = "Collider:setOrientation",
  34552. module = "lovr.physics",
  34553. related = {
  34554. "Collider:applyTorque",
  34555. "Collider:getAngularVelocity",
  34556. "Collider:setAngularVelocity",
  34557. "Collider:getPosition",
  34558. "Collider:setPosition",
  34559. "Collider:getPose",
  34560. "Collider:setPose"
  34561. },
  34562. variants = {
  34563. {
  34564. description = "Set the orientation of the Collider using numbers.",
  34565. arguments = {
  34566. {
  34567. name = "angle",
  34568. type = "number",
  34569. description = "The number of radians the Collider is rotated around its axis of rotation."
  34570. },
  34571. {
  34572. name = "ax",
  34573. type = "number",
  34574. description = "The x component of the axis of rotation."
  34575. },
  34576. {
  34577. name = "ay",
  34578. type = "number",
  34579. description = "The y component of the axis of rotation."
  34580. },
  34581. {
  34582. name = "az",
  34583. type = "number",
  34584. description = "The z component of the axis of rotation."
  34585. }
  34586. },
  34587. returns = {}
  34588. },
  34589. {
  34590. description = "Set the orientation of the Collider using a quaternion.",
  34591. arguments = {
  34592. {
  34593. name = "orientation",
  34594. type = "Quat",
  34595. description = "The orientation of the Collider."
  34596. }
  34597. },
  34598. returns = {}
  34599. }
  34600. }
  34601. },
  34602. {
  34603. name = "setPose",
  34604. summary = "Set the pose of the Collider.",
  34605. description = "Sets the position and orientation of the Collider.",
  34606. key = "Collider:setPose",
  34607. module = "lovr.physics",
  34608. related = {
  34609. "Collider:setPosition",
  34610. "Collider:setOrientation"
  34611. },
  34612. variants = {
  34613. {
  34614. description = "Set the pose of the Collider using numbers.",
  34615. arguments = {
  34616. {
  34617. name = "x",
  34618. type = "number",
  34619. description = "The x position of the Collider, in meters."
  34620. },
  34621. {
  34622. name = "y",
  34623. type = "number",
  34624. description = "The y position of the Collider, in meters."
  34625. },
  34626. {
  34627. name = "z",
  34628. type = "number",
  34629. description = "The z position of the Collider, in meters."
  34630. },
  34631. {
  34632. name = "angle",
  34633. type = "number",
  34634. description = "The number of radians the Collider is rotated around its axis of rotation."
  34635. },
  34636. {
  34637. name = "ax",
  34638. type = "number",
  34639. description = "The x component of the axis of rotation."
  34640. },
  34641. {
  34642. name = "ay",
  34643. type = "number",
  34644. description = "The y component of the axis of rotation."
  34645. },
  34646. {
  34647. name = "az",
  34648. type = "number",
  34649. description = "The z component of the axis of rotation."
  34650. }
  34651. },
  34652. returns = {}
  34653. },
  34654. {
  34655. description = "Set the pose of the Collider using vector types.",
  34656. arguments = {
  34657. {
  34658. name = "position",
  34659. type = "Vec3",
  34660. description = "The position of the Collider, in meters."
  34661. },
  34662. {
  34663. name = "orientation",
  34664. type = "Quat",
  34665. description = "The orientation of the Collider."
  34666. }
  34667. },
  34668. returns = {}
  34669. }
  34670. }
  34671. },
  34672. {
  34673. name = "setPosition",
  34674. summary = "Set the position of the Collider.",
  34675. description = "Sets the position of the Collider.",
  34676. key = "Collider:setPosition",
  34677. module = "lovr.physics",
  34678. related = {
  34679. "Collider:applyForce",
  34680. "Collider:getLinearVelocity",
  34681. "Collider:setLinearVelocity",
  34682. "Collider:getOrientation",
  34683. "Collider:setOrientation",
  34684. "Collider:getPose",
  34685. "Collider:setPose"
  34686. },
  34687. variants = {
  34688. {
  34689. description = "Set the position of the Collider using numbers.",
  34690. arguments = {
  34691. {
  34692. name = "x",
  34693. type = "number",
  34694. description = "The x position of the Collider, in meters."
  34695. },
  34696. {
  34697. name = "y",
  34698. type = "number",
  34699. description = "The y position of the Collider, in meters."
  34700. },
  34701. {
  34702. name = "z",
  34703. type = "number",
  34704. description = "The z position of the Collider, in meters."
  34705. }
  34706. },
  34707. returns = {}
  34708. },
  34709. {
  34710. description = "Set the position of the Collider using a vector.",
  34711. arguments = {
  34712. {
  34713. name = "position",
  34714. type = "Vec3",
  34715. description = "The position of the Collider, in meters."
  34716. }
  34717. },
  34718. returns = {}
  34719. }
  34720. }
  34721. },
  34722. {
  34723. name = "setRestitution",
  34724. summary = "Set the bounciness of the Collider.",
  34725. description = "Sets the restitution (bounciness) of the Collider. By default, the restitution of two Colliders is combined (the max is used) when they collide to cause them to bounce away from each other. The initial restitution is 0.",
  34726. key = "Collider:setRestitution",
  34727. module = "lovr.physics",
  34728. related = {
  34729. "Collider:getFriction",
  34730. "Collider:setFriction",
  34731. "World:collide"
  34732. },
  34733. variants = {
  34734. {
  34735. arguments = {
  34736. {
  34737. name = "restitution",
  34738. type = "number",
  34739. description = "The new restitution."
  34740. }
  34741. },
  34742. returns = {}
  34743. }
  34744. }
  34745. },
  34746. {
  34747. name = "setSleepingAllowed",
  34748. summary = "Set whether the Collider is allowed to sleep.",
  34749. description = "Sets whether the Collider is allowed to sleep.",
  34750. key = "Collider:setSleepingAllowed",
  34751. module = "lovr.physics",
  34752. notes = "If sleeping is enabled, the simulation will put the Collider to sleep if it hasn't moved in a while. Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly.\n\nIt is possible to set the default value for new colliders using `World:setSleepingAllowed`.\n\nColliders can be manually put to sleep or woken up using `Collider:setAwake`.",
  34753. related = {
  34754. "World:isSleepingAllowed",
  34755. "World:setSleepingAllowed",
  34756. "Collider:isAwake",
  34757. "Collider:setAwake"
  34758. },
  34759. variants = {
  34760. {
  34761. arguments = {
  34762. {
  34763. name = "allowed",
  34764. type = "boolean",
  34765. description = "Whether the Collider can go to sleep."
  34766. }
  34767. },
  34768. returns = {}
  34769. }
  34770. }
  34771. },
  34772. {
  34773. name = "setTag",
  34774. summary = "Set the Collider's tag.",
  34775. description = "Sets the Collider's tag.",
  34776. key = "Collider:setTag",
  34777. module = "lovr.physics",
  34778. notes = "Collision between tags can be enabled and disabled using `World:enableCollisionBetween` and `World:disableCollisionBetween`.",
  34779. related = {
  34780. "World:disableCollisionBetween",
  34781. "World:enableCollisionBetween",
  34782. "World:isCollisionEnabledBetween",
  34783. "lovr.physics.newWorld"
  34784. },
  34785. variants = {
  34786. {
  34787. arguments = {
  34788. {
  34789. name = "tag",
  34790. type = "string",
  34791. description = "The Collider's collision tag."
  34792. }
  34793. },
  34794. returns = {}
  34795. },
  34796. {
  34797. description = "Clear the Collider's tag.",
  34798. arguments = {},
  34799. returns = {}
  34800. }
  34801. }
  34802. },
  34803. {
  34804. name = "setUserData",
  34805. summary = "Set the Collider's user data.",
  34806. description = "Associates a custom value with the Collider.",
  34807. key = "Collider:setUserData",
  34808. module = "lovr.physics",
  34809. notes = "User data can be useful to identify the Collider in callbacks.",
  34810. variants = {
  34811. {
  34812. arguments = {
  34813. {
  34814. name = "data",
  34815. type = "*",
  34816. description = "The custom value to associate with the Collider."
  34817. }
  34818. },
  34819. returns = {}
  34820. }
  34821. }
  34822. }
  34823. }
  34824. },
  34825. {
  34826. name = "CylinderShape",
  34827. summary = "A cylinder Shape.",
  34828. description = "A type of `Shape` that can be used for cylinder-shaped things.",
  34829. key = "CylinderShape",
  34830. module = "lovr.physics",
  34831. constructors = {
  34832. "lovr.physics.newCylinderShape",
  34833. "World:newCylinderCollider"
  34834. },
  34835. extends = "Shape",
  34836. methods = {
  34837. {
  34838. name = "getLength",
  34839. summary = "Get the length of the CylinderShape.",
  34840. description = "Returns the length of the CylinderShape.",
  34841. key = "CylinderShape:getLength",
  34842. module = "lovr.physics",
  34843. variants = {
  34844. {
  34845. arguments = {},
  34846. returns = {
  34847. {
  34848. name = "length",
  34849. type = "number",
  34850. description = "The length of the cylinder, in meters."
  34851. }
  34852. }
  34853. }
  34854. }
  34855. },
  34856. {
  34857. name = "getRadius",
  34858. summary = "Get the radius of the CylinderShape.",
  34859. description = "Returns the radius of the CylinderShape.",
  34860. key = "CylinderShape:getRadius",
  34861. module = "lovr.physics",
  34862. variants = {
  34863. {
  34864. arguments = {},
  34865. returns = {
  34866. {
  34867. name = "radius",
  34868. type = "number",
  34869. description = "The radius of the cylinder, in meters."
  34870. }
  34871. }
  34872. }
  34873. }
  34874. },
  34875. {
  34876. name = "setLength",
  34877. summary = "Set the length of the CylinderShape.",
  34878. description = "Sets the length of the CylinderShape.",
  34879. key = "CylinderShape:setLength",
  34880. module = "lovr.physics",
  34881. variants = {
  34882. {
  34883. arguments = {
  34884. {
  34885. name = "length",
  34886. type = "number",
  34887. description = "The new length, in meters."
  34888. }
  34889. },
  34890. returns = {}
  34891. }
  34892. }
  34893. },
  34894. {
  34895. name = "setRadius",
  34896. summary = "Set the radius of the CylinderShape.",
  34897. description = "Sets the radius of the CylinderShape.",
  34898. key = "CylinderShape:setRadius",
  34899. module = "lovr.physics",
  34900. variants = {
  34901. {
  34902. arguments = {
  34903. {
  34904. name = "radius",
  34905. type = "number",
  34906. description = "The new radius, in meters."
  34907. }
  34908. },
  34909. returns = {}
  34910. }
  34911. }
  34912. }
  34913. }
  34914. },
  34915. {
  34916. name = "DistanceJoint",
  34917. summary = "A fixed distance joint.",
  34918. description = "A DistanceJoint is a type of `Joint` that tries to keep two colliders a fixed distance apart. The distance is determined by the initial distance between the anchor points. The joint allows for rotation on the anchor points.",
  34919. key = "DistanceJoint",
  34920. module = "lovr.physics",
  34921. constructors = {
  34922. "lovr.physics.newDistanceJoint"
  34923. },
  34924. extends = "Joint",
  34925. methods = {
  34926. {
  34927. name = "getAnchors",
  34928. summary = "Get the anchor points of the DistanceJoint.",
  34929. description = "Returns the anchor points of the DistanceJoint.",
  34930. key = "DistanceJoint:getAnchors",
  34931. module = "lovr.physics",
  34932. variants = {
  34933. {
  34934. arguments = {},
  34935. returns = {
  34936. {
  34937. name = "x1",
  34938. type = "number",
  34939. description = "The x coordinate of the first anchor point, in world coordinates."
  34940. },
  34941. {
  34942. name = "y1",
  34943. type = "number",
  34944. description = "The y coordinate of the first anchor point, in world coordinates."
  34945. },
  34946. {
  34947. name = "z1",
  34948. type = "number",
  34949. description = "The z coordinate of the first anchor point, in world coordinates."
  34950. },
  34951. {
  34952. name = "x2",
  34953. type = "number",
  34954. description = "The x coordinate of the second anchor point, in world coordinates."
  34955. },
  34956. {
  34957. name = "y2",
  34958. type = "number",
  34959. description = "The y coordinate of the second anchor point, in world coordinates."
  34960. },
  34961. {
  34962. name = "z2",
  34963. type = "number",
  34964. description = "The z coordinate of the second anchor point, in world coordinates."
  34965. }
  34966. }
  34967. }
  34968. }
  34969. },
  34970. {
  34971. name = "getDistance",
  34972. summary = "Get the target distance of the DistanceJoint.",
  34973. description = "Returns the target distance for the DistanceJoint. The joint tries to keep the Colliders this far apart.",
  34974. key = "DistanceJoint:getDistance",
  34975. module = "lovr.physics",
  34976. variants = {
  34977. {
  34978. arguments = {},
  34979. returns = {
  34980. {
  34981. name = "distance",
  34982. type = "number",
  34983. description = "The target distance."
  34984. }
  34985. }
  34986. }
  34987. }
  34988. },
  34989. {
  34990. name = "getResponseTime",
  34991. summary = "Get the response time of the joint.",
  34992. description = "Returns the response time of the joint. See `World:setResponseTime` for more info.",
  34993. key = "DistanceJoint:getResponseTime",
  34994. module = "lovr.physics",
  34995. related = {
  34996. "BallJoint:getResponseTime",
  34997. "BallJoint:setResponseTime",
  34998. "World:getResponseTime",
  34999. "World:setResponseTime"
  35000. },
  35001. variants = {
  35002. {
  35003. arguments = {},
  35004. returns = {
  35005. {
  35006. name = "responseTime",
  35007. type = "number",
  35008. description = "The response time setting for the joint."
  35009. }
  35010. }
  35011. }
  35012. }
  35013. },
  35014. {
  35015. name = "getTightness",
  35016. summary = "Get the joint tightness.",
  35017. description = "Returns the tightness of the joint. See `World:setTightness` for how this affects the joint.",
  35018. key = "DistanceJoint:getTightness",
  35019. module = "lovr.physics",
  35020. related = {
  35021. "BallJoint:getTightness",
  35022. "BallJoint:setTightness",
  35023. "World:getTightness",
  35024. "World:setTightness"
  35025. },
  35026. variants = {
  35027. {
  35028. arguments = {},
  35029. returns = {
  35030. {
  35031. name = "tightness",
  35032. type = "number",
  35033. description = "The tightness of the joint."
  35034. }
  35035. }
  35036. }
  35037. }
  35038. },
  35039. {
  35040. name = "setAnchors",
  35041. summary = "Set the anchor points of the DistanceJoint.",
  35042. description = "Sets the anchor points of the DistanceJoint.",
  35043. key = "DistanceJoint:setAnchors",
  35044. module = "lovr.physics",
  35045. variants = {
  35046. {
  35047. description = "Sets the anchor points using numbers.",
  35048. arguments = {
  35049. {
  35050. name = "x1",
  35051. type = "number",
  35052. description = "The x coordinate of the first anchor point, in world coordinates."
  35053. },
  35054. {
  35055. name = "y1",
  35056. type = "number",
  35057. description = "The y coordinate of the first anchor point, in world coordinates."
  35058. },
  35059. {
  35060. name = "z1",
  35061. type = "number",
  35062. description = "The z coordinate of the first anchor point, in world coordinates."
  35063. },
  35064. {
  35065. name = "x2",
  35066. type = "number",
  35067. description = "The x coordinate of the second anchor point, in world coordinates."
  35068. },
  35069. {
  35070. name = "y2",
  35071. type = "number",
  35072. description = "The y coordinate of the second anchor point, in world coordinates."
  35073. },
  35074. {
  35075. name = "z2",
  35076. type = "number",
  35077. description = "The z coordinate of the second anchor point, in world coordinates."
  35078. }
  35079. },
  35080. returns = {}
  35081. },
  35082. {
  35083. description = "Sets the anchor points using vectors.",
  35084. arguments = {
  35085. {
  35086. name = "first",
  35087. type = "Vec3",
  35088. description = "The first anchor point, in world coordinates."
  35089. },
  35090. {
  35091. name = "second",
  35092. type = "Vec3",
  35093. description = "The second anchor point, in world coordinates."
  35094. }
  35095. },
  35096. returns = {}
  35097. }
  35098. }
  35099. },
  35100. {
  35101. name = "setDistance",
  35102. summary = "Set the target distance of the DistanceJoint.",
  35103. description = "Sets the target distance for the DistanceJoint. The joint tries to keep the Colliders this far apart.",
  35104. key = "DistanceJoint:setDistance",
  35105. module = "lovr.physics",
  35106. variants = {
  35107. {
  35108. arguments = {
  35109. {
  35110. name = "distance",
  35111. type = "number",
  35112. description = "The new target distance."
  35113. }
  35114. },
  35115. returns = {}
  35116. }
  35117. }
  35118. },
  35119. {
  35120. name = "setResponseTime",
  35121. summary = "Set the response time of the joint.",
  35122. description = "Sets the response time of the joint. See `World:setResponseTime` for more info.",
  35123. key = "DistanceJoint:setResponseTime",
  35124. module = "lovr.physics",
  35125. related = {
  35126. "BallJoint:getResponseTime",
  35127. "BallJoint:setResponseTime",
  35128. "World:getResponseTime",
  35129. "World:setResponseTime"
  35130. },
  35131. variants = {
  35132. {
  35133. arguments = {
  35134. {
  35135. name = "responseTime",
  35136. type = "number",
  35137. description = "The new response time setting for the joint."
  35138. }
  35139. },
  35140. returns = {}
  35141. }
  35142. }
  35143. },
  35144. {
  35145. name = "setTightness",
  35146. summary = "Set the joint tightness.",
  35147. description = "Sets the tightness of the joint. See `World:setTightness` for how this affects the joint.",
  35148. key = "DistanceJoint:setTightness",
  35149. module = "lovr.physics",
  35150. related = {
  35151. "BallJoint:getTightness",
  35152. "BallJoint:setTightness",
  35153. "World:getTightness",
  35154. "World:setTightness"
  35155. },
  35156. variants = {
  35157. {
  35158. arguments = {
  35159. {
  35160. name = "tightness",
  35161. type = "number",
  35162. description = "The tightness of the joint."
  35163. }
  35164. },
  35165. returns = {}
  35166. }
  35167. }
  35168. }
  35169. },
  35170. related = {
  35171. "Collider"
  35172. }
  35173. },
  35174. {
  35175. name = "HingeJoint",
  35176. summary = "A hinge joint.",
  35177. description = "A HingeJoint is a type of `Joint` that only allows colliders to rotate on a single axis.",
  35178. key = "HingeJoint",
  35179. module = "lovr.physics",
  35180. constructors = {
  35181. "lovr.physics.newHingeJoint"
  35182. },
  35183. extends = "Joint",
  35184. methods = {
  35185. {
  35186. name = "getAnchors",
  35187. summary = "Get the anchor points of the HingeJoint.",
  35188. description = "Returns the anchor points of the HingeJoint.",
  35189. key = "HingeJoint:getAnchors",
  35190. module = "lovr.physics",
  35191. variants = {
  35192. {
  35193. arguments = {},
  35194. returns = {
  35195. {
  35196. name = "x1",
  35197. type = "number",
  35198. description = "The x coordinate of the first anchor point, in world coordinates."
  35199. },
  35200. {
  35201. name = "y1",
  35202. type = "number",
  35203. description = "The y coordinate of the first anchor point, in world coordinates."
  35204. },
  35205. {
  35206. name = "z1",
  35207. type = "number",
  35208. description = "The z coordinate of the first anchor point, in world coordinates."
  35209. },
  35210. {
  35211. name = "x2",
  35212. type = "number",
  35213. description = "The x coordinate of the second anchor point, in world coordinates."
  35214. },
  35215. {
  35216. name = "y2",
  35217. type = "number",
  35218. description = "The y coordinate of the second anchor point, in world coordinates."
  35219. },
  35220. {
  35221. name = "z2",
  35222. type = "number",
  35223. description = "The z coordinate of the second anchor point, in world coordinates."
  35224. }
  35225. }
  35226. }
  35227. }
  35228. },
  35229. {
  35230. name = "getAngle",
  35231. summary = "Get the angle of the HingeJoint.",
  35232. description = "Get the angle between the two colliders attached to the HingeJoint. When the joint is created or when the anchor or axis is set, the current angle is the new \"zero\" angle.",
  35233. key = "HingeJoint:getAngle",
  35234. module = "lovr.physics",
  35235. variants = {
  35236. {
  35237. arguments = {},
  35238. returns = {
  35239. {
  35240. name = "angle",
  35241. type = "number",
  35242. description = "The hinge angle, in radians."
  35243. }
  35244. }
  35245. }
  35246. }
  35247. },
  35248. {
  35249. name = "getAxis",
  35250. summary = "Get the HingeJoint's axis.",
  35251. description = "Returns the axis of the hinge.",
  35252. key = "HingeJoint:getAxis",
  35253. module = "lovr.physics",
  35254. variants = {
  35255. {
  35256. arguments = {},
  35257. returns = {
  35258. {
  35259. name = "x",
  35260. type = "number",
  35261. description = "The x component of the axis."
  35262. },
  35263. {
  35264. name = "y",
  35265. type = "number",
  35266. description = "The y component of the axis."
  35267. },
  35268. {
  35269. name = "z",
  35270. type = "number",
  35271. description = "The z component of the axis."
  35272. }
  35273. }
  35274. }
  35275. }
  35276. },
  35277. {
  35278. name = "getLimits",
  35279. summary = "Get the HingeJoint's angle limits.",
  35280. description = "Returns the upper and lower limits of the hinge angle. These will be between -π and π.",
  35281. key = "HingeJoint:getLimits",
  35282. module = "lovr.physics",
  35283. related = {
  35284. "HingeJoint:getAngle",
  35285. "HingeJoint:getLowerLimit",
  35286. "HingeJoint:setLowerLimit",
  35287. "HingeJoint:getUpperLimit",
  35288. "HingeJoint:setUpperLimit"
  35289. },
  35290. variants = {
  35291. {
  35292. arguments = {},
  35293. returns = {
  35294. {
  35295. name = "lower",
  35296. type = "number",
  35297. description = "The lower limit, in radians."
  35298. },
  35299. {
  35300. name = "upper",
  35301. type = "number",
  35302. description = "The upper limit, in radians."
  35303. }
  35304. }
  35305. }
  35306. }
  35307. },
  35308. {
  35309. name = "getLowerLimit",
  35310. summary = "Get the HingeJoint's lower angle limit.",
  35311. description = "Returns the lower limit of the hinge angle. This will be greater than -π.",
  35312. key = "HingeJoint:getLowerLimit",
  35313. module = "lovr.physics",
  35314. related = {
  35315. "HingeJoint:getAngle",
  35316. "HingeJoint:getUpperLimit",
  35317. "HingeJoint:setUpperLimit",
  35318. "HingeJoint:getLimits",
  35319. "HingeJoint:setLimits"
  35320. },
  35321. variants = {
  35322. {
  35323. arguments = {},
  35324. returns = {
  35325. {
  35326. name = "limit",
  35327. type = "number",
  35328. description = "The lower limit, in radians."
  35329. }
  35330. }
  35331. }
  35332. }
  35333. },
  35334. {
  35335. name = "getUpperLimit",
  35336. summary = "Get the HingeJoint's upper angle limit.",
  35337. description = "Returns the upper limit of the hinge angle. This will be less than π.",
  35338. key = "HingeJoint:getUpperLimit",
  35339. module = "lovr.physics",
  35340. related = {
  35341. "HingeJoint:getAngle",
  35342. "HingeJoint:getLowerLimit",
  35343. "HingeJoint:setLowerLimit",
  35344. "HingeJoint:getLimits",
  35345. "HingeJoint:setLimits"
  35346. },
  35347. variants = {
  35348. {
  35349. arguments = {},
  35350. returns = {
  35351. {
  35352. name = "limit",
  35353. type = "number",
  35354. description = "The upper limit, in radians."
  35355. }
  35356. }
  35357. }
  35358. }
  35359. },
  35360. {
  35361. name = "setAnchor",
  35362. summary = "Set the anchor point of the HingeJoint.",
  35363. description = "Sets a new anchor point for the HingeJoint.",
  35364. key = "HingeJoint:setAnchor",
  35365. module = "lovr.physics",
  35366. variants = {
  35367. {
  35368. description = "Sets the anchor point using numbers.",
  35369. arguments = {
  35370. {
  35371. name = "x",
  35372. type = "number",
  35373. description = "The x coordinate of the anchor point, in world coordinates."
  35374. },
  35375. {
  35376. name = "y",
  35377. type = "number",
  35378. description = "The y coordinate of the anchor point, in world coordinates."
  35379. },
  35380. {
  35381. name = "z",
  35382. type = "number",
  35383. description = "The z coordinate of the anchor point, in world coordinates."
  35384. }
  35385. },
  35386. returns = {}
  35387. },
  35388. {
  35389. description = "Sets the anchor point using a vector.",
  35390. arguments = {
  35391. {
  35392. name = "anchor",
  35393. type = "Vec3",
  35394. description = "The anchor point, in world coordinates."
  35395. }
  35396. },
  35397. returns = {}
  35398. }
  35399. }
  35400. },
  35401. {
  35402. name = "setAxis",
  35403. summary = "Set the HingeJoint's axis.",
  35404. description = "Sets the axis of the hinge.",
  35405. key = "HingeJoint:setAxis",
  35406. module = "lovr.physics",
  35407. variants = {
  35408. {
  35409. description = "Set the axis using numbers.",
  35410. arguments = {
  35411. {
  35412. name = "x",
  35413. type = "number",
  35414. description = "The x component of the axis."
  35415. },
  35416. {
  35417. name = "y",
  35418. type = "number",
  35419. description = "The y component of the axis."
  35420. },
  35421. {
  35422. name = "z",
  35423. type = "number",
  35424. description = "The z component of the axis."
  35425. }
  35426. },
  35427. returns = {}
  35428. },
  35429. {
  35430. description = "Set the axis using a vector.",
  35431. arguments = {
  35432. {
  35433. name = "axis",
  35434. type = "Vec3",
  35435. description = "The axis."
  35436. }
  35437. },
  35438. returns = {}
  35439. }
  35440. }
  35441. },
  35442. {
  35443. name = "setLimits",
  35444. summary = "Set the HingeJoint's angle limits.",
  35445. description = "Sets the upper and lower limits of the hinge angle. These should be between -π and π.",
  35446. key = "HingeJoint:setLimits",
  35447. module = "lovr.physics",
  35448. related = {
  35449. "HingeJoint:getAngle",
  35450. "HingeJoint:getLowerLimit",
  35451. "HingeJoint:setLowerLimit",
  35452. "HingeJoint:getUpperLimit",
  35453. "HingeJoint:setUpperLimit"
  35454. },
  35455. variants = {
  35456. {
  35457. arguments = {
  35458. {
  35459. name = "lower",
  35460. type = "number",
  35461. description = "The lower limit, in radians."
  35462. },
  35463. {
  35464. name = "upper",
  35465. type = "number",
  35466. description = "The upper limit, in radians."
  35467. }
  35468. },
  35469. returns = {}
  35470. }
  35471. }
  35472. },
  35473. {
  35474. name = "setLowerLimit",
  35475. summary = "Set the HingeJoint's lower angle limit.",
  35476. description = "Sets the lower limit of the hinge angle. This should be greater than -π.",
  35477. key = "HingeJoint:setLowerLimit",
  35478. module = "lovr.physics",
  35479. related = {
  35480. "HingeJoint:getAngle",
  35481. "HingeJoint:getUpperLimit",
  35482. "HingeJoint:setUpperLimit",
  35483. "HingeJoint:getLimits",
  35484. "HingeJoint:setLimits"
  35485. },
  35486. variants = {
  35487. {
  35488. arguments = {
  35489. {
  35490. name = "limit",
  35491. type = "number",
  35492. description = "The lower limit, in radians."
  35493. }
  35494. },
  35495. returns = {}
  35496. }
  35497. }
  35498. },
  35499. {
  35500. name = "setUpperLimit",
  35501. summary = "Set the HingeJoint's upper angle limit.",
  35502. description = "Sets the upper limit of the hinge angle. This should be less than π.",
  35503. key = "HingeJoint:setUpperLimit",
  35504. module = "lovr.physics",
  35505. related = {
  35506. "HingeJoint:getAngle",
  35507. "HingeJoint:getLowerLimit",
  35508. "HingeJoint:setLowerLimit",
  35509. "HingeJoint:getLimits",
  35510. "HingeJoint:setLimits"
  35511. },
  35512. variants = {
  35513. {
  35514. arguments = {
  35515. {
  35516. name = "limit",
  35517. type = "number",
  35518. description = "The upper limit, in radians."
  35519. }
  35520. },
  35521. returns = {}
  35522. }
  35523. }
  35524. }
  35525. },
  35526. related = {
  35527. "Collider"
  35528. }
  35529. },
  35530. {
  35531. name = "Joint",
  35532. summary = "Joins two Colliders together.",
  35533. description = "A Joint is a physics object that constrains the movement of two Colliders.",
  35534. key = "Joint",
  35535. module = "lovr.physics",
  35536. constructors = {
  35537. "lovr.physics.newBallJoint",
  35538. "lovr.physics.newDistanceJoint",
  35539. "lovr.physics.newHingeJoint",
  35540. "lovr.physics.newSliderJoint"
  35541. },
  35542. methods = {
  35543. {
  35544. name = "destroy",
  35545. summary = "Destroy the Joint.",
  35546. description = "Destroy the Joint, removing it from Colliders it's attached to.",
  35547. key = "Joint:destroy",
  35548. module = "lovr.physics",
  35549. notes = "Calling functions on the Joint after destroying it is a bad idea.",
  35550. related = {
  35551. "Collider:destroy",
  35552. "Shape:destroy",
  35553. "World:destroy"
  35554. },
  35555. variants = {
  35556. {
  35557. arguments = {},
  35558. returns = {}
  35559. }
  35560. }
  35561. },
  35562. {
  35563. name = "getColliders",
  35564. summary = "Get the Colliders the Joint is attached to.",
  35565. description = "Returns the Colliders the Joint is attached to. All Joints are attached to two colliders.",
  35566. key = "Joint:getColliders",
  35567. module = "lovr.physics",
  35568. variants = {
  35569. {
  35570. arguments = {},
  35571. returns = {
  35572. {
  35573. name = "colliderA",
  35574. type = "Collider",
  35575. description = "The first Collider."
  35576. },
  35577. {
  35578. name = "colliderB",
  35579. type = "Collider",
  35580. description = "The second Collider."
  35581. }
  35582. }
  35583. }
  35584. }
  35585. },
  35586. {
  35587. name = "getType",
  35588. summary = "Get the type of the Joint.",
  35589. description = "Returns the type of the Joint.",
  35590. key = "Joint:getType",
  35591. module = "lovr.physics",
  35592. related = {
  35593. "JointType"
  35594. },
  35595. variants = {
  35596. {
  35597. arguments = {},
  35598. returns = {
  35599. {
  35600. name = "type",
  35601. type = "JointType",
  35602. description = "The type of the Joint."
  35603. }
  35604. }
  35605. }
  35606. }
  35607. },
  35608. {
  35609. name = "getUserData",
  35610. summary = "Get the Joint's user data.",
  35611. description = "Returns the user data associated with the Joint.",
  35612. key = "Joint:getUserData",
  35613. module = "lovr.physics",
  35614. variants = {
  35615. {
  35616. arguments = {},
  35617. returns = {
  35618. {
  35619. name = "data",
  35620. type = "*",
  35621. description = "The custom value associated with the Joint."
  35622. }
  35623. }
  35624. }
  35625. }
  35626. },
  35627. {
  35628. name = "isEnabled",
  35629. summary = "Check if the Joint is enabled.",
  35630. description = "Returns whether the Joint is enabled.",
  35631. key = "Joint:isEnabled",
  35632. module = "lovr.physics",
  35633. variants = {
  35634. {
  35635. arguments = {},
  35636. returns = {
  35637. {
  35638. name = "enabled",
  35639. type = "boolean",
  35640. description = "Whether the Joint is enabled."
  35641. }
  35642. }
  35643. }
  35644. }
  35645. },
  35646. {
  35647. name = "setEnabled",
  35648. summary = "Enable or disable the Joint.",
  35649. description = "Enable or disable the Joint.",
  35650. key = "Joint:setEnabled",
  35651. module = "lovr.physics",
  35652. variants = {
  35653. {
  35654. arguments = {
  35655. {
  35656. name = "enabled",
  35657. type = "boolean",
  35658. description = "Whether the Joint should be enabled."
  35659. }
  35660. },
  35661. returns = {}
  35662. }
  35663. }
  35664. },
  35665. {
  35666. name = "setUserData",
  35667. summary = "Set the Joint's user data.",
  35668. description = "Sets the user data associated with the Joint.",
  35669. key = "Joint:setUserData",
  35670. module = "lovr.physics",
  35671. variants = {
  35672. {
  35673. arguments = {
  35674. {
  35675. name = "data",
  35676. type = "*",
  35677. description = "The custom value associated with the Joint."
  35678. }
  35679. },
  35680. returns = {}
  35681. }
  35682. }
  35683. }
  35684. },
  35685. related = {
  35686. "Collider"
  35687. }
  35688. },
  35689. {
  35690. name = "MeshShape",
  35691. summary = "A mesh Shape.",
  35692. description = "A type of `Shape` that can be used for triangle meshes.",
  35693. key = "MeshShape",
  35694. module = "lovr.physics",
  35695. constructors = {
  35696. "lovr.physics.newMeshShape",
  35697. "World:newMeshCollider"
  35698. },
  35699. extends = "Shape",
  35700. methods = {}
  35701. },
  35702. {
  35703. name = "Shape",
  35704. summary = "Defines the shape of Colliders.",
  35705. description = "A Shape is a physics object that can be attached to colliders to define their shape.",
  35706. key = "Shape",
  35707. module = "lovr.physics",
  35708. constructors = {
  35709. "lovr.physics.newBoxShape",
  35710. "lovr.physics.newCapsuleShape",
  35711. "lovr.physics.newCylinderShape",
  35712. "lovr.physics.newSphereShape",
  35713. "lovr.physics.newMeshShape",
  35714. "lovr.physics.newTerrainShape",
  35715. "World:newBoxCollider",
  35716. "World:newCapsuleCollider",
  35717. "World:newCylinderCollider",
  35718. "World:newSphereCollider",
  35719. "World:newMeshCollider",
  35720. "World:newTerrainCollider"
  35721. },
  35722. methods = {
  35723. {
  35724. name = "destroy",
  35725. summary = "Destroy the Shape.",
  35726. description = "Destroy the Shape, removing it from Colliders it's attached to.",
  35727. key = "Shape:destroy",
  35728. module = "lovr.physics",
  35729. notes = "Calling functions on the Shape after destroying it is a bad idea.",
  35730. related = {
  35731. "Collider:destroy",
  35732. "Joint:destroy",
  35733. "World:destroy"
  35734. },
  35735. variants = {
  35736. {
  35737. arguments = {},
  35738. returns = {}
  35739. }
  35740. }
  35741. },
  35742. {
  35743. name = "getAABB",
  35744. summary = "Get the Shape's axis aligned bounding box.",
  35745. description = "Returns the bounding box for the Shape.",
  35746. key = "Shape:getAABB",
  35747. module = "lovr.physics",
  35748. related = {
  35749. "Collider:getAABB"
  35750. },
  35751. variants = {
  35752. {
  35753. arguments = {},
  35754. returns = {
  35755. {
  35756. name = "minx",
  35757. type = "number",
  35758. description = "The minimum x coordinate of the box."
  35759. },
  35760. {
  35761. name = "maxx",
  35762. type = "number",
  35763. description = "The maximum x coordinate of the box."
  35764. },
  35765. {
  35766. name = "miny",
  35767. type = "number",
  35768. description = "The minimum y coordinate of the box."
  35769. },
  35770. {
  35771. name = "maxy",
  35772. type = "number",
  35773. description = "The maximum y coordinate of the box."
  35774. },
  35775. {
  35776. name = "minz",
  35777. type = "number",
  35778. description = "The minimum z coordinate of the box."
  35779. },
  35780. {
  35781. name = "maxz",
  35782. type = "number",
  35783. description = "The maximum z coordinate of the box."
  35784. }
  35785. }
  35786. }
  35787. }
  35788. },
  35789. {
  35790. name = "getCollider",
  35791. summary = "Get the Collider the Shape is attached to.",
  35792. description = "Returns the Collider the Shape is attached to.",
  35793. key = "Shape:getCollider",
  35794. module = "lovr.physics",
  35795. notes = "A Shape can only be attached to one Collider at a time.",
  35796. related = {
  35797. "Collider",
  35798. "Collider:addShape",
  35799. "Collider:removeShape"
  35800. },
  35801. variants = {
  35802. {
  35803. arguments = {},
  35804. returns = {
  35805. {
  35806. name = "collider",
  35807. type = "Collider",
  35808. description = "The Collider the Shape is attached to."
  35809. }
  35810. }
  35811. }
  35812. }
  35813. },
  35814. {
  35815. name = "getMass",
  35816. summary = "Compute mass properties of the Shape.",
  35817. description = "Computes mass properties of the Shape.",
  35818. key = "Shape:getMass",
  35819. module = "lovr.physics",
  35820. related = {
  35821. "Collider:getMass",
  35822. "Collider:setMass",
  35823. "Collider:getMassData",
  35824. "Collider:setMassData"
  35825. },
  35826. variants = {
  35827. {
  35828. arguments = {
  35829. {
  35830. name = "density",
  35831. type = "number",
  35832. description = "The density to use, in kilograms per cubic meter."
  35833. }
  35834. },
  35835. returns = {
  35836. {
  35837. name = "cx",
  35838. type = "number",
  35839. description = "The x position of the center of mass."
  35840. },
  35841. {
  35842. name = "cy",
  35843. type = "number",
  35844. description = "The y position of the center of mass."
  35845. },
  35846. {
  35847. name = "cz",
  35848. type = "number",
  35849. description = "The z position of the center of mass."
  35850. },
  35851. {
  35852. name = "mass",
  35853. type = "number",
  35854. description = "The mass of the Shape."
  35855. },
  35856. {
  35857. name = "inertia",
  35858. type = "table",
  35859. description = "A table containing 6 values of the rotational inertia tensor matrix. The table contains the 3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements of the upper right portion of the 3x3 matrix."
  35860. }
  35861. }
  35862. }
  35863. }
  35864. },
  35865. {
  35866. name = "getOrientation",
  35867. summary = "Get the Shape's orientation.",
  35868. description = "Get the orientation of the Shape relative to its Collider.",
  35869. key = "Shape:getOrientation",
  35870. module = "lovr.physics",
  35871. related = {
  35872. "Shape:getPosition",
  35873. "Shape:setPosition",
  35874. "Shape:getPose",
  35875. "Shape:setPose"
  35876. },
  35877. variants = {
  35878. {
  35879. arguments = {},
  35880. returns = {
  35881. {
  35882. name = "angle",
  35883. type = "number",
  35884. description = "The number of radians the Shape is rotated."
  35885. },
  35886. {
  35887. name = "ax",
  35888. type = "number",
  35889. description = "The x component of the rotation axis."
  35890. },
  35891. {
  35892. name = "ay",
  35893. type = "number",
  35894. description = "The y component of the rotation axis."
  35895. },
  35896. {
  35897. name = "az",
  35898. type = "number",
  35899. description = "The z component of the rotation axis."
  35900. }
  35901. }
  35902. }
  35903. }
  35904. },
  35905. {
  35906. name = "getPose",
  35907. summary = "Get the pose of the Shape.",
  35908. description = "Returns the position and orientation of the Shape, relative to its Collider.",
  35909. key = "Shape:getPose",
  35910. module = "lovr.physics",
  35911. related = {
  35912. "Shape:getPosition",
  35913. "Shape:setPosition",
  35914. "Shape:getOrientation",
  35915. "Shape:setOrientation"
  35916. },
  35917. variants = {
  35918. {
  35919. arguments = {},
  35920. returns = {
  35921. {
  35922. name = "x",
  35923. type = "number",
  35924. description = "The x position of the Shape, in meters."
  35925. },
  35926. {
  35927. name = "y",
  35928. type = "number",
  35929. description = "The y position of the Shape, in meters."
  35930. },
  35931. {
  35932. name = "z",
  35933. type = "number",
  35934. description = "The z position of the Shape, in meters."
  35935. },
  35936. {
  35937. name = "angle",
  35938. type = "number",
  35939. description = "The number of radians the Shape is rotated around its axis of rotation."
  35940. },
  35941. {
  35942. name = "ax",
  35943. type = "number",
  35944. description = "The x component of the axis of rotation."
  35945. },
  35946. {
  35947. name = "ay",
  35948. type = "number",
  35949. description = "The y component of the axis of rotation."
  35950. },
  35951. {
  35952. name = "az",
  35953. type = "number",
  35954. description = "The z component of the axis of rotation."
  35955. }
  35956. }
  35957. }
  35958. }
  35959. },
  35960. {
  35961. name = "getPosition",
  35962. summary = "Get the Shape's position.",
  35963. description = "Get the position of the Shape relative to its Collider.",
  35964. key = "Shape:getPosition",
  35965. module = "lovr.physics",
  35966. related = {
  35967. "Shape:getOrientation",
  35968. "Shape:setOrientation",
  35969. "Shape:getPose",
  35970. "Shape:setPose"
  35971. },
  35972. variants = {
  35973. {
  35974. arguments = {},
  35975. returns = {
  35976. {
  35977. name = "x",
  35978. type = "number",
  35979. description = "The x offset."
  35980. },
  35981. {
  35982. name = "y",
  35983. type = "number",
  35984. description = "The y offset."
  35985. },
  35986. {
  35987. name = "z",
  35988. type = "number",
  35989. description = "The z offset."
  35990. }
  35991. }
  35992. }
  35993. }
  35994. },
  35995. {
  35996. name = "getType",
  35997. summary = "Get the type of the Shape.",
  35998. description = "Returns the type of the Shape.",
  35999. key = "Shape:getType",
  36000. module = "lovr.physics",
  36001. related = {
  36002. "ShapeType"
  36003. },
  36004. variants = {
  36005. {
  36006. arguments = {},
  36007. returns = {
  36008. {
  36009. name = "type",
  36010. type = "ShapeType",
  36011. description = "The type of the Shape."
  36012. }
  36013. }
  36014. }
  36015. }
  36016. },
  36017. {
  36018. name = "getUserData",
  36019. summary = "Get the Shape's user data.",
  36020. description = "Returns the user data associated with the Shape.",
  36021. key = "Shape:getUserData",
  36022. module = "lovr.physics",
  36023. notes = "User data can be useful to identify the Shape in callbacks.",
  36024. variants = {
  36025. {
  36026. arguments = {},
  36027. returns = {
  36028. {
  36029. name = "data",
  36030. type = "*",
  36031. description = "The custom value associated with the Shape."
  36032. }
  36033. }
  36034. }
  36035. }
  36036. },
  36037. {
  36038. name = "isEnabled",
  36039. summary = "Check if the Shape is enabled.",
  36040. description = "Returns whether the Shape is enabled.",
  36041. key = "Shape:isEnabled",
  36042. module = "lovr.physics",
  36043. notes = "Disabled shapes won't collide with anything.",
  36044. variants = {
  36045. {
  36046. arguments = {},
  36047. returns = {
  36048. {
  36049. name = "enabled",
  36050. type = "boolean",
  36051. description = "Whether the Shape is enabled."
  36052. }
  36053. }
  36054. }
  36055. }
  36056. },
  36057. {
  36058. name = "isSensor",
  36059. summary = "Check if the Shape is a sensor.",
  36060. description = "Returns whether the Shape is a sensor. Sensors do not trigger any collision response, but they still report collisions in `World:collide`.",
  36061. key = "Shape:isSensor",
  36062. module = "lovr.physics",
  36063. variants = {
  36064. {
  36065. arguments = {},
  36066. returns = {
  36067. {
  36068. name = "sensor",
  36069. type = "boolean",
  36070. description = "Whether the Shape is a sensor."
  36071. }
  36072. }
  36073. }
  36074. }
  36075. },
  36076. {
  36077. name = "setEnabled",
  36078. summary = "Enable or disable the Shape.",
  36079. description = "Enable or disable the Shape.",
  36080. key = "Shape:setEnabled",
  36081. module = "lovr.physics",
  36082. notes = "Disabled shapes won't collide with anything.",
  36083. variants = {
  36084. {
  36085. arguments = {
  36086. {
  36087. name = "enabled",
  36088. type = "boolean",
  36089. description = "Whether the Shape should be enabled."
  36090. }
  36091. },
  36092. returns = {}
  36093. }
  36094. }
  36095. },
  36096. {
  36097. name = "setOrientation",
  36098. summary = "Set the Shape's orientation.",
  36099. description = "Set the orientation of the Shape relative to its Collider.",
  36100. key = "Shape:setOrientation",
  36101. module = "lovr.physics",
  36102. notes = "If the Shape isn't attached to a Collider, this will error.",
  36103. related = {
  36104. "Shape:getPosition",
  36105. "Shape:setPosition"
  36106. },
  36107. variants = {
  36108. {
  36109. description = "Set the orientation of the Shape using numbers.",
  36110. arguments = {
  36111. {
  36112. name = "angle",
  36113. type = "number",
  36114. description = "The number of radians the Shape is rotated."
  36115. },
  36116. {
  36117. name = "ax",
  36118. type = "number",
  36119. description = "The x component of the rotation axis."
  36120. },
  36121. {
  36122. name = "ay",
  36123. type = "number",
  36124. description = "The y component of the rotation axis."
  36125. },
  36126. {
  36127. name = "az",
  36128. type = "number",
  36129. description = "The z component of the rotation axis."
  36130. }
  36131. },
  36132. returns = {}
  36133. },
  36134. {
  36135. description = "Set the orientation of the Shape using a quaternion.",
  36136. arguments = {
  36137. {
  36138. name = "orientation",
  36139. type = "Quat",
  36140. description = "The orientation of the Shape."
  36141. }
  36142. },
  36143. returns = {}
  36144. }
  36145. }
  36146. },
  36147. {
  36148. name = "setPose",
  36149. summary = "Set the pose of the Shape.",
  36150. description = "Sets the position and orientation of the Shape, relative to its Collider.",
  36151. key = "Shape:setPose",
  36152. module = "lovr.physics",
  36153. notes = "If the Shape isn't attached to a Collider, this will error.",
  36154. related = {
  36155. "Shape:getPosition",
  36156. "Shape:setPosition",
  36157. "Shape:getOrientation",
  36158. "Shape:setOrientation"
  36159. },
  36160. variants = {
  36161. {
  36162. description = "Set the pose of the Shape using numbers.",
  36163. arguments = {
  36164. {
  36165. name = "x",
  36166. type = "number",
  36167. description = "The x position of the Shape, in meters."
  36168. },
  36169. {
  36170. name = "y",
  36171. type = "number",
  36172. description = "The y position of the Shape, in meters."
  36173. },
  36174. {
  36175. name = "z",
  36176. type = "number",
  36177. description = "The z position of the Shape, in meters."
  36178. },
  36179. {
  36180. name = "angle",
  36181. type = "number",
  36182. description = "The number of radians the Shape is rotated around its axis of rotation."
  36183. },
  36184. {
  36185. name = "ax",
  36186. type = "number",
  36187. description = "The x component of the axis of rotation."
  36188. },
  36189. {
  36190. name = "ay",
  36191. type = "number",
  36192. description = "The y component of the axis of rotation."
  36193. },
  36194. {
  36195. name = "az",
  36196. type = "number",
  36197. description = "The z component of the axis of rotation."
  36198. }
  36199. },
  36200. returns = {}
  36201. },
  36202. {
  36203. description = "Set the pose of the Shape using vector types.",
  36204. arguments = {
  36205. {
  36206. name = "position",
  36207. type = "Vec3",
  36208. description = "The position of the Shape, in meters."
  36209. },
  36210. {
  36211. name = "orientation",
  36212. type = "Quat",
  36213. description = "The orientation of the Shape."
  36214. }
  36215. },
  36216. returns = {}
  36217. }
  36218. }
  36219. },
  36220. {
  36221. name = "setPosition",
  36222. summary = "Set the Shape's position.",
  36223. description = "Set the position of the Shape relative to its Collider.",
  36224. key = "Shape:setPosition",
  36225. module = "lovr.physics",
  36226. notes = "If the Shape isn't attached to a Collider, this will error.",
  36227. related = {
  36228. "Shape:getOrientation",
  36229. "Shape:setOrientation"
  36230. },
  36231. variants = {
  36232. {
  36233. description = "Set the position of the Shape using numbers.",
  36234. arguments = {
  36235. {
  36236. name = "x",
  36237. type = "number",
  36238. description = "The x offset."
  36239. },
  36240. {
  36241. name = "y",
  36242. type = "number",
  36243. description = "The y offset."
  36244. },
  36245. {
  36246. name = "z",
  36247. type = "number",
  36248. description = "The z offset."
  36249. }
  36250. },
  36251. returns = {}
  36252. },
  36253. {
  36254. description = "Set the position of the Shape using a vector.",
  36255. arguments = {
  36256. {
  36257. name = "position",
  36258. type = "Vec3",
  36259. description = "The position."
  36260. }
  36261. },
  36262. returns = {}
  36263. }
  36264. }
  36265. },
  36266. {
  36267. name = "setSensor",
  36268. summary = "Set the sensor status for the Shape.",
  36269. description = "Sets whether this Shape is a sensor. When a Shape is a sensor, it will not generate any collision response when it collides with things, but collisions can still be detected with `World:collide` and `World:getContacts`.",
  36270. key = "Shape:setSensor",
  36271. module = "lovr.physics",
  36272. variants = {
  36273. {
  36274. arguments = {
  36275. {
  36276. name = "sensor",
  36277. type = "boolean",
  36278. description = "Whether the Shape should be a sensor."
  36279. }
  36280. },
  36281. returns = {}
  36282. }
  36283. }
  36284. },
  36285. {
  36286. name = "setUserData",
  36287. summary = "Set the Shape's user data.",
  36288. description = "Sets the user data associated with the Shape.",
  36289. key = "Shape:setUserData",
  36290. module = "lovr.physics",
  36291. notes = "User data can be useful to identify the Shape in callbacks.",
  36292. variants = {
  36293. {
  36294. arguments = {
  36295. {
  36296. name = "data",
  36297. type = "*",
  36298. description = "The custom value associated with the Shape."
  36299. }
  36300. },
  36301. returns = {}
  36302. }
  36303. }
  36304. }
  36305. }
  36306. },
  36307. {
  36308. name = "SliderJoint",
  36309. summary = "A slider joint.",
  36310. description = "A SliderJoint is a type of `Joint` that only allows colliders to move on a single axis.",
  36311. key = "SliderJoint",
  36312. module = "lovr.physics",
  36313. constructors = {
  36314. "lovr.physics.newSliderJoint"
  36315. },
  36316. extends = "Joint",
  36317. methods = {
  36318. {
  36319. name = "getAxis",
  36320. summary = "Get the SliderJoint's axis.",
  36321. description = "Returns the axis of the slider.",
  36322. key = "SliderJoint:getAxis",
  36323. module = "lovr.physics",
  36324. variants = {
  36325. {
  36326. arguments = {},
  36327. returns = {
  36328. {
  36329. name = "x",
  36330. type = "number",
  36331. description = "The x component of the axis."
  36332. },
  36333. {
  36334. name = "y",
  36335. type = "number",
  36336. description = "The y component of the axis."
  36337. },
  36338. {
  36339. name = "z",
  36340. type = "number",
  36341. description = "The z component of the axis."
  36342. }
  36343. }
  36344. }
  36345. }
  36346. },
  36347. {
  36348. name = "getLimits",
  36349. summary = "Get the SliderJoint's limits.",
  36350. description = "Returns the upper and lower limits of the slider position.",
  36351. key = "SliderJoint:getLimits",
  36352. module = "lovr.physics",
  36353. related = {
  36354. "SliderJoint:getPosition",
  36355. "SliderJoint:getLowerLimit",
  36356. "SliderJoint:setLowerLimit",
  36357. "SliderJoint:getUpperLimit",
  36358. "SliderJoint:setUpperLimit"
  36359. },
  36360. variants = {
  36361. {
  36362. arguments = {},
  36363. returns = {
  36364. {
  36365. name = "lower",
  36366. type = "number",
  36367. description = "The lower limit."
  36368. },
  36369. {
  36370. name = "upper",
  36371. type = "number",
  36372. description = "The upper limit."
  36373. }
  36374. }
  36375. }
  36376. }
  36377. },
  36378. {
  36379. name = "getLowerLimit",
  36380. summary = "Get the SliderJoint's lower limit.",
  36381. description = "Returns the lower limit of the slider position.",
  36382. key = "SliderJoint:getLowerLimit",
  36383. module = "lovr.physics",
  36384. related = {
  36385. "SliderJoint:getPosition",
  36386. "SliderJoint:getUpperLimit",
  36387. "SliderJoint:setUpperLimit",
  36388. "SliderJoint:getLimits",
  36389. "SliderJoint:setLimits"
  36390. },
  36391. variants = {
  36392. {
  36393. arguments = {},
  36394. returns = {
  36395. {
  36396. name = "limit",
  36397. type = "number",
  36398. description = "The lower limit."
  36399. }
  36400. }
  36401. }
  36402. }
  36403. },
  36404. {
  36405. name = "getPosition",
  36406. summary = "Get how far the SliderJoint is extended.",
  36407. description = "Returns how far the slider joint is extended (zero is the position the slider was created at, positive values are further apart).",
  36408. key = "SliderJoint:getPosition",
  36409. module = "lovr.physics",
  36410. related = {
  36411. "SliderJoint:getAxis",
  36412. "SliderJoint:getLowerLimit",
  36413. "SliderJoint:setLowerLimit",
  36414. "SliderJoint:getUpperLimit",
  36415. "SliderJoint:setUpperLimit"
  36416. },
  36417. variants = {
  36418. {
  36419. arguments = {},
  36420. returns = {
  36421. {
  36422. name = "position",
  36423. type = "number",
  36424. description = "The joint position along its axis."
  36425. }
  36426. }
  36427. }
  36428. }
  36429. },
  36430. {
  36431. name = "getUpperLimit",
  36432. summary = "Get the SliderJoint's upper limit.",
  36433. description = "Returns the upper limit of the slider position.",
  36434. key = "SliderJoint:getUpperLimit",
  36435. module = "lovr.physics",
  36436. related = {
  36437. "SliderJoint:getPosition",
  36438. "SliderJoint:getLowerLimit",
  36439. "SliderJoint:setLowerLimit",
  36440. "SliderJoint:getLimits",
  36441. "SliderJoint:setLimits"
  36442. },
  36443. variants = {
  36444. {
  36445. arguments = {},
  36446. returns = {
  36447. {
  36448. name = "limit",
  36449. type = "number",
  36450. description = "The upper limit."
  36451. }
  36452. }
  36453. }
  36454. }
  36455. },
  36456. {
  36457. name = "setAxis",
  36458. summary = "Set the SliderJoint's axis.",
  36459. description = "Sets the axis of the slider.",
  36460. key = "SliderJoint:setAxis",
  36461. module = "lovr.physics",
  36462. variants = {
  36463. {
  36464. description = "Set the axis using numbers.",
  36465. arguments = {
  36466. {
  36467. name = "x",
  36468. type = "number",
  36469. description = "The x component of the axis."
  36470. },
  36471. {
  36472. name = "y",
  36473. type = "number",
  36474. description = "The y component of the axis."
  36475. },
  36476. {
  36477. name = "z",
  36478. type = "number",
  36479. description = "The z component of the axis."
  36480. }
  36481. },
  36482. returns = {}
  36483. },
  36484. {
  36485. description = "Set the axis using a vector.",
  36486. arguments = {
  36487. {
  36488. name = "axis",
  36489. type = "Vec3",
  36490. description = "The axis."
  36491. }
  36492. },
  36493. returns = {}
  36494. }
  36495. }
  36496. },
  36497. {
  36498. name = "setLimits",
  36499. summary = "Set the SliderJoint's limits.",
  36500. description = "Sets the upper and lower limits of the slider position.",
  36501. key = "SliderJoint:setLimits",
  36502. module = "lovr.physics",
  36503. related = {
  36504. "SliderJoint:getPosition",
  36505. "SliderJoint:getLowerLimit",
  36506. "SliderJoint:setLowerLimit",
  36507. "SliderJoint:getUpperLimit",
  36508. "SliderJoint:setUpperLimit"
  36509. },
  36510. variants = {
  36511. {
  36512. arguments = {
  36513. {
  36514. name = "lower",
  36515. type = "number",
  36516. description = "The lower limit."
  36517. },
  36518. {
  36519. name = "upper",
  36520. type = "number",
  36521. description = "The upper limit."
  36522. }
  36523. },
  36524. returns = {}
  36525. }
  36526. }
  36527. },
  36528. {
  36529. name = "setLowerLimit",
  36530. summary = "Set the SliderJoint's lower limit.",
  36531. description = "Sets the lower limit of the slider position.",
  36532. key = "SliderJoint:setLowerLimit",
  36533. module = "lovr.physics",
  36534. related = {
  36535. "SliderJoint:getPosition",
  36536. "SliderJoint:getUpperLimit",
  36537. "SliderJoint:setUpperLimit",
  36538. "SliderJoint:getLimits",
  36539. "SliderJoint:setLimits"
  36540. },
  36541. variants = {
  36542. {
  36543. arguments = {
  36544. {
  36545. name = "limit",
  36546. type = "number",
  36547. description = "The lower limit."
  36548. }
  36549. },
  36550. returns = {}
  36551. }
  36552. }
  36553. },
  36554. {
  36555. name = "setUpperLimit",
  36556. summary = "Set the SliderJoint's upper limit.",
  36557. description = "Sets the upper limit of the slider position.",
  36558. key = "SliderJoint:setUpperLimit",
  36559. module = "lovr.physics",
  36560. related = {
  36561. "SliderJoint:getPosition",
  36562. "SliderJoint:getLowerLimit",
  36563. "SliderJoint:setLowerLimit",
  36564. "SliderJoint:getLimits",
  36565. "SliderJoint:setLimits"
  36566. },
  36567. variants = {
  36568. {
  36569. arguments = {
  36570. {
  36571. name = "limit",
  36572. type = "number",
  36573. description = "The upper limit."
  36574. }
  36575. },
  36576. returns = {}
  36577. }
  36578. }
  36579. }
  36580. },
  36581. related = {
  36582. "Collider"
  36583. }
  36584. },
  36585. {
  36586. name = "SphereShape",
  36587. summary = "A sphere Shape.",
  36588. description = "A type of `Shape` that can be used for spheres.",
  36589. key = "SphereShape",
  36590. module = "lovr.physics",
  36591. constructors = {
  36592. "lovr.physics.newSphereShape",
  36593. "World:newSphereCollider"
  36594. },
  36595. extends = "Shape",
  36596. methods = {
  36597. {
  36598. name = "getRadius",
  36599. summary = "Get the radius of the SphereShape.",
  36600. description = "Returns the radius of the SphereShape.",
  36601. key = "SphereShape:getRadius",
  36602. module = "lovr.physics",
  36603. variants = {
  36604. {
  36605. arguments = {},
  36606. returns = {
  36607. {
  36608. name = "radius",
  36609. type = "number",
  36610. description = "The radius of the sphere, in meters."
  36611. }
  36612. }
  36613. }
  36614. }
  36615. },
  36616. {
  36617. name = "setRadius",
  36618. summary = "Set the radius of the SphereShape.",
  36619. description = "Sets the radius of the SphereShape.",
  36620. key = "SphereShape:setRadius",
  36621. module = "lovr.physics",
  36622. variants = {
  36623. {
  36624. arguments = {
  36625. {
  36626. name = "radius",
  36627. type = "number",
  36628. description = "The radius of the sphere, in meters."
  36629. }
  36630. },
  36631. returns = {}
  36632. }
  36633. }
  36634. }
  36635. }
  36636. },
  36637. {
  36638. name = "TerrainShape",
  36639. summary = "A terrain Shape.",
  36640. description = "A type of `Shape` that can be used for terrains and irregular surfaces.",
  36641. key = "TerrainShape",
  36642. module = "lovr.physics",
  36643. constructors = {
  36644. "lovr.physics.newTerrainShape",
  36645. "World:newTerrainCollider"
  36646. },
  36647. extends = "Shape",
  36648. methods = {}
  36649. },
  36650. {
  36651. name = "World",
  36652. summary = "An independent physics simulation.",
  36653. description = "A World is an object that holds the colliders, joints, and shapes in a physics simulation.",
  36654. key = "World",
  36655. module = "lovr.physics",
  36656. constructors = {
  36657. "lovr.physics.newWorld"
  36658. },
  36659. methods = {
  36660. {
  36661. name = "collide",
  36662. tag = "worldCollision",
  36663. summary = "Attempt to collide two shapes.",
  36664. description = "Attempt to collide two shapes. Internally this sets up constraint forces to move the shapes' colliders apart if they are touching. The colliders won't actually move until `World:update` is called again to advance the physics simulation.\n\nCollision responses can be customized using friction and restitution (bounciness) parameters, and default to using a mix between the parameters of the two colliders.\n\nUsually this is called internally by `World:update`, or in a custom collision resolver passed to `World:update`.\n\nIf you want to detect if objects are touching without colliding them, use `World:getContacts` or make one or both of the shapes sensors using `Shape:setSensor`.",
  36665. key = "World:collide",
  36666. module = "lovr.physics",
  36667. notes = "For friction, numbers in the range of 0-1 are common, but larger numbers can also be used.\n\nFor restitution, numbers in the range 0-1 should be used.\n\nThis function respects collision tags, so using `World:disableCollisionBetween` and `World:enableCollisionBetween` will change the behavior of this function.",
  36668. related = {
  36669. "World:computeOverlaps",
  36670. "World:overlaps",
  36671. "World:disableCollisionBetween",
  36672. "World:enableCollisionBetween",
  36673. "World:isCollisionEnabledBetween",
  36674. "Collider:setFriction",
  36675. "Collider:setRestitution"
  36676. },
  36677. variants = {
  36678. {
  36679. arguments = {
  36680. {
  36681. name = "shapeA",
  36682. type = "Shape",
  36683. description = "The first shape."
  36684. },
  36685. {
  36686. name = "shapeB",
  36687. type = "Shape",
  36688. description = "The second shape."
  36689. },
  36690. {
  36691. name = "friction",
  36692. type = "number",
  36693. description = "The friction parameter for the collision.",
  36694. default = "nil"
  36695. },
  36696. {
  36697. name = "restitution",
  36698. type = "number",
  36699. description = "The restitution (bounciness) parameter for the collision.",
  36700. default = "nil"
  36701. }
  36702. },
  36703. returns = {
  36704. {
  36705. name = "collided",
  36706. type = "boolean",
  36707. description = "Whether the shapes collided."
  36708. }
  36709. }
  36710. }
  36711. }
  36712. },
  36713. {
  36714. name = "computeOverlaps",
  36715. tag = "worldCollision",
  36716. summary = "Compute pairs of shapes that are close to each other.",
  36717. description = "Detects which pairs of shapes in the world are near each other and could be colliding. After calling this function, the `World:overlaps` iterator can be used to iterate over the overlaps, and `World:collide` can be used to resolve a collision for the shapes (if any). Usually this is called automatically by `World:update`.",
  36718. key = "World:computeOverlaps",
  36719. module = "lovr.physics",
  36720. examples = {
  36721. {
  36722. code = "world:computeOverlaps()\nfor shapeA, shapeB in world:overlaps() do\n local areColliding = world:collide(shapeA, shapeB)\n print(shapeA, shapeB, areColliding)\nend"
  36723. }
  36724. },
  36725. notes = "This performs the \"broad phase\" culling of objects in the World, usually using a spatial hash or other acceleration structure like a quad tree or octree.",
  36726. related = {
  36727. "World:overlaps",
  36728. "World:collide",
  36729. "World:update"
  36730. },
  36731. variants = {
  36732. {
  36733. arguments = {},
  36734. returns = {}
  36735. }
  36736. }
  36737. },
  36738. {
  36739. name = "destroy",
  36740. tag = "worldBasics",
  36741. summary = "Destroy the World!! Muahaha!",
  36742. description = "Destroy the World!",
  36743. key = "World:destroy",
  36744. module = "lovr.physics",
  36745. notes = "Bad things will happen if you destroy the world and then try to access it or anything that was in it.",
  36746. variants = {
  36747. {
  36748. arguments = {},
  36749. returns = {}
  36750. }
  36751. }
  36752. },
  36753. {
  36754. name = "disableCollisionBetween",
  36755. tag = "worldCollision",
  36756. summary = "Disable collision between two tags.",
  36757. description = "Disables collision between two collision tags.",
  36758. key = "World:disableCollisionBetween",
  36759. module = "lovr.physics",
  36760. notes = "Tags must be set up when creating the World, see `lovr.physics.newWorld`.\n\nBy default, collision is enabled between all tags.",
  36761. related = {
  36762. "lovr.physics.newWorld",
  36763. "World:enableCollisionBetween",
  36764. "World:isCollisionEnabledBetween"
  36765. },
  36766. variants = {
  36767. {
  36768. arguments = {
  36769. {
  36770. name = "tag1",
  36771. type = "string",
  36772. description = "The first tag."
  36773. },
  36774. {
  36775. name = "tag2",
  36776. type = "string",
  36777. description = "The second tag."
  36778. }
  36779. },
  36780. returns = {}
  36781. }
  36782. }
  36783. },
  36784. {
  36785. name = "enableCollisionBetween",
  36786. tag = "worldCollision",
  36787. summary = "Enable collision between two tags.",
  36788. description = "Enables collision between two collision tags.",
  36789. key = "World:enableCollisionBetween",
  36790. module = "lovr.physics",
  36791. notes = "Tags must be set up when creating the World, see `lovr.physics.newWorld`.\n\nBy default, collision is enabled between all tags.",
  36792. related = {
  36793. "lovr.physics.newWorld",
  36794. "World:disableCollisionBetween",
  36795. "World:isCollisionEnabledBetween"
  36796. },
  36797. variants = {
  36798. {
  36799. arguments = {
  36800. {
  36801. name = "tag1",
  36802. type = "string",
  36803. description = "The first tag."
  36804. },
  36805. {
  36806. name = "tag2",
  36807. type = "string",
  36808. description = "The second tag."
  36809. }
  36810. },
  36811. returns = {}
  36812. }
  36813. }
  36814. },
  36815. {
  36816. name = "getAngularDamping",
  36817. tag = "worldProperties",
  36818. summary = "Get the angular damping of the World.",
  36819. description = "Returns the angular damping parameters of the World. Angular damping makes things less \"spinny\", making them slow down their angular velocity over time.",
  36820. key = "World:getAngularDamping",
  36821. module = "lovr.physics",
  36822. notes = "This sets the default damping for newly-created colliders. Damping can also be set on a per-collider basis using `Collider:setAngularDamping`.",
  36823. related = {
  36824. "Collider:getAngularDamping",
  36825. "Collider:setAngularDamping"
  36826. },
  36827. variants = {
  36828. {
  36829. arguments = {},
  36830. returns = {
  36831. {
  36832. name = "damping",
  36833. type = "number",
  36834. description = "The angular damping."
  36835. },
  36836. {
  36837. name = "threshold",
  36838. type = "number",
  36839. description = "Velocity limit below which the damping is not applied."
  36840. }
  36841. }
  36842. }
  36843. }
  36844. },
  36845. {
  36846. name = "getColliders",
  36847. tag = "colliders",
  36848. summary = "Get a table of all Colliders in the World.",
  36849. description = "Returns a table of all Colliders in the World.",
  36850. key = "World:getColliders",
  36851. module = "lovr.physics",
  36852. variants = {
  36853. {
  36854. arguments = {},
  36855. returns = {
  36856. {
  36857. name = "colliders",
  36858. type = "table",
  36859. description = "A table of `Collider` objects."
  36860. }
  36861. }
  36862. },
  36863. {
  36864. arguments = {
  36865. {
  36866. name = "t",
  36867. type = "table",
  36868. description = "A table to fill with Colliders and return."
  36869. }
  36870. },
  36871. returns = {
  36872. {
  36873. name = "colliders",
  36874. type = "table",
  36875. description = "A table of `Collider` objects."
  36876. }
  36877. }
  36878. }
  36879. }
  36880. },
  36881. {
  36882. name = "getContacts",
  36883. tag = "worldCollision",
  36884. summary = "Get a list of points where a pair of shapes touch.",
  36885. description = "Computes collision information between two shapes and returns a list of contacts where the shapes intersect. Each contact point consists of a position, a normal vector, and a penetration depth.",
  36886. key = "World:getContacts",
  36887. module = "lovr.physics",
  36888. notes = "This only detects collision information, it does not cause the shapes to collide with each other. Use `World:collide` for that.\n\nThis function ignores collision tags.",
  36889. related = {
  36890. "World:collide"
  36891. },
  36892. variants = {
  36893. {
  36894. arguments = {
  36895. {
  36896. name = "shapeA",
  36897. type = "Shape",
  36898. description = "The first shape."
  36899. },
  36900. {
  36901. name = "shapeB",
  36902. type = "Shape",
  36903. description = "The second shape."
  36904. }
  36905. },
  36906. returns = {
  36907. {
  36908. name = "contacts",
  36909. type = "table",
  36910. description = "A list of contacts. Each contact consists of 7 numbers: the contact position, the normal vector, and a depth value indicating how far the shapes intersect each other at the contact point (`{ x, y, z, nx, ny, nz, depth }`)."
  36911. }
  36912. }
  36913. }
  36914. }
  36915. },
  36916. {
  36917. name = "getGravity",
  36918. tag = "worldProperties",
  36919. summary = "Get the gravity of the World.",
  36920. description = "Returns the gravity of the World.",
  36921. key = "World:getGravity",
  36922. module = "lovr.physics",
  36923. variants = {
  36924. {
  36925. arguments = {},
  36926. returns = {
  36927. {
  36928. name = "xg",
  36929. type = "number",
  36930. description = "The x component of the gravity force."
  36931. },
  36932. {
  36933. name = "yg",
  36934. type = "number",
  36935. description = "The y component of the gravity force."
  36936. },
  36937. {
  36938. name = "zg",
  36939. type = "number",
  36940. description = "The z component of the gravity force."
  36941. }
  36942. }
  36943. }
  36944. }
  36945. },
  36946. {
  36947. name = "getLinearDamping",
  36948. tag = "worldProperties",
  36949. summary = "Get the linear damping of the World.",
  36950. description = "Returns the linear damping parameters of the World. Linear damping is similar to drag or air resistance, slowing down colliders over time as they move.",
  36951. key = "World:getLinearDamping",
  36952. module = "lovr.physics",
  36953. notes = "A linear damping of 0 means colliders won't slow down over time. This is the default.\n\nThis sets the default damping for newly-created colliders. Damping can also be set on a per-collider basis using `Collider:setLinearDamping`.",
  36954. related = {
  36955. "Collider:getLinearDamping",
  36956. "Collider:setLinearDamping"
  36957. },
  36958. variants = {
  36959. {
  36960. arguments = {},
  36961. returns = {
  36962. {
  36963. name = "damping",
  36964. type = "number",
  36965. description = "The linear damping."
  36966. },
  36967. {
  36968. name = "threshold",
  36969. type = "number",
  36970. description = "Velocity limit below which the damping is not applied."
  36971. }
  36972. }
  36973. }
  36974. }
  36975. },
  36976. {
  36977. name = "getResponseTime",
  36978. tag = "worldProperties",
  36979. summary = "Get the response time of the World.",
  36980. description = "Returns the response time factor of the World.\n\nThe response time controls how relaxed collisions and joints are in the physics simulation, and functions similar to inertia. A low response time means collisions are resolved quickly, and higher values make objects more spongy and soft.\n\nThe value can be any positive number. It can be changed on a per-joint basis for `DistanceJoint` and `BallJoint` objects.",
  36981. key = "World:getResponseTime",
  36982. module = "lovr.physics",
  36983. related = {
  36984. "BallJoint:getResponseTime",
  36985. "BallJoint:setResponseTime",
  36986. "DistanceJoint:getResponseTime",
  36987. "DistanceJoint:setResponseTime",
  36988. "World:getTightness",
  36989. "World:setTightness"
  36990. },
  36991. variants = {
  36992. {
  36993. arguments = {},
  36994. returns = {
  36995. {
  36996. name = "responseTime",
  36997. type = "number",
  36998. description = "The response time setting for the World."
  36999. }
  37000. }
  37001. }
  37002. }
  37003. },
  37004. {
  37005. name = "getStepCount",
  37006. tag = "worldProperties",
  37007. summary = "Get the step count of the World.",
  37008. description = "Returns the step count of the World. The step count influences how many steps are taken during a call to `World:update`. A higher number of steps will be slower, but more accurate. The default step count is 20.",
  37009. key = "World:getStepCount",
  37010. module = "lovr.physics",
  37011. related = {
  37012. "World:update"
  37013. },
  37014. variants = {
  37015. {
  37016. arguments = {},
  37017. returns = {
  37018. {
  37019. name = "steps",
  37020. type = "number",
  37021. description = "The step count."
  37022. }
  37023. }
  37024. }
  37025. }
  37026. },
  37027. {
  37028. name = "getTags",
  37029. tag = "worldCollision",
  37030. summary = "Get the list of tags the World was created with.",
  37031. description = "Returns the list of collision tags used when creating the World.",
  37032. key = "World:getTags",
  37033. module = "lovr.physics",
  37034. related = {
  37035. "lovr.physics.newWorld",
  37036. "World:enableCollisionBetween",
  37037. "World:disableCollisionBetween",
  37038. "World:isCollisionEnabledBetween"
  37039. },
  37040. variants = {
  37041. {
  37042. arguments = {},
  37043. returns = {
  37044. {
  37045. name = "tags",
  37046. type = "table",
  37047. description = "A table of collision tags (strings)."
  37048. }
  37049. }
  37050. }
  37051. }
  37052. },
  37053. {
  37054. name = "getTightness",
  37055. tag = "worldProperties",
  37056. summary = "Get the tightness of joints in the World.",
  37057. description = "Returns the tightness of joints in the World.\n\nThe tightness controls how much force is applied to colliders connected by joints. With a value of 0, no force will be applied and joints won't have any effect. With a tightness of 1, a strong force will be used to try to keep the Colliders constrained. A tightness larger than 1 will overcorrect the joints, which can sometimes be desirable. Negative tightness values are not supported.",
  37058. key = "World:getTightness",
  37059. module = "lovr.physics",
  37060. related = {
  37061. "DistanceJoint:getTightness",
  37062. "DistanceJoint:setTightness"
  37063. },
  37064. variants = {
  37065. {
  37066. arguments = {},
  37067. returns = {
  37068. {
  37069. name = "tightness",
  37070. type = "number",
  37071. description = "The tightness of the World."
  37072. }
  37073. }
  37074. }
  37075. }
  37076. },
  37077. {
  37078. name = "isCollisionEnabledBetween",
  37079. tag = "worldCollision",
  37080. summary = "Check if two tags can collide.",
  37081. description = "Returns whether collisions are currently enabled between two tags.",
  37082. key = "World:isCollisionEnabledBetween",
  37083. module = "lovr.physics",
  37084. notes = "Tags must be set up when creating the World, see `lovr.physics.newWorld`.\n\nBy default, collision is enabled between all tags.",
  37085. related = {
  37086. "lovr.physics.newWorld",
  37087. "World:disableCollisionBetween",
  37088. "World:enableCollisionBetween"
  37089. },
  37090. variants = {
  37091. {
  37092. arguments = {
  37093. {
  37094. name = "tag1",
  37095. type = "string",
  37096. description = "The first tag, or `nil` to use a wildcard.",
  37097. default = "nil"
  37098. },
  37099. {
  37100. name = "tag2",
  37101. type = "string",
  37102. description = "The second tag, or `nil` to use a wildcard.",
  37103. default = "nil"
  37104. }
  37105. },
  37106. returns = {
  37107. {
  37108. name = "enabled",
  37109. type = "boolean",
  37110. description = "Whether or not two colliders with the specified tags will collide."
  37111. }
  37112. }
  37113. }
  37114. }
  37115. },
  37116. {
  37117. name = "isSleepingAllowed",
  37118. tag = "worldProperties",
  37119. summary = "Check if colliders can go to sleep.",
  37120. description = "Returns whether colliders can go to sleep in the World.",
  37121. key = "World:isSleepingAllowed",
  37122. module = "lovr.physics",
  37123. notes = "If sleeping is enabled, the World will try to detect colliders that haven't moved for a while and put them to sleep. Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly.\n\nThis can be set on individual colliders.\n\nColliders can be manually put to sleep or woken up using `Collider:setAwake`.",
  37124. related = {
  37125. "Collider:isSleepingAllowed",
  37126. "Collider:setSleepingAllowed",
  37127. "Collider:isAwake",
  37128. "Collider:setAwake"
  37129. },
  37130. variants = {
  37131. {
  37132. arguments = {},
  37133. returns = {
  37134. {
  37135. name = "allowed",
  37136. type = "boolean",
  37137. description = "Whether colliders can sleep."
  37138. }
  37139. }
  37140. }
  37141. }
  37142. },
  37143. {
  37144. name = "newBoxCollider",
  37145. tag = "colliders",
  37146. summary = "Add a Collider with a BoxShape to the World.",
  37147. description = "Adds a new Collider to the World with a BoxShape already attached.",
  37148. key = "World:newBoxCollider",
  37149. module = "lovr.physics",
  37150. related = {
  37151. "BoxShape",
  37152. "Collider",
  37153. "World:newCollider",
  37154. "World:newCapsuleCollider",
  37155. "World:newCylinderCollider",
  37156. "World:newMeshCollider",
  37157. "World:newSphereCollider",
  37158. "World:newTerrainCollider"
  37159. },
  37160. variants = {
  37161. {
  37162. arguments = {
  37163. {
  37164. name = "x",
  37165. type = "number",
  37166. description = "The x coordinate of the center of the box.",
  37167. default = "0"
  37168. },
  37169. {
  37170. name = "y",
  37171. type = "number",
  37172. description = "The y coordinate of the center of the box.",
  37173. default = "0"
  37174. },
  37175. {
  37176. name = "z",
  37177. type = "number",
  37178. description = "The z coordinate of the center of the box.",
  37179. default = "0"
  37180. },
  37181. {
  37182. name = "width",
  37183. type = "number",
  37184. description = "The total width of the box, in meters.",
  37185. default = "1"
  37186. },
  37187. {
  37188. name = "height",
  37189. type = "number",
  37190. description = "The total height of the box, in meters.",
  37191. default = "width"
  37192. },
  37193. {
  37194. name = "depth",
  37195. type = "number",
  37196. description = "The total depth of the box, in meters.",
  37197. default = "width"
  37198. }
  37199. },
  37200. returns = {
  37201. {
  37202. name = "collider",
  37203. type = "Collider",
  37204. description = "The new Collider."
  37205. }
  37206. }
  37207. },
  37208. {
  37209. arguments = {
  37210. {
  37211. name = "position",
  37212. type = "Vec3",
  37213. description = "The position of the center of the box, in meters."
  37214. },
  37215. {
  37216. name = "size",
  37217. type = "Vec3",
  37218. description = "The size of the box, in meters."
  37219. }
  37220. },
  37221. returns = {
  37222. {
  37223. name = "collider",
  37224. type = "Collider",
  37225. description = "The new Collider."
  37226. }
  37227. }
  37228. }
  37229. }
  37230. },
  37231. {
  37232. name = "newCapsuleCollider",
  37233. tag = "colliders",
  37234. summary = "Add a Collider with a CapsuleShape to the World.",
  37235. description = "Adds a new Collider to the World with a CapsuleShape already attached.",
  37236. key = "World:newCapsuleCollider",
  37237. module = "lovr.physics",
  37238. related = {
  37239. "CapsuleShape",
  37240. "Collider",
  37241. "World:newCollider",
  37242. "World:newBoxCollider",
  37243. "World:newCylinderCollider",
  37244. "World:newMeshCollider",
  37245. "World:newSphereCollider",
  37246. "World:newTerrainCollider"
  37247. },
  37248. variants = {
  37249. {
  37250. arguments = {
  37251. {
  37252. name = "x",
  37253. type = "number",
  37254. description = "The x coordinate of the center of the capsule, in meters.",
  37255. default = "0"
  37256. },
  37257. {
  37258. name = "y",
  37259. type = "number",
  37260. description = "The y coordinate of the center of the capsule, in meters.",
  37261. default = "0"
  37262. },
  37263. {
  37264. name = "z",
  37265. type = "number",
  37266. description = "The z coordinate of the center of the capsule, in meters.",
  37267. default = "0"
  37268. },
  37269. {
  37270. name = "radius",
  37271. type = "number",
  37272. description = "The radius of the capsule, in meters.",
  37273. default = "1"
  37274. },
  37275. {
  37276. name = "length",
  37277. type = "number",
  37278. description = "The length of the capsule, not including the caps, in meters.",
  37279. default = "1"
  37280. }
  37281. },
  37282. returns = {
  37283. {
  37284. name = "collider",
  37285. type = "Collider",
  37286. description = "The new Collider."
  37287. }
  37288. }
  37289. },
  37290. {
  37291. arguments = {
  37292. {
  37293. name = "position",
  37294. type = "Vec3",
  37295. description = "The position of the center of the capsule, in meters."
  37296. },
  37297. {
  37298. name = "radius",
  37299. type = "number",
  37300. description = "The radius of the capsule, in meters.",
  37301. default = "1"
  37302. },
  37303. {
  37304. name = "length",
  37305. type = "number",
  37306. description = "The length of the capsule, not including the caps, in meters.",
  37307. default = "1"
  37308. }
  37309. },
  37310. returns = {
  37311. {
  37312. name = "collider",
  37313. type = "Collider",
  37314. description = "The new Collider."
  37315. }
  37316. }
  37317. }
  37318. }
  37319. },
  37320. {
  37321. name = "newCollider",
  37322. tag = "colliders",
  37323. summary = "Add a Collider to the World.",
  37324. description = "Adds a new Collider to the World.",
  37325. key = "World:newCollider",
  37326. module = "lovr.physics",
  37327. examples = {
  37328. {
  37329. description = "Create a new world, add a collider to it, and update it, printing out the collider's position as it falls.",
  37330. code = "function lovr.load()\n world = lovr.physics.newWorld()\n box = world:newBoxCollider()\nend\n\nfunction lovr.update(dt)\n world:update(dt)\n print(box:getPosition())\nend"
  37331. }
  37332. },
  37333. notes = "This function creates a collider without any shapes attached to it, which means it won't collide with anything. To add a shape to the collider, use `Collider:addShape`, or use one of the following functions to create the collider:\n\n- `World:newBoxCollider`\n- `World:newCapsuleCollider`\n- `World:newCylinderCollider`\n- `World:newSphereCollider`",
  37334. related = {
  37335. "World:newBoxCollider",
  37336. "World:newCapsuleCollider",
  37337. "World:newCylinderCollider",
  37338. "World:newMeshCollider",
  37339. "World:newSphereCollider",
  37340. "World:newTerrainCollider",
  37341. "Collider",
  37342. "Shape"
  37343. },
  37344. variants = {
  37345. {
  37346. arguments = {
  37347. {
  37348. name = "x",
  37349. type = "number",
  37350. description = "The x position of the Collider.",
  37351. default = "0"
  37352. },
  37353. {
  37354. name = "y",
  37355. type = "number",
  37356. description = "The y position of the Collider.",
  37357. default = "0"
  37358. },
  37359. {
  37360. name = "z",
  37361. type = "number",
  37362. description = "The z position of the Collider.",
  37363. default = "0"
  37364. }
  37365. },
  37366. returns = {
  37367. {
  37368. name = "collider",
  37369. type = "Collider",
  37370. description = "The new Collider."
  37371. }
  37372. }
  37373. },
  37374. {
  37375. arguments = {
  37376. {
  37377. name = "position",
  37378. type = "Vec3",
  37379. description = "The position of the Collider."
  37380. }
  37381. },
  37382. returns = {
  37383. {
  37384. name = "collider",
  37385. type = "Collider",
  37386. description = "The new Collider."
  37387. }
  37388. }
  37389. }
  37390. }
  37391. },
  37392. {
  37393. name = "newCylinderCollider",
  37394. tag = "colliders",
  37395. summary = "Add a Collider with a CylinderShape to the World.",
  37396. description = "Adds a new Collider to the World with a CylinderShape already attached.",
  37397. key = "World:newCylinderCollider",
  37398. module = "lovr.physics",
  37399. related = {
  37400. "CylinderShape",
  37401. "Collider",
  37402. "World:newCollider",
  37403. "World:newBoxCollider",
  37404. "World:newCapsuleCollider",
  37405. "World:newMeshCollider",
  37406. "World:newSphereCollider",
  37407. "World:newTerrainCollider"
  37408. },
  37409. variants = {
  37410. {
  37411. arguments = {
  37412. {
  37413. name = "x",
  37414. type = "number",
  37415. description = "The x coordinate of the center of the cylinder, in meters.",
  37416. default = "0"
  37417. },
  37418. {
  37419. name = "y",
  37420. type = "number",
  37421. description = "The y coordinate of the center of the cylinder, in meters.",
  37422. default = "0"
  37423. },
  37424. {
  37425. name = "z",
  37426. type = "number",
  37427. description = "The z coordinate of the center of the cylinder, in meters.",
  37428. default = "0"
  37429. },
  37430. {
  37431. name = "radius",
  37432. type = "number",
  37433. description = "The radius of the cylinder, in meters.",
  37434. default = "1"
  37435. },
  37436. {
  37437. name = "length",
  37438. type = "number",
  37439. description = "The length of the cylinder, in meters.",
  37440. default = "1"
  37441. }
  37442. },
  37443. returns = {
  37444. {
  37445. name = "collider",
  37446. type = "Collider",
  37447. description = "The new Collider."
  37448. }
  37449. }
  37450. },
  37451. {
  37452. arguments = {
  37453. {
  37454. name = "position",
  37455. type = "Vec3",
  37456. description = "The position of the center of the cylinder, in meters."
  37457. },
  37458. {
  37459. name = "radius",
  37460. type = "number",
  37461. description = "The radius of the cylinder, in meters.",
  37462. default = "1"
  37463. },
  37464. {
  37465. name = "length",
  37466. type = "number",
  37467. description = "The length of the cylinder, in meters.",
  37468. default = "1"
  37469. }
  37470. },
  37471. returns = {
  37472. {
  37473. name = "collider",
  37474. type = "Collider",
  37475. description = "The new Collider."
  37476. }
  37477. }
  37478. }
  37479. }
  37480. },
  37481. {
  37482. name = "newMeshCollider",
  37483. tag = "colliders",
  37484. summary = "Add a Collider with a MeshShape to the World.",
  37485. description = "Adds a new Collider to the World with a MeshShape already attached.",
  37486. key = "World:newMeshCollider",
  37487. module = "lovr.physics",
  37488. related = {
  37489. "Collider",
  37490. "World:newCollider",
  37491. "World:newBoxCollider",
  37492. "World:newCapsuleCollider",
  37493. "World:newCylinderCollider",
  37494. "World:newSphereCollider",
  37495. "World:newTerrainCollider",
  37496. "Model:getTriangles"
  37497. },
  37498. variants = {
  37499. {
  37500. arguments = {
  37501. {
  37502. name = "vertices",
  37503. type = "table",
  37504. description = "The table of vertices in the mesh. Each vertex is a table with 3 numbers."
  37505. },
  37506. {
  37507. name = "indices",
  37508. type = "table",
  37509. description = "A table of triangle indices representing how the vertices are connected in the Mesh."
  37510. }
  37511. },
  37512. returns = {
  37513. {
  37514. name = "collider",
  37515. type = "Collider",
  37516. description = "The new Collider."
  37517. }
  37518. }
  37519. },
  37520. {
  37521. arguments = {
  37522. {
  37523. name = "model",
  37524. type = "Model",
  37525. description = "A Model to use for the mesh data. Similar to calling `Model:getTriangles` and passing it to this function, but has better performance."
  37526. }
  37527. },
  37528. returns = {
  37529. {
  37530. name = "collider",
  37531. type = "Collider",
  37532. description = "The new Collider."
  37533. }
  37534. }
  37535. }
  37536. }
  37537. },
  37538. {
  37539. name = "newSphereCollider",
  37540. tag = "colliders",
  37541. summary = "Add a Collider with a SphereShape to the World.",
  37542. description = "Adds a new Collider to the World with a SphereShape already attached.",
  37543. key = "World:newSphereCollider",
  37544. module = "lovr.physics",
  37545. related = {
  37546. "SphereShape",
  37547. "Collider",
  37548. "World:newCollider",
  37549. "World:newBoxCollider",
  37550. "World:newCapsuleCollider",
  37551. "World:newCylinderCollider",
  37552. "World:newMeshCollider",
  37553. "World:newTerrainCollider"
  37554. },
  37555. variants = {
  37556. {
  37557. arguments = {
  37558. {
  37559. name = "x",
  37560. type = "number",
  37561. description = "The x coordinate of the center of the sphere, in meters.",
  37562. default = "0"
  37563. },
  37564. {
  37565. name = "y",
  37566. type = "number",
  37567. description = "The y coordinate of the center of the sphere, in meters.",
  37568. default = "0"
  37569. },
  37570. {
  37571. name = "z",
  37572. type = "number",
  37573. description = "The z coordinate of the center of the sphere, in meters.",
  37574. default = "0"
  37575. },
  37576. {
  37577. name = "radius",
  37578. type = "number",
  37579. description = "The radius of the sphere, in meters.",
  37580. default = "1"
  37581. }
  37582. },
  37583. returns = {
  37584. {
  37585. name = "collider",
  37586. type = "Collider",
  37587. description = "The new Collider."
  37588. }
  37589. }
  37590. },
  37591. {
  37592. arguments = {
  37593. {
  37594. name = "position",
  37595. type = "Vec3",
  37596. description = "The position of the center of the sphere, in meters."
  37597. },
  37598. {
  37599. name = "radius",
  37600. type = "number",
  37601. description = "The radius of the sphere, in meters.",
  37602. default = "1"
  37603. }
  37604. },
  37605. returns = {
  37606. {
  37607. name = "collider",
  37608. type = "Collider",
  37609. description = "The new Collider."
  37610. }
  37611. }
  37612. }
  37613. }
  37614. },
  37615. {
  37616. name = "newTerrainCollider",
  37617. tag = "colliders",
  37618. summary = "Add a Collider with a TerrainShape to the World.",
  37619. description = "Adds a new Collider to the World with a TerrainShape already attached.",
  37620. key = "World:newTerrainCollider",
  37621. module = "lovr.physics",
  37622. notes = "The collider will be positioned at 0, 0, 0. Unlike other colliders, it will automatically be set as kinematic when created.",
  37623. related = {
  37624. "Collider",
  37625. "World:newCollider",
  37626. "World:newBoxCollider",
  37627. "World:newCapsuleCollider",
  37628. "World:newCylinderCollider",
  37629. "World:newSphereCollider",
  37630. "World:newMeshCollider",
  37631. "lovr.data.newImage"
  37632. },
  37633. variants = {
  37634. {
  37635. description = "Create a flat floor collider.",
  37636. arguments = {
  37637. {
  37638. name = "scale",
  37639. type = "number",
  37640. description = "The width and depth of the terrain, in meters."
  37641. }
  37642. },
  37643. returns = {
  37644. {
  37645. name = "collider",
  37646. type = "Collider",
  37647. description = "The new Collider."
  37648. }
  37649. }
  37650. },
  37651. {
  37652. description = "Create terrain from a heightmap image.",
  37653. arguments = {
  37654. {
  37655. name = "scale",
  37656. type = "number",
  37657. description = "The width and depth of the terrain, in meters."
  37658. },
  37659. {
  37660. name = "heightmap",
  37661. type = "Image",
  37662. description = "A heightmap image describing the terrain elevation at different points. The red channel brightness of each pixel determines the elevation at corresponding coordinates."
  37663. },
  37664. {
  37665. name = "stretch",
  37666. type = "number",
  37667. description = "A vertical multiplier for height values to obtain terrain height. When the image format has pixel values only in the 0 to 1 range, this can be used to scale the height to meters.",
  37668. default = "1.0"
  37669. }
  37670. },
  37671. returns = {
  37672. {
  37673. name = "collider",
  37674. type = "Collider",
  37675. description = "The new Collider."
  37676. }
  37677. }
  37678. },
  37679. {
  37680. description = "Create terrain defined with a callback function.",
  37681. arguments = {
  37682. {
  37683. name = "scale",
  37684. type = "number",
  37685. description = "The width and depth of the terrain, in meters."
  37686. },
  37687. {
  37688. name = "callback",
  37689. type = "function",
  37690. description = "A function that computes terrain height from x and z coordinates. The x and z inputs will range from `-scale / 2` to `scale / 2`.",
  37691. arguments = {
  37692. {
  37693. name = "x",
  37694. type = "number"
  37695. },
  37696. {
  37697. name = "z",
  37698. type = "number"
  37699. }
  37700. },
  37701. returns = {
  37702. name = "height",
  37703. type = "number"
  37704. }
  37705. },
  37706. {
  37707. name = "samples",
  37708. type = "number",
  37709. description = "The number of samples taken across the x and z dimensions. More samples will result in higher terrain fidelity, but use more CPU and memory.",
  37710. default = "100"
  37711. }
  37712. },
  37713. returns = {
  37714. {
  37715. name = "collider",
  37716. type = "Collider",
  37717. description = "The new Collider."
  37718. }
  37719. }
  37720. }
  37721. }
  37722. },
  37723. {
  37724. name = "overlaps",
  37725. tag = "worldCollision",
  37726. summary = "Iterate over pairs of nearby shapes.",
  37727. description = "Returns an iterator that can be used to iterate over \"overlaps\", or potential collisions between pairs of shapes in the World. This should be called after using `World:computeOverlaps` to compute the list of overlaps. Usually this is called automatically by `World:update`.",
  37728. key = "World:overlaps",
  37729. module = "lovr.physics",
  37730. examples = {
  37731. {
  37732. code = "world:computeOverlaps()\nfor shapeA, shapeB in world:overlaps() do\n local areColliding = world:collide(shapeA, shapeB)\n print(shapeA, shapeB, areColliding)\nend"
  37733. }
  37734. },
  37735. related = {
  37736. "World:computeOverlaps",
  37737. "World:collide",
  37738. "World:update"
  37739. },
  37740. variants = {
  37741. {
  37742. arguments = {},
  37743. returns = {
  37744. {
  37745. name = "iterator",
  37746. type = "function",
  37747. description = "A Lua iterator, usable in a for loop.",
  37748. arguments = {},
  37749. returns = {}
  37750. }
  37751. }
  37752. }
  37753. }
  37754. },
  37755. {
  37756. name = "queryBox",
  37757. tag = "worldBasics",
  37758. summary = "Find all shapes that intersect a box.",
  37759. description = "Finds all the shapes that intersect a box and calls a function for each one.",
  37760. key = "World:queryBox",
  37761. module = "lovr.physics",
  37762. notes = "Currently there is no way to specify a rotated box.",
  37763. related = {
  37764. "World:querySphere",
  37765. "World:raycast",
  37766. "World:getContacts",
  37767. "Shape:setSensor"
  37768. },
  37769. variants = {
  37770. {
  37771. arguments = {
  37772. {
  37773. name = "x",
  37774. type = "number",
  37775. description = "The x coordinate of the center of the box."
  37776. },
  37777. {
  37778. name = "y",
  37779. type = "number",
  37780. description = "The y coordinate of the center of the box."
  37781. },
  37782. {
  37783. name = "z",
  37784. type = "number",
  37785. description = "The z coordinate of the center of the box."
  37786. },
  37787. {
  37788. name = "w",
  37789. type = "number",
  37790. description = "The width of the box."
  37791. },
  37792. {
  37793. name = "h",
  37794. type = "number",
  37795. description = "The height of the box."
  37796. },
  37797. {
  37798. name = "d",
  37799. type = "number",
  37800. description = "The depth of the box."
  37801. },
  37802. {
  37803. name = "callback",
  37804. type = "function",
  37805. description = "An optional function to call when an intersection is detected. The function will be called with a single `Shape` argument, and it may return `false` to cancel the query.",
  37806. default = "nil"
  37807. }
  37808. },
  37809. returns = {
  37810. {
  37811. name = "any",
  37812. type = "boolean",
  37813. description = "Whether there were any intersections."
  37814. }
  37815. }
  37816. },
  37817. {
  37818. arguments = {
  37819. {
  37820. name = "position",
  37821. type = "Vec3",
  37822. description = "The position of the center of the box."
  37823. },
  37824. {
  37825. name = "size",
  37826. type = "Vec3",
  37827. description = "The size of the box."
  37828. },
  37829. {
  37830. name = "callback",
  37831. type = "function",
  37832. description = "An optional function to call when an intersection is detected. The function will be called with a single `Shape` argument, and it may return `false` to cancel the query.",
  37833. default = "nil"
  37834. }
  37835. },
  37836. returns = {
  37837. {
  37838. name = "any",
  37839. type = "boolean",
  37840. description = "Whether there were any intersections."
  37841. }
  37842. }
  37843. }
  37844. }
  37845. },
  37846. {
  37847. name = "querySphere",
  37848. tag = "worldBasics",
  37849. summary = "Find all shapes that intersect a sphere.",
  37850. description = "Finds all the shapes that intersect a sphere and calls a function for each one.",
  37851. key = "World:querySphere",
  37852. module = "lovr.physics",
  37853. related = {
  37854. "World:queryBox",
  37855. "World:raycast",
  37856. "World:getContacts",
  37857. "Shape:setSensor"
  37858. },
  37859. variants = {
  37860. {
  37861. arguments = {
  37862. {
  37863. name = "x",
  37864. type = "number",
  37865. description = "The x coordinate of the center of the sphere."
  37866. },
  37867. {
  37868. name = "y",
  37869. type = "number",
  37870. description = "The y coordinate of the center of the sphere."
  37871. },
  37872. {
  37873. name = "z",
  37874. type = "number",
  37875. description = "The z coordinate of the center of the sphere."
  37876. },
  37877. {
  37878. name = "radius",
  37879. type = "number",
  37880. description = "The radius of the sphere."
  37881. },
  37882. {
  37883. name = "callback",
  37884. type = "function",
  37885. description = "An optional function to call when an intersection is detected. The function will be called with a single `Shape` argument, and it may return `false` to cancel the query.",
  37886. default = "nil"
  37887. }
  37888. },
  37889. returns = {
  37890. {
  37891. name = "any",
  37892. type = "boolean",
  37893. description = "Whether there were any intersections."
  37894. }
  37895. }
  37896. },
  37897. {
  37898. arguments = {
  37899. {
  37900. name = "position",
  37901. type = "Vec3",
  37902. description = "The position of the center of the sphere."
  37903. },
  37904. {
  37905. name = "radius",
  37906. type = "number",
  37907. description = "The radius of the sphere."
  37908. },
  37909. {
  37910. name = "callback",
  37911. type = "function",
  37912. description = "An optional function to call when an intersection is detected. The function will be called with a single `Shape` argument, and it may return `false` to cancel the query.",
  37913. default = "nil"
  37914. }
  37915. },
  37916. returns = {
  37917. {
  37918. name = "any",
  37919. type = "boolean",
  37920. description = "Whether there were any intersections."
  37921. }
  37922. }
  37923. }
  37924. }
  37925. },
  37926. {
  37927. name = "raycast",
  37928. tag = "worldBasics",
  37929. summary = "Cast a ray through the World.",
  37930. description = "Casts a ray through the World, calling a function every time the ray intersects with a Shape.",
  37931. key = "World:raycast",
  37932. module = "lovr.physics",
  37933. examples = {
  37934. {
  37935. code = "function lovr.load()\n world = lovr.physics.newWorld()\n world:newSphereCollider(0, 0, 0, 2)\n\n -- Cast a ray through the sphere\n local x1, y1, z1 = .5, 3, 0\n local x2, y2, z2 = -.5, -2, 0\n world:raycast(x1, y1, z1, x2, y2, z2, function(shape, x, y, z, nx, ny, nz)\n print('Collision detected!', shape, x, y, z, nx, ny, nz)\n end)\nend"
  37936. }
  37937. },
  37938. notes = "The callback is passed the shape that was hit, the hit position (in world coordinates), and the normal vector of the hit.",
  37939. related = {
  37940. "World:queryBox",
  37941. "World:querySphere"
  37942. },
  37943. variants = {
  37944. {
  37945. arguments = {
  37946. {
  37947. name = "x1",
  37948. type = "number",
  37949. description = "The x coordinate of the starting position of the ray."
  37950. },
  37951. {
  37952. name = "y1",
  37953. type = "number",
  37954. description = "The y coordinate of the starting position of the ray."
  37955. },
  37956. {
  37957. name = "z1",
  37958. type = "number",
  37959. description = "The z coordinate of the starting position of the ray."
  37960. },
  37961. {
  37962. name = "x2",
  37963. type = "number",
  37964. description = "The x coordinate of the ending position of the ray."
  37965. },
  37966. {
  37967. name = "y2",
  37968. type = "number",
  37969. description = "The y coordinate of the ending position of the ray."
  37970. },
  37971. {
  37972. name = "z2",
  37973. type = "number",
  37974. description = "The z coordinate of the ending position of the ray."
  37975. },
  37976. {
  37977. name = "callback",
  37978. type = "function",
  37979. description = "The function to call when an intersection is detected. It can return `false` to cancel checks against additional shapes.",
  37980. arguments = {
  37981. {
  37982. name = "shape",
  37983. type = "Shape"
  37984. },
  37985. {
  37986. name = "x",
  37987. type = "number"
  37988. },
  37989. {
  37990. name = "y",
  37991. type = "number"
  37992. },
  37993. {
  37994. name = "z",
  37995. type = "number"
  37996. },
  37997. {
  37998. name = "nx",
  37999. type = "number"
  38000. },
  38001. {
  38002. name = "ny",
  38003. type = "number"
  38004. },
  38005. {
  38006. name = "nz",
  38007. type = "number"
  38008. }
  38009. },
  38010. returns = {}
  38011. }
  38012. },
  38013. returns = {}
  38014. },
  38015. {
  38016. arguments = {
  38017. {
  38018. name = "start",
  38019. type = "Vec3",
  38020. description = "The starting position of the ray."
  38021. },
  38022. {
  38023. name = "end",
  38024. type = "Vec3",
  38025. description = "The end position of the ray."
  38026. },
  38027. {
  38028. name = "callback",
  38029. type = "function",
  38030. description = "The function to call when an intersection is detected. It can return `false` to cancel checks against additional shapes.",
  38031. arguments = {
  38032. {
  38033. name = "shape",
  38034. type = "Shape"
  38035. },
  38036. {
  38037. name = "x",
  38038. type = "number"
  38039. },
  38040. {
  38041. name = "y",
  38042. type = "number"
  38043. },
  38044. {
  38045. name = "z",
  38046. type = "number"
  38047. },
  38048. {
  38049. name = "nx",
  38050. type = "number"
  38051. },
  38052. {
  38053. name = "ny",
  38054. type = "number"
  38055. },
  38056. {
  38057. name = "nz",
  38058. type = "number"
  38059. }
  38060. },
  38061. returns = {}
  38062. }
  38063. },
  38064. returns = {}
  38065. }
  38066. }
  38067. },
  38068. {
  38069. name = "setAngularDamping",
  38070. tag = "worldProperties",
  38071. summary = "Set the angular damping of the World.",
  38072. description = "Sets the angular damping of the World. Angular damping makes things less \"spinny\", making them slow down their angular velocity over time. Damping is only applied when angular velocity is over the threshold value.",
  38073. key = "World:setAngularDamping",
  38074. module = "lovr.physics",
  38075. notes = "This sets the default damping for newly-created colliders. Damping can also be set on a per-collider basis using `Collider:setAngularDamping`.",
  38076. related = {
  38077. "Collider:getAngularDamping",
  38078. "Collider:setAngularDamping"
  38079. },
  38080. variants = {
  38081. {
  38082. arguments = {
  38083. {
  38084. name = "damping",
  38085. type = "number",
  38086. description = "The angular damping."
  38087. },
  38088. {
  38089. name = "threshold",
  38090. type = "number",
  38091. description = "Velocity limit below which the damping is not applied.",
  38092. default = "0"
  38093. }
  38094. },
  38095. returns = {}
  38096. }
  38097. }
  38098. },
  38099. {
  38100. name = "setGravity",
  38101. tag = "worldProperties",
  38102. summary = "Set the gravity of the World.",
  38103. description = "Sets the gravity of the World.",
  38104. key = "World:setGravity",
  38105. module = "lovr.physics",
  38106. variants = {
  38107. {
  38108. arguments = {
  38109. {
  38110. name = "xg",
  38111. type = "number",
  38112. description = "The x component of the gravity force."
  38113. },
  38114. {
  38115. name = "yg",
  38116. type = "number",
  38117. description = "The y component of the gravity force."
  38118. },
  38119. {
  38120. name = "zg",
  38121. type = "number",
  38122. description = "The z component of the gravity force."
  38123. }
  38124. },
  38125. returns = {}
  38126. },
  38127. {
  38128. arguments = {
  38129. {
  38130. name = "gravity",
  38131. type = "Vec3",
  38132. description = "The gravity force."
  38133. }
  38134. },
  38135. returns = {}
  38136. }
  38137. }
  38138. },
  38139. {
  38140. name = "setLinearDamping",
  38141. tag = "worldProperties",
  38142. summary = "Set the linear damping of the World.",
  38143. description = "Sets the linear damping of the World. Linear damping is similar to drag or air resistance, slowing down colliders over time as they move. Damping is only applied when linear velocity is over the threshold value.",
  38144. key = "World:setLinearDamping",
  38145. module = "lovr.physics",
  38146. notes = "A linear damping of 0 means colliders won't slow down over time. This is the default.\n\nThis sets the default damping for newly-created colliders. Damping can also be set on a per-collider basis using `Collider:setLinearDamping`.",
  38147. related = {
  38148. "Collider:getLinearDamping",
  38149. "Collider:setLinearDamping"
  38150. },
  38151. variants = {
  38152. {
  38153. arguments = {
  38154. {
  38155. name = "damping",
  38156. type = "number",
  38157. description = "The linear damping."
  38158. },
  38159. {
  38160. name = "threshold",
  38161. type = "number",
  38162. description = "Velocity limit below which the damping is not applied.",
  38163. default = "0"
  38164. }
  38165. },
  38166. returns = {}
  38167. }
  38168. }
  38169. },
  38170. {
  38171. name = "setResponseTime",
  38172. tag = "worldProperties",
  38173. summary = "Set the response time of the World.",
  38174. description = "Sets the response time factor of the World.\n\nThe response time controls how relaxed collisions and joints are in the physics simulation, and functions similar to inertia. A low response time means collisions are resolved quickly, and higher values make objects more spongy and soft.\n\nThe value can be any positive number. It can be changed on a per-joint basis for `DistanceJoint` and `BallJoint` objects.",
  38175. key = "World:setResponseTime",
  38176. module = "lovr.physics",
  38177. related = {
  38178. "BallJoint:getResponseTime",
  38179. "BallJoint:setResponseTime",
  38180. "DistanceJoint:getResponseTime",
  38181. "DistanceJoint:setResponseTime",
  38182. "World:getTightness",
  38183. "World:setTightness"
  38184. },
  38185. variants = {
  38186. {
  38187. arguments = {
  38188. {
  38189. name = "responseTime",
  38190. type = "number",
  38191. description = "The new response time setting for the World."
  38192. }
  38193. },
  38194. returns = {}
  38195. }
  38196. }
  38197. },
  38198. {
  38199. name = "setSleepingAllowed",
  38200. tag = "worldProperties",
  38201. summary = "Set whether colliders can go to sleep.",
  38202. description = "Sets whether colliders can go to sleep in the World.",
  38203. key = "World:setSleepingAllowed",
  38204. module = "lovr.physics",
  38205. notes = "If sleeping is enabled, the World will try to detect colliders that haven't moved for a while and put them to sleep. Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly.\n\nThis can be set on individual colliders.\n\nColliders can be manually put to sleep or woken up using `Collider:setAwake`.",
  38206. related = {
  38207. "Collider:isSleepingAllowed",
  38208. "Collider:setSleepingAllowed",
  38209. "Collider:isAwake",
  38210. "Collider:setAwake"
  38211. },
  38212. variants = {
  38213. {
  38214. arguments = {
  38215. {
  38216. name = "allowed",
  38217. type = "boolean",
  38218. description = "Whether colliders can sleep."
  38219. }
  38220. },
  38221. returns = {}
  38222. }
  38223. }
  38224. },
  38225. {
  38226. name = "setStepCount",
  38227. tag = "worldProperties",
  38228. summary = "Set the step count of the World.",
  38229. description = "Sets the step count of the World. The step count influences how many steps are taken during a call to `World:update`. A higher number of steps will be slower, but more accurate. The default step count is 20.",
  38230. key = "World:setStepCount",
  38231. module = "lovr.physics",
  38232. related = {
  38233. "World:update"
  38234. },
  38235. variants = {
  38236. {
  38237. arguments = {
  38238. {
  38239. name = "steps",
  38240. type = "number",
  38241. description = "The new step count."
  38242. }
  38243. },
  38244. returns = {}
  38245. }
  38246. }
  38247. },
  38248. {
  38249. name = "setTightness",
  38250. tag = "worldProperties",
  38251. summary = "Set the tightness of joints in the World.",
  38252. description = "Sets the tightness of joints in the World.\n\nThe tightness controls how much force is applied to colliders connected by joints. With a value of 0, no force will be applied and joints won't have any effect. With a tightness of 1, a strong force will be used to try to keep the Colliders constrained. A tightness larger than 1 will overcorrect the joints, which can sometimes be desirable. Negative tightness values are not supported.",
  38253. key = "World:setTightness",
  38254. module = "lovr.physics",
  38255. related = {
  38256. "BallJoint:getTightness",
  38257. "BallJoint:setTightness",
  38258. "DistanceJoint:getTightness",
  38259. "DistanceJoint:setTightness",
  38260. "World:getResponseTime",
  38261. "World:setResponseTime"
  38262. },
  38263. variants = {
  38264. {
  38265. arguments = {
  38266. {
  38267. name = "tightness",
  38268. type = "number",
  38269. description = "The new tightness for the World."
  38270. }
  38271. },
  38272. returns = {}
  38273. }
  38274. }
  38275. },
  38276. {
  38277. name = "update",
  38278. tag = "worldBasics",
  38279. summary = "Update the World.",
  38280. description = "Updates the World, advancing the physics simulation forward in time and resolving collisions between colliders in the World.",
  38281. key = "World:update",
  38282. module = "lovr.physics",
  38283. notes = "It is common to pass the `dt` variable from `lovr.update` into this function.\n\nThe default collision resolver function is:\n\n function defaultResolver(world)\n world:computeOverlaps()\n for shapeA, shapeB in world:overlaps() do\n world:collide(shapeA, shapeB)\n end\n end\n\nAdditional logic could be introduced to the collision resolver function to add custom collision behavior or to change the collision parameters (like friction and restitution) on a per-collision basis.\n\n> If possible, use a fixed timestep value for updating the World. It will greatly improve the\n> accuracy of the simulation and reduce bugs. For more information on implementing a fixed\n> timestep loop, see [this article](http://gafferongames.com/game-physics/fix-your-timestep/).",
  38284. related = {
  38285. "World:computeOverlaps",
  38286. "World:overlaps",
  38287. "World:collide"
  38288. },
  38289. variants = {
  38290. {
  38291. arguments = {
  38292. {
  38293. name = "dt",
  38294. type = "number",
  38295. description = "The amount of time to advance the simulation forward."
  38296. },
  38297. {
  38298. name = "resolver",
  38299. type = "function",
  38300. description = "The collision resolver function to use. This will be called before updating to allow for custom collision processing. If absent, a default will be used.",
  38301. arguments = {
  38302. {
  38303. name = "world",
  38304. type = "World"
  38305. }
  38306. },
  38307. returns = {},
  38308. default = "nil",
  38309. variants = {
  38310. {
  38311. arguments = {
  38312. "dt",
  38313. "resolver"
  38314. },
  38315. returns = {}
  38316. }
  38317. }
  38318. }
  38319. },
  38320. returns = {}
  38321. }
  38322. }
  38323. }
  38324. },
  38325. notes = "Be sure to update the World in `lovr.update` using `World:update`, otherwise everything will stand still.",
  38326. sections = {
  38327. {
  38328. name = "Basics",
  38329. tag = "worldBasics"
  38330. },
  38331. {
  38332. name = "Colliders",
  38333. tag = "colliders",
  38334. description = "The following functions add Colliders to the World. `World:newCollider` adds an \"empty\" Collider without any Shapes attached, whereas the other functions are shortcut functions to add Colliders with Shapes already attached to them."
  38335. },
  38336. {
  38337. name = "Properties",
  38338. tag = "worldProperties",
  38339. description = "The following functions are global properties of the simulation that apply to all new Colliders."
  38340. },
  38341. {
  38342. name = "Collision",
  38343. tag = "worldCollision",
  38344. description = "When the World is created using `lovr.physics.newWorld`, it is possible to specify a list of collision tags for the World. Colliders can then be assigned a tag. You can enable and disable collision between pairs of tags. There are also some helper functions to quickly identify pairs of colliders that are near each other and test whether or not they are colliding. These are used internally by default by `World:update`, but you can override this behavior and use the functions directly for custom collision behavior."
  38345. }
  38346. }
  38347. }
  38348. },
  38349. sections = {
  38350. {
  38351. name = "Worlds",
  38352. tag = "world",
  38353. description = "A physics World holds all of the colliders and joints in the simulation. It must be updated every frame using `World:update`, during which it will move all the colliders and resolve collisions between them."
  38354. },
  38355. {
  38356. name = "Colliders",
  38357. tag = "colliders",
  38358. description = "Colliders are objects that represent a single rigid body in the physics simulation. They can have forces applied to them and collide with other colliders."
  38359. },
  38360. {
  38361. name = "Shapes",
  38362. tag = "shapes",
  38363. description = "Shapes are 3D physics shapes that can be attached to colliders. Shapes define, well, the shape of a Collider and how it collides with other objects. Without any Shapes, a collider wouldn't collide with anything.\n\nNormally, you don't need to create Shapes yourself, as there are convenience functions on the World that will create colliders with shapes already attached. However, you can attach multiple Shapes to a collider to create more complicated objects, and sometimes it can be useful to access the individual Shapes on a collider."
  38364. },
  38365. {
  38366. name = "Joints",
  38367. tag = "joints",
  38368. description = "Joints are objects that constrain the movement of colliders in various ways. Joints are attached to two colliders when they're created and usually have a concept of an \"anchor\", which is where the Joint is attached to relative to the colliders. Joints can be used to create all sorts of neat things like doors, drawers, buttons, levers, or pendulums."
  38369. }
  38370. }
  38371. },
  38372. {
  38373. name = "system",
  38374. tag = "modules",
  38375. summary = "Provides information about the current operating system and platform.",
  38376. description = "The `lovr.system` provides information about the current platform and hardware.\n\nIt also interfaces with the desktop window and window input.",
  38377. key = "lovr.system",
  38378. enums = {
  38379. {
  38380. name = "Permission",
  38381. summary = "Application permissions.",
  38382. description = "These are the different permissions that need to be requested using `lovr.system.requestPermission` on some platforms.",
  38383. key = "Permission",
  38384. module = "lovr.system",
  38385. related = {
  38386. "lovr.system.requestPermission"
  38387. },
  38388. values = {
  38389. {
  38390. name = "audiocapture",
  38391. description = "Requests microphone access."
  38392. }
  38393. }
  38394. }
  38395. },
  38396. functions = {
  38397. {
  38398. name = "getCoreCount",
  38399. tag = "system-info",
  38400. summary = "Get the number of logical cores.",
  38401. description = "Returns the number of logical cores on the system.",
  38402. key = "lovr.system.getCoreCount",
  38403. module = "lovr.system",
  38404. related = {
  38405. "lovr.thread"
  38406. },
  38407. variants = {
  38408. {
  38409. arguments = {},
  38410. returns = {
  38411. {
  38412. name = "cores",
  38413. type = "number",
  38414. description = "The number of logical cores on the system."
  38415. }
  38416. }
  38417. }
  38418. }
  38419. },
  38420. {
  38421. name = "getMousePosition",
  38422. tag = "system-mouse",
  38423. summary = "Get the position of the mouse.",
  38424. description = "Returns the position of the mouse.",
  38425. key = "lovr.system.getMousePosition",
  38426. module = "lovr.system",
  38427. related = {
  38428. "lovr.system.getMouseX",
  38429. "lovr.system.getMouseY",
  38430. "lovr.mousemoved"
  38431. },
  38432. variants = {
  38433. {
  38434. arguments = {},
  38435. returns = {
  38436. {
  38437. name = "x",
  38438. type = "number",
  38439. description = "The x position of the mouse, relative to the top-left of the window."
  38440. },
  38441. {
  38442. name = "y",
  38443. type = "number",
  38444. description = "The y position of the mouse, relative to the top-left of the window."
  38445. }
  38446. }
  38447. }
  38448. }
  38449. },
  38450. {
  38451. name = "getMouseX",
  38452. tag = "system-mouse",
  38453. summary = "Get the x position of the mouse.",
  38454. description = "Returns the x position of the mouse.",
  38455. key = "lovr.system.getMouseX",
  38456. module = "lovr.system",
  38457. related = {
  38458. "lovr.system.getMouseY",
  38459. "lovr.system.getMousePosition",
  38460. "lovr.mousemoved"
  38461. },
  38462. variants = {
  38463. {
  38464. arguments = {},
  38465. returns = {
  38466. {
  38467. name = "x",
  38468. type = "number",
  38469. description = "The x position of the mouse, relative to the top-left of the window."
  38470. }
  38471. }
  38472. }
  38473. }
  38474. },
  38475. {
  38476. name = "getMouseY",
  38477. tag = "system-mouse",
  38478. summary = "Get the y position of the mouse.",
  38479. description = "Returns the y position of the mouse.",
  38480. key = "lovr.system.getMouseY",
  38481. module = "lovr.system",
  38482. related = {
  38483. "lovr.system.getMouseX",
  38484. "lovr.system.getMousePosition",
  38485. "lovr.mousemoved"
  38486. },
  38487. variants = {
  38488. {
  38489. arguments = {},
  38490. returns = {
  38491. {
  38492. name = "y",
  38493. type = "number",
  38494. description = "The y position of the mouse, relative to the top-left of the window."
  38495. }
  38496. }
  38497. }
  38498. }
  38499. },
  38500. {
  38501. name = "getOS",
  38502. tag = "system-info",
  38503. summary = "Get the current operating system.",
  38504. description = "Returns the current operating system.",
  38505. key = "lovr.system.getOS",
  38506. module = "lovr.system",
  38507. variants = {
  38508. {
  38509. arguments = {},
  38510. returns = {
  38511. {
  38512. name = "os",
  38513. type = "string",
  38514. description = "Either \"Windows\", \"macOS\", \"Linux\", \"Android\" or \"Web\"."
  38515. }
  38516. }
  38517. }
  38518. }
  38519. },
  38520. {
  38521. name = "getWindowDensity",
  38522. tag = "system-window",
  38523. summary = "Get the window pixel density.",
  38524. description = "Returns the window pixel density. High DPI windows will usually return 2.0 to indicate that there are 2 pixels for every window coordinate in each axis. On a normal display, 1.0 is returned, indicating that window coordinates match up with pixels 1:1.",
  38525. key = "lovr.system.getWindowDensity",
  38526. module = "lovr.system",
  38527. variants = {
  38528. {
  38529. arguments = {},
  38530. returns = {
  38531. {
  38532. name = "density",
  38533. type = "number",
  38534. description = "The pixel density of the window."
  38535. }
  38536. }
  38537. }
  38538. }
  38539. },
  38540. {
  38541. name = "getWindowDimensions",
  38542. tag = "system-window",
  38543. summary = "Get the dimensions of the window.",
  38544. description = "Returns the dimensions of the desktop window.",
  38545. key = "lovr.system.getWindowDimensions",
  38546. module = "lovr.system",
  38547. notes = "If the window is not open, this will return zeros.",
  38548. related = {
  38549. "lovr.system.getWindowWidth",
  38550. "lovr.system.getWindowHeight",
  38551. "lovr.system.isWindowOpen"
  38552. },
  38553. variants = {
  38554. {
  38555. arguments = {},
  38556. returns = {
  38557. {
  38558. name = "width",
  38559. type = "number",
  38560. description = "The width of the desktop window."
  38561. },
  38562. {
  38563. name = "height",
  38564. type = "number",
  38565. description = "The height of the desktop window."
  38566. }
  38567. }
  38568. }
  38569. }
  38570. },
  38571. {
  38572. name = "getWindowHeight",
  38573. tag = "system-window",
  38574. summary = "Get the height of the window.",
  38575. description = "Returns the height of the desktop window.",
  38576. key = "lovr.system.getWindowHeight",
  38577. module = "lovr.system",
  38578. notes = "If the window is not open, this will return zero.",
  38579. related = {
  38580. "lovr.system.getWindowWidth",
  38581. "lovr.system.getWindowDimensions",
  38582. "lovr.system.isWindowOpen"
  38583. },
  38584. variants = {
  38585. {
  38586. arguments = {},
  38587. returns = {
  38588. {
  38589. name = "width",
  38590. type = "number",
  38591. description = "The height of the desktop window."
  38592. }
  38593. }
  38594. }
  38595. }
  38596. },
  38597. {
  38598. name = "getWindowWidth",
  38599. tag = "system-window",
  38600. summary = "Get the width of the window.",
  38601. description = "Returns the width of the desktop window.",
  38602. key = "lovr.system.getWindowWidth",
  38603. module = "lovr.system",
  38604. notes = "If the window is not open, this will return zero.",
  38605. related = {
  38606. "lovr.system.getWindowHeight",
  38607. "lovr.system.getWindowDimensions",
  38608. "lovr.system.isWindowOpen"
  38609. },
  38610. variants = {
  38611. {
  38612. arguments = {},
  38613. returns = {
  38614. {
  38615. name = "width",
  38616. type = "number",
  38617. description = "The width of the desktop window."
  38618. }
  38619. }
  38620. }
  38621. }
  38622. },
  38623. {
  38624. name = "hasKeyRepeat",
  38625. tag = "system-keyboard",
  38626. summary = "Check if key repeat is enabled.",
  38627. description = "Returns whether key repeat is enabled.",
  38628. key = "lovr.system.hasKeyRepeat",
  38629. module = "lovr.system",
  38630. notes = "Key repeat is disabled by default.",
  38631. related = {
  38632. "lovr.keypressed"
  38633. },
  38634. variants = {
  38635. {
  38636. arguments = {},
  38637. returns = {
  38638. {
  38639. name = "enabled",
  38640. type = "boolean",
  38641. description = "Whether key repeat is enabled."
  38642. }
  38643. }
  38644. }
  38645. }
  38646. },
  38647. {
  38648. name = "isKeyDown",
  38649. tag = "system-keyboard",
  38650. summary = "Get the state of a key.",
  38651. description = "Returns whether a key on the keyboard is pressed.",
  38652. key = "lovr.system.isKeyDown",
  38653. module = "lovr.system",
  38654. related = {
  38655. "lovr.system.wasKeyPressed",
  38656. "lovr.system.wasKeyReleased",
  38657. "lovr.keypressed",
  38658. "lovr.keyreleased"
  38659. },
  38660. variants = {
  38661. {
  38662. arguments = {
  38663. {
  38664. name = "...",
  38665. type = "KeyCode",
  38666. description = "The set of keys to check."
  38667. }
  38668. },
  38669. returns = {
  38670. {
  38671. name = "down",
  38672. type = "boolean",
  38673. description = "Whether any of the keys are currently pressed."
  38674. }
  38675. }
  38676. }
  38677. }
  38678. },
  38679. {
  38680. name = "isMouseDown",
  38681. tag = "system-mouse",
  38682. summary = "Check if a mouse button is pressed.",
  38683. description = "Returns whether a mouse button is currently pressed.",
  38684. key = "lovr.system.isMouseDown",
  38685. module = "lovr.system",
  38686. related = {
  38687. "lovr.mousepressed",
  38688. "lovr.mousereleased",
  38689. "lovr.system.getMouseX",
  38690. "lovr.system.getMouseY",
  38691. "lovr.system.getMousePosition"
  38692. },
  38693. variants = {
  38694. {
  38695. arguments = {
  38696. {
  38697. name = "button",
  38698. type = "number",
  38699. description = "The index of a button to check. Use 1 for the primary mouse button, 2 for the secondary button, and 3 for the middle button. Other indices can be used, but are hardware-specific."
  38700. }
  38701. },
  38702. returns = {
  38703. {
  38704. name = "down",
  38705. type = "boolean",
  38706. description = "Whether the mouse button is currently down."
  38707. }
  38708. }
  38709. }
  38710. }
  38711. },
  38712. {
  38713. name = "isWindowOpen",
  38714. tag = "system-window",
  38715. summary = "Check if the desktop window is open.",
  38716. description = "Returns whether the desktop window is open. `t.window` can be set to `nil` in `lovr.conf` to disable automatic opening of the window. In this case, the window can be opened manually using `lovr.system.openWindow`.",
  38717. key = "lovr.system.isWindowOpen",
  38718. module = "lovr.system",
  38719. related = {
  38720. "lovr.system.openWindow"
  38721. },
  38722. variants = {
  38723. {
  38724. arguments = {},
  38725. returns = {
  38726. {
  38727. name = "open",
  38728. type = "boolean",
  38729. description = "Whether the desktop window is open."
  38730. }
  38731. }
  38732. }
  38733. }
  38734. },
  38735. {
  38736. name = "openWindow",
  38737. tag = "system-window",
  38738. summary = "Open the desktop window.",
  38739. description = "Opens the desktop window. If the window is already open, this function does nothing.",
  38740. key = "lovr.system.openWindow",
  38741. module = "lovr.system",
  38742. notes = "By default, the window is opened automatically, but this can be disabled by setting `t.window` to `nil` in `conf.lua`.",
  38743. related = {
  38744. "lovr.system.isWindowOpen",
  38745. "lovr.conf"
  38746. },
  38747. variants = {
  38748. {
  38749. arguments = {
  38750. {
  38751. name = "options",
  38752. type = "table",
  38753. description = "Window options.",
  38754. table = {
  38755. {
  38756. name = "width",
  38757. type = "number",
  38758. description = "The width of the window, or 0 to use the width of the monitor.",
  38759. default = "720"
  38760. },
  38761. {
  38762. name = "height",
  38763. type = "number",
  38764. description = "The height of the window, or 0 to use the height of the monitor.",
  38765. default = "800"
  38766. },
  38767. {
  38768. name = "fullscreen",
  38769. type = "boolean",
  38770. description = "Whether the window should be fullscreen."
  38771. },
  38772. {
  38773. name = "resizable",
  38774. type = "boolean",
  38775. description = "Whether the window should be resizable."
  38776. },
  38777. {
  38778. name = "title",
  38779. type = "string",
  38780. description = "The window title."
  38781. },
  38782. {
  38783. name = "icon",
  38784. type = "string",
  38785. description = "An `Image` or path to an image file to use for the window icon."
  38786. }
  38787. }
  38788. }
  38789. },
  38790. returns = {}
  38791. }
  38792. }
  38793. },
  38794. {
  38795. name = "pollEvents",
  38796. tag = "system-window",
  38797. summary = "Poll the OS for new window events.",
  38798. description = "Fills the event queue with unprocessed events from the operating system. This function should be called often, otherwise the operating system will consider the application unresponsive. This function is called in the default implementation of `lovr.run`.",
  38799. key = "lovr.system.pollEvents",
  38800. module = "lovr.system",
  38801. related = {
  38802. "lovr.event.poll"
  38803. },
  38804. variants = {
  38805. {
  38806. arguments = {},
  38807. returns = {}
  38808. }
  38809. }
  38810. },
  38811. {
  38812. name = "requestPermission",
  38813. tag = "system-info",
  38814. summary = "Request permission to use a feature.",
  38815. description = "Requests permission to use a feature. Usually this will pop up a dialog box that the user needs to confirm. Once the permission request has been acknowledged, the `lovr.permission` callback will be called with the result. Currently, this is only used for requesting microphone access on Android devices.",
  38816. key = "lovr.system.requestPermission",
  38817. module = "lovr.system",
  38818. related = {
  38819. "lovr.permission"
  38820. },
  38821. variants = {
  38822. {
  38823. arguments = {
  38824. {
  38825. name = "permission",
  38826. type = "Permission",
  38827. description = "The permission to request."
  38828. }
  38829. },
  38830. returns = {}
  38831. }
  38832. }
  38833. },
  38834. {
  38835. name = "setKeyRepeat",
  38836. tag = "system-keyboard",
  38837. summary = "Enable or disable key repeat.",
  38838. description = "Enables or disables key repeat. Key repeat affects whether `lovr.keypressed` will be fired multiple times while a key is held down. The `repeat` parameter of the callback can be used to detect whether a key press comes from a \"repeat\" or not.",
  38839. key = "lovr.system.setKeyRepeat",
  38840. module = "lovr.system",
  38841. notes = "Key repeat is disabled by default. `lovr.textinput` is not affected by key repeat.",
  38842. related = {
  38843. "lovr.keypressed"
  38844. },
  38845. variants = {
  38846. {
  38847. arguments = {
  38848. {
  38849. name = "enable",
  38850. type = "boolean",
  38851. description = "Whether key repeat should be enabled."
  38852. }
  38853. },
  38854. returns = {}
  38855. }
  38856. }
  38857. },
  38858. {
  38859. name = "wasKeyPressed",
  38860. tag = "system-keyboard",
  38861. summary = "Check if a key was pressed this frame.",
  38862. description = "Returns whether a key on the keyboard was pressed this frame.",
  38863. key = "lovr.system.wasKeyPressed",
  38864. module = "lovr.system",
  38865. notes = "Technically this returns whether the key was pressed between the last 2 calls to `lovr.system.pollEvents`, but that function is called automatically at the beginning of each frame in `lovr.run`, so it all works out!",
  38866. related = {
  38867. "lovr.system.isKeyDown",
  38868. "lovr.system.wasKeyReleased",
  38869. "lovr.keypressed",
  38870. "lovr.keyreleased"
  38871. },
  38872. variants = {
  38873. {
  38874. arguments = {
  38875. {
  38876. name = "...",
  38877. type = "KeyCode",
  38878. description = "The set of keys to check."
  38879. }
  38880. },
  38881. returns = {
  38882. {
  38883. name = "pressed",
  38884. type = "boolean",
  38885. description = "Whether any of the specified keys were pressed this frame."
  38886. }
  38887. }
  38888. }
  38889. }
  38890. },
  38891. {
  38892. name = "wasKeyReleased",
  38893. tag = "system-keyboard",
  38894. summary = "Check if a key was released this frame.",
  38895. description = "Returns whether a key on the keyboard was released this frame.",
  38896. key = "lovr.system.wasKeyReleased",
  38897. module = "lovr.system",
  38898. notes = "Technically this returns whether the key was released between the last 2 calls to `lovr.system.pollEvents`, but that function is called automatically at the beginning of each frame in `lovr.run`, so it all works out!",
  38899. related = {
  38900. "lovr.system.isKeyDown",
  38901. "lovr.system.wasKeyPressed",
  38902. "lovr.keypressed",
  38903. "lovr.keyreleased"
  38904. },
  38905. variants = {
  38906. {
  38907. arguments = {
  38908. {
  38909. name = "...",
  38910. type = "KeyCode",
  38911. description = "The set of keys to check."
  38912. }
  38913. },
  38914. returns = {
  38915. {
  38916. name = "released",
  38917. type = "boolean",
  38918. description = "Whether any of the specified keys were released this frame."
  38919. }
  38920. }
  38921. }
  38922. }
  38923. }
  38924. },
  38925. objects = {},
  38926. sections = {
  38927. {
  38928. name = "System Information",
  38929. tag = "system-info"
  38930. },
  38931. {
  38932. name = "Keyboard",
  38933. tag = "system-keyboard"
  38934. },
  38935. {
  38936. name = "Mouse",
  38937. tag = "system-mouse"
  38938. },
  38939. {
  38940. name = "Window",
  38941. tag = "system-window"
  38942. }
  38943. }
  38944. },
  38945. {
  38946. name = "thread",
  38947. tag = "modules",
  38948. summary = "Allows the creation of background threads.",
  38949. description = "The `lovr.thread` module provides functions for creating threads and communicating between them.\n\nThese are operating system level threads, which are different from Lua coroutines.\n\nThreads are useful for performing expensive background computation without affecting the framerate or performance of the main thread. Some examples of this include asset loading, networking and network requests, and physics simulation.\n\nThreads come with some caveats:\n\n- Threads run in a bare Lua environment. The `lovr` module (and any of lovr's modules) need to\n be required before they can be used.\n - To get `require` to work properly, add `require 'lovr.filesystem'` to the thread code.\n- Threads are completely isolated from other threads. They do not have access to the variables\n or functions of other threads, and communication between threads must be coordinated through\n `Channel` objects.\n- The graphics module (or any functions that perform rendering) cannot be used in a thread.\n Note that this includes creating graphics objects like Models and Textures. There are \"data\"\n equivalent `ModelData` and `Image` objects that can be used in threads though.\n- `lovr.system.pollEvents` cannot be called from a thread.\n- Crashes or problems can happen if two threads access the same object at the same time, so\n special care must be taken to coordinate access to objects from multiple threads.",
  38950. key = "lovr.thread",
  38951. enums = {},
  38952. functions = {
  38953. {
  38954. name = "getChannel",
  38955. summary = "Get a Channel for communicating between threads.",
  38956. description = "Returns a named Channel for communicating between threads.",
  38957. key = "lovr.thread.getChannel",
  38958. module = "lovr.thread",
  38959. related = {
  38960. "Channel"
  38961. },
  38962. variants = {
  38963. {
  38964. arguments = {
  38965. {
  38966. name = "name",
  38967. type = "string",
  38968. description = "The name of the Channel to get."
  38969. }
  38970. },
  38971. returns = {
  38972. {
  38973. name = "channel",
  38974. type = "Channel",
  38975. description = "The Channel with the specified name."
  38976. }
  38977. }
  38978. }
  38979. }
  38980. },
  38981. {
  38982. name = "newThread",
  38983. summary = "Create a new Thread.",
  38984. description = "Creates a new Thread from Lua code.",
  38985. key = "lovr.thread.newThread",
  38986. module = "lovr.thread",
  38987. notes = "The Thread won\\'t start running immediately. Use `Thread:start` to start it.\n\nThe string argument is assumed to be a filename if there isn't a newline in the first 1024 characters. For really short thread code, an extra newline can be added to trick LÖVR into loading it properly.",
  38988. related = {
  38989. "Thread:start",
  38990. "lovr.threaderror"
  38991. },
  38992. variants = {
  38993. {
  38994. arguments = {
  38995. {
  38996. name = "code",
  38997. type = "string",
  38998. description = "The code to run in the Thread."
  38999. }
  39000. },
  39001. returns = {
  39002. {
  39003. name = "thread",
  39004. type = "Thread",
  39005. description = "The new Thread."
  39006. }
  39007. }
  39008. },
  39009. {
  39010. arguments = {
  39011. {
  39012. name = "filename",
  39013. type = "string",
  39014. description = "A file containing code to run in the Thread."
  39015. }
  39016. },
  39017. returns = {
  39018. {
  39019. name = "thread",
  39020. type = "Thread",
  39021. description = "The new Thread."
  39022. }
  39023. }
  39024. },
  39025. {
  39026. arguments = {
  39027. {
  39028. name = "blob",
  39029. type = "Blob",
  39030. description = "The code to run in the Thread."
  39031. }
  39032. },
  39033. returns = {
  39034. {
  39035. name = "thread",
  39036. type = "Thread",
  39037. description = "The new Thread."
  39038. }
  39039. }
  39040. }
  39041. }
  39042. }
  39043. },
  39044. objects = {
  39045. {
  39046. name = "Channel",
  39047. summary = "A message channel for communicating between threads.",
  39048. description = "A Channel is an object used to communicate between `Thread` objects. Channels are obtained by name using `lovr.thread.getChannel`. Different threads can send messages on the same Channel to communicate with each other. Messages can be sent and received on a Channel using `Channel:push` and `Channel:pop`, and are received in a first-in-first-out fashion. The following types of data can be passed through Channels: nil, boolean, number, string, and any LÖVR object.",
  39049. key = "Channel",
  39050. module = "lovr.thread",
  39051. constructors = {
  39052. "lovr.thread.getChannel"
  39053. },
  39054. methods = {
  39055. {
  39056. name = "clear",
  39057. summary = "Clear all messages from the Channel.",
  39058. description = "Removes all pending messages from the Channel.",
  39059. key = "Channel:clear",
  39060. module = "lovr.thread",
  39061. variants = {
  39062. {
  39063. arguments = {},
  39064. returns = {}
  39065. }
  39066. }
  39067. },
  39068. {
  39069. name = "hasRead",
  39070. summary = "Get whether a message has been read.",
  39071. description = "Returns whether or not the message with the given ID has been read. Every call to `Channel:push` returns a message ID.",
  39072. key = "Channel:hasRead",
  39073. module = "lovr.thread",
  39074. related = {
  39075. "Channel:push"
  39076. },
  39077. variants = {
  39078. {
  39079. arguments = {
  39080. {
  39081. name = "id",
  39082. type = "number",
  39083. description = "The ID of the message to check."
  39084. }
  39085. },
  39086. returns = {
  39087. {
  39088. name = "read",
  39089. type = "boolean",
  39090. description = "Whether the message has been read."
  39091. }
  39092. }
  39093. }
  39094. }
  39095. },
  39096. {
  39097. name = "peek",
  39098. summary = "Look at a message from the Channel without popping it.",
  39099. description = "Returns a message from the Channel without popping it from the queue. If the Channel is empty, `nil` is returned. This can be useful to determine if the Channel is empty.",
  39100. key = "Channel:peek",
  39101. module = "lovr.thread",
  39102. notes = "The second return value can be used to detect if a `nil` message is in the queue.",
  39103. related = {
  39104. "Channel:pop"
  39105. },
  39106. variants = {
  39107. {
  39108. arguments = {},
  39109. returns = {
  39110. {
  39111. name = "message",
  39112. type = "*",
  39113. description = "The message, or `nil` if there is no message."
  39114. },
  39115. {
  39116. name = "present",
  39117. type = "boolean",
  39118. description = "Whether a message was returned (use to detect nil)."
  39119. }
  39120. }
  39121. }
  39122. }
  39123. },
  39124. {
  39125. name = "pop",
  39126. summary = "Pop a message from the Channel.",
  39127. description = "Pops a message from the Channel. If the Channel is empty, an optional timeout argument can be used to wait for a message, otherwise `nil` is returned.",
  39128. key = "Channel:pop",
  39129. module = "lovr.thread",
  39130. notes = "Threads can get stuck forever waiting on Channel messages, so be careful.",
  39131. related = {
  39132. "Channel:peek",
  39133. "Channel:push"
  39134. },
  39135. variants = {
  39136. {
  39137. arguments = {
  39138. {
  39139. name = "wait",
  39140. type = "number",
  39141. description = "How long to wait for a message to be popped, in seconds. `true` can be used to wait forever and `false` can be used to avoid waiting.",
  39142. default = "false"
  39143. }
  39144. },
  39145. returns = {
  39146. {
  39147. name = "message",
  39148. type = "*",
  39149. description = "The received message, or `nil` if nothing was received."
  39150. }
  39151. }
  39152. }
  39153. }
  39154. },
  39155. {
  39156. name = "push",
  39157. summary = "Push a message onto the Channel.",
  39158. description = "Pushes a message onto the Channel. The following types of data can be pushed: nil, boolean, number, string, lightuserdata, vectors, and userdata (LÖVR objects). Notably, tables are not currently supported and should be serialized to strings.",
  39159. key = "Channel:push",
  39160. module = "lovr.thread",
  39161. notes = "Threads can get stuck forever waiting on Channel messages, so be careful.",
  39162. related = {
  39163. "Channel:pop",
  39164. "Channel:hasRead"
  39165. },
  39166. variants = {
  39167. {
  39168. arguments = {
  39169. {
  39170. name = "message",
  39171. type = "*",
  39172. description = "The message to push."
  39173. },
  39174. {
  39175. name = "wait",
  39176. type = "number",
  39177. description = "How long to wait for the message to be popped, in seconds. `true` can be used to wait forever and `false` can be used to avoid waiting.",
  39178. default = "false"
  39179. }
  39180. },
  39181. returns = {
  39182. {
  39183. name = "id",
  39184. type = "number",
  39185. description = "The ID of the pushed message."
  39186. },
  39187. {
  39188. name = "read",
  39189. type = "boolean",
  39190. description = "Whether the message was read by another thread before the wait timeout."
  39191. }
  39192. }
  39193. }
  39194. }
  39195. }
  39196. }
  39197. },
  39198. {
  39199. name = "Thread",
  39200. summary = "A separate thread of execution that can run code in parallel with other threads.",
  39201. description = "A Thread is an object that runs a chunk of Lua code in the background. Threads are completely isolated from other threads, meaning they have their own Lua context and can't access the variables and functions of other threads. Communication between threads is limited and is accomplished by using `Channel` objects.\n\nTo get `require` to work properly, add `require 'lovr.filesystem'` to the thread code.",
  39202. key = "Thread",
  39203. module = "lovr.thread",
  39204. constructors = {
  39205. "lovr.thread.newThread"
  39206. },
  39207. methods = {
  39208. {
  39209. name = "getError",
  39210. summary = "Get the Thread's error message.",
  39211. description = "Returns the message for the error that occurred on the Thread, or nil if no error has occurred.",
  39212. key = "Thread:getError",
  39213. module = "lovr.thread",
  39214. related = {
  39215. "lovr.threaderror"
  39216. },
  39217. variants = {
  39218. {
  39219. arguments = {},
  39220. returns = {
  39221. {
  39222. name = "error",
  39223. type = "string",
  39224. description = "The error message, or `nil` if no error has occurred on the Thread."
  39225. }
  39226. }
  39227. }
  39228. }
  39229. },
  39230. {
  39231. name = "isRunning",
  39232. summary = "Check if the Thread is running.",
  39233. description = "Returns whether or not the Thread is currently running.",
  39234. key = "Thread:isRunning",
  39235. module = "lovr.thread",
  39236. related = {
  39237. "Thread:start"
  39238. },
  39239. variants = {
  39240. {
  39241. arguments = {},
  39242. returns = {
  39243. {
  39244. name = "running",
  39245. type = "boolean",
  39246. description = "Whether or not the Thread is running."
  39247. }
  39248. }
  39249. }
  39250. }
  39251. },
  39252. {
  39253. name = "start",
  39254. summary = "Start the Thread.",
  39255. description = "Starts the Thread.",
  39256. key = "Thread:start",
  39257. module = "lovr.thread",
  39258. examples = {
  39259. {
  39260. code = "function lovr.load()\n lovr.thread.newThread([[\n print(...)\n ]]):start(lovr.getVersion())\nend"
  39261. }
  39262. },
  39263. notes = "The arguments can be nil, booleans, numbers, strings, or LÖVR objects.",
  39264. variants = {
  39265. {
  39266. arguments = {
  39267. {
  39268. name = "...arguments",
  39269. type = "*",
  39270. description = "Up to 4 arguments to pass to the Thread's function."
  39271. }
  39272. },
  39273. returns = {}
  39274. }
  39275. }
  39276. },
  39277. {
  39278. name = "wait",
  39279. summary = "Wait for the Thread to complete.",
  39280. description = "Waits for the Thread to complete, then returns.",
  39281. key = "Thread:wait",
  39282. module = "lovr.thread",
  39283. related = {
  39284. "Thread:isRunning"
  39285. },
  39286. variants = {
  39287. {
  39288. arguments = {},
  39289. returns = {}
  39290. }
  39291. }
  39292. }
  39293. },
  39294. related = {
  39295. "lovr.threaderror",
  39296. "lovr.system.getCoreCount",
  39297. "Channel"
  39298. }
  39299. }
  39300. },
  39301. related = {
  39302. "lovr.system.getCoreCount"
  39303. }
  39304. },
  39305. {
  39306. name = "timer",
  39307. tag = "modules",
  39308. summary = "Exposes a high resolution timer.",
  39309. description = "The `lovr.timer` module provides a few functions that deal with time. All times are measured in seconds.",
  39310. key = "lovr.timer",
  39311. enums = {},
  39312. functions = {
  39313. {
  39314. name = "getAverageDelta",
  39315. summary = "Get the average delta over the last second.",
  39316. description = "Returns the average delta over the last second.",
  39317. key = "lovr.timer.getAverageDelta",
  39318. module = "lovr.timer",
  39319. related = {
  39320. "lovr.timer.getDelta",
  39321. "lovr.update"
  39322. },
  39323. variants = {
  39324. {
  39325. arguments = {},
  39326. returns = {
  39327. {
  39328. name = "delta",
  39329. type = "number",
  39330. description = "The average delta, in seconds."
  39331. }
  39332. }
  39333. }
  39334. }
  39335. },
  39336. {
  39337. name = "getDelta",
  39338. summary = "Get the time elapsed since the last update.",
  39339. description = "Returns the time between the last two frames. This is the same value as the `dt` argument provided to `lovr.update`.",
  39340. key = "lovr.timer.getDelta",
  39341. module = "lovr.timer",
  39342. notes = "The return value of this function will remain the same until `lovr.timer.step` is called. This function should not be used to measure times for game behavior or benchmarking, use `lovr.timer.getTime` for that.",
  39343. related = {
  39344. "lovr.timer.getTime",
  39345. "lovr.update"
  39346. },
  39347. variants = {
  39348. {
  39349. arguments = {},
  39350. returns = {
  39351. {
  39352. name = "dt",
  39353. type = "number",
  39354. description = "The delta time, in seconds."
  39355. }
  39356. }
  39357. }
  39358. }
  39359. },
  39360. {
  39361. name = "getFPS",
  39362. summary = "Get the current frames per second.",
  39363. description = "Returns the current frames per second, averaged over the last 90 frames.",
  39364. key = "lovr.timer.getFPS",
  39365. module = "lovr.timer",
  39366. variants = {
  39367. {
  39368. arguments = {},
  39369. returns = {
  39370. {
  39371. name = "fps",
  39372. type = "number",
  39373. description = "The current FPS."
  39374. }
  39375. }
  39376. }
  39377. }
  39378. },
  39379. {
  39380. name = "getTime",
  39381. summary = "Get the current time.",
  39382. description = "Returns the time since some time in the past. This can be used to measure the difference between two points in time.",
  39383. key = "lovr.timer.getTime",
  39384. module = "lovr.timer",
  39385. related = {
  39386. "lovr.headset.getTime"
  39387. },
  39388. variants = {
  39389. {
  39390. arguments = {},
  39391. returns = {
  39392. {
  39393. name = "time",
  39394. type = "number",
  39395. description = "The current time, in seconds."
  39396. }
  39397. }
  39398. }
  39399. }
  39400. },
  39401. {
  39402. name = "sleep",
  39403. summary = "Go to sleep.",
  39404. description = "Sleeps the application for a specified number of seconds. While the game is asleep, no code will be run, no graphics will be drawn, and the window will be unresponsive.",
  39405. key = "lovr.timer.sleep",
  39406. module = "lovr.timer",
  39407. variants = {
  39408. {
  39409. arguments = {
  39410. {
  39411. name = "duration",
  39412. type = "number",
  39413. description = "The number of seconds to sleep for."
  39414. }
  39415. },
  39416. returns = {}
  39417. }
  39418. }
  39419. },
  39420. {
  39421. name = "step",
  39422. summary = "Steps the internal clock.",
  39423. description = "Steps the timer, returning the new delta time. This is called automatically in `lovr.run` and it's used to calculate the new `dt` to pass to `lovr.update`.",
  39424. key = "lovr.timer.step",
  39425. module = "lovr.timer",
  39426. variants = {
  39427. {
  39428. arguments = {},
  39429. returns = {
  39430. {
  39431. name = "delta",
  39432. type = "number",
  39433. description = "The amount of time since the last call to this function, in seconds."
  39434. }
  39435. }
  39436. }
  39437. }
  39438. }
  39439. },
  39440. objects = {}
  39441. },
  39442. {
  39443. name = "utf8",
  39444. tag = "libraries",
  39445. summary = "UTF-8 string processing.",
  39446. description = "LÖVR includes Lua 5.3's `utf8` library, even on Lua versions that don't support it. Lua's regular strings aren't utf8-aware, so this library makes it easier to work with multi-byte characters that are outside the ASCII range.\n\nSee the [Lua reference manual](https://www.lua.org/manual/5.3/manual.html#6.5) for documentation.",
  39447. key = "utf8",
  39448. enums = {},
  39449. examples = {
  39450. {
  39451. code = "local utf8 = require 'utf8'\n\nlocal str = 'LÖVR'\n\nprint(string.len(str)) --> prints 5, because Ö takes up 2 bytes\nprint(utf8.len(str)) --> prints 4"
  39452. }
  39453. },
  39454. external = true,
  39455. functions = {},
  39456. objects = {}
  39457. }
  39458. }
  39459. }