babylon.2.1.d.ts 241 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834
  1. declare module BABYLON {
  2. class _DepthCullingState {
  3. private _isDepthTestDirty;
  4. private _isDepthMaskDirty;
  5. private _isDepthFuncDirty;
  6. private _isCullFaceDirty;
  7. private _isCullDirty;
  8. private _isZOffsetDirty;
  9. private _depthTest;
  10. private _depthMask;
  11. private _depthFunc;
  12. private _cull;
  13. private _cullFace;
  14. private _zOffset;
  15. isDirty: boolean;
  16. zOffset: number;
  17. cullFace: number;
  18. cull: boolean;
  19. depthFunc: number;
  20. depthMask: boolean;
  21. depthTest: boolean;
  22. reset(): void;
  23. apply(gl: WebGLRenderingContext): void;
  24. }
  25. class _AlphaState {
  26. private _isAlphaBlendDirty;
  27. private _isBlendFunctionParametersDirty;
  28. private _alphaBlend;
  29. private _blendFunctionParameters;
  30. isDirty: boolean;
  31. alphaBlend: boolean;
  32. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33. reset(): void;
  34. apply(gl: WebGLRenderingContext): void;
  35. }
  36. class EngineCapabilities {
  37. maxTexturesImageUnits: number;
  38. maxTextureSize: number;
  39. maxCubemapTextureSize: number;
  40. maxRenderTextureSize: number;
  41. standardDerivatives: boolean;
  42. s3tc: any;
  43. textureFloat: boolean;
  44. textureAnisotropicFilterExtension: any;
  45. maxAnisotropy: number;
  46. instancedArrays: any;
  47. uintIndices: boolean;
  48. highPrecisionShaderSupported: boolean;
  49. }
  50. /**
  51. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  52. */
  53. class Engine {
  54. private static _ALPHA_DISABLE;
  55. private static _ALPHA_ADD;
  56. private static _ALPHA_COMBINE;
  57. private static _DELAYLOADSTATE_NONE;
  58. private static _DELAYLOADSTATE_LOADED;
  59. private static _DELAYLOADSTATE_LOADING;
  60. private static _DELAYLOADSTATE_NOTLOADED;
  61. private static _TEXTUREFORMAT_ALPHA;
  62. private static _TEXTUREFORMAT_LUMINANCE;
  63. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  64. private static _TEXTUREFORMAT_RGB;
  65. private static _TEXTUREFORMAT_RGBA;
  66. private static _TEXTURETYPE_UNSIGNED_INT;
  67. private static _TEXTURETYPE_FLOAT;
  68. static ALPHA_DISABLE: number;
  69. static ALPHA_ADD: number;
  70. static ALPHA_COMBINE: number;
  71. static DELAYLOADSTATE_NONE: number;
  72. static DELAYLOADSTATE_LOADED: number;
  73. static DELAYLOADSTATE_LOADING: number;
  74. static DELAYLOADSTATE_NOTLOADED: number;
  75. static TEXTUREFORMAT_ALPHA: number;
  76. static TEXTUREFORMAT_LUMINANCE: number;
  77. static TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78. static TEXTUREFORMAT_RGB: number;
  79. static TEXTUREFORMAT_RGBA: number;
  80. static TEXTURETYPE_UNSIGNED_INT: number;
  81. static TEXTURETYPE_FLOAT: number;
  82. static Version: string;
  83. static Epsilon: number;
  84. static CollisionsEpsilon: number;
  85. static CodeRepository: string;
  86. static ShadersRepository: string;
  87. isFullscreen: boolean;
  88. isPointerLock: boolean;
  89. cullBackFaces: boolean;
  90. renderEvenInBackground: boolean;
  91. scenes: Scene[];
  92. _gl: WebGLRenderingContext;
  93. private _renderingCanvas;
  94. private _windowIsBackground;
  95. static audioEngine: AudioEngine;
  96. private _onBlur;
  97. private _onFocus;
  98. private _onFullscreenChange;
  99. private _onPointerLockChange;
  100. private _hardwareScalingLevel;
  101. private _caps;
  102. private _pointerLockRequested;
  103. private _alphaTest;
  104. private _resizeLoadingUI;
  105. private _loadingDiv;
  106. private _loadingTextDiv;
  107. private _loadingDivBackgroundColor;
  108. private _drawCalls;
  109. private _glVersion;
  110. private _glRenderer;
  111. private _glVendor;
  112. private _videoTextureSupported;
  113. private _renderingQueueLaunched;
  114. private _activeRenderLoops;
  115. private fpsRange;
  116. private previousFramesDuration;
  117. private fps;
  118. private deltaTime;
  119. private _depthCullingState;
  120. private _alphaState;
  121. private _alphaMode;
  122. private _loadedTexturesCache;
  123. _activeTexturesCache: BaseTexture[];
  124. private _currentEffect;
  125. private _compiledEffects;
  126. private _vertexAttribArrays;
  127. private _cachedViewport;
  128. private _cachedVertexBuffers;
  129. private _cachedIndexBuffer;
  130. private _cachedEffectForVertexBuffers;
  131. private _currentRenderTarget;
  132. private _uintIndicesCurrentlySet;
  133. private _workingCanvas;
  134. private _workingContext;
  135. /**
  136. * @constructor
  137. * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
  138. * @param {boolean} [antialias] - enable antialias
  139. * @param options - further options to be sent to the getContext function
  140. */
  141. constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: any);
  142. private _prepareWorkingCanvas();
  143. getGlInfo(): {
  144. vendor: string;
  145. renderer: string;
  146. version: string;
  147. };
  148. getAspectRatio(camera: Camera): number;
  149. getRenderWidth(): number;
  150. getRenderHeight(): number;
  151. getRenderingCanvas(): HTMLCanvasElement;
  152. getRenderingCanvasClientRect(): ClientRect;
  153. setHardwareScalingLevel(level: number): void;
  154. getHardwareScalingLevel(): number;
  155. getLoadedTexturesCache(): WebGLTexture[];
  156. getCaps(): EngineCapabilities;
  157. drawCalls: number;
  158. resetDrawCalls(): void;
  159. setDepthFunctionToGreater(): void;
  160. setDepthFunctionToGreaterOrEqual(): void;
  161. setDepthFunctionToLess(): void;
  162. setDepthFunctionToLessOrEqual(): void;
  163. /**
  164. * stop executing a render loop function and remove it from the execution array
  165. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  166. */
  167. stopRenderLoop(renderFunction?: () => void): void;
  168. _renderLoop(): void;
  169. /**
  170. * Register and execute a render loop. The engine can have more than one render function.
  171. * @param {Function} renderFunction - the function to continuesly execute starting the next render loop.
  172. * @example
  173. * engine.runRenderLoop(function () {
  174. * scene.render()
  175. * })
  176. */
  177. runRenderLoop(renderFunction: () => void): void;
  178. /**
  179. * Toggle full screen mode.
  180. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  181. */
  182. switchFullscreen(requestPointerLock: boolean): void;
  183. clear(color: any, backBuffer: boolean, depthStencil: boolean): void;
  184. /**
  185. * Set the WebGL's viewport
  186. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  187. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  188. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  189. */
  190. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  191. setDirectViewport(x: number, y: number, width: number, height: number): void;
  192. beginFrame(): void;
  193. endFrame(): void;
  194. /**
  195. * resize the view according to the canvas' size.
  196. * @example
  197. * window.addEventListener("resize", function () {
  198. * engine.resize();
  199. * });
  200. */
  201. resize(): void;
  202. /**
  203. * force a specific size of the canvas
  204. * @param {number} width - the new canvas' width
  205. * @param {number} height - the new canvas' height
  206. */
  207. setSize(width: number, height: number): void;
  208. bindFramebuffer(texture: WebGLTexture): void;
  209. unBindFramebuffer(texture: WebGLTexture): void;
  210. flushFramebuffer(): void;
  211. restoreDefaultFramebuffer(): void;
  212. private _resetVertexBufferBinding();
  213. createVertexBuffer(vertices: number[]): WebGLBuffer;
  214. createDynamicVertexBuffer(capacity: number): WebGLBuffer;
  215. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: any, offset?: number): void;
  216. private _resetIndexBufferBinding();
  217. createIndexBuffer(indices: number[]): WebGLBuffer;
  218. bindBuffers(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  219. bindMultiBuffers(vertexBuffers: VertexBuffer[], indexBuffer: WebGLBuffer, effect: Effect): void;
  220. _releaseBuffer(buffer: WebGLBuffer): boolean;
  221. createInstancesBuffer(capacity: number): WebGLBuffer;
  222. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  223. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[]): void;
  224. unBindInstancesBuffer(instancesBuffer: WebGLBuffer, offsetLocations: number[]): void;
  225. applyStates(): void;
  226. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  227. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  228. _releaseEffect(effect: Effect): void;
  229. createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  230. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  231. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
  232. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  233. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  234. enableEffect(effect: Effect): void;
  235. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  236. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  237. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  238. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  239. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  240. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  241. setFloat(uniform: WebGLUniformLocation, value: number): void;
  242. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  243. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  244. setBool(uniform: WebGLUniformLocation, bool: number): void;
  245. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  246. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  247. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  248. setState(culling: boolean, zOffset?: number, force?: boolean): void;
  249. setDepthBuffer(enable: boolean): void;
  250. getDepthWrite(): boolean;
  251. setDepthWrite(enable: boolean): void;
  252. setColorWrite(enable: boolean): void;
  253. setAlphaMode(mode: number): void;
  254. getAlphaMode(): number;
  255. setAlphaTesting(enable: boolean): void;
  256. getAlphaTesting(): boolean;
  257. wipeCaches(): void;
  258. setSamplingMode(texture: WebGLTexture, samplingMode: number): void;
  259. createTexture(url: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any): WebGLTexture;
  260. createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number): WebGLTexture;
  261. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number, forceExponantOfTwo?: boolean): WebGLTexture;
  262. updateTextureSamplingMode(samplingMode: number, texture: WebGLTexture): void;
  263. updateDynamicTexture(texture: WebGLTexture, canvas: HTMLCanvasElement, invertY: boolean): void;
  264. updateVideoTexture(texture: WebGLTexture, video: HTMLVideoElement, invertY: boolean): void;
  265. createRenderTargetTexture(size: any, options: any): WebGLTexture;
  266. createCubeTexture(rootUrl: string, scene: Scene, extensions: string[], noMipmap?: boolean): WebGLTexture;
  267. _releaseTexture(texture: WebGLTexture): void;
  268. bindSamplers(effect: Effect): void;
  269. _bindTexture(channel: number, texture: WebGLTexture): void;
  270. setTextureFromPostProcess(channel: number, postProcess: PostProcess): void;
  271. setTexture(channel: number, texture: BaseTexture): void;
  272. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  273. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  274. dispose(): void;
  275. displayLoadingUI(): void;
  276. loadingUIText: string;
  277. loadingUIBackgroundColor: string;
  278. hideLoadingUI(): void;
  279. getFps(): number;
  280. getDeltaTime(): number;
  281. private _measureFps();
  282. static isSupported(): boolean;
  283. }
  284. }
  285. interface Window {
  286. mozIndexedDB(func: any): any;
  287. webkitIndexedDB(func: any): any;
  288. IDBTransaction(func: any): any;
  289. webkitIDBTransaction(func: any): any;
  290. msIDBTransaction(func: any): any;
  291. IDBKeyRange(func: any): any;
  292. webkitIDBKeyRange(func: any): any;
  293. msIDBKeyRange(func: any): any;
  294. URL: HTMLURL;
  295. webkitURL: HTMLURL;
  296. webkitRequestAnimationFrame(func: any): any;
  297. mozRequestAnimationFrame(func: any): any;
  298. oRequestAnimationFrame(func: any): any;
  299. WebGLRenderingContext: WebGLRenderingContext;
  300. MSGesture: MSGesture;
  301. CANNON: any;
  302. SIMD: any;
  303. AudioContext: AudioContext;
  304. webkitAudioContext: AudioContext;
  305. }
  306. interface HTMLURL {
  307. createObjectURL(param1: any, param2?: any): any;
  308. }
  309. interface Document {
  310. exitFullscreen(): void;
  311. webkitCancelFullScreen(): void;
  312. mozCancelFullScreen(): void;
  313. msCancelFullScreen(): void;
  314. webkitIsFullScreen: boolean;
  315. mozFullScreen: boolean;
  316. msIsFullScreen: boolean;
  317. fullscreen: boolean;
  318. mozPointerLockElement: HTMLElement;
  319. msPointerLockElement: HTMLElement;
  320. webkitPointerLockElement: HTMLElement;
  321. pointerLockElement: HTMLElement;
  322. }
  323. interface HTMLCanvasElement {
  324. requestPointerLock(): void;
  325. msRequestPointerLock(): void;
  326. mozRequestPointerLock(): void;
  327. webkitRequestPointerLock(): void;
  328. }
  329. interface CanvasRenderingContext2D {
  330. imageSmoothingEnabled: boolean;
  331. mozImageSmoothingEnabled: boolean;
  332. oImageSmoothingEnabled: boolean;
  333. webkitImageSmoothingEnabled: boolean;
  334. }
  335. interface WebGLTexture {
  336. isReady: boolean;
  337. isCube: boolean;
  338. url: string;
  339. noMipmap: boolean;
  340. samplingMode: number;
  341. references: number;
  342. generateMipMaps: boolean;
  343. _size: number;
  344. _baseWidth: number;
  345. _baseHeight: number;
  346. _width: number;
  347. _height: number;
  348. _workingCanvas: HTMLCanvasElement;
  349. _workingContext: CanvasRenderingContext2D;
  350. _framebuffer: WebGLFramebuffer;
  351. _depthBuffer: WebGLRenderbuffer;
  352. _cachedCoordinatesMode: number;
  353. _cachedWrapU: number;
  354. _cachedWrapV: number;
  355. }
  356. interface WebGLBuffer {
  357. references: number;
  358. capacity: number;
  359. is32Bits: boolean;
  360. }
  361. interface MouseEvent {
  362. movementX: number;
  363. movementY: number;
  364. mozMovementX: number;
  365. mozMovementY: number;
  366. webkitMovementX: number;
  367. webkitMovementY: number;
  368. msMovementX: number;
  369. msMovementY: number;
  370. }
  371. interface MSStyleCSSProperties {
  372. webkitTransform: string;
  373. webkitTransition: string;
  374. }
  375. interface Navigator {
  376. getVRDevices: () => any;
  377. mozGetVRDevices: (any: any) => any;
  378. isCocoonJS: boolean;
  379. }
  380. interface Screen {
  381. orientation: string;
  382. mozOrientation: string;
  383. }
  384. declare module BABYLON {
  385. /**
  386. * Node is the basic class for all scene objects (Mesh, Light Camera).
  387. */
  388. class Node {
  389. parent: Node;
  390. name: string;
  391. id: string;
  392. uniqueId: number;
  393. state: string;
  394. animations: Animation[];
  395. onReady: (node: Node) => void;
  396. private _childrenFlag;
  397. private _isEnabled;
  398. private _isReady;
  399. _currentRenderId: number;
  400. private _parentRenderId;
  401. _waitingParentId: string;
  402. private _scene;
  403. _cache: any;
  404. /**
  405. * @constructor
  406. * @param {string} name - the name and id to be given to this node
  407. * @param {BABYLON.Scene} the scene this node will be added to
  408. */
  409. constructor(name: string, scene: Scene);
  410. getScene(): Scene;
  411. getEngine(): Engine;
  412. getWorldMatrix(): Matrix;
  413. _initCache(): void;
  414. updateCache(force?: boolean): void;
  415. _updateCache(ignoreParentClass?: boolean): void;
  416. _isSynchronized(): boolean;
  417. _markSyncedWithParent(): void;
  418. isSynchronizedWithParent(): boolean;
  419. isSynchronized(updateCache?: boolean): boolean;
  420. hasNewParent(update?: boolean): boolean;
  421. /**
  422. * Is this node ready to be used/rendered
  423. * @return {boolean} is it ready
  424. */
  425. isReady(): boolean;
  426. /**
  427. * Is this node enabled.
  428. * If the node has a parent and is enabled, the parent will be inspected as well.
  429. * @return {boolean} whether this node (and its parent) is enabled.
  430. * @see setEnabled
  431. */
  432. isEnabled(): boolean;
  433. /**
  434. * Set the enabled state of this node.
  435. * @param {boolean} value - the new enabled state
  436. * @see isEnabled
  437. */
  438. setEnabled(value: boolean): void;
  439. /**
  440. * Is this node a descendant of the given node.
  441. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
  442. * @param {BABYLON.Node} ancestor - The parent node to inspect
  443. * @see parent
  444. */
  445. isDescendantOf(ancestor: Node): boolean;
  446. _getDescendants(list: Node[], results: Node[]): void;
  447. /**
  448. * Will return all nodes that have this node as parent.
  449. * @return {BABYLON.Node[]} all children nodes of all types.
  450. */
  451. getDescendants(): Node[];
  452. _setReady(state: boolean): void;
  453. }
  454. }
  455. declare module BABYLON {
  456. interface IDisposable {
  457. dispose(): void;
  458. }
  459. /**
  460. * Represents a scene to be rendered by the engine.
  461. * @see http://doc.babylonjs.com/page.php?p=21911
  462. */
  463. class Scene {
  464. private static _FOGMODE_NONE;
  465. private static _FOGMODE_EXP;
  466. private static _FOGMODE_EXP2;
  467. private static _FOGMODE_LINEAR;
  468. static MinDeltaTime: number;
  469. static MaxDeltaTime: number;
  470. static FOGMODE_NONE: number;
  471. static FOGMODE_EXP: number;
  472. static FOGMODE_EXP2: number;
  473. static FOGMODE_LINEAR: number;
  474. autoClear: boolean;
  475. clearColor: any;
  476. ambientColor: Color3;
  477. /**
  478. * A function to be executed before rendering this scene
  479. * @type {Function}
  480. */
  481. beforeRender: () => void;
  482. /**
  483. * A function to be executed after rendering this scene
  484. * @type {Function}
  485. */
  486. afterRender: () => void;
  487. /**
  488. * A function to be executed when this scene is disposed.
  489. * @type {Function}
  490. */
  491. onDispose: () => void;
  492. beforeCameraRender: (camera: Camera) => void;
  493. afterCameraRender: (camera: Camera) => void;
  494. forceWireframe: boolean;
  495. forcePointsCloud: boolean;
  496. forceShowBoundingBoxes: boolean;
  497. clipPlane: Plane;
  498. animationsEnabled: boolean;
  499. private _onPointerMove;
  500. private _onPointerDown;
  501. private _onPointerUp;
  502. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  503. onPointerUp: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  504. cameraToUseForPointers: Camera;
  505. private _pointerX;
  506. private _pointerY;
  507. private _meshUnderPointer;
  508. private _onKeyDown;
  509. private _onKeyUp;
  510. /**
  511. * is fog enabled on this scene.
  512. * @type {boolean}
  513. */
  514. fogEnabled: boolean;
  515. fogMode: number;
  516. fogColor: Color3;
  517. fogDensity: number;
  518. fogStart: number;
  519. fogEnd: number;
  520. /**
  521. * is shadow enabled on this scene.
  522. * @type {boolean}
  523. */
  524. shadowsEnabled: boolean;
  525. /**
  526. * is light enabled on this scene.
  527. * @type {boolean}
  528. */
  529. lightsEnabled: boolean;
  530. /**
  531. * All of the lights added to this scene.
  532. * @see BABYLON.Light
  533. * @type {BABYLON.Light[]}
  534. */
  535. lights: Light[];
  536. onNewLightAdded: (newLight?: Light, positionInArray?: number, scene?: Scene) => void;
  537. onLightRemoved: (removedLight?: Light) => void;
  538. /**
  539. * All of the cameras added to this scene.
  540. * @see BABYLON.Camera
  541. * @type {BABYLON.Camera[]}
  542. */
  543. cameras: Camera[];
  544. onNewCameraAdded: (newCamera?: Camera, positionInArray?: number, scene?: Scene) => void;
  545. onCameraRemoved: (removedCamera?: Camera) => void;
  546. activeCameras: Camera[];
  547. activeCamera: Camera;
  548. /**
  549. * All of the (abstract) meshes added to this scene.
  550. * @see BABYLON.AbstractMesh
  551. * @type {BABYLON.AbstractMesh[]}
  552. */
  553. meshes: AbstractMesh[];
  554. onNewMeshAdded: (newMesh?: AbstractMesh, positionInArray?: number, scene?: Scene) => void;
  555. onMeshRemoved: (removedMesh?: AbstractMesh) => void;
  556. private _geometries;
  557. onGeometryAdded: (newGeometry?: Geometry) => void;
  558. onGeometryRemoved: (removedGeometry?: Geometry) => void;
  559. materials: Material[];
  560. multiMaterials: MultiMaterial[];
  561. defaultMaterial: StandardMaterial;
  562. texturesEnabled: boolean;
  563. textures: BaseTexture[];
  564. particlesEnabled: boolean;
  565. particleSystems: ParticleSystem[];
  566. spritesEnabled: boolean;
  567. spriteManagers: SpriteManager[];
  568. layers: Layer[];
  569. skeletonsEnabled: boolean;
  570. skeletons: Skeleton[];
  571. lensFlaresEnabled: boolean;
  572. lensFlareSystems: LensFlareSystem[];
  573. collisionsEnabled: boolean;
  574. private _workerCollisions;
  575. collisionCoordinator: ICollisionCoordinator;
  576. gravity: Vector3;
  577. postProcessesEnabled: boolean;
  578. postProcessManager: PostProcessManager;
  579. postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  580. renderTargetsEnabled: boolean;
  581. dumpNextRenderTargets: boolean;
  582. customRenderTargets: RenderTargetTexture[];
  583. useDelayedTextureLoading: boolean;
  584. importedMeshesFiles: String[];
  585. database: any;
  586. /**
  587. * This scene's action manager
  588. * @type {BABYLON.ActionManager}
  589. */
  590. actionManager: ActionManager;
  591. _actionManagers: ActionManager[];
  592. private _meshesForIntersections;
  593. proceduralTexturesEnabled: boolean;
  594. _proceduralTextures: ProceduralTexture[];
  595. mainSoundTrack: SoundTrack;
  596. soundTracks: SoundTrack[];
  597. private _audioEnabled;
  598. private _headphone;
  599. simplificationQueue: SimplificationQueue;
  600. private _engine;
  601. private _totalVertices;
  602. _activeIndices: number;
  603. _activeParticles: number;
  604. private _lastFrameDuration;
  605. private _evaluateActiveMeshesDuration;
  606. private _renderTargetsDuration;
  607. _particlesDuration: number;
  608. private _renderDuration;
  609. _spritesDuration: number;
  610. private _animationRatio;
  611. private _animationStartDate;
  612. _cachedMaterial: Material;
  613. private _renderId;
  614. private _executeWhenReadyTimeoutId;
  615. _toBeDisposed: SmartArray<IDisposable>;
  616. private _onReadyCallbacks;
  617. private _pendingData;
  618. private _onBeforeRenderCallbacks;
  619. private _onAfterRenderCallbacks;
  620. private _activeMeshes;
  621. private _processedMaterials;
  622. private _renderTargets;
  623. _activeParticleSystems: SmartArray<ParticleSystem>;
  624. private _activeSkeletons;
  625. _activeBones: number;
  626. private _renderingManager;
  627. private _physicsEngine;
  628. _activeAnimatables: Animatable[];
  629. private _transformMatrix;
  630. private _pickWithRayInverseMatrix;
  631. private _boundingBoxRenderer;
  632. private _outlineRenderer;
  633. private _viewMatrix;
  634. private _projectionMatrix;
  635. private _frustumPlanes;
  636. private _selectionOctree;
  637. private _pointerOverMesh;
  638. private _debugLayer;
  639. private _depthRenderer;
  640. private _uniqueIdCounter;
  641. /**
  642. * @constructor
  643. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  644. */
  645. constructor(engine: Engine);
  646. debugLayer: DebugLayer;
  647. workerCollisions: boolean;
  648. /**
  649. * The mesh that is currently under the pointer.
  650. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  651. */
  652. meshUnderPointer: AbstractMesh;
  653. /**
  654. * Current on-screen X position of the pointer
  655. * @return {number} X position of the pointer
  656. */
  657. pointerX: number;
  658. /**
  659. * Current on-screen Y position of the pointer
  660. * @return {number} Y position of the pointer
  661. */
  662. pointerY: number;
  663. getCachedMaterial(): Material;
  664. getBoundingBoxRenderer(): BoundingBoxRenderer;
  665. getOutlineRenderer(): OutlineRenderer;
  666. getEngine(): Engine;
  667. getTotalVertices(): number;
  668. getActiveIndices(): number;
  669. getActiveParticles(): number;
  670. getActiveBones(): number;
  671. getLastFrameDuration(): number;
  672. getEvaluateActiveMeshesDuration(): number;
  673. getActiveMeshes(): SmartArray<Mesh>;
  674. getRenderTargetsDuration(): number;
  675. getRenderDuration(): number;
  676. getParticlesDuration(): number;
  677. getSpritesDuration(): number;
  678. getAnimationRatio(): number;
  679. getRenderId(): number;
  680. incrementRenderId(): void;
  681. private _updatePointerPosition(evt);
  682. attachControl(): void;
  683. detachControl(): void;
  684. isReady(): boolean;
  685. resetCachedMaterial(): void;
  686. registerBeforeRender(func: () => void): void;
  687. unregisterBeforeRender(func: () => void): void;
  688. registerAfterRender(func: () => void): void;
  689. unregisterAfterRender(func: () => void): void;
  690. _addPendingData(data: any): void;
  691. _removePendingData(data: any): void;
  692. getWaitingItemsCount(): number;
  693. /**
  694. * Registers a function to be executed when the scene is ready.
  695. * @param {Function} func - the function to be executed.
  696. */
  697. executeWhenReady(func: () => void): void;
  698. _checkIsReady(): void;
  699. /**
  700. * Will start the animation sequence of a given target
  701. * @param target - the target
  702. * @param {number} from - from which frame should animation start
  703. * @param {number} to - till which frame should animation run.
  704. * @param {boolean} [loop] - should the animation loop
  705. * @param {number} [speedRatio] - the speed in which to run the animation
  706. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  707. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  708. * @return {BABYLON.Animatable} the animatable object created for this animation
  709. * @see BABYLON.Animatable
  710. * @see http://doc.babylonjs.com/page.php?p=22081
  711. */
  712. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  713. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  714. getAnimatableByTarget(target: any): Animatable;
  715. /**
  716. * Will stop the animation of the given target
  717. * @param target - the target
  718. * @see beginAnimation
  719. */
  720. stopAnimation(target: any): void;
  721. private _animate();
  722. getViewMatrix(): Matrix;
  723. getProjectionMatrix(): Matrix;
  724. getTransformMatrix(): Matrix;
  725. setTransformMatrix(view: Matrix, projection: Matrix): void;
  726. addMesh(newMesh: AbstractMesh): void;
  727. removeMesh(toRemove: AbstractMesh): number;
  728. removeLight(toRemove: Light): number;
  729. removeCamera(toRemove: Camera): number;
  730. addLight(newLight: Light): void;
  731. addCamera(newCamera: Camera): void;
  732. /**
  733. * sets the active camera of the scene using its ID
  734. * @param {string} id - the camera's ID
  735. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  736. * @see activeCamera
  737. */
  738. setActiveCameraByID(id: string): Camera;
  739. /**
  740. * sets the active camera of the scene using its name
  741. * @param {string} name - the camera's name
  742. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  743. * @see activeCamera
  744. */
  745. setActiveCameraByName(name: string): Camera;
  746. /**
  747. * get a material using its id
  748. * @param {string} the material's ID
  749. * @return {BABYLON.Material|null} the material or null if none found.
  750. */
  751. getMaterialByID(id: string): Material;
  752. /**
  753. * get a material using its name
  754. * @param {string} the material's name
  755. * @return {BABYLON.Material|null} the material or null if none found.
  756. */
  757. getMaterialByName(name: string): Material;
  758. getCameraByID(id: string): Camera;
  759. getCameraByUniqueID(uniqueId: number): Camera;
  760. /**
  761. * get a camera using its name
  762. * @param {string} the camera's name
  763. * @return {BABYLON.Camera|null} the camera or null if none found.
  764. */
  765. getCameraByName(name: string): Camera;
  766. /**
  767. * get a light node using its name
  768. * @param {string} the light's name
  769. * @return {BABYLON.Light|null} the light or null if none found.
  770. */
  771. getLightByName(name: string): Light;
  772. /**
  773. * get a light node using its ID
  774. * @param {string} the light's id
  775. * @return {BABYLON.Light|null} the light or null if none found.
  776. */
  777. getLightByID(id: string): Light;
  778. /**
  779. * get a light node using its scene-generated unique ID
  780. * @param {number} the light's unique id
  781. * @return {BABYLON.Light|null} the light or null if none found.
  782. */
  783. getLightByUniqueID(uniqueId: number): Light;
  784. /**
  785. * get a geometry using its ID
  786. * @param {string} the geometry's id
  787. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  788. */
  789. getGeometryByID(id: string): Geometry;
  790. /**
  791. * add a new geometry to this scene.
  792. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  793. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  794. * @return {boolean} was the geometry added or not
  795. */
  796. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  797. /**
  798. * Removes an existing geometry
  799. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  800. * @return {boolean} was the geometry removed or not
  801. */
  802. removeGeometry(geometry: Geometry): boolean;
  803. getGeometries(): Geometry[];
  804. /**
  805. * Get the first added mesh found of a given ID
  806. * @param {string} id - the id to search for
  807. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  808. */
  809. getMeshByID(id: string): AbstractMesh;
  810. /**
  811. * Get a mesh with its auto-generated unique id
  812. * @param {number} uniqueId - the unique id to search for
  813. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  814. */
  815. getMeshByUniqueID(uniqueId: number): AbstractMesh;
  816. /**
  817. * Get a the last added mesh found of a given ID
  818. * @param {string} id - the id to search for
  819. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  820. */
  821. getLastMeshByID(id: string): AbstractMesh;
  822. /**
  823. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  824. * @param {string} id - the id to search for
  825. * @return {BABYLON.Node|null} the node found or null if not found at all.
  826. */
  827. getLastEntryByID(id: string): Node;
  828. getNodeByName(name: string): Node;
  829. getMeshByName(name: string): AbstractMesh;
  830. getSoundByName(name: string): Sound;
  831. getLastSkeletonByID(id: string): Skeleton;
  832. getSkeletonById(id: string): Skeleton;
  833. getSkeletonByName(name: string): Skeleton;
  834. isActiveMesh(mesh: Mesh): boolean;
  835. private _evaluateSubMesh(subMesh, mesh);
  836. private _evaluateActiveMeshes();
  837. private _activeMesh(mesh);
  838. updateTransformMatrix(force?: boolean): void;
  839. private _renderForCamera(camera);
  840. private _processSubCameras(camera);
  841. private _checkIntersections();
  842. render(): void;
  843. private _updateAudioParameters();
  844. audioEnabled: boolean;
  845. private _disableAudio();
  846. private _enableAudio();
  847. headphone: boolean;
  848. private _switchAudioModeForHeadphones();
  849. private _switchAudioModeForNormalSpeakers();
  850. enableDepthRenderer(): DepthRenderer;
  851. disableDepthRenderer(): void;
  852. dispose(): void;
  853. disposeSounds(): void;
  854. getWorldExtends(): {
  855. min: Vector3;
  856. max: Vector3;
  857. };
  858. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  859. createPickingRay(x: number, y: number, world: Matrix, camera: Camera): Ray;
  860. private _internalPick(rayFunction, predicate, fastCheck?);
  861. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo;
  862. pickWithRay(ray: Ray, predicate: (mesh: Mesh) => boolean, fastCheck?: boolean): PickingInfo;
  863. setPointerOverMesh(mesh: AbstractMesh): void;
  864. getPointerOverMesh(): AbstractMesh;
  865. getPhysicsEngine(): PhysicsEngine;
  866. enablePhysics(gravity: Vector3, plugin?: IPhysicsEnginePlugin): boolean;
  867. disablePhysicsEngine(): void;
  868. isPhysicsEnabled(): boolean;
  869. setGravity(gravity: Vector3): void;
  870. createCompoundImpostor(parts: any, options: PhysicsBodyCreationOptions): any;
  871. deleteCompoundImpostor(compound: any): void;
  872. createDefaultCameraOrLight(): void;
  873. private _getByTags(list, tagsQuery, forEach?);
  874. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  875. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  876. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  877. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  878. }
  879. }
  880. declare module BABYLON {
  881. class Action {
  882. triggerOptions: any;
  883. trigger: number;
  884. _actionManager: ActionManager;
  885. private _nextActiveAction;
  886. private _child;
  887. private _condition;
  888. private _triggerParameter;
  889. constructor(triggerOptions: any, condition?: Condition);
  890. _prepare(): void;
  891. getTriggerParameter(): any;
  892. _executeCurrent(evt: ActionEvent): void;
  893. execute(evt: ActionEvent): void;
  894. then(action: Action): Action;
  895. _getProperty(propertyPath: string): string;
  896. _getEffectiveTarget(target: any, propertyPath: string): any;
  897. }
  898. }
  899. declare module BABYLON {
  900. /**
  901. * ActionEvent is the event beint sent when an action is triggered.
  902. */
  903. class ActionEvent {
  904. source: AbstractMesh;
  905. pointerX: number;
  906. pointerY: number;
  907. meshUnderPointer: AbstractMesh;
  908. sourceEvent: any;
  909. /**
  910. * @constructor
  911. * @param source The mesh that triggered the action.
  912. * @param pointerX the X mouse cursor position at the time of the event
  913. * @param pointerY the Y mouse cursor position at the time of the event
  914. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  915. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  916. */
  917. constructor(source: AbstractMesh, pointerX: number, pointerY: number, meshUnderPointer: AbstractMesh, sourceEvent?: any);
  918. /**
  919. * Helper function to auto-create an ActionEvent from a source mesh.
  920. * @param source the source mesh that triggered the event
  921. * @param evt {Event} The original (browser) event
  922. */
  923. static CreateNew(source: AbstractMesh, evt?: Event): ActionEvent;
  924. /**
  925. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  926. * @param scene the scene where the event occurred
  927. * @param evt {Event} The original (browser) event
  928. */
  929. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  930. }
  931. /**
  932. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  933. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  934. */
  935. class ActionManager {
  936. private static _NothingTrigger;
  937. private static _OnPickTrigger;
  938. private static _OnLeftPickTrigger;
  939. private static _OnRightPickTrigger;
  940. private static _OnCenterPickTrigger;
  941. private static _OnPointerOverTrigger;
  942. private static _OnPointerOutTrigger;
  943. private static _OnEveryFrameTrigger;
  944. private static _OnIntersectionEnterTrigger;
  945. private static _OnIntersectionExitTrigger;
  946. private static _OnKeyDownTrigger;
  947. private static _OnKeyUpTrigger;
  948. private static _OnPickUpTrigger;
  949. static NothingTrigger: number;
  950. static OnPickTrigger: number;
  951. static OnLeftPickTrigger: number;
  952. static OnRightPickTrigger: number;
  953. static OnCenterPickTrigger: number;
  954. static OnPointerOverTrigger: number;
  955. static OnPointerOutTrigger: number;
  956. static OnEveryFrameTrigger: number;
  957. static OnIntersectionEnterTrigger: number;
  958. static OnIntersectionExitTrigger: number;
  959. static OnKeyDownTrigger: number;
  960. static OnKeyUpTrigger: number;
  961. static OnPickUpTrigger: number;
  962. actions: Action[];
  963. private _scene;
  964. constructor(scene: Scene);
  965. dispose(): void;
  966. getScene(): Scene;
  967. /**
  968. * Does this action manager handles actions of any of the given triggers
  969. * @param {number[]} triggers - the triggers to be tested
  970. * @return {boolean} whether one (or more) of the triggers is handeled
  971. */
  972. hasSpecificTriggers(triggers: number[]): boolean;
  973. /**
  974. * Does this action manager handles actions of a given trigger
  975. * @param {number} trigger - the trigger to be tested
  976. * @return {boolean} whether the trigger is handeled
  977. */
  978. hasSpecificTrigger(trigger: number): boolean;
  979. /**
  980. * Does this action manager has pointer triggers
  981. * @return {boolean} whether or not it has pointer triggers
  982. */
  983. hasPointerTriggers: boolean;
  984. /**
  985. * Does this action manager has pick triggers
  986. * @return {boolean} whether or not it has pick triggers
  987. */
  988. hasPickTriggers: boolean;
  989. /**
  990. * Registers an action to this action manager
  991. * @param {BABYLON.Action} action - the action to be registered
  992. * @return {BABYLON.Action} the action amended (prepared) after registration
  993. */
  994. registerAction(action: Action): Action;
  995. /**
  996. * Process a specific trigger
  997. * @param {number} trigger - the trigger to process
  998. * @param evt {BABYLON.ActionEvent} the event details to be processed
  999. */
  1000. processTrigger(trigger: number, evt: ActionEvent): void;
  1001. _getEffectiveTarget(target: any, propertyPath: string): any;
  1002. _getProperty(propertyPath: string): string;
  1003. }
  1004. }
  1005. declare module BABYLON {
  1006. class Condition {
  1007. _actionManager: ActionManager;
  1008. _evaluationId: number;
  1009. _currentResult: boolean;
  1010. constructor(actionManager: ActionManager);
  1011. isValid(): boolean;
  1012. _getProperty(propertyPath: string): string;
  1013. _getEffectiveTarget(target: any, propertyPath: string): any;
  1014. }
  1015. class ValueCondition extends Condition {
  1016. propertyPath: string;
  1017. value: any;
  1018. operator: number;
  1019. private static _IsEqual;
  1020. private static _IsDifferent;
  1021. private static _IsGreater;
  1022. private static _IsLesser;
  1023. static IsEqual: number;
  1024. static IsDifferent: number;
  1025. static IsGreater: number;
  1026. static IsLesser: number;
  1027. _actionManager: ActionManager;
  1028. private _target;
  1029. private _property;
  1030. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1031. isValid(): boolean;
  1032. }
  1033. class PredicateCondition extends Condition {
  1034. predicate: () => boolean;
  1035. _actionManager: ActionManager;
  1036. constructor(actionManager: ActionManager, predicate: () => boolean);
  1037. isValid(): boolean;
  1038. }
  1039. class StateCondition extends Condition {
  1040. value: string;
  1041. _actionManager: ActionManager;
  1042. private _target;
  1043. constructor(actionManager: ActionManager, target: any, value: string);
  1044. isValid(): boolean;
  1045. }
  1046. }
  1047. declare module BABYLON {
  1048. class SwitchBooleanAction extends Action {
  1049. propertyPath: string;
  1050. private _target;
  1051. private _property;
  1052. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1053. _prepare(): void;
  1054. execute(): void;
  1055. }
  1056. class SetStateAction extends Action {
  1057. value: string;
  1058. private _target;
  1059. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1060. execute(): void;
  1061. }
  1062. class SetValueAction extends Action {
  1063. propertyPath: string;
  1064. value: any;
  1065. private _target;
  1066. private _property;
  1067. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1068. _prepare(): void;
  1069. execute(): void;
  1070. }
  1071. class IncrementValueAction extends Action {
  1072. propertyPath: string;
  1073. value: any;
  1074. private _target;
  1075. private _property;
  1076. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1077. _prepare(): void;
  1078. execute(): void;
  1079. }
  1080. class PlayAnimationAction extends Action {
  1081. from: number;
  1082. to: number;
  1083. loop: boolean;
  1084. private _target;
  1085. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  1086. _prepare(): void;
  1087. execute(): void;
  1088. }
  1089. class StopAnimationAction extends Action {
  1090. private _target;
  1091. constructor(triggerOptions: any, target: any, condition?: Condition);
  1092. _prepare(): void;
  1093. execute(): void;
  1094. }
  1095. class DoNothingAction extends Action {
  1096. constructor(triggerOptions?: any, condition?: Condition);
  1097. execute(): void;
  1098. }
  1099. class CombineAction extends Action {
  1100. children: Action[];
  1101. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1102. _prepare(): void;
  1103. execute(evt: ActionEvent): void;
  1104. }
  1105. class ExecuteCodeAction extends Action {
  1106. func: (evt: ActionEvent) => void;
  1107. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1108. execute(evt: ActionEvent): void;
  1109. }
  1110. class SetParentAction extends Action {
  1111. private _parent;
  1112. private _target;
  1113. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1114. _prepare(): void;
  1115. execute(): void;
  1116. }
  1117. class PlaySoundAction extends Action {
  1118. private _sound;
  1119. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1120. _prepare(): void;
  1121. execute(): void;
  1122. }
  1123. class StopSoundAction extends Action {
  1124. private _sound;
  1125. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1126. _prepare(): void;
  1127. execute(): void;
  1128. }
  1129. }
  1130. declare module BABYLON {
  1131. class InterpolateValueAction extends Action {
  1132. propertyPath: string;
  1133. value: any;
  1134. duration: number;
  1135. stopOtherAnimations: boolean;
  1136. private _target;
  1137. private _property;
  1138. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean);
  1139. _prepare(): void;
  1140. execute(): void;
  1141. }
  1142. }
  1143. declare module BABYLON {
  1144. class Animatable {
  1145. target: any;
  1146. fromFrame: number;
  1147. toFrame: number;
  1148. loopAnimation: boolean;
  1149. speedRatio: number;
  1150. onAnimationEnd: any;
  1151. private _localDelayOffset;
  1152. private _pausedDelay;
  1153. private _animations;
  1154. private _paused;
  1155. private _scene;
  1156. animationStarted: boolean;
  1157. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: any, animations?: any);
  1158. appendAnimations(target: any, animations: Animation[]): void;
  1159. getAnimationByTargetProperty(property: string): Animation;
  1160. pause(): void;
  1161. restart(): void;
  1162. stop(): void;
  1163. _animate(delay: number): boolean;
  1164. }
  1165. }
  1166. declare module BABYLON {
  1167. class Animation {
  1168. name: string;
  1169. targetProperty: string;
  1170. framePerSecond: number;
  1171. dataType: number;
  1172. loopMode: number;
  1173. private _keys;
  1174. private _offsetsCache;
  1175. private _highLimitsCache;
  1176. private _stopped;
  1177. _target: any;
  1178. private _easingFunction;
  1179. targetPropertyPath: string[];
  1180. currentFrame: number;
  1181. static CreateAndStartAnimation(name: string, mesh: AbstractMesh, tartgetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number): Animatable;
  1182. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number);
  1183. isStopped(): boolean;
  1184. getKeys(): any[];
  1185. getEasingFunction(): IEasingFunction;
  1186. setEasingFunction(easingFunction: EasingFunction): void;
  1187. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  1188. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  1189. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  1190. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  1191. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  1192. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  1193. clone(): Animation;
  1194. setKeys(values: Array<any>): void;
  1195. private _getKeyValue(value);
  1196. private _interpolate(currentFrame, repeatCount, loopMode, offsetValue?, highLimitValue?);
  1197. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number): boolean;
  1198. private static _ANIMATIONTYPE_FLOAT;
  1199. private static _ANIMATIONTYPE_VECTOR3;
  1200. private static _ANIMATIONTYPE_QUATERNION;
  1201. private static _ANIMATIONTYPE_MATRIX;
  1202. private static _ANIMATIONTYPE_COLOR3;
  1203. private static _ANIMATIONTYPE_VECTOR2;
  1204. private static _ANIMATIONLOOPMODE_RELATIVE;
  1205. private static _ANIMATIONLOOPMODE_CYCLE;
  1206. private static _ANIMATIONLOOPMODE_CONSTANT;
  1207. static ANIMATIONTYPE_FLOAT: number;
  1208. static ANIMATIONTYPE_VECTOR3: number;
  1209. static ANIMATIONTYPE_VECTOR2: number;
  1210. static ANIMATIONTYPE_QUATERNION: number;
  1211. static ANIMATIONTYPE_MATRIX: number;
  1212. static ANIMATIONTYPE_COLOR3: number;
  1213. static ANIMATIONLOOPMODE_RELATIVE: number;
  1214. static ANIMATIONLOOPMODE_CYCLE: number;
  1215. static ANIMATIONLOOPMODE_CONSTANT: number;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. interface IEasingFunction {
  1220. ease(gradient: number): number;
  1221. }
  1222. class EasingFunction implements IEasingFunction {
  1223. private static _EASINGMODE_EASEIN;
  1224. private static _EASINGMODE_EASEOUT;
  1225. private static _EASINGMODE_EASEINOUT;
  1226. static EASINGMODE_EASEIN: number;
  1227. static EASINGMODE_EASEOUT: number;
  1228. static EASINGMODE_EASEINOUT: number;
  1229. private _easingMode;
  1230. setEasingMode(easingMode: number): void;
  1231. getEasingMode(): number;
  1232. easeInCore(gradient: number): number;
  1233. ease(gradient: number): number;
  1234. }
  1235. class CircleEase extends EasingFunction implements IEasingFunction {
  1236. easeInCore(gradient: number): number;
  1237. }
  1238. class BackEase extends EasingFunction implements IEasingFunction {
  1239. amplitude: number;
  1240. constructor(amplitude?: number);
  1241. easeInCore(gradient: number): number;
  1242. }
  1243. class BounceEase extends EasingFunction implements IEasingFunction {
  1244. bounces: number;
  1245. bounciness: number;
  1246. constructor(bounces?: number, bounciness?: number);
  1247. easeInCore(gradient: number): number;
  1248. }
  1249. class CubicEase extends EasingFunction implements IEasingFunction {
  1250. easeInCore(gradient: number): number;
  1251. }
  1252. class ElasticEase extends EasingFunction implements IEasingFunction {
  1253. oscillations: number;
  1254. springiness: number;
  1255. constructor(oscillations?: number, springiness?: number);
  1256. easeInCore(gradient: number): number;
  1257. }
  1258. class ExponentialEase extends EasingFunction implements IEasingFunction {
  1259. exponent: number;
  1260. constructor(exponent?: number);
  1261. easeInCore(gradient: number): number;
  1262. }
  1263. class PowerEase extends EasingFunction implements IEasingFunction {
  1264. power: number;
  1265. constructor(power?: number);
  1266. easeInCore(gradient: number): number;
  1267. }
  1268. class QuadraticEase extends EasingFunction implements IEasingFunction {
  1269. easeInCore(gradient: number): number;
  1270. }
  1271. class QuarticEase extends EasingFunction implements IEasingFunction {
  1272. easeInCore(gradient: number): number;
  1273. }
  1274. class QuinticEase extends EasingFunction implements IEasingFunction {
  1275. easeInCore(gradient: number): number;
  1276. }
  1277. class SineEase extends EasingFunction implements IEasingFunction {
  1278. easeInCore(gradient: number): number;
  1279. }
  1280. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  1281. x1: number;
  1282. y1: number;
  1283. x2: number;
  1284. y2: number;
  1285. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  1286. easeInCore(gradient: number): number;
  1287. }
  1288. }
  1289. declare module BABYLON {
  1290. class Analyser {
  1291. SMOOTHING: number;
  1292. FFT_SIZE: number;
  1293. BARGRAPHAMPLITUDE: number;
  1294. DEBUGCANVASPOS: {
  1295. x: number;
  1296. y: number;
  1297. };
  1298. DEBUGCANVASSIZE: {
  1299. width: number;
  1300. height: number;
  1301. };
  1302. private _byteFreqs;
  1303. private _byteTime;
  1304. private _floatFreqs;
  1305. private _webAudioAnalyser;
  1306. private _debugCanvas;
  1307. private _debugCanvasContext;
  1308. private _scene;
  1309. private _registerFunc;
  1310. private _audioEngine;
  1311. constructor(scene: Scene);
  1312. getFrequencyBinCount(): number;
  1313. getByteFrequencyData(): Uint8Array;
  1314. getByteTimeDomainData(): Uint8Array;
  1315. getFloatFrequencyData(): Uint8Array;
  1316. drawDebugCanvas(): void;
  1317. stopDebugCanvas(): void;
  1318. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  1319. dispose(): void;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. class AudioEngine {
  1324. private _audioContext;
  1325. private _audioContextInitialized;
  1326. canUseWebAudio: boolean;
  1327. masterGain: GainNode;
  1328. private _connectedAnalyser;
  1329. WarnedWebAudioUnsupported: boolean;
  1330. audioContext: AudioContext;
  1331. constructor();
  1332. private _initializeAudioContext();
  1333. dispose(): void;
  1334. getGlobalVolume(): number;
  1335. setGlobalVolume(newVolume: number): void;
  1336. connectToAnalyser(analyser: Analyser): void;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. class Sound {
  1341. name: string;
  1342. autoplay: boolean;
  1343. loop: boolean;
  1344. useCustomAttenuation: boolean;
  1345. soundTrackId: number;
  1346. spatialSound: boolean;
  1347. refDistance: number;
  1348. rolloffFactor: number;
  1349. maxDistance: number;
  1350. distanceModel: string;
  1351. private _panningModel;
  1352. onended: () => any;
  1353. private _playbackRate;
  1354. private _startTime;
  1355. private _startOffset;
  1356. private _position;
  1357. private _localDirection;
  1358. private _volume;
  1359. private _isLoaded;
  1360. private _isReadyToPlay;
  1361. isPlaying: boolean;
  1362. isPaused: boolean;
  1363. private _isDirectional;
  1364. private _readyToPlayCallback;
  1365. private _audioBuffer;
  1366. private _soundSource;
  1367. private _soundPanner;
  1368. private _soundGain;
  1369. private _inputAudioNode;
  1370. private _ouputAudioNode;
  1371. private _coneInnerAngle;
  1372. private _coneOuterAngle;
  1373. private _coneOuterGain;
  1374. private _scene;
  1375. private _connectedMesh;
  1376. private _customAttenuationFunction;
  1377. private _registerFunc;
  1378. /**
  1379. * Create a sound and attach it to a scene
  1380. * @param name Name of your sound
  1381. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  1382. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  1383. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel
  1384. */
  1385. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
  1386. dispose(): void;
  1387. private _soundLoaded(audioData);
  1388. setAudioBuffer(audioBuffer: AudioBuffer): void;
  1389. updateOptions(options: any): void;
  1390. private _createSpatialParameters();
  1391. private _updateSpatialParameters();
  1392. switchPanningModelToHRTF(): void;
  1393. switchPanningModelToEqualPower(): void;
  1394. private _switchPanningModel();
  1395. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  1396. /**
  1397. * Transform this sound into a directional source
  1398. * @param coneInnerAngle Size of the inner cone in degree
  1399. * @param coneOuterAngle Size of the outer cone in degree
  1400. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  1401. */
  1402. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  1403. setPosition(newPosition: Vector3): void;
  1404. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  1405. private _updateDirection();
  1406. updateDistanceFromListener(): void;
  1407. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  1408. /**
  1409. * Play the sound
  1410. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  1411. */
  1412. play(time?: number): void;
  1413. private _onended();
  1414. /**
  1415. * Stop the sound
  1416. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  1417. */
  1418. stop(time?: number): void;
  1419. pause(): void;
  1420. setVolume(newVolume: number, time?: number): void;
  1421. setPlaybackRate(newPlaybackRate: number): void;
  1422. getVolume(): number;
  1423. attachToMesh(meshToConnectTo: AbstractMesh): void;
  1424. private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
  1425. }
  1426. }
  1427. declare module BABYLON {
  1428. class SoundTrack {
  1429. private _audioEngine;
  1430. private _outputAudioNode;
  1431. private _inputAudioNode;
  1432. private _trackConvolver;
  1433. private _scene;
  1434. id: number;
  1435. soundCollection: Array<Sound>;
  1436. private _isMainTrack;
  1437. private _connectedAnalyser;
  1438. constructor(scene: Scene, options?: any);
  1439. dispose(): void;
  1440. AddSound(sound: Sound): void;
  1441. RemoveSound(sound: Sound): void;
  1442. setVolume(newVolume: number): void;
  1443. switchPanningModelToHRTF(): void;
  1444. switchPanningModelToEqualPower(): void;
  1445. connectToAnalyser(analyser: Analyser): void;
  1446. }
  1447. }
  1448. declare module BABYLON {
  1449. class Bone {
  1450. name: string;
  1451. children: Bone[];
  1452. animations: Animation[];
  1453. private _skeleton;
  1454. private _matrix;
  1455. private _baseMatrix;
  1456. private _worldTransform;
  1457. private _absoluteTransform;
  1458. private _invertedAbsoluteTransform;
  1459. private _parent;
  1460. constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix);
  1461. getParent(): Bone;
  1462. getLocalMatrix(): Matrix;
  1463. getBaseMatrix(): Matrix;
  1464. getWorldMatrix(): Matrix;
  1465. getInvertedAbsoluteTransform(): Matrix;
  1466. getAbsoluteMatrix(): Matrix;
  1467. updateMatrix(matrix: Matrix): void;
  1468. private _updateDifferenceMatrix();
  1469. markAsDirty(): void;
  1470. }
  1471. }
  1472. declare module BABYLON {
  1473. class Skeleton {
  1474. name: string;
  1475. id: string;
  1476. bones: Bone[];
  1477. private _scene;
  1478. private _isDirty;
  1479. private _transformMatrices;
  1480. private _animatables;
  1481. private _identity;
  1482. constructor(name: string, id: string, scene: Scene);
  1483. getTransformMatrices(): Float32Array;
  1484. _markAsDirty(): void;
  1485. prepare(): void;
  1486. getAnimatables(): IAnimatable[];
  1487. clone(name: string, id: string): Skeleton;
  1488. }
  1489. }
  1490. declare module BABYLON {
  1491. class AnaglyphFreeCamera extends FreeCamera {
  1492. constructor(name: string, position: Vector3, eyeSpace: number, scene: Scene);
  1493. }
  1494. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  1495. constructor(name: string, alpha: number, beta: number, radius: number, target: any, eyeSpace: number, scene: Scene);
  1496. }
  1497. class AnaglyphGamepadCamera extends GamepadCamera {
  1498. constructor(name: string, position: Vector3, eyeSpace: number, scene: Scene);
  1499. }
  1500. }
  1501. declare module BABYLON {
  1502. class ArcRotateCamera extends Camera {
  1503. alpha: number;
  1504. beta: number;
  1505. radius: number;
  1506. target: any;
  1507. inertialAlphaOffset: number;
  1508. inertialBetaOffset: number;
  1509. inertialRadiusOffset: number;
  1510. lowerAlphaLimit: any;
  1511. upperAlphaLimit: any;
  1512. lowerBetaLimit: number;
  1513. upperBetaLimit: number;
  1514. lowerRadiusLimit: any;
  1515. upperRadiusLimit: any;
  1516. angularSensibility: number;
  1517. wheelPrecision: number;
  1518. pinchPrecision: number;
  1519. keysUp: number[];
  1520. keysDown: number[];
  1521. keysLeft: number[];
  1522. keysRight: number[];
  1523. zoomOnFactor: number;
  1524. targetScreenOffset: Vector2;
  1525. pinchInwards: boolean;
  1526. allowUpsideDown: boolean;
  1527. private _keys;
  1528. private _viewMatrix;
  1529. private _attachedElement;
  1530. private _onPointerDown;
  1531. private _onPointerUp;
  1532. private _onPointerMove;
  1533. private _wheel;
  1534. private _onMouseMove;
  1535. private _onKeyDown;
  1536. private _onKeyUp;
  1537. private _onLostFocus;
  1538. private _reset;
  1539. private _onGestureStart;
  1540. private _onGesture;
  1541. private _MSGestureHandler;
  1542. onCollide: (collidedMesh: AbstractMesh) => void;
  1543. checkCollisions: boolean;
  1544. collisionRadius: Vector3;
  1545. private _collider;
  1546. private _previousPosition;
  1547. private _collisionVelocity;
  1548. private _newPosition;
  1549. private _previousAlpha;
  1550. private _previousBeta;
  1551. private _previousRadius;
  1552. private _collisionTriggered;
  1553. constructor(name: string, alpha: number, beta: number, radius: number, target: any, scene: Scene);
  1554. _getTargetPosition(): Vector3;
  1555. _initCache(): void;
  1556. _updateCache(ignoreParentClass?: boolean): void;
  1557. _isSynchronizedViewMatrix(): boolean;
  1558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1559. detachControl(element: HTMLElement): void;
  1560. _checkInputs(): void;
  1561. private _checkLimits();
  1562. setPosition(position: Vector3): void;
  1563. _getViewMatrix(): Matrix;
  1564. private _onCollisionPositionChange;
  1565. zoomOn(meshes?: AbstractMesh[]): void;
  1566. focusOn(meshesOrMinMaxVectorAndDistance: any): void;
  1567. /**
  1568. * @override
  1569. * Override Camera.createRigCamera
  1570. */
  1571. createRigCamera(name: string, cameraIndex: number): Camera;
  1572. /**
  1573. * @override
  1574. * Override Camera._updateRigCameras
  1575. */
  1576. _updateRigCameras(): void;
  1577. }
  1578. }
  1579. declare module BABYLON {
  1580. class VRCameraMetrics {
  1581. hResolution: number;
  1582. vResolution: number;
  1583. hScreenSize: number;
  1584. vScreenSize: number;
  1585. vScreenCenter: number;
  1586. eyeToScreenDistance: number;
  1587. lensSeparationDistance: number;
  1588. interpupillaryDistance: number;
  1589. distortionK: number[];
  1590. chromaAbCorrection: number[];
  1591. postProcessScaleFactor: number;
  1592. lensCenterOffset: number;
  1593. compensateDistorsion: boolean;
  1594. aspectRatio: number;
  1595. aspectRatioFov: number;
  1596. leftHMatrix: Matrix;
  1597. rightHMatrix: Matrix;
  1598. leftPreViewMatrix: Matrix;
  1599. rightPreViewMatrix: Matrix;
  1600. static GetDefault(): VRCameraMetrics;
  1601. }
  1602. class Camera extends Node {
  1603. position: Vector3;
  1604. private static _PERSPECTIVE_CAMERA;
  1605. private static _ORTHOGRAPHIC_CAMERA;
  1606. private static _FOVMODE_VERTICAL_FIXED;
  1607. private static _FOVMODE_HORIZONTAL_FIXED;
  1608. private static _RIG_MODE_NONE;
  1609. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  1610. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  1611. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  1612. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  1613. private static _RIG_MODE_VR;
  1614. static PERSPECTIVE_CAMERA: number;
  1615. static ORTHOGRAPHIC_CAMERA: number;
  1616. static FOVMODE_VERTICAL_FIXED: number;
  1617. static FOVMODE_HORIZONTAL_FIXED: number;
  1618. static RIG_MODE_NONE: number;
  1619. static RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  1620. static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  1621. static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  1622. static RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  1623. static RIG_MODE_VR: number;
  1624. upVector: Vector3;
  1625. orthoLeft: any;
  1626. orthoRight: any;
  1627. orthoBottom: any;
  1628. orthoTop: any;
  1629. fov: number;
  1630. minZ: number;
  1631. maxZ: number;
  1632. inertia: number;
  1633. mode: number;
  1634. isIntermediate: boolean;
  1635. viewport: Viewport;
  1636. layerMask: number;
  1637. fovMode: number;
  1638. cameraRigMode: number;
  1639. _cameraRigParams: any;
  1640. _rigCameras: Camera[];
  1641. private _computedViewMatrix;
  1642. _projectionMatrix: Matrix;
  1643. private _worldMatrix;
  1644. _postProcesses: PostProcess[];
  1645. _postProcessesTakenIndices: any[];
  1646. _activeMeshes: SmartArray<Mesh>;
  1647. private _globalPosition;
  1648. constructor(name: string, position: Vector3, scene: Scene);
  1649. globalPosition: Vector3;
  1650. getActiveMeshes(): SmartArray<Mesh>;
  1651. isActiveMesh(mesh: Mesh): boolean;
  1652. _initCache(): void;
  1653. _updateCache(ignoreParentClass?: boolean): void;
  1654. _updateFromScene(): void;
  1655. _isSynchronized(): boolean;
  1656. _isSynchronizedViewMatrix(): boolean;
  1657. _isSynchronizedProjectionMatrix(): boolean;
  1658. attachControl(element: HTMLElement): void;
  1659. detachControl(element: HTMLElement): void;
  1660. _update(): void;
  1661. _checkInputs(): void;
  1662. attachPostProcess(postProcess: PostProcess, insertAt?: number): number;
  1663. detachPostProcess(postProcess: PostProcess, atIndices?: any): number[];
  1664. getWorldMatrix(): Matrix;
  1665. _getViewMatrix(): Matrix;
  1666. getViewMatrix(force?: boolean): Matrix;
  1667. _computeViewMatrix(force?: boolean): Matrix;
  1668. getProjectionMatrix(force?: boolean): Matrix;
  1669. dispose(): void;
  1670. setCameraRigMode(mode: number, rigParams: any): void;
  1671. private _getVRProjectionMatrix();
  1672. setCameraRigParameter(name: string, value: any): void;
  1673. /**
  1674. * May needs to be overridden by children so sub has required properties to be copied
  1675. */
  1676. createRigCamera(name: string, cameraIndex: number): Camera;
  1677. /**
  1678. * May needs to be overridden by children
  1679. */
  1680. _updateRigCameras(): void;
  1681. }
  1682. }
  1683. declare module BABYLON {
  1684. class DeviceOrientationCamera extends FreeCamera {
  1685. private _offsetX;
  1686. private _offsetY;
  1687. private _orientationGamma;
  1688. private _orientationBeta;
  1689. private _initialOrientationGamma;
  1690. private _initialOrientationBeta;
  1691. private _attachedCanvas;
  1692. private _orientationChanged;
  1693. angularSensibility: number;
  1694. moveSensibility: number;
  1695. constructor(name: string, position: Vector3, scene: Scene);
  1696. attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void;
  1697. detachControl(canvas: HTMLCanvasElement): void;
  1698. _checkInputs(): void;
  1699. }
  1700. }
  1701. declare module BABYLON {
  1702. class FollowCamera extends TargetCamera {
  1703. radius: number;
  1704. rotationOffset: number;
  1705. heightOffset: number;
  1706. cameraAcceleration: number;
  1707. maxCameraSpeed: number;
  1708. target: AbstractMesh;
  1709. constructor(name: string, position: Vector3, scene: Scene);
  1710. private getRadians(degrees);
  1711. private follow(cameraTarget);
  1712. _checkInputs(): void;
  1713. }
  1714. }
  1715. declare module BABYLON {
  1716. class FreeCamera extends TargetCamera {
  1717. ellipsoid: Vector3;
  1718. keysUp: number[];
  1719. keysDown: number[];
  1720. keysLeft: number[];
  1721. keysRight: number[];
  1722. checkCollisions: boolean;
  1723. applyGravity: boolean;
  1724. angularSensibility: number;
  1725. onCollide: (collidedMesh: AbstractMesh) => void;
  1726. private _keys;
  1727. private _collider;
  1728. private _needMoveForGravity;
  1729. private _oldPosition;
  1730. private _diffPosition;
  1731. private _newPosition;
  1732. private _attachedElement;
  1733. private _localDirection;
  1734. private _transformedDirection;
  1735. private _onMouseDown;
  1736. private _onMouseUp;
  1737. private _onMouseOut;
  1738. private _onMouseMove;
  1739. private _onKeyDown;
  1740. private _onKeyUp;
  1741. _onLostFocus: (e: FocusEvent) => any;
  1742. _waitingLockedTargetId: string;
  1743. constructor(name: string, position: Vector3, scene: Scene);
  1744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1745. detachControl(element: HTMLElement): void;
  1746. _collideWithWorld(velocity: Vector3): void;
  1747. private _onCollisionPositionChange;
  1748. _checkInputs(): void;
  1749. _decideIfNeedsToMove(): boolean;
  1750. _updatePosition(): void;
  1751. }
  1752. }
  1753. declare module BABYLON {
  1754. class GamepadCamera extends FreeCamera {
  1755. private _gamepad;
  1756. private _gamepads;
  1757. angularSensibility: number;
  1758. moveSensibility: number;
  1759. constructor(name: string, position: Vector3, scene: Scene);
  1760. private _onNewGameConnected(gamepad);
  1761. _checkInputs(): void;
  1762. dispose(): void;
  1763. }
  1764. }
  1765. declare module BABYLON {
  1766. class TargetCamera extends Camera {
  1767. cameraDirection: Vector3;
  1768. cameraRotation: Vector2;
  1769. rotation: Vector3;
  1770. speed: number;
  1771. noRotationConstraint: boolean;
  1772. lockedTarget: any;
  1773. _currentTarget: Vector3;
  1774. _viewMatrix: Matrix;
  1775. _camMatrix: Matrix;
  1776. _cameraTransformMatrix: Matrix;
  1777. _cameraRotationMatrix: Matrix;
  1778. private _rigCamTransformMatrix;
  1779. _referencePoint: Vector3;
  1780. _transformedReferencePoint: Vector3;
  1781. _lookAtTemp: Matrix;
  1782. _tempMatrix: Matrix;
  1783. _reset: () => void;
  1784. _waitingLockedTargetId: string;
  1785. constructor(name: string, position: Vector3, scene: Scene);
  1786. _getLockedTargetPosition(): Vector3;
  1787. _initCache(): void;
  1788. _updateCache(ignoreParentClass?: boolean): void;
  1789. _isSynchronizedViewMatrix(): boolean;
  1790. _computeLocalCameraSpeed(): number;
  1791. setTarget(target: Vector3): void;
  1792. getTarget(): Vector3;
  1793. _decideIfNeedsToMove(): boolean;
  1794. _updatePosition(): void;
  1795. _checkInputs(): void;
  1796. _getViewMatrix(): Matrix;
  1797. _getVRViewMatrix(): Matrix;
  1798. /**
  1799. * @override
  1800. * Override Camera.createRigCamera
  1801. */
  1802. createRigCamera(name: string, cameraIndex: number): Camera;
  1803. /**
  1804. * @override
  1805. * Override Camera._updateRigCameras
  1806. */
  1807. _updateRigCameras(): void;
  1808. private _getRigCamPosition(halfSpace, result);
  1809. }
  1810. }
  1811. declare module BABYLON {
  1812. class TouchCamera extends FreeCamera {
  1813. private _offsetX;
  1814. private _offsetY;
  1815. private _pointerCount;
  1816. private _pointerPressed;
  1817. private _attachedCanvas;
  1818. private _onPointerDown;
  1819. private _onPointerUp;
  1820. private _onPointerMove;
  1821. angularSensibility: number;
  1822. moveSensibility: number;
  1823. constructor(name: string, position: Vector3, scene: Scene);
  1824. attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void;
  1825. detachControl(canvas: HTMLCanvasElement): void;
  1826. _checkInputs(): void;
  1827. }
  1828. }
  1829. declare module BABYLON {
  1830. class VirtualJoysticksCamera extends FreeCamera {
  1831. private _leftjoystick;
  1832. private _rightjoystick;
  1833. constructor(name: string, position: Vector3, scene: Scene);
  1834. _checkInputs(): void;
  1835. dispose(): void;
  1836. }
  1837. }
  1838. declare module BABYLON {
  1839. class VRCamera extends FreeCamera {
  1840. private _leftCamera;
  1841. private _rightCamera;
  1842. private _offsetOrientation;
  1843. private _deviceOrientationHandler;
  1844. constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
  1845. _update(): void;
  1846. _updateCamera(camera: FreeCamera): void;
  1847. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1849. detachControl(element: HTMLElement): void;
  1850. }
  1851. }
  1852. declare module BABYLON {
  1853. class VRDeviceOrientationFreeCamera extends FreeCamera {
  1854. _alpha: number;
  1855. _beta: number;
  1856. _gamma: number;
  1857. private _offsetOrientation;
  1858. private _deviceOrientationHandler;
  1859. constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
  1860. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1862. detachControl(element: HTMLElement): void;
  1863. }
  1864. }
  1865. declare var HMDVRDevice: any;
  1866. declare var PositionSensorVRDevice: any;
  1867. declare module BABYLON {
  1868. class WebVRFreeCamera extends FreeCamera {
  1869. _hmdDevice: any;
  1870. _sensorDevice: any;
  1871. _cacheState: any;
  1872. _cacheQuaternion: Quaternion;
  1873. _cacheRotation: Vector3;
  1874. _vrEnabled: boolean;
  1875. constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
  1876. private _getWebVRDevices(devices);
  1877. _checkInputs(): void;
  1878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1879. detachControl(element: HTMLElement): void;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. class Collider {
  1884. radius: Vector3;
  1885. retry: number;
  1886. velocity: Vector3;
  1887. basePoint: Vector3;
  1888. epsilon: number;
  1889. collisionFound: boolean;
  1890. velocityWorldLength: number;
  1891. basePointWorld: Vector3;
  1892. velocityWorld: Vector3;
  1893. normalizedVelocity: Vector3;
  1894. initialVelocity: Vector3;
  1895. initialPosition: Vector3;
  1896. nearestDistance: number;
  1897. intersectionPoint: Vector3;
  1898. collidedMesh: AbstractMesh;
  1899. private _collisionPoint;
  1900. private _planeIntersectionPoint;
  1901. private _tempVector;
  1902. private _tempVector2;
  1903. private _tempVector3;
  1904. private _tempVector4;
  1905. private _edge;
  1906. private _baseToVertex;
  1907. private _destinationPoint;
  1908. private _slidePlaneNormal;
  1909. private _displacementVector;
  1910. _initialize(source: Vector3, dir: Vector3, e: number): void;
  1911. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  1912. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  1913. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  1914. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: number[], indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  1915. _getResponse(pos: Vector3, vel: Vector3): void;
  1916. }
  1917. }
  1918. declare module BABYLON {
  1919. var CollisionWorker: string;
  1920. interface ICollisionCoordinator {
  1921. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  1922. init(scene: Scene): void;
  1923. destroy(): void;
  1924. onMeshAdded(mesh: AbstractMesh): any;
  1925. onMeshUpdated(mesh: AbstractMesh): any;
  1926. onMeshRemoved(mesh: AbstractMesh): any;
  1927. onGeometryAdded(geometry: Geometry): any;
  1928. onGeometryUpdated(geometry: Geometry): any;
  1929. onGeometryDeleted(geometry: Geometry): any;
  1930. }
  1931. interface SerializedMesh {
  1932. id: string;
  1933. name: string;
  1934. uniqueId: number;
  1935. geometryId: string;
  1936. sphereCenter: Array<number>;
  1937. sphereRadius: number;
  1938. boxMinimum: Array<number>;
  1939. boxMaximum: Array<number>;
  1940. worldMatrixFromCache: any;
  1941. subMeshes: Array<SerializedSubMesh>;
  1942. checkCollisions: boolean;
  1943. }
  1944. interface SerializedSubMesh {
  1945. position: number;
  1946. verticesStart: number;
  1947. verticesCount: number;
  1948. indexStart: number;
  1949. indexCount: number;
  1950. hasMaterial: boolean;
  1951. sphereCenter: Array<number>;
  1952. sphereRadius: number;
  1953. boxMinimum: Array<number>;
  1954. boxMaximum: Array<number>;
  1955. }
  1956. interface SerializedGeometry {
  1957. id: string;
  1958. positions: Float32Array;
  1959. indices: Int32Array;
  1960. normals: Float32Array;
  1961. }
  1962. interface BabylonMessage {
  1963. taskType: WorkerTaskType;
  1964. payload: InitPayload | CollidePayload | UpdatePayload;
  1965. }
  1966. interface SerializedColliderToWorker {
  1967. position: Array<number>;
  1968. velocity: Array<number>;
  1969. radius: Array<number>;
  1970. }
  1971. enum WorkerTaskType {
  1972. INIT = 0,
  1973. UPDATE = 1,
  1974. COLLIDE = 2,
  1975. }
  1976. interface WorkerReply {
  1977. error: WorkerReplyType;
  1978. taskType: WorkerTaskType;
  1979. payload?: any;
  1980. }
  1981. interface CollisionReplyPayload {
  1982. newPosition: Array<number>;
  1983. collisionId: number;
  1984. collidedMeshUniqueId: number;
  1985. }
  1986. interface InitPayload {
  1987. }
  1988. interface CollidePayload {
  1989. collisionId: number;
  1990. collider: SerializedColliderToWorker;
  1991. maximumRetry: number;
  1992. excludedMeshUniqueId?: number;
  1993. }
  1994. interface UpdatePayload {
  1995. updatedMeshes: {
  1996. [n: number]: SerializedMesh;
  1997. };
  1998. updatedGeometries: {
  1999. [s: string]: SerializedGeometry;
  2000. };
  2001. removedMeshes: Array<number>;
  2002. removedGeometries: Array<string>;
  2003. }
  2004. enum WorkerReplyType {
  2005. SUCCESS = 0,
  2006. UNKNOWN_ERROR = 1,
  2007. }
  2008. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  2009. private _scene;
  2010. private _scaledPosition;
  2011. private _scaledVelocity;
  2012. private _collisionsCallbackArray;
  2013. private _init;
  2014. private _runningUpdated;
  2015. private _runningCollisionTask;
  2016. private _worker;
  2017. private _addUpdateMeshesList;
  2018. private _addUpdateGeometriesList;
  2019. private _toRemoveMeshesArray;
  2020. private _toRemoveGeometryArray;
  2021. constructor();
  2022. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  2023. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  2024. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  2025. init(scene: Scene): void;
  2026. destroy(): void;
  2027. onMeshAdded(mesh: AbstractMesh): void;
  2028. onMeshUpdated: (mesh: AbstractMesh) => void;
  2029. onMeshRemoved(mesh: AbstractMesh): void;
  2030. onGeometryAdded(geometry: Geometry): void;
  2031. onGeometryUpdated: (geometry: Geometry) => void;
  2032. onGeometryDeleted(geometry: Geometry): void;
  2033. private _afterRender;
  2034. private _onMessageFromWorker;
  2035. }
  2036. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  2037. private _scene;
  2038. private _scaledPosition;
  2039. private _scaledVelocity;
  2040. private _finalPosition;
  2041. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  2042. init(scene: Scene): void;
  2043. destroy(): void;
  2044. onMeshAdded(mesh: AbstractMesh): void;
  2045. onMeshUpdated(mesh: AbstractMesh): void;
  2046. onMeshRemoved(mesh: AbstractMesh): void;
  2047. onGeometryAdded(geometry: Geometry): void;
  2048. onGeometryUpdated(geometry: Geometry): void;
  2049. onGeometryDeleted(geometry: Geometry): void;
  2050. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  2051. }
  2052. }
  2053. declare module BABYLON {
  2054. var WorkerIncluded: boolean;
  2055. class CollisionCache {
  2056. private _meshes;
  2057. private _geometries;
  2058. getMeshes(): {
  2059. [n: number]: SerializedMesh;
  2060. };
  2061. getGeometries(): {
  2062. [s: number]: SerializedGeometry;
  2063. };
  2064. getMesh(id: any): SerializedMesh;
  2065. addMesh(mesh: SerializedMesh): void;
  2066. getGeometry(id: string): SerializedGeometry;
  2067. addGeometry(geometry: SerializedGeometry): void;
  2068. }
  2069. class CollideWorker {
  2070. collider: Collider;
  2071. private _collisionCache;
  2072. private finalPosition;
  2073. private collisionsScalingMatrix;
  2074. private collisionTranformationMatrix;
  2075. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  2076. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId?: number): void;
  2077. private checkCollision(mesh);
  2078. private processCollisionsForSubMeshes(transformMatrix, mesh);
  2079. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  2080. private checkSubmeshCollision(subMesh);
  2081. }
  2082. interface ICollisionDetector {
  2083. onInit(payload: InitPayload): void;
  2084. onUpdate(payload: UpdatePayload): void;
  2085. onCollision(payload: CollidePayload): void;
  2086. }
  2087. class CollisionDetectorTransferable implements ICollisionDetector {
  2088. private _collisionCache;
  2089. onInit(payload: InitPayload): void;
  2090. onUpdate(payload: UpdatePayload): void;
  2091. onCollision(payload: CollidePayload): void;
  2092. }
  2093. }
  2094. declare module BABYLON {
  2095. class IntersectionInfo {
  2096. bu: number;
  2097. bv: number;
  2098. distance: number;
  2099. faceId: number;
  2100. subMeshId: number;
  2101. constructor(bu: number, bv: number, distance: number);
  2102. }
  2103. class PickingInfo {
  2104. hit: boolean;
  2105. distance: number;
  2106. pickedPoint: Vector3;
  2107. pickedMesh: AbstractMesh;
  2108. bu: number;
  2109. bv: number;
  2110. faceId: number;
  2111. subMeshId: number;
  2112. getNormal(useWorldCoordinates?: boolean): Vector3;
  2113. getTextureCoordinates(): Vector2;
  2114. }
  2115. }
  2116. declare module BABYLON {
  2117. class BoundingBox {
  2118. minimum: Vector3;
  2119. maximum: Vector3;
  2120. vectors: Vector3[];
  2121. center: Vector3;
  2122. extendSize: Vector3;
  2123. directions: Vector3[];
  2124. vectorsWorld: Vector3[];
  2125. minimumWorld: Vector3;
  2126. maximumWorld: Vector3;
  2127. private _worldMatrix;
  2128. constructor(minimum: Vector3, maximum: Vector3);
  2129. getWorldMatrix(): Matrix;
  2130. _update(world: Matrix): void;
  2131. isInFrustum(frustumPlanes: Plane[]): boolean;
  2132. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2133. intersectsPoint(point: Vector3): boolean;
  2134. intersectsSphere(sphere: BoundingSphere): boolean;
  2135. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  2136. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  2137. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  2138. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2139. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2140. }
  2141. }
  2142. declare module BABYLON {
  2143. class BoundingInfo {
  2144. minimum: Vector3;
  2145. maximum: Vector3;
  2146. boundingBox: BoundingBox;
  2147. boundingSphere: BoundingSphere;
  2148. constructor(minimum: Vector3, maximum: Vector3);
  2149. _update(world: Matrix): void;
  2150. isInFrustum(frustumPlanes: Plane[]): boolean;
  2151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2152. _checkCollision(collider: Collider): boolean;
  2153. intersectsPoint(point: Vector3): boolean;
  2154. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  2155. }
  2156. }
  2157. declare module BABYLON {
  2158. class BoundingSphere {
  2159. minimum: Vector3;
  2160. maximum: Vector3;
  2161. center: Vector3;
  2162. radius: number;
  2163. centerWorld: Vector3;
  2164. radiusWorld: number;
  2165. private _tempRadiusVector;
  2166. constructor(minimum: Vector3, maximum: Vector3);
  2167. _update(world: Matrix): void;
  2168. isInFrustum(frustumPlanes: Plane[]): boolean;
  2169. intersectsPoint(point: Vector3): boolean;
  2170. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  2171. }
  2172. }
  2173. declare module BABYLON {
  2174. interface IOctreeContainer<T> {
  2175. blocks: Array<OctreeBlock<T>>;
  2176. }
  2177. class Octree<T> {
  2178. maxDepth: number;
  2179. blocks: Array<OctreeBlock<T>>;
  2180. dynamicContent: T[];
  2181. private _maxBlockCapacity;
  2182. private _selectionContent;
  2183. private _creationFunc;
  2184. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  2185. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  2186. addMesh(entry: T): void;
  2187. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  2188. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  2189. intersectsRay(ray: Ray): SmartArray<T>;
  2190. 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;
  2191. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  2192. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  2193. }
  2194. }
  2195. declare module BABYLON {
  2196. class OctreeBlock<T> {
  2197. entries: T[];
  2198. blocks: Array<OctreeBlock<T>>;
  2199. private _depth;
  2200. private _maxDepth;
  2201. private _capacity;
  2202. private _minPoint;
  2203. private _maxPoint;
  2204. private _boundingVectors;
  2205. private _creationFunc;
  2206. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  2207. capacity: number;
  2208. minPoint: Vector3;
  2209. maxPoint: Vector3;
  2210. addEntry(entry: T): void;
  2211. addEntries(entries: T[]): void;
  2212. select(frustumPlanes: Plane[], selection: SmartArray<T>, allowDuplicate?: boolean): void;
  2213. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray<T>, allowDuplicate?: boolean): void;
  2214. intersectsRay(ray: Ray, selection: SmartArray<T>): void;
  2215. createInnerBlocks(): void;
  2216. }
  2217. }
  2218. declare module BABYLON {
  2219. class DebugLayer {
  2220. private _scene;
  2221. private _camera;
  2222. private _transformationMatrix;
  2223. private _enabled;
  2224. private _labelsEnabled;
  2225. private _displayStatistics;
  2226. private _displayTree;
  2227. private _displayLogs;
  2228. private _globalDiv;
  2229. private _statsDiv;
  2230. private _statsSubsetDiv;
  2231. private _optionsDiv;
  2232. private _optionsSubsetDiv;
  2233. private _logDiv;
  2234. private _logSubsetDiv;
  2235. private _treeDiv;
  2236. private _treeSubsetDiv;
  2237. private _drawingCanvas;
  2238. private _drawingContext;
  2239. private _syncPositions;
  2240. private _syncData;
  2241. private _syncUI;
  2242. private _onCanvasClick;
  2243. private _clickPosition;
  2244. private _ratio;
  2245. private _identityMatrix;
  2246. private _showUI;
  2247. private _needToRefreshMeshesTree;
  2248. shouldDisplayLabel: (node: Node) => boolean;
  2249. shouldDisplayAxis: (mesh: Mesh) => boolean;
  2250. axisRatio: number;
  2251. accentColor: string;
  2252. customStatsFunction: () => string;
  2253. constructor(scene: Scene);
  2254. private _refreshMeshesTreeContent();
  2255. private _renderSingleAxis(zero, unit, unitText, label, color);
  2256. private _renderAxis(projectedPosition, mesh, globalViewport);
  2257. private _renderLabel(text, projectedPosition, labelOffset, onClick, getFillStyle);
  2258. private _isClickInsideRect(x, y, width, height);
  2259. isVisible(): boolean;
  2260. hide(): void;
  2261. show(showUI?: boolean, camera?: Camera): void;
  2262. private _clearLabels();
  2263. private _generateheader(root, text);
  2264. private _generateTexBox(root, title, color);
  2265. private _generateAdvancedCheckBox(root, leftTitle, rightTitle, initialState, task, tag?);
  2266. private _generateCheckBox(root, title, initialState, task, tag?);
  2267. private _generateButton(root, title, task, tag?);
  2268. private _generateRadio(root, title, name, initialState, task, tag?);
  2269. private _generateDOMelements();
  2270. private _displayStats();
  2271. }
  2272. }
  2273. declare module BABYLON {
  2274. class Layer {
  2275. name: string;
  2276. texture: Texture;
  2277. isBackground: boolean;
  2278. color: Color4;
  2279. onDispose: () => void;
  2280. private _scene;
  2281. private _vertexDeclaration;
  2282. private _vertexStrideSize;
  2283. private _vertexBuffer;
  2284. private _indexBuffer;
  2285. private _effect;
  2286. constructor(name: string, imgUrl: string, scene: Scene, isBackground?: boolean, color?: Color4);
  2287. render(): void;
  2288. dispose(): void;
  2289. }
  2290. }
  2291. declare module BABYLON {
  2292. class LensFlare {
  2293. size: number;
  2294. position: number;
  2295. color: Color3;
  2296. texture: Texture;
  2297. private _system;
  2298. constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem);
  2299. dispose: () => void;
  2300. }
  2301. }
  2302. declare module BABYLON {
  2303. class LensFlareSystem {
  2304. name: string;
  2305. lensFlares: LensFlare[];
  2306. borderLimit: number;
  2307. meshesSelectionPredicate: (mesh: Mesh) => boolean;
  2308. private _scene;
  2309. private _emitter;
  2310. private _vertexDeclaration;
  2311. private _vertexStrideSize;
  2312. private _vertexBuffer;
  2313. private _indexBuffer;
  2314. private _effect;
  2315. private _positionX;
  2316. private _positionY;
  2317. private _isEnabled;
  2318. constructor(name: string, emitter: any, scene: Scene);
  2319. isEnabled: boolean;
  2320. getScene(): Scene;
  2321. getEmitter(): any;
  2322. getEmitterPosition(): Vector3;
  2323. computeEffectivePosition(globalViewport: Viewport): boolean;
  2324. _isVisible(): boolean;
  2325. render(): boolean;
  2326. dispose(): void;
  2327. }
  2328. }
  2329. declare module BABYLON {
  2330. class DirectionalLight extends Light implements IShadowLight {
  2331. direction: Vector3;
  2332. position: Vector3;
  2333. private _transformedDirection;
  2334. transformedPosition: Vector3;
  2335. private _worldMatrix;
  2336. shadowOrthoScale: number;
  2337. constructor(name: string, direction: Vector3, scene: Scene);
  2338. getAbsolutePosition(): Vector3;
  2339. setDirectionToTarget(target: Vector3): Vector3;
  2340. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2341. supportsVSM(): boolean;
  2342. needRefreshPerFrame(): boolean;
  2343. computeTransformedPosition(): boolean;
  2344. transferToEffect(effect: Effect, directionUniformName: string): void;
  2345. _getWorldMatrix(): Matrix;
  2346. }
  2347. }
  2348. declare module BABYLON {
  2349. class HemisphericLight extends Light {
  2350. direction: Vector3;
  2351. groundColor: Color3;
  2352. private _worldMatrix;
  2353. constructor(name: string, direction: Vector3, scene: Scene);
  2354. setDirectionToTarget(target: Vector3): Vector3;
  2355. getShadowGenerator(): ShadowGenerator;
  2356. transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void;
  2357. _getWorldMatrix(): Matrix;
  2358. }
  2359. }
  2360. declare module BABYLON {
  2361. interface IShadowLight {
  2362. position: Vector3;
  2363. direction: Vector3;
  2364. transformedPosition: Vector3;
  2365. name: string;
  2366. computeTransformedPosition(): boolean;
  2367. getScene(): Scene;
  2368. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2369. supportsVSM(): boolean;
  2370. needRefreshPerFrame(): boolean;
  2371. _shadowGenerator: ShadowGenerator;
  2372. }
  2373. class Light extends Node {
  2374. diffuse: Color3;
  2375. specular: Color3;
  2376. intensity: number;
  2377. range: number;
  2378. includeOnlyWithLayerMask: number;
  2379. includedOnlyMeshes: AbstractMesh[];
  2380. excludedMeshes: AbstractMesh[];
  2381. excludeWithLayerMask: number;
  2382. _shadowGenerator: ShadowGenerator;
  2383. private _parentedWorldMatrix;
  2384. _excludedMeshesIds: string[];
  2385. _includedOnlyMeshesIds: string[];
  2386. constructor(name: string, scene: Scene);
  2387. getShadowGenerator(): ShadowGenerator;
  2388. getAbsolutePosition(): Vector3;
  2389. transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void;
  2390. _getWorldMatrix(): Matrix;
  2391. canAffectMesh(mesh: AbstractMesh): boolean;
  2392. getWorldMatrix(): Matrix;
  2393. dispose(): void;
  2394. }
  2395. }
  2396. declare module BABYLON {
  2397. class PointLight extends Light {
  2398. position: Vector3;
  2399. private _worldMatrix;
  2400. private _transformedPosition;
  2401. constructor(name: string, position: Vector3, scene: Scene);
  2402. getAbsolutePosition(): Vector3;
  2403. transferToEffect(effect: Effect, positionUniformName: string): void;
  2404. getShadowGenerator(): ShadowGenerator;
  2405. _getWorldMatrix(): Matrix;
  2406. }
  2407. }
  2408. declare module BABYLON {
  2409. class SpotLight extends Light implements IShadowLight {
  2410. position: Vector3;
  2411. direction: Vector3;
  2412. angle: number;
  2413. exponent: number;
  2414. transformedPosition: Vector3;
  2415. private _transformedDirection;
  2416. private _worldMatrix;
  2417. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  2418. getAbsolutePosition(): Vector3;
  2419. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2420. supportsVSM(): boolean;
  2421. needRefreshPerFrame(): boolean;
  2422. setDirectionToTarget(target: Vector3): Vector3;
  2423. computeTransformedPosition(): boolean;
  2424. transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void;
  2425. _getWorldMatrix(): Matrix;
  2426. }
  2427. }
  2428. declare module BABYLON {
  2429. class ShadowGenerator {
  2430. private static _FILTER_NONE;
  2431. private static _FILTER_VARIANCESHADOWMAP;
  2432. private static _FILTER_POISSONSAMPLING;
  2433. private static _FILTER_BLURVARIANCESHADOWMAP;
  2434. static FILTER_NONE: number;
  2435. static FILTER_VARIANCESHADOWMAP: number;
  2436. static FILTER_POISSONSAMPLING: number;
  2437. static FILTER_BLURVARIANCESHADOWMAP: number;
  2438. private _filter;
  2439. blurScale: number;
  2440. private _blurBoxOffset;
  2441. private _bias;
  2442. bias: number;
  2443. blurBoxOffset: number;
  2444. filter: number;
  2445. useVarianceShadowMap: boolean;
  2446. usePoissonSampling: boolean;
  2447. useBlurVarianceShadowMap: boolean;
  2448. private _light;
  2449. private _scene;
  2450. private _shadowMap;
  2451. private _shadowMap2;
  2452. private _darkness;
  2453. private _transparencyShadow;
  2454. private _effect;
  2455. private _viewMatrix;
  2456. private _projectionMatrix;
  2457. private _transformMatrix;
  2458. private _worldViewProjection;
  2459. private _cachedPosition;
  2460. private _cachedDirection;
  2461. private _cachedDefines;
  2462. private _currentRenderID;
  2463. private _downSamplePostprocess;
  2464. private _boxBlurPostprocess;
  2465. private _mapSize;
  2466. constructor(mapSize: number, light: IShadowLight);
  2467. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  2468. getShadowMap(): RenderTargetTexture;
  2469. getShadowMapForRendering(): RenderTargetTexture;
  2470. getLight(): IShadowLight;
  2471. getTransformMatrix(): Matrix;
  2472. getDarkness(): number;
  2473. setDarkness(darkness: number): void;
  2474. setTransparencyShadow(hasShadow: boolean): void;
  2475. private _packHalf(depth);
  2476. dispose(): void;
  2477. }
  2478. }
  2479. declare module BABYLON {
  2480. interface ISceneLoaderPlugin {
  2481. extensions: string;
  2482. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
  2483. load: (scene: Scene, data: string, rootUrl: string) => boolean;
  2484. }
  2485. class SceneLoader {
  2486. private static _ForceFullSceneLoadingForIncremental;
  2487. private static _ShowLoadingScreen;
  2488. static ForceFullSceneLoadingForIncremental: boolean;
  2489. static ShowLoadingScreen: boolean;
  2490. private static _registeredPlugins;
  2491. private static _getPluginForFilename(sceneFilename);
  2492. static RegisterPlugin(plugin: ISceneLoaderPlugin): void;
  2493. static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, e: any) => void): void;
  2494. /**
  2495. * Load a scene
  2496. * @param rootUrl a string that defines the root url for scene and resources
  2497. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  2498. * @param engine is the instance of BABYLON.Engine to use to create the scene
  2499. */
  2500. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  2501. /**
  2502. * Append a scene
  2503. * @param rootUrl a string that defines the root url for scene and resources
  2504. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  2505. * @param scene is the instance of BABYLON.Scene to append to
  2506. */
  2507. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  2508. }
  2509. }
  2510. declare module BABYLON.Internals {
  2511. }
  2512. declare module BABYLON {
  2513. class EffectFallbacks {
  2514. private _defines;
  2515. private _currentRank;
  2516. private _maxRank;
  2517. addFallback(rank: number, define: string): void;
  2518. isMoreFallbacks: boolean;
  2519. reduce(currentDefines: string): string;
  2520. }
  2521. class Effect {
  2522. name: any;
  2523. defines: string;
  2524. onCompiled: (effect: Effect) => void;
  2525. onError: (effect: Effect, errors: string) => void;
  2526. onBind: (effect: Effect) => void;
  2527. private _engine;
  2528. private _uniformsNames;
  2529. private _samplers;
  2530. private _isReady;
  2531. private _compilationError;
  2532. private _attributesNames;
  2533. private _attributes;
  2534. private _uniforms;
  2535. _key: string;
  2536. private _program;
  2537. private _valueCache;
  2538. 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);
  2539. isReady(): boolean;
  2540. getProgram(): WebGLProgram;
  2541. getAttributesNames(): string[];
  2542. getAttributeLocation(index: number): number;
  2543. getAttributeLocationByName(name: string): number;
  2544. getAttributesCount(): number;
  2545. getUniformIndex(uniformName: string): number;
  2546. getUniform(uniformName: string): WebGLUniformLocation;
  2547. getSamplers(): string[];
  2548. getCompilationError(): string;
  2549. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  2550. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  2551. private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
  2552. _bindTexture(channel: string, texture: WebGLTexture): void;
  2553. setTexture(channel: string, texture: BaseTexture): void;
  2554. setTextureFromPostProcess(channel: string, postProcess: PostProcess): void;
  2555. _cacheFloat2(uniformName: string, x: number, y: number): void;
  2556. _cacheFloat3(uniformName: string, x: number, y: number, z: number): void;
  2557. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  2558. setArray(uniformName: string, array: number[]): Effect;
  2559. setArray2(uniformName: string, array: number[]): Effect;
  2560. setArray3(uniformName: string, array: number[]): Effect;
  2561. setArray4(uniformName: string, array: number[]): Effect;
  2562. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  2563. setMatrix(uniformName: string, matrix: Matrix): Effect;
  2564. setFloat(uniformName: string, value: number): Effect;
  2565. setBool(uniformName: string, bool: boolean): Effect;
  2566. setVector2(uniformName: string, vector2: Vector2): Effect;
  2567. setFloat2(uniformName: string, x: number, y: number): Effect;
  2568. setVector3(uniformName: string, vector3: Vector3): Effect;
  2569. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  2570. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  2571. setColor3(uniformName: string, color3: Color3): Effect;
  2572. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  2573. static ShadersStore: {};
  2574. }
  2575. }
  2576. declare module BABYLON {
  2577. class Material {
  2578. name: string;
  2579. private static _TriangleFillMode;
  2580. private static _WireFrameFillMode;
  2581. private static _PointFillMode;
  2582. static TriangleFillMode: number;
  2583. static WireFrameFillMode: number;
  2584. static PointFillMode: number;
  2585. id: string;
  2586. checkReadyOnEveryCall: boolean;
  2587. checkReadyOnlyOnce: boolean;
  2588. state: string;
  2589. alpha: number;
  2590. backFaceCulling: boolean;
  2591. onCompiled: (effect: Effect) => void;
  2592. onError: (effect: Effect, errors: string) => void;
  2593. onDispose: () => void;
  2594. onBind: (material: Material, mesh: Mesh) => void;
  2595. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  2596. _effect: Effect;
  2597. _wasPreviouslyReady: boolean;
  2598. private _scene;
  2599. private _fillMode;
  2600. pointSize: number;
  2601. zOffset: number;
  2602. wireframe: boolean;
  2603. pointsCloud: boolean;
  2604. fillMode: number;
  2605. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  2606. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2607. getEffect(): Effect;
  2608. getScene(): Scene;
  2609. needAlphaBlending(): boolean;
  2610. needAlphaTesting(): boolean;
  2611. getAlphaTestTexture(): BaseTexture;
  2612. trackCreation(onCompiled: (effect: Effect) => void, onError: (effect: Effect, errors: string) => void): void;
  2613. _preBind(): void;
  2614. bind(world: Matrix, mesh?: Mesh): void;
  2615. bindOnlyWorldMatrix(world: Matrix): void;
  2616. unbind(): void;
  2617. dispose(forceDisposeEffect?: boolean): void;
  2618. }
  2619. }
  2620. declare module BABYLON {
  2621. class MultiMaterial extends Material {
  2622. subMaterials: Material[];
  2623. constructor(name: string, scene: Scene);
  2624. getSubMaterial(index: any): Material;
  2625. isReady(mesh?: AbstractMesh): boolean;
  2626. clone(name: string): MultiMaterial;
  2627. }
  2628. }
  2629. declare module BABYLON {
  2630. class ShaderMaterial extends Material {
  2631. private _shaderPath;
  2632. private _options;
  2633. private _textures;
  2634. private _floats;
  2635. private _floatsArrays;
  2636. private _colors3;
  2637. private _colors4;
  2638. private _vectors2;
  2639. private _vectors3;
  2640. private _matrices;
  2641. private _cachedWorldViewMatrix;
  2642. private _renderId;
  2643. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  2644. needAlphaBlending(): boolean;
  2645. needAlphaTesting(): boolean;
  2646. private _checkUniform(uniformName);
  2647. setTexture(name: string, texture: Texture): ShaderMaterial;
  2648. setFloat(name: string, value: number): ShaderMaterial;
  2649. setFloats(name: string, value: number[]): ShaderMaterial;
  2650. setColor3(name: string, value: Color3): ShaderMaterial;
  2651. setColor4(name: string, value: Color4): ShaderMaterial;
  2652. setVector2(name: string, value: Vector2): ShaderMaterial;
  2653. setVector3(name: string, value: Vector3): ShaderMaterial;
  2654. setMatrix(name: string, value: Matrix): ShaderMaterial;
  2655. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2656. bindOnlyWorldMatrix(world: Matrix): void;
  2657. bind(world: Matrix, mesh?: Mesh): void;
  2658. dispose(forceDisposeEffect?: boolean): void;
  2659. }
  2660. }
  2661. declare module BABYLON {
  2662. class FresnelParameters {
  2663. isEnabled: boolean;
  2664. leftColor: Color3;
  2665. rightColor: Color3;
  2666. bias: number;
  2667. power: number;
  2668. }
  2669. class StandardMaterial extends Material {
  2670. diffuseTexture: BaseTexture;
  2671. ambientTexture: BaseTexture;
  2672. opacityTexture: BaseTexture;
  2673. reflectionTexture: BaseTexture;
  2674. emissiveTexture: BaseTexture;
  2675. specularTexture: BaseTexture;
  2676. bumpTexture: BaseTexture;
  2677. ambientColor: Color3;
  2678. diffuseColor: Color3;
  2679. specularColor: Color3;
  2680. specularPower: number;
  2681. emissiveColor: Color3;
  2682. useAlphaFromDiffuseTexture: boolean;
  2683. useSpecularOverAlpha: boolean;
  2684. fogEnabled: boolean;
  2685. diffuseFresnelParameters: FresnelParameters;
  2686. opacityFresnelParameters: FresnelParameters;
  2687. reflectionFresnelParameters: FresnelParameters;
  2688. emissiveFresnelParameters: FresnelParameters;
  2689. private _cachedDefines;
  2690. private _renderTargets;
  2691. private _worldViewProjectionMatrix;
  2692. private _globalAmbientColor;
  2693. private _scaledDiffuse;
  2694. private _scaledSpecular;
  2695. private _renderId;
  2696. constructor(name: string, scene: Scene);
  2697. needAlphaBlending(): boolean;
  2698. needAlphaTesting(): boolean;
  2699. private _shouldUseAlphaFromDiffuseTexture();
  2700. getAlphaTestTexture(): BaseTexture;
  2701. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2702. unbind(): void;
  2703. bindOnlyWorldMatrix(world: Matrix): void;
  2704. bind(world: Matrix, mesh?: Mesh): void;
  2705. getAnimatables(): IAnimatable[];
  2706. dispose(forceDisposeEffect?: boolean): void;
  2707. clone(name: string): StandardMaterial;
  2708. static DiffuseTextureEnabled: boolean;
  2709. static AmbientTextureEnabled: boolean;
  2710. static OpacityTextureEnabled: boolean;
  2711. static ReflectionTextureEnabled: boolean;
  2712. static EmissiveTextureEnabled: boolean;
  2713. static SpecularTextureEnabled: boolean;
  2714. static BumpTextureEnabled: boolean;
  2715. static FresnelEnabled: boolean;
  2716. }
  2717. }
  2718. declare module BABYLON {
  2719. class BaseTexture {
  2720. name: string;
  2721. delayLoadState: number;
  2722. hasAlpha: boolean;
  2723. getAlphaFromRGB: boolean;
  2724. level: number;
  2725. isCube: boolean;
  2726. isRenderTarget: boolean;
  2727. animations: Animation[];
  2728. onDispose: () => void;
  2729. coordinatesIndex: number;
  2730. coordinatesMode: number;
  2731. wrapU: number;
  2732. wrapV: number;
  2733. anisotropicFilteringLevel: number;
  2734. _cachedAnisotropicFilteringLevel: number;
  2735. private _scene;
  2736. _texture: WebGLTexture;
  2737. constructor(scene: Scene);
  2738. getScene(): Scene;
  2739. getTextureMatrix(): Matrix;
  2740. getReflectionTextureMatrix(): Matrix;
  2741. getInternalTexture(): WebGLTexture;
  2742. isReady(): boolean;
  2743. getSize(): ISize;
  2744. getBaseSize(): ISize;
  2745. scale(ratio: number): void;
  2746. canRescale: boolean;
  2747. _removeFromCache(url: string, noMipmap: boolean): void;
  2748. _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture;
  2749. delayLoad(): void;
  2750. releaseInternalTexture(): void;
  2751. clone(): BaseTexture;
  2752. dispose(): void;
  2753. }
  2754. }
  2755. declare module BABYLON {
  2756. class CubeTexture extends BaseTexture {
  2757. url: string;
  2758. coordinatesMode: number;
  2759. private _noMipmap;
  2760. private _extensions;
  2761. private _textureMatrix;
  2762. constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean);
  2763. clone(): CubeTexture;
  2764. delayLoad(): void;
  2765. getReflectionTextureMatrix(): Matrix;
  2766. }
  2767. }
  2768. declare module BABYLON {
  2769. class DynamicTexture extends Texture {
  2770. private _generateMipMaps;
  2771. private _canvas;
  2772. private _context;
  2773. constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number);
  2774. canRescale: boolean;
  2775. scale(ratio: number): void;
  2776. getContext(): CanvasRenderingContext2D;
  2777. clear(): void;
  2778. update(invertY?: boolean): void;
  2779. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  2780. clone(): DynamicTexture;
  2781. }
  2782. }
  2783. declare module BABYLON {
  2784. class MirrorTexture extends RenderTargetTexture {
  2785. mirrorPlane: Plane;
  2786. private _transformMatrix;
  2787. private _mirrorMatrix;
  2788. private _savedViewMatrix;
  2789. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  2790. clone(): MirrorTexture;
  2791. }
  2792. }
  2793. declare module BABYLON {
  2794. class RawTexture extends Texture {
  2795. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  2796. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2797. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2798. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2799. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2800. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2801. }
  2802. }
  2803. declare module BABYLON {
  2804. class RenderTargetTexture extends Texture {
  2805. renderList: AbstractMesh[];
  2806. renderParticles: boolean;
  2807. renderSprites: boolean;
  2808. coordinatesMode: number;
  2809. onBeforeRender: () => void;
  2810. onAfterRender: () => void;
  2811. onAfterUnbind: () => void;
  2812. onClear: (engine: Engine) => void;
  2813. activeCamera: Camera;
  2814. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  2815. private _size;
  2816. _generateMipMaps: boolean;
  2817. private _renderingManager;
  2818. _waitingRenderList: string[];
  2819. private _doNotChangeAspectRatio;
  2820. private _currentRefreshId;
  2821. private _refreshRate;
  2822. constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number);
  2823. resetRefreshCounter(): void;
  2824. refreshRate: number;
  2825. _shouldRender(): boolean;
  2826. isReady(): boolean;
  2827. getRenderSize(): number;
  2828. canRescale: boolean;
  2829. scale(ratio: number): void;
  2830. resize(size: any, generateMipMaps?: boolean): void;
  2831. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  2832. clone(): RenderTargetTexture;
  2833. }
  2834. }
  2835. declare module BABYLON {
  2836. class Texture extends BaseTexture {
  2837. static NEAREST_SAMPLINGMODE: number;
  2838. static BILINEAR_SAMPLINGMODE: number;
  2839. static TRILINEAR_SAMPLINGMODE: number;
  2840. static EXPLICIT_MODE: number;
  2841. static SPHERICAL_MODE: number;
  2842. static PLANAR_MODE: number;
  2843. static CUBIC_MODE: number;
  2844. static PROJECTION_MODE: number;
  2845. static SKYBOX_MODE: number;
  2846. static CLAMP_ADDRESSMODE: number;
  2847. static WRAP_ADDRESSMODE: number;
  2848. static MIRROR_ADDRESSMODE: number;
  2849. url: string;
  2850. uOffset: number;
  2851. vOffset: number;
  2852. uScale: number;
  2853. vScale: number;
  2854. uAng: number;
  2855. vAng: number;
  2856. wAng: number;
  2857. private _noMipmap;
  2858. _invertY: boolean;
  2859. private _rowGenerationMatrix;
  2860. private _cachedTextureMatrix;
  2861. private _projectionModeMatrix;
  2862. private _t0;
  2863. private _t1;
  2864. private _t2;
  2865. private _cachedUOffset;
  2866. private _cachedVOffset;
  2867. private _cachedUScale;
  2868. private _cachedVScale;
  2869. private _cachedUAng;
  2870. private _cachedVAng;
  2871. private _cachedWAng;
  2872. private _cachedCoordinatesMode;
  2873. _samplingMode: number;
  2874. private _buffer;
  2875. private _deleteBuffer;
  2876. constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean);
  2877. delayLoad(): void;
  2878. updateSamplingMode(samplingMode: number): void;
  2879. private _prepareRowForTextureGeneration(x, y, z, t);
  2880. getTextureMatrix(): Matrix;
  2881. getReflectionTextureMatrix(): Matrix;
  2882. clone(): Texture;
  2883. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void): Texture;
  2884. }
  2885. }
  2886. declare module BABYLON {
  2887. class VideoTexture extends Texture {
  2888. video: HTMLVideoElement;
  2889. private _autoLaunch;
  2890. private _lastUpdate;
  2891. constructor(name: string, urls: string[], scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  2892. update(): boolean;
  2893. }
  2894. }
  2895. declare module BABYLON {
  2896. class CustomProceduralTexture extends ProceduralTexture {
  2897. private _animate;
  2898. private _time;
  2899. private _config;
  2900. private _texturePath;
  2901. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2902. private loadJson(jsonUrl);
  2903. isReady(): boolean;
  2904. render(useCameraPostProcess?: boolean): void;
  2905. updateTextures(): void;
  2906. updateShaderUniforms(): void;
  2907. animate: boolean;
  2908. }
  2909. }
  2910. declare module BABYLON {
  2911. class ProceduralTexture extends Texture {
  2912. private _size;
  2913. _generateMipMaps: boolean;
  2914. private _doNotChangeAspectRatio;
  2915. private _currentRefreshId;
  2916. private _refreshRate;
  2917. private _vertexBuffer;
  2918. private _indexBuffer;
  2919. private _effect;
  2920. private _vertexDeclaration;
  2921. private _vertexStrideSize;
  2922. private _uniforms;
  2923. private _samplers;
  2924. private _fragment;
  2925. _textures: Texture[];
  2926. private _floats;
  2927. private _floatsArrays;
  2928. private _colors3;
  2929. private _colors4;
  2930. private _vectors2;
  2931. private _vectors3;
  2932. private _matrices;
  2933. private _fallbackTexture;
  2934. private _fallbackTextureUsed;
  2935. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2936. reset(): void;
  2937. isReady(): boolean;
  2938. resetRefreshCounter(): void;
  2939. setFragment(fragment: any): void;
  2940. refreshRate: number;
  2941. _shouldRender(): boolean;
  2942. getRenderSize(): number;
  2943. resize(size: any, generateMipMaps: any): void;
  2944. private _checkUniform(uniformName);
  2945. setTexture(name: string, texture: Texture): ProceduralTexture;
  2946. setFloat(name: string, value: number): ProceduralTexture;
  2947. setFloats(name: string, value: number[]): ProceduralTexture;
  2948. setColor3(name: string, value: Color3): ProceduralTexture;
  2949. setColor4(name: string, value: Color4): ProceduralTexture;
  2950. setVector2(name: string, value: Vector2): ProceduralTexture;
  2951. setVector3(name: string, value: Vector3): ProceduralTexture;
  2952. setMatrix(name: string, value: Matrix): ProceduralTexture;
  2953. render(useCameraPostProcess?: boolean): void;
  2954. clone(): ProceduralTexture;
  2955. dispose(): void;
  2956. }
  2957. }
  2958. declare module BABYLON {
  2959. class WoodProceduralTexture extends ProceduralTexture {
  2960. private _ampScale;
  2961. private _woodColor;
  2962. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2963. updateShaderUniforms(): void;
  2964. ampScale: number;
  2965. woodColor: Color3;
  2966. }
  2967. class FireProceduralTexture extends ProceduralTexture {
  2968. private _time;
  2969. private _speed;
  2970. private _autoGenerateTime;
  2971. private _fireColors;
  2972. private _alphaThreshold;
  2973. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2974. updateShaderUniforms(): void;
  2975. render(useCameraPostProcess?: boolean): void;
  2976. static PurpleFireColors: Color3[];
  2977. static GreenFireColors: Color3[];
  2978. static RedFireColors: Color3[];
  2979. static BlueFireColors: Color3[];
  2980. fireColors: Color3[];
  2981. time: number;
  2982. speed: Vector2;
  2983. alphaThreshold: number;
  2984. }
  2985. class CloudProceduralTexture extends ProceduralTexture {
  2986. private _skyColor;
  2987. private _cloudColor;
  2988. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2989. updateShaderUniforms(): void;
  2990. skyColor: Color3;
  2991. cloudColor: Color3;
  2992. }
  2993. class GrassProceduralTexture extends ProceduralTexture {
  2994. private _grassColors;
  2995. private _herb1;
  2996. private _herb2;
  2997. private _herb3;
  2998. private _groundColor;
  2999. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3000. updateShaderUniforms(): void;
  3001. grassColors: Color3[];
  3002. groundColor: Color3;
  3003. }
  3004. class RoadProceduralTexture extends ProceduralTexture {
  3005. private _roadColor;
  3006. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3007. updateShaderUniforms(): void;
  3008. roadColor: Color3;
  3009. }
  3010. class BrickProceduralTexture extends ProceduralTexture {
  3011. private _numberOfBricksHeight;
  3012. private _numberOfBricksWidth;
  3013. private _jointColor;
  3014. private _brickColor;
  3015. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3016. updateShaderUniforms(): void;
  3017. numberOfBricksHeight: number;
  3018. numberOfBricksWidth: number;
  3019. jointColor: Color3;
  3020. brickColor: Color3;
  3021. }
  3022. class MarbleProceduralTexture extends ProceduralTexture {
  3023. private _numberOfTilesHeight;
  3024. private _numberOfTilesWidth;
  3025. private _amplitude;
  3026. private _marbleColor;
  3027. private _jointColor;
  3028. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3029. updateShaderUniforms(): void;
  3030. numberOfTilesHeight: number;
  3031. numberOfTilesWidth: number;
  3032. jointColor: Color3;
  3033. marbleColor: Color3;
  3034. }
  3035. }
  3036. declare module BABYLON {
  3037. class Color3 {
  3038. r: number;
  3039. g: number;
  3040. b: number;
  3041. constructor(r?: number, g?: number, b?: number);
  3042. toString(): string;
  3043. toArray(array: number[], index?: number): Color3;
  3044. toColor4(alpha?: number): Color4;
  3045. asArray(): number[];
  3046. toLuminance(): number;
  3047. multiply(otherColor: Color3): Color3;
  3048. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  3049. equals(otherColor: Color3): boolean;
  3050. scale(scale: number): Color3;
  3051. scaleToRef(scale: number, result: Color3): Color3;
  3052. add(otherColor: Color3): Color3;
  3053. addToRef(otherColor: Color3, result: Color3): Color3;
  3054. subtract(otherColor: Color3): Color3;
  3055. subtractToRef(otherColor: Color3, result: Color3): Color3;
  3056. clone(): Color3;
  3057. copyFrom(source: Color3): Color3;
  3058. copyFromFloats(r: number, g: number, b: number): Color3;
  3059. static FromArray(array: number[], offset?: number): Color3;
  3060. static FromInts(r: number, g: number, b: number): Color3;
  3061. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  3062. static Red(): Color3;
  3063. static Green(): Color3;
  3064. static Blue(): Color3;
  3065. static Black(): Color3;
  3066. static White(): Color3;
  3067. static Purple(): Color3;
  3068. static Magenta(): Color3;
  3069. static Yellow(): Color3;
  3070. static Gray(): Color3;
  3071. }
  3072. class Color4 {
  3073. r: number;
  3074. g: number;
  3075. b: number;
  3076. a: number;
  3077. constructor(r: number, g: number, b: number, a: number);
  3078. addInPlace(right: any): Color4;
  3079. asArray(): number[];
  3080. toArray(array: number[], index?: number): Color4;
  3081. add(right: Color4): Color4;
  3082. subtract(right: Color4): Color4;
  3083. subtractToRef(right: Color4, result: Color4): Color4;
  3084. scale(scale: number): Color4;
  3085. scaleToRef(scale: number, result: Color4): Color4;
  3086. toString(): string;
  3087. clone(): Color4;
  3088. copyFrom(source: Color4): Color4;
  3089. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  3090. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  3091. static FromArray(array: number[], offset?: number): Color4;
  3092. static FromInts(r: number, g: number, b: number, a: number): Color4;
  3093. }
  3094. class Vector2 {
  3095. x: number;
  3096. y: number;
  3097. constructor(x: number, y: number);
  3098. toString(): string;
  3099. toArray(array: number[], index?: number): Vector2;
  3100. asArray(): number[];
  3101. copyFrom(source: Vector2): Vector2;
  3102. copyFromFloats(x: number, y: number): Vector2;
  3103. add(otherVector: Vector2): Vector2;
  3104. addVector3(otherVector: Vector3): Vector2;
  3105. subtract(otherVector: Vector2): Vector2;
  3106. subtractInPlace(otherVector: Vector2): Vector2;
  3107. multiplyInPlace(otherVector: Vector2): Vector2;
  3108. multiply(otherVector: Vector2): Vector2;
  3109. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  3110. multiplyByFloats(x: number, y: number): Vector2;
  3111. divide(otherVector: Vector2): Vector2;
  3112. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  3113. negate(): Vector2;
  3114. scaleInPlace(scale: number): Vector2;
  3115. scale(scale: number): Vector2;
  3116. equals(otherVector: Vector2): boolean;
  3117. equalsWithEpsilon(otherVector: Vector2): boolean;
  3118. length(): number;
  3119. lengthSquared(): number;
  3120. normalize(): Vector2;
  3121. clone(): Vector2;
  3122. static Zero(): Vector2;
  3123. static FromArray(array: number[], offset?: number): Vector2;
  3124. static FromArrayToRef(array: number[], offset: number, result: Vector2): void;
  3125. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  3126. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  3127. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  3128. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  3129. static Dot(left: Vector2, right: Vector2): number;
  3130. static Normalize(vector: Vector2): Vector2;
  3131. static Minimize(left: Vector2, right: Vector2): Vector2;
  3132. static Maximize(left: Vector2, right: Vector2): Vector2;
  3133. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  3134. static Distance(value1: Vector2, value2: Vector2): number;
  3135. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  3136. }
  3137. class Vector3 {
  3138. x: number;
  3139. y: number;
  3140. z: number;
  3141. constructor(x: number, y: number, z: number);
  3142. toString(): string;
  3143. asArray(): number[];
  3144. toArray(array: number[], index?: number): Vector3;
  3145. toQuaternion(): Quaternion;
  3146. addInPlace(otherVector: Vector3): Vector3;
  3147. add(otherVector: Vector3): Vector3;
  3148. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  3149. subtractInPlace(otherVector: Vector3): Vector3;
  3150. subtract(otherVector: Vector3): Vector3;
  3151. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  3152. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3153. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3154. negate(): Vector3;
  3155. scaleInPlace(scale: number): Vector3;
  3156. scale(scale: number): Vector3;
  3157. scaleToRef(scale: number, result: Vector3): void;
  3158. equals(otherVector: Vector3): boolean;
  3159. equalsWithEpsilon(otherVector: Vector3): boolean;
  3160. equalsToFloats(x: number, y: number, z: number): boolean;
  3161. multiplyInPlace(otherVector: Vector3): Vector3;
  3162. multiply(otherVector: Vector3): Vector3;
  3163. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  3164. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3165. divide(otherVector: Vector3): Vector3;
  3166. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  3167. MinimizeInPlace(other: Vector3): Vector3;
  3168. MaximizeInPlace(other: Vector3): Vector3;
  3169. length(): number;
  3170. lengthSquared(): number;
  3171. normalize(): Vector3;
  3172. clone(): Vector3;
  3173. copyFrom(source: Vector3): Vector3;
  3174. copyFromFloats(x: number, y: number, z: number): Vector3;
  3175. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number;
  3176. static FromArray(array: number[], offset?: number): Vector3;
  3177. static FromArrayToRef(array: number[], offset: number, result: Vector3): void;
  3178. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  3179. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3180. static Zero(): Vector3;
  3181. static Up(): Vector3;
  3182. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  3183. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3184. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3185. static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3186. static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3187. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  3188. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3189. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3190. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  3191. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  3192. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  3193. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  3194. static Dot(left: Vector3, right: Vector3): number;
  3195. static Cross(left: Vector3, right: Vector3): Vector3;
  3196. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3197. static Normalize(vector: Vector3): Vector3;
  3198. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  3199. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  3200. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  3201. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  3202. static Minimize(left: Vector3, right: Vector3): Vector3;
  3203. static Maximize(left: Vector3, right: Vector3): Vector3;
  3204. static Distance(value1: Vector3, value2: Vector3): number;
  3205. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  3206. static Center(value1: Vector3, value2: Vector3): Vector3;
  3207. /**
  3208. * Given three orthogonal left-handed oriented Vector3 axis in space (target system),
  3209. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3210. * to something in order to rotate it from its local system to the given target system.
  3211. */
  3212. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  3213. }
  3214. class Vector4 {
  3215. x: number;
  3216. y: number;
  3217. z: number;
  3218. w: number;
  3219. constructor(x: number, y: number, z: number, w: number);
  3220. toString(): string;
  3221. asArray(): number[];
  3222. toArray(array: number[], index?: number): Vector4;
  3223. addInPlace(otherVector: Vector4): Vector4;
  3224. add(otherVector: Vector4): Vector4;
  3225. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  3226. subtractInPlace(otherVector: Vector4): Vector4;
  3227. subtract(otherVector: Vector4): Vector4;
  3228. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  3229. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3230. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3231. negate(): Vector4;
  3232. scaleInPlace(scale: number): Vector4;
  3233. scale(scale: number): Vector4;
  3234. scaleToRef(scale: number, result: Vector4): void;
  3235. equals(otherVector: Vector4): boolean;
  3236. equalsWithEpsilon(otherVector: Vector4): boolean;
  3237. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3238. multiplyInPlace(otherVector: Vector4): Vector4;
  3239. multiply(otherVector: Vector4): Vector4;
  3240. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  3241. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3242. divide(otherVector: Vector4): Vector4;
  3243. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  3244. MinimizeInPlace(other: Vector4): Vector4;
  3245. MaximizeInPlace(other: Vector4): Vector4;
  3246. length(): number;
  3247. lengthSquared(): number;
  3248. normalize(): Vector4;
  3249. clone(): Vector4;
  3250. copyFrom(source: Vector4): Vector4;
  3251. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3252. static FromArray(array: number[], offset?: number): Vector4;
  3253. static FromArrayToRef(array: number[], offset: number, result: Vector4): void;
  3254. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  3255. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3256. static Zero(): Vector4;
  3257. static Normalize(vector: Vector4): Vector4;
  3258. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  3259. static Minimize(left: Vector4, right: Vector4): Vector4;
  3260. static Maximize(left: Vector4, right: Vector4): Vector4;
  3261. static Distance(value1: Vector4, value2: Vector4): number;
  3262. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  3263. static Center(value1: Vector4, value2: Vector4): Vector4;
  3264. }
  3265. class Quaternion {
  3266. x: number;
  3267. y: number;
  3268. z: number;
  3269. w: number;
  3270. constructor(x?: number, y?: number, z?: number, w?: number);
  3271. toString(): string;
  3272. asArray(): number[];
  3273. equals(otherQuaternion: Quaternion): boolean;
  3274. clone(): Quaternion;
  3275. copyFrom(other: Quaternion): Quaternion;
  3276. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3277. add(other: Quaternion): Quaternion;
  3278. subtract(other: Quaternion): Quaternion;
  3279. scale(value: number): Quaternion;
  3280. multiply(q1: Quaternion): Quaternion;
  3281. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  3282. length(): number;
  3283. normalize(): Quaternion;
  3284. toEulerAngles(): Vector3;
  3285. toEulerAnglesToRef(result: Vector3): Quaternion;
  3286. toRotationMatrix(result: Matrix): Quaternion;
  3287. fromRotationMatrix(matrix: Matrix): Quaternion;
  3288. static FromRotationMatrix(matrix: Matrix): Quaternion;
  3289. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  3290. static Inverse(q: Quaternion): Quaternion;
  3291. static Identity(): Quaternion;
  3292. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  3293. static FromArray(array: number[], offset?: number): Quaternion;
  3294. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3295. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3296. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3297. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3298. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  3299. }
  3300. class Matrix {
  3301. private static _tempQuaternion;
  3302. private static _xAxis;
  3303. private static _yAxis;
  3304. private static _zAxis;
  3305. m: Float32Array;
  3306. isIdentity(): boolean;
  3307. determinant(): number;
  3308. toArray(): Float32Array;
  3309. asArray(): Float32Array;
  3310. invert(): Matrix;
  3311. invertToRef(other: Matrix): Matrix;
  3312. invertToRefSIMD(other: Matrix): Matrix;
  3313. setTranslation(vector3: Vector3): Matrix;
  3314. multiply(other: Matrix): Matrix;
  3315. copyFrom(other: Matrix): Matrix;
  3316. copyToArray(array: Float32Array, offset?: number): Matrix;
  3317. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  3318. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  3319. multiplyToArraySIMD(other: Matrix, result: Matrix, offset?: number): void;
  3320. equals(value: Matrix): boolean;
  3321. clone(): Matrix;
  3322. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  3323. static FromArray(array: number[], offset?: number): Matrix;
  3324. static FromArrayToRef(array: number[], offset: number, result: Matrix): void;
  3325. 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;
  3326. 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;
  3327. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  3328. static Identity(): Matrix;
  3329. static IdentityToRef(result: Matrix): void;
  3330. static Zero(): Matrix;
  3331. static RotationX(angle: number): Matrix;
  3332. static Invert(source: Matrix): Matrix;
  3333. static RotationXToRef(angle: number, result: Matrix): void;
  3334. static RotationY(angle: number): Matrix;
  3335. static RotationYToRef(angle: number, result: Matrix): void;
  3336. static RotationZ(angle: number): Matrix;
  3337. static RotationZToRef(angle: number, result: Matrix): void;
  3338. static RotationAxis(axis: Vector3, angle: number): Matrix;
  3339. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3340. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3341. static Scaling(x: number, y: number, z: number): Matrix;
  3342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3343. static Translation(x: number, y: number, z: number): Matrix;
  3344. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3345. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  3346. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  3347. static LookAtLHToRefSIMD(eyeRef: Vector3, targetRef: Vector3, upRef: Vector3, result: Matrix): void;
  3348. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3349. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3350. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3351. static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3352. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3353. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3354. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, fovMode?: number): void;
  3355. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  3356. static Transpose(matrix: Matrix): Matrix;
  3357. static Reflection(plane: Plane): Matrix;
  3358. static ReflectionToRef(plane: Plane, result: Matrix): void;
  3359. }
  3360. class Plane {
  3361. normal: Vector3;
  3362. d: number;
  3363. constructor(a: number, b: number, c: number, d: number);
  3364. asArray(): number[];
  3365. clone(): Plane;
  3366. normalize(): Plane;
  3367. transform(transformation: Matrix): Plane;
  3368. dotCoordinate(point: any): number;
  3369. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  3370. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  3371. signedDistanceTo(point: Vector3): number;
  3372. static FromArray(array: number[]): Plane;
  3373. static FromPoints(point1: any, point2: any, point3: any): Plane;
  3374. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  3375. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  3376. }
  3377. class Viewport {
  3378. x: number;
  3379. y: number;
  3380. width: number;
  3381. height: number;
  3382. constructor(x: number, y: number, width: number, height: number);
  3383. toGlobal(engine: any): Viewport;
  3384. }
  3385. class Frustum {
  3386. static GetPlanes(transform: Matrix): Plane[];
  3387. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  3388. }
  3389. class Ray {
  3390. origin: Vector3;
  3391. direction: Vector3;
  3392. length: number;
  3393. private _edge1;
  3394. private _edge2;
  3395. private _pvec;
  3396. private _tvec;
  3397. private _qvec;
  3398. constructor(origin: Vector3, direction: Vector3, length?: number);
  3399. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3400. intersectsBox(box: BoundingBox): boolean;
  3401. intersectsSphere(sphere: any): boolean;
  3402. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo;
  3403. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3404. /**
  3405. * 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
  3406. * transformed to the given world matrix.
  3407. * @param origin The origin point
  3408. * @param end The end point
  3409. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3410. */
  3411. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3412. static Transform(ray: Ray, matrix: Matrix): Ray;
  3413. }
  3414. enum Space {
  3415. LOCAL = 0,
  3416. WORLD = 1,
  3417. }
  3418. class Axis {
  3419. static X: Vector3;
  3420. static Y: Vector3;
  3421. static Z: Vector3;
  3422. }
  3423. class BezierCurve {
  3424. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3425. }
  3426. enum Orientation {
  3427. CW = 0,
  3428. CCW = 1,
  3429. }
  3430. class Angle {
  3431. private _radians;
  3432. constructor(radians: number);
  3433. degrees: () => number;
  3434. radians: () => number;
  3435. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  3436. static FromRadians(radians: number): Angle;
  3437. static FromDegrees(degrees: number): Angle;
  3438. }
  3439. class Arc2 {
  3440. startPoint: Vector2;
  3441. midPoint: Vector2;
  3442. endPoint: Vector2;
  3443. centerPoint: Vector2;
  3444. radius: number;
  3445. angle: Angle;
  3446. startAngle: Angle;
  3447. orientation: Orientation;
  3448. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  3449. }
  3450. class PathCursor {
  3451. private path;
  3452. private _onchange;
  3453. value: number;
  3454. animations: Animation[];
  3455. constructor(path: Path2);
  3456. getPoint(): Vector3;
  3457. moveAhead(step?: number): PathCursor;
  3458. moveBack(step?: number): PathCursor;
  3459. move(step: number): PathCursor;
  3460. private ensureLimits();
  3461. private markAsDirty(propertyName);
  3462. private raiseOnChange();
  3463. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3464. }
  3465. class Path2 {
  3466. private _points;
  3467. private _length;
  3468. closed: boolean;
  3469. constructor(x: number, y: number);
  3470. addLineTo(x: number, y: number): Path2;
  3471. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3472. close(): Path2;
  3473. length(): number;
  3474. getPoints(): Vector2[];
  3475. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3476. static StartingAt(x: number, y: number): Path2;
  3477. }
  3478. class Path3D {
  3479. path: Vector3[];
  3480. private _curve;
  3481. private _distances;
  3482. private _tangents;
  3483. private _normals;
  3484. private _binormals;
  3485. constructor(path: Vector3[], firstNormal?: Vector3);
  3486. getCurve(): Vector3[];
  3487. getTangents(): Vector3[];
  3488. getNormals(): Vector3[];
  3489. getBinormals(): Vector3[];
  3490. getDistances(): number[];
  3491. update(path: Vector3[], firstNormal?: Vector3): Path3D;
  3492. private _compute(firstNormal);
  3493. private _getFirstNonNullVector(index);
  3494. private _getLastNonNullVector(index);
  3495. private _normalVector(v0, vt, va);
  3496. }
  3497. class Curve3 {
  3498. private _points;
  3499. private _length;
  3500. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  3501. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  3502. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  3503. constructor(points: Vector3[]);
  3504. getPoints(): Vector3[];
  3505. length(): number;
  3506. continue(curve: Curve3): Curve3;
  3507. private _computeLength(path);
  3508. }
  3509. class PositionNormalVertex {
  3510. position: Vector3;
  3511. normal: Vector3;
  3512. constructor(position?: Vector3, normal?: Vector3);
  3513. clone(): PositionNormalVertex;
  3514. }
  3515. class PositionNormalTextureVertex {
  3516. position: Vector3;
  3517. normal: Vector3;
  3518. uv: Vector2;
  3519. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  3520. clone(): PositionNormalTextureVertex;
  3521. }
  3522. class SIMDHelper {
  3523. private static _isEnabled;
  3524. static IsEnabled: boolean;
  3525. static DisableSIMD(): void;
  3526. static EnableSIMD(): void;
  3527. }
  3528. }
  3529. declare module BABYLON {
  3530. class AbstractMesh extends Node implements IDisposable {
  3531. private static _BILLBOARDMODE_NONE;
  3532. private static _BILLBOARDMODE_X;
  3533. private static _BILLBOARDMODE_Y;
  3534. private static _BILLBOARDMODE_Z;
  3535. private static _BILLBOARDMODE_ALL;
  3536. static BILLBOARDMODE_NONE: number;
  3537. static BILLBOARDMODE_X: number;
  3538. static BILLBOARDMODE_Y: number;
  3539. static BILLBOARDMODE_Z: number;
  3540. static BILLBOARDMODE_ALL: number;
  3541. definedFacingForward: boolean;
  3542. position: Vector3;
  3543. rotation: Vector3;
  3544. rotationQuaternion: Quaternion;
  3545. scaling: Vector3;
  3546. billboardMode: number;
  3547. visibility: number;
  3548. alphaIndex: number;
  3549. infiniteDistance: boolean;
  3550. isVisible: boolean;
  3551. isPickable: boolean;
  3552. showBoundingBox: boolean;
  3553. showSubMeshesBoundingBox: boolean;
  3554. onDispose: any;
  3555. isBlocker: boolean;
  3556. skeleton: Skeleton;
  3557. renderingGroupId: number;
  3558. material: Material;
  3559. receiveShadows: boolean;
  3560. actionManager: ActionManager;
  3561. renderOutline: boolean;
  3562. outlineColor: Color3;
  3563. outlineWidth: number;
  3564. renderOverlay: boolean;
  3565. overlayColor: Color3;
  3566. overlayAlpha: number;
  3567. hasVertexAlpha: boolean;
  3568. useVertexColors: boolean;
  3569. applyFog: boolean;
  3570. useOctreeForRenderingSelection: boolean;
  3571. useOctreeForPicking: boolean;
  3572. useOctreeForCollisions: boolean;
  3573. layerMask: number;
  3574. alwaysSelectAsActiveMesh: boolean;
  3575. _physicImpostor: number;
  3576. _physicsMass: number;
  3577. _physicsFriction: number;
  3578. _physicRestitution: number;
  3579. private _checkCollisions;
  3580. ellipsoid: Vector3;
  3581. ellipsoidOffset: Vector3;
  3582. private _collider;
  3583. private _oldPositionForCollisions;
  3584. private _diffPositionForCollisions;
  3585. private _newPositionForCollisions;
  3586. private _localScaling;
  3587. private _localRotation;
  3588. private _localTranslation;
  3589. private _localBillboard;
  3590. private _localPivotScaling;
  3591. private _localPivotScalingRotation;
  3592. private _localWorld;
  3593. _worldMatrix: Matrix;
  3594. private _rotateYByPI;
  3595. private _absolutePosition;
  3596. private _collisionsTransformMatrix;
  3597. private _collisionsScalingMatrix;
  3598. _positions: Vector3[];
  3599. private _isDirty;
  3600. _masterMesh: AbstractMesh;
  3601. _boundingInfo: BoundingInfo;
  3602. private _pivotMatrix;
  3603. _isDisposed: boolean;
  3604. _renderId: number;
  3605. subMeshes: SubMesh[];
  3606. _submeshesOctree: Octree<SubMesh>;
  3607. _intersectionsInProgress: AbstractMesh[];
  3608. private _onAfterWorldMatrixUpdate;
  3609. private _isWorldMatrixFrozen;
  3610. _waitingActions: any;
  3611. constructor(name: string, scene: Scene);
  3612. isBlocked: boolean;
  3613. getLOD(camera: Camera): AbstractMesh;
  3614. getTotalVertices(): number;
  3615. getIndices(): number[];
  3616. getVerticesData(kind: string): number[];
  3617. isVerticesDataPresent(kind: string): boolean;
  3618. getBoundingInfo(): BoundingInfo;
  3619. useBones: boolean;
  3620. _preActivate(): void;
  3621. _activate(renderId: number): void;
  3622. getWorldMatrix(): Matrix;
  3623. worldMatrixFromCache: Matrix;
  3624. absolutePosition: Vector3;
  3625. freezeWorldMatrix(): void;
  3626. unfreezeWorldMatrix(): void;
  3627. isWorldMatrixFrozen: boolean;
  3628. rotate(axis: Vector3, amount: number, space: Space): void;
  3629. translate(axis: Vector3, distance: number, space: Space): void;
  3630. getAbsolutePosition(): Vector3;
  3631. setAbsolutePosition(absolutePosition: Vector3): void;
  3632. /**
  3633. * Perform relative position change from the point of view of behind the front of the mesh.
  3634. * This is performed taking into account the meshes current rotation, so you do not have to care.
  3635. * Supports definition of mesh facing forward or backward.
  3636. * @param {number} amountRight
  3637. * @param {number} amountUp
  3638. * @param {number} amountForward
  3639. */
  3640. movePOV(amountRight: number, amountUp: number, amountForward: number): void;
  3641. /**
  3642. * Calculate relative position change from the point of view of behind the front of the mesh.
  3643. * This is performed taking into account the meshes current rotation, so you do not have to care.
  3644. * Supports definition of mesh facing forward or backward.
  3645. * @param {number} amountRight
  3646. * @param {number} amountUp
  3647. * @param {number} amountForward
  3648. */
  3649. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  3650. /**
  3651. * Perform relative rotation change from the point of view of behind the front of the mesh.
  3652. * Supports definition of mesh facing forward or backward.
  3653. * @param {number} flipBack
  3654. * @param {number} twirlClockwise
  3655. * @param {number} tiltRight
  3656. */
  3657. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void;
  3658. /**
  3659. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  3660. * Supports definition of mesh facing forward or backward.
  3661. * @param {number} flipBack
  3662. * @param {number} twirlClockwise
  3663. * @param {number} tiltRight
  3664. */
  3665. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  3666. setPivotMatrix(matrix: Matrix): void;
  3667. getPivotMatrix(): Matrix;
  3668. _isSynchronized(): boolean;
  3669. _initCache(): void;
  3670. markAsDirty(property: string): void;
  3671. _updateBoundingInfo(): void;
  3672. _updateSubMeshesBoundingInfo(matrix: Matrix): void;
  3673. computeWorldMatrix(force?: boolean): Matrix;
  3674. /**
  3675. * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated
  3676. * @param func: callback function to add
  3677. */
  3678. registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  3679. unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  3680. setPositionWithLocalVector(vector3: Vector3): void;
  3681. getPositionExpressedInLocalSpace(): Vector3;
  3682. locallyTranslate(vector3: Vector3): void;
  3683. lookAt(targetPoint: Vector3, yawCor: number, pitchCor: number, rollCor: number): void;
  3684. isInFrustum(frustumPlanes: Plane[]): boolean;
  3685. isCompletelyInFrustum(camera?: Camera): boolean;
  3686. intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean;
  3687. intersectsPoint(point: Vector3): boolean;
  3688. setPhysicsState(impostor?: any, options?: PhysicsBodyCreationOptions): any;
  3689. getPhysicsImpostor(): number;
  3690. getPhysicsMass(): number;
  3691. getPhysicsFriction(): number;
  3692. getPhysicsRestitution(): number;
  3693. getPositionInCameraSpace(camera?: Camera): Vector3;
  3694. getDistanceToCamera(camera?: Camera): number;
  3695. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  3696. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void;
  3697. updatePhysicsBodyPosition(): void;
  3698. checkCollisions: boolean;
  3699. moveWithCollisions(velocity: Vector3): void;
  3700. private _onCollisionPositionChange;
  3701. /**
  3702. * This function will create an octree to help select the right submeshes for rendering, picking and collisions
  3703. * Please note that you must have a decent number of submeshes to get performance improvements when using octree
  3704. */
  3705. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  3706. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void;
  3707. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void;
  3708. _checkCollision(collider: Collider): void;
  3709. _generatePointsArray(): boolean;
  3710. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  3711. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh;
  3712. releaseSubMeshes(): void;
  3713. dispose(doNotRecurse?: boolean): void;
  3714. }
  3715. }
  3716. declare module BABYLON {
  3717. class CSG {
  3718. private polygons;
  3719. matrix: Matrix;
  3720. position: Vector3;
  3721. rotation: Vector3;
  3722. rotationQuaternion: Quaternion;
  3723. scaling: Vector3;
  3724. static FromMesh(mesh: Mesh): CSG;
  3725. private static FromPolygons(polygons);
  3726. clone(): CSG;
  3727. private toPolygons();
  3728. union(csg: CSG): CSG;
  3729. unionInPlace(csg: CSG): void;
  3730. subtract(csg: CSG): CSG;
  3731. subtractInPlace(csg: CSG): void;
  3732. intersect(csg: CSG): CSG;
  3733. intersectInPlace(csg: CSG): void;
  3734. inverse(): CSG;
  3735. inverseInPlace(): void;
  3736. copyTransformAttributes(csg: CSG): CSG;
  3737. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  3738. toMesh(name: string, material: Material, scene: Scene, keepSubMeshes: boolean): Mesh;
  3739. }
  3740. }
  3741. declare module BABYLON {
  3742. class Geometry implements IGetSetVerticesData {
  3743. id: string;
  3744. delayLoadState: number;
  3745. delayLoadingFile: string;
  3746. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  3747. private _scene;
  3748. private _engine;
  3749. private _meshes;
  3750. private _totalVertices;
  3751. private _indices;
  3752. private _vertexBuffers;
  3753. private _isDisposed;
  3754. _delayInfo: any;
  3755. private _indexBuffer;
  3756. _boundingInfo: BoundingInfo;
  3757. _delayLoadingFunction: (any: any, geometry: Geometry) => void;
  3758. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Mesh);
  3759. getScene(): Scene;
  3760. getEngine(): Engine;
  3761. isReady(): boolean;
  3762. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  3763. setVerticesData(kind: string, data: number[], updatable?: boolean, stride?: number): void;
  3764. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  3765. updateVerticesData(kind: string, data: number[], updateExtends?: boolean): void;
  3766. getTotalVertices(): number;
  3767. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  3768. getVertexBuffer(kind: string): VertexBuffer;
  3769. getVertexBuffers(): VertexBuffer[];
  3770. isVerticesDataPresent(kind: string): boolean;
  3771. getVerticesDataKinds(): string[];
  3772. setIndices(indices: number[], totalVertices?: number): void;
  3773. getTotalIndices(): number;
  3774. getIndices(copyWhenShared?: boolean): number[];
  3775. getIndexBuffer(): any;
  3776. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  3777. applyToMesh(mesh: Mesh): void;
  3778. private _applyToMesh(mesh);
  3779. private notifyUpdate(kind?);
  3780. load(scene: Scene, onLoaded?: () => void): void;
  3781. isDisposed(): boolean;
  3782. dispose(): void;
  3783. copy(id: string): Geometry;
  3784. static ExtractFromMesh(mesh: Mesh, id: string): Geometry;
  3785. static RandomId(): string;
  3786. }
  3787. module Geometry.Primitives {
  3788. class _Primitive extends Geometry {
  3789. private _beingRegenerated;
  3790. private _canBeRegenerated;
  3791. constructor(id: string, scene: Scene, vertexData?: VertexData, canBeRegenerated?: boolean, mesh?: Mesh);
  3792. canBeRegenerated(): boolean;
  3793. regenerate(): void;
  3794. asNewGeometry(id: string): Geometry;
  3795. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  3796. setVerticesData(kind: string, data: number[], updatable?: boolean): void;
  3797. _regenerateVertexData(): VertexData;
  3798. copy(id: string): Geometry;
  3799. }
  3800. class Ribbon extends _Primitive {
  3801. pathArray: Vector3[][];
  3802. closeArray: boolean;
  3803. closePath: boolean;
  3804. offset: number;
  3805. side: number;
  3806. constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3807. _regenerateVertexData(): VertexData;
  3808. copy(id: string): Geometry;
  3809. }
  3810. class Box extends _Primitive {
  3811. size: number;
  3812. side: number;
  3813. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3814. _regenerateVertexData(): VertexData;
  3815. copy(id: string): Geometry;
  3816. }
  3817. class Sphere extends _Primitive {
  3818. segments: number;
  3819. diameter: number;
  3820. side: number;
  3821. constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3822. _regenerateVertexData(): VertexData;
  3823. copy(id: string): Geometry;
  3824. }
  3825. class Cylinder extends _Primitive {
  3826. height: number;
  3827. diameterTop: number;
  3828. diameterBottom: number;
  3829. tessellation: number;
  3830. subdivisions: number;
  3831. side: number;
  3832. constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3833. _regenerateVertexData(): VertexData;
  3834. copy(id: string): Geometry;
  3835. }
  3836. class Torus extends _Primitive {
  3837. diameter: number;
  3838. thickness: number;
  3839. tessellation: number;
  3840. side: number;
  3841. constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3842. _regenerateVertexData(): VertexData;
  3843. copy(id: string): Geometry;
  3844. }
  3845. class Ground extends _Primitive {
  3846. width: number;
  3847. height: number;
  3848. subdivisions: number;
  3849. constructor(id: string, scene: Scene, width: number, height: number, subdivisions: number, canBeRegenerated?: boolean, mesh?: Mesh);
  3850. _regenerateVertexData(): VertexData;
  3851. copy(id: string): Geometry;
  3852. }
  3853. class TiledGround extends _Primitive {
  3854. xmin: number;
  3855. zmin: number;
  3856. xmax: number;
  3857. zmax: number;
  3858. subdivisions: {
  3859. w: number;
  3860. h: number;
  3861. };
  3862. precision: {
  3863. w: number;
  3864. h: number;
  3865. };
  3866. constructor(id: string, scene: Scene, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  3867. w: number;
  3868. h: number;
  3869. }, precision: {
  3870. w: number;
  3871. h: number;
  3872. }, canBeRegenerated?: boolean, mesh?: Mesh);
  3873. _regenerateVertexData(): VertexData;
  3874. copy(id: string): Geometry;
  3875. }
  3876. class Plane extends _Primitive {
  3877. size: number;
  3878. side: number;
  3879. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3880. _regenerateVertexData(): VertexData;
  3881. copy(id: string): Geometry;
  3882. }
  3883. class TorusKnot extends _Primitive {
  3884. radius: number;
  3885. tube: number;
  3886. radialSegments: number;
  3887. tubularSegments: number;
  3888. p: number;
  3889. q: number;
  3890. side: number;
  3891. constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3892. _regenerateVertexData(): VertexData;
  3893. copy(id: string): Geometry;
  3894. }
  3895. }
  3896. }
  3897. declare module BABYLON {
  3898. class GroundMesh extends Mesh {
  3899. generateOctree: boolean;
  3900. private _worldInverse;
  3901. _subdivisions: number;
  3902. constructor(name: string, scene: Scene);
  3903. subdivisions: number;
  3904. optimize(chunksCount: number): void;
  3905. getHeightAtCoordinates(x: number, z: number): number;
  3906. }
  3907. }
  3908. declare module BABYLON {
  3909. /**
  3910. * Creates an instance based on a source mesh.
  3911. */
  3912. class InstancedMesh extends AbstractMesh {
  3913. private _sourceMesh;
  3914. private _currentLOD;
  3915. constructor(name: string, source: Mesh);
  3916. receiveShadows: boolean;
  3917. material: Material;
  3918. visibility: number;
  3919. skeleton: Skeleton;
  3920. getTotalVertices(): number;
  3921. sourceMesh: Mesh;
  3922. getVerticesData(kind: string): number[];
  3923. isVerticesDataPresent(kind: string): boolean;
  3924. getIndices(): number[];
  3925. _positions: Vector3[];
  3926. refreshBoundingInfo(): void;
  3927. _preActivate(): void;
  3928. _activate(renderId: number): void;
  3929. getLOD(camera: Camera): AbstractMesh;
  3930. _syncSubMeshes(): void;
  3931. _generatePointsArray(): boolean;
  3932. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  3933. dispose(doNotRecurse?: boolean): void;
  3934. }
  3935. }
  3936. declare module BABYLON {
  3937. class LinesMesh extends Mesh {
  3938. color: Color3;
  3939. alpha: number;
  3940. private _colorShader;
  3941. private _ib;
  3942. private _indicesLength;
  3943. private _indices;
  3944. constructor(name: string, scene: Scene, updatable?: boolean);
  3945. material: Material;
  3946. isPickable: boolean;
  3947. checkCollisions: boolean;
  3948. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  3949. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  3950. intersects(ray: Ray, fastCheck?: boolean): any;
  3951. dispose(doNotRecurse?: boolean): void;
  3952. }
  3953. }
  3954. declare module BABYLON {
  3955. class _InstancesBatch {
  3956. mustReturn: boolean;
  3957. visibleInstances: InstancedMesh[][];
  3958. renderSelf: boolean[];
  3959. }
  3960. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  3961. static _FRONTSIDE: number;
  3962. static _BACKSIDE: number;
  3963. static _DOUBLESIDE: number;
  3964. static _DEFAULTSIDE: number;
  3965. static _NO_CAP: number;
  3966. static _CAP_START: number;
  3967. static _CAP_END: number;
  3968. static _CAP_ALL: number;
  3969. static FRONTSIDE: number;
  3970. static BACKSIDE: number;
  3971. static DOUBLESIDE: number;
  3972. static DEFAULTSIDE: number;
  3973. static NO_CAP: number;
  3974. static CAP_START: number;
  3975. static CAP_END: number;
  3976. static CAP_ALL: number;
  3977. delayLoadState: number;
  3978. instances: InstancedMesh[];
  3979. delayLoadingFile: string;
  3980. _binaryInfo: any;
  3981. private _LODLevels;
  3982. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  3983. _geometry: Geometry;
  3984. private _onBeforeRenderCallbacks;
  3985. private _onAfterRenderCallbacks;
  3986. _delayInfo: any;
  3987. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  3988. _visibleInstances: any;
  3989. private _renderIdForInstances;
  3990. private _batchCache;
  3991. private _worldMatricesInstancesBuffer;
  3992. private _worldMatricesInstancesArray;
  3993. private _instancesBufferSize;
  3994. _shouldGenerateFlatShading: boolean;
  3995. private _preActivateId;
  3996. private _sideOrientation;
  3997. private _areNormalsFrozen;
  3998. /**
  3999. * @constructor
  4000. * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
  4001. * @param {Scene} scene - The scene to add this mesh to.
  4002. * @param {Node} parent - The parent of this mesh, if it has one
  4003. * @param {Mesh} source - An optional Mesh from which geometry is shared, cloned.
  4004. * @param {boolean} doNotCloneChildren - When cloning, skip cloning child meshes of source, default False.
  4005. * When false, achieved by calling a clone(), also passing False.
  4006. * This will make creation of children, recursive.
  4007. */
  4008. constructor(name: string, scene: Scene, parent?: Node, source?: Mesh, doNotCloneChildren?: boolean);
  4009. hasLODLevels: boolean;
  4010. private _sortLODLevels();
  4011. /**
  4012. * Add a mesh as LOD level triggered at the given distance.
  4013. * @param {number} distance - the distance from the center of the object to show this level
  4014. * @param {BABYLON.Mesh} mesh - the mesh to be added as LOD level
  4015. * @return {BABYLON.Mesh} this mesh (for chaining)
  4016. */
  4017. addLODLevel(distance: number, mesh: Mesh): Mesh;
  4018. getLODLevelAtDistance(distance: number): Mesh;
  4019. /**
  4020. * Remove a mesh from the LOD array
  4021. * @param {BABYLON.Mesh} mesh - the mesh to be removed.
  4022. * @return {BABYLON.Mesh} this mesh (for chaining)
  4023. */
  4024. removeLODLevel(mesh: Mesh): Mesh;
  4025. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  4026. geometry: Geometry;
  4027. getTotalVertices(): number;
  4028. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  4029. getVertexBuffer(kind: any): VertexBuffer;
  4030. isVerticesDataPresent(kind: string): boolean;
  4031. getVerticesDataKinds(): string[];
  4032. getTotalIndices(): number;
  4033. getIndices(copyWhenShared?: boolean): number[];
  4034. isBlocked: boolean;
  4035. isReady(): boolean;
  4036. isDisposed(): boolean;
  4037. sideOrientation: number;
  4038. areNormalsFrozen: boolean;
  4039. /** This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
  4040. freezeNormals(): void;
  4041. /** This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
  4042. unfreezeNormals(): void;
  4043. _preActivate(): void;
  4044. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): void;
  4045. refreshBoundingInfo(): void;
  4046. _createGlobalSubMesh(): SubMesh;
  4047. subdivide(count: number): void;
  4048. setVerticesData(kind: any, data: any, updatable?: boolean, stride?: number): void;
  4049. updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
  4050. updateVerticesDataDirectly(kind: string, data: Float32Array, offset?: number, makeItUnique?: boolean): void;
  4051. updateMeshPositions(positionFunction: any, computeNormals?: boolean): void;
  4052. makeGeometryUnique(): void;
  4053. setIndices(indices: number[], totalVertices?: number): void;
  4054. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  4055. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  4056. registerBeforeRender(func: (mesh: AbstractMesh) => void): void;
  4057. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void;
  4058. registerAfterRender(func: (mesh: AbstractMesh) => void): void;
  4059. unregisterAfterRender(func: (mesh: AbstractMesh) => void): void;
  4060. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  4061. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
  4062. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix) => void): void;
  4063. render(subMesh: SubMesh): void;
  4064. getEmittedParticleSystems(): ParticleSystem[];
  4065. getHierarchyEmittedParticleSystems(): ParticleSystem[];
  4066. getChildren(): Node[];
  4067. _checkDelayState(): void;
  4068. isInFrustum(frustumPlanes: Plane[]): boolean;
  4069. setMaterialByID(id: string): void;
  4070. getAnimatables(): IAnimatable[];
  4071. bakeTransformIntoVertices(transform: Matrix): void;
  4072. _resetPointsArrayCache(): void;
  4073. _generatePointsArray(): boolean;
  4074. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): Mesh;
  4075. dispose(doNotRecurse?: boolean): void;
  4076. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void): void;
  4077. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number): void;
  4078. convertToFlatShadedMesh(): void;
  4079. createInstance(name: string): InstancedMesh;
  4080. synchronizeInstances(): void;
  4081. /**
  4082. * Simplify the mesh according to the given array of settings.
  4083. * Function will return immediately and will simplify async.
  4084. * @param settings a collection of simplification settings.
  4085. * @param parallelProcessing should all levels calculate parallel or one after the other.
  4086. * @param type the type of simplification to run.
  4087. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  4088. */
  4089. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): void;
  4090. /**
  4091. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  4092. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  4093. * This should be used together with the simplification to avoid disappearing triangles.
  4094. * @param successCallback an optional success callback to be called after the optimization finished.
  4095. */
  4096. optimizeIndices(successCallback?: (mesh?: Mesh) => void): void;
  4097. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, ribbonInstance?: Mesh): Mesh;
  4098. static CreateDisc(name: string, radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4099. static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4100. static CreateSphere(name: string, segments: number, diameter: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4101. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
  4102. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4103. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4104. static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, linesInstance?: LinesMesh): LinesMesh;
  4105. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, linesInstance?: LinesMesh): LinesMesh;
  4106. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, extrudedInstance?: Mesh): Mesh;
  4107. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: any, rotationFunction: any, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, extrudedInstance?: Mesh): Mesh;
  4108. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance);
  4109. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4110. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4111. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene: Scene, updatable?: boolean): Mesh;
  4112. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  4113. w: number;
  4114. h: number;
  4115. }, precision: {
  4116. w: number;
  4117. h: number;
  4118. }, scene: Scene, updatable?: boolean): Mesh;
  4119. 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;
  4120. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  4121. (i: number, distance: number): number;
  4122. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, tubeInstance?: Mesh): Mesh;
  4123. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle?: number): Mesh;
  4124. static MinMax(meshes: AbstractMesh[]): {
  4125. min: Vector3;
  4126. max: Vector3;
  4127. };
  4128. static Center(meshesOrMinMaxVector: any): Vector3;
  4129. /**
  4130. * Merge the array of meshes into a single mesh for performance reasons.
  4131. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  4132. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  4133. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  4134. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  4135. */
  4136. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh;
  4137. }
  4138. }
  4139. declare module BABYLON {
  4140. interface IGetSetVerticesData {
  4141. isVerticesDataPresent(kind: string): boolean;
  4142. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  4143. getIndices(copyWhenShared?: boolean): number[];
  4144. setVerticesData(kind: string, data: number[], updatable?: boolean): void;
  4145. updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
  4146. setIndices(indices: number[]): void;
  4147. }
  4148. class VertexData {
  4149. positions: number[];
  4150. normals: number[];
  4151. uvs: number[];
  4152. uv2s: number[];
  4153. colors: number[];
  4154. matricesIndices: number[];
  4155. matricesWeights: number[];
  4156. indices: number[];
  4157. set(data: number[], kind: string): void;
  4158. applyToMesh(mesh: Mesh, updatable?: boolean): void;
  4159. applyToGeometry(geometry: Geometry, updatable?: boolean): void;
  4160. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): void;
  4161. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): void;
  4162. private _applyTo(meshOrGeometry, updatable?);
  4163. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  4164. transform(matrix: Matrix): void;
  4165. merge(other: VertexData): void;
  4166. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean): VertexData;
  4167. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean): VertexData;
  4168. private static _ExtractFrom(meshOrGeometry, copyWhenShared?);
  4169. static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, sideOrientation?: number): VertexData;
  4170. static CreateBox(size: number, sideOrientation?: number): VertexData;
  4171. static CreateSphere(segments: number, diameter: number, sideOrientation?: number): VertexData;
  4172. static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, sideOrientation?: number): VertexData;
  4173. static CreateTorus(diameter: any, thickness: any, tessellation: any, sideOrientation?: number): VertexData;
  4174. static CreateLines(points: Vector3[]): VertexData;
  4175. static CreateDashedLines(points: Vector3[], dashSize: number, gapSize: number, dashNb: number): VertexData;
  4176. static CreateGround(width: number, height: number, subdivisions: number): VertexData;
  4177. static CreateTiledGround(xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: {
  4178. w: number;
  4179. h: number;
  4180. }, precision?: {
  4181. w: number;
  4182. h: number;
  4183. }): VertexData;
  4184. static CreateGroundFromHeightMap(width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, buffer: Uint8Array, bufferWidth: number, bufferHeight: number): VertexData;
  4185. static CreatePlane(size: number, sideOrientation?: number): VertexData;
  4186. static CreateDisc(radius: number, tessellation: number, sideOrientation?: number): VertexData;
  4187. static CreateTorusKnot(radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, sideOrientation?: number): VertexData;
  4188. /**
  4189. * @param {any} - positions (number[] or Float32Array)
  4190. * @param {any} - indices (number[] or Uint16Array)
  4191. * @param {any} - normals (number[] or Float32Array)
  4192. */
  4193. static ComputeNormals(positions: any, indices: any, normals: any): void;
  4194. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs);
  4195. }
  4196. }
  4197. declare module BABYLON.Internals {
  4198. class MeshLODLevel {
  4199. distance: number;
  4200. mesh: Mesh;
  4201. constructor(distance: number, mesh: Mesh);
  4202. }
  4203. }
  4204. declare module BABYLON {
  4205. /**
  4206. * A simplifier interface for future simplification implementations.
  4207. */
  4208. interface ISimplifier {
  4209. /**
  4210. * Simplification of a given mesh according to the given settings.
  4211. * Since this requires computation, it is assumed that the function runs async.
  4212. * @param settings The settings of the simplification, including quality and distance
  4213. * @param successCallback A callback that will be called after the mesh was simplified.
  4214. * @param errorCallback in case of an error, this callback will be called. optional.
  4215. */
  4216. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  4217. }
  4218. /**
  4219. * Expected simplification settings.
  4220. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  4221. */
  4222. interface ISimplificationSettings {
  4223. quality: number;
  4224. distance: number;
  4225. optimizeMesh?: boolean;
  4226. }
  4227. class SimplificationSettings implements ISimplificationSettings {
  4228. quality: number;
  4229. distance: number;
  4230. optimizeMesh: boolean;
  4231. constructor(quality: number, distance: number, optimizeMesh?: boolean);
  4232. }
  4233. interface ISimplificationTask {
  4234. settings: Array<ISimplificationSettings>;
  4235. simplificationType: SimplificationType;
  4236. mesh: Mesh;
  4237. successCallback?: () => void;
  4238. parallelProcessing: boolean;
  4239. }
  4240. class SimplificationQueue {
  4241. private _simplificationArray;
  4242. running: any;
  4243. constructor();
  4244. addTask(task: ISimplificationTask): void;
  4245. executeNext(): void;
  4246. runSimplification(task: ISimplificationTask): void;
  4247. private getSimplifier(task);
  4248. }
  4249. /**
  4250. * The implemented types of simplification.
  4251. * At the moment only Quadratic Error Decimation is implemented.
  4252. */
  4253. enum SimplificationType {
  4254. QUADRATIC = 0,
  4255. }
  4256. class DecimationTriangle {
  4257. vertices: Array<DecimationVertex>;
  4258. normal: Vector3;
  4259. error: Array<number>;
  4260. deleted: boolean;
  4261. isDirty: boolean;
  4262. borderFactor: number;
  4263. deletePending: boolean;
  4264. originalOffset: number;
  4265. constructor(vertices: Array<DecimationVertex>);
  4266. }
  4267. class DecimationVertex {
  4268. position: Vector3;
  4269. id: any;
  4270. q: QuadraticMatrix;
  4271. isBorder: boolean;
  4272. triangleStart: number;
  4273. triangleCount: number;
  4274. originalOffsets: Array<number>;
  4275. constructor(position: Vector3, id: any);
  4276. updatePosition(newPosition: Vector3): void;
  4277. }
  4278. class QuadraticMatrix {
  4279. data: Array<number>;
  4280. constructor(data?: Array<number>);
  4281. det(a11: any, a12: any, a13: any, a21: any, a22: any, a23: any, a31: any, a32: any, a33: any): number;
  4282. addInPlace(matrix: QuadraticMatrix): void;
  4283. addArrayInPlace(data: Array<number>): void;
  4284. add(matrix: QuadraticMatrix): QuadraticMatrix;
  4285. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  4286. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  4287. }
  4288. class Reference {
  4289. vertexId: number;
  4290. triangleId: number;
  4291. constructor(vertexId: number, triangleId: number);
  4292. }
  4293. /**
  4294. * An implementation of the Quadratic Error simplification algorithm.
  4295. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  4296. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  4297. * @author RaananW
  4298. */
  4299. class QuadraticErrorSimplification implements ISimplifier {
  4300. private _mesh;
  4301. private triangles;
  4302. private vertices;
  4303. private references;
  4304. private initialized;
  4305. private _reconstructedMesh;
  4306. syncIterations: number;
  4307. aggressiveness: number;
  4308. decimationIterations: number;
  4309. boundingBoxEpsilon: number;
  4310. constructor(_mesh: Mesh);
  4311. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  4312. private isTriangleOnBoundingBox(triangle);
  4313. private runDecimation(settings, submeshIndex, successCallback);
  4314. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  4315. private init(callback);
  4316. private reconstructMesh(submeshIndex);
  4317. private initDecimatedMesh();
  4318. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  4319. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  4320. private identifyBorder();
  4321. private updateMesh(identifyBorders?);
  4322. private vertexError(q, point);
  4323. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  4324. }
  4325. }
  4326. declare module BABYLON {
  4327. class Polygon {
  4328. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  4329. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  4330. static Parse(input: string): Vector2[];
  4331. static StartingAt(x: number, y: number): Path2;
  4332. }
  4333. class PolygonMeshBuilder {
  4334. private _swctx;
  4335. private _points;
  4336. private _outlinepoints;
  4337. private _holes;
  4338. private _name;
  4339. private _scene;
  4340. constructor(name: string, contours: Path2, scene: Scene);
  4341. constructor(name: string, contours: Vector2[], scene: Scene);
  4342. addHole(hole: Vector2[]): PolygonMeshBuilder;
  4343. build(updatable?: boolean, depth?: number): Mesh;
  4344. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  4345. }
  4346. }
  4347. declare module BABYLON {
  4348. class SubMesh {
  4349. materialIndex: number;
  4350. verticesStart: number;
  4351. verticesCount: number;
  4352. indexStart: any;
  4353. indexCount: number;
  4354. linesIndexCount: number;
  4355. private _mesh;
  4356. private _renderingMesh;
  4357. private _boundingInfo;
  4358. private _linesIndexBuffer;
  4359. _lastColliderWorldVertices: Vector3[];
  4360. _trianglePlanes: Plane[];
  4361. _lastColliderTransformMatrix: Matrix;
  4362. _renderId: number;
  4363. _alphaIndex: number;
  4364. _distanceToCamera: number;
  4365. _id: number;
  4366. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: any, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  4367. getBoundingInfo(): BoundingInfo;
  4368. getMesh(): AbstractMesh;
  4369. getRenderingMesh(): Mesh;
  4370. getMaterial(): Material;
  4371. refreshBoundingInfo(): void;
  4372. _checkCollision(collider: Collider): boolean;
  4373. updateBoundingInfo(world: Matrix): void;
  4374. isInFrustum(frustumPlanes: Plane[]): boolean;
  4375. render(): void;
  4376. getLinesIndexBuffer(indices: number[], engine: any): WebGLBuffer;
  4377. canIntersects(ray: Ray): boolean;
  4378. intersects(ray: Ray, positions: Vector3[], indices: number[], fastCheck?: boolean): IntersectionInfo;
  4379. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  4380. dispose(): void;
  4381. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  4382. }
  4383. }
  4384. declare module BABYLON {
  4385. class VertexBuffer {
  4386. private _mesh;
  4387. private _engine;
  4388. private _buffer;
  4389. private _data;
  4390. private _updatable;
  4391. private _kind;
  4392. private _strideSize;
  4393. constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number);
  4394. isUpdatable(): boolean;
  4395. getData(): number[];
  4396. getBuffer(): WebGLBuffer;
  4397. getStrideSize(): number;
  4398. create(data?: number[]): void;
  4399. update(data: number[]): void;
  4400. updateDirectly(data: Float32Array, offset: number): void;
  4401. dispose(): void;
  4402. private static _PositionKind;
  4403. private static _NormalKind;
  4404. private static _UVKind;
  4405. private static _UV2Kind;
  4406. private static _ColorKind;
  4407. private static _MatricesIndicesKind;
  4408. private static _MatricesWeightsKind;
  4409. static PositionKind: string;
  4410. static NormalKind: string;
  4411. static UVKind: string;
  4412. static UV2Kind: string;
  4413. static ColorKind: string;
  4414. static MatricesIndicesKind: string;
  4415. static MatricesWeightsKind: string;
  4416. }
  4417. }
  4418. declare module BABYLON {
  4419. class Particle {
  4420. position: Vector3;
  4421. direction: Vector3;
  4422. color: Color4;
  4423. colorStep: Color4;
  4424. lifeTime: number;
  4425. age: number;
  4426. size: number;
  4427. angle: number;
  4428. angularSpeed: number;
  4429. copyTo(other: Particle): void;
  4430. }
  4431. }
  4432. declare module BABYLON {
  4433. class ParticleSystem implements IDisposable {
  4434. name: string;
  4435. static BLENDMODE_ONEONE: number;
  4436. static BLENDMODE_STANDARD: number;
  4437. id: string;
  4438. renderingGroupId: number;
  4439. emitter: any;
  4440. emitRate: number;
  4441. manualEmitCount: number;
  4442. updateSpeed: number;
  4443. targetStopDuration: number;
  4444. disposeOnStop: boolean;
  4445. minEmitPower: number;
  4446. maxEmitPower: number;
  4447. minLifeTime: number;
  4448. maxLifeTime: number;
  4449. minSize: number;
  4450. maxSize: number;
  4451. minAngularSpeed: number;
  4452. maxAngularSpeed: number;
  4453. particleTexture: Texture;
  4454. onDispose: () => void;
  4455. updateFunction: (particles: Particle[]) => void;
  4456. blendMode: number;
  4457. forceDepthWrite: boolean;
  4458. gravity: Vector3;
  4459. direction1: Vector3;
  4460. direction2: Vector3;
  4461. minEmitBox: Vector3;
  4462. maxEmitBox: Vector3;
  4463. color1: Color4;
  4464. color2: Color4;
  4465. colorDead: Color4;
  4466. textureMask: Color4;
  4467. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3) => void;
  4468. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3) => void;
  4469. private particles;
  4470. private _capacity;
  4471. private _scene;
  4472. private _vertexDeclaration;
  4473. private _vertexStrideSize;
  4474. private _stockParticles;
  4475. private _newPartsExcess;
  4476. private _vertexBuffer;
  4477. private _indexBuffer;
  4478. private _vertices;
  4479. private _effect;
  4480. private _customEffect;
  4481. private _cachedDefines;
  4482. private _scaledColorStep;
  4483. private _colorDiff;
  4484. private _scaledDirection;
  4485. private _scaledGravity;
  4486. private _currentRenderId;
  4487. private _alive;
  4488. private _started;
  4489. private _stopped;
  4490. private _actualFrame;
  4491. private _scaledUpdateSpeed;
  4492. constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
  4493. recycleParticle(particle: Particle): void;
  4494. getCapacity(): number;
  4495. isAlive(): boolean;
  4496. isStarted(): boolean;
  4497. start(): void;
  4498. stop(): void;
  4499. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  4500. private _update(newParticles);
  4501. private _getEffect();
  4502. animate(): void;
  4503. render(): number;
  4504. dispose(): void;
  4505. clone(name: string, newEmitter: any): ParticleSystem;
  4506. }
  4507. }
  4508. declare module BABYLON {
  4509. interface IPhysicsEnginePlugin {
  4510. initialize(iterations?: number): any;
  4511. setGravity(gravity: Vector3): void;
  4512. runOneStep(delta: number): void;
  4513. registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4514. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4515. unregisterMesh(mesh: AbstractMesh): any;
  4516. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4517. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4518. dispose(): void;
  4519. isSupported(): boolean;
  4520. updateBodyPosition(mesh: AbstractMesh): void;
  4521. }
  4522. interface PhysicsBodyCreationOptions {
  4523. mass: number;
  4524. friction: number;
  4525. restitution: number;
  4526. }
  4527. interface PhysicsCompoundBodyPart {
  4528. mesh: Mesh;
  4529. impostor: number;
  4530. }
  4531. class PhysicsEngine {
  4532. gravity: Vector3;
  4533. private _currentPlugin;
  4534. constructor(plugin?: IPhysicsEnginePlugin);
  4535. _initialize(gravity?: Vector3): void;
  4536. _runOneStep(delta: number): void;
  4537. _setGravity(gravity: Vector3): void;
  4538. _registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4539. _registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4540. _unregisterMesh(mesh: AbstractMesh): void;
  4541. _applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4542. _createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4543. _updateBodyPosition(mesh: AbstractMesh): void;
  4544. dispose(): void;
  4545. isSupported(): boolean;
  4546. static NoImpostor: number;
  4547. static SphereImpostor: number;
  4548. static BoxImpostor: number;
  4549. static PlaneImpostor: number;
  4550. static MeshImpostor: number;
  4551. static CapsuleImpostor: number;
  4552. static ConeImpostor: number;
  4553. static CylinderImpostor: number;
  4554. static ConvexHullImpostor: number;
  4555. static Epsilon: number;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. class CannonJSPlugin implements IPhysicsEnginePlugin {
  4560. checkWithEpsilon: (value: number) => number;
  4561. private _world;
  4562. private _registeredMeshes;
  4563. private _physicsMaterials;
  4564. initialize(iterations?: number): void;
  4565. private _checkWithEpsilon(value);
  4566. runOneStep(delta: number): void;
  4567. setGravity(gravity: Vector3): void;
  4568. registerMesh(mesh: AbstractMesh, impostor: number, options?: PhysicsBodyCreationOptions): any;
  4569. private _createSphere(radius, mesh, options?);
  4570. private _createBox(x, y, z, mesh, options?);
  4571. private _createPlane(mesh, options?);
  4572. private _createConvexPolyhedron(rawVerts, rawFaces, mesh, options?);
  4573. private _addMaterial(friction, restitution);
  4574. private _createRigidBodyFromShape(shape, mesh, mass, friction, restitution);
  4575. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4576. private _unbindBody(body);
  4577. unregisterMesh(mesh: AbstractMesh): void;
  4578. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4579. updateBodyPosition: (mesh: AbstractMesh) => void;
  4580. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3): boolean;
  4581. dispose(): void;
  4582. isSupported(): boolean;
  4583. }
  4584. }
  4585. declare module BABYLON {
  4586. class OimoJSPlugin implements IPhysicsEnginePlugin {
  4587. private _world;
  4588. private _registeredMeshes;
  4589. private _checkWithEpsilon(value);
  4590. initialize(iterations?: number): void;
  4591. setGravity(gravity: Vector3): void;
  4592. registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4593. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4594. private _createBodyAsCompound(part, options, initialMesh);
  4595. unregisterMesh(mesh: AbstractMesh): void;
  4596. private _unbindBody(body);
  4597. /**
  4598. * Update the body position according to the mesh position
  4599. * @param mesh
  4600. */
  4601. updateBodyPosition: (mesh: AbstractMesh) => void;
  4602. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4603. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4604. dispose(): void;
  4605. isSupported(): boolean;
  4606. private _getLastShape(body);
  4607. runOneStep(time: number): void;
  4608. }
  4609. }
  4610. declare module BABYLON {
  4611. class AnaglyphPostProcess extends PostProcess {
  4612. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4613. }
  4614. }
  4615. declare module BABYLON {
  4616. class BlackAndWhitePostProcess extends PostProcess {
  4617. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4618. }
  4619. }
  4620. declare module BABYLON {
  4621. class BlurPostProcess extends PostProcess {
  4622. direction: Vector2;
  4623. blurWidth: number;
  4624. constructor(name: string, direction: Vector2, blurWidth: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4625. }
  4626. }
  4627. declare module BABYLON {
  4628. class ColorCorrectionPostProcess extends PostProcess {
  4629. private _colorTableTexture;
  4630. constructor(name: string, colorTableUrl: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4631. }
  4632. }
  4633. declare module BABYLON {
  4634. class ConvolutionPostProcess extends PostProcess {
  4635. kernel: number[];
  4636. constructor(name: string, kernel: number[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4637. static EdgeDetect0Kernel: number[];
  4638. static EdgeDetect1Kernel: number[];
  4639. static EdgeDetect2Kernel: number[];
  4640. static SharpenKernel: number[];
  4641. static EmbossKernel: number[];
  4642. static GaussianKernel: number[];
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. class DisplayPassPostProcess extends PostProcess {
  4647. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4648. }
  4649. }
  4650. declare module BABYLON {
  4651. class FilterPostProcess extends PostProcess {
  4652. kernelMatrix: Matrix;
  4653. constructor(name: string, kernelMatrix: Matrix, ratio: number, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4654. }
  4655. }
  4656. declare module BABYLON {
  4657. class FxaaPostProcess extends PostProcess {
  4658. texelWidth: number;
  4659. texelHeight: number;
  4660. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4661. }
  4662. }
  4663. declare module BABYLON {
  4664. class LensRenderingPipeline extends PostProcessRenderPipeline {
  4665. /**
  4666. * The chromatic aberration PostProcess id in the pipeline
  4667. * @type {string}
  4668. */
  4669. LensChromaticAberrationEffect: string;
  4670. /**
  4671. * The highlights enhancing PostProcess id in the pipeline
  4672. * @type {string}
  4673. */
  4674. HighlightsEnhancingEffect: string;
  4675. /**
  4676. * The depth-of-field PostProcess id in the pipeline
  4677. * @type {string}
  4678. */
  4679. LensDepthOfFieldEffect: string;
  4680. private _scene;
  4681. private _depthTexture;
  4682. private _grainTexture;
  4683. private _chromaticAberrationPostProcess;
  4684. private _highlightsPostProcess;
  4685. private _depthOfFieldPostProcess;
  4686. private _edgeBlur;
  4687. private _grainAmount;
  4688. private _chromaticAberration;
  4689. private _distortion;
  4690. private _highlightsGain;
  4691. private _highlightsThreshold;
  4692. private _dofDistance;
  4693. private _dofAperture;
  4694. private _dofDarken;
  4695. private _dofPentagon;
  4696. private _blurNoise;
  4697. /**
  4698. * @constructor
  4699. *
  4700. * Effect parameters are as follow:
  4701. * {
  4702. * chromatic_aberration: number; // from 0 to x (1 for realism)
  4703. * edge_blur: number; // from 0 to x (1 for realism)
  4704. * distortion: number; // from 0 to x (1 for realism)
  4705. * grain_amount: number; // from 0 to 1
  4706. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  4707. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  4708. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  4709. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  4710. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  4711. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  4712. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  4713. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  4714. * }
  4715. * Note: if an effect parameter is unset, effect is disabled
  4716. *
  4717. * @param {string} name - The rendering pipeline name
  4718. * @param {object} parameters - An object containing all parameters (see above)
  4719. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  4720. * @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)
  4721. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  4722. */
  4723. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  4724. setEdgeBlur(amount: number): void;
  4725. disableEdgeBlur(): void;
  4726. setGrainAmount(amount: number): void;
  4727. disableGrain(): void;
  4728. setChromaticAberration(amount: number): void;
  4729. disableChromaticAberration(): void;
  4730. setEdgeDistortion(amount: number): void;
  4731. disableEdgeDistortion(): void;
  4732. setFocusDistance(amount: number): void;
  4733. disableDepthOfField(): void;
  4734. setAperture(amount: number): void;
  4735. setDarkenOutOfFocus(amount: number): void;
  4736. enablePentagonBokeh(): void;
  4737. disablePentagonBokeh(): void;
  4738. enableNoiseBlur(): void;
  4739. disableNoiseBlur(): void;
  4740. setHighlightsGain(amount: number): void;
  4741. setHighlightsThreshold(amount: number): void;
  4742. disableHighlights(): void;
  4743. /**
  4744. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  4745. */
  4746. dispose(disableDepthRender?: boolean): void;
  4747. private _createChromaticAberrationPostProcess(ratio);
  4748. private _createHighlightsPostProcess(ratio);
  4749. private _createDepthOfFieldPostProcess(ratio);
  4750. private _createGrainTexture();
  4751. }
  4752. }
  4753. declare module BABYLON {
  4754. class PassPostProcess extends PostProcess {
  4755. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4756. }
  4757. }
  4758. declare module BABYLON {
  4759. class PostProcess {
  4760. name: string;
  4761. onApply: (effect: Effect) => void;
  4762. onBeforeRender: (effect: Effect) => void;
  4763. onSizeChanged: () => void;
  4764. onActivate: (camera: Camera) => void;
  4765. width: number;
  4766. height: number;
  4767. renderTargetSamplingMode: number;
  4768. clearColor: Color4;
  4769. private _camera;
  4770. private _scene;
  4771. private _engine;
  4772. private _renderRatio;
  4773. private _reusable;
  4774. _textures: SmartArray<WebGLTexture>;
  4775. _currentRenderTextureInd: number;
  4776. private _effect;
  4777. constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string);
  4778. isReusable(): boolean;
  4779. activate(camera: Camera, sourceTexture?: WebGLTexture): void;
  4780. apply(): Effect;
  4781. dispose(camera?: Camera): void;
  4782. }
  4783. }
  4784. declare module BABYLON {
  4785. class PostProcessManager {
  4786. private _scene;
  4787. private _indexBuffer;
  4788. private _vertexDeclaration;
  4789. private _vertexStrideSize;
  4790. private _vertexBuffer;
  4791. constructor(scene: Scene);
  4792. private _prepareBuffers();
  4793. _prepareFrame(sourceTexture?: WebGLTexture): boolean;
  4794. directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void;
  4795. _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void;
  4796. dispose(): void;
  4797. }
  4798. }
  4799. declare module BABYLON {
  4800. class RefractionPostProcess extends PostProcess {
  4801. color: Color3;
  4802. depth: number;
  4803. colorLevel: number;
  4804. private _refRexture;
  4805. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4806. dispose(camera: Camera): void;
  4807. }
  4808. }
  4809. declare module BABYLON {
  4810. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  4811. /**
  4812. * The PassPostProcess id in the pipeline that contains the original scene color
  4813. * @type {string}
  4814. */
  4815. SSAOOriginalSceneColorEffect: string;
  4816. /**
  4817. * The SSAO PostProcess id in the pipeline
  4818. * @type {string}
  4819. */
  4820. SSAORenderEffect: string;
  4821. /**
  4822. * The horizontal blur PostProcess id in the pipeline
  4823. * @type {string}
  4824. */
  4825. SSAOBlurHRenderEffect: string;
  4826. /**
  4827. * The vertical blur PostProcess id in the pipeline
  4828. * @type {string}
  4829. */
  4830. SSAOBlurVRenderEffect: string;
  4831. /**
  4832. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  4833. * @type {string}
  4834. */
  4835. SSAOCombineRenderEffect: string;
  4836. /**
  4837. * The output strength of the SSAO post-process. Default value is 1.0.
  4838. * @type {number}
  4839. */
  4840. totalStrength: number;
  4841. /**
  4842. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0002
  4843. * @type {number}
  4844. */
  4845. radius: number;
  4846. /**
  4847. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  4848. * Must not be equal to fallOff and superior to fallOff.
  4849. * Default value is 0.0075
  4850. * @type {number}
  4851. */
  4852. area: number;
  4853. /**
  4854. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  4855. * Must not be equal to area and inferior to area.
  4856. * Default value is 0.0002
  4857. * @type {number}
  4858. */
  4859. fallOff: number;
  4860. private _scene;
  4861. private _depthTexture;
  4862. private _randomTexture;
  4863. private _originalColorPostProcess;
  4864. private _ssaoPostProcess;
  4865. private _blurHPostProcess;
  4866. private _blurVPostProcess;
  4867. private _ssaoCombinePostProcess;
  4868. private _firstUpdate;
  4869. /**
  4870. * @constructor
  4871. * @param {string} name - The rendering pipeline name
  4872. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  4873. * @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 }
  4874. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  4875. */
  4876. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  4877. /**
  4878. * Returns the horizontal blur PostProcess
  4879. * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
  4880. */
  4881. getBlurHPostProcess(): BlurPostProcess;
  4882. /**
  4883. * Returns the vertical blur PostProcess
  4884. * @return {BABYLON.BlurPostProcess} The vertical blur post-process
  4885. */
  4886. getBlurVPostProcess(): BlurPostProcess;
  4887. /**
  4888. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  4889. */
  4890. dispose(disableDepthRender?: boolean): void;
  4891. private _createSSAOPostProcess(ratio);
  4892. private _createSSAOCombinePostProcess(ratio);
  4893. private _createRandomTexture();
  4894. }
  4895. }
  4896. declare module BABYLON {
  4897. class StereogramInterlacePostProcess extends PostProcess {
  4898. private _stepSize;
  4899. constructor(name: string, camB: Camera, postProcessA: PostProcess, isStereogramHoriz: boolean, samplingMode?: number);
  4900. }
  4901. }
  4902. declare module BABYLON {
  4903. class StereoscopicInterlacePostProcess extends PostProcess {
  4904. private _stepSize;
  4905. constructor(name: string, camB: Camera, postProcessA: PostProcess, isStereoscopicHoriz: boolean, samplingMode?: number);
  4906. }
  4907. }
  4908. declare module BABYLON {
  4909. class VolumetricLightScatteringPostProcess extends PostProcess {
  4910. private _volumetricLightScatteringPass;
  4911. private _volumetricLightScatteringRTT;
  4912. private _viewPort;
  4913. private _screenCoordinates;
  4914. private _cachedDefines;
  4915. private _customMeshPosition;
  4916. /**
  4917. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  4918. * @type {boolean}
  4919. */
  4920. useCustomMeshPosition: boolean;
  4921. /**
  4922. * If the post-process should inverse the light scattering direction
  4923. * @type {boolean}
  4924. */
  4925. invert: boolean;
  4926. /**
  4927. * The internal mesh used by the post-process
  4928. * @type {boolean}
  4929. */
  4930. mesh: Mesh;
  4931. /**
  4932. * Set to true to use the diffuseColor instead of the diffuseTexture
  4933. * @type {boolean}
  4934. */
  4935. useDiffuseColor: boolean;
  4936. /**
  4937. * Array containing the excluded meshes not rendered in the internal pass
  4938. */
  4939. excludedMeshes: AbstractMesh[];
  4940. exposure: number;
  4941. decay: number;
  4942. weight: number;
  4943. density: number;
  4944. /**
  4945. * @constructor
  4946. * @param {string} name - The post-process name
  4947. * @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)
  4948. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  4949. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  4950. * @param {number} samples - The post-process quality, default 100
  4951. * @param {number} samplingMode - The post-process filtering mode
  4952. * @param {BABYLON.Engine} engine - The babylon engine
  4953. * @param {boolean} reusable - If the post-process is reusable
  4954. */
  4955. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4956. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  4957. /**
  4958. * Sets the new light position for light scattering effect
  4959. * @param {BABYLON.Vector3} The new custom light position
  4960. */
  4961. setCustomMeshPosition(position: Vector3): void;
  4962. /**
  4963. * Returns the light position for light scattering effect
  4964. * @return {BABYLON.Vector3} The custom light position
  4965. */
  4966. getCustomMeshPosition(): Vector3;
  4967. /**
  4968. * Disposes the internal assets and detaches the post-process from the camera
  4969. */
  4970. dispose(camera: Camera): void;
  4971. /**
  4972. * Returns the render target texture used by the post-process
  4973. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  4974. */
  4975. getPass(): RenderTargetTexture;
  4976. private _meshExcluded(mesh);
  4977. private _createPass(scene, ratio);
  4978. private _updateMeshScreenCoordinates(scene);
  4979. /**
  4980. * Creates a default mesh for the Volumeric Light Scattering post-process
  4981. * @param {string} The mesh name
  4982. * @param {BABYLON.Scene} The scene where to create the mesh
  4983. * @return {BABYLON.Mesh} the default mesh
  4984. */
  4985. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  4986. }
  4987. }
  4988. declare module BABYLON {
  4989. class VRDistortionCorrectionPostProcess extends PostProcess {
  4990. aspectRatio: number;
  4991. private _isRightEye;
  4992. private _distortionFactors;
  4993. private _postProcessScaleFactor;
  4994. private _lensCenterOffset;
  4995. private _scaleIn;
  4996. private _scaleFactor;
  4997. private _lensCenter;
  4998. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  4999. }
  5000. }
  5001. declare module BABYLON {
  5002. class PostProcessRenderEffect {
  5003. private _engine;
  5004. private _postProcesses;
  5005. private _getPostProcess;
  5006. private _singleInstance;
  5007. private _cameras;
  5008. private _indicesForCamera;
  5009. private _renderPasses;
  5010. private _renderEffectAsPasses;
  5011. _name: string;
  5012. applyParameters: (postProcess: PostProcess) => void;
  5013. constructor(engine: Engine, name: string, getPostProcess: () => PostProcess, singleInstance?: boolean);
  5014. _update(): void;
  5015. addPass(renderPass: PostProcessRenderPass): void;
  5016. removePass(renderPass: PostProcessRenderPass): void;
  5017. addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void;
  5018. getPass(passName: string): void;
  5019. emptyPasses(): void;
  5020. _attachCameras(cameras: Camera): any;
  5021. _attachCameras(cameras: Camera[]): any;
  5022. _detachCameras(cameras: Camera): any;
  5023. _detachCameras(cameras: Camera[]): any;
  5024. _enable(cameras: Camera): any;
  5025. _enable(cameras: Camera[]): any;
  5026. _disable(cameras: Camera): any;
  5027. _disable(cameras: Camera[]): any;
  5028. getPostProcess(camera?: Camera): PostProcess;
  5029. private _linkParameters();
  5030. private _linkTextures(effect);
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. class PostProcessRenderPass {
  5035. private _enabled;
  5036. private _renderList;
  5037. private _renderTexture;
  5038. private _scene;
  5039. private _refCount;
  5040. _name: string;
  5041. constructor(scene: Scene, name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void);
  5042. _incRefCount(): number;
  5043. _decRefCount(): number;
  5044. _update(): void;
  5045. setRenderList(renderList: Mesh[]): void;
  5046. getRenderTexture(): RenderTargetTexture;
  5047. }
  5048. }
  5049. declare module BABYLON {
  5050. class PostProcessRenderPipeline {
  5051. private _engine;
  5052. private _renderEffects;
  5053. private _renderEffectsForIsolatedPass;
  5054. private _cameras;
  5055. _name: string;
  5056. private static PASS_EFFECT_NAME;
  5057. private static PASS_SAMPLER_NAME;
  5058. constructor(engine: Engine, name: string);
  5059. addEffect(renderEffect: PostProcessRenderEffect): void;
  5060. _enableEffect(renderEffectName: string, cameras: Camera): any;
  5061. _enableEffect(renderEffectName: string, cameras: Camera[]): any;
  5062. _disableEffect(renderEffectName: string, cameras: Camera): any;
  5063. _disableEffect(renderEffectName: string, cameras: Camera[]): any;
  5064. _attachCameras(cameras: Camera, unique: boolean): any;
  5065. _attachCameras(cameras: Camera[], unique: boolean): any;
  5066. _detachCameras(cameras: Camera): any;
  5067. _detachCameras(cameras: Camera[]): any;
  5068. _enableDisplayOnlyPass(passName: any, cameras: Camera): any;
  5069. _enableDisplayOnlyPass(passName: any, cameras: Camera[]): any;
  5070. _disableDisplayOnlyPass(cameras: Camera): any;
  5071. _disableDisplayOnlyPass(cameras: Camera[]): any;
  5072. _update(): void;
  5073. }
  5074. }
  5075. declare module BABYLON {
  5076. class PostProcessRenderPipelineManager {
  5077. private _renderPipelines;
  5078. constructor();
  5079. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  5080. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): any;
  5081. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): any;
  5082. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): any;
  5083. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): any;
  5084. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  5085. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  5086. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  5087. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  5088. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera): any;
  5089. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera[]): any;
  5090. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera): any;
  5091. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera[]): any;
  5092. update(): void;
  5093. }
  5094. }
  5095. declare module BABYLON {
  5096. class BoundingBoxRenderer {
  5097. frontColor: Color3;
  5098. backColor: Color3;
  5099. showBackLines: boolean;
  5100. renderList: SmartArray<BoundingBox>;
  5101. private _scene;
  5102. private _colorShader;
  5103. private _vb;
  5104. private _ib;
  5105. constructor(scene: Scene);
  5106. private _prepareRessources();
  5107. reset(): void;
  5108. render(): void;
  5109. dispose(): void;
  5110. }
  5111. }
  5112. declare module BABYLON {
  5113. class DepthRenderer {
  5114. private _scene;
  5115. private _depthMap;
  5116. private _effect;
  5117. private _viewMatrix;
  5118. private _projectionMatrix;
  5119. private _transformMatrix;
  5120. private _worldViewProjection;
  5121. private _cachedDefines;
  5122. constructor(scene: Scene, type?: number);
  5123. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5124. getDepthMap(): RenderTargetTexture;
  5125. dispose(): void;
  5126. }
  5127. }
  5128. declare module BABYLON {
  5129. class OutlineRenderer {
  5130. private _scene;
  5131. private _effect;
  5132. private _cachedDefines;
  5133. constructor(scene: Scene);
  5134. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  5135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5136. }
  5137. }
  5138. declare module BABYLON {
  5139. class RenderingGroup {
  5140. index: number;
  5141. private _scene;
  5142. private _opaqueSubMeshes;
  5143. private _transparentSubMeshes;
  5144. private _alphaTestSubMeshes;
  5145. private _activeVertices;
  5146. constructor(index: number, scene: Scene);
  5147. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void): boolean;
  5148. prepare(): void;
  5149. dispatch(subMesh: SubMesh): void;
  5150. }
  5151. }
  5152. declare module BABYLON {
  5153. class RenderingManager {
  5154. static MAX_RENDERINGGROUPS: number;
  5155. private _scene;
  5156. private _renderingGroups;
  5157. private _depthBufferAlreadyCleaned;
  5158. constructor(scene: Scene);
  5159. private _renderParticles(index, activeMeshes);
  5160. private _renderSprites(index);
  5161. private _clearDepthBuffer();
  5162. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void;
  5163. reset(): void;
  5164. dispatch(subMesh: SubMesh): void;
  5165. }
  5166. }
  5167. declare module BABYLON {
  5168. class Sprite {
  5169. name: string;
  5170. position: Vector3;
  5171. color: Color4;
  5172. width: number;
  5173. height: number;
  5174. angle: number;
  5175. cellIndex: number;
  5176. invertU: number;
  5177. invertV: number;
  5178. disposeWhenFinishedAnimating: boolean;
  5179. animations: Animation[];
  5180. private _animationStarted;
  5181. private _loopAnimation;
  5182. private _fromIndex;
  5183. private _toIndex;
  5184. private _delay;
  5185. private _direction;
  5186. private _frameCount;
  5187. private _manager;
  5188. private _time;
  5189. size: number;
  5190. constructor(name: string, manager: SpriteManager);
  5191. playAnimation(from: number, to: number, loop: boolean, delay: number): void;
  5192. stopAnimation(): void;
  5193. _animate(deltaTime: number): void;
  5194. dispose(): void;
  5195. }
  5196. }
  5197. declare module BABYLON {
  5198. class SpriteManager {
  5199. name: string;
  5200. cellSize: number;
  5201. sprites: Sprite[];
  5202. renderingGroupId: number;
  5203. onDispose: () => void;
  5204. fogEnabled: boolean;
  5205. private _capacity;
  5206. private _spriteTexture;
  5207. private _epsilon;
  5208. private _scene;
  5209. private _vertexDeclaration;
  5210. private _vertexStrideSize;
  5211. private _vertexBuffer;
  5212. private _indexBuffer;
  5213. private _vertices;
  5214. private _effectBase;
  5215. private _effectFog;
  5216. constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon?: number, samplingMode?: number);
  5217. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  5218. render(): void;
  5219. dispose(): void;
  5220. }
  5221. }
  5222. declare module BABYLON.Internals {
  5223. class AndOrNotEvaluator {
  5224. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5225. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  5226. private static _SimplifyNegation(booleanString);
  5227. }
  5228. }
  5229. declare module BABYLON {
  5230. interface IAssetTask {
  5231. onSuccess: (task: IAssetTask) => void;
  5232. onError: (task: IAssetTask) => void;
  5233. isCompleted: boolean;
  5234. run(scene: Scene, onSuccess: () => void, onError: () => void): any;
  5235. }
  5236. class MeshAssetTask implements IAssetTask {
  5237. name: string;
  5238. meshesNames: any;
  5239. rootUrl: string;
  5240. sceneFilename: string;
  5241. loadedMeshes: Array<AbstractMesh>;
  5242. loadedParticleSystems: Array<ParticleSystem>;
  5243. loadedSkeletons: Array<Skeleton>;
  5244. onSuccess: (task: IAssetTask) => void;
  5245. onError: (task: IAssetTask) => void;
  5246. isCompleted: boolean;
  5247. constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string);
  5248. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5249. }
  5250. class TextFileAssetTask implements IAssetTask {
  5251. name: string;
  5252. url: string;
  5253. onSuccess: (task: IAssetTask) => void;
  5254. onError: (task: IAssetTask) => void;
  5255. isCompleted: boolean;
  5256. text: string;
  5257. constructor(name: string, url: string);
  5258. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5259. }
  5260. class BinaryFileAssetTask implements IAssetTask {
  5261. name: string;
  5262. url: string;
  5263. onSuccess: (task: IAssetTask) => void;
  5264. onError: (task: IAssetTask) => void;
  5265. isCompleted: boolean;
  5266. data: ArrayBuffer;
  5267. constructor(name: string, url: string);
  5268. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5269. }
  5270. class ImageAssetTask implements IAssetTask {
  5271. name: string;
  5272. url: string;
  5273. onSuccess: (task: IAssetTask) => void;
  5274. onError: (task: IAssetTask) => void;
  5275. isCompleted: boolean;
  5276. image: HTMLImageElement;
  5277. constructor(name: string, url: string);
  5278. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5279. }
  5280. class TextureAssetTask implements IAssetTask {
  5281. name: string;
  5282. url: string;
  5283. noMipmap: boolean;
  5284. invertY: boolean;
  5285. samplingMode: number;
  5286. onSuccess: (task: IAssetTask) => void;
  5287. onError: (task: IAssetTask) => void;
  5288. isCompleted: boolean;
  5289. texture: Texture;
  5290. constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number);
  5291. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5292. }
  5293. class AssetsManager {
  5294. private _tasks;
  5295. private _scene;
  5296. private _waitingTasksCount;
  5297. onFinish: (tasks: IAssetTask[]) => void;
  5298. onTaskSuccess: (task: IAssetTask) => void;
  5299. onTaskError: (task: IAssetTask) => void;
  5300. useDefaultLoadingScreen: boolean;
  5301. constructor(scene: Scene);
  5302. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask;
  5303. addTextFileTask(taskName: string, url: string): IAssetTask;
  5304. addBinaryFileTask(taskName: string, url: string): IAssetTask;
  5305. addImageTask(taskName: string, url: string): IAssetTask;
  5306. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): IAssetTask;
  5307. private _decreaseWaitingTasksCount();
  5308. private _runTask(task);
  5309. reset(): AssetsManager;
  5310. load(): AssetsManager;
  5311. }
  5312. }
  5313. declare module BABYLON {
  5314. class Database {
  5315. private callbackManifestChecked;
  5316. private currentSceneUrl;
  5317. private db;
  5318. private enableSceneOffline;
  5319. private enableTexturesOffline;
  5320. private manifestVersionFound;
  5321. private mustUpdateRessources;
  5322. private hasReachedQuota;
  5323. private isSupported;
  5324. private idbFactory;
  5325. static IsUASupportingBlobStorage: boolean;
  5326. static IDBStorageEnabled: boolean;
  5327. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  5328. static parseURL: (url: string) => string;
  5329. static ReturnFullUrlLocation: (url: string) => string;
  5330. checkManifestFile(): void;
  5331. openAsync(successCallback: any, errorCallback: any): void;
  5332. loadImageFromDB(url: string, image: HTMLImageElement): void;
  5333. private _loadImageFromDBAsync(url, image, notInDBCallback);
  5334. private _saveImageIntoDBAsync(url, image);
  5335. private _checkVersionFromDB(url, versionLoaded);
  5336. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  5337. private _saveVersionIntoDBAsync(url, callback);
  5338. private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?);
  5339. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  5340. private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?);
  5341. }
  5342. }
  5343. declare module BABYLON {
  5344. class FilesInput {
  5345. private _engine;
  5346. private _currentScene;
  5347. private _canvas;
  5348. private _sceneLoadedCallback;
  5349. private _progressCallback;
  5350. private _additionnalRenderLoopLogicCallback;
  5351. private _textureLoadingCallback;
  5352. private _startingProcessingFilesCallback;
  5353. private _elementToMonitor;
  5354. static FilesTextures: any[];
  5355. static FilesToLoad: any[];
  5356. private _sceneFileToLoad;
  5357. private _filesToLoad;
  5358. 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);
  5359. monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void;
  5360. private renderFunction();
  5361. private drag(e);
  5362. private drop(eventDrop);
  5363. loadFiles(event: any): void;
  5364. reload(): void;
  5365. }
  5366. }
  5367. declare module BABYLON {
  5368. class Gamepads {
  5369. private babylonGamepads;
  5370. private oneGamepadConnected;
  5371. private isMonitoring;
  5372. private gamepadEventSupported;
  5373. private gamepadSupportAvailable;
  5374. private _callbackGamepadConnected;
  5375. private buttonADataURL;
  5376. private static gamepadDOMInfo;
  5377. constructor(ongamedpadconnected: (gamepad: Gamepad) => void);
  5378. private _insertGamepadDOMInstructions();
  5379. private _insertGamepadDOMNotSupported();
  5380. dispose(): void;
  5381. private _onGamepadConnected(evt);
  5382. private _addNewGamepad(gamepad);
  5383. private _onGamepadDisconnected(evt);
  5384. private _startMonitoringGamepads();
  5385. private _stopMonitoringGamepads();
  5386. private _checkGamepadsStatus();
  5387. private _updateGamepadObjects();
  5388. }
  5389. class StickValues {
  5390. x: any;
  5391. y: any;
  5392. constructor(x: any, y: any);
  5393. }
  5394. class Gamepad {
  5395. id: string;
  5396. index: number;
  5397. browserGamepad: any;
  5398. private _leftStick;
  5399. private _rightStick;
  5400. private _onleftstickchanged;
  5401. private _onrightstickchanged;
  5402. constructor(id: string, index: number, browserGamepad: any);
  5403. onleftstickchanged(callback: (values: StickValues) => void): void;
  5404. onrightstickchanged(callback: (values: StickValues) => void): void;
  5405. leftStick: StickValues;
  5406. rightStick: StickValues;
  5407. update(): void;
  5408. }
  5409. class GenericPad extends Gamepad {
  5410. id: string;
  5411. index: number;
  5412. gamepad: any;
  5413. private _buttons;
  5414. private _onbuttondown;
  5415. private _onbuttonup;
  5416. onbuttondown(callback: (buttonPressed: number) => void): void;
  5417. onbuttonup(callback: (buttonReleased: number) => void): void;
  5418. constructor(id: string, index: number, gamepad: any);
  5419. private _setButtonValue(newValue, currentValue, buttonIndex);
  5420. update(): void;
  5421. }
  5422. enum Xbox360Button {
  5423. A = 0,
  5424. B = 1,
  5425. X = 2,
  5426. Y = 3,
  5427. Start = 4,
  5428. Back = 5,
  5429. LB = 6,
  5430. RB = 7,
  5431. LeftStick = 8,
  5432. RightStick = 9,
  5433. }
  5434. enum Xbox360Dpad {
  5435. Up = 0,
  5436. Down = 1,
  5437. Left = 2,
  5438. Right = 3,
  5439. }
  5440. class Xbox360Pad extends Gamepad {
  5441. private _leftTrigger;
  5442. private _rightTrigger;
  5443. private _onlefttriggerchanged;
  5444. private _onrighttriggerchanged;
  5445. private _onbuttondown;
  5446. private _onbuttonup;
  5447. private _ondpaddown;
  5448. private _ondpadup;
  5449. private _buttonA;
  5450. private _buttonB;
  5451. private _buttonX;
  5452. private _buttonY;
  5453. private _buttonBack;
  5454. private _buttonStart;
  5455. private _buttonLB;
  5456. private _buttonRB;
  5457. private _buttonLeftStick;
  5458. private _buttonRightStick;
  5459. private _dPadUp;
  5460. private _dPadDown;
  5461. private _dPadLeft;
  5462. private _dPadRight;
  5463. onlefttriggerchanged(callback: (value: number) => void): void;
  5464. onrighttriggerchanged(callback: (value: number) => void): void;
  5465. leftTrigger: number;
  5466. rightTrigger: number;
  5467. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5468. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5469. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5470. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5471. private _setButtonValue(newValue, currentValue, buttonType);
  5472. private _setDPadValue(newValue, currentValue, buttonType);
  5473. buttonA: number;
  5474. buttonB: number;
  5475. buttonX: number;
  5476. buttonY: number;
  5477. buttonStart: number;
  5478. buttonBack: number;
  5479. buttonLB: number;
  5480. buttonRB: number;
  5481. buttonLeftStick: number;
  5482. buttonRightStick: number;
  5483. dPadUp: number;
  5484. dPadDown: number;
  5485. dPadLeft: number;
  5486. dPadRight: number;
  5487. update(): void;
  5488. }
  5489. }
  5490. interface Navigator {
  5491. getGamepads(func?: any): any;
  5492. webkitGetGamepads(func?: any): any;
  5493. msGetGamepads(func?: any): any;
  5494. webkitGamepads(func?: any): any;
  5495. }
  5496. declare module BABYLON {
  5497. class SceneOptimization {
  5498. priority: number;
  5499. apply: (scene: Scene) => boolean;
  5500. constructor(priority?: number);
  5501. }
  5502. class TextureOptimization extends SceneOptimization {
  5503. priority: number;
  5504. maximumSize: number;
  5505. constructor(priority?: number, maximumSize?: number);
  5506. apply: (scene: Scene) => boolean;
  5507. }
  5508. class HardwareScalingOptimization extends SceneOptimization {
  5509. priority: number;
  5510. maximumScale: number;
  5511. private _currentScale;
  5512. constructor(priority?: number, maximumScale?: number);
  5513. apply: (scene: Scene) => boolean;
  5514. }
  5515. class ShadowsOptimization extends SceneOptimization {
  5516. apply: (scene: Scene) => boolean;
  5517. }
  5518. class PostProcessesOptimization extends SceneOptimization {
  5519. apply: (scene: Scene) => boolean;
  5520. }
  5521. class LensFlaresOptimization extends SceneOptimization {
  5522. apply: (scene: Scene) => boolean;
  5523. }
  5524. class ParticlesOptimization extends SceneOptimization {
  5525. apply: (scene: Scene) => boolean;
  5526. }
  5527. class RenderTargetsOptimization extends SceneOptimization {
  5528. apply: (scene: Scene) => boolean;
  5529. }
  5530. class MergeMeshesOptimization extends SceneOptimization {
  5531. private _canBeMerged;
  5532. apply: (scene: Scene) => boolean;
  5533. }
  5534. class SceneOptimizerOptions {
  5535. targetFrameRate: number;
  5536. trackerDuration: number;
  5537. optimizations: SceneOptimization[];
  5538. constructor(targetFrameRate?: number, trackerDuration?: number);
  5539. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5540. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5541. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5542. }
  5543. class SceneOptimizer {
  5544. static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void;
  5545. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void;
  5546. }
  5547. }
  5548. declare module BABYLON {
  5549. class SceneSerializer {
  5550. static Serialize(scene: Scene): any;
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. class SmartArray<T> {
  5555. data: Array<T>;
  5556. length: number;
  5557. private _id;
  5558. private _duplicateId;
  5559. constructor(capacity: number);
  5560. push(value: any): void;
  5561. pushNoDuplicate(value: any): void;
  5562. sort(compareFn: any): void;
  5563. reset(): void;
  5564. concat(array: any): void;
  5565. concatWithNoDuplicate(array: any): void;
  5566. indexOf(value: any): number;
  5567. private static _GlobalId;
  5568. }
  5569. }
  5570. declare module BABYLON {
  5571. class SmartCollection {
  5572. count: number;
  5573. items: any;
  5574. private _keys;
  5575. private _initialCapacity;
  5576. constructor(capacity?: number);
  5577. add(key: any, item: any): number;
  5578. remove(key: any): number;
  5579. removeItemOfIndex(index: number): number;
  5580. indexOf(key: any): number;
  5581. item(key: any): any;
  5582. getAllKeys(): any[];
  5583. getKeyByIndex(index: number): any;
  5584. getItemByIndex(index: number): any;
  5585. empty(): void;
  5586. forEach(block: (item: any) => void): void;
  5587. }
  5588. }
  5589. declare module BABYLON {
  5590. class Tags {
  5591. static EnableFor(obj: any): void;
  5592. static DisableFor(obj: any): void;
  5593. static HasTags(obj: any): boolean;
  5594. static GetTags(obj: any): any;
  5595. static AddTagsTo(obj: any, tagsString: string): void;
  5596. static _AddTagTo(obj: any, tag: string): void;
  5597. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5598. static _RemoveTagFrom(obj: any, tag: string): void;
  5599. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5600. }
  5601. }
  5602. declare module BABYLON {
  5603. interface IAnimatable {
  5604. animations: Array<Animation>;
  5605. }
  5606. interface ISize {
  5607. width: number;
  5608. height: number;
  5609. }
  5610. class Tools {
  5611. static BaseUrl: string;
  5612. static SetImmediate(action: () => void): void;
  5613. static IsExponantOfTwo(value: number): boolean;
  5614. static GetExponantOfTwo(value: number, max: number): number;
  5615. static GetFilename(path: string): string;
  5616. static GetDOMTextContent(element: HTMLElement): string;
  5617. static ToDegrees(angle: number): number;
  5618. static ToRadians(angle: number): number;
  5619. static ExtractMinAndMaxIndexed(positions: number[], indices: number[], indexStart: number, indexCount: number): {
  5620. minimum: Vector3;
  5621. maximum: Vector3;
  5622. };
  5623. static ExtractMinAndMax(positions: number[], start: number, count: number): {
  5624. minimum: Vector3;
  5625. maximum: Vector3;
  5626. };
  5627. static MakeArray(obj: any, allowsNullUndefined?: boolean): Array<any>;
  5628. static GetPointerPrefix(): string;
  5629. static QueueNewFrame(func: any): void;
  5630. static RequestFullscreen(element: any): void;
  5631. static ExitFullscreen(): void;
  5632. static CleanUrl(url: string): string;
  5633. static LoadImage(url: string, onload: any, onerror: any, database: any): HTMLImageElement;
  5634. static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?: any, useArrayBuffer?: boolean, onError?: () => void): void;
  5635. static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void;
  5636. static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void;
  5637. static Clamp(value: number, min?: number, max?: number): number;
  5638. static Sign(value: number): number;
  5639. static Format(value: number, decimals?: number): string;
  5640. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  5641. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  5642. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5643. static IsEmpty(obj: any): boolean;
  5644. static RegisterTopRootEvents(events: {
  5645. name: string;
  5646. handler: EventListener;
  5647. }[]): void;
  5648. static UnregisterTopRootEvents(events: {
  5649. name: string;
  5650. handler: EventListener;
  5651. }[]): void;
  5652. static DumpFramebuffer(width: number, height: number, engine: Engine): void;
  5653. static CreateScreenshot(engine: Engine, camera: Camera, size: any): void;
  5654. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  5655. private static _NoneLogLevel;
  5656. private static _MessageLogLevel;
  5657. private static _WarningLogLevel;
  5658. private static _ErrorLogLevel;
  5659. private static _LogCache;
  5660. static OnNewCacheEntry: (entry: string) => void;
  5661. static NoneLogLevel: number;
  5662. static MessageLogLevel: number;
  5663. static WarningLogLevel: number;
  5664. static ErrorLogLevel: number;
  5665. static AllLogLevel: number;
  5666. private static _AddLogEntry(entry);
  5667. private static _FormatMessage(message);
  5668. static Log: (message: string) => void;
  5669. private static _LogDisabled(message);
  5670. private static _LogEnabled(message);
  5671. static Warn: (message: string) => void;
  5672. private static _WarnDisabled(message);
  5673. private static _WarnEnabled(message);
  5674. static Error: (message: string) => void;
  5675. private static _ErrorDisabled(message);
  5676. private static _ErrorEnabled(message);
  5677. static LogCache: string;
  5678. static LogLevels: number;
  5679. private static _PerformanceNoneLogLevel;
  5680. private static _PerformanceUserMarkLogLevel;
  5681. private static _PerformanceConsoleLogLevel;
  5682. private static _performance;
  5683. static PerformanceNoneLogLevel: number;
  5684. static PerformanceUserMarkLogLevel: number;
  5685. static PerformanceConsoleLogLevel: number;
  5686. static PerformanceLogLevel: number;
  5687. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  5688. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  5689. static _StartUserMark(counterName: string, condition?: boolean): void;
  5690. static _EndUserMark(counterName: string, condition?: boolean): void;
  5691. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  5692. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  5693. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  5694. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  5695. static Now: number;
  5696. static GetFps(): number;
  5697. }
  5698. /**
  5699. * An implementation of a loop for asynchronous functions.
  5700. */
  5701. class AsyncLoop {
  5702. iterations: number;
  5703. private _fn;
  5704. private _successCallback;
  5705. index: number;
  5706. private _done;
  5707. /**
  5708. * Constroctor.
  5709. * @param iterations the number of iterations.
  5710. * @param _fn the function to run each iteration
  5711. * @param _successCallback the callback that will be called upon succesful execution
  5712. * @param offset starting offset.
  5713. */
  5714. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  5715. /**
  5716. * Execute the next iteration. Must be called after the last iteration was finished.
  5717. */
  5718. executeNext(): void;
  5719. /**
  5720. * Break the loop and run the success callback.
  5721. */
  5722. breakLoop(): void;
  5723. /**
  5724. * Helper function
  5725. */
  5726. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  5727. /**
  5728. * A for-loop that will run a given number of iterations synchronous and the rest async.
  5729. * @param iterations total number of iterations
  5730. * @param syncedIterations number of synchronous iterations in each async iteration.
  5731. * @param fn the function to call each iteration.
  5732. * @param callback a success call back that will be called when iterating stops.
  5733. * @param breakFunction a break condition (optional)
  5734. * @param timeout timeout settings for the setTimeout function. default - 0.
  5735. * @constructor
  5736. */
  5737. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  5738. }
  5739. }
  5740. declare module BABYLON.Internals {
  5741. interface DDSInfo {
  5742. width: number;
  5743. height: number;
  5744. mipmapCount: number;
  5745. isFourCC: boolean;
  5746. isRGB: boolean;
  5747. isLuminance: boolean;
  5748. isCube: boolean;
  5749. }
  5750. class DDSTools {
  5751. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  5752. private static GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5753. private static GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5754. private static GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5755. static UploadDDSLevels(gl: WebGLRenderingContext, ext: any, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number): void;
  5756. }
  5757. }
  5758. declare module BABYLON.Internals {
  5759. class TGATools {
  5760. private static _TYPE_NO_DATA;
  5761. private static _TYPE_INDEXED;
  5762. private static _TYPE_RGB;
  5763. private static _TYPE_GREY;
  5764. private static _TYPE_RLE_INDEXED;
  5765. private static _TYPE_RLE_RGB;
  5766. private static _TYPE_RLE_GREY;
  5767. private static _ORIGIN_MASK;
  5768. private static _ORIGIN_SHIFT;
  5769. private static _ORIGIN_BL;
  5770. private static _ORIGIN_BR;
  5771. private static _ORIGIN_UL;
  5772. private static _ORIGIN_UR;
  5773. static GetTGAHeader(data: Uint8Array): any;
  5774. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  5775. 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;
  5776. 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;
  5777. 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;
  5778. 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;
  5779. 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;
  5780. 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;
  5781. }
  5782. }
  5783. declare module BABYLON {
  5784. enum JoystickAxis {
  5785. X = 0,
  5786. Y = 1,
  5787. Z = 2,
  5788. }
  5789. class VirtualJoystick {
  5790. reverseLeftRight: boolean;
  5791. reverseUpDown: boolean;
  5792. deltaPosition: Vector3;
  5793. pressed: boolean;
  5794. private static _globalJoystickIndex;
  5795. private static vjCanvas;
  5796. private static vjCanvasContext;
  5797. private static vjCanvasWidth;
  5798. private static vjCanvasHeight;
  5799. private static halfWidth;
  5800. private static halfHeight;
  5801. private _action;
  5802. private _axisTargetedByLeftAndRight;
  5803. private _axisTargetedByUpAndDown;
  5804. private _joystickSensibility;
  5805. private _inversedSensibility;
  5806. private _rotationSpeed;
  5807. private _inverseRotationSpeed;
  5808. private _rotateOnAxisRelativeToMesh;
  5809. private _joystickPointerID;
  5810. private _joystickColor;
  5811. private _joystickPointerPos;
  5812. private _joystickPointerStartPos;
  5813. private _deltaJoystickVector;
  5814. private _leftJoystick;
  5815. private _joystickIndex;
  5816. private _touches;
  5817. constructor(leftJoystick?: boolean);
  5818. setJoystickSensibility(newJoystickSensibility: number): void;
  5819. private _onPointerDown(e);
  5820. private _onPointerMove(e);
  5821. private _onPointerUp(e);
  5822. /**
  5823. * Change the color of the virtual joystick
  5824. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  5825. */
  5826. setJoystickColor(newColor: string): void;
  5827. setActionOnTouch(action: () => any): void;
  5828. setAxisForLeftRight(axis: JoystickAxis): void;
  5829. setAxisForUpDown(axis: JoystickAxis): void;
  5830. private _clearCanvas();
  5831. private _drawVirtualJoystick();
  5832. releaseCanvas(): void;
  5833. }
  5834. }