babylon.2.4.d.ts 624 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717
  1. declare module BABYLON {
  2. class InstancingAttributeInfo {
  3. /**
  4. * Index/offset of the attribute in the vertex shader
  5. */
  6. index: number;
  7. /**
  8. * size of the attribute, 1, 2, 3 or 4
  9. */
  10. attributeSize: number;
  11. /**
  12. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  13. * default is FLOAT
  14. */
  15. attribyteType: number;
  16. /**
  17. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  18. */
  19. normalized: boolean;
  20. /**
  21. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  22. */
  23. offset: number;
  24. /**
  25. * Name of the GLSL attribute, for debugging purpose only
  26. */
  27. attributeName: string;
  28. }
  29. class EngineCapabilities {
  30. maxTexturesImageUnits: number;
  31. maxTextureSize: number;
  32. maxCubemapTextureSize: number;
  33. maxRenderTextureSize: number;
  34. standardDerivatives: boolean;
  35. s3tc: WEBGL_compressed_texture_s3tc;
  36. textureFloat: boolean;
  37. textureAnisotropicFilterExtension: EXT_texture_filter_anisotropic;
  38. maxAnisotropy: number;
  39. instancedArrays: ANGLE_instanced_arrays;
  40. uintIndices: boolean;
  41. highPrecisionShaderSupported: boolean;
  42. fragmentDepthSupported: boolean;
  43. textureFloatLinearFiltering: boolean;
  44. textureLOD: boolean;
  45. drawBuffersExtension: any;
  46. }
  47. /**
  48. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  49. */
  50. class Engine {
  51. private static _ALPHA_DISABLE;
  52. private static _ALPHA_ADD;
  53. private static _ALPHA_COMBINE;
  54. private static _ALPHA_SUBTRACT;
  55. private static _ALPHA_MULTIPLY;
  56. private static _ALPHA_MAXIMIZED;
  57. private static _ALPHA_ONEONE;
  58. private static _DELAYLOADSTATE_NONE;
  59. private static _DELAYLOADSTATE_LOADED;
  60. private static _DELAYLOADSTATE_LOADING;
  61. private static _DELAYLOADSTATE_NOTLOADED;
  62. private static _TEXTUREFORMAT_ALPHA;
  63. private static _TEXTUREFORMAT_LUMINANCE;
  64. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  65. private static _TEXTUREFORMAT_RGB;
  66. private static _TEXTUREFORMAT_RGBA;
  67. private static _TEXTURETYPE_UNSIGNED_INT;
  68. private static _TEXTURETYPE_FLOAT;
  69. static ALPHA_DISABLE: number;
  70. static ALPHA_ONEONE: number;
  71. static ALPHA_ADD: number;
  72. static ALPHA_COMBINE: number;
  73. static ALPHA_SUBTRACT: number;
  74. static ALPHA_MULTIPLY: number;
  75. static ALPHA_MAXIMIZED: number;
  76. static DELAYLOADSTATE_NONE: number;
  77. static DELAYLOADSTATE_LOADED: number;
  78. static DELAYLOADSTATE_LOADING: number;
  79. static DELAYLOADSTATE_NOTLOADED: number;
  80. static TEXTUREFORMAT_ALPHA: number;
  81. static TEXTUREFORMAT_LUMINANCE: number;
  82. static TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83. static TEXTUREFORMAT_RGB: number;
  84. static TEXTUREFORMAT_RGBA: number;
  85. static TEXTURETYPE_UNSIGNED_INT: number;
  86. static TEXTURETYPE_FLOAT: number;
  87. static Version: string;
  88. static CollisionsEpsilon: number;
  89. static CodeRepository: string;
  90. static ShadersRepository: string;
  91. isFullscreen: boolean;
  92. isPointerLock: boolean;
  93. cullBackFaces: boolean;
  94. renderEvenInBackground: boolean;
  95. enableOfflineSupport: boolean;
  96. scenes: Scene[];
  97. _gl: WebGLRenderingContext;
  98. private _renderingCanvas;
  99. private _windowIsBackground;
  100. private _webGLVersion;
  101. static audioEngine: AudioEngine;
  102. private _onBlur;
  103. private _onFocus;
  104. private _onFullscreenChange;
  105. private _onPointerLockChange;
  106. private _hardwareScalingLevel;
  107. private _caps;
  108. private _pointerLockRequested;
  109. private _alphaTest;
  110. private _loadingScreen;
  111. private _drawCalls;
  112. private _glVersion;
  113. private _glRenderer;
  114. private _glVendor;
  115. private _videoTextureSupported;
  116. private _renderingQueueLaunched;
  117. private _activeRenderLoops;
  118. private fpsRange;
  119. private previousFramesDuration;
  120. private fps;
  121. private deltaTime;
  122. private _depthCullingState;
  123. private _alphaState;
  124. private _alphaMode;
  125. private _loadedTexturesCache;
  126. private _maxTextureChannels;
  127. private _activeTexturesCache;
  128. private _currentEffect;
  129. private _compiledEffects;
  130. private _vertexAttribArraysEnabled;
  131. private _vertexAttribArraysToUse;
  132. private _cachedViewport;
  133. private _cachedVertexBuffers;
  134. private _cachedIndexBuffer;
  135. private _cachedEffectForVertexBuffers;
  136. private _currentRenderTarget;
  137. private _uintIndicesCurrentlySet;
  138. private _currentBoundBuffer;
  139. private _currentInstanceLocations;
  140. private _currentInstanceBuffers;
  141. private _workingCanvas;
  142. private _workingContext;
  143. private _externalData;
  144. private _bindedRenderFunction;
  145. /**
  146. * @constructor
  147. * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
  148. * @param {boolean} [antialias] - enable antialias
  149. * @param options - further options to be sent to the getContext function
  150. */
  151. constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: {
  152. antialias?: boolean;
  153. preserveDrawingBuffer?: boolean;
  154. limitDeviceRatio?: number;
  155. }, adaptToDeviceRatio?: boolean);
  156. webGLVersion: string;
  157. private _prepareWorkingCanvas();
  158. resetTextureCache(): void;
  159. getGlInfo(): {
  160. vendor: string;
  161. renderer: string;
  162. version: string;
  163. };
  164. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  165. getRenderWidth(useScreen?: boolean): number;
  166. getRenderHeight(useScreen?: boolean): number;
  167. getRenderingCanvas(): HTMLCanvasElement;
  168. getRenderingCanvasClientRect(): ClientRect;
  169. setHardwareScalingLevel(level: number): void;
  170. getHardwareScalingLevel(): number;
  171. getLoadedTexturesCache(): WebGLTexture[];
  172. getCaps(): EngineCapabilities;
  173. drawCalls: number;
  174. resetDrawCalls(): void;
  175. getDepthFunction(): number;
  176. setDepthFunction(depthFunc: number): void;
  177. setDepthFunctionToGreater(): void;
  178. setDepthFunctionToGreaterOrEqual(): void;
  179. setDepthFunctionToLess(): void;
  180. setDepthFunctionToLessOrEqual(): void;
  181. /**
  182. * stop executing a render loop function and remove it from the execution array
  183. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  184. */
  185. stopRenderLoop(renderFunction?: () => void): void;
  186. _renderLoop(): void;
  187. /**
  188. * Register and execute a render loop. The engine can have more than one render function.
  189. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  190. * @example
  191. * engine.runRenderLoop(function () {
  192. * scene.render()
  193. * })
  194. */
  195. runRenderLoop(renderFunction: () => void): void;
  196. /**
  197. * Toggle full screen mode.
  198. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  199. * @param {any} options - an options object to be sent to the requestFullscreen function
  200. */
  201. switchFullscreen(requestPointerLock: boolean, options?: any): void;
  202. clear(color: any, backBuffer: boolean, depthStencil: boolean): void;
  203. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  204. /**
  205. * Set the WebGL's viewport
  206. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  207. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  208. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  209. */
  210. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  211. /**
  212. * Directly set the WebGL Viewport
  213. * The x, y, width & height are directly passed to the WebGL call
  214. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state.
  215. */
  216. setDirectViewport(x: number, y: number, width: number, height: number): Viewport;
  217. beginFrame(): void;
  218. endFrame(): void;
  219. /**
  220. * resize the view according to the canvas' size.
  221. * @example
  222. * window.addEventListener("resize", function () {
  223. * engine.resize();
  224. * });
  225. */
  226. resize(): void;
  227. /**
  228. * force a specific size of the canvas
  229. * @param {number} width - the new canvas' width
  230. * @param {number} height - the new canvas' height
  231. */
  232. setSize(width: number, height: number): void;
  233. bindFramebuffer(texture: WebGLTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number): void;
  234. unBindFramebuffer(texture: WebGLTexture, disableGenerateMipMaps?: boolean): void;
  235. generateMipMapsForCubemap(texture: WebGLTexture): void;
  236. flushFramebuffer(): void;
  237. restoreDefaultFramebuffer(): void;
  238. private _resetVertexBufferBinding();
  239. createVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
  240. createDynamicVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
  241. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: number[] | Float32Array, offset?: number, count?: number): void;
  242. private _resetIndexBufferBinding();
  243. createIndexBuffer(indices: number[] | Int32Array): WebGLBuffer;
  244. bindArrayBuffer(buffer: WebGLBuffer): void;
  245. updateArrayBuffer(data: Float32Array): void;
  246. private bindBuffer(buffer, target);
  247. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  248. bindBuffers(vertexBuffers: {
  249. [key: string]: VertexBuffer;
  250. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  251. unbindInstanceAttributes(): void;
  252. _releaseBuffer(buffer: WebGLBuffer): boolean;
  253. createInstancesBuffer(capacity: number): WebGLBuffer;
  254. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  255. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  256. applyStates(): void;
  257. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  258. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  259. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  260. _releaseEffect(effect: Effect): void;
  261. createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  262. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  263. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
  264. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  265. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  266. enableEffect(effect: Effect): void;
  267. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  268. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  269. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  270. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  271. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  272. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  273. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  274. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  275. setFloat(uniform: WebGLUniformLocation, value: number): void;
  276. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  277. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  278. setBool(uniform: WebGLUniformLocation, bool: number): void;
  279. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  280. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  281. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  282. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  283. setDepthBuffer(enable: boolean): void;
  284. getDepthWrite(): boolean;
  285. setDepthWrite(enable: boolean): void;
  286. setColorWrite(enable: boolean): void;
  287. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  288. getAlphaMode(): number;
  289. setAlphaTesting(enable: boolean): void;
  290. getAlphaTesting(): boolean;
  291. wipeCaches(): void;
  292. setSamplingMode(texture: WebGLTexture, samplingMode: number): void;
  293. createTexture(url: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any): WebGLTexture;
  294. private _getInternalFormat(format);
  295. updateRawTexture(texture: WebGLTexture, data: ArrayBufferView, format: number, invertY: boolean, compression?: string): void;
  296. createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: string): WebGLTexture;
  297. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): WebGLTexture;
  298. updateTextureSamplingMode(samplingMode: number, texture: WebGLTexture): void;
  299. updateDynamicTexture(texture: WebGLTexture, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean): void;
  300. updateVideoTexture(texture: WebGLTexture, video: HTMLVideoElement, invertY: boolean): void;
  301. createRenderTargetTexture(size: any, options: any): WebGLTexture;
  302. createRenderTargetCubeTexture(size: number, options?: any): WebGLTexture;
  303. createCubeTexture(rootUrl: string, scene: Scene, files: string[], noMipmap?: boolean): WebGLTexture;
  304. updateTextureSize(texture: WebGLTexture, width: number, height: number): void;
  305. createRawCubeTexture(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer) => ArrayBufferView[], mipmmapGenerator: ((faces: ArrayBufferView[]) => ArrayBufferView[][])): WebGLTexture;
  306. _releaseTexture(texture: WebGLTexture): void;
  307. bindSamplers(effect: Effect): void;
  308. _bindTexture(channel: number, texture: WebGLTexture): void;
  309. setTextureFromPostProcess(channel: number, postProcess: PostProcess): void;
  310. unbindAllTextures(): void;
  311. setTexture(channel: number, texture: BaseTexture): void;
  312. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  313. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  314. /**
  315. * Add an externaly attached data from its key.
  316. * This method call will fail and return false, if such key already exists.
  317. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  318. * @param key the unique key that identifies the data
  319. * @param data the data object to associate to the key for this Engine instance
  320. * @return true if no such key were already present and the data was added successfully, false otherwise
  321. */
  322. addExternalData<T>(key: string, data: T): boolean;
  323. /**
  324. * Get an externaly attached data from its key
  325. * @param key the unique key that identifies the data
  326. * @return the associated data, if present (can be null), or undefined if not present
  327. */
  328. getExternalData<T>(key: string): T;
  329. /**
  330. * Get an externaly attached data from its key, create it using a factory if it's not already present
  331. * @param key the unique key that identifies the data
  332. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  333. * @return the associated data, can be null if the factory returned null.
  334. */
  335. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  336. /**
  337. * Remove an externaly attached data from the Engine instance
  338. * @param key the unique key that identifies the data
  339. * @return true if the data was successfully removed, false if it doesn't exist
  340. */
  341. removeExternalData(key: any): boolean;
  342. releaseInternalTexture(texture: WebGLTexture): void;
  343. dispose(): void;
  344. displayLoadingUI(): void;
  345. hideLoadingUI(): void;
  346. loadingScreen: ILoadingScreen;
  347. loadingUIText: string;
  348. loadingUIBackgroundColor: string;
  349. getFps(): number;
  350. getDeltaTime(): number;
  351. private _measureFps();
  352. static isSupported(): boolean;
  353. }
  354. }
  355. interface Window {
  356. mozIndexedDB(func: any): any;
  357. webkitIndexedDB(func: any): any;
  358. IDBTransaction(func: any): any;
  359. webkitIDBTransaction(func: any): any;
  360. msIDBTransaction(func: any): any;
  361. IDBKeyRange(func: any): any;
  362. webkitIDBKeyRange(func: any): any;
  363. msIDBKeyRange(func: any): any;
  364. webkitURL: HTMLURL;
  365. webkitRequestAnimationFrame(func: any): any;
  366. mozRequestAnimationFrame(func: any): any;
  367. oRequestAnimationFrame(func: any): any;
  368. WebGLRenderingContext: WebGLRenderingContext;
  369. MSGesture: MSGesture;
  370. CANNON: any;
  371. SIMD: any;
  372. AudioContext: AudioContext;
  373. webkitAudioContext: AudioContext;
  374. PointerEvent: any;
  375. }
  376. interface HTMLURL {
  377. createObjectURL(param1: any, param2?: any): any;
  378. }
  379. interface Document {
  380. exitFullscreen(): void;
  381. webkitCancelFullScreen(): void;
  382. mozCancelFullScreen(): void;
  383. msCancelFullScreen(): void;
  384. mozFullScreen: boolean;
  385. msIsFullScreen: boolean;
  386. fullscreen: boolean;
  387. mozPointerLockElement: HTMLElement;
  388. msPointerLockElement: HTMLElement;
  389. webkitPointerLockElement: HTMLElement;
  390. }
  391. interface HTMLCanvasElement {
  392. requestPointerLock(): void;
  393. msRequestPointerLock(): void;
  394. mozRequestPointerLock(): void;
  395. webkitRequestPointerLock(): void;
  396. }
  397. interface CanvasRenderingContext2D {
  398. imageSmoothingEnabled: boolean;
  399. mozImageSmoothingEnabled: boolean;
  400. oImageSmoothingEnabled: boolean;
  401. webkitImageSmoothingEnabled: boolean;
  402. }
  403. interface WebGLTexture {
  404. isReady: boolean;
  405. isCube: boolean;
  406. url: string;
  407. noMipmap: boolean;
  408. samplingMode: number;
  409. references: number;
  410. generateMipMaps: boolean;
  411. _size: number;
  412. _baseWidth: number;
  413. _baseHeight: number;
  414. _width: number;
  415. _height: number;
  416. _workingCanvas: HTMLCanvasElement;
  417. _workingContext: CanvasRenderingContext2D;
  418. _framebuffer: WebGLFramebuffer;
  419. _depthBuffer: WebGLRenderbuffer;
  420. _cachedCoordinatesMode: number;
  421. _cachedWrapU: number;
  422. _cachedWrapV: number;
  423. _isDisabled: boolean;
  424. }
  425. interface WebGLBuffer {
  426. references: number;
  427. capacity: number;
  428. is32Bits: boolean;
  429. }
  430. interface MouseEvent {
  431. mozMovementX: number;
  432. mozMovementY: number;
  433. webkitMovementX: number;
  434. webkitMovementY: number;
  435. msMovementX: number;
  436. msMovementY: number;
  437. }
  438. interface MSStyleCSSProperties {
  439. webkitTransform: string;
  440. webkitTransition: string;
  441. }
  442. interface Navigator {
  443. getVRDevices: () => any;
  444. mozGetVRDevices: (any: any) => any;
  445. isCocoonJS: boolean;
  446. }
  447. interface Screen {
  448. orientation: string;
  449. mozOrientation: string;
  450. }
  451. interface HTMLMediaElement {
  452. crossOrigin: string;
  453. }
  454. declare module BABYLON {
  455. /**
  456. * Node is the basic class for all scene objects (Mesh, Light Camera).
  457. */
  458. class Node {
  459. name: string;
  460. id: string;
  461. uniqueId: number;
  462. state: string;
  463. animations: Animation[];
  464. private _ranges;
  465. onReady: (node: Node) => void;
  466. private _childrenFlag;
  467. private _isEnabled;
  468. private _isReady;
  469. _currentRenderId: number;
  470. private _parentRenderId;
  471. _waitingParentId: string;
  472. private _scene;
  473. _cache: any;
  474. private _parentNode;
  475. private _children;
  476. parent: Node;
  477. /**
  478. * @constructor
  479. * @param {string} name - the name and id to be given to this node
  480. * @param {BABYLON.Scene} the scene this node will be added to
  481. */
  482. constructor(name: string, scene: Scene);
  483. getScene(): Scene;
  484. getEngine(): Engine;
  485. getWorldMatrix(): Matrix;
  486. _initCache(): void;
  487. updateCache(force?: boolean): void;
  488. _updateCache(ignoreParentClass?: boolean): void;
  489. _isSynchronized(): boolean;
  490. _markSyncedWithParent(): void;
  491. isSynchronizedWithParent(): boolean;
  492. isSynchronized(updateCache?: boolean): boolean;
  493. hasNewParent(update?: boolean): boolean;
  494. /**
  495. * Is this node ready to be used/rendered
  496. * @return {boolean} is it ready
  497. */
  498. isReady(): boolean;
  499. /**
  500. * Is this node enabled.
  501. * If the node has a parent and is enabled, the parent will be inspected as well.
  502. * @return {boolean} whether this node (and its parent) is enabled.
  503. * @see setEnabled
  504. */
  505. isEnabled(): boolean;
  506. /**
  507. * Set the enabled state of this node.
  508. * @param {boolean} value - the new enabled state
  509. * @see isEnabled
  510. */
  511. setEnabled(value: boolean): void;
  512. /**
  513. * Is this node a descendant of the given node.
  514. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
  515. * @param {BABYLON.Node} ancestor - The parent node to inspect
  516. * @see parent
  517. */
  518. isDescendantOf(ancestor: Node): boolean;
  519. /**
  520. * Evaluate the list of children and determine if they should be considered as descendants considering the given criterias
  521. * @param {BABYLON.Node[]} results the result array containing the nodes matching the given criterias
  522. * @param {boolean} directDescendantsOnly if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
  523. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  524. */
  525. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  526. /**
  527. * Will return all nodes that have this node as ascendant.
  528. * @param {boolean} directDescendantsOnly if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
  529. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  530. * @return {BABYLON.Node[]} all children nodes of all types.
  531. */
  532. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  533. /**
  534. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  535. * @Deprecated, legacy support.
  536. * use getDecendants instead.
  537. */
  538. getChildren(predicate?: (node: Node) => boolean): Node[];
  539. /**
  540. * Get all child-meshes of this node.
  541. */
  542. getChildMeshes(directDecendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  543. _setReady(state: boolean): void;
  544. getAnimationByName(name: string): Animation;
  545. createAnimationRange(name: string, from: number, to: number): void;
  546. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  547. getAnimationRange(name: string): AnimationRange;
  548. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): void;
  549. serializeAnimationRanges(): any;
  550. dispose(): void;
  551. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  552. }
  553. }
  554. declare module BABYLON {
  555. interface IDisposable {
  556. dispose(): void;
  557. }
  558. class PointerEventTypes {
  559. static _POINTERDOWN: number;
  560. static _POINTERUP: number;
  561. static _POINTERMOVE: number;
  562. static _POINTERWHEEL: number;
  563. static _POINTERPICK: number;
  564. static POINTERDOWN: number;
  565. static POINTERUP: number;
  566. static POINTERMOVE: number;
  567. static POINTERWHEEL: number;
  568. static POINTERPICK: number;
  569. }
  570. class PointerInfoBase {
  571. type: number;
  572. event: PointerEvent | MouseWheelEvent;
  573. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  574. }
  575. /**
  576. * This class is used to store pointer related info for the onPrePointerObservable event.
  577. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  578. */
  579. class PointerInfoPre extends PointerInfoBase {
  580. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: any, localY: any);
  581. localPosition: Vector2;
  582. skipOnPointerObservable: boolean;
  583. }
  584. /**
  585. * This type contains all the data related to a pointer event in Babylon.js.
  586. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  587. */
  588. class PointerInfo extends PointerInfoBase {
  589. pickInfo: PickingInfo;
  590. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: PickingInfo);
  591. }
  592. /**
  593. * Represents a scene to be rendered by the engine.
  594. * @see http://doc.babylonjs.com/page.php?p=21911
  595. */
  596. class Scene implements IAnimatable {
  597. private static _FOGMODE_NONE;
  598. private static _FOGMODE_EXP;
  599. private static _FOGMODE_EXP2;
  600. private static _FOGMODE_LINEAR;
  601. static MinDeltaTime: number;
  602. static MaxDeltaTime: number;
  603. static FOGMODE_NONE: number;
  604. static FOGMODE_EXP: number;
  605. static FOGMODE_EXP2: number;
  606. static FOGMODE_LINEAR: number;
  607. autoClear: boolean;
  608. clearColor: any;
  609. ambientColor: Color3;
  610. forceWireframe: boolean;
  611. forcePointsCloud: boolean;
  612. forceShowBoundingBoxes: boolean;
  613. clipPlane: Plane;
  614. animationsEnabled: boolean;
  615. constantlyUpdateMeshUnderPointer: boolean;
  616. /**
  617. * An event triggered when the scene is disposed.
  618. * @type {BABYLON.Observable}
  619. */
  620. onDisposeObservable: Observable<Scene>;
  621. private _onDisposeObserver;
  622. onDispose: () => void;
  623. /**
  624. * An event triggered before rendering the scene
  625. * @type {BABYLON.Observable}
  626. */
  627. onBeforeRenderObservable: Observable<Scene>;
  628. private _onBeforeRenderObserver;
  629. beforeRender: () => void;
  630. /**
  631. * An event triggered after rendering the scene
  632. * @type {BABYLON.Observable}
  633. */
  634. onAfterRenderObservable: Observable<Scene>;
  635. private _onAfterRenderObserver;
  636. afterRender: () => void;
  637. /**
  638. * An event triggered when the scene is ready
  639. * @type {BABYLON.Observable}
  640. */
  641. onReadyObservable: Observable<Scene>;
  642. /**
  643. * An event triggered before rendering a camera
  644. * @type {BABYLON.Observable}
  645. */
  646. onBeforeCameraRenderObservable: Observable<Camera>;
  647. private _onBeforeCameraRenderObserver;
  648. beforeCameraRender: () => void;
  649. /**
  650. * An event triggered after rendering a camera
  651. * @type {BABYLON.Observable}
  652. */
  653. onAfterCameraRenderObservable: Observable<Camera>;
  654. private _onAfterCameraRenderObserver;
  655. afterCameraRender: () => void;
  656. /**
  657. * An event triggered when a camera is created
  658. * @type {BABYLON.Observable}
  659. */
  660. onNewCameraAddedObservable: Observable<Camera>;
  661. /**
  662. * An event triggered when a camera is removed
  663. * @type {BABYLON.Observable}
  664. */
  665. onCameraRemovedObservable: Observable<Camera>;
  666. /**
  667. * An event triggered when a light is created
  668. * @type {BABYLON.Observable}
  669. */
  670. onNewLightAddedObservable: Observable<Light>;
  671. /**
  672. * An event triggered when a light is removed
  673. * @type {BABYLON.Observable}
  674. */
  675. onLightRemovedObservable: Observable<Light>;
  676. /**
  677. * An event triggered when a geometry is created
  678. * @type {BABYLON.Observable}
  679. */
  680. onNewGeometryAddedObservable: Observable<Geometry>;
  681. /**
  682. * An event triggered when a geometry is removed
  683. * @type {BABYLON.Observable}
  684. */
  685. onGeometryRemovedObservable: Observable<Geometry>;
  686. /**
  687. * An event triggered when a mesh is created
  688. * @type {BABYLON.Observable}
  689. */
  690. onNewMeshAddedObservable: Observable<AbstractMesh>;
  691. /**
  692. * An event triggered when a mesh is removed
  693. * @type {BABYLON.Observable}
  694. */
  695. onMeshRemovedObservable: Observable<AbstractMesh>;
  696. animations: Animation[];
  697. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  698. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  699. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  700. private _onPointerMove;
  701. private _onPointerDown;
  702. private _onPointerUp;
  703. /**
  704. * @deprecated Use onPointerObservable instead
  705. */
  706. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  707. /**
  708. * @deprecated Use onPointerObservable instead
  709. */
  710. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  711. /**
  712. * @deprecated Use onPointerObservable instead
  713. */
  714. onPointerUp: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  715. /**
  716. * @deprecated Use onPointerObservable instead
  717. */
  718. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  719. /**
  720. * This observable event is triggered when any mouse event registered during Scene.attach() is called BEFORE the 3D engine to process anything (mesh/sprite picking for instance).
  721. * You have the possibility to skip the 3D Engine process and the call to onPointerObservable by setting PointerInfoBase.skipOnPointerObservable to true
  722. */
  723. onPrePointerObservable: Observable<PointerInfoPre>;
  724. /**
  725. * Observable event triggered each time an input event is received from the rendering canvas
  726. */
  727. onPointerObservable: Observable<PointerInfo>;
  728. unTranslatedPointer: Vector2;
  729. cameraToUseForPointers: Camera;
  730. private _pointerX;
  731. private _pointerY;
  732. private _unTranslatedPointerX;
  733. private _unTranslatedPointerY;
  734. private _startingPointerPosition;
  735. private _startingPointerTime;
  736. _mirroredCameraPosition: Vector3;
  737. private _onKeyDown;
  738. private _onKeyUp;
  739. /**
  740. * is fog enabled on this scene.
  741. * @type {boolean}
  742. */
  743. fogEnabled: boolean;
  744. fogMode: number;
  745. fogColor: Color3;
  746. fogDensity: number;
  747. fogStart: number;
  748. fogEnd: number;
  749. /**
  750. * is shadow enabled on this scene.
  751. * @type {boolean}
  752. */
  753. shadowsEnabled: boolean;
  754. /**
  755. * is light enabled on this scene.
  756. * @type {boolean}
  757. */
  758. lightsEnabled: boolean;
  759. /**
  760. * All of the lights added to this scene.
  761. * @see BABYLON.Light
  762. * @type {BABYLON.Light[]}
  763. */
  764. lights: Light[];
  765. /**
  766. * All of the cameras added to this scene.
  767. * @see BABYLON.Camera
  768. * @type {BABYLON.Camera[]}
  769. */
  770. cameras: Camera[];
  771. activeCameras: Camera[];
  772. activeCamera: Camera;
  773. /**
  774. * All of the (abstract) meshes added to this scene.
  775. * @see BABYLON.AbstractMesh
  776. * @type {BABYLON.AbstractMesh[]}
  777. */
  778. meshes: AbstractMesh[];
  779. private _geometries;
  780. materials: Material[];
  781. multiMaterials: MultiMaterial[];
  782. defaultMaterial: StandardMaterial;
  783. texturesEnabled: boolean;
  784. textures: BaseTexture[];
  785. particlesEnabled: boolean;
  786. particleSystems: ParticleSystem[];
  787. spritesEnabled: boolean;
  788. spriteManagers: SpriteManager[];
  789. layers: Layer[];
  790. skeletonsEnabled: boolean;
  791. skeletons: Skeleton[];
  792. lensFlaresEnabled: boolean;
  793. lensFlareSystems: LensFlareSystem[];
  794. collisionsEnabled: boolean;
  795. private _workerCollisions;
  796. collisionCoordinator: ICollisionCoordinator;
  797. gravity: Vector3;
  798. postProcessesEnabled: boolean;
  799. postProcessManager: PostProcessManager;
  800. postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  801. renderTargetsEnabled: boolean;
  802. dumpNextRenderTargets: boolean;
  803. customRenderTargets: RenderTargetTexture[];
  804. useDelayedTextureLoading: boolean;
  805. importedMeshesFiles: String[];
  806. probesEnabled: boolean;
  807. reflectionProbes: ReflectionProbe[];
  808. database: any;
  809. /**
  810. * This scene's action manager
  811. * @type {BABYLON.ActionManager}
  812. */
  813. actionManager: ActionManager;
  814. _actionManagers: ActionManager[];
  815. private _meshesForIntersections;
  816. proceduralTexturesEnabled: boolean;
  817. _proceduralTextures: ProceduralTexture[];
  818. mainSoundTrack: SoundTrack;
  819. soundTracks: SoundTrack[];
  820. private _audioEnabled;
  821. private _headphone;
  822. simplificationQueue: SimplificationQueue;
  823. private _engine;
  824. private _totalVertices;
  825. _activeIndices: number;
  826. _activeParticles: number;
  827. private _lastFrameDuration;
  828. private _evaluateActiveMeshesDuration;
  829. private _renderTargetsDuration;
  830. _particlesDuration: number;
  831. private _renderDuration;
  832. _spritesDuration: number;
  833. private _animationRatio;
  834. private _animationStartDate;
  835. _cachedMaterial: Material;
  836. private _renderId;
  837. private _executeWhenReadyTimeoutId;
  838. private _intermediateRendering;
  839. _toBeDisposed: SmartArray<IDisposable>;
  840. private _pendingData;
  841. private _activeMeshes;
  842. private _processedMaterials;
  843. private _renderTargets;
  844. _activeParticleSystems: SmartArray<ParticleSystem>;
  845. private _activeSkeletons;
  846. private _softwareSkinnedMeshes;
  847. _activeBones: number;
  848. private _renderingManager;
  849. private _physicsEngine;
  850. _activeAnimatables: Animatable[];
  851. private _transformMatrix;
  852. private _pickWithRayInverseMatrix;
  853. private _edgesRenderers;
  854. private _boundingBoxRenderer;
  855. private _outlineRenderer;
  856. private _viewMatrix;
  857. private _projectionMatrix;
  858. private _frustumPlanes;
  859. private _selectionOctree;
  860. private _pointerOverMesh;
  861. private _pointerOverSprite;
  862. private _debugLayer;
  863. private _depthRenderer;
  864. private _uniqueIdCounter;
  865. private _pickedDownMesh;
  866. private _pickedDownSprite;
  867. /**
  868. * @constructor
  869. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  870. */
  871. constructor(engine: Engine);
  872. debugLayer: DebugLayer;
  873. workerCollisions: boolean;
  874. SelectionOctree: Octree<AbstractMesh>;
  875. /**
  876. * The mesh that is currently under the pointer.
  877. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  878. */
  879. meshUnderPointer: AbstractMesh;
  880. /**
  881. * Current on-screen X position of the pointer
  882. * @return {number} X position of the pointer
  883. */
  884. pointerX: number;
  885. /**
  886. * Current on-screen Y position of the pointer
  887. * @return {number} Y position of the pointer
  888. */
  889. pointerY: number;
  890. getCachedMaterial(): Material;
  891. getBoundingBoxRenderer(): BoundingBoxRenderer;
  892. getOutlineRenderer(): OutlineRenderer;
  893. getEngine(): Engine;
  894. getTotalVertices(): number;
  895. getActiveIndices(): number;
  896. getActiveParticles(): number;
  897. getActiveBones(): number;
  898. getLastFrameDuration(): number;
  899. getEvaluateActiveMeshesDuration(): number;
  900. getActiveMeshes(): SmartArray<Mesh>;
  901. getRenderTargetsDuration(): number;
  902. getRenderDuration(): number;
  903. getParticlesDuration(): number;
  904. getSpritesDuration(): number;
  905. getAnimationRatio(): number;
  906. getRenderId(): number;
  907. incrementRenderId(): void;
  908. private _updatePointerPosition(evt);
  909. /**
  910. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  911. * @param attachUp defines if you want to attach events to pointerup
  912. * @param attachDown defines if you want to attach events to pointerdown
  913. * @param attachMove defines if you want to attach events to pointermove
  914. */
  915. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  916. detachControl(): void;
  917. isReady(): boolean;
  918. resetCachedMaterial(): void;
  919. registerBeforeRender(func: () => void): void;
  920. unregisterBeforeRender(func: () => void): void;
  921. registerAfterRender(func: () => void): void;
  922. unregisterAfterRender(func: () => void): void;
  923. _addPendingData(data: any): void;
  924. _removePendingData(data: any): void;
  925. getWaitingItemsCount(): number;
  926. /**
  927. * Registers a function to be executed when the scene is ready.
  928. * @param {Function} func - the function to be executed.
  929. */
  930. executeWhenReady(func: () => void): void;
  931. _checkIsReady(): void;
  932. /**
  933. * Will start the animation sequence of a given target
  934. * @param target - the target
  935. * @param {number} from - from which frame should animation start
  936. * @param {number} to - till which frame should animation run.
  937. * @param {boolean} [loop] - should the animation loop
  938. * @param {number} [speedRatio] - the speed in which to run the animation
  939. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  940. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  941. * @return {BABYLON.Animatable} the animatable object created for this animation
  942. * @see BABYLON.Animatable
  943. * @see http://doc.babylonjs.com/page.php?p=22081
  944. */
  945. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  946. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  947. getAnimatableByTarget(target: any): Animatable;
  948. Animatables: Animatable[];
  949. /**
  950. * Will stop the animation of the given target
  951. * @param target - the target
  952. * @see beginAnimation
  953. */
  954. stopAnimation(target: any): void;
  955. private _animate();
  956. getViewMatrix(): Matrix;
  957. getProjectionMatrix(): Matrix;
  958. getTransformMatrix(): Matrix;
  959. setTransformMatrix(view: Matrix, projection: Matrix): void;
  960. addMesh(newMesh: AbstractMesh): void;
  961. removeMesh(toRemove: AbstractMesh): number;
  962. removeSkeleton(toRemove: Skeleton): number;
  963. removeLight(toRemove: Light): number;
  964. removeCamera(toRemove: Camera): number;
  965. addLight(newLight: Light): void;
  966. addCamera(newCamera: Camera): void;
  967. /**
  968. * Switch active camera
  969. * @param {Camera} newCamera - new active camera
  970. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  971. */
  972. swithActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  973. /**
  974. * sets the active camera of the scene using its ID
  975. * @param {string} id - the camera's ID
  976. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  977. * @see activeCamera
  978. */
  979. setActiveCameraByID(id: string): Camera;
  980. /**
  981. * sets the active camera of the scene using its name
  982. * @param {string} name - the camera's name
  983. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  984. * @see activeCamera
  985. */
  986. setActiveCameraByName(name: string): Camera;
  987. /**
  988. * get a material using its id
  989. * @param {string} the material's ID
  990. * @return {BABYLON.Material|null} the material or null if none found.
  991. */
  992. getMaterialByID(id: string): Material;
  993. /**
  994. * get a material using its name
  995. * @param {string} the material's name
  996. * @return {BABYLON.Material|null} the material or null if none found.
  997. */
  998. getMaterialByName(name: string): Material;
  999. getLensFlareSystemByName(name: string): LensFlareSystem;
  1000. getLensFlareSystemByID(id: string): LensFlareSystem;
  1001. getCameraByID(id: string): Camera;
  1002. getCameraByUniqueID(uniqueId: number): Camera;
  1003. /**
  1004. * get a camera using its name
  1005. * @param {string} the camera's name
  1006. * @return {BABYLON.Camera|null} the camera or null if none found.
  1007. */
  1008. getCameraByName(name: string): Camera;
  1009. /**
  1010. * get a bone using its id
  1011. * @param {string} the bone's id
  1012. * @return {BABYLON.Bone|null} the bone or null if not found
  1013. */
  1014. getBoneByID(id: string): Bone;
  1015. /**
  1016. * get a bone using its id
  1017. * @param {string} the bone's name
  1018. * @return {BABYLON.Bone|null} the bone or null if not found
  1019. */
  1020. getBoneByName(name: string): Bone;
  1021. /**
  1022. * get a light node using its name
  1023. * @param {string} the light's name
  1024. * @return {BABYLON.Light|null} the light or null if none found.
  1025. */
  1026. getLightByName(name: string): Light;
  1027. /**
  1028. * get a light node using its ID
  1029. * @param {string} the light's id
  1030. * @return {BABYLON.Light|null} the light or null if none found.
  1031. */
  1032. getLightByID(id: string): Light;
  1033. /**
  1034. * get a light node using its scene-generated unique ID
  1035. * @param {number} the light's unique id
  1036. * @return {BABYLON.Light|null} the light or null if none found.
  1037. */
  1038. getLightByUniqueID(uniqueId: number): Light;
  1039. /**
  1040. * get a particle system by id
  1041. * @param id {number} the particle system id
  1042. * @return {BABYLON.ParticleSystem|null} the corresponding system or null if none found.
  1043. */
  1044. getParticleSystemByID(id: string): ParticleSystem;
  1045. /**
  1046. * get a geometry using its ID
  1047. * @param {string} the geometry's id
  1048. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1049. */
  1050. getGeometryByID(id: string): Geometry;
  1051. /**
  1052. * add a new geometry to this scene.
  1053. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1054. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1055. * @return {boolean} was the geometry added or not
  1056. */
  1057. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1058. /**
  1059. * Removes an existing geometry
  1060. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1061. * @return {boolean} was the geometry removed or not
  1062. */
  1063. removeGeometry(geometry: Geometry): boolean;
  1064. getGeometries(): Geometry[];
  1065. /**
  1066. * Get the first added mesh found of a given ID
  1067. * @param {string} id - the id to search for
  1068. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1069. */
  1070. getMeshByID(id: string): AbstractMesh;
  1071. getMeshesByID(id: string): Array<AbstractMesh>;
  1072. /**
  1073. * Get a mesh with its auto-generated unique id
  1074. * @param {number} uniqueId - the unique id to search for
  1075. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1076. */
  1077. getMeshByUniqueID(uniqueId: number): AbstractMesh;
  1078. /**
  1079. * Get a the last added mesh found of a given ID
  1080. * @param {string} id - the id to search for
  1081. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1082. */
  1083. getLastMeshByID(id: string): AbstractMesh;
  1084. /**
  1085. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1086. * @param {string} id - the id to search for
  1087. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1088. */
  1089. getLastEntryByID(id: string): Node;
  1090. getNodeByID(id: string): Node;
  1091. getNodeByName(name: string): Node;
  1092. getMeshByName(name: string): AbstractMesh;
  1093. getSoundByName(name: string): Sound;
  1094. getLastSkeletonByID(id: string): Skeleton;
  1095. getSkeletonById(id: string): Skeleton;
  1096. getSkeletonByName(name: string): Skeleton;
  1097. isActiveMesh(mesh: Mesh): boolean;
  1098. private _evaluateSubMesh(subMesh, mesh);
  1099. _isInIntermediateRendering(): boolean;
  1100. private _evaluateActiveMeshes();
  1101. private _activeMesh(mesh);
  1102. updateTransformMatrix(force?: boolean): void;
  1103. private _renderForCamera(camera);
  1104. private _processSubCameras(camera);
  1105. private _checkIntersections();
  1106. render(): void;
  1107. private _updateAudioParameters();
  1108. audioEnabled: boolean;
  1109. private _disableAudio();
  1110. private _enableAudio();
  1111. headphone: boolean;
  1112. private _switchAudioModeForHeadphones();
  1113. private _switchAudioModeForNormalSpeakers();
  1114. enableDepthRenderer(): DepthRenderer;
  1115. disableDepthRenderer(): void;
  1116. freezeMaterials(): void;
  1117. unfreezeMaterials(): void;
  1118. dispose(): void;
  1119. disposeSounds(): void;
  1120. getWorldExtends(): {
  1121. min: Vector3;
  1122. max: Vector3;
  1123. };
  1124. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1125. createPickingRay(x: number, y: number, world: Matrix, camera: Camera, cameraViewSpace?: boolean): Ray;
  1126. createPickingRayInCameraSpace(x: number, y: number, camera: Camera): Ray;
  1127. private _internalPick(rayFunction, predicate, fastCheck?);
  1128. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1129. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo;
  1130. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo;
  1131. pickWithRay(ray: Ray, predicate: (mesh: Mesh) => boolean, fastCheck?: boolean): PickingInfo;
  1132. setPointerOverMesh(mesh: AbstractMesh): void;
  1133. getPointerOverMesh(): AbstractMesh;
  1134. setPointerOverSprite(sprite: Sprite): void;
  1135. getPointerOverSprite(): Sprite;
  1136. getPhysicsEngine(): PhysicsEngine;
  1137. /**
  1138. * Enables physics to the current scene
  1139. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1140. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1141. * @return {boolean} was the physics engine initialized
  1142. */
  1143. enablePhysics(gravity?: Vector3, plugin?: IPhysicsEnginePlugin): boolean;
  1144. disablePhysicsEngine(): void;
  1145. isPhysicsEnabled(): boolean;
  1146. /**
  1147. *
  1148. * Sets the gravity of the physics engine (and NOT of the scene)
  1149. * @param {BABYLON.Vector3} [gravity] - the new gravity to be used
  1150. */
  1151. setGravity(gravity: Vector3): void;
  1152. /**
  1153. * Legacy support, using the new API
  1154. * @Deprecated
  1155. */
  1156. createCompoundImpostor(parts: any, options: PhysicsImpostorParameters): any;
  1157. deleteCompoundImpostor(compound: any): void;
  1158. createDefaultCameraOrLight(): void;
  1159. private _getByTags(list, tagsQuery, forEach?);
  1160. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1161. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1162. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1163. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1164. }
  1165. }
  1166. declare module BABYLON {
  1167. class Action {
  1168. triggerOptions: any;
  1169. trigger: number;
  1170. _actionManager: ActionManager;
  1171. private _nextActiveAction;
  1172. private _child;
  1173. private _condition;
  1174. private _triggerParameter;
  1175. constructor(triggerOptions: any, condition?: Condition);
  1176. _prepare(): void;
  1177. getTriggerParameter(): any;
  1178. _executeCurrent(evt: ActionEvent): void;
  1179. execute(evt: ActionEvent): void;
  1180. skipToNextActiveAction(): void;
  1181. then(action: Action): Action;
  1182. _getProperty(propertyPath: string): string;
  1183. _getEffectiveTarget(target: any, propertyPath: string): any;
  1184. serialize(parent: any): any;
  1185. protected _serialize(serializedAction: any, parent?: any): any;
  1186. static _SerializeValueAsString: (value: any) => string;
  1187. static _GetTargetProperty: (target: Scene | Node) => {
  1188. name: string;
  1189. targetType: string;
  1190. value: string;
  1191. };
  1192. }
  1193. }
  1194. declare module BABYLON {
  1195. /**
  1196. * ActionEvent is the event beint sent when an action is triggered.
  1197. */
  1198. class ActionEvent {
  1199. source: any;
  1200. pointerX: number;
  1201. pointerY: number;
  1202. meshUnderPointer: AbstractMesh;
  1203. sourceEvent: any;
  1204. additionalData: any;
  1205. /**
  1206. * @constructor
  1207. * @param source The mesh or sprite that triggered the action.
  1208. * @param pointerX The X mouse cursor position at the time of the event
  1209. * @param pointerY The Y mouse cursor position at the time of the event
  1210. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1211. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1212. */
  1213. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: AbstractMesh, sourceEvent?: any, additionalData?: any);
  1214. /**
  1215. * Helper function to auto-create an ActionEvent from a source mesh.
  1216. * @param source The source mesh that triggered the event
  1217. * @param evt {Event} The original (browser) event
  1218. */
  1219. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1220. /**
  1221. * Helper function to auto-create an ActionEvent from a source mesh.
  1222. * @param source The source sprite that triggered the event
  1223. * @param scene Scene associated with the sprite
  1224. * @param evt {Event} The original (browser) event
  1225. */
  1226. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1227. /**
  1228. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1229. * @param scene the scene where the event occurred
  1230. * @param evt {Event} The original (browser) event
  1231. */
  1232. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1233. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1234. }
  1235. /**
  1236. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1237. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1238. */
  1239. class ActionManager {
  1240. private static _NothingTrigger;
  1241. private static _OnPickTrigger;
  1242. private static _OnLeftPickTrigger;
  1243. private static _OnRightPickTrigger;
  1244. private static _OnCenterPickTrigger;
  1245. private static _OnPickDownTrigger;
  1246. private static _OnPickUpTrigger;
  1247. private static _OnLongPressTrigger;
  1248. private static _OnPointerOverTrigger;
  1249. private static _OnPointerOutTrigger;
  1250. private static _OnEveryFrameTrigger;
  1251. private static _OnIntersectionEnterTrigger;
  1252. private static _OnIntersectionExitTrigger;
  1253. private static _OnKeyDownTrigger;
  1254. private static _OnKeyUpTrigger;
  1255. private static _OnPickOutTrigger;
  1256. static NothingTrigger: number;
  1257. static OnPickTrigger: number;
  1258. static OnLeftPickTrigger: number;
  1259. static OnRightPickTrigger: number;
  1260. static OnCenterPickTrigger: number;
  1261. static OnPickDownTrigger: number;
  1262. static OnPickUpTrigger: number;
  1263. static OnPickOutTrigger: number;
  1264. static OnLongPressTrigger: number;
  1265. static OnPointerOverTrigger: number;
  1266. static OnPointerOutTrigger: number;
  1267. static OnEveryFrameTrigger: number;
  1268. static OnIntersectionEnterTrigger: number;
  1269. static OnIntersectionExitTrigger: number;
  1270. static OnKeyDownTrigger: number;
  1271. static OnKeyUpTrigger: number;
  1272. static DragMovementThreshold: number;
  1273. static LongPressDelay: number;
  1274. actions: Action[];
  1275. private _scene;
  1276. constructor(scene: Scene);
  1277. dispose(): void;
  1278. getScene(): Scene;
  1279. /**
  1280. * Does this action manager handles actions of any of the given triggers
  1281. * @param {number[]} triggers - the triggers to be tested
  1282. * @return {boolean} whether one (or more) of the triggers is handeled
  1283. */
  1284. hasSpecificTriggers(triggers: number[]): boolean;
  1285. /**
  1286. * Does this action manager handles actions of a given trigger
  1287. * @param {number} trigger - the trigger to be tested
  1288. * @return {boolean} whether the trigger is handeled
  1289. */
  1290. hasSpecificTrigger(trigger: number): boolean;
  1291. /**
  1292. * Does this action manager has pointer triggers
  1293. * @return {boolean} whether or not it has pointer triggers
  1294. */
  1295. hasPointerTriggers: boolean;
  1296. /**
  1297. * Does this action manager has pick triggers
  1298. * @return {boolean} whether or not it has pick triggers
  1299. */
  1300. hasPickTriggers: boolean;
  1301. /**
  1302. * Registers an action to this action manager
  1303. * @param {BABYLON.Action} action - the action to be registered
  1304. * @return {BABYLON.Action} the action amended (prepared) after registration
  1305. */
  1306. registerAction(action: Action): Action;
  1307. /**
  1308. * Process a specific trigger
  1309. * @param {number} trigger - the trigger to process
  1310. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1311. */
  1312. processTrigger(trigger: number, evt: ActionEvent): void;
  1313. _getEffectiveTarget(target: any, propertyPath: string): any;
  1314. _getProperty(propertyPath: string): string;
  1315. serialize(name: string): any;
  1316. static Parse(parsedActions: any, object: AbstractMesh, scene: Scene): void;
  1317. static GetTriggerName(trigger: number): string;
  1318. }
  1319. }
  1320. declare module BABYLON {
  1321. class Condition {
  1322. _actionManager: ActionManager;
  1323. _evaluationId: number;
  1324. _currentResult: boolean;
  1325. constructor(actionManager: ActionManager);
  1326. isValid(): boolean;
  1327. _getProperty(propertyPath: string): string;
  1328. _getEffectiveTarget(target: any, propertyPath: string): any;
  1329. serialize(): any;
  1330. protected _serialize(serializedCondition: any): any;
  1331. }
  1332. class ValueCondition extends Condition {
  1333. propertyPath: string;
  1334. value: any;
  1335. operator: number;
  1336. private static _IsEqual;
  1337. private static _IsDifferent;
  1338. private static _IsGreater;
  1339. private static _IsLesser;
  1340. static IsEqual: number;
  1341. static IsDifferent: number;
  1342. static IsGreater: number;
  1343. static IsLesser: number;
  1344. _actionManager: ActionManager;
  1345. private _target;
  1346. private _effectiveTarget;
  1347. private _property;
  1348. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1349. isValid(): boolean;
  1350. serialize(): any;
  1351. static GetOperatorName(operator: number): string;
  1352. }
  1353. class PredicateCondition extends Condition {
  1354. predicate: () => boolean;
  1355. _actionManager: ActionManager;
  1356. constructor(actionManager: ActionManager, predicate: () => boolean);
  1357. isValid(): boolean;
  1358. }
  1359. class StateCondition extends Condition {
  1360. value: string;
  1361. _actionManager: ActionManager;
  1362. private _target;
  1363. constructor(actionManager: ActionManager, target: any, value: string);
  1364. isValid(): boolean;
  1365. serialize(): any;
  1366. }
  1367. }
  1368. declare module BABYLON {
  1369. class SwitchBooleanAction extends Action {
  1370. propertyPath: string;
  1371. private _target;
  1372. private _effectiveTarget;
  1373. private _property;
  1374. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1375. _prepare(): void;
  1376. execute(): void;
  1377. serialize(parent: any): any;
  1378. }
  1379. class SetStateAction extends Action {
  1380. value: string;
  1381. private _target;
  1382. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1383. execute(): void;
  1384. serialize(parent: any): any;
  1385. }
  1386. class SetValueAction extends Action {
  1387. propertyPath: string;
  1388. value: any;
  1389. private _target;
  1390. private _effectiveTarget;
  1391. private _property;
  1392. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1393. _prepare(): void;
  1394. execute(): void;
  1395. serialize(parent: any): any;
  1396. }
  1397. class IncrementValueAction extends Action {
  1398. propertyPath: string;
  1399. value: any;
  1400. private _target;
  1401. private _effectiveTarget;
  1402. private _property;
  1403. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1404. _prepare(): void;
  1405. execute(): void;
  1406. serialize(parent: any): any;
  1407. }
  1408. class PlayAnimationAction extends Action {
  1409. from: number;
  1410. to: number;
  1411. loop: boolean;
  1412. private _target;
  1413. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  1414. _prepare(): void;
  1415. execute(): void;
  1416. serialize(parent: any): any;
  1417. }
  1418. class StopAnimationAction extends Action {
  1419. private _target;
  1420. constructor(triggerOptions: any, target: any, condition?: Condition);
  1421. _prepare(): void;
  1422. execute(): void;
  1423. serialize(parent: any): any;
  1424. }
  1425. class DoNothingAction extends Action {
  1426. constructor(triggerOptions?: any, condition?: Condition);
  1427. execute(): void;
  1428. serialize(parent: any): any;
  1429. }
  1430. class CombineAction extends Action {
  1431. children: Action[];
  1432. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1433. _prepare(): void;
  1434. execute(evt: ActionEvent): void;
  1435. serialize(parent: any): any;
  1436. }
  1437. class ExecuteCodeAction extends Action {
  1438. func: (evt: ActionEvent) => void;
  1439. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1440. execute(evt: ActionEvent): void;
  1441. }
  1442. class SetParentAction extends Action {
  1443. private _parent;
  1444. private _target;
  1445. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1446. _prepare(): void;
  1447. execute(): void;
  1448. serialize(parent: any): any;
  1449. }
  1450. class PlaySoundAction extends Action {
  1451. private _sound;
  1452. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1453. _prepare(): void;
  1454. execute(): void;
  1455. serialize(parent: any): any;
  1456. }
  1457. class StopSoundAction extends Action {
  1458. private _sound;
  1459. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1460. _prepare(): void;
  1461. execute(): void;
  1462. serialize(parent: any): any;
  1463. }
  1464. }
  1465. declare module BABYLON {
  1466. class InterpolateValueAction extends Action {
  1467. propertyPath: string;
  1468. value: any;
  1469. duration: number;
  1470. stopOtherAnimations: boolean;
  1471. onInterpolationDone: () => void;
  1472. private _target;
  1473. private _effectiveTarget;
  1474. private _property;
  1475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  1476. _prepare(): void;
  1477. execute(): void;
  1478. serialize(parent: any): any;
  1479. }
  1480. }
  1481. declare module BABYLON {
  1482. class Animatable {
  1483. target: any;
  1484. fromFrame: number;
  1485. toFrame: number;
  1486. loopAnimation: boolean;
  1487. speedRatio: number;
  1488. onAnimationEnd: any;
  1489. private _localDelayOffset;
  1490. private _pausedDelay;
  1491. private _animations;
  1492. private _paused;
  1493. private _scene;
  1494. animationStarted: boolean;
  1495. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: any, animations?: any);
  1496. getAnimations(): Animation[];
  1497. appendAnimations(target: any, animations: Animation[]): void;
  1498. getAnimationByTargetProperty(property: string): Animation;
  1499. reset(): void;
  1500. enableBlending(blendingSpeed: number): void;
  1501. disableBlending(): void;
  1502. goToFrame(frame: number): void;
  1503. pause(): void;
  1504. restart(): void;
  1505. stop(): void;
  1506. _animate(delay: number): boolean;
  1507. }
  1508. }
  1509. declare module BABYLON {
  1510. class AnimationRange {
  1511. name: string;
  1512. from: number;
  1513. to: number;
  1514. constructor(name: string, from: number, to: number);
  1515. clone(): AnimationRange;
  1516. }
  1517. /**
  1518. * Composed of a frame, and an action function
  1519. */
  1520. class AnimationEvent {
  1521. frame: number;
  1522. action: () => void;
  1523. onlyOnce: boolean;
  1524. isDone: boolean;
  1525. constructor(frame: number, action: () => void, onlyOnce?: boolean);
  1526. }
  1527. class PathCursor {
  1528. private path;
  1529. private _onchange;
  1530. value: number;
  1531. animations: Animation[];
  1532. constructor(path: Path2);
  1533. getPoint(): Vector3;
  1534. moveAhead(step?: number): PathCursor;
  1535. moveBack(step?: number): PathCursor;
  1536. move(step: number): PathCursor;
  1537. private ensureLimits();
  1538. private markAsDirty(propertyName);
  1539. private raiseOnChange();
  1540. onchange(f: (cursor: PathCursor) => void): PathCursor;
  1541. }
  1542. class Animation {
  1543. name: string;
  1544. targetProperty: string;
  1545. framePerSecond: number;
  1546. dataType: number;
  1547. loopMode: number;
  1548. enableBlending: boolean;
  1549. private _keys;
  1550. private _offsetsCache;
  1551. private _highLimitsCache;
  1552. private _stopped;
  1553. _target: any;
  1554. private _blendingFactor;
  1555. private _easingFunction;
  1556. private _events;
  1557. targetPropertyPath: string[];
  1558. currentFrame: number;
  1559. allowMatricesInterpolation: boolean;
  1560. blendingSpeed: number;
  1561. private _originalBlendValue;
  1562. private _ranges;
  1563. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Animation;
  1564. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Animatable;
  1565. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Animatable;
  1566. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number, enableBlending?: boolean);
  1567. /**
  1568. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  1569. */
  1570. toString(fullDetails?: boolean): string;
  1571. /**
  1572. * Add an event to this animation.
  1573. */
  1574. addEvent(event: AnimationEvent): void;
  1575. /**
  1576. * Remove all events found at the given frame
  1577. * @param frame
  1578. */
  1579. removeEvents(frame: number): void;
  1580. createRange(name: string, from: number, to: number): void;
  1581. deleteRange(name: string, deleteFrames?: boolean): void;
  1582. getRange(name: string): AnimationRange;
  1583. reset(): void;
  1584. isStopped(): boolean;
  1585. getKeys(): any[];
  1586. getHighestFrame(): number;
  1587. getEasingFunction(): IEasingFunction;
  1588. setEasingFunction(easingFunction: EasingFunction): void;
  1589. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  1590. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  1591. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  1592. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  1593. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  1594. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  1595. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  1596. clone(): Animation;
  1597. setKeys(values: Array<any>): void;
  1598. private _getKeyValue(value);
  1599. private _interpolate(currentFrame, repeatCount, loopMode, offsetValue?, highLimitValue?);
  1600. setValue(currentValue: any, blend?: boolean): void;
  1601. goToFrame(frame: number): void;
  1602. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  1603. serialize(): any;
  1604. private static _ANIMATIONTYPE_FLOAT;
  1605. private static _ANIMATIONTYPE_VECTOR3;
  1606. private static _ANIMATIONTYPE_QUATERNION;
  1607. private static _ANIMATIONTYPE_MATRIX;
  1608. private static _ANIMATIONTYPE_COLOR3;
  1609. private static _ANIMATIONTYPE_VECTOR2;
  1610. private static _ANIMATIONTYPE_SIZE;
  1611. private static _ANIMATIONLOOPMODE_RELATIVE;
  1612. private static _ANIMATIONLOOPMODE_CYCLE;
  1613. private static _ANIMATIONLOOPMODE_CONSTANT;
  1614. static ANIMATIONTYPE_FLOAT: number;
  1615. static ANIMATIONTYPE_VECTOR3: number;
  1616. static ANIMATIONTYPE_VECTOR2: number;
  1617. static ANIMATIONTYPE_SIZE: number;
  1618. static ANIMATIONTYPE_QUATERNION: number;
  1619. static ANIMATIONTYPE_MATRIX: number;
  1620. static ANIMATIONTYPE_COLOR3: number;
  1621. static ANIMATIONLOOPMODE_RELATIVE: number;
  1622. static ANIMATIONLOOPMODE_CYCLE: number;
  1623. static ANIMATIONLOOPMODE_CONSTANT: number;
  1624. static Parse(parsedAnimation: any): Animation;
  1625. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  1626. }
  1627. }
  1628. declare module BABYLON {
  1629. interface IEasingFunction {
  1630. ease(gradient: number): number;
  1631. }
  1632. class EasingFunction implements IEasingFunction {
  1633. private static _EASINGMODE_EASEIN;
  1634. private static _EASINGMODE_EASEOUT;
  1635. private static _EASINGMODE_EASEINOUT;
  1636. static EASINGMODE_EASEIN: number;
  1637. static EASINGMODE_EASEOUT: number;
  1638. static EASINGMODE_EASEINOUT: number;
  1639. private _easingMode;
  1640. setEasingMode(easingMode: number): void;
  1641. getEasingMode(): number;
  1642. easeInCore(gradient: number): number;
  1643. ease(gradient: number): number;
  1644. }
  1645. class CircleEase extends EasingFunction implements IEasingFunction {
  1646. easeInCore(gradient: number): number;
  1647. }
  1648. class BackEase extends EasingFunction implements IEasingFunction {
  1649. amplitude: number;
  1650. constructor(amplitude?: number);
  1651. easeInCore(gradient: number): number;
  1652. }
  1653. class BounceEase extends EasingFunction implements IEasingFunction {
  1654. bounces: number;
  1655. bounciness: number;
  1656. constructor(bounces?: number, bounciness?: number);
  1657. easeInCore(gradient: number): number;
  1658. }
  1659. class CubicEase extends EasingFunction implements IEasingFunction {
  1660. easeInCore(gradient: number): number;
  1661. }
  1662. class ElasticEase extends EasingFunction implements IEasingFunction {
  1663. oscillations: number;
  1664. springiness: number;
  1665. constructor(oscillations?: number, springiness?: number);
  1666. easeInCore(gradient: number): number;
  1667. }
  1668. class ExponentialEase extends EasingFunction implements IEasingFunction {
  1669. exponent: number;
  1670. constructor(exponent?: number);
  1671. easeInCore(gradient: number): number;
  1672. }
  1673. class PowerEase extends EasingFunction implements IEasingFunction {
  1674. power: number;
  1675. constructor(power?: number);
  1676. easeInCore(gradient: number): number;
  1677. }
  1678. class QuadraticEase extends EasingFunction implements IEasingFunction {
  1679. easeInCore(gradient: number): number;
  1680. }
  1681. class QuarticEase extends EasingFunction implements IEasingFunction {
  1682. easeInCore(gradient: number): number;
  1683. }
  1684. class QuinticEase extends EasingFunction implements IEasingFunction {
  1685. easeInCore(gradient: number): number;
  1686. }
  1687. class SineEase extends EasingFunction implements IEasingFunction {
  1688. easeInCore(gradient: number): number;
  1689. }
  1690. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  1691. x1: number;
  1692. y1: number;
  1693. x2: number;
  1694. y2: number;
  1695. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  1696. easeInCore(gradient: number): number;
  1697. }
  1698. }
  1699. declare module BABYLON {
  1700. class Analyser {
  1701. SMOOTHING: number;
  1702. FFT_SIZE: number;
  1703. BARGRAPHAMPLITUDE: number;
  1704. DEBUGCANVASPOS: {
  1705. x: number;
  1706. y: number;
  1707. };
  1708. DEBUGCANVASSIZE: {
  1709. width: number;
  1710. height: number;
  1711. };
  1712. private _byteFreqs;
  1713. private _byteTime;
  1714. private _floatFreqs;
  1715. private _webAudioAnalyser;
  1716. private _debugCanvas;
  1717. private _debugCanvasContext;
  1718. private _scene;
  1719. private _registerFunc;
  1720. private _audioEngine;
  1721. constructor(scene: Scene);
  1722. getFrequencyBinCount(): number;
  1723. getByteFrequencyData(): Uint8Array;
  1724. getByteTimeDomainData(): Uint8Array;
  1725. getFloatFrequencyData(): Uint8Array;
  1726. drawDebugCanvas(): void;
  1727. stopDebugCanvas(): void;
  1728. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  1729. dispose(): void;
  1730. }
  1731. }
  1732. declare module BABYLON {
  1733. class AudioEngine {
  1734. private _audioContext;
  1735. private _audioContextInitialized;
  1736. canUseWebAudio: boolean;
  1737. masterGain: GainNode;
  1738. private _connectedAnalyser;
  1739. WarnedWebAudioUnsupported: boolean;
  1740. unlocked: boolean;
  1741. onAudioUnlocked: () => any;
  1742. audioContext: AudioContext;
  1743. constructor();
  1744. private _unlockiOSaudio();
  1745. private _initializeAudioContext();
  1746. dispose(): void;
  1747. getGlobalVolume(): number;
  1748. setGlobalVolume(newVolume: number): void;
  1749. connectToAnalyser(analyser: Analyser): void;
  1750. }
  1751. }
  1752. declare module BABYLON {
  1753. class Sound {
  1754. name: string;
  1755. autoplay: boolean;
  1756. loop: boolean;
  1757. useCustomAttenuation: boolean;
  1758. soundTrackId: number;
  1759. spatialSound: boolean;
  1760. refDistance: number;
  1761. rolloffFactor: number;
  1762. maxDistance: number;
  1763. distanceModel: string;
  1764. private _panningModel;
  1765. onended: () => any;
  1766. private _playbackRate;
  1767. private _streaming;
  1768. private _startTime;
  1769. private _startOffset;
  1770. private _position;
  1771. private _localDirection;
  1772. private _volume;
  1773. private _isLoaded;
  1774. private _isReadyToPlay;
  1775. isPlaying: boolean;
  1776. isPaused: boolean;
  1777. private _isDirectional;
  1778. private _readyToPlayCallback;
  1779. private _audioBuffer;
  1780. private _soundSource;
  1781. private _streamingSource;
  1782. private _soundPanner;
  1783. private _soundGain;
  1784. private _inputAudioNode;
  1785. private _ouputAudioNode;
  1786. private _coneInnerAngle;
  1787. private _coneOuterAngle;
  1788. private _coneOuterGain;
  1789. private _scene;
  1790. private _connectedMesh;
  1791. private _customAttenuationFunction;
  1792. private _registerFunc;
  1793. private _isOutputConnected;
  1794. private _htmlAudioElement;
  1795. /**
  1796. * Create a sound and attach it to a scene
  1797. * @param name Name of your sound
  1798. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  1799. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  1800. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  1801. */
  1802. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
  1803. dispose(): void;
  1804. private _soundLoaded(audioData);
  1805. setAudioBuffer(audioBuffer: AudioBuffer): void;
  1806. updateOptions(options: any): void;
  1807. private _createSpatialParameters();
  1808. private _updateSpatialParameters();
  1809. switchPanningModelToHRTF(): void;
  1810. switchPanningModelToEqualPower(): void;
  1811. private _switchPanningModel();
  1812. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  1813. /**
  1814. * Transform this sound into a directional source
  1815. * @param coneInnerAngle Size of the inner cone in degree
  1816. * @param coneOuterAngle Size of the outer cone in degree
  1817. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  1818. */
  1819. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  1820. setPosition(newPosition: Vector3): void;
  1821. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  1822. private _updateDirection();
  1823. updateDistanceFromListener(): void;
  1824. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  1825. /**
  1826. * Play the sound
  1827. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  1828. */
  1829. play(time?: number): void;
  1830. private _onended();
  1831. /**
  1832. * Stop the sound
  1833. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  1834. */
  1835. stop(time?: number): void;
  1836. pause(): void;
  1837. setVolume(newVolume: number, time?: number): void;
  1838. setPlaybackRate(newPlaybackRate: number): void;
  1839. getVolume(): number;
  1840. attachToMesh(meshToConnectTo: AbstractMesh): void;
  1841. detachFromMesh(): void;
  1842. private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
  1843. clone(): Sound;
  1844. getAudioBuffer(): AudioBuffer;
  1845. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  1846. }
  1847. }
  1848. declare module BABYLON {
  1849. class SoundTrack {
  1850. private _outputAudioNode;
  1851. private _inputAudioNode;
  1852. private _trackConvolver;
  1853. private _scene;
  1854. id: number;
  1855. soundCollection: Array<Sound>;
  1856. private _isMainTrack;
  1857. private _connectedAnalyser;
  1858. private _options;
  1859. private _isInitialized;
  1860. constructor(scene: Scene, options?: any);
  1861. private _initializeSoundTrackAudioGraph();
  1862. dispose(): void;
  1863. AddSound(sound: Sound): void;
  1864. RemoveSound(sound: Sound): void;
  1865. setVolume(newVolume: number): void;
  1866. switchPanningModelToHRTF(): void;
  1867. switchPanningModelToEqualPower(): void;
  1868. connectToAnalyser(analyser: Analyser): void;
  1869. }
  1870. }
  1871. declare module BABYLON {
  1872. class Bone extends Node {
  1873. name: string;
  1874. children: Bone[];
  1875. animations: Animation[];
  1876. length: number;
  1877. private _skeleton;
  1878. _matrix: Matrix;
  1879. private _restPose;
  1880. private _baseMatrix;
  1881. private _worldTransform;
  1882. private _absoluteTransform;
  1883. private _invertedAbsoluteTransform;
  1884. private _parent;
  1885. constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix, restPose?: Matrix);
  1886. getParent(): Bone;
  1887. getLocalMatrix(): Matrix;
  1888. getBaseMatrix(): Matrix;
  1889. getRestPose(): Matrix;
  1890. returnToRest(): void;
  1891. getWorldMatrix(): Matrix;
  1892. getInvertedAbsoluteTransform(): Matrix;
  1893. getAbsoluteTransform(): Matrix;
  1894. updateMatrix(matrix: Matrix): void;
  1895. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  1896. markAsDirty(): void;
  1897. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Vector3): boolean;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. class Skeleton {
  1902. name: string;
  1903. id: string;
  1904. bones: Bone[];
  1905. dimensionsAtRest: Vector3;
  1906. needInitialSkinMatrix: boolean;
  1907. private _scene;
  1908. private _isDirty;
  1909. private _transformMatrices;
  1910. private _meshesWithPoseMatrix;
  1911. private _animatables;
  1912. private _identity;
  1913. private _ranges;
  1914. constructor(name: string, id: string, scene: Scene);
  1915. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  1916. getScene(): Scene;
  1917. /**
  1918. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  1919. */
  1920. toString(fullDetails?: boolean): string;
  1921. /**
  1922. * Get bone's index searching by name
  1923. * @param {string} name is bone's name to search for
  1924. * @return {number} Indice of the bone. Returns -1 if not found
  1925. */
  1926. getBoneIndexByName(name: string): number;
  1927. createAnimationRange(name: string, from: number, to: number): void;
  1928. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  1929. getAnimationRange(name: string): AnimationRange;
  1930. /**
  1931. * Returns as an Array, all AnimationRanges defined on this skeleton
  1932. */
  1933. getAnimationRanges(): AnimationRange[];
  1934. /**
  1935. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  1936. */
  1937. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  1938. returnToRest(): void;
  1939. private _getHighestAnimationFrame();
  1940. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1941. _markAsDirty(): void;
  1942. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  1943. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  1944. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Matrix): void;
  1945. prepare(): void;
  1946. getAnimatables(): IAnimatable[];
  1947. clone(name: string, id: string): Skeleton;
  1948. enableBlending(blendingSpeed?: number): void;
  1949. dispose(): void;
  1950. serialize(): any;
  1951. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  1952. }
  1953. }
  1954. declare module BABYLON {
  1955. class ArcRotateCamera extends TargetCamera {
  1956. alpha: number;
  1957. beta: number;
  1958. radius: number;
  1959. target: Vector3;
  1960. inertialAlphaOffset: number;
  1961. inertialBetaOffset: number;
  1962. inertialRadiusOffset: number;
  1963. lowerAlphaLimit: any;
  1964. upperAlphaLimit: any;
  1965. lowerBetaLimit: number;
  1966. upperBetaLimit: number;
  1967. lowerRadiusLimit: any;
  1968. upperRadiusLimit: any;
  1969. inertialPanningX: number;
  1970. inertialPanningY: number;
  1971. angularSensibilityX: number;
  1972. angularSensibilityY: number;
  1973. pinchPrecision: number;
  1974. panningSensibility: number;
  1975. keysUp: number[];
  1976. keysDown: number[];
  1977. keysLeft: number[];
  1978. keysRight: number[];
  1979. wheelPrecision: number;
  1980. zoomOnFactor: number;
  1981. targetScreenOffset: Vector2;
  1982. allowUpsideDown: boolean;
  1983. _viewMatrix: Matrix;
  1984. _useCtrlForPanning: boolean;
  1985. inputs: ArcRotateCameraInputsManager;
  1986. _reset: () => void;
  1987. panningAxis: Vector3;
  1988. private _localDirection;
  1989. private _transformedDirection;
  1990. onCollide: (collidedMesh: AbstractMesh) => void;
  1991. checkCollisions: boolean;
  1992. collisionRadius: Vector3;
  1993. private _collider;
  1994. private _previousPosition;
  1995. private _collisionVelocity;
  1996. private _newPosition;
  1997. private _previousAlpha;
  1998. private _previousBeta;
  1999. private _previousRadius;
  2000. private _collisionTriggered;
  2001. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  2002. _initCache(): void;
  2003. _updateCache(ignoreParentClass?: boolean): void;
  2004. private _getTargetPosition();
  2005. _isSynchronizedViewMatrix(): boolean;
  2006. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean): void;
  2007. detachControl(element: HTMLElement): void;
  2008. _checkInputs(): void;
  2009. private _checkLimits();
  2010. rebuildAnglesAndRadius(): void;
  2011. setPosition(position: Vector3): void;
  2012. setTarget(target: Vector3): void;
  2013. _getViewMatrix(): Matrix;
  2014. private _onCollisionPositionChange;
  2015. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  2016. focusOn(meshesOrMinMaxVectorAndDistance: any, doNotUpdateMaxZ?: boolean): void;
  2017. /**
  2018. * @override
  2019. * Override Camera.createRigCamera
  2020. */
  2021. createRigCamera(name: string, cameraIndex: number): Camera;
  2022. /**
  2023. * @override
  2024. * Override Camera._updateRigCameras
  2025. */
  2026. _updateRigCameras(): void;
  2027. dispose(): void;
  2028. getTypeName(): string;
  2029. }
  2030. }
  2031. declare module BABYLON {
  2032. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  2033. constructor(camera: ArcRotateCamera);
  2034. addMouseWheel(): ArcRotateCameraInputsManager;
  2035. addPointers(): ArcRotateCameraInputsManager;
  2036. addKeyboard(): ArcRotateCameraInputsManager;
  2037. addGamepad(): ArcRotateCameraInputsManager;
  2038. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  2039. }
  2040. }
  2041. declare module BABYLON {
  2042. class Camera extends Node {
  2043. inputs: CameraInputsManager<Camera>;
  2044. private static _PERSPECTIVE_CAMERA;
  2045. private static _ORTHOGRAPHIC_CAMERA;
  2046. private static _FOVMODE_VERTICAL_FIXED;
  2047. private static _FOVMODE_HORIZONTAL_FIXED;
  2048. private static _RIG_MODE_NONE;
  2049. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  2050. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  2051. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  2052. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  2053. private static _RIG_MODE_VR;
  2054. static PERSPECTIVE_CAMERA: number;
  2055. static ORTHOGRAPHIC_CAMERA: number;
  2056. static FOVMODE_VERTICAL_FIXED: number;
  2057. static FOVMODE_HORIZONTAL_FIXED: number;
  2058. static RIG_MODE_NONE: number;
  2059. static RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  2060. static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  2061. static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  2062. static RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  2063. static RIG_MODE_VR: number;
  2064. static ForceAttachControlToAlwaysPreventDefault: boolean;
  2065. position: Vector3;
  2066. upVector: Vector3;
  2067. orthoLeft: any;
  2068. orthoRight: any;
  2069. orthoBottom: any;
  2070. orthoTop: any;
  2071. fov: number;
  2072. minZ: number;
  2073. maxZ: number;
  2074. inertia: number;
  2075. mode: number;
  2076. isIntermediate: boolean;
  2077. viewport: Viewport;
  2078. layerMask: number;
  2079. fovMode: number;
  2080. cameraRigMode: number;
  2081. interaxialDistance: number;
  2082. isStereoscopicSideBySide: boolean;
  2083. _cameraRigParams: any;
  2084. _rigCameras: Camera[];
  2085. _rigPostProcess: PostProcess;
  2086. private _computedViewMatrix;
  2087. _projectionMatrix: Matrix;
  2088. private _worldMatrix;
  2089. _postProcesses: PostProcess[];
  2090. _activeMeshes: SmartArray<Mesh>;
  2091. private _globalPosition;
  2092. constructor(name: string, position: Vector3, scene: Scene);
  2093. /**
  2094. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2095. */
  2096. toString(fullDetails?: boolean): string;
  2097. globalPosition: Vector3;
  2098. getActiveMeshes(): SmartArray<Mesh>;
  2099. isActiveMesh(mesh: Mesh): boolean;
  2100. _initCache(): void;
  2101. _updateCache(ignoreParentClass?: boolean): void;
  2102. _updateFromScene(): void;
  2103. _isSynchronized(): boolean;
  2104. _isSynchronizedViewMatrix(): boolean;
  2105. _isSynchronizedProjectionMatrix(): boolean;
  2106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  2107. detachControl(element: HTMLElement): void;
  2108. _update(): void;
  2109. _checkInputs(): void;
  2110. private _cascadePostProcessesToRigCams();
  2111. attachPostProcess(postProcess: PostProcess, insertAt?: number): number;
  2112. detachPostProcess(postProcess: PostProcess, atIndices?: any): number[];
  2113. getWorldMatrix(): Matrix;
  2114. _getViewMatrix(): Matrix;
  2115. getViewMatrix(force?: boolean): Matrix;
  2116. _computeViewMatrix(force?: boolean): Matrix;
  2117. getProjectionMatrix(force?: boolean): Matrix;
  2118. dispose(): void;
  2119. setCameraRigMode(mode: number, rigParams: any): void;
  2120. private _getVRProjectionMatrix();
  2121. setCameraRigParameter(name: string, value: any): void;
  2122. /**
  2123. * needs to be overridden by children so sub has required properties to be copied
  2124. */
  2125. createRigCamera(name: string, cameraIndex: number): Camera;
  2126. /**
  2127. * May need to be overridden by children
  2128. */
  2129. _updateRigCameras(): void;
  2130. _setupInputs(): void;
  2131. serialize(): any;
  2132. getTypeName(): string;
  2133. clone(name: string): Camera;
  2134. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  2135. static Parse(parsedCamera: any, scene: Scene): Camera;
  2136. }
  2137. }
  2138. declare module BABYLON {
  2139. var CameraInputTypes: {};
  2140. interface ICameraInput<TCamera extends BABYLON.Camera> {
  2141. camera: TCamera;
  2142. getTypeName(): string;
  2143. getSimpleName(): string;
  2144. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  2145. detachControl: (element: HTMLElement) => void;
  2146. checkInputs?: () => void;
  2147. }
  2148. interface CameraInputsMap<TCamera extends BABYLON.Camera> {
  2149. [name: string]: ICameraInput<TCamera>;
  2150. [idx: number]: ICameraInput<TCamera>;
  2151. }
  2152. class CameraInputsManager<TCamera extends BABYLON.Camera> {
  2153. attached: CameraInputsMap<TCamera>;
  2154. attachedElement: HTMLElement;
  2155. noPreventDefault: boolean;
  2156. camera: TCamera;
  2157. checkInputs: () => void;
  2158. constructor(camera: TCamera);
  2159. add(input: ICameraInput<TCamera>): void;
  2160. remove(inputToRemove: ICameraInput<TCamera>): void;
  2161. removeByType(inputType: string): void;
  2162. private _addCheckInputs(fn);
  2163. attachInput(input: ICameraInput<TCamera>): void;
  2164. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  2165. detachElement(element: HTMLElement): void;
  2166. rebuildInputCheck(): void;
  2167. clear(): void;
  2168. serialize(serializedCamera: any): void;
  2169. parse(parsedCamera: any): void;
  2170. }
  2171. }
  2172. declare module BABYLON {
  2173. class DeviceOrientationCamera extends FreeCamera {
  2174. angularSensibility: number;
  2175. moveSensibility: number;
  2176. constructor(name: string, position: Vector3, scene: Scene);
  2177. getTypeName(): string;
  2178. }
  2179. }
  2180. declare module BABYLON {
  2181. class FollowCamera extends TargetCamera {
  2182. radius: number;
  2183. rotationOffset: number;
  2184. heightOffset: number;
  2185. cameraAcceleration: number;
  2186. maxCameraSpeed: number;
  2187. target: AbstractMesh;
  2188. constructor(name: string, position: Vector3, scene: Scene, target?: AbstractMesh);
  2189. private getRadians(degrees);
  2190. private follow(cameraTarget);
  2191. _checkInputs(): void;
  2192. getTypeName(): string;
  2193. }
  2194. class ArcFollowCamera extends TargetCamera {
  2195. alpha: number;
  2196. beta: number;
  2197. radius: number;
  2198. target: AbstractMesh;
  2199. private _cartesianCoordinates;
  2200. constructor(name: string, alpha: number, beta: number, radius: number, target: AbstractMesh, scene: Scene);
  2201. private follow();
  2202. _checkInputs(): void;
  2203. getTypeName(): string;
  2204. }
  2205. }
  2206. declare module BABYLON {
  2207. class FreeCamera extends TargetCamera {
  2208. ellipsoid: Vector3;
  2209. checkCollisions: boolean;
  2210. applyGravity: boolean;
  2211. inputs: FreeCameraInputsManager;
  2212. angularSensibility: number;
  2213. keysUp: number[];
  2214. keysDown: number[];
  2215. keysLeft: number[];
  2216. keysRight: number[];
  2217. onCollide: (collidedMesh: AbstractMesh) => void;
  2218. private _collider;
  2219. private _needMoveForGravity;
  2220. private _oldPosition;
  2221. private _diffPosition;
  2222. private _newPosition;
  2223. _localDirection: Vector3;
  2224. _transformedDirection: Vector3;
  2225. constructor(name: string, position: Vector3, scene: Scene);
  2226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  2227. detachControl(element: HTMLElement): void;
  2228. _collideWithWorld(velocity: Vector3): void;
  2229. private _onCollisionPositionChange;
  2230. _checkInputs(): void;
  2231. _decideIfNeedsToMove(): boolean;
  2232. _updatePosition(): void;
  2233. dispose(): void;
  2234. getTypeName(): string;
  2235. }
  2236. }
  2237. declare module BABYLON {
  2238. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  2239. constructor(camera: FreeCamera);
  2240. addKeyboard(): FreeCameraInputsManager;
  2241. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  2242. addGamepad(): FreeCameraInputsManager;
  2243. addDeviceOrientation(): FreeCameraInputsManager;
  2244. addVRDeviceOrientation(): FreeCameraInputsManager;
  2245. addTouch(): FreeCameraInputsManager;
  2246. addVirtualJoystick(): FreeCameraInputsManager;
  2247. }
  2248. }
  2249. declare module BABYLON {
  2250. class GamepadCamera extends UniversalCamera {
  2251. gamepadAngularSensibility: number;
  2252. gamepadMoveSensibility: number;
  2253. constructor(name: string, position: Vector3, scene: Scene);
  2254. getTypeName(): string;
  2255. }
  2256. }
  2257. declare module BABYLON {
  2258. class AnaglyphFreeCamera extends FreeCamera {
  2259. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  2260. getTypeName(): string;
  2261. }
  2262. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  2263. constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, scene: Scene);
  2264. getTypeName(): string;
  2265. }
  2266. class AnaglyphGamepadCamera extends GamepadCamera {
  2267. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  2268. getTypeName(): string;
  2269. }
  2270. class AnaglyphUniversalCamera extends UniversalCamera {
  2271. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  2272. getTypeName(): string;
  2273. }
  2274. class StereoscopicFreeCamera extends FreeCamera {
  2275. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2276. getTypeName(): string;
  2277. }
  2278. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  2279. constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2280. getTypeName(): string;
  2281. }
  2282. class StereoscopicGamepadCamera extends GamepadCamera {
  2283. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2284. getTypeName(): string;
  2285. }
  2286. class StereoscopicUniversalCamera extends UniversalCamera {
  2287. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2288. getTypeName(): string;
  2289. }
  2290. }
  2291. declare module BABYLON {
  2292. class TargetCamera extends Camera {
  2293. cameraDirection: Vector3;
  2294. cameraRotation: Vector2;
  2295. rotation: Vector3;
  2296. rotationQuaternion: Quaternion;
  2297. speed: number;
  2298. noRotationConstraint: boolean;
  2299. lockedTarget: any;
  2300. _currentTarget: Vector3;
  2301. _viewMatrix: Matrix;
  2302. _camMatrix: Matrix;
  2303. _cameraTransformMatrix: Matrix;
  2304. _cameraRotationMatrix: Matrix;
  2305. private _rigCamTransformMatrix;
  2306. _referencePoint: Vector3;
  2307. private _defaultUpVector;
  2308. _transformedReferencePoint: Vector3;
  2309. _lookAtTemp: Matrix;
  2310. _tempMatrix: Matrix;
  2311. _reset: () => void;
  2312. constructor(name: string, position: Vector3, scene: Scene);
  2313. getFrontPosition(distance: number): Vector3;
  2314. _getLockedTargetPosition(): Vector3;
  2315. _initCache(): void;
  2316. _updateCache(ignoreParentClass?: boolean): void;
  2317. _isSynchronizedViewMatrix(): boolean;
  2318. _computeLocalCameraSpeed(): number;
  2319. setTarget(target: Vector3): void;
  2320. getTarget(): Vector3;
  2321. _decideIfNeedsToMove(): boolean;
  2322. _updatePosition(): void;
  2323. _checkInputs(): void;
  2324. private _updateCameraRotationMatrix();
  2325. _getViewMatrix(): Matrix;
  2326. /**
  2327. * @override
  2328. * Override Camera.createRigCamera
  2329. */
  2330. createRigCamera(name: string, cameraIndex: number): Camera;
  2331. /**
  2332. * @override
  2333. * Override Camera._updateRigCameras
  2334. */
  2335. _updateRigCameras(): void;
  2336. private _getRigCamPosition(halfSpace, result);
  2337. getTypeName(): string;
  2338. }
  2339. }
  2340. declare module BABYLON {
  2341. class TouchCamera extends FreeCamera {
  2342. touchAngularSensibility: number;
  2343. touchMoveSensibility: number;
  2344. constructor(name: string, position: Vector3, scene: Scene);
  2345. getTypeName(): string;
  2346. _setupInputs(): void;
  2347. }
  2348. }
  2349. declare module BABYLON {
  2350. class UniversalCamera extends TouchCamera {
  2351. gamepadAngularSensibility: number;
  2352. gamepadMoveSensibility: number;
  2353. constructor(name: string, position: Vector3, scene: Scene);
  2354. getTypeName(): string;
  2355. }
  2356. }
  2357. declare module BABYLON {
  2358. class VirtualJoysticksCamera extends FreeCamera {
  2359. constructor(name: string, position: Vector3, scene: Scene);
  2360. }
  2361. }
  2362. declare module BABYLON {
  2363. class DebugLayer {
  2364. private _scene;
  2365. private _camera;
  2366. private _transformationMatrix;
  2367. private _enabled;
  2368. private _labelsEnabled;
  2369. private _displayStatistics;
  2370. private _displayTree;
  2371. private _displayLogs;
  2372. private _globalDiv;
  2373. private _statsDiv;
  2374. private _statsSubsetDiv;
  2375. private _optionsDiv;
  2376. private _optionsSubsetDiv;
  2377. private _logDiv;
  2378. private _logSubsetDiv;
  2379. private _treeDiv;
  2380. private _treeSubsetDiv;
  2381. private _drawingCanvas;
  2382. private _drawingContext;
  2383. private _rootElement;
  2384. private _skeletonViewers;
  2385. _syncPositions: () => void;
  2386. private _syncData;
  2387. private _syncUI;
  2388. private _onCanvasClick;
  2389. private _clickPosition;
  2390. private _ratio;
  2391. private _identityMatrix;
  2392. private _showUI;
  2393. private _needToRefreshMeshesTree;
  2394. shouldDisplayLabel: (node: Node) => boolean;
  2395. shouldDisplayAxis: (mesh: Mesh) => boolean;
  2396. axisRatio: number;
  2397. accentColor: string;
  2398. customStatsFunction: () => string;
  2399. constructor(scene: Scene);
  2400. private _refreshMeshesTreeContent();
  2401. private _renderSingleAxis(zero, unit, unitText, label, color);
  2402. private _renderAxis(projectedPosition, mesh, globalViewport);
  2403. private _renderLabel(text, projectedPosition, labelOffset, onClick, getFillStyle);
  2404. private _isClickInsideRect(x, y, width, height);
  2405. isVisible(): boolean;
  2406. hide(): void;
  2407. private _clearSkeletonViewers();
  2408. show(showUI?: boolean, camera?: Camera, rootElement?: HTMLElement): void;
  2409. private _clearLabels();
  2410. private _generateheader(root, text);
  2411. private _generateTexBox(root, title, color);
  2412. private _generateAdvancedCheckBox(root, leftTitle, rightTitle, initialState, task, tag?);
  2413. private _generateCheckBox(root, title, initialState, task, tag?);
  2414. private _generateButton(root, title, task, tag?);
  2415. private _generateRadio(root, title, name, initialState, task, tag?);
  2416. private _generateDOMelements();
  2417. private _displayStats();
  2418. }
  2419. }
  2420. declare module BABYLON.Debug {
  2421. /**
  2422. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  2423. */
  2424. class SkeletonViewer {
  2425. skeleton: Skeleton;
  2426. mesh: AbstractMesh;
  2427. autoUpdateBonesMatrices: boolean;
  2428. renderingGroupId: number;
  2429. color: Color3;
  2430. private _scene;
  2431. private _debugLines;
  2432. private _debugMesh;
  2433. private _isEnabled;
  2434. private _renderFunction;
  2435. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  2436. isEnabled: boolean;
  2437. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  2438. private _getLinesForBonesWithLength(bones, meshMat);
  2439. private _getLinesForBonesNoLength(bones, meshMat);
  2440. update(): void;
  2441. private _updateBoneMatrix(bone);
  2442. dispose(): void;
  2443. }
  2444. }
  2445. declare module BABYLON {
  2446. /**
  2447. * Stores 2D Bounding Information.
  2448. * This class handles a circle area and a bounding rectangle one.
  2449. */
  2450. class BoundingInfo2D {
  2451. /**
  2452. * The coordinate of the center of the bounding info
  2453. */
  2454. center: Vector2;
  2455. /**
  2456. * The radius of the bounding circle, from the center of the bounded object
  2457. */
  2458. radius: number;
  2459. /**
  2460. * The extent of the bounding rectangle, from the center of the bounded object.
  2461. * This is an absolute value in both X and Y of the vector which describe the right/top corner of the rectangle, you can easily reconstruct the whole rectangle by negating X &| Y.
  2462. */
  2463. extent: Vector2;
  2464. constructor();
  2465. /**
  2466. * Create a BoundingInfo2D object from a given size
  2467. * @param size the size that will be used to set the extend, radius will be computed from it.
  2468. */
  2469. static CreateFromSize(size: Size): BoundingInfo2D;
  2470. /**
  2471. * Create a BoundingInfo2D object from a given radius
  2472. * @param radius the radius to use, the extent will be computed from it.
  2473. */
  2474. static CreateFromRadius(radius: number): BoundingInfo2D;
  2475. /**
  2476. * Create a BoundingInfo2D object from a list of points.
  2477. * The resulted object will be the smallest bounding area that includes all the given points.
  2478. * @param points an array of points to compute the bounding object from.
  2479. */
  2480. static CreateFromPoints(points: Vector2[]): BoundingInfo2D;
  2481. /**
  2482. * Update a BoundingInfo2D object using the given Size as input
  2483. * @param size the bounding data will be computed from this size.
  2484. * @param b must be a valid/allocated object, it will contain the result of the operation
  2485. */
  2486. static CreateFromSizeToRef(size: Size, b: BoundingInfo2D): void;
  2487. /**
  2488. * Update a BoundingInfo2D object using the given radius as input
  2489. * @param radius the bounding data will be computed from this radius
  2490. * @param b must be a valid/allocated object, it will contain the result of the operation
  2491. */
  2492. static CreateFromRadiusToRef(radius: number, b: BoundingInfo2D): void;
  2493. /**
  2494. * Update a BoundingInfo2D object using the given points array as input
  2495. * @param points the point array to use to update the bounding data
  2496. * @param b must be a valid/allocated object, it will contain the result of the operation
  2497. */
  2498. static CreateFromPointsToRef(points: Vector2[], b: BoundingInfo2D): void;
  2499. /**
  2500. * Update a BoundingInfo2D object using the given min/max values as input
  2501. * @param xmin the smallest x coordinate
  2502. * @param xmax the biggest x coordinate
  2503. * @param ymin the smallest y coordinate
  2504. * @param ymax the buggest y coordinate
  2505. * @param b must be a valid/allocated object, it will contain the result of the operation
  2506. */
  2507. static CreateFromMinMaxToRef(xmin: number, xmax: number, ymin: number, ymax: number, b: BoundingInfo2D): void;
  2508. /**
  2509. * Duplicate this instance and return a new one
  2510. * @return the duplicated instance
  2511. */
  2512. clone(): BoundingInfo2D;
  2513. /**
  2514. * return the max extend of the bounding info
  2515. */
  2516. max(): Vector2;
  2517. /**
  2518. * Update a vector2 with the max extend of the bounding info
  2519. * @param result must be a valid/allocated vector2 that will contain the result of the operation
  2520. */
  2521. maxToRef(result: Vector2): void;
  2522. /**
  2523. * Apply a transformation matrix to this BoundingInfo2D and return a new instance containing the result
  2524. * @param matrix the transformation matrix to apply
  2525. * @return the new instance containing the result of the transformation applied on this BoundingInfo2D
  2526. */
  2527. transform(matrix: Matrix): BoundingInfo2D;
  2528. /**
  2529. * Compute the union of this BoundingInfo2D with a given one, returns a new BoundingInfo2D as a result
  2530. * @param other the second BoundingInfo2D to compute the union with this one
  2531. * @return a new instance containing the result of the union
  2532. */
  2533. union(other: BoundingInfo2D): BoundingInfo2D;
  2534. private static _transform;
  2535. /**
  2536. * Transform this BoundingInfo2D with a given matrix and store the result in an existing BoundingInfo2D instance.
  2537. * This is a GC friendly version, try to use it as much as possible, specially if your transformation is inside a loop, allocate the result object once for good outside of the loop and use it every time.
  2538. * @param matrix The matrix to use to compute the transformation
  2539. * @param result A VALID (i.e. allocated) BoundingInfo2D object where the result will be stored
  2540. */
  2541. transformToRef(matrix: Matrix, result: BoundingInfo2D): void;
  2542. /**
  2543. * Compute the union of this BoundingInfo2D with another one and store the result in a third valid BoundingInfo2D object
  2544. * This is a GC friendly version, try to use it as much as possible, specially if your transformation is inside a loop, allocate the result object once for good outside of the loop and use it every time.
  2545. * @param other the second object used to compute the union
  2546. * @param result a VALID BoundingInfo2D instance (i.e. allocated) where the result will be stored
  2547. */
  2548. unionToRef(other: BoundingInfo2D, result: BoundingInfo2D): void;
  2549. /**
  2550. * Check if the given point is inside the BoundingInfo.
  2551. * The test is first made on the radius, then inside the rectangle described by the extent
  2552. * @param pickPosition the position to test
  2553. * @return true if the point is inside, false otherwise
  2554. */
  2555. doesIntersect(pickPosition: Vector2): boolean;
  2556. }
  2557. }
  2558. declare module BABYLON {
  2559. /**
  2560. * This interface is used to implement a lockable instance pattern.
  2561. * Classes that implements it may be locked at any time, making their content immutable from now on.
  2562. * You also can query if a given instance is locked or not.
  2563. * This allow instances to be shared among several 'consumers'.
  2564. */
  2565. interface ILockable {
  2566. /**
  2567. * Query the lock state
  2568. * @returns returns true if the object is locked and immutable, false if it's not
  2569. */
  2570. isLocked(): boolean;
  2571. /**
  2572. * A call to this method will definitely lock the instance, making its content immutable
  2573. * @returns the previous lock state of the object. so if true is returned the object were already locked and this method does nothing, if false is returned it means the object wasn't locked and this call locked it for good.
  2574. */
  2575. lock(): boolean;
  2576. }
  2577. /**
  2578. * This interface defines the IBrush2D contract.
  2579. * Classes implementing a new type of Brush2D must implement this interface
  2580. */
  2581. interface IBrush2D extends ILockable {
  2582. /**
  2583. * Define if the brush will use transparency / alpha blending
  2584. * @returns true if the brush use transparency
  2585. */
  2586. isTransparent(): boolean;
  2587. /**
  2588. * It is critical for each instance of a given Brush2D type to return a unique string that identifies it because the Border instance will certainly be part of the computed ModelKey for a given Primitive
  2589. * @returns A string identifier that uniquely identify the instance
  2590. */
  2591. toString(): string;
  2592. }
  2593. /**
  2594. * Base class implementing the ILocable interface.
  2595. * The particularity of this class is to call the protected onLock() method when the instance is about to be locked for good.
  2596. */
  2597. class LockableBase implements ILockable {
  2598. isLocked(): boolean;
  2599. private _isLocked;
  2600. lock(): boolean;
  2601. /**
  2602. * Protected handler that will be called when the instance is about to be locked.
  2603. */
  2604. protected onLock(): void;
  2605. }
  2606. class SolidColorBrush2D extends LockableBase implements IBrush2D {
  2607. constructor(color: Color4, lock?: boolean);
  2608. /**
  2609. * Return true if the brush is transparent, false if it's totally opaque
  2610. */
  2611. isTransparent(): boolean;
  2612. /**
  2613. * The color used by this instance to render
  2614. * @returns the color object. Note that it's not a clone of the actual object stored in the instance so you MUST NOT modify it, otherwise unexpected behavior might occurs.
  2615. */
  2616. color: Color4;
  2617. /**
  2618. * Return a unique identifier of the instance, which is simply the hexadecimal representation (CSS Style) of the solid color.
  2619. */
  2620. toString(): string;
  2621. private _color;
  2622. }
  2623. class GradientColorBrush2D extends LockableBase implements IBrush2D {
  2624. constructor(color1: Color4, color2: Color4, translation?: Vector2, rotation?: number, scale?: number, lock?: boolean);
  2625. /**
  2626. * Return true if the brush is transparent, false if it's totally opaque
  2627. */
  2628. isTransparent(): boolean;
  2629. /**
  2630. * First color, the blend will start from this color
  2631. */
  2632. color1: Color4;
  2633. /**
  2634. * Second color, the blend will end to this color
  2635. */
  2636. color2: Color4;
  2637. /**
  2638. * Translation vector to apply on the blend
  2639. * Default is [0;0]
  2640. */
  2641. translation: Vector2;
  2642. /**
  2643. * Rotation in radian to apply to the brush
  2644. * Default direction of the brush is vertical, you can change this using this property.
  2645. * Default is 0.
  2646. */
  2647. rotation: number;
  2648. /**
  2649. * Scale factor to apply to the gradient.
  2650. * Default is 1: no scale.
  2651. */
  2652. scale: number;
  2653. /**
  2654. * Return a string describing the brush
  2655. */
  2656. toString(): string;
  2657. /**
  2658. * Build a unique key string for the given parameters
  2659. */
  2660. static BuildKey(color1: Color4, color2: Color4, translation: Vector2, rotation: number, scale: number): string;
  2661. private _color1;
  2662. private _color2;
  2663. private _translation;
  2664. private _rotation;
  2665. private _scale;
  2666. }
  2667. }
  2668. declare module BABYLON {
  2669. class Canvas2DEngineBoundData {
  2670. GetOrAddModelCache<TInstData>(key: string, factory: (key: string) => ModelRenderCache): ModelRenderCache;
  2671. private _modelCache;
  2672. DisposeModelRenderCache(modelRenderCache: ModelRenderCache): boolean;
  2673. }
  2674. abstract class Canvas2D extends Group2D {
  2675. /**
  2676. * In this strategy only the direct children groups of the Canvas will be cached, their whole content (whatever the sub groups they have) into a single bitmap.
  2677. * This strategy doesn't allow primitives added directly as children of the Canvas.
  2678. * You typically want to use this strategy of a screenSpace fullscreen canvas: you don't want a bitmap cache taking the whole screen resolution but still want the main contents (say UI in the topLeft and rightBottom for instance) to be efficiently cached.
  2679. */
  2680. static CACHESTRATEGY_TOPLEVELGROUPS: number;
  2681. /**
  2682. * In this strategy each group will have its own cache bitmap (except if a given group explicitly defines the DONTCACHEOVERRIDE or CACHEINPARENTGROUP behaviors).
  2683. * This strategy is typically used if the canvas has some groups that are frequently animated. Unchanged ones will have a steady cache and the others will be refreshed when they change, reducing the redraw operation count to their content only.
  2684. * When using this strategy, group instances can rely on the DONTCACHEOVERRIDE or CACHEINPARENTGROUP behaviors to minimize the amount of cached bitmaps.
  2685. * Note that in this mode the Canvas itself is not cached, it only contains the sprites of its direct children group to render, there's no point to cache the whole canvas, sprites will be rendered pretty efficiently, the memory cost would be too great for the value of it.
  2686. */
  2687. static CACHESTRATEGY_ALLGROUPS: number;
  2688. /**
  2689. * In this strategy the whole canvas is cached into a single bitmap containing every primitives it owns, at the exception of the ones that are owned by a group having the DONTCACHEOVERRIDE behavior (these primitives will be directly drawn to the viewport at each render for screenSpace Canvas or be part of the Canvas cache bitmap for worldSpace Canvas).
  2690. */
  2691. static CACHESTRATEGY_CANVAS: number;
  2692. /**
  2693. * This strategy is used to recompose/redraw the canvas entirely at each viewport render.
  2694. * Use this strategy if memory is a concern above rendering performances and/or if the canvas is frequently animated (hence reducing the benefits of caching).
  2695. * Note that you can't use this strategy for WorldSpace Canvas, they need at least a top level group caching.
  2696. */
  2697. static CACHESTRATEGY_DONTCACHE: number;
  2698. constructor(scene: Scene, settings?: {
  2699. id?: string;
  2700. children?: Array<Prim2DBase>;
  2701. size?: Size;
  2702. renderScaleFactor?: number;
  2703. isScreenSpace?: boolean;
  2704. cachingStrategy?: number;
  2705. enableInteraction?: boolean;
  2706. origin?: Vector2;
  2707. isVisible?: boolean;
  2708. backgroundRoundRadius?: number;
  2709. backgroundFill?: IBrush2D | string;
  2710. backgroundBorder?: IBrush2D | string;
  2711. backgroundBorderThickNess?: number;
  2712. });
  2713. protected _canvasPreInit(settings: any): void;
  2714. static hierarchyLevelMaxSiblingCount: number;
  2715. private _setupInteraction(enable);
  2716. /**
  2717. * If you set your own WorldSpaceNode to display the Canvas2D you have to provide your own implementation of this method which computes the local position in the Canvas based on the given 3D World one.
  2718. * Beware that you have to take under consideration the origin and the renderScaleFactor in your calculations! Good luck!
  2719. */
  2720. worldSpaceToNodeLocal: (worldPos: Vector3) => Vector2;
  2721. /**
  2722. * Internal method, you should use the Prim2DBase version instead
  2723. */
  2724. _setPointerCapture(pointerId: number, primitive: Prim2DBase): boolean;
  2725. /**
  2726. * Internal method, you should use the Prim2DBase version instead
  2727. */
  2728. _releasePointerCapture(pointerId: number, primitive: Prim2DBase): boolean;
  2729. /**
  2730. * Determine if the given pointer is captured or not
  2731. * @param pointerId the Id of the pointer
  2732. * @return true if it's captured, false otherwise
  2733. */
  2734. isPointerCaptured(pointerId: number): boolean;
  2735. private getCapturedPrimitive(pointerId);
  2736. private static _interInfo;
  2737. private _handlePointerEventForInteraction(eventData, localPosition, eventState);
  2738. private _updatePointerInfo(eventData, localPosition);
  2739. private _updateIntersectionList(mouseLocalPos, isCapture);
  2740. private _updateOverStatus();
  2741. private _updatePrimPointerPos(prim);
  2742. private _notifDebugMode;
  2743. private _debugExecObserver(prim, mask);
  2744. private _bubbleNotifyPrimPointerObserver(prim, mask, eventData);
  2745. private _triggerActionManager(prim, ppi, mask, eventData);
  2746. _notifParents(prim: Prim2DBase, mask: number): void;
  2747. /**
  2748. * Don't forget to call the dispose method when you're done with the Canvas instance.
  2749. * But don't worry, if you dispose its scene, the canvas will be automatically disposed too.
  2750. */
  2751. dispose(): boolean;
  2752. /**
  2753. * Accessor to the Scene that owns the Canvas
  2754. * @returns The instance of the Scene object
  2755. */
  2756. scene: Scene;
  2757. /**
  2758. * Accessor to the Engine that drives the Scene used by this Canvas
  2759. * @returns The instance of the Engine object
  2760. */
  2761. engine: Engine;
  2762. /**
  2763. * Accessor of the Caching Strategy used by this Canvas.
  2764. * See Canvas2D.CACHESTRATEGY_xxxx static members for more information
  2765. * @returns the value corresponding to the used strategy.
  2766. */
  2767. cachingStrategy: number;
  2768. /**
  2769. * Only valid for World Space Canvas, returns the scene node that displays the canvas
  2770. */
  2771. worldSpaceCanvasNode: Node;
  2772. /**
  2773. * Check if the WebGL Instanced Array extension is supported or not
  2774. */
  2775. supportInstancedArray: boolean;
  2776. /**
  2777. * Property that defines the fill object used to draw the background of the Canvas.
  2778. * Note that Canvas with a Caching Strategy of
  2779. * @returns If the background is not set, null will be returned, otherwise a valid fill object is returned.
  2780. */
  2781. backgroundFill: IBrush2D;
  2782. /**
  2783. * Property that defines the border object used to draw the background of the Canvas.
  2784. * @returns If the background is not set, null will be returned, otherwise a valid border object is returned.
  2785. */
  2786. backgroundBorder: IBrush2D;
  2787. /**
  2788. * Property that defines the thickness of the border object used to draw the background of the Canvas.
  2789. * @returns If the background is not set, null will be returned, otherwise a valid number matching the thickness is returned.
  2790. */
  2791. backgroundBorderThickness: number;
  2792. /**
  2793. * You can set the roundRadius of the background
  2794. * @returns The current roundRadius
  2795. */
  2796. backgroundRoundRadius: number;
  2797. /**
  2798. * Enable/Disable interaction for this Canvas
  2799. * When enabled the Prim2DBase.pointerEventObservable property will notified when appropriate events occur
  2800. */
  2801. interactionEnabled: boolean;
  2802. /**
  2803. * Access the babylon.js' engine bound data, do not invoke this method, it's for internal purpose only
  2804. * @returns {}
  2805. */
  2806. _engineData: Canvas2DEngineBoundData;
  2807. private checkBackgroundAvailability();
  2808. private __engineData;
  2809. private _interactionEnabled;
  2810. private _primPointerInfo;
  2811. private _updateRenderId;
  2812. private _intersectionRenderId;
  2813. private _hoverStatusRenderId;
  2814. private _pickStartingPosition;
  2815. private _renderScaleFactor;
  2816. private _pickedDownPrim;
  2817. private _pickStartingTime;
  2818. private _previousIntersectionList;
  2819. private _actualIntersectionList;
  2820. private _previousOverPrimitive;
  2821. private _actualOverPrimitive;
  2822. private _capturedPointers;
  2823. private _scenePrePointerObserver;
  2824. private _scenePointerObserver;
  2825. protected _worldSpaceNode: Node;
  2826. private _mapCounter;
  2827. private _background;
  2828. private _scene;
  2829. private _engine;
  2830. private _fitRenderingDevice;
  2831. private _isScreenSpace;
  2832. private _cachedCanvasGroup;
  2833. private _cachingStrategy;
  2834. private _hierarchyLevelMaxSiblingCount;
  2835. private _groupCacheMaps;
  2836. private _beforeRenderObserver;
  2837. private _afterRenderObserver;
  2838. private _supprtInstancedArray;
  2839. private _trackedGroups;
  2840. _renderingSize: Size;
  2841. protected onPrimBecomesDirty(): void;
  2842. private static _v;
  2843. private static _m;
  2844. private _updateTrackedNodes();
  2845. private _updateCanvasState();
  2846. /**
  2847. * Method that renders the Canvas, you should not invoke
  2848. */
  2849. private _render();
  2850. /**
  2851. * Internal method that allocate a cache for the given group.
  2852. * Caching is made using a collection of MapTexture where many groups have their bitmap cache stored inside.
  2853. * @param group The group to allocate the cache of.
  2854. * @return custom type with the PackedRect instance giving information about the cache location into the texture and also the MapTexture instance that stores the cache.
  2855. */
  2856. _allocateGroupCache(group: Group2D, parent: Group2D, minSize?: Size): {
  2857. node: PackedRect;
  2858. texture: MapTexture;
  2859. sprite: Sprite2D;
  2860. };
  2861. /**
  2862. * Define the default size used for both the width and height of a MapTexture to allocate.
  2863. * Note that some MapTexture might be bigger than this size if the first node to allocate is bigger in width or height
  2864. */
  2865. private static _groupTextureCacheSize;
  2866. /**
  2867. * Internal method used to register a Scene Node to track position for the given group
  2868. * Do not invoke this method, for internal purpose only.
  2869. * @param group the group to track its associated Scene Node
  2870. */
  2871. _registerTrackedNode(group: Group2D): void;
  2872. /**
  2873. * Internal method used to unregister a tracked Scene Node
  2874. * Do not invoke this method, it's for internal purpose only.
  2875. * @param group the group to unregister its tracked Scene Node from.
  2876. */
  2877. _unregisterTrackedNode(group: Group2D): void;
  2878. /**
  2879. * Get a Solid Color Brush instance matching the given color.
  2880. * @param color The color to retrieve
  2881. * @return A shared instance of the SolidColorBrush2D class that use the given color
  2882. */
  2883. static GetSolidColorBrush(color: Color4): IBrush2D;
  2884. /**
  2885. * Get a Solid Color Brush instance matching the given color expressed as a CSS formatted hexadecimal value.
  2886. * @param color The color to retrieve
  2887. * @return A shared instance of the SolidColorBrush2D class that uses the given color
  2888. */
  2889. static GetSolidColorBrushFromHex(hexValue: string): IBrush2D;
  2890. /**
  2891. * Get a Gradient Color Brush
  2892. * @param color1 starting color
  2893. * @param color2 engine color
  2894. * @param translation translation vector to apply. default is [0;0]
  2895. * @param rotation rotation in radian to apply to the brush, initial direction is top to bottom. rotation is counter clockwise. default is 0.
  2896. * @param scale scaling factor to apply. default is 1.
  2897. */
  2898. static GetGradientColorBrush(color1: Color4, color2: Color4, translation?: Vector2, rotation?: number, scale?: number): IBrush2D;
  2899. /**
  2900. * Create a solid or gradient brush from a string value.
  2901. * @param brushString should be either
  2902. * - "solid: #RRGGBBAA" or "#RRGGBBAA"
  2903. * - "gradient: #FF808080, #FFFFFFF[, [10:20], 180, 1]" for color1, color2, translation, rotation (degree), scale. The last three are optionals, but if specified must be is this order. "gradient:" can be omitted.
  2904. */
  2905. static GetBrushFromString(brushString: string): IBrush2D;
  2906. private static _solidColorBrushes;
  2907. private static _gradientColorBrushes;
  2908. }
  2909. class WorldSpaceCanvas2D extends Canvas2D {
  2910. /**
  2911. * Create a new 2D WorldSpace Rendering Canvas, it is a 2D rectangle that has a size (width/height) and a world transformation information to place it in the world space.
  2912. * This kind of canvas can't have its Primitives directly drawn in the Viewport, they need to be cached in a bitmap at some point, as a consequence the DONT_CACHE strategy is unavailable. For now only CACHESTRATEGY_CANVAS is supported, but the remaining strategies will be soon.
  2913. * @param scene the Scene that owns the Canvas
  2914. * @param size the dimension of the Canvas in World Space
  2915. * @param settings a combination of settings, possible ones are
  2916. * - children: an array of direct children primitives
  2917. * - id: a text identifier, for information purpose only, default is null.
  2918. * - worldPosition the position of the Canvas in World Space, default is [0,0,0]
  2919. * - worldRotation the rotation of the Canvas in World Space, default is Quaternion.Identity()
  2920. * - renderScaleFactor A scale factor applied to create the rendering texture that will be mapped in the Scene Rectangle. If you set 2 for instance the texture will be twice large in width and height. A greater value will allow to achieve a better rendering quality. Default value is 1.
  2921. * BE AWARE that the Canvas true dimension will be size*renderScaleFactor, then all coordinates and size will have to be express regarding this size.
  2922. * TIPS: if you want a renderScaleFactor independent reference of frame, create a child Group2D in the Canvas with position 0,0 and size set to null, then set its scale property to the same amount than the renderScaleFactor, put all your primitive inside using coordinates regarding the size property you pick for the Canvas and you'll be fine.
  2923. * - sideOrientation: Unexpected behavior occur if the value is different from Mesh.DEFAULTSIDE right now, so please use this one, which is the default.
  2924. * - cachingStrategy Must be CACHESTRATEGY_CANVAS for now, which is the default.
  2925. * - enableInteraction: if true the pointer events will be listened and rerouted to the appropriate primitives of the Canvas2D through the Prim2DBase.onPointerEventObservable observable property. Default is false (the opposite of ScreenSpace).
  2926. * - isVisible: true if the canvas must be visible, false for hidden. Default is true.
  2927. * - backgroundRoundRadius: the round radius of the background, either backgroundFill or backgroundBorder must be specified.
  2928. * - backgroundFill: the brush to use to create a background fill for the canvas. can be a string value (see Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2929. * - backgroundBorder: the brush to use to create a background border for the canvas. can be a string value (see Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2930. * - backgroundBorderThickness: if a backgroundBorder is specified, its thickness can be set using this property
  2931. * - customWorldSpaceNode: if specified the Canvas will be rendered in this given Node. But it's the responsibility of the caller to set the "worldSpaceToNodeLocal" property to compute the hit of the mouse ray into the node (in world coordinate system) as well as rendering the cached bitmap in the node itself. The properties cachedRect and cachedTexture of Group2D will give you what you need to do that.
  2932. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2933. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2934. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2935. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2936. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  2937. */
  2938. constructor(scene: Scene, size: Size, settings?: {
  2939. children?: Array<Prim2DBase>;
  2940. id?: string;
  2941. worldPosition?: Vector3;
  2942. worldRotation?: Quaternion;
  2943. renderScaleFactor?: number;
  2944. sideOrientation?: number;
  2945. cachingStrategy?: number;
  2946. enableInteraction?: boolean;
  2947. isVisible?: boolean;
  2948. backgroundRoundRadius?: number;
  2949. backgroundFill?: IBrush2D | string;
  2950. backgroundBorder?: IBrush2D | string;
  2951. backgroundBorderThickNess?: number;
  2952. customWorldSpaceNode?: Node;
  2953. paddingTop?: number | string;
  2954. paddingLeft?: number | string;
  2955. paddingRight?: number | string;
  2956. paddingBottom?: number | string;
  2957. padding?: string;
  2958. });
  2959. }
  2960. class ScreenSpaceCanvas2D extends Canvas2D {
  2961. /**
  2962. * Create a new 2D ScreenSpace Rendering Canvas, it is a 2D rectangle that has a size (width/height) and a position relative to the bottom/left corner of the screen.
  2963. * ScreenSpace Canvas will be drawn in the Viewport as a 2D Layer lying to the top of the 3D Scene. Typically used for traditional UI.
  2964. * All caching strategies will be available.
  2965. * PLEASE NOTE: the origin of a Screen Space Canvas is set to [0;0] (bottom/left) which is different than the default origin of a Primitive which is centered [0.5;0.5]
  2966. * @param scene the Scene that owns the Canvas
  2967. * @param settings a combination of settings, possible ones are
  2968. * - children: an array of direct children primitives
  2969. * - id: a text identifier, for information purpose only
  2970. * - x: the position along the x axis (horizontal), relative to the left edge of the viewport. you can alternatively use the position setting.
  2971. * - y: the position along the y axis (vertically), relative to the bottom edge of the viewport. you can alternatively use the position setting.
  2972. * - position: the position of the canvas, relative from the bottom/left of the scene's viewport. Alternatively you can set the x and y properties directly. Default value is [0, 0]
  2973. * - width: the width of the Canvas. you can alternatively use the size setting.
  2974. * - height: the height of the Canvas. you can alternatively use the size setting.
  2975. * - size: the Size of the canvas. Alternatively the width and height properties can be set. If null two behaviors depend on the cachingStrategy: if it's CACHESTRATEGY_CACHECANVAS then it will always auto-fit the rendering device, in all the other modes it will fit the content of the Canvas
  2976. * - cachingStrategy: either CACHESTRATEGY_TOPLEVELGROUPS, CACHESTRATEGY_ALLGROUPS, CACHESTRATEGY_CANVAS, CACHESTRATEGY_DONTCACHE. Please refer to their respective documentation for more information. Default is Canvas2D.CACHESTRATEGY_DONTCACHE
  2977. * - enableInteraction: if true the pointer events will be listened and rerouted to the appropriate primitives of the Canvas2D through the Prim2DBase.onPointerEventObservable observable property. Default is true.
  2978. * - isVisible: true if the canvas must be visible, false for hidden. Default is true.
  2979. * - backgroundRoundRadius: the round radius of the background, either backgroundFill or backgroundBorder must be specified.
  2980. * - backgroundFill: the brush to use to create a background fill for the canvas. can be a string value (see BABYLON.Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2981. * - backgroundBorder: the brush to use to create a background border for the canvas. can be a string value (see BABYLON.Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2982. * - backgroundBorderThickness: if a backgroundBorder is specified, its thickness can be set using this property
  2983. * - customWorldSpaceNode: if specified the Canvas will be rendered in this given Node. But it's the responsibility of the caller to set the "worldSpaceToNodeLocal" property to compute the hit of the mouse ray into the node (in world coordinate system) as well as rendering the cached bitmap in the node itself. The properties cachedRect and cachedTexture of Group2D will give you what you need to do that.
  2984. * - paddingTop: top padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2985. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2986. * - paddingRight: right padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2987. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2988. * - padding: top, left, right and bottom padding formatted as a single string (see BABYLON.PrimitiveThickness.fromString)
  2989. */
  2990. constructor(scene: Scene, settings?: {
  2991. children?: Array<Prim2DBase>;
  2992. id?: string;
  2993. x?: number;
  2994. y?: number;
  2995. position?: Vector2;
  2996. origin?: Vector2;
  2997. width?: number;
  2998. height?: number;
  2999. size?: Size;
  3000. cachingStrategy?: number;
  3001. enableInteraction?: boolean;
  3002. isVisible?: boolean;
  3003. backgroundRoundRadius?: number;
  3004. backgroundFill?: IBrush2D | string;
  3005. backgroundBorder?: IBrush2D | string;
  3006. backgroundBorderThickNess?: number;
  3007. paddingTop?: number | string;
  3008. paddingLeft?: number | string;
  3009. paddingRight?: number | string;
  3010. paddingBottom?: number | string;
  3011. padding?: string;
  3012. });
  3013. }
  3014. }
  3015. declare module BABYLON {
  3016. class LayoutEngineBase implements ILockable {
  3017. constructor();
  3018. updateLayout(prim: Prim2DBase): void;
  3019. isChildPositionAllowed: boolean;
  3020. isLocked(): boolean;
  3021. lock(): boolean;
  3022. layoutDirtyOnPropertyChangedMask: any;
  3023. private _isLocked;
  3024. }
  3025. class CanvasLayoutEngine extends LayoutEngineBase {
  3026. static Singleton: CanvasLayoutEngine;
  3027. updateLayout(prim: Prim2DBase): void;
  3028. private _doUpdate(prim);
  3029. isChildPositionAllowed: boolean;
  3030. }
  3031. class StackPanelLayoutEngine extends LayoutEngineBase {
  3032. constructor();
  3033. static Horizontal: StackPanelLayoutEngine;
  3034. static Vertical: StackPanelLayoutEngine;
  3035. private static _horizontal;
  3036. private static _vertical;
  3037. isHorizontal: boolean;
  3038. private _isHorizontal;
  3039. updateLayout(prim: Prim2DBase): void;
  3040. isChildPositionAllowed: boolean;
  3041. }
  3042. }
  3043. declare module BABYLON {
  3044. class Ellipse2DRenderCache extends ModelRenderCache {
  3045. effectsReady: boolean;
  3046. fillVB: WebGLBuffer;
  3047. fillIB: WebGLBuffer;
  3048. fillIndicesCount: number;
  3049. instancingFillAttributes: InstancingAttributeInfo[];
  3050. effectFillInstanced: Effect;
  3051. effectFill: Effect;
  3052. borderVB: WebGLBuffer;
  3053. borderIB: WebGLBuffer;
  3054. borderIndicesCount: number;
  3055. instancingBorderAttributes: InstancingAttributeInfo[];
  3056. effectBorderInstanced: Effect;
  3057. effectBorder: Effect;
  3058. constructor(engine: Engine, modelKey: string);
  3059. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  3060. dispose(): boolean;
  3061. }
  3062. class Ellipse2DInstanceData extends Shape2DInstanceData {
  3063. constructor(partId: number);
  3064. properties: Vector3;
  3065. }
  3066. class Ellipse2D extends Shape2D {
  3067. static acutalSizeProperty: Prim2DPropInfo;
  3068. static subdivisionsProperty: Prim2DPropInfo;
  3069. actualSize: Size;
  3070. subdivisions: number;
  3071. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  3072. protected updateLevelBoundingInfo(): void;
  3073. /**
  3074. * Create an Ellipse 2D Shape primitive
  3075. * @param settings a combination of settings, possible ones are
  3076. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  3077. * - children: an array of direct children
  3078. * - id: a text identifier, for information purpose
  3079. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  3080. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  3081. * - scale: the initial scale of the primitive. default is 1
  3082. * - origin: define the normalized origin point location, default [0.5;0.5]
  3083. * - size: the size of the group. Alternatively the width and height properties can be set. Default will be [10;10].
  3084. * - subdivision: the number of subdivision to create the ellipse perimeter, default is 64.
  3085. * - fill: the brush used to draw the fill content of the ellipse, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can also be a string value (see Canvas2D.GetBrushFromString)
  3086. * - border: the brush used to draw the border of the ellipse, you can set null to draw nothing (but you will have to set a fill brush), default is null. can be a string value (see Canvas2D.GetBrushFromString)
  3087. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3088. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3089. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3090. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3091. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  3092. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  3093. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  3094. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  3095. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3096. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3097. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3098. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3099. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  3100. */
  3101. constructor(settings?: {
  3102. parent?: Prim2DBase;
  3103. children?: Array<Prim2DBase>;
  3104. id?: string;
  3105. position?: Vector2;
  3106. x?: number;
  3107. y?: number;
  3108. rotation?: number;
  3109. scale?: number;
  3110. origin?: Vector2;
  3111. size?: Size;
  3112. width?: number;
  3113. height?: number;
  3114. subdivisions?: number;
  3115. fill?: IBrush2D | string;
  3116. border?: IBrush2D | string;
  3117. borderThickness?: number;
  3118. isVisible?: boolean;
  3119. marginTop?: number | string;
  3120. marginLeft?: number | string;
  3121. marginRight?: number | string;
  3122. marginBottom?: number | string;
  3123. margin?: number | string;
  3124. marginHAlignment?: number;
  3125. marginVAlignment?: number;
  3126. marginAlignment?: string;
  3127. paddingTop?: number | string;
  3128. paddingLeft?: number | string;
  3129. paddingRight?: number | string;
  3130. paddingBottom?: number | string;
  3131. padding?: string;
  3132. });
  3133. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  3134. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Ellipse2DRenderCache;
  3135. protected createInstanceDataParts(): InstanceDataBase[];
  3136. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  3137. private _subdivisions;
  3138. }
  3139. }
  3140. declare module BABYLON {
  3141. class Group2D extends Prim2DBase {
  3142. static GROUP2D_PROPCOUNT: number;
  3143. static sizeProperty: Prim2DPropInfo;
  3144. static actualSizeProperty: Prim2DPropInfo;
  3145. /**
  3146. * Default behavior, the group will use the caching strategy defined at the Canvas Level
  3147. */
  3148. static GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY: number;
  3149. /**
  3150. * When used, this group's content won't be cached, no matter which strategy used.
  3151. * If the group is part of a WorldSpace Canvas, its content will be drawn in the Canvas cache bitmap.
  3152. */
  3153. static GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE: number;
  3154. /**
  3155. * When used, the group's content will be cached in the nearest cached parent group/canvas
  3156. */
  3157. static GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP: number;
  3158. /**
  3159. * Create an Logical or Renderable Group.
  3160. * @param settings a combination of settings, possible ones are
  3161. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  3162. * - children: an array of direct children
  3163. * - id a text identifier, for information purpose
  3164. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  3165. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  3166. * - scale: the initial scale of the primitive. default is 1
  3167. * - origin: define the normalized origin point location, default [0.5;0.5]
  3168. * - size: the size of the group. Alternatively the width and height properties can be set. If null the size will be computed from its content, default is null.
  3169. * - cacheBehavior: Define how the group should behave regarding the Canvas's cache strategy, default is Group2D.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY
  3170. * - layoutEngine: either an instance of a layout engine based class (StackPanel.Vertical, StackPanel.Horizontal) or a string ('canvas' for Canvas layout, 'StackPanel' or 'HorizontalStackPanel' for horizontal Stack Panel layout, 'VerticalStackPanel' for vertical Stack Panel layout).
  3171. * - isVisible: true if the group must be visible, false for hidden. Default is true.
  3172. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3173. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3174. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3175. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3176. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  3177. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  3178. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  3179. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  3180. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3181. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3182. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3183. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3184. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  3185. */
  3186. constructor(settings?: {
  3187. parent?: Prim2DBase;
  3188. children?: Array<Prim2DBase>;
  3189. id?: string;
  3190. position?: Vector2;
  3191. x?: number;
  3192. y?: number;
  3193. trackNode?: Node;
  3194. origin?: Vector2;
  3195. size?: Size;
  3196. width?: number;
  3197. height?: number;
  3198. cacheBehavior?: number;
  3199. layoutEngine?: LayoutEngineBase | string;
  3200. isVisible?: boolean;
  3201. marginTop?: number | string;
  3202. marginLeft?: number | string;
  3203. marginRight?: number | string;
  3204. marginBottom?: number | string;
  3205. margin?: number | string;
  3206. marginHAlignment?: number;
  3207. marginVAlignment?: number;
  3208. marginAlignment?: string;
  3209. paddingTop?: number | string;
  3210. paddingLeft?: number | string;
  3211. paddingRight?: number | string;
  3212. paddingBottom?: number | string;
  3213. padding?: string;
  3214. });
  3215. static _createCachedCanvasGroup(owner: Canvas2D): Group2D;
  3216. protected applyCachedTexture(vertexData: VertexData, material: StandardMaterial): void;
  3217. /**
  3218. * Allow you to access the information regarding the cached rectangle of the Group2D into the MapTexture.
  3219. * If the `noWorldSpaceNode` options was used at the creation of a WorldSpaceCanvas, the rendering of the canvas must be made by the caller, so typically you want to bind the cacheTexture property to some material/mesh and you must use the cachedRect.UVs property to get the UV coordinates to use for your quad that will display the Canvas.
  3220. */
  3221. cachedRect: PackedRect;
  3222. /**
  3223. * Access the texture that maintains a cached version of the Group2D.
  3224. * This is useful only if you're not using a WorldSpaceNode for your WorldSpace Canvas and therefore need to perform the rendering yourself.
  3225. */
  3226. cacheTexture: MapTexture;
  3227. /**
  3228. * Call this method to remove this Group and its children from the Canvas
  3229. */
  3230. dispose(): boolean;
  3231. /**
  3232. * @returns Returns true if the Group render content, false if it's a logical group only
  3233. */
  3234. isRenderableGroup: boolean;
  3235. /**
  3236. * @returns only meaningful for isRenderableGroup, will be true if the content of the Group is cached into a texture, false if it's rendered every time
  3237. */
  3238. isCachedGroup: boolean;
  3239. /**
  3240. * Get/Set the size of the group. If null the size of the group will be determine from its content.
  3241. * BEWARE: if the Group is a RenderableGroup and its content is cache the texture will be resized each time the group is getting bigger. For performance reason the opposite won't be true: the texture won't shrink if the group does.
  3242. */
  3243. size: Size;
  3244. viewportSize: ISize;
  3245. actualSize: Size;
  3246. /**
  3247. * Get/set the Cache Behavior, used in case the Canvas Cache Strategy is set to CACHESTRATEGY_ALLGROUPS. Can be either GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP, GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE or GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY. See their documentation for more information.
  3248. * It is critical to understand than you HAVE TO play with this behavior in order to achieve a good performance/memory ratio. Caching all groups would certainly be the worst strategy of all.
  3249. */
  3250. cacheBehavior: number;
  3251. _addPrimToDirtyList(prim: Prim2DBase): void;
  3252. _renderCachedCanvas(): void;
  3253. /**
  3254. * Get/set the Scene's Node that should be tracked, the group's position will follow the projected position of the Node.
  3255. */
  3256. trackedNode: Node;
  3257. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  3258. protected updateLevelBoundingInfo(): void;
  3259. protected _prepareGroupRender(context: PrepareRender2DContext): void;
  3260. protected _groupRender(): void;
  3261. private _updateTransparentData();
  3262. private _renderTransparentData();
  3263. private _prepareContext(engine, context, gii);
  3264. private _bindCacheTarget();
  3265. private _unbindCacheTarget();
  3266. protected handleGroupChanged(prop: Prim2DPropInfo): void;
  3267. private detectGroupStates();
  3268. private _trackedNode;
  3269. protected _isRenderableGroup: boolean;
  3270. protected _isCachedGroup: boolean;
  3271. private _cacheGroupDirty;
  3272. private _cacheBehavior;
  3273. private _viewportPosition;
  3274. private _viewportSize;
  3275. _renderableData: RenderableGroupData;
  3276. }
  3277. class RenderableGroupData {
  3278. constructor();
  3279. dispose(): void;
  3280. addNewTransparentPrimitiveInfo(prim: RenderablePrim2D, gii: GroupInstanceInfo): TransparentPrimitiveInfo;
  3281. removeTransparentPrimitiveInfo(tpi: TransparentPrimitiveInfo): void;
  3282. transparentPrimitiveZChanged(tpi: TransparentPrimitiveInfo): void;
  3283. updateSmallestZChangedPrim(tpi: TransparentPrimitiveInfo): void;
  3284. _primDirtyList: Array<Prim2DBase>;
  3285. _childrenRenderableGroups: Array<Group2D>;
  3286. _renderGroupInstancesInfo: StringDictionary<GroupInstanceInfo>;
  3287. _cacheNode: PackedRect;
  3288. _cacheTexture: MapTexture;
  3289. _cacheRenderSprite: Sprite2D;
  3290. _transparentListChanged: boolean;
  3291. _transparentPrimitives: Array<TransparentPrimitiveInfo>;
  3292. _transparentSegments: Array<TransparentSegment>;
  3293. _firstChangedPrim: TransparentPrimitiveInfo;
  3294. }
  3295. class TransparentPrimitiveInfo {
  3296. _primitive: RenderablePrim2D;
  3297. _groupInstanceInfo: GroupInstanceInfo;
  3298. _transparentSegment: TransparentSegment;
  3299. }
  3300. }
  3301. declare module BABYLON {
  3302. class Lines2DRenderCache extends ModelRenderCache {
  3303. effectsReady: boolean;
  3304. fillVB: WebGLBuffer;
  3305. fillIB: WebGLBuffer;
  3306. fillIndicesCount: number;
  3307. instancingFillAttributes: InstancingAttributeInfo[];
  3308. effectFill: Effect;
  3309. effectFillInstanced: Effect;
  3310. borderVB: WebGLBuffer;
  3311. borderIB: WebGLBuffer;
  3312. borderIndicesCount: number;
  3313. instancingBorderAttributes: InstancingAttributeInfo[];
  3314. effectBorder: Effect;
  3315. effectBorderInstanced: Effect;
  3316. constructor(engine: Engine, modelKey: string);
  3317. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  3318. dispose(): boolean;
  3319. }
  3320. class Lines2DInstanceData extends Shape2DInstanceData {
  3321. constructor(partId: number);
  3322. boundingMin: Vector2;
  3323. boundingMax: Vector2;
  3324. }
  3325. class Lines2D extends Shape2D {
  3326. /**
  3327. * No Cap to apply on the extremity
  3328. */
  3329. static NoCap: number;
  3330. /**
  3331. * A round cap, will use the line thickness as diameter
  3332. */
  3333. static RoundCap: number;
  3334. /**
  3335. * Creates a triangle at the extremity.
  3336. */
  3337. static TriangleCap: number;
  3338. /**
  3339. * Creates a Square anchor at the extremity, the square size is twice the thickness of the line
  3340. */
  3341. static SquareAnchorCap: number;
  3342. /**
  3343. * Creates a round anchor at the extremity, the diameter is twice the thickness of the line
  3344. */
  3345. static RoundAnchorCap: number;
  3346. /**
  3347. * Creates a diamond anchor at the extremity.
  3348. */
  3349. static DiamondAnchorCap: number;
  3350. /**
  3351. * Creates an arrow anchor at the extremity. the arrow base size is twice the thickness of the line
  3352. */
  3353. static ArrowCap: number;
  3354. static pointsProperty: Prim2DPropInfo;
  3355. static fillThicknessProperty: Prim2DPropInfo;
  3356. static closedProperty: Prim2DPropInfo;
  3357. static startCapProperty: Prim2DPropInfo;
  3358. static endCapProperty: Prim2DPropInfo;
  3359. points: Vector2[];
  3360. fillThickness: number;
  3361. closed: boolean;
  3362. startCap: number;
  3363. endCap: number;
  3364. private static _prevA;
  3365. private static _prevB;
  3366. private static _curA;
  3367. private static _curB;
  3368. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  3369. protected boundingMin: Vector2;
  3370. protected boundingMax: Vector2;
  3371. protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
  3372. protected updateLevelBoundingInfo(): void;
  3373. /**
  3374. * Create an 2D Lines Shape primitive. The defined lines may be opened or closed (see below)
  3375. * @param points an array that describe the points to use to draw the line, must contain at least two entries.
  3376. * @param settings a combination of settings, possible ones are
  3377. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  3378. * - children: an array of direct children
  3379. * - id a text identifier, for information purpose
  3380. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  3381. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  3382. * - scale: the initial scale of the primitive. default is 1
  3383. * - origin: define the normalized origin point location, default [0.5;0.5]
  3384. * - fillThickness: the thickness of the fill part of the line, can be null to draw nothing (but a border brush must be given), default is 1.
  3385. * - closed: if false the lines are said to be opened, the first point and the latest DON'T connect. if true the lines are said to be closed, the first and last point will be connected by a line. For instance you can define the 4 points of a rectangle, if you set closed to true a 4 edges rectangle will be drawn. If you set false, only three edges will be drawn, the edge formed by the first and last point won't exist. Default is false.
  3386. * - startCap: Draw a cap of the given type at the start of the first line, you can't define a Cap if the Lines2D is closed. Default is Lines2D.NoCap.
  3387. * - endCap: Draw a cap of the given type at the end of the last line, you can't define a Cap if the Lines2D is closed. Default is Lines2D.NoCap.
  3388. * - fill: the brush used to draw the fill content of the lines, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can be a string value (see Canvas2D.GetBrushFromString)
  3389. * - border: the brush used to draw the border of the lines, you can set null to draw nothing (but you will have to set a fill brush), default is null. can be a string value (see Canvas2D.GetBrushFromString)
  3390. * - borderThickness: the thickness of the drawn border, default is 1.
  3391. * - isVisible: true if the primitive must be visible, false for hidden. Default is true.
  3392. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3393. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3394. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3395. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3396. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  3397. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  3398. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  3399. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  3400. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3401. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3402. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3403. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3404. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  3405. */
  3406. constructor(points: Vector2[], settings?: {
  3407. parent?: Prim2DBase;
  3408. children?: Array<Prim2DBase>;
  3409. id?: string;
  3410. position?: Vector2;
  3411. x?: number;
  3412. y?: number;
  3413. rotation?: number;
  3414. scale?: number;
  3415. origin?: Vector2;
  3416. fillThickness?: number;
  3417. closed?: boolean;
  3418. startCap?: number;
  3419. endCap?: number;
  3420. fill?: IBrush2D | string;
  3421. border?: IBrush2D | string;
  3422. borderThickness?: number;
  3423. isVisible?: boolean;
  3424. marginTop?: number | string;
  3425. marginLeft?: number | string;
  3426. marginRight?: number | string;
  3427. marginBottom?: number | string;
  3428. margin?: number | string;
  3429. marginHAlignment?: number;
  3430. marginVAlignment?: number;
  3431. marginAlignment?: string;
  3432. paddingTop?: number | string;
  3433. paddingLeft?: number | string;
  3434. paddingRight?: number | string;
  3435. paddingBottom?: number | string;
  3436. padding?: string;
  3437. });
  3438. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  3439. private _perp(v, res);
  3440. private _direction(a, b, res);
  3441. private static _miterTps;
  3442. private _computeMiter(tangent, miter, a, b);
  3443. private _intersect(x1, y1, x2, y2, x3, y3, x4, y4);
  3444. private _updateMinMax(array, offset);
  3445. private static _startDir;
  3446. private static _endDir;
  3447. private _store(array, contour, index, max, p, n, halfThickness, borderThickness, detectFlip?);
  3448. private _getCapSize(type, border?);
  3449. private static _tpsV;
  3450. private _storeVertex(vb, baseOffset, index, basePos, rotation, vertex, contour);
  3451. private _storeIndex(ib, baseOffset, index, vertexIndex);
  3452. private _buildCap(vb, vbi, ib, ibi, pos, thickness, borderThickness, type, capDir, contour);
  3453. private _buildLine(vb, contour, ht, bt?);
  3454. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Lines2DRenderCache;
  3455. private _computeLines2D();
  3456. size: Size;
  3457. protected createInstanceDataParts(): InstanceDataBase[];
  3458. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  3459. private static _noCap;
  3460. private static _roundCap;
  3461. private static _triangleCap;
  3462. private static _squareAnchorCap;
  3463. private static _roundAnchorCap;
  3464. private static _diamondAnchorCap;
  3465. private static _arrowCap;
  3466. private static _roundCapSubDiv;
  3467. private _fillVB;
  3468. private _fillIB;
  3469. private _borderVB;
  3470. private _borderIB;
  3471. private _boundingMin;
  3472. private _boundingMax;
  3473. private _contour;
  3474. private _startCapContour;
  3475. private _startCapTriIndices;
  3476. private _endCapContour;
  3477. private _endCapTriIndices;
  3478. private _closed;
  3479. private _startCap;
  3480. private _endCap;
  3481. private _fillThickness;
  3482. private _points;
  3483. }
  3484. }
  3485. declare module BABYLON {
  3486. const enum ShaderDataType {
  3487. Vector2 = 0,
  3488. Vector3 = 1,
  3489. Vector4 = 2,
  3490. Matrix = 3,
  3491. float = 4,
  3492. Color3 = 5,
  3493. Color4 = 6,
  3494. Size = 7,
  3495. }
  3496. class GroupInstanceInfo {
  3497. constructor(owner: Group2D, mrc: ModelRenderCache, partCount: number);
  3498. dispose(): boolean;
  3499. private _isDisposed;
  3500. owner: Group2D;
  3501. modelRenderCache: ModelRenderCache;
  3502. partIndexFromId: StringDictionary<number>;
  3503. hasOpaqueData: boolean;
  3504. hasAlphaTestData: boolean;
  3505. hasTransparentData: boolean;
  3506. opaqueDirty: boolean;
  3507. opaqueData: GroupInfoPartData[];
  3508. alphaTestDirty: boolean;
  3509. alphaTestData: GroupInfoPartData[];
  3510. transparentOrderDirty: boolean;
  3511. transparentDirty: boolean;
  3512. transparentData: TransparentGroupInfoPartData[];
  3513. sortTransparentData(): void;
  3514. usedShaderCategories: string[];
  3515. strides: number[];
  3516. private _partCount;
  3517. private _strides;
  3518. private _usedShaderCategories;
  3519. private _opaqueData;
  3520. private _alphaTestData;
  3521. private _transparentData;
  3522. }
  3523. class TransparentSegment {
  3524. groupInsanceInfo: GroupInstanceInfo;
  3525. startZ: number;
  3526. endZ: number;
  3527. startDataIndex: number;
  3528. endDataIndex: number;
  3529. }
  3530. class GroupInfoPartData {
  3531. _partData: DynamicFloatArray;
  3532. _partBuffer: WebGLBuffer;
  3533. _partBufferSize: number;
  3534. constructor(stride: number);
  3535. dispose(engine: Engine): boolean;
  3536. private _isDisposed;
  3537. }
  3538. class TransparentGroupInfoPartData extends GroupInfoPartData {
  3539. constructor(stride: number, zoff: number);
  3540. }
  3541. class ModelRenderCache {
  3542. constructor(engine: Engine, modelKey: string);
  3543. dispose(): boolean;
  3544. isDisposed: boolean;
  3545. addRef(): number;
  3546. modelKey: string;
  3547. /**
  3548. * Render the model instances
  3549. * @param instanceInfo
  3550. * @param context
  3551. * @return must return true is the rendering succeed, false if the rendering couldn't be done (asset's not yet ready, like Effect)
  3552. */
  3553. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  3554. addInstanceDataParts(data: InstanceDataBase[]): string;
  3555. removeInstanceData(key: string): void;
  3556. protected getPartIndexFromId(partId: number): number;
  3557. protected loadInstancingAttributes(partId: number, effect: Effect): InstancingAttributeInfo[];
  3558. private static v2;
  3559. private static v3;
  3560. private static v4;
  3561. protected setupUniforms(effect: Effect, partIndex: number, data: DynamicFloatArray, elementCount: number): void;
  3562. protected _engine: Engine;
  3563. private _modelKey;
  3564. _instancesData: StringDictionary<InstanceDataBase[]>;
  3565. private _nextKey;
  3566. private _refCounter;
  3567. _partData: ModelRenderCachePartData[];
  3568. _partsClassInfo: ClassTreeInfo<InstanceClassInfo, InstancePropInfo>[];
  3569. }
  3570. class ModelRenderCachePartData {
  3571. _partId: number;
  3572. _zBiasOffset: number;
  3573. _partDataStride: number;
  3574. _partUsedCategories: string[];
  3575. _partJoinedUsedCategories: string;
  3576. }
  3577. }
  3578. declare module BABYLON {
  3579. class PrepareRender2DContext {
  3580. constructor();
  3581. /**
  3582. * True if the primitive must be refreshed no matter what
  3583. * This mode is needed because sometimes the primitive doesn't change by itself, but external changes make a refresh of its InstanceData necessary
  3584. */
  3585. forceRefreshPrimitive: boolean;
  3586. }
  3587. class Render2DContext {
  3588. constructor(renderMode: number);
  3589. /**
  3590. * Define which render Mode should be used to render the primitive: one of Render2DContext.RenderModeXxxx property
  3591. */
  3592. renderMode: number;
  3593. /**
  3594. * If true hardware instancing is supported and must be used for the rendering. The groupInfoPartData._partBuffer must be used.
  3595. * If false rendering on a per primitive basis must be made. The following properties must be used
  3596. * - groupInfoPartData._partData: contains the primitive instances data to render
  3597. * - partDataStartIndex: the index into instanceArrayData of the first instance to render.
  3598. * - partDataCount: the number of primitive to render
  3599. */
  3600. useInstancing: boolean;
  3601. /**
  3602. * Contains the data related to the primitives instances to render
  3603. */
  3604. groupInfoPartData: GroupInfoPartData[];
  3605. /**
  3606. * The index into groupInfoPartData._partData of the first primitive to render. This is an index, not an offset: it represent the nth primitive which is the first to render.
  3607. */
  3608. partDataStartIndex: number;
  3609. /**
  3610. * The exclusive end index, you have to render the primitive instances until you reach this one, but don't render this one!
  3611. */
  3612. partDataEndIndex: number;
  3613. /**
  3614. * The set of primitives to render is opaque.
  3615. * This is the first rendering pass. All Opaque primitives are rendered. Depth Compare and Write are both enabled.
  3616. */
  3617. static RenderModeOpaque: number;
  3618. /**
  3619. * The set of primitives to render is using Alpha Test (aka masking).
  3620. * Alpha Blend is enabled, the AlphaMode must be manually set, the render occurs after the RenderModeOpaque and is depth independent (i.e. primitives are not sorted by depth). Depth Compare and Write are both enabled.
  3621. */
  3622. static RenderModeAlphaTest: number;
  3623. /**
  3624. * The set of primitives to render is transparent.
  3625. * Alpha Blend is enabled, the AlphaMode must be manually set, the render occurs after the RenderModeAlphaTest and is depth dependent (i.e. primitives are stored by depth and rendered back to front). Depth Compare is on, but Depth write is Off.
  3626. */
  3627. static RenderModeTransparent: number;
  3628. private static _renderModeOpaque;
  3629. private static _renderModeAlphaTest;
  3630. private static _renderModeTransparent;
  3631. private _renderMode;
  3632. }
  3633. /**
  3634. * This class store information for the pointerEventObservable Observable.
  3635. * The Observable is divided into many sub events (using the Mask feature of the Observable pattern): PointerOver, PointerEnter, PointerDown, PointerMouseWheel, PointerMove, PointerUp, PointerDown, PointerLeave, PointerGotCapture and PointerLostCapture.
  3636. */
  3637. class PrimitivePointerInfo {
  3638. private static _pointerOver;
  3639. private static _pointerEnter;
  3640. private static _pointerDown;
  3641. private static _pointerMouseWheel;
  3642. private static _pointerMove;
  3643. private static _pointerUp;
  3644. private static _pointerOut;
  3645. private static _pointerLeave;
  3646. private static _pointerGotCapture;
  3647. private static _pointerLostCapture;
  3648. private static _mouseWheelPrecision;
  3649. /**
  3650. * This event type is raised when a pointing device is moved into the hit test boundaries of a primitive.
  3651. * Bubbles: yes
  3652. */
  3653. static PointerOver: number;
  3654. /**
  3655. * This event type is raised when a pointing device is moved into the hit test boundaries of a primitive or one of its descendants.
  3656. * Bubbles: no
  3657. */
  3658. static PointerEnter: number;
  3659. /**
  3660. * This event type is raised when a pointer enters the active button state (non-zero value in the buttons property). For mouse it's when the device transitions from no buttons depressed to at least one button depressed. For touch/pen this is when a physical contact is made.
  3661. * Bubbles: yes
  3662. */
  3663. static PointerDown: number;
  3664. /**
  3665. * This event type is raised when the pointer is a mouse and it's wheel is rolling
  3666. * Bubbles: yes
  3667. */
  3668. static PointerMouseWheel: number;
  3669. /**
  3670. * This event type is raised when a pointer change coordinates or when a pointer changes button state, pressure, tilt, or contact geometry and the circumstances produce no other pointers events.
  3671. * Bubbles: yes
  3672. */
  3673. static PointerMove: number;
  3674. /**
  3675. * This event type is raised when the pointer leaves the active buttons states (zero value in the buttons property). For mouse, this is when the device transitions from at least one button depressed to no buttons depressed. For touch/pen, this is when physical contact is removed.
  3676. * Bubbles: yes
  3677. */
  3678. static PointerUp: number;
  3679. /**
  3680. * This event type is raised when a pointing device is moved out of the hit test the boundaries of a primitive.
  3681. * Bubbles: yes
  3682. */
  3683. static PointerOut: number;
  3684. /**
  3685. * This event type is raised when a pointing device is moved out of the hit test boundaries of a primitive and all its descendants.
  3686. * Bubbles: no
  3687. */
  3688. static PointerLeave: number;
  3689. /**
  3690. * This event type is raised when a primitive receives the pointer capture. This event is fired at the element that is receiving pointer capture. Subsequent events for that pointer will be fired at this element.
  3691. * Bubbles: yes
  3692. */
  3693. static PointerGotCapture: number;
  3694. /**
  3695. * This event type is raised after pointer capture is released for a pointer.
  3696. * Bubbles: yes
  3697. */
  3698. static PointerLostCapture: number;
  3699. static MouseWheelPrecision: number;
  3700. /**
  3701. * Event Type, one of the static PointerXXXX property defined above (PrimitivePointerInfo.PointerOver to PrimitivePointerInfo.PointerLostCapture)
  3702. */
  3703. eventType: number;
  3704. /**
  3705. * Position of the pointer relative to the bottom/left of the Canvas
  3706. */
  3707. canvasPointerPos: Vector2;
  3708. /**
  3709. * Position of the pointer relative to the bottom/left of the primitive that registered the Observer
  3710. */
  3711. primitivePointerPos: Vector2;
  3712. /**
  3713. * The primitive where the event was initiated first (in case of bubbling)
  3714. */
  3715. relatedTarget: Prim2DBase;
  3716. /**
  3717. * Position of the pointer relative to the bottom/left of the relatedTarget
  3718. */
  3719. relatedTargetPointerPos: Vector2;
  3720. /**
  3721. * An observable can set this property to true to stop bubbling on the upper levels
  3722. */
  3723. cancelBubble: boolean;
  3724. /**
  3725. * True if the Control keyboard key is down
  3726. */
  3727. ctrlKey: boolean;
  3728. /**
  3729. * true if the Shift keyboard key is down
  3730. */
  3731. shiftKey: boolean;
  3732. /**
  3733. * true if the Alt keyboard key is down
  3734. */
  3735. altKey: boolean;
  3736. /**
  3737. * true if the Meta keyboard key is down
  3738. */
  3739. metaKey: boolean;
  3740. /**
  3741. * For button, buttons, refer to https://www.w3.org/TR/pointerevents/#button-states
  3742. */
  3743. button: number;
  3744. /**
  3745. * For button, buttons, refer to https://www.w3.org/TR/pointerevents/#button-states
  3746. */
  3747. buttons: number;
  3748. /**
  3749. * The amount of mouse wheel rolled
  3750. */
  3751. mouseWheelDelta: number;
  3752. /**
  3753. * Id of the Pointer involved in the event
  3754. */
  3755. pointerId: number;
  3756. width: number;
  3757. height: number;
  3758. presssure: number;
  3759. tilt: Vector2;
  3760. /**
  3761. * true if the involved pointer is captured for a particular primitive, false otherwise.
  3762. */
  3763. isCaptured: boolean;
  3764. constructor();
  3765. updateRelatedTarget(prim: Prim2DBase, primPointerPos: Vector2): void;
  3766. static getEventTypeName(mask: number): string;
  3767. }
  3768. /**
  3769. * Defines the horizontal and vertical alignment information for a Primitive.
  3770. */
  3771. class PrimitiveAlignment {
  3772. constructor(changeCallback: () => void);
  3773. /**
  3774. * Alignment is made relative to the left edge of the Primitive. Valid for horizontal alignment only.
  3775. */
  3776. static AlignLeft: number;
  3777. /**
  3778. * Alignment is made relative to the top edge of the Primitive. Valid for vertical alignment only.
  3779. */
  3780. static AlignTop: number;
  3781. /**
  3782. * Alignment is made relative to the right edge of the Primitive. Valid for horizontal alignment only.
  3783. */
  3784. static AlignRight: number;
  3785. /**
  3786. * Alignment is made relative to the bottom edge of the Primitive. Valid for vertical alignment only.
  3787. */
  3788. static AlignBottom: number;
  3789. /**
  3790. * Alignment is made to center the content from equal distance to the opposite edges of the Primitive
  3791. */
  3792. static AlignCenter: number;
  3793. /**
  3794. * The content is stretched toward the opposite edges of the Primitive
  3795. */
  3796. static AlignStretch: number;
  3797. private static _AlignLeft;
  3798. private static _AlignTop;
  3799. private static _AlignRight;
  3800. private static _AlignBottom;
  3801. private static _AlignCenter;
  3802. private static _AlignStretch;
  3803. /**
  3804. * Get/set the horizontal alignment. Use one of the AlignXXX static properties of this class
  3805. */
  3806. horizontal: number;
  3807. /**
  3808. * Get/set the vertical alignment. Use one of the AlignXXX static properties of this class
  3809. */
  3810. vertical: number;
  3811. private _changedCallback;
  3812. private _horizontal;
  3813. private _vertical;
  3814. /**
  3815. * Set the horizontal alignment from a string value.
  3816. * @param text can be either: 'left','right','center','stretch'
  3817. */
  3818. setHorizontal(text: string): void;
  3819. /**
  3820. * Set the vertical alignment from a string value.
  3821. * @param text can be either: 'top','bottom','center','stretch'
  3822. */
  3823. setVertical(text: string): void;
  3824. /**
  3825. * Set the horizontal and or vertical alignments from a string value.
  3826. * @param text can be: [<h:|horizontal:><left|right|center|stretch>], [<v:|vertical:><top|bottom|center|stretch>]
  3827. */
  3828. fromString(value: string): void;
  3829. }
  3830. /**
  3831. * Stores information about a Primitive that was intersected
  3832. */
  3833. class PrimitiveIntersectedInfo {
  3834. prim: Prim2DBase;
  3835. intersectionLocation: Vector2;
  3836. constructor(prim: Prim2DBase, intersectionLocation: Vector2);
  3837. }
  3838. /**
  3839. * Define a thickness toward every edges of a Primitive to allow margin and padding.
  3840. * The thickness can be expressed as pixels, percentages, inherit the value of the parent primitive or be auto.
  3841. */
  3842. class PrimitiveThickness {
  3843. constructor(parentAccess: () => PrimitiveThickness, changedCallback: () => void);
  3844. /**
  3845. * Set the thickness from a string value
  3846. * @param thickness format is "top: <value>, left:<value>, right:<value>, bottom:<value>" each are optional, auto will be set if it's omitted.
  3847. * Values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3848. */
  3849. fromString(thickness: string): void;
  3850. /**
  3851. * Set the thickness from multiple string
  3852. * Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3853. * @param top the top thickness to set
  3854. * @param left the left thickness to set
  3855. * @param right the right thickness to set
  3856. * @param bottom the bottom thickness to set
  3857. */
  3858. fromStrings(top: string, left: string, right: string, bottom: string): PrimitiveThickness;
  3859. /**
  3860. * Set the thickness from pixel values
  3861. * @param top the top thickness in pixels to set
  3862. * @param left the left thickness in pixels to set
  3863. * @param right the right thickness in pixels to set
  3864. * @param bottom the bottom thickness in pixels to set
  3865. */
  3866. fromPixels(top: number, left: number, right: number, bottom: number): PrimitiveThickness;
  3867. /**
  3868. * Apply the same pixel value to all edges
  3869. * @param margin the value to set, in pixels.
  3870. */
  3871. fromUniformPixels(margin: number): PrimitiveThickness;
  3872. /**
  3873. * Set all edges in auto
  3874. */
  3875. auto(): PrimitiveThickness;
  3876. private _clear();
  3877. private _extractString(value, emitChanged);
  3878. private _setStringValue(value, index, emitChanged);
  3879. private _setPixels(value, index, emitChanged);
  3880. private _setPercentage(value, index, emitChanged);
  3881. private _getStringValue(index);
  3882. private _isType(index, type);
  3883. private _getType(index, processInherit);
  3884. private _setType(index, type);
  3885. setTop(value: number | string): void;
  3886. setLeft(value: number | string): void;
  3887. setRight(value: number | string): void;
  3888. setBottom(value: number | string): void;
  3889. /**
  3890. * Get/set the top thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3891. */
  3892. top: string;
  3893. /**
  3894. * Get/set the left thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3895. */
  3896. left: string;
  3897. /**
  3898. * Get/set the right thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3899. */
  3900. right: string;
  3901. /**
  3902. * Get/set the bottom thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3903. */
  3904. bottom: string;
  3905. /**
  3906. * Get/set the top thickness in pixel.
  3907. */
  3908. topPixels: number;
  3909. /**
  3910. * Get/set the left thickness in pixel.
  3911. */
  3912. leftPixels: number;
  3913. /**
  3914. * Get/set the right thickness in pixel.
  3915. */
  3916. rightPixels: number;
  3917. /**
  3918. * Get/set the bottom thickness in pixel.
  3919. */
  3920. bottomPixels: number;
  3921. /**
  3922. * Get/set the top thickness in percentage.
  3923. * The get will return a valid value only if the edge type is percentage.
  3924. * The Set will change the edge mode if needed
  3925. */
  3926. topPercentage: number;
  3927. /**
  3928. * Get/set the left thickness in percentage.
  3929. * The get will return a valid value only if the edge mode is percentage.
  3930. * The Set will change the edge mode if needed
  3931. */
  3932. leftPercentage: number;
  3933. /**
  3934. * Get/set the right thickness in percentage.
  3935. * The get will return a valid value only if the edge mode is percentage.
  3936. * The Set will change the edge mode if needed
  3937. */
  3938. rightPercentage: number;
  3939. /**
  3940. * Get/set the bottom thickness in percentage.
  3941. * The get will return a valid value only if the edge mode is percentage.
  3942. * The Set will change the edge mode if needed
  3943. */
  3944. bottomPercentage: number;
  3945. /**
  3946. * Get/set the top mode. The setter shouldn't be used, other setters with value should be preferred
  3947. */
  3948. topMode: number;
  3949. /**
  3950. * Get/set the left mode. The setter shouldn't be used, other setters with value should be preferred
  3951. */
  3952. leftMode: number;
  3953. /**
  3954. * Get/set the right mode. The setter shouldn't be used, other setters with value should be preferred
  3955. */
  3956. rightMode: number;
  3957. /**
  3958. * Get/set the bottom mode. The setter shouldn't be used, other setters with value should be preferred
  3959. */
  3960. bottomMode: number;
  3961. private _parentAccess;
  3962. private _changedCallback;
  3963. private _pixels;
  3964. private _percentages;
  3965. private _flags;
  3966. static Auto: number;
  3967. static Inherit: number;
  3968. static Percentage: number;
  3969. static Pixel: number;
  3970. private _computePixels(index, sourceArea, emitChanged);
  3971. /**
  3972. * Compute the positioning/size of an area considering the thickness of this object and a given alignment
  3973. * @param sourceArea the source area
  3974. * @param contentSize the content size to position/resize
  3975. * @param alignment the alignment setting
  3976. * @param dstOffset the position of the content
  3977. * @param dstArea the new size of the content
  3978. */
  3979. computeWithAlignment(sourceArea: Size, contentSize: Size, alignment: PrimitiveAlignment, dstOffset: Vector2, dstArea: Size): void;
  3980. /**
  3981. * Compute an area and its position considering this thickness properties based on a given source area
  3982. * @param sourceArea the source area
  3983. * @param dstOffset the position of the resulting area
  3984. * @param dstArea the size of the resulting area
  3985. */
  3986. compute(sourceArea: Size, dstOffset: Vector2, dstArea: Size): void;
  3987. /**
  3988. * Compute an area considering this thickness properties based on a given source area
  3989. * @param sourceArea the source area
  3990. * @param result the resulting area
  3991. */
  3992. computeArea(sourceArea: Size, result: Size): void;
  3993. }
  3994. /**
  3995. * Main class used for the Primitive Intersection API
  3996. */
  3997. class IntersectInfo2D {
  3998. constructor();
  3999. /**
  4000. * Set the pick position, relative to the primitive where the intersection test is made
  4001. */
  4002. pickPosition: Vector2;
  4003. /**
  4004. * If true the intersection will stop at the first hit, if false all primitives will be tested and the intersectedPrimitives array will be filled accordingly (false default)
  4005. */
  4006. findFirstOnly: boolean;
  4007. /**
  4008. * If true the intersection test will also be made on hidden primitive (false default)
  4009. */
  4010. intersectHidden: boolean;
  4011. _globalPickPosition: Vector2;
  4012. _localPickPosition: Vector2;
  4013. /**
  4014. * The topmost intersected primitive
  4015. */
  4016. topMostIntersectedPrimitive: PrimitiveIntersectedInfo;
  4017. /**
  4018. * The array containing all intersected primitive, in no particular order.
  4019. */
  4020. intersectedPrimitives: Array<PrimitiveIntersectedInfo>;
  4021. /**
  4022. * true if at least one primitive intersected during the test
  4023. */
  4024. isIntersected: boolean;
  4025. isPrimIntersected(prim: Prim2DBase): Vector2;
  4026. _exit(firstLevel: boolean): void;
  4027. }
  4028. class Prim2DBase extends SmartPropertyPrim {
  4029. static PRIM2DBASE_PROPCOUNT: number;
  4030. constructor(settings: {
  4031. parent?: Prim2DBase;
  4032. id?: string;
  4033. children?: Array<Prim2DBase>;
  4034. position?: Vector2;
  4035. x?: number;
  4036. y?: number;
  4037. rotation?: number;
  4038. scale?: number;
  4039. origin?: Vector2;
  4040. layoutEngine?: LayoutEngineBase | string;
  4041. isVisible?: boolean;
  4042. marginTop?: number | string;
  4043. marginLeft?: number | string;
  4044. marginRight?: number | string;
  4045. marginBottom?: number | string;
  4046. margin?: number | string;
  4047. marginHAlignment?: number;
  4048. marginVAlignment?: number;
  4049. marginAlignment?: string;
  4050. paddingTop?: number | string;
  4051. paddingLeft?: number | string;
  4052. paddingRight?: number | string;
  4053. paddingBottom?: number | string;
  4054. padding?: string;
  4055. });
  4056. actionManager: ActionManager;
  4057. /**
  4058. * From 'this' primitive, traverse up (from parent to parent) until the given predicate is true
  4059. * @param predicate the predicate to test on each parent
  4060. * @return the first primitive where the predicate was successful
  4061. */
  4062. traverseUp(predicate: (p: Prim2DBase) => boolean): Prim2DBase;
  4063. /**
  4064. * Retrieve the owner Canvas2D
  4065. */
  4066. owner: Canvas2D;
  4067. /**
  4068. * Get the parent primitive (can be the Canvas, only the Canvas has no parent)
  4069. */
  4070. parent: Prim2DBase;
  4071. /**
  4072. * The array of direct children primitives
  4073. */
  4074. children: Prim2DBase[];
  4075. /**
  4076. * The identifier of this primitive, may not be unique, it's for information purpose only
  4077. */
  4078. id: string;
  4079. /**
  4080. * Metadata of the position property
  4081. */
  4082. static positionProperty: Prim2DPropInfo;
  4083. /**
  4084. * Metadata of the actualPosition property
  4085. */
  4086. static actualPositionProperty: Prim2DPropInfo;
  4087. /**
  4088. * Metadata of the size property
  4089. */
  4090. static sizeProperty: Prim2DPropInfo;
  4091. /**
  4092. * Metadata of the rotation property
  4093. */
  4094. static rotationProperty: Prim2DPropInfo;
  4095. /**
  4096. * Metadata of the scale property
  4097. */
  4098. static scaleProperty: Prim2DPropInfo;
  4099. /**
  4100. * Metadata of the origin property
  4101. */
  4102. static originProperty: Prim2DPropInfo;
  4103. /**
  4104. * Metadata of the levelVisible property
  4105. */
  4106. static levelVisibleProperty: Prim2DPropInfo;
  4107. /**
  4108. * Metadata of the isVisible property
  4109. */
  4110. static isVisibleProperty: Prim2DPropInfo;
  4111. /**
  4112. * Metadata of the zOrder property
  4113. */
  4114. static zOrderProperty: Prim2DPropInfo;
  4115. /**
  4116. * Metadata of the margin property
  4117. */
  4118. static marginProperty: Prim2DPropInfo;
  4119. /**
  4120. * Metadata of the margin property
  4121. */
  4122. static paddingProperty: Prim2DPropInfo;
  4123. /**
  4124. * Metadata of the hAlignment property
  4125. */
  4126. static marginAlignmentProperty: Prim2DPropInfo;
  4127. /**
  4128. * DO NOT INVOKE for internal purpose only
  4129. */
  4130. actualPosition: Vector2;
  4131. private static _nullPosition;
  4132. /**
  4133. * Shortcut to actualPosition.x
  4134. */
  4135. actualX: number;
  4136. /**
  4137. * Shortcut to actualPosition.y
  4138. */
  4139. actualY: number;
  4140. /**
  4141. * Position of the primitive, relative to its parent.
  4142. * BEWARE: if you change only position.x or y it won't trigger a property change and you won't have the expected behavior.
  4143. * Use this property to set a new Vector2 object, otherwise to change only the x/y use Prim2DBase.x or y properties.
  4144. * Setting this property may have no effect is specific alignment are in effect.
  4145. */
  4146. position: Vector2;
  4147. /**
  4148. * Direct access to the position.x value of the primitive
  4149. * Use this property when you only want to change one component of the position property
  4150. */
  4151. x: number;
  4152. /**
  4153. * Direct access to the position.y value of the primitive
  4154. * Use this property when you only want to change one component of the position property
  4155. */
  4156. y: number;
  4157. private static boundinbBoxReentrency;
  4158. protected static nullSize: Size;
  4159. /**
  4160. * Size of the primitive or its bounding area
  4161. * BEWARE: if you change only size.width or height it won't trigger a property change and you won't have the expected behavior.
  4162. * Use this property to set a new Size object, otherwise to change only the width/height use Prim2DBase.width or height properties.
  4163. */
  4164. size: Size;
  4165. /**
  4166. * Direct access to the size.width value of the primitive
  4167. * Use this property when you only want to change one component of the size property
  4168. */
  4169. width: number;
  4170. /**
  4171. * Direct access to the size.height value of the primitive
  4172. * Use this property when you only want to change one component of the size property
  4173. */
  4174. height: number;
  4175. rotation: number;
  4176. scale: number;
  4177. /**
  4178. * Return the size of the primitive as it's being rendered into the target.
  4179. * This value may be different of the size property when layout/alignment is used or specific primitive types can implement a custom logic through this property.
  4180. * BEWARE: don't use the setter, it's for internal purpose only
  4181. * Note to implementers: you have to override this property and declare if necessary a @xxxxInstanceLevel decorator
  4182. */
  4183. actualSize: Size;
  4184. actualZOffset: number;
  4185. /**
  4186. * Get or set the minimal size the Layout Engine should respect when computing the primitive's actualSize.
  4187. * The Primitive's size won't be less than specified.
  4188. * The default value depends of the Primitive type
  4189. */
  4190. minSize: Size;
  4191. /**
  4192. * Get or set the maximal size the Layout Engine should respect when computing the primitive's actualSize.
  4193. * The Primitive's size won't be more than specified.
  4194. * The default value depends of the Primitive type
  4195. */
  4196. maxSize: Size;
  4197. /**
  4198. * The origin defines the normalized coordinate of the center of the primitive, from the bottom/left corner.
  4199. * The origin is used only to compute transformation of the primitive, it has no meaning in the primitive local frame of reference
  4200. * For instance:
  4201. * 0,0 means the center is bottom/left. Which is the default for Canvas2D instances
  4202. * 0.5,0.5 means the center is at the center of the primitive, which is default of all types of Primitives
  4203. * 0,1 means the center is top/left
  4204. * @returns The normalized center.
  4205. */
  4206. origin: Vector2;
  4207. levelVisible: boolean;
  4208. isVisible: boolean;
  4209. zOrder: number;
  4210. margin: PrimitiveThickness;
  4211. private _hasMargin;
  4212. padding: PrimitiveThickness;
  4213. private _hasPadding;
  4214. marginAlignment: PrimitiveAlignment;
  4215. /**
  4216. * Get/set the layout engine to use for this primitive.
  4217. * The default layout engine is the CanvasLayoutEngine.
  4218. */
  4219. layoutEngine: LayoutEngineBase;
  4220. /**
  4221. * Get/set the layout are of this primitive.
  4222. * The Layout area is the zone allocated by the Layout Engine for this particular primitive. Margins/Alignment will be computed based on this area.
  4223. * The setter should only be called by a Layout Engine class.
  4224. */
  4225. layoutArea: Size;
  4226. /**
  4227. * Get/set the layout area position (relative to the parent primitive).
  4228. * The setter should only be called by a Layout Engine class.
  4229. */
  4230. layoutAreaPos: Vector2;
  4231. /**
  4232. * Define if the Primitive can be subject to intersection test or not (default is true)
  4233. */
  4234. isPickable: boolean;
  4235. /**
  4236. * Return the depth level of the Primitive into the Canvas' Graph. A Canvas will be 0, its direct children 1, and so on.
  4237. */
  4238. hierarchyDepth: number;
  4239. /**
  4240. * Retrieve the Group that is responsible to render this primitive
  4241. */
  4242. renderGroup: Group2D;
  4243. /**
  4244. * Get the global transformation matrix of the primitive
  4245. */
  4246. globalTransform: Matrix;
  4247. /**
  4248. * return the global position of the primitive, relative to its canvas
  4249. */
  4250. getGlobalPosition(): Vector2;
  4251. /**
  4252. * return the global position of the primitive, relative to its canvas
  4253. * @param v the valid Vector2 object where the global position will be stored
  4254. */
  4255. getGlobalPositionByRef(v: Vector2): void;
  4256. /**
  4257. * Get invert of the global transformation matrix of the primitive
  4258. */
  4259. invGlobalTransform: Matrix;
  4260. /**
  4261. * Get the local transformation of the primitive
  4262. */
  4263. localTransform: Matrix;
  4264. /**
  4265. * Get the boundingInfo associated to the primitive and its children.
  4266. * The value is supposed to be always up to date
  4267. */
  4268. boundingInfo: BoundingInfo2D;
  4269. /**
  4270. * Determine if the size is automatically computed or fixed because manually specified.
  4271. * Use the actualSize property to get the final/real size of the primitive
  4272. * @returns true if the size is automatically computed, false if it were manually specified.
  4273. */
  4274. isSizeAuto: boolean;
  4275. /**
  4276. * Determine if the position is automatically computed or fixed because manually specified.
  4277. * Use the actualPosition property to get the final/real position of the primitive
  4278. * @returns true if the position is automatically computed, false if it were manually specified.
  4279. */
  4280. isPositionAuto: boolean;
  4281. /**
  4282. * Interaction with the primitive can be create using this Observable. See the PrimitivePointerInfo class for more information
  4283. */
  4284. pointerEventObservable: Observable<PrimitivePointerInfo>;
  4285. findById(id: string): Prim2DBase;
  4286. protected onZOrderChanged(): void;
  4287. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  4288. /**
  4289. * Capture all the Events of the given PointerId for this primitive.
  4290. * Don't forget to call releasePointerEventsCapture when done.
  4291. * @param pointerId the Id of the pointer to capture the events from.
  4292. */
  4293. setPointerEventCapture(pointerId: number): boolean;
  4294. /**
  4295. * Release a captured pointer made with setPointerEventCapture.
  4296. * @param pointerId the Id of the pointer to release the capture from.
  4297. */
  4298. releasePointerEventsCapture(pointerId: number): boolean;
  4299. /**
  4300. * Make an intersection test with the primitive, all inputs/outputs are stored in the IntersectInfo2D class, see its documentation for more information.
  4301. * @param intersectInfo contains the settings of the intersection to perform, to setup before calling this method as well as the result, available after a call to this method.
  4302. */
  4303. intersect(intersectInfo: IntersectInfo2D): boolean;
  4304. moveChild(child: Prim2DBase, previous: Prim2DBase): boolean;
  4305. private addChild(child);
  4306. /**
  4307. * Dispose the primitive, remove it from its parent.
  4308. */
  4309. dispose(): boolean;
  4310. protected onPrimBecomesDirty(): void;
  4311. _needPrepare(): boolean;
  4312. _prepareRender(context: PrepareRender2DContext): void;
  4313. _prepareRenderPre(context: PrepareRender2DContext): void;
  4314. _prepareRenderPost(context: PrepareRender2DContext): void;
  4315. protected _canvasPreInit(settings: any): void;
  4316. protected static _isCanvasInit: boolean;
  4317. protected static CheckParent(parent: Prim2DBase): void;
  4318. protected updateCachedStatesOf(list: Prim2DBase[], recurse: boolean): void;
  4319. private _parentLayoutDirty();
  4320. protected _setLayoutDirty(): void;
  4321. private _checkPositionChange();
  4322. protected _positioningDirty(): void;
  4323. private _changeLayoutEngine(engine);
  4324. private static _t0;
  4325. private static _t1;
  4326. private static _t2;
  4327. private static _v0;
  4328. private _updateLocalTransform();
  4329. protected updateCachedStates(recurse: boolean): void;
  4330. private static _icPos;
  4331. private static _icArea;
  4332. private static _size;
  4333. private _updatePositioning();
  4334. /**
  4335. * Get the content are of this primitive, this area is computed using the padding property and also possibly the primitive type itself.
  4336. * Children of this primitive will be positioned relative to the bottom/left corner of this area.
  4337. */
  4338. contentArea: Size;
  4339. _patchHierarchy(owner: Canvas2D): void;
  4340. private _patchHierarchyDepth(child);
  4341. /**
  4342. * This method is used to alter the contentArea of the Primitive before margin is applied.
  4343. * In most of the case you won't need to override this method, but it can prove some usefulness, check the Rectangle2D class for a concrete application.
  4344. * @param primSize the current size of the primitive
  4345. * @param initialContentPosition the position of the initial content area to compute, a valid object is passed, you have to set its properties. PLEASE ROUND the values, we're talking about pixels and fraction of them is not a good thing!
  4346. * @param initialContentArea the size of the initial content area to compute, a valid object is passed, you have to set its properties. PLEASE ROUND the values, we're talking about pixels and fraction of them is not a good thing!
  4347. */
  4348. protected _getInitialContentAreaToRef(primSize: Size, initialContentPosition: Vector2, initialContentArea: Size): void;
  4349. private _owner;
  4350. private _parent;
  4351. private _actionManager;
  4352. protected _children: Array<Prim2DBase>;
  4353. private _renderGroup;
  4354. private _hierarchyDepth;
  4355. protected _hierarchyDepthOffset: number;
  4356. protected _siblingDepthOffset: number;
  4357. private _zOrder;
  4358. private _margin;
  4359. private _padding;
  4360. private _marginAlignment;
  4361. _pointerEventObservable: Observable<PrimitivePointerInfo>;
  4362. private _id;
  4363. private _position;
  4364. private _actualPosition;
  4365. protected _size: Size;
  4366. protected _actualSize: Size;
  4367. _boundingSize: Size;
  4368. protected _minSize: Size;
  4369. protected _maxSize: Size;
  4370. protected _desiredSize: Size;
  4371. private _layoutEngine;
  4372. private _marginOffset;
  4373. private _parentMargingOffset;
  4374. private _parentContentArea;
  4375. private _layoutAreaPos;
  4376. private _layoutArea;
  4377. private _contentArea;
  4378. private _rotation;
  4379. private _scale;
  4380. private _origin;
  4381. protected _parentTransformStep: number;
  4382. protected _globalTransformStep: number;
  4383. protected _globalTransformProcessStep: number;
  4384. protected _localTransform: Matrix;
  4385. protected _globalTransform: Matrix;
  4386. protected _invGlobalTransform: Matrix;
  4387. }
  4388. }
  4389. declare module BABYLON {
  4390. class Rectangle2DRenderCache extends ModelRenderCache {
  4391. effectsReady: boolean;
  4392. fillVB: WebGLBuffer;
  4393. fillIB: WebGLBuffer;
  4394. fillIndicesCount: number;
  4395. instancingFillAttributes: InstancingAttributeInfo[];
  4396. effectFill: Effect;
  4397. effectFillInstanced: Effect;
  4398. borderVB: WebGLBuffer;
  4399. borderIB: WebGLBuffer;
  4400. borderIndicesCount: number;
  4401. instancingBorderAttributes: InstancingAttributeInfo[];
  4402. effectBorder: Effect;
  4403. effectBorderInstanced: Effect;
  4404. constructor(engine: Engine, modelKey: string);
  4405. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  4406. dispose(): boolean;
  4407. }
  4408. class Rectangle2DInstanceData extends Shape2DInstanceData {
  4409. constructor(partId: number);
  4410. properties: Vector3;
  4411. }
  4412. class Rectangle2D extends Shape2D {
  4413. static actualSizeProperty: Prim2DPropInfo;
  4414. static notRoundedProperty: Prim2DPropInfo;
  4415. static roundRadiusProperty: Prim2DPropInfo;
  4416. actualSize: Size;
  4417. notRounded: boolean;
  4418. roundRadius: number;
  4419. private static _i0;
  4420. private static _i1;
  4421. private static _i2;
  4422. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  4423. protected updateLevelBoundingInfo(): void;
  4424. /**
  4425. * Create an Rectangle 2D Shape primitive. May be a sharp rectangle (with sharp corners), or a rounded one.
  4426. * @param settings a combination of settings, possible ones are
  4427. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  4428. * - children: an array of direct children
  4429. * - id a text identifier, for information purpose
  4430. * - position: the X & Y positions relative to its parent. Alternatively the x and y settings can be set. Default is [0;0]
  4431. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  4432. * - scale: the initial scale of the primitive. default is 1
  4433. * - origin: define the normalized origin point location, default [0.5;0.5]
  4434. * - size: the size of the group. Alternatively the width and height settings can be set. Default will be [10;10].
  4435. * - roundRadius: if the rectangle has rounded corner, set their radius, default is 0 (to get a sharp edges rectangle).
  4436. * - fill: the brush used to draw the fill content of the rectangle, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can also be a string value (see Canvas2D.GetBrushFromString)
  4437. * - border: the brush used to draw the border of the rectangle, you can set null to draw nothing (but you will have to set a fill brush), default is null. can also be a string value (see Canvas2D.GetBrushFromString)
  4438. * - borderThickness: the thickness of the drawn border, default is 1.
  4439. * - isVisible: true if the primitive must be visible, false for hidden. Default is true.
  4440. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4441. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4442. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4443. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4444. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  4445. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  4446. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  4447. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  4448. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4449. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4450. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4451. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4452. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  4453. */
  4454. constructor(settings?: {
  4455. parent?: Prim2DBase;
  4456. children?: Array<Prim2DBase>;
  4457. id?: string;
  4458. position?: Vector2;
  4459. x?: number;
  4460. y?: number;
  4461. rotation?: number;
  4462. scale?: number;
  4463. origin?: Vector2;
  4464. size?: Size;
  4465. width?: number;
  4466. height?: number;
  4467. roundRadius?: number;
  4468. fill?: IBrush2D | string;
  4469. border?: IBrush2D | string;
  4470. borderThickness?: number;
  4471. isVisible?: boolean;
  4472. marginTop?: number | string;
  4473. marginLeft?: number | string;
  4474. marginRight?: number | string;
  4475. marginBottom?: number | string;
  4476. margin?: number | string;
  4477. marginHAlignment?: number;
  4478. marginVAlignment?: number;
  4479. marginAlignment?: string;
  4480. paddingTop?: number | string;
  4481. paddingLeft?: number | string;
  4482. paddingRight?: number | string;
  4483. paddingBottom?: number | string;
  4484. padding?: string;
  4485. });
  4486. static roundSubdivisions: number;
  4487. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  4488. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Rectangle2DRenderCache;
  4489. protected _getInitialContentAreaToRef(primSize: Size, initialContentPosition: Vector2, initialContentArea: Size): void;
  4490. protected createInstanceDataParts(): InstanceDataBase[];
  4491. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4492. private _notRounded;
  4493. private _roundRadius;
  4494. }
  4495. }
  4496. declare module BABYLON {
  4497. class InstanceClassInfo {
  4498. constructor(base: InstanceClassInfo);
  4499. mapProperty(propInfo: InstancePropInfo, push: boolean): void;
  4500. getInstancingAttributeInfos(effect: Effect, categories: string[]): InstancingAttributeInfo[];
  4501. getShaderAttributes(categories: string[]): string[];
  4502. private _getBaseOffset(categories);
  4503. static _CurCategories: string;
  4504. private _baseInfo;
  4505. private _nextOffset;
  4506. private _attributes;
  4507. }
  4508. class InstancePropInfo {
  4509. attributeName: string;
  4510. category: string;
  4511. size: number;
  4512. shaderOffset: number;
  4513. instanceOffset: StringDictionary<number>;
  4514. dataType: ShaderDataType;
  4515. delimitedCategory: string;
  4516. constructor();
  4517. setSize(val: any): void;
  4518. writeData(array: Float32Array, offset: number, val: any): void;
  4519. }
  4520. function instanceData<T>(category?: string, shaderAttributeName?: string): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4521. class InstanceDataBase {
  4522. constructor(partId: number, dataElementCount: number);
  4523. id: number;
  4524. isVisible: boolean;
  4525. zBias: Vector2;
  4526. transformX: Vector4;
  4527. transformY: Vector4;
  4528. getClassTreeInfo(): ClassTreeInfo<InstanceClassInfo, InstancePropInfo>;
  4529. allocElements(): void;
  4530. freeElements(): void;
  4531. dataElementCount: number;
  4532. curElement: number;
  4533. dataElements: DynamicFloatArrayElementInfo[];
  4534. dataBuffer: DynamicFloatArray;
  4535. typeInfo: ClassTreeInfo<InstanceClassInfo, InstancePropInfo>;
  4536. private _dataElementCount;
  4537. }
  4538. abstract class RenderablePrim2D extends Prim2DBase {
  4539. static RENDERABLEPRIM2D_PROPCOUNT: number;
  4540. static isAlphaTestProperty: Prim2DPropInfo;
  4541. static isTransparentProperty: Prim2DPropInfo;
  4542. isAlphaTest: boolean;
  4543. isTransparent: boolean;
  4544. constructor(settings?: {
  4545. parent?: Prim2DBase;
  4546. id?: string;
  4547. origin?: Vector2;
  4548. isVisible?: boolean;
  4549. });
  4550. /**
  4551. * Dispose the primitive and its resources, remove it from its parent
  4552. */
  4553. dispose(): boolean;
  4554. _prepareRenderPre(context: PrepareRender2DContext): void;
  4555. private _createModelRenderCache();
  4556. private _createModelDataParts();
  4557. private _setupModelRenderCache(parts);
  4558. protected onZOrderChanged(): void;
  4559. private _updateInstanceDataParts(gii);
  4560. _getFirstIndexInDataBuffer(): number;
  4561. _getLastIndexInDataBuffer(): number;
  4562. _getNextPrimZOrder(): number;
  4563. _getPrevPrimZOrder(): number;
  4564. /**
  4565. * Transform a given point using the Primitive's origin setting.
  4566. * This method requires the Primitive's actualSize to be accurate
  4567. * @param p the point to transform
  4568. * @param originOffset an offset applied on the current origin before performing the transformation. Depending on which frame of reference your data is expressed you may have to apply a offset. (if you data is expressed from the bottom/left, no offset is required. If it's expressed from the center the a [-0.5;-0.5] offset has to be applied.
  4569. * @param res an allocated Vector2 that will receive the transformed content
  4570. */
  4571. protected transformPointWithOriginByRef(p: Vector2, originOffset: Vector2, res: Vector2): void;
  4572. protected transformPointWithOriginToRef(p: Vector2, originOffset: Vector2, res: Vector2): Vector2;
  4573. /**
  4574. * Get the info for a given effect based on the dataPart metadata
  4575. * @param dataPartId partId in part list to get the info
  4576. * @param vertexBufferAttributes vertex buffer attributes to manually add
  4577. * @param useInstanced specified if Instanced Array should be used, if null the engine caps will be used (so true if WebGL supports it, false otherwise), but you have the possibility to override the engine capability. However, if you manually set true but the engine does not support Instanced Array, this method will return null
  4578. */
  4579. protected getDataPartEffectInfo(dataPartId: number, vertexBufferAttributes: string[], useInstanced?: boolean): {
  4580. attributes: string[];
  4581. uniforms: string[];
  4582. defines: string;
  4583. };
  4584. protected modelRenderCache: ModelRenderCache;
  4585. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  4586. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): void;
  4587. protected createInstanceDataParts(): InstanceDataBase[];
  4588. protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
  4589. protected beforeRefreshForLayoutConstruction(part: InstanceDataBase): any;
  4590. protected afterRefreshForLayoutConstruction(part: InstanceDataBase, obj: any): void;
  4591. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4592. /**
  4593. * Update the instanceDataBase level properties of a part
  4594. * @param part the part to update
  4595. * @param positionOffset to use in multi part per primitive (e.g. the Text2D has N parts for N letter to display), this give the offset to apply (e.g. the position of the letter from the bottom/left corner of the text).
  4596. */
  4597. protected updateInstanceDataPart(part: InstanceDataBase, positionOffset?: Vector2): void;
  4598. private _modelRenderCache;
  4599. private _modelRenderInstanceID;
  4600. private _transparentPrimitiveInfo;
  4601. protected _instanceDataParts: InstanceDataBase[];
  4602. protected _isAlphaTest: boolean;
  4603. protected _isTransparent: boolean;
  4604. }
  4605. }
  4606. declare module BABYLON {
  4607. abstract class Shape2D extends RenderablePrim2D {
  4608. static SHAPE2D_BORDERPARTID: number;
  4609. static SHAPE2D_FILLPARTID: number;
  4610. static SHAPE2D_CATEGORY_BORDER: string;
  4611. static SHAPE2D_CATEGORY_BORDERSOLID: string;
  4612. static SHAPE2D_CATEGORY_BORDERGRADIENT: string;
  4613. static SHAPE2D_CATEGORY_FILLSOLID: string;
  4614. static SHAPE2D_CATEGORY_FILLGRADIENT: string;
  4615. static SHAPE2D_PROPCOUNT: number;
  4616. static borderProperty: Prim2DPropInfo;
  4617. static fillProperty: Prim2DPropInfo;
  4618. static borderThicknessProperty: Prim2DPropInfo;
  4619. border: IBrush2D;
  4620. /**
  4621. * Get/set the brush to render the Fill part of the Primitive
  4622. */
  4623. fill: IBrush2D;
  4624. borderThickness: number;
  4625. constructor(settings?: {
  4626. fill?: IBrush2D | string;
  4627. border?: IBrush2D | string;
  4628. borderThickness?: number;
  4629. });
  4630. protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
  4631. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4632. private _updateTransparencyStatus();
  4633. private _border;
  4634. private _borderThickness;
  4635. private _fill;
  4636. }
  4637. class Shape2DInstanceData extends InstanceDataBase {
  4638. fillSolidColor: Color4;
  4639. fillGradientColor1: Color4;
  4640. fillGradientColor2: Color4;
  4641. fillGradientTY: Vector4;
  4642. borderThickness: number;
  4643. borderSolidColor: Color4;
  4644. borderGradientColor1: Color4;
  4645. borderGradientColor2: Color4;
  4646. borderGradientTY: Vector4;
  4647. }
  4648. }
  4649. declare module BABYLON {
  4650. class Prim2DClassInfo {
  4651. }
  4652. class Prim2DPropInfo {
  4653. static PROPKIND_MODEL: number;
  4654. static PROPKIND_INSTANCE: number;
  4655. static PROPKIND_DYNAMIC: number;
  4656. id: number;
  4657. flagId: number;
  4658. kind: number;
  4659. name: string;
  4660. dirtyBoundingInfo: boolean;
  4661. typeLevelCompare: boolean;
  4662. }
  4663. /**
  4664. * Custom type of the propertyChanged observable
  4665. */
  4666. class PropertyChangedInfo {
  4667. /**
  4668. * Previous value of the property
  4669. */
  4670. oldValue: any;
  4671. /**
  4672. * New value of the property
  4673. */
  4674. newValue: any;
  4675. /**
  4676. * Name of the property that changed its value
  4677. */
  4678. propertyName: string;
  4679. }
  4680. /**
  4681. * Property Changed interface
  4682. */
  4683. interface IPropertyChanged {
  4684. /**
  4685. * PropertyChanged observable
  4686. */
  4687. propertyChanged: Observable<PropertyChangedInfo>;
  4688. }
  4689. class ClassTreeInfo<TClass, TProp> {
  4690. constructor(baseClass: ClassTreeInfo<TClass, TProp>, type: Object, classContentFactory: (base: TClass) => TClass);
  4691. classContent: TClass;
  4692. type: Object;
  4693. levelContent: StringDictionary<TProp>;
  4694. fullContent: StringDictionary<TProp>;
  4695. getLevelOf(type: Object): ClassTreeInfo<TClass, TProp>;
  4696. getOrAddType(baseType: Object, type: Object): ClassTreeInfo<TClass, TProp>;
  4697. static get<TClass, TProp>(type: Object): ClassTreeInfo<TClass, TProp>;
  4698. static getOrRegister<TClass, TProp>(type: Object, classContentFactory: (base: TClass) => TClass): ClassTreeInfo<TClass, TProp>;
  4699. private _type;
  4700. private _classContent;
  4701. private _baseClass;
  4702. private _subClasses;
  4703. private _levelContent;
  4704. private _fullContent;
  4705. private _classContentFactory;
  4706. }
  4707. abstract class SmartPropertyPrim implements IPropertyChanged {
  4708. constructor();
  4709. /**
  4710. * An observable that is triggered when a property (using of the XXXXLevelProperty decorator) has its value changing.
  4711. * You can add an observer that will be triggered only for a given set of Properties using the Mask feature of the Observable and the corresponding Prim2DPropInfo.flagid value (e.g. Prim2DBase.positionProperty.flagid|Prim2DBase.rotationProperty.flagid to be notified only about position or rotation change)
  4712. */
  4713. propertyChanged: Observable<PropertyChangedInfo>;
  4714. /**
  4715. * Check if the object is disposed or not.
  4716. * @returns true if the object is dispose, false otherwise.
  4717. */
  4718. isDisposed: boolean;
  4719. /**
  4720. * Disposable pattern, this method must be overloaded by derived types in order to clean up hardware related resources.
  4721. * @returns false if the object is already dispose, true otherwise. Your implementation must call super.dispose() and check for a false return and return immediately if it's the case.
  4722. */
  4723. dispose(): boolean;
  4724. /**
  4725. * Animation array, more info: http://doc.babylonjs.com/tutorials/Animations
  4726. */
  4727. animations: Animation[];
  4728. /**
  4729. * Returns as a new array populated with the Animatable used by the primitive. Must be overloaded by derived primitives.
  4730. * Look at Sprite2D for more information
  4731. */
  4732. getAnimatables(): IAnimatable[];
  4733. /**
  4734. * Property giving the Model Key associated to the property.
  4735. * This value is constructed from the type of the primitive and all the name/value of its properties declared with the modelLevelProperty decorator
  4736. * @returns the model key string.
  4737. */
  4738. modelKey: string;
  4739. /**
  4740. * States if the Primitive is dirty and should be rendered again next time.
  4741. * @returns true is dirty, false otherwise
  4742. */
  4743. isDirty: boolean;
  4744. /**
  4745. * Access the dictionary of properties metadata. Only properties decorated with XXXXLevelProperty are concerned
  4746. * @returns the dictionary, the key is the property name as declared in Javascript, the value is the metadata object
  4747. */
  4748. private propDic;
  4749. private static _createPropInfo(target, propName, propId, dirtyBoundingInfo, typeLevelCompare, kind);
  4750. private static _checkUnchanged(curValue, newValue);
  4751. private static propChangedInfo;
  4752. markAsDirty(propertyName: string): void;
  4753. protected _boundingBoxDirty(): void;
  4754. private _handlePropChanged<T>(curValue, newValue, propName, propInfo, typeLevelCompare);
  4755. protected onPrimitivePropertyDirty(propFlagId: number): void;
  4756. protected handleGroupChanged(prop: Prim2DPropInfo): void;
  4757. /**
  4758. * Check if a given set of properties are dirty or not.
  4759. * @param flags a ORed combination of Prim2DPropInfo.flagId values
  4760. * @return true if at least one property is dirty, false if none of them are.
  4761. */
  4762. checkPropertiesDirty(flags: number): boolean;
  4763. /**
  4764. * Clear a given set of properties.
  4765. * @param flags a ORed combination of Prim2DPropInfo.flagId values
  4766. * @return the new set of property still marked as dirty
  4767. */
  4768. protected clearPropertiesDirty(flags: number): number;
  4769. _resetPropertiesDirty(): void;
  4770. /**
  4771. * Retrieve the boundingInfo for this Primitive, computed based on the primitive itself and NOT its children
  4772. */
  4773. levelBoundingInfo: BoundingInfo2D;
  4774. /**
  4775. * This method must be overridden by a given Primitive implementation to compute its boundingInfo
  4776. */
  4777. protected updateLevelBoundingInfo(): void;
  4778. /**
  4779. * Property method called when the Primitive becomes dirty
  4780. */
  4781. protected onPrimBecomesDirty(): void;
  4782. static _hookProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare: boolean, dirtyBoundingInfo: boolean, kind: number): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4783. /**
  4784. * Add an externally attached data from its key.
  4785. * This method call will fail and return false, if such key already exists.
  4786. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4787. * @param key the unique key that identifies the data
  4788. * @param data the data object to associate to the key for this Engine instance
  4789. * @return true if no such key were already present and the data was added successfully, false otherwise
  4790. */
  4791. addExternalData<T>(key: string, data: T): boolean;
  4792. /**
  4793. * Get an externally attached data from its key
  4794. * @param key the unique key that identifies the data
  4795. * @return the associated data, if present (can be null), or undefined if not present
  4796. */
  4797. getExternalData<T>(key: string): T;
  4798. /**
  4799. * Get an externally attached data from its key, create it using a factory if it's not already present
  4800. * @param key the unique key that identifies the data
  4801. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  4802. * @return the associated data, can be null if the factory returned null.
  4803. */
  4804. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  4805. /**
  4806. * Remove an externally attached data from the Engine instance
  4807. * @param key the unique key that identifies the data
  4808. * @return true if the data was successfully removed, false if it doesn't exist
  4809. */
  4810. removeExternalData(key: any): boolean;
  4811. /**
  4812. * Check if a given flag is set
  4813. * @param flag the flag value
  4814. * @return true if set, false otherwise
  4815. */
  4816. _isFlagSet(flag: number): boolean;
  4817. /**
  4818. * Check if all given flags are set
  4819. * @param flags the flags ORed
  4820. * @return true if all the flags are set, false otherwise
  4821. */
  4822. _areAllFlagsSet(flags: number): boolean;
  4823. /**
  4824. * Check if at least one flag of the given flags is set
  4825. * @param flags the flags ORed
  4826. * @return true if at least one flag is set, false otherwise
  4827. */
  4828. _areSomeFlagsSet(flags: number): boolean;
  4829. /**
  4830. * Clear the given flags
  4831. * @param flags the flags to clear
  4832. */
  4833. _clearFlags(flags: number): void;
  4834. /**
  4835. * Set the given flags to true state
  4836. * @param flags the flags ORed to set
  4837. * @return the flags state before this call
  4838. */
  4839. _setFlags(flags: number): number;
  4840. /**
  4841. * Change the state of the given flags
  4842. * @param flags the flags ORed to change
  4843. * @param state true to set them, false to clear them
  4844. */
  4845. _changeFlags(flags: number, state: boolean): void;
  4846. static flagIsDisposed: number;
  4847. static flagLevelBoundingInfoDirty: number;
  4848. static flagModelDirty: number;
  4849. static flagLayoutDirty: number;
  4850. static flagLevelVisible: number;
  4851. static flagBoundingInfoDirty: number;
  4852. static flagIsPickable: number;
  4853. static flagIsVisible: number;
  4854. static flagVisibilityChanged: number;
  4855. static flagPositioningDirty: number;
  4856. static flagTrackedGroup: number;
  4857. private _flags;
  4858. private _externalData;
  4859. private _modelKey;
  4860. private _propInfo;
  4861. protected _levelBoundingInfo: BoundingInfo2D;
  4862. protected _boundingInfo: BoundingInfo2D;
  4863. protected _instanceDirtyFlags: number;
  4864. }
  4865. function modelLevelProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare?: boolean, dirtyBoundingInfo?: boolean): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4866. function instanceLevelProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare?: boolean, dirtyBoundingInfo?: boolean): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4867. function dynamicLevelProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare?: boolean, dirtyBoundingInfo?: boolean): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4868. }
  4869. declare module BABYLON {
  4870. class Sprite2DRenderCache extends ModelRenderCache {
  4871. effectsReady: boolean;
  4872. vb: WebGLBuffer;
  4873. ib: WebGLBuffer;
  4874. instancingAttributes: InstancingAttributeInfo[];
  4875. texture: Texture;
  4876. effect: Effect;
  4877. effectInstanced: Effect;
  4878. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  4879. dispose(): boolean;
  4880. }
  4881. class Sprite2DInstanceData extends InstanceDataBase {
  4882. constructor(partId: number);
  4883. topLeftUV: Vector2;
  4884. sizeUV: Vector2;
  4885. textureSize: Vector2;
  4886. properties: Vector3;
  4887. }
  4888. class Sprite2D extends RenderablePrim2D {
  4889. static SPRITE2D_MAINPARTID: number;
  4890. static textureProperty: Prim2DPropInfo;
  4891. static actualSizeProperty: Prim2DPropInfo;
  4892. static spriteLocationProperty: Prim2DPropInfo;
  4893. static spriteFrameProperty: Prim2DPropInfo;
  4894. static invertYProperty: Prim2DPropInfo;
  4895. static alignToPixelProperty: Prim2DPropInfo;
  4896. texture: Texture;
  4897. actualSize: Size;
  4898. spriteLocation: Vector2;
  4899. spriteFrame: number;
  4900. invertY: boolean;
  4901. /**
  4902. * Get/set if the sprite rendering should be aligned to the target rendering device pixel or not
  4903. */
  4904. alignToPixel: boolean;
  4905. protected updateLevelBoundingInfo(): void;
  4906. /**
  4907. * Get the animatable array (see http://doc.babylonjs.com/tutorials/Animations)
  4908. */
  4909. getAnimatables(): IAnimatable[];
  4910. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  4911. /**
  4912. * Create an 2D Sprite primitive
  4913. * @param texture the texture that stores the sprite to render
  4914. * @param settings a combination of settings, possible ones are
  4915. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  4916. * - children: an array of direct children
  4917. * - id a text identifier, for information purpose
  4918. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  4919. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  4920. * - scale: the initial scale of the primitive. default is 1
  4921. * - origin: define the normalized origin point location, default [0.5;0.5]
  4922. * - spriteSize: the size of the sprite (in pixels), if null the size of the given texture will be used, default is null.
  4923. * - spriteLocation: the location (in pixels) in the texture of the top/left corner of the Sprite to display, default is null (0,0)
  4924. * - invertY: if true the texture Y will be inverted, default is false.
  4925. * - alignToPixel: if true the sprite's texels will be aligned to the rendering viewport pixels, ensuring the best rendering quality but slow animations won't be done as smooth as if you set false. If false a texel could lies between two pixels, being blended by the texture sampling mode you choose, the rendering result won't be as good, but very slow animation will be overall better looking. Default is true: content will be aligned.
  4926. * - isVisible: true if the sprite must be visible, false for hidden. Default is true.
  4927. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4928. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4929. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4930. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4931. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  4932. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  4933. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  4934. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  4935. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4936. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4937. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4938. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4939. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  4940. */
  4941. constructor(texture: Texture, settings?: {
  4942. parent?: Prim2DBase;
  4943. children?: Array<Prim2DBase>;
  4944. id?: string;
  4945. position?: Vector2;
  4946. x?: number;
  4947. y?: number;
  4948. rotation?: number;
  4949. scale?: number;
  4950. origin?: Vector2;
  4951. spriteSize?: Size;
  4952. spriteLocation?: Vector2;
  4953. invertY?: boolean;
  4954. alignToPixel?: boolean;
  4955. isVisible?: boolean;
  4956. marginTop?: number | string;
  4957. marginLeft?: number | string;
  4958. marginRight?: number | string;
  4959. marginBottom?: number | string;
  4960. margin?: number | string;
  4961. marginHAlignment?: number;
  4962. marginVAlignment?: number;
  4963. marginAlignment?: string;
  4964. paddingTop?: number | string;
  4965. paddingLeft?: number | string;
  4966. paddingRight?: number | string;
  4967. paddingBottom?: number | string;
  4968. padding?: string;
  4969. });
  4970. static _createCachedCanvasSprite(owner: Canvas2D, texture: MapTexture, size: Size, pos: Vector2): Sprite2D;
  4971. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  4972. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Sprite2DRenderCache;
  4973. protected createInstanceDataParts(): InstanceDataBase[];
  4974. private static _prop;
  4975. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4976. private _texture;
  4977. private _location;
  4978. private _spriteFrame;
  4979. private _invertY;
  4980. private _alignToPixel;
  4981. }
  4982. }
  4983. declare module BABYLON {
  4984. class Text2DRenderCache extends ModelRenderCache {
  4985. effectsReady: boolean;
  4986. vb: WebGLBuffer;
  4987. ib: WebGLBuffer;
  4988. instancingAttributes: InstancingAttributeInfo[];
  4989. fontTexture: FontTexture;
  4990. effect: Effect;
  4991. effectInstanced: Effect;
  4992. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  4993. dispose(): boolean;
  4994. }
  4995. class Text2DInstanceData extends InstanceDataBase {
  4996. constructor(partId: number, dataElementCount: number);
  4997. topLeftUV: Vector2;
  4998. sizeUV: Vector2;
  4999. textureSize: Vector2;
  5000. color: Color4;
  5001. }
  5002. class Text2D extends RenderablePrim2D {
  5003. static TEXT2D_MAINPARTID: number;
  5004. static fontProperty: Prim2DPropInfo;
  5005. static defaultFontColorProperty: Prim2DPropInfo;
  5006. static textProperty: Prim2DPropInfo;
  5007. static sizeProperty: Prim2DPropInfo;
  5008. fontName: string;
  5009. defaultFontColor: Color4;
  5010. text: string;
  5011. size: Size;
  5012. /**
  5013. * Get the actual size of the Text2D primitive
  5014. */
  5015. actualSize: Size;
  5016. /**
  5017. * Get the area that bounds the text associated to the primitive
  5018. */
  5019. textSize: Size;
  5020. protected fontTexture: FontTexture;
  5021. /**
  5022. * Dispose the primitive, remove it from its parent
  5023. */
  5024. dispose(): boolean;
  5025. protected updateLevelBoundingInfo(): void;
  5026. /**
  5027. * Create a Text primitive
  5028. * @param text the text to display
  5029. * @param settings a combination of settings, possible ones are
  5030. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  5031. * - children: an array of direct children
  5032. * - id a text identifier, for information purpose
  5033. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  5034. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  5035. * - scale: the initial scale of the primitive. default is 1
  5036. * - origin: define the normalized origin point location, default [0.5;0.5]
  5037. * - fontName: the name/size/style of the font to use, following the CSS notation. Default is "12pt Arial".
  5038. * - defaultColor: the color by default to apply on each letter of the text to display, default is plain white.
  5039. * - areaSize: the size of the area in which to display the text, default is auto-fit from text content.
  5040. * - tabulationSize: number of space character to insert when a tabulation is encountered, default is 4
  5041. * - isVisible: true if the text must be visible, false for hidden. Default is true.
  5042. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5043. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5044. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5045. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5046. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  5047. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  5048. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  5049. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  5050. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5051. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5052. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5053. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5054. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  5055. */
  5056. constructor(text: string, settings?: {
  5057. parent?: Prim2DBase;
  5058. children?: Array<Prim2DBase>;
  5059. id?: string;
  5060. position?: Vector2;
  5061. x?: number;
  5062. y?: number;
  5063. rotation?: number;
  5064. scale?: number;
  5065. origin?: Vector2;
  5066. fontName?: string;
  5067. defaultFontColor?: Color4;
  5068. size?: Size;
  5069. tabulationSize?: number;
  5070. isVisible?: boolean;
  5071. marginTop?: number | string;
  5072. marginLeft?: number | string;
  5073. marginRight?: number | string;
  5074. marginBottom?: number | string;
  5075. margin?: number | string;
  5076. marginHAlignment?: number;
  5077. marginVAlignment?: number;
  5078. marginAlignment?: string;
  5079. paddingTop?: number | string;
  5080. paddingLeft?: number | string;
  5081. paddingRight?: number | string;
  5082. paddingBottom?: number | string;
  5083. padding?: string;
  5084. });
  5085. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  5086. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  5087. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Text2DRenderCache;
  5088. protected createInstanceDataParts(): InstanceDataBase[];
  5089. protected beforeRefreshForLayoutConstruction(part: InstanceDataBase): any;
  5090. protected afterRefreshForLayoutConstruction(part: InstanceDataBase, obj: any): void;
  5091. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  5092. private _updateCharCount();
  5093. private _fontTexture;
  5094. private _tabulationSize;
  5095. private _charCount;
  5096. private _fontName;
  5097. private _defaultFontColor;
  5098. private _text;
  5099. private _textSize;
  5100. }
  5101. }
  5102. declare module BABYLON {
  5103. /**
  5104. * This is the class that is used to display a World Space Canvas into a 3D scene
  5105. */
  5106. class WorldSpaceCanvas2DNode extends Mesh {
  5107. constructor(name: string, scene: Scene, canvas: Canvas2D);
  5108. dispose(): void;
  5109. private _canvas;
  5110. }
  5111. }
  5112. declare module BABYLON {
  5113. class Collider {
  5114. radius: Vector3;
  5115. retry: number;
  5116. velocity: Vector3;
  5117. basePoint: Vector3;
  5118. epsilon: number;
  5119. collisionFound: boolean;
  5120. velocityWorldLength: number;
  5121. basePointWorld: Vector3;
  5122. velocityWorld: Vector3;
  5123. normalizedVelocity: Vector3;
  5124. initialVelocity: Vector3;
  5125. initialPosition: Vector3;
  5126. nearestDistance: number;
  5127. intersectionPoint: Vector3;
  5128. collidedMesh: AbstractMesh;
  5129. private _collisionPoint;
  5130. private _planeIntersectionPoint;
  5131. private _tempVector;
  5132. private _tempVector2;
  5133. private _tempVector3;
  5134. private _tempVector4;
  5135. private _edge;
  5136. private _baseToVertex;
  5137. private _destinationPoint;
  5138. private _slidePlaneNormal;
  5139. private _displacementVector;
  5140. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5141. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5142. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5143. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5144. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: number[] | Int32Array, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5145. _getResponse(pos: Vector3, vel: Vector3): void;
  5146. }
  5147. }
  5148. declare module BABYLON {
  5149. var CollisionWorker: string;
  5150. interface ICollisionCoordinator {
  5151. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  5152. init(scene: Scene): void;
  5153. destroy(): void;
  5154. onMeshAdded(mesh: AbstractMesh): any;
  5155. onMeshUpdated(mesh: AbstractMesh): any;
  5156. onMeshRemoved(mesh: AbstractMesh): any;
  5157. onGeometryAdded(geometry: Geometry): any;
  5158. onGeometryUpdated(geometry: Geometry): any;
  5159. onGeometryDeleted(geometry: Geometry): any;
  5160. }
  5161. interface SerializedMesh {
  5162. id: string;
  5163. name: string;
  5164. uniqueId: number;
  5165. geometryId: string;
  5166. sphereCenter: Array<number>;
  5167. sphereRadius: number;
  5168. boxMinimum: Array<number>;
  5169. boxMaximum: Array<number>;
  5170. worldMatrixFromCache: any;
  5171. subMeshes: Array<SerializedSubMesh>;
  5172. checkCollisions: boolean;
  5173. }
  5174. interface SerializedSubMesh {
  5175. position: number;
  5176. verticesStart: number;
  5177. verticesCount: number;
  5178. indexStart: number;
  5179. indexCount: number;
  5180. hasMaterial: boolean;
  5181. sphereCenter: Array<number>;
  5182. sphereRadius: number;
  5183. boxMinimum: Array<number>;
  5184. boxMaximum: Array<number>;
  5185. }
  5186. interface SerializedGeometry {
  5187. id: string;
  5188. positions: Float32Array;
  5189. indices: Int32Array;
  5190. normals: Float32Array;
  5191. }
  5192. interface BabylonMessage {
  5193. taskType: WorkerTaskType;
  5194. payload: InitPayload | CollidePayload | UpdatePayload;
  5195. }
  5196. interface SerializedColliderToWorker {
  5197. position: Array<number>;
  5198. velocity: Array<number>;
  5199. radius: Array<number>;
  5200. }
  5201. enum WorkerTaskType {
  5202. INIT = 0,
  5203. UPDATE = 1,
  5204. COLLIDE = 2,
  5205. }
  5206. interface WorkerReply {
  5207. error: WorkerReplyType;
  5208. taskType: WorkerTaskType;
  5209. payload?: any;
  5210. }
  5211. interface CollisionReplyPayload {
  5212. newPosition: Array<number>;
  5213. collisionId: number;
  5214. collidedMeshUniqueId: number;
  5215. }
  5216. interface InitPayload {
  5217. }
  5218. interface CollidePayload {
  5219. collisionId: number;
  5220. collider: SerializedColliderToWorker;
  5221. maximumRetry: number;
  5222. excludedMeshUniqueId?: number;
  5223. }
  5224. interface UpdatePayload {
  5225. updatedMeshes: {
  5226. [n: number]: SerializedMesh;
  5227. };
  5228. updatedGeometries: {
  5229. [s: string]: SerializedGeometry;
  5230. };
  5231. removedMeshes: Array<number>;
  5232. removedGeometries: Array<string>;
  5233. }
  5234. enum WorkerReplyType {
  5235. SUCCESS = 0,
  5236. UNKNOWN_ERROR = 1,
  5237. }
  5238. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5239. private _scene;
  5240. private _scaledPosition;
  5241. private _scaledVelocity;
  5242. private _collisionsCallbackArray;
  5243. private _init;
  5244. private _runningUpdated;
  5245. private _runningCollisionTask;
  5246. private _worker;
  5247. private _addUpdateMeshesList;
  5248. private _addUpdateGeometriesList;
  5249. private _toRemoveMeshesArray;
  5250. private _toRemoveGeometryArray;
  5251. constructor();
  5252. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5253. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5254. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  5255. init(scene: Scene): void;
  5256. destroy(): void;
  5257. onMeshAdded(mesh: AbstractMesh): void;
  5258. onMeshUpdated: (mesh: AbstractMesh) => void;
  5259. onMeshRemoved(mesh: AbstractMesh): void;
  5260. onGeometryAdded(geometry: Geometry): void;
  5261. onGeometryUpdated: (geometry: Geometry) => void;
  5262. onGeometryDeleted(geometry: Geometry): void;
  5263. private _afterRender;
  5264. private _onMessageFromWorker;
  5265. }
  5266. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5267. private _scene;
  5268. private _scaledPosition;
  5269. private _scaledVelocity;
  5270. private _finalPosition;
  5271. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  5272. init(scene: Scene): void;
  5273. destroy(): void;
  5274. onMeshAdded(mesh: AbstractMesh): void;
  5275. onMeshUpdated(mesh: AbstractMesh): void;
  5276. onMeshRemoved(mesh: AbstractMesh): void;
  5277. onGeometryAdded(geometry: Geometry): void;
  5278. onGeometryUpdated(geometry: Geometry): void;
  5279. onGeometryDeleted(geometry: Geometry): void;
  5280. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5281. }
  5282. }
  5283. declare module BABYLON {
  5284. var WorkerIncluded: boolean;
  5285. class CollisionCache {
  5286. private _meshes;
  5287. private _geometries;
  5288. getMeshes(): {
  5289. [n: number]: SerializedMesh;
  5290. };
  5291. getGeometries(): {
  5292. [s: number]: SerializedGeometry;
  5293. };
  5294. getMesh(id: any): SerializedMesh;
  5295. addMesh(mesh: SerializedMesh): void;
  5296. removeMesh(uniqueId: number): void;
  5297. getGeometry(id: string): SerializedGeometry;
  5298. addGeometry(geometry: SerializedGeometry): void;
  5299. removeGeometry(id: string): void;
  5300. }
  5301. class CollideWorker {
  5302. collider: Collider;
  5303. private _collisionCache;
  5304. private finalPosition;
  5305. private collisionsScalingMatrix;
  5306. private collisionTranformationMatrix;
  5307. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5308. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId?: number): void;
  5309. private checkCollision(mesh);
  5310. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5311. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5312. private checkSubmeshCollision(subMesh);
  5313. }
  5314. interface ICollisionDetector {
  5315. onInit(payload: InitPayload): void;
  5316. onUpdate(payload: UpdatePayload): void;
  5317. onCollision(payload: CollidePayload): void;
  5318. }
  5319. class CollisionDetectorTransferable implements ICollisionDetector {
  5320. private _collisionCache;
  5321. onInit(payload: InitPayload): void;
  5322. onUpdate(payload: UpdatePayload): void;
  5323. onCollision(payload: CollidePayload): void;
  5324. }
  5325. }
  5326. declare module BABYLON {
  5327. class IntersectionInfo {
  5328. bu: number;
  5329. bv: number;
  5330. distance: number;
  5331. faceId: number;
  5332. subMeshId: number;
  5333. constructor(bu: number, bv: number, distance: number);
  5334. }
  5335. class PickingInfo {
  5336. hit: boolean;
  5337. distance: number;
  5338. pickedPoint: Vector3;
  5339. pickedMesh: AbstractMesh;
  5340. bu: number;
  5341. bv: number;
  5342. faceId: number;
  5343. subMeshId: number;
  5344. pickedSprite: Sprite;
  5345. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Vector3;
  5346. getTextureCoordinates(): Vector2;
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. class BoundingBox {
  5351. minimum: Vector3;
  5352. maximum: Vector3;
  5353. vectors: Vector3[];
  5354. center: Vector3;
  5355. extendSize: Vector3;
  5356. directions: Vector3[];
  5357. vectorsWorld: Vector3[];
  5358. minimumWorld: Vector3;
  5359. maximumWorld: Vector3;
  5360. private _worldMatrix;
  5361. constructor(minimum: Vector3, maximum: Vector3);
  5362. getWorldMatrix(): Matrix;
  5363. setWorldMatrix(matrix: Matrix): BoundingBox;
  5364. _update(world: Matrix): void;
  5365. isInFrustum(frustumPlanes: Plane[]): boolean;
  5366. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5367. intersectsPoint(point: Vector3): boolean;
  5368. intersectsSphere(sphere: BoundingSphere): boolean;
  5369. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5370. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5371. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5372. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5373. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5374. }
  5375. }
  5376. declare module BABYLON {
  5377. class BoundingInfo {
  5378. minimum: Vector3;
  5379. maximum: Vector3;
  5380. boundingBox: BoundingBox;
  5381. boundingSphere: BoundingSphere;
  5382. private _isLocked;
  5383. constructor(minimum: Vector3, maximum: Vector3);
  5384. isLocked: boolean;
  5385. update(world: Matrix): void;
  5386. isInFrustum(frustumPlanes: Plane[]): boolean;
  5387. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5388. _checkCollision(collider: Collider): boolean;
  5389. intersectsPoint(point: Vector3): boolean;
  5390. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5391. }
  5392. }
  5393. declare module BABYLON {
  5394. class BoundingSphere {
  5395. minimum: Vector3;
  5396. maximum: Vector3;
  5397. center: Vector3;
  5398. radius: number;
  5399. centerWorld: Vector3;
  5400. radiusWorld: number;
  5401. private _tempRadiusVector;
  5402. constructor(minimum: Vector3, maximum: Vector3);
  5403. _update(world: Matrix): void;
  5404. isInFrustum(frustumPlanes: Plane[]): boolean;
  5405. intersectsPoint(point: Vector3): boolean;
  5406. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5407. }
  5408. }
  5409. declare module BABYLON {
  5410. class Ray {
  5411. origin: Vector3;
  5412. direction: Vector3;
  5413. length: number;
  5414. private _edge1;
  5415. private _edge2;
  5416. private _pvec;
  5417. private _tvec;
  5418. private _qvec;
  5419. constructor(origin: Vector3, direction: Vector3, length?: number);
  5420. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5421. intersectsBox(box: BoundingBox): boolean;
  5422. intersectsSphere(sphere: BoundingSphere): boolean;
  5423. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo;
  5424. intersectsPlane(plane: Plane): number;
  5425. private static smallnum;
  5426. private static rayl;
  5427. /**
  5428. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5429. * @param sega the first point of the segment to test the intersection against
  5430. * @param segb the second point of the segment to test the intersection against
  5431. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5432. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5433. */
  5434. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5435. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5436. /**
  5437. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  5438. * transformed to the given world matrix.
  5439. * @param origin The origin point
  5440. * @param end The end point
  5441. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5442. */
  5443. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5444. static Transform(ray: Ray, matrix: Matrix): Ray;
  5445. }
  5446. }
  5447. declare module BABYLON {
  5448. class Layer {
  5449. name: string;
  5450. texture: Texture;
  5451. isBackground: boolean;
  5452. color: Color4;
  5453. scale: Vector2;
  5454. offset: Vector2;
  5455. alphaBlendingMode: number;
  5456. alphaTest: boolean;
  5457. private _scene;
  5458. private _vertexBuffers;
  5459. private _indexBuffer;
  5460. private _effect;
  5461. private _alphaTestEffect;
  5462. /**
  5463. * An event triggered when the layer is disposed.
  5464. * @type {BABYLON.Observable}
  5465. */
  5466. onDisposeObservable: Observable<Layer>;
  5467. private _onDisposeObserver;
  5468. onDispose: () => void;
  5469. /**
  5470. * An event triggered before rendering the scene
  5471. * @type {BABYLON.Observable}
  5472. */
  5473. onBeforeRenderObservable: Observable<Layer>;
  5474. private _onBeforeRenderObserver;
  5475. onBeforeRender: () => void;
  5476. /**
  5477. * An event triggered after rendering the scene
  5478. * @type {BABYLON.Observable}
  5479. */
  5480. onAfterRenderObservable: Observable<Layer>;
  5481. private _onAfterRenderObserver;
  5482. onAfterRender: () => void;
  5483. constructor(name: string, imgUrl: string, scene: Scene, isBackground?: boolean, color?: Color4);
  5484. render(): void;
  5485. dispose(): void;
  5486. }
  5487. }
  5488. declare module BABYLON {
  5489. class LensFlare {
  5490. size: number;
  5491. position: number;
  5492. color: Color3;
  5493. texture: Texture;
  5494. private _system;
  5495. constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem);
  5496. dispose: () => void;
  5497. }
  5498. }
  5499. declare module BABYLON {
  5500. class LensFlareSystem {
  5501. name: string;
  5502. lensFlares: LensFlare[];
  5503. borderLimit: number;
  5504. meshesSelectionPredicate: (mesh: Mesh) => boolean;
  5505. layerMask: number;
  5506. id: string;
  5507. private _scene;
  5508. private _emitter;
  5509. private _vertexBuffers;
  5510. private _indexBuffer;
  5511. private _effect;
  5512. private _positionX;
  5513. private _positionY;
  5514. private _isEnabled;
  5515. constructor(name: string, emitter: any, scene: Scene);
  5516. isEnabled: boolean;
  5517. getScene(): Scene;
  5518. getEmitter(): any;
  5519. setEmitter(newEmitter: any): void;
  5520. getEmitterPosition(): Vector3;
  5521. computeEffectivePosition(globalViewport: Viewport): boolean;
  5522. _isVisible(): boolean;
  5523. render(): boolean;
  5524. dispose(): void;
  5525. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  5526. serialize(): any;
  5527. }
  5528. }
  5529. declare module BABYLON {
  5530. class DirectionalLight extends Light implements IShadowLight {
  5531. position: Vector3;
  5532. direction: Vector3;
  5533. private _transformedDirection;
  5534. transformedPosition: Vector3;
  5535. private _worldMatrix;
  5536. shadowOrthoScale: number;
  5537. autoUpdateExtends: boolean;
  5538. private _orthoLeft;
  5539. private _orthoRight;
  5540. private _orthoTop;
  5541. private _orthoBottom;
  5542. constructor(name: string, direction: Vector3, scene: Scene);
  5543. getAbsolutePosition(): Vector3;
  5544. setDirectionToTarget(target: Vector3): Vector3;
  5545. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5546. supportsVSM(): boolean;
  5547. needRefreshPerFrame(): boolean;
  5548. needCube(): boolean;
  5549. getShadowDirection(faceIndex?: number): Vector3;
  5550. computeTransformedPosition(): boolean;
  5551. transferToEffect(effect: Effect, directionUniformName: string): void;
  5552. _getWorldMatrix(): Matrix;
  5553. getTypeID(): number;
  5554. }
  5555. }
  5556. declare module BABYLON {
  5557. class HemisphericLight extends Light {
  5558. groundColor: Color3;
  5559. direction: Vector3;
  5560. private _worldMatrix;
  5561. constructor(name: string, direction: Vector3, scene: Scene);
  5562. setDirectionToTarget(target: Vector3): Vector3;
  5563. getShadowGenerator(): ShadowGenerator;
  5564. transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void;
  5565. _getWorldMatrix(): Matrix;
  5566. getTypeID(): number;
  5567. }
  5568. }
  5569. declare module BABYLON {
  5570. interface IShadowLight {
  5571. id: string;
  5572. position: Vector3;
  5573. transformedPosition: Vector3;
  5574. name: string;
  5575. computeTransformedPosition(): boolean;
  5576. getScene(): Scene;
  5577. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5578. supportsVSM(): boolean;
  5579. needRefreshPerFrame(): boolean;
  5580. needCube(): boolean;
  5581. getShadowDirection(faceIndex?: number): Vector3;
  5582. _shadowGenerator: ShadowGenerator;
  5583. }
  5584. class Light extends Node {
  5585. diffuse: Color3;
  5586. specular: Color3;
  5587. intensity: number;
  5588. range: number;
  5589. includeOnlyWithLayerMask: number;
  5590. includedOnlyMeshes: AbstractMesh[];
  5591. excludedMeshes: AbstractMesh[];
  5592. excludeWithLayerMask: number;
  5593. radius: number;
  5594. _shadowGenerator: ShadowGenerator;
  5595. private _parentedWorldMatrix;
  5596. _excludedMeshesIds: string[];
  5597. _includedOnlyMeshesIds: string[];
  5598. constructor(name: string, scene: Scene);
  5599. /**
  5600. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5601. */
  5602. toString(fullDetails?: boolean): string;
  5603. getShadowGenerator(): ShadowGenerator;
  5604. getAbsolutePosition(): Vector3;
  5605. transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void;
  5606. _getWorldMatrix(): Matrix;
  5607. canAffectMesh(mesh: AbstractMesh): boolean;
  5608. getWorldMatrix(): Matrix;
  5609. dispose(): void;
  5610. getTypeID(): number;
  5611. clone(name: string): Light;
  5612. serialize(): any;
  5613. static GetConstructorFromName(type: number, name: string, scene: Scene): () => Light;
  5614. static Parse(parsedLight: any, scene: Scene): Light;
  5615. }
  5616. }
  5617. declare module BABYLON {
  5618. class PointLight extends Light implements IShadowLight {
  5619. private _worldMatrix;
  5620. transformedPosition: Vector3;
  5621. position: Vector3;
  5622. constructor(name: string, position: Vector3, scene: Scene);
  5623. getAbsolutePosition(): Vector3;
  5624. computeTransformedPosition(): boolean;
  5625. transferToEffect(effect: Effect, positionUniformName: string): void;
  5626. needCube(): boolean;
  5627. supportsVSM(): boolean;
  5628. needRefreshPerFrame(): boolean;
  5629. getShadowDirection(faceIndex?: number): Vector3;
  5630. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5631. _getWorldMatrix(): Matrix;
  5632. getTypeID(): number;
  5633. }
  5634. }
  5635. declare module BABYLON {
  5636. class SpotLight extends Light implements IShadowLight {
  5637. position: Vector3;
  5638. direction: Vector3;
  5639. angle: number;
  5640. exponent: number;
  5641. transformedPosition: Vector3;
  5642. private _transformedDirection;
  5643. private _worldMatrix;
  5644. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  5645. getAbsolutePosition(): Vector3;
  5646. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5647. needCube(): boolean;
  5648. supportsVSM(): boolean;
  5649. needRefreshPerFrame(): boolean;
  5650. getShadowDirection(faceIndex?: number): Vector3;
  5651. setDirectionToTarget(target: Vector3): Vector3;
  5652. computeTransformedPosition(): boolean;
  5653. transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void;
  5654. _getWorldMatrix(): Matrix;
  5655. getTypeID(): number;
  5656. }
  5657. }
  5658. declare module BABYLON {
  5659. interface ISceneLoaderPlugin {
  5660. extensions: string;
  5661. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
  5662. load: (scene: Scene, data: string, rootUrl: string) => boolean;
  5663. }
  5664. interface ISceneLoaderPluginAsync {
  5665. extensions: string;
  5666. importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void;
  5667. loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean;
  5668. }
  5669. class SceneLoader {
  5670. private static _ForceFullSceneLoadingForIncremental;
  5671. private static _ShowLoadingScreen;
  5672. static NO_LOGGING: number;
  5673. static MINIMAL_LOGGING: number;
  5674. static SUMMARY_LOGGING: number;
  5675. static DETAILED_LOGGING: number;
  5676. private static _loggingLevel;
  5677. static ForceFullSceneLoadingForIncremental: boolean;
  5678. static ShowLoadingScreen: boolean;
  5679. static loggingLevel: number;
  5680. private static _registeredPlugins;
  5681. private static _getPluginForFilename(sceneFilename);
  5682. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  5683. static RegisterPlugin(plugin: ISceneLoaderPlugin): void;
  5684. static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void;
  5685. /**
  5686. * Load a scene
  5687. * @param rootUrl a string that defines the root url for scene and resources
  5688. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  5689. * @param engine is the instance of BABYLON.Engine to use to create the scene
  5690. */
  5691. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  5692. /**
  5693. * Append a scene
  5694. * @param rootUrl a string that defines the root url for scene and resources
  5695. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  5696. * @param scene is the instance of BABYLON.Scene to append to
  5697. */
  5698. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  5699. }
  5700. }
  5701. declare module BABYLON {
  5702. /**
  5703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  5704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  5705. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  5706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  5707. */
  5708. class ColorCurves {
  5709. private _dirty;
  5710. private _tempColor;
  5711. private _globalCurve;
  5712. private _highlightsCurve;
  5713. private _midtonesCurve;
  5714. private _shadowsCurve;
  5715. private _positiveCurve;
  5716. private _negativeCurve;
  5717. private _globalHue;
  5718. private _globalDensity;
  5719. private _globalSaturation;
  5720. private _globalExposure;
  5721. /**
  5722. * Gets the global Hue value.
  5723. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5724. */
  5725. /**
  5726. * Sets the global Hue value.
  5727. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5728. */
  5729. GlobalHue: number;
  5730. /**
  5731. * Gets the global Density value.
  5732. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5733. * Values less than zero provide a filter of opposite hue.
  5734. */
  5735. /**
  5736. * Sets the global Density value.
  5737. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5738. * Values less than zero provide a filter of opposite hue.
  5739. */
  5740. GlobalDensity: number;
  5741. /**
  5742. * Gets the global Saturation value.
  5743. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5744. */
  5745. /**
  5746. * Sets the global Saturation value.
  5747. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5748. */
  5749. GlobalSaturation: number;
  5750. private _highlightsHue;
  5751. private _highlightsDensity;
  5752. private _highlightsSaturation;
  5753. private _highlightsExposure;
  5754. /**
  5755. * Gets the highlights Hue value.
  5756. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5757. */
  5758. /**
  5759. * Sets the highlights Hue value.
  5760. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5761. */
  5762. HighlightsHue: number;
  5763. /**
  5764. * Gets the highlights Density value.
  5765. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5766. * Values less than zero provide a filter of opposite hue.
  5767. */
  5768. /**
  5769. * Sets the highlights Density value.
  5770. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5771. * Values less than zero provide a filter of opposite hue.
  5772. */
  5773. HighlightsDensity: number;
  5774. /**
  5775. * Gets the highlights Saturation value.
  5776. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5777. */
  5778. /**
  5779. * Sets the highlights Saturation value.
  5780. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5781. */
  5782. HighlightsSaturation: number;
  5783. /**
  5784. * Gets the highlights Exposure value.
  5785. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5786. */
  5787. /**
  5788. * Sets the highlights Exposure value.
  5789. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5790. */
  5791. HighlightsExposure: number;
  5792. private _midtonesHue;
  5793. private _midtonesDensity;
  5794. private _midtonesSaturation;
  5795. private _midtonesExposure;
  5796. /**
  5797. * Gets the midtones Hue value.
  5798. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5799. */
  5800. /**
  5801. * Sets the midtones Hue value.
  5802. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5803. */
  5804. MidtonesHue: number;
  5805. /**
  5806. * Gets the midtones Density value.
  5807. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5808. * Values less than zero provide a filter of opposite hue.
  5809. */
  5810. /**
  5811. * Sets the midtones Density value.
  5812. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5813. * Values less than zero provide a filter of opposite hue.
  5814. */
  5815. MidtonesDensity: number;
  5816. /**
  5817. * Gets the midtones Saturation value.
  5818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5819. */
  5820. /**
  5821. * Sets the midtones Saturation value.
  5822. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5823. */
  5824. MidtonesSaturation: number;
  5825. /**
  5826. * Gets the midtones Exposure value.
  5827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5828. */
  5829. /**
  5830. * Sets the midtones Exposure value.
  5831. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5832. */
  5833. MidtonesExposure: number;
  5834. private _shadowsHue;
  5835. private _shadowsDensity;
  5836. private _shadowsSaturation;
  5837. private _shadowsExposure;
  5838. /**
  5839. * Gets the shadows Hue value.
  5840. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5841. */
  5842. /**
  5843. * Sets the shadows Hue value.
  5844. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5845. */
  5846. ShadowsHue: number;
  5847. /**
  5848. * Gets the shadows Density value.
  5849. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5850. * Values less than zero provide a filter of opposite hue.
  5851. */
  5852. /**
  5853. * Sets the shadows Density value.
  5854. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5855. * Values less than zero provide a filter of opposite hue.
  5856. */
  5857. ShadowsDensity: number;
  5858. /**
  5859. * Gets the shadows Saturation value.
  5860. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5861. */
  5862. /**
  5863. * Sets the shadows Saturation value.
  5864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5865. */
  5866. ShadowsSaturation: number;
  5867. /**
  5868. * Gets the shadows Exposure value.
  5869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5870. */
  5871. /**
  5872. * Sets the shadows Exposure value.
  5873. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5874. */
  5875. ShadowsExposure: number;
  5876. /**
  5877. * Binds the color curves to the shader.
  5878. * @param colorCurves The color curve to bind
  5879. * @param effect The effect to bind to
  5880. */
  5881. static Bind(colorCurves: ColorCurves, effect: Effect): void;
  5882. /**
  5883. * Prepare the list of uniforms associated with the ColorCurves effects.
  5884. * @param uniformsList The list of uniforms used in the effect
  5885. */
  5886. static PrepareUniforms(uniformsList: string[]): void;
  5887. /**
  5888. * Returns color grading data based on a hue, density, saturation and exposure value.
  5889. * @param filterHue The hue of the color filter.
  5890. * @param filterDensity The density of the color filter.
  5891. * @param saturation The saturation.
  5892. * @param exposure The exposure.
  5893. * @param result The result data container.
  5894. */
  5895. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  5896. /**
  5897. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  5898. * @param value The input slider value in range [-100,100].
  5899. * @returns Adjusted value.
  5900. */
  5901. private static applyColorGradingSliderNonlinear(value);
  5902. /**
  5903. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  5904. * @param hue The hue (H) input.
  5905. * @param saturation The saturation (S) input.
  5906. * @param brightness The brightness (B) input.
  5907. * @result An RGBA color represented as Vector4.
  5908. */
  5909. private static fromHSBToRef(hue, saturation, brightness, result);
  5910. /**
  5911. * Returns a value clamped between min and max
  5912. * @param value The value to clamp
  5913. * @param min The minimum of value
  5914. * @param max The maximum of value
  5915. * @returns The clamped value.
  5916. */
  5917. private static clamp(value, min, max);
  5918. /**
  5919. * Clones the current color curve instance.
  5920. * @return The cloned curves
  5921. */
  5922. clone(): ColorCurves;
  5923. /**
  5924. * Serializes the current color curve instance to a json representation.
  5925. * @return a JSON representation
  5926. */
  5927. serialize(): any;
  5928. /**
  5929. * Parses the color curve from a json representation.
  5930. * @param source the JSON source to parse
  5931. * @return The parsed curves
  5932. */
  5933. static Parse(source: any): ColorCurves;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. class EffectFallbacks {
  5938. private _defines;
  5939. private _currentRank;
  5940. private _maxRank;
  5941. private _mesh;
  5942. private _meshRank;
  5943. addFallback(rank: number, define: string): void;
  5944. addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void;
  5945. isMoreFallbacks: boolean;
  5946. reduce(currentDefines: string): string;
  5947. }
  5948. class Effect {
  5949. name: any;
  5950. defines: string;
  5951. onCompiled: (effect: Effect) => void;
  5952. onError: (effect: Effect, errors: string) => void;
  5953. onBind: (effect: Effect) => void;
  5954. private _engine;
  5955. private _uniformsNames;
  5956. private _samplers;
  5957. private _isReady;
  5958. private _compilationError;
  5959. private _attributesNames;
  5960. private _attributes;
  5961. private _uniforms;
  5962. _key: string;
  5963. private _indexParameters;
  5964. private _program;
  5965. private _valueCache;
  5966. constructor(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], engine: any, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any);
  5967. isReady(): boolean;
  5968. getProgram(): WebGLProgram;
  5969. getAttributesNames(): string[];
  5970. getAttributeLocation(index: number): number;
  5971. getAttributeLocationByName(name: string): number;
  5972. getAttributesCount(): number;
  5973. getUniformIndex(uniformName: string): number;
  5974. getUniform(uniformName: string): WebGLUniformLocation;
  5975. getSamplers(): string[];
  5976. getCompilationError(): string;
  5977. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  5978. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  5979. private _dumpShadersName();
  5980. private _processIncludes(sourceCode, callback);
  5981. private _processPrecision(source);
  5982. private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
  5983. isSupported: boolean;
  5984. _bindTexture(channel: string, texture: WebGLTexture): void;
  5985. setTexture(channel: string, texture: BaseTexture): void;
  5986. setTextureFromPostProcess(channel: string, postProcess: PostProcess): void;
  5987. _cacheMatrix(uniformName: any, matrix: any): void;
  5988. _cacheFloat2(uniformName: string, x: number, y: number): void;
  5989. _cacheFloat3(uniformName: string, x: number, y: number, z: number): void;
  5990. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  5991. setArray(uniformName: string, array: number[]): Effect;
  5992. setArray2(uniformName: string, array: number[]): Effect;
  5993. setArray3(uniformName: string, array: number[]): Effect;
  5994. setArray4(uniformName: string, array: number[]): Effect;
  5995. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  5996. setMatrix(uniformName: string, matrix: Matrix): Effect;
  5997. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  5998. setMatrix2x2(uniformname: string, matrix: Float32Array): Effect;
  5999. setFloat(uniformName: string, value: number): Effect;
  6000. setBool(uniformName: string, bool: boolean): Effect;
  6001. setVector2(uniformName: string, vector2: Vector2): Effect;
  6002. setFloat2(uniformName: string, x: number, y: number): Effect;
  6003. setVector3(uniformName: string, vector3: Vector3): Effect;
  6004. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  6005. setVector4(uniformName: string, vector4: Vector4): Effect;
  6006. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  6007. setColor3(uniformName: string, color3: Color3): Effect;
  6008. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  6009. static ShadersStore: {};
  6010. static IncludesShadersStore: {};
  6011. }
  6012. }
  6013. declare module BABYLON {
  6014. class FresnelParameters {
  6015. isEnabled: boolean;
  6016. leftColor: Color3;
  6017. rightColor: Color3;
  6018. bias: number;
  6019. power: number;
  6020. clone(): FresnelParameters;
  6021. serialize(): any;
  6022. static Parse(parsedFresnelParameters: any): FresnelParameters;
  6023. }
  6024. }
  6025. declare module BABYLON {
  6026. class MaterialDefines {
  6027. _keys: string[];
  6028. rebuild(): void;
  6029. isEqual(other: MaterialDefines): boolean;
  6030. cloneTo(other: MaterialDefines): void;
  6031. reset(): void;
  6032. toString(): string;
  6033. }
  6034. class Material {
  6035. name: string;
  6036. private static _TriangleFillMode;
  6037. private static _WireFrameFillMode;
  6038. private static _PointFillMode;
  6039. static TriangleFillMode: number;
  6040. static WireFrameFillMode: number;
  6041. static PointFillMode: number;
  6042. private static _ClockWiseSideOrientation;
  6043. private static _CounterClockWiseSideOrientation;
  6044. static ClockWiseSideOrientation: number;
  6045. static CounterClockWiseSideOrientation: number;
  6046. id: string;
  6047. checkReadyOnEveryCall: boolean;
  6048. checkReadyOnlyOnce: boolean;
  6049. state: string;
  6050. alpha: number;
  6051. backFaceCulling: boolean;
  6052. sideOrientation: number;
  6053. onCompiled: (effect: Effect) => void;
  6054. onError: (effect: Effect, errors: string) => void;
  6055. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  6056. /**
  6057. * An event triggered when the material is disposed.
  6058. * @type {BABYLON.Observable}
  6059. */
  6060. onDisposeObservable: Observable<Material>;
  6061. private _onDisposeObserver;
  6062. onDispose: () => void;
  6063. /**
  6064. * An event triggered when the material is compiled.
  6065. * @type {BABYLON.Observable}
  6066. */
  6067. onBindObservable: Observable<AbstractMesh>;
  6068. private _onBindObserver;
  6069. onBind: (Mesh: AbstractMesh) => void;
  6070. alphaMode: number;
  6071. disableDepthWrite: boolean;
  6072. fogEnabled: boolean;
  6073. pointSize: number;
  6074. zOffset: number;
  6075. wireframe: boolean;
  6076. pointsCloud: boolean;
  6077. fillMode: number;
  6078. _effect: Effect;
  6079. _wasPreviouslyReady: boolean;
  6080. private _scene;
  6081. private _fillMode;
  6082. private _cachedDepthWriteState;
  6083. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  6084. /**
  6085. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6086. * subclasses should override adding information pertainent to themselves
  6087. */
  6088. toString(fullDetails?: boolean): string;
  6089. isFrozen: boolean;
  6090. freeze(): void;
  6091. unfreeze(): void;
  6092. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6093. getEffect(): Effect;
  6094. getScene(): Scene;
  6095. needAlphaBlending(): boolean;
  6096. needAlphaTesting(): boolean;
  6097. getAlphaTestTexture(): BaseTexture;
  6098. markDirty(): void;
  6099. _preBind(): void;
  6100. bind(world: Matrix, mesh?: Mesh): void;
  6101. bindOnlyWorldMatrix(world: Matrix): void;
  6102. unbind(): void;
  6103. clone(name: string): Material;
  6104. getBindedMeshes(): AbstractMesh[];
  6105. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6106. serialize(): any;
  6107. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  6108. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. class MaterialHelper {
  6113. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, maxSimultaneousLights?: number): boolean;
  6114. static PrepareUniformsAndSamplersList(uniformsList: string[], samplersList: string[], defines: MaterialDefines, maxSimultaneousLights?: number): void;
  6115. static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void;
  6116. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void;
  6117. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  6118. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: number, effect: Effect, depthValuesAlreadySet: boolean): boolean;
  6119. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  6120. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number): void;
  6121. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  6122. static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void;
  6123. static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void;
  6124. static BindClipPlane(effect: Effect, scene: Scene): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. class MultiMaterial extends Material {
  6129. subMaterials: Material[];
  6130. constructor(name: string, scene: Scene);
  6131. getSubMaterial(index: any): Material;
  6132. isReady(mesh?: AbstractMesh): boolean;
  6133. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  6134. serialize(): any;
  6135. }
  6136. }
  6137. declare module BABYLON {
  6138. /**
  6139. * The Physically based material of BJS.
  6140. *
  6141. * This offers the main features of a standard PBR material.
  6142. * For more information, please refer to the documentation :
  6143. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  6144. */
  6145. class PBRMaterial extends BABYLON.Material {
  6146. /**
  6147. * Intensity of the direct lights e.g. the four lights available in your scene.
  6148. * This impacts both the direct diffuse and specular highlights.
  6149. */
  6150. directIntensity: number;
  6151. /**
  6152. * Intensity of the emissive part of the material.
  6153. * This helps controlling the emissive effect without modifying the emissive color.
  6154. */
  6155. emissiveIntensity: number;
  6156. /**
  6157. * Intensity of the environment e.g. how much the environment will light the object
  6158. * either through harmonics for rough material or through the refelction for shiny ones.
  6159. */
  6160. environmentIntensity: number;
  6161. /**
  6162. * This is a special control allowing the reduction of the specular highlights coming from the
  6163. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  6164. */
  6165. specularIntensity: number;
  6166. private _lightingInfos;
  6167. /**
  6168. * Debug Control allowing disabling the bump map on this material.
  6169. */
  6170. disableBumpMap: boolean;
  6171. /**
  6172. * Debug Control helping enforcing or dropping the darkness of shadows.
  6173. * 1.0 means the shadows have their normal darkness, 0.0 means the shadows are not visible.
  6174. */
  6175. overloadedShadowIntensity: number;
  6176. /**
  6177. * Debug Control helping dropping the shading effect coming from the diffuse lighting.
  6178. * 1.0 means the shade have their normal impact, 0.0 means no shading at all.
  6179. */
  6180. overloadedShadeIntensity: number;
  6181. private _overloadedShadowInfos;
  6182. /**
  6183. * The camera exposure used on this material.
  6184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  6185. * This corresponds to a photographic exposure.
  6186. */
  6187. cameraExposure: number;
  6188. /**
  6189. * The camera contrast used on this material.
  6190. * This property is here and not in the camera to allow controlling contrast without full screen post process.
  6191. */
  6192. cameraContrast: number;
  6193. /**
  6194. * Color Grading 2D Lookup Texture.
  6195. * This allows special effects like sepia, black and white to sixties rendering style.
  6196. */
  6197. cameraColorGradingTexture: BaseTexture;
  6198. private _cameraColorGradingScaleOffset;
  6199. private _cameraColorGradingInfos;
  6200. /**
  6201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  6202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  6203. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  6204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  6205. */
  6206. cameraColorCurves: ColorCurves;
  6207. private _cameraInfos;
  6208. private _microsurfaceTextureLods;
  6209. /**
  6210. * Debug Control allowing to overload the ambient color.
  6211. * This as to be use with the overloadedAmbientIntensity parameter.
  6212. */
  6213. overloadedAmbient: Color3;
  6214. /**
  6215. * Debug Control indicating how much the overloaded ambient color is used against the default one.
  6216. */
  6217. overloadedAmbientIntensity: number;
  6218. /**
  6219. * Debug Control allowing to overload the albedo color.
  6220. * This as to be use with the overloadedAlbedoIntensity parameter.
  6221. */
  6222. overloadedAlbedo: Color3;
  6223. /**
  6224. * Debug Control indicating how much the overloaded albedo color is used against the default one.
  6225. */
  6226. overloadedAlbedoIntensity: number;
  6227. /**
  6228. * Debug Control allowing to overload the reflectivity color.
  6229. * This as to be use with the overloadedReflectivityIntensity parameter.
  6230. */
  6231. overloadedReflectivity: Color3;
  6232. /**
  6233. * Debug Control indicating how much the overloaded reflectivity color is used against the default one.
  6234. */
  6235. overloadedReflectivityIntensity: number;
  6236. /**
  6237. * Debug Control allowing to overload the emissive color.
  6238. * This as to be use with the overloadedEmissiveIntensity parameter.
  6239. */
  6240. overloadedEmissive: Color3;
  6241. /**
  6242. * Debug Control indicating how much the overloaded emissive color is used against the default one.
  6243. */
  6244. overloadedEmissiveIntensity: number;
  6245. private _overloadedIntensity;
  6246. /**
  6247. * Debug Control allowing to overload the reflection color.
  6248. * This as to be use with the overloadedReflectionIntensity parameter.
  6249. */
  6250. overloadedReflection: Color3;
  6251. /**
  6252. * Debug Control indicating how much the overloaded reflection color is used against the default one.
  6253. */
  6254. overloadedReflectionIntensity: number;
  6255. /**
  6256. * Debug Control allowing to overload the microsurface.
  6257. * This as to be use with the overloadedMicroSurfaceIntensity parameter.
  6258. */
  6259. overloadedMicroSurface: number;
  6260. /**
  6261. * Debug Control indicating how much the overloaded microsurface is used against the default one.
  6262. */
  6263. overloadedMicroSurfaceIntensity: number;
  6264. private _overloadedMicroSurface;
  6265. /**
  6266. * AKA Diffuse Texture in standard nomenclature.
  6267. */
  6268. albedoTexture: BaseTexture;
  6269. /**
  6270. * AKA Occlusion Texture in other nomenclature.
  6271. */
  6272. ambientTexture: BaseTexture;
  6273. opacityTexture: BaseTexture;
  6274. reflectionTexture: BaseTexture;
  6275. emissiveTexture: BaseTexture;
  6276. /**
  6277. * AKA Specular texture in other nomenclature.
  6278. */
  6279. reflectivityTexture: BaseTexture;
  6280. bumpTexture: BaseTexture;
  6281. lightmapTexture: BaseTexture;
  6282. refractionTexture: BaseTexture;
  6283. ambientColor: Color3;
  6284. /**
  6285. * AKA Diffuse Color in other nomenclature.
  6286. */
  6287. albedoColor: Color3;
  6288. /**
  6289. * AKA Specular Color in other nomenclature.
  6290. */
  6291. reflectivityColor: Color3;
  6292. reflectionColor: Color3;
  6293. emissiveColor: Color3;
  6294. /**
  6295. * AKA Glossiness in other nomenclature.
  6296. */
  6297. microSurface: number;
  6298. /**
  6299. * source material index of refraction (IOR)' / 'destination material IOR.
  6300. */
  6301. indexOfRefraction: number;
  6302. /**
  6303. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  6304. */
  6305. invertRefractionY: boolean;
  6306. opacityFresnelParameters: FresnelParameters;
  6307. emissiveFresnelParameters: FresnelParameters;
  6308. /**
  6309. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  6310. * Materials half opaque for instance using refraction could benefit from this control.
  6311. */
  6312. linkRefractionWithTransparency: boolean;
  6313. /**
  6314. * The emissive and albedo are linked to never be more than one (Energy conservation).
  6315. */
  6316. linkEmissiveWithAlbedo: boolean;
  6317. useLightmapAsShadowmap: boolean;
  6318. /**
  6319. * In this mode, the emissive informtaion will always be added to the lighting once.
  6320. * A light for instance can be thought as emissive.
  6321. */
  6322. useEmissiveAsIllumination: boolean;
  6323. /**
  6324. * Secifies that the alpha is coming form the albedo channel alpha channel.
  6325. */
  6326. useAlphaFromAlbedoTexture: boolean;
  6327. /**
  6328. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  6329. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  6330. */
  6331. useSpecularOverAlpha: boolean;
  6332. /**
  6333. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  6334. */
  6335. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  6336. /**
  6337. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  6338. * The material will try to infer what glossiness each pixel should be.
  6339. */
  6340. useAutoMicroSurfaceFromReflectivityMap: boolean;
  6341. /**
  6342. * Allows to work with scalar in linear mode. This is definitely a matter of preferences and tools used during
  6343. * the creation of the material.
  6344. */
  6345. useScalarInLinearSpace: boolean;
  6346. /**
  6347. * BJS is using an harcoded light falloff based on a manually sets up range.
  6348. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  6349. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  6350. */
  6351. usePhysicalLightFalloff: boolean;
  6352. /**
  6353. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  6354. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  6355. */
  6356. useRadianceOverAlpha: boolean;
  6357. /**
  6358. * Allows using the bump map in parallax mode.
  6359. */
  6360. useParallax: boolean;
  6361. /**
  6362. * Allows using the bump map in parallax occlusion mode.
  6363. */
  6364. useParallaxOcclusion: boolean;
  6365. /**
  6366. * Controls the scale bias of the parallax mode.
  6367. */
  6368. parallaxScaleBias: number;
  6369. /**
  6370. * If sets to true, disables all the lights affecting the material.
  6371. */
  6372. disableLighting: boolean;
  6373. /**
  6374. * Number of Simultaneous lights allowed on the material.
  6375. */
  6376. maxSimultaneousLights: number;
  6377. /**
  6378. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  6379. */
  6380. invertNormalMapX: boolean;
  6381. /**
  6382. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  6383. */
  6384. invertNormalMapY: boolean;
  6385. private _renderTargets;
  6386. private _worldViewProjectionMatrix;
  6387. private _globalAmbientColor;
  6388. private _tempColor;
  6389. private _renderId;
  6390. private _defines;
  6391. private _cachedDefines;
  6392. private _useLogarithmicDepth;
  6393. /**
  6394. * Instantiates a new PBRMaterial instance.
  6395. *
  6396. * @param name The material name
  6397. * @param scene The scene the material will be use in.
  6398. */
  6399. constructor(name: string, scene: Scene);
  6400. useLogarithmicDepth: boolean;
  6401. needAlphaBlending(): boolean;
  6402. needAlphaTesting(): boolean;
  6403. private _shouldUseAlphaFromAlbedoTexture();
  6404. getAlphaTestTexture(): BaseTexture;
  6405. private _checkCache(scene, mesh?, useInstances?);
  6406. private convertColorToLinearSpaceToRef(color, ref);
  6407. private static convertColorToLinearSpaceToRef(color, ref, useScalarInLinear);
  6408. private static _scaledAlbedo;
  6409. private static _scaledReflectivity;
  6410. private static _scaledEmissive;
  6411. private static _scaledReflection;
  6412. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean, maxSimultaneousLights: number, usePhysicalLightFalloff: boolean): void;
  6413. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6414. unbind(): void;
  6415. bindOnlyWorldMatrix(world: Matrix): void;
  6416. private _myScene;
  6417. private _myShadowGenerator;
  6418. bind(world: Matrix, mesh?: Mesh): void;
  6419. getAnimatables(): IAnimatable[];
  6420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6421. clone(name: string): PBRMaterial;
  6422. serialize(): any;
  6423. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  6424. }
  6425. }
  6426. declare module BABYLON {
  6427. class ShaderMaterial extends Material {
  6428. private _shaderPath;
  6429. private _options;
  6430. private _textures;
  6431. private _floats;
  6432. private _floatsArrays;
  6433. private _colors3;
  6434. private _colors4;
  6435. private _vectors2;
  6436. private _vectors3;
  6437. private _vectors4;
  6438. private _matrices;
  6439. private _matrices3x3;
  6440. private _matrices2x2;
  6441. private _cachedWorldViewMatrix;
  6442. private _renderId;
  6443. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  6444. needAlphaBlending(): boolean;
  6445. needAlphaTesting(): boolean;
  6446. private _checkUniform(uniformName);
  6447. setTexture(name: string, texture: Texture): ShaderMaterial;
  6448. setFloat(name: string, value: number): ShaderMaterial;
  6449. setFloats(name: string, value: number[]): ShaderMaterial;
  6450. setColor3(name: string, value: Color3): ShaderMaterial;
  6451. setColor4(name: string, value: Color4): ShaderMaterial;
  6452. setVector2(name: string, value: Vector2): ShaderMaterial;
  6453. setVector3(name: string, value: Vector3): ShaderMaterial;
  6454. setVector4(name: string, value: Vector4): ShaderMaterial;
  6455. setMatrix(name: string, value: Matrix): ShaderMaterial;
  6456. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  6457. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  6458. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6459. bindOnlyWorldMatrix(world: Matrix): void;
  6460. bind(world: Matrix, mesh?: Mesh): void;
  6461. clone(name: string): ShaderMaterial;
  6462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6463. serialize(): any;
  6464. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  6465. }
  6466. }
  6467. declare module BABYLON {
  6468. class StandardMaterial extends Material {
  6469. diffuseTexture: BaseTexture;
  6470. ambientTexture: BaseTexture;
  6471. opacityTexture: BaseTexture;
  6472. reflectionTexture: BaseTexture;
  6473. emissiveTexture: BaseTexture;
  6474. specularTexture: BaseTexture;
  6475. bumpTexture: BaseTexture;
  6476. lightmapTexture: BaseTexture;
  6477. refractionTexture: BaseTexture;
  6478. ambientColor: Color3;
  6479. diffuseColor: Color3;
  6480. specularColor: Color3;
  6481. emissiveColor: Color3;
  6482. specularPower: number;
  6483. useAlphaFromDiffuseTexture: boolean;
  6484. useEmissiveAsIllumination: boolean;
  6485. linkEmissiveWithDiffuse: boolean;
  6486. useReflectionFresnelFromSpecular: boolean;
  6487. useSpecularOverAlpha: boolean;
  6488. useReflectionOverAlpha: boolean;
  6489. disableLighting: boolean;
  6490. useParallax: boolean;
  6491. useParallaxOcclusion: boolean;
  6492. parallaxScaleBias: number;
  6493. roughness: number;
  6494. indexOfRefraction: number;
  6495. invertRefractionY: boolean;
  6496. useLightmapAsShadowmap: boolean;
  6497. diffuseFresnelParameters: FresnelParameters;
  6498. opacityFresnelParameters: FresnelParameters;
  6499. reflectionFresnelParameters: FresnelParameters;
  6500. refractionFresnelParameters: FresnelParameters;
  6501. emissiveFresnelParameters: FresnelParameters;
  6502. useGlossinessFromSpecularMapAlpha: boolean;
  6503. maxSimultaneousLights: number;
  6504. /**
  6505. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  6506. */
  6507. invertNormalMapX: boolean;
  6508. /**
  6509. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  6510. */
  6511. invertNormalMapY: boolean;
  6512. private _renderTargets;
  6513. private _worldViewProjectionMatrix;
  6514. private _globalAmbientColor;
  6515. private _renderId;
  6516. private _defines;
  6517. private _cachedDefines;
  6518. private _useLogarithmicDepth;
  6519. constructor(name: string, scene: Scene);
  6520. useLogarithmicDepth: boolean;
  6521. needAlphaBlending(): boolean;
  6522. needAlphaTesting(): boolean;
  6523. private _shouldUseAlphaFromDiffuseTexture();
  6524. getAlphaTestTexture(): BaseTexture;
  6525. private _checkCache(scene, mesh?, useInstances?);
  6526. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6527. unbind(): void;
  6528. bindOnlyWorldMatrix(world: Matrix): void;
  6529. bind(world: Matrix, mesh?: Mesh): void;
  6530. getAnimatables(): IAnimatable[];
  6531. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6532. clone(name: string): StandardMaterial;
  6533. serialize(): any;
  6534. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  6535. static DiffuseTextureEnabled: boolean;
  6536. static AmbientTextureEnabled: boolean;
  6537. static OpacityTextureEnabled: boolean;
  6538. static ReflectionTextureEnabled: boolean;
  6539. static EmissiveTextureEnabled: boolean;
  6540. static SpecularTextureEnabled: boolean;
  6541. static BumpTextureEnabled: boolean;
  6542. static FresnelEnabled: boolean;
  6543. static LightmapTextureEnabled: boolean;
  6544. static RefractionTextureEnabled: boolean;
  6545. }
  6546. }
  6547. declare module BABYLON {
  6548. class SIMDVector3 {
  6549. static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void;
  6550. static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  6551. }
  6552. class SIMDMatrix {
  6553. multiplyToArraySIMD(other: Matrix, result: Matrix, offset?: number): void;
  6554. invertToRefSIMD(other: Matrix): Matrix;
  6555. static LookAtLHToRefSIMD(eyeRef: Vector3, targetRef: Vector3, upRef: Vector3, result: Matrix): void;
  6556. }
  6557. class SIMDHelper {
  6558. private static _isEnabled;
  6559. static IsEnabled: boolean;
  6560. static DisableSIMD(): void;
  6561. static EnableSIMD(): void;
  6562. }
  6563. }
  6564. declare module BABYLON {
  6565. const ToGammaSpace: number;
  6566. const ToLinearSpace: number;
  6567. const Epsilon: number;
  6568. class MathTools {
  6569. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  6570. static ToHex(i: number): string;
  6571. static Sign(value: number): number;
  6572. static Clamp(value: number, min?: number, max?: number): number;
  6573. }
  6574. class Color3 {
  6575. r: number;
  6576. g: number;
  6577. b: number;
  6578. constructor(r?: number, g?: number, b?: number);
  6579. toString(): string;
  6580. getClassName(): string;
  6581. getHashCode(): number;
  6582. toArray(array: number[], index?: number): Color3;
  6583. toColor4(alpha?: number): Color4;
  6584. asArray(): number[];
  6585. toLuminance(): number;
  6586. multiply(otherColor: Color3): Color3;
  6587. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  6588. equals(otherColor: Color3): boolean;
  6589. equalsFloats(r: number, g: number, b: number): boolean;
  6590. scale(scale: number): Color3;
  6591. scaleToRef(scale: number, result: Color3): Color3;
  6592. add(otherColor: Color3): Color3;
  6593. addToRef(otherColor: Color3, result: Color3): Color3;
  6594. subtract(otherColor: Color3): Color3;
  6595. subtractToRef(otherColor: Color3, result: Color3): Color3;
  6596. clone(): Color3;
  6597. copyFrom(source: Color3): Color3;
  6598. copyFromFloats(r: number, g: number, b: number): Color3;
  6599. toHexString(): string;
  6600. toLinearSpace(): Color3;
  6601. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6602. toGammaSpace(): Color3;
  6603. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6604. static FromHexString(hex: string): Color3;
  6605. static FromArray(array: number[], offset?: number): Color3;
  6606. static FromInts(r: number, g: number, b: number): Color3;
  6607. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  6608. static Red(): Color3;
  6609. static Green(): Color3;
  6610. static Blue(): Color3;
  6611. static Black(): Color3;
  6612. static White(): Color3;
  6613. static Purple(): Color3;
  6614. static Magenta(): Color3;
  6615. static Yellow(): Color3;
  6616. static Gray(): Color3;
  6617. }
  6618. class Color4 {
  6619. r: number;
  6620. g: number;
  6621. b: number;
  6622. a: number;
  6623. constructor(r: number, g: number, b: number, a: number);
  6624. addInPlace(right: any): Color4;
  6625. asArray(): number[];
  6626. toArray(array: number[], index?: number): Color4;
  6627. add(right: Color4): Color4;
  6628. subtract(right: Color4): Color4;
  6629. subtractToRef(right: Color4, result: Color4): Color4;
  6630. scale(scale: number): Color4;
  6631. scaleToRef(scale: number, result: Color4): Color4;
  6632. /**
  6633. * Multipy an RGBA Color4 value by another and return a new Color4 object
  6634. * @param color The Color4 (RGBA) value to multiply by
  6635. * @returns A new Color4.
  6636. */
  6637. multiply(color: Color4): Color4;
  6638. /**
  6639. * Multipy an RGBA Color4 value by another and push the result in a reference value
  6640. * @param color The Color4 (RGBA) value to multiply by
  6641. * @param result The Color4 (RGBA) to fill the result in
  6642. * @returns the result Color4.
  6643. */
  6644. multiplyToRef(color: Color4, result: Color4): Color4;
  6645. toString(): string;
  6646. getClassName(): string;
  6647. getHashCode(): number;
  6648. clone(): Color4;
  6649. copyFrom(source: Color4): Color4;
  6650. toHexString(): string;
  6651. static FromHexString(hex: string): Color4;
  6652. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  6653. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  6654. static FromArray(array: number[], offset?: number): Color4;
  6655. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6656. static CheckColors4(colors: number[], count: number): number[];
  6657. }
  6658. class Vector2 {
  6659. x: number;
  6660. y: number;
  6661. constructor(x: number, y: number);
  6662. toString(): string;
  6663. getClassName(): string;
  6664. getHashCode(): number;
  6665. toArray(array: number[] | Float32Array, index?: number): Vector2;
  6666. asArray(): number[];
  6667. copyFrom(source: Vector2): Vector2;
  6668. copyFromFloats(x: number, y: number): Vector2;
  6669. add(otherVector: Vector2): Vector2;
  6670. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  6671. addVector3(otherVector: Vector3): Vector2;
  6672. subtract(otherVector: Vector2): Vector2;
  6673. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  6674. subtractInPlace(otherVector: Vector2): Vector2;
  6675. multiplyInPlace(otherVector: Vector2): Vector2;
  6676. multiply(otherVector: Vector2): Vector2;
  6677. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  6678. multiplyByFloats(x: number, y: number): Vector2;
  6679. divide(otherVector: Vector2): Vector2;
  6680. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  6681. negate(): Vector2;
  6682. scaleInPlace(scale: number): Vector2;
  6683. scale(scale: number): Vector2;
  6684. equals(otherVector: Vector2): boolean;
  6685. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  6686. length(): number;
  6687. lengthSquared(): number;
  6688. normalize(): Vector2;
  6689. clone(): Vector2;
  6690. static Zero(): Vector2;
  6691. static FromArray(array: number[] | Float32Array, offset?: number): Vector2;
  6692. static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector2): void;
  6693. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  6694. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  6695. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  6696. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  6697. static Dot(left: Vector2, right: Vector2): number;
  6698. static Normalize(vector: Vector2): Vector2;
  6699. static Minimize(left: Vector2, right: Vector2): Vector2;
  6700. static Maximize(left: Vector2, right: Vector2): Vector2;
  6701. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  6702. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  6703. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  6704. static Distance(value1: Vector2, value2: Vector2): number;
  6705. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  6706. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  6707. }
  6708. class Vector3 {
  6709. x: number;
  6710. y: number;
  6711. z: number;
  6712. constructor(x: number, y: number, z: number);
  6713. toString(): string;
  6714. getClassName(): string;
  6715. getHashCode(): number;
  6716. asArray(): number[];
  6717. toArray(array: number[] | Float32Array, index?: number): Vector3;
  6718. toQuaternion(): Quaternion;
  6719. addInPlace(otherVector: Vector3): Vector3;
  6720. add(otherVector: Vector3): Vector3;
  6721. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  6722. subtractInPlace(otherVector: Vector3): Vector3;
  6723. subtract(otherVector: Vector3): Vector3;
  6724. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  6725. subtractFromFloats(x: number, y: number, z: number): Vector3;
  6726. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  6727. negate(): Vector3;
  6728. scaleInPlace(scale: number): Vector3;
  6729. scale(scale: number): Vector3;
  6730. scaleToRef(scale: number, result: Vector3): void;
  6731. equals(otherVector: Vector3): boolean;
  6732. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  6733. equalsToFloats(x: number, y: number, z: number): boolean;
  6734. multiplyInPlace(otherVector: Vector3): Vector3;
  6735. multiply(otherVector: Vector3): Vector3;
  6736. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  6737. multiplyByFloats(x: number, y: number, z: number): Vector3;
  6738. divide(otherVector: Vector3): Vector3;
  6739. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  6740. MinimizeInPlace(other: Vector3): Vector3;
  6741. MaximizeInPlace(other: Vector3): Vector3;
  6742. length(): number;
  6743. lengthSquared(): number;
  6744. normalize(): Vector3;
  6745. clone(): Vector3;
  6746. copyFrom(source: Vector3): Vector3;
  6747. copyFromFloats(x: number, y: number, z: number): Vector3;
  6748. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number;
  6749. static FromArray(array: number[] | Float32Array, offset?: number): Vector3;
  6750. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  6751. static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector3): void;
  6752. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  6753. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  6754. static Zero(): Vector3;
  6755. static Up(): Vector3;
  6756. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  6757. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  6758. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  6759. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  6760. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  6761. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  6762. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  6763. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  6764. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  6765. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  6766. static Dot(left: Vector3, right: Vector3): number;
  6767. static Cross(left: Vector3, right: Vector3): Vector3;
  6768. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  6769. static Normalize(vector: Vector3): Vector3;
  6770. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  6771. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  6772. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  6773. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  6774. static Minimize(left: Vector3, right: Vector3): Vector3;
  6775. static Maximize(left: Vector3, right: Vector3): Vector3;
  6776. static Distance(value1: Vector3, value2: Vector3): number;
  6777. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  6778. static Center(value1: Vector3, value2: Vector3): Vector3;
  6779. /**
  6780. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  6781. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  6782. * to something in order to rotate it from its local system to the given target system.
  6783. */
  6784. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  6785. /**
  6786. * The same than RotationFromAxis but updates the passed ref Vector3 parameter.
  6787. */
  6788. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  6789. }
  6790. class Vector4 {
  6791. x: number;
  6792. y: number;
  6793. z: number;
  6794. w: number;
  6795. constructor(x: number, y: number, z: number, w: number);
  6796. toString(): string;
  6797. getClassName(): string;
  6798. getHashCode(): number;
  6799. asArray(): number[];
  6800. toArray(array: number[], index?: number): Vector4;
  6801. addInPlace(otherVector: Vector4): Vector4;
  6802. add(otherVector: Vector4): Vector4;
  6803. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  6804. subtractInPlace(otherVector: Vector4): Vector4;
  6805. subtract(otherVector: Vector4): Vector4;
  6806. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  6807. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  6808. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  6809. negate(): Vector4;
  6810. scaleInPlace(scale: number): Vector4;
  6811. scale(scale: number): Vector4;
  6812. scaleToRef(scale: number, result: Vector4): void;
  6813. equals(otherVector: Vector4): boolean;
  6814. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  6815. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  6816. multiplyInPlace(otherVector: Vector4): Vector4;
  6817. multiply(otherVector: Vector4): Vector4;
  6818. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  6819. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  6820. divide(otherVector: Vector4): Vector4;
  6821. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  6822. MinimizeInPlace(other: Vector4): Vector4;
  6823. MaximizeInPlace(other: Vector4): Vector4;
  6824. length(): number;
  6825. lengthSquared(): number;
  6826. normalize(): Vector4;
  6827. toVector3(): Vector3;
  6828. clone(): Vector4;
  6829. copyFrom(source: Vector4): Vector4;
  6830. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  6831. static FromArray(array: number[], offset?: number): Vector4;
  6832. static FromArrayToRef(array: number[], offset: number, result: Vector4): void;
  6833. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  6834. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  6835. static Zero(): Vector4;
  6836. static Normalize(vector: Vector4): Vector4;
  6837. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  6838. static Minimize(left: Vector4, right: Vector4): Vector4;
  6839. static Maximize(left: Vector4, right: Vector4): Vector4;
  6840. static Distance(value1: Vector4, value2: Vector4): number;
  6841. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  6842. static Center(value1: Vector4, value2: Vector4): Vector4;
  6843. }
  6844. interface ISize {
  6845. width: number;
  6846. height: number;
  6847. }
  6848. class Size implements ISize {
  6849. width: number;
  6850. height: number;
  6851. constructor(width: number, height: number);
  6852. toString(): string;
  6853. getClassName(): string;
  6854. getHashCode(): number;
  6855. copyFrom(src: Size): void;
  6856. clone(): Size;
  6857. equals(other: Size): boolean;
  6858. surface: number;
  6859. static Zero(): Size;
  6860. add(otherSize: Size): Size;
  6861. substract(otherSize: Size): Size;
  6862. static Lerp(start: Size, end: Size, amount: number): Size;
  6863. }
  6864. class Quaternion {
  6865. x: number;
  6866. y: number;
  6867. z: number;
  6868. w: number;
  6869. constructor(x?: number, y?: number, z?: number, w?: number);
  6870. toString(): string;
  6871. getClassName(): string;
  6872. getHashCode(): number;
  6873. asArray(): number[];
  6874. equals(otherQuaternion: Quaternion): boolean;
  6875. clone(): Quaternion;
  6876. copyFrom(other: Quaternion): Quaternion;
  6877. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  6878. add(other: Quaternion): Quaternion;
  6879. subtract(other: Quaternion): Quaternion;
  6880. scale(value: number): Quaternion;
  6881. multiply(q1: Quaternion): Quaternion;
  6882. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  6883. multiplyInPlace(q1: Quaternion): Quaternion;
  6884. conjugateToRef(ref: Quaternion): Quaternion;
  6885. conjugateInPlace(): Quaternion;
  6886. conjugate(): Quaternion;
  6887. length(): number;
  6888. normalize(): Quaternion;
  6889. toEulerAngles(order?: string): Vector3;
  6890. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  6891. toRotationMatrix(result: Matrix): Quaternion;
  6892. fromRotationMatrix(matrix: Matrix): Quaternion;
  6893. static FromRotationMatrix(matrix: Matrix): Quaternion;
  6894. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  6895. static Inverse(q: Quaternion): Quaternion;
  6896. static Identity(): Quaternion;
  6897. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  6898. static FromArray(array: number[], offset?: number): Quaternion;
  6899. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  6900. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  6901. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  6902. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  6903. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  6904. }
  6905. class Matrix {
  6906. private static _tempQuaternion;
  6907. private static _xAxis;
  6908. private static _yAxis;
  6909. private static _zAxis;
  6910. m: Float32Array;
  6911. isIdentity(): boolean;
  6912. determinant(): number;
  6913. toArray(): Float32Array;
  6914. asArray(): Float32Array;
  6915. invert(): Matrix;
  6916. reset(): Matrix;
  6917. add(other: Matrix): Matrix;
  6918. addToRef(other: Matrix, result: Matrix): Matrix;
  6919. addToSelf(other: Matrix): Matrix;
  6920. invertToRef(other: Matrix): Matrix;
  6921. setTranslation(vector3: Vector3): Matrix;
  6922. getTranslation(): Vector3;
  6923. multiply(other: Matrix): Matrix;
  6924. copyFrom(other: Matrix): Matrix;
  6925. copyToArray(array: Float32Array, offset?: number): Matrix;
  6926. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  6927. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  6928. equals(value: Matrix): boolean;
  6929. clone(): Matrix;
  6930. getClassName(): string;
  6931. getHashCode(): number;
  6932. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  6933. static FromArray(array: number[], offset?: number): Matrix;
  6934. static FromArrayToRef(array: number[], offset: number, result: Matrix): void;
  6935. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  6936. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  6937. getRow(index: number): Vector4;
  6938. setRow(index: number, row: Vector4): Matrix;
  6939. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  6940. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  6941. static Identity(): Matrix;
  6942. static IdentityToRef(result: Matrix): void;
  6943. static Zero(): Matrix;
  6944. static RotationX(angle: number): Matrix;
  6945. static Invert(source: Matrix): Matrix;
  6946. static RotationXToRef(angle: number, result: Matrix): void;
  6947. static RotationY(angle: number): Matrix;
  6948. static RotationYToRef(angle: number, result: Matrix): void;
  6949. static RotationZ(angle: number): Matrix;
  6950. static RotationZToRef(angle: number, result: Matrix): void;
  6951. static RotationAxis(axis: Vector3, angle: number): Matrix;
  6952. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  6953. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  6954. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  6955. static Scaling(x: number, y: number, z: number): Matrix;
  6956. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  6957. static Translation(x: number, y: number, z: number): Matrix;
  6958. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  6959. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  6960. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  6961. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  6962. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  6963. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  6964. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  6965. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  6966. static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  6967. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  6968. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  6969. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  6970. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  6971. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  6972. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  6973. static Transpose(matrix: Matrix): Matrix;
  6974. static Reflection(plane: Plane): Matrix;
  6975. static ReflectionToRef(plane: Plane, result: Matrix): void;
  6976. }
  6977. class Plane {
  6978. normal: Vector3;
  6979. d: number;
  6980. constructor(a: number, b: number, c: number, d: number);
  6981. asArray(): number[];
  6982. clone(): Plane;
  6983. getClassName(): string;
  6984. getHashCode(): number;
  6985. normalize(): Plane;
  6986. transform(transformation: Matrix): Plane;
  6987. dotCoordinate(point: any): number;
  6988. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  6989. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  6990. signedDistanceTo(point: Vector3): number;
  6991. static FromArray(array: number[]): Plane;
  6992. static FromPoints(point1: any, point2: any, point3: any): Plane;
  6993. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  6994. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  6995. }
  6996. class Viewport {
  6997. x: number;
  6998. y: number;
  6999. width: number;
  7000. height: number;
  7001. constructor(x: number, y: number, width: number, height: number);
  7002. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  7003. }
  7004. class Frustum {
  7005. static GetPlanes(transform: Matrix): Plane[];
  7006. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  7007. }
  7008. enum Space {
  7009. LOCAL = 0,
  7010. WORLD = 1,
  7011. }
  7012. class Axis {
  7013. static X: Vector3;
  7014. static Y: Vector3;
  7015. static Z: Vector3;
  7016. }
  7017. class BezierCurve {
  7018. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  7019. }
  7020. enum Orientation {
  7021. CW = 0,
  7022. CCW = 1,
  7023. }
  7024. class Angle {
  7025. private _radians;
  7026. constructor(radians: number);
  7027. degrees: () => number;
  7028. radians: () => number;
  7029. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  7030. static FromRadians(radians: number): Angle;
  7031. static FromDegrees(degrees: number): Angle;
  7032. }
  7033. class Arc2 {
  7034. startPoint: Vector2;
  7035. midPoint: Vector2;
  7036. endPoint: Vector2;
  7037. centerPoint: Vector2;
  7038. radius: number;
  7039. angle: Angle;
  7040. startAngle: Angle;
  7041. orientation: Orientation;
  7042. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  7043. }
  7044. class Path2 {
  7045. private _points;
  7046. private _length;
  7047. closed: boolean;
  7048. constructor(x: number, y: number);
  7049. addLineTo(x: number, y: number): Path2;
  7050. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  7051. close(): Path2;
  7052. length(): number;
  7053. getPoints(): Vector2[];
  7054. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  7055. static StartingAt(x: number, y: number): Path2;
  7056. }
  7057. class Path3D {
  7058. path: Vector3[];
  7059. private _curve;
  7060. private _distances;
  7061. private _tangents;
  7062. private _normals;
  7063. private _binormals;
  7064. private _raw;
  7065. /**
  7066. * new Path3D(path, normal, raw)
  7067. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  7068. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  7069. * path : an array of Vector3, the curve axis of the Path3D
  7070. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  7071. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  7072. */
  7073. constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean);
  7074. /**
  7075. * Returns the Path3D array of successive Vector3 designing its curve.
  7076. */
  7077. getCurve(): Vector3[];
  7078. /**
  7079. * Returns an array populated with tangent vectors on each Path3D curve point.
  7080. */
  7081. getTangents(): Vector3[];
  7082. /**
  7083. * Returns an array populated with normal vectors on each Path3D curve point.
  7084. */
  7085. getNormals(): Vector3[];
  7086. /**
  7087. * Returns an array populated with binormal vectors on each Path3D curve point.
  7088. */
  7089. getBinormals(): Vector3[];
  7090. /**
  7091. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  7092. */
  7093. getDistances(): number[];
  7094. /**
  7095. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  7096. * Returns the same object updated.
  7097. */
  7098. update(path: Vector3[], firstNormal?: Vector3): Path3D;
  7099. private _compute(firstNormal);
  7100. private _getFirstNonNullVector(index);
  7101. private _getLastNonNullVector(index);
  7102. private _normalVector(v0, vt, va);
  7103. }
  7104. class Curve3 {
  7105. private _points;
  7106. private _length;
  7107. /**
  7108. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  7109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  7110. * @param v1 (Vector3) the control point
  7111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  7112. * @param nbPoints (integer) the wanted number of points in the curve
  7113. */
  7114. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  7115. /**
  7116. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  7117. * @param v0 (Vector3) the origin point of the Cubic Bezier
  7118. * @param v1 (Vector3) the first control point
  7119. * @param v2 (Vector3) the second control point
  7120. * @param v3 (Vector3) the end point of the Cubic Bezier
  7121. * @param nbPoints (integer) the wanted number of points in the curve
  7122. */
  7123. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  7124. /**
  7125. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  7126. * @param p1 (Vector3) the origin point of the Hermite Spline
  7127. * @param t1 (Vector3) the tangent vector at the origin point
  7128. * @param p2 (Vector3) the end point of the Hermite Spline
  7129. * @param t2 (Vector3) the tangent vector at the end point
  7130. * @param nbPoints (integer) the wanted number of points in the curve
  7131. */
  7132. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  7133. /**
  7134. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  7135. * A Curve3 is designed from a series of successive Vector3.
  7136. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  7137. */
  7138. constructor(points: Vector3[]);
  7139. /**
  7140. * Returns the Curve3 stored array of successive Vector3
  7141. */
  7142. getPoints(): Vector3[];
  7143. /**
  7144. * Returns the computed length (float) of the curve.
  7145. */
  7146. length(): number;
  7147. /**
  7148. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  7149. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  7150. * curveA and curveB keep unchanged.
  7151. */
  7152. continue(curve: Curve3): Curve3;
  7153. private _computeLength(path);
  7154. }
  7155. class SphericalHarmonics {
  7156. L00: Vector3;
  7157. L1_1: Vector3;
  7158. L10: Vector3;
  7159. L11: Vector3;
  7160. L2_2: Vector3;
  7161. L2_1: Vector3;
  7162. L20: Vector3;
  7163. L21: Vector3;
  7164. L22: Vector3;
  7165. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  7166. scale(scale: number): void;
  7167. }
  7168. class SphericalPolynomial {
  7169. x: Vector3;
  7170. y: Vector3;
  7171. z: Vector3;
  7172. xx: Vector3;
  7173. yy: Vector3;
  7174. zz: Vector3;
  7175. xy: Vector3;
  7176. yz: Vector3;
  7177. zx: Vector3;
  7178. addAmbient(color: Color3): void;
  7179. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  7180. }
  7181. class PositionNormalVertex {
  7182. position: Vector3;
  7183. normal: Vector3;
  7184. constructor(position?: Vector3, normal?: Vector3);
  7185. clone(): PositionNormalVertex;
  7186. }
  7187. class PositionNormalTextureVertex {
  7188. position: Vector3;
  7189. normal: Vector3;
  7190. uv: Vector2;
  7191. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  7192. clone(): PositionNormalTextureVertex;
  7193. }
  7194. class Tmp {
  7195. static Color3: Color3[];
  7196. static Vector2: Vector2[];
  7197. static Vector3: Vector3[];
  7198. static Vector4: Vector4[];
  7199. static Quaternion: Quaternion[];
  7200. static Matrix: Matrix[];
  7201. }
  7202. }
  7203. declare module BABYLON {
  7204. class Particle {
  7205. position: Vector3;
  7206. direction: Vector3;
  7207. color: Color4;
  7208. colorStep: Color4;
  7209. lifeTime: number;
  7210. age: number;
  7211. size: number;
  7212. angle: number;
  7213. angularSpeed: number;
  7214. copyTo(other: Particle): void;
  7215. }
  7216. }
  7217. declare module BABYLON {
  7218. class ParticleSystem implements IDisposable, IAnimatable {
  7219. name: string;
  7220. static BLENDMODE_ONEONE: number;
  7221. static BLENDMODE_STANDARD: number;
  7222. animations: Animation[];
  7223. id: string;
  7224. renderingGroupId: number;
  7225. emitter: any;
  7226. emitRate: number;
  7227. manualEmitCount: number;
  7228. updateSpeed: number;
  7229. targetStopDuration: number;
  7230. disposeOnStop: boolean;
  7231. minEmitPower: number;
  7232. maxEmitPower: number;
  7233. minLifeTime: number;
  7234. maxLifeTime: number;
  7235. minSize: number;
  7236. maxSize: number;
  7237. minAngularSpeed: number;
  7238. maxAngularSpeed: number;
  7239. particleTexture: Texture;
  7240. layerMask: number;
  7241. /**
  7242. * An event triggered when the system is disposed.
  7243. * @type {BABYLON.Observable}
  7244. */
  7245. onDisposeObservable: Observable<ParticleSystem>;
  7246. private _onDisposeObserver;
  7247. onDispose: () => void;
  7248. updateFunction: (particles: Particle[]) => void;
  7249. blendMode: number;
  7250. forceDepthWrite: boolean;
  7251. gravity: Vector3;
  7252. direction1: Vector3;
  7253. direction2: Vector3;
  7254. minEmitBox: Vector3;
  7255. maxEmitBox: Vector3;
  7256. color1: Color4;
  7257. color2: Color4;
  7258. colorDead: Color4;
  7259. textureMask: Color4;
  7260. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  7261. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  7262. private particles;
  7263. private _capacity;
  7264. private _scene;
  7265. private _stockParticles;
  7266. private _newPartsExcess;
  7267. private _vertexData;
  7268. private _vertexBuffer;
  7269. private _vertexBuffers;
  7270. private _indexBuffer;
  7271. private _effect;
  7272. private _customEffect;
  7273. private _cachedDefines;
  7274. private _scaledColorStep;
  7275. private _colorDiff;
  7276. private _scaledDirection;
  7277. private _scaledGravity;
  7278. private _currentRenderId;
  7279. private _alive;
  7280. private _started;
  7281. private _stopped;
  7282. private _actualFrame;
  7283. private _scaledUpdateSpeed;
  7284. constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
  7285. recycleParticle(particle: Particle): void;
  7286. getCapacity(): number;
  7287. isAlive(): boolean;
  7288. isStarted(): boolean;
  7289. start(): void;
  7290. stop(): void;
  7291. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  7292. private _update(newParticles);
  7293. private _getEffect();
  7294. animate(): void;
  7295. render(): number;
  7296. dispose(): void;
  7297. clone(name: string, newEmitter: any): ParticleSystem;
  7298. serialize(): any;
  7299. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  7300. }
  7301. }
  7302. declare module BABYLON {
  7303. class SolidParticle {
  7304. idx: number;
  7305. color: Color4;
  7306. position: Vector3;
  7307. rotation: Vector3;
  7308. rotationQuaternion: Quaternion;
  7309. scaling: Vector3;
  7310. uvs: Vector4;
  7311. velocity: Vector3;
  7312. alive: boolean;
  7313. isVisible: boolean;
  7314. _pos: number;
  7315. _model: ModelShape;
  7316. shapeId: number;
  7317. idxInShape: number;
  7318. constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number);
  7319. scale: Vector3;
  7320. quaternion: Quaternion;
  7321. }
  7322. class ModelShape {
  7323. shapeID: number;
  7324. _shape: Vector3[];
  7325. _shapeUV: number[];
  7326. _positionFunction: (particle: SolidParticle, i: number, s: number) => void;
  7327. _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void;
  7328. constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void);
  7329. }
  7330. }
  7331. declare module BABYLON {
  7332. /**
  7333. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  7334. */
  7335. class SolidParticleSystem implements IDisposable {
  7336. /**
  7337. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  7338. * Example : var p = SPS.particles[i];
  7339. */
  7340. particles: SolidParticle[];
  7341. /**
  7342. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  7343. */
  7344. nbParticles: number;
  7345. /**
  7346. * If the particles must ever face the camera (default false). Useful for planar particles.
  7347. */
  7348. billboard: boolean;
  7349. /**
  7350. * This a counter ofr your own usage. It's not set by any SPS functions.
  7351. */
  7352. counter: number;
  7353. /**
  7354. * The SPS name. This name is also given to the underlying mesh.
  7355. */
  7356. name: string;
  7357. /**
  7358. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  7359. */
  7360. mesh: Mesh;
  7361. /**
  7362. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  7363. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  7364. */
  7365. vars: any;
  7366. /**
  7367. * This array is populated when the SPS is set as 'pickable'.
  7368. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  7369. * Each element of this array is an object `{idx: int, faceId: int}`.
  7370. * `idx` is the picked particle index in the `SPS.particles` array
  7371. * `faceId` is the picked face index counted within this particle.
  7372. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  7373. */
  7374. pickedParticles: {
  7375. idx: number;
  7376. faceId: number;
  7377. }[];
  7378. private _scene;
  7379. private _positions;
  7380. private _indices;
  7381. private _normals;
  7382. private _colors;
  7383. private _uvs;
  7384. private _positions32;
  7385. private _normals32;
  7386. private _fixedNormal32;
  7387. private _colors32;
  7388. private _uvs32;
  7389. private _index;
  7390. private _updatable;
  7391. private _pickable;
  7392. private _isVisibilityBoxLocked;
  7393. private _alwaysVisible;
  7394. private _shapeCounter;
  7395. private _copy;
  7396. private _shape;
  7397. private _shapeUV;
  7398. private _color;
  7399. private _computeParticleColor;
  7400. private _computeParticleTexture;
  7401. private _computeParticleRotation;
  7402. private _computeParticleVertex;
  7403. private _computeBoundingBox;
  7404. private _cam_axisZ;
  7405. private _cam_axisY;
  7406. private _cam_axisX;
  7407. private _axisX;
  7408. private _axisY;
  7409. private _axisZ;
  7410. private _camera;
  7411. private _particle;
  7412. private _fakeCamPos;
  7413. private _rotMatrix;
  7414. private _invertMatrix;
  7415. private _rotated;
  7416. private _quaternion;
  7417. private _vertex;
  7418. private _normal;
  7419. private _yaw;
  7420. private _pitch;
  7421. private _roll;
  7422. private _halfroll;
  7423. private _halfpitch;
  7424. private _halfyaw;
  7425. private _sinRoll;
  7426. private _cosRoll;
  7427. private _sinPitch;
  7428. private _cosPitch;
  7429. private _sinYaw;
  7430. private _cosYaw;
  7431. private _w;
  7432. private _minimum;
  7433. private _maximum;
  7434. /**
  7435. * Creates a SPS (Solid Particle System) object.
  7436. * `name` (String) is the SPS name, this will be the underlying mesh name.
  7437. * `scene` (Scene) is the scene in which the SPS is added.
  7438. * `updatable` (default true) : if the SPS must be updatable or immutable.
  7439. * `isPickable` (default false) : if the solid particles must be pickable.
  7440. */
  7441. constructor(name: string, scene: Scene, options?: {
  7442. updatable?: boolean;
  7443. isPickable?: boolean;
  7444. });
  7445. /**
  7446. * Builds the SPS underlying mesh. Returns a standard Mesh.
  7447. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  7448. */
  7449. buildMesh(): Mesh;
  7450. /**
  7451. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  7452. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  7453. * Thus the particles generated from `digest()` have their property `position` set yet.
  7454. * `mesh` ( Mesh ) is the mesh to be digested
  7455. * `facetNb` (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  7456. * `delta` (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  7457. * `number` (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  7458. */
  7459. digest(mesh: Mesh, options?: {
  7460. facetNb?: number;
  7461. number?: number;
  7462. delta?: number;
  7463. }): SolidParticleSystem;
  7464. private _resetCopy();
  7465. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idx, idxInShape, options);
  7466. private _posToShape(positions);
  7467. private _uvsToShapeUV(uvs);
  7468. private _addParticle(idx, idxpos, model, shapeId, idxInShape);
  7469. /**
  7470. * Adds some particles to the SPS from the model shape. Returns the shape id.
  7471. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  7472. * `mesh` is any Mesh object that will be used as a model for the solid particles.
  7473. * `nb` (positive integer) the number of particles to be created from this model
  7474. * `positionFunction` is an optional javascript function to called for each particle on SPS creation.
  7475. * `vertexFunction` is an optional javascript function to called for each vertex of each particle on SPS creation
  7476. */
  7477. addShape(mesh: Mesh, nb: number, options?: {
  7478. positionFunction?: any;
  7479. vertexFunction?: any;
  7480. }): number;
  7481. private _rebuildParticle(particle);
  7482. /**
  7483. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  7484. */
  7485. rebuildMesh(): void;
  7486. /**
  7487. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  7488. * This method calls `updateParticle()` for each particle of the SPS.
  7489. * For an animated SPS, it is usually called within the render loop.
  7490. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  7491. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  7492. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  7493. */
  7494. setParticles(start?: number, end?: number, update?: boolean): void;
  7495. private _quaternionRotationYPR();
  7496. private _quaternionToRotationMatrix();
  7497. /**
  7498. * Disposes the SPS
  7499. */
  7500. dispose(): void;
  7501. /**
  7502. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  7503. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7504. */
  7505. refreshVisibleSize(): void;
  7506. /**
  7507. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  7508. * @param size the size (float) of the visibility box
  7509. * note : this doesn't lock the SPS mesh bounding box.
  7510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7511. */
  7512. setVisibilityBox(size: number): void;
  7513. /**
  7514. * Sets the SPS as always visible or not
  7515. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7516. */
  7517. isAlwaysVisible: boolean;
  7518. /**
  7519. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  7520. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7521. */
  7522. isVisibilityBoxLocked: boolean;
  7523. /**
  7524. * Tells to `setParticles()` to compute the particle rotations or not.
  7525. * Default value : true. The SPS is faster when it's set to false.
  7526. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  7527. */
  7528. computeParticleRotation: boolean;
  7529. /**
  7530. * Tells to `setParticles()` to compute the particle colors or not.
  7531. * Default value : true. The SPS is faster when it's set to false.
  7532. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  7533. */
  7534. computeParticleColor: boolean;
  7535. /**
  7536. * Tells to `setParticles()` to compute the particle textures or not.
  7537. * Default value : true. The SPS is faster when it's set to false.
  7538. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  7539. */
  7540. computeParticleTexture: boolean;
  7541. /**
  7542. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  7543. * Default value : false. The SPS is faster when it's set to false.
  7544. * Note : the particle custom vertex positions aren't stored values.
  7545. */
  7546. computeParticleVertex: boolean;
  7547. /**
  7548. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  7549. */
  7550. computeBoundingBox: boolean;
  7551. /**
  7552. * This function does nothing. It may be overwritten to set all the particle first values.
  7553. * The SPS doesn't call this function, you may have to call it by your own.
  7554. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  7555. */
  7556. initParticles(): void;
  7557. /**
  7558. * This function does nothing. It may be overwritten to recycle a particle.
  7559. * The SPS doesn't call this function, you may have to call it by your own.
  7560. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  7561. */
  7562. recycleParticle(particle: SolidParticle): SolidParticle;
  7563. /**
  7564. * Updates a particle : this function should be overwritten by the user.
  7565. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  7566. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  7567. * ex : just set a particle position or velocity and recycle conditions
  7568. */
  7569. updateParticle(particle: SolidParticle): SolidParticle;
  7570. /**
  7571. * Updates a vertex of a particle : it can be overwritten by the user.
  7572. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  7573. * @param particle the current particle
  7574. * @param vertex the current index of the current particle
  7575. * @param pt the index of the current vertex in the particle shape
  7576. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  7577. * ex : just set a vertex particle position
  7578. */
  7579. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  7580. /**
  7581. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  7582. * This does nothing and may be overwritten by the user.
  7583. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7584. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7585. * @param update the boolean update value actually passed to setParticles()
  7586. */
  7587. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  7588. /**
  7589. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  7590. * This will be passed three parameters.
  7591. * This does nothing and may be overwritten by the user.
  7592. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7593. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7594. * @param update the boolean update value actually passed to setParticles()
  7595. */
  7596. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. class AbstractMesh extends Node implements IDisposable {
  7601. private static _BILLBOARDMODE_NONE;
  7602. private static _BILLBOARDMODE_X;
  7603. private static _BILLBOARDMODE_Y;
  7604. private static _BILLBOARDMODE_Z;
  7605. private static _BILLBOARDMODE_ALL;
  7606. static BILLBOARDMODE_NONE: number;
  7607. static BILLBOARDMODE_X: number;
  7608. static BILLBOARDMODE_Y: number;
  7609. static BILLBOARDMODE_Z: number;
  7610. static BILLBOARDMODE_ALL: number;
  7611. /**
  7612. * An event triggered when the mesh is disposed.
  7613. * @type {BABYLON.Observable}
  7614. */
  7615. onDisposeObservable: Observable<AbstractMesh>;
  7616. private _onDisposeObserver;
  7617. onDispose: () => void;
  7618. /**
  7619. * An event triggered when this mesh collides with another one
  7620. * @type {BABYLON.Observable}
  7621. */
  7622. onCollideObservable: Observable<AbstractMesh>;
  7623. private _onCollideObserver;
  7624. onCollide: () => void;
  7625. /**
  7626. * An event triggered when the collision's position changes
  7627. * @type {BABYLON.Observable}
  7628. */
  7629. onCollisionPositionChangeObservable: Observable<Vector3>;
  7630. private _onCollisionPositionChangeObserver;
  7631. onCollisionPositionChange: () => void;
  7632. /**
  7633. * An event triggered after the world matrix is updated
  7634. * @type {BABYLON.Observable}
  7635. */
  7636. onAfterWorldMatrixUpdateObservable: Observable<AbstractMesh>;
  7637. definedFacingForward: boolean;
  7638. position: Vector3;
  7639. private _rotation;
  7640. _rotationQuaternion: Quaternion;
  7641. private _scaling;
  7642. billboardMode: number;
  7643. visibility: number;
  7644. alphaIndex: number;
  7645. infiniteDistance: boolean;
  7646. isVisible: boolean;
  7647. isPickable: boolean;
  7648. showBoundingBox: boolean;
  7649. showSubMeshesBoundingBox: boolean;
  7650. isBlocker: boolean;
  7651. renderingGroupId: number;
  7652. material: Material;
  7653. receiveShadows: boolean;
  7654. renderOutline: boolean;
  7655. outlineColor: Color3;
  7656. outlineWidth: number;
  7657. renderOverlay: boolean;
  7658. overlayColor: Color3;
  7659. overlayAlpha: number;
  7660. hasVertexAlpha: boolean;
  7661. useVertexColors: boolean;
  7662. applyFog: boolean;
  7663. computeBonesUsingShaders: boolean;
  7664. scalingDeterminant: number;
  7665. numBoneInfluencers: number;
  7666. useOctreeForRenderingSelection: boolean;
  7667. useOctreeForPicking: boolean;
  7668. useOctreeForCollisions: boolean;
  7669. layerMask: number;
  7670. alwaysSelectAsActiveMesh: boolean;
  7671. /**
  7672. * This scene's action manager
  7673. * @type {BABYLON.ActionManager}
  7674. */
  7675. actionManager: ActionManager;
  7676. physicsImpostor: BABYLON.PhysicsImpostor;
  7677. onPhysicsCollide: (collidedMesh: AbstractMesh, contact: any) => void;
  7678. private _checkCollisions;
  7679. ellipsoid: Vector3;
  7680. ellipsoidOffset: Vector3;
  7681. private _collider;
  7682. private _oldPositionForCollisions;
  7683. private _diffPositionForCollisions;
  7684. private _newPositionForCollisions;
  7685. private _meshToBoneReferal;
  7686. edgesWidth: number;
  7687. edgesColor: Color4;
  7688. _edgesRenderer: EdgesRenderer;
  7689. private _localWorld;
  7690. _worldMatrix: Matrix;
  7691. private _rotateYByPI;
  7692. private _absolutePosition;
  7693. private _collisionsTransformMatrix;
  7694. private _collisionsScalingMatrix;
  7695. _positions: Vector3[];
  7696. private _isDirty;
  7697. _masterMesh: AbstractMesh;
  7698. _materialDefines: MaterialDefines;
  7699. _boundingInfo: BoundingInfo;
  7700. private _pivotMatrix;
  7701. _isDisposed: boolean;
  7702. _renderId: number;
  7703. subMeshes: SubMesh[];
  7704. _submeshesOctree: Octree<SubMesh>;
  7705. _intersectionsInProgress: AbstractMesh[];
  7706. private _isWorldMatrixFrozen;
  7707. _unIndexed: boolean;
  7708. _poseMatrix: Matrix;
  7709. _waitingActions: any;
  7710. _waitingFreezeWorldMatrix: boolean;
  7711. private _skeleton;
  7712. _bonesTransformMatrices: Float32Array;
  7713. skeleton: Skeleton;
  7714. constructor(name: string, scene: Scene);
  7715. /**
  7716. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  7717. */
  7718. toString(fullDetails?: boolean): string;
  7719. /**
  7720. * Getting the rotation object.
  7721. * If rotation quaternion is set, this vector will (almost always) be the Zero vector!
  7722. */
  7723. rotation: Vector3;
  7724. scaling: Vector3;
  7725. rotationQuaternion: Quaternion;
  7726. updatePoseMatrix(matrix: Matrix): void;
  7727. getPoseMatrix(): Matrix;
  7728. disableEdgesRendering(): void;
  7729. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): void;
  7730. isBlocked: boolean;
  7731. getLOD(camera: Camera): AbstractMesh;
  7732. getTotalVertices(): number;
  7733. getIndices(): number[] | Int32Array;
  7734. getVerticesData(kind: string): number[] | Float32Array;
  7735. isVerticesDataPresent(kind: string): boolean;
  7736. getBoundingInfo(): BoundingInfo;
  7737. useBones: boolean;
  7738. _preActivate(): void;
  7739. _preActivateForIntermediateRendering(renderId: number): void;
  7740. _activate(renderId: number): void;
  7741. getWorldMatrix(): Matrix;
  7742. worldMatrixFromCache: Matrix;
  7743. absolutePosition: Vector3;
  7744. freezeWorldMatrix(): void;
  7745. unfreezeWorldMatrix(): void;
  7746. isWorldMatrixFrozen: boolean;
  7747. rotate(axis: Vector3, amount: number, space?: Space): void;
  7748. translate(axis: Vector3, distance: number, space?: Space): void;
  7749. getAbsolutePosition(): Vector3;
  7750. setAbsolutePosition(absolutePosition: Vector3): void;
  7751. /**
  7752. * Perform relative position change from the point of view of behind the front of the mesh.
  7753. * This is performed taking into account the meshes current rotation, so you do not have to care.
  7754. * Supports definition of mesh facing forward or backward.
  7755. * @param {number} amountRight
  7756. * @param {number} amountUp
  7757. * @param {number} amountForward
  7758. */
  7759. movePOV(amountRight: number, amountUp: number, amountForward: number): void;
  7760. /**
  7761. * Calculate relative position change from the point of view of behind the front of the mesh.
  7762. * This is performed taking into account the meshes current rotation, so you do not have to care.
  7763. * Supports definition of mesh facing forward or backward.
  7764. * @param {number} amountRight
  7765. * @param {number} amountUp
  7766. * @param {number} amountForward
  7767. */
  7768. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  7769. /**
  7770. * Perform relative rotation change from the point of view of behind the front of the mesh.
  7771. * Supports definition of mesh facing forward or backward.
  7772. * @param {number} flipBack
  7773. * @param {number} twirlClockwise
  7774. * @param {number} tiltRight
  7775. */
  7776. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void;
  7777. /**
  7778. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  7779. * Supports definition of mesh facing forward or backward.
  7780. * @param {number} flipBack
  7781. * @param {number} twirlClockwise
  7782. * @param {number} tiltRight
  7783. */
  7784. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  7785. setPivotMatrix(matrix: Matrix): void;
  7786. getPivotMatrix(): Matrix;
  7787. _isSynchronized(): boolean;
  7788. _initCache(): void;
  7789. markAsDirty(property: string): void;
  7790. _updateBoundingInfo(): void;
  7791. _updateSubMeshesBoundingInfo(matrix: Matrix): void;
  7792. computeWorldMatrix(force?: boolean): Matrix;
  7793. /**
  7794. * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated
  7795. * @param func: callback function to add
  7796. */
  7797. registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  7798. unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  7799. setPositionWithLocalVector(vector3: Vector3): void;
  7800. getPositionExpressedInLocalSpace(): Vector3;
  7801. locallyTranslate(vector3: Vector3): void;
  7802. lookAt(targetPoint: Vector3, yawCor: number, pitchCor: number, rollCor: number): void;
  7803. attachToBone(bone: Bone, affectedMesh: AbstractMesh): void;
  7804. detachFromBone(): void;
  7805. isInFrustum(frustumPlanes: Plane[]): boolean;
  7806. isCompletelyInFrustum(camera?: Camera): boolean;
  7807. intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean;
  7808. intersectsPoint(point: Vector3): boolean;
  7809. /**
  7810. * @Deprecated. Use new PhysicsImpostor instead.
  7811. * */
  7812. setPhysicsState(impostor?: any, options?: PhysicsImpostorParameters): any;
  7813. getPhysicsImpostor(): PhysicsImpostor;
  7814. /**
  7815. * @Deprecated. Use getPhysicsImpostor().getParam("mass");
  7816. */
  7817. getPhysicsMass(): number;
  7818. /**
  7819. * @Deprecated. Use getPhysicsImpostor().getParam("friction");
  7820. */
  7821. getPhysicsFriction(): number;
  7822. /**
  7823. * @Deprecated. Use getPhysicsImpostor().getParam("restitution");
  7824. */
  7825. getPhysicsRestitution(): number;
  7826. getPositionInCameraSpace(camera?: Camera): Vector3;
  7827. getDistanceToCamera(camera?: Camera): number;
  7828. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  7829. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void;
  7830. /**
  7831. * @Deprecated
  7832. */
  7833. updatePhysicsBodyPosition(): void;
  7834. /**
  7835. * @Deprecated
  7836. * Calling this function is not needed anymore.
  7837. * The physics engine takes care of transofmration automatically.
  7838. */
  7839. updatePhysicsBody(): void;
  7840. checkCollisions: boolean;
  7841. moveWithCollisions(velocity: Vector3): void;
  7842. private _onCollisionPositionChange;
  7843. /**
  7844. * This function will create an octree to help select the right submeshes for rendering, picking and collisions
  7845. * Please note that you must have a decent number of submeshes to get performance improvements when using octree
  7846. */
  7847. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  7848. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void;
  7849. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void;
  7850. _checkCollision(collider: Collider): void;
  7851. _generatePointsArray(): boolean;
  7852. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  7853. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh;
  7854. releaseSubMeshes(): void;
  7855. dispose(doNotRecurse?: boolean): void;
  7856. }
  7857. }
  7858. declare module BABYLON {
  7859. class Buffer {
  7860. private _engine;
  7861. private _buffer;
  7862. private _data;
  7863. private _updatable;
  7864. private _strideSize;
  7865. private _instanced;
  7866. constructor(engine: any, data: number[] | Float32Array, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  7867. createVertexBuffer(kind: string, offset: number, size: number, stride?: number): VertexBuffer;
  7868. isUpdatable(): boolean;
  7869. getData(): number[] | Float32Array;
  7870. getBuffer(): WebGLBuffer;
  7871. getStrideSize(): number;
  7872. getIsInstanced(): boolean;
  7873. create(data?: number[] | Float32Array): void;
  7874. update(data: number[] | Float32Array): void;
  7875. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  7876. dispose(): void;
  7877. }
  7878. }
  7879. declare module BABYLON {
  7880. class CSG {
  7881. private polygons;
  7882. matrix: Matrix;
  7883. position: Vector3;
  7884. rotation: Vector3;
  7885. rotationQuaternion: Quaternion;
  7886. scaling: Vector3;
  7887. static FromMesh(mesh: Mesh): CSG;
  7888. private static FromPolygons(polygons);
  7889. clone(): CSG;
  7890. private toPolygons();
  7891. union(csg: CSG): CSG;
  7892. unionInPlace(csg: CSG): void;
  7893. subtract(csg: CSG): CSG;
  7894. subtractInPlace(csg: CSG): void;
  7895. intersect(csg: CSG): CSG;
  7896. intersectInPlace(csg: CSG): void;
  7897. inverse(): CSG;
  7898. inverseInPlace(): void;
  7899. copyTransformAttributes(csg: CSG): CSG;
  7900. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  7901. toMesh(name: string, material: Material, scene: Scene, keepSubMeshes: boolean): Mesh;
  7902. }
  7903. }
  7904. declare module BABYLON {
  7905. class Geometry implements IGetSetVerticesData {
  7906. id: string;
  7907. delayLoadState: number;
  7908. delayLoadingFile: string;
  7909. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  7910. private _scene;
  7911. private _engine;
  7912. private _meshes;
  7913. private _totalVertices;
  7914. private _indices;
  7915. private _vertexBuffers;
  7916. private _isDisposed;
  7917. private _extend;
  7918. private _boundingBias;
  7919. _delayInfo: any;
  7920. private _indexBuffer;
  7921. _boundingInfo: BoundingInfo;
  7922. _delayLoadingFunction: (any: any, geometry: Geometry) => void;
  7923. _softwareSkinningRenderId: number;
  7924. /**
  7925. * The Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  7926. * @returns The Bias Vector
  7927. */
  7928. boundingBias: Vector2;
  7929. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Mesh);
  7930. extend: {
  7931. minimum: Vector3;
  7932. maximum: Vector3;
  7933. };
  7934. getScene(): Scene;
  7935. getEngine(): Engine;
  7936. isReady(): boolean;
  7937. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  7938. setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean, stride?: number): void;
  7939. setVerticesBuffer(buffer: VertexBuffer): void;
  7940. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  7941. updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean): void;
  7942. private updateBoundingInfo(updateExtends, data);
  7943. getTotalVertices(): number;
  7944. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Float32Array;
  7945. getVertexBuffer(kind: string): VertexBuffer;
  7946. getVertexBuffers(): {
  7947. [key: string]: VertexBuffer;
  7948. };
  7949. isVerticesDataPresent(kind: string): boolean;
  7950. getVerticesDataKinds(): string[];
  7951. setIndices(indices: number[] | Int32Array, totalVertices?: number): void;
  7952. getTotalIndices(): number;
  7953. getIndices(copyWhenShared?: boolean): number[] | Int32Array;
  7954. getIndexBuffer(): WebGLBuffer;
  7955. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  7956. applyToMesh(mesh: Mesh): void;
  7957. private updateExtend(data?, stride?);
  7958. private _applyToMesh(mesh);
  7959. private notifyUpdate(kind?);
  7960. load(scene: Scene, onLoaded?: () => void): void;
  7961. /**
  7962. * Invert the geometry to move from a right handed system to a left handed one.
  7963. */
  7964. toLeftHanded(): void;
  7965. isDisposed(): boolean;
  7966. dispose(): void;
  7967. copy(id: string): Geometry;
  7968. serialize(): any;
  7969. serializeVerticeData(): any;
  7970. static ExtractFromMesh(mesh: Mesh, id: string): Geometry;
  7971. static RandomId(): string;
  7972. static ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  7973. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Geometry;
  7974. }
  7975. module Geometry.Primitives {
  7976. class _Primitive extends Geometry {
  7977. private _canBeRegenerated;
  7978. private _beingRegenerated;
  7979. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Mesh);
  7980. canBeRegenerated(): boolean;
  7981. regenerate(): void;
  7982. asNewGeometry(id: string): Geometry;
  7983. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  7984. setVerticesData(kind: string, data: number[] | Int32Array | Float32Array, updatable?: boolean): void;
  7985. _regenerateVertexData(): VertexData;
  7986. copy(id: string): Geometry;
  7987. serialize(): any;
  7988. }
  7989. class Ribbon extends _Primitive {
  7990. pathArray: Vector3[][];
  7991. closeArray: boolean;
  7992. closePath: boolean;
  7993. offset: number;
  7994. side: number;
  7995. constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  7996. _regenerateVertexData(): VertexData;
  7997. copy(id: string): Geometry;
  7998. }
  7999. class Box extends _Primitive {
  8000. size: number;
  8001. side: number;
  8002. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8003. _regenerateVertexData(): VertexData;
  8004. copy(id: string): Geometry;
  8005. serialize(): any;
  8006. static Parse(parsedBox: any, scene: Scene): Box;
  8007. }
  8008. class Sphere extends _Primitive {
  8009. segments: number;
  8010. diameter: number;
  8011. side: number;
  8012. constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8013. _regenerateVertexData(): VertexData;
  8014. copy(id: string): Geometry;
  8015. serialize(): any;
  8016. static Parse(parsedSphere: any, scene: Scene): Geometry.Primitives.Sphere;
  8017. }
  8018. class Disc extends _Primitive {
  8019. radius: number;
  8020. tessellation: number;
  8021. side: number;
  8022. constructor(id: string, scene: Scene, radius: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8023. _regenerateVertexData(): VertexData;
  8024. copy(id: string): Geometry;
  8025. }
  8026. class Cylinder extends _Primitive {
  8027. height: number;
  8028. diameterTop: number;
  8029. diameterBottom: number;
  8030. tessellation: number;
  8031. subdivisions: number;
  8032. side: number;
  8033. constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8034. _regenerateVertexData(): VertexData;
  8035. copy(id: string): Geometry;
  8036. serialize(): any;
  8037. static Parse(parsedCylinder: any, scene: Scene): Geometry.Primitives.Cylinder;
  8038. }
  8039. class Torus extends _Primitive {
  8040. diameter: number;
  8041. thickness: number;
  8042. tessellation: number;
  8043. side: number;
  8044. constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8045. _regenerateVertexData(): VertexData;
  8046. copy(id: string): Geometry;
  8047. serialize(): any;
  8048. static Parse(parsedTorus: any, scene: Scene): Geometry.Primitives.Torus;
  8049. }
  8050. class Ground extends _Primitive {
  8051. width: number;
  8052. height: number;
  8053. subdivisions: number;
  8054. constructor(id: string, scene: Scene, width: number, height: number, subdivisions: number, canBeRegenerated?: boolean, mesh?: Mesh);
  8055. _regenerateVertexData(): VertexData;
  8056. copy(id: string): Geometry;
  8057. serialize(): any;
  8058. static Parse(parsedGround: any, scene: Scene): Geometry.Primitives.Ground;
  8059. }
  8060. class TiledGround extends _Primitive {
  8061. xmin: number;
  8062. zmin: number;
  8063. xmax: number;
  8064. zmax: number;
  8065. subdivisions: {
  8066. w: number;
  8067. h: number;
  8068. };
  8069. precision: {
  8070. w: number;
  8071. h: number;
  8072. };
  8073. constructor(id: string, scene: Scene, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  8074. w: number;
  8075. h: number;
  8076. }, precision: {
  8077. w: number;
  8078. h: number;
  8079. }, canBeRegenerated?: boolean, mesh?: Mesh);
  8080. _regenerateVertexData(): VertexData;
  8081. copy(id: string): Geometry;
  8082. }
  8083. class Plane extends _Primitive {
  8084. size: number;
  8085. side: number;
  8086. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8087. _regenerateVertexData(): VertexData;
  8088. copy(id: string): Geometry;
  8089. serialize(): any;
  8090. static Parse(parsedPlane: any, scene: Scene): Geometry.Primitives.Plane;
  8091. }
  8092. class TorusKnot extends _Primitive {
  8093. radius: number;
  8094. tube: number;
  8095. radialSegments: number;
  8096. tubularSegments: number;
  8097. p: number;
  8098. q: number;
  8099. side: number;
  8100. constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8101. _regenerateVertexData(): VertexData;
  8102. copy(id: string): Geometry;
  8103. serialize(): any;
  8104. static Parse(parsedTorusKnot: any, scene: Scene): Geometry.Primitives.TorusKnot;
  8105. }
  8106. }
  8107. }
  8108. declare module BABYLON {
  8109. class GroundMesh extends Mesh {
  8110. generateOctree: boolean;
  8111. private _worldInverse;
  8112. private _heightQuads;
  8113. _subdivisions: number;
  8114. _width: number;
  8115. _height: number;
  8116. _minX: number;
  8117. _maxX: number;
  8118. _minZ: number;
  8119. _maxZ: number;
  8120. constructor(name: string, scene: Scene);
  8121. subdivisions: number;
  8122. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  8123. /**
  8124. * Returns a height (y) value in the Worl system :
  8125. * the ground altitude at the coordinates (x, z) expressed in the World system.
  8126. * Returns the ground y position if (x, z) are outside the ground surface.
  8127. * Not pertinent if the ground is rotated.
  8128. */
  8129. getHeightAtCoordinates(x: number, z: number): number;
  8130. /**
  8131. * Returns a normalized vector (Vector3) orthogonal to the ground
  8132. * at the ground coordinates (x, z) expressed in the World system.
  8133. * Returns Vector3(0, 1, 0) if (x, z) are outside the ground surface.
  8134. * Not pertinent if the ground is rotated.
  8135. */
  8136. getNormalAtCoordinates(x: number, z: number): Vector3;
  8137. /**
  8138. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  8139. * at the ground coordinates (x, z) expressed in the World system.
  8140. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  8141. * Not pertinent if the ground is rotated.
  8142. */
  8143. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): void;
  8144. /**
  8145. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  8146. * if the ground has been updated.
  8147. * This can be used in the render loop
  8148. */
  8149. updateCoordinateHeights(): void;
  8150. private _getFacetAt(x, z);
  8151. private _initHeightQuads();
  8152. private _computeHeightQuads();
  8153. }
  8154. }
  8155. declare module BABYLON {
  8156. /**
  8157. * Creates an instance based on a source mesh.
  8158. */
  8159. class InstancedMesh extends AbstractMesh {
  8160. private _sourceMesh;
  8161. private _currentLOD;
  8162. constructor(name: string, source: Mesh);
  8163. receiveShadows: boolean;
  8164. material: Material;
  8165. visibility: number;
  8166. skeleton: Skeleton;
  8167. renderingGroupId: number;
  8168. getTotalVertices(): number;
  8169. sourceMesh: Mesh;
  8170. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Float32Array;
  8171. isVerticesDataPresent(kind: string): boolean;
  8172. getIndices(): number[] | Int32Array;
  8173. _positions: Vector3[];
  8174. refreshBoundingInfo(): void;
  8175. _preActivate(): void;
  8176. _activate(renderId: number): void;
  8177. getLOD(camera: Camera): AbstractMesh;
  8178. _syncSubMeshes(): void;
  8179. _generatePointsArray(): boolean;
  8180. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  8181. dispose(doNotRecurse?: boolean): void;
  8182. }
  8183. }
  8184. declare module BABYLON {
  8185. class LinesMesh extends Mesh {
  8186. color: Color3;
  8187. alpha: number;
  8188. private _positionBuffer;
  8189. /**
  8190. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  8191. * This margin is expressed in world space coordinates, so its value may vary.
  8192. * Default value is 0.1
  8193. * @returns the intersection Threshold value.
  8194. */
  8195. /**
  8196. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  8197. * This margin is expressed in world space coordinates, so its value may vary.
  8198. * @param value the new threshold to apply
  8199. */
  8200. intersectionThreshold: number;
  8201. private _intersectionThreshold;
  8202. private _colorShader;
  8203. constructor(name: string, scene: Scene, parent?: Node, source?: LinesMesh, doNotCloneChildren?: boolean);
  8204. material: Material;
  8205. checkCollisions: boolean;
  8206. createInstance(name: string): InstancedMesh;
  8207. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  8208. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  8209. dispose(doNotRecurse?: boolean): void;
  8210. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  8211. }
  8212. }
  8213. declare module BABYLON {
  8214. class _InstancesBatch {
  8215. mustReturn: boolean;
  8216. visibleInstances: InstancedMesh[][];
  8217. renderSelf: boolean[];
  8218. }
  8219. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  8220. static _FRONTSIDE: number;
  8221. static _BACKSIDE: number;
  8222. static _DOUBLESIDE: number;
  8223. static _DEFAULTSIDE: number;
  8224. static _NO_CAP: number;
  8225. static _CAP_START: number;
  8226. static _CAP_END: number;
  8227. static _CAP_ALL: number;
  8228. /**
  8229. * Mesh side orientation : usually the external or front surface
  8230. */
  8231. static FRONTSIDE: number;
  8232. /**
  8233. * Mesh side orientation : usually the internal or back surface
  8234. */
  8235. static BACKSIDE: number;
  8236. /**
  8237. * Mesh side orientation : both internal and external or front and back surfaces
  8238. */
  8239. static DOUBLESIDE: number;
  8240. /**
  8241. * Mesh side orientation : by default, `FRONTSIDE`
  8242. */
  8243. static DEFAULTSIDE: number;
  8244. /**
  8245. * Mesh cap setting : no cap
  8246. */
  8247. static NO_CAP: number;
  8248. /**
  8249. * Mesh cap setting : one cap at the beginning of the mesh
  8250. */
  8251. static CAP_START: number;
  8252. /**
  8253. * Mesh cap setting : one cap at the end of the mesh
  8254. */
  8255. static CAP_END: number;
  8256. /**
  8257. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  8258. */
  8259. static CAP_ALL: number;
  8260. /**
  8261. * An event triggered before rendering the mesh
  8262. * @type {BABYLON.Observable}
  8263. */
  8264. onBeforeRenderObservable: Observable<Mesh>;
  8265. /**
  8266. * An event triggered after rendering the mesh
  8267. * @type {BABYLON.Observable}
  8268. */
  8269. onAfterRenderObservable: Observable<Mesh>;
  8270. /**
  8271. * An event triggered before drawing the mesh
  8272. * @type {BABYLON.Observable}
  8273. */
  8274. onBeforeDrawObservable: Observable<Mesh>;
  8275. private _onBeforeDrawObserver;
  8276. onBeforeDraw: () => void;
  8277. delayLoadState: number;
  8278. instances: InstancedMesh[];
  8279. delayLoadingFile: string;
  8280. _binaryInfo: any;
  8281. private _LODLevels;
  8282. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  8283. _geometry: Geometry;
  8284. _delayInfo: any;
  8285. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  8286. _visibleInstances: any;
  8287. private _renderIdForInstances;
  8288. private _batchCache;
  8289. private _instancesBufferSize;
  8290. private _instancesBuffer;
  8291. private _instancesData;
  8292. private _overridenInstanceCount;
  8293. _shouldGenerateFlatShading: boolean;
  8294. private _preActivateId;
  8295. private _sideOrientation;
  8296. private _areNormalsFrozen;
  8297. private _sourcePositions;
  8298. private _sourceNormals;
  8299. /**
  8300. * @constructor
  8301. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  8302. * @param {Scene} scene The scene to add this mesh to.
  8303. * @param {Node} parent The parent of this mesh, if it has one
  8304. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  8305. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  8306. * When false, achieved by calling a clone(), also passing False.
  8307. * This will make creation of children, recursive.
  8308. */
  8309. constructor(name: string, scene: Scene, parent?: Node, source?: Mesh, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  8310. /**
  8311. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8312. */
  8313. toString(fullDetails?: boolean): string;
  8314. hasLODLevels: boolean;
  8315. private _sortLODLevels();
  8316. /**
  8317. * Add a mesh as LOD level triggered at the given distance.
  8318. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8319. * @param {number} distance The distance from the center of the object to show this level
  8320. * @param {Mesh} mesh The mesh to be added as LOD level
  8321. * @return {Mesh} This mesh (for chaining)
  8322. */
  8323. addLODLevel(distance: number, mesh: Mesh): Mesh;
  8324. /**
  8325. * Returns the LOD level mesh at the passed distance or null if not found.
  8326. * It is related to the method `addLODLevel(distance, mesh)`.
  8327. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8328. */
  8329. getLODLevelAtDistance(distance: number): Mesh;
  8330. /**
  8331. * Remove a mesh from the LOD array
  8332. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8333. * @param {Mesh} mesh The mesh to be removed.
  8334. * @return {Mesh} This mesh (for chaining)
  8335. */
  8336. removeLODLevel(mesh: Mesh): Mesh;
  8337. /**
  8338. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  8339. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8340. */
  8341. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  8342. /**
  8343. * Returns the mesh internal Geometry object.
  8344. */
  8345. geometry: Geometry;
  8346. /**
  8347. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  8348. */
  8349. getTotalVertices(): number;
  8350. /**
  8351. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  8352. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  8353. * Returns null if the mesh has no geometry or no vertex buffer.
  8354. * Possible `kind` values :
  8355. * - BABYLON.VertexBuffer.PositionKind
  8356. * - BABYLON.VertexBuffer.UVKind
  8357. * - BABYLON.VertexBuffer.UV2Kind
  8358. * - BABYLON.VertexBuffer.UV3Kind
  8359. * - BABYLON.VertexBuffer.UV4Kind
  8360. * - BABYLON.VertexBuffer.UV5Kind
  8361. * - BABYLON.VertexBuffer.UV6Kind
  8362. * - BABYLON.VertexBuffer.ColorKind
  8363. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8364. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8365. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8366. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8367. */
  8368. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Float32Array;
  8369. /**
  8370. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  8371. * Returns `undefined` if the mesh has no geometry.
  8372. * Possible `kind` values :
  8373. * - BABYLON.VertexBuffer.PositionKind
  8374. * - BABYLON.VertexBuffer.UVKind
  8375. * - BABYLON.VertexBuffer.UV2Kind
  8376. * - BABYLON.VertexBuffer.UV3Kind
  8377. * - BABYLON.VertexBuffer.UV4Kind
  8378. * - BABYLON.VertexBuffer.UV5Kind
  8379. * - BABYLON.VertexBuffer.UV6Kind
  8380. * - BABYLON.VertexBuffer.ColorKind
  8381. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8382. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8383. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8384. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8385. */
  8386. getVertexBuffer(kind: any): VertexBuffer;
  8387. /**
  8388. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  8389. * Possible `kind` values :
  8390. * - BABYLON.VertexBuffer.PositionKind
  8391. * - BABYLON.VertexBuffer.UVKind
  8392. * - BABYLON.VertexBuffer.UV2Kind
  8393. * - BABYLON.VertexBuffer.UV3Kind
  8394. * - BABYLON.VertexBuffer.UV4Kind
  8395. * - BABYLON.VertexBuffer.UV5Kind
  8396. * - BABYLON.VertexBuffer.UV6Kind
  8397. * - BABYLON.VertexBuffer.ColorKind
  8398. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8399. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8400. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8401. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8402. */
  8403. isVerticesDataPresent(kind: string): boolean;
  8404. /**
  8405. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  8406. * Possible `kind` values :
  8407. * - BABYLON.VertexBuffer.PositionKind
  8408. * - BABYLON.VertexBuffer.UVKind
  8409. * - BABYLON.VertexBuffer.UV2Kind
  8410. * - BABYLON.VertexBuffer.UV3Kind
  8411. * - BABYLON.VertexBuffer.UV4Kind
  8412. * - BABYLON.VertexBuffer.UV5Kind
  8413. * - BABYLON.VertexBuffer.UV6Kind
  8414. * - BABYLON.VertexBuffer.ColorKind
  8415. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8416. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8417. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8418. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8419. */
  8420. getVerticesDataKinds(): string[];
  8421. /**
  8422. * Returns a positive integer : the total number of indices in this mesh geometry.
  8423. * Returns zero if the mesh has no geometry.
  8424. */
  8425. getTotalIndices(): number;
  8426. /**
  8427. * Returns an array of integers or a Int32Array populated with the mesh indices.
  8428. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  8429. * Returns an empty array if the mesh has no geometry.
  8430. */
  8431. getIndices(copyWhenShared?: boolean): number[] | Int32Array;
  8432. isBlocked: boolean;
  8433. /**
  8434. * Boolean : true once the mesh is ready after all the delayed process (loading, etc) are complete.
  8435. */
  8436. isReady(): boolean;
  8437. /**
  8438. * Boolean : true if the mesh has been disposed.
  8439. */
  8440. isDisposed(): boolean;
  8441. /**
  8442. * Sets the mesh side orientation : BABYLON.Mesh.FRONTSIDE, BABYLON.Mesh.BACKSIDE, BABYLON.Mesh.DOUBLESIDE or BABYLON.Mesh.DEFAULTSIDE
  8443. * tuto : http://doc.babylonjs.com/tutorials/Discover_Basic_Elements#side-orientation
  8444. */
  8445. sideOrientation: number;
  8446. /**
  8447. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  8448. * This property is pertinent only for updatable parametric shapes.
  8449. */
  8450. areNormalsFrozen: boolean;
  8451. /**
  8452. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  8453. * It has no effect at all on other shapes.
  8454. * It prevents the mesh normals from being recomputed on next `positions` array update.
  8455. */
  8456. freezeNormals(): void;
  8457. /**
  8458. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  8459. * It has no effect at all on other shapes.
  8460. * It reactivates the mesh normals computation if it was previously frozen.
  8461. */
  8462. unfreezeNormals(): void;
  8463. /**
  8464. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  8465. */
  8466. overridenInstanceCount: number;
  8467. _preActivate(): void;
  8468. _preActivateForIntermediateRendering(renderId: number): void;
  8469. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): void;
  8470. /**
  8471. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  8472. * This means the mesh underlying bounding box and sphere are recomputed.
  8473. */
  8474. refreshBoundingInfo(): void;
  8475. _createGlobalSubMesh(): SubMesh;
  8476. subdivide(count: number): void;
  8477. /**
  8478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  8479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  8480. * The `data` are either a numeric array either a Float32Array.
  8481. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  8482. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  8483. * Note that a new underlying VertexBuffer object is created each call.
  8484. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  8485. *
  8486. * Possible `kind` values :
  8487. * - BABYLON.VertexBuffer.PositionKind
  8488. * - BABYLON.VertexBuffer.UVKind
  8489. * - BABYLON.VertexBuffer.UV2Kind
  8490. * - BABYLON.VertexBuffer.UV3Kind
  8491. * - BABYLON.VertexBuffer.UV4Kind
  8492. * - BABYLON.VertexBuffer.UV5Kind
  8493. * - BABYLON.VertexBuffer.UV6Kind
  8494. * - BABYLON.VertexBuffer.ColorKind
  8495. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8496. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8497. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8498. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8499. */
  8500. setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean, stride?: number): void;
  8501. setVerticesBuffer(buffer: VertexBuffer): void;
  8502. /**
  8503. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  8504. * If the mesh has no geometry, it is simply returned as it is.
  8505. * The `data` are either a numeric array either a Float32Array.
  8506. * No new underlying VertexBuffer object is created.
  8507. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  8508. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  8509. *
  8510. * Possible `kind` values :
  8511. * - BABYLON.VertexBuffer.PositionKind
  8512. * - BABYLON.VertexBuffer.UVKind
  8513. * - BABYLON.VertexBuffer.UV2Kind
  8514. * - BABYLON.VertexBuffer.UV3Kind
  8515. * - BABYLON.VertexBuffer.UV4Kind
  8516. * - BABYLON.VertexBuffer.UV5Kind
  8517. * - BABYLON.VertexBuffer.UV6Kind
  8518. * - BABYLON.VertexBuffer.ColorKind
  8519. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8520. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8521. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8522. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8523. */
  8524. updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean, makeItUnique?: boolean): void;
  8525. /**
  8526. * Deprecated since BabylonJS v2.3
  8527. */
  8528. updateVerticesDataDirectly(kind: string, data: Float32Array, offset?: number, makeItUnique?: boolean): void;
  8529. /**
  8530. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  8531. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  8532. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  8533. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  8534. */
  8535. updateMeshPositions(positionFunction: any, computeNormals?: boolean): void;
  8536. makeGeometryUnique(): void;
  8537. /**
  8538. * Sets the mesh indices.
  8539. * Expects an array populated with integers or a Int32Array.
  8540. * If the mesh has no geometry, a new `Geometry` object is created and set to the mesh.
  8541. * This method creates a new index buffer each call.
  8542. */
  8543. setIndices(indices: number[] | Int32Array, totalVertices?: number): void;
  8544. /**
  8545. * Invert the geometry to move from a right handed system to a left handed one.
  8546. */
  8547. toLeftHanded(): void;
  8548. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  8549. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  8550. /**
  8551. * Registers for this mesh a javascript function called just before the rendering process.
  8552. * This function is passed the current mesh and doesn't return anything.
  8553. */
  8554. registerBeforeRender(func: (mesh: AbstractMesh) => void): void;
  8555. /**
  8556. * Disposes a previously registered javascript function called before the rendering.
  8557. * This function is passed the current mesh and doesn't return anything.
  8558. */
  8559. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void;
  8560. /**
  8561. * Registers for this mesh a javascript function called just after the rendering is complete.
  8562. * This function is passed the current mesh and doesn't return anything.
  8563. */
  8564. registerAfterRender(func: (mesh: AbstractMesh) => void): void;
  8565. /**
  8566. * Disposes a previously registered javascript function called after the rendering.
  8567. * This function is passed the current mesh and doesn't return anything.
  8568. */
  8569. unregisterAfterRender(func: (mesh: AbstractMesh) => void): void;
  8570. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  8571. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
  8572. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix) => void): void;
  8573. /**
  8574. * Triggers the draw call for the mesh.
  8575. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  8576. */
  8577. render(subMesh: SubMesh, enableAlphaMode: boolean): void;
  8578. /**
  8579. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  8580. */
  8581. getEmittedParticleSystems(): ParticleSystem[];
  8582. /**
  8583. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  8584. */
  8585. getHierarchyEmittedParticleSystems(): ParticleSystem[];
  8586. _checkDelayState(): void;
  8587. /**
  8588. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  8589. */
  8590. isInFrustum(frustumPlanes: Plane[]): boolean;
  8591. /**
  8592. * Sets the mesh material by the material or multiMaterial `id` property.
  8593. * The material `id` is a string identifying the material or the multiMaterial.
  8594. * This method returns nothing.
  8595. */
  8596. setMaterialByID(id: string): void;
  8597. /**
  8598. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  8599. */
  8600. getAnimatables(): IAnimatable[];
  8601. /**
  8602. * Modifies the mesh geometry according to the passed transformation matrix.
  8603. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  8604. * The mesh normals are modified accordingly the same transformation.
  8605. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  8606. * Note that, under the hood, this method sets a new VertexBuffer each call.
  8607. */
  8608. bakeTransformIntoVertices(transform: Matrix): void;
  8609. /**
  8610. * Modifies the mesh geometry according to its own current World Matrix.
  8611. * The mesh World Matrix is then reset.
  8612. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  8613. * tuto : tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  8614. * Note that, under the hood, this method sets a new VertexBuffer each call.
  8615. */
  8616. bakeCurrentTransformIntoVertices(): void;
  8617. _resetPointsArrayCache(): void;
  8618. _generatePointsArray(): boolean;
  8619. /**
  8620. * Returns a new Mesh object generated from the current mesh properties.
  8621. * This method must not get confused with createInstance().
  8622. * The parameter `name` is a string, the name given to the new mesh.
  8623. * The optional parameter `newParent` can be any `Node` object (default `null`).
  8624. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  8625. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  8626. */
  8627. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  8628. /**
  8629. * Disposes the mesh.
  8630. * This also frees the memory allocated under the hood to all the buffers used by WebGL.
  8631. */
  8632. dispose(doNotRecurse?: boolean): void;
  8633. /**
  8634. * Modifies the mesh geometry according to a displacement map.
  8635. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  8636. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  8637. * This method returns nothing.
  8638. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  8639. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  8640. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  8641. */
  8642. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void): void;
  8643. /**
  8644. * Modifies the mesh geometry according to a displacementMap buffer.
  8645. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  8646. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  8647. * This method returns nothing.
  8648. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  8649. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  8650. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  8651. */
  8652. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number): void;
  8653. /**
  8654. * Modify the mesh to get a flat shading rendering.
  8655. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  8656. * This method returns nothing.
  8657. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  8658. */
  8659. convertToFlatShadedMesh(): void;
  8660. /**
  8661. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  8662. * In other words, more vertices, no more indices and a single bigger VBO.
  8663. * This method returns nothing.
  8664. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  8665. *
  8666. */
  8667. convertToUnIndexedMesh(): void;
  8668. /**
  8669. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  8670. * This method returns nothing.
  8671. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  8672. */
  8673. flipFaces(flipNormals?: boolean): void;
  8674. /**
  8675. * Creates a new InstancedMesh object from the mesh model.
  8676. * An instance shares the same properties and the same material than its model.
  8677. * Only these properties of each instance can then be set individually :
  8678. * - position
  8679. * - rotation
  8680. * - rotationQuaternion
  8681. * - setPivotMatrix
  8682. * - scaling
  8683. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  8684. * Warning : this method is not supported for Line mesh and LineSystem
  8685. */
  8686. createInstance(name: string): InstancedMesh;
  8687. /**
  8688. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  8689. * After this call, all the mesh instances have the same submeshes than the current mesh.
  8690. * This method returns nothing.
  8691. */
  8692. synchronizeInstances(): void;
  8693. /**
  8694. * Simplify the mesh according to the given array of settings.
  8695. * Function will return immediately and will simplify async. It returns nothing.
  8696. * @param settings a collection of simplification settings.
  8697. * @param parallelProcessing should all levels calculate parallel or one after the other.
  8698. * @param type the type of simplification to run.
  8699. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  8700. */
  8701. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): void;
  8702. /**
  8703. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  8704. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  8705. * This should be used together with the simplification to avoid disappearing triangles.
  8706. * @param successCallback an optional success callback to be called after the optimization finished.
  8707. */
  8708. optimizeIndices(successCallback?: (mesh?: Mesh) => void): void;
  8709. /**
  8710. * Returns a new Mesh object what is a deep copy of the passed mesh.
  8711. * The parameter `parsedMesh` is the mesh to be copied.
  8712. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8713. */
  8714. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  8715. /**
  8716. * Creates a ribbon mesh.
  8717. * Please consider using the same method from the MeshBuilder class instead.
  8718. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  8719. *
  8720. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  8721. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  8722. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  8723. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  8724. * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path.
  8725. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  8726. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  8727. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8728. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8729. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8730. */
  8731. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  8732. /**
  8733. * Creates a plane polygonal mesh. By default, this is a disc.
  8734. * Please consider using the same method from the MeshBuilder class instead.
  8735. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  8736. * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
  8737. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8738. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8739. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8740. */
  8741. static CreateDisc(name: string, radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8742. /**
  8743. * Creates a box mesh.
  8744. * Please consider using the same method from the MeshBuilder class instead.
  8745. * The parameter `size` sets the size (float) of each box side (default 1).
  8746. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8747. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8748. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8749. */
  8750. static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8751. /**
  8752. * Creates a sphere mesh.
  8753. * Please consider using the same method from the MeshBuilder class instead.
  8754. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  8755. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  8756. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8757. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8758. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8759. */
  8760. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8761. /**
  8762. * Creates a cylinder or a cone mesh.
  8763. * Please consider using the same method from the MeshBuilder class instead.
  8764. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  8765. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  8766. * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  8767. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  8768. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  8769. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8770. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8771. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8772. */
  8773. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
  8774. /**
  8775. * Creates a torus mesh.
  8776. * Please consider using the same method from the MeshBuilder class instead.
  8777. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  8778. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  8779. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  8780. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8781. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8782. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8783. */
  8784. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8785. /**
  8786. * Creates a torus knot mesh.
  8787. * Please consider using the same method from the MeshBuilder class instead.
  8788. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  8789. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  8790. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  8791. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  8792. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8793. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8794. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8795. */
  8796. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8797. /**
  8798. * Creates a line mesh.
  8799. * Please consider using the same method from the MeshBuilder class instead.
  8800. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  8801. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  8802. * The parameter `points` is an array successive Vector3.
  8803. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  8804. * When updating an instance, remember that only point positions can change, not the number of points.
  8805. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8806. */
  8807. static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  8808. /**
  8809. * Creates a dashed line mesh.
  8810. * Please consider using the same method from the MeshBuilder class instead.
  8811. * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  8812. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  8813. * The parameter `points` is an array successive Vector3.
  8814. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  8815. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  8816. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  8817. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  8818. * When updating an instance, remember that only point positions can change, not the number of points.
  8819. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8820. */
  8821. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  8822. /**
  8823. * Creates an extruded shape mesh.
  8824. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  8825. * Please consider using the same method from the MeshBuilder class instead.
  8826. *
  8827. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  8828. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  8829. * extruded along the Z axis.
  8830. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  8831. * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  8832. * The parameter `scale` (float, default 1) is the value to scale the shape.
  8833. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  8834. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  8835. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  8836. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8837. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8838. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8839. */
  8840. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  8841. /**
  8842. * Creates an custom extruded shape mesh.
  8843. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  8844. * Please consider using the same method from the MeshBuilder class instead.
  8845. *
  8846. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  8847. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  8848. * extruded along the Z axis.
  8849. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  8850. * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  8851. * and the distance of this point from the begining of the path :
  8852. * ```javascript
  8853. * var rotationFunction = function(i, distance) {
  8854. * // do things
  8855. * return rotationValue; }
  8856. * ```
  8857. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  8858. * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  8859. * and the distance of this point from the begining of the path :
  8860. * ```javascript
  8861. * var scaleFunction = function(i, distance) {
  8862. * // do things
  8863. * return scaleValue;}
  8864. * ```
  8865. * It must returns a float value that will be the scale value applied to the shape on each path point.
  8866. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  8867. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  8868. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  8869. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  8870. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  8871. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8872. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8873. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8874. */
  8875. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  8876. /**
  8877. * Creates lathe mesh.
  8878. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  8879. * Please consider using the same method from the MeshBuilder class instead.
  8880. *
  8881. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be
  8882. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  8883. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  8884. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  8885. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8886. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8887. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8888. */
  8889. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8890. /**
  8891. * Creates a plane mesh.
  8892. * Please consider using the same method from the MeshBuilder class instead.
  8893. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  8894. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8895. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8896. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8897. */
  8898. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  8899. /**
  8900. * Creates a ground mesh.
  8901. * Please consider using the same method from the MeshBuilder class instead.
  8902. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  8903. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  8904. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8905. */
  8906. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene: Scene, updatable?: boolean): Mesh;
  8907. /**
  8908. * Creates a tiled ground mesh.
  8909. * Please consider using the same method from the MeshBuilder class instead.
  8910. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  8911. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  8912. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  8913. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  8914. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  8915. * numbers of subdivisions on the ground width and height of each tile.
  8916. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8917. */
  8918. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  8919. w: number;
  8920. h: number;
  8921. }, precision: {
  8922. w: number;
  8923. h: number;
  8924. }, scene: Scene, updatable?: boolean): Mesh;
  8925. /**
  8926. * Creates a ground mesh from a height map.
  8927. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  8928. * Please consider using the same method from the MeshBuilder class instead.
  8929. * The parameter `url` sets the URL of the height map image resource.
  8930. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  8931. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  8932. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  8933. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  8934. * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  8935. * This function is passed the newly built mesh :
  8936. * ```javascript
  8937. * function(mesh) { // do things
  8938. * return; }
  8939. * ```
  8940. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8941. */
  8942. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  8943. /**
  8944. * Creates a tube mesh.
  8945. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  8946. *
  8947. * Please consider using the same method from the MeshBuilder class instead.
  8948. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  8949. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  8950. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  8951. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  8952. * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path.
  8953. * It must return a radius value (positive float) :
  8954. * ```javascript
  8955. * var radiusFunction = function(i, distance) {
  8956. * // do things
  8957. * return radius; }
  8958. * ```
  8959. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  8960. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  8961. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8962. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8963. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8964. */
  8965. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  8966. (i: number, distance: number): number;
  8967. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  8968. /**
  8969. * Creates a polyhedron mesh.
  8970. *
  8971. * Please consider using the same method from the MeshBuilder class instead.
  8972. * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial
  8973. * to choose the wanted type.
  8974. * The parameter `size` (positive float, default 1) sets the polygon size.
  8975. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  8976. * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`.
  8977. * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  8978. * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`).
  8979. * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  8980. * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored.
  8981. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  8982. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  8983. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  8984. */
  8985. static CreatePolyhedron(name: string, options: {
  8986. type?: number;
  8987. size?: number;
  8988. sizeX?: number;
  8989. sizeY?: number;
  8990. sizeZ?: number;
  8991. custom?: any;
  8992. faceUV?: Vector4[];
  8993. faceColors?: Color4[];
  8994. updatable?: boolean;
  8995. sideOrientation?: number;
  8996. }, scene: Scene): Mesh;
  8997. /**
  8998. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  8999. * Please consider using the same method from the MeshBuilder class instead.
  9000. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  9001. * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`).
  9002. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  9003. * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
  9004. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9005. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9006. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9007. */
  9008. static CreateIcoSphere(name: string, options: {
  9009. radius?: number;
  9010. flat?: boolean;
  9011. subdivisions?: number;
  9012. sideOrientation?: number;
  9013. updatable?: boolean;
  9014. }, scene: Scene): Mesh;
  9015. /**
  9016. * Creates a decal mesh.
  9017. * Please consider using the same method from the MeshBuilder class instead.
  9018. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal.
  9019. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  9020. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  9021. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  9022. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  9023. */
  9024. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  9025. /**
  9026. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  9027. */
  9028. setPositionsForCPUSkinning(): Float32Array;
  9029. /**
  9030. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  9031. */
  9032. setNormalsForCPUSkinning(): Float32Array;
  9033. /**
  9034. * Update the vertex buffers by applying transformation from the bones
  9035. * @param {skeleton} skeleton to apply
  9036. */
  9037. applySkeleton(skeleton: Skeleton): Mesh;
  9038. /**
  9039. * Returns an object `{min: Vector3, max: Vector3}`
  9040. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  9041. */
  9042. static MinMax(meshes: AbstractMesh[]): {
  9043. min: Vector3;
  9044. max: Vector3;
  9045. };
  9046. /**
  9047. * Returns a `Vector3`, the center of the `{min: Vector3, max: Vector3}` or the center of MinMax vector3 computed from a mesh array.
  9048. */
  9049. static Center(meshesOrMinMaxVector: any): Vector3;
  9050. /**
  9051. * Merge the array of meshes into a single mesh for performance reasons.
  9052. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  9053. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  9054. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  9055. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  9056. */
  9057. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh;
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. interface IGetSetVerticesData {
  9062. isVerticesDataPresent(kind: string): boolean;
  9063. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Int32Array | Float32Array;
  9064. getIndices(copyWhenShared?: boolean): number[] | Int32Array;
  9065. setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean): void;
  9066. updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean, makeItUnique?: boolean): void;
  9067. setIndices(indices: number[] | Int32Array): void;
  9068. }
  9069. class VertexData {
  9070. positions: number[] | Float32Array;
  9071. normals: number[] | Float32Array;
  9072. uvs: number[] | Float32Array;
  9073. uvs2: number[] | Float32Array;
  9074. uvs3: number[] | Float32Array;
  9075. uvs4: number[] | Float32Array;
  9076. uvs5: number[] | Float32Array;
  9077. uvs6: number[] | Float32Array;
  9078. colors: number[] | Float32Array;
  9079. matricesIndices: number[] | Float32Array;
  9080. matricesWeights: number[] | Float32Array;
  9081. matricesIndicesExtra: number[] | Float32Array;
  9082. matricesWeightsExtra: number[] | Float32Array;
  9083. indices: number[] | Int32Array;
  9084. set(data: number[] | Float32Array, kind: string): void;
  9085. applyToMesh(mesh: Mesh, updatable?: boolean): void;
  9086. applyToGeometry(geometry: Geometry, updatable?: boolean): void;
  9087. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): void;
  9088. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): void;
  9089. private _applyTo(meshOrGeometry, updatable?);
  9090. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  9091. transform(matrix: Matrix): void;
  9092. merge(other: VertexData): void;
  9093. private _mergeElement(source, other);
  9094. serialize(): any;
  9095. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean): VertexData;
  9096. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean): VertexData;
  9097. private static _ExtractFrom(meshOrGeometry, copyWhenShared?);
  9098. static CreateRibbon(options: {
  9099. pathArray: Vector3[][];
  9100. closeArray?: boolean;
  9101. closePath?: boolean;
  9102. offset?: number;
  9103. sideOrientation?: number;
  9104. }): VertexData;
  9105. static CreateBox(options: {
  9106. size?: number;
  9107. width?: number;
  9108. height?: number;
  9109. depth?: number;
  9110. faceUV?: Vector4[];
  9111. faceColors?: Color4[];
  9112. sideOrientation?: number;
  9113. }): VertexData;
  9114. static CreateSphere(options: {
  9115. segments?: number;
  9116. diameter?: number;
  9117. diameterX?: number;
  9118. diameterY?: number;
  9119. diameterZ?: number;
  9120. arc?: number;
  9121. slice?: number;
  9122. sideOrientation?: number;
  9123. }): VertexData;
  9124. static CreateCylinder(options: {
  9125. height?: number;
  9126. diameterTop?: number;
  9127. diameterBottom?: number;
  9128. diameter?: number;
  9129. tessellation?: number;
  9130. subdivisions?: number;
  9131. arc?: number;
  9132. faceColors?: Color4[];
  9133. faceUV?: Vector4[];
  9134. hasRings?: boolean;
  9135. enclose?: boolean;
  9136. sideOrientation?: number;
  9137. }): VertexData;
  9138. static CreateTorus(options: {
  9139. diameter?: number;
  9140. thickness?: number;
  9141. tessellation?: number;
  9142. sideOrientation?: number;
  9143. }): VertexData;
  9144. static CreateLineSystem(options: {
  9145. lines: Vector3[][];
  9146. }): VertexData;
  9147. static CreateDashedLines(options: {
  9148. points: Vector3[];
  9149. dashSize?: number;
  9150. gapSize?: number;
  9151. dashNb?: number;
  9152. }): VertexData;
  9153. static CreateGround(options: {
  9154. width?: number;
  9155. height?: number;
  9156. subdivisions?: number;
  9157. }): VertexData;
  9158. static CreateTiledGround(options: {
  9159. xmin: number;
  9160. zmin: number;
  9161. xmax: number;
  9162. zmax: number;
  9163. subdivisions?: {
  9164. w: number;
  9165. h: number;
  9166. };
  9167. precision?: {
  9168. w: number;
  9169. h: number;
  9170. };
  9171. }): VertexData;
  9172. static CreateGroundFromHeightMap(options: {
  9173. width: number;
  9174. height: number;
  9175. subdivisions: number;
  9176. minHeight: number;
  9177. maxHeight: number;
  9178. buffer: Uint8Array;
  9179. bufferWidth: number;
  9180. bufferHeight: number;
  9181. }): VertexData;
  9182. static CreatePlane(options: {
  9183. size?: number;
  9184. width?: number;
  9185. height?: number;
  9186. sideOrientation?: number;
  9187. }): VertexData;
  9188. static CreateDisc(options: {
  9189. radius?: number;
  9190. tessellation?: number;
  9191. arc?: number;
  9192. sideOrientation?: number;
  9193. }): VertexData;
  9194. static CreateIcoSphere(options: {
  9195. radius?: number;
  9196. radiusX?: number;
  9197. radiusY?: number;
  9198. radiusZ?: number;
  9199. flat?: boolean;
  9200. subdivisions?: number;
  9201. sideOrientation?: number;
  9202. }): VertexData;
  9203. static CreatePolyhedron(options: {
  9204. type?: number;
  9205. size?: number;
  9206. sizeX?: number;
  9207. sizeY?: number;
  9208. sizeZ?: number;
  9209. custom?: any;
  9210. faceUV?: Vector4[];
  9211. faceColors?: Color4[];
  9212. flat?: boolean;
  9213. sideOrientation?: number;
  9214. }): VertexData;
  9215. static CreateTorusKnot(options: {
  9216. radius?: number;
  9217. tube?: number;
  9218. radialSegments?: number;
  9219. tubularSegments?: number;
  9220. p?: number;
  9221. q?: number;
  9222. sideOrientation?: number;
  9223. }): VertexData;
  9224. /**
  9225. * @param {any} - positions (number[] or Float32Array)
  9226. * @param {any} - indices (number[] or Uint16Array)
  9227. * @param {any} - normals (number[] or Float32Array)
  9228. */
  9229. static ComputeNormals(positions: any, indices: any, normals: any): void;
  9230. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs);
  9231. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  9232. }
  9233. }
  9234. declare module BABYLON {
  9235. class MeshBuilder {
  9236. /**
  9237. * Creates a box mesh.
  9238. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  9239. * The parameter `size` sets the size (float) of each box side (default 1).
  9240. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  9241. * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements).
  9242. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  9243. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9244. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9245. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9246. */
  9247. static CreateBox(name: string, options: {
  9248. size?: number;
  9249. width?: number;
  9250. height?: number;
  9251. depth?: number;
  9252. faceUV?: Vector4[];
  9253. faceColors?: Color4[];
  9254. sideOrientation?: number;
  9255. updatable?: boolean;
  9256. }, scene: Scene): Mesh;
  9257. /**
  9258. * Creates a sphere mesh.
  9259. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  9260. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  9261. * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value than `diameter`).
  9262. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  9263. * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  9264. * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude).
  9265. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9266. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9267. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9268. */
  9269. static CreateSphere(name: string, options: {
  9270. segments?: number;
  9271. diameter?: number;
  9272. diameterX?: number;
  9273. diameterY?: number;
  9274. diameterZ?: number;
  9275. arc?: number;
  9276. slice?: number;
  9277. sideOrientation?: number;
  9278. updatable?: boolean;
  9279. }, scene: any): Mesh;
  9280. /**
  9281. * Creates a plane polygonal mesh. By default, this is a disc.
  9282. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  9283. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  9284. * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
  9285. * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  9286. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9287. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9288. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9289. */
  9290. static CreateDisc(name: string, options: {
  9291. radius?: number;
  9292. tessellation?: number;
  9293. arc?: number;
  9294. updatable?: boolean;
  9295. sideOrientation?: number;
  9296. }, scene: Scene): Mesh;
  9297. /**
  9298. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  9299. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  9300. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  9301. * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`).
  9302. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  9303. * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
  9304. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9305. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9306. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9307. */
  9308. static CreateIcoSphere(name: string, options: {
  9309. radius?: number;
  9310. radiusX?: number;
  9311. radiusY?: number;
  9312. radiusZ?: number;
  9313. flat?: boolean;
  9314. subdivisions?: number;
  9315. sideOrientation?: number;
  9316. updatable?: boolean;
  9317. }, scene: Scene): Mesh;
  9318. /**
  9319. * Creates a ribbon mesh.
  9320. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9321. *
  9322. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  9323. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  9324. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  9325. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  9326. * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path.
  9327. * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  9328. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  9329. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9330. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9331. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9332. */
  9333. static CreateRibbon(name: string, options: {
  9334. pathArray: Vector3[][];
  9335. closeArray?: boolean;
  9336. closePath?: boolean;
  9337. offset?: number;
  9338. updatable?: boolean;
  9339. sideOrientation?: number;
  9340. instance?: Mesh;
  9341. }, scene?: Scene): Mesh;
  9342. /**
  9343. * Creates a cylinder or a cone mesh.
  9344. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  9345. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  9346. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  9347. * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  9348. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  9349. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  9350. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  9351. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  9352. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  9353. * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  9354. * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  9355. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  9356. * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  9357. * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  9358. * If `enclose` is false, a ring surface is one element.
  9359. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  9360. * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  9361. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9362. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9363. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9364. */
  9365. static CreateCylinder(name: string, options: {
  9366. height?: number;
  9367. diameterTop?: number;
  9368. diameterBottom?: number;
  9369. diameter?: number;
  9370. tessellation?: number;
  9371. subdivisions?: number;
  9372. arc?: number;
  9373. faceColors?: Color4[];
  9374. faceUV?: Vector4[];
  9375. updatable?: boolean;
  9376. hasRings?: boolean;
  9377. enclose?: boolean;
  9378. sideOrientation?: number;
  9379. }, scene: any): Mesh;
  9380. /**
  9381. * Creates a torus mesh.
  9382. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  9383. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  9384. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  9385. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  9386. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9387. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9388. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9389. */
  9390. static CreateTorus(name: string, options: {
  9391. diameter?: number;
  9392. thickness?: number;
  9393. tessellation?: number;
  9394. updatable?: boolean;
  9395. sideOrientation?: number;
  9396. }, scene: any): Mesh;
  9397. /**
  9398. * Creates a torus knot mesh.
  9399. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  9400. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  9401. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  9402. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  9403. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  9404. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9405. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9406. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9407. */
  9408. static CreateTorusKnot(name: string, options: {
  9409. radius?: number;
  9410. tube?: number;
  9411. radialSegments?: number;
  9412. tubularSegments?: number;
  9413. p?: number;
  9414. q?: number;
  9415. updatable?: boolean;
  9416. sideOrientation?: number;
  9417. }, scene: any): Mesh;
  9418. /**
  9419. * Creates a line system mesh.
  9420. * A line system is a pool of many lines gathered in a single mesh.
  9421. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  9422. * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter.
  9423. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  9424. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  9425. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  9426. * updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9427. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  9428. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9429. */
  9430. static CreateLineSystem(name: string, options: {
  9431. lines: Vector3[][];
  9432. updatable: boolean;
  9433. instance?: LinesMesh;
  9434. }, scene: Scene): LinesMesh;
  9435. /**
  9436. * Creates a line mesh.
  9437. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  9438. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  9439. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  9440. * The parameter `points` is an array successive Vector3.
  9441. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9442. * When updating an instance, remember that only point positions can change, not the number of points.
  9443. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9444. */
  9445. static CreateLines(name: string, options: {
  9446. points: Vector3[];
  9447. updatable?: boolean;
  9448. instance?: LinesMesh;
  9449. }, scene: Scene): LinesMesh;
  9450. /**
  9451. * Creates a dashed line mesh.
  9452. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  9453. * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  9454. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  9455. * The parameter `points` is an array successive Vector3.
  9456. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  9457. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  9458. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  9459. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9460. * When updating an instance, remember that only point positions can change, not the number of points.
  9461. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9462. */
  9463. static CreateDashedLines(name: string, options: {
  9464. points: Vector3[];
  9465. dashSize?: number;
  9466. gapSize?: number;
  9467. dashNb?: number;
  9468. updatable?: boolean;
  9469. instance?: LinesMesh;
  9470. }, scene: Scene): LinesMesh;
  9471. /**
  9472. * Creates an extruded shape mesh.
  9473. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9474. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  9475. *
  9476. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  9477. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  9478. * extruded along the Z axis.
  9479. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  9480. * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  9481. * The parameter `scale` (float, default 1) is the value to scale the shape.
  9482. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9483. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  9484. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  9485. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9486. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9487. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9488. */
  9489. static ExtrudeShape(name: string, options: {
  9490. shape: Vector3[];
  9491. path: Vector3[];
  9492. scale?: number;
  9493. rotation?: number;
  9494. cap?: number;
  9495. updatable?: boolean;
  9496. sideOrientation?: number;
  9497. instance?: Mesh;
  9498. }, scene: Scene): Mesh;
  9499. /**
  9500. * Creates an custom extruded shape mesh.
  9501. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9502. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  9503. *
  9504. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  9505. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  9506. * extruded along the Z axis.
  9507. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  9508. * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  9509. * and the distance of this point from the begining of the path :
  9510. * ```javascript
  9511. * var rotationFunction = function(i, distance) {
  9512. * // do things
  9513. * return rotationValue; }
  9514. * ```
  9515. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  9516. * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  9517. * and the distance of this point from the begining of the path :
  9518. * ```javascript
  9519. * var scaleFunction = function(i, distance) {
  9520. * // do things
  9521. * return scaleValue;}
  9522. * ```
  9523. * It must returns a float value that will be the scale value applied to the shape on each path point.
  9524. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  9525. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  9526. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9527. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  9528. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  9529. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9530. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9532. */
  9533. static ExtrudeShapeCustom(name: string, options: {
  9534. shape: Vector3[];
  9535. path: Vector3[];
  9536. scaleFunction?: any;
  9537. rotationFunction?: any;
  9538. ribbonCloseArray?: boolean;
  9539. ribbonClosePath?: boolean;
  9540. cap?: number;
  9541. updatable?: boolean;
  9542. sideOrientation?: number;
  9543. instance?: Mesh;
  9544. }, scene: Scene): Mesh;
  9545. /**
  9546. * Creates lathe mesh.
  9547. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  9548. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  9549. *
  9550. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be
  9551. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  9552. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  9553. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  9554. * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape.
  9555. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  9556. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9557. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9558. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9559. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9560. */
  9561. static CreateLathe(name: string, options: {
  9562. shape: Vector3[];
  9563. radius?: number;
  9564. tessellation?: number;
  9565. arc?: number;
  9566. closed?: boolean;
  9567. updatable?: boolean;
  9568. sideOrientation?: number;
  9569. cap?: number;
  9570. }, scene: Scene): Mesh;
  9571. /**
  9572. * Creates a plane mesh.
  9573. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  9574. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  9575. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  9576. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  9577. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9578. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9579. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9580. */
  9581. static CreatePlane(name: string, options: {
  9582. size?: number;
  9583. width?: number;
  9584. height?: number;
  9585. sideOrientation?: number;
  9586. updatable?: boolean;
  9587. sourcePlane?: Plane;
  9588. }, scene: Scene): Mesh;
  9589. /**
  9590. * Creates a ground mesh.
  9591. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  9592. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  9593. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  9594. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9595. */
  9596. static CreateGround(name: string, options: {
  9597. width?: number;
  9598. height?: number;
  9599. subdivisions?: number;
  9600. updatable?: boolean;
  9601. }, scene: any): Mesh;
  9602. /**
  9603. * Creates a tiled ground mesh.
  9604. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  9605. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  9606. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  9607. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  9608. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  9609. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  9610. * numbers of subdivisions on the ground width and height of each tile.
  9611. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9612. */
  9613. static CreateTiledGround(name: string, options: {
  9614. xmin: number;
  9615. zmin: number;
  9616. xmax: number;
  9617. zmax: number;
  9618. subdivisions?: {
  9619. w: number;
  9620. h: number;
  9621. };
  9622. precision?: {
  9623. w: number;
  9624. h: number;
  9625. };
  9626. updatable?: boolean;
  9627. }, scene: Scene): Mesh;
  9628. /**
  9629. * Creates a ground mesh from a height map.
  9630. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  9631. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  9632. * The parameter `url` sets the URL of the height map image resource.
  9633. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  9634. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  9635. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  9636. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  9637. * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  9638. * This function is passed the newly built mesh :
  9639. * ```javascript
  9640. * function(mesh) { // do things
  9641. * return; }
  9642. * ```
  9643. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9644. */
  9645. static CreateGroundFromHeightMap(name: string, url: string, options: {
  9646. width?: number;
  9647. height?: number;
  9648. subdivisions?: number;
  9649. minHeight?: number;
  9650. maxHeight?: number;
  9651. updatable?: boolean;
  9652. onReady?: (mesh: GroundMesh) => void;
  9653. }, scene: Scene): GroundMesh;
  9654. /**
  9655. * Creates a tube mesh.
  9656. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9657. *
  9658. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  9659. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  9660. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  9661. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  9662. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  9663. * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path.
  9664. * It must return a radius value (positive float) :
  9665. * ```javascript
  9666. * var radiusFunction = function(i, distance) {
  9667. * // do things
  9668. * return radius; }
  9669. * ```
  9670. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  9671. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9672. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  9673. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9674. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9675. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9676. */
  9677. static CreateTube(name: string, options: {
  9678. path: Vector3[];
  9679. radius?: number;
  9680. tessellation?: number;
  9681. radiusFunction?: {
  9682. (i: number, distance: number): number;
  9683. };
  9684. cap?: number;
  9685. arc?: number;
  9686. updatable?: boolean;
  9687. sideOrientation?: number;
  9688. instance?: Mesh;
  9689. }, scene: Scene): Mesh;
  9690. /**
  9691. * Creates a polyhedron mesh.
  9692. *
  9693. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  9694. * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial
  9695. * to choose the wanted type.
  9696. * The parameter `size` (positive float, default 1) sets the polygon size.
  9697. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  9698. * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`.
  9699. * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  9700. * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`).
  9701. * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  9702. * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored.
  9703. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9704. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9705. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9706. */
  9707. static CreatePolyhedron(name: string, options: {
  9708. type?: number;
  9709. size?: number;
  9710. sizeX?: number;
  9711. sizeY?: number;
  9712. sizeZ?: number;
  9713. custom?: any;
  9714. faceUV?: Vector4[];
  9715. faceColors?: Color4[];
  9716. flat?: boolean;
  9717. updatable?: boolean;
  9718. sideOrientation?: number;
  9719. }, scene: Scene): Mesh;
  9720. /**
  9721. * Creates a decal mesh.
  9722. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  9723. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal.
  9724. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  9725. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  9726. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  9727. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  9728. */
  9729. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  9730. position?: Vector3;
  9731. normal?: Vector3;
  9732. size?: Vector3;
  9733. angle?: number;
  9734. }): Mesh;
  9735. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance);
  9736. }
  9737. }
  9738. declare module BABYLON.Internals {
  9739. class MeshLODLevel {
  9740. distance: number;
  9741. mesh: Mesh;
  9742. constructor(distance: number, mesh: Mesh);
  9743. }
  9744. }
  9745. declare module BABYLON {
  9746. /**
  9747. * A simplifier interface for future simplification implementations.
  9748. */
  9749. interface ISimplifier {
  9750. /**
  9751. * Simplification of a given mesh according to the given settings.
  9752. * Since this requires computation, it is assumed that the function runs async.
  9753. * @param settings The settings of the simplification, including quality and distance
  9754. * @param successCallback A callback that will be called after the mesh was simplified.
  9755. * @param errorCallback in case of an error, this callback will be called. optional.
  9756. */
  9757. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  9758. }
  9759. /**
  9760. * Expected simplification settings.
  9761. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  9762. */
  9763. interface ISimplificationSettings {
  9764. quality: number;
  9765. distance: number;
  9766. optimizeMesh?: boolean;
  9767. }
  9768. class SimplificationSettings implements ISimplificationSettings {
  9769. quality: number;
  9770. distance: number;
  9771. optimizeMesh: boolean;
  9772. constructor(quality: number, distance: number, optimizeMesh?: boolean);
  9773. }
  9774. interface ISimplificationTask {
  9775. settings: Array<ISimplificationSettings>;
  9776. simplificationType: SimplificationType;
  9777. mesh: Mesh;
  9778. successCallback?: () => void;
  9779. parallelProcessing: boolean;
  9780. }
  9781. class SimplificationQueue {
  9782. private _simplificationArray;
  9783. running: any;
  9784. constructor();
  9785. addTask(task: ISimplificationTask): void;
  9786. executeNext(): void;
  9787. runSimplification(task: ISimplificationTask): void;
  9788. private getSimplifier(task);
  9789. }
  9790. /**
  9791. * The implemented types of simplification.
  9792. * At the moment only Quadratic Error Decimation is implemented.
  9793. */
  9794. enum SimplificationType {
  9795. QUADRATIC = 0,
  9796. }
  9797. class DecimationTriangle {
  9798. vertices: Array<DecimationVertex>;
  9799. normal: Vector3;
  9800. error: Array<number>;
  9801. deleted: boolean;
  9802. isDirty: boolean;
  9803. borderFactor: number;
  9804. deletePending: boolean;
  9805. originalOffset: number;
  9806. constructor(vertices: Array<DecimationVertex>);
  9807. }
  9808. class DecimationVertex {
  9809. position: Vector3;
  9810. id: any;
  9811. q: QuadraticMatrix;
  9812. isBorder: boolean;
  9813. triangleStart: number;
  9814. triangleCount: number;
  9815. originalOffsets: Array<number>;
  9816. constructor(position: Vector3, id: any);
  9817. updatePosition(newPosition: Vector3): void;
  9818. }
  9819. class QuadraticMatrix {
  9820. data: Array<number>;
  9821. constructor(data?: Array<number>);
  9822. det(a11: any, a12: any, a13: any, a21: any, a22: any, a23: any, a31: any, a32: any, a33: any): number;
  9823. addInPlace(matrix: QuadraticMatrix): void;
  9824. addArrayInPlace(data: Array<number>): void;
  9825. add(matrix: QuadraticMatrix): QuadraticMatrix;
  9826. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  9827. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  9828. }
  9829. class Reference {
  9830. vertexId: number;
  9831. triangleId: number;
  9832. constructor(vertexId: number, triangleId: number);
  9833. }
  9834. /**
  9835. * An implementation of the Quadratic Error simplification algorithm.
  9836. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  9837. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  9838. * @author RaananW
  9839. */
  9840. class QuadraticErrorSimplification implements ISimplifier {
  9841. private _mesh;
  9842. private triangles;
  9843. private vertices;
  9844. private references;
  9845. private initialized;
  9846. private _reconstructedMesh;
  9847. syncIterations: number;
  9848. aggressiveness: number;
  9849. decimationIterations: number;
  9850. boundingBoxEpsilon: number;
  9851. constructor(_mesh: Mesh);
  9852. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  9853. private isTriangleOnBoundingBox(triangle);
  9854. private runDecimation(settings, submeshIndex, successCallback);
  9855. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  9856. private init(callback);
  9857. private reconstructMesh(submeshIndex);
  9858. private initDecimatedMesh();
  9859. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  9860. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  9861. private identifyBorder();
  9862. private updateMesh(identifyBorders?);
  9863. private vertexError(q, point);
  9864. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  9865. }
  9866. }
  9867. declare module BABYLON {
  9868. class Polygon {
  9869. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  9870. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  9871. static Parse(input: string): Vector2[];
  9872. static StartingAt(x: number, y: number): Path2;
  9873. }
  9874. class PolygonMeshBuilder {
  9875. private _points;
  9876. private _outlinepoints;
  9877. private _holes;
  9878. private _name;
  9879. private _scene;
  9880. private _epoints;
  9881. private _eholes;
  9882. private _addToepoint(points);
  9883. constructor(name: string, contours: Path2, scene: Scene);
  9884. constructor(name: string, contours: Vector2[], scene: Scene);
  9885. addHole(hole: Vector2[]): PolygonMeshBuilder;
  9886. build(updatable?: boolean, depth?: number): Mesh;
  9887. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  9888. }
  9889. }
  9890. declare module BABYLON {
  9891. class SubMesh {
  9892. materialIndex: number;
  9893. verticesStart: number;
  9894. verticesCount: number;
  9895. indexStart: any;
  9896. indexCount: number;
  9897. linesIndexCount: number;
  9898. private _mesh;
  9899. private _renderingMesh;
  9900. private _boundingInfo;
  9901. private _linesIndexBuffer;
  9902. _lastColliderWorldVertices: Vector3[];
  9903. _trianglePlanes: Plane[];
  9904. _lastColliderTransformMatrix: Matrix;
  9905. _renderId: number;
  9906. _alphaIndex: number;
  9907. _distanceToCamera: number;
  9908. _id: number;
  9909. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: any, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  9910. IsGlobal: boolean;
  9911. getBoundingInfo(): BoundingInfo;
  9912. getMesh(): AbstractMesh;
  9913. getRenderingMesh(): Mesh;
  9914. getMaterial(): Material;
  9915. refreshBoundingInfo(): void;
  9916. _checkCollision(collider: Collider): boolean;
  9917. updateBoundingInfo(world: Matrix): void;
  9918. isInFrustum(frustumPlanes: Plane[]): boolean;
  9919. render(enableAlphaMode: boolean): void;
  9920. getLinesIndexBuffer(indices: number[] | Int32Array, engine: Engine): WebGLBuffer;
  9921. canIntersects(ray: Ray): boolean;
  9922. intersects(ray: Ray, positions: Vector3[], indices: number[] | Int32Array, fastCheck?: boolean): IntersectionInfo;
  9923. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  9924. dispose(): void;
  9925. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  9926. }
  9927. }
  9928. declare module BABYLON {
  9929. class VertexBuffer {
  9930. private _buffer;
  9931. private _kind;
  9932. private _offset;
  9933. private _size;
  9934. private _stride;
  9935. private _ownsBuffer;
  9936. constructor(engine: any, data: number[] | Float32Array | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  9937. getKind(): string;
  9938. isUpdatable(): boolean;
  9939. getData(): number[] | Float32Array;
  9940. getBuffer(): WebGLBuffer;
  9941. getStrideSize(): number;
  9942. getOffset(): number;
  9943. getSize(): number;
  9944. getIsInstanced(): boolean;
  9945. create(data?: number[] | Float32Array): void;
  9946. update(data: number[] | Float32Array): void;
  9947. updateDirectly(data: Float32Array, offset: number): void;
  9948. dispose(): void;
  9949. private static _PositionKind;
  9950. private static _NormalKind;
  9951. private static _UVKind;
  9952. private static _UV2Kind;
  9953. private static _UV3Kind;
  9954. private static _UV4Kind;
  9955. private static _UV5Kind;
  9956. private static _UV6Kind;
  9957. private static _ColorKind;
  9958. private static _MatricesIndicesKind;
  9959. private static _MatricesWeightsKind;
  9960. private static _MatricesIndicesExtraKind;
  9961. private static _MatricesWeightsExtraKind;
  9962. static PositionKind: string;
  9963. static NormalKind: string;
  9964. static UVKind: string;
  9965. static UV2Kind: string;
  9966. static UV3Kind: string;
  9967. static UV4Kind: string;
  9968. static UV5Kind: string;
  9969. static UV6Kind: string;
  9970. static ColorKind: string;
  9971. static MatricesIndicesKind: string;
  9972. static MatricesWeightsKind: string;
  9973. static MatricesIndicesExtraKind: string;
  9974. static MatricesWeightsExtraKind: string;
  9975. }
  9976. }
  9977. declare module BABYLON {
  9978. interface PhysicsImpostorJoint {
  9979. mainImpostor: PhysicsImpostor;
  9980. connectedImpostor: PhysicsImpostor;
  9981. joint: PhysicsJoint;
  9982. }
  9983. class PhysicsEngine {
  9984. private _physicsPlugin;
  9985. gravity: Vector3;
  9986. constructor(gravity?: Vector3, _physicsPlugin?: IPhysicsEnginePlugin);
  9987. setGravity(gravity: Vector3): void;
  9988. /**
  9989. * Set the time step of the physics engine.
  9990. * default is 1/60.
  9991. * To slow it down, enter 1/600 for example.
  9992. * To speed it up, 1/30
  9993. * @param {number} newTimeStep the new timestep to apply to this world.
  9994. */
  9995. setTimeStep(newTimeStep?: number): void;
  9996. dispose(): void;
  9997. getPhysicsPluginName(): string;
  9998. /**
  9999. * @Deprecated
  10000. *
  10001. */
  10002. static NoImpostor: number;
  10003. static SphereImpostor: number;
  10004. static BoxImpostor: number;
  10005. static PlaneImpostor: number;
  10006. static MeshImpostor: number;
  10007. static CylinderImpostor: number;
  10008. static HeightmapImpostor: number;
  10009. static CapsuleImpostor: number;
  10010. static ConeImpostor: number;
  10011. static ConvexHullImpostor: number;
  10012. static Epsilon: number;
  10013. private _impostors;
  10014. private _joints;
  10015. /**
  10016. * Adding a new impostor for the impostor tracking.
  10017. * This will be done by the impostor itself.
  10018. * @param {PhysicsImpostor} impostor the impostor to add
  10019. */
  10020. addImpostor(impostor: PhysicsImpostor): void;
  10021. /**
  10022. * Remove an impostor from the engine.
  10023. * This impostor and its mesh will not longer be updated by the physics engine.
  10024. * @param {PhysicsImpostor} impostor the impostor to remove
  10025. */
  10026. removeImpostor(impostor: PhysicsImpostor): void;
  10027. /**
  10028. * Add a joint to the physics engine
  10029. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  10030. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  10031. * @param {PhysicsJoint} the joint that will connect both impostors.
  10032. */
  10033. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  10034. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  10035. /**
  10036. * Called by the scene. no need to call it.
  10037. */
  10038. _step(delta: number): void;
  10039. getPhysicsPlugin(): IPhysicsEnginePlugin;
  10040. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): PhysicsImpostor;
  10041. getImpostorWithPhysicsBody(body: any): PhysicsImpostor;
  10042. }
  10043. interface IPhysicsEnginePlugin {
  10044. world: any;
  10045. name: string;
  10046. setGravity(gravity: Vector3): any;
  10047. setTimeStep(timeStep: number): any;
  10048. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  10049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): any;
  10050. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): any;
  10051. generatePhysicsBody(impostor: PhysicsImpostor): any;
  10052. removePhysicsBody(impostor: PhysicsImpostor): any;
  10053. generateJoint(joint: PhysicsImpostorJoint): any;
  10054. removeJoint(joint: PhysicsImpostorJoint): any;
  10055. isSupported(): boolean;
  10056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): any;
  10057. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): any;
  10058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): any;
  10059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): any;
  10060. getLinearVelocity(impostor: PhysicsImpostor): Vector3;
  10061. getAngularVelocity(impostor: PhysicsImpostor): Vector3;
  10062. setBodyMass(impostor: PhysicsImpostor, mass: number): any;
  10063. sleepBody(impostor: PhysicsImpostor): any;
  10064. wakeUpBody(impostor: PhysicsImpostor): any;
  10065. updateDistanceJoint(joint: DistanceJoint, maxDistance: number, minDistance?: number): any;
  10066. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): any;
  10067. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): any;
  10068. dispose(): any;
  10069. }
  10070. }
  10071. declare module BABYLON {
  10072. interface PhysicsImpostorParameters {
  10073. mass: number;
  10074. friction?: number;
  10075. restitution?: number;
  10076. nativeOptions?: any;
  10077. }
  10078. interface IPhysicsEnabledObject {
  10079. position: Vector3;
  10080. rotationQuaternion: Quaternion;
  10081. scaling: Vector3;
  10082. rotation?: Vector3;
  10083. parent?: any;
  10084. getBoundingInfo?(): BoundingInfo;
  10085. computeWorldMatrix?(force: boolean): void;
  10086. getChildMeshes?(): Array<AbstractMesh>;
  10087. getVerticesData?(kind: string): Array<number> | Float32Array;
  10088. getIndices?(): Array<number> | Int32Array;
  10089. getScene?(): Scene;
  10090. }
  10091. class PhysicsImpostor {
  10092. object: IPhysicsEnabledObject;
  10093. type: number;
  10094. private _options;
  10095. private _scene;
  10096. static DEFAULT_OBJECT_SIZE: Vector3;
  10097. private _physicsEngine;
  10098. private _physicsBody;
  10099. private _bodyUpdateRequired;
  10100. private _onBeforePhysicsStepCallbacks;
  10101. private _onAfterPhysicsStepCallbacks;
  10102. private _onPhysicsCollideCallbacks;
  10103. private _deltaPosition;
  10104. private _deltaRotation;
  10105. private _deltaRotationConjugated;
  10106. private _parent;
  10107. uniqueId: number;
  10108. private _joints;
  10109. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene);
  10110. /**
  10111. * This function will completly initialize this impostor.
  10112. * It will create a new body - but only if this mesh has no parent.
  10113. * If it has, this impostor will not be used other than to define the impostor
  10114. * of the child mesh.
  10115. */
  10116. _init(): void;
  10117. private _getPhysicsParent();
  10118. /**
  10119. * Should a new body be generated.
  10120. */
  10121. isBodyInitRequired(): boolean;
  10122. setScalingUpdated(updated: boolean): void;
  10123. /**
  10124. * Force a regeneration of this or the parent's impostor's body.
  10125. * Use under cautious - This will remove all joints already implemented.
  10126. */
  10127. forceUpdate(): void;
  10128. /**
  10129. * Gets the body that holds this impostor. Either its own, or its parent.
  10130. */
  10131. /**
  10132. * Set the physics body. Used mainly by the physics engine/plugin
  10133. */
  10134. physicsBody: any;
  10135. parent: PhysicsImpostor;
  10136. resetUpdateFlags(): void;
  10137. getObjectExtendSize(): Vector3;
  10138. getObjectCenter(): Vector3;
  10139. /**
  10140. * Get a specific parametes from the options parameter.
  10141. */
  10142. getParam(paramName: string): any;
  10143. /**
  10144. * Sets a specific parameter in the options given to the physics plugin
  10145. */
  10146. setParam(paramName: string, value: number): void;
  10147. /**
  10148. * Specifically change the body's mass option. Won't recreate the physics body object
  10149. */
  10150. setMass(mass: number): void;
  10151. getLinearVelocity(): Vector3;
  10152. /**
  10153. * Set the body's linear velocity.
  10154. */
  10155. setLinearVelocity(velocity: Vector3): void;
  10156. getAngularVelocity(): Vector3;
  10157. /**
  10158. * Set the body's linear velocity.
  10159. */
  10160. setAngularVelocity(velocity: Vector3): void;
  10161. /**
  10162. * Execute a function with the physics plugin native code.
  10163. * Provide a function the will have two variables - the world object and the physics body object.
  10164. */
  10165. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  10166. /**
  10167. * Register a function that will be executed before the physics world is stepping forward.
  10168. */
  10169. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  10170. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  10171. /**
  10172. * Register a function that will be executed after the physics step
  10173. */
  10174. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  10175. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  10176. /**
  10177. * register a function that will be executed when this impostor collides against a different body.
  10178. */
  10179. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  10180. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  10181. private _tmpPositionWithDelta;
  10182. private _tmpRotationWithDelta;
  10183. /**
  10184. * this function is executed by the physics engine.
  10185. */
  10186. beforeStep: () => void;
  10187. /**
  10188. * this function is executed by the physics engine.
  10189. */
  10190. afterStep: () => void;
  10191. onCollide: (e: {
  10192. body: any;
  10193. }) => void;
  10194. /**
  10195. * Apply a force
  10196. */
  10197. applyForce(force: Vector3, contactPoint: Vector3): void;
  10198. /**
  10199. * Apply an impulse
  10200. */
  10201. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  10202. /**
  10203. * A help function to create a joint.
  10204. */
  10205. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): void;
  10206. /**
  10207. * Add a joint to this impostor with a different impostor.
  10208. */
  10209. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  10210. /**
  10211. * Will keep this body still, in a sleep mode.
  10212. */
  10213. sleep(): void;
  10214. /**
  10215. * Wake the body up.
  10216. */
  10217. wakeUp(): void;
  10218. clone(newObject: IPhysicsEnabledObject): PhysicsImpostor;
  10219. dispose(): void;
  10220. setDeltaPosition(position: Vector3): void;
  10221. setDeltaRotation(rotation: Quaternion): void;
  10222. static NoImpostor: number;
  10223. static SphereImpostor: number;
  10224. static BoxImpostor: number;
  10225. static PlaneImpostor: number;
  10226. static MeshImpostor: number;
  10227. static CylinderImpostor: number;
  10228. static ParticleImpostor: number;
  10229. static HeightmapImpostor: number;
  10230. }
  10231. }
  10232. declare module BABYLON {
  10233. interface PhysicsJointData {
  10234. mainPivot?: Vector3;
  10235. connectedPivot?: Vector3;
  10236. mainAxis?: Vector3;
  10237. connectedAxis?: Vector3;
  10238. collision?: boolean;
  10239. nativeParams?: any;
  10240. }
  10241. /**
  10242. * This is a holder class for the physics joint created by the physics plugin.
  10243. * It holds a set of functions to control the underlying joint.
  10244. */
  10245. class PhysicsJoint {
  10246. type: number;
  10247. jointData: PhysicsJointData;
  10248. private _physicsJoint;
  10249. protected _physicsPlugin: IPhysicsEnginePlugin;
  10250. constructor(type: number, jointData: PhysicsJointData);
  10251. physicsJoint: any;
  10252. physicsPlugin: IPhysicsEnginePlugin;
  10253. /**
  10254. * Execute a function that is physics-plugin specific.
  10255. * @param {Function} func the function that will be executed.
  10256. * It accepts two parameters: the physics world and the physics joint.
  10257. */
  10258. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  10259. static DistanceJoint: number;
  10260. static HingeJoint: number;
  10261. static BallAndSocketJoint: number;
  10262. static WheelJoint: number;
  10263. static SliderJoint: number;
  10264. static PrismaticJoint: number;
  10265. static UniversalJoint: number;
  10266. static Hinge2Joint: number;
  10267. static PointToPointJoint: number;
  10268. static SpringJoint: number;
  10269. static LockJoint: number;
  10270. }
  10271. /**
  10272. * A class representing a physics distance joint.
  10273. */
  10274. class DistanceJoint extends PhysicsJoint {
  10275. constructor(jointData: DistanceJointData);
  10276. /**
  10277. * Update the predefined distance.
  10278. */
  10279. updateDistance(maxDistance: number, minDistance?: number): void;
  10280. }
  10281. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  10282. constructor(type: number, jointData: PhysicsJointData);
  10283. /**
  10284. * Set the motor values.
  10285. * Attention, this function is plugin specific. Engines won't react 100% the same.
  10286. * @param {number} force the force to apply
  10287. * @param {number} maxForce max force for this motor.
  10288. */
  10289. setMotor(force?: number, maxForce?: number): void;
  10290. /**
  10291. * Set the motor's limits.
  10292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  10293. */
  10294. setLimit(upperLimit: number, lowerLimit?: number): void;
  10295. }
  10296. /**
  10297. * This class represents a single hinge physics joint
  10298. */
  10299. class HingeJoint extends MotorEnabledJoint {
  10300. constructor(jointData: PhysicsJointData);
  10301. /**
  10302. * Set the motor values.
  10303. * Attention, this function is plugin specific. Engines won't react 100% the same.
  10304. * @param {number} force the force to apply
  10305. * @param {number} maxForce max force for this motor.
  10306. */
  10307. setMotor(force?: number, maxForce?: number): void;
  10308. /**
  10309. * Set the motor's limits.
  10310. * Attention, this function is plugin specific. Engines won't react 100% the same.
  10311. */
  10312. setLimit(upperLimit: number, lowerLimit?: number): void;
  10313. }
  10314. /**
  10315. * This class represents a dual hinge physics joint (same as wheel joint)
  10316. */
  10317. class Hinge2Joint extends MotorEnabledJoint {
  10318. constructor(jointData: PhysicsJointData);
  10319. /**
  10320. * Set the motor values.
  10321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  10322. * @param {number} force the force to apply
  10323. * @param {number} maxForce max force for this motor.
  10324. * @param {motorIndex} the motor's index, 0 or 1.
  10325. */
  10326. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  10327. /**
  10328. * Set the motor limits.
  10329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  10330. * @param {number} upperLimit the upper limit
  10331. * @param {number} lowerLimit lower limit
  10332. * @param {motorIndex} the motor's index, 0 or 1.
  10333. */
  10334. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  10335. }
  10336. interface IMotorEnabledJoint {
  10337. physicsJoint: any;
  10338. setMotor(force?: number, maxForce?: number, motorIndex?: number): any;
  10339. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): any;
  10340. }
  10341. interface DistanceJointData extends PhysicsJointData {
  10342. maxDistance: number;
  10343. }
  10344. interface SpringJointData extends PhysicsJointData {
  10345. length: number;
  10346. stiffness: number;
  10347. damping: number;
  10348. }
  10349. }
  10350. declare module BABYLON {
  10351. class AnaglyphPostProcess extends PostProcess {
  10352. private _passedProcess;
  10353. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  10354. }
  10355. }
  10356. declare module BABYLON {
  10357. class BlackAndWhitePostProcess extends PostProcess {
  10358. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10359. }
  10360. }
  10361. declare module BABYLON {
  10362. class BlurPostProcess extends PostProcess {
  10363. direction: Vector2;
  10364. blurWidth: number;
  10365. constructor(name: string, direction: Vector2, blurWidth: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10366. }
  10367. }
  10368. declare module BABYLON {
  10369. class ColorCorrectionPostProcess extends PostProcess {
  10370. private _colorTableTexture;
  10371. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10372. }
  10373. }
  10374. declare module BABYLON {
  10375. class ConvolutionPostProcess extends PostProcess {
  10376. kernel: number[];
  10377. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10378. static EdgeDetect0Kernel: number[];
  10379. static EdgeDetect1Kernel: number[];
  10380. static EdgeDetect2Kernel: number[];
  10381. static SharpenKernel: number[];
  10382. static EmbossKernel: number[];
  10383. static GaussianKernel: number[];
  10384. }
  10385. }
  10386. declare module BABYLON {
  10387. class DisplayPassPostProcess extends PostProcess {
  10388. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10389. }
  10390. }
  10391. declare module BABYLON {
  10392. class FilterPostProcess extends PostProcess {
  10393. kernelMatrix: Matrix;
  10394. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10395. }
  10396. }
  10397. declare module BABYLON {
  10398. class FxaaPostProcess extends PostProcess {
  10399. texelWidth: number;
  10400. texelHeight: number;
  10401. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10402. }
  10403. }
  10404. declare module BABYLON {
  10405. class HDRRenderingPipeline extends PostProcessRenderPipeline implements IDisposable {
  10406. /**
  10407. * Public members
  10408. */
  10409. /**
  10410. * Gaussian blur coefficient
  10411. * @type {number}
  10412. */
  10413. gaussCoeff: number;
  10414. /**
  10415. * Gaussian blur mean
  10416. * @type {number}
  10417. */
  10418. gaussMean: number;
  10419. /**
  10420. * Gaussian blur standard deviation
  10421. * @type {number}
  10422. */
  10423. gaussStandDev: number;
  10424. /**
  10425. * Gaussian blur multiplier. Multiplies the blur effect
  10426. * @type {number}
  10427. */
  10428. gaussMultiplier: number;
  10429. /**
  10430. * Exposure, controls the overall intensity of the pipeline
  10431. * @type {number}
  10432. */
  10433. exposure: number;
  10434. /**
  10435. * Minimum luminance that the post-process can output. Luminance is >= 0
  10436. * @type {number}
  10437. */
  10438. minimumLuminance: number;
  10439. /**
  10440. * Maximum luminance that the post-process can output. Must be suprerior to minimumLuminance
  10441. * @type {number}
  10442. */
  10443. maximumLuminance: number;
  10444. /**
  10445. * Increase rate for luminance: eye adaptation speed to dark
  10446. * @type {number}
  10447. */
  10448. luminanceIncreaserate: number;
  10449. /**
  10450. * Decrease rate for luminance: eye adaptation speed to bright
  10451. * @type {number}
  10452. */
  10453. luminanceDecreaseRate: number;
  10454. /**
  10455. * Minimum luminance needed to compute HDR
  10456. * @type {number}
  10457. */
  10458. brightThreshold: number;
  10459. /**
  10460. * Private members
  10461. */
  10462. private _guassianBlurHPostProcess;
  10463. private _guassianBlurVPostProcess;
  10464. private _brightPassPostProcess;
  10465. private _textureAdderPostProcess;
  10466. private _downSampleX4PostProcess;
  10467. private _originalPostProcess;
  10468. private _hdrPostProcess;
  10469. private _hdrCurrentLuminance;
  10470. private _hdrOutputLuminance;
  10471. static LUM_STEPS: number;
  10472. private _downSamplePostProcesses;
  10473. private _scene;
  10474. private _needUpdate;
  10475. /**
  10476. * @constructor
  10477. * @param {string} name - The rendering pipeline name
  10478. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  10479. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  10480. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  10481. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  10482. */
  10483. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: PostProcess, cameras?: Camera[]);
  10484. /**
  10485. * Tells the pipeline to update its post-processes
  10486. */
  10487. update(): void;
  10488. /**
  10489. * Returns the current calculated luminance
  10490. */
  10491. getCurrentLuminance(): number;
  10492. /**
  10493. * Returns the currently drawn luminance
  10494. */
  10495. getOutputLuminance(): number;
  10496. /**
  10497. * Releases the rendering pipeline and its internal effects. Detaches pipeline from cameras
  10498. */
  10499. dispose(): void;
  10500. /**
  10501. * Creates the HDR post-process and computes the luminance adaptation
  10502. */
  10503. private _createHDRPostProcess(scene, ratio);
  10504. /**
  10505. * Texture Adder post-process
  10506. */
  10507. private _createTextureAdderPostProcess(scene, ratio);
  10508. /**
  10509. * Down sample X4 post-process
  10510. */
  10511. private _createDownSampleX4PostProcess(scene, ratio);
  10512. /**
  10513. * Bright pass post-process
  10514. */
  10515. private _createBrightPassPostProcess(scene, ratio);
  10516. /**
  10517. * Luminance generator. Creates the luminance post-process and down sample post-processes
  10518. */
  10519. private _createLuminanceGeneratorPostProcess(scene);
  10520. /**
  10521. * Gaussian blur post-processes. Horizontal and Vertical
  10522. */
  10523. private _createGaussianBlurPostProcess(scene, ratio);
  10524. }
  10525. }
  10526. declare module BABYLON {
  10527. class LensRenderingPipeline extends PostProcessRenderPipeline {
  10528. /**
  10529. * The chromatic aberration PostProcess id in the pipeline
  10530. * @type {string}
  10531. */
  10532. LensChromaticAberrationEffect: string;
  10533. /**
  10534. * The highlights enhancing PostProcess id in the pipeline
  10535. * @type {string}
  10536. */
  10537. HighlightsEnhancingEffect: string;
  10538. /**
  10539. * The depth-of-field PostProcess id in the pipeline
  10540. * @type {string}
  10541. */
  10542. LensDepthOfFieldEffect: string;
  10543. private _scene;
  10544. private _depthTexture;
  10545. private _grainTexture;
  10546. private _chromaticAberrationPostProcess;
  10547. private _highlightsPostProcess;
  10548. private _depthOfFieldPostProcess;
  10549. private _edgeBlur;
  10550. private _grainAmount;
  10551. private _chromaticAberration;
  10552. private _distortion;
  10553. private _highlightsGain;
  10554. private _highlightsThreshold;
  10555. private _dofDistance;
  10556. private _dofAperture;
  10557. private _dofDarken;
  10558. private _dofPentagon;
  10559. private _blurNoise;
  10560. /**
  10561. * @constructor
  10562. *
  10563. * Effect parameters are as follow:
  10564. * {
  10565. * chromatic_aberration: number; // from 0 to x (1 for realism)
  10566. * edge_blur: number; // from 0 to x (1 for realism)
  10567. * distortion: number; // from 0 to x (1 for realism)
  10568. * grain_amount: number; // from 0 to 1
  10569. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  10570. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  10571. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  10572. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  10573. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  10574. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  10575. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  10576. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  10577. * }
  10578. * Note: if an effect parameter is unset, effect is disabled
  10579. *
  10580. * @param {string} name - The rendering pipeline name
  10581. * @param {object} parameters - An object containing all parameters (see above)
  10582. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  10583. * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  10584. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  10585. */
  10586. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  10587. setEdgeBlur(amount: number): void;
  10588. disableEdgeBlur(): void;
  10589. setGrainAmount(amount: number): void;
  10590. disableGrain(): void;
  10591. setChromaticAberration(amount: number): void;
  10592. disableChromaticAberration(): void;
  10593. setEdgeDistortion(amount: number): void;
  10594. disableEdgeDistortion(): void;
  10595. setFocusDistance(amount: number): void;
  10596. disableDepthOfField(): void;
  10597. setAperture(amount: number): void;
  10598. setDarkenOutOfFocus(amount: number): void;
  10599. enablePentagonBokeh(): void;
  10600. disablePentagonBokeh(): void;
  10601. enableNoiseBlur(): void;
  10602. disableNoiseBlur(): void;
  10603. setHighlightsGain(amount: number): void;
  10604. setHighlightsThreshold(amount: number): void;
  10605. disableHighlights(): void;
  10606. /**
  10607. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  10608. */
  10609. dispose(disableDepthRender?: boolean): void;
  10610. private _createChromaticAberrationPostProcess(ratio);
  10611. private _createHighlightsPostProcess(ratio);
  10612. private _createDepthOfFieldPostProcess(ratio);
  10613. private _createGrainTexture();
  10614. }
  10615. }
  10616. declare module BABYLON {
  10617. class PassPostProcess extends PostProcess {
  10618. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10619. }
  10620. }
  10621. declare module BABYLON {
  10622. type PostProcessOptions = {
  10623. width: number;
  10624. height: number;
  10625. };
  10626. class PostProcess {
  10627. name: string;
  10628. width: number;
  10629. height: number;
  10630. renderTargetSamplingMode: number;
  10631. clearColor: Color4;
  10632. enablePixelPerfectMode: boolean;
  10633. private _camera;
  10634. private _scene;
  10635. private _engine;
  10636. private _options;
  10637. private _reusable;
  10638. private _textureType;
  10639. _textures: SmartArray<WebGLTexture>;
  10640. _currentRenderTextureInd: number;
  10641. private _effect;
  10642. private _samplers;
  10643. private _fragmentUrl;
  10644. private _parameters;
  10645. private _scaleRatio;
  10646. /**
  10647. * An event triggered when the postprocess is activated.
  10648. * @type {BABYLON.Observable}
  10649. */
  10650. onActivateObservable: Observable<Camera>;
  10651. private _onActivateObserver;
  10652. onActivate: (camera: Camera) => void;
  10653. /**
  10654. * An event triggered when the postprocess changes its size.
  10655. * @type {BABYLON.Observable}
  10656. */
  10657. onSizeChangedObservable: Observable<PostProcess>;
  10658. private _onSizeChangedObserver;
  10659. onSizeChanged: (postProcess: PostProcess) => void;
  10660. /**
  10661. * An event triggered when the postprocess applies its effect.
  10662. * @type {BABYLON.Observable}
  10663. */
  10664. onApplyObservable: Observable<Effect>;
  10665. private _onApplyObserver;
  10666. onApply: (effect: Effect) => void;
  10667. /**
  10668. * An event triggered before rendering the postprocess
  10669. * @type {BABYLON.Observable}
  10670. */
  10671. onBeforeRenderObservable: Observable<Effect>;
  10672. private _onBeforeRenderObserver;
  10673. onBeforeRender: (effect: Effect) => void;
  10674. /**
  10675. * An event triggered after rendering the postprocess
  10676. * @type {BABYLON.Observable}
  10677. */
  10678. onAfterRenderObservable: Observable<Effect>;
  10679. private _onAfterRenderObserver;
  10680. onAfterRender: (efect: Effect) => void;
  10681. constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number);
  10682. updateEffect(defines?: string): void;
  10683. isReusable(): boolean;
  10684. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  10685. markTextureDirty(): void;
  10686. activate(camera: Camera, sourceTexture?: WebGLTexture): void;
  10687. isSupported: boolean;
  10688. apply(): Effect;
  10689. dispose(camera?: Camera): void;
  10690. }
  10691. }
  10692. declare module BABYLON {
  10693. class PostProcessManager {
  10694. private _scene;
  10695. private _indexBuffer;
  10696. private _vertexBuffers;
  10697. constructor(scene: Scene);
  10698. private _prepareBuffers();
  10699. _prepareFrame(sourceTexture?: WebGLTexture): boolean;
  10700. directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void;
  10701. _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void;
  10702. dispose(): void;
  10703. }
  10704. }
  10705. declare module BABYLON {
  10706. class RefractionPostProcess extends PostProcess {
  10707. color: Color3;
  10708. depth: number;
  10709. colorLevel: number;
  10710. private _refRexture;
  10711. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10712. dispose(camera: Camera): void;
  10713. }
  10714. }
  10715. declare module BABYLON {
  10716. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  10717. /**
  10718. * The PassPostProcess id in the pipeline that contains the original scene color
  10719. * @type {string}
  10720. */
  10721. SSAOOriginalSceneColorEffect: string;
  10722. /**
  10723. * The SSAO PostProcess id in the pipeline
  10724. * @type {string}
  10725. */
  10726. SSAORenderEffect: string;
  10727. /**
  10728. * The horizontal blur PostProcess id in the pipeline
  10729. * @type {string}
  10730. */
  10731. SSAOBlurHRenderEffect: string;
  10732. /**
  10733. * The vertical blur PostProcess id in the pipeline
  10734. * @type {string}
  10735. */
  10736. SSAOBlurVRenderEffect: string;
  10737. /**
  10738. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  10739. * @type {string}
  10740. */
  10741. SSAOCombineRenderEffect: string;
  10742. /**
  10743. * The output strength of the SSAO post-process. Default value is 1.0.
  10744. * @type {number}
  10745. */
  10746. totalStrength: number;
  10747. /**
  10748. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  10749. * @type {number}
  10750. */
  10751. radius: number;
  10752. /**
  10753. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  10754. * Must not be equal to fallOff and superior to fallOff.
  10755. * Default value is 0.975
  10756. * @type {number}
  10757. */
  10758. area: number;
  10759. /**
  10760. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  10761. * Must not be equal to area and inferior to area.
  10762. * Default value is 0.0
  10763. * @type {number}
  10764. */
  10765. fallOff: number;
  10766. /**
  10767. * The base color of the SSAO post-process
  10768. * The final result is "base + ssao" between [0, 1]
  10769. * @type {number}
  10770. */
  10771. base: number;
  10772. private _scene;
  10773. private _depthTexture;
  10774. private _randomTexture;
  10775. private _originalColorPostProcess;
  10776. private _ssaoPostProcess;
  10777. private _blurHPostProcess;
  10778. private _blurVPostProcess;
  10779. private _ssaoCombinePostProcess;
  10780. private _firstUpdate;
  10781. private _ratio;
  10782. /**
  10783. * @constructor
  10784. * @param {string} name - The rendering pipeline name
  10785. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  10786. * @param {any} ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  10787. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  10788. */
  10789. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  10790. /**
  10791. * Returns the horizontal blur PostProcess
  10792. * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
  10793. */
  10794. getBlurHPostProcess(): BlurPostProcess;
  10795. /**
  10796. * Returns the vertical blur PostProcess
  10797. * @return {BABYLON.BlurPostProcess} The vertical blur post-process
  10798. */
  10799. getBlurVPostProcess(): BlurPostProcess;
  10800. /**
  10801. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  10802. */
  10803. dispose(disableDepthRender?: boolean): void;
  10804. private _createBlurPostProcess(ratio);
  10805. private _createSSAOPostProcess(ratio);
  10806. private _createSSAOCombinePostProcess(ratio);
  10807. private _createRandomTexture();
  10808. }
  10809. }
  10810. declare module BABYLON {
  10811. class StereoscopicInterlacePostProcess extends PostProcess {
  10812. private _stepSize;
  10813. private _passedProcess;
  10814. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10815. }
  10816. }
  10817. declare module BABYLON {
  10818. enum TonemappingOperator {
  10819. Hable = 0,
  10820. Reinhard = 1,
  10821. HejiDawson = 2,
  10822. Photographic = 3,
  10823. }
  10824. class TonemapPostProcess extends PostProcess {
  10825. private _operator;
  10826. exposureAdjustment: number;
  10827. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  10828. }
  10829. }
  10830. declare module BABYLON {
  10831. class VolumetricLightScatteringPostProcess extends PostProcess {
  10832. private _volumetricLightScatteringPass;
  10833. private _volumetricLightScatteringRTT;
  10834. private _viewPort;
  10835. private _screenCoordinates;
  10836. private _cachedDefines;
  10837. /**
  10838. * If not undefined, the mesh position is computed from the attached node position
  10839. * @type {{position: Vector3}}
  10840. */
  10841. attachedNode: {
  10842. position: Vector3;
  10843. };
  10844. /**
  10845. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  10846. * @type {Vector3}
  10847. */
  10848. customMeshPosition: Vector3;
  10849. /**
  10850. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  10851. * @type {boolean}
  10852. */
  10853. useCustomMeshPosition: boolean;
  10854. /**
  10855. * If the post-process should inverse the light scattering direction
  10856. * @type {boolean}
  10857. */
  10858. invert: boolean;
  10859. /**
  10860. * The internal mesh used by the post-process
  10861. * @type {boolean}
  10862. */
  10863. mesh: Mesh;
  10864. useDiffuseColor: boolean;
  10865. /**
  10866. * Array containing the excluded meshes not rendered in the internal pass
  10867. */
  10868. excludedMeshes: AbstractMesh[];
  10869. /**
  10870. * Controls the overall intensity of the post-process
  10871. * @type {number}
  10872. */
  10873. exposure: number;
  10874. /**
  10875. * Dissipates each sample's contribution in range [0, 1]
  10876. * @type {number}
  10877. */
  10878. decay: number;
  10879. /**
  10880. * Controls the overall intensity of each sample
  10881. * @type {number}
  10882. */
  10883. weight: number;
  10884. /**
  10885. * Controls the density of each sample
  10886. * @type {number}
  10887. */
  10888. density: number;
  10889. /**
  10890. * @constructor
  10891. * @param {string} name - The post-process name
  10892. * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  10893. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  10894. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  10895. * @param {number} samples - The post-process quality, default 100
  10896. * @param {number} samplingMode - The post-process filtering mode
  10897. * @param {BABYLON.Engine} engine - The babylon engine
  10898. * @param {boolean} reusable - If the post-process is reusable
  10899. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  10900. */
  10901. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  10902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10903. /**
  10904. * Sets the new light position for light scattering effect
  10905. * @param {BABYLON.Vector3} The new custom light position
  10906. */
  10907. setCustomMeshPosition(position: Vector3): void;
  10908. /**
  10909. * Returns the light position for light scattering effect
  10910. * @return {BABYLON.Vector3} The custom light position
  10911. */
  10912. getCustomMeshPosition(): Vector3;
  10913. /**
  10914. * Disposes the internal assets and detaches the post-process from the camera
  10915. */
  10916. dispose(camera: Camera): void;
  10917. /**
  10918. * Returns the render target texture used by the post-process
  10919. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  10920. */
  10921. getPass(): RenderTargetTexture;
  10922. private _meshExcluded(mesh);
  10923. private _createPass(scene, ratio);
  10924. private _updateMeshScreenCoordinates(scene);
  10925. /**
  10926. * Creates a default mesh for the Volumeric Light Scattering post-process
  10927. * @param {string} The mesh name
  10928. * @param {BABYLON.Scene} The scene where to create the mesh
  10929. * @return {BABYLON.Mesh} the default mesh
  10930. */
  10931. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  10932. }
  10933. }
  10934. declare module BABYLON {
  10935. class VRDistortionCorrectionPostProcess extends PostProcess {
  10936. aspectRatio: number;
  10937. private _isRightEye;
  10938. private _distortionFactors;
  10939. private _postProcessScaleFactor;
  10940. private _lensCenterOffset;
  10941. private _scaleIn;
  10942. private _scaleFactor;
  10943. private _lensCenter;
  10944. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  10945. }
  10946. }
  10947. declare module BABYLON {
  10948. class ReflectionProbe {
  10949. name: string;
  10950. private _scene;
  10951. private _renderTargetTexture;
  10952. private _projectionMatrix;
  10953. private _viewMatrix;
  10954. private _target;
  10955. private _add;
  10956. private _attachedMesh;
  10957. invertYAxis: boolean;
  10958. position: Vector3;
  10959. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  10960. refreshRate: number;
  10961. getScene(): Scene;
  10962. cubeTexture: RenderTargetTexture;
  10963. renderList: AbstractMesh[];
  10964. attachToMesh(mesh: AbstractMesh): void;
  10965. dispose(): void;
  10966. }
  10967. }
  10968. declare module BABYLON {
  10969. class BoundingBoxRenderer {
  10970. frontColor: Color3;
  10971. backColor: Color3;
  10972. showBackLines: boolean;
  10973. renderList: SmartArray<BoundingBox>;
  10974. private _scene;
  10975. private _colorShader;
  10976. private _vertexBuffers;
  10977. private _indexBuffer;
  10978. constructor(scene: Scene);
  10979. private _prepareRessources();
  10980. reset(): void;
  10981. render(): void;
  10982. dispose(): void;
  10983. }
  10984. }
  10985. declare module BABYLON {
  10986. class DepthRenderer {
  10987. private _scene;
  10988. private _depthMap;
  10989. private _effect;
  10990. private _viewMatrix;
  10991. private _projectionMatrix;
  10992. private _transformMatrix;
  10993. private _worldViewProjection;
  10994. private _cachedDefines;
  10995. constructor(scene: Scene, type?: number);
  10996. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10997. getDepthMap(): RenderTargetTexture;
  10998. dispose(): void;
  10999. }
  11000. }
  11001. declare module BABYLON {
  11002. class EdgesRenderer {
  11003. edgesWidthScalerForOrthographic: number;
  11004. edgesWidthScalerForPerspective: number;
  11005. private _source;
  11006. private _linesPositions;
  11007. private _linesNormals;
  11008. private _linesIndices;
  11009. private _epsilon;
  11010. private _indicesCount;
  11011. private _lineShader;
  11012. private _ib;
  11013. private _buffers;
  11014. private _checkVerticesInsteadOfIndices;
  11015. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  11016. private _prepareRessources();
  11017. dispose(): void;
  11018. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  11019. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  11020. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  11021. _generateEdgesLines(): void;
  11022. render(): void;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. class OutlineRenderer {
  11027. private _scene;
  11028. private _effect;
  11029. private _cachedDefines;
  11030. constructor(scene: Scene);
  11031. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  11032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11033. }
  11034. }
  11035. declare module BABYLON {
  11036. class RenderingGroup {
  11037. index: number;
  11038. private _scene;
  11039. private _opaqueSubMeshes;
  11040. private _transparentSubMeshes;
  11041. private _alphaTestSubMeshes;
  11042. private _activeVertices;
  11043. onBeforeTransparentRendering: () => void;
  11044. constructor(index: number, scene: Scene);
  11045. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void): boolean;
  11046. prepare(): void;
  11047. dispatch(subMesh: SubMesh): void;
  11048. }
  11049. }
  11050. declare module BABYLON {
  11051. class RenderingManager {
  11052. static MAX_RENDERINGGROUPS: number;
  11053. private _scene;
  11054. private _renderingGroups;
  11055. private _depthBufferAlreadyCleaned;
  11056. private _currentIndex;
  11057. private _currentActiveMeshes;
  11058. private _currentRenderParticles;
  11059. private _currentRenderSprites;
  11060. constructor(scene: Scene);
  11061. private _renderParticles(index, activeMeshes);
  11062. private _renderSprites(index);
  11063. private _clearDepthBuffer();
  11064. private _renderSpritesAndParticles();
  11065. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void;
  11066. reset(): void;
  11067. dispatch(subMesh: SubMesh): void;
  11068. }
  11069. }
  11070. declare module BABYLON {
  11071. class Sprite {
  11072. name: string;
  11073. position: Vector3;
  11074. color: Color4;
  11075. width: number;
  11076. height: number;
  11077. angle: number;
  11078. cellIndex: number;
  11079. invertU: number;
  11080. invertV: number;
  11081. disposeWhenFinishedAnimating: boolean;
  11082. animations: Animation[];
  11083. isPickable: boolean;
  11084. actionManager: ActionManager;
  11085. private _animationStarted;
  11086. private _loopAnimation;
  11087. private _fromIndex;
  11088. private _toIndex;
  11089. private _delay;
  11090. private _direction;
  11091. private _frameCount;
  11092. private _manager;
  11093. private _time;
  11094. size: number;
  11095. constructor(name: string, manager: SpriteManager);
  11096. playAnimation(from: number, to: number, loop: boolean, delay: number): void;
  11097. stopAnimation(): void;
  11098. _animate(deltaTime: number): void;
  11099. dispose(): void;
  11100. }
  11101. }
  11102. declare module BABYLON {
  11103. class SpriteManager {
  11104. name: string;
  11105. cellSize: number;
  11106. sprites: Sprite[];
  11107. renderingGroupId: number;
  11108. layerMask: number;
  11109. fogEnabled: boolean;
  11110. isPickable: boolean;
  11111. /**
  11112. * An event triggered when the manager is disposed.
  11113. * @type {BABYLON.Observable}
  11114. */
  11115. onDisposeObservable: Observable<SpriteManager>;
  11116. private _onDisposeObserver;
  11117. onDispose: () => void;
  11118. private _capacity;
  11119. private _spriteTexture;
  11120. private _epsilon;
  11121. private _scene;
  11122. private _vertexData;
  11123. private _buffer;
  11124. private _vertexBuffers;
  11125. private _indexBuffer;
  11126. private _effectBase;
  11127. private _effectFog;
  11128. texture: Texture;
  11129. constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon?: number, samplingMode?: number);
  11130. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  11131. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo;
  11132. render(): void;
  11133. dispose(): void;
  11134. }
  11135. }
  11136. declare module BABYLON.Internals {
  11137. class _AlphaState {
  11138. private _isAlphaBlendDirty;
  11139. private _isBlendFunctionParametersDirty;
  11140. private _alphaBlend;
  11141. private _blendFunctionParameters;
  11142. isDirty: boolean;
  11143. alphaBlend: boolean;
  11144. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  11145. reset(): void;
  11146. apply(gl: WebGLRenderingContext): void;
  11147. }
  11148. }
  11149. declare module BABYLON.Internals {
  11150. class _DepthCullingState {
  11151. private _isDepthTestDirty;
  11152. private _isDepthMaskDirty;
  11153. private _isDepthFuncDirty;
  11154. private _isCullFaceDirty;
  11155. private _isCullDirty;
  11156. private _isZOffsetDirty;
  11157. private _depthTest;
  11158. private _depthMask;
  11159. private _depthFunc;
  11160. private _cull;
  11161. private _cullFace;
  11162. private _zOffset;
  11163. isDirty: boolean;
  11164. zOffset: number;
  11165. cullFace: number;
  11166. cull: boolean;
  11167. depthFunc: number;
  11168. depthMask: boolean;
  11169. depthTest: boolean;
  11170. reset(): void;
  11171. apply(gl: WebGLRenderingContext): void;
  11172. }
  11173. }
  11174. declare module BABYLON.Internals {
  11175. class AndOrNotEvaluator {
  11176. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  11177. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  11178. private static _SimplifyNegation(booleanString);
  11179. }
  11180. }
  11181. declare module BABYLON {
  11182. interface IAssetTask {
  11183. onSuccess: (task: IAssetTask) => void;
  11184. onError: (task: IAssetTask) => void;
  11185. isCompleted: boolean;
  11186. run(scene: Scene, onSuccess: () => void, onError: () => void): any;
  11187. }
  11188. class MeshAssetTask implements IAssetTask {
  11189. name: string;
  11190. meshesNames: any;
  11191. rootUrl: string;
  11192. sceneFilename: string;
  11193. loadedMeshes: Array<AbstractMesh>;
  11194. loadedParticleSystems: Array<ParticleSystem>;
  11195. loadedSkeletons: Array<Skeleton>;
  11196. onSuccess: (task: IAssetTask) => void;
  11197. onError: (task: IAssetTask) => void;
  11198. isCompleted: boolean;
  11199. constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string);
  11200. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11201. }
  11202. class TextFileAssetTask implements IAssetTask {
  11203. name: string;
  11204. url: string;
  11205. onSuccess: (task: IAssetTask) => void;
  11206. onError: (task: IAssetTask) => void;
  11207. isCompleted: boolean;
  11208. text: string;
  11209. constructor(name: string, url: string);
  11210. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11211. }
  11212. class BinaryFileAssetTask implements IAssetTask {
  11213. name: string;
  11214. url: string;
  11215. onSuccess: (task: IAssetTask) => void;
  11216. onError: (task: IAssetTask) => void;
  11217. isCompleted: boolean;
  11218. data: ArrayBuffer;
  11219. constructor(name: string, url: string);
  11220. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11221. }
  11222. class ImageAssetTask implements IAssetTask {
  11223. name: string;
  11224. url: string;
  11225. onSuccess: (task: IAssetTask) => void;
  11226. onError: (task: IAssetTask) => void;
  11227. isCompleted: boolean;
  11228. image: HTMLImageElement;
  11229. constructor(name: string, url: string);
  11230. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11231. }
  11232. class TextureAssetTask implements IAssetTask {
  11233. name: string;
  11234. url: string;
  11235. noMipmap: boolean;
  11236. invertY: boolean;
  11237. samplingMode: number;
  11238. onSuccess: (task: IAssetTask) => void;
  11239. onError: (task: IAssetTask) => void;
  11240. isCompleted: boolean;
  11241. texture: Texture;
  11242. constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number);
  11243. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11244. }
  11245. class AssetsManager {
  11246. private _tasks;
  11247. private _scene;
  11248. private _waitingTasksCount;
  11249. onFinish: (tasks: IAssetTask[]) => void;
  11250. onTaskSuccess: (task: IAssetTask) => void;
  11251. onTaskError: (task: IAssetTask) => void;
  11252. useDefaultLoadingScreen: boolean;
  11253. constructor(scene: Scene);
  11254. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask;
  11255. addTextFileTask(taskName: string, url: string): IAssetTask;
  11256. addBinaryFileTask(taskName: string, url: string): IAssetTask;
  11257. addImageTask(taskName: string, url: string): IAssetTask;
  11258. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): IAssetTask;
  11259. private _decreaseWaitingTasksCount();
  11260. private _runTask(task);
  11261. reset(): AssetsManager;
  11262. load(): AssetsManager;
  11263. }
  11264. }
  11265. declare module BABYLON {
  11266. class Database {
  11267. private callbackManifestChecked;
  11268. private currentSceneUrl;
  11269. private db;
  11270. private enableSceneOffline;
  11271. private enableTexturesOffline;
  11272. private manifestVersionFound;
  11273. private mustUpdateRessources;
  11274. private hasReachedQuota;
  11275. private isSupported;
  11276. private idbFactory;
  11277. static IsUASupportingBlobStorage: boolean;
  11278. static IDBStorageEnabled: boolean;
  11279. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  11280. static parseURL: (url: string) => string;
  11281. static ReturnFullUrlLocation: (url: string) => string;
  11282. checkManifestFile(): void;
  11283. openAsync(successCallback: any, errorCallback: any): void;
  11284. loadImageFromDB(url: string, image: HTMLImageElement): void;
  11285. private _loadImageFromDBAsync(url, image, notInDBCallback);
  11286. private _saveImageIntoDBAsync(url, image);
  11287. private _checkVersionFromDB(url, versionLoaded);
  11288. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  11289. private _saveVersionIntoDBAsync(url, callback);
  11290. private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?);
  11291. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  11292. private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?);
  11293. }
  11294. }
  11295. declare module BABYLON {
  11296. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11297. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11298. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11299. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11300. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11301. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11302. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11303. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11304. class SerializationHelper {
  11305. static Serialize<T>(entity: T, serializationObject?: any): any;
  11306. static Parse<T>(creationFunction: () => T, source: any, scene: Scene, rootUrl?: string): T;
  11307. static Clone<T>(creationFunction: () => T, source: T): T;
  11308. }
  11309. }
  11310. declare module BABYLON {
  11311. class DynamicFloatArrayElementInfo {
  11312. offset: number;
  11313. }
  11314. /**
  11315. * The purpose of this class is to store float32 based elements of a given size (defined by the stride argument) in a dynamic fashion, that is, you can add/free elements. You can then access to a defragmented/packed version of the underlying Float32Array by calling the pack() method.
  11316. * The intent is to maintain through time data that will be bound to a WebGlBuffer with the ability to change add/remove elements.
  11317. * It was first built to efficiently maintain the WebGlBuffer that contain instancing based data.
  11318. * Allocating an Element will return a instance of DynamicFloatArrayElement which contains the offset into the Float32Array of where the element starts, you are then responsible to copy your data using this offset.
  11319. * Beware, calling pack() may change the offset of some Entries because this method will defragment the Float32Array to replace empty elements by moving allocated ones at their location.
  11320. * This method will return an ArrayBufferView on the existing Float32Array that describes the used elements. Use this View to update the WebGLBuffer and NOT the "buffer" field of the class. The pack() method won't shrink/reallocate the buffer to keep it GC friendly, all the empty space will be put at the end of the buffer, the method just ensure there are no "free holes".
  11321. */
  11322. class DynamicFloatArray {
  11323. /**
  11324. * Construct an instance of the dynamic float array
  11325. * @param stride size of one element in float (i.e. not bytes!)
  11326. * @param initialElementCount the number of available entries at construction
  11327. */
  11328. constructor(stride: number, initialElementCount: number);
  11329. /**
  11330. * Allocate an element in the array.
  11331. * @return the element info instance that contains the offset into the main buffer of the element's location.
  11332. * Beware, this offset may change when you call pack()
  11333. */
  11334. allocElement(): DynamicFloatArrayElementInfo;
  11335. /**
  11336. * Free the element corresponding to the given element info
  11337. * @param elInfo the element that describe the allocated element
  11338. */
  11339. freeElement(elInfo: DynamicFloatArrayElementInfo): void;
  11340. /**
  11341. * This method will pack all the used elements into a linear sequence and put all the free space at the end.
  11342. * Instances of DynamicFloatArrayElement may have their 'offset' member changed as data could be copied from one location to another, so be sure to read/write your data based on the value inside this member after you called pack().
  11343. * @return the subArray that is the view of the used elements area, you can use it as a source to update a WebGLBuffer
  11344. */
  11345. pack(): Float32Array;
  11346. private _moveElement(element, destOffset);
  11347. private _growBuffer();
  11348. /**
  11349. * This is the main buffer, all elements are stored inside, you use the DynamicFloatArrayElement instance of a given element to know its location into this buffer, then you have the responsibility to perform write operations in this buffer at the right location!
  11350. * Don't use this buffer for a WebGL bufferSubData() operation, but use the one returned by the pack() method.
  11351. */
  11352. buffer: Float32Array;
  11353. /**
  11354. * Get the total count of entries that can fit in the current buffer
  11355. * @returns the elements count
  11356. */
  11357. totalElementCount: number;
  11358. /**
  11359. * Get the count of free entries that can still be allocated without resizing the buffer
  11360. * @returns the free elements count
  11361. */
  11362. freeElementCount: number;
  11363. /**
  11364. * Get the count of allocated elements
  11365. * @returns the allocated elements count
  11366. */
  11367. usedElementCount: number;
  11368. /**
  11369. * Return the size of one element in float
  11370. * @returns the size in float
  11371. */
  11372. stride: number;
  11373. compareValueOffset: number;
  11374. sortingAscending: boolean;
  11375. sort(): boolean;
  11376. private _allEntries;
  11377. private _freeEntries;
  11378. private _stride;
  11379. private _lastUsed;
  11380. private _firstFree;
  11381. private _sortTable;
  11382. private _sortedTable;
  11383. }
  11384. }
  11385. declare module Earcut {
  11386. /**
  11387. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  11388. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  11389. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  11390. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  11391. */
  11392. function earcut(data: number[], holeIndices: number[], dim: number): any[];
  11393. /**
  11394. * return a percentage difference between the polygon area and its triangulation area;
  11395. * used to verify correctness of triangulation
  11396. */
  11397. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  11398. /**
  11399. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  11400. */
  11401. function flatten(data: number[][][]): {
  11402. vertices: any[];
  11403. holes: any[];
  11404. dimensions: number;
  11405. };
  11406. }
  11407. declare module BABYLON {
  11408. class FilesInput {
  11409. private _engine;
  11410. private _currentScene;
  11411. private _canvas;
  11412. private _sceneLoadedCallback;
  11413. private _progressCallback;
  11414. private _additionnalRenderLoopLogicCallback;
  11415. private _textureLoadingCallback;
  11416. private _startingProcessingFilesCallback;
  11417. private _elementToMonitor;
  11418. static FilesTextures: any[];
  11419. static FilesToLoad: any[];
  11420. private _sceneFileToLoad;
  11421. private _filesToLoad;
  11422. constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any);
  11423. monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void;
  11424. private renderFunction();
  11425. private drag(e);
  11426. private drop(eventDrop);
  11427. loadFiles(event: any): void;
  11428. reload(): void;
  11429. }
  11430. }
  11431. declare module BABYLON {
  11432. class Gamepads {
  11433. private babylonGamepads;
  11434. private oneGamepadConnected;
  11435. private isMonitoring;
  11436. private gamepadEventSupported;
  11437. private gamepadSupportAvailable;
  11438. private _callbackGamepadConnected;
  11439. private _onGamepadConnectedEvent;
  11440. private _onGamepadDisonnectedEvent;
  11441. private static gamepadDOMInfo;
  11442. constructor(ongamedpadconnected: (gamepad: Gamepad) => void);
  11443. dispose(): void;
  11444. private _onGamepadConnected(evt);
  11445. private _addNewGamepad(gamepad);
  11446. private _onGamepadDisconnected(evt);
  11447. private _startMonitoringGamepads();
  11448. private _stopMonitoringGamepads();
  11449. private _checkGamepadsStatus();
  11450. private _updateGamepadObjects();
  11451. }
  11452. class StickValues {
  11453. x: any;
  11454. y: any;
  11455. constructor(x: any, y: any);
  11456. }
  11457. class Gamepad {
  11458. id: string;
  11459. index: number;
  11460. browserGamepad: any;
  11461. private _leftStick;
  11462. private _rightStick;
  11463. private _onleftstickchanged;
  11464. private _onrightstickchanged;
  11465. constructor(id: string, index: number, browserGamepad: any);
  11466. onleftstickchanged(callback: (values: StickValues) => void): void;
  11467. onrightstickchanged(callback: (values: StickValues) => void): void;
  11468. leftStick: StickValues;
  11469. rightStick: StickValues;
  11470. update(): void;
  11471. }
  11472. class GenericPad extends Gamepad {
  11473. id: string;
  11474. index: number;
  11475. gamepad: any;
  11476. private _buttons;
  11477. private _onbuttondown;
  11478. private _onbuttonup;
  11479. onbuttondown(callback: (buttonPressed: number) => void): void;
  11480. onbuttonup(callback: (buttonReleased: number) => void): void;
  11481. constructor(id: string, index: number, gamepad: any);
  11482. private _setButtonValue(newValue, currentValue, buttonIndex);
  11483. update(): void;
  11484. }
  11485. enum Xbox360Button {
  11486. A = 0,
  11487. B = 1,
  11488. X = 2,
  11489. Y = 3,
  11490. Start = 4,
  11491. Back = 5,
  11492. LB = 6,
  11493. RB = 7,
  11494. LeftStick = 8,
  11495. RightStick = 9,
  11496. }
  11497. enum Xbox360Dpad {
  11498. Up = 0,
  11499. Down = 1,
  11500. Left = 2,
  11501. Right = 3,
  11502. }
  11503. class Xbox360Pad extends Gamepad {
  11504. private _leftTrigger;
  11505. private _rightTrigger;
  11506. private _onlefttriggerchanged;
  11507. private _onrighttriggerchanged;
  11508. private _onbuttondown;
  11509. private _onbuttonup;
  11510. private _ondpaddown;
  11511. private _ondpadup;
  11512. private _buttonA;
  11513. private _buttonB;
  11514. private _buttonX;
  11515. private _buttonY;
  11516. private _buttonBack;
  11517. private _buttonStart;
  11518. private _buttonLB;
  11519. private _buttonRB;
  11520. private _buttonLeftStick;
  11521. private _buttonRightStick;
  11522. private _dPadUp;
  11523. private _dPadDown;
  11524. private _dPadLeft;
  11525. private _dPadRight;
  11526. onlefttriggerchanged(callback: (value: number) => void): void;
  11527. onrighttriggerchanged(callback: (value: number) => void): void;
  11528. leftTrigger: number;
  11529. rightTrigger: number;
  11530. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  11531. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  11532. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  11533. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  11534. private _setButtonValue(newValue, currentValue, buttonType);
  11535. private _setDPadValue(newValue, currentValue, buttonType);
  11536. buttonA: number;
  11537. buttonB: number;
  11538. buttonX: number;
  11539. buttonY: number;
  11540. buttonStart: number;
  11541. buttonBack: number;
  11542. buttonLB: number;
  11543. buttonRB: number;
  11544. buttonLeftStick: number;
  11545. buttonRightStick: number;
  11546. dPadUp: number;
  11547. dPadDown: number;
  11548. dPadLeft: number;
  11549. dPadRight: number;
  11550. update(): void;
  11551. }
  11552. }
  11553. interface Navigator {
  11554. getGamepads(func?: any): any;
  11555. webkitGetGamepads(func?: any): any;
  11556. msGetGamepads(func?: any): any;
  11557. webkitGamepads(func?: any): any;
  11558. }
  11559. declare module BABYLON {
  11560. interface ILoadingScreen {
  11561. displayLoadingUI: () => void;
  11562. hideLoadingUI: () => void;
  11563. loadingUIBackgroundColor: string;
  11564. loadingUIText: string;
  11565. }
  11566. class DefaultLoadingScreen implements ILoadingScreen {
  11567. private _renderingCanvas;
  11568. private _loadingText;
  11569. private _loadingDivBackgroundColor;
  11570. private _loadingDiv;
  11571. private _loadingTextDiv;
  11572. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11573. displayLoadingUI(): void;
  11574. hideLoadingUI(): void;
  11575. loadingUIText: string;
  11576. loadingUIBackgroundColor: string;
  11577. private _resizeLoadingUI;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. /**
  11582. * A class serves as a medium between the observable and its observers
  11583. */
  11584. class EventState {
  11585. /**
  11586. * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored
  11587. */
  11588. constructor(mask: number, skipNextObservers?: boolean);
  11589. /**
  11590. * An Observer can set this property to true to prevent subsequent observers of being notified
  11591. */
  11592. skipNextObservers: boolean;
  11593. /**
  11594. * Get the mask value that were used to trigger the event corresponding to this EventState object
  11595. */
  11596. mask: number;
  11597. }
  11598. /**
  11599. * Represent an Observer registered to a given Observable object.
  11600. */
  11601. class Observer<T> {
  11602. callback: (eventData: T, eventState: EventState) => void;
  11603. mask: number;
  11604. constructor(callback: (eventData: T, eventState: EventState) => void, mask: number);
  11605. }
  11606. /**
  11607. * The Observable class is a simple implementation of the Observable pattern.
  11608. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  11609. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  11610. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  11611. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  11612. */
  11613. class Observable<T> {
  11614. _observers: Observer<T>[];
  11615. /**
  11616. * Create a new Observer with the specified callback
  11617. * @param callback the callback that will be executed for that Observer
  11618. * @param mask the mask used to filter observers
  11619. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  11620. */
  11621. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean): Observer<T>;
  11622. /**
  11623. * Remove an Observer from the Observable object
  11624. * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned.
  11625. */
  11626. remove(observer: Observer<T>): boolean;
  11627. /**
  11628. * Remove a callback from the Observable object
  11629. * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned.
  11630. */
  11631. removeCallback(callback: (eventData: T, eventState: EventState) => void): boolean;
  11632. /**
  11633. * Notify all Observers by calling their respective callback with the given data
  11634. * @param eventData
  11635. * @param mask
  11636. */
  11637. notifyObservers(eventData: T, mask?: number): void;
  11638. /**
  11639. * return true is the Observable has at least one Observer registered
  11640. */
  11641. hasObservers(): boolean;
  11642. /**
  11643. * Clear the list of observers
  11644. */
  11645. clear(): void;
  11646. /**
  11647. * Clone the current observable
  11648. */
  11649. clone(): Observable<T>;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /**
  11654. * This class describe a rectangle that were added to the map.
  11655. * You have access to its coordinates either in pixel or normalized (UV)
  11656. */
  11657. class PackedRect {
  11658. constructor(root: PackedRect, parent: PackedRect, pos: Vector2, size: Size);
  11659. /**
  11660. * @returns the position of this node into the map
  11661. */
  11662. pos: Vector2;
  11663. /**
  11664. * @returns the size of the rectangle this node handles
  11665. */
  11666. contentSize: Size;
  11667. /**
  11668. * Compute the UV of the top/left, top/right, bottom/right, bottom/left points of the rectangle this node handles into the map
  11669. * @returns And array of 4 Vector2, containing UV coordinates for the four corners of the Rectangle into the map
  11670. */
  11671. UVs: Vector2[];
  11672. /**
  11673. * Free this rectangle from the map.
  11674. * Call this method when you no longer need the rectangle to be in the map.
  11675. */
  11676. freeContent(): void;
  11677. protected isUsed: boolean;
  11678. protected findAndSplitNode(contentSize: Size): PackedRect;
  11679. private findNode(size);
  11680. private splitNode(contentSize);
  11681. private attemptDefrag();
  11682. private clearNode();
  11683. private isRecursiveFree;
  11684. protected evalFreeSize(size: number): number;
  11685. protected _root: PackedRect;
  11686. protected _parent: PackedRect;
  11687. private _contentSize;
  11688. private _initialSize;
  11689. private _leftNode;
  11690. private _rightNode;
  11691. private _bottomNode;
  11692. private _pos;
  11693. protected _size: Size;
  11694. }
  11695. /**
  11696. * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimally as possible.
  11697. * This class is typically used to build lightmaps, sprite map or to pack several little textures into a big one.
  11698. * Note that this class allows allocated Rectangles to be freed: that is the map is dynamically maintained so you can add/remove rectangle based on their life-cycle.
  11699. */
  11700. class RectPackingMap extends PackedRect {
  11701. /**
  11702. * Create an instance of the object with a dimension using the given size
  11703. * @param size The dimension of the rectangle that will contain all the sub ones.
  11704. */
  11705. constructor(size: Size);
  11706. /**
  11707. * Add a rectangle, finding the best location to store it into the map
  11708. * @param size the dimension of the rectangle to store
  11709. * @return the Node containing the rectangle information, or null if we couldn't find a free spot
  11710. */
  11711. addRect(size: Size): PackedRect;
  11712. /**
  11713. * Return the current space free normalized between [0;1]
  11714. * @returns {}
  11715. */
  11716. freeSpace: number;
  11717. }
  11718. }
  11719. declare module BABYLON {
  11720. class SceneOptimization {
  11721. priority: number;
  11722. apply: (scene: Scene) => boolean;
  11723. constructor(priority?: number);
  11724. }
  11725. class TextureOptimization extends SceneOptimization {
  11726. priority: number;
  11727. maximumSize: number;
  11728. constructor(priority?: number, maximumSize?: number);
  11729. apply: (scene: Scene) => boolean;
  11730. }
  11731. class HardwareScalingOptimization extends SceneOptimization {
  11732. priority: number;
  11733. maximumScale: number;
  11734. private _currentScale;
  11735. constructor(priority?: number, maximumScale?: number);
  11736. apply: (scene: Scene) => boolean;
  11737. }
  11738. class ShadowsOptimization extends SceneOptimization {
  11739. apply: (scene: Scene) => boolean;
  11740. }
  11741. class PostProcessesOptimization extends SceneOptimization {
  11742. apply: (scene: Scene) => boolean;
  11743. }
  11744. class LensFlaresOptimization extends SceneOptimization {
  11745. apply: (scene: Scene) => boolean;
  11746. }
  11747. class ParticlesOptimization extends SceneOptimization {
  11748. apply: (scene: Scene) => boolean;
  11749. }
  11750. class RenderTargetsOptimization extends SceneOptimization {
  11751. apply: (scene: Scene) => boolean;
  11752. }
  11753. class MergeMeshesOptimization extends SceneOptimization {
  11754. static _UpdateSelectionTree: boolean;
  11755. static UpdateSelectionTree: boolean;
  11756. private _canBeMerged;
  11757. apply: (scene: Scene, updateSelectionTree?: boolean) => boolean;
  11758. }
  11759. class SceneOptimizerOptions {
  11760. targetFrameRate: number;
  11761. trackerDuration: number;
  11762. optimizations: SceneOptimization[];
  11763. constructor(targetFrameRate?: number, trackerDuration?: number);
  11764. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  11765. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  11766. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  11767. }
  11768. class SceneOptimizer {
  11769. static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void;
  11770. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void;
  11771. }
  11772. }
  11773. declare module BABYLON {
  11774. class SceneSerializer {
  11775. static ClearCache(): void;
  11776. static Serialize(scene: Scene): any;
  11777. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  11778. }
  11779. }
  11780. declare module BABYLON {
  11781. class SmartArray<T> {
  11782. data: Array<T>;
  11783. length: number;
  11784. private _id;
  11785. private _duplicateId;
  11786. constructor(capacity: number);
  11787. push(value: any): void;
  11788. pushNoDuplicate(value: any): boolean;
  11789. sort(compareFn: any): void;
  11790. reset(): void;
  11791. concat(array: any): void;
  11792. concatWithNoDuplicate(array: any): void;
  11793. indexOf(value: any): number;
  11794. private static _GlobalId;
  11795. }
  11796. }
  11797. declare module BABYLON {
  11798. /**
  11799. * This class implement a typical dictionary using a string as key and the generic type T as value.
  11800. * The underlying implementation relies on an associative array to ensure the best performances.
  11801. * The value can be anything including 'null' but except 'undefined'
  11802. */
  11803. class StringDictionary<T> {
  11804. /**
  11805. * Get a value based from its key
  11806. * @param key the given key to get the matching value from
  11807. * @return the value if found, otherwise undefined is returned
  11808. */
  11809. get(key: string): T;
  11810. /**
  11811. * Get a value from its key or add it if it doesn't exist.
  11812. * This method will ensure you that a given key/data will be present in the dictionary.
  11813. * @param key the given key to get the matching value from
  11814. * @param factory the factory that will create the value if the key is not present in the dictionary.
  11815. * The factory will only be invoked if there's no data for the given key.
  11816. * @return the value corresponding to the key.
  11817. */
  11818. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  11819. /**
  11820. * Get a value from its key if present in the dictionary otherwise add it
  11821. * @param key the key to get the value from
  11822. * @param val if there's no such key/value pair in the dictionary add it with this value
  11823. * @return the value corresponding to the key
  11824. */
  11825. getOrAdd(key: string, val: T): T;
  11826. /**
  11827. * Check if there's a given key in the dictionary
  11828. * @param key the key to check for
  11829. * @return true if the key is present, false otherwise
  11830. */
  11831. contains(key: any): boolean;
  11832. /**
  11833. * Add a new key and its corresponding value
  11834. * @param key the key to add
  11835. * @param value the value corresponding to the key
  11836. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  11837. */
  11838. add(key: string, value: T): boolean;
  11839. set(key: string, value: T): boolean;
  11840. /**
  11841. * Remove a key/value from the dictionary.
  11842. * @param key the key to remove
  11843. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  11844. */
  11845. remove(key: string): boolean;
  11846. /**
  11847. * Clear the whole content of the dictionary
  11848. */
  11849. clear(): void;
  11850. count: number;
  11851. /**
  11852. * Execute a callback on each key/val of the dictionary.
  11853. * Note that you can remove any element in this dictionary in the callback implementation
  11854. * @param callback the callback to execute on a given key/value pair
  11855. */
  11856. forEach(callback: (key: string, val: T) => void): void;
  11857. /**
  11858. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  11859. * If the callback returns null or undefined the method will iterate to the next key/value pair
  11860. * Note that you can remove any element in this dictionary in the callback implementation
  11861. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  11862. */
  11863. first<TRes>(callback: (key: string, val: T) => TRes): TRes;
  11864. private _count;
  11865. private _data;
  11866. }
  11867. }
  11868. declare module BABYLON {
  11869. class Tags {
  11870. static EnableFor(obj: any): void;
  11871. static DisableFor(obj: any): void;
  11872. static HasTags(obj: any): boolean;
  11873. static GetTags(obj: any, asString?: boolean): any;
  11874. static AddTagsTo(obj: any, tagsString: string): void;
  11875. static _AddTagTo(obj: any, tag: string): void;
  11876. static RemoveTagsFrom(obj: any, tagsString: string): void;
  11877. static _RemoveTagFrom(obj: any, tag: string): void;
  11878. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  11879. }
  11880. }
  11881. declare module BABYLON.Internals {
  11882. interface DDSInfo {
  11883. width: number;
  11884. height: number;
  11885. mipmapCount: number;
  11886. isFourCC: boolean;
  11887. isRGB: boolean;
  11888. isLuminance: boolean;
  11889. isCube: boolean;
  11890. }
  11891. class DDSTools {
  11892. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  11893. private static GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  11894. private static GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  11895. private static GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  11896. static UploadDDSLevels(gl: WebGLRenderingContext, ext: any, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number): void;
  11897. }
  11898. }
  11899. declare module BABYLON.Internals {
  11900. class TGATools {
  11901. private static _TYPE_NO_DATA;
  11902. private static _TYPE_INDEXED;
  11903. private static _TYPE_RGB;
  11904. private static _TYPE_GREY;
  11905. private static _TYPE_RLE_INDEXED;
  11906. private static _TYPE_RLE_RGB;
  11907. private static _TYPE_RLE_GREY;
  11908. private static _ORIGIN_MASK;
  11909. private static _ORIGIN_SHIFT;
  11910. private static _ORIGIN_BL;
  11911. private static _ORIGIN_BR;
  11912. private static _ORIGIN_UL;
  11913. private static _ORIGIN_UR;
  11914. static GetTGAHeader(data: Uint8Array): any;
  11915. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  11916. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  11917. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  11918. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  11919. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  11920. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  11921. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  11922. }
  11923. }
  11924. declare module BABYLON {
  11925. interface IAnimatable {
  11926. animations: Array<Animation>;
  11927. }
  11928. class Tools {
  11929. static BaseUrl: string;
  11930. static CorsBehavior: any;
  11931. static UseFallbackTexture: boolean;
  11932. static Instantiate(className: string): any;
  11933. static SetImmediate(action: () => void): void;
  11934. static IsExponentOfTwo(value: number): boolean;
  11935. static GetExponentOfTwo(value: number, max: number): number;
  11936. static GetFilename(path: string): string;
  11937. static GetDOMTextContent(element: HTMLElement): string;
  11938. static ToDegrees(angle: number): number;
  11939. static ToRadians(angle: number): number;
  11940. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  11941. static ExtractMinAndMaxIndexed(positions: number[] | Float32Array, indices: number[] | Int32Array, indexStart: number, indexCount: number, bias?: Vector2): {
  11942. minimum: Vector3;
  11943. maximum: Vector3;
  11944. };
  11945. static ExtractMinAndMax(positions: number[] | Float32Array, start: number, count: number, bias?: Vector2, stride?: number): {
  11946. minimum: Vector3;
  11947. maximum: Vector3;
  11948. };
  11949. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i) => Vector2;
  11950. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Vector2): {
  11951. minimum: Vector2;
  11952. maximum: Vector2;
  11953. };
  11954. static MakeArray(obj: any, allowsNullUndefined?: boolean): Array<any>;
  11955. static GetPointerPrefix(): string;
  11956. static QueueNewFrame(func: any): void;
  11957. static RequestFullscreen(element: any, options?: any): void;
  11958. static ExitFullscreen(): void;
  11959. static CleanUrl(url: string): string;
  11960. static LoadImage(url: any, onload: any, onerror: any, database: any): HTMLImageElement;
  11961. static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?: any, useArrayBuffer?: boolean, onError?: () => void): void;
  11962. static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void;
  11963. static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void;
  11964. static FileAsURL(content: string): string;
  11965. static Format(value: number, decimals?: number): string;
  11966. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  11967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  11968. static IsEmpty(obj: any): boolean;
  11969. static RegisterTopRootEvents(events: {
  11970. name: string;
  11971. handler: EventListener;
  11972. }[]): void;
  11973. static UnregisterTopRootEvents(events: {
  11974. name: string;
  11975. handler: EventListener;
  11976. }[]): void;
  11977. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void): void;
  11978. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void): void;
  11979. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  11980. private static _NoneLogLevel;
  11981. private static _MessageLogLevel;
  11982. private static _WarningLogLevel;
  11983. private static _ErrorLogLevel;
  11984. private static _LogCache;
  11985. static errorsCount: number;
  11986. static OnNewCacheEntry: (entry: string) => void;
  11987. static NoneLogLevel: number;
  11988. static MessageLogLevel: number;
  11989. static WarningLogLevel: number;
  11990. static ErrorLogLevel: number;
  11991. static AllLogLevel: number;
  11992. private static _AddLogEntry(entry);
  11993. private static _FormatMessage(message);
  11994. static Log: (message: string) => void;
  11995. private static _LogDisabled(message);
  11996. private static _LogEnabled(message);
  11997. static Warn: (message: string) => void;
  11998. private static _WarnDisabled(message);
  11999. private static _WarnEnabled(message);
  12000. static Error: (message: string) => void;
  12001. private static _ErrorDisabled(message);
  12002. private static _ErrorEnabled(message);
  12003. static LogCache: string;
  12004. static ClearLogCache(): void;
  12005. static LogLevels: number;
  12006. private static _PerformanceNoneLogLevel;
  12007. private static _PerformanceUserMarkLogLevel;
  12008. private static _PerformanceConsoleLogLevel;
  12009. private static _performance;
  12010. static PerformanceNoneLogLevel: number;
  12011. static PerformanceUserMarkLogLevel: number;
  12012. static PerformanceConsoleLogLevel: number;
  12013. static PerformanceLogLevel: number;
  12014. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  12015. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  12016. static _StartUserMark(counterName: string, condition?: boolean): void;
  12017. static _EndUserMark(counterName: string, condition?: boolean): void;
  12018. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  12019. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  12020. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  12021. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  12022. static Now: number;
  12023. /**
  12024. * This method will return the name of the class used to create the instance of the given object.
  12025. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  12026. * @param object the object to get the class name from
  12027. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  12028. */
  12029. static getClassName(object: any, isType?: boolean): string;
  12030. static first<T>(array: Array<T>, predicate: (item) => boolean): T;
  12031. /**
  12032. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  12033. * @param array
  12034. */
  12035. static arrayOrStringFeeder(array: any): (i) => number;
  12036. /**
  12037. * Compute the hashCode of a stream of number
  12038. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  12039. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  12040. * @return the hash code computed
  12041. */
  12042. static hashCodeFromStream(feeder: (index: number) => number): number;
  12043. }
  12044. /**
  12045. * Use this className as a decorator on a given class definition to add it a name.
  12046. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  12047. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  12048. * @param name
  12049. */
  12050. function className(name: string): (target: Object) => void;
  12051. /**
  12052. * An implementation of a loop for asynchronous functions.
  12053. */
  12054. class AsyncLoop {
  12055. iterations: number;
  12056. private _fn;
  12057. private _successCallback;
  12058. index: number;
  12059. private _done;
  12060. /**
  12061. * Constroctor.
  12062. * @param iterations the number of iterations.
  12063. * @param _fn the function to run each iteration
  12064. * @param _successCallback the callback that will be called upon succesful execution
  12065. * @param offset starting offset.
  12066. */
  12067. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  12068. /**
  12069. * Execute the next iteration. Must be called after the last iteration was finished.
  12070. */
  12071. executeNext(): void;
  12072. /**
  12073. * Break the loop and run the success callback.
  12074. */
  12075. breakLoop(): void;
  12076. /**
  12077. * Helper function
  12078. */
  12079. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  12080. /**
  12081. * A for-loop that will run a given number of iterations synchronous and the rest async.
  12082. * @param iterations total number of iterations
  12083. * @param syncedIterations number of synchronous iterations in each async iteration.
  12084. * @param fn the function to call each iteration.
  12085. * @param callback a success call back that will be called when iterating stops.
  12086. * @param breakFunction a break condition (optional)
  12087. * @param timeout timeout settings for the setTimeout function. default - 0.
  12088. * @constructor
  12089. */
  12090. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  12091. }
  12092. }
  12093. declare module BABYLON {
  12094. enum JoystickAxis {
  12095. X = 0,
  12096. Y = 1,
  12097. Z = 2,
  12098. }
  12099. class VirtualJoystick {
  12100. reverseLeftRight: boolean;
  12101. reverseUpDown: boolean;
  12102. deltaPosition: Vector3;
  12103. pressed: boolean;
  12104. private static _globalJoystickIndex;
  12105. private static vjCanvas;
  12106. private static vjCanvasContext;
  12107. private static vjCanvasWidth;
  12108. private static vjCanvasHeight;
  12109. private static halfWidth;
  12110. private static halfHeight;
  12111. private _action;
  12112. private _axisTargetedByLeftAndRight;
  12113. private _axisTargetedByUpAndDown;
  12114. private _joystickSensibility;
  12115. private _inversedSensibility;
  12116. private _rotationSpeed;
  12117. private _inverseRotationSpeed;
  12118. private _rotateOnAxisRelativeToMesh;
  12119. private _joystickPointerID;
  12120. private _joystickColor;
  12121. private _joystickPointerPos;
  12122. private _joystickPreviousPointerPos;
  12123. private _joystickPointerStartPos;
  12124. private _deltaJoystickVector;
  12125. private _leftJoystick;
  12126. private _joystickIndex;
  12127. private _touches;
  12128. private _onPointerDownHandlerRef;
  12129. private _onPointerMoveHandlerRef;
  12130. private _onPointerUpHandlerRef;
  12131. private _onPointerOutHandlerRef;
  12132. private _onResize;
  12133. constructor(leftJoystick?: boolean);
  12134. setJoystickSensibility(newJoystickSensibility: number): void;
  12135. private _onPointerDown(e);
  12136. private _onPointerMove(e);
  12137. private _onPointerUp(e);
  12138. /**
  12139. * Change the color of the virtual joystick
  12140. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  12141. */
  12142. setJoystickColor(newColor: string): void;
  12143. setActionOnTouch(action: () => any): void;
  12144. setAxisForLeftRight(axis: JoystickAxis): void;
  12145. setAxisForUpDown(axis: JoystickAxis): void;
  12146. private _clearCanvas();
  12147. private _drawVirtualJoystick();
  12148. releaseCanvas(): void;
  12149. }
  12150. }
  12151. declare module BABYLON {
  12152. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  12153. camera: ArcRotateCamera;
  12154. gamepad: Gamepad;
  12155. private _gamepads;
  12156. gamepadRotationSensibility: number;
  12157. gamepadMoveSensibility: number;
  12158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12159. detachControl(element: HTMLElement): void;
  12160. checkInputs(): void;
  12161. private _onNewGameConnected(gamepad);
  12162. getTypeName(): string;
  12163. getSimpleName(): string;
  12164. }
  12165. }
  12166. declare module BABYLON {
  12167. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  12168. camera: ArcRotateCamera;
  12169. private _keys;
  12170. private _onKeyDown;
  12171. private _onKeyUp;
  12172. private _onLostFocus;
  12173. keysUp: number[];
  12174. keysDown: number[];
  12175. keysLeft: number[];
  12176. keysRight: number[];
  12177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12178. detachControl(element: HTMLElement): void;
  12179. checkInputs(): void;
  12180. getTypeName(): string;
  12181. getSimpleName(): string;
  12182. }
  12183. }
  12184. declare module BABYLON {
  12185. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  12186. camera: ArcRotateCamera;
  12187. private _wheel;
  12188. private _observer;
  12189. wheelPrecision: number;
  12190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12191. detachControl(element: HTMLElement): void;
  12192. getTypeName(): string;
  12193. getSimpleName(): string;
  12194. }
  12195. }
  12196. declare module BABYLON {
  12197. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  12198. camera: ArcRotateCamera;
  12199. angularSensibilityX: number;
  12200. angularSensibilityY: number;
  12201. pinchPrecision: number;
  12202. panningSensibility: number;
  12203. private _isRightClick;
  12204. private _isCtrlPushed;
  12205. pinchInwards: boolean;
  12206. private _pointerInput;
  12207. private _observer;
  12208. private _onKeyDown;
  12209. private _onKeyUp;
  12210. private _onMouseMove;
  12211. private _onGestureStart;
  12212. private _onGesture;
  12213. private _MSGestureHandler;
  12214. private _onLostFocus;
  12215. private _onContextMenu;
  12216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12217. detachControl(element: HTMLElement): void;
  12218. getTypeName(): string;
  12219. getSimpleName(): string;
  12220. }
  12221. }
  12222. declare module BABYLON {
  12223. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  12224. camera: ArcRotateCamera;
  12225. alphaCorrection: number;
  12226. betaCorrection: number;
  12227. gammaCorrection: number;
  12228. private _alpha;
  12229. private _beta;
  12230. private _gamma;
  12231. private _dirty;
  12232. private _offsetOrientation;
  12233. private _deviceOrientationHandler;
  12234. constructor();
  12235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12236. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  12237. checkInputs(): void;
  12238. detachControl(element: HTMLElement): void;
  12239. getTypeName(): string;
  12240. getSimpleName(): string;
  12241. }
  12242. }
  12243. declare module BABYLON {
  12244. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  12245. private _camera;
  12246. private _screenOrientationAngle;
  12247. private _constantTranform;
  12248. private _screenQuaternion;
  12249. private _alpha;
  12250. private _beta;
  12251. private _gamma;
  12252. constructor();
  12253. camera: FreeCamera;
  12254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12255. private _orientationChanged;
  12256. private _deviceOrientation;
  12257. detachControl(element: HTMLElement): void;
  12258. checkInputs(): void;
  12259. getTypeName(): string;
  12260. getSimpleName(): string;
  12261. }
  12262. }
  12263. declare module BABYLON {
  12264. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  12265. camera: FreeCamera;
  12266. gamepad: Gamepad;
  12267. private _gamepads;
  12268. gamepadAngularSensibility: number;
  12269. gamepadMoveSensibility: number;
  12270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12271. detachControl(element: HTMLElement): void;
  12272. checkInputs(): void;
  12273. private _onNewGameConnected(gamepad);
  12274. getTypeName(): string;
  12275. getSimpleName(): string;
  12276. }
  12277. }
  12278. declare module BABYLON {
  12279. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  12280. camera: FreeCamera;
  12281. private _keys;
  12282. private _onKeyDown;
  12283. private _onKeyUp;
  12284. keysUp: number[];
  12285. keysDown: number[];
  12286. keysLeft: number[];
  12287. keysRight: number[];
  12288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12289. detachControl(element: HTMLElement): void;
  12290. checkInputs(): void;
  12291. getTypeName(): string;
  12292. _onLostFocus(e: FocusEvent): void;
  12293. getSimpleName(): string;
  12294. }
  12295. }
  12296. declare module BABYLON {
  12297. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12298. touchEnabled: boolean;
  12299. camera: FreeCamera;
  12300. angularSensibility: number;
  12301. private _pointerInput;
  12302. private _observer;
  12303. private previousPosition;
  12304. constructor(touchEnabled?: boolean);
  12305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12306. detachControl(element: HTMLElement): void;
  12307. getTypeName(): string;
  12308. getSimpleName(): string;
  12309. }
  12310. }
  12311. declare module BABYLON {
  12312. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12313. camera: FreeCamera;
  12314. private _offsetX;
  12315. private _offsetY;
  12316. private _pointerCount;
  12317. private _pointerPressed;
  12318. private _pointerInput;
  12319. private _observer;
  12320. private _onLostFocus;
  12321. touchAngularSensibility: number;
  12322. touchMoveSensibility: number;
  12323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12324. detachControl(element: HTMLElement): void;
  12325. checkInputs(): void;
  12326. getTypeName(): string;
  12327. getSimpleName(): string;
  12328. }
  12329. }
  12330. declare module BABYLON {
  12331. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  12332. camera: FreeCamera;
  12333. private _leftjoystick;
  12334. private _rightjoystick;
  12335. getLeftJoystick(): VirtualJoystick;
  12336. getRightJoystick(): VirtualJoystick;
  12337. checkInputs(): void;
  12338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12339. detachControl(element: HTMLElement): void;
  12340. getTypeName(): string;
  12341. getSimpleName(): string;
  12342. }
  12343. }
  12344. declare module BABYLON {
  12345. class FreeCameraVRDeviceOrientationInput implements ICameraInput<FreeCamera> {
  12346. camera: FreeCamera;
  12347. alphaCorrection: number;
  12348. betaCorrection: number;
  12349. gammaCorrection: number;
  12350. private _alpha;
  12351. private _beta;
  12352. private _gamma;
  12353. private _dirty;
  12354. private _offsetOrientation;
  12355. private _deviceOrientationHandler;
  12356. constructor();
  12357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12358. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  12359. checkInputs(): void;
  12360. detachControl(element: HTMLElement): void;
  12361. getTypeName(): string;
  12362. getSimpleName(): string;
  12363. }
  12364. }
  12365. declare module BABYLON {
  12366. class VRCameraMetrics {
  12367. hResolution: number;
  12368. vResolution: number;
  12369. hScreenSize: number;
  12370. vScreenSize: number;
  12371. vScreenCenter: number;
  12372. eyeToScreenDistance: number;
  12373. lensSeparationDistance: number;
  12374. interpupillaryDistance: number;
  12375. distortionK: number[];
  12376. chromaAbCorrection: number[];
  12377. postProcessScaleFactor: number;
  12378. lensCenterOffset: number;
  12379. compensateDistortion: boolean;
  12380. aspectRatio: number;
  12381. aspectRatioFov: number;
  12382. leftHMatrix: Matrix;
  12383. rightHMatrix: Matrix;
  12384. leftPreViewMatrix: Matrix;
  12385. rightPreViewMatrix: Matrix;
  12386. static GetDefault(): VRCameraMetrics;
  12387. }
  12388. }
  12389. declare module BABYLON {
  12390. class VRDeviceOrientationFreeCamera extends FreeCamera {
  12391. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean);
  12392. getTypeName(): string;
  12393. }
  12394. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  12395. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean);
  12396. getTypeName(): string;
  12397. }
  12398. }
  12399. declare var HMDVRDevice: any;
  12400. declare var PositionSensorVRDevice: any;
  12401. declare module BABYLON {
  12402. class WebVRFreeCamera extends FreeCamera {
  12403. _hmdDevice: any;
  12404. _sensorDevice: any;
  12405. private _cacheState;
  12406. _vrEnabled: boolean;
  12407. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean);
  12408. private _getWebVRDevices(devices);
  12409. _checkInputs(): void;
  12410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12411. detachControl(element: HTMLElement): void;
  12412. requestVRFullscreen(requestPointerlock: boolean): void;
  12413. getTypeName(): string;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. interface IOctreeContainer<T> {
  12418. blocks: Array<OctreeBlock<T>>;
  12419. }
  12420. class Octree<T> {
  12421. maxDepth: number;
  12422. blocks: Array<OctreeBlock<T>>;
  12423. dynamicContent: T[];
  12424. private _maxBlockCapacity;
  12425. private _selectionContent;
  12426. private _creationFunc;
  12427. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  12428. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  12429. addMesh(entry: T): void;
  12430. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  12431. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  12432. intersectsRay(ray: Ray): SmartArray<T>;
  12433. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  12434. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  12435. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. class OctreeBlock<T> {
  12440. entries: T[];
  12441. blocks: Array<OctreeBlock<T>>;
  12442. private _depth;
  12443. private _maxDepth;
  12444. private _capacity;
  12445. private _minPoint;
  12446. private _maxPoint;
  12447. private _boundingVectors;
  12448. private _creationFunc;
  12449. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  12450. capacity: number;
  12451. minPoint: Vector3;
  12452. maxPoint: Vector3;
  12453. addEntry(entry: T): void;
  12454. addEntries(entries: T[]): void;
  12455. select(frustumPlanes: Plane[], selection: SmartArray<T>, allowDuplicate?: boolean): void;
  12456. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray<T>, allowDuplicate?: boolean): void;
  12457. intersectsRay(ray: Ray, selection: SmartArray<T>): void;
  12458. createInnerBlocks(): void;
  12459. }
  12460. }
  12461. declare module BABYLON {
  12462. class ShadowGenerator {
  12463. private static _FILTER_NONE;
  12464. private static _FILTER_VARIANCESHADOWMAP;
  12465. private static _FILTER_POISSONSAMPLING;
  12466. private static _FILTER_BLURVARIANCESHADOWMAP;
  12467. static FILTER_NONE: number;
  12468. static FILTER_VARIANCESHADOWMAP: number;
  12469. static FILTER_POISSONSAMPLING: number;
  12470. static FILTER_BLURVARIANCESHADOWMAP: number;
  12471. private _filter;
  12472. blurScale: number;
  12473. private _blurBoxOffset;
  12474. private _bias;
  12475. private _lightDirection;
  12476. forceBackFacesOnly: boolean;
  12477. bias: number;
  12478. blurBoxOffset: number;
  12479. filter: number;
  12480. useVarianceShadowMap: boolean;
  12481. usePoissonSampling: boolean;
  12482. useBlurVarianceShadowMap: boolean;
  12483. private _light;
  12484. private _scene;
  12485. private _shadowMap;
  12486. private _shadowMap2;
  12487. private _darkness;
  12488. private _transparencyShadow;
  12489. private _effect;
  12490. private _viewMatrix;
  12491. private _projectionMatrix;
  12492. private _transformMatrix;
  12493. private _worldViewProjection;
  12494. private _cachedPosition;
  12495. private _cachedDirection;
  12496. private _cachedDefines;
  12497. private _currentRenderID;
  12498. private _downSamplePostprocess;
  12499. private _boxBlurPostprocess;
  12500. private _mapSize;
  12501. private _currentFaceIndex;
  12502. private _currentFaceIndexCache;
  12503. constructor(mapSize: number, light: IShadowLight);
  12504. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  12505. getShadowMap(): RenderTargetTexture;
  12506. getShadowMapForRendering(): RenderTargetTexture;
  12507. getLight(): IShadowLight;
  12508. getTransformMatrix(): Matrix;
  12509. getDarkness(): number;
  12510. setDarkness(darkness: number): void;
  12511. setTransparencyShadow(hasShadow: boolean): void;
  12512. private _packHalf(depth);
  12513. dispose(): void;
  12514. serialize(): any;
  12515. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  12516. }
  12517. }
  12518. declare module BABYLON.Internals {
  12519. }
  12520. declare module BABYLON {
  12521. class BaseTexture {
  12522. name: string;
  12523. hasAlpha: boolean;
  12524. getAlphaFromRGB: boolean;
  12525. level: number;
  12526. coordinatesIndex: number;
  12527. coordinatesMode: number;
  12528. wrapU: number;
  12529. wrapV: number;
  12530. anisotropicFilteringLevel: number;
  12531. isCube: boolean;
  12532. isRenderTarget: boolean;
  12533. toString(): string;
  12534. animations: Animation[];
  12535. /**
  12536. * An event triggered when the texture is disposed.
  12537. * @type {BABYLON.Observable}
  12538. */
  12539. onDisposeObservable: Observable<BaseTexture>;
  12540. private _onDisposeObserver;
  12541. onDispose: () => void;
  12542. delayLoadState: number;
  12543. _cachedAnisotropicFilteringLevel: number;
  12544. private _scene;
  12545. _texture: WebGLTexture;
  12546. constructor(scene: Scene);
  12547. getScene(): Scene;
  12548. getTextureMatrix(): Matrix;
  12549. getReflectionTextureMatrix(): Matrix;
  12550. getInternalTexture(): WebGLTexture;
  12551. isReady(): boolean;
  12552. getSize(): ISize;
  12553. getBaseSize(): ISize;
  12554. scale(ratio: number): void;
  12555. canRescale: boolean;
  12556. _removeFromCache(url: string, noMipmap: boolean): void;
  12557. _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture;
  12558. delayLoad(): void;
  12559. clone(): BaseTexture;
  12560. releaseInternalTexture(): void;
  12561. dispose(): void;
  12562. serialize(): any;
  12563. }
  12564. }
  12565. declare module BABYLON {
  12566. /**
  12567. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  12568. * It can help converting any input color in a desired output one. This can then be used to create effects
  12569. * from sepia, black and white to sixties or futuristic rendering...
  12570. *
  12571. * The only supported format is currently 3dl.
  12572. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  12573. */
  12574. class ColorGradingTexture extends BaseTexture {
  12575. /**
  12576. * The current internal texture size.
  12577. */
  12578. private _size;
  12579. /**
  12580. * The current texture matrix. (will always be identity in color grading texture)
  12581. */
  12582. private _textureMatrix;
  12583. /**
  12584. * The texture URL.
  12585. */
  12586. url: string;
  12587. /**
  12588. * Empty line regex stored for GC.
  12589. */
  12590. private static _noneEmptyLineRegex;
  12591. /**
  12592. * Instantiates a ColorGradingTexture from the following parameters.
  12593. *
  12594. * @param url The location of the color gradind data (currently only supporting 3dl)
  12595. * @param scene The scene the texture will be used in
  12596. */
  12597. constructor(url: string, scene: Scene);
  12598. /**
  12599. * Returns the texture matrix used in most of the material.
  12600. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  12601. */
  12602. getTextureMatrix(): Matrix;
  12603. /**
  12604. * Occurs when the file being loaded is a .3dl LUT file.
  12605. */
  12606. private load3dlTexture();
  12607. /**
  12608. * Starts the loading process of the texture.
  12609. */
  12610. private loadTexture();
  12611. /**
  12612. * Clones the color gradind texture.
  12613. */
  12614. clone(): ColorGradingTexture;
  12615. /**
  12616. * Called during delayed load for textures.
  12617. */
  12618. delayLoad(): void;
  12619. /**
  12620. * Parses a color grading texture serialized by Babylon.
  12621. * @param parsedTexture The texture information being parsedTexture
  12622. * @param scene The scene to load the texture in
  12623. * @param rootUrl The root url of the data assets to load
  12624. * @return A color gradind texture
  12625. */
  12626. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): ColorGradingTexture;
  12627. /**
  12628. * Serializes the LUT texture to json format.
  12629. */
  12630. serialize(): any;
  12631. }
  12632. }
  12633. declare module BABYLON {
  12634. class CubeTexture extends BaseTexture {
  12635. url: string;
  12636. coordinatesMode: number;
  12637. private _noMipmap;
  12638. private _files;
  12639. private _extensions;
  12640. private _textureMatrix;
  12641. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  12642. constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean, files?: string[]);
  12643. delayLoad(): void;
  12644. getReflectionTextureMatrix(): Matrix;
  12645. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  12646. clone(): CubeTexture;
  12647. }
  12648. }
  12649. declare module BABYLON {
  12650. class DynamicTexture extends Texture {
  12651. private _generateMipMaps;
  12652. private _canvas;
  12653. private _context;
  12654. constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number);
  12655. canRescale: boolean;
  12656. scale(ratio: number): void;
  12657. getContext(): CanvasRenderingContext2D;
  12658. clear(): void;
  12659. update(invertY?: boolean): void;
  12660. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  12661. clone(): DynamicTexture;
  12662. }
  12663. }
  12664. declare module BABYLON {
  12665. /**
  12666. * This class given information about a given character.
  12667. */
  12668. class CharInfo {
  12669. /**
  12670. * The normalized ([0;1]) top/left position of the character in the texture
  12671. */
  12672. topLeftUV: Vector2;
  12673. /**
  12674. * The normalized ([0;1]) right/bottom position of the character in the texture
  12675. */
  12676. bottomRightUV: Vector2;
  12677. charWidth: number;
  12678. }
  12679. class FontTexture extends Texture {
  12680. private _canvas;
  12681. private _context;
  12682. private _lineHeight;
  12683. private _offset;
  12684. private _currentFreePosition;
  12685. private _charInfos;
  12686. private _curCharCount;
  12687. private _lastUpdateCharCount;
  12688. private _spaceWidth;
  12689. private _usedCounter;
  12690. spaceWidth: number;
  12691. lineHeight: number;
  12692. static GetCachedFontTexture(scene: Scene, fontName: string): FontTexture;
  12693. static ReleaseCachedFontTexture(scene: Scene, fontName: string): void;
  12694. /**
  12695. * Create a new instance of the FontTexture class
  12696. * @param name the name of the texture
  12697. * @param font the font to use, use the W3C CSS notation
  12698. * @param scene the scene that owns the texture
  12699. * @param maxCharCount the approximative maximum count of characters that could fit in the texture. This is an approximation because most of the fonts are proportional (each char has its own Width). The 'W' character's width is used to compute the size of the texture based on the given maxCharCount
  12700. * @param samplingMode the texture sampling mode
  12701. */
  12702. constructor(name: string, font: string, scene: Scene, maxCharCount?: number, samplingMode?: number);
  12703. /**
  12704. * Make sure the given char is present in the font map.
  12705. * @param char the character to get or add
  12706. * @return the CharInfo instance corresponding to the given character
  12707. */
  12708. getChar(char: string): CharInfo;
  12709. measureText(text: string, tabulationSize?: number): Size;
  12710. private getFontHeight(font);
  12711. canRescale: boolean;
  12712. getContext(): CanvasRenderingContext2D;
  12713. /**
  12714. * Call this method when you've call getChar() at least one time, this will update the texture if needed.
  12715. * Don't be afraid to call it, if no new character was added, this method simply does nothing.
  12716. */
  12717. update(): void;
  12718. clone(): FontTexture;
  12719. }
  12720. }
  12721. declare module BABYLON {
  12722. /**
  12723. * This represents a texture coming from an HDR input.
  12724. *
  12725. * The only supported format is currently panorama picture stored in RGBE format.
  12726. * Example of such files can be found on HDRLib: http://hdrlib.com/
  12727. */
  12728. class HDRCubeTexture extends BaseTexture {
  12729. private static _facesMapping;
  12730. private _useInGammaSpace;
  12731. private _generateHarmonics;
  12732. private _noMipmap;
  12733. private _extensions;
  12734. private _textureMatrix;
  12735. private _size;
  12736. private _usePMREMGenerator;
  12737. private _isBABYLONPreprocessed;
  12738. /**
  12739. * The texture URL.
  12740. */
  12741. url: string;
  12742. /**
  12743. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  12744. */
  12745. coordinatesMode: number;
  12746. /**
  12747. * The spherical polynomial data extracted from the texture.
  12748. */
  12749. sphericalPolynomial: SphericalPolynomial;
  12750. /**
  12751. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  12752. * This is usefull at run time to apply the good shader.
  12753. */
  12754. isPMREM: boolean;
  12755. /**
  12756. * Instantiates an HDRTexture from the following parameters.
  12757. *
  12758. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  12759. * @param scene The scene the texture will be used in
  12760. * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  12761. * @param noMipmap Forces to not generate the mipmap if true
  12762. * @param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process
  12763. * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  12764. * @param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  12765. */
  12766. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean);
  12767. /**
  12768. * Occurs when the file is a preprocessed .babylon.hdr file.
  12769. */
  12770. private loadBabylonTexture();
  12771. /**
  12772. * Occurs when the file is raw .hdr file.
  12773. */
  12774. private loadHDRTexture();
  12775. /**
  12776. * Starts the loading process of the texture.
  12777. */
  12778. private loadTexture();
  12779. clone(): HDRCubeTexture;
  12780. delayLoad(): void;
  12781. getReflectionTextureMatrix(): Matrix;
  12782. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): HDRCubeTexture;
  12783. serialize(): any;
  12784. /**
  12785. * Saves as a file the data contained in the texture in a binary format.
  12786. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  12787. * as the spherical used in the lighting.
  12788. * @param url The HDR file url.
  12789. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  12790. * @param onError Method called if any error happens during download.
  12791. * @return The packed binary data.
  12792. */
  12793. static generateBabylonHDROnDisk(url: string, size: number, onError?: (() => void)): void;
  12794. /**
  12795. * Serializes the data contained in the texture in a binary format.
  12796. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  12797. * as the spherical used in the lighting.
  12798. * @param url The HDR file url.
  12799. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  12800. * @param onError Method called if any error happens during download.
  12801. * @return The packed binary data.
  12802. */
  12803. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer) => void), onError?: (() => void)): void;
  12804. }
  12805. }
  12806. declare module BABYLON {
  12807. class MapTexture extends Texture {
  12808. private _rectPackingMap;
  12809. private _size;
  12810. private _replacedViewport;
  12811. constructor(name: string, scene: Scene, size: ISize, samplingMode?: number);
  12812. /**
  12813. * Allocate a rectangle of a given size in the texture map
  12814. * @param size the size of the rectangle to allocation
  12815. * @return the PackedRect instance corresponding to the allocated rect or null is there was not enough space to allocate it.
  12816. */
  12817. allocateRect(size: Size): PackedRect;
  12818. /**
  12819. * Free a given rectangle from the texture map
  12820. * @param rectInfo the instance corresponding to the rect to free.
  12821. */
  12822. freeRect(rectInfo: PackedRect): void;
  12823. /**
  12824. * Return the available space in the range of [O;1]. 0 being not space left at all, 1 being an empty texture map.
  12825. * This is the cumulated space, not the biggest available surface. Due to fragmentation you may not allocate a rect corresponding to this surface.
  12826. * @returns {}
  12827. */
  12828. freeSpace: number;
  12829. /**
  12830. * Bind the texture to the rendering engine to render in the zone of a given rectangle.
  12831. * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect.
  12832. * Don't forget to call unbindTexture when you're done rendering
  12833. * @param rect the zone to render to
  12834. * @param clear true to clear the portion's color/depth data
  12835. */
  12836. bindTextureForRect(rect: PackedRect, clear: boolean): void;
  12837. /**
  12838. * Bind the texture to the rendering engine to render in the zone of the given size at the given position.
  12839. * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect.
  12840. * Don't forget to call unbindTexture when you're done rendering
  12841. * @param pos the position into the texture
  12842. * @param size the portion to fit the clip space to
  12843. * @param clear true to clear the portion's color/depth data
  12844. */
  12845. bindTextureForPosSize(pos: Vector2, size: Size, clear: boolean): void;
  12846. /**
  12847. * Unbind the texture map from the rendering engine.
  12848. * Call this method when you're done rendering. A previous call to bindTextureForRect has to be made.
  12849. * @param dumpForDebug if set to true the content of the texture map will be dumped to a picture file that will be sent to the internet browser.
  12850. */
  12851. unbindTexture(dumpForDebug?: boolean): void;
  12852. canRescale: boolean;
  12853. clone(): MapTexture;
  12854. }
  12855. }
  12856. declare module BABYLON {
  12857. class MirrorTexture extends RenderTargetTexture {
  12858. mirrorPlane: Plane;
  12859. private _transformMatrix;
  12860. private _mirrorMatrix;
  12861. private _savedViewMatrix;
  12862. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  12863. clone(): MirrorTexture;
  12864. serialize(): any;
  12865. }
  12866. }
  12867. declare module BABYLON {
  12868. class RawTexture extends Texture {
  12869. format: number;
  12870. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  12871. update(data: ArrayBufferView): void;
  12872. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12873. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12874. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12875. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12876. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12877. }
  12878. }
  12879. declare module BABYLON {
  12880. /**
  12881. * Creates a refraction texture used by refraction channel of the standard material.
  12882. * @param name the texture name
  12883. * @param size size of the underlying texture
  12884. * @param scene root scene
  12885. */
  12886. class RefractionTexture extends RenderTargetTexture {
  12887. refractionPlane: Plane;
  12888. depth: number;
  12889. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  12890. clone(): RefractionTexture;
  12891. serialize(): any;
  12892. }
  12893. }
  12894. declare module BABYLON {
  12895. class RenderTargetTexture extends Texture {
  12896. isCube: boolean;
  12897. static _REFRESHRATE_RENDER_ONCE: number;
  12898. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  12899. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  12900. static REFRESHRATE_RENDER_ONCE: number;
  12901. static REFRESHRATE_RENDER_ONEVERYFRAME: number;
  12902. static REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  12903. /**
  12904. * Use this predicate to dynamically define the list of mesh you want to render.
  12905. * If set, the renderList property will be overwritten.
  12906. */
  12907. renderListPredicate: (AbstractMesh) => boolean;
  12908. /**
  12909. * Use this list to define the list of mesh you want to render.
  12910. */
  12911. renderList: AbstractMesh[];
  12912. renderParticles: boolean;
  12913. renderSprites: boolean;
  12914. coordinatesMode: number;
  12915. activeCamera: Camera;
  12916. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  12917. useCameraPostProcesses: boolean;
  12918. /**
  12919. * An event triggered when the texture is unbind.
  12920. * @type {BABYLON.Observable}
  12921. */
  12922. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  12923. private _onAfterUnbindObserver;
  12924. onAfterUnbind: () => void;
  12925. /**
  12926. * An event triggered before rendering the texture
  12927. * @type {BABYLON.Observable}
  12928. */
  12929. onBeforeRenderObservable: Observable<number>;
  12930. private _onBeforeRenderObserver;
  12931. onBeforeRender: (faceIndex: number) => void;
  12932. /**
  12933. * An event triggered after rendering the texture
  12934. * @type {BABYLON.Observable}
  12935. */
  12936. onAfterRenderObservable: Observable<number>;
  12937. private _onAfterRenderObserver;
  12938. onAfterRender: (faceIndex: number) => void;
  12939. /**
  12940. * An event triggered after the texture clear
  12941. * @type {BABYLON.Observable}
  12942. */
  12943. onClearObservable: Observable<Engine>;
  12944. private _onClearObserver;
  12945. onClear: (Engine: Engine) => void;
  12946. private _size;
  12947. _generateMipMaps: boolean;
  12948. private _renderingManager;
  12949. _waitingRenderList: string[];
  12950. private _doNotChangeAspectRatio;
  12951. private _currentRefreshId;
  12952. private _refreshRate;
  12953. private _textureMatrix;
  12954. constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number);
  12955. resetRefreshCounter(): void;
  12956. refreshRate: number;
  12957. _shouldRender(): boolean;
  12958. isReady(): boolean;
  12959. getRenderSize(): number;
  12960. canRescale: boolean;
  12961. scale(ratio: number): void;
  12962. getReflectionTextureMatrix(): Matrix;
  12963. resize(size: any, generateMipMaps?: boolean): void;
  12964. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  12965. renderToTarget(faceIndex: number, currentRenderList: AbstractMesh[], useCameraPostProcess: boolean, dumpForDebug: boolean): void;
  12966. clone(): RenderTargetTexture;
  12967. serialize(): any;
  12968. }
  12969. }
  12970. declare module BABYLON {
  12971. class Texture extends BaseTexture {
  12972. static NEAREST_SAMPLINGMODE: number;
  12973. static BILINEAR_SAMPLINGMODE: number;
  12974. static TRILINEAR_SAMPLINGMODE: number;
  12975. static EXPLICIT_MODE: number;
  12976. static SPHERICAL_MODE: number;
  12977. static PLANAR_MODE: number;
  12978. static CUBIC_MODE: number;
  12979. static PROJECTION_MODE: number;
  12980. static SKYBOX_MODE: number;
  12981. static INVCUBIC_MODE: number;
  12982. static EQUIRECTANGULAR_MODE: number;
  12983. static FIXED_EQUIRECTANGULAR_MODE: number;
  12984. static CLAMP_ADDRESSMODE: number;
  12985. static WRAP_ADDRESSMODE: number;
  12986. static MIRROR_ADDRESSMODE: number;
  12987. url: string;
  12988. uOffset: number;
  12989. vOffset: number;
  12990. uScale: number;
  12991. vScale: number;
  12992. uAng: number;
  12993. vAng: number;
  12994. wAng: number;
  12995. noMipmap: boolean;
  12996. private _noMipmap;
  12997. _invertY: boolean;
  12998. private _rowGenerationMatrix;
  12999. private _cachedTextureMatrix;
  13000. private _projectionModeMatrix;
  13001. private _t0;
  13002. private _t1;
  13003. private _t2;
  13004. private _cachedUOffset;
  13005. private _cachedVOffset;
  13006. private _cachedUScale;
  13007. private _cachedVScale;
  13008. private _cachedUAng;
  13009. private _cachedVAng;
  13010. private _cachedWAng;
  13011. private _cachedCoordinatesMode;
  13012. _samplingMode: number;
  13013. private _buffer;
  13014. private _deleteBuffer;
  13015. private _delayedOnLoad;
  13016. private _delayedOnError;
  13017. constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean);
  13018. delayLoad(): void;
  13019. updateSamplingMode(samplingMode: number): void;
  13020. private _prepareRowForTextureGeneration(x, y, z, t);
  13021. getTextureMatrix(): Matrix;
  13022. getReflectionTextureMatrix(): Matrix;
  13023. clone(): Texture;
  13024. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void): Texture;
  13025. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture;
  13026. }
  13027. }
  13028. declare module BABYLON {
  13029. class VideoTexture extends Texture {
  13030. video: HTMLVideoElement;
  13031. private _autoLaunch;
  13032. private _lastUpdate;
  13033. private _generateMipMaps;
  13034. /**
  13035. * Creates a video texture.
  13036. * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
  13037. * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
  13038. * @param {BABYLON.Scene} scene is obviously the current scene.
  13039. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  13040. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  13041. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  13042. */
  13043. constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  13044. private _createTexture();
  13045. update(): boolean;
  13046. }
  13047. }
  13048. declare module BABYLON {
  13049. class CannonJSPlugin implements IPhysicsEnginePlugin {
  13050. private _useDeltaForWorldStep;
  13051. world: any;
  13052. name: string;
  13053. private _physicsMaterials;
  13054. private _fixedTimeStep;
  13055. private _currentCollisionGroup;
  13056. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  13057. setGravity(gravity: Vector3): void;
  13058. setTimeStep(timeStep: number): void;
  13059. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13060. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13061. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13062. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13063. private _processChildMeshes(mainImpostor);
  13064. removePhysicsBody(impostor: PhysicsImpostor): void;
  13065. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  13066. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  13067. private _addMaterial(name, friction, restitution);
  13068. private _checkWithEpsilon(value);
  13069. private _createShape(impostor);
  13070. private _createHeightmap(object, pointDepth?);
  13071. private _minus90X;
  13072. private _plus90X;
  13073. private _tmpPosition;
  13074. private _tmpQuaternion;
  13075. private _tmpDeltaPosition;
  13076. private _tmpDeltaRotation;
  13077. private _tmpUnityRotation;
  13078. private _updatePhysicsBodyTransformation(impostor);
  13079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13081. isSupported(): boolean;
  13082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13084. getLinearVelocity(impostor: PhysicsImpostor): Vector3;
  13085. getAngularVelocity(impostor: PhysicsImpostor): Vector3;
  13086. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13087. sleepBody(impostor: PhysicsImpostor): void;
  13088. wakeUpBody(impostor: PhysicsImpostor): void;
  13089. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13090. private enableMotor(joint, motorIndex?);
  13091. private disableMotor(joint, motorIndex?);
  13092. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  13093. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  13094. dispose(): void;
  13095. }
  13096. }
  13097. declare module BABYLON {
  13098. class OimoJSPlugin {
  13099. world: any;
  13100. name: string;
  13101. constructor(iterations?: number);
  13102. setGravity(gravity: Vector3): void;
  13103. setTimeStep(timeStep: number): void;
  13104. private _tmpImpostorsArray;
  13105. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13106. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13107. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13108. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13109. private _tmpPositionVector;
  13110. removePhysicsBody(impostor: PhysicsImpostor): void;
  13111. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  13112. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  13113. isSupported(): boolean;
  13114. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13115. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13116. private _getLastShape(body);
  13117. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13118. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13119. getLinearVelocity(impostor: PhysicsImpostor): Vector3;
  13120. getAngularVelocity(impostor: PhysicsImpostor): Vector3;
  13121. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13122. sleepBody(impostor: PhysicsImpostor): void;
  13123. wakeUpBody(impostor: PhysicsImpostor): void;
  13124. updateDistanceJoint(joint: IMotorEnabledJoint, maxDistance: number, minDistance?: number): void;
  13125. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13126. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13127. dispose(): void;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. class PostProcessRenderEffect {
  13132. private _engine;
  13133. private _postProcesses;
  13134. private _getPostProcess;
  13135. private _singleInstance;
  13136. private _cameras;
  13137. private _indicesForCamera;
  13138. private _renderPasses;
  13139. private _renderEffectAsPasses;
  13140. _name: string;
  13141. applyParameters: (postProcess: PostProcess) => void;
  13142. constructor(engine: Engine, name: string, getPostProcess: () => PostProcess, singleInstance?: boolean);
  13143. isSupported: boolean;
  13144. _update(): void;
  13145. addPass(renderPass: PostProcessRenderPass): void;
  13146. removePass(renderPass: PostProcessRenderPass): void;
  13147. addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void;
  13148. getPass(passName: string): void;
  13149. emptyPasses(): void;
  13150. _attachCameras(cameras: Camera): any;
  13151. _attachCameras(cameras: Camera[]): any;
  13152. _detachCameras(cameras: Camera): any;
  13153. _detachCameras(cameras: Camera[]): any;
  13154. _enable(cameras: Camera): any;
  13155. _enable(cameras: Camera[]): any;
  13156. _disable(cameras: Camera): any;
  13157. _disable(cameras: Camera[]): any;
  13158. getPostProcess(camera?: Camera): PostProcess;
  13159. private _linkParameters();
  13160. private _linkTextures(effect);
  13161. }
  13162. }
  13163. declare module BABYLON {
  13164. class PostProcessRenderPass {
  13165. private _enabled;
  13166. private _renderList;
  13167. private _renderTexture;
  13168. private _scene;
  13169. private _refCount;
  13170. _name: string;
  13171. constructor(scene: Scene, name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void);
  13172. _incRefCount(): number;
  13173. _decRefCount(): number;
  13174. _update(): void;
  13175. setRenderList(renderList: Mesh[]): void;
  13176. getRenderTexture(): RenderTargetTexture;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. class PostProcessRenderPipeline {
  13181. private _engine;
  13182. private _renderEffects;
  13183. private _renderEffectsForIsolatedPass;
  13184. private _cameras;
  13185. _name: string;
  13186. private static PASS_EFFECT_NAME;
  13187. private static PASS_SAMPLER_NAME;
  13188. constructor(engine: Engine, name: string);
  13189. isSupported: boolean;
  13190. addEffect(renderEffect: PostProcessRenderEffect): void;
  13191. _enableEffect(renderEffectName: string, cameras: Camera): any;
  13192. _enableEffect(renderEffectName: string, cameras: Camera[]): any;
  13193. _disableEffect(renderEffectName: string, cameras: Camera): any;
  13194. _disableEffect(renderEffectName: string, cameras: Camera[]): any;
  13195. _attachCameras(cameras: Camera, unique: boolean): any;
  13196. _attachCameras(cameras: Camera[], unique: boolean): any;
  13197. _detachCameras(cameras: Camera): any;
  13198. _detachCameras(cameras: Camera[]): any;
  13199. _enableDisplayOnlyPass(passName: any, cameras: Camera): any;
  13200. _enableDisplayOnlyPass(passName: any, cameras: Camera[]): any;
  13201. _disableDisplayOnlyPass(cameras: Camera): any;
  13202. _disableDisplayOnlyPass(cameras: Camera[]): any;
  13203. _update(): void;
  13204. dispose(): void;
  13205. }
  13206. }
  13207. declare module BABYLON {
  13208. class PostProcessRenderPipelineManager {
  13209. private _renderPipelines;
  13210. constructor();
  13211. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  13212. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): any;
  13213. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): any;
  13214. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): any;
  13215. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): any;
  13216. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  13217. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  13218. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  13219. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  13220. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera): any;
  13221. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera[]): any;
  13222. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera): any;
  13223. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera[]): any;
  13224. update(): void;
  13225. }
  13226. }
  13227. declare module BABYLON.Internals {
  13228. /**
  13229. * Helper class dealing with the extraction of spherical polynomial dataArray
  13230. * from a cube map.
  13231. */
  13232. class CubeMapToSphericalPolynomialTools {
  13233. private static FileFaces;
  13234. /**
  13235. * Converts a cubemap to the according Spherical Polynomial data.
  13236. * This extracts the first 3 orders only as they are the only one used in the lighting.
  13237. *
  13238. * @param cubeInfo The Cube map to extract the information from.
  13239. * @return The Spherical Polynomial data.
  13240. */
  13241. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  13242. }
  13243. }
  13244. declare module BABYLON.Internals {
  13245. /**
  13246. * Header information of HDR texture files.
  13247. */
  13248. interface HDRInfo {
  13249. /**
  13250. * The height of the texture in pixels.
  13251. */
  13252. height: number;
  13253. /**
  13254. * The width of the texture in pixels.
  13255. */
  13256. width: number;
  13257. /**
  13258. * The index of the beginning of the data in the binary file.
  13259. */
  13260. dataPosition: number;
  13261. }
  13262. /**
  13263. * This groups tools to convert HDR texture to native colors array.
  13264. */
  13265. class HDRTools {
  13266. private static Ldexp(mantissa, exponent);
  13267. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  13268. private static readStringLine(uint8array, startIndex);
  13269. /**
  13270. * Reads header information from an RGBE texture stored in a native array.
  13271. * More information on this format are available here:
  13272. * https://en.wikipedia.org/wiki/RGBE_image_format
  13273. *
  13274. * @param uint8array The binary file stored in native array.
  13275. * @return The header information.
  13276. */
  13277. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  13278. /**
  13279. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  13280. * This RGBE texture needs to store the information as a panorama.
  13281. *
  13282. * More information on this format are available here:
  13283. * https://en.wikipedia.org/wiki/RGBE_image_format
  13284. *
  13285. * @param buffer The binary file stored in an array buffer.
  13286. * @param size The expected size of the extracted cubemap.
  13287. * @return The Cube Map information.
  13288. */
  13289. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  13290. /**
  13291. * Returns the pixels data extracted from an RGBE texture.
  13292. * This pixels will be stored left to right up to down in the R G B order in one array.
  13293. *
  13294. * More information on this format are available here:
  13295. * https://en.wikipedia.org/wiki/RGBE_image_format
  13296. *
  13297. * @param uint8array The binary file stored in an array buffer.
  13298. * @param hdrInfo The header information of the file.
  13299. * @return The pixels data in RGB right to left up to down order.
  13300. */
  13301. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  13302. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  13303. }
  13304. }
  13305. declare module BABYLON.Internals {
  13306. /**
  13307. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  13308. */
  13309. interface CubeMapInfo {
  13310. /**
  13311. * The pixel array for the front face.
  13312. * This is stored in RGB, left to right, up to down format.
  13313. */
  13314. front: Float32Array;
  13315. /**
  13316. * The pixel array for the back face.
  13317. * This is stored in RGB, left to right, up to down format.
  13318. */
  13319. back: Float32Array;
  13320. /**
  13321. * The pixel array for the left face.
  13322. * This is stored in RGB, left to right, up to down format.
  13323. */
  13324. left: Float32Array;
  13325. /**
  13326. * The pixel array for the right face.
  13327. * This is stored in RGB, left to right, up to down format.
  13328. */
  13329. right: Float32Array;
  13330. /**
  13331. * The pixel array for the up face.
  13332. * This is stored in RGB, left to right, up to down format.
  13333. */
  13334. up: Float32Array;
  13335. /**
  13336. * The pixel array for the down face.
  13337. * This is stored in RGB, left to right, up to down format.
  13338. */
  13339. down: Float32Array;
  13340. /**
  13341. * The size of the cubemap stored.
  13342. *
  13343. * Each faces will be size * size pixels.
  13344. */
  13345. size: number;
  13346. }
  13347. /**
  13348. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  13349. */
  13350. class PanoramaToCubeMapTools {
  13351. private static FACE_FRONT;
  13352. private static FACE_BACK;
  13353. private static FACE_RIGHT;
  13354. private static FACE_LEFT;
  13355. private static FACE_DOWN;
  13356. private static FACE_UP;
  13357. /**
  13358. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  13359. *
  13360. * @param float32Array The source data.
  13361. * @param inputWidth The width of the input panorama.
  13362. * @param inputhHeight The height of the input panorama.
  13363. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  13364. * @return The cubemap data
  13365. */
  13366. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  13367. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  13368. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  13369. }
  13370. }
  13371. declare namespace BABYLON.Internals {
  13372. /**
  13373. * Helper class to PreProcess a cubemap in order to generate mipmap according to the level of blur
  13374. * required by the glossinees of a material.
  13375. *
  13376. * This only supports the cosine drop power as well as Warp fixup generation method.
  13377. *
  13378. * This is using the process from CubeMapGen described here:
  13379. * https://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/
  13380. */
  13381. class PMREMGenerator {
  13382. input: ArrayBufferView[];
  13383. inputSize: number;
  13384. outputSize: number;
  13385. maxNumMipLevels: number;
  13386. numChannels: number;
  13387. isFloat: boolean;
  13388. specularPower: number;
  13389. cosinePowerDropPerMip: number;
  13390. excludeBase: boolean;
  13391. fixup: boolean;
  13392. private static CP_MAX_MIPLEVELS;
  13393. private static CP_UDIR;
  13394. private static CP_VDIR;
  13395. private static CP_FACEAXIS;
  13396. private static CP_FACE_X_POS;
  13397. private static CP_FACE_X_NEG;
  13398. private static CP_FACE_Y_POS;
  13399. private static CP_FACE_Y_NEG;
  13400. private static CP_FACE_Z_POS;
  13401. private static CP_FACE_Z_NEG;
  13402. private static CP_EDGE_LEFT;
  13403. private static CP_EDGE_RIGHT;
  13404. private static CP_EDGE_TOP;
  13405. private static CP_EDGE_BOTTOM;
  13406. private static CP_CORNER_NNN;
  13407. private static CP_CORNER_NNP;
  13408. private static CP_CORNER_NPN;
  13409. private static CP_CORNER_NPP;
  13410. private static CP_CORNER_PNN;
  13411. private static CP_CORNER_PNP;
  13412. private static CP_CORNER_PPN;
  13413. private static CP_CORNER_PPP;
  13414. private static _vectorTemp;
  13415. private static _sgFace2DMapping;
  13416. private static _sgCubeNgh;
  13417. private static _sgCubeEdgeList;
  13418. private static _sgCubeCornerList;
  13419. private _outputSurface;
  13420. private _normCubeMap;
  13421. private _filterLUT;
  13422. private _numMipLevels;
  13423. /**
  13424. * Constructor of the generator.
  13425. *
  13426. * @param input The different faces data from the original cubemap in the order X+ X- Y+ Y- Z+ Z-
  13427. * @param inputSize The size of the cubemap faces
  13428. * @param outputSize The size of the output cubemap faces
  13429. * @param maxNumMipLevels The max number of mip map to generate (0 means all)
  13430. * @param numChannels The number of channels stored in the cubemap (3 for RBGE for instance)
  13431. * @param isFloat Specifies if the input texture is in float or int (hdr is usually in float)
  13432. * @param specularPower The max specular level of the desired cubemap
  13433. * @param cosinePowerDropPerMip The amount of drop the specular power will follow on each mip
  13434. * @param excludeBase Specifies wether to process the level 0 (original level) or not
  13435. * @param fixup Specifies wether to apply the edge fixup algorythm or not
  13436. */
  13437. constructor(input: ArrayBufferView[], inputSize: number, outputSize: number, maxNumMipLevels: number, numChannels: number, isFloat: boolean, specularPower: number, cosinePowerDropPerMip: number, excludeBase: boolean, fixup: boolean);
  13438. /**
  13439. * Launches the filter process and return the result.
  13440. *
  13441. * @return the filter cubemap in the form mip0 [faces1..6] .. mipN [faces1..6]
  13442. */
  13443. filterCubeMap(): ArrayBufferView[][];
  13444. private init();
  13445. private filterCubeMapMipChain();
  13446. private getBaseFilterAngle(cosinePower);
  13447. private precomputeFilterLookupTables(srcCubeMapWidth);
  13448. private buildNormalizerSolidAngleCubemap(size);
  13449. private texelCoordToVect(faceIdx, u, v, size, fixup);
  13450. private vectToTexelCoord(x, y, z, size);
  13451. private areaElement(x, y);
  13452. private texelCoordSolidAngle(faceIdx, u, v, size);
  13453. private filterCubeSurfaces(srcCubeMap, srcSize, dstCubeMap, dstSize, filterConeAngle, specularPower);
  13454. private clearFilterExtents(filterExtents);
  13455. private determineFilterExtents(centerTapDir, srcSize, bboxSize, filterExtents);
  13456. private processFilterExtents(centerTapDir, dotProdThresh, filterExtents, srcCubeMap, srcSize, specularPower);
  13457. private fixupCubeEdges(cubeMap, cubeMapSize);
  13458. }
  13459. }
  13460. declare module BABYLON {
  13461. class CustomProceduralTexture extends ProceduralTexture {
  13462. private _animate;
  13463. private _time;
  13464. private _config;
  13465. private _texturePath;
  13466. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  13467. private loadJson(jsonUrl);
  13468. isReady(): boolean;
  13469. render(useCameraPostProcess?: boolean): void;
  13470. updateTextures(): void;
  13471. updateShaderUniforms(): void;
  13472. animate: boolean;
  13473. }
  13474. }
  13475. declare module BABYLON {
  13476. class ProceduralTexture extends Texture {
  13477. isCube: boolean;
  13478. private _size;
  13479. _generateMipMaps: boolean;
  13480. isEnabled: boolean;
  13481. private _doNotChangeAspectRatio;
  13482. private _currentRefreshId;
  13483. private _refreshRate;
  13484. onGenerated: () => void;
  13485. private _vertexBuffers;
  13486. private _indexBuffer;
  13487. private _effect;
  13488. private _uniforms;
  13489. private _samplers;
  13490. private _fragment;
  13491. _textures: Texture[];
  13492. private _floats;
  13493. private _floatsArrays;
  13494. private _colors3;
  13495. private _colors4;
  13496. private _vectors2;
  13497. private _vectors3;
  13498. private _matrices;
  13499. private _fallbackTexture;
  13500. private _fallbackTextureUsed;
  13501. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean, isCube?: boolean);
  13502. reset(): void;
  13503. isReady(): boolean;
  13504. resetRefreshCounter(): void;
  13505. setFragment(fragment: any): void;
  13506. refreshRate: number;
  13507. _shouldRender(): boolean;
  13508. getRenderSize(): number;
  13509. resize(size: any, generateMipMaps: any): void;
  13510. private _checkUniform(uniformName);
  13511. setTexture(name: string, texture: Texture): ProceduralTexture;
  13512. setFloat(name: string, value: number): ProceduralTexture;
  13513. setFloats(name: string, value: number[]): ProceduralTexture;
  13514. setColor3(name: string, value: Color3): ProceduralTexture;
  13515. setColor4(name: string, value: Color4): ProceduralTexture;
  13516. setVector2(name: string, value: Vector2): ProceduralTexture;
  13517. setVector3(name: string, value: Vector3): ProceduralTexture;
  13518. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13519. render(useCameraPostProcess?: boolean): void;
  13520. clone(): ProceduralTexture;
  13521. dispose(): void;
  13522. }
  13523. }