babylon.2.1.d.ts 243 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876
  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 StereogramFreeCamera extends FreeCamera {
  1767. constructor(name: string, position: Vector3, eyeSpace: number, isVertical: boolean, scene: Scene);
  1768. }
  1769. class StereogramArcRotateCamera extends ArcRotateCamera {
  1770. constructor(name: string, alpha: number, beta: number, radius: number, target: any, eyeSpace: number, isVertical: boolean, scene: Scene);
  1771. }
  1772. class StereogramGamepadCamera extends GamepadCamera {
  1773. constructor(name: string, position: Vector3, eyeSpace: number, isVertical: boolean, scene: Scene);
  1774. }
  1775. }
  1776. declare module BABYLON {
  1777. class StereoscopicFreeCamera extends FreeCamera {
  1778. constructor(name: string, position: Vector3, eyeSpace: number, isVertical: boolean, scene: Scene);
  1779. }
  1780. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  1781. constructor(name: string, alpha: number, beta: number, radius: number, target: any, eyeSpace: number, isVertical: boolean, scene: Scene);
  1782. }
  1783. class StereoscopicGamepadCamera extends GamepadCamera {
  1784. constructor(name: string, position: Vector3, eyeSpace: number, isVertical: boolean, scene: Scene);
  1785. }
  1786. }
  1787. declare module BABYLON {
  1788. class AnaglyphFreeCamera extends FreeCamera {
  1789. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  1790. }
  1791. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  1792. constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, scene: Scene);
  1793. }
  1794. class AnaglyphGamepadCamera extends GamepadCamera {
  1795. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  1796. }
  1797. class StereoscopicFreeCamera extends FreeCamera {
  1798. constructor(name: string, position: Vector3, interaxialDistance: number, isSideBySide: boolean, scene: Scene);
  1799. }
  1800. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  1801. constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, isSideBySide: boolean, scene: Scene);
  1802. }
  1803. class StereoscopicGamepadCamera extends GamepadCamera {
  1804. constructor(name: string, position: Vector3, interaxialDistance: number, isSideBySide: boolean, scene: Scene);
  1805. }
  1806. }
  1807. declare module BABYLON {
  1808. class TargetCamera extends Camera {
  1809. cameraDirection: Vector3;
  1810. cameraRotation: Vector2;
  1811. rotation: Vector3;
  1812. speed: number;
  1813. noRotationConstraint: boolean;
  1814. lockedTarget: any;
  1815. _currentTarget: Vector3;
  1816. _viewMatrix: Matrix;
  1817. _camMatrix: Matrix;
  1818. _cameraTransformMatrix: Matrix;
  1819. _cameraRotationMatrix: Matrix;
  1820. private _rigCamTransformMatrix;
  1821. _referencePoint: Vector3;
  1822. _transformedReferencePoint: Vector3;
  1823. _lookAtTemp: Matrix;
  1824. _tempMatrix: Matrix;
  1825. _reset: () => void;
  1826. _waitingLockedTargetId: string;
  1827. constructor(name: string, position: Vector3, scene: Scene);
  1828. _getLockedTargetPosition(): Vector3;
  1829. _initCache(): void;
  1830. _updateCache(ignoreParentClass?: boolean): void;
  1831. _isSynchronizedViewMatrix(): boolean;
  1832. _computeLocalCameraSpeed(): number;
  1833. setTarget(target: Vector3): void;
  1834. getTarget(): Vector3;
  1835. _decideIfNeedsToMove(): boolean;
  1836. _updatePosition(): void;
  1837. _checkInputs(): void;
  1838. _getViewMatrix(): Matrix;
  1839. _getVRViewMatrix(): Matrix;
  1840. /**
  1841. * @override
  1842. * Override Camera.createRigCamera
  1843. */
  1844. createRigCamera(name: string, cameraIndex: number): Camera;
  1845. /**
  1846. * @override
  1847. * Override Camera._updateRigCameras
  1848. */
  1849. _updateRigCameras(): void;
  1850. private _getRigCamPosition(halfSpace, result);
  1851. }
  1852. }
  1853. declare module BABYLON {
  1854. class TouchCamera extends FreeCamera {
  1855. private _offsetX;
  1856. private _offsetY;
  1857. private _pointerCount;
  1858. private _pointerPressed;
  1859. private _attachedCanvas;
  1860. private _onPointerDown;
  1861. private _onPointerUp;
  1862. private _onPointerMove;
  1863. angularSensibility: number;
  1864. moveSensibility: number;
  1865. constructor(name: string, position: Vector3, scene: Scene);
  1866. attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void;
  1867. detachControl(canvas: HTMLCanvasElement): void;
  1868. _checkInputs(): void;
  1869. }
  1870. }
  1871. declare module BABYLON {
  1872. class VirtualJoysticksCamera extends FreeCamera {
  1873. private _leftjoystick;
  1874. private _rightjoystick;
  1875. constructor(name: string, position: Vector3, scene: Scene);
  1876. _checkInputs(): void;
  1877. dispose(): void;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. class VRCamera extends FreeCamera {
  1882. private _leftCamera;
  1883. private _rightCamera;
  1884. private _offsetOrientation;
  1885. private _deviceOrientationHandler;
  1886. constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
  1887. _update(): void;
  1888. _updateCamera(camera: FreeCamera): void;
  1889. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1891. detachControl(element: HTMLElement): void;
  1892. }
  1893. }
  1894. declare module BABYLON {
  1895. class VRDeviceOrientationFreeCamera extends FreeCamera {
  1896. _alpha: number;
  1897. _beta: number;
  1898. _gamma: number;
  1899. private _offsetOrientation;
  1900. private _deviceOrientationHandler;
  1901. constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
  1902. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1904. detachControl(element: HTMLElement): void;
  1905. }
  1906. }
  1907. declare var HMDVRDevice: any;
  1908. declare var PositionSensorVRDevice: any;
  1909. declare module BABYLON {
  1910. class WebVRFreeCamera extends FreeCamera {
  1911. _hmdDevice: any;
  1912. _sensorDevice: any;
  1913. _cacheState: any;
  1914. _cacheQuaternion: Quaternion;
  1915. _cacheRotation: Vector3;
  1916. _vrEnabled: boolean;
  1917. constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
  1918. private _getWebVRDevices(devices);
  1919. _checkInputs(): void;
  1920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1921. detachControl(element: HTMLElement): void;
  1922. }
  1923. }
  1924. declare module BABYLON {
  1925. class Collider {
  1926. radius: Vector3;
  1927. retry: number;
  1928. velocity: Vector3;
  1929. basePoint: Vector3;
  1930. epsilon: number;
  1931. collisionFound: boolean;
  1932. velocityWorldLength: number;
  1933. basePointWorld: Vector3;
  1934. velocityWorld: Vector3;
  1935. normalizedVelocity: Vector3;
  1936. initialVelocity: Vector3;
  1937. initialPosition: Vector3;
  1938. nearestDistance: number;
  1939. intersectionPoint: Vector3;
  1940. collidedMesh: AbstractMesh;
  1941. private _collisionPoint;
  1942. private _planeIntersectionPoint;
  1943. private _tempVector;
  1944. private _tempVector2;
  1945. private _tempVector3;
  1946. private _tempVector4;
  1947. private _edge;
  1948. private _baseToVertex;
  1949. private _destinationPoint;
  1950. private _slidePlaneNormal;
  1951. private _displacementVector;
  1952. _initialize(source: Vector3, dir: Vector3, e: number): void;
  1953. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  1954. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  1955. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  1956. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: number[], indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  1957. _getResponse(pos: Vector3, vel: Vector3): void;
  1958. }
  1959. }
  1960. declare module BABYLON {
  1961. var CollisionWorker: string;
  1962. interface ICollisionCoordinator {
  1963. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  1964. init(scene: Scene): void;
  1965. destroy(): void;
  1966. onMeshAdded(mesh: AbstractMesh): any;
  1967. onMeshUpdated(mesh: AbstractMesh): any;
  1968. onMeshRemoved(mesh: AbstractMesh): any;
  1969. onGeometryAdded(geometry: Geometry): any;
  1970. onGeometryUpdated(geometry: Geometry): any;
  1971. onGeometryDeleted(geometry: Geometry): any;
  1972. }
  1973. interface SerializedMesh {
  1974. id: string;
  1975. name: string;
  1976. uniqueId: number;
  1977. geometryId: string;
  1978. sphereCenter: Array<number>;
  1979. sphereRadius: number;
  1980. boxMinimum: Array<number>;
  1981. boxMaximum: Array<number>;
  1982. worldMatrixFromCache: any;
  1983. subMeshes: Array<SerializedSubMesh>;
  1984. checkCollisions: boolean;
  1985. }
  1986. interface SerializedSubMesh {
  1987. position: number;
  1988. verticesStart: number;
  1989. verticesCount: number;
  1990. indexStart: number;
  1991. indexCount: number;
  1992. hasMaterial: boolean;
  1993. sphereCenter: Array<number>;
  1994. sphereRadius: number;
  1995. boxMinimum: Array<number>;
  1996. boxMaximum: Array<number>;
  1997. }
  1998. interface SerializedGeometry {
  1999. id: string;
  2000. positions: Float32Array;
  2001. indices: Int32Array;
  2002. normals: Float32Array;
  2003. }
  2004. interface BabylonMessage {
  2005. taskType: WorkerTaskType;
  2006. payload: InitPayload | CollidePayload | UpdatePayload;
  2007. }
  2008. interface SerializedColliderToWorker {
  2009. position: Array<number>;
  2010. velocity: Array<number>;
  2011. radius: Array<number>;
  2012. }
  2013. enum WorkerTaskType {
  2014. INIT = 0,
  2015. UPDATE = 1,
  2016. COLLIDE = 2,
  2017. }
  2018. interface WorkerReply {
  2019. error: WorkerReplyType;
  2020. taskType: WorkerTaskType;
  2021. payload?: any;
  2022. }
  2023. interface CollisionReplyPayload {
  2024. newPosition: Array<number>;
  2025. collisionId: number;
  2026. collidedMeshUniqueId: number;
  2027. }
  2028. interface InitPayload {
  2029. }
  2030. interface CollidePayload {
  2031. collisionId: number;
  2032. collider: SerializedColliderToWorker;
  2033. maximumRetry: number;
  2034. excludedMeshUniqueId?: number;
  2035. }
  2036. interface UpdatePayload {
  2037. updatedMeshes: {
  2038. [n: number]: SerializedMesh;
  2039. };
  2040. updatedGeometries: {
  2041. [s: string]: SerializedGeometry;
  2042. };
  2043. removedMeshes: Array<number>;
  2044. removedGeometries: Array<string>;
  2045. }
  2046. enum WorkerReplyType {
  2047. SUCCESS = 0,
  2048. UNKNOWN_ERROR = 1,
  2049. }
  2050. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  2051. private _scene;
  2052. private _scaledPosition;
  2053. private _scaledVelocity;
  2054. private _collisionsCallbackArray;
  2055. private _init;
  2056. private _runningUpdated;
  2057. private _runningCollisionTask;
  2058. private _worker;
  2059. private _addUpdateMeshesList;
  2060. private _addUpdateGeometriesList;
  2061. private _toRemoveMeshesArray;
  2062. private _toRemoveGeometryArray;
  2063. constructor();
  2064. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  2065. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  2066. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  2067. init(scene: Scene): void;
  2068. destroy(): void;
  2069. onMeshAdded(mesh: AbstractMesh): void;
  2070. onMeshUpdated: (mesh: AbstractMesh) => void;
  2071. onMeshRemoved(mesh: AbstractMesh): void;
  2072. onGeometryAdded(geometry: Geometry): void;
  2073. onGeometryUpdated: (geometry: Geometry) => void;
  2074. onGeometryDeleted(geometry: Geometry): void;
  2075. private _afterRender;
  2076. private _onMessageFromWorker;
  2077. }
  2078. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  2079. private _scene;
  2080. private _scaledPosition;
  2081. private _scaledVelocity;
  2082. private _finalPosition;
  2083. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  2084. init(scene: Scene): void;
  2085. destroy(): void;
  2086. onMeshAdded(mesh: AbstractMesh): void;
  2087. onMeshUpdated(mesh: AbstractMesh): void;
  2088. onMeshRemoved(mesh: AbstractMesh): void;
  2089. onGeometryAdded(geometry: Geometry): void;
  2090. onGeometryUpdated(geometry: Geometry): void;
  2091. onGeometryDeleted(geometry: Geometry): void;
  2092. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  2093. }
  2094. }
  2095. declare module BABYLON {
  2096. var WorkerIncluded: boolean;
  2097. class CollisionCache {
  2098. private _meshes;
  2099. private _geometries;
  2100. getMeshes(): {
  2101. [n: number]: SerializedMesh;
  2102. };
  2103. getGeometries(): {
  2104. [s: number]: SerializedGeometry;
  2105. };
  2106. getMesh(id: any): SerializedMesh;
  2107. addMesh(mesh: SerializedMesh): void;
  2108. getGeometry(id: string): SerializedGeometry;
  2109. addGeometry(geometry: SerializedGeometry): void;
  2110. }
  2111. class CollideWorker {
  2112. collider: Collider;
  2113. private _collisionCache;
  2114. private finalPosition;
  2115. private collisionsScalingMatrix;
  2116. private collisionTranformationMatrix;
  2117. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  2118. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId?: number): void;
  2119. private checkCollision(mesh);
  2120. private processCollisionsForSubMeshes(transformMatrix, mesh);
  2121. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  2122. private checkSubmeshCollision(subMesh);
  2123. }
  2124. interface ICollisionDetector {
  2125. onInit(payload: InitPayload): void;
  2126. onUpdate(payload: UpdatePayload): void;
  2127. onCollision(payload: CollidePayload): void;
  2128. }
  2129. class CollisionDetectorTransferable implements ICollisionDetector {
  2130. private _collisionCache;
  2131. onInit(payload: InitPayload): void;
  2132. onUpdate(payload: UpdatePayload): void;
  2133. onCollision(payload: CollidePayload): void;
  2134. }
  2135. }
  2136. declare module BABYLON {
  2137. class IntersectionInfo {
  2138. bu: number;
  2139. bv: number;
  2140. distance: number;
  2141. faceId: number;
  2142. subMeshId: number;
  2143. constructor(bu: number, bv: number, distance: number);
  2144. }
  2145. class PickingInfo {
  2146. hit: boolean;
  2147. distance: number;
  2148. pickedPoint: Vector3;
  2149. pickedMesh: AbstractMesh;
  2150. bu: number;
  2151. bv: number;
  2152. faceId: number;
  2153. subMeshId: number;
  2154. getNormal(useWorldCoordinates?: boolean): Vector3;
  2155. getTextureCoordinates(): Vector2;
  2156. }
  2157. }
  2158. declare module BABYLON {
  2159. class BoundingBox {
  2160. minimum: Vector3;
  2161. maximum: Vector3;
  2162. vectors: Vector3[];
  2163. center: Vector3;
  2164. extendSize: Vector3;
  2165. directions: Vector3[];
  2166. vectorsWorld: Vector3[];
  2167. minimumWorld: Vector3;
  2168. maximumWorld: Vector3;
  2169. private _worldMatrix;
  2170. constructor(minimum: Vector3, maximum: Vector3);
  2171. getWorldMatrix(): Matrix;
  2172. _update(world: Matrix): void;
  2173. isInFrustum(frustumPlanes: Plane[]): boolean;
  2174. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2175. intersectsPoint(point: Vector3): boolean;
  2176. intersectsSphere(sphere: BoundingSphere): boolean;
  2177. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  2178. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  2179. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  2180. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2181. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2182. }
  2183. }
  2184. declare module BABYLON {
  2185. class BoundingInfo {
  2186. minimum: Vector3;
  2187. maximum: Vector3;
  2188. boundingBox: BoundingBox;
  2189. boundingSphere: BoundingSphere;
  2190. constructor(minimum: Vector3, maximum: Vector3);
  2191. _update(world: Matrix): void;
  2192. isInFrustum(frustumPlanes: Plane[]): boolean;
  2193. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2194. _checkCollision(collider: Collider): boolean;
  2195. intersectsPoint(point: Vector3): boolean;
  2196. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  2197. }
  2198. }
  2199. declare module BABYLON {
  2200. class BoundingSphere {
  2201. minimum: Vector3;
  2202. maximum: Vector3;
  2203. center: Vector3;
  2204. radius: number;
  2205. centerWorld: Vector3;
  2206. radiusWorld: number;
  2207. private _tempRadiusVector;
  2208. constructor(minimum: Vector3, maximum: Vector3);
  2209. _update(world: Matrix): void;
  2210. isInFrustum(frustumPlanes: Plane[]): boolean;
  2211. intersectsPoint(point: Vector3): boolean;
  2212. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  2213. }
  2214. }
  2215. declare module BABYLON {
  2216. interface IOctreeContainer<T> {
  2217. blocks: Array<OctreeBlock<T>>;
  2218. }
  2219. class Octree<T> {
  2220. maxDepth: number;
  2221. blocks: Array<OctreeBlock<T>>;
  2222. dynamicContent: T[];
  2223. private _maxBlockCapacity;
  2224. private _selectionContent;
  2225. private _creationFunc;
  2226. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  2227. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  2228. addMesh(entry: T): void;
  2229. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  2230. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  2231. intersectsRay(ray: Ray): SmartArray<T>;
  2232. 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;
  2233. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  2234. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  2235. }
  2236. }
  2237. declare module BABYLON {
  2238. class OctreeBlock<T> {
  2239. entries: T[];
  2240. blocks: Array<OctreeBlock<T>>;
  2241. private _depth;
  2242. private _maxDepth;
  2243. private _capacity;
  2244. private _minPoint;
  2245. private _maxPoint;
  2246. private _boundingVectors;
  2247. private _creationFunc;
  2248. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  2249. capacity: number;
  2250. minPoint: Vector3;
  2251. maxPoint: Vector3;
  2252. addEntry(entry: T): void;
  2253. addEntries(entries: T[]): void;
  2254. select(frustumPlanes: Plane[], selection: SmartArray<T>, allowDuplicate?: boolean): void;
  2255. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray<T>, allowDuplicate?: boolean): void;
  2256. intersectsRay(ray: Ray, selection: SmartArray<T>): void;
  2257. createInnerBlocks(): void;
  2258. }
  2259. }
  2260. declare module BABYLON {
  2261. class DebugLayer {
  2262. private _scene;
  2263. private _camera;
  2264. private _transformationMatrix;
  2265. private _enabled;
  2266. private _labelsEnabled;
  2267. private _displayStatistics;
  2268. private _displayTree;
  2269. private _displayLogs;
  2270. private _globalDiv;
  2271. private _statsDiv;
  2272. private _statsSubsetDiv;
  2273. private _optionsDiv;
  2274. private _optionsSubsetDiv;
  2275. private _logDiv;
  2276. private _logSubsetDiv;
  2277. private _treeDiv;
  2278. private _treeSubsetDiv;
  2279. private _drawingCanvas;
  2280. private _drawingContext;
  2281. private _syncPositions;
  2282. private _syncData;
  2283. private _syncUI;
  2284. private _onCanvasClick;
  2285. private _clickPosition;
  2286. private _ratio;
  2287. private _identityMatrix;
  2288. private _showUI;
  2289. private _needToRefreshMeshesTree;
  2290. shouldDisplayLabel: (node: Node) => boolean;
  2291. shouldDisplayAxis: (mesh: Mesh) => boolean;
  2292. axisRatio: number;
  2293. accentColor: string;
  2294. customStatsFunction: () => string;
  2295. constructor(scene: Scene);
  2296. private _refreshMeshesTreeContent();
  2297. private _renderSingleAxis(zero, unit, unitText, label, color);
  2298. private _renderAxis(projectedPosition, mesh, globalViewport);
  2299. private _renderLabel(text, projectedPosition, labelOffset, onClick, getFillStyle);
  2300. private _isClickInsideRect(x, y, width, height);
  2301. isVisible(): boolean;
  2302. hide(): void;
  2303. show(showUI?: boolean, camera?: Camera): void;
  2304. private _clearLabels();
  2305. private _generateheader(root, text);
  2306. private _generateTexBox(root, title, color);
  2307. private _generateAdvancedCheckBox(root, leftTitle, rightTitle, initialState, task, tag?);
  2308. private _generateCheckBox(root, title, initialState, task, tag?);
  2309. private _generateButton(root, title, task, tag?);
  2310. private _generateRadio(root, title, name, initialState, task, tag?);
  2311. private _generateDOMelements();
  2312. private _displayStats();
  2313. }
  2314. }
  2315. declare module BABYLON {
  2316. class Layer {
  2317. name: string;
  2318. texture: Texture;
  2319. isBackground: boolean;
  2320. color: Color4;
  2321. onDispose: () => void;
  2322. private _scene;
  2323. private _vertexDeclaration;
  2324. private _vertexStrideSize;
  2325. private _vertexBuffer;
  2326. private _indexBuffer;
  2327. private _effect;
  2328. constructor(name: string, imgUrl: string, scene: Scene, isBackground?: boolean, color?: Color4);
  2329. render(): void;
  2330. dispose(): void;
  2331. }
  2332. }
  2333. declare module BABYLON {
  2334. class LensFlare {
  2335. size: number;
  2336. position: number;
  2337. color: Color3;
  2338. texture: Texture;
  2339. private _system;
  2340. constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem);
  2341. dispose: () => void;
  2342. }
  2343. }
  2344. declare module BABYLON {
  2345. class LensFlareSystem {
  2346. name: string;
  2347. lensFlares: LensFlare[];
  2348. borderLimit: number;
  2349. meshesSelectionPredicate: (mesh: Mesh) => boolean;
  2350. private _scene;
  2351. private _emitter;
  2352. private _vertexDeclaration;
  2353. private _vertexStrideSize;
  2354. private _vertexBuffer;
  2355. private _indexBuffer;
  2356. private _effect;
  2357. private _positionX;
  2358. private _positionY;
  2359. private _isEnabled;
  2360. constructor(name: string, emitter: any, scene: Scene);
  2361. isEnabled: boolean;
  2362. getScene(): Scene;
  2363. getEmitter(): any;
  2364. getEmitterPosition(): Vector3;
  2365. computeEffectivePosition(globalViewport: Viewport): boolean;
  2366. _isVisible(): boolean;
  2367. render(): boolean;
  2368. dispose(): void;
  2369. }
  2370. }
  2371. declare module BABYLON {
  2372. class DirectionalLight extends Light implements IShadowLight {
  2373. direction: Vector3;
  2374. position: Vector3;
  2375. private _transformedDirection;
  2376. transformedPosition: Vector3;
  2377. private _worldMatrix;
  2378. shadowOrthoScale: number;
  2379. constructor(name: string, direction: Vector3, scene: Scene);
  2380. getAbsolutePosition(): Vector3;
  2381. setDirectionToTarget(target: Vector3): Vector3;
  2382. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2383. supportsVSM(): boolean;
  2384. needRefreshPerFrame(): boolean;
  2385. computeTransformedPosition(): boolean;
  2386. transferToEffect(effect: Effect, directionUniformName: string): void;
  2387. _getWorldMatrix(): Matrix;
  2388. }
  2389. }
  2390. declare module BABYLON {
  2391. class HemisphericLight extends Light {
  2392. direction: Vector3;
  2393. groundColor: Color3;
  2394. private _worldMatrix;
  2395. constructor(name: string, direction: Vector3, scene: Scene);
  2396. setDirectionToTarget(target: Vector3): Vector3;
  2397. getShadowGenerator(): ShadowGenerator;
  2398. transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void;
  2399. _getWorldMatrix(): Matrix;
  2400. }
  2401. }
  2402. declare module BABYLON {
  2403. interface IShadowLight {
  2404. position: Vector3;
  2405. direction: Vector3;
  2406. transformedPosition: Vector3;
  2407. name: string;
  2408. computeTransformedPosition(): boolean;
  2409. getScene(): Scene;
  2410. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2411. supportsVSM(): boolean;
  2412. needRefreshPerFrame(): boolean;
  2413. _shadowGenerator: ShadowGenerator;
  2414. }
  2415. class Light extends Node {
  2416. diffuse: Color3;
  2417. specular: Color3;
  2418. intensity: number;
  2419. range: number;
  2420. includeOnlyWithLayerMask: number;
  2421. includedOnlyMeshes: AbstractMesh[];
  2422. excludedMeshes: AbstractMesh[];
  2423. excludeWithLayerMask: number;
  2424. _shadowGenerator: ShadowGenerator;
  2425. private _parentedWorldMatrix;
  2426. _excludedMeshesIds: string[];
  2427. _includedOnlyMeshesIds: string[];
  2428. constructor(name: string, scene: Scene);
  2429. getShadowGenerator(): ShadowGenerator;
  2430. getAbsolutePosition(): Vector3;
  2431. transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void;
  2432. _getWorldMatrix(): Matrix;
  2433. canAffectMesh(mesh: AbstractMesh): boolean;
  2434. getWorldMatrix(): Matrix;
  2435. dispose(): void;
  2436. }
  2437. }
  2438. declare module BABYLON {
  2439. class PointLight extends Light {
  2440. position: Vector3;
  2441. private _worldMatrix;
  2442. private _transformedPosition;
  2443. constructor(name: string, position: Vector3, scene: Scene);
  2444. getAbsolutePosition(): Vector3;
  2445. transferToEffect(effect: Effect, positionUniformName: string): void;
  2446. getShadowGenerator(): ShadowGenerator;
  2447. _getWorldMatrix(): Matrix;
  2448. }
  2449. }
  2450. declare module BABYLON {
  2451. class SpotLight extends Light implements IShadowLight {
  2452. position: Vector3;
  2453. direction: Vector3;
  2454. angle: number;
  2455. exponent: number;
  2456. transformedPosition: Vector3;
  2457. private _transformedDirection;
  2458. private _worldMatrix;
  2459. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  2460. getAbsolutePosition(): Vector3;
  2461. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2462. supportsVSM(): boolean;
  2463. needRefreshPerFrame(): boolean;
  2464. setDirectionToTarget(target: Vector3): Vector3;
  2465. computeTransformedPosition(): boolean;
  2466. transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void;
  2467. _getWorldMatrix(): Matrix;
  2468. }
  2469. }
  2470. declare module BABYLON {
  2471. class ShadowGenerator {
  2472. private static _FILTER_NONE;
  2473. private static _FILTER_VARIANCESHADOWMAP;
  2474. private static _FILTER_POISSONSAMPLING;
  2475. private static _FILTER_BLURVARIANCESHADOWMAP;
  2476. static FILTER_NONE: number;
  2477. static FILTER_VARIANCESHADOWMAP: number;
  2478. static FILTER_POISSONSAMPLING: number;
  2479. static FILTER_BLURVARIANCESHADOWMAP: number;
  2480. private _filter;
  2481. blurScale: number;
  2482. private _blurBoxOffset;
  2483. private _bias;
  2484. bias: number;
  2485. blurBoxOffset: number;
  2486. filter: number;
  2487. useVarianceShadowMap: boolean;
  2488. usePoissonSampling: boolean;
  2489. useBlurVarianceShadowMap: boolean;
  2490. private _light;
  2491. private _scene;
  2492. private _shadowMap;
  2493. private _shadowMap2;
  2494. private _darkness;
  2495. private _transparencyShadow;
  2496. private _effect;
  2497. private _viewMatrix;
  2498. private _projectionMatrix;
  2499. private _transformMatrix;
  2500. private _worldViewProjection;
  2501. private _cachedPosition;
  2502. private _cachedDirection;
  2503. private _cachedDefines;
  2504. private _currentRenderID;
  2505. private _downSamplePostprocess;
  2506. private _boxBlurPostprocess;
  2507. private _mapSize;
  2508. constructor(mapSize: number, light: IShadowLight);
  2509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  2510. getShadowMap(): RenderTargetTexture;
  2511. getShadowMapForRendering(): RenderTargetTexture;
  2512. getLight(): IShadowLight;
  2513. getTransformMatrix(): Matrix;
  2514. getDarkness(): number;
  2515. setDarkness(darkness: number): void;
  2516. setTransparencyShadow(hasShadow: boolean): void;
  2517. private _packHalf(depth);
  2518. dispose(): void;
  2519. }
  2520. }
  2521. declare module BABYLON {
  2522. interface ISceneLoaderPlugin {
  2523. extensions: string;
  2524. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
  2525. load: (scene: Scene, data: string, rootUrl: string) => boolean;
  2526. }
  2527. class SceneLoader {
  2528. private static _ForceFullSceneLoadingForIncremental;
  2529. private static _ShowLoadingScreen;
  2530. static ForceFullSceneLoadingForIncremental: boolean;
  2531. static ShowLoadingScreen: boolean;
  2532. private static _registeredPlugins;
  2533. private static _getPluginForFilename(sceneFilename);
  2534. static RegisterPlugin(plugin: ISceneLoaderPlugin): void;
  2535. 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;
  2536. /**
  2537. * Load a scene
  2538. * @param rootUrl a string that defines the root url for scene and resources
  2539. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  2540. * @param engine is the instance of BABYLON.Engine to use to create the scene
  2541. */
  2542. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  2543. /**
  2544. * Append a scene
  2545. * @param rootUrl a string that defines the root url for scene and resources
  2546. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  2547. * @param scene is the instance of BABYLON.Scene to append to
  2548. */
  2549. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  2550. }
  2551. }
  2552. declare module BABYLON.Internals {
  2553. }
  2554. declare module BABYLON {
  2555. class EffectFallbacks {
  2556. private _defines;
  2557. private _currentRank;
  2558. private _maxRank;
  2559. addFallback(rank: number, define: string): void;
  2560. isMoreFallbacks: boolean;
  2561. reduce(currentDefines: string): string;
  2562. }
  2563. class Effect {
  2564. name: any;
  2565. defines: string;
  2566. onCompiled: (effect: Effect) => void;
  2567. onError: (effect: Effect, errors: string) => void;
  2568. onBind: (effect: Effect) => void;
  2569. private _engine;
  2570. private _uniformsNames;
  2571. private _samplers;
  2572. private _isReady;
  2573. private _compilationError;
  2574. private _attributesNames;
  2575. private _attributes;
  2576. private _uniforms;
  2577. _key: string;
  2578. private _program;
  2579. private _valueCache;
  2580. 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);
  2581. isReady(): boolean;
  2582. getProgram(): WebGLProgram;
  2583. getAttributesNames(): string[];
  2584. getAttributeLocation(index: number): number;
  2585. getAttributeLocationByName(name: string): number;
  2586. getAttributesCount(): number;
  2587. getUniformIndex(uniformName: string): number;
  2588. getUniform(uniformName: string): WebGLUniformLocation;
  2589. getSamplers(): string[];
  2590. getCompilationError(): string;
  2591. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  2592. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  2593. private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
  2594. _bindTexture(channel: string, texture: WebGLTexture): void;
  2595. setTexture(channel: string, texture: BaseTexture): void;
  2596. setTextureFromPostProcess(channel: string, postProcess: PostProcess): void;
  2597. _cacheFloat2(uniformName: string, x: number, y: number): void;
  2598. _cacheFloat3(uniformName: string, x: number, y: number, z: number): void;
  2599. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  2600. setArray(uniformName: string, array: number[]): Effect;
  2601. setArray2(uniformName: string, array: number[]): Effect;
  2602. setArray3(uniformName: string, array: number[]): Effect;
  2603. setArray4(uniformName: string, array: number[]): Effect;
  2604. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  2605. setMatrix(uniformName: string, matrix: Matrix): Effect;
  2606. setFloat(uniformName: string, value: number): Effect;
  2607. setBool(uniformName: string, bool: boolean): Effect;
  2608. setVector2(uniformName: string, vector2: Vector2): Effect;
  2609. setFloat2(uniformName: string, x: number, y: number): Effect;
  2610. setVector3(uniformName: string, vector3: Vector3): Effect;
  2611. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  2612. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  2613. setColor3(uniformName: string, color3: Color3): Effect;
  2614. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  2615. static ShadersStore: {};
  2616. }
  2617. }
  2618. declare module BABYLON {
  2619. class Material {
  2620. name: string;
  2621. private static _TriangleFillMode;
  2622. private static _WireFrameFillMode;
  2623. private static _PointFillMode;
  2624. static TriangleFillMode: number;
  2625. static WireFrameFillMode: number;
  2626. static PointFillMode: number;
  2627. id: string;
  2628. checkReadyOnEveryCall: boolean;
  2629. checkReadyOnlyOnce: boolean;
  2630. state: string;
  2631. alpha: number;
  2632. backFaceCulling: boolean;
  2633. onCompiled: (effect: Effect) => void;
  2634. onError: (effect: Effect, errors: string) => void;
  2635. onDispose: () => void;
  2636. onBind: (material: Material, mesh: Mesh) => void;
  2637. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  2638. _effect: Effect;
  2639. _wasPreviouslyReady: boolean;
  2640. private _scene;
  2641. private _fillMode;
  2642. pointSize: number;
  2643. zOffset: number;
  2644. wireframe: boolean;
  2645. pointsCloud: boolean;
  2646. fillMode: number;
  2647. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  2648. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2649. getEffect(): Effect;
  2650. getScene(): Scene;
  2651. needAlphaBlending(): boolean;
  2652. needAlphaTesting(): boolean;
  2653. getAlphaTestTexture(): BaseTexture;
  2654. trackCreation(onCompiled: (effect: Effect) => void, onError: (effect: Effect, errors: string) => void): void;
  2655. _preBind(): void;
  2656. bind(world: Matrix, mesh?: Mesh): void;
  2657. bindOnlyWorldMatrix(world: Matrix): void;
  2658. unbind(): void;
  2659. dispose(forceDisposeEffect?: boolean): void;
  2660. }
  2661. }
  2662. declare module BABYLON {
  2663. class MultiMaterial extends Material {
  2664. subMaterials: Material[];
  2665. constructor(name: string, scene: Scene);
  2666. getSubMaterial(index: any): Material;
  2667. isReady(mesh?: AbstractMesh): boolean;
  2668. clone(name: string): MultiMaterial;
  2669. }
  2670. }
  2671. declare module BABYLON {
  2672. class ShaderMaterial extends Material {
  2673. private _shaderPath;
  2674. private _options;
  2675. private _textures;
  2676. private _floats;
  2677. private _floatsArrays;
  2678. private _colors3;
  2679. private _colors4;
  2680. private _vectors2;
  2681. private _vectors3;
  2682. private _matrices;
  2683. private _cachedWorldViewMatrix;
  2684. private _renderId;
  2685. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  2686. needAlphaBlending(): boolean;
  2687. needAlphaTesting(): boolean;
  2688. private _checkUniform(uniformName);
  2689. setTexture(name: string, texture: Texture): ShaderMaterial;
  2690. setFloat(name: string, value: number): ShaderMaterial;
  2691. setFloats(name: string, value: number[]): ShaderMaterial;
  2692. setColor3(name: string, value: Color3): ShaderMaterial;
  2693. setColor4(name: string, value: Color4): ShaderMaterial;
  2694. setVector2(name: string, value: Vector2): ShaderMaterial;
  2695. setVector3(name: string, value: Vector3): ShaderMaterial;
  2696. setMatrix(name: string, value: Matrix): ShaderMaterial;
  2697. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2698. bindOnlyWorldMatrix(world: Matrix): void;
  2699. bind(world: Matrix, mesh?: Mesh): void;
  2700. dispose(forceDisposeEffect?: boolean): void;
  2701. }
  2702. }
  2703. declare module BABYLON {
  2704. class FresnelParameters {
  2705. isEnabled: boolean;
  2706. leftColor: Color3;
  2707. rightColor: Color3;
  2708. bias: number;
  2709. power: number;
  2710. }
  2711. class StandardMaterial extends Material {
  2712. diffuseTexture: BaseTexture;
  2713. ambientTexture: BaseTexture;
  2714. opacityTexture: BaseTexture;
  2715. reflectionTexture: BaseTexture;
  2716. emissiveTexture: BaseTexture;
  2717. specularTexture: BaseTexture;
  2718. bumpTexture: BaseTexture;
  2719. ambientColor: Color3;
  2720. diffuseColor: Color3;
  2721. specularColor: Color3;
  2722. specularPower: number;
  2723. emissiveColor: Color3;
  2724. useAlphaFromDiffuseTexture: boolean;
  2725. useSpecularOverAlpha: boolean;
  2726. fogEnabled: boolean;
  2727. diffuseFresnelParameters: FresnelParameters;
  2728. opacityFresnelParameters: FresnelParameters;
  2729. reflectionFresnelParameters: FresnelParameters;
  2730. emissiveFresnelParameters: FresnelParameters;
  2731. private _cachedDefines;
  2732. private _renderTargets;
  2733. private _worldViewProjectionMatrix;
  2734. private _globalAmbientColor;
  2735. private _scaledDiffuse;
  2736. private _scaledSpecular;
  2737. private _renderId;
  2738. constructor(name: string, scene: Scene);
  2739. needAlphaBlending(): boolean;
  2740. needAlphaTesting(): boolean;
  2741. private _shouldUseAlphaFromDiffuseTexture();
  2742. getAlphaTestTexture(): BaseTexture;
  2743. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2744. unbind(): void;
  2745. bindOnlyWorldMatrix(world: Matrix): void;
  2746. bind(world: Matrix, mesh?: Mesh): void;
  2747. getAnimatables(): IAnimatable[];
  2748. dispose(forceDisposeEffect?: boolean): void;
  2749. clone(name: string): StandardMaterial;
  2750. static DiffuseTextureEnabled: boolean;
  2751. static AmbientTextureEnabled: boolean;
  2752. static OpacityTextureEnabled: boolean;
  2753. static ReflectionTextureEnabled: boolean;
  2754. static EmissiveTextureEnabled: boolean;
  2755. static SpecularTextureEnabled: boolean;
  2756. static BumpTextureEnabled: boolean;
  2757. static FresnelEnabled: boolean;
  2758. }
  2759. }
  2760. declare module BABYLON {
  2761. class BaseTexture {
  2762. name: string;
  2763. delayLoadState: number;
  2764. hasAlpha: boolean;
  2765. getAlphaFromRGB: boolean;
  2766. level: number;
  2767. isCube: boolean;
  2768. isRenderTarget: boolean;
  2769. animations: Animation[];
  2770. onDispose: () => void;
  2771. coordinatesIndex: number;
  2772. coordinatesMode: number;
  2773. wrapU: number;
  2774. wrapV: number;
  2775. anisotropicFilteringLevel: number;
  2776. _cachedAnisotropicFilteringLevel: number;
  2777. private _scene;
  2778. _texture: WebGLTexture;
  2779. constructor(scene: Scene);
  2780. getScene(): Scene;
  2781. getTextureMatrix(): Matrix;
  2782. getReflectionTextureMatrix(): Matrix;
  2783. getInternalTexture(): WebGLTexture;
  2784. isReady(): boolean;
  2785. getSize(): ISize;
  2786. getBaseSize(): ISize;
  2787. scale(ratio: number): void;
  2788. canRescale: boolean;
  2789. _removeFromCache(url: string, noMipmap: boolean): void;
  2790. _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture;
  2791. delayLoad(): void;
  2792. releaseInternalTexture(): void;
  2793. clone(): BaseTexture;
  2794. dispose(): void;
  2795. }
  2796. }
  2797. declare module BABYLON {
  2798. class CubeTexture extends BaseTexture {
  2799. url: string;
  2800. coordinatesMode: number;
  2801. private _noMipmap;
  2802. private _extensions;
  2803. private _textureMatrix;
  2804. constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean);
  2805. clone(): CubeTexture;
  2806. delayLoad(): void;
  2807. getReflectionTextureMatrix(): Matrix;
  2808. }
  2809. }
  2810. declare module BABYLON {
  2811. class DynamicTexture extends Texture {
  2812. private _generateMipMaps;
  2813. private _canvas;
  2814. private _context;
  2815. constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number);
  2816. canRescale: boolean;
  2817. scale(ratio: number): void;
  2818. getContext(): CanvasRenderingContext2D;
  2819. clear(): void;
  2820. update(invertY?: boolean): void;
  2821. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  2822. clone(): DynamicTexture;
  2823. }
  2824. }
  2825. declare module BABYLON {
  2826. class MirrorTexture extends RenderTargetTexture {
  2827. mirrorPlane: Plane;
  2828. private _transformMatrix;
  2829. private _mirrorMatrix;
  2830. private _savedViewMatrix;
  2831. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  2832. clone(): MirrorTexture;
  2833. }
  2834. }
  2835. declare module BABYLON {
  2836. class RawTexture extends Texture {
  2837. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  2838. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2839. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2840. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2841. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2842. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2843. }
  2844. }
  2845. declare module BABYLON {
  2846. class RenderTargetTexture extends Texture {
  2847. renderList: AbstractMesh[];
  2848. renderParticles: boolean;
  2849. renderSprites: boolean;
  2850. coordinatesMode: number;
  2851. onBeforeRender: () => void;
  2852. onAfterRender: () => void;
  2853. onAfterUnbind: () => void;
  2854. onClear: (engine: Engine) => void;
  2855. activeCamera: Camera;
  2856. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  2857. private _size;
  2858. _generateMipMaps: boolean;
  2859. private _renderingManager;
  2860. _waitingRenderList: string[];
  2861. private _doNotChangeAspectRatio;
  2862. private _currentRefreshId;
  2863. private _refreshRate;
  2864. constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number);
  2865. resetRefreshCounter(): void;
  2866. refreshRate: number;
  2867. _shouldRender(): boolean;
  2868. isReady(): boolean;
  2869. getRenderSize(): number;
  2870. canRescale: boolean;
  2871. scale(ratio: number): void;
  2872. resize(size: any, generateMipMaps?: boolean): void;
  2873. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  2874. clone(): RenderTargetTexture;
  2875. }
  2876. }
  2877. declare module BABYLON {
  2878. class Texture extends BaseTexture {
  2879. static NEAREST_SAMPLINGMODE: number;
  2880. static BILINEAR_SAMPLINGMODE: number;
  2881. static TRILINEAR_SAMPLINGMODE: number;
  2882. static EXPLICIT_MODE: number;
  2883. static SPHERICAL_MODE: number;
  2884. static PLANAR_MODE: number;
  2885. static CUBIC_MODE: number;
  2886. static PROJECTION_MODE: number;
  2887. static SKYBOX_MODE: number;
  2888. static CLAMP_ADDRESSMODE: number;
  2889. static WRAP_ADDRESSMODE: number;
  2890. static MIRROR_ADDRESSMODE: number;
  2891. url: string;
  2892. uOffset: number;
  2893. vOffset: number;
  2894. uScale: number;
  2895. vScale: number;
  2896. uAng: number;
  2897. vAng: number;
  2898. wAng: number;
  2899. private _noMipmap;
  2900. _invertY: boolean;
  2901. private _rowGenerationMatrix;
  2902. private _cachedTextureMatrix;
  2903. private _projectionModeMatrix;
  2904. private _t0;
  2905. private _t1;
  2906. private _t2;
  2907. private _cachedUOffset;
  2908. private _cachedVOffset;
  2909. private _cachedUScale;
  2910. private _cachedVScale;
  2911. private _cachedUAng;
  2912. private _cachedVAng;
  2913. private _cachedWAng;
  2914. private _cachedCoordinatesMode;
  2915. _samplingMode: number;
  2916. private _buffer;
  2917. private _deleteBuffer;
  2918. constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean);
  2919. delayLoad(): void;
  2920. updateSamplingMode(samplingMode: number): void;
  2921. private _prepareRowForTextureGeneration(x, y, z, t);
  2922. getTextureMatrix(): Matrix;
  2923. getReflectionTextureMatrix(): Matrix;
  2924. clone(): Texture;
  2925. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void): Texture;
  2926. }
  2927. }
  2928. declare module BABYLON {
  2929. class VideoTexture extends Texture {
  2930. video: HTMLVideoElement;
  2931. private _autoLaunch;
  2932. private _lastUpdate;
  2933. constructor(name: string, urls: string[], scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  2934. update(): boolean;
  2935. }
  2936. }
  2937. declare module BABYLON {
  2938. class CustomProceduralTexture extends ProceduralTexture {
  2939. private _animate;
  2940. private _time;
  2941. private _config;
  2942. private _texturePath;
  2943. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2944. private loadJson(jsonUrl);
  2945. isReady(): boolean;
  2946. render(useCameraPostProcess?: boolean): void;
  2947. updateTextures(): void;
  2948. updateShaderUniforms(): void;
  2949. animate: boolean;
  2950. }
  2951. }
  2952. declare module BABYLON {
  2953. class ProceduralTexture extends Texture {
  2954. private _size;
  2955. _generateMipMaps: boolean;
  2956. private _doNotChangeAspectRatio;
  2957. private _currentRefreshId;
  2958. private _refreshRate;
  2959. private _vertexBuffer;
  2960. private _indexBuffer;
  2961. private _effect;
  2962. private _vertexDeclaration;
  2963. private _vertexStrideSize;
  2964. private _uniforms;
  2965. private _samplers;
  2966. private _fragment;
  2967. _textures: Texture[];
  2968. private _floats;
  2969. private _floatsArrays;
  2970. private _colors3;
  2971. private _colors4;
  2972. private _vectors2;
  2973. private _vectors3;
  2974. private _matrices;
  2975. private _fallbackTexture;
  2976. private _fallbackTextureUsed;
  2977. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2978. reset(): void;
  2979. isReady(): boolean;
  2980. resetRefreshCounter(): void;
  2981. setFragment(fragment: any): void;
  2982. refreshRate: number;
  2983. _shouldRender(): boolean;
  2984. getRenderSize(): number;
  2985. resize(size: any, generateMipMaps: any): void;
  2986. private _checkUniform(uniformName);
  2987. setTexture(name: string, texture: Texture): ProceduralTexture;
  2988. setFloat(name: string, value: number): ProceduralTexture;
  2989. setFloats(name: string, value: number[]): ProceduralTexture;
  2990. setColor3(name: string, value: Color3): ProceduralTexture;
  2991. setColor4(name: string, value: Color4): ProceduralTexture;
  2992. setVector2(name: string, value: Vector2): ProceduralTexture;
  2993. setVector3(name: string, value: Vector3): ProceduralTexture;
  2994. setMatrix(name: string, value: Matrix): ProceduralTexture;
  2995. render(useCameraPostProcess?: boolean): void;
  2996. clone(): ProceduralTexture;
  2997. dispose(): void;
  2998. }
  2999. }
  3000. declare module BABYLON {
  3001. class WoodProceduralTexture extends ProceduralTexture {
  3002. private _ampScale;
  3003. private _woodColor;
  3004. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3005. updateShaderUniforms(): void;
  3006. ampScale: number;
  3007. woodColor: Color3;
  3008. }
  3009. class FireProceduralTexture extends ProceduralTexture {
  3010. private _time;
  3011. private _speed;
  3012. private _autoGenerateTime;
  3013. private _fireColors;
  3014. private _alphaThreshold;
  3015. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3016. updateShaderUniforms(): void;
  3017. render(useCameraPostProcess?: boolean): void;
  3018. static PurpleFireColors: Color3[];
  3019. static GreenFireColors: Color3[];
  3020. static RedFireColors: Color3[];
  3021. static BlueFireColors: Color3[];
  3022. fireColors: Color3[];
  3023. time: number;
  3024. speed: Vector2;
  3025. alphaThreshold: number;
  3026. }
  3027. class CloudProceduralTexture extends ProceduralTexture {
  3028. private _skyColor;
  3029. private _cloudColor;
  3030. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3031. updateShaderUniforms(): void;
  3032. skyColor: Color3;
  3033. cloudColor: Color3;
  3034. }
  3035. class GrassProceduralTexture extends ProceduralTexture {
  3036. private _grassColors;
  3037. private _herb1;
  3038. private _herb2;
  3039. private _herb3;
  3040. private _groundColor;
  3041. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3042. updateShaderUniforms(): void;
  3043. grassColors: Color3[];
  3044. groundColor: Color3;
  3045. }
  3046. class RoadProceduralTexture extends ProceduralTexture {
  3047. private _roadColor;
  3048. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3049. updateShaderUniforms(): void;
  3050. roadColor: Color3;
  3051. }
  3052. class BrickProceduralTexture extends ProceduralTexture {
  3053. private _numberOfBricksHeight;
  3054. private _numberOfBricksWidth;
  3055. private _jointColor;
  3056. private _brickColor;
  3057. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3058. updateShaderUniforms(): void;
  3059. numberOfBricksHeight: number;
  3060. numberOfBricksWidth: number;
  3061. jointColor: Color3;
  3062. brickColor: Color3;
  3063. }
  3064. class MarbleProceduralTexture extends ProceduralTexture {
  3065. private _numberOfTilesHeight;
  3066. private _numberOfTilesWidth;
  3067. private _amplitude;
  3068. private _marbleColor;
  3069. private _jointColor;
  3070. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  3071. updateShaderUniforms(): void;
  3072. numberOfTilesHeight: number;
  3073. numberOfTilesWidth: number;
  3074. jointColor: Color3;
  3075. marbleColor: Color3;
  3076. }
  3077. }
  3078. declare module BABYLON {
  3079. class Color3 {
  3080. r: number;
  3081. g: number;
  3082. b: number;
  3083. constructor(r?: number, g?: number, b?: number);
  3084. toString(): string;
  3085. toArray(array: number[], index?: number): Color3;
  3086. toColor4(alpha?: number): Color4;
  3087. asArray(): number[];
  3088. toLuminance(): number;
  3089. multiply(otherColor: Color3): Color3;
  3090. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  3091. equals(otherColor: Color3): boolean;
  3092. scale(scale: number): Color3;
  3093. scaleToRef(scale: number, result: Color3): Color3;
  3094. add(otherColor: Color3): Color3;
  3095. addToRef(otherColor: Color3, result: Color3): Color3;
  3096. subtract(otherColor: Color3): Color3;
  3097. subtractToRef(otherColor: Color3, result: Color3): Color3;
  3098. clone(): Color3;
  3099. copyFrom(source: Color3): Color3;
  3100. copyFromFloats(r: number, g: number, b: number): Color3;
  3101. static FromArray(array: number[], offset?: number): Color3;
  3102. static FromInts(r: number, g: number, b: number): Color3;
  3103. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  3104. static Red(): Color3;
  3105. static Green(): Color3;
  3106. static Blue(): Color3;
  3107. static Black(): Color3;
  3108. static White(): Color3;
  3109. static Purple(): Color3;
  3110. static Magenta(): Color3;
  3111. static Yellow(): Color3;
  3112. static Gray(): Color3;
  3113. }
  3114. class Color4 {
  3115. r: number;
  3116. g: number;
  3117. b: number;
  3118. a: number;
  3119. constructor(r: number, g: number, b: number, a: number);
  3120. addInPlace(right: any): Color4;
  3121. asArray(): number[];
  3122. toArray(array: number[], index?: number): Color4;
  3123. add(right: Color4): Color4;
  3124. subtract(right: Color4): Color4;
  3125. subtractToRef(right: Color4, result: Color4): Color4;
  3126. scale(scale: number): Color4;
  3127. scaleToRef(scale: number, result: Color4): Color4;
  3128. toString(): string;
  3129. clone(): Color4;
  3130. copyFrom(source: Color4): Color4;
  3131. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  3132. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  3133. static FromArray(array: number[], offset?: number): Color4;
  3134. static FromInts(r: number, g: number, b: number, a: number): Color4;
  3135. }
  3136. class Vector2 {
  3137. x: number;
  3138. y: number;
  3139. constructor(x: number, y: number);
  3140. toString(): string;
  3141. toArray(array: number[], index?: number): Vector2;
  3142. asArray(): number[];
  3143. copyFrom(source: Vector2): Vector2;
  3144. copyFromFloats(x: number, y: number): Vector2;
  3145. add(otherVector: Vector2): Vector2;
  3146. addVector3(otherVector: Vector3): Vector2;
  3147. subtract(otherVector: Vector2): Vector2;
  3148. subtractInPlace(otherVector: Vector2): Vector2;
  3149. multiplyInPlace(otherVector: Vector2): Vector2;
  3150. multiply(otherVector: Vector2): Vector2;
  3151. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  3152. multiplyByFloats(x: number, y: number): Vector2;
  3153. divide(otherVector: Vector2): Vector2;
  3154. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  3155. negate(): Vector2;
  3156. scaleInPlace(scale: number): Vector2;
  3157. scale(scale: number): Vector2;
  3158. equals(otherVector: Vector2): boolean;
  3159. equalsWithEpsilon(otherVector: Vector2): boolean;
  3160. length(): number;
  3161. lengthSquared(): number;
  3162. normalize(): Vector2;
  3163. clone(): Vector2;
  3164. static Zero(): Vector2;
  3165. static FromArray(array: number[], offset?: number): Vector2;
  3166. static FromArrayToRef(array: number[], offset: number, result: Vector2): void;
  3167. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  3168. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  3169. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  3170. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  3171. static Dot(left: Vector2, right: Vector2): number;
  3172. static Normalize(vector: Vector2): Vector2;
  3173. static Minimize(left: Vector2, right: Vector2): Vector2;
  3174. static Maximize(left: Vector2, right: Vector2): Vector2;
  3175. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  3176. static Distance(value1: Vector2, value2: Vector2): number;
  3177. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  3178. }
  3179. class Vector3 {
  3180. x: number;
  3181. y: number;
  3182. z: number;
  3183. constructor(x: number, y: number, z: number);
  3184. toString(): string;
  3185. asArray(): number[];
  3186. toArray(array: number[], index?: number): Vector3;
  3187. toQuaternion(): Quaternion;
  3188. addInPlace(otherVector: Vector3): Vector3;
  3189. add(otherVector: Vector3): Vector3;
  3190. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  3191. subtractInPlace(otherVector: Vector3): Vector3;
  3192. subtract(otherVector: Vector3): Vector3;
  3193. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  3194. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3195. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3196. negate(): Vector3;
  3197. scaleInPlace(scale: number): Vector3;
  3198. scale(scale: number): Vector3;
  3199. scaleToRef(scale: number, result: Vector3): void;
  3200. equals(otherVector: Vector3): boolean;
  3201. equalsWithEpsilon(otherVector: Vector3): boolean;
  3202. equalsToFloats(x: number, y: number, z: number): boolean;
  3203. multiplyInPlace(otherVector: Vector3): Vector3;
  3204. multiply(otherVector: Vector3): Vector3;
  3205. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  3206. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3207. divide(otherVector: Vector3): Vector3;
  3208. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  3209. MinimizeInPlace(other: Vector3): Vector3;
  3210. MaximizeInPlace(other: Vector3): Vector3;
  3211. length(): number;
  3212. lengthSquared(): number;
  3213. normalize(): Vector3;
  3214. clone(): Vector3;
  3215. copyFrom(source: Vector3): Vector3;
  3216. copyFromFloats(x: number, y: number, z: number): Vector3;
  3217. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number;
  3218. static FromArray(array: number[], offset?: number): Vector3;
  3219. static FromArrayToRef(array: number[], offset: number, result: Vector3): void;
  3220. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  3221. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3222. static Zero(): Vector3;
  3223. static Up(): Vector3;
  3224. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  3225. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3226. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3227. static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3228. static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3229. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  3230. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3231. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3232. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  3233. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  3234. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  3235. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  3236. static Dot(left: Vector3, right: Vector3): number;
  3237. static Cross(left: Vector3, right: Vector3): Vector3;
  3238. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3239. static Normalize(vector: Vector3): Vector3;
  3240. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  3241. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  3242. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  3243. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  3244. static Minimize(left: Vector3, right: Vector3): Vector3;
  3245. static Maximize(left: Vector3, right: Vector3): Vector3;
  3246. static Distance(value1: Vector3, value2: Vector3): number;
  3247. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  3248. static Center(value1: Vector3, value2: Vector3): Vector3;
  3249. /**
  3250. * Given three orthogonal left-handed oriented Vector3 axis in space (target system),
  3251. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3252. * to something in order to rotate it from its local system to the given target system.
  3253. */
  3254. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  3255. }
  3256. class Vector4 {
  3257. x: number;
  3258. y: number;
  3259. z: number;
  3260. w: number;
  3261. constructor(x: number, y: number, z: number, w: number);
  3262. toString(): string;
  3263. asArray(): number[];
  3264. toArray(array: number[], index?: number): Vector4;
  3265. addInPlace(otherVector: Vector4): Vector4;
  3266. add(otherVector: Vector4): Vector4;
  3267. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  3268. subtractInPlace(otherVector: Vector4): Vector4;
  3269. subtract(otherVector: Vector4): Vector4;
  3270. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  3271. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3272. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3273. negate(): Vector4;
  3274. scaleInPlace(scale: number): Vector4;
  3275. scale(scale: number): Vector4;
  3276. scaleToRef(scale: number, result: Vector4): void;
  3277. equals(otherVector: Vector4): boolean;
  3278. equalsWithEpsilon(otherVector: Vector4): boolean;
  3279. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3280. multiplyInPlace(otherVector: Vector4): Vector4;
  3281. multiply(otherVector: Vector4): Vector4;
  3282. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  3283. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3284. divide(otherVector: Vector4): Vector4;
  3285. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  3286. MinimizeInPlace(other: Vector4): Vector4;
  3287. MaximizeInPlace(other: Vector4): Vector4;
  3288. length(): number;
  3289. lengthSquared(): number;
  3290. normalize(): Vector4;
  3291. clone(): Vector4;
  3292. copyFrom(source: Vector4): Vector4;
  3293. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3294. static FromArray(array: number[], offset?: number): Vector4;
  3295. static FromArrayToRef(array: number[], offset: number, result: Vector4): void;
  3296. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  3297. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3298. static Zero(): Vector4;
  3299. static Normalize(vector: Vector4): Vector4;
  3300. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  3301. static Minimize(left: Vector4, right: Vector4): Vector4;
  3302. static Maximize(left: Vector4, right: Vector4): Vector4;
  3303. static Distance(value1: Vector4, value2: Vector4): number;
  3304. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  3305. static Center(value1: Vector4, value2: Vector4): Vector4;
  3306. }
  3307. class Quaternion {
  3308. x: number;
  3309. y: number;
  3310. z: number;
  3311. w: number;
  3312. constructor(x?: number, y?: number, z?: number, w?: number);
  3313. toString(): string;
  3314. asArray(): number[];
  3315. equals(otherQuaternion: Quaternion): boolean;
  3316. clone(): Quaternion;
  3317. copyFrom(other: Quaternion): Quaternion;
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3319. add(other: Quaternion): Quaternion;
  3320. subtract(other: Quaternion): Quaternion;
  3321. scale(value: number): Quaternion;
  3322. multiply(q1: Quaternion): Quaternion;
  3323. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  3324. length(): number;
  3325. normalize(): Quaternion;
  3326. toEulerAngles(): Vector3;
  3327. toEulerAnglesToRef(result: Vector3): Quaternion;
  3328. toRotationMatrix(result: Matrix): Quaternion;
  3329. fromRotationMatrix(matrix: Matrix): Quaternion;
  3330. static FromRotationMatrix(matrix: Matrix): Quaternion;
  3331. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  3332. static Inverse(q: Quaternion): Quaternion;
  3333. static Identity(): Quaternion;
  3334. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  3335. static FromArray(array: number[], offset?: number): Quaternion;
  3336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3337. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3338. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3339. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3340. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  3341. }
  3342. class Matrix {
  3343. private static _tempQuaternion;
  3344. private static _xAxis;
  3345. private static _yAxis;
  3346. private static _zAxis;
  3347. m: Float32Array;
  3348. isIdentity(): boolean;
  3349. determinant(): number;
  3350. toArray(): Float32Array;
  3351. asArray(): Float32Array;
  3352. invert(): Matrix;
  3353. invertToRef(other: Matrix): Matrix;
  3354. invertToRefSIMD(other: Matrix): Matrix;
  3355. setTranslation(vector3: Vector3): Matrix;
  3356. multiply(other: Matrix): Matrix;
  3357. copyFrom(other: Matrix): Matrix;
  3358. copyToArray(array: Float32Array, offset?: number): Matrix;
  3359. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  3360. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  3361. multiplyToArraySIMD(other: Matrix, result: Matrix, offset?: number): void;
  3362. equals(value: Matrix): boolean;
  3363. clone(): Matrix;
  3364. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  3365. static FromArray(array: number[], offset?: number): Matrix;
  3366. static FromArrayToRef(array: number[], offset: number, result: Matrix): void;
  3367. 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;
  3368. 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;
  3369. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  3370. static Identity(): Matrix;
  3371. static IdentityToRef(result: Matrix): void;
  3372. static Zero(): Matrix;
  3373. static RotationX(angle: number): Matrix;
  3374. static Invert(source: Matrix): Matrix;
  3375. static RotationXToRef(angle: number, result: Matrix): void;
  3376. static RotationY(angle: number): Matrix;
  3377. static RotationYToRef(angle: number, result: Matrix): void;
  3378. static RotationZ(angle: number): Matrix;
  3379. static RotationZToRef(angle: number, result: Matrix): void;
  3380. static RotationAxis(axis: Vector3, angle: number): Matrix;
  3381. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3382. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3383. static Scaling(x: number, y: number, z: number): Matrix;
  3384. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3385. static Translation(x: number, y: number, z: number): Matrix;
  3386. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3387. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  3388. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  3389. static LookAtLHToRefSIMD(eyeRef: Vector3, targetRef: Vector3, upRef: Vector3, result: Matrix): void;
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3392. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3393. static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3394. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3395. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3396. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, fovMode?: number): void;
  3397. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  3398. static Transpose(matrix: Matrix): Matrix;
  3399. static Reflection(plane: Plane): Matrix;
  3400. static ReflectionToRef(plane: Plane, result: Matrix): void;
  3401. }
  3402. class Plane {
  3403. normal: Vector3;
  3404. d: number;
  3405. constructor(a: number, b: number, c: number, d: number);
  3406. asArray(): number[];
  3407. clone(): Plane;
  3408. normalize(): Plane;
  3409. transform(transformation: Matrix): Plane;
  3410. dotCoordinate(point: any): number;
  3411. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  3412. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  3413. signedDistanceTo(point: Vector3): number;
  3414. static FromArray(array: number[]): Plane;
  3415. static FromPoints(point1: any, point2: any, point3: any): Plane;
  3416. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  3417. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  3418. }
  3419. class Viewport {
  3420. x: number;
  3421. y: number;
  3422. width: number;
  3423. height: number;
  3424. constructor(x: number, y: number, width: number, height: number);
  3425. toGlobal(engine: any): Viewport;
  3426. }
  3427. class Frustum {
  3428. static GetPlanes(transform: Matrix): Plane[];
  3429. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  3430. }
  3431. class Ray {
  3432. origin: Vector3;
  3433. direction: Vector3;
  3434. length: number;
  3435. private _edge1;
  3436. private _edge2;
  3437. private _pvec;
  3438. private _tvec;
  3439. private _qvec;
  3440. constructor(origin: Vector3, direction: Vector3, length?: number);
  3441. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3442. intersectsBox(box: BoundingBox): boolean;
  3443. intersectsSphere(sphere: any): boolean;
  3444. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo;
  3445. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3446. /**
  3447. * 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
  3448. * transformed to the given world matrix.
  3449. * @param origin The origin point
  3450. * @param end The end point
  3451. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3452. */
  3453. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3454. static Transform(ray: Ray, matrix: Matrix): Ray;
  3455. }
  3456. enum Space {
  3457. LOCAL = 0,
  3458. WORLD = 1,
  3459. }
  3460. class Axis {
  3461. static X: Vector3;
  3462. static Y: Vector3;
  3463. static Z: Vector3;
  3464. }
  3465. class BezierCurve {
  3466. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3467. }
  3468. enum Orientation {
  3469. CW = 0,
  3470. CCW = 1,
  3471. }
  3472. class Angle {
  3473. private _radians;
  3474. constructor(radians: number);
  3475. degrees: () => number;
  3476. radians: () => number;
  3477. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  3478. static FromRadians(radians: number): Angle;
  3479. static FromDegrees(degrees: number): Angle;
  3480. }
  3481. class Arc2 {
  3482. startPoint: Vector2;
  3483. midPoint: Vector2;
  3484. endPoint: Vector2;
  3485. centerPoint: Vector2;
  3486. radius: number;
  3487. angle: Angle;
  3488. startAngle: Angle;
  3489. orientation: Orientation;
  3490. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  3491. }
  3492. class PathCursor {
  3493. private path;
  3494. private _onchange;
  3495. value: number;
  3496. animations: Animation[];
  3497. constructor(path: Path2);
  3498. getPoint(): Vector3;
  3499. moveAhead(step?: number): PathCursor;
  3500. moveBack(step?: number): PathCursor;
  3501. move(step: number): PathCursor;
  3502. private ensureLimits();
  3503. private markAsDirty(propertyName);
  3504. private raiseOnChange();
  3505. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3506. }
  3507. class Path2 {
  3508. private _points;
  3509. private _length;
  3510. closed: boolean;
  3511. constructor(x: number, y: number);
  3512. addLineTo(x: number, y: number): Path2;
  3513. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3514. close(): Path2;
  3515. length(): number;
  3516. getPoints(): Vector2[];
  3517. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3518. static StartingAt(x: number, y: number): Path2;
  3519. }
  3520. class Path3D {
  3521. path: Vector3[];
  3522. private _curve;
  3523. private _distances;
  3524. private _tangents;
  3525. private _normals;
  3526. private _binormals;
  3527. constructor(path: Vector3[], firstNormal?: Vector3);
  3528. getCurve(): Vector3[];
  3529. getTangents(): Vector3[];
  3530. getNormals(): Vector3[];
  3531. getBinormals(): Vector3[];
  3532. getDistances(): number[];
  3533. update(path: Vector3[], firstNormal?: Vector3): Path3D;
  3534. private _compute(firstNormal);
  3535. private _getFirstNonNullVector(index);
  3536. private _getLastNonNullVector(index);
  3537. private _normalVector(v0, vt, va);
  3538. }
  3539. class Curve3 {
  3540. private _points;
  3541. private _length;
  3542. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  3543. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  3544. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  3545. constructor(points: Vector3[]);
  3546. getPoints(): Vector3[];
  3547. length(): number;
  3548. continue(curve: Curve3): Curve3;
  3549. private _computeLength(path);
  3550. }
  3551. class PositionNormalVertex {
  3552. position: Vector3;
  3553. normal: Vector3;
  3554. constructor(position?: Vector3, normal?: Vector3);
  3555. clone(): PositionNormalVertex;
  3556. }
  3557. class PositionNormalTextureVertex {
  3558. position: Vector3;
  3559. normal: Vector3;
  3560. uv: Vector2;
  3561. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  3562. clone(): PositionNormalTextureVertex;
  3563. }
  3564. class SIMDHelper {
  3565. private static _isEnabled;
  3566. static IsEnabled: boolean;
  3567. static DisableSIMD(): void;
  3568. static EnableSIMD(): void;
  3569. }
  3570. }
  3571. declare module BABYLON {
  3572. class AbstractMesh extends Node implements IDisposable {
  3573. private static _BILLBOARDMODE_NONE;
  3574. private static _BILLBOARDMODE_X;
  3575. private static _BILLBOARDMODE_Y;
  3576. private static _BILLBOARDMODE_Z;
  3577. private static _BILLBOARDMODE_ALL;
  3578. static BILLBOARDMODE_NONE: number;
  3579. static BILLBOARDMODE_X: number;
  3580. static BILLBOARDMODE_Y: number;
  3581. static BILLBOARDMODE_Z: number;
  3582. static BILLBOARDMODE_ALL: number;
  3583. definedFacingForward: boolean;
  3584. position: Vector3;
  3585. rotation: Vector3;
  3586. rotationQuaternion: Quaternion;
  3587. scaling: Vector3;
  3588. billboardMode: number;
  3589. visibility: number;
  3590. alphaIndex: number;
  3591. infiniteDistance: boolean;
  3592. isVisible: boolean;
  3593. isPickable: boolean;
  3594. showBoundingBox: boolean;
  3595. showSubMeshesBoundingBox: boolean;
  3596. onDispose: any;
  3597. isBlocker: boolean;
  3598. skeleton: Skeleton;
  3599. renderingGroupId: number;
  3600. material: Material;
  3601. receiveShadows: boolean;
  3602. actionManager: ActionManager;
  3603. renderOutline: boolean;
  3604. outlineColor: Color3;
  3605. outlineWidth: number;
  3606. renderOverlay: boolean;
  3607. overlayColor: Color3;
  3608. overlayAlpha: number;
  3609. hasVertexAlpha: boolean;
  3610. useVertexColors: boolean;
  3611. applyFog: boolean;
  3612. useOctreeForRenderingSelection: boolean;
  3613. useOctreeForPicking: boolean;
  3614. useOctreeForCollisions: boolean;
  3615. layerMask: number;
  3616. alwaysSelectAsActiveMesh: boolean;
  3617. _physicImpostor: number;
  3618. _physicsMass: number;
  3619. _physicsFriction: number;
  3620. _physicRestitution: number;
  3621. private _checkCollisions;
  3622. ellipsoid: Vector3;
  3623. ellipsoidOffset: Vector3;
  3624. private _collider;
  3625. private _oldPositionForCollisions;
  3626. private _diffPositionForCollisions;
  3627. private _newPositionForCollisions;
  3628. private _localScaling;
  3629. private _localRotation;
  3630. private _localTranslation;
  3631. private _localBillboard;
  3632. private _localPivotScaling;
  3633. private _localPivotScalingRotation;
  3634. private _localWorld;
  3635. _worldMatrix: Matrix;
  3636. private _rotateYByPI;
  3637. private _absolutePosition;
  3638. private _collisionsTransformMatrix;
  3639. private _collisionsScalingMatrix;
  3640. _positions: Vector3[];
  3641. private _isDirty;
  3642. _masterMesh: AbstractMesh;
  3643. _boundingInfo: BoundingInfo;
  3644. private _pivotMatrix;
  3645. _isDisposed: boolean;
  3646. _renderId: number;
  3647. subMeshes: SubMesh[];
  3648. _submeshesOctree: Octree<SubMesh>;
  3649. _intersectionsInProgress: AbstractMesh[];
  3650. private _onAfterWorldMatrixUpdate;
  3651. private _isWorldMatrixFrozen;
  3652. _waitingActions: any;
  3653. constructor(name: string, scene: Scene);
  3654. isBlocked: boolean;
  3655. getLOD(camera: Camera): AbstractMesh;
  3656. getTotalVertices(): number;
  3657. getIndices(): number[];
  3658. getVerticesData(kind: string): number[];
  3659. isVerticesDataPresent(kind: string): boolean;
  3660. getBoundingInfo(): BoundingInfo;
  3661. useBones: boolean;
  3662. _preActivate(): void;
  3663. _activate(renderId: number): void;
  3664. getWorldMatrix(): Matrix;
  3665. worldMatrixFromCache: Matrix;
  3666. absolutePosition: Vector3;
  3667. freezeWorldMatrix(): void;
  3668. unfreezeWorldMatrix(): void;
  3669. isWorldMatrixFrozen: boolean;
  3670. rotate(axis: Vector3, amount: number, space: Space): void;
  3671. translate(axis: Vector3, distance: number, space: Space): void;
  3672. getAbsolutePosition(): Vector3;
  3673. setAbsolutePosition(absolutePosition: Vector3): void;
  3674. /**
  3675. * Perform relative position change from the point of view of behind the front of the mesh.
  3676. * This is performed taking into account the meshes current rotation, so you do not have to care.
  3677. * Supports definition of mesh facing forward or backward.
  3678. * @param {number} amountRight
  3679. * @param {number} amountUp
  3680. * @param {number} amountForward
  3681. */
  3682. movePOV(amountRight: number, amountUp: number, amountForward: number): void;
  3683. /**
  3684. * Calculate relative position change from the point of view of behind the front of the mesh.
  3685. * This is performed taking into account the meshes current rotation, so you do not have to care.
  3686. * Supports definition of mesh facing forward or backward.
  3687. * @param {number} amountRight
  3688. * @param {number} amountUp
  3689. * @param {number} amountForward
  3690. */
  3691. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  3692. /**
  3693. * Perform relative rotation change from the point of view of behind the front of the mesh.
  3694. * Supports definition of mesh facing forward or backward.
  3695. * @param {number} flipBack
  3696. * @param {number} twirlClockwise
  3697. * @param {number} tiltRight
  3698. */
  3699. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void;
  3700. /**
  3701. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  3702. * Supports definition of mesh facing forward or backward.
  3703. * @param {number} flipBack
  3704. * @param {number} twirlClockwise
  3705. * @param {number} tiltRight
  3706. */
  3707. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  3708. setPivotMatrix(matrix: Matrix): void;
  3709. getPivotMatrix(): Matrix;
  3710. _isSynchronized(): boolean;
  3711. _initCache(): void;
  3712. markAsDirty(property: string): void;
  3713. _updateBoundingInfo(): void;
  3714. _updateSubMeshesBoundingInfo(matrix: Matrix): void;
  3715. computeWorldMatrix(force?: boolean): Matrix;
  3716. /**
  3717. * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated
  3718. * @param func: callback function to add
  3719. */
  3720. registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  3721. unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  3722. setPositionWithLocalVector(vector3: Vector3): void;
  3723. getPositionExpressedInLocalSpace(): Vector3;
  3724. locallyTranslate(vector3: Vector3): void;
  3725. lookAt(targetPoint: Vector3, yawCor: number, pitchCor: number, rollCor: number): void;
  3726. isInFrustum(frustumPlanes: Plane[]): boolean;
  3727. isCompletelyInFrustum(camera?: Camera): boolean;
  3728. intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean;
  3729. intersectsPoint(point: Vector3): boolean;
  3730. setPhysicsState(impostor?: any, options?: PhysicsBodyCreationOptions): any;
  3731. getPhysicsImpostor(): number;
  3732. getPhysicsMass(): number;
  3733. getPhysicsFriction(): number;
  3734. getPhysicsRestitution(): number;
  3735. getPositionInCameraSpace(camera?: Camera): Vector3;
  3736. getDistanceToCamera(camera?: Camera): number;
  3737. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  3738. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void;
  3739. updatePhysicsBodyPosition(): void;
  3740. checkCollisions: boolean;
  3741. moveWithCollisions(velocity: Vector3): void;
  3742. private _onCollisionPositionChange;
  3743. /**
  3744. * This function will create an octree to help select the right submeshes for rendering, picking and collisions
  3745. * Please note that you must have a decent number of submeshes to get performance improvements when using octree
  3746. */
  3747. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  3748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void;
  3749. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void;
  3750. _checkCollision(collider: Collider): void;
  3751. _generatePointsArray(): boolean;
  3752. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  3753. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh;
  3754. releaseSubMeshes(): void;
  3755. dispose(doNotRecurse?: boolean): void;
  3756. }
  3757. }
  3758. declare module BABYLON {
  3759. class CSG {
  3760. private polygons;
  3761. matrix: Matrix;
  3762. position: Vector3;
  3763. rotation: Vector3;
  3764. rotationQuaternion: Quaternion;
  3765. scaling: Vector3;
  3766. static FromMesh(mesh: Mesh): CSG;
  3767. private static FromPolygons(polygons);
  3768. clone(): CSG;
  3769. private toPolygons();
  3770. union(csg: CSG): CSG;
  3771. unionInPlace(csg: CSG): void;
  3772. subtract(csg: CSG): CSG;
  3773. subtractInPlace(csg: CSG): void;
  3774. intersect(csg: CSG): CSG;
  3775. intersectInPlace(csg: CSG): void;
  3776. inverse(): CSG;
  3777. inverseInPlace(): void;
  3778. copyTransformAttributes(csg: CSG): CSG;
  3779. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  3780. toMesh(name: string, material: Material, scene: Scene, keepSubMeshes: boolean): Mesh;
  3781. }
  3782. }
  3783. declare module BABYLON {
  3784. class Geometry implements IGetSetVerticesData {
  3785. id: string;
  3786. delayLoadState: number;
  3787. delayLoadingFile: string;
  3788. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  3789. private _scene;
  3790. private _engine;
  3791. private _meshes;
  3792. private _totalVertices;
  3793. private _indices;
  3794. private _vertexBuffers;
  3795. private _isDisposed;
  3796. _delayInfo: any;
  3797. private _indexBuffer;
  3798. _boundingInfo: BoundingInfo;
  3799. _delayLoadingFunction: (any: any, geometry: Geometry) => void;
  3800. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Mesh);
  3801. getScene(): Scene;
  3802. getEngine(): Engine;
  3803. isReady(): boolean;
  3804. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  3805. setVerticesData(kind: string, data: number[], updatable?: boolean, stride?: number): void;
  3806. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  3807. updateVerticesData(kind: string, data: number[], updateExtends?: boolean): void;
  3808. getTotalVertices(): number;
  3809. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  3810. getVertexBuffer(kind: string): VertexBuffer;
  3811. getVertexBuffers(): VertexBuffer[];
  3812. isVerticesDataPresent(kind: string): boolean;
  3813. getVerticesDataKinds(): string[];
  3814. setIndices(indices: number[], totalVertices?: number): void;
  3815. getTotalIndices(): number;
  3816. getIndices(copyWhenShared?: boolean): number[];
  3817. getIndexBuffer(): any;
  3818. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  3819. applyToMesh(mesh: Mesh): void;
  3820. private _applyToMesh(mesh);
  3821. private notifyUpdate(kind?);
  3822. load(scene: Scene, onLoaded?: () => void): void;
  3823. isDisposed(): boolean;
  3824. dispose(): void;
  3825. copy(id: string): Geometry;
  3826. static ExtractFromMesh(mesh: Mesh, id: string): Geometry;
  3827. static RandomId(): string;
  3828. }
  3829. module Geometry.Primitives {
  3830. class _Primitive extends Geometry {
  3831. private _beingRegenerated;
  3832. private _canBeRegenerated;
  3833. constructor(id: string, scene: Scene, vertexData?: VertexData, canBeRegenerated?: boolean, mesh?: Mesh);
  3834. canBeRegenerated(): boolean;
  3835. regenerate(): void;
  3836. asNewGeometry(id: string): Geometry;
  3837. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  3838. setVerticesData(kind: string, data: number[], updatable?: boolean): void;
  3839. _regenerateVertexData(): VertexData;
  3840. copy(id: string): Geometry;
  3841. }
  3842. class Ribbon extends _Primitive {
  3843. pathArray: Vector3[][];
  3844. closeArray: boolean;
  3845. closePath: boolean;
  3846. offset: number;
  3847. side: number;
  3848. constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3849. _regenerateVertexData(): VertexData;
  3850. copy(id: string): Geometry;
  3851. }
  3852. class Box extends _Primitive {
  3853. size: number;
  3854. side: number;
  3855. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3856. _regenerateVertexData(): VertexData;
  3857. copy(id: string): Geometry;
  3858. }
  3859. class Sphere extends _Primitive {
  3860. segments: number;
  3861. diameter: number;
  3862. side: number;
  3863. constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3864. _regenerateVertexData(): VertexData;
  3865. copy(id: string): Geometry;
  3866. }
  3867. class Cylinder extends _Primitive {
  3868. height: number;
  3869. diameterTop: number;
  3870. diameterBottom: number;
  3871. tessellation: number;
  3872. subdivisions: number;
  3873. side: number;
  3874. constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3875. _regenerateVertexData(): VertexData;
  3876. copy(id: string): Geometry;
  3877. }
  3878. class Torus extends _Primitive {
  3879. diameter: number;
  3880. thickness: number;
  3881. tessellation: number;
  3882. side: number;
  3883. constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3884. _regenerateVertexData(): VertexData;
  3885. copy(id: string): Geometry;
  3886. }
  3887. class Ground extends _Primitive {
  3888. width: number;
  3889. height: number;
  3890. subdivisions: number;
  3891. constructor(id: string, scene: Scene, width: number, height: number, subdivisions: number, canBeRegenerated?: boolean, mesh?: Mesh);
  3892. _regenerateVertexData(): VertexData;
  3893. copy(id: string): Geometry;
  3894. }
  3895. class TiledGround extends _Primitive {
  3896. xmin: number;
  3897. zmin: number;
  3898. xmax: number;
  3899. zmax: number;
  3900. subdivisions: {
  3901. w: number;
  3902. h: number;
  3903. };
  3904. precision: {
  3905. w: number;
  3906. h: number;
  3907. };
  3908. constructor(id: string, scene: Scene, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  3909. w: number;
  3910. h: number;
  3911. }, precision: {
  3912. w: number;
  3913. h: number;
  3914. }, canBeRegenerated?: boolean, mesh?: Mesh);
  3915. _regenerateVertexData(): VertexData;
  3916. copy(id: string): Geometry;
  3917. }
  3918. class Plane extends _Primitive {
  3919. size: number;
  3920. side: number;
  3921. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3922. _regenerateVertexData(): VertexData;
  3923. copy(id: string): Geometry;
  3924. }
  3925. class TorusKnot extends _Primitive {
  3926. radius: number;
  3927. tube: number;
  3928. radialSegments: number;
  3929. tubularSegments: number;
  3930. p: number;
  3931. q: number;
  3932. side: number;
  3933. constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3934. _regenerateVertexData(): VertexData;
  3935. copy(id: string): Geometry;
  3936. }
  3937. }
  3938. }
  3939. declare module BABYLON {
  3940. class GroundMesh extends Mesh {
  3941. generateOctree: boolean;
  3942. private _worldInverse;
  3943. _subdivisions: number;
  3944. constructor(name: string, scene: Scene);
  3945. subdivisions: number;
  3946. optimize(chunksCount: number): void;
  3947. getHeightAtCoordinates(x: number, z: number): number;
  3948. }
  3949. }
  3950. declare module BABYLON {
  3951. /**
  3952. * Creates an instance based on a source mesh.
  3953. */
  3954. class InstancedMesh extends AbstractMesh {
  3955. private _sourceMesh;
  3956. private _currentLOD;
  3957. constructor(name: string, source: Mesh);
  3958. receiveShadows: boolean;
  3959. material: Material;
  3960. visibility: number;
  3961. skeleton: Skeleton;
  3962. getTotalVertices(): number;
  3963. sourceMesh: Mesh;
  3964. getVerticesData(kind: string): number[];
  3965. isVerticesDataPresent(kind: string): boolean;
  3966. getIndices(): number[];
  3967. _positions: Vector3[];
  3968. refreshBoundingInfo(): void;
  3969. _preActivate(): void;
  3970. _activate(renderId: number): void;
  3971. getLOD(camera: Camera): AbstractMesh;
  3972. _syncSubMeshes(): void;
  3973. _generatePointsArray(): boolean;
  3974. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  3975. dispose(doNotRecurse?: boolean): void;
  3976. }
  3977. }
  3978. declare module BABYLON {
  3979. class LinesMesh extends Mesh {
  3980. color: Color3;
  3981. alpha: number;
  3982. private _colorShader;
  3983. private _ib;
  3984. private _indicesLength;
  3985. private _indices;
  3986. constructor(name: string, scene: Scene, updatable?: boolean);
  3987. material: Material;
  3988. isPickable: boolean;
  3989. checkCollisions: boolean;
  3990. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  3991. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  3992. intersects(ray: Ray, fastCheck?: boolean): any;
  3993. dispose(doNotRecurse?: boolean): void;
  3994. }
  3995. }
  3996. declare module BABYLON {
  3997. class _InstancesBatch {
  3998. mustReturn: boolean;
  3999. visibleInstances: InstancedMesh[][];
  4000. renderSelf: boolean[];
  4001. }
  4002. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  4003. static _FRONTSIDE: number;
  4004. static _BACKSIDE: number;
  4005. static _DOUBLESIDE: number;
  4006. static _DEFAULTSIDE: number;
  4007. static _NO_CAP: number;
  4008. static _CAP_START: number;
  4009. static _CAP_END: number;
  4010. static _CAP_ALL: number;
  4011. static FRONTSIDE: number;
  4012. static BACKSIDE: number;
  4013. static DOUBLESIDE: number;
  4014. static DEFAULTSIDE: number;
  4015. static NO_CAP: number;
  4016. static CAP_START: number;
  4017. static CAP_END: number;
  4018. static CAP_ALL: number;
  4019. delayLoadState: number;
  4020. instances: InstancedMesh[];
  4021. delayLoadingFile: string;
  4022. _binaryInfo: any;
  4023. private _LODLevels;
  4024. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  4025. _geometry: Geometry;
  4026. private _onBeforeRenderCallbacks;
  4027. private _onAfterRenderCallbacks;
  4028. _delayInfo: any;
  4029. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  4030. _visibleInstances: any;
  4031. private _renderIdForInstances;
  4032. private _batchCache;
  4033. private _worldMatricesInstancesBuffer;
  4034. private _worldMatricesInstancesArray;
  4035. private _instancesBufferSize;
  4036. _shouldGenerateFlatShading: boolean;
  4037. private _preActivateId;
  4038. private _sideOrientation;
  4039. private _areNormalsFrozen;
  4040. /**
  4041. * @constructor
  4042. * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
  4043. * @param {Scene} scene - The scene to add this mesh to.
  4044. * @param {Node} parent - The parent of this mesh, if it has one
  4045. * @param {Mesh} source - An optional Mesh from which geometry is shared, cloned.
  4046. * @param {boolean} doNotCloneChildren - When cloning, skip cloning child meshes of source, default False.
  4047. * When false, achieved by calling a clone(), also passing False.
  4048. * This will make creation of children, recursive.
  4049. */
  4050. constructor(name: string, scene: Scene, parent?: Node, source?: Mesh, doNotCloneChildren?: boolean);
  4051. hasLODLevels: boolean;
  4052. private _sortLODLevels();
  4053. /**
  4054. * Add a mesh as LOD level triggered at the given distance.
  4055. * @param {number} distance - the distance from the center of the object to show this level
  4056. * @param {BABYLON.Mesh} mesh - the mesh to be added as LOD level
  4057. * @return {BABYLON.Mesh} this mesh (for chaining)
  4058. */
  4059. addLODLevel(distance: number, mesh: Mesh): Mesh;
  4060. getLODLevelAtDistance(distance: number): Mesh;
  4061. /**
  4062. * Remove a mesh from the LOD array
  4063. * @param {BABYLON.Mesh} mesh - the mesh to be removed.
  4064. * @return {BABYLON.Mesh} this mesh (for chaining)
  4065. */
  4066. removeLODLevel(mesh: Mesh): Mesh;
  4067. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  4068. geometry: Geometry;
  4069. getTotalVertices(): number;
  4070. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  4071. getVertexBuffer(kind: any): VertexBuffer;
  4072. isVerticesDataPresent(kind: string): boolean;
  4073. getVerticesDataKinds(): string[];
  4074. getTotalIndices(): number;
  4075. getIndices(copyWhenShared?: boolean): number[];
  4076. isBlocked: boolean;
  4077. isReady(): boolean;
  4078. isDisposed(): boolean;
  4079. sideOrientation: number;
  4080. areNormalsFrozen: boolean;
  4081. /** This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
  4082. freezeNormals(): void;
  4083. /** This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
  4084. unfreezeNormals(): void;
  4085. _preActivate(): void;
  4086. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): void;
  4087. refreshBoundingInfo(): void;
  4088. _createGlobalSubMesh(): SubMesh;
  4089. subdivide(count: number): void;
  4090. setVerticesData(kind: any, data: any, updatable?: boolean, stride?: number): void;
  4091. updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
  4092. updateVerticesDataDirectly(kind: string, data: Float32Array, offset?: number, makeItUnique?: boolean): void;
  4093. updateMeshPositions(positionFunction: any, computeNormals?: boolean): void;
  4094. makeGeometryUnique(): void;
  4095. setIndices(indices: number[], totalVertices?: number): void;
  4096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  4097. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  4098. registerBeforeRender(func: (mesh: AbstractMesh) => void): void;
  4099. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void;
  4100. registerAfterRender(func: (mesh: AbstractMesh) => void): void;
  4101. unregisterAfterRender(func: (mesh: AbstractMesh) => void): void;
  4102. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  4103. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
  4104. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix) => void): void;
  4105. render(subMesh: SubMesh): void;
  4106. getEmittedParticleSystems(): ParticleSystem[];
  4107. getHierarchyEmittedParticleSystems(): ParticleSystem[];
  4108. getChildren(): Node[];
  4109. _checkDelayState(): void;
  4110. isInFrustum(frustumPlanes: Plane[]): boolean;
  4111. setMaterialByID(id: string): void;
  4112. getAnimatables(): IAnimatable[];
  4113. bakeTransformIntoVertices(transform: Matrix): void;
  4114. _resetPointsArrayCache(): void;
  4115. _generatePointsArray(): boolean;
  4116. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): Mesh;
  4117. dispose(doNotRecurse?: boolean): void;
  4118. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void): void;
  4119. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number): void;
  4120. convertToFlatShadedMesh(): void;
  4121. createInstance(name: string): InstancedMesh;
  4122. synchronizeInstances(): void;
  4123. /**
  4124. * Simplify the mesh according to the given array of settings.
  4125. * Function will return immediately and will simplify async.
  4126. * @param settings a collection of simplification settings.
  4127. * @param parallelProcessing should all levels calculate parallel or one after the other.
  4128. * @param type the type of simplification to run.
  4129. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  4130. */
  4131. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): void;
  4132. /**
  4133. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  4134. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  4135. * This should be used together with the simplification to avoid disappearing triangles.
  4136. * @param successCallback an optional success callback to be called after the optimization finished.
  4137. */
  4138. optimizeIndices(successCallback?: (mesh?: Mesh) => void): void;
  4139. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, ribbonInstance?: Mesh): Mesh;
  4140. static CreateDisc(name: string, radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4141. static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4142. static CreateSphere(name: string, segments: number, diameter: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4143. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
  4144. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4145. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4146. static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, linesInstance?: LinesMesh): LinesMesh;
  4147. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, linesInstance?: LinesMesh): LinesMesh;
  4148. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, extrudedInstance?: Mesh): Mesh;
  4149. 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;
  4150. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance);
  4151. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4152. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4153. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene: Scene, updatable?: boolean): Mesh;
  4154. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  4155. w: number;
  4156. h: number;
  4157. }, precision: {
  4158. w: number;
  4159. h: number;
  4160. }, scene: Scene, updatable?: boolean): Mesh;
  4161. 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;
  4162. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  4163. (i: number, distance: number): number;
  4164. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, tubeInstance?: Mesh): Mesh;
  4165. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle?: number): Mesh;
  4166. static MinMax(meshes: AbstractMesh[]): {
  4167. min: Vector3;
  4168. max: Vector3;
  4169. };
  4170. static Center(meshesOrMinMaxVector: any): Vector3;
  4171. /**
  4172. * Merge the array of meshes into a single mesh for performance reasons.
  4173. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  4174. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  4175. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  4176. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  4177. */
  4178. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh;
  4179. }
  4180. }
  4181. declare module BABYLON {
  4182. interface IGetSetVerticesData {
  4183. isVerticesDataPresent(kind: string): boolean;
  4184. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  4185. getIndices(copyWhenShared?: boolean): number[];
  4186. setVerticesData(kind: string, data: number[], updatable?: boolean): void;
  4187. updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
  4188. setIndices(indices: number[]): void;
  4189. }
  4190. class VertexData {
  4191. positions: number[];
  4192. normals: number[];
  4193. uvs: number[];
  4194. uv2s: number[];
  4195. colors: number[];
  4196. matricesIndices: number[];
  4197. matricesWeights: number[];
  4198. indices: number[];
  4199. set(data: number[], kind: string): void;
  4200. applyToMesh(mesh: Mesh, updatable?: boolean): void;
  4201. applyToGeometry(geometry: Geometry, updatable?: boolean): void;
  4202. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): void;
  4203. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): void;
  4204. private _applyTo(meshOrGeometry, updatable?);
  4205. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  4206. transform(matrix: Matrix): void;
  4207. merge(other: VertexData): void;
  4208. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean): VertexData;
  4209. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean): VertexData;
  4210. private static _ExtractFrom(meshOrGeometry, copyWhenShared?);
  4211. static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, sideOrientation?: number): VertexData;
  4212. static CreateBox(size: number, sideOrientation?: number): VertexData;
  4213. static CreateSphere(segments: number, diameter: number, sideOrientation?: number): VertexData;
  4214. static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, sideOrientation?: number): VertexData;
  4215. static CreateTorus(diameter: any, thickness: any, tessellation: any, sideOrientation?: number): VertexData;
  4216. static CreateLines(points: Vector3[]): VertexData;
  4217. static CreateDashedLines(points: Vector3[], dashSize: number, gapSize: number, dashNb: number): VertexData;
  4218. static CreateGround(width: number, height: number, subdivisions: number): VertexData;
  4219. static CreateTiledGround(xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: {
  4220. w: number;
  4221. h: number;
  4222. }, precision?: {
  4223. w: number;
  4224. h: number;
  4225. }): VertexData;
  4226. static CreateGroundFromHeightMap(width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, buffer: Uint8Array, bufferWidth: number, bufferHeight: number): VertexData;
  4227. static CreatePlane(size: number, sideOrientation?: number): VertexData;
  4228. static CreateDisc(radius: number, tessellation: number, sideOrientation?: number): VertexData;
  4229. static CreateTorusKnot(radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, sideOrientation?: number): VertexData;
  4230. /**
  4231. * @param {any} - positions (number[] or Float32Array)
  4232. * @param {any} - indices (number[] or Uint16Array)
  4233. * @param {any} - normals (number[] or Float32Array)
  4234. */
  4235. static ComputeNormals(positions: any, indices: any, normals: any): void;
  4236. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs);
  4237. }
  4238. }
  4239. declare module BABYLON.Internals {
  4240. class MeshLODLevel {
  4241. distance: number;
  4242. mesh: Mesh;
  4243. constructor(distance: number, mesh: Mesh);
  4244. }
  4245. }
  4246. declare module BABYLON {
  4247. /**
  4248. * A simplifier interface for future simplification implementations.
  4249. */
  4250. interface ISimplifier {
  4251. /**
  4252. * Simplification of a given mesh according to the given settings.
  4253. * Since this requires computation, it is assumed that the function runs async.
  4254. * @param settings The settings of the simplification, including quality and distance
  4255. * @param successCallback A callback that will be called after the mesh was simplified.
  4256. * @param errorCallback in case of an error, this callback will be called. optional.
  4257. */
  4258. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  4259. }
  4260. /**
  4261. * Expected simplification settings.
  4262. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  4263. */
  4264. interface ISimplificationSettings {
  4265. quality: number;
  4266. distance: number;
  4267. optimizeMesh?: boolean;
  4268. }
  4269. class SimplificationSettings implements ISimplificationSettings {
  4270. quality: number;
  4271. distance: number;
  4272. optimizeMesh: boolean;
  4273. constructor(quality: number, distance: number, optimizeMesh?: boolean);
  4274. }
  4275. interface ISimplificationTask {
  4276. settings: Array<ISimplificationSettings>;
  4277. simplificationType: SimplificationType;
  4278. mesh: Mesh;
  4279. successCallback?: () => void;
  4280. parallelProcessing: boolean;
  4281. }
  4282. class SimplificationQueue {
  4283. private _simplificationArray;
  4284. running: any;
  4285. constructor();
  4286. addTask(task: ISimplificationTask): void;
  4287. executeNext(): void;
  4288. runSimplification(task: ISimplificationTask): void;
  4289. private getSimplifier(task);
  4290. }
  4291. /**
  4292. * The implemented types of simplification.
  4293. * At the moment only Quadratic Error Decimation is implemented.
  4294. */
  4295. enum SimplificationType {
  4296. QUADRATIC = 0,
  4297. }
  4298. class DecimationTriangle {
  4299. vertices: Array<DecimationVertex>;
  4300. normal: Vector3;
  4301. error: Array<number>;
  4302. deleted: boolean;
  4303. isDirty: boolean;
  4304. borderFactor: number;
  4305. deletePending: boolean;
  4306. originalOffset: number;
  4307. constructor(vertices: Array<DecimationVertex>);
  4308. }
  4309. class DecimationVertex {
  4310. position: Vector3;
  4311. id: any;
  4312. q: QuadraticMatrix;
  4313. isBorder: boolean;
  4314. triangleStart: number;
  4315. triangleCount: number;
  4316. originalOffsets: Array<number>;
  4317. constructor(position: Vector3, id: any);
  4318. updatePosition(newPosition: Vector3): void;
  4319. }
  4320. class QuadraticMatrix {
  4321. data: Array<number>;
  4322. constructor(data?: Array<number>);
  4323. det(a11: any, a12: any, a13: any, a21: any, a22: any, a23: any, a31: any, a32: any, a33: any): number;
  4324. addInPlace(matrix: QuadraticMatrix): void;
  4325. addArrayInPlace(data: Array<number>): void;
  4326. add(matrix: QuadraticMatrix): QuadraticMatrix;
  4327. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  4328. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  4329. }
  4330. class Reference {
  4331. vertexId: number;
  4332. triangleId: number;
  4333. constructor(vertexId: number, triangleId: number);
  4334. }
  4335. /**
  4336. * An implementation of the Quadratic Error simplification algorithm.
  4337. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  4338. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  4339. * @author RaananW
  4340. */
  4341. class QuadraticErrorSimplification implements ISimplifier {
  4342. private _mesh;
  4343. private triangles;
  4344. private vertices;
  4345. private references;
  4346. private initialized;
  4347. private _reconstructedMesh;
  4348. syncIterations: number;
  4349. aggressiveness: number;
  4350. decimationIterations: number;
  4351. boundingBoxEpsilon: number;
  4352. constructor(_mesh: Mesh);
  4353. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  4354. private isTriangleOnBoundingBox(triangle);
  4355. private runDecimation(settings, submeshIndex, successCallback);
  4356. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  4357. private init(callback);
  4358. private reconstructMesh(submeshIndex);
  4359. private initDecimatedMesh();
  4360. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  4361. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  4362. private identifyBorder();
  4363. private updateMesh(identifyBorders?);
  4364. private vertexError(q, point);
  4365. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  4366. }
  4367. }
  4368. declare module BABYLON {
  4369. class Polygon {
  4370. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  4371. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  4372. static Parse(input: string): Vector2[];
  4373. static StartingAt(x: number, y: number): Path2;
  4374. }
  4375. class PolygonMeshBuilder {
  4376. private _swctx;
  4377. private _points;
  4378. private _outlinepoints;
  4379. private _holes;
  4380. private _name;
  4381. private _scene;
  4382. constructor(name: string, contours: Path2, scene: Scene);
  4383. constructor(name: string, contours: Vector2[], scene: Scene);
  4384. addHole(hole: Vector2[]): PolygonMeshBuilder;
  4385. build(updatable?: boolean, depth?: number): Mesh;
  4386. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  4387. }
  4388. }
  4389. declare module BABYLON {
  4390. class SubMesh {
  4391. materialIndex: number;
  4392. verticesStart: number;
  4393. verticesCount: number;
  4394. indexStart: any;
  4395. indexCount: number;
  4396. linesIndexCount: number;
  4397. private _mesh;
  4398. private _renderingMesh;
  4399. private _boundingInfo;
  4400. private _linesIndexBuffer;
  4401. _lastColliderWorldVertices: Vector3[];
  4402. _trianglePlanes: Plane[];
  4403. _lastColliderTransformMatrix: Matrix;
  4404. _renderId: number;
  4405. _alphaIndex: number;
  4406. _distanceToCamera: number;
  4407. _id: number;
  4408. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: any, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  4409. getBoundingInfo(): BoundingInfo;
  4410. getMesh(): AbstractMesh;
  4411. getRenderingMesh(): Mesh;
  4412. getMaterial(): Material;
  4413. refreshBoundingInfo(): void;
  4414. _checkCollision(collider: Collider): boolean;
  4415. updateBoundingInfo(world: Matrix): void;
  4416. isInFrustum(frustumPlanes: Plane[]): boolean;
  4417. render(): void;
  4418. getLinesIndexBuffer(indices: number[], engine: any): WebGLBuffer;
  4419. canIntersects(ray: Ray): boolean;
  4420. intersects(ray: Ray, positions: Vector3[], indices: number[], fastCheck?: boolean): IntersectionInfo;
  4421. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  4422. dispose(): void;
  4423. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  4424. }
  4425. }
  4426. declare module BABYLON {
  4427. class VertexBuffer {
  4428. private _mesh;
  4429. private _engine;
  4430. private _buffer;
  4431. private _data;
  4432. private _updatable;
  4433. private _kind;
  4434. private _strideSize;
  4435. constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number);
  4436. isUpdatable(): boolean;
  4437. getData(): number[];
  4438. getBuffer(): WebGLBuffer;
  4439. getStrideSize(): number;
  4440. create(data?: number[]): void;
  4441. update(data: number[]): void;
  4442. updateDirectly(data: Float32Array, offset: number): void;
  4443. dispose(): void;
  4444. private static _PositionKind;
  4445. private static _NormalKind;
  4446. private static _UVKind;
  4447. private static _UV2Kind;
  4448. private static _ColorKind;
  4449. private static _MatricesIndicesKind;
  4450. private static _MatricesWeightsKind;
  4451. static PositionKind: string;
  4452. static NormalKind: string;
  4453. static UVKind: string;
  4454. static UV2Kind: string;
  4455. static ColorKind: string;
  4456. static MatricesIndicesKind: string;
  4457. static MatricesWeightsKind: string;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. class Particle {
  4462. position: Vector3;
  4463. direction: Vector3;
  4464. color: Color4;
  4465. colorStep: Color4;
  4466. lifeTime: number;
  4467. age: number;
  4468. size: number;
  4469. angle: number;
  4470. angularSpeed: number;
  4471. copyTo(other: Particle): void;
  4472. }
  4473. }
  4474. declare module BABYLON {
  4475. class ParticleSystem implements IDisposable {
  4476. name: string;
  4477. static BLENDMODE_ONEONE: number;
  4478. static BLENDMODE_STANDARD: number;
  4479. id: string;
  4480. renderingGroupId: number;
  4481. emitter: any;
  4482. emitRate: number;
  4483. manualEmitCount: number;
  4484. updateSpeed: number;
  4485. targetStopDuration: number;
  4486. disposeOnStop: boolean;
  4487. minEmitPower: number;
  4488. maxEmitPower: number;
  4489. minLifeTime: number;
  4490. maxLifeTime: number;
  4491. minSize: number;
  4492. maxSize: number;
  4493. minAngularSpeed: number;
  4494. maxAngularSpeed: number;
  4495. particleTexture: Texture;
  4496. onDispose: () => void;
  4497. updateFunction: (particles: Particle[]) => void;
  4498. blendMode: number;
  4499. forceDepthWrite: boolean;
  4500. gravity: Vector3;
  4501. direction1: Vector3;
  4502. direction2: Vector3;
  4503. minEmitBox: Vector3;
  4504. maxEmitBox: Vector3;
  4505. color1: Color4;
  4506. color2: Color4;
  4507. colorDead: Color4;
  4508. textureMask: Color4;
  4509. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3) => void;
  4510. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3) => void;
  4511. private particles;
  4512. private _capacity;
  4513. private _scene;
  4514. private _vertexDeclaration;
  4515. private _vertexStrideSize;
  4516. private _stockParticles;
  4517. private _newPartsExcess;
  4518. private _vertexBuffer;
  4519. private _indexBuffer;
  4520. private _vertices;
  4521. private _effect;
  4522. private _customEffect;
  4523. private _cachedDefines;
  4524. private _scaledColorStep;
  4525. private _colorDiff;
  4526. private _scaledDirection;
  4527. private _scaledGravity;
  4528. private _currentRenderId;
  4529. private _alive;
  4530. private _started;
  4531. private _stopped;
  4532. private _actualFrame;
  4533. private _scaledUpdateSpeed;
  4534. constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
  4535. recycleParticle(particle: Particle): void;
  4536. getCapacity(): number;
  4537. isAlive(): boolean;
  4538. isStarted(): boolean;
  4539. start(): void;
  4540. stop(): void;
  4541. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  4542. private _update(newParticles);
  4543. private _getEffect();
  4544. animate(): void;
  4545. render(): number;
  4546. dispose(): void;
  4547. clone(name: string, newEmitter: any): ParticleSystem;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. interface IPhysicsEnginePlugin {
  4552. initialize(iterations?: number): any;
  4553. setGravity(gravity: Vector3): void;
  4554. runOneStep(delta: number): void;
  4555. registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4556. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4557. unregisterMesh(mesh: AbstractMesh): any;
  4558. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4559. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4560. dispose(): void;
  4561. isSupported(): boolean;
  4562. updateBodyPosition(mesh: AbstractMesh): void;
  4563. }
  4564. interface PhysicsBodyCreationOptions {
  4565. mass: number;
  4566. friction: number;
  4567. restitution: number;
  4568. }
  4569. interface PhysicsCompoundBodyPart {
  4570. mesh: Mesh;
  4571. impostor: number;
  4572. }
  4573. class PhysicsEngine {
  4574. gravity: Vector3;
  4575. private _currentPlugin;
  4576. constructor(plugin?: IPhysicsEnginePlugin);
  4577. _initialize(gravity?: Vector3): void;
  4578. _runOneStep(delta: number): void;
  4579. _setGravity(gravity: Vector3): void;
  4580. _registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4581. _registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4582. _unregisterMesh(mesh: AbstractMesh): void;
  4583. _applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4584. _createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4585. _updateBodyPosition(mesh: AbstractMesh): void;
  4586. dispose(): void;
  4587. isSupported(): boolean;
  4588. static NoImpostor: number;
  4589. static SphereImpostor: number;
  4590. static BoxImpostor: number;
  4591. static PlaneImpostor: number;
  4592. static MeshImpostor: number;
  4593. static CapsuleImpostor: number;
  4594. static ConeImpostor: number;
  4595. static CylinderImpostor: number;
  4596. static ConvexHullImpostor: number;
  4597. static Epsilon: number;
  4598. }
  4599. }
  4600. declare module BABYLON {
  4601. class CannonJSPlugin implements IPhysicsEnginePlugin {
  4602. checkWithEpsilon: (value: number) => number;
  4603. private _world;
  4604. private _registeredMeshes;
  4605. private _physicsMaterials;
  4606. initialize(iterations?: number): void;
  4607. private _checkWithEpsilon(value);
  4608. runOneStep(delta: number): void;
  4609. setGravity(gravity: Vector3): void;
  4610. registerMesh(mesh: AbstractMesh, impostor: number, options?: PhysicsBodyCreationOptions): any;
  4611. private _createSphere(radius, mesh, options?);
  4612. private _createBox(x, y, z, mesh, options?);
  4613. private _createPlane(mesh, options?);
  4614. private _createConvexPolyhedron(rawVerts, rawFaces, mesh, options?);
  4615. private _addMaterial(friction, restitution);
  4616. private _createRigidBodyFromShape(shape, mesh, mass, friction, restitution);
  4617. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4618. private _unbindBody(body);
  4619. unregisterMesh(mesh: AbstractMesh): void;
  4620. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4621. updateBodyPosition: (mesh: AbstractMesh) => void;
  4622. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3): boolean;
  4623. dispose(): void;
  4624. isSupported(): boolean;
  4625. }
  4626. }
  4627. declare module BABYLON {
  4628. class OimoJSPlugin implements IPhysicsEnginePlugin {
  4629. private _world;
  4630. private _registeredMeshes;
  4631. private _checkWithEpsilon(value);
  4632. initialize(iterations?: number): void;
  4633. setGravity(gravity: Vector3): void;
  4634. registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4635. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4636. private _createBodyAsCompound(part, options, initialMesh);
  4637. unregisterMesh(mesh: AbstractMesh): void;
  4638. private _unbindBody(body);
  4639. /**
  4640. * Update the body position according to the mesh position
  4641. * @param mesh
  4642. */
  4643. updateBodyPosition: (mesh: AbstractMesh) => void;
  4644. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4645. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4646. dispose(): void;
  4647. isSupported(): boolean;
  4648. private _getLastShape(body);
  4649. runOneStep(time: number): void;
  4650. }
  4651. }
  4652. declare module BABYLON {
  4653. class AnaglyphPostProcess extends PostProcess {
  4654. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4655. }
  4656. }
  4657. declare module BABYLON {
  4658. class BlackAndWhitePostProcess extends PostProcess {
  4659. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4660. }
  4661. }
  4662. declare module BABYLON {
  4663. class BlurPostProcess extends PostProcess {
  4664. direction: Vector2;
  4665. blurWidth: number;
  4666. constructor(name: string, direction: Vector2, blurWidth: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. class ColorCorrectionPostProcess extends PostProcess {
  4671. private _colorTableTexture;
  4672. constructor(name: string, colorTableUrl: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4673. }
  4674. }
  4675. declare module BABYLON {
  4676. class ConvolutionPostProcess extends PostProcess {
  4677. kernel: number[];
  4678. constructor(name: string, kernel: number[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4679. static EdgeDetect0Kernel: number[];
  4680. static EdgeDetect1Kernel: number[];
  4681. static EdgeDetect2Kernel: number[];
  4682. static SharpenKernel: number[];
  4683. static EmbossKernel: number[];
  4684. static GaussianKernel: number[];
  4685. }
  4686. }
  4687. declare module BABYLON {
  4688. class DisplayPassPostProcess extends PostProcess {
  4689. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4690. }
  4691. }
  4692. declare module BABYLON {
  4693. class FilterPostProcess extends PostProcess {
  4694. kernelMatrix: Matrix;
  4695. constructor(name: string, kernelMatrix: Matrix, ratio: number, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4696. }
  4697. }
  4698. declare module BABYLON {
  4699. class FxaaPostProcess extends PostProcess {
  4700. texelWidth: number;
  4701. texelHeight: number;
  4702. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4703. }
  4704. }
  4705. declare module BABYLON {
  4706. class LensRenderingPipeline extends PostProcessRenderPipeline {
  4707. /**
  4708. * The chromatic aberration PostProcess id in the pipeline
  4709. * @type {string}
  4710. */
  4711. LensChromaticAberrationEffect: string;
  4712. /**
  4713. * The highlights enhancing PostProcess id in the pipeline
  4714. * @type {string}
  4715. */
  4716. HighlightsEnhancingEffect: string;
  4717. /**
  4718. * The depth-of-field PostProcess id in the pipeline
  4719. * @type {string}
  4720. */
  4721. LensDepthOfFieldEffect: string;
  4722. private _scene;
  4723. private _depthTexture;
  4724. private _grainTexture;
  4725. private _chromaticAberrationPostProcess;
  4726. private _highlightsPostProcess;
  4727. private _depthOfFieldPostProcess;
  4728. private _edgeBlur;
  4729. private _grainAmount;
  4730. private _chromaticAberration;
  4731. private _distortion;
  4732. private _highlightsGain;
  4733. private _highlightsThreshold;
  4734. private _dofDistance;
  4735. private _dofAperture;
  4736. private _dofDarken;
  4737. private _dofPentagon;
  4738. private _blurNoise;
  4739. /**
  4740. * @constructor
  4741. *
  4742. * Effect parameters are as follow:
  4743. * {
  4744. * chromatic_aberration: number; // from 0 to x (1 for realism)
  4745. * edge_blur: number; // from 0 to x (1 for realism)
  4746. * distortion: number; // from 0 to x (1 for realism)
  4747. * grain_amount: number; // from 0 to 1
  4748. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  4749. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  4750. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  4751. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  4752. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  4753. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  4754. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  4755. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  4756. * }
  4757. * Note: if an effect parameter is unset, effect is disabled
  4758. *
  4759. * @param {string} name - The rendering pipeline name
  4760. * @param {object} parameters - An object containing all parameters (see above)
  4761. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  4762. * @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)
  4763. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  4764. */
  4765. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  4766. setEdgeBlur(amount: number): void;
  4767. disableEdgeBlur(): void;
  4768. setGrainAmount(amount: number): void;
  4769. disableGrain(): void;
  4770. setChromaticAberration(amount: number): void;
  4771. disableChromaticAberration(): void;
  4772. setEdgeDistortion(amount: number): void;
  4773. disableEdgeDistortion(): void;
  4774. setFocusDistance(amount: number): void;
  4775. disableDepthOfField(): void;
  4776. setAperture(amount: number): void;
  4777. setDarkenOutOfFocus(amount: number): void;
  4778. enablePentagonBokeh(): void;
  4779. disablePentagonBokeh(): void;
  4780. enableNoiseBlur(): void;
  4781. disableNoiseBlur(): void;
  4782. setHighlightsGain(amount: number): void;
  4783. setHighlightsThreshold(amount: number): void;
  4784. disableHighlights(): void;
  4785. /**
  4786. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  4787. */
  4788. dispose(disableDepthRender?: boolean): void;
  4789. private _createChromaticAberrationPostProcess(ratio);
  4790. private _createHighlightsPostProcess(ratio);
  4791. private _createDepthOfFieldPostProcess(ratio);
  4792. private _createGrainTexture();
  4793. }
  4794. }
  4795. declare module BABYLON {
  4796. class PassPostProcess extends PostProcess {
  4797. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4798. }
  4799. }
  4800. declare module BABYLON {
  4801. class PostProcess {
  4802. name: string;
  4803. onApply: (effect: Effect) => void;
  4804. onBeforeRender: (effect: Effect) => void;
  4805. onSizeChanged: () => void;
  4806. onActivate: (camera: Camera) => void;
  4807. width: number;
  4808. height: number;
  4809. renderTargetSamplingMode: number;
  4810. clearColor: Color4;
  4811. private _camera;
  4812. private _scene;
  4813. private _engine;
  4814. private _renderRatio;
  4815. private _reusable;
  4816. _textures: SmartArray<WebGLTexture>;
  4817. _currentRenderTextureInd: number;
  4818. private _effect;
  4819. constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string);
  4820. isReusable(): boolean;
  4821. activate(camera: Camera, sourceTexture?: WebGLTexture): void;
  4822. apply(): Effect;
  4823. dispose(camera?: Camera): void;
  4824. }
  4825. }
  4826. declare module BABYLON {
  4827. class PostProcessManager {
  4828. private _scene;
  4829. private _indexBuffer;
  4830. private _vertexDeclaration;
  4831. private _vertexStrideSize;
  4832. private _vertexBuffer;
  4833. constructor(scene: Scene);
  4834. private _prepareBuffers();
  4835. _prepareFrame(sourceTexture?: WebGLTexture): boolean;
  4836. directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void;
  4837. _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void;
  4838. dispose(): void;
  4839. }
  4840. }
  4841. declare module BABYLON {
  4842. class RefractionPostProcess extends PostProcess {
  4843. color: Color3;
  4844. depth: number;
  4845. colorLevel: number;
  4846. private _refRexture;
  4847. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4848. dispose(camera: Camera): void;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  4853. /**
  4854. * The PassPostProcess id in the pipeline that contains the original scene color
  4855. * @type {string}
  4856. */
  4857. SSAOOriginalSceneColorEffect: string;
  4858. /**
  4859. * The SSAO PostProcess id in the pipeline
  4860. * @type {string}
  4861. */
  4862. SSAORenderEffect: string;
  4863. /**
  4864. * The horizontal blur PostProcess id in the pipeline
  4865. * @type {string}
  4866. */
  4867. SSAOBlurHRenderEffect: string;
  4868. /**
  4869. * The vertical blur PostProcess id in the pipeline
  4870. * @type {string}
  4871. */
  4872. SSAOBlurVRenderEffect: string;
  4873. /**
  4874. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  4875. * @type {string}
  4876. */
  4877. SSAOCombineRenderEffect: string;
  4878. /**
  4879. * The output strength of the SSAO post-process. Default value is 1.0.
  4880. * @type {number}
  4881. */
  4882. totalStrength: number;
  4883. /**
  4884. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0002
  4885. * @type {number}
  4886. */
  4887. radius: number;
  4888. /**
  4889. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  4890. * Must not be equal to fallOff and superior to fallOff.
  4891. * Default value is 0.0075
  4892. * @type {number}
  4893. */
  4894. area: number;
  4895. /**
  4896. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  4897. * Must not be equal to area and inferior to area.
  4898. * Default value is 0.0002
  4899. * @type {number}
  4900. */
  4901. fallOff: number;
  4902. private _scene;
  4903. private _depthTexture;
  4904. private _randomTexture;
  4905. private _originalColorPostProcess;
  4906. private _ssaoPostProcess;
  4907. private _blurHPostProcess;
  4908. private _blurVPostProcess;
  4909. private _ssaoCombinePostProcess;
  4910. private _firstUpdate;
  4911. /**
  4912. * @constructor
  4913. * @param {string} name - The rendering pipeline name
  4914. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  4915. * @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 }
  4916. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  4917. */
  4918. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  4919. /**
  4920. * Returns the horizontal blur PostProcess
  4921. * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
  4922. */
  4923. getBlurHPostProcess(): BlurPostProcess;
  4924. /**
  4925. * Returns the vertical blur PostProcess
  4926. * @return {BABYLON.BlurPostProcess} The vertical blur post-process
  4927. */
  4928. getBlurVPostProcess(): BlurPostProcess;
  4929. /**
  4930. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  4931. */
  4932. dispose(disableDepthRender?: boolean): void;
  4933. private _createSSAOPostProcess(ratio);
  4934. private _createSSAOCombinePostProcess(ratio);
  4935. private _createRandomTexture();
  4936. }
  4937. }
  4938. declare module BABYLON {
  4939. class StereogramInterlacePostProcess extends PostProcess {
  4940. private _stepSize;
  4941. constructor(name: string, camB: Camera, postProcessA: PostProcess, isStereogramHoriz: boolean, samplingMode?: number);
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. class StereoscopicInterlacePostProcess extends PostProcess {
  4946. private _stepSize;
  4947. constructor(name: string, camB: Camera, postProcessA: PostProcess, isStereoscopicHoriz: boolean, samplingMode?: number);
  4948. }
  4949. }
  4950. declare module BABYLON {
  4951. class VolumetricLightScatteringPostProcess extends PostProcess {
  4952. private _volumetricLightScatteringPass;
  4953. private _volumetricLightScatteringRTT;
  4954. private _viewPort;
  4955. private _screenCoordinates;
  4956. private _cachedDefines;
  4957. private _customMeshPosition;
  4958. /**
  4959. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  4960. * @type {boolean}
  4961. */
  4962. useCustomMeshPosition: boolean;
  4963. /**
  4964. * If the post-process should inverse the light scattering direction
  4965. * @type {boolean}
  4966. */
  4967. invert: boolean;
  4968. /**
  4969. * The internal mesh used by the post-process
  4970. * @type {boolean}
  4971. */
  4972. mesh: Mesh;
  4973. /**
  4974. * Set to true to use the diffuseColor instead of the diffuseTexture
  4975. * @type {boolean}
  4976. */
  4977. useDiffuseColor: boolean;
  4978. /**
  4979. * Array containing the excluded meshes not rendered in the internal pass
  4980. */
  4981. excludedMeshes: AbstractMesh[];
  4982. exposure: number;
  4983. decay: number;
  4984. weight: number;
  4985. density: number;
  4986. /**
  4987. * @constructor
  4988. * @param {string} name - The post-process name
  4989. * @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)
  4990. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  4991. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  4992. * @param {number} samples - The post-process quality, default 100
  4993. * @param {number} samplingMode - The post-process filtering mode
  4994. * @param {BABYLON.Engine} engine - The babylon engine
  4995. * @param {boolean} reusable - If the post-process is reusable
  4996. */
  4997. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4998. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  4999. /**
  5000. * Sets the new light position for light scattering effect
  5001. * @param {BABYLON.Vector3} The new custom light position
  5002. */
  5003. setCustomMeshPosition(position: Vector3): void;
  5004. /**
  5005. * Returns the light position for light scattering effect
  5006. * @return {BABYLON.Vector3} The custom light position
  5007. */
  5008. getCustomMeshPosition(): Vector3;
  5009. /**
  5010. * Disposes the internal assets and detaches the post-process from the camera
  5011. */
  5012. dispose(camera: Camera): void;
  5013. /**
  5014. * Returns the render target texture used by the post-process
  5015. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  5016. */
  5017. getPass(): RenderTargetTexture;
  5018. private _meshExcluded(mesh);
  5019. private _createPass(scene, ratio);
  5020. private _updateMeshScreenCoordinates(scene);
  5021. /**
  5022. * Creates a default mesh for the Volumeric Light Scattering post-process
  5023. * @param {string} The mesh name
  5024. * @param {BABYLON.Scene} The scene where to create the mesh
  5025. * @return {BABYLON.Mesh} the default mesh
  5026. */
  5027. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  5028. }
  5029. }
  5030. declare module BABYLON {
  5031. class VRDistortionCorrectionPostProcess extends PostProcess {
  5032. aspectRatio: number;
  5033. private _isRightEye;
  5034. private _distortionFactors;
  5035. private _postProcessScaleFactor;
  5036. private _lensCenterOffset;
  5037. private _scaleIn;
  5038. private _scaleFactor;
  5039. private _lensCenter;
  5040. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  5041. }
  5042. }
  5043. declare module BABYLON {
  5044. class PostProcessRenderEffect {
  5045. private _engine;
  5046. private _postProcesses;
  5047. private _getPostProcess;
  5048. private _singleInstance;
  5049. private _cameras;
  5050. private _indicesForCamera;
  5051. private _renderPasses;
  5052. private _renderEffectAsPasses;
  5053. _name: string;
  5054. applyParameters: (postProcess: PostProcess) => void;
  5055. constructor(engine: Engine, name: string, getPostProcess: () => PostProcess, singleInstance?: boolean);
  5056. _update(): void;
  5057. addPass(renderPass: PostProcessRenderPass): void;
  5058. removePass(renderPass: PostProcessRenderPass): void;
  5059. addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void;
  5060. getPass(passName: string): void;
  5061. emptyPasses(): void;
  5062. _attachCameras(cameras: Camera): any;
  5063. _attachCameras(cameras: Camera[]): any;
  5064. _detachCameras(cameras: Camera): any;
  5065. _detachCameras(cameras: Camera[]): any;
  5066. _enable(cameras: Camera): any;
  5067. _enable(cameras: Camera[]): any;
  5068. _disable(cameras: Camera): any;
  5069. _disable(cameras: Camera[]): any;
  5070. getPostProcess(camera?: Camera): PostProcess;
  5071. private _linkParameters();
  5072. private _linkTextures(effect);
  5073. }
  5074. }
  5075. declare module BABYLON {
  5076. class PostProcessRenderPass {
  5077. private _enabled;
  5078. private _renderList;
  5079. private _renderTexture;
  5080. private _scene;
  5081. private _refCount;
  5082. _name: string;
  5083. constructor(scene: Scene, name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void);
  5084. _incRefCount(): number;
  5085. _decRefCount(): number;
  5086. _update(): void;
  5087. setRenderList(renderList: Mesh[]): void;
  5088. getRenderTexture(): RenderTargetTexture;
  5089. }
  5090. }
  5091. declare module BABYLON {
  5092. class PostProcessRenderPipeline {
  5093. private _engine;
  5094. private _renderEffects;
  5095. private _renderEffectsForIsolatedPass;
  5096. private _cameras;
  5097. _name: string;
  5098. private static PASS_EFFECT_NAME;
  5099. private static PASS_SAMPLER_NAME;
  5100. constructor(engine: Engine, name: string);
  5101. addEffect(renderEffect: PostProcessRenderEffect): void;
  5102. _enableEffect(renderEffectName: string, cameras: Camera): any;
  5103. _enableEffect(renderEffectName: string, cameras: Camera[]): any;
  5104. _disableEffect(renderEffectName: string, cameras: Camera): any;
  5105. _disableEffect(renderEffectName: string, cameras: Camera[]): any;
  5106. _attachCameras(cameras: Camera, unique: boolean): any;
  5107. _attachCameras(cameras: Camera[], unique: boolean): any;
  5108. _detachCameras(cameras: Camera): any;
  5109. _detachCameras(cameras: Camera[]): any;
  5110. _enableDisplayOnlyPass(passName: any, cameras: Camera): any;
  5111. _enableDisplayOnlyPass(passName: any, cameras: Camera[]): any;
  5112. _disableDisplayOnlyPass(cameras: Camera): any;
  5113. _disableDisplayOnlyPass(cameras: Camera[]): any;
  5114. _update(): void;
  5115. }
  5116. }
  5117. declare module BABYLON {
  5118. class PostProcessRenderPipelineManager {
  5119. private _renderPipelines;
  5120. constructor();
  5121. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  5122. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): any;
  5123. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): any;
  5124. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): any;
  5125. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): any;
  5126. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  5127. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  5128. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  5129. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  5130. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera): any;
  5131. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera[]): any;
  5132. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera): any;
  5133. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera[]): any;
  5134. update(): void;
  5135. }
  5136. }
  5137. declare module BABYLON {
  5138. class BoundingBoxRenderer {
  5139. frontColor: Color3;
  5140. backColor: Color3;
  5141. showBackLines: boolean;
  5142. renderList: SmartArray<BoundingBox>;
  5143. private _scene;
  5144. private _colorShader;
  5145. private _vb;
  5146. private _ib;
  5147. constructor(scene: Scene);
  5148. private _prepareRessources();
  5149. reset(): void;
  5150. render(): void;
  5151. dispose(): void;
  5152. }
  5153. }
  5154. declare module BABYLON {
  5155. class DepthRenderer {
  5156. private _scene;
  5157. private _depthMap;
  5158. private _effect;
  5159. private _viewMatrix;
  5160. private _projectionMatrix;
  5161. private _transformMatrix;
  5162. private _worldViewProjection;
  5163. private _cachedDefines;
  5164. constructor(scene: Scene, type?: number);
  5165. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5166. getDepthMap(): RenderTargetTexture;
  5167. dispose(): void;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. class OutlineRenderer {
  5172. private _scene;
  5173. private _effect;
  5174. private _cachedDefines;
  5175. constructor(scene: Scene);
  5176. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  5177. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5178. }
  5179. }
  5180. declare module BABYLON {
  5181. class RenderingGroup {
  5182. index: number;
  5183. private _scene;
  5184. private _opaqueSubMeshes;
  5185. private _transparentSubMeshes;
  5186. private _alphaTestSubMeshes;
  5187. private _activeVertices;
  5188. constructor(index: number, scene: Scene);
  5189. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void): boolean;
  5190. prepare(): void;
  5191. dispatch(subMesh: SubMesh): void;
  5192. }
  5193. }
  5194. declare module BABYLON {
  5195. class RenderingManager {
  5196. static MAX_RENDERINGGROUPS: number;
  5197. private _scene;
  5198. private _renderingGroups;
  5199. private _depthBufferAlreadyCleaned;
  5200. constructor(scene: Scene);
  5201. private _renderParticles(index, activeMeshes);
  5202. private _renderSprites(index);
  5203. private _clearDepthBuffer();
  5204. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void;
  5205. reset(): void;
  5206. dispatch(subMesh: SubMesh): void;
  5207. }
  5208. }
  5209. declare module BABYLON {
  5210. class Sprite {
  5211. name: string;
  5212. position: Vector3;
  5213. color: Color4;
  5214. width: number;
  5215. height: number;
  5216. angle: number;
  5217. cellIndex: number;
  5218. invertU: number;
  5219. invertV: number;
  5220. disposeWhenFinishedAnimating: boolean;
  5221. animations: Animation[];
  5222. private _animationStarted;
  5223. private _loopAnimation;
  5224. private _fromIndex;
  5225. private _toIndex;
  5226. private _delay;
  5227. private _direction;
  5228. private _frameCount;
  5229. private _manager;
  5230. private _time;
  5231. size: number;
  5232. constructor(name: string, manager: SpriteManager);
  5233. playAnimation(from: number, to: number, loop: boolean, delay: number): void;
  5234. stopAnimation(): void;
  5235. _animate(deltaTime: number): void;
  5236. dispose(): void;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. class SpriteManager {
  5241. name: string;
  5242. cellSize: number;
  5243. sprites: Sprite[];
  5244. renderingGroupId: number;
  5245. onDispose: () => void;
  5246. fogEnabled: boolean;
  5247. private _capacity;
  5248. private _spriteTexture;
  5249. private _epsilon;
  5250. private _scene;
  5251. private _vertexDeclaration;
  5252. private _vertexStrideSize;
  5253. private _vertexBuffer;
  5254. private _indexBuffer;
  5255. private _vertices;
  5256. private _effectBase;
  5257. private _effectFog;
  5258. constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon?: number, samplingMode?: number);
  5259. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  5260. render(): void;
  5261. dispose(): void;
  5262. }
  5263. }
  5264. declare module BABYLON.Internals {
  5265. class AndOrNotEvaluator {
  5266. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5267. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  5268. private static _SimplifyNegation(booleanString);
  5269. }
  5270. }
  5271. declare module BABYLON {
  5272. interface IAssetTask {
  5273. onSuccess: (task: IAssetTask) => void;
  5274. onError: (task: IAssetTask) => void;
  5275. isCompleted: boolean;
  5276. run(scene: Scene, onSuccess: () => void, onError: () => void): any;
  5277. }
  5278. class MeshAssetTask implements IAssetTask {
  5279. name: string;
  5280. meshesNames: any;
  5281. rootUrl: string;
  5282. sceneFilename: string;
  5283. loadedMeshes: Array<AbstractMesh>;
  5284. loadedParticleSystems: Array<ParticleSystem>;
  5285. loadedSkeletons: Array<Skeleton>;
  5286. onSuccess: (task: IAssetTask) => void;
  5287. onError: (task: IAssetTask) => void;
  5288. isCompleted: boolean;
  5289. constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string);
  5290. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5291. }
  5292. class TextFileAssetTask implements IAssetTask {
  5293. name: string;
  5294. url: string;
  5295. onSuccess: (task: IAssetTask) => void;
  5296. onError: (task: IAssetTask) => void;
  5297. isCompleted: boolean;
  5298. text: string;
  5299. constructor(name: string, url: string);
  5300. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5301. }
  5302. class BinaryFileAssetTask implements IAssetTask {
  5303. name: string;
  5304. url: string;
  5305. onSuccess: (task: IAssetTask) => void;
  5306. onError: (task: IAssetTask) => void;
  5307. isCompleted: boolean;
  5308. data: ArrayBuffer;
  5309. constructor(name: string, url: string);
  5310. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5311. }
  5312. class ImageAssetTask implements IAssetTask {
  5313. name: string;
  5314. url: string;
  5315. onSuccess: (task: IAssetTask) => void;
  5316. onError: (task: IAssetTask) => void;
  5317. isCompleted: boolean;
  5318. image: HTMLImageElement;
  5319. constructor(name: string, url: string);
  5320. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5321. }
  5322. class TextureAssetTask implements IAssetTask {
  5323. name: string;
  5324. url: string;
  5325. noMipmap: boolean;
  5326. invertY: boolean;
  5327. samplingMode: number;
  5328. onSuccess: (task: IAssetTask) => void;
  5329. onError: (task: IAssetTask) => void;
  5330. isCompleted: boolean;
  5331. texture: Texture;
  5332. constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number);
  5333. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5334. }
  5335. class AssetsManager {
  5336. private _tasks;
  5337. private _scene;
  5338. private _waitingTasksCount;
  5339. onFinish: (tasks: IAssetTask[]) => void;
  5340. onTaskSuccess: (task: IAssetTask) => void;
  5341. onTaskError: (task: IAssetTask) => void;
  5342. useDefaultLoadingScreen: boolean;
  5343. constructor(scene: Scene);
  5344. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask;
  5345. addTextFileTask(taskName: string, url: string): IAssetTask;
  5346. addBinaryFileTask(taskName: string, url: string): IAssetTask;
  5347. addImageTask(taskName: string, url: string): IAssetTask;
  5348. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): IAssetTask;
  5349. private _decreaseWaitingTasksCount();
  5350. private _runTask(task);
  5351. reset(): AssetsManager;
  5352. load(): AssetsManager;
  5353. }
  5354. }
  5355. declare module BABYLON {
  5356. class Database {
  5357. private callbackManifestChecked;
  5358. private currentSceneUrl;
  5359. private db;
  5360. private enableSceneOffline;
  5361. private enableTexturesOffline;
  5362. private manifestVersionFound;
  5363. private mustUpdateRessources;
  5364. private hasReachedQuota;
  5365. private isSupported;
  5366. private idbFactory;
  5367. static IsUASupportingBlobStorage: boolean;
  5368. static IDBStorageEnabled: boolean;
  5369. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  5370. static parseURL: (url: string) => string;
  5371. static ReturnFullUrlLocation: (url: string) => string;
  5372. checkManifestFile(): void;
  5373. openAsync(successCallback: any, errorCallback: any): void;
  5374. loadImageFromDB(url: string, image: HTMLImageElement): void;
  5375. private _loadImageFromDBAsync(url, image, notInDBCallback);
  5376. private _saveImageIntoDBAsync(url, image);
  5377. private _checkVersionFromDB(url, versionLoaded);
  5378. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  5379. private _saveVersionIntoDBAsync(url, callback);
  5380. private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?);
  5381. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  5382. private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?);
  5383. }
  5384. }
  5385. declare module BABYLON {
  5386. class FilesInput {
  5387. private _engine;
  5388. private _currentScene;
  5389. private _canvas;
  5390. private _sceneLoadedCallback;
  5391. private _progressCallback;
  5392. private _additionnalRenderLoopLogicCallback;
  5393. private _textureLoadingCallback;
  5394. private _startingProcessingFilesCallback;
  5395. private _elementToMonitor;
  5396. static FilesTextures: any[];
  5397. static FilesToLoad: any[];
  5398. private _sceneFileToLoad;
  5399. private _filesToLoad;
  5400. 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);
  5401. monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void;
  5402. private renderFunction();
  5403. private drag(e);
  5404. private drop(eventDrop);
  5405. loadFiles(event: any): void;
  5406. reload(): void;
  5407. }
  5408. }
  5409. declare module BABYLON {
  5410. class Gamepads {
  5411. private babylonGamepads;
  5412. private oneGamepadConnected;
  5413. private isMonitoring;
  5414. private gamepadEventSupported;
  5415. private gamepadSupportAvailable;
  5416. private _callbackGamepadConnected;
  5417. private buttonADataURL;
  5418. private static gamepadDOMInfo;
  5419. constructor(ongamedpadconnected: (gamepad: Gamepad) => void);
  5420. private _insertGamepadDOMInstructions();
  5421. private _insertGamepadDOMNotSupported();
  5422. dispose(): void;
  5423. private _onGamepadConnected(evt);
  5424. private _addNewGamepad(gamepad);
  5425. private _onGamepadDisconnected(evt);
  5426. private _startMonitoringGamepads();
  5427. private _stopMonitoringGamepads();
  5428. private _checkGamepadsStatus();
  5429. private _updateGamepadObjects();
  5430. }
  5431. class StickValues {
  5432. x: any;
  5433. y: any;
  5434. constructor(x: any, y: any);
  5435. }
  5436. class Gamepad {
  5437. id: string;
  5438. index: number;
  5439. browserGamepad: any;
  5440. private _leftStick;
  5441. private _rightStick;
  5442. private _onleftstickchanged;
  5443. private _onrightstickchanged;
  5444. constructor(id: string, index: number, browserGamepad: any);
  5445. onleftstickchanged(callback: (values: StickValues) => void): void;
  5446. onrightstickchanged(callback: (values: StickValues) => void): void;
  5447. leftStick: StickValues;
  5448. rightStick: StickValues;
  5449. update(): void;
  5450. }
  5451. class GenericPad extends Gamepad {
  5452. id: string;
  5453. index: number;
  5454. gamepad: any;
  5455. private _buttons;
  5456. private _onbuttondown;
  5457. private _onbuttonup;
  5458. onbuttondown(callback: (buttonPressed: number) => void): void;
  5459. onbuttonup(callback: (buttonReleased: number) => void): void;
  5460. constructor(id: string, index: number, gamepad: any);
  5461. private _setButtonValue(newValue, currentValue, buttonIndex);
  5462. update(): void;
  5463. }
  5464. enum Xbox360Button {
  5465. A = 0,
  5466. B = 1,
  5467. X = 2,
  5468. Y = 3,
  5469. Start = 4,
  5470. Back = 5,
  5471. LB = 6,
  5472. RB = 7,
  5473. LeftStick = 8,
  5474. RightStick = 9,
  5475. }
  5476. enum Xbox360Dpad {
  5477. Up = 0,
  5478. Down = 1,
  5479. Left = 2,
  5480. Right = 3,
  5481. }
  5482. class Xbox360Pad extends Gamepad {
  5483. private _leftTrigger;
  5484. private _rightTrigger;
  5485. private _onlefttriggerchanged;
  5486. private _onrighttriggerchanged;
  5487. private _onbuttondown;
  5488. private _onbuttonup;
  5489. private _ondpaddown;
  5490. private _ondpadup;
  5491. private _buttonA;
  5492. private _buttonB;
  5493. private _buttonX;
  5494. private _buttonY;
  5495. private _buttonBack;
  5496. private _buttonStart;
  5497. private _buttonLB;
  5498. private _buttonRB;
  5499. private _buttonLeftStick;
  5500. private _buttonRightStick;
  5501. private _dPadUp;
  5502. private _dPadDown;
  5503. private _dPadLeft;
  5504. private _dPadRight;
  5505. onlefttriggerchanged(callback: (value: number) => void): void;
  5506. onrighttriggerchanged(callback: (value: number) => void): void;
  5507. leftTrigger: number;
  5508. rightTrigger: number;
  5509. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5510. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5511. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5512. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5513. private _setButtonValue(newValue, currentValue, buttonType);
  5514. private _setDPadValue(newValue, currentValue, buttonType);
  5515. buttonA: number;
  5516. buttonB: number;
  5517. buttonX: number;
  5518. buttonY: number;
  5519. buttonStart: number;
  5520. buttonBack: number;
  5521. buttonLB: number;
  5522. buttonRB: number;
  5523. buttonLeftStick: number;
  5524. buttonRightStick: number;
  5525. dPadUp: number;
  5526. dPadDown: number;
  5527. dPadLeft: number;
  5528. dPadRight: number;
  5529. update(): void;
  5530. }
  5531. }
  5532. interface Navigator {
  5533. getGamepads(func?: any): any;
  5534. webkitGetGamepads(func?: any): any;
  5535. msGetGamepads(func?: any): any;
  5536. webkitGamepads(func?: any): any;
  5537. }
  5538. declare module BABYLON {
  5539. class SceneOptimization {
  5540. priority: number;
  5541. apply: (scene: Scene) => boolean;
  5542. constructor(priority?: number);
  5543. }
  5544. class TextureOptimization extends SceneOptimization {
  5545. priority: number;
  5546. maximumSize: number;
  5547. constructor(priority?: number, maximumSize?: number);
  5548. apply: (scene: Scene) => boolean;
  5549. }
  5550. class HardwareScalingOptimization extends SceneOptimization {
  5551. priority: number;
  5552. maximumScale: number;
  5553. private _currentScale;
  5554. constructor(priority?: number, maximumScale?: number);
  5555. apply: (scene: Scene) => boolean;
  5556. }
  5557. class ShadowsOptimization extends SceneOptimization {
  5558. apply: (scene: Scene) => boolean;
  5559. }
  5560. class PostProcessesOptimization extends SceneOptimization {
  5561. apply: (scene: Scene) => boolean;
  5562. }
  5563. class LensFlaresOptimization extends SceneOptimization {
  5564. apply: (scene: Scene) => boolean;
  5565. }
  5566. class ParticlesOptimization extends SceneOptimization {
  5567. apply: (scene: Scene) => boolean;
  5568. }
  5569. class RenderTargetsOptimization extends SceneOptimization {
  5570. apply: (scene: Scene) => boolean;
  5571. }
  5572. class MergeMeshesOptimization extends SceneOptimization {
  5573. private _canBeMerged;
  5574. apply: (scene: Scene) => boolean;
  5575. }
  5576. class SceneOptimizerOptions {
  5577. targetFrameRate: number;
  5578. trackerDuration: number;
  5579. optimizations: SceneOptimization[];
  5580. constructor(targetFrameRate?: number, trackerDuration?: number);
  5581. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5582. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5583. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5584. }
  5585. class SceneOptimizer {
  5586. static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void;
  5587. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void;
  5588. }
  5589. }
  5590. declare module BABYLON {
  5591. class SceneSerializer {
  5592. static Serialize(scene: Scene): any;
  5593. }
  5594. }
  5595. declare module BABYLON {
  5596. class SmartArray<T> {
  5597. data: Array<T>;
  5598. length: number;
  5599. private _id;
  5600. private _duplicateId;
  5601. constructor(capacity: number);
  5602. push(value: any): void;
  5603. pushNoDuplicate(value: any): void;
  5604. sort(compareFn: any): void;
  5605. reset(): void;
  5606. concat(array: any): void;
  5607. concatWithNoDuplicate(array: any): void;
  5608. indexOf(value: any): number;
  5609. private static _GlobalId;
  5610. }
  5611. }
  5612. declare module BABYLON {
  5613. class SmartCollection {
  5614. count: number;
  5615. items: any;
  5616. private _keys;
  5617. private _initialCapacity;
  5618. constructor(capacity?: number);
  5619. add(key: any, item: any): number;
  5620. remove(key: any): number;
  5621. removeItemOfIndex(index: number): number;
  5622. indexOf(key: any): number;
  5623. item(key: any): any;
  5624. getAllKeys(): any[];
  5625. getKeyByIndex(index: number): any;
  5626. getItemByIndex(index: number): any;
  5627. empty(): void;
  5628. forEach(block: (item: any) => void): void;
  5629. }
  5630. }
  5631. declare module BABYLON {
  5632. class Tags {
  5633. static EnableFor(obj: any): void;
  5634. static DisableFor(obj: any): void;
  5635. static HasTags(obj: any): boolean;
  5636. static GetTags(obj: any): any;
  5637. static AddTagsTo(obj: any, tagsString: string): void;
  5638. static _AddTagTo(obj: any, tag: string): void;
  5639. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5640. static _RemoveTagFrom(obj: any, tag: string): void;
  5641. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5642. }
  5643. }
  5644. declare module BABYLON {
  5645. interface IAnimatable {
  5646. animations: Array<Animation>;
  5647. }
  5648. interface ISize {
  5649. width: number;
  5650. height: number;
  5651. }
  5652. class Tools {
  5653. static BaseUrl: string;
  5654. static SetImmediate(action: () => void): void;
  5655. static IsExponantOfTwo(value: number): boolean;
  5656. static GetExponantOfTwo(value: number, max: number): number;
  5657. static GetFilename(path: string): string;
  5658. static GetDOMTextContent(element: HTMLElement): string;
  5659. static ToDegrees(angle: number): number;
  5660. static ToRadians(angle: number): number;
  5661. static ExtractMinAndMaxIndexed(positions: number[], indices: number[], indexStart: number, indexCount: number): {
  5662. minimum: Vector3;
  5663. maximum: Vector3;
  5664. };
  5665. static ExtractMinAndMax(positions: number[], start: number, count: number): {
  5666. minimum: Vector3;
  5667. maximum: Vector3;
  5668. };
  5669. static MakeArray(obj: any, allowsNullUndefined?: boolean): Array<any>;
  5670. static GetPointerPrefix(): string;
  5671. static QueueNewFrame(func: any): void;
  5672. static RequestFullscreen(element: any): void;
  5673. static ExitFullscreen(): void;
  5674. static CleanUrl(url: string): string;
  5675. static LoadImage(url: string, onload: any, onerror: any, database: any): HTMLImageElement;
  5676. static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?: any, useArrayBuffer?: boolean, onError?: () => void): void;
  5677. static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void;
  5678. static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void;
  5679. static Clamp(value: number, min?: number, max?: number): number;
  5680. static Sign(value: number): number;
  5681. static Format(value: number, decimals?: number): string;
  5682. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  5683. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  5684. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5685. static IsEmpty(obj: any): boolean;
  5686. static RegisterTopRootEvents(events: {
  5687. name: string;
  5688. handler: EventListener;
  5689. }[]): void;
  5690. static UnregisterTopRootEvents(events: {
  5691. name: string;
  5692. handler: EventListener;
  5693. }[]): void;
  5694. static DumpFramebuffer(width: number, height: number, engine: Engine): void;
  5695. static CreateScreenshot(engine: Engine, camera: Camera, size: any): void;
  5696. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  5697. private static _NoneLogLevel;
  5698. private static _MessageLogLevel;
  5699. private static _WarningLogLevel;
  5700. private static _ErrorLogLevel;
  5701. private static _LogCache;
  5702. static OnNewCacheEntry: (entry: string) => void;
  5703. static NoneLogLevel: number;
  5704. static MessageLogLevel: number;
  5705. static WarningLogLevel: number;
  5706. static ErrorLogLevel: number;
  5707. static AllLogLevel: number;
  5708. private static _AddLogEntry(entry);
  5709. private static _FormatMessage(message);
  5710. static Log: (message: string) => void;
  5711. private static _LogDisabled(message);
  5712. private static _LogEnabled(message);
  5713. static Warn: (message: string) => void;
  5714. private static _WarnDisabled(message);
  5715. private static _WarnEnabled(message);
  5716. static Error: (message: string) => void;
  5717. private static _ErrorDisabled(message);
  5718. private static _ErrorEnabled(message);
  5719. static LogCache: string;
  5720. static LogLevels: number;
  5721. private static _PerformanceNoneLogLevel;
  5722. private static _PerformanceUserMarkLogLevel;
  5723. private static _PerformanceConsoleLogLevel;
  5724. private static _performance;
  5725. static PerformanceNoneLogLevel: number;
  5726. static PerformanceUserMarkLogLevel: number;
  5727. static PerformanceConsoleLogLevel: number;
  5728. static PerformanceLogLevel: number;
  5729. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  5730. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  5731. static _StartUserMark(counterName: string, condition?: boolean): void;
  5732. static _EndUserMark(counterName: string, condition?: boolean): void;
  5733. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  5734. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  5735. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  5736. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  5737. static Now: number;
  5738. static GetFps(): number;
  5739. }
  5740. /**
  5741. * An implementation of a loop for asynchronous functions.
  5742. */
  5743. class AsyncLoop {
  5744. iterations: number;
  5745. private _fn;
  5746. private _successCallback;
  5747. index: number;
  5748. private _done;
  5749. /**
  5750. * Constroctor.
  5751. * @param iterations the number of iterations.
  5752. * @param _fn the function to run each iteration
  5753. * @param _successCallback the callback that will be called upon succesful execution
  5754. * @param offset starting offset.
  5755. */
  5756. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  5757. /**
  5758. * Execute the next iteration. Must be called after the last iteration was finished.
  5759. */
  5760. executeNext(): void;
  5761. /**
  5762. * Break the loop and run the success callback.
  5763. */
  5764. breakLoop(): void;
  5765. /**
  5766. * Helper function
  5767. */
  5768. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  5769. /**
  5770. * A for-loop that will run a given number of iterations synchronous and the rest async.
  5771. * @param iterations total number of iterations
  5772. * @param syncedIterations number of synchronous iterations in each async iteration.
  5773. * @param fn the function to call each iteration.
  5774. * @param callback a success call back that will be called when iterating stops.
  5775. * @param breakFunction a break condition (optional)
  5776. * @param timeout timeout settings for the setTimeout function. default - 0.
  5777. * @constructor
  5778. */
  5779. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  5780. }
  5781. }
  5782. declare module BABYLON.Internals {
  5783. interface DDSInfo {
  5784. width: number;
  5785. height: number;
  5786. mipmapCount: number;
  5787. isFourCC: boolean;
  5788. isRGB: boolean;
  5789. isLuminance: boolean;
  5790. isCube: boolean;
  5791. }
  5792. class DDSTools {
  5793. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  5794. private static GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5795. private static GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5796. private static GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5797. static UploadDDSLevels(gl: WebGLRenderingContext, ext: any, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number): void;
  5798. }
  5799. }
  5800. declare module BABYLON.Internals {
  5801. class TGATools {
  5802. private static _TYPE_NO_DATA;
  5803. private static _TYPE_INDEXED;
  5804. private static _TYPE_RGB;
  5805. private static _TYPE_GREY;
  5806. private static _TYPE_RLE_INDEXED;
  5807. private static _TYPE_RLE_RGB;
  5808. private static _TYPE_RLE_GREY;
  5809. private static _ORIGIN_MASK;
  5810. private static _ORIGIN_SHIFT;
  5811. private static _ORIGIN_BL;
  5812. private static _ORIGIN_BR;
  5813. private static _ORIGIN_UL;
  5814. private static _ORIGIN_UR;
  5815. static GetTGAHeader(data: Uint8Array): any;
  5816. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  5817. 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;
  5818. 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;
  5819. 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;
  5820. 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;
  5821. 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;
  5822. 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;
  5823. }
  5824. }
  5825. declare module BABYLON {
  5826. enum JoystickAxis {
  5827. X = 0,
  5828. Y = 1,
  5829. Z = 2,
  5830. }
  5831. class VirtualJoystick {
  5832. reverseLeftRight: boolean;
  5833. reverseUpDown: boolean;
  5834. deltaPosition: Vector3;
  5835. pressed: boolean;
  5836. private static _globalJoystickIndex;
  5837. private static vjCanvas;
  5838. private static vjCanvasContext;
  5839. private static vjCanvasWidth;
  5840. private static vjCanvasHeight;
  5841. private static halfWidth;
  5842. private static halfHeight;
  5843. private _action;
  5844. private _axisTargetedByLeftAndRight;
  5845. private _axisTargetedByUpAndDown;
  5846. private _joystickSensibility;
  5847. private _inversedSensibility;
  5848. private _rotationSpeed;
  5849. private _inverseRotationSpeed;
  5850. private _rotateOnAxisRelativeToMesh;
  5851. private _joystickPointerID;
  5852. private _joystickColor;
  5853. private _joystickPointerPos;
  5854. private _joystickPointerStartPos;
  5855. private _deltaJoystickVector;
  5856. private _leftJoystick;
  5857. private _joystickIndex;
  5858. private _touches;
  5859. constructor(leftJoystick?: boolean);
  5860. setJoystickSensibility(newJoystickSensibility: number): void;
  5861. private _onPointerDown(e);
  5862. private _onPointerMove(e);
  5863. private _onPointerUp(e);
  5864. /**
  5865. * Change the color of the virtual joystick
  5866. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  5867. */
  5868. setJoystickColor(newColor: string): void;
  5869. setActionOnTouch(action: () => any): void;
  5870. setAxisForLeftRight(axis: JoystickAxis): void;
  5871. setAxisForUpDown(axis: JoystickAxis): void;
  5872. private _clearCanvas();
  5873. private _drawVirtualJoystick();
  5874. releaseCanvas(): void;
  5875. }
  5876. }