123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035 |
- return {
- callbacks = {
- {
- name = "conf",
- tag = "callbacks",
- summary = "Called to read configuration settings at startup.",
- description = "The `lovr.conf` callback lets you configure default settings for LÖVR. It is called once right before the game starts.\n\n:::note\nMake sure you put `lovr.conf` in a file called `conf.lua`, a special file that's loaded before the rest of the framework initializes.\n:::",
- key = "lovr.conf",
- module = "lovr",
- examples = {
- {
- description = "A noop conf.lua that sets all configuration settings to their defaults:",
- code = "function lovr.conf(t)\n\n -- Set the project version and identity\n t.version = '0.18.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', 'simulator' }\n t.headset.start = true\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 -- Thread settings\n t.thread.workers = -1\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"
- }
- },
- 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.",
- related = {
- "lovr.load"
- },
- variants = {
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "The table to edit the configuration settings on.",
- table = {
- {
- name = "version",
- type = "string",
- description = "The version of LÖVR this project targets (not used yet)."
- },
- {
- name = "identity",
- type = "string",
- description = "A unique label for this project."
- },
- {
- name = "saveprecedence",
- type = "boolean",
- description = "Whether the files in the save directory should have precedence over files in the source archive."
- },
- {
- name = "modules",
- type = "table",
- description = "The set of enabled modules to use.",
- table = {
- {
- name = "audio",
- type = "boolean",
- description = "Whether the audio module should be enabled."
- },
- {
- name = "data",
- type = "boolean",
- description = "Whether the data module should be enabled."
- },
- {
- name = "event",
- type = "boolean",
- description = "Whether the event module should be enabled."
- },
- {
- name = "graphics",
- type = "boolean",
- description = "Whether the graphics module should be enabled."
- },
- {
- name = "headset",
- type = "boolean",
- description = "Whether the headset module should be enabled."
- },
- {
- name = "math",
- type = "boolean",
- description = "Whether the math module should be enabled."
- },
- {
- name = "physics",
- type = "boolean",
- description = "Whether the physics module should be enabled."
- },
- {
- name = "system",
- type = "boolean",
- description = "Whether the system module should be enabled."
- },
- {
- name = "thread",
- type = "boolean",
- description = "Whether the thread module should be enabled."
- },
- {
- name = "timer",
- type = "boolean",
- description = "Whether the timer module should be enabled."
- }
- }
- },
- {
- name = "audio",
- type = "table",
- description = "Configuration for the audio module.",
- table = {
- {
- name = "spatializer",
- type = "string",
- description = "An audio spatializer to use (`simple`, `oculus`, or `phonon`). If `nil`, all of them are attempted."
- },
- {
- name = "samplerate",
- type = "number",
- description = "The sample rate to use for audio playback."
- },
- {
- name = "start",
- type = "boolean",
- description = "Whether the playback device should be automatically started."
- }
- }
- },
- {
- name = "graphics",
- type = "table",
- description = "Configuration for the graphics module.",
- table = {
- {
- name = "debug",
- type = "boolean",
- description = "Whether debug messages from the GPU should get sent to lovr.log."
- },
- {
- name = "vsync",
- type = "boolean",
- description = "Whether vsync is enabled (forced off when VR is active)."
- },
- {
- name = "stencil",
- type = "boolean",
- description = "Whether the desktop window should have a stencil buffer."
- },
- {
- name = "antialias",
- type = "boolean",
- description = "Whether the desktop window rendering should be antialiased."
- },
- {
- name = "hdr",
- type = "boolean",
- description = "Whether the (**super experimental**) HDR mode should be enabled. See `lovr.graphics.isHDR`."
- },
- {
- name = "shadercache",
- type = "boolean",
- description = "Whether the shader cache should be loaded and saved to disk."
- }
- }
- },
- {
- name = "headset",
- type = "table",
- description = "Configuration for the headset.",
- table = {
- {
- name = "drivers",
- type = "table",
- description = "An ordered list of preferred headset drivers."
- },
- {
- name = "start",
- type = "boolean",
- description = "Whether a VR session should begin at startup."
- },
- {
- name = "supersample",
- type = "number",
- 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\"."
- },
- {
- name = "seated",
- type = "boolean",
- 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."
- },
- {
- name = "antialias",
- type = "boolean",
- description = "Whether headset rendering should be antialiased."
- },
- {
- name = "stencil",
- type = "boolean",
- description = "Whether headset rendering should have a stencil buffer."
- },
- {
- name = "submitdepth",
- type = "boolean",
- description = "Whether the depth buffer should be sent to the VR runtime (improves reprojection)."
- },
- {
- name = "overlay",
- type = "boolean",
- 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). Requires the `overlay` headset feature to be supported, see `lovr.headset.getFeatures`."
- }
- }
- },
- {
- name = "math",
- type = "table",
- description = "Configuration for the math module.",
- table = {
- {
- name = "globals",
- type = "boolean",
- description = "Whether vector object functions should be added to the global scope."
- }
- }
- },
- {
- name = "thread",
- type = "table",
- description = "Configuration for the thread module.",
- table = {
- {
- name = "workers",
- type = "number",
- description = "The number of worker threads to spawn. Can be negative, which will be added to the number of cores in the system."
- }
- }
- },
- {
- name = "window",
- type = "table",
- description = "Configuration for the window.",
- table = {
- {
- name = "width",
- type = "number",
- description = "The width of the window (or 0 to use the monitor width)."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the window (or 0 to use the monitor height) ."
- },
- {
- name = "fullscreen",
- type = "boolean",
- description = "Whether the window is fullscreen."
- },
- {
- name = "resizable",
- type = "boolean",
- description = "Whether the window is resizable."
- },
- {
- name = "title",
- type = "string",
- description = "The window title."
- },
- {
- name = "icon",
- type = "string",
- description = "The path to the window icon file."
- }
- }
- }
- }
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "draw",
- tag = "callbacks",
- summary = "Called continuously to render frames to the display.",
- 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.",
- key = "lovr.draw",
- module = "lovr",
- 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",
- related = {
- "lovr.mirror",
- "lovr.headset.getPass",
- "lovr.graphics.getWindowPass",
- "lovr.graphics.setBackgroundColor"
- },
- variants = {
- {
- arguments = {
- {
- name = "pass",
- type = "Pass",
- description = "A render pass targeting the main display (headset or window)."
- }
- },
- returns = {
- {
- name = "skip",
- type = "boolean",
- description = "If truthy, the input Pass will not be submitted to the GPU."
- }
- }
- }
- }
- },
- {
- name = "errhand",
- tag = "callbacks",
- summary = "Called when an error occurs.",
- 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.",
- key = "lovr.errhand",
- module = "lovr",
- examples = {
- {
- description = "The default error handler.",
- 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() ~= 'simulator' 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"
- }
- },
- related = {
- "lovr.quit"
- },
- variants = {
- {
- arguments = {
- {
- name = "message",
- type = "string",
- description = "The error message."
- }
- },
- returns = {
- {
- name = "handler",
- type = "function",
- description = "The error handler function. It should return nil to continue running, \"restart\" to restart the app, or a number representing an exit status.",
- arguments = {},
- returns = {
- {
- name = "result",
- type = "*"
- }
- }
- }
- }
- }
- }
- },
- {
- name = "filechanged",
- tag = "callbacks",
- summary = "Called when a file is changed.",
- description = "The `lovr.filechanged` callback is called when a file is changed. File watching must be enabled, either by passing `--watch` when starting LÖVR or by calling `lovr.filesystem.watch`.\n\nCurrently, only files in the source directory are watched. On Android, files in the sdcard directory are watched.",
- key = "lovr.filechanged",
- module = "lovr",
- notes = "LÖVR provides a default implementation for `lovr.filechanged` that restarts the project if a non-hidden file was changed:\n\n function lovr.filechanged(path)\n if not path:match('^%.') then\n lovr.event.restart()\n end\n end",
- related = {
- "lovr.filesystem.watch",
- "lovr.filesystem.unwatch"
- },
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path to the file that changed."
- },
- {
- name = "action",
- type = "FileAction",
- description = "What happened to the file."
- },
- {
- name = "oldpath",
- type = "string",
- description = "The old path, for `rename` actions."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "focus",
- tag = "callbacks",
- summary = "Called when the application gains or loses input focus.",
- description = "The `lovr.focus` callback is called whenever the application acquires or loses focus (for example, when opening or closing the system VR menu). The callback receives a `focused` argument, indicating whether or not the application is now focused. Additionally, both the headset and desktop window have separate focus states, so a `display` argument indicates which display gained or lost input focus. It may make sense to pause the game, reduce visual fidelity, or mute audio when the application loses focus.",
- key = "lovr.focus",
- module = "lovr",
- related = {
- "lovr.headset.isFocused",
- "lovr.visible"
- },
- variants = {
- {
- arguments = {
- {
- name = "focused",
- type = "boolean",
- description = "Whether the program is now focused."
- },
- {
- name = "display",
- type = "DisplayType",
- description = "Whether the headset or desktop window changed input focus."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "keypressed",
- tag = "callbacks",
- summary = "Called when a key is pressed.",
- description = "This callback is called when a key is pressed.",
- key = "lovr.keypressed",
- module = "lovr",
- related = {
- "lovr.system.wasKeyPressed",
- "lovr.keyreleased",
- "lovr.textinput",
- "lovr.system.isKeyDown"
- },
- variants = {
- {
- arguments = {
- {
- name = "key",
- type = "KeyCode",
- description = "The key that was pressed."
- },
- {
- name = "scancode",
- type = "number",
- description = "The id of the key (ignores keyboard layout, may vary between keyboards)."
- },
- {
- name = "repeat",
- type = "boolean",
- description = "Whether the event is the result of a key repeat instead of an actual press."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "keyreleased",
- tag = "callbacks",
- summary = "Called when a key is released.",
- description = "This callback is called when a key is released.",
- key = "lovr.keyreleased",
- module = "lovr",
- related = {
- "lovr.system.wasKeyReleased",
- "lovr.keypressed",
- "lovr.textinput",
- "lovr.system.isKeyDown"
- },
- variants = {
- {
- arguments = {
- {
- name = "key",
- type = "KeyCode",
- description = "The key that was released."
- },
- {
- name = "scancode",
- type = "number",
- description = "The id of the key (ignores keyboard layout, may vary between keyboards)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "load",
- tag = "callbacks",
- summary = "Called once at startup.",
- 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.",
- key = "lovr.load",
- module = "lovr",
- examples = {
- {
- 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"
- }
- },
- 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.",
- related = {
- "lovr.quit"
- },
- variants = {
- {
- arguments = {
- {
- name = "arg",
- type = "table",
- description = "The command line arguments provided to the program."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "log",
- tag = "callbacks",
- summary = "Called when a message is logged.",
- 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`. The `t.headset.debug` will enable OpenXR messages from the VR runtime, tagged as `XR`.\n\nIt is also possible to emit custom log messages using `lovr.event.push`, or by calling the callback.",
- key = "lovr.log",
- module = "lovr",
- related = {
- "Pass:text"
- },
- variants = {
- {
- arguments = {
- {
- name = "message",
- type = "string",
- description = "The log message. It may end in a newline."
- },
- {
- name = "level",
- type = "string",
- description = "The log level (`debug`, `info`, `warn`, or `error`)."
- },
- {
- name = "tag",
- type = "string",
- description = "The log tag."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "mirror",
- tag = "callbacks",
- summary = "Called to render content to the desktop window.",
- 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.",
- key = "lovr.mirror",
- module = "lovr",
- examples = {
- {
- 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.",
- 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"
- }
- },
- related = {
- "lovr.system.openWindow",
- "lovr.draw"
- },
- variants = {
- {
- arguments = {
- {
- name = "pass",
- type = "Pass",
- description = "A render pass targeting the window."
- }
- },
- returns = {
- {
- name = "skip",
- type = "boolean",
- description = "If truthy, the input Pass will not be submitted to the GPU."
- }
- }
- }
- }
- },
- {
- name = "mount",
- tag = "callbacks",
- summary = "Called when the headset is put on or taken off.",
- description = "The `lovr.mount` callback is called when the headset is put on or taken off.",
- key = "lovr.mount",
- module = "lovr",
- related = {
- "lovr.headset.isMounted"
- },
- variants = {
- {
- arguments = {
- {
- name = "mounted",
- type = "boolean",
- description = "Whether the headset is mounted."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "mousemoved",
- tag = "callbacks",
- summary = "Called when the mouse is moved.",
- description = "This callback is called when the mouse is moved.",
- key = "lovr.mousemoved",
- module = "lovr",
- related = {
- "lovr.mousepressed",
- "lovr.mousereleased",
- "lovr.wheelmoved",
- "lovr.system.getMouseX",
- "lovr.system.getMouseY",
- "lovr.system.getMousePosition"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The new x position of the mouse."
- },
- {
- name = "y",
- type = "number",
- description = "The new y position of the mouse."
- },
- {
- name = "dx",
- type = "number",
- description = "The movement on the x axis since the last mousemove event."
- },
- {
- name = "dy",
- type = "number",
- description = "The movement on the y axis since the last mousemove event."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "mousepressed",
- tag = "callbacks",
- summary = "Called when a mouse button is pressed.",
- description = "This callback is called when a mouse button is pressed.",
- key = "lovr.mousepressed",
- module = "lovr",
- related = {
- "lovr.mousereleased",
- "lovr.mousemoved",
- "lovr.wheelmoved",
- "lovr.system.isMouseDown"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the mouse when the button was pressed."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the mouse when the button was pressed."
- },
- {
- name = "button",
- type = "number",
- 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."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "mousereleased",
- tag = "callbacks",
- summary = "Called when a mouse button is released.",
- description = "This callback is called when a mouse button is released.",
- key = "lovr.mousereleased",
- module = "lovr",
- related = {
- "lovr.mousepressed",
- "lovr.mousemoved",
- "lovr.wheelmoved",
- "lovr.system.isMouseDown"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the mouse when the button was released."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the mouse when the button was released."
- },
- {
- name = "button",
- type = "number",
- 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."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "permission",
- tag = "callbacks",
- summary = "Called when a permission request is answered.",
- description = "This callback contains a permission response previously requested with `lovr.system.requestPermission`. The callback contains information on whether permission was granted or denied.",
- key = "lovr.permission",
- module = "lovr",
- related = {
- "lovr.system.requestPermission"
- },
- variants = {
- {
- arguments = {
- {
- name = "permission",
- type = "Permission",
- description = "The type of permission."
- },
- {
- name = "granted",
- type = "boolean",
- description = "Whether permission was granted or denied."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "quit",
- tag = "callbacks",
- summary = "Called before quitting.",
- 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.",
- key = "lovr.quit",
- module = "lovr",
- examples = {
- {
- code = "function lovr.quit()\n if shouldQuit() then\n return false\n else\n return true\n end\nend"
- }
- },
- related = {
- "lovr.event.quit",
- "lovr.load"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "abort",
- type = "boolean",
- description = "Whether quitting should be aborted."
- }
- }
- }
- }
- },
- {
- name = "recenter",
- tag = "callbacks",
- summary = "Called when the user recenters the coordinate space.",
- 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`.",
- key = "lovr.recenter",
- module = "lovr",
- 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.",
- related = {
- "lovr.headset.getBoundsWidth",
- "lovr.headset.getBoundsDepth",
- "lovr.headset.getBoundsDimensions",
- "lovr.headset.getBoundsGeometry",
- "lovr.headset.isSeated"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "resize",
- tag = "callbacks",
- summary = "Called when the window is resized.",
- description = "This callback is called when the desktop window is resized.",
- key = "lovr.resize",
- module = "lovr",
- related = {
- "Pass:getDimensions",
- "Pass:getWidth",
- "Pass:getHeight",
- "lovr.headset.getDisplayDimensions",
- "lovr.conf"
- },
- variants = {
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The new width of the window."
- },
- {
- name = "height",
- type = "number",
- description = "The new height of the window."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "restart",
- tag = "callbacks",
- summary = "Called when restarting.",
- 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.",
- key = "lovr.restart",
- module = "lovr",
- examples = {
- {
- code = "function lovr.restart()\n return currentLevel:getName()\nend"
- }
- },
- notes = "Only nil, booleans, numbers, and strings are supported types for the return value.",
- related = {
- "lovr.event.restart",
- "lovr.load",
- "lovr.quit"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "cookie",
- type = "*",
- description = "The value to send to the next `lovr.load`."
- }
- }
- }
- }
- },
- {
- name = "run",
- tag = "callbacks",
- summary = "The main entry point.",
- 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.",
- key = "lovr.run",
- module = "lovr",
- examples = {
- {
- description = "The default `lovr.run`:",
- 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 return 'restart', lovr.restart and lovr.restart()\n elseif name == 'quit' and (not lovr.quit or not lovr.quit(a)) then return a or 0\n elseif name ~= 'quit' and 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 and lovr.headset.isActive() 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"
- }
- },
- 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.",
- related = {
- "lovr.load",
- "lovr.quit"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "loop",
- type = "function",
- description = "The main loop function.",
- arguments = {},
- returns = {
- {
- name = "result",
- type = "*"
- }
- }
- }
- }
- }
- }
- },
- {
- name = "textinput",
- tag = "callbacks",
- summary = "Called when text has been entered.",
- 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 `!`.",
- key = "lovr.textinput",
- module = "lovr",
- 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.",
- related = {
- "lovr.keypressed",
- "lovr.keyreleased"
- },
- variants = {
- {
- arguments = {
- {
- name = "text",
- type = "string",
- description = "The UTF-8 encoded character."
- },
- {
- name = "code",
- type = "number",
- description = "The integer codepoint of the character."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "threaderror",
- tag = "callbacks",
- summary = "Called when an error occurs in a thread.",
- 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.",
- key = "lovr.threaderror",
- module = "lovr",
- related = {
- "Thread",
- "Thread:getError",
- "lovr.errhand"
- },
- variants = {
- {
- arguments = {
- {
- name = "thread",
- type = "Thread",
- description = "The Thread that errored."
- },
- {
- name = "message",
- type = "string",
- description = "The error message."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "update",
- tag = "callbacks",
- summary = "Called every frame to update the application logic.",
- 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.",
- key = "lovr.update",
- module = "lovr",
- examples = {
- {
- code = "function lovr.update(dt)\n ball.vy = ball.vy + ball.gravity * dt\n ball.y = ball.y + ball.vy * dt\nend"
- }
- },
- related = {
- "lovr.timer.getDelta"
- },
- variants = {
- {
- arguments = {
- {
- name = "dt",
- type = "number",
- description = "The number of seconds elapsed since the last update."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "visible",
- tag = "callbacks",
- summary = "Called when the application gains or loses visibility.",
- 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`.\n\nThis event is also fired when the desktop window is minimized or restored. It's possible to distinguish between the headset and window using the `display` parameter.",
- key = "lovr.visible",
- module = "lovr",
- related = {
- "lovr.headset.isVisible",
- "lovr.focus"
- },
- variants = {
- {
- arguments = {
- {
- name = "visible",
- type = "boolean",
- description = "Whether the application is visible."
- },
- {
- name = "display",
- type = "DisplayType",
- description = "Whether the headset or desktop window changed visibility."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "wheelmoved",
- tag = "callbacks",
- summary = "Called when a mouse wheel is moved.",
- description = "This callback is called on scroll action, from a mouse wheel or a touchpad",
- key = "lovr.wheelmoved",
- module = "lovr",
- related = {
- "lovr.mousepressed",
- "lovr.mousereleased",
- "lovr.mousemoved",
- "lovr.system.isMouseDown"
- },
- variants = {
- {
- arguments = {
- {
- name = "dx",
- type = "number",
- description = "The relative horizontal motion; rightward movement resuts in positive values."
- },
- {
- name = "dy",
- type = "number",
- description = "The relative vertical motion; upward movement results in positive values."
- }
- },
- returns = {}
- }
- }
- }
- },
- modules = {
- {
- name = "enet",
- tag = "libraries",
- summary = "UDP networking library.",
- 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).",
- key = "enet",
- enums = {},
- examples = {
- {
- 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.",
- 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"
- }
- },
- external = true,
- functions = {},
- objects = {}
- },
- {
- name = "http",
- tag = "libraries",
- summary = "HTTP(S) requests.",
- 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.",
- key = "http",
- enums = {},
- examples = {
- {
- 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"
- }
- },
- external = true,
- functions = {},
- notes = "On Linux, this module requires the `curl` library to be installed. Example on Debian-based distributions:\n\n sudo apt install libcurl4",
- objects = {}
- },
- {
- name = "lovr",
- summary = "In the beginning, there was nothing.",
- 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**.",
- key = "lovr",
- enums = {},
- functions = {
- {
- name = "getVersion",
- tag = "version",
- summary = "Get the current version.",
- description = "Get the current major, minor, and patch version of LÖVR.",
- key = "lovr.getVersion",
- module = "lovr",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "major",
- type = "number",
- description = "The major version."
- },
- {
- name = "minor",
- type = "number",
- description = "The minor version."
- },
- {
- name = "patch",
- type = "number",
- description = "The patch number."
- },
- {
- name = "codename",
- type = "string",
- description = "The version codename."
- },
- {
- name = "commit",
- type = "string",
- description = "The commit hash (not available in all builds)."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "Object",
- summary = "The base object.",
- description = "The superclass of all LÖVR objects. All objects have these methods.",
- key = "Object",
- module = "lovr",
- methods = {
- {
- name = "release",
- summary = "Immediately release the Lua reference to an object.",
- 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.",
- key = "Object:release",
- module = "lovr",
- 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).",
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "type",
- summary = "Get the type name of the object.",
- description = "Returns the name of the object's type as a string.",
- key = "Object:type",
- module = "lovr",
- examples = {
- {
- code = "function isTexture(obj)\n return type(obj) == 'userdata' and obj:type() == 'Texture'\nend"
- }
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "type",
- type = "string",
- description = "The type of the object."
- }
- }
- }
- }
- }
- },
- notes = "Note that the functions here don't apply to any vector objects, see `Vectors`."
- }
- },
- sections = {
- {
- name = "Modules",
- tag = "modules",
- 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."
- },
- {
- name = "Callbacks",
- tag = "callbacks",
- 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."
- },
- {
- name = "Version",
- tag = "version",
- description = "This function returns the current version of LÖVR."
- },
- {
- name = "Libraries",
- tag = "libraries",
- description = "LÖVR bundles a few third-party modules by default."
- }
- }
- },
- {
- name = "audio",
- tag = "modules",
- summary = "Plays sound.",
- 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.",
- key = "lovr.audio",
- enums = {
- {
- name = "AudioMaterial",
- summary = "Different types of audio materials.",
- description = "Different types of audio material presets, for use with `lovr.audio.setGeometry`.",
- key = "AudioMaterial",
- module = "lovr.audio",
- values = {
- {
- name = "generic",
- description = "Generic default audio material."
- },
- {
- name = "brick",
- description = "Brick."
- },
- {
- name = "carpet",
- description = "Carpet."
- },
- {
- name = "ceramic",
- description = "Ceramic."
- },
- {
- name = "concrete",
- description = "Concrete."
- },
- {
- name = "glass",
- description = "Glass."
- },
- {
- name = "gravel",
- description = "Gravel."
- },
- {
- name = "metal",
- description = "Metal."
- },
- {
- name = "plaster",
- description = "Plaster."
- },
- {
- name = "rock",
- description = "Rock."
- },
- {
- name = "wood",
- description = "Wood."
- }
- }
- },
- {
- name = "AudioShareMode",
- summary = "How audio devices are shared on the system.",
- 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.",
- key = "AudioShareMode",
- module = "lovr.audio",
- related = {
- "lovr.audio.setDevice"
- },
- values = {
- {
- name = "shared",
- description = "Shared mode."
- },
- {
- name = "exclusive",
- description = "Exclusive mode."
- }
- }
- },
- {
- name = "AudioType",
- summary = "Different types of audio devices",
- description = "When referencing audio devices, this indicates whether it's the playback or capture device.",
- key = "AudioType",
- module = "lovr.audio",
- related = {
- "lovr.audio.getDevices",
- "lovr.audio.setDevice",
- "lovr.audio.start",
- "lovr.audio.stop",
- "lovr.audio.isStarted"
- },
- values = {
- {
- name = "playback",
- description = "The playback device (speakers, headphones)."
- },
- {
- name = "capture",
- description = "The capture device (microphone)."
- }
- }
- },
- {
- name = "Effect",
- summary = "Different types of Source effects.",
- description = "Different types of effects that can be applied with `Source:setEffectEnabled`.",
- key = "Effect",
- module = "lovr.audio",
- 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.",
- values = {
- {
- name = "absorption",
- description = "Models absorption as sound travels through the air, water, etc."
- },
- {
- name = "attenuation",
- description = "Decreases audio volume with distance (1 / max(distance, 1))."
- },
- {
- name = "occlusion",
- description = "Causes audio to drop off when the Source is occluded by geometry."
- },
- {
- name = "reverb",
- description = "Models reverb caused by audio bouncing off of geometry."
- },
- {
- name = "spatialization",
- description = "Spatializes the Source using either simple panning or an HRTF."
- },
- {
- name = "transmission",
- description = "Causes audio to be heard through walls when occluded, based on audio materials."
- }
- }
- },
- {
- name = "TimeUnit",
- summary = "Time units for sound samples.",
- 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).",
- key = "TimeUnit",
- module = "lovr.audio",
- values = {
- {
- name = "seconds",
- description = "Seconds."
- },
- {
- name = "frames",
- description = "Frames."
- }
- }
- },
- {
- name = "VolumeUnit",
- summary = "Different units of volume.",
- 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.",
- key = "VolumeUnit",
- module = "lovr.audio",
- values = {
- {
- name = "linear",
- description = "Linear volume range."
- },
- {
- name = "db",
- description = "Decibels."
- }
- }
- }
- },
- functions = {
- {
- name = "getAbsorption",
- tag = "listener",
- summary = "Get the absorption coefficients.",
- 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.",
- key = "lovr.audio.getAbsorption",
- module = "lovr.audio",
- 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.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "low",
- type = "number",
- description = "The absorption coefficient for the low frequency band."
- },
- {
- name = "mid",
- type = "number",
- description = "The absorption coefficient for the mid frequency band."
- },
- {
- name = "high",
- type = "number",
- description = "The absorption coefficient for the high frequency band."
- }
- }
- }
- }
- },
- {
- name = "getDevice",
- tag = "devices",
- summary = "Get the current audio device.",
- description = "Returns information about the active playback or capture device.",
- key = "lovr.audio.getDevice",
- module = "lovr.audio",
- notes = "If no device has been set yet, this function returns `nil`.\n\nThe device doesn't need to be started.",
- related = {
- "lovr.audio.getDevices",
- "lovr.audio.setDevice"
- },
- variants = {
- {
- arguments = {
- {
- name = "type",
- type = "AudioType",
- description = "The type of device to query.",
- default = "'playback'"
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the device."
- },
- {
- name = "id",
- type = "userdata",
- description = "The opaque id of the device."
- }
- }
- }
- }
- },
- {
- name = "getDevices",
- tag = "devices",
- summary = "Get a list of audio devices.",
- 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`.",
- key = "lovr.audio.getDevices",
- module = "lovr.audio",
- related = {
- "lovr.audio.setDevice",
- "lovr.audio.getDevice",
- "lovr.audio.start",
- "lovr.audio.stop"
- },
- variants = {
- {
- arguments = {
- {
- name = "type",
- type = "AudioType",
- description = "The type of devices to query (playback or capture).",
- default = "'playback'"
- }
- },
- returns = {
- {
- name = "devices",
- type = "table",
- description = "The list of devices.",
- table = {
- {
- name = "[].id",
- type = "userdata",
- description = "A unique, opaque id for the device."
- },
- {
- name = "[].name",
- type = "string",
- description = "A human readable name for the device."
- },
- {
- name = "[].default",
- type = "boolean",
- description = "Whether the device is the default audio device."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- tag = "listener",
- summary = "Get the orientation of the listener.",
- description = "Returns the orientation of the virtual audio listener in angle/axis representation.",
- key = "lovr.audio.getOrientation",
- module = "lovr.audio",
- related = {
- "lovr.audio.getPosition",
- "lovr.audio.getPose",
- "Source:getOrientation"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the listener is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- tag = "listener",
- summary = "Get the pose of the listener.",
- description = "Returns the position and orientation of the virtual audio listener.",
- key = "lovr.audio.getPose",
- module = "lovr.audio",
- related = {
- "lovr.audio.getPosition",
- "lovr.audio.getOrientation",
- "Source:getPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the listener, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the listener, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the listener, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the listener is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- tag = "listener",
- summary = "Get the position of the listener.",
- description = "Returns the position of the virtual audio listener, in meters.",
- key = "lovr.audio.getPosition",
- module = "lovr.audio",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the listener."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the listener."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the listener."
- }
- }
- }
- }
- },
- {
- name = "getSampleRate",
- tag = "devices",
- summary = "Get the playback device sample rate.",
- description = "Returns the sample rate used by the playback device. This can be changed using `lovr.conf`.",
- key = "lovr.audio.getSampleRate",
- module = "lovr.audio",
- related = {
- "lovr.conf"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "rate",
- type = "number",
- description = "The sample rate of the playback device, in Hz."
- }
- }
- }
- }
- },
- {
- name = "getSpatializer",
- tag = "listener",
- summary = "Get the name of the active spatializer",
- 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`.",
- key = "lovr.audio.getSpatializer",
- module = "lovr.audio",
- 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>",
- related = {
- "lovr.conf"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "spatializer",
- type = "string",
- description = "The name of the active spatializer."
- }
- }
- }
- }
- },
- {
- name = "getVolume",
- tag = "listener",
- summary = "Get the master volume.",
- description = "Returns the master volume. All audio sent to the playback device has its volume multiplied by this factor.",
- key = "lovr.audio.getVolume",
- module = "lovr.audio",
- notes = "The default volume is 1.0 (0 dB).",
- variants = {
- {
- arguments = {
- {
- name = "units",
- type = "VolumeUnit",
- description = "The units to return (linear or db).",
- default = "'linear'"
- }
- },
- returns = {
- {
- name = "volume",
- type = "number",
- description = "The master volume."
- }
- }
- }
- }
- },
- {
- name = "isStarted",
- tag = "devices",
- summary = "Check if an audio device is started.",
- description = "Returns whether an audio device is started.",
- key = "lovr.audio.isStarted",
- module = "lovr.audio",
- related = {
- "lovr.audio.start",
- "lovr.audio.stop"
- },
- variants = {
- {
- arguments = {
- {
- name = "type",
- type = "AudioType",
- description = "The type of device to check.",
- default = "'playback'"
- }
- },
- returns = {
- {
- name = "started",
- type = "boolean",
- description = "Whether the device is active."
- }
- }
- }
- }
- },
- {
- name = "newSource",
- tag = "sources",
- summary = "Create a new Source.",
- description = "Creates a new Source from an ogg, wav, or mp3 file.",
- key = "lovr.audio.newSource",
- module = "lovr.audio",
- examples = {
- {
- 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"
- }
- },
- related = {
- "Source:clone"
- },
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The filename of the sound to load."
- },
- {
- name = "options",
- type = "table",
- description = "Optional options.",
- table = {
- {
- name = "decode",
- type = "boolean",
- 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.",
- default = "false"
- },
- {
- name = "pitchable",
- type = "boolean",
- description = "Whether the pitch of the Source can be changed with `Source:setPitch`. Setting this to false will improve performance slightly.",
- default = "true"
- },
- {
- name = "spatial",
- type = "boolean",
- 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.",
- default = "true"
- },
- {
- name = "effects",
- type = "table",
- 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.",
- default = "nil"
- }
- }
- }
- },
- returns = {
- {
- name = "source",
- type = "Source",
- description = "The new Source."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob containing the Source data."
- },
- {
- name = "options",
- type = "table",
- description = "Optional options.",
- table = {
- {
- name = "decode",
- type = "boolean",
- 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.",
- default = "false"
- },
- {
- name = "pitchable",
- type = "boolean",
- description = "Whether the pitch of the Source can be changed with `Source:setPitch`. Setting this to false will improve performance slightly.",
- default = "true"
- },
- {
- name = "spatial",
- type = "boolean",
- 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.",
- default = "true"
- },
- {
- name = "effects",
- type = "table",
- 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.",
- default = "nil"
- }
- }
- }
- },
- returns = {
- {
- name = "source",
- type = "Source",
- description = "The new Source."
- }
- }
- },
- {
- arguments = {
- {
- name = "sound",
- type = "Sound",
- description = "The Sound containing raw audio samples to play."
- },
- {
- name = "options",
- type = "table",
- description = "Optional options.",
- table = {
- {
- name = "decode",
- type = "boolean",
- 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.",
- default = "false"
- },
- {
- name = "pitchable",
- type = "boolean",
- description = "Whether the pitch of the Source can be changed with `Source:setPitch`. Setting this to false will improve performance slightly.",
- default = "true"
- },
- {
- name = "spatial",
- type = "boolean",
- 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.",
- default = "true"
- },
- {
- name = "effects",
- type = "table",
- 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.",
- default = "nil"
- }
- }
- }
- },
- returns = {
- {
- name = "source",
- type = "Source",
- description = "The new Source."
- }
- }
- }
- }
- },
- {
- name = "setAbsorption",
- tag = "listener",
- summary = "Set the absorption coefficients.",
- 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.",
- key = "lovr.audio.setAbsorption",
- module = "lovr.audio",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "low",
- type = "number",
- description = "The absorption coefficient for the low frequency band."
- },
- {
- name = "mid",
- type = "number",
- description = "The absorption coefficient for the mid frequency band."
- },
- {
- name = "high",
- type = "number",
- description = "The absorption coefficient for the high frequency band."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDevice",
- tag = "devices",
- summary = "Switch audio devices.",
- 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.",
- key = "lovr.audio.setDevice",
- module = "lovr.audio",
- related = {
- "lovr.audio.getDevice",
- "lovr.audio.getDevices",
- "lovr.audio.start",
- "lovr.audio.stop"
- },
- variants = {
- {
- arguments = {
- {
- name = "type",
- type = "AudioType",
- description = "The device to switch.",
- default = "'playback'"
- },
- {
- name = "id",
- type = "userdata",
- description = "The id of the device to use, or `nil` to use the default device.",
- default = "nil"
- },
- {
- name = "sink",
- type = "Sound",
- description = "An optional audio stream to use as a sink for the device.",
- default = "nil"
- },
- {
- name = "mode",
- type = "AudioShareMode",
- description = "The sharing mode for the device.",
- default = "shared"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether creating the audio device succeeded."
- }
- }
- }
- }
- },
- {
- name = "setGeometry",
- tag = "listener",
- summary = "Set the geometry for audio effects.",
- 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.",
- key = "lovr.audio.setGeometry",
- module = "lovr.audio",
- 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.",
- related = {
- "lovr.audio.getSpatializer",
- "Source:setEffectEnabled"
- },
- variants = {
- {
- arguments = {
- {
- name = "vertices",
- type = "table",
- 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."
- },
- {
- name = "indices",
- type = "table",
- 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)."
- },
- {
- name = "material",
- type = "AudioMaterial",
- description = "The acoustic material to use.",
- default = "'generic'"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether audio geometry is supported by the current spatializer and the geometry was loaded successfully."
- }
- }
- },
- {
- arguments = {
- {
- name = "model",
- type = "Model",
- description = "A model to use for the audio geometry."
- },
- {
- name = "material",
- type = "AudioMaterial",
- description = "The acoustic material to use.",
- default = "'generic'"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether audio geometry is supported by the current spatializer and the geometry was loaded successfully."
- }
- }
- }
- }
- },
- {
- name = "setOrientation",
- tag = "listener",
- summary = "Set the orientation of the listener.",
- description = "Sets the orientation of the virtual audio listener in angle/axis representation.",
- key = "lovr.audio.setOrientation",
- module = "lovr.audio",
- related = {
- "lovr.audio.setPosition",
- "lovr.audio.setPose",
- "Source:setOrientation"
- },
- variants = {
- {
- description = "Set the listener orientation using numbers.",
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the listener should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the listener orientation using a vector.",
- arguments = {
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the listener."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPose",
- tag = "listener",
- summary = "Set the pose of the listener.",
- description = "Sets the position and orientation of the virtual audio listener.",
- key = "lovr.audio.setPose",
- module = "lovr.audio",
- 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.",
- related = {
- "lovr.audio.setPosition",
- "lovr.audio.setOrientation",
- "Source:setPose"
- },
- variants = {
- {
- description = "Set the pose of the listener using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the listener."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the listener."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the listener."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the listener is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the pose of the listener using vector types.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the listener."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the listener."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPosition",
- tag = "listener",
- summary = "Set the position of the listener.",
- 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.",
- key = "lovr.audio.setPosition",
- module = "lovr.audio",
- related = {
- "lovr.audio.setOrientation",
- "lovr.audio.setPose",
- "Source:setPosition"
- },
- variants = {
- {
- description = "Set the listener position using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the listener."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the listener."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the listener."
- }
- },
- returns = {}
- },
- {
- description = "Set the listener position using a vector.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The listener position."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setVolume",
- tag = "listener",
- summary = "Set the master volume.",
- description = "Sets the master volume. All audio sent to the playback device has its volume multiplied by this factor.",
- key = "lovr.audio.setVolume",
- module = "lovr.audio",
- notes = "The volume will be clamped to a 0-1 range (0 dB).",
- variants = {
- {
- arguments = {
- {
- name = "volume",
- type = "number",
- description = "The master volume."
- },
- {
- name = "units",
- type = "VolumeUnit",
- description = "The units of the value.",
- default = "'linear'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "start",
- tag = "devices",
- summary = "Start an audio device.",
- 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`.",
- key = "lovr.audio.start",
- module = "lovr.audio",
- 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",
- related = {
- "lovr.audio.getDevices",
- "lovr.audio.setDevice",
- "lovr.audio.stop",
- "lovr.audio.isStarted",
- "lovr.system.requestPermission",
- "lovr.permission"
- },
- variants = {
- {
- arguments = {
- {
- name = "type",
- type = "AudioType",
- description = "The type of device to start.",
- default = "'playback'"
- }
- },
- returns = {
- {
- name = "started",
- type = "boolean",
- description = "Whether the device was successfully started."
- }
- }
- }
- }
- },
- {
- name = "stop",
- tag = "devices",
- summary = "Stop an audio device.",
- 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`",
- key = "lovr.audio.stop",
- module = "lovr.audio",
- notes = "Switching devices with `lovr.audio.setDevice` will stop the existing one.",
- related = {
- "lovr.audio.getDevices",
- "lovr.audio.setDevice",
- "lovr.audio.start",
- "lovr.audio.isStarted"
- },
- variants = {
- {
- arguments = {
- {
- name = "type",
- type = "AudioType",
- description = "The type of device to stop.",
- default = "'playback'"
- }
- },
- returns = {
- {
- name = "stopped",
- type = "boolean",
- description = "Whether the device was successfully stopped."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "Source",
- summary = "A playable sound object.",
- 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`.",
- key = "Source",
- module = "lovr.audio",
- constructors = {
- "lovr.audio.newSource",
- "Source:clone"
- },
- methods = {
- {
- name = "clone",
- tag = "sourceUtility",
- summary = "Create an identical copy of the Source.",
- 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.",
- key = "Source:clone",
- module = "lovr.audio",
- 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.",
- related = {
- "lovr.audio.newSource"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "source",
- type = "Source",
- description = "A genetically identical copy of the Source."
- }
- }
- }
- }
- },
- {
- name = "getDirectivity",
- tag = "sourceEffects",
- summary = "Get the directivity of the Source.",
- 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.",
- key = "Source:getDirectivity",
- module = "lovr.audio",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "weight",
- type = "number",
- description = "The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid."
- },
- {
- name = "power",
- type = "number",
- description = "The dipole power, controlling how focused the directivity shape is."
- }
- }
- }
- }
- },
- {
- name = "getDuration",
- tag = "sourcePlayback",
- summary = "Get the duration of the Source.",
- description = "Returns the duration of the Source.",
- key = "Source:getDuration",
- module = "lovr.audio",
- related = {
- "Sound:getDuration"
- },
- variants = {
- {
- arguments = {
- {
- name = "unit",
- type = "TimeUnit",
- description = "The unit to return.",
- default = "'seconds'"
- }
- },
- returns = {
- {
- name = "duration",
- type = "number",
- description = "The duration of the Source."
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- tag = "sourceEffects",
- summary = "Get the orientation of the Source.",
- description = "Returns the orientation of the Source, in angle/axis representation.",
- key = "Source:getOrientation",
- module = "lovr.audio",
- related = {
- "Source:getPosition",
- "Source:getPose",
- "lovr.audio.getOrientation"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Source is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPitch",
- tag = "sourcePlayback",
- summary = "Get the pitch of the Source.",
- description = "Returns the pitch of the Source.",
- key = "Source:getPitch",
- module = "lovr.audio",
- 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.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "pitch",
- type = "number",
- description = "The pitch."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- tag = "sourceEffects",
- summary = "Get the pose of the Source.",
- description = "Returns the position and orientation of the Source.",
- key = "Source:getPose",
- module = "lovr.audio",
- related = {
- "Source:getPosition",
- "Source:getOrientation",
- "lovr.audio.getPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Source, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Source, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Source, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Source is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- tag = "sourceEffects",
- summary = "Get the position of the Source.",
- 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.",
- key = "Source:getPosition",
- module = "lovr.audio",
- related = {
- "Source:getOrientation",
- "Source:getPose",
- "lovr.audio.getPosition"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- }
- }
- }
- }
- },
- {
- name = "getRadius",
- tag = "sourceEffects",
- summary = "Get the radius of the Source.",
- 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.",
- key = "Source:getRadius",
- module = "lovr.audio",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the Source, in meters."
- }
- }
- }
- }
- },
- {
- name = "getSound",
- tag = "sourceUtility",
- summary = "Get the Sound object backing the Source.",
- 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`.",
- key = "Source:getSound",
- module = "lovr.audio",
- related = {
- "Source:clone",
- "lovr.audio.newSource"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "sound",
- type = "Sound",
- description = "The Sound object."
- }
- }
- }
- }
- },
- {
- name = "getVolume",
- tag = "sourcePlayback",
- summary = "Get the volume of the Source.",
- description = "Returns the current volume factor for the Source.",
- key = "Source:getVolume",
- module = "lovr.audio",
- variants = {
- {
- arguments = {
- {
- name = "units",
- type = "VolumeUnit",
- description = "The units to return (linear or db).",
- default = "'linear'"
- }
- },
- returns = {
- {
- name = "volume",
- type = "number",
- description = "The volume of the Source."
- }
- }
- }
- }
- },
- {
- name = "isEffectEnabled",
- tag = "sourceEffects",
- summary = "Check if an effect is enabled.",
- description = "Returns whether a given `Effect` is enabled for the Source.",
- key = "Source:isEffectEnabled",
- module = "lovr.audio",
- 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.",
- related = {
- "Source:isSpatial"
- },
- variants = {
- {
- arguments = {
- {
- name = "effect",
- type = "Effect",
- description = "The effect."
- }
- },
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether the effect is enabled."
- }
- }
- }
- }
- },
- {
- name = "isLooping",
- tag = "sourcePlayback",
- summary = "Check if the Source is looping.",
- description = "Returns whether or not the Source will loop when it finishes.",
- key = "Source:isLooping",
- module = "lovr.audio",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "looping",
- type = "boolean",
- description = "Whether or not the Source is looping."
- }
- }
- }
- }
- },
- {
- name = "isPlaying",
- tag = "sourcePlayback",
- summary = "Check if the Source is playing.",
- description = "Returns whether or not the Source is playing.",
- key = "Source:isPlaying",
- module = "lovr.audio",
- related = {
- "Source:play",
- "Source:pause",
- "Source:stop"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "playing",
- type = "boolean",
- description = "Whether the Source is playing."
- }
- }
- }
- }
- },
- {
- name = "isSpatial",
- tag = "sourceEffects",
- summary = "Check if the Source is spatial.",
- 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.",
- key = "Source:isSpatial",
- module = "lovr.audio",
- related = {
- "Source:isEffectEnabled",
- "Source:setEffectEnabled"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "spatial",
- type = "boolean",
- description = "Whether the source is spatial."
- }
- }
- }
- }
- },
- {
- name = "pause",
- tag = "sourcePlayback",
- summary = "Pause the Source.",
- description = "Pauses the source. It can be resumed with `Source:resume` or `Source:play`. If a paused source is rewound, it will remain paused.",
- key = "Source:pause",
- module = "lovr.audio",
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "play",
- tag = "sourcePlayback",
- summary = "Play the Source.",
- description = "Plays the Source. This doesn't do anything if the Source is already playing.",
- key = "Source:play",
- module = "lovr.audio",
- 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`.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the Source successfully started playing."
- }
- }
- }
- }
- },
- {
- name = "seek",
- tag = "sourcePlayback",
- summary = "Set the playback position of the Source.",
- description = "Seeks the Source to the specified position.",
- key = "Source:seek",
- module = "lovr.audio",
- notes = "Seeking a Source backed by a stream `Sound` has no meaningful effect.",
- variants = {
- {
- arguments = {
- {
- name = "position",
- type = "number",
- description = "The position to seek to."
- },
- {
- name = "unit",
- type = "TimeUnit",
- description = "The units for the seek position.",
- default = "'seconds'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDirectivity",
- tag = "sourceEffects",
- summary = "Set the directivity of the Source.",
- 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.",
- key = "Source:setDirectivity",
- module = "lovr.audio",
- variants = {
- {
- arguments = {
- {
- name = "weight",
- type = "number",
- description = "The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid."
- },
- {
- name = "power",
- type = "number",
- description = "The dipole power, controlling how focused the directivity shape is."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setEffectEnabled",
- tag = "sourceEffects",
- summary = "Enable or disable an effect.",
- description = "Enables or disables an effect on the Source.",
- key = "Source:setEffectEnabled",
- module = "lovr.audio",
- 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.",
- related = {
- "Source:isSpatial"
- },
- variants = {
- {
- arguments = {
- {
- name = "effect",
- type = "Effect",
- description = "The effect."
- },
- {
- name = "enable",
- type = "boolean",
- description = "Whether the effect should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setLooping",
- tag = "sourcePlayback",
- summary = "Set whether or not the Source loops.",
- description = "Sets whether or not the Source loops.",
- key = "Source:setLooping",
- module = "lovr.audio",
- notes = "Attempting to loop a Source backed by a stream `Sound` will cause an error.",
- variants = {
- {
- arguments = {
- {
- name = "loop",
- type = "boolean",
- description = "Whether or not the Source will loop."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setOrientation",
- tag = "sourceEffects",
- summary = "Set the orientation of the Source.",
- description = "Sets the orientation of the Source in angle/axis representation.",
- key = "Source:setOrientation",
- module = "lovr.audio",
- related = {
- "Source:setPosition",
- "Source:setPose",
- "lovr.audio.setOrientation"
- },
- variants = {
- {
- description = "Set the orientation using angle/axis numbers.",
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Source should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the orientation using a quaternion.",
- arguments = {
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPitch",
- tag = "sourcePlayback",
- summary = "Set the pitch of the Source.",
- description = "Sets the pitch of the Source.",
- key = "Source:setPitch",
- module = "lovr.audio",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "pitch",
- type = "number",
- description = "The new pitch."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPose",
- tag = "sourceEffects",
- summary = "Set the pose of the Source.",
- description = "Sets the position and orientation of the Source.",
- key = "Source:setPose",
- module = "lovr.audio",
- notes = "The position doesn't have any defined units, but meters are used by convention.",
- related = {
- "Source:setPosition",
- "Source:setOrientation",
- "lovr.audio.setPose"
- },
- variants = {
- {
- description = "Set the pose using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Source."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Source."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Source."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Source is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the pose using vector types.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPosition",
- tag = "sourceEffects",
- summary = "Set the position of the Source.",
- 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.",
- key = "Source:setPosition",
- module = "lovr.audio",
- notes = "The position doesn't have any defined units, but meters are used by convention.",
- related = {
- "Source:setOrientation",
- "Source:setPose"
- },
- variants = {
- {
- description = "Set the position using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the position."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the position."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the position."
- }
- },
- returns = {}
- },
- {
- description = "Set the position using a vector.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setRadius",
- tag = "sourceEffects",
- summary = "Set the radius of the Source.",
- 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.",
- key = "Source:setRadius",
- module = "lovr.audio",
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The new radius of the Source, in meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setVolume",
- tag = "sourcePlayback",
- summary = "Set the volume of the Source.",
- description = "Sets the current volume factor for the Source.",
- key = "Source:setVolume",
- module = "lovr.audio",
- notes = "The volume will be clamped to a 0-1 range (0 dB).",
- variants = {
- {
- arguments = {
- {
- name = "volume",
- type = "number",
- description = "The new volume."
- },
- {
- name = "units",
- type = "VolumeUnit",
- description = "The units of the value.",
- default = "'linear'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "stop",
- tag = "sourcePlayback",
- summary = "Stop the Source.",
- description = "Stops the source, also rewinding it to the beginning.",
- key = "Source:stop",
- module = "lovr.audio",
- related = {
- "Source:play",
- "Source:pause",
- "Source:isPlaying"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "tell",
- tag = "sourcePlayback",
- summary = "Get the playback position of the Source.",
- description = "Returns the current playback position of the Source.",
- key = "Source:tell",
- module = "lovr.audio",
- notes = "The return value for Sources backed by a stream `Sound` has no meaning.",
- variants = {
- {
- arguments = {
- {
- name = "unit",
- type = "TimeUnit",
- description = "The unit to return.",
- default = "'seconds'"
- }
- },
- returns = {
- {
- name = "position",
- type = "number",
- description = "The current playback position."
- }
- }
- }
- }
- }
- },
- sections = {
- {
- name = "Playback",
- tag = "sourcePlayback"
- },
- {
- name = "Effects",
- tag = "sourceEffects"
- },
- {
- name = "Utility",
- tag = "sourceUtility"
- }
- }
- }
- },
- sections = {
- {
- name = "Sources",
- tag = "sources",
- description = "Sources are objects that represent a single sound instance."
- },
- {
- name = "Listener",
- tag = "listener",
- 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."
- },
- {
- name = "Devices",
- tag = "devices",
- 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`."
- }
- }
- },
- {
- name = "data",
- tag = "modules",
- summary = "Exposes low level functions for working with data.",
- description = "The `lovr.data` module provides functions for accessing underlying data representations for several LÖVR objects.",
- key = "lovr.data",
- enums = {
- {
- name = "AnimationProperty",
- summary = "Different animated properties.",
- description = "This indicates the different node properties that can be animated.",
- key = "AnimationProperty",
- module = "lovr.data",
- values = {
- {
- name = "translation",
- description = "Node translation."
- },
- {
- name = "rotation",
- description = "Node rotation."
- },
- {
- name = "scale",
- description = "Node scale."
- },
- {
- name = "weights",
- description = "Node blend shape weights."
- }
- }
- },
- {
- name = "AttributeType",
- summary = "Data types for vertex attributes in meshes.",
- description = "These are the data types that can be used by vertex data in meshes.",
- key = "AttributeType",
- module = "lovr.data",
- values = {
- {
- name = "i8",
- description = "Signed 8 bit integers (-128 to 127)."
- },
- {
- name = "u8",
- description = "Unsigned 8 bit integers (0 to 255)."
- },
- {
- name = "i16",
- description = "Signed 16 bit integers (-32768 to 32767)."
- },
- {
- name = "u16",
- description = "Unsigned 16 bit integers (0 to 65535)."
- },
- {
- name = "i32",
- description = "Signed 32 bit integers (-2147483648 to 2147483647)."
- },
- {
- name = "u32",
- description = "Unsigned 32 bit integers (0 to 429467295)."
- },
- {
- name = "f32",
- description = "Floating point numbers."
- }
- }
- },
- {
- name = "ChannelLayout",
- summary = "Different channel layouts for Sounds.",
- description = "Sounds can have different numbers of channels, and those channels can map to various speaker layouts.",
- key = "ChannelLayout",
- module = "lovr.data",
- related = {
- "lovr.data.newSound",
- "Sound:getFormat"
- },
- values = {
- {
- name = "mono",
- description = "1 channel."
- },
- {
- name = "stereo",
- description = "2 channels. The first channel is for the left speaker and the second is for the right."
- },
- {
- name = "ambisonic",
- 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."
- }
- }
- },
- {
- name = "DefaultAttribute",
- summary = "Attributes that can be loaded from a model.",
- description = "These are the different types of attributes that may be present in meshes loaded from models.",
- key = "DefaultAttribute",
- module = "lovr.data",
- values = {
- {
- name = "position",
- description = "Vertex positions."
- },
- {
- name = "normal",
- description = "Vertex normal vectors."
- },
- {
- name = "uv",
- description = "Vertex texture coordinates."
- },
- {
- name = "color",
- description = "Vertex colors."
- },
- {
- name = "tangent",
- description = "Vertex tangent vectors."
- },
- {
- name = "joints",
- description = "Vertex joint indices."
- },
- {
- name = "weights",
- description = "Vertex joint weights."
- }
- }
- },
- {
- name = "ModelDrawMode",
- summary = "Different draw modes for meshes in ModelDatas.",
- description = "The DrawMode of a mesh determines how its vertices are connected together.",
- key = "ModelDrawMode",
- module = "lovr.data",
- related = {
- "ModelData:getMeshDrawMode"
- },
- values = {
- {
- name = "points",
- description = "Each vertex is draw as a single point."
- },
- {
- name = "lines",
- description = "Every pair of vertices is drawn as a line."
- },
- {
- name = "linestrip",
- description = "Draws a single line through all of the vertices."
- },
- {
- name = "lineloop",
- description = "Draws a single line through all of the vertices, then connects back to the first vertex."
- },
- {
- name = "strip",
- description = "Vertices are rendered as triangles. After the first 3 vertices, each subsequent vertex connects to the previous two."
- },
- {
- name = "triangles",
- description = "Every 3 vertices forms a triangle."
- },
- {
- name = "fan",
- description = "Vertices are rendered as triangles. After the first 3 vertices, each subsequent vertex is connected to the previous vertex and the first vertex."
- }
- }
- },
- {
- name = "SampleFormat",
- summary = "Different data types for samples in a Sound.",
- description = "Sounds can store audio samples as 16 bit integers or 32 bit floats.",
- key = "SampleFormat",
- module = "lovr.data",
- related = {
- "lovr.data.newSound",
- "Sound:getFormat"
- },
- values = {
- {
- name = "f32",
- description = "32 bit floating point samples (between -1.0 and 1.0)."
- },
- {
- name = "i16",
- description = "16 bit integer samples (between -32768 and 32767)."
- }
- }
- },
- {
- name = "SmoothMode",
- summary = "Different ways to interpolate between animation keyframes.",
- description = "Different ways to interpolate between animation keyframes.",
- key = "SmoothMode",
- module = "lovr.data",
- values = {
- {
- name = "step",
- description = "The animated property will snap to the nearest keyframe."
- },
- {
- name = "linear",
- description = "The animated property will linearly interpolate between keyframes."
- },
- {
- name = "cubic",
- description = "The animated property will follow a smooth curve between nearby keyframes."
- }
- }
- },
- {
- name = "TextureFormat",
- summary = "Different pixel formats in `Image` and `Texture` objects.",
- 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.",
- key = "TextureFormat",
- module = "lovr.data",
- values = {
- {
- name = "r8",
- description = "One 8-bit channel. 1 byte per pixel."
- },
- {
- name = "rg8",
- description = "Two 8-bit channels. 2 bytes per pixel."
- },
- {
- name = "rgba8",
- description = "Four 8-bit channels. 4 bytes per pixel."
- },
- {
- name = "bgra8",
- description = "Four 8-bit channels. 4 bytes per pixel."
- },
- {
- name = "r16",
- description = "One 16-bit channel. 2 bytes per pixel."
- },
- {
- name = "rg16",
- description = "Two 16-bit channels. 4 bytes per pixel."
- },
- {
- name = "rgba16",
- description = "Four 16-bit channels. 8 bytes per pixel."
- },
- {
- name = "r16f",
- description = "One 16-bit floating point channel. 2 bytes per pixel."
- },
- {
- name = "rg16f",
- description = "Two 16-bit floating point channels. 4 bytes per pixel."
- },
- {
- name = "rgba16f",
- description = "Four 16-bit floating point channels. 8 bytes per pixel."
- },
- {
- name = "r32f",
- description = "One 32-bit floating point channel. 4 bytes per pixel."
- },
- {
- name = "rg32f",
- description = "Two 32-bit floating point channels. 8 bytes per pixel."
- },
- {
- name = "rgba32f",
- description = "Four 32-bit floating point channels. 16 bytes per pixel."
- },
- {
- name = "rgb565",
- description = "Packs three channels into 16 bits. 2 bytes per pixel."
- },
- {
- name = "rgb5a1",
- description = "Packs four channels into 16 bits, with \"cutout\" alpha. 2 bytes per pixel."
- },
- {
- name = "rgb10a2",
- description = "Packs four channels into 32 bits. 4 bytes per pixel."
- },
- {
- name = "rg11b10f",
- description = "Packs three unsigned floating point channels into 32 bits. 4 bytes per pixel."
- },
- {
- name = "d16",
- description = "One 16-bit depth channel. 2 bytes per pixel."
- },
- {
- name = "d24",
- description = "One 24-bit depth channel. 4 bytes per pixel."
- },
- {
- name = "d24s8",
- description = "One 24-bit depth channel and one 8-bit stencil channel. 4 bytes per pixel."
- },
- {
- name = "d32f",
- description = "One 32-bit floating point depth channel. 4 bytes per pixel."
- },
- {
- name = "d32fs8",
- description = "One 32-bit floating point depth channel and one 8-bit stencil channel. 5 bytes per pixel."
- },
- {
- name = "bc1",
- description = "3 channels. 8 bytes per 4x4 block, or 0.5 bytes per pixel. Good for opaque images."
- },
- {
- name = "bc2",
- 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."
- },
- {
- name = "bc3",
- description = "Four channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for color images with transparency."
- },
- {
- name = "bc4u",
- description = "One unsigned normalized channel. 8 bytes per 4x4 block or 0.5 bytes per pixel. Good for grayscale images, like heightmaps."
- },
- {
- name = "bc4s",
- 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."
- },
- {
- name = "bc5u",
- description = "Two unsigned normalized channels. 16 bytes per 4x4 block, or 1 byte per pixel. Good for normal maps."
- },
- {
- name = "bc5s",
- description = "Two signed normalized channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for normal maps."
- },
- {
- name = "bc6uf",
- description = "Three unsigned floating point channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for HDR images."
- },
- {
- name = "bc6sf",
- description = "Three floating point channels. 16 bytes per 4x4 block or 1 byte per pixel. Good for HDR images."
- },
- {
- name = "bc7",
- description = "Four channels. 16 bytes per 4x4 block or 1 byte per pixel. High quality. Good for most color images, including transparency."
- },
- {
- name = "astc4x4",
- description = "Four channels, 16 bytes per 4x4 block or 1 byte per pixel."
- },
- {
- name = "astc5x4",
- description = "Four channels, 16 bytes per 5x4 block or 0.80 bytes per pixel."
- },
- {
- name = "astc5x5",
- description = "Four channels, 16 bytes per 5x5 block or 0.64 bytes per pixel."
- },
- {
- name = "astc6x5",
- description = "Four channels, 16 bytes per 6x5 block or 0.53 bytes per pixel."
- },
- {
- name = "astc6x6",
- description = "Four channels, 16 bytes per 6x6 block or 0.44 bytes per pixel."
- },
- {
- name = "astc8x5",
- description = "Four channels, 16 bytes per 8x5 block or 0.40 bytes per pixel."
- },
- {
- name = "astc8x6",
- description = "Four channels, 16 bytes per 8x6 block or 0.33 bytes per pixel."
- },
- {
- name = "astc8x8",
- description = "Four channels, 16 bytes per 8x8 block or 0.25 bytes per pixel."
- },
- {
- name = "astc10x5",
- description = "Four channels, 16 bytes per 10x5 block or 0.32 bytes per pixel."
- },
- {
- name = "astc10x6",
- description = "Four channels, 16 bytes per 10x6 block or 0.27 bytes per pixel."
- },
- {
- name = "astc10x8",
- description = "Four channels, 16 bytes per 10x8 block or 0.20 bytes per pixel."
- },
- {
- name = "astc10x10",
- description = "Four channels, 16 bytes per 10x10 block or 0.16 bytes per pixel."
- },
- {
- name = "astc12x10",
- description = "Four channels, 16 bytes per 12x10 block or 0.13 bytes per pixel."
- },
- {
- name = "astc12x12",
- description = "Four channels, 16 bytes per 12x12 block or 0.11 bytes per pixel."
- }
- }
- }
- },
- functions = {
- {
- name = "newBlob",
- summary = "Create a new Blob.",
- description = "Creates a new Blob.",
- key = "lovr.data.newBlob",
- module = "lovr.data",
- related = {
- "lovr.filesystem.newBlob"
- },
- variants = {
- {
- arguments = {
- {
- name = "size",
- type = "number",
- description = "The amount of data to allocate for the Blob, in bytes. All of the bytes will be filled with zeroes."
- },
- {
- name = "name",
- type = "string",
- description = "A name for the Blob (used in error messages)",
- default = "''"
- }
- },
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The new Blob."
- }
- }
- },
- {
- arguments = {
- {
- name = "contents",
- type = "string",
- description = "A string to use for the Blob's contents."
- },
- {
- name = "name",
- type = "string",
- description = "A name for the Blob (used in error messages)",
- default = "''"
- }
- },
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The new Blob."
- }
- }
- },
- {
- arguments = {
- {
- name = "source",
- type = "Blob",
- description = "A Blob to copy the contents from."
- },
- {
- name = "name",
- type = "string",
- description = "A name for the Blob (used in error messages)",
- default = "''"
- }
- },
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The new Blob."
- }
- }
- }
- }
- },
- {
- name = "newImage",
- summary = "Create a new Image.",
- 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.",
- key = "lovr.data.newImage",
- module = "lovr.data",
- 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.",
- variants = {
- {
- description = "Load image data from a file.",
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The filename of the image to load."
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The new Image."
- }
- }
- },
- {
- description = "Create an Image with a given size and pixel format.",
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the texture."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture's pixels.",
- default = "rgba8"
- },
- {
- name = "data",
- type = "Blob",
- description = "Raw pixel values to use as the contents. If `nil`, the data will all be zero.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The new Image."
- }
- }
- },
- {
- description = "Clone an existing Image.",
- arguments = {
- {
- name = "source",
- type = "Image",
- description = "The Image to clone."
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The new Image."
- }
- }
- },
- {
- description = "Decode image data from a Blob.",
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob containing image data to decode."
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The new Image."
- }
- }
- }
- }
- },
- {
- name = "newModelData",
- summary = "Create a new ModelData.",
- description = "Loads a 3D model from a file. The supported 3D file formats are OBJ and glTF.",
- key = "lovr.data.newModelData",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The filename of the model to load."
- }
- },
- returns = {
- {
- name = "modelData",
- type = "ModelData",
- description = "The new ModelData."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob containing data for a model to decode."
- }
- },
- returns = {
- {
- name = "modelData",
- type = "ModelData",
- description = "The new ModelData."
- }
- }
- }
- }
- },
- {
- name = "newRasterizer",
- summary = "Create a new Rasterizer.",
- description = "Creates a new Rasterizer from a TTF or BMFont file.",
- key = "lovr.data.newRasterizer",
- module = "lovr.data",
- variants = {
- {
- description = "Create a Rasterizer for the default font included with LÖVR (Varela Round).",
- arguments = {
- {
- name = "size",
- type = "number",
- description = "The resolution to render the font at, in pixels (TTF only). Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations.",
- default = "32"
- }
- },
- returns = {
- {
- name = "rasterizer",
- type = "Rasterizer",
- description = "The new Rasterizer."
- }
- }
- },
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The filename of the font file to load."
- },
- {
- name = "size",
- type = "number",
- description = "The resolution to render the font at, in pixels (TTF only). Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations.",
- default = "32"
- }
- },
- returns = {
- {
- name = "rasterizer",
- type = "Rasterizer",
- description = "The new Rasterizer."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob containing font data."
- },
- {
- name = "size",
- type = "number",
- description = "The resolution to render the font at, in pixels (TTF only). Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations.",
- default = "32"
- }
- },
- returns = {
- {
- name = "rasterizer",
- type = "Rasterizer",
- description = "The new Rasterizer."
- }
- }
- }
- }
- },
- {
- name = "newSound",
- summary = "Create a new Sound.",
- 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.",
- key = "lovr.data.newSound",
- module = "lovr.data",
- 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.",
- variants = {
- {
- description = "Create a raw or stream Sound from a frame count and format info:",
- arguments = {
- {
- name = "frames",
- type = "number",
- description = "The number of frames the Sound can hold."
- },
- {
- name = "format",
- type = "SampleFormat",
- description = "The sample data type.",
- default = "'f32'"
- },
- {
- name = "channels",
- type = "ChannelLayout",
- description = "The channel layout.",
- default = "'stereo'"
- },
- {
- name = "sampleRate",
- type = "number",
- description = "The sample rate, in Hz.",
- default = "48000"
- },
- {
- name = "contents",
- type = "*",
- 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.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "sound",
- type = "Sound",
- description = "Sounds good."
- }
- }
- },
- {
- description = "Load a sound from a file. Compressed audio formats (OGG, MP3) can optionally be decoded into raw sounds.",
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The filename of a sound to load."
- },
- {
- name = "decode",
- type = "boolean",
- description = "Whether compressed audio files should be immediately decoded."
- }
- },
- returns = {
- {
- name = "sound",
- type = "Sound",
- description = "Sounds good."
- }
- }
- },
- {
- 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.",
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob containing audio file data to load."
- },
- {
- name = "decode",
- type = "boolean",
- description = "Whether compressed audio files should be immediately decoded."
- }
- },
- returns = {
- {
- name = "sound",
- type = "Sound",
- description = "Sounds good."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "Blob",
- summary = "A chunk of binary data.",
- 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.",
- key = "Blob",
- module = "lovr.data",
- constructors = {
- "lovr.data.newBlob",
- "lovr.filesystem.newBlob"
- },
- methods = {
- {
- name = "getSize",
- summary = "Get the size of the Blob, in bytes.",
- description = "Returns the size of the Blob's contents, in bytes.",
- key = "Blob:getSize",
- module = "lovr.data",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "bytes",
- type = "number",
- description = "The size of the Blob, in bytes."
- }
- }
- }
- }
- },
- {
- name = "getName",
- summary = "Get the label of the Blob.",
- 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.",
- key = "Blob:getName",
- module = "lovr.data",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the Blob."
- }
- }
- }
- }
- },
- {
- name = "getPointer",
- summary = "Get a raw pointer to the Blob's data.",
- 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!",
- key = "Blob:getPointer",
- module = "lovr.data",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "pointer",
- type = "userdata",
- description = "A pointer to the data."
- }
- }
- }
- }
- },
- {
- name = "getString",
- summary = "Get the Blob's contents as a string.",
- description = "Returns a binary string containing the Blob's data.",
- key = "Blob:getString",
- module = "lovr.data",
- examples = {
- {
- description = "Print each byte of the main.lua file:",
- code = "blob = lovr.filesystem.newBlob('main.lua')\nstr = blob:getString()\n\nfor i = 1, #str do\n print(string.byte(str, i))\nend"
- }
- },
- notes = "This effectively allocates a new copy of the Blob as a Lua string, so this should be avoided for really big Blobs!",
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A byte offset into the Blob where the string will start.",
- default = "0"
- },
- {
- name = "size",
- type = "number",
- 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.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "data",
- type = "string",
- description = "The Blob's data."
- }
- }
- }
- }
- },
- {
- name = "getI8",
- summary = "Unpack signed 8-bit integers from the Blob.",
- description = "Returns signed 8-bit integers from the data in the Blob.",
- key = "Blob:getI8",
- module = "lovr.data",
- related = {
- "Blob:setI8",
- "Blob:getU8",
- "Blob:getI16",
- "Blob:getU16",
- "Blob:getI32",
- "Blob:getU32",
- "Blob:getF32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of integers to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` signed 8-bit integers, from -128 to 127."
- }
- }
- }
- }
- },
- {
- name = "getU8",
- summary = "Unpack unsigned 8-bit integers from the Blob.",
- description = "Returns unsigned 8-bit integers from the data in the Blob.",
- key = "Blob:getU8",
- module = "lovr.data",
- related = {
- "Blob:setU8",
- "Blob:getI8",
- "Blob:getI16",
- "Blob:getU16",
- "Blob:getI32",
- "Blob:getU32",
- "Blob:getF32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of integers to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` unsigned 8-bit integers, from 0 to 255."
- }
- }
- }
- }
- },
- {
- name = "getI16",
- summary = "Unpack signed 16-bit integers from the Blob.",
- description = "Returns signed 16-bit integers from the data in the Blob.",
- key = "Blob:getI16",
- module = "lovr.data",
- related = {
- "Blob:setI16",
- "Blob:getI8",
- "Blob:getU8",
- "Blob:getU16",
- "Blob:getI32",
- "Blob:getU32",
- "Blob:getF32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of integers to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` signed 16-bit integers, from -32768 to 32767."
- }
- }
- }
- }
- },
- {
- name = "getU16",
- summary = "Unpack unsigned 16-bit integers from the Blob.",
- description = "Returns unsigned 16-bit integers from the data in the Blob.",
- key = "Blob:getU16",
- module = "lovr.data",
- related = {
- "Blob:setU16",
- "Blob:getI8",
- "Blob:getU8",
- "Blob:getI16",
- "Blob:getI32",
- "Blob:getU32",
- "Blob:getF32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of integers to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` unsigned 16-bit integers, from 0 to 65535."
- }
- }
- }
- }
- },
- {
- name = "getI32",
- summary = "Unpack signed 32-bit integers from the Blob.",
- description = "Returns signed 32-bit integers from the data in the Blob.",
- key = "Blob:getI32",
- module = "lovr.data",
- related = {
- "Blob:setI32",
- "Blob:getI8",
- "Blob:getU8",
- "Blob:getI16",
- "Blob:getU16",
- "Blob:getU32",
- "Blob:getF32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of integers to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` signed 32-bit integers, from -2147483648 to 2147483647."
- }
- }
- }
- }
- },
- {
- name = "getU32",
- summary = "Unpack unsigned 32-bit integers from the Blob.",
- description = "Returns unsigned 32-bit integers from the data in the Blob.",
- key = "Blob:getU32",
- module = "lovr.data",
- related = {
- "Blob:setU32",
- "Blob:getI8",
- "Blob:getU8",
- "Blob:getI16",
- "Blob:getU16",
- "Blob:getI32",
- "Blob:getF32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of integers to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` unsigned 32-bit integers, from 0 to 4294967296."
- }
- }
- }
- }
- },
- {
- name = "getF32",
- summary = "Unpack 32-bit floating point numbers from the Blob.",
- description = "Returns 32-bit floating point numbers from the data in the Blob.",
- key = "Blob:getF32",
- module = "lovr.data",
- related = {
- "Blob:setF32",
- "Blob:getI8",
- "Blob:getU8",
- "Blob:getI16",
- "Blob:getU16",
- "Blob:getI32",
- "Blob:getU32",
- "Blob:getF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of floats to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` 32-bit floats."
- }
- }
- }
- }
- },
- {
- name = "getF64",
- summary = "Unpack 64-bit floating point numbers from the Blob.",
- description = "Returns 64-bit floating point numbers from the data in the Blob.",
- key = "Blob:getF64",
- module = "lovr.data",
- related = {
- "Blob:setF64",
- "Blob:getI8",
- "Blob:getU8",
- "Blob:getI16",
- "Blob:getU16",
- "Blob:getI32",
- "Blob:getU32",
- "Blob:getF32"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to read from.",
- default = "0"
- },
- {
- name = "count",
- type = "number",
- description = "The number of doubles to read.",
- default = "1"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "`count` 64-bit doubles."
- }
- }
- }
- }
- },
- {
- name = "setI8",
- summary = "Write 8-bit signed integers to the Blob.",
- description = "Writes 8-bit signed integers to the Blob.",
- key = "Blob:setI8",
- module = "lovr.data",
- related = {
- "Blob:getI8",
- "Blob:setU8",
- "Blob:setI16",
- "Blob:setU16",
- "Blob:setI32",
- "Blob:setU32",
- "Blob:setF32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 8-bit signed integers (each taking up 1 byte, ranging from\n-127 to 128)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 8-bit signed integers (each taking up 1 byte, ranging from -127 to 128)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setU8",
- summary = "Write 8-bit unsigned integers to the Blob.",
- description = "Writes 8-bit unsigned integers to the Blob.",
- key = "Blob:setU8",
- module = "lovr.data",
- related = {
- "Blob:getU8",
- "Blob:setI8",
- "Blob:setI16",
- "Blob:setU16",
- "Blob:setI32",
- "Blob:setU32",
- "Blob:setF32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 8-bit unsigned integers (each taking up 1 byte, ranging from 0 to 255)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 8-bit unsigned integers (each taking up 1 byte, ranging from 0 to 255)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setI16",
- summary = "Write 16-bit signed integers to the Blob.",
- description = "Writes 16-bit signed integers to the Blob.",
- key = "Blob:setI16",
- module = "lovr.data",
- related = {
- "Blob:getI16",
- "Blob:setI8",
- "Blob:setU8",
- "Blob:setU16",
- "Blob:setI32",
- "Blob:setU32",
- "Blob:setF32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 16-bit signed integers (each taking up 2 bytes, ranging from\n-32768 to 32767)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 16-bit signed integers (each taking up 2 bytes, ranging from -32768 to 32767)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setU16",
- summary = "Write 16-bit unsigned integers to the Blob.",
- description = "Writes 16-bit unsigned integers to the Blob.",
- key = "Blob:setU16",
- module = "lovr.data",
- related = {
- "Blob:getU16",
- "Blob:setI8",
- "Blob:setU8",
- "Blob:setI16",
- "Blob:setI32",
- "Blob:setU32",
- "Blob:setF32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 16-bit unsigned integers (each taking up 2 bytes, ranging from 0 to 65535)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 16-bit unsigned integers (each taking up 2 bytes, ranging from 0 to 65535)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setI32",
- summary = "Write 32-bit signed integers to the Blob.",
- description = "Writes 32-bit signed integers to the Blob.",
- key = "Blob:setI32",
- module = "lovr.data",
- related = {
- "Blob:getI32",
- "Blob:setI8",
- "Blob:setU8",
- "Blob:setI16",
- "Blob:setU16",
- "Blob:setU32",
- "Blob:setF32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 32-bit signed integers (each taking up 4 bytes, ranging from\n-2147483648 to 2147483647)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 32-bit signed integers (each taking up 4 bytes, ranging from -2147483648 to 2147483647)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setU32",
- summary = "Write 32-bit unsigned integers to the Blob.",
- description = "Writes 32-bit unsigned integers to the Blob.",
- key = "Blob:setU32",
- module = "lovr.data",
- related = {
- "Blob:getU32",
- "Blob:setI8",
- "Blob:setU8",
- "Blob:setI16",
- "Blob:setU16",
- "Blob:setI32",
- "Blob:setF32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 32-bit unsigned integers (each taking up 4 bytes, ranging from 0 to 4294967296)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 32-bit unsigned integers (each taking up 4 bytes, ranging from 0 to 4294967296)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setF32",
- summary = "Write 32-bit floating point numbers to the Blob.",
- description = "Writes 32-bit floating point numbers to the Blob.",
- key = "Blob:setF32",
- module = "lovr.data",
- related = {
- "Blob:getF32",
- "Blob:setI8",
- "Blob:setU8",
- "Blob:setI16",
- "Blob:setU16",
- "Blob:setI32",
- "Blob:setU32",
- "Blob:setF64"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 32-bit floats (each taking up 4 bytes)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 32-bit floats (each taking up 4 bytes)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setF64",
- summary = "Write 64-bit floating point numbers to the Blob.",
- description = "Writes 64-bit floating point numbers to the Blob.",
- key = "Blob:setF64",
- module = "lovr.data",
- related = {
- "Blob:getF64",
- "Blob:setI8",
- "Blob:setU8",
- "Blob:setI16",
- "Blob:setU16",
- "Blob:setI32",
- "Blob:setU32",
- "Blob:setF32"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "...",
- type = "number",
- description = "Numbers to write to the blob as 64-bit floating point numbers (each taking up 8 bytes)."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A non-negative byte offset to start writing at."
- },
- {
- name = "table",
- type = "number",
- description = "A table of numbers to write to the blob as 64-bit floating point numbers (each taking up 8 bytes)."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "Image",
- summary = "An object that stores pixel data for Textures.",
- 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.",
- key = "Image",
- module = "lovr.data",
- constructors = {
- "lovr.data.newImage"
- },
- methods = {
- {
- name = "encode",
- summary = "Encode the Image as png.",
- description = "Encodes the Image to an uncompressed png. This intended mainly for debugging.",
- key = "Image:encode",
- module = "lovr.data",
- related = {
- "lovr.filesystem.write"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "A new Blob containing the PNG image data."
- }
- }
- }
- }
- },
- {
- name = "getBlob",
- summary = "Get the bytes backing this Image as a `Blob`.",
- description = "Returns a Blob containing the raw bytes of the Image.",
- key = "Image:getBlob",
- module = "lovr.data",
- related = {
- "Blob:getPointer",
- "Sound:getBlob"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob instance containing the bytes for the `Image`."
- }
- }
- }
- }
- },
- {
- name = "getDimensions",
- summary = "Get the dimensions of the Image.",
- description = "Returns the dimensions of the Image, in pixels.",
- key = "Image:getDimensions",
- module = "lovr.data",
- related = {
- "Image:getWidth",
- "Image:getHeight",
- "Texture:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the Image, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the Image, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getFormat",
- summary = "Get the pixel format of the Image.",
- description = "Returns the format of the Image.",
- key = "Image:getFormat",
- module = "lovr.data",
- related = {
- "TextureFormat",
- "Texture:getFormat"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the pixels in the Image."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- summary = "Get the height of the Image.",
- description = "Returns the height of the Image, in pixels.",
- key = "Image:getHeight",
- module = "lovr.data",
- related = {
- "Image:getWidth",
- "Image:getDimensions",
- "Texture:getHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height of the Image, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getPixel",
- summary = "Get the value of a pixel of the Image.",
- description = "Returns the value of a pixel of the Image.",
- key = "Image:getPixel",
- module = "lovr.data",
- notes = "The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`.",
- related = {
- "Image:setPixel",
- "Image:mapPixel",
- "TextureFormat",
- "Texture:getPixels",
- "Texture:setPixels",
- "Texture:newReadback"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the pixel to get (0-indexed)."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the pixel to get (0-indexed)."
- }
- },
- returns = {
- {
- name = "r",
- type = "number",
- description = "The red component of the pixel, from 0.0 to 1.0."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the pixel, from 0.0 to 1.0."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the pixel, from 0.0 to 1.0."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the pixel, from 0.0 to 1.0."
- }
- }
- }
- }
- },
- {
- name = "getPointer",
- summary = "Get a raw pointer to the Image pixel data.",
- description = "Returns a raw pointer to the Image's pixel data. This can be used to interface with other C libraries or the LuaJIT FFI.",
- key = "Image:getPointer",
- module = "lovr.data",
- examples = {
- {
- description = "Simple example of writing to Image pixels with LuaJIT's FFI module.",
- code = "local ffi = require 'ffi'\n\nfunction lovr.load()\n image = lovr.data.newImage(2, 2)\n\n ffi.cdef [[\n typedef struct { uint8_t r, g, b, a; } Pixel;\n ]]\n\n pointer = image:getPointer()\n pixels = ffi.cast('Pixel*', pointer)\n pixels[0] = { 255, 0, 0, 255 }\n pixels[1] = { 0, 255, 0, 255 }\n pixels[2] = { 0, 0, 255, 255 }\n pixels[3] = { 255, 255, 255, 255 }\n\n texture = lovr.graphics.newTexture(image)\nend\n\nfunction lovr.draw(pass)\n pass:setSampler('nearest')\n pass:fill(texture)\nend"
- }
- },
- variants = {
- {
- arguments = {
- {
- name = "level",
- type = "number",
- description = "The mipmap level to get the pointer of (for DDS and KTX images).",
- default = "1"
- },
- {
- name = "layer",
- type = "number",
- description = "The array layer to get the pointer of (for DDS and KTX images).",
- default = "1"
- }
- },
- returns = {
- {
- name = "pointer",
- type = "userdata",
- description = "A pointer to the raw pixel data."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- summary = "Get the width of the Image.",
- description = "Returns the width of the Image, in pixels.",
- key = "Image:getWidth",
- module = "lovr.data",
- related = {
- "Image:getHeight",
- "Image:getDimensions",
- "Texture:getWidth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the Image, in pixels."
- }
- }
- }
- }
- },
- {
- name = "mapPixel",
- summary = "Transform an Image by applying a function to every pixel.",
- 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.",
- key = "Image:mapPixel",
- module = "lovr.data",
- examples = {
- {
- description = "Convert an Image to grayscale.",
- 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)"
- },
- {
- 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.",
- 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"
- }
- },
- notes = "The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`.",
- related = {
- "Image:setPixel",
- "Image:getPixel",
- "TextureFormat",
- "Texture:setPixels"
- },
- variants = {
- {
- arguments = {
- {
- name = "callback",
- type = "function",
- description = "The function that will be called for each pixel."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the upper-left corner of the area of the Image to affect.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the upper-left corner of the area of the Image to affect.",
- default = "0"
- },
- {
- name = "w",
- type = "number",
- description = "The width of the area to affect.",
- default = "image:getWidth()"
- },
- {
- name = "h",
- type = "number",
- description = "The height of the area to affect.",
- default = "image:getHeight()"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "paste",
- summary = "Copy pixels from another Image to this one.",
- description = "Copies a rectangle of pixels from one Image to this one.",
- key = "Image:paste",
- module = "lovr.data",
- 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.",
- related = {
- "Image:getPixel",
- "Image:setPixel",
- "Texture:setPixels"
- },
- variants = {
- {
- arguments = {
- {
- name = "source",
- type = "Image",
- description = "The Image to copy pixels from."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate to paste to (0-indexed).",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate to paste to (0-indexed).",
- default = "0"
- },
- {
- name = "fromX",
- type = "number",
- description = "The x coordinate in the source to paste from (0-indexed).",
- default = "0"
- },
- {
- name = "fromY",
- type = "number",
- description = "The y coordinate in the source to paste from (0-indexed).",
- default = "0"
- },
- {
- name = "width",
- type = "number",
- description = "The width of the region to copy.",
- default = "source:getWidth()"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the region to copy.",
- default = "source:getHeight()"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPixel",
- summary = "Set the value of a pixel of the Image.",
- 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`.",
- key = "Image:setPixel",
- module = "lovr.data",
- notes = "The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`.",
- related = {
- "Image:mapPixel",
- "Image:getPixel",
- "TextureFormat",
- "Texture:setPixels"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the pixel to set (0-indexed)."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the pixel to set (0-indexed)."
- },
- {
- name = "r",
- type = "number",
- description = "The red component of the pixel, from 0.0 to 1.0."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the pixel, from 0.0 to 1.0."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the pixel, from 0.0 to 1.0."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the pixel, from 0.0 to 1.0.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "ModelData",
- summary = "An object that loads and stores data for 3D models.",
- 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.",
- key = "ModelData",
- module = "lovr.data",
- constructors = {
- "lovr.data.newModelData"
- },
- methods = {
- {
- name = "getAnimationChannelCount",
- summary = "Get the number of channels in an animation.",
- description = "Returns the number of channels in an animation.\n\nA channel is a set of keyframes for a single property of a node.",
- key = "ModelData:getAnimationChannelCount",
- module = "lovr.data",
- related = {
- "ModelData:getAnimationNode",
- "ModelData:getAnimationProperty"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of channels in the animation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation."
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of channels in the animation."
- }
- }
- }
- }
- },
- {
- name = "getAnimationCount",
- summary = "Get the number of animations in the model.",
- description = "Returns the number of animations in the model.",
- key = "ModelData:getAnimationCount",
- module = "lovr.data",
- related = {
- "Model:getAnimationCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of animations in the model."
- }
- }
- }
- }
- },
- {
- name = "getAnimationDuration",
- summary = "Get the duration of an animation.",
- description = "Returns the duration of an animation.",
- key = "ModelData:getAnimationDuration",
- module = "lovr.data",
- notes = "The duration of the animation is calculated as the latest timestamp of all of its channels.",
- related = {
- "Model:getAnimationDuration"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the animation."
- }
- },
- returns = {
- {
- name = "duration",
- type = "number",
- description = "The duration of the animation, in seconds."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the animation."
- }
- },
- returns = {
- {
- name = "duration",
- type = "number",
- description = "The duration of the animation, in seconds."
- }
- }
- }
- }
- },
- {
- name = "getAnimationKeyframe",
- summary = "Get a keyframe in a channel of an animation.",
- description = "Returns a single keyframe in a channel of an animation.",
- key = "ModelData:getAnimationKeyframe",
- module = "lovr.data",
- related = {
- "ModelData:getAnimationSmoothMode",
- "ModelData:getAnimationKeyframeCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- },
- {
- name = "keyframe",
- type = "number",
- description = "The index of a keyframe in the channel."
- }
- },
- returns = {
- {
- name = "time",
- type = "number",
- description = "The timestamp of the keyframe."
- },
- {
- name = "...",
- type = "number",
- description = "The data for the keyframe (either 3 or 4 numbers depending on the property)."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- },
- {
- name = "keyframe",
- type = "number",
- description = "The index of a keyframe in the channel."
- }
- },
- returns = {
- {
- name = "time",
- type = "number",
- description = "The timestamp of the keyframe."
- },
- {
- name = "...",
- type = "number",
- description = "The data for the keyframe (either 3 or 4 numbers depending on the property)."
- }
- }
- }
- }
- },
- {
- name = "getAnimationKeyframeCount",
- summary = "Get the number of keyframes in a channel of an animation.",
- description = "Returns the number of keyframes in a channel of an animation.",
- key = "ModelData:getAnimationKeyframeCount",
- module = "lovr.data",
- related = {
- "ModelData:getAnimationSmoothMode",
- "ModelData:getAnimationKeyframe"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of keyframes in the channel."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of keyframes in the channel."
- }
- }
- }
- }
- },
- {
- name = "getAnimationName",
- summary = "Get the name of an animation.",
- description = "Returns the name of an animation.",
- key = "ModelData:getAnimationName",
- module = "lovr.data",
- notes = "If the animation does not have a name, this function returns `nil`.",
- related = {
- "Model:getAnimationName"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the animation."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the animation."
- }
- }
- }
- }
- },
- {
- name = "getAnimationNode",
- summary = "Get the node targeted by the channel of an animation.",
- description = "Returns the index of a node targeted by an animation's channel.",
- key = "ModelData:getAnimationNode",
- module = "lovr.data",
- related = {
- "ModelData:getAnimationProperty",
- "ModelData:getAnimationSmoothMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "node",
- type = "number",
- description = "The index of the node targeted by the channel."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "node",
- type = "number",
- description = "The index of the node targeted by the channel."
- }
- }
- }
- }
- },
- {
- name = "getAnimationProperty",
- summary = "Get the property targeted by the channel of an animation.",
- description = "Returns the property targeted by an animation's channel.",
- key = "ModelData:getAnimationProperty",
- module = "lovr.data",
- related = {
- "ModelData:getAnimationNode",
- "ModelData:getAnimationSmoothMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "property",
- type = "AnimationProperty",
- description = "The property (translation, rotation, scale, weights) affected by the keyframes."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "property",
- type = "AnimationProperty",
- description = "The property (translation, rotation, scale, weights) affected by the keyframes."
- }
- }
- }
- }
- },
- {
- name = "getAnimationSmoothMode",
- summary = "Get the smooth mode of a channel in an animation.",
- description = "Returns the smooth mode of a channel in an animation.",
- key = "ModelData:getAnimationSmoothMode",
- module = "lovr.data",
- related = {
- "ModelData:getAnimationNode",
- "ModelData:getAnimationProperty"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "smooth",
- type = "SmoothMode",
- description = "The smooth mode of the keyframes."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation."
- },
- {
- name = "channel",
- type = "number",
- description = "The index of a channel in the animation."
- }
- },
- returns = {
- {
- name = "smooth",
- type = "SmoothMode",
- description = "The smooth mode of the keyframes."
- }
- }
- }
- }
- },
- {
- name = "getBlendShapeCount",
- summary = "Get the number of blend shapes in the model.",
- description = "Returns the number of blend shapes in the model.",
- key = "ModelData:getBlendShapeCount",
- module = "lovr.data",
- related = {
- "ModelData:getBlendShapeName",
- "Model:getBlendShapeCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of blend shapes in the model."
- }
- }
- }
- }
- },
- {
- name = "getBlendShapeName",
- summary = "Get the name of a blend shape in the model.",
- description = "Returns the name of a blend shape in the model.",
- key = "ModelData:getBlendShapeName",
- module = "lovr.data",
- notes = "This function will throw an error if the blend shape index is invalid.",
- related = {
- "ModelData:getBlendShapeCount",
- "Model:getBlendShapeName"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a blend shape."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the blend shape."
- }
- }
- }
- }
- },
- {
- name = "getBlob",
- summary = "Get a Blob in the model.",
- description = "Returns one of the Blobs in the model, by index.",
- key = "ModelData:getBlob",
- module = "lovr.data",
- related = {
- "ModelData:getBlobCount",
- "ModelData:getImage"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the Blob to get."
- }
- },
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob object."
- }
- }
- }
- }
- },
- {
- name = "getBlobCount",
- summary = "Get the number of Blobs stored in the model.",
- description = "Returns the number of Blobs in the model.",
- key = "ModelData:getBlobCount",
- module = "lovr.data",
- related = {
- "ModelData:getBlob",
- "ModelData:getImageCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of Blobs in the model."
- }
- }
- }
- }
- },
- {
- name = "getBoundingBox",
- summary = "Get the bounding box of the model.",
- description = "Returns the 6 values of the model's axis-aligned bounding box.",
- key = "ModelData:getBoundingBox",
- module = "lovr.data",
- related = {
- "ModelData:getWidth",
- "ModelData:getHeight",
- "ModelData:getDepth",
- "ModelData:getDimensions",
- "ModelData:getCenter",
- "ModelData:getBoundingSphere",
- "Model:getBoundingBox"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "minx",
- type = "number",
- description = "The minimum x coordinate of the vertices in the model."
- },
- {
- name = "maxx",
- type = "number",
- description = "The maximum x coordinate of the vertices in the model."
- },
- {
- name = "miny",
- type = "number",
- description = "The minimum y coordinate of the vertices in the model."
- },
- {
- name = "maxy",
- type = "number",
- description = "The maximum y coordinate of the vertices in the model."
- },
- {
- name = "minz",
- type = "number",
- description = "The minimum z coordinate of the vertices in the model."
- },
- {
- name = "maxz",
- type = "number",
- description = "The maximum z coordinate of the vertices in the model."
- }
- }
- }
- }
- },
- {
- name = "getBoundingSphere",
- summary = "Get the bounding sphere of the model.",
- description = "Returns a sphere approximately enclosing the vertices in the model.",
- key = "ModelData:getBoundingSphere",
- module = "lovr.data",
- related = {
- "ModelData:getWidth",
- "ModelData:getHeight",
- "ModelData:getDepth",
- "ModelData:getDimensions",
- "ModelData:getCenter",
- "ModelData:getBoundingBox",
- "Model:getBoundingSphere"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the position of the sphere."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the position of the sphere."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the position of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the bounding sphere."
- }
- }
- }
- }
- },
- {
- name = "getCenter",
- summary = "Get the center of the model's bounding box.",
- description = "Returns the center of the model's axis-aligned bounding box, relative to the model's origin.",
- key = "ModelData:getCenter",
- module = "lovr.data",
- related = {
- "ModelData:getWidth",
- "ModelData:getHeight",
- "ModelData:getDepth",
- "ModelData:getDimensions",
- "ModelData:getBoundingBox",
- "Model:getCenter"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x offset of the center of the bounding box."
- },
- {
- name = "y",
- type = "number",
- description = "The y offset of the center of the bounding box."
- },
- {
- name = "z",
- type = "number",
- description = "The z offset of the center of the bounding box."
- }
- }
- }
- }
- },
- {
- name = "getDepth",
- summary = "Get the depth of the model.",
- description = "Returns the depth of the model, computed from its axis-aligned bounding box.",
- key = "ModelData:getDepth",
- module = "lovr.data",
- related = {
- "ModelData:getWidth",
- "ModelData:getHeight",
- "ModelData:getDimensions",
- "ModelData:getCenter",
- "ModelData:getBoundingBox",
- "Model:getDepth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "depth",
- type = "number",
- description = "The depth of the model."
- }
- }
- }
- }
- },
- {
- name = "getDimensions",
- summary = "Get the dimensions of the model.",
- description = "Returns the width, height, and depth of the model, computed from its axis-aligned bounding box.",
- key = "ModelData:getDimensions",
- module = "lovr.data",
- related = {
- "ModelData:getWidth",
- "ModelData:getHeight",
- "ModelData:getDepth",
- "ModelData:getCenter",
- "ModelData:getBoundingBox",
- "Model:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the model."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the model."
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the model."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- summary = "Get the height of the model.",
- description = "Returns the height of the model, computed from its axis-aligned bounding box.",
- key = "ModelData:getHeight",
- module = "lovr.data",
- related = {
- "ModelData:getWidth",
- "ModelData:getDepth",
- "ModelData:getDimensions",
- "ModelData:getCenter",
- "ModelData:getBoundingBox",
- "Model:getHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height of the model."
- }
- }
- }
- }
- },
- {
- name = "getImage",
- summary = "Get an Image in the model.",
- description = "Returns one of the Images in the model, by index.",
- key = "ModelData:getImage",
- module = "lovr.data",
- related = {
- "ModelData:getImageCount",
- "ModelData:getBlob"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the Image to get."
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The Image object."
- }
- }
- }
- }
- },
- {
- name = "getImageCount",
- summary = "Get the number of Images stored in the model.",
- description = "Returns the number of Images in the model.",
- key = "ModelData:getImageCount",
- module = "lovr.data",
- related = {
- "ModelData:getImage",
- "ModelData:getBlobCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of Images in the model."
- }
- }
- }
- }
- },
- {
- name = "getMaterial",
- summary = "Get the material properties for a material in the model.",
- description = "Returns a table with all of the properties of a material.",
- key = "ModelData:getMaterial",
- module = "lovr.data",
- notes = "All images are optional and may be `nil`.",
- related = {
- "ModelData:getMaterialCount",
- "ModelData:getMeshMaterial",
- "lovr.graphics.newMaterial",
- "Model:getMaterial"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a material."
- }
- },
- returns = {
- {
- name = "properties",
- type = "table",
- description = "The material properties.",
- table = {
- {
- name = "color",
- type = "table",
- description = "The color of the material. The table contains the `r`, `g`, `b`, and `a` components of the color, from 0 to 1."
- },
- {
- name = "glow",
- type = "table",
- 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."
- },
- {
- name = "uvShift",
- type = "table",
- description = "A table with 2 numbers indicating an offset to apply to UVs."
- },
- {
- name = "uvScale",
- type = "table",
- description = "A table with 2 numbers indicating a scale to apply to UVs. By default, shaders apply the UV scale before the UV offset."
- },
- {
- name = "metalness",
- type = "number",
- 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."
- },
- {
- name = "roughness",
- type = "number",
- 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."
- },
- {
- name = "clearcoat",
- type = "number",
- description = "The clearcoat parameter of the material."
- },
- {
- name = "clearcoatRoughness",
- type = "number",
- description = "The roughness of the clearcoat layer."
- },
- {
- name = "occlusionStrength",
- type = "number",
- description = "A number multiplied by the value from the ambient occlusion texture to control how strong the occlusion effect is."
- },
- {
- name = "normalScale",
- type = "number",
- description = "A number multiplied by the value from the normal texture to control how strong the normal mapping effect is."
- },
- {
- name = "alphaCutoff",
- type = "number",
- 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."
- },
- {
- name = "texture",
- type = "number",
- description = "The index of the Image used for the color texture."
- },
- {
- name = "glowTexture",
- type = "number",
- description = "The index of the Image used for the glow texture."
- },
- {
- name = "occlusionTexture",
- type = "number",
- 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."
- },
- {
- name = "metalnessTexture",
- type = "number",
- 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."
- },
- {
- name = "roughnessTexture",
- type = "number",
- 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."
- },
- {
- name = "clearcoatTexture",
- type = "number",
- 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."
- },
- {
- name = "normalTexture",
- type = "number",
- description = "The index of the Image to use for the normal map."
- }
- }
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of a material."
- }
- },
- returns = {
- {
- name = "properties",
- type = "table",
- description = "The material properties.",
- table = {
- {
- name = "color",
- type = "table",
- description = "The color of the material. The table contains the `r`, `g`, `b`, and `a` components of the color, from 0 to 1."
- },
- {
- name = "glow",
- type = "table",
- 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."
- },
- {
- name = "uvShift",
- type = "table",
- description = "A table with 2 numbers indicating an offset to apply to UVs."
- },
- {
- name = "uvScale",
- type = "table",
- description = "A table with 2 numbers indicating a scale to apply to UVs. By default, shaders apply the UV scale before the UV offset."
- },
- {
- name = "metalness",
- type = "number",
- 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."
- },
- {
- name = "roughness",
- type = "number",
- 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."
- },
- {
- name = "clearcoat",
- type = "number",
- description = "The clearcoat parameter of the material."
- },
- {
- name = "clearcoatRoughness",
- type = "number",
- description = "The roughness of the clearcoat layer."
- },
- {
- name = "occlusionStrength",
- type = "number",
- description = "A number multiplied by the value from the ambient occlusion texture to control how strong the occlusion effect is."
- },
- {
- name = "normalScale",
- type = "number",
- description = "A number multiplied by the value from the normal texture to control how strong the normal mapping effect is."
- },
- {
- name = "alphaCutoff",
- type = "number",
- 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."
- },
- {
- name = "texture",
- type = "number",
- description = "The index of the Image used for the color texture."
- },
- {
- name = "glowTexture",
- type = "number",
- description = "The index of the Image used for the glow texture."
- },
- {
- name = "occlusionTexture",
- type = "number",
- 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."
- },
- {
- name = "metalnessTexture",
- type = "number",
- 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."
- },
- {
- name = "roughnessTexture",
- type = "number",
- 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."
- },
- {
- name = "clearcoatTexture",
- type = "number",
- 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."
- },
- {
- name = "normalTexture",
- type = "number",
- description = "The index of the Image to use for the normal map."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getMaterialCount",
- summary = "Get the number of materials in the model.",
- description = "Returns the number of materials in the model.",
- key = "ModelData:getMaterialCount",
- module = "lovr.data",
- related = {
- "ModelData:getMaterialName",
- "ModelData:getMeshMaterial",
- "ModelData:getMaterial",
- "Model:getMaterialCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of materials in the model."
- }
- }
- }
- }
- },
- {
- name = "getMaterialName",
- summary = "Get the name of a material in the model.",
- description = "Returns the name of a material in the model.",
- key = "ModelData:getMaterialName",
- module = "lovr.data",
- related = {
- "ModelData:getMaterialCount",
- "ModelData:getMeshMaterial",
- "ModelData:getMaterial",
- "Model:getMaterialName"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a material."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the material, or nil if the material does not have a name."
- }
- }
- }
- }
- },
- {
- name = "getMeshCount",
- summary = "Get the number of meshes in the model.",
- description = "Returns the number of meshes in the model.",
- key = "ModelData:getMeshCount",
- module = "lovr.data",
- related = {
- "ModelData:getNodeMeshes"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of meshes in the model."
- }
- }
- }
- }
- },
- {
- name = "getMeshDrawMode",
- summary = "Get the draw mode of a mesh.",
- description = "Returns the draw mode of a mesh. This controls how its vertices are connected together (points, lines, or triangles).",
- key = "ModelData:getMeshDrawMode",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh."
- }
- },
- returns = {
- {
- name = "mode",
- type = "ModelDrawMode",
- description = "The draw mode of the mesh."
- }
- }
- }
- }
- },
- {
- name = "getMeshIndex",
- summary = "Get one of the vertex indices in a mesh.",
- 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.",
- key = "ModelData:getMeshIndex",
- module = "lovr.data",
- related = {
- "ModelData:getMeshIndexFormat",
- "ModelData:getMeshIndexCount",
- "ModelData:getMeshVertex",
- "ModelData:getTriangles"
- },
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh to get the vertex from."
- },
- {
- name = "index",
- type = "number",
- description = "The index of a vertex index in the mesh to retrieve."
- }
- },
- returns = {
- {
- name = "vertexindex",
- type = "number",
- description = "The vertex index. Like all indices in Lua, this is 1-indexed."
- }
- }
- }
- }
- },
- {
- name = "getMeshIndexCount",
- summary = "Get the number of vertex indices in a mesh.",
- description = "Returns the number of vertex indices in a mesh. Vertex indices allow for vertices to be reused when defining triangles.",
- key = "ModelData:getMeshIndexCount",
- module = "lovr.data",
- notes = "This may return zero if the mesh does not use indices.",
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh."
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of vertex indices in the mesh."
- }
- }
- }
- }
- },
- {
- name = "getMeshIndexFormat",
- summary = "Get the data format of vertex indices in a mesh.",
- description = "Returns the data format of vertex indices in a mesh. If a mesh doesn't use vertex indices, this function returns nil.",
- key = "ModelData:getMeshIndexFormat",
- module = "lovr.data",
- related = {
- "ModelData:getMeshVertexFormat"
- },
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh."
- }
- },
- returns = {
- {
- name = "type",
- type = "AttributeType",
- description = "The data type of each vertex index (always u16 or u32)."
- },
- {
- name = "blob",
- type = "number",
- description = "The index of a Blob in the mesh where the binary data is stored."
- },
- {
- name = "offset",
- type = "number",
- description = "A byte offset into the Blob's data where the index data starts."
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- }
- },
- {
- name = "getMeshMaterial",
- summary = "Get the index of the material applied to a mesh.",
- description = "Returns the index of the material applied to a mesh.",
- key = "ModelData:getMeshMaterial",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh."
- }
- },
- returns = {
- {
- name = "material",
- type = "number",
- description = "The index of the material applied to the mesh, or nil if the mesh does not have a material."
- }
- }
- }
- }
- },
- {
- name = "getMeshVertex",
- summary = "Get the data for a single vertex in a mesh.",
- 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`.",
- key = "ModelData:getMeshVertex",
- module = "lovr.data",
- related = {
- "ModelData:getMeshVertexFormat",
- "ModelData:getMeshVertexCount",
- "ModelData:getMeshIndex",
- "ModelData:getTriangles"
- },
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh to get the vertex from."
- },
- {
- name = "vertex",
- type = "number",
- description = "The index of a vertex in the mesh to retrieve."
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "The data for all of the attributes of the vertex."
- }
- }
- }
- }
- },
- {
- name = "getMeshVertexCount",
- summary = "Get the number of vertices in a mesh.",
- description = "Returns the number of vertices in a mesh.",
- key = "ModelData:getMeshVertexCount",
- module = "lovr.data",
- related = {
- "ModelData:getMeshIndexCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh."
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of vertices in the mesh."
- }
- }
- }
- }
- },
- {
- name = "getMeshVertexFormat",
- summary = "Get the vertex format of a mesh.",
- 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.",
- key = "ModelData:getMeshVertexFormat",
- module = "lovr.data",
- 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.",
- related = {
- "ModelData:getMeshIndexFormat"
- },
- variants = {
- {
- arguments = {
- {
- name = "mesh",
- type = "number",
- description = "The index of a mesh."
- }
- },
- returns = {
- {
- name = "format",
- type = "table",
- description = "The vertex format of the mesh."
- }
- }
- }
- }
- },
- {
- name = "getMetadata",
- summary = "Get extra information from the model file.",
- 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.",
- key = "ModelData:getMetadata",
- module = "lovr.data",
- related = {
- "Model:getMetadata"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "metadata",
- type = "string",
- description = "The metadata from the model file."
- }
- }
- }
- }
- },
- {
- name = "getNodeChildren",
- summary = "Get the children of a node.",
- description = "Given a parent node, this function returns a table with the indices of its children.",
- key = "ModelData:getNodeChildren",
- module = "lovr.data",
- notes = "If the node does not have any children, this function returns an empty table.",
- related = {
- "ModelData:getNodeParent",
- "ModelData:getRootNode",
- "Model:getNodeChildren"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the parent node."
- }
- },
- returns = {
- {
- name = "children",
- type = "table",
- description = "A table containing a node index for each child of the node."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the parent node."
- }
- },
- returns = {
- {
- name = "children",
- type = "table",
- description = "A table containing a node index for each child of the node."
- }
- }
- }
- }
- },
- {
- name = "getNodeCount",
- summary = "Get the number of nodes in the model.",
- description = "Returns the number of nodes in the model.",
- key = "ModelData:getNodeCount",
- module = "lovr.data",
- related = {
- "Model:getNodeCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of nodes in the model."
- }
- }
- }
- }
- },
- {
- name = "getNodeMeshes",
- summary = "Get the indices of meshes attached to a node.",
- 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.",
- key = "ModelData:getNodeMeshes",
- module = "lovr.data",
- related = {
- "ModelData:getMeshCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "meshes",
- type = "table",
- description = "A table with the node's mesh indices."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "meshes",
- type = "table",
- description = "A table with the node's mesh indices."
- }
- }
- }
- }
- },
- {
- name = "getNodeName",
- summary = "Get the name of a node.",
- description = "Returns the name of a node.",
- key = "ModelData:getNodeName",
- module = "lovr.data",
- notes = "If the node does not have a name, this function returns `nil`.",
- related = {
- "Model:getNodeName"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- }
- }
- }
- },
- {
- name = "getNodeOrientation",
- summary = "Get the local orientation of a node.",
- description = "Returns local orientation of a node, relative to its parent.",
- key = "ModelData:getNodeOrientation",
- module = "lovr.data",
- related = {
- "ModelData:getNodePosition",
- "ModelData:getNodeScale",
- "ModelData:getNodePose",
- "ModelData:getNodeTransform"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getNodeParent",
- summary = "Get the parent of a node.",
- description = "Given a child node, this function returns the index of its parent.",
- key = "ModelData:getNodeParent",
- module = "lovr.data",
- related = {
- "ModelData:getNodeChildren",
- "ModelData:getRootNode",
- "Model:getNodeParent"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the child node."
- }
- },
- returns = {
- {
- name = "parent",
- type = "number",
- description = "The index of the parent."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the child node."
- }
- },
- returns = {
- {
- name = "parent",
- type = "number",
- description = "The index of the parent."
- }
- }
- }
- }
- },
- {
- name = "getNodePose",
- summary = "Get the local pose of a node.",
- description = "Returns local pose (position and orientation) of a node, relative to its parent.",
- key = "ModelData:getNodePose",
- module = "lovr.data",
- related = {
- "ModelData:getNodePosition",
- "ModelData:getNodeOrientation",
- "ModelData:getNodeScale",
- "ModelData:getNodeTransform"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getNodePosition",
- summary = "Get the local position of a node.",
- description = "Returns local position of a node, relative to its parent.",
- key = "ModelData:getNodePosition",
- module = "lovr.data",
- related = {
- "ModelData:getNodeOrientation",
- "ModelData:getNodeScale",
- "ModelData:getNodePose",
- "ModelData:getNodeTransform"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- }
- }
- }
- }
- },
- {
- name = "getNodeScale",
- summary = "Get the local scale of a node.",
- description = "Returns local scale of a node, relative to its parent.",
- key = "ModelData:getNodeScale",
- module = "lovr.data",
- related = {
- "ModelData:getNodePosition",
- "ModelData:getNodeOrientation",
- "ModelData:getNodePose",
- "ModelData:getNodeTransform"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- }
- }
- }
- }
- },
- {
- name = "getNodeSkin",
- summary = "Get the index of the skin used by a node.",
- 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.",
- key = "ModelData:getNodeSkin",
- module = "lovr.data",
- related = {
- "ModelData:getSkinCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "skin",
- type = "number",
- description = "The index of the node's skin, or nil if the node isn't skeletally animated."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "skin",
- type = "number",
- description = "The index of the node's skin, or nil if the node isn't skeletally animated."
- }
- }
- }
- }
- },
- {
- name = "getNodeTransform",
- summary = "Get the local transform of a node.",
- description = "Returns local transform (position, orientation, and scale) of a node, relative to its parent.",
- key = "ModelData:getNodeTransform",
- module = "lovr.data",
- notes = "For best results when animating, it's recommended to keep the 3 components of the scale the same.",
- related = {
- "ModelData:getNodePosition",
- "ModelData:getNodeOrientation",
- "ModelData:getNodeScale",
- "ModelData:getNodePose"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- },
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- },
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getRootNode",
- summary = "Get the index of the root node.",
- description = "Returns the index of the model's root node.",
- key = "ModelData:getRootNode",
- module = "lovr.data",
- related = {
- "ModelData:getNodeCount",
- "ModelData:getNodeParent",
- "Model:getRootNode"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "root",
- type = "number",
- description = "The index of the root node."
- }
- }
- }
- }
- },
- {
- name = "getSkinCount",
- summary = "Get the number of skins in the model.",
- description = "Returns the number of skins in the model. A skin is a collection of joints targeted by an animation.",
- key = "ModelData:getSkinCount",
- module = "lovr.data",
- notes = "There is currently a maximum of 256 skins.",
- related = {
- "Model:hasJoints"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of skins in the model."
- }
- }
- }
- }
- },
- {
- name = "getSkinInverseBindMatrix",
- summary = "Get the inverse bind matrix for a joint in the skin.",
- description = "Returns the inverse bind matrix for a joint in the skin.",
- key = "ModelData:getSkinInverseBindMatrix",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "skin",
- type = "number",
- description = "The index of a skin."
- },
- {
- name = "joint",
- type = "number",
- description = "The index of a joint in the skin."
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "The 16 components of the 4x4 inverse bind matrix, in column-major order."
- }
- }
- }
- }
- },
- {
- name = "getSkinJoints",
- summary = "Get the joints in a skin.",
- description = "Returns a table with the node indices of the joints in a skin.",
- key = "ModelData:getSkinJoints",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "skin",
- type = "number",
- description = "The index of a skin."
- }
- },
- returns = {
- {
- name = "joints",
- type = "table",
- description = "The joints in the skin."
- }
- }
- }
- }
- },
- {
- name = "getTriangleCount",
- summary = "Get the total number of triangles in the model.",
- 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`.",
- key = "ModelData:getTriangleCount",
- module = "lovr.data",
- related = {
- "ModelData:getTriangles",
- "ModelData:getVertexCount",
- "Model:getTriangleCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The total number of triangles in the model."
- }
- }
- }
- }
- },
- {
- name = "getTriangles",
- summary = "Get all the triangles in the model.",
- 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.",
- key = "ModelData:getTriangles",
- module = "lovr.data",
- notes = "After this function is called on a ModelData once, the result is cached.",
- related = {
- "ModelData:getTriangleCount",
- "ModelData:getVertexCount",
- "Model:getTriangles"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "vertices",
- type = "table",
- 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."
- },
- {
- name = "indices",
- type = "table",
- description = "A list of numbers representing how to connect the vertices into triangles. Each number is a 1-based index into the `vertices` table, and every 3 indices form a triangle."
- }
- }
- }
- }
- },
- {
- name = "getVertexCount",
- summary = "Get the total vertex count of the model.",
- 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`.",
- key = "ModelData:getVertexCount",
- module = "lovr.data",
- related = {
- "ModelData:getTriangles",
- "ModelData:getTriangleCount",
- "Model:getVertexCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The total number of vertices in the model."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- summary = "Get the width of the model.",
- description = "Returns the width of the model, computed from its axis-aligned bounding box.",
- key = "ModelData:getWidth",
- module = "lovr.data",
- related = {
- "ModelData:getHeight",
- "ModelData:getDepth",
- "ModelData:getDimensions",
- "ModelData:getCenter",
- "ModelData:getBoundingBox",
- "Model:getWidth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the model."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Rasterizer",
- summary = "An object that rasterizes glyphs from font files.",
- 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.",
- key = "Rasterizer",
- module = "lovr.data",
- constructors = {
- "lovr.data.newRasterizer"
- },
- methods = {
- {
- name = "getAdvance",
- summary = "Get the advance of a glyph.",
- description = "Returns the advance metric for a glyph, in pixels. The advance is the horizontal distance to advance the cursor after rendering the glyph.",
- key = "Rasterizer:getAdvance",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- }
- },
- returns = {
- {
- name = "advance",
- type = "number",
- description = "The advance of the glyph, in pixels."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- }
- },
- returns = {
- {
- name = "advance",
- type = "number",
- description = "The advance of the glyph, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getAscent",
- summary = "Get the ascent of the font.",
- description = "Returns the ascent metric of the font, in pixels. The ascent represents how far any glyph of the font ascends above the baseline.",
- key = "Rasterizer:getAscent",
- module = "lovr.data",
- related = {
- "Rasterizer:getDescent",
- "Font:getAscent"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "ascent",
- type = "number",
- description = "The ascent of the font, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getBearing",
- summary = "Get the bearing of a glyph.",
- 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.",
- key = "Rasterizer:getBearing",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- }
- },
- returns = {
- {
- name = "bearing",
- type = "number",
- description = "The bearing of the glyph, in pixels."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- }
- },
- returns = {
- {
- name = "bearing",
- type = "number",
- description = "The bearing of the glyph, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getBoundingBox",
- summary = "Get the bounding box of a glyph, or the font.",
- 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.",
- key = "Rasterizer:getBoundingBox",
- module = "lovr.data",
- related = {
- "Rasterizer:getWidth",
- "Rasterizer:getHeight",
- "Rasterizer:getDimensions"
- },
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- }
- },
- returns = {
- {
- name = "x1",
- type = "number",
- description = "The left edge of the bounding box, in pixels."
- },
- {
- name = "y1",
- type = "number",
- description = "The bottom edge of the bounding box, in pixels."
- },
- {
- name = "x2",
- type = "number",
- description = "The right edge of the bounding box, in pixels."
- },
- {
- name = "y2",
- type = "number",
- description = "The top edge of the bounding box, in pixels."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- }
- },
- returns = {
- {
- name = "x1",
- type = "number",
- description = "The left edge of the bounding box, in pixels."
- },
- {
- name = "y1",
- type = "number",
- description = "The bottom edge of the bounding box, in pixels."
- },
- {
- name = "x2",
- type = "number",
- description = "The right edge of the bounding box, in pixels."
- },
- {
- name = "y2",
- type = "number",
- description = "The top edge of the bounding box, in pixels."
- }
- }
- },
- {
- arguments = {},
- returns = {
- {
- name = "x1",
- type = "number",
- description = "The left edge of the bounding box, in pixels."
- },
- {
- name = "y1",
- type = "number",
- description = "The bottom edge of the bounding box, in pixels."
- },
- {
- name = "x2",
- type = "number",
- description = "The right edge of the bounding box, in pixels."
- },
- {
- name = "y2",
- type = "number",
- description = "The top edge of the bounding box, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getCurves",
- summary = "Get the bezier curves defining a glyph.",
- description = "Returns the bezier curve control points defining the shape of a glyph.",
- key = "Rasterizer:getCurves",
- module = "lovr.data",
- related = {
- "Curve",
- "Rasterizer:newImage"
- },
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- },
- {
- name = "three",
- type = "boolean",
- description = "Whether the control points should be 3D or 2D."
- }
- },
- returns = {
- {
- name = "curves",
- type = "table",
- 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.)."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- },
- {
- name = "three",
- type = "boolean",
- description = "Whether the control points should be 3D or 2D."
- }
- },
- returns = {
- {
- name = "curves",
- type = "table",
- 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.)."
- }
- }
- }
- }
- },
- {
- name = "getDescent",
- summary = "Get the descent of the font.",
- description = "Returns the descent metric of the font, in pixels. The descent represents how far any glyph of the font descends below the baseline.",
- key = "Rasterizer:getDescent",
- module = "lovr.data",
- related = {
- "Rasterizer:getAscent",
- "Font:getDescent"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "descent",
- type = "number",
- description = "The descent of the font, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getDimensions",
- summary = "Get the dimensions of a glyph, or the font.",
- description = "Returns the dimensions of a glyph, or the dimensions of any glyph.",
- key = "Rasterizer:getDimensions",
- module = "lovr.data",
- related = {
- "Rasterizer:getWidth",
- "Rasterizer:getHeight",
- "Rasterizer:getBoundingBox"
- },
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- }
- },
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height, in pixels."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- }
- },
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height, in pixels."
- }
- }
- },
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getFontSize",
- summary = "Get the size of the font.",
- 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.",
- key = "Rasterizer:getFontSize",
- module = "lovr.data",
- related = {
- "Rasterizer:getHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "size",
- type = "number",
- description = "The font size, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getGlyphCount",
- summary = "Get the number of glyphs stored in the font file.",
- description = "Returns the number of glyphs stored in the font file.",
- key = "Rasterizer:getGlyphCount",
- module = "lovr.data",
- related = {
- "Rasterizer:hasGlyphs"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of glyphs stored in the font file."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- summary = "Get the height of a glyph, or the font.",
- description = "Returns the height of a glyph, or the maximum height of any glyph.",
- key = "Rasterizer:getHeight",
- module = "lovr.data",
- related = {
- "Rasterizer:getWidth",
- "Rasterizer:getDimensions",
- "Rasterizer:getBoundingBox"
- },
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- }
- },
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height, in pixels."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- }
- },
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height, in pixels."
- }
- }
- },
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getKerning",
- summary = "Get the kerning between two glyphs.",
- 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.",
- key = "Rasterizer:getKerning",
- module = "lovr.data",
- related = {
- "Font:getKerning"
- },
- variants = {
- {
- arguments = {
- {
- name = "first",
- type = "string",
- description = "The first character."
- },
- {
- name = "second",
- type = "string",
- description = "The second character."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- },
- {
- arguments = {
- {
- name = "firstCodepoint",
- type = "number",
- description = "The first codepoint."
- },
- {
- name = "second",
- type = "string",
- description = "The second character."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- },
- {
- arguments = {
- {
- name = "first",
- type = "string",
- description = "The first character."
- },
- {
- name = "secondCodepoint",
- type = "number",
- description = "The second codepoint."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- },
- {
- arguments = {
- {
- name = "firstCodepoint",
- type = "number",
- description = "The first codepoint."
- },
- {
- name = "secondCodepoint",
- type = "number",
- description = "The second codepoint."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- }
- }
- },
- {
- name = "getLeading",
- summary = "Get the leading of the font.",
- description = "Returns the leading metric of the font, in pixels. This is the full amount of space between lines.",
- key = "Rasterizer:getLeading",
- module = "lovr.data",
- related = {
- "Rasterizer:getAscent",
- "Rasterizer:getDescent"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "leading",
- type = "number",
- description = "The font leading, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- summary = "Get the width of a glyph, or the font.",
- description = "Returns the width of a glyph, or the maximum width of any glyph.",
- key = "Rasterizer:getWidth",
- module = "lovr.data",
- related = {
- "Rasterizer:getHeight",
- "Rasterizer:getDimensions",
- "Rasterizer:getBoundingBox"
- },
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- }
- },
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width, in pixels."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- }
- },
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width, in pixels."
- }
- }
- },
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width, in pixels."
- }
- }
- }
- }
- },
- {
- name = "hasGlyphs",
- summary = "Get whether the Rasterizer can rasterize a set of glyphs.",
- description = "Returns whether the Rasterizer can rasterize a set of glyphs.",
- key = "Rasterizer:hasGlyphs",
- module = "lovr.data",
- related = {
- "Rasterizer:getGlyphCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "...",
- type = "*",
- description = "Strings (sets of characters) or numbers (character codes) to check for."
- }
- },
- returns = {
- {
- name = "hasGlyphs",
- type = "boolean",
- description = "true if the Rasterizer can rasterize all of the supplied characters, false otherwise."
- }
- }
- }
- }
- },
- {
- name = "newImage",
- summary = "Get an Image of a rasterized glyph.",
- description = "Returns an `Image` containing a rasterized glyph.",
- key = "Rasterizer:newImage",
- module = "lovr.data",
- related = {
- "Rasterizer:getCurves"
- },
- variants = {
- {
- arguments = {
- {
- name = "character",
- type = "string",
- description = "A character."
- },
- {
- name = "spread",
- type = "number",
- description = "The width of the distance field, for signed distance field rasterization.",
- default = "4.0"
- },
- {
- name = "padding",
- type = "number",
- description = "The number of pixels of padding to add at the edges of the image.",
- default = "spread / 2"
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The glyph image. It will be in the `rgba32f` format."
- }
- }
- },
- {
- arguments = {
- {
- name = "codepoint",
- type = "number",
- description = "A codepoint."
- },
- {
- name = "spread",
- type = "number",
- description = "The width of the distance field, for signed distance field rasterization.",
- default = "4.0"
- },
- {
- name = "padding",
- type = "number",
- description = "The number of pixels of padding to add at the edges of the image.",
- default = "spread / 2"
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The glyph image. It will be in the `rgba32f` format."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Sound",
- summary = "An object that holds raw audio samples.",
- 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.",
- key = "Sound",
- module = "lovr.data",
- constructors = {
- "lovr.data.newSound"
- },
- methods = {
- {
- name = "getBlob",
- summary = "Get the bytes backing this Sound as a Blob.",
- description = "Returns a Blob containing the raw bytes of the Sound.",
- key = "Sound:getBlob",
- module = "lovr.data",
- notes = "Samples for each channel are stored interleaved. The data type of each sample is given by `Sound:getFormat`.",
- related = {
- "Blob:getPointer",
- "Image:getBlob"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob instance containing the bytes for the `Sound`."
- }
- }
- }
- }
- },
- {
- name = "getByteStride",
- summary = "Get the byte stride of the Sound.",
- description = "Returns the byte stride of the Sound. This is the size of each frame, in bytes. For example, a stereo sound with a 32-bit floating point format would have a stride of 8 (4 bytes per sample, and 2 samples per frame).",
- key = "Sound:getByteStride",
- module = "lovr.data",
- related = {
- "Sound:getChannelCount",
- "Sound:getFormat"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "stride",
- type = "number",
- description = "The size of a frame, in bytes."
- }
- }
- }
- }
- },
- {
- name = "getCapacity",
- summary = "Get the number of frames that can be written to the Sound.",
- 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`.",
- key = "Sound:getCapacity",
- module = "lovr.data",
- related = {
- "Sound:getFrameCount",
- "Sound:getSampleCount",
- "Source:getDuration"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "capacity",
- type = "number",
- description = "The number of frames that can be written to the Sound."
- }
- }
- }
- }
- },
- {
- name = "getChannelCount",
- summary = "Get the number of channels in the Sound.",
- 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.",
- key = "Sound:getChannelCount",
- module = "lovr.data",
- related = {
- "Sound:getChannelLayout",
- "Sound:getByteStride"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "channels",
- type = "number",
- description = "The number of channels in the sound."
- }
- }
- }
- }
- },
- {
- name = "getChannelLayout",
- summary = "Get the channel layout of the Sound.",
- description = "Returns the channel layout of the Sound.",
- key = "Sound:getChannelLayout",
- module = "lovr.data",
- related = {
- "Sound:getChannelCount",
- "Sound:getByteStride"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "channels",
- type = "ChannelLayout",
- description = "The channel layout."
- }
- }
- }
- }
- },
- {
- name = "getDuration",
- summary = "Get the duration of the Sound.",
- description = "Returns the duration of the Sound, in seconds.",
- key = "Sound:getDuration",
- module = "lovr.data",
- notes = "This can be computed as `(frameCount / sampleRate)`.",
- related = {
- "Sound:getFrameCount",
- "Sound:getSampleCount",
- "Sound:getSampleRate",
- "Source:getDuration"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "duration",
- type = "number",
- description = "The duration of the Sound, in seconds."
- }
- }
- }
- }
- },
- {
- name = "getFormat",
- summary = "Get the sample format of the Sound.",
- description = "Returns the sample format of the Sound.",
- key = "Sound:getFormat",
- module = "lovr.data",
- related = {
- "Sound:getChannelLayout",
- "Sound:getByteStride",
- "Sound:getSampleRate"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "format",
- type = "SampleFormat",
- description = "The data type of each sample."
- }
- }
- }
- }
- },
- {
- name = "getFrameCount",
- summary = "Get the number of frames in the Sound.",
- description = "Returns the number of frames in the Sound. A frame stores one sample for each channel.",
- key = "Sound:getFrameCount",
- module = "lovr.data",
- notes = "For streams, this returns the number of frames in the stream's buffer.",
- related = {
- "Sound:getDuration",
- "Sound:getSampleCount",
- "Sound:getChannelCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frames",
- type = "number",
- description = "The number of frames in the Sound."
- }
- }
- }
- }
- },
- {
- name = "getFrames",
- summary = "Read frames from the Sound.",
- description = "Reads frames from the Sound into a table, Blob, or another Sound.",
- key = "Sound:getFrames",
- module = "lovr.data",
- variants = {
- {
- arguments = {
- {
- name = "count",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame offset to apply to the sound when reading frames.",
- default = "0"
- }
- },
- returns = {
- {
- name = "t",
- type = "table",
- description = "A table containing audio frames."
- },
- {
- name = "count",
- type = "number",
- description = "The number of frames read."
- }
- }
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "An existing table to read frames into."
- },
- {
- name = "count",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame offset to apply to the sound when reading frames.",
- default = "0"
- },
- {
- name = "dstOffset",
- type = "number",
- description = "An offset to apply to the destination when writing frames (indices for tables, bytes for Blobs, frames for Sounds).",
- default = "0"
- }
- },
- returns = {
- {
- name = "t",
- type = "table",
- description = "A table containing audio frames."
- },
- {
- name = "count",
- type = "number",
- description = "The number of frames read."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "A Blob to read frames into."
- },
- {
- name = "count",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame offset to apply to the sound when reading frames.",
- default = "0"
- },
- {
- name = "dstOffset",
- type = "number",
- description = "An offset to apply to the destination when writing frames (indices for tables, bytes for Blobs, frames for Sounds).",
- default = "0"
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of frames read."
- }
- }
- },
- {
- arguments = {
- {
- name = "sound",
- type = "Sound",
- description = "Another Sound to copy frames into."
- },
- {
- name = "count",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame offset to apply to the sound when reading frames.",
- default = "0"
- },
- {
- name = "dstOffset",
- type = "number",
- description = "An offset to apply to the destination when writing frames (indices for tables, bytes for Blobs, frames for Sounds).",
- default = "0"
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of frames read."
- }
- }
- }
- }
- },
- {
- name = "getSampleCount",
- summary = "Get the number of samples in the Sound.",
- description = "Returns the total number of samples in the Sound.",
- key = "Sound:getSampleCount",
- module = "lovr.data",
- notes = "For streams, this returns the number of samples in the stream's buffer.",
- related = {
- "Sound:getDuration",
- "Sound:getFrameCount",
- "Sound:getChannelCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "samples",
- type = "number",
- description = "The total number of samples in the Sound."
- }
- }
- }
- }
- },
- {
- name = "getSampleRate",
- summary = "Get the sample rate of the Sound.",
- 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.",
- key = "Sound:getSampleRate",
- module = "lovr.data",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The number of frames per second in the Sound."
- }
- }
- }
- }
- },
- {
- name = "isCompressed",
- summary = "Check if the Sound is compressed.",
- 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`.",
- key = "Sound:isCompressed",
- module = "lovr.data",
- related = {
- "Sound:isStream",
- "lovr.data.newSound"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "compressed",
- type = "boolean",
- description = "Whether the Sound is compressed."
- }
- }
- }
- }
- },
- {
- name = "isStream",
- summary = "Check if the Sound is a stream.",
- description = "Returns whether the Sound is a stream.",
- key = "Sound:isStream",
- module = "lovr.data",
- related = {
- "Sound:isCompressed",
- "lovr.data.newSound"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "stream",
- type = "boolean",
- description = "Whether the Sound is a stream."
- }
- }
- }
- }
- },
- {
- name = "setFrames",
- summary = "Write frames to the Sound.",
- description = "Writes frames to the Sound.",
- key = "Sound:setFrames",
- module = "lovr.data",
- examples = {
- {
- description = "Generate a sine wave.",
- 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"
- }
- },
- variants = {
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table containing frames to write."
- },
- {
- name = "count",
- type = "number",
- description = "How many frames to write. If nil, writes as many as possible.",
- default = "nil"
- },
- {
- name = "dstOffset",
- type = "number",
- description = "A frame offset to apply when writing the frames.",
- default = "0"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame, byte, or index offset to apply when reading frames from the source.",
- default = "0"
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of frames written."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing frames to write."
- },
- {
- name = "count",
- type = "number",
- description = "How many frames to write. If nil, writes as many as possible.",
- default = "nil"
- },
- {
- name = "dstOffset",
- type = "number",
- description = "A frame offset to apply when writing the frames.",
- default = "0"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame, byte, or index offset to apply when reading frames from the source.",
- default = "0"
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of frames written."
- }
- }
- },
- {
- arguments = {
- {
- name = "sound",
- type = "Sound",
- description = "Another Sound to copy frames from."
- },
- {
- name = "count",
- type = "number",
- description = "How many frames to write. If nil, writes as many as possible.",
- default = "nil"
- },
- {
- name = "dstOffset",
- type = "number",
- description = "A frame offset to apply when writing the frames.",
- default = "0"
- },
- {
- name = "srcOffset",
- type = "number",
- description = "A frame, byte, or index offset to apply when reading frames from the source.",
- default = "0"
- }
- },
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of frames written."
- }
- }
- }
- }
- }
- }
- }
- }
- },
- {
- name = "event",
- tag = "modules",
- summary = "Handles events from the operating system.",
- 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.",
- key = "lovr.event",
- enums = {
- {
- name = "DisplayType",
- summary = "Distinguishes between the headset and window displays.",
- description = "This enum is used to distinguish whether a display is the headset display or the desktop window.",
- key = "DisplayType",
- module = "lovr.event",
- related = {
- "lovr.focus",
- "lovr.visible"
- },
- values = {
- {
- name = "headset",
- description = "The headset."
- },
- {
- name = "window",
- description = "The desktop window."
- }
- }
- },
- {
- name = "KeyCode",
- summary = "Keys that can be pressed.",
- description = "Keys that can be pressed on a keyboard. Notably, numpad keys are missing right now.",
- key = "KeyCode",
- module = "lovr.event",
- related = {
- "lovr.keypressed",
- "lovr.keyreleased"
- },
- values = {
- {
- name = "a",
- description = "The A key."
- },
- {
- name = "b",
- description = "The B key."
- },
- {
- name = "c",
- description = "The C key."
- },
- {
- name = "d",
- description = "The D key."
- },
- {
- name = "e",
- description = "The E key."
- },
- {
- name = "f",
- description = "The F key."
- },
- {
- name = "g",
- description = "The G key."
- },
- {
- name = "h",
- description = "The H key."
- },
- {
- name = "i",
- description = "The I key."
- },
- {
- name = "j",
- description = "The J key."
- },
- {
- name = "k",
- description = "The K key."
- },
- {
- name = "l",
- description = "The L key."
- },
- {
- name = "m",
- description = "The M key."
- },
- {
- name = "n",
- description = "The N key."
- },
- {
- name = "o",
- description = "The O key."
- },
- {
- name = "p",
- description = "The P key."
- },
- {
- name = "q",
- description = "The Q key."
- },
- {
- name = "r",
- description = "The R key."
- },
- {
- name = "s",
- description = "The S key."
- },
- {
- name = "t",
- description = "The T key."
- },
- {
- name = "u",
- description = "The U key."
- },
- {
- name = "v",
- description = "The V key."
- },
- {
- name = "w",
- description = "The W key."
- },
- {
- name = "x",
- description = "The X key."
- },
- {
- name = "y",
- description = "The Y key."
- },
- {
- name = "z",
- description = "The Z key."
- },
- {
- name = "0",
- description = "The 0 key."
- },
- {
- name = "1",
- description = "The 1 key."
- },
- {
- name = "2",
- description = "The 2 key."
- },
- {
- name = "3",
- description = "The 3 key."
- },
- {
- name = "4",
- description = "The 4 key."
- },
- {
- name = "5",
- description = "The 5 key."
- },
- {
- name = "6",
- description = "The 6 key."
- },
- {
- name = "7",
- description = "The 7 key."
- },
- {
- name = "8",
- description = "The 8 key."
- },
- {
- name = "9",
- description = "The 9 key."
- },
- {
- name = "space",
- description = "The space bar."
- },
- {
- name = "return",
- description = "The enter key."
- },
- {
- name = "tab",
- description = "The tab key."
- },
- {
- name = "escape",
- description = "The escape key."
- },
- {
- name = "backspace",
- description = "The backspace key."
- },
- {
- name = "up",
- description = "The up arrow key."
- },
- {
- name = "down",
- description = "The down arrow key."
- },
- {
- name = "left",
- description = "The left arrow key."
- },
- {
- name = "right",
- description = "The right arrow key."
- },
- {
- name = "home",
- description = "The home key."
- },
- {
- name = "end",
- description = "The end key."
- },
- {
- name = "pageup",
- description = "The page up key."
- },
- {
- name = "pagedown",
- description = "The page down key."
- },
- {
- name = "insert",
- description = "The insert key."
- },
- {
- name = "delete",
- description = "The delete key."
- },
- {
- name = "f1",
- description = "The F1 key."
- },
- {
- name = "f2",
- description = "The F2 key."
- },
- {
- name = "f3",
- description = "The F3 key."
- },
- {
- name = "f4",
- description = "The F4 key."
- },
- {
- name = "f5",
- description = "The F5 key."
- },
- {
- name = "f6",
- description = "The F6 key."
- },
- {
- name = "f7",
- description = "The F7 key."
- },
- {
- name = "f8",
- description = "The F8 key."
- },
- {
- name = "f9",
- description = "The F9 key."
- },
- {
- name = "f10",
- description = "The F10 key."
- },
- {
- name = "f11",
- description = "The F11 key."
- },
- {
- name = "f12",
- description = "The F12 key."
- },
- {
- name = "`",
- description = "The backtick/backquote/grave accent key."
- },
- {
- name = "-",
- description = "The dash/hyphen/minus key."
- },
- {
- name = "=",
- description = "The equal sign key."
- },
- {
- name = "[",
- description = "The left bracket key."
- },
- {
- name = "]",
- description = "The right bracket key."
- },
- {
- name = "\\",
- description = "The backslash key."
- },
- {
- name = ";",
- description = "The semicolon key."
- },
- {
- name = "'",
- description = "The single quote key."
- },
- {
- name = ",",
- description = "The comma key."
- },
- {
- name = ".",
- description = "The period key."
- },
- {
- name = "/",
- description = "The slash key."
- },
- {
- name = "kp0",
- description = "The 0 numpad key."
- },
- {
- name = "kp1",
- description = "The 1 numpad key."
- },
- {
- name = "kp2",
- description = "The 2 numpad key."
- },
- {
- name = "kp3",
- description = "The 3 numpad key."
- },
- {
- name = "kp4",
- description = "The 4 numpad key."
- },
- {
- name = "kp5",
- description = "The 5 numpad key."
- },
- {
- name = "kp6",
- description = "The 6 numpad key."
- },
- {
- name = "kp7",
- description = "The 7 numpad key."
- },
- {
- name = "kp8",
- description = "The 8 numpad key."
- },
- {
- name = "kp9",
- description = "The 9 numpad key."
- },
- {
- name = "kp.",
- description = "The . numpad key."
- },
- {
- name = "kp/",
- description = "The / numpad key."
- },
- {
- name = "kp*",
- description = "The * numpad key."
- },
- {
- name = "kp-",
- description = "The - numpad key."
- },
- {
- name = "kp+",
- description = "The + numpad key."
- },
- {
- name = "kpenter",
- description = "The enter numpad key."
- },
- {
- name = "kp=",
- description = "The equals numpad key."
- },
- {
- name = "lctrl",
- description = "The left control key."
- },
- {
- name = "lshift",
- description = "The left shift key."
- },
- {
- name = "lalt",
- description = "The left alt key."
- },
- {
- name = "lgui",
- description = "The left OS key (windows, command, super)."
- },
- {
- name = "rctrl",
- description = "The right control key."
- },
- {
- name = "rshift",
- description = "The right shift key."
- },
- {
- name = "ralt",
- description = "The right alt key."
- },
- {
- name = "rgui",
- description = "The right OS key (windows, command, super)."
- },
- {
- name = "capslock",
- description = "The caps lock key."
- },
- {
- name = "scrolllock",
- description = "The scroll lock key."
- },
- {
- name = "numlock",
- description = "The numlock key."
- }
- }
- }
- },
- examples = {
- {
- description = "Adding a custom event.",
- 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"
- }
- },
- functions = {
- {
- name = "clear",
- summary = "Clear the event queue.",
- description = "Clears the event queue, removing any unprocessed events.",
- key = "lovr.event.clear",
- module = "lovr.event",
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "poll",
- summary = "Iterate over unprocessed events in the queue.",
- 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.",
- key = "lovr.event.poll",
- module = "lovr.event",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "iterator",
- type = "function",
- description = "The iterator function, usable in a for loop.",
- arguments = {},
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "push",
- summary = "Manually push an event onto the queue.",
- 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.",
- key = "lovr.event.push",
- module = "lovr.event",
- notes = "Only nil, booleans, numbers, strings, and LÖVR objects are supported types for event data.",
- related = {
- "lovr.event.poll",
- "lovr.event.quit"
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the event."
- },
- {
- name = "...",
- type = "*",
- description = "The arguments for the event. Currently, up to 4 are supported."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "quit",
- summary = "Quit the application.",
- 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.",
- key = "lovr.event.quit",
- module = "lovr.event",
- 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.",
- related = {
- "lovr.quit",
- "lovr.event.poll",
- "lovr.event.restart"
- },
- variants = {
- {
- arguments = {
- {
- name = "code",
- type = "number",
- description = "The exit code of the program.",
- default = "0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "restart",
- summary = "Restart the application.",
- description = "Pushes an event to restart the framework.",
- key = "lovr.event.restart",
- module = "lovr.event",
- 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.",
- related = {
- "lovr.restart",
- "lovr.event.poll",
- "lovr.event.quit"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- }
- },
- 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`.",
- objects = {}
- },
- {
- name = "filesystem",
- tag = "modules",
- summary = "Provides access to the filesystem.",
- 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\\<user>\\AppData\\Roaming\\LOVR\\<identity></code></td>\n </tr>\n <tr>\n <td>macOS</td>\n <td><code>/Users/<user>/Library/Application Support/LOVR/<identity></code></td>\n </tr>\n <tr>\n <td>Linux</td>\n <td><code>/home/<user>/.local/share/LOVR/<identity></code></td>\n </tr>\n <tr>\n <td>Android</td>\n <td><code>/sdcard/Android/data/<identity>/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`.",
- key = "lovr.filesystem",
- enums = {
- {
- name = "FileAction",
- summary = "Different actions that can be taken on files.",
- description = "The different actions that can be taken on files, reported by `lovr.filechanged` when filesystem watching is active.",
- key = "FileAction",
- module = "lovr.filesystem",
- values = {
- {
- name = "create",
- description = "The file was created."
- },
- {
- name = "delete",
- description = "The file was deleted."
- },
- {
- name = "modify",
- description = "The file's contents were modified."
- },
- {
- name = "rename",
- description = "The file was renamed."
- }
- }
- },
- {
- name = "OpenMode",
- summary = "Different ways to open a file.",
- description = "Different ways to open a `File` with `lovr.filesystem.newFile`.",
- key = "OpenMode",
- module = "lovr.filesystem",
- values = {
- {
- name = "r",
- description = "Open the file for reading."
- },
- {
- name = "w",
- description = "Open the file for writing (overwrites existing data)."
- },
- {
- name = "a",
- description = "Open the file for appending."
- }
- }
- }
- },
- functions = {
- {
- name = "append",
- tag = "filesystem-files",
- summary = "Append content to the end of a file.",
- description = "Appends content to the end of a file.",
- key = "lovr.filesystem.append",
- module = "lovr.filesystem",
- notes = "If the file does not exist, it is created.",
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The file to append to."
- },
- {
- name = "content",
- type = "string",
- description = "A string to write to the end of the file."
- }
- },
- returns = {
- {
- name = "success",
- type = "number",
- description = "Whether the operation was successful."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if there was an error."
- }
- }
- },
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The file to append to."
- },
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing data to append to the file."
- }
- },
- returns = {
- {
- name = "success",
- type = "number",
- description = "Whether the operation was successful."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if there was an error."
- }
- }
- }
- }
- },
- {
- name = "createDirectory",
- tag = "filesystem-files",
- summary = "Create a directory.",
- description = "Creates a directory in the save directory. Any parent directories that don't exist will also be created.",
- key = "lovr.filesystem.createDirectory",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The directory to create, recursively."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the directory was created."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if there was a failure."
- }
- }
- }
- }
- },
- {
- name = "getAppdataDirectory",
- tag = "filesystem-paths",
- summary = "Get the application data directory.",
- 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.",
- key = "lovr.filesystem.getAppdataDirectory",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The absolute path to the appdata directory."
- }
- }
- }
- }
- },
- {
- name = "getDirectoryItems",
- tag = "filesystem-files",
- summary = "Get a list of files in a directory.",
- description = "Returns a sorted table containing all files and folders in a single directory.",
- key = "lovr.filesystem.getDirectoryItems",
- module = "lovr.filesystem",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The directory."
- }
- },
- returns = {
- {
- name = "items",
- type = "table",
- description = "A table with a string for each file and subfolder in the directory."
- }
- }
- }
- }
- },
- {
- name = "getExecutablePath",
- tag = "filesystem-paths",
- summary = "Get the path of the LÖVR executable.",
- description = "Returns the absolute path of the LÖVR executable.",
- key = "lovr.filesystem.getExecutablePath",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The absolute path of the LÖVR executable, or `nil` if it is unknown."
- }
- }
- }
- }
- },
- {
- name = "getIdentity",
- tag = "filesystem-virtual",
- summary = "Get the name of the save directory.",
- 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`.",
- key = "lovr.filesystem.getIdentity",
- module = "lovr.filesystem",
- notes = "On Android, this is always the package id (like `org.lovr.app`).",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "identity",
- type = "string",
- description = "The name of the save directory, or `nil` if it isn't set."
- }
- }
- }
- }
- },
- {
- name = "getLastModified",
- tag = "filesystem-files",
- summary = "Get the modification time of a file.",
- description = "Returns when a file was last modified, since some arbitrary time in the past.",
- key = "lovr.filesystem.getLastModified",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The file to check."
- }
- },
- returns = {
- {
- name = "time",
- type = "number",
- description = "The modification time of the file, in seconds, or `nil` if there was an error."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if there was an error."
- }
- }
- }
- }
- },
- {
- name = "getRealDirectory",
- tag = "filesystem-virtual",
- summary = "Get the absolute path to a file.",
- 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.",
- key = "lovr.filesystem.getRealDirectory",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path to check."
- }
- },
- returns = {
- {
- name = "realpath",
- type = "string",
- description = "The absolute path of the mounted archive containing `path`."
- }
- }
- }
- }
- },
- {
- name = "getRequirePath",
- tag = "filesystem-lua",
- summary = "Get the require path.",
- 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.",
- key = "lovr.filesystem.getRequirePath",
- module = "lovr.filesystem",
- notes = "The default reqiure path is '?.lua;?/init.lua'.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The semicolon separated list of search patterns."
- }
- }
- }
- }
- },
- {
- name = "getSaveDirectory",
- tag = "filesystem-paths",
- summary = "Get the location of the save directory.",
- description = "Returns the absolute path to the save directory.",
- key = "lovr.filesystem.getSaveDirectory",
- module = "lovr.filesystem",
- 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`.",
- related = {
- "lovr.filesystem.getIdentity",
- "lovr.filesystem.getAppdataDirectory"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The absolute path to the save directory."
- }
- }
- }
- }
- },
- {
- name = "getSize",
- tag = "filesystem-files",
- summary = "Get the size of a file.",
- description = "Returns the size of a file, in bytes.",
- key = "lovr.filesystem.getSize",
- module = "lovr.filesystem",
- notes = "If the file does not exist, an error is thrown.",
- related = {
- "File:getSize"
- },
- variants = {
- {
- arguments = {
- {
- name = "file",
- type = "string",
- description = "The file."
- }
- },
- returns = {
- {
- name = "size",
- type = "number",
- description = "The size of the file, in bytes."
- }
- }
- }
- }
- },
- {
- name = "getSource",
- tag = "filesystem-paths",
- summary = "Get the location of the project source.",
- description = "Get the absolute path of the project's source directory or archive.",
- key = "lovr.filesystem.getSource",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The absolute path of the project's source, or `nil` if it's unknown."
- }
- }
- }
- }
- },
- {
- name = "getUserDirectory",
- tag = "filesystem-paths",
- summary = "Get the location of the user's home directory.",
- description = "Returns the absolute path of the user's home directory.",
- key = "lovr.filesystem.getUserDirectory",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The absolute path of the user's home directory."
- }
- }
- }
- }
- },
- {
- name = "getWorkingDirectory",
- tag = "filesystem-paths",
- summary = "Get the current working directory.",
- description = "Returns the absolute path of the working directory. Usually this is where the executable was started from.",
- key = "lovr.filesystem.getWorkingDirectory",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The current working directory, or `nil` if it's unknown."
- }
- }
- }
- }
- },
- {
- name = "isDirectory",
- tag = "filesystem-files",
- summary = "Check whether a path is a directory.",
- description = "Check if a path exists and is a directory.",
- key = "lovr.filesystem.isDirectory",
- module = "lovr.filesystem",
- related = {
- "lovr.filesystem.isFile"
- },
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path to check."
- }
- },
- returns = {
- {
- name = "isDirectory",
- type = "boolean",
- description = "Whether or not the path is a directory."
- }
- }
- }
- }
- },
- {
- name = "isFile",
- tag = "filesystem-files",
- summary = "Check whether a path is a file.",
- description = "Check if a path exists and is a file.",
- key = "lovr.filesystem.isFile",
- module = "lovr.filesystem",
- related = {
- "lovr.filesystem.isDirectory"
- },
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path to check."
- }
- },
- returns = {
- {
- name = "isFile",
- type = "boolean",
- description = "Whether or not the path is a file."
- }
- }
- }
- }
- },
- {
- name = "isFused",
- tag = "filesystem-virtual",
- summary = "Check if the project is fused.",
- description = "Returns whether the current project source is fused to the executable.",
- key = "lovr.filesystem.isFused",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "fused",
- type = "boolean",
- description = "Whether or not the project is fused."
- }
- }
- }
- }
- },
- {
- name = "load",
- tag = "filesystem-lua",
- summary = "Load a file as Lua code.",
- description = "Load a file containing Lua code, returning a Lua chunk that can be run.",
- key = "lovr.filesystem.load",
- module = "lovr.filesystem",
- examples = {
- {
- description = "Safely loading code:",
- 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"
- }
- },
- notes = "An error is thrown if the file contains syntax errors.",
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The file to load."
- },
- {
- name = "mode",
- type = "string",
- description = "The type of code that can be loaded. `t` allows text, `b` allows binary, and `bt` allows both.",
- default = "'bt'"
- }
- },
- returns = {
- {
- name = "chunk",
- type = "function",
- description = "The runnable chunk."
- }
- }
- }
- }
- },
- {
- name = "mount",
- tag = "filesystem-virtual",
- summary = "Mount a directory or archive.",
- description = "Mounts a directory or `.zip` archive, adding it to the virtual filesystem. This allows you to read files from it.",
- key = "lovr.filesystem.mount",
- module = "lovr.filesystem",
- examples = {
- {
- description = "Mount `data.zip` with a file `images/background.png`:",
- code = "lovr.filesystem.mount('data.zip', 'assets')\nprint(lovr.filesystem.isFile('assets/images/background.png')) -- true"
- }
- },
- 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.",
- related = {
- "lovr.filesystem.unmount"
- },
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path to mount."
- },
- {
- name = "mountpoint",
- type = "string",
- description = "The path in the virtual filesystem to mount to.",
- default = "'/'"
- },
- {
- name = "append",
- type = "boolean",
- description = "Whether the archive will be added to the end or the beginning of the search path.",
- default = "false"
- },
- {
- name = "root",
- type = "string",
- description = "A subdirectory inside the archive to use as the root. If `nil`, the actual root of the archive is used.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the archive was successfully mounted."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if the archive failed to mount."
- }
- }
- }
- }
- },
- {
- name = "newBlob",
- tag = "filesystem-files",
- summary = "Create a new Blob from a file.",
- description = "Creates a new Blob that contains the contents of a file.",
- key = "lovr.filesystem.newBlob",
- module = "lovr.filesystem",
- related = {
- "lovr.data.newBlob",
- "Blob"
- },
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The file to load."
- }
- },
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The new Blob."
- }
- }
- }
- }
- },
- {
- name = "newFile",
- tag = "filesystem-files",
- summary = "Open a file, returning a `File` object.",
- description = "Opens a file, returning a `File` object that can be used to read/write the file contents.\n\nNormally you can just use `lovr.filesystem.read`, `lovr.filesystem.write`, etc. However, those methods open and close the file each time they are called. So, when performing multiple operations on a file, creating a File object and keeping it open will have less overhead.",
- key = "lovr.filesystem.newFile",
- module = "lovr.filesystem",
- examples = {
- {
- code = "function lovr.load()\n local file = lovr.filesystem.newFile('asdf.txt', 'w')\n file:write('asdf')\n file:release()\nend"
- }
- },
- related = {
- "lovr.filesystem.read",
- "lovr.filesystem.write",
- "lovr.filesystem.append"
- },
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path of the file to open."
- },
- {
- name = "mode",
- type = "OpenMode",
- description = "The mode to open the file in (`r`, `w`, or `a`)."
- }
- },
- returns = {
- {
- name = "file",
- type = "File",
- description = "A new file object, or nil if an error occurred."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if an error occurred."
- }
- }
- }
- }
- },
- {
- name = "read",
- tag = "filesystem-files",
- summary = "Read a file.",
- description = "Read the contents of a file.",
- key = "lovr.filesystem.read",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The name of the file to read."
- }
- },
- returns = {
- {
- name = "contents",
- type = "string",
- description = "The contents of the file, or nil if the file could not be read."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if any."
- }
- }
- }
- }
- },
- {
- name = "remove",
- tag = "filesystem-files",
- summary = "Remove a file or directory.",
- description = "Remove a file or directory in the save directory.",
- key = "lovr.filesystem.remove",
- module = "lovr.filesystem",
- notes = "A directory can only be removed if it is empty.\n\nTo recursively remove a folder, use this function with `lovr.filesystem.getDirectoryItems`.",
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The file or directory to remove."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the path was removed."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if any."
- }
- }
- }
- }
- },
- {
- name = "setIdentity",
- tag = "filesystem-virtual",
- summary = "Set the name of the save directory.",
- 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`.",
- key = "lovr.filesystem.setIdentity",
- module = "lovr.filesystem",
- related = {
- "lovr.conf",
- "lovr.filesystem.getSaveDirectory"
- },
- variants = {
- {
- arguments = {
- {
- name = "identity",
- type = "string",
- description = "The name of the save directory."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setRequirePath",
- tag = "filesystem-lua",
- summary = "Set the require path.",
- 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.",
- key = "lovr.filesystem.setRequirePath",
- module = "lovr.filesystem",
- notes = "The default reqiure path is '?.lua;?/init.lua'.",
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "An optional semicolon separated list of search patterns.",
- default = "nil"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "unmount",
- tag = "filesystem-virtual",
- summary = "Unmount a mounted archive.",
- description = "Unmounts a directory or archive previously mounted with `lovr.filesystem.mount`.",
- key = "lovr.filesystem.unmount",
- module = "lovr.filesystem",
- notes = "This function is not thread safe. Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported.",
- related = {
- "lovr.filesystem.mount"
- },
- variants = {
- {
- arguments = {
- {
- name = "path",
- type = "string",
- description = "The path to unmount."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the archive was unmounted."
- }
- }
- }
- }
- },
- {
- name = "unwatch",
- tag = "filesystem-files",
- summary = "Stop watching files.",
- description = "Stops watching files.",
- key = "lovr.filesystem.unwatch",
- module = "lovr.filesystem",
- related = {
- "lovr.filesystem.watch",
- "lovr.filechanged"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "watch",
- tag = "filesystem-files",
- summary = "Start watching the filesystem for changes.",
- description = "Starts watching the filesystem for changes. File events will be reported by the `lovr.filechanged` callback.\n\nCurrently, on PC, only files in the source directory will be watched. On Android, files in the save directory will be watched instead, so that pushing new files with `adb` can be detected.",
- key = "lovr.filesystem.watch",
- module = "lovr.filesystem",
- related = {
- "lovr.filesystem.unwatch",
- "lovr.filechanged"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "write",
- tag = "filesystem-files",
- summary = "Write to a file.",
- description = "Write to a file in the save directory.",
- key = "lovr.filesystem.write",
- module = "lovr.filesystem",
- 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.",
- related = {
- "lovr.filesystem.append",
- "lovr.filesystem.getSaveDirectory",
- "lovr.filesystem.read"
- },
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The file to write to."
- },
- {
- name = "content",
- type = "string",
- description = "A string to write to the file."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the write was successful."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if there was an error."
- }
- }
- },
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The file to write to."
- },
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing data to write to the file."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the write was successful."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if there was an error."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "File",
- summary = "Represents an open file handle.",
- description = "A File is an object that provides read or write access to a file on the filesystem.",
- key = "File",
- module = "lovr.filesystem",
- constructors = {
- "lovr.filesystem.newFile"
- },
- methods = {
- {
- name = "getMode",
- summary = "Get the mode the file was opened in.",
- description = "Returns the mode the file was opened in.",
- key = "File:getMode",
- module = "lovr.filesystem",
- related = {
- "File:getPath"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mode",
- type = "OpenMode",
- description = "The mode the file was opened in (`r`, `w`, or `a`)."
- }
- }
- }
- }
- },
- {
- name = "getPath",
- summary = "Get the file's path.",
- description = "Returns the file's path.",
- key = "File:getPath",
- module = "lovr.filesystem",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "path",
- type = "string",
- description = "The file path."
- }
- }
- }
- }
- },
- {
- name = "getSize",
- summary = "Get the size of the File.",
- description = "Returns the size of the file, in bytes.",
- key = "File:getSize",
- module = "lovr.filesystem",
- related = {
- "lovr.filesystem.getSize"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "size",
- type = "number",
- description = "The size of the file, in bytes, or nil if an error occurred."
- },
- {
- name = "error",
- type = "string",
- description = "The error message, if an error occurred."
- }
- }
- }
- }
- },
- {
- name = "isEOF",
- summary = "Check if the end of the file has been reached.",
- description = "Returns whether the end of file has been reached. When true, `File:read` will no longer return data.",
- key = "File:isEOF",
- module = "lovr.filesystem",
- related = {
- "File:seek",
- "File:tell",
- "File:getSize"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "eof",
- type = "boolean",
- description = "Whether the end of the file has been reached."
- }
- }
- }
- }
- },
- {
- name = "read",
- summary = "Read data from the file.",
- description = "Reads data from the file.",
- key = "File:read",
- module = "lovr.filesystem",
- notes = "The file must have been opened for reading.\n\nThe maximum number of bytes that can be read at a time is 2^53 - 1.",
- related = {
- "File:write",
- "lovr.filesystem.read",
- "lovr.filesystem.newBlob"
- },
- variants = {
- {
- arguments = {
- {
- name = "bytes",
- type = "number",
- description = "The number of bytes to read from the file, or `nil` to read the rest of the file."
- }
- },
- returns = {
- {
- name = "data",
- type = "string",
- description = "The data that was read, or nil if an error occurred."
- },
- {
- name = "size",
- type = "number",
- description = "The number of bytes that were read, or the error message if an error occurred."
- }
- }
- }
- }
- },
- {
- name = "seek",
- summary = "Seek to a position in the file.",
- description = "Seeks to a new position in the file. `File:read` and `File:write` will read/write relative to this position.",
- key = "File:seek",
- module = "lovr.filesystem",
- related = {
- "File:tell",
- "File:getSize"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "The new file offset, in bytes."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "tell",
- summary = "Get the seek position of the file.",
- description = "Returns the seek position of the file, which is where `File:read` and `File:write will read/write from.",
- key = "File:tell",
- module = "lovr.filesystem",
- related = {
- "File:seek"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "offset",
- type = "number",
- description = "The file offset, in bytes."
- }
- }
- }
- }
- },
- {
- name = "write",
- summary = "Write data to the file.",
- description = "Writes data to the file.",
- key = "File:write",
- module = "lovr.filesystem",
- notes = "The maximum number of bytes that can be written at a time is 2^53 - 1.\n\nUse `File:seek` to control where the data is written.",
- related = {
- "File:read",
- "lovr.filesystem.write",
- "lovr.filesystem.append"
- },
- variants = {
- {
- arguments = {
- {
- name = "string",
- type = "string",
- description = "A string to write to the file."
- },
- {
- name = "size",
- type = "number",
- description = "The number of bytes to write, or nil to write all of the data from the string/Blob.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the data was successfully written."
- },
- {
- name = "message",
- type = "string",
- description = "The error message."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob containing data to write to the file."
- },
- {
- name = "size",
- type = "number",
- description = "The number of bytes to write, or nil to write all of the data from the string/Blob.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the data was successfully written."
- },
- {
- name = "message",
- type = "string",
- description = "The error message."
- }
- }
- }
- }
- }
- }
- }
- },
- sections = {
- {
- name = "Files",
- tag = "filesystem-files",
- description = "Operations for reading/writing files and querying their metadata."
- },
- {
- name = "Virtual Filesystem",
- tag = "filesystem-virtual"
- },
- {
- name = "Paths",
- tag = "filesystem-paths",
- description = "Useful system paths."
- },
- {
- name = "Lua",
- tag = "filesystem-lua"
- }
- }
- },
- {
- name = "graphics",
- tag = "modules",
- summary = "Renders graphics using the GPU.",
- description = "The graphics module renders graphics and performs computation using the GPU.\n\nMost of the graphics functions are on the `Pass` object.",
- key = "lovr.graphics",
- enums = {
- {
- name = "BlendAlphaMode",
- summary = "Whether premultiplied alpha is enabled.",
- description = "Controls whether premultiplied alpha is enabled.",
- key = "BlendAlphaMode",
- module = "lovr.graphics",
- 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.",
- related = {
- "BlendMode",
- "Pass:setBlendMode"
- },
- values = {
- {
- name = "alphamultiply",
- description = "Color channel values are multiplied by the alpha channel during blending."
- },
- {
- name = "premultiplied",
- 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\"."
- }
- }
- },
- {
- name = "BlendMode",
- summary = "Blend modes.",
- description = "Different ways pixels can blend with the pixels behind them.",
- key = "BlendMode",
- module = "lovr.graphics",
- related = {
- "BlendAlphaMode",
- "Pass:setBlendMode"
- },
- values = {
- {
- name = "alpha",
- description = "Colors will be mixed based on alpha."
- },
- {
- name = "add",
- description = "Colors will be added to the existing color, alpha will not be changed."
- },
- {
- name = "subtract",
- description = "Colors will be subtracted from the existing color, alpha will not be changed."
- },
- {
- name = "multiply",
- description = "All color channels will be multiplied together, producing a darkening effect."
- },
- {
- name = "lighten",
- description = "The maximum value of each color channel will be used."
- },
- {
- name = "darken",
- description = "The minimum value of each color channel will be used."
- },
- {
- name = "screen",
- description = "The opposite of multiply: the pixel colors are inverted, multiplied, and inverted again, producing a lightening effect."
- }
- }
- },
- {
- name = "CompareMode",
- summary = "Different ways of performing comparisons.",
- 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.",
- key = "CompareMode",
- module = "lovr.graphics",
- notes = "This type can also be specified using mathematical notation, e.g. `=`, `>`, `<=`, etc. `notequal` can be provided as `~=` or `!=`.",
- related = {
- "Pass:setDepthTest",
- "Pass:setStencilTest",
- "Pass:setDepthWrite",
- "Pass:setStencilWrite"
- },
- values = {
- {
- name = "none",
- description = "The test does not take place, and acts as though it always passes."
- },
- {
- name = "equal",
- description = "The test passes if the values are equal."
- },
- {
- name = "notequal",
- description = "The test passes if the values are not equal."
- },
- {
- name = "less",
- description = "The test passes if the value is less than the existing one."
- },
- {
- name = "lequal",
- description = "The test passes if the value is less than or equal to the existing one."
- },
- {
- name = "greater",
- description = "The test passes if the value is greater than the existing one."
- },
- {
- name = "gequal",
- description = "The test passes if the value is greater than or equal to the existing one."
- }
- }
- },
- {
- name = "CullMode",
- summary = "Different ways of doing face culling.",
- description = "The different ways of doing triangle backface culling.",
- key = "CullMode",
- module = "lovr.graphics",
- related = {
- "Winding",
- "Pass:setCullMode",
- "Pass:setWinding"
- },
- values = {
- {
- name = "none",
- description = "Both sides of triangles will be drawn."
- },
- {
- name = "back",
- description = "Skips rendering the back side of triangles."
- },
- {
- name = "front",
- description = "Skips rendering the front side of triangles."
- }
- }
- },
- {
- name = "DataLayout",
- summary = "Different ways of padding GPU buffer data.",
- 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[]; }",
- key = "DataLayout",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newBuffer",
- "Buffer:getFormat",
- "Buffer:getStride",
- "DataType"
- },
- values = {
- {
- name = "packed",
- description = "The packed layout, without any padding."
- },
- {
- name = "std140",
- description = "The std140 layout."
- },
- {
- name = "std430",
- description = "The std430 layout."
- }
- }
- },
- {
- name = "DataType",
- summary = "Different types for `Buffer` fields.",
- 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)",
- key = "DataType",
- module = "lovr.graphics",
- 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!",
- related = {
- "lovr.graphics.newBuffer",
- "Buffer:getFormat"
- },
- values = {
- {
- name = "i8x4",
- description = "Four 8-bit signed integers."
- },
- {
- name = "u8x4",
- description = "Four 8-bit unsigned integers."
- },
- {
- name = "sn8x4",
- description = "Four 8-bit signed normalized values."
- },
- {
- name = "un8x4",
- description = "Four 8-bit unsigned normalized values (aka `color`)."
- },
- {
- name = "sn10x3",
- description = "Three 10-bit signed normalized values, and 2 padding bits."
- },
- {
- name = "un10x3",
- description = "Three 10-bit unsigned normalized values, and 2 padding bits."
- },
- {
- name = "i16",
- description = "One 16-bit signed integer."
- },
- {
- name = "i16x2",
- description = "Two 16-bit signed integers."
- },
- {
- name = "i16x4",
- description = "Four 16-bit signed integers."
- },
- {
- name = "u16",
- description = "One 16-bit unsigned integer."
- },
- {
- name = "u16x2",
- description = "Two 16-bit unsigned integers."
- },
- {
- name = "u16x4",
- description = "Four 16-bit unsigned integers."
- },
- {
- name = "sn16x2",
- description = "Two 16-bit signed normalized values."
- },
- {
- name = "sn16x4",
- description = "Four 16-bit signed normalized values."
- },
- {
- name = "un16x2",
- description = "Two 16-bit unsigned normalized values."
- },
- {
- name = "un16x4",
- description = "Four 16-bit unsigned normalized values."
- },
- {
- name = "i32",
- description = "One 32-bit signed integer (aka `int`)."
- },
- {
- name = "i32x2",
- description = "Two 32-bit signed integers."
- },
- {
- name = "i32x3",
- description = "Three 32-bit signed integers."
- },
- {
- name = "i32x4",
- description = "Four 32-bit signed integers."
- },
- {
- name = "u32",
- description = "One 32-bit unsigned integer (aka `uint`)."
- },
- {
- name = "u32x2",
- description = "Two 32-bit unsigned integers."
- },
- {
- name = "u32x3",
- description = "Three 32-bit unsigned integers."
- },
- {
- name = "u32x4",
- description = "Four 32-bit unsigned integers."
- },
- {
- name = "f16x2",
- description = "Two 16-bit floating point numbers."
- },
- {
- name = "f16x4",
- description = "Four 16-bit floating point numbers."
- },
- {
- name = "f32",
- description = "One 32-bit floating point number (aka `float`)."
- },
- {
- name = "f32x2",
- description = "Two 32-bit floating point numbers (aka `vec2`)."
- },
- {
- name = "f32x3",
- description = "Three 32-bit floating point numbers (aka `vec3`)."
- },
- {
- name = "f32x4",
- description = "Four 32-bit floating point numbers (aka `vec4`)."
- },
- {
- name = "mat2",
- description = "A 2x2 matrix containing four 32-bit floats."
- },
- {
- name = "mat3",
- description = "A 3x3 matrix containing nine 32-bit floats."
- },
- {
- name = "mat4",
- description = "A 4x4 matrix containing sixteen 32-bit floats."
- },
- {
- name = "index16",
- description = "Like u16, but 1-indexed."
- },
- {
- name = "index32",
- description = "Like u32, but 1-indexed."
- }
- }
- },
- {
- name = "DefaultShader",
- summary = "Built-in shaders.",
- 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.",
- key = "DefaultShader",
- module = "lovr.graphics",
- values = {
- {
- name = "unlit",
- description = "Basic shader without lighting that uses colors and a texture."
- },
- {
- name = "normal",
- description = "Shades triangles based on their normal, resulting in a cool rainbow effect."
- },
- {
- name = "font",
- description = "Renders font glyphs."
- },
- {
- name = "cubemap",
- description = "Renders cubemaps."
- },
- {
- name = "equirect",
- description = "Renders spherical textures."
- },
- {
- name = "fill",
- description = "Renders a fullscreen triangle."
- }
- }
- },
- {
- name = "DrawMode",
- summary = "Different ways to draw mesh vertices.",
- description = "Different ways vertices in a mesh can be connected together and filled in with pixels.",
- key = "DrawMode",
- module = "lovr.graphics",
- values = {
- {
- name = "points",
- 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`."
- },
- {
- name = "lines",
- 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."
- },
- {
- name = "triangles",
- 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."
- }
- }
- },
- {
- name = "DrawStyle",
- summary = "Different styles to draw shapes.",
- description = "Whether a shape should be drawn filled or outlined.",
- key = "DrawStyle",
- module = "lovr.graphics",
- related = {
- "Pass:plane",
- "Pass:cube",
- "Pass:box",
- "Pass:circle"
- },
- values = {
- {
- name = "fill",
- description = "The shape will be filled in (the default)."
- },
- {
- name = "line",
- description = "The shape will be outlined."
- }
- }
- },
- {
- name = "FilterMode",
- summary = "Different ways to smooth textures.",
- description = "Controls how `Sampler` objects smooth pixels in textures.",
- key = "FilterMode",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newSampler",
- "Sampler:getFilter",
- "Texture:setPixels"
- },
- values = {
- {
- name = "nearest",
- description = "A pixelated appearance where the \"nearest neighbor\" pixel is used."
- },
- {
- name = "linear",
- description = "A smooth appearance where neighboring pixels are averaged."
- },
- {
- name = "cubic",
- description = "An even smoother appearance, but slower and typically only available on mobile GPUs. Use `lovr.graphics.isFormatSupported('format', 'cubic')` to check for support for a specific format, or `lovr.graphics.getFeatures().cubic` to see if cubic filtering is supported at all.\n\nNote that this can only be used for `min` and `mag` options in sampler. Trying to use this for the `mip` filter mode will silently fall back to `linear`."
- }
- }
- },
- {
- name = "HorizontalAlign",
- summary = "Different ways to horizontally align text.",
- description = "Different ways to horizontally align text with `Pass:text`.",
- key = "HorizontalAlign",
- module = "lovr.graphics",
- related = {
- "VerticalAlign",
- "Pass:text",
- "Font:getVertices"
- },
- values = {
- {
- name = "left",
- description = "Left-aligned text."
- },
- {
- name = "center",
- description = "Centered text."
- },
- {
- name = "right",
- description = "Right-aligned text."
- }
- }
- },
- {
- name = "MeshStorage",
- summary = "Whether a Mesh stores its data on the CPU or GPU.",
- description = "Whether a Mesh stores its data on the CPU or GPU.",
- key = "MeshStorage",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.newMesh"
- },
- values = {
- {
- name = "cpu",
- description = "The Mesh will store a copy of the vertices on the CPU."
- },
- {
- name = "gpu",
- description = "The Mesh will not keep a CPU copy, only storing vertices on the GPU."
- }
- }
- },
- {
- name = "OriginType",
- summary = "Different coordinate spaces for nodes in a Model.",
- description = "Different coordinate spaces for nodes in a `Model`.",
- key = "OriginType",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:getNodeOrientation",
- "Model:getNodeScale",
- "Model:getNodePose",
- "Model:getNodeTransform",
- "Model:getRootNode",
- "Model:getNodeParent"
- },
- values = {
- {
- name = "root",
- description = "Transforms are relative to the origin (root) of the Model."
- },
- {
- name = "parent",
- description = "Transforms are relative to the parent of the node."
- }
- }
- },
- {
- name = "PassType",
- summary = "Different types of Passes.",
- 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.",
- key = "PassType",
- module = "lovr.graphics",
- deprecated = true,
- related = {
- "lovr.graphics.getPass",
- "lovr.graphics.submit",
- "Pass:getType"
- },
- values = {
- {
- name = "render",
- 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."
- },
- {
- name = "compute",
- 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."
- },
- {
- name = "transfer",
- 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."
- }
- }
- },
- {
- name = "ShaderStage",
- summary = "Different shader stages.",
- description = "Different shader stages. Graphics shaders have a `vertex` and `fragment` stage, and compute shaders have a single `compute` stage.",
- key = "ShaderStage",
- module = "lovr.graphics",
- values = {
- {
- name = "vertex",
- description = "The vertex stage, which computes transformed vertex positions."
- },
- {
- name = "fragment",
- description = "The fragment stage, which computes pixel colors."
- },
- {
- name = "compute",
- description = "The compute stage, which performs arbitrary computation."
- }
- }
- },
- {
- name = "ShaderType",
- summary = "Different types of Shaders.",
- description = "The two types of shaders that can be created.",
- key = "ShaderType",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newShader",
- "Shader:getType",
- "ShaderStage"
- },
- values = {
- {
- name = "graphics",
- description = "A graphics shader with a vertex and pixel stage."
- },
- {
- name = "compute",
- description = "A compute shader with a single compute stage."
- }
- }
- },
- {
- name = "StackType",
- summary = "Types of stacks that can be pushed and popped.",
- description = "Different types of stacks that can be pushed and popped with `Pass:push` and `Pass:pop`.",
- key = "StackType",
- module = "lovr.graphics",
- values = {
- {
- name = "transform",
- description = "The transform stack (`Pass:transform`, `Pass:translate`, etc.)."
- },
- {
- name = "state",
- description = "Graphics state, like `Pass:setColor`, `Pass:setFont`, etc. Notably this does not include camera poses/projections or shader variables changed with `Pass:send`."
- }
- }
- },
- {
- name = "StencilAction",
- summary = "Different ways of updating the stencil buffer.",
- description = "Different ways of updating the stencil buffer with `Pass:setStencilWrite`.",
- key = "StencilAction",
- module = "lovr.graphics",
- related = {
- "Pass:setStencilWrite",
- "Pass:setStencilTest",
- "Pass:setColorWrite"
- },
- values = {
- {
- name = "keep",
- description = "Stencil buffer pixels will not be changed by draws."
- },
- {
- name = "zero",
- description = "Stencil buffer pixels will be set to zero."
- },
- {
- name = "replace",
- description = "Stencil buffer pixels will be replaced with a custom value."
- },
- {
- name = "increment",
- description = "Stencil buffer pixels will be incremented each time they're rendered to."
- },
- {
- name = "decrement",
- description = "Stencil buffer pixels will be decremented each time they're rendered to."
- },
- {
- name = "incrementwrap",
- description = "Similar to increment, but will wrap around to 0 when it exceeds 255."
- },
- {
- name = "decrementwrap",
- description = "Similar to decrement, but will wrap around to 255 when it goes below 0."
- },
- {
- name = "invert",
- description = "The bits in the stencil buffer pixels will be inverted."
- }
- }
- },
- {
- name = "TextureFeature",
- summary = "Different ways Textures can be used.",
- 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.",
- key = "TextureFeature",
- module = "lovr.graphics",
- values = {
- {
- name = "sample",
- description = "The Texture can be sampled (e.g. used in a `Material` or sent to a `texture2D` variable in shaders)."
- },
- {
- name = "render",
- description = "The Texture can used as a canvas in a `Pass`."
- },
- {
- name = "storage",
- description = "The Texture can be sent to a storage image variable in shaders (e.g. `image2D`)."
- },
- {
- name = "blit",
- description = "The Texture can be used with `Pass:blit` and `Pass:generateMipmaps`."
- },
- {
- name = "cubic",
- description = "The Texture can be used with a sampler that uses a `cubic` filter mode. See `FilterMode`."
- }
- }
- },
- {
- name = "TextureType",
- summary = "The different types of textures.",
- 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.",
- key = "TextureType",
- module = "lovr.graphics",
- values = {
- {
- name = "2d",
- description = "A single 2D image, the most common type."
- },
- {
- name = "3d",
- 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."
- },
- {
- name = "cube",
- description = "Six square 2D images with the same dimensions that define the faces of a cubemap, used for skyboxes or other \"directional\" images. Can also have higher multiples of 6 images, which will be interpreted as a cubemap array image."
- },
- {
- name = "array",
- description = "Array textures are sequences of distinct 2D images that all have the same dimensions."
- }
- }
- },
- {
- name = "TextureUsage",
- summary = "Different operations `Texture` can be used for.",
- 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`.",
- key = "TextureUsage",
- module = "lovr.graphics",
- values = {
- {
- name = "sample",
- 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`)."
- },
- {
- name = "render",
- description = "Whether the texture can be rendered to (i.e. by using it as a render target in `lovr.graphics.pass`)."
- },
- {
- name = "storage",
- 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`)."
- },
- {
- name = "transfer",
- description = "Whether the texture can be used for transfer operations like `Texture:setPixels`, `Texture:blit`, etc."
- }
- }
- },
- {
- name = "VerticalAlign",
- summary = "Different ways to vertically align text.",
- description = "Different ways to vertically align text with `Pass:text`.",
- key = "VerticalAlign",
- module = "lovr.graphics",
- related = {
- "HorizontalAlign",
- "Pass:text",
- "Font:getVertices"
- },
- values = {
- {
- name = "top",
- description = "Top-aligned text."
- },
- {
- name = "middle",
- description = "Centered text."
- },
- {
- name = "bottom",
- description = "Bottom-aligned text."
- }
- }
- },
- {
- name = "Winding",
- summary = "Different triangle windings.",
- description = "Indicates whether the front face of a triangle uses the clockwise or counterclockwise vertex order.",
- key = "Winding",
- module = "lovr.graphics",
- related = {
- "Pass:setWinding",
- "Pass:setCullMode"
- },
- values = {
- {
- name = "clockwise",
- description = "Clockwise winding."
- },
- {
- name = "counterclockwise",
- description = "Counterclockwise winding."
- }
- }
- },
- {
- name = "WrapMode",
- summary = "Different ways to wrap textures.",
- description = "Controls how `Sampler` objects wrap textures.",
- key = "WrapMode",
- module = "lovr.graphics",
- values = {
- {
- name = "clamp",
- description = "Pixels will be clamped to the edge, with pixels outside the 0-1 uv range using colors from the nearest edge."
- },
- {
- name = "repeat",
- description = "Tiles the texture."
- },
- {
- name = "mirror",
- description = "Similar to `repeat`, but flips the texture each time it repeats."
- },
- {
- name = "border",
- description = "Similar to `clamp`, but everything outside the 0-1 uv range will be filled with transparent black, i.e. `(0, 0, 0, 0)`."
- }
- }
- }
- },
- functions = {
- {
- name = "compileShader",
- tag = "graphics-objects",
- summary = "Compile shader code to bytecode.",
- 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.",
- key = "lovr.graphics.compileShader",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.newShader",
- "Shader"
- },
- variants = {
- {
- arguments = {
- {
- name = "stage",
- type = "ShaderStage",
- description = "The type of shader to compile."
- },
- {
- name = "source",
- type = "string",
- description = "A string or filename with shader code."
- }
- },
- returns = {
- {
- name = "bytecode",
- type = "Blob",
- description = "A Blob containing compiled SPIR-V code."
- }
- }
- },
- {
- arguments = {
- {
- name = "stage",
- type = "ShaderStage",
- description = "The type of shader to compile."
- },
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing shader code."
- }
- },
- returns = {
- {
- name = "bytecode",
- type = "Blob",
- description = "A Blob containing compiled SPIR-V code."
- }
- }
- }
- }
- },
- {
- name = "getBackgroundColor",
- tag = "graphics-global",
- summary = "Get the background color.",
- 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.",
- key = "lovr.graphics.getBackgroundColor",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.newPass",
- "Pass:setClear",
- "Texture:clear",
- "Pass:fill"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "r",
- type = "number",
- description = "The red component of the background color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the background color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the background color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the background color."
- }
- }
- }
- }
- },
- {
- name = "getBuffer",
- tag = "graphics-objects",
- summary = "Get a temporary Buffer.",
- description = "Returns a temporary Buffer.",
- key = "lovr.graphics.getBuffer",
- module = "lovr.graphics",
- deprecated = true,
- examples = {
- {
- description = "Examples of different buffer formats.",
- 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'))"
- }
- },
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "size",
- type = "number",
- description = "The size of the Buffer, in bytes."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- },
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- },
- {
- name = "data",
- type = "table",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- },
- {
- name = "blob",
- type = "Blob",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- },
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- },
- {
- name = "data",
- type = "table",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- },
- {
- name = "blob",
- type = "Blob",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "data",
- type = "table",
- 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."
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- },
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "data",
- type = "table",
- 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."
- },
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- },
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- }
- }
- },
- {
- name = "getDefaultFont",
- tag = "graphics-objects",
- summary = "Get the default Font.",
- 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.",
- key = "lovr.graphics.getDefaultFont",
- module = "lovr.graphics",
- related = {
- "Pass:text",
- "lovr.graphics.newFont"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "font",
- type = "Font",
- description = "The default Font object."
- }
- }
- }
- }
- },
- {
- name = "getDevice",
- tag = "graphics-misc",
- summary = "Get information about the graphics device and driver.",
- description = "Returns information about the graphics device and driver.",
- key = "lovr.graphics.getDevice",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.getFeatures",
- "lovr.graphics.getLimits"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "device",
- type = "table",
- table = {
- {
- name = "id",
- type = "number",
- description = "The vendor-unique number for this GPU."
- },
- {
- name = "vendor",
- type = "number",
- description = "The identifier of the GPU vendor."
- },
- {
- name = "name",
- type = "string",
- description = "The name of the GPU."
- },
- {
- name = "renderer",
- type = "string",
- description = "The renderer in use, currently either \"Vulkan\" or \"WebGPU\"."
- },
- {
- name = "subgroupSize",
- type = "number",
- 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."
- },
- {
- name = "discrete",
- type = "boolean",
- description = "Whether the GPU is a discrete graphics card."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getFeatures",
- tag = "graphics-misc",
- summary = "Get the supported GPU features.",
- description = "Returns a table indicating which features are supported by the GPU.",
- key = "lovr.graphics.getFeatures",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.isFormatSupported",
- "lovr.graphics.getDevice",
- "lovr.graphics.getLimits"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "features",
- type = "table",
- description = "",
- table = {
- {
- name = "textureBC",
- type = "boolean",
- 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."
- },
- {
- name = "textureASTC",
- type = "boolean",
- 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."
- },
- {
- name = "wireframe",
- type = "boolean",
- 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."
- },
- {
- name = "depthClamp",
- type = "boolean",
- description = "When supported, `Pass:setDepthClamp` will work, otherwise it will do nothing."
- },
- {
- name = "depthResolve",
- type = "boolean",
- 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."
- },
- {
- name = "indirectDrawFirstInstance",
- type = "boolean",
- description = "Whether indirect draws can set the firstInstance property of buffer memory to something other than zero."
- },
- {
- name = "float64",
- type = "boolean",
- description = "Whether shader code can use doubles."
- },
- {
- name = "int64",
- type = "boolean",
- description = "Whether shader code can use signed and unsigned 64-bit integers."
- },
- {
- name = "int16",
- type = "boolean",
- description = "Whether shader code can use signed and unsigned 16-bit integers."
- },
- {
- name = "cubic",
- type = "boolean",
- description = "Whether the GPU supports cubic texture filtering. To check for specific format support, use `lovr.graphics.isFormatSupported` with the `cubic` `TextureFeature`."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getLimits",
- tag = "graphics-misc",
- summary = "Get the limits of the current GPU.",
- description = "Returns limits of the current GPU.",
- key = "lovr.graphics.getLimits",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.isFormatSupported",
- "lovr.graphics.getDevice",
- "lovr.graphics.getFeatures"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "limits",
- type = "table",
- description = "",
- table = {
- {
- name = "textureSize2D",
- type = "number",
- description = "The maximum width/height of `2d` and `array` textures."
- },
- {
- name = "textureSize3D",
- type = "number",
- description = "The maximum width/height/depth of `3d` textures."
- },
- {
- name = "textureSizeCube",
- type = "number",
- description = "The maximum width/height of `cube` textures."
- },
- {
- name = "textureLayers",
- type = "number",
- description = "The maximum depth of `array` textures."
- },
- {
- name = "renderSize",
- type = "table",
- description = "The maximum width, height, and layer count of a texture (or texture view) used as a render target."
- },
- {
- name = "uniformBuffersPerStage",
- type = "number",
- description = "The maximum number of uniform buffers in a shader stage."
- },
- {
- name = "storageBuffersPerStage",
- type = "number",
- description = "The maximum number of storage buffers in a shader stage."
- },
- {
- name = "sampledTexturesPerStage",
- type = "number",
- description = "The maximum number of sampled textures in a shader stage."
- },
- {
- name = "storageTexturesPerStage",
- type = "number",
- description = "The maximum number of storage textures in a shader stage."
- },
- {
- name = "samplersPerStage",
- type = "number",
- description = "The maximum number of samplers in a shader stage."
- },
- {
- name = "resourcesPerShader",
- type = "number",
- description = "The maximum combined number of buffers, textures, and sampler variables in a Shader."
- },
- {
- name = "uniformBufferRange",
- type = "number",
- description = "The maximum range of bytes that can be bound to a uniform buffer in a shader."
- },
- {
- name = "storageBufferRange",
- type = "number",
- description = "The maximum range of bytes that can be bound to a storage buffer in a shader."
- },
- {
- name = "uniformBufferAlign",
- type = "number",
- 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."
- },
- {
- name = "storageBufferAlign",
- type = "number",
- 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."
- },
- {
- name = "vertexAttributes",
- type = "number",
- description = "The maximum number of input attributes in a vertex shader."
- },
- {
- name = "vertexBufferStride",
- type = "number",
- description = "The maximum stride of a buffer used as a vertex buffer, in bytes."
- },
- {
- name = "vertexShaderOutputs",
- type = "number",
- description = "The maximum number of components output from a vertex shader."
- },
- {
- name = "clipDistances",
- type = "number",
- description = "The maximum number of clipping planes declared by a shader."
- },
- {
- name = "cullDistances",
- type = "number",
- description = "The maximum number of cull distances declared by a shader."
- },
- {
- name = "clipAndCullDistances",
- type = "number",
- description = "The maximum number of clipping planes and cull distances declared by a shader."
- },
- {
- name = "workgroupCount",
- type = "table",
- description = "The maximum values of `x`, `y`, and `z` in `Pass:compute`."
- },
- {
- name = "workgroupSize",
- type = "table",
- description = "The maximum values of `local_size_x`, `local_size_y`, and `local_size_z` declared in a compute shader."
- },
- {
- name = "totalWorkgroupSize",
- type = "number",
- description = "The maximum product of `local_size_x`, `local_size_y`, and `local_size_z` in a compute shader."
- },
- {
- name = "computeSharedMemory",
- type = "number",
- description = "The maximum number of bytes used by `shared` variables in compute shaders."
- },
- {
- name = "indirectDrawCount",
- type = "number",
- description = "The maximum number of draws that can be issued by an indirect draw call."
- },
- {
- name = "instances",
- type = "number",
- description = "The maximum number of instances that can be rendered in a draw call."
- },
- {
- name = "anisotropy",
- type = "number",
- description = "The maximum value of the `anisotropy` parameter in `lovr.graphics.newSampler`."
- },
- {
- name = "pointSize",
- type = "number",
- description = "The maximum point size."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getPass",
- tag = "graphics-objects",
- summary = "Get a temporary Pass.",
- description = "Creates and returns a temporary Pass object.",
- key = "lovr.graphics.getPass",
- module = "lovr.graphics",
- deprecated = true,
- 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 `lovr.graphics.newTextureView`.\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.",
- related = {
- "lovr.graphics.submit",
- "lovr.graphics.getWindowPass",
- "lovr.headset.getPass"
- },
- variants = {
- {
- description = "Create a compute pass.",
- arguments = {
- {
- name = "type",
- type = "PassType",
- description = "The type of pass to create."
- }
- },
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The new Pass."
- }
- }
- },
- {
- description = "Create a render pass.",
- arguments = {
- {
- name = "type",
- type = "PassType",
- description = "The type of pass to create."
- },
- {
- name = "texture",
- type = "Texture",
- description = "The texture the render pass will render to. Ignored for non-render passes."
- }
- },
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The new Pass."
- }
- }
- },
- {
- description = "Create a render pass, with options.",
- arguments = {
- {
- name = "type",
- type = "PassType",
- description = "The type of pass to create."
- },
- {
- name = "canvas",
- type = "table",
- description = "Render pass configuration. Up to 4 textures can be provided in table keys 1 through 4. Ignored for non-render passes.",
- table = {
- {
- name = "depth",
- type = "table",
- description = "Depth/stencil buffer configuration. In addition to a table, it can be a `Texture`, a `TextureFormat`, or `false` to disable the depth buffer.",
- table = {
- {
- name = "format",
- type = "TextureFormat",
- 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.",
- default = "'d32f'"
- },
- {
- name = "texture",
- type = "Texture",
- description = "A Texture to use as the depth buffer. Takes precedence over `format`."
- }
- }
- },
- {
- name = "samples",
- type = "number",
- description = "The number of multisamples to use. Can be 4 for antialiasing, or 1 to disable antialiasing.",
- default = "4"
- }
- }
- }
- },
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The new Pass."
- }
- }
- }
- }
- },
- {
- name = "getWindowPass",
- tag = "graphics-objects",
- summary = "Get the window pass.",
- 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`.",
- key = "lovr.graphics.getWindowPass",
- module = "lovr.graphics",
- 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`.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The window pass, or `nil` if there is no window."
- }
- }
- }
- }
- },
- {
- name = "isFormatSupported",
- tag = "graphics-misc",
- summary = "Check if a Texture format is supported.",
- description = "Returns the type of operations the GPU supports for a texture format, if any.",
- key = "lovr.graphics.isFormatSupported",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.getDevice",
- "lovr.graphics.getFeatures",
- "lovr.graphics.getLimits"
- },
- variants = {
- {
- arguments = {
- {
- name = "format",
- type = "TextureFormat",
- description = "The texture format to query."
- },
- {
- name = "...features",
- type = "TextureFeature",
- 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."
- }
- },
- returns = {
- {
- name = "linear",
- type = "boolean",
- description = "Whether the GPU supports these operations for textures with this format, when created with the `linear` flag set to `true`."
- },
- {
- name = "srgb",
- type = "boolean",
- description = "Whether the GPU supports these operations for textures with this format, when created with the `linear` flag set to `false`."
- }
- }
- }
- }
- },
- {
- name = "isHDR",
- tag = "graphics-global",
- summary = "Check if the **super experimental** HDR mode is active.",
- description = "Returns whether the **super experimental** HDR mode is active.\n\nTo enable HDR, add `t.graphics.hdr` to `lovr.conf`. When enabled, LÖVR will try to create an HDR10 window. If the GPU supports it, then this function will return true and the window texture will be HDR:\n\n- Its format will be `rgb10a2` instead of `rgba8`.\n- The display will assume its colors are in the Rec.2020 color space, instead of sRGB.\n- The display will assume its colors are encoded with the PQ transfer function, instead of sRGB.\n\nFor now, it's up to you to write PQ-encoded Rec.2020 color data from your shader when rendering to the window.",
- key = "lovr.graphics.isHDR",
- module = "lovr.graphics",
- notes = "The following shader helper functions make it easier to convert between sRGB colors and HDR10:\n\n vec3 pqToLinear(vec3 color);\n vec3 linearToPQ(vec3 color);\n vec3 sRGBToRec2020(vec3 color);\n vec3 rec2020ToSRGB(vec3 color);",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "hdr",
- type = "boolean",
- description = "Whether HDR is enabled."
- }
- }
- }
- }
- },
- {
- name = "isTimingEnabled",
- tag = "graphics-global",
- summary = "Check if timing stats are enabled.",
- 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.",
- key = "lovr.graphics.isTimingEnabled",
- module = "lovr.graphics",
- related = {
- "Pass:getStats"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether timing is enabled."
- }
- }
- }
- }
- },
- {
- name = "newBuffer",
- tag = "graphics-objects",
- summary = "Create a new Buffer.",
- description = "Creates a Buffer.",
- key = "lovr.graphics.newBuffer",
- module = "lovr.graphics",
- examples = {
- {
- description = "Examples of different buffer formats.",
- 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'))"
- }
- },
- 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. The field name is used to match table keys up to buffer\n fields when writing table data to the Buffer, and is also used to match up buffer fields with\n vertex attribute names declared in a `Shader`. LÖVR has a set of <a\n href=\"Shaders#vertex-attributes\">default vertex attributes</a> that shaders will automatically\n use, allowing you to create a custom mesh without having to write shader code or add custom\n vertex attributes in a shader.\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.",
- related = {
- "Shader:getBufferFormat"
- },
- variants = {
- {
- arguments = {
- {
- name = "size",
- type = "number",
- description = "The size of the Buffer, in bytes."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- },
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- },
- {
- name = "data",
- type = "table",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- },
- {
- name = "blob",
- type = "Blob",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- },
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- },
- {
- name = "data",
- type = "table",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- },
- {
- name = "blob",
- type = "Blob",
- 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."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- }
- },
- {
- arguments = {
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "data",
- type = "table",
- 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."
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer.",
- default = "1"
- },
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "data",
- type = "table",
- 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."
- },
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of each item in the Buffer."
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- },
- {
- name = "format",
- type = "table",
- description = "A list of fields in the Buffer.",
- table = {
- {
- name = "layout",
- type = "DataLayout",
- description = "How to lay out the Buffer fields in memory.",
- default = "packed"
- },
- {
- name = "stride",
- type = "number",
- 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."
- }
- }
- }
- },
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The new Buffer."
- }
- },
- deprecated = true
- }
- }
- },
- {
- name = "newFont",
- tag = "graphics-objects",
- summary = "Create a new Font.",
- description = "Creates a new Font.",
- key = "lovr.graphics.newFont",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.getDefaultFont",
- "lovr.data.newRasterizer",
- "Pass:text"
- },
- variants = {
- {
- description = "Creates a new Font from a font file.",
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "A path to a TTF or BMFont file."
- },
- {
- name = "size",
- type = "number",
- description = "The size of the Font in pixels (TTF only). Larger sizes are slower to initialize and use more memory, but have better quality.",
- default = "32"
- },
- {
- name = "spread",
- type = "number",
- 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.",
- default = "4"
- }
- },
- returns = {
- {
- name = "font",
- type = "Font",
- description = "The new Font."
- }
- }
- },
- {
- description = "Creates a new Font from font data.",
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing TTF or BMFont file data."
- },
- {
- name = "size",
- type = "number",
- description = "The size of the Font in pixels (TTF only). Larger sizes are slower to initialize and use more memory, but have better quality.",
- default = "32"
- },
- {
- name = "spread",
- type = "number",
- 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.",
- default = "4"
- }
- },
- returns = {
- {
- name = "font",
- type = "Font",
- description = "The new Font."
- }
- }
- },
- {
- description = "Creates a new Font using the default typeface (Varela Round).",
- arguments = {
- {
- name = "size",
- type = "number",
- description = "The size of the Font in pixels (TTF only). Larger sizes are slower to initialize and use more memory, but have better quality.",
- default = "32"
- },
- {
- name = "spread",
- type = "number",
- 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.",
- default = "4"
- }
- },
- returns = {
- {
- name = "font",
- type = "Font",
- description = "The new Font."
- }
- }
- },
- {
- description = "Creates a new Font from an existing Rasterizer.",
- arguments = {
- {
- name = "rasterizer",
- type = "Rasterizer",
- description = "An existing Rasterizer to use to load glyph images."
- },
- {
- name = "spread",
- type = "number",
- 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.",
- default = "4"
- }
- },
- returns = {
- {
- name = "font",
- type = "Font",
- description = "The new Font."
- }
- }
- }
- }
- },
- {
- name = "newMaterial",
- tag = "graphics-objects",
- summary = "Create a new Material.",
- 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.",
- key = "lovr.graphics.newMaterial",
- module = "lovr.graphics",
- 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`.",
- variants = {
- {
- arguments = {
- {
- name = "properties",
- type = "table",
- description = "Material properties.",
- table = {
- {
- name = "color",
- type = "Vec4",
- 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`.",
- default = "{ 1, 1, 1, 1 }"
- },
- {
- name = "glow",
- type = "Vec4",
- 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`.",
- default = "{ 0, 0, 0, 0 }"
- },
- {
- name = "uvShift",
- type = "Vec2",
- 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`.",
- default = "{ 0, 0 }"
- },
- {
- name = "uvScale",
- type = "Vec2",
- 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`.",
- default = "{ 1, 1 }"
- },
- {
- name = "metalness",
- type = "number",
- 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`.",
- default = "0"
- },
- {
- name = "roughness",
- type = "number",
- 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`.",
- default = "0"
- },
- {
- name = "clearcoat",
- type = "number",
- description = "The clearcoat factor. Not currently used by LÖVR.",
- default = "0"
- },
- {
- name = "clearcoatRoughness",
- type = "number",
- description = "The roughness of the clearcoat layer. Not currently used by LÖVR.",
- default = "0"
- },
- {
- name = "occlusionStrength",
- type = "number",
- 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`.",
- default = "1"
- },
- {
- name = "normalScale",
- type = "number",
- 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`.",
- default = "1"
- },
- {
- name = "alphaCutoff",
- type = "number",
- 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`.",
- default = "0"
- },
- {
- name = "texture",
- type = "Texture",
- 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`."
- },
- {
- name = "glowTexture",
- type = "Texture",
- 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)."
- },
- {
- name = "metalnessTexture",
- type = "Texture",
- 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`."
- },
- {
- name = "roughnessTexture",
- type = "Texture",
- 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`."
- },
- {
- name = "clearcoatTexture",
- type = "Texture",
- description = "Not currently used by LÖVR."
- },
- {
- name = "occlusionTexture",
- type = "Texture",
- 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`."
- },
- {
- name = "normalTexture",
- type = "Texture",
- 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`."
- }
- }
- }
- },
- returns = {
- {
- name = "material",
- type = "Material",
- description = "The new material."
- }
- }
- }
- }
- },
- {
- name = "newMesh",
- tag = "graphics-objects",
- summary = "Create a new Mesh.",
- 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 }",
- key = "lovr.graphics.newMesh",
- module = "lovr.graphics",
- examples = {
- {
- 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"
- }
- },
- notes = "The Mesh will always use the `gpu` storage mode if it's created from a vertex buffer.",
- related = {
- "lovr.graphics.newBuffer",
- "lovr.graphics.newModel"
- },
- variants = {
- {
- arguments = {
- {
- name = "count",
- type = "number",
- description = "The number of vertices in the Mesh."
- },
- {
- name = "storage",
- type = "MeshStorage",
- description = "The storage mode of the Mesh.",
- default = "'cpu'"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- },
- {
- arguments = {
- {
- name = "vertices",
- type = "table",
- 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."
- },
- {
- name = "storage",
- type = "MeshStorage",
- description = "The storage mode of the Mesh.",
- default = "'cpu'"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- 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."
- },
- {
- name = "storage",
- type = "MeshStorage",
- description = "The storage mode of the Mesh.",
- default = "'cpu'"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- 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."
- },
- {
- name = "count",
- type = "number",
- description = "The number of vertices in the Mesh."
- },
- {
- name = "storage",
- type = "MeshStorage",
- description = "The storage mode of the Mesh.",
- default = "'cpu'"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- 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."
- },
- {
- name = "vertices",
- type = "table",
- 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."
- },
- {
- name = "storage",
- type = "MeshStorage",
- description = "The storage mode of the Mesh.",
- default = "'cpu'"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- },
- {
- arguments = {
- {
- name = "format",
- type = "table",
- 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."
- },
- {
- name = "blob",
- type = "Blob",
- 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."
- },
- {
- name = "storage",
- type = "MeshStorage",
- description = "The storage mode of the Mesh.",
- default = "'cpu'"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- },
- {
- arguments = {
- {
- name = "buffer",
- type = "Buffer",
- 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."
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The new Mesh."
- }
- }
- }
- }
- },
- {
- name = "newModel",
- tag = "graphics-objects",
- summary = "Create a new Model.",
- description = "Loads a 3D model from a file. Currently, OBJ, glTF, and binary STL files are supported.",
- key = "lovr.graphics.newModel",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.data.newModelData",
- "Pass:draw"
- },
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The path to model file."
- },
- {
- name = "options",
- type = "table",
- description = "Model options.",
- table = {
- {
- name = "mipmaps",
- type = "boolean",
- description = "Whether the textures created for the Model should have mipmaps generated.",
- default = "true"
- },
- {
- name = "materials",
- type = "boolean",
- 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.",
- default = "true"
- }
- }
- }
- },
- returns = {
- {
- name = "model",
- type = "Model",
- description = "The new Model."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing 3D model data."
- },
- {
- name = "options",
- type = "table",
- description = "Model options.",
- table = {
- {
- name = "mipmaps",
- type = "boolean",
- description = "Whether the textures created for the Model should have mipmaps generated.",
- default = "true"
- },
- {
- name = "materials",
- type = "boolean",
- 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.",
- default = "true"
- }
- }
- }
- },
- returns = {
- {
- name = "model",
- type = "Model",
- description = "The new Model."
- }
- }
- },
- {
- arguments = {
- {
- name = "modelData",
- type = "ModelData",
- description = "An existing ModelData object to use for the Model."
- },
- {
- name = "options",
- type = "table",
- description = "Model options.",
- table = {
- {
- name = "mipmaps",
- type = "boolean",
- description = "Whether the textures created for the Model should have mipmaps generated.",
- default = "true"
- },
- {
- name = "materials",
- type = "boolean",
- 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.",
- default = "true"
- }
- }
- }
- },
- returns = {
- {
- name = "model",
- type = "Model",
- description = "The new Model."
- }
- }
- }
- }
- },
- {
- name = "newPass",
- tag = "graphics-objects",
- summary = "Create a new Pass.",
- 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`.",
- key = "lovr.graphics.newPass",
- module = "lovr.graphics",
- 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 `lovr.graphics.newTextureView`.",
- related = {
- "lovr.graphics.submit",
- "lovr.graphics.getWindowPass",
- "lovr.headset.getPass"
- },
- variants = {
- {
- description = "Create a pass that renders to a set of textures.",
- arguments = {
- {
- name = "...textures",
- type = "Texture",
- description = "One or more textures the pass will render to. This can be changed later using `Pass:setCanvas`."
- }
- },
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The new Pass."
- }
- }
- },
- {
- description = "Create a pass, with extra canvas settings.",
- arguments = {
- {
- name = "canvas",
- type = "table",
- description = "Render target configuration. Up to 4 textures can be provided in table keys 1 through 4, as well as the following keys:",
- table = {
- {
- name = "depth",
- type = "table",
- description = "Depth/stencil buffer settings. In addition to a table, it can be a `Texture`, a `TextureFormat`, or `false` to disable the depth buffer.",
- table = {
- {
- name = "format",
- type = "TextureFormat",
- 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.",
- default = "'d32f'"
- },
- {
- name = "texture",
- type = "Texture",
- description = "A Texture to use as the depth buffer. Takes precedence over `format`."
- }
- }
- },
- {
- name = "samples",
- type = "number",
- description = "The number of multisamples to use. Can be 4 for antialiasing, or 1 to disable antialiasing.",
- default = "4"
- }
- }
- }
- },
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The new Pass."
- }
- }
- },
- {
- description = "Create an empty Pass without a canvas.",
- arguments = {},
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The new Pass."
- }
- }
- }
- }
- },
- {
- name = "newSampler",
- tag = "graphics-objects",
- summary = "Create a new Sampler.",
- 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.",
- key = "lovr.graphics.newSampler",
- module = "lovr.graphics",
- related = {
- "Pass:setSampler"
- },
- variants = {
- {
- arguments = {
- {
- name = "parameters",
- type = "table",
- description = "Parameters for the sampler.",
- table = {
- {
- name = "filter",
- type = "table",
- description = "How the sampler smooths texture pixels. Can be a table of 3 FilterModes, or a single FilterMode to use for all three.",
- default = "'linear'",
- table = {
- {
- name = "[1]",
- type = "FilterMode",
- description = "The filter mode to use when minifying a texture (drawing it at a smaller size than its native pixel resolution)."
- },
- {
- name = "[2]",
- type = "FilterMode",
- description = "The filter mode to use when magnifying a texture (drawing it at a larger size than its native pixel resolution)."
- },
- {
- name = "[3]",
- type = "FilterMode",
- description = "The filter mode used to smooth between mipmap levels in a texture."
- }
- }
- },
- {
- name = "wrap",
- type = "table",
- 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.",
- default = "'repeat'",
- table = {
- {
- name = "[1]",
- type = "WrapMode",
- description = "The horizontal wrap mode."
- },
- {
- name = "[2]",
- type = "WrapMode",
- description = "The vertical wrap mode."
- },
- {
- name = "[3]",
- type = "WrapMode",
- description = "The \"z\" wrap mode for 3D textures."
- }
- }
- },
- {
- name = "compare",
- type = "CompareMode",
- description = "The compare mode of the sampler (for shadow samplers).",
- default = "'none'"
- },
- {
- name = "anisotropy",
- type = "number",
- description = "The maximum amount of anisotropic filtering to use.",
- default = "1"
- },
- {
- name = "mipmaprange",
- type = "table",
- description = "A table of 2 mipmap levels the sampler will clamp to."
- }
- }
- }
- },
- returns = {
- {
- name = "sampler",
- type = "Sampler",
- description = "The new sampler."
- }
- }
- }
- }
- },
- {
- name = "newShader",
- tag = "graphics-objects",
- summary = "Create a new Shader.",
- 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.\n\nBy default, the provided shader code is expected to implement a `vec4 lovrmain() { ... }` function that is called for each vertex or fragment. If the `raw` option is set to `true`, the code is treated as a raw shader and the `lovrmain` function is not required. In this case, the shader code is expected to implement its own `main` function.",
- key = "lovr.graphics.newShader",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.compileShader",
- "ShaderType",
- "ShaderStage"
- },
- variants = {
- {
- description = "Create a graphics shader. It has a vertex stage that computes vertex positions, and a fragment stage that computes pixel colors.",
- arguments = {
- {
- name = "vertex",
- type = "string",
- 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."
- },
- {
- name = "fragment",
- type = "string",
- 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."
- },
- {
- name = "options",
- type = "table",
- description = "Shader options.",
- table = {
- {
- name = "flags",
- type = "table",
- 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."
- },
- {
- name = "label",
- type = "string",
- description = "A label to use for the shader in debugging tools."
- },
- {
- name = "raw",
- type = "boolean",
- description = "If set to true, the code is treated as a raw shader. It will be compiled with none of the LÖVR helpers."
- }
- }
- }
- },
- returns = {
- {
- name = "shader",
- type = "Shader",
- description = "The new shader."
- }
- }
- },
- {
- description = "Create a compute shader.",
- arguments = {
- {
- name = "compute",
- type = "string",
- description = "A string, path to a file, or Blob containing GLSL or SPIR-V code for the compute stage."
- },
- {
- name = "options",
- type = "table",
- description = "Shader options.",
- table = {
- {
- name = "flags",
- type = "table",
- 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."
- },
- {
- name = "label",
- type = "string",
- description = "A label to use for the shader in debugging tools."
- },
- {
- name = "raw",
- type = "boolean",
- description = "If set to true, the code is treated as a raw shader. It will be compiled with none of the LÖVR helpers."
- }
- }
- }
- },
- returns = {
- {
- name = "shader",
- type = "Shader",
- description = "The new shader."
- }
- }
- },
- {
- description = "Create a copy of one of the default shaders (used to provide different flags).",
- arguments = {
- {
- name = "default",
- type = "DefaultShader",
- description = "The default shader to use."
- },
- {
- name = "options",
- type = "table",
- description = "Shader options.",
- table = {
- {
- name = "flags",
- type = "table",
- 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."
- },
- {
- name = "label",
- type = "string",
- description = "A label to use for the shader in debugging tools."
- },
- {
- name = "raw",
- type = "boolean",
- description = "If set to true, the code is treated as a raw shader. It will be compiled with none of the LÖVR helpers."
- }
- }
- }
- },
- returns = {
- {
- name = "shader",
- type = "Shader",
- description = "The new shader."
- }
- }
- }
- }
- },
- {
- name = "newTexture",
- tag = "graphics-objects",
- summary = "Create a new Texture.",
- 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.",
- key = "lovr.graphics.newTexture",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.newTextureView"
- },
- variants = {
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "The filename of an image to load."
- },
- {
- name = "options",
- type = "table",
- description = "Texture options.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture (ignored when images are provided).",
- default = "'rgba8'"
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
- default = "false"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
- default = "1"
- },
- {
- name = "mipmaps",
- type = "*",
- 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.",
- default = "true"
- },
- {
- name = "usage",
- type = "table",
- description = "A list of `TextureUsage` indicating how the texture will be used."
- },
- {
- name = "label",
- type = "string",
- description = "A label for the Texture that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The new Texture."
- }
- }
- },
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the Texture, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the Texture, in pixels."
- },
- {
- name = "options",
- type = "table",
- description = "Texture options.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture (ignored when images are provided).",
- default = "'rgba8'"
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
- default = "false"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
- default = "1"
- },
- {
- name = "mipmaps",
- type = "*",
- 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.",
- default = "true"
- },
- {
- name = "usage",
- type = "table",
- description = "A list of `TextureUsage` indicating how the texture will be used."
- },
- {
- name = "label",
- type = "string",
- description = "A label for the Texture that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The new Texture."
- }
- }
- },
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the Texture, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the Texture, in pixels."
- },
- {
- name = "layers",
- type = "number",
- description = "The number of layers in the Texture."
- },
- {
- name = "options",
- type = "table",
- description = "Texture options.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture (ignored when images are provided).",
- default = "'rgba8'"
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
- default = "false"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
- default = "1"
- },
- {
- name = "mipmaps",
- type = "*",
- 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.",
- default = "true"
- },
- {
- name = "usage",
- type = "table",
- description = "A list of `TextureUsage` indicating how the texture will be used."
- },
- {
- name = "label",
- type = "string",
- description = "A label for the Texture that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The new Texture."
- }
- }
- },
- {
- arguments = {
- {
- name = "image",
- type = "string",
- description = "An Image object holding pixel data to load into the Texture."
- },
- {
- name = "options",
- type = "table",
- description = "Texture options.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture (ignored when images are provided).",
- default = "'rgba8'"
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
- default = "false"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
- default = "1"
- },
- {
- name = "mipmaps",
- type = "*",
- 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.",
- default = "true"
- },
- {
- name = "usage",
- type = "table",
- description = "A list of `TextureUsage` indicating how the texture will be used."
- },
- {
- name = "label",
- type = "string",
- description = "A label for the Texture that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The new Texture."
- }
- }
- },
- {
- arguments = {
- {
- name = "images",
- type = "table",
- description = "A table of filenames or Images to load into the Texture."
- },
- {
- name = "options",
- type = "table",
- description = "Texture options.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture (ignored when images are provided).",
- default = "'rgba8'"
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
- default = "false"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
- default = "1"
- },
- {
- name = "mipmaps",
- type = "*",
- 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.",
- default = "true"
- },
- {
- name = "usage",
- type = "table",
- description = "A list of `TextureUsage` indicating how the texture will be used."
- },
- {
- name = "label",
- type = "string",
- description = "A label for the Texture that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The new Texture."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "A Blob object holding pixel data to load into the Texture."
- },
- {
- name = "options",
- type = "table",
- description = "Texture options.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the texture."
- },
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the texture (ignored when images are provided).",
- default = "'rgba8'"
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the texture is in linear color space instead of sRGB. Linear textures should be used for non-color data, like normal maps.",
- default = "false"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the texture, used for multisample antialiasing. Currently must be 1 or 4. Ignored when images are provided.",
- default = "1"
- },
- {
- name = "mipmaps",
- type = "*",
- 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.",
- default = "true"
- },
- {
- name = "usage",
- type = "table",
- description = "A list of `TextureUsage` indicating how the texture will be used."
- },
- {
- name = "label",
- type = "string",
- description = "A label for the Texture that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The new Texture."
- }
- }
- }
- }
- },
- {
- name = "newTextureView",
- tag = "graphics-objects",
- summary = "Create a texture view.",
- 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`, and it may reference a subset of the parent texture's layers and mipmap levels.\n\nTexture views are used for:\n\n- Reinterpretation of texture contents. For example, a cubemap can be treated as an array\n texture.\n- Rendering to a particular array layer or mipmap level of a texture.\n- Binding a particular range of layers or mipmap levels to a shader.",
- key = "lovr.graphics.newTextureView",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newTexture"
- },
- variants = {
- {
- arguments = {
- {
- name = "parent",
- type = "Texture",
- description = "The parent Texture to create a view of."
- },
- {
- name = "options",
- type = "table",
- description = "Options for the texture view.",
- table = {
- {
- name = "type",
- type = "TextureType",
- description = "The texture type of the view. Defaults to the type of the parent."
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the first layer referenced by the view.",
- default = "1"
- },
- {
- name = "layercount",
- type = "number",
- description = "The number of layers in the view. Defaults to 1 if a layer index is provided, otherwise the view will reference all layers.",
- default = "nil"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the first mipmap referenced by the view.",
- default = "1"
- },
- {
- name = "mipmapcount",
- type = "number",
- description = "The number of mipmap levels in the view. Defaults to 1 if a mipmap index is provided, otherwise the view will reference all mipmaps.",
- default = "nil"
- },
- {
- name = "label",
- type = "string",
- description = "An optional label for the view that will show up in debugging tools."
- }
- }
- }
- },
- returns = {
- {
- name = "view",
- type = "Texture",
- description = "The new texture view."
- }
- }
- }
- }
- },
- {
- name = "present",
- tag = "work-submission",
- summary = "Update the desktop window contents.",
- 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.",
- key = "lovr.graphics.present",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.submit",
- "lovr.graphics.getWindowPass"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setBackgroundColor",
- tag = "graphics-global",
- summary = "Set the background color.",
- 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.",
- key = "lovr.graphics.setBackgroundColor",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.newPass",
- "Pass:setClear",
- "Texture:clear",
- "Pass:fill"
- },
- variants = {
- {
- arguments = {
- {
- name = "r",
- type = "number",
- description = "The red component of the background color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the background color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the background color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the background color.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "hex",
- type = "number",
- description = "A hexcode (like `0xffffff`) to use for the background color (does not support alpha)."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the background color.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "table",
- type = "table",
- description = "A table containing 3 or 4 color components."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setTimingEnabled",
- tag = "graphics-global",
- summary = "Enable or disable timing stats.",
- 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.",
- key = "lovr.graphics.setTimingEnabled",
- module = "lovr.graphics",
- related = {
- "Pass:getStats"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether timing should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "submit",
- tag = "work-submission",
- summary = "Submit recorded graphics work to the GPU.",
- description = "Submits work to the GPU.",
- key = "lovr.graphics.submit",
- module = "lovr.graphics",
- 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.",
- related = {
- "lovr.graphics.wait"
- },
- variants = {
- {
- arguments = {
- {
- name = "...",
- type = "Pass",
- description = "The pass objects to submit. Falsy values will be skipped."
- }
- },
- returns = {
- {
- name = "true",
- type = "boolean",
- description = "Always returns true, for convenience when returning from `lovr.draw`."
- }
- }
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table of passes to submit. Falsy values will be skipped."
- }
- },
- returns = {
- {
- name = "true",
- type = "boolean",
- description = "Always returns true, for convenience when returning from `lovr.draw`."
- }
- }
- }
- }
- },
- {
- name = "wait",
- tag = "work-submission",
- summary = "Stall the CPU until all submitted GPU work is finished.",
- 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.",
- key = "lovr.graphics.wait",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.submit"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- }
- },
- objects = {
- {
- name = "Buffer",
- summary = "A block of memory on the GPU.",
- 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).",
- key = "Buffer",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newBuffer",
- "lovr.graphics.getBuffer"
- },
- methods = {
- {
- name = "clear",
- tag = "buffer-transfer",
- summary = "Clear data in the Buffer.",
- description = "Clears a range of data in the Buffer to a value.",
- key = "Buffer:clear",
- module = "lovr.graphics",
- related = {
- "Texture:clear"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "The offset of the range of the Buffer to clear, in bytes. Must be a multiple of 4.",
- default = "0"
- },
- {
- name = "extent",
- type = "number",
- description = "The number of bytes to clear. If `nil`, clears to the end of the Buffer. Must be a multiple of 4.",
- default = "nil"
- },
- {
- name = "value",
- type = "number",
- description = "The value to clear to. This will be interpreted as a 32 bit number, which will be repeated across the clear range.",
- default = "0x00000000"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "getData",
- tag = "buffer-transfer",
- summary = "Get the data in the Buffer.",
- 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.",
- key = "Buffer:getData",
- module = "lovr.graphics",
- 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.",
- related = {
- "Buffer:newReadback",
- "Buffer:mapData",
- "Readback:getData"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the first item to read.",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- description = "The number of items to read. If nil, reads the remainder of the buffer.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "t",
- type = "table",
- description = "The table with the Buffer's data."
- }
- }
- }
- }
- },
- {
- name = "getFormat",
- tag = "buffer-metadata",
- summary = "Get the format of the Buffer.",
- description = "Returns the format the Buffer was created with.",
- key = "Buffer:getFormat",
- module = "lovr.graphics",
- examples = {
- {
- 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"
- }
- },
- related = {
- "Buffer:getSize",
- "Buffer:getLength",
- "Buffer:getStride"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "format",
- type = "table",
- description = "A list of fields comprising the format.",
- table = {
- {
- name = "[].name",
- type = "string",
- description = "The name of the field (if fields were created with names)."
- },
- {
- name = "[].type",
- type = "*",
- description = "The `DataType` of the field, or a recursive table with the sub-format."
- },
- {
- name = "[].offset",
- type = "number",
- description = "The offset of the field relative to its parent, in bytes."
- },
- {
- name = "[].length",
- type = "number",
- description = "The array length of the field, or `nil` if it's not an array."
- },
- {
- name = "[].stride",
- type = "number",
- description = "The stride of the field in bytes, or `nil` if it's not an array."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getLength",
- tag = "buffer-metadata",
- summary = "Get the length of the Buffer.",
- description = "Returns the length of the Buffer, or `nil` if the Buffer was not created with a format.",
- key = "Buffer:getLength",
- module = "lovr.graphics",
- related = {
- "Buffer:getSize",
- "Buffer:getStride"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the Buffer."
- }
- }
- }
- }
- },
- {
- name = "getPointer",
- tag = "buffer-transfer",
- summary = "Get a writable pointer to the Buffer's memory.",
- 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.",
- key = "Buffer:getPointer",
- module = "lovr.graphics",
- deprecated = true,
- 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.",
- related = {
- "Blob:getPointer",
- "Buffer:mapData"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A byte offset in the buffer to write to.",
- default = "0"
- },
- {
- name = "extent",
- type = "number",
- description = "The number of bytes to replace. If nil, writes to the rest of the buffer.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "pointer",
- type = "lightuserdata",
- description = "A pointer to the Buffer's memory."
- }
- }
- }
- }
- },
- {
- name = "getSize",
- tag = "buffer-metadata",
- summary = "Get the size of the Buffer, in bytes.",
- 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.",
- key = "Buffer:getSize",
- module = "lovr.graphics",
- related = {
- "Buffer:getLength",
- "Buffer:getStride"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "size",
- type = "number",
- description = "The size of the Buffer, in bytes."
- }
- }
- }
- }
- },
- {
- name = "getStride",
- tag = "buffer-metadata",
- summary = "Get the stride of the Buffer, in bytes.",
- description = "Returns the distance between each item in the Buffer, in bytes, or `nil` if the Buffer was not created with a format.",
- key = "Buffer:getStride",
- module = "lovr.graphics",
- 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.",
- related = {
- "Buffer:getSize",
- "Buffer:getLength"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "stride",
- type = "number",
- description = "The stride of the Buffer, in bytes."
- }
- }
- }
- }
- },
- {
- name = "isTemporary",
- tag = "buffer-metadata",
- summary = "Check if the Buffer is temporary.",
- description = "Returns whether the Buffer is temporary.",
- key = "Buffer:isTemporary",
- module = "lovr.graphics",
- deprecated = true,
- related = {
- "lovr.graphics.getBuffer"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "temporary",
- type = "boolean",
- description = "Whether the Buffer is temporary."
- }
- }
- }
- }
- },
- {
- name = "mapData",
- tag = "buffer-transfer",
- summary = "Get a writable pointer to the Buffer's memory.",
- 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.",
- key = "Buffer:mapData",
- module = "lovr.graphics",
- 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.",
- related = {
- "Blob:getPointer",
- "Buffer:getPointer"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A byte offset in the buffer to write to.",
- default = "0"
- },
- {
- name = "extent",
- type = "number",
- description = "The number of bytes to replace. If nil, writes to the rest of the buffer.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "pointer",
- type = "lightuserdata",
- description = "A pointer to the Buffer's memory."
- }
- }
- }
- }
- },
- {
- name = "newReadback",
- tag = "buffer-transfer",
- summary = "Read back the contents of the Buffer asynchronously.",
- 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`.",
- key = "Buffer:newReadback",
- module = "lovr.graphics",
- notes = "The offset and extent arguments must be a multiple of the Buffer's stride (unless it was created without a format).",
- related = {
- "Buffer:getData",
- "Texture:newReadback"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "A byte offset to read from.",
- default = "0"
- },
- {
- name = "extent",
- type = "number",
- description = "The number of bytes to read. If nil, reads the rest of the buffer.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "readback",
- type = "Readback",
- description = "A new Readback object."
- }
- }
- }
- }
- },
- {
- name = "setData",
- tag = "buffer-transfer",
- summary = "Change the data in the Buffer.",
- description = "Copies data to the Buffer from either a table, `Blob`, or `Buffer`.",
- key = "Buffer:setData",
- module = "lovr.graphics",
- examples = {
- {
- description = "Various examples of copying different formats.",
- 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"
- }
- },
- 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}}",
- variants = {
- {
- arguments = {
- {
- name = "table",
- type = "table",
- description = "A flat or nested table of items to copy to the Buffer (see notes for format)."
- },
- {
- name = "destinationIndex",
- type = "number",
- description = "The index of the first value in the Buffer to update.",
- default = "1"
- },
- {
- name = "sourceIndex",
- type = "number",
- description = "The index in the table to copy from.",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- description = "The number of items to copy. `nil` will copy as many items as possible, based on the lengths of the source and destination.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- description = "Copies a single field to a buffer with numbers (buffer length must be 1).",
- arguments = {
- {
- name = "...numbers",
- type = "number",
- description = "Numerical components to copy to the buffer."
- }
- },
- returns = {}
- },
- {
- description = "Copies a single vector to a buffer (buffer length must be 1).",
- arguments = {
- {
- name = "vector",
- type = "*",
- description = "Vector objects to copy to the buffer."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob to copy data from."
- },
- {
- name = "destinationOffset",
- type = "number",
- description = "The byte offset to copy to.",
- default = "0"
- },
- {
- name = "sourceOffset",
- type = "number",
- description = "The byte offset to copy from.",
- default = "0"
- },
- {
- name = "size",
- type = "number",
- description = "The number of bytes to copy. If nil, copies as many bytes as possible.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The Buffer to copy data from."
- },
- {
- name = "destinationOffset",
- type = "number",
- description = "The byte offset to copy to.",
- default = "0"
- },
- {
- name = "sourceOffset",
- type = "number",
- description = "The byte offset to copy from.",
- default = "0"
- },
- {
- name = "size",
- type = "number",
- description = "The number of bytes to copy. If nil, copies as many bytes as possible.",
- default = "nil"
- }
- },
- returns = {}
- }
- }
- }
- },
- sections = {
- {
- name = "Metadata",
- tag = "buffer-metadata"
- },
- {
- name = "Transfers",
- tag = "buffer-transfer"
- }
- }
- },
- {
- name = "Font",
- summary = "A Font used to render text.",
- 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 and BMFont files using `lovr.graphics.newFont`.\n\nEach Font uses a `Rasterizer` to load the font 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\nFor TTF fonts, LÖ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.",
- key = "Font",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newFont",
- "lovr.graphics.getDefaultFont"
- },
- methods = {
- {
- name = "getAscent",
- summary = "Get the ascent of the Font.",
- 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.",
- key = "Font:getAscent",
- module = "lovr.graphics",
- related = {
- "Rasterizer:getAscent",
- "Font:getDescent",
- "Font:getHeight",
- "Font:getKerning",
- "Font:getWidth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "ascent",
- type = "number",
- description = "The ascent of the font."
- }
- }
- }
- }
- },
- {
- name = "getDescent",
- summary = "Get the descent of the Font.",
- 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.",
- key = "Font:getDescent",
- module = "lovr.graphics",
- related = {
- "Rasterizer:getDescent",
- "Font:getAscent",
- "Font:getHeight",
- "Font:getKerning",
- "Font:getWidth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "descent",
- type = "number",
- description = "The descent of the font."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- summary = "Get the height of the Font.",
- 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.",
- key = "Font:getHeight",
- module = "lovr.graphics",
- related = {
- "Rasterizer:getLeading",
- "Font:getLineSpacing",
- "Font:setLineSpacing",
- "Font:getAscent",
- "Font:getDescent",
- "Font:getKerning",
- "Font:getWidth",
- "Font:getLines"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height of the font."
- }
- }
- }
- }
- },
- {
- name = "getKerning",
- summary = "Get the kerning between 2 glyphs.",
- 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.",
- key = "Font:getKerning",
- module = "lovr.graphics",
- related = {
- "Rasterizer:getKerning",
- "Font:getAscent",
- "Font:getDescent",
- "Font:getHeight",
- "Font:getWidth"
- },
- variants = {
- {
- arguments = {
- {
- name = "first",
- type = "string",
- description = "The first character."
- },
- {
- name = "second",
- type = "string",
- description = "The second character."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- },
- {
- arguments = {
- {
- name = "firstCodepoint",
- type = "number",
- description = "The first codepoint."
- },
- {
- name = "second",
- type = "string",
- description = "The second character."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- },
- {
- arguments = {
- {
- name = "first",
- type = "string",
- description = "The first character."
- },
- {
- name = "secondCodepoint",
- type = "number",
- description = "The second codepoint."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- },
- {
- arguments = {
- {
- name = "firstCodepoint",
- type = "number",
- description = "The first codepoint."
- },
- {
- name = "secondCodepoint",
- type = "number",
- description = "The second codepoint."
- }
- },
- returns = {
- {
- name = "keming",
- type = "number",
- description = "The kerning between the two glyphs."
- }
- }
- }
- }
- },
- {
- name = "getLineSpacing",
- summary = "Get the line spacing of the Font.",
- 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.",
- key = "Font:getLineSpacing",
- module = "lovr.graphics",
- related = {
- "Font:getHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "spacing",
- type = "number",
- description = "The line spacing of the font."
- }
- }
- }
- }
- },
- {
- name = "getLines",
- summary = "Wrap a string into a sequence of lines.",
- description = "Returns a table of wrapped lines for a piece of text, given a line length limit.\n\nBy default the units for `limit` are in meters. If text is being drawn with scale applied, make sure the scale is also applied to the `limit`.",
- key = "Font:getLines",
- module = "lovr.graphics",
- notes = "The font's pixel density is incorporated into the limit. So if the font's pixel density is changed to 1 (changing the font's units to pixels), the `limit` will be in pixels as well.",
- related = {
- "Font:getWidth",
- "Font:getHeight",
- "Pass:text"
- },
- variants = {
- {
- arguments = {
- {
- name = "string",
- type = "string",
- description = "The text to wrap."
- },
- {
- name = "wrap",
- type = "number",
- description = "The line length to wrap at."
- }
- },
- returns = {
- {
- name = "lines",
- type = "table",
- description = "A table of strings, one for each wrapped line."
- }
- }
- },
- {
- arguments = {
- {
- name = "strings",
- type = "table",
- description = "A table of colored strings, each given as a `{ color, string }` pair. The color can be a `Vec3`, `Vec4`, table, or hexcode."
- },
- {
- name = "wrap",
- type = "number",
- description = "The line length to wrap at."
- }
- },
- returns = {
- {
- name = "lines",
- type = "table",
- description = "A table of strings, one for each wrapped line."
- }
- }
- }
- }
- },
- {
- name = "getPixelDensity",
- summary = "Get the pixel density of the Font.",
- 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.",
- key = "Font:getPixelDensity",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "density",
- type = "number",
- description = "The pixel density of the font."
- }
- }
- }
- }
- },
- {
- name = "getRasterizer",
- summary = "Get the Font's Rasterizer.",
- description = "Returns the Rasterizer object backing the Font.",
- key = "Font:getRasterizer",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newFont",
- "lovr.data.newRasterizer"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "rasterizer",
- type = "Rasterizer",
- description = "The Rasterizer."
- }
- }
- }
- }
- },
- {
- name = "getVertices",
- summary = "Get the vertices for a piece of text.",
- 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.",
- key = "Font:getVertices",
- module = "lovr.graphics",
- 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' }",
- variants = {
- {
- arguments = {
- {
- name = "string",
- type = "string",
- description = "The text to render."
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum line length. The units depend on the pixel density of the font, but are in meters by default.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal align."
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical align."
- }
- },
- returns = {
- {
- name = "vertices",
- type = "table",
- description = "The table of vertices. See below for the format of each vertex."
- },
- {
- name = "material",
- type = "Material",
- description = "A Material to use when rendering the vertices."
- }
- }
- },
- {
- arguments = {
- {
- name = "strings",
- type = "table",
- description = "A table of colored strings, each given as a `{ color, string }` pair. The color can be a `Vec3`, `Vec4`, table, or hexcode."
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum line length. The units depend on the pixel density of the font, but are in meters by default.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal align."
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical align."
- }
- },
- returns = {
- {
- name = "vertices",
- type = "table",
- description = "The table of vertices. See below for the format of each vertex."
- },
- {
- name = "material",
- type = "Material",
- description = "A Material to use when rendering the vertices."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- summary = "Get the width of rendered text.",
- description = "Returns the maximum width of a piece of text. This function does not perform wrapping but does respect newlines in the text.",
- key = "Font:getWidth",
- module = "lovr.graphics",
- related = {
- "Font:getAscent",
- "Font:getDescent",
- "Font:getHeight",
- "Font:getKerning",
- "Font:getLines"
- },
- variants = {
- {
- arguments = {
- {
- name = "string",
- type = "string",
- description = "The text to measure."
- }
- },
- returns = {
- {
- name = "width",
- type = "number",
- description = "The maximum width of the text."
- }
- }
- },
- {
- arguments = {
- {
- name = "strings",
- type = "table",
- description = "A table of colored strings, each given as a `{ color, string }` pair. The color can be a `Vec3`, `Vec4`, table, or hexcode."
- }
- },
- returns = {
- {
- name = "width",
- type = "number",
- description = "The maximum width of the text."
- }
- }
- }
- }
- },
- {
- name = "setLineSpacing",
- summary = "Set the line spacing of the Font.",
- 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.",
- key = "Font:setLineSpacing",
- module = "lovr.graphics",
- related = {
- "Font:getHeight"
- },
- variants = {
- {
- arguments = {
- {
- name = "spacing",
- type = "number",
- description = "The new line spacing."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPixelDensity",
- summary = "Set the pixel density of the Font.",
- 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.",
- key = "Font:setPixelDensity",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {
- {
- name = "density",
- type = "number",
- description = "The new pixel density of the font."
- }
- },
- returns = {}
- },
- {
- description = "Resets the pixel density to the default, which is given by `Font:getHeight`.",
- arguments = {},
- returns = {}
- }
- }
- }
- },
- 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`."
- },
- {
- name = "Material",
- summary = "A set of properties and textures that define the properties of a surface.",
- 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`.",
- key = "Material",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newMaterial"
- },
- methods = {
- {
- name = "getProperties",
- summary = "Get the properties of the Material.",
- description = "Returns the properties of the Material in a table.",
- key = "Material:getProperties",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "properties",
- type = "table",
- description = "The Material properties."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Mesh",
- summary = "A drawable triangle mesh.",
- 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.",
- key = "Mesh",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newMesh"
- },
- methods = {
- {
- name = "computeBoundingBox",
- summary = "Compute the bounding box of the Mesh.",
- 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.",
- key = "Mesh:computeBoundingBox",
- module = "lovr.graphics",
- related = {
- "Mesh:getBoundingBox",
- "Mesh:setBoundingBox",
- "Pass:setViewCull",
- "Collider:getAABB",
- "Shape:getAABB",
- "Model:getBoundingBox",
- "ModelData:getBoundingBox"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "updated",
- type = "boolean",
- description = "Whether the bounding box was updated."
- }
- }
- }
- }
- },
- {
- name = "getBoundingBox",
- summary = "Get the bounding box of the Mesh.",
- 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.",
- key = "Mesh:getBoundingBox",
- module = "lovr.graphics",
- related = {
- "Mesh:computeBoundingBox",
- "Pass:setViewCull",
- "Collider:getAABB",
- "Shape:getAABB",
- "Model:getBoundingBox",
- "ModelData:getBoundingBox"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "minx",
- type = "number",
- description = "The minimum x coordinate of the bounding box."
- },
- {
- name = "maxx",
- type = "number",
- description = "The maximum x coordinate of the bounding box."
- },
- {
- name = "miny",
- type = "number",
- description = "The minimum y coordinate of the bounding box."
- },
- {
- name = "maxy",
- type = "number",
- description = "The maximum y coordinate of the bounding box."
- },
- {
- name = "minz",
- type = "number",
- description = "The minimum z coordinate of the bounding box."
- },
- {
- name = "maxz",
- type = "number",
- description = "The maximum z coordinate of the bounding box."
- }
- }
- }
- }
- },
- {
- name = "getDrawMode",
- summary = "Get the draw mode of the Mesh.",
- 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`.",
- key = "Mesh:getDrawMode",
- module = "lovr.graphics",
- related = {
- "Pass:setMeshMode"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mode",
- type = "DrawMode",
- description = "The current draw mode."
- }
- }
- }
- }
- },
- {
- name = "getDrawRange",
- summary = "Get the range of vertices drawn by the Mesh.",
- description = "Returns the range of vertices drawn by the Mesh. If different sets of mesh data are stored in a single Mesh object, the draw range can be used to select different sets of vertices to render.",
- key = "Mesh:getDrawRange",
- module = "lovr.graphics",
- related = {
- "Mesh:setIndices"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "start",
- type = "number",
- description = "The index of the first vertex that will be drawn (or the first index, if the Mesh has vertex indices)."
- },
- {
- name = "count",
- type = "number",
- description = "The number of vertices that will be drawn (or indices, if the Mesh has vertex indices)."
- },
- {
- name = "offset",
- type = "number",
- description = "When the Mesh has vertex indices, an offset that will be added to the index values before fetching the corresponding vertex. This is ignored if the Mesh does not have vertex indices."
- }
- }
- },
- {
- description = "This function returns nothing if no draw range is set.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "getIndexBuffer",
- summary = "Get the Buffer backing the vertex indices of the Mesh.",
- 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.",
- key = "Mesh:getIndexBuffer",
- module = "lovr.graphics",
- related = {
- "Mesh:getIndices",
- "Mesh:setIndices",
- "Mesh:getVertexBuffer"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The index buffer."
- }
- }
- }
- }
- },
- {
- name = "getIndices",
- summary = "Get the vertex indices in the Mesh.",
- description = "Returns a table with the Mesh's vertex indices.",
- key = "Mesh:getIndices",
- module = "lovr.graphics",
- 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.",
- related = {
- "Mesh:getIndexBuffer",
- "Mesh:setIndexBuffer"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "t",
- type = "table",
- description = "A table of numbers with the 1-based vertex indices."
- }
- }
- }
- }
- },
- {
- name = "getMaterial",
- summary = "Get the Material applied to the Mesh.",
- description = "Returns the `Material` applied to the Mesh.",
- key = "Mesh:getMaterial",
- module = "lovr.graphics",
- related = {
- "Pass:setMaterial",
- "Model:getMaterial",
- "lovr.graphics.newMaterial"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "material",
- type = "Material",
- description = "The material."
- }
- }
- }
- }
- },
- {
- name = "getVertexBuffer",
- summary = "Get the Buffer backing the vertices of the Mesh.",
- 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.",
- key = "Mesh:getVertexBuffer",
- module = "lovr.graphics",
- related = {
- "Mesh:getVertices",
- "Mesh:setVertices",
- "Mesh:getIndexBuffer"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The vertex buffer."
- }
- }
- }
- }
- },
- {
- name = "getVertexCount",
- summary = "Get the number of vertices in the Mesh.",
- description = "Returns the number of vertices in the Mesh. The vertex count is set when the Mesh is created and can't change afterwards.",
- key = "Mesh:getVertexCount",
- module = "lovr.graphics",
- related = {
- "Mesh:getVertexStride",
- "Mesh:getVertexFormat",
- "lovr.graphics.newMesh",
- "Model:getMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of vertices in the Mesh."
- }
- }
- }
- }
- },
- {
- name = "getVertexFormat",
- summary = "Get the vertex format of the Mesh.",
- 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.).",
- key = "Mesh:getVertexFormat",
- module = "lovr.graphics",
- 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.",
- related = {
- "Mesh:getVertexCount",
- "Mesh:getVertexStride",
- "lovr.graphics.newMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "format",
- type = "table",
- description = "The vertex format.",
- table = {
- {
- name = "[][1]",
- type = "string",
- description = "The name of the attribute."
- },
- {
- name = "[][2]",
- type = "DataType",
- description = "The type of the attribute."
- },
- {
- name = "[][3]",
- type = "number",
- description = "The byte offset of the attribute."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getVertexStride",
- summary = "Get the size of each vertex in the Mesh.",
- description = "Returns the stride of the Mesh, which is the number of bytes used by each vertex.",
- key = "Mesh:getVertexStride",
- module = "lovr.graphics",
- related = {
- "Mesh:getVertexCount",
- "Mesh:getVertexFormat",
- "lovr.graphics.newMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "stride",
- type = "number",
- description = "The stride of the Mesh, in bytes."
- }
- }
- }
- }
- },
- {
- name = "getVertices",
- summary = "Get the vertices in the Mesh.",
- description = "Returns the vertices in the Mesh.",
- key = "Mesh:getVertices",
- module = "lovr.graphics",
- 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.**",
- related = {
- "Mesh:getVertexBuffer",
- "Mesh:getVertexFormat",
- "Mesh:getIndices",
- "Mesh:setIndices"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the first vertex to return.",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- description = "The number of vertices to return. If nil, returns the \"rest\" of the vertices, based on the `index` argument.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "vertices",
- type = "table",
- description = "A table of vertices. Each vertex is a table of numbers for each vertex attribute, given by the vertex format of the Mesh."
- }
- }
- }
- }
- },
- {
- name = "setBoundingBox",
- summary = "Set or remove the bounding box of the Mesh.",
- 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.",
- key = "Mesh:setBoundingBox",
- module = "lovr.graphics",
- related = {
- "Mesh:computeBoundingBox",
- "Pass:setViewCull",
- "Collider:getAABB",
- "Shape:getAABB",
- "Model:getBoundingBox",
- "ModelData:getBoundingBox"
- },
- variants = {
- {
- arguments = {
- {
- name = "minx",
- type = "number",
- description = "The minimum x coordinate of the bounding box."
- },
- {
- name = "maxx",
- type = "number",
- description = "The maximum x coordinate of the bounding box."
- },
- {
- name = "miny",
- type = "number",
- description = "The minimum y coordinate of the bounding box."
- },
- {
- name = "maxy",
- type = "number",
- description = "The maximum y coordinate of the bounding box."
- },
- {
- name = "minz",
- type = "number",
- description = "The minimum z coordinate of the bounding box."
- },
- {
- name = "maxz",
- type = "number",
- description = "The maximum z coordinate of the bounding box."
- }
- },
- returns = {}
- },
- {
- description = "Remove the bounding box.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setDrawMode",
- summary = "Set the draw mode of the Mesh.",
- 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`.",
- key = "Mesh:setDrawMode",
- module = "lovr.graphics",
- related = {
- "Pass:setMeshMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "DrawMode",
- description = "The current draw mode."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDrawRange",
- summary = "Set the range of vertices drawn by the Mesh.",
- description = "Sets the range of vertices drawn by the Mesh. If different sets of mesh data are stored in a single Mesh object, the draw range can be used to select different sets of vertices to render.",
- key = "Mesh:setDrawRange",
- module = "lovr.graphics",
- notes = "When using an index buffer, the draw range defines a range of indices to render instead of a range of vertices. Additionally, a vertex offset can be set, which is added to the values in the index buffer before fetching the vertices. This makes it easier to pack multiple sets of indexed mesh data in a single Mesh object, without having to manually offset the data in each index buffer.",
- related = {
- "Mesh:setIndices"
- },
- variants = {
- {
- arguments = {
- {
- name = "start",
- type = "number",
- description = "The index of the first vertex that will be drawn (or the first index, if the Mesh has vertex indices)."
- },
- {
- name = "count",
- type = "number",
- description = "The number of vertices that will be drawn (or indices, if the Mesh has vertex indices)."
- },
- {
- name = "offset",
- type = "number",
- description = "When the Mesh has vertex indices, an offset that will be added to the index values before fetching the corresponding vertex. This is ignored if the Mesh does not have vertex indices."
- }
- },
- returns = {}
- },
- {
- description = "Disable the draw range. The Mesh will draw all of its vertices.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setIndexBuffer",
- summary = "Set a Buffer for the Mesh to use for vertex indices.",
- 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.",
- key = "Mesh:setIndexBuffer",
- module = "lovr.graphics",
- examples = {
- {
- description = "Use an index buffer to draw a plane.",
- 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"
- }
- },
- 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.",
- related = {
- "Mesh:getIndices",
- "Mesh:setIndices",
- "Mesh:getVertexBuffer"
- },
- variants = {
- {
- arguments = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The index buffer."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setIndices",
- summary = "Set the vertex indices of the Mesh.",
- 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.",
- key = "Mesh:setIndices",
- module = "lovr.graphics",
- related = {
- "Mesh:getIndexBuffer",
- "Mesh:setIndexBuffer",
- "Mesh:setVertices"
- },
- variants = {
- {
- description = "Set vertex indices using a table.",
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A list of numbers (1-based)."
- }
- },
- returns = {}
- },
- {
- description = "Set vertex indices using a Blob.",
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob with index data."
- },
- {
- name = "type",
- type = "DataType",
- description = "The type of index data in the Blob. Must be `u16` or `u32`."
- }
- },
- returns = {}
- },
- {
- description = "Disable vertex indices.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setMaterial",
- summary = "Set a Material to use when drawing the Mesh.",
- description = "Sets a `Material` to use when drawing the Mesh.",
- key = "Mesh:setMaterial",
- module = "lovr.graphics",
- related = {
- "Pass:setMaterial",
- "Model:getMaterial",
- "lovr.graphics.newMaterial"
- },
- variants = {
- {
- arguments = {
- {
- name = "material",
- type = "Material",
- description = "The material to use."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "texture",
- type = "Texture",
- description = "The texture to use as the material."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setVertices",
- summary = "Set vertices in the Mesh.",
- description = "Sets the data for vertices in the Mesh.",
- key = "Mesh:setVertices",
- module = "lovr.graphics",
- notes = "Note that a `Pass` that draws a Mesh will only \"see\" the vertices as they exist when the pass is submitted. So, if this function is used to change vertices multiple times before submitting the Pass, only the final value of each vertex will be used. Example:\n\n function lovr.draw(pass)\n -- Due to the second :setVertices call below, the Mesh\n -- contains a sphere when this pass is submitted! So\n -- this code will actually draw 2 spheres!\n mesh:setVertices(cube)\n pass:draw(mesh, x1, y1, z1)\n\n mesh:setVertices(sphere)\n pass:draw(mesh, x2, y2, z2)\n end\n\nIf you want multiple meshes, then use multiple Mesh objects! Or, *append* vertices to the Mesh instead of replacing them, and use `Mesh:setDrawRange` to control which vertices are drawn for a particular draw call.\n\nCPU 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.",
- related = {
- "Mesh:getVertexBuffer",
- "Mesh:getVertexFormat",
- "Mesh:getIndices",
- "Mesh:setIndices"
- },
- variants = {
- {
- arguments = {
- {
- name = "vertices",
- type = "table",
- description = "A table of vertices, where each vertex is a table of numbers matching the vertex format of the Mesh."
- },
- {
- name = "index",
- type = "number",
- description = "The index of the first vertex to return.",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- description = "The number of vertices to return. If nil, returns the \"rest\" of the vertices, based on the `index` argument.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "A Blob containing binary vertex data."
- },
- {
- name = "index",
- type = "number",
- description = "The index of the first vertex to return.",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- description = "The number of vertices to return. If nil, returns the \"rest\" of the vertices, based on the `index` argument.",
- default = "nil"
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "Model",
- summary = "A 3D model.",
- 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.",
- key = "Model",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newModel",
- "lovr.headset.newModel"
- },
- methods = {
- {
- name = "animate",
- summary = "Animate the Model.",
- 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.",
- key = "Model:animate",
- module = "lovr.graphics",
- 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.",
- related = {
- "Model:resetNodeTransforms",
- "Model:getAnimationCount",
- "Model:getAnimationName",
- "Model:getAnimationDuration",
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodeTransform",
- "Model:setNodeTransform"
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an animation in the model file."
- },
- {
- name = "time",
- type = "number",
- description = "The timestamp to evaluate the keyframes at, in seconds."
- },
- {
- name = "blend",
- type = "number",
- description = "How much of the animation's pose to blend into the nodes, from 0 to 1.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation in the model file."
- },
- {
- name = "time",
- type = "number",
- description = "The timestamp to evaluate the keyframes at, in seconds."
- },
- {
- name = "blend",
- type = "number",
- description = "How much of the animation's pose to blend into the nodes, from 0 to 1.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "clone",
- summary = "Return a lightweight copy of the Model with its own animation state.",
- 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.",
- key = "Model:clone",
- module = "lovr.graphics",
- notes = "The node transforms of the clone will be reset to their initial setup poses.",
- related = {
- "lovr.graphics.newModel"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "model",
- type = "Model",
- description = "A genetically identical copy of the Model."
- }
- }
- }
- }
- },
- {
- name = "getAnimationCount",
- summary = "Get the number of animations in the Model.",
- description = "Returns the number of animations in the Model.",
- key = "Model:getAnimationCount",
- module = "lovr.graphics",
- related = {
- "Model:getAnimationName",
- "Model:getAnimationDuration",
- "Model:animate"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of animations in the Model."
- }
- }
- }
- }
- },
- {
- name = "getAnimationDuration",
- summary = "Get the duration of an animation in the Model.",
- description = "Returns the duration of an animation in the Model, in seconds.",
- key = "Model:getAnimationDuration",
- module = "lovr.graphics",
- notes = "The duration of an animation is calculated as the largest timestamp of all of its keyframes.",
- related = {
- "Model:getAnimationCount",
- "Model:getAnimationName",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The animation index."
- }
- },
- returns = {
- {
- name = "duration",
- type = "number",
- description = "The duration of the animation, in seconds."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the animation."
- }
- },
- returns = {
- {
- name = "duration",
- type = "number",
- description = "The duration of the animation, in seconds."
- }
- }
- }
- }
- },
- {
- name = "getAnimationName",
- summary = "Get the name of an animation in the Model.",
- description = "Returns the name of an animation in the Model.",
- key = "Model:getAnimationName",
- module = "lovr.graphics",
- related = {
- "Model:getAnimationCount",
- "Model:getAnimationDuration"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of an animation."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the animation."
- }
- }
- }
- }
- },
- {
- name = "getBlendShapeCount",
- summary = "Get the number of blend shapes in the model.",
- description = "Returns the number of blend shapes in the model.",
- key = "Model:getBlendShapeCount",
- module = "lovr.graphics",
- related = {
- "Model:getBlendShapeName",
- "ModelData:getBlendShapeCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of blend shapes in the model."
- }
- }
- }
- }
- },
- {
- name = "getBlendShapeName",
- summary = "Get the name of a blend shape in the model.",
- description = "Returns the name of a blend shape in the model.",
- key = "Model:getBlendShapeName",
- module = "lovr.graphics",
- notes = "This function will throw an error if the blend shape index is invalid.",
- related = {
- "Model:getBlendShapeCount",
- "ModelData:getBlendShapeName"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a blend shape."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the blend shape."
- }
- }
- }
- }
- },
- {
- name = "getBlendShapeWeight",
- summary = "Get the weight of a blend shape.",
- 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.",
- key = "Model:getBlendShapeWeight",
- module = "lovr.graphics",
- 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.",
- related = {
- "Model:getBlendShapeCount",
- "Model:getBlendShapeName",
- "Model:resetBlendShapes"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a blend shape."
- }
- },
- returns = {
- {
- name = "weight",
- type = "number",
- description = "The weight of the blend shape."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of a blend shape."
- }
- },
- returns = {
- {
- name = "weight",
- type = "number",
- description = "The weight of the blend shape."
- }
- }
- }
- }
- },
- {
- name = "getBoundingBox",
- summary = "Get the bounding box of the Model.",
- description = "Returns the 6 values of the Model's axis-aligned bounding box.",
- key = "Model:getBoundingBox",
- module = "lovr.graphics",
- related = {
- "Model:getWidth",
- "Model:getHeight",
- "Model:getDepth",
- "Model:getDimensions",
- "Model:getCenter",
- "Model:getBoundingSphere",
- "ModelData:getBoundingBox",
- "Collider:getAABB"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "minx",
- type = "number",
- description = "The minimum x coordinate of the vertices in the Model."
- },
- {
- name = "maxx",
- type = "number",
- description = "The maximum x coordinate of the vertices in the Model."
- },
- {
- name = "miny",
- type = "number",
- description = "The minimum y coordinate of the vertices in the Model."
- },
- {
- name = "maxy",
- type = "number",
- description = "The maximum y coordinate of the vertices in the Model."
- },
- {
- name = "minz",
- type = "number",
- description = "The minimum z coordinate of the vertices in the Model."
- },
- {
- name = "maxz",
- type = "number",
- description = "The maximum z coordinate of the vertices in the Model."
- }
- }
- }
- }
- },
- {
- name = "getBoundingSphere",
- summary = "Get the bounding sphere of the Model.",
- description = "Returns a sphere approximately enclosing the vertices in the Model.",
- key = "Model:getBoundingSphere",
- module = "lovr.graphics",
- related = {
- "Model:getWidth",
- "Model:getHeight",
- "Model:getDepth",
- "Model:getDimensions",
- "Model:getCenter",
- "Model:getBoundingBox",
- "ModelData:getBoundingSphere"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the position of the sphere."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the position of the sphere."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the position of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the bounding sphere."
- }
- }
- }
- }
- },
- {
- name = "getCenter",
- summary = "Get the center of the Model's bounding box.",
- description = "Returns the center of the Model's axis-aligned bounding box, relative to the Model's origin.",
- key = "Model:getCenter",
- module = "lovr.graphics",
- related = {
- "Model:getWidth",
- "Model:getHeight",
- "Model:getDepth",
- "Model:getDimensions",
- "Model:getBoundingBox",
- "ModelData:getCenter"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x offset of the center of the bounding box."
- },
- {
- name = "y",
- type = "number",
- description = "The y offset of the center of the bounding box."
- },
- {
- name = "z",
- type = "number",
- description = "The z offset of the center of the bounding box."
- }
- }
- }
- }
- },
- {
- name = "getData",
- summary = "Get the ModelData backing the Model.",
- description = "Returns the ModelData this Model was created from.",
- key = "Model:getData",
- module = "lovr.graphics",
- related = {
- "lovr.data.newModelData"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "data",
- type = "ModelData",
- description = "The ModelData."
- }
- }
- }
- }
- },
- {
- name = "getDepth",
- summary = "Get the depth of the Model.",
- description = "Returns the depth of the Model, computed from its axis-aligned bounding box.",
- key = "Model:getDepth",
- module = "lovr.graphics",
- related = {
- "Model:getWidth",
- "Model:getHeight",
- "Model:getDimensions",
- "Model:getCenter",
- "Model:getBoundingBox",
- "ModelData:getDepth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "depth",
- type = "number",
- description = "The depth of the Model."
- }
- }
- }
- }
- },
- {
- name = "getDimensions",
- summary = "Get the dimensions of the Model.",
- description = "Returns the width, height, and depth of the Model, computed from its axis-aligned bounding box.",
- key = "Model:getDimensions",
- module = "lovr.graphics",
- related = {
- "Model:getWidth",
- "Model:getHeight",
- "Model:getDepth",
- "Model:getCenter",
- "Model:getBoundingBox",
- "ModelData:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the Model."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the Model."
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the Model."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- summary = "Get the height of the Model.",
- description = "Returns the height of the Model, computed from its axis-aligned bounding box.",
- key = "Model:getHeight",
- module = "lovr.graphics",
- related = {
- "Model:getWidth",
- "Model:getDepth",
- "Model:getDimensions",
- "Model:getCenter",
- "Model:getBoundingBox",
- "ModelData:getHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height of the Model."
- }
- }
- }
- }
- },
- {
- name = "getIndexBuffer",
- summary = "Get a Buffer containing the triangle indices in the Model.",
- description = "Returns the index buffer used by the Model. The index buffer describes the order used to draw the vertices in each mesh.",
- key = "Model:getIndexBuffer",
- module = "lovr.graphics",
- related = {
- "Model:getVertexBuffer",
- "Model:getMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The index buffer."
- }
- }
- }
- }
- },
- {
- name = "getMaterial",
- summary = "Get a Material from the Model.",
- description = "Returns a `Material` loaded from the Model.",
- key = "Model:getMaterial",
- module = "lovr.graphics",
- related = {
- "Model:getMaterialCount",
- "Model:getMaterialName"
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the Material to return."
- }
- },
- returns = {
- {
- name = "material",
- type = "Material",
- description = "The material."
- }
- }
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the Material to return."
- }
- },
- returns = {
- {
- name = "material",
- type = "Material",
- description = "The material."
- }
- }
- }
- }
- },
- {
- name = "getMaterialCount",
- summary = "Get the number of materials in the Model.",
- description = "Returns the number of materials in the Model.",
- key = "Model:getMaterialCount",
- module = "lovr.graphics",
- related = {
- "Model:getMaterialName",
- "Model:getMaterial"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of materials in the Model."
- }
- }
- }
- }
- },
- {
- name = "getMaterialName",
- summary = "Get the name of a material in the Model.",
- description = "Returns the name of a material in the Model.",
- key = "Model:getMaterialName",
- module = "lovr.graphics",
- related = {
- "Model:getMaterialCount",
- "Model:getMaterial"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a material."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the material."
- }
- }
- }
- }
- },
- {
- name = "getMesh",
- summary = "Get a Mesh from the Model.",
- description = "Returns a `Mesh` from the Model.",
- key = "Model:getMesh",
- module = "lovr.graphics",
- related = {
- "Model:getMeshCount",
- "lovr.graphics.newMesh"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the Mesh to return."
- }
- },
- returns = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The mesh object."
- }
- }
- }
- }
- },
- {
- name = "getMeshCount",
- summary = "Get the number of meshes in the Model.",
- description = "Returns the number of meshes in the Model.",
- key = "Model:getMeshCount",
- module = "lovr.graphics",
- related = {
- "Model:getMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of meshes in the Model."
- }
- }
- }
- }
- },
- {
- name = "getMetadata",
- summary = "Get extra information from the model file.",
- 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.",
- key = "Model:getMetadata",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "metadata",
- type = "string",
- description = "The metadata from the model file."
- }
- }
- }
- }
- },
- {
- name = "getNodeChildren",
- summary = "Get the children of a node.",
- description = "Given a parent node, this function returns a table with the indices of its children.",
- key = "Model:getNodeChildren",
- module = "lovr.graphics",
- notes = "If the node does not have any children, this function returns an empty table.",
- related = {
- "Model:getNodeParent",
- "Model:getRootNode"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the parent node."
- }
- },
- returns = {
- {
- name = "children",
- type = "table",
- description = "A table containing a node index for each child of the node."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the parent node."
- }
- },
- returns = {
- {
- name = "children",
- type = "table",
- description = "A table containing a node index for each child of the node."
- }
- }
- }
- }
- },
- {
- name = "getNodeCount",
- summary = "Get the number of nodes in the model.",
- description = "Returns the number of nodes in the model.",
- key = "Model:getNodeCount",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of nodes in the model."
- }
- }
- }
- }
- },
- {
- name = "getNodeName",
- summary = "Get the name of a node in the Model.",
- description = "Returns the name of a node.",
- key = "Model:getNodeName",
- module = "lovr.graphics",
- related = {
- "Model:getNodeCount",
- "Model:getAnimationName",
- "Model:getMaterialName"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- }
- },
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- }
- }
- }
- }
- },
- {
- name = "getNodeOrientation",
- summary = "Get the orientation of a node.",
- description = "Returns the orientation of a node.",
- key = "Model:getNodeOrientation",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the orientation should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the orientation should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getNodeParent",
- summary = "Get the parent of a node.",
- description = "Given a child node, this function returns the index of its parent.",
- key = "Model:getNodeParent",
- module = "lovr.graphics",
- related = {
- "Model:getNodeChildren",
- "Model:getRootNode"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the child node."
- }
- },
- returns = {
- {
- name = "parent",
- type = "number",
- description = "The index of the parent."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the child node."
- }
- },
- returns = {
- {
- name = "parent",
- type = "number",
- description = "The index of the parent."
- }
- }
- }
- }
- },
- {
- name = "getNodePose",
- summary = "Get the pose of a node.",
- description = "Returns the pose (position and orientation) of a node.",
- key = "Model:getNodePose",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the pose should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the node."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the node."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the node."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of a node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the pose should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the node."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the node."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the node."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getNodePosition",
- summary = "Get the position of a node.",
- description = "Returns the position of a node.",
- key = "Model:getNodePosition",
- module = "lovr.graphics",
- related = {
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "space",
- type = "OriginType",
- description = "Whether the position should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "space",
- type = "OriginType",
- description = "Whether the position should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- }
- }
- }
- }
- },
- {
- name = "getNodeScale",
- summary = "Get the scale of a node.",
- description = "Returns the scale of a node.",
- key = "Model:getNodeScale",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the scale should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x scale."
- },
- {
- name = "y",
- type = "number",
- description = "The y scale."
- },
- {
- name = "z",
- type = "number",
- description = "The z scale."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the scale should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x scale."
- },
- {
- name = "y",
- type = "number",
- description = "The y scale."
- },
- {
- name = "z",
- type = "number",
- description = "The z scale."
- }
- }
- }
- }
- },
- {
- name = "getNodeTransform",
- summary = "Get the transform of a node.",
- description = "Returns the transform (position, scale, and rotation) of a node.",
- key = "Model:getNodeTransform",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the transform should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the node."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the node."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the node."
- },
- {
- name = "sx",
- type = "number",
- description = "The x scale of the node."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale of the node."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale of the node."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of a node."
- },
- {
- name = "origin",
- type = "OriginType",
- description = "Whether the transform should be returned relative to the root node or the node's parent.",
- default = "'root'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the node."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the node."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the node."
- },
- {
- name = "sx",
- type = "number",
- description = "The x scale of the node."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale of the node."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale of the node."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getRootNode",
- summary = "Get the index of the root node.",
- description = "Returns the index of the model's root node.",
- key = "Model:getRootNode",
- module = "lovr.graphics",
- related = {
- "Model:getNodeCount",
- "Model:getNodeParent"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "root",
- type = "number",
- description = "The index of the root node."
- }
- }
- }
- }
- },
- {
- name = "getTexture",
- summary = "Get one of the textures in the Model.",
- description = "Returns one of the textures in the Model.",
- key = "Model:getTexture",
- module = "lovr.graphics",
- related = {
- "Model:getTextureCount",
- "Model:getMaterial"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the texture to get."
- }
- },
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The texture."
- }
- }
- }
- }
- },
- {
- name = "getTextureCount",
- summary = "Get the number of textures in the Model.",
- description = "Returns the number of textures in the Model.",
- key = "Model:getTextureCount",
- module = "lovr.graphics",
- related = {
- "Model:getTexture"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of textures in the Model."
- }
- }
- }
- }
- },
- {
- name = "getTriangleCount",
- summary = "Get the total number of triangles in the Model.",
- description = "Returns the total number of triangles in the Model.",
- key = "Model:getTriangleCount",
- module = "lovr.graphics",
- 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.",
- related = {
- "Model:getTriangles",
- "Model:getVertexCount",
- "ModelData:getTriangleCount",
- "Model:getMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The total number of triangles in the Model."
- }
- }
- }
- }
- },
- {
- name = "getTriangles",
- summary = "Get all the triangles in the Model.",
- 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.",
- key = "Model:getTriangles",
- module = "lovr.graphics",
- notes = "After this function is called on a Model once, the result is cached (in its ModelData).",
- related = {
- "Model:getTriangleCount",
- "Model:getVertexCount",
- "Model:getMesh",
- "ModelData:getTriangles"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "vertices",
- type = "table",
- 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."
- },
- {
- name = "indices",
- type = "table",
- description = "A list of numbers representing how to connect the vertices into triangles. Each number is a 1-based index into the `vertices` table, and every 3 indices form a triangle."
- }
- }
- }
- }
- },
- {
- name = "getVertexBuffer",
- summary = "Get a Buffer containing the vertices in the Model.",
- description = "Returns a `Buffer` that holds the vertices of all of the meshes in the Model.",
- key = "Model:getVertexBuffer",
- module = "lovr.graphics",
- related = {
- "Model:getIndexBuffer",
- "Model:getMesh"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The vertex buffer."
- }
- }
- }
- }
- },
- {
- name = "getVertexCount",
- summary = "Get the total vertex count of the Model.",
- description = "Returns the total vertex count of the Model.",
- key = "Model:getVertexCount",
- module = "lovr.graphics",
- 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.",
- related = {
- "Model:getTriangles",
- "Model:getTriangleCount",
- "ModelData:getVertexCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The total number of vertices."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- summary = "Get the width of the Model.",
- description = "Returns the width of the Model, computed from its axis-aligned bounding box.",
- key = "Model:getWidth",
- module = "lovr.graphics",
- related = {
- "Model:getHeight",
- "Model:getDepth",
- "Model:getDimensions",
- "Model:getCenter",
- "Model:getBoundingBox",
- "ModelData:getWidth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the Model."
- }
- }
- }
- }
- },
- {
- name = "hasJoints",
- summary = "Check if the Model uses joints for skeletal animation.",
- description = "Returns whether the Model has any skeletal animations.",
- key = "Model:hasJoints",
- module = "lovr.graphics",
- 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.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "jointed",
- type = "boolean",
- description = "Whether the animation uses joint nodes for skeletal animation."
- }
- }
- }
- }
- },
- {
- name = "resetBlendShapes",
- summary = "Reset blend shape weights.",
- description = "Resets blend shape weights to the original ones defined in the model file.",
- key = "Model:resetBlendShapes",
- module = "lovr.graphics",
- related = {
- "Model:resetNodeTransforms",
- "Model:getBlendShapeWeight",
- "Model:setBlendShapeWeight"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "resetNodeTransforms",
- summary = "Reset node transforms.",
- description = "Resets node transforms to the original ones defined in the model file.",
- key = "Model:resetNodeTransforms",
- module = "lovr.graphics",
- related = {
- "Model:resetBlendShapes"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setBlendShapeWeight",
- summary = "Set the weight of a blend shape.",
- 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.",
- key = "Model:setBlendShapeWeight",
- module = "lovr.graphics",
- 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.",
- related = {
- "Model:getBlendShapeCount",
- "Model:getBlendShapeName",
- "Model:resetBlendShapes"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of a blend shape."
- },
- {
- name = "weight",
- type = "number",
- description = "The new weight for the blend shape."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of a blend shape."
- },
- {
- name = "weight",
- type = "number",
- description = "The new weight for the blend shape."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setNodeOrientation",
- summary = "Set or blend the orientation of a node.",
- 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.",
- key = "Model:setNodeOrientation",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setNodePose",
- summary = "Set or blend the pose of a node.",
- 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.",
- key = "Model:setNodePose",
- module = "lovr.graphics",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "x",
- type = "number",
- description = "The x component of the position."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the position."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the position."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "x",
- type = "number",
- description = "The x component of the position."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the position."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the position."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The target position. Can also be provided as 3 numbers."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The target orientation. Can also be provided as 4 numbers in angle-axis form."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The target position. Can also be provided as 3 numbers."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The target orientation. Can also be provided as 4 numbers in angle-axis form."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setNodePosition",
- summary = "Set or blend the position of a node.",
- description = "Sets or blends the position of a node. This sets the local position of the node, relative to its parent.",
- key = "Model:setNodePosition",
- module = "lovr.graphics",
- related = {
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the new position."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the new position."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the new position."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the new position."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the new position."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the new position."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The new position."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The new position."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setNodeScale",
- summary = "Set or blend the scale of a node.",
- 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.",
- key = "Model:setNodeScale",
- module = "lovr.graphics",
- notes = "For best results when animating, it's recommended to keep the 3 scale components the same.",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:getNodeTransform",
- "Model:setNodeTransform",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The new scale."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The new scale."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setNodeTransform",
- summary = "Set or blend the transform of a node.",
- 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.",
- key = "Model:setNodeTransform",
- module = "lovr.graphics",
- 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.",
- related = {
- "Model:getNodePosition",
- "Model:setNodePosition",
- "Model:getNodeOrientation",
- "Model:setNodeOrientation",
- "Model:getNodeScale",
- "Model:setNodeScale",
- "Model:getNodePose",
- "Model:setNodePose",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "x",
- type = "number",
- description = "The x component of the position."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the position."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the position."
- },
- {
- name = "sx",
- type = "number",
- description = "The x component of the scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y component of the scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z component of the scale."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "x",
- type = "number",
- description = "The x component of the position."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the position."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the position."
- },
- {
- name = "sx",
- type = "number",
- description = "The x component of the scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y component of the scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z component of the scale."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the node should be rotated around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The scale."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The scale."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the node."
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the node."
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform."
- },
- {
- name = "blend",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "Pass",
- summary = "A stream of graphics commands.",
- 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.",
- key = "Pass",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newPass",
- "lovr.graphics.getWindowPass",
- "lovr.headset.getPass",
- "lovr.graphics.getPass"
- },
- methods = {
- {
- name = "barrier",
- tag = "compute",
- summary = "Synchronize compute work.",
- 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.",
- key = "Pass:barrier",
- module = "lovr.graphics",
- examples = {
- {
- 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"
- }
- },
- 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.",
- related = {
- "Pass:compute"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "beginTally",
- tag = "tally",
- summary = "Begin a tally.",
- 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`.",
- key = "Pass:beginTally",
- module = "lovr.graphics",
- notes = "There is currently a maximum of 256 tallies per pass.\n\nIf a tally is already active, this function will error.",
- related = {
- "Pass:finishTally"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "index",
- type = "number",
- description = "The index of the tally that was started."
- }
- }
- }
- }
- },
- {
- name = "box",
- tag = "drawing",
- summary = "Draw a box.",
- description = "Draw a box. This is like `Pass:cube`, except it takes 3 separate values for the scale.",
- key = "Pass:box",
- module = "lovr.graphics",
- related = {
- "Pass:cube"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the box.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the box.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the box.",
- default = "0"
- },
- {
- name = "width",
- type = "number",
- description = "The width of the box.",
- default = "1"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box.",
- default = "1"
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the box around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the box should be drawn filled or outlined.",
- default = "'fill'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the box."
- },
- {
- name = "size",
- type = "Vec3",
- description = "The size of the box."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the box."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the box should be drawn filled or outlined.",
- default = "'fill'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the box."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the box should be drawn filled or outlined.",
- default = "'fill'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "capsule",
- tag = "drawing",
- summary = "Draw a capsule.",
- description = "Draws a capsule. A capsule is shaped like a cylinder with a hemisphere on each end.",
- key = "Pass:capsule",
- module = "lovr.graphics",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the capsule.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the capsule.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the capsule.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule.",
- default = "1.0"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the capsule.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the capsule around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "32"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule.",
- default = "1.0"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the capsule.",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the capsule."
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "32"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the capsule."
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "32"
- }
- },
- returns = {}
- },
- {
- description = "Draws a capsule between two points.",
- arguments = {
- {
- name = "p1",
- type = "Vec3",
- description = "The starting point of the capsule."
- },
- {
- name = "p2",
- type = "Vec3",
- description = "The ending point of the capsule."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule.",
- default = "1.0"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "32"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "circle",
- tag = "drawing",
- summary = "Draw a circle.",
- description = "Draws a circle.",
- key = "Pass:circle",
- module = "lovr.graphics",
- notes = "The local origin of the circle is in its center. The local z axis is perpendicular to the circle.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the circle.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the circle.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the circle.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the circle.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the circle around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the circle should be filled or outlined.",
- default = "'fill'"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments to render.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the circle."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the circle.",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the circle."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the circle should be filled or outlined.",
- default = "'fill'"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments to render.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the circle."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the circle should be filled or outlined.",
- default = "'fill'"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments to render.",
- default = "64"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "compute",
- tag = "compute",
- summary = "Run a compute shader.",
- 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.",
- key = "Pass:compute",
- module = "lovr.graphics",
- examples = {
- {
- description = "A compute shader that makes a texture grayscale.",
- code = "function lovr.load()\n shader = lovr.graphics.newShader([[\n layout(local_size_x = 8, local_size_y = 8) in;\n layout(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"
- }
- },
- 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\nThere are limits to the number of workgroups that can be dispatched, see the `workgroupCount` limit in `lovr.graphics.getLimits`. The local workgroup size is also limited by the `workgroupSize` and `totalWorkgroupSize` limits.\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.",
- related = {
- "Pass:barrier",
- "Pass:setShader",
- "Pass:send",
- "lovr.graphics.getLimits"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The number of workgroups to dispatch in the x dimension.",
- default = "1"
- },
- {
- name = "y",
- type = "number",
- description = "The number of workgroups to dispatch in the y dimension.",
- default = "1"
- },
- {
- name = "z",
- type = "number",
- description = "The number of workgroups to dispatch in the z dimension.",
- default = "1"
- }
- },
- returns = {}
- },
- {
- 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.",
- arguments = {
- {
- name = "buffer",
- type = "Buffer",
- description = "A Buffer object containing the x, y, and z workgroup counts, stored as 4 byte unsigned integers."
- },
- {
- name = "offset",
- type = "number",
- description = "The byte offset to read the workgroup counts from in the Buffer.",
- default = "0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "cone",
- tag = "drawing",
- summary = "Draw a cone.",
- description = "Draws a cone.",
- key = "Pass:cone",
- module = "lovr.graphics",
- notes = "The local origin is at the center of the base of the cone, and the negative z axis points towards the tip.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the base of the cone.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the base of the cone.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the base of the cone.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cone.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cone.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the cone around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments in the cone.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the base of the cone."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cone.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cone.",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the cone."
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments in the cone.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the cone."
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments in the cone.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "p1",
- type = "Vec3",
- description = "The position of the base of the cone."
- },
- {
- name = "p2",
- type = "Vec3",
- description = "The position of the tip of the cone."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cone.",
- default = "1"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of segments in the cone.",
- default = "64"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "cube",
- tag = "drawing",
- summary = "Draw a cube.",
- description = "Draws a cube.",
- key = "Pass:cube",
- module = "lovr.graphics",
- notes = "The local origin is in the center of the cube.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the cube.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the cube.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the cube.",
- default = "0"
- },
- {
- name = "size",
- type = "number",
- description = "The size of the cube.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the cube around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the cube should be drawn filled or outlined.",
- default = "'fill'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the cube."
- },
- {
- name = "size",
- type = "number",
- description = "The size of the cube.",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the cube."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the cube should be drawn filled or outlined.",
- default = "'fill'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the cube."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the cube should be drawn filled or outlined.",
- default = "'fill'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "cylinder",
- tag = "drawing",
- summary = "Draw a cylinder.",
- description = "Draws a cylinder.",
- key = "Pass:cylinder",
- module = "lovr.graphics",
- notes = "The local origin is in the center of the cylinder, and the length of the cylinder is along the z axis.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the cylinder.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the cylinder.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the cylinder.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cylinder.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the cylinder around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "capped",
- type = "boolean",
- description = "Whether the tops and bottoms of the cylinder should be rendered.",
- default = "true"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the cylinder."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cylinder.",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the cylinder."
- },
- {
- name = "capped",
- type = "boolean",
- description = "Whether the tops and bottoms of the cylinder should be rendered.",
- default = "true"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the cylinder."
- },
- {
- name = "capped",
- type = "boolean",
- description = "Whether the tops and bottoms of the cylinder should be rendered.",
- default = "true"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "64"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "p1",
- type = "Vec3",
- description = "The starting point of the cylinder."
- },
- {
- name = "p2",
- type = "Vec3",
- description = "The ending point of the cylinder."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder.",
- default = "1"
- },
- {
- name = "capped",
- type = "boolean",
- description = "Whether the tops and bottoms of the cylinder should be rendered.",
- default = "true"
- },
- {
- name = "angle1",
- type = "number",
- description = "The angle of the beginning of the arc.",
- default = "0"
- },
- {
- name = "angle2",
- type = "number",
- description = "angle of the end of the arc.",
- default = "2 * math.pi"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to render.",
- default = "64"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "draw",
- tag = "drawing",
- summary = "Draw a Model, Mesh, or Texture.",
- description = "Draws a `Model`, `Mesh`, or `Texture`.",
- key = "Pass:draw",
- module = "lovr.graphics",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "object",
- type = "*",
- description = "The Model, Mesh, or Texture to draw."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate to draw the object at.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate to draw the object at.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate to draw the object at.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the object.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the object around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of instances to draw.",
- default = "1"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "object",
- type = "*",
- description = "The Model, Mesh, or Texture to draw."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to draw the object at."
- },
- {
- name = "scale3",
- type = "Vec3",
- description = "The scale of the object, as a vector."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the object."
- },
- {
- name = "instances",
- type = "number",
- description = "The number of instances to draw.",
- default = "1"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "object",
- type = "*",
- description = "The Model, Mesh, or Texture to draw."
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the object."
- },
- {
- name = "instances",
- type = "number",
- description = "The number of instances to draw.",
- default = "1"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "fill",
- tag = "drawing",
- summary = "Draw a fullscreen triangle.",
- description = "Draws a fullscreen triangle. The `fill` shader is used, which stretches the triangle across the screen.",
- key = "Pass:fill",
- module = "lovr.graphics",
- 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).",
- variants = {
- {
- arguments = {
- {
- name = "texture",
- type = "Texture",
- description = "The texture to fill. If nil, the texture from the active material is used."
- }
- },
- returns = {}
- },
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "finishTally",
- tag = "tally",
- summary = "Finish a tally.",
- 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`.",
- key = "Pass:finishTally",
- module = "lovr.graphics",
- notes = "There is currently a maximum of 256 tallies per pass.\n\nIf no tally is active, this function will error.",
- related = {
- "Pass:beginTally"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "index",
- type = "number",
- description = "The index of the tally that was finished."
- }
- }
- }
- }
- },
- {
- name = "getCanvas",
- tag = "canvas",
- summary = "Get the Pass's canvas.",
- 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.",
- key = "Pass:getCanvas",
- module = "lovr.graphics",
- 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 }",
- related = {
- "Pass:getClear",
- "Pass:setClear",
- "Pass:getWidth",
- "Pass:getHeight",
- "Pass:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "canvas",
- type = "table",
- description = "The canvas. Numeric keys will contain the color Textures, along with the following keys:",
- table = {
- {
- name = "depth",
- type = "*",
- description = "A `Texture` or `TextureFormat` with the depth buffer."
- },
- {
- name = "samples",
- type = "number",
- description = "The number of multisamples used for antialiasing (either 1 or 4)."
- }
- }
- }
- }
- },
- {
- description = "This function returns nil when a canvas hasn't been set.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "getClear",
- tag = "canvas",
- summary = "Return the clear values of the Pass.",
- description = "Returns the clear values of the pass.",
- key = "Pass:getClear",
- module = "lovr.graphics",
- notes = "The default clear color is transparent black.",
- related = {
- "Pass:getCanvas"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "clears",
- type = "table",
- 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."
- }
- }
- }
- }
- },
- {
- name = "getDimensions",
- tag = "canvas",
- summary = "Get the dimensions of the Pass's canvas.",
- description = "Returns the dimensions of the textures of the Pass's canvas, in pixels.",
- key = "Pass:getDimensions",
- module = "lovr.graphics",
- notes = "If the pass doesn't have a canvas, this function returns zeros.",
- related = {
- "Pass:getWidth",
- "Pass:getHeight",
- "Pass:getViewCount",
- "Pass:getCanvas",
- "Pass:setCanvas",
- "lovr.system.getWindowDimensions",
- "lovr.headset.getDisplayDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The texture width."
- },
- {
- name = "height",
- type = "number",
- description = "The texture height."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- tag = "canvas",
- summary = "Get the height of the Pass's canvas.",
- description = "Returns the height of the textures of the Pass's canvas, in pixels.",
- key = "Pass:getHeight",
- module = "lovr.graphics",
- notes = "If the pass doesn't have a canvas, this function returns zero.",
- related = {
- "Pass:getWidth",
- "Pass:getDimensions",
- "Pass:getViewCount",
- "Pass:getCanvas",
- "Pass:setCanvas",
- "lovr.system.getWindowHeight",
- "lovr.headset.getDisplayHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The texture height."
- }
- }
- }
- }
- },
- {
- name = "getLabel",
- tag = "pass-misc",
- summary = "Get the debug label of the Pass.",
- description = "Returns the debug label of the Pass, which will show up when the Pass is printed and in some graphics debugging tools. This is set when the Pass is created, and can't be changed afterwards.",
- key = "Pass:getLabel",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newPass",
- "Texture:getLabel",
- "Shader:getLabel"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "label",
- type = "string",
- description = "The label, or nil if none was set."
- }
- }
- }
- }
- },
- {
- name = "getProjection",
- tag = "camera",
- summary = "Get the field of view.",
- description = "Returns the projection for a single view.",
- key = "Pass:getProjection",
- module = "lovr.graphics",
- related = {
- "lovr.headset.getViewAngles",
- "lovr.headset.getViewCount",
- "Pass:getViewPose",
- "Pass:setViewPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The view index."
- }
- },
- returns = {
- {
- name = "left",
- type = "number",
- description = "The left field of view angle, in radians."
- },
- {
- name = "right",
- type = "number",
- description = "The right field of view angle, in radians."
- },
- {
- name = "up",
- type = "number",
- description = "The top field of view angle, in radians."
- },
- {
- name = "down",
- type = "number",
- description = "The bottom field of view angle, in radians."
- }
- }
- },
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The view index."
- },
- {
- name = "matrix",
- type = "Mat4",
- description = "The matrix to fill with the projection."
- }
- },
- returns = {
- {
- name = "matrix",
- type = "Mat4",
- description = "The matrix containing the projection."
- }
- }
- }
- }
- },
- {
- name = "getSampleCount",
- tag = "canvas",
- summary = "Get the antialiasing setting of a render pass.",
- description = "Returns the antialiasing setting of a render pass.",
- key = "Pass:getSampleCount",
- module = "lovr.graphics",
- deprecated = true,
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "samples",
- type = "number",
- description = "The number of samples used for rendering. Currently, will be 1 or 4."
- }
- }
- }
- }
- },
- {
- name = "getStats",
- tag = "pass-misc",
- summary = "Get statistics for the Pass.",
- description = "Returns statistics for the Pass.",
- key = "Pass:getStats",
- module = "lovr.graphics",
- examples = {
- {
- description = "See how long it takes the GPU to render a cube.",
- 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"
- }
- },
- related = {
- "lovr.graphics.isTimingEnabled",
- "lovr.graphics.setTimingEnabled",
- "Pass:setViewCull"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "stats",
- type = "table",
- description = "A table with statistics.",
- table = {
- {
- name = "draws",
- type = "number",
- description = "The number of draws added to the Pass."
- },
- {
- name = "computes",
- type = "number",
- description = "The number of compute calls added to the Pass."
- },
- {
- name = "drawsCulled",
- type = "number",
- description = "The number of draw calls that were culled the last time the Pass was submitted."
- },
- {
- name = "cpuMemoryReserved",
- type = "number",
- description = "The amount of CPU memory the Pass has reserved, in bytes."
- },
- {
- name = "cpuMemoryUsed",
- type = "number",
- description = "The amount of CPU memory the Pass is currently using, in bytes."
- },
- {
- name = "submitTime",
- type = "number",
- 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."
- },
- {
- name = "gpuTime",
- type = "number",
- 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."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getTallyBuffer",
- tag = "tally",
- summary = "Get the Buffer that tally results will be written to.",
- 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`.",
- key = "Pass:getTallyBuffer",
- module = "lovr.graphics",
- related = {
- "Pass:beginTally",
- "Pass:finishTally"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The buffer."
- },
- {
- name = "offset",
- type = "number",
- description = "An offset in the buffer where results will be written."
- }
- }
- }
- }
- },
- {
- name = "getTarget",
- tag = "canvas",
- summary = "Get the textures a render pass is rendering to.",
- description = "Returns the textures a render pass is rendering to.",
- key = "Pass:getTarget",
- module = "lovr.graphics",
- deprecated = true,
- related = {
- "Pass:getClear"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "target",
- type = "table",
- description = "A table of the color textures targeted by the pass, with an additional `depth` key if the pass has a depth texture."
- }
- }
- }
- }
- },
- {
- name = "getType",
- tag = "pass-misc",
- summary = "Get the type of the Pass.",
- description = "Returns the type of the pass (render, compute, or transfer). The type restricts what kinds of functions can be called on the pass.",
- key = "Pass:getType",
- module = "lovr.graphics",
- deprecated = true,
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "type",
- type = "PassType",
- description = "The type of the Pass."
- }
- }
- }
- }
- },
- {
- name = "getViewCount",
- tag = "camera",
- summary = "Returns the view count of a render pass.",
- description = "Returns the view count of a render pass. This is the layer count of the textures it is rendering to.",
- key = "Pass:getViewCount",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:getViewPose",
- "Pass:setViewPose",
- "Pass:getProjection",
- "Pass:setProjection",
- "lovr.headset.getViewCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "views",
- type = "number",
- description = "The view count."
- }
- }
- }
- }
- },
- {
- name = "getViewPose",
- tag = "camera",
- summary = "Get the camera pose.",
- description = "Get the pose of a single view.",
- key = "Pass:getViewPose",
- module = "lovr.graphics",
- related = {
- "lovr.headset.getViewPose",
- "lovr.headset.getViewCount",
- "Pass:getProjection",
- "Pass:setProjection"
- },
- variants = {
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The view index."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the viewer, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the viewer, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the viewer, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the viewer is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- },
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The view index."
- },
- {
- name = "matrix",
- type = "Mat4",
- description = "The matrix to fill with the view pose."
- },
- {
- name = "invert",
- type = "boolean",
- description = "Whether the matrix should be inverted."
- }
- },
- returns = {
- {
- name = "matrix",
- type = "Mat4",
- description = "The matrix containing the view pose."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- tag = "canvas",
- summary = "Get the width of the Pass's canvas.",
- description = "Returns the width of the textures of the Pass's canvas, in pixels.",
- key = "Pass:getWidth",
- module = "lovr.graphics",
- notes = "If the pass doesn't have a canvas, this function returns zero.",
- related = {
- "Pass:getHeight",
- "Pass:getDimensions",
- "Pass:getViewCount",
- "Pass:getCanvas",
- "Pass:setCanvas",
- "lovr.system.getWindowWidth",
- "lovr.headset.getDisplayWidth"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The texture width."
- }
- }
- }
- }
- },
- {
- name = "line",
- tag = "drawing",
- summary = "Draw a line.",
- description = "Draws a line between points. `Pass:mesh` can also be used to draw line segments using the `line` `DrawMode`.",
- key = "Pass:line",
- module = "lovr.graphics",
- notes = "There is currently no way to increase line thickness.",
- variants = {
- {
- arguments = {
- {
- name = "x1",
- type = "number",
- description = "The x coordinate of the first point."
- },
- {
- name = "y1",
- type = "number",
- description = "The y coordinate of the first point."
- },
- {
- name = "z1",
- type = "number",
- description = "The z coordinate of the first point."
- },
- {
- name = "x2",
- type = "number",
- description = "The x coordinate of the next point."
- },
- {
- name = "y2",
- type = "number",
- description = "The y coordinate of the next point."
- },
- {
- name = "z2",
- type = "number",
- description = "The z coordinate of the next point."
- },
- {
- name = "...",
- type = "*",
- description = "More points to add to the line."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table of numbers or `Vec3` objects (not a mix) representing points of the line."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "v1",
- type = "Vec3",
- description = "A vector containing the position of the first point of the line."
- },
- {
- name = "v2",
- type = "Vec3",
- description = "A vector containing the position of the next point on the line."
- },
- {
- name = "...",
- type = "*",
- description = "More points to add to the line."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "mesh",
- tag = "drawing",
- summary = "Draw a mesh.",
- description = "Draws a mesh.",
- key = "Pass:mesh",
- module = "lovr.graphics",
- examples = {
- {
- 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"
- }
- },
- 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.",
- related = {
- "Pass:setMeshMode"
- },
- variants = {
- {
- description = "Draw a range of vertices from a Buffer, using numbers for the transform.",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the position to draw the mesh at.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the position to draw the mesh at.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the position to draw the mesh at.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the mesh.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the mesh is rotated around its rotational axis.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "start",
- type = "number",
- description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- 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`).",
- default = "nil"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of copies of the mesh to render.",
- default = "1"
- }
- },
- returns = {}
- },
- {
- description = "Draw a range of vertices from a Buffer, using vector types for the transform.",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to draw the mesh at."
- },
- {
- name = "scales",
- type = "Vec3",
- description = "The scale of the mesh."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the mesh."
- },
- {
- name = "start",
- type = "number",
- description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- 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`).",
- default = "nil"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of copies of the mesh to render.",
- default = "1"
- }
- },
- returns = {}
- },
- {
- description = "Draw a range of vertices from a Buffer, using a matrix for the transform.",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform to apply to the mesh."
- },
- {
- name = "start",
- type = "number",
- description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- 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`).",
- default = "nil"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of copies of the mesh to render.",
- default = "1"
- }
- },
- returns = {}
- },
- {
- description = "Draw a mesh using a vertex buffer and an index buffer, using numbers for the transform.",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "indices",
- type = "Buffer",
- description = "The buffer containing the vertex indices to draw."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the position to draw the mesh at.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the position to draw the mesh at.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the position to draw the mesh at.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the mesh.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the mesh is rotated around its rotational axis.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "start",
- type = "number",
- description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- 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`).",
- default = "nil"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of copies of the mesh to render.",
- default = "1"
- },
- {
- name = "base",
- type = "number",
- description = "A base offset to apply to vertex indices.",
- default = "0"
- }
- },
- returns = {}
- },
- {
- description = "Draw a mesh using a vertex buffer and an index buffer, using vector types for the transform.",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "indices",
- type = "Buffer",
- description = "The buffer containing the vertex indices to draw."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to draw the mesh at."
- },
- {
- name = "scales",
- type = "Vec3",
- description = "The scale of the mesh."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the mesh."
- },
- {
- name = "start",
- type = "number",
- description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- 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`).",
- default = "nil"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of copies of the mesh to render.",
- default = "1"
- },
- {
- name = "base",
- type = "number",
- description = "A base offset to apply to vertex indices.",
- default = "0"
- }
- },
- returns = {}
- },
- {
- description = "Draw a mesh using a vertex buffer and an index buffer, using a matrix for the transform.",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "indices",
- type = "Buffer",
- description = "The buffer containing the vertex indices to draw."
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform to apply to the mesh."
- },
- {
- name = "start",
- type = "number",
- description = "The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- 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`).",
- default = "nil"
- },
- {
- name = "instances",
- type = "number",
- description = "The number of copies of the mesh to render.",
- default = "1"
- },
- {
- name = "base",
- type = "number",
- description = "A base offset to apply to vertex indices.",
- default = "0"
- }
- },
- returns = {}
- },
- {
- description = "Perform indirect draws by specifying a `draws` command buffer. This allows for the drawing of instanced geometry to be orchestrated by a compute shader that writes to the `draws` buffer. The `draws` buffer contains one or more commands that define how to draw instances. The `stride` determines the number of bytes between each draw command. By default the draws are assumed to be tightly packed, with 20 bytes between indexed draws and 16 bytes for non-indexed draws.\n\nThe `draws` buffer should use one of these formats:\n\n { -- drawing with vertices and indices\n { name = 'indexCount', type = 'u32' },\n { name = 'instanceCount', type = 'u32' },\n { name = 'firstIndex', type = 'u32' },\n { name = 'vertexOffset', type = 'i32' },\n { name = 'firstInstance', type = 'u32' }\n }\n\n { -- drawing with vertices; indices = nil\n { name = 'vertexCount', type = 'u32' },\n { name = 'instanceCount', type = 'u32' },\n { name = 'firstVertex', type = 'u32' },\n { name = 'firstInstance', type = 'u32' }\n }",
- arguments = {
- {
- name = "vertices",
- type = "Buffer",
- description = "The buffer containing the vertices to draw.",
- default = "nil"
- },
- {
- name = "indices",
- type = "Buffer",
- description = "The buffer containing the vertex indices to draw."
- },
- {
- name = "draws",
- type = "Buffer",
- description = "The buffer containing indirect draw commands."
- },
- {
- name = "drawcount",
- type = "number",
- description = "The number of indirect draws to draw.",
- default = "1"
- },
- {
- name = "offset",
- type = "number",
- description = "A byte offset into the draw buffer.",
- default = "0"
- },
- {
- name = "stride",
- type = "number",
- description = "The number of bytes between consecutive elements in the draw buffer. When zero or nil, the stride is autodetected, and will be 20 bytes when an index buffer is provided and 16 bytes otherwise.",
- default = "0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "origin",
- tag = "transform",
- summary = "Reset the transform to the origin.",
- description = "Resets the transform back to the origin.",
- key = "Pass:origin",
- module = "lovr.graphics",
- related = {
- "Pass:translate",
- "Pass:rotate",
- "Pass:scale",
- "Pass:transform",
- "Pass:push",
- "Pass:pop"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "plane",
- tag = "drawing",
- summary = "Draw a plane.",
- description = "Draws a plane.",
- key = "Pass:plane",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the plane.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the plane.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the plane.",
- default = "0"
- },
- {
- name = "width",
- type = "number",
- description = "The width of the plane.",
- default = "1"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the plane.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the plane around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the plane should be drawn filled or outlined.",
- default = "'fill'"
- },
- {
- name = "columns",
- type = "number",
- description = "The number of horizontal segments in the plane.",
- default = "1"
- },
- {
- name = "rows",
- type = "number",
- description = "The number of vertical segments in the plane.",
- default = "columns"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the plane."
- },
- {
- name = "size",
- type = "Vec2",
- description = "The size of the plane."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the plane."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the plane should be drawn filled or outlined.",
- default = "'fill'"
- },
- {
- name = "columns",
- type = "number",
- description = "The number of horizontal segments in the plane.",
- default = "1"
- },
- {
- name = "rows",
- type = "number",
- description = "The number of vertical segments in the plane.",
- default = "columns"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the plane."
- },
- {
- name = "style",
- type = "DrawStyle",
- description = "Whether the plane should be drawn filled or outlined.",
- default = "'fill'"
- },
- {
- name = "columns",
- type = "number",
- description = "The number of horizontal segments in the plane.",
- default = "1"
- },
- {
- name = "rows",
- type = "number",
- description = "The number of vertical segments in the plane.",
- default = "columns"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "points",
- tag = "drawing",
- summary = "Draw points.",
- description = "Draws points. `Pass:mesh` can also be used to draw points using a `Buffer`.",
- key = "Pass:points",
- module = "lovr.graphics",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the first point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the first point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the first point."
- },
- {
- name = "...",
- type = "*",
- description = "More points."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table of numbers or Vec3 objects (not both) representing point positions."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A vector containing the position of the first point to draw."
- },
- {
- name = "...",
- type = "*",
- description = "More points."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "polygon",
- tag = "drawing",
- summary = "Draw a polygon.",
- description = "Draws a polygon. The 3D vertices must be coplanar (all lie on the same plane), and the polygon must be convex (does not intersect itself or have any angles between vertices greater than 180 degrees), otherwise rendering artifacts may occur.",
- key = "Pass:polygon",
- module = "lovr.graphics",
- notes = "Currently, the polygon will not have normal vectors.\n\n`Mesh` objects can also be used to draw arbitrary triangle meshes.",
- related = {
- "Pass:points",
- "Pass:line",
- "Pass:draw"
- },
- variants = {
- {
- arguments = {
- {
- name = "x1",
- type = "number",
- description = "The x coordinate of the first vertex."
- },
- {
- name = "y1",
- type = "number",
- description = "The y coordinate of the first vertex."
- },
- {
- name = "z1",
- type = "number",
- description = "The z coordinate of the first vertex."
- },
- {
- name = "x2",
- type = "number",
- description = "The x coordinate of the next vertex."
- },
- {
- name = "y2",
- type = "number",
- description = "The y coordinate of the next vertex."
- },
- {
- name = "z2",
- type = "number",
- description = "The z coordinate of the next vertex."
- },
- {
- name = "...",
- type = "*",
- description = "More vertices to add to the polygon."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table of numbers or `Vec3` objects (not a mix) representing vertices of the polygon."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "v1",
- type = "Vec3",
- description = "A vector containing the position of the first vertex of the polygon."
- },
- {
- name = "v2",
- type = "Vec3",
- description = "A vector containing the position of the next vertex on the polygon."
- },
- {
- name = "...",
- type = "*",
- description = "More vertices to add to the polygon."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "pop",
- tag = "transform",
- summary = "Pop one of the stacks.",
- description = "Pops the transform or render state stack, restoring it to the state it was in when it was last pushed.",
- key = "Pass:pop",
- module = "lovr.graphics",
- notes = "If a stack is popped without a corresponding push, the stack \"underflows\" which causes an error.",
- related = {
- "Pass:push",
- "StackType"
- },
- variants = {
- {
- arguments = {
- {
- name = "stack",
- type = "StackType",
- description = "The type of stack to pop.",
- default = "'transform'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "push",
- tag = "transform",
- summary = "Push state onto a stack.",
- 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.",
- key = "Pass:push",
- module = "lovr.graphics",
- 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`.",
- related = {
- "Pass:pop",
- "StackType"
- },
- variants = {
- {
- arguments = {
- {
- name = "stack",
- type = "StackType",
- description = "The type of stack to push.",
- default = "'transform'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "reset",
- tag = "pass-misc",
- summary = "Reset the Pass.",
- description = "Resets the Pass, clearing all of its draws and computes and resetting all of its state to the default values.",
- key = "Pass:reset",
- module = "lovr.graphics",
- 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`.",
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "rotate",
- tag = "transform",
- summary = "Rotate the coordinate system.",
- description = "Rotates the coordinate system.",
- key = "Pass:rotate",
- module = "lovr.graphics",
- related = {
- "Pass:translate",
- "Pass:scale",
- "Pass:transform",
- "Pass:origin",
- "Pass:push",
- "Pass:pop"
- },
- variants = {
- {
- description = "Rotate the coordinate system using numbers.",
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The amount to rotate the coordinate system by, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Rotate the coordinate system using a quaternion.",
- arguments = {
- {
- name = "rotation",
- type = "Quat",
- description = "A quaternion containing the rotation to apply."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "roundrect",
- tag = "drawing",
- summary = "Draw a rounded rectangle.",
- description = "Draws a rounded rectangle.",
- key = "Pass:roundrect",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the rectangle.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the rectangle.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the rectangle.",
- default = "0"
- },
- {
- name = "width",
- type = "number",
- description = "The width of the rectangle.",
- default = "1"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the rectangle.",
- default = "1"
- },
- {
- name = "thickness",
- type = "number",
- description = "The thickness of the rectangle.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the rectangle around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners.",
- default = "0"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh.",
- default = "8"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the rectangle."
- },
- {
- name = "size",
- type = "Vec3",
- description = "The size of the rectangle (width, height, thickness)."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the rectangle."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners.",
- default = "0"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh.",
- default = "8"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the rectangle."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners.",
- default = "0"
- },
- {
- name = "segments",
- type = "number",
- description = "The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh.",
- default = "8"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "scale",
- tag = "transform",
- summary = "Scale the coordinate system.",
- description = "Scales the coordinate system.",
- key = "Pass:scale",
- module = "lovr.graphics",
- related = {
- "Pass:translate",
- "Pass:rotate",
- "Pass:transform",
- "Pass:origin",
- "Pass:push",
- "Pass:pop"
- },
- variants = {
- {
- description = "Scale the coordinate system using numbers.",
- arguments = {
- {
- name = "sx",
- type = "number",
- description = "The x component of the scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y component of the scale.",
- default = "sx"
- },
- {
- name = "sz",
- type = "number",
- description = "The z component of the scale.",
- default = "sx"
- }
- },
- returns = {}
- },
- {
- description = "Scale the coordinate system using a vector.",
- arguments = {
- {
- name = "scale",
- type = "Vec3",
- description = "The scale to apply."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "send",
- tag = "shaders",
- summary = "Set the value of a shader variable.",
- description = "Sends a value to a variable in the Pass's active `Shader`. The active shader is changed using `Pass:setShader`.",
- key = "Pass:send",
- module = "lovr.graphics",
- examples = {
- {
- code = "function lovr.load()\n shader = lovr.graphics.newShader([[\n uniform sampler mySampler;\n uniform Colors { vec4 colors[256]; };\n uniform texture2D rocks;\n uniform uint constant;\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"
- }
- },
- notes = "The 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.",
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the Shader variable."
- },
- {
- name = "buffer",
- type = "Buffer",
- description = "The Buffer to assign."
- },
- {
- name = "offset",
- type = "number",
- description = "An offset from the start of the buffer where data will be read, in bytes.",
- default = "0"
- },
- {
- name = "extent",
- type = "number",
- 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.",
- default = "0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the Shader variable."
- },
- {
- name = "texture",
- type = "Texture",
- description = "The Texture to assign."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the Shader variable."
- },
- {
- name = "sampler",
- type = "Sampler",
- description = "The Sampler to assign."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the Shader variable."
- },
- {
- name = "data",
- type = "*",
- description = "Numbers, booleans, vectors, or tables to assign to the data or uniform buffer."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setAlphaToCoverage",
- tag = "pipeline",
- summary = "Enable or disable alpha to coverage.",
- 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.",
- key = "Pass:setAlphaToCoverage",
- module = "lovr.graphics",
- notes = "By default, alpha to coverage is disabled.",
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether alpha to coverage should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setBlendMode",
- tag = "pipeline",
- summary = "Set the blend mode.",
- 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.",
- key = "Pass:setBlendMode",
- module = "lovr.graphics",
- notes = "The default blend mode is `alpha` with the `alphamultiply` alpha mode.",
- variants = {
- {
- description = "Sets the blend mode for all canvas textures.",
- arguments = {
- {
- name = "blend",
- type = "BlendMode",
- description = "The blend mode."
- },
- {
- name = "alphaBlend",
- type = "BlendAlphaMode",
- description = "The alpha blend mode, used to control premultiplied alpha."
- }
- },
- returns = {}
- },
- {
- 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.",
- arguments = {},
- returns = {}
- },
- {
- description = "Sets the blend mode for a single canvas texture.",
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the canvas texture that will use the new blend mode."
- },
- {
- name = "blend",
- type = "BlendMode",
- description = "The blend mode."
- },
- {
- name = "alphaBlend",
- type = "BlendAlphaMode",
- description = "The alpha blend mode, used to control premultiplied alpha."
- }
- },
- returns = {}
- },
- {
- description = "Disables blending for a single canvas texture.",
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the canvas texture that will use the new blend mode."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setCanvas",
- tag = "canvas",
- summary = "Set the Pass's canvas.",
- 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.",
- key = "Pass:setCanvas",
- module = "lovr.graphics",
- 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 (`lovr.graphics.newTextureView`).\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 }",
- related = {
- "Pass:getClear",
- "Pass:setClear",
- "Pass:getWidth",
- "Pass:getHeight",
- "Pass:getDimensions"
- },
- variants = {
- {
- arguments = {
- {
- name = "...textures",
- type = "Texture",
- description = "One or more color textures the pass will render to."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "canvas",
- type = "table",
- 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:",
- table = {
- {
- name = "depth",
- type = "*",
- description = "A `Texture` or `TextureFormat` with the depth buffer.",
- default = "d32f"
- },
- {
- name = "samples",
- type = "number",
- description = "The number of multisamples used for antialiasing (either 1 or 4).",
- default = "4"
- }
- }
- }
- },
- returns = {}
- },
- {
- description = "Disable the canvas. Any draws in the Pass will be skipped when it is submitted (compute shaders will still run though).",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setClear",
- tag = "canvas",
- summary = "Set the clear values of the Pass.",
- 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.",
- key = "Pass:setClear",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setCanvas",
- "Texture:clear"
- },
- variants = {
- {
- description = "Set the clear color for all color textures, using a hexcode.",
- arguments = {
- {
- name = "hex",
- type = "number",
- description = "A hexcode color to clear all color textures to."
- }
- },
- returns = {}
- },
- {
- description = "Set the clear color for all color textures, using numbers.",
- arguments = {
- {
- name = "r",
- type = "number",
- description = "The red component of the clear color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the clear color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the clear color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the clear color.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- description = "Set the clear color for all color textures, using a boolean.",
- arguments = {
- {
- name = "clear",
- type = "boolean",
- description = "Whether color textures should be cleared."
- }
- },
- returns = {}
- },
- {
- description = "Set the clear color for all color textures using a table, or set clear values for individual textures.",
- arguments = {
- {
- name = "t",
- type = "table",
- 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."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setColor",
- tag = "pipeline",
- summary = "Set the color.",
- description = "Sets the color used for drawing. Color components are from 0 to 1.",
- key = "Pass:setColor",
- module = "lovr.graphics",
- notes = "The default color is `(1, 1, 1, 1)`.",
- variants = {
- {
- arguments = {
- {
- name = "r",
- type = "number",
- description = "The red component of the color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the color.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table of 3 or 4 color components."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "hex",
- type = "number",
- description = "A hexcode."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the color.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setColorWrite",
- tag = "pipeline",
- summary = "Change the color channels affected by drawing.",
- 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.",
- key = "Pass:setColorWrite",
- module = "lovr.graphics",
- notes = "By default, color writes are enabled for all channels.",
- related = {
- "Pass:setDepthWrite",
- "Pass:setStencilWrite"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether all color components should be affected by draws."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "r",
- type = "boolean",
- description = "Whether the red component should be affected by draws."
- },
- {
- name = "g",
- type = "boolean",
- description = "Whether the green component should be affected by draws."
- },
- {
- name = "b",
- type = "boolean",
- description = "Whether the blue component should be affected by draws."
- },
- {
- name = "a",
- type = "boolean",
- description = "Whether the alpha component should be affected by draws."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the canvas texture to update."
- },
- {
- name = "enable",
- type = "boolean",
- description = "Whether all color components should be affected by draws."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the canvas texture to update."
- },
- {
- name = "r",
- type = "boolean",
- description = "Whether the red component should be affected by draws."
- },
- {
- name = "g",
- type = "boolean",
- description = "Whether the green component should be affected by draws."
- },
- {
- name = "b",
- type = "boolean",
- description = "Whether the blue component should be affected by draws."
- },
- {
- name = "a",
- type = "boolean",
- description = "Whether the alpha component should be affected by draws."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setCullMode",
- tag = "pipeline",
- summary = "Control triangle face culling.",
- description = "Sets whether the front or back faces of triangles are culled.",
- key = "Pass:setCullMode",
- module = "lovr.graphics",
- deprecated = true,
- notes = "By default, face culling is disabled.",
- related = {
- "Pass:setViewCull",
- "Pass:setWinding"
- },
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "CullMode",
- description = "Whether `front` faces, `back` faces, or `none` of the faces should be culled."
- }
- },
- returns = {}
- },
- {
- description = "Disable face culling.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setDepthClamp",
- tag = "pipeline",
- summary = "Enable or disable depth clamp.",
- 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.",
- key = "Pass:setDepthClamp",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setDepthTest",
- "Pass:setDepthWrite",
- "Pass:setDepthOffset"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether depth clamp should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDepthOffset",
- tag = "pipeline",
- summary = "Configure the depth offset.",
- 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.",
- key = "Pass:setDepthOffset",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setDepthTest",
- "Pass:setDepthWrite"
- },
- variants = {
- {
- arguments = {
- {
- name = "offset",
- type = "number",
- description = "The depth offset.",
- default = "0.0"
- },
- {
- name = "sloped",
- type = "number",
- description = "The sloped depth offset.",
- default = "0.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDepthTest",
- tag = "pipeline",
- summary = "Configure the depth test.",
- description = "Sets the depth test.",
- key = "Pass:setDepthTest",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setDepthWrite",
- "Pass:setDepthOffset",
- "Pass:setDepthClamp",
- "Pass:setStencilTest",
- "Pass:setProjection"
- },
- variants = {
- {
- arguments = {
- {
- name = "test",
- type = "CompareMode",
- description = "The new depth test to use."
- }
- },
- returns = {}
- },
- {
- description = "Disable the depth test.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setDepthWrite",
- tag = "pipeline",
- summary = "Set whether draws write to the depth buffer.",
- 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.",
- key = "Pass:setDepthWrite",
- module = "lovr.graphics",
- notes = "The default depth write is `true`.",
- related = {
- "Pass:setStencilWrite",
- "Pass:setColorWrite",
- "Pass:setDepthTest"
- },
- variants = {
- {
- arguments = {
- {
- name = "write",
- type = "boolean",
- description = "Whether the depth buffer should be affected by draws."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setFaceCull",
- tag = "pipeline",
- summary = "Control triangle face culling.",
- description = "Sets whether the front or back faces of triangles are culled.",
- key = "Pass:setFaceCull",
- module = "lovr.graphics",
- notes = "By default, face culling is disabled.",
- related = {
- "Pass:setViewCull",
- "Pass:setWinding"
- },
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "CullMode",
- description = "Whether `front` faces, `back` faces, or `none` of the faces should be culled."
- }
- },
- returns = {}
- },
- {
- description = "Disable face culling.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setFont",
- tag = "pipeline",
- summary = "Set the font.",
- description = "Sets the font used for `Pass:text`.",
- key = "Pass:setFont",
- module = "lovr.graphics",
- related = {
- "Pass:text",
- "lovr.graphics.newFont",
- "lovr.graphics.getDefaultFont"
- },
- variants = {
- {
- arguments = {
- {
- name = "font",
- type = "Font",
- description = "The Font to use when rendering text."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setMaterial",
- tag = "pipeline",
- summary = "Set the material.",
- description = "Sets the material. This will apply to most drawing, except for text, skyboxes, and models, which use their own materials.",
- key = "Pass:setMaterial",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {
- {
- name = "material",
- type = "Material",
- description = "The material to use for drawing."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "texture",
- type = "Texture",
- description = "The texture to use as the material."
- }
- },
- returns = {}
- },
- {
- description = "Use the default material.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setMeshMode",
- tag = "pipeline",
- summary = "Change the way vertices are connected together.",
- description = "Changes the way vertices are connected together when drawing using `Pass:mesh`.",
- key = "Pass:setMeshMode",
- module = "lovr.graphics",
- notes = "The default mesh mode is `triangles`.",
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "DrawMode",
- description = "The mesh mode to use."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setProjection",
- tag = "camera",
- summary = "Set the field of view.",
- 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.",
- key = "Pass:setProjection",
- module = "lovr.graphics",
- 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`.",
- related = {
- "lovr.headset.getViewAngles",
- "lovr.headset.getViewCount",
- "Pass:getViewPose",
- "Pass:setViewPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The index of the view to update."
- },
- {
- name = "left",
- type = "number",
- description = "The left field of view angle, in radians."
- },
- {
- name = "right",
- type = "number",
- description = "The right field of view angle, in radians."
- },
- {
- name = "up",
- type = "number",
- description = "The top field of view angle, in radians."
- },
- {
- name = "down",
- type = "number",
- description = "The bottom field of view angle, in radians."
- },
- {
- name = "near",
- type = "number",
- description = "The near clipping plane distance, in meters.",
- default = ".01"
- },
- {
- name = "far",
- type = "number",
- description = "The far clipping plane distance, in meters.",
- default = "0.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The index of the view to update."
- },
- {
- name = "matrix",
- type = "Mat4",
- description = "The projection matrix for the view."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSampler",
- tag = "pipeline",
- summary = "Set the sampler.",
- 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.",
- key = "Pass:setSampler",
- module = "lovr.graphics",
- examples = {
- {
- code = "function lovr.draw(pass)\n pass:setSampler('nearest') -- activate minecraft mode\n pass:setMaterial(rock)\n pass:cube(x, y, z)\nend"
- }
- },
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "filter",
- type = "FilterMode",
- description = "The default filter mode to use when sampling textures (the `repeat` wrap mode will be used).",
- default = "'linear'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "sampler",
- type = "Sampler",
- description = "The default sampler shaders will use when reading from textures."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setScissor",
- tag = "camera",
- summary = "Set the scissor rectangle.",
- description = "Sets the scissor rectangle. Any pixels outside the scissor rectangle will not be drawn.",
- key = "Pass:setScissor",
- module = "lovr.graphics",
- notes = "`x` and `y` can not be negative. `w` and `h` must be positive.\n\nBy default, the scissor covers the entire canvas.",
- related = {
- "Pass:setViewport"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the upper-left corner of the scissor rectangle."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the upper-left corner of the scissor rectangle."
- },
- {
- name = "w",
- type = "number",
- description = "The width of the scissor rectangle."
- },
- {
- name = "h",
- type = "number",
- description = "The height of the scissor rectangle."
- }
- },
- returns = {}
- },
- {
- description = "Disable the scissor.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setShader",
- tag = "shaders",
- summary = "Set the active Shader.",
- 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.",
- key = "Pass:setShader",
- module = "lovr.graphics",
- notes = "Changing the shader will preserve variable values (the ones set using `Pass:send`) **unless** the new shader declares a variable with the same as one in the old shader, but a different type. The variable \"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 there's a clash in types, the variable will be reset to use a default resource:\n\n- Buffer variables do not have well-defined behavior when they are reset like this, and may\n return random data or even crash the GPU.\n- Texture variable will use a default texture with a single white pixel.\n- Sampler variables will use a default sampler with a `linear` filter mode and `repeat` wrap\n mode.\n\nUniform variables with basic types like `float`, `vec3`, `mat4`, etc. will have their data preserved as long as both shaders declare the variable with the same name and type.",
- related = {
- "Pass:send",
- "Pass:compute"
- },
- variants = {
- {
- arguments = {
- {
- name = "shader",
- type = "Shader",
- description = "The shader to use."
- }
- },
- returns = {}
- },
- {
- description = "Use one of the default shaders for drawing.",
- arguments = {
- {
- name = "default",
- type = "DefaultShader",
- description = "One of the default shaders to use."
- }
- },
- returns = {}
- },
- {
- description = "Switch back to using an automatic shader for drawing.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setStencilTest",
- tag = "pipeline",
- summary = "Configure the stencil test.",
- 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`.",
- key = "Pass:setStencilTest",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setStencilWrite",
- "Pass:setDepthTest"
- },
- variants = {
- {
- arguments = {
- {
- name = "test",
- type = "CompareMode",
- description = "The new stencil test to use."
- },
- {
- name = "value",
- type = "number",
- description = "The stencil value to compare against."
- },
- {
- name = "mask",
- type = "number",
- description = "An optional mask to apply to stencil values before the comparison.",
- default = "0xff"
- }
- },
- returns = {}
- },
- {
- description = "Disable the stencil test.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setStencilWrite",
- tag = "pipeline",
- summary = "Set whether draws write to the stencil buffer.",
- 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.",
- key = "Pass:setStencilWrite",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setStencilTest",
- "Pass:setDepthTest"
- },
- variants = {
- {
- arguments = {
- {
- name = "action",
- type = "StencilAction",
- description = "How pixels drawn will update the stencil buffer."
- },
- {
- name = "value",
- type = "number",
- description = "When using the 'replace' action, this is the value to replace with.",
- default = "1"
- },
- {
- name = "mask",
- type = "number",
- description = "An optional mask to apply to stencil values before writing.",
- default = "0xff"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "actions",
- type = "table",
- 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."
- },
- {
- name = "value",
- type = "number",
- description = "When using the 'replace' action, this is the value to replace with.",
- default = "1"
- },
- {
- name = "mask",
- type = "number",
- description = "An optional mask to apply to stencil values before writing.",
- default = "0xff"
- }
- },
- returns = {}
- },
- {
- description = "Disables stencil writing.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setTallyBuffer",
- tag = "tally",
- summary = "Set the Buffer that tally results will be written to.",
- 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`.",
- key = "Pass:setTallyBuffer",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:beginTally",
- "Pass:finishTally"
- },
- variants = {
- {
- arguments = {
- {
- name = "buffer",
- type = "Buffer",
- description = "The buffer."
- },
- {
- name = "offset",
- type = "number",
- description = "A byte offset where results will be written. Must be a multiple of 4."
- }
- },
- returns = {}
- },
- {
- description = "Unset the tally buffer.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setViewCull",
- tag = "pipeline",
- summary = "Enable or disable view frustum culling.",
- 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.",
- key = "Pass:setViewCull",
- module = "lovr.graphics",
- 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 model is animated, then the bounding box will become out of sync and culling will not work properly. View culling should be disabled when rendering animated 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.",
- related = {
- "Pass:setCullMode",
- "Mesh:computeBoundingBox",
- "Mesh:setBoundingBox",
- "Pass:setViewPose",
- "Pass:setProjection"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether frustum culling should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setViewPose",
- tag = "camera",
- summary = "Set the camera pose.",
- 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`.",
- key = "Pass:setViewPose",
- module = "lovr.graphics",
- related = {
- "lovr.headset.getViewPose",
- "lovr.headset.getViewCount",
- "Pass:getProjection",
- "Pass:setProjection"
- },
- variants = {
- {
- description = "Set the pose of the view using numbers.",
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The index of the view to update."
- },
- {
- name = "x",
- type = "number",
- description = "The x position of the viewer, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the viewer, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the viewer, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the viewer is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the pose of the view using vectors.",
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The index of the view to update."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position of the viewer, in meters."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the viewer."
- }
- },
- returns = {}
- },
- {
- description = "Set the pose of the view using a matrix.",
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The index of the view to update."
- },
- {
- name = "matrix",
- type = "Mat4",
- description = "A matrix containing the viewer pose."
- },
- {
- name = "inverted",
- type = "boolean",
- description = "Whether the matrix is an inverted pose (a view matrix)."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setViewport",
- tag = "camera",
- summary = "Set the viewport.",
- 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.",
- key = "Pass:setViewport",
- module = "lovr.graphics",
- notes = "The 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 canvas, with min depth and max depth respectively set to 0 and 1.",
- related = {
- "Pass:setScissor",
- "Pass:getDimensions"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the upper-left corner of the viewport."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the upper-left corner of the viewport."
- },
- {
- name = "w",
- type = "number",
- description = "The width of the viewport. Must be positive."
- },
- {
- name = "h",
- type = "number",
- description = "The height of the viewport. May be negative."
- },
- {
- name = "dmin",
- type = "number",
- description = "The min component of the depth range, between 0 and 1.",
- default = "0.0"
- },
- {
- name = "dmax",
- type = "number",
- description = "The max component of the depth range, between 0 and 1.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- description = "Disable the viewport.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setWinding",
- tag = "pipeline",
- summary = "Set the winding direction of triangle vertices.",
- 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`.",
- key = "Pass:setWinding",
- module = "lovr.graphics",
- notes = "The default winding is counterclockwise. LÖVR's builtin shapes are wound counterclockwise.",
- related = {
- "Pass:setCullMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "winding",
- type = "Winding",
- description = "Whether triangle vertices are ordered `clockwise` or `counterclockwise`."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setWireframe",
- tag = "pipeline",
- summary = "Enable or disable wireframe rendering.",
- 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.",
- key = "Pass:setWireframe",
- module = "lovr.graphics",
- notes = "Wireframe rendering is disabled by default.\n\nThere is currently no way to change the thickness of the lines.",
- related = {
- "Pass:setMeshMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether wireframe rendering should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "skybox",
- tag = "drawing",
- summary = "Draw a skybox.",
- description = "Draws a skybox.",
- key = "Pass:skybox",
- module = "lovr.graphics",
- 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).",
- variants = {
- {
- arguments = {
- {
- name = "skybox",
- type = "Texture",
- 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."
- }
- },
- returns = {}
- },
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "sphere",
- tag = "drawing",
- summary = "Draw a sphere.",
- description = "Draws a sphere",
- key = "Pass:sphere",
- module = "lovr.graphics",
- notes = "The local origin of the sphere is in its center.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the sphere.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the sphere.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the sphere.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the sphere around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "longitudes",
- type = "number",
- description = "The number of \"horizontal\" segments.",
- default = "48"
- },
- {
- name = "latitudes",
- type = "number",
- description = "The number of \"vertical\" segments.",
- default = "longitudes / 2"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere.",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the sphere."
- },
- {
- name = "longitudes",
- type = "number",
- description = "The number of \"horizontal\" segments.",
- default = "48"
- },
- {
- name = "latitudes",
- type = "number",
- description = "The number of \"vertical\" segments.",
- default = "longitudes / 2"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the sphere."
- },
- {
- name = "longitudes",
- type = "number",
- description = "The number of \"horizontal\" segments.",
- default = "48"
- },
- {
- name = "latitudes",
- type = "number",
- description = "The number of \"vertical\" segments.",
- default = "longitudes / 2"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "text",
- tag = "drawing",
- summary = "Draw text.",
- description = "Draws text. The font can be changed using `Pass:setFont`.",
- key = "Pass:text",
- module = "lovr.graphics",
- 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.",
- related = {
- "Pass:setFont",
- "lovr.graphics.getDefaultFont",
- "Pass:setShader",
- "Font:getWidth",
- "Font:getHeight",
- "Font:getLines",
- "Font:getVertices",
- "Font"
- },
- variants = {
- {
- arguments = {
- {
- name = "text",
- type = "string",
- description = "The text to render."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the text origin.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the text origin.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the text origin.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the text (with the default pixel density, units are meters).",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the text around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal alignment relative to the text origin.",
- default = "'center'"
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical alignment relative to the text origin.",
- default = "'middle'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "text",
- type = "string",
- description = "The text to render."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position of the text."
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the text (with the default pixel density, units are meters).",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the text."
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal alignment relative to the text origin.",
- default = "'center'"
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical alignment relative to the text origin.",
- default = "'middle'"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "text",
- type = "string",
- description = "The text to render."
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the text."
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal alignment relative to the text origin.",
- default = "'center'"
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical alignment relative to the text origin.",
- default = "'middle'"
- }
- },
- returns = {}
- },
- {
- description = "Renders multicolor text.",
- arguments = {
- {
- name = "colortext",
- type = "table",
- 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."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the text origin.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the text origin.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the text origin.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the text (with the default pixel density, units are meters).",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the text around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal alignment relative to the text origin.",
- default = "'center'"
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical alignment relative to the text origin.",
- default = "'middle'"
- }
- },
- returns = {}
- },
- {
- description = "Renders multicolor text.",
- arguments = {
- {
- name = "colortext",
- type = "table",
- 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."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position of the text."
- },
- {
- name = "scale",
- type = "number",
- description = "The scale of the text (with the default pixel density, units are meters).",
- default = "1"
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the text."
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal alignment relative to the text origin.",
- default = "'center'"
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical alignment relative to the text origin.",
- default = "'middle'"
- }
- },
- returns = {}
- },
- {
- description = "Renders multicolor text.",
- arguments = {
- {
- name = "colortext",
- type = "table",
- 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."
- },
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the text."
- },
- {
- name = "wrap",
- type = "number",
- description = "The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap.",
- default = "0"
- },
- {
- name = "halign",
- type = "HorizontalAlign",
- description = "The horizontal alignment relative to the text origin.",
- default = "'center'"
- },
- {
- name = "valign",
- type = "VerticalAlign",
- description = "The vertical alignment relative to the text origin.",
- default = "'middle'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "torus",
- tag = "drawing",
- summary = "Draw a donut.",
- description = "Draws a torus.",
- key = "Pass:torus",
- module = "lovr.graphics",
- notes = "The local origin is in the center of the torus, and the torus forms a circle around the local Z axis.",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the torus.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the torus.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the torus.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the torus.",
- default = "1"
- },
- {
- name = "thickness",
- type = "number",
- description = "The thickness of the torus.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the torus around its rotation axis, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "tsegments",
- type = "number",
- description = "The number of toroidal (circular) segments to render.",
- default = "64"
- },
- {
- name = "psegments",
- type = "number",
- description = "The number of poloidal (tubular) segments to render.",
- default = "32"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the torus."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The size of the torus (x and y scale the radius, z is the thickness)."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the torus."
- },
- {
- name = "tsegments",
- type = "number",
- description = "The number of toroidal (circular) segments to render.",
- default = "64"
- },
- {
- name = "psegments",
- type = "number",
- description = "The number of poloidal (tubular) segments to render.",
- default = "32"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "The transform of the torus."
- },
- {
- name = "tsegments",
- type = "number",
- description = "The number of toroidal (circular) segments to render.",
- default = "64"
- },
- {
- name = "psegments",
- type = "number",
- description = "The number of poloidal (tubular) segments to render.",
- default = "32"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "transform",
- tag = "transform",
- summary = "Apply a general transform to the coordinate system.",
- description = "Transforms the coordinate system.",
- key = "Pass:transform",
- module = "lovr.graphics",
- related = {
- "Pass:translate",
- "Pass:rotate",
- "Pass:scale",
- "Pass:origin",
- "Pass:push",
- "Pass:pop"
- },
- variants = {
- {
- description = "Transform the coordinate system using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation."
- },
- {
- name = "sx",
- type = "number",
- description = "The x component of the scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y component of the scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z component of the scale."
- },
- {
- name = "angle",
- type = "number",
- description = "The amount to rotate the coordinate system by, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Transform the coordinate system using vector types.",
- arguments = {
- {
- name = "translation",
- type = "Vec3",
- description = "The translation to apply."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The scale to apply."
- },
- {
- name = "rotation",
- type = "Quat",
- description = "A quaternion containing the rotation to apply."
- }
- },
- returns = {}
- },
- {
- description = "Transform the coordinate system using a matrix.",
- arguments = {
- {
- name = "transform",
- type = "Mat4",
- description = "A matrix containing the transformation to apply."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "translate",
- tag = "transform",
- summary = "Translate the coordinate system.",
- description = "Translates the coordinate system.",
- key = "Pass:translate",
- module = "lovr.graphics",
- notes = "Order matters when scaling, translating, and rotating the coordinate system.",
- related = {
- "Pass:rotate",
- "Pass:scale",
- "Pass:transform",
- "Pass:origin",
- "Pass:push",
- "Pass:pop"
- },
- variants = {
- {
- description = "Translate the coordinate system using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation."
- }
- },
- returns = {}
- },
- {
- description = "Translate the coordinate system using a vector.",
- arguments = {
- {
- name = "translation",
- type = "Vec3",
- description = "The translation."
- }
- },
- returns = {}
- }
- }
- }
- },
- sections = {
- {
- name = "Drawing",
- tag = "drawing",
- description = "Draw objects and shapes."
- },
- {
- name = "Coordinate System",
- tag = "transform",
- description = "Manipulate the 3D coordinate system."
- },
- {
- name = "Render States",
- tag = "pipeline",
- description = "Set render states that change the way draws appear. Render states can be saved and restored using `Pass:push` and `Pass:pop`."
- },
- {
- name = "Shaders",
- tag = "shaders",
- description = "Change the shader used for draws or computes, and set variables in the active shader."
- },
- {
- name = "Compute",
- tag = "compute"
- },
- {
- name = "Tally",
- tag = "tally",
- description = "Tallies count the number of pixels that were visible for a draw."
- },
- {
- name = "Camera",
- tag = "camera"
- },
- {
- name = "Canvas",
- tag = "canvas"
- },
- {
- name = "Miscellaneous",
- tag = "pass-misc"
- }
- }
- },
- {
- name = "Readback",
- summary = "An asynchronous read of a GPU resource.",
- description = "Readbacks track the progress of an asynchronous read of a `Buffer` or `Texture`. The Readback can be polled for completion or the CPU with `Readback:isComplete`, or you can wait for it to finish using `Readback:wait`.",
- key = "Readback",
- module = "lovr.graphics",
- constructors = {
- "Buffer:newReadback",
- "Texture:newReadback"
- },
- methods = {
- {
- name = "getBlob",
- summary = "Get Readback's data as a Blob.",
- description = "Returns the Readback's data as a Blob.",
- key = "Readback:getBlob",
- module = "lovr.graphics",
- notes = "If the Readback is reading back a Texture, returns `nil`.",
- related = {
- "Readback:getData",
- "Readback:getImage"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "blob",
- type = "Blob",
- description = "The Blob."
- }
- }
- }
- }
- },
- {
- name = "getData",
- summary = "Get Readback's data as a table.",
- description = "Returns the data from the Readback, as a table. See `Buffer:getData` for the way the table is structured.",
- key = "Readback:getData",
- module = "lovr.graphics",
- notes = "This returns `nil` for readbacks of `Texture` objects.",
- related = {
- "Readback:getBlob",
- "Readback:getImage"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "data",
- type = "table",
- description = "A table containing the data that was read back."
- }
- }
- }
- }
- },
- {
- name = "getImage",
- summary = "Get Readback's data as an Image.",
- description = "Returns the Readback's data as an Image.",
- key = "Readback:getImage",
- module = "lovr.graphics",
- notes = "If the Readback is not reading back a Texture, returns `nil`.",
- related = {
- "Readback:getData",
- "Readback:getBlob"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The Image."
- }
- }
- }
- }
- },
- {
- name = "isComplete",
- summary = "Check if a Readback is complete.",
- description = "Returns whether the Readback has completed on the GPU and its data is available.",
- key = "Readback:isComplete",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "complete",
- type = "boolean",
- description = "Whether the readback is complete."
- }
- }
- }
- }
- },
- {
- name = "wait",
- summary = "Wait for the Readback to finish.",
- description = "Blocks the CPU until the Readback is finished on the GPU.",
- key = "Readback:wait",
- module = "lovr.graphics",
- notes = "If `lovr.graphics.submit` or `lovr.graphics.wait` has not been called since the readback was created, the readback has not been submitted yet, so no wait will occur and this function will return `false`.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "waited",
- type = "boolean",
- description = "Whether the CPU had to be blocked for waiting."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Sampler",
- summary = "An object that controls how texture pixels are read.",
- 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 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.",
- key = "Sampler",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newSampler"
- },
- methods = {
- {
- name = "getAnisotropy",
- summary = "Get the anisotropy level of the Sampler.",
- description = "Returns the anisotropy level of the Sampler. Anisotropy smooths out a texture's appearance when viewed at grazing angles.",
- key = "Sampler:getAnisotropy",
- module = "lovr.graphics",
- 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.",
- related = {
- "Sampler:getFilter",
- "Sampler:getWrap",
- "Sampler:getCompareMode",
- "Sampler:getMipmapRange"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "anisotropy",
- type = "number",
- description = "The anisotropy level of the sampler."
- }
- }
- }
- }
- },
- {
- name = "getCompareMode",
- summary = "Get the compare mode of the Sampler.",
- 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.",
- key = "Sampler:getCompareMode",
- module = "lovr.graphics",
- related = {
- "Sampler:getFilter",
- "Sampler:getWrap",
- "Sampler:getAnisotropy",
- "Sampler:getMipmapRange"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "compare",
- type = "CompareMode",
- description = "The compare mode of the sampler."
- }
- }
- }
- }
- },
- {
- name = "getFilter",
- summary = "Get the filter mode of the Sampler.",
- description = "Returns the filter mode of the Sampler.",
- key = "Sampler:getFilter",
- module = "lovr.graphics",
- related = {
- "Sampler:getWrap",
- "Sampler:getCompareMode",
- "Sampler:getAnisotropy",
- "Sampler:getMipmapRange"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "min",
- type = "FilterMode",
- description = "The filter mode used when the texture is minified."
- },
- {
- name = "mag",
- type = "FilterMode",
- description = "The filter mode used when the texture is magnified."
- },
- {
- name = "mip",
- type = "FilterMode",
- description = "The filter mode used to select a mipmap level."
- }
- }
- }
- }
- },
- {
- name = "getMipmapRange",
- summary = "Get the mipmap range of the Sampler.",
- 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.",
- key = "Sampler:getMipmapRange",
- module = "lovr.graphics",
- related = {
- "Sampler:getFilter",
- "Sampler:getWrap",
- "Sampler:getCompareMode",
- "Sampler:getAnisotropy"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "min",
- type = "number",
- description = "The minimum mipmap level that will be sampled (0 is the largest image)."
- },
- {
- name = "max",
- type = "number",
- description = "The maximum mipmap level that will be sampled."
- }
- }
- }
- }
- },
- {
- name = "getWrap",
- summary = "Get the wrap mode of the Sampler.",
- description = "Returns the wrap mode of the sampler, used to wrap or clamp texture coordinates when the extend outside of the 0-1 range.",
- key = "Sampler:getWrap",
- module = "lovr.graphics",
- related = {
- "Sampler:getFilter",
- "Sampler:getCompareMode",
- "Sampler:getAnisotropy",
- "Sampler:getMipmapRange"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "WrapMode",
- description = "The wrap mode used in the horizontal direction."
- },
- {
- name = "y",
- type = "WrapMode",
- description = "The wrap mode used in the vertical direction."
- },
- {
- name = "z",
- type = "WrapMode",
- description = "The wrap mode used in the \"z\" direction, for 3D textures only."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Shader",
- summary = "GPU program.",
- description = "Shaders are small GPU programs. See the `Shaders` guide for a full introduction to Shaders.",
- key = "Shader",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newShader",
- "Shader:clone"
- },
- methods = {
- {
- name = "clone",
- summary = "Clone a Shader.",
- 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.",
- key = "Shader:clone",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {
- {
- name = "source",
- type = "Shader",
- description = "The Shader to clone."
- },
- {
- name = "flags",
- type = "table",
- description = "The flags used by the clone."
- }
- },
- returns = {
- {
- name = "shader",
- type = "Shader",
- description = "The new Shader."
- }
- }
- }
- }
- },
- {
- name = "getBufferFormat",
- summary = "Get the format of a buffer in the Shader.",
- 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.",
- key = "Shader:getBufferFormat",
- module = "lovr.graphics",
- examples = {
- {
- code = "shader = lovr.graphics.newShader([[\n 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)"
- }
- },
- 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 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 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",
- related = {
- "lovr.graphics.newBuffer",
- "Buffer:getFormat"
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the buffer variable to return the format of."
- }
- },
- returns = {
- {
- name = "format",
- type = "table",
- 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."
- },
- {
- name = "length",
- type = "number",
- description = "The number of items in the buffer (or 1 if the buffer is not an array)."
- }
- }
- }
- }
- },
- {
- name = "getLabel",
- summary = "Get the debug label of the Shader.",
- description = "Returns the debug label of the Shader, which will show up when the Shader is printed and in some graphics debugging tools. This is set when the Shader is created, and can't be changed afterwards.",
- key = "Shader:getLabel",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newShader",
- "Texture:getLabel",
- "Pass:getLabel"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "label",
- type = "string",
- description = "The label, or nil if none was set."
- }
- }
- }
- }
- },
- {
- name = "getType",
- summary = "Get the type of the Shader.",
- description = "Returns whether the shader is a graphics or compute shader.",
- key = "Shader:getType",
- module = "lovr.graphics",
- related = {
- "Shader:hasStage",
- "lovr.graphics.newShader"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "type",
- type = "ShaderType",
- description = "The type of the Shader."
- }
- }
- }
- }
- },
- {
- name = "getWorkgroupSize",
- summary = "Get the workgroup size of a compute shader.",
- 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`.",
- key = "Shader:getWorkgroupSize",
- module = "lovr.graphics",
- 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.\n\nThe maximum workgroup size is hardware-specific, and is given by the `workgroupSize` and `totalWorkgroupSize` limit in `lovr.graphics.getLimits`.",
- related = {
- "Pass:compute",
- "lovr.graphics.getLimits"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x size of a workgroup."
- },
- {
- name = "y",
- type = "number",
- description = "The y size of a workgroup."
- },
- {
- name = "z",
- type = "number",
- description = "The z size of a workgroup."
- }
- }
- }
- }
- },
- {
- name = "hasAttribute",
- summary = "Check if the Shader has a given vertex attribute.",
- description = "Returns whether the Shader has a vertex attribute, by name or location.",
- key = "Shader:hasAttribute",
- module = "lovr.graphics",
- examples = {
- {
- code = "function lovr.load()\n shader = lovr.graphics.newShader([[\n 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\nend"
- }
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of an attribute."
- }
- },
- returns = {
- {
- name = "exists",
- type = "boolean",
- description = "Whether the Shader has the attribute."
- }
- }
- },
- {
- arguments = {
- {
- name = "location",
- type = "number",
- description = "The location of an attribute."
- }
- },
- returns = {
- {
- name = "exists",
- type = "boolean",
- description = "Whether the Shader has the attribute."
- }
- }
- }
- }
- },
- {
- name = "hasStage",
- summary = "Check if the Shader has a given stage.",
- description = "Returns whether the Shader has a given stage.",
- key = "Shader:hasStage",
- module = "lovr.graphics",
- related = {
- "Shader:getType"
- },
- variants = {
- {
- arguments = {
- {
- name = "stage",
- type = "ShaderStage",
- description = "The stage."
- }
- },
- returns = {
- {
- name = "exists",
- type = "boolean",
- description = "Whether the Shader has the stage."
- }
- }
- }
- }
- },
- {
- name = "hasVariable",
- summary = "Check if the Shader has a variable.",
- description = "Returns whether the Shader has a variable.",
- key = "Shader:hasVariable",
- module = "lovr.graphics",
- examples = {
- {
- code = "for key, texture in pairs(textures) do\n if shader:hasVariable(key) then\n pass:send(key, texture)\n end\nend"
- }
- },
- notes = "This will return true if the variable is a buffer, texture, sampler, or other uniform variable (anything that can be sent with `Pass:send`).",
- related = {
- "Pass:send"
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the variable to check."
- }
- },
- returns = {
- {
- name = "exists",
- type = "boolean",
- description = "Whether the Shader has the variable."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Texture",
- summary = "A multidimensional block of memory on the GPU.",
- 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.",
- key = "Texture",
- module = "lovr.graphics",
- constructors = {
- "lovr.graphics.newTexture",
- "lovr.graphics.newTextureView"
- },
- methods = {
- {
- name = "clear",
- tag = "texture-transfer",
- summary = "Clear the Texture to a color.",
- 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.",
- key = "Texture:clear",
- module = "lovr.graphics",
- 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.",
- related = {
- "Buffer:clear",
- "Texture:setPixels",
- "Pass:setClear"
- },
- variants = {
- {
- description = "Clear the whole texture to zero (transparent black).",
- arguments = {},
- returns = {}
- },
- {
- arguments = {
- {
- name = "hex",
- type = "number",
- description = "The hexcode color to clear to."
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the first layer to clear.",
- default = "1"
- },
- {
- name = "layerCount",
- type = "number",
- description = "The number of layers to clear. If nil, clears the rest of the layers.",
- default = "nil"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the first mipmap to clear.",
- default = "1"
- },
- {
- name = "mipmapCount",
- type = "number",
- description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "r",
- type = "number",
- description = "The red component of the clear color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the clear color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the clear color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the clear color."
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the first layer to clear.",
- default = "1"
- },
- {
- name = "layerCount",
- type = "number",
- description = "The number of layers to clear. If nil, clears the rest of the layers.",
- default = "nil"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the first mipmap to clear.",
- default = "1"
- },
- {
- name = "mipmapCount",
- type = "number",
- description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table with color components."
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the first layer to clear.",
- default = "1"
- },
- {
- name = "layerCount",
- type = "number",
- description = "The number of layers to clear. If nil, clears the rest of the layers.",
- default = "nil"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the first mipmap to clear.",
- default = "1"
- },
- {
- name = "mipmapCount",
- type = "number",
- description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "v3",
- type = "Vec3",
- description = "A vec3 with the clear color."
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the first layer to clear.",
- default = "1"
- },
- {
- name = "layerCount",
- type = "number",
- description = "The number of layers to clear. If nil, clears the rest of the layers.",
- default = "nil"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the first mipmap to clear.",
- default = "1"
- },
- {
- name = "mipmapCount",
- type = "number",
- description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "v4",
- type = "Vec4",
- description = "A vec4 with the clear color."
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the first layer to clear.",
- default = "1"
- },
- {
- name = "layerCount",
- type = "number",
- description = "The number of layers to clear. If nil, clears the rest of the layers.",
- default = "nil"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the first mipmap to clear.",
- default = "1"
- },
- {
- name = "mipmapCount",
- type = "number",
- description = "The number of mipmaps to clear. If nil, clears the rest of the mipmaps.",
- default = "nil"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "generateMipmaps",
- tag = "texture-transfer",
- summary = "Regenerate mipmaps for a Texture.",
- 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.",
- key = "Texture:generateMipmaps",
- module = "lovr.graphics",
- 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.",
- related = {
- "Texture:setPixels",
- "Texture:getMipmapCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "base",
- type = "number",
- description = "The base mipmap level which will be used to generate subsequent mipmaps.",
- default = "1"
- },
- {
- name = "count",
- type = "number",
- description = "The number of mipmap levels to generate. If nil, the rest of the mipmaps will be generated.",
- default = "nil"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "getDimensions",
- tag = "texture-metadata",
- summary = "Get the dimensions of the Texture.",
- description = "Returns the width, height, and depth of the Texture.",
- key = "Texture:getDimensions",
- module = "lovr.graphics",
- related = {
- "Texture:getWidth",
- "Texture:getHeight",
- "Texture:getLayerCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the Texture."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the Texture."
- },
- {
- name = "layers",
- type = "number",
- description = "The number of layers in the Texture."
- }
- }
- }
- }
- },
- {
- name = "getFormat",
- tag = "texture-metadata",
- summary = "Get the format of the Texture.",
- description = "Returns the format of the texture.",
- key = "Texture:getFormat",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "format",
- type = "TextureFormat",
- description = "The format of the Texture."
- },
- {
- name = "linear",
- type = "boolean",
- description = "Whether the format is linear or srgb."
- }
- }
- }
- }
- },
- {
- name = "getHeight",
- tag = "texture-metadata",
- summary = "Get the height of the Texture, in pixels.",
- description = "Returns the height of the Texture, in pixels.",
- key = "Texture:getHeight",
- module = "lovr.graphics",
- related = {
- "Texture:getWidth",
- "Texture:getLayerCount",
- "Texture:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height of the Texture, in pixels."
- }
- }
- }
- }
- },
- {
- name = "getLabel",
- tag = "texture-metadata",
- summary = "Get the debug label of the Texture.",
- description = "Returns the debug label of the Texture, which will show up when the Texture is printed and in some graphics debugging tools. This is set when the Texture is created, and can't be changed afterwards.",
- key = "Texture:getLabel",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newTexture",
- "Shader:getLabel",
- "Pass:getLabel"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "label",
- type = "string",
- description = "The label, or nil if none was set."
- }
- }
- }
- }
- },
- {
- name = "getLayerCount",
- tag = "texture-metadata",
- summary = "Get the layer count of the Texture.",
- description = "Returns the layer count of the Texture. 2D textures always have 1 layer and cubemaps always have a layer count divisible by 6. 3D and array textures have a variable number of layers.",
- key = "Texture:getLayerCount",
- module = "lovr.graphics",
- related = {
- "Texture:getWidth",
- "Texture:getHeight",
- "Texture:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "layers",
- type = "number",
- description = "The layer count of the Texture."
- }
- }
- }
- }
- },
- {
- name = "getMipmapCount",
- tag = "texture-metadata",
- summary = "Get the number of mipmap levels in the Texture.",
- description = "Returns the number of mipmap levels in the Texture.",
- key = "Texture:getMipmapCount",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newTexture",
- "Sampler:getMipmapRange",
- "Texture:generateMipmaps"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mipmaps",
- type = "number",
- description = "The number of mipmap levels in the Texture."
- }
- }
- }
- }
- },
- {
- name = "getPixels",
- tag = "texture-transfer",
- summary = "Get the pixels of the Texture.",
- 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`.",
- key = "Texture:getPixels",
- module = "lovr.graphics",
- 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.",
- related = {
- "Texture:newReadback"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x offset of the region to download.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y offset of the region to download.",
- default = "0"
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the layer to download.",
- default = "1"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the mipmap level to download.",
- default = "1"
- },
- {
- name = "width",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "height",
- type = "number",
- 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.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "image",
- type = "Image",
- description = "The new image with the pixels."
- }
- }
- }
- }
- },
- {
- name = "getSampleCount",
- tag = "texture-metadata",
- summary = "Get the number of MSAA samples in the Texture.",
- 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).",
- key = "Texture:getSampleCount",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newTexture",
- "Pass:getSampleCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "samples",
- type = "number",
- description = "The number of samples in the Texture."
- }
- }
- }
- }
- },
- {
- name = "getSampler",
- tag = "texture-sampler",
- summary = "Get the Sampler assigned to the Texture.",
- description = "Returns the Sampler object previously assigned with `Texture:setSampler`.\n\nThis API is experimental, and subject to change in the future!",
- key = "Texture:getSampler",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "sampler",
- type = "Sampler",
- description = "The Sampler object."
- }
- }
- }
- }
- },
- {
- name = "getType",
- tag = "texture-metadata",
- summary = "Get the type of the Texture.",
- description = "Returns the type of the texture.",
- key = "Texture:getType",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "type",
- type = "TextureType",
- description = "The type of the Texture."
- }
- }
- }
- }
- },
- {
- name = "getWidth",
- tag = "texture-metadata",
- summary = "Get the width of the Texture, in pixels.",
- description = "Returns the width of the Texture, in pixels.",
- key = "Texture:getWidth",
- module = "lovr.graphics",
- related = {
- "Texture:getHeight",
- "Texture:getLayerCount",
- "Texture:getDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the Texture, in pixels."
- }
- }
- }
- }
- },
- {
- name = "hasUsage",
- tag = "texture-metadata",
- summary = "Check if a Texture was created with a set of usage flags.",
- 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.",
- key = "Texture:hasUsage",
- module = "lovr.graphics",
- related = {
- "lovr.graphics.newTexture"
- },
- variants = {
- {
- arguments = {
- {
- name = "...",
- type = "TextureUsage",
- description = "One or more usage flags."
- }
- },
- returns = {
- {
- name = "supported",
- type = "boolean",
- description = "Whether the Texture has all the provided usage flags."
- }
- }
- }
- }
- },
- {
- name = "newReadback",
- tag = "texture-transfer",
- summary = "Read back the contents of the Texture asynchronously.",
- 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.",
- key = "Texture:newReadback",
- module = "lovr.graphics",
- examples = {
- {
- 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.",
- 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"
- }
- },
- 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.",
- related = {
- "Texture:getPixels",
- "Buffer:newReadback"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x offset of the region to download.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y offset of the region to download.",
- default = "0"
- },
- {
- name = "layer",
- type = "number",
- description = "The index of the layer to download.",
- default = "1"
- },
- {
- name = "mipmap",
- type = "number",
- description = "The index of the mipmap level to download.",
- default = "1"
- },
- {
- name = "width",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "height",
- type = "number",
- 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.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "readback",
- type = "Readback",
- description = "A new Readback object."
- }
- }
- }
- }
- },
- {
- name = "setPixels",
- tag = "texture-transfer",
- summary = "Replace pixels in the Texture.",
- 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.",
- key = "Texture:setPixels",
- module = "lovr.graphics",
- 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\nImages can't be copied to multisample textures. Multisample textures can be copied between each other as long as there isn't any scaling.\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.\n- The formats do not need to match, unless they're depth formats.",
- related = {
- "Texture:newReadback",
- "Texture:generateMipmaps",
- "Image:paste"
- },
- variants = {
- {
- arguments = {
- {
- name = "image",
- type = "Image",
- description = "The image to copy to the texture."
- },
- {
- name = "dstx",
- type = "number",
- description = "The x offset to copy to.",
- default = "0"
- },
- {
- name = "dsty",
- type = "number",
- description = "The y offset to copy to.",
- default = "0"
- },
- {
- name = "dstlayer",
- type = "number",
- description = "The index of the layer to copy to.",
- default = "1"
- },
- {
- name = "dstmipmap",
- type = "number",
- description = "The index of the mipmap level to copy to.",
- default = "1"
- },
- {
- name = "srcx",
- type = "number",
- description = "The x offset to copy from.",
- default = "0"
- },
- {
- name = "srcy",
- type = "number",
- description = "The y offset to copy from.",
- default = "0"
- },
- {
- name = "srclayer",
- type = "number",
- description = "The index of the layer to copy from.",
- default = "1"
- },
- {
- name = "srcmipmap",
- type = "number",
- description = "The index of the mipmap level to copy from.",
- default = "1"
- },
- {
- name = "width",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "height",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "layers",
- type = "number",
- description = "The number of layers to copy. If nil, copies as many layers as possible.",
- default = "nil"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "texture",
- type = "Texture",
- description = "The texture to copy from."
- },
- {
- name = "dstx",
- type = "number",
- description = "The x offset to copy to.",
- default = "0"
- },
- {
- name = "dsty",
- type = "number",
- description = "The y offset to copy to.",
- default = "0"
- },
- {
- name = "dstlayer",
- type = "number",
- description = "The index of the layer to copy to.",
- default = "1"
- },
- {
- name = "dstmipmap",
- type = "number",
- description = "The index of the mipmap level to copy to.",
- default = "1"
- },
- {
- name = "srcx",
- type = "number",
- description = "The x offset to copy from.",
- default = "0"
- },
- {
- name = "srcy",
- type = "number",
- description = "The y offset to copy from.",
- default = "0"
- },
- {
- name = "srclayer",
- type = "number",
- description = "The index of the layer to copy from.",
- default = "1"
- },
- {
- name = "srcmipmap",
- type = "number",
- description = "The index of the mipmap level to copy from.",
- default = "1"
- },
- {
- name = "width",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "height",
- type = "number",
- 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.",
- default = "nil"
- },
- {
- name = "layers",
- type = "number",
- description = "The number of layers to copy. If nil, copies as many layers as possible.",
- default = "nil"
- },
- {
- name = "srcwidth",
- type = "number",
- 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.",
- default = "width"
- },
- {
- name = "srcheight",
- type = "number",
- 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.",
- default = "width"
- },
- {
- name = "srcdepth",
- type = "number",
- description = "The depth of the region in the source texture to copy (`3d` textures only).",
- default = "layers"
- },
- {
- name = "filter",
- type = "FilterMode",
- description = "The filtering mode used to scale the copy when the source and destination sizes don't match.",
- default = "'linear'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSampler",
- tag = "texture-sampler",
- summary = "Set sampler settings for the Texture.",
- description = "Sets sampler settings for the texture. This can either be a `FilterMode` like `nearest`, or a `Sampler` object, which allows configuring all of the filtering and wrapping settings.\n\nThere are other ways of using custom samplers for a texture, but they have disadvantages:\n\n- `Sampler` objects can be sent to shaders and used to sample from the texture, but this\n requires writing custom shader code and sending sampler objects with `Pass:send`, which is\n inconvenient.\n- `Pass:setSampler` exists, but it applies to all textures in all draws in the Pass. It doesn't\n allow for changing filtering settings on a per-texture basis.\n\nThis API is experimental, and subject to change in the future!",
- key = "Texture:setSampler",
- module = "lovr.graphics",
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "FilterMode",
- description = "The FilterMode shaders will use when reading pixels from the texture."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "sampler",
- type = "Sampler",
- description = "The Sampler object shaders will use when reading pixels from the texture."
- }
- },
- returns = {}
- },
- {
- description = "Remove the texture's sampler, instead using the one set by `Pass:setSampler`.",
- arguments = {},
- returns = {}
- }
- }
- }
- },
- sections = {
- {
- name = "Metadata",
- tag = "texture-metadata"
- },
- {
- name = "Transfers",
- tag = "texture-transfer"
- },
- {
- name = "Sampler",
- tag = "texture-sampler"
- }
- }
- }
- },
- sections = {
- {
- name = "Objects",
- tag = "graphics-objects"
- },
- {
- name = "Global State",
- tag = "graphics-global"
- },
- {
- name = "Work Submission",
- tag = "work-submission",
- 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."
- },
- {
- name = "System Info",
- tag = "graphics-misc",
- description = "Information about the GPU hardware and the features it supports."
- }
- }
- },
- {
- name = "headset",
- tag = "modules",
- summary = "Connects to VR hardware.",
- 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.",
- key = "lovr.headset",
- enums = {
- {
- name = "Device",
- summary = "Different types of input devices supported by the `lovr.headset` module.",
- description = "Different types of input devices supported by the `lovr.headset` module.",
- key = "Device",
- module = "lovr.headset",
- 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.",
- related = {
- "DeviceAxis",
- "DeviceButton",
- "lovr.headset.getPose",
- "lovr.headset.getPosition",
- "lovr.headset.getOrientation",
- "lovr.headset.getVelocity",
- "lovr.headset.getAngularVelocity",
- "lovr.headset.getSkeleton",
- "lovr.headset.isTracked",
- "lovr.headset.isDown",
- "lovr.headset.isTouched",
- "lovr.headset.wasPressed",
- "lovr.headset.wasReleased",
- "lovr.headset.getAxis",
- "lovr.headset.vibrate",
- "lovr.headset.animate"
- },
- values = {
- {
- name = "head",
- description = "The headset."
- },
- {
- name = "floor",
- 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."
- },
- {
- name = "left",
- description = "A shorthand for hand/left."
- },
- {
- name = "right",
- description = "A shorthand for hand/right."
- },
- {
- name = "hand/left",
- description = "The left hand."
- },
- {
- name = "hand/right",
- description = "The right hand."
- },
- {
- name = "hand/left/grip",
- description = "The left hand grip pose, used for held objects."
- },
- {
- name = "hand/right/grip",
- description = "The right hand grip pose, used for held objects."
- },
- {
- name = "hand/left/point",
- description = "The left hand pointer pose, used for pointing or aiming."
- },
- {
- name = "hand/right/point",
- description = "The right hand pointer pose, used for pointing or aiming."
- },
- {
- name = "hand/left/pinch",
- description = "The left hand pinch pose between the thumb and index fingers, used for precise, close-range interactions."
- },
- {
- name = "hand/right/pinch",
- description = "The right hand pinch pose between the thumb and index fingers, used for precise, close-range interactions."
- },
- {
- name = "hand/left/poke",
- description = "The left hand poke pose, on the tip of the index finger or in front of a controller."
- },
- {
- name = "hand/right/poke",
- description = "The right hand poke pose, on the tip of the index finger or in front of a controller."
- },
- {
- name = "elbow/left",
- description = "A device tracking the left elbow."
- },
- {
- name = "elbow/right",
- description = "A device tracking the right elbow."
- },
- {
- name = "shoulder/left",
- description = "A device tracking the left shoulder."
- },
- {
- name = "shoulder/right",
- description = "A device tracking the right shoulder."
- },
- {
- name = "chest",
- description = "A device tracking the chest."
- },
- {
- name = "waist",
- description = "A device tracking the waist."
- },
- {
- name = "knee/left",
- description = "A device tracking the left knee."
- },
- {
- name = "knee/right",
- description = "A device tracking the right knee."
- },
- {
- name = "foot/left",
- description = "A device tracking the left foot or ankle."
- },
- {
- name = "foot/right",
- description = "A device tracking the right foot or ankle."
- },
- {
- name = "camera",
- description = "A camera device, often used for recording \"mixed reality\" footage."
- },
- {
- name = "keyboard",
- description = "A tracked keyboard."
- },
- {
- name = "stylus",
- description = "A tracked pen or pointer."
- },
- {
- name = "eye/left",
- description = "The left eye."
- },
- {
- name = "eye/right",
- description = "The right eye."
- },
- {
- name = "eye/gaze",
- 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."
- }
- }
- },
- {
- name = "DeviceAxis",
- summary = "Different axes on an input device.",
- description = "Axes on an input device.",
- key = "DeviceAxis",
- module = "lovr.headset",
- related = {
- "lovr.headset.getAxis",
- "DeviceButton"
- },
- values = {
- {
- name = "trigger",
- description = "A trigger (1D)."
- },
- {
- name = "thumbstick",
- description = "A thumbstick (2D)."
- },
- {
- name = "touchpad",
- description = "A touchpad (2D)."
- },
- {
- name = "grip",
- description = "A grip button or grab gesture (1D)."
- },
- {
- name = "nib",
- description = "The pressure sensitivity of the nib (tip) of a `stylus` device."
- }
- }
- },
- {
- name = "DeviceButton",
- summary = "Different buttons on an input device.",
- description = "Buttons on an input device.",
- key = "DeviceButton",
- module = "lovr.headset",
- values = {
- {
- name = "trigger",
- description = "The trigger button."
- },
- {
- name = "thumbstick",
- description = "The thumbstick."
- },
- {
- name = "thumbrest",
- description = "The thumbrest."
- },
- {
- name = "touchpad",
- description = "The touchpad."
- },
- {
- name = "grip",
- description = "The grip button."
- },
- {
- name = "menu",
- description = "The menu button."
- },
- {
- name = "a",
- description = "The A button."
- },
- {
- name = "b",
- description = "The B button."
- },
- {
- name = "x",
- description = "The X button."
- },
- {
- name = "y",
- description = "The Y button."
- },
- {
- name = "nib",
- description = "The nib (tip) of the `stylus` device."
- }
- }
- },
- {
- name = "FoveationLevel",
- summary = "Different foveation levels.",
- description = "The different levels of foveation supported by `lovr.headset.setFoveation`.",
- key = "FoveationLevel",
- module = "lovr.headset",
- values = {
- {
- name = "low",
- description = "Low foveation."
- },
- {
- name = "medium",
- description = "Medium foveation."
- },
- {
- name = "high",
- description = "High foveation."
- }
- }
- },
- {
- name = "HeadsetDriver",
- summary = "VR APIs.",
- 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.",
- key = "HeadsetDriver",
- module = "lovr.headset",
- values = {
- {
- name = "simulator",
- description = "A VR simulator using keyboard/mouse."
- },
- {
- name = "openxr",
- description = "OpenXR."
- }
- }
- },
- {
- name = "HeadsetOrigin",
- summary = "Different types of coordinate space origins.",
- 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.",
- key = "HeadsetOrigin",
- module = "lovr.headset",
- values = {
- {
- name = "head",
- description = "The origin is at the head."
- },
- {
- name = "floor",
- description = "The origin is on the floor."
- }
- }
- },
- {
- name = "PassthroughMode",
- summary = "Passthrough modes.",
- 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`.",
- key = "PassthroughMode",
- module = "lovr.headset",
- related = {
- "lovr.headset.getPassthrough",
- "lovr.headset.setPassthrough",
- "lovr.headset.getPassthroughModes"
- },
- values = {
- {
- name = "opaque",
- description = "The headset display will not blend with anything behind it. Most VR headsets use this mode."
- },
- {
- name = "blend",
- 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."
- },
- {
- name = "add",
- 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."
- }
- }
- }
- },
- functions = {
- {
- name = "animate",
- tag = "controller-models",
- summary = "Animate a model to match its Device input state.",
- 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`.",
- key = "lovr.headset.animate",
- module = "lovr.headset",
- examples = {
- {
- 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"
- }
- },
- notes = "It's possible to animate a custom hand model by retargeting joint poses, see the `Interaction/Custom_Hand_Rig` example.",
- related = {
- "lovr.headset.newModel",
- "Model:animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "model",
- type = "Model",
- description = "The model to animate."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- 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`."
- }
- }
- },
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to use for the animation data.",
- default = "'head'"
- },
- {
- name = "model",
- type = "Model",
- description = "The model to animate."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- 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`."
- }
- },
- deprecated = true
- }
- }
- },
- {
- name = "getAngularVelocity",
- tag = "input",
- summary = "Get the angular velocity of a device.",
- description = "Returns the current angular velocity of a device.",
- key = "lovr.headset.getAngularVelocity",
- module = "lovr.headset",
- notes = "If the device isn't tracked, all zeroes will be returned.",
- related = {
- "lovr.headset.getVelocity",
- "lovr.headset.getPosition",
- "lovr.headset.getOrientation"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the velocity of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the angular velocity."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the angular velocity."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the angular velocity."
- }
- }
- }
- }
- },
- {
- name = "getAxis",
- tag = "input",
- summary = "Get the state of an analog axis on a device.",
- 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.",
- key = "lovr.headset.getAxis",
- module = "lovr.headset",
- 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.",
- related = {
- "DeviceAxis",
- "lovr.headset.isDown"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device."
- },
- {
- name = "axis",
- type = "DeviceAxis",
- description = "The axis."
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "The current state of the components of the axis, or `nil` if the device does not have any information about the axis."
- }
- }
- }
- }
- },
- {
- name = "getBoundsDepth",
- tag = "playArea",
- summary = "Get the depth of the play area.",
- description = "Returns the depth of the play area, in meters.",
- key = "lovr.headset.getBoundsDepth",
- module = "lovr.headset",
- related = {
- "lovr.headset.getBoundsWidth",
- "lovr.headset.getBoundsDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "depth",
- type = "number",
- description = "The depth of the play area, in meters."
- }
- }
- }
- }
- },
- {
- name = "getBoundsDimensions",
- tag = "playArea",
- summary = "Get the size of the play area.",
- description = "Returns the size of the play area, in meters.",
- key = "lovr.headset.getBoundsDimensions",
- module = "lovr.headset",
- related = {
- "lovr.headset.getBoundsWidth",
- "lovr.headset.getBoundsDepth",
- "lovr.headset.getBoundsGeometry"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the play area, in meters."
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the play area, in meters."
- }
- }
- }
- }
- },
- {
- name = "getBoundsGeometry",
- tag = "playArea",
- summary = "Get a list of points that make up the play area boundary.",
- 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.",
- key = "lovr.headset.getBoundsGeometry",
- module = "lovr.headset",
- related = {
- "lovr.headset.getBoundsDimensions"
- },
- variants = {
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table to fill with the points. If `nil`, a new table will be created.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "points",
- type = "table",
- description = "A flat table of 3D points representing the play area boundaries."
- }
- }
- }
- }
- },
- {
- name = "getBoundsWidth",
- tag = "playArea",
- summary = "Get the width of the play area.",
- description = "Returns the width of the play area, in meters.",
- key = "lovr.headset.getBoundsWidth",
- module = "lovr.headset",
- related = {
- "lovr.headset.getBoundsDepth",
- "lovr.headset.getBoundsDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the play area, in meters."
- }
- }
- }
- }
- },
- {
- name = "getClipDistance",
- tag = "headset",
- summary = "Get the near and far clipping planes of the headset.",
- 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.",
- key = "lovr.headset.getClipDistance",
- module = "lovr.headset",
- notes = "The default near and far clipping planes are 0.01 meters and 0.0 meters.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "near",
- type = "number",
- description = "The distance to the near clipping plane, in meters."
- },
- {
- name = "far",
- type = "number",
- description = "The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range."
- }
- }
- }
- }
- },
- {
- name = "getDeltaTime",
- tag = "headset-misc",
- summary = "Get the predicted delta time.",
- 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`.",
- key = "lovr.headset.getDeltaTime",
- module = "lovr.headset",
- related = {
- "lovr.headset.getTime",
- "lovr.timer.getTime",
- "lovr.timer.getDelta"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "dt",
- type = "number",
- description = "The delta time."
- }
- }
- }
- }
- },
- {
- name = "getDirection",
- tag = "input",
- summary = "Get the direction a device is pointing.",
- description = "Returns the direction a device is pointing. It will always be normalized.",
- key = "lovr.headset.getDirection",
- module = "lovr.headset",
- 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()`.",
- related = {
- "lovr.headset.getPose",
- "lovr.headset.getOrientation",
- "lovr.headset.getVelocity",
- "lovr.headset.getAngularVelocity",
- "lovr.headset.isTracked",
- "lovr.headset.getDriver"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the direction of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the direction."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the direction."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the direction."
- }
- }
- }
- }
- },
- {
- name = "getDisplayDimensions",
- tag = "headset",
- summary = "Get the dimensions of the headset display.",
- description = "Returns the texture dimensions of the headset display (for one eye), in pixels.",
- key = "lovr.headset.getDisplayDimensions",
- module = "lovr.headset",
- related = {
- "lovr.headset.getDisplayWidth",
- "lovr.headset.getDisplayHeight"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the display."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the display."
- }
- }
- }
- }
- },
- {
- name = "getDisplayFrequencies",
- tag = "headset",
- summary = "Get the list of refresh rates supported by the display.",
- description = "Returns a table with all the refresh rates supported by the headset display, in Hz.",
- key = "lovr.headset.getDisplayFrequencies",
- module = "lovr.headset",
- deprecated = true,
- related = {
- "lovr.headset.setDisplayFrequency"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequencies",
- type = "table",
- description = "A flat table of the refresh rates supported by the headset display, nil if not supported."
- }
- }
- }
- }
- },
- {
- name = "getDisplayFrequency",
- tag = "headset",
- summary = "Get the refresh rate of the display.",
- description = "Returns the refresh rate of the headset display, in Hz.",
- key = "lovr.headset.getDisplayFrequency",
- module = "lovr.headset",
- deprecated = true,
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the display, or `nil` if I have no idea what it is."
- }
- }
- }
- }
- },
- {
- name = "getDisplayHeight",
- tag = "headset",
- summary = "Get the height of the headset display.",
- description = "Returns the height of the headset display (for one eye), in pixels.",
- key = "lovr.headset.getDisplayHeight",
- module = "lovr.headset",
- related = {
- "lovr.headset.getDisplayWidth",
- "lovr.headset.getDisplayDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "height",
- type = "number",
- description = "The height of the display."
- }
- }
- }
- }
- },
- {
- name = "getDisplayWidth",
- tag = "headset",
- summary = "Get the width of the headset display.",
- description = "Returns the width of the headset display (for one eye), in pixels.",
- key = "lovr.headset.getDisplayWidth",
- module = "lovr.headset",
- related = {
- "lovr.headset.getDisplayHeight",
- "lovr.headset.getDisplayDimensions"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the display."
- }
- }
- }
- }
- },
- {
- name = "getDriver",
- tag = "headset-misc",
- summary = "Get the VR API currently in use for a device.",
- 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`.",
- key = "lovr.headset.getDriver",
- module = "lovr.headset",
- related = {
- "lovr.headset.getName"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "driver",
- type = "HeadsetDriver",
- description = "The current headset backend, e.g. `openxr` or `simulator`."
- },
- {
- name = "runtime",
- type = "string",
- description = "The name of the VR runtime, e.g. `SteamVR/OpenXR`."
- }
- }
- }
- }
- },
- {
- name = "getFeatures",
- tag = "headset-misc",
- summary = "Get the supported headset features.",
- description = "Returns a table of features that are supported by the current headset runtime.",
- key = "lovr.headset.getFeatures",
- module = "lovr.headset",
- related = {
- "lovr.headset.getName"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "features",
- type = "table",
- description = "",
- table = {
- {
- name = "overlay",
- type = "boolean",
- description = "Whether LÖVR is able to run as an overlay on top of other VR applications. When unsupported, the `t.headset.overlay` option in `lovr.conf` will be ignored. Currently this will also be false if `t.headset.overlay` is false."
- },
- {
- name = "proximity",
- type = "boolean",
- description = "Whether the headset provides access to its proximity sensor. When unsupported, `lovr.headset.isMounted` will always return true and `lovr.mount` will never be called."
- },
- {
- name = "passthrough",
- type = "boolean",
- description = "Whether the headset supports one of the non-opaque passthrough modes. When unsupported, `lovr.headset.getPassthroughModes` will only return 'opaque'."
- },
- {
- name = "refreshRate",
- type = "boolean",
- description = "Whether the headset display supports querying and changing the refresh rate. When unsupported, `lovr.headset.getRefreshRate` will always return nil and `lovr.headset.setRefreshRate` will always return false."
- },
- {
- name = "depthSubmission",
- type = "boolean",
- description = "Whether `t.headset.submitdepth` in `lovr.conf` is active and supported."
- },
- {
- name = "eyeTracking",
- type = "boolean",
- description = "Whether the headset supports eye gaze tracking. When unsupported, the `eye/*` devices will always be untracked."
- },
- {
- name = "handTracking",
- type = "boolean",
- description = "Whether hand tracking is supported. When false, `lovr.headset.getSkeleton` will always return nil."
- },
- {
- name = "handTrackingElbow",
- type = "boolean",
- description = "Whether the hand tracker is able to return data for the `elbow/*` devices."
- },
- {
- name = "keyboardTracking",
- type = "boolean",
- description = "Whether the system supports tracked keyboards for the `keyboard` device."
- },
- {
- name = "viveTrackers",
- type = "boolean",
- description = "Whether the system supports Vive trackers."
- },
- {
- name = "handModel",
- type = "boolean",
- description = "Whether `lovr.headset.newModel` is able to load models for the user\\'s hands."
- },
- {
- name = "controllerModel",
- type = "boolean",
- description = "Whether `lovr.headset.newModel` supports loading controller models."
- },
- {
- name = "controllerSkeleton",
- type = "boolean",
- description = "Whether the `t.headset.controllerskeleton` option in `lovr.conf` is supported and whether the `controller` key in the `lovr.headset.getSkeleton` table is supported. When this is false, it is not possible to determine whether hand tracking data is coming from the user's actual hands or if it's estimated from controller button inputs."
- },
- {
- name = "cubeBackground",
- type = "boolean",
- description = "Whether `lovr.headset.setBackground` supports cubemap textures."
- },
- {
- name = "equirectBackground",
- type = "boolean",
- description = "Whether `lovr.headset.setBackground` supports equirectangular textures."
- },
- {
- name = "layerColor",
- type = "boolean",
- description = "Whether `Layer:setColor` is supported."
- },
- {
- name = "layerCurve",
- type = "boolean",
- description = "Whether `Layer:setCurve` is supported."
- },
- {
- name = "layerDepthTest",
- type = "boolean",
- description = "Whether Layers are able to depth sort with the rest of the 3D scene, and with each other. When unsupported, layers will always render on top of the 3D scene and any layers that come before them in the layer list."
- },
- {
- name = "layerFilter",
- type = "boolean",
- description = "Whether the `filter` option is supported for Layers."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getFoveation",
- tag = "headset",
- summary = "Get the current foveation settings.",
- description = "Returns the current foveation settings, previously set by `lovr.headset.setFoveation`.'",
- key = "lovr.headset.getFoveation",
- module = "lovr.headset",
- notes = "Foveation is disabled by default.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "level",
- type = "FoveationLevel",
- description = "The foveation level (or the maximum level when dynamic foveation is active)."
- },
- {
- name = "dynamic",
- type = "boolean",
- description = "Whether dynamic foveation is active, allowing the system to reduce foveation based on GPU load."
- }
- }
- }
- }
- },
- {
- name = "getHandles",
- tag = "headset-misc",
- summary = "Get native pointers to OpenXR objects.",
- description = "Returns pointers to the OpenXR instance and session objects.\n\nThis can be used with FFI or other native plugins to integrate with other OpenXR code.",
- key = "lovr.headset.getHandles",
- module = "lovr.headset",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "instance",
- type = "lightuserdata",
- description = "The OpenXR instance handle (`XrInstance`)."
- },
- {
- name = "session",
- type = "lightuserdata",
- description = "The OpenXR session handle (`XrSession`)."
- }
- }
- }
- }
- },
- {
- name = "getHands",
- tag = "input",
- summary = "Get a list of currently tracked hand devices.",
- description = "Returns a table with all of the currently tracked hand devices.",
- key = "lovr.headset.getHands",
- module = "lovr.headset",
- examples = {
- {
- 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"
- }
- },
- notes = "The hand paths will *always* be either `hand/left` or `hand/right`.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "hands",
- type = "table",
- description = "The currently tracked hand devices.",
- arguments = {},
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "getLayers",
- tag = "layers",
- summary = "Get the list of active layers.",
- description = "Returns the list of active `Layer` objects. These are the layers that will be rendered in the headset's display. They are rendered in order.",
- key = "lovr.headset.getLayers",
- module = "lovr.headset",
- notes = "Currently some VR systems are able to sort the layers by their Z depth, but on others layers later in the list will render on top of previous layers, regardless of depth.\n\nThere is currently a maximum of 10 layers.",
- related = {
- "lovr.headset.newLayer",
- "Layer"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "layers",
- type = "table",
- description = "The list of layers."
- }
- }
- }
- }
- },
- {
- name = "getName",
- tag = "headset-misc",
- summary = "Get the name of the connected headset display.",
- 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.",
- key = "lovr.headset.getName",
- module = "lovr.headset",
- notes = "When headset simulator is used this function returns `nil`.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "name",
- type = "string",
- description = "The name of the headset as a string."
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- tag = "input",
- summary = "Get the orientation of a device.",
- description = "Returns the current orientation of a device, in angle/axis form.",
- key = "lovr.headset.getOrientation",
- module = "lovr.headset",
- notes = "If the device isn't tracked, all zeroes will be returned.",
- related = {
- "lovr.headset.getPose",
- "lovr.headset.getPosition",
- "lovr.headset.getDirection",
- "lovr.headset.getVelocity",
- "lovr.headset.getAngularVelocity",
- "lovr.headset.isTracked",
- "lovr.headset.getDriver"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the orientation of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the axis of rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getOriginType",
- tag = "playArea",
- summary = "Get the type of tracking origin of the headset.",
- description = "Returns the type of origin used for the tracking volume. The different types of origins are explained on the `HeadsetOrigin` page.",
- key = "lovr.headset.getOriginType",
- module = "lovr.headset",
- deprecated = true,
- related = {
- "HeadsetOrigin"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "origin",
- type = "HeadsetOrigin",
- description = "The type of origin."
- }
- }
- }
- }
- },
- {
- name = "getPass",
- tag = "headset-misc",
- summary = "Get a Pass that renders to the headset.",
- description = "Returns a `Pass` that renders to the headset display.",
- key = "lovr.headset.getPass",
- module = "lovr.headset",
- 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.",
- related = {
- "lovr.graphics.newPass",
- "lovr.graphics.getWindowPass",
- "lovr.conf"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The pass."
- }
- }
- }
- }
- },
- {
- name = "getPassthrough",
- tag = "headset",
- summary = "Get the current passthrough mode.",
- description = "Returns the current passthrough mode.",
- key = "lovr.headset.getPassthrough",
- module = "lovr.headset",
- related = {
- "lovr.headset.getPassthroughModes"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mode",
- type = "PassthroughMode",
- description = "The current passthrough mode."
- }
- }
- }
- }
- },
- {
- name = "getPassthroughModes",
- tag = "headset",
- summary = "Get the supported passthrough modes.",
- description = "Returns the set of supported passthrough modes.",
- key = "lovr.headset.getPassthroughModes",
- module = "lovr.headset",
- related = {
- "lovr.headset.getPassthrough",
- "lovr.headset.setPassthrough"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "modes",
- type = "table",
- description = "The set of supported passthrough modes. Keys will be `PassthroughMode` strings, and values will be booleans indicating whether the mode is supported."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- tag = "input",
- summary = "Get the pose of a device.",
- description = "Returns the current position and orientation of a device.",
- key = "lovr.headset.getPose",
- module = "lovr.headset",
- notes = "Units are in meters.\n\nIf the device isn't tracked, all zeroes will be returned.",
- related = {
- "lovr.headset.getPosition",
- "lovr.headset.getOrientation",
- "lovr.headset.getVelocity",
- "lovr.headset.getAngularVelocity",
- "lovr.headset.getSkeleton",
- "lovr.headset.isTracked",
- "lovr.headset.getDriver"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the pose of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position."
- },
- {
- name = "y",
- type = "number",
- description = "The y position."
- },
- {
- name = "z",
- type = "number",
- description = "The z position."
- },
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the axis of rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- tag = "input",
- summary = "Get the position of a device.",
- description = "Returns the current position of a device, in meters, relative to the play area.",
- key = "lovr.headset.getPosition",
- module = "lovr.headset",
- notes = "If the device isn't tracked, all zeroes will be returned.",
- related = {
- "lovr.headset.getPose",
- "lovr.headset.getOrientation",
- "lovr.headset.getVelocity",
- "lovr.headset.getAngularVelocity",
- "lovr.headset.isTracked",
- "lovr.headset.getDriver"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the position of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the device."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the device."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the device."
- }
- }
- }
- }
- },
- {
- name = "getRefreshRate",
- tag = "headset",
- summary = "Get the refresh rate of the headset display.",
- description = "Returns the refresh rate of the headset display, in Hz.",
- key = "lovr.headset.getRefreshRate",
- module = "lovr.headset",
- related = {
- "lovr.headset.getRefreshRates"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "rate",
- type = "number",
- description = "The refresh rate of the display, or `nil` if I have no idea what it is."
- }
- }
- }
- }
- },
- {
- name = "getRefreshRates",
- tag = "headset",
- summary = "Get the list of refresh rates supported by the display.",
- description = "Returns a table with all the refresh rates supported by the headset display, in Hz.",
- key = "lovr.headset.getRefreshRates",
- module = "lovr.headset",
- related = {
- "lovr.headset.getRefreshRate",
- "lovr.headset.setRefreshRate"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "rates",
- type = "table",
- description = "A flat table of the refresh rates supported by the headset display, or nil if not supported."
- }
- }
- }
- }
- },
- {
- name = "getSkeleton",
- tag = "input",
- summary = "Get skeletal joint transforms tracked by a device.",
- description = "Returns a list of joint transforms tracked by a device. Currently, only hand devices are able to track joints.",
- key = "lovr.headset.getSkeleton",
- module = "lovr.headset",
- examples = {
- {
- 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"
- }
- },
- notes = "If the Device does not support tracking joints or the transforms are unavailable, this function returns `nil`.\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\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>",
- related = {
- "lovr.headset.getPose",
- "lovr.headset.animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The hand device to query (`left` or `right`)."
- }
- },
- returns = {
- {
- name = "transforms",
- type = "table",
- 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."
- }
- }
- },
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The hand device to query (`left` or `right`)."
- },
- {
- name = "t",
- type = "table",
- description = "A table to fill with the joint transforms, instead of allocating a new one."
- }
- },
- returns = {
- {
- name = "transforms",
- type = "table",
- 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."
- }
- }
- }
- }
- },
- {
- name = "getTexture",
- tag = "headset-misc",
- summary = "Get the Texture for the headset display.",
- 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.",
- key = "lovr.headset.getTexture",
- module = "lovr.headset",
- notes = "This function may return `nil` if the headset is not being rendered to this frame.",
- related = {
- "lovr.headset.getPass",
- "lovr.mirror"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The headset texture."
- }
- }
- }
- }
- },
- {
- name = "getTime",
- tag = "headset-misc",
- summary = "Get the predicted display time.",
- 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.",
- key = "lovr.headset.getTime",
- module = "lovr.headset",
- notes = "This has a different epoch than `lovr.timer.getTime`, so it is not guaranteed to be close to that value.",
- related = {
- "lovr.headset.getDeltaTime",
- "lovr.timer.getTime"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "time",
- type = "number",
- description = "The predicted display time, in seconds."
- }
- }
- }
- }
- },
- {
- name = "getVelocity",
- tag = "input",
- summary = "Get the linear velocity of a device.",
- description = "Returns the current linear velocity of a device, in meters per second.",
- key = "lovr.headset.getVelocity",
- module = "lovr.headset",
- notes = "If the device isn't tracked, all zeroes will be returned.",
- related = {
- "lovr.headset.getAngularVelocity",
- "lovr.headset.getPose",
- "lovr.headset.getPosition",
- "lovr.headset.getOrientation"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the velocity of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x component of the linear velocity."
- },
- {
- name = "vy",
- type = "number",
- description = "The y component of the linear velocity."
- },
- {
- name = "vz",
- type = "number",
- description = "The z component of the linear velocity."
- }
- }
- }
- }
- },
- {
- name = "getViewAngles",
- tag = "headset",
- summary = "Get the field of view angles of a view.",
- 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.",
- key = "lovr.headset.getViewAngles",
- module = "lovr.headset",
- related = {
- "lovr.headset.getViewCount",
- "lovr.headset.getViewPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The view index."
- }
- },
- returns = {
- {
- name = "left",
- type = "number",
- description = "The left view angle, in radians."
- },
- {
- name = "right",
- type = "number",
- description = "The right view angle, in radians."
- },
- {
- name = "top",
- type = "number",
- description = "The top view angle, in radians."
- },
- {
- name = "bottom",
- type = "number",
- description = "The bottom view angle, in radians."
- }
- }
- }
- }
- },
- {
- name = "getViewCount",
- tag = "headset",
- summary = "Get the number of views used for rendering.",
- 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.",
- key = "lovr.headset.getViewCount",
- module = "lovr.headset",
- related = {
- "lovr.headset.getViewPose",
- "lovr.headset.getViewAngles"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of views."
- }
- }
- }
- }
- },
- {
- name = "getViewPose",
- tag = "headset",
- summary = "Get the pose of one of the views.",
- 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.",
- key = "lovr.headset.getViewPose",
- module = "lovr.headset",
- related = {
- "lovr.headset.getViewCount",
- "lovr.headset.getViewAngles"
- },
- variants = {
- {
- arguments = {
- {
- name = "view",
- type = "number",
- description = "The view index."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the view position, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the view position, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the view position, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the rotation axis, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "isActive",
- tag = "headset-misc",
- summary = "Check if the headset session is active.",
- description = "Returns whether a headset session is active. When true, there is an active connection to the VR hardware. When false, most headset methods will not work properly until `lovr.headset.start` is used to start a session.",
- key = "lovr.headset.isActive",
- module = "lovr.headset",
- related = {
- "lovr.headset.start",
- "lovr.headset.stop"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "active",
- type = "boolean",
- description = "Whether the headset session is active."
- }
- }
- }
- }
- },
- {
- name = "isDown",
- tag = "input",
- summary = "Get the state of a button on a device.",
- description = "Returns whether a button on a device is pressed.",
- key = "lovr.headset.isDown",
- module = "lovr.headset",
- notes = "When hand tracking is active, pinching will be mapped to the `trigger` button.",
- related = {
- "DeviceButton",
- "lovr.headset.wasPressed",
- "lovr.headset.wasReleased",
- "lovr.headset.isTouched",
- "lovr.headset.getAxis"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device."
- },
- {
- name = "button",
- type = "DeviceButton",
- description = "The button."
- }
- },
- returns = {
- {
- name = "down",
- type = "boolean",
- description = "Whether the button on the device is currently pressed, or `nil` if the device does not have the specified button."
- }
- }
- }
- }
- },
- {
- name = "isFocused",
- tag = "headset-misc",
- summary = "Check if LÖVR has VR input focus.",
- 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.",
- key = "lovr.headset.isFocused",
- module = "lovr.headset",
- related = {
- "lovr.focus"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "focused",
- type = "boolean",
- description = "Whether the application is focused."
- }
- }
- }
- }
- },
- {
- name = "isMounted",
- tag = "headset-misc",
- summary = "Check if the headset is \"mounted\" (worn on a head).",
- description = "Returns whether the headset is mounted. Usually this uses a proximity sensor on the headset to detect whether someone is wearing the headset.",
- key = "lovr.headset.isMounted",
- module = "lovr.headset",
- related = {
- "lovr.mount",
- "lovr.headset.isFocused",
- "lovr.headset.isVisible"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mounted",
- type = "boolean",
- description = "Whether the headset is mounted."
- }
- }
- }
- }
- },
- {
- name = "isSeated",
- tag = "playArea",
- summary = "Check if the coordinate space is standing or seated.",
- 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.",
- key = "lovr.headset.isSeated",
- module = "lovr.headset",
- related = {
- "lovr.conf",
- "lovr.recenter"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "seated",
- type = "boolean",
- description = "Whether the experience is seated."
- }
- }
- }
- }
- },
- {
- name = "isTouched",
- tag = "input",
- summary = "Check if a button on a device is touched.",
- description = "Returns whether a button on a device is currently touched.",
- key = "lovr.headset.isTouched",
- module = "lovr.headset",
- related = {
- "DeviceButton",
- "lovr.headset.isDown",
- "lovr.headset.getAxis"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device."
- },
- {
- name = "button",
- type = "DeviceButton",
- description = "The button."
- }
- },
- returns = {
- {
- name = "touched",
- type = "boolean",
- 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."
- }
- }
- }
- }
- },
- {
- name = "isTracked",
- tag = "input",
- summary = "Check if a device is currently tracked.",
- description = "Returns whether any active headset driver is currently returning pose information for a device.",
- key = "lovr.headset.isTracked",
- module = "lovr.headset",
- notes = "If a device is tracked, it is guaranteed to return a valid pose until the next call to `lovr.headset.update`.",
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to get the pose of.",
- default = "'head'"
- }
- },
- returns = {
- {
- name = "tracked",
- type = "boolean",
- description = "Whether the device is currently tracked."
- }
- }
- }
- }
- },
- {
- name = "isVisible",
- tag = "headset-misc",
- summary = "Check if content is being shown in the headset display.",
- 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.",
- key = "lovr.headset.isVisible",
- module = "lovr.headset",
- 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`.",
- related = {
- "lovr.visible",
- "lovr.headset.isFocused",
- "lovr.focus"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "visible",
- type = "boolean",
- description = "Whether the application is visible."
- }
- }
- }
- }
- },
- {
- name = "newLayer",
- tag = "layers",
- summary = "Create a new Layer.",
- description = "Creates a new `Layer`.",
- key = "lovr.headset.newLayer",
- module = "lovr.headset",
- related = {
- "lovr.headset.getLayers",
- "lovr.headset.setLayers"
- },
- variants = {
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the Layer texture, in pixels."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the Layer texture, in pixels."
- }
- },
- returns = {
- {
- name = "layer",
- type = "Layer",
- description = "The new Layer."
- }
- }
- }
- }
- },
- {
- name = "newModel",
- tag = "controller-models",
- summary = "Get a Model for a device.",
- description = "Returns a new Model for the specified device.",
- key = "lovr.headset.newModel",
- module = "lovr.headset",
- examples = {
- {
- 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"
- }
- },
- notes = "Currently this is only implemented for hand models on the Oculus Quest.",
- related = {
- "lovr.headset.animate"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to load a model for.",
- default = "'head'"
- },
- {
- name = "options",
- type = "table",
- description = "Options for loading the model.",
- default = "{}",
- table = {
- {
- name = "animated",
- type = "boolean",
- description = "Whether an animatable model should be loaded, for use with `lovr.headset.animate`.",
- default = "false"
- }
- }
- }
- },
- returns = {
- {
- name = "model",
- type = "Model",
- description = "The new Model, or `nil` if a model could not be loaded."
- }
- }
- }
- }
- },
- {
- name = "setBackground",
- tag = "layers",
- summary = "Set the background layer.",
- description = "Sets a background layer. This will render behind any transparent pixels in the main 3D content. It works similarly to other `Layer` objects, but using a cubemap or equirectangular texture.\n\nThe background texture is sent to the VR runtime once, and the runtime is responsible for compositing it behind the rest of the scene. This can improve performance greatly, since the background doesn't need to be re-rendered every frame. It also ensures the background remains tracked smoothly even if LÖVR is struggling to render at a high frame rate.",
- key = "lovr.headset.setBackground",
- module = "lovr.headset",
- notes = "There is no `lovr.headset.getBackground` because LÖVR does not store the Image or Texture after setting it as a background, to save memory.",
- related = {
- "Layer",
- "Pass:skybox"
- },
- variants = {
- {
- arguments = {
- {
- name = "texture",
- type = "Texture",
- description = "The Texture to use for the background. It can be a `cube` texture which will be rendered as a cubemap, or a `2d` texture interpreted as equirectangular (sometimes called panoramic or spherical) coordinates.\n\nThe texture can have any color format, but it will be converted to `rgba8` before getting copied to the VR runtime."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "image",
- type = "Image",
- description = "The Image to use for the background. It can have 1 layer for an equirectangular background, or 6 layers for a cubemap. Currently, it must have a format of `rgba8`."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "images",
- type = "table",
- description = "A table of 1 or 6 images to use for the background. They must be the same size and they currently must use the `rgba8` format."
- }
- },
- returns = {}
- },
- {
- description = "Disables any previously set background.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setClipDistance",
- tag = "headset",
- summary = "Set the near and far clipping planes of the headset.",
- 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.",
- key = "lovr.headset.setClipDistance",
- module = "lovr.headset",
- notes = "The default clip distances are 0.01 and 0.0.",
- variants = {
- {
- arguments = {
- {
- name = "near",
- type = "number",
- description = "The distance to the near clipping plane, in meters."
- },
- {
- name = "far",
- type = "number",
- description = "The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDisplayFrequency",
- tag = "headset",
- summary = "Set the display refresh rate.",
- description = "Sets the display refresh rate, in Hz.",
- key = "lovr.headset.setDisplayFrequency",
- module = "lovr.headset",
- deprecated = true,
- notes = "Changing the display refresh-rate also changes the frequency of lovr.update() and lovr.draw() as they depend on the display frequency.",
- variants = {
- {
- arguments = {
- {
- name = "frequency",
- type = "number",
- description = "The new refresh rate, in Hz."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the display refresh rate was successfully set."
- }
- }
- }
- }
- },
- {
- name = "setFoveation",
- tag = "headset",
- summary = "Set foveated rendering settings.",
- description = "Sets foveated rendering settings. Currently only fixed foveated rendering is supported. This renders the edges of the screen at a lower resolution to improve GPU performance. Higher foveation levels will save more GPU time, but make the edges of the screen more blocky.",
- key = "lovr.headset.setFoveation",
- module = "lovr.headset",
- notes = "Foveation is disabled by default.",
- variants = {
- {
- arguments = {
- {
- name = "level",
- type = "FoveationLevel",
- description = "The foveation level (or the maximum level when dynamic foveation is active)."
- },
- {
- name = "dynamic",
- type = "boolean",
- description = "Whether the system is allowed to dynamically adjust the foveation level based on GPU load.",
- default = "true"
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether foveation was enabled successfully."
- }
- }
- },
- {
- description = "Disables foveation.",
- arguments = {},
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether foveation was enabled successfully."
- }
- }
- }
- }
- },
- {
- name = "setLayers",
- tag = "layers",
- summary = "Set the list of active layers.",
- description = "Sets the list of active `Layer` objects. These are the layers that will be rendered in the headset's display. They are rendered in order.",
- key = "lovr.headset.setLayers",
- module = "lovr.headset",
- notes = "Currently some VR systems are able to sort the layers by their Z depth, but on others layers later in the list will render on top of previous layers, regardless of depth.\n\nThere is currently a maximum of 10 layers.",
- related = {
- "lovr.headset.newLayer",
- "Layer"
- },
- variants = {
- {
- arguments = {
- {
- name = "...layers",
- type = "Layer",
- description = "Zero or more layers to render in the headset."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table with zero or more layers starting at index 1."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPassthrough",
- tag = "headset",
- summary = "Change current passthrough mode.",
- description = "Sets a new passthrough mode. Not all headsets support all passthrough modes. Use `lovr.headset.getPassthroughModes` to see which modes are supported.",
- key = "lovr.headset.setPassthrough",
- module = "lovr.headset",
- 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.\n\nQuest Link currently requires some extra steps to enable passthrough, see [this article](https://developers.meta.com/horizon/documentation/native/android/mobile-passthrough-over-link) for details.",
- related = {
- "lovr.headset.getPassthroughModes"
- },
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "PassthroughMode",
- description = "The passthrough mode to request."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the passthrough mode was supported and successfully enabled."
- }
- }
- },
- {
- arguments = {
- {
- name = "transparent",
- type = "boolean",
- 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."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the passthrough mode was supported and successfully enabled."
- }
- }
- },
- {
- description = "Switch to the headset's default passthrough mode.",
- arguments = {},
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the passthrough mode was supported and successfully enabled."
- }
- }
- }
- }
- },
- {
- name = "setRefreshRate",
- tag = "headset",
- summary = "Set the display refresh rate.",
- description = "Sets the display refresh rate, in Hz.",
- key = "lovr.headset.setRefreshRate",
- module = "lovr.headset",
- 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.",
- related = {
- "lovr.headset.getRefreshRates"
- },
- variants = {
- {
- arguments = {
- {
- name = "rate",
- type = "number",
- description = "The new refresh rate, in Hz."
- }
- },
- returns = {
- {
- name = "success",
- type = "boolean",
- description = "Whether the display refresh rate was successfully set."
- }
- }
- }
- }
- },
- {
- name = "start",
- tag = "headset-misc",
- summary = "Starts the headset session.",
- description = "Starts the headset session. This must be called after the graphics module is initialized. Normally it is called automatically by `boot.lua`, but this can be disabled by setting `t.headset.start` to false in `lovr.conf`.",
- key = "lovr.headset.start",
- module = "lovr.headset",
- related = {
- "lovr.headset.stop",
- "lovr.headset.isActive"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "stop",
- tag = "headset-misc",
- summary = "Stop the headset session.",
- description = "Stops the headset session. This tears down the connection to the VR runtime and hardware. `lovr.draw` will instead start rendering to the desktop window, as though the headset module was disabled. However, certain information about the headset can still be queried, such as its name, supported passthrough modes, display size, etc. A headset session can be started later using `lovr.headset.start`.",
- key = "lovr.headset.stop",
- module = "lovr.headset",
- notes = "The headset module behaves in the following manner when there is no headset session:\n\n- `lovr.headset.isActive` returns `false`.\n- `lovr.headset.getPass` returns `nil`.\n- All devices will be untracked.",
- related = {
- "lovr.headset.start",
- "lovr.headset.isActive"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "stopVibration",
- tag = "input",
- summary = "Stop vibration on a device.",
- description = "Causes the device to stop any active haptics vibration.",
- key = "lovr.headset.stopVibration",
- module = "lovr.headset",
- related = {
- "lovr.headset.vibrate"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to stop the vibration on.",
- default = "'head'"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "submit",
- tag = "headset-misc",
- summary = "Submit a frame to the headset display.",
- 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`.",
- key = "lovr.headset.submit",
- module = "lovr.headset",
- related = {
- "lovr.headset.getPass",
- "lovr.headset.getTexture"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "update",
- tag = "headset-misc",
- summary = "Update the headset module.",
- description = "Updates the headset module, blocking until it is time to start a new frame and polling new input states. This should only be called once at the beginning of a frame, and is normally taken care of by the default `lovr.run` implementation.",
- key = "lovr.headset.update",
- module = "lovr.headset",
- related = {
- "lovr.headset.submit"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "vibrate",
- tag = "input",
- summary = "Make a device go BZZZ!",
- description = "Causes the device to vibrate with a custom strength, duration, and frequency, if possible.",
- key = "lovr.headset.vibrate",
- module = "lovr.headset",
- related = {
- "lovr.headset.stopVibration"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device to vibrate.",
- default = "'head'"
- },
- {
- name = "strength",
- type = "number",
- description = "The strength of the vibration (amplitude), between 0 and 1.",
- default = "1"
- },
- {
- name = "duration",
- type = "number",
- description = "The duration of the vibration, in seconds.",
- default = ".5"
- },
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the vibration, in hertz. 0 will use a default frequency.",
- default = "0"
- }
- },
- returns = {
- {
- name = "vibrated",
- type = "boolean",
- description = "Whether the vibration was successfully triggered by an active headset driver."
- }
- }
- }
- }
- },
- {
- name = "wasPressed",
- tag = "input",
- summary = "Check if a button was just pressed.",
- description = "Returns whether a button on a device was pressed this frame.",
- key = "lovr.headset.wasPressed",
- module = "lovr.headset",
- 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.",
- related = {
- "DeviceButton",
- "lovr.headset.isDown",
- "lovr.headset.wasReleased",
- "lovr.headset.isTouched",
- "lovr.headset.getAxis"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device."
- },
- {
- name = "button",
- type = "DeviceButton",
- description = "The button to check."
- }
- },
- returns = {
- {
- name = "pressed",
- type = "boolean",
- description = "Whether the button on the device was pressed this frame."
- }
- }
- }
- }
- },
- {
- name = "wasReleased",
- tag = "input",
- summary = "Check if a button was just released.",
- description = "Returns whether a button on a device was released this frame.",
- key = "lovr.headset.wasReleased",
- module = "lovr.headset",
- 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.",
- related = {
- "DeviceButton",
- "lovr.headset.isDown",
- "lovr.headset.wasPressed",
- "lovr.headset.isTouched",
- "lovr.headset.getAxis"
- },
- variants = {
- {
- arguments = {
- {
- name = "device",
- type = "Device",
- description = "The device."
- },
- {
- name = "button",
- type = "DeviceButton",
- description = "The button to check."
- }
- },
- returns = {
- {
- name = "released",
- type = "boolean",
- description = "Whether the button on the device was released this frame."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "Layer",
- summary = "A quad in 3D space.",
- description = "A Layer is a textured plane placed in 3D space. Layers are sent directly to the VR runtime and composited along with the rest of the 3D content. This has several advantages compared to rendering the texture into the 3D scene with `Pass:draw`:\n\n- Better tracking. The VR runtime composites the texture later in the rendering process, using a more accurate head pose.\n- Better resolution, less shimmery. Regular 3D content must have lens distortion correction\n applied to it, whereas layers are composited after distortion correction, meaning they have a\n higher pixel density. The layer can also use a higher resolution than the main headset\n texture, allowing for extra resolution on the 2D content without having to supersample all of\n the 3D rendering.\n- Supersampling and sharpening effects. Some headset runtimes (currently just Quest) can also\n supersample and sharpen layers.\n\nCombined, all of this makes a massive difference in quality when rendering 2D content on a Layer, especially improving text readability.\n\nNote that currently the VR simulator does not support layers.",
- key = "Layer",
- module = "lovr.headset",
- constructors = {
- "lovr.headset.newLayer"
- },
- methods = {
- {
- name = "getColor",
- summary = "Get the color of the layer.",
- description = "Returns the color of the layer. This will tint the contents of its texture. It can be used to fade the layer without re-rendering its texture, which is especially useful for layers created with the `static` option.",
- key = "Layer:getColor",
- module = "lovr.headset",
- notes = "The default color is white (all 1s).\n\nNot every headset system supports layer colors. See the `layerColor` property of `lovr.headset.getFeatures` to check for support.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "r",
- type = "number",
- description = "The red component of the color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the color."
- }
- }
- }
- }
- },
- {
- name = "getCurve",
- summary = "Get the curve of the layer.",
- description = "Returns the curve of the layer. Curving a layer renders it on a piece of a cylinder instead of a plane. The radius of the cylinder is `1 / curve` meters, so increasing the curve decreases the radius of the cylinder.",
- key = "Layer:getCurve",
- module = "lovr.headset",
- notes = "When a layer is created, its curve is zero.\n\nNot every headset system supports curved layers. See the `layerCurve` property of `lovr.headset.getFeatures` to check for support.\n\nNo matter what the curve is, the center of the layer texture will always get rendered at the layer's pose.\n\nThe largest possible curve is `2 * math.pi / width`, where `width` is the width of the layer in meters. This would cause the cylinder to fully wrap around.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "curve",
- type = "number",
- description = "The curve of the layer."
- }
- }
- }
- }
- },
- {
- name = "getDimensions",
- summary = "Get the size of the layer.",
- description = "Returns the width and height of the layer. This is the size of the Layer's plane in meters, not the resolution of the layer's texture in pixels.",
- key = "Layer:getDimensions",
- module = "lovr.headset",
- notes = "When a layer is created, its width and height are 1 meter.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the layer, in meters."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the layer, in meters."
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- summary = "Get the orientation of the layer.",
- description = "Returns the orientation of the layer.",
- key = "Layer:getOrientation",
- module = "lovr.headset",
- related = {
- "Layer:getPosition",
- "Layer:setPosition",
- "Layer:getPose",
- "Layer:setPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the axis of rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPass",
- summary = "Get the render pass for the layer.",
- description = "Returns the render pass for the layer. This can be used to render to the layer.",
- key = "Layer:getPass",
- module = "lovr.headset",
- notes = "This function will reset the Layer's render pass when it is called, as though `Pass:reset` was called.\n\nThe Pass will have its background color cleared to the background color, set using `lovr.graphics.setBackgroundColor`.\n\nThe Pass will have its view matrix set to the origin, and its projection will be set to an orthographic matrix where the top left of the texture is at the origin and the bottom right of the texture will be at `(width, height)` in pixels.",
- related = {
- "Layer:getTexture"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "pass",
- type = "Pass",
- description = "The layer's render pass."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- summary = "Get the pose of the layer.",
- description = "Returns the position and orientation of the layer.",
- key = "Layer:getPose",
- module = "lovr.headset",
- notes = "Units are in meters.",
- related = {
- "Layer:getPosition",
- "Layer:setPosition",
- "Layer:getOrientation",
- "Layer:setOrientation"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position."
- },
- {
- name = "y",
- type = "number",
- description = "The y position."
- },
- {
- name = "z",
- type = "number",
- description = "The z position."
- },
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the axis of rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- summary = "Get the position of the layer.",
- description = "Returns the position of the layer, in meters.",
- key = "Layer:getPosition",
- module = "lovr.headset",
- related = {
- "Layer:getOrientation",
- "Layer:setOrientation",
- "Layer:getPose",
- "Layer:setPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the layer."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the layer."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the layer."
- }
- }
- }
- }
- },
- {
- name = "getTexture",
- summary = "Get the texture for the layer.",
- description = "Returns the texture for the layer. This is the texture that will be pasted onto the layer.",
- key = "Layer:getTexture",
- module = "lovr.headset",
- notes = "This function may return a different `Texture` object each frame. The return value should not be cached.\n\nThe texture will have the `rgba8` format, with `sample` and `render` usage flags.",
- related = {
- "Layer:getPass"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "texture",
- type = "Texture",
- description = "The layer's texture."
- }
- }
- }
- }
- },
- {
- name = "getViewport",
- summary = "Get the viewport of the layer.",
- description = "Returns the viewport of the layer. The viewport is a 2D region of pixels that the layer will display within its plane.",
- key = "Layer:getViewport",
- module = "lovr.headset",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the upper-left corner of the viewport."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the upper-left corner of the viewport."
- },
- {
- name = "w",
- type = "number",
- description = "The width of the viewport, in pixels."
- },
- {
- name = "h",
- type = "number",
- description = "The height of the viewport, in pixels."
- }
- }
- }
- }
- },
- {
- name = "setColor",
- summary = "Set the color of the layer.",
- description = "Sets the color of the layer. This will tint the contents of its texture. It can be used to fade the layer without re-rendering its texture, which is especially useful for layers created with the `static` option.",
- key = "Layer:setColor",
- module = "lovr.headset",
- notes = "The default color is white (all 1s).\n\nNot every headset system supports layer colors. See the `layerColor` property of `lovr.headset.getFeatures` to check for support.",
- variants = {
- {
- arguments = {
- {
- name = "r",
- type = "number",
- description = "The red component of the color."
- },
- {
- name = "g",
- type = "number",
- description = "The green component of the color."
- },
- {
- name = "b",
- type = "number",
- description = "The blue component of the color."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the color.",
- default = "1.0"
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "t",
- type = "table",
- description = "A table of 3 or 4 color components."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "hex",
- type = "number",
- description = "A hexcode."
- },
- {
- name = "a",
- type = "number",
- description = "The alpha component of the color.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setCurve",
- summary = "Set the curve of the layer.",
- description = "Sets the curve of the layer. Curving a layer renders it on a piece of a cylinder instead of a plane. The radius of the cylinder is `1 / curve` meters, so increasing the curve decreases the radius of the cylinder.",
- key = "Layer:setCurve",
- module = "lovr.headset",
- notes = "When a layer is created, its curve is zero.\n\nNot every headset system supports curved layers. See the `layerCurve` property of `lovr.headset.getFeatures` to check for support. If curved layers are not supported, this function will do nothing.\n\nNo matter what the curve is, the center of the layer texture will always get rendered at the layer's pose.\n\nThe largest possible curve is `2 * math.pi / width`, where `width` is the width of the layer in meters. This would cause the cylinder to fully wrap around.",
- variants = {
- {
- arguments = {
- {
- name = "curve",
- type = "number",
- description = "The curve of the layer. Negative values or zero means no curve.",
- default = "0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDimensions",
- summary = "Set the size of the layer.",
- description = "Sets the width and height of the layer. This is the size of the Layer's plane in meters, not not the resolution of the layer's texture in pixels.",
- key = "Layer:setDimensions",
- module = "lovr.headset",
- notes = "When a layer is created, its width and height are 1 meter.",
- variants = {
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the layer, in meters."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the layer, in meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setOrientation",
- summary = "Set the orientation of the layer.",
- description = "Sets the orientation of the layer.",
- key = "Layer:setOrientation",
- module = "lovr.headset",
- related = {
- "Layer:getPosition",
- "Layer:setPosition",
- "Layer:getPose",
- "Layer:setPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the axis of rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the layer."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPose",
- summary = "Set the pose of the layer.",
- description = "Sets the position and orientation of the layer.",
- key = "Layer:setPose",
- module = "lovr.headset",
- notes = "Units are in meters.",
- related = {
- "Layer:getPosition",
- "Layer:setPosition",
- "Layer:getOrientation",
- "Layer:setOrientation"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position."
- },
- {
- name = "y",
- type = "number",
- description = "The y position."
- },
- {
- name = "z",
- type = "number",
- description = "The z position."
- },
- {
- name = "angle",
- type = "number",
- description = "The amount of rotation around the axis of rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the layer."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the layer."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPosition",
- summary = "Set the position of the layer.",
- description = "Sets the position of the layer, in meters.",
- key = "Layer:setPosition",
- module = "lovr.headset",
- related = {
- "Layer:getOrientation",
- "Layer:setOrientation",
- "Layer:getPose",
- "Layer:setPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the layer."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the layer."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the layer."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setViewport",
- summary = "Set the viewport of the layer.",
- description = "Sets the viewport of the layer. The viewport is a 2D region of pixels that the layer will display within its plane.",
- key = "Layer:setViewport",
- module = "lovr.headset",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the upper-left corner of the viewport."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the upper-left corner of the viewport."
- },
- {
- name = "w",
- type = "number",
- description = "The width of the viewport, in pixels."
- },
- {
- name = "h",
- type = "number",
- description = "The height of the viewport, in pixels."
- }
- },
- returns = {}
- }
- }
- }
- }
- }
- },
- sections = {
- {
- name = "Input",
- tag = "input",
- description = "Functions for accessing input devices, like controllers, hands, trackers, or gamepads."
- },
- {
- name = "Controller Models",
- tag = "controller-models"
- },
- {
- name = "Display",
- tag = "headset",
- description = "Functions that return information about the active head mounted display (HMD)."
- },
- {
- name = "Play area",
- tag = "playArea",
- 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."
- },
- {
- name = "Layers",
- tag = "layers",
- description = "Layers are 2D textured quads that can be placed in 3D space. They are higher quality than rendering regular planes in the 3D scene."
- },
- {
- name = "Miscellaneous",
- tag = "headset-misc",
- description = "Functions that are internal or return information about the VR session."
- }
- }
- },
- {
- name = "math",
- tag = "modules",
- summary = "Contains useful math helpers.",
- description = "The `lovr.math` module provides math helpers commonly used for 3D applications.",
- key = "lovr.math",
- enums = {},
- functions = {
- {
- name = "drain",
- tag = "vectors",
- summary = "Drain the temporary vector pool.",
- description = "Drains the temporary vector pool, invalidating existing temporary vectors.\n\nThis is called automatically at the end of each frame.",
- key = "lovr.math.drain",
- module = "lovr.math",
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "gammaToLinear",
- tag = "mathOther",
- summary = "Convert a color from gamma space to linear space.",
- description = "Converts a color from gamma space to linear space.",
- key = "lovr.math.gammaToLinear",
- module = "lovr.math",
- related = {
- "lovr.math.linearToGamma"
- },
- variants = {
- {
- arguments = {
- {
- name = "gr",
- type = "number",
- description = "The red component of the gamma-space color."
- },
- {
- name = "gg",
- type = "number",
- description = "The green component of the gamma-space color."
- },
- {
- name = "gb",
- type = "number",
- description = "The blue component of the gamma-space color."
- }
- },
- returns = {
- {
- name = "lr",
- type = "number",
- description = "The red component of the resulting linear-space color."
- },
- {
- name = "lg",
- type = "number",
- description = "The green component of the resulting linear-space color."
- },
- {
- name = "lb",
- type = "number",
- description = "The blue component of the resulting linear-space color."
- }
- }
- },
- {
- description = "A table can also be used.",
- arguments = {
- {
- name = "color",
- type = "table",
- description = "A table containing the components of a gamma-space color."
- }
- },
- returns = {
- {
- name = "lr",
- type = "number",
- description = "The red component of the resulting linear-space color."
- },
- {
- name = "lg",
- type = "number",
- description = "The green component of the resulting linear-space color."
- },
- {
- name = "lb",
- type = "number",
- description = "The blue component of the resulting linear-space color."
- }
- }
- },
- {
- description = "Convert a single color channel.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The color channel to convert."
- }
- },
- returns = {
- {
- name = "y",
- type = "number",
- description = "The converted color channel."
- }
- }
- }
- }
- },
- {
- name = "getRandomSeed",
- tag = "random",
- summary = "Get the random seed.",
- description = "Get the seed used to initialize the random generator.",
- key = "lovr.math.getRandomSeed",
- module = "lovr.math",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "seed",
- type = "number",
- description = "The new seed."
- }
- }
- }
- }
- },
- {
- name = "linearToGamma",
- tag = "mathOther",
- summary = "Convert a color from linear space to gamma space.",
- description = "Converts a color from linear space to gamma space.",
- key = "lovr.math.linearToGamma",
- module = "lovr.math",
- related = {
- "lovr.math.gammaToLinear"
- },
- variants = {
- {
- arguments = {
- {
- name = "lr",
- type = "number",
- description = "The red component of the linear-space color."
- },
- {
- name = "lg",
- type = "number",
- description = "The green component of the linear-space color."
- },
- {
- name = "lb",
- type = "number",
- description = "The blue component of the linear-space color."
- }
- },
- returns = {
- {
- name = "gr",
- type = "number",
- description = "The red component of the resulting gamma-space color."
- },
- {
- name = "gg",
- type = "number",
- description = "The green component of the resulting gamma-space color."
- },
- {
- name = "gb",
- type = "number",
- description = "The blue component of the resulting gamma-space color."
- }
- }
- },
- {
- description = "A table can also be used.",
- arguments = {
- {
- name = "color",
- type = "table",
- description = "A table containing the components of a linear-space color."
- }
- },
- returns = {
- {
- name = "gr",
- type = "number",
- description = "The red component of the resulting gamma-space color."
- },
- {
- name = "gg",
- type = "number",
- description = "The green component of the resulting gamma-space color."
- },
- {
- name = "gb",
- type = "number",
- description = "The blue component of the resulting gamma-space color."
- }
- }
- },
- {
- description = "Convert a single color channel.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The color channel to convert."
- }
- },
- returns = {
- {
- name = "y",
- type = "number",
- description = "The converted color channel."
- }
- }
- }
- }
- },
- {
- name = "mat4",
- tag = "vectors",
- summary = "Create a temporary Mat4.",
- description = "Creates a temporary 4D matrix. This function takes the same arguments as `Mat4:set`.",
- key = "lovr.math.mat4",
- module = "lovr.math",
- related = {
- "lovr.math.newMat4",
- "Mat4",
- "Vectors"
- },
- variants = {
- {
- description = "Sets the matrix to the identity matrix.",
- arguments = {},
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- description = "Copies the values from an existing matrix.",
- arguments = {
- {
- name = "n",
- type = "Mat4",
- description = "An existing matrix to copy the values from."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The translation of the matrix.",
- default = "0, 0, 0"
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The scale of the matrix.",
- default = "1, 1, 1"
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation of the matrix.",
- default = "0, 0, 0, 1"
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The translation of the matrix.",
- default = "0, 0, 0"
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation of the matrix.",
- default = "0, 0, 0, 1"
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "...",
- type = "number",
- description = "16 numbers to use as the raw values of the matrix (column-major)."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- description = "Sets the diagonal values to a number and everything else to 0.",
- arguments = {
- {
- name = "d",
- type = "number",
- description = "A number to use for the diagonal elements."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- }
- }
- },
- {
- name = "newCurve",
- tag = "mathOther",
- summary = "Create a new Curve.",
- description = "Creates a new `Curve` from a list of control points.",
- key = "lovr.math.newCurve",
- module = "lovr.math",
- variants = {
- {
- description = "Create a Curve from a set of initial control points.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the first control point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the first control point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the first control point."
- },
- {
- name = "...",
- type = "*",
- description = "Additional control points."
- }
- },
- returns = {
- {
- name = "curve",
- type = "Curve",
- description = "The new Curve."
- }
- }
- },
- {
- description = "Create a Curve from a set of initial control points, using vectors.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "The first control point."
- },
- {
- name = "...",
- type = "*",
- description = "Additional control points."
- }
- },
- returns = {
- {
- name = "curve",
- type = "Curve",
- description = "The new Curve."
- }
- }
- },
- {
- description = "Create a Curve from control points in a table. The table values can be numbers or `Vec3` objects.",
- arguments = {
- {
- name = "points",
- type = "table",
- description = "A table of control points, formatted as numbers or `Vec3` objects."
- }
- },
- returns = {
- {
- name = "curve",
- type = "Curve",
- description = "The new Curve."
- }
- }
- },
- {
- description = "Create an empty Curve, reserving space ahead of time for a certain number of control points.",
- arguments = {
- {
- name = "n",
- type = "number",
- description = "The number of points to reserve for the Curve."
- }
- },
- returns = {
- {
- name = "curve",
- type = "Curve",
- description = "The new Curve."
- }
- }
- }
- }
- },
- {
- name = "newMat4",
- tag = "vectors",
- summary = "Create a new Mat4.",
- description = "Creates a new 4D matrix. This function takes the same arguments as `Mat4:set`.",
- key = "lovr.math.newMat4",
- module = "lovr.math",
- related = {
- "lovr.math.mat4",
- "Mat4",
- "Vectors"
- },
- variants = {
- {
- description = "Sets the matrix to the identity matrix.",
- arguments = {},
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- description = "Copies the values from an existing matrix.",
- arguments = {
- {
- name = "n",
- type = "Mat4",
- description = "An existing matrix to copy the values from."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The translation of the matrix.",
- default = "0, 0, 0"
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The scale of the matrix.",
- default = "1, 1, 1"
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation of the matrix.",
- default = "0, 0, 0, 1"
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The translation of the matrix.",
- default = "0, 0, 0"
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation of the matrix.",
- default = "0, 0, 0, 1"
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "...",
- type = "number",
- description = "16 numbers to use as the raw values of the matrix (column-major)."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- },
- {
- description = "Sets the diagonal values to a number and everything else to 0.",
- arguments = {
- {
- name = "d",
- type = "number",
- description = "A number to use for the diagonal elements."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The new matrix."
- }
- }
- }
- }
- },
- {
- name = "newQuat",
- tag = "vectors",
- summary = "Create a new Quat.",
- description = "Creates a new quaternion. This function takes the same arguments as `Quat:set`.",
- key = "lovr.math.newQuat",
- module = "lovr.math",
- related = {
- "lovr.math.quat",
- "Quat",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "An angle to use for the rotation, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "0"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "raw",
- type = "boolean",
- description = "Whether the components should be interpreted as raw `(x, y, z, w)` components.",
- default = "false"
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "r",
- type = "Quat",
- description = "An existing quaternion to copy the values from."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- description = "Uses the direction of a vector.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A normalized direction vector."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- description = "Sets the rotation to represent the rotation between two vectors.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A normalized direction vector."
- },
- {
- name = "u",
- type = "Vec3",
- description = "Another normalized direction vector."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "A matrix to use the rotation from."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- description = "Set the quaternion to the identity (0, 0, 0, 1).",
- arguments = {},
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- }
- }
- },
- {
- name = "newRandomGenerator",
- tag = "random",
- summary = "Create a new RandomGenerator.",
- 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.",
- key = "lovr.math.newRandomGenerator",
- module = "lovr.math",
- variants = {
- {
- description = "Create a RandomGenerator with a default seed.",
- arguments = {},
- returns = {
- {
- name = "randomGenerator",
- type = "RandomGenerator",
- description = "The new RandomGenerator."
- }
- }
- },
- {
- arguments = {
- {
- name = "seed",
- type = "number",
- description = "The initial seed for the RandomGenerator."
- }
- },
- returns = {
- {
- name = "randomGenerator",
- type = "RandomGenerator",
- description = "The new RandomGenerator."
- }
- }
- },
- {
- 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.",
- arguments = {
- {
- name = "low",
- type = "number",
- description = "The lower 32 bits of the seed."
- },
- {
- name = "high",
- type = "number",
- description = "The upper 32 bits of the seed."
- }
- },
- returns = {
- {
- name = "randomGenerator",
- type = "RandomGenerator",
- description = "The new RandomGenerator."
- }
- }
- }
- }
- },
- {
- name = "newVec2",
- tag = "vectors",
- summary = "Create a new Vec2.",
- description = "Creates a new 2D vector. This function takes the same arguments as `Vec2:set`.",
- key = "lovr.math.newVec2",
- module = "lovr.math",
- related = {
- "lovr.math.vec2",
- "Vec2",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec2",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "A vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec2",
- description = "The new vector."
- }
- }
- }
- }
- },
- {
- name = "newVec3",
- tag = "vectors",
- summary = "Create a new Vec3.",
- description = "Creates a new 3D vector. This function takes the same arguments as `Vec3:set`.",
- key = "lovr.math.newVec3",
- module = "lovr.math",
- related = {
- "lovr.math.vec3",
- "Vec3",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y value of the vector.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "The z value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "A vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "A matrix to use the position of."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "q",
- type = "Quat",
- description = "A quat to use the direction of."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- }
- }
- },
- {
- name = "newVec4",
- tag = "vectors",
- summary = "Create a new Vec4.",
- description = "Creates a new 4D vector. This function takes the same arguments as `Vec4:set`.",
- key = "lovr.math.newVec4",
- module = "lovr.math",
- related = {
- "lovr.math.vec4",
- "Vec4",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y value of the vector.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "The z value of the vector.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "The w value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec4",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "A vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec4",
- description = "The new vector."
- }
- }
- }
- }
- },
- {
- name = "noise",
- tag = "random",
- summary = "Generate simplex noise.",
- description = "Returns a 1D, 2D, 3D, or 4D simplex noise value. The number will be between 0 and 1.",
- key = "lovr.math.noise",
- module = "lovr.math",
- related = {
- "lovr.math.random"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the input."
- }
- },
- returns = {
- {
- name = "noise",
- type = "number",
- description = "The noise value, between 0 and 1."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the input."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the input."
- }
- },
- returns = {
- {
- name = "noise",
- type = "number",
- description = "The noise value, between 0 and 1."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the input."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the input."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the input."
- }
- },
- returns = {
- {
- name = "noise",
- type = "number",
- description = "The noise value, between 0 and 1."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the input."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the input."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the input."
- },
- {
- name = "w",
- type = "number",
- description = "The w coordinate of the input."
- }
- },
- returns = {
- {
- name = "noise",
- type = "number",
- description = "The noise value, between 0 and 1."
- }
- }
- }
- }
- },
- {
- name = "quat",
- tag = "vectors",
- summary = "Create a temporary Quat.",
- description = "Creates a temporary quaternion. This function takes the same arguments as `Quat:set`.",
- key = "lovr.math.quat",
- module = "lovr.math",
- related = {
- "lovr.math.newQuat",
- "Quat",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "An angle to use for the rotation, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "0"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "raw",
- type = "boolean",
- description = "Whether the components should be interpreted as raw `(x, y, z, w)` components.",
- default = "false"
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "r",
- type = "Quat",
- description = "An existing quaternion to copy the values from."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- description = "Uses the direction of a vector.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A normalized direction vector."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- description = "Sets the rotation to represent the rotation between two vectors.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A normalized direction vector."
- },
- {
- name = "u",
- type = "Vec3",
- description = "Another normalized direction vector."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "A matrix to use the rotation from."
- }
- },
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- },
- {
- description = "Set the quaternion to the identity (0, 0, 0, 1).",
- arguments = {},
- returns = {
- {
- name = "q",
- type = "Quat",
- description = "The new quaternion."
- }
- }
- }
- }
- },
- {
- name = "random",
- tag = "random",
- summary = "Get a random number.",
- 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).",
- key = "lovr.math.random",
- module = "lovr.math",
- notes = "You can set the random seed using `lovr.math.setRandomSeed`.",
- related = {
- "lovr.math.randomNormal",
- "RandomGenerator",
- "lovr.math.noise"
- },
- variants = {
- {
- description = "Generate a pseudo-random floating point number in the range `[0,1)`",
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "A pseudo-random number."
- }
- }
- },
- {
- description = "Generate a pseudo-random integer in the range `[1,high]`",
- arguments = {
- {
- name = "high",
- type = "number",
- description = "The maximum number to generate."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "A pseudo-random number."
- }
- }
- },
- {
- description = "Generate a pseudo-random integer in the range `[low,high]`",
- arguments = {
- {
- name = "low",
- type = "number",
- description = "The minimum number to generate."
- },
- {
- name = "high",
- type = "number",
- description = "The maximum number to generate."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "A pseudo-random number."
- }
- }
- }
- }
- },
- {
- name = "randomNormal",
- tag = "random",
- summary = "Get a random number from a normal distribution.",
- 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).",
- key = "lovr.math.randomNormal",
- module = "lovr.math",
- related = {
- "lovr.math.random",
- "RandomGenerator"
- },
- variants = {
- {
- arguments = {
- {
- name = "sigma",
- type = "number",
- 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.",
- default = "1"
- },
- {
- name = "mu",
- type = "number",
- description = "The average value returned.",
- default = "0"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "A normally distributed pseudo-random number."
- }
- }
- }
- }
- },
- {
- name = "setRandomSeed",
- tag = "random",
- summary = "Set the random seed.",
- 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`.",
- key = "lovr.math.setRandomSeed",
- module = "lovr.math",
- variants = {
- {
- arguments = {
- {
- name = "seed",
- type = "number",
- description = "The new seed."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "vec2",
- tag = "vectors",
- summary = "Create a temporary Vec2.",
- description = "Creates a temporary 2D vector. This function takes the same arguments as `Vec2:set`.",
- key = "lovr.math.vec2",
- module = "lovr.math",
- related = {
- "lovr.math.newVec2",
- "Vec2",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec2",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "A vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec2",
- description = "The new vector."
- }
- }
- }
- }
- },
- {
- name = "vec3",
- tag = "vectors",
- summary = "Create a temporary Vec3.",
- description = "Creates a temporary 3D vector. This function takes the same arguments as `Vec3:set`.",
- key = "lovr.math.vec3",
- module = "lovr.math",
- related = {
- "lovr.math.newVec3",
- "Vec3",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y value of the vector.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "The z value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "A vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "A matrix to use the position of."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "q",
- type = "Quat",
- description = "A quat to use the direction of."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The new vector."
- }
- }
- }
- }
- },
- {
- name = "vec4",
- tag = "vectors",
- summary = "Create a temporary Vec4.",
- description = "Creates a temporary 4D vector. This function takes the same arguments as `Vec4:set`.",
- key = "lovr.math.vec4",
- module = "lovr.math",
- related = {
- "lovr.math.newVec4",
- "Vec4",
- "Vectors"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y value of the vector.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "The z value of the vector.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "The w value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec4",
- description = "The new vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "A vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec4",
- description = "The new vector."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "Curve",
- summary = "A Bézier curve.",
- 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.",
- key = "Curve",
- module = "lovr.math",
- constructors = {
- "lovr.math.newCurve",
- "Curve:slice"
- },
- methods = {
- {
- name = "addPoint",
- summary = "Add a new control point to the Curve.",
- description = "Inserts a new control point into the Curve at the specified index.",
- key = "Curve:addPoint",
- module = "lovr.math",
- notes = "An error will be thrown if the index is less than one or more than the number of control points.",
- related = {
- "Curve:getPointCount",
- "Curve:getPoint",
- "Curve:setPoint",
- "Curve:removePoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the control point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the control point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the control point."
- },
- {
- name = "index",
- type = "number",
- 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.",
- default = "nil"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "evaluate",
- summary = "Turn a number from 0 to 1 into a point on the Curve.",
- 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.",
- key = "Curve:evaluate",
- module = "lovr.math",
- notes = "An error will be thrown if `t` is not between 0 and 1, or if the Curve has less than two points.",
- related = {
- "Curve:getTangent",
- "Curve:render",
- "Curve:slice"
- },
- variants = {
- {
- arguments = {
- {
- name = "t",
- type = "number",
- description = "The parameter to evaluate the Curve at."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the point."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the point."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the point."
- }
- }
- }
- }
- },
- {
- name = "getPoint",
- summary = "Get a control point of the Curve.",
- description = "Returns a control point of the Curve.",
- key = "Curve:getPoint",
- module = "lovr.math",
- notes = "An error will be thrown if the index is less than one or more than the number of control points.",
- related = {
- "Curve:getPointCount",
- "Curve:setPoint",
- "Curve:addPoint",
- "Curve:removePoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index to retrieve."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the control point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the control point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the control point."
- }
- }
- }
- }
- },
- {
- name = "getPointCount",
- summary = "Get the number of control points in the Curve.",
- description = "Returns the number of control points in the Curve.",
- key = "Curve:getPointCount",
- module = "lovr.math",
- related = {
- "Curve:getPoint",
- "Curve:setPoint",
- "Curve:addPoint",
- "Curve:removePoint"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of control points."
- }
- }
- }
- }
- },
- {
- name = "getTangent",
- summary = "Get the direction of the Curve at a point.",
- 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.",
- key = "Curve:getTangent",
- module = "lovr.math",
- notes = "The direction vector returned by this function will have a length of one.",
- related = {
- "Curve:evaluate",
- "Curve:render",
- "Curve:slice"
- },
- variants = {
- {
- arguments = {
- {
- name = "t",
- type = "number",
- description = "Where on the Curve to compute the direction."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the point."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the point."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the point."
- }
- }
- }
- }
- },
- {
- name = "removePoint",
- summary = "Remove a control point from the Curve.",
- description = "Removes a control point from the Curve.",
- key = "Curve:removePoint",
- module = "lovr.math",
- notes = "An error will be thrown if the index is less than one or more than the number of control points.",
- related = {
- "Curve:getPointCount",
- "Curve:getPoint",
- "Curve:setPoint",
- "Curve:addPoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the control point to remove."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "render",
- summary = "Get a list of points on the Curve.",
- 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.",
- key = "Curve:render",
- module = "lovr.math",
- notes = "This function will always return 2 points if the Curve is a line with only 2 control points.",
- related = {
- "Curve:evaluate",
- "Curve:slice",
- "Pass:points",
- "Pass:line",
- "Pass:mesh"
- },
- variants = {
- {
- arguments = {
- {
- name = "n",
- type = "number",
- description = "The number of points to use.",
- default = "32"
- },
- {
- name = "t1",
- type = "number",
- description = "How far along the curve to start rendering.",
- default = "0"
- },
- {
- name = "t2",
- type = "number",
- description = "How far along the curve to stop rendering.",
- default = "1"
- }
- },
- returns = {
- {
- name = "t",
- type = "table",
- description = "A (flat) table of 3D points along the curve."
- }
- }
- }
- }
- },
- {
- name = "setPoint",
- summary = "Set a control point of the Curve.",
- description = "Changes the position of a control point on the Curve.",
- key = "Curve:setPoint",
- module = "lovr.math",
- notes = "An error will be thrown if the index is less than one or more than the number of control points.",
- related = {
- "Curve:getPointCount",
- "Curve:getPoint",
- "Curve:addPoint",
- "Curve:removePoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index to modify."
- },
- {
- name = "x",
- type = "number",
- description = "The new x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The new y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The new z coordinate."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "slice",
- summary = "Get a new Curve from a slice of an existing one.",
- description = "Returns a new Curve created by slicing the Curve at the specified start and end points.",
- key = "Curve:slice",
- module = "lovr.math",
- 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.",
- related = {
- "Curve:evaluate",
- "Curve:render"
- },
- variants = {
- {
- arguments = {
- {
- name = "t1",
- type = "number",
- description = "The starting point to slice at."
- },
- {
- name = "t2",
- type = "number",
- description = "The ending point to slice at."
- }
- },
- returns = {
- {
- name = "curve",
- type = "Curve",
- description = "A new Curve."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Mat4",
- summary = "A 4x4 matrix.",
- description = "A `mat4` is a math type that holds 16 values in a 4x4 grid.",
- key = "Mat4",
- module = "lovr.math",
- constructors = {
- "lovr.math.newMat4",
- "lovr.math.mat4"
- },
- methods = {
- {
- name = "equals",
- summary = "Check if a matrix equals another matrix.",
- description = "Returns whether a matrix is approximately equal to another matrix.",
- key = "Mat4:equals",
- module = "lovr.math",
- related = {
- "Vec2:equals",
- "Vec3:equals",
- "Vec4:equals",
- "Quat:equals"
- },
- variants = {
- {
- arguments = {
- {
- name = "n",
- type = "Mat4",
- description = "The other matrix."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 matrices approximately equal each other."
- }
- }
- }
- }
- },
- {
- name = "fov",
- summary = "Set a projection using raw field of view angles.",
- description = "Sets a projection matrix using raw projection angles and clipping planes.\n\nThis can be used for asymmetric or oblique projections.",
- key = "Mat4:fov",
- module = "lovr.math",
- related = {
- "Mat4:orthographic",
- "Mat4:perspective",
- "Pass:setProjection"
- },
- variants = {
- {
- arguments = {
- {
- name = "left",
- type = "number",
- description = "The left half-angle of the projection, in radians."
- },
- {
- name = "right",
- type = "number",
- description = "The right half-angle of the projection, in radians."
- },
- {
- name = "up",
- type = "number",
- description = "The top half-angle of the projection, in radians."
- },
- {
- name = "down",
- type = "number",
- description = "The bottom half-angle of the projection, in radians."
- },
- {
- name = "near",
- type = "number",
- description = "The near plane of the projection."
- },
- {
- name = "far",
- type = "number",
- 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.",
- default = "0"
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- summary = "Get the angle/axis rotation of the matrix.",
- description = "Returns the angle/axis rotation of the matrix.",
- key = "Mat4:getOrientation",
- module = "lovr.math",
- related = {
- "Mat4:getPosition",
- "Mat4:getScale",
- "Mat4:getPose",
- "Mat4:unpack",
- "Mat4:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the matrix rotates around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- summary = "Get the position and rotation of the matrix.",
- description = "Returns the position and rotation of the matrix.",
- key = "Mat4:getPose",
- module = "lovr.math",
- related = {
- "Mat4:getPosition",
- "Mat4:getOrientation",
- "Mat4:getScale",
- "Mat4:unpack",
- "Mat4:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z translation."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the matrix rotates around its rotation axis."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- summary = "Get the translation of the matrix.",
- description = "Returns the translation of the matrix. This is the last column of the matrix.",
- key = "Mat4:getPosition",
- module = "lovr.math",
- related = {
- "Mat4:getOrientation",
- "Mat4:getScale",
- "Mat4:getPose",
- "Mat4:unpack",
- "Mat4:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z translation."
- }
- }
- }
- }
- },
- {
- name = "getScale",
- summary = "Get the scale factor of the matrix.",
- description = "Returns the scale factor of the matrix.",
- key = "Mat4:getScale",
- module = "lovr.math",
- related = {
- "Mat4:getPosition",
- "Mat4:getOrientation",
- "Mat4:getPose",
- "Mat4:unpack",
- "Mat4:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "sx",
- type = "number",
- description = "The x scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z scale."
- }
- }
- }
- }
- },
- {
- name = "identity",
- summary = "Reset the matrix to the identity.",
- description = "Resets the matrix to the identity, effectively setting its translation to zero, its scale to 1, and clearing any rotation.",
- key = "Mat4:identity",
- module = "lovr.math",
- related = {
- "Pass:origin"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "invert",
- summary = "Invert the matrix.",
- description = "Inverts the matrix, causing it to represent the opposite of its old transform.",
- key = "Mat4:invert",
- module = "lovr.math",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The inverted matrix."
- }
- }
- }
- }
- },
- {
- name = "lookAt",
- summary = "Create a view transform that looks from a position to target position.",
- 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.\n\nThe lookAt() function produces same result as target() after matrix inversion.",
- key = "Mat4:lookAt",
- module = "lovr.math",
- examples = {
- {
- code = "function lovr.draw(pass)\n pass:setViewPose(1, mat4():lookAt(cameraPos, playerPos), true)\n\n -- draw scene\nend"
- }
- },
- related = {
- "Mat4:target",
- "Quat:direction"
- },
- variants = {
- {
- arguments = {
- {
- name = "from",
- type = "Vec3",
- description = "The position of the viewer."
- },
- {
- name = "to",
- type = "Vec3",
- description = "The position of the target."
- },
- {
- name = "up",
- type = "Vec3",
- description = "The up vector of the viewer.",
- default = "Vec3(0, 1, 0)"
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "mul",
- summary = "Multiply a matrix with another matrix or a vector.",
- 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.",
- key = "Mat4:mul",
- module = "lovr.math",
- 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).",
- related = {
- "Mat4:translate",
- "Mat4:rotate",
- "Mat4:scale"
- },
- variants = {
- {
- arguments = {
- {
- name = "n",
- type = "Mat4",
- description = "The matrix."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "v3",
- type = "Vec3",
- description = "A 3D vector, treated as a point."
- }
- },
- returns = {
- {
- name = "v3",
- type = "Vec3",
- description = "The transformed vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "v4",
- type = "Vec4",
- description = "A 4D vector."
- }
- },
- returns = {
- {
- name = "v4",
- type = "Vec4",
- description = "The transformed vector."
- }
- }
- }
- }
- },
- {
- name = "orthographic",
- summary = "Turn the matrix into an orthographic projection.",
- 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.",
- key = "Mat4:orthographic",
- module = "lovr.math",
- related = {
- "Mat4:perspective",
- "Mat4:fov",
- "Pass:setProjection"
- },
- variants = {
- {
- arguments = {
- {
- name = "left",
- type = "number",
- description = "The left edge of the projection."
- },
- {
- name = "right",
- type = "number",
- description = "The right edge of the projection."
- },
- {
- name = "bottom",
- type = "number",
- description = "The bottom edge of the projection."
- },
- {
- name = "top",
- type = "number",
- description = "The top edge of the projection."
- },
- {
- name = "near",
- type = "number",
- description = "The position of the near clipping plane."
- },
- {
- name = "far",
- type = "number",
- description = "The position of the far clipping plane."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the projection."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the projection."
- },
- {
- name = "near",
- type = "number",
- description = "The position of the near clipping plane."
- },
- {
- name = "far",
- type = "number",
- description = "The position of the far clipping plane."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "perspective",
- summary = "Turn the matrix into a perspective projection.",
- 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.",
- key = "Mat4:perspective",
- module = "lovr.math",
- related = {
- "Mat4:orthographic",
- "Mat4:fov",
- "Pass:setProjection"
- },
- variants = {
- {
- arguments = {
- {
- name = "fov",
- type = "number",
- description = "The vertical field of view (in radians)."
- },
- {
- name = "aspect",
- type = "number",
- description = "The horizontal aspect ratio of the projection (width / height)."
- },
- {
- name = "near",
- type = "number",
- description = "The near plane."
- },
- {
- name = "far",
- type = "number",
- 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.",
- default = "0"
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "reflect",
- summary = "Create a matrix that reflects across a plane.",
- description = "Turns the matrix into a reflection matrix that transforms values as though they were reflected across a plane.",
- key = "Mat4:reflect",
- module = "lovr.math",
- variants = {
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the plane."
- },
- {
- name = "normal",
- type = "Vec3",
- description = "The normal vector of the plane."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The reflected matrix."
- }
- }
- }
- }
- },
- {
- name = "rotate",
- summary = "Rotate the matrix.",
- description = "Rotates the matrix using a quaternion or an angle/axis rotation.",
- key = "Mat4:rotate",
- module = "lovr.math",
- related = {
- "Mat4:translate",
- "Mat4:scale",
- "Mat4:identity"
- },
- variants = {
- {
- arguments = {
- {
- name = "q",
- type = "Quat",
- description = "The rotation to apply to the matrix."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The rotated matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The angle component of the angle/axis rotation (radians)."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The rotated matrix."
- }
- }
- }
- }
- },
- {
- name = "scale",
- summary = "Scale the matrix.",
- description = "Scales the matrix.",
- key = "Mat4:scale",
- module = "lovr.math",
- related = {
- "Mat4:translate",
- "Mat4:rotate",
- "Mat4:identity"
- },
- variants = {
- {
- arguments = {
- {
- name = "scale",
- type = "Vec3",
- description = "The 3D scale to apply."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "sx",
- type = "number",
- description = "The x component of the scale to apply."
- },
- {
- name = "sy",
- type = "number",
- description = "The y component of the scale to apply.",
- default = "sx"
- },
- {
- name = "sz",
- type = "number",
- description = "The z component of the scale to apply.",
- default = "sx"
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "set",
- summary = "Set the components of the matrix.",
- description = "Sets the components of the matrix from separate position, rotation, and scale arguments or an existing matrix.",
- key = "Mat4:set",
- module = "lovr.math",
- related = {
- "Mat4:unpack"
- },
- variants = {
- {
- description = "Resets the matrix to the identity matrix, without any translation, rotation, or scale.",
- arguments = {},
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- description = "Copies the values from an existing matrix.",
- arguments = {
- {
- name = "n",
- type = "Mat4",
- description = "An existing matrix to copy the values from."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- description = "Sets the position, scale, and rotation of the matrix using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation."
- },
- {
- name = "sx",
- type = "number",
- description = "The x component of the scale."
- },
- {
- name = "sy",
- type = "number",
- description = "The y component of the scale."
- },
- {
- name = "sz",
- type = "number",
- description = "The z component of the scale."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle of the rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- description = "Sets the pose (position and orientation) of the matrix using numbers. The scale is set to 1 on all axes.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle of the rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The translation of the matrix."
- },
- {
- name = "scale",
- type = "Vec3",
- description = "The scale of the matrix."
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation of the matrix."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The translation of the matrix."
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation of the matrix."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- description = "Sets the raw components of the matrix using 16 numbers in column-major order.",
- arguments = {
- {
- name = "...",
- type = "number",
- description = "The raw values of the matrix, in column-major order."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- },
- {
- description = "Sets the diagonal values to a number and everything else to 0.",
- arguments = {
- {
- name = "d",
- type = "number",
- description = "A number to use for the diagonal elements."
- }
- },
- returns = {
- {
- name = "m",
- type = "Mat4",
- description = "The input matrix."
- }
- }
- }
- }
- },
- {
- name = "target",
- summary = "Create a model transform that targets from a position to target position.",
- 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.",
- key = "Mat4:target",
- module = "lovr.math",
- related = {
- "Mat4:lookAt",
- "Quat:direction"
- },
- variants = {
- {
- arguments = {
- {
- name = "from",
- type = "Vec3",
- description = "The position of the viewer."
- },
- {
- name = "to",
- type = "Vec3",
- description = "The position of the target."
- },
- {
- name = "up",
- type = "Vec3",
- description = "The up vector of the viewer.",
- default = "Vec3(0, 1, 0)"
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The modified matrix."
- }
- }
- }
- }
- },
- {
- name = "translate",
- summary = "Translate the matrix.",
- description = "Translates the matrix.",
- key = "Mat4:translate",
- module = "lovr.math",
- related = {
- "Mat4:rotate",
- "Mat4:scale",
- "Mat4:identity"
- },
- variants = {
- {
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "The translation vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The translated matrix."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation."
- }
- },
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The translated matrix."
- }
- }
- }
- }
- },
- {
- name = "transpose",
- summary = "Transpose the matrix.",
- description = "Transposes the matrix, mirroring its values along the diagonal.",
- key = "Mat4:transpose",
- module = "lovr.math",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Mat4",
- description = "The transposed matrix."
- }
- }
- }
- }
- },
- {
- name = "unpack",
- summary = "Get the individual components of the matrix.",
- 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.",
- key = "Mat4:unpack",
- module = "lovr.math",
- related = {
- "Mat4:set",
- "Mat4:getPosition",
- "Mat4:getOrientation",
- "Mat4:getScale",
- "Mat4:getPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "raw",
- type = "boolean",
- description = "Whether to return the 16 raw components.",
- default = "false"
- }
- },
- returns = {
- {
- name = "...",
- type = "number",
- description = "The requested components of the matrix."
- }
- }
- }
- }
- }
- },
- related = {
- "Vec3",
- "Quat",
- "Vectors"
- }
- },
- {
- name = "Quat",
- summary = "A quaternion.",
- description = "A `quat` is a math type that represents a 3D rotation, stored as four numbers.",
- key = "Quat",
- module = "lovr.math",
- constructors = {
- "lovr.math.newQuat",
- "lovr.math.quat"
- },
- methods = {
- {
- name = "conjugate",
- summary = "Conjugate (invert) the quaternion.",
- 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.",
- key = "Quat:conjugate",
- module = "lovr.math",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The inverted quaternion."
- }
- }
- }
- }
- },
- {
- name = "direction",
- summary = "Get the direction of the quaternion.",
- description = "Creates a new temporary vec3 facing the forward direction, rotates it by this quaternion, and returns the vector.",
- key = "Quat:direction",
- module = "lovr.math",
- related = {
- "Mat4:lookAt"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The direction vector."
- }
- }
- }
- }
- },
- {
- name = "equals",
- summary = "Check if a quaternion equals another quaternion.",
- description = "Returns whether a quaternion is approximately equal to another quaternion.",
- key = "Quat:equals",
- module = "lovr.math",
- related = {
- "Vec2:equals",
- "Vec3:equals",
- "Vec4:equals",
- "Mat4:equals"
- },
- variants = {
- {
- arguments = {
- {
- name = "r",
- type = "Quat",
- description = "The other quaternion."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 quaternions approximately equal each other."
- }
- }
- }
- }
- },
- {
- name = "getEuler",
- summary = "Get the euler angles of the quaternion.",
- description = "Returns the euler angles of the quaternion, in YXZ order.",
- key = "Quat:getEuler",
- module = "lovr.math",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "pitch",
- type = "number",
- description = "The pitch (x axis rotation)."
- },
- {
- name = "yaw",
- type = "number",
- description = "The yaw (y axis rotation)."
- },
- {
- name = "roll",
- type = "number",
- description = "The roll (z axis rotation)."
- }
- }
- }
- }
- },
- {
- name = "length",
- summary = "Get the length of the quaternion.",
- description = "Returns the length of the quaternion.",
- key = "Quat:length",
- module = "lovr.math",
- related = {
- "Quat:normalize"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the quaternion."
- }
- }
- }
- }
- },
- {
- name = "mul",
- summary = "Multiply a quaternion by another quaternion or a vector.",
- 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.",
- key = "Quat:mul",
- module = "lovr.math",
- variants = {
- {
- arguments = {
- {
- name = "r",
- type = "Quat",
- description = "A quaternion to combine with the original."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "v3",
- type = "Vec3",
- description = "A vector to rotate."
- }
- },
- returns = {
- {
- name = "v3",
- type = "Vec3",
- description = "The rotated vector."
- }
- }
- }
- }
- },
- {
- name = "normalize",
- summary = "Normalize the length of the quaternion to 1.",
- description = "Adjusts the values in the quaternion so that its length becomes 1.",
- key = "Quat:normalize",
- module = "lovr.math",
- 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!",
- related = {
- "Quat:length"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The normalized quaternion."
- }
- }
- }
- }
- },
- {
- name = "set",
- summary = "Set the components of the quaternion.",
- 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.",
- key = "Quat:set",
- module = "lovr.math",
- related = {
- "Quat:unpack"
- },
- variants = {
- {
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The angle to use for the rotation, in radians.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "0"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- },
- {
- name = "raw",
- type = "boolean",
- description = "Whether the components should be interpreted as raw `(x, y, z, w)` components.",
- default = "false"
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "r",
- type = "Quat",
- description = "An existing quaternion to copy the values from."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- },
- {
- description = "Sets the values from a direction vector.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A normalized direction vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- },
- {
- description = "Sets the values to represent the rotation between two vectors.",
- arguments = {
- {
- name = "v",
- type = "Vec3",
- description = "A normalized direction vector."
- },
- {
- name = "u",
- type = "Vec3",
- description = "Another normalized direction vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- },
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "A matrix to use the rotation from."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- },
- {
- description = "Reset the quaternion to the identity (0, 0, 0, 1).",
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- }
- }
- },
- {
- name = "setEuler",
- summary = "Set the value of the quaternion using euler angles.",
- description = "Sets the value of the quaternion using euler angles. The rotation order is YXZ.",
- key = "Quat:setEuler",
- module = "lovr.math",
- variants = {
- {
- arguments = {
- {
- name = "pitch",
- type = "number",
- description = "The pitch (x axis rotation)."
- },
- {
- name = "yaw",
- type = "number",
- description = "The yaw (y axis rotation)."
- },
- {
- name = "roll",
- type = "number",
- description = "The roll (z axis rotation)."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion."
- }
- }
- }
- }
- },
- {
- name = "slerp",
- summary = "Moves this quaternion some amount towards another one.",
- 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.",
- key = "Quat:slerp",
- module = "lovr.math",
- related = {
- "Vec3:lerp"
- },
- variants = {
- {
- arguments = {
- {
- name = "r",
- type = "Quat",
- description = "The quaternion to slerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Quat",
- description = "The modified quaternion, containing the new lerped values."
- }
- }
- }
- }
- },
- {
- name = "unpack",
- summary = "Get the components of the quaternion.",
- description = "Returns the components of the quaternion as numbers, either in an angle/axis representation or as raw quaternion values.",
- key = "Quat:unpack",
- module = "lovr.math",
- related = {
- "Quat:set"
- },
- variants = {
- {
- arguments = {
- {
- name = "raw",
- type = "boolean",
- description = "Whether the values should be returned as raw values instead of angle/axis.",
- default = "false"
- }
- },
- returns = {
- {
- name = "a",
- type = "number",
- description = "The angle in radians, or the x value."
- },
- {
- name = "b",
- type = "number",
- description = "The x component of the rotation axis or the y value."
- },
- {
- name = "c",
- type = "number",
- description = "The y component of the rotation axis or the z value."
- },
- {
- name = "d",
- type = "number",
- description = "The z component of the rotation axis or the w value."
- }
- }
- }
- }
- }
- },
- related = {
- "Vec3",
- "Mat4",
- "Vectors"
- }
- },
- {
- name = "RandomGenerator",
- summary = "A pseudo-random number generator.",
- 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.",
- key = "RandomGenerator",
- module = "lovr.math",
- constructors = {
- "lovr.math.newRandomGenerator"
- },
- methods = {
- {
- name = "getSeed",
- summary = "Get the seed value of the RandomGenerator.",
- description = "Returns the seed used to initialize the RandomGenerator.",
- key = "RandomGenerator:getSeed",
- module = "lovr.math",
- notes = "Since the seed is a 64 bit integer, each 32 bits of the seed are returned separately to avoid precision issues.",
- related = {
- "lovr.math.newRandomGenerator"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "low",
- type = "number",
- description = "The lower 32 bits of the seed."
- },
- {
- name = "high",
- type = "number",
- description = "The upper 32 bits of the seed."
- }
- }
- }
- }
- },
- {
- name = "getState",
- summary = "Get the current state of the RandomGenerator.",
- description = "Returns the current state of the RandomGenerator. This can be used with `RandomGenerator:setState` to reliably restore a previous state of the generator.",
- key = "RandomGenerator:getState",
- module = "lovr.math",
- notes = "The seed represents the starting state of the RandomGenerator, whereas the state represents the current state of the generator.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "state",
- type = "string",
- description = "The serialized state."
- }
- }
- }
- }
- },
- {
- name = "random",
- summary = "Get a random number.",
- description = "Returns the next uniformly distributed pseudo-random number from the RandomGenerator's sequence.",
- key = "RandomGenerator:random",
- module = "lovr.math",
- related = {
- "lovr.math.random",
- "RandomGenerator:randomNormal"
- },
- variants = {
- {
- description = "Generate a pseudo-random floating point number in the range `[0,1)`",
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "A pseudo-random number."
- }
- }
- },
- {
- description = "Generate a pseudo-random integer in the range `[1,high]`",
- arguments = {
- {
- name = "high",
- type = "number",
- description = "The maximum number to generate."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "A pseudo-random number."
- }
- }
- },
- {
- description = "Generate a pseudo-random integer in the range `[low,high]`",
- arguments = {
- {
- name = "low",
- type = "number",
- description = "The minimum number to generate."
- },
- {
- name = "high",
- type = "number",
- description = "The maximum number to generate."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "A pseudo-random number."
- }
- }
- }
- }
- },
- {
- name = "randomNormal",
- summary = "Get a random number from a normal distribution.",
- 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).",
- key = "RandomGenerator:randomNormal",
- module = "lovr.math",
- related = {
- "lovr.math.randomNormal",
- "RandomGenerator:random"
- },
- variants = {
- {
- arguments = {
- {
- name = "sigma",
- type = "number",
- 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.",
- default = "1"
- },
- {
- name = "mu",
- type = "number",
- description = "The average value returned.",
- default = "0"
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "A normally distributed pseudo-random number."
- }
- }
- }
- }
- },
- {
- name = "setSeed",
- summary = "Reinitialize the RandomGenerator with a new seed.",
- description = "Seed the RandomGenerator with a new seed. Each seed will cause the RandomGenerator to produce a unique sequence of random numbers.",
- key = "RandomGenerator:setSeed",
- module = "lovr.math",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "seed",
- type = "number",
- description = "The random seed."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "low",
- type = "number",
- description = "The lower 32 bits of the seed."
- },
- {
- name = "high",
- type = "number",
- description = "The upper 32 bits of the seed."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setState",
- summary = "Set the state of the RandomGenerator.",
- 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.",
- key = "RandomGenerator:setState",
- module = "lovr.math",
- notes = "The seed represents the starting state of the RandomGenerator, whereas the state represents the current state of the generator.",
- variants = {
- {
- arguments = {
- {
- name = "state",
- type = "string",
- description = "The serialized state."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "Vec2",
- summary = "A 2D vector.",
- description = "A vector object that holds two numbers.",
- key = "Vec2",
- module = "lovr.math",
- constructors = {
- "lovr.math.newVec2",
- "lovr.math.vec2"
- },
- methods = {
- {
- name = "add",
- summary = "Add a vector or a number to the vector.",
- description = "Adds a vector or a number to the vector.",
- key = "Vec2:add",
- module = "lovr.math",
- related = {
- "Vec2:sub",
- "Vec2:mul",
- "Vec2:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to add to x component."
- },
- {
- name = "y",
- type = "number",
- description = "A value to add to y component.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "angle",
- summary = "Get the angle to another vector.",
- description = "Returns the angle between vectors.",
- key = "Vec2:angle",
- module = "lovr.math",
- 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`.",
- related = {
- "Vec2:distance",
- "Vec2:length"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The angle to the other vector, in radians."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the other vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the other vector."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The angle to the other vector, in radians."
- }
- }
- }
- }
- },
- {
- name = "distance",
- summary = "Get the distance to another vector.",
- description = "Returns the distance to another vector.",
- key = "Vec2:distance",
- module = "lovr.math",
- related = {
- "Vec2:angle",
- "Vec2:length"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The vector to measure the distance to."
- }
- },
- returns = {
- {
- name = "distance",
- type = "number",
- description = "The distance to `u`."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to measure distance to."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to measure distance to."
- }
- },
- returns = {
- {
- name = "distance",
- type = "number",
- description = "The distance to `u`."
- }
- }
- }
- }
- },
- {
- name = "div",
- summary = "Divides the vector by a vector or a number.",
- description = "Divides the vector by a vector or a number.",
- key = "Vec2:div",
- module = "lovr.math",
- related = {
- "Vec2:add",
- "Vec2:sub",
- "Vec2:mul"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The other vector to divide the components by."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to divide x component by."
- },
- {
- name = "y",
- type = "number",
- description = "A value to divide y component by.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "dot",
- summary = "Get the dot product with another vector.",
- description = "Returns the dot product between this vector and another one.",
- key = "Vec2:dot",
- module = "lovr.math",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The vector to compute the dot product with."
- }
- },
- returns = {
- {
- name = "dot",
- type = "number",
- description = "The dot product between `v` and `u`."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to compute the dot product with."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to compute the dot product with."
- }
- },
- returns = {
- {
- name = "dot",
- type = "number",
- description = "The dot product between `v` and `u`."
- }
- }
- }
- }
- },
- {
- name = "equals",
- summary = "Check if a vector equals another vector.",
- description = "Returns whether a vector is approximately equal to another vector.",
- key = "Vec2:equals",
- module = "lovr.math",
- notes = "To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`.",
- related = {
- "Vec3:equals",
- "Vec4:equals",
- "Quat:equals",
- "Mat4:equals"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 vectors approximately equal each other."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the other vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the other vector."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 vectors approximately equal each other."
- }
- }
- }
- }
- },
- {
- name = "length",
- summary = "Get the length of the vector.",
- description = "Returns the length of the vector.",
- key = "Vec2:length",
- module = "lovr.math",
- notes = "The length is equivalent to this:\n\n math.sqrt(v.x * v.x + v.y * v.y)",
- related = {
- "Vec2:normalize",
- "Vec2:distance"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the vector."
- }
- }
- }
- }
- },
- {
- name = "lerp",
- summary = "Moves this vector some amount towards another one.",
- 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.",
- key = "Vec2:lerp",
- module = "lovr.math",
- related = {
- "Quat:slerp"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The vector to lerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The interpolated vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to lerp towards."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to lerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The interpolated vector."
- }
- }
- }
- }
- },
- {
- name = "mul",
- summary = "Multiply the vector by a vector or a number.",
- description = "Multiplies the vector by a vector or a number.",
- key = "Vec2:mul",
- module = "lovr.math",
- related = {
- "Vec2:add",
- "Vec2:sub",
- "Vec2:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The other vector to multiply the components by."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to multiply x component by."
- },
- {
- name = "y",
- type = "number",
- description = "A value to multiply y component by.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "normalize",
- summary = "Normalize the length of the vector to 1.",
- description = "Adjusts the values in the vector so that its direction stays the same but its length becomes 1.",
- key = "Vec2:normalize",
- module = "lovr.math",
- related = {
- "Vec2:length"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The normalized vector."
- }
- }
- }
- }
- },
- {
- name = "set",
- summary = "Set the components of the vector.",
- description = "Sets the components of the vector, either from numbers or an existing vector.",
- key = "Vec2:set",
- module = "lovr.math",
- related = {
- "Vec2:unpack"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The new x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The new y value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec2",
- description = "The input vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec2",
- description = "The input vector."
- }
- }
- }
- }
- },
- {
- name = "sub",
- summary = "Subtract a vector or a number from the vector.",
- description = "Subtracts a vector or a number from the vector.",
- key = "Vec2:sub",
- module = "lovr.math",
- related = {
- "Vec2:add",
- "Vec2:mul",
- "Vec2:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec2",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to subtract from x component."
- },
- {
- name = "y",
- type = "number",
- description = "A value to subtract from y component.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec2",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "unpack",
- summary = "Get the components of the vector.",
- description = "Returns the 2 components of the vector as numbers.",
- key = "Vec2:unpack",
- module = "lovr.math",
- related = {
- "Vec2:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x value."
- },
- {
- name = "y",
- type = "number",
- description = "The y value."
- }
- }
- }
- }
- }
- },
- related = {
- "Vec3",
- "Vec4",
- "Vectors"
- }
- },
- {
- name = "Vec3",
- summary = "A 3D vector.",
- description = "A vector object that holds three numbers.",
- key = "Vec3",
- module = "lovr.math",
- constructors = {
- "lovr.math.newVec3",
- "lovr.math.vec3"
- },
- methods = {
- {
- name = "add",
- summary = "Add a vector or a number to the vector.",
- description = "Adds a vector or a number to the vector.",
- key = "Vec3:add",
- module = "lovr.math",
- related = {
- "Vec3:sub",
- "Vec3:mul",
- "Vec3:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to add to x component."
- },
- {
- name = "y",
- type = "number",
- description = "A value to add to y component.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to add to z component.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "angle",
- summary = "Get the angle to another vector.",
- description = "Returns the angle between vectors.",
- key = "Vec3:angle",
- module = "lovr.math",
- 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`.",
- related = {
- "Vec3:distance",
- "Vec3:length"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The angle to the other vector, in radians."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the other vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the other vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the other vector."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The angle to the other vector, in radians."
- }
- }
- }
- }
- },
- {
- name = "cross",
- summary = "Get the cross product with another vector.",
- 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`.",
- key = "Vec3:cross",
- module = "lovr.math",
- notes = "The vectors are not normalized before or after computing the cross product.",
- related = {
- "Vec3:dot"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The vector to compute the cross product with."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to compute cross product with."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to compute cross product with."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to compute cross product with."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "distance",
- summary = "Get the distance to another vector.",
- description = "Returns the distance to another vector.",
- key = "Vec3:distance",
- module = "lovr.math",
- related = {
- "Vec3:angle",
- "Vec3:length"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The vector to measure the distance to."
- }
- },
- returns = {
- {
- name = "distance",
- type = "number",
- description = "The distance to `u`."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to measure distance to."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to measure distance to."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to measure distance to."
- }
- },
- returns = {
- {
- name = "distance",
- type = "number",
- description = "The distance to `u`."
- }
- }
- }
- }
- },
- {
- name = "div",
- summary = "Divides the vector by a vector or a number.",
- description = "Divides the vector by a vector or a number.",
- key = "Vec3:div",
- module = "lovr.math",
- related = {
- "Vec3:add",
- "Vec3:sub",
- "Vec3:mul"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The other vector to divide the components by."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to divide x component by."
- },
- {
- name = "y",
- type = "number",
- description = "A value to divide y component by.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to divide z component by.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "dot",
- summary = "Get the dot product with another vector.",
- description = "Returns the dot product between this vector and another one.",
- key = "Vec3:dot",
- module = "lovr.math",
- 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.",
- related = {
- "Vec3:cross"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The vector to compute the dot product with."
- }
- },
- returns = {
- {
- name = "dot",
- type = "number",
- description = "The dot product between `v` and `u`."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to compute the dot product with."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to compute the dot product with."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to compute the dot product with."
- }
- },
- returns = {
- {
- name = "dot",
- type = "number",
- description = "The dot product between `v` and `u`."
- }
- }
- }
- }
- },
- {
- name = "equals",
- summary = "Check if a vector equals another vector.",
- description = "Returns whether a vector is approximately equal to another vector.",
- key = "Vec3:equals",
- module = "lovr.math",
- notes = "To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`.",
- related = {
- "Vec2:equals",
- "Vec4:equals",
- "Quat:equals",
- "Mat4:equals"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 vectors approximately equal each other."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the other vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the other vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the other vector."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 vectors approximately equal each other."
- }
- }
- }
- }
- },
- {
- name = "length",
- summary = "Get the length of the vector.",
- description = "Returns the length of the vector.",
- key = "Vec3:length",
- module = "lovr.math",
- notes = "The length is equivalent to this:\n\n math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)",
- related = {
- "Vec3:normalize",
- "Vec3:distance"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the vector."
- }
- }
- }
- }
- },
- {
- name = "lerp",
- summary = "Moves this vector some amount towards another one.",
- 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.",
- key = "Vec3:lerp",
- module = "lovr.math",
- related = {
- "Quat:slerp"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The vector to lerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The interpolated vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to lerp towards."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to lerp towards."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to lerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The interpolated vector."
- }
- }
- }
- }
- },
- {
- name = "mul",
- summary = "Multiply the vector by a vector or a number.",
- description = "Multiplies the vector by a vector or a number.",
- key = "Vec3:mul",
- module = "lovr.math",
- related = {
- "Vec3:add",
- "Vec3:sub",
- "Vec3:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The other vector to multiply the components by."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to multiply x component by."
- },
- {
- name = "y",
- type = "number",
- description = "A value to multiply y component by.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to multiply z component by.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "normalize",
- summary = "Normalize the length of the vector to 1.",
- description = "Adjusts the values in the vector so that its direction stays the same but its length becomes 1.",
- key = "Vec3:normalize",
- module = "lovr.math",
- related = {
- "Vec3:length"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The normalized vector."
- }
- }
- }
- }
- },
- {
- name = "rotate",
- summary = "Apply a rotation to the vector.",
- description = "Applies a rotation to the vector, using a `Quat` or an angle/axis rotation.",
- key = "Vec3:rotate",
- module = "lovr.math",
- related = {
- "Quat:mul"
- },
- variants = {
- {
- arguments = {
- {
- name = "q",
- type = "Quat",
- description = "The quaternion to apply."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians to rotate."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis to rotate around."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis to rotate around."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis to rotate around."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "set",
- summary = "Set the components of the vector.",
- description = "Sets the components of the vector, either from numbers or an existing vector.",
- key = "Vec3:set",
- module = "lovr.math",
- related = {
- "Vec3:unpack"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The new x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The new y value of the vector.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "The new z value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The input vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The input vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "q",
- type = "Quat",
- description = "A quat to use the direction of."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The input vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "The matrix to use the position of."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec3",
- description = "The input vector."
- }
- }
- }
- }
- },
- {
- name = "sub",
- summary = "Subtract a vector or a number from the vector.",
- description = "Subtracts a vector or a number from the vector.",
- key = "Vec3:sub",
- module = "lovr.math",
- related = {
- "Vec3:add",
- "Vec3:mul",
- "Vec3:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec3",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to subtract from x component."
- },
- {
- name = "y",
- type = "number",
- description = "A value to subtract from y component.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to subtract from z component.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "transform",
- summary = "Apply a transform to the vector.",
- 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.",
- key = "Vec3:transform",
- module = "lovr.math",
- related = {
- "Mat4:mul",
- "Vec4:transform",
- "Vec3:rotate"
- },
- variants = {
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "The matrix to apply."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The original vector, with transformed components."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale factor.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians to rotate around the rotation axis.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The original vector, with transformed components."
- }
- }
- },
- {
- arguments = {
- {
- name = "translation",
- type = "Vec3",
- description = "The translation to apply."
- },
- {
- name = "scale",
- type = "number",
- description = "The scale factor.",
- default = "1"
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation to apply."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec3",
- description = "The original vector, with transformed components."
- }
- }
- }
- }
- },
- {
- name = "unpack",
- summary = "Get the components of the vector.",
- description = "Returns the 3 components of the vector as numbers.",
- key = "Vec3:unpack",
- module = "lovr.math",
- related = {
- "Vec3:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x value."
- },
- {
- name = "y",
- type = "number",
- description = "The y value."
- },
- {
- name = "z",
- type = "number",
- description = "The z value."
- }
- }
- }
- }
- }
- },
- related = {
- "Vec2",
- "Vec4",
- "Vectors"
- }
- },
- {
- name = "Vec4",
- summary = "A 4D vector.",
- description = "A vector object that holds four numbers.",
- key = "Vec4",
- module = "lovr.math",
- constructors = {
- "lovr.math.newVec4",
- "lovr.math.vec4"
- },
- methods = {
- {
- name = "add",
- summary = "Add a vector or a number to the vector.",
- description = "Adds a vector or a number to the vector.",
- key = "Vec4:add",
- module = "lovr.math",
- related = {
- "Vec4:sub",
- "Vec4:mul",
- "Vec4:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to add to x component."
- },
- {
- name = "y",
- type = "number",
- description = "A value to add to y component.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to add to z component.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "A value to add to w component.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "angle",
- summary = "Get the angle to another vector.",
- description = "Returns the angle between vectors.",
- key = "Vec4:angle",
- module = "lovr.math",
- 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`.",
- related = {
- "Vec4:distance",
- "Vec4:length"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The angle to other vector, in radians."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the other vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the other vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the other vector."
- },
- {
- name = "w",
- type = "number",
- description = "The w component of the other vector."
- }
- },
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The angle to other vector, in radians."
- }
- }
- }
- }
- },
- {
- name = "distance",
- summary = "Get the distance to another vector.",
- description = "Returns the distance to another vector.",
- key = "Vec4:distance",
- module = "lovr.math",
- related = {
- "Vec4:angle",
- "Vec4:length"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The vector to measure the distance to."
- }
- },
- returns = {
- {
- name = "distance",
- type = "number",
- description = "The distance to `u`."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to measure distance to."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to measure distance to."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to measure distance to."
- },
- {
- name = "w",
- type = "number",
- description = "A value of w component to measure distance to."
- }
- },
- returns = {
- {
- name = "distance",
- type = "number",
- description = "The distance to `u`."
- }
- }
- }
- }
- },
- {
- name = "div",
- summary = "Divides the vector by a vector or a number.",
- description = "Divides the vector by a vector or a number.",
- key = "Vec4:div",
- module = "lovr.math",
- related = {
- "Vec4:add",
- "Vec4:sub",
- "Vec4:mul"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The other vector to divide the components by."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to divide x component by."
- },
- {
- name = "y",
- type = "number",
- description = "A value to divide y component by.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to divide z component by.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "A value to divide w component by.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "dot",
- summary = "Get the dot product with another vector.",
- description = "Returns the dot product between this vector and another one.",
- key = "Vec4:dot",
- module = "lovr.math",
- 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.",
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The vector to compute the dot product with."
- }
- },
- returns = {
- {
- name = "dot",
- type = "number",
- description = "The dot product between `v` and `u`."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to compute the dot product with."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to compute the dot product with."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to compute the dot product with."
- },
- {
- name = "w",
- type = "number",
- description = "A value of w component to compute the dot product with."
- }
- },
- returns = {
- {
- name = "dot",
- type = "number",
- description = "The dot product between `v` and `u`."
- }
- }
- }
- }
- },
- {
- name = "equals",
- summary = "Check if a vector equals another vector.",
- description = "Returns whether a vector is approximately equal to another vector.",
- key = "Vec4:equals",
- module = "lovr.math",
- notes = "To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`.",
- related = {
- "Vec2:equals",
- "Vec3:equals",
- "Quat:equals",
- "Mat4:equals"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 vectors approximately equal each other."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the other vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the other vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the other vector."
- },
- {
- name = "w",
- type = "number",
- description = "The w component of the other vector."
- }
- },
- returns = {
- {
- name = "equal",
- type = "boolean",
- description = "Whether the 2 vectors approximately equal each other."
- }
- }
- }
- }
- },
- {
- name = "length",
- summary = "Get the length of the vector.",
- description = "Returns the length of the vector.",
- key = "Vec4:length",
- module = "lovr.math",
- 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)",
- related = {
- "Vec4:normalize",
- "Vec4:distance"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the vector."
- }
- }
- }
- }
- },
- {
- name = "lerp",
- summary = "Moves this vector some amount towards another one.",
- 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.",
- key = "Vec4:lerp",
- module = "lovr.math",
- related = {
- "Quat:slerp"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The vector to lerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The interpolated vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value of x component to lerp towards."
- },
- {
- name = "y",
- type = "number",
- description = "A value of y component to lerp towards."
- },
- {
- name = "z",
- type = "number",
- description = "A value of z component to lerp towards."
- },
- {
- name = "w",
- type = "number",
- description = "A value of w component to lerp towards."
- },
- {
- name = "t",
- type = "number",
- description = "The lerping parameter."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The interpolated vector."
- }
- }
- }
- }
- },
- {
- name = "mul",
- summary = "Multiply the vector by a vector or a number.",
- description = "Multiplies the vector by a vector or a number.",
- key = "Vec4:mul",
- module = "lovr.math",
- related = {
- "Vec4:add",
- "Vec4:sub",
- "Vec4:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The other vector to multiply the components by."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to multiply x component by."
- },
- {
- name = "y",
- type = "number",
- description = "A value to multiply y component by.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to multiply z component by.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "A value to multiply w component by.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "normalize",
- summary = "Normalize the length of the vector to 1.",
- description = "Adjusts the values in the vector so that its direction stays the same but its length becomes 1.",
- key = "Vec4:normalize",
- module = "lovr.math",
- related = {
- "Vec4:length"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The normalized vector."
- }
- }
- }
- }
- },
- {
- name = "set",
- summary = "Set the components of the vector.",
- description = "Sets the components of the vector, either from numbers or an existing vector.",
- key = "Vec4:set",
- module = "lovr.math",
- related = {
- "Vec4:unpack"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The new x value of the vector.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The new y value of the vector.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "The new z value of the vector.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "The new w value of the vector.",
- default = "x"
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec4",
- description = "The input vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The vector to copy the values from."
- }
- },
- returns = {
- {
- name = "v",
- type = "Vec4",
- description = "The input vector."
- }
- }
- }
- }
- },
- {
- name = "sub",
- summary = "Subtract a vector or a number from the vector.",
- description = "Subtracts a vector or a number from the vector.",
- key = "Vec4:sub",
- module = "lovr.math",
- related = {
- "Vec4:add",
- "Vec4:mul",
- "Vec4:div"
- },
- variants = {
- {
- arguments = {
- {
- name = "u",
- type = "Vec4",
- description = "The other vector."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "A value to subtract from x component."
- },
- {
- name = "y",
- type = "number",
- description = "A value to subtract from y component.",
- default = "x"
- },
- {
- name = "z",
- type = "number",
- description = "A value to subtract from z component.",
- default = "x"
- },
- {
- name = "w",
- type = "number",
- description = "A value to subtract from w component.",
- default = "x"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The modified vector."
- }
- }
- }
- }
- },
- {
- name = "transform",
- summary = "Apply a transform to the vector.",
- 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.",
- key = "Vec4:transform",
- module = "lovr.math",
- related = {
- "Mat4:mul",
- "Vec3:transform"
- },
- variants = {
- {
- arguments = {
- {
- name = "m",
- type = "Mat4",
- description = "The matrix to apply."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The original vector, with transformed components."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the translation.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the translation.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the translation.",
- default = "0"
- },
- {
- name = "scale",
- type = "number",
- description = "The scale factor.",
- default = "1"
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians to rotate around the rotation axis.",
- default = "0"
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation.",
- default = "0"
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation.",
- default = "1"
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation.",
- default = "0"
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The original vector, with transformed components."
- }
- }
- },
- {
- arguments = {
- {
- name = "translation",
- type = "Vec3",
- description = "The translation to apply."
- },
- {
- name = "scale",
- type = "number",
- description = "The scale factor.",
- default = "1"
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The rotation to apply."
- }
- },
- returns = {
- {
- name = "self",
- type = "Vec4",
- description = "The original vector, with transformed components."
- }
- }
- }
- }
- },
- {
- name = "unpack",
- summary = "Get the components of the vector.",
- description = "Returns the 4 components of the vector as numbers.",
- key = "Vec4:unpack",
- module = "lovr.math",
- related = {
- "Vec4:set"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x value."
- },
- {
- name = "y",
- type = "number",
- description = "The y value."
- },
- {
- name = "z",
- type = "number",
- description = "The z value."
- },
- {
- name = "w",
- type = "number",
- description = "The w value."
- }
- }
- }
- }
- }
- },
- related = {
- "Vec2",
- "Vec3",
- "Vectors"
- }
- },
- {
- name = "Vectors",
- summary = "What is your vector victor.",
- 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.",
- key = "Vectors",
- module = "lovr.math",
- constructors = {
- "lovr.math.vec2",
- "lovr.math.vec3",
- "lovr.math.vec4",
- "lovr.math.quat",
- "lovr.math.mat4",
- "lovr.math.newVec2",
- "lovr.math.newVec3",
- "lovr.math.newVec4",
- "lovr.math.newQuat",
- "lovr.math.newMat4"
- },
- methods = {},
- 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)"
- }
- },
- sections = {
- {
- name = "Randomization",
- tag = "random",
- description = "Functions for generating random numbers and noise."
- },
- {
- name = "Vectors",
- tag = "vectors",
- description = "A collection of vector objects. Check out the `Vectors` guide for an introduction."
- },
- {
- name = "Other",
- tag = "mathOther",
- description = "Other miscellaneous math objects/helpers."
- }
- }
- },
- {
- name = "physics",
- tag = "modules",
- summary = "Simulates 3D physics.",
- description = "The `lovr.physics` module simulates 3D rigid body physics.",
- key = "lovr.physics",
- enums = {
- {
- name = "JointType",
- summary = "Types of physics joints.",
- description = "Represents the different types of physics Joints available.",
- key = "JointType",
- module = "lovr.physics",
- related = {
- "Joint",
- "BallJoint",
- "DistanceJoint",
- "HingeJoint",
- "SliderJoint"
- },
- values = {
- {
- name = "ball",
- description = "A BallJoint."
- },
- {
- name = "distance",
- description = "A DistanceJoint."
- },
- {
- name = "hinge",
- description = "A HingeJoint."
- },
- {
- name = "slider",
- description = "A SliderJoint."
- }
- }
- },
- {
- name = "MotorMode",
- summary = "The different states for joint motors.",
- description = "The different ways the motor on a joint can be used.",
- key = "MotorMode",
- module = "lovr.physics",
- related = {
- "HingeJoint:setMotorMode",
- "SliderJoint:setMotorMode"
- },
- values = {
- {
- name = "position",
- description = "The motor drives to a particular value."
- },
- {
- name = "velocity",
- description = "The motor drives to a particular speed."
- }
- }
- },
- {
- name = "ShapeType",
- summary = "Types of physics shapes.",
- description = "Represents the different types of physics Shapes available.",
- key = "ShapeType",
- module = "lovr.physics",
- related = {
- "Shape",
- "BoxShape",
- "SphereShape",
- "CapsuleShape",
- "CylinderShape",
- "ConvexShape",
- "MeshShape",
- "TerrainShape"
- },
- values = {
- {
- name = "box",
- description = "A box."
- },
- {
- name = "sphere",
- description = "A sphere."
- },
- {
- name = "capsule",
- description = "A capsule (cylinder with rounded ends)."
- },
- {
- name = "cylinder",
- description = "A cylinder."
- },
- {
- name = "convex",
- description = "A convex hull."
- },
- {
- name = "mesh",
- description = "A triangle mesh. Colliders with this shape can not move."
- },
- {
- name = "terrain",
- description = "A heightfield. Colliders with this shape can not move."
- }
- }
- }
- },
- functions = {
- {
- name = "newBallJoint",
- summary = "Create a new BallJoint.",
- description = "Creates a new BallJoint.",
- key = "lovr.physics.newBallJoint",
- module = "lovr.physics",
- 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.\n\nIf the anchor is nil, the position of the first Collider is the anchor. If the first collider is nil, then the position of the second Collider is the anchor.",
- related = {
- "lovr.physics.newConeJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newSliderJoint",
- "lovr.physics.newWeldJoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "x",
- type = "number",
- description = "The x position of the joint anchor point, in world coordinates."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the joint anchor point, in world coordinates."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the joint anchor point, in world coordinates."
- }
- },
- returns = {
- {
- name = "ball",
- type = "BallJoint",
- description = "The new BallJoint."
- }
- }
- },
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "anchor",
- type = "Vec3",
- description = "The joint anchor point, in world coordinates."
- }
- },
- returns = {
- {
- name = "ball",
- type = "BallJoint",
- description = "The new BallJoint."
- }
- }
- }
- }
- },
- {
- name = "newBoxShape",
- summary = "Create a new BoxShape.",
- description = "Creates a new BoxShape.",
- key = "lovr.physics.newBoxShape",
- module = "lovr.physics",
- notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
- related = {
- "BoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape"
- },
- variants = {
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the box, in meters.",
- default = "1"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box, in meters.",
- default = "width"
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box, in meters.",
- default = "width"
- }
- },
- returns = {
- {
- name = "box",
- type = "BoxShape",
- description = "The new BoxShape."
- }
- }
- }
- }
- },
- {
- name = "newCapsuleShape",
- summary = "Create a new CapsuleShape.",
- description = "Creates a new CapsuleShape. Capsules are cylinders with hemispheres on each end.",
- key = "lovr.physics.newCapsuleShape",
- module = "lovr.physics",
- notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
- related = {
- "CapsuleShape",
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape"
- },
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule, in meters.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the capsule, not including the caps, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "capsule",
- type = "CapsuleShape",
- description = "The new CapsuleShape."
- }
- }
- }
- }
- },
- {
- name = "newConeJoint",
- summary = "Create a new ConeJoint.",
- description = "Creates a new ConeJoint.",
- key = "lovr.physics.newConeJoint",
- module = "lovr.physics",
- notes = "A ConeJoint is similar to a BallJoint, where the relative position between the colliders will be constrained to a single point. However, the ConeJoint also limits the rotation away from the cone axis. This can be useful for limb joints, ropes, etc.\n\nIf the anchor is nil, the position of the first Collider is the anchor. If the first Collider is nil, the position of the second collider is the anchor.\n\nIf the axis is nil, it defaults to the direction between the anchor and the second Collider.",
- related = {
- "lovr.physics.newWeldJoint",
- "lovr.physics.newBallJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newSliderJoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "x",
- type = "number",
- description = "The x position of the joint anchor point, in world space."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the joint anchor point, in world space."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the joint anchor point, in world space."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the cone axis, in world space."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the cone axis, in world space."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the cone axis, in world space."
- }
- },
- returns = {
- {
- name = "cone",
- type = "ConeJoint",
- description = "The new ConeJoint."
- }
- }
- },
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "anchor",
- type = "Vec3",
- description = "The joint anchor point, in world space."
- },
- {
- name = "axis",
- type = "Vec3",
- description = "The cone axis, in world space."
- }
- },
- returns = {
- {
- name = "cone",
- type = "ConeJoint",
- description = "The new ConeJoint."
- }
- }
- }
- }
- },
- {
- name = "newConvexShape",
- summary = "Create a new ConvexShape.",
- description = "Creates a new ConvexShape.",
- key = "lovr.physics.newConvexShape",
- module = "lovr.physics",
- related = {
- "ConvexShape",
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape"
- },
- variants = {
- {
- arguments = {
- {
- name = "points",
- type = "table",
- description = "A list of vertices to compute a convex hull from. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D point)."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "shape",
- type = "ConvexShape",
- description = "The new ConvexShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "modelData",
- type = "ModelData",
- description = "The ModelData to compute a convex hull from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "shape",
- type = "ConvexShape",
- description = "The new ConvexShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "model",
- type = "Model",
- description = "The Model to compute a convex hull from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "shape",
- type = "ConvexShape",
- description = "The new ConvexShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The Mesh to compute a convex hull from. It must use the `cpu` storage mode."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "shape",
- type = "ConvexShape",
- description = "The new ConvexShape."
- }
- }
- },
- {
- description = "Clones an existing ConvexShape, which is faster than passing the same points multiple times. Clones can have their own scale. The clone's scale doesn't get multiplied with the scale of the template.",
- arguments = {
- {
- name = "template",
- type = "ConvexShape",
- description = "An existing ConvexShape to clone."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "shape",
- type = "ConvexShape",
- description = "The new ConvexShape."
- }
- }
- }
- }
- },
- {
- name = "newCylinderShape",
- summary = "Create a new CylinderShape.",
- description = "Creates a new CylinderShape.",
- key = "lovr.physics.newCylinderShape",
- module = "lovr.physics",
- notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
- related = {
- "CylinderShape",
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape"
- },
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder, in meters.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cylinder, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "cylinder",
- type = "CylinderShape",
- description = "The new CylinderShape."
- }
- }
- }
- }
- },
- {
- name = "newDistanceJoint",
- summary = "Create a new DistanceJoint.",
- description = "Creates a new DistanceJoint.",
- key = "lovr.physics.newDistanceJoint",
- module = "lovr.physics",
- 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.\n\nIf no anchors are given, they default to the positions of the Colliders.",
- related = {
- "lovr.physics.newBallJoint",
- "lovr.physics.newConeJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newSliderJoint",
- "lovr.physics.newWeldJoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "x1",
- type = "number",
- description = "The x position of the first anchor point, in world coordinates."
- },
- {
- name = "y1",
- type = "number",
- description = "The y position of the first anchor point, in world coordinates."
- },
- {
- name = "z1",
- type = "number",
- description = "The z position of the first anchor point, in world coordinates."
- },
- {
- name = "x2",
- type = "number",
- description = "The x position of the second anchor point, in world coordinates."
- },
- {
- name = "y2",
- type = "number",
- description = "The y position of the second anchor point, in world coordinates."
- },
- {
- name = "z2",
- type = "number",
- description = "The z position of the second anchor point, in world coordinates."
- }
- },
- returns = {
- {
- name = "joint",
- type = "DistanceJoint",
- description = "The new DistanceJoint."
- }
- }
- },
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "first",
- type = "Vec3",
- description = "The first anchor point, in world coordinates."
- },
- {
- name = "second",
- type = "Vec3",
- description = "The second anchor point, in world coordinates."
- }
- },
- returns = {
- {
- name = "joint",
- type = "DistanceJoint",
- description = "The new DistanceJoint."
- }
- }
- }
- }
- },
- {
- name = "newHingeJoint",
- summary = "Create a new HingeJoint.",
- description = "Creates a new HingeJoint.",
- key = "lovr.physics.newHingeJoint",
- module = "lovr.physics",
- notes = "A hinge joint constrains two colliders to allow rotation only around the hinge's axis.\n\nIf the anchor is nil, the position of the first Collider is the anchor. If the first Collider is nil, the position of the second collider is the anchor.\n\nIf the axis is nil, it defaults to the direction between the anchor and the second Collider.",
- related = {
- "lovr.physics.newBallJoint",
- "lovr.physics.newConeJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newSliderJoint",
- "lovr.physics.newWeldJoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "x",
- type = "number",
- description = "The x position of the hinge anchor, in world coordinates."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the hinge anchor, in world coordinates."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the hinge anchor, in world coordinates."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the hinge axis direction."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the hinge axis direction."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the hinge axis direction."
- }
- },
- returns = {
- {
- name = "hinge",
- type = "HingeJoint",
- description = "The new HingeJoint."
- }
- }
- },
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "anchor",
- type = "Vec3",
- description = "The anchor point, in world coordinates."
- },
- {
- name = "axis",
- type = "Vec3",
- description = "The hinge axis direction."
- }
- },
- returns = {
- {
- name = "hinge",
- type = "HingeJoint",
- description = "The new HingeJoint."
- }
- }
- }
- }
- },
- {
- name = "newMeshShape",
- summary = "Create a new MeshShape.",
- description = "Creates a new MeshShape.",
- key = "lovr.physics.newMeshShape",
- module = "lovr.physics",
- related = {
- "MeshShape",
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newTerrainShape",
- "Model:getTriangles"
- },
- variants = {
- {
- arguments = {
- {
- name = "vertices",
- type = "table",
- description = "The table of vertices in the mesh. Each vertex is a table with 3 numbers."
- },
- {
- name = "indices",
- type = "table",
- description = "A table of triangle indices representing how the vertices are connected in the Mesh."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the mesh vertices.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "MeshShape",
- description = "The new MeshShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "modelData",
- type = "ModelData",
- description = "The ModelData to use the vertices from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the mesh vertices.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "MeshShape",
- description = "The new MeshShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "model",
- type = "Model",
- description = "A Model to use for the mesh data. Similar to calling `Model:getTriangles` and passing it to this function, but has better performance."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the mesh vertices.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "MeshShape",
- description = "The new MeshShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "mesh",
- type = "Mesh",
- description = "The Mesh to use the vertices from. It must use the `cpu` storage mode."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the mesh vertices.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "MeshShape",
- description = "The new MeshShape."
- }
- }
- },
- {
- description = "Clones an existing MeshShape, which is faster than passing the same mesh multiple times. Clones can have their own scale. The clone's scale doesn't get multiplied with the scale of the template.",
- arguments = {
- {
- name = "template",
- type = "MeshShape",
- description = "An existing MeshShape to clone."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the mesh vertices.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "mesh",
- type = "MeshShape",
- description = "The new MeshShape."
- }
- }
- }
- }
- },
- {
- name = "newSliderJoint",
- summary = "Create a new SliderJoint.",
- description = "Creates a new SliderJoint.",
- key = "lovr.physics.newSliderJoint",
- module = "lovr.physics",
- notes = "A slider joint constrains two colliders to only allow movement along the slider's axis.",
- related = {
- "lovr.physics.newBallJoint",
- "lovr.physics.newConeJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newWeldJoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the slider axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the slider axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the slider axis."
- }
- },
- returns = {
- {
- name = "slider",
- type = "SliderJoint",
- description = "The new SliderJoint."
- }
- }
- },
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- },
- {
- name = "axis",
- type = "Vec3",
- description = "The slider axis direction."
- }
- },
- returns = {
- {
- name = "slider",
- type = "SliderJoint",
- description = "The new SliderJoint."
- }
- }
- }
- }
- },
- {
- name = "newSphereShape",
- summary = "Create a new SphereShape.",
- description = "Creates a new SphereShape.",
- key = "lovr.physics.newSphereShape",
- module = "lovr.physics",
- notes = "A Shape can be attached to a Collider using `Collider:addShape`.",
- related = {
- "SphereShape",
- "lovr.physics.newBoxShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape"
- },
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "sphere",
- type = "SphereShape",
- description = "The new SphereShape."
- }
- }
- }
- }
- },
- {
- name = "newTerrainShape",
- summary = "Create a new TerrainShape.",
- description = "Creates a new TerrainShape.",
- key = "lovr.physics.newTerrainShape",
- module = "lovr.physics",
- notes = "A Shape can be attached to a Collider using `Collider:addShape`. For immobile terrain use the `Collider:setKinematic`.",
- related = {
- "TerrainShape",
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.data.newImage"
- },
- variants = {
- {
- description = "Create a flat floor collider.",
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The width and depth of the terrain, in meters."
- }
- },
- returns = {
- {
- name = "terrain",
- type = "TerrainShape",
- description = "The new TerrainShape."
- }
- }
- },
- {
- description = "Create terrain from a heightmap image.",
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The width and depth of the terrain, in meters."
- },
- {
- name = "heightmap",
- type = "Image",
- description = "A heightmap image describing the terrain elevation at different points. The red channel brightness of each pixel determines the elevation at corresponding coordinates."
- },
- {
- name = "stretch",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "terrain",
- type = "TerrainShape",
- description = "The new TerrainShape."
- }
- }
- },
- {
- description = "Create terrain defined with a callback function.",
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The width and depth of the terrain, in meters."
- },
- {
- name = "callback",
- type = "function",
- 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`.",
- arguments = {
- {
- name = "x",
- type = "number"
- },
- {
- name = "z",
- type = "number"
- }
- },
- returns = {
- name = "height",
- type = "number"
- }
- },
- {
- name = "samples",
- type = "number",
- 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.",
- default = "100"
- }
- },
- returns = {
- {
- name = "terrain",
- type = "TerrainShape",
- description = "The new TerrainShape."
- }
- }
- }
- }
- },
- {
- name = "newWeldJoint",
- summary = "Create a new WeldJoint.",
- description = "Creates a new WeldJoint.",
- key = "lovr.physics.newWeldJoint",
- module = "lovr.physics",
- notes = "The joint will try to keep the Colliders in the relative pose they were at when the joint was created.",
- related = {
- "lovr.physics.newBallJoint",
- "lovr.physics.newConeJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newSliderJoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first collider to attach the Joint to, or `nil` to attach the joint to a fixed position in the World."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second collider to attach the Joint to."
- }
- },
- returns = {
- {
- name = "joint",
- type = "WeldJoint",
- description = "The new WeldJoint."
- }
- }
- }
- }
- },
- {
- name = "newWorld",
- summary = "Create a new World.",
- description = "Creates a new physics World.",
- key = "lovr.physics.newWorld",
- module = "lovr.physics",
- related = {
- "World:update"
- },
- variants = {
- {
- arguments = {
- {
- name = "settings",
- type = "table",
- description = "An optional table with settings for the physics simulation.",
- table = {
- {
- name = "tags",
- type = "table",
- description = "The list of collision tags (strings). Colliders can be assigned a tag, and collision can be enabled and disabled between different tags. There is a maximum of 31 tags.",
- default = "{}"
- },
- {
- name = "staticTags",
- type = "table",
- description = "An optional list of collision tags that are \"static\". Colliders with a static tag will not move, and the physics engine uses this for optimization.",
- default = "{}"
- },
- {
- name = "maxColliders",
- type = "number",
- description = "The maximum number of Colliders in the World. Increasing this will use more memory. This can't be bigger than 2^23 (around 8 million).",
- default = "16384"
- },
- {
- name = "threadSafe",
- type = "boolean",
- description = "Whether the World and the objects it contains can be used from multiple threads. This will use a set of locks to ensure only one thread can access a Collider at a given time. Disable this to potentially get a small performance boost when only using the World from a single Thread.",
- default = "true"
- },
- {
- name = "allowSleep",
- type = "boolean",
- description = "Whether colliders should be allowed to go to sleep when they come to rest. Sleeping colliders don't need to simulate movement until something hits them. This improves performance a lot for a typical physics scene where many objects are at rest.",
- default = "true"
- },
- {
- name = "stabilization",
- type = "number",
- description = "How quickly the physics engine corrects position error from collisions and joints, from 0 to 1. If the value is too low, objects will be spongy, but if it's too high then physics will explode. Values between .2 and .8 are recommended.",
- default = "0.2"
- },
- {
- name = "maxOverlap",
- type = "number",
- description = "The maximum amount that colliders are allowed to overlap, in meters.",
- default = ".01"
- },
- {
- name = "restitutionThreshold",
- type = "number",
- description = "A velocity below which restitution (bounciness) will not be applied, in meters per second. If this is too low then objects may have trouble coming to rest.",
- default = "1.0"
- },
- {
- name = "velocitySteps",
- type = "number",
- description = "The number of solver velocity iterations to run per tick. This must be at least 2. Larger values will increase accuracy but use more CPU.",
- default = "10"
- },
- {
- name = "positionSteps",
- type = "number",
- description = "The number of solver position iterations to run per tick. Larger values will increase accuracy but use more CPU.",
- default = "2"
- }
- }
- }
- },
- returns = {
- {
- name = "world",
- type = "World",
- description = "A whole new World."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "BallJoint",
- summary = "A ball and socket joint.",
- 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.",
- key = "BallJoint",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newBallJoint"
- },
- extends = "Joint",
- methods = {},
- related = {
- "Collider"
- }
- },
- {
- name = "BoxShape",
- summary = "A box Shape.",
- description = "A type of `Shape` that can be used for cubes or boxes.",
- key = "BoxShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newBoxShape",
- "World:newBoxCollider"
- },
- extends = "Shape",
- methods = {
- {
- name = "getDimensions",
- summary = "Get the dimensions of the BoxShape.",
- description = "Returns the width, height, and depth of the BoxShape.",
- key = "BoxShape:getDimensions",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the box, in meters."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box, in meters."
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box, in meters."
- }
- }
- }
- }
- },
- {
- name = "setDimensions",
- summary = "Set the dimensions of the BoxShape.",
- description = "Sets the width, height, and depth of the BoxShape.",
- key = "BoxShape:setDimensions",
- module = "lovr.physics",
- notes = "This changes the mass of the shape. If the shape is attached to a collider with automatic mass enabled, the mass properties of the collider will update as well.\n\nChanging shapes can make the physics engine explode since it can cause objects to overlap in unnatural ways.",
- variants = {
- {
- arguments = {
- {
- name = "width",
- type = "number",
- description = "The width of the box, in meters."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box, in meters."
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box, in meters."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "CapsuleShape",
- summary = "A capsule Shape.",
- description = "A type of `Shape` that can be used for capsule-shaped things.",
- key = "CapsuleShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newCapsuleShape",
- "World:newCapsuleCollider"
- },
- extends = "Shape",
- methods = {
- {
- name = "getLength",
- summary = "Get the length of the CapsuleShape.",
- description = "Returns the length of the CapsuleShape, not including the caps.",
- key = "CapsuleShape:getLength",
- module = "lovr.physics",
- related = {
- "CapsuleShape:getRadius",
- "CapsuleShape:setRadius"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the capsule, in meters."
- }
- }
- }
- }
- },
- {
- name = "getRadius",
- summary = "Get the radius of the CapsuleShape.",
- description = "Returns the radius of the CapsuleShape.",
- key = "CapsuleShape:getRadius",
- module = "lovr.physics",
- related = {
- "CapsuleShape:getLength",
- "CapsuleShape:setLength"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule, in meters."
- }
- }
- }
- }
- },
- {
- name = "setLength",
- summary = "Set the length of the CapsuleShape.",
- description = "Sets the length of the CapsuleShape.",
- key = "CapsuleShape:setLength",
- module = "lovr.physics",
- notes = "This changes the mass of the shape. If the shape is attached to a collider with automatic mass enabled, the mass properties of the collider will update as well.\n\nChanging shapes can make the physics engine explode since it can cause objects to overlap in unnatural ways.",
- related = {
- "CapsuleShape:getRadius",
- "CapsuleShape:setRadius"
- },
- variants = {
- {
- arguments = {
- {
- name = "length",
- type = "number",
- description = "The new length, in meters, not including the caps."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setRadius",
- summary = "Set the radius of the CapsuleShape.",
- description = "Sets the radius of the CapsuleShape.",
- key = "CapsuleShape:setRadius",
- module = "lovr.physics",
- notes = "This changes the mass of the shape. If the shape is attached to a collider with automatic mass enabled, the mass properties of the collider will update as well.\n\nChanging shapes can make the physics engine explode since it can cause objects to overlap in unnatural ways.",
- related = {
- "CapsuleShape:getLength",
- "CapsuleShape:setLength"
- },
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The new radius, in meters."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "Collider",
- summary = "A single object in a physics simulation.",
- description = "Colliders represent a single rigid body in the physics simulation.",
- key = "Collider",
- module = "lovr.physics",
- constructors = {
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- methods = {
- {
- name = "addShape",
- summary = "Add a Shape to the Collider.",
- description = "Attaches a Shape to the collider.",
- key = "Collider:addShape",
- module = "lovr.physics",
- notes = "By default, LÖVR will recompute mass properties for the Collider as shapes are added and removed. Use `Collider:setAutomaticMass` to enable or disable this behavior.\n\nShapes can only be attached to a single Collider. Attempting to attach a shape to multiple colliders (or to a single collider multiple times) will error. Use `Collider:removeShape` to remove shapes from their original collider before reattaching them.\n\nAdding a `MeshShape` or a `TerrainShape` will force the Collider to be immobile. It will immediately become kinematic, and will not move via velocity or forces. However, it can still be repositioned with methods like `Collider:setPosition`.",
- related = {
- "Collider:removeShape",
- "Collider:getShapes",
- "Collider:getShape",
- "Shape"
- },
- variants = {
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to attach."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "applyAngularImpulse",
- summary = "Apply an angular impulse to the Collider.",
- description = "Applies an angular impulse to the Collider.\n\nAn impulse is a single instantaneous push. Impulses are independent of time, and are meant to only be applied once. Use `Collider:applyTorque` for a time-dependent push that happens over multiple frames.",
- key = "Collider:applyAngularImpulse",
- module = "lovr.physics",
- notes = "Kinematic colliders ignore forces.\n\nIf the Collider is asleep, this will wake it up.\n\nImpulses are accumulated and processed during `World:update`.",
- related = {
- "Collider:applyTorque",
- "Collider:applyForce",
- "Collider:applyLinearImpulse"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the world-space impulse vector, in newton meter seconds."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the world-space impulse vector, in newton meter seconds."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the world-space impulse vector, in newton meter seconds."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "impulse",
- type = "Vec3",
- description = "The world-space impulse vector, in newton meter seconds."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "applyForce",
- summary = "Apply a force to the Collider.",
- description = "Applies a force to the Collider.",
- key = "Collider:applyForce",
- module = "lovr.physics",
- notes = "Kinematic colliders ignore forces.\n\nIf the Collider is asleep, this will wake it up.\n\nForces are accumulated and processed during `World:update`.",
- related = {
- "Collider:applyLinearImpulse",
- "Collider:applyTorque",
- "Collider:applyAngularImpulse"
- },
- variants = {
- {
- description = "Apply a force at the center of mass.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the world-space force vector, in newtons."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the world-space force vector, in newtons."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the world-space force vector, in newtons."
- }
- },
- returns = {}
- },
- {
- description = "Apply a force at a custom position.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the world-space force vector, in newtons."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the world-space force vector, in newtons."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the world-space force vector, in newtons."
- },
- {
- name = "px",
- type = "number",
- description = "The x position to apply the force at, in world space."
- },
- {
- name = "py",
- type = "number",
- description = "The y position to apply the force at, in world space."
- },
- {
- name = "pz",
- type = "number",
- description = "The z position to apply the force at, in world space."
- }
- },
- returns = {}
- },
- {
- description = "Apply a force at the center of mass, using vector types.",
- arguments = {
- {
- name = "force",
- type = "Vec3",
- description = "The world-space force vector, in newtons."
- }
- },
- returns = {}
- },
- {
- description = "Apply a force at a custom position, using vector types.",
- arguments = {
- {
- name = "force",
- type = "Vec3",
- description = "The world-space force vector, in newtons."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to apply the force at, in world space."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "applyLinearImpulse",
- summary = "Apply a linear impulse to the Collider.",
- description = "Applies a linear impulse to the Collider.\n\nAn impulse is a single instantaneous push. Impulses are independent of time, and are meant to only be applied once. Use `Collider:applyForce` for a time-dependent push that happens over multiple frames.",
- key = "Collider:applyLinearImpulse",
- module = "lovr.physics",
- notes = "Kinematic colliders ignore forces.\n\nIf the Collider is asleep, this will wake it up.\n\nImpulses are accumulated and processed during `World:update`.",
- related = {
- "Collider:applyForce",
- "Collider:applyTorque",
- "Collider:applyAngularImpulse"
- },
- variants = {
- {
- description = "Apply an impulse at the center of mass.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the world-space impulse vector, in newton seconds."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the world-space impulse vector, in newton seconds."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the world-space impulse vector, in newton seconds."
- }
- },
- returns = {}
- },
- {
- description = "Apply an impulse at a custom position.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the world-space impulse vector, in newton seconds."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the world-space impulse vector, in newton seconds."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the world-space impulse vector, in newton seconds."
- },
- {
- name = "px",
- type = "number",
- description = "The x position to apply the impulse at, in world space."
- },
- {
- name = "py",
- type = "number",
- description = "The y position to apply the impulse at, in world space."
- },
- {
- name = "pz",
- type = "number",
- description = "The z position to apply the impulse at, in world space."
- }
- },
- returns = {}
- },
- {
- description = "Apply an impulse at the center of mass, using vector types.",
- arguments = {
- {
- name = "impulse",
- type = "Vec3",
- description = "The world-space impulse vector, in newton seconds."
- }
- },
- returns = {}
- },
- {
- description = "Apply an impulse at a custom position, using vector types.",
- arguments = {
- {
- name = "impulse",
- type = "Vec3",
- description = "The world-space impulse vector, in newton seconds."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to apply the impulse at, in world space."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "applyTorque",
- summary = "Apply torque to the Collider.",
- description = "Applies torque to the Collider.",
- key = "Collider:applyTorque",
- module = "lovr.physics",
- notes = "Kinematic colliders ignore forces.\n\nIf the Collider is asleep, this will wake it up.\n\nForces are accumulated and processed during `World:update`.",
- related = {
- "Collider:applyAngularImpulse",
- "Collider:applyForce",
- "Collider:applyLinearImpulse"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the world-space torque vector, in newton meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the world-space torque vector, in newton meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the world-space torque vector, in newton meters."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "torque",
- type = "Vec3",
- description = "The world-space torque vector, in newton meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "destroy",
- summary = "Destroy the Collider.",
- description = "Destroys the Collider, removing it from the World and destroying all Shapes and Joints attached to it.",
- key = "Collider:destroy",
- module = "lovr.physics",
- notes = "After a Collider is destroyed, calling methods on it or passing it to a function will throw an error.",
- related = {
- "Collider:isDestroyed",
- "Collider:setEnabled",
- "World:destroy",
- "Shape:destroy",
- "Joint:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "getAABB",
- summary = "Get the Collider's axis aligned bounding box.",
- description = "Returns the world-space axis-aligned bounding box of the Collider, computed from attached shapes.",
- key = "Collider:getAABB",
- module = "lovr.physics",
- related = {
- "Shape:getAABB",
- "World:queryBox"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "minx",
- type = "number",
- description = "The minimum x coordinate of the box."
- },
- {
- name = "maxx",
- type = "number",
- description = "The maximum x coordinate of the box."
- },
- {
- name = "miny",
- type = "number",
- description = "The minimum y coordinate of the box."
- },
- {
- name = "maxy",
- type = "number",
- description = "The maximum y coordinate of the box."
- },
- {
- name = "minz",
- type = "number",
- description = "The minimum z coordinate of the box."
- },
- {
- name = "maxz",
- type = "number",
- description = "The maximum z coordinate of the box."
- }
- }
- }
- }
- },
- {
- name = "getAngularDamping",
- summary = "Get the angular damping of the Collider.",
- description = "Returns the angular damping of the Collider. Angular damping is similar to drag or air resistance, reducing the Collider's angular velocity over time.",
- key = "Collider:getAngularDamping",
- module = "lovr.physics",
- notes = "The default damping is .05, meaning the collider will lose approximately 5% of its angular velocity each second. A damping value of zero means the Collider will not lose velocity over time.",
- related = {
- "Collider:getLinearDamping",
- "Collider:setLinearDamping",
- "Collider:getInertia",
- "Collider:setInertia"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "damping",
- type = "number",
- description = "The angular damping."
- }
- }
- }
- }
- },
- {
- name = "getAngularVelocity",
- summary = "Get the angular velocity of the Collider.",
- description = "Returns the angular velocity of the Collider.",
- key = "Collider:getAngularVelocity",
- module = "lovr.physics",
- related = {
- "Collider:getLinearVelocity",
- "Collider:setLinearVelocity",
- "Collider:applyTorque",
- "Collider:getOrientation",
- "Collider:setOrientation"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x component of the angular velocity."
- },
- {
- name = "vy",
- type = "number",
- description = "The y component of the angular velocity."
- },
- {
- name = "vz",
- type = "number",
- description = "The z component of the angular velocity."
- }
- }
- }
- }
- },
- {
- name = "getAutomaticMass",
- summary = "Get whether automatic mass is enabled.",
- description = "Returns whether automatic mass is enabled for the Collider.\n\nWhen enabled, the Collider's mass, inertia, and center of mass will be recomputed when:\n\n- A shape is added to or removed from the Collider.\n- A shape attached to the Collider changes shape (e.g. `SphereShape:setRadius`).\n- A shape attached to the Collider is moved using `Shape:setOffset`.\n- A shape attached to the Collider changes its density using `Shape:setDensity`.\n\nAdditionally, changing the center of mass of a Collider will automatically update its inertia when automatic mass is enabled.\n\nDisable this to manage the mass properties manually. When automatic mass is disabled, `Collider:resetMassData` can still be used to reset the mass from attached shapes if needed.",
- key = "Collider:getAutomaticMass",
- module = "lovr.physics",
- related = {
- "Collider:resetMassData",
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether automatic mass is enabled."
- }
- }
- }
- }
- },
- {
- name = "getCenterOfMass",
- summary = "Get the Collider's local center of mass.",
- description = "Returns the Collider's center of mass, in the Collider's local coordinate space.",
- key = "Collider:getCenterOfMass",
- module = "lovr.physics",
- notes = "By default, the center of mass of the Collider is kept up to date automatically as the Collider's shapes change. To disable this, use `Collider:setAutomaticMass`.\n\nUse `Collider:resetMassData` to reset the center of mass and other mass properties based on the Collider's shapes.",
- related = {
- "Shape:getCenterOfMass",
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData",
- "Shape:getOffset",
- "Shape:setOffset"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the center of mass."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the center of mass."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the center of mass."
- }
- }
- }
- }
- },
- {
- name = "getDegreesOfFreedom",
- summary = "Get the enabled translation/rotation axes.",
- description = "Get the degrees of freedom of the Collider.",
- key = "Collider:getDegreesOfFreedom",
- module = "lovr.physics",
- notes = "The default state is `xyz` for both translation and rotation.\n\nThe physics engine does not support disabling all degrees of freedom. At least one translation or rotation axis needs to be enabled. To disable all movement for a collider, make it kinematic.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "translation",
- type = "string",
- description = "A string containing the world-space axes the Collider is allowed to move on. The string will have 'x', 'y', and 'z' letters representing which axes are enabled. If no axes are enabled then it will be an empty string."
- },
- {
- name = "rotation",
- type = "string",
- description = "A string containing the world-space axes the Collider is allowed to rotate around. The string will have 'x', 'y', and 'z' letters representing which axes are enabled. If no axes are enabled then it will be an empty string."
- }
- }
- }
- }
- },
- {
- name = "getFriction",
- summary = "Get the friction of the Collider.",
- description = "Returns the friction of the Collider. Friction determines how easy it is for two colliders to slide against each other. Low friction makes it easier for a collider to slide, simulating a smooth surface.",
- key = "Collider:getFriction",
- module = "lovr.physics",
- notes = "The default friction is .2.\n\nWhen two colliders collide, their friction is combined using the geometric mean:\n\n friction = (frictionA * frictionB) ^ .5",
- related = {
- "Contact:getFriction",
- "Contact:setFriction",
- "Collider:getRestitution",
- "Collider:setRestitution"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "friction",
- type = "number",
- description = "The friction of the Collider."
- }
- }
- }
- }
- },
- {
- name = "getGravityScale",
- summary = "Get the gravity scale of the Collider.",
- description = "Returns the gravity scale of the Collider. This is multiplied with the global gravity from the World, so 1.0 is regular gravity, 0.0 will ignore gravity, etc.",
- key = "Collider:getGravityScale",
- module = "lovr.physics",
- related = {
- "World:getGravity",
- "World:setGravity",
- "Collider:getLinearDamping",
- "Collider:setLinearDamping"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "scale",
- type = "number",
- description = "The gravity scale."
- }
- }
- }
- }
- },
- {
- name = "getInertia",
- summary = "Get the inertia of the Collider.",
- description = "Returns the inertia of the Collider.\n\nInertia is kind of like \"angular mass\". Regular mass determines how resistant the Collider is to linear forces (movement), whereas inertia determines how resistant the Collider is to torque (rotation). Colliders with less inertia are more spinny.\n\nIn 3D, inertia is represented by a 3x3 matrix, called a tensor. To make calculations easier, the physics engine stores the inertia using eigenvalue decomposition, splitting the matrix into a diagonal matrix and a rotation. It's complicated!\n\nIn a realistic simulation, mass and inertia follow a linear relationship. If the mass of an object increases, the diagonal part of its inertia should increase proportionally.",
- key = "Collider:getInertia",
- module = "lovr.physics",
- notes = "By default, the inertia of the Collider is kept up to date automatically as the Collider's shapes change. To disable this, use `Collider:setAutomaticMass`.\n\nUse `Collider:resetMassData` to reset the inertia and other mass properties based on the Collider's shapes.\n\nIf the Collider is kinematic or all rotation axes are disabled, this returns zeroes.",
- related = {
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData",
- "Shape:getInertia"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "dx",
- type = "number",
- description = "The x component of the diagonal matrix."
- },
- {
- name = "dy",
- type = "number",
- description = "The y component of the diagonal matrix."
- },
- {
- name = "dz",
- type = "number",
- description = "The z component of the diagonal matrix."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle of the inertia rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the inertia rotation axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the inertia rotation axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the inertia rotation axis."
- }
- }
- }
- }
- },
- {
- name = "getJoints",
- summary = "Get a list of Joints attached to the Collider.",
- description = "Returns a list of Joints attached to the Collider.",
- key = "Collider:getJoints",
- module = "lovr.physics",
- related = {
- "World:getJoints",
- "Joint:getColliders",
- "Joint:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "joints",
- type = "table",
- description = "A list of `Joint` objects attached to the Collider."
- }
- }
- }
- }
- },
- {
- name = "getLinearDamping",
- summary = "Get the linear damping of the Collider.",
- description = "Returns the linear damping of the Collider. Linear damping is similar to drag or air resistance, slowing the Collider down over time.",
- key = "Collider:getLinearDamping",
- module = "lovr.physics",
- notes = "The default damping is .05, meaning the collider will lose approximately 5% of its velocity each second. A damping value of zero means the Collider will not lose velocity over time.",
- related = {
- "Collider:getAngularDamping",
- "Collider:setAngularDamping",
- "Collider:getGravityScale",
- "Collider:setGravityScale"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "damping",
- type = "number",
- description = "The linear damping."
- }
- }
- }
- }
- },
- {
- name = "getLinearVelocity",
- summary = "Get the linear velocity of the Collider.",
- description = "Returns the world-space linear velocity of the center of mass of the Collider, in meters per second.",
- key = "Collider:getLinearVelocity",
- module = "lovr.physics",
- notes = "Currently, velocity is clamped to 500 meters per second to improve stability of the simulation.",
- related = {
- "Collider:applyForce",
- "Collider:getLinearVelocityFromLocalPoint",
- "Collider:getLinearVelocityFromWorldPoint",
- "Collider:getAngularVelocity",
- "Collider:setAngularVelocity",
- "Collider:getPosition",
- "Collider:setPosition"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x component of the velocity."
- },
- {
- name = "vy",
- type = "number",
- description = "The y component of the velocity."
- },
- {
- name = "vz",
- type = "number",
- description = "The z component of the velocity."
- }
- }
- }
- }
- },
- {
- name = "getLinearVelocityFromLocalPoint",
- summary = "Get the linear velocity of a point on the Collider.",
- description = "Returns the linear velocity of a point on the Collider. This includes the velocity of the center of mass plus the angular velocity at that point.",
- key = "Collider:getLinearVelocityFromLocalPoint",
- module = "lovr.physics",
- related = {
- "Collider:getLinearVelocity",
- "Collider:getLinearVelocityFromWorldPoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position in local space."
- },
- {
- name = "y",
- type = "number",
- description = "The y position in local space."
- },
- {
- name = "z",
- type = "number",
- description = "The z position in local space."
- }
- },
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x velocity of the point."
- },
- {
- name = "vy",
- type = "number",
- description = "The y velocity of the point."
- },
- {
- name = "vz",
- type = "number",
- description = "The z velocity of the point."
- }
- }
- },
- {
- arguments = {
- {
- name = "point",
- type = "Vec3",
- description = "The local-space point."
- }
- },
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x velocity of the point."
- },
- {
- name = "vy",
- type = "number",
- description = "The y velocity of the point."
- },
- {
- name = "vz",
- type = "number",
- description = "The z velocity of the point."
- }
- }
- }
- }
- },
- {
- name = "getLinearVelocityFromWorldPoint",
- summary = "Get the linear velocity of the Collider at a world space point.",
- description = "Returns the linear velocity of a point on the Collider. This includes the velocity of the center of mass plus the angular velocity at that point.",
- key = "Collider:getLinearVelocityFromWorldPoint",
- module = "lovr.physics",
- related = {
- "Collider:getLinearVelocity",
- "Collider:getLinearVelocityFromLocalPoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position in world space."
- },
- {
- name = "y",
- type = "number",
- description = "The y position in world space."
- },
- {
- name = "z",
- type = "number",
- description = "The z position in world space."
- }
- },
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x velocity of the point."
- },
- {
- name = "vy",
- type = "number",
- description = "The y velocity of the point."
- },
- {
- name = "vz",
- type = "number",
- description = "The z velocity of the point."
- }
- }
- },
- {
- arguments = {
- {
- name = "point",
- type = "Vec3",
- description = "The world-space point."
- }
- },
- returns = {
- {
- name = "vx",
- type = "number",
- description = "The x velocity of the point."
- },
- {
- name = "vy",
- type = "number",
- description = "The y velocity of the point."
- },
- {
- name = "vz",
- type = "number",
- description = "The z velocity of the point."
- }
- }
- }
- }
- },
- {
- name = "getLocalPoint",
- summary = "Transform a point from world space to collider space.",
- description = "Transforms a point from world coordinates into local coordinates relative to the Collider.",
- key = "Collider:getLocalPoint",
- module = "lovr.physics",
- related = {
- "Collider:getWorldPoint",
- "Collider:getLocalVector",
- "Collider:getWorldVector"
- },
- variants = {
- {
- arguments = {
- {
- name = "wx",
- type = "number",
- description = "The x component of the world point."
- },
- {
- name = "wy",
- type = "number",
- description = "The y component of the world point."
- },
- {
- name = "wz",
- type = "number",
- description = "The z component of the world point."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the local point."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the local point."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the local point."
- }
- }
- },
- {
- arguments = {
- {
- name = "point",
- type = "Vec3",
- description = "The world point."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the local point."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the local point."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the local point."
- }
- }
- }
- }
- },
- {
- name = "getLocalVector",
- summary = "Transform a vector from world space to local space.",
- description = "Transforms a direction vector from world space to local space.",
- key = "Collider:getLocalVector",
- module = "lovr.physics",
- related = {
- "Collider:getWorldVector",
- "Collider:getLocalPoint",
- "Collider:getWorldPoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "wx",
- type = "number",
- description = "The x component of the world vector."
- },
- {
- name = "wy",
- type = "number",
- description = "The y component of the world vector."
- },
- {
- name = "wz",
- type = "number",
- description = "The z component of the world vector."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the local vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the local vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the local vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "vector",
- type = "Vec3",
- description = "The world vector."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the local vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the local vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the local vector."
- }
- }
- }
- }
- },
- {
- name = "getMass",
- summary = "Get the mass of the Collider.",
- description = "Returns the mass of the Collider.\n\nThe relative mass of colliders determines how they react when they collide. A heavier collider has more momentum than a lighter collider moving the same speed, and will impart more force on the lighter collider.\n\nMore generally, heavier colliders react less to forces they receive, including forces applied with functions like `Collider:applyForce`.\n\nColliders with higher mass do not fall faster. Use `Collider:setLinearDamping` to give a collider drag to make it fall slower or `Collider:setGravityScale` to change the way it reacts to gravity.",
- key = "Collider:getMass",
- module = "lovr.physics",
- notes = "By default, the mass of the Collider will be kept up to date automatically as shapes are added and removed from the Collider (or if the shapes change size or density). Use `Collider:setAutomaticMass` to customize this.\n\nMass can be overridden with `Collider:setMass`, or recomputed from the attached shapes with `Collider:resetMassData`.\n\nIf the Collider is kinematic or all translation axes are disabled, this returns 0.",
- related = {
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData",
- "Shape:getDensity",
- "Shape:setDensity",
- "Shape:getVolume",
- "Shape:getMass"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mass",
- type = "number",
- description = "The mass of the Collider, in kilograms."
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- summary = "Get the orientation of the Collider.",
- description = "Returns the orientation of the Collider in angle/axis representation.",
- key = "Collider:getOrientation",
- module = "lovr.physics",
- notes = "If `World:interpolate` has been called, this returns an interpolated orientation between the last two physics updates.",
- related = {
- "Collider:applyTorque",
- "Collider:getAngularVelocity",
- "Collider:setAngularVelocity",
- "Collider:getPosition",
- "Collider:setPosition",
- "Collider:getPose",
- "Collider:setPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Collider is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- summary = "Get the pose of the Collider.",
- description = "Returns the position and orientation of the Collider.",
- key = "Collider:getPose",
- module = "lovr.physics",
- notes = "If `World:interpolate` has been called, this returns an interpolated pose between the last two physics updates.",
- related = {
- "Collider:getPosition",
- "Collider:getOrientation"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Collider, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Collider, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Collider, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Collider is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- summary = "Get the position of the Collider.",
- description = "Returns the position of the Collider.",
- key = "Collider:getPosition",
- module = "lovr.physics",
- notes = "If `World:interpolate` has been called, this returns an interpolated position between the last two physics updates.",
- related = {
- "Collider:applyForce",
- "Collider:getLinearVelocity",
- "Collider:setLinearVelocity",
- "Collider:getOrientation",
- "Collider:setOrientation",
- "Collider:getPose",
- "Collider:setPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Collider, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Collider, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Collider, in meters."
- }
- }
- }
- }
- },
- {
- name = "getRestitution",
- summary = "Get the bounciness of the Collider.",
- description = "Returns the restitution of the Collider. Restitution makes a Collider bounce when it collides with other objects. A restitution value of zero would result in an inelastic collision response, whereas 1.0 would result in an elastic collision that preserves all of the velocity. The restitution can be bigger than 1.0 to make the collision even more bouncy.",
- key = "Collider:getRestitution",
- module = "lovr.physics",
- notes = "To improve stability of the simulation and allow colliders to come to rest, restitution is only applied if the collider is moving above a certain speed. This can be configured using the `restitutionThreshold` option in `lovr.physics.newWorld`.",
- related = {
- "Contact:getRestitution",
- "Contact:setRestitution",
- "Collider:getFriction",
- "Collider:setFriction"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "restitution",
- type = "number",
- description = "The restitution of the Collider."
- }
- }
- }
- }
- },
- {
- name = "getShape",
- summary = "Get the first Shape attached to the Collider.",
- description = "Returns a Shape attached to the Collider.\n\nFor the common case where a Collider only has a single shape, this is more convenient and efficient than extracting it from the table returned by `Collider:getShapes`. It is always equivalent to `Collider:getShapes()[1]`.",
- key = "Collider:getShape",
- module = "lovr.physics",
- examples = {
- {
- code = "function drawBoxCollider(pass, collider)\n local position = vec3(collider:getPosition())\n local size = vec3(collider:getShape():getDimensions())\n local orientation = quat(collider:getOrientation())\n pass:box(position, size, orientation)\nend"
- }
- },
- notes = "This may return `nil` if the Collider doesn't have any shapes attached to it.",
- related = {
- "Collider:getShapes",
- "Collider:addShape",
- "Collider:removeShape",
- "Shape"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "shape",
- type = "Shape",
- description = "One of the `Shape` objects attached to the Collider."
- }
- }
- }
- }
- },
- {
- name = "getShapes",
- summary = "Get a list of Shapes attached to the Collider.",
- description = "Returns a list of Shapes attached to the Collider.",
- key = "Collider:getShapes",
- module = "lovr.physics",
- related = {
- "Collider:getShape",
- "Collider:addShape",
- "Collider:removeShape",
- "Shape"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "shapes",
- type = "table",
- description = "A list of `Shape` objects attached to the Collider."
- }
- }
- }
- }
- },
- {
- name = "getTag",
- summary = "Get the Collider's tag.",
- description = "Returns the Collider's tag.\n\nTags are strings that represent the category of a collider. Use `World:enableCollisionBetween` and `World:disableCollisionBetween` to control which pairs of tags should collide with each other. Physics queries like `World:raycast` also use tags to filter their results.\n\nThe list of available tags is set in `lovr.physics.newWorld`.",
- key = "Collider:getTag",
- module = "lovr.physics",
- related = {
- "World:getTags",
- "World:disableCollisionBetween",
- "World:enableCollisionBetween",
- "World:isCollisionEnabledBetween",
- "lovr.physics.newWorld"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "tag",
- type = "string",
- description = "The Collider's tag."
- }
- }
- }
- }
- },
- {
- name = "getUserData",
- summary = "Get the Lua value associated with the Collider.",
- description = "Returns the Lua value associated with the Collider.",
- key = "Collider:getUserData",
- module = "lovr.physics",
- notes = "The userdata is useful for linking a Collider with custom data:\n\n local collider = world:raycast(origin, direction, 'enemy')\n\n if collider then\n -- Get the enemy object from its Collider\n local enemy = collider:getUserData()\n enemy.health = 0\n end\n\nThe user data is not shared between threads. Each thread has its own user data for the Collider.",
- related = {
- "Shape:getUserData",
- "Shape:setUserData",
- "Joint:getUserData",
- "Joint:setUserData"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "data",
- type = "*",
- description = "The custom value associated with the Collider."
- }
- }
- }
- }
- },
- {
- name = "getWorld",
- summary = "Get the World the Collider is in.",
- description = "Returns the World the Collider is in.",
- key = "Collider:getWorld",
- module = "lovr.physics",
- notes = "Colliders can only ever be in the World that created them.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "world",
- type = "World",
- description = "The World the Collider is in."
- }
- }
- }
- }
- },
- {
- name = "getWorldPoint",
- summary = "Transform a point from local space to world space.",
- description = "Transforms a local point relative to the collider to a point in world coordinates.",
- key = "Collider:getWorldPoint",
- module = "lovr.physics",
- related = {
- "Collider:getLocalPoint",
- "Collider:getLocalVector",
- "Collider:getWorldVector"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the local point."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the local point."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the local point."
- }
- },
- returns = {
- {
- name = "wx",
- type = "number",
- description = "The x component of the world point."
- },
- {
- name = "wy",
- type = "number",
- description = "The y component of the world point."
- },
- {
- name = "wz",
- type = "number",
- description = "The z component of the world point."
- }
- }
- },
- {
- arguments = {
- {
- name = "point",
- type = "Vec3",
- description = "The local point."
- }
- },
- returns = {
- {
- name = "wx",
- type = "number",
- description = "The x component of the world point."
- },
- {
- name = "wy",
- type = "number",
- description = "The y component of the world point."
- },
- {
- name = "wz",
- type = "number",
- description = "The z component of the world point."
- }
- }
- }
- }
- },
- {
- name = "getWorldVector",
- summary = "Transform a vector from local space to world space.",
- description = "Transforms a direction vector from local space to world space.",
- key = "Collider:getWorldVector",
- module = "lovr.physics",
- related = {
- "Collider:getLocalVector",
- "Collider:getLocalPoint",
- "Collider:getWorldPoint"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the local vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the local vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the local vector."
- }
- },
- returns = {
- {
- name = "wx",
- type = "number",
- description = "The x component of the world vector."
- },
- {
- name = "wy",
- type = "number",
- description = "The y component of the world vector."
- },
- {
- name = "wz",
- type = "number",
- description = "The z component of the world vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "vector",
- type = "Vec3",
- description = "The local vector."
- }
- },
- returns = {
- {
- name = "wx",
- type = "number",
- description = "The x component of the world vector."
- },
- {
- name = "wy",
- type = "number",
- description = "The y component of the world vector."
- },
- {
- name = "wz",
- type = "number",
- description = "The z component of the world vector."
- }
- }
- }
- }
- },
- {
- name = "isAwake",
- summary = "Check if the Collider is awake.",
- description = "Returns whether the Collider is awake.",
- key = "Collider:isAwake",
- module = "lovr.physics",
- notes = "See `Collider:setSleepingAllowed` for notes about sleeping.",
- related = {
- "Collider:isSleepingAllowed",
- "Collider:setSleepingAllowed"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "awake",
- type = "boolean",
- description = "Whether the Collider is finally awake."
- }
- }
- }
- }
- },
- {
- name = "isContinuous",
- summary = "Check if the Collider is using continuous collision detection.",
- description = "Returns whether the Collider uses continuous collision detection.\n\nNormally on each timestep a Collider will \"teleport\" to its new position based on its velocity. Usually this works fine, but if a Collider is going really fast relative to its size, then it might miss collisions with objects or pass through walls. Enabling continuous collision detection means the Collider will check for obstacles along its path before moving to the new location. This prevents the Collider from going through walls, but reduces performance. It's usually used for projectiles, which tend to be small and really fast.",
- key = "Collider:isContinuous",
- module = "lovr.physics",
- notes = "The physics engine performs an optimization where continuous collision detection is only used if the Collider is moving faster than 75% of its size. So it is not necessary to enable and disable continuous collision detection based on how fast the Collider is moving.\n\nColliders that are sensors are not able to use continuous collision detection.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "continuous",
- type = "boolean",
- description = "Whether the Collider uses continuous collision detection."
- }
- }
- }
- }
- },
- {
- name = "isDestroyed",
- summary = "Check if the Collider has been destroyed.",
- description = "Returns whether the collider has been destroyed.",
- key = "Collider:isDestroyed",
- module = "lovr.physics",
- notes = "After a Collider is destroyed, calling methods on it or passing it to a function will throw an error.",
- related = {
- "Collider:destroy",
- "World:destroy",
- "Shape:destroy",
- "Joint:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "destroyed",
- type = "boolean",
- description = "Whether the collider has been destroyed."
- }
- }
- }
- }
- },
- {
- name = "isEnabled",
- summary = "Check if the Collider is enabled.",
- description = "Returns whether the Collider is enabled. When a Collider is disabled, it is removed from the World and does not impact the physics simulation in any way. The Collider keeps all of its state and can be re-enabled to add it back to the World.",
- key = "Collider:isEnabled",
- module = "lovr.physics",
- notes = "Colliders are enabled when they are created.",
- related = {
- "Collider:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether the Collider is enabled."
- }
- }
- }
- }
- },
- {
- name = "isGravityIgnored",
- summary = "Check if the Collider ignores gravity.",
- description = "Returns whether the Collider is currently ignoring gravity.",
- key = "Collider:isGravityIgnored",
- module = "lovr.physics",
- deprecated = true,
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "ignored",
- type = "boolean",
- description = "Whether gravity is ignored for this Collider."
- }
- }
- }
- }
- },
- {
- name = "isKinematic",
- summary = "Check if the Collider is kinematic.",
- description = "Returns whether the Collider is kinematic.\n\nKinematic colliders behave like they have infinite mass. They ignore forces applied to them from gravity, joints, and collisions, but they can still move if given a velocity. Kinematic colliders don't collide with other kinematic colliders. They're useful for static environment objects in a level, or for objects that have their position managed outside of the physics system like tracked hands.",
- key = "Collider:isKinematic",
- module = "lovr.physics",
- notes = "If a Collider has a `MeshShape` or a `TerrainShape`, it will always be kinematic.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "kinematic",
- type = "boolean",
- description = "Whether the Collider is kinematic."
- }
- }
- }
- }
- },
- {
- name = "isSensor",
- summary = "Check if the Collider is a sensor.",
- description = "Returns whether the Collider is a sensor. Sensors do not collide with other objects, but they can still sense collisions with the collision callbacks set by `World:setCallbacks`. Use them to trigger gameplay behavior when an object is inside a region of space.",
- key = "Collider:isSensor",
- module = "lovr.physics",
- examples = {
- {
- code = "danger = world:newBoxCollider(x, y, z, width, height, depth)\ndanger:setKinematic(true)\ndanger:setSensor(true)\n\nworld:setCallbacks({\n enter = function(a, b)\n if (a == danger and b == player) or (a == player and b == danger) then\n damagePlayer()\n end\n end\n})"
- }
- },
- notes = "Sensors are still reported as hits when doing raycasts and other queries. Use tags to ignore sensors if needed.\n\nWhen a World is created, a set of collision tags can be marked as \"static\", for performance. Sensors do not detect collision with colliders that have a static tag. Also, if a sensor itself has a static tag, it will not be able to detect collisions with sleeping colliders. If a Collider enters a static sensor and goes to sleep, the `exit` callback is called and the sensor is no longer able to detect that collider.\n\nSensors can not use continuous collision detection.\n\nSensors will never go to sleep.",
- related = {
- "Collider:setKinematic",
- "Collider:setEnabled",
- "World:overlapShape",
- "World:setCallbacks"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "sensor",
- type = "boolean",
- description = "Whether the Collider is a sensor."
- }
- }
- }
- }
- },
- {
- name = "isSleepingAllowed",
- summary = "Check if the Collider is allowed to sleep.",
- description = "Returns whether the Collider is allowed to automatically go to sleep.\n\nWhen enabled, the Collider will go to sleep if it hasn't moved in a while. The physics engine does not simulate movement for colliders that are asleep, which saves a lot of CPU for a typical physics world where most objects are at rest at any given time.",
- key = "Collider:isSleepingAllowed",
- module = "lovr.physics",
- notes = "Sleeping is enabled by default. Sleeping can be disabled globally using the `allowSleep` option in `lovr.physics.newWorld`.\n\nColliders can still be put to sleep manually with `Collider:setAwake`, even if automatic sleeping is disabled.\n\nSleeping colliders will wake up when:\n\n- Colliding with a moving collider\n- Awakened explicitly with `Collider:setAwake`\n- Changing position `Collider:setPosition` or `Collider:setOrientation`\n- Changing velocity (to something non-zero)\n- Applying force, torque, or an impulse\n- Enabling a joint connected to the sleeping collider\n\nNotably, the following will not wake up the collider:\n\n- Changing its kinematic state with `Collider:setKinematic`\n- Changing its shape with `Collider:addShape` or `Collider:removeShape`\n- Disabling or destroying a sleeping collider it is resting on\n\nSensors will never go to sleep.",
- related = {
- "Collider:isAwake",
- "Collider:setAwake"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "sleepy",
- type = "boolean",
- description = "Whether the Collider can go to sleep."
- }
- }
- }
- }
- },
- {
- name = "moveKinematic",
- summary = "TODO",
- description = "TODO",
- key = "Collider:moveKinematic",
- module = "lovr.physics",
- notes = "",
- related = {},
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "removeShape",
- summary = "Remove a Shape from the Collider.",
- description = "Removes a Shape from the Collider.",
- key = "Collider:removeShape",
- module = "lovr.physics",
- notes = "By default, LÖVR will recompute mass properties for the Collider as shapes are added and removed. Use `Collider:setAutomaticMass` to enable or disable this behavior.\n\nIt is valid for a Collider to have zero shapes, but due to a limitation of the physics engine LÖVR substitutes in a 1mm sphere so that the Collider still has mass. It isn't advisable to keep these tiny spheres around. Instead, prefer to quickly attach other shapes, or disable the Collider with `Collider:setEnabled`.",
- related = {
- "Collider:addShape",
- "Collider:getShapes",
- "Shape"
- },
- variants = {
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to remove."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "resetMassData",
- summary = "Reset mass properties.",
- description = "Resets the mass, inertia, and center of mass of the Collider based on its attached shapes.\n\nIf automatic mass is enabled, these properties will be kept up to date automatically. Use this function when automatic mass is disabled or if mass needs to be reset after being overridden.",
- key = "Collider:resetMassData",
- module = "lovr.physics",
- related = {
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setAngularDamping",
- summary = "Set the angular damping of the Collider.",
- description = "Sets the angular damping of the Collider. Angular damping is similar to drag or air resistance, reducing the Collider's angular velocity over time.",
- key = "Collider:setAngularDamping",
- module = "lovr.physics",
- notes = "The default damping is .05, meaning the collider will lose approximately 5% of its velocity each second. A damping value of zero means the Collider will not lose velocity over time.\n\nNegative damping is not meaningful and will be clamped to zero.",
- related = {
- "Collider:getLinearDamping",
- "Collider:setLinearDamping",
- "Collider:getInertia",
- "Collider:setInertia"
- },
- variants = {
- {
- arguments = {
- {
- name = "damping",
- type = "number",
- description = "The angular damping."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setAngularVelocity",
- summary = "Set the angular velocity of the Collider.",
- description = "Sets the angular velocity of the Collider.",
- key = "Collider:setAngularVelocity",
- module = "lovr.physics",
- notes = "Although setting the velocity directly is useful sometimes, it can cause problems:\n\n- Velocity ignores mass, so it can lead to unnaturally sharp changes in motion.\n- If the velocity of a Collider is changed multiple times during a frame, only the last one is\n going to have an effect, nullifying the other velocities that were set.\n- Setting the velocity of a Collider every frame can mess up collisions, since the forces used\n to resolve a collision will get ignored by changing the velocity.\n\nUsing forces and impulses to move Colliders will avoid all of these issues.\n\nIf the Collider is asleep, setting the angular velocity to a non-zero value will wake it up.\n\nIf the Collider has a tag that was marked as static when the World was created, then the Collider can not move and this function will do nothing.",
- related = {
- "Collider:applyTorque",
- "Collider:applyAngularImpulse",
- "Collider:getLinearVelocity",
- "Collider:setLinearVelocity",
- "Collider:getOrientation",
- "Collider:setOrientation"
- },
- variants = {
- {
- description = "Sets the angular velocity of the Collider using numbers.",
- arguments = {
- {
- name = "vx",
- type = "number",
- description = "The x component of the angular velocity."
- },
- {
- name = "vy",
- type = "number",
- description = "The y component of the angular velocity."
- },
- {
- name = "vz",
- type = "number",
- description = "The z component of the angular velocity."
- }
- },
- returns = {}
- },
- {
- description = "Sets the angular velocity of the Collider using a vector.",
- arguments = {
- {
- name = "velocity",
- type = "Vec3",
- description = "The angular velocity of the Collider."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setAutomaticMass",
- summary = "Enable or disable automatic mass.",
- description = "Enables or disables automatic mass for the Collider.\n\nWhen enabled, the Collider's mass, inertia, and center of mass will be recomputed when:\n\n- A shape is added to or removed from the Collider.\n- A shape attached to the Collider changes shape (e.g. `SphereShape:setRadius`).\n- A shape attached to the Collider is moved using `Shape:setOffset`.\n- A shape attached to the Collider changes its density using `Shape:setDensity`.\n\nAdditionally, changing the center of mass of a Collider will automatically update its inertia when automatic mass is enabled.\n\nDisable this to manage the mass properties manually. When automatic mass is disabled, `Collider:resetMassData` can still be used to reset the mass from attached shapes if needed.",
- key = "Collider:setAutomaticMass",
- module = "lovr.physics",
- related = {
- "Collider:resetMassData",
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether automatic mass should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setAwake",
- summary = "Put the Collider to sleep or wake it up.",
- description = "Puts the Collider to sleep or wakes it up manually.",
- key = "Collider:setAwake",
- module = "lovr.physics",
- notes = "This function can still be used to put a Collider to sleep even if automatic sleeping has been disabled with `Collider:setSleepingAllowed`.",
- related = {
- "Collider:isSleepingAllowed",
- "Collider:setSleepingAllowed"
- },
- variants = {
- {
- arguments = {
- {
- name = "awake",
- type = "boolean",
- description = "Whether the Collider should be awake."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setCenterOfMass",
- summary = "Set the Collider's center of mass.",
- description = "Sets the Collider's center of mass, in the Collider's local coordinate space.\n\nThis does not change the Collider's position.",
- key = "Collider:setCenterOfMass",
- module = "lovr.physics",
- notes = "By default, the center of mass of the Collider is kept up to date automatically as the Collider's shapes change. To disable this, use `Collider:setAutomaticMass`.\n\nUse `Collider:resetMassData` to reset the center and other mass properties based on the Collider's shapes.",
- related = {
- "Shape:getCenterOfMass",
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData",
- "Shape:getOffset",
- "Shape:setOffset"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the center of mass."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the center of mass."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the center of mass."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "center",
- type = "Vec3",
- description = "The center of mass."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setContinuous",
- summary = "Set whether the Collider uses continuous collision detection.",
- description = "Sets whether the Collider uses continuous collision detection.\n\nNormally on each timestep a Collider will \"teleport\" to its new position based on its velocity. Usually this works fine, but if a Collider is going really fast relative to its size, then it might miss collisions with objects or pass through walls. Enabling continuous collision detection means the Collider will check for obstacles along its path before moving to the new location. This prevents the Collider from going through walls, but reduces performance. It's usually used for projectiles, which tend to be small and really fast.",
- key = "Collider:setContinuous",
- module = "lovr.physics",
- notes = "The physics engine performs an optimization where continuous collision detection is only used if the Collider is moving faster than 75% of its size. So it is not necessary to enable and disable continuous collision detection based on how fast the Collider is moving.\n\nColliders that are sensors are not able to use continuous collision detection.",
- variants = {
- {
- arguments = {
- {
- name = "continuous",
- type = "boolean",
- description = "Whether the Collider uses continuous collision detection."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setDegreesOfFreedom",
- summary = "Set the enabled translation/rotation axes.",
- description = "Set the degrees of freedom of the Collider.",
- key = "Collider:setDegreesOfFreedom",
- module = "lovr.physics",
- notes = "The default state is `xyz` for both translation and rotation.\n\nThe physics engine does not support disabling all degrees of freedom. At least one translation or rotation axis needs to be enabled. To disable all movement for a collider, make it kinematic.\n\nWhen all translation axes are disabled, `Collider:getMass` will return 0.\n\nWhen all rotation axes are disabled, `Collider:getInertia` will return zero/identity.\n\nThis function does nothing if the Collider is kinematic.",
- variants = {
- {
- arguments = {
- {
- name = "translation",
- type = "string",
- description = "A string containing the world-space axes the Collider is allowed to move on. The string should have 'x', 'y', and 'z' letters representing the axes to enable. Use nil or an empty string to disable all translation."
- },
- {
- name = "rotation",
- type = "string",
- description = "A string containing the world-space axes the Collider is allowed to rotate on. The string should have 'x', 'y', and 'z' letters representing the axes to enable. Use nil or an empty string to disable all rotation."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setEnabled",
- summary = "Enable or disable the Collider.",
- description = "Enables or disables the Collider. When a Collider is disabled, it is removed from the World and does not impact the physics simulation in any way. The Collider keeps all of its state and can be re-enabled to add it back to the World.",
- key = "Collider:setEnabled",
- module = "lovr.physics",
- related = {
- "Collider:destroy"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether the Collider should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setFriction",
- summary = "Set the friction of the Collider.",
- description = "Sets the friction of the Collider. Friction determines how easy it is for two colliders to slide against each other. Low friction makes it easier for a collider to slide, simulating a smooth surface.",
- key = "Collider:setFriction",
- module = "lovr.physics",
- notes = "The default friction is .2.\n\nWhen two colliders collide, their friction is combined using the geometric mean:\n\n friction = (frictionA * frictionB) ^ .5",
- related = {
- "Contact:getFriction",
- "Contact:setFriction",
- "Collider:getRestitution",
- "Collider:setRestitution"
- },
- variants = {
- {
- arguments = {
- {
- name = "friction",
- type = "number",
- description = "The friction of the Collider."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setGravityIgnored",
- summary = "Set whether the Collider ignores gravity.",
- description = "Sets whether the Collider should ignore gravity.",
- key = "Collider:setGravityIgnored",
- module = "lovr.physics",
- deprecated = true,
- variants = {
- {
- arguments = {
- {
- name = "ignored",
- type = "boolean",
- description = "Whether gravity should be ignored."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setGravityScale",
- summary = "Set the gravity scale of the Collider.",
- description = "Sets the gravity scale of the Collider. This is multiplied with the global gravity from the World, so 1.0 is regular gravity, 0.0 will ignore gravity, etc.",
- key = "Collider:setGravityScale",
- module = "lovr.physics",
- related = {
- "World:getGravity",
- "World:setGravity",
- "Collider:getLinearDamping",
- "Collider:setLinearDamping"
- },
- variants = {
- {
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The gravity scale."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setInertia",
- summary = "Set the inertia of the Collider.",
- description = "Sets the inertia of the Collider.\n\nInertia is kind of like \"angular mass\". Regular mass determines how resistant the Collider is to linear forces (movement), whereas inertia determines how resistant the Collider is to torque (rotation). Colliders with less inertia are more spinny.\n\nIn 3D, inertia is represented by a 3x3 matrix, called a tensor. To make calculations easier, the physics engine stores the inertia using eigenvalue decomposition, splitting the matrix into a diagonal matrix and a rotation. It's complicated!\n\nIn a realistic simulation, mass and inertia follow a linear relationship. If the mass of an object increases, the diagonal part of its inertia should increase proportionally.",
- key = "Collider:setInertia",
- module = "lovr.physics",
- notes = "By default, the inertia of the Collider is kept up to date automatically as the Collider's shapes change. To disable this, use `Collider:setAutomaticMass`.\n\nUse `Collider:resetMassData` to reset the inertia and other mass properties based on the Collider's shapes.\n\nIf the Collider is kinematic or all rotation axes are disabled, the collider behaves as though it has infinite inertia, and this function will do nothing.",
- related = {
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData",
- "Shape:getInertia"
- },
- variants = {
- {
- arguments = {
- {
- name = "dx",
- type = "number",
- description = "The x component of the diagonal matrix."
- },
- {
- name = "dy",
- type = "number",
- description = "The y component of the diagonal matrix."
- },
- {
- name = "dz",
- type = "number",
- description = "The z component of the diagonal matrix."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle of the inertia rotation, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the rotation axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the rotation axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the rotation axis."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "diagonal",
- type = "Vec3",
- description = "A vector containing the 3 elements of a diagonal matrix."
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The inertia rotation."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setKinematic",
- summary = "Set whether the Collider is kinematic.",
- description = "Sets whether the Collider is kinematic.\n\nKinematic colliders behave like they have infinite mass. They ignore forces applied to them from gravity, joints, and collisions, but they can still move if given a velocity. Kinematic colliders don't collide with other kinematic colliders. They're useful for static environment objects in a level, or for objects that have their position managed outside of the physics system like tracked hands.",
- key = "Collider:setKinematic",
- module = "lovr.physics",
- notes = "If a Collider has a `MeshShape` or a `TerrainShape`, the collider will always be kinematic and this function will do nothing.",
- variants = {
- {
- arguments = {
- {
- name = "kinematic",
- type = "boolean",
- description = "Whether the Collider should be kinematic."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setLinearDamping",
- summary = "Set the linear damping of the Collider.",
- description = "Sets the linear damping of the Collider. Linear damping is similar to drag or air resistance, slowing the Collider down over time.",
- key = "Collider:setLinearDamping",
- module = "lovr.physics",
- notes = "The default damping is .05, meaning the collider will lose approximately 5% of its velocity each second. A damping value of zero means the Collider will not lose velocity over time.\n\nNegative damping is not meaningful and will be clamped to zero.",
- related = {
- "Collider:getAngularDamping",
- "Collider:setAngularDamping",
- "Collider:getGravityScale",
- "Collider:setGravityScale"
- },
- variants = {
- {
- arguments = {
- {
- name = "damping",
- type = "number",
- description = "The linear damping."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setLinearVelocity",
- summary = "Set the linear velocity of the Collider.",
- description = "Sets the world-space linear velocity of the center of mass of the Collider.",
- key = "Collider:setLinearVelocity",
- module = "lovr.physics",
- notes = "Although setting the velocity directly is useful sometimes, it can cause problems:\n\n- Velocity ignores mass, so it can lead to unnaturally sharp changes in motion.\n- If the velocity of a Collider is changed multiple times during a frame, only the last one is\n going to have an effect, nullifying the other velocities that were set.\n- Setting the velocity of a Collider every frame can mess up collisions, since the forces used\n to resolve a collision will get ignored by changing the velocity.\n\nUsing forces and impulses to move Colliders will avoid all of these issues.\n\nIf the Collider is asleep, setting the velocity to a non-zero value will wake it up.\n\nIf the Collider has a tag that was marked as static when the World was created, then the Collider can not move and this function will do nothing.\n\nCurrently, velocity is clamped to 500 meters per second to improve stability of the simulation.",
- related = {
- "Collider:applyForce",
- "Collider:applyLinearImpulse",
- "Collider:getLinearVelocityFromLocalPoint",
- "Collider:getLinearVelocityFromWorldPoint",
- "Collider:getAngularVelocity",
- "Collider:setAngularVelocity",
- "Collider:getPosition",
- "Collider:setPosition"
- },
- variants = {
- {
- description = "Set the linear velocity of the collider using numbers.",
- arguments = {
- {
- name = "vx",
- type = "number",
- description = "The x component of the new velocity, in meters per second."
- },
- {
- name = "vy",
- type = "number",
- description = "The y component of the new velocity, in meters per second."
- },
- {
- name = "vz",
- type = "number",
- description = "The z component of the new velocity, in meters per second."
- }
- },
- returns = {}
- },
- {
- description = "Set the linear velocity of the collider using a vector.",
- arguments = {
- {
- name = "velocity",
- type = "Vec3",
- description = "The new velocity, in meters per second."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setMass",
- summary = "Set the mass of the Collider.",
- description = "Sets the mass of the Collider.\n\nThe relative mass of colliders determines how they react when they collide. A heavier collider has more momentum than a lighter collider moving the same speed, and will impart more force on the lighter collider.\n\nMore generally, heavier colliders react less to forces they receive, including forces applied with functions like `Collider:applyForce`.\n\nColliders with higher mass do not fall faster. Use `Collider:setLinearDamping` to give a collider drag to make it fall slower or `Collider:setGravityScale` to change the way it reacts to gravity.",
- key = "Collider:setMass",
- module = "lovr.physics",
- notes = "The mass must be positive. Attempting to set a zero or negative mass will error.\n\nBy default, the mass of the Collider is kept up to date automatically as the Collider's shapes change. Use `Collider:setAutomaticMass` to disable this.\n\nUse `Collider:resetMassData` to reset the mass based on the Collider's shapes.\n\nIf the Collider is kinematic or all translation axes are disabled, this function will do nothing.",
- related = {
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData",
- "Shape:getDensity",
- "Shape:setDensity",
- "Shape:getVolume",
- "Shape:getMass"
- },
- variants = {
- {
- arguments = {
- {
- name = "mass",
- type = "number",
- description = "The new mass for the Collider, in kilograms."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setOrientation",
- summary = "Set the orientation of the Collider.",
- description = "Sets the orientation of the Collider in angle/axis representation.",
- key = "Collider:setOrientation",
- module = "lovr.physics",
- related = {
- "Collider:applyTorque",
- "Collider:getAngularVelocity",
- "Collider:setAngularVelocity",
- "Collider:getPosition",
- "Collider:setPosition",
- "Collider:getPose",
- "Collider:setPose"
- },
- variants = {
- {
- description = "Set the orientation of the Collider using numbers.",
- arguments = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Collider is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the orientation of the Collider using a quaternion.",
- arguments = {
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the Collider."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPose",
- summary = "Set the pose of the Collider.",
- description = "Sets the position and orientation of the Collider.",
- key = "Collider:setPose",
- module = "lovr.physics",
- related = {
- "Collider:setPosition",
- "Collider:setOrientation"
- },
- variants = {
- {
- description = "Set the pose of the Collider using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Collider, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Collider, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Collider, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Collider is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- description = "Set the pose of the Collider using vector types.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the Collider, in meters."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the Collider."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPosition",
- summary = "Set the position of the Collider.",
- description = "Sets the position of the Collider.",
- key = "Collider:setPosition",
- module = "lovr.physics",
- related = {
- "Collider:applyForce",
- "Collider:getLinearVelocity",
- "Collider:setLinearVelocity",
- "Collider:getOrientation",
- "Collider:setOrientation",
- "Collider:getPose",
- "Collider:setPose"
- },
- variants = {
- {
- description = "Set the position of the Collider using numbers.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Collider, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Collider, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Collider, in meters."
- }
- },
- returns = {}
- },
- {
- description = "Set the position of the Collider using a vector.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the Collider, in meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setRestitution",
- summary = "Set the bounciness of the Collider.",
- description = "Sets the restitution of the Collider. Restitution makes a Collider bounce when it collides with other objects. A restitution value of zero would result in an inelastic collision response, whereas 1.0 would result in an elastic collision that preserves all of the velocity.",
- key = "Collider:setRestitution",
- module = "lovr.physics",
- notes = "To improve stability of the simulation and allow colliders to come to rest, restitution is only applied if the collider is moving above a certain speed. This can be configured using the `restitutionThreshold` option in `lovr.physics.newWorld`.\n\nNegative restitution is not meaningful and is clamped to zero.",
- related = {
- "Contact:getRestitution",
- "Contact:setRestitution",
- "Collider:getFriction",
- "Collider:setFriction"
- },
- variants = {
- {
- arguments = {
- {
- name = "restitution",
- type = "number",
- description = "The restitution of the Collider."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSensor",
- summary = "Set whether the Collider should be a sensor.",
- description = "Sets whether the Collider should be a sensor. Sensors do not collide with other objects, but they can still sense collisions with the collision callbacks set by `World:setCallbacks`. Use them to trigger gameplay behavior when an object is inside a region of space.",
- key = "Collider:setSensor",
- module = "lovr.physics",
- notes = "Sensors are still reported as hits when doing raycasts and other queries. Use tags to ignore sensors if needed.\n\nWhen a World is created, a set of collision tags can be marked as \"static\", for performance. Sensors do not detect collision with colliders that have a static tag. Also, if a sensor itself has a static tag, it will not be able to detect collisions with sleeping colliders. If a Collider enters a static sensor and goes to sleep, the `exit` callback is called and the sensor is no longer able to detect that collider.\n\nSensors can not use continuous collision detection.\n\nSensors will never go to sleep.",
- related = {
- "Collider:setKinematic",
- "Collider:setEnabled",
- "World:overlapShape",
- "World:setCallbacks"
- },
- variants = {
- {
- arguments = {
- {
- name = "sensor",
- type = "boolean",
- description = "Whether the Collider should be a sensor."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSleepingAllowed",
- summary = "Set whether the Collider is allowed to sleep.",
- description = "Sets whether the Collider is allowed to automatically go to sleep.\n\nWhen enabled, the Collider will go to sleep if it hasn't moved in a while. The physics engine does not simulate movement for colliders that are asleep, which saves a lot of CPU for a typical physics world where most objects are at rest at any given time.",
- key = "Collider:setSleepingAllowed",
- module = "lovr.physics",
- notes = "Sleeping is enabled by default. Sleeping can be disabled globally using the `allowSleep` option in `lovr.physics.newWorld`.\n\nColliders can still be put to sleep manually with `Collider:setAwake`, even if automatic sleeping is disabled.\n\nSleeping colliders will wake up when:\n\n- Colliding with a moving collider\n- Awakened explicitly with `Collider:setAwake`\n- Changing position `Collider:setPosition` or `Collider:setOrientation`\n- Changing velocity (to something non-zero)\n- Applying force, torque, or an impulse\n- Enabling a joint connected to the sleeping collider\n\nNotably, the following will not wake up the collider:\n\n- Changing its kinematic state with `Collider:setKinematic`\n- Changing its shape with `Collider:addShape` or `Collider:removeShape`\n- Disabling or destroying a sleeping collider it is resting on\n\nSensors will never go to sleep.",
- related = {
- "Collider:isAwake",
- "Collider:setAwake"
- },
- variants = {
- {
- arguments = {
- {
- name = "sleepy",
- type = "boolean",
- description = "Whether the Collider can go to sleep."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setTag",
- summary = "Set the Collider's tag.",
- description = "Sets the Collider's tag.\n\nTags are strings that represent the category of a collider. Use `World:enableCollisionBetween` and `World:disableCollisionBetween` to control which pairs of tags should collide with each other. Physics queries like `World:raycast` also use tags to filter their results.\n\nThe list of available tags is set in `lovr.physics.newWorld`.",
- key = "Collider:setTag",
- module = "lovr.physics",
- related = {
- "World:getTags",
- "World:disableCollisionBetween",
- "World:enableCollisionBetween",
- "World:isCollisionEnabledBetween",
- "lovr.physics.newWorld"
- },
- variants = {
- {
- arguments = {
- {
- name = "tag",
- type = "string",
- description = "The Collider's tag."
- }
- },
- returns = {}
- },
- {
- description = "Clear the Collider's tag.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setUserData",
- summary = "Associate a Lua value with the Collider.",
- description = "Associates a Lua value with the Collider.",
- key = "Collider:setUserData",
- module = "lovr.physics",
- notes = "Set the user data to `nil` to clear any existing reference.\n\nThe userdata is useful for linking a Collider with custom data:\n\n local collider = world:raycast(origin, direction, 'enemy')\n\n if collider then\n -- Get the enemy object from its Collider\n local enemy = collider:getUserData()\n enemy.health = 0\n end\n\nThe user data is not shared between threads. Each thread has its own user data for the Collider.",
- related = {
- "Shape:getUserData",
- "Shape:setUserData",
- "Joint:getUserData",
- "Joint:setUserData"
- },
- variants = {
- {
- arguments = {
- {
- name = "data",
- type = "*",
- description = "The custom value to associate with the Collider."
- }
- },
- returns = {}
- }
- }
- }
- },
- sections = {
- {
- name = "Motion",
- links = {
- "Collider:getPosition",
- "Collider:setPosition",
- "Collider:getOrientation",
- "Collider:setOrientation",
- "Collider:getPose",
- "Collider:setPose",
- "Collider:getLocalPoint",
- "Collider:getWorldPoint",
- "Collider:getLocalVector",
- "Collider:getWorldVector",
- "Collider:getAABB",
- "Collider:getLinearVelocity",
- "Collider:setLinearVelocity",
- "Collider:getAngularVelocity",
- "Collider:setAngularVelocity",
- "Collider:getLinearVelocityFromLocalPoint",
- "Collider:getLinearVelocityFromWorldPoint",
- "Collider:moveKinematic",
- "Collider:applyForce",
- "Collider:applyTorque",
- "Collider:applyLinearImpulse",
- "Collider:applyAngularImpulse",
- "Collider:getLinearDamping",
- "Collider:setLinearDamping",
- "Collider:getAngularDamping",
- "Collider:setAngularDamping",
- "Collider:isKinematic",
- "Collider:setKinematic",
- "Collider:isContinuous",
- "Collider:setContinuous",
- "Collider:getDegreesOfFreedom",
- "Collider:setDegreesOfFreedom",
- "Collider:getGravityScale",
- "Collider:setGravityScale",
- "Collider:isSleepingAllowed",
- "Collider:setSleepingAllowed",
- "Collider:isAwake",
- "Collider:setAwake"
- }
- },
- {
- name = "Collision",
- links = {
- "Collider:getTag",
- "Collider:setTag",
- "Collider:getShape",
- "Collider:getShapes",
- "Collider:addShape",
- "Collider:removeShape",
- "Collider:isSensor",
- "Collider:setSensor",
- "Collider:getFriction",
- "Collider:setFriction",
- "Collider:getRestitution",
- "Collider:setRestitution"
- }
- },
- {
- name = "Mass",
- links = {
- "Collider:getMass",
- "Collider:setMass",
- "Collider:getInertia",
- "Collider:setInertia",
- "Collider:getCenterOfMass",
- "Collider:setCenterOfMass",
- "Collider:getAutomaticMass",
- "Collider:setAutomaticMass",
- "Collider:resetMassData"
- }
- },
- {
- name = "Miscellaneous",
- links = {
- "Collider:getUserData",
- "Collider:setUserData",
- "Collider:isEnabled",
- "Collider:setEnabled",
- "Collider:getWorld",
- "Collider:getJoints",
- "Collider:destroy",
- "Collider:isDestroyed"
- }
- }
- }
- },
- {
- name = "ConeJoint",
- summary = "TODO",
- description = "TODO",
- key = "ConeJoint",
- module = "lovr.physics",
- extends = "Joint",
- methods = {
- {
- name = "getAxis",
- summary = "Get the axis of the cone.",
- description = "Returns the axis of the ConeJoint, in world space. The axis is relative to the first Collider connected to the Joint, so it will rotate as the collider does. The relative angle between the axis and the second collider will be constrained based on the ConeJoint's angle limit.",
- key = "ConeJoint:getAxis",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis."
- }
- }
- }
- }
- },
- {
- name = "getLimit",
- summary = "Get the angle limit of the ConeJoint.",
- description = "Returns the angle limit of the ConeJoint. The relative angle between the ConeJoint's axis and the second Collider will be constrained to this limit.",
- key = "ConeJoint:getLimit",
- module = "lovr.physics",
- notes = "The default limit is zero, preventing any rotation away from the axis.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "limit",
- type = "number",
- description = "The angle limit, in radians."
- }
- }
- }
- }
- },
- {
- name = "setLimit",
- summary = "Set the angle limit of the ConeJoint.",
- description = "Sets the angle limit of the ConeJoint. The relative angle between the ConeJoint's axis and the second Collider will be constrained to this limit.",
- key = "ConeJoint:setLimit",
- module = "lovr.physics",
- notes = "The default limit is zero, preventing any rotation away from the axis.",
- variants = {
- {
- arguments = {
- {
- name = "limit",
- type = "number",
- description = "The new limit in radians, between 0 and pi."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "Contact",
- summary = "TODO",
- description = "TODO",
- key = "Contact",
- module = "lovr.physics",
- methods = {
- {
- name = "getColliders",
- summary = "Get the two Colliders that are in contact.",
- description = "Returns the two Colliders that are in contact.",
- key = "Contact:getColliders",
- module = "lovr.physics",
- related = {
- "Contact:getShapes"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "first",
- type = "Collider",
- description = "The first collider."
- },
- {
- name = "second",
- type = "Collider",
- description = "The second collider."
- }
- }
- }
- }
- },
- {
- name = "getFriction",
- summary = "Get the friction of the Contact.",
- description = "Returns the friction of the Contact. Lower friction makes it easier for the colliders to slide against each other.",
- key = "Contact:getFriction",
- module = "lovr.physics",
- related = {
- "Collider:getFriction",
- "Collider:setFriction",
- "Contact:getRestitution",
- "Contact:setRestitution"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "friction",
- type = "number",
- description = "The contact friction."
- }
- }
- }
- }
- },
- {
- name = "getNormal",
- summary = "Get the normal vector of the Contact.",
- description = "Returns the normal vector of the Contact. This is a direction vector that represents which direction the second collider should move to resolve the collision.",
- key = "Contact:getNormal",
- module = "lovr.physics",
- related = {
- "Contact:getOverlap",
- "Contact:getPoints"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the normal vector."
- }
- }
- }
- }
- },
- {
- name = "getOverlap",
- summary = "Get the amount of overlap between the colliders.",
- description = "Returns the amount of overlap between the colliders.",
- key = "Contact:getOverlap",
- module = "lovr.physics",
- related = {
- "Contact:getNormal"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "overlap",
- type = "number",
- description = "The amount of overlap, in meters."
- }
- }
- }
- }
- },
- {
- name = "getPoints",
- summary = "Get the contact points of the Contact.",
- description = "Returns the contact points of the Contact. These are the points where the colliders are intersecting.",
- key = "Contact:getPoints",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "...points",
- type = "number",
- description = "Triplets of x/y/z numbers, one for each contact point."
- }
- }
- }
- }
- },
- {
- name = "getRestitution",
- summary = "Get the bounciness of the Contact.",
- description = "Returns the restitution of the Contact. Restitution makes the Colliders bounce off of each other. A restitution value of zero results in an inelastic collision response, whereas 1.0 results in an elastic collision that preserves all of the velocity. Restitution can be bigger than 1.0 to make the collision even more bouncy.",
- key = "Contact:getRestitution",
- module = "lovr.physics",
- notes = "The default restitution is the maximum restitution of either of the colliders.",
- related = {
- "Collider:getRestitution",
- "Collider:setRestitution",
- "Contact:getFriction",
- "Contact:setFriction"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "restitution",
- type = "number",
- description = "The contact restitution."
- }
- }
- }
- }
- },
- {
- name = "getShapes",
- summary = "Get the two Shapes that are in contact.",
- description = "Returns the two Shapes that are in contact.",
- key = "Contact:getShapes",
- module = "lovr.physics",
- related = {
- "Contact:getColliders"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "first",
- type = "Shape",
- description = "The first shape."
- },
- {
- name = "second",
- type = "Shape",
- description = "The second shape."
- }
- }
- }
- }
- },
- {
- name = "getSurfaceVelocity",
- summary = "Get the surface velocity of the Contact.",
- description = "Returns the world space surface velocity of the Contact. This can be used to achieve a conveyor belt effect.",
- key = "Contact:getSurfaceVelocity",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the surface velocity."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the surface velocity."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the surface velocity."
- }
- }
- }
- }
- },
- {
- name = "isEnabled",
- summary = "Check if the Contact is enabled.",
- description = "Returns whether the Contact is enabled. Disabled contacts do not generate any collision response. Use `Contact:setEnabled` to disable a contact to selectively ignore certain collisions.",
- key = "Contact:isEnabled",
- module = "lovr.physics",
- related = {
- "Collider:isEnabled",
- "Collider:setEnabled",
- "World:setCallbacks"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether the Contact is enabled."
- }
- }
- }
- }
- },
- {
- name = "setEnabled",
- summary = "Enable or disable the Contact.",
- description = "Enables or disables the Contact. Disabled contacts do not generate any collision response.",
- key = "Contact:setEnabled",
- module = "lovr.physics",
- notes = "Note that this is the slowest way to ignore a collision. Faster ways to disable collisions (in increasing order of speed) are:\n\n- The `filter` callback in `World:setCallbacks`\n- Disabling collision between tags with `World:disableCollisionBetween`\n- Removing the collider from the World completely with `Collider:setEnabled`",
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether the Contact should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setFriction",
- summary = "Set the friction of the Contact.",
- description = "Sets the friction of the Contact. Lower friction makes it easier for the colliders to slide against each other. This overrides the default friction computed by the friction of the two Colliders.",
- key = "Contact:setFriction",
- module = "lovr.physics",
- notes = "The default friction is computed from the geometric mean of the Colliders' friction:\n\n friction = (frictionA * frictionB) ^ .5\n\nNegative frictions will be clamped to zero.",
- related = {
- "Collider:getFriction",
- "Collider:setFriction",
- "Contact:getRestitution",
- "Contact:setRestitution"
- },
- variants = {
- {
- arguments = {
- {
- name = "friction",
- type = "number",
- description = "The contact friction."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setRestitution",
- summary = "Set the bounciness of the Contact.",
- description = "Sets the restitution of the Contact. Restitution makes the Colliders bounce off of each other. A restitution value of zero results in an inelastic collision response, whereas 1.0 results in an elastic collision that preserves all of the velocity. Restitution can be bigger than 1.0 to make the collision even more bouncy.",
- key = "Contact:setRestitution",
- module = "lovr.physics",
- notes = "The default restitution is the maximum restitution of either of the colliders.\n\nNegative restitution values will be clamped to zero.",
- related = {
- "Collider:getRestitution",
- "Collider:setRestitution",
- "Contact:getFriction",
- "Contact:setFriction"
- },
- variants = {
- {
- arguments = {
- {
- name = "restitution",
- type = "number",
- description = "The contact restitution."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSurfaceVelocity",
- summary = "Set the surface velocity of the Contact.",
- description = "Sets the world space surface velocity of the Contact. This can be used to achieve a conveyor belt effect.",
- key = "Contact:setSurfaceVelocity",
- module = "lovr.physics",
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x component of the surface velocity."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the surface velocity."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the surface velocity."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "velocity",
- type = "Vec3",
- description = "The surface velocity."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "ConvexShape",
- summary = "A convex hull shape.",
- description = "A type of `Shape` that is a convex hull of a collection of points, allowing for custom collision shapes. It is similar to a `MeshShape`, but it is not required to be kinematic, and it will use the convex hull of the mesh instead of using the exact triangles of the object.\n\nConvex shapes can be created from a `Model`, `ModelData`, `Mesh`, or a table of point positions, similar to `MeshShape`.\n\nConvex shapes can be cloned by passing in an existing ConvexShape to clone:\n\n model = lovr.data.newModelData('rock.glb')\n parent = lovr.physics.newConvexShape(model)\n clone = lovr.physics.newConvexShape(parent, scale)\n\nThe clone will reuse all of the data from the parent, which speeds things up a lot.\n\nConvex shapes can have a custom scale applied to their points, and clones can have their own scale.",
- key = "ConvexShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newConvexShape",
- "World:newConvexCollider"
- },
- examples = {
- {
- description = "Drawing a convex hull.",
- code = "function lovr.load()\n model = lovr.graphics.newModel('eggplant.glb')\n hull = lovr.physics.newConvexShape(model)\n\n -- Each face will be a list of points to draw a line through\n faces = {}\n\n for f = 1, hull:getFaceCount() do\n local face = {}\n\n for _, pointindex in ipairs(hull:getFace(f)) do\n local x, y, z = hull:getPoint(pointindex)\n table.insert(face, x)\n table.insert(face, y)\n table.insert(face, z)\n end\n\n -- Connect the last point back to the first point\n table.insert(face, face[1])\n table.insert(face, face[2])\n table.insert(face, face[3])\n\n table.insert(faces, face)\n end\nend\n\nfunction lovr.draw(pass)\n pass:push()\n pass:translate(0, 0, -5)\n pass:draw(model)\n\n pass:setColor(1, 0, 0)\n for i, points in pairs(faces) do\n pass:line(points)\n end\n pass:pop()\nend"
- }
- },
- extends = "Shape",
- methods = {
- {
- name = "getFace",
- summary = "Get the point indices of one of the faces of the convex hull.",
- description = "Returns the indices of points that make up one of the faces of the convex hull.",
- key = "ConvexShape:getFace",
- module = "lovr.physics",
- related = {
- "ConvexShape:getPoint",
- "ConvexShape:getFaceCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the face."
- }
- },
- returns = {
- {
- name = "points",
- type = "table",
- description = "A table with point indices. Use `ConvexShape:getPoint` to get the coordinates. The points are given in counterclockwise order."
- }
- }
- }
- }
- },
- {
- name = "getFaceCount",
- summary = "Get the number of faces in the convex hull.",
- description = "Returns the number of faces in the convex hull.",
- key = "ConvexShape:getFaceCount",
- module = "lovr.physics",
- related = {
- "ConvexShape:getFace"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of faces."
- }
- }
- }
- }
- },
- {
- name = "getPoint",
- summary = "Get one of the points in the convex hull.",
- description = "Returns one of the points in the convex hull, in local space.",
- key = "ConvexShape:getPoint",
- module = "lovr.physics",
- notes = "The point positions will be scaled by the ConvexShape's scale, see `ConvexShape:getScale`.",
- related = {
- "ConvexShape:getPointCount"
- },
- variants = {
- {
- arguments = {
- {
- name = "index",
- type = "number",
- description = "The index of the point."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate."
- }
- }
- }
- }
- },
- {
- name = "getPointCount",
- summary = "Get the number of points in the convex hull.",
- description = "Returns the number of points in the convex hull.",
- key = "ConvexShape:getPointCount",
- module = "lovr.physics",
- notes = "This isn't necessarily the same as the number of points or vertices that were used to create the shape, since points inside the hull will be discarded.",
- related = {
- "ConvexShape:getPoint"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of points."
- }
- }
- }
- }
- },
- {
- name = "getScale",
- summary = "Get the scale the ConvexShape was created with.",
- description = "Returns the scale the ConvexShape was created with.",
- key = "ConvexShape:getScale",
- module = "lovr.physics",
- related = {
- "lovr.physics.newConvexShape",
- "World:newConvexCollider"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "scale",
- type = "number",
- description = "The scale."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "CylinderShape",
- summary = "A cylinder Shape.",
- description = "A type of `Shape` that can be used for cylinder-shaped things.",
- key = "CylinderShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newCylinderShape",
- "World:newCylinderCollider"
- },
- extends = "Shape",
- methods = {
- {
- name = "getLength",
- summary = "Get the length of the CylinderShape.",
- description = "Returns the length of the CylinderShape.",
- key = "CylinderShape:getLength",
- module = "lovr.physics",
- related = {
- "CylinderShape:getRadius",
- "CylinderShape:setRadius"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "length",
- type = "number",
- description = "The length of the cylinder, in meters."
- }
- }
- }
- }
- },
- {
- name = "getRadius",
- summary = "Get the radius of the CylinderShape.",
- description = "Returns the radius of the CylinderShape.",
- key = "CylinderShape:getRadius",
- module = "lovr.physics",
- related = {
- "CylinderShape:getLength",
- "CylinderShape:setLength"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder, in meters."
- }
- }
- }
- }
- },
- {
- name = "setLength",
- summary = "Set the length of the CylinderShape.",
- description = "Sets the length of the CylinderShape.",
- key = "CylinderShape:setLength",
- module = "lovr.physics",
- notes = "This changes the mass of the shape. If the shape is attached to a collider with automatic mass enabled, the mass properties of the collider will update as well.\n\nChanging shapes can make the physics engine explode since it can cause objects to overlap in unnatural ways.",
- related = {
- "CylinderShape:getRadius",
- "CylinderShape:setRadius"
- },
- variants = {
- {
- arguments = {
- {
- name = "length",
- type = "number",
- description = "The new length, in meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setRadius",
- summary = "Set the radius of the CylinderShape.",
- description = "Sets the radius of the CylinderShape.",
- key = "CylinderShape:setRadius",
- module = "lovr.physics",
- notes = "This changes the mass of the shape. If the shape is attached to a collider with automatic mass enabled, the mass properties of the collider will update as well.\n\nChanging shapes can make the physics engine explode since it can cause objects to overlap in unnatural ways.",
- related = {
- "CylinderShape:getLength",
- "CylinderShape:setLength"
- },
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The new radius, in meters."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "DistanceJoint",
- summary = "A fixed distance joint.",
- description = "A DistanceJoint is a type of `Joint` that tries to keep two colliders within a certain distance. The distance is determined by the initial distance between the anchor points. The joint allows for rotation on the anchor points.",
- key = "DistanceJoint",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newDistanceJoint"
- },
- extends = "Joint",
- methods = {
- {
- name = "getLimits",
- summary = "Get the minimum and maximum distance.",
- description = "Returns the minimum and maximum distance allowed between the Colliders.",
- key = "DistanceJoint:getLimits",
- module = "lovr.physics",
- notes = "The limits default to the distance between the Colliders when the Joint was created.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "min",
- type = "number",
- description = "The minimum distance, in meters. The Colliders won't be able to get closer than this."
- },
- {
- name = "max",
- type = "number",
- description = "The maximum distance, in meters. The Colliders won't be able to get further than this."
- }
- }
- }
- }
- },
- {
- name = "getSpring",
- summary = "Get the spring parameters of the joint.",
- description = "Returns the DistanceJoint's spring parameters. Use this to control how fast the joint pulls the colliders back together at the distance limits.",
- key = "DistanceJoint:getSpring",
- module = "lovr.physics",
- notes = "Higher frequencies make the spring more stiff. When zero (the default), the spring is disabled and the limits will be as stiff as possible.\n\nThe damping ratio controls how quickly the oscillation slows down:\n\n- Undamped: Zero damping will cause the spring to oscillate forever. (Note that the spring may\n still lose a small amount of energy over time).\n- Underdamped: Damping less than one results in a system that is underdamped. The spring will\n oscillate around the target, but the oscillations will decay over time, eventually stabilizing\n at the target.\n- Overdamped: Damping greater than one will not have any oscillation, and the spring will take\n extra time to reach the target.\n- Critical Damping: When the damping is exactly 1.0, there is no oscillation and the spring\n takes the minimum amount of time to reach the target (based on the frequency).\n\nThe default damping ratio is 1.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled."
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring."
- }
- }
- }
- }
- },
- {
- name = "setLimits",
- summary = "Set the minimum and maximum distance.",
- description = "Sets the minimum and maximum distance allowed between the Colliders.",
- key = "DistanceJoint:setLimits",
- module = "lovr.physics",
- notes = "The limits default to the distance between the Colliders when the Joint was created.",
- variants = {
- {
- arguments = {
- {
- name = "min",
- type = "number",
- description = "The minimum distance, in meters. The Colliders won't be able to get closer than this.",
- default = "0"
- },
- {
- name = "max",
- type = "number",
- description = "The maximum distance, in meters. The Colliders won't be able to get further than this.",
- default = "min"
- }
- },
- returns = {}
- },
- {
- description = "Remove the limits, setting the minimum distance to zero and the maximum distance to infinity.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setSpring",
- summary = "Set the spring parameters of the joint.",
- description = "Sets the DistanceJoint's spring parameters. Use this to control how fast the joint pulls the colliders back together at the distance limits.",
- key = "DistanceJoint:setSpring",
- module = "lovr.physics",
- notes = "Higher frequencies make the spring more stiff. When zero (the default), the spring is disabled and the limits will be as stiff as possible.\n\nThe damping ratio controls how quickly the oscillation slows down:\n\n- Undamped: Zero damping will cause the spring to oscillate forever. (Note that the spring may\n still lose a small amount of energy over time).\n- Underdamped: Damping less than one results in a system that is underdamped. The spring will\n oscillate around the target, but the oscillations will decay over time, eventually stabilizing\n at the target.\n- Overdamped: Damping greater than one will not have any oscillation, and the spring will take\n extra time to reach the target.\n- Critical Damping: When the damping is exactly 1.0, there is no oscillation and the spring\n takes the minimum amount of time to reach the target (based on the frequency).",
- variants = {
- {
- arguments = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled.",
- default = "0.0"
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- }
- },
- related = {
- "Collider"
- }
- },
- {
- name = "HingeJoint",
- summary = "A hinge joint.",
- description = "A HingeJoint is a type of `Joint` that only allows colliders to rotate on a single axis.",
- key = "HingeJoint",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newHingeJoint"
- },
- extends = "Joint",
- methods = {
- {
- name = "getAngle",
- summary = "Get the current angle of the HingeJoint.",
- description = "Returns the current angle of the HingeJoint, relative to the rest position.",
- key = "HingeJoint:getAngle",
- module = "lovr.physics",
- related = {
- "HingeJoint:getAxis",
- "HingeJoint:getLimits",
- "HingeJoint:setLimits"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The hinge angle, in radians."
- }
- }
- }
- }
- },
- {
- name = "getAxis",
- summary = "Get the rotation axis of the HingeJoint.",
- description = "Returns the axis of the hinge, in world space.",
- key = "HingeJoint:getAxis",
- module = "lovr.physics",
- related = {
- "HingeJoint:getAngle",
- "Joint:getAnchors"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the axis."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the axis."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the axis."
- }
- }
- }
- }
- },
- {
- name = "getFriction",
- summary = "Get the friction of the HingeJoint.",
- description = "Returns the friction of the HingeJoint. This is a maximum torque force that will be applied, in newton meters.",
- key = "HingeJoint:getFriction",
- module = "lovr.physics",
- notes = "Friction is only applied when the motor is disabled.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "friction",
- type = "number",
- description = "The friction, in newton meters."
- }
- }
- }
- }
- },
- {
- name = "getLimits",
- summary = "Get the angle limits of the HingeJoint.",
- description = "Returns the angle limits of the HingeJoint. The \"zero\" angle is determined by the relative position of the colliders at the time the joint was created.",
- key = "HingeJoint:getLimits",
- module = "lovr.physics",
- notes = "The default limits are -π and π.",
- related = {
- "HingeJoint:getAngle"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "min",
- type = "number",
- description = "The minimum angle, in radians. Always between -π and 0."
- },
- {
- name = "max",
- type = "number",
- description = "The maximum angle, in radians. Always between 0 and π."
- }
- }
- }
- }
- },
- {
- name = "getMaxMotorTorque",
- summary = "Get the maximum amount of torque the motor can use.",
- description = "Returns the maximum amount of torque the motor can use to reach its target, in newton meters.\n\nThere are separate limits for each direction the hinge can move. They're usually kept the same, but one of them can be set to zero to make a motor that can only push in one direction. Note that both limits are positive.",
- key = "HingeJoint:getMaxMotorTorque",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMotorTorque"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "positive",
- type = "number",
- description = "The maximum amount of torque the motor can use to push the hinge in the \"positive\" direction, in newton meters."
- },
- {
- name = "negative",
- type = "number",
- description = "The maximum amount of torque the motor can use to push the hinge in the \"negative\" direction, in newton meters."
- }
- }
- }
- }
- },
- {
- name = "getMotorMode",
- summary = "Get the motor mode of the HingeJoint.",
- description = "Returns the motor mode of the HingeJoint. When enabled, the motor will drive the hinge to a target angle (for the `position` mode) or a target speed (for the `velocity` mode), set by `HingeJoint:setMotorTarget`.",
- key = "HingeJoint:getMotorMode",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMotorTarget",
- "HingeJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mode",
- type = "MotorMode",
- description = "The mode of the motor, or `nil` if the motor is disabled."
- }
- }
- }
- }
- },
- {
- name = "getMotorSpring",
- summary = "Get the spring parameters of the motor target.",
- description = "Returns the spring parameters of the motor target. These are similar to the spring parameters set by `HingeJoint:setSpring`, but they apply to the motor when it reaches its target instead of the angle limits of the hinge joint. Note that these only take effect when the motor mode is `position`.",
- key = "HingeJoint:getMotorSpring",
- module = "lovr.physics",
- notes = "See `HingeJoint:setSpring` for more detailed info on how the spring parameters work.",
- related = {
- "HingeJoint:getSpring",
- "HingeJoint:setSpring",
- "HingeJoint:getMotorTarget",
- "HingeJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled."
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring."
- }
- }
- }
- }
- },
- {
- name = "getMotorTarget",
- summary = "Get the target of the hinge motor.",
- description = "Returns the target value for the HingeJoint's motor. This is either a target angle or a target velocity, based on the mode set by `HingeJoint:setMotorMode`.",
- key = "HingeJoint:getMotorTarget",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMotorMode",
- "HingeJoint:setMotorMode"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "target",
- type = "number",
- description = "The target value, in radians or radians per second, depending on the mode."
- }
- }
- }
- }
- },
- {
- name = "getMotorTorque",
- summary = "Get the current motor torque.",
- description = "Returns the current torque the motor is using to reach its target, in newton meters.",
- key = "HingeJoint:getMotorTorque",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMaxMotorTorque",
- "HingeJoint:setMaxMotorTorque"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "torque",
- type = "number",
- description = "The current torque, in newton meters."
- }
- }
- }
- }
- },
- {
- name = "getSpring",
- summary = "Get the spring parameters of the HingeJoint limits.",
- description = "Returns the spring parameters of the HingeJoint. Use this to make the angle limits of the hinge \"soft\". When the motor is active, a separate set of spring parameters can be set on the motor, see `HingeJoint:setMotorSpring`.",
- key = "HingeJoint:getSpring",
- module = "lovr.physics",
- notes = "Higher frequencies make the spring more stiff. When zero (the default), the spring is disabled and the limits will be as stiff as possible.\n\nThe damping ratio controls how quickly the oscillation slows down:\n\n- Undamped: Zero damping will cause the spring to oscillate forever. (Note that the spring may\n still lose a small amount of energy over time).\n- Underdamped: Damping less than one results in a system that is underdamped. The spring will\n oscillate around the target, but the oscillations will decay over time, eventually stabilizing\n at the target.\n- Overdamped: Damping greater than one will not have any oscillation, and the spring will take\n extra time to reach the target.\n- Critical Damping: When the damping is exactly 1.0, there is no oscillation and the spring\n takes the minimum amount of time to reach the target (based on the frequency).\n\nThe default damping ratio is 1.",
- related = {
- "HingeJoint:getMotorSpring",
- "HingeJoint:setMotorSpring"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled."
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring."
- }
- }
- }
- }
- },
- {
- name = "setFriction",
- summary = "Set the friction of the HingeJoint.",
- description = "Sets the friction of the HingeJoint. This is a maximum torque force that will be applied, in newton meters.",
- key = "HingeJoint:setFriction",
- module = "lovr.physics",
- notes = "Friction is only applied when the motor is disabled.",
- variants = {
- {
- arguments = {
- {
- name = "friction",
- type = "number",
- description = "The friction, in newton meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setLimits",
- summary = "Set the angle limits of the HingeJoint.",
- description = "Sets the angle limits of the HingeJoint. The \"zero\" angle is determined by the relative position of the colliders at the time the joint was created.",
- key = "HingeJoint:setLimits",
- module = "lovr.physics",
- notes = "The default limits are -π and π.",
- related = {
- "HingeJoint:getAngle"
- },
- variants = {
- {
- arguments = {
- {
- name = "min",
- type = "number",
- description = "The minimum angle, in radians. Should be between -π and 0."
- },
- {
- name = "max",
- type = "number",
- description = "The maximum angle, in radians. Should be between 0 and π."
- }
- },
- returns = {}
- },
- {
- description = "Disable the limits, setting them to -π and π.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setMaxMotorTorque",
- summary = "Set the maximum amount of torque the motor can use.",
- description = "Sets the maximum amount of torque the motor can use to reach its target, in newton meters.\n\nThere are separate limits for each direction the hinge can move. They're usually kept the same, but one of them can be set to zero to make a motor that can only push in one direction. Note that both limits are positive.",
- key = "HingeJoint:setMaxMotorTorque",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMotorTorque"
- },
- variants = {
- {
- arguments = {
- {
- name = "positive",
- type = "number",
- description = "The maximum amount of torque the motor can use to push the hinge in the \"positive\" direction, in newton meters.",
- default = "math.huge"
- },
- {
- name = "negative",
- type = "number",
- description = "The maximum amount of torque the motor can use to push the hinge in the \"negative\" direction, in newton meters.",
- default = "positive"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setMotorMode",
- summary = "Set the motor mode of the HingeJoint.",
- description = "Sets the motor mode of the HingeJoint. When enabled, the motor will drive the hinge to a target angle (for the `position` mode) or a target speed (for the `velocity` mode), set by `HingeJoint:setMotorTarget`.",
- key = "HingeJoint:setMotorMode",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMotorTarget",
- "HingeJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "MotorMode",
- description = "The mode of the motor."
- }
- },
- returns = {}
- },
- {
- description = "Disables the motor.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setMotorSpring",
- summary = "Set the spring parameters of the motor target.",
- description = "Sets the spring parameters of the motor target. These are similar to the spring parameters set by `HingeJoint:setSpring`, but they apply to the motor when it reaches its target instead of the angle limits of the hinge joint. Note that these only take effect when the motor mode is `position`.",
- key = "HingeJoint:setMotorSpring",
- module = "lovr.physics",
- notes = "See `HingeJoint:setSpring` for more detailed info on how the spring parameters work.",
- related = {
- "HingeJoint:getSpring",
- "HingeJoint:setSpring",
- "HingeJoint:getMotorTarget",
- "HingeJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled.",
- default = "0.0"
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setMotorTarget",
- summary = "Set the target of the hinge motor.",
- description = "Sets the target value for the HingeJoint's motor. This is either a target angle or a target velocity, based on the mode set by `HingeJoint:setMotorMode`.",
- key = "HingeJoint:setMotorTarget",
- module = "lovr.physics",
- related = {
- "HingeJoint:getMotorMode",
- "HingeJoint:setMotorMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "target",
- type = "number",
- description = "The target value, in radians or radians per second, depending on the mode."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSpring",
- summary = "Set the spring parameters of the HingeJoint limits.",
- description = "Sets the spring parameters of the HingeJoint. Use this to make the angle limits of the hinge \"soft\". When the motor is active, a separate set of spring parameters can be set on the motor, see `HingeJoint:setMotorSpring`.",
- key = "HingeJoint:setSpring",
- module = "lovr.physics",
- notes = "Higher frequencies make the spring more stiff. When zero (the default), the spring is disabled and the limits will be as stiff as possible.\n\nThe damping ratio controls how quickly the oscillation slows down:\n\n- Undamped: Zero damping will cause the spring to oscillate forever. (Note that the spring may\n still lose a small amount of energy over time).\n- Underdamped: Damping less than one results in a system that is underdamped. The spring will\n oscillate around the target, but the oscillations will decay over time, eventually stabilizing\n at the target.\n- Overdamped: Damping greater than one will not have any oscillation, and the spring will take\n extra time to reach the target.\n- Critical Damping: When the damping is exactly 1.0, there is no oscillation and the spring\n takes the minimum amount of time to reach the target (based on the frequency).",
- related = {
- "HingeJoint:getMotorSpring",
- "HingeJoint:setMotorSpring"
- },
- variants = {
- {
- arguments = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled.",
- default = "0.0"
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- }
- },
- related = {
- "Collider"
- }
- },
- {
- name = "Joint",
- summary = "Joins two Colliders together.",
- description = "A Joint is a physics object that constrains the movement of two Colliders.",
- key = "Joint",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newWeldJoint",
- "lovr.physics.newBallJoint",
- "lovr.physics.newConeJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newSliderJoint"
- },
- methods = {
- {
- name = "destroy",
- summary = "Destroy the Joint.",
- description = "Destroys the Joint, removing it from the World and breaking the connection between its Colliders. There is no way to get the Joint back after destroying it, and attempting to use it will throw an error. To temporarily disable a Joint, use `Joint:setEnabled`.",
- key = "Joint:destroy",
- module = "lovr.physics",
- notes = "Joints are automatically destroyed if either of their Colliders are destroyed or if the World is destroyed or garbage collected.",
- related = {
- "Joint:isDestroyed",
- "Joint:setEnabled",
- "Collider:destroy",
- "Shape:destroy",
- "World:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "getAnchors",
- summary = "Get the anchor points of the Joint.",
- description = "Returns the world space anchor points of the Joint. Joints are attached to each collider at a single point, which is defined when the Joint is created.",
- key = "Joint:getAnchors",
- module = "lovr.physics",
- related = {
- "Joint:getColliders"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x1",
- type = "number",
- description = "The x coordinate of the anchor point on the first Collider, in world space."
- },
- {
- name = "y1",
- type = "number",
- description = "The y coordinate of the anchor point on the first Collider, in world space."
- },
- {
- name = "z1",
- type = "number",
- description = "The z coordinate of the anchor point on the first Collider, in world space."
- },
- {
- name = "x2",
- type = "number",
- description = "The x coordinate of the anchor point on the second Collider, in world space."
- },
- {
- name = "y2",
- type = "number",
- description = "The y coordinate of the anchor point on the second Collider, in world space."
- },
- {
- name = "z2",
- type = "number",
- description = "The z coordinate of the anchor point on the second Collider, in world space."
- }
- }
- }
- }
- },
- {
- name = "getColliders",
- summary = "Get the Colliders the Joint is attached to.",
- description = "Returns the Colliders the Joint is attached to.",
- key = "Joint:getColliders",
- module = "lovr.physics",
- related = {
- "Collider:getJoints"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "colliderA",
- type = "Collider",
- description = "The first Collider."
- },
- {
- name = "colliderB",
- type = "Collider",
- description = "The second Collider."
- }
- }
- }
- }
- },
- {
- name = "getForce",
- summary = "Get the force used to satisfy the Joint's constraint.",
- description = "Returns the magnitude of the force used to satisfy the Joint's constraint during the last physics update, in newtons.\n\nThis is useful for breakable joints. Use `Joint:destroy` to break the joint if its force goes above a threshold.",
- key = "Joint:getForce",
- module = "lovr.physics",
- notes = "This does not include the motor force of a `SliderJoint`, see `SliderJoint:getMotorForce`. that.",
- related = {
- "Joint:getTorque",
- "SliderJoint:getMotorForce"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "force",
- type = "number",
- description = "The magnitude of the force used to satisfy the Joint's constraint."
- }
- }
- }
- }
- },
- {
- name = "getPriority",
- summary = "Get the priority of the Joint.",
- description = "Returns the priority of the Joint. Joints with a higher priority are more likely to be solved correctly. Priority values are non-negative integers.",
- key = "Joint:getPriority",
- module = "lovr.physics",
- notes = "The default priority is zero.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "priority",
- type = "number",
- description = "The integer priority value."
- }
- }
- }
- }
- },
- {
- name = "getTorque",
- summary = "Get the torque used to satisfy the Joint's constraint.",
- description = "Returns the magnitude of the torque used to satisfy the Joint's constraint during the last physics update, in newton meters.\n\nThis is useful for breakable joints. Use `Joint:destroy` to break the joint if its torque goes above a threshold.",
- key = "Joint:getTorque",
- module = "lovr.physics",
- notes = "This does not include the motor force of a `HingeJoint`, see `HingeJoint:getMotorForce`.",
- related = {
- "Joint:getForce",
- "HingeJoint:getMotorTorque"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "torque",
- type = "number",
- description = "The magnitude of the torque used to satisfy the Joint's constraint."
- }
- }
- }
- }
- },
- {
- name = "getType",
- summary = "Get the type of the Joint.",
- description = "Returns the type of the Joint.",
- key = "Joint:getType",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "type",
- type = "JointType",
- description = "The type of the Joint."
- }
- }
- }
- }
- },
- {
- name = "getUserData",
- summary = "Get the Lua value associated with the Joint.",
- description = "Returns the Lua value associated with the Joint.",
- key = "Joint:getUserData",
- module = "lovr.physics",
- notes = "The user data is not shared between threads. Each thread has its own user data for the Joint.",
- related = {
- "Collider:getUserData",
- "Collider:setUserData",
- "Shape:getUserData",
- "Shape:setUserData"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "data",
- type = "*",
- description = "The custom value associated with the Joint."
- }
- }
- }
- }
- },
- {
- name = "isDestroyed",
- summary = "Check if a Joint is destroyed.",
- description = "Returns whether a Joint has been destroyed. This the only method that can be called on a destroyed Joint, using the Joint in any other way will error.",
- key = "Joint:isDestroyed",
- module = "lovr.physics",
- related = {
- "Joint:destroy",
- "Joint:isEnabled",
- "Joint:setEnabled",
- "Collider:destroy",
- "Shape:destroy",
- "World:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "destroyed",
- type = "boolean",
- description = "Whether the Joint has been destroyed."
- }
- }
- }
- }
- },
- {
- name = "isEnabled",
- summary = "Check if the Joint is enabled.",
- description = "Returns whether the Joint is enabled. Disabled joints do not affect the simulation in any way. Use `Joint:setEnabled` to reactivate the Joint later. If the Joint is no longer needed, `Joint:destroy` is a better option that completely removes the Joint from the simulation.",
- key = "Joint:isEnabled",
- module = "lovr.physics",
- related = {
- "Joint:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether the Joint is enabled."
- }
- }
- }
- }
- },
- {
- name = "setEnabled",
- summary = "Enable or disable the Joint.",
- description = "Enable or disable the Joint. Disabled joints do not affect the simulation in any way. If the Joint is no longer needed, `Joint:destroy` is a better option that completely removes the Joint from the simulation.",
- key = "Joint:setEnabled",
- module = "lovr.physics",
- related = {
- "Joint:destroy"
- },
- variants = {
- {
- arguments = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether the Joint should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setPriority",
- summary = "Set the priority of the Joint.",
- description = "Sets the priority of the Joint. Joints with a higher priority are more likely to be solved correctly. Priority values are non-negative integers.",
- key = "Joint:setPriority",
- module = "lovr.physics",
- notes = "The default priority is zero.",
- variants = {
- {
- arguments = {
- {
- name = "priority",
- type = "number",
- description = "The integer priority value."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setUserData",
- summary = "Associate a Lua value with the Joint.",
- description = "Associates a Lua value with the Joint.",
- key = "Joint:setUserData",
- module = "lovr.physics",
- notes = "Set the user data to `nil` to clear any existing reference.\n\nThe user data is not shared between threads. Each thread has its own user data for the Joint.",
- related = {
- "Collider:getUserData",
- "Collider:setUserData",
- "Shape:getUserData",
- "Shape:setUserData"
- },
- variants = {
- {
- arguments = {
- {
- name = "data",
- type = "*",
- description = "The custom value to associate with the Joint."
- }
- },
- returns = {}
- }
- }
- }
- },
- related = {
- "Collider"
- }
- },
- {
- name = "MeshShape",
- summary = "A mesh Shape.",
- description = "A type of `Shape` that can be used for triangle meshes.",
- key = "MeshShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newMeshShape",
- "World:newMeshCollider"
- },
- extends = "Shape",
- methods = {
- {
- name = "getScale",
- summary = "Get the scale the MeshShape was created with.",
- description = "Returns the scale the MeshShape was created with.",
- key = "MeshShape:getScale",
- module = "lovr.physics",
- related = {
- "lovr.physics.newMeshShape",
- "World:newMeshCollider"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "scale",
- type = "number",
- description = "The scale."
- }
- }
- }
- }
- }
- },
- notes = "If a `Collider` contains a MeshShape, it will be forced to become kinematic. `ConvexShape` can be used instead for dynamic mesh colliders."
- },
- {
- name = "Shape",
- summary = "Defines the shape of Colliders.",
- description = "A Shape is a physics object that can be attached to colliders to define their shape.",
- key = "Shape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- methods = {
- {
- name = "containsPoint",
- summary = "Check if a point is inside the shape.",
- description = "Returns whether a point is inside the Shape.\n\nThis takes into account the pose of the Shape's collider (if any), as well as its local offset set with `Shape:setOffset`.",
- key = "Shape:containsPoint",
- module = "lovr.physics",
- related = {
- "Shape:raycast",
- "World:raycast",
- "World:shapecast",
- "World:overlapShape",
- "World:queryBox",
- "World:querySphere"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the point."
- }
- },
- returns = {
- {
- name = "hit",
- type = "boolean",
- description = "Whether the point is inside the Shape."
- }
- }
- },
- {
- arguments = {
- {
- name = "point",
- type = "Vec3",
- description = "The point, as a vector."
- }
- },
- returns = {
- {
- name = "hit",
- type = "boolean",
- description = "Whether the point is inside the Shape."
- }
- }
- }
- }
- },
- {
- name = "destroy",
- summary = "Destroy the Shape.",
- description = "Destroys the Shape, removing it from the Collider it's attached to.",
- key = "Shape:destroy",
- module = "lovr.physics",
- notes = "Calling methods on the Shape after destroying it will error (except for `Shape:isDestroyed`).\n\nIf the Shape is attached to a Collider with automatic mass enabled, the collider's mass properties will update.",
- related = {
- "Shape:isDestroyed",
- "Collider:destroy",
- "Joint:destroy",
- "World:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "getAABB",
- summary = "Get the Shape's axis aligned bounding box.",
- description = "Returns the axis aligned bounding box of the Shape.",
- key = "Shape:getAABB",
- module = "lovr.physics",
- related = {
- "Collider:getAABB"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "minx",
- type = "number",
- description = "The minimum x coordinate of the box."
- },
- {
- name = "maxx",
- type = "number",
- description = "The maximum x coordinate of the box."
- },
- {
- name = "miny",
- type = "number",
- description = "The minimum y coordinate of the box."
- },
- {
- name = "maxy",
- type = "number",
- description = "The maximum y coordinate of the box."
- },
- {
- name = "minz",
- type = "number",
- description = "The minimum z coordinate of the box."
- },
- {
- name = "maxz",
- type = "number",
- description = "The maximum z coordinate of the box."
- }
- }
- }
- }
- },
- {
- name = "getCenterOfMass",
- summary = "Get the center of mass of the Shape.",
- description = "Returns the center of mass of the Shape. Currently the only shape that can have a non-zero center of mass is `ConvexShape`.",
- key = "Shape:getCenterOfMass",
- module = "lovr.physics",
- notes = "`MeshShape` and `TerrainShape` do not have a well-defined mass, this function returns zero for those shapes.",
- related = {
- "Collider:getCenterOfMass",
- "Shape:getOffset",
- "Shape:setOffset"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the center of mass."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the center of mass."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the center of mass."
- }
- }
- }
- }
- },
- {
- name = "getCollider",
- summary = "Get the Collider the Shape is attached to.",
- description = "Returns the Collider the Shape is attached to.\n\nThis function will return `nil` if the Shape is not attached to a Collider. When a Shape isn't attached to a Collider, the Shape can still be used for queries with `World:overlapShape` and `World:shapecast`.",
- key = "Shape:getCollider",
- module = "lovr.physics",
- notes = "A Shape can only be attached to one Collider at a time.",
- related = {
- "Collider",
- "Collider:getShape",
- "Collider:getShapes",
- "Collider:addShape",
- "Collider:removeShape"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The Collider the Shape is attached to, or nil if the Shape isn't attached to a Collider."
- }
- }
- }
- }
- },
- {
- name = "getDensity",
- summary = "Get the density of the Shape.",
- description = "Returns the density of the Shape, in kilograms per cubic meter. The density, combined with the volume of the Shape, determines the Shape's overall mass.",
- key = "Shape:getDensity",
- module = "lovr.physics",
- notes = "The default density is 1,000, which is the density of water.\n\n`MeshShape` and `TerrainShape` do not have volume, and return 0.",
- related = {
- "Shape:getVolume",
- "Shape:getMass"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "density",
- type = "number",
- description = "The density of the Shape, in kilograms per cubic meter."
- }
- }
- }
- }
- },
- {
- name = "getInertia",
- summary = "Get the inertia of the Shape.",
- description = "Returns the inertia of the Shape.\n\nInertia is kind of like \"angular mass\". Regular mass determines how resistant a Collider is to linear forces (movement), whereas inertia determines how resistant the Collider is to torque (rotation). Colliders with less inertia are more spinny.\n\nIn 3D, inertia is represented by a 3x3 matrix, called a tensor. To make calculations easier, the physics engine stores the inertia using eigenvalue decomposition, splitting the matrix into a diagonal matrix and a rotation. It's complicated!\n\nIn a realistic simulation, mass and inertia follow a linear relationship. If the mass of an object increases, the diagonal part of its inertia should increase proportionally.",
- key = "Shape:getInertia",
- module = "lovr.physics",
- notes = "`MeshShape` and `TerrainShape` do not have mass or volue, and for those shapes this function returns zeroes.",
- related = {
- "Shape:getMass",
- "Shape:getCenterOfMass",
- "Collider:getInertia"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "dx",
- type = "number",
- description = "The x component of the diagonal matrix."
- },
- {
- name = "dy",
- type = "number",
- description = "The y component of the diagonal matrix."
- },
- {
- name = "dz",
- type = "number",
- description = "The z component of the diagonal matrix."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle of the inertia rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the inertia rotation axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the inertia rotation axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the inertia rotation axis."
- }
- }
- }
- }
- },
- {
- name = "getMass",
- summary = "Get the mass of the Shape.",
- description = "Returns the mass of the Shape, in kilograms. The mass is the volume multiplied by the density.",
- key = "Shape:getMass",
- module = "lovr.physics",
- notes = "The mass of a Collider is the sum of the mass of all of its Shapes. The center of a mass of a Collider is the average of all of its Shapes, weighted by their mass.\n\n`MeshShape` and `TerrainShape` do not have mass, and will return 0.",
- related = {
- "Collider:getMass",
- "Collider:setMass",
- "Collider:resetMassData",
- "Shape:getVolume",
- "Shape:getDensity",
- "Shape:setDensity",
- "Shape:getInertia",
- "Shape:getCenterOfMass"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mass",
- type = "number",
- description = "The mass of the Shape, in kilograms."
- }
- }
- }
- }
- },
- {
- name = "getOffset",
- summary = "Get the local offset of the Shape.",
- description = "Returns the local offset of the Shape. When the Shape is attached to a Collider, it will have this offset relative to the Collider.",
- key = "Shape:getOffset",
- module = "lovr.physics",
- related = {
- "Shape:getPosition",
- "Shape:getOrientation",
- "Shape:getPose"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The local x offset of the Shape, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The local y offset of the Shape, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The local z offset of the Shape, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Shape is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getOrientation",
- summary = "Get the orientation of the Shape.",
- description = "Get the orientation of the Shape in world space, taking into account the position and orientation of the Collider it's attached to, if any. Shapes that aren't attached to a Collider will return their local offset.",
- key = "Shape:getOrientation",
- module = "lovr.physics",
- related = {
- "Shape:getPosition",
- "Shape:getPose",
- "Shape:getOffset",
- "Shape:setOffset"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Shape is rotated."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the rotation axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the rotation axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the rotation axis."
- }
- }
- }
- }
- },
- {
- name = "getPose",
- summary = "Get the pose of the Shape.",
- description = "Returns the position and orientation of the Shape in world space, taking into the account the position and orientation of the Collider it's attached to, if any. Shapes that aren't attached to a Collider will return their local offset.",
- key = "Shape:getPose",
- module = "lovr.physics",
- related = {
- "Shape:getPosition",
- "Shape:getOrientation",
- "Shape:getOffset",
- "Shape:setOffset"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Shape, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Shape, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Shape, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Shape is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- summary = "Get the position of the Shape.",
- description = "Returns the position of the Shape in world space, taking into the account the position and orientation of the Collider it's attached to, if any. Shapes that aren't attached to a Collider will return their local offset.",
- key = "Shape:getPosition",
- module = "lovr.physics",
- related = {
- "Shape:getOrientation",
- "Shape:getPose",
- "Shape:getOffset",
- "Shape:setOffset"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position, in world space."
- },
- {
- name = "y",
- type = "number",
- description = "The y position, in world space."
- },
- {
- name = "z",
- type = "number",
- description = "The z position, in world space."
- }
- }
- }
- }
- },
- {
- name = "getType",
- summary = "Get the type of the Shape.",
- description = "Returns the type of the Shape.",
- key = "Shape:getType",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "type",
- type = "ShapeType",
- description = "The type of the Shape."
- }
- }
- }
- }
- },
- {
- name = "getUserData",
- summary = "Get the Lua value associated with the Shape.",
- description = "Returns the Lua value associated with the Shape.",
- key = "Shape:getUserData",
- module = "lovr.physics",
- notes = "The user data is not shared between threads. Each thread has its own user data for the Shape.",
- related = {
- "Collider:getUserData",
- "Collider:setUserData",
- "Joint:getUserData",
- "Joint:setUserData"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "data",
- type = "*",
- description = "The custom value associated with the Shape."
- }
- }
- }
- }
- },
- {
- name = "getVolume",
- summary = "Get the volume of the Shape.",
- description = "Returns the volume of the Shape, in cubic meters.",
- key = "Shape:getVolume",
- module = "lovr.physics",
- notes = "`MeshShape` and `TerrainShape` do not have volume, and will return 0.",
- related = {
- "Shape:getDensity",
- "Shape:setDensity",
- "Shape:getMass",
- "Shape:getAABB"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "volume",
- type = "number",
- description = "The volume of the shape, in cubic meters."
- }
- }
- }
- }
- },
- {
- name = "isDestroyed",
- summary = "Check if the Shape is destroyed.",
- description = "Returns whether the Shape has been destroyed. Destroyed shapes can not be used for anything.",
- key = "Shape:isDestroyed",
- module = "lovr.physics",
- related = {
- "Shape:destroy",
- "Collider:isDestroyed",
- "Joint:isDestroyed",
- "World:isDestroyed"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "destroyed",
- type = "boolean",
- description = "Whether the Shape has been destroyed."
- }
- }
- }
- }
- },
- {
- name = "raycast",
- summary = "Cast a ray against the shape.",
- description = "Casts a ray against the Shape and returns the first intersection.\n\nThis takes into account the pose of the Shape's collider (if any), as well as its local offset set with `Shape:setOffset`.",
- key = "Shape:raycast",
- module = "lovr.physics",
- related = {
- "World:raycast",
- "Shape:containsPoint",
- "World:shapecast",
- "World:overlapShape"
- },
- variants = {
- {
- arguments = {
- {
- name = "x1",
- type = "number",
- description = "The x coordinate of the origin of the ray."
- },
- {
- name = "y1",
- type = "number",
- description = "The y coordinate of the origin of the ray."
- },
- {
- name = "z1",
- type = "number",
- description = "The z coordinate of the origin of the ray."
- },
- {
- name = "x2",
- type = "number",
- description = "The x coordinate of the endpoint of the ray."
- },
- {
- name = "y2",
- type = "number",
- description = "The y coordinate of the endpoint of the ray."
- },
- {
- name = "z2",
- type = "number",
- description = "The z coordinate of the endpoint of the ray."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the impact point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the impact point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the impact point."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the normal vector."
- },
- {
- name = "triangle",
- type = "number",
- description = "The index of the triangle that was hit, or `nil` if this is not a MeshShape."
- }
- }
- },
- {
- arguments = {
- {
- name = "origin",
- type = "Vec3",
- description = "The origin of the ray."
- },
- {
- name = "endpoint",
- type = "Vec3",
- description = "The endpoint of the ray."
- }
- },
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the impact point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the impact point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the impact point."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the normal vector."
- },
- {
- name = "triangle",
- type = "number",
- description = "The index of the triangle that was hit, or `nil` if this is not a MeshShape."
- }
- }
- }
- }
- },
- {
- name = "setDensity",
- summary = "Set the density of the Shape.",
- description = "Sets the density of the Shape, in kilograms per cubic meter. The density, combined with the volume of the Shape, determines the Shape's overall mass.",
- key = "Shape:setDensity",
- module = "lovr.physics",
- notes = "This changes the mass of the Shape. If the Shape is attached to a Collider with automatic mass enabled, the Collider's mass properties will change as well.\n\nThe default density is 1,000, which is the density of water.\n\n`MeshShape` and `TerrainShape` do not have mass.",
- related = {
- "Shape:getVolume",
- "Shape:getMass"
- },
- variants = {
- {
- arguments = {
- {
- name = "density",
- type = "number",
- description = "The density of the Shape, in kilograms per cubic meter."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setOffset",
- summary = "Set the local offset of the Shape.",
- description = "Sets the local offset of the Shape. When the Shape is attached to a Collider, it will have this offset relative to the Collider.",
- key = "Shape:setOffset",
- module = "lovr.physics",
- related = {
- "Shape:getPosition",
- "Shape:getOrientation",
- "Shape:getPose"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The local x offset of the Shape, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The local y offset of the Shape, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The local z offset of the Shape, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The number of radians the Shape is rotated around its axis of rotation."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The local offset of the Shape, in meters."
- },
- {
- name = "rotation",
- type = "Quat",
- description = "The local rotation of the Shape, in meters."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setUserData",
- summary = "Associate a Lua value with the Shape.",
- description = "Associates a Lua value with the Shape.",
- key = "Shape:setUserData",
- module = "lovr.physics",
- notes = "Set the user data to `nil` to clear any existing reference.\n\nThe user data is not shared between threads. Each thread has its own user data for the Shape.",
- related = {
- "Collider:getUserData",
- "Collider:setUserData",
- "Joint:getUserData",
- "Joint:setUserData"
- },
- variants = {
- {
- arguments = {
- {
- name = "data",
- type = "*",
- description = "The custom value to associate with the Shape."
- }
- },
- returns = {}
- }
- }
- }
- },
- sections = {
- {
- name = "Basics",
- links = {
- "Shape:getType",
- "Shape:destroy",
- "Shape:isDestroyed",
- "Shape:getCollider",
- "Shape:getUserData",
- "Shape:setUserData"
- }
- },
- {
- name = "Position",
- links = {
- "Shape:getOffset",
- "Shape:setOffset",
- "Shape:getPosition",
- "Shape:getOrientation",
- "Shape:getPose",
- "Shape:getAABB"
- }
- },
- {
- name = "Mass",
- links = {
- "Shape:getVolume",
- "Shape:getDensity",
- "Shape:setDensity",
- "Shape:getMass",
- "Shape:getInertia",
- "Shape:getCenterOfMass"
- }
- },
- {
- name = "Queries",
- links = {
- "Shape:containsPoint",
- "Shape:raycast"
- }
- }
- }
- },
- {
- name = "SliderJoint",
- summary = "A slider joint.",
- description = "A SliderJoint is a type of `Joint` that only allows colliders to move on a single axis.",
- key = "SliderJoint",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newSliderJoint"
- },
- extends = "Joint",
- methods = {
- {
- name = "getAxis",
- summary = "Get the axis of the SliderJoint.",
- description = "Returns the axis of the slider, in world space.",
- key = "SliderJoint:getAxis",
- module = "lovr.physics",
- related = {
- "SliderJoint:getPosition"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x component of the axis."
- },
- {
- name = "y",
- type = "number",
- description = "The y component of the axis."
- },
- {
- name = "z",
- type = "number",
- description = "The z component of the axis."
- }
- }
- }
- }
- },
- {
- name = "getFriction",
- summary = "Get the friction of the SliderJoint.",
- description = "Returns the friction of the SliderJoint. This is a maximum friction force that will be applied, in newtons, opposing movement along the slider axis.",
- key = "SliderJoint:getFriction",
- module = "lovr.physics",
- notes = "Friction is only applied when the motor is disabled.",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "friction",
- type = "number",
- description = "The maximum friction force, in newtons."
- }
- }
- }
- }
- },
- {
- name = "getLimits",
- summary = "Get the position limits of the SliderJoint.",
- description = "Returns the position limits of the SliderJoint. The \"zero\" position is determined by the relative position of the colliders at the time the joint was created, and positive positions are further apart along the slider axis.",
- key = "SliderJoint:getLimits",
- module = "lovr.physics",
- notes = "The default limits are -math.huge and math.huge (no limits).",
- related = {
- "SliderJoint:getPosition"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "min",
- type = "number",
- description = "The minimum position, in meters. Must be less than or equal to zero."
- },
- {
- name = "max",
- type = "number",
- description = "The maximum position, in meters. Must be greater than or equal to zero."
- }
- }
- }
- }
- },
- {
- name = "getMaxMotorForce",
- summary = "Get the maximum amount of force the motor can use.",
- description = "Returns the maximum amount of force the motor can use to reach its target, in newtons.\n\nThere are separate limits for each direction the slider can move. They're usually kept the same, but one of them can be set to zero to make a motor that can only push in one direction. Note that both limits are positive.",
- key = "SliderJoint:getMaxMotorForce",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMotorForce"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "positive",
- type = "number",
- description = "The maximum amount of force the motor can use to push the slider in the \"positive\" direction, in newtons."
- },
- {
- name = "negative",
- type = "number",
- description = "The maximum amount of force the motor can use to push the slider in the \"negative\" direction, in newtons."
- }
- }
- }
- }
- },
- {
- name = "getMotorForce",
- summary = "Get the current motor force.",
- description = "Returns the current force the motor is using to reach its target, in newtons.",
- key = "SliderJoint:getMotorForce",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMaxMotorForce",
- "SliderJoint:setMaxMotorForce"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "force",
- type = "number",
- description = "The current force, in newtons."
- }
- }
- }
- }
- },
- {
- name = "getMotorMode",
- summary = "Get the motor mode of the SliderJoint.",
- description = "Returns the motor mode of the SliderJoint. When enabled, the motor will drive the slider to a target position (for the `position` mode) or a target speed (for the `velocity` mode), set by `SliderJoint:setMotorTarget`.",
- key = "SliderJoint:getMotorMode",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMotorTarget",
- "SliderJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "mode",
- type = "MotorMode",
- description = "The mode of the motor, or `nil` if the motor is disabled."
- }
- }
- }
- }
- },
- {
- name = "getMotorSpring",
- summary = "Get the spring parameters of the motor target.",
- description = "Returns the spring parameters of the motor target. These are similar to the spring parameters set by `SliderJoint:setSpring`, but they apply to the motor when it reaches its target instead of the position limits of the slider joint. Note that these only take effect when the motor mode is `position`.",
- key = "SliderJoint:getMotorSpring",
- module = "lovr.physics",
- notes = "See `SliderJoint:setSpring` for more detailed info on how the spring parameters work.",
- related = {
- "SliderJoint:getSpring",
- "SliderJoint:setSpring",
- "SliderJoint:getMotorTarget",
- "SliderJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled."
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring."
- }
- }
- }
- }
- },
- {
- name = "getMotorTarget",
- summary = "Get the target of the slider motor.",
- description = "Returns the target value for the SliderJoint's motor. This is either a target position or a target velocity, based on the mode set by `SliderJoint:setMotorMode`.",
- key = "SliderJoint:getMotorTarget",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMotorMode",
- "SliderJoint:setMotorMode"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "target",
- type = "number",
- description = "The target value, in meters or meters per second, depending on the mode."
- }
- }
- }
- }
- },
- {
- name = "getPosition",
- summary = "Get how far the SliderJoint is extended.",
- description = "Returns the position of the slider joint. The \"zero\" position is the relative distance the colliders were at when the joint is created, and positive positions are further apart along the slider's axis.",
- key = "SliderJoint:getPosition",
- module = "lovr.physics",
- related = {
- "SliderJoint:getAxis",
- "SliderJoint:setLimits"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "position",
- type = "number",
- description = "The position of the slider joint, in meters."
- }
- }
- }
- }
- },
- {
- name = "getSpring",
- summary = "Get the spring parameters of the SliderJoint limits.",
- description = "Returns the spring parameters of the SliderJoint. Use this to make the position limits of the slider \"soft\". When the motor is active, a separate set of spring parameters can be set on the motor, see `SliderJoint:setMotorSpring`.",
- key = "SliderJoint:getSpring",
- module = "lovr.physics",
- notes = "Higher frequencies make the spring more stiff. When zero (the default), the spring is disabled and the limits will be as stiff as possible.\n\nThe damping ratio controls how quickly the oscillation slows down:\n\n- Undamped: Zero damping will cause the spring to oscillate forever. (Note that the spring may\n still lose a small amount of energy over time).\n- Underdamped: Damping less than one results in a system that is underdamped. The spring will\n oscillate around the target, but the oscillations will decay over time, eventually stabilizing\n at the target.\n- Overdamped: Damping greater than one will not have any oscillation, and the spring will take\n extra time to reach the target.\n- Critical Damping: When the damping is exactly 1.0, there is no oscillation and the spring\n takes the minimum amount of time to reach the target (based on the frequency).\n\nThe default damping ratio is 1.",
- related = {
- "SliderJoint:getMotorSpring",
- "SliderJoint:setMotorSpring"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled."
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring."
- }
- }
- }
- }
- },
- {
- name = "setFriction",
- summary = "Set the friction of the SliderJoint.",
- description = "Sets the friction of the SliderJoint. This is a maximum friction force that will be applied, in newtons, opposing movement along the slider axis.",
- key = "SliderJoint:setFriction",
- module = "lovr.physics",
- notes = "Friction is only applied when the motor is disabled.",
- variants = {
- {
- arguments = {
- {
- name = "friction",
- type = "number",
- description = "The maximum friction force, in newtons."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setLimits",
- summary = "Set the position limits of the SliderJoint.",
- description = "Sets the position limits of the SliderJoint. The \"zero\" position is determined by the relative position of the colliders at the time the joint was created, and positive distances are further apart on the slider axis.",
- key = "SliderJoint:setLimits",
- module = "lovr.physics",
- notes = "The default limits are -math.huge and math.huge.",
- related = {
- "SliderJoint:getPosition"
- },
- variants = {
- {
- arguments = {
- {
- name = "min",
- type = "number",
- description = "The minimum position, in meters. Must be less than or equal to zero."
- },
- {
- name = "max",
- type = "number",
- description = "The maximum position, in meters. Must be greater than or equal to zero."
- }
- },
- returns = {}
- },
- {
- description = "Disable the limits, setting them to -math.huge and math.huge.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setMaxMotorForce",
- summary = "Set the maximum amount of force the motor can use.",
- description = "Sets the maximum amount of force the motor can use to reach its target, in newtons.\n\nThere are separate limits for each direction the slider can move. They're usually kept the same, but one of them can be set to zero to make a motor that can only push in one direction. Note that both limits are positive.",
- key = "SliderJoint:setMaxMotorForce",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMotorForce"
- },
- variants = {
- {
- arguments = {
- {
- name = "positive",
- type = "number",
- description = "The maximum amount of force the motor can use to push the slider in the \"positive\" direction, in newtons.",
- default = "math.huge"
- },
- {
- name = "negative",
- type = "number",
- description = "The maximum amount of force the motor can use to push the slider in the \"negative\" direction, in newtons.",
- default = "positive"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setMotorMode",
- summary = "Set the motor mode of the SliderJoint.",
- description = "Sets the motor mode of the SliderJoint. When enabled, the motor will drive the slider to a target position (for the `position` mode) or a target speed (for the `velocity` mode), set by `SliderJoint:setMotorTarget`.",
- key = "SliderJoint:setMotorMode",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMotorTarget",
- "SliderJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {
- {
- name = "mode",
- type = "MotorMode",
- description = "The mode of the motor."
- }
- },
- returns = {}
- },
- {
- description = "Disables the motor.",
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "setMotorSpring",
- summary = "Set the spring parameters of the motor target.",
- description = "Sets the spring parameters of the motor target. These are similar to the spring parameters set by `SldierJoint:setSpring`, but they apply to the motor when it reaches its target instead of the position limits of the slider joint. Note that these only take effect when the motor mode is `position`.",
- key = "SliderJoint:setMotorSpring",
- module = "lovr.physics",
- notes = "See `SldierJoint:setSpring` for more detailed info on how the spring parameters work.",
- related = {
- "SliderJoint:getSpring",
- "SliderJoint:setSpring",
- "SliderJoint:getMotorTarget",
- "SliderJoint:setMotorTarget"
- },
- variants = {
- {
- arguments = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled.",
- default = "0.0"
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setMotorTarget",
- summary = "Set the target of the slider motor.",
- description = "Sets the target value for the SliderJoint's motor. This is either a target position or a target velocity, based on the mode set by `SliderJoint:setMotorMode`.",
- key = "SliderJoint:setMotorTarget",
- module = "lovr.physics",
- related = {
- "SliderJoint:getMotorMode",
- "SliderJoint:setMotorMode"
- },
- variants = {
- {
- arguments = {
- {
- name = "target",
- type = "number",
- description = "The target value, in meters or meters per second, depending on the mode."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSpring",
- summary = "Set the spring parameters of the SliderJoint limits.",
- description = "Sets the spring parameters of the SliderJoint. Use this to make the position limits of the slider \"soft\". When the motor is active, a separate set of spring parameters can be set on the motor, see `SliderJoint:setMotorSpring`.",
- key = "SliderJoint:setSpring",
- module = "lovr.physics",
- notes = "Higher frequencies make the spring more stiff. When zero (the default), the spring is disabled and the limits will be as stiff as possible.\n\nThe damping ratio controls how quickly the oscillation slows down:\n\n- Undamped: Zero damping will cause the spring to oscillate forever. (Note that the spring may\n still lose a small amount of energy over time).\n- Underdamped: Damping less than one results in a system that is underdamped. The spring will\n oscillate around the target, but the oscillations will decay over time, eventually stabilizing\n at the target.\n- Overdamped: Damping greater than one will not have any oscillation, and the spring will take\n extra time to reach the target.\n- Critical Damping: When the damping is exactly 1.0, there is no oscillation and the spring\n takes the minimum amount of time to reach the target (based on the frequency).",
- related = {
- "SliderJoint:getMotorSpring",
- "SliderJoint:setMotorSpring"
- },
- variants = {
- {
- arguments = {
- {
- name = "frequency",
- type = "number",
- description = "The frequency of the spring, in hertz. Higher frequencies make the spring more stiff. When zero, the spring is disabled.",
- default = "0.0"
- },
- {
- name = "damping",
- type = "number",
- description = "The damping ratio of the spring.",
- default = "1.0"
- }
- },
- returns = {}
- }
- }
- }
- },
- related = {
- "Collider"
- }
- },
- {
- name = "SphereShape",
- summary = "A sphere Shape.",
- description = "A type of `Shape` that can be used for spheres.",
- key = "SphereShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newSphereShape",
- "World:newSphereCollider"
- },
- extends = "Shape",
- methods = {
- {
- name = "getRadius",
- summary = "Get the radius of the SphereShape.",
- description = "Returns the radius of the SphereShape.",
- key = "SphereShape:getRadius",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters."
- }
- }
- }
- }
- },
- {
- name = "setRadius",
- summary = "Set the radius of the SphereShape.",
- description = "Sets the radius of the SphereShape.",
- key = "SphereShape:setRadius",
- module = "lovr.physics",
- notes = "This changes the mass of the shape. If the shape is attached to a collider with automatic mass enabled, the mass properties of the collider will update as well.\n\nChanging shapes can make the physics engine explode since it can cause objects to overlap in unnatural ways.",
- variants = {
- {
- arguments = {
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters."
- }
- },
- returns = {}
- }
- }
- }
- }
- },
- {
- name = "TerrainShape",
- summary = "A terrain Shape.",
- description = "A type of `Shape` that can be used for terrains and irregular surfaces.",
- key = "TerrainShape",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newTerrainShape",
- "World:newTerrainCollider"
- },
- extends = "Shape",
- methods = {}
- },
- {
- name = "WeldJoint",
- summary = "A joint that welds two colliders together.",
- description = "A WeldJoint is a `Joint` that restricts all relative motion between two colliders, as though they were welded together into a single object. All six degrees of freedom are constrained.\n\nWeldJoints are useful for making breakable objects. Several colliders can be welded together with joints, and if `Joint:getForce` reports a large enough value, the joints can be disabled or destroyed, allowing the pieces to move freely.",
- key = "WeldJoint",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newWeldJoint"
- },
- extends = "Joint",
- methods = {}
- },
- {
- name = "World",
- summary = "An object holding all the colliders and joints in a physics simulation.",
- description = "A World is an object that holds all of the colliders and joints in a physics simulation.\n\nBe sure to call `World:update` on the World every frame to advance the simulation.",
- key = "World",
- module = "lovr.physics",
- constructors = {
- "lovr.physics.newWorld"
- },
- methods = {
- {
- name = "destroy",
- summary = "Destroy the World!! Muahaha!",
- description = "Destroys the World. This will destroy all colliders, shapes, and joints in the world. After calling this function, the world can no longer be used. Attempting to call a method on the World after destroying it will error, with the exception of `World:isDestroyed`.",
- key = "World:destroy",
- module = "lovr.physics",
- notes = "If a World gets garbage collected, it will be destroyed and, consequently, all of the colliders, shapes, and joints in the World will be destroyed as well, even if they can still be reached by Lua. This is an exception to the way objects in LÖVR normally work, and is done to avoid issues with cycles in reference counting.",
- related = {
- "Collider:destroy",
- "Shape:destroy",
- "Joint:destroy"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "disableCollisionBetween",
- summary = "Disable collision between two tags.",
- description = "Disables collision between two tags. Use `Collider:setTag` to set a Collider's tag.",
- key = "World:disableCollisionBetween",
- module = "lovr.physics",
- notes = "By default, collision is enabled between all tags.\n\nAnother way of disabling collisions is by using the `filter` callback in `World:setCallbacks`. However, using tags is much faster than using the callback, because the physics engine calls the callback later in the collision detection process. With tags, the colliders are ignored much earlier and precise collision detection is never performed.\n\nTags can be marked as \"static\" when the world is created, as an optimization hint. Static tags will never collide with other static tags, regardless of whether collision is enabled between them.",
- related = {
- "World:enableCollisionBetween",
- "World:isCollisionEnabledBetween",
- "lovr.physics.newWorld",
- "World:getTags",
- "Collider:setTag"
- },
- variants = {
- {
- arguments = {
- {
- name = "tag1",
- type = "string",
- description = "The first tag."
- },
- {
- name = "tag2",
- type = "string",
- description = "The second tag."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "enableCollisionBetween",
- summary = "Enable collision between two tags.",
- description = "Enables collision between two tags. Use `Collider:setTag` to set a Collider's tag.",
- key = "World:enableCollisionBetween",
- module = "lovr.physics",
- notes = "By default, collision is enabled between all tags.\n\nTags can be marked as \"static\" when the world is created, as an optimization hint. Static tags will never collide with other static tags, regardless of whether collision is enabled between them.",
- related = {
- "World:disableCollisionBetween",
- "World:isCollisionEnabledBetween",
- "lovr.physics.newWorld",
- "World:getTags",
- "Collider:setTag"
- },
- variants = {
- {
- arguments = {
- {
- name = "tag1",
- type = "string",
- description = "The first tag."
- },
- {
- name = "tag2",
- type = "string",
- description = "The second tag."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "getAngularDamping",
- summary = "Get the angular damping of the World.",
- description = "Returns the angular damping parameters of the World. Angular damping makes things less \"spinny\", making them slow down their angular velocity over time.",
- key = "World:getAngularDamping",
- module = "lovr.physics",
- deprecated = true,
- notes = "This sets the default damping for newly-created colliders. Damping can also be set on a per-collider basis using `Collider:setAngularDamping`.",
- related = {
- "Collider:getAngularDamping",
- "Collider:setAngularDamping"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "damping",
- type = "number",
- description = "The angular damping."
- },
- {
- name = "threshold",
- type = "number",
- description = "Velocity limit below which the damping is not applied."
- }
- }
- }
- }
- },
- {
- name = "getCallbacks",
- summary = "Get the World's collision callbacks.",
- description = "- Returns the callbacks assigned to the World.\n- The callbacks are described in more detail on `World:setCallbacks`.",
- key = "World:getCallbacks",
- module = "lovr.physics",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "callbacks",
- type = "table",
- description = "The World collision callbacks.",
- table = {
- {
- name = "filter",
- type = "function",
- description = "The function used to filter collisions."
- },
- {
- name = "enter",
- type = "function",
- description = "The function called when 2 colliders start touching."
- },
- {
- name = "exit",
- type = "function",
- description = "The function called when 2 colliders stop touching."
- },
- {
- name = "contact",
- type = "function",
- description = "The function called every frame while 2 colliders are in contact."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "getColliderCount",
- summary = "Get the number of colliders in the world.",
- description = "Returns the number of colliders in the world. This includes sleeping and disabled colliders.",
- key = "World:getColliderCount",
- module = "lovr.physics",
- notes = "The world has a maximum number of colliders, configured when creating the world. The default is 8192. Trying to create more than this will error.",
- related = {
- "World:getColliders",
- "World:getJointCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of colliders in the World."
- }
- }
- }
- }
- },
- {
- name = "getColliders",
- summary = "Get a list of colliders in the World.",
- description = "Returns a list of colliders in the world. This includes sleeping and disabled colliders.",
- key = "World:getColliders",
- module = "lovr.physics",
- related = {
- "World:getColliderCount",
- "World:getJoints"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "colliders",
- type = "table",
- description = "The list of `Collider` objects in the World."
- }
- }
- }
- }
- },
- {
- name = "getGravity",
- summary = "Get the gravity of the World.",
- description = "Returns the World's gravity. Gravity is a constant acceleration applied to all colliders. The default is `(0, -9.81, 0)` meters per second squared, causing colliders to fall downward.\n\nUse `Collider:setGravityScale` to change gravity strength for a single collider.",
- key = "World:getGravity",
- module = "lovr.physics",
- notes = "Kinematic colliders ignore gravity, since they are not moved by forces. Colliders with higher mass do not fall faster.",
- related = {
- "Collider:getGravityScale",
- "Collider:setGravityScale",
- "Collider:getLinearDamping",
- "Collider:setLinearDamping"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "gx",
- type = "number",
- description = "The x component of the gravity force, in meters per second squared."
- },
- {
- name = "gy",
- type = "number",
- description = "The y component of the gravity force, in meters per second squared."
- },
- {
- name = "gz",
- type = "number",
- description = "The z component of the gravity force, in meters per second squared."
- }
- }
- }
- }
- },
- {
- name = "getJointCount",
- summary = "Get the number of joints in the world.",
- description = "Returns the number of joints in the world. This includes disabled joints.",
- key = "World:getJointCount",
- module = "lovr.physics",
- related = {
- "World:getJoints",
- "World:getColliderCount"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of joints in the World."
- }
- }
- }
- }
- },
- {
- name = "getJoints",
- summary = "Get a list of joints in the World.",
- description = "Returns a table with all the joints in the World. This includes disabled joints.",
- key = "World:getJoints",
- module = "lovr.physics",
- related = {
- "World:getJointCount",
- "World:getColliders"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "joints",
- type = "table",
- description = "The list of `Joint` objects in the World."
- }
- }
- }
- }
- },
- {
- name = "getLinearDamping",
- summary = "Get the linear damping of the World.",
- 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.",
- key = "World:getLinearDamping",
- module = "lovr.physics",
- deprecated = true,
- 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`.",
- related = {
- "Collider:getLinearDamping",
- "Collider:setLinearDamping"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "damping",
- type = "number",
- description = "The linear damping."
- },
- {
- name = "threshold",
- type = "number",
- description = "Velocity limit below which the damping is not applied."
- }
- }
- }
- }
- },
- {
- name = "getResponseTime",
- summary = "Get the response time of the World.",
- 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.",
- key = "World:getResponseTime",
- module = "lovr.physics",
- deprecated = true,
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "responseTime",
- type = "number",
- description = "The response time setting for the World."
- }
- }
- }
- }
- },
- {
- name = "getStepCount",
- summary = "Get the step count of the World.",
- 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.",
- key = "World:getStepCount",
- module = "lovr.physics",
- deprecated = true,
- related = {
- "World:update"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "steps",
- type = "number",
- description = "The step count."
- }
- }
- }
- }
- },
- {
- name = "getTags",
- summary = "Get the World's list of collision tags.",
- description = "Returns the list of collision tags that were specified when the World was created. Tags are assigned to colliders using `Collider:setTag`, and collision can be enabled/disabled for pairs of tags with `World:enableCollisionBetween` and `World:disableCollisionBetween`.",
- key = "World:getTags",
- module = "lovr.physics",
- related = {
- "lovr.physics.newWorld",
- "Collider:getTag",
- "Collider:setTag",
- "World:enableCollisionBetween",
- "World:disableCollisionBetween",
- "World:isCollisionEnabledBetween"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "tags",
- type = "table",
- description = "A table of collision tags (strings)."
- }
- }
- }
- }
- },
- {
- name = "getTightness",
- summary = "Get the tightness of joints in the World.",
- 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.",
- key = "World:getTightness",
- module = "lovr.physics",
- deprecated = true,
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "tightness",
- type = "number",
- description = "The tightness of the World."
- }
- }
- }
- }
- },
- {
- name = "interpolate",
- summary = "Interpolate collider poses.",
- description = "Interpolates collider poses between their previous pose and their current pose. Methods like `Collider:getPosition` and `Collider:getOrientation` will return the smoothed values.\n\nAfter `World:update` is called, any interpolation is reset and `World:interpolate` will need to be called again to recompute the interpolated poses.\n\nThis can be used to decouple the physics tick rate from the rendering rate. For example, the physics simulation can be run at a fixed rate of 30Hz, and collider poses can be interpolated before rendering. This leads to a more stable simulation, and allows the physics rate to be increased or decreased as desired, independent of the current display refresh rate.",
- key = "World:interpolate",
- module = "lovr.physics",
- examples = {
- {
- description = "An example of a fixed timestep physics update.",
- code = "function lovr.load()\n world = lovr.physics.newWorld()\n time = 0\n timestep = 1 / 30 -- 30Hz\nend\n\nfunction lovr.update(dt)\n time = time + dt\n\n -- Update as many times as needed, if any\n while time >= timestep do\n world:update(timestep)\n time = time - timestep\n\n -- Potentially do per-tick gameplay logic here\n -- like check for collisions or apply impulses\n end\n\n -- Interpolate the colliders\n local alpha = time / timestep\n world:interpolate(alpha)\nend\n\nfunction lovr.draw(pass)\n -- Draw colliders as usual, using `Collider:getPose` etc.\nend"
- }
- },
- variants = {
- {
- arguments = {
- {
- name = "alpha",
- type = "number",
- description = "The interpolation parameter. An alpha of zero will use the previous collider pose, an alpha of 1.0 will use the latest collider pose, etc. Can be less than zero or greater than one."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "isCollisionEnabledBetween",
- summary = "Check if two tags can collide.",
- description = "Returns whether collisions are enabled between a pair of tags.",
- key = "World:isCollisionEnabledBetween",
- module = "lovr.physics",
- notes = "If either tag is nil, this function returns true, for convenience. For example, the following function will still work if either of the colliders don't have a tag:\n\n function willCollide(c1, c2)\n return world:isCollisionEnabledBetween(c1:getTag(), c2:getTag())\n end\n\nBy default, collision is enabled between all tags.\n\nTags can be marked as \"static\" when the world is created, as an optimization hint. Static tags will never collide with other static tags, regardless of whether collision is enabled between them.",
- related = {
- "World:disableCollisionBetween",
- "World:enableCollisionBetween",
- "lovr.physics.newWorld",
- "World:getTags",
- "Collider:setTag"
- },
- variants = {
- {
- arguments = {
- {
- name = "tag1",
- type = "string",
- description = "The first tag."
- },
- {
- name = "tag2",
- type = "string",
- description = "The second tag."
- }
- },
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether or not two colliders with the specified tags will collide."
- }
- }
- }
- }
- },
- {
- name = "isDestroyed",
- summary = "Check if the World has been destroyed.",
- description = "Returns whether the World has been destroyed. Destroyed worlds can not be used for anything.",
- key = "World:isDestroyed",
- module = "lovr.physics",
- related = {
- "World:destroy",
- "Collider:isDestroyed",
- "Shape:isDestroyed",
- "Joint:isDestroyed"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "destroyed",
- type = "boolean",
- description = "Whether the World has been destroyed."
- }
- }
- }
- }
- },
- {
- name = "isSleepingAllowed",
- summary = "Check if colliders can go to sleep.",
- description = "Returns whether colliders can go to sleep in the World.",
- key = "World:isSleepingAllowed",
- module = "lovr.physics",
- deprecated = true,
- 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`.",
- related = {
- "Collider:isSleepingAllowed",
- "Collider:setSleepingAllowed",
- "Collider:isAwake",
- "Collider:setAwake"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "allowed",
- type = "boolean",
- description = "Whether colliders can sleep."
- }
- }
- }
- }
- },
- {
- name = "newBoxCollider",
- summary = "Add a Collider with a BoxShape to the World.",
- description = "Adds a Collider to the world and attaches a `BoxShape`.",
- key = "World:newBoxCollider",
- module = "lovr.physics",
- notes = "This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in `lovr.physics.newWorld`.",
- related = {
- "BoxShape",
- "Collider",
- "World:newCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the box, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the box, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the box, in meters.",
- default = "0"
- },
- {
- name = "width",
- type = "number",
- description = "The width of the box, in meters.",
- default = "1"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box, in meters.",
- default = "width"
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box, in meters.",
- default = "width"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the box, in meters."
- },
- {
- name = "size",
- type = "Vec3",
- description = "The size of the box, in meters."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newCapsuleCollider",
- summary = "Add a Collider with a CapsuleShape to the World.",
- description = "Adds a Collider to the world and attaches a `CapsuleShape`.",
- key = "World:newCapsuleCollider",
- module = "lovr.physics",
- notes = "This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in `lovr.physics.newWorld`.\n\nThe length of the capsule goes along its local Z axis.",
- related = {
- "CapsuleShape",
- "Collider",
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the capsule, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the capsule, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the capsule, in meters.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule, in meters.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the capsule, not including the caps, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule, in meters."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the capsule, in meters.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the capsule, not including the caps, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newCollider",
- summary = "Add a Collider to the World.",
- description = "Adds a new Collider to the World, without attaching any Shapes to it. Use `Collider:addShape` to add shapes.",
- key = "World:newCollider",
- module = "lovr.physics",
- examples = {
- {
- code = "function lovr.load()\n world = lovr.physics.newWorld()\n collider = world:newCollider(0, 0, 0)\n shape = lovr.physics.newSphereShape(.5)\n collider:addShape(shape)\nend"
- }
- },
- notes = "This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in `lovr.physics.newWorld`.",
- related = {
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider",
- "Collider:addShape",
- "Collider",
- "Shape"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x position of the Collider."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the Collider."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of the Collider."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the Collider."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newConvexCollider",
- summary = "Add a Collider with a ConvexShape to the World.",
- description = "Adds a Collider to the world and attaches a `ConvexShape`. A `ConvexShape` is a convex hull of a set of points, kinda like if you wrapped them in wrapping paper.",
- key = "World:newConvexCollider",
- module = "lovr.physics",
- notes = "This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in `lovr.physics.newWorld`.",
- related = {
- "ConvexShape",
- "Collider",
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "points",
- type = "table",
- description = "A list of vertices to compute a convex hull from. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D point)."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule, in meters."
- },
- {
- name = "points",
- type = "table",
- description = "A list of vertices to compute a convex hull from. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D point)."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "modelData",
- type = "ModelData",
- description = "The ModelData to compute a convex hull from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule, in meters."
- },
- {
- name = "modelData",
- type = "ModelData",
- description = "The ModelData to compute a convex hull from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "model",
- type = "Model",
- description = "The Model to compute a convex hull from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule, in meters."
- },
- {
- name = "model",
- type = "Model",
- description = "The Model to compute a convex hull from."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "mesh",
- type = "Mesh",
- description = "The Mesh to compute a convex hull from. It must use the `cpu` storage mode."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule, in meters."
- },
- {
- name = "mesh",
- type = "Mesh",
- description = "The Mesh to compute a convex hull from. It must use the `cpu` storage mode."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- description = "Clones an existing ConvexShape, which is faster than passing the same points multiple times. Clones can have their own scale. The clone's scale doesn't get multiplied with the scale of the template.",
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the collider, in meters.",
- default = "0"
- },
- {
- name = "template",
- type = "ConvexShape",
- description = "An existing ConvexShape to clone."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- description = "Clones an existing ConvexShape, which is faster than passing the same points multiple times. Clones can have their own scale. The clone's scale doesn't get multiplied with the scale of the template.",
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the capsule, in meters."
- },
- {
- name = "template",
- type = "ConvexShape",
- description = "An existing ConvexShape to clone."
- },
- {
- name = "scale",
- type = "number",
- description = "A scale to apply to the points.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newCylinderCollider",
- summary = "Add a Collider with a CylinderShape to the World.",
- description = "Adds a Collider to the world and attaches a `CylinderShape`.",
- key = "World:newCylinderCollider",
- module = "lovr.physics",
- notes = "This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in `lovr.physics.newWorld`.\n\nThe length of the cylinder goes along its local Z axis.",
- related = {
- "CylinderShape",
- "Collider",
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the cylinder, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the cylinder, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the cylinder, in meters.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder, in meters.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cylinder, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the cylinder, in meters."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the cylinder, in meters.",
- default = "1"
- },
- {
- name = "length",
- type = "number",
- description = "The length of the cylinder, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newMeshCollider",
- summary = "Add a Collider with a MeshShape to the World.",
- description = "Adds a Collider to the world and attaches a `MeshShape`.\n\nColliders with mesh shapes are immobile and can only be used for static environment objects. The collider will be kinematic and forces/velocities will not move it. Also, these colliders will not detect collisions with other kinematic objects.\n\nMeshShapes are not treated as solid objects, but instead a collection of triangles. They do not have mass or volume, and there is no concept of being \"inside\" a mesh. `ConvexShape` is a good alternative for solid objects with an arbitrary shape.",
- key = "World:newMeshCollider",
- module = "lovr.physics",
- notes = "The triangles in a MeshShape should use counterclockwise winding.",
- related = {
- "Collider",
- "MeshShape",
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newTerrainCollider",
- "Model:getTriangles"
- },
- variants = {
- {
- arguments = {
- {
- name = "vertices",
- type = "table",
- description = "A table of vertices in the mesh. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D vertex)."
- },
- {
- name = "indices",
- type = "table",
- description = "A table of triangle indices representing how the vertices are connected together into triangles."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "modelData",
- type = "ModelData",
- description = "A ModelData to use for the mesh data."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "model",
- type = "Model",
- description = "A Model to use for the mesh data. Similar to calling `Model:getTriangles` and passing it to this function, but has better performance."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "mesh",
- type = "Mesh",
- description = "A Mesh to use for the mesh data. It must use the `cpu` storage mode."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- description = "Clones an existing MeshShape, which is faster than passing the same mesh multiple times. Clones can have their own scale. The clone's scale doesn't get multiplied with the scale of the template.",
- arguments = {
- {
- name = "template",
- type = "MeshShape",
- description = "An existing MeshShape to reuse."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newSphereCollider",
- summary = "Add a Collider with a SphereShape to the World.",
- description = "Adds a Collider to the world and attaches a `SphereShape`.",
- key = "World:newSphereCollider",
- module = "lovr.physics",
- notes = "This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in `lovr.physics.newWorld`.",
- related = {
- "SphereShape",
- "Collider",
- "World:newCollider",
- "World:newBoxCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the sphere, in meters.",
- default = "0"
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the sphere, in meters.",
- default = "0"
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the sphere, in meters.",
- default = "0"
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the sphere, in meters."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters.",
- default = "1"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "newTerrainCollider",
- summary = "Add a Collider with a TerrainShape to the World.",
- description = "Adds a Collider to the world and attaches a `TerrainShape`.\n\nColliders with terrain shapes are immobile and can only be used for static environment objects. The collider will be kinematic and forces/velocities will not move it. Also, these colliders will not detect collisions with other kinematic objects.\n\nTerrainShapes are not treated as solid objects, but instead a collection of triangles. They do not have mass or volume, and there is no concept of being \"inside\" the terrain.",
- key = "World:newTerrainCollider",
- module = "lovr.physics",
- related = {
- "Collider",
- "TerrainShape",
- "World:newCollider",
- "World:newBoxCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newSphereCollider",
- "World:newMeshCollider",
- "lovr.data.newImage"
- },
- variants = {
- {
- description = "Create a flat floor collider.",
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The width and depth of the terrain, in meters."
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- description = "Create terrain from a heightmap image.",
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The width and depth of the terrain, in meters."
- },
- {
- name = "heightmap",
- type = "Image",
- description = "A heightmap image describing the terrain elevation at different points. The red channel brightness of each pixel determines the elevation at corresponding coordinates. The image must be square and must have one of the formats supported by `Image:getPixel`."
- },
- {
- name = "stretch",
- type = "number",
- 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.",
- default = "1.0"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- },
- {
- description = "Create terrain defined with a callback function.",
- arguments = {
- {
- name = "scale",
- type = "number",
- description = "The width and depth of the terrain, in meters."
- },
- {
- name = "callback",
- type = "function",
- description = "A function that returns terrain height from x and z coordinates. The x and z inputs will range from `-scale / 2` to `scale / 2`.",
- arguments = {
- {
- name = "x",
- type = "number"
- },
- {
- name = "z",
- type = "number"
- }
- },
- returns = {
- name = "height",
- type = "number"
- }
- },
- {
- name = "samples",
- type = "number",
- 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.",
- default = "100"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The new Collider."
- }
- }
- }
- }
- },
- {
- name = "overlapShape",
- summary = "Find colliders that overlap a shape.",
- description = "Places a shape in the World, returning any shapes it intersects.\n\nA tag filter can be given to filter out shapes by their collider's tag:\n\n- Use nil to skip filtering.\n- Pass a tag name to only return shapes whose collider has that tag.\n- Pass a tag name with a ~ in front of it to exclude colliders with that tag.\n- Pass multiple tags separated by spaces to include multiple tags (works with ~ too).\n\nProvide an optional callback to call for each shape detected. If the callbacks nil, this function returns the first shape detected. In either case this function returns the shape, the hit position, and a penetration vector. The penetration vector represents the direction and distance the shape would need to move so that it is no longer colliding with the input shape.",
- key = "World:overlapShape",
- module = "lovr.physics",
- related = {
- "World:shapecast",
- "World:raycast",
- "World:queryBox",
- "World:querySphere"
- },
- variants = {
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to test."
- },
- {
- name = "x",
- type = "number",
- description = "The x position to place the shape at, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position to place the shape at, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position to place the shape at, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle the shape is rotated around its rotation axis, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "maxDistance",
- type = "number",
- description = "The maximum distance at which a shape can be detected, in meters. Zero will detect shapes touching the input shape, 1.0 will detect shapes within 1 meter of the input shape, etc.",
- default = "0"
- },
- {
- name = "filter",
- type = "string",
- description = "Tags to filter by, or nil for no filter.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "The callback to call for each intersection detected."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to test."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to place the shape at, in meters."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the shape."
- },
- {
- name = "maxDistance",
- type = "number",
- description = "The maximum distance at which a shape can be detected, in meters. Zero will detect shapes touching the input shape, 1.0 will detect shapes within 1 meter of the input shape, etc.",
- default = "0"
- },
- {
- name = "filter",
- type = "string",
- description = "Tags to filter by, or nil for no filter.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "The callback to call for each intersection detected."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to test."
- },
- {
- name = "x",
- type = "number",
- description = "The x position to place the shape at, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y position to place the shape at, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z position to place the shape at, in meters."
- },
- {
- name = "angle",
- type = "number",
- description = "The angle the shape is rotated around its rotation axis, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the axis of rotation."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the axis of rotation."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the axis of rotation."
- },
- {
- name = "maxDistance",
- type = "number",
- description = "The maximum distance at which a shape can be detected, in meters. Zero will detect shapes touching the input shape, 1.0 will detect shapes within 1 meter of the input shape, etc.",
- default = "0"
- },
- {
- name = "filter",
- type = "string",
- description = "Tags to filter by, or nil for no filter.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The collider that was hit."
- },
- {
- name = "shape",
- type = "Shape",
- description = "The shape that was hit."
- },
- {
- name = "x",
- type = "number",
- description = "The x position of a world space contact point on the surface of the shape."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of a world space contact point on the surface of the shape."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of a world space contact point on the surface of the shape."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the penetration vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the penetration vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the penetration vector."
- }
- }
- },
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to test."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to place the shape at, in meters."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the shape."
- },
- {
- name = "maxDistance",
- type = "number",
- description = "The maximum distance at which a shape can be detected, in meters. Zero will detect shapes touching the input shape, 1.0 will detect shapes within 1 meter of the input shape, etc.",
- default = "0"
- },
- {
- name = "filter",
- type = "string",
- description = "Tags to filter by, or nil for no filter.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The collider that was hit."
- },
- {
- name = "shape",
- type = "Shape",
- description = "The shape that was hit."
- },
- {
- name = "x",
- type = "number",
- description = "The x position of a world space contact point on the surface of the shape."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of a world space contact point on the surface of the shape."
- },
- {
- name = "z",
- type = "number",
- description = "The z position of a world space contact point on the surface of the shape."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the penetration vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the penetration vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the penetration vector."
- }
- }
- }
- }
- },
- {
- name = "queryBox",
- summary = "Find colliders that intersect an axis-aligned box.",
- description = "Find colliders within an axis-aligned bounding box. This is a fast but imprecise query that only checks a rough box around colliders. Use `World:overlapShape` for an exact collision test.\n\nRough queries like this are useful for doing a quick check before doing lots of more expensive collision testing.\n\nPass a callback function to call for each collider detected, or leave the callback off and this function will return the first collider found.",
- key = "World:queryBox",
- module = "lovr.physics",
- notes = "This will return sleeping colliders and sensors, but it will ignore disabled colliders.",
- related = {
- "World:querySphere",
- "World:overlapShape",
- "World:shapecast",
- "World:raycast"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the box, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the box, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the box, in meters."
- },
- {
- name = "width",
- type = "number",
- description = "The width of the box, in meters"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box, in meters"
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box, in meters."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "A function to call when a collider is detected. The function will be called with a single `Collider` argument."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the box, in meters."
- },
- {
- name = "size",
- type = "Vec3",
- description = "The size of the box, in meters."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "A function to call when a collider is detected. The function will be called with a single `Collider` argument."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the box, in meters."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the box, in meters."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the box, in meters."
- },
- {
- name = "width",
- type = "number",
- description = "The width of the box, in meters"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the box, in meters"
- },
- {
- name = "depth",
- type = "number",
- description = "The depth of the box, in meters."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "A Collider that intersected the box."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the box, in meters."
- },
- {
- name = "size",
- type = "Vec3",
- description = "The size of the box, in meters."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "A Collider that intersected the box."
- }
- }
- }
- }
- },
- {
- name = "querySphere",
- summary = "Find colliders that intersect a sphere.",
- description = "Find colliders within a sphere. This is a fast but imprecise query that only checks a rough box around colliders. Use `World:overlapShape` for an exact collision test.\n\nRough queries like this are useful for doing a quick check before doing lots of more expensive collision testing.\n\nPass a callback function to call for each collider detected, or leave the callback off and this function will return the first collider found.",
- key = "World:querySphere",
- module = "lovr.physics",
- related = {
- "World:queryBox",
- "World:overlapShape",
- "World:shapecast",
- "World:raycast"
- },
- variants = {
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the sphere."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the sphere."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters"
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "A function to call when an intersection is detected. The function will be called with a single `Collider` argument."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters"
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "A function to call when an intersection is detected. The function will be called with a single `Collider` argument."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the center of the sphere."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the center of the sphere."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the center of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters"
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "A Collider that intersected the sphere."
- }
- }
- },
- {
- arguments = {
- {
- name = "position",
- type = "Vec3",
- description = "The position of the center of the sphere."
- },
- {
- name = "radius",
- type = "number",
- description = "The radius of the sphere, in meters"
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front of the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "A Collider that intersected the sphere."
- }
- }
- }
- }
- },
- {
- name = "raycast",
- summary = "Find colliders that intersect a line.",
- description = "Traces a ray through the world and calls a function for each collider that was hit.\n\nThe callback can be left off, in which case the closest hit will be returned.",
- key = "World:raycast",
- module = "lovr.physics",
- notes = "The callback function is passed a collider, a shape, a world-space point, a world-space normal, a triangle index, and a fraction:\n\n function(collider, shape, x, y, z, nx, ny, nz, tri, fraction)\n return fraction\n end\n\nThe callback can return a fraction value used to limit the range of further hits. For example:\n\n- Returning 0.0 will abort the raycast and ignore all other hits.\n- Returning 1.0 will call the callback for all hits.\n- Returning `fraction` will return successively closer hits.\n\nRaycasts will hit sensors and sleeping colliders, but will not hit disabled colliders.",
- related = {
- "Shape:raycast",
- "World:shapecast",
- "World:overlapShape",
- "World:queryBox",
- "World:querySphere"
- },
- variants = {
- {
- arguments = {
- {
- name = "x1",
- type = "number",
- description = "The x coordinate of the origin of the ray."
- },
- {
- name = "y1",
- type = "number",
- description = "The y coordinate of the origin of the ray."
- },
- {
- name = "z1",
- type = "number",
- description = "The z coordinate of the origin of the ray."
- },
- {
- name = "x2",
- type = "number",
- description = "The x coordinate of the endpoint of the ray."
- },
- {
- name = "y2",
- type = "number",
- description = "The y coordinate of the endpoint of the ray."
- },
- {
- name = "z2",
- type = "number",
- description = "The z coordinate of the endpoint of the ray."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "The function to call when an intersection is detected (see notes).",
- arguments = {
- {
- name = "collider",
- type = "Collider"
- },
- {
- name = "shape",
- type = "Shape"
- },
- {
- name = "x",
- type = "number"
- },
- {
- name = "y",
- type = "number"
- },
- {
- name = "z",
- type = "number"
- },
- {
- name = "nx",
- type = "number"
- },
- {
- name = "ny",
- type = "number"
- },
- {
- name = "nz",
- type = "number"
- },
- {
- name = "triangle",
- type = "number"
- },
- {
- name = "fraction",
- type = "number"
- }
- },
- returns = {
- {
- name = "limit",
- type = "number",
- default = "1.0"
- }
- }
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "origin",
- type = "Vec3",
- description = "The origin of the ray."
- },
- {
- name = "endpoint",
- type = "Vec3",
- description = "The endpoint of the ray."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "The function to call when an intersection is detected (see notes).",
- arguments = {
- {
- name = "collider",
- type = "Collider"
- },
- {
- name = "shape",
- type = "Shape"
- },
- {
- name = "x",
- type = "number"
- },
- {
- name = "y",
- type = "number"
- },
- {
- name = "z",
- type = "number"
- },
- {
- name = "nx",
- type = "number"
- },
- {
- name = "ny",
- type = "number"
- },
- {
- name = "nz",
- type = "number"
- },
- {
- name = "triangle",
- type = "number"
- },
- {
- name = "fraction",
- type = "number"
- }
- },
- returns = {
- {
- name = "limit",
- type = "number",
- default = "1.0"
- }
- }
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "x1",
- type = "number",
- description = "The x coordinate of the origin of the ray."
- },
- {
- name = "y1",
- type = "number",
- description = "The y coordinate of the origin of the ray."
- },
- {
- name = "z1",
- type = "number",
- description = "The z coordinate of the origin of the ray."
- },
- {
- name = "x2",
- type = "number",
- description = "The x coordinate of the endpoint of the ray."
- },
- {
- name = "y2",
- type = "number",
- description = "The y coordinate of the endpoint of the ray."
- },
- {
- name = "z2",
- type = "number",
- description = "The z coordinate of the endpoint of the ray."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The Collider that was hit."
- },
- {
- name = "shape",
- type = "Shape",
- description = "The Shape that was hit."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the impact point, in world space."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the impact point, in world space."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the impact point, in world space."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the normal vector."
- },
- {
- name = "triangle",
- type = "number",
- description = "The index of the triangle that was hit, or nil if a MeshShape was not hit."
- }
- }
- },
- {
- arguments = {
- {
- name = "origin",
- type = "Vec3",
- description = "The origin of the ray."
- },
- {
- name = "endpoint",
- type = "Vec3",
- description = "The endpoint of the ray."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The Collider that was hit."
- },
- {
- name = "shape",
- type = "Shape",
- description = "The Shape that was hit."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the impact point, in world space."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the impact point, in world space."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the impact point, in world space."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the normal vector."
- },
- {
- name = "triangle",
- type = "number",
- description = "The index of the triangle that was hit, or nil if a MeshShape was not hit."
- }
- }
- }
- }
- },
- {
- name = "setAngularDamping",
- summary = "Set the angular damping of the World.",
- 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.",
- key = "World:setAngularDamping",
- module = "lovr.physics",
- deprecated = true,
- notes = "This sets the default damping for newly-created colliders. Damping can also be set on a per-collider basis using `Collider:setAngularDamping`.",
- related = {
- "Collider:getAngularDamping",
- "Collider:setAngularDamping"
- },
- variants = {
- {
- arguments = {
- {
- name = "damping",
- type = "number",
- description = "The angular damping."
- },
- {
- name = "threshold",
- type = "number",
- description = "Velocity limit below which the damping is not applied.",
- default = "0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setCallbacks",
- summary = "Set the World's collision callbacks.",
- description = "Assigns collision callbacks to the world. These callbacks are used to filter collisions or get notifications when colliders start or stop touching. Callbacks are called during `World:update`.\n\n### Filter\n\nFilters collisions. Receives two colliders and returns a boolean indicating if they should collide. Note that it is much faster to use tags and `World:enableCollisionBetween` to control collision. This should only be used when the logic for filtering the collision is highly dynamic.\n\n### Enter\n\nCalled when two colliders begin touching. Receives two colliders and a `Contact` object with more information about the collision. The `contact` callback will also be called for this collision.\n\n### Exit\n\nCalled when two colliders stop touching. Receives two colliders.\n\n### Contact\n\nCalled continuously while two colliders are touching. Receives two colliders and a `Contact` object with more information about the collision. The contact can also be disabled to disable the collision response, and its friction/resitution/velocity can be changed. There can be multiple active contact areas (called \"manifolds\") between a pair of colliders; this callback will be called for each one.",
- key = "World:setCallbacks",
- module = "lovr.physics",
- examples = {
- {
- code = "world:setCallbacks({\n filter = function(a, b)\n return true\n end,\n enter = function(a, b, contact)\n -- play sounds, spawn particles, etc.\n -- the collision has not been resolved yet, so the velocity of a and b\n -- is the velocity before the collision, and can be used to estimate the\n -- collision force\n end,\n exit = function(a, b)\n -- a and b have stopped touching!\n end,\n contact = function(a, b, contact)\n -- a and b are touching this frame\n -- use sparingly, as this may be called many times per frame\n -- use Contact:setFriction and Contact:setResitution to update\n -- the contact behavior, or Contact:setSurfaceVelocity, for a\n -- conveyor belt effect, or Contact:setEnabled to disable the\n -- collision completely.\n end\n})"
- }
- },
- notes = "The `Thread` that last set these callbacks must also be the thread to call `World:update`.\n\nNote that when a collider goes to sleep, its active contacts will be removed and the `exit` callback will be called.",
- related = {
- "World:update",
- "Contact"
- },
- variants = {
- {
- arguments = {
- {
- name = "callbacks",
- type = "table",
- description = "The World collision callbacks.",
- table = {
- {
- name = "filter",
- type = "function",
- description = "The function to use to filter collisions."
- },
- {
- name = "enter",
- type = "function",
- description = "The function to call when 2 colliders start touching."
- },
- {
- name = "exit",
- type = "function",
- description = "The function to call when 2 colliders stop touching."
- },
- {
- name = "contact",
- type = "function",
- description = "The function to call every frame while 2 colliders are in contact."
- }
- }
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setGravity",
- summary = "Set the gravity of the World.",
- description = "Sets the World's gravity. Gravity is a constant acceleration applied to all colliders. The default is `(0, -9.81, 0)` meters per second squared, causing colliders to fall downward.\n\nUse `Collider:setGravityScale` to change gravity strength for a single collider.",
- key = "World:setGravity",
- module = "lovr.physics",
- notes = "Kinematic colliders ignore gravity, since they are not moved by forces. Colliders with higher mass do not fall faster.",
- related = {
- "Collider:getGravityScale",
- "Collider:setGravityScale",
- "Collider:getLinearDamping",
- "Collider:setLinearDamping"
- },
- variants = {
- {
- arguments = {
- {
- name = "xg",
- type = "number",
- description = "The x component of the gravity force."
- },
- {
- name = "yg",
- type = "number",
- description = "The y component of the gravity force."
- },
- {
- name = "zg",
- type = "number",
- description = "The z component of the gravity force."
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "gravity",
- type = "Vec3",
- description = "The gravity force."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setLinearDamping",
- summary = "Set the linear damping of the World.",
- 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.",
- key = "World:setLinearDamping",
- module = "lovr.physics",
- deprecated = true,
- 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`.",
- related = {
- "Collider:getLinearDamping",
- "Collider:setLinearDamping"
- },
- variants = {
- {
- arguments = {
- {
- name = "damping",
- type = "number",
- description = "The linear damping."
- },
- {
- name = "threshold",
- type = "number",
- description = "Velocity limit below which the damping is not applied.",
- default = "0"
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setResponseTime",
- summary = "Set the response time of the World.",
- 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.",
- key = "World:setResponseTime",
- module = "lovr.physics",
- deprecated = true,
- variants = {
- {
- arguments = {
- {
- name = "responseTime",
- type = "number",
- description = "The new response time setting for the World."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setSleepingAllowed",
- summary = "Set whether colliders can go to sleep.",
- description = "Sets whether colliders can go to sleep in the World.",
- key = "World:setSleepingAllowed",
- module = "lovr.physics",
- deprecated = true,
- 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`.",
- related = {
- "Collider:isSleepingAllowed",
- "Collider:setSleepingAllowed",
- "Collider:isAwake",
- "Collider:setAwake"
- },
- variants = {
- {
- arguments = {
- {
- name = "allowed",
- type = "boolean",
- description = "Whether colliders can sleep."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setStepCount",
- summary = "Set the step count of the World.",
- 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.",
- key = "World:setStepCount",
- module = "lovr.physics",
- deprecated = true,
- related = {
- "World:update"
- },
- variants = {
- {
- arguments = {
- {
- name = "steps",
- type = "number",
- description = "The new step count."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setTightness",
- summary = "Set the tightness of joints in the World.",
- 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.",
- key = "World:setTightness",
- module = "lovr.physics",
- deprecated = true,
- variants = {
- {
- arguments = {
- {
- name = "tightness",
- type = "number",
- description = "The new tightness for the World."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "shapecast",
- summary = "Move a shape through the world and return any colliders it touches.",
- description = "Moves a shape from a starting point to an endpoint and returns any colliders it touches along its path.\n\nThis is similar to a raycast, but with a `Shape` instead of a point.",
- key = "World:shapecast",
- module = "lovr.physics",
- notes = "The callback function is passed a collider, a shape, a world-space point, a world-space normal, a triangle index (for mesh shapes), and a fraction:\n\n function(collider, shape, x, y, z, nx, ny, nz, tri, fraction)\n return fraction\n end\n\nThe callback can return a fraction value used to limit the range of further hits. For example:\n\n- Returning 0.0 will abort the shapecast and ignore all other hits.\n- Returning 1.0 will call the callback for all hits.\n- Returning `fraction` will return successively closer hits.\n\nShapecasts will hit sensors and sleeping colliders, but will not hit disabled colliders.",
- related = {
- "World:raycast",
- "World:overlapShape",
- "World:queryBox",
- "World:querySphere"
- },
- variants = {
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to cast."
- },
- {
- name = "x1",
- type = "number",
- description = "The x position to start at."
- },
- {
- name = "y1",
- type = "number",
- description = "The y position to start at."
- },
- {
- name = "z1",
- type = "number",
- description = "The z position to start at."
- },
- {
- name = "x2",
- type = "number",
- description = "The x position to move the shape to."
- },
- {
- name = "y2",
- type = "number",
- description = "The y position to move the shape to."
- },
- {
- name = "z2",
- type = "number",
- description = "The z position to move the shape to."
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the shape around its rotation axis, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the rotation axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the rotation axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the rotation axis."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "The function to call when an intersection is detected (see notes).",
- arguments = {
- {
- name = "collider",
- type = "Collider"
- },
- {
- name = "shape",
- type = "Shape"
- },
- {
- name = "x",
- type = "number"
- },
- {
- name = "y",
- type = "number"
- },
- {
- name = "z",
- type = "number"
- },
- {
- name = "nx",
- type = "number"
- },
- {
- name = "ny",
- type = "number"
- },
- {
- name = "nz",
- type = "number"
- },
- {
- name = "triangle",
- type = "number"
- },
- {
- name = "fraction",
- type = "number"
- }
- },
- returns = {
- {
- name = "limit",
- type = "number",
- default = "1.0"
- }
- }
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to cast."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to start at."
- },
- {
- name = "destination",
- type = "Vec3",
- description = "The position to move the shape to."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the shape."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- },
- {
- name = "callback",
- type = "function",
- description = "The function to call when an intersection is detected (see notes).",
- arguments = {
- {
- name = "collider",
- type = "Collider"
- },
- {
- name = "shape",
- type = "Shape"
- },
- {
- name = "x",
- type = "number"
- },
- {
- name = "y",
- type = "number"
- },
- {
- name = "z",
- type = "number"
- },
- {
- name = "nx",
- type = "number"
- },
- {
- name = "ny",
- type = "number"
- },
- {
- name = "nz",
- type = "number"
- },
- {
- name = "triangle",
- type = "number"
- },
- {
- name = "fraction",
- type = "number"
- }
- },
- returns = {
- {
- name = "limit",
- type = "number",
- default = "1.0"
- }
- }
- }
- },
- returns = {}
- },
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to cast."
- },
- {
- name = "x1",
- type = "number",
- description = "The x position to start at."
- },
- {
- name = "y1",
- type = "number",
- description = "The y position to start at."
- },
- {
- name = "z1",
- type = "number",
- description = "The z position to start at."
- },
- {
- name = "x2",
- type = "number",
- description = "The x position to move the shape to."
- },
- {
- name = "y2",
- type = "number",
- description = "The y position to move the shape to."
- },
- {
- name = "z2",
- type = "number",
- description = "The z position to move the shape to."
- },
- {
- name = "angle",
- type = "number",
- description = "The rotation of the shape around its rotation axis, in radians."
- },
- {
- name = "ax",
- type = "number",
- description = "The x component of the rotation axis."
- },
- {
- name = "ay",
- type = "number",
- description = "The y component of the rotation axis."
- },
- {
- name = "az",
- type = "number",
- description = "The z component of the rotation axis."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The Collider that was hit."
- },
- {
- name = "shape",
- type = "Shape",
- description = "The Shape that was hit."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the impact point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the impact point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the impact point."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the normal vector."
- },
- {
- name = "triangle",
- type = "number",
- description = "The triangle that was hit, or `nil` if a MeshShape was not hit."
- },
- {
- name = "fraction",
- type = "number",
- description = "The fraction along the ray where the impact occurred."
- }
- }
- },
- {
- arguments = {
- {
- name = "shape",
- type = "Shape",
- description = "The Shape to cast."
- },
- {
- name = "position",
- type = "Vec3",
- description = "The position to start at."
- },
- {
- name = "destination",
- type = "Vec3",
- description = "The position to move the shape to."
- },
- {
- name = "orientation",
- type = "Quat",
- description = "The orientation of the shape."
- },
- {
- name = "filter",
- type = "string",
- description = "An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put `~` in front the tags to exclude colliders with those tags.",
- default = "nil"
- }
- },
- returns = {
- {
- name = "collider",
- type = "Collider",
- description = "The Collider that was hit."
- },
- {
- name = "shape",
- type = "Shape",
- description = "The Shape that was hit."
- },
- {
- name = "x",
- type = "number",
- description = "The x coordinate of the impact point."
- },
- {
- name = "y",
- type = "number",
- description = "The y coordinate of the impact point."
- },
- {
- name = "z",
- type = "number",
- description = "The z coordinate of the impact point."
- },
- {
- name = "nx",
- type = "number",
- description = "The x component of the normal vector."
- },
- {
- name = "ny",
- type = "number",
- description = "The y component of the normal vector."
- },
- {
- name = "nz",
- type = "number",
- description = "The z component of the normal vector."
- },
- {
- name = "triangle",
- type = "number",
- description = "The triangle that was hit, or `nil` if a MeshShape was not hit."
- },
- {
- name = "fraction",
- type = "number",
- description = "The fraction along the ray where the impact occurred."
- }
- }
- }
- }
- },
- {
- name = "update",
- summary = "Advance the physics simulation.",
- description = "Updates the World, advancing the physics simulation forward in time and moving all the colliders.",
- key = "World:update",
- module = "lovr.physics",
- examples = {
- {
- code = "function lovr.update(dt)\n world:update(dt)\nend"
- }
- },
- notes = "By default, the World updates at a fixed timestep. This means that the physics simulation will always update with a constant rate, for example 60 \"ticks\" per second. This improves stability of the simulation and decouples physics from rendering. Collider poses are automatically interpolated between the two most recent ticks, ensuring smooth movement even if the tick rate is lower than the rendering rate.\n\nFixed timestep can be disabled by setting the `tickRate` option to 0 in `lovr.physics.newWorld`. This will use a variable timestep where the `dt` value passed to this function will be applied directly to the physics simulation.\n\nThis function must be called from the last thread that called `World:setCallbacks`. If no callbacks are set, then this can be called from any thread.",
- related = {
- "lovr.physics.newWorld"
- },
- variants = {
- {
- arguments = {
- {
- name = "dt",
- type = "number",
- description = "The amount of time to advance the simulation forward."
- }
- },
- returns = {}
- }
- }
- }
- },
- sections = {
- {
- name = "Basics",
- links = {
- "World:update",
- "World:interpolate",
- "World:getGravity",
- "World:setGravity",
- "World:getCallbacks",
- "World:setCallbacks",
- "World:destroy",
- "World:isDestroyed"
- }
- },
- {
- name = "Queries",
- description = "Queries answer some question about the World, like \"do any colliders intersect this line?\" or \"are there any colliders inside this sphere?\". There are 3 types of queries:\n\n- \"cast\" tests sweep a shape along a line and figure out which colliders are in its path.\n- \"overlap\" tests place a shape at a position and figure out which colliders it touches.\n- \"query\" tests are similar to overlap tests, but they are fast and inexact. They only\n check the bounding box of a collider, and only support testing against simple shapes.",
- links = {
- "World:raycast",
- "World:shapecast",
- "World:overlapShape",
- "World:queryBox",
- "World:querySphere"
- }
- },
- {
- name = "Collision Tags",
- description = "Collision tags are used to ignore collision between certain pairs of colliders. The list of available tags is defined when creating the world, and colliders can be given a tag using `Collider:setTag`.",
- links = {
- "World:getTags",
- "World:disableCollisionBetween",
- "World:enableCollisionBetween",
- "World:isCollisionEnabledBetween"
- }
- },
- {
- name = "Colliders",
- links = {
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider",
- "World:getColliderCount",
- "World:getColliders"
- }
- },
- {
- name = "Joints",
- links = {
- "World:getJointCount",
- "World:getJoints"
- }
- }
- }
- }
- },
- sections = {
- {
- name = "World",
- description = "A World holds all of the objects in a physics simulation. Use methods like `World:newBoxCollider` to add objects to the world. Call `World:update` each frame to advance the physics simulation and calculate new positions for all the colliders.",
- links = {
- "lovr.physics.newWorld"
- }
- },
- {
- name = "Colliders",
- description = "A Collider is a single \"object\" in the physics world. A Collider has zero or more `Shape` objects attached to it, which determine its collision shape. Colliders can be connected together with `Joint` objects.",
- links = {
- "World:newCollider",
- "World:newBoxCollider",
- "World:newSphereCollider",
- "World:newCapsuleCollider",
- "World:newCylinderCollider",
- "World:newConvexCollider",
- "World:newMeshCollider",
- "World:newTerrainCollider"
- }
- },
- {
- name = "Shapes",
- description = "Shapes define the collision shape of a collider. Normally it isn't necessary to create shapes manually, instead convenience methods like `World:newSphereCollider` will create a collider with a shape attached.",
- links = {
- "lovr.physics.newBoxShape",
- "lovr.physics.newSphereShape",
- "lovr.physics.newCapsuleShape",
- "lovr.physics.newCylinderShape",
- "lovr.physics.newConvexShape",
- "lovr.physics.newMeshShape",
- "lovr.physics.newTerrainShape"
- }
- },
- {
- name = "Joints",
- description = "Joints connect colliders together and constrain their movement in various ways.",
- links = {
- "lovr.physics.newWeldJoint",
- "lovr.physics.newBallJoint",
- "lovr.physics.newConeJoint",
- "lovr.physics.newDistanceJoint",
- "lovr.physics.newHingeJoint",
- "lovr.physics.newSliderJoint"
- }
- }
- }
- },
- {
- name = "system",
- tag = "modules",
- summary = "Provides information about the current operating system and platform.",
- description = "The `lovr.system` provides information about the current platform and hardware.\n\nIt also interfaces with the desktop window and window input.",
- key = "lovr.system",
- enums = {
- {
- name = "Permission",
- summary = "Application permissions.",
- description = "These are the different permissions that need to be requested using `lovr.system.requestPermission` on some platforms.",
- key = "Permission",
- module = "lovr.system",
- related = {
- "lovr.system.requestPermission"
- },
- values = {
- {
- name = "audiocapture",
- description = "Requests microphone access."
- }
- }
- }
- },
- functions = {
- {
- name = "getClipboardText",
- tag = "system-clipboard",
- summary = "Get the clipboard text.",
- description = "Returns the clipboard text.",
- key = "lovr.system.getClipboardText",
- module = "lovr.system",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "text",
- type = "string",
- description = "The clipboard text (may be nil)."
- }
- }
- }
- }
- },
- {
- name = "getCoreCount",
- tag = "system-info",
- summary = "Get the number of logical cores.",
- description = "Returns the number of logical cores on the system.",
- key = "lovr.system.getCoreCount",
- module = "lovr.system",
- related = {
- "lovr.thread"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "cores",
- type = "number",
- description = "The number of logical cores on the system."
- }
- }
- }
- }
- },
- {
- name = "getMousePosition",
- tag = "system-mouse",
- summary = "Get the position of the mouse.",
- description = "Returns the position of the mouse.",
- key = "lovr.system.getMousePosition",
- module = "lovr.system",
- related = {
- "lovr.system.getMouseX",
- "lovr.system.getMouseY",
- "lovr.mousemoved"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the mouse, relative to the top-left of the window."
- },
- {
- name = "y",
- type = "number",
- description = "The y position of the mouse, relative to the top-left of the window."
- }
- }
- }
- }
- },
- {
- name = "getMouseX",
- tag = "system-mouse",
- summary = "Get the x position of the mouse.",
- description = "Returns the x position of the mouse.",
- key = "lovr.system.getMouseX",
- module = "lovr.system",
- related = {
- "lovr.system.getMouseY",
- "lovr.system.getMousePosition",
- "lovr.mousemoved"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "x",
- type = "number",
- description = "The x position of the mouse, relative to the top-left of the window."
- }
- }
- }
- }
- },
- {
- name = "getMouseY",
- tag = "system-mouse",
- summary = "Get the y position of the mouse.",
- description = "Returns the y position of the mouse.",
- key = "lovr.system.getMouseY",
- module = "lovr.system",
- related = {
- "lovr.system.getMouseX",
- "lovr.system.getMousePosition",
- "lovr.mousemoved"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "y",
- type = "number",
- description = "The y position of the mouse, relative to the top-left of the window."
- }
- }
- }
- }
- },
- {
- name = "getOS",
- tag = "system-info",
- summary = "Get the current operating system.",
- description = "Returns the current operating system.",
- key = "lovr.system.getOS",
- module = "lovr.system",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "os",
- type = "string",
- description = "Either \"Windows\", \"macOS\", \"Linux\", \"Android\" or \"Web\"."
- }
- }
- }
- }
- },
- {
- name = "getWindowDensity",
- tag = "system-window",
- summary = "Get the window pixel density.",
- 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.",
- key = "lovr.system.getWindowDensity",
- module = "lovr.system",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "density",
- type = "number",
- description = "The pixel density of the window."
- }
- }
- }
- }
- },
- {
- name = "getWindowDimensions",
- tag = "system-window",
- summary = "Get the dimensions of the window.",
- description = "Returns the dimensions of the desktop window.",
- key = "lovr.system.getWindowDimensions",
- module = "lovr.system",
- notes = "If the window is not open, this will return zeros.",
- related = {
- "lovr.system.getWindowWidth",
- "lovr.system.getWindowHeight",
- "lovr.system.isWindowOpen"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the desktop window."
- },
- {
- name = "height",
- type = "number",
- description = "The height of the desktop window."
- }
- }
- }
- }
- },
- {
- name = "getWindowHeight",
- tag = "system-window",
- summary = "Get the height of the window.",
- description = "Returns the height of the desktop window.",
- key = "lovr.system.getWindowHeight",
- module = "lovr.system",
- notes = "If the window is not open, this will return zero.",
- related = {
- "lovr.system.getWindowWidth",
- "lovr.system.getWindowDimensions",
- "lovr.system.isWindowOpen"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The height of the desktop window."
- }
- }
- }
- }
- },
- {
- name = "getWindowWidth",
- tag = "system-window",
- summary = "Get the width of the window.",
- description = "Returns the width of the desktop window.",
- key = "lovr.system.getWindowWidth",
- module = "lovr.system",
- notes = "If the window is not open, this will return zero.",
- related = {
- "lovr.system.getWindowHeight",
- "lovr.system.getWindowDimensions",
- "lovr.system.isWindowOpen"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "width",
- type = "number",
- description = "The width of the desktop window."
- }
- }
- }
- }
- },
- {
- name = "hasKeyRepeat",
- tag = "system-keyboard",
- summary = "Check if key repeat is enabled.",
- description = "Returns whether key repeat is enabled.",
- key = "lovr.system.hasKeyRepeat",
- module = "lovr.system",
- notes = "Key repeat is disabled by default.",
- related = {
- "lovr.keypressed"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "enabled",
- type = "boolean",
- description = "Whether key repeat is enabled."
- }
- }
- }
- }
- },
- {
- name = "isKeyDown",
- tag = "system-keyboard",
- summary = "Get the state of a key.",
- description = "Returns whether a key on the keyboard is pressed.",
- key = "lovr.system.isKeyDown",
- module = "lovr.system",
- related = {
- "lovr.system.wasKeyPressed",
- "lovr.system.wasKeyReleased",
- "lovr.keypressed",
- "lovr.keyreleased"
- },
- variants = {
- {
- arguments = {
- {
- name = "...",
- type = "KeyCode",
- description = "The set of keys to check."
- }
- },
- returns = {
- {
- name = "down",
- type = "boolean",
- description = "Whether any of the keys are currently pressed."
- }
- }
- }
- }
- },
- {
- name = "isMouseDown",
- tag = "system-mouse",
- summary = "Check if a mouse button is pressed.",
- description = "Returns whether a mouse button is currently pressed.",
- key = "lovr.system.isMouseDown",
- module = "lovr.system",
- related = {
- "lovr.mousepressed",
- "lovr.mousereleased",
- "lovr.system.getMouseX",
- "lovr.system.getMouseY",
- "lovr.system.getMousePosition"
- },
- variants = {
- {
- arguments = {
- {
- name = "button",
- type = "number",
- 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."
- }
- },
- returns = {
- {
- name = "down",
- type = "boolean",
- description = "Whether the mouse button is currently down."
- }
- }
- }
- }
- },
- {
- name = "isWindowFocused",
- tag = "system-window",
- summary = "Check if the desktop window is focused.",
- description = "Returns whether the desktop window is focused.",
- key = "lovr.system.isWindowFocused",
- module = "lovr.system",
- related = {
- "lovr.focus",
- "lovr.headset.isFocused",
- "lovr.system.openWindow",
- "lovr.system.isWindowOpen",
- "lovr.system.isWindowVisible"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "focused",
- type = "boolean",
- description = "Whether the desktop window is focused."
- }
- }
- }
- }
- },
- {
- name = "isWindowOpen",
- tag = "system-window",
- summary = "Check if the desktop window is open.",
- 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`.",
- key = "lovr.system.isWindowOpen",
- module = "lovr.system",
- related = {
- "lovr.system.openWindow",
- "lovr.system.isWindowVisible",
- "lovr.system.isWindowFocused"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "open",
- type = "boolean",
- description = "Whether the desktop window is open."
- }
- }
- }
- }
- },
- {
- name = "isWindowVisible",
- tag = "system-window",
- summary = "Check if the desktop window is visible.",
- description = "Returns whether the desktop window is visible (open and not minimized).",
- key = "lovr.system.isWindowVisible",
- module = "lovr.system",
- related = {
- "lovr.visible",
- "lovr.headset.isVisible",
- "lovr.system.openWindow",
- "lovr.system.isWindowOpen",
- "lovr.system.isWindowFocused"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "visible",
- type = "boolean",
- description = "Whether the desktop window is visible."
- }
- }
- }
- }
- },
- {
- name = "openWindow",
- tag = "system-window",
- summary = "Open the desktop window.",
- description = "Opens the desktop window. If the window is already open, this function does nothing.",
- key = "lovr.system.openWindow",
- module = "lovr.system",
- notes = "By default, the window is opened automatically, but this can be disabled by setting `t.window` to `nil` in `conf.lua`.",
- related = {
- "lovr.system.isWindowOpen",
- "lovr.conf"
- },
- variants = {
- {
- arguments = {
- {
- name = "options",
- type = "table",
- description = "Window options.",
- table = {
- {
- name = "width",
- type = "number",
- description = "The width of the window, or 0 to use the width of the monitor.",
- default = "720"
- },
- {
- name = "height",
- type = "number",
- description = "The height of the window, or 0 to use the height of the monitor.",
- default = "800"
- },
- {
- name = "fullscreen",
- type = "boolean",
- description = "Whether the window should be fullscreen."
- },
- {
- name = "resizable",
- type = "boolean",
- description = "Whether the window should be resizable."
- },
- {
- name = "title",
- type = "string",
- description = "The window title."
- },
- {
- name = "icon",
- type = "string",
- description = "An `Image` or path to an image file to use for the window icon."
- }
- }
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "pollEvents",
- tag = "system-window",
- summary = "Poll the OS for new window events.",
- 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`, and the events are later processed by `lovr.event.poll`.",
- key = "lovr.system.pollEvents",
- module = "lovr.system",
- related = {
- "lovr.event.poll"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "requestPermission",
- tag = "system-info",
- summary = "Request permission to use a feature.",
- 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.",
- key = "lovr.system.requestPermission",
- module = "lovr.system",
- related = {
- "lovr.permission"
- },
- variants = {
- {
- arguments = {
- {
- name = "permission",
- type = "Permission",
- description = "The permission to request."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setClipboardText",
- tag = "system-clipboard",
- summary = "Set the clipboard text.",
- description = "Sets the clipboard text.",
- key = "lovr.system.setClipboardText",
- module = "lovr.system",
- variants = {
- {
- arguments = {
- {
- name = "text",
- type = "string",
- description = "The string to set as the clipboard text."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "setKeyRepeat",
- tag = "system-keyboard",
- summary = "Enable or disable key repeat.",
- 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.",
- key = "lovr.system.setKeyRepeat",
- module = "lovr.system",
- notes = "Key repeat is disabled by default. `lovr.textinput` is not affected by key repeat.",
- related = {
- "lovr.keypressed"
- },
- variants = {
- {
- arguments = {
- {
- name = "enable",
- type = "boolean",
- description = "Whether key repeat should be enabled."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "wasKeyPressed",
- tag = "system-keyboard",
- summary = "Check if a key was pressed this frame.",
- description = "Returns whether a key on the keyboard was pressed this frame.",
- key = "lovr.system.wasKeyPressed",
- module = "lovr.system",
- 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!",
- related = {
- "lovr.system.isKeyDown",
- "lovr.system.wasKeyReleased",
- "lovr.keypressed",
- "lovr.keyreleased"
- },
- variants = {
- {
- arguments = {
- {
- name = "...",
- type = "KeyCode",
- description = "The set of keys to check."
- }
- },
- returns = {
- {
- name = "pressed",
- type = "boolean",
- description = "Whether any of the specified keys were pressed this frame."
- }
- }
- }
- }
- },
- {
- name = "wasKeyReleased",
- tag = "system-keyboard",
- summary = "Check if a key was released this frame.",
- description = "Returns whether a key on the keyboard was released this frame.",
- key = "lovr.system.wasKeyReleased",
- module = "lovr.system",
- 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!",
- related = {
- "lovr.system.isKeyDown",
- "lovr.system.wasKeyPressed",
- "lovr.keypressed",
- "lovr.keyreleased"
- },
- variants = {
- {
- arguments = {
- {
- name = "...",
- type = "KeyCode",
- description = "The set of keys to check."
- }
- },
- returns = {
- {
- name = "released",
- type = "boolean",
- description = "Whether any of the specified keys were released this frame."
- }
- }
- }
- }
- },
- {
- name = "wasMousePressed",
- tag = "system-mouse",
- summary = "Check if a mouse button was pressed this frame.",
- description = "Returns whether a button on the mouse was pressed this frame.",
- key = "lovr.system.wasMousePressed",
- module = "lovr.system",
- notes = "Technically this returns whether the button 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!",
- related = {
- "lovr.system.isMouseDown",
- "lovr.system.wasMouseReleased",
- "lovr.mousepressed",
- "lovr.mousereleased"
- },
- variants = {
- {
- arguments = {
- {
- name = "button",
- type = "number",
- 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."
- }
- },
- returns = {
- {
- name = "pressed",
- type = "boolean",
- description = "Whether the mouse button was pressed this frame."
- }
- }
- }
- }
- },
- {
- name = "wasMouseReleased",
- tag = "system-mouse",
- summary = "Check if a mouse button was released this frame.",
- description = "Returns whether a button on the mouse was released this frame.",
- key = "lovr.system.wasMouseReleased",
- module = "lovr.system",
- notes = "Technically this returns whether the button 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!",
- related = {
- "lovr.system.isMouseDown",
- "lovr.system.wasMousePressed",
- "lovr.mousepressed",
- "lovr.mousereleased"
- },
- variants = {
- {
- arguments = {
- {
- name = "button",
- type = "number",
- 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."
- }
- },
- returns = {
- {
- name = "released",
- type = "boolean",
- description = "Whether the mouse button was released this frame."
- }
- }
- }
- }
- }
- },
- objects = {},
- sections = {
- {
- name = "System Information",
- tag = "system-info"
- },
- {
- name = "Keyboard",
- tag = "system-keyboard"
- },
- {
- name = "Mouse",
- tag = "system-mouse"
- },
- {
- name = "Clipboard",
- tag = "system-clipboard"
- },
- {
- name = "Window",
- tag = "system-window"
- }
- }
- },
- {
- name = "thread",
- tag = "modules",
- summary = "Allows the creation of background threads.",
- 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.",
- key = "lovr.thread",
- enums = {},
- functions = {
- {
- name = "getChannel",
- summary = "Get a Channel for communicating between threads.",
- description = "Returns a named Channel for communicating between threads.",
- key = "lovr.thread.getChannel",
- module = "lovr.thread",
- related = {
- "Channel",
- "lovr.thread.newChannel"
- },
- variants = {
- {
- arguments = {
- {
- name = "name",
- type = "string",
- description = "The name of the Channel to get."
- }
- },
- returns = {
- {
- name = "channel",
- type = "Channel",
- description = "The Channel with the specified name."
- }
- }
- }
- }
- },
- {
- name = "newChannel",
- summary = "Create a new, unnamed Channel.",
- description = "Creates a new unnamed `Channel` object. Usually it's more convenient to use `lovr.thread.getChannel`, since other threads can use that function to query the channel by name. Unnamed channels don't require a unique name, but they need to be sent to other threads somehow (e.g. on a different Channel or as an argument to `Thread:start`).",
- key = "lovr.thread.newChannel",
- module = "lovr.thread",
- related = {
- "lovr.thread.getChannel"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "channel",
- type = "Channel",
- description = "The new Channel."
- }
- }
- }
- }
- },
- {
- name = "newThread",
- summary = "Create a new Thread.",
- description = "Creates a new Thread from Lua code.",
- key = "lovr.thread.newThread",
- module = "lovr.thread",
- 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.",
- related = {
- "Thread:start",
- "lovr.threaderror"
- },
- variants = {
- {
- arguments = {
- {
- name = "code",
- type = "string",
- description = "The code to run in the Thread."
- }
- },
- returns = {
- {
- name = "thread",
- type = "Thread",
- description = "The new Thread."
- }
- }
- },
- {
- arguments = {
- {
- name = "filename",
- type = "string",
- description = "A file containing code to run in the Thread."
- }
- },
- returns = {
- {
- name = "thread",
- type = "Thread",
- description = "The new Thread."
- }
- }
- },
- {
- arguments = {
- {
- name = "blob",
- type = "Blob",
- description = "The code to run in the Thread."
- }
- },
- returns = {
- {
- name = "thread",
- type = "Thread",
- description = "The new Thread."
- }
- }
- }
- }
- }
- },
- objects = {
- {
- name = "Channel",
- summary = "A message channel for communicating between threads.",
- description = "A Channel is an object used to communicate between `Thread` objects. 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, lightuserdata, table, vector, and any LÖVR object.",
- key = "Channel",
- module = "lovr.thread",
- constructors = {
- "lovr.thread.newChannel",
- "lovr.thread.getChannel"
- },
- methods = {
- {
- name = "clear",
- summary = "Clear all messages from the Channel.",
- description = "Removes all pending messages from the Channel.",
- key = "Channel:clear",
- module = "lovr.thread",
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- },
- {
- name = "getCount",
- summary = "Get the number of messages in the Channel.",
- description = "Returns the number of messages in the Channel.",
- key = "Channel:getCount",
- module = "lovr.thread",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "count",
- type = "number",
- description = "The number of messages in the Channel."
- }
- }
- }
- }
- },
- {
- name = "hasRead",
- summary = "Get whether a message has been read.",
- description = "Returns whether or not the message with the given ID has been read. Every call to `Channel:push` returns a message ID.",
- key = "Channel:hasRead",
- module = "lovr.thread",
- related = {
- "Channel:push"
- },
- variants = {
- {
- arguments = {
- {
- name = "id",
- type = "number",
- description = "The ID of the message to check."
- }
- },
- returns = {
- {
- name = "read",
- type = "boolean",
- description = "Whether the message has been read."
- }
- }
- }
- }
- },
- {
- name = "peek",
- summary = "Look at a message from the Channel without popping it.",
- 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.",
- key = "Channel:peek",
- module = "lovr.thread",
- notes = "The second return value can be used to detect if a `nil` message is in the queue.",
- related = {
- "Channel:pop"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "message",
- type = "*",
- description = "The message, or `nil` if there is no message."
- },
- {
- name = "present",
- type = "boolean",
- description = "Whether a message was returned (use to detect nil)."
- }
- }
- }
- }
- },
- {
- name = "pop",
- summary = "Pop a message from the Channel.",
- 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.",
- key = "Channel:pop",
- module = "lovr.thread",
- notes = "Threads can get stuck forever waiting on Channel messages, so be careful.",
- related = {
- "Channel:peek",
- "Channel:push"
- },
- variants = {
- {
- arguments = {
- {
- name = "wait",
- type = "number",
- 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.",
- default = "false"
- }
- },
- returns = {
- {
- name = "message",
- type = "*",
- description = "The received message, or `nil` if nothing was received."
- }
- }
- }
- }
- },
- {
- name = "push",
- summary = "Push a message onto the Channel.",
- description = "Pushes a message onto the Channel. The following types of data can be pushed: nil, boolean, number, string, table, lightuserdata, vectors, and userdata (LÖVR objects).",
- key = "Channel:push",
- module = "lovr.thread",
- notes = "Threads can get stuck forever waiting on Channel messages, so be careful.",
- related = {
- "Channel:pop",
- "Channel:hasRead"
- },
- variants = {
- {
- arguments = {
- {
- name = "message",
- type = "*",
- description = "The message to push."
- },
- {
- name = "wait",
- type = "number",
- 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.",
- default = "false"
- }
- },
- returns = {
- {
- name = "id",
- type = "number",
- description = "The ID of the pushed message."
- },
- {
- name = "read",
- type = "boolean",
- description = "Whether the message was read by another thread before the wait timeout."
- }
- }
- }
- }
- }
- }
- },
- {
- name = "Thread",
- summary = "A separate thread of execution that can run code in parallel with other threads.",
- 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.",
- key = "Thread",
- module = "lovr.thread",
- constructors = {
- "lovr.thread.newThread"
- },
- methods = {
- {
- name = "getError",
- summary = "Get the Thread's error message.",
- description = "Returns the message for the error that occurred on the Thread, or nil if no error has occurred.",
- key = "Thread:getError",
- module = "lovr.thread",
- related = {
- "lovr.threaderror"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "error",
- type = "string",
- description = "The error message, or `nil` if no error has occurred on the Thread."
- }
- }
- }
- }
- },
- {
- name = "isRunning",
- summary = "Check if the Thread is running.",
- description = "Returns whether or not the Thread is currently running.",
- key = "Thread:isRunning",
- module = "lovr.thread",
- related = {
- "Thread:start"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "running",
- type = "boolean",
- description = "Whether or not the Thread is running."
- }
- }
- }
- }
- },
- {
- name = "start",
- summary = "Start the Thread.",
- description = "Starts the Thread.",
- key = "Thread:start",
- module = "lovr.thread",
- examples = {
- {
- code = "function lovr.load()\n lovr.thread.newThread([[\n print(...)\n ]]):start(lovr.getVersion())\nend"
- }
- },
- notes = "The arguments can be nil, booleans, numbers, strings, or LÖVR objects.",
- variants = {
- {
- arguments = {
- {
- name = "...arguments",
- type = "*",
- description = "Up to 4 arguments to pass to the Thread's function."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "wait",
- summary = "Wait for the Thread to complete.",
- description = "Waits for the Thread to complete, then returns.",
- key = "Thread:wait",
- module = "lovr.thread",
- related = {
- "Thread:isRunning"
- },
- variants = {
- {
- arguments = {},
- returns = {}
- }
- }
- }
- },
- related = {
- "lovr.threaderror",
- "lovr.system.getCoreCount",
- "Channel"
- }
- }
- },
- related = {
- "lovr.system.getCoreCount"
- }
- },
- {
- name = "timer",
- tag = "modules",
- summary = "Exposes a high resolution timer.",
- description = "The `lovr.timer` module provides a few functions that deal with time. All times are measured in seconds.",
- key = "lovr.timer",
- enums = {},
- functions = {
- {
- name = "getAverageDelta",
- summary = "Get the average delta over the last second.",
- description = "Returns the average delta over the last second.",
- key = "lovr.timer.getAverageDelta",
- module = "lovr.timer",
- related = {
- "lovr.timer.getDelta",
- "lovr.update"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "delta",
- type = "number",
- description = "The average delta, in seconds."
- }
- }
- }
- }
- },
- {
- name = "getDelta",
- summary = "Get the time elapsed since the last update.",
- description = "Returns the time between the last two frames. This is the same value as the `dt` argument provided to `lovr.update` when VR is disabled. When VR is enabled, the `dt` will instead be `lovr.headset.getDeltaTime`.",
- key = "lovr.timer.getDelta",
- module = "lovr.timer",
- 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.",
- related = {
- "lovr.headset.getDeltaTime",
- "lovr.timer.getTime",
- "lovr.update"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "dt",
- type = "number",
- description = "The delta time, in seconds."
- }
- }
- }
- }
- },
- {
- name = "getFPS",
- summary = "Get the current frames per second.",
- description = "Returns the current frames per second, averaged over the last 90 frames.",
- key = "lovr.timer.getFPS",
- module = "lovr.timer",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "fps",
- type = "number",
- description = "The current FPS."
- }
- }
- }
- }
- },
- {
- name = "getTime",
- summary = "Get the current time.",
- description = "Returns the time since some time in the past. This can be used to measure the difference between two points in time.",
- key = "lovr.timer.getTime",
- module = "lovr.timer",
- related = {
- "lovr.headset.getTime"
- },
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "time",
- type = "number",
- description = "The current time, in seconds."
- }
- }
- }
- }
- },
- {
- name = "sleep",
- summary = "Go to sleep.",
- 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.",
- key = "lovr.timer.sleep",
- module = "lovr.timer",
- variants = {
- {
- arguments = {
- {
- name = "duration",
- type = "number",
- description = "The number of seconds to sleep for."
- }
- },
- returns = {}
- }
- }
- },
- {
- name = "step",
- summary = "Steps the internal clock.",
- 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`.",
- key = "lovr.timer.step",
- module = "lovr.timer",
- variants = {
- {
- arguments = {},
- returns = {
- {
- name = "delta",
- type = "number",
- description = "The amount of time since the last call to this function, in seconds."
- }
- }
- }
- }
- }
- },
- objects = {}
- },
- {
- name = "utf8",
- tag = "libraries",
- summary = "UTF-8 string processing.",
- 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.",
- key = "utf8",
- enums = {},
- examples = {
- {
- 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"
- }
- },
- external = true,
- functions = {},
- objects = {}
- }
- }
- }
|