babylon.2.1.d.ts 237 KB

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